shipmail 0.5.6 → 0.5.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -882,7 +882,10 @@ type OutboundHeader = {
882
882
  type MessageMetadata = Readonly<Record<string, string | number | boolean | null>>;
883
883
  type SendMessageParams = {
884
884
  readonly mailbox_id?: string | undefined;
885
- /** Sending mailbox: `hello@example.com` or `Acme Support <hello@example.com>`. */
885
+ /**
886
+ * Sending mailbox: `hello@example.com` or `Acme Support <hello@example.com>`.
887
+ * For a transactional sender, pass the bare sender address. Shipmail adds its name and Reply-To.
888
+ */
886
889
  readonly from?: string | undefined;
887
890
  readonly to: readonly EmailRecipientInput[];
888
891
  readonly cc?: readonly EmailRecipientInput[] | undefined;
@@ -1286,6 +1289,22 @@ type InboxReplyDraft = {
1286
1289
  }[];
1287
1290
  readonly created_at: string;
1288
1291
  };
1292
+ type InboxDraftRecipient = {
1293
+ readonly address: string;
1294
+ readonly name: string | null;
1295
+ };
1296
+ type InboxDraft = {
1297
+ readonly object: "inbox_draft";
1298
+ /** Inbox message ID of the saved draft. Read it with `getInboxMessage`. */
1299
+ readonly id: string;
1300
+ readonly mailbox_id: string;
1301
+ readonly from: InboxDraftRecipient;
1302
+ readonly to: readonly InboxDraftRecipient[];
1303
+ readonly cc: readonly InboxDraftRecipient[];
1304
+ readonly bcc: readonly InboxDraftRecipient[];
1305
+ readonly subject: string;
1306
+ readonly created_at: string;
1307
+ };
1289
1308
  type InboxReplyDraftSend = {
1290
1309
  readonly object: "inbox_reply_draft_send";
1291
1310
  readonly draft_id: string;
@@ -1430,6 +1449,14 @@ type ListInboxThreadsParams = {
1430
1449
  readonly cursor?: string | undefined;
1431
1450
  readonly limit?: number | undefined;
1432
1451
  };
1452
+ type CreateInboxDraftParams = {
1453
+ readonly to: readonly EmailRecipientInput[];
1454
+ readonly cc?: readonly EmailRecipientInput[] | undefined;
1455
+ readonly bcc?: readonly EmailRecipientInput[] | undefined;
1456
+ readonly subject?: string | undefined;
1457
+ readonly text?: string | undefined;
1458
+ readonly html?: string | undefined;
1459
+ };
1433
1460
  type CreateInboxReplyDraftParams = {
1434
1461
  readonly text?: string | undefined;
1435
1462
  readonly html?: string | undefined;
@@ -1529,6 +1556,8 @@ declare class Mailboxes extends ApiResource {
1529
1556
  listInboxThreads(id: string, params?: ListInboxThreadsParams, options?: MethodOptions): Promise<InboxThreads>;
1530
1557
  getInboxThread(id: string, threadId: string, options?: MethodOptions): Promise<InboxThread>;
1531
1558
  updateInboxThreadAttention(id: string, threadId: string, params: UpdateInboxThreadAttentionParams, options?: MethodOptions): Promise<InboxThreadAttentionResult>;
1559
+ /** Saves a new message to the mailbox's Drafts folder. It is never sent by this call. */
1560
+ createInboxDraft(id: string, params: CreateInboxDraftParams, options?: MethodOptions): Promise<InboxDraft>;
1532
1561
  createInboxReplyDraft(id: string, threadId: string, params: CreateInboxReplyDraftParams, options?: MethodOptions): Promise<InboxReplyDraft>;
1533
1562
  sendInboxReplyDraft(id: string, threadId: string, draftId: string, options?: MethodOptions): Promise<InboxReplyDraftSend>;
1534
1563
  replyToInboxMessage(id: string, messageId: string, params: ReplyToMessageParams, options?: MethodOptions): Promise<Message>;
@@ -2419,4 +2448,4 @@ declare function verifyWebhook(body: string, headers: WebhookHeaders | Headers,
2419
2448
  readonly toleranceInSeconds?: number | undefined;
2420
2449
  }): Promise<WebhookEvent>;
2421
2450
 
2422
- export { type AddSubscriberParams, type AddSubscribersBatchParams, type AddSubscribersBatchResult, type ApiErrorBody, type Audience, type AudienceFeed, AuthenticationError, AuthorizationError, type Automation, type AutomationAction, type AutomationCondition, type AutomationDefinition, type AutomationRun, type AutomationRunStatus, type AutomationRunSummary, type AutomationStatus, type AutomationTrigger, type BookingPage, CONFERENCING_PROVIDER_IDS, type CalendarAvailability, type CalendarAvailabilityParams, type CalendarAvailabilitySlot, type CalendarEvent, type CalendarEventPrivacy, type CalendarEventStatus, type CalendarFreeBusyStatus, type CalendarInvitationLanguage, type CapabilitiesResponse, type CapabilityResourceConstraints, type ConferencingProviderId, ConflictError, ConnectionError, type ConsumePartnerMailboxCredentialGrantParams, type CreateAudienceParams, type CreateAutomationParams, type CreateBookingPageParams, type CreateCalendarEventParams, type CreateDomainParams, type CreateInboxReplyDraftParams, type CreateMailboxAppPasswordParams, type CreateMailboxFolderParams, type CreateMailboxParams, type CreateNewsletterFromChangelogParams, type CreateNewsletterParams, type CreatePartnerOrganizationParams, type CreateReplyScanParams, type CreateWebhookParams, type CreatedMailboxAppPassword, type CreatedPartnerOrganization, DOMAIN_STATUSES, type DataMode, type DeleteCalendarEventParams, type Domain, type DomainDnsRecord, type DomainDnsRecordKey, type DomainDnsRecordSet, type DomainDnsRecordStatus, type DomainRegistrationInfo, type DomainSearchResult, type DomainStatus, type DomainVerificationResult, type DownloadInboxAttachmentParams, type EmailAuthVerdict, type EmailAuthenticationResults, type EmailRecipient, type EmailRecipientInput, type ErrorType, type GetCalendarEventParams, type GetThreadParams, type InboxAttachment, type InboxBodyPart, type InboxBodyValue, type InboxEmailHeader, type InboxFullMessage, type InboxKeyword, type InboxMessage, type InboxMessageAction, type InboxMessages, type InboxReplyDraft, type InboxReplyDraftSend, type InboxThread, type InboxThreadAttentionResult, type InboxThreadAttentionState, type InboxThreadSummary, type InboxThreads, type InjectSandboxInboundParams, InternalServerError, type ListAudiencesParams, type ListAutomationsResponse, type ListBookingPagesParams, type ListCalendarEventsParams, type ListDeliveriesParams, type ListDomainsParams, type ListInboxMessagesParams, type ListInboxThreadsParams, type ListMailboxesParams, type ListMembersParams, type ListMessageAnalyticsParams, type ListMessagesParams, type ListNewsletterAssetsParams, type ListNewsletterDomainsParams, type ListNewsletterSenderIdentitiesParams, type ListNewslettersParams, type ListReplyScanResultsParams, type ListScheduledMessagesParams, type ListSubscribersParams, type ListSuppressionsParams, type ListThreadsParams, type ListWebhooksParams, MESSAGE_SOURCES, MESSAGE_STATUSES, type Mailbox, type MailboxAppPassword, type MailboxAppPasswordList, type MailboxAppPasswordPurpose, type MailboxAppPasswordState, type MailboxDeliveryDestination, type MailboxDeliveryRouting, type MailboxExport, type MailboxExportErrorCode, type MailboxExportStatus, type MailboxFolder, type MailboxFolders, type MailboxIdentities, type MailboxIdentity, type MailboxRule, type MailboxRuleAction, type MailboxRuleCondition, type MailboxRuleFolder, type MailboxRuleMatchMode, type MailboxRuleMoveTarget, type MailboxRules, type Member, type MemberRole, type MergeFields, type Message, type MessageAnalytics, type MessageAnalyticsPage, type MessageMetadata, type MessageRuleDisposition, type MessageSource, type MessageStatus, type MethodOptions, type MoveInboxMessageParams, type Newsletter, type NewsletterArchiveVisibility, type NewsletterAsset, type NewsletterAssetContentType, type NewsletterAssetKind, type NewsletterAssetListResponse, type NewsletterAssetStorageUsage, type NewsletterAssetUpload, type NewsletterBlock, type NewsletterButtonAlign, type NewsletterCalloutVariant, type NewsletterChangelogEntry, type NewsletterChangelogMedia, type NewsletterChangelogTone, type NewsletterColumnContent, type NewsletterColumnImageFit, type NewsletterColumnRatio, type NewsletterCountedUrl, type NewsletterDomain, type NewsletterDomainRecordStatus, type NewsletterDomainStatus, type NewsletterPreflight, type NewsletterPreflightItem, type NewsletterPreflightItemStatus, type NewsletterPreflightStatus, type NewsletterPreview, type NewsletterSenderIdentity, type NewsletterStatus, type NewsletterStylingMode, type NewsletterTestSend, type NewsletterTestSendStatus, type NewsletterUrlBreakdown, type NewsletterUrlSource, NotFoundError, type OneTimeSecretMethodOptions, type OutboundHeader, Page, type PaginatedResponse, type PaginationParams, type PartnerDataClassification, type PartnerMailboxCredential, type PartnerMailboxCredentialGrant, type PartnerMailboxCredentialGrantList, type PartnerOrganization, type PartnerOrganizationList, type PartnerOrganizationStatus, type PartnerOwnershipInvitation, type PartnerUsage, type PrepareNewsletterAssetUploadParams, type PrepareStagedAttachmentUploadParams, QuotaExceededError, RateLimitError, ReconciliationRequiredError, type Recurrence, type RecurrenceFrequency, type RecurrenceNDay, type RegisterDomainParams, type RegisterNewsletterAssetFromUrlParams, type RegistrationContact, type Reminder, type ReplyScan, type ReplyScanCandidate, type ReplyScanResults, type ReplyScanStatus, type ReplyToMessageParams, type ReplyToThreadParams, type RequestOptions, type ResetMailboxPasswordParams, type RotateSecretResponse, type SandboxOutcome, type ScheduleNewsletterParams, type ScheduledMessage, type ScheduledMessageAttachment, type ScheduledMessageList, type ScheduledMessageRecipient, type ScheduledMessageUploadedAttachment, type SearchDomainsParams, type SendMessageParams, type SendNewsletterTestParams, ShipmailClient, type ShipmailConfig, ShipmailError, type StageAttachmentParams, type StagedAttachment, type StagedAttachmentUpload, type StatusResponse, type Subscriber, type SubscriberOutcome, type SubscriberResult, type SubscriberStatus, type Suppression, type TestWebhookResponse, type Thread, type UpdateAudienceFeedParams, type UpdateAudienceParams, type UpdateAutoReplyParams, type UpdateAutomationParams, type UpdateBookingPageParams, type UpdateCalendarEventParams, type UpdateDomainParams, type UpdateInboxMessageParams, type UpdateInboxThreadAttentionParams, type UpdateMailboxDeliveryRoutingParams, type UpdateMailboxFolderParams, type UpdateMailboxParams, type UpdateMailboxRulesParams, type UpdateNewsletterParams, type UpdatePartnerOrganizationParams, type UpdateScheduledMessageParams, type UpdateSubscriberParams, type UpdateWebhookParams, type UploadNewsletterAssetParams, ValidationError, WEBHOOK_DELIVERY_EVENT_TYPES, WEBHOOK_DELIVERY_STATUSES, WEBHOOK_EVENT_TYPES, type Webhook, type WebhookDelivery, type WebhookDeliveryDetail, type WebhookDeliveryEventType, type WebhookDeliveryStatus, type WebhookEvent, type WebhookEventType, WebhookVerificationError, type WebhookWithSecret, type Weekday, ShipmailClient as default, verifyWebhook };
2451
+ export { type AddSubscriberParams, type AddSubscribersBatchParams, type AddSubscribersBatchResult, type ApiErrorBody, type Audience, type AudienceFeed, AuthenticationError, AuthorizationError, type Automation, type AutomationAction, type AutomationCondition, type AutomationDefinition, type AutomationRun, type AutomationRunStatus, type AutomationRunSummary, type AutomationStatus, type AutomationTrigger, type BookingPage, CONFERENCING_PROVIDER_IDS, type CalendarAvailability, type CalendarAvailabilityParams, type CalendarAvailabilitySlot, type CalendarEvent, type CalendarEventPrivacy, type CalendarEventStatus, type CalendarFreeBusyStatus, type CalendarInvitationLanguage, type CapabilitiesResponse, type CapabilityResourceConstraints, type ConferencingProviderId, ConflictError, ConnectionError, type ConsumePartnerMailboxCredentialGrantParams, type CreateAudienceParams, type CreateAutomationParams, type CreateBookingPageParams, type CreateCalendarEventParams, type CreateDomainParams, type CreateInboxDraftParams, type CreateInboxReplyDraftParams, type CreateMailboxAppPasswordParams, type CreateMailboxFolderParams, type CreateMailboxParams, type CreateNewsletterFromChangelogParams, type CreateNewsletterParams, type CreatePartnerOrganizationParams, type CreateReplyScanParams, type CreateWebhookParams, type CreatedMailboxAppPassword, type CreatedPartnerOrganization, DOMAIN_STATUSES, type DataMode, type DeleteCalendarEventParams, type Domain, type DomainDnsRecord, type DomainDnsRecordKey, type DomainDnsRecordSet, type DomainDnsRecordStatus, type DomainRegistrationInfo, type DomainSearchResult, type DomainStatus, type DomainVerificationResult, type DownloadInboxAttachmentParams, type EmailAuthVerdict, type EmailAuthenticationResults, type EmailRecipient, type EmailRecipientInput, type ErrorType, type GetCalendarEventParams, type GetThreadParams, type InboxAttachment, type InboxBodyPart, type InboxBodyValue, type InboxDraft, type InboxDraftRecipient, type InboxEmailHeader, type InboxFullMessage, type InboxKeyword, type InboxMessage, type InboxMessageAction, type InboxMessages, type InboxReplyDraft, type InboxReplyDraftSend, type InboxThread, type InboxThreadAttentionResult, type InboxThreadAttentionState, type InboxThreadSummary, type InboxThreads, type InjectSandboxInboundParams, InternalServerError, type ListAudiencesParams, type ListAutomationsResponse, type ListBookingPagesParams, type ListCalendarEventsParams, type ListDeliveriesParams, type ListDomainsParams, type ListInboxMessagesParams, type ListInboxThreadsParams, type ListMailboxesParams, type ListMembersParams, type ListMessageAnalyticsParams, type ListMessagesParams, type ListNewsletterAssetsParams, type ListNewsletterDomainsParams, type ListNewsletterSenderIdentitiesParams, type ListNewslettersParams, type ListReplyScanResultsParams, type ListScheduledMessagesParams, type ListSubscribersParams, type ListSuppressionsParams, type ListThreadsParams, type ListWebhooksParams, MESSAGE_SOURCES, MESSAGE_STATUSES, type Mailbox, type MailboxAppPassword, type MailboxAppPasswordList, type MailboxAppPasswordPurpose, type MailboxAppPasswordState, type MailboxDeliveryDestination, type MailboxDeliveryRouting, type MailboxExport, type MailboxExportErrorCode, type MailboxExportStatus, type MailboxFolder, type MailboxFolders, type MailboxIdentities, type MailboxIdentity, type MailboxRule, type MailboxRuleAction, type MailboxRuleCondition, type MailboxRuleFolder, type MailboxRuleMatchMode, type MailboxRuleMoveTarget, type MailboxRules, type Member, type MemberRole, type MergeFields, type Message, type MessageAnalytics, type MessageAnalyticsPage, type MessageMetadata, type MessageRuleDisposition, type MessageSource, type MessageStatus, type MethodOptions, type MoveInboxMessageParams, type Newsletter, type NewsletterArchiveVisibility, type NewsletterAsset, type NewsletterAssetContentType, type NewsletterAssetKind, type NewsletterAssetListResponse, type NewsletterAssetStorageUsage, type NewsletterAssetUpload, type NewsletterBlock, type NewsletterButtonAlign, type NewsletterCalloutVariant, type NewsletterChangelogEntry, type NewsletterChangelogMedia, type NewsletterChangelogTone, type NewsletterColumnContent, type NewsletterColumnImageFit, type NewsletterColumnRatio, type NewsletterCountedUrl, type NewsletterDomain, type NewsletterDomainRecordStatus, type NewsletterDomainStatus, type NewsletterPreflight, type NewsletterPreflightItem, type NewsletterPreflightItemStatus, type NewsletterPreflightStatus, type NewsletterPreview, type NewsletterSenderIdentity, type NewsletterStatus, type NewsletterStylingMode, type NewsletterTestSend, type NewsletterTestSendStatus, type NewsletterUrlBreakdown, type NewsletterUrlSource, NotFoundError, type OneTimeSecretMethodOptions, type OutboundHeader, Page, type PaginatedResponse, type PaginationParams, type PartnerDataClassification, type PartnerMailboxCredential, type PartnerMailboxCredentialGrant, type PartnerMailboxCredentialGrantList, type PartnerOrganization, type PartnerOrganizationList, type PartnerOrganizationStatus, type PartnerOwnershipInvitation, type PartnerUsage, type PrepareNewsletterAssetUploadParams, type PrepareStagedAttachmentUploadParams, QuotaExceededError, RateLimitError, ReconciliationRequiredError, type Recurrence, type RecurrenceFrequency, type RecurrenceNDay, type RegisterDomainParams, type RegisterNewsletterAssetFromUrlParams, type RegistrationContact, type Reminder, type ReplyScan, type ReplyScanCandidate, type ReplyScanResults, type ReplyScanStatus, type ReplyToMessageParams, type ReplyToThreadParams, type RequestOptions, type ResetMailboxPasswordParams, type RotateSecretResponse, type SandboxOutcome, type ScheduleNewsletterParams, type ScheduledMessage, type ScheduledMessageAttachment, type ScheduledMessageList, type ScheduledMessageRecipient, type ScheduledMessageUploadedAttachment, type SearchDomainsParams, type SendMessageParams, type SendNewsletterTestParams, ShipmailClient, type ShipmailConfig, ShipmailError, type StageAttachmentParams, type StagedAttachment, type StagedAttachmentUpload, type StatusResponse, type Subscriber, type SubscriberOutcome, type SubscriberResult, type SubscriberStatus, type Suppression, type TestWebhookResponse, type Thread, type UpdateAudienceFeedParams, type UpdateAudienceParams, type UpdateAutoReplyParams, type UpdateAutomationParams, type UpdateBookingPageParams, type UpdateCalendarEventParams, type UpdateDomainParams, type UpdateInboxMessageParams, type UpdateInboxThreadAttentionParams, type UpdateMailboxDeliveryRoutingParams, type UpdateMailboxFolderParams, type UpdateMailboxParams, type UpdateMailboxRulesParams, type UpdateNewsletterParams, type UpdatePartnerOrganizationParams, type UpdateScheduledMessageParams, type UpdateSubscriberParams, type UpdateWebhookParams, type UploadNewsletterAssetParams, ValidationError, WEBHOOK_DELIVERY_EVENT_TYPES, WEBHOOK_DELIVERY_STATUSES, WEBHOOK_EVENT_TYPES, type Webhook, type WebhookDelivery, type WebhookDeliveryDetail, type WebhookDeliveryEventType, type WebhookDeliveryStatus, type WebhookEvent, type WebhookEventType, WebhookVerificationError, type WebhookWithSecret, type Weekday, ShipmailClient as default, verifyWebhook };
package/dist/index.d.ts CHANGED
@@ -882,7 +882,10 @@ type OutboundHeader = {
882
882
  type MessageMetadata = Readonly<Record<string, string | number | boolean | null>>;
883
883
  type SendMessageParams = {
884
884
  readonly mailbox_id?: string | undefined;
885
- /** Sending mailbox: `hello@example.com` or `Acme Support <hello@example.com>`. */
885
+ /**
886
+ * Sending mailbox: `hello@example.com` or `Acme Support <hello@example.com>`.
887
+ * For a transactional sender, pass the bare sender address. Shipmail adds its name and Reply-To.
888
+ */
886
889
  readonly from?: string | undefined;
887
890
  readonly to: readonly EmailRecipientInput[];
888
891
  readonly cc?: readonly EmailRecipientInput[] | undefined;
@@ -1286,6 +1289,22 @@ type InboxReplyDraft = {
1286
1289
  }[];
1287
1290
  readonly created_at: string;
1288
1291
  };
1292
+ type InboxDraftRecipient = {
1293
+ readonly address: string;
1294
+ readonly name: string | null;
1295
+ };
1296
+ type InboxDraft = {
1297
+ readonly object: "inbox_draft";
1298
+ /** Inbox message ID of the saved draft. Read it with `getInboxMessage`. */
1299
+ readonly id: string;
1300
+ readonly mailbox_id: string;
1301
+ readonly from: InboxDraftRecipient;
1302
+ readonly to: readonly InboxDraftRecipient[];
1303
+ readonly cc: readonly InboxDraftRecipient[];
1304
+ readonly bcc: readonly InboxDraftRecipient[];
1305
+ readonly subject: string;
1306
+ readonly created_at: string;
1307
+ };
1289
1308
  type InboxReplyDraftSend = {
1290
1309
  readonly object: "inbox_reply_draft_send";
1291
1310
  readonly draft_id: string;
@@ -1430,6 +1449,14 @@ type ListInboxThreadsParams = {
1430
1449
  readonly cursor?: string | undefined;
1431
1450
  readonly limit?: number | undefined;
1432
1451
  };
1452
+ type CreateInboxDraftParams = {
1453
+ readonly to: readonly EmailRecipientInput[];
1454
+ readonly cc?: readonly EmailRecipientInput[] | undefined;
1455
+ readonly bcc?: readonly EmailRecipientInput[] | undefined;
1456
+ readonly subject?: string | undefined;
1457
+ readonly text?: string | undefined;
1458
+ readonly html?: string | undefined;
1459
+ };
1433
1460
  type CreateInboxReplyDraftParams = {
1434
1461
  readonly text?: string | undefined;
1435
1462
  readonly html?: string | undefined;
@@ -1529,6 +1556,8 @@ declare class Mailboxes extends ApiResource {
1529
1556
  listInboxThreads(id: string, params?: ListInboxThreadsParams, options?: MethodOptions): Promise<InboxThreads>;
1530
1557
  getInboxThread(id: string, threadId: string, options?: MethodOptions): Promise<InboxThread>;
1531
1558
  updateInboxThreadAttention(id: string, threadId: string, params: UpdateInboxThreadAttentionParams, options?: MethodOptions): Promise<InboxThreadAttentionResult>;
1559
+ /** Saves a new message to the mailbox's Drafts folder. It is never sent by this call. */
1560
+ createInboxDraft(id: string, params: CreateInboxDraftParams, options?: MethodOptions): Promise<InboxDraft>;
1532
1561
  createInboxReplyDraft(id: string, threadId: string, params: CreateInboxReplyDraftParams, options?: MethodOptions): Promise<InboxReplyDraft>;
1533
1562
  sendInboxReplyDraft(id: string, threadId: string, draftId: string, options?: MethodOptions): Promise<InboxReplyDraftSend>;
1534
1563
  replyToInboxMessage(id: string, messageId: string, params: ReplyToMessageParams, options?: MethodOptions): Promise<Message>;
@@ -2419,4 +2448,4 @@ declare function verifyWebhook(body: string, headers: WebhookHeaders | Headers,
2419
2448
  readonly toleranceInSeconds?: number | undefined;
2420
2449
  }): Promise<WebhookEvent>;
2421
2450
 
2422
- export { type AddSubscriberParams, type AddSubscribersBatchParams, type AddSubscribersBatchResult, type ApiErrorBody, type Audience, type AudienceFeed, AuthenticationError, AuthorizationError, type Automation, type AutomationAction, type AutomationCondition, type AutomationDefinition, type AutomationRun, type AutomationRunStatus, type AutomationRunSummary, type AutomationStatus, type AutomationTrigger, type BookingPage, CONFERENCING_PROVIDER_IDS, type CalendarAvailability, type CalendarAvailabilityParams, type CalendarAvailabilitySlot, type CalendarEvent, type CalendarEventPrivacy, type CalendarEventStatus, type CalendarFreeBusyStatus, type CalendarInvitationLanguage, type CapabilitiesResponse, type CapabilityResourceConstraints, type ConferencingProviderId, ConflictError, ConnectionError, type ConsumePartnerMailboxCredentialGrantParams, type CreateAudienceParams, type CreateAutomationParams, type CreateBookingPageParams, type CreateCalendarEventParams, type CreateDomainParams, type CreateInboxReplyDraftParams, type CreateMailboxAppPasswordParams, type CreateMailboxFolderParams, type CreateMailboxParams, type CreateNewsletterFromChangelogParams, type CreateNewsletterParams, type CreatePartnerOrganizationParams, type CreateReplyScanParams, type CreateWebhookParams, type CreatedMailboxAppPassword, type CreatedPartnerOrganization, DOMAIN_STATUSES, type DataMode, type DeleteCalendarEventParams, type Domain, type DomainDnsRecord, type DomainDnsRecordKey, type DomainDnsRecordSet, type DomainDnsRecordStatus, type DomainRegistrationInfo, type DomainSearchResult, type DomainStatus, type DomainVerificationResult, type DownloadInboxAttachmentParams, type EmailAuthVerdict, type EmailAuthenticationResults, type EmailRecipient, type EmailRecipientInput, type ErrorType, type GetCalendarEventParams, type GetThreadParams, type InboxAttachment, type InboxBodyPart, type InboxBodyValue, type InboxEmailHeader, type InboxFullMessage, type InboxKeyword, type InboxMessage, type InboxMessageAction, type InboxMessages, type InboxReplyDraft, type InboxReplyDraftSend, type InboxThread, type InboxThreadAttentionResult, type InboxThreadAttentionState, type InboxThreadSummary, type InboxThreads, type InjectSandboxInboundParams, InternalServerError, type ListAudiencesParams, type ListAutomationsResponse, type ListBookingPagesParams, type ListCalendarEventsParams, type ListDeliveriesParams, type ListDomainsParams, type ListInboxMessagesParams, type ListInboxThreadsParams, type ListMailboxesParams, type ListMembersParams, type ListMessageAnalyticsParams, type ListMessagesParams, type ListNewsletterAssetsParams, type ListNewsletterDomainsParams, type ListNewsletterSenderIdentitiesParams, type ListNewslettersParams, type ListReplyScanResultsParams, type ListScheduledMessagesParams, type ListSubscribersParams, type ListSuppressionsParams, type ListThreadsParams, type ListWebhooksParams, MESSAGE_SOURCES, MESSAGE_STATUSES, type Mailbox, type MailboxAppPassword, type MailboxAppPasswordList, type MailboxAppPasswordPurpose, type MailboxAppPasswordState, type MailboxDeliveryDestination, type MailboxDeliveryRouting, type MailboxExport, type MailboxExportErrorCode, type MailboxExportStatus, type MailboxFolder, type MailboxFolders, type MailboxIdentities, type MailboxIdentity, type MailboxRule, type MailboxRuleAction, type MailboxRuleCondition, type MailboxRuleFolder, type MailboxRuleMatchMode, type MailboxRuleMoveTarget, type MailboxRules, type Member, type MemberRole, type MergeFields, type Message, type MessageAnalytics, type MessageAnalyticsPage, type MessageMetadata, type MessageRuleDisposition, type MessageSource, type MessageStatus, type MethodOptions, type MoveInboxMessageParams, type Newsletter, type NewsletterArchiveVisibility, type NewsletterAsset, type NewsletterAssetContentType, type NewsletterAssetKind, type NewsletterAssetListResponse, type NewsletterAssetStorageUsage, type NewsletterAssetUpload, type NewsletterBlock, type NewsletterButtonAlign, type NewsletterCalloutVariant, type NewsletterChangelogEntry, type NewsletterChangelogMedia, type NewsletterChangelogTone, type NewsletterColumnContent, type NewsletterColumnImageFit, type NewsletterColumnRatio, type NewsletterCountedUrl, type NewsletterDomain, type NewsletterDomainRecordStatus, type NewsletterDomainStatus, type NewsletterPreflight, type NewsletterPreflightItem, type NewsletterPreflightItemStatus, type NewsletterPreflightStatus, type NewsletterPreview, type NewsletterSenderIdentity, type NewsletterStatus, type NewsletterStylingMode, type NewsletterTestSend, type NewsletterTestSendStatus, type NewsletterUrlBreakdown, type NewsletterUrlSource, NotFoundError, type OneTimeSecretMethodOptions, type OutboundHeader, Page, type PaginatedResponse, type PaginationParams, type PartnerDataClassification, type PartnerMailboxCredential, type PartnerMailboxCredentialGrant, type PartnerMailboxCredentialGrantList, type PartnerOrganization, type PartnerOrganizationList, type PartnerOrganizationStatus, type PartnerOwnershipInvitation, type PartnerUsage, type PrepareNewsletterAssetUploadParams, type PrepareStagedAttachmentUploadParams, QuotaExceededError, RateLimitError, ReconciliationRequiredError, type Recurrence, type RecurrenceFrequency, type RecurrenceNDay, type RegisterDomainParams, type RegisterNewsletterAssetFromUrlParams, type RegistrationContact, type Reminder, type ReplyScan, type ReplyScanCandidate, type ReplyScanResults, type ReplyScanStatus, type ReplyToMessageParams, type ReplyToThreadParams, type RequestOptions, type ResetMailboxPasswordParams, type RotateSecretResponse, type SandboxOutcome, type ScheduleNewsletterParams, type ScheduledMessage, type ScheduledMessageAttachment, type ScheduledMessageList, type ScheduledMessageRecipient, type ScheduledMessageUploadedAttachment, type SearchDomainsParams, type SendMessageParams, type SendNewsletterTestParams, ShipmailClient, type ShipmailConfig, ShipmailError, type StageAttachmentParams, type StagedAttachment, type StagedAttachmentUpload, type StatusResponse, type Subscriber, type SubscriberOutcome, type SubscriberResult, type SubscriberStatus, type Suppression, type TestWebhookResponse, type Thread, type UpdateAudienceFeedParams, type UpdateAudienceParams, type UpdateAutoReplyParams, type UpdateAutomationParams, type UpdateBookingPageParams, type UpdateCalendarEventParams, type UpdateDomainParams, type UpdateInboxMessageParams, type UpdateInboxThreadAttentionParams, type UpdateMailboxDeliveryRoutingParams, type UpdateMailboxFolderParams, type UpdateMailboxParams, type UpdateMailboxRulesParams, type UpdateNewsletterParams, type UpdatePartnerOrganizationParams, type UpdateScheduledMessageParams, type UpdateSubscriberParams, type UpdateWebhookParams, type UploadNewsletterAssetParams, ValidationError, WEBHOOK_DELIVERY_EVENT_TYPES, WEBHOOK_DELIVERY_STATUSES, WEBHOOK_EVENT_TYPES, type Webhook, type WebhookDelivery, type WebhookDeliveryDetail, type WebhookDeliveryEventType, type WebhookDeliveryStatus, type WebhookEvent, type WebhookEventType, WebhookVerificationError, type WebhookWithSecret, type Weekday, ShipmailClient as default, verifyWebhook };
2451
+ export { type AddSubscriberParams, type AddSubscribersBatchParams, type AddSubscribersBatchResult, type ApiErrorBody, type Audience, type AudienceFeed, AuthenticationError, AuthorizationError, type Automation, type AutomationAction, type AutomationCondition, type AutomationDefinition, type AutomationRun, type AutomationRunStatus, type AutomationRunSummary, type AutomationStatus, type AutomationTrigger, type BookingPage, CONFERENCING_PROVIDER_IDS, type CalendarAvailability, type CalendarAvailabilityParams, type CalendarAvailabilitySlot, type CalendarEvent, type CalendarEventPrivacy, type CalendarEventStatus, type CalendarFreeBusyStatus, type CalendarInvitationLanguage, type CapabilitiesResponse, type CapabilityResourceConstraints, type ConferencingProviderId, ConflictError, ConnectionError, type ConsumePartnerMailboxCredentialGrantParams, type CreateAudienceParams, type CreateAutomationParams, type CreateBookingPageParams, type CreateCalendarEventParams, type CreateDomainParams, type CreateInboxDraftParams, type CreateInboxReplyDraftParams, type CreateMailboxAppPasswordParams, type CreateMailboxFolderParams, type CreateMailboxParams, type CreateNewsletterFromChangelogParams, type CreateNewsletterParams, type CreatePartnerOrganizationParams, type CreateReplyScanParams, type CreateWebhookParams, type CreatedMailboxAppPassword, type CreatedPartnerOrganization, DOMAIN_STATUSES, type DataMode, type DeleteCalendarEventParams, type Domain, type DomainDnsRecord, type DomainDnsRecordKey, type DomainDnsRecordSet, type DomainDnsRecordStatus, type DomainRegistrationInfo, type DomainSearchResult, type DomainStatus, type DomainVerificationResult, type DownloadInboxAttachmentParams, type EmailAuthVerdict, type EmailAuthenticationResults, type EmailRecipient, type EmailRecipientInput, type ErrorType, type GetCalendarEventParams, type GetThreadParams, type InboxAttachment, type InboxBodyPart, type InboxBodyValue, type InboxDraft, type InboxDraftRecipient, type InboxEmailHeader, type InboxFullMessage, type InboxKeyword, type InboxMessage, type InboxMessageAction, type InboxMessages, type InboxReplyDraft, type InboxReplyDraftSend, type InboxThread, type InboxThreadAttentionResult, type InboxThreadAttentionState, type InboxThreadSummary, type InboxThreads, type InjectSandboxInboundParams, InternalServerError, type ListAudiencesParams, type ListAutomationsResponse, type ListBookingPagesParams, type ListCalendarEventsParams, type ListDeliveriesParams, type ListDomainsParams, type ListInboxMessagesParams, type ListInboxThreadsParams, type ListMailboxesParams, type ListMembersParams, type ListMessageAnalyticsParams, type ListMessagesParams, type ListNewsletterAssetsParams, type ListNewsletterDomainsParams, type ListNewsletterSenderIdentitiesParams, type ListNewslettersParams, type ListReplyScanResultsParams, type ListScheduledMessagesParams, type ListSubscribersParams, type ListSuppressionsParams, type ListThreadsParams, type ListWebhooksParams, MESSAGE_SOURCES, MESSAGE_STATUSES, type Mailbox, type MailboxAppPassword, type MailboxAppPasswordList, type MailboxAppPasswordPurpose, type MailboxAppPasswordState, type MailboxDeliveryDestination, type MailboxDeliveryRouting, type MailboxExport, type MailboxExportErrorCode, type MailboxExportStatus, type MailboxFolder, type MailboxFolders, type MailboxIdentities, type MailboxIdentity, type MailboxRule, type MailboxRuleAction, type MailboxRuleCondition, type MailboxRuleFolder, type MailboxRuleMatchMode, type MailboxRuleMoveTarget, type MailboxRules, type Member, type MemberRole, type MergeFields, type Message, type MessageAnalytics, type MessageAnalyticsPage, type MessageMetadata, type MessageRuleDisposition, type MessageSource, type MessageStatus, type MethodOptions, type MoveInboxMessageParams, type Newsletter, type NewsletterArchiveVisibility, type NewsletterAsset, type NewsletterAssetContentType, type NewsletterAssetKind, type NewsletterAssetListResponse, type NewsletterAssetStorageUsage, type NewsletterAssetUpload, type NewsletterBlock, type NewsletterButtonAlign, type NewsletterCalloutVariant, type NewsletterChangelogEntry, type NewsletterChangelogMedia, type NewsletterChangelogTone, type NewsletterColumnContent, type NewsletterColumnImageFit, type NewsletterColumnRatio, type NewsletterCountedUrl, type NewsletterDomain, type NewsletterDomainRecordStatus, type NewsletterDomainStatus, type NewsletterPreflight, type NewsletterPreflightItem, type NewsletterPreflightItemStatus, type NewsletterPreflightStatus, type NewsletterPreview, type NewsletterSenderIdentity, type NewsletterStatus, type NewsletterStylingMode, type NewsletterTestSend, type NewsletterTestSendStatus, type NewsletterUrlBreakdown, type NewsletterUrlSource, NotFoundError, type OneTimeSecretMethodOptions, type OutboundHeader, Page, type PaginatedResponse, type PaginationParams, type PartnerDataClassification, type PartnerMailboxCredential, type PartnerMailboxCredentialGrant, type PartnerMailboxCredentialGrantList, type PartnerOrganization, type PartnerOrganizationList, type PartnerOrganizationStatus, type PartnerOwnershipInvitation, type PartnerUsage, type PrepareNewsletterAssetUploadParams, type PrepareStagedAttachmentUploadParams, QuotaExceededError, RateLimitError, ReconciliationRequiredError, type Recurrence, type RecurrenceFrequency, type RecurrenceNDay, type RegisterDomainParams, type RegisterNewsletterAssetFromUrlParams, type RegistrationContact, type Reminder, type ReplyScan, type ReplyScanCandidate, type ReplyScanResults, type ReplyScanStatus, type ReplyToMessageParams, type ReplyToThreadParams, type RequestOptions, type ResetMailboxPasswordParams, type RotateSecretResponse, type SandboxOutcome, type ScheduleNewsletterParams, type ScheduledMessage, type ScheduledMessageAttachment, type ScheduledMessageList, type ScheduledMessageRecipient, type ScheduledMessageUploadedAttachment, type SearchDomainsParams, type SendMessageParams, type SendNewsletterTestParams, ShipmailClient, type ShipmailConfig, ShipmailError, type StageAttachmentParams, type StagedAttachment, type StagedAttachmentUpload, type StatusResponse, type Subscriber, type SubscriberOutcome, type SubscriberResult, type SubscriberStatus, type Suppression, type TestWebhookResponse, type Thread, type UpdateAudienceFeedParams, type UpdateAudienceParams, type UpdateAutoReplyParams, type UpdateAutomationParams, type UpdateBookingPageParams, type UpdateCalendarEventParams, type UpdateDomainParams, type UpdateInboxMessageParams, type UpdateInboxThreadAttentionParams, type UpdateMailboxDeliveryRoutingParams, type UpdateMailboxFolderParams, type UpdateMailboxParams, type UpdateMailboxRulesParams, type UpdateNewsletterParams, type UpdatePartnerOrganizationParams, type UpdateScheduledMessageParams, type UpdateSubscriberParams, type UpdateWebhookParams, type UploadNewsletterAssetParams, ValidationError, WEBHOOK_DELIVERY_EVENT_TYPES, WEBHOOK_DELIVERY_STATUSES, WEBHOOK_EVENT_TYPES, type Webhook, type WebhookDelivery, type WebhookDeliveryDetail, type WebhookDeliveryEventType, type WebhookDeliveryStatus, type WebhookEvent, type WebhookEventType, WebhookVerificationError, type WebhookWithSecret, type Weekday, ShipmailClient as default, verifyWebhook };
package/dist/index.js CHANGED
@@ -24,6 +24,7 @@ var API_KEY_SCOPES = [
24
24
  "messages:read",
25
25
  "messages:write",
26
26
  "drafts:write",
27
+ "drafts:compose",
27
28
  "messages:send",
28
29
  "newsletters:read",
29
30
  "newsletters:write",
@@ -63,6 +64,7 @@ var API_KEY_SCOPE_DESCRIPTIONS = {
63
64
  "messages:read": "List and retrieve messages.",
64
65
  "messages:write": "Update, move, delete, and inject sandbox messages.",
65
66
  "drafts:write": "Create agent-safe reply drafts with server-derived recipients.",
67
+ "drafts:compose": "Save new-message drafts to a mailbox's Drafts folder for review. Cannot send.",
66
68
  "messages:send": "Send messages, replies, and approved reply drafts.",
67
69
  "newsletters:read": "List and retrieve newsletter drafts and campaigns.",
68
70
  "newsletters:write": "Create, update, test, schedule, cancel, and resume newsletters.",
@@ -875,6 +877,15 @@ var Mailboxes = class extends ApiResource {
875
877
  methodOptions: options
876
878
  });
877
879
  }
880
+ /** Saves a new message to the mailbox's Drafts folder. It is never sent by this call. */
881
+ createInboxDraft(id, params, options) {
882
+ return this.client.request({
883
+ method: "POST",
884
+ path: `/mailboxes/${encodeURIComponent(id)}/inbox/drafts`,
885
+ body: params,
886
+ methodOptions: options
887
+ });
888
+ }
878
889
  createInboxReplyDraft(id, threadId, params, options) {
879
890
  return this.client.request({
880
891
  method: "POST",
@@ -1695,17 +1706,26 @@ var Webhooks = class extends ApiResource {
1695
1706
  };
1696
1707
 
1697
1708
  // src/version.ts
1698
- var VERSION = "0.5.6";
1709
+ var VERSION = "0.5.8";
1699
1710
 
1700
1711
  // src/client.ts
1701
1712
  var DEFAULT_BASE_URL = "https://shipmail.to/api/v1";
1702
1713
  var DEFAULT_MAX_RETRIES = 2;
1703
1714
  var DEFAULT_TIMEOUT = 3e4;
1715
+ var MAX_RETRY_AFTER_MS = 6e4;
1716
+ function parseRetryAfter(value) {
1717
+ if (!value?.trim()) return void 0;
1718
+ const seconds = Number(value);
1719
+ if (Number.isFinite(seconds) && seconds >= 0) return seconds * 1e3;
1720
+ if (/^[+-]?[\d.]+$/.test(value.trim())) return void 0;
1721
+ const date = Date.parse(value);
1722
+ return Number.isFinite(date) ? Math.max(0, date - Date.now()) : void 0;
1723
+ }
1704
1724
  function isRetryableStatus(status) {
1705
1725
  return status === 429 || status >= 500;
1706
1726
  }
1707
1727
  function calculateBackoff(attempt, retryAfterMs) {
1708
- if (retryAfterMs !== void 0 && retryAfterMs > 0) {
1728
+ if (retryAfterMs !== void 0 && Number.isFinite(retryAfterMs) && retryAfterMs >= 0) {
1709
1729
  return retryAfterMs;
1710
1730
  }
1711
1731
  const base2 = Math.min(2 ** attempt * 500, 8e3);
@@ -1748,6 +1768,9 @@ var ShipmailClient = class {
1748
1768
  this.defaultHeaders = config.defaultHeaders ? { ...config.defaultHeaders } : {};
1749
1769
  this.organizationId = config.organizationId;
1750
1770
  }
1771
+ if (!Number.isSafeInteger(this.maxRetries) || this.maxRetries < 0) {
1772
+ throw new RangeError("maxRetries must be a non-negative safe integer");
1773
+ }
1751
1774
  this.audiences = new Audiences(this);
1752
1775
  this.automations = new Automations(this);
1753
1776
  this.bookingPages = new BookingPages(this);
@@ -1783,9 +1806,13 @@ var ShipmailClient = class {
1783
1806
  const url = this.buildUrl(options.path, options.query);
1784
1807
  let lastError;
1785
1808
  const methodOpts = options.methodOptions;
1809
+ const retryHeaders = new Headers({ ...this.defaultHeaders, ...methodOpts?.headers });
1810
+ const method = options.method.toUpperCase();
1811
+ const idempotencyKey = methodOpts?.idempotencyKey || retryHeaders.get("Idempotency-Key");
1812
+ const canRetry = ["GET", "HEAD", "OPTIONS"].includes(method) || ["POST", "PATCH", "PUT"].includes(method) && Boolean(idempotencyKey?.trim());
1813
+ let retryAfterMs;
1786
1814
  for (let attempt = 0; attempt <= this.maxRetries; attempt++) {
1787
1815
  if (attempt > 0) {
1788
- const retryAfterMs = lastError instanceof RateLimitError && lastError.retryAfter !== void 0 ? lastError.retryAfter * 1e3 : void 0;
1789
1816
  const delay = calculateBackoff(attempt - 1, retryAfterMs);
1790
1817
  await new Promise((resolve) => setTimeout(resolve, delay));
1791
1818
  }
@@ -1822,7 +1849,10 @@ var ShipmailClient = class {
1822
1849
  });
1823
1850
  } catch (err) {
1824
1851
  lastError = new ConnectionError(err instanceof Error ? err.message : "Request failed");
1825
- if (attempt < this.maxRetries) continue;
1852
+ if (canRetry && !methodOpts?.signal?.aborted && attempt < this.maxRetries) {
1853
+ retryAfterMs = void 0;
1854
+ continue;
1855
+ }
1826
1856
  throw lastError;
1827
1857
  }
1828
1858
  if (response.ok) {
@@ -1842,7 +1872,14 @@ var ShipmailClient = class {
1842
1872
  retryable: isRetryableStatus(response.status)
1843
1873
  });
1844
1874
  }
1845
- if (!lastError.retryable || attempt >= this.maxRetries) {
1875
+ retryAfterMs = parseRetryAfter(response.headers.get("Retry-After"));
1876
+ if (retryAfterMs === void 0 && lastError instanceof RateLimitError) {
1877
+ const seconds = lastError.retryAfter;
1878
+ if (typeof seconds === "number" && Number.isFinite(seconds) && seconds >= 0) {
1879
+ retryAfterMs = seconds * 1e3;
1880
+ }
1881
+ }
1882
+ if (!canRetry || !lastError.retryable || attempt >= this.maxRetries || retryAfterMs !== void 0 && retryAfterMs > MAX_RETRY_AFTER_MS) {
1846
1883
  throw lastError;
1847
1884
  }
1848
1885
  }