To use the SDK, you’ll first need to generate an access token.
If you haven’t created any users or roles yet, head to the IAM section in the dashboard. Start by creating a role, then create a user and assign the appropriate role(s) to them.
Once your user is set up, go to their API user edit page. From there, you can generate a new secret or create a token for an existing secret by clicking the "Generate secret" button.
const platform = new Platform({
token: // your generated token
})
// now you can
const results = await platform.function().run("hello_world", {text: "Hi!"})
For the beta SDK export (@ptkl/sdk/beta), component model reads support:
cacheTTL (number, seconds) in find optionsonly (string[]) field projection in find filtersconst resp = await platform.component("ecommerce::orders").find(
{
currentPage: 1,
perPage: 20,
only: ["uuid", "status", "total"],
},
{
cacheTTL: 0, // force fresh read
locale: "en_US",
}
)
Thunder read methods support optional only projection fields:
const row = await platform.thunder().findOne("user_settings", { user_id: 42 }, ["theme", "timezone"])