@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.
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,26 +7589,41 @@ 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
  }
7612
+ /**
7613
+ * Activate SMS on a workspace-assigned number: attach it to the given
7614
+ * brand's Messaging Service (A2P 10DLC). Preconditions (412 otherwise):
7615
+ * campaign VERIFIED, brand has a Messaging Service, phone assigned to a
7616
+ * workspace with a Twilio SID.
7617
+ */
7618
+ async activateA2PNumber(orgUuid, providerPhoneUuid, brandUuid) {
7619
+ return this.fetch(
7620
+ `o/${orgUuid}/phone-numbers/a2p/activate-number`,
7621
+ {
7622
+ method: "POST",
7623
+ body: JSON.stringify({ providerPhoneUuid, brandUuid })
7624
+ }
7625
+ );
7626
+ }
7609
7627
  // ============================================================================
7610
7628
  // Organization Business Profile API (Twilio Trust Hub Secondary CP)
7611
7629
  // ============================================================================
@@ -7619,8 +7637,8 @@ var OrgApi = class extends BaseApiClient {
7619
7637
  * which is impossible (lifecycle status is one of `draft` /
7620
7638
  * `pending-review` / `in-review` / `twilio-approved` / `twilio-rejected`).
7621
7639
  */
7622
- async getBusinessProfile(orgUuid) {
7623
- return this.fetch(`o/${orgUuid}/business-profile`);
7640
+ async getBusinessProfile(orgUuid, legalEntityUuid) {
7641
+ return this.fetch(businessProfilePath(orgUuid, legalEntityUuid));
7624
7642
  }
7625
7643
  /**
7626
7644
  * Upsert the org's business profile. Idempotent via cached SIDs.
@@ -7628,8 +7646,8 @@ var OrgApi = class extends BaseApiClient {
7628
7646
  * compliance evaluation result so the frontend can immediately enable
7629
7647
  * Submit without a second round-trip.
7630
7648
  */
7631
- async updateBusinessProfile(orgUuid, data) {
7632
- return this.fetch(`o/${orgUuid}/business-profile`, {
7649
+ async updateBusinessProfile(orgUuid, data, legalEntityUuid) {
7650
+ return this.fetch(businessProfilePath(orgUuid, legalEntityUuid), {
7633
7651
  method: "PUT",
7634
7652
  body: JSON.stringify(data)
7635
7653
  });
@@ -7639,20 +7657,70 @@ var OrgApi = class extends BaseApiClient {
7639
7657
  * compliance live and returns 412 if the profile is not currently
7640
7658
  * `compliant`; returns 409 if a review is already in flight.
7641
7659
  */
7642
- async submitBusinessProfile(orgUuid) {
7643
- return this.fetch(`o/${orgUuid}/business-profile/submit`, {
7644
- method: "POST"
7645
- });
7660
+ async submitBusinessProfile(orgUuid, legalEntityUuid) {
7661
+ return this.fetch(
7662
+ `${businessProfilePath(orgUuid, legalEntityUuid)}/submit`,
7663
+ { method: "POST" }
7664
+ );
7646
7665
  }
7647
7666
  /**
7648
7667
  * Cancel an in-flight Twilio review. Resets the cached profile state
7649
7668
  * to `draft` so the user can edit and resubmit.
7650
7669
  */
7651
- async cancelBusinessProfile(orgUuid) {
7652
- return this.fetch(`o/${orgUuid}/business-profile/cancel`, {
7653
- method: "POST"
7670
+ async cancelBusinessProfile(orgUuid, legalEntityUuid) {
7671
+ return this.fetch(
7672
+ `${businessProfilePath(orgUuid, legalEntityUuid)}/cancel`,
7673
+ { method: "POST" }
7674
+ );
7675
+ }
7676
+ // ============================================================================
7677
+ // Legal entities (Twilio Secondary Customer Profiles)
7678
+ // ============================================================================
7679
+ /** List the org's legal entities (one Customer Profile each). */
7680
+ async listLegalEntities(orgUuid) {
7681
+ return this.fetch(`o/${orgUuid}/legal-entities`);
7682
+ }
7683
+ /** Create a legal entity. Its business profile is edited via the entity-scoped business-profile methods. */
7684
+ async createLegalEntity(orgUuid, data) {
7685
+ return this.fetch(`o/${orgUuid}/legal-entities`, {
7686
+ method: "POST",
7687
+ body: JSON.stringify(data)
7654
7688
  });
7655
7689
  }
7690
+ async getLegalEntity(orgUuid, legalEntityUuid) {
7691
+ return this.fetch(`o/${orgUuid}/legal-entities/${legalEntityUuid}`);
7692
+ }
7693
+ /** Cached voice trust product state (CNAM / SHAKEN-STIR / Voice Integrity) for one legal entity. */
7694
+ async getVoiceTrustProducts(orgUuid, legalEntityUuid) {
7695
+ return this.fetch(
7696
+ `o/${orgUuid}/legal-entities/${legalEntityUuid}/trust-products`
7697
+ );
7698
+ }
7699
+ /** Reconcile trust product state against Twilio (discovery + status refresh). */
7700
+ async syncVoiceTrustProducts(orgUuid, legalEntityUuid) {
7701
+ return this.fetch(
7702
+ `o/${orgUuid}/legal-entities/${legalEntityUuid}/trust-products/sync`,
7703
+ // Empty JSON body is the CSRF barrier the route requires (GRA-6284).
7704
+ { method: "POST", body: JSON.stringify({}) }
7705
+ );
7706
+ }
7707
+ /**
7708
+ * Set up + submit one voice trust product for a legal entity. Requires
7709
+ * the entity's business profile to be twilio-approved (412 otherwise).
7710
+ */
7711
+ async setupVoiceTrustProduct(orgUuid, legalEntityUuid, product, data) {
7712
+ return this.fetch(
7713
+ `o/${orgUuid}/legal-entities/${legalEntityUuid}/trust-products/${product}`,
7714
+ { method: "POST", body: JSON.stringify(data) }
7715
+ );
7716
+ }
7717
+ /**
7718
+ * Brand detail with live registration-workflow state (`workflowStatus`,
7719
+ * `pendingSampleMessages`) for the sample-approval step.
7720
+ */
7721
+ async getA2PBrand(orgUuid, brandUuid) {
7722
+ return this.fetch(`o/${orgUuid}/a2p-brands/${brandUuid}`);
7723
+ }
7656
7724
  /**
7657
7725
  * List the org's A2P brands (broker resources). The SMS-consent editor uses
7658
7726
  * this to pick which brand's consent config to edit.
@@ -7756,6 +7824,9 @@ var OrgApi = class extends BaseApiClient {
7756
7824
  );
7757
7825
  }
7758
7826
  };
7827
+ function businessProfilePath(orgUuid, legalEntityUuid) {
7828
+ return legalEntityUuid ? `o/${orgUuid}/legal-entities/${legalEntityUuid}/business-profile` : `o/${orgUuid}/business-profile`;
7829
+ }
7759
7830
 
7760
7831
  // src/api/oauth.ts
7761
7832
  function getOAuthPath(providerSlug, action) {
@@ -9048,11 +9119,11 @@ var SubscriptionsApi = class extends BaseApiClient {
9048
9119
  * customer, and subscription are created on payment by the checkout
9049
9120
  * completion handler.
9050
9121
  */
9051
- async createCheckoutSession(productId, planPeriod = "month") {
9122
+ async createCheckoutSession(productId, planPeriod = "month", options = {}) {
9052
9123
  return this.fetch(`subscriptions/checkout-session`, {
9053
9124
  method: "POST",
9054
9125
  credentials: "include",
9055
- body: JSON.stringify({ productId, planPeriod }),
9126
+ body: JSON.stringify({ productId, planPeriod, ...options }),
9056
9127
  headers: { "Content-Type": "application/json" }
9057
9128
  });
9058
9129
  }
@@ -9109,12 +9180,15 @@ var SubscriptionsApi = class extends BaseApiClient {
9109
9180
  return this.fetch(`subscriptions/${subscriptionId}/items`);
9110
9181
  }
9111
9182
  /** Purchase extra credits on a subscription (org-level). */
9112
- async purchaseCredits(subscriptionId, amountCents) {
9183
+ async purchaseCredits(subscriptionId, amountCents, idempotencyKey = crypto.randomUUID()) {
9113
9184
  return this.fetch(`subscriptions/${subscriptionId}/purchase-credits`, {
9114
9185
  method: "POST",
9115
9186
  credentials: "include",
9116
9187
  body: JSON.stringify({ amount_cents: amountCents }),
9117
- headers: { "Content-Type": "application/json" }
9188
+ headers: {
9189
+ "Content-Type": "application/json",
9190
+ "Idempotency-Key": idempotencyKey
9191
+ }
9118
9192
  });
9119
9193
  }
9120
9194
  };
@@ -9257,6 +9331,13 @@ var CustomersApi = class extends BaseApiClient {
9257
9331
  async getMyCustomerInvoices(uuid) {
9258
9332
  return this.fetch(`customers/${uuid}/invoices`);
9259
9333
  }
9334
+ async createMyCustomerPortalSession(uuid, returnUrl) {
9335
+ return this.fetch(`customers/${uuid}/stripe/portal-session`, {
9336
+ method: "POST",
9337
+ body: JSON.stringify({ returnUrl }),
9338
+ headers: { "Content-Type": "application/json" }
9339
+ });
9340
+ }
9260
9341
  async updateMyCustomer(uuid, data) {
9261
9342
  return this.fetch(`customers/${uuid}`, {
9262
9343
  method: "PUT",
@@ -9274,7 +9355,8 @@ var CustomersApi = class extends BaseApiClient {
9274
9355
  async attachMyCustomerPaymentMethod(uuid, paymentMethodId, setAsDefault = false) {
9275
9356
  return this.fetch(`customers/${uuid}/stripe/payment-methods/${paymentMethodId}/attach`, {
9276
9357
  method: "POST",
9277
- body: JSON.stringify({ setAsDefault })
9358
+ body: JSON.stringify({ setAsDefault }),
9359
+ headers: { "Content-Type": "application/json" }
9278
9360
  });
9279
9361
  }
9280
9362
  async detachMyCustomerPaymentMethod(uuid, paymentMethodId) {
@@ -12406,6 +12488,7 @@ function bindCustomersMethods(target, customers) {
12406
12488
  target.getMyCustomerAccounts = customers.getMyCustomerAccounts.bind(customers);
12407
12489
  target.getMyCustomerSubscriptions = customers.getMyCustomerSubscriptions.bind(customers);
12408
12490
  target.getMyCustomerInvoices = customers.getMyCustomerInvoices.bind(customers);
12491
+ target.createMyCustomerPortalSession = customers.createMyCustomerPortalSession.bind(customers);
12409
12492
  target.updateMyCustomer = customers.updateMyCustomer.bind(customers);
12410
12493
  target.createMyCustomerSetupIntent = customers.createMyCustomerSetupIntent.bind(customers);
12411
12494
  target.getMyCustomerPaymentMethods = customers.getMyCustomerPaymentMethods.bind(customers);
@@ -13392,6 +13475,7 @@ var GravityRailClient = class {
13392
13475
  getMyCustomerAccounts;
13393
13476
  getMyCustomerSubscriptions;
13394
13477
  getMyCustomerInvoices;
13478
+ createMyCustomerPortalSession;
13395
13479
  updateMyCustomer;
13396
13480
  createMyCustomerSetupIntent;
13397
13481
  getMyCustomerPaymentMethods;