notideus 1.0.1 → 1.1.1
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 +23 -0
- package/dist/index.cjs +183 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +210 -1
- package/dist/index.d.ts +210 -1
- package/dist/index.js +183 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -81,6 +81,26 @@ if (page.next_cursor) {
|
|
|
81
81
|
}
|
|
82
82
|
```
|
|
83
83
|
|
|
84
|
+
### Webhooks
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
const created = await notideus.webhooks.create({ name: 'Production API', url: 'https://example.com/hook', events: ['email.delivered'] });
|
|
88
|
+
console.log(created.secret); // whsec_… — shown once
|
|
89
|
+
await notideus.webhooks.update(created.endpoint.id, { name: 'Production API', url: 'https://example.com/hook', events: ['email.delivered'], status: 'disabled' });
|
|
90
|
+
const log = await notideus.webhooks.deliveries.list({ endpoint_id: created.endpoint.id });
|
|
91
|
+
await notideus.webhooks.deliveries.redeliver(log.data[0].id);
|
|
92
|
+
const events = await notideus.webhooks.events();
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Inbound email
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
const routes = await notideus.inbound.routes.list(); // { data, meta }
|
|
99
|
+
await notideus.inbound.routes.create({ domain_id, recipient: 'support', store: true });
|
|
100
|
+
const inbox = await notideus.inbound.messages.list({ q: 'billing' });
|
|
101
|
+
const raw = await notideus.inbound.messages.raw(inbox.data[0].id); // { data, contentType, filename }
|
|
102
|
+
```
|
|
103
|
+
|
|
84
104
|
### Hosted unsubscribe (token-based, unauthenticated)
|
|
85
105
|
|
|
86
106
|
```ts
|
|
@@ -110,6 +130,9 @@ try {
|
|
|
110
130
|
if (err instanceof NotideusError && err.code === 'rate_limited') {
|
|
111
131
|
// err.retryAfter = seconds to wait
|
|
112
132
|
}
|
|
133
|
+
if (err instanceof NotideusError && err.code === 'account_suspended') {
|
|
134
|
+
// err.reason = optional admin note explaining the suspension
|
|
135
|
+
}
|
|
113
136
|
}
|
|
114
137
|
```
|
|
115
138
|
|
package/dist/index.cjs
CHANGED
|
@@ -30,12 +30,14 @@ var NotideusError = class extends Error {
|
|
|
30
30
|
code;
|
|
31
31
|
status;
|
|
32
32
|
retryAfter;
|
|
33
|
+
reason;
|
|
33
34
|
constructor(options) {
|
|
34
35
|
super(options.message);
|
|
35
36
|
this.name = "NotideusError";
|
|
36
37
|
this.code = options.code;
|
|
37
38
|
this.status = options.status;
|
|
38
39
|
this.retryAfter = options.retryAfter;
|
|
40
|
+
this.reason = options.reason;
|
|
39
41
|
}
|
|
40
42
|
};
|
|
41
43
|
|
|
@@ -71,6 +73,44 @@ var ApiClient = class {
|
|
|
71
73
|
}
|
|
72
74
|
}
|
|
73
75
|
}
|
|
76
|
+
// requestBinary downloads a binary endpoint (raw MIME, attachments). Auth
|
|
77
|
+
// headers are attached like request(); non-2xx responses raise NotideusError
|
|
78
|
+
// with the standard envelope. No retries — callers can re-invoke.
|
|
79
|
+
async requestBinary(path, options = {}) {
|
|
80
|
+
const headers = {
|
|
81
|
+
"User-Agent": `notideus-node/${VERSION}`
|
|
82
|
+
};
|
|
83
|
+
if (this.apiKey) headers.Authorization = `Bearer ${this.apiKey}`;
|
|
84
|
+
const controller = new AbortController();
|
|
85
|
+
const timer = setTimeout(() => controller.abort(), this.timeout);
|
|
86
|
+
const onCallerAbort = () => controller.abort();
|
|
87
|
+
if (options.signal) {
|
|
88
|
+
if (options.signal.aborted) controller.abort();
|
|
89
|
+
else options.signal.addEventListener("abort", onCallerAbort, { once: true });
|
|
90
|
+
}
|
|
91
|
+
try {
|
|
92
|
+
const res = await fetch(new URL(path, this.baseURL), { headers, signal: controller.signal });
|
|
93
|
+
if (!res.ok) throw await this.toError(res);
|
|
94
|
+
const disposition = res.headers.get("content-disposition") ?? "";
|
|
95
|
+
const match = CONTENT_DISPOSITION_FILENAME.exec(disposition);
|
|
96
|
+
return {
|
|
97
|
+
data: new Uint8Array(await res.arrayBuffer()),
|
|
98
|
+
contentType: res.headers.get("content-type") ?? "application/octet-stream",
|
|
99
|
+
filename: match ? match[1] : null
|
|
100
|
+
};
|
|
101
|
+
} catch (err) {
|
|
102
|
+
if (err instanceof NotideusError) throw err;
|
|
103
|
+
if (options.signal?.aborted) throw err;
|
|
104
|
+
throw new NotideusError({
|
|
105
|
+
code: controller.signal.aborted ? "request_timeout" : "network_error",
|
|
106
|
+
message: err instanceof Error ? err.message : String(err),
|
|
107
|
+
status: 0
|
|
108
|
+
});
|
|
109
|
+
} finally {
|
|
110
|
+
clearTimeout(timer);
|
|
111
|
+
options.signal?.removeEventListener("abort", onCallerAbort);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
74
114
|
delayMs(err, attempt) {
|
|
75
115
|
if (err instanceof NotideusError && err.retryAfter != null) {
|
|
76
116
|
return err.retryAfter * 1e3;
|
|
@@ -127,10 +167,12 @@ var ApiClient = class {
|
|
|
127
167
|
async toError(response) {
|
|
128
168
|
let code = "unknown_error";
|
|
129
169
|
let message = response.statusText || `HTTP ${response.status}`;
|
|
170
|
+
let reason;
|
|
130
171
|
try {
|
|
131
172
|
const parsed = await response.json();
|
|
132
173
|
if (parsed.error?.code) code = parsed.error.code;
|
|
133
174
|
if (parsed.error?.message) message = parsed.error.message;
|
|
175
|
+
if (typeof parsed.error?.reason === "string") reason = parsed.error.reason;
|
|
134
176
|
} catch {
|
|
135
177
|
}
|
|
136
178
|
const retryAfterHeader = response.headers.get("retry-after");
|
|
@@ -138,10 +180,12 @@ var ApiClient = class {
|
|
|
138
180
|
code,
|
|
139
181
|
message,
|
|
140
182
|
status: response.status,
|
|
141
|
-
retryAfter: retryAfterHeader ? Number(retryAfterHeader) : void 0
|
|
183
|
+
retryAfter: retryAfterHeader ? Number(retryAfterHeader) : void 0,
|
|
184
|
+
reason
|
|
142
185
|
});
|
|
143
186
|
}
|
|
144
187
|
};
|
|
188
|
+
var CONTENT_DISPOSITION_FILENAME = /filename="?([^";]+)"?/;
|
|
145
189
|
function hasIdempotencyKey(body) {
|
|
146
190
|
return typeof body === "object" && body !== null && body.idempotency_key != null;
|
|
147
191
|
}
|
|
@@ -209,6 +253,68 @@ var EmailsResource = class {
|
|
|
209
253
|
}
|
|
210
254
|
};
|
|
211
255
|
|
|
256
|
+
// src/resources/inbound.ts
|
|
257
|
+
function routePath(id) {
|
|
258
|
+
return `/v1/inbound/routes/${encodeURIComponent(id)}`;
|
|
259
|
+
}
|
|
260
|
+
function messagePath(id) {
|
|
261
|
+
return `/v1/inbound/messages/${encodeURIComponent(id)}`;
|
|
262
|
+
}
|
|
263
|
+
var InboundRoutesResource = class {
|
|
264
|
+
constructor(client) {
|
|
265
|
+
this.client = client;
|
|
266
|
+
}
|
|
267
|
+
client;
|
|
268
|
+
async list() {
|
|
269
|
+
return this.client.request("GET", "/v1/inbound/routes");
|
|
270
|
+
}
|
|
271
|
+
async create(params) {
|
|
272
|
+
const res = await this.client.request("POST", "/v1/inbound/routes", { body: params });
|
|
273
|
+
return res.route;
|
|
274
|
+
}
|
|
275
|
+
async get(id) {
|
|
276
|
+
const res = await this.client.request("GET", routePath(id));
|
|
277
|
+
return res.route;
|
|
278
|
+
}
|
|
279
|
+
async update(id, params) {
|
|
280
|
+
const res = await this.client.request("PATCH", routePath(id), { body: params });
|
|
281
|
+
return res.route;
|
|
282
|
+
}
|
|
283
|
+
async delete(id) {
|
|
284
|
+
await this.client.request("DELETE", routePath(id));
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
var InboundMessagesResource = class {
|
|
288
|
+
constructor(client) {
|
|
289
|
+
this.client = client;
|
|
290
|
+
}
|
|
291
|
+
client;
|
|
292
|
+
async list(params = {}) {
|
|
293
|
+
const { q, route_id, cursor, limit } = params;
|
|
294
|
+
return this.client.request("GET", "/v1/inbound/messages", {
|
|
295
|
+
query: { q, route_id, cursor, limit }
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
async get(id) {
|
|
299
|
+
const res = await this.client.request("GET", messagePath(id));
|
|
300
|
+
return res.message;
|
|
301
|
+
}
|
|
302
|
+
async raw(id, options = {}) {
|
|
303
|
+
return this.client.requestBinary(`${messagePath(id)}/raw`, options);
|
|
304
|
+
}
|
|
305
|
+
async attachment(messageId, index, options = {}) {
|
|
306
|
+
return this.client.requestBinary(`${messagePath(messageId)}/attachments/${index}`, options);
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
var InboundResource = class {
|
|
310
|
+
routes;
|
|
311
|
+
messages;
|
|
312
|
+
constructor(client) {
|
|
313
|
+
this.routes = new InboundRoutesResource(client);
|
|
314
|
+
this.messages = new InboundMessagesResource(client);
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
|
|
212
318
|
// src/resources/plans.ts
|
|
213
319
|
var PlansResource = class {
|
|
214
320
|
constructor(client) {
|
|
@@ -250,6 +356,78 @@ var UnsubscribeResource = class {
|
|
|
250
356
|
}
|
|
251
357
|
};
|
|
252
358
|
|
|
359
|
+
// src/resources/webhook-deliveries.ts
|
|
360
|
+
function deliveryPath(id) {
|
|
361
|
+
return `/v1/webhook-deliveries/${encodeURIComponent(id)}`;
|
|
362
|
+
}
|
|
363
|
+
var WebhookDeliveriesResource = class {
|
|
364
|
+
constructor(client) {
|
|
365
|
+
this.client = client;
|
|
366
|
+
}
|
|
367
|
+
client;
|
|
368
|
+
async list(params = {}) {
|
|
369
|
+
const { endpoint_id, event_type, status, cursor, limit } = params;
|
|
370
|
+
return this.client.request("GET", "/v1/webhook-deliveries", {
|
|
371
|
+
query: { endpoint_id, event_type, status, cursor, limit }
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
async get(id) {
|
|
375
|
+
return this.client.request("GET", deliveryPath(id));
|
|
376
|
+
}
|
|
377
|
+
async redeliver(id) {
|
|
378
|
+
const res = await this.client.request("POST", `${deliveryPath(id)}/redeliver`);
|
|
379
|
+
return res.delivery;
|
|
380
|
+
}
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
// src/resources/webhooks.ts
|
|
384
|
+
function webhookPath(id) {
|
|
385
|
+
return `/v1/webhooks/${encodeURIComponent(id)}`;
|
|
386
|
+
}
|
|
387
|
+
var WebhooksResource = class {
|
|
388
|
+
constructor(client) {
|
|
389
|
+
this.client = client;
|
|
390
|
+
this.deliveries = new WebhookDeliveriesResource(client);
|
|
391
|
+
}
|
|
392
|
+
client;
|
|
393
|
+
deliveries;
|
|
394
|
+
async list(params = {}) {
|
|
395
|
+
const { cursor, limit } = params;
|
|
396
|
+
return this.client.request("GET", "/v1/webhooks", { query: { cursor, limit } });
|
|
397
|
+
}
|
|
398
|
+
async create(params) {
|
|
399
|
+
return this.client.request("POST", "/v1/webhooks", { body: params });
|
|
400
|
+
}
|
|
401
|
+
async get(id) {
|
|
402
|
+
const res = await this.client.request("GET", webhookPath(id));
|
|
403
|
+
return res.endpoint;
|
|
404
|
+
}
|
|
405
|
+
async update(id, params) {
|
|
406
|
+
const res = await this.client.request("PATCH", webhookPath(id), { body: params });
|
|
407
|
+
return res.endpoint;
|
|
408
|
+
}
|
|
409
|
+
async delete(id) {
|
|
410
|
+
await this.client.request("DELETE", webhookPath(id));
|
|
411
|
+
}
|
|
412
|
+
async test(id, event) {
|
|
413
|
+
const res = await this.client.request(
|
|
414
|
+
"POST",
|
|
415
|
+
`${webhookPath(id)}/test`,
|
|
416
|
+
{ body: event ? { event } : {} }
|
|
417
|
+
);
|
|
418
|
+
return res.delivery;
|
|
419
|
+
}
|
|
420
|
+
// rotateSecret replaces the endpoint's signing secret; the new secret is
|
|
421
|
+
// returned exactly once. The old secret stops working immediately.
|
|
422
|
+
async rotateSecret(id) {
|
|
423
|
+
return this.client.request("POST", `${webhookPath(id)}/rotate-secret`, { body: {} });
|
|
424
|
+
}
|
|
425
|
+
async events() {
|
|
426
|
+
const res = await this.client.request("GET", "/v1/webhooks/meta/events");
|
|
427
|
+
return res.data;
|
|
428
|
+
}
|
|
429
|
+
};
|
|
430
|
+
|
|
253
431
|
// src/resources/whatsapp.ts
|
|
254
432
|
var WhatsAppResource = class {
|
|
255
433
|
messages;
|
|
@@ -284,6 +462,8 @@ var Notideus = class {
|
|
|
284
462
|
whatsapp;
|
|
285
463
|
unsubscribe;
|
|
286
464
|
plans;
|
|
465
|
+
webhooks;
|
|
466
|
+
inbound;
|
|
287
467
|
constructor(apiKey, options = {}) {
|
|
288
468
|
this.client = new ApiClient({ ...options, apiKey });
|
|
289
469
|
this.emails = new EmailsResource(this.client);
|
|
@@ -291,6 +471,8 @@ var Notideus = class {
|
|
|
291
471
|
this.whatsapp = new WhatsAppResource(this.client);
|
|
292
472
|
this.unsubscribe = new UnsubscribeResource(this.client);
|
|
293
473
|
this.plans = new PlansResource(this.client);
|
|
474
|
+
this.webhooks = new WebhooksResource(this.client);
|
|
475
|
+
this.inbound = new InboundResource(this.client);
|
|
294
476
|
}
|
|
295
477
|
};
|
|
296
478
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/errors.ts","../src/client.ts","../src/resources/contacts.ts","../src/resources/emails.ts","../src/resources/plans.ts","../src/resources/unsubscribe.ts","../src/resources/whatsapp.ts"],"sourcesContent":["import { ApiClient, type ClientOptions } from './client.js';\nimport { ContactsResource } from './resources/contacts.js';\nimport { EmailsResource } from './resources/emails.js';\nimport { PlansResource } from './resources/plans.js';\nimport { UnsubscribeResource } from './resources/unsubscribe.js';\nimport { WhatsAppResource } from './resources/whatsapp.js';\n\nexport { NotideusError } from './errors.js';\nexport type { ClientOptions } from './client.js';\nexport type { BatchItemError, BatchItemResult } from './types/common.js';\nexport type {\n BulkContactInput,\n Contact,\n ContactStatus,\n CreateContactParams,\n ListContactsParams,\n ListContactsResponse,\n UpdateContactParams\n} from './types/contact.js';\nexport type { Email, SendEmailParams } from './types/email.js';\nexport type {\n ContactsTier,\n FreeAllowances,\n Plan,\n PlanCatalog,\n PlanLocale,\n PlanTier\n} from './types/plans.js';\nexport type { SendWhatsAppMessageParams, WhatsAppMessage } from './types/whatsapp.js';\nexport type { UnsubscribeInfo, UnsubscribeTopic } from './types/unsubscribe.js';\n\nexport class Notideus {\n private readonly client: ApiClient;\n readonly emails: EmailsResource;\n readonly contacts: ContactsResource;\n readonly whatsapp: WhatsAppResource;\n readonly unsubscribe: UnsubscribeResource;\n readonly plans: PlansResource;\n\n constructor(apiKey?: string, options: Omit<ClientOptions, 'apiKey'> = {}) {\n this.client = new ApiClient({ ...options, apiKey });\n this.emails = new EmailsResource(this.client);\n this.contacts = new ContactsResource(this.client);\n this.whatsapp = new WhatsAppResource(this.client);\n this.unsubscribe = new UnsubscribeResource(this.client);\n this.plans = new PlansResource(this.client);\n }\n}\n","export interface NotideusErrorOptions {\n code: string;\n message: string;\n status: number;\n retryAfter?: number;\n}\n\nexport class NotideusError extends Error {\n readonly code: string;\n readonly status: number;\n readonly retryAfter?: number;\n\n constructor(options: NotideusErrorOptions) {\n super(options.message);\n this.name = 'NotideusError';\n this.code = options.code;\n this.status = options.status;\n this.retryAfter = options.retryAfter;\n }\n}\n","import { NotideusError } from './errors.js';\n\nconst DEFAULT_BASE_URL = 'https://api.notideus.io';\nconst DEFAULT_TIMEOUT_MS = 30_000;\nconst VERSION = '0.1.0';\n\nexport interface ClientOptions {\n apiKey?: string;\n baseURL?: string;\n timeout?: number;\n maxRetries?: number;\n sleep?: (ms: number) => Promise<void>;\n}\n\nexport interface RequestOptions {\n query?: Record<string, string | number | undefined>;\n body?: unknown;\n authenticated?: boolean;\n signal?: AbortSignal;\n}\n\nexport class ApiClient {\n private readonly apiKey?: string;\n private readonly baseURL: string;\n private readonly timeout: number;\n private readonly maxRetries: number;\n private readonly sleep: (ms: number) => Promise<void>;\n\n constructor(options: ClientOptions = {}) {\n this.apiKey = options.apiKey;\n this.baseURL = options.baseURL ?? DEFAULT_BASE_URL;\n this.timeout = options.timeout ?? DEFAULT_TIMEOUT_MS;\n this.maxRetries = options.maxRetries ?? 2;\n this.sleep = options.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));\n }\n\n async request<T>(method: string, path: string, options: RequestOptions = {}): Promise<T> {\n const idempotent = method !== 'POST' || hasIdempotencyKey(options.body);\n let attempt = 0;\n for (;;) {\n try {\n return await this.attempt<T>(method, path, options);\n } catch (err) {\n if (!idempotent || !isRetriable(err) || attempt >= this.maxRetries) {\n throw err;\n }\n await this.sleep(this.delayMs(err, attempt));\n attempt += 1;\n }\n }\n }\n\n private delayMs(err: unknown, attempt: number): number {\n if (err instanceof NotideusError && err.retryAfter != null) {\n return err.retryAfter * 1000;\n }\n return Math.min(1000 * 2 ** attempt, 8000) + Math.floor(Math.random() * 250);\n }\n\n private async attempt<T>(method: string, path: string, options: RequestOptions): Promise<T> {\n const url = this.buildUrl(path, options.query);\n const headers: Record<string, string> = {\n 'User-Agent': `notideus-node/${VERSION}`\n };\n if (options.authenticated !== false && this.apiKey) {\n headers.Authorization = `Bearer ${this.apiKey}`;\n }\n let body: string | undefined;\n if (options.body !== undefined) {\n headers['Content-Type'] = 'application/json';\n body = JSON.stringify(options.body);\n }\n\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), this.timeout);\n const onCallerAbort = () => controller.abort();\n if (options.signal) {\n if (options.signal.aborted) controller.abort();\n else options.signal.addEventListener('abort', onCallerAbort, { once: true });\n }\n\n try {\n const response = await fetch(url, { method, headers, body, signal: controller.signal });\n if (response.status === 204) return undefined as T;\n if (!response.ok) throw await this.toError(response);\n return (await response.json()) as T;\n } catch (err) {\n if (err instanceof NotideusError) throw err;\n if (options.signal?.aborted) throw err;\n throw new NotideusError({\n code: controller.signal.aborted ? 'request_timeout' : 'network_error',\n message: err instanceof Error ? err.message : String(err),\n status: 0\n });\n } finally {\n clearTimeout(timer);\n options.signal?.removeEventListener('abort', onCallerAbort);\n }\n }\n\n private buildUrl(path: string, query?: RequestOptions['query']): string {\n const url = new URL(path, this.baseURL);\n if (query) {\n for (const [key, value] of Object.entries(query)) {\n if (value !== undefined) url.searchParams.set(key, String(value));\n }\n }\n return url.toString();\n }\n\n private async toError(response: Response): Promise<NotideusError> {\n let code = 'unknown_error';\n let message = response.statusText || `HTTP ${response.status}`;\n try {\n const parsed = (await response.json()) as { error?: { code?: string; message?: string } };\n if (parsed.error?.code) code = parsed.error.code;\n if (parsed.error?.message) message = parsed.error.message;\n } catch {\n // non-JSON error body — keep the defaults\n }\n const retryAfterHeader = response.headers.get('retry-after');\n return new NotideusError({\n code,\n message,\n status: response.status,\n retryAfter: retryAfterHeader ? Number(retryAfterHeader) : undefined\n });\n }\n}\n\nfunction hasIdempotencyKey(body: unknown): boolean {\n return (\n typeof body === 'object' &&\n body !== null &&\n (body as Record<string, unknown>).idempotency_key != null\n );\n}\n\nfunction isRetriable(err: unknown): boolean {\n if (!(err instanceof NotideusError)) return false;\n if (err.code === 'network_error' || err.code === 'request_timeout') return true;\n return err.status === 429 || err.status >= 500;\n}\n","import type { ApiClient } from '../client.js';\nimport type { BatchItemResult } from '../types/common.js';\nimport type {\n BulkContactInput,\n Contact,\n CreateContactParams,\n ListContactsParams,\n ListContactsResponse,\n UpdateContactParams\n} from '../types/contact.js';\n\nfunction contactPath(email: string): string {\n return `/v1/contacts/${encodeURIComponent(email)}`;\n}\n\nexport class ContactsResource {\n constructor(private readonly client: ApiClient) {}\n\n async list(params: ListContactsParams = {}): Promise<ListContactsResponse> {\n const { limit, status, email, cursor } = params;\n return this.client.request<ListContactsResponse>('GET', '/v1/contacts', {\n query: { limit, status, email, cursor }\n });\n }\n\n async create(params: CreateContactParams): Promise<Contact> {\n return this.client.request<Contact>('POST', '/v1/contacts', { body: params });\n }\n\n async get(email: string): Promise<Contact> {\n return this.client.request<Contact>('GET', contactPath(email));\n }\n\n async update(email: string, params: UpdateContactParams): Promise<Contact> {\n return this.client.request<Contact>('PATCH', contactPath(email), { body: params });\n }\n\n async delete(email: string): Promise<void> {\n await this.client.request<void>('DELETE', contactPath(email));\n }\n\n async bulk(contacts: BulkContactInput[]): Promise<BatchItemResult[]> {\n const res = await this.client.request<{ data: BatchItemResult[] }>('POST', '/v1/contacts/bulk', {\n body: { contacts }\n });\n return res.data;\n }\n\n async unsubscribe(email: string): Promise<Contact> {\n return this.client.request<Contact>('POST', `${contactPath(email)}/unsubscribe`);\n }\n\n async resubscribe(email: string): Promise<Contact> {\n return this.client.request<Contact>('POST', `${contactPath(email)}/resubscribe`);\n }\n}\n","import type { ApiClient } from '../client.js';\nimport type { BatchItemResult } from '../types/common.js';\nimport type { Email, SendEmailParams } from '../types/email.js';\n\nexport class EmailsResource {\n constructor(private readonly client: ApiClient) {}\n\n async send(params: SendEmailParams): Promise<Email> {\n return this.client.request<Email>('POST', '/v1/emails', { body: params });\n }\n\n async sendBatch(emails: SendEmailParams[]): Promise<BatchItemResult[]> {\n const res = await this.client.request<{ data: BatchItemResult[] }>('POST', '/v1/emails/batch', {\n body: { emails }\n });\n return res.data;\n }\n}\n","import type { ApiClient } from '../client.js';\nimport type { PlanCatalog, PlanLocale } from '../types/plans.js';\n\nexport class PlansResource {\n constructor(private readonly client: ApiClient) {}\n\n async list(params: { locale?: PlanLocale } = {}): Promise<PlanCatalog> {\n return this.client.request<PlanCatalog>('GET', '/v1/plans', {\n query: { locale: params.locale },\n authenticated: false\n });\n }\n}\n","import type { ApiClient } from '../client.js';\nimport type { UnsubscribeInfo } from '../types/unsubscribe.js';\n\nexport class UnsubscribeResource {\n constructor(private readonly client: ApiClient) {}\n\n async info(token: string): Promise<UnsubscribeInfo> {\n return this.client.request<UnsubscribeInfo>('GET', '/v1/unsubscribe/info', {\n query: { t: token },\n authenticated: false\n });\n }\n\n async unsubscribe(token: string, topicIds?: string[]): Promise<void> {\n const body: Record<string, unknown> = { token };\n if (topicIds !== undefined) {\n body.topic_ids = topicIds;\n }\n await this.client.request<void>('POST', '/v1/unsubscribe', { body, authenticated: false });\n }\n\n async preferences(token: string, topicIds: string[]): Promise<void> {\n await this.client.request<void>('POST', '/v1/unsubscribe/preferences', {\n body: { token, topic_ids: topicIds },\n authenticated: false\n });\n }\n}\n","import type { ApiClient } from '../client.js';\nimport type { BatchItemResult } from '../types/common.js';\nimport type { SendWhatsAppMessageParams, WhatsAppMessage } from '../types/whatsapp.js';\n\nexport class WhatsAppResource {\n readonly messages: WhatsAppMessagesResource;\n\n constructor(client: ApiClient) {\n this.messages = new WhatsAppMessagesResource(client);\n }\n}\n\nexport class WhatsAppMessagesResource {\n constructor(private readonly client: ApiClient) {}\n\n async send(params: SendWhatsAppMessageParams): Promise<WhatsAppMessage[]> {\n const res = await this.client.request<{ data: WhatsAppMessage[] }>('POST', '/v1/whatsapp/messages', {\n body: params\n });\n return res.data;\n }\n\n async sendBatch(messages: SendWhatsAppMessageParams[]): Promise<BatchItemResult[]> {\n const res = await this.client.request<{ data: BatchItemResult[] }>('POST', '/v1/whatsapp/messages/batch', {\n body: { messages }\n });\n return res.data;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACOO,IAAM,gBAAN,cAA4B,MAAM;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EAET,YAAY,SAA+B;AACzC,UAAM,QAAQ,OAAO;AACrB,SAAK,OAAO;AACZ,SAAK,OAAO,QAAQ;AACpB,SAAK,SAAS,QAAQ;AACtB,SAAK,aAAa,QAAQ;AAAA,EAC5B;AACF;;;ACjBA,IAAM,mBAAmB;AACzB,IAAM,qBAAqB;AAC3B,IAAM,UAAU;AAiBT,IAAM,YAAN,MAAgB;AAAA,EACJ;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEjB,YAAY,UAAyB,CAAC,GAAG;AACvC,SAAK,SAAS,QAAQ;AACtB,SAAK,UAAU,QAAQ,WAAW;AAClC,SAAK,UAAU,QAAQ,WAAW;AAClC,SAAK,aA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A,EAET,YAAY,QAAiB,UAAyC,CAAC,GAAG;AACxE,SAAK,SAAS,IAAI,UAAU,EAAE,GAAG,SAAS,OAAO,CAAC;AAClD,SAAK,SAAS,IAAI,eAAe,KAAK,MAAM;AAC5C,SAAK,WAAW,IAAI,iBAAiB,KAAK,MAAM;AAChD,SAAK,WAAW,IAAI,iBAAiB,KAAK,MAAM;AAChD,SAAK,cAAc,IAAI,oBAAoB,KAAK,MAAM;AACtD,SAAK,QAAQ,IAAI,cAAc,KAAK,MAAM;AAAA,EAC5C;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/errors.ts","../src/client.ts","../src/resources/contacts.ts","../src/resources/emails.ts","../src/resources/inbound.ts","../src/resources/plans.ts","../src/resources/unsubscribe.ts","../src/resources/webhook-deliveries.ts","../src/resources/webhooks.ts","../src/resources/whatsapp.ts"],"sourcesContent":["import { ApiClient, type ClientOptions } from './client.js';\nimport { ContactsResource } from './resources/contacts.js';\nimport { EmailsResource } from './resources/emails.js';\nimport { InboundResource } from './resources/inbound.js';\nimport { PlansResource } from './resources/plans.js';\nimport { UnsubscribeResource } from './resources/unsubscribe.js';\nimport { WebhooksResource } from './resources/webhooks.js';\nimport { WhatsAppResource } from './resources/whatsapp.js';\n\nexport { NotideusError } from './errors.js';\nexport type { BinaryResult, ClientOptions } from './client.js';\nexport type { BatchItemError, BatchItemResult } from './types/common.js';\nexport type {\n BulkContactInput,\n Contact,\n ContactStatus,\n CreateContactParams,\n ListContactsParams,\n ListContactsResponse,\n UpdateContactParams\n} from './types/contact.js';\nexport type { Email, SendEmailParams } from './types/email.js';\nexport type {\n CreateInboundRouteParams,\n InboundAttachment,\n InboundMessage,\n InboundMessageStatus,\n InboundRoute,\n InboundRouteStatus,\n ListInboundMessagesParams,\n ListInboundMessagesResponse,\n ListInboundRoutesResponse,\n UpdateInboundRouteParams\n} from './types/inbound.js';\nexport type {\n ContactsTier,\n FreeAllowances,\n Plan,\n PlanCatalog,\n PlanLocale,\n PlanTier\n} from './types/plans.js';\nexport type { SendWhatsAppMessageParams, WhatsAppMessage } from './types/whatsapp.js';\nexport type { UnsubscribeInfo, UnsubscribeTopic } from './types/unsubscribe.js';\nexport type {\n CreateWebhookParams,\n ListWebhookDeliveriesParams,\n ListWebhookDeliveriesResponse,\n ListWebhooksParams,\n ListWebhooksResponse,\n UpdateWebhookParams,\n WebhookAttempt,\n WebhookCreated,\n WebhookDelivery,\n WebhookDeliveryResult,\n WebhookDeliveryStatus,\n WebhookEndpoint,\n WebhookEndpointStatus,\n WebhookEventDescriptor\n} from './types/webhook.js';\n\nexport class Notideus {\n private readonly client: ApiClient;\n readonly emails: EmailsResource;\n readonly contacts: ContactsResource;\n readonly whatsapp: WhatsAppResource;\n readonly unsubscribe: UnsubscribeResource;\n readonly plans: PlansResource;\n readonly webhooks: WebhooksResource;\n readonly inbound: InboundResource;\n\n constructor(apiKey?: string, options: Omit<ClientOptions, 'apiKey'> = {}) {\n this.client = new ApiClient({ ...options, apiKey });\n this.emails = new EmailsResource(this.client);\n this.contacts = new ContactsResource(this.client);\n this.whatsapp = new WhatsAppResource(this.client);\n this.unsubscribe = new UnsubscribeResource(this.client);\n this.plans = new PlansResource(this.client);\n this.webhooks = new WebhooksResource(this.client);\n this.inbound = new InboundResource(this.client);\n }\n}\n","export interface NotideusErrorOptions {\n code: string;\n message: string;\n status: number;\n retryAfter?: number;\n /** Admin-provided note, present on account_suspended errors. */\n reason?: string;\n}\n\nexport class NotideusError extends Error {\n readonly code: string;\n readonly status: number;\n readonly retryAfter?: number;\n readonly reason?: string;\n\n constructor(options: NotideusErrorOptions) {\n super(options.message);\n this.name = 'NotideusError';\n this.code = options.code;\n this.status = options.status;\n this.retryAfter = options.retryAfter;\n this.reason = options.reason;\n }\n}\n","import { NotideusError } from './errors.js';\n\nconst DEFAULT_BASE_URL = 'https://api.notideus.io';\nconst DEFAULT_TIMEOUT_MS = 30_000;\nconst VERSION = '0.1.0';\n\nexport interface ClientOptions {\n apiKey?: string;\n baseURL?: string;\n timeout?: number;\n maxRetries?: number;\n sleep?: (ms: number) => Promise<void>;\n}\n\nexport interface RequestOptions {\n query?: Record<string, string | number | undefined>;\n body?: unknown;\n authenticated?: boolean;\n signal?: AbortSignal;\n}\n\nexport interface BinaryResult {\n data: Uint8Array;\n contentType: string;\n filename: string | null;\n}\n\nexport class ApiClient {\n private readonly apiKey?: string;\n private readonly baseURL: string;\n private readonly timeout: number;\n private readonly maxRetries: number;\n private readonly sleep: (ms: number) => Promise<void>;\n\n constructor(options: ClientOptions = {}) {\n this.apiKey = options.apiKey;\n this.baseURL = options.baseURL ?? DEFAULT_BASE_URL;\n this.timeout = options.timeout ?? DEFAULT_TIMEOUT_MS;\n this.maxRetries = options.maxRetries ?? 2;\n this.sleep = options.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));\n }\n\n async request<T>(method: string, path: string, options: RequestOptions = {}): Promise<T> {\n const idempotent = method !== 'POST' || hasIdempotencyKey(options.body);\n let attempt = 0;\n for (;;) {\n try {\n return await this.attempt<T>(method, path, options);\n } catch (err) {\n if (!idempotent || !isRetriable(err) || attempt >= this.maxRetries) {\n throw err;\n }\n await this.sleep(this.delayMs(err, attempt));\n attempt += 1;\n }\n }\n }\n\n // requestBinary downloads a binary endpoint (raw MIME, attachments). Auth\n // headers are attached like request(); non-2xx responses raise NotideusError\n // with the standard envelope. No retries — callers can re-invoke.\n async requestBinary(path: string, options: { signal?: AbortSignal } = {}): Promise<BinaryResult> {\n const headers: Record<string, string> = {\n 'User-Agent': `notideus-node/${VERSION}`\n };\n if (this.apiKey) headers.Authorization = `Bearer ${this.apiKey}`;\n\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), this.timeout);\n const onCallerAbort = () => controller.abort();\n if (options.signal) {\n if (options.signal.aborted) controller.abort();\n else options.signal.addEventListener('abort', onCallerAbort, { once: true });\n }\n\n try {\n const res = await fetch(new URL(path, this.baseURL), { headers, signal: controller.signal });\n if (!res.ok) throw await this.toError(res);\n const disposition = res.headers.get('content-disposition') ?? '';\n const match = CONTENT_DISPOSITION_FILENAME.exec(disposition);\n return {\n data: new Uint8Array(await res.arrayBuffer()),\n contentType: res.headers.get('content-type') ?? 'application/octet-stream',\n filename: match ? match[1] : null\n };\n } catch (err) {\n if (err instanceof NotideusError) throw err;\n if (options.signal?.aborted) throw err;\n throw new NotideusError({\n code: controller.signal.aborted ? 'request_timeout' : 'network_error',\n message: err instanceof Error ? err.message : String(err),\n status: 0\n });\n } finally {\n clearTimeout(timer);\n options.signal?.removeEventListener('abort', onCallerAbort);\n }\n }\n\n private delayMs(err: unknown, attempt: number): number {\n if (err instanceof NotideusError && err.retryAfter != null) {\n return err.retryAfter * 1000;\n }\n return Math.min(1000 * 2 ** attempt, 8000) + Math.floor(Math.random() * 250);\n }\n\n private async attempt<T>(method: string, path: string, options: RequestOptions): Promise<T> {\n const url = this.buildUrl(path, options.query);\n const headers: Record<string, string> = {\n 'User-Agent': `notideus-node/${VERSION}`\n };\n if (options.authenticated !== false && this.apiKey) {\n headers.Authorization = `Bearer ${this.apiKey}`;\n }\n let body: string | undefined;\n if (options.body !== undefined) {\n headers['Content-Type'] = 'application/json';\n body = JSON.stringify(options.body);\n }\n\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), this.timeout);\n const onCallerAbort = () => controller.abort();\n if (options.signal) {\n if (options.signal.aborted) controller.abort();\n else options.signal.addEventListener('abort', onCallerAbort, { once: true });\n }\n\n try {\n const response = await fetch(url, { method, headers, body, signal: controller.signal });\n if (response.status === 204) return undefined as T;\n if (!response.ok) throw await this.toError(response);\n return (await response.json()) as T;\n } catch (err) {\n if (err instanceof NotideusError) throw err;\n if (options.signal?.aborted) throw err;\n throw new NotideusError({\n code: controller.signal.aborted ? 'request_timeout' : 'network_error',\n message: err instanceof Error ? err.message : String(err),\n status: 0\n });\n } finally {\n clearTimeout(timer);\n options.signal?.removeEventListener('abort', onCallerAbort);\n }\n }\n\n private buildUrl(path: string, query?: RequestOptions['query']): string {\n const url = new URL(path, this.baseURL);\n if (query) {\n for (const [key, value] of Object.entries(query)) {\n if (value !== undefined) url.searchParams.set(key, String(value));\n }\n }\n return url.toString();\n }\n\n private async toError(response: Response): Promise<NotideusError> {\n let code = 'unknown_error';\n let message = response.statusText || `HTTP ${response.status}`;\n let reason: string | undefined;\n try {\n const parsed = (await response.json()) as { error?: { code?: string; message?: string; reason?: string } };\n if (parsed.error?.code) code = parsed.error.code;\n if (parsed.error?.message) message = parsed.error.message;\n if (typeof parsed.error?.reason === 'string') reason = parsed.error.reason;\n } catch {\n // non-JSON error body — keep the defaults\n }\n const retryAfterHeader = response.headers.get('retry-after');\n return new NotideusError({\n code,\n message,\n status: response.status,\n retryAfter: retryAfterHeader ? Number(retryAfterHeader) : undefined,\n reason\n });\n }\n}\n\nconst CONTENT_DISPOSITION_FILENAME = /filename=\"?([^\";]+)\"?/;\n\nfunction hasIdempotencyKey(body: unknown): boolean {\n return (\n typeof body === 'object' &&\n body !== null &&\n (body as Record<string, unknown>).idempotency_key != null\n );\n}\n\nfunction isRetriable(err: unknown): boolean {\n if (!(err instanceof NotideusError)) return false;\n if (err.code === 'network_error' || err.code === 'request_timeout') return true;\n return err.status === 429 || err.status >= 500;\n}\n","import type { ApiClient } from '../client.js';\nimport type { BatchItemResult } from '../types/common.js';\nimport type {\n BulkContactInput,\n Contact,\n CreateContactParams,\n ListContactsParams,\n ListContactsResponse,\n UpdateContactParams\n} from '../types/contact.js';\n\nfunction contactPath(email: string): string {\n return `/v1/contacts/${encodeURIComponent(email)}`;\n}\n\nexport class ContactsResource {\n constructor(private readonly client: ApiClient) {}\n\n async list(params: ListContactsParams = {}): Promise<ListContactsResponse> {\n const { limit, status, email, cursor } = params;\n return this.client.request<ListContactsResponse>('GET', '/v1/contacts', {\n query: { limit, status, email, cursor }\n });\n }\n\n async create(params: CreateContactParams): Promise<Contact> {\n return this.client.request<Contact>('POST', '/v1/contacts', { body: params });\n }\n\n async get(email: string): Promise<Contact> {\n return this.client.request<Contact>('GET', contactPath(email));\n }\n\n async update(email: string, params: UpdateContactParams): Promise<Contact> {\n return this.client.request<Contact>('PATCH', contactPath(email), { body: params });\n }\n\n async delete(email: string): Promise<void> {\n await this.client.request<void>('DELETE', contactPath(email));\n }\n\n async bulk(contacts: BulkContactInput[]): Promise<BatchItemResult[]> {\n const res = await this.client.request<{ data: BatchItemResult[] }>('POST', '/v1/contacts/bulk', {\n body: { contacts }\n });\n return res.data;\n }\n\n async unsubscribe(email: string): Promise<Contact> {\n return this.client.request<Contact>('POST', `${contactPath(email)}/unsubscribe`);\n }\n\n async resubscribe(email: string): Promise<Contact> {\n return this.client.request<Contact>('POST', `${contactPath(email)}/resubscribe`);\n }\n}\n","import type { ApiClient } from '../client.js';\nimport type { BatchItemResult } from '../types/common.js';\nimport type { Email, SendEmailParams } from '../types/email.js';\n\nexport class EmailsResource {\n constructor(private readonly client: ApiClient) {}\n\n async send(params: SendEmailParams): Promise<Email> {\n return this.client.request<Email>('POST', '/v1/emails', { body: params });\n }\n\n async sendBatch(emails: SendEmailParams[]): Promise<BatchItemResult[]> {\n const res = await this.client.request<{ data: BatchItemResult[] }>('POST', '/v1/emails/batch', {\n body: { emails }\n });\n return res.data;\n }\n}\n","import type { ApiClient, BinaryResult } from '../client.js';\nimport type {\n CreateInboundRouteParams,\n InboundMessage,\n InboundRoute,\n ListInboundMessagesParams,\n ListInboundMessagesResponse,\n ListInboundRoutesResponse,\n UpdateInboundRouteParams\n} from '../types/inbound.js';\n\nfunction routePath(id: string): string {\n return `/v1/inbound/routes/${encodeURIComponent(id)}`;\n}\n\nfunction messagePath(id: string): string {\n return `/v1/inbound/messages/${encodeURIComponent(id)}`;\n}\n\nexport class InboundRoutesResource {\n constructor(private readonly client: ApiClient) {}\n\n async list(): Promise<ListInboundRoutesResponse> {\n return this.client.request<ListInboundRoutesResponse>('GET', '/v1/inbound/routes');\n }\n\n async create(params: CreateInboundRouteParams): Promise<InboundRoute> {\n const res = await this.client.request<{ route: InboundRoute }>('POST', '/v1/inbound/routes', { body: params });\n return res.route;\n }\n\n async get(id: string): Promise<InboundRoute> {\n const res = await this.client.request<{ route: InboundRoute }>('GET', routePath(id));\n return res.route;\n }\n\n async update(id: string, params: UpdateInboundRouteParams): Promise<InboundRoute> {\n const res = await this.client.request<{ route: InboundRoute }>('PATCH', routePath(id), { body: params });\n return res.route;\n }\n\n async delete(id: string): Promise<void> {\n await this.client.request<void>('DELETE', routePath(id));\n }\n}\n\nexport class InboundMessagesResource {\n constructor(private readonly client: ApiClient) {}\n\n async list(params: ListInboundMessagesParams = {}): Promise<ListInboundMessagesResponse> {\n const { q, route_id, cursor, limit } = params;\n return this.client.request<ListInboundMessagesResponse>('GET', '/v1/inbound/messages', {\n query: { q, route_id, cursor, limit }\n });\n }\n\n async get(id: string): Promise<InboundMessage> {\n const res = await this.client.request<{ message: InboundMessage }>('GET', messagePath(id));\n return res.message;\n }\n\n async raw(id: string, options: { signal?: AbortSignal } = {}): Promise<BinaryResult> {\n return this.client.requestBinary(`${messagePath(id)}/raw`, options);\n }\n\n async attachment(messageId: string, index: number, options: { signal?: AbortSignal } = {}): Promise<BinaryResult> {\n return this.client.requestBinary(`${messagePath(messageId)}/attachments/${index}`, options);\n }\n}\n\nexport class InboundResource {\n readonly routes: InboundRoutesResource;\n readonly messages: InboundMessagesResource;\n\n constructor(client: ApiClient) {\n this.routes = new InboundRoutesResource(client);\n this.messages = new InboundMessagesResource(client);\n }\n}\n","import type { ApiClient } from '../client.js';\nimport type { PlanCatalog, PlanLocale } from '../types/plans.js';\n\nexport class PlansResource {\n constructor(private readonly client: ApiClient) {}\n\n async list(params: { locale?: PlanLocale } = {}): Promise<PlanCatalog> {\n return this.client.request<PlanCatalog>('GET', '/v1/plans', {\n query: { locale: params.locale },\n authenticated: false\n });\n }\n}\n","import type { ApiClient } from '../client.js';\nimport type { UnsubscribeInfo } from '../types/unsubscribe.js';\n\nexport class UnsubscribeResource {\n constructor(private readonly client: ApiClient) {}\n\n async info(token: string): Promise<UnsubscribeInfo> {\n return this.client.request<UnsubscribeInfo>('GET', '/v1/unsubscribe/info', {\n query: { t: token },\n authenticated: false\n });\n }\n\n async unsubscribe(token: string, topicIds?: string[]): Promise<void> {\n const body: Record<string, unknown> = { token };\n if (topicIds !== undefined) {\n body.topic_ids = topicIds;\n }\n await this.client.request<void>('POST', '/v1/unsubscribe', { body, authenticated: false });\n }\n\n async preferences(token: string, topicIds: string[]): Promise<void> {\n await this.client.request<void>('POST', '/v1/unsubscribe/preferences', {\n body: { token, topic_ids: topicIds },\n authenticated: false\n });\n }\n}\n","import type { ApiClient } from '../client.js';\nimport type {\n ListWebhookDeliveriesParams,\n ListWebhookDeliveriesResponse,\n WebhookDelivery,\n WebhookDeliveryResult\n} from '../types/webhook.js';\n\nfunction deliveryPath(id: string): string {\n return `/v1/webhook-deliveries/${encodeURIComponent(id)}`;\n}\n\nexport class WebhookDeliveriesResource {\n constructor(private readonly client: ApiClient) {}\n\n async list(params: ListWebhookDeliveriesParams = {}): Promise<ListWebhookDeliveriesResponse> {\n const { endpoint_id, event_type, status, cursor, limit } = params;\n return this.client.request<ListWebhookDeliveriesResponse>('GET', '/v1/webhook-deliveries', {\n query: { endpoint_id, event_type, status, cursor, limit }\n });\n }\n\n async get(id: string): Promise<WebhookDeliveryResult> {\n return this.client.request<WebhookDeliveryResult>('GET', deliveryPath(id));\n }\n\n async redeliver(id: string): Promise<WebhookDelivery> {\n const res = await this.client.request<{ delivery: WebhookDelivery }>('POST', `${deliveryPath(id)}/redeliver`);\n return res.delivery;\n }\n}\n","import type { ApiClient } from '../client.js';\nimport { WebhookDeliveriesResource } from './webhook-deliveries.js';\nimport type {\n CreateWebhookParams,\n ListWebhooksParams,\n ListWebhooksResponse,\n UpdateWebhookParams,\n WebhookCreated,\n WebhookDelivery,\n WebhookEndpoint,\n WebhookEventDescriptor\n} from '../types/webhook.js';\n\nfunction webhookPath(id: string): string {\n return `/v1/webhooks/${encodeURIComponent(id)}`;\n}\n\nexport class WebhooksResource {\n readonly deliveries: WebhookDeliveriesResource;\n\n constructor(private readonly client: ApiClient) {\n this.deliveries = new WebhookDeliveriesResource(client);\n }\n\n async list(params: ListWebhooksParams = {}): Promise<ListWebhooksResponse> {\n const { cursor, limit } = params;\n return this.client.request<ListWebhooksResponse>('GET', '/v1/webhooks', { query: { cursor, limit } });\n }\n\n async create(params: CreateWebhookParams): Promise<WebhookCreated> {\n return this.client.request<WebhookCreated>('POST', '/v1/webhooks', { body: params });\n }\n\n async get(id: string): Promise<WebhookEndpoint> {\n const res = await this.client.request<{ endpoint: WebhookEndpoint }>('GET', webhookPath(id));\n return res.endpoint;\n }\n\n async update(id: string, params: UpdateWebhookParams): Promise<WebhookEndpoint> {\n const res = await this.client.request<{ endpoint: WebhookEndpoint }>('PATCH', webhookPath(id), { body: params });\n return res.endpoint;\n }\n\n async delete(id: string): Promise<void> {\n await this.client.request<void>('DELETE', webhookPath(id));\n }\n\n async test(id: string, event?: string): Promise<WebhookDelivery> {\n const res = await this.client.request<{ delivery: WebhookDelivery }>(\n 'POST',\n `${webhookPath(id)}/test`,\n { body: event ? { event } : {} }\n );\n return res.delivery;\n }\n\n // rotateSecret replaces the endpoint's signing secret; the new secret is\n // returned exactly once. The old secret stops working immediately.\n async rotateSecret(id: string): Promise<WebhookCreated> {\n return this.client.request<WebhookCreated>('POST', `${webhookPath(id)}/rotate-secret`, { body: {} });\n }\n\n async events(): Promise<WebhookEventDescriptor[]> {\n const res = await this.client.request<{ data: WebhookEventDescriptor[] }>('GET', '/v1/webhooks/meta/events');\n return res.data;\n }\n}\n","import type { ApiClient } from '../client.js';\nimport type { BatchItemResult } from '../types/common.js';\nimport type { SendWhatsAppMessageParams, WhatsAppMessage } from '../types/whatsapp.js';\n\nexport class WhatsAppResource {\n readonly messages: WhatsAppMessagesResource;\n\n constructor(client: ApiClient) {\n this.messages = new WhatsAppMessagesResource(client);\n }\n}\n\nexport class WhatsAppMessagesResource {\n constructor(private readonly client: ApiClient) {}\n\n async send(params: SendWhatsAppMessageParams): Promise<WhatsAppMessage[]> {\n const res = await this.client.request<{ data: WhatsAppMessage[] }>('POST', '/v1/whatsapp/messages', {\n body: params\n });\n return res.data;\n }\n\n async sendBatch(messages: SendWhatsAppMessageParams[]): Promise<BatchItemResult[]> {\n const res = await this.client.request<{ data: BatchItemResult[] }>('POST', '/v1/whatsapp/messages/batch', {\n body: { messages }\n });\n return res.data;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACSO,IAAM,gBAAN,cAA4B,MAAM;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAET,YAAY,SAA+B;AACzC,UAAM,QAAQ,OAAO;AACrB,SAAK,OAAO;AACZ,SAAK,OAAO,QAAQ;AACpB,SAAK,SAAS,QAAQ;AACtB,SAAK,aAAa,QAAQ;AAC1B,SAAK,SAAS,QAAQ;AAAA,EACxB;AACF;;;ACrBA,IAAM,mBAAmB;AACzB,IAAM,qBAAqB;AAC3B,IAAM,UAAU;AAuBT,IAAM,YAAN,MAAgB;AAAA,EACJ;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEjB,YAAY,UAAyB,CAAC,GAAG;AACvC,SAAK,SAAS,QAAQ;AACtB,SAAK,UAAU,QAAQ,WAAW;AAClC,SAAK,UAAU,QAAQ,WAAW;AAClC,SAAK,aAAa,QAAQ,cAAc;AACxC,SAAK,QAAQ,QAAQ,UAAU,CAAC,OAAO,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,EAAE,CAAC;AAAA,EACzF;AAAA,EAEA,MAAM,QAAW,QAAgB,MAAc,UAA0B,CAAC,GAAe;AACvF,UAAM,aAAa,WAAW,UAAU,kBAAkB,QAAQ,IAAI;AACtE,QAAI,UAAU;AACd,eAAS;AACP,UAAI;AACF,eAAO,MAAM,KAAK,QAAW,QAAQ,MAAM,OAAO;AAAA,MAC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U,EAAE,GAAG,SAAS,OAAO,CAAC;AAClD,SAAK,SAAS,IAAI,eAAe,KAAK,MAAM;AAC5C,SAAK,WAAW,IAAI,iBAAiB,KAAK,MAAM;AAChD,SAAK,WAAW,IAAI,iBAAiB,KAAK,MAAM;AAChD,SAAK,cAAc,IAAI,oBAAoB,KAAK,MAAM;AACtD,SAAK,QAAQ,IAAI,cAAc,KAAK,MAAM;AAC1C,SAAK,WAAW,IAAI,iBAAiB,KAAK,MAAM;AAChD,SAAK,UAAU,IAAI,gBAAgB,KAAK,MAAM;AAAA,EAChD;AACF;","names":[]}
|
package/dist/index.d.cts
CHANGED
|
@@ -11,6 +11,11 @@ interface RequestOptions {
|
|
|
11
11
|
authenticated?: boolean;
|
|
12
12
|
signal?: AbortSignal;
|
|
13
13
|
}
|
|
14
|
+
interface BinaryResult {
|
|
15
|
+
data: Uint8Array;
|
|
16
|
+
contentType: string;
|
|
17
|
+
filename: string | null;
|
|
18
|
+
}
|
|
14
19
|
declare class ApiClient {
|
|
15
20
|
private readonly apiKey?;
|
|
16
21
|
private readonly baseURL;
|
|
@@ -19,6 +24,9 @@ declare class ApiClient {
|
|
|
19
24
|
private readonly sleep;
|
|
20
25
|
constructor(options?: ClientOptions);
|
|
21
26
|
request<T>(method: string, path: string, options?: RequestOptions): Promise<T>;
|
|
27
|
+
requestBinary(path: string, options?: {
|
|
28
|
+
signal?: AbortSignal;
|
|
29
|
+
}): Promise<BinaryResult>;
|
|
22
30
|
private delayMs;
|
|
23
31
|
private attempt;
|
|
24
32
|
private buildUrl;
|
|
@@ -96,6 +104,10 @@ interface SendEmailParams {
|
|
|
96
104
|
variables?: Record<string, string>;
|
|
97
105
|
tags?: string[];
|
|
98
106
|
idempotency_key?: string;
|
|
107
|
+
/** Opt into open tracking (1px pixel injected at send time). Default false. */
|
|
108
|
+
track_opens?: boolean;
|
|
109
|
+
/** Opt into click tracking (links rewritten through the redirect). Default false. */
|
|
110
|
+
track_clicks?: boolean;
|
|
99
111
|
}
|
|
100
112
|
interface Email {
|
|
101
113
|
id: string;
|
|
@@ -128,6 +140,100 @@ declare class EmailsResource {
|
|
|
128
140
|
sendBatch(emails: SendEmailParams[]): Promise<BatchItemResult[]>;
|
|
129
141
|
}
|
|
130
142
|
|
|
143
|
+
type InboundRouteStatus = 'active' | 'disabled';
|
|
144
|
+
interface InboundRoute {
|
|
145
|
+
id: string;
|
|
146
|
+
domain_id: string;
|
|
147
|
+
recipient: string;
|
|
148
|
+
name: string;
|
|
149
|
+
webhook_endpoint_id: string | null;
|
|
150
|
+
store: boolean;
|
|
151
|
+
status: InboundRouteStatus;
|
|
152
|
+
created_at: string;
|
|
153
|
+
updated_at: string;
|
|
154
|
+
}
|
|
155
|
+
interface CreateInboundRouteParams {
|
|
156
|
+
domain_id: string;
|
|
157
|
+
recipient: string;
|
|
158
|
+
name?: string;
|
|
159
|
+
store: boolean;
|
|
160
|
+
webhook_endpoint_id?: string;
|
|
161
|
+
}
|
|
162
|
+
interface UpdateInboundRouteParams {
|
|
163
|
+
recipient: string;
|
|
164
|
+
name?: string;
|
|
165
|
+
store: boolean;
|
|
166
|
+
webhook_endpoint_id?: string;
|
|
167
|
+
}
|
|
168
|
+
interface ListInboundRoutesResponse {
|
|
169
|
+
data: InboundRoute[];
|
|
170
|
+
meta: {
|
|
171
|
+
simulate_enabled: boolean;
|
|
172
|
+
retention_days: number;
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
type InboundMessageStatus = 'received' | 'processed' | 'failed';
|
|
176
|
+
interface InboundAttachment {
|
|
177
|
+
name: string;
|
|
178
|
+
content_type: string;
|
|
179
|
+
size_kb: number;
|
|
180
|
+
key: string;
|
|
181
|
+
}
|
|
182
|
+
interface InboundMessage {
|
|
183
|
+
id: string;
|
|
184
|
+
route_id: string | null;
|
|
185
|
+
from_addr: string;
|
|
186
|
+
from_name: string;
|
|
187
|
+
to_addr: string;
|
|
188
|
+
subject: string;
|
|
189
|
+
text: string;
|
|
190
|
+
html: string;
|
|
191
|
+
headers: Record<string, string>;
|
|
192
|
+
attachments: InboundAttachment[];
|
|
193
|
+
spam_verdict: string | null;
|
|
194
|
+
size_kb: number;
|
|
195
|
+
status: InboundMessageStatus;
|
|
196
|
+
error: string | null;
|
|
197
|
+
received_at: string;
|
|
198
|
+
}
|
|
199
|
+
interface ListInboundMessagesParams {
|
|
200
|
+
q?: string;
|
|
201
|
+
route_id?: string;
|
|
202
|
+
cursor?: string;
|
|
203
|
+
limit?: number;
|
|
204
|
+
}
|
|
205
|
+
interface ListInboundMessagesResponse {
|
|
206
|
+
data: InboundMessage[];
|
|
207
|
+
next_cursor?: string;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
declare class InboundRoutesResource {
|
|
211
|
+
private readonly client;
|
|
212
|
+
constructor(client: ApiClient);
|
|
213
|
+
list(): Promise<ListInboundRoutesResponse>;
|
|
214
|
+
create(params: CreateInboundRouteParams): Promise<InboundRoute>;
|
|
215
|
+
get(id: string): Promise<InboundRoute>;
|
|
216
|
+
update(id: string, params: UpdateInboundRouteParams): Promise<InboundRoute>;
|
|
217
|
+
delete(id: string): Promise<void>;
|
|
218
|
+
}
|
|
219
|
+
declare class InboundMessagesResource {
|
|
220
|
+
private readonly client;
|
|
221
|
+
constructor(client: ApiClient);
|
|
222
|
+
list(params?: ListInboundMessagesParams): Promise<ListInboundMessagesResponse>;
|
|
223
|
+
get(id: string): Promise<InboundMessage>;
|
|
224
|
+
raw(id: string, options?: {
|
|
225
|
+
signal?: AbortSignal;
|
|
226
|
+
}): Promise<BinaryResult>;
|
|
227
|
+
attachment(messageId: string, index: number, options?: {
|
|
228
|
+
signal?: AbortSignal;
|
|
229
|
+
}): Promise<BinaryResult>;
|
|
230
|
+
}
|
|
231
|
+
declare class InboundResource {
|
|
232
|
+
readonly routes: InboundRoutesResource;
|
|
233
|
+
readonly messages: InboundMessagesResource;
|
|
234
|
+
constructor(client: ApiClient);
|
|
235
|
+
}
|
|
236
|
+
|
|
131
237
|
type PlanLocale = 'en' | 'fr';
|
|
132
238
|
interface PlanTier {
|
|
133
239
|
emails: number;
|
|
@@ -193,6 +299,103 @@ declare class UnsubscribeResource {
|
|
|
193
299
|
preferences(token: string, topicIds: string[]): Promise<void>;
|
|
194
300
|
}
|
|
195
301
|
|
|
302
|
+
type WebhookEndpointStatus = 'active' | 'disabled';
|
|
303
|
+
interface WebhookEndpoint {
|
|
304
|
+
id: string;
|
|
305
|
+
name: string;
|
|
306
|
+
url: string;
|
|
307
|
+
secret_prefix: string;
|
|
308
|
+
events: string[];
|
|
309
|
+
status: WebhookEndpointStatus;
|
|
310
|
+
created_at: string;
|
|
311
|
+
updated_at: string;
|
|
312
|
+
}
|
|
313
|
+
interface CreateWebhookParams {
|
|
314
|
+
name: string;
|
|
315
|
+
url: string;
|
|
316
|
+
events: string[];
|
|
317
|
+
}
|
|
318
|
+
interface UpdateWebhookParams {
|
|
319
|
+
name: string;
|
|
320
|
+
url: string;
|
|
321
|
+
events: string[];
|
|
322
|
+
status: WebhookEndpointStatus;
|
|
323
|
+
}
|
|
324
|
+
interface WebhookCreated {
|
|
325
|
+
endpoint: WebhookEndpoint;
|
|
326
|
+
secret: string;
|
|
327
|
+
}
|
|
328
|
+
interface ListWebhooksParams {
|
|
329
|
+
cursor?: string;
|
|
330
|
+
limit?: number;
|
|
331
|
+
}
|
|
332
|
+
interface ListWebhooksResponse {
|
|
333
|
+
data: WebhookEndpoint[];
|
|
334
|
+
next_cursor?: string;
|
|
335
|
+
}
|
|
336
|
+
type WebhookDeliveryStatus = 'pending' | 'success' | 'failed';
|
|
337
|
+
interface WebhookDelivery {
|
|
338
|
+
id: string;
|
|
339
|
+
endpoint_id: string;
|
|
340
|
+
event_type: string;
|
|
341
|
+
payload: unknown;
|
|
342
|
+
status: WebhookDeliveryStatus;
|
|
343
|
+
attempts: number;
|
|
344
|
+
last_status_code: number | null;
|
|
345
|
+
last_error: string | null;
|
|
346
|
+
delivered_at: string | null;
|
|
347
|
+
created_at: string;
|
|
348
|
+
}
|
|
349
|
+
interface WebhookAttempt {
|
|
350
|
+
attempt: number;
|
|
351
|
+
status_code: number | null;
|
|
352
|
+
error: string | null;
|
|
353
|
+
duration_ms: number;
|
|
354
|
+
created_at: string;
|
|
355
|
+
}
|
|
356
|
+
interface WebhookDeliveryResult {
|
|
357
|
+
delivery: WebhookDelivery;
|
|
358
|
+
attempts: WebhookAttempt[];
|
|
359
|
+
}
|
|
360
|
+
interface ListWebhookDeliveriesParams {
|
|
361
|
+
endpoint_id?: string;
|
|
362
|
+
event_type?: string;
|
|
363
|
+
status?: WebhookDeliveryStatus;
|
|
364
|
+
cursor?: string;
|
|
365
|
+
limit?: number;
|
|
366
|
+
}
|
|
367
|
+
interface ListWebhookDeliveriesResponse {
|
|
368
|
+
data: WebhookDelivery[];
|
|
369
|
+
next_cursor?: string;
|
|
370
|
+
}
|
|
371
|
+
interface WebhookEventDescriptor {
|
|
372
|
+
type: string;
|
|
373
|
+
description: string;
|
|
374
|
+
sample: unknown;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
declare class WebhookDeliveriesResource {
|
|
378
|
+
private readonly client;
|
|
379
|
+
constructor(client: ApiClient);
|
|
380
|
+
list(params?: ListWebhookDeliveriesParams): Promise<ListWebhookDeliveriesResponse>;
|
|
381
|
+
get(id: string): Promise<WebhookDeliveryResult>;
|
|
382
|
+
redeliver(id: string): Promise<WebhookDelivery>;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
declare class WebhooksResource {
|
|
386
|
+
private readonly client;
|
|
387
|
+
readonly deliveries: WebhookDeliveriesResource;
|
|
388
|
+
constructor(client: ApiClient);
|
|
389
|
+
list(params?: ListWebhooksParams): Promise<ListWebhooksResponse>;
|
|
390
|
+
create(params: CreateWebhookParams): Promise<WebhookCreated>;
|
|
391
|
+
get(id: string): Promise<WebhookEndpoint>;
|
|
392
|
+
update(id: string, params: UpdateWebhookParams): Promise<WebhookEndpoint>;
|
|
393
|
+
delete(id: string): Promise<void>;
|
|
394
|
+
test(id: string, event?: string): Promise<WebhookDelivery>;
|
|
395
|
+
rotateSecret(id: string): Promise<WebhookCreated>;
|
|
396
|
+
events(): Promise<WebhookEventDescriptor[]>;
|
|
397
|
+
}
|
|
398
|
+
|
|
196
399
|
interface SendWhatsAppMessageParams {
|
|
197
400
|
template_id: string;
|
|
198
401
|
to: string[];
|
|
@@ -221,11 +424,14 @@ interface NotideusErrorOptions {
|
|
|
221
424
|
message: string;
|
|
222
425
|
status: number;
|
|
223
426
|
retryAfter?: number;
|
|
427
|
+
/** Admin-provided note, present on account_suspended errors. */
|
|
428
|
+
reason?: string;
|
|
224
429
|
}
|
|
225
430
|
declare class NotideusError extends Error {
|
|
226
431
|
readonly code: string;
|
|
227
432
|
readonly status: number;
|
|
228
433
|
readonly retryAfter?: number;
|
|
434
|
+
readonly reason?: string;
|
|
229
435
|
constructor(options: NotideusErrorOptions);
|
|
230
436
|
}
|
|
231
437
|
|
|
@@ -236,7 +442,10 @@ declare class Notideus {
|
|
|
236
442
|
readonly whatsapp: WhatsAppResource;
|
|
237
443
|
readonly unsubscribe: UnsubscribeResource;
|
|
238
444
|
readonly plans: PlansResource;
|
|
445
|
+
readonly webhooks: WebhooksResource;
|
|
446
|
+
readonly inbound: InboundResource;
|
|
239
447
|
constructor(apiKey?: string, options?: Omit<ClientOptions, 'apiKey'>);
|
|
240
448
|
}
|
|
241
449
|
|
|
242
|
-
export {
|
|
450
|
+
export { Notideus, NotideusError };
|
|
451
|
+
export type { BatchItemError, BatchItemResult, BinaryResult, BulkContactInput, ClientOptions, Contact, ContactStatus, ContactsTier, CreateContactParams, CreateInboundRouteParams, CreateWebhookParams, Email, FreeAllowances, InboundAttachment, InboundMessage, InboundMessageStatus, InboundRoute, InboundRouteStatus, ListContactsParams, ListContactsResponse, ListInboundMessagesParams, ListInboundMessagesResponse, ListInboundRoutesResponse, ListWebhookDeliveriesParams, ListWebhookDeliveriesResponse, ListWebhooksParams, ListWebhooksResponse, Plan, PlanCatalog, PlanLocale, PlanTier, SendEmailParams, SendWhatsAppMessageParams, UnsubscribeInfo, UnsubscribeTopic, UpdateContactParams, UpdateInboundRouteParams, UpdateWebhookParams, WebhookAttempt, WebhookCreated, WebhookDelivery, WebhookDeliveryResult, WebhookDeliveryStatus, WebhookEndpoint, WebhookEndpointStatus, WebhookEventDescriptor, WhatsAppMessage };
|
package/dist/index.d.ts
CHANGED
|
@@ -11,6 +11,11 @@ interface RequestOptions {
|
|
|
11
11
|
authenticated?: boolean;
|
|
12
12
|
signal?: AbortSignal;
|
|
13
13
|
}
|
|
14
|
+
interface BinaryResult {
|
|
15
|
+
data: Uint8Array;
|
|
16
|
+
contentType: string;
|
|
17
|
+
filename: string | null;
|
|
18
|
+
}
|
|
14
19
|
declare class ApiClient {
|
|
15
20
|
private readonly apiKey?;
|
|
16
21
|
private readonly baseURL;
|
|
@@ -19,6 +24,9 @@ declare class ApiClient {
|
|
|
19
24
|
private readonly sleep;
|
|
20
25
|
constructor(options?: ClientOptions);
|
|
21
26
|
request<T>(method: string, path: string, options?: RequestOptions): Promise<T>;
|
|
27
|
+
requestBinary(path: string, options?: {
|
|
28
|
+
signal?: AbortSignal;
|
|
29
|
+
}): Promise<BinaryResult>;
|
|
22
30
|
private delayMs;
|
|
23
31
|
private attempt;
|
|
24
32
|
private buildUrl;
|
|
@@ -96,6 +104,10 @@ interface SendEmailParams {
|
|
|
96
104
|
variables?: Record<string, string>;
|
|
97
105
|
tags?: string[];
|
|
98
106
|
idempotency_key?: string;
|
|
107
|
+
/** Opt into open tracking (1px pixel injected at send time). Default false. */
|
|
108
|
+
track_opens?: boolean;
|
|
109
|
+
/** Opt into click tracking (links rewritten through the redirect). Default false. */
|
|
110
|
+
track_clicks?: boolean;
|
|
99
111
|
}
|
|
100
112
|
interface Email {
|
|
101
113
|
id: string;
|
|
@@ -128,6 +140,100 @@ declare class EmailsResource {
|
|
|
128
140
|
sendBatch(emails: SendEmailParams[]): Promise<BatchItemResult[]>;
|
|
129
141
|
}
|
|
130
142
|
|
|
143
|
+
type InboundRouteStatus = 'active' | 'disabled';
|
|
144
|
+
interface InboundRoute {
|
|
145
|
+
id: string;
|
|
146
|
+
domain_id: string;
|
|
147
|
+
recipient: string;
|
|
148
|
+
name: string;
|
|
149
|
+
webhook_endpoint_id: string | null;
|
|
150
|
+
store: boolean;
|
|
151
|
+
status: InboundRouteStatus;
|
|
152
|
+
created_at: string;
|
|
153
|
+
updated_at: string;
|
|
154
|
+
}
|
|
155
|
+
interface CreateInboundRouteParams {
|
|
156
|
+
domain_id: string;
|
|
157
|
+
recipient: string;
|
|
158
|
+
name?: string;
|
|
159
|
+
store: boolean;
|
|
160
|
+
webhook_endpoint_id?: string;
|
|
161
|
+
}
|
|
162
|
+
interface UpdateInboundRouteParams {
|
|
163
|
+
recipient: string;
|
|
164
|
+
name?: string;
|
|
165
|
+
store: boolean;
|
|
166
|
+
webhook_endpoint_id?: string;
|
|
167
|
+
}
|
|
168
|
+
interface ListInboundRoutesResponse {
|
|
169
|
+
data: InboundRoute[];
|
|
170
|
+
meta: {
|
|
171
|
+
simulate_enabled: boolean;
|
|
172
|
+
retention_days: number;
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
type InboundMessageStatus = 'received' | 'processed' | 'failed';
|
|
176
|
+
interface InboundAttachment {
|
|
177
|
+
name: string;
|
|
178
|
+
content_type: string;
|
|
179
|
+
size_kb: number;
|
|
180
|
+
key: string;
|
|
181
|
+
}
|
|
182
|
+
interface InboundMessage {
|
|
183
|
+
id: string;
|
|
184
|
+
route_id: string | null;
|
|
185
|
+
from_addr: string;
|
|
186
|
+
from_name: string;
|
|
187
|
+
to_addr: string;
|
|
188
|
+
subject: string;
|
|
189
|
+
text: string;
|
|
190
|
+
html: string;
|
|
191
|
+
headers: Record<string, string>;
|
|
192
|
+
attachments: InboundAttachment[];
|
|
193
|
+
spam_verdict: string | null;
|
|
194
|
+
size_kb: number;
|
|
195
|
+
status: InboundMessageStatus;
|
|
196
|
+
error: string | null;
|
|
197
|
+
received_at: string;
|
|
198
|
+
}
|
|
199
|
+
interface ListInboundMessagesParams {
|
|
200
|
+
q?: string;
|
|
201
|
+
route_id?: string;
|
|
202
|
+
cursor?: string;
|
|
203
|
+
limit?: number;
|
|
204
|
+
}
|
|
205
|
+
interface ListInboundMessagesResponse {
|
|
206
|
+
data: InboundMessage[];
|
|
207
|
+
next_cursor?: string;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
declare class InboundRoutesResource {
|
|
211
|
+
private readonly client;
|
|
212
|
+
constructor(client: ApiClient);
|
|
213
|
+
list(): Promise<ListInboundRoutesResponse>;
|
|
214
|
+
create(params: CreateInboundRouteParams): Promise<InboundRoute>;
|
|
215
|
+
get(id: string): Promise<InboundRoute>;
|
|
216
|
+
update(id: string, params: UpdateInboundRouteParams): Promise<InboundRoute>;
|
|
217
|
+
delete(id: string): Promise<void>;
|
|
218
|
+
}
|
|
219
|
+
declare class InboundMessagesResource {
|
|
220
|
+
private readonly client;
|
|
221
|
+
constructor(client: ApiClient);
|
|
222
|
+
list(params?: ListInboundMessagesParams): Promise<ListInboundMessagesResponse>;
|
|
223
|
+
get(id: string): Promise<InboundMessage>;
|
|
224
|
+
raw(id: string, options?: {
|
|
225
|
+
signal?: AbortSignal;
|
|
226
|
+
}): Promise<BinaryResult>;
|
|
227
|
+
attachment(messageId: string, index: number, options?: {
|
|
228
|
+
signal?: AbortSignal;
|
|
229
|
+
}): Promise<BinaryResult>;
|
|
230
|
+
}
|
|
231
|
+
declare class InboundResource {
|
|
232
|
+
readonly routes: InboundRoutesResource;
|
|
233
|
+
readonly messages: InboundMessagesResource;
|
|
234
|
+
constructor(client: ApiClient);
|
|
235
|
+
}
|
|
236
|
+
|
|
131
237
|
type PlanLocale = 'en' | 'fr';
|
|
132
238
|
interface PlanTier {
|
|
133
239
|
emails: number;
|
|
@@ -193,6 +299,103 @@ declare class UnsubscribeResource {
|
|
|
193
299
|
preferences(token: string, topicIds: string[]): Promise<void>;
|
|
194
300
|
}
|
|
195
301
|
|
|
302
|
+
type WebhookEndpointStatus = 'active' | 'disabled';
|
|
303
|
+
interface WebhookEndpoint {
|
|
304
|
+
id: string;
|
|
305
|
+
name: string;
|
|
306
|
+
url: string;
|
|
307
|
+
secret_prefix: string;
|
|
308
|
+
events: string[];
|
|
309
|
+
status: WebhookEndpointStatus;
|
|
310
|
+
created_at: string;
|
|
311
|
+
updated_at: string;
|
|
312
|
+
}
|
|
313
|
+
interface CreateWebhookParams {
|
|
314
|
+
name: string;
|
|
315
|
+
url: string;
|
|
316
|
+
events: string[];
|
|
317
|
+
}
|
|
318
|
+
interface UpdateWebhookParams {
|
|
319
|
+
name: string;
|
|
320
|
+
url: string;
|
|
321
|
+
events: string[];
|
|
322
|
+
status: WebhookEndpointStatus;
|
|
323
|
+
}
|
|
324
|
+
interface WebhookCreated {
|
|
325
|
+
endpoint: WebhookEndpoint;
|
|
326
|
+
secret: string;
|
|
327
|
+
}
|
|
328
|
+
interface ListWebhooksParams {
|
|
329
|
+
cursor?: string;
|
|
330
|
+
limit?: number;
|
|
331
|
+
}
|
|
332
|
+
interface ListWebhooksResponse {
|
|
333
|
+
data: WebhookEndpoint[];
|
|
334
|
+
next_cursor?: string;
|
|
335
|
+
}
|
|
336
|
+
type WebhookDeliveryStatus = 'pending' | 'success' | 'failed';
|
|
337
|
+
interface WebhookDelivery {
|
|
338
|
+
id: string;
|
|
339
|
+
endpoint_id: string;
|
|
340
|
+
event_type: string;
|
|
341
|
+
payload: unknown;
|
|
342
|
+
status: WebhookDeliveryStatus;
|
|
343
|
+
attempts: number;
|
|
344
|
+
last_status_code: number | null;
|
|
345
|
+
last_error: string | null;
|
|
346
|
+
delivered_at: string | null;
|
|
347
|
+
created_at: string;
|
|
348
|
+
}
|
|
349
|
+
interface WebhookAttempt {
|
|
350
|
+
attempt: number;
|
|
351
|
+
status_code: number | null;
|
|
352
|
+
error: string | null;
|
|
353
|
+
duration_ms: number;
|
|
354
|
+
created_at: string;
|
|
355
|
+
}
|
|
356
|
+
interface WebhookDeliveryResult {
|
|
357
|
+
delivery: WebhookDelivery;
|
|
358
|
+
attempts: WebhookAttempt[];
|
|
359
|
+
}
|
|
360
|
+
interface ListWebhookDeliveriesParams {
|
|
361
|
+
endpoint_id?: string;
|
|
362
|
+
event_type?: string;
|
|
363
|
+
status?: WebhookDeliveryStatus;
|
|
364
|
+
cursor?: string;
|
|
365
|
+
limit?: number;
|
|
366
|
+
}
|
|
367
|
+
interface ListWebhookDeliveriesResponse {
|
|
368
|
+
data: WebhookDelivery[];
|
|
369
|
+
next_cursor?: string;
|
|
370
|
+
}
|
|
371
|
+
interface WebhookEventDescriptor {
|
|
372
|
+
type: string;
|
|
373
|
+
description: string;
|
|
374
|
+
sample: unknown;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
declare class WebhookDeliveriesResource {
|
|
378
|
+
private readonly client;
|
|
379
|
+
constructor(client: ApiClient);
|
|
380
|
+
list(params?: ListWebhookDeliveriesParams): Promise<ListWebhookDeliveriesResponse>;
|
|
381
|
+
get(id: string): Promise<WebhookDeliveryResult>;
|
|
382
|
+
redeliver(id: string): Promise<WebhookDelivery>;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
declare class WebhooksResource {
|
|
386
|
+
private readonly client;
|
|
387
|
+
readonly deliveries: WebhookDeliveriesResource;
|
|
388
|
+
constructor(client: ApiClient);
|
|
389
|
+
list(params?: ListWebhooksParams): Promise<ListWebhooksResponse>;
|
|
390
|
+
create(params: CreateWebhookParams): Promise<WebhookCreated>;
|
|
391
|
+
get(id: string): Promise<WebhookEndpoint>;
|
|
392
|
+
update(id: string, params: UpdateWebhookParams): Promise<WebhookEndpoint>;
|
|
393
|
+
delete(id: string): Promise<void>;
|
|
394
|
+
test(id: string, event?: string): Promise<WebhookDelivery>;
|
|
395
|
+
rotateSecret(id: string): Promise<WebhookCreated>;
|
|
396
|
+
events(): Promise<WebhookEventDescriptor[]>;
|
|
397
|
+
}
|
|
398
|
+
|
|
196
399
|
interface SendWhatsAppMessageParams {
|
|
197
400
|
template_id: string;
|
|
198
401
|
to: string[];
|
|
@@ -221,11 +424,14 @@ interface NotideusErrorOptions {
|
|
|
221
424
|
message: string;
|
|
222
425
|
status: number;
|
|
223
426
|
retryAfter?: number;
|
|
427
|
+
/** Admin-provided note, present on account_suspended errors. */
|
|
428
|
+
reason?: string;
|
|
224
429
|
}
|
|
225
430
|
declare class NotideusError extends Error {
|
|
226
431
|
readonly code: string;
|
|
227
432
|
readonly status: number;
|
|
228
433
|
readonly retryAfter?: number;
|
|
434
|
+
readonly reason?: string;
|
|
229
435
|
constructor(options: NotideusErrorOptions);
|
|
230
436
|
}
|
|
231
437
|
|
|
@@ -236,7 +442,10 @@ declare class Notideus {
|
|
|
236
442
|
readonly whatsapp: WhatsAppResource;
|
|
237
443
|
readonly unsubscribe: UnsubscribeResource;
|
|
238
444
|
readonly plans: PlansResource;
|
|
445
|
+
readonly webhooks: WebhooksResource;
|
|
446
|
+
readonly inbound: InboundResource;
|
|
239
447
|
constructor(apiKey?: string, options?: Omit<ClientOptions, 'apiKey'>);
|
|
240
448
|
}
|
|
241
449
|
|
|
242
|
-
export {
|
|
450
|
+
export { Notideus, NotideusError };
|
|
451
|
+
export type { BatchItemError, BatchItemResult, BinaryResult, BulkContactInput, ClientOptions, Contact, ContactStatus, ContactsTier, CreateContactParams, CreateInboundRouteParams, CreateWebhookParams, Email, FreeAllowances, InboundAttachment, InboundMessage, InboundMessageStatus, InboundRoute, InboundRouteStatus, ListContactsParams, ListContactsResponse, ListInboundMessagesParams, ListInboundMessagesResponse, ListInboundRoutesResponse, ListWebhookDeliveriesParams, ListWebhookDeliveriesResponse, ListWebhooksParams, ListWebhooksResponse, Plan, PlanCatalog, PlanLocale, PlanTier, SendEmailParams, SendWhatsAppMessageParams, UnsubscribeInfo, UnsubscribeTopic, UpdateContactParams, UpdateInboundRouteParams, UpdateWebhookParams, WebhookAttempt, WebhookCreated, WebhookDelivery, WebhookDeliveryResult, WebhookDeliveryStatus, WebhookEndpoint, WebhookEndpointStatus, WebhookEventDescriptor, WhatsAppMessage };
|
package/dist/index.js
CHANGED
|
@@ -3,12 +3,14 @@ var NotideusError = class extends Error {
|
|
|
3
3
|
code;
|
|
4
4
|
status;
|
|
5
5
|
retryAfter;
|
|
6
|
+
reason;
|
|
6
7
|
constructor(options) {
|
|
7
8
|
super(options.message);
|
|
8
9
|
this.name = "NotideusError";
|
|
9
10
|
this.code = options.code;
|
|
10
11
|
this.status = options.status;
|
|
11
12
|
this.retryAfter = options.retryAfter;
|
|
13
|
+
this.reason = options.reason;
|
|
12
14
|
}
|
|
13
15
|
};
|
|
14
16
|
|
|
@@ -44,6 +46,44 @@ var ApiClient = class {
|
|
|
44
46
|
}
|
|
45
47
|
}
|
|
46
48
|
}
|
|
49
|
+
// requestBinary downloads a binary endpoint (raw MIME, attachments). Auth
|
|
50
|
+
// headers are attached like request(); non-2xx responses raise NotideusError
|
|
51
|
+
// with the standard envelope. No retries — callers can re-invoke.
|
|
52
|
+
async requestBinary(path, options = {}) {
|
|
53
|
+
const headers = {
|
|
54
|
+
"User-Agent": `notideus-node/${VERSION}`
|
|
55
|
+
};
|
|
56
|
+
if (this.apiKey) headers.Authorization = `Bearer ${this.apiKey}`;
|
|
57
|
+
const controller = new AbortController();
|
|
58
|
+
const timer = setTimeout(() => controller.abort(), this.timeout);
|
|
59
|
+
const onCallerAbort = () => controller.abort();
|
|
60
|
+
if (options.signal) {
|
|
61
|
+
if (options.signal.aborted) controller.abort();
|
|
62
|
+
else options.signal.addEventListener("abort", onCallerAbort, { once: true });
|
|
63
|
+
}
|
|
64
|
+
try {
|
|
65
|
+
const res = await fetch(new URL(path, this.baseURL), { headers, signal: controller.signal });
|
|
66
|
+
if (!res.ok) throw await this.toError(res);
|
|
67
|
+
const disposition = res.headers.get("content-disposition") ?? "";
|
|
68
|
+
const match = CONTENT_DISPOSITION_FILENAME.exec(disposition);
|
|
69
|
+
return {
|
|
70
|
+
data: new Uint8Array(await res.arrayBuffer()),
|
|
71
|
+
contentType: res.headers.get("content-type") ?? "application/octet-stream",
|
|
72
|
+
filename: match ? match[1] : null
|
|
73
|
+
};
|
|
74
|
+
} catch (err) {
|
|
75
|
+
if (err instanceof NotideusError) throw err;
|
|
76
|
+
if (options.signal?.aborted) throw err;
|
|
77
|
+
throw new NotideusError({
|
|
78
|
+
code: controller.signal.aborted ? "request_timeout" : "network_error",
|
|
79
|
+
message: err instanceof Error ? err.message : String(err),
|
|
80
|
+
status: 0
|
|
81
|
+
});
|
|
82
|
+
} finally {
|
|
83
|
+
clearTimeout(timer);
|
|
84
|
+
options.signal?.removeEventListener("abort", onCallerAbort);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
47
87
|
delayMs(err, attempt) {
|
|
48
88
|
if (err instanceof NotideusError && err.retryAfter != null) {
|
|
49
89
|
return err.retryAfter * 1e3;
|
|
@@ -100,10 +140,12 @@ var ApiClient = class {
|
|
|
100
140
|
async toError(response) {
|
|
101
141
|
let code = "unknown_error";
|
|
102
142
|
let message = response.statusText || `HTTP ${response.status}`;
|
|
143
|
+
let reason;
|
|
103
144
|
try {
|
|
104
145
|
const parsed = await response.json();
|
|
105
146
|
if (parsed.error?.code) code = parsed.error.code;
|
|
106
147
|
if (parsed.error?.message) message = parsed.error.message;
|
|
148
|
+
if (typeof parsed.error?.reason === "string") reason = parsed.error.reason;
|
|
107
149
|
} catch {
|
|
108
150
|
}
|
|
109
151
|
const retryAfterHeader = response.headers.get("retry-after");
|
|
@@ -111,10 +153,12 @@ var ApiClient = class {
|
|
|
111
153
|
code,
|
|
112
154
|
message,
|
|
113
155
|
status: response.status,
|
|
114
|
-
retryAfter: retryAfterHeader ? Number(retryAfterHeader) : void 0
|
|
156
|
+
retryAfter: retryAfterHeader ? Number(retryAfterHeader) : void 0,
|
|
157
|
+
reason
|
|
115
158
|
});
|
|
116
159
|
}
|
|
117
160
|
};
|
|
161
|
+
var CONTENT_DISPOSITION_FILENAME = /filename="?([^";]+)"?/;
|
|
118
162
|
function hasIdempotencyKey(body) {
|
|
119
163
|
return typeof body === "object" && body !== null && body.idempotency_key != null;
|
|
120
164
|
}
|
|
@@ -182,6 +226,68 @@ var EmailsResource = class {
|
|
|
182
226
|
}
|
|
183
227
|
};
|
|
184
228
|
|
|
229
|
+
// src/resources/inbound.ts
|
|
230
|
+
function routePath(id) {
|
|
231
|
+
return `/v1/inbound/routes/${encodeURIComponent(id)}`;
|
|
232
|
+
}
|
|
233
|
+
function messagePath(id) {
|
|
234
|
+
return `/v1/inbound/messages/${encodeURIComponent(id)}`;
|
|
235
|
+
}
|
|
236
|
+
var InboundRoutesResource = class {
|
|
237
|
+
constructor(client) {
|
|
238
|
+
this.client = client;
|
|
239
|
+
}
|
|
240
|
+
client;
|
|
241
|
+
async list() {
|
|
242
|
+
return this.client.request("GET", "/v1/inbound/routes");
|
|
243
|
+
}
|
|
244
|
+
async create(params) {
|
|
245
|
+
const res = await this.client.request("POST", "/v1/inbound/routes", { body: params });
|
|
246
|
+
return res.route;
|
|
247
|
+
}
|
|
248
|
+
async get(id) {
|
|
249
|
+
const res = await this.client.request("GET", routePath(id));
|
|
250
|
+
return res.route;
|
|
251
|
+
}
|
|
252
|
+
async update(id, params) {
|
|
253
|
+
const res = await this.client.request("PATCH", routePath(id), { body: params });
|
|
254
|
+
return res.route;
|
|
255
|
+
}
|
|
256
|
+
async delete(id) {
|
|
257
|
+
await this.client.request("DELETE", routePath(id));
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
var InboundMessagesResource = class {
|
|
261
|
+
constructor(client) {
|
|
262
|
+
this.client = client;
|
|
263
|
+
}
|
|
264
|
+
client;
|
|
265
|
+
async list(params = {}) {
|
|
266
|
+
const { q, route_id, cursor, limit } = params;
|
|
267
|
+
return this.client.request("GET", "/v1/inbound/messages", {
|
|
268
|
+
query: { q, route_id, cursor, limit }
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
async get(id) {
|
|
272
|
+
const res = await this.client.request("GET", messagePath(id));
|
|
273
|
+
return res.message;
|
|
274
|
+
}
|
|
275
|
+
async raw(id, options = {}) {
|
|
276
|
+
return this.client.requestBinary(`${messagePath(id)}/raw`, options);
|
|
277
|
+
}
|
|
278
|
+
async attachment(messageId, index, options = {}) {
|
|
279
|
+
return this.client.requestBinary(`${messagePath(messageId)}/attachments/${index}`, options);
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
var InboundResource = class {
|
|
283
|
+
routes;
|
|
284
|
+
messages;
|
|
285
|
+
constructor(client) {
|
|
286
|
+
this.routes = new InboundRoutesResource(client);
|
|
287
|
+
this.messages = new InboundMessagesResource(client);
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
|
|
185
291
|
// src/resources/plans.ts
|
|
186
292
|
var PlansResource = class {
|
|
187
293
|
constructor(client) {
|
|
@@ -223,6 +329,78 @@ var UnsubscribeResource = class {
|
|
|
223
329
|
}
|
|
224
330
|
};
|
|
225
331
|
|
|
332
|
+
// src/resources/webhook-deliveries.ts
|
|
333
|
+
function deliveryPath(id) {
|
|
334
|
+
return `/v1/webhook-deliveries/${encodeURIComponent(id)}`;
|
|
335
|
+
}
|
|
336
|
+
var WebhookDeliveriesResource = class {
|
|
337
|
+
constructor(client) {
|
|
338
|
+
this.client = client;
|
|
339
|
+
}
|
|
340
|
+
client;
|
|
341
|
+
async list(params = {}) {
|
|
342
|
+
const { endpoint_id, event_type, status, cursor, limit } = params;
|
|
343
|
+
return this.client.request("GET", "/v1/webhook-deliveries", {
|
|
344
|
+
query: { endpoint_id, event_type, status, cursor, limit }
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
async get(id) {
|
|
348
|
+
return this.client.request("GET", deliveryPath(id));
|
|
349
|
+
}
|
|
350
|
+
async redeliver(id) {
|
|
351
|
+
const res = await this.client.request("POST", `${deliveryPath(id)}/redeliver`);
|
|
352
|
+
return res.delivery;
|
|
353
|
+
}
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
// src/resources/webhooks.ts
|
|
357
|
+
function webhookPath(id) {
|
|
358
|
+
return `/v1/webhooks/${encodeURIComponent(id)}`;
|
|
359
|
+
}
|
|
360
|
+
var WebhooksResource = class {
|
|
361
|
+
constructor(client) {
|
|
362
|
+
this.client = client;
|
|
363
|
+
this.deliveries = new WebhookDeliveriesResource(client);
|
|
364
|
+
}
|
|
365
|
+
client;
|
|
366
|
+
deliveries;
|
|
367
|
+
async list(params = {}) {
|
|
368
|
+
const { cursor, limit } = params;
|
|
369
|
+
return this.client.request("GET", "/v1/webhooks", { query: { cursor, limit } });
|
|
370
|
+
}
|
|
371
|
+
async create(params) {
|
|
372
|
+
return this.client.request("POST", "/v1/webhooks", { body: params });
|
|
373
|
+
}
|
|
374
|
+
async get(id) {
|
|
375
|
+
const res = await this.client.request("GET", webhookPath(id));
|
|
376
|
+
return res.endpoint;
|
|
377
|
+
}
|
|
378
|
+
async update(id, params) {
|
|
379
|
+
const res = await this.client.request("PATCH", webhookPath(id), { body: params });
|
|
380
|
+
return res.endpoint;
|
|
381
|
+
}
|
|
382
|
+
async delete(id) {
|
|
383
|
+
await this.client.request("DELETE", webhookPath(id));
|
|
384
|
+
}
|
|
385
|
+
async test(id, event) {
|
|
386
|
+
const res = await this.client.request(
|
|
387
|
+
"POST",
|
|
388
|
+
`${webhookPath(id)}/test`,
|
|
389
|
+
{ body: event ? { event } : {} }
|
|
390
|
+
);
|
|
391
|
+
return res.delivery;
|
|
392
|
+
}
|
|
393
|
+
// rotateSecret replaces the endpoint's signing secret; the new secret is
|
|
394
|
+
// returned exactly once. The old secret stops working immediately.
|
|
395
|
+
async rotateSecret(id) {
|
|
396
|
+
return this.client.request("POST", `${webhookPath(id)}/rotate-secret`, { body: {} });
|
|
397
|
+
}
|
|
398
|
+
async events() {
|
|
399
|
+
const res = await this.client.request("GET", "/v1/webhooks/meta/events");
|
|
400
|
+
return res.data;
|
|
401
|
+
}
|
|
402
|
+
};
|
|
403
|
+
|
|
226
404
|
// src/resources/whatsapp.ts
|
|
227
405
|
var WhatsAppResource = class {
|
|
228
406
|
messages;
|
|
@@ -257,6 +435,8 @@ var Notideus = class {
|
|
|
257
435
|
whatsapp;
|
|
258
436
|
unsubscribe;
|
|
259
437
|
plans;
|
|
438
|
+
webhooks;
|
|
439
|
+
inbound;
|
|
260
440
|
constructor(apiKey, options = {}) {
|
|
261
441
|
this.client = new ApiClient({ ...options, apiKey });
|
|
262
442
|
this.emails = new EmailsResource(this.client);
|
|
@@ -264,6 +444,8 @@ var Notideus = class {
|
|
|
264
444
|
this.whatsapp = new WhatsAppResource(this.client);
|
|
265
445
|
this.unsubscribe = new UnsubscribeResource(this.client);
|
|
266
446
|
this.plans = new PlansResource(this.client);
|
|
447
|
+
this.webhooks = new WebhooksResource(this.client);
|
|
448
|
+
this.inbound = new InboundResource(this.client);
|
|
267
449
|
}
|
|
268
450
|
};
|
|
269
451
|
export {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/errors.ts","../src/client.ts","../src/resources/contacts.ts","../src/resources/emails.ts","../src/resources/plans.ts","../src/resources/unsubscribe.ts","../src/resources/whatsapp.ts","../src/index.ts"],"sourcesContent":["export interface NotideusErrorOptions {\n code: string;\n message: string;\n status: number;\n retryAfter?: number;\n}\n\nexport class NotideusError extends Error {\n readonly code: string;\n readonly status: number;\n readonly retryAfter?: number;\n\n constructor(options: NotideusErrorOptions) {\n super(options.message);\n this.name = 'NotideusError';\n this.code = options.code;\n this.status = options.status;\n this.retryAfter = options.retryAfter;\n }\n}\n","import { NotideusError } from './errors.js';\n\nconst DEFAULT_BASE_URL = 'https://api.notideus.io';\nconst DEFAULT_TIMEOUT_MS = 30_000;\nconst VERSION = '0.1.0';\n\nexport interface ClientOptions {\n apiKey?: string;\n baseURL?: string;\n timeout?: number;\n maxRetries?: number;\n sleep?: (ms: number) => Promise<void>;\n}\n\nexport interface RequestOptions {\n query?: Record<string, string | number | undefined>;\n body?: unknown;\n authenticated?: boolean;\n signal?: AbortSignal;\n}\n\nexport class ApiClient {\n private readonly apiKey?: string;\n private readonly baseURL: string;\n private readonly timeout: number;\n private readonly maxRetries: number;\n private readonly sleep: (ms: number) => Promise<void>;\n\n constructor(options: ClientOptions = {}) {\n this.apiKey = options.apiKey;\n this.baseURL = options.baseURL ?? DEFAULT_BASE_URL;\n this.timeout = options.timeout ?? DEFAULT_TIMEOUT_MS;\n this.maxRetries = options.maxRetries ?? 2;\n this.sleep = options.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));\n }\n\n async request<T>(method: string, path: string, options: RequestOptions = {}): Promise<T> {\n const idempotent = method !== 'POST' || hasIdempotencyKey(options.body);\n let attempt = 0;\n for (;;) {\n try {\n return await this.attempt<T>(method, path, options);\n } catch (err) {\n if (!idempotent || !isRetriable(err) || attempt >= this.maxRetries) {\n throw err;\n }\n await this.sleep(this.delayMs(err, attempt));\n attempt += 1;\n }\n }\n }\n\n private delayMs(err: unknown, attempt: number): number {\n if (err instanceof NotideusError && err.retryAfter != null) {\n return err.retryAfter * 1000;\n }\n return Math.min(1000 * 2 ** attempt, 8000) + Math.floor(Math.random() * 250);\n }\n\n private async attempt<T>(method: string, path: string, options: RequestOptions): Promise<T> {\n const url = this.buildUrl(path, options.query);\n const headers: Record<string, string> = {\n 'User-Agent': `notideus-node/${VERSION}`\n };\n if (options.authenticated !== false && this.apiKey) {\n headers.Authorization = `Bearer ${this.apiKey}`;\n }\n let body: string | undefined;\n if (options.body !== undefined) {\n headers['Content-Type'] = 'application/json';\n body = JSON.stringify(options.body);\n }\n\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), this.timeout);\n const onCallerAbort = () => controller.abort();\n if (options.signal) {\n if (options.signal.aborted) controller.abort();\n else options.signal.addEventListener('abort', onCallerAbort, { once: true });\n }\n\n try {\n const response = await fetch(url, { method, headers, body, signal: controller.signal });\n if (response.status === 204) return undefined as T;\n if (!response.ok) throw await this.toError(response);\n return (await response.json()) as T;\n } catch (err) {\n if (err instanceof NotideusError) throw err;\n if (options.signal?.aborted) throw err;\n throw new NotideusError({\n code: controller.signal.aborted ? 'request_timeout' : 'network_error',\n message: err instanceof Error ? err.message : String(err),\n status: 0\n });\n } finally {\n clearTimeout(timer);\n options.signal?.removeEventListener('abort', onCallerAbort);\n }\n }\n\n private buildUrl(path: string, query?: RequestOptions['query']): string {\n const url = new URL(path, this.baseURL);\n if (query) {\n for (const [key, value] of Object.entries(query)) {\n if (value !== undefined) url.searchParams.set(key, String(value));\n }\n }\n return url.toString();\n }\n\n private async toError(response: Response): Promise<NotideusError> {\n let code = 'unknown_error';\n let message = response.statusText || `HTTP ${response.status}`;\n try {\n const parsed = (await response.json()) as { error?: { code?: string; message?: string } };\n if (parsed.error?.code) code = parsed.error.code;\n if (parsed.error?.message) message = parsed.error.message;\n } catch {\n // non-JSON error body — keep the defaults\n }\n const retryAfterHeader = response.headers.get('retry-after');\n return new NotideusError({\n code,\n message,\n status: response.status,\n retryAfter: retryAfterHeader ? Number(retryAfterHeader) : undefined\n });\n }\n}\n\nfunction hasIdempotencyKey(body: unknown): boolean {\n return (\n typeof body === 'object' &&\n body !== null &&\n (body as Record<string, unknown>).idempotency_key != null\n );\n}\n\nfunction isRetriable(err: unknown): boolean {\n if (!(err instanceof NotideusError)) return false;\n if (err.code === 'network_error' || err.code === 'request_timeout') return true;\n return err.status === 429 || err.status >= 500;\n}\n","import type { ApiClient } from '../client.js';\nimport type { BatchItemResult } from '../types/common.js';\nimport type {\n BulkContactInput,\n Contact,\n CreateContactParams,\n ListContactsParams,\n ListContactsResponse,\n UpdateContactParams\n} from '../types/contact.js';\n\nfunction contactPath(email: string): string {\n return `/v1/contacts/${encodeURIComponent(email)}`;\n}\n\nexport class ContactsResource {\n constructor(private readonly client: ApiClient) {}\n\n async list(params: ListContactsParams = {}): Promise<ListContactsResponse> {\n const { limit, status, email, cursor } = params;\n return this.client.request<ListContactsResponse>('GET', '/v1/contacts', {\n query: { limit, status, email, cursor }\n });\n }\n\n async create(params: CreateContactParams): Promise<Contact> {\n return this.client.request<Contact>('POST', '/v1/contacts', { body: params });\n }\n\n async get(email: string): Promise<Contact> {\n return this.client.request<Contact>('GET', contactPath(email));\n }\n\n async update(email: string, params: UpdateContactParams): Promise<Contact> {\n return this.client.request<Contact>('PATCH', contactPath(email), { body: params });\n }\n\n async delete(email: string): Promise<void> {\n await this.client.request<void>('DELETE', contactPath(email));\n }\n\n async bulk(contacts: BulkContactInput[]): Promise<BatchItemResult[]> {\n const res = await this.client.request<{ data: BatchItemResult[] }>('POST', '/v1/contacts/bulk', {\n body: { contacts }\n });\n return res.data;\n }\n\n async unsubscribe(email: string): Promise<Contact> {\n return this.client.request<Contact>('POST', `${contactPath(email)}/unsubscribe`);\n }\n\n async resubscribe(email: string): Promise<Contact> {\n return this.client.request<Contact>('POST', `${contactPath(email)}/resubscribe`);\n }\n}\n","import type { ApiClient } from '../client.js';\nimport type { BatchItemResult } from '../types/common.js';\nimport type { Email, SendEmailParams } from '../types/email.js';\n\nexport class EmailsResource {\n constructor(private readonly client: ApiClient) {}\n\n async send(params: SendEmailParams): Promise<Email> {\n return this.client.request<Email>('POST', '/v1/emails', { body: params });\n }\n\n async sendBatch(emails: SendEmailParams[]): Promise<BatchItemResult[]> {\n const res = await this.client.request<{ data: BatchItemResult[] }>('POST', '/v1/emails/batch', {\n body: { emails }\n });\n return res.data;\n }\n}\n","import type { ApiClient } from '../client.js';\nimport type { PlanCatalog, PlanLocale } from '../types/plans.js';\n\nexport class PlansResource {\n constructor(private readonly client: ApiClient) {}\n\n async list(params: { locale?: PlanLocale } = {}): Promise<PlanCatalog> {\n return this.client.request<PlanCatalog>('GET', '/v1/plans', {\n query: { locale: params.locale },\n authenticated: false\n });\n }\n}\n","import type { ApiClient } from '../client.js';\nimport type { UnsubscribeInfo } from '../types/unsubscribe.js';\n\nexport class UnsubscribeResource {\n constructor(private readonly client: ApiClient) {}\n\n async info(token: string): Promise<UnsubscribeInfo> {\n return this.client.request<UnsubscribeInfo>('GET', '/v1/unsubscribe/info', {\n query: { t: token },\n authenticated: false\n });\n }\n\n async unsubscribe(token: string, topicIds?: string[]): Promise<void> {\n const body: Record<string, unknown> = { token };\n if (topicIds !== undefined) {\n body.topic_ids = topicIds;\n }\n await this.client.request<void>('POST', '/v1/unsubscribe', { body, authenticated: false });\n }\n\n async preferences(token: string, topicIds: string[]): Promise<void> {\n await this.client.request<void>('POST', '/v1/unsubscribe/preferences', {\n body: { token, topic_ids: topicIds },\n authenticated: false\n });\n }\n}\n","import type { ApiClient } from '../client.js';\nimport type { BatchItemResult } from '../types/common.js';\nimport type { SendWhatsAppMessageParams, WhatsAppMessage } from '../types/whatsapp.js';\n\nexport class WhatsAppResource {\n readonly messages: WhatsAppMessagesResource;\n\n constructor(client: ApiClient) {\n this.messages = new WhatsAppMessagesResource(client);\n }\n}\n\nexport class WhatsAppMessagesResource {\n constructor(private readonly client: ApiClient) {}\n\n async send(params: SendWhatsAppMessageParams): Promise<WhatsAppMessage[]> {\n const res = await this.client.request<{ data: WhatsAppMessage[] }>('POST', '/v1/whatsapp/messages', {\n body: params\n });\n return res.data;\n }\n\n async sendBatch(messages: SendWhatsAppMessageParams[]): Promise<BatchItemResult[]> {\n const res = await this.client.request<{ data: BatchItemResult[] }>('POST', '/v1/whatsapp/messages/batch', {\n body: { messages }\n });\n return res.data;\n }\n}\n","import { ApiClient, type ClientOptions } from './client.js';\nimport { ContactsResource } from './resources/contacts.js';\nimport { EmailsResource } from './resources/emails.js';\nimport { PlansResource } from './resources/plans.js';\nimport { UnsubscribeResource } from './resources/unsubscribe.js';\nimport { WhatsAppResource } from './resources/whatsapp.js';\n\nexport { NotideusError } from './errors.js';\nexport type { ClientOptions } from './client.js';\nexport type { BatchItemError, BatchItemResult } from './types/common.js';\nexport type {\n BulkContactInput,\n Contact,\n ContactStatus,\n CreateContactParams,\n ListContactsParams,\n ListContactsResponse,\n UpdateContactParams\n} from './types/contact.js';\nexport type { Email, SendEmailParams } from './types/email.js';\nexport type {\n ContactsTier,\n FreeAllowances,\n Plan,\n PlanCatalog,\n PlanLocale,\n PlanTier\n} from './types/plans.js';\nexport type { SendWhatsAppMessageParams, WhatsAppMessage } from './types/whatsapp.js';\nexport type { UnsubscribeInfo, UnsubscribeTopic } from './types/unsubscribe.js';\n\nexport class Notideus {\n private readonly client: ApiClient;\n readonly emails: EmailsResource;\n readonly contacts: ContactsResource;\n readonly whatsapp: WhatsAppResource;\n readonly unsubscribe: UnsubscribeResource;\n readonly plans: PlansResource;\n\n constructor(apiKey?: string, options: Omit<ClientOptions, 'apiKey'> = {}) {\n this.client = new ApiClient({ ...options, apiKey });\n this.emails = new EmailsResource(this.client);\n this.contacts = new ContactsResource(this.client);\n this.whatsapp = new WhatsAppResource(this.client);\n this.unsubscribe = new UnsubscribeResource(this.client);\n this.plans = new PlansResource(this.client);\n }\n}\n"],"mappings":";AAOO,IAAM,gBAAN,cAA4B,MAAM;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EAET,YAAY,SAA+B;AACzC,UAAM,QAAQ,OAAO;AACrB,SAAK,OAAO;AACZ,SAAK,OAAO,QAAQ;AACpB,SAAK,SAAS,QAAQ;AACtB,SAAK,aAAa,QAAQ;AAAA,EAC5B;AACF;;;ACjBA,IAAM,mBAAmB;AACzB,IAAM,qBAAqB;AAC3B,IAAM,UAAU;AAiBT,IAAM,YAAN,MAAgB;AAAA,EACJ;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEjB,YAAY,UAAyB,CAAC,GAAG;AACvC,SAAK,SAAS,QAAQ;AACtB,SAAK,UAAU,QAAQ,WAAW;AAClC,SAAK,UAAU,QAAQ,WAAW;AAClC,SAAK,aAAa,QAAQ,cAAc;AACxC,SAAK,QAAQ,QAAQ,UAAU,CAAC,OAAO,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,EAAE,CAAC;AAAA,EACzF;AAAA,EAEA,MAAM,QAAW,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5C,SAAK,WAAW,IAAI,iBAAiB,KAAK,MAAM;AAChD,SAAK,WAAW,IAAI,iBAAiB,KAAK,MAAM;AAChD,SAAK,cAAc,IAAI,oBAAoB,KAAK,MAAM;AACtD,SAAK,QAAQ,IAAI,cAAc,KAAK,MAAM;AAAA,EAC5C;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/errors.ts","../src/client.ts","../src/resources/contacts.ts","../src/resources/emails.ts","../src/resources/inbound.ts","../src/resources/plans.ts","../src/resources/unsubscribe.ts","../src/resources/webhook-deliveries.ts","../src/resources/webhooks.ts","../src/resources/whatsapp.ts","../src/index.ts"],"sourcesContent":["export interface NotideusErrorOptions {\n code: string;\n message: string;\n status: number;\n retryAfter?: number;\n /** Admin-provided note, present on account_suspended errors. */\n reason?: string;\n}\n\nexport class NotideusError extends Error {\n readonly code: string;\n readonly status: number;\n readonly retryAfter?: number;\n readonly reason?: string;\n\n constructor(options: NotideusErrorOptions) {\n super(options.message);\n this.name = 'NotideusError';\n this.code = options.code;\n this.status = options.status;\n this.retryAfter = options.retryAfter;\n this.reason = options.reason;\n }\n}\n","import { NotideusError } from './errors.js';\n\nconst DEFAULT_BASE_URL = 'https://api.notideus.io';\nconst DEFAULT_TIMEOUT_MS = 30_000;\nconst VERSION = '0.1.0';\n\nexport interface ClientOptions {\n apiKey?: string;\n baseURL?: string;\n timeout?: number;\n maxRetries?: number;\n sleep?: (ms: number) => Promise<void>;\n}\n\nexport interface RequestOptions {\n query?: Record<string, string | number | undefined>;\n body?: unknown;\n authenticated?: boolean;\n signal?: AbortSignal;\n}\n\nexport interface BinaryResult {\n data: Uint8Array;\n contentType: string;\n filename: string | null;\n}\n\nexport class ApiClient {\n private readonly apiKey?: string;\n private readonly baseURL: string;\n private readonly timeout: number;\n private readonly maxRetries: number;\n private readonly sleep: (ms: number) => Promise<void>;\n\n constructor(options: ClientOptions = {}) {\n this.apiKey = options.apiKey;\n this.baseURL = options.baseURL ?? DEFAULT_BASE_URL;\n this.timeout = options.timeout ?? DEFAULT_TIMEOUT_MS;\n this.maxRetries = options.maxRetries ?? 2;\n this.sleep = options.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));\n }\n\n async request<T>(method: string, path: string, options: RequestOptions = {}): Promise<T> {\n const idempotent = method !== 'POST' || hasIdempotencyKey(options.body);\n let attempt = 0;\n for (;;) {\n try {\n return await this.attempt<T>(method, path, options);\n } catch (err) {\n if (!idempotent || !isRetriable(err) || attempt >= this.maxRetries) {\n throw err;\n }\n await this.sleep(this.delayMs(err, attempt));\n attempt += 1;\n }\n }\n }\n\n // requestBinary downloads a binary endpoint (raw MIME, attachments). Auth\n // headers are attached like request(); non-2xx responses raise NotideusError\n // with the standard envelope. No retries — callers can re-invoke.\n async requestBinary(path: string, options: { signal?: AbortSignal } = {}): Promise<BinaryResult> {\n const headers: Record<string, string> = {\n 'User-Agent': `notideus-node/${VERSION}`\n };\n if (this.apiKey) headers.Authorization = `Bearer ${this.apiKey}`;\n\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), this.timeout);\n const onCallerAbort = () => controller.abort();\n if (options.signal) {\n if (options.signal.aborted) controller.abort();\n else options.signal.addEventListener('abort', onCallerAbort, { once: true });\n }\n\n try {\n const res = await fetch(new URL(path, this.baseURL), { headers, signal: controller.signal });\n if (!res.ok) throw await this.toError(res);\n const disposition = res.headers.get('content-disposition') ?? '';\n const match = CONTENT_DISPOSITION_FILENAME.exec(disposition);\n return {\n data: new Uint8Array(await res.arrayBuffer()),\n contentType: res.headers.get('content-type') ?? 'application/octet-stream',\n filename: match ? match[1] : null\n };\n } catch (err) {\n if (err instanceof NotideusError) throw err;\n if (options.signal?.aborted) throw err;\n throw new NotideusError({\n code: controller.signal.aborted ? 'request_timeout' : 'network_error',\n message: err instanceof Error ? err.message : String(err),\n status: 0\n });\n } finally {\n clearTimeout(timer);\n options.signal?.removeEventListener('abort', onCallerAbort);\n }\n }\n\n private delayMs(err: unknown, attempt: number): number {\n if (err instanceof NotideusError && err.retryAfter != null) {\n return err.retryAfter * 1000;\n }\n return Math.min(1000 * 2 ** attempt, 8000) + Math.floor(Math.random() * 250);\n }\n\n private async attempt<T>(method: string, path: string, options: RequestOptions): Promise<T> {\n const url = this.buildUrl(path, options.query);\n const headers: Record<string, string> = {\n 'User-Agent': `notideus-node/${VERSION}`\n };\n if (options.authenticated !== false && this.apiKey) {\n headers.Authorization = `Bearer ${this.apiKey}`;\n }\n let body: string | undefined;\n if (options.body !== undefined) {\n headers['Content-Type'] = 'application/json';\n body = JSON.stringify(options.body);\n }\n\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), this.timeout);\n const onCallerAbort = () => controller.abort();\n if (options.signal) {\n if (options.signal.aborted) controller.abort();\n else options.signal.addEventListener('abort', onCallerAbort, { once: true });\n }\n\n try {\n const response = await fetch(url, { method, headers, body, signal: controller.signal });\n if (response.status === 204) return undefined as T;\n if (!response.ok) throw await this.toError(response);\n return (await response.json()) as T;\n } catch (err) {\n if (err instanceof NotideusError) throw err;\n if (options.signal?.aborted) throw err;\n throw new NotideusError({\n code: controller.signal.aborted ? 'request_timeout' : 'network_error',\n message: err instanceof Error ? err.message : String(err),\n status: 0\n });\n } finally {\n clearTimeout(timer);\n options.signal?.removeEventListener('abort', onCallerAbort);\n }\n }\n\n private buildUrl(path: string, query?: RequestOptions['query']): string {\n const url = new URL(path, this.baseURL);\n if (query) {\n for (const [key, value] of Object.entries(query)) {\n if (value !== undefined) url.searchParams.set(key, String(value));\n }\n }\n return url.toString();\n }\n\n private async toError(response: Response): Promise<NotideusError> {\n let code = 'unknown_error';\n let message = response.statusText || `HTTP ${response.status}`;\n let reason: string | undefined;\n try {\n const parsed = (await response.json()) as { error?: { code?: string; message?: string; reason?: string } };\n if (parsed.error?.code) code = parsed.error.code;\n if (parsed.error?.message) message = parsed.error.message;\n if (typeof parsed.error?.reason === 'string') reason = parsed.error.reason;\n } catch {\n // non-JSON error body — keep the defaults\n }\n const retryAfterHeader = response.headers.get('retry-after');\n return new NotideusError({\n code,\n message,\n status: response.status,\n retryAfter: retryAfterHeader ? Number(retryAfterHeader) : undefined,\n reason\n });\n }\n}\n\nconst CONTENT_DISPOSITION_FILENAME = /filename=\"?([^\";]+)\"?/;\n\nfunction hasIdempotencyKey(body: unknown): boolean {\n return (\n typeof body === 'object' &&\n body !== null &&\n (body as Record<string, unknown>).idempotency_key != null\n );\n}\n\nfunction isRetriable(err: unknown): boolean {\n if (!(err instanceof NotideusError)) return false;\n if (err.code === 'network_error' || err.code === 'request_timeout') return true;\n return err.status === 429 || err.status >= 500;\n}\n","import type { ApiClient } from '../client.js';\nimport type { BatchItemResult } from '../types/common.js';\nimport type {\n BulkContactInput,\n Contact,\n CreateContactParams,\n ListContactsParams,\n ListContactsResponse,\n UpdateContactParams\n} from '../types/contact.js';\n\nfunction contactPath(email: string): string {\n return `/v1/contacts/${encodeURIComponent(email)}`;\n}\n\nexport class ContactsResource {\n constructor(private readonly client: ApiClient) {}\n\n async list(params: ListContactsParams = {}): Promise<ListContactsResponse> {\n const { limit, status, email, cursor } = params;\n return this.client.request<ListContactsResponse>('GET', '/v1/contacts', {\n query: { limit, status, email, cursor }\n });\n }\n\n async create(params: CreateContactParams): Promise<Contact> {\n return this.client.request<Contact>('POST', '/v1/contacts', { body: params });\n }\n\n async get(email: string): Promise<Contact> {\n return this.client.request<Contact>('GET', contactPath(email));\n }\n\n async update(email: string, params: UpdateContactParams): Promise<Contact> {\n return this.client.request<Contact>('PATCH', contactPath(email), { body: params });\n }\n\n async delete(email: string): Promise<void> {\n await this.client.request<void>('DELETE', contactPath(email));\n }\n\n async bulk(contacts: BulkContactInput[]): Promise<BatchItemResult[]> {\n const res = await this.client.request<{ data: BatchItemResult[] }>('POST', '/v1/contacts/bulk', {\n body: { contacts }\n });\n return res.data;\n }\n\n async unsubscribe(email: string): Promise<Contact> {\n return this.client.request<Contact>('POST', `${contactPath(email)}/unsubscribe`);\n }\n\n async resubscribe(email: string): Promise<Contact> {\n return this.client.request<Contact>('POST', `${contactPath(email)}/resubscribe`);\n }\n}\n","import type { ApiClient } from '../client.js';\nimport type { BatchItemResult } from '../types/common.js';\nimport type { Email, SendEmailParams } from '../types/email.js';\n\nexport class EmailsResource {\n constructor(private readonly client: ApiClient) {}\n\n async send(params: SendEmailParams): Promise<Email> {\n return this.client.request<Email>('POST', '/v1/emails', { body: params });\n }\n\n async sendBatch(emails: SendEmailParams[]): Promise<BatchItemResult[]> {\n const res = await this.client.request<{ data: BatchItemResult[] }>('POST', '/v1/emails/batch', {\n body: { emails }\n });\n return res.data;\n }\n}\n","import type { ApiClient, BinaryResult } from '../client.js';\nimport type {\n CreateInboundRouteParams,\n InboundMessage,\n InboundRoute,\n ListInboundMessagesParams,\n ListInboundMessagesResponse,\n ListInboundRoutesResponse,\n UpdateInboundRouteParams\n} from '../types/inbound.js';\n\nfunction routePath(id: string): string {\n return `/v1/inbound/routes/${encodeURIComponent(id)}`;\n}\n\nfunction messagePath(id: string): string {\n return `/v1/inbound/messages/${encodeURIComponent(id)}`;\n}\n\nexport class InboundRoutesResource {\n constructor(private readonly client: ApiClient) {}\n\n async list(): Promise<ListInboundRoutesResponse> {\n return this.client.request<ListInboundRoutesResponse>('GET', '/v1/inbound/routes');\n }\n\n async create(params: CreateInboundRouteParams): Promise<InboundRoute> {\n const res = await this.client.request<{ route: InboundRoute }>('POST', '/v1/inbound/routes', { body: params });\n return res.route;\n }\n\n async get(id: string): Promise<InboundRoute> {\n const res = await this.client.request<{ route: InboundRoute }>('GET', routePath(id));\n return res.route;\n }\n\n async update(id: string, params: UpdateInboundRouteParams): Promise<InboundRoute> {\n const res = await this.client.request<{ route: InboundRoute }>('PATCH', routePath(id), { body: params });\n return res.route;\n }\n\n async delete(id: string): Promise<void> {\n await this.client.request<void>('DELETE', routePath(id));\n }\n}\n\nexport class InboundMessagesResource {\n constructor(private readonly client: ApiClient) {}\n\n async list(params: ListInboundMessagesParams = {}): Promise<ListInboundMessagesResponse> {\n const { q, route_id, cursor, limit } = params;\n return this.client.request<ListInboundMessagesResponse>('GET', '/v1/inbound/messages', {\n query: { q, route_id, cursor, limit }\n });\n }\n\n async get(id: string): Promise<InboundMessage> {\n const res = await this.client.request<{ message: InboundMessage }>('GET', messagePath(id));\n return res.message;\n }\n\n async raw(id: string, options: { signal?: AbortSignal } = {}): Promise<BinaryResult> {\n return this.client.requestBinary(`${messagePath(id)}/raw`, options);\n }\n\n async attachment(messageId: string, index: number, options: { signal?: AbortSignal } = {}): Promise<BinaryResult> {\n return this.client.requestBinary(`${messagePath(messageId)}/attachments/${index}`, options);\n }\n}\n\nexport class InboundResource {\n readonly routes: InboundRoutesResource;\n readonly messages: InboundMessagesResource;\n\n constructor(client: ApiClient) {\n this.routes = new InboundRoutesResource(client);\n this.messages = new InboundMessagesResource(client);\n }\n}\n","import type { ApiClient } from '../client.js';\nimport type { PlanCatalog, PlanLocale } from '../types/plans.js';\n\nexport class PlansResource {\n constructor(private readonly client: ApiClient) {}\n\n async list(params: { locale?: PlanLocale } = {}): Promise<PlanCatalog> {\n return this.client.request<PlanCatalog>('GET', '/v1/plans', {\n query: { locale: params.locale },\n authenticated: false\n });\n }\n}\n","import type { ApiClient } from '../client.js';\nimport type { UnsubscribeInfo } from '../types/unsubscribe.js';\n\nexport class UnsubscribeResource {\n constructor(private readonly client: ApiClient) {}\n\n async info(token: string): Promise<UnsubscribeInfo> {\n return this.client.request<UnsubscribeInfo>('GET', '/v1/unsubscribe/info', {\n query: { t: token },\n authenticated: false\n });\n }\n\n async unsubscribe(token: string, topicIds?: string[]): Promise<void> {\n const body: Record<string, unknown> = { token };\n if (topicIds !== undefined) {\n body.topic_ids = topicIds;\n }\n await this.client.request<void>('POST', '/v1/unsubscribe', { body, authenticated: false });\n }\n\n async preferences(token: string, topicIds: string[]): Promise<void> {\n await this.client.request<void>('POST', '/v1/unsubscribe/preferences', {\n body: { token, topic_ids: topicIds },\n authenticated: false\n });\n }\n}\n","import type { ApiClient } from '../client.js';\nimport type {\n ListWebhookDeliveriesParams,\n ListWebhookDeliveriesResponse,\n WebhookDelivery,\n WebhookDeliveryResult\n} from '../types/webhook.js';\n\nfunction deliveryPath(id: string): string {\n return `/v1/webhook-deliveries/${encodeURIComponent(id)}`;\n}\n\nexport class WebhookDeliveriesResource {\n constructor(private readonly client: ApiClient) {}\n\n async list(params: ListWebhookDeliveriesParams = {}): Promise<ListWebhookDeliveriesResponse> {\n const { endpoint_id, event_type, status, cursor, limit } = params;\n return this.client.request<ListWebhookDeliveriesResponse>('GET', '/v1/webhook-deliveries', {\n query: { endpoint_id, event_type, status, cursor, limit }\n });\n }\n\n async get(id: string): Promise<WebhookDeliveryResult> {\n return this.client.request<WebhookDeliveryResult>('GET', deliveryPath(id));\n }\n\n async redeliver(id: string): Promise<WebhookDelivery> {\n const res = await this.client.request<{ delivery: WebhookDelivery }>('POST', `${deliveryPath(id)}/redeliver`);\n return res.delivery;\n }\n}\n","import type { ApiClient } from '../client.js';\nimport { WebhookDeliveriesResource } from './webhook-deliveries.js';\nimport type {\n CreateWebhookParams,\n ListWebhooksParams,\n ListWebhooksResponse,\n UpdateWebhookParams,\n WebhookCreated,\n WebhookDelivery,\n WebhookEndpoint,\n WebhookEventDescriptor\n} from '../types/webhook.js';\n\nfunction webhookPath(id: string): string {\n return `/v1/webhooks/${encodeURIComponent(id)}`;\n}\n\nexport class WebhooksResource {\n readonly deliveries: WebhookDeliveriesResource;\n\n constructor(private readonly client: ApiClient) {\n this.deliveries = new WebhookDeliveriesResource(client);\n }\n\n async list(params: ListWebhooksParams = {}): Promise<ListWebhooksResponse> {\n const { cursor, limit } = params;\n return this.client.request<ListWebhooksResponse>('GET', '/v1/webhooks', { query: { cursor, limit } });\n }\n\n async create(params: CreateWebhookParams): Promise<WebhookCreated> {\n return this.client.request<WebhookCreated>('POST', '/v1/webhooks', { body: params });\n }\n\n async get(id: string): Promise<WebhookEndpoint> {\n const res = await this.client.request<{ endpoint: WebhookEndpoint }>('GET', webhookPath(id));\n return res.endpoint;\n }\n\n async update(id: string, params: UpdateWebhookParams): Promise<WebhookEndpoint> {\n const res = await this.client.request<{ endpoint: WebhookEndpoint }>('PATCH', webhookPath(id), { body: params });\n return res.endpoint;\n }\n\n async delete(id: string): Promise<void> {\n await this.client.request<void>('DELETE', webhookPath(id));\n }\n\n async test(id: string, event?: string): Promise<WebhookDelivery> {\n const res = await this.client.request<{ delivery: WebhookDelivery }>(\n 'POST',\n `${webhookPath(id)}/test`,\n { body: event ? { event } : {} }\n );\n return res.delivery;\n }\n\n // rotateSecret replaces the endpoint's signing secret; the new secret is\n // returned exactly once. The old secret stops working immediately.\n async rotateSecret(id: string): Promise<WebhookCreated> {\n return this.client.request<WebhookCreated>('POST', `${webhookPath(id)}/rotate-secret`, { body: {} });\n }\n\n async events(): Promise<WebhookEventDescriptor[]> {\n const res = await this.client.request<{ data: WebhookEventDescriptor[] }>('GET', '/v1/webhooks/meta/events');\n return res.data;\n }\n}\n","import type { ApiClient } from '../client.js';\nimport type { BatchItemResult } from '../types/common.js';\nimport type { SendWhatsAppMessageParams, WhatsAppMessage } from '../types/whatsapp.js';\n\nexport class WhatsAppResource {\n readonly messages: WhatsAppMessagesResource;\n\n constructor(client: ApiClient) {\n this.messages = new WhatsAppMessagesResource(client);\n }\n}\n\nexport class WhatsAppMessagesResource {\n constructor(private readonly client: ApiClient) {}\n\n async send(params: SendWhatsAppMessageParams): Promise<WhatsAppMessage[]> {\n const res = await this.client.request<{ data: WhatsAppMessage[] }>('POST', '/v1/whatsapp/messages', {\n body: params\n });\n return res.data;\n }\n\n async sendBatch(messages: SendWhatsAppMessageParams[]): Promise<BatchItemResult[]> {\n const res = await this.client.request<{ data: BatchItemResult[] }>('POST', '/v1/whatsapp/messages/batch', {\n body: { messages }\n });\n return res.data;\n }\n}\n","import { ApiClient, type ClientOptions } from './client.js';\nimport { ContactsResource } from './resources/contacts.js';\nimport { EmailsResource } from './resources/emails.js';\nimport { InboundResource } from './resources/inbound.js';\nimport { PlansResource } from './resources/plans.js';\nimport { UnsubscribeResource } from './resources/unsubscribe.js';\nimport { WebhooksResource } from './resources/webhooks.js';\nimport { WhatsAppResource } from './resources/whatsapp.js';\n\nexport { NotideusError } from './errors.js';\nexport type { BinaryResult, ClientOptions } from './client.js';\nexport type { BatchItemError, BatchItemResult } from './types/common.js';\nexport type {\n BulkContactInput,\n Contact,\n ContactStatus,\n CreateContactParams,\n ListContactsParams,\n ListContactsResponse,\n UpdateContactParams\n} from './types/contact.js';\nexport type { Email, SendEmailParams } from './types/email.js';\nexport type {\n CreateInboundRouteParams,\n InboundAttachment,\n InboundMessage,\n InboundMessageStatus,\n InboundRoute,\n InboundRouteStatus,\n ListInboundMessagesParams,\n ListInboundMessagesResponse,\n ListInboundRoutesResponse,\n UpdateInboundRouteParams\n} from './types/inbound.js';\nexport type {\n ContactsTier,\n FreeAllowances,\n Plan,\n PlanCatalog,\n PlanLocale,\n PlanTier\n} from './types/plans.js';\nexport type { SendWhatsAppMessageParams, WhatsAppMessage } from './types/whatsapp.js';\nexport type { UnsubscribeInfo, UnsubscribeTopic } from './types/unsubscribe.js';\nexport type {\n CreateWebhookParams,\n ListWebhookDeliveriesParams,\n ListWebhookDeliveriesResponse,\n ListWebhooksParams,\n ListWebhooksResponse,\n UpdateWebhookParams,\n WebhookAttempt,\n WebhookCreated,\n WebhookDelivery,\n WebhookDeliveryResult,\n WebhookDeliveryStatus,\n WebhookEndpoint,\n WebhookEndpointStatus,\n WebhookEventDescriptor\n} from './types/webhook.js';\n\nexport class Notideus {\n private readonly client: ApiClient;\n readonly emails: EmailsResource;\n readonly contacts: ContactsResource;\n readonly whatsapp: WhatsAppResource;\n readonly unsubscribe: UnsubscribeResource;\n readonly plans: PlansResource;\n readonly webhooks: WebhooksResource;\n readonly inbound: InboundResource;\n\n constructor(apiKey?: string, options: Omit<ClientOptions, 'apiKey'> = {}) {\n this.client = new ApiClient({ ...options, apiKey });\n this.emails = new EmailsResource(this.client);\n this.contacts = new ContactsResource(this.client);\n this.whatsapp = new WhatsAppResource(this.client);\n this.unsubscribe = new UnsubscribeResource(this.client);\n this.plans = new PlansResource(this.client);\n this.webhooks = new WebhooksResource(this.client);\n this.inbound = new InboundResource(this.client);\n }\n}\n"],"mappings":";AASO,IAAM,gBAAN,cAA4B,MAAM;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAET,YAAY,SAA+B;AACzC,UAAM,QAAQ,OAAO;AACrB,SAAK,OAAO;AACZ,SAAK,OAAO,QAAQ;AACpB,SAAK,SAAS,QAAQ;AACtB,SAAK,aAAa,QAAQ;AAC1B,SAAK,SAAS,QAAQ;AAAA,EACxB;AACF;;;ACrBA,IAAM,mBAAmB;AACzB,IAAM,qBAAqB;AAC3B,IAAM,UAAU;AAuBT,IAAM,YAAN,MAAgB;AAAA,EACJ;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEjB,YAAY,UAAyB,CAAC,GAAG;AACvC,SAAK,SAAS,QAAQ;AACtB,SAAK,UAAU,QAAQ,WAAW;AAClC,SAAK,UAAU,QAAQ,WAAW;AAClC,SAAK,aAAa,QAAQ,cAAc;AACxC,SAAK,QAAQ,QAAQ,UAAU,CAAC,OAAO,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,EAAE,CAAC;AAAA,EACzF;AAAA,EAEA,MAAM,QAAW,QAAgB,MAAc,UAA0B,CAAC,GAAe;AACvF,UAAM,aAAa,WAAW,UAAU,kBAAkB,QAAQ,IAAI;AACtE,QAAI,UAAU;AACd,eAAS;AACP,UAAI;AACF,eAAO,MAAM,KAAK,QAAW,QAAQ,MAAM,OAAO;AAAA,MACpD,SAAS,KAAK;AACZ,YAAI,CAAC,cAAc,CAAC,YAAY,GAAG,KAAK,WAAW,KAAK,YAAY;AAClE,gBAAM;AAAA,QACR;AACA,cAAM,KAAK,MAAM,KAAK,QAAQ,KAAK,OAAO,CAAC;AAC3C,mBAAW;AAAA,MACb;AAAA,IACF;AAAA,EACF;A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M;AACtD,SAAK,QAAQ,IAAI,cAAc,KAAK,MAAM;AAC1C,SAAK,WAAW,IAAI,iBAAiB,KAAK,MAAM;AAChD,SAAK,UAAU,IAAI,gBAAgB,KAAK,MAAM;AAAA,EAChD;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "notideus",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Official Node.js SDK for the Notideus email API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"notideus",
|
|
@@ -47,10 +47,10 @@
|
|
|
47
47
|
"prepublishOnly": "npm run build"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@eslint/js": "^
|
|
50
|
+
"@eslint/js": "^10.0.1",
|
|
51
51
|
"@types/node": "^26.6.4",
|
|
52
52
|
"eslint": "^10.12.0",
|
|
53
|
-
"tsup": "^
|
|
53
|
+
"tsup": "^9.0.0",
|
|
54
54
|
"typescript": "^5.6.0",
|
|
55
55
|
"typescript-eslint": "^8.10.0",
|
|
56
56
|
"vitest": "^5.0.3"
|