postbound 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.
- package/LICENSE +21 -0
- package/README.md +1022 -2
- package/dist/index.cjs +411 -0
- package/dist/index.d.cts +614 -0
- package/dist/index.d.mts +614 -0
- package/dist/index.mjs +410 -0
- package/package.json +67 -3
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,614 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export interface RequestOptions {
|
|
3
|
+
headers?: HeadersInit;
|
|
4
|
+
signal?: AbortSignal;
|
|
5
|
+
}
|
|
6
|
+
export interface IdempotentRequestOptions extends RequestOptions {
|
|
7
|
+
idempotencyKey?: string;
|
|
8
|
+
}
|
|
9
|
+
export type PaginationOptions = {
|
|
10
|
+
limit?: number;
|
|
11
|
+
} & ({
|
|
12
|
+
after?: string;
|
|
13
|
+
before?: never;
|
|
14
|
+
} | {
|
|
15
|
+
before?: string;
|
|
16
|
+
after?: never;
|
|
17
|
+
});
|
|
18
|
+
export interface List<T> {
|
|
19
|
+
object: 'list';
|
|
20
|
+
has_more: boolean;
|
|
21
|
+
data: T[];
|
|
22
|
+
}
|
|
23
|
+
export interface DeletedResource<Object extends string> {
|
|
24
|
+
object: Object;
|
|
25
|
+
id: string;
|
|
26
|
+
deleted: true;
|
|
27
|
+
}
|
|
28
|
+
export interface ResourceReference<Object extends string> {
|
|
29
|
+
object: Object;
|
|
30
|
+
id: string;
|
|
31
|
+
}
|
|
32
|
+
export type RequireAtLeastOne<T> = { [K in keyof T]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<keyof T, K>>>; }[keyof T];
|
|
33
|
+
type ErrorCode = 'validation_error' | 'missing_required_field' | 'invalid_parameter' | 'invalid_from_address' | 'invalid_scheduled_date' | 'invalid_attachment' | 'invalid_json' | 'invalid_state' | 'invalid_idempotent_request' | 'concurrent_idempotent_requests' | 'invalid_download_link' | 'missing_api_key' | 'invalid_api_key' | 'restricted_api_key' | 'forbidden' | 'not_found' | 'method_not_allowed' | 'domain_already_exists' | 'contact_already_exists' | 'verification_conflict' | 'domain_verification_unavailable' | 'rate_limit_exceeded' | 'internal_server_error' | 'application_error';
|
|
34
|
+
type ErrorResponse = {
|
|
35
|
+
message: string;
|
|
36
|
+
statusCode: number | null;
|
|
37
|
+
name: ErrorCode;
|
|
38
|
+
request_id?: string;
|
|
39
|
+
};
|
|
40
|
+
type Response<T> = ({
|
|
41
|
+
data: T;
|
|
42
|
+
error: null;
|
|
43
|
+
} | {
|
|
44
|
+
error: ErrorResponse;
|
|
45
|
+
data: null;
|
|
46
|
+
}) & {
|
|
47
|
+
headers: Record<string, string> | null;
|
|
48
|
+
};
|
|
49
|
+
type Tag = {
|
|
50
|
+
name: string;
|
|
51
|
+
value: string;
|
|
52
|
+
};
|
|
53
|
+
export type ApiKeyPermission = 'full_access' | 'sending_access';
|
|
54
|
+
export interface CreateApiKeyOptions {
|
|
55
|
+
name: string;
|
|
56
|
+
permission?: ApiKeyPermission;
|
|
57
|
+
domainId?: string;
|
|
58
|
+
}
|
|
59
|
+
export interface CreateApiKeyResponseSuccess {
|
|
60
|
+
id: string;
|
|
61
|
+
token: string;
|
|
62
|
+
}
|
|
63
|
+
export type CreateApiKeyResponse = Response<CreateApiKeyResponseSuccess>;
|
|
64
|
+
export type ListApiKeysOptions = PaginationOptions;
|
|
65
|
+
export interface ApiKey {
|
|
66
|
+
id: string;
|
|
67
|
+
name: string;
|
|
68
|
+
permission: ApiKeyPermission;
|
|
69
|
+
domain_id: string | null;
|
|
70
|
+
token_prefix: string;
|
|
71
|
+
last_used_at: string | null;
|
|
72
|
+
created_at: string;
|
|
73
|
+
}
|
|
74
|
+
export type ListApiKeysResponseSuccess = List<ApiKey>;
|
|
75
|
+
export type ListApiKeysResponse = Response<ListApiKeysResponseSuccess>;
|
|
76
|
+
export type RemoveApiKeyResponseSuccess = Record<string, never>;
|
|
77
|
+
export type RemoveApiKeyResponse = Response<RemoveApiKeyResponseSuccess>;
|
|
78
|
+
export interface Audience {
|
|
79
|
+
object: 'audience';
|
|
80
|
+
id: string;
|
|
81
|
+
name: string;
|
|
82
|
+
created_at: string;
|
|
83
|
+
}
|
|
84
|
+
export interface CreateAudienceOptions {
|
|
85
|
+
name: string;
|
|
86
|
+
}
|
|
87
|
+
export interface CreateAudienceResponseSuccess {
|
|
88
|
+
object: 'audience';
|
|
89
|
+
id: string;
|
|
90
|
+
name: string;
|
|
91
|
+
}
|
|
92
|
+
export type CreateAudienceResponse = Response<CreateAudienceResponseSuccess>;
|
|
93
|
+
export type GetAudienceResponseSuccess = Audience;
|
|
94
|
+
export type GetAudienceResponse = Response<GetAudienceResponseSuccess>;
|
|
95
|
+
export type ListAudiencesOptions = PaginationOptions;
|
|
96
|
+
export interface AudienceListItem {
|
|
97
|
+
id: string;
|
|
98
|
+
name: string;
|
|
99
|
+
created_at: string;
|
|
100
|
+
}
|
|
101
|
+
export type ListAudiencesResponseSuccess = List<AudienceListItem>;
|
|
102
|
+
export type ListAudiencesResponse = Response<ListAudiencesResponseSuccess>;
|
|
103
|
+
export type RemoveAudiencesResponseSuccess = DeletedResource<'audience'>;
|
|
104
|
+
export type RemoveAudiencesResponse = Response<RemoveAudiencesResponseSuccess>;
|
|
105
|
+
export type EmailEvent = 'queued' | 'scheduled' | 'sent' | 'delivered' | 'delivery_delayed' | 'bounced' | 'complained' | 'opened' | 'clicked' | 'failed' | 'canceled';
|
|
106
|
+
export interface Attachment {
|
|
107
|
+
content?: string | Uint8Array | ArrayBuffer;
|
|
108
|
+
filename?: string;
|
|
109
|
+
path?: string;
|
|
110
|
+
contentType?: string;
|
|
111
|
+
contentId?: string;
|
|
112
|
+
}
|
|
113
|
+
export interface EmailApiAttachment {
|
|
114
|
+
content?: string;
|
|
115
|
+
filename?: string;
|
|
116
|
+
path?: string;
|
|
117
|
+
content_type?: string;
|
|
118
|
+
content_id?: string;
|
|
119
|
+
}
|
|
120
|
+
export interface CreateEmailBaseOptions {
|
|
121
|
+
from: string;
|
|
122
|
+
to: string | string[];
|
|
123
|
+
subject: string;
|
|
124
|
+
cc?: string | string[];
|
|
125
|
+
bcc?: string | string[];
|
|
126
|
+
replyTo?: string | string[];
|
|
127
|
+
headers?: Record<string, string>;
|
|
128
|
+
tags?: Tag[];
|
|
129
|
+
attachments?: Attachment[];
|
|
130
|
+
scheduledAt?: string;
|
|
131
|
+
}
|
|
132
|
+
export type EmailContentOptions = RequireAtLeastOne<{
|
|
133
|
+
react: React.ReactNode;
|
|
134
|
+
html: string;
|
|
135
|
+
text: string;
|
|
136
|
+
}>;
|
|
137
|
+
export type CreateEmailOptions = CreateEmailBaseOptions & EmailContentOptions;
|
|
138
|
+
export interface EmailApiOptions {
|
|
139
|
+
from: string;
|
|
140
|
+
to: string | string[];
|
|
141
|
+
subject: string;
|
|
142
|
+
html?: string;
|
|
143
|
+
text?: string;
|
|
144
|
+
cc?: string | string[];
|
|
145
|
+
bcc?: string | string[];
|
|
146
|
+
reply_to?: string | string[];
|
|
147
|
+
headers?: Record<string, string>;
|
|
148
|
+
tags?: Tag[];
|
|
149
|
+
attachments?: EmailApiAttachment[];
|
|
150
|
+
scheduled_at?: string;
|
|
151
|
+
}
|
|
152
|
+
export type CreateEmailRequestOptions = IdempotentRequestOptions;
|
|
153
|
+
export interface CreateEmailResponseSuccess {
|
|
154
|
+
id: string;
|
|
155
|
+
}
|
|
156
|
+
export type CreateEmailResponse = Response<CreateEmailResponseSuccess>;
|
|
157
|
+
export interface EmailEventRecord {
|
|
158
|
+
type: EmailEvent;
|
|
159
|
+
occurred_at: string;
|
|
160
|
+
metadata: Record<string, string>;
|
|
161
|
+
}
|
|
162
|
+
export interface GetEmailResponseSuccess {
|
|
163
|
+
object: 'email';
|
|
164
|
+
id: string;
|
|
165
|
+
to: string[];
|
|
166
|
+
from: string;
|
|
167
|
+
created_at: string;
|
|
168
|
+
subject: string;
|
|
169
|
+
html: string | null;
|
|
170
|
+
text: string | null;
|
|
171
|
+
bcc: string[] | null;
|
|
172
|
+
cc: string[] | null;
|
|
173
|
+
reply_to: string[] | null;
|
|
174
|
+
last_event: EmailEvent;
|
|
175
|
+
scheduled_at: string | null;
|
|
176
|
+
tags: Tag[] | null;
|
|
177
|
+
events: EmailEventRecord[];
|
|
178
|
+
}
|
|
179
|
+
export type GetEmailResponse = Response<GetEmailResponseSuccess>;
|
|
180
|
+
export type ListEmailsOptions = PaginationOptions & {
|
|
181
|
+
status?: EmailEvent;
|
|
182
|
+
q?: string;
|
|
183
|
+
};
|
|
184
|
+
export interface EmailListItem {
|
|
185
|
+
id: string;
|
|
186
|
+
to: string[];
|
|
187
|
+
from: string;
|
|
188
|
+
created_at: string;
|
|
189
|
+
subject: string;
|
|
190
|
+
bcc: string[] | null;
|
|
191
|
+
cc: string[] | null;
|
|
192
|
+
reply_to: string[] | null;
|
|
193
|
+
last_event: EmailEvent;
|
|
194
|
+
scheduled_at: string | null;
|
|
195
|
+
}
|
|
196
|
+
export type ListEmailsResponseSuccess = List<EmailListItem>;
|
|
197
|
+
export type ListEmailsResponse = Response<ListEmailsResponseSuccess>;
|
|
198
|
+
export interface UpdateEmailOptions {
|
|
199
|
+
id: string;
|
|
200
|
+
scheduledAt: string;
|
|
201
|
+
}
|
|
202
|
+
export type UpdateEmailResponseSuccess = ResourceReference<'email'>;
|
|
203
|
+
export type UpdateEmailResponse = Response<UpdateEmailResponseSuccess>;
|
|
204
|
+
export type CancelEmailResponseSuccess = ResourceReference<'email'>;
|
|
205
|
+
export type CancelEmailResponse = Response<CancelEmailResponseSuccess>;
|
|
206
|
+
export type BatchEmailOptions = Omit<CreateEmailBaseOptions, 'attachments' | 'scheduledAt'> & EmailContentOptions;
|
|
207
|
+
export type CreateBatchOptions = BatchEmailOptions[];
|
|
208
|
+
export interface CreateBatchResponseSuccess {
|
|
209
|
+
data: {
|
|
210
|
+
id: string;
|
|
211
|
+
}[];
|
|
212
|
+
}
|
|
213
|
+
export type CreateBatchResponse = Response<CreateBatchResponseSuccess>;
|
|
214
|
+
export type ContactReference = {
|
|
215
|
+
audienceId: string;
|
|
216
|
+
} & ({
|
|
217
|
+
id: string;
|
|
218
|
+
email?: never;
|
|
219
|
+
} | {
|
|
220
|
+
email: string;
|
|
221
|
+
id?: never;
|
|
222
|
+
});
|
|
223
|
+
export interface Contact {
|
|
224
|
+
object: 'contact';
|
|
225
|
+
id: string;
|
|
226
|
+
email: string;
|
|
227
|
+
first_name: string;
|
|
228
|
+
last_name: string;
|
|
229
|
+
created_at: string;
|
|
230
|
+
unsubscribed: boolean;
|
|
231
|
+
}
|
|
232
|
+
export interface CreateContactOptions {
|
|
233
|
+
audienceId: string;
|
|
234
|
+
email: string;
|
|
235
|
+
firstName?: string;
|
|
236
|
+
lastName?: string;
|
|
237
|
+
unsubscribed?: boolean;
|
|
238
|
+
}
|
|
239
|
+
export type CreateContactResponseSuccess = ResourceReference<'contact'>;
|
|
240
|
+
export type CreateContactResponse = Response<CreateContactResponseSuccess>;
|
|
241
|
+
export type GetContactOptions = ContactReference;
|
|
242
|
+
export type GetContactResponseSuccess = Contact;
|
|
243
|
+
export type GetContactResponse = Response<GetContactResponseSuccess>;
|
|
244
|
+
export type ListContactsOptions = PaginationOptions & {
|
|
245
|
+
audienceId: string;
|
|
246
|
+
};
|
|
247
|
+
export interface ContactListItem {
|
|
248
|
+
id: string;
|
|
249
|
+
email: string;
|
|
250
|
+
first_name: string;
|
|
251
|
+
last_name: string;
|
|
252
|
+
created_at: string;
|
|
253
|
+
unsubscribed: boolean;
|
|
254
|
+
}
|
|
255
|
+
export type ListContactsResponseSuccess = List<ContactListItem>;
|
|
256
|
+
export type ListContactsResponse = Response<ListContactsResponseSuccess>;
|
|
257
|
+
export type UpdateContactOptions = ContactReference & {
|
|
258
|
+
firstName?: string;
|
|
259
|
+
lastName?: string;
|
|
260
|
+
unsubscribed?: boolean;
|
|
261
|
+
};
|
|
262
|
+
export type UpdateContactResponseSuccess = ResourceReference<'contact'>;
|
|
263
|
+
export type UpdateContactResponse = Response<UpdateContactResponseSuccess>;
|
|
264
|
+
export type RemoveContactOptions = ContactReference;
|
|
265
|
+
export interface RemoveContactResponseSuccess {
|
|
266
|
+
object: 'contact';
|
|
267
|
+
contact: string;
|
|
268
|
+
deleted: true;
|
|
269
|
+
}
|
|
270
|
+
export type RemoveContactResponse = Response<RemoveContactResponseSuccess>;
|
|
271
|
+
export type DomainStatus = 'not_started' | 'pending' | 'verified' | 'failed';
|
|
272
|
+
export type DomainTls = 'opportunistic' | 'enforced';
|
|
273
|
+
export type DomainCapability = 'enabled' | 'disabled';
|
|
274
|
+
export interface DomainCapabilities {
|
|
275
|
+
sending: DomainCapability;
|
|
276
|
+
receiving: DomainCapability;
|
|
277
|
+
}
|
|
278
|
+
export interface DomainRecord {
|
|
279
|
+
record: 'Ownership' | 'DKIM' | 'SPF' | 'Receiving';
|
|
280
|
+
name: string;
|
|
281
|
+
type: 'TXT' | 'MX';
|
|
282
|
+
ttl: string;
|
|
283
|
+
status: DomainStatus;
|
|
284
|
+
value: string;
|
|
285
|
+
priority?: number;
|
|
286
|
+
}
|
|
287
|
+
export interface Domain {
|
|
288
|
+
object: 'domain';
|
|
289
|
+
id: string;
|
|
290
|
+
name: string;
|
|
291
|
+
status: DomainStatus;
|
|
292
|
+
created_at: string;
|
|
293
|
+
region: string;
|
|
294
|
+
custom_return_path: string;
|
|
295
|
+
open_tracking: boolean;
|
|
296
|
+
click_tracking: boolean;
|
|
297
|
+
tls: DomainTls;
|
|
298
|
+
capabilities: DomainCapabilities;
|
|
299
|
+
records: DomainRecord[];
|
|
300
|
+
}
|
|
301
|
+
export interface CreateDomainOptions {
|
|
302
|
+
name: string;
|
|
303
|
+
region?: string;
|
|
304
|
+
customReturnPath?: string;
|
|
305
|
+
}
|
|
306
|
+
export type CreateDomainResponseSuccess = Domain;
|
|
307
|
+
export type CreateDomainResponse = Response<CreateDomainResponseSuccess>;
|
|
308
|
+
export type GetDomainResponseSuccess = Domain;
|
|
309
|
+
export type GetDomainResponse = Response<GetDomainResponseSuccess>;
|
|
310
|
+
export type ListDomainsOptions = PaginationOptions;
|
|
311
|
+
export interface DomainListItem {
|
|
312
|
+
id: string;
|
|
313
|
+
name: string;
|
|
314
|
+
status: DomainStatus;
|
|
315
|
+
created_at: string;
|
|
316
|
+
region: string;
|
|
317
|
+
}
|
|
318
|
+
export type ListDomainsResponseSuccess = List<DomainListItem>;
|
|
319
|
+
export type ListDomainsResponse = Response<ListDomainsResponseSuccess>;
|
|
320
|
+
export interface UpdateDomainOptions {
|
|
321
|
+
id: string;
|
|
322
|
+
openTracking?: boolean;
|
|
323
|
+
clickTracking?: boolean;
|
|
324
|
+
tls?: DomainTls;
|
|
325
|
+
capabilities?: Partial<DomainCapabilities>;
|
|
326
|
+
}
|
|
327
|
+
export type UpdateDomainResponseSuccess = ResourceReference<'domain'>;
|
|
328
|
+
export type UpdateDomainResponse = Response<UpdateDomainResponseSuccess>;
|
|
329
|
+
export type VerifyDomainResponseSuccess = ResourceReference<'domain'>;
|
|
330
|
+
export type VerifyDomainResponse = Response<VerifyDomainResponseSuccess>;
|
|
331
|
+
export type RemoveDomainResponseSuccess = DeletedResource<'domain'>;
|
|
332
|
+
export type RemoveDomainResponse = Response<RemoveDomainResponseSuccess>;
|
|
333
|
+
export type HtmlFormat = 'data_uri' | 'cid';
|
|
334
|
+
export type AuthenticationResult = 'pass' | 'fail' | 'gray' | 'processing_failed' | 'unknown';
|
|
335
|
+
export interface ReceivedEmailAuthentication {
|
|
336
|
+
spf: AuthenticationResult;
|
|
337
|
+
dkim: AuthenticationResult;
|
|
338
|
+
dmarc: AuthenticationResult;
|
|
339
|
+
}
|
|
340
|
+
export interface ReceivedAttachmentSummary {
|
|
341
|
+
id: string;
|
|
342
|
+
filename: string;
|
|
343
|
+
content_type: string;
|
|
344
|
+
content_disposition: string | null;
|
|
345
|
+
content_id: string | null;
|
|
346
|
+
size: number;
|
|
347
|
+
}
|
|
348
|
+
export interface SignedDownload {
|
|
349
|
+
download_url: string;
|
|
350
|
+
expires_at: string;
|
|
351
|
+
}
|
|
352
|
+
export interface GetReceivingEmailOptions {
|
|
353
|
+
html_format?: HtmlFormat;
|
|
354
|
+
}
|
|
355
|
+
export interface GetReceivingEmailResponseSuccess {
|
|
356
|
+
object: 'email';
|
|
357
|
+
id: string;
|
|
358
|
+
to: string[];
|
|
359
|
+
from: string;
|
|
360
|
+
created_at: string;
|
|
361
|
+
subject: string;
|
|
362
|
+
html: string | null;
|
|
363
|
+
html_format: HtmlFormat;
|
|
364
|
+
text: string | null;
|
|
365
|
+
headers: Record<string, string>;
|
|
366
|
+
bcc: string[] | null;
|
|
367
|
+
cc: string[] | null;
|
|
368
|
+
reply_to: string[] | null;
|
|
369
|
+
received_for: string[];
|
|
370
|
+
authentication: ReceivedEmailAuthentication;
|
|
371
|
+
message_id: string;
|
|
372
|
+
raw: SignedDownload;
|
|
373
|
+
attachments: ReceivedAttachmentSummary[];
|
|
374
|
+
}
|
|
375
|
+
export type GetReceivingEmailResponse = Response<GetReceivingEmailResponseSuccess>;
|
|
376
|
+
export type ListReceivingEmailsOptions = PaginationOptions;
|
|
377
|
+
export interface ReceivedEmailListItem {
|
|
378
|
+
id: string;
|
|
379
|
+
to: string[];
|
|
380
|
+
from: string;
|
|
381
|
+
subject: string;
|
|
382
|
+
created_at: string;
|
|
383
|
+
message_id: string;
|
|
384
|
+
attachments_count: number;
|
|
385
|
+
}
|
|
386
|
+
export type ListReceivingEmailsResponseSuccess = List<ReceivedEmailListItem>;
|
|
387
|
+
export type ListReceivingEmailsResponse = Response<ListReceivingEmailsResponseSuccess>;
|
|
388
|
+
export interface ReceivedAttachment extends ReceivedAttachmentSummary, SignedDownload {}
|
|
389
|
+
export interface GetAttachmentOptions {
|
|
390
|
+
emailId: string;
|
|
391
|
+
id: string;
|
|
392
|
+
}
|
|
393
|
+
export interface GetAttachmentResponseSuccess extends ReceivedAttachment {
|
|
394
|
+
object: 'attachment';
|
|
395
|
+
}
|
|
396
|
+
export type GetAttachmentResponse = Response<GetAttachmentResponseSuccess>;
|
|
397
|
+
export type ListAttachmentsOptions = PaginationOptions & {
|
|
398
|
+
emailId: string;
|
|
399
|
+
};
|
|
400
|
+
export type ListAttachmentsResponseSuccess = List<ReceivedAttachment>;
|
|
401
|
+
export type ListAttachmentsResponse = Response<ListAttachmentsResponseSuccess>;
|
|
402
|
+
declare class ApiKeys {
|
|
403
|
+
private readonly postbound;
|
|
404
|
+
constructor(postbound: Postbound);
|
|
405
|
+
create(payload: CreateApiKeyOptions, requestOptions?: IdempotentRequestOptions): Promise<CreateApiKeyResponse>;
|
|
406
|
+
list(options?: ListApiKeysOptions, requestOptions?: RequestOptions): Promise<ListApiKeysResponse>;
|
|
407
|
+
remove(id: string, requestOptions?: RequestOptions): Promise<RemoveApiKeyResponse>;
|
|
408
|
+
}
|
|
409
|
+
declare class Audiences {
|
|
410
|
+
private readonly postbound;
|
|
411
|
+
constructor(postbound: Postbound);
|
|
412
|
+
create(payload: CreateAudienceOptions, requestOptions?: IdempotentRequestOptions): Promise<CreateAudienceResponse>;
|
|
413
|
+
get(id: string, requestOptions?: RequestOptions): Promise<GetAudienceResponse>;
|
|
414
|
+
list(options?: ListAudiencesOptions, requestOptions?: RequestOptions): Promise<ListAudiencesResponse>;
|
|
415
|
+
remove(id: string, requestOptions?: RequestOptions): Promise<RemoveAudiencesResponse>;
|
|
416
|
+
}
|
|
417
|
+
declare class Batch {
|
|
418
|
+
private readonly postbound;
|
|
419
|
+
constructor(postbound: Postbound);
|
|
420
|
+
send(payload: CreateBatchOptions, requestOptions?: IdempotentRequestOptions): Promise<CreateBatchResponse>;
|
|
421
|
+
create(payload: CreateBatchOptions, requestOptions?: IdempotentRequestOptions): Promise<CreateBatchResponse>;
|
|
422
|
+
}
|
|
423
|
+
declare class Contacts {
|
|
424
|
+
private readonly postbound;
|
|
425
|
+
constructor(postbound: Postbound);
|
|
426
|
+
create(payload: CreateContactOptions, requestOptions?: IdempotentRequestOptions): Promise<CreateContactResponse>;
|
|
427
|
+
get(options: GetContactOptions, requestOptions?: RequestOptions): Promise<GetContactResponse>;
|
|
428
|
+
list(options: ListContactsOptions, requestOptions?: RequestOptions): Promise<ListContactsResponse>;
|
|
429
|
+
update(options: UpdateContactOptions, requestOptions?: RequestOptions): Promise<UpdateContactResponse>;
|
|
430
|
+
remove(options: RemoveContactOptions, requestOptions?: RequestOptions): Promise<RemoveContactResponse>;
|
|
431
|
+
private withContactPath;
|
|
432
|
+
}
|
|
433
|
+
declare class Domains {
|
|
434
|
+
private readonly postbound;
|
|
435
|
+
constructor(postbound: Postbound);
|
|
436
|
+
create(payload: CreateDomainOptions, requestOptions?: IdempotentRequestOptions): Promise<CreateDomainResponse>;
|
|
437
|
+
get(id: string, requestOptions?: RequestOptions): Promise<GetDomainResponse>;
|
|
438
|
+
list(options?: ListDomainsOptions, requestOptions?: RequestOptions): Promise<ListDomainsResponse>;
|
|
439
|
+
update(payload: UpdateDomainOptions, requestOptions?: RequestOptions): Promise<UpdateDomainResponse>;
|
|
440
|
+
verify(id: string, requestOptions?: IdempotentRequestOptions): Promise<VerifyDomainResponse>;
|
|
441
|
+
remove(id: string, requestOptions?: RequestOptions): Promise<RemoveDomainResponse>;
|
|
442
|
+
}
|
|
443
|
+
declare class ReceivingAttachments {
|
|
444
|
+
private readonly postbound;
|
|
445
|
+
constructor(postbound: Postbound);
|
|
446
|
+
get(options: GetAttachmentOptions, requestOptions?: RequestOptions): Promise<GetAttachmentResponse>;
|
|
447
|
+
list(options: ListAttachmentsOptions, requestOptions?: RequestOptions): Promise<ListAttachmentsResponse>;
|
|
448
|
+
}
|
|
449
|
+
declare class Receiving {
|
|
450
|
+
private readonly postbound;
|
|
451
|
+
readonly attachments: ReceivingAttachments;
|
|
452
|
+
constructor(postbound: Postbound);
|
|
453
|
+
get(id: string, options?: GetReceivingEmailOptions, requestOptions?: RequestOptions): Promise<GetReceivingEmailResponse>;
|
|
454
|
+
list(options?: ListReceivingEmailsOptions, requestOptions?: RequestOptions): Promise<ListReceivingEmailsResponse>;
|
|
455
|
+
}
|
|
456
|
+
declare class Emails {
|
|
457
|
+
private readonly postbound;
|
|
458
|
+
readonly receiving: Receiving;
|
|
459
|
+
constructor(postbound: Postbound);
|
|
460
|
+
send(payload: CreateEmailOptions, requestOptions?: CreateEmailRequestOptions): Promise<CreateEmailResponse>;
|
|
461
|
+
create(payload: CreateEmailOptions, requestOptions?: CreateEmailRequestOptions): Promise<CreateEmailResponse>;
|
|
462
|
+
get(id: string, requestOptions?: RequestOptions): Promise<GetEmailResponse>;
|
|
463
|
+
list(options?: ListEmailsOptions, requestOptions?: RequestOptions): Promise<ListEmailsResponse>;
|
|
464
|
+
update(payload: UpdateEmailOptions, requestOptions?: RequestOptions): Promise<UpdateEmailResponse>;
|
|
465
|
+
cancel(id: string, requestOptions?: RequestOptions): Promise<CancelEmailResponse>;
|
|
466
|
+
}
|
|
467
|
+
export type EmailWebhookEvent = 'email.sent' | 'email.delivered' | 'email.delivery_delayed' | 'email.bounced' | 'email.complained' | 'email.opened' | 'email.clicked' | 'email.failed';
|
|
468
|
+
export type DomainWebhookEvent = 'domain.verified' | 'domain.failed';
|
|
469
|
+
export type WebhookEvent = EmailWebhookEvent | DomainWebhookEvent | 'email.received';
|
|
470
|
+
export interface EmailEventData {
|
|
471
|
+
email_id: string;
|
|
472
|
+
from: string;
|
|
473
|
+
to: string[];
|
|
474
|
+
subject: string;
|
|
475
|
+
tags: Tag[];
|
|
476
|
+
created_at: string;
|
|
477
|
+
metadata?: Record<string, string>;
|
|
478
|
+
}
|
|
479
|
+
export interface EmailEventPayload<Type extends EmailWebhookEvent> {
|
|
480
|
+
type: Type;
|
|
481
|
+
created_at: string;
|
|
482
|
+
data: EmailEventData;
|
|
483
|
+
}
|
|
484
|
+
export interface ReceivedEmailEventAttachment {
|
|
485
|
+
id: string;
|
|
486
|
+
filename: string;
|
|
487
|
+
content_type: string;
|
|
488
|
+
content_disposition: string | null;
|
|
489
|
+
content_id: string | null;
|
|
490
|
+
}
|
|
491
|
+
export interface EmailReceivedEventPayload {
|
|
492
|
+
type: 'email.received';
|
|
493
|
+
created_at: string;
|
|
494
|
+
data: {
|
|
495
|
+
email_id: string;
|
|
496
|
+
created_at: string;
|
|
497
|
+
from: string;
|
|
498
|
+
to: string[];
|
|
499
|
+
cc: string[];
|
|
500
|
+
bcc: string[];
|
|
501
|
+
received_for: string[];
|
|
502
|
+
message_id: string;
|
|
503
|
+
subject: string;
|
|
504
|
+
attachments: ReceivedEmailEventAttachment[];
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
export interface DomainEventPayload<Type extends DomainWebhookEvent> {
|
|
508
|
+
type: Type;
|
|
509
|
+
created_at: string;
|
|
510
|
+
data: {
|
|
511
|
+
domain_id: string;
|
|
512
|
+
name: string;
|
|
513
|
+
status: string;
|
|
514
|
+
region: string;
|
|
515
|
+
};
|
|
516
|
+
}
|
|
517
|
+
export interface WebhookTestEventPayload {
|
|
518
|
+
type: 'webhook.test';
|
|
519
|
+
created_at: string;
|
|
520
|
+
data: {
|
|
521
|
+
message: string;
|
|
522
|
+
};
|
|
523
|
+
}
|
|
524
|
+
export type WebhookEventPayload = EmailEventPayload<'email.sent'> | EmailEventPayload<'email.delivered'> | EmailEventPayload<'email.delivery_delayed'> | EmailEventPayload<'email.bounced'> | EmailEventPayload<'email.complained'> | EmailEventPayload<'email.opened'> | EmailEventPayload<'email.clicked'> | EmailEventPayload<'email.failed'> | EmailReceivedEventPayload | DomainEventPayload<'domain.verified'> | DomainEventPayload<'domain.failed'> | WebhookTestEventPayload;
|
|
525
|
+
export type WebhookType = 'http' | 'discord' | 'teams';
|
|
526
|
+
export type WebhookDeliveryStatus = 'success' | 'failed';
|
|
527
|
+
export interface Webhook {
|
|
528
|
+
id: string;
|
|
529
|
+
type: WebhookType;
|
|
530
|
+
url: string;
|
|
531
|
+
events: WebhookEvent[];
|
|
532
|
+
enabled: boolean;
|
|
533
|
+
created_at: string;
|
|
534
|
+
last_delivery_status: WebhookDeliveryStatus | null;
|
|
535
|
+
}
|
|
536
|
+
export interface WebhookWithSigningSecret extends Webhook {
|
|
537
|
+
signing_secret?: string;
|
|
538
|
+
}
|
|
539
|
+
export interface CreateWebhookOptions {
|
|
540
|
+
type?: WebhookType;
|
|
541
|
+
url: string;
|
|
542
|
+
events: WebhookEvent[];
|
|
543
|
+
enabled?: boolean;
|
|
544
|
+
}
|
|
545
|
+
export type CreateWebhookResponseSuccess = WebhookWithSigningSecret;
|
|
546
|
+
export type CreateWebhookResponse = Response<CreateWebhookResponseSuccess>;
|
|
547
|
+
export type GetWebhookResponseSuccess = WebhookWithSigningSecret;
|
|
548
|
+
export type GetWebhookResponse = Response<GetWebhookResponseSuccess>;
|
|
549
|
+
export type ListWebhooksOptions = PaginationOptions;
|
|
550
|
+
export type ListWebhooksResponseSuccess = List<Webhook>;
|
|
551
|
+
export type ListWebhooksResponse = Response<ListWebhooksResponseSuccess>;
|
|
552
|
+
export interface UpdateWebhookOptions {
|
|
553
|
+
url?: string;
|
|
554
|
+
events?: WebhookEvent[];
|
|
555
|
+
enabled?: boolean;
|
|
556
|
+
}
|
|
557
|
+
export type UpdateWebhookResponseSuccess = Webhook;
|
|
558
|
+
export type UpdateWebhookResponse = Response<UpdateWebhookResponseSuccess>;
|
|
559
|
+
export type RemoveWebhookResponseSuccess = DeletedResource<'webhook'>;
|
|
560
|
+
export type RemoveWebhookResponse = Response<RemoveWebhookResponseSuccess>;
|
|
561
|
+
export interface TestWebhookResponseSuccess {
|
|
562
|
+
object: 'webhook_test';
|
|
563
|
+
success: boolean;
|
|
564
|
+
status_code: number | null;
|
|
565
|
+
error: string | null;
|
|
566
|
+
}
|
|
567
|
+
export type TestWebhookResponse = Response<TestWebhookResponseSuccess>;
|
|
568
|
+
export interface VerifyWebhookOptions {
|
|
569
|
+
payload: string;
|
|
570
|
+
headers: {
|
|
571
|
+
id: string;
|
|
572
|
+
timestamp: string;
|
|
573
|
+
signature: string;
|
|
574
|
+
};
|
|
575
|
+
webhookSecret: string;
|
|
576
|
+
}
|
|
577
|
+
declare class Webhooks {
|
|
578
|
+
private readonly postbound;
|
|
579
|
+
constructor(postbound: Postbound);
|
|
580
|
+
create(payload: CreateWebhookOptions, requestOptions?: IdempotentRequestOptions): Promise<CreateWebhookResponse>;
|
|
581
|
+
get(id: string, requestOptions?: RequestOptions): Promise<GetWebhookResponse>;
|
|
582
|
+
list(options?: ListWebhooksOptions, requestOptions?: RequestOptions): Promise<ListWebhooksResponse>;
|
|
583
|
+
update(id: string, payload: UpdateWebhookOptions, requestOptions?: RequestOptions): Promise<UpdateWebhookResponse>;
|
|
584
|
+
remove(id: string, requestOptions?: RequestOptions): Promise<RemoveWebhookResponse>;
|
|
585
|
+
test(id: string, requestOptions?: IdempotentRequestOptions): Promise<TestWebhookResponse>;
|
|
586
|
+
verify(options: VerifyWebhookOptions): WebhookEventPayload;
|
|
587
|
+
}
|
|
588
|
+
interface PostboundOptions {
|
|
589
|
+
baseUrl?: string;
|
|
590
|
+
userAgent?: string;
|
|
591
|
+
}
|
|
592
|
+
export declare class Postbound {
|
|
593
|
+
readonly key: string;
|
|
594
|
+
readonly baseUrl: string;
|
|
595
|
+
readonly userAgent: string;
|
|
596
|
+
private readonly debug;
|
|
597
|
+
private readonly headers;
|
|
598
|
+
readonly apiKeys: ApiKeys;
|
|
599
|
+
readonly audiences: Audiences;
|
|
600
|
+
readonly batch: Batch;
|
|
601
|
+
readonly contacts: Contacts;
|
|
602
|
+
readonly domains: Domains;
|
|
603
|
+
readonly emails: Emails;
|
|
604
|
+
readonly webhooks: Webhooks;
|
|
605
|
+
constructor(key?: string, options?: PostboundOptions);
|
|
606
|
+
get<T>(path: string, options?: RequestOptions): Promise<Response<T>>;
|
|
607
|
+
post<T>(path: string, body?: unknown, options?: IdempotentRequestOptions): Promise<Response<T>>;
|
|
608
|
+
patch<T>(path: string, body: unknown, options?: RequestOptions): Promise<Response<T>>;
|
|
609
|
+
delete<T>(path: string, options?: RequestOptions): Promise<Response<T>>;
|
|
610
|
+
private send;
|
|
611
|
+
private execute;
|
|
612
|
+
private fail;
|
|
613
|
+
}
|
|
614
|
+
export type { ErrorCode, ErrorResponse, PostboundOptions, Response, Tag };
|