delivrie 0.2.0 → 0.3.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/README.md +4 -4
- package/dist/cjs/client.cjs +82 -4
- package/dist/cjs/client.d.cts +157 -4
- package/dist/cjs/types.d.cts +181 -3
- package/dist/esm/client.d.ts +157 -4
- package/dist/esm/client.js +82 -4
- package/dist/esm/types.d.ts +181 -3
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ import { Delivrie } from "delivrie";
|
|
|
14
14
|
const delivrie = new Delivrie(process.env.DELIVRIE_API_KEY);
|
|
15
15
|
|
|
16
16
|
const { data, error } = await delivrie.emails.send({
|
|
17
|
-
from: "
|
|
17
|
+
from: "Acme <orders@mail.acme.com>",
|
|
18
18
|
to: "ada@example.com",
|
|
19
19
|
subject: "Your order is on its way",
|
|
20
20
|
html: "<p>Thanks for your order!</p>",
|
|
@@ -72,7 +72,7 @@ Change the defaults with `new Delivrie(key, { maxRetries: 0, timeout: 10_000 })`
|
|
|
72
72
|
```ts
|
|
73
73
|
// Attachments: pass a base64 string, a Buffer or a Uint8Array
|
|
74
74
|
await delivrie.emails.send({
|
|
75
|
-
from: "billing@mail.
|
|
75
|
+
from: "billing@mail.acme.com",
|
|
76
76
|
to: ["ada@example.com"],
|
|
77
77
|
subject: "Invoice",
|
|
78
78
|
text: "Your invoice is attached.",
|
|
@@ -81,7 +81,7 @@ await delivrie.emails.send({
|
|
|
81
81
|
|
|
82
82
|
// A published template, scheduled for later
|
|
83
83
|
await delivrie.emails.send({
|
|
84
|
-
from: "hello@mail.
|
|
84
|
+
from: "hello@mail.acme.com",
|
|
85
85
|
to: "ada@example.com",
|
|
86
86
|
template: { id: "welcome", variables: { first_name: "Ada" } },
|
|
87
87
|
scheduledAt: "tomorrow at 9am",
|
|
@@ -91,7 +91,7 @@ await delivrie.emails.send({
|
|
|
91
91
|
await delivrie.emails.batch([{ ... }, { ... }]);
|
|
92
92
|
|
|
93
93
|
// Domains, contacts, broadcasts
|
|
94
|
-
await delivrie.domains.create({ name: "mail.
|
|
94
|
+
await delivrie.domains.create({ name: "mail.acme.com" });
|
|
95
95
|
await delivrie.contacts.create({ email: "ada@example.com", first_name: "Ada" });
|
|
96
96
|
await delivrie.broadcasts.send("bc_123", { scheduled_at: "in 1 hour" });
|
|
97
97
|
|
package/dist/cjs/client.cjs
CHANGED
|
@@ -35,7 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.Delivrie = exports.VERSION = void 0;
|
|
37
37
|
const webhooks_js_1 = require("./webhooks.cjs");
|
|
38
|
-
exports.VERSION = "0.
|
|
38
|
+
exports.VERSION = "0.3.0";
|
|
39
39
|
const DEFAULT_BASE_URL = "https://delivrie.io/api";
|
|
40
40
|
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
41
41
|
const enc = encodeURIComponent;
|
|
@@ -87,7 +87,7 @@ function normalizeEmail(e) {
|
|
|
87
87
|
if (when !== undefined)
|
|
88
88
|
out.scheduled_at = when instanceof Date ? when.toISOString() : when;
|
|
89
89
|
if (attachments)
|
|
90
|
-
out.attachments = attachments.map((a) => (
|
|
90
|
+
out.attachments = attachments.map((a) => (a.content === undefined || typeof a.content === "string" ? { ...a } : { ...a, content: toBase64(a.content) }));
|
|
91
91
|
return out;
|
|
92
92
|
}
|
|
93
93
|
/**
|
|
@@ -96,7 +96,7 @@ function normalizeEmail(e) {
|
|
|
96
96
|
* ```ts
|
|
97
97
|
* import { Delivrie } from "delivrie";
|
|
98
98
|
* const delivrie = new Delivrie(process.env.DELIVRIE_API_KEY);
|
|
99
|
-
* const { data, error } = await delivrie.emails.send({ from: "
|
|
99
|
+
* const { data, error } = await delivrie.emails.send({ from: "Acme <hi@acme.com>", to: "ada@example.com", subject: "Hi", html: "<p>Hello</p>" });
|
|
100
100
|
* ```
|
|
101
101
|
*/
|
|
102
102
|
class Delivrie {
|
|
@@ -134,6 +134,14 @@ class Delivrie {
|
|
|
134
134
|
/** Cancel a scheduled email. */
|
|
135
135
|
cancel: (id) => this.request("POST", `/emails/${enc(id)}/cancel`),
|
|
136
136
|
forward: (id, params) => this.request("POST", `/emails/${enc(id)}/forward`, params),
|
|
137
|
+
/** A sent email's files with download links that work for an hour. */
|
|
138
|
+
attachments: (id) => this.request("GET", `/emails/${enc(id)}/attachments`),
|
|
139
|
+
/** A received email's files with download links that work for an hour. */
|
|
140
|
+
receivedAttachments: (id) => this.request("GET", `/emails/received/${enc(id)}/attachments`),
|
|
141
|
+
/** A public link to the email and its delivery timeline. */
|
|
142
|
+
share: (id, params = {}) => this.request("POST", `/emails/${enc(id)}/share`, params),
|
|
143
|
+
/** Revoke every share link for the email. */
|
|
144
|
+
unshare: (id) => this.request("DELETE", `/emails/${enc(id)}/share`),
|
|
137
145
|
};
|
|
138
146
|
this.domains = {
|
|
139
147
|
create: (params) => this.request("POST", "/domains", params),
|
|
@@ -147,11 +155,16 @@ class Delivrie {
|
|
|
147
155
|
this.apiKeys = {
|
|
148
156
|
create: (params) => this.request("POST", "/api-keys", params),
|
|
149
157
|
list: () => this.request("GET", "/api-keys"),
|
|
158
|
+
/** Rename a key. */
|
|
159
|
+
update: (id, params) => this.request("PATCH", `/api-keys/${enc(id)}`, params),
|
|
150
160
|
remove: (id) => this.request("DELETE", `/api-keys/${enc(id)}`),
|
|
151
161
|
};
|
|
152
162
|
this.webhooks = {
|
|
153
163
|
create: (params) => this.request("POST", "/webhooks", params),
|
|
154
164
|
list: () => this.request("GET", "/webhooks"),
|
|
165
|
+
/** Change the endpoint, events or status (enabled, disabled). */
|
|
166
|
+
update: (id, params) => this.request("PATCH", `/webhooks/${enc(id)}`, params),
|
|
167
|
+
remove: (id) => this.request("DELETE", `/webhooks/${enc(id)}`),
|
|
155
168
|
/** Recent delivery attempts for a webhook. */
|
|
156
169
|
deliveries: (id) => this.request("GET", `/webhooks/${enc(id)}/events`),
|
|
157
170
|
/** Send a test event to the endpoint. */
|
|
@@ -168,11 +181,24 @@ class Delivrie {
|
|
|
168
181
|
update: (idOrEmail, params) => this.request("PATCH", `/contacts/${enc(idOrEmail)}`, params),
|
|
169
182
|
list: (params = {}) => this.request("GET", "/contacts", undefined, { query: { ...params } }),
|
|
170
183
|
remove: (idOrEmail) => this.request("DELETE", `/contacts/${enc(idOrEmail)}`),
|
|
184
|
+
imports: {
|
|
185
|
+
/** Import up to 50,000 contacts from CSV text or a list. Runs in the background. */
|
|
186
|
+
create: (params) => this.request("POST", "/contacts/imports", params),
|
|
187
|
+
get: (id) => this.request("GET", `/contacts/imports/${enc(id)}`),
|
|
188
|
+
list: (params = {}) => this.request("GET", "/contacts/imports", undefined, { query: { ...params } }),
|
|
189
|
+
},
|
|
171
190
|
};
|
|
172
191
|
this.segments = {
|
|
173
192
|
create: (params) => this.request("POST", "/segments", params),
|
|
174
193
|
list: () => this.request("GET", "/segments"),
|
|
194
|
+
get: (id) => this.request("GET", `/segments/${enc(id)}`),
|
|
195
|
+
/** Rename a segment. */
|
|
196
|
+
update: (id, params) => this.request("PATCH", `/segments/${enc(id)}`, params),
|
|
175
197
|
remove: (id) => this.request("DELETE", `/segments/${enc(id)}`),
|
|
198
|
+
/** The contacts in a segment. */
|
|
199
|
+
contacts: (id, params = {}) => this.request("GET", `/segments/${enc(id)}/contacts`, undefined, { query: { ...params } }),
|
|
200
|
+
/** Take contacts (emails or ids) out of a segment. The contacts aren't deleted. */
|
|
201
|
+
removeContacts: (id, contacts) => this.request("DELETE", `/segments/${enc(id)}/contacts`, { contacts }),
|
|
176
202
|
/** Add contacts by email (they're created if needed). */
|
|
177
203
|
addContacts: (id, contacts) => this.request("POST", `/segments/${enc(id)}/contacts`, { contacts: contacts.map((c) => (typeof c === "string" ? { email: c } : c)) }),
|
|
178
204
|
};
|
|
@@ -186,7 +212,18 @@ class Delivrie {
|
|
|
186
212
|
send: (id, params = {}) => this.request("POST", `/broadcasts/${enc(id)}/send`, params.scheduled_at === undefined ? {} : { scheduled_at: params.scheduled_at instanceof Date ? params.scheduled_at.toISOString() : params.scheduled_at }),
|
|
187
213
|
cancel: (id) => this.request("POST", `/broadcasts/${enc(id)}/cancel`),
|
|
188
214
|
/** How many contacts the broadcast will reach. */
|
|
189
|
-
|
|
215
|
+
/** Who it went to (with delivered/opened/clicked/bounced flags), or before sending, who it will reach. */
|
|
216
|
+
recipients: (id, params = {}) => this.request("GET", `/broadcasts/${enc(id)}/recipients`, undefined, { query: { ...params } }),
|
|
217
|
+
/** Clicked links with total and unique clicks. */
|
|
218
|
+
links: (id) => this.request("GET", `/broadcasts/${enc(id)}/links`),
|
|
219
|
+
/** Edit a draft. */
|
|
220
|
+
update: (id, params) => this.request("PATCH", `/broadcasts/${enc(id)}`, params),
|
|
221
|
+
/** Copy it as a new draft. */
|
|
222
|
+
duplicate: (id, params = {}) => this.request("POST", `/broadcasts/${enc(id)}/duplicate`, params),
|
|
223
|
+
/** A draft's subject and blocks with ids. */
|
|
224
|
+
getContent: (id) => this.request("GET", `/broadcasts/${enc(id)}/content`),
|
|
225
|
+
/** Edit a draft block by block. Anyone with it open in the editor sees the change live. */
|
|
226
|
+
editContent: (id, params) => this.request("POST", `/broadcasts/${enc(id)}/content`, params),
|
|
190
227
|
remove: (id) => this.request("DELETE", `/broadcasts/${enc(id)}`),
|
|
191
228
|
};
|
|
192
229
|
this.templates = {
|
|
@@ -196,6 +233,13 @@ class Delivrie {
|
|
|
196
233
|
list: () => this.request("GET", "/templates"),
|
|
197
234
|
/** Publish the current draft so sends use it. */
|
|
198
235
|
publish: (id) => this.request("POST", `/templates/${enc(id)}/publish`),
|
|
236
|
+
/** Change it. Saved as a draft until published. */
|
|
237
|
+
update: (idOrAlias, params) => this.request("PATCH", `/templates/${enc(idOrAlias)}`, params),
|
|
238
|
+
duplicate: (idOrAlias, params = {}) => this.request("POST", `/templates/${enc(idOrAlias)}/duplicate`, params),
|
|
239
|
+
remove: (idOrAlias) => this.request("DELETE", `/templates/${enc(idOrAlias)}`),
|
|
240
|
+
getContent: (idOrAlias) => this.request("GET", `/templates/${enc(idOrAlias)}/content`),
|
|
241
|
+
/** Edit it block by block. Anyone with it open in the editor sees the change live. */
|
|
242
|
+
editContent: (idOrAlias, params) => this.request("POST", `/templates/${enc(idOrAlias)}/content`, params),
|
|
199
243
|
};
|
|
200
244
|
this.suppressions = {
|
|
201
245
|
/** Stop sending to one or more addresses. */
|
|
@@ -216,6 +260,10 @@ class Delivrie {
|
|
|
216
260
|
publish: (id) => this.request("POST", `/automations/${enc(id)}/publish`),
|
|
217
261
|
pause: (id) => this.request("POST", `/automations/${enc(id)}/pause`),
|
|
218
262
|
resume: (id) => this.request("POST", `/automations/${enc(id)}/resume`),
|
|
263
|
+
/** Copy it, with its trigger and steps, as a new draft. */
|
|
264
|
+
duplicate: (id, params = {}) => this.request("POST", `/automations/${enc(id)}/duplicate`, params),
|
|
265
|
+
update: (id, params) => this.request("PATCH", `/automations/${enc(id)}`, params),
|
|
266
|
+
remove: (id) => this.request("DELETE", `/automations/${enc(id)}`),
|
|
219
267
|
};
|
|
220
268
|
this.inbox = {
|
|
221
269
|
threads: {
|
|
@@ -223,9 +271,39 @@ class Delivrie {
|
|
|
223
271
|
get: (id) => this.request("GET", `/inbox/threads/${enc(id)}`),
|
|
224
272
|
update: (id, params) => this.request("PATCH", `/inbox/threads/${enc(id)}`, params),
|
|
225
273
|
reply: (id, params) => this.request("POST", `/inbox/threads/${enc(id)}/reply`, params),
|
|
274
|
+
/** Run the inbox's agent on this thread now. */
|
|
275
|
+
runAgent: (id) => this.request("POST", `/inbox/threads/${enc(id)}/agent`),
|
|
276
|
+
notes: (id) => this.request("GET", `/inbox/threads/${enc(id)}/notes`),
|
|
277
|
+
addNote: (id, body) => this.request("POST", `/inbox/threads/${enc(id)}/notes`, { body }),
|
|
278
|
+
},
|
|
279
|
+
notes: { remove: (id) => this.request("DELETE", `/inbox/notes/${enc(id)}`) },
|
|
280
|
+
drafts: {
|
|
281
|
+
list: (params = {}) => this.request("GET", "/inbox/drafts", undefined, { query: { ...params } }),
|
|
282
|
+
create: (params) => this.request("POST", "/inbox/drafts", params),
|
|
283
|
+
update: (id, params) => this.request("PATCH", `/inbox/drafts/${enc(id)}`, params),
|
|
284
|
+
send: (id) => this.request("POST", `/inbox/drafts/${enc(id)}/send`),
|
|
285
|
+
remove: (id) => this.request("DELETE", `/inbox/drafts/${enc(id)}`),
|
|
226
286
|
},
|
|
227
287
|
labels: { list: () => this.request("GET", "/inbox/labels") },
|
|
228
288
|
};
|
|
289
|
+
/** Inboxes (addresses on receiving domains) and their agent settings. */
|
|
290
|
+
this.inboxes = {
|
|
291
|
+
list: () => this.request("GET", "/inboxes"),
|
|
292
|
+
create: (params) => this.request("POST", "/inboxes", params),
|
|
293
|
+
get: (idOrAddress) => this.request("GET", `/inboxes/${enc(idOrAddress)}`),
|
|
294
|
+
update: (idOrAddress, params) => this.request("PATCH", `/inboxes/${enc(idOrAddress)}`, params),
|
|
295
|
+
remove: (idOrAddress) => this.request("DELETE", `/inboxes/${enc(idOrAddress)}`),
|
|
296
|
+
agentRuns: (idOrAddress, params = {}) => this.request("GET", `/inboxes/${enc(idOrAddress)}/agent-runs`, undefined, { query: { ...params } }),
|
|
297
|
+
};
|
|
298
|
+
/** AI writing in the team's brand voice. */
|
|
299
|
+
this.ai = {
|
|
300
|
+
/** Write an email from a url and/or brief. With target, writes it into a template or draft broadcast. */
|
|
301
|
+
draft: (params) => this.request("POST", "/ai/draft", params),
|
|
302
|
+
/** Rewrite blocks with an instruction. */
|
|
303
|
+
rewrite: (params) => this.request("POST", "/ai/rewrite", params),
|
|
304
|
+
/** Subject line ideas for an email's text. */
|
|
305
|
+
subjects: (params) => this.request("POST", "/ai/subjects", params),
|
|
306
|
+
};
|
|
229
307
|
this.metrics = {
|
|
230
308
|
get: (params = {}) => this.request("GET", "/metrics", undefined, { query: params }),
|
|
231
309
|
};
|
package/dist/cjs/client.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ApiKey, Automation, Broadcast, Contact, CreateApiKeyRequest, CreateApiKeyResponse, CreateBroadcastRequest, CreateContactRequest, CreateDomainRequest, CreateEmailResponse, CreateTemplateRequest, CreateWebhookRequest, CreateWebhookResponse, Domain, Email, EmailSummary, ForwardEmailRequest, InboxThread, List, ListContactsParams, ListEmailsParams, Log, LogSummary, Metrics, Pagination, ReplyToThreadRequest, RequestOptions, Result, Segment, SendEmailRequest, SendEventRequest, Suppression, Template, Topic, UpdateContactRequest, UpdateDomainRequest, Usage, Webhook, WebhookDelivery, Deleted,
|
|
1
|
+
import type { ApiKey, Automation, Broadcast, Contact, CreateApiKeyRequest, CreateApiKeyResponse, CreateBroadcastRequest, CreateContactRequest, CreateDomainRequest, CreateEmailResponse, CreateTemplateRequest, CreateWebhookRequest, CreateWebhookResponse, Domain, Email, EmailSummary, ForwardEmailRequest, InboxThread, List, ListContactsParams, ListEmailsParams, Log, LogSummary, Metrics, Pagination, ReplyToThreadRequest, RequestOptions, Result, Segment, SendEmailRequest, SendEventRequest, Suppression, Template, Topic, UpdateContactRequest, UpdateDomainRequest, Usage, Webhook, WebhookDelivery, Deleted, BroadcastRecipients, BroadcastLink, AttachmentDownload, EmailShare, ContactImport, CreateContactImportRequest, EmailContent, EmailBlock, EditContentRequest, AiDraftRequest, AiDraft } from "./types.cjs";
|
|
2
2
|
import { type VerifyWebhookOptions } from "./webhooks.cjs";
|
|
3
|
-
export declare const VERSION = "0.
|
|
3
|
+
export declare const VERSION = "0.3.0";
|
|
4
4
|
export interface DelivrieOptions {
|
|
5
5
|
/** Defaults to `https://delivrie.io/api`. */
|
|
6
6
|
baseUrl?: string;
|
|
@@ -21,7 +21,7 @@ type Query = Record<string, string | number | boolean | undefined | null>;
|
|
|
21
21
|
* ```ts
|
|
22
22
|
* import { Delivrie } from "delivrie";
|
|
23
23
|
* const delivrie = new Delivrie(process.env.DELIVRIE_API_KEY);
|
|
24
|
-
* const { data, error } = await delivrie.emails.send({ from: "
|
|
24
|
+
* const { data, error } = await delivrie.emails.send({ from: "Acme <hi@acme.com>", to: "ada@example.com", subject: "Hi", html: "<p>Hello</p>" });
|
|
25
25
|
* ```
|
|
26
26
|
*/
|
|
27
27
|
export declare class Delivrie {
|
|
@@ -60,6 +60,16 @@ export declare class Delivrie {
|
|
|
60
60
|
id: string;
|
|
61
61
|
}>>;
|
|
62
62
|
forward: (id: string, params: ForwardEmailRequest) => Promise<Result<CreateEmailResponse>>;
|
|
63
|
+
/** A sent email's files with download links that work for an hour. */
|
|
64
|
+
attachments: (id: string) => Promise<Result<List<AttachmentDownload>>>;
|
|
65
|
+
/** A received email's files with download links that work for an hour. */
|
|
66
|
+
receivedAttachments: (id: string) => Promise<Result<List<AttachmentDownload>>>;
|
|
67
|
+
/** A public link to the email and its delivery timeline. */
|
|
68
|
+
share: (id: string, params?: {
|
|
69
|
+
expires_in_hours?: number;
|
|
70
|
+
}) => Promise<Result<EmailShare>>;
|
|
71
|
+
/** Revoke every share link for the email. */
|
|
72
|
+
unshare: (id: string) => Promise<Result<Record<string, unknown>>>;
|
|
63
73
|
};
|
|
64
74
|
readonly domains: {
|
|
65
75
|
create: (params: CreateDomainRequest) => Promise<Result<Domain>>;
|
|
@@ -73,11 +83,22 @@ export declare class Delivrie {
|
|
|
73
83
|
readonly apiKeys: {
|
|
74
84
|
create: (params: CreateApiKeyRequest) => Promise<Result<CreateApiKeyResponse>>;
|
|
75
85
|
list: () => Promise<Result<List<ApiKey>>>;
|
|
86
|
+
/** Rename a key. */
|
|
87
|
+
update: (id: string, params: {
|
|
88
|
+
name: string;
|
|
89
|
+
}) => Promise<Result<ApiKey>>;
|
|
76
90
|
remove: (id: string) => Promise<Result<Deleted>>;
|
|
77
91
|
};
|
|
78
92
|
readonly webhooks: {
|
|
79
93
|
create: (params: CreateWebhookRequest) => Promise<Result<CreateWebhookResponse>>;
|
|
80
94
|
list: () => Promise<Result<List<Webhook>>>;
|
|
95
|
+
/** Change the endpoint, events or status (enabled, disabled). */
|
|
96
|
+
update: (id: string, params: {
|
|
97
|
+
endpoint?: string;
|
|
98
|
+
events?: string[];
|
|
99
|
+
status?: "enabled" | "disabled";
|
|
100
|
+
}) => Promise<Result<Webhook>>;
|
|
101
|
+
remove: (id: string) => Promise<Result<Deleted>>;
|
|
81
102
|
/** Recent delivery attempts for a webhook. */
|
|
82
103
|
deliveries: (id: string) => Promise<Result<List<WebhookDelivery>>>;
|
|
83
104
|
/** Send a test event to the endpoint. */
|
|
@@ -100,6 +121,14 @@ export declare class Delivrie {
|
|
|
100
121
|
}>>;
|
|
101
122
|
list: (params?: ListContactsParams) => Promise<Result<List<Contact>>>;
|
|
102
123
|
remove: (idOrEmail: string) => Promise<Result<Deleted>>;
|
|
124
|
+
imports: {
|
|
125
|
+
/** Import up to 50,000 contacts from CSV text or a list. Runs in the background. */
|
|
126
|
+
create: (params: CreateContactImportRequest) => Promise<Result<ContactImport>>;
|
|
127
|
+
get: (id: string) => Promise<Result<ContactImport>>;
|
|
128
|
+
list: (params?: {
|
|
129
|
+
limit?: number;
|
|
130
|
+
}) => Promise<Result<List<ContactImport>>>;
|
|
131
|
+
};
|
|
103
132
|
};
|
|
104
133
|
readonly segments: {
|
|
105
134
|
create: (params: {
|
|
@@ -109,7 +138,24 @@ export declare class Delivrie {
|
|
|
109
138
|
id: string;
|
|
110
139
|
}>>;
|
|
111
140
|
list: () => Promise<Result<List<Segment>>>;
|
|
141
|
+
get: (id: string) => Promise<Result<Segment & {
|
|
142
|
+
contacts: number;
|
|
143
|
+
}>>;
|
|
144
|
+
/** Rename a segment. */
|
|
145
|
+
update: (id: string, params: {
|
|
146
|
+
name: string;
|
|
147
|
+
}) => Promise<Result<Segment>>;
|
|
112
148
|
remove: (id: string) => Promise<Result<Deleted>>;
|
|
149
|
+
/** The contacts in a segment. */
|
|
150
|
+
contacts: (id: string, params?: Pagination) => Promise<Result<List<Contact> & {
|
|
151
|
+
total: number;
|
|
152
|
+
}>>;
|
|
153
|
+
/** Take contacts (emails or ids) out of a segment. The contacts aren't deleted. */
|
|
154
|
+
removeContacts: (id: string, contacts: string[]) => Promise<Result<{
|
|
155
|
+
object: "segment";
|
|
156
|
+
id: string;
|
|
157
|
+
removed: number;
|
|
158
|
+
}>>;
|
|
113
159
|
/** Add contacts by email (they're created if needed). */
|
|
114
160
|
addContacts: (id: string, contacts: Array<string | CreateContactRequest>) => Promise<Result<Record<string, unknown>>>;
|
|
115
161
|
};
|
|
@@ -132,7 +178,32 @@ export declare class Delivrie {
|
|
|
132
178
|
}) => Promise<Result<Broadcast>>;
|
|
133
179
|
cancel: (id: string) => Promise<Result<Broadcast>>;
|
|
134
180
|
/** How many contacts the broadcast will reach. */
|
|
135
|
-
|
|
181
|
+
/** Who it went to (with delivered/opened/clicked/bounced flags), or before sending, who it will reach. */
|
|
182
|
+
recipients: (id: string, params?: Pagination & {
|
|
183
|
+
status?: string;
|
|
184
|
+
}) => Promise<Result<BroadcastRecipients>>;
|
|
185
|
+
/** Clicked links with total and unique clicks. */
|
|
186
|
+
links: (id: string) => Promise<Result<List<BroadcastLink> & {
|
|
187
|
+
total_clicks: number;
|
|
188
|
+
}>>;
|
|
189
|
+
/** Edit a draft. */
|
|
190
|
+
update: (id: string, params: Partial<CreateBroadcastRequest>) => Promise<Result<{
|
|
191
|
+
object: "broadcast";
|
|
192
|
+
id: string;
|
|
193
|
+
}>>;
|
|
194
|
+
/** Copy it as a new draft. */
|
|
195
|
+
duplicate: (id: string, params?: {
|
|
196
|
+
name?: string;
|
|
197
|
+
}) => Promise<Result<{
|
|
198
|
+
object: "broadcast";
|
|
199
|
+
id: string;
|
|
200
|
+
name: string;
|
|
201
|
+
status: string;
|
|
202
|
+
}>>;
|
|
203
|
+
/** A draft's subject and blocks with ids. */
|
|
204
|
+
getContent: (id: string) => Promise<Result<EmailContent>>;
|
|
205
|
+
/** Edit a draft block by block. Anyone with it open in the editor sees the change live. */
|
|
206
|
+
editContent: (id: string, params: EditContentRequest) => Promise<Result<EmailContent>>;
|
|
136
207
|
remove: (id: string) => Promise<Result<Deleted>>;
|
|
137
208
|
};
|
|
138
209
|
readonly templates: {
|
|
@@ -145,6 +216,23 @@ export declare class Delivrie {
|
|
|
145
216
|
list: () => Promise<Result<List<Template>>>;
|
|
146
217
|
/** Publish the current draft so sends use it. */
|
|
147
218
|
publish: (id: string) => Promise<Result<Template>>;
|
|
219
|
+
/** Change it. Saved as a draft until published. */
|
|
220
|
+
update: (idOrAlias: string, params: Partial<CreateTemplateRequest> & Record<string, unknown>) => Promise<Result<{
|
|
221
|
+
object: "template";
|
|
222
|
+
id: string;
|
|
223
|
+
}>>;
|
|
224
|
+
duplicate: (idOrAlias: string, params?: {
|
|
225
|
+
name?: string;
|
|
226
|
+
alias?: string;
|
|
227
|
+
}) => Promise<Result<{
|
|
228
|
+
object: "template";
|
|
229
|
+
id: string;
|
|
230
|
+
name: string;
|
|
231
|
+
}>>;
|
|
232
|
+
remove: (idOrAlias: string) => Promise<Result<Deleted>>;
|
|
233
|
+
getContent: (idOrAlias: string) => Promise<Result<EmailContent>>;
|
|
234
|
+
/** Edit it block by block. Anyone with it open in the editor sees the change live. */
|
|
235
|
+
editContent: (idOrAlias: string, params: EditContentRequest) => Promise<Result<EmailContent>>;
|
|
148
236
|
};
|
|
149
237
|
readonly suppressions: {
|
|
150
238
|
/** Stop sending to one or more addresses. */
|
|
@@ -165,6 +253,15 @@ export declare class Delivrie {
|
|
|
165
253
|
publish: (id: string) => Promise<Result<Automation>>;
|
|
166
254
|
pause: (id: string) => Promise<Result<Automation>>;
|
|
167
255
|
resume: (id: string) => Promise<Result<Automation>>;
|
|
256
|
+
/** Copy it, with its trigger and steps, as a new draft. */
|
|
257
|
+
duplicate: (id: string, params?: {
|
|
258
|
+
name?: string;
|
|
259
|
+
}) => Promise<Result<Automation>>;
|
|
260
|
+
update: (id: string, params: {
|
|
261
|
+
name?: string;
|
|
262
|
+
reentry?: "once" | "always";
|
|
263
|
+
}) => Promise<Result<Automation>>;
|
|
264
|
+
remove: (id: string) => Promise<Result<Deleted>>;
|
|
168
265
|
};
|
|
169
266
|
readonly inbox: {
|
|
170
267
|
threads: {
|
|
@@ -172,11 +269,67 @@ export declare class Delivrie {
|
|
|
172
269
|
get: (id: string) => Promise<Result<InboxThread>>;
|
|
173
270
|
update: (id: string, params: Record<string, unknown>) => Promise<Result<InboxThread>>;
|
|
174
271
|
reply: (id: string, params: ReplyToThreadRequest) => Promise<Result<CreateEmailResponse>>;
|
|
272
|
+
/** Run the inbox's agent on this thread now. */
|
|
273
|
+
runAgent: (id: string) => Promise<Result<Record<string, unknown>>>;
|
|
274
|
+
notes: (id: string) => Promise<Result<List<Record<string, unknown>>>>;
|
|
275
|
+
addNote: (id: string, body: string) => Promise<Result<Record<string, unknown>>>;
|
|
276
|
+
};
|
|
277
|
+
notes: {
|
|
278
|
+
remove: (id: string) => Promise<Result<Deleted>>;
|
|
279
|
+
};
|
|
280
|
+
drafts: {
|
|
281
|
+
list: (params?: {
|
|
282
|
+
thread_id?: string;
|
|
283
|
+
inbox?: string;
|
|
284
|
+
source?: "user" | "agent";
|
|
285
|
+
}) => Promise<Result<List<Record<string, unknown>>>>;
|
|
286
|
+
create: (params: Record<string, unknown>) => Promise<Result<Record<string, unknown>>>;
|
|
287
|
+
update: (id: string, params: Record<string, unknown>) => Promise<Result<Record<string, unknown>>>;
|
|
288
|
+
send: (id: string) => Promise<Result<CreateEmailResponse>>;
|
|
289
|
+
remove: (id: string) => Promise<Result<Deleted>>;
|
|
175
290
|
};
|
|
176
291
|
labels: {
|
|
177
292
|
list: () => Promise<Result<List<Record<string, unknown>>>>;
|
|
178
293
|
};
|
|
179
294
|
};
|
|
295
|
+
/** Inboxes (addresses on receiving domains) and their agent settings. */
|
|
296
|
+
readonly inboxes: {
|
|
297
|
+
list: () => Promise<Result<List<Record<string, unknown>>>>;
|
|
298
|
+
create: (params: {
|
|
299
|
+
address: string;
|
|
300
|
+
name?: string;
|
|
301
|
+
description?: string;
|
|
302
|
+
}) => Promise<Result<Record<string, unknown>>>;
|
|
303
|
+
get: (idOrAddress: string) => Promise<Result<Record<string, unknown>>>;
|
|
304
|
+
update: (idOrAddress: string, params: Record<string, unknown>) => Promise<Result<Record<string, unknown>>>;
|
|
305
|
+
remove: (idOrAddress: string) => Promise<Result<Deleted>>;
|
|
306
|
+
agentRuns: (idOrAddress: string, params?: {
|
|
307
|
+
limit?: number;
|
|
308
|
+
}) => Promise<Result<List<Record<string, unknown>>>>;
|
|
309
|
+
};
|
|
310
|
+
/** AI writing in the team's brand voice. */
|
|
311
|
+
readonly ai: {
|
|
312
|
+
/** Write an email from a url and/or brief. With target, writes it into a template or draft broadcast. */
|
|
313
|
+
draft: (params: AiDraftRequest) => Promise<Result<AiDraft>>;
|
|
314
|
+
/** Rewrite blocks with an instruction. */
|
|
315
|
+
rewrite: (params: {
|
|
316
|
+
blocks: EmailBlock[];
|
|
317
|
+
instruction: string;
|
|
318
|
+
kind?: "broadcast" | "template";
|
|
319
|
+
context?: string;
|
|
320
|
+
}) => Promise<Result<{
|
|
321
|
+
object: "ai_rewrite";
|
|
322
|
+
blocks: EmailBlock[];
|
|
323
|
+
}>>;
|
|
324
|
+
/** Subject line ideas for an email's text. */
|
|
325
|
+
subjects: (params: {
|
|
326
|
+
text: string;
|
|
327
|
+
current?: string;
|
|
328
|
+
}) => Promise<Result<List<{
|
|
329
|
+
subject: string;
|
|
330
|
+
preview_text: string;
|
|
331
|
+
}>>>;
|
|
332
|
+
};
|
|
180
333
|
readonly metrics: {
|
|
181
334
|
get: (params?: {
|
|
182
335
|
days?: number;
|
package/dist/cjs/types.d.cts
CHANGED
|
@@ -36,9 +36,12 @@ export interface Tag {
|
|
|
36
36
|
value: string;
|
|
37
37
|
}
|
|
38
38
|
export interface Attachment {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
/** Defaults to the file name in `path`. */
|
|
40
|
+
filename?: string;
|
|
41
|
+
/** File contents as a base64 string (or a Buffer/Uint8Array, which the SDK encodes for you). Up to 40 MB per email. Provide `content` or `path`. */
|
|
42
|
+
content?: string | Uint8Array;
|
|
43
|
+
/** A public https:// URL that Delivrie downloads when the email is accepted. */
|
|
44
|
+
path?: string;
|
|
42
45
|
content_type?: string;
|
|
43
46
|
/** Set to reference the file inline from HTML with `cid:<content_id>`. */
|
|
44
47
|
content_id?: string;
|
|
@@ -153,6 +156,8 @@ export interface Domain {
|
|
|
153
156
|
receiving_subdomain: string | null;
|
|
154
157
|
receiving_mode: string | null;
|
|
155
158
|
receiving_addresses: string[] | null;
|
|
159
|
+
/** Addresses that get a copy of every email this domain receives. Empty when forwarding is off. */
|
|
160
|
+
receiving_forward_to: string[];
|
|
156
161
|
receiving_verified_at: string | null;
|
|
157
162
|
}
|
|
158
163
|
export interface CreateDomainRequest {
|
|
@@ -385,6 +390,179 @@ export interface ReplyToThreadRequest {
|
|
|
385
390
|
text?: string;
|
|
386
391
|
html?: string;
|
|
387
392
|
}
|
|
393
|
+
/** GET /broadcasts/:id/recipients. `total`, `topic_opt_out` and `recipients` are counts; `data` lists people. */
|
|
394
|
+
export interface BroadcastRecipients {
|
|
395
|
+
object: "list";
|
|
396
|
+
data: Array<{
|
|
397
|
+
object: "broadcast_recipient";
|
|
398
|
+
email: string;
|
|
399
|
+
contact_id: string | null;
|
|
400
|
+
email_id?: string;
|
|
401
|
+
status: string;
|
|
402
|
+
sent_at?: string | null;
|
|
403
|
+
delivered?: boolean;
|
|
404
|
+
opened?: boolean;
|
|
405
|
+
clicked?: boolean;
|
|
406
|
+
bounced?: boolean;
|
|
407
|
+
complained?: boolean;
|
|
408
|
+
unsubscribed?: boolean;
|
|
409
|
+
}>;
|
|
410
|
+
has_more: boolean;
|
|
411
|
+
/** Contacts in the segment (before sending) or emails sent. */
|
|
412
|
+
total: number;
|
|
413
|
+
topic_opt_out: number;
|
|
414
|
+
/** How many it reaches after unsubscribes, topic opt-outs and suppressions. */
|
|
415
|
+
recipients: number;
|
|
416
|
+
}
|
|
417
|
+
export interface BroadcastLink {
|
|
418
|
+
object: "broadcast_link";
|
|
419
|
+
link: string;
|
|
420
|
+
clicks: number;
|
|
421
|
+
unique_clicks: number;
|
|
422
|
+
}
|
|
423
|
+
/** A sent or received email's file. `download_url` works until `expires_at` (an hour). */
|
|
424
|
+
export interface AttachmentDownload {
|
|
425
|
+
object: "attachment";
|
|
426
|
+
id: string;
|
|
427
|
+
filename: string;
|
|
428
|
+
content_type: string;
|
|
429
|
+
size: number | null;
|
|
430
|
+
content_id?: string;
|
|
431
|
+
download_url: string | null;
|
|
432
|
+
expires_at: string | null;
|
|
433
|
+
/** Why there's no download_url: the file is older than storage, or past the 30-day retention. */
|
|
434
|
+
note?: string;
|
|
435
|
+
}
|
|
436
|
+
export interface EmailShare {
|
|
437
|
+
object: "email_share";
|
|
438
|
+
email_id: string;
|
|
439
|
+
url: string;
|
|
440
|
+
token: string;
|
|
441
|
+
expires_at: string;
|
|
442
|
+
}
|
|
443
|
+
export interface CreateContactImportRequest {
|
|
444
|
+
/** CSV text with a header row and an email column. Provide csv or contacts. */
|
|
445
|
+
csv?: string;
|
|
446
|
+
/** Contacts as objects, or plain email addresses. */
|
|
447
|
+
contacts?: Array<string | CreateContactRequest>;
|
|
448
|
+
/** Map CSV headers to fields: { "E-mail": "email", "Company": "property:company", "Notes": null }. */
|
|
449
|
+
columns?: Record<string, string | null>;
|
|
450
|
+
/** Add everyone to these segments. */
|
|
451
|
+
segment_ids?: string[];
|
|
452
|
+
/** Update contacts that already exist. Default true. */
|
|
453
|
+
update_existing?: boolean;
|
|
454
|
+
}
|
|
455
|
+
export interface ContactImport {
|
|
456
|
+
object: "contact_import";
|
|
457
|
+
id: string;
|
|
458
|
+
status: "queued" | "processing" | "completed" | "failed";
|
|
459
|
+
segment_ids: string[];
|
|
460
|
+
update_existing: boolean;
|
|
461
|
+
total: number;
|
|
462
|
+
processed: number;
|
|
463
|
+
created: number;
|
|
464
|
+
updated: number;
|
|
465
|
+
skipped: number;
|
|
466
|
+
/** The first 100 problems. */
|
|
467
|
+
errors: Array<{
|
|
468
|
+
row: number | null;
|
|
469
|
+
email: string | null;
|
|
470
|
+
message: string;
|
|
471
|
+
}>;
|
|
472
|
+
error: string | null;
|
|
473
|
+
created_at: string;
|
|
474
|
+
completed_at: string | null;
|
|
475
|
+
}
|
|
476
|
+
/** An editor block: title, heading, eyebrow, text, bulleted, numbered, callout, button, image, rows, divider, spacer, otp, footer. */
|
|
477
|
+
export interface EmailBlock {
|
|
478
|
+
id?: string;
|
|
479
|
+
type: string;
|
|
480
|
+
[field: string]: unknown;
|
|
481
|
+
}
|
|
482
|
+
export type EditOperation = {
|
|
483
|
+
op: "replace";
|
|
484
|
+
id: string;
|
|
485
|
+
block: EmailBlock;
|
|
486
|
+
} | {
|
|
487
|
+
op: "update";
|
|
488
|
+
id: string;
|
|
489
|
+
set: Record<string, unknown>;
|
|
490
|
+
} | {
|
|
491
|
+
op: "insert";
|
|
492
|
+
after?: string | null;
|
|
493
|
+
before?: string;
|
|
494
|
+
block?: EmailBlock;
|
|
495
|
+
blocks?: EmailBlock[];
|
|
496
|
+
} | {
|
|
497
|
+
op: "delete";
|
|
498
|
+
id: string;
|
|
499
|
+
} | {
|
|
500
|
+
op: "move";
|
|
501
|
+
id: string;
|
|
502
|
+
after?: string | null;
|
|
503
|
+
before?: string;
|
|
504
|
+
};
|
|
505
|
+
export interface EditContentRequest {
|
|
506
|
+
ops?: EditOperation[];
|
|
507
|
+
/** Replace every block. */
|
|
508
|
+
blocks?: EmailBlock[];
|
|
509
|
+
subject?: string;
|
|
510
|
+
/** Broadcasts only. */
|
|
511
|
+
preview_text?: string;
|
|
512
|
+
/** One line on what changed, shown in the editor. */
|
|
513
|
+
summary?: string;
|
|
514
|
+
}
|
|
515
|
+
export interface EmailContent {
|
|
516
|
+
object: "template_content" | "broadcast_content";
|
|
517
|
+
id: string;
|
|
518
|
+
name: string;
|
|
519
|
+
subject: string | null;
|
|
520
|
+
preview_text?: string | null;
|
|
521
|
+
content: {
|
|
522
|
+
page: Record<string, unknown> | null;
|
|
523
|
+
blocks: EmailBlock[];
|
|
524
|
+
};
|
|
525
|
+
agent_edit: {
|
|
526
|
+
by: string;
|
|
527
|
+
at: string;
|
|
528
|
+
rev: number;
|
|
529
|
+
summary?: string;
|
|
530
|
+
} | null;
|
|
531
|
+
editor_url: string;
|
|
532
|
+
}
|
|
533
|
+
export interface AiDraftRequest {
|
|
534
|
+
/** A page to write from: a blog post, changelog, product or event page. */
|
|
535
|
+
url?: string;
|
|
536
|
+
/** What the email is for. Provide url, brief or both. */
|
|
537
|
+
brief?: string;
|
|
538
|
+
kind?: "broadcast" | "template";
|
|
539
|
+
length?: "short" | "medium" | "long";
|
|
540
|
+
tone?: string;
|
|
541
|
+
variables?: string[];
|
|
542
|
+
/** Write it straight into this template or draft broadcast. */
|
|
543
|
+
target?: {
|
|
544
|
+
type: "template" | "broadcast";
|
|
545
|
+
id: string;
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
export interface AiDraft {
|
|
549
|
+
object: "ai_draft";
|
|
550
|
+
subject: string;
|
|
551
|
+
preview_text: string;
|
|
552
|
+
content: {
|
|
553
|
+
blocks: EmailBlock[];
|
|
554
|
+
};
|
|
555
|
+
notes: string | null;
|
|
556
|
+
source: {
|
|
557
|
+
url: string;
|
|
558
|
+
title: string;
|
|
559
|
+
} | null;
|
|
560
|
+
target?: {
|
|
561
|
+
type: "template" | "broadcast";
|
|
562
|
+
id: string;
|
|
563
|
+
};
|
|
564
|
+
}
|
|
565
|
+
/** @deprecated Use BroadcastRecipients. */
|
|
388
566
|
export interface BroadcastRecipientCount {
|
|
389
567
|
/** Contacts in the segment. */
|
|
390
568
|
total: number;
|
package/dist/esm/client.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ApiKey, Automation, Broadcast, Contact, CreateApiKeyRequest, CreateApiKeyResponse, CreateBroadcastRequest, CreateContactRequest, CreateDomainRequest, CreateEmailResponse, CreateTemplateRequest, CreateWebhookRequest, CreateWebhookResponse, Domain, Email, EmailSummary, ForwardEmailRequest, InboxThread, List, ListContactsParams, ListEmailsParams, Log, LogSummary, Metrics, Pagination, ReplyToThreadRequest, RequestOptions, Result, Segment, SendEmailRequest, SendEventRequest, Suppression, Template, Topic, UpdateContactRequest, UpdateDomainRequest, Usage, Webhook, WebhookDelivery, Deleted,
|
|
1
|
+
import type { ApiKey, Automation, Broadcast, Contact, CreateApiKeyRequest, CreateApiKeyResponse, CreateBroadcastRequest, CreateContactRequest, CreateDomainRequest, CreateEmailResponse, CreateTemplateRequest, CreateWebhookRequest, CreateWebhookResponse, Domain, Email, EmailSummary, ForwardEmailRequest, InboxThread, List, ListContactsParams, ListEmailsParams, Log, LogSummary, Metrics, Pagination, ReplyToThreadRequest, RequestOptions, Result, Segment, SendEmailRequest, SendEventRequest, Suppression, Template, Topic, UpdateContactRequest, UpdateDomainRequest, Usage, Webhook, WebhookDelivery, Deleted, BroadcastRecipients, BroadcastLink, AttachmentDownload, EmailShare, ContactImport, CreateContactImportRequest, EmailContent, EmailBlock, EditContentRequest, AiDraftRequest, AiDraft } from "./types.js";
|
|
2
2
|
import { type VerifyWebhookOptions } from "./webhooks.js";
|
|
3
|
-
export declare const VERSION = "0.
|
|
3
|
+
export declare const VERSION = "0.3.0";
|
|
4
4
|
export interface DelivrieOptions {
|
|
5
5
|
/** Defaults to `https://delivrie.io/api`. */
|
|
6
6
|
baseUrl?: string;
|
|
@@ -21,7 +21,7 @@ type Query = Record<string, string | number | boolean | undefined | null>;
|
|
|
21
21
|
* ```ts
|
|
22
22
|
* import { Delivrie } from "delivrie";
|
|
23
23
|
* const delivrie = new Delivrie(process.env.DELIVRIE_API_KEY);
|
|
24
|
-
* const { data, error } = await delivrie.emails.send({ from: "
|
|
24
|
+
* const { data, error } = await delivrie.emails.send({ from: "Acme <hi@acme.com>", to: "ada@example.com", subject: "Hi", html: "<p>Hello</p>" });
|
|
25
25
|
* ```
|
|
26
26
|
*/
|
|
27
27
|
export declare class Delivrie {
|
|
@@ -60,6 +60,16 @@ export declare class Delivrie {
|
|
|
60
60
|
id: string;
|
|
61
61
|
}>>;
|
|
62
62
|
forward: (id: string, params: ForwardEmailRequest) => Promise<Result<CreateEmailResponse>>;
|
|
63
|
+
/** A sent email's files with download links that work for an hour. */
|
|
64
|
+
attachments: (id: string) => Promise<Result<List<AttachmentDownload>>>;
|
|
65
|
+
/** A received email's files with download links that work for an hour. */
|
|
66
|
+
receivedAttachments: (id: string) => Promise<Result<List<AttachmentDownload>>>;
|
|
67
|
+
/** A public link to the email and its delivery timeline. */
|
|
68
|
+
share: (id: string, params?: {
|
|
69
|
+
expires_in_hours?: number;
|
|
70
|
+
}) => Promise<Result<EmailShare>>;
|
|
71
|
+
/** Revoke every share link for the email. */
|
|
72
|
+
unshare: (id: string) => Promise<Result<Record<string, unknown>>>;
|
|
63
73
|
};
|
|
64
74
|
readonly domains: {
|
|
65
75
|
create: (params: CreateDomainRequest) => Promise<Result<Domain>>;
|
|
@@ -73,11 +83,22 @@ export declare class Delivrie {
|
|
|
73
83
|
readonly apiKeys: {
|
|
74
84
|
create: (params: CreateApiKeyRequest) => Promise<Result<CreateApiKeyResponse>>;
|
|
75
85
|
list: () => Promise<Result<List<ApiKey>>>;
|
|
86
|
+
/** Rename a key. */
|
|
87
|
+
update: (id: string, params: {
|
|
88
|
+
name: string;
|
|
89
|
+
}) => Promise<Result<ApiKey>>;
|
|
76
90
|
remove: (id: string) => Promise<Result<Deleted>>;
|
|
77
91
|
};
|
|
78
92
|
readonly webhooks: {
|
|
79
93
|
create: (params: CreateWebhookRequest) => Promise<Result<CreateWebhookResponse>>;
|
|
80
94
|
list: () => Promise<Result<List<Webhook>>>;
|
|
95
|
+
/** Change the endpoint, events or status (enabled, disabled). */
|
|
96
|
+
update: (id: string, params: {
|
|
97
|
+
endpoint?: string;
|
|
98
|
+
events?: string[];
|
|
99
|
+
status?: "enabled" | "disabled";
|
|
100
|
+
}) => Promise<Result<Webhook>>;
|
|
101
|
+
remove: (id: string) => Promise<Result<Deleted>>;
|
|
81
102
|
/** Recent delivery attempts for a webhook. */
|
|
82
103
|
deliveries: (id: string) => Promise<Result<List<WebhookDelivery>>>;
|
|
83
104
|
/** Send a test event to the endpoint. */
|
|
@@ -100,6 +121,14 @@ export declare class Delivrie {
|
|
|
100
121
|
}>>;
|
|
101
122
|
list: (params?: ListContactsParams) => Promise<Result<List<Contact>>>;
|
|
102
123
|
remove: (idOrEmail: string) => Promise<Result<Deleted>>;
|
|
124
|
+
imports: {
|
|
125
|
+
/** Import up to 50,000 contacts from CSV text or a list. Runs in the background. */
|
|
126
|
+
create: (params: CreateContactImportRequest) => Promise<Result<ContactImport>>;
|
|
127
|
+
get: (id: string) => Promise<Result<ContactImport>>;
|
|
128
|
+
list: (params?: {
|
|
129
|
+
limit?: number;
|
|
130
|
+
}) => Promise<Result<List<ContactImport>>>;
|
|
131
|
+
};
|
|
103
132
|
};
|
|
104
133
|
readonly segments: {
|
|
105
134
|
create: (params: {
|
|
@@ -109,7 +138,24 @@ export declare class Delivrie {
|
|
|
109
138
|
id: string;
|
|
110
139
|
}>>;
|
|
111
140
|
list: () => Promise<Result<List<Segment>>>;
|
|
141
|
+
get: (id: string) => Promise<Result<Segment & {
|
|
142
|
+
contacts: number;
|
|
143
|
+
}>>;
|
|
144
|
+
/** Rename a segment. */
|
|
145
|
+
update: (id: string, params: {
|
|
146
|
+
name: string;
|
|
147
|
+
}) => Promise<Result<Segment>>;
|
|
112
148
|
remove: (id: string) => Promise<Result<Deleted>>;
|
|
149
|
+
/** The contacts in a segment. */
|
|
150
|
+
contacts: (id: string, params?: Pagination) => Promise<Result<List<Contact> & {
|
|
151
|
+
total: number;
|
|
152
|
+
}>>;
|
|
153
|
+
/** Take contacts (emails or ids) out of a segment. The contacts aren't deleted. */
|
|
154
|
+
removeContacts: (id: string, contacts: string[]) => Promise<Result<{
|
|
155
|
+
object: "segment";
|
|
156
|
+
id: string;
|
|
157
|
+
removed: number;
|
|
158
|
+
}>>;
|
|
113
159
|
/** Add contacts by email (they're created if needed). */
|
|
114
160
|
addContacts: (id: string, contacts: Array<string | CreateContactRequest>) => Promise<Result<Record<string, unknown>>>;
|
|
115
161
|
};
|
|
@@ -132,7 +178,32 @@ export declare class Delivrie {
|
|
|
132
178
|
}) => Promise<Result<Broadcast>>;
|
|
133
179
|
cancel: (id: string) => Promise<Result<Broadcast>>;
|
|
134
180
|
/** How many contacts the broadcast will reach. */
|
|
135
|
-
|
|
181
|
+
/** Who it went to (with delivered/opened/clicked/bounced flags), or before sending, who it will reach. */
|
|
182
|
+
recipients: (id: string, params?: Pagination & {
|
|
183
|
+
status?: string;
|
|
184
|
+
}) => Promise<Result<BroadcastRecipients>>;
|
|
185
|
+
/** Clicked links with total and unique clicks. */
|
|
186
|
+
links: (id: string) => Promise<Result<List<BroadcastLink> & {
|
|
187
|
+
total_clicks: number;
|
|
188
|
+
}>>;
|
|
189
|
+
/** Edit a draft. */
|
|
190
|
+
update: (id: string, params: Partial<CreateBroadcastRequest>) => Promise<Result<{
|
|
191
|
+
object: "broadcast";
|
|
192
|
+
id: string;
|
|
193
|
+
}>>;
|
|
194
|
+
/** Copy it as a new draft. */
|
|
195
|
+
duplicate: (id: string, params?: {
|
|
196
|
+
name?: string;
|
|
197
|
+
}) => Promise<Result<{
|
|
198
|
+
object: "broadcast";
|
|
199
|
+
id: string;
|
|
200
|
+
name: string;
|
|
201
|
+
status: string;
|
|
202
|
+
}>>;
|
|
203
|
+
/** A draft's subject and blocks with ids. */
|
|
204
|
+
getContent: (id: string) => Promise<Result<EmailContent>>;
|
|
205
|
+
/** Edit a draft block by block. Anyone with it open in the editor sees the change live. */
|
|
206
|
+
editContent: (id: string, params: EditContentRequest) => Promise<Result<EmailContent>>;
|
|
136
207
|
remove: (id: string) => Promise<Result<Deleted>>;
|
|
137
208
|
};
|
|
138
209
|
readonly templates: {
|
|
@@ -145,6 +216,23 @@ export declare class Delivrie {
|
|
|
145
216
|
list: () => Promise<Result<List<Template>>>;
|
|
146
217
|
/** Publish the current draft so sends use it. */
|
|
147
218
|
publish: (id: string) => Promise<Result<Template>>;
|
|
219
|
+
/** Change it. Saved as a draft until published. */
|
|
220
|
+
update: (idOrAlias: string, params: Partial<CreateTemplateRequest> & Record<string, unknown>) => Promise<Result<{
|
|
221
|
+
object: "template";
|
|
222
|
+
id: string;
|
|
223
|
+
}>>;
|
|
224
|
+
duplicate: (idOrAlias: string, params?: {
|
|
225
|
+
name?: string;
|
|
226
|
+
alias?: string;
|
|
227
|
+
}) => Promise<Result<{
|
|
228
|
+
object: "template";
|
|
229
|
+
id: string;
|
|
230
|
+
name: string;
|
|
231
|
+
}>>;
|
|
232
|
+
remove: (idOrAlias: string) => Promise<Result<Deleted>>;
|
|
233
|
+
getContent: (idOrAlias: string) => Promise<Result<EmailContent>>;
|
|
234
|
+
/** Edit it block by block. Anyone with it open in the editor sees the change live. */
|
|
235
|
+
editContent: (idOrAlias: string, params: EditContentRequest) => Promise<Result<EmailContent>>;
|
|
148
236
|
};
|
|
149
237
|
readonly suppressions: {
|
|
150
238
|
/** Stop sending to one or more addresses. */
|
|
@@ -165,6 +253,15 @@ export declare class Delivrie {
|
|
|
165
253
|
publish: (id: string) => Promise<Result<Automation>>;
|
|
166
254
|
pause: (id: string) => Promise<Result<Automation>>;
|
|
167
255
|
resume: (id: string) => Promise<Result<Automation>>;
|
|
256
|
+
/** Copy it, with its trigger and steps, as a new draft. */
|
|
257
|
+
duplicate: (id: string, params?: {
|
|
258
|
+
name?: string;
|
|
259
|
+
}) => Promise<Result<Automation>>;
|
|
260
|
+
update: (id: string, params: {
|
|
261
|
+
name?: string;
|
|
262
|
+
reentry?: "once" | "always";
|
|
263
|
+
}) => Promise<Result<Automation>>;
|
|
264
|
+
remove: (id: string) => Promise<Result<Deleted>>;
|
|
168
265
|
};
|
|
169
266
|
readonly inbox: {
|
|
170
267
|
threads: {
|
|
@@ -172,11 +269,67 @@ export declare class Delivrie {
|
|
|
172
269
|
get: (id: string) => Promise<Result<InboxThread>>;
|
|
173
270
|
update: (id: string, params: Record<string, unknown>) => Promise<Result<InboxThread>>;
|
|
174
271
|
reply: (id: string, params: ReplyToThreadRequest) => Promise<Result<CreateEmailResponse>>;
|
|
272
|
+
/** Run the inbox's agent on this thread now. */
|
|
273
|
+
runAgent: (id: string) => Promise<Result<Record<string, unknown>>>;
|
|
274
|
+
notes: (id: string) => Promise<Result<List<Record<string, unknown>>>>;
|
|
275
|
+
addNote: (id: string, body: string) => Promise<Result<Record<string, unknown>>>;
|
|
276
|
+
};
|
|
277
|
+
notes: {
|
|
278
|
+
remove: (id: string) => Promise<Result<Deleted>>;
|
|
279
|
+
};
|
|
280
|
+
drafts: {
|
|
281
|
+
list: (params?: {
|
|
282
|
+
thread_id?: string;
|
|
283
|
+
inbox?: string;
|
|
284
|
+
source?: "user" | "agent";
|
|
285
|
+
}) => Promise<Result<List<Record<string, unknown>>>>;
|
|
286
|
+
create: (params: Record<string, unknown>) => Promise<Result<Record<string, unknown>>>;
|
|
287
|
+
update: (id: string, params: Record<string, unknown>) => Promise<Result<Record<string, unknown>>>;
|
|
288
|
+
send: (id: string) => Promise<Result<CreateEmailResponse>>;
|
|
289
|
+
remove: (id: string) => Promise<Result<Deleted>>;
|
|
175
290
|
};
|
|
176
291
|
labels: {
|
|
177
292
|
list: () => Promise<Result<List<Record<string, unknown>>>>;
|
|
178
293
|
};
|
|
179
294
|
};
|
|
295
|
+
/** Inboxes (addresses on receiving domains) and their agent settings. */
|
|
296
|
+
readonly inboxes: {
|
|
297
|
+
list: () => Promise<Result<List<Record<string, unknown>>>>;
|
|
298
|
+
create: (params: {
|
|
299
|
+
address: string;
|
|
300
|
+
name?: string;
|
|
301
|
+
description?: string;
|
|
302
|
+
}) => Promise<Result<Record<string, unknown>>>;
|
|
303
|
+
get: (idOrAddress: string) => Promise<Result<Record<string, unknown>>>;
|
|
304
|
+
update: (idOrAddress: string, params: Record<string, unknown>) => Promise<Result<Record<string, unknown>>>;
|
|
305
|
+
remove: (idOrAddress: string) => Promise<Result<Deleted>>;
|
|
306
|
+
agentRuns: (idOrAddress: string, params?: {
|
|
307
|
+
limit?: number;
|
|
308
|
+
}) => Promise<Result<List<Record<string, unknown>>>>;
|
|
309
|
+
};
|
|
310
|
+
/** AI writing in the team's brand voice. */
|
|
311
|
+
readonly ai: {
|
|
312
|
+
/** Write an email from a url and/or brief. With target, writes it into a template or draft broadcast. */
|
|
313
|
+
draft: (params: AiDraftRequest) => Promise<Result<AiDraft>>;
|
|
314
|
+
/** Rewrite blocks with an instruction. */
|
|
315
|
+
rewrite: (params: {
|
|
316
|
+
blocks: EmailBlock[];
|
|
317
|
+
instruction: string;
|
|
318
|
+
kind?: "broadcast" | "template";
|
|
319
|
+
context?: string;
|
|
320
|
+
}) => Promise<Result<{
|
|
321
|
+
object: "ai_rewrite";
|
|
322
|
+
blocks: EmailBlock[];
|
|
323
|
+
}>>;
|
|
324
|
+
/** Subject line ideas for an email's text. */
|
|
325
|
+
subjects: (params: {
|
|
326
|
+
text: string;
|
|
327
|
+
current?: string;
|
|
328
|
+
}) => Promise<Result<List<{
|
|
329
|
+
subject: string;
|
|
330
|
+
preview_text: string;
|
|
331
|
+
}>>>;
|
|
332
|
+
};
|
|
180
333
|
readonly metrics: {
|
|
181
334
|
get: (params?: {
|
|
182
335
|
days?: number;
|
package/dist/esm/client.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { verifyWebhook } from "./webhooks.js";
|
|
2
|
-
export const VERSION = "0.
|
|
2
|
+
export const VERSION = "0.3.0";
|
|
3
3
|
const DEFAULT_BASE_URL = "https://delivrie.io/api";
|
|
4
4
|
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
5
5
|
const enc = encodeURIComponent;
|
|
@@ -51,7 +51,7 @@ function normalizeEmail(e) {
|
|
|
51
51
|
if (when !== undefined)
|
|
52
52
|
out.scheduled_at = when instanceof Date ? when.toISOString() : when;
|
|
53
53
|
if (attachments)
|
|
54
|
-
out.attachments = attachments.map((a) => (
|
|
54
|
+
out.attachments = attachments.map((a) => (a.content === undefined || typeof a.content === "string" ? { ...a } : { ...a, content: toBase64(a.content) }));
|
|
55
55
|
return out;
|
|
56
56
|
}
|
|
57
57
|
/**
|
|
@@ -60,7 +60,7 @@ function normalizeEmail(e) {
|
|
|
60
60
|
* ```ts
|
|
61
61
|
* import { Delivrie } from "delivrie";
|
|
62
62
|
* const delivrie = new Delivrie(process.env.DELIVRIE_API_KEY);
|
|
63
|
-
* const { data, error } = await delivrie.emails.send({ from: "
|
|
63
|
+
* const { data, error } = await delivrie.emails.send({ from: "Acme <hi@acme.com>", to: "ada@example.com", subject: "Hi", html: "<p>Hello</p>" });
|
|
64
64
|
* ```
|
|
65
65
|
*/
|
|
66
66
|
export class Delivrie {
|
|
@@ -98,6 +98,14 @@ export class Delivrie {
|
|
|
98
98
|
/** Cancel a scheduled email. */
|
|
99
99
|
cancel: (id) => this.request("POST", `/emails/${enc(id)}/cancel`),
|
|
100
100
|
forward: (id, params) => this.request("POST", `/emails/${enc(id)}/forward`, params),
|
|
101
|
+
/** A sent email's files with download links that work for an hour. */
|
|
102
|
+
attachments: (id) => this.request("GET", `/emails/${enc(id)}/attachments`),
|
|
103
|
+
/** A received email's files with download links that work for an hour. */
|
|
104
|
+
receivedAttachments: (id) => this.request("GET", `/emails/received/${enc(id)}/attachments`),
|
|
105
|
+
/** A public link to the email and its delivery timeline. */
|
|
106
|
+
share: (id, params = {}) => this.request("POST", `/emails/${enc(id)}/share`, params),
|
|
107
|
+
/** Revoke every share link for the email. */
|
|
108
|
+
unshare: (id) => this.request("DELETE", `/emails/${enc(id)}/share`),
|
|
101
109
|
};
|
|
102
110
|
this.domains = {
|
|
103
111
|
create: (params) => this.request("POST", "/domains", params),
|
|
@@ -111,11 +119,16 @@ export class Delivrie {
|
|
|
111
119
|
this.apiKeys = {
|
|
112
120
|
create: (params) => this.request("POST", "/api-keys", params),
|
|
113
121
|
list: () => this.request("GET", "/api-keys"),
|
|
122
|
+
/** Rename a key. */
|
|
123
|
+
update: (id, params) => this.request("PATCH", `/api-keys/${enc(id)}`, params),
|
|
114
124
|
remove: (id) => this.request("DELETE", `/api-keys/${enc(id)}`),
|
|
115
125
|
};
|
|
116
126
|
this.webhooks = {
|
|
117
127
|
create: (params) => this.request("POST", "/webhooks", params),
|
|
118
128
|
list: () => this.request("GET", "/webhooks"),
|
|
129
|
+
/** Change the endpoint, events or status (enabled, disabled). */
|
|
130
|
+
update: (id, params) => this.request("PATCH", `/webhooks/${enc(id)}`, params),
|
|
131
|
+
remove: (id) => this.request("DELETE", `/webhooks/${enc(id)}`),
|
|
119
132
|
/** Recent delivery attempts for a webhook. */
|
|
120
133
|
deliveries: (id) => this.request("GET", `/webhooks/${enc(id)}/events`),
|
|
121
134
|
/** Send a test event to the endpoint. */
|
|
@@ -132,11 +145,24 @@ export class Delivrie {
|
|
|
132
145
|
update: (idOrEmail, params) => this.request("PATCH", `/contacts/${enc(idOrEmail)}`, params),
|
|
133
146
|
list: (params = {}) => this.request("GET", "/contacts", undefined, { query: { ...params } }),
|
|
134
147
|
remove: (idOrEmail) => this.request("DELETE", `/contacts/${enc(idOrEmail)}`),
|
|
148
|
+
imports: {
|
|
149
|
+
/** Import up to 50,000 contacts from CSV text or a list. Runs in the background. */
|
|
150
|
+
create: (params) => this.request("POST", "/contacts/imports", params),
|
|
151
|
+
get: (id) => this.request("GET", `/contacts/imports/${enc(id)}`),
|
|
152
|
+
list: (params = {}) => this.request("GET", "/contacts/imports", undefined, { query: { ...params } }),
|
|
153
|
+
},
|
|
135
154
|
};
|
|
136
155
|
this.segments = {
|
|
137
156
|
create: (params) => this.request("POST", "/segments", params),
|
|
138
157
|
list: () => this.request("GET", "/segments"),
|
|
158
|
+
get: (id) => this.request("GET", `/segments/${enc(id)}`),
|
|
159
|
+
/** Rename a segment. */
|
|
160
|
+
update: (id, params) => this.request("PATCH", `/segments/${enc(id)}`, params),
|
|
139
161
|
remove: (id) => this.request("DELETE", `/segments/${enc(id)}`),
|
|
162
|
+
/** The contacts in a segment. */
|
|
163
|
+
contacts: (id, params = {}) => this.request("GET", `/segments/${enc(id)}/contacts`, undefined, { query: { ...params } }),
|
|
164
|
+
/** Take contacts (emails or ids) out of a segment. The contacts aren't deleted. */
|
|
165
|
+
removeContacts: (id, contacts) => this.request("DELETE", `/segments/${enc(id)}/contacts`, { contacts }),
|
|
140
166
|
/** Add contacts by email (they're created if needed). */
|
|
141
167
|
addContacts: (id, contacts) => this.request("POST", `/segments/${enc(id)}/contacts`, { contacts: contacts.map((c) => (typeof c === "string" ? { email: c } : c)) }),
|
|
142
168
|
};
|
|
@@ -150,7 +176,18 @@ export class Delivrie {
|
|
|
150
176
|
send: (id, params = {}) => this.request("POST", `/broadcasts/${enc(id)}/send`, params.scheduled_at === undefined ? {} : { scheduled_at: params.scheduled_at instanceof Date ? params.scheduled_at.toISOString() : params.scheduled_at }),
|
|
151
177
|
cancel: (id) => this.request("POST", `/broadcasts/${enc(id)}/cancel`),
|
|
152
178
|
/** How many contacts the broadcast will reach. */
|
|
153
|
-
|
|
179
|
+
/** Who it went to (with delivered/opened/clicked/bounced flags), or before sending, who it will reach. */
|
|
180
|
+
recipients: (id, params = {}) => this.request("GET", `/broadcasts/${enc(id)}/recipients`, undefined, { query: { ...params } }),
|
|
181
|
+
/** Clicked links with total and unique clicks. */
|
|
182
|
+
links: (id) => this.request("GET", `/broadcasts/${enc(id)}/links`),
|
|
183
|
+
/** Edit a draft. */
|
|
184
|
+
update: (id, params) => this.request("PATCH", `/broadcasts/${enc(id)}`, params),
|
|
185
|
+
/** Copy it as a new draft. */
|
|
186
|
+
duplicate: (id, params = {}) => this.request("POST", `/broadcasts/${enc(id)}/duplicate`, params),
|
|
187
|
+
/** A draft's subject and blocks with ids. */
|
|
188
|
+
getContent: (id) => this.request("GET", `/broadcasts/${enc(id)}/content`),
|
|
189
|
+
/** Edit a draft block by block. Anyone with it open in the editor sees the change live. */
|
|
190
|
+
editContent: (id, params) => this.request("POST", `/broadcasts/${enc(id)}/content`, params),
|
|
154
191
|
remove: (id) => this.request("DELETE", `/broadcasts/${enc(id)}`),
|
|
155
192
|
};
|
|
156
193
|
this.templates = {
|
|
@@ -160,6 +197,13 @@ export class Delivrie {
|
|
|
160
197
|
list: () => this.request("GET", "/templates"),
|
|
161
198
|
/** Publish the current draft so sends use it. */
|
|
162
199
|
publish: (id) => this.request("POST", `/templates/${enc(id)}/publish`),
|
|
200
|
+
/** Change it. Saved as a draft until published. */
|
|
201
|
+
update: (idOrAlias, params) => this.request("PATCH", `/templates/${enc(idOrAlias)}`, params),
|
|
202
|
+
duplicate: (idOrAlias, params = {}) => this.request("POST", `/templates/${enc(idOrAlias)}/duplicate`, params),
|
|
203
|
+
remove: (idOrAlias) => this.request("DELETE", `/templates/${enc(idOrAlias)}`),
|
|
204
|
+
getContent: (idOrAlias) => this.request("GET", `/templates/${enc(idOrAlias)}/content`),
|
|
205
|
+
/** Edit it block by block. Anyone with it open in the editor sees the change live. */
|
|
206
|
+
editContent: (idOrAlias, params) => this.request("POST", `/templates/${enc(idOrAlias)}/content`, params),
|
|
163
207
|
};
|
|
164
208
|
this.suppressions = {
|
|
165
209
|
/** Stop sending to one or more addresses. */
|
|
@@ -180,6 +224,10 @@ export class Delivrie {
|
|
|
180
224
|
publish: (id) => this.request("POST", `/automations/${enc(id)}/publish`),
|
|
181
225
|
pause: (id) => this.request("POST", `/automations/${enc(id)}/pause`),
|
|
182
226
|
resume: (id) => this.request("POST", `/automations/${enc(id)}/resume`),
|
|
227
|
+
/** Copy it, with its trigger and steps, as a new draft. */
|
|
228
|
+
duplicate: (id, params = {}) => this.request("POST", `/automations/${enc(id)}/duplicate`, params),
|
|
229
|
+
update: (id, params) => this.request("PATCH", `/automations/${enc(id)}`, params),
|
|
230
|
+
remove: (id) => this.request("DELETE", `/automations/${enc(id)}`),
|
|
183
231
|
};
|
|
184
232
|
this.inbox = {
|
|
185
233
|
threads: {
|
|
@@ -187,9 +235,39 @@ export class Delivrie {
|
|
|
187
235
|
get: (id) => this.request("GET", `/inbox/threads/${enc(id)}`),
|
|
188
236
|
update: (id, params) => this.request("PATCH", `/inbox/threads/${enc(id)}`, params),
|
|
189
237
|
reply: (id, params) => this.request("POST", `/inbox/threads/${enc(id)}/reply`, params),
|
|
238
|
+
/** Run the inbox's agent on this thread now. */
|
|
239
|
+
runAgent: (id) => this.request("POST", `/inbox/threads/${enc(id)}/agent`),
|
|
240
|
+
notes: (id) => this.request("GET", `/inbox/threads/${enc(id)}/notes`),
|
|
241
|
+
addNote: (id, body) => this.request("POST", `/inbox/threads/${enc(id)}/notes`, { body }),
|
|
242
|
+
},
|
|
243
|
+
notes: { remove: (id) => this.request("DELETE", `/inbox/notes/${enc(id)}`) },
|
|
244
|
+
drafts: {
|
|
245
|
+
list: (params = {}) => this.request("GET", "/inbox/drafts", undefined, { query: { ...params } }),
|
|
246
|
+
create: (params) => this.request("POST", "/inbox/drafts", params),
|
|
247
|
+
update: (id, params) => this.request("PATCH", `/inbox/drafts/${enc(id)}`, params),
|
|
248
|
+
send: (id) => this.request("POST", `/inbox/drafts/${enc(id)}/send`),
|
|
249
|
+
remove: (id) => this.request("DELETE", `/inbox/drafts/${enc(id)}`),
|
|
190
250
|
},
|
|
191
251
|
labels: { list: () => this.request("GET", "/inbox/labels") },
|
|
192
252
|
};
|
|
253
|
+
/** Inboxes (addresses on receiving domains) and their agent settings. */
|
|
254
|
+
this.inboxes = {
|
|
255
|
+
list: () => this.request("GET", "/inboxes"),
|
|
256
|
+
create: (params) => this.request("POST", "/inboxes", params),
|
|
257
|
+
get: (idOrAddress) => this.request("GET", `/inboxes/${enc(idOrAddress)}`),
|
|
258
|
+
update: (idOrAddress, params) => this.request("PATCH", `/inboxes/${enc(idOrAddress)}`, params),
|
|
259
|
+
remove: (idOrAddress) => this.request("DELETE", `/inboxes/${enc(idOrAddress)}`),
|
|
260
|
+
agentRuns: (idOrAddress, params = {}) => this.request("GET", `/inboxes/${enc(idOrAddress)}/agent-runs`, undefined, { query: { ...params } }),
|
|
261
|
+
};
|
|
262
|
+
/** AI writing in the team's brand voice. */
|
|
263
|
+
this.ai = {
|
|
264
|
+
/** Write an email from a url and/or brief. With target, writes it into a template or draft broadcast. */
|
|
265
|
+
draft: (params) => this.request("POST", "/ai/draft", params),
|
|
266
|
+
/** Rewrite blocks with an instruction. */
|
|
267
|
+
rewrite: (params) => this.request("POST", "/ai/rewrite", params),
|
|
268
|
+
/** Subject line ideas for an email's text. */
|
|
269
|
+
subjects: (params) => this.request("POST", "/ai/subjects", params),
|
|
270
|
+
};
|
|
193
271
|
this.metrics = {
|
|
194
272
|
get: (params = {}) => this.request("GET", "/metrics", undefined, { query: params }),
|
|
195
273
|
};
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -36,9 +36,12 @@ export interface Tag {
|
|
|
36
36
|
value: string;
|
|
37
37
|
}
|
|
38
38
|
export interface Attachment {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
/** Defaults to the file name in `path`. */
|
|
40
|
+
filename?: string;
|
|
41
|
+
/** File contents as a base64 string (or a Buffer/Uint8Array, which the SDK encodes for you). Up to 40 MB per email. Provide `content` or `path`. */
|
|
42
|
+
content?: string | Uint8Array;
|
|
43
|
+
/** A public https:// URL that Delivrie downloads when the email is accepted. */
|
|
44
|
+
path?: string;
|
|
42
45
|
content_type?: string;
|
|
43
46
|
/** Set to reference the file inline from HTML with `cid:<content_id>`. */
|
|
44
47
|
content_id?: string;
|
|
@@ -153,6 +156,8 @@ export interface Domain {
|
|
|
153
156
|
receiving_subdomain: string | null;
|
|
154
157
|
receiving_mode: string | null;
|
|
155
158
|
receiving_addresses: string[] | null;
|
|
159
|
+
/** Addresses that get a copy of every email this domain receives. Empty when forwarding is off. */
|
|
160
|
+
receiving_forward_to: string[];
|
|
156
161
|
receiving_verified_at: string | null;
|
|
157
162
|
}
|
|
158
163
|
export interface CreateDomainRequest {
|
|
@@ -385,6 +390,179 @@ export interface ReplyToThreadRequest {
|
|
|
385
390
|
text?: string;
|
|
386
391
|
html?: string;
|
|
387
392
|
}
|
|
393
|
+
/** GET /broadcasts/:id/recipients. `total`, `topic_opt_out` and `recipients` are counts; `data` lists people. */
|
|
394
|
+
export interface BroadcastRecipients {
|
|
395
|
+
object: "list";
|
|
396
|
+
data: Array<{
|
|
397
|
+
object: "broadcast_recipient";
|
|
398
|
+
email: string;
|
|
399
|
+
contact_id: string | null;
|
|
400
|
+
email_id?: string;
|
|
401
|
+
status: string;
|
|
402
|
+
sent_at?: string | null;
|
|
403
|
+
delivered?: boolean;
|
|
404
|
+
opened?: boolean;
|
|
405
|
+
clicked?: boolean;
|
|
406
|
+
bounced?: boolean;
|
|
407
|
+
complained?: boolean;
|
|
408
|
+
unsubscribed?: boolean;
|
|
409
|
+
}>;
|
|
410
|
+
has_more: boolean;
|
|
411
|
+
/** Contacts in the segment (before sending) or emails sent. */
|
|
412
|
+
total: number;
|
|
413
|
+
topic_opt_out: number;
|
|
414
|
+
/** How many it reaches after unsubscribes, topic opt-outs and suppressions. */
|
|
415
|
+
recipients: number;
|
|
416
|
+
}
|
|
417
|
+
export interface BroadcastLink {
|
|
418
|
+
object: "broadcast_link";
|
|
419
|
+
link: string;
|
|
420
|
+
clicks: number;
|
|
421
|
+
unique_clicks: number;
|
|
422
|
+
}
|
|
423
|
+
/** A sent or received email's file. `download_url` works until `expires_at` (an hour). */
|
|
424
|
+
export interface AttachmentDownload {
|
|
425
|
+
object: "attachment";
|
|
426
|
+
id: string;
|
|
427
|
+
filename: string;
|
|
428
|
+
content_type: string;
|
|
429
|
+
size: number | null;
|
|
430
|
+
content_id?: string;
|
|
431
|
+
download_url: string | null;
|
|
432
|
+
expires_at: string | null;
|
|
433
|
+
/** Why there's no download_url: the file is older than storage, or past the 30-day retention. */
|
|
434
|
+
note?: string;
|
|
435
|
+
}
|
|
436
|
+
export interface EmailShare {
|
|
437
|
+
object: "email_share";
|
|
438
|
+
email_id: string;
|
|
439
|
+
url: string;
|
|
440
|
+
token: string;
|
|
441
|
+
expires_at: string;
|
|
442
|
+
}
|
|
443
|
+
export interface CreateContactImportRequest {
|
|
444
|
+
/** CSV text with a header row and an email column. Provide csv or contacts. */
|
|
445
|
+
csv?: string;
|
|
446
|
+
/** Contacts as objects, or plain email addresses. */
|
|
447
|
+
contacts?: Array<string | CreateContactRequest>;
|
|
448
|
+
/** Map CSV headers to fields: { "E-mail": "email", "Company": "property:company", "Notes": null }. */
|
|
449
|
+
columns?: Record<string, string | null>;
|
|
450
|
+
/** Add everyone to these segments. */
|
|
451
|
+
segment_ids?: string[];
|
|
452
|
+
/** Update contacts that already exist. Default true. */
|
|
453
|
+
update_existing?: boolean;
|
|
454
|
+
}
|
|
455
|
+
export interface ContactImport {
|
|
456
|
+
object: "contact_import";
|
|
457
|
+
id: string;
|
|
458
|
+
status: "queued" | "processing" | "completed" | "failed";
|
|
459
|
+
segment_ids: string[];
|
|
460
|
+
update_existing: boolean;
|
|
461
|
+
total: number;
|
|
462
|
+
processed: number;
|
|
463
|
+
created: number;
|
|
464
|
+
updated: number;
|
|
465
|
+
skipped: number;
|
|
466
|
+
/** The first 100 problems. */
|
|
467
|
+
errors: Array<{
|
|
468
|
+
row: number | null;
|
|
469
|
+
email: string | null;
|
|
470
|
+
message: string;
|
|
471
|
+
}>;
|
|
472
|
+
error: string | null;
|
|
473
|
+
created_at: string;
|
|
474
|
+
completed_at: string | null;
|
|
475
|
+
}
|
|
476
|
+
/** An editor block: title, heading, eyebrow, text, bulleted, numbered, callout, button, image, rows, divider, spacer, otp, footer. */
|
|
477
|
+
export interface EmailBlock {
|
|
478
|
+
id?: string;
|
|
479
|
+
type: string;
|
|
480
|
+
[field: string]: unknown;
|
|
481
|
+
}
|
|
482
|
+
export type EditOperation = {
|
|
483
|
+
op: "replace";
|
|
484
|
+
id: string;
|
|
485
|
+
block: EmailBlock;
|
|
486
|
+
} | {
|
|
487
|
+
op: "update";
|
|
488
|
+
id: string;
|
|
489
|
+
set: Record<string, unknown>;
|
|
490
|
+
} | {
|
|
491
|
+
op: "insert";
|
|
492
|
+
after?: string | null;
|
|
493
|
+
before?: string;
|
|
494
|
+
block?: EmailBlock;
|
|
495
|
+
blocks?: EmailBlock[];
|
|
496
|
+
} | {
|
|
497
|
+
op: "delete";
|
|
498
|
+
id: string;
|
|
499
|
+
} | {
|
|
500
|
+
op: "move";
|
|
501
|
+
id: string;
|
|
502
|
+
after?: string | null;
|
|
503
|
+
before?: string;
|
|
504
|
+
};
|
|
505
|
+
export interface EditContentRequest {
|
|
506
|
+
ops?: EditOperation[];
|
|
507
|
+
/** Replace every block. */
|
|
508
|
+
blocks?: EmailBlock[];
|
|
509
|
+
subject?: string;
|
|
510
|
+
/** Broadcasts only. */
|
|
511
|
+
preview_text?: string;
|
|
512
|
+
/** One line on what changed, shown in the editor. */
|
|
513
|
+
summary?: string;
|
|
514
|
+
}
|
|
515
|
+
export interface EmailContent {
|
|
516
|
+
object: "template_content" | "broadcast_content";
|
|
517
|
+
id: string;
|
|
518
|
+
name: string;
|
|
519
|
+
subject: string | null;
|
|
520
|
+
preview_text?: string | null;
|
|
521
|
+
content: {
|
|
522
|
+
page: Record<string, unknown> | null;
|
|
523
|
+
blocks: EmailBlock[];
|
|
524
|
+
};
|
|
525
|
+
agent_edit: {
|
|
526
|
+
by: string;
|
|
527
|
+
at: string;
|
|
528
|
+
rev: number;
|
|
529
|
+
summary?: string;
|
|
530
|
+
} | null;
|
|
531
|
+
editor_url: string;
|
|
532
|
+
}
|
|
533
|
+
export interface AiDraftRequest {
|
|
534
|
+
/** A page to write from: a blog post, changelog, product or event page. */
|
|
535
|
+
url?: string;
|
|
536
|
+
/** What the email is for. Provide url, brief or both. */
|
|
537
|
+
brief?: string;
|
|
538
|
+
kind?: "broadcast" | "template";
|
|
539
|
+
length?: "short" | "medium" | "long";
|
|
540
|
+
tone?: string;
|
|
541
|
+
variables?: string[];
|
|
542
|
+
/** Write it straight into this template or draft broadcast. */
|
|
543
|
+
target?: {
|
|
544
|
+
type: "template" | "broadcast";
|
|
545
|
+
id: string;
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
export interface AiDraft {
|
|
549
|
+
object: "ai_draft";
|
|
550
|
+
subject: string;
|
|
551
|
+
preview_text: string;
|
|
552
|
+
content: {
|
|
553
|
+
blocks: EmailBlock[];
|
|
554
|
+
};
|
|
555
|
+
notes: string | null;
|
|
556
|
+
source: {
|
|
557
|
+
url: string;
|
|
558
|
+
title: string;
|
|
559
|
+
} | null;
|
|
560
|
+
target?: {
|
|
561
|
+
type: "template" | "broadcast";
|
|
562
|
+
id: string;
|
|
563
|
+
};
|
|
564
|
+
}
|
|
565
|
+
/** @deprecated Use BroadcastRecipients. */
|
|
388
566
|
export interface BroadcastRecipientCount {
|
|
389
567
|
/** Contacts in the segment. */
|
|
390
568
|
total: number;
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "delivrie",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Official Node.js and TypeScript SDK for the Delivrie email API: send transactional email, manage domains, contacts, broadcasts and templates, and verify webhooks.",
|
|
5
|
-
"keywords": ["delivrie", "email", "email-api", "transactional-email", "smtp", "resend-alternative", "webhooks"
|
|
5
|
+
"keywords": ["delivrie", "email", "email-api", "transactional-email", "smtp", "resend-alternative", "webhooks"],
|
|
6
6
|
"homepage": "https://delivrie.io/docs/sdks",
|
|
7
|
-
"repository": { "type": "git", "url": "git+https://github.com/
|
|
7
|
+
"repository": { "type": "git", "url": "git+https://github.com/bysurce/delivrie.git", "directory": "sdk/node" },
|
|
8
8
|
"bugs": { "url": "https://delivrie.io/support" },
|
|
9
9
|
"license": "MIT",
|
|
10
|
-
"author": "
|
|
10
|
+
"author": "Surce Inc <support@delivrie.io>",
|
|
11
11
|
"type": "module",
|
|
12
12
|
"main": "./dist/cjs/index.cjs",
|
|
13
13
|
"module": "./dist/esm/index.js",
|