@awesomate/sdk 0.93.0 → 0.98.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.93.0";
29
+ export declare const VERSION = "0.98.0";
30
30
  /** Augmented by the generated awesomate.d.ts, so each kind's rows are typed. */
31
31
  export interface Kinds {
32
32
  }
@@ -696,6 +696,8 @@ export interface AwesomateErrorDetails {
696
696
  }>;
697
697
  /** With restore_to_public (files.restore() into public/ without confirmPublic): the path it would go back to. */
698
698
  target?: string;
699
+ /** With roll_incomplete (knowledge.guests.roll()): the guest's keys still live, the new one too when it would not stop. */
700
+ stillLive?: string[];
699
701
  }
700
702
  /**
701
703
  * Every failure from the hub. `message` is for you, the developer; `personMessage`, when the hub
@@ -740,6 +742,8 @@ export declare class AwesomateError extends Error {
740
742
  }>;
741
743
  /** With serverCode restore_to_public (`files.restore()`): the path in public/ it would go back to. */
742
744
  readonly target?: string;
745
+ /** With serverCode roll_incomplete (`knowledge.guests.roll()`): the guest's keys still live. Roll or remove again. */
746
+ readonly stillLive?: string[];
743
747
  constructor(
744
748
  /** Why it failed. */
745
749
  code: ErrorCode, message: string,
@@ -1344,7 +1348,10 @@ export declare class AwesomateClient {
1344
1348
  preview: (id: string) => Promise<EmailPreview | null>;
1345
1349
  /**
1346
1350
  * One test copy of a draft to the key's own person, and nobody else (5 of an email an hour).
1347
- * Needs crm:draft and full team access.
1351
+ * Needs crm:draft and full team access. Where the account has Better email designs
1352
+ * (`email_design_studio`), a key's test copy waits until `designPreview({ id })` has drawn this
1353
+ * version (server code `preview_required`) and until what its pictures show must be fixed is fixed
1354
+ * (`qa_blocker`, with `blockers`).
1348
1355
  */
1349
1356
  test: (id: string) => Promise<EmailTestSent>;
1350
1357
  /** Replace a draft. Once someone approved it, it is refused: a person changes it in the hub. */
@@ -1400,7 +1407,9 @@ export declare class AwesomateClient {
1400
1407
  }) => Promise<EmailFromChoice[] | null>;
1401
1408
  /**
1402
1409
  * The usual From for each kind of email (`one_to_one`: an email to one person; `automation`: an
1403
- * automation's service email that names no From), and the owner's own addresses it can be. Needs crm:read.
1410
+ * automation's service email that names no From; `video`: a video's ticket emails; `forms`: a form's
1411
+ * download email; `desk`: a reply from the account's own support desk), and the owner's own addresses
1412
+ * it can be. Needs crm:read.
1404
1413
  */
1405
1414
  fromDefaults: () => Promise<EmailFromDefaults>;
1406
1415
  /**
@@ -1409,6 +1418,23 @@ export declare class AwesomateClient {
1409
1418
  * and `own_address`). It never adds or proves an address: the owner does that in the hub.
1410
1419
  */
1411
1420
  setFromDefault: (kind: EmailFromDefaultKind, from: string) => Promise<EmailFromDefaults>;
1421
+ /**
1422
+ * Pictures of an email as it will look, drawn by the hub: `desktop` (600 px wide), `phone` (375 px)
1423
+ * and `dark` (a dark inbox), with the hub's footer and preview text in and merge fields filled for a
1424
+ * sample person. Name one: `id` (a saved email), `templateId` (an email template) or `mjml` (an email
1425
+ * design not saved yet, with its `subject`, `preheader` and `kind` if you have them). Each picture's
1426
+ * `url` works for 10 minutes without a token, so you can put it in an `<img>`; after that, ask again.
1427
+ * When there are none, `unavailable` says why (`preview_limit`: the account's 30 in 10 minutes are
1428
+ * used; `preview_unavailable`: try again in a minute). Needs crm:draft, full team access and
1429
+ * Better email designs on the account (`email_design_studio`; `unavailable`, server code
1430
+ * `feature_unavailable`, otherwise).
1431
+ *
1432
+ * @example
1433
+ * const [first] = await db.emails.list();
1434
+ * const pics = await db.emails.designPreview({ id: first.id });
1435
+ * for (const p of pics.pictures) console.log(p.name, p.url);
1436
+ */
1437
+ designPreview: (input: EmailDesignPreviewInput) => Promise<EmailDesignPreview>;
1412
1438
  };
1413
1439
  /**
1414
1440
  * Email series: emails that go to one person at a time over days, starting when something
@@ -1911,6 +1937,66 @@ export declare class AwesomateClient {
1911
1937
  confirm?: string;
1912
1938
  title?: string;
1913
1939
  }) => Promise<SharedVideo>;
1940
+ /**
1941
+ * Guest access: a named, time-limited pass for someone outside the business (an agency, a
1942
+ * contractor) to ask the collections or tags the owner picks. Each guest is one key on the
1943
+ * account's Guest answers agent, never shown documents only the owner can see. Needs the account's
1944
+ * token at the Owner level (knowledge:read to read, knowledge:write to change), never an app key or
1945
+ * the Hub Key. A chat connection's key, or a Claude Code key while it acts for the owner, may read
1946
+ * (list, log) but never give, change, roll or remove. Every plan with Knowledge, where the
1947
+ * account has Guest access (`knowledge_guests`; feature_unavailable otherwise).
1948
+ * `id` is the key the guest holds now; after a roll, any earlier id still finds them.
1949
+ *
1950
+ * @example
1951
+ * const g = await db.knowledge.guests.give({ name: 'Jordan, ads manager', tags: ['product-info'], ends_in_days: 30 });
1952
+ * console.log(g.ready.ask_link); // shown once: send it to Jordan yourself
1953
+ */
1954
+ guests: {
1955
+ /**
1956
+ * Every guest: `guests` live or paused, newest first; `ended` ended or removed. Never a key. The
1957
+ * account's token at the Owner level with knowledge:read.
1958
+ */
1959
+ list: () => Promise<KnowledgeGuestList>;
1960
+ /**
1961
+ * Give someone access: the account's token at the Owner level with knowledge:write, never an app
1962
+ * key, the Hub Key, a chat connection's key or a Claude Code key acting for the owner. At least one
1963
+ * collection or tag. Ends in 90 days unless `ends_in_days` or
1964
+ * `ends_at` says otherwise (1 to 365 days); `cap` answers a month, half the account's unless set,
1965
+ * counting toward the account's answers. The key comes back once, in `key` and `ready`: hand it
1966
+ * to the guest and never store it. Pass your own `request_id` (a UUID) so a retry gives the same
1967
+ * guest once. A retry after the guest took the account's last place answers `too_many_guests`:
1968
+ * find them with `list()` and `roll()` them for a key.
1969
+ */
1970
+ give: (guest: KnowledgeGuestGive) => Promise<KnowledgeGuestKey>;
1971
+ /**
1972
+ * Change a guest: any field of `give()`, and only what differs is changed. `widened` says the
1973
+ * change gave them more (more to read, a later end or more answers).
1974
+ */
1975
+ update: (id: string, change: KnowledgeGuestChange) => Promise<KnowledgeGuestUpdated>;
1976
+ /**
1977
+ * A new key for the guest, ending when the old one would have, and the old key stopped: for a
1978
+ * link that went further than it should. The new key comes back once. Pass your own
1979
+ * `request_id` so a retry shows the same new key. `roll_incomplete` (serverCode) means the old
1980
+ * key would not stop, so the new one is not shown; `stillLive` on the error names the keys still
1981
+ * live (the new one too when it would not stop either): roll or remove again.
1982
+ */
1983
+ roll: (id: string, options?: {
1984
+ request_id?: string;
1985
+ }) => Promise<KnowledgeGuestKey>;
1986
+ /** End a guest's access for good: every key they held stops and their kept questions are forgotten. */
1987
+ remove: (id: string) => Promise<{
1988
+ removed: true;
1989
+ questions_forgotten: boolean;
1990
+ }>;
1991
+ /**
1992
+ * What a guest did, newest first: when, from where, and the question when it was kept. `limit`
1993
+ * is 1 to 200 (default 50); pass `next_cursor` back as `cursor` for the page after.
1994
+ */
1995
+ log: (id: string, options?: {
1996
+ limit?: number;
1997
+ cursor?: string;
1998
+ }) => Promise<KnowledgeGuestLog>;
1999
+ };
1914
2000
  };
1915
2001
  /**
1916
2002
  * Tell Contacts something happened to someone ("job_paid", "quote_sent"), so any email series
@@ -5416,7 +5502,7 @@ export interface EmailDraftInput {
5416
5502
  from?: string;
5417
5503
  }
5418
5504
  /** The kinds of email a usual From is set for. */
5419
- export type EmailFromDefaultKind = 'one_to_one' | 'automation';
5505
+ export type EmailFromDefaultKind = 'one_to_one' | 'automation' | 'video' | 'forms' | 'desk';
5420
5506
  /** One address an email can go from, from `emails.fromChoices()` (and `from_choices` on `get()` and `preview()`). */
5421
5507
  export interface EmailFromChoice {
5422
5508
  /** `'sending_name'`, or the own address itself: what to pass as `from`. */
@@ -5432,6 +5518,12 @@ export interface EmailFromChoice {
5432
5518
  paused?: boolean;
5433
5519
  /** An own address's uses, as the owner switched them on. */
5434
5520
  uses?: Array<'one_to_one' | 'invites' | 'lists'>;
5521
+ /**
5522
+ * Where replies to an email from this own address go: `desk` (they come to the account's support desk,
5523
+ * filed with the email they answer), `mailbox` (straight to the address; the owner chose that), or
5524
+ * `no_desk` (straight to the address, since no support desk is switched on).
5525
+ */
5526
+ replies?: 'desk' | 'mailbox' | 'no_desk';
5435
5527
  /** The name on its From line; null for the personal name. */
5436
5528
  name?: string | null;
5437
5529
  label: string;
@@ -5454,6 +5546,64 @@ export interface EmailFromDefaults {
5454
5546
  uses: Array<'one_to_one' | 'invites' | 'lists'>;
5455
5547
  }>;
5456
5548
  }
5549
+ /** Which email `emails.designPreview()` draws: a saved email, a template, or a design not saved yet. */
5550
+ export type EmailDesignPreviewInput = {
5551
+ id: string;
5552
+ } | {
5553
+ templateId: number;
5554
+ } | {
5555
+ mjml: string;
5556
+ subject?: string;
5557
+ preheader?: string;
5558
+ kind?: 'marketing' | 'transactional';
5559
+ };
5560
+ /** One picture of an email. */
5561
+ export interface EmailPicture {
5562
+ /**
5563
+ * `desktop` (600 px wide), `phone` (375 px) or `dark` (a dark inbox, 600 px); `desktop_marked`,
5564
+ * `phone_marked` or `dark_marked`: that page with each of `qa`'s findings on it framed in red.
5565
+ */
5566
+ name: 'desktop' | 'phone' | 'dark' | 'desktop_marked' | 'phone_marked' | 'dark_marked';
5567
+ width: number;
5568
+ height: number;
5569
+ /** The PNG, for 10 minutes, with no token needed. */
5570
+ url: string;
5571
+ /** True when the email is taller than the hub draws and the picture stops part way. */
5572
+ cut: boolean;
5573
+ }
5574
+ /** What `emails.designPreview()` answers. */
5575
+ export interface EmailDesignPreview {
5576
+ pictures: EmailPicture[];
5577
+ /** When the pictures' addresses stop working (ISO time), or null when there are none. */
5578
+ expiresAt: string | null;
5579
+ /** Pictures in the email that were not drawn, each with why (not on the account's Files or websites, over 1 MB, and so on). */
5580
+ leftOut: Array<{
5581
+ url: string;
5582
+ problem: string;
5583
+ }>;
5584
+ /** Why there are no pictures, or null. */
5585
+ unavailable: {
5586
+ code: string;
5587
+ error: string;
5588
+ retryAfter: number | null;
5589
+ } | null;
5590
+ /**
5591
+ * What the pictures show, or null when the hub measured nothing. `blockers` (a word cut or past the
5592
+ * edge at phone width, a logo drawn as a solid box) hold back a key's test copy until fixed;
5593
+ * `warnings` are worth fixing.
5594
+ */
5595
+ qa: {
5596
+ blockers: EmailDesignFinding[];
5597
+ warnings: EmailDesignFinding[];
5598
+ } | null;
5599
+ }
5600
+ /** One thing the pictures of an email show: what it is, on which page, the element, and a sentence saying what to do. */
5601
+ export interface EmailDesignFinding {
5602
+ code: string;
5603
+ page: string;
5604
+ element: string;
5605
+ message: string;
5606
+ }
5457
5607
  /** Who a picked-people email reaches, as a model may see it. */
5458
5608
  export interface EmailReach {
5459
5609
  count: number;
@@ -6909,6 +7059,128 @@ export interface KnowledgeDataQuery {
6909
7059
  limit?: number;
6910
7060
  [key: string]: unknown;
6911
7061
  }
7062
+ /** Where a guest stands: live, paused, ended (past its end) or removed (ended by the owner). */
7063
+ export type KnowledgeGuestState = 'live' | 'paused' | 'ended' | 'removed';
7064
+ /** One guest, from knowledge.guests. Never the key. */
7065
+ export interface KnowledgeGuest {
7066
+ /** The key the guest holds now (a roll gives a new one; an earlier id still finds them). */
7067
+ id: string;
7068
+ /** Who they are, as the owner named them. */
7069
+ name: string | null;
7070
+ agent_id: string | null;
7071
+ policy_id: string | null;
7072
+ /** Collection ids they can read. */
7073
+ collections: string[];
7074
+ /** Tags they can read. */
7075
+ tags: string[];
7076
+ /** When access was given. */
7077
+ made: string | null;
7078
+ /** When the key they hold now was made, if a roll replaced an earlier one. */
7079
+ rolled: string | null;
7080
+ last_used: string | null;
7081
+ /** When access ends. */
7082
+ ends: string | null;
7083
+ /** Answers a month. */
7084
+ cap: number | null;
7085
+ /** Answers this month (UTC); null when it could not be read. */
7086
+ answers_this_month: number | null;
7087
+ /** The most places they asked from on one day in the last 31: more than a few can mean the link was passed on. */
7088
+ places: number | null;
7089
+ /** Their questions are kept for 30 days. */
7090
+ keep_questions: boolean;
7091
+ state: KnowledgeGuestState;
7092
+ /** Keys a roll replaced. One still live means it would not stop: roll or remove again. */
7093
+ earlier: Array<{
7094
+ id: string;
7095
+ state: KnowledgeGuestState;
7096
+ }>;
7097
+ }
7098
+ /** What knowledge.guests.list() returns. */
7099
+ export interface KnowledgeGuestList {
7100
+ /** Live and paused, newest first. */
7101
+ guests: KnowledgeGuest[];
7102
+ /** Ended and removed. */
7103
+ ended: KnowledgeGuest[];
7104
+ /** The most live guests an account can have. */
7105
+ max_live: number;
7106
+ /** The answers a month a new guest gets unless you say; null when it could not be read. */
7107
+ default_cap: number | null;
7108
+ }
7109
+ /** What knowledge.guests.give() takes. Give at least one collection or tag. */
7110
+ export interface KnowledgeGuestGive {
7111
+ /** Who they are (1 to 120 characters). */
7112
+ name: string;
7113
+ /** Collection ids, up to 32. */
7114
+ collections?: string[];
7115
+ /** Tags, up to 32. */
7116
+ tags?: string[];
7117
+ /** 1 to 365. Default 90. Not with ends_at. */
7118
+ ends_in_days?: number;
7119
+ /** A date (`2027-02-24`, the end of that day UTC) or a time with its offset, up to a year out. Not with ends_in_days. */
7120
+ ends_at?: string;
7121
+ /** Answers a month. Default half the account's. */
7122
+ cap?: number;
7123
+ /** Keep their questions for 30 days, for you to read in the log. Default true. */
7124
+ keep_questions?: boolean;
7125
+ /** A UUID of your own: a retry with the same one gives the same guest once. */
7126
+ request_id?: string;
7127
+ }
7128
+ /** What knowledge.guests.update() takes: any of give()'s fields. */
7129
+ export type KnowledgeGuestChange = Partial<Omit<KnowledgeGuestGive, 'request_id'>>;
7130
+ /** A guest's key, shown once, from knowledge.guests.give() and roll(). */
7131
+ export interface KnowledgeGuestKey {
7132
+ guest: KnowledgeGuest;
7133
+ /** The key itself. Hand it to the guest; never store or log it. */
7134
+ key: string;
7135
+ /** The key ready to send: a link to ask from a browser, a Claude Code command (null when it cannot be made) and the key. */
7136
+ ready: {
7137
+ ask_link: string;
7138
+ claude_code: string | null;
7139
+ api_key: string;
7140
+ };
7141
+ /** Asked to keep questions, but Knowledge cannot keep them yet: the guest was given access without. */
7142
+ questions_not_live?: true;
7143
+ /** From roll(): earlier keys that would not stop. Roll or remove again. */
7144
+ still_live?: string[];
7145
+ }
7146
+ /** What knowledge.guests.update() returns. */
7147
+ export interface KnowledgeGuestUpdated {
7148
+ guest: KnowledgeGuest;
7149
+ /** What changed: name, scope, ends, cap, questions. */
7150
+ changed: Array<'name' | 'scope' | 'ends' | 'cap' | 'questions'>;
7151
+ /** The change gave them more: more to read, a later end or more answers. */
7152
+ widened: boolean;
7153
+ /** Asked to keep questions, but Knowledge cannot keep them yet. */
7154
+ questions_not_live?: true;
7155
+ }
7156
+ /** One thing a guest did, from knowledge.guests.log(). */
7157
+ export interface KnowledgeGuestLogRow {
7158
+ at: string | null;
7159
+ /** ask_page: the Ask link; ai_app: an AI app such as Claude Code; api: anything else. */
7160
+ where: 'ask_page' | 'ai_app' | 'api';
7161
+ /** True for a question, false for anything else (a search, a list). */
7162
+ asked: boolean;
7163
+ /** The HTTP status the guest got. */
7164
+ status: number | null;
7165
+ /** How the question was answered (such as `ok` or `no_results`), never the answer itself. */
7166
+ answer: string | null;
7167
+ /** How many sources the answer cited. */
7168
+ sources: number | null;
7169
+ /** Where they asked from, as a number: 1 for the first place on this page, 2 for the next. Never an address, and per page only. */
7170
+ place: number | null;
7171
+ /** The question, when it was kept and the caller may read it; otherwise null. */
7172
+ question: string | null;
7173
+ }
7174
+ /** What knowledge.guests.log() returns. */
7175
+ export interface KnowledgeGuestLog {
7176
+ /** The guest's id. */
7177
+ guest: string;
7178
+ rows: KnowledgeGuestLogRow[];
7179
+ /** Pass back as cursor for the next page; null on the last. */
7180
+ next_cursor: string | null;
7181
+ /** Questions are the owner's to read: true when they were left out for this caller. */
7182
+ questions_hidden?: true;
7183
+ }
6912
7184
  /** Where a session is kept: localStorage, Capacitor Preferences, or anything with these three. */
6913
7185
  export interface SessionStorageLike {
6914
7186
  /** The stored value, or null. */
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.93.0';
29
+ export const VERSION = '0.98.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;
@@ -71,6 +71,8 @@ export class AwesomateError extends Error {
71
71
  roles;
72
72
  /** With serverCode restore_to_public (`files.restore()`): the path in public/ it would go back to. */
73
73
  target;
74
+ /** With serverCode roll_incomplete (`knowledge.guests.roll()`): the guest's keys still live. Roll or remove again. */
75
+ stillLive;
74
76
  constructor(
75
77
  /** Why it failed. */
76
78
  code, message,
@@ -107,16 +109,24 @@ export class AwesomateError extends Error {
107
109
  this.roles = details.roles;
108
110
  if (details.target !== undefined)
109
111
  this.target = details.target;
112
+ if (details.stillLive !== undefined)
113
+ this.stillLive = details.stillLive;
110
114
  }
111
115
  }
112
116
  /** Every code the hub uses for "the account has switched this off in its privacy settings". */
113
117
  const CONSENT_CODES = new Set(['consent_blocked', 'consent_denied', 'consent_required', 'consent_off', 'consent_missing', 'files_consent_off']);
114
118
  const UPGRADE_CODES = new Set(['upgrade_required', 'plan_required']);
119
+ /** Guest access (knowledge.guests): a request to fix, and a guest or account that stands in the way. */
120
+ const GUEST_VALIDATION_CODES = new Set(['scope_required', 'cap_required', 'nothing_to_change']);
121
+ const GUEST_CONFLICT_CODES = new Set(['too_many_guests', 'guest_ended', 'guest_paused', 'guest_agent_paused']);
115
122
  /** A code-like word: some hub areas send their code in `error` and the sentence in `message`. */
116
123
  const CODE_LIKE = /^[a-z][a-z0-9_]*$/;
117
124
  function errorCode(status, server, body = {}) {
118
125
  if (server === 'validation' || server === 'invalid' || status === 422)
119
126
  return 'validation';
127
+ // a 400 that says the request was wrong (invalid_request, a checked body's issues), or one of Guest access's own
128
+ if (status === 400 && (server === 'invalid_request' || Array.isArray(body.issues) || (server && GUEST_VALIDATION_CODES.has(server))))
129
+ return 'validation';
120
130
  // A file the hub will not take as sent: too big, no length, or a type it refuses.
121
131
  if (status === 411 || status === 413 || status === 415)
122
132
  return 'validation';
@@ -140,7 +150,7 @@ function errorCode(status, server, body = {}) {
140
150
  // changed: a thing a setup adds to changed since checkSetup(). already / already_suggested: a list
141
151
  // already fills from that tag, or someone has suggested it (lists.proposeTagRule()).
142
152
  if (server === 'conflict' || server === 'stale' || server === 'not_draft' || server === 'not_run' || server === 'changed'
143
- || server === 'already' || server === 'already_suggested')
153
+ || server === 'already' || server === 'already_suggested' || (server && GUEST_CONFLICT_CODES.has(server)))
144
154
  return 'conflict';
145
155
  if (status === 404 && server !== 'not_live')
146
156
  return 'not_found';
@@ -180,11 +190,15 @@ function refusal(status, json) {
180
190
  const target = serverCode === 'restore_to_public' ? nonEmpty(json.target) : undefined;
181
191
  if (target)
182
192
  details.target = target;
193
+ if (serverCode === 'roll_incomplete' && Array.isArray(json.still_live))
194
+ details.stillLive = json.still_live.map(String);
195
+ const issue = Array.isArray(json.issues) ? json.issues[0] : undefined;
196
+ const issuePath = issue && typeof issue === 'object' && issue.path !== '(root)' ? nonEmpty(issue.path) : undefined;
183
197
  return {
184
198
  code: errorCode(status, serverCode, json),
185
199
  message: (codeInError ? sentence : error ?? sentence) ?? `The hub answered ${status}.`,
186
200
  serverCode,
187
- field: nonEmpty(json.field),
201
+ field: nonEmpty(json.field) ?? issuePath,
188
202
  details,
189
203
  };
190
204
  }
@@ -1072,7 +1086,10 @@ export class AwesomateClient {
1072
1086
  },
1073
1087
  /**
1074
1088
  * One test copy of a draft to the key's own person, and nobody else (5 of an email an hour).
1075
- * Needs crm:draft and full team access.
1089
+ * Needs crm:draft and full team access. Where the account has Better email designs
1090
+ * (`email_design_studio`), a key's test copy waits until `designPreview({ id })` has drawn this
1091
+ * version (server code `preview_required`) and until what its pictures show must be fixed is fixed
1092
+ * (`qa_blocker`, with `blockers`).
1076
1093
  */
1077
1094
  test: async (id) => this.request('POST', `/api/my-crm/v1/emails/${emailId(id)}/test`, {}, false),
1078
1095
  /** Replace a draft. Once someone approved it, it is refused: a person changes it in the hub. */
@@ -1124,7 +1141,9 @@ export class AwesomateClient {
1124
1141
  },
1125
1142
  /**
1126
1143
  * The usual From for each kind of email (`one_to_one`: an email to one person; `automation`: an
1127
- * automation's service email that names no From), and the owner's own addresses it can be. Needs crm:read.
1144
+ * automation's service email that names no From; `video`: a video's ticket emails; `forms`: a form's
1145
+ * download email; `desk`: a reply from the account's own support desk), and the owner's own addresses
1146
+ * it can be. Needs crm:read.
1128
1147
  */
1129
1148
  fromDefaults: async () => this.request('GET', '/api/my-crm/v1/emails/from-defaults'),
1130
1149
  /**
@@ -1133,6 +1152,34 @@ export class AwesomateClient {
1133
1152
  * and `own_address`). It never adds or proves an address: the owner does that in the hub.
1134
1153
  */
1135
1154
  setFromDefault: async (kind, from) => this.request('PUT', '/api/my-crm/v1/emails/from-defaults', { kind, from }, false),
1155
+ /**
1156
+ * Pictures of an email as it will look, drawn by the hub: `desktop` (600 px wide), `phone` (375 px)
1157
+ * and `dark` (a dark inbox), with the hub's footer and preview text in and merge fields filled for a
1158
+ * sample person. Name one: `id` (a saved email), `templateId` (an email template) or `mjml` (an email
1159
+ * design not saved yet, with its `subject`, `preheader` and `kind` if you have them). Each picture's
1160
+ * `url` works for 10 minutes without a token, so you can put it in an `<img>`; after that, ask again.
1161
+ * When there are none, `unavailable` says why (`preview_limit`: the account's 30 in 10 minutes are
1162
+ * used; `preview_unavailable`: try again in a minute). Needs crm:draft, full team access and
1163
+ * Better email designs on the account (`email_design_studio`; `unavailable`, server code
1164
+ * `feature_unavailable`, otherwise).
1165
+ *
1166
+ * @example
1167
+ * const [first] = await db.emails.list();
1168
+ * const pics = await db.emails.designPreview({ id: first.id });
1169
+ * for (const p of pics.pictures) console.log(p.name, p.url);
1170
+ */
1171
+ designPreview: async (input) => {
1172
+ const body = 'id' in input ? { id: input.id } : 'templateId' in input ? { template_id: input.templateId }
1173
+ : { mjml: input.mjml, subject: input.subject, preheader: input.preheader, kind: input.kind };
1174
+ const r = await this.request('POST', '/api/my-crm/v1/emails/design-preview', body, false);
1175
+ return {
1176
+ pictures: (r.previews ?? []).map((p) => ({ name: p.name, width: p.width, height: p.height, url: p.url, cut: p.cut === true })),
1177
+ qa: r.qa ? { blockers: r.qa.blockers ?? [], warnings: r.qa.warnings ?? [] } : null,
1178
+ expiresAt: r.previews_expire_at ?? null,
1179
+ leftOut: r.previews_pictures_left_out ?? [],
1180
+ unavailable: r.previews_unavailable ? { code: r.previews_unavailable.code, error: r.previews_unavailable.error, retryAfter: r.previews_unavailable.retry_after ?? null } : null,
1181
+ };
1182
+ },
1136
1183
  };
1137
1184
  /**
1138
1185
  * Email series: emails that go to one person at a time over days, starting when something
@@ -1784,6 +1831,66 @@ export class AwesomateClient {
1784
1831
  ...(options.enabled && options.confirm ? { confirm: options.confirm } : {}),
1785
1832
  }, false);
1786
1833
  },
1834
+ /**
1835
+ * Guest access: a named, time-limited pass for someone outside the business (an agency, a
1836
+ * contractor) to ask the collections or tags the owner picks. Each guest is one key on the
1837
+ * account's Guest answers agent, never shown documents only the owner can see. Needs the account's
1838
+ * token at the Owner level (knowledge:read to read, knowledge:write to change), never an app key or
1839
+ * the Hub Key. A chat connection's key, or a Claude Code key while it acts for the owner, may read
1840
+ * (list, log) but never give, change, roll or remove. Every plan with Knowledge, where the
1841
+ * account has Guest access (`knowledge_guests`; feature_unavailable otherwise).
1842
+ * `id` is the key the guest holds now; after a roll, any earlier id still finds them.
1843
+ *
1844
+ * @example
1845
+ * const g = await db.knowledge.guests.give({ name: 'Jordan, ads manager', tags: ['product-info'], ends_in_days: 30 });
1846
+ * console.log(g.ready.ask_link); // shown once: send it to Jordan yourself
1847
+ */
1848
+ guests: {
1849
+ /**
1850
+ * Every guest: `guests` live or paused, newest first; `ended` ended or removed. Never a key. The
1851
+ * account's token at the Owner level with knowledge:read.
1852
+ */
1853
+ list: () => this.request('GET', '/api/knowledge/guests'),
1854
+ /**
1855
+ * Give someone access: the account's token at the Owner level with knowledge:write, never an app
1856
+ * key, the Hub Key, a chat connection's key or a Claude Code key acting for the owner. At least one
1857
+ * collection or tag. Ends in 90 days unless `ends_in_days` or
1858
+ * `ends_at` says otherwise (1 to 365 days); `cap` answers a month, half the account's unless set,
1859
+ * counting toward the account's answers. The key comes back once, in `key` and `ready`: hand it
1860
+ * to the guest and never store it. Pass your own `request_id` (a UUID) so a retry gives the same
1861
+ * guest once. A retry after the guest took the account's last place answers `too_many_guests`:
1862
+ * find them with `list()` and `roll()` them for a key.
1863
+ */
1864
+ give: (guest) => this.request('POST', '/api/knowledge/guests', guest, false),
1865
+ /**
1866
+ * Change a guest: any field of `give()`, and only what differs is changed. `widened` says the
1867
+ * change gave them more (more to read, a later end or more answers).
1868
+ */
1869
+ update: (id, change) => this.request('PATCH', `/api/knowledge/guests/${encodeURIComponent(id)}`, change, false),
1870
+ /**
1871
+ * A new key for the guest, ending when the old one would have, and the old key stopped: for a
1872
+ * link that went further than it should. The new key comes back once. Pass your own
1873
+ * `request_id` so a retry shows the same new key. `roll_incomplete` (serverCode) means the old
1874
+ * key would not stop, so the new one is not shown; `stillLive` on the error names the keys still
1875
+ * live (the new one too when it would not stop either): roll or remove again.
1876
+ */
1877
+ roll: (id, options = {}) => this.request('POST', `/api/knowledge/guests/${encodeURIComponent(id)}/roll`, options.request_id ? { request_id: options.request_id } : {}, false),
1878
+ /** End a guest's access for good: every key they held stops and their kept questions are forgotten. */
1879
+ remove: (id) => this.request('DELETE', `/api/knowledge/guests/${encodeURIComponent(id)}`, undefined, false),
1880
+ /**
1881
+ * What a guest did, newest first: when, from where, and the question when it was kept. `limit`
1882
+ * is 1 to 200 (default 50); pass `next_cursor` back as `cursor` for the page after.
1883
+ */
1884
+ log: (id, options = {}) => {
1885
+ const q = new URLSearchParams();
1886
+ if (options.limit !== undefined)
1887
+ q.set('limit', String(options.limit));
1888
+ if (options.cursor)
1889
+ q.set('cursor', options.cursor);
1890
+ const qs = q.toString();
1891
+ return this.request('GET', `/api/knowledge/guests/${encodeURIComponent(id)}/log${qs ? `?${qs}` : ''}`);
1892
+ },
1893
+ },
1787
1894
  };
1788
1895
  /**
1789
1896
  * Tell Contacts something happened to someone ("job_paid", "quote_sent"), so any email series
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awesomate/sdk",
3
- "version": "0.93.0",
3
+ "version": "0.98.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",