@awesomate/sdk 0.26.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 +72 -4
- package/dist/index.js +42 -4
- 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
|
}
|
|
@@ -962,9 +962,10 @@ export declare class AwesomateClient {
|
|
|
962
962
|
}>;
|
|
963
963
|
/**
|
|
964
964
|
* Who this token is: the account, its plan, the token's scopes and when it expires, and which
|
|
965
|
-
* features the account has (each with the sentence to say when it does not)
|
|
966
|
-
*
|
|
967
|
-
*
|
|
965
|
+
* features the account has (each with the sentence to say when it does not), and whose key it
|
|
966
|
+
* is: the account owner's, which acts as the owner, or a team member's own, which does only what
|
|
967
|
+
* that person can do in the hub. Needs hosting:read; an app key cannot ask (it reads and writes
|
|
968
|
+
* its own kinds only).
|
|
968
969
|
*
|
|
969
970
|
* @example
|
|
970
971
|
* const me = await db.whoami();
|
|
@@ -1842,6 +1843,20 @@ export interface WhoAmI {
|
|
|
1842
1843
|
reason: string | null;
|
|
1843
1844
|
message: string | null;
|
|
1844
1845
|
}> | null;
|
|
1846
|
+
/**
|
|
1847
|
+
* Whose key this is: `account_owner` (acts as the owner), or `person`, a team member's own key,
|
|
1848
|
+
* which does what that person can do and never more (`level` view or full). Null for a browser
|
|
1849
|
+
* session, or from an older hub.
|
|
1850
|
+
*/
|
|
1851
|
+
key: {
|
|
1852
|
+
holder: 'account_owner';
|
|
1853
|
+
email: string | null;
|
|
1854
|
+
} | {
|
|
1855
|
+
holder: 'person';
|
|
1856
|
+
email: string | null;
|
|
1857
|
+
name: string | null;
|
|
1858
|
+
level: 'view' | 'full';
|
|
1859
|
+
} | null;
|
|
1845
1860
|
}
|
|
1846
1861
|
/** One column of a kind, from schema(). */
|
|
1847
1862
|
export interface SchemaColumn {
|
|
@@ -2424,6 +2439,45 @@ export interface VoiceSession {
|
|
|
2424
2439
|
}>;
|
|
2425
2440
|
say_as: Record<string, string>;
|
|
2426
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
|
+
}
|
|
2427
2481
|
/**
|
|
2428
2482
|
* The browser client for one of the account's apps, from createAppClient(): sign-in is under
|
|
2429
2483
|
* `auth`, and every data call runs as the signed-in person, inside the account's access rules.
|
|
@@ -2510,6 +2564,20 @@ export declare class AwesomateAppClient {
|
|
|
2510
2564
|
* else names no record, so it answers null without asking the hub. Pro and above.
|
|
2511
2565
|
*/
|
|
2512
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>;
|
|
2513
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. */
|
|
2514
2582
|
write<K extends KindName>(kind: K, data: Partial<RowOf<K>> | Record<string, unknown>, options?: WriteOptions): Promise<string>;
|
|
2515
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;
|
|
@@ -709,9 +709,10 @@ export class AwesomateClient {
|
|
|
709
709
|
}
|
|
710
710
|
/**
|
|
711
711
|
* Who this token is: the account, its plan, the token's scopes and when it expires, and which
|
|
712
|
-
* features the account has (each with the sentence to say when it does not)
|
|
713
|
-
*
|
|
714
|
-
*
|
|
712
|
+
* features the account has (each with the sentence to say when it does not), and whose key it
|
|
713
|
+
* is: the account owner's, which acts as the owner, or a team member's own, which does only what
|
|
714
|
+
* that person can do in the hub. Needs hosting:read; an app key cannot ask (it reads and writes
|
|
715
|
+
* its own kinds only).
|
|
715
716
|
*
|
|
716
717
|
* @example
|
|
717
718
|
* const me = await db.whoami();
|
|
@@ -725,6 +726,7 @@ export class AwesomateClient {
|
|
|
725
726
|
scopes: Array.isArray(r.scopes) ? r.scopes.map(String) : [],
|
|
726
727
|
tokenExpiresAt: r.patExpiresAt ?? null,
|
|
727
728
|
features: r.features ?? null,
|
|
729
|
+
key: r.key ?? null,
|
|
728
730
|
};
|
|
729
731
|
}
|
|
730
732
|
/**
|
|
@@ -1320,6 +1322,42 @@ export class AwesomateAppClient {
|
|
|
1320
1322
|
throw err;
|
|
1321
1323
|
}
|
|
1322
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
|
+
}
|
|
1323
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. */
|
|
1324
1362
|
async write(kind, data, options = {}) {
|
|
1325
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",
|