@gravity-rail/sdk 0.11.0 → 0.13.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.
@@ -1,5 +1,5 @@
1
- import { dT as GravityRailClient } from './client-BCgXtr8p.cjs';
2
- import { bU as WorkspaceMemberResponse, aK as DataRecordResponse } from './tasks-C4aYbWVv.cjs';
1
+ import { dV as GravityRailClient } from './client-DlndHSuK.cjs';
2
+ import { bU as WorkspaceMemberResponse, aK as DataRecordResponse } from './tasks-Bz1JR0r0.cjs';
3
3
  import 'zod';
4
4
 
5
5
  interface OutboundPhoneNumberOption {
package/dist/helpers.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { dT as GravityRailClient } from './client-Dh1l20Ue.js';
2
- import { bU as WorkspaceMemberResponse, aK as DataRecordResponse } from './tasks-C4aYbWVv.js';
1
+ import { dV as GravityRailClient } from './client-BGs2ArRW.js';
2
+ import { bU as WorkspaceMemberResponse, aK as DataRecordResponse } from './tasks-Bz1JR0r0.js';
3
3
  import 'zod';
4
4
 
5
5
  interface OutboundPhoneNumberOption {
package/dist/index.cjs CHANGED
@@ -5610,26 +5610,41 @@ var OrgApi = class extends BaseApiClient {
5610
5610
  return this.fetch(`o/${orgUuid}/phone-numbers/a2p/status`);
5611
5611
  }
5612
5612
  /**
5613
- * Start org-level A2P brand registration.
5613
+ * Start A2P brand registration under a legal entity. `legalEntityUuid`
5614
+ * is required — brands register per legal entity (Customer Profile);
5615
+ * there is no primary-entity fallback.
5614
5616
  */
5615
- async startA2PRegistration(orgUuid, brandName, brandDescription) {
5616
- return this.fetch(
5617
- `o/${orgUuid}/phone-numbers/a2p/start`,
5618
- {
5619
- method: "POST",
5620
- body: JSON.stringify({ brandName, brandDescription })
5621
- }
5622
- );
5617
+ async startA2PRegistration(orgUuid, legalEntityUuid, brandName, brandDescription) {
5618
+ return this.fetch(`o/${orgUuid}/phone-numbers/a2p/start`, {
5619
+ method: "POST",
5620
+ body: JSON.stringify({ legalEntityUuid, brandName, brandDescription })
5621
+ });
5623
5622
  }
5624
5623
  /**
5625
- * Approve sample messages for the org's A2P campaign.
5624
+ * Approve sample messages for one brand's A2P campaign. Signals the
5625
+ * brand's registration workflow to create the TCR campaign.
5626
5626
  */
5627
- async approveA2PMessages(orgUuid, sampleMessages) {
5627
+ async approveA2PMessages(orgUuid, brandUuid, sampleMessages) {
5628
5628
  return this.fetch(`o/${orgUuid}/phone-numbers/a2p/approve-messages`, {
5629
5629
  method: "POST",
5630
- body: JSON.stringify({ sampleMessages })
5630
+ body: JSON.stringify({ brandUuid, sampleMessages })
5631
5631
  });
5632
5632
  }
5633
+ /**
5634
+ * Activate SMS on a workspace-assigned number: attach it to the given
5635
+ * brand's Messaging Service (A2P 10DLC). Preconditions (412 otherwise):
5636
+ * campaign VERIFIED, brand has a Messaging Service, phone assigned to a
5637
+ * workspace with a Twilio SID.
5638
+ */
5639
+ async activateA2PNumber(orgUuid, providerPhoneUuid, brandUuid) {
5640
+ return this.fetch(
5641
+ `o/${orgUuid}/phone-numbers/a2p/activate-number`,
5642
+ {
5643
+ method: "POST",
5644
+ body: JSON.stringify({ providerPhoneUuid, brandUuid })
5645
+ }
5646
+ );
5647
+ }
5633
5648
  // ============================================================================
5634
5649
  // Organization Business Profile API (Twilio Trust Hub Secondary CP)
5635
5650
  // ============================================================================
@@ -5643,8 +5658,8 @@ var OrgApi = class extends BaseApiClient {
5643
5658
  * which is impossible (lifecycle status is one of `draft` /
5644
5659
  * `pending-review` / `in-review` / `twilio-approved` / `twilio-rejected`).
5645
5660
  */
5646
- async getBusinessProfile(orgUuid) {
5647
- return this.fetch(`o/${orgUuid}/business-profile`);
5661
+ async getBusinessProfile(orgUuid, legalEntityUuid) {
5662
+ return this.fetch(businessProfilePath(orgUuid, legalEntityUuid));
5648
5663
  }
5649
5664
  /**
5650
5665
  * Upsert the org's business profile. Idempotent via cached SIDs.
@@ -5652,8 +5667,8 @@ var OrgApi = class extends BaseApiClient {
5652
5667
  * compliance evaluation result so the frontend can immediately enable
5653
5668
  * Submit without a second round-trip.
5654
5669
  */
5655
- async updateBusinessProfile(orgUuid, data) {
5656
- return this.fetch(`o/${orgUuid}/business-profile`, {
5670
+ async updateBusinessProfile(orgUuid, data, legalEntityUuid) {
5671
+ return this.fetch(businessProfilePath(orgUuid, legalEntityUuid), {
5657
5672
  method: "PUT",
5658
5673
  body: JSON.stringify(data)
5659
5674
  });
@@ -5663,20 +5678,70 @@ var OrgApi = class extends BaseApiClient {
5663
5678
  * compliance live and returns 412 if the profile is not currently
5664
5679
  * `compliant`; returns 409 if a review is already in flight.
5665
5680
  */
5666
- async submitBusinessProfile(orgUuid) {
5667
- return this.fetch(`o/${orgUuid}/business-profile/submit`, {
5668
- method: "POST"
5669
- });
5681
+ async submitBusinessProfile(orgUuid, legalEntityUuid) {
5682
+ return this.fetch(
5683
+ `${businessProfilePath(orgUuid, legalEntityUuid)}/submit`,
5684
+ { method: "POST" }
5685
+ );
5670
5686
  }
5671
5687
  /**
5672
5688
  * Cancel an in-flight Twilio review. Resets the cached profile state
5673
5689
  * to `draft` so the user can edit and resubmit.
5674
5690
  */
5675
- async cancelBusinessProfile(orgUuid) {
5676
- return this.fetch(`o/${orgUuid}/business-profile/cancel`, {
5677
- method: "POST"
5691
+ async cancelBusinessProfile(orgUuid, legalEntityUuid) {
5692
+ return this.fetch(
5693
+ `${businessProfilePath(orgUuid, legalEntityUuid)}/cancel`,
5694
+ { method: "POST" }
5695
+ );
5696
+ }
5697
+ // ============================================================================
5698
+ // Legal entities (Twilio Secondary Customer Profiles)
5699
+ // ============================================================================
5700
+ /** List the org's legal entities (one Customer Profile each). */
5701
+ async listLegalEntities(orgUuid) {
5702
+ return this.fetch(`o/${orgUuid}/legal-entities`);
5703
+ }
5704
+ /** Create a legal entity. Its business profile is edited via the entity-scoped business-profile methods. */
5705
+ async createLegalEntity(orgUuid, data) {
5706
+ return this.fetch(`o/${orgUuid}/legal-entities`, {
5707
+ method: "POST",
5708
+ body: JSON.stringify(data)
5678
5709
  });
5679
5710
  }
5711
+ async getLegalEntity(orgUuid, legalEntityUuid) {
5712
+ return this.fetch(`o/${orgUuid}/legal-entities/${legalEntityUuid}`);
5713
+ }
5714
+ /** Cached voice trust product state (CNAM / SHAKEN-STIR / Voice Integrity) for one legal entity. */
5715
+ async getVoiceTrustProducts(orgUuid, legalEntityUuid) {
5716
+ return this.fetch(
5717
+ `o/${orgUuid}/legal-entities/${legalEntityUuid}/trust-products`
5718
+ );
5719
+ }
5720
+ /** Reconcile trust product state against Twilio (discovery + status refresh). */
5721
+ async syncVoiceTrustProducts(orgUuid, legalEntityUuid) {
5722
+ return this.fetch(
5723
+ `o/${orgUuid}/legal-entities/${legalEntityUuid}/trust-products/sync`,
5724
+ // Empty JSON body is the CSRF barrier the route requires (GRA-6284).
5725
+ { method: "POST", body: JSON.stringify({}) }
5726
+ );
5727
+ }
5728
+ /**
5729
+ * Set up + submit one voice trust product for a legal entity. Requires
5730
+ * the entity's business profile to be twilio-approved (412 otherwise).
5731
+ */
5732
+ async setupVoiceTrustProduct(orgUuid, legalEntityUuid, product, data) {
5733
+ return this.fetch(
5734
+ `o/${orgUuid}/legal-entities/${legalEntityUuid}/trust-products/${product}`,
5735
+ { method: "POST", body: JSON.stringify(data) }
5736
+ );
5737
+ }
5738
+ /**
5739
+ * Brand detail with live registration-workflow state (`workflowStatus`,
5740
+ * `pendingSampleMessages`) for the sample-approval step.
5741
+ */
5742
+ async getA2PBrand(orgUuid, brandUuid) {
5743
+ return this.fetch(`o/${orgUuid}/a2p-brands/${brandUuid}`);
5744
+ }
5680
5745
  /**
5681
5746
  * List the org's A2P brands (broker resources). The SMS-consent editor uses
5682
5747
  * this to pick which brand's consent config to edit.
@@ -5780,6 +5845,9 @@ var OrgApi = class extends BaseApiClient {
5780
5845
  );
5781
5846
  }
5782
5847
  };
5848
+ function businessProfilePath(orgUuid, legalEntityUuid) {
5849
+ return legalEntityUuid ? `o/${orgUuid}/legal-entities/${legalEntityUuid}/business-profile` : `o/${orgUuid}/business-profile`;
5850
+ }
5783
5851
 
5784
5852
  // src/api/oauth.ts
5785
5853
  function getOAuthPath(providerSlug, action) {
@@ -7045,11 +7113,11 @@ var SubscriptionsApi = class extends BaseApiClient {
7045
7113
  * customer, and subscription are created on payment by the checkout
7046
7114
  * completion handler.
7047
7115
  */
7048
- async createCheckoutSession(productId, planPeriod = "month") {
7116
+ async createCheckoutSession(productId, planPeriod = "month", options = {}) {
7049
7117
  return this.fetch(`subscriptions/checkout-session`, {
7050
7118
  method: "POST",
7051
7119
  credentials: "include",
7052
- body: JSON.stringify({ productId, planPeriod }),
7120
+ body: JSON.stringify({ productId, planPeriod, ...options }),
7053
7121
  headers: { "Content-Type": "application/json" }
7054
7122
  });
7055
7123
  }
@@ -7106,12 +7174,15 @@ var SubscriptionsApi = class extends BaseApiClient {
7106
7174
  return this.fetch(`subscriptions/${subscriptionId}/items`);
7107
7175
  }
7108
7176
  /** Purchase extra credits on a subscription (org-level). */
7109
- async purchaseCredits(subscriptionId, amountCents) {
7177
+ async purchaseCredits(subscriptionId, amountCents, idempotencyKey = crypto.randomUUID()) {
7110
7178
  return this.fetch(`subscriptions/${subscriptionId}/purchase-credits`, {
7111
7179
  method: "POST",
7112
7180
  credentials: "include",
7113
7181
  body: JSON.stringify({ amount_cents: amountCents }),
7114
- headers: { "Content-Type": "application/json" }
7182
+ headers: {
7183
+ "Content-Type": "application/json",
7184
+ "Idempotency-Key": idempotencyKey
7185
+ }
7115
7186
  });
7116
7187
  }
7117
7188
  };
@@ -7254,6 +7325,13 @@ var CustomersApi = class extends BaseApiClient {
7254
7325
  async getMyCustomerInvoices(uuid) {
7255
7326
  return this.fetch(`customers/${uuid}/invoices`);
7256
7327
  }
7328
+ async createMyCustomerPortalSession(uuid, returnUrl) {
7329
+ return this.fetch(`customers/${uuid}/stripe/portal-session`, {
7330
+ method: "POST",
7331
+ body: JSON.stringify({ returnUrl }),
7332
+ headers: { "Content-Type": "application/json" }
7333
+ });
7334
+ }
7257
7335
  async updateMyCustomer(uuid, data) {
7258
7336
  return this.fetch(`customers/${uuid}`, {
7259
7337
  method: "PUT",
@@ -7271,7 +7349,8 @@ var CustomersApi = class extends BaseApiClient {
7271
7349
  async attachMyCustomerPaymentMethod(uuid, paymentMethodId, setAsDefault = false) {
7272
7350
  return this.fetch(`customers/${uuid}/stripe/payment-methods/${paymentMethodId}/attach`, {
7273
7351
  method: "POST",
7274
- body: JSON.stringify({ setAsDefault })
7352
+ body: JSON.stringify({ setAsDefault }),
7353
+ headers: { "Content-Type": "application/json" }
7275
7354
  });
7276
7355
  }
7277
7356
  async detachMyCustomerPaymentMethod(uuid, paymentMethodId) {
@@ -8270,6 +8349,7 @@ var EventRuleObjectType = /* @__PURE__ */ ((EventRuleObjectType2) => {
8270
8349
  EventRuleObjectType2["CALENDAR_EVENT_TYPE"] = "calendar_event_type";
8271
8350
  EventRuleObjectType2["JOURNEY"] = "journey";
8272
8351
  EventRuleObjectType2["CALL"] = "call";
8352
+ EventRuleObjectType2["VOICEMAIL"] = "voicemail";
8273
8353
  return EventRuleObjectType2;
8274
8354
  })(EventRuleObjectType || {});
8275
8355
  var EventRuleEventType = /* @__PURE__ */ ((EventRuleEventType2) => {
@@ -8301,6 +8381,7 @@ var EventRuleEventType = /* @__PURE__ */ ((EventRuleEventType2) => {
8301
8381
  EventRuleEventType2["CALL_STARTED"] = "call:started";
8302
8382
  EventRuleEventType2["CALL_COMPLETED"] = "call:completed";
8303
8383
  EventRuleEventType2["CALL_SUMMARY"] = "call:summary";
8384
+ EventRuleEventType2["VOICEMAIL_RECEIVED"] = "voicemail:received";
8304
8385
  return EventRuleEventType2;
8305
8386
  })(EventRuleEventType || {});
8306
8387
  var EventRuleActionType = /* @__PURE__ */ ((EventRuleActionType2) => {
@@ -8351,11 +8432,9 @@ var WorkspaceFeature = /* @__PURE__ */ ((WorkspaceFeature2) => {
8351
8432
  WorkspaceFeature2["BROWSER"] = "browser";
8352
8433
  WorkspaceFeature2["WEB_SEARCH"] = "web_search";
8353
8434
  WorkspaceFeature2["CALENDAR"] = "calendar";
8354
- WorkspaceFeature2["DIRECT_MESSAGES"] = "direct_messages";
8355
8435
  WorkspaceFeature2["JOURNEYS"] = "journeys";
8356
8436
  WorkspaceFeature2["EXPERIMENTS"] = "experiments";
8357
8437
  WorkspaceFeature2["OPERATOR"] = "operator";
8358
- WorkspaceFeature2["PRESENCE"] = "presence";
8359
8438
  WorkspaceFeature2["GMAIL"] = "gmail";
8360
8439
  WorkspaceFeature2["GCALENDAR"] = "gcalendar";
8361
8440
  WorkspaceFeature2["MONDAY"] = "monday";
@@ -11043,6 +11122,7 @@ function bindCustomersMethods(target, customers) {
11043
11122
  target.getMyCustomerAccounts = customers.getMyCustomerAccounts.bind(customers);
11044
11123
  target.getMyCustomerSubscriptions = customers.getMyCustomerSubscriptions.bind(customers);
11045
11124
  target.getMyCustomerInvoices = customers.getMyCustomerInvoices.bind(customers);
11125
+ target.createMyCustomerPortalSession = customers.createMyCustomerPortalSession.bind(customers);
11046
11126
  target.updateMyCustomer = customers.updateMyCustomer.bind(customers);
11047
11127
  target.createMyCustomerSetupIntent = customers.createMyCustomerSetupIntent.bind(customers);
11048
11128
  target.getMyCustomerPaymentMethods = customers.getMyCustomerPaymentMethods.bind(customers);
@@ -12029,6 +12109,7 @@ var GravityRailClient = class {
12029
12109
  getMyCustomerAccounts;
12030
12110
  getMyCustomerSubscriptions;
12031
12111
  getMyCustomerInvoices;
12112
+ createMyCustomerPortalSession;
12032
12113
  updateMyCustomer;
12033
12114
  createMyCustomerSetupIntent;
12034
12115
  getMyCustomerPaymentMethods;