@masters-union/outbound-sdk 0.1.3 → 0.1.5
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 +113 -123
- package/dist/index.d.mts +36 -30
- package/dist/index.d.ts +36 -30
- package/dist/index.js +69 -58
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +69 -58
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,188 +2,178 @@
|
|
|
2
2
|
|
|
3
3
|
Official Node.js SDK for the [Outbound](https://github.com/AdarshChakrworty/outbound) email platform.
|
|
4
4
|
|
|
5
|
-
## Install
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
::: code-group
|
|
9
|
+
```bash [npm]
|
|
10
|
+
npm install @masters-union/outbound-sdk
|
|
11
|
+
```
|
|
12
|
+
```bash [yarn]
|
|
13
|
+
yarn add @masters-union/outbound-sdk
|
|
14
|
+
```
|
|
15
|
+
```bash [pnpm]
|
|
16
|
+
pnpm add @masters-union/outbound-sdk
|
|
9
17
|
```
|
|
18
|
+
:::
|
|
10
19
|
|
|
11
|
-
|
|
20
|
+
**Requirements:** Node.js 18+ (uses native `fetch`)
|
|
12
21
|
|
|
13
|
-
|
|
14
|
-
import { Outbound } from 'outbound-sdk';
|
|
22
|
+
## Quick Setup
|
|
15
23
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
24
|
+
### 1. Get your API key
|
|
25
|
+
|
|
26
|
+
Your Outbound admin will provide you with an API key. It looks like:
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
mu_outbound_a1b2c3d4e5f6...
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### 2. Initialize the client
|
|
19
33
|
|
|
20
|
-
|
|
34
|
+
::: code-group
|
|
35
|
+
```ts [ESM]
|
|
36
|
+
import { Outbound } from '@masters-union/outbound-sdk';
|
|
37
|
+
|
|
38
|
+
const outbound = new Outbound({ apiKey: 'mu_outbound_...' });
|
|
39
|
+
```
|
|
40
|
+
```js [CommonJS]
|
|
41
|
+
const { Outbound } = require('@masters-union/outbound-sdk');
|
|
42
|
+
|
|
43
|
+
const outbound = new Outbound({ apiKey: 'mu_outbound_...' });
|
|
21
44
|
```
|
|
45
|
+
:::
|
|
22
46
|
|
|
23
|
-
|
|
47
|
+
Once you set the API key in the constructor, every method uses it automatically. No need to pass it on every call.
|
|
24
48
|
|
|
25
|
-
### Send
|
|
49
|
+
### 3. Send your first email
|
|
26
50
|
|
|
27
51
|
```ts
|
|
28
|
-
const { jobId, messageId } = await outbound.email.send(
|
|
52
|
+
const { jobId, messageId } = await outbound.email.send({
|
|
29
53
|
toEmail: 'user@example.com',
|
|
30
|
-
fromEmail: 'noreply@
|
|
54
|
+
fromEmail: 'noreply@yourcompany.com', // must be a verified domain
|
|
31
55
|
emailSubject: 'Welcome!',
|
|
32
56
|
htmlBody: '<h1>Hello World</h1>',
|
|
33
57
|
});
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
### Send Bulk Emails
|
|
37
58
|
|
|
38
|
-
|
|
39
|
-
const result = await outbound.email.bulk(apiKey, {
|
|
40
|
-
fromEmail: 'noreply@company.com',
|
|
41
|
-
emailSubject: 'Newsletter',
|
|
42
|
-
emails: [
|
|
43
|
-
{ toEmail: 'alice@example.com', htmlBody: '<h1>Hi Alice</h1>' },
|
|
44
|
-
{ toEmail: 'bob@example.com', htmlBody: '<h1>Hi Bob</h1>' },
|
|
45
|
-
],
|
|
46
|
-
});
|
|
47
|
-
// result.recipientCount, result.jobId
|
|
59
|
+
console.log(`Email queued: ${jobId}`);
|
|
48
60
|
```
|
|
49
61
|
|
|
50
|
-
|
|
62
|
+
::: warning Verified Domains Only
|
|
63
|
+
The `fromEmail` must use a domain that has been verified and assigned to your tenant account by the admin. Sending from an unverified domain will return a `403 Forbidden` error.
|
|
64
|
+
:::
|
|
65
|
+
|
|
66
|
+
### 4. Check delivery status
|
|
51
67
|
|
|
52
68
|
```ts
|
|
53
|
-
const status = await outbound.email.status(
|
|
54
|
-
|
|
69
|
+
const status = await outbound.email.status(jobId);
|
|
70
|
+
|
|
71
|
+
for (const recipient of status.recipients) {
|
|
72
|
+
console.log(`${recipient.recipient_email}: ${recipient.status}`);
|
|
73
|
+
// "sent" → "delivered" → "opened" → "clicked"
|
|
74
|
+
}
|
|
55
75
|
```
|
|
56
76
|
|
|
57
|
-
###
|
|
77
|
+
### 5. Send with a template
|
|
58
78
|
|
|
59
79
|
```ts
|
|
60
|
-
// Create
|
|
61
|
-
const { template } = await outbound.templates.create(
|
|
62
|
-
name: 'welcome',
|
|
80
|
+
// Create a reusable template
|
|
81
|
+
const { template } = await outbound.templates.create({
|
|
82
|
+
name: 'welcome-email',
|
|
63
83
|
subject: 'Welcome {{firstName}}!',
|
|
64
|
-
htmlBody: '<h1>Hello {{firstName}}</h1>',
|
|
65
|
-
variables: ['firstName'],
|
|
84
|
+
htmlBody: '<h1>Hello {{firstName}}</h1><p>Welcome to {{company}}.</p>',
|
|
85
|
+
variables: ['firstName', 'company'],
|
|
66
86
|
});
|
|
67
87
|
|
|
68
|
-
//
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
// Send using template
|
|
72
|
-
const { jobId } = await outbound.templates.send(apiKey, {
|
|
88
|
+
// Send to one person
|
|
89
|
+
await outbound.templates.send({
|
|
73
90
|
templateId: template.id,
|
|
74
91
|
toEmail: 'user@example.com',
|
|
75
|
-
fromEmail: 'noreply@
|
|
76
|
-
variables: { firstName: 'John' },
|
|
92
|
+
fromEmail: 'noreply@yourcompany.com',
|
|
93
|
+
variables: { firstName: 'John', company: 'Acme' },
|
|
77
94
|
});
|
|
78
95
|
|
|
79
|
-
//
|
|
80
|
-
|
|
96
|
+
// Send to many people
|
|
97
|
+
await outbound.templates.bulkSend({
|
|
81
98
|
templateId: template.id,
|
|
82
|
-
fromEmail: 'noreply@
|
|
99
|
+
fromEmail: 'noreply@yourcompany.com',
|
|
83
100
|
recipients: [
|
|
84
|
-
{ toEmail: 'alice@example.com', variables: { firstName: 'Alice' } },
|
|
85
|
-
{ toEmail: 'bob@example.com', variables: { firstName: 'Bob' } },
|
|
101
|
+
{ toEmail: 'alice@example.com', variables: { firstName: 'Alice', company: 'Acme' } },
|
|
102
|
+
{ toEmail: 'bob@example.com', variables: { firstName: 'Bob', company: 'Acme' } },
|
|
86
103
|
],
|
|
87
104
|
});
|
|
88
|
-
|
|
89
|
-
// Preview
|
|
90
|
-
const preview = await outbound.templates.preview(apiKey, template.id, {
|
|
91
|
-
variables: { firstName: 'John' },
|
|
92
|
-
});
|
|
93
105
|
```
|
|
94
106
|
|
|
95
|
-
###
|
|
107
|
+
### 6. Multi-tenant usage
|
|
108
|
+
|
|
109
|
+
The SDK supports multi-tenant applications. You can override the API key on any individual call using the optional last argument:
|
|
96
110
|
|
|
97
111
|
```ts
|
|
98
|
-
//
|
|
99
|
-
await outbound.suppressions.add(apiKey, { email: 'bad@example.com', reason: 'manual' });
|
|
112
|
+
const outbound = new Outbound(); // no default apiKey
|
|
100
113
|
|
|
101
|
-
|
|
102
|
-
const
|
|
114
|
+
const tenantAKey = 'mu_outbound_tenant_a_...';
|
|
115
|
+
const tenantBKey = 'mu_outbound_tenant_b_...';
|
|
103
116
|
|
|
104
|
-
//
|
|
105
|
-
await outbound.
|
|
117
|
+
// Pass { apiKey } as the last argument to override per call
|
|
118
|
+
await outbound.email.send({ /* ... */ }, { apiKey: tenantAKey });
|
|
119
|
+
await outbound.email.send({ /* ... */ }, { apiKey: tenantBKey });
|
|
106
120
|
```
|
|
107
121
|
|
|
108
|
-
|
|
122
|
+
You can also set a default in the constructor and override only when needed:
|
|
109
123
|
|
|
110
124
|
```ts
|
|
111
|
-
//
|
|
112
|
-
const { webhook, secret } = await outbound.webhooks.create(apiKey, {
|
|
113
|
-
url: 'https://myapp.com/webhooks/outbound',
|
|
114
|
-
events: ['delivery', 'bounce', 'complaint'],
|
|
115
|
-
});
|
|
116
|
-
// Store `secret` securely for signature verification
|
|
125
|
+
const outbound = new Outbound({ apiKey: tenantAKey }); // default
|
|
117
126
|
|
|
118
|
-
//
|
|
119
|
-
|
|
127
|
+
await outbound.email.send({ /* ... */ }); // uses tenantAKey
|
|
128
|
+
await outbound.email.send({ /* ... */ }, { apiKey: tenantBKey }); // uses tenantBKey
|
|
120
129
|
```
|
|
121
130
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
```ts
|
|
125
|
-
const dashboard = await outbound.dashboard.get(apiKey);
|
|
126
|
-
// dashboard.last30Days.sent, dashboard.quota, etc.
|
|
131
|
+
## Key Concepts
|
|
127
132
|
|
|
128
|
-
|
|
129
|
-
// quota.dailyUsed, quota.monthlyUsed, quota.remaining
|
|
130
|
-
```
|
|
133
|
+
### Email Lifecycle
|
|
131
134
|
|
|
132
|
-
|
|
135
|
+
Every email goes through these statuses:
|
|
133
136
|
|
|
134
|
-
```
|
|
135
|
-
|
|
137
|
+
```
|
|
138
|
+
queued → processing → sent → delivered
|
|
139
|
+
↘ bounced
|
|
140
|
+
↘ complained
|
|
141
|
+
delivered → opened → clicked
|
|
142
|
+
```
|
|
136
143
|
|
|
137
|
-
|
|
138
|
-
|
|
144
|
+
| Status | Meaning |
|
|
145
|
+
|--------|---------|
|
|
146
|
+
| `queued` | Email is in the queue, waiting to be processed |
|
|
147
|
+
| `processing` | Email is being sent to AWS SES |
|
|
148
|
+
| `sent` | SES accepted the email |
|
|
149
|
+
| `delivered` | Email landed in recipient's inbox |
|
|
150
|
+
| `bounced` | Email bounced (bad address or mailbox full) |
|
|
151
|
+
| `complained` | Recipient marked it as spam |
|
|
152
|
+
| `opened` | Recipient opened the email (requires tracking) |
|
|
153
|
+
| `clicked` | Recipient clicked a link (requires tracking) |
|
|
154
|
+
| `failed` | Failed to send (SES rejection or error) |
|
|
139
155
|
|
|
140
|
-
|
|
141
|
-
await outbound.email.send(tenantAKey, { ... });
|
|
142
|
-
await outbound.email.send(tenantBKey, { ... });
|
|
143
|
-
```
|
|
156
|
+
### Suppression List
|
|
144
157
|
|
|
145
|
-
|
|
158
|
+
The platform automatically suppresses emails that bounce or receive complaints. You can also manually suppress emails. Any future send to a suppressed address is **silently filtered out** — it won't count against your quota.
|
|
146
159
|
|
|
147
|
-
|
|
148
|
-
|--------|---------|-------------|
|
|
149
|
-
| `baseUrl` | `https://outbound-api.mastersunion.org` | API base URL |
|
|
150
|
-
| `timeout` | `30000` | Request timeout in ms |
|
|
151
|
-
| `maxRetries` | `3` | Max retries on 429/5xx |
|
|
152
|
-
| `retryDelay` | `1000` | Initial retry delay in ms (exponential backoff) |
|
|
160
|
+
### Quotas
|
|
153
161
|
|
|
154
|
-
|
|
162
|
+
Your tenant account has:
|
|
163
|
+
- **Daily limit** — Max emails per day
|
|
164
|
+
- **Monthly limit** — Max emails per month
|
|
165
|
+
- **Rate limit** — Max emails per second
|
|
166
|
+
- **Template limit** — Max number of templates
|
|
155
167
|
|
|
156
|
-
|
|
168
|
+
Check your quota anytime with `outbound.dashboard.quota()`.
|
|
157
169
|
|
|
158
|
-
|
|
159
|
-
import { Outbound, RateLimitError, NotFoundError } from 'outbound-sdk';
|
|
160
|
-
|
|
161
|
-
try {
|
|
162
|
-
await outbound.email.send(apiKey, { ... });
|
|
163
|
-
} catch (err) {
|
|
164
|
-
if (err instanceof RateLimitError) {
|
|
165
|
-
console.log(`Rate limited. Retry after ${err.retryAfter}s`);
|
|
166
|
-
} else if (err instanceof NotFoundError) {
|
|
167
|
-
console.log('Resource not found');
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
```
|
|
170
|
+
## What's Next?
|
|
171
171
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
| `NotFoundError` | 404 |
|
|
178
|
-
| `ConflictError` | 409 |
|
|
179
|
-
| `RateLimitError` | 429 |
|
|
180
|
-
| `ServerError` | 5xx |
|
|
181
|
-
| `TimeoutError` | - |
|
|
182
|
-
| `NetworkError` | - |
|
|
183
|
-
|
|
184
|
-
## Requirements
|
|
185
|
-
|
|
186
|
-
- Node.js 18+ (uses native `fetch`)
|
|
172
|
+
- [Configuration](/guide/configuration) — Customize timeouts, retries, and more
|
|
173
|
+
- [Error Handling](/guide/error-handling) — Handle every error type
|
|
174
|
+
- [Email API](/api/email) — Single and bulk sending reference
|
|
175
|
+
- [Templates API](/api/templates) — Full template lifecycle
|
|
176
|
+
- [Webhooks API](/api/webhooks) — Real-time event notifications
|
|
187
177
|
|
|
188
178
|
## License
|
|
189
179
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
interface OutboundConfig {
|
|
2
|
+
apiKey?: string;
|
|
2
3
|
baseUrl?: string;
|
|
3
4
|
timeout?: number;
|
|
4
5
|
maxRetries?: number;
|
|
5
6
|
retryDelay?: number;
|
|
6
7
|
}
|
|
7
8
|
interface ResolvedConfig {
|
|
9
|
+
apiKey?: string;
|
|
8
10
|
baseUrl: string;
|
|
9
11
|
timeout: number;
|
|
10
12
|
maxRetries: number;
|
|
11
13
|
retryDelay: number;
|
|
12
14
|
}
|
|
15
|
+
interface RequestOverrides {
|
|
16
|
+
apiKey?: string;
|
|
17
|
+
}
|
|
13
18
|
interface SendEmailParams {
|
|
14
19
|
toEmail: string;
|
|
15
20
|
fromEmail: string;
|
|
@@ -296,10 +301,11 @@ interface QuotaResponse {
|
|
|
296
301
|
declare class HttpClient {
|
|
297
302
|
private config;
|
|
298
303
|
constructor(config: ResolvedConfig);
|
|
299
|
-
get<T>(
|
|
300
|
-
post<T>(
|
|
301
|
-
patch<T>(
|
|
302
|
-
delete<T>(
|
|
304
|
+
get<T>(path: string, params?: Record<string, unknown>, apiKey?: string): Promise<T>;
|
|
305
|
+
post<T>(path: string, body?: unknown, apiKey?: string): Promise<T>;
|
|
306
|
+
patch<T>(path: string, body?: unknown, apiKey?: string): Promise<T>;
|
|
307
|
+
delete<T>(path: string, apiKey?: string): Promise<T>;
|
|
308
|
+
private resolveApiKey;
|
|
303
309
|
private request;
|
|
304
310
|
private buildUrl;
|
|
305
311
|
private parseError;
|
|
@@ -309,39 +315,39 @@ declare class HttpClient {
|
|
|
309
315
|
declare class EmailResource {
|
|
310
316
|
private http;
|
|
311
317
|
constructor(http: HttpClient);
|
|
312
|
-
send(
|
|
313
|
-
bulk(
|
|
314
|
-
status(
|
|
318
|
+
send(params: SendEmailParams, overrides?: RequestOverrides): Promise<SendEmailResponse>;
|
|
319
|
+
bulk(params: BulkEmailParams, overrides?: RequestOverrides): Promise<BulkEmailResponse>;
|
|
320
|
+
status(jobId: string, overrides?: RequestOverrides): Promise<JobStatusResponse>;
|
|
315
321
|
}
|
|
316
322
|
|
|
317
323
|
declare class TemplatesResource {
|
|
318
324
|
private http;
|
|
319
325
|
constructor(http: HttpClient);
|
|
320
|
-
create(
|
|
321
|
-
list(
|
|
322
|
-
listAll(
|
|
323
|
-
get(
|
|
324
|
-
update(
|
|
325
|
-
delete(
|
|
326
|
+
create(params: CreateTemplateParams, overrides?: RequestOverrides): Promise<TemplateResponse>;
|
|
327
|
+
list(params?: ListTemplatesParams, overrides?: RequestOverrides): Promise<ListTemplatesResponse>;
|
|
328
|
+
listAll(params?: Omit<ListTemplatesParams, 'page'>, overrides?: RequestOverrides): AsyncGenerator<Template>;
|
|
329
|
+
get(id: string, overrides?: RequestOverrides): Promise<TemplateResponse>;
|
|
330
|
+
update(id: string, params: UpdateTemplateParams, overrides?: RequestOverrides): Promise<TemplateResponse>;
|
|
331
|
+
delete(id: string, overrides?: RequestOverrides): Promise<{
|
|
326
332
|
message: string;
|
|
327
333
|
id: string;
|
|
328
334
|
}>;
|
|
329
|
-
duplicate(
|
|
335
|
+
duplicate(id: string, params?: {
|
|
330
336
|
name?: string;
|
|
331
|
-
}): Promise<TemplateResponse>;
|
|
332
|
-
preview(
|
|
333
|
-
send(
|
|
334
|
-
bulkSend(
|
|
335
|
-
stats(
|
|
337
|
+
}, overrides?: RequestOverrides): Promise<TemplateResponse>;
|
|
338
|
+
preview(id: string, params?: TemplatePreviewParams, overrides?: RequestOverrides): Promise<TemplatePreviewResponse>;
|
|
339
|
+
send(params: TemplateSendParams, overrides?: RequestOverrides): Promise<SendEmailResponse>;
|
|
340
|
+
bulkSend(params: TemplateBulkSendParams, overrides?: RequestOverrides): Promise<TemplateBulkSendResponse>;
|
|
341
|
+
stats(overrides?: RequestOverrides): Promise<TemplateStatsResponse>;
|
|
336
342
|
}
|
|
337
343
|
|
|
338
344
|
declare class SuppressionsResource {
|
|
339
345
|
private http;
|
|
340
346
|
constructor(http: HttpClient);
|
|
341
|
-
list(
|
|
342
|
-
listAll(
|
|
343
|
-
add(
|
|
344
|
-
remove(
|
|
347
|
+
list(params?: ListSuppressionsParams, overrides?: RequestOverrides): Promise<ListSuppressionsResponse>;
|
|
348
|
+
listAll(params?: Omit<ListSuppressionsParams, 'page'>, overrides?: RequestOverrides): AsyncGenerator<Suppression>;
|
|
349
|
+
add(params: AddSuppressionParams, overrides?: RequestOverrides): Promise<SuppressionResponse>;
|
|
350
|
+
remove(email: string, overrides?: RequestOverrides): Promise<{
|
|
345
351
|
message: string;
|
|
346
352
|
}>;
|
|
347
353
|
}
|
|
@@ -349,10 +355,10 @@ declare class SuppressionsResource {
|
|
|
349
355
|
declare class WebhooksResource {
|
|
350
356
|
private http;
|
|
351
357
|
constructor(http: HttpClient);
|
|
352
|
-
create(
|
|
353
|
-
list(
|
|
354
|
-
update(
|
|
355
|
-
delete(
|
|
358
|
+
create(params: CreateWebhookParams, overrides?: RequestOverrides): Promise<CreateWebhookResponse>;
|
|
359
|
+
list(overrides?: RequestOverrides): Promise<ListWebhooksResponse>;
|
|
360
|
+
update(id: string, params: UpdateWebhookParams, overrides?: RequestOverrides): Promise<UpdateWebhookResponse>;
|
|
361
|
+
delete(id: string, overrides?: RequestOverrides): Promise<{
|
|
356
362
|
message: string;
|
|
357
363
|
id: string;
|
|
358
364
|
}>;
|
|
@@ -361,8 +367,8 @@ declare class WebhooksResource {
|
|
|
361
367
|
declare class DashboardResource {
|
|
362
368
|
private http;
|
|
363
369
|
constructor(http: HttpClient);
|
|
364
|
-
get(
|
|
365
|
-
quota(
|
|
370
|
+
get(overrides?: RequestOverrides): Promise<DashboardResponse>;
|
|
371
|
+
quota(overrides?: RequestOverrides): Promise<QuotaResponse>;
|
|
366
372
|
}
|
|
367
373
|
|
|
368
374
|
declare class Outbound {
|
|
@@ -414,4 +420,4 @@ declare class NetworkError extends OutboundError {
|
|
|
414
420
|
constructor(message?: string);
|
|
415
421
|
}
|
|
416
422
|
|
|
417
|
-
export { type AddSuppressionParams, type Attachment, AuthenticationError, BadRequestError, type BulkEmailParams, type BulkEmailRecipient, type BulkEmailResponse, ConflictError, type CreateTemplateParams, type CreateWebhookParams, type CreateWebhookResponse, type DashboardResponse, type EmailRecipientStatus, type EmailStatus, ForbiddenError, type JobStatusResponse, type ListSuppressionsParams, type ListSuppressionsResponse, type ListTemplatesParams, type ListTemplatesResponse, type ListWebhooksResponse, NetworkError, NotFoundError, Outbound, type OutboundConfig, OutboundError, type QuotaResponse, RateLimitError, type ResolvedConfig, type SendEmailParams, type SendEmailResponse, ServerError, type Suppression, type SuppressionResponse, type Template, type TemplateBulkRecipient, type TemplateBulkSendParams, type TemplateBulkSendResponse, type TemplatePreviewParams, type TemplatePreviewResponse, type TemplateResponse, type TemplateSendParams, type TemplateStatsResponse, TimeoutError, type UpdateTemplateParams, type UpdateWebhookParams, type UpdateWebhookResponse, type Webhook, type WebhookEvent };
|
|
423
|
+
export { type AddSuppressionParams, type Attachment, AuthenticationError, BadRequestError, type BulkEmailParams, type BulkEmailRecipient, type BulkEmailResponse, ConflictError, type CreateTemplateParams, type CreateWebhookParams, type CreateWebhookResponse, type DashboardResponse, type EmailRecipientStatus, type EmailStatus, ForbiddenError, type JobStatusResponse, type ListSuppressionsParams, type ListSuppressionsResponse, type ListTemplatesParams, type ListTemplatesResponse, type ListWebhooksResponse, NetworkError, NotFoundError, Outbound, type OutboundConfig, OutboundError, type QuotaResponse, RateLimitError, type RequestOverrides, type ResolvedConfig, type SendEmailParams, type SendEmailResponse, ServerError, type Suppression, type SuppressionResponse, type Template, type TemplateBulkRecipient, type TemplateBulkSendParams, type TemplateBulkSendResponse, type TemplatePreviewParams, type TemplatePreviewResponse, type TemplateResponse, type TemplateSendParams, type TemplateStatsResponse, TimeoutError, type UpdateTemplateParams, type UpdateWebhookParams, type UpdateWebhookResponse, type Webhook, type WebhookEvent };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
interface OutboundConfig {
|
|
2
|
+
apiKey?: string;
|
|
2
3
|
baseUrl?: string;
|
|
3
4
|
timeout?: number;
|
|
4
5
|
maxRetries?: number;
|
|
5
6
|
retryDelay?: number;
|
|
6
7
|
}
|
|
7
8
|
interface ResolvedConfig {
|
|
9
|
+
apiKey?: string;
|
|
8
10
|
baseUrl: string;
|
|
9
11
|
timeout: number;
|
|
10
12
|
maxRetries: number;
|
|
11
13
|
retryDelay: number;
|
|
12
14
|
}
|
|
15
|
+
interface RequestOverrides {
|
|
16
|
+
apiKey?: string;
|
|
17
|
+
}
|
|
13
18
|
interface SendEmailParams {
|
|
14
19
|
toEmail: string;
|
|
15
20
|
fromEmail: string;
|
|
@@ -296,10 +301,11 @@ interface QuotaResponse {
|
|
|
296
301
|
declare class HttpClient {
|
|
297
302
|
private config;
|
|
298
303
|
constructor(config: ResolvedConfig);
|
|
299
|
-
get<T>(
|
|
300
|
-
post<T>(
|
|
301
|
-
patch<T>(
|
|
302
|
-
delete<T>(
|
|
304
|
+
get<T>(path: string, params?: Record<string, unknown>, apiKey?: string): Promise<T>;
|
|
305
|
+
post<T>(path: string, body?: unknown, apiKey?: string): Promise<T>;
|
|
306
|
+
patch<T>(path: string, body?: unknown, apiKey?: string): Promise<T>;
|
|
307
|
+
delete<T>(path: string, apiKey?: string): Promise<T>;
|
|
308
|
+
private resolveApiKey;
|
|
303
309
|
private request;
|
|
304
310
|
private buildUrl;
|
|
305
311
|
private parseError;
|
|
@@ -309,39 +315,39 @@ declare class HttpClient {
|
|
|
309
315
|
declare class EmailResource {
|
|
310
316
|
private http;
|
|
311
317
|
constructor(http: HttpClient);
|
|
312
|
-
send(
|
|
313
|
-
bulk(
|
|
314
|
-
status(
|
|
318
|
+
send(params: SendEmailParams, overrides?: RequestOverrides): Promise<SendEmailResponse>;
|
|
319
|
+
bulk(params: BulkEmailParams, overrides?: RequestOverrides): Promise<BulkEmailResponse>;
|
|
320
|
+
status(jobId: string, overrides?: RequestOverrides): Promise<JobStatusResponse>;
|
|
315
321
|
}
|
|
316
322
|
|
|
317
323
|
declare class TemplatesResource {
|
|
318
324
|
private http;
|
|
319
325
|
constructor(http: HttpClient);
|
|
320
|
-
create(
|
|
321
|
-
list(
|
|
322
|
-
listAll(
|
|
323
|
-
get(
|
|
324
|
-
update(
|
|
325
|
-
delete(
|
|
326
|
+
create(params: CreateTemplateParams, overrides?: RequestOverrides): Promise<TemplateResponse>;
|
|
327
|
+
list(params?: ListTemplatesParams, overrides?: RequestOverrides): Promise<ListTemplatesResponse>;
|
|
328
|
+
listAll(params?: Omit<ListTemplatesParams, 'page'>, overrides?: RequestOverrides): AsyncGenerator<Template>;
|
|
329
|
+
get(id: string, overrides?: RequestOverrides): Promise<TemplateResponse>;
|
|
330
|
+
update(id: string, params: UpdateTemplateParams, overrides?: RequestOverrides): Promise<TemplateResponse>;
|
|
331
|
+
delete(id: string, overrides?: RequestOverrides): Promise<{
|
|
326
332
|
message: string;
|
|
327
333
|
id: string;
|
|
328
334
|
}>;
|
|
329
|
-
duplicate(
|
|
335
|
+
duplicate(id: string, params?: {
|
|
330
336
|
name?: string;
|
|
331
|
-
}): Promise<TemplateResponse>;
|
|
332
|
-
preview(
|
|
333
|
-
send(
|
|
334
|
-
bulkSend(
|
|
335
|
-
stats(
|
|
337
|
+
}, overrides?: RequestOverrides): Promise<TemplateResponse>;
|
|
338
|
+
preview(id: string, params?: TemplatePreviewParams, overrides?: RequestOverrides): Promise<TemplatePreviewResponse>;
|
|
339
|
+
send(params: TemplateSendParams, overrides?: RequestOverrides): Promise<SendEmailResponse>;
|
|
340
|
+
bulkSend(params: TemplateBulkSendParams, overrides?: RequestOverrides): Promise<TemplateBulkSendResponse>;
|
|
341
|
+
stats(overrides?: RequestOverrides): Promise<TemplateStatsResponse>;
|
|
336
342
|
}
|
|
337
343
|
|
|
338
344
|
declare class SuppressionsResource {
|
|
339
345
|
private http;
|
|
340
346
|
constructor(http: HttpClient);
|
|
341
|
-
list(
|
|
342
|
-
listAll(
|
|
343
|
-
add(
|
|
344
|
-
remove(
|
|
347
|
+
list(params?: ListSuppressionsParams, overrides?: RequestOverrides): Promise<ListSuppressionsResponse>;
|
|
348
|
+
listAll(params?: Omit<ListSuppressionsParams, 'page'>, overrides?: RequestOverrides): AsyncGenerator<Suppression>;
|
|
349
|
+
add(params: AddSuppressionParams, overrides?: RequestOverrides): Promise<SuppressionResponse>;
|
|
350
|
+
remove(email: string, overrides?: RequestOverrides): Promise<{
|
|
345
351
|
message: string;
|
|
346
352
|
}>;
|
|
347
353
|
}
|
|
@@ -349,10 +355,10 @@ declare class SuppressionsResource {
|
|
|
349
355
|
declare class WebhooksResource {
|
|
350
356
|
private http;
|
|
351
357
|
constructor(http: HttpClient);
|
|
352
|
-
create(
|
|
353
|
-
list(
|
|
354
|
-
update(
|
|
355
|
-
delete(
|
|
358
|
+
create(params: CreateWebhookParams, overrides?: RequestOverrides): Promise<CreateWebhookResponse>;
|
|
359
|
+
list(overrides?: RequestOverrides): Promise<ListWebhooksResponse>;
|
|
360
|
+
update(id: string, params: UpdateWebhookParams, overrides?: RequestOverrides): Promise<UpdateWebhookResponse>;
|
|
361
|
+
delete(id: string, overrides?: RequestOverrides): Promise<{
|
|
356
362
|
message: string;
|
|
357
363
|
id: string;
|
|
358
364
|
}>;
|
|
@@ -361,8 +367,8 @@ declare class WebhooksResource {
|
|
|
361
367
|
declare class DashboardResource {
|
|
362
368
|
private http;
|
|
363
369
|
constructor(http: HttpClient);
|
|
364
|
-
get(
|
|
365
|
-
quota(
|
|
370
|
+
get(overrides?: RequestOverrides): Promise<DashboardResponse>;
|
|
371
|
+
quota(overrides?: RequestOverrides): Promise<QuotaResponse>;
|
|
366
372
|
}
|
|
367
373
|
|
|
368
374
|
declare class Outbound {
|
|
@@ -414,4 +420,4 @@ declare class NetworkError extends OutboundError {
|
|
|
414
420
|
constructor(message?: string);
|
|
415
421
|
}
|
|
416
422
|
|
|
417
|
-
export { type AddSuppressionParams, type Attachment, AuthenticationError, BadRequestError, type BulkEmailParams, type BulkEmailRecipient, type BulkEmailResponse, ConflictError, type CreateTemplateParams, type CreateWebhookParams, type CreateWebhookResponse, type DashboardResponse, type EmailRecipientStatus, type EmailStatus, ForbiddenError, type JobStatusResponse, type ListSuppressionsParams, type ListSuppressionsResponse, type ListTemplatesParams, type ListTemplatesResponse, type ListWebhooksResponse, NetworkError, NotFoundError, Outbound, type OutboundConfig, OutboundError, type QuotaResponse, RateLimitError, type ResolvedConfig, type SendEmailParams, type SendEmailResponse, ServerError, type Suppression, type SuppressionResponse, type Template, type TemplateBulkRecipient, type TemplateBulkSendParams, type TemplateBulkSendResponse, type TemplatePreviewParams, type TemplatePreviewResponse, type TemplateResponse, type TemplateSendParams, type TemplateStatsResponse, TimeoutError, type UpdateTemplateParams, type UpdateWebhookParams, type UpdateWebhookResponse, type Webhook, type WebhookEvent };
|
|
423
|
+
export { type AddSuppressionParams, type Attachment, AuthenticationError, BadRequestError, type BulkEmailParams, type BulkEmailRecipient, type BulkEmailResponse, ConflictError, type CreateTemplateParams, type CreateWebhookParams, type CreateWebhookResponse, type DashboardResponse, type EmailRecipientStatus, type EmailStatus, ForbiddenError, type JobStatusResponse, type ListSuppressionsParams, type ListSuppressionsResponse, type ListTemplatesParams, type ListTemplatesResponse, type ListWebhooksResponse, NetworkError, NotFoundError, Outbound, type OutboundConfig, OutboundError, type QuotaResponse, RateLimitError, type RequestOverrides, type ResolvedConfig, type SendEmailParams, type SendEmailResponse, ServerError, type Suppression, type SuppressionResponse, type Template, type TemplateBulkRecipient, type TemplateBulkSendParams, type TemplateBulkSendResponse, type TemplatePreviewParams, type TemplatePreviewResponse, type TemplateResponse, type TemplateSendParams, type TemplateStatsResponse, TimeoutError, type UpdateTemplateParams, type UpdateWebhookParams, type UpdateWebhookResponse, type Webhook, type WebhookEvent };
|