@messagebird/sdk 0.28.0 → 0.29.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.mjs CHANGED
@@ -1532,7 +1532,7 @@ const cancelEmailMessage = (options) => (options.client ?? client).post({
1532
1532
  /**
1533
1533
  * List contacts
1534
1534
  *
1535
- * Returns a paginated list of contacts in the workspace, newest first. Look up a single contact by its exact `email`, `phone_number`, or `external_id`, or search by email, first name, last name, or phone substring with `q`. Pass `include_total=true` to add the total number of matching contacts to the response.
1535
+ * Returns a paginated list of contacts in the workspace, newest first. Look up a single contact by its exact `email`, `phone_number`, or `external_id`, or search by email, first name, last name, or phone substring with `q`. Repeat `phone_number` to resolve up to 50 numbers to their contacts in one request, raising `limit` to at least the number of values you pass. Pass `include_total=true` to add the total number of matching contacts to the response.
1536
1536
  *
1537
1537
  */
1538
1538
  const listContacts = (options) => (options?.client ?? client).get({
@@ -4179,6 +4179,29 @@ var EmailResource = class extends EmailResourceBase {
4179
4179
  * });
4180
4180
  * console.log(msg.id, msg.status); // "em_…", "accepted"
4181
4181
  *
4182
+ * @example Send a published template instead of inline content
4183
+ * const msg = await bird.email.send({
4184
+ * from: { email: "onboarding@messagebird.dev", name: "Bird" },
4185
+ * to: ["delivered@messagebird.dev"],
4186
+ * category: "transactional",
4187
+ * template: {
4188
+ * slug: "welcome-email",
4189
+ * parameters: { first_name: "Jane" },
4190
+ * },
4191
+ * });
4192
+ * console.log(msg.id, msg.status);
4193
+ *
4194
+ * @example Sending to the sandbox bounce address, which hard-bounces every time
4195
+ * const msg = await bird.email.send({
4196
+ * from: { email: "onboarding@messagebird.dev", name: "Bird" },
4197
+ * to: ["bounce+signup-flow@messagebird.dev"],
4198
+ * subject: "Sandbox bounce test",
4199
+ * html: "<p>This message will hard-bounce.</p>",
4200
+ * tags: [{ name: "flow", value: "signup" }],
4201
+ * metadata: { test_run: "docs-capture-1" },
4202
+ * });
4203
+ * console.log(msg.id, msg.status); // "em_…", "accepted"
4204
+ *
4182
4205
  * @example A richer send — cc/bcc, reply-to, tags, metadata, click-tracking off, and an idempotency key (safe to retry; the server dedupes)
4183
4206
  * await bird.email.send(
4184
4207
  * {
@@ -4632,7 +4655,7 @@ var ContactPropertiesResource = class extends Resource {
4632
4655
  //#region src/resources/contacts.gen.ts
4633
4656
  var ContactsResource = class extends Resource {
4634
4657
  /**
4635
- * List the workspace's contacts as a cursor page, newest first. Look one up by exact email, phone_number, or external_id, or search by email, name, or phone substring. Pass include_total for a total count.
4658
+ * List the workspace's contacts as a cursor page, newest first. Look one up by exact email, phone_number, or external_id, repeating phone_number to resolve up to 50 numbers in one call (raise limit to match), or search by email, name, or phone substring. Pass include_total for a total count.
4636
4659
  *
4637
4660
  * @example Iterate every contact, or take one page
4638
4661
  * for await (const contact of bird.contacts.list({ q: "acme.com" })) {
@@ -4780,7 +4803,7 @@ var SmsResourceBase = class extends Resource {
4780
4803
  var SmsResource = class extends SmsResourceBase {
4781
4804
  /**
4782
4805
  * Send one SMS to a single recipient. Supply either `text` (with a `category`)
4783
- * or a stored `template` (by `id` or `name`, with its `parameters`). The
4806
+ * or a stored `template` (by `id` or `slug`, with its `parameters`). The
4784
4807
  * result is `accepted`, not yet delivered — read it back with `get` to confirm.
4785
4808
  *
4786
4809
  * @example Send free text
@@ -4795,7 +4818,7 @@ var SmsResource = class extends SmsResourceBase {
4795
4818
  * @example Send by template
4796
4819
  * await bird.sms.send({
4797
4820
  * to: "+14155550100",
4798
- * template: { name: "bird_otp_verification", parameters: { code: "123456" } },
4821
+ * template: { slug: "bird_otp_verification", parameters: { code: "123456" } },
4799
4822
  * });
4800
4823
  */
4801
4824
  send(params, options) {
@@ -4833,7 +4856,7 @@ var SmsTemplatesResource = class extends Resource {
4833
4856
  *
4834
4857
  * @example List the built-in templates
4835
4858
  * const { data } = await bird.smsTemplates.list({ scope: "system" });
4836
- * for (const tpl of data) console.log(tpl.id, tpl.name);
4859
+ * for (const tpl of data) console.log(tpl.id, tpl.slug);
4837
4860
  */
4838
4861
  list(query, options) {
4839
4862
  return this.call("GET", options, ({ signal, headers }) => listSmsTemplates({
@@ -4844,9 +4867,9 @@ var SmsTemplatesResource = class extends Resource {
4844
4867
  }));
4845
4868
  }
4846
4869
  /**
4847
- * Get one SMS template by its name or id, including its body and the variables it expects. Fetch it before sms_send to see which parameter keys a template send requires.
4870
+ * Get one SMS template by its slug or id, including its body and the variables it expects. Fetch it before sms_send to see which parameter keys a template send requires.
4848
4871
  *
4849
- * @example Read one template by name or id
4872
+ * @example Read one template by slug or id
4850
4873
  * const tpl = await bird.smsTemplates.get("bird_otp_verification");
4851
4874
  * console.log(tpl.body, tpl.variables);
4852
4875
  */
@@ -4927,9 +4950,7 @@ var WhatsappResource = class extends WhatsappResourceBase {
4927
4950
  * to: "+15551234567",
4928
4951
  * template: {
4929
4952
  * slug: "bird_otp",
4930
- * components: [
4931
- * { type: "body", parameters: [{ type: "text", text: "123456" }] },
4932
- * ],
4953
+ * components: [{ type: "body", parameters: [{ type: "text", text: "123456" }] }],
4933
4954
  * },
4934
4955
  * });
4935
4956
  * console.log(msg.id, msg.status);
@@ -4986,7 +5007,7 @@ var VoiceResource = class extends Resource {
4986
5007
  //#region src/resources/verifyVerifications.gen.ts
4987
5008
  var VerifyVerificationsResource = class extends Resource {
4988
5009
  /**
4989
- * Start a verification: generate a one-time passcode and send it to the recipient in `to` (a phone number over the phone channels enabled for its destination country; an email address over email; or both). It is sent over one channel at a time and fails over to the next in the plan, never over two at once. Calling again for the same recipient reuses the in-progress verification and sends a fresh code after the resend cooldown; it does not start a second one, so use this both to send and to resend. The passcode is never returned; submit what the recipient enters with verify_verifications_check. SMS delivery draws on the workspace's SMS balance.
5010
+ * Start a verification: generate a one-time passcode and send it to the recipient in `to` (a phone number over the phone channels enabled for its destination country; an email address over email; or both). It is sent over one channel at a time and fails over to the next in the plan, never over two at once. Calling again for the same recipient reuses the in-progress verification and sends a fresh code after the resend cooldown; it does not start a second one, so use this both to send and to resend. The passcode is never returned; submit what the recipient enters with verify_verifications_check. SMS, WhatsApp and Telegram delivery all draw on the workspace's balance.
4990
5011
  *
4991
5012
  * @example Start a verification over SMS
4992
5013
  * const verification = await bird.verify.verifications.create({
@@ -5386,9 +5407,9 @@ var BirdClient = class {
5386
5407
  this.#headers = {
5387
5408
  ...opts.defaultHeaders,
5388
5409
  Authorization: `Bearer ${opts.apiKey}`,
5389
- "User-Agent": `bird-sdk-js/0.28.0`,
5410
+ "User-Agent": `bird-sdk-js/0.29.0`,
5390
5411
  "Bird-Surface": "sdk-js",
5391
- "Bird-Version": "0.28.0"
5412
+ "Bird-Version": "0.29.0"
5392
5413
  };
5393
5414
  const caller = detectCaller();
5394
5415
  if (caller) this.#headers["Bird-Caller"] = caller;
@@ -5622,6 +5643,28 @@ const SMSErrorCode = {
5622
5643
  Unreachable: "unreachable"
5623
5644
  };
5624
5645
  /**
5646
+ * Values of TemplateLanguageStatus known at this SDK version. The wire value is an open
5647
+ * string: a value added by a newer server deserializes unchanged, so switch on
5648
+ * these with a `default` branch rather than treating the set as closed.
5649
+ */
5650
+ const TemplateLanguageStatus = {
5651
+ Draft: "draft",
5652
+ Live: "live",
5653
+ Superseded: "superseded"
5654
+ };
5655
+ /**
5656
+ * Values of TemplateStatus known at this SDK version. The wire value is an open
5657
+ * string: a value added by a newer server deserializes unchanged, so switch on
5658
+ * these with a `default` branch rather than treating the set as closed.
5659
+ */
5660
+ const TemplateStatus = {
5661
+ Active: "active",
5662
+ Draft: "draft",
5663
+ Inactive: "inactive",
5664
+ Pending: "pending",
5665
+ Rejected: "rejected"
5666
+ };
5667
+ /**
5625
5668
  * Values of VerificationAttemptFailureReason known at this SDK version. The wire value is an open
5626
5669
  * string: a value added by a newer server deserializes unchanged, so switch on
5627
5670
  * these with a `default` branch rather than treating the set as closed.
@@ -5643,6 +5686,7 @@ const VerificationAttemptFailureReason = {
5643
5686
  const VerificationChannel = {
5644
5687
  Email: "email",
5645
5688
  Sms: "sms",
5689
+ Telegram: "telegram",
5646
5690
  Whatsapp: "whatsapp"
5647
5691
  };
5648
5692
  /**
@@ -5669,6 +5713,19 @@ const WhatsAppErrorCode = {
5669
5713
  Undeliverable: "undeliverable"
5670
5714
  };
5671
5715
  /**
5716
+ * Values of WhatsAppEventType known at this SDK version. The wire value is an open
5717
+ * string: a value added by a newer server deserializes unchanged, so switch on
5718
+ * these with a `default` branch rather than treating the set as closed.
5719
+ */
5720
+ const WhatsAppEventType = {
5721
+ WhatsappAccepted: "whatsapp.accepted",
5722
+ WhatsappDelivered: "whatsapp.delivered",
5723
+ WhatsappFailed: "whatsapp.failed",
5724
+ WhatsappRead: "whatsapp.read",
5725
+ WhatsappRejected: "whatsapp.rejected",
5726
+ WhatsappSent: "whatsapp.sent"
5727
+ };
5728
+ /**
5672
5729
  * Values of WhatsAppTemplateCategory known at this SDK version. The wire value is an open
5673
5730
  * string: a value added by a newer server deserializes unchanged, so switch on
5674
5731
  * these with a `default` branch rather than treating the set as closed.
@@ -5692,6 +5749,6 @@ const WhatsAppTemplateParameterType = {
5692
5749
  Video: "video"
5693
5750
  };
5694
5751
  //#endregion
5695
- export { BirdAPIError, BirdAuthError, BirdBadRequestError, BirdBillingError, BirdClient, BirdConflictError, BirdConnectionError, BirdError, BirdInternalError, BirdMisdirectedError, BirdNotFoundError, BirdNotImplementedError, BirdPayloadTooLargeError, BirdPermissionError, BirdPreconditionError, BirdRateLimitError, BirdServiceUnavailableError, BirdTimeoutError, BirdValidationError, BirdWebhookVerificationError, EmailEventType, EmailLookupFlag, EmailLookupReason, EmailLookupResult, LookupFlag, LookupPropertyStatus, SMSErrorCode, VerificationAttemptFailureReason, VerificationChannel, VerificationTerminalReason, WebhookEventType, WhatsAppErrorCode, WhatsAppTemplateCategory, WhatsAppTemplateParameterType, baseUrlForRegion, regionFromApiKey };
5752
+ export { BirdAPIError, BirdAuthError, BirdBadRequestError, BirdBillingError, BirdClient, BirdConflictError, BirdConnectionError, BirdError, BirdInternalError, BirdMisdirectedError, BirdNotFoundError, BirdNotImplementedError, BirdPayloadTooLargeError, BirdPermissionError, BirdPreconditionError, BirdRateLimitError, BirdServiceUnavailableError, BirdTimeoutError, BirdValidationError, BirdWebhookVerificationError, EmailEventType, EmailLookupFlag, EmailLookupReason, EmailLookupResult, LookupFlag, LookupPropertyStatus, SMSErrorCode, TemplateLanguageStatus, TemplateStatus, VerificationAttemptFailureReason, VerificationChannel, VerificationTerminalReason, WebhookEventType, WhatsAppErrorCode, WhatsAppEventType, WhatsAppTemplateCategory, WhatsAppTemplateParameterType, baseUrlForRegion, regionFromApiKey };
5696
5753
 
5697
5754
  //# sourceMappingURL=index.mjs.map