notideus 1.1.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -55,14 +55,21 @@ await notideus.emails.send({ from, to, subject, html?, text?, template_id?, vari
55
55
  await notideus.emails.sendBatch([{ /* same shape */ }, …]); // up to 100
56
56
  ```
57
57
 
58
- ### WhatsApp messages
58
+ ### Automation events
59
+
60
+ Send a custom event to start every active automation that matches its name. Provide exactly one recipient: an `email` address or an existing `contact_id`. The `202 Accepted` response confirms asynchronous dispatch, not email delivery.
59
61
 
60
62
  ```ts
61
- await notideus.whatsapp.messages.send({ template_id, to: ['+33612345678'], parameters: { 'body:1': 'Jane' } });
62
- await notideus.whatsapp.messages.sendBatch([…]);
63
+ const result = await notideus.events.send({
64
+ event: 'user.created',
65
+ email: 'ada@example.com', // or: contact_id: 'contact-uuid'
66
+ payload: { first_name: 'Ada', plan: 'Pro' },
67
+ idempotency_key: 'signup-42'
68
+ });
69
+ console.log(result.created, result.event.id);
63
70
  ```
64
71
 
65
- `send` returns one entry per recipient: `[{ id, to, status }]`.
72
+ Top-level payload fields fill matching template variables (for example `{{first_name}}`); `{{email}}` and `{{event_name}}` are built in. Replaying an `idempotency_key` returns the same event with `created: false` and never creates a duplicate run.
66
73
 
67
74
  ### Contacts
68
75
 
package/dist/index.cjs CHANGED
@@ -253,6 +253,17 @@ var EmailsResource = class {
253
253
  }
254
254
  };
255
255
 
256
+ // src/resources/events.ts
257
+ var EventsResource = class {
258
+ constructor(client) {
259
+ this.client = client;
260
+ }
261
+ client;
262
+ async send(params) {
263
+ return this.client.request("POST", "/v1/events/send", { body: params });
264
+ }
265
+ };
266
+
256
267
  // src/resources/inbound.ts
257
268
  function routePath(id) {
258
269
  return `/v1/inbound/routes/${encodeURIComponent(id)}`;
@@ -290,9 +301,19 @@ var InboundMessagesResource = class {
290
301
  }
291
302
  client;
292
303
  async list(params = {}) {
293
- const { q, route_id, cursor, limit } = params;
304
+ const { q, route_id, folder, folder_id, unread, attachments, sort, cursor, limit } = params;
294
305
  return this.client.request("GET", "/v1/inbound/messages", {
295
- query: { q, route_id, cursor, limit }
306
+ query: {
307
+ q,
308
+ route_id,
309
+ folder,
310
+ folder_id,
311
+ unread: unread === void 0 ? void 0 : String(unread),
312
+ attachments: attachments === void 0 ? void 0 : String(attachments),
313
+ sort,
314
+ cursor,
315
+ limit
316
+ }
296
317
  });
297
318
  }
298
319
  async get(id) {
@@ -305,13 +326,45 @@ var InboundMessagesResource = class {
305
326
  async attachment(messageId, index, options = {}) {
306
327
  return this.client.requestBinary(`${messagePath(messageId)}/attachments/${index}`, options);
307
328
  }
329
+ async update(id, params) {
330
+ const res = await this.client.request("PATCH", messagePath(id), { body: params });
331
+ return res.message;
332
+ }
333
+ async delete(id) {
334
+ await this.client.request("DELETE", messagePath(id));
335
+ }
336
+ };
337
+ function folderPath(id) {
338
+ return `/v1/inbound/folders/${encodeURIComponent(id)}`;
339
+ }
340
+ var InboundFoldersResource = class {
341
+ constructor(client) {
342
+ this.client = client;
343
+ }
344
+ client;
345
+ async list() {
346
+ return this.client.request("GET", "/v1/inbound/folders");
347
+ }
348
+ async create(name) {
349
+ const res = await this.client.request("POST", "/v1/inbound/folders", { body: { name } });
350
+ return res.folder;
351
+ }
352
+ async update(id, name) {
353
+ const res = await this.client.request("PATCH", folderPath(id), { body: { name } });
354
+ return res.folder;
355
+ }
356
+ async delete(id) {
357
+ await this.client.request("DELETE", folderPath(id));
358
+ }
308
359
  };
309
360
  var InboundResource = class {
310
361
  routes;
311
362
  messages;
363
+ folders;
312
364
  constructor(client) {
313
365
  this.routes = new InboundRoutesResource(client);
314
366
  this.messages = new InboundMessagesResource(client);
367
+ this.folders = new InboundFoldersResource(client);
315
368
  }
316
369
  };
317
370
 
@@ -428,38 +481,12 @@ var WebhooksResource = class {
428
481
  }
429
482
  };
430
483
 
431
- // src/resources/whatsapp.ts
432
- var WhatsAppResource = class {
433
- messages;
434
- constructor(client) {
435
- this.messages = new WhatsAppMessagesResource(client);
436
- }
437
- };
438
- var WhatsAppMessagesResource = class {
439
- constructor(client) {
440
- this.client = client;
441
- }
442
- client;
443
- async send(params) {
444
- const res = await this.client.request("POST", "/v1/whatsapp/messages", {
445
- body: params
446
- });
447
- return res.data;
448
- }
449
- async sendBatch(messages) {
450
- const res = await this.client.request("POST", "/v1/whatsapp/messages/batch", {
451
- body: { messages }
452
- });
453
- return res.data;
454
- }
455
- };
456
-
457
484
  // src/index.ts
458
485
  var Notideus = class {
459
486
  client;
460
487
  emails;
488
+ events;
461
489
  contacts;
462
- whatsapp;
463
490
  unsubscribe;
464
491
  plans;
465
492
  webhooks;
@@ -467,8 +494,8 @@ var Notideus = class {
467
494
  constructor(apiKey, options = {}) {
468
495
  this.client = new ApiClient({ ...options, apiKey });
469
496
  this.emails = new EmailsResource(this.client);
497
+ this.events = new EventsResource(this.client);
470
498
  this.contacts = new ContactsResource(this.client);
471
- this.whatsapp = new WhatsAppResource(this.client);
472
499
  this.unsubscribe = new UnsubscribeResource(this.client);
473
500
  this.plans = new PlansResource(this.client);
474
501
  this.webhooks = new WebhooksResource(this.client);
@@ -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/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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ACD,WAAO,IAAI;AAAA,EACb;AAAA,EAEA,MAAM,UAAU,UAAmE;AACjF,UAAM,MAAM,MAAM,KAAK,OAAO,QAAqC,QAAQ,+BAA+B;AAAA,MACxG,MAAM,EAAE,SAAS;AAAA,IACnB,CAAC;AACD,WAAO,IAAI;AAAA,EACb;AACF;;;AViCO,IAAM,WAAN,MAAe;AAAA,EACH;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,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;AAC1C,SAAK,WAAW,IAAI,iBAAiB,KAAK,MAAM;AAChD,SAAK,UAAU,IAAI,gBAAgB,KAAK,MAAM;AAAA,EAChD;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/events.ts","../src/resources/inbound.ts","../src/resources/plans.ts","../src/resources/unsubscribe.ts","../src/resources/webhook-deliveries.ts","../src/resources/webhooks.ts"],"sourcesContent":["import { ApiClient, type ClientOptions } from './client.js';\nimport { ContactsResource } from './resources/contacts.js';\nimport { EmailsResource } from './resources/emails.js';\nimport { EventsResource } from './resources/events.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';\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 { AutomationEvent, SendEventParams, SendEventResult } from './types/event.js';\nexport type {\n CreateInboundRouteParams,\n InboundAttachment,\n InboundMessage,\n InboundMessageStatus,\n InboundRoute,\n InboundRouteStatus,\n InboxFolder,\n InboxFolderName,\n InboxFolderFilter,\n InboxCounts,\n InboxFolderOverview,\n UpdateInboundMessageParams,\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 { 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 events: EventsResource;\n readonly contacts: ContactsResource;\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.events = new EventsResource(this.client);\n this.contacts = new ContactsResource(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 } from '../client.js';\nimport type { SendEventParams, SendEventResult } from '../types/event.js';\n\nexport class EventsResource {\n constructor(private readonly client: ApiClient) {}\n\n async send(params: SendEventParams): Promise<SendEventResult> {\n return this.client.request<SendEventResult>('POST', '/v1/events/send', { body: params });\n }\n}\n","import type { ApiClient, BinaryResult } from '../client.js';\nimport type {\n CreateInboundRouteParams,\n InboundMessage,\n InboundRoute,\n InboxFolder,\n InboxFolderOverview,\n UpdateInboundMessageParams,\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, folder, folder_id, unread, attachments, sort, cursor, limit } = params;\n return this.client.request<ListInboundMessagesResponse>('GET', '/v1/inbound/messages', {\n query: {\n q,\n route_id,\n folder,\n folder_id,\n unread: unread === undefined ? undefined : String(unread),\n attachments: attachments === undefined ? undefined : String(attachments),\n sort,\n cursor,\n limit\n }\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 async update(id: string, params: UpdateInboundMessageParams): Promise<InboundMessage> {\n const res = await this.client.request<{ message: InboundMessage }>('PATCH', messagePath(id), { body: params });\n return res.message;\n }\n\n async delete(id: string): Promise<void> {\n await this.client.request<void>('DELETE', messagePath(id));\n }\n}\n\nfunction folderPath(id: string): string {\n return `/v1/inbound/folders/${encodeURIComponent(id)}`;\n}\n\nexport class InboundFoldersResource {\n constructor(private readonly client: ApiClient) {}\n\n async list(): Promise<InboxFolderOverview> {\n return this.client.request<InboxFolderOverview>('GET', '/v1/inbound/folders');\n }\n\n async create(name: string): Promise<InboxFolder> {\n const res = await this.client.request<{ folder: InboxFolder }>('POST', '/v1/inbound/folders', { body: { name } });\n return res.folder;\n }\n\n async update(id: string, name: string): Promise<InboxFolder> {\n const res = await this.client.request<{ folder: InboxFolder }>('PATCH', folderPath(id), { body: { name } });\n return res.folder;\n }\n\n async delete(id: string): Promise<void> {\n await this.client.request<void>('DELETE', folderPath(id));\n }\n}\n\nexport class InboundResource {\n readonly routes: InboundRoutesResource;\n readonly messages: InboundMessagesResource;\n readonly folders: InboundFoldersResource;\n\n constructor(client: ApiClient) {\n this.routes = new InboundRoutesResource(client);\n this.messages = new InboundMessagesResource(client);\n this.folders = new InboundFoldersResource(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"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;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I,CAAC,EAAE;AAAA,IACjC;AACA,WAAO,IAAI;AAAA,EACb;AAAA;AAAA;AAAA,EAIA,MAAM,aAAa,IAAqC;AACtD,WAAO,KAAK,OAAO,QAAwB,QAAQ,GAAG,YAAY,EAAE,CAAC,kBAAkB,EAAE,MAAM,CAAC,EAAE,CAAC;AAAA,EACrG;AAAA,EAEA,MAAM,SAA4C;AAChD,UAAM,MAAM,MAAM,KAAK,OAAO,QAA4C,OAAO,0BAA0B;AAC3G,WAAO,IAAI;AAAA,EACb;AACF;;;AVCO,IAAM,WAAN,MAAe;AAAA,EACH;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,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,SAAS,IAAI,eAAe,KAAK,MAAM;AAC5C,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
@@ -95,6 +95,8 @@ declare class ContactsResource {
95
95
  interface SendEmailParams {
96
96
  from: string;
97
97
  to: string[];
98
+ cc?: string[];
99
+ bcc?: string[];
98
100
  subject: string;
99
101
  html?: string;
100
102
  text?: string;
@@ -116,6 +118,8 @@ interface Email {
116
118
  template_id: string | null;
117
119
  from_address: string;
118
120
  to_emails: string[];
121
+ cc_emails: string[];
122
+ bcc_emails: string[];
119
123
  subject: string;
120
124
  html: string;
121
125
  size_kb: number;
@@ -140,6 +144,38 @@ declare class EmailsResource {
140
144
  sendBatch(emails: SendEmailParams[]): Promise<BatchItemResult[]>;
141
145
  }
142
146
 
147
+ interface SendEventBase {
148
+ event: string;
149
+ payload?: Record<string, unknown>;
150
+ idempotency_key?: string;
151
+ }
152
+ type SendEventParams = SendEventBase & ({
153
+ email: string;
154
+ contact_id?: never;
155
+ } | {
156
+ contact_id: string;
157
+ email?: never;
158
+ });
159
+ interface AutomationEvent {
160
+ id: string;
161
+ event: string;
162
+ email: string;
163
+ contact_id: string | null;
164
+ payload: Record<string, unknown>;
165
+ source: 'api' | 'test';
166
+ created_at: string;
167
+ }
168
+ interface SendEventResult {
169
+ event: AutomationEvent;
170
+ created: boolean;
171
+ }
172
+
173
+ declare class EventsResource {
174
+ private readonly client;
175
+ constructor(client: ApiClient);
176
+ send(params: SendEventParams): Promise<SendEventResult>;
177
+ }
178
+
143
179
  type InboundRouteStatus = 'active' | 'disabled';
144
180
  interface InboundRoute {
145
181
  id: string;
@@ -195,10 +231,46 @@ interface InboundMessage {
195
231
  status: InboundMessageStatus;
196
232
  error: string | null;
197
233
  received_at: string;
234
+ read_at: string | null;
235
+ starred: boolean;
236
+ folder: 'inbox' | 'archive' | 'trash';
237
+ folder_id: string | null;
238
+ }
239
+ type InboxFolderName = 'inbox' | 'archive' | 'trash';
240
+ type InboxFolderFilter = InboxFolderName | 'starred' | 'all';
241
+ interface InboxFolder {
242
+ id: string;
243
+ name: string;
244
+ created_at: string;
245
+ updated_at: string;
246
+ }
247
+ interface InboxCounts {
248
+ inbox: number;
249
+ unread: number;
250
+ starred: number;
251
+ archive: number;
252
+ trash: number;
253
+ all: number;
254
+ }
255
+ interface InboxFolderOverview {
256
+ data: InboxFolder[];
257
+ counts: InboxCounts;
258
+ route_unread: Record<string, number>;
259
+ }
260
+ interface UpdateInboundMessageParams {
261
+ read?: boolean;
262
+ starred?: boolean;
263
+ folder?: InboxFolderName;
264
+ folder_id?: string;
198
265
  }
199
266
  interface ListInboundMessagesParams {
200
267
  q?: string;
201
268
  route_id?: string;
269
+ folder?: InboxFolderFilter;
270
+ folder_id?: string;
271
+ unread?: boolean;
272
+ attachments?: boolean;
273
+ sort?: 'newest' | 'oldest';
202
274
  cursor?: string;
203
275
  limit?: number;
204
276
  }
@@ -227,10 +299,21 @@ declare class InboundMessagesResource {
227
299
  attachment(messageId: string, index: number, options?: {
228
300
  signal?: AbortSignal;
229
301
  }): Promise<BinaryResult>;
302
+ update(id: string, params: UpdateInboundMessageParams): Promise<InboundMessage>;
303
+ delete(id: string): Promise<void>;
304
+ }
305
+ declare class InboundFoldersResource {
306
+ private readonly client;
307
+ constructor(client: ApiClient);
308
+ list(): Promise<InboxFolderOverview>;
309
+ create(name: string): Promise<InboxFolder>;
310
+ update(id: string, name: string): Promise<InboxFolder>;
311
+ delete(id: string): Promise<void>;
230
312
  }
231
313
  declare class InboundResource {
232
314
  readonly routes: InboundRoutesResource;
233
315
  readonly messages: InboundMessagesResource;
316
+ readonly folders: InboundFoldersResource;
234
317
  constructor(client: ApiClient);
235
318
  }
236
319
 
@@ -396,29 +479,6 @@ declare class WebhooksResource {
396
479
  events(): Promise<WebhookEventDescriptor[]>;
397
480
  }
398
481
 
399
- interface SendWhatsAppMessageParams {
400
- template_id: string;
401
- to: string[];
402
- parameters?: Record<string, string>;
403
- idempotency_key?: string;
404
- }
405
- interface WhatsAppMessage {
406
- id: string;
407
- to: string;
408
- status: string;
409
- }
410
-
411
- declare class WhatsAppResource {
412
- readonly messages: WhatsAppMessagesResource;
413
- constructor(client: ApiClient);
414
- }
415
- declare class WhatsAppMessagesResource {
416
- private readonly client;
417
- constructor(client: ApiClient);
418
- send(params: SendWhatsAppMessageParams): Promise<WhatsAppMessage[]>;
419
- sendBatch(messages: SendWhatsAppMessageParams[]): Promise<BatchItemResult[]>;
420
- }
421
-
422
482
  interface NotideusErrorOptions {
423
483
  code: string;
424
484
  message: string;
@@ -438,8 +498,8 @@ declare class NotideusError extends Error {
438
498
  declare class Notideus {
439
499
  private readonly client;
440
500
  readonly emails: EmailsResource;
501
+ readonly events: EventsResource;
441
502
  readonly contacts: ContactsResource;
442
- readonly whatsapp: WhatsAppResource;
443
503
  readonly unsubscribe: UnsubscribeResource;
444
504
  readonly plans: PlansResource;
445
505
  readonly webhooks: WebhooksResource;
@@ -448,4 +508,4 @@ declare class Notideus {
448
508
  }
449
509
 
450
510
  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 };
511
+ export type { AutomationEvent, BatchItemError, BatchItemResult, BinaryResult, BulkContactInput, ClientOptions, Contact, ContactStatus, ContactsTier, CreateContactParams, CreateInboundRouteParams, CreateWebhookParams, Email, FreeAllowances, InboundAttachment, InboundMessage, InboundMessageStatus, InboundRoute, InboundRouteStatus, InboxCounts, InboxFolder, InboxFolderFilter, InboxFolderName, InboxFolderOverview, ListContactsParams, ListContactsResponse, ListInboundMessagesParams, ListInboundMessagesResponse, ListInboundRoutesResponse, ListWebhookDeliveriesParams, ListWebhookDeliveriesResponse, ListWebhooksParams, ListWebhooksResponse, Plan, PlanCatalog, PlanLocale, PlanTier, SendEmailParams, SendEventParams, SendEventResult, UnsubscribeInfo, UnsubscribeTopic, UpdateContactParams, UpdateInboundMessageParams, UpdateInboundRouteParams, UpdateWebhookParams, WebhookAttempt, WebhookCreated, WebhookDelivery, WebhookDeliveryResult, WebhookDeliveryStatus, WebhookEndpoint, WebhookEndpointStatus, WebhookEventDescriptor };
package/dist/index.d.ts CHANGED
@@ -95,6 +95,8 @@ declare class ContactsResource {
95
95
  interface SendEmailParams {
96
96
  from: string;
97
97
  to: string[];
98
+ cc?: string[];
99
+ bcc?: string[];
98
100
  subject: string;
99
101
  html?: string;
100
102
  text?: string;
@@ -116,6 +118,8 @@ interface Email {
116
118
  template_id: string | null;
117
119
  from_address: string;
118
120
  to_emails: string[];
121
+ cc_emails: string[];
122
+ bcc_emails: string[];
119
123
  subject: string;
120
124
  html: string;
121
125
  size_kb: number;
@@ -140,6 +144,38 @@ declare class EmailsResource {
140
144
  sendBatch(emails: SendEmailParams[]): Promise<BatchItemResult[]>;
141
145
  }
142
146
 
147
+ interface SendEventBase {
148
+ event: string;
149
+ payload?: Record<string, unknown>;
150
+ idempotency_key?: string;
151
+ }
152
+ type SendEventParams = SendEventBase & ({
153
+ email: string;
154
+ contact_id?: never;
155
+ } | {
156
+ contact_id: string;
157
+ email?: never;
158
+ });
159
+ interface AutomationEvent {
160
+ id: string;
161
+ event: string;
162
+ email: string;
163
+ contact_id: string | null;
164
+ payload: Record<string, unknown>;
165
+ source: 'api' | 'test';
166
+ created_at: string;
167
+ }
168
+ interface SendEventResult {
169
+ event: AutomationEvent;
170
+ created: boolean;
171
+ }
172
+
173
+ declare class EventsResource {
174
+ private readonly client;
175
+ constructor(client: ApiClient);
176
+ send(params: SendEventParams): Promise<SendEventResult>;
177
+ }
178
+
143
179
  type InboundRouteStatus = 'active' | 'disabled';
144
180
  interface InboundRoute {
145
181
  id: string;
@@ -195,10 +231,46 @@ interface InboundMessage {
195
231
  status: InboundMessageStatus;
196
232
  error: string | null;
197
233
  received_at: string;
234
+ read_at: string | null;
235
+ starred: boolean;
236
+ folder: 'inbox' | 'archive' | 'trash';
237
+ folder_id: string | null;
238
+ }
239
+ type InboxFolderName = 'inbox' | 'archive' | 'trash';
240
+ type InboxFolderFilter = InboxFolderName | 'starred' | 'all';
241
+ interface InboxFolder {
242
+ id: string;
243
+ name: string;
244
+ created_at: string;
245
+ updated_at: string;
246
+ }
247
+ interface InboxCounts {
248
+ inbox: number;
249
+ unread: number;
250
+ starred: number;
251
+ archive: number;
252
+ trash: number;
253
+ all: number;
254
+ }
255
+ interface InboxFolderOverview {
256
+ data: InboxFolder[];
257
+ counts: InboxCounts;
258
+ route_unread: Record<string, number>;
259
+ }
260
+ interface UpdateInboundMessageParams {
261
+ read?: boolean;
262
+ starred?: boolean;
263
+ folder?: InboxFolderName;
264
+ folder_id?: string;
198
265
  }
199
266
  interface ListInboundMessagesParams {
200
267
  q?: string;
201
268
  route_id?: string;
269
+ folder?: InboxFolderFilter;
270
+ folder_id?: string;
271
+ unread?: boolean;
272
+ attachments?: boolean;
273
+ sort?: 'newest' | 'oldest';
202
274
  cursor?: string;
203
275
  limit?: number;
204
276
  }
@@ -227,10 +299,21 @@ declare class InboundMessagesResource {
227
299
  attachment(messageId: string, index: number, options?: {
228
300
  signal?: AbortSignal;
229
301
  }): Promise<BinaryResult>;
302
+ update(id: string, params: UpdateInboundMessageParams): Promise<InboundMessage>;
303
+ delete(id: string): Promise<void>;
304
+ }
305
+ declare class InboundFoldersResource {
306
+ private readonly client;
307
+ constructor(client: ApiClient);
308
+ list(): Promise<InboxFolderOverview>;
309
+ create(name: string): Promise<InboxFolder>;
310
+ update(id: string, name: string): Promise<InboxFolder>;
311
+ delete(id: string): Promise<void>;
230
312
  }
231
313
  declare class InboundResource {
232
314
  readonly routes: InboundRoutesResource;
233
315
  readonly messages: InboundMessagesResource;
316
+ readonly folders: InboundFoldersResource;
234
317
  constructor(client: ApiClient);
235
318
  }
236
319
 
@@ -396,29 +479,6 @@ declare class WebhooksResource {
396
479
  events(): Promise<WebhookEventDescriptor[]>;
397
480
  }
398
481
 
399
- interface SendWhatsAppMessageParams {
400
- template_id: string;
401
- to: string[];
402
- parameters?: Record<string, string>;
403
- idempotency_key?: string;
404
- }
405
- interface WhatsAppMessage {
406
- id: string;
407
- to: string;
408
- status: string;
409
- }
410
-
411
- declare class WhatsAppResource {
412
- readonly messages: WhatsAppMessagesResource;
413
- constructor(client: ApiClient);
414
- }
415
- declare class WhatsAppMessagesResource {
416
- private readonly client;
417
- constructor(client: ApiClient);
418
- send(params: SendWhatsAppMessageParams): Promise<WhatsAppMessage[]>;
419
- sendBatch(messages: SendWhatsAppMessageParams[]): Promise<BatchItemResult[]>;
420
- }
421
-
422
482
  interface NotideusErrorOptions {
423
483
  code: string;
424
484
  message: string;
@@ -438,8 +498,8 @@ declare class NotideusError extends Error {
438
498
  declare class Notideus {
439
499
  private readonly client;
440
500
  readonly emails: EmailsResource;
501
+ readonly events: EventsResource;
441
502
  readonly contacts: ContactsResource;
442
- readonly whatsapp: WhatsAppResource;
443
503
  readonly unsubscribe: UnsubscribeResource;
444
504
  readonly plans: PlansResource;
445
505
  readonly webhooks: WebhooksResource;
@@ -448,4 +508,4 @@ declare class Notideus {
448
508
  }
449
509
 
450
510
  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 };
511
+ export type { AutomationEvent, BatchItemError, BatchItemResult, BinaryResult, BulkContactInput, ClientOptions, Contact, ContactStatus, ContactsTier, CreateContactParams, CreateInboundRouteParams, CreateWebhookParams, Email, FreeAllowances, InboundAttachment, InboundMessage, InboundMessageStatus, InboundRoute, InboundRouteStatus, InboxCounts, InboxFolder, InboxFolderFilter, InboxFolderName, InboxFolderOverview, ListContactsParams, ListContactsResponse, ListInboundMessagesParams, ListInboundMessagesResponse, ListInboundRoutesResponse, ListWebhookDeliveriesParams, ListWebhookDeliveriesResponse, ListWebhooksParams, ListWebhooksResponse, Plan, PlanCatalog, PlanLocale, PlanTier, SendEmailParams, SendEventParams, SendEventResult, UnsubscribeInfo, UnsubscribeTopic, UpdateContactParams, UpdateInboundMessageParams, UpdateInboundRouteParams, UpdateWebhookParams, WebhookAttempt, WebhookCreated, WebhookDelivery, WebhookDeliveryResult, WebhookDeliveryStatus, WebhookEndpoint, WebhookEndpointStatus, WebhookEventDescriptor };
package/dist/index.js CHANGED
@@ -226,6 +226,17 @@ var EmailsResource = class {
226
226
  }
227
227
  };
228
228
 
229
+ // src/resources/events.ts
230
+ var EventsResource = class {
231
+ constructor(client) {
232
+ this.client = client;
233
+ }
234
+ client;
235
+ async send(params) {
236
+ return this.client.request("POST", "/v1/events/send", { body: params });
237
+ }
238
+ };
239
+
229
240
  // src/resources/inbound.ts
230
241
  function routePath(id) {
231
242
  return `/v1/inbound/routes/${encodeURIComponent(id)}`;
@@ -263,9 +274,19 @@ var InboundMessagesResource = class {
263
274
  }
264
275
  client;
265
276
  async list(params = {}) {
266
- const { q, route_id, cursor, limit } = params;
277
+ const { q, route_id, folder, folder_id, unread, attachments, sort, cursor, limit } = params;
267
278
  return this.client.request("GET", "/v1/inbound/messages", {
268
- query: { q, route_id, cursor, limit }
279
+ query: {
280
+ q,
281
+ route_id,
282
+ folder,
283
+ folder_id,
284
+ unread: unread === void 0 ? void 0 : String(unread),
285
+ attachments: attachments === void 0 ? void 0 : String(attachments),
286
+ sort,
287
+ cursor,
288
+ limit
289
+ }
269
290
  });
270
291
  }
271
292
  async get(id) {
@@ -278,13 +299,45 @@ var InboundMessagesResource = class {
278
299
  async attachment(messageId, index, options = {}) {
279
300
  return this.client.requestBinary(`${messagePath(messageId)}/attachments/${index}`, options);
280
301
  }
302
+ async update(id, params) {
303
+ const res = await this.client.request("PATCH", messagePath(id), { body: params });
304
+ return res.message;
305
+ }
306
+ async delete(id) {
307
+ await this.client.request("DELETE", messagePath(id));
308
+ }
309
+ };
310
+ function folderPath(id) {
311
+ return `/v1/inbound/folders/${encodeURIComponent(id)}`;
312
+ }
313
+ var InboundFoldersResource = class {
314
+ constructor(client) {
315
+ this.client = client;
316
+ }
317
+ client;
318
+ async list() {
319
+ return this.client.request("GET", "/v1/inbound/folders");
320
+ }
321
+ async create(name) {
322
+ const res = await this.client.request("POST", "/v1/inbound/folders", { body: { name } });
323
+ return res.folder;
324
+ }
325
+ async update(id, name) {
326
+ const res = await this.client.request("PATCH", folderPath(id), { body: { name } });
327
+ return res.folder;
328
+ }
329
+ async delete(id) {
330
+ await this.client.request("DELETE", folderPath(id));
331
+ }
281
332
  };
282
333
  var InboundResource = class {
283
334
  routes;
284
335
  messages;
336
+ folders;
285
337
  constructor(client) {
286
338
  this.routes = new InboundRoutesResource(client);
287
339
  this.messages = new InboundMessagesResource(client);
340
+ this.folders = new InboundFoldersResource(client);
288
341
  }
289
342
  };
290
343
 
@@ -401,38 +454,12 @@ var WebhooksResource = class {
401
454
  }
402
455
  };
403
456
 
404
- // src/resources/whatsapp.ts
405
- var WhatsAppResource = class {
406
- messages;
407
- constructor(client) {
408
- this.messages = new WhatsAppMessagesResource(client);
409
- }
410
- };
411
- var WhatsAppMessagesResource = class {
412
- constructor(client) {
413
- this.client = client;
414
- }
415
- client;
416
- async send(params) {
417
- const res = await this.client.request("POST", "/v1/whatsapp/messages", {
418
- body: params
419
- });
420
- return res.data;
421
- }
422
- async sendBatch(messages) {
423
- const res = await this.client.request("POST", "/v1/whatsapp/messages/batch", {
424
- body: { messages }
425
- });
426
- return res.data;
427
- }
428
- };
429
-
430
457
  // src/index.ts
431
458
  var Notideus = class {
432
459
  client;
433
460
  emails;
461
+ events;
434
462
  contacts;
435
- whatsapp;
436
463
  unsubscribe;
437
464
  plans;
438
465
  webhooks;
@@ -440,8 +467,8 @@ var Notideus = class {
440
467
  constructor(apiKey, options = {}) {
441
468
  this.client = new ApiClient({ ...options, apiKey });
442
469
  this.emails = new EmailsResource(this.client);
470
+ this.events = new EventsResource(this.client);
443
471
  this.contacts = new ContactsResource(this.client);
444
- this.whatsapp = new WhatsAppResource(this.client);
445
472
  this.unsubscribe = new UnsubscribeResource(this.client);
446
473
  this.plans = new PlansResource(this.client);
447
474
  this.webhooks = new WebhooksResource(this.client);
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/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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;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,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;AAC1C,SAAK,WAAW,IAAI,iBAAiB,KAAK,MAAM;AAChD,SAAK,UAAU,IAAI,gBAAgB,KAAK,MAAM;AAAA,EAChD;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/errors.ts","../src/client.ts","../src/resources/contacts.ts","../src/resources/emails.ts","../src/resources/events.ts","../src/resources/inbound.ts","../src/resources/plans.ts","../src/resources/unsubscribe.ts","../src/resources/webhook-deliveries.ts","../src/resources/webhooks.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 } from '../client.js';\nimport type { SendEventParams, SendEventResult } from '../types/event.js';\n\nexport class EventsResource {\n constructor(private readonly client: ApiClient) {}\n\n async send(params: SendEventParams): Promise<SendEventResult> {\n return this.client.request<SendEventResult>('POST', '/v1/events/send', { body: params });\n }\n}\n","import type { ApiClient, BinaryResult } from '../client.js';\nimport type {\n CreateInboundRouteParams,\n InboundMessage,\n InboundRoute,\n InboxFolder,\n InboxFolderOverview,\n UpdateInboundMessageParams,\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, folder, folder_id, unread, attachments, sort, cursor, limit } = params;\n return this.client.request<ListInboundMessagesResponse>('GET', '/v1/inbound/messages', {\n query: {\n q,\n route_id,\n folder,\n folder_id,\n unread: unread === undefined ? undefined : String(unread),\n attachments: attachments === undefined ? undefined : String(attachments),\n sort,\n cursor,\n limit\n }\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 async update(id: string, params: UpdateInboundMessageParams): Promise<InboundMessage> {\n const res = await this.client.request<{ message: InboundMessage }>('PATCH', messagePath(id), { body: params });\n return res.message;\n }\n\n async delete(id: string): Promise<void> {\n await this.client.request<void>('DELETE', messagePath(id));\n }\n}\n\nfunction folderPath(id: string): string {\n return `/v1/inbound/folders/${encodeURIComponent(id)}`;\n}\n\nexport class InboundFoldersResource {\n constructor(private readonly client: ApiClient) {}\n\n async list(): Promise<InboxFolderOverview> {\n return this.client.request<InboxFolderOverview>('GET', '/v1/inbound/folders');\n }\n\n async create(name: string): Promise<InboxFolder> {\n const res = await this.client.request<{ folder: InboxFolder }>('POST', '/v1/inbound/folders', { body: { name } });\n return res.folder;\n }\n\n async update(id: string, name: string): Promise<InboxFolder> {\n const res = await this.client.request<{ folder: InboxFolder }>('PATCH', folderPath(id), { body: { name } });\n return res.folder;\n }\n\n async delete(id: string): Promise<void> {\n await this.client.request<void>('DELETE', folderPath(id));\n }\n}\n\nexport class InboundResource {\n readonly routes: InboundRoutesResource;\n readonly messages: InboundMessagesResource;\n readonly folders: InboundFoldersResource;\n\n constructor(client: ApiClient) {\n this.routes = new InboundRoutesResource(client);\n this.messages = new InboundMessagesResource(client);\n this.folders = new InboundFoldersResource(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 { ApiClient, type ClientOptions } from './client.js';\nimport { ContactsResource } from './resources/contacts.js';\nimport { EmailsResource } from './resources/emails.js';\nimport { EventsResource } from './resources/events.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';\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 { AutomationEvent, SendEventParams, SendEventResult } from './types/event.js';\nexport type {\n CreateInboundRouteParams,\n InboundAttachment,\n InboundMessage,\n InboundMessageStatus,\n InboundRoute,\n InboundRouteStatus,\n InboxFolder,\n InboxFolderName,\n InboxFolderFilter,\n InboxCounts,\n InboxFolderOverview,\n UpdateInboundMessageParams,\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 { 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 events: EventsResource;\n readonly contacts: ContactsResource;\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.events = new EventsResource(this.client);\n this.contacts = new ContactsResource(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,IA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,EACb;AACF;;;ACCO,IAAM,WAAN,MAAe;AAAA,EACH;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,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,SAAS,IAAI,eAAe,KAAK,MAAM;AAC5C,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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "notideus",
3
- "version": "1.1.1",
3
+ "version": "2.0.0",
4
4
  "description": "Official Node.js SDK for the Notideus email API",
5
5
  "keywords": [
6
6
  "notideus",
@@ -11,8 +11,7 @@
11
11
  "sdk",
12
12
  "api client",
13
13
  "nodejs",
14
- "typescript",
15
- "whatsapp"
14
+ "typescript"
16
15
  ],
17
16
  "license": "MIT",
18
17
  "repository": "github:notideus/sdk-node",