shipmail 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.
@@ -0,0 +1,346 @@
1
+ declare class Page<T> implements AsyncIterable<T> {
2
+ private readonly client;
3
+ private readonly path;
4
+ private readonly query;
5
+ constructor(client: ShipMailClient, path: string, query: Record<string, string | number | boolean | undefined>);
6
+ [Symbol.asyncIterator](): AsyncIterator<T>;
7
+ }
8
+
9
+ declare abstract class ApiResource {
10
+ protected readonly client: ShipMailClient;
11
+ constructor(client: ShipMailClient);
12
+ }
13
+
14
+ type ShipMailConfig = {
15
+ readonly apiKey: string;
16
+ readonly baseUrl?: string | undefined;
17
+ readonly maxRetries?: number | undefined;
18
+ readonly timeout?: number | undefined;
19
+ readonly fetch?: typeof fetch | undefined;
20
+ };
21
+ type PaginationParams = {
22
+ readonly cursor?: string | undefined;
23
+ readonly limit?: number | undefined;
24
+ };
25
+ type PaginatedResponse<T> = {
26
+ readonly data: readonly T[];
27
+ readonly pagination: {
28
+ readonly next_cursor: string | null;
29
+ readonly has_more: boolean;
30
+ };
31
+ };
32
+ type ErrorType = "validation_error" | "authentication_error" | "authorization_error" | "not_found" | "rate_limit_error" | "conflict" | "internal_error";
33
+ type ApiErrorBody = {
34
+ readonly error: {
35
+ readonly type: ErrorType;
36
+ readonly message: string;
37
+ readonly request_id?: string | undefined;
38
+ readonly details?: readonly {
39
+ readonly field: string;
40
+ readonly message: string;
41
+ }[] | undefined;
42
+ readonly retry_after?: number | undefined;
43
+ };
44
+ };
45
+ type EmailRecipient = {
46
+ readonly address: string;
47
+ readonly name?: string | null | undefined;
48
+ };
49
+ declare const WEBHOOK_EVENT_TYPES: readonly ["message.received", "message.queued", "message.sent", "message.delivered", "message.bounced", "message.complained", "domain.verified", "domain.verification_failed", "domain.degraded"];
50
+ type WebhookEventType = (typeof WEBHOOK_EVENT_TYPES)[number];
51
+ type StatusResponse = {
52
+ readonly status: string;
53
+ readonly version: string;
54
+ readonly time: string;
55
+ readonly request_id: string;
56
+ };
57
+
58
+ type Domain = {
59
+ readonly id: string;
60
+ readonly name: string;
61
+ readonly status: string;
62
+ readonly dns_provider: string | null;
63
+ readonly ownership_verified: boolean;
64
+ readonly mx_verified: boolean;
65
+ readonly spf_verified: boolean;
66
+ readonly dkim_verified: boolean;
67
+ readonly dmarc_verified: boolean;
68
+ readonly ses_verified: boolean;
69
+ readonly catch_all_mailbox_id: string | null;
70
+ readonly verified_at: string | null;
71
+ readonly created_at: string;
72
+ readonly updated_at: string;
73
+ };
74
+ type CreateDomainParams = {
75
+ readonly name: string;
76
+ };
77
+ type UpdateDomainParams = {
78
+ readonly catch_all_mailbox_id?: string | null | undefined;
79
+ };
80
+ type ListDomainsParams = PaginationParams;
81
+ type DomainVerificationResult = {
82
+ readonly all_verified: boolean;
83
+ readonly records: {
84
+ readonly ownership: boolean;
85
+ readonly mx: boolean;
86
+ readonly spf: boolean;
87
+ readonly dkim: boolean;
88
+ readonly dmarc: boolean;
89
+ };
90
+ readonly ses_verified: boolean;
91
+ readonly ses_error: boolean;
92
+ readonly existing_spf: string | null;
93
+ readonly suggested_spf: string | null;
94
+ readonly conflicting_mx: readonly string[];
95
+ };
96
+
97
+ declare class Domains extends ApiResource {
98
+ create(params: CreateDomainParams): Promise<Domain>;
99
+ list(params?: ListDomainsParams): Promise<PaginatedResponse<Domain>>;
100
+ listAutoPaginating(params?: Omit<ListDomainsParams, "cursor">): Page<Domain>;
101
+ get(id: string): Promise<Domain>;
102
+ update(id: string, params: UpdateDomainParams): Promise<Domain>;
103
+ delete(id: string): Promise<void>;
104
+ verify(id: string): Promise<DomainVerificationResult>;
105
+ }
106
+
107
+ type Mailbox = {
108
+ readonly id: string;
109
+ readonly domain_id: string;
110
+ readonly address: string;
111
+ readonly display_name: string | null;
112
+ readonly avatar_url: string | null;
113
+ readonly created_at: string;
114
+ readonly updated_at: string;
115
+ };
116
+ type CreateMailboxParams = {
117
+ readonly domain_id: string;
118
+ readonly address: string;
119
+ readonly display_name?: string | undefined;
120
+ };
121
+ type UpdateMailboxParams = {
122
+ readonly display_name?: string | null | undefined;
123
+ };
124
+ type ListMailboxesParams = PaginationParams & {
125
+ readonly domain_id?: string | undefined;
126
+ };
127
+ type UploadAvatarResponse = {
128
+ readonly avatar_url: string;
129
+ };
130
+
131
+ declare class Mailboxes extends ApiResource {
132
+ create(params: CreateMailboxParams): Promise<Mailbox>;
133
+ list(params?: ListMailboxesParams): Promise<PaginatedResponse<Mailbox>>;
134
+ listAutoPaginating(params?: Omit<ListMailboxesParams, "cursor">): Page<Mailbox>;
135
+ get(id: string): Promise<Mailbox>;
136
+ update(id: string, params: UpdateMailboxParams): Promise<Mailbox>;
137
+ delete(id: string): Promise<void>;
138
+ uploadAvatar(id: string, data: ArrayBuffer, contentType: string): Promise<UploadAvatarResponse>;
139
+ deleteAvatar(id: string): Promise<void>;
140
+ }
141
+
142
+ type Message = {
143
+ readonly id: string;
144
+ readonly mailbox_id: string;
145
+ readonly thread_id: string | null;
146
+ readonly source: string;
147
+ readonly status: string;
148
+ readonly created_at: string;
149
+ readonly updated_at: string;
150
+ };
151
+ type SendMessageParams = {
152
+ readonly mailbox_id: string;
153
+ readonly to: readonly EmailRecipient[];
154
+ readonly cc?: readonly EmailRecipient[] | undefined;
155
+ readonly bcc?: readonly EmailRecipient[] | undefined;
156
+ readonly reply_to?: EmailRecipient | undefined;
157
+ readonly subject: string;
158
+ readonly body_html?: string | undefined;
159
+ readonly body_text?: string | undefined;
160
+ readonly in_reply_to?: string | undefined;
161
+ readonly references?: readonly string[] | undefined;
162
+ };
163
+
164
+ declare class Messages extends ApiResource {
165
+ send(params: SendMessageParams): Promise<Message>;
166
+ get(id: string): Promise<Message>;
167
+ }
168
+
169
+ declare class Status extends ApiResource {
170
+ get(): Promise<StatusResponse>;
171
+ }
172
+
173
+ type ListThreadsParams = PaginationParams & {
174
+ readonly mailbox_id: string;
175
+ };
176
+ type GetThreadParams = PaginationParams;
177
+ type ReplyToThreadParams = {
178
+ readonly body_html?: string | undefined;
179
+ readonly body_text?: string | undefined;
180
+ readonly to?: readonly EmailRecipient[] | undefined;
181
+ readonly cc?: readonly EmailRecipient[] | undefined;
182
+ };
183
+
184
+ declare class Threads extends ApiResource {
185
+ list(params: ListThreadsParams): Promise<PaginatedResponse<Message>>;
186
+ listAutoPaginating(params: Omit<ListThreadsParams, "cursor">): Page<Message>;
187
+ get(id: string, params?: GetThreadParams): Promise<PaginatedResponse<Message>>;
188
+ reply(id: string, params: ReplyToThreadParams): Promise<Message>;
189
+ }
190
+
191
+ type Webhook = {
192
+ readonly id: string;
193
+ readonly url: string;
194
+ readonly events: readonly string[];
195
+ readonly active: boolean;
196
+ readonly description: string | null;
197
+ readonly created_at: string;
198
+ readonly updated_at: string;
199
+ };
200
+ type WebhookWithSecret = Webhook & {
201
+ readonly secret: string;
202
+ };
203
+ type CreateWebhookParams = {
204
+ readonly url: string;
205
+ readonly events: readonly WebhookEventType[];
206
+ readonly description?: string | undefined;
207
+ };
208
+ type UpdateWebhookParams = {
209
+ readonly url?: string | undefined;
210
+ readonly events?: readonly WebhookEventType[] | undefined;
211
+ readonly description?: string | null | undefined;
212
+ readonly active?: boolean | undefined;
213
+ };
214
+ type ListWebhooksParams = PaginationParams;
215
+ type RotateSecretResponse = {
216
+ readonly secret: string;
217
+ readonly previous_secret_expires_at: string;
218
+ };
219
+ type TestWebhookResponse = {
220
+ readonly event_id: string;
221
+ };
222
+ type WebhookDelivery = {
223
+ readonly id: string;
224
+ readonly event_id: string;
225
+ readonly event_type: string;
226
+ readonly status: string;
227
+ readonly attempts: number;
228
+ readonly last_status_code: number | null;
229
+ readonly last_error: string | null;
230
+ readonly created_at: string;
231
+ readonly delivered_at: string | null;
232
+ };
233
+ type ListDeliveriesParams = PaginationParams & {
234
+ readonly status?: string | undefined;
235
+ readonly event_type?: string | undefined;
236
+ };
237
+ type WebhookEvent<T = unknown> = {
238
+ readonly event_id: string;
239
+ readonly event_type: WebhookEventType;
240
+ readonly created_at: string;
241
+ readonly data: T;
242
+ };
243
+
244
+ declare class Webhooks extends ApiResource {
245
+ create(params: CreateWebhookParams): Promise<WebhookWithSecret>;
246
+ list(params?: ListWebhooksParams): Promise<PaginatedResponse<Webhook>>;
247
+ listAutoPaginating(params?: Omit<ListWebhooksParams, "cursor">): Page<Webhook>;
248
+ get(id: string): Promise<Webhook>;
249
+ update(id: string, params: UpdateWebhookParams): Promise<Webhook>;
250
+ delete(id: string): Promise<void>;
251
+ rotateSecret(id: string): Promise<RotateSecretResponse>;
252
+ test(id: string): Promise<TestWebhookResponse>;
253
+ listDeliveries(id: string, params?: ListDeliveriesParams): Promise<PaginatedResponse<WebhookDelivery>>;
254
+ listDeliveriesAutoPaginating(id: string, params?: Omit<ListDeliveriesParams, "cursor">): Page<WebhookDelivery>;
255
+ }
256
+
257
+ type RequestOptions = {
258
+ readonly method: string;
259
+ readonly path: string;
260
+ readonly body?: unknown | undefined;
261
+ readonly query?: Record<string, string | number | boolean | undefined> | undefined;
262
+ readonly rawBody?: ArrayBuffer | undefined;
263
+ readonly contentType?: string | undefined;
264
+ };
265
+ declare class ShipMailClient {
266
+ private readonly apiKey;
267
+ private readonly baseUrl;
268
+ private readonly maxRetries;
269
+ private readonly timeout;
270
+ private readonly fetchFn;
271
+ readonly domains: Domains;
272
+ readonly mailboxes: Mailboxes;
273
+ readonly messages: Messages;
274
+ readonly threads: Threads;
275
+ readonly webhooks: Webhooks;
276
+ readonly status: Status;
277
+ constructor(config: string | ShipMailConfig);
278
+ request<T>(options: RequestOptions): Promise<T>;
279
+ private buildUrl;
280
+ }
281
+
282
+ declare class ShipMailError extends Error {
283
+ readonly status: number | undefined;
284
+ readonly type: ErrorType | undefined;
285
+ readonly requestId: string | undefined;
286
+ readonly retryable: boolean;
287
+ constructor(message: string, options?: {
288
+ readonly status?: number | undefined;
289
+ readonly type?: ErrorType | undefined;
290
+ readonly requestId?: string | undefined;
291
+ readonly retryable?: boolean | undefined;
292
+ });
293
+ }
294
+ declare class AuthenticationError extends ShipMailError {
295
+ constructor(message: string, requestId?: string);
296
+ }
297
+ declare class AuthorizationError extends ShipMailError {
298
+ constructor(message: string, requestId?: string);
299
+ }
300
+ declare class ValidationError extends ShipMailError {
301
+ readonly details: readonly {
302
+ readonly field: string;
303
+ readonly message: string;
304
+ }[] | undefined;
305
+ constructor(message: string, options?: {
306
+ readonly requestId?: string | undefined;
307
+ readonly details?: readonly {
308
+ readonly field: string;
309
+ readonly message: string;
310
+ }[] | undefined;
311
+ });
312
+ }
313
+ declare class NotFoundError extends ShipMailError {
314
+ constructor(message: string, requestId?: string);
315
+ }
316
+ declare class RateLimitError extends ShipMailError {
317
+ readonly retryAfter: number | undefined;
318
+ constructor(message: string, options?: {
319
+ readonly requestId?: string | undefined;
320
+ readonly retryAfter?: number | undefined;
321
+ });
322
+ }
323
+ declare class ConflictError extends ShipMailError {
324
+ constructor(message: string, requestId?: string);
325
+ }
326
+ declare class InternalServerError extends ShipMailError {
327
+ constructor(message: string, requestId?: string);
328
+ }
329
+ declare class ConnectionError extends ShipMailError {
330
+ constructor(message: string);
331
+ }
332
+ declare class WebhookVerificationError extends ShipMailError {
333
+ constructor(message: string);
334
+ }
335
+
336
+ type WebhookHeaders = {
337
+ readonly "x-shipmail-signature"?: string;
338
+ readonly "x-shipmail-timestamp"?: string;
339
+ readonly "x-shipmail-event-id"?: string;
340
+ readonly [key: string]: string | undefined;
341
+ };
342
+ declare function verifyWebhook(body: string, headers: WebhookHeaders | Headers, secret: string, options?: {
343
+ readonly toleranceInSeconds?: number | undefined;
344
+ }): WebhookEvent;
345
+
346
+ export { type ApiErrorBody, AuthenticationError, AuthorizationError, ConflictError, ConnectionError, type CreateDomainParams, type CreateMailboxParams, type CreateWebhookParams, type Domain, type DomainVerificationResult, type EmailRecipient, type ErrorType, type GetThreadParams, InternalServerError, type ListDeliveriesParams, type ListDomainsParams, type ListMailboxesParams, type ListThreadsParams, type ListWebhooksParams, type Message, NotFoundError, Page, type PaginatedResponse, type PaginationParams, RateLimitError, type ReplyToThreadParams, type RotateSecretResponse, type SendMessageParams, ShipMailClient, type ShipMailConfig, ShipMailError, type StatusResponse, type TestWebhookResponse, type UpdateDomainParams, type UpdateMailboxParams, type UpdateWebhookParams, type UploadAvatarResponse, ValidationError, WEBHOOK_EVENT_TYPES, type Webhook, type WebhookDelivery, type WebhookEvent, type WebhookEventType, WebhookVerificationError, type WebhookWithSecret, ShipMailClient as default, verifyWebhook };
@@ -0,0 +1,346 @@
1
+ declare class Page<T> implements AsyncIterable<T> {
2
+ private readonly client;
3
+ private readonly path;
4
+ private readonly query;
5
+ constructor(client: ShipMailClient, path: string, query: Record<string, string | number | boolean | undefined>);
6
+ [Symbol.asyncIterator](): AsyncIterator<T>;
7
+ }
8
+
9
+ declare abstract class ApiResource {
10
+ protected readonly client: ShipMailClient;
11
+ constructor(client: ShipMailClient);
12
+ }
13
+
14
+ type ShipMailConfig = {
15
+ readonly apiKey: string;
16
+ readonly baseUrl?: string | undefined;
17
+ readonly maxRetries?: number | undefined;
18
+ readonly timeout?: number | undefined;
19
+ readonly fetch?: typeof fetch | undefined;
20
+ };
21
+ type PaginationParams = {
22
+ readonly cursor?: string | undefined;
23
+ readonly limit?: number | undefined;
24
+ };
25
+ type PaginatedResponse<T> = {
26
+ readonly data: readonly T[];
27
+ readonly pagination: {
28
+ readonly next_cursor: string | null;
29
+ readonly has_more: boolean;
30
+ };
31
+ };
32
+ type ErrorType = "validation_error" | "authentication_error" | "authorization_error" | "not_found" | "rate_limit_error" | "conflict" | "internal_error";
33
+ type ApiErrorBody = {
34
+ readonly error: {
35
+ readonly type: ErrorType;
36
+ readonly message: string;
37
+ readonly request_id?: string | undefined;
38
+ readonly details?: readonly {
39
+ readonly field: string;
40
+ readonly message: string;
41
+ }[] | undefined;
42
+ readonly retry_after?: number | undefined;
43
+ };
44
+ };
45
+ type EmailRecipient = {
46
+ readonly address: string;
47
+ readonly name?: string | null | undefined;
48
+ };
49
+ declare const WEBHOOK_EVENT_TYPES: readonly ["message.received", "message.queued", "message.sent", "message.delivered", "message.bounced", "message.complained", "domain.verified", "domain.verification_failed", "domain.degraded"];
50
+ type WebhookEventType = (typeof WEBHOOK_EVENT_TYPES)[number];
51
+ type StatusResponse = {
52
+ readonly status: string;
53
+ readonly version: string;
54
+ readonly time: string;
55
+ readonly request_id: string;
56
+ };
57
+
58
+ type Domain = {
59
+ readonly id: string;
60
+ readonly name: string;
61
+ readonly status: string;
62
+ readonly dns_provider: string | null;
63
+ readonly ownership_verified: boolean;
64
+ readonly mx_verified: boolean;
65
+ readonly spf_verified: boolean;
66
+ readonly dkim_verified: boolean;
67
+ readonly dmarc_verified: boolean;
68
+ readonly ses_verified: boolean;
69
+ readonly catch_all_mailbox_id: string | null;
70
+ readonly verified_at: string | null;
71
+ readonly created_at: string;
72
+ readonly updated_at: string;
73
+ };
74
+ type CreateDomainParams = {
75
+ readonly name: string;
76
+ };
77
+ type UpdateDomainParams = {
78
+ readonly catch_all_mailbox_id?: string | null | undefined;
79
+ };
80
+ type ListDomainsParams = PaginationParams;
81
+ type DomainVerificationResult = {
82
+ readonly all_verified: boolean;
83
+ readonly records: {
84
+ readonly ownership: boolean;
85
+ readonly mx: boolean;
86
+ readonly spf: boolean;
87
+ readonly dkim: boolean;
88
+ readonly dmarc: boolean;
89
+ };
90
+ readonly ses_verified: boolean;
91
+ readonly ses_error: boolean;
92
+ readonly existing_spf: string | null;
93
+ readonly suggested_spf: string | null;
94
+ readonly conflicting_mx: readonly string[];
95
+ };
96
+
97
+ declare class Domains extends ApiResource {
98
+ create(params: CreateDomainParams): Promise<Domain>;
99
+ list(params?: ListDomainsParams): Promise<PaginatedResponse<Domain>>;
100
+ listAutoPaginating(params?: Omit<ListDomainsParams, "cursor">): Page<Domain>;
101
+ get(id: string): Promise<Domain>;
102
+ update(id: string, params: UpdateDomainParams): Promise<Domain>;
103
+ delete(id: string): Promise<void>;
104
+ verify(id: string): Promise<DomainVerificationResult>;
105
+ }
106
+
107
+ type Mailbox = {
108
+ readonly id: string;
109
+ readonly domain_id: string;
110
+ readonly address: string;
111
+ readonly display_name: string | null;
112
+ readonly avatar_url: string | null;
113
+ readonly created_at: string;
114
+ readonly updated_at: string;
115
+ };
116
+ type CreateMailboxParams = {
117
+ readonly domain_id: string;
118
+ readonly address: string;
119
+ readonly display_name?: string | undefined;
120
+ };
121
+ type UpdateMailboxParams = {
122
+ readonly display_name?: string | null | undefined;
123
+ };
124
+ type ListMailboxesParams = PaginationParams & {
125
+ readonly domain_id?: string | undefined;
126
+ };
127
+ type UploadAvatarResponse = {
128
+ readonly avatar_url: string;
129
+ };
130
+
131
+ declare class Mailboxes extends ApiResource {
132
+ create(params: CreateMailboxParams): Promise<Mailbox>;
133
+ list(params?: ListMailboxesParams): Promise<PaginatedResponse<Mailbox>>;
134
+ listAutoPaginating(params?: Omit<ListMailboxesParams, "cursor">): Page<Mailbox>;
135
+ get(id: string): Promise<Mailbox>;
136
+ update(id: string, params: UpdateMailboxParams): Promise<Mailbox>;
137
+ delete(id: string): Promise<void>;
138
+ uploadAvatar(id: string, data: ArrayBuffer, contentType: string): Promise<UploadAvatarResponse>;
139
+ deleteAvatar(id: string): Promise<void>;
140
+ }
141
+
142
+ type Message = {
143
+ readonly id: string;
144
+ readonly mailbox_id: string;
145
+ readonly thread_id: string | null;
146
+ readonly source: string;
147
+ readonly status: string;
148
+ readonly created_at: string;
149
+ readonly updated_at: string;
150
+ };
151
+ type SendMessageParams = {
152
+ readonly mailbox_id: string;
153
+ readonly to: readonly EmailRecipient[];
154
+ readonly cc?: readonly EmailRecipient[] | undefined;
155
+ readonly bcc?: readonly EmailRecipient[] | undefined;
156
+ readonly reply_to?: EmailRecipient | undefined;
157
+ readonly subject: string;
158
+ readonly body_html?: string | undefined;
159
+ readonly body_text?: string | undefined;
160
+ readonly in_reply_to?: string | undefined;
161
+ readonly references?: readonly string[] | undefined;
162
+ };
163
+
164
+ declare class Messages extends ApiResource {
165
+ send(params: SendMessageParams): Promise<Message>;
166
+ get(id: string): Promise<Message>;
167
+ }
168
+
169
+ declare class Status extends ApiResource {
170
+ get(): Promise<StatusResponse>;
171
+ }
172
+
173
+ type ListThreadsParams = PaginationParams & {
174
+ readonly mailbox_id: string;
175
+ };
176
+ type GetThreadParams = PaginationParams;
177
+ type ReplyToThreadParams = {
178
+ readonly body_html?: string | undefined;
179
+ readonly body_text?: string | undefined;
180
+ readonly to?: readonly EmailRecipient[] | undefined;
181
+ readonly cc?: readonly EmailRecipient[] | undefined;
182
+ };
183
+
184
+ declare class Threads extends ApiResource {
185
+ list(params: ListThreadsParams): Promise<PaginatedResponse<Message>>;
186
+ listAutoPaginating(params: Omit<ListThreadsParams, "cursor">): Page<Message>;
187
+ get(id: string, params?: GetThreadParams): Promise<PaginatedResponse<Message>>;
188
+ reply(id: string, params: ReplyToThreadParams): Promise<Message>;
189
+ }
190
+
191
+ type Webhook = {
192
+ readonly id: string;
193
+ readonly url: string;
194
+ readonly events: readonly string[];
195
+ readonly active: boolean;
196
+ readonly description: string | null;
197
+ readonly created_at: string;
198
+ readonly updated_at: string;
199
+ };
200
+ type WebhookWithSecret = Webhook & {
201
+ readonly secret: string;
202
+ };
203
+ type CreateWebhookParams = {
204
+ readonly url: string;
205
+ readonly events: readonly WebhookEventType[];
206
+ readonly description?: string | undefined;
207
+ };
208
+ type UpdateWebhookParams = {
209
+ readonly url?: string | undefined;
210
+ readonly events?: readonly WebhookEventType[] | undefined;
211
+ readonly description?: string | null | undefined;
212
+ readonly active?: boolean | undefined;
213
+ };
214
+ type ListWebhooksParams = PaginationParams;
215
+ type RotateSecretResponse = {
216
+ readonly secret: string;
217
+ readonly previous_secret_expires_at: string;
218
+ };
219
+ type TestWebhookResponse = {
220
+ readonly event_id: string;
221
+ };
222
+ type WebhookDelivery = {
223
+ readonly id: string;
224
+ readonly event_id: string;
225
+ readonly event_type: string;
226
+ readonly status: string;
227
+ readonly attempts: number;
228
+ readonly last_status_code: number | null;
229
+ readonly last_error: string | null;
230
+ readonly created_at: string;
231
+ readonly delivered_at: string | null;
232
+ };
233
+ type ListDeliveriesParams = PaginationParams & {
234
+ readonly status?: string | undefined;
235
+ readonly event_type?: string | undefined;
236
+ };
237
+ type WebhookEvent<T = unknown> = {
238
+ readonly event_id: string;
239
+ readonly event_type: WebhookEventType;
240
+ readonly created_at: string;
241
+ readonly data: T;
242
+ };
243
+
244
+ declare class Webhooks extends ApiResource {
245
+ create(params: CreateWebhookParams): Promise<WebhookWithSecret>;
246
+ list(params?: ListWebhooksParams): Promise<PaginatedResponse<Webhook>>;
247
+ listAutoPaginating(params?: Omit<ListWebhooksParams, "cursor">): Page<Webhook>;
248
+ get(id: string): Promise<Webhook>;
249
+ update(id: string, params: UpdateWebhookParams): Promise<Webhook>;
250
+ delete(id: string): Promise<void>;
251
+ rotateSecret(id: string): Promise<RotateSecretResponse>;
252
+ test(id: string): Promise<TestWebhookResponse>;
253
+ listDeliveries(id: string, params?: ListDeliveriesParams): Promise<PaginatedResponse<WebhookDelivery>>;
254
+ listDeliveriesAutoPaginating(id: string, params?: Omit<ListDeliveriesParams, "cursor">): Page<WebhookDelivery>;
255
+ }
256
+
257
+ type RequestOptions = {
258
+ readonly method: string;
259
+ readonly path: string;
260
+ readonly body?: unknown | undefined;
261
+ readonly query?: Record<string, string | number | boolean | undefined> | undefined;
262
+ readonly rawBody?: ArrayBuffer | undefined;
263
+ readonly contentType?: string | undefined;
264
+ };
265
+ declare class ShipMailClient {
266
+ private readonly apiKey;
267
+ private readonly baseUrl;
268
+ private readonly maxRetries;
269
+ private readonly timeout;
270
+ private readonly fetchFn;
271
+ readonly domains: Domains;
272
+ readonly mailboxes: Mailboxes;
273
+ readonly messages: Messages;
274
+ readonly threads: Threads;
275
+ readonly webhooks: Webhooks;
276
+ readonly status: Status;
277
+ constructor(config: string | ShipMailConfig);
278
+ request<T>(options: RequestOptions): Promise<T>;
279
+ private buildUrl;
280
+ }
281
+
282
+ declare class ShipMailError extends Error {
283
+ readonly status: number | undefined;
284
+ readonly type: ErrorType | undefined;
285
+ readonly requestId: string | undefined;
286
+ readonly retryable: boolean;
287
+ constructor(message: string, options?: {
288
+ readonly status?: number | undefined;
289
+ readonly type?: ErrorType | undefined;
290
+ readonly requestId?: string | undefined;
291
+ readonly retryable?: boolean | undefined;
292
+ });
293
+ }
294
+ declare class AuthenticationError extends ShipMailError {
295
+ constructor(message: string, requestId?: string);
296
+ }
297
+ declare class AuthorizationError extends ShipMailError {
298
+ constructor(message: string, requestId?: string);
299
+ }
300
+ declare class ValidationError extends ShipMailError {
301
+ readonly details: readonly {
302
+ readonly field: string;
303
+ readonly message: string;
304
+ }[] | undefined;
305
+ constructor(message: string, options?: {
306
+ readonly requestId?: string | undefined;
307
+ readonly details?: readonly {
308
+ readonly field: string;
309
+ readonly message: string;
310
+ }[] | undefined;
311
+ });
312
+ }
313
+ declare class NotFoundError extends ShipMailError {
314
+ constructor(message: string, requestId?: string);
315
+ }
316
+ declare class RateLimitError extends ShipMailError {
317
+ readonly retryAfter: number | undefined;
318
+ constructor(message: string, options?: {
319
+ readonly requestId?: string | undefined;
320
+ readonly retryAfter?: number | undefined;
321
+ });
322
+ }
323
+ declare class ConflictError extends ShipMailError {
324
+ constructor(message: string, requestId?: string);
325
+ }
326
+ declare class InternalServerError extends ShipMailError {
327
+ constructor(message: string, requestId?: string);
328
+ }
329
+ declare class ConnectionError extends ShipMailError {
330
+ constructor(message: string);
331
+ }
332
+ declare class WebhookVerificationError extends ShipMailError {
333
+ constructor(message: string);
334
+ }
335
+
336
+ type WebhookHeaders = {
337
+ readonly "x-shipmail-signature"?: string;
338
+ readonly "x-shipmail-timestamp"?: string;
339
+ readonly "x-shipmail-event-id"?: string;
340
+ readonly [key: string]: string | undefined;
341
+ };
342
+ declare function verifyWebhook(body: string, headers: WebhookHeaders | Headers, secret: string, options?: {
343
+ readonly toleranceInSeconds?: number | undefined;
344
+ }): WebhookEvent;
345
+
346
+ export { type ApiErrorBody, AuthenticationError, AuthorizationError, ConflictError, ConnectionError, type CreateDomainParams, type CreateMailboxParams, type CreateWebhookParams, type Domain, type DomainVerificationResult, type EmailRecipient, type ErrorType, type GetThreadParams, InternalServerError, type ListDeliveriesParams, type ListDomainsParams, type ListMailboxesParams, type ListThreadsParams, type ListWebhooksParams, type Message, NotFoundError, Page, type PaginatedResponse, type PaginationParams, RateLimitError, type ReplyToThreadParams, type RotateSecretResponse, type SendMessageParams, ShipMailClient, type ShipMailConfig, ShipMailError, type StatusResponse, type TestWebhookResponse, type UpdateDomainParams, type UpdateMailboxParams, type UpdateWebhookParams, type UploadAvatarResponse, ValidationError, WEBHOOK_EVENT_TYPES, type Webhook, type WebhookDelivery, type WebhookEvent, type WebhookEventType, WebhookVerificationError, type WebhookWithSecret, ShipMailClient as default, verifyWebhook };