@awesomate/sdk 0.27.0 → 0.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -26,7 +26,7 @@
26
26
  * Docs: https://hub.awesomate.ai/docs/sdk/
27
27
  */
28
28
  /** This package's version, sent to the hub with every server call. */
29
- export declare const VERSION = "0.27.0";
29
+ export declare const VERSION = "0.29.0";
30
30
  /** Augmented by the generated awesomate.d.ts, so each kind's rows are typed. */
31
31
  export interface Kinds {
32
32
  }
@@ -944,6 +944,19 @@ export declare class AwesomateClient {
944
944
  * columns and rows, plus what it assumed.
945
945
  */
946
946
  data: (query: KnowledgeDataQuery) => Promise<Record<string, unknown>>;
947
+ /**
948
+ * A video the owner shared with **Anyone can watch**: its permanent player link and an embed
949
+ * code for a web page. `link` and `embed` are null until the video is shared, and when it is no
950
+ * longer Public (`enabled` true, `watchable` false). Read only: sharing is switched on in the hub
951
+ * or through Claude Code, by an Owner. `title` names the video in the embed code.
952
+ *
953
+ * @example
954
+ * const v = await db.knowledge.video('src-quote-walkthrough', { title: 'How we quote a job' });
955
+ * if (v.watchable && v.embed) console.log(v.embed);
956
+ */
957
+ video: (sourceId: string, options?: {
958
+ title?: string;
959
+ }) => Promise<SharedVideo>;
947
960
  };
948
961
  /**
949
962
  * Tell Contacts something happened to someone ("job_paid", "quote_sent"), so any email series
@@ -2261,6 +2274,17 @@ export interface KnowledgeSearchHit {
2261
2274
  url?: string;
2262
2275
  poster_url?: string;
2263
2276
  }
2277
+ /** A video anyone can watch, from knowledge.video(). */
2278
+ export interface SharedVideo {
2279
+ /** The owner switched Anyone can watch on. */
2280
+ enabled: boolean;
2281
+ /** Switched on and the video still Public: what a viewer gets. */
2282
+ watchable: boolean;
2283
+ /** The permanent player page, on the account's own links. address when it has one; null until shared. */
2284
+ link: string | null;
2285
+ /** An iframe of the player for a web page; null until shared. */
2286
+ embed: string | null;
2287
+ }
2264
2288
  /** What knowledge.search() returns. */
2265
2289
  export interface KnowledgeSearchResult {
2266
2290
  query: string;
@@ -2439,6 +2463,45 @@ export interface VoiceSession {
2439
2463
  }>;
2440
2464
  say_as: Record<string, string>;
2441
2465
  }
2466
+ /** One field on a record page: its value as this person may read it, and whether they may change it. */
2467
+ export interface RecordPageField {
2468
+ key: string;
2469
+ label: string;
2470
+ type: string;
2471
+ value: unknown;
2472
+ change: boolean;
2473
+ }
2474
+ /** One section on a record page, in the order the account set; `folded` sections start closed. */
2475
+ export interface RecordPageSection {
2476
+ key: string;
2477
+ label: string;
2478
+ folded: boolean;
2479
+ fields: RecordPageField[];
2480
+ }
2481
+ /** A record laid out for the signed-in person's app role (`app.recordPage`). */
2482
+ export interface RecordPage {
2483
+ kind: {
2484
+ key: string;
2485
+ label: string;
2486
+ labelPlural: string;
2487
+ };
2488
+ id: string;
2489
+ /** Where it is up to, in the account's words for people outside the team. Null when there are none to show. */
2490
+ stage: {
2491
+ label: string;
2492
+ closed: boolean;
2493
+ } | null;
2494
+ /** Read only from its stage on: nothing on it can be changed. */
2495
+ locked: boolean;
2496
+ /** Whether this person may change the record at all. Each field's `change` says which. */
2497
+ canWrite: boolean;
2498
+ sections: RecordPageSection[];
2499
+ /** Fields the account keeps at the top of the page, in order. */
2500
+ pinned: string[];
2501
+ /** The part of the page it opens on. */
2502
+ tab: 'details' | 'activity' | 'related';
2503
+ asAt: string;
2504
+ }
2442
2505
  /**
2443
2506
  * The browser client for one of the account's apps, from createAppClient(): sign-in is under
2444
2507
  * `auth`, and every data call runs as the signed-in person, inside the account's access rules.
@@ -2525,6 +2588,20 @@ export declare class AwesomateAppClient {
2525
2588
  * else names no record, so it answers null without asking the hub. Pro and above.
2526
2589
  */
2527
2590
  get<K extends KindName>(kind: K, id: string): Promise<RowOf<K> | null>;
2591
+ /**
2592
+ * One record laid out for this person: the sections and fields their app role is shown, in the
2593
+ * order the account set for that role, each field with its value and whether they may change it,
2594
+ * and where the record is up to in the account's own words for people outside the team. Null when
2595
+ * there is no such record this person may read. The database decides every permission; the
2596
+ * account sets the layout on the record page in the hub ("Viewing as", the role "in your apps").
2597
+ * Needs the account's record pages. A locked record says `locked: true`, and a change to it fails
2598
+ * with `forbidden` and `serverCode: 'locked'`.
2599
+ *
2600
+ * @example
2601
+ * const page = await app.recordPage('job', job.id);
2602
+ * for (const section of page?.sections ?? []) console.log(section.label, section.fields.map((f) => f.value));
2603
+ */
2604
+ recordPage<K extends KindName>(kind: K, id: string): Promise<RecordPage | null>;
2528
2605
  /** Create a record (returns its id) or change one with options.id, inside the kind's write rule for this user. Pro and above. */
2529
2606
  write<K extends KindName>(kind: K, data: Partial<RowOf<K>> | Record<string, unknown>, options?: WriteOptions): Promise<string>;
2530
2607
  /** Archive a record, inside the kind's write rule for this person. Pro and above. */
package/dist/index.js CHANGED
@@ -26,7 +26,7 @@
26
26
  * Docs: https://hub.awesomate.ai/docs/sdk/
27
27
  */
28
28
  /** This package's version, sent to the hub with every server call. */
29
- export const VERSION = '0.27.0';
29
+ export const VERSION = '0.29.0';
30
30
  const DEFAULT_BASE = 'https://hub.awesomate.ai';
31
31
  /** Every record and contact id is a UUID; anything else can name no row. */
32
32
  const RECORD_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
@@ -687,6 +687,20 @@ export class AwesomateClient {
687
687
  * columns and rows, plus what it assumed.
688
688
  */
689
689
  data: (query) => this.request('POST', '/api/knowledge/data/query', query, false),
690
+ /**
691
+ * A video the owner shared with **Anyone can watch**: its permanent player link and an embed
692
+ * code for a web page. `link` and `embed` are null until the video is shared, and when it is no
693
+ * longer Public (`enabled` true, `watchable` false). Read only: sharing is switched on in the hub
694
+ * or through Claude Code, by an Owner. `title` names the video in the embed code.
695
+ *
696
+ * @example
697
+ * const v = await db.knowledge.video('src-quote-walkthrough', { title: 'How we quote a job' });
698
+ * if (v.watchable && v.embed) console.log(v.embed);
699
+ */
700
+ video: (sourceId, options = {}) => {
701
+ const q = new URLSearchParams({ title: (options.title ?? '').slice(0, 100) });
702
+ return this.request('GET', `/api/knowledge/sources/${encodeURIComponent(sourceId)}/public-video?${q}`);
703
+ },
690
704
  };
691
705
  /**
692
706
  * Tell Contacts something happened to someone ("job_paid", "quote_sent"), so any email series
@@ -1322,6 +1336,42 @@ export class AwesomateAppClient {
1322
1336
  throw err;
1323
1337
  }
1324
1338
  }
1339
+ /**
1340
+ * One record laid out for this person: the sections and fields their app role is shown, in the
1341
+ * order the account set for that role, each field with its value and whether they may change it,
1342
+ * and where the record is up to in the account's own words for people outside the team. Null when
1343
+ * there is no such record this person may read. The database decides every permission; the
1344
+ * account sets the layout on the record page in the hub ("Viewing as", the role "in your apps").
1345
+ * Needs the account's record pages. A locked record says `locked: true`, and a change to it fails
1346
+ * with `forbidden` and `serverCode: 'locked'`.
1347
+ *
1348
+ * @example
1349
+ * const page = await app.recordPage('job', job.id);
1350
+ * for (const section of page?.sections ?? []) console.log(section.label, section.fields.map((f) => f.value));
1351
+ */
1352
+ async recordPage(kind, id) {
1353
+ if (!RECORD_ID.test(String(id)))
1354
+ return null;
1355
+ try {
1356
+ const r = await this.data('GET', `/records/${encodeURIComponent(kind)}/${encodeURIComponent(String(id))}`);
1357
+ return {
1358
+ kind: { key: r.kind.key, label: r.kind.label, labelPlural: r.kind.label_plural },
1359
+ id: r.id,
1360
+ stage: r.stage,
1361
+ locked: r.locked,
1362
+ canWrite: r.can_write,
1363
+ sections: r.sections,
1364
+ pinned: r.pinned,
1365
+ tab: r.tab,
1366
+ asAt: r.as_at,
1367
+ };
1368
+ }
1369
+ catch (err) {
1370
+ if (err instanceof AwesomateError && err.code === 'not_found')
1371
+ return null;
1372
+ throw err;
1373
+ }
1374
+ }
1325
1375
  /** Create a record (returns its id) or change one with options.id, inside the kind's write rule for this user. Pro and above. */
1326
1376
  async write(kind, data, options = {}) {
1327
1377
  const r = await this.data('POST', '/call', {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awesomate/sdk",
3
- "version": "0.27.0",
3
+ "version": "0.29.0",
4
4
  "description": "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",
5
5
  "license": "MIT",
6
6
  "type": "module",