@sendclipper/node 0.0.0-stage → 0.1.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.
Files changed (125) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/LICENSE +21 -0
  3. package/README.md +208 -2
  4. package/dist/cjs/core.d.ts +95 -0
  5. package/dist/cjs/core.d.ts.map +1 -0
  6. package/dist/cjs/core.js +231 -0
  7. package/dist/cjs/core.js.map +1 -0
  8. package/dist/cjs/errors.d.ts +34 -0
  9. package/dist/cjs/errors.d.ts.map +1 -0
  10. package/dist/cjs/errors.js +110 -0
  11. package/dist/cjs/errors.js.map +1 -0
  12. package/dist/cjs/index.d.ts +52 -0
  13. package/dist/cjs/index.d.ts.map +1 -0
  14. package/dist/cjs/index.js +80 -0
  15. package/dist/cjs/index.js.map +1 -0
  16. package/dist/cjs/package.json +3 -0
  17. package/dist/cjs/render.d.ts +14 -0
  18. package/dist/cjs/render.d.ts.map +1 -0
  19. package/dist/cjs/render.js +64 -0
  20. package/dist/cjs/render.js.map +1 -0
  21. package/dist/cjs/resources/audience.d.ts +51 -0
  22. package/dist/cjs/resources/audience.d.ts.map +1 -0
  23. package/dist/cjs/resources/audience.js +105 -0
  24. package/dist/cjs/resources/audience.js.map +1 -0
  25. package/dist/cjs/resources/domains.d.ts +22 -0
  26. package/dist/cjs/resources/domains.d.ts.map +1 -0
  27. package/dist/cjs/resources/domains.js +45 -0
  28. package/dist/cjs/resources/domains.js.map +1 -0
  29. package/dist/cjs/resources/emails.d.ts +34 -0
  30. package/dist/cjs/resources/emails.d.ts.map +1 -0
  31. package/dist/cjs/resources/emails.js +67 -0
  32. package/dist/cjs/resources/emails.js.map +1 -0
  33. package/dist/cjs/resources/mailboxes.d.ts +27 -0
  34. package/dist/cjs/resources/mailboxes.d.ts.map +1 -0
  35. package/dist/cjs/resources/mailboxes.js +65 -0
  36. package/dist/cjs/resources/mailboxes.js.map +1 -0
  37. package/dist/cjs/resources/sandboxes.d.ts +54 -0
  38. package/dist/cjs/resources/sandboxes.d.ts.map +1 -0
  39. package/dist/cjs/resources/sandboxes.js +107 -0
  40. package/dist/cjs/resources/sandboxes.js.map +1 -0
  41. package/dist/cjs/resources/templates.d.ts +58 -0
  42. package/dist/cjs/resources/templates.d.ts.map +1 -0
  43. package/dist/cjs/resources/templates.js +97 -0
  44. package/dist/cjs/resources/templates.js.map +1 -0
  45. package/dist/cjs/resources/webhooks.d.ts +39 -0
  46. package/dist/cjs/resources/webhooks.d.ts.map +1 -0
  47. package/dist/cjs/resources/webhooks.js +75 -0
  48. package/dist/cjs/resources/webhooks.js.map +1 -0
  49. package/dist/cjs/resources/workspace.d.ts +21 -0
  50. package/dist/cjs/resources/workspace.d.ts.map +1 -0
  51. package/dist/cjs/resources/workspace.js +38 -0
  52. package/dist/cjs/resources/workspace.js.map +1 -0
  53. package/dist/cjs/types.d.ts +662 -0
  54. package/dist/cjs/types.d.ts.map +1 -0
  55. package/dist/cjs/types.js +9 -0
  56. package/dist/cjs/types.js.map +1 -0
  57. package/dist/cjs/version.d.ts +3 -0
  58. package/dist/cjs/version.d.ts.map +1 -0
  59. package/dist/cjs/version.js +6 -0
  60. package/dist/cjs/version.js.map +1 -0
  61. package/dist/cjs/webhook-signature.d.ts +38 -0
  62. package/dist/cjs/webhook-signature.d.ts.map +1 -0
  63. package/dist/cjs/webhook-signature.js +102 -0
  64. package/dist/cjs/webhook-signature.js.map +1 -0
  65. package/dist/esm/core.d.ts +95 -0
  66. package/dist/esm/core.d.ts.map +1 -0
  67. package/dist/esm/core.js +225 -0
  68. package/dist/esm/core.js.map +1 -0
  69. package/dist/esm/errors.d.ts +34 -0
  70. package/dist/esm/errors.d.ts.map +1 -0
  71. package/dist/esm/errors.js +102 -0
  72. package/dist/esm/errors.js.map +1 -0
  73. package/dist/esm/index.d.ts +52 -0
  74. package/dist/esm/index.d.ts.map +1 -0
  75. package/dist/esm/index.js +65 -0
  76. package/dist/esm/index.js.map +1 -0
  77. package/dist/esm/render.d.ts +14 -0
  78. package/dist/esm/render.d.ts.map +1 -0
  79. package/dist/esm/render.js +28 -0
  80. package/dist/esm/render.js.map +1 -0
  81. package/dist/esm/resources/audience.d.ts +51 -0
  82. package/dist/esm/resources/audience.d.ts.map +1 -0
  83. package/dist/esm/resources/audience.js +99 -0
  84. package/dist/esm/resources/audience.js.map +1 -0
  85. package/dist/esm/resources/domains.d.ts +22 -0
  86. package/dist/esm/resources/domains.d.ts.map +1 -0
  87. package/dist/esm/resources/domains.js +41 -0
  88. package/dist/esm/resources/domains.js.map +1 -0
  89. package/dist/esm/resources/emails.d.ts +34 -0
  90. package/dist/esm/resources/emails.d.ts.map +1 -0
  91. package/dist/esm/resources/emails.js +62 -0
  92. package/dist/esm/resources/emails.js.map +1 -0
  93. package/dist/esm/resources/mailboxes.d.ts +27 -0
  94. package/dist/esm/resources/mailboxes.d.ts.map +1 -0
  95. package/dist/esm/resources/mailboxes.js +60 -0
  96. package/dist/esm/resources/mailboxes.js.map +1 -0
  97. package/dist/esm/resources/sandboxes.d.ts +54 -0
  98. package/dist/esm/resources/sandboxes.d.ts.map +1 -0
  99. package/dist/esm/resources/sandboxes.js +102 -0
  100. package/dist/esm/resources/sandboxes.js.map +1 -0
  101. package/dist/esm/resources/templates.d.ts +58 -0
  102. package/dist/esm/resources/templates.d.ts.map +1 -0
  103. package/dist/esm/resources/templates.js +91 -0
  104. package/dist/esm/resources/templates.js.map +1 -0
  105. package/dist/esm/resources/webhooks.d.ts +39 -0
  106. package/dist/esm/resources/webhooks.d.ts.map +1 -0
  107. package/dist/esm/resources/webhooks.js +70 -0
  108. package/dist/esm/resources/webhooks.js.map +1 -0
  109. package/dist/esm/resources/workspace.d.ts +21 -0
  110. package/dist/esm/resources/workspace.d.ts.map +1 -0
  111. package/dist/esm/resources/workspace.js +32 -0
  112. package/dist/esm/resources/workspace.js.map +1 -0
  113. package/dist/esm/types.d.ts +662 -0
  114. package/dist/esm/types.d.ts.map +1 -0
  115. package/dist/esm/types.js +8 -0
  116. package/dist/esm/types.js.map +1 -0
  117. package/dist/esm/version.d.ts +3 -0
  118. package/dist/esm/version.d.ts.map +1 -0
  119. package/dist/esm/version.js +3 -0
  120. package/dist/esm/version.js.map +1 -0
  121. package/dist/esm/webhook-signature.d.ts +38 -0
  122. package/dist/esm/webhook-signature.d.ts.map +1 -0
  123. package/dist/esm/webhook-signature.js +95 -0
  124. package/dist/esm/webhook-signature.js.map +1 -0
  125. package/package.json +72 -4
@@ -0,0 +1,32 @@
1
+ import { seg } from '../core.js';
2
+ export class WorkspaceResource {
3
+ http;
4
+ constructor(http) {
5
+ this.http = http;
6
+ }
7
+ /** The workspace this key belongs to. */
8
+ get(options = {}) {
9
+ return this.http.call({ method: 'GET', path: '/workspace', ...options });
10
+ }
11
+ }
12
+ export class ApiKeys {
13
+ http;
14
+ constructor(http) {
15
+ this.http = http;
16
+ }
17
+ /** The workspace's keys, masked. Keys are created and revoked in the dashboard only. */
18
+ list(options = {}) {
19
+ return this.http.call({ method: 'GET', path: '/api-keys', ...options });
20
+ }
21
+ }
22
+ export class Automations {
23
+ http;
24
+ constructor(http) {
25
+ this.http = http;
26
+ }
27
+ /** Start a Live automation with a `manual` trigger for one contact. */
28
+ enroll(automationId, email, options = {}) {
29
+ return this.http.call({ method: 'POST', path: `/automations/${seg(automationId)}/enrollments`, body: { email }, ...options });
30
+ }
31
+ }
32
+ //# sourceMappingURL=workspace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspace.js","sourceRoot":"","sources":["../../../src/resources/workspace.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAGjC,MAAM,OAAO,iBAAiB;IACC;IAA7B,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD,yCAAyC;IACzC,GAAG,CAAC,UAA0B,EAAE;QAC9B,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAC3E,CAAC;CACF;AAED,MAAM,OAAO,OAAO;IACW;IAA7B,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD,wFAAwF;IACxF,IAAI,CAAC,UAA0B,EAAE;QAC/B,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAC1E,CAAC;CACF;AAED,MAAM,OAAO,WAAW;IACO;IAA7B,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD,uEAAuE;IACvE,MAAM,CAAC,YAAoB,EAAE,KAAa,EAAE,UAA0B,EAAE;QACtE,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,GAAG,CAAC,YAAY,CAAC,cAAc,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAChI,CAAC;CACF"}
@@ -0,0 +1,662 @@
1
+ /** Values for `{{tags}}`: a flat object of tag → string / number / boolean. */
2
+ export type TemplateVariables = Record<string, string | number | boolean>;
3
+ export type SendClass = 'transactional' | 'marketing';
4
+ export type DomainRegion = 'us-east-1' | 'eu-west-1' | 'us-west-2';
5
+ /** A list page addressed by number. */
6
+ export interface NumberedPage<T> {
7
+ items: T[];
8
+ total: number;
9
+ page: number;
10
+ pageSize: number;
11
+ }
12
+ /** A list page addressed by an opaque cursor. */
13
+ export interface CursorPage<T> {
14
+ data: T[];
15
+ page: {
16
+ cursor: string | null;
17
+ hasMore: boolean;
18
+ };
19
+ }
20
+ interface SendEmailBase {
21
+ /** A bare address on a verified domain: `hello@send.acme.io`. A display-name form is refused. */
22
+ from: string;
23
+ /** ONE recipient. For several, use `emails.sendBatch()` with one item each. */
24
+ to: string;
25
+ /** Plain-text alternative. */
26
+ text?: string;
27
+ /** Fills `{{tags}}` in a template, or in a hand-written `html` body. */
28
+ variables?: TemplateVariables;
29
+ /** `transactional` (default) or `marketing`. Marketing adds one-click unsubscribe and the postal-address footer. */
30
+ sendClass?: SendClass;
31
+ /** `false` leaves the open-tracking pixel out. Default `true`. */
32
+ trackOpens?: boolean;
33
+ /** `false` leaves links unwrapped. Default `true`. */
34
+ trackClicks?: boolean;
35
+ }
36
+ /** A message with its own body. */
37
+ export interface SendEmailWithHtml extends SendEmailBase {
38
+ subject: string;
39
+ html: string;
40
+ react?: never;
41
+ templateId?: never;
42
+ template?: never;
43
+ }
44
+ /**
45
+ * A message whose body is a React Email component, rendered locally to
46
+ * `html` (and `text`, unless you give one). Needs `@react-email/render`.
47
+ */
48
+ export interface SendEmailWithReact extends SendEmailBase {
49
+ subject: string;
50
+ /** e.g. `<WelcomeEmail name="Ada" />`. */
51
+ react: unknown;
52
+ html?: never;
53
+ templateId?: never;
54
+ template?: never;
55
+ }
56
+ /** A message rendered from a published template. */
57
+ export interface SendEmailWithTemplate extends SendEmailBase {
58
+ /** A published template's public id (`tpl_…`) or uuid. */
59
+ templateId?: string;
60
+ /** A published template's send name (its `key`, e.g. `"welcome"`). Use this or `templateId`. */
61
+ template?: string;
62
+ /** Overrides the template's subject. */
63
+ subject?: string;
64
+ html?: never;
65
+ react?: never;
66
+ }
67
+ export type SendEmailParams = SendEmailWithHtml | SendEmailWithReact | SendEmailWithTemplate;
68
+ export type EmailStatus = 'queued' | 'sent' | 'delivered' | 'opened' | 'clicked' | 'bounced' | 'complained' | 'failed';
69
+ export interface SentEmail {
70
+ /** SendClipper's id for the message. Use it with `emails.get()`. */
71
+ id: string;
72
+ messageId: string;
73
+ sesMessageId: string | null;
74
+ from: string;
75
+ to: string;
76
+ domain: string;
77
+ subject: string;
78
+ status: EmailStatus;
79
+ createdAt: string;
80
+ templateId: string | null;
81
+ }
82
+ export type BatchResult = {
83
+ index: number;
84
+ status: 'accepted';
85
+ id: string;
86
+ messageId: string;
87
+ } | {
88
+ index: number;
89
+ status: 'failed';
90
+ error: {
91
+ code: string;
92
+ message: string;
93
+ detail?: unknown;
94
+ };
95
+ };
96
+ export interface SendBatchResponse {
97
+ /** One entry per submitted item, in order. A failed item costs its siblings nothing. */
98
+ data: BatchResult[];
99
+ summary: {
100
+ submitted: number;
101
+ accepted: number;
102
+ failed: number;
103
+ };
104
+ }
105
+ export interface ListEmailsParams {
106
+ search?: string;
107
+ status?: EmailStatus;
108
+ /** Exact sending domain. */
109
+ domain?: string;
110
+ broadcastId?: string;
111
+ /** ISO 8601 lower bound. */
112
+ from?: string;
113
+ /** ISO 8601 upper bound. */
114
+ to?: string;
115
+ page?: number;
116
+ /** 1–100, default 50. */
117
+ pageSize?: number;
118
+ }
119
+ export interface EmailRow {
120
+ id: string;
121
+ messageId: string;
122
+ from: string;
123
+ to: string;
124
+ domain: string;
125
+ subject: string;
126
+ status: EmailStatus;
127
+ sesMessageId: string | null;
128
+ createdAt: string;
129
+ }
130
+ export interface EmailList extends NumberedPage<EmailRow> {
131
+ /** A search counts only its newest 1,000 matches. */
132
+ totalCapped: boolean;
133
+ }
134
+ export interface EmailEvent {
135
+ id: string;
136
+ type: string;
137
+ meta: unknown;
138
+ createdAt: string;
139
+ }
140
+ export interface EmailDetail extends EmailRow {
141
+ html: string | null;
142
+ text: string | null;
143
+ /** `true` once the retention window deleted the body. */
144
+ bodyExpired: boolean;
145
+ events: EmailEvent[];
146
+ threadId?: string | null;
147
+ sendClass?: SendClass;
148
+ trackOpens?: boolean;
149
+ trackClicks?: boolean;
150
+ }
151
+ export interface EmailStats {
152
+ total: number;
153
+ queued: number;
154
+ sent: number;
155
+ delivered: number;
156
+ opened: number;
157
+ clicked: number;
158
+ bounced: number;
159
+ complained: number;
160
+ failed: number;
161
+ bodyRetentionDays: number;
162
+ }
163
+ export interface DnsRecord {
164
+ type: string;
165
+ purpose: string;
166
+ host: string;
167
+ value: string;
168
+ copyValue?: string;
169
+ priority?: number;
170
+ status?: string;
171
+ }
172
+ export interface Domain {
173
+ id: string;
174
+ name: string;
175
+ region: DomainRegion;
176
+ status: 'verified' | 'pending' | 'failed';
177
+ spfOk: boolean;
178
+ dkimOk: boolean;
179
+ dmarcOk: boolean;
180
+ records: Array<{
181
+ name: 'SPF' | 'DKIM' | 'DMARC';
182
+ ok: boolean;
183
+ }>;
184
+ sent: number;
185
+ checkCount: number;
186
+ lastCheckedAt: string | null;
187
+ createdAt: string;
188
+ lastError: string | null;
189
+ receivingEnabled: boolean;
190
+ mxOk: boolean;
191
+ receivingVerified: boolean;
192
+ receivingError: string | null;
193
+ }
194
+ export interface DomainRecords {
195
+ domain: Domain;
196
+ records: DnsRecord[];
197
+ }
198
+ export interface CreateDomainParams {
199
+ /** A hostname such as `send.acme.com`. No scheme, no trailing slash. */
200
+ name: string;
201
+ /** Where Amazon SES registers it. Cannot change once the domain holds messages. */
202
+ region: DomainRegion;
203
+ }
204
+ export type TemplateBlock = Record<string, unknown> & {
205
+ type: string;
206
+ id?: string;
207
+ };
208
+ export interface TemplateTag {
209
+ id: string;
210
+ name: string;
211
+ color: TagColor;
212
+ }
213
+ export type TagColor = 'gray' | 'red' | 'orange' | 'amber' | 'green' | 'teal' | 'blue' | 'purple' | 'pink';
214
+ export interface TemplateSummary {
215
+ id: string;
216
+ publicId: string;
217
+ name: string;
218
+ status: 'draft' | 'published';
219
+ blockCount: number;
220
+ updatedAt: string;
221
+ publishedAt: string | null;
222
+ createdAt: string;
223
+ domains: Array<{
224
+ id: string;
225
+ name: string;
226
+ }>;
227
+ tags: TemplateTag[];
228
+ key: string | null;
229
+ project: {
230
+ id: string;
231
+ name: string;
232
+ } | null;
233
+ }
234
+ export interface Template extends TemplateSummary {
235
+ subject: string;
236
+ preheader: string;
237
+ blocks: TemplateBlock[];
238
+ html: string;
239
+ }
240
+ export interface CreateTemplateParams {
241
+ name?: string;
242
+ subject?: string;
243
+ preheader?: string;
244
+ /** See https://sendclipper.com/docs for the block types. Unknown fields are dropped. */
245
+ blocks?: TemplateBlock[];
246
+ /** The domain whose project the template belongs to. */
247
+ projectDomainId?: string;
248
+ /** Send name, unique in its project: `emails.send({ template: key })`. */
249
+ key?: string;
250
+ }
251
+ export interface UpdateTemplateParams {
252
+ name?: string;
253
+ subject?: string;
254
+ preheader?: string;
255
+ blocks?: TemplateBlock[];
256
+ domainIds?: string[];
257
+ projectDomainId?: string | null;
258
+ key?: string | null;
259
+ }
260
+ export interface ListTemplatesParams {
261
+ /** A tag id. */
262
+ tag?: string;
263
+ /** A project (domain) id. */
264
+ project?: string;
265
+ }
266
+ export interface TemplatePreview {
267
+ subject: string;
268
+ preheader: string;
269
+ html: string;
270
+ text: string;
271
+ variables: Array<{
272
+ name: string;
273
+ fallback: string | null;
274
+ value: string;
275
+ provided: boolean;
276
+ }>;
277
+ /** Links whose target a tag would make unsafe. */
278
+ unsafeLinks: string[];
279
+ }
280
+ export interface TemplateAsset {
281
+ id: string;
282
+ publicId: string;
283
+ /** Public URL a mail client can load. */
284
+ url: string;
285
+ mimeType: string;
286
+ bytes: number;
287
+ name: string;
288
+ createdAt: string;
289
+ }
290
+ export interface UploadTemplateAssetParams {
291
+ /** `image/png`, `image/jpeg`, `image/gif` or `image/webp`. */
292
+ mimeType: string;
293
+ /** The file's bytes; a Buffer/Uint8Array is base64-encoded for you. */
294
+ data: Uint8Array | string;
295
+ name?: string;
296
+ }
297
+ export interface Sandbox {
298
+ id: string;
299
+ name: string;
300
+ slug: string;
301
+ /** Mail sent to this address lands in the sandbox. */
302
+ inboxAddress: string;
303
+ inboundLive: boolean;
304
+ projectLabel: string;
305
+ color: string;
306
+ total: number;
307
+ unread: number;
308
+ messageCap: number;
309
+ retentionDays: number;
310
+ lastTrappedAt: string | null;
311
+ createdAt: string;
312
+ }
313
+ export interface CreateSandboxParams {
314
+ name: string;
315
+ projectLabel?: string;
316
+ /** `#rrggbb`. */
317
+ color?: string;
318
+ }
319
+ export type UpdateSandboxParams = Partial<CreateSandboxParams>;
320
+ export interface SandboxCredentials {
321
+ host: string;
322
+ port: number;
323
+ tls: 'required' | 'optional' | 'none';
324
+ maxRecipients: number;
325
+ username: string;
326
+ password: string;
327
+ maxMessageBytes: number;
328
+ retentionDays: number;
329
+ apiEndpoint: string;
330
+ inboxId: string;
331
+ inboxAddress: string;
332
+ inboundDomain: string;
333
+ inboundLive: boolean;
334
+ /** The JSON token is hashed; only its hint can be read back. */
335
+ apiTokenHint: string;
336
+ }
337
+ export interface ResetSandboxCredentials {
338
+ username: string;
339
+ password: string;
340
+ /** The `sc_sbx_…` token. Shown once. */
341
+ apiToken: string;
342
+ }
343
+ export interface SandboxMessageSummary {
344
+ id: string;
345
+ subject: string;
346
+ fromAddress: string;
347
+ fromName: string;
348
+ toAddresses: string[];
349
+ snippet: string;
350
+ sizeBytes: number;
351
+ read: boolean;
352
+ trappedAt: string;
353
+ }
354
+ export interface SandboxMessage extends SandboxMessageSummary {
355
+ ccAddresses: string[];
356
+ /** SMTP envelope, recorded apart from the headers (a Bcc recipient is only here). */
357
+ envelopeFrom: string;
358
+ envelopeTo: string[];
359
+ bodyHtml: string | null;
360
+ /** `null` when the message carried no text/plain part. */
361
+ bodyText: string | null;
362
+ headers: Array<{
363
+ name: string;
364
+ value: string;
365
+ }>;
366
+ transport: string;
367
+ clientIp: string | null;
368
+ hasRaw: boolean;
369
+ }
370
+ export interface ListSandboxMessagesParams {
371
+ search?: string;
372
+ limit?: number;
373
+ }
374
+ export type WebhookEventType = 'email.delivered' | 'email.opened' | 'email.clicked' | 'email.bounced' | 'email.complained' | 'email.failed';
375
+ export interface WebhookEndpoint {
376
+ id: string;
377
+ url: string;
378
+ events: WebhookEventType[];
379
+ active: boolean;
380
+ createdAt: string;
381
+ secretMasked: string;
382
+ secretRotatedAt: string | null;
383
+ previousSecretExpiresAt: string | null;
384
+ successRate: number | null;
385
+ successRateWindowDays: number;
386
+ deliveryCount: number;
387
+ deliveredCount: number;
388
+ }
389
+ export interface WebhookEndpointWithSecret extends WebhookEndpoint {
390
+ /** The full `whsec_…` signing secret. Returned once; store it now. */
391
+ secret: string;
392
+ }
393
+ export interface CreateWebhookParams {
394
+ url: string;
395
+ events: WebhookEventType[];
396
+ /** Accept a plain `http://` URL. Off by default. */
397
+ allowInsecureHttp?: boolean;
398
+ }
399
+ export interface UpdateWebhookParams {
400
+ url?: string;
401
+ events?: WebhookEventType[];
402
+ active?: boolean;
403
+ allowInsecureHttp?: boolean;
404
+ }
405
+ export type WebhookDispatchState = 'pending' | 'delivering' | 'delivered' | 'dead_lettered';
406
+ export interface ListWebhookDispatchesParams {
407
+ /** Default `dead_lettered`. `retrying` = pending or delivering. */
408
+ state?: WebhookDispatchState | 'retrying' | 'all';
409
+ endpointId?: string;
410
+ cursor?: string;
411
+ /** 1–100. */
412
+ limit?: number;
413
+ }
414
+ export interface WebhookDispatch {
415
+ id: string;
416
+ endpointId: string;
417
+ endpointUrl: string;
418
+ /** The `id` the receiver saw in the body. */
419
+ eventId: string;
420
+ event: WebhookEventType;
421
+ state: WebhookDispatchState;
422
+ attempts: number;
423
+ lastStatusCode: number | null;
424
+ lastError: string | null;
425
+ lastAttemptError: string | null;
426
+ firstAttemptAt: string | null;
427
+ lastAttemptAt: string | null;
428
+ nextAttemptAt: string | null;
429
+ createdAt: string;
430
+ replayedAt: string | null;
431
+ replayCount: number;
432
+ }
433
+ export interface ReplayAllParams {
434
+ state?: 'dead_lettered';
435
+ endpointId?: string;
436
+ }
437
+ export interface ReplayAllResult {
438
+ queued: number;
439
+ remaining: number;
440
+ capped: boolean;
441
+ max: number;
442
+ }
443
+ /** What a webhook delivery's body is. */
444
+ export interface WebhookEvent {
445
+ /** Stable for one (email, event): deduplicate on it. */
446
+ id: string;
447
+ event: WebhookEventType;
448
+ createdAt: string;
449
+ data: {
450
+ emailId: string;
451
+ messageId: string;
452
+ to: string;
453
+ domain: string;
454
+ subject: string;
455
+ [field: string]: unknown;
456
+ };
457
+ }
458
+ export type ContactStatus = 'subscribed' | 'unsubscribed' | 'bounced';
459
+ export interface Contact {
460
+ id: string;
461
+ name: string;
462
+ email: string;
463
+ status: ContactStatus;
464
+ audienceId: string | null;
465
+ audienceName: string | null;
466
+ audienceColor: string | null;
467
+ createdAt: string;
468
+ }
469
+ export interface ContactList extends NumberedPage<Contact> {
470
+ totalPages: number;
471
+ totalAll: number;
472
+ }
473
+ export interface CreateContactParams {
474
+ name: string;
475
+ email: string;
476
+ audienceId?: string;
477
+ status?: ContactStatus;
478
+ }
479
+ export interface ListContactsParams {
480
+ audienceId?: string;
481
+ status?: ContactStatus;
482
+ page?: number;
483
+ /** 1–200, default 25. */
484
+ pageSize?: number;
485
+ }
486
+ export interface Audience {
487
+ id: string;
488
+ name: string;
489
+ color: string;
490
+ count: number;
491
+ }
492
+ export interface ImportContactsParams {
493
+ /** CSV or vCard bytes/text. */
494
+ file: Uint8Array | string;
495
+ /** `contacts.csv` / `contacts.vcf`; the extension decides the parser. */
496
+ filename?: string;
497
+ audienceId?: string;
498
+ newAudience?: string;
499
+ createAudiences?: boolean;
500
+ onDuplicate?: 'skip' | 'update';
501
+ /** Column mapping as the dashboard's import preview returns it. */
502
+ mapping?: Record<string, unknown>;
503
+ }
504
+ export type SuppressionReason = 'hard_bounce' | 'soft_bounce' | 'complaint' | 'unsubscribe' | 'manual' | 'provider';
505
+ export interface Suppression {
506
+ id: string;
507
+ email: string;
508
+ reason: SuppressionReason;
509
+ reasonLabel: string;
510
+ reasonDetail: string | null;
511
+ diagnosticCode: string | null;
512
+ /** `marketing` for an unsubscribe, `all` for everything else. */
513
+ scope: 'all' | 'marketing';
514
+ sourceEmailId: string | null;
515
+ sourceMessageId: string | null;
516
+ createdAt: string;
517
+ }
518
+ export interface SuppressionList extends CursorPage<Suppression> {
519
+ counts: {
520
+ total: number;
521
+ byReason: Record<SuppressionReason, number>;
522
+ };
523
+ }
524
+ export interface ListSuppressionsParams {
525
+ /** Address search. */
526
+ q?: string;
527
+ reason?: SuppressionReason;
528
+ cursor?: string;
529
+ /** 1–100. */
530
+ limit?: number;
531
+ }
532
+ export type MailFolder = 'all' | 'inbox' | 'starred' | 'sent' | 'drafts' | 'archive' | 'spam' | 'trash';
533
+ export interface Mailbox {
534
+ id: string;
535
+ address: string;
536
+ displayName: string;
537
+ domain: string;
538
+ domainId: string;
539
+ catchAll: boolean;
540
+ archived: boolean;
541
+ canReceive: boolean;
542
+ canSend: boolean;
543
+ unread: number;
544
+ total: number;
545
+ }
546
+ export interface CreateMailboxParams {
547
+ domainId: string;
548
+ localPart: string;
549
+ displayName?: string;
550
+ color?: string;
551
+ catchAll?: boolean;
552
+ }
553
+ export interface UpdateMailboxParams {
554
+ localPart?: string;
555
+ displayName?: string;
556
+ color?: string;
557
+ catchAll?: boolean;
558
+ archived?: boolean;
559
+ notifyOwner?: boolean;
560
+ embedOrigins?: string[];
561
+ }
562
+ export interface ListMailboxMessagesParams {
563
+ folder?: MailFolder;
564
+ search?: string;
565
+ label?: string;
566
+ /** 1–200. */
567
+ limit?: number;
568
+ cursor?: string;
569
+ }
570
+ export interface MailboxMessageRow {
571
+ id: string;
572
+ folder: string;
573
+ from: string;
574
+ fromName: string;
575
+ to: string;
576
+ cc: string | null;
577
+ bcc: string | null;
578
+ subject: string;
579
+ snippet: string;
580
+ label: string | null;
581
+ unread: boolean;
582
+ starred: boolean;
583
+ receivedAt: string;
584
+ mailboxId: string | null;
585
+ threadId: string | null;
586
+ }
587
+ export interface MailboxMessageList {
588
+ items: MailboxMessageRow[];
589
+ total: number;
590
+ unread: number;
591
+ totalCapped: boolean;
592
+ page: {
593
+ cursor: string | null;
594
+ hasMore: boolean;
595
+ };
596
+ }
597
+ export interface MailboxThreadMessage {
598
+ id: string;
599
+ direction: 'inbound' | 'outbound';
600
+ from: string;
601
+ fromName: string;
602
+ to: string;
603
+ cc: string[] | null;
604
+ subject: string;
605
+ snippet: string;
606
+ bodyText: string | null;
607
+ bodyHtml: string | null;
608
+ bodyExpiredAt: string | null;
609
+ occurredAt: string;
610
+ folder: string | null;
611
+ status: string | null;
612
+ unread: boolean;
613
+ }
614
+ export interface MailboxMessage extends MailboxMessageRow {
615
+ bodyText: string | null;
616
+ bodyHtml: string | null;
617
+ bodyExpiredAt: string | null;
618
+ thread: {
619
+ id: string;
620
+ subject: string;
621
+ messageCount: number;
622
+ lastAt: string;
623
+ participants: string[];
624
+ messages: MailboxThreadMessage[];
625
+ } | null;
626
+ /** Download one with `mailboxes.messages.attachment()`. */
627
+ attachments: Array<{
628
+ id: string;
629
+ filename: string;
630
+ contentType: string;
631
+ sizeBytes: number;
632
+ }>;
633
+ /** SPF/DKIM/DMARC/spam verdicts for received mail; `null` for your own sends. */
634
+ authentication: Record<string, unknown> | null;
635
+ }
636
+ export interface Workspace {
637
+ id: string;
638
+ name: string;
639
+ publicId: string;
640
+ createdAt: string;
641
+ sendingPaused: {
642
+ at: string;
643
+ reason: string;
644
+ message: string;
645
+ } | null;
646
+ postalAddress: string | null;
647
+ [field: string]: unknown;
648
+ }
649
+ export interface ApiKey {
650
+ id: string;
651
+ name: string;
652
+ masked: string;
653
+ prefix: string;
654
+ last4: string;
655
+ permission: 'full' | 'sending' | 'read';
656
+ domainId: string | null;
657
+ domain: string | null;
658
+ createdAt: string;
659
+ lastUsedAt: string | null;
660
+ }
661
+ export {};
662
+ //# sourceMappingURL=types.d.ts.map