@gravity-rail/cli 3.2.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.
- package/dist/{account-verify-phone-KOK7STAQ.js → account-verify-phone-VZYUPN64.js} +3 -3
- package/dist/{chunk-WBFYLV7Q.js → chunk-JOXB4Y4Q.js} +87 -46
- package/dist/chunk-JOXB4Y4Q.js.map +1 -0
- package/dist/{chunk-INGVO35B.js → chunk-KDWGBYCM.js} +25 -3
- package/dist/chunk-KDWGBYCM.js.map +1 -0
- package/dist/{cli-client-context-NJgZhyfd.d.ts → cli-client-context-BVZdWMkY.d.ts} +2 -0
- package/dist/cli-utils.d.ts +2 -2
- package/dist/cli-utils.js +1 -1
- package/dist/gr.js +557 -348
- package/dist/gr.js.map +1 -1
- package/dist/lib.d.ts +1 -1
- package/dist/lib.js +106 -77
- package/dist/lib.js.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-INGVO35B.js.map +0 -1
- package/dist/chunk-WBFYLV7Q.js.map +0 -1
- /package/dist/{account-verify-phone-KOK7STAQ.js.map → account-verify-phone-VZYUPN64.js.map} +0 -0
package/dist/gr.js
CHANGED
|
@@ -241,7 +241,7 @@ var init_pagination = __esm({
|
|
|
241
241
|
}
|
|
242
242
|
});
|
|
243
243
|
|
|
244
|
-
// ../sdk/dist/chunk-
|
|
244
|
+
// ../sdk/dist/chunk-ZLF3N3ZD.js
|
|
245
245
|
function isApiValidationError(value) {
|
|
246
246
|
if (!value || typeof value !== "object") return false;
|
|
247
247
|
const v = value;
|
|
@@ -259,25 +259,24 @@ function parseOrgAuthChallenge(wwwAuthenticate) {
|
|
|
259
259
|
if (!wwwAuthenticate.includes('realm="org"')) return null;
|
|
260
260
|
const orgUuidMatch = wwwAuthenticate.match(/org_uuid="([^"]+)"/);
|
|
261
261
|
const authUrlMatch = wwwAuthenticate.match(/auth_url="([^"]+)"/);
|
|
262
|
+
const acrValues = wwwAuthenticate.match(/acr_values="([^"]*)"/)?.[1]?.trim().split(/\s+/).filter(Boolean);
|
|
262
263
|
if (!orgUuidMatch?.[1] || !authUrlMatch?.[1]) {
|
|
263
264
|
console.warn("Invalid org auth challenge header: missing required fields");
|
|
264
265
|
return null;
|
|
265
266
|
}
|
|
266
267
|
return {
|
|
267
268
|
orgUuid: orgUuidMatch[1],
|
|
268
|
-
authUrl: authUrlMatch[1]
|
|
269
|
+
authUrl: authUrlMatch[1],
|
|
270
|
+
...acrValues?.length ? { acrValues } : {}
|
|
269
271
|
};
|
|
270
272
|
}
|
|
271
|
-
function orgAuthHeaderName(token) {
|
|
272
|
-
return token.startsWith("gr_sess_") ? "X-Org-Session" : "X-Org-Token";
|
|
273
|
-
}
|
|
274
273
|
function setOrgAuthHeader(headers2, token) {
|
|
275
274
|
if (!token) return;
|
|
276
|
-
headers2.set(
|
|
275
|
+
headers2.set("X-Org-Session", token);
|
|
277
276
|
}
|
|
278
277
|
var ApiError, BaseApiClient;
|
|
279
|
-
var
|
|
280
|
-
"../sdk/dist/chunk-
|
|
278
|
+
var init_chunk_ZLF3N3ZD = __esm({
|
|
279
|
+
"../sdk/dist/chunk-ZLF3N3ZD.js"() {
|
|
281
280
|
ApiError = class extends Error {
|
|
282
281
|
statusCode;
|
|
283
282
|
/** Legacy string-array errors — kept for non-validation callers. */
|
|
@@ -311,13 +310,13 @@ var init_chunk_RLFS7O2L = __esm({
|
|
|
311
310
|
enhancedAuthInProgress = null;
|
|
312
311
|
orgAuthHandler;
|
|
313
312
|
orgAuthInProgress = null;
|
|
313
|
+
orgSessionRevision = 0;
|
|
314
|
+
orgSessionRejectionHandler;
|
|
314
315
|
orgSession;
|
|
315
316
|
/**
|
|
316
|
-
*
|
|
317
|
-
* a
|
|
318
|
-
*
|
|
319
|
-
* `!this.orgSession` would prevent re-auth across orgs and surface as a silent
|
|
320
|
-
* 401 in multi-org CLI workflows.
|
|
317
|
+
* Optional issuer context supplied with an opaque credential. A handler
|
|
318
|
+
* cannot complete a challenge with a session explicitly bound to another org.
|
|
319
|
+
* The server remains responsible for validating the credential itself.
|
|
321
320
|
*/
|
|
322
321
|
orgSessionOrgUuid;
|
|
323
322
|
constructor(apiKey, baseUrl3, customFetch) {
|
|
@@ -352,24 +351,25 @@ var init_chunk_RLFS7O2L = __esm({
|
|
|
352
351
|
}
|
|
353
352
|
/**
|
|
354
353
|
* Set the opaque org session credential a bearer client sends as `X-Org-Session`.
|
|
355
|
-
*
|
|
356
|
-
*
|
|
354
|
+
* Only opaque `gr_sess_` credentials are supported. A legacy org token
|
|
355
|
+
* raises an error; sign in to the organization again to obtain a session.
|
|
356
|
+
* Pass `undefined` to clear the session.
|
|
357
357
|
*
|
|
358
|
-
* `orgUuid` is the org that issued the credential
|
|
359
|
-
* handler
|
|
360
|
-
*
|
|
361
|
-
*
|
|
358
|
+
* `orgUuid` is the org that issued the credential. When supplied by an
|
|
359
|
+
* org-auth handler, it must match the challenge the handler completes.
|
|
360
|
+
* Callers without that context may omit it. Any rejected credential can
|
|
361
|
+
* trigger one reauthentication attempt, including for the same org.
|
|
362
362
|
*/
|
|
363
363
|
setOrgSession(session, orgUuid) {
|
|
364
|
+
if (session !== void 0 && !/^gr_sess_[A-Za-z0-9_-]+$/.test(session)) {
|
|
365
|
+
throw new Error(
|
|
366
|
+
"Unsupported organization session. Sign in again to obtain an opaque gr_sess_ credential."
|
|
367
|
+
);
|
|
368
|
+
}
|
|
369
|
+
this.orgSessionRejectionHandler = void 0;
|
|
364
370
|
this.orgSession = session;
|
|
365
371
|
this.orgSessionOrgUuid = session ? orgUuid : void 0;
|
|
366
|
-
|
|
367
|
-
/**
|
|
368
|
-
* @deprecated Legacy compatibility for stateless orgToken JWE credentials.
|
|
369
|
-
* Prefer setOrgSession() for opaque org browser sessions.
|
|
370
|
-
*/
|
|
371
|
-
setOrgToken(token, orgUuid) {
|
|
372
|
-
this.setOrgSession(token, orgUuid);
|
|
372
|
+
this.orgSessionRevision += 1;
|
|
373
373
|
}
|
|
374
374
|
/**
|
|
375
375
|
* The `credentials` a request carries: none for a bearer client (the fetch
|
|
@@ -380,33 +380,99 @@ var init_chunk_RLFS7O2L = __esm({
|
|
|
380
380
|
}
|
|
381
381
|
/**
|
|
382
382
|
* Run the org-auth handler once for concurrent challenges. A bearer client's
|
|
383
|
-
* handler
|
|
383
|
+
* handler returns a candidate; a same-origin session's
|
|
384
384
|
* handler leaves an httpOnly org-session cookie on the page's origin instead,
|
|
385
385
|
* which the retry presents. A bearer client whose handler issued nothing has
|
|
386
386
|
* nothing to retry with.
|
|
387
387
|
*/
|
|
388
|
-
async answerOrgAuthChallenge(
|
|
388
|
+
async answerOrgAuthChallenge(info, presented, requestRevision) {
|
|
389
389
|
const handler = this.orgAuthHandler;
|
|
390
|
-
if (!handler)
|
|
391
|
-
if (
|
|
392
|
-
this.orgAuthInProgress
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
390
|
+
if (!handler) throw new ApiError("Organization authentication handler is unavailable", 401);
|
|
391
|
+
if (this.orgAuthInProgress) {
|
|
392
|
+
if (this.orgAuthInProgress.orgUuid !== info.orgUuid || this.orgAuthInProgress.requestRevision !== requestRevision) {
|
|
393
|
+
throw new ApiError(
|
|
394
|
+
"Organization authentication context changed. Retry the request.",
|
|
395
|
+
401
|
|
396
|
+
);
|
|
397
|
+
}
|
|
398
|
+
return this.orgAuthInProgress.promise;
|
|
399
|
+
}
|
|
400
|
+
if (this.orgSessionRevision !== requestRevision) {
|
|
401
|
+
throw new ApiError("Organization authentication context changed. Retry the request.", 401);
|
|
402
|
+
}
|
|
403
|
+
this.clearOrgSessionIfCurrent(presented);
|
|
404
|
+
const attemptRevision = this.orgSessionRevision;
|
|
405
|
+
const promise = Promise.resolve().then(() => handler(info)).then((candidate) => {
|
|
406
|
+
if (this.orgSessionRevision !== attemptRevision) {
|
|
407
|
+
throw new ApiError(
|
|
408
|
+
"Organization authentication context changed. Retry the request.",
|
|
409
|
+
401
|
|
410
|
+
);
|
|
411
|
+
}
|
|
412
|
+
if (candidate === void 0) {
|
|
413
|
+
if (this.apiKey) {
|
|
414
|
+
throw new ApiError(
|
|
415
|
+
"Organization authentication must return a session candidate",
|
|
416
|
+
401
|
|
417
|
+
);
|
|
397
418
|
}
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
419
|
+
return "cookie";
|
|
420
|
+
}
|
|
421
|
+
if (!candidate || typeof candidate.session !== "string" || candidate.source !== "cache" && candidate.source !== "new") {
|
|
422
|
+
throw new ApiError(
|
|
423
|
+
"Organization authentication returned an invalid session candidate",
|
|
424
|
+
401
|
|
425
|
+
);
|
|
426
|
+
}
|
|
427
|
+
if (candidate.orgUuid !== info.orgUuid) {
|
|
428
|
+
throw new ApiError(
|
|
429
|
+
"Organization authentication issued a session for another organization",
|
|
430
|
+
401
|
|
431
|
+
);
|
|
432
|
+
}
|
|
433
|
+
if (candidate.source === "cache" && info.sessionRejected) {
|
|
434
|
+
throw new ApiError(
|
|
435
|
+
"Organization authentication requires a newly issued session after rejection",
|
|
436
|
+
401
|
|
437
|
+
);
|
|
438
|
+
}
|
|
439
|
+
this.setOrgSession(candidate.session, candidate.orgUuid);
|
|
440
|
+
let rejected = false;
|
|
441
|
+
this.orgSessionRejectionHandler = () => {
|
|
442
|
+
if (rejected) return;
|
|
443
|
+
rejected = true;
|
|
444
|
+
candidate.onRejected?.();
|
|
445
|
+
};
|
|
446
|
+
return candidate.source;
|
|
447
|
+
}).finally(() => {
|
|
448
|
+
if (this.orgAuthInProgress?.promise === promise) this.orgAuthInProgress = null;
|
|
449
|
+
});
|
|
450
|
+
this.orgAuthInProgress = { orgUuid: info.orgUuid, requestRevision, promise };
|
|
451
|
+
return promise;
|
|
452
|
+
}
|
|
453
|
+
assertOrgAuthContext(orgUuid) {
|
|
454
|
+
if (this.orgSession && this.orgSessionOrgUuid !== orgUuid || this.apiKey && !this.orgSession) {
|
|
455
|
+
throw new ApiError("Organization authentication context changed. Retry the request.", 401);
|
|
404
456
|
}
|
|
405
|
-
|
|
406
|
-
|
|
457
|
+
}
|
|
458
|
+
notifyOrgSessionRejected(presented, callback) {
|
|
459
|
+
try {
|
|
460
|
+
callback?.();
|
|
461
|
+
} catch {
|
|
462
|
+
this.clearOrgSessionIfCurrent(presented);
|
|
463
|
+
throw new ApiError("Could not discard rejected organization session", 401);
|
|
407
464
|
}
|
|
408
465
|
}
|
|
409
|
-
|
|
466
|
+
hasNewerOrgSession(presented, orgUuid) {
|
|
467
|
+
return Boolean(
|
|
468
|
+
presented && this.orgSession && this.orgSession !== presented && this.orgSessionOrgUuid === orgUuid
|
|
469
|
+
);
|
|
470
|
+
}
|
|
471
|
+
clearOrgSessionIfCurrent(expected2) {
|
|
472
|
+
if (this.orgSession !== expected2 || this.orgSession === void 0) return;
|
|
473
|
+
this.setOrgSession(void 0);
|
|
474
|
+
}
|
|
475
|
+
async fetch(endpoint, options, orgAuthRetriesRemaining = this.apiKey && !this.orgSession ? 2 : 1, enhancedAuthRetry = false) {
|
|
410
476
|
try {
|
|
411
477
|
const headers2 = new Headers({
|
|
412
478
|
// Don't set Content-Type for FormData — the browser must set it
|
|
@@ -418,6 +484,10 @@ var init_chunk_RLFS7O2L = __esm({
|
|
|
418
484
|
headers2.set("Authorization", `Bearer ${this.apiKey}`);
|
|
419
485
|
}
|
|
420
486
|
setOrgAuthHeader(headers2, this.orgSession);
|
|
487
|
+
const presentedOrgSession = headers2.get("X-Org-Session");
|
|
488
|
+
const requestOrgRevision = this.orgSessionRevision;
|
|
489
|
+
const presentedOrgUuid = this.orgSessionOrgUuid;
|
|
490
|
+
const rejectionHandler = this.orgSessionRejectionHandler;
|
|
421
491
|
const fullUrl = `${this.baseUrl}/api/v2/${endpoint}`;
|
|
422
492
|
const response = await this.fetchFunction(fullUrl, {
|
|
423
493
|
...options,
|
|
@@ -426,7 +496,7 @@ var init_chunk_RLFS7O2L = __esm({
|
|
|
426
496
|
headers: headers2
|
|
427
497
|
});
|
|
428
498
|
if (!response.ok) {
|
|
429
|
-
if (response.status === 401 && requiresStepUpAuth(response.headers.get("WWW-Authenticate")) && this.enhancedAuthHandler) {
|
|
499
|
+
if (response.status === 401 && !enhancedAuthRetry && requiresStepUpAuth(response.headers.get("WWW-Authenticate")) && this.enhancedAuthHandler) {
|
|
430
500
|
if (this.enhancedAuthInProgress) {
|
|
431
501
|
await this.enhancedAuthInProgress;
|
|
432
502
|
} else {
|
|
@@ -438,28 +508,36 @@ var init_chunk_RLFS7O2L = __esm({
|
|
|
438
508
|
this.enhancedAuthInProgress = null;
|
|
439
509
|
}
|
|
440
510
|
}
|
|
441
|
-
|
|
442
|
-
return await this.fetch(endpoint, options);
|
|
443
|
-
} catch (retryError) {
|
|
444
|
-
this.orgSession = void 0;
|
|
445
|
-
this.orgSessionOrgUuid = void 0;
|
|
446
|
-
throw retryError;
|
|
447
|
-
}
|
|
511
|
+
return await this.fetch(endpoint, options, orgAuthRetriesRemaining, true);
|
|
448
512
|
}
|
|
449
513
|
if (response.status === 401) {
|
|
450
514
|
const orgAuthInfo = parseOrgAuthChallenge(response.headers.get("WWW-Authenticate"));
|
|
451
|
-
if (orgAuthInfo &&
|
|
452
|
-
|
|
453
|
-
|
|
515
|
+
if (orgAuthInfo && presentedOrgSession) {
|
|
516
|
+
orgAuthInfo.sessionRejected = true;
|
|
517
|
+
if (presentedOrgUuid === orgAuthInfo.orgUuid) {
|
|
518
|
+
this.notifyOrgSessionRejected(presentedOrgSession, rejectionHandler);
|
|
519
|
+
}
|
|
454
520
|
}
|
|
455
|
-
if (orgAuthInfo &&
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
521
|
+
if (orgAuthInfo && orgAuthRetriesRemaining > 0 && this.orgAuthHandler) {
|
|
522
|
+
let nextOrgRetries = orgAuthRetriesRemaining - 1;
|
|
523
|
+
if (!this.hasNewerOrgSession(presentedOrgSession, orgAuthInfo.orgUuid)) {
|
|
524
|
+
const completion = await this.answerOrgAuthChallenge(
|
|
525
|
+
orgAuthInfo,
|
|
526
|
+
presentedOrgSession,
|
|
527
|
+
requestOrgRevision
|
|
528
|
+
);
|
|
529
|
+
if (completion !== "cache") nextOrgRetries = 0;
|
|
530
|
+
}
|
|
531
|
+
this.assertOrgAuthContext(orgAuthInfo.orgUuid);
|
|
532
|
+
return await this.fetch(endpoint, options, nextOrgRetries, enhancedAuthRetry);
|
|
533
|
+
}
|
|
534
|
+
if (orgAuthInfo) {
|
|
535
|
+
this.clearOrgSessionIfCurrent(presentedOrgSession);
|
|
536
|
+
if (orgAuthInfo.acrValues?.includes("urn:gravity:mfa")) {
|
|
537
|
+
throw new ApiError(
|
|
538
|
+
"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.",
|
|
539
|
+
401
|
|
540
|
+
);
|
|
463
541
|
}
|
|
464
542
|
}
|
|
465
543
|
}
|
|
@@ -521,7 +599,7 @@ ${formattedErrors}`, response.status);
|
|
|
521
599
|
throw error;
|
|
522
600
|
}
|
|
523
601
|
}
|
|
524
|
-
async fetchRaw(endpoint, options, allowedErrorStatuses = [],
|
|
602
|
+
async fetchRaw(endpoint, options, allowedErrorStatuses = [], orgAuthRetriesRemaining = this.apiKey && !this.orgSession ? 2 : 1, enhancedAuthRetry = false) {
|
|
525
603
|
try {
|
|
526
604
|
const headers2 = new Headers({
|
|
527
605
|
...options?.headers || {}
|
|
@@ -533,6 +611,10 @@ ${formattedErrors}`, response.status);
|
|
|
533
611
|
headers2.set("Authorization", `Bearer ${this.apiKey}`);
|
|
534
612
|
}
|
|
535
613
|
setOrgAuthHeader(headers2, this.orgSession);
|
|
614
|
+
const presentedOrgSession = headers2.get("X-Org-Session");
|
|
615
|
+
const requestOrgRevision = this.orgSessionRevision;
|
|
616
|
+
const presentedOrgUuid = this.orgSessionOrgUuid;
|
|
617
|
+
const rejectionHandler = this.orgSessionRejectionHandler;
|
|
536
618
|
const response = await this.fetchFunction(`${this.baseUrl}/api/v2/${endpoint}`, {
|
|
537
619
|
...options,
|
|
538
620
|
...this.credentialsInit(),
|
|
@@ -540,7 +622,7 @@ ${formattedErrors}`, response.status);
|
|
|
540
622
|
headers: headers2
|
|
541
623
|
});
|
|
542
624
|
if (!response.ok) {
|
|
543
|
-
if (response.status === 401 && requiresStepUpAuth(response.headers.get("WWW-Authenticate")) && this.enhancedAuthHandler) {
|
|
625
|
+
if (response.status === 401 && !enhancedAuthRetry && requiresStepUpAuth(response.headers.get("WWW-Authenticate")) && this.enhancedAuthHandler) {
|
|
544
626
|
if (this.enhancedAuthInProgress) {
|
|
545
627
|
await this.enhancedAuthInProgress;
|
|
546
628
|
} else {
|
|
@@ -552,28 +634,48 @@ ${formattedErrors}`, response.status);
|
|
|
552
634
|
this.enhancedAuthInProgress = null;
|
|
553
635
|
}
|
|
554
636
|
}
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
637
|
+
return await this.fetchRaw(
|
|
638
|
+
endpoint,
|
|
639
|
+
options,
|
|
640
|
+
allowedErrorStatuses,
|
|
641
|
+
orgAuthRetriesRemaining,
|
|
642
|
+
true
|
|
643
|
+
);
|
|
562
644
|
}
|
|
563
645
|
if (response.status === 401) {
|
|
564
646
|
const orgAuthInfo = parseOrgAuthChallenge(response.headers.get("WWW-Authenticate"));
|
|
565
|
-
if (orgAuthInfo &&
|
|
566
|
-
|
|
567
|
-
|
|
647
|
+
if (orgAuthInfo && presentedOrgSession) {
|
|
648
|
+
orgAuthInfo.sessionRejected = true;
|
|
649
|
+
if (presentedOrgUuid === orgAuthInfo.orgUuid) {
|
|
650
|
+
this.notifyOrgSessionRejected(presentedOrgSession, rejectionHandler);
|
|
651
|
+
}
|
|
568
652
|
}
|
|
569
|
-
if (orgAuthInfo &&
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
653
|
+
if (orgAuthInfo && orgAuthRetriesRemaining > 0 && this.orgAuthHandler) {
|
|
654
|
+
let nextOrgRetries = orgAuthRetriesRemaining - 1;
|
|
655
|
+
if (!this.hasNewerOrgSession(presentedOrgSession, orgAuthInfo.orgUuid)) {
|
|
656
|
+
const completion = await this.answerOrgAuthChallenge(
|
|
657
|
+
orgAuthInfo,
|
|
658
|
+
presentedOrgSession,
|
|
659
|
+
requestOrgRevision
|
|
660
|
+
);
|
|
661
|
+
if (completion !== "cache") nextOrgRetries = 0;
|
|
662
|
+
}
|
|
663
|
+
this.assertOrgAuthContext(orgAuthInfo.orgUuid);
|
|
664
|
+
return await this.fetchRaw(
|
|
665
|
+
endpoint,
|
|
666
|
+
options,
|
|
667
|
+
allowedErrorStatuses,
|
|
668
|
+
nextOrgRetries,
|
|
669
|
+
enhancedAuthRetry
|
|
670
|
+
);
|
|
671
|
+
}
|
|
672
|
+
if (orgAuthInfo) {
|
|
673
|
+
this.clearOrgSessionIfCurrent(presentedOrgSession);
|
|
674
|
+
if (!allowedErrorStatuses.includes(401) && orgAuthInfo.acrValues?.includes("urn:gravity:mfa")) {
|
|
675
|
+
throw new ApiError(
|
|
676
|
+
"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.",
|
|
677
|
+
401
|
|
678
|
+
);
|
|
577
679
|
}
|
|
578
680
|
}
|
|
579
681
|
}
|
|
@@ -3167,7 +3269,7 @@ var init_libphonenumber_js = __esm({
|
|
|
3167
3269
|
}
|
|
3168
3270
|
});
|
|
3169
3271
|
|
|
3170
|
-
// ../sdk/dist/chunk-
|
|
3272
|
+
// ../sdk/dist/chunk-WHRIIBJ4.js
|
|
3171
3273
|
function resourceWorkflowsPath(wid, ...segments) {
|
|
3172
3274
|
const tail = segments.map((segment) => encodeURIComponent(String(segment))).join("/");
|
|
3173
3275
|
const base = `w/${encodeURIComponent(wid)}/resource-workflows`;
|
|
@@ -3400,6 +3502,7 @@ function createApiModules(apiKey, baseUrl3, customFetch) {
|
|
|
3400
3502
|
agents: new AgentsApi(apiKey, baseUrl3, customFetch),
|
|
3401
3503
|
aiModels: new AIModelsApi(apiKey, baseUrl3, customFetch),
|
|
3402
3504
|
apiKeys: new ApiKeysApi(apiKey, baseUrl3, customFetch),
|
|
3505
|
+
appLinks: new AppLinksApi(apiKey, baseUrl3, customFetch),
|
|
3403
3506
|
apps: new AppsApi(apiKey, baseUrl3, customFetch),
|
|
3404
3507
|
assignments: new AssignmentsApi(apiKey, baseUrl3, customFetch),
|
|
3405
3508
|
auth: new AuthApi(apiKey, baseUrl3, customFetch),
|
|
@@ -3410,7 +3513,7 @@ function createApiModules(apiKey, baseUrl3, customFetch) {
|
|
|
3410
3513
|
calls: new CallsApi(apiKey, baseUrl3, customFetch),
|
|
3411
3514
|
cel: new CELApi(apiKey, baseUrl3, customFetch),
|
|
3412
3515
|
chats: new ChatsApi(apiKey, baseUrl3, customFetch),
|
|
3413
|
-
customers: new
|
|
3516
|
+
customers: new OrganizationBillingApi(apiKey, baseUrl3, customFetch),
|
|
3414
3517
|
resellers: new ResellersApi(apiKey, baseUrl3, customFetch),
|
|
3415
3518
|
customToolkits: new CustomToolkitsApi(apiKey, baseUrl3, customFetch),
|
|
3416
3519
|
dashboards: new DashboardsApi(apiKey, baseUrl3, customFetch),
|
|
@@ -3503,6 +3606,9 @@ function bindAccessGrantsMethods(target, accessGrants) {
|
|
|
3503
3606
|
target.getMemberGrants = accessGrants.getMemberGrants.bind(accessGrants);
|
|
3504
3607
|
target.getGranteeGrants = accessGrants.getGranteeGrants.bind(accessGrants);
|
|
3505
3608
|
}
|
|
3609
|
+
function bindAppLinksMethods(target, appLinks) {
|
|
3610
|
+
target.resolveAppLink = appLinks.resolveAppLink.bind(appLinks);
|
|
3611
|
+
}
|
|
3506
3612
|
function bindInterventionRequestsMethods(target, interventionRequests) {
|
|
3507
3613
|
target.getAgentModeAttention = interventionRequests.getAgentModeAttention.bind(interventionRequests);
|
|
3508
3614
|
target.getInterventionRequests = interventionRequests.getInterventionRequests.bind(interventionRequests);
|
|
@@ -4025,9 +4131,7 @@ function bindEventsMethods(target, events) {
|
|
|
4025
4131
|
target.createEventRule = events.createEventRule.bind(events);
|
|
4026
4132
|
target.updateEventRule = events.updateEventRule.bind(events);
|
|
4027
4133
|
target.deleteEventRule = events.deleteEventRule.bind(events);
|
|
4028
|
-
target.testWebhook = events.testWebhook.bind(events);
|
|
4029
4134
|
target.reorderEventRules = events.reorderEventRules.bind(events);
|
|
4030
|
-
target.getWebhookLogs = events.getWebhookLogs.bind(events);
|
|
4031
4135
|
target.getRuleExecutions = events.getRuleExecutions.bind(events);
|
|
4032
4136
|
target.getRoutines = events.getRoutines.bind(events);
|
|
4033
4137
|
target.getRoutine = events.getRoutine.bind(events);
|
|
@@ -4454,6 +4558,9 @@ function bindIntegrationsMethods(target, mondayIntegration, discordBots, slackAp
|
|
|
4454
4558
|
target.describeSalesforceObject = salesforce.describeSalesforceObject.bind(salesforce);
|
|
4455
4559
|
target.searchSalesforceRecords = salesforce.searchSalesforceRecords.bind(salesforce);
|
|
4456
4560
|
target.importSalesforceMembers = salesforce.importSalesforceMembers.bind(salesforce);
|
|
4561
|
+
target.bindHubspotCalendar = hubspot.bindHubspotCalendar.bind(hubspot);
|
|
4562
|
+
target.unlinkHubspotCalendar = hubspot.unlinkHubspotCalendar.bind(hubspot);
|
|
4563
|
+
target.importHubspotCalendarEvents = hubspot.importHubspotCalendarEvents.bind(hubspot);
|
|
4457
4564
|
target.getHubspotBookingReceipt = hubspot.getHubspotBookingReceipt.bind(hubspot);
|
|
4458
4565
|
target.releaseHubspotBookingAttempt = hubspot.releaseHubspotBookingAttempt.bind(hubspot);
|
|
4459
4566
|
target.installHubspot = hubspot.installHubspot.bind(hubspot);
|
|
@@ -4567,7 +4674,7 @@ function bindOrgMethods(target, org) {
|
|
|
4567
4674
|
target.getOrganizationWorkspaces = org.getOrganizationWorkspaces.bind(org);
|
|
4568
4675
|
target.getOrganizationWorkspace = org.getOrganizationWorkspace.bind(org);
|
|
4569
4676
|
target.updateOrganizationWorkspace = org.updateOrganizationWorkspace.bind(org);
|
|
4570
|
-
target.
|
|
4677
|
+
target.getOrgBillingAccess = org.getOrgBillingAccess.bind(org);
|
|
4571
4678
|
target.getA2PCampaignConfig = org.getA2PCampaignConfig.bind(org);
|
|
4572
4679
|
target.updateA2PCampaignConfig = org.updateA2PCampaignConfig.bind(org);
|
|
4573
4680
|
target.getOrgWorkspaceUsage = org.getOrgWorkspaceUsage.bind(org);
|
|
@@ -4745,20 +4852,22 @@ function bindQueriesMethods(target, queries) {
|
|
|
4745
4852
|
target.previewQuery = queries.previewQuery.bind(queries);
|
|
4746
4853
|
target.runQuery = queries.runQuery.bind(queries);
|
|
4747
4854
|
}
|
|
4748
|
-
function
|
|
4749
|
-
target.
|
|
4750
|
-
target.
|
|
4751
|
-
target.
|
|
4752
|
-
target.
|
|
4753
|
-
target.
|
|
4754
|
-
target.
|
|
4755
|
-
target.
|
|
4756
|
-
target.
|
|
4757
|
-
target.
|
|
4758
|
-
target.
|
|
4759
|
-
target.
|
|
4760
|
-
target.
|
|
4761
|
-
target.
|
|
4855
|
+
function bindOrganizationBillingMethods(target, billing) {
|
|
4856
|
+
target.getOrganizationSubscription = billing.getOrganizationSubscription.bind(billing);
|
|
4857
|
+
target.updateOrganizationCreditSettings = billing.updateOrganizationCreditSettings.bind(billing);
|
|
4858
|
+
target.purchaseOrganizationCredits = billing.purchaseOrganizationCredits.bind(billing);
|
|
4859
|
+
target.getBillingOrganizations = billing.getBillingOrganizations.bind(billing);
|
|
4860
|
+
target.getOrganizationBilling = billing.getOrganizationBilling.bind(billing);
|
|
4861
|
+
target.getOrganizationBillingSubscriptions = billing.getOrganizationBillingSubscriptions.bind(billing);
|
|
4862
|
+
target.getOrganizationInvoices = billing.getOrganizationInvoices.bind(billing);
|
|
4863
|
+
target.createOrganizationPortalSession = billing.createOrganizationPortalSession.bind(billing);
|
|
4864
|
+
target.updateOrganizationBilling = billing.updateOrganizationBilling.bind(billing);
|
|
4865
|
+
target.createOrganizationSetupIntent = billing.createOrganizationSetupIntent.bind(billing);
|
|
4866
|
+
target.getOrganizationPaymentMethods = billing.getOrganizationPaymentMethods.bind(billing);
|
|
4867
|
+
target.attachOrganizationPaymentMethod = billing.attachOrganizationPaymentMethod.bind(billing);
|
|
4868
|
+
target.detachOrganizationPaymentMethod = billing.detachOrganizationPaymentMethod.bind(billing);
|
|
4869
|
+
target.setDefaultOrganizationPaymentMethod = billing.setDefaultOrganizationPaymentMethod.bind(billing);
|
|
4870
|
+
target.getOrganizationCreditGrants = billing.getOrganizationCreditGrants.bind(billing);
|
|
4762
4871
|
}
|
|
4763
4872
|
function bindResellersMethods(target, resellers) {
|
|
4764
4873
|
target.getMyResellers = resellers.getMyResellers.bind(resellers);
|
|
@@ -4808,10 +4917,10 @@ function getRevisionState(workflow, revision) {
|
|
|
4808
4917
|
state: revision?.publishedAt != null ? "published" : "draft"
|
|
4809
4918
|
};
|
|
4810
4919
|
}
|
|
4811
|
-
var AbilitiesApi, ResourceWorkflowsApi, BundlesApi, InstallationsApi, AccessGrantsApi, AgentTasksApi, AgentsApi, AIModelsApi, ApiKeysApi, AppsApi, AssignmentsApi, VoiceApi, AuthApi, BuildersApi, CalendarsApi, CallsApi, CELApi, ChatsApi, ConfluenceApi, CustomToolkitsApi, DataTypesApi, DiscordBotsApi, SlackAppsApi, EventsApi, FeaturesApi, FhirConnectionsApi, StediApi, InboundFaxStatus, DocumoFaxApi, HealthieApi, FilesApi, InboxesApi, InquiriesApi, AppConnectionsApi, McpServersApi, MemberImportValidationError, MembersApi, MondayIntegrationApi, NotificationRulesApi, OperatorApi, OrgApi, OAuthConnectionsApi, OAuthApi, PhoneNumbersApi, PronunciationsApi, PromptsApi, PersonasApi, QueriesApi, QualificationsApi, ReportsApi, RoutingRulesApi, SalesforceApi, ConnectionSyncApi, HubspotApi, SitesApi, SubscriptionsApi, SupportRequestsApi,
|
|
4812
|
-
var
|
|
4813
|
-
"../sdk/dist/chunk-
|
|
4814
|
-
|
|
4920
|
+
var AbilitiesApi, ResourceWorkflowsApi, BundlesApi, InstallationsApi, AccessGrantsApi, AgentTasksApi, AgentsApi, AIModelsApi, ApiKeysApi, AppLinksApi, AppsApi, AssignmentsApi, VoiceApi, AuthApi, BuildersApi, CalendarsApi, CallsApi, CELApi, ChatsApi, ConfluenceApi, CustomToolkitsApi, DataTypesApi, DiscordBotsApi, SlackAppsApi, EventsApi, FeaturesApi, FhirConnectionsApi, StediApi, InboundFaxStatus, DocumoFaxApi, HealthieApi, FilesApi, InboxesApi, InquiriesApi, AppConnectionsApi, McpServersApi, MemberImportValidationError, MembersApi, MondayIntegrationApi, NotificationRulesApi, OperatorApi, OrgApi, OAuthConnectionsApi, OAuthApi, PhoneNumbersApi, PronunciationsApi, PromptsApi, PersonasApi, QueriesApi, QualificationsApi, ReportsApi, RoutingRulesApi, SalesforceApi, ConnectionSyncApi, HubspotApi, SitesApi, SubscriptionsApi, SupportRequestsApi, OrganizationBillingApi, ResellersApi, SupervisorsApi, TasksApi, TemplatesApi, ToolkitsApi, JourneysApi, WorkflowsApi, WorkflowNotesApi, EventRuleObjectType, EventRuleEventType, EventRuleActionType, DriverMode, MEMBER_RELATIONSHIP_KINDS, WorkspaceInvitationsApi, WorkspacesApi, MedicalBillingApi, DashboardsApi, DevicesApi, TeamsAppsApi, ExperimentsApi, PatientSyncConnectionsApi, ClaimMdApi, ActivityApi, MotdApi, InterventionRequestsApi, MetricsApi, DataReportsApi, ProjectsApi, TrackedLinksApi, WORKSPACE_METHOD_NAMES, WORKSPACE_METHOD_NAME_SET, GravityRailClient, WIDGET_SLUGS, CHAT_TYPES, BUILTIN_ASSISTANT_CHAT_TYPES, MEMBER_AGENT_CHAT_TYPES, ActivityGrain, ActivityGroupBy, ActivityOpenItemOrder, ActivityWindowBasis;
|
|
4921
|
+
var init_chunk_WHRIIBJ4 = __esm({
|
|
4922
|
+
"../sdk/dist/chunk-WHRIIBJ4.js"() {
|
|
4923
|
+
init_chunk_ZLF3N3ZD();
|
|
4815
4924
|
init_libphonenumber_js();
|
|
4816
4925
|
AbilitiesApi = class extends BaseApiClient {
|
|
4817
4926
|
/**
|
|
@@ -5491,6 +5600,19 @@ var init_chunk_MAPAZORN = __esm({
|
|
|
5491
5600
|
});
|
|
5492
5601
|
}
|
|
5493
5602
|
};
|
|
5603
|
+
AppLinksApi = class extends BaseApiClient {
|
|
5604
|
+
/**
|
|
5605
|
+
* Resolve an App Link to the concrete chat it opens.
|
|
5606
|
+
*
|
|
5607
|
+
* `linkParams` is the `?with=&mode=&action=&channel=` suffix built from the
|
|
5608
|
+
* link's search params (an empty string when the link carries none). The
|
|
5609
|
+
* resolver re-runs the current session's workspace authorization; the
|
|
5610
|
+
* response is ids and closed-vocabulary enums only, never PHI.
|
|
5611
|
+
*/
|
|
5612
|
+
async resolveAppLink(wid, linkParams = "") {
|
|
5613
|
+
return this.fetch(`w/${wid}/app-links/resolve${linkParams}`);
|
|
5614
|
+
}
|
|
5615
|
+
};
|
|
5494
5616
|
AppsApi = class extends BaseApiClient {
|
|
5495
5617
|
/**
|
|
5496
5618
|
* List apps - either public apps, account's apps, or all apps visible to a workspace
|
|
@@ -7725,13 +7847,6 @@ var init_chunk_MAPAZORN = __esm({
|
|
|
7725
7847
|
method: "DELETE"
|
|
7726
7848
|
});
|
|
7727
7849
|
}
|
|
7728
|
-
/** Send a one-off test webhook for an existing webhook event rule. */
|
|
7729
|
-
async testWebhook(wid, id, request) {
|
|
7730
|
-
return this.fetch(`w/${wid}/event-rules/${id}/test-webhook`, {
|
|
7731
|
-
method: "POST",
|
|
7732
|
-
body: JSON.stringify(request)
|
|
7733
|
-
});
|
|
7734
|
-
}
|
|
7735
7850
|
/** Reorder event rules by specifying the desired rule ID sequence. */
|
|
7736
7851
|
async reorderEventRules(wid, ruleIds) {
|
|
7737
7852
|
return this.fetch(`w/${wid}/event-rules/reorder`, {
|
|
@@ -7739,19 +7854,6 @@ var init_chunk_MAPAZORN = __esm({
|
|
|
7739
7854
|
body: JSON.stringify(ruleIds)
|
|
7740
7855
|
});
|
|
7741
7856
|
}
|
|
7742
|
-
/** List webhook logs with optional filtering by event type and success status. */
|
|
7743
|
-
async getWebhookLogs(wid, options = {}) {
|
|
7744
|
-
const params = new URLSearchParams();
|
|
7745
|
-
if (options.page) params.append("page", options.page.toString());
|
|
7746
|
-
if (options.pageSize) params.append("pageSize", options.pageSize.toString());
|
|
7747
|
-
if (options.sortBy) params.append("sortBy", options.sortBy);
|
|
7748
|
-
if (options.sortOrder) params.append("sortOrder", options.sortOrder);
|
|
7749
|
-
if (options.eventType) params.append("eventType", options.eventType);
|
|
7750
|
-
if (options.success !== void 0) params.append("success", options.success.toString());
|
|
7751
|
-
return this.fetch(
|
|
7752
|
-
`w/${wid}/webhook-logs${params.toString() ? `?${params.toString()}` : ""}`
|
|
7753
|
-
);
|
|
7754
|
-
}
|
|
7755
7857
|
/** List event rule executions with cursor-based pagination and filtering. */
|
|
7756
7858
|
async getRuleExecutions(wid, options = {}) {
|
|
7757
7859
|
const params = new URLSearchParams();
|
|
@@ -10265,27 +10367,15 @@ var init_chunk_MAPAZORN = __esm({
|
|
|
10265
10367
|
method: "DELETE"
|
|
10266
10368
|
});
|
|
10267
10369
|
}
|
|
10268
|
-
/**
|
|
10269
|
-
|
|
10270
|
-
|
|
10271
|
-
* `subscriptionId` is the org-scoped row — never pick the customer's
|
|
10272
|
-
* newest subscription from the list endpoint. One customer can bill many
|
|
10273
|
-
* organizations.
|
|
10274
|
-
*
|
|
10275
|
-
* Returns the generated `OrgBillingCustomerResponse` — the contract the
|
|
10276
|
-
* route actually emits, `audiences` included. The hand-written mirror that
|
|
10277
|
-
* used to live here listed four fields and silently dropped `audiences`,
|
|
10278
|
-
* so callers could not see the commercial roles they hold (GRA-8792).
|
|
10279
|
-
* Regenerate the shape (`yarn generate:types`) rather than re-declaring it.
|
|
10280
|
-
*/
|
|
10281
|
-
async getOrgBillingCustomer(orgIdOrUuid) {
|
|
10282
|
-
return this.fetch(`o/${orgIdOrUuid}/billing-customer`);
|
|
10370
|
+
/** Current Organization billing access and billable subscription. */
|
|
10371
|
+
async getOrgBillingAccess(orgIdOrUuid) {
|
|
10372
|
+
return this.fetch(`o/${orgIdOrUuid}/billing-access`);
|
|
10283
10373
|
}
|
|
10284
10374
|
/**
|
|
10285
10375
|
* Per-workspace usage for this organization's current credit window.
|
|
10286
10376
|
*
|
|
10287
|
-
* Requires
|
|
10288
|
-
* same gate `
|
|
10377
|
+
* Requires Organization billing access, the
|
|
10378
|
+
* same gate `getOrgBillingAccess().hasAccess` reports, and the one that
|
|
10289
10379
|
* decides whether the billing tab is shown at all.
|
|
10290
10380
|
*
|
|
10291
10381
|
* `creditsUsed` is a real organization-wide total or it is null; it is
|
|
@@ -10328,6 +10418,12 @@ var init_chunk_MAPAZORN = __esm({
|
|
|
10328
10418
|
body: JSON.stringify(data)
|
|
10329
10419
|
});
|
|
10330
10420
|
}
|
|
10421
|
+
async setOrganizationMemberBillingRole(orgUuid, memberId, billingRole) {
|
|
10422
|
+
return this.fetch(`o/${orgUuid}/members/${memberId}/billing-role`, {
|
|
10423
|
+
method: "PUT",
|
|
10424
|
+
body: JSON.stringify({ billingRole })
|
|
10425
|
+
});
|
|
10426
|
+
}
|
|
10331
10427
|
/**
|
|
10332
10428
|
* Remove a member from an organization.
|
|
10333
10429
|
*/
|
|
@@ -12581,6 +12677,24 @@ var init_chunk_MAPAZORN = __esm({
|
|
|
12581
12677
|
}
|
|
12582
12678
|
};
|
|
12583
12679
|
HubspotApi = class extends BaseApiClient {
|
|
12680
|
+
async bindHubspotCalendar(wid, calendarId, linkId) {
|
|
12681
|
+
return this.fetch(`w/${wid}/app-connections/hubspot/calendars/${calendarId}/binding`, {
|
|
12682
|
+
method: "PUT",
|
|
12683
|
+
body: JSON.stringify({ linkId })
|
|
12684
|
+
});
|
|
12685
|
+
}
|
|
12686
|
+
async unlinkHubspotCalendar(wid, calendarId) {
|
|
12687
|
+
return this.fetch(`w/${wid}/app-connections/hubspot/calendars/${calendarId}/binding`, {
|
|
12688
|
+
method: "DELETE"
|
|
12689
|
+
});
|
|
12690
|
+
}
|
|
12691
|
+
/** Import one page into native CalendarEvents. Does not book or send invitations. */
|
|
12692
|
+
async importHubspotCalendarEvents(wid, calendarId, eventTypeId) {
|
|
12693
|
+
return this.fetch(`w/${wid}/app-connections/hubspot/calendars/${calendarId}/events/sync`, {
|
|
12694
|
+
method: "POST",
|
|
12695
|
+
body: JSON.stringify({ eventTypeId })
|
|
12696
|
+
});
|
|
12697
|
+
}
|
|
12584
12698
|
async getHubspotBookingReceipt(wid, meetingId) {
|
|
12585
12699
|
return this.fetch(
|
|
12586
12700
|
`w/${wid}/app-connections/hubspot/booking-deals/${encodeURIComponent(meetingId)}/receipt`
|
|
@@ -13341,17 +13455,31 @@ var init_chunk_MAPAZORN = __esm({
|
|
|
13341
13455
|
);
|
|
13342
13456
|
}
|
|
13343
13457
|
};
|
|
13344
|
-
|
|
13345
|
-
async
|
|
13346
|
-
return this.fetch(
|
|
13458
|
+
OrganizationBillingApi = class extends BaseApiClient {
|
|
13459
|
+
async getOrganizationSubscription(orgUuid) {
|
|
13460
|
+
return this.fetch(`o/${orgUuid}/billing/subscription`);
|
|
13347
13461
|
}
|
|
13348
|
-
async
|
|
13349
|
-
return this.fetch(`
|
|
13462
|
+
async updateOrganizationCreditSettings(orgUuid, updates) {
|
|
13463
|
+
return this.fetch(`o/${orgUuid}/billing/subscription`, {
|
|
13464
|
+
method: "PUT",
|
|
13465
|
+
body: JSON.stringify(updates),
|
|
13466
|
+
headers: { "Content-Type": "application/json" }
|
|
13467
|
+
});
|
|
13350
13468
|
}
|
|
13351
|
-
async
|
|
13352
|
-
return this.fetch(`
|
|
13469
|
+
async purchaseOrganizationCredits(orgUuid, amountCents, idempotencyKey = crypto.randomUUID()) {
|
|
13470
|
+
return this.fetch(`o/${orgUuid}/billing/subscription/purchase-credits`, {
|
|
13471
|
+
method: "POST",
|
|
13472
|
+
body: JSON.stringify({ amountCents }),
|
|
13473
|
+
headers: { "Content-Type": "application/json", "Idempotency-Key": idempotencyKey }
|
|
13474
|
+
});
|
|
13475
|
+
}
|
|
13476
|
+
async getBillingOrganizations() {
|
|
13477
|
+
return this.fetch("o/billing-organizations");
|
|
13478
|
+
}
|
|
13479
|
+
async getOrganizationBilling(uuid) {
|
|
13480
|
+
return this.fetch(`o/${uuid}/billing`);
|
|
13353
13481
|
}
|
|
13354
|
-
async
|
|
13482
|
+
async getOrganizationBillingSubscriptions(uuid, opts) {
|
|
13355
13483
|
const params = new URLSearchParams();
|
|
13356
13484
|
if (opts?.status) params.set("status", opts.status);
|
|
13357
13485
|
if (opts?.page !== void 0) params.set("page", String(opts.page));
|
|
@@ -13360,50 +13488,53 @@ var init_chunk_MAPAZORN = __esm({
|
|
|
13360
13488
|
params.set("subscription_id", String(opts.subscriptionId));
|
|
13361
13489
|
}
|
|
13362
13490
|
const qs = params.toString();
|
|
13363
|
-
return this.fetch(`
|
|
13491
|
+
return this.fetch(`o/${uuid}/billing/subscriptions${qs ? "?" + qs : ""}`);
|
|
13364
13492
|
}
|
|
13365
|
-
async
|
|
13366
|
-
return this.fetch(`
|
|
13493
|
+
async getOrganizationInvoices(uuid) {
|
|
13494
|
+
return this.fetch(`o/${uuid}/billing/invoices`);
|
|
13367
13495
|
}
|
|
13368
|
-
async
|
|
13369
|
-
return this.fetch(`
|
|
13496
|
+
async createOrganizationPortalSession(uuid, returnUrl) {
|
|
13497
|
+
return this.fetch(`o/${uuid}/billing/stripe/portal-session`, {
|
|
13370
13498
|
method: "POST",
|
|
13371
13499
|
body: JSON.stringify({ returnUrl }),
|
|
13372
13500
|
headers: { "Content-Type": "application/json" }
|
|
13373
13501
|
});
|
|
13374
13502
|
}
|
|
13375
|
-
async
|
|
13376
|
-
return this.fetch(`
|
|
13503
|
+
async updateOrganizationBilling(uuid, data) {
|
|
13504
|
+
return this.fetch(`o/${uuid}/billing`, {
|
|
13377
13505
|
method: "PUT",
|
|
13378
13506
|
body: JSON.stringify(data),
|
|
13379
13507
|
headers: { "Content-Type": "application/json" }
|
|
13380
13508
|
});
|
|
13381
13509
|
}
|
|
13382
13510
|
// ===== Payment Methods =====
|
|
13383
|
-
async
|
|
13384
|
-
return this.fetch(`
|
|
13511
|
+
async createOrganizationSetupIntent(uuid) {
|
|
13512
|
+
return this.fetch(`o/${uuid}/billing/stripe/setup-intent`, {
|
|
13513
|
+
method: "POST",
|
|
13514
|
+
body: JSON.stringify({})
|
|
13515
|
+
});
|
|
13385
13516
|
}
|
|
13386
|
-
async
|
|
13387
|
-
return this.fetch(`
|
|
13517
|
+
async getOrganizationPaymentMethods(uuid) {
|
|
13518
|
+
return this.fetch(`o/${uuid}/billing/stripe/payment-methods`);
|
|
13388
13519
|
}
|
|
13389
|
-
async
|
|
13390
|
-
return this.fetch(`
|
|
13520
|
+
async attachOrganizationPaymentMethod(uuid, paymentMethodId, setAsDefault = false) {
|
|
13521
|
+
return this.fetch(`o/${uuid}/billing/stripe/payment-methods/${paymentMethodId}/attach`, {
|
|
13391
13522
|
method: "POST",
|
|
13392
13523
|
body: JSON.stringify({ setAsDefault }),
|
|
13393
13524
|
headers: { "Content-Type": "application/json" }
|
|
13394
13525
|
});
|
|
13395
13526
|
}
|
|
13396
|
-
async
|
|
13397
|
-
return this.fetch(`
|
|
13527
|
+
async detachOrganizationPaymentMethod(uuid, paymentMethodId) {
|
|
13528
|
+
return this.fetch(`o/${uuid}/billing/stripe/payment-methods/${paymentMethodId}`, {
|
|
13398
13529
|
method: "DELETE"
|
|
13399
13530
|
});
|
|
13400
13531
|
}
|
|
13401
|
-
async
|
|
13402
|
-
return this.fetch(`
|
|
13532
|
+
async setDefaultOrganizationPaymentMethod(uuid, paymentMethodId) {
|
|
13533
|
+
return this.fetch(`o/${uuid}/billing/stripe/payment-methods/${paymentMethodId}/set-default`, {
|
|
13403
13534
|
method: "PUT"
|
|
13404
13535
|
});
|
|
13405
13536
|
}
|
|
13406
|
-
async
|
|
13537
|
+
async getOrganizationCreditGrants(uuid, opts) {
|
|
13407
13538
|
const params = new URLSearchParams();
|
|
13408
13539
|
if (opts?.subscriptionId !== void 0) {
|
|
13409
13540
|
params.set("subscription_id", String(opts.subscriptionId));
|
|
@@ -13411,7 +13542,7 @@ var init_chunk_MAPAZORN = __esm({
|
|
|
13411
13542
|
if (opts?.page !== void 0) params.set("page", String(opts.page));
|
|
13412
13543
|
if (opts?.pageSize !== void 0) params.set("page_size", String(opts.pageSize));
|
|
13413
13544
|
const qs = params.toString();
|
|
13414
|
-
return this.fetch(`
|
|
13545
|
+
return this.fetch(`o/${uuid}/billing/credit-grants${qs ? "?" + qs : ""}`);
|
|
13415
13546
|
}
|
|
13416
13547
|
};
|
|
13417
13548
|
ResellersApi = class extends BaseApiClient {
|
|
@@ -14469,7 +14600,6 @@ var init_chunk_MAPAZORN = __esm({
|
|
|
14469
14600
|
EventRuleActionType2["MEMBER_NOTIFY_ACTION"] = "member:notify";
|
|
14470
14601
|
EventRuleActionType2["MEMBER_LABEL_ACTION"] = "member:label";
|
|
14471
14602
|
EventRuleActionType2["MEMBER_UPSERT"] = "member:upsert";
|
|
14472
|
-
EventRuleActionType2["SEND_WEBHOOK"] = "webhook:send";
|
|
14473
14603
|
EventRuleActionType2["SWITCH_TASK_ACTION"] = "task:switch";
|
|
14474
14604
|
EventRuleActionType2["ASSISTANT_MESSAGE"] = "assistant:message";
|
|
14475
14605
|
EventRuleActionType2["FORM_FIELD_UPDATE"] = "form:update_field";
|
|
@@ -15227,8 +15357,8 @@ var init_chunk_MAPAZORN = __esm({
|
|
|
15227
15357
|
*
|
|
15228
15358
|
* `bindings` values are sent in the request body only. They are never
|
|
15229
15359
|
* projected from a response and must never be logged: the point of a
|
|
15230
|
-
* binding is that a
|
|
15231
|
-
*
|
|
15360
|
+
* binding is that a phone number, inbox or Member belongs to ONE target
|
|
15361
|
+
* workspace.
|
|
15232
15362
|
*/
|
|
15233
15363
|
/** Download a workspace export ZIP (``export.json`` + file blobs). */
|
|
15234
15364
|
async exportWorkspaceZip(wid, workflowId, scope, exclude, options) {
|
|
@@ -15289,10 +15419,6 @@ var init_chunk_MAPAZORN = __esm({
|
|
|
15289
15419
|
* Pass ``archive`` (the ZIP from ``exportWorkspaceZip``) to restore file
|
|
15290
15420
|
* contents. ``exportData`` may be omitted when the ZIP contains it.
|
|
15291
15421
|
*
|
|
15292
|
-
* ``activateWebhookRules`` is safety-default false: imported
|
|
15293
|
-
* ``webhook:send`` EventRules are force-disabled unless the operator
|
|
15294
|
-
* opts in. An exported-inactive rule stays inactive either way.
|
|
15295
|
-
*
|
|
15296
15422
|
* With ``options.intent = 'template_reapply'`` this is the GUARDED apply.
|
|
15297
15423
|
* It requires ``options.expectedPlanFingerprint`` — the digest a preview
|
|
15298
15424
|
* returned — and answers 200 ``success``, 200 ``noop`` (the target already
|
|
@@ -15300,15 +15426,14 @@ var init_chunk_MAPAZORN = __esm({
|
|
|
15300
15426
|
* ``stale_import_plan`` or 409 ``import_plan_refused``. Both 409s commit
|
|
15301
15427
|
* nothing and carry the complete values-free ``planRows``.
|
|
15302
15428
|
*/
|
|
15303
|
-
async importWorkspace(wid, exportData, importMappings, createNew, archive,
|
|
15429
|
+
async importWorkspace(wid, exportData, importMappings, createNew, archive, autoMap, options) {
|
|
15304
15430
|
if (archive) {
|
|
15305
15431
|
return this.importWorkspaceZip(wid, archive, {
|
|
15306
15432
|
...options,
|
|
15307
15433
|
exportData,
|
|
15308
15434
|
importMappings,
|
|
15309
15435
|
createNew,
|
|
15310
|
-
autoMap
|
|
15311
|
-
activateWebhookRules
|
|
15436
|
+
autoMap
|
|
15312
15437
|
});
|
|
15313
15438
|
}
|
|
15314
15439
|
if (!exportData) {
|
|
@@ -15320,9 +15445,6 @@ var init_chunk_MAPAZORN = __esm({
|
|
|
15320
15445
|
createNew,
|
|
15321
15446
|
...planFields(options)
|
|
15322
15447
|
};
|
|
15323
|
-
if (activateWebhookRules) {
|
|
15324
|
-
payload.activateWebhookRules = activateWebhookRules;
|
|
15325
|
-
}
|
|
15326
15448
|
if (autoMap) {
|
|
15327
15449
|
payload.autoMap = autoMap;
|
|
15328
15450
|
}
|
|
@@ -15348,25 +15470,17 @@ var init_chunk_MAPAZORN = __esm({
|
|
|
15348
15470
|
*
|
|
15349
15471
|
* `options.bindings` values are sent in the request body only. They are
|
|
15350
15472
|
* never projected from a response and must never be logged: the point of a
|
|
15351
|
-
* binding is that a
|
|
15352
|
-
*
|
|
15473
|
+
* binding is that a phone number, inbox or Member belongs to ONE target
|
|
15474
|
+
* workspace.
|
|
15353
15475
|
*/
|
|
15354
15476
|
async importWorkspaceZip(wid, archive, options) {
|
|
15355
|
-
const {
|
|
15356
|
-
exportData,
|
|
15357
|
-
importMappings,
|
|
15358
|
-
createNew,
|
|
15359
|
-
autoMap,
|
|
15360
|
-
activateWebhookRules,
|
|
15361
|
-
...planOptions
|
|
15362
|
-
} = options ?? {};
|
|
15477
|
+
const { exportData, importMappings, createNew, autoMap, ...planOptions } = options ?? {};
|
|
15363
15478
|
const payload = {
|
|
15364
15479
|
importMappings: importMappings ?? {},
|
|
15365
15480
|
createNew: createNew ?? {},
|
|
15366
15481
|
...planFields(planOptions)
|
|
15367
15482
|
};
|
|
15368
15483
|
if (exportData) payload.exportData = exportData;
|
|
15369
|
-
if (activateWebhookRules) payload.activateWebhookRules = activateWebhookRules;
|
|
15370
15484
|
if (autoMap) payload.autoMap = autoMap;
|
|
15371
15485
|
const form = new FormData();
|
|
15372
15486
|
form.append(
|
|
@@ -16819,6 +16933,9 @@ var init_chunk_MAPAZORN = __esm({
|
|
|
16819
16933
|
"getHubspotObjectProperties",
|
|
16820
16934
|
"getHubspotReconciliationMatches",
|
|
16821
16935
|
"getHubspotStatus",
|
|
16936
|
+
"bindHubspotCalendar",
|
|
16937
|
+
"unlinkHubspotCalendar",
|
|
16938
|
+
"importHubspotCalendarEvents",
|
|
16822
16939
|
"getHubspotBookingReceipt",
|
|
16823
16940
|
"releaseHubspotBookingAttempt",
|
|
16824
16941
|
"getHubspotSyncLogs",
|
|
@@ -16985,7 +17102,6 @@ var init_chunk_MAPAZORN = __esm({
|
|
|
16985
17102
|
"getUsageDashboard",
|
|
16986
17103
|
"getVariableRegistry",
|
|
16987
17104
|
"getVoiceUsageReport",
|
|
16988
|
-
"getWebhookLogs",
|
|
16989
17105
|
"getWorkflow",
|
|
16990
17106
|
"getWorkflowOpeningTurnConversionReport",
|
|
16991
17107
|
"getWorkflowActivity",
|
|
@@ -17188,7 +17304,6 @@ var init_chunk_MAPAZORN = __esm({
|
|
|
17188
17304
|
"testMcpServerConnection",
|
|
17189
17305
|
"testMondayConnection",
|
|
17190
17306
|
"testRunJourney",
|
|
17191
|
-
"testWebhook",
|
|
17192
17307
|
"toggleFieldIndex",
|
|
17193
17308
|
"unarchiveAgent",
|
|
17194
17309
|
"unarchiveChat",
|
|
@@ -17618,6 +17733,8 @@ var init_chunk_MAPAZORN = __esm({
|
|
|
17618
17733
|
resolveEntityRefs;
|
|
17619
17734
|
resolveOrgEntityRefs;
|
|
17620
17735
|
resolveAccountEntityRefs;
|
|
17736
|
+
// App Links API
|
|
17737
|
+
resolveAppLink;
|
|
17621
17738
|
// MOTD API
|
|
17622
17739
|
getMotd;
|
|
17623
17740
|
// Tracked Links analytics (#10934)
|
|
@@ -17852,7 +17969,7 @@ var init_chunk_MAPAZORN = __esm({
|
|
|
17852
17969
|
getOrganizationWorkspaces;
|
|
17853
17970
|
getOrganizationWorkspace;
|
|
17854
17971
|
updateOrganizationWorkspace;
|
|
17855
|
-
|
|
17972
|
+
getOrgBillingAccess;
|
|
17856
17973
|
getA2PCampaignConfig;
|
|
17857
17974
|
updateA2PCampaignConfig;
|
|
17858
17975
|
getOrgWorkspaceUsage;
|
|
@@ -18061,9 +18178,7 @@ var init_chunk_MAPAZORN = __esm({
|
|
|
18061
18178
|
createEventRule;
|
|
18062
18179
|
updateEventRule;
|
|
18063
18180
|
deleteEventRule;
|
|
18064
|
-
testWebhook;
|
|
18065
18181
|
reorderEventRules;
|
|
18066
|
-
getWebhookLogs;
|
|
18067
18182
|
getRuleExecutions;
|
|
18068
18183
|
getRoutines;
|
|
18069
18184
|
getRoutine;
|
|
@@ -18484,6 +18599,9 @@ var init_chunk_MAPAZORN = __esm({
|
|
|
18484
18599
|
searchSalesforceRecords;
|
|
18485
18600
|
importSalesforceMembers;
|
|
18486
18601
|
// HubSpot API
|
|
18602
|
+
bindHubspotCalendar;
|
|
18603
|
+
unlinkHubspotCalendar;
|
|
18604
|
+
importHubspotCalendarEvents;
|
|
18487
18605
|
getHubspotBookingReceipt;
|
|
18488
18606
|
releaseHubspotBookingAttempt;
|
|
18489
18607
|
installHubspot;
|
|
@@ -18560,20 +18678,22 @@ var init_chunk_MAPAZORN = __esm({
|
|
|
18560
18678
|
suggestPronunciations;
|
|
18561
18679
|
getRecommendedVoices;
|
|
18562
18680
|
previewPronunciation;
|
|
18563
|
-
//
|
|
18564
|
-
|
|
18565
|
-
|
|
18566
|
-
|
|
18567
|
-
|
|
18568
|
-
|
|
18569
|
-
|
|
18570
|
-
|
|
18571
|
-
|
|
18572
|
-
|
|
18573
|
-
|
|
18574
|
-
|
|
18575
|
-
|
|
18576
|
-
|
|
18681
|
+
// Organization billing API
|
|
18682
|
+
getOrganizationSubscription;
|
|
18683
|
+
updateOrganizationCreditSettings;
|
|
18684
|
+
purchaseOrganizationCredits;
|
|
18685
|
+
getBillingOrganizations;
|
|
18686
|
+
getOrganizationBilling;
|
|
18687
|
+
getOrganizationBillingSubscriptions;
|
|
18688
|
+
getOrganizationInvoices;
|
|
18689
|
+
createOrganizationPortalSession;
|
|
18690
|
+
updateOrganizationBilling;
|
|
18691
|
+
createOrganizationSetupIntent;
|
|
18692
|
+
getOrganizationPaymentMethods;
|
|
18693
|
+
attachOrganizationPaymentMethod;
|
|
18694
|
+
detachOrganizationPaymentMethod;
|
|
18695
|
+
setDefaultOrganizationPaymentMethod;
|
|
18696
|
+
getOrganizationCreditGrants;
|
|
18577
18697
|
// Resellers API (self-service reseller portal)
|
|
18578
18698
|
getMyResellers;
|
|
18579
18699
|
getMyReseller;
|
|
@@ -18658,6 +18778,7 @@ var init_chunk_MAPAZORN = __esm({
|
|
|
18658
18778
|
bindDashboardsMethods(this, apis.dashboards);
|
|
18659
18779
|
bindActivityMethods(this, apis.activity);
|
|
18660
18780
|
bindMotdMethods(this, apis.motd);
|
|
18781
|
+
bindAppLinksMethods(this, apis.appLinks);
|
|
18661
18782
|
bindTrackedLinksMethods(this, apis.trackedLinks);
|
|
18662
18783
|
bindJourneysMethods(this, apis.journeys);
|
|
18663
18784
|
bindBundlesMethods(this, apis.bundles, apis.resourceWorkflows);
|
|
@@ -18714,7 +18835,7 @@ var init_chunk_MAPAZORN = __esm({
|
|
|
18714
18835
|
apis.confluence
|
|
18715
18836
|
);
|
|
18716
18837
|
bindPronunciationsMethods(this, apis.pronunciations);
|
|
18717
|
-
|
|
18838
|
+
bindOrganizationBillingMethods(this, apis.customers);
|
|
18718
18839
|
bindResellersMethods(this, apis.resellers);
|
|
18719
18840
|
bindSupportRequestMethods(this, apis.supportRequests);
|
|
18720
18841
|
bindRoutingRulesMethods(this, apis.routingRules);
|
|
@@ -18761,8 +18882,9 @@ var init_chunk_MAPAZORN = __esm({
|
|
|
18761
18882
|
}
|
|
18762
18883
|
/**
|
|
18763
18884
|
* Set the org session credential for cross-domain / non-browser clients (e.g. CLI).
|
|
18764
|
-
*
|
|
18765
|
-
*
|
|
18885
|
+
* Only opaque `gr_sess_` credentials are supported and sent as `X-Org-Session`.
|
|
18886
|
+
* Legacy org tokens raise an error. Sign in again to obtain a session;
|
|
18887
|
+
* pass `undefined` to clear it.
|
|
18766
18888
|
*
|
|
18767
18889
|
* `orgUuid` is the org that issued the session. Pass it so the SDK can
|
|
18768
18890
|
* detect a stale session (e.g. switching orgs mid-session) and re-fire the
|
|
@@ -18777,13 +18899,6 @@ var init_chunk_MAPAZORN = __esm({
|
|
|
18777
18899
|
}
|
|
18778
18900
|
});
|
|
18779
18901
|
}
|
|
18780
|
-
/**
|
|
18781
|
-
* @deprecated Legacy compatibility for stateless orgToken JWE credentials.
|
|
18782
|
-
* Prefer setOrgSession() for opaque org browser sessions.
|
|
18783
|
-
*/
|
|
18784
|
-
setOrgToken(token, orgUuid) {
|
|
18785
|
-
this.setOrgSession(token, orgUuid);
|
|
18786
|
-
}
|
|
18787
18902
|
/**
|
|
18788
18903
|
* Update the API key across all modules.
|
|
18789
18904
|
* Used after successful re-authentication.
|
|
@@ -18893,10 +19008,10 @@ var init_chunk_6KPGCPGW = __esm({
|
|
|
18893
19008
|
var SEARCHABLE_EVENT_RULE_SOURCE_FIELDS, ActivityEventType, EntityKind;
|
|
18894
19009
|
var init_dist = __esm({
|
|
18895
19010
|
"../sdk/dist/index.js"() {
|
|
18896
|
-
|
|
19011
|
+
init_chunk_WHRIIBJ4();
|
|
18897
19012
|
init_chunk_D5VNVTUQ();
|
|
18898
19013
|
init_chunk_6KPGCPGW();
|
|
18899
|
-
|
|
19014
|
+
init_chunk_ZLF3N3ZD();
|
|
18900
19015
|
SEARCHABLE_EVENT_RULE_SOURCE_FIELDS = [
|
|
18901
19016
|
"taskId",
|
|
18902
19017
|
"dataTypeId",
|
|
@@ -23320,7 +23435,7 @@ var init_package = __esm({
|
|
|
23320
23435
|
"package.json"() {
|
|
23321
23436
|
package_default = {
|
|
23322
23437
|
name: "@gravity-rail/cli",
|
|
23323
|
-
version: "
|
|
23438
|
+
version: "4.0.0",
|
|
23324
23439
|
description: "Gravity Rail CLI \u2014 manage workspaces from the command line",
|
|
23325
23440
|
type: "module",
|
|
23326
23441
|
bin: {
|
|
@@ -23388,9 +23503,19 @@ var init_package = __esm({
|
|
|
23388
23503
|
};
|
|
23389
23504
|
}
|
|
23390
23505
|
});
|
|
23506
|
+
|
|
23507
|
+
// src/lib/org-session.ts
|
|
23508
|
+
function isOrgSessionCredential(value) {
|
|
23509
|
+
return typeof value === "string" && /^gr_sess_[A-Za-z0-9_-]+$/.test(value);
|
|
23510
|
+
}
|
|
23511
|
+
var init_org_session = __esm({
|
|
23512
|
+
"src/lib/org-session.ts"() {
|
|
23513
|
+
}
|
|
23514
|
+
});
|
|
23391
23515
|
var DEFAULT_PROFILE, LOOPBACK_HOSTNAMES, CredentialsManager;
|
|
23392
23516
|
var init_credentials_manager = __esm({
|
|
23393
23517
|
"src/cli-utils/credentials-manager.ts"() {
|
|
23518
|
+
init_org_session();
|
|
23394
23519
|
DEFAULT_PROFILE = "default";
|
|
23395
23520
|
LOOPBACK_HOSTNAMES = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "[::1]"]);
|
|
23396
23521
|
CredentialsManager = class {
|
|
@@ -23698,7 +23823,7 @@ var init_credentials_manager = __esm({
|
|
|
23698
23823
|
const name = profile ?? parsed.store.currentProfile ?? DEFAULT_PROFILE;
|
|
23699
23824
|
if (profile) this.validateProfileName(profile);
|
|
23700
23825
|
const entry = parsed.store.profiles[name]?.orgSessions?.[orgUuid];
|
|
23701
|
-
if (!entry?.session) return void 0;
|
|
23826
|
+
if (!isOrgSessionCredential(entry?.session)) return void 0;
|
|
23702
23827
|
if (entry.expiresAt && new Date(entry.expiresAt) <= /* @__PURE__ */ new Date()) return void 0;
|
|
23703
23828
|
return entry.session;
|
|
23704
23829
|
}
|
|
@@ -23708,6 +23833,9 @@ var init_credentials_manager = __esm({
|
|
|
23708
23833
|
* logged-in account profile (never create a token-less profile row).
|
|
23709
23834
|
*/
|
|
23710
23835
|
setOrgSession(env, profile, orgUuid, session, expiresAt) {
|
|
23836
|
+
if (!isOrgSessionCredential(session)) {
|
|
23837
|
+
throw new Error("Invalid organization session. Sign in again.");
|
|
23838
|
+
}
|
|
23711
23839
|
const parsed = this.readStore(env);
|
|
23712
23840
|
if (!parsed) return;
|
|
23713
23841
|
const store = parsed.store;
|
|
@@ -23721,6 +23849,17 @@ var init_credentials_manager = __esm({
|
|
|
23721
23849
|
};
|
|
23722
23850
|
this.writeStore(env, store);
|
|
23723
23851
|
}
|
|
23852
|
+
/** Remove the entry only when its currently stored token matches the rejected one. */
|
|
23853
|
+
removeOrgSession(env, profile, orgUuid, expectedSession) {
|
|
23854
|
+
const parsed = this.readStore(env);
|
|
23855
|
+
if (!parsed) return;
|
|
23856
|
+
const name = profile ?? parsed.store.currentProfile ?? DEFAULT_PROFILE;
|
|
23857
|
+
if (profile) this.validateProfileName(profile);
|
|
23858
|
+
const sessions = parsed.store.profiles[name]?.orgSessions;
|
|
23859
|
+
if (sessions?.[orgUuid]?.session !== expectedSession) return;
|
|
23860
|
+
delete sessions[orgUuid];
|
|
23861
|
+
this.writeStore(env, parsed.store);
|
|
23862
|
+
}
|
|
23724
23863
|
getCacheDir() {
|
|
23725
23864
|
return this.cacheDir;
|
|
23726
23865
|
}
|
|
@@ -24843,12 +24982,25 @@ async function tryDirectJoin(apiUrl, accessToken, orgAuthInfo) {
|
|
|
24843
24982
|
try {
|
|
24844
24983
|
body = await response.json();
|
|
24845
24984
|
} catch {
|
|
24846
|
-
throw new
|
|
24985
|
+
throw new OrgSignInResponseError("Org join succeeded but returned an invalid response");
|
|
24986
|
+
}
|
|
24987
|
+
if (!body || typeof body !== "object" || Array.isArray(body)) {
|
|
24988
|
+
throw new OrgSignInResponseError("Org join succeeded but returned an invalid response");
|
|
24847
24989
|
}
|
|
24848
24990
|
if (typeof body.orgSession !== "string" || !body.orgSession) {
|
|
24849
|
-
throw new
|
|
24991
|
+
throw new OrgSignInResponseError("Org join succeeded but returned no org session");
|
|
24850
24992
|
}
|
|
24851
|
-
|
|
24993
|
+
let expiresAt;
|
|
24994
|
+
if (body.expiresAt !== void 0) {
|
|
24995
|
+
if (typeof body.expiresAt !== "string" || !Number.isFinite(Date.parse(body.expiresAt))) {
|
|
24996
|
+
throw new OrgSignInResponseError("Org join returned an invalid session expiry");
|
|
24997
|
+
}
|
|
24998
|
+
expiresAt = body.expiresAt;
|
|
24999
|
+
if (Date.parse(expiresAt) <= Date.now()) {
|
|
25000
|
+
throw new OrgSignInResponseError("Org join returned an expired session");
|
|
25001
|
+
}
|
|
25002
|
+
}
|
|
25003
|
+
return { session: body.orgSession, expiresAt };
|
|
24852
25004
|
}
|
|
24853
25005
|
function isAllowedAuthUrl(url, apiUrl, frontendUrl) {
|
|
24854
25006
|
try {
|
|
@@ -24984,9 +25136,14 @@ This workspace requires organization SSO authentication.`);
|
|
|
24984
25136
|
});
|
|
24985
25137
|
if (!response.ok)
|
|
24986
25138
|
throw new Error(`Could not finish organization sign-in (${response.status}).`);
|
|
24987
|
-
|
|
24988
|
-
|
|
24989
|
-
|
|
25139
|
+
let result3;
|
|
25140
|
+
try {
|
|
25141
|
+
result3 = await response.json();
|
|
25142
|
+
} catch {
|
|
25143
|
+
throw new OrgSignInResponseError("Invalid organization sign-in response.");
|
|
25144
|
+
}
|
|
25145
|
+
if (!result3 || !isOrgSessionCredential(result3.orgSession)) {
|
|
25146
|
+
throw new OrgSignInResponseError("Invalid organization sign-in response.");
|
|
24990
25147
|
}
|
|
24991
25148
|
return result3.orgSession;
|
|
24992
25149
|
} finally {
|
|
@@ -24994,54 +25151,77 @@ This workspace requires organization SSO authentication.`);
|
|
|
24994
25151
|
}
|
|
24995
25152
|
}
|
|
24996
25153
|
function registerOrgAuthHandler(apiClient, apiUrl, accessToken, orgAuthCtx) {
|
|
24997
|
-
apiClient.setOrgAuthHandler(
|
|
24998
|
-
|
|
24999
|
-
|
|
25000
|
-
|
|
25001
|
-
|
|
25002
|
-
|
|
25003
|
-
|
|
25004
|
-
|
|
25005
|
-
|
|
25006
|
-
|
|
25007
|
-
|
|
25008
|
-
|
|
25009
|
-
|
|
25010
|
-
|
|
25011
|
-
|
|
25012
|
-
|
|
25013
|
-
|
|
25014
|
-
|
|
25154
|
+
apiClient.setOrgAuthHandler(
|
|
25155
|
+
async (orgAuthInfo) => {
|
|
25156
|
+
const orgUuid = orgAuthInfo.orgUuid;
|
|
25157
|
+
if (!ORG_UUID_RE.test(orgUuid)) {
|
|
25158
|
+
throw new Error("Invalid organization id in auth challenge");
|
|
25159
|
+
}
|
|
25160
|
+
const cm = orgAuthCtx?.credentialsManager;
|
|
25161
|
+
const initialCachedSession = cm && orgAuthCtx ? cm.getOrgSession(orgAuthCtx.env, orgAuthCtx.profile, orgUuid) : void 0;
|
|
25162
|
+
const adopt = (session2, expiresAt) => {
|
|
25163
|
+
if (!isOrgSessionCredential(session2)) {
|
|
25164
|
+
throw new OrgSignInResponseError("Invalid organization sign-in response.");
|
|
25165
|
+
}
|
|
25166
|
+
if (cm && orgAuthCtx && expiresAt && cm.getOrgSession(orgAuthCtx.env, orgAuthCtx.profile, orgUuid) === initialCachedSession) {
|
|
25167
|
+
cm.setOrgSession(orgAuthCtx.env, orgAuthCtx.profile, orgUuid, session2, expiresAt);
|
|
25168
|
+
}
|
|
25169
|
+
return {
|
|
25170
|
+
session: session2,
|
|
25171
|
+
orgUuid,
|
|
25172
|
+
source: "new",
|
|
25173
|
+
onRejected: () => {
|
|
25174
|
+
if (cm && orgAuthCtx)
|
|
25175
|
+
cm.removeOrgSession(orgAuthCtx.env, orgAuthCtx.profile, orgUuid, session2);
|
|
25176
|
+
}
|
|
25177
|
+
};
|
|
25178
|
+
};
|
|
25179
|
+
if (cm && orgAuthCtx && !orgAuthInfo.sessionRejected && !orgAuthInfo.acrValues?.length) {
|
|
25180
|
+
const cached = cm.getOrgSession(orgAuthCtx.env, orgAuthCtx.profile, orgUuid);
|
|
25181
|
+
if (cached) {
|
|
25182
|
+
return {
|
|
25183
|
+
session: cached,
|
|
25184
|
+
orgUuid,
|
|
25185
|
+
source: "cache",
|
|
25186
|
+
onRejected: () => {
|
|
25187
|
+
cm.removeOrgSession(orgAuthCtx.env, orgAuthCtx.profile, orgUuid, cached);
|
|
25188
|
+
}
|
|
25189
|
+
};
|
|
25190
|
+
}
|
|
25191
|
+
}
|
|
25192
|
+
let orgSession = null;
|
|
25193
|
+
try {
|
|
25194
|
+
orgSession = await tryDirectJoin(apiUrl, accessToken, orgAuthInfo);
|
|
25195
|
+
} catch (err) {
|
|
25196
|
+
if (err instanceof OrgSignInResponseError) throw err;
|
|
25197
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
25198
|
+
stderr2(`Warning: org direct-join failed (${msg}); trying browser sign-in`);
|
|
25015
25199
|
}
|
|
25016
|
-
}
|
|
25017
|
-
try {
|
|
25018
|
-
const orgSession = await tryDirectJoin(apiUrl, accessToken, orgAuthInfo);
|
|
25019
25200
|
if (orgSession !== null) {
|
|
25020
|
-
adopt(orgSession);
|
|
25021
|
-
return;
|
|
25201
|
+
return adopt(orgSession.session, orgSession.expiresAt);
|
|
25022
25202
|
}
|
|
25023
|
-
|
|
25024
|
-
|
|
25025
|
-
|
|
25026
|
-
|
|
25027
|
-
|
|
25028
|
-
|
|
25029
|
-
|
|
25030
|
-
|
|
25031
|
-
|
|
25032
|
-
|
|
25033
|
-
|
|
25034
|
-
|
|
25035
|
-
);
|
|
25203
|
+
if (!orgAuthCtx?.interactive || isHeadless()) {
|
|
25204
|
+
throw new Error(
|
|
25205
|
+
"This workspace\u2019s organization requires SSO sign-in, which needs a browser.\nRun an interactive `gr` command on a machine with a browser to sign in once (the session is then cached), or use an API key for non-interactive use:\n export GRAVITY_RAIL_API_KEY=<key> (see: gr api-keys)"
|
|
25206
|
+
);
|
|
25207
|
+
}
|
|
25208
|
+
if (!isAllowedAuthUrl(orgAuthInfo.authUrl, apiUrl, orgAuthCtx.frontendUrl)) {
|
|
25209
|
+
throw new Error(
|
|
25210
|
+
`Refusing to open organization auth URL: host does not match the configured API/frontend host. Re-run with the expected --api-url, or contact support.`
|
|
25211
|
+
);
|
|
25212
|
+
}
|
|
25213
|
+
const session = await stepUpViaBrowser(orgAuthInfo, apiUrl, accessToken);
|
|
25214
|
+
return adopt(session, new Date(Date.now() + ORG_SESSION_CACHE_TTL_MS).toISOString());
|
|
25036
25215
|
}
|
|
25037
|
-
|
|
25038
|
-
adopt(session);
|
|
25039
|
-
});
|
|
25216
|
+
);
|
|
25040
25217
|
}
|
|
25041
|
-
var ORG_AUTH_TIMEOUT_MS, ORG_SESSION_CACHE_TTL_MS, CLI_ORG_AUTH_BRIDGE_PATH, ORG_UUID_RE;
|
|
25218
|
+
var OrgSignInResponseError, ORG_AUTH_TIMEOUT_MS, ORG_SESSION_CACHE_TTL_MS, CLI_ORG_AUTH_BRIDGE_PATH, ORG_UUID_RE;
|
|
25042
25219
|
var init_org_auth = __esm({
|
|
25043
25220
|
"src/lib/org-auth.ts"() {
|
|
25044
25221
|
init_output();
|
|
25222
|
+
init_org_session();
|
|
25223
|
+
OrgSignInResponseError = class extends Error {
|
|
25224
|
+
};
|
|
25045
25225
|
ORG_AUTH_TIMEOUT_MS = 5 * 60 * 1e3;
|
|
25046
25226
|
ORG_SESSION_CACHE_TTL_MS = 6.5 * 24 * 60 * 60 * 1e3;
|
|
25047
25227
|
CLI_ORG_AUTH_BRIDGE_PATH = "/cli/org-auth";
|
|
@@ -26328,7 +26508,7 @@ var agentTasksDomain = {
|
|
|
26328
26508
|
args: [
|
|
26329
26509
|
{
|
|
26330
26510
|
name: "status",
|
|
26331
|
-
description: "Filter by A2A state
|
|
26511
|
+
description: "Filter by canonical A2A state, e.g. TASK_STATE_WORKING or TASK_STATE_COMPLETED",
|
|
26332
26512
|
required: false
|
|
26333
26513
|
},
|
|
26334
26514
|
{
|
|
@@ -26338,7 +26518,7 @@ var agentTasksDomain = {
|
|
|
26338
26518
|
},
|
|
26339
26519
|
{
|
|
26340
26520
|
name: "parent-task",
|
|
26341
|
-
description: "Filter by parent
|
|
26521
|
+
description: "Filter by parent AgentTask integer ID",
|
|
26342
26522
|
required: false
|
|
26343
26523
|
},
|
|
26344
26524
|
{
|
|
@@ -27269,7 +27449,7 @@ var chatsDomain = {
|
|
|
27269
27449
|
|
|
27270
27450
|
// ../sdk/dist/helpers.js
|
|
27271
27451
|
init_chunk_6KPGCPGW();
|
|
27272
|
-
|
|
27452
|
+
init_chunk_ZLF3N3ZD();
|
|
27273
27453
|
new TextEncoder();
|
|
27274
27454
|
var WORKSPACE_EXPORT_JSON_MEMBER = "export.json";
|
|
27275
27455
|
var MAX_EXPORT_JSON_BYTES = 8 * 1024 * 1024;
|
|
@@ -29389,10 +29569,10 @@ function parseBindingsFile(payload) {
|
|
|
29389
29569
|
}
|
|
29390
29570
|
const record2 = entry;
|
|
29391
29571
|
const value = record2.value;
|
|
29392
|
-
if (typeof value !== "string"
|
|
29393
|
-
throw new CLIError(`${where}: "value" must be a string
|
|
29572
|
+
if (typeof value !== "string") {
|
|
29573
|
+
throw new CLIError(`${where}: "value" must be a string.`);
|
|
29394
29574
|
}
|
|
29395
|
-
if (
|
|
29575
|
+
if (value.length === 0) {
|
|
29396
29576
|
throw new CLIError(`${where}: "value" must not be empty.`);
|
|
29397
29577
|
}
|
|
29398
29578
|
const binding = {
|
|
@@ -30264,18 +30444,12 @@ Provisioning started. Watch it come up with:
|
|
|
30264
30444
|
name: "create-all",
|
|
30265
30445
|
description: "Auto-generate createNew entries for all entities in the export data. Use when importing into a fresh workspace.",
|
|
30266
30446
|
isFlag: true
|
|
30267
|
-
},
|
|
30268
|
-
{
|
|
30269
|
-
name: "activate-webhooks",
|
|
30270
|
-
description: "Keep imported webhook:send EventRules at their exported active state. Safety default: OFF \u2014 without this flag, an exported-active webhook rule is force-disabled on import so a cloned workspace never calls the source workspace's webhook URLs. An exported-inactive rule stays inactive either way. Only pass this once you have verified the destination should own those webhook calls.",
|
|
30271
|
-
isFlag: true
|
|
30272
30447
|
}
|
|
30273
30448
|
],
|
|
30274
30449
|
examples: [
|
|
30275
30450
|
"yarn gr workspaces import -w $UUID --env dev --file export.json --create-all",
|
|
30276
30451
|
"yarn gr workspaces import -w $UUID --env dev --file export.zip --create-all",
|
|
30277
|
-
`yarn gr workspaces import -w $UUID --env dev --data '{"exportData": ..., "createNew": ..., "importMappings": {}}'
|
|
30278
|
-
"yarn gr workspaces import -w $UUID --env dev --file export.json --create-all --activate-webhooks"
|
|
30452
|
+
`yarn gr workspaces import -w $UUID --env dev --data '{"exportData": ..., "createNew": ..., "importMappings": {}}'`
|
|
30279
30453
|
],
|
|
30280
30454
|
handler: async ({ ctx, workspace, data, args }) => {
|
|
30281
30455
|
if (!data) throw new CLIError("JSON or ZIP data required (--data, --file, or stdin)");
|
|
@@ -30294,7 +30468,6 @@ Provisioning started. Watch it come up with:
|
|
|
30294
30468
|
payload = data;
|
|
30295
30469
|
}
|
|
30296
30470
|
const createAll = args["create-all"] === true;
|
|
30297
|
-
const activateWebhooks = args["activate-webhooks"] === true;
|
|
30298
30471
|
const parsed = parseImportPayload(payload);
|
|
30299
30472
|
const { exportData, importMappings } = parsed;
|
|
30300
30473
|
const createNew = createAll ? deriveCreateNew(exportData, parsed.createNew) : parsed.createNew;
|
|
@@ -30304,7 +30477,6 @@ Provisioning started. Watch it come up with:
|
|
|
30304
30477
|
importMappings,
|
|
30305
30478
|
createNew,
|
|
30306
30479
|
archive,
|
|
30307
|
-
activateWebhooks,
|
|
30308
30480
|
// Forwarded as parsed: present when the payload carried it,
|
|
30309
30481
|
// absent otherwise. The server reads presence (see
|
|
30310
30482
|
// `ParsedImportPayload`), so this is the operator's choice of
|
|
@@ -30458,7 +30630,7 @@ Provisioning started. Watch it come up with:
|
|
|
30458
30630
|
},
|
|
30459
30631
|
{
|
|
30460
30632
|
name: "bindings-file",
|
|
30461
|
-
description: "Local JSON keyed by target workspace UUID, supplying that target's phone / inbox / Member /
|
|
30633
|
+
description: "Local JSON keyed by target workspace UUID, supplying that target's phone / inbox / Member / Routine audience. Values are sent in the request body and never printed."
|
|
30462
30634
|
},
|
|
30463
30635
|
{
|
|
30464
30636
|
name: "yes",
|
|
@@ -31692,15 +31864,6 @@ var ACTION_PARAM_HINTS = {
|
|
|
31692
31864
|
"Template vars such as {{member}} describe the event, whoever receives it."
|
|
31693
31865
|
]
|
|
31694
31866
|
},
|
|
31695
|
-
"webhook:send": {
|
|
31696
|
-
summary: "legacy: existing rules only \u2014 POST the event payload to a URL",
|
|
31697
|
-
shape: ['{"webhookUrl":"https://example.com/hook"}'],
|
|
31698
|
-
notes: [
|
|
31699
|
-
"New webhook:send rules are refused; set up new integrations under Organization \u2192 Webhooks.",
|
|
31700
|
-
"This shape is for updating an existing rule: webhookUrl must be https in production,",
|
|
31701
|
-
"and an update that omits signingSecret keeps the stored secret."
|
|
31702
|
-
]
|
|
31703
|
-
},
|
|
31704
31867
|
"assistant:message": {
|
|
31705
31868
|
summary: "inject an assistant message into the chat",
|
|
31706
31869
|
shape: [
|
|
@@ -32007,8 +32170,8 @@ ${EVENT_RULE_FIELD_REFERENCE}`,
|
|
|
32007
32170
|
"Common actionTypes: member:label, member:notify, email:send, sms:send,",
|
|
32008
32171
|
" chat:create, member:upsert",
|
|
32009
32172
|
"",
|
|
32010
|
-
"
|
|
32011
|
-
"Organization \u2192 Webhooks.
|
|
32173
|
+
"Event rules have no webhook action. To send events to an external URL, use",
|
|
32174
|
+
"organization webhooks (Organization \u2192 Webhooks).",
|
|
32012
32175
|
"",
|
|
32013
32176
|
'member:label actionParams: {"addLabelIds":["uuid"],"removeLabelIds":["uuid"]}'
|
|
32014
32177
|
]
|
|
@@ -38848,7 +39011,7 @@ var SUBSCRIPTION_COLUMNS = [
|
|
|
38848
39011
|
{ header: "PERIOD", getValue: (s) => String(s.planPeriod ?? "") },
|
|
38849
39012
|
{
|
|
38850
39013
|
header: "ORG",
|
|
38851
|
-
getValue: (s) => String(s.
|
|
39014
|
+
getValue: (s) => String(s.organizationUuid ?? "")
|
|
38852
39015
|
}
|
|
38853
39016
|
];
|
|
38854
39017
|
var CONTRACT_BEARING_STATUSES = /* @__PURE__ */ new Set([
|
|
@@ -38983,9 +39146,7 @@ Then check it landed:
|
|
|
38983
39146
|
]);
|
|
38984
39147
|
return;
|
|
38985
39148
|
}
|
|
38986
|
-
const orgUuid = String(
|
|
38987
|
-
contract.organizationUuid ?? contract.customerOrganizationUuid ?? "<org-uuid>"
|
|
38988
|
-
);
|
|
39149
|
+
const orgUuid = String(contract.organizationUuid ?? "<org-uuid>");
|
|
38989
39150
|
hint(ctx, [
|
|
38990
39151
|
"You have an active subscription. Add a workspace:",
|
|
38991
39152
|
` gr workspaces create --org ${orgUuid} --name "My Workspace"`
|
|
@@ -39021,48 +39182,48 @@ var INVOICE_COLUMNS = [
|
|
|
39021
39182
|
];
|
|
39022
39183
|
var commands = [
|
|
39023
39184
|
{
|
|
39024
|
-
path: ["billing", "
|
|
39025
|
-
description: "List
|
|
39185
|
+
path: ["billing", "organizations"],
|
|
39186
|
+
description: "List Organizations where you have billing access",
|
|
39026
39187
|
requiresWorkspace: false,
|
|
39027
39188
|
handler: async (hctx) => {
|
|
39028
|
-
const result3 = await requireAuth(hctx.ctx).apiClient.
|
|
39189
|
+
const result3 = await requireAuth(hctx.ctx).apiClient.getBillingOrganizations();
|
|
39029
39190
|
outputData(listResult(result3, false), hctx.ctx);
|
|
39030
39191
|
}
|
|
39031
39192
|
},
|
|
39032
39193
|
{
|
|
39033
|
-
path: ["billing", "
|
|
39034
|
-
description: "Get
|
|
39035
|
-
args: [
|
|
39194
|
+
path: ["org", "billing", "profile"],
|
|
39195
|
+
description: "Get this Organization\u2019s billing profile",
|
|
39196
|
+
args: [ORG_UUID_ARG],
|
|
39036
39197
|
requiresWorkspace: false,
|
|
39037
39198
|
handler: async (hctx) => {
|
|
39038
|
-
const uuid = hctx.args
|
|
39039
|
-
const result3 = await requireAuth(hctx.ctx).apiClient.
|
|
39199
|
+
const uuid = requireOrgRef(hctx.args);
|
|
39200
|
+
const result3 = await requireAuth(hctx.ctx).apiClient.getOrganizationBilling(uuid);
|
|
39040
39201
|
outputSingle(result3, hctx.ctx);
|
|
39041
39202
|
}
|
|
39042
39203
|
},
|
|
39043
39204
|
{
|
|
39044
|
-
path: ["billing", "update-
|
|
39045
|
-
description: "Update
|
|
39205
|
+
path: ["org", "billing", "update-profile"],
|
|
39206
|
+
description: "Update this Organization\u2019s invoice details and billing email",
|
|
39046
39207
|
mutates: true,
|
|
39047
39208
|
args: [
|
|
39048
|
-
|
|
39049
|
-
{ name: "name", description: "
|
|
39209
|
+
ORG_UUID_ARG,
|
|
39210
|
+
{ name: "name", description: "Invoice name" },
|
|
39050
39211
|
{ name: "email", description: "Billing email" },
|
|
39051
39212
|
{ name: "phone", description: "Phone number" },
|
|
39052
39213
|
{ name: "description", description: "Description / notes" }
|
|
39053
39214
|
],
|
|
39054
39215
|
requiresWorkspace: false,
|
|
39055
39216
|
handler: async (hctx) => {
|
|
39056
|
-
const uuid = hctx.args
|
|
39217
|
+
const uuid = requireOrgRef(hctx.args);
|
|
39057
39218
|
const data = {};
|
|
39058
39219
|
if (hctx.args.name) data.name = hctx.args.name;
|
|
39059
|
-
if (hctx.args.email) data.
|
|
39220
|
+
if (hctx.args.email) data.billingEmail = hctx.args.email;
|
|
39060
39221
|
if (hctx.args.phone) data.phone = hctx.args.phone;
|
|
39061
39222
|
if (hctx.args.description) data.description = hctx.args.description;
|
|
39062
39223
|
if (Object.keys(data).length === 0 && !hctx.data) {
|
|
39063
39224
|
throw new CLIError("Provide --name, --email, --phone, --description, or JSON data");
|
|
39064
39225
|
}
|
|
39065
|
-
const result3 = await requireAuth(hctx.ctx).apiClient.
|
|
39226
|
+
const result3 = await requireAuth(hctx.ctx).apiClient.updateOrganizationBilling(
|
|
39066
39227
|
uuid,
|
|
39067
39228
|
hctx.data ? hctx.data : data
|
|
39068
39229
|
);
|
|
@@ -39070,31 +39231,33 @@ var commands = [
|
|
|
39070
39231
|
}
|
|
39071
39232
|
},
|
|
39072
39233
|
{
|
|
39073
|
-
path: ["billing", "invoices"],
|
|
39074
|
-
description: "List
|
|
39075
|
-
args: [
|
|
39234
|
+
path: ["org", "billing", "invoices"],
|
|
39235
|
+
description: "List this Organization\u2019s invoices",
|
|
39236
|
+
args: [ORG_UUID_ARG],
|
|
39076
39237
|
requiresWorkspace: false,
|
|
39077
39238
|
handler: async (hctx) => {
|
|
39078
|
-
const uuid = hctx.args
|
|
39079
|
-
const result3 = await requireAuth(hctx.ctx).apiClient.
|
|
39239
|
+
const uuid = requireOrgRef(hctx.args);
|
|
39240
|
+
const result3 = await requireAuth(hctx.ctx).apiClient.getOrganizationInvoices(uuid);
|
|
39080
39241
|
outputData(listResult(result3, false), hctx.ctx, INVOICE_COLUMNS);
|
|
39081
39242
|
}
|
|
39082
39243
|
},
|
|
39083
39244
|
{
|
|
39084
|
-
path: ["billing", "subscriptions"],
|
|
39085
|
-
description: "List
|
|
39086
|
-
args: [
|
|
39245
|
+
path: ["org", "billing", "subscriptions"],
|
|
39246
|
+
description: "List this Organization\u2019s subscriptions",
|
|
39247
|
+
args: [ORG_UUID_ARG],
|
|
39087
39248
|
requiresWorkspace: false,
|
|
39088
39249
|
handler: async (hctx) => {
|
|
39089
|
-
const uuid = hctx.args
|
|
39090
|
-
const result3 = await requireAuth(hctx.ctx).apiClient.
|
|
39250
|
+
const uuid = requireOrgRef(hctx.args);
|
|
39251
|
+
const result3 = await requireAuth(hctx.ctx).apiClient.getOrganizationBillingSubscriptions(
|
|
39252
|
+
uuid
|
|
39253
|
+
);
|
|
39091
39254
|
outputData(listResult(result3, false), hctx.ctx);
|
|
39092
39255
|
}
|
|
39093
39256
|
}
|
|
39094
39257
|
];
|
|
39095
39258
|
var billingPortalDomain = {
|
|
39096
39259
|
name: "billing",
|
|
39097
|
-
description: "
|
|
39260
|
+
description: "Organization billing, invoices and subscriptions",
|
|
39098
39261
|
commands
|
|
39099
39262
|
};
|
|
39100
39263
|
|
|
@@ -39834,11 +39997,11 @@ init_errors();
|
|
|
39834
39997
|
init_output();
|
|
39835
39998
|
async function subject(hctx) {
|
|
39836
39999
|
const auth = requireAuth(hctx.ctx);
|
|
39837
|
-
const billing = await auth.apiClient.
|
|
39838
|
-
if (!billing.hasAccess
|
|
39839
|
-
throw new CLIError("
|
|
40000
|
+
const billing = await auth.apiClient.getOrgBillingAccess(requireOrgRef(hctx.args));
|
|
40001
|
+
if (!billing.hasAccess) {
|
|
40002
|
+
throw new CLIError("Billing access on this organization is required");
|
|
39840
40003
|
}
|
|
39841
|
-
return { auth, billing };
|
|
40004
|
+
return { auth, billing, orgUuid: requireOrgRef(hctx.args) };
|
|
39842
40005
|
}
|
|
39843
40006
|
var orgBillingCommands = [
|
|
39844
40007
|
{
|
|
@@ -39846,14 +40009,8 @@ var orgBillingCommands = [
|
|
|
39846
40009
|
description: "Read only this organization\u2019s billable subscription",
|
|
39847
40010
|
args: [ORG_UUID_ARG],
|
|
39848
40011
|
handler: async (hctx) => {
|
|
39849
|
-
const { auth,
|
|
39850
|
-
outputSingle(
|
|
39851
|
-
await auth.apiClient.getMyCustomerSubscriptions(billing.customerUuid, {
|
|
39852
|
-
subscriptionId: billing.subscriptionId,
|
|
39853
|
-
pageSize: 1
|
|
39854
|
-
}),
|
|
39855
|
-
hctx.ctx
|
|
39856
|
-
);
|
|
40012
|
+
const { auth, orgUuid } = await subject(hctx);
|
|
40013
|
+
outputSingle(await auth.apiClient.getOrganizationSubscription(orgUuid), hctx.ctx);
|
|
39857
40014
|
}
|
|
39858
40015
|
},
|
|
39859
40016
|
{
|
|
@@ -39863,18 +40020,18 @@ var orgBillingCommands = [
|
|
|
39863
40020
|
mutates: true,
|
|
39864
40021
|
acceptsJsonInput: true,
|
|
39865
40022
|
handler: async (hctx) => {
|
|
39866
|
-
const { auth,
|
|
40023
|
+
const { auth, orgUuid } = await subject(hctx);
|
|
39867
40024
|
if (!hctx.data || typeof hctx.data !== "object" || Array.isArray(hctx.data))
|
|
39868
40025
|
throw new CLIError("Provide credit settings as a JSON object with --data");
|
|
39869
40026
|
outputSingle(
|
|
39870
|
-
await auth.apiClient.
|
|
40027
|
+
await auth.apiClient.updateOrganizationCreditSettings(orgUuid, hctx.data),
|
|
39871
40028
|
hctx.ctx
|
|
39872
40029
|
);
|
|
39873
40030
|
}
|
|
39874
40031
|
},
|
|
39875
40032
|
{
|
|
39876
40033
|
path: ["org", "billing", "purchase-credits"],
|
|
39877
|
-
description: "Purchase extra credits for this organization (charges the
|
|
40034
|
+
description: "Purchase extra credits for this organization (charges the Organization\u2019s payment method)",
|
|
39878
40035
|
args: [
|
|
39879
40036
|
ORG_UUID_ARG,
|
|
39880
40037
|
{ name: "amount-cents", description: "Amount to charge in cents", required: true },
|
|
@@ -39885,13 +40042,13 @@ var orgBillingCommands = [
|
|
|
39885
40042
|
],
|
|
39886
40043
|
mutates: true,
|
|
39887
40044
|
handler: async (hctx) => {
|
|
39888
|
-
const { auth,
|
|
40045
|
+
const { auth, orgUuid } = await subject(hctx);
|
|
39889
40046
|
const amount = Number(hctx.args["amount-cents"]);
|
|
39890
40047
|
if (!Number.isInteger(amount) || amount < 100 || amount > 1e7)
|
|
39891
40048
|
throw new CLIError("Use an integer amount between 100 and 10000000 cents");
|
|
39892
40049
|
outputSingle(
|
|
39893
|
-
await auth.apiClient.
|
|
39894
|
-
|
|
40050
|
+
await auth.apiClient.purchaseOrganizationCredits(
|
|
40051
|
+
orgUuid,
|
|
39895
40052
|
amount,
|
|
39896
40053
|
hctx.args["idempotency-key"]
|
|
39897
40054
|
),
|
|
@@ -47421,6 +47578,58 @@ var hubspotDomain = {
|
|
|
47421
47578
|
name: "hubspot",
|
|
47422
47579
|
description: "HubSpot CRM integration",
|
|
47423
47580
|
commands: [
|
|
47581
|
+
{
|
|
47582
|
+
path: ["hubspot", "calendar", "bind"],
|
|
47583
|
+
description: "Link a native calendar to a HubSpot scheduling link",
|
|
47584
|
+
requiresWorkspace: true,
|
|
47585
|
+
mutates: true,
|
|
47586
|
+
args: [
|
|
47587
|
+
{ name: "calendar-id", description: "Native Calendar ID", required: true },
|
|
47588
|
+
{ name: "link-id", description: "HubSpot scheduling link ID", required: true }
|
|
47589
|
+
],
|
|
47590
|
+
handler: async ({ ctx, workspace, args }) => {
|
|
47591
|
+
await requireAuth(ctx).apiClient.bindHubspotCalendar(
|
|
47592
|
+
workspace,
|
|
47593
|
+
requireNumber(args, "calendar-id"),
|
|
47594
|
+
requireString(args, "link-id")
|
|
47595
|
+
);
|
|
47596
|
+
outputSingle({ status: "linked" }, ctx);
|
|
47597
|
+
}
|
|
47598
|
+
},
|
|
47599
|
+
{
|
|
47600
|
+
path: ["hubspot", "calendar", "unlink"],
|
|
47601
|
+
description: "Unlink a native calendar from HubSpot",
|
|
47602
|
+
requiresWorkspace: true,
|
|
47603
|
+
mutates: true,
|
|
47604
|
+
args: [{ name: "calendar-id", description: "Native Calendar ID", required: true }],
|
|
47605
|
+
handler: async ({ ctx, workspace, args }) => {
|
|
47606
|
+
await requireAuth(ctx).apiClient.unlinkHubspotCalendar(
|
|
47607
|
+
workspace,
|
|
47608
|
+
requireNumber(args, "calendar-id")
|
|
47609
|
+
);
|
|
47610
|
+
outputSingle({ status: "unlinked" }, ctx);
|
|
47611
|
+
}
|
|
47612
|
+
},
|
|
47613
|
+
{
|
|
47614
|
+
path: ["hubspot", "calendar", "import"],
|
|
47615
|
+
description: "Import one page of bookings into native CalendarEvents; repeat while complete is false. Sends no invitations.",
|
|
47616
|
+
requiresWorkspace: true,
|
|
47617
|
+
mutates: true,
|
|
47618
|
+
args: [
|
|
47619
|
+
{ name: "calendar-id", description: "Native Calendar ID", required: true },
|
|
47620
|
+
{ name: "event-type-id", description: "Native CalendarEventType ID", required: true }
|
|
47621
|
+
],
|
|
47622
|
+
handler: async ({ ctx, workspace, args }) => {
|
|
47623
|
+
outputSingle(
|
|
47624
|
+
await requireAuth(ctx).apiClient.importHubspotCalendarEvents(
|
|
47625
|
+
workspace,
|
|
47626
|
+
requireNumber(args, "calendar-id"),
|
|
47627
|
+
requireNumber(args, "event-type-id")
|
|
47628
|
+
),
|
|
47629
|
+
ctx
|
|
47630
|
+
);
|
|
47631
|
+
}
|
|
47632
|
+
},
|
|
47424
47633
|
{
|
|
47425
47634
|
path: ["hubspot", "booking-deals", "receipt"],
|
|
47426
47635
|
description: "Inspect a booking receipt before operator recovery",
|