@awesomate/sdk 0.92.0 → 0.96.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 +166 -2
- package/dist/index.js +60 -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.96.0";
|
|
30
30
|
/** Augmented by the generated awesomate.d.ts, so each kind's rows are typed. */
|
|
31
31
|
export interface Kinds {
|
|
32
32
|
}
|
|
@@ -1344,7 +1344,10 @@ export declare class AwesomateClient {
|
|
|
1344
1344
|
preview: (id: string) => Promise<EmailPreview | null>;
|
|
1345
1345
|
/**
|
|
1346
1346
|
* 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.
|
|
1347
|
+
* Needs crm:draft and full team access. Where the account has Better email designs
|
|
1348
|
+
* (`email_design_studio`), a key's test copy waits until `designPreview({ id })` has drawn this
|
|
1349
|
+
* version (server code `preview_required`) and until what its pictures show must be fixed is fixed
|
|
1350
|
+
* (`qa_blocker`, with `blockers`).
|
|
1348
1351
|
*/
|
|
1349
1352
|
test: (id: string) => Promise<EmailTestSent>;
|
|
1350
1353
|
/** Replace a draft. Once someone approved it, it is refused: a person changes it in the hub. */
|
|
@@ -1385,6 +1388,49 @@ export declare class AwesomateClient {
|
|
|
1385
1388
|
}) => Promise<EmailBrief>;
|
|
1386
1389
|
/** The result of a `brief()` that answered `pending`: still `pending`, or the questions or the draft. */
|
|
1387
1390
|
briefStatus: (jobId: string) => Promise<EmailBrief>;
|
|
1391
|
+
/**
|
|
1392
|
+
* The addresses an email can go from (needs `own_address` on the account): the sending name, then
|
|
1393
|
+
* each of the account's own ready addresses with its uses and whether it fits an email to a list,
|
|
1394
|
+
* or to `picked` people picked by hand (50 or fewer is one-to-one). Null when there are no own
|
|
1395
|
+
* addresses: every email goes from the sending name. Pass a choice's `value` as `from` on `draft()`.
|
|
1396
|
+
*
|
|
1397
|
+
* @example
|
|
1398
|
+
* const choices = await db.emails.fromChoices({ picked: 1 });
|
|
1399
|
+
* const own = choices?.find((c) => c.own && c.allowed);
|
|
1400
|
+
*/
|
|
1401
|
+
fromChoices: (opts?: {
|
|
1402
|
+
picked?: number;
|
|
1403
|
+
}) => Promise<EmailFromChoice[] | null>;
|
|
1404
|
+
/**
|
|
1405
|
+
* The usual From for each kind of email (`one_to_one`: an email to one person; `automation`: an
|
|
1406
|
+
* automation's service email that names no From; `video`: a video's ticket emails; `forms`: a form's
|
|
1407
|
+
* download email; `desk`: a reply from the account's own support desk), and the owner's own addresses
|
|
1408
|
+
* it can be. Needs crm:read.
|
|
1409
|
+
*/
|
|
1410
|
+
fromDefaults: () => Promise<EmailFromDefaults>;
|
|
1411
|
+
/**
|
|
1412
|
+
* Set the usual From for a kind of email to one of the owner's own ready addresses set up for it,
|
|
1413
|
+
* or `'sending_name'` to go back to the sending name. Only the account owner's key (needs crm:draft
|
|
1414
|
+
* and `own_address`). It never adds or proves an address: the owner does that in the hub.
|
|
1415
|
+
*/
|
|
1416
|
+
setFromDefault: (kind: EmailFromDefaultKind, from: string) => Promise<EmailFromDefaults>;
|
|
1417
|
+
/**
|
|
1418
|
+
* Pictures of an email as it will look, drawn by the hub: `desktop` (600 px wide), `phone` (375 px)
|
|
1419
|
+
* and `dark` (a dark inbox), with the hub's footer and preview text in and merge fields filled for a
|
|
1420
|
+
* sample person. Name one: `id` (a saved email), `templateId` (an email template) or `mjml` (an email
|
|
1421
|
+
* design not saved yet, with its `subject`, `preheader` and `kind` if you have them). Each picture's
|
|
1422
|
+
* `url` works for 10 minutes without a token, so you can put it in an `<img>`; after that, ask again.
|
|
1423
|
+
* When there are none, `unavailable` says why (`preview_limit`: the account's 30 in 10 minutes are
|
|
1424
|
+
* used; `preview_unavailable`: try again in a minute). Needs crm:draft, full team access and
|
|
1425
|
+
* Better email designs on the account (`email_design_studio`; `unavailable`, server code
|
|
1426
|
+
* `feature_unavailable`, otherwise).
|
|
1427
|
+
*
|
|
1428
|
+
* @example
|
|
1429
|
+
* const [first] = await db.emails.list();
|
|
1430
|
+
* const pics = await db.emails.designPreview({ id: first.id });
|
|
1431
|
+
* for (const p of pics.pictures) console.log(p.name, p.url);
|
|
1432
|
+
*/
|
|
1433
|
+
designPreview: (input: EmailDesignPreviewInput) => Promise<EmailDesignPreview>;
|
|
1388
1434
|
};
|
|
1389
1435
|
/**
|
|
1390
1436
|
* Email series: emails that go to one person at a time over days, starting when something
|
|
@@ -5383,6 +5429,116 @@ export interface EmailDraftInput {
|
|
|
5383
5429
|
* is saved.
|
|
5384
5430
|
*/
|
|
5385
5431
|
record?: string | null;
|
|
5432
|
+
/**
|
|
5433
|
+
* Which address it goes from (needs `own_address`): `'sending_name'`, or one of the account's own
|
|
5434
|
+
* ready addresses from `fromChoices()`. Left out, a new one-to-one email from the owner's key goes from
|
|
5435
|
+
* the account's usual one-to-one From, and anything else keeps the From it has. Approval refuses an
|
|
5436
|
+
* address not set up for the email.
|
|
5437
|
+
*/
|
|
5438
|
+
from?: string;
|
|
5439
|
+
}
|
|
5440
|
+
/** The kinds of email a usual From is set for. */
|
|
5441
|
+
export type EmailFromDefaultKind = 'one_to_one' | 'automation' | 'video' | 'forms' | 'desk';
|
|
5442
|
+
/** One address an email can go from, from `emails.fromChoices()` (and `from_choices` on `get()` and `preview()`). */
|
|
5443
|
+
export interface EmailFromChoice {
|
|
5444
|
+
/** `'sending_name'`, or the own address itself: what to pass as `from`. */
|
|
5445
|
+
value: string;
|
|
5446
|
+
address: string;
|
|
5447
|
+
/** An address of the business's own, at its own domain (not its sending name). */
|
|
5448
|
+
own: boolean;
|
|
5449
|
+
/** Whether this email could go from it now. */
|
|
5450
|
+
allowed: boolean;
|
|
5451
|
+
/** When it can't: the use it isn't switched on for. */
|
|
5452
|
+
needs?: 'one_to_one' | 'invites' | 'lists';
|
|
5453
|
+
/** When it can't: list emails from it are stopped for now. */
|
|
5454
|
+
paused?: boolean;
|
|
5455
|
+
/** An own address's uses, as the owner switched them on. */
|
|
5456
|
+
uses?: Array<'one_to_one' | 'invites' | 'lists'>;
|
|
5457
|
+
/**
|
|
5458
|
+
* Where replies to an email from this own address go: `desk` (they come to the account's support desk,
|
|
5459
|
+
* filed with the email they answer), `mailbox` (straight to the address; the owner chose that), or
|
|
5460
|
+
* `no_desk` (straight to the address, since no support desk is switched on).
|
|
5461
|
+
*/
|
|
5462
|
+
replies?: 'desk' | 'mailbox' | 'no_desk';
|
|
5463
|
+
/** The name on its From line; null for the personal name. */
|
|
5464
|
+
name?: string | null;
|
|
5465
|
+
label: string;
|
|
5466
|
+
/** Why it can't be chosen for this email, in a sentence. */
|
|
5467
|
+
note?: string;
|
|
5468
|
+
/** For an own address on an email to many people: what the owner should know first. */
|
|
5469
|
+
warning?: string;
|
|
5470
|
+
}
|
|
5471
|
+
/** From `emails.fromDefaults()` and `emails.setFromDefault()`. */
|
|
5472
|
+
export interface EmailFromDefaults {
|
|
5473
|
+
/** Each kind: the address (null: the sending name), and whether it is used now (false: it no longer fits, so the sending name goes). */
|
|
5474
|
+
defaults: Array<{
|
|
5475
|
+
kind: EmailFromDefaultKind;
|
|
5476
|
+
address: string | null;
|
|
5477
|
+
applies: boolean;
|
|
5478
|
+
}>;
|
|
5479
|
+
/** The owner's own ready addresses, each with its uses: what a usual From can be. */
|
|
5480
|
+
addresses: Array<{
|
|
5481
|
+
address: string;
|
|
5482
|
+
uses: Array<'one_to_one' | 'invites' | 'lists'>;
|
|
5483
|
+
}>;
|
|
5484
|
+
}
|
|
5485
|
+
/** Which email `emails.designPreview()` draws: a saved email, a template, or a design not saved yet. */
|
|
5486
|
+
export type EmailDesignPreviewInput = {
|
|
5487
|
+
id: string;
|
|
5488
|
+
} | {
|
|
5489
|
+
templateId: number;
|
|
5490
|
+
} | {
|
|
5491
|
+
mjml: string;
|
|
5492
|
+
subject?: string;
|
|
5493
|
+
preheader?: string;
|
|
5494
|
+
kind?: 'marketing' | 'transactional';
|
|
5495
|
+
};
|
|
5496
|
+
/** One picture of an email. */
|
|
5497
|
+
export interface EmailPicture {
|
|
5498
|
+
/**
|
|
5499
|
+
* `desktop` (600 px wide), `phone` (375 px) or `dark` (a dark inbox, 600 px); `desktop_marked`,
|
|
5500
|
+
* `phone_marked` or `dark_marked`: that page with each of `qa`'s findings on it framed in red.
|
|
5501
|
+
*/
|
|
5502
|
+
name: 'desktop' | 'phone' | 'dark' | 'desktop_marked' | 'phone_marked' | 'dark_marked';
|
|
5503
|
+
width: number;
|
|
5504
|
+
height: number;
|
|
5505
|
+
/** The PNG, for 10 minutes, with no token needed. */
|
|
5506
|
+
url: string;
|
|
5507
|
+
/** True when the email is taller than the hub draws and the picture stops part way. */
|
|
5508
|
+
cut: boolean;
|
|
5509
|
+
}
|
|
5510
|
+
/** What `emails.designPreview()` answers. */
|
|
5511
|
+
export interface EmailDesignPreview {
|
|
5512
|
+
pictures: EmailPicture[];
|
|
5513
|
+
/** When the pictures' addresses stop working (ISO time), or null when there are none. */
|
|
5514
|
+
expiresAt: string | null;
|
|
5515
|
+
/** 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). */
|
|
5516
|
+
leftOut: Array<{
|
|
5517
|
+
url: string;
|
|
5518
|
+
problem: string;
|
|
5519
|
+
}>;
|
|
5520
|
+
/** Why there are no pictures, or null. */
|
|
5521
|
+
unavailable: {
|
|
5522
|
+
code: string;
|
|
5523
|
+
error: string;
|
|
5524
|
+
retryAfter: number | null;
|
|
5525
|
+
} | null;
|
|
5526
|
+
/**
|
|
5527
|
+
* What the pictures show, or null when the hub measured nothing. `blockers` (a word cut or past the
|
|
5528
|
+
* edge at phone width, a logo drawn as a solid box) hold back a key's test copy until fixed;
|
|
5529
|
+
* `warnings` are worth fixing.
|
|
5530
|
+
*/
|
|
5531
|
+
qa: {
|
|
5532
|
+
blockers: EmailDesignFinding[];
|
|
5533
|
+
warnings: EmailDesignFinding[];
|
|
5534
|
+
} | null;
|
|
5535
|
+
}
|
|
5536
|
+
/** One thing the pictures of an email show: what it is, on which page, the element, and a sentence saying what to do. */
|
|
5537
|
+
export interface EmailDesignFinding {
|
|
5538
|
+
code: string;
|
|
5539
|
+
page: string;
|
|
5540
|
+
element: string;
|
|
5541
|
+
message: string;
|
|
5386
5542
|
}
|
|
5387
5543
|
/** Who a picked-people email reaches, as a model may see it. */
|
|
5388
5544
|
export interface EmailReach {
|
|
@@ -5459,6 +5615,10 @@ export interface EmailPreview {
|
|
|
5459
5615
|
checks: EmailSeriesChecks | null;
|
|
5460
5616
|
reviewUrl: string;
|
|
5461
5617
|
next: string;
|
|
5618
|
+
/** The addresses it could go from (only when the account has its own ready addresses). */
|
|
5619
|
+
from_choices?: EmailFromChoice[];
|
|
5620
|
+
/** True when the choices could not be read just now. */
|
|
5621
|
+
from_choices_unread?: true;
|
|
5462
5622
|
}
|
|
5463
5623
|
/** From `emails.test()`. */
|
|
5464
5624
|
export interface EmailTestSent {
|
|
@@ -5530,6 +5690,10 @@ export interface EmailDetail {
|
|
|
5530
5690
|
shape?: 'direct';
|
|
5531
5691
|
/** A one-to-one email's record (the id of the job, booking or quote it is about), or null. */
|
|
5532
5692
|
record?: string | null;
|
|
5693
|
+
/** The addresses it could go from (only when the account has its own ready addresses). */
|
|
5694
|
+
from_choices?: EmailFromChoice[];
|
|
5695
|
+
/** True when the choices could not be read just now. */
|
|
5696
|
+
from_choices_unread?: true;
|
|
5533
5697
|
}
|
|
5534
5698
|
/** `emails.discard()`: the draft is stopped and left out of the lists. */
|
|
5535
5699
|
export interface EmailDiscarded {
|
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.96.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;
|
|
@@ -1072,7 +1072,10 @@ export class AwesomateClient {
|
|
|
1072
1072
|
},
|
|
1073
1073
|
/**
|
|
1074
1074
|
* 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.
|
|
1075
|
+
* Needs crm:draft and full team access. Where the account has Better email designs
|
|
1076
|
+
* (`email_design_studio`), a key's test copy waits until `designPreview({ id })` has drawn this
|
|
1077
|
+
* version (server code `preview_required`) and until what its pictures show must be fixed is fixed
|
|
1078
|
+
* (`qa_blocker`, with `blockers`).
|
|
1076
1079
|
*/
|
|
1077
1080
|
test: async (id) => this.request('POST', `/api/my-crm/v1/emails/${emailId(id)}/test`, {}, false),
|
|
1078
1081
|
/** Replace a draft. Once someone approved it, it is refused: a person changes it in the hub. */
|
|
@@ -1108,6 +1111,61 @@ export class AwesomateClient {
|
|
|
1108
1111
|
},
|
|
1109
1112
|
/** The result of a `brief()` that answered `pending`: still `pending`, or the questions or the draft. */
|
|
1110
1113
|
briefStatus: async (jobId) => briefFromWire(await this.request('GET', `/api/my-crm/v1/emails/brief/${encodeURIComponent(jobId)}`)),
|
|
1114
|
+
/**
|
|
1115
|
+
* The addresses an email can go from (needs `own_address` on the account): the sending name, then
|
|
1116
|
+
* each of the account's own ready addresses with its uses and whether it fits an email to a list,
|
|
1117
|
+
* or to `picked` people picked by hand (50 or fewer is one-to-one). Null when there are no own
|
|
1118
|
+
* addresses: every email goes from the sending name. Pass a choice's `value` as `from` on `draft()`.
|
|
1119
|
+
*
|
|
1120
|
+
* @example
|
|
1121
|
+
* const choices = await db.emails.fromChoices({ picked: 1 });
|
|
1122
|
+
* const own = choices?.find((c) => c.own && c.allowed);
|
|
1123
|
+
*/
|
|
1124
|
+
fromChoices: async (opts = {}) => {
|
|
1125
|
+
const q = opts.picked !== undefined ? `?people=${encodeURIComponent(String(opts.picked))}` : '';
|
|
1126
|
+
return (await this.request('GET', `/api/my-crm/v1/emails/from-choices${q}`)).from?.choices ?? null;
|
|
1127
|
+
},
|
|
1128
|
+
/**
|
|
1129
|
+
* The usual From for each kind of email (`one_to_one`: an email to one person; `automation`: an
|
|
1130
|
+
* automation's service email that names no From; `video`: a video's ticket emails; `forms`: a form's
|
|
1131
|
+
* download email; `desk`: a reply from the account's own support desk), and the owner's own addresses
|
|
1132
|
+
* it can be. Needs crm:read.
|
|
1133
|
+
*/
|
|
1134
|
+
fromDefaults: async () => this.request('GET', '/api/my-crm/v1/emails/from-defaults'),
|
|
1135
|
+
/**
|
|
1136
|
+
* Set the usual From for a kind of email to one of the owner's own ready addresses set up for it,
|
|
1137
|
+
* or `'sending_name'` to go back to the sending name. Only the account owner's key (needs crm:draft
|
|
1138
|
+
* and `own_address`). It never adds or proves an address: the owner does that in the hub.
|
|
1139
|
+
*/
|
|
1140
|
+
setFromDefault: async (kind, from) => this.request('PUT', '/api/my-crm/v1/emails/from-defaults', { kind, from }, false),
|
|
1141
|
+
/**
|
|
1142
|
+
* Pictures of an email as it will look, drawn by the hub: `desktop` (600 px wide), `phone` (375 px)
|
|
1143
|
+
* and `dark` (a dark inbox), with the hub's footer and preview text in and merge fields filled for a
|
|
1144
|
+
* sample person. Name one: `id` (a saved email), `templateId` (an email template) or `mjml` (an email
|
|
1145
|
+
* design not saved yet, with its `subject`, `preheader` and `kind` if you have them). Each picture's
|
|
1146
|
+
* `url` works for 10 minutes without a token, so you can put it in an `<img>`; after that, ask again.
|
|
1147
|
+
* When there are none, `unavailable` says why (`preview_limit`: the account's 30 in 10 minutes are
|
|
1148
|
+
* used; `preview_unavailable`: try again in a minute). Needs crm:draft, full team access and
|
|
1149
|
+
* Better email designs on the account (`email_design_studio`; `unavailable`, server code
|
|
1150
|
+
* `feature_unavailable`, otherwise).
|
|
1151
|
+
*
|
|
1152
|
+
* @example
|
|
1153
|
+
* const [first] = await db.emails.list();
|
|
1154
|
+
* const pics = await db.emails.designPreview({ id: first.id });
|
|
1155
|
+
* for (const p of pics.pictures) console.log(p.name, p.url);
|
|
1156
|
+
*/
|
|
1157
|
+
designPreview: async (input) => {
|
|
1158
|
+
const body = 'id' in input ? { id: input.id } : 'templateId' in input ? { template_id: input.templateId }
|
|
1159
|
+
: { mjml: input.mjml, subject: input.subject, preheader: input.preheader, kind: input.kind };
|
|
1160
|
+
const r = await this.request('POST', '/api/my-crm/v1/emails/design-preview', body, false);
|
|
1161
|
+
return {
|
|
1162
|
+
pictures: (r.previews ?? []).map((p) => ({ name: p.name, width: p.width, height: p.height, url: p.url, cut: p.cut === true })),
|
|
1163
|
+
qa: r.qa ? { blockers: r.qa.blockers ?? [], warnings: r.qa.warnings ?? [] } : null,
|
|
1164
|
+
expiresAt: r.previews_expire_at ?? null,
|
|
1165
|
+
leftOut: r.previews_pictures_left_out ?? [],
|
|
1166
|
+
unavailable: r.previews_unavailable ? { code: r.previews_unavailable.code, error: r.previews_unavailable.error, retryAfter: r.previews_unavailable.retry_after ?? null } : null,
|
|
1167
|
+
};
|
|
1168
|
+
},
|
|
1111
1169
|
};
|
|
1112
1170
|
/**
|
|
1113
1171
|
* Email series: emails that go to one person at a time over days, starting when something
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@awesomate/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.96.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",
|