shipmail 0.1.20 → 0.1.22
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 +358 -106
- package/dist/index.cjs +188 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +337 -5
- package/dist/index.d.ts +337 -5
- package/dist/index.js +188 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -59,7 +59,7 @@ type StatusResponse = {
|
|
|
59
59
|
};
|
|
60
60
|
declare const DOMAIN_STATUSES: readonly ["pending", "verifying", "verified", "degraded", "failed"];
|
|
61
61
|
type DomainStatus = (typeof DOMAIN_STATUSES)[number];
|
|
62
|
-
declare const MESSAGE_STATUSES: readonly ["queued", "sent", "delivered", "bounced", "complained", "failed"];
|
|
62
|
+
declare const MESSAGE_STATUSES: readonly ["scheduled", "queued", "sent", "delivered", "bounced", "complained", "failed", "cancelled"];
|
|
63
63
|
type MessageStatus = (typeof MESSAGE_STATUSES)[number];
|
|
64
64
|
declare const MESSAGE_SOURCES: readonly ["api", "dashboard", "inbound", "smtp"];
|
|
65
65
|
type MessageSource = (typeof MESSAGE_SOURCES)[number];
|
|
@@ -95,7 +95,7 @@ type CreateDomainParams = {
|
|
|
95
95
|
readonly name: string;
|
|
96
96
|
};
|
|
97
97
|
type UpdateDomainParams = {
|
|
98
|
-
readonly catch_all_mailbox_id
|
|
98
|
+
readonly catch_all_mailbox_id: string | null;
|
|
99
99
|
};
|
|
100
100
|
type ListDomainsParams = PaginationParams;
|
|
101
101
|
type DomainVerificationResult = {
|
|
@@ -167,6 +167,100 @@ declare class Domains extends ApiResource {
|
|
|
167
167
|
register(params: RegisterDomainParams, options?: MethodOptions): Promise<Domain>;
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
+
declare const MAILBOX_IMPORT_STATUSES: readonly ["queued", "running", "paused_throttle", "paused_quota", "completed", "failed", "cancelled", "undo_queued", "undoing", "undone", "undo_failed"];
|
|
171
|
+
type MailboxImportStatus = (typeof MAILBOX_IMPORT_STATUSES)[number];
|
|
172
|
+
declare const MAILBOX_IMPORT_PROVIDERS: readonly ["gmail", "outlook", "yahoo", "aol", "icloud", "fastmail", "zoho", "imap", "takeout", "proton", "tuta", "file"];
|
|
173
|
+
type MailboxImportProvider = (typeof MAILBOX_IMPORT_PROVIDERS)[number];
|
|
174
|
+
declare const MAILBOX_IMPORT_IMAP_PROVIDERS: readonly ["gmail", "yahoo", "aol", "icloud", "fastmail", "zoho", "imap"];
|
|
175
|
+
type MailboxImportImapProvider = (typeof MAILBOX_IMPORT_IMAP_PROVIDERS)[number];
|
|
176
|
+
declare const MAILBOX_IMPORT_FILE_PROVIDERS: readonly ["takeout", "proton", "tuta", "file"];
|
|
177
|
+
type MailboxImportFileProvider = (typeof MAILBOX_IMPORT_FILE_PROVIDERS)[number];
|
|
178
|
+
declare const MAILBOX_IMPORT_FOLDER_STATES: readonly ["pending", "importing", "completed", "failed"];
|
|
179
|
+
type MailboxImportFolderState = (typeof MAILBOX_IMPORT_FOLDER_STATES)[number];
|
|
180
|
+
declare const MAILBOX_IMPORT_RANGES: readonly ["all", "12m", "3m", "1m"];
|
|
181
|
+
type MailboxImportRange = (typeof MAILBOX_IMPORT_RANGES)[number];
|
|
182
|
+
type MailboxImportKind = "imap" | "file";
|
|
183
|
+
type MailboxImportCounts = {
|
|
184
|
+
readonly found: number;
|
|
185
|
+
readonly imported: number;
|
|
186
|
+
readonly undone: number;
|
|
187
|
+
readonly duplicates_skipped: number;
|
|
188
|
+
readonly oversize_skipped: number;
|
|
189
|
+
readonly failed: number;
|
|
190
|
+
readonly contacts_imported: number;
|
|
191
|
+
};
|
|
192
|
+
type MailboxImportBytes = {
|
|
193
|
+
readonly total: number;
|
|
194
|
+
readonly imported: number;
|
|
195
|
+
};
|
|
196
|
+
type MailboxImportFolder = {
|
|
197
|
+
readonly source_folder: string;
|
|
198
|
+
readonly target_folder: string | null;
|
|
199
|
+
readonly role: string | null;
|
|
200
|
+
readonly state: MailboxImportFolderState;
|
|
201
|
+
readonly found: number;
|
|
202
|
+
readonly imported: number;
|
|
203
|
+
readonly duplicates: number;
|
|
204
|
+
readonly oversize: number;
|
|
205
|
+
readonly failed: number;
|
|
206
|
+
};
|
|
207
|
+
type MailboxImport = {
|
|
208
|
+
readonly object: "import";
|
|
209
|
+
readonly id: string;
|
|
210
|
+
readonly mailbox_id: string;
|
|
211
|
+
readonly kind: MailboxImportKind;
|
|
212
|
+
readonly provider: MailboxImportProvider;
|
|
213
|
+
readonly source_address: string | null;
|
|
214
|
+
readonly status: MailboxImportStatus;
|
|
215
|
+
readonly status_detail: string | null;
|
|
216
|
+
readonly error: string | null;
|
|
217
|
+
readonly resume_at: string | null;
|
|
218
|
+
readonly counts: MailboxImportCounts;
|
|
219
|
+
readonly bytes: MailboxImportBytes;
|
|
220
|
+
readonly created_at: string;
|
|
221
|
+
readonly started_at: string | null;
|
|
222
|
+
readonly completed_at: string | null;
|
|
223
|
+
readonly folders?: readonly MailboxImportFolder[] | undefined;
|
|
224
|
+
};
|
|
225
|
+
type MailboxImports = {
|
|
226
|
+
readonly object: "imports";
|
|
227
|
+
readonly mailbox_id: string;
|
|
228
|
+
readonly data: readonly MailboxImport[];
|
|
229
|
+
};
|
|
230
|
+
type MailboxImportImapSource = {
|
|
231
|
+
readonly type: "imap";
|
|
232
|
+
readonly provider: MailboxImportImapProvider;
|
|
233
|
+
readonly email: string;
|
|
234
|
+
readonly password: string;
|
|
235
|
+
readonly host?: string | undefined;
|
|
236
|
+
readonly port?: number | undefined;
|
|
237
|
+
};
|
|
238
|
+
type MailboxImportFileSource = {
|
|
239
|
+
readonly type: "files";
|
|
240
|
+
readonly provider: MailboxImportFileProvider;
|
|
241
|
+
readonly file_ids: readonly string[];
|
|
242
|
+
};
|
|
243
|
+
type MailboxImportOptions = {
|
|
244
|
+
readonly folders?: readonly string[] | null | undefined;
|
|
245
|
+
readonly range?: MailboxImportRange | undefined;
|
|
246
|
+
readonly include_spam?: boolean | undefined;
|
|
247
|
+
readonly include_trash?: boolean | undefined;
|
|
248
|
+
};
|
|
249
|
+
type CreateMailboxImportParams = {
|
|
250
|
+
readonly source: MailboxImportImapSource | MailboxImportFileSource;
|
|
251
|
+
readonly options?: MailboxImportOptions | undefined;
|
|
252
|
+
};
|
|
253
|
+
type CreateImportUploadParams = {
|
|
254
|
+
readonly file_name: string;
|
|
255
|
+
readonly size_bytes: number;
|
|
256
|
+
};
|
|
257
|
+
type ImportUpload = {
|
|
258
|
+
readonly object: "import_upload";
|
|
259
|
+
readonly file_id: string;
|
|
260
|
+
readonly upload_url: string;
|
|
261
|
+
readonly expires_in_seconds: number;
|
|
262
|
+
};
|
|
263
|
+
|
|
170
264
|
type AutoReply = {
|
|
171
265
|
readonly enabled: boolean;
|
|
172
266
|
readonly subject: string | null;
|
|
@@ -181,10 +275,173 @@ type Mailbox = {
|
|
|
181
275
|
readonly address: string;
|
|
182
276
|
readonly display_name: string | null;
|
|
183
277
|
readonly suspended_at: string | null;
|
|
278
|
+
readonly spam_filter_threshold: number;
|
|
184
279
|
readonly auto_reply: AutoReply;
|
|
185
280
|
readonly created_at: string;
|
|
186
281
|
readonly updated_at: string;
|
|
187
282
|
};
|
|
283
|
+
type MailboxFolder = {
|
|
284
|
+
readonly object: "mailbox_folder";
|
|
285
|
+
readonly id: string;
|
|
286
|
+
readonly name: string;
|
|
287
|
+
readonly parent_id: string | null;
|
|
288
|
+
readonly role: string | null;
|
|
289
|
+
readonly kind: "custom" | "system";
|
|
290
|
+
readonly total_emails: number;
|
|
291
|
+
readonly unread_emails: number;
|
|
292
|
+
readonly unread_threads: number;
|
|
293
|
+
readonly sort_order: number;
|
|
294
|
+
};
|
|
295
|
+
type MailboxFolders = {
|
|
296
|
+
readonly object: "mailbox_folders";
|
|
297
|
+
readonly mailbox_id: string;
|
|
298
|
+
readonly address: string;
|
|
299
|
+
readonly data: readonly MailboxFolder[];
|
|
300
|
+
};
|
|
301
|
+
type MailboxIdentity = {
|
|
302
|
+
readonly object: "mailbox_identity";
|
|
303
|
+
readonly id: string;
|
|
304
|
+
readonly name: string;
|
|
305
|
+
readonly email: string;
|
|
306
|
+
};
|
|
307
|
+
type MailboxIdentities = {
|
|
308
|
+
readonly object: "mailbox_identities";
|
|
309
|
+
readonly mailbox_id: string;
|
|
310
|
+
readonly address: string;
|
|
311
|
+
readonly data: readonly MailboxIdentity[];
|
|
312
|
+
};
|
|
313
|
+
type InboxEmailHeader = {
|
|
314
|
+
readonly name: string | null;
|
|
315
|
+
readonly email: string | null;
|
|
316
|
+
};
|
|
317
|
+
type InboxKeyword = "$flagged" | "$seen" | "$draft" | "$answered" | "$forwarded";
|
|
318
|
+
type InboxAttachment = {
|
|
319
|
+
readonly part_id: string;
|
|
320
|
+
readonly blob_id: string;
|
|
321
|
+
readonly name: string | null;
|
|
322
|
+
readonly content_type: string;
|
|
323
|
+
readonly size: number;
|
|
324
|
+
readonly download_path: string;
|
|
325
|
+
};
|
|
326
|
+
type InboxBodyPart = {
|
|
327
|
+
readonly part_id: string;
|
|
328
|
+
readonly type: string;
|
|
329
|
+
};
|
|
330
|
+
type InboxBodyValue = {
|
|
331
|
+
readonly value: string;
|
|
332
|
+
readonly is_encoding_problem: boolean;
|
|
333
|
+
};
|
|
334
|
+
type InboxMessage = {
|
|
335
|
+
readonly object: "inbox_message";
|
|
336
|
+
readonly id: string;
|
|
337
|
+
readonly thread_id: string;
|
|
338
|
+
readonly mailbox_id: string;
|
|
339
|
+
readonly address: string;
|
|
340
|
+
readonly folder_ids: readonly string[];
|
|
341
|
+
readonly keywords: Readonly<Record<string, boolean>>;
|
|
342
|
+
readonly from: readonly InboxEmailHeader[] | null;
|
|
343
|
+
readonly to: readonly InboxEmailHeader[] | null;
|
|
344
|
+
readonly subject: string | null;
|
|
345
|
+
readonly received_at: string;
|
|
346
|
+
readonly preview: string;
|
|
347
|
+
readonly has_attachment: boolean;
|
|
348
|
+
readonly size: number;
|
|
349
|
+
};
|
|
350
|
+
type InboxFullMessage = Omit<InboxMessage, "object"> & {
|
|
351
|
+
readonly object: "inbox_message_full";
|
|
352
|
+
readonly cc: readonly InboxEmailHeader[] | null;
|
|
353
|
+
readonly reply_to: readonly InboxEmailHeader[] | null;
|
|
354
|
+
readonly message_id: readonly string[] | null;
|
|
355
|
+
readonly in_reply_to: readonly string[] | null;
|
|
356
|
+
readonly references: readonly string[] | null;
|
|
357
|
+
readonly body_values: Readonly<Record<string, InboxBodyValue>>;
|
|
358
|
+
readonly text_body: readonly InboxBodyPart[];
|
|
359
|
+
readonly html_body: readonly InboxBodyPart[];
|
|
360
|
+
readonly attachments: readonly InboxAttachment[];
|
|
361
|
+
};
|
|
362
|
+
type InboxMessages = {
|
|
363
|
+
readonly object: "inbox_messages";
|
|
364
|
+
readonly mailbox_id: string;
|
|
365
|
+
readonly address: string;
|
|
366
|
+
readonly data: readonly InboxMessage[];
|
|
367
|
+
readonly pagination: {
|
|
368
|
+
readonly position: number;
|
|
369
|
+
readonly limit: number;
|
|
370
|
+
readonly total: number;
|
|
371
|
+
readonly has_more: boolean;
|
|
372
|
+
readonly next_position: number | null;
|
|
373
|
+
};
|
|
374
|
+
};
|
|
375
|
+
type InboxThread = {
|
|
376
|
+
readonly object: "inbox_thread";
|
|
377
|
+
readonly mailbox_id: string;
|
|
378
|
+
readonly address: string;
|
|
379
|
+
readonly thread_id: string;
|
|
380
|
+
readonly data: readonly InboxFullMessage[];
|
|
381
|
+
};
|
|
382
|
+
type InboxMessageAction = {
|
|
383
|
+
readonly object: "inbox_message_action";
|
|
384
|
+
readonly mailbox_id: string;
|
|
385
|
+
readonly address: string;
|
|
386
|
+
readonly message_id: string;
|
|
387
|
+
readonly ok: true;
|
|
388
|
+
};
|
|
389
|
+
type MailboxRuleMatchMode = "all" | "any";
|
|
390
|
+
type MailboxRuleCondition = {
|
|
391
|
+
readonly type: "from_is" | "from_contains" | "recipient_is" | "plus_tag_is" | "subject_contains";
|
|
392
|
+
readonly value: string;
|
|
393
|
+
} | {
|
|
394
|
+
readonly type: "has_attachment" | "list_unsubscribe_exists";
|
|
395
|
+
} | {
|
|
396
|
+
readonly type: "group";
|
|
397
|
+
readonly match_mode: MailboxRuleMatchMode;
|
|
398
|
+
readonly conditions: readonly MailboxRuleCondition[];
|
|
399
|
+
};
|
|
400
|
+
type MailboxRuleMoveTarget = {
|
|
401
|
+
readonly kind: "system";
|
|
402
|
+
readonly role: "inbox" | "archive" | "junk" | "trash";
|
|
403
|
+
} | {
|
|
404
|
+
readonly kind: "custom";
|
|
405
|
+
readonly folder_id: string;
|
|
406
|
+
};
|
|
407
|
+
type MailboxRuleAction = {
|
|
408
|
+
readonly type: "move";
|
|
409
|
+
readonly target: MailboxRuleMoveTarget;
|
|
410
|
+
} | {
|
|
411
|
+
readonly type: "mark_read";
|
|
412
|
+
} | {
|
|
413
|
+
readonly type: "star";
|
|
414
|
+
} | {
|
|
415
|
+
readonly type: "send_webhook";
|
|
416
|
+
} | {
|
|
417
|
+
readonly type: "ai_draft_reply";
|
|
418
|
+
readonly instructions: string;
|
|
419
|
+
readonly reply_mode: "reply" | "reply_all";
|
|
420
|
+
};
|
|
421
|
+
type MailboxRule = {
|
|
422
|
+
readonly id: string;
|
|
423
|
+
readonly name: string;
|
|
424
|
+
readonly enabled: boolean;
|
|
425
|
+
readonly position: number;
|
|
426
|
+
readonly match_mode: MailboxRuleMatchMode;
|
|
427
|
+
readonly stop: boolean;
|
|
428
|
+
readonly conditions: readonly MailboxRuleCondition[];
|
|
429
|
+
readonly actions: readonly MailboxRuleAction[];
|
|
430
|
+
};
|
|
431
|
+
type MailboxRuleFolder = {
|
|
432
|
+
readonly id: string;
|
|
433
|
+
readonly name: string;
|
|
434
|
+
readonly parent_id: string | null;
|
|
435
|
+
readonly role: string | null;
|
|
436
|
+
readonly kind: "custom" | "system";
|
|
437
|
+
};
|
|
438
|
+
type MailboxRules = {
|
|
439
|
+
readonly object: "mailbox_rules";
|
|
440
|
+
readonly mailbox_id: string;
|
|
441
|
+
readonly address: string;
|
|
442
|
+
readonly rules: readonly MailboxRule[];
|
|
443
|
+
readonly folders: readonly MailboxRuleFolder[];
|
|
444
|
+
};
|
|
188
445
|
type CreateMailboxParams = {
|
|
189
446
|
readonly domain_id: string;
|
|
190
447
|
readonly address: string;
|
|
@@ -193,9 +450,41 @@ type CreateMailboxParams = {
|
|
|
193
450
|
type UpdateMailboxParams = {
|
|
194
451
|
readonly display_name?: string | null | undefined;
|
|
195
452
|
};
|
|
453
|
+
type CreateMailboxFolderParams = {
|
|
454
|
+
readonly name: string;
|
|
455
|
+
readonly parent_id: string | null;
|
|
456
|
+
};
|
|
457
|
+
type UpdateMailboxFolderParams = {
|
|
458
|
+
readonly name: string;
|
|
459
|
+
};
|
|
460
|
+
type ResetMailboxPasswordParams = {
|
|
461
|
+
readonly password: string;
|
|
462
|
+
};
|
|
196
463
|
type ListMailboxesParams = PaginationParams & {
|
|
197
464
|
readonly domain_id?: string | undefined;
|
|
198
465
|
};
|
|
466
|
+
type ListInboxMessagesParams = {
|
|
467
|
+
readonly folder_id?: string | undefined;
|
|
468
|
+
readonly folder_role?: "inbox" | "starred" | "sent" | "drafts" | "archive" | "junk" | "trash" | undefined;
|
|
469
|
+
readonly search_text?: string | undefined;
|
|
470
|
+
readonly position?: number | undefined;
|
|
471
|
+
readonly limit?: number | undefined;
|
|
472
|
+
readonly has_keyword?: InboxKeyword | undefined;
|
|
473
|
+
readonly not_keyword?: InboxKeyword | undefined;
|
|
474
|
+
};
|
|
475
|
+
type DownloadInboxAttachmentParams = {
|
|
476
|
+
readonly blob_id: string;
|
|
477
|
+
readonly name?: string | undefined;
|
|
478
|
+
};
|
|
479
|
+
type UpdateInboxMessageParams = {
|
|
480
|
+
readonly read?: boolean | undefined;
|
|
481
|
+
readonly starred?: boolean | undefined;
|
|
482
|
+
};
|
|
483
|
+
type MoveInboxMessageParams = {
|
|
484
|
+
readonly from_folder_id?: string | undefined;
|
|
485
|
+
readonly target_role?: "inbox" | "archive" | "junk" | "trash" | undefined;
|
|
486
|
+
readonly target_folder_id?: string | undefined;
|
|
487
|
+
};
|
|
199
488
|
type UpdateAutoReplyParams = {
|
|
200
489
|
readonly enabled: boolean;
|
|
201
490
|
readonly subject?: string | null | undefined;
|
|
@@ -203,6 +492,12 @@ type UpdateAutoReplyParams = {
|
|
|
203
492
|
readonly from_date?: string | null | undefined;
|
|
204
493
|
readonly to_date?: string | null | undefined;
|
|
205
494
|
};
|
|
495
|
+
type UpdateSpamFilterParams = {
|
|
496
|
+
readonly threshold: number;
|
|
497
|
+
};
|
|
498
|
+
type UpdateMailboxRulesParams = {
|
|
499
|
+
readonly rules: readonly MailboxRule[];
|
|
500
|
+
};
|
|
206
501
|
|
|
207
502
|
declare class Mailboxes extends ApiResource {
|
|
208
503
|
create(params: CreateMailboxParams, options?: MethodOptions): Promise<Mailbox>;
|
|
@@ -211,7 +506,28 @@ declare class Mailboxes extends ApiResource {
|
|
|
211
506
|
get(id: string, options?: MethodOptions): Promise<Mailbox>;
|
|
212
507
|
update(id: string, params: UpdateMailboxParams, options?: MethodOptions): Promise<Mailbox>;
|
|
213
508
|
delete(id: string, options?: MethodOptions): Promise<void>;
|
|
509
|
+
listFolders(id: string, options?: MethodOptions): Promise<MailboxFolders>;
|
|
510
|
+
createFolder(id: string, params: CreateMailboxFolderParams, options?: MethodOptions): Promise<MailboxFolder>;
|
|
511
|
+
updateFolder(id: string, folderId: string, params: UpdateMailboxFolderParams, options?: MethodOptions): Promise<MailboxFolder>;
|
|
512
|
+
deleteFolder(id: string, folderId: string, options?: MethodOptions): Promise<void>;
|
|
513
|
+
listIdentities(id: string, options?: MethodOptions): Promise<MailboxIdentities>;
|
|
514
|
+
listInboxMessages(id: string, params?: ListInboxMessagesParams, options?: MethodOptions): Promise<InboxMessages>;
|
|
515
|
+
getInboxThread(id: string, threadId: string, options?: MethodOptions): Promise<InboxThread>;
|
|
516
|
+
updateInboxMessage(id: string, messageId: string, params: UpdateInboxMessageParams, options?: MethodOptions): Promise<InboxMessageAction>;
|
|
517
|
+
moveInboxMessage(id: string, messageId: string, params: MoveInboxMessageParams, options?: MethodOptions): Promise<InboxMessageAction>;
|
|
518
|
+
deleteInboxMessage(id: string, messageId: string, options?: MethodOptions): Promise<void>;
|
|
519
|
+
downloadInboxAttachment(id: string, params: DownloadInboxAttachmentParams, options?: MethodOptions): Promise<Uint8Array>;
|
|
520
|
+
resetPassword(id: string, params: ResetMailboxPasswordParams, options?: MethodOptions): Promise<Mailbox>;
|
|
521
|
+
getRules(id: string, options?: MethodOptions): Promise<MailboxRules>;
|
|
522
|
+
updateRules(id: string, params: UpdateMailboxRulesParams, options?: MethodOptions): Promise<MailboxRules>;
|
|
214
523
|
updateAutoReply(id: string, params: UpdateAutoReplyParams, options?: MethodOptions): Promise<Mailbox>;
|
|
524
|
+
updateSpamFilter(id: string, params: UpdateSpamFilterParams, options?: MethodOptions): Promise<Mailbox>;
|
|
525
|
+
createImport(id: string, params: CreateMailboxImportParams, options?: MethodOptions): Promise<MailboxImport>;
|
|
526
|
+
listImports(id: string, options?: MethodOptions): Promise<MailboxImports>;
|
|
527
|
+
getImport(id: string, importId: string, options?: MethodOptions): Promise<MailboxImport>;
|
|
528
|
+
cancelImport(id: string, importId: string, options?: MethodOptions): Promise<MailboxImport>;
|
|
529
|
+
undoImport(id: string, importId: string, options?: MethodOptions): Promise<MailboxImport>;
|
|
530
|
+
createImportUpload(id: string, params: CreateImportUploadParams, options?: MethodOptions): Promise<ImportUpload>;
|
|
215
531
|
}
|
|
216
532
|
|
|
217
533
|
type Message = {
|
|
@@ -240,6 +556,7 @@ type Message = {
|
|
|
240
556
|
}[] | null;
|
|
241
557
|
readonly source: MessageSource;
|
|
242
558
|
readonly status: MessageStatus;
|
|
559
|
+
readonly scheduled_at: string | null;
|
|
243
560
|
readonly created_at: string;
|
|
244
561
|
readonly updated_at: string;
|
|
245
562
|
};
|
|
@@ -261,6 +578,7 @@ type SendMessageParams = {
|
|
|
261
578
|
readonly in_reply_to?: string | undefined;
|
|
262
579
|
readonly references?: readonly string[] | undefined;
|
|
263
580
|
readonly attachments?: readonly Attachment[] | undefined;
|
|
581
|
+
readonly scheduled_at?: string | undefined;
|
|
264
582
|
};
|
|
265
583
|
type ListMessagesParams = PaginationParams & {
|
|
266
584
|
readonly mailbox_id: string;
|
|
@@ -270,6 +588,7 @@ type ReplyToMessageParams = {
|
|
|
270
588
|
readonly text?: string | undefined;
|
|
271
589
|
readonly to: readonly EmailRecipientInput[];
|
|
272
590
|
readonly cc?: readonly EmailRecipientInput[] | undefined;
|
|
591
|
+
readonly scheduled_at?: string | undefined;
|
|
273
592
|
};
|
|
274
593
|
|
|
275
594
|
declare class Messages extends ApiResource {
|
|
@@ -301,6 +620,16 @@ declare class Suppressions extends ApiResource {
|
|
|
301
620
|
remove(email: string, options?: MethodOptions): Promise<void>;
|
|
302
621
|
}
|
|
303
622
|
|
|
623
|
+
type Thread = {
|
|
624
|
+
readonly object: "thread";
|
|
625
|
+
readonly id: string;
|
|
626
|
+
readonly mailbox_id: string;
|
|
627
|
+
readonly subject: string | null;
|
|
628
|
+
readonly message_count: number;
|
|
629
|
+
readonly latest_message: Message;
|
|
630
|
+
readonly created_at: string;
|
|
631
|
+
readonly updated_at: string;
|
|
632
|
+
};
|
|
304
633
|
type ListThreadsParams = PaginationParams & {
|
|
305
634
|
readonly mailbox_id: string;
|
|
306
635
|
};
|
|
@@ -310,11 +639,12 @@ type ReplyToThreadParams = {
|
|
|
310
639
|
readonly text?: string | undefined;
|
|
311
640
|
readonly to?: readonly EmailRecipientInput[] | undefined;
|
|
312
641
|
readonly cc?: readonly EmailRecipientInput[] | undefined;
|
|
642
|
+
readonly scheduled_at?: string | undefined;
|
|
313
643
|
};
|
|
314
644
|
|
|
315
645
|
declare class Threads extends ApiResource {
|
|
316
|
-
list(params: ListThreadsParams, options?: MethodOptions): Promise<PaginatedResponse<
|
|
317
|
-
listAutoPaginating(params: Omit<ListThreadsParams, "cursor">): Page<
|
|
646
|
+
list(params: ListThreadsParams, options?: MethodOptions): Promise<PaginatedResponse<Thread>>;
|
|
647
|
+
listAutoPaginating(params: Omit<ListThreadsParams, "cursor">): Page<Thread>;
|
|
318
648
|
get(id: string, params?: GetThreadParams, options?: MethodOptions): Promise<PaginatedResponse<Message>>;
|
|
319
649
|
reply(id: string, params: ReplyToThreadParams, options?: MethodOptions): Promise<Message>;
|
|
320
650
|
}
|
|
@@ -419,6 +749,8 @@ declare class ShipMailClient {
|
|
|
419
749
|
*/
|
|
420
750
|
constructor(config: string | ShipMailConfig);
|
|
421
751
|
request<T>(options: RequestOptions): Promise<T>;
|
|
752
|
+
requestBytes(options: RequestOptions): Promise<Uint8Array>;
|
|
753
|
+
private requestWithParser;
|
|
422
754
|
private buildUrl;
|
|
423
755
|
}
|
|
424
756
|
|
|
@@ -493,4 +825,4 @@ declare function verifyWebhook(body: string, headers: WebhookHeaders | Headers,
|
|
|
493
825
|
readonly toleranceInSeconds?: number | undefined;
|
|
494
826
|
}): Promise<WebhookEvent>;
|
|
495
827
|
|
|
496
|
-
export { type ApiErrorBody, AuthenticationError, AuthorizationError, ConflictError, ConnectionError, type CreateDomainParams, type CreateMailboxParams, type CreateWebhookParams, DOMAIN_STATUSES, type Domain, type DomainRegistrationInfo, type DomainSearchResult, type DomainStatus, type DomainVerificationResult, type EmailRecipient, type EmailRecipientInput, type ErrorType, type GetThreadParams, InternalServerError, type ListDeliveriesParams, type ListDomainsParams, type ListMailboxesParams, type ListMessagesParams, type ListSuppressionsParams, type ListThreadsParams, type ListWebhooksParams, MESSAGE_SOURCES, MESSAGE_STATUSES, type Mailbox, type Message, type MessageSource, type MessageStatus, type MethodOptions, NotFoundError, Page, type PaginatedResponse, type PaginationParams, QuotaExceededError, RateLimitError, type RegisterDomainParams, type RegistrationContact, type ReplyToMessageParams, type ReplyToThreadParams, type RequestOptions, type RotateSecretResponse, type SearchDomainsParams, type SendMessageParams, ShipMailClient, type ShipMailConfig, ShipMailError, type StatusResponse, type Suppression, type TestWebhookResponse, type UpdateAutoReplyParams, type UpdateDomainParams, type UpdateMailboxParams, type UpdateWebhookParams, ValidationError, WEBHOOK_DELIVERY_STATUSES, WEBHOOK_EVENT_TYPES, type Webhook, type WebhookDelivery, type WebhookDeliveryStatus, type WebhookEvent, type WebhookEventType, WebhookVerificationError, type WebhookWithSecret, ShipMailClient as default, verifyWebhook };
|
|
828
|
+
export { type ApiErrorBody, AuthenticationError, AuthorizationError, ConflictError, ConnectionError, type CreateDomainParams, type CreateMailboxFolderParams, type CreateMailboxParams, type CreateWebhookParams, DOMAIN_STATUSES, type Domain, type DomainRegistrationInfo, type DomainSearchResult, type DomainStatus, type DomainVerificationResult, type DownloadInboxAttachmentParams, type EmailRecipient, type EmailRecipientInput, type ErrorType, type GetThreadParams, type InboxAttachment, type InboxBodyPart, type InboxBodyValue, type InboxEmailHeader, type InboxFullMessage, type InboxKeyword, type InboxMessage, type InboxMessageAction, type InboxMessages, type InboxThread, InternalServerError, type ListDeliveriesParams, type ListDomainsParams, type ListInboxMessagesParams, type ListMailboxesParams, type ListMessagesParams, type ListSuppressionsParams, type ListThreadsParams, type ListWebhooksParams, MESSAGE_SOURCES, MESSAGE_STATUSES, type Mailbox, type MailboxFolder, type MailboxFolders, type MailboxIdentities, type MailboxIdentity, type MailboxRule, type MailboxRuleAction, type MailboxRuleCondition, type MailboxRuleFolder, type MailboxRuleMatchMode, type MailboxRuleMoveTarget, type MailboxRules, type Message, type MessageSource, type MessageStatus, type MethodOptions, type MoveInboxMessageParams, NotFoundError, Page, type PaginatedResponse, type PaginationParams, QuotaExceededError, RateLimitError, type RegisterDomainParams, type RegistrationContact, type ReplyToMessageParams, type ReplyToThreadParams, type RequestOptions, type ResetMailboxPasswordParams, type RotateSecretResponse, type SearchDomainsParams, type SendMessageParams, ShipMailClient, type ShipMailConfig, ShipMailError, type StatusResponse, type Suppression, type TestWebhookResponse, type Thread, type UpdateAutoReplyParams, type UpdateDomainParams, type UpdateInboxMessageParams, type UpdateMailboxFolderParams, type UpdateMailboxParams, type UpdateMailboxRulesParams, type UpdateSpamFilterParams, type UpdateWebhookParams, ValidationError, WEBHOOK_DELIVERY_STATUSES, WEBHOOK_EVENT_TYPES, type Webhook, type WebhookDelivery, type WebhookDeliveryStatus, type WebhookEvent, type WebhookEventType, WebhookVerificationError, type WebhookWithSecret, ShipMailClient as default, verifyWebhook };
|
package/dist/index.js
CHANGED
|
@@ -265,6 +265,123 @@ var Mailboxes = class extends ApiResource {
|
|
|
265
265
|
methodOptions: options
|
|
266
266
|
});
|
|
267
267
|
}
|
|
268
|
+
listFolders(id, options) {
|
|
269
|
+
return this.client.request({
|
|
270
|
+
method: "GET",
|
|
271
|
+
path: `/mailboxes/${encodeURIComponent(id)}/folders`,
|
|
272
|
+
methodOptions: options
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
createFolder(id, params, options) {
|
|
276
|
+
return this.client.request({
|
|
277
|
+
method: "POST",
|
|
278
|
+
path: `/mailboxes/${encodeURIComponent(id)}/folders`,
|
|
279
|
+
body: params,
|
|
280
|
+
methodOptions: options
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
updateFolder(id, folderId, params, options) {
|
|
284
|
+
return this.client.request({
|
|
285
|
+
method: "PATCH",
|
|
286
|
+
path: `/mailboxes/${encodeURIComponent(id)}/folders/${encodeURIComponent(folderId)}`,
|
|
287
|
+
body: params,
|
|
288
|
+
methodOptions: options
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
deleteFolder(id, folderId, options) {
|
|
292
|
+
return this.client.request({
|
|
293
|
+
method: "DELETE",
|
|
294
|
+
path: `/mailboxes/${encodeURIComponent(id)}/folders/${encodeURIComponent(folderId)}`,
|
|
295
|
+
methodOptions: options
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
listIdentities(id, options) {
|
|
299
|
+
return this.client.request({
|
|
300
|
+
method: "GET",
|
|
301
|
+
path: `/mailboxes/${encodeURIComponent(id)}/identities`,
|
|
302
|
+
methodOptions: options
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
listInboxMessages(id, params, options) {
|
|
306
|
+
return this.client.request({
|
|
307
|
+
method: "GET",
|
|
308
|
+
path: `/mailboxes/${encodeURIComponent(id)}/inbox/messages`,
|
|
309
|
+
query: {
|
|
310
|
+
folder_id: params?.folder_id,
|
|
311
|
+
folder_role: params?.folder_role,
|
|
312
|
+
search_text: params?.search_text,
|
|
313
|
+
position: params?.position,
|
|
314
|
+
limit: params?.limit,
|
|
315
|
+
has_keyword: params?.has_keyword,
|
|
316
|
+
not_keyword: params?.not_keyword
|
|
317
|
+
},
|
|
318
|
+
methodOptions: options
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
getInboxThread(id, threadId, options) {
|
|
322
|
+
return this.client.request({
|
|
323
|
+
method: "GET",
|
|
324
|
+
path: `/mailboxes/${encodeURIComponent(id)}/inbox/threads/${encodeURIComponent(threadId)}`,
|
|
325
|
+
methodOptions: options
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
updateInboxMessage(id, messageId, params, options) {
|
|
329
|
+
return this.client.request({
|
|
330
|
+
method: "PATCH",
|
|
331
|
+
path: `/mailboxes/${encodeURIComponent(id)}/inbox/messages/${encodeURIComponent(messageId)}`,
|
|
332
|
+
body: params,
|
|
333
|
+
methodOptions: options
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
moveInboxMessage(id, messageId, params, options) {
|
|
337
|
+
return this.client.request({
|
|
338
|
+
method: "POST",
|
|
339
|
+
path: `/mailboxes/${encodeURIComponent(id)}/inbox/messages/${encodeURIComponent(messageId)}/move`,
|
|
340
|
+
body: params,
|
|
341
|
+
methodOptions: options
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
deleteInboxMessage(id, messageId, options) {
|
|
345
|
+
return this.client.request({
|
|
346
|
+
method: "DELETE",
|
|
347
|
+
path: `/mailboxes/${encodeURIComponent(id)}/inbox/messages/${encodeURIComponent(messageId)}`,
|
|
348
|
+
methodOptions: options
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
downloadInboxAttachment(id, params, options) {
|
|
352
|
+
return this.client.requestBytes({
|
|
353
|
+
method: "GET",
|
|
354
|
+
path: `/mailboxes/${encodeURIComponent(id)}/inbox/attachments`,
|
|
355
|
+
query: {
|
|
356
|
+
blob_id: params.blob_id,
|
|
357
|
+
name: params.name
|
|
358
|
+
},
|
|
359
|
+
methodOptions: options
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
resetPassword(id, params, options) {
|
|
363
|
+
return this.client.request({
|
|
364
|
+
method: "PATCH",
|
|
365
|
+
path: `/mailboxes/${encodeURIComponent(id)}/password`,
|
|
366
|
+
body: params,
|
|
367
|
+
methodOptions: options
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
getRules(id, options) {
|
|
371
|
+
return this.client.request({
|
|
372
|
+
method: "GET",
|
|
373
|
+
path: `/mailboxes/${encodeURIComponent(id)}/rules`,
|
|
374
|
+
methodOptions: options
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
updateRules(id, params, options) {
|
|
378
|
+
return this.client.request({
|
|
379
|
+
method: "PUT",
|
|
380
|
+
path: `/mailboxes/${encodeURIComponent(id)}/rules`,
|
|
381
|
+
body: params,
|
|
382
|
+
methodOptions: options
|
|
383
|
+
});
|
|
384
|
+
}
|
|
268
385
|
updateAutoReply(id, params, options) {
|
|
269
386
|
return this.client.request({
|
|
270
387
|
method: "PATCH",
|
|
@@ -273,6 +390,58 @@ var Mailboxes = class extends ApiResource {
|
|
|
273
390
|
methodOptions: options
|
|
274
391
|
});
|
|
275
392
|
}
|
|
393
|
+
updateSpamFilter(id, params, options) {
|
|
394
|
+
return this.client.request({
|
|
395
|
+
method: "PATCH",
|
|
396
|
+
path: `/mailboxes/${encodeURIComponent(id)}/spam-filter`,
|
|
397
|
+
body: params,
|
|
398
|
+
methodOptions: options
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
createImport(id, params, options) {
|
|
402
|
+
return this.client.request({
|
|
403
|
+
method: "POST",
|
|
404
|
+
path: `/mailboxes/${encodeURIComponent(id)}/imports`,
|
|
405
|
+
body: params,
|
|
406
|
+
methodOptions: options
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
listImports(id, options) {
|
|
410
|
+
return this.client.request({
|
|
411
|
+
method: "GET",
|
|
412
|
+
path: `/mailboxes/${encodeURIComponent(id)}/imports`,
|
|
413
|
+
methodOptions: options
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
getImport(id, importId, options) {
|
|
417
|
+
return this.client.request({
|
|
418
|
+
method: "GET",
|
|
419
|
+
path: `/mailboxes/${encodeURIComponent(id)}/imports/${encodeURIComponent(importId)}`,
|
|
420
|
+
methodOptions: options
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
cancelImport(id, importId, options) {
|
|
424
|
+
return this.client.request({
|
|
425
|
+
method: "POST",
|
|
426
|
+
path: `/mailboxes/${encodeURIComponent(id)}/imports/${encodeURIComponent(importId)}/cancel`,
|
|
427
|
+
methodOptions: options
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
undoImport(id, importId, options) {
|
|
431
|
+
return this.client.request({
|
|
432
|
+
method: "POST",
|
|
433
|
+
path: `/mailboxes/${encodeURIComponent(id)}/imports/${encodeURIComponent(importId)}/undo`,
|
|
434
|
+
methodOptions: options
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
createImportUpload(id, params, options) {
|
|
438
|
+
return this.client.request({
|
|
439
|
+
method: "POST",
|
|
440
|
+
path: `/mailboxes/${encodeURIComponent(id)}/imports/files`,
|
|
441
|
+
body: params,
|
|
442
|
+
methodOptions: options
|
|
443
|
+
});
|
|
444
|
+
}
|
|
276
445
|
};
|
|
277
446
|
|
|
278
447
|
// src/resources/messages.ts
|
|
@@ -488,7 +657,7 @@ var Webhooks = class extends ApiResource {
|
|
|
488
657
|
};
|
|
489
658
|
|
|
490
659
|
// src/version.ts
|
|
491
|
-
var VERSION = "0.1.
|
|
660
|
+
var VERSION = "0.1.22";
|
|
492
661
|
|
|
493
662
|
// src/client.ts
|
|
494
663
|
var DEFAULT_BASE_URL = "https://shipmail.to/api/v1";
|
|
@@ -542,6 +711,19 @@ var ShipMailClient = class {
|
|
|
542
711
|
this.status = new Status(this);
|
|
543
712
|
}
|
|
544
713
|
async request(options) {
|
|
714
|
+
return this.requestWithParser(options, "application/json", async (response) => {
|
|
715
|
+
if (response.status === 204) {
|
|
716
|
+
return void 0;
|
|
717
|
+
}
|
|
718
|
+
return await response.json();
|
|
719
|
+
});
|
|
720
|
+
}
|
|
721
|
+
async requestBytes(options) {
|
|
722
|
+
return this.requestWithParser(options, "application/octet-stream", async (response) => {
|
|
723
|
+
return new Uint8Array(await response.arrayBuffer());
|
|
724
|
+
});
|
|
725
|
+
}
|
|
726
|
+
async requestWithParser(options, accept, parseSuccess) {
|
|
545
727
|
const url = this.buildUrl(options.path, options.query);
|
|
546
728
|
let lastError;
|
|
547
729
|
const methodOpts = options.methodOptions;
|
|
@@ -557,7 +739,7 @@ var ShipMailClient = class {
|
|
|
557
739
|
...this.defaultHeaders,
|
|
558
740
|
Authorization: `Bearer ${this.apiKey}`,
|
|
559
741
|
"User-Agent": `shipmail-node/${VERSION}`,
|
|
560
|
-
Accept:
|
|
742
|
+
Accept: accept,
|
|
561
743
|
...methodOpts?.headers
|
|
562
744
|
};
|
|
563
745
|
if (methodOpts?.idempotencyKey) {
|
|
@@ -583,11 +765,8 @@ var ShipMailClient = class {
|
|
|
583
765
|
if (attempt < this.maxRetries) continue;
|
|
584
766
|
throw lastError;
|
|
585
767
|
}
|
|
586
|
-
if (response.status === 204) {
|
|
587
|
-
return void 0;
|
|
588
|
-
}
|
|
589
768
|
if (response.ok) {
|
|
590
|
-
return
|
|
769
|
+
return parseSuccess(response);
|
|
591
770
|
}
|
|
592
771
|
let errorBody;
|
|
593
772
|
try {
|
|
@@ -639,12 +818,14 @@ var WEBHOOK_EVENT_TYPES = [
|
|
|
639
818
|
];
|
|
640
819
|
var DOMAIN_STATUSES = ["pending", "verifying", "verified", "degraded", "failed"];
|
|
641
820
|
var MESSAGE_STATUSES = [
|
|
821
|
+
"scheduled",
|
|
642
822
|
"queued",
|
|
643
823
|
"sent",
|
|
644
824
|
"delivered",
|
|
645
825
|
"bounced",
|
|
646
826
|
"complained",
|
|
647
|
-
"failed"
|
|
827
|
+
"failed",
|
|
828
|
+
"cancelled"
|
|
648
829
|
];
|
|
649
830
|
var MESSAGE_SOURCES = ["api", "dashboard", "inbound", "smtp"];
|
|
650
831
|
var WEBHOOK_DELIVERY_STATUSES = ["pending", "delivered", "failed"];
|