@awesomate/sdk 0.27.0 → 0.28.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 +54 -1
- package/dist/index.js +37 -1
- package/package.json +1 -1
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.
|
|
29
|
+
export declare const VERSION = "0.28.0";
|
|
30
30
|
/** Augmented by the generated awesomate.d.ts, so each kind's rows are typed. */
|
|
31
31
|
export interface Kinds {
|
|
32
32
|
}
|
|
@@ -2439,6 +2439,45 @@ export interface VoiceSession {
|
|
|
2439
2439
|
}>;
|
|
2440
2440
|
say_as: Record<string, string>;
|
|
2441
2441
|
}
|
|
2442
|
+
/** One field on a record page: its value as this person may read it, and whether they may change it. */
|
|
2443
|
+
export interface RecordPageField {
|
|
2444
|
+
key: string;
|
|
2445
|
+
label: string;
|
|
2446
|
+
type: string;
|
|
2447
|
+
value: unknown;
|
|
2448
|
+
change: boolean;
|
|
2449
|
+
}
|
|
2450
|
+
/** One section on a record page, in the order the account set; `folded` sections start closed. */
|
|
2451
|
+
export interface RecordPageSection {
|
|
2452
|
+
key: string;
|
|
2453
|
+
label: string;
|
|
2454
|
+
folded: boolean;
|
|
2455
|
+
fields: RecordPageField[];
|
|
2456
|
+
}
|
|
2457
|
+
/** A record laid out for the signed-in person's app role (`app.recordPage`). */
|
|
2458
|
+
export interface RecordPage {
|
|
2459
|
+
kind: {
|
|
2460
|
+
key: string;
|
|
2461
|
+
label: string;
|
|
2462
|
+
labelPlural: string;
|
|
2463
|
+
};
|
|
2464
|
+
id: string;
|
|
2465
|
+
/** Where it is up to, in the account's words for people outside the team. Null when there are none to show. */
|
|
2466
|
+
stage: {
|
|
2467
|
+
label: string;
|
|
2468
|
+
closed: boolean;
|
|
2469
|
+
} | null;
|
|
2470
|
+
/** Read only from its stage on: nothing on it can be changed. */
|
|
2471
|
+
locked: boolean;
|
|
2472
|
+
/** Whether this person may change the record at all. Each field's `change` says which. */
|
|
2473
|
+
canWrite: boolean;
|
|
2474
|
+
sections: RecordPageSection[];
|
|
2475
|
+
/** Fields the account keeps at the top of the page, in order. */
|
|
2476
|
+
pinned: string[];
|
|
2477
|
+
/** The part of the page it opens on. */
|
|
2478
|
+
tab: 'details' | 'activity' | 'related';
|
|
2479
|
+
asAt: string;
|
|
2480
|
+
}
|
|
2442
2481
|
/**
|
|
2443
2482
|
* The browser client for one of the account's apps, from createAppClient(): sign-in is under
|
|
2444
2483
|
* `auth`, and every data call runs as the signed-in person, inside the account's access rules.
|
|
@@ -2525,6 +2564,20 @@ export declare class AwesomateAppClient {
|
|
|
2525
2564
|
* else names no record, so it answers null without asking the hub. Pro and above.
|
|
2526
2565
|
*/
|
|
2527
2566
|
get<K extends KindName>(kind: K, id: string): Promise<RowOf<K> | null>;
|
|
2567
|
+
/**
|
|
2568
|
+
* One record laid out for this person: the sections and fields their app role is shown, in the
|
|
2569
|
+
* order the account set for that role, each field with its value and whether they may change it,
|
|
2570
|
+
* and where the record is up to in the account's own words for people outside the team. Null when
|
|
2571
|
+
* there is no such record this person may read. The database decides every permission; the
|
|
2572
|
+
* account sets the layout on the record page in the hub ("Viewing as", the role "in your apps").
|
|
2573
|
+
* Needs the account's record pages. A locked record says `locked: true`, and a change to it fails
|
|
2574
|
+
* with `forbidden` and `serverCode: 'locked'`.
|
|
2575
|
+
*
|
|
2576
|
+
* @example
|
|
2577
|
+
* const page = await app.recordPage('job', job.id);
|
|
2578
|
+
* for (const section of page?.sections ?? []) console.log(section.label, section.fields.map((f) => f.value));
|
|
2579
|
+
*/
|
|
2580
|
+
recordPage<K extends KindName>(kind: K, id: string): Promise<RecordPage | null>;
|
|
2528
2581
|
/** 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
2582
|
write<K extends KindName>(kind: K, data: Partial<RowOf<K>> | Record<string, unknown>, options?: WriteOptions): Promise<string>;
|
|
2530
2583
|
/** 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.
|
|
29
|
+
export const VERSION = '0.28.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;
|
|
@@ -1322,6 +1322,42 @@ export class AwesomateAppClient {
|
|
|
1322
1322
|
throw err;
|
|
1323
1323
|
}
|
|
1324
1324
|
}
|
|
1325
|
+
/**
|
|
1326
|
+
* One record laid out for this person: the sections and fields their app role is shown, in the
|
|
1327
|
+
* order the account set for that role, each field with its value and whether they may change it,
|
|
1328
|
+
* and where the record is up to in the account's own words for people outside the team. Null when
|
|
1329
|
+
* there is no such record this person may read. The database decides every permission; the
|
|
1330
|
+
* account sets the layout on the record page in the hub ("Viewing as", the role "in your apps").
|
|
1331
|
+
* Needs the account's record pages. A locked record says `locked: true`, and a change to it fails
|
|
1332
|
+
* with `forbidden` and `serverCode: 'locked'`.
|
|
1333
|
+
*
|
|
1334
|
+
* @example
|
|
1335
|
+
* const page = await app.recordPage('job', job.id);
|
|
1336
|
+
* for (const section of page?.sections ?? []) console.log(section.label, section.fields.map((f) => f.value));
|
|
1337
|
+
*/
|
|
1338
|
+
async recordPage(kind, id) {
|
|
1339
|
+
if (!RECORD_ID.test(String(id)))
|
|
1340
|
+
return null;
|
|
1341
|
+
try {
|
|
1342
|
+
const r = await this.data('GET', `/records/${encodeURIComponent(kind)}/${encodeURIComponent(String(id))}`);
|
|
1343
|
+
return {
|
|
1344
|
+
kind: { key: r.kind.key, label: r.kind.label, labelPlural: r.kind.label_plural },
|
|
1345
|
+
id: r.id,
|
|
1346
|
+
stage: r.stage,
|
|
1347
|
+
locked: r.locked,
|
|
1348
|
+
canWrite: r.can_write,
|
|
1349
|
+
sections: r.sections,
|
|
1350
|
+
pinned: r.pinned,
|
|
1351
|
+
tab: r.tab,
|
|
1352
|
+
asAt: r.as_at,
|
|
1353
|
+
};
|
|
1354
|
+
}
|
|
1355
|
+
catch (err) {
|
|
1356
|
+
if (err instanceof AwesomateError && err.code === 'not_found')
|
|
1357
|
+
return null;
|
|
1358
|
+
throw err;
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1325
1361
|
/** 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
1362
|
async write(kind, data, options = {}) {
|
|
1327
1363
|
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.
|
|
3
|
+
"version": "0.28.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",
|