@gravity-rail/sdk 3.1.0 → 4.0.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.
Files changed (38) hide show
  1. package/README.md +16 -1
  2. package/dist/{chat-interaction-DwH4z1qk.d.ts → chat-interaction-DXgKjFqZ.d.cts} +497 -523
  3. package/dist/{chat-interaction-ClNfn1UV.d.cts → chat-interaction-a7U-tHfQ.d.ts} +497 -523
  4. package/dist/{chunk-ANVLMZLD.js → chunk-WHRIIBJ4.js} +182 -145
  5. package/dist/chunk-WHRIIBJ4.js.map +1 -0
  6. package/dist/{chunk-RLFS7O2L.js → chunk-ZLF3N3ZD.js} +183 -81
  7. package/dist/chunk-ZLF3N3ZD.js.map +1 -0
  8. package/dist/helpers.cjs.map +1 -1
  9. package/dist/helpers.d.cts +2 -2
  10. package/dist/helpers.d.ts +2 -2
  11. package/dist/helpers.js +1 -1
  12. package/dist/index.cjs +340 -221
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.d.cts +6 -6
  15. package/dist/index.d.ts +6 -6
  16. package/dist/index.js +2 -2
  17. package/dist/index.js.map +1 -1
  18. package/dist/internal.cjs +368 -225
  19. package/dist/internal.cjs.map +1 -1
  20. package/dist/internal.d.cts +45 -9
  21. package/dist/internal.d.ts +45 -9
  22. package/dist/internal.js +14 -6
  23. package/dist/internal.js.map +1 -1
  24. package/dist/{member-import-IN06xJrR.d.cts → member-import-BHtOru8g.d.cts} +1 -1
  25. package/dist/{member-import-D-_eJBE7.d.ts → member-import-VOLKR5dY.d.ts} +1 -1
  26. package/dist/{path-D_KPlBIr.d.cts → path-B3b3_El9.d.cts} +36 -18
  27. package/dist/{path-D4S8xYyo.d.ts → path-CUY-Iw70.d.ts} +36 -18
  28. package/dist/schemas.cjs +2 -4
  29. package/dist/schemas.cjs.map +1 -1
  30. package/dist/schemas.d.cts +21 -22
  31. package/dist/schemas.d.ts +21 -22
  32. package/dist/schemas.js +2 -4
  33. package/dist/schemas.js.map +1 -1
  34. package/dist/{tasks-C8sHnwH5.d.cts → tasks-CgptqCsN.d.cts} +17 -48
  35. package/dist/{tasks-C8sHnwH5.d.ts → tasks-CgptqCsN.d.ts} +17 -48
  36. package/package.json +3 -3
  37. package/dist/chunk-ANVLMZLD.js.map +0 -1
  38. package/dist/chunk-RLFS7O2L.js.map +0 -1
package/dist/internal.cjs CHANGED
@@ -44,6 +44,7 @@ __export(internal_exports, {
44
44
  ApiError: () => ApiError,
45
45
  ApiKeysApi: () => ApiKeysApi,
46
46
  AppConnectionsApi: () => AppConnectionsApi,
47
+ AppLinksApi: () => AppLinksApi,
47
48
  AppsApi: () => AppsApi,
48
49
  AssignmentsApi: () => AssignmentsApi,
49
50
  AttendeeResponseStatus: () => AttendeeResponseStatus,
@@ -90,7 +91,6 @@ __export(internal_exports, {
90
91
  CustomerActivityReviewOutcome: () => CustomerActivityReviewOutcome,
91
92
  CustomerActivitySeverity: () => CustomerActivitySeverity,
92
93
  CustomerActivitySlaThresholdSource: () => CustomerActivitySlaThresholdSource,
93
- CustomersApi: () => CustomersApi,
94
94
  DEFAULT_AGENT_CHAT_MODEL: () => DEFAULT_AGENT_CHAT_MODEL,
95
95
  DEFAULT_AGENT_REALTIME_MODEL: () => DEFAULT_AGENT_REALTIME_MODEL,
96
96
  DEFAULT_AGENT_REALTIME_MODEL_CONFIG: () => DEFAULT_AGENT_REALTIME_MODEL_CONFIG,
@@ -130,6 +130,7 @@ __export(internal_exports, {
130
130
  HubspotApi: () => HubspotApi,
131
131
  ImportReadinessIssueCode: () => ImportReadinessIssueCode,
132
132
  ImportReadinessIssueResourceType: () => ImportReadinessIssueResourceType,
133
+ ImportReadinessResponseCapCutResourceTypesItem: () => ImportReadinessResponseCapCutResourceTypesItem,
133
134
  ImportSkippedRuleResourceGroupResourceType: () => ImportSkippedRuleResourceGroupResourceType,
134
135
  ImportSkippedRuleResponseNeededResourceTypesItem: () => ImportSkippedRuleResponseNeededResourceTypesItem,
135
136
  ImportSkippedRuleResponseParentKind: () => ImportSkippedRuleResponseParentKind,
@@ -178,6 +179,8 @@ __export(internal_exports, {
178
179
  OrgApi: () => OrgApi,
179
180
  OrgFeature: () => OrgFeature,
180
181
  OrganizationAddonResponseScope: () => OrganizationAddonResponseScope,
182
+ OrganizationBillingApi: () => OrganizationBillingApi,
183
+ OrganizationClassification: () => OrganizationClassification,
181
184
  PERMISSION_ADMIN: () => PERMISSION_ADMIN,
182
185
  PERMISSION_CREATE: () => PERMISSION_CREATE,
183
186
  PERMISSION_DELETE: () => PERMISSION_DELETE,
@@ -299,6 +302,7 @@ __export(internal_exports, {
299
302
  bindActivityMethods: () => bindActivityMethods,
300
303
  bindAgentTasksMethods: () => bindAgentTasksMethods,
301
304
  bindAgentsMethods: () => bindAgentsMethods,
305
+ bindAppLinksMethods: () => bindAppLinksMethods,
302
306
  bindAppsMethods: () => bindAppsMethods,
303
307
  bindAuthMethods: () => bindAuthMethods,
304
308
  bindBillingMethods: () => bindBillingMethods,
@@ -307,7 +311,6 @@ __export(internal_exports, {
307
311
  bindCallsMethods: () => bindCallsMethods,
308
312
  bindChatsMethods: () => bindChatsMethods,
309
313
  bindCommunicationsMethods: () => bindCommunicationsMethods,
310
- bindCustomersMethods: () => bindCustomersMethods,
311
314
  bindDashboardsMethods: () => bindDashboardsMethods,
312
315
  bindDataReportsMethods: () => bindDataReportsMethods,
313
316
  bindDataTypesMethods: () => bindDataTypesMethods,
@@ -324,6 +327,7 @@ __export(internal_exports, {
324
327
  bindMotdMethods: () => bindMotdMethods,
325
328
  bindOperatorMethods: () => bindOperatorMethods,
326
329
  bindOrgMethods: () => bindOrgMethods,
330
+ bindOrganizationBillingMethods: () => bindOrganizationBillingMethods,
327
331
  bindPersonasMethods: () => bindPersonasMethods,
328
332
  bindProjectsMethods: () => bindProjectsMethods,
329
333
  bindPromptsMethods: () => bindPromptsMethods,
@@ -718,7 +722,6 @@ var EventRuleActionType = /* @__PURE__ */ ((EventRuleActionType2) => {
718
722
  EventRuleActionType2["MEMBER_NOTIFY_ACTION"] = "member:notify";
719
723
  EventRuleActionType2["MEMBER_LABEL_ACTION"] = "member:label";
720
724
  EventRuleActionType2["MEMBER_UPSERT"] = "member:upsert";
721
- EventRuleActionType2["SEND_WEBHOOK"] = "webhook:send";
722
725
  EventRuleActionType2["SWITCH_TASK_ACTION"] = "task:switch";
723
726
  EventRuleActionType2["ASSISTANT_MESSAGE"] = "assistant:message";
724
727
  EventRuleActionType2["FORM_FIELD_UPDATE"] = "form:update_field";
@@ -1003,6 +1006,14 @@ var TTS_MODEL_DEEPGRAM_AURA_2 = "deepgram:tts:aura-2";
1003
1006
  var TTS_MODEL_AWS_POLLY_GENERATIVE = "aws:tts:polly-generative";
1004
1007
  var TTS_MODEL_AWS_POLLY_NEURAL = "aws:tts:polly-neural";
1005
1008
 
1009
+ // src/types/generated/organization_billing.ts
1010
+ var OrganizationClassification = {
1011
+ commercial: "commercial",
1012
+ internal: "internal",
1013
+ demo: "demo",
1014
+ promo: "promo"
1015
+ };
1016
+
1006
1017
  // src/types/pids-types.ts
1007
1018
  var PIDS_DISPOSITIONS = ["true_positive", "false_positive", "needs_more_context"];
1008
1019
  var PIDS_SOURCES = ["scheduled", "backfill", "pre_llm"];
@@ -2233,6 +2244,14 @@ var ImportReadinessIssueResourceType = {
2233
2244
  app_connection: "app_connection",
2234
2245
  site: "site"
2235
2246
  };
2247
+ var ImportReadinessResponseCapCutResourceTypesItem = {
2248
+ phone: "phone",
2249
+ inbox: "inbox",
2250
+ workflow: "workflow",
2251
+ routine: "routine",
2252
+ app_connection: "app_connection",
2253
+ site: "site"
2254
+ };
2236
2255
  var ImportSkippedRuleResourceGroupResourceType = {
2237
2256
  phone: "phone",
2238
2257
  inbox: "inbox",
@@ -2948,18 +2967,18 @@ var SCOPES = {
2948
2967
  "webhooks:read": {
2949
2968
  name: "webhooks:read",
2950
2969
  category: "webhooks" /* WEBHOOKS */,
2951
- description: "View webhook logs"
2970
+ description: "View the organization webhook endpoints that cover this workspace"
2952
2971
  },
2953
2972
  "webhooks:write": {
2954
2973
  name: "webhooks:write",
2955
2974
  category: "webhooks" /* WEBHOOKS */,
2956
- description: "Configure webhooks",
2975
+ description: "Legacy webhook scope; grants no write operation (includes webhooks:read)",
2957
2976
  implies: ["webhooks:read"]
2958
2977
  },
2959
2978
  "webhooks:admin": {
2960
2979
  name: "webhooks:admin",
2961
2980
  category: "webhooks" /* WEBHOOKS */,
2962
- description: "Delete webhooks",
2981
+ description: "Legacy webhook scope; grants no write operation (includes webhooks:read)",
2963
2982
  implies: ["webhooks:write"]
2964
2983
  },
2965
2984
  "webhooks:raw": {
@@ -3264,21 +3283,20 @@ function parseOrgAuthChallenge(wwwAuthenticate) {
3264
3283
  if (!wwwAuthenticate.includes('realm="org"')) return null;
3265
3284
  const orgUuidMatch = wwwAuthenticate.match(/org_uuid="([^"]+)"/);
3266
3285
  const authUrlMatch = wwwAuthenticate.match(/auth_url="([^"]+)"/);
3286
+ const acrValues = wwwAuthenticate.match(/acr_values="([^"]*)"/)?.[1]?.trim().split(/\s+/).filter(Boolean);
3267
3287
  if (!orgUuidMatch?.[1] || !authUrlMatch?.[1]) {
3268
3288
  console.warn("Invalid org auth challenge header: missing required fields");
3269
3289
  return null;
3270
3290
  }
3271
3291
  return {
3272
3292
  orgUuid: orgUuidMatch[1],
3273
- authUrl: authUrlMatch[1]
3293
+ authUrl: authUrlMatch[1],
3294
+ ...acrValues?.length ? { acrValues } : {}
3274
3295
  };
3275
3296
  }
3276
- function orgAuthHeaderName(token) {
3277
- return token.startsWith("gr_sess_") ? "X-Org-Session" : "X-Org-Token";
3278
- }
3279
3297
  function setOrgAuthHeader(headers, token) {
3280
3298
  if (!token) return;
3281
- headers.set(orgAuthHeaderName(token), token);
3299
+ headers.set("X-Org-Session", token);
3282
3300
  }
3283
3301
  var BaseApiClient = class {
3284
3302
  baseUrl;
@@ -3289,13 +3307,13 @@ var BaseApiClient = class {
3289
3307
  enhancedAuthInProgress = null;
3290
3308
  orgAuthHandler;
3291
3309
  orgAuthInProgress = null;
3310
+ orgSessionRevision = 0;
3311
+ orgSessionRejectionHandler;
3292
3312
  orgSession;
3293
3313
  /**
3294
- * The org_uuid that issued the current org auth credential. Tracked so we can detect
3295
- * a 401 challenge from a *different* org and re-fire the handler — the
3296
- * credential is opaque to the client, so without this the original guard
3297
- * `!this.orgSession` would prevent re-auth across orgs and surface as a silent
3298
- * 401 in multi-org CLI workflows.
3314
+ * Optional issuer context supplied with an opaque credential. A handler
3315
+ * cannot complete a challenge with a session explicitly bound to another org.
3316
+ * The server remains responsible for validating the credential itself.
3299
3317
  */
3300
3318
  orgSessionOrgUuid;
3301
3319
  constructor(apiKey, baseUrl, customFetch) {
@@ -3330,24 +3348,25 @@ var BaseApiClient = class {
3330
3348
  }
3331
3349
  /**
3332
3350
  * Set the opaque org session credential a bearer client sends as `X-Org-Session`.
3333
- * Opaque gr_sess_ values use X-Org-Session. Legacy orgToken JWE values still
3334
- * use X-Org-Token through setOrgToken() during the migration window.
3351
+ * Only opaque `gr_sess_` credentials are supported. A legacy org token
3352
+ * raises an error; sign in to the organization again to obtain a session.
3353
+ * Pass `undefined` to clear the session.
3335
3354
  *
3336
- * `orgUuid` is the org that issued the credential; passing it lets the 401
3337
- * handler detect a stale session when a subsequent request targets a
3338
- * different org and re-fire the org-auth handler instead of silently
3339
- * 401-ing. Callers without that context (legacy / unknown) may omit it.
3355
+ * `orgUuid` is the org that issued the credential. When supplied by an
3356
+ * org-auth handler, it must match the challenge the handler completes.
3357
+ * Callers without that context may omit it. Any rejected credential can
3358
+ * trigger one reauthentication attempt, including for the same org.
3340
3359
  */
3341
3360
  setOrgSession(session, orgUuid) {
3361
+ if (session !== void 0 && !/^gr_sess_[A-Za-z0-9_-]+$/.test(session)) {
3362
+ throw new Error(
3363
+ "Unsupported organization session. Sign in again to obtain an opaque gr_sess_ credential."
3364
+ );
3365
+ }
3366
+ this.orgSessionRejectionHandler = void 0;
3342
3367
  this.orgSession = session;
3343
3368
  this.orgSessionOrgUuid = session ? orgUuid : void 0;
3344
- }
3345
- /**
3346
- * @deprecated Legacy compatibility for stateless orgToken JWE credentials.
3347
- * Prefer setOrgSession() for opaque org browser sessions.
3348
- */
3349
- setOrgToken(token, orgUuid) {
3350
- this.setOrgSession(token, orgUuid);
3369
+ this.orgSessionRevision += 1;
3351
3370
  }
3352
3371
  /**
3353
3372
  * The `credentials` a request carries: none for a bearer client (the fetch
@@ -3358,33 +3377,99 @@ var BaseApiClient = class {
3358
3377
  }
3359
3378
  /**
3360
3379
  * Run the org-auth handler once for concurrent challenges. A bearer client's
3361
- * handler sets the org session with `setOrgSession`; a same-origin session's
3380
+ * handler returns a candidate; a same-origin session's
3362
3381
  * handler leaves an httpOnly org-session cookie on the page's origin instead,
3363
3382
  * which the retry presents. A bearer client whose handler issued nothing has
3364
3383
  * nothing to retry with.
3365
3384
  */
3366
- async answerOrgAuthChallenge(orgAuthInfo) {
3385
+ async answerOrgAuthChallenge(info, presented, requestRevision) {
3367
3386
  const handler = this.orgAuthHandler;
3368
- if (!handler) return;
3369
- if (!this.orgAuthInProgress) {
3370
- this.orgAuthInProgress = (async () => {
3371
- try {
3372
- await handler(orgAuthInfo);
3373
- } finally {
3374
- this.orgAuthInProgress = null;
3375
- }
3376
- })();
3387
+ if (!handler) throw new ApiError("Organization authentication handler is unavailable", 401);
3388
+ if (this.orgAuthInProgress) {
3389
+ if (this.orgAuthInProgress.orgUuid !== info.orgUuid || this.orgAuthInProgress.requestRevision !== requestRevision) {
3390
+ throw new ApiError(
3391
+ "Organization authentication context changed. Retry the request.",
3392
+ 401
3393
+ );
3394
+ }
3395
+ return this.orgAuthInProgress.promise;
3377
3396
  }
3378
- await this.orgAuthInProgress;
3379
- if (this.orgSession) {
3380
- this.orgSessionOrgUuid = orgAuthInfo.orgUuid;
3381
- return;
3397
+ if (this.orgSessionRevision !== requestRevision) {
3398
+ throw new ApiError("Organization authentication context changed. Retry the request.", 401);
3382
3399
  }
3383
- if (this.apiKey) {
3384
- throw new ApiError("Organization authentication did not issue a session", 401);
3400
+ this.clearOrgSessionIfCurrent(presented);
3401
+ const attemptRevision = this.orgSessionRevision;
3402
+ const promise = Promise.resolve().then(() => handler(info)).then((candidate) => {
3403
+ if (this.orgSessionRevision !== attemptRevision) {
3404
+ throw new ApiError(
3405
+ "Organization authentication context changed. Retry the request.",
3406
+ 401
3407
+ );
3408
+ }
3409
+ if (candidate === void 0) {
3410
+ if (this.apiKey) {
3411
+ throw new ApiError(
3412
+ "Organization authentication must return a session candidate",
3413
+ 401
3414
+ );
3415
+ }
3416
+ return "cookie";
3417
+ }
3418
+ if (!candidate || typeof candidate.session !== "string" || candidate.source !== "cache" && candidate.source !== "new") {
3419
+ throw new ApiError(
3420
+ "Organization authentication returned an invalid session candidate",
3421
+ 401
3422
+ );
3423
+ }
3424
+ if (candidate.orgUuid !== info.orgUuid) {
3425
+ throw new ApiError(
3426
+ "Organization authentication issued a session for another organization",
3427
+ 401
3428
+ );
3429
+ }
3430
+ if (candidate.source === "cache" && info.sessionRejected) {
3431
+ throw new ApiError(
3432
+ "Organization authentication requires a newly issued session after rejection",
3433
+ 401
3434
+ );
3435
+ }
3436
+ this.setOrgSession(candidate.session, candidate.orgUuid);
3437
+ let rejected = false;
3438
+ this.orgSessionRejectionHandler = () => {
3439
+ if (rejected) return;
3440
+ rejected = true;
3441
+ candidate.onRejected?.();
3442
+ };
3443
+ return candidate.source;
3444
+ }).finally(() => {
3445
+ if (this.orgAuthInProgress?.promise === promise) this.orgAuthInProgress = null;
3446
+ });
3447
+ this.orgAuthInProgress = { orgUuid: info.orgUuid, requestRevision, promise };
3448
+ return promise;
3449
+ }
3450
+ assertOrgAuthContext(orgUuid) {
3451
+ if (this.orgSession && this.orgSessionOrgUuid !== orgUuid || this.apiKey && !this.orgSession) {
3452
+ throw new ApiError("Organization authentication context changed. Retry the request.", 401);
3385
3453
  }
3386
3454
  }
3387
- async fetch(endpoint, options, orgAuthRetry = false) {
3455
+ notifyOrgSessionRejected(presented, callback) {
3456
+ try {
3457
+ callback?.();
3458
+ } catch {
3459
+ this.clearOrgSessionIfCurrent(presented);
3460
+ throw new ApiError("Could not discard rejected organization session", 401);
3461
+ }
3462
+ }
3463
+ hasNewerOrgSession(presented, orgUuid) {
3464
+ return Boolean(
3465
+ presented && this.orgSession && this.orgSession !== presented && this.orgSessionOrgUuid === orgUuid
3466
+ );
3467
+ }
3468
+ clearOrgSessionIfCurrent(expected) {
3469
+ if (this.orgSession !== expected || this.orgSession === void 0) return;
3470
+ this.setOrgSession(void 0);
3471
+ }
3472
+ async fetch(endpoint, options, orgAuthRetriesRemaining = this.apiKey && !this.orgSession ? 2 : 1, enhancedAuthRetry = false) {
3388
3473
  try {
3389
3474
  const headers = new Headers({
3390
3475
  // Don't set Content-Type for FormData — the browser must set it
@@ -3396,6 +3481,10 @@ var BaseApiClient = class {
3396
3481
  headers.set("Authorization", `Bearer ${this.apiKey}`);
3397
3482
  }
3398
3483
  setOrgAuthHeader(headers, this.orgSession);
3484
+ const presentedOrgSession = headers.get("X-Org-Session");
3485
+ const requestOrgRevision = this.orgSessionRevision;
3486
+ const presentedOrgUuid = this.orgSessionOrgUuid;
3487
+ const rejectionHandler = this.orgSessionRejectionHandler;
3399
3488
  const fullUrl = `${this.baseUrl}/api/v2/${endpoint}`;
3400
3489
  const response = await this.fetchFunction(fullUrl, {
3401
3490
  ...options,
@@ -3404,7 +3493,7 @@ var BaseApiClient = class {
3404
3493
  headers
3405
3494
  });
3406
3495
  if (!response.ok) {
3407
- if (response.status === 401 && requiresStepUpAuth(response.headers.get("WWW-Authenticate")) && this.enhancedAuthHandler) {
3496
+ if (response.status === 401 && !enhancedAuthRetry && requiresStepUpAuth(response.headers.get("WWW-Authenticate")) && this.enhancedAuthHandler) {
3408
3497
  if (this.enhancedAuthInProgress) {
3409
3498
  await this.enhancedAuthInProgress;
3410
3499
  } else {
@@ -3416,28 +3505,36 @@ var BaseApiClient = class {
3416
3505
  this.enhancedAuthInProgress = null;
3417
3506
  }
3418
3507
  }
3419
- try {
3420
- return await this.fetch(endpoint, options);
3421
- } catch (retryError) {
3422
- this.orgSession = void 0;
3423
- this.orgSessionOrgUuid = void 0;
3424
- throw retryError;
3425
- }
3508
+ return await this.fetch(endpoint, options, orgAuthRetriesRemaining, true);
3426
3509
  }
3427
3510
  if (response.status === 401) {
3428
3511
  const orgAuthInfo = parseOrgAuthChallenge(response.headers.get("WWW-Authenticate"));
3429
- if (orgAuthInfo && this.orgSession && this.orgSessionOrgUuid && this.orgSessionOrgUuid !== orgAuthInfo.orgUuid) {
3430
- this.orgSession = void 0;
3431
- this.orgSessionOrgUuid = void 0;
3512
+ if (orgAuthInfo && presentedOrgSession) {
3513
+ orgAuthInfo.sessionRejected = true;
3514
+ if (presentedOrgUuid === orgAuthInfo.orgUuid) {
3515
+ this.notifyOrgSessionRejected(presentedOrgSession, rejectionHandler);
3516
+ }
3432
3517
  }
3433
- if (orgAuthInfo && !this.orgSession && !orgAuthRetry && this.orgAuthHandler) {
3434
- await this.answerOrgAuthChallenge(orgAuthInfo);
3435
- try {
3436
- return await this.fetch(endpoint, options, true);
3437
- } catch (retryError) {
3438
- this.orgSession = void 0;
3439
- this.orgSessionOrgUuid = void 0;
3440
- throw retryError;
3518
+ if (orgAuthInfo && orgAuthRetriesRemaining > 0 && this.orgAuthHandler) {
3519
+ let nextOrgRetries = orgAuthRetriesRemaining - 1;
3520
+ if (!this.hasNewerOrgSession(presentedOrgSession, orgAuthInfo.orgUuid)) {
3521
+ const completion = await this.answerOrgAuthChallenge(
3522
+ orgAuthInfo,
3523
+ presentedOrgSession,
3524
+ requestOrgRevision
3525
+ );
3526
+ if (completion !== "cache") nextOrgRetries = 0;
3527
+ }
3528
+ this.assertOrgAuthContext(orgAuthInfo.orgUuid);
3529
+ return await this.fetch(endpoint, options, nextOrgRetries, enhancedAuthRetry);
3530
+ }
3531
+ if (orgAuthInfo) {
3532
+ this.clearOrgSessionIfCurrent(presentedOrgSession);
3533
+ if (orgAuthInfo.acrValues?.includes("urn:gravity:mfa")) {
3534
+ throw new ApiError(
3535
+ "Organization sign-in still requires MFA. Complete MFA with your account or configured identity provider. For SSO, verify that the provider requires MFA and returns verified method evidence.",
3536
+ 401
3537
+ );
3441
3538
  }
3442
3539
  }
3443
3540
  }
@@ -3499,7 +3596,7 @@ ${formattedErrors}`, response.status);
3499
3596
  throw error;
3500
3597
  }
3501
3598
  }
3502
- async fetchRaw(endpoint, options, allowedErrorStatuses = [], orgAuthRetry = false) {
3599
+ async fetchRaw(endpoint, options, allowedErrorStatuses = [], orgAuthRetriesRemaining = this.apiKey && !this.orgSession ? 2 : 1, enhancedAuthRetry = false) {
3503
3600
  try {
3504
3601
  const headers = new Headers({
3505
3602
  ...options?.headers || {}
@@ -3511,6 +3608,10 @@ ${formattedErrors}`, response.status);
3511
3608
  headers.set("Authorization", `Bearer ${this.apiKey}`);
3512
3609
  }
3513
3610
  setOrgAuthHeader(headers, this.orgSession);
3611
+ const presentedOrgSession = headers.get("X-Org-Session");
3612
+ const requestOrgRevision = this.orgSessionRevision;
3613
+ const presentedOrgUuid = this.orgSessionOrgUuid;
3614
+ const rejectionHandler = this.orgSessionRejectionHandler;
3514
3615
  const response = await this.fetchFunction(`${this.baseUrl}/api/v2/${endpoint}`, {
3515
3616
  ...options,
3516
3617
  ...this.credentialsInit(),
@@ -3518,7 +3619,7 @@ ${formattedErrors}`, response.status);
3518
3619
  headers
3519
3620
  });
3520
3621
  if (!response.ok) {
3521
- if (response.status === 401 && requiresStepUpAuth(response.headers.get("WWW-Authenticate")) && this.enhancedAuthHandler) {
3622
+ if (response.status === 401 && !enhancedAuthRetry && requiresStepUpAuth(response.headers.get("WWW-Authenticate")) && this.enhancedAuthHandler) {
3522
3623
  if (this.enhancedAuthInProgress) {
3523
3624
  await this.enhancedAuthInProgress;
3524
3625
  } else {
@@ -3530,28 +3631,48 @@ ${formattedErrors}`, response.status);
3530
3631
  this.enhancedAuthInProgress = null;
3531
3632
  }
3532
3633
  }
3533
- try {
3534
- return await this.fetchRaw(endpoint, options, allowedErrorStatuses);
3535
- } catch (retryError) {
3536
- this.orgSession = void 0;
3537
- this.orgSessionOrgUuid = void 0;
3538
- throw retryError;
3539
- }
3634
+ return await this.fetchRaw(
3635
+ endpoint,
3636
+ options,
3637
+ allowedErrorStatuses,
3638
+ orgAuthRetriesRemaining,
3639
+ true
3640
+ );
3540
3641
  }
3541
3642
  if (response.status === 401) {
3542
3643
  const orgAuthInfo = parseOrgAuthChallenge(response.headers.get("WWW-Authenticate"));
3543
- if (orgAuthInfo && this.orgSession && this.orgSessionOrgUuid && this.orgSessionOrgUuid !== orgAuthInfo.orgUuid) {
3544
- this.orgSession = void 0;
3545
- this.orgSessionOrgUuid = void 0;
3644
+ if (orgAuthInfo && presentedOrgSession) {
3645
+ orgAuthInfo.sessionRejected = true;
3646
+ if (presentedOrgUuid === orgAuthInfo.orgUuid) {
3647
+ this.notifyOrgSessionRejected(presentedOrgSession, rejectionHandler);
3648
+ }
3546
3649
  }
3547
- if (orgAuthInfo && !this.orgSession && !orgAuthRetry && this.orgAuthHandler) {
3548
- await this.answerOrgAuthChallenge(orgAuthInfo);
3549
- try {
3550
- return await this.fetchRaw(endpoint, options, allowedErrorStatuses, true);
3551
- } catch (retryError) {
3552
- this.orgSession = void 0;
3553
- this.orgSessionOrgUuid = void 0;
3554
- throw retryError;
3650
+ if (orgAuthInfo && orgAuthRetriesRemaining > 0 && this.orgAuthHandler) {
3651
+ let nextOrgRetries = orgAuthRetriesRemaining - 1;
3652
+ if (!this.hasNewerOrgSession(presentedOrgSession, orgAuthInfo.orgUuid)) {
3653
+ const completion = await this.answerOrgAuthChallenge(
3654
+ orgAuthInfo,
3655
+ presentedOrgSession,
3656
+ requestOrgRevision
3657
+ );
3658
+ if (completion !== "cache") nextOrgRetries = 0;
3659
+ }
3660
+ this.assertOrgAuthContext(orgAuthInfo.orgUuid);
3661
+ return await this.fetchRaw(
3662
+ endpoint,
3663
+ options,
3664
+ allowedErrorStatuses,
3665
+ nextOrgRetries,
3666
+ enhancedAuthRetry
3667
+ );
3668
+ }
3669
+ if (orgAuthInfo) {
3670
+ this.clearOrgSessionIfCurrent(presentedOrgSession);
3671
+ if (!allowedErrorStatuses.includes(401) && orgAuthInfo.acrValues?.includes("urn:gravity:mfa")) {
3672
+ throw new ApiError(
3673
+ "Organization sign-in still requires MFA. Complete MFA with your account or configured identity provider. For SSO, verify that the provider requires MFA and returns verified method evidence.",
3674
+ 401
3675
+ );
3555
3676
  }
3556
3677
  }
3557
3678
  }
@@ -4325,6 +4446,21 @@ var ApiKeysApi = class extends BaseApiClient {
4325
4446
  }
4326
4447
  };
4327
4448
 
4449
+ // src/api/app-links.ts
4450
+ var AppLinksApi = class extends BaseApiClient {
4451
+ /**
4452
+ * Resolve an App Link to the concrete chat it opens.
4453
+ *
4454
+ * `linkParams` is the `?with=&mode=&action=&channel=` suffix built from the
4455
+ * link's search params (an empty string when the link carries none). The
4456
+ * resolver re-runs the current session's workspace authorization; the
4457
+ * response is ids and closed-vocabulary enums only, never PHI.
4458
+ */
4459
+ async resolveAppLink(wid, linkParams = "") {
4460
+ return this.fetch(`w/${wid}/app-links/resolve${linkParams}`);
4461
+ }
4462
+ };
4463
+
4328
4464
  // src/api/apps.ts
4329
4465
  var AppsApi = class extends BaseApiClient {
4330
4466
  /**
@@ -6783,13 +6919,6 @@ var EventsApi = class extends BaseApiClient {
6783
6919
  method: "DELETE"
6784
6920
  });
6785
6921
  }
6786
- /** Send a one-off test webhook for an existing webhook event rule. */
6787
- async testWebhook(wid, id, request) {
6788
- return this.fetch(`w/${wid}/event-rules/${id}/test-webhook`, {
6789
- method: "POST",
6790
- body: JSON.stringify(request)
6791
- });
6792
- }
6793
6922
  /** Reorder event rules by specifying the desired rule ID sequence. */
6794
6923
  async reorderEventRules(wid, ruleIds) {
6795
6924
  return this.fetch(`w/${wid}/event-rules/reorder`, {
@@ -6797,19 +6926,6 @@ var EventsApi = class extends BaseApiClient {
6797
6926
  body: JSON.stringify(ruleIds)
6798
6927
  });
6799
6928
  }
6800
- /** List webhook logs with optional filtering by event type and success status. */
6801
- async getWebhookLogs(wid, options = {}) {
6802
- const params = new URLSearchParams();
6803
- if (options.page) params.append("page", options.page.toString());
6804
- if (options.pageSize) params.append("pageSize", options.pageSize.toString());
6805
- if (options.sortBy) params.append("sortBy", options.sortBy);
6806
- if (options.sortOrder) params.append("sortOrder", options.sortOrder);
6807
- if (options.eventType) params.append("eventType", options.eventType);
6808
- if (options.success !== void 0) params.append("success", options.success.toString());
6809
- return this.fetch(
6810
- `w/${wid}/webhook-logs${params.toString() ? `?${params.toString()}` : ""}`
6811
- );
6812
- }
6813
6929
  /** List event rule executions with cursor-based pagination and filtering. */
6814
6930
  async getRuleExecutions(wid, options = {}) {
6815
6931
  const params = new URLSearchParams();
@@ -9837,27 +9953,15 @@ var OrgApi = class extends BaseApiClient {
9837
9953
  method: "DELETE"
9838
9954
  });
9839
9955
  }
9840
- /**
9841
- * Get the billing customer and this organization's billable subscription.
9842
- *
9843
- * `subscriptionId` is the org-scoped row — never pick the customer's
9844
- * newest subscription from the list endpoint. One customer can bill many
9845
- * organizations.
9846
- *
9847
- * Returns the generated `OrgBillingCustomerResponse` — the contract the
9848
- * route actually emits, `audiences` included. The hand-written mirror that
9849
- * used to live here listed four fields and silently dropped `audiences`,
9850
- * so callers could not see the commercial roles they hold (GRA-8792).
9851
- * Regenerate the shape (`yarn generate:types`) rather than re-declaring it.
9852
- */
9853
- async getOrgBillingCustomer(orgIdOrUuid) {
9854
- return this.fetch(`o/${orgIdOrUuid}/billing-customer`);
9956
+ /** Current Organization billing access and billable subscription. */
9957
+ async getOrgBillingAccess(orgIdOrUuid) {
9958
+ return this.fetch(`o/${orgIdOrUuid}/billing-access`);
9855
9959
  }
9856
9960
  /**
9857
9961
  * Per-workspace usage for this organization's current credit window.
9858
9962
  *
9859
- * Requires a billing role on the organization's billing customer — the
9860
- * same gate `getOrgBillingCustomer().hasAccess` reports, and the one that
9963
+ * Requires Organization billing access, the
9964
+ * same gate `getOrgBillingAccess().hasAccess` reports, and the one that
9861
9965
  * decides whether the billing tab is shown at all.
9862
9966
  *
9863
9967
  * `creditsUsed` is a real organization-wide total or it is null; it is
@@ -9900,6 +10004,12 @@ var OrgApi = class extends BaseApiClient {
9900
10004
  body: JSON.stringify(data)
9901
10005
  });
9902
10006
  }
10007
+ async setOrganizationMemberBillingRole(orgUuid, memberId, billingRole) {
10008
+ return this.fetch(`o/${orgUuid}/members/${memberId}/billing-role`, {
10009
+ method: "PUT",
10010
+ body: JSON.stringify({ billingRole })
10011
+ });
10012
+ }
9903
10013
  /**
9904
10014
  * Remove a member from an organization.
9905
10015
  */
@@ -12355,6 +12465,24 @@ var ConnectionSyncApi = class extends BaseApiClient {
12355
12465
 
12356
12466
  // src/api/hubspot.ts
12357
12467
  var HubspotApi = class extends BaseApiClient {
12468
+ async bindHubspotCalendar(wid, calendarId, linkId) {
12469
+ return this.fetch(`w/${wid}/app-connections/hubspot/calendars/${calendarId}/binding`, {
12470
+ method: "PUT",
12471
+ body: JSON.stringify({ linkId })
12472
+ });
12473
+ }
12474
+ async unlinkHubspotCalendar(wid, calendarId) {
12475
+ return this.fetch(`w/${wid}/app-connections/hubspot/calendars/${calendarId}/binding`, {
12476
+ method: "DELETE"
12477
+ });
12478
+ }
12479
+ /** Import one page into native CalendarEvents. Does not book or send invitations. */
12480
+ async importHubspotCalendarEvents(wid, calendarId, eventTypeId) {
12481
+ return this.fetch(`w/${wid}/app-connections/hubspot/calendars/${calendarId}/events/sync`, {
12482
+ method: "POST",
12483
+ body: JSON.stringify({ eventTypeId })
12484
+ });
12485
+ }
12358
12486
  async getHubspotBookingReceipt(wid, meetingId) {
12359
12487
  return this.fetch(
12360
12488
  `w/${wid}/app-connections/hubspot/booking-deals/${encodeURIComponent(meetingId)}/receipt`
@@ -13171,18 +13299,32 @@ var SupportRequestsApi = class extends BaseApiClient {
13171
13299
  }
13172
13300
  };
13173
13301
 
13174
- // src/api/customers.ts
13175
- var CustomersApi = class extends BaseApiClient {
13176
- async getMyCustomers() {
13177
- return this.fetch("customers");
13302
+ // src/api/organization-billing.ts
13303
+ var OrganizationBillingApi = class extends BaseApiClient {
13304
+ async getOrganizationSubscription(orgUuid) {
13305
+ return this.fetch(`o/${orgUuid}/billing/subscription`);
13306
+ }
13307
+ async updateOrganizationCreditSettings(orgUuid, updates) {
13308
+ return this.fetch(`o/${orgUuid}/billing/subscription`, {
13309
+ method: "PUT",
13310
+ body: JSON.stringify(updates),
13311
+ headers: { "Content-Type": "application/json" }
13312
+ });
13178
13313
  }
13179
- async getMyCustomer(uuid) {
13180
- return this.fetch(`customers/${uuid}`);
13314
+ async purchaseOrganizationCredits(orgUuid, amountCents, idempotencyKey = crypto.randomUUID()) {
13315
+ return this.fetch(`o/${orgUuid}/billing/subscription/purchase-credits`, {
13316
+ method: "POST",
13317
+ body: JSON.stringify({ amountCents }),
13318
+ headers: { "Content-Type": "application/json", "Idempotency-Key": idempotencyKey }
13319
+ });
13320
+ }
13321
+ async getBillingOrganizations() {
13322
+ return this.fetch("o/billing-organizations");
13181
13323
  }
13182
- async getMyCustomerAccounts(uuid) {
13183
- return this.fetch(`customers/${uuid}/accounts`);
13324
+ async getOrganizationBilling(uuid) {
13325
+ return this.fetch(`o/${uuid}/billing`);
13184
13326
  }
13185
- async getMyCustomerSubscriptions(uuid, opts) {
13327
+ async getOrganizationBillingSubscriptions(uuid, opts) {
13186
13328
  const params = new URLSearchParams();
13187
13329
  if (opts?.status) params.set("status", opts.status);
13188
13330
  if (opts?.page !== void 0) params.set("page", String(opts.page));
@@ -13191,50 +13333,53 @@ var CustomersApi = class extends BaseApiClient {
13191
13333
  params.set("subscription_id", String(opts.subscriptionId));
13192
13334
  }
13193
13335
  const qs = params.toString();
13194
- return this.fetch(`customers/${uuid}/subscriptions${qs ? "?" + qs : ""}`);
13336
+ return this.fetch(`o/${uuid}/billing/subscriptions${qs ? "?" + qs : ""}`);
13195
13337
  }
13196
- async getMyCustomerInvoices(uuid) {
13197
- return this.fetch(`customers/${uuid}/invoices`);
13338
+ async getOrganizationInvoices(uuid) {
13339
+ return this.fetch(`o/${uuid}/billing/invoices`);
13198
13340
  }
13199
- async createMyCustomerPortalSession(uuid, returnUrl) {
13200
- return this.fetch(`customers/${uuid}/stripe/portal-session`, {
13341
+ async createOrganizationPortalSession(uuid, returnUrl) {
13342
+ return this.fetch(`o/${uuid}/billing/stripe/portal-session`, {
13201
13343
  method: "POST",
13202
13344
  body: JSON.stringify({ returnUrl }),
13203
13345
  headers: { "Content-Type": "application/json" }
13204
13346
  });
13205
13347
  }
13206
- async updateMyCustomer(uuid, data) {
13207
- return this.fetch(`customers/${uuid}`, {
13348
+ async updateOrganizationBilling(uuid, data) {
13349
+ return this.fetch(`o/${uuid}/billing`, {
13208
13350
  method: "PUT",
13209
13351
  body: JSON.stringify(data),
13210
13352
  headers: { "Content-Type": "application/json" }
13211
13353
  });
13212
13354
  }
13213
13355
  // ===== Payment Methods =====
13214
- async createMyCustomerSetupIntent(uuid) {
13215
- return this.fetch(`customers/${uuid}/stripe/setup-intent`, { method: "POST" });
13356
+ async createOrganizationSetupIntent(uuid) {
13357
+ return this.fetch(`o/${uuid}/billing/stripe/setup-intent`, {
13358
+ method: "POST",
13359
+ body: JSON.stringify({})
13360
+ });
13216
13361
  }
13217
- async getMyCustomerPaymentMethods(uuid) {
13218
- return this.fetch(`customers/${uuid}/stripe/payment-methods`);
13362
+ async getOrganizationPaymentMethods(uuid) {
13363
+ return this.fetch(`o/${uuid}/billing/stripe/payment-methods`);
13219
13364
  }
13220
- async attachMyCustomerPaymentMethod(uuid, paymentMethodId, setAsDefault = false) {
13221
- return this.fetch(`customers/${uuid}/stripe/payment-methods/${paymentMethodId}/attach`, {
13365
+ async attachOrganizationPaymentMethod(uuid, paymentMethodId, setAsDefault = false) {
13366
+ return this.fetch(`o/${uuid}/billing/stripe/payment-methods/${paymentMethodId}/attach`, {
13222
13367
  method: "POST",
13223
13368
  body: JSON.stringify({ setAsDefault }),
13224
13369
  headers: { "Content-Type": "application/json" }
13225
13370
  });
13226
13371
  }
13227
- async detachMyCustomerPaymentMethod(uuid, paymentMethodId) {
13228
- return this.fetch(`customers/${uuid}/stripe/payment-methods/${paymentMethodId}`, {
13372
+ async detachOrganizationPaymentMethod(uuid, paymentMethodId) {
13373
+ return this.fetch(`o/${uuid}/billing/stripe/payment-methods/${paymentMethodId}`, {
13229
13374
  method: "DELETE"
13230
13375
  });
13231
13376
  }
13232
- async setDefaultMyCustomerPaymentMethod(uuid, paymentMethodId) {
13233
- return this.fetch(`customers/${uuid}/stripe/payment-methods/${paymentMethodId}/set-default`, {
13377
+ async setDefaultOrganizationPaymentMethod(uuid, paymentMethodId) {
13378
+ return this.fetch(`o/${uuid}/billing/stripe/payment-methods/${paymentMethodId}/set-default`, {
13234
13379
  method: "PUT"
13235
13380
  });
13236
13381
  }
13237
- async getMyCustomerCreditGrants(uuid, opts) {
13382
+ async getOrganizationCreditGrants(uuid, opts) {
13238
13383
  const params = new URLSearchParams();
13239
13384
  if (opts?.subscriptionId !== void 0) {
13240
13385
  params.set("subscription_id", String(opts.subscriptionId));
@@ -13242,7 +13387,7 @@ var CustomersApi = class extends BaseApiClient {
13242
13387
  if (opts?.page !== void 0) params.set("page", String(opts.page));
13243
13388
  if (opts?.pageSize !== void 0) params.set("page_size", String(opts.pageSize));
13244
13389
  const qs = params.toString();
13245
- return this.fetch(`customers/${uuid}/credit-grants${qs ? "?" + qs : ""}`);
13390
+ return this.fetch(`o/${uuid}/billing/credit-grants${qs ? "?" + qs : ""}`);
13246
13391
  }
13247
13392
  };
13248
13393
 
@@ -13980,7 +14125,7 @@ var WorkflowsApi = class extends BaseApiClient {
13980
14125
  body.append("relativePath", relativePath);
13981
14126
  return this.fetch(`w/${wid}/workflows/${id}/knowledge/uploads`, { method: "POST", body });
13982
14127
  }
13983
- /** List all workflows in a workspace, optionally including archived ones. */
14128
+ /** List workflows by archived status; `archived: true` returns only archived Workflows. */
13984
14129
  async getWorkflows(wid, options = {}) {
13985
14130
  const params = new URLSearchParams();
13986
14131
  if (options.archived) params.set("archived", "true");
@@ -14932,8 +15077,8 @@ var WorkspacesApi = class extends BaseApiClient {
14932
15077
  *
14933
15078
  * `bindings` values are sent in the request body only. They are never
14934
15079
  * projected from a response and must never be logged: the point of a
14935
- * binding is that a webhook endpoint and a signing secret belong to ONE
14936
- * target workspace.
15080
+ * binding is that a phone number, inbox or Member belongs to ONE target
15081
+ * workspace.
14937
15082
  */
14938
15083
  /** Download a workspace export ZIP (``export.json`` + file blobs). */
14939
15084
  async exportWorkspaceZip(wid, workflowId, scope, exclude, options) {
@@ -14994,10 +15139,6 @@ var WorkspacesApi = class extends BaseApiClient {
14994
15139
  * Pass ``archive`` (the ZIP from ``exportWorkspaceZip``) to restore file
14995
15140
  * contents. ``exportData`` may be omitted when the ZIP contains it.
14996
15141
  *
14997
- * ``activateWebhookRules`` is safety-default false: imported
14998
- * ``webhook:send`` EventRules are force-disabled unless the operator
14999
- * opts in. An exported-inactive rule stays inactive either way.
15000
- *
15001
15142
  * With ``options.intent = 'template_reapply'`` this is the GUARDED apply.
15002
15143
  * It requires ``options.expectedPlanFingerprint`` — the digest a preview
15003
15144
  * returned — and answers 200 ``success``, 200 ``noop`` (the target already
@@ -15005,15 +15146,14 @@ var WorkspacesApi = class extends BaseApiClient {
15005
15146
  * ``stale_import_plan`` or 409 ``import_plan_refused``. Both 409s commit
15006
15147
  * nothing and carry the complete values-free ``planRows``.
15007
15148
  */
15008
- async importWorkspace(wid, exportData, importMappings, createNew, archive, activateWebhookRules, autoMap, options) {
15149
+ async importWorkspace(wid, exportData, importMappings, createNew, archive, autoMap, options) {
15009
15150
  if (archive) {
15010
15151
  return this.importWorkspaceZip(wid, archive, {
15011
15152
  ...options,
15012
15153
  exportData,
15013
15154
  importMappings,
15014
15155
  createNew,
15015
- autoMap,
15016
- activateWebhookRules
15156
+ autoMap
15017
15157
  });
15018
15158
  }
15019
15159
  if (!exportData) {
@@ -15025,9 +15165,6 @@ var WorkspacesApi = class extends BaseApiClient {
15025
15165
  createNew,
15026
15166
  ...planFields(options)
15027
15167
  };
15028
- if (activateWebhookRules) {
15029
- payload.activateWebhookRules = activateWebhookRules;
15030
- }
15031
15168
  if (autoMap) {
15032
15169
  payload.autoMap = autoMap;
15033
15170
  }
@@ -15053,25 +15190,17 @@ var WorkspacesApi = class extends BaseApiClient {
15053
15190
  *
15054
15191
  * `options.bindings` values are sent in the request body only. They are
15055
15192
  * never projected from a response and must never be logged: the point of a
15056
- * binding is that a webhook endpoint and a signing secret belong to ONE
15057
- * target workspace.
15193
+ * binding is that a phone number, inbox or Member belongs to ONE target
15194
+ * workspace.
15058
15195
  */
15059
15196
  async importWorkspaceZip(wid, archive, options) {
15060
- const {
15061
- exportData,
15062
- importMappings,
15063
- createNew,
15064
- autoMap,
15065
- activateWebhookRules,
15066
- ...planOptions
15067
- } = options ?? {};
15197
+ const { exportData, importMappings, createNew, autoMap, ...planOptions } = options ?? {};
15068
15198
  const payload = {
15069
15199
  importMappings: importMappings ?? {},
15070
15200
  createNew: createNew ?? {},
15071
15201
  ...planFields(planOptions)
15072
15202
  };
15073
15203
  if (exportData) payload.exportData = exportData;
15074
- if (activateWebhookRules) payload.activateWebhookRules = activateWebhookRules;
15075
15204
  if (autoMap) payload.autoMap = autoMap;
15076
15205
  const form = new FormData();
15077
15206
  form.append(
@@ -15250,6 +15379,7 @@ function createApiModules(apiKey, baseUrl, customFetch) {
15250
15379
  agents: new AgentsApi(apiKey, baseUrl, customFetch),
15251
15380
  aiModels: new AIModelsApi(apiKey, baseUrl, customFetch),
15252
15381
  apiKeys: new ApiKeysApi(apiKey, baseUrl, customFetch),
15382
+ appLinks: new AppLinksApi(apiKey, baseUrl, customFetch),
15253
15383
  apps: new AppsApi(apiKey, baseUrl, customFetch),
15254
15384
  assignments: new AssignmentsApi(apiKey, baseUrl, customFetch),
15255
15385
  auth: new AuthApi(apiKey, baseUrl, customFetch),
@@ -15260,7 +15390,7 @@ function createApiModules(apiKey, baseUrl, customFetch) {
15260
15390
  calls: new CallsApi(apiKey, baseUrl, customFetch),
15261
15391
  cel: new CELApi(apiKey, baseUrl, customFetch),
15262
15392
  chats: new ChatsApi(apiKey, baseUrl, customFetch),
15263
- customers: new CustomersApi(apiKey, baseUrl, customFetch),
15393
+ customers: new OrganizationBillingApi(apiKey, baseUrl, customFetch),
15264
15394
  resellers: new ResellersApi(apiKey, baseUrl, customFetch),
15265
15395
  customToolkits: new CustomToolkitsApi(apiKey, baseUrl, customFetch),
15266
15396
  dashboards: new DashboardsApi(apiKey, baseUrl, customFetch),
@@ -15817,6 +15947,9 @@ var WORKSPACE_METHOD_NAMES = [
15817
15947
  "getHubspotObjectProperties",
15818
15948
  "getHubspotReconciliationMatches",
15819
15949
  "getHubspotStatus",
15950
+ "bindHubspotCalendar",
15951
+ "unlinkHubspotCalendar",
15952
+ "importHubspotCalendarEvents",
15820
15953
  "getHubspotBookingReceipt",
15821
15954
  "releaseHubspotBookingAttempt",
15822
15955
  "getHubspotSyncLogs",
@@ -15983,7 +16116,6 @@ var WORKSPACE_METHOD_NAMES = [
15983
16116
  "getUsageDashboard",
15984
16117
  "getVariableRegistry",
15985
16118
  "getVoiceUsageReport",
15986
- "getWebhookLogs",
15987
16119
  "getWorkflow",
15988
16120
  "getWorkflowOpeningTurnConversionReport",
15989
16121
  "getWorkflowActivity",
@@ -16186,7 +16318,6 @@ var WORKSPACE_METHOD_NAMES = [
16186
16318
  "testMcpServerConnection",
16187
16319
  "testMondayConnection",
16188
16320
  "testRunJourney",
16189
- "testWebhook",
16190
16321
  "toggleFieldIndex",
16191
16322
  "unarchiveAgent",
16192
16323
  "unarchiveChat",
@@ -16332,6 +16463,11 @@ function bindAccessGrantsMethods(target, accessGrants) {
16332
16463
  target.getGranteeGrants = accessGrants.getGranteeGrants.bind(accessGrants);
16333
16464
  }
16334
16465
 
16466
+ // src/client/bindings/app-links.ts
16467
+ function bindAppLinksMethods(target, appLinks) {
16468
+ target.resolveAppLink = appLinks.resolveAppLink.bind(appLinks);
16469
+ }
16470
+
16335
16471
  // src/client/bindings/intervention-requests.ts
16336
16472
  function bindInterventionRequestsMethods(target, interventionRequests) {
16337
16473
  target.getAgentModeAttention = interventionRequests.getAgentModeAttention.bind(interventionRequests);
@@ -16891,9 +17027,7 @@ function bindEventsMethods(target, events) {
16891
17027
  target.createEventRule = events.createEventRule.bind(events);
16892
17028
  target.updateEventRule = events.updateEventRule.bind(events);
16893
17029
  target.deleteEventRule = events.deleteEventRule.bind(events);
16894
- target.testWebhook = events.testWebhook.bind(events);
16895
17030
  target.reorderEventRules = events.reorderEventRules.bind(events);
16896
- target.getWebhookLogs = events.getWebhookLogs.bind(events);
16897
17031
  target.getRuleExecutions = events.getRuleExecutions.bind(events);
16898
17032
  target.getRoutines = events.getRoutines.bind(events);
16899
17033
  target.getRoutine = events.getRoutine.bind(events);
@@ -17336,6 +17470,9 @@ function bindIntegrationsMethods(target, mondayIntegration, discordBots, slackAp
17336
17470
  target.describeSalesforceObject = salesforce.describeSalesforceObject.bind(salesforce);
17337
17471
  target.searchSalesforceRecords = salesforce.searchSalesforceRecords.bind(salesforce);
17338
17472
  target.importSalesforceMembers = salesforce.importSalesforceMembers.bind(salesforce);
17473
+ target.bindHubspotCalendar = hubspot.bindHubspotCalendar.bind(hubspot);
17474
+ target.unlinkHubspotCalendar = hubspot.unlinkHubspotCalendar.bind(hubspot);
17475
+ target.importHubspotCalendarEvents = hubspot.importHubspotCalendarEvents.bind(hubspot);
17339
17476
  target.getHubspotBookingReceipt = hubspot.getHubspotBookingReceipt.bind(hubspot);
17340
17477
  target.releaseHubspotBookingAttempt = hubspot.releaseHubspotBookingAttempt.bind(hubspot);
17341
17478
  target.installHubspot = hubspot.installHubspot.bind(hubspot);
@@ -17453,7 +17590,7 @@ function bindOrgMethods(target, org) {
17453
17590
  target.getOrganizationWorkspaces = org.getOrganizationWorkspaces.bind(org);
17454
17591
  target.getOrganizationWorkspace = org.getOrganizationWorkspace.bind(org);
17455
17592
  target.updateOrganizationWorkspace = org.updateOrganizationWorkspace.bind(org);
17456
- target.getOrgBillingCustomer = org.getOrgBillingCustomer.bind(org);
17593
+ target.getOrgBillingAccess = org.getOrgBillingAccess.bind(org);
17457
17594
  target.getA2PCampaignConfig = org.getA2PCampaignConfig.bind(org);
17458
17595
  target.updateA2PCampaignConfig = org.updateA2PCampaignConfig.bind(org);
17459
17596
  target.getOrgWorkspaceUsage = org.getOrgWorkspaceUsage.bind(org);
@@ -17652,21 +17789,23 @@ function bindQueriesMethods(target, queries) {
17652
17789
  target.runQuery = queries.runQuery.bind(queries);
17653
17790
  }
17654
17791
 
17655
- // src/client/bindings/customers.ts
17656
- function bindCustomersMethods(target, customers) {
17657
- target.getMyCustomers = customers.getMyCustomers.bind(customers);
17658
- target.getMyCustomer = customers.getMyCustomer.bind(customers);
17659
- target.getMyCustomerAccounts = customers.getMyCustomerAccounts.bind(customers);
17660
- target.getMyCustomerSubscriptions = customers.getMyCustomerSubscriptions.bind(customers);
17661
- target.getMyCustomerInvoices = customers.getMyCustomerInvoices.bind(customers);
17662
- target.createMyCustomerPortalSession = customers.createMyCustomerPortalSession.bind(customers);
17663
- target.updateMyCustomer = customers.updateMyCustomer.bind(customers);
17664
- target.createMyCustomerSetupIntent = customers.createMyCustomerSetupIntent.bind(customers);
17665
- target.getMyCustomerPaymentMethods = customers.getMyCustomerPaymentMethods.bind(customers);
17666
- target.attachMyCustomerPaymentMethod = customers.attachMyCustomerPaymentMethod.bind(customers);
17667
- target.detachMyCustomerPaymentMethod = customers.detachMyCustomerPaymentMethod.bind(customers);
17668
- target.setDefaultMyCustomerPaymentMethod = customers.setDefaultMyCustomerPaymentMethod.bind(customers);
17669
- target.getMyCustomerCreditGrants = customers.getMyCustomerCreditGrants.bind(customers);
17792
+ // src/client/bindings/organization-billing.ts
17793
+ function bindOrganizationBillingMethods(target, billing) {
17794
+ target.getOrganizationSubscription = billing.getOrganizationSubscription.bind(billing);
17795
+ target.updateOrganizationCreditSettings = billing.updateOrganizationCreditSettings.bind(billing);
17796
+ target.purchaseOrganizationCredits = billing.purchaseOrganizationCredits.bind(billing);
17797
+ target.getBillingOrganizations = billing.getBillingOrganizations.bind(billing);
17798
+ target.getOrganizationBilling = billing.getOrganizationBilling.bind(billing);
17799
+ target.getOrganizationBillingSubscriptions = billing.getOrganizationBillingSubscriptions.bind(billing);
17800
+ target.getOrganizationInvoices = billing.getOrganizationInvoices.bind(billing);
17801
+ target.createOrganizationPortalSession = billing.createOrganizationPortalSession.bind(billing);
17802
+ target.updateOrganizationBilling = billing.updateOrganizationBilling.bind(billing);
17803
+ target.createOrganizationSetupIntent = billing.createOrganizationSetupIntent.bind(billing);
17804
+ target.getOrganizationPaymentMethods = billing.getOrganizationPaymentMethods.bind(billing);
17805
+ target.attachOrganizationPaymentMethod = billing.attachOrganizationPaymentMethod.bind(billing);
17806
+ target.detachOrganizationPaymentMethod = billing.detachOrganizationPaymentMethod.bind(billing);
17807
+ target.setDefaultOrganizationPaymentMethod = billing.setDefaultOrganizationPaymentMethod.bind(billing);
17808
+ target.getOrganizationCreditGrants = billing.getOrganizationCreditGrants.bind(billing);
17670
17809
  }
17671
17810
 
17672
17811
  // src/client/bindings/resellers.ts
@@ -18029,6 +18168,8 @@ var GravityRailClient = class {
18029
18168
  resolveEntityRefs;
18030
18169
  resolveOrgEntityRefs;
18031
18170
  resolveAccountEntityRefs;
18171
+ // App Links API
18172
+ resolveAppLink;
18032
18173
  // MOTD API
18033
18174
  getMotd;
18034
18175
  // Tracked Links analytics (#10934)
@@ -18263,7 +18404,7 @@ var GravityRailClient = class {
18263
18404
  getOrganizationWorkspaces;
18264
18405
  getOrganizationWorkspace;
18265
18406
  updateOrganizationWorkspace;
18266
- getOrgBillingCustomer;
18407
+ getOrgBillingAccess;
18267
18408
  getA2PCampaignConfig;
18268
18409
  updateA2PCampaignConfig;
18269
18410
  getOrgWorkspaceUsage;
@@ -18472,9 +18613,7 @@ var GravityRailClient = class {
18472
18613
  createEventRule;
18473
18614
  updateEventRule;
18474
18615
  deleteEventRule;
18475
- testWebhook;
18476
18616
  reorderEventRules;
18477
- getWebhookLogs;
18478
18617
  getRuleExecutions;
18479
18618
  getRoutines;
18480
18619
  getRoutine;
@@ -18895,6 +19034,9 @@ var GravityRailClient = class {
18895
19034
  searchSalesforceRecords;
18896
19035
  importSalesforceMembers;
18897
19036
  // HubSpot API
19037
+ bindHubspotCalendar;
19038
+ unlinkHubspotCalendar;
19039
+ importHubspotCalendarEvents;
18898
19040
  getHubspotBookingReceipt;
18899
19041
  releaseHubspotBookingAttempt;
18900
19042
  installHubspot;
@@ -18971,20 +19113,22 @@ var GravityRailClient = class {
18971
19113
  suggestPronunciations;
18972
19114
  getRecommendedVoices;
18973
19115
  previewPronunciation;
18974
- // Customers API (self-service billing portal)
18975
- getMyCustomers;
18976
- getMyCustomer;
18977
- getMyCustomerAccounts;
18978
- getMyCustomerSubscriptions;
18979
- getMyCustomerInvoices;
18980
- createMyCustomerPortalSession;
18981
- updateMyCustomer;
18982
- createMyCustomerSetupIntent;
18983
- getMyCustomerPaymentMethods;
18984
- attachMyCustomerPaymentMethod;
18985
- detachMyCustomerPaymentMethod;
18986
- setDefaultMyCustomerPaymentMethod;
18987
- getMyCustomerCreditGrants;
19116
+ // Organization billing API
19117
+ getOrganizationSubscription;
19118
+ updateOrganizationCreditSettings;
19119
+ purchaseOrganizationCredits;
19120
+ getBillingOrganizations;
19121
+ getOrganizationBilling;
19122
+ getOrganizationBillingSubscriptions;
19123
+ getOrganizationInvoices;
19124
+ createOrganizationPortalSession;
19125
+ updateOrganizationBilling;
19126
+ createOrganizationSetupIntent;
19127
+ getOrganizationPaymentMethods;
19128
+ attachOrganizationPaymentMethod;
19129
+ detachOrganizationPaymentMethod;
19130
+ setDefaultOrganizationPaymentMethod;
19131
+ getOrganizationCreditGrants;
18988
19132
  // Resellers API (self-service reseller portal)
18989
19133
  getMyResellers;
18990
19134
  getMyReseller;
@@ -19069,6 +19213,7 @@ var GravityRailClient = class {
19069
19213
  bindDashboardsMethods(this, apis.dashboards);
19070
19214
  bindActivityMethods(this, apis.activity);
19071
19215
  bindMotdMethods(this, apis.motd);
19216
+ bindAppLinksMethods(this, apis.appLinks);
19072
19217
  bindTrackedLinksMethods(this, apis.trackedLinks);
19073
19218
  bindJourneysMethods(this, apis.journeys);
19074
19219
  bindBundlesMethods(this, apis.bundles, apis.resourceWorkflows);
@@ -19125,7 +19270,7 @@ var GravityRailClient = class {
19125
19270
  apis.confluence
19126
19271
  );
19127
19272
  bindPronunciationsMethods(this, apis.pronunciations);
19128
- bindCustomersMethods(this, apis.customers);
19273
+ bindOrganizationBillingMethods(this, apis.customers);
19129
19274
  bindResellersMethods(this, apis.resellers);
19130
19275
  bindSupportRequestMethods(this, apis.supportRequests);
19131
19276
  bindRoutingRulesMethods(this, apis.routingRules);
@@ -19172,8 +19317,9 @@ var GravityRailClient = class {
19172
19317
  }
19173
19318
  /**
19174
19319
  * Set the org session credential for cross-domain / non-browser clients (e.g. CLI).
19175
- * Opaque gr_sess_ values use X-Org-Session. Legacy orgToken JWE values still
19176
- * use X-Org-Token during the migration window.
19320
+ * Only opaque `gr_sess_` credentials are supported and sent as `X-Org-Session`.
19321
+ * Legacy org tokens raise an error. Sign in again to obtain a session;
19322
+ * pass `undefined` to clear it.
19177
19323
  *
19178
19324
  * `orgUuid` is the org that issued the session. Pass it so the SDK can
19179
19325
  * detect a stale session (e.g. switching orgs mid-session) and re-fire the
@@ -19188,13 +19334,6 @@ var GravityRailClient = class {
19188
19334
  }
19189
19335
  });
19190
19336
  }
19191
- /**
19192
- * @deprecated Legacy compatibility for stateless orgToken JWE credentials.
19193
- * Prefer setOrgSession() for opaque org browser sessions.
19194
- */
19195
- setOrgToken(token, orgUuid) {
19196
- this.setOrgSession(token, orgUuid);
19197
- }
19198
19337
  /**
19199
19338
  * Update the API key across all modules.
19200
19339
  * Used after successful re-authentication.
@@ -19357,6 +19496,7 @@ function pathDraftToStorage(draft, original) {
19357
19496
  ApiError,
19358
19497
  ApiKeysApi,
19359
19498
  AppConnectionsApi,
19499
+ AppLinksApi,
19360
19500
  AppsApi,
19361
19501
  AssignmentsApi,
19362
19502
  AttendeeResponseStatus,
@@ -19403,7 +19543,6 @@ function pathDraftToStorage(draft, original) {
19403
19543
  CustomerActivityReviewOutcome,
19404
19544
  CustomerActivitySeverity,
19405
19545
  CustomerActivitySlaThresholdSource,
19406
- CustomersApi,
19407
19546
  DEFAULT_AGENT_CHAT_MODEL,
19408
19547
  DEFAULT_AGENT_REALTIME_MODEL,
19409
19548
  DEFAULT_AGENT_REALTIME_MODEL_CONFIG,
@@ -19443,6 +19582,7 @@ function pathDraftToStorage(draft, original) {
19443
19582
  HubspotApi,
19444
19583
  ImportReadinessIssueCode,
19445
19584
  ImportReadinessIssueResourceType,
19585
+ ImportReadinessResponseCapCutResourceTypesItem,
19446
19586
  ImportSkippedRuleResourceGroupResourceType,
19447
19587
  ImportSkippedRuleResponseNeededResourceTypesItem,
19448
19588
  ImportSkippedRuleResponseParentKind,
@@ -19491,6 +19631,8 @@ function pathDraftToStorage(draft, original) {
19491
19631
  OrgApi,
19492
19632
  OrgFeature,
19493
19633
  OrganizationAddonResponseScope,
19634
+ OrganizationBillingApi,
19635
+ OrganizationClassification,
19494
19636
  PERMISSION_ADMIN,
19495
19637
  PERMISSION_CREATE,
19496
19638
  PERMISSION_DELETE,
@@ -19612,6 +19754,7 @@ function pathDraftToStorage(draft, original) {
19612
19754
  bindActivityMethods,
19613
19755
  bindAgentTasksMethods,
19614
19756
  bindAgentsMethods,
19757
+ bindAppLinksMethods,
19615
19758
  bindAppsMethods,
19616
19759
  bindAuthMethods,
19617
19760
  bindBillingMethods,
@@ -19620,7 +19763,6 @@ function pathDraftToStorage(draft, original) {
19620
19763
  bindCallsMethods,
19621
19764
  bindChatsMethods,
19622
19765
  bindCommunicationsMethods,
19623
- bindCustomersMethods,
19624
19766
  bindDashboardsMethods,
19625
19767
  bindDataReportsMethods,
19626
19768
  bindDataTypesMethods,
@@ -19637,6 +19779,7 @@ function pathDraftToStorage(draft, original) {
19637
19779
  bindMotdMethods,
19638
19780
  bindOperatorMethods,
19639
19781
  bindOrgMethods,
19782
+ bindOrganizationBillingMethods,
19640
19783
  bindPersonasMethods,
19641
19784
  bindProjectsMethods,
19642
19785
  bindPromptsMethods,