@messagebird/sdk 0.8.4 → 0.9.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/dist/index.d.mts CHANGED
@@ -381,7 +381,7 @@ type EventWhatsAppRead = {
381
381
  */
382
382
  type WhatsAppErrorCode = string;
383
383
  /**
384
- * Failure detail for a message that could not be delivered. Null when there is no failure.
384
+ * Failure detail for a message that could not be delivered.
385
385
  */
386
386
  type WhatsAppError = {
387
387
  code: WhatsAppErrorCode;
@@ -472,7 +472,7 @@ type EventSmsUndeliveredData = EventSmsBase & {
472
472
  */
473
473
  type SmsErrorCode = "invalid_destination" | "unreachable" | "blocked_by_carrier" | "blocked_by_recipient" | "landline_unreachable" | "content_rejected" | "sender_unregistered" | "recipient_opted_out" | "provider_unavailable" | "insufficient_balance" | "unknown";
474
474
  /**
475
- * Failure detail for a message that could not be delivered or was rejected. Null when there is no failure.
475
+ * Failure detail for a message that could not be delivered or was rejected.
476
476
  */
477
477
  type SmsError = {
478
478
  code: SmsErrorCode;
@@ -1942,15 +1942,15 @@ type WhatsAppTemplateCategory = string;
1942
1942
  */
1943
1943
  type TemplateScope = "system" | "workspace";
1944
1944
  /**
1945
- * A template's send-by handle — the stable reference used in place of the template id when sending. Lowercase letters, numbers, hyphens, and underscores; starts and ends with a letter or number.
1945
+ * A WhatsApp template's name — the stable handle used to reference the template when sending. Lowercase letters, numbers, and underscores.
1946
1946
  *
1947
1947
  */
1948
- type TemplateName = string;
1948
+ type WhatsAppTemplateName = string;
1949
1949
  type WhatsAppTemplate = {
1950
1950
  /**
1951
1951
  * The template's stable handle. Pass it as the template reference when sending.
1952
1952
  */
1953
- readonly name: TemplateName;
1953
+ readonly name: WhatsAppTemplateName;
1954
1954
  scope: TemplateScope;
1955
1955
  /**
1956
1956
  * The language code of this template variant (for example `en` or `pt_BR`).
@@ -1991,11 +1991,11 @@ type WhatsAppEvent = {
1991
1991
  */
1992
1992
  readonly occurred_at: string;
1993
1993
  /**
1994
- * Failure detail. Present on `whatsapp.failed` events; null otherwise.
1994
+ * Failure detail. Present only on `whatsapp.failed` events.
1995
1995
  */
1996
1996
  error?: WhatsAppError;
1997
1997
  };
1998
- type SendWhatsAppMessageRequest = {
1998
+ type WhatsAppMessageSendRequest = {
1999
1999
  /**
2000
2000
  * The message recipient's phone number in E.164 format (for example `+31612345678`).
2001
2001
  */
@@ -2004,7 +2004,7 @@ type SendWhatsAppMessageRequest = {
2004
2004
  * The template to send. Bird selects the sender number from the template's category, so there is no sender field on this request. Templates are currently the only supported content type, so every send must include one; free-text content will be added in a future release.
2005
2005
  *
2006
2006
  */
2007
- template?: SendWhatsAppMessageTemplate;
2007
+ template?: WhatsAppTemplateSend;
2008
2008
  /**
2009
2009
  * Structured `{name, value}` labels for filtering. Tags become first-class query dimensions: filter the list endpoint by tag name. Maximum 20 tags per send. Use tags for low-cardinality dimensions (`category`, `experiment_variant`). For arbitrary structured context you do not need as a filter dimension, use `metadata` instead.
2010
2010
  *
@@ -2038,11 +2038,11 @@ type WhatsAppMessageTemplateComponent = {
2038
2038
  */
2039
2039
  parameters?: Array<WhatsAppMessageTemplateComponentParameter>;
2040
2040
  };
2041
- type SendWhatsAppMessageTemplate = {
2041
+ type WhatsAppTemplateSend = {
2042
2042
  /**
2043
2043
  * The template to send, by its name (for example `bird_otp`).
2044
2044
  */
2045
- name: TemplateName;
2045
+ name: WhatsAppTemplateName;
2046
2046
  /**
2047
2047
  * Language code of the template variant to send (for example `en` or `pt_BR`). May be omitted when the template has a single language.
2048
2048
  *
@@ -2066,7 +2066,7 @@ type WhatsAppMessageTemplate = {
2066
2066
  /**
2067
2067
  * The template's stable handle (for example `bird_otp`).
2068
2068
  */
2069
- readonly name: TemplateName;
2069
+ readonly name: WhatsAppTemplateName;
2070
2070
  /**
2071
2071
  * Content classification applied to messages sent from this template.
2072
2072
  */
@@ -2081,33 +2081,6 @@ type WhatsAppMessageTemplate = {
2081
2081
  */
2082
2082
  readonly components: Array<WhatsAppMessageTemplateComponent>;
2083
2083
  };
2084
- /**
2085
- * Contact on the other end of the message. Fields are omitted when not available; at least one is always present.
2086
- */
2087
- type WhatsAppMessageContact = {
2088
- /**
2089
- * Contact's phone number in E.164 format, when known.
2090
- */
2091
- readonly phone_number?: string;
2092
- /**
2093
- * Business-scoped user ID (Meta's WhatsApp identifier for this contact within the business account), when available.
2094
- */
2095
- readonly bsuid?: string;
2096
- };
2097
- /**
2098
- * The business identity that sent the message. `phone_number` is always present; `phone_number_id` is included only for account-owned numbers.
2099
- *
2100
- */
2101
- type WhatsAppMessageBusiness = {
2102
- /**
2103
- * E.164 phone number of the WhatsApp business account that sent the message.
2104
- */
2105
- readonly phone_number?: string;
2106
- /**
2107
- * The WhatsApp phone number identifier. Present only for account-owned numbers.
2108
- */
2109
- readonly phone_number_id?: string;
2110
- };
2111
2084
  type WhatsAppMessage = {
2112
2085
  /**
2113
2086
  * Message ID.
@@ -2117,15 +2090,21 @@ type WhatsAppMessage = {
2117
2090
  * Whether the message was sent by the business (`outbound`) or received from the contact (`inbound`).
2118
2091
  */
2119
2092
  readonly direction: "outbound" | "inbound";
2120
- readonly business: WhatsAppMessageBusiness;
2121
- readonly contact: WhatsAppMessageContact;
2093
+ /**
2094
+ * Sender of the message. On outbound messages, the business number it was sent from; on inbound, the WhatsApp contact.
2095
+ */
2096
+ readonly from: WhatsAppAddress;
2097
+ /**
2098
+ * Recipient of the message. On outbound messages, the WhatsApp contact; on inbound, the business number.
2099
+ */
2100
+ readonly to: WhatsAppAddress;
2122
2101
  /**
2123
2102
  * The template the message was sent from. For authentication templates the filled-in values are not returned.
2124
2103
  */
2125
2104
  readonly template?: WhatsAppMessageTemplate;
2126
2105
  readonly status: WhatsAppMessageStatus;
2127
2106
  /**
2128
- * Failure detail for a message that did not reach the recipient. Null when there is no failure.
2107
+ * Failure detail for a message that did not reach the recipient. Present only when the message failed.
2129
2108
  */
2130
2109
  last_error?: WhatsAppError;
2131
2110
  /**
@@ -2290,6 +2269,11 @@ type TemplateVariable = {
2290
2269
  * Content classification. Drives opt-out (STOP) policy, quiet-hours, and per-country compliance.
2291
2270
  */
2292
2271
  type SmsMessageCategory = "transactional" | "marketing" | "authentication" | "service";
2272
+ /**
2273
+ * A template's send-by handle — the stable reference used in place of the template id when sending. Lowercase letters, numbers, hyphens, and underscores; starts and ends with a letter or number.
2274
+ *
2275
+ */
2276
+ type TemplateName = string;
2293
2277
  type SmsTemplateId = string;
2294
2278
  type SmsTemplate = {
2295
2279
  /**
@@ -2487,7 +2471,7 @@ type SmsMessage = {
2487
2471
  */
2488
2472
  readonly mcc_mnc?: string | null;
2489
2473
  /**
2490
- * Failure detail on a terminally failed or rejected message. Null otherwise.
2474
+ * Failure detail on a terminally failed or rejected message. Present only when the message failed.
2491
2475
  */
2492
2476
  last_error?: SmsError;
2493
2477
  /**
@@ -4420,7 +4404,7 @@ declare class SmsTemplatesResource extends Resource {
4420
4404
  //#endregion
4421
4405
  //#region src/resources/whatsapp.d.ts
4422
4406
  /** Body for `bird.whatsapp.send` — a template send; Bird picks the sender from the template's category. */
4423
- type WhatsappSendParams = SendWhatsAppMessageRequest;
4407
+ type WhatsappSendParams = WhatsAppMessageSendRequest;
4424
4408
  /** Filters and cursor params for `bird.whatsapp.list`. */
4425
4409
  type WhatsappListQuery = NonNullable<ListWhatsAppMessagesData["query"]>;
4426
4410
  /** Filter for `bird.whatsapp.listEvents`. */
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.4`,
3156
+ "User-Agent": `bird-sdk-js/0.9.0`,
3157
3157
  "Bird-Surface": "sdk-js",
3158
- "Bird-Version": "0.8.4"
3158
+ "Bird-Version": "0.9.0"
3159
3159
  };
3160
3160
  const caller = detectCaller();
3161
3161
  if (caller) this.#headers["Bird-Caller"] = caller;