@messagebird/sdk 0.8.0 → 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +215 -44
- package/dist/index.mjs +8 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -269,6 +269,194 @@ interface PaginatedPromise<T> extends Promise<CursorPage<T>>, AsyncIterable<T> {
|
|
|
269
269
|
}
|
|
270
270
|
//#endregion
|
|
271
271
|
//#region src/generated/types.gen.d.ts
|
|
272
|
+
/**
|
|
273
|
+
* Payload of the whatsapp.sent event.
|
|
274
|
+
*/
|
|
275
|
+
type EventWhatsAppSentData = EventWhatsAppBase;
|
|
276
|
+
/**
|
|
277
|
+
* Structured key/value label attached to a message. Surfaces in list filters, the event log, and webhook payloads. Use tags for low-cardinality filtering dimensions (category, experiment ID, template ID). For arbitrary per-send context that does not need to be filterable, use `metadata`.
|
|
278
|
+
* Tag count and per-tag size are capped to keep per-send tag payloads small — see the send request for the array maximum. Tag names are unique within a send; supplying the same name twice is rejected.
|
|
279
|
+
*
|
|
280
|
+
*/
|
|
281
|
+
type Tag = {
|
|
282
|
+
/**
|
|
283
|
+
* Tag name. ASCII letters, digits, underscore, and hyphen only. Case-sensitive. Maximum 32 characters.
|
|
284
|
+
*
|
|
285
|
+
*/
|
|
286
|
+
name: string;
|
|
287
|
+
/**
|
|
288
|
+
* Tag value. ASCII letters, digits, underscore, and hyphen only. Case-sensitive. Maximum 64 characters.
|
|
289
|
+
*
|
|
290
|
+
*/
|
|
291
|
+
value: string;
|
|
292
|
+
};
|
|
293
|
+
/**
|
|
294
|
+
* Sender or recipient of a WhatsApp message — a phone number, a business-scoped user ID, or both.
|
|
295
|
+
*/
|
|
296
|
+
type WhatsAppAddress = {
|
|
297
|
+
/**
|
|
298
|
+
* Phone number in E.164 format, when known.
|
|
299
|
+
*/
|
|
300
|
+
phone_number?: string;
|
|
301
|
+
/**
|
|
302
|
+
* Business-scoped user ID — Meta's identifier for the WhatsApp user. Present only on the WhatsApp-user side of the message.
|
|
303
|
+
*
|
|
304
|
+
*/
|
|
305
|
+
bsuid?: string;
|
|
306
|
+
};
|
|
307
|
+
type WorkspaceId = string;
|
|
308
|
+
type WhatsAppMessageId = string;
|
|
309
|
+
/**
|
|
310
|
+
* Identity fields shared by every WhatsApp lifecycle event payload.
|
|
311
|
+
*/
|
|
312
|
+
type EventWhatsAppBase = {
|
|
313
|
+
/**
|
|
314
|
+
* ID of the WhatsApp message.
|
|
315
|
+
*/
|
|
316
|
+
whatsapp_id: WhatsAppMessageId;
|
|
317
|
+
/**
|
|
318
|
+
* ID of the workspace.
|
|
319
|
+
*/
|
|
320
|
+
workspace_id: WorkspaceId;
|
|
321
|
+
/**
|
|
322
|
+
* Whether the message was sent by the business (`outbound`) or received from the contact (`inbound`).
|
|
323
|
+
*/
|
|
324
|
+
direction: "outbound" | "inbound";
|
|
325
|
+
/**
|
|
326
|
+
* Sender of the message. On outbound messages, the business number it was sent from.
|
|
327
|
+
*/
|
|
328
|
+
from: WhatsAppAddress;
|
|
329
|
+
/**
|
|
330
|
+
* Recipient of the message. On outbound messages, the WhatsApp contact.
|
|
331
|
+
*/
|
|
332
|
+
to: WhatsAppAddress;
|
|
333
|
+
/**
|
|
334
|
+
* Tags provided on the send request, echoed on every event for the message. Null when the message carried no tags.
|
|
335
|
+
*
|
|
336
|
+
*/
|
|
337
|
+
tags: Array<Tag> | null;
|
|
338
|
+
/**
|
|
339
|
+
* The metadata object provided on the send request, echoed on every event for the message. Null when the message carried no metadata.
|
|
340
|
+
*
|
|
341
|
+
*/
|
|
342
|
+
metadata: {
|
|
343
|
+
[key: string]: unknown;
|
|
344
|
+
} | null;
|
|
345
|
+
};
|
|
346
|
+
/**
|
|
347
|
+
* Bird handed the message to Meta for delivery.
|
|
348
|
+
*/
|
|
349
|
+
type EventWhatsAppSent = {
|
|
350
|
+
/**
|
|
351
|
+
* Event type.
|
|
352
|
+
*/
|
|
353
|
+
type: "whatsapp.sent";
|
|
354
|
+
/**
|
|
355
|
+
* Time Bird handed the message to Meta for delivery.
|
|
356
|
+
*/
|
|
357
|
+
timestamp: string;
|
|
358
|
+
data: EventWhatsAppSentData;
|
|
359
|
+
};
|
|
360
|
+
/**
|
|
361
|
+
* Payload of the whatsapp.read event.
|
|
362
|
+
*/
|
|
363
|
+
type EventWhatsAppReadData = EventWhatsAppBase;
|
|
364
|
+
/**
|
|
365
|
+
* The recipient read the message.
|
|
366
|
+
*/
|
|
367
|
+
type EventWhatsAppRead = {
|
|
368
|
+
/**
|
|
369
|
+
* Event type.
|
|
370
|
+
*/
|
|
371
|
+
type: "whatsapp.read";
|
|
372
|
+
/**
|
|
373
|
+
* Time the recipient read the message.
|
|
374
|
+
*/
|
|
375
|
+
timestamp: string;
|
|
376
|
+
data: EventWhatsAppReadData;
|
|
377
|
+
};
|
|
378
|
+
/**
|
|
379
|
+
* Bird-stable failure reason, uniform whether the failure happened internally or was reported by the WhatsApp network. `insufficient_balance` — the workspace could not afford the send. `price_not_found` — no price was configured for this destination/template combination. `internal_error` — an unexpected Bird-side failure. `undeliverable` — the recipient could not be reached (e.g. not on WhatsApp, number invalid). `service_window_expired` — the 24-hour customer care window has closed and a free-form message cannot be sent; send a template instead. `rate_limited` — the send was throttled.
|
|
380
|
+
*
|
|
381
|
+
*/
|
|
382
|
+
type WhatsAppErrorCode = string;
|
|
383
|
+
/**
|
|
384
|
+
* Failure detail for a message that could not be delivered. Null when there is no failure.
|
|
385
|
+
*/
|
|
386
|
+
type WhatsAppError = {
|
|
387
|
+
code: WhatsAppErrorCode;
|
|
388
|
+
/**
|
|
389
|
+
* Human-readable explanation of the failure.
|
|
390
|
+
*/
|
|
391
|
+
readonly description: string;
|
|
392
|
+
/**
|
|
393
|
+
* Raw error code from the WhatsApp Cloud API, when available, for low-level debugging.
|
|
394
|
+
*/
|
|
395
|
+
readonly meta_error_code?: string | null;
|
|
396
|
+
/**
|
|
397
|
+
* When the failure occurred.
|
|
398
|
+
*/
|
|
399
|
+
readonly occurred_at: string;
|
|
400
|
+
} | null;
|
|
401
|
+
/**
|
|
402
|
+
* Payload of the whatsapp.failed event.
|
|
403
|
+
*/
|
|
404
|
+
type EventWhatsAppFailedData = EventWhatsAppBase & {
|
|
405
|
+
/**
|
|
406
|
+
* Why the message terminally failed.
|
|
407
|
+
*/
|
|
408
|
+
error: WhatsAppError;
|
|
409
|
+
};
|
|
410
|
+
/**
|
|
411
|
+
* The message terminally failed and will not be delivered.
|
|
412
|
+
*/
|
|
413
|
+
type EventWhatsAppFailed = {
|
|
414
|
+
/**
|
|
415
|
+
* Event type.
|
|
416
|
+
*/
|
|
417
|
+
type: "whatsapp.failed";
|
|
418
|
+
/**
|
|
419
|
+
* Time the failure was recorded.
|
|
420
|
+
*/
|
|
421
|
+
timestamp: string;
|
|
422
|
+
data: EventWhatsAppFailedData;
|
|
423
|
+
};
|
|
424
|
+
/**
|
|
425
|
+
* Payload of the whatsapp.delivered event.
|
|
426
|
+
*/
|
|
427
|
+
type EventWhatsAppDeliveredData = EventWhatsAppBase;
|
|
428
|
+
/**
|
|
429
|
+
* The message was delivered to the recipient's device.
|
|
430
|
+
*/
|
|
431
|
+
type EventWhatsAppDelivered = {
|
|
432
|
+
/**
|
|
433
|
+
* Event type.
|
|
434
|
+
*/
|
|
435
|
+
type: "whatsapp.delivered";
|
|
436
|
+
/**
|
|
437
|
+
* Time the message was delivered to the recipient's device.
|
|
438
|
+
*/
|
|
439
|
+
timestamp: string;
|
|
440
|
+
data: EventWhatsAppDeliveredData;
|
|
441
|
+
};
|
|
442
|
+
/**
|
|
443
|
+
* Payload of the whatsapp.accepted event.
|
|
444
|
+
*/
|
|
445
|
+
type EventWhatsAppAcceptedData = EventWhatsAppBase;
|
|
446
|
+
/**
|
|
447
|
+
* Bird accepted and charged the send request.
|
|
448
|
+
*/
|
|
449
|
+
type EventWhatsAppAccepted = {
|
|
450
|
+
/**
|
|
451
|
+
* Event type.
|
|
452
|
+
*/
|
|
453
|
+
type: "whatsapp.accepted";
|
|
454
|
+
/**
|
|
455
|
+
* Time Bird accepted and charged the send request.
|
|
456
|
+
*/
|
|
457
|
+
timestamp: string;
|
|
458
|
+
data: EventWhatsAppAcceptedData;
|
|
459
|
+
};
|
|
272
460
|
/**
|
|
273
461
|
* Payload of the sms.undelivered event.
|
|
274
462
|
*/
|
|
@@ -301,24 +489,6 @@ type SmsError = {
|
|
|
301
489
|
*/
|
|
302
490
|
occurred_at: string;
|
|
303
491
|
} | null;
|
|
304
|
-
/**
|
|
305
|
-
* Structured key/value label attached to a message. Surfaces in list filters, the event log, and webhook payloads. Use tags for low-cardinality filtering dimensions (category, experiment ID, template ID). For arbitrary per-send context that does not need to be filterable, use `metadata`.
|
|
306
|
-
* Tag count and per-tag size are capped to keep per-send tag payloads small — see the send request for the array maximum. Tag names are unique within a send; supplying the same name twice is rejected.
|
|
307
|
-
*
|
|
308
|
-
*/
|
|
309
|
-
type Tag = {
|
|
310
|
-
/**
|
|
311
|
-
* Tag name. ASCII letters, digits, underscore, and hyphen only. Case-sensitive. Maximum 32 characters.
|
|
312
|
-
*
|
|
313
|
-
*/
|
|
314
|
-
name: string;
|
|
315
|
-
/**
|
|
316
|
-
* Tag value. ASCII letters, digits, underscore, and hyphen only. Case-sensitive. Maximum 64 characters.
|
|
317
|
-
*
|
|
318
|
-
*/
|
|
319
|
-
value: string;
|
|
320
|
-
};
|
|
321
|
-
type WorkspaceId = string;
|
|
322
492
|
type SmsMessageId = string;
|
|
323
493
|
/**
|
|
324
494
|
* Identity fields shared by every SMS lifecycle event payload.
|
|
@@ -679,6 +849,11 @@ type EventEmailMailboxMessageReceivedData = {
|
|
|
679
849
|
* Number of attachments on the message. Metadata is durable; bytes are fetchable while within the 30-day original-source window.
|
|
680
850
|
*/
|
|
681
851
|
attachment_count: number;
|
|
852
|
+
/**
|
|
853
|
+
* Whether the sender of the received message was authenticated. `pass` means the sender's identity was verified; `fail` means it was checked and did not verify; `unknown` means no verdict is available and the sender should not be treated as verified.
|
|
854
|
+
*
|
|
855
|
+
*/
|
|
856
|
+
authentication?: "pass" | "fail" | "unknown" | null;
|
|
682
857
|
/**
|
|
683
858
|
* Whether SPF passed for the sender, or null when no verdict was computable.
|
|
684
859
|
*/
|
|
@@ -939,6 +1114,11 @@ type EventEmailReceivedData = {
|
|
|
939
1114
|
* In-Reply-To header — the Message-ID this message replies to, or null when it is not a reply.
|
|
940
1115
|
*/
|
|
941
1116
|
in_reply_to?: string | null;
|
|
1117
|
+
/**
|
|
1118
|
+
* Whether the sender of the received message was authenticated. `pass` means the sender's identity was verified; `fail` means it was checked and did not verify; `unknown` means no verdict is available and the sender should not be treated as verified.
|
|
1119
|
+
*
|
|
1120
|
+
*/
|
|
1121
|
+
authentication?: "pass" | "fail" | "unknown" | null;
|
|
942
1122
|
/**
|
|
943
1123
|
* Whether SPF passed for the sender, or null when the result did not carry an SPF verdict.
|
|
944
1124
|
*/
|
|
@@ -1388,7 +1568,17 @@ type WebhookEvent = ({
|
|
|
1388
1568
|
type: "sms.sent";
|
|
1389
1569
|
} & EventSmsSent) | ({
|
|
1390
1570
|
type: "sms.undelivered";
|
|
1391
|
-
} & EventSmsUndelivered)
|
|
1571
|
+
} & EventSmsUndelivered) | ({
|
|
1572
|
+
type: "whatsapp.accepted";
|
|
1573
|
+
} & EventWhatsAppAccepted) | ({
|
|
1574
|
+
type: "whatsapp.delivered";
|
|
1575
|
+
} & EventWhatsAppDelivered) | ({
|
|
1576
|
+
type: "whatsapp.failed";
|
|
1577
|
+
} & EventWhatsAppFailed) | ({
|
|
1578
|
+
type: "whatsapp.read";
|
|
1579
|
+
} & EventWhatsAppRead) | ({
|
|
1580
|
+
type: "whatsapp.sent";
|
|
1581
|
+
} & EventWhatsAppSent);
|
|
1392
1582
|
type Timestamps = {
|
|
1393
1583
|
readonly created_at: string;
|
|
1394
1584
|
readonly updated_at: string;
|
|
@@ -1785,29 +1975,6 @@ type WhatsAppEventList = {
|
|
|
1785
1975
|
*/
|
|
1786
1976
|
data: Array<WhatsAppEvent>;
|
|
1787
1977
|
};
|
|
1788
|
-
/**
|
|
1789
|
-
* Bird-stable failure reason, uniform whether the failure happened internally or was reported by the WhatsApp network. `insufficient_balance` — the workspace could not afford the send. `price_not_found` — no price was configured for this destination/template combination. `internal_error` — an unexpected Bird-side failure. `undeliverable` — the recipient could not be reached (e.g. not on WhatsApp, number invalid). `service_window_expired` — the 24-hour customer care window has closed and a free-form message cannot be sent; send a template instead. `rate_limited` — the send was throttled.
|
|
1790
|
-
*
|
|
1791
|
-
*/
|
|
1792
|
-
type WhatsAppErrorCode = string;
|
|
1793
|
-
/**
|
|
1794
|
-
* Failure detail for a message that could not be delivered. Null when there is no failure.
|
|
1795
|
-
*/
|
|
1796
|
-
type WhatsAppError = {
|
|
1797
|
-
code: WhatsAppErrorCode;
|
|
1798
|
-
/**
|
|
1799
|
-
* Human-readable explanation of the failure.
|
|
1800
|
-
*/
|
|
1801
|
-
readonly description: string;
|
|
1802
|
-
/**
|
|
1803
|
-
* Raw error code from the WhatsApp Cloud API, when available, for low-level debugging.
|
|
1804
|
-
*/
|
|
1805
|
-
readonly meta_error_code?: string | null;
|
|
1806
|
-
/**
|
|
1807
|
-
* When the failure occurred.
|
|
1808
|
-
*/
|
|
1809
|
-
readonly occurred_at: string;
|
|
1810
|
-
} | null;
|
|
1811
1978
|
type WhatsAppEventId = string;
|
|
1812
1979
|
type WhatsAppEvent = {
|
|
1813
1980
|
/**
|
|
@@ -1826,7 +1993,7 @@ type WhatsAppEvent = {
|
|
|
1826
1993
|
/**
|
|
1827
1994
|
* Failure detail. Present on `whatsapp.failed` events; null otherwise.
|
|
1828
1995
|
*/
|
|
1829
|
-
error
|
|
1996
|
+
error?: WhatsAppError;
|
|
1830
1997
|
};
|
|
1831
1998
|
type SendWhatsAppMessageRequest = {
|
|
1832
1999
|
/**
|
|
@@ -1941,7 +2108,6 @@ type WhatsAppMessageBusiness = {
|
|
|
1941
2108
|
*/
|
|
1942
2109
|
readonly phone_number_id?: string;
|
|
1943
2110
|
};
|
|
1944
|
-
type WhatsAppMessageId = string;
|
|
1945
2111
|
type WhatsAppMessage = {
|
|
1946
2112
|
/**
|
|
1947
2113
|
* Message ID.
|
|
@@ -4580,6 +4746,11 @@ declare const WebhookEventType: {
|
|
|
4580
4746
|
readonly SmsRejected: "sms.rejected";
|
|
4581
4747
|
readonly SmsSent: "sms.sent";
|
|
4582
4748
|
readonly SmsUndelivered: "sms.undelivered";
|
|
4749
|
+
readonly WhatsappAccepted: "whatsapp.accepted";
|
|
4750
|
+
readonly WhatsappDelivered: "whatsapp.delivered";
|
|
4751
|
+
readonly WhatsappFailed: "whatsapp.failed";
|
|
4752
|
+
readonly WhatsappRead: "whatsapp.read";
|
|
4753
|
+
readonly WhatsappSent: "whatsapp.sent";
|
|
4583
4754
|
};
|
|
4584
4755
|
/** A known webhook event type value. */
|
|
4585
4756
|
type WebhookEventTypeValue = (typeof WebhookEventType)[keyof typeof WebhookEventType];
|
package/dist/index.mjs
CHANGED
|
@@ -3153,9 +3153,9 @@ var BirdClient = class {
|
|
|
3153
3153
|
this.#headers = {
|
|
3154
3154
|
...opts.defaultHeaders,
|
|
3155
3155
|
Authorization: `Bearer ${opts.apiKey}`,
|
|
3156
|
-
"User-Agent": `bird-sdk-js/0.8.
|
|
3156
|
+
"User-Agent": `bird-sdk-js/0.8.2`,
|
|
3157
3157
|
"Bird-Surface": "sdk-js",
|
|
3158
|
-
"Bird-Version": "0.8.
|
|
3158
|
+
"Bird-Version": "0.8.2"
|
|
3159
3159
|
};
|
|
3160
3160
|
const caller = detectCaller();
|
|
3161
3161
|
if (caller) this.#headers["Bird-Caller"] = caller;
|
|
@@ -3273,7 +3273,12 @@ const WebhookEventType = {
|
|
|
3273
3273
|
SmsFailed: "sms.failed",
|
|
3274
3274
|
SmsRejected: "sms.rejected",
|
|
3275
3275
|
SmsSent: "sms.sent",
|
|
3276
|
-
SmsUndelivered: "sms.undelivered"
|
|
3276
|
+
SmsUndelivered: "sms.undelivered",
|
|
3277
|
+
WhatsappAccepted: "whatsapp.accepted",
|
|
3278
|
+
WhatsappDelivered: "whatsapp.delivered",
|
|
3279
|
+
WhatsappFailed: "whatsapp.failed",
|
|
3280
|
+
WhatsappRead: "whatsapp.read",
|
|
3281
|
+
WhatsappSent: "whatsapp.sent"
|
|
3277
3282
|
};
|
|
3278
3283
|
//#endregion
|
|
3279
3284
|
export { BirdAPIError, BirdAuthError, BirdBadRequestError, BirdBillingError, BirdClient, BirdConflictError, BirdConnectionError, BirdError, BirdInternalError, BirdMisdirectedError, BirdNotFoundError, BirdNotImplementedError, BirdPayloadTooLargeError, BirdPermissionError, BirdPreconditionError, BirdRateLimitError, BirdServiceUnavailableError, BirdTimeoutError, BirdValidationError, BirdWebhookVerificationError, WebhookEventType, baseUrlForRegion, regionFromApiKey };
|