@awesomate/sdk 0.93.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 +90 -4
- package/dist/index.js +36 -3
- 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. */
|
|
@@ -1400,7 +1403,9 @@ export declare class AwesomateClient {
|
|
|
1400
1403
|
}) => Promise<EmailFromChoice[] | null>;
|
|
1401
1404
|
/**
|
|
1402
1405
|
* 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
|
|
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.
|
|
1404
1409
|
*/
|
|
1405
1410
|
fromDefaults: () => Promise<EmailFromDefaults>;
|
|
1406
1411
|
/**
|
|
@@ -1409,6 +1414,23 @@ export declare class AwesomateClient {
|
|
|
1409
1414
|
* and `own_address`). It never adds or proves an address: the owner does that in the hub.
|
|
1410
1415
|
*/
|
|
1411
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>;
|
|
1412
1434
|
};
|
|
1413
1435
|
/**
|
|
1414
1436
|
* Email series: emails that go to one person at a time over days, starting when something
|
|
@@ -5416,7 +5438,7 @@ export interface EmailDraftInput {
|
|
|
5416
5438
|
from?: string;
|
|
5417
5439
|
}
|
|
5418
5440
|
/** The kinds of email a usual From is set for. */
|
|
5419
|
-
export type EmailFromDefaultKind = 'one_to_one' | 'automation';
|
|
5441
|
+
export type EmailFromDefaultKind = 'one_to_one' | 'automation' | 'video' | 'forms' | 'desk';
|
|
5420
5442
|
/** One address an email can go from, from `emails.fromChoices()` (and `from_choices` on `get()` and `preview()`). */
|
|
5421
5443
|
export interface EmailFromChoice {
|
|
5422
5444
|
/** `'sending_name'`, or the own address itself: what to pass as `from`. */
|
|
@@ -5432,6 +5454,12 @@ export interface EmailFromChoice {
|
|
|
5432
5454
|
paused?: boolean;
|
|
5433
5455
|
/** An own address's uses, as the owner switched them on. */
|
|
5434
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';
|
|
5435
5463
|
/** The name on its From line; null for the personal name. */
|
|
5436
5464
|
name?: string | null;
|
|
5437
5465
|
label: string;
|
|
@@ -5454,6 +5482,64 @@ export interface EmailFromDefaults {
|
|
|
5454
5482
|
uses: Array<'one_to_one' | 'invites' | 'lists'>;
|
|
5455
5483
|
}>;
|
|
5456
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;
|
|
5542
|
+
}
|
|
5457
5543
|
/** Who a picked-people email reaches, as a model may see it. */
|
|
5458
5544
|
export interface EmailReach {
|
|
5459
5545
|
count: number;
|
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. */
|
|
@@ -1124,7 +1127,9 @@ export class AwesomateClient {
|
|
|
1124
1127
|
},
|
|
1125
1128
|
/**
|
|
1126
1129
|
* 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
|
|
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.
|
|
1128
1133
|
*/
|
|
1129
1134
|
fromDefaults: async () => this.request('GET', '/api/my-crm/v1/emails/from-defaults'),
|
|
1130
1135
|
/**
|
|
@@ -1133,6 +1138,34 @@ export class AwesomateClient {
|
|
|
1133
1138
|
* and `own_address`). It never adds or proves an address: the owner does that in the hub.
|
|
1134
1139
|
*/
|
|
1135
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
|
+
},
|
|
1136
1169
|
};
|
|
1137
1170
|
/**
|
|
1138
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",
|