@awesomate/sdk
v0.27.0
Published
Your own Awesomate data from Node and the browser: query contacts and app data with generated types, and sign your app's own users in
Readme
@awesomate/sdk
Build apps on your own Awesomate data. Sign your customers in, show them their records as they change, and let them act, with the rules about who sees what kept in your own database.
Docs: https://hub.awesomate.ai/docs/sdk/ (a quickstart, a tutorial that builds a customer portal, guides, and a reference generated from this package's code). For AI tools: llms.txt.
npm install @awesomate/sdkIn a web page: your app's people (Pro and above)
import { createAppClient } from '@awesomate/sdk';
const app = createAppClient({ publishableKey: 'pk_...' }); // not a secret
app.auth.onChange((user) => render(user));
render(await app.auth.user()); // someone already signed in on this device
await app.auth.signInWithLink(email, { redirectTo: location.href });
// As the signed-in person: the database applies the account's rules.
const stop = app.live('job', { orderBy: ['created_at', 'desc'] }, (rows) => render(rows));
await app.call('accept_quote', { job: job.id });On a server: your account's data
import { createClient } from '@awesomate/sdk';
const db = createClient({ token: process.env.AWESOMATE_TOKEN! }); // a secret: never in a browser
const { rows, next } = await db.query('contact', { where: { created_at: { gte: '$YEAR_BEGIN' } }, limit: 50 });
await db.write('job', { title: 'Possum in the roof', status: 'open' }, { links: { customer: rows[0].id } });Types for your own account's kinds, saved queries and recipes:
npx @awesomate/sdk types --out awesomate.d.tsWhat changed
See the changelog.
MIT licence.
