@gravity-rail/sdk 0.11.0 → 0.12.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/internal.cjs CHANGED
@@ -455,6 +455,7 @@ var EventRuleObjectType = /* @__PURE__ */ ((EventRuleObjectType2) => {
455
455
  EventRuleObjectType2["CALENDAR_EVENT_TYPE"] = "calendar_event_type";
456
456
  EventRuleObjectType2["JOURNEY"] = "journey";
457
457
  EventRuleObjectType2["CALL"] = "call";
458
+ EventRuleObjectType2["VOICEMAIL"] = "voicemail";
458
459
  return EventRuleObjectType2;
459
460
  })(EventRuleObjectType || {});
460
461
  var EventRuleEventType = /* @__PURE__ */ ((EventRuleEventType2) => {
@@ -486,6 +487,7 @@ var EventRuleEventType = /* @__PURE__ */ ((EventRuleEventType2) => {
486
487
  EventRuleEventType2["CALL_STARTED"] = "call:started";
487
488
  EventRuleEventType2["CALL_COMPLETED"] = "call:completed";
488
489
  EventRuleEventType2["CALL_SUMMARY"] = "call:summary";
490
+ EventRuleEventType2["VOICEMAIL_RECEIVED"] = "voicemail:received";
489
491
  return EventRuleEventType2;
490
492
  })(EventRuleEventType || {});
491
493
  var EventRuleActionType = /* @__PURE__ */ ((EventRuleActionType2) => {
@@ -536,11 +538,9 @@ var WorkspaceFeature = /* @__PURE__ */ ((WorkspaceFeature2) => {
536
538
  WorkspaceFeature2["BROWSER"] = "browser";
537
539
  WorkspaceFeature2["WEB_SEARCH"] = "web_search";
538
540
  WorkspaceFeature2["CALENDAR"] = "calendar";
539
- WorkspaceFeature2["DIRECT_MESSAGES"] = "direct_messages";
540
541
  WorkspaceFeature2["JOURNEYS"] = "journeys";
541
542
  WorkspaceFeature2["EXPERIMENTS"] = "experiments";
542
543
  WorkspaceFeature2["OPERATOR"] = "operator";
543
- WorkspaceFeature2["PRESENCE"] = "presence";
544
544
  WorkspaceFeature2["GMAIL"] = "gmail";
545
545
  WorkspaceFeature2["GCALENDAR"] = "gcalendar";
546
546
  WorkspaceFeature2["MONDAY"] = "monday";
@@ -937,7 +937,10 @@ var CustomerActivityClassifierLabel = {
937
937
  escalation_failure: "escalation_failure",
938
938
  repeated_tool_failure: "repeated_tool_failure",
939
939
  transcription_quality: "transcription_quality",
940
- repetitive_loop: "repetitive_loop"
940
+ repetitive_loop: "repetitive_loop",
941
+ manager_no_response: "manager_no_response",
942
+ docs_or_skill_gap: "docs_or_skill_gap",
943
+ discovery_thrash: "discovery_thrash"
941
944
  };
942
945
  var CustomerActivityEventSource = {
943
946
  system: "system",
@@ -7586,24 +7589,24 @@ var OrgApi = class extends BaseApiClient {
7586
7589
  return this.fetch(`o/${orgUuid}/phone-numbers/a2p/status`);
7587
7590
  }
7588
7591
  /**
7589
- * Start org-level A2P brand registration.
7592
+ * Start A2P brand registration under a legal entity. `legalEntityUuid`
7593
+ * is required — brands register per legal entity (Customer Profile);
7594
+ * there is no primary-entity fallback.
7590
7595
  */
7591
- async startA2PRegistration(orgUuid, brandName, brandDescription) {
7592
- return this.fetch(
7593
- `o/${orgUuid}/phone-numbers/a2p/start`,
7594
- {
7595
- method: "POST",
7596
- body: JSON.stringify({ brandName, brandDescription })
7597
- }
7598
- );
7596
+ async startA2PRegistration(orgUuid, legalEntityUuid, brandName, brandDescription) {
7597
+ return this.fetch(`o/${orgUuid}/phone-numbers/a2p/start`, {
7598
+ method: "POST",
7599
+ body: JSON.stringify({ legalEntityUuid, brandName, brandDescription })
7600
+ });
7599
7601
  }
7600
7602
  /**
7601
- * Approve sample messages for the org's A2P campaign.
7603
+ * Approve sample messages for one brand's A2P campaign. Signals the
7604
+ * brand's registration workflow to create the TCR campaign.
7602
7605
  */
7603
- async approveA2PMessages(orgUuid, sampleMessages) {
7606
+ async approveA2PMessages(orgUuid, brandUuid, sampleMessages) {
7604
7607
  return this.fetch(`o/${orgUuid}/phone-numbers/a2p/approve-messages`, {
7605
7608
  method: "POST",
7606
- body: JSON.stringify({ sampleMessages })
7609
+ body: JSON.stringify({ brandUuid, sampleMessages })
7607
7610
  });
7608
7611
  }
7609
7612
  // ============================================================================
@@ -7619,8 +7622,8 @@ var OrgApi = class extends BaseApiClient {
7619
7622
  * which is impossible (lifecycle status is one of `draft` /
7620
7623
  * `pending-review` / `in-review` / `twilio-approved` / `twilio-rejected`).
7621
7624
  */
7622
- async getBusinessProfile(orgUuid) {
7623
- return this.fetch(`o/${orgUuid}/business-profile`);
7625
+ async getBusinessProfile(orgUuid, legalEntityUuid) {
7626
+ return this.fetch(businessProfilePath(orgUuid, legalEntityUuid));
7624
7627
  }
7625
7628
  /**
7626
7629
  * Upsert the org's business profile. Idempotent via cached SIDs.
@@ -7628,8 +7631,8 @@ var OrgApi = class extends BaseApiClient {
7628
7631
  * compliance evaluation result so the frontend can immediately enable
7629
7632
  * Submit without a second round-trip.
7630
7633
  */
7631
- async updateBusinessProfile(orgUuid, data) {
7632
- return this.fetch(`o/${orgUuid}/business-profile`, {
7634
+ async updateBusinessProfile(orgUuid, data, legalEntityUuid) {
7635
+ return this.fetch(businessProfilePath(orgUuid, legalEntityUuid), {
7633
7636
  method: "PUT",
7634
7637
  body: JSON.stringify(data)
7635
7638
  });
@@ -7639,20 +7642,46 @@ var OrgApi = class extends BaseApiClient {
7639
7642
  * compliance live and returns 412 if the profile is not currently
7640
7643
  * `compliant`; returns 409 if a review is already in flight.
7641
7644
  */
7642
- async submitBusinessProfile(orgUuid) {
7643
- return this.fetch(`o/${orgUuid}/business-profile/submit`, {
7644
- method: "POST"
7645
- });
7645
+ async submitBusinessProfile(orgUuid, legalEntityUuid) {
7646
+ return this.fetch(
7647
+ `${businessProfilePath(orgUuid, legalEntityUuid)}/submit`,
7648
+ { method: "POST" }
7649
+ );
7646
7650
  }
7647
7651
  /**
7648
7652
  * Cancel an in-flight Twilio review. Resets the cached profile state
7649
7653
  * to `draft` so the user can edit and resubmit.
7650
7654
  */
7651
- async cancelBusinessProfile(orgUuid) {
7652
- return this.fetch(`o/${orgUuid}/business-profile/cancel`, {
7653
- method: "POST"
7655
+ async cancelBusinessProfile(orgUuid, legalEntityUuid) {
7656
+ return this.fetch(
7657
+ `${businessProfilePath(orgUuid, legalEntityUuid)}/cancel`,
7658
+ { method: "POST" }
7659
+ );
7660
+ }
7661
+ // ============================================================================
7662
+ // Legal entities (Twilio Secondary Customer Profiles)
7663
+ // ============================================================================
7664
+ /** List the org's legal entities (one Customer Profile each). */
7665
+ async listLegalEntities(orgUuid) {
7666
+ return this.fetch(`o/${orgUuid}/legal-entities`);
7667
+ }
7668
+ /** Create a legal entity. Its business profile is edited via the entity-scoped business-profile methods. */
7669
+ async createLegalEntity(orgUuid, data) {
7670
+ return this.fetch(`o/${orgUuid}/legal-entities`, {
7671
+ method: "POST",
7672
+ body: JSON.stringify(data)
7654
7673
  });
7655
7674
  }
7675
+ async getLegalEntity(orgUuid, legalEntityUuid) {
7676
+ return this.fetch(`o/${orgUuid}/legal-entities/${legalEntityUuid}`);
7677
+ }
7678
+ /**
7679
+ * Brand detail with live registration-workflow state (`workflowStatus`,
7680
+ * `pendingSampleMessages`) for the sample-approval step.
7681
+ */
7682
+ async getA2PBrand(orgUuid, brandUuid) {
7683
+ return this.fetch(`o/${orgUuid}/a2p-brands/${brandUuid}`);
7684
+ }
7656
7685
  /**
7657
7686
  * List the org's A2P brands (broker resources). The SMS-consent editor uses
7658
7687
  * this to pick which brand's consent config to edit.
@@ -7756,6 +7785,9 @@ var OrgApi = class extends BaseApiClient {
7756
7785
  );
7757
7786
  }
7758
7787
  };
7788
+ function businessProfilePath(orgUuid, legalEntityUuid) {
7789
+ return legalEntityUuid ? `o/${orgUuid}/legal-entities/${legalEntityUuid}/business-profile` : `o/${orgUuid}/business-profile`;
7790
+ }
7759
7791
 
7760
7792
  // src/api/oauth.ts
7761
7793
  function getOAuthPath(providerSlug, action) {
@@ -9048,11 +9080,11 @@ var SubscriptionsApi = class extends BaseApiClient {
9048
9080
  * customer, and subscription are created on payment by the checkout
9049
9081
  * completion handler.
9050
9082
  */
9051
- async createCheckoutSession(productId, planPeriod = "month") {
9083
+ async createCheckoutSession(productId, planPeriod = "month", options = {}) {
9052
9084
  return this.fetch(`subscriptions/checkout-session`, {
9053
9085
  method: "POST",
9054
9086
  credentials: "include",
9055
- body: JSON.stringify({ productId, planPeriod }),
9087
+ body: JSON.stringify({ productId, planPeriod, ...options }),
9056
9088
  headers: { "Content-Type": "application/json" }
9057
9089
  });
9058
9090
  }
@@ -9109,12 +9141,15 @@ var SubscriptionsApi = class extends BaseApiClient {
9109
9141
  return this.fetch(`subscriptions/${subscriptionId}/items`);
9110
9142
  }
9111
9143
  /** Purchase extra credits on a subscription (org-level). */
9112
- async purchaseCredits(subscriptionId, amountCents) {
9144
+ async purchaseCredits(subscriptionId, amountCents, idempotencyKey = crypto.randomUUID()) {
9113
9145
  return this.fetch(`subscriptions/${subscriptionId}/purchase-credits`, {
9114
9146
  method: "POST",
9115
9147
  credentials: "include",
9116
9148
  body: JSON.stringify({ amount_cents: amountCents }),
9117
- headers: { "Content-Type": "application/json" }
9149
+ headers: {
9150
+ "Content-Type": "application/json",
9151
+ "Idempotency-Key": idempotencyKey
9152
+ }
9118
9153
  });
9119
9154
  }
9120
9155
  };
@@ -9257,6 +9292,13 @@ var CustomersApi = class extends BaseApiClient {
9257
9292
  async getMyCustomerInvoices(uuid) {
9258
9293
  return this.fetch(`customers/${uuid}/invoices`);
9259
9294
  }
9295
+ async createMyCustomerPortalSession(uuid, returnUrl) {
9296
+ return this.fetch(`customers/${uuid}/stripe/portal-session`, {
9297
+ method: "POST",
9298
+ body: JSON.stringify({ returnUrl }),
9299
+ headers: { "Content-Type": "application/json" }
9300
+ });
9301
+ }
9260
9302
  async updateMyCustomer(uuid, data) {
9261
9303
  return this.fetch(`customers/${uuid}`, {
9262
9304
  method: "PUT",
@@ -9274,7 +9316,8 @@ var CustomersApi = class extends BaseApiClient {
9274
9316
  async attachMyCustomerPaymentMethod(uuid, paymentMethodId, setAsDefault = false) {
9275
9317
  return this.fetch(`customers/${uuid}/stripe/payment-methods/${paymentMethodId}/attach`, {
9276
9318
  method: "POST",
9277
- body: JSON.stringify({ setAsDefault })
9319
+ body: JSON.stringify({ setAsDefault }),
9320
+ headers: { "Content-Type": "application/json" }
9278
9321
  });
9279
9322
  }
9280
9323
  async detachMyCustomerPaymentMethod(uuid, paymentMethodId) {
@@ -12406,6 +12449,7 @@ function bindCustomersMethods(target, customers) {
12406
12449
  target.getMyCustomerAccounts = customers.getMyCustomerAccounts.bind(customers);
12407
12450
  target.getMyCustomerSubscriptions = customers.getMyCustomerSubscriptions.bind(customers);
12408
12451
  target.getMyCustomerInvoices = customers.getMyCustomerInvoices.bind(customers);
12452
+ target.createMyCustomerPortalSession = customers.createMyCustomerPortalSession.bind(customers);
12409
12453
  target.updateMyCustomer = customers.updateMyCustomer.bind(customers);
12410
12454
  target.createMyCustomerSetupIntent = customers.createMyCustomerSetupIntent.bind(customers);
12411
12455
  target.getMyCustomerPaymentMethods = customers.getMyCustomerPaymentMethods.bind(customers);
@@ -13392,6 +13436,7 @@ var GravityRailClient = class {
13392
13436
  getMyCustomerAccounts;
13393
13437
  getMyCustomerSubscriptions;
13394
13438
  getMyCustomerInvoices;
13439
+ createMyCustomerPortalSession;
13395
13440
  updateMyCustomer;
13396
13441
  createMyCustomerSetupIntent;
13397
13442
  getMyCustomerPaymentMethods;