@awesomate/sdk 0.77.1 → 0.79.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 +181 -2
- package/dist/index.js +85 -2
- 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.79.0";
|
|
30
30
|
/** Augmented by the generated awesomate.d.ts, so each kind's rows are typed. */
|
|
31
31
|
export interface Kinds {
|
|
32
32
|
}
|
|
@@ -574,6 +574,34 @@ export interface TrashEntry {
|
|
|
574
574
|
/** When it was removed, or null when the trash name does not say. */
|
|
575
575
|
deleted_at: string | null;
|
|
576
576
|
}
|
|
577
|
+
/** One move or copy in a list: where from, and where to (a folder ending in "/" keeps the name). */
|
|
578
|
+
export interface FilePair {
|
|
579
|
+
from: string;
|
|
580
|
+
to: string;
|
|
581
|
+
}
|
|
582
|
+
/** Each item of a moveMany() or copyMany(), answered on its own. */
|
|
583
|
+
export type FileBatchItem = {
|
|
584
|
+
from: string;
|
|
585
|
+
to: string;
|
|
586
|
+
ok: true;
|
|
587
|
+
entry: FileEntry;
|
|
588
|
+
}
|
|
589
|
+
/** partial: a copy stopped part way and left this behind; delete it before trying again. */
|
|
590
|
+
| {
|
|
591
|
+
from: string;
|
|
592
|
+
to: string;
|
|
593
|
+
ok: false;
|
|
594
|
+
error: string;
|
|
595
|
+
code: string;
|
|
596
|
+
partial?: string;
|
|
597
|
+
};
|
|
598
|
+
/** What moveMany() or copyMany() did: every item, how many went (moved or copied) and how many did not. */
|
|
599
|
+
export interface FilesBatchResult {
|
|
600
|
+
results: FileBatchItem[];
|
|
601
|
+
moved?: number;
|
|
602
|
+
copied?: number;
|
|
603
|
+
failed: number;
|
|
604
|
+
}
|
|
577
605
|
/** How much of the plan's Files space is used. */
|
|
578
606
|
export interface FilesUsage {
|
|
579
607
|
used_bytes: number;
|
|
@@ -761,8 +789,22 @@ export declare class AwesomateClient {
|
|
|
761
789
|
download: (path: string) => Promise<Blob>;
|
|
762
790
|
/** Make a folder, and any above it. */
|
|
763
791
|
mkdir: (path: string) => Promise<FileEntry>;
|
|
764
|
-
/** Move or rename. Anything using the old path or address needs the new one. */
|
|
792
|
+
/** Move or rename. A `to` ending in "/" is a folder to move it into, keeping its name. Anything using the old path or address needs the new one. */
|
|
765
793
|
move: (from: string, to: string) => Promise<FileEntry>;
|
|
794
|
+
/** Move up to 100 at once. Each is answered on its own in `results`; one that fails does not stop the rest. */
|
|
795
|
+
moveMany: (items: FilePair[]) => Promise<FilesBatchResult>;
|
|
796
|
+
/**
|
|
797
|
+
* Copy a file or a folder, leaving the original. A `to` ending in "/" keeps the name. A file already at `to` is
|
|
798
|
+
* replaced only with `{ overwrite: true }`; a folder copy never writes into a folder that is there. One call copies
|
|
799
|
+
* at most 200 files and 250 MB, within the plan's Files space.
|
|
800
|
+
*/
|
|
801
|
+
copy: (from: string, to: string, opts?: {
|
|
802
|
+
overwrite?: boolean;
|
|
803
|
+
}) => Promise<FileEntry>;
|
|
804
|
+
/** Copy up to 100 at once (200 files and 250 MB in all). Each is answered on its own in `results`. */
|
|
805
|
+
copyMany: (items: FilePair[], opts?: {
|
|
806
|
+
overwrite?: boolean;
|
|
807
|
+
}) => Promise<FilesBatchResult>;
|
|
766
808
|
/** Move a file from private/ or temp/ to the same place under public/, and answer its public_url. Anyone with the address can open it. */
|
|
767
809
|
makePublic: (path: string) => Promise<FileEntry>;
|
|
768
810
|
/** Move a file out of public/ into private/. Its public address stops serving it within seconds (a browser that already opened it may keep its own copy for a while). */
|
|
@@ -1391,6 +1433,59 @@ export declare class AwesomateClient {
|
|
|
1391
1433
|
/** Where the business's Stripe account stands, with one sentence (`next`) saying what happens next. */
|
|
1392
1434
|
status: () => Promise<PaymentsStatus>;
|
|
1393
1435
|
};
|
|
1436
|
+
/**
|
|
1437
|
+
* The account's own help centre: its topics and articles, written as drafts, published to the
|
|
1438
|
+
* public help pages (shown while the centre's pages are on, and sent to the business's Knowledge
|
|
1439
|
+
* where the centre feeds it), unpublished or archived. Needs the account's token with help:write, a permission no plan
|
|
1440
|
+
* gives by itself: the account owner switches it on for one key in the hub (Claude Code, Get my
|
|
1441
|
+
* code, "Write, publish and take down your help centre articles"). Never an app key, a team
|
|
1442
|
+
* member's key or a chat connection. An account with no help centre answers not_found with
|
|
1443
|
+
* serverCode `no_help_centre`.
|
|
1444
|
+
*
|
|
1445
|
+
* An article's working copy (title, summary, body) is what you change; the public sees its
|
|
1446
|
+
* published copy, so an edit is not live until you publish again. Publishing is refused while
|
|
1447
|
+
* the body still has a `[CHECK:` note in it. Bodies are Markdown.
|
|
1448
|
+
*
|
|
1449
|
+
* @example
|
|
1450
|
+
* const { topics } = await db.help.centre();
|
|
1451
|
+
* const article = await db.help.articles.create({ title: 'Connect Xero', body: 'Open Settings, then Integrations.', topicId: topics[0]?.id });
|
|
1452
|
+
* await db.help.articles.publish(article.id);
|
|
1453
|
+
*/
|
|
1454
|
+
readonly help: {
|
|
1455
|
+
/** The centre, its public address, the segments an article may name, and its topics. */
|
|
1456
|
+
centre: () => Promise<HelpCentreView>;
|
|
1457
|
+
topics: {
|
|
1458
|
+
/** Every topic, in the centre's order. */
|
|
1459
|
+
list: () => Promise<HelpTopic[]>;
|
|
1460
|
+
/** Add a topic; its slug is made from the name unless given. */
|
|
1461
|
+
create: (input: {
|
|
1462
|
+
name: string;
|
|
1463
|
+
slug?: string;
|
|
1464
|
+
description?: string | null;
|
|
1465
|
+
}) => Promise<HelpTopic>;
|
|
1466
|
+
};
|
|
1467
|
+
articles: {
|
|
1468
|
+
/** Articles without their bodies, optionally in one status or matching words in the title. */
|
|
1469
|
+
list: (options?: {
|
|
1470
|
+
status?: HelpArticleStatus;
|
|
1471
|
+
q?: string;
|
|
1472
|
+
}) => Promise<HelpArticleSummary[]>;
|
|
1473
|
+
/** One article with its working and published copies, or null when there is none. */
|
|
1474
|
+
get: (id: string) => Promise<HelpArticle | null>;
|
|
1475
|
+
/** A new draft. Its slug is made from the title unless given; segments default to everyone. */
|
|
1476
|
+
create: (input: HelpArticleInput) => Promise<HelpArticle>;
|
|
1477
|
+
/** Change a draft's (or a published article's working) copy. Fields left out are left as they are. */
|
|
1478
|
+
update: (id: string, patch: Partial<HelpArticleInput>) => Promise<HelpArticle>;
|
|
1479
|
+
/** Make the working copy public (and send its page to Knowledge where the centre feeds it). */
|
|
1480
|
+
publish: (id: string) => Promise<HelpArticle>;
|
|
1481
|
+
/** Take it off the public pages; it stays as a draft. */
|
|
1482
|
+
unpublish: (id: string) => Promise<HelpArticle>;
|
|
1483
|
+
/** Archive it: off the public pages and out of Knowledge. Restoring is done in the hub. */
|
|
1484
|
+
archive: (id: string) => Promise<HelpArticle>;
|
|
1485
|
+
};
|
|
1486
|
+
};
|
|
1487
|
+
/** A help centre call: the account's own token only, and a change is never sent twice. */
|
|
1488
|
+
private helpRequest;
|
|
1394
1489
|
/**
|
|
1395
1490
|
* The account's own support desk: the help inbox for its customers, under Contacts, Inbox in
|
|
1396
1491
|
* the hub. Read only, on purpose: every message here was written by someone outside the
|
|
@@ -5128,6 +5223,90 @@ export interface CompanyUpsertResult {
|
|
|
5128
5223
|
/** How it found the company it changed: by id, abn or name; null when it made one. */
|
|
5129
5224
|
matched_by: 'id' | 'abn' | 'name' | null;
|
|
5130
5225
|
}
|
|
5226
|
+
/** An article's status in a help centre. */
|
|
5227
|
+
export type HelpArticleStatus = 'draft' | 'published' | 'archived';
|
|
5228
|
+
/** A help centre's topic, from help.topics. */
|
|
5229
|
+
export interface HelpTopic {
|
|
5230
|
+
id: string;
|
|
5231
|
+
name: string;
|
|
5232
|
+
slug: string;
|
|
5233
|
+
description: string | null;
|
|
5234
|
+
position: number;
|
|
5235
|
+
updatedAt: string;
|
|
5236
|
+
}
|
|
5237
|
+
/** The help centre, from help.centre(). */
|
|
5238
|
+
export interface HelpCentreView {
|
|
5239
|
+
centre: {
|
|
5240
|
+
handle: string;
|
|
5241
|
+
title: string;
|
|
5242
|
+
/** Whether its public pages are on. */
|
|
5243
|
+
status: 'off' | 'on';
|
|
5244
|
+
/** Its own address (help.<domain>), when it has one. */
|
|
5245
|
+
customHost: string | null;
|
|
5246
|
+
hostStatus: 'none' | 'pending' | 'active' | 'problem';
|
|
5247
|
+
};
|
|
5248
|
+
/** Where its public pages are. */
|
|
5249
|
+
publicUrl: string | null;
|
|
5250
|
+
/** The audiences an article may name (`all`, or plans on Awesomate's own centre). */
|
|
5251
|
+
segments: string[];
|
|
5252
|
+
topics: HelpTopic[];
|
|
5253
|
+
}
|
|
5254
|
+
/** What creating or changing an article takes. */
|
|
5255
|
+
export interface HelpArticleInput {
|
|
5256
|
+
title: string;
|
|
5257
|
+
/** Made from the title when left out. Fixed once the article has been published. */
|
|
5258
|
+
slug?: string;
|
|
5259
|
+
summary?: string | null;
|
|
5260
|
+
/** Markdown. A `[CHECK: ...]` note blocks publishing until it is gone. */
|
|
5261
|
+
body?: string;
|
|
5262
|
+
/** Who it is for: `['all']` (the default) or names from help.centre().segments. */
|
|
5263
|
+
segments?: string[];
|
|
5264
|
+
topicId?: string | null;
|
|
5265
|
+
}
|
|
5266
|
+
/** An article in a list, from help.articles.list(): no bodies. */
|
|
5267
|
+
export interface HelpArticleSummary {
|
|
5268
|
+
id: string;
|
|
5269
|
+
title: string;
|
|
5270
|
+
slug: string;
|
|
5271
|
+
summary: string | null;
|
|
5272
|
+
status: HelpArticleStatus;
|
|
5273
|
+
publishedTitle: string | null;
|
|
5274
|
+
publishedAt: string | null;
|
|
5275
|
+
firstPublishedAt: string | null;
|
|
5276
|
+
segments: string[];
|
|
5277
|
+
topicId: string | null;
|
|
5278
|
+
/** Publishing would change what the public sees. */
|
|
5279
|
+
changed: boolean;
|
|
5280
|
+
/** Where its page stands in the business's Knowledge, when it has been sent there. */
|
|
5281
|
+
knowledge: {
|
|
5282
|
+
action: 'add' | 'remove';
|
|
5283
|
+
status: 'pending' | 'sent' | 'done' | 'failed';
|
|
5284
|
+
words: string | null;
|
|
5285
|
+
at: string;
|
|
5286
|
+
} | null;
|
|
5287
|
+
updatedAt: string;
|
|
5288
|
+
}
|
|
5289
|
+
/** One article in full, from help.articles.get() and every change. */
|
|
5290
|
+
export interface HelpArticle {
|
|
5291
|
+
id: string;
|
|
5292
|
+
title: string;
|
|
5293
|
+
slug: string;
|
|
5294
|
+
summary: string | null;
|
|
5295
|
+
body: string;
|
|
5296
|
+
status: HelpArticleStatus;
|
|
5297
|
+
publishedTitle: string | null;
|
|
5298
|
+
publishedSummary: string | null;
|
|
5299
|
+
publishedBody: string | null;
|
|
5300
|
+
publishedAt: string | null;
|
|
5301
|
+
firstPublishedAt: string | null;
|
|
5302
|
+
segments: string[];
|
|
5303
|
+
topicId: string | null;
|
|
5304
|
+
position: number;
|
|
5305
|
+
staffNote: string | null;
|
|
5306
|
+
createdAt: string;
|
|
5307
|
+
updatedAt: string;
|
|
5308
|
+
changed: boolean;
|
|
5309
|
+
}
|
|
5131
5310
|
/** The account's support desk, from supportDesk.status(). */
|
|
5132
5311
|
export interface SupportDeskStatus {
|
|
5133
5312
|
on: boolean;
|
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.79.0';
|
|
30
30
|
const DEFAULT_BASE = 'https://hub.awesomate.ai';
|
|
31
31
|
/** The one check for a platform `watch_url` (mirrored in the hub's awesomate-knowledge.ts and its MCP). */
|
|
32
32
|
const WATCH_URL = /^https:\/\/[^\s"'<>]+$/i;
|
|
@@ -367,8 +367,18 @@ export class AwesomateClient {
|
|
|
367
367
|
download: async (path) => (await this.raw('GET', `/api/files/stream?${new URLSearchParams({ path, disposition: 'attachment' })}`)).blob(),
|
|
368
368
|
/** Make a folder, and any above it. */
|
|
369
369
|
mkdir: async (path) => (await this.filesCall('POST', '/api/files/mkdir', { path })).entry,
|
|
370
|
-
/** Move or rename. Anything using the old path or address needs the new one. */
|
|
370
|
+
/** Move or rename. A `to` ending in "/" is a folder to move it into, keeping its name. Anything using the old path or address needs the new one. */
|
|
371
371
|
move: async (from, to) => (await this.filesCall('POST', '/api/files/move', { from, to })).entry,
|
|
372
|
+
/** Move up to 100 at once. Each is answered on its own in `results`; one that fails does not stop the rest. */
|
|
373
|
+
moveMany: async (items) => this.filesCall('POST', '/api/files/move', { items }),
|
|
374
|
+
/**
|
|
375
|
+
* Copy a file or a folder, leaving the original. A `to` ending in "/" keeps the name. A file already at `to` is
|
|
376
|
+
* replaced only with `{ overwrite: true }`; a folder copy never writes into a folder that is there. One call copies
|
|
377
|
+
* at most 200 files and 250 MB, within the plan's Files space.
|
|
378
|
+
*/
|
|
379
|
+
copy: async (from, to, opts = {}) => (await this.filesCall('POST', '/api/files/copy', { from, to, ...(opts.overwrite ? { overwrite: true } : {}) })).entry,
|
|
380
|
+
/** Copy up to 100 at once (200 files and 250 MB in all). Each is answered on its own in `results`. */
|
|
381
|
+
copyMany: async (items, opts = {}) => this.filesCall('POST', '/api/files/copy', { items, ...(opts.overwrite ? { overwrite: true } : {}) }),
|
|
372
382
|
/** Move a file from private/ or temp/ to the same place under public/, and answer its public_url. Anyone with the address can open it. */
|
|
373
383
|
makePublic: async (path) => {
|
|
374
384
|
const [top, ...rest] = path.replace(/^\/+/, '').split('/');
|
|
@@ -1076,6 +1086,79 @@ export class AwesomateClient {
|
|
|
1076
1086
|
/** Where the business's Stripe account stands, with one sentence (`next`) saying what happens next. */
|
|
1077
1087
|
status: () => this.request('GET', '/api/my-crm/v1/payments/status'),
|
|
1078
1088
|
};
|
|
1089
|
+
/**
|
|
1090
|
+
* The account's own help centre: its topics and articles, written as drafts, published to the
|
|
1091
|
+
* public help pages (shown while the centre's pages are on, and sent to the business's Knowledge
|
|
1092
|
+
* where the centre feeds it), unpublished or archived. Needs the account's token with help:write, a permission no plan
|
|
1093
|
+
* gives by itself: the account owner switches it on for one key in the hub (Claude Code, Get my
|
|
1094
|
+
* code, "Write, publish and take down your help centre articles"). Never an app key, a team
|
|
1095
|
+
* member's key or a chat connection. An account with no help centre answers not_found with
|
|
1096
|
+
* serverCode `no_help_centre`.
|
|
1097
|
+
*
|
|
1098
|
+
* An article's working copy (title, summary, body) is what you change; the public sees its
|
|
1099
|
+
* published copy, so an edit is not live until you publish again. Publishing is refused while
|
|
1100
|
+
* the body still has a `[CHECK:` note in it. Bodies are Markdown.
|
|
1101
|
+
*
|
|
1102
|
+
* @example
|
|
1103
|
+
* const { topics } = await db.help.centre();
|
|
1104
|
+
* const article = await db.help.articles.create({ title: 'Connect Xero', body: 'Open Settings, then Integrations.', topicId: topics[0]?.id });
|
|
1105
|
+
* await db.help.articles.publish(article.id);
|
|
1106
|
+
*/
|
|
1107
|
+
help = {
|
|
1108
|
+
/** The centre, its public address, the segments an article may name, and its topics. */
|
|
1109
|
+
centre: async () => {
|
|
1110
|
+
const r = await this.helpRequest('GET', '/?articles=0');
|
|
1111
|
+
return { centre: r.centre, publicUrl: r.publicUrl, segments: r.segments, topics: r.topics };
|
|
1112
|
+
},
|
|
1113
|
+
topics: {
|
|
1114
|
+
/** Every topic, in the centre's order. */
|
|
1115
|
+
list: async () => (await this.helpRequest('GET', '/?articles=0')).topics,
|
|
1116
|
+
/** Add a topic; its slug is made from the name unless given. */
|
|
1117
|
+
create: async (input) => (await this.helpRequest('POST', '/topics', input)).topic,
|
|
1118
|
+
},
|
|
1119
|
+
articles: {
|
|
1120
|
+
/** Articles without their bodies, optionally in one status or matching words in the title. */
|
|
1121
|
+
list: async (options = {}) => {
|
|
1122
|
+
const q = new URLSearchParams();
|
|
1123
|
+
if (options.status)
|
|
1124
|
+
q.set('status', options.status);
|
|
1125
|
+
if (options.q)
|
|
1126
|
+
q.set('q', options.q);
|
|
1127
|
+
const qs = q.toString();
|
|
1128
|
+
return (await this.helpRequest('GET', `/${qs ? `?${qs}` : ''}`)).articles;
|
|
1129
|
+
},
|
|
1130
|
+
/** One article with its working and published copies, or null when there is none. */
|
|
1131
|
+
get: async (id) => {
|
|
1132
|
+
if (!RECORD_ID.test(String(id)))
|
|
1133
|
+
return null;
|
|
1134
|
+
try {
|
|
1135
|
+
return (await this.helpRequest('GET', `/articles/${encodeURIComponent(String(id))}`)).article;
|
|
1136
|
+
}
|
|
1137
|
+
catch (err) {
|
|
1138
|
+
if (err instanceof AwesomateError && err.code === 'not_found' && err.serverCode !== 'no_help_centre')
|
|
1139
|
+
return null;
|
|
1140
|
+
throw err;
|
|
1141
|
+
}
|
|
1142
|
+
},
|
|
1143
|
+
/** A new draft. Its slug is made from the title unless given; segments default to everyone. */
|
|
1144
|
+
create: async (input) => (await this.helpRequest('POST', '/articles', input)).article,
|
|
1145
|
+
/** Change a draft's (or a published article's working) copy. Fields left out are left as they are. */
|
|
1146
|
+
update: async (id, patch) => (await this.helpRequest('PATCH', `/articles/${encodeURIComponent(String(id))}`, patch)).article,
|
|
1147
|
+
/** Make the working copy public (and send its page to Knowledge where the centre feeds it). */
|
|
1148
|
+
publish: async (id) => (await this.helpRequest('POST', `/articles/${encodeURIComponent(String(id))}/publish`)).article,
|
|
1149
|
+
/** Take it off the public pages; it stays as a draft. */
|
|
1150
|
+
unpublish: async (id) => (await this.helpRequest('POST', `/articles/${encodeURIComponent(String(id))}/unpublish`)).article,
|
|
1151
|
+
/** Archive it: off the public pages and out of Knowledge. Restoring is done in the hub. */
|
|
1152
|
+
archive: async (id) => (await this.helpRequest('POST', `/articles/${encodeURIComponent(String(id))}/archive`)).article,
|
|
1153
|
+
},
|
|
1154
|
+
};
|
|
1155
|
+
/** A help centre call: the account's own token only, and a change is never sent twice. */
|
|
1156
|
+
helpRequest(method, path, body) {
|
|
1157
|
+
if (this.appKey) {
|
|
1158
|
+
throw new AwesomateError('forbidden', "The help centre needs the account's token with help:write, not an app key.", 0);
|
|
1159
|
+
}
|
|
1160
|
+
return this.request(method, `/api/my-help/v1${path}`, body, method === 'GET');
|
|
1161
|
+
}
|
|
1079
1162
|
/**
|
|
1080
1163
|
* The account's own support desk: the help inbox for its customers, under Contacts, Inbox in
|
|
1081
1164
|
* the hub. Read only, on purpose: every message here was written by someone outside the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@awesomate/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.79.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",
|