@gravity-rail/cli 0.3.0 → 0.4.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/README.md +29 -1
- package/dist/{chunk-OIFV7TAT.js → chunk-C6D4FO6A.js} +25 -5
- package/dist/chunk-C6D4FO6A.js.map +1 -0
- package/dist/cli-utils.js +1 -1
- package/dist/gr.js +2207 -214
- package/dist/gr.js.map +1 -1
- package/dist/lib.d.ts +3 -2
- package/dist/lib.js +1888 -50
- package/dist/lib.js.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-OIFV7TAT.js.map +0 -1
package/dist/lib.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AGUIClient,
|
|
3
3
|
CredentialsManager,
|
|
4
|
+
__export,
|
|
5
|
+
__reExport,
|
|
4
6
|
clearScreen,
|
|
5
7
|
formatTimestamp,
|
|
6
8
|
getEnvironmentConfig,
|
|
@@ -11,7 +13,7 @@ import {
|
|
|
11
13
|
printTable,
|
|
12
14
|
refreshAccessToken,
|
|
13
15
|
selectFromList
|
|
14
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-C6D4FO6A.js";
|
|
15
17
|
|
|
16
18
|
// src/lib/errors.ts
|
|
17
19
|
var CLIError = class extends Error {
|
|
@@ -264,8 +266,1460 @@ function findDef(defs, arg) {
|
|
|
264
266
|
return void 0;
|
|
265
267
|
}
|
|
266
268
|
|
|
267
|
-
//
|
|
269
|
+
// ../client/dist/index.mjs
|
|
270
|
+
var dist_exports = {};
|
|
271
|
+
__export(dist_exports, {
|
|
272
|
+
AdminApi: () => AdminApi,
|
|
273
|
+
ApiClient: () => ApiClient,
|
|
274
|
+
bindAdminMethods: () => bindAdminMethods
|
|
275
|
+
});
|
|
276
|
+
__reExport(dist_exports, internal_star);
|
|
277
|
+
import * as internal_star from "@gravity-rail/sdk/internal";
|
|
278
|
+
import { BaseApiClient } from "@gravity-rail/sdk/internal";
|
|
268
279
|
import { GravityRailClient } from "@gravity-rail/sdk";
|
|
280
|
+
var AdminApi = class extends BaseApiClient {
|
|
281
|
+
// Admin Accounts API
|
|
282
|
+
async getAccounts(options) {
|
|
283
|
+
const params = new URLSearchParams();
|
|
284
|
+
if (options.search) params.append("search", options.search);
|
|
285
|
+
if (options.createdAfter) params.append("created_after", options.createdAfter);
|
|
286
|
+
if (options.createdBefore) params.append("created_before", options.createdBefore);
|
|
287
|
+
if (options.sortBy) params.append("sortBy", options.sortBy);
|
|
288
|
+
if (options.sortOrder) params.append("sortOrder", options.sortOrder);
|
|
289
|
+
if (options.page) params.append("page", options.page.toString());
|
|
290
|
+
if (options.pageSize) params.append("pageSize", options.pageSize.toString());
|
|
291
|
+
if (options.isActive !== void 0) params.append("isActive", options.isActive.toString());
|
|
292
|
+
if (options.organizationId !== void 0)
|
|
293
|
+
params.append("organizationId", options.organizationId.toString());
|
|
294
|
+
if (options.pendingDeletion !== void 0)
|
|
295
|
+
params.append("pendingDeletion", options.pendingDeletion.toString());
|
|
296
|
+
return this.fetch(`admin/accounts?${params.toString()}`);
|
|
297
|
+
}
|
|
298
|
+
async getAccountDetails(id) {
|
|
299
|
+
return this.fetch(`admin/accounts/${id}`);
|
|
300
|
+
}
|
|
301
|
+
async getAccountByUuid(uuid) {
|
|
302
|
+
return this.fetch(`admin/accounts/${uuid}`);
|
|
303
|
+
}
|
|
304
|
+
async getAccountMemberships(accountId) {
|
|
305
|
+
return this.fetch(`admin/accounts/${accountId}/memberships`);
|
|
306
|
+
}
|
|
307
|
+
async getAccountOrgMemberships(accountId) {
|
|
308
|
+
return this.fetch(`admin/accounts/${accountId}/org-memberships`);
|
|
309
|
+
}
|
|
310
|
+
async createAccountOrgMembership(accountId, organizationId, role = "member") {
|
|
311
|
+
return this.fetch(`admin/accounts/${accountId}/org-memberships`, {
|
|
312
|
+
method: "POST",
|
|
313
|
+
body: JSON.stringify({ organizationId, role })
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
async deleteAccountOrgMembership(accountId, organizationId) {
|
|
317
|
+
return this.fetch(`admin/accounts/${accountId}/org-memberships/${organizationId}`, {
|
|
318
|
+
method: "DELETE"
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
async getAccountMembership(accountId, workspaceId) {
|
|
322
|
+
return this.fetch(
|
|
323
|
+
`admin/accounts/${accountId}/memberships/${workspaceId}`
|
|
324
|
+
);
|
|
325
|
+
}
|
|
326
|
+
async updateAccountMembership(accountId, workspaceId, updates) {
|
|
327
|
+
return this.fetch(
|
|
328
|
+
`admin/accounts/${accountId}/memberships/${workspaceId}`,
|
|
329
|
+
{
|
|
330
|
+
method: "PUT",
|
|
331
|
+
body: JSON.stringify(updates)
|
|
332
|
+
}
|
|
333
|
+
);
|
|
334
|
+
}
|
|
335
|
+
async createAccountMembership(accountId, workspaceId, data) {
|
|
336
|
+
return this.fetch(
|
|
337
|
+
`admin/accounts/${accountId}/memberships/${workspaceId}`,
|
|
338
|
+
{
|
|
339
|
+
method: "POST",
|
|
340
|
+
body: JSON.stringify(data)
|
|
341
|
+
}
|
|
342
|
+
);
|
|
343
|
+
}
|
|
344
|
+
async deleteAccountMembership(accountId, workspaceId) {
|
|
345
|
+
return this.fetch(`admin/accounts/${accountId}/memberships/${workspaceId}`, {
|
|
346
|
+
method: "DELETE"
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
async updateAccountAsAdmin(id, updates) {
|
|
350
|
+
return this.fetch(`admin/accounts/${id}`, {
|
|
351
|
+
method: "PUT",
|
|
352
|
+
body: JSON.stringify(updates)
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
async createAccountAsAdmin(data) {
|
|
356
|
+
return this.fetch("admin/accounts", {
|
|
357
|
+
method: "POST",
|
|
358
|
+
body: JSON.stringify(data)
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
async deleteAccountAsAdmin(id) {
|
|
362
|
+
return this.fetch(`admin/accounts/${id}`, {
|
|
363
|
+
method: "DELETE"
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
// GDPR Data Subject Rights (superuser only)
|
|
367
|
+
async exportAccountData(accountId) {
|
|
368
|
+
return this.fetch(`admin/data-rights/${accountId}/export`, {
|
|
369
|
+
method: "POST"
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
async requestAccountDeletion(accountId) {
|
|
373
|
+
return this.fetch(`admin/data-rights/${accountId}/delete`, {
|
|
374
|
+
method: "POST"
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
async cancelAccountDeletion(accountId) {
|
|
378
|
+
return this.fetch(`admin/data-rights/${accountId}/cancel-delete`, {
|
|
379
|
+
method: "POST"
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Look up an account by email or phone. Returns verification status.
|
|
384
|
+
* Used to check if a verified account exists before creating a new one.
|
|
385
|
+
*/
|
|
386
|
+
async lookupAccount(options) {
|
|
387
|
+
const params = new URLSearchParams();
|
|
388
|
+
if (options.email) params.append("email", options.email);
|
|
389
|
+
if (options.phone) params.append("phone", options.phone);
|
|
390
|
+
return this.fetch(`admin/accounts/lookup?${params.toString()}`);
|
|
391
|
+
}
|
|
392
|
+
// Admin Organizations API
|
|
393
|
+
async getOrganizations(options) {
|
|
394
|
+
const params = new URLSearchParams();
|
|
395
|
+
if (options?.search) params.append("search", options.search);
|
|
396
|
+
if (options?.page) params.append("page", options.page.toString());
|
|
397
|
+
if (options?.pageSize) params.append("pageSize", options.pageSize.toString());
|
|
398
|
+
if (options?.noSubscription) params.append("no_subscription", "true");
|
|
399
|
+
if (options?.sortBy) params.append("sortBy", options.sortBy);
|
|
400
|
+
if (options?.sortOrder) params.append("sortOrder", options.sortOrder);
|
|
401
|
+
return this.fetch(
|
|
402
|
+
`admin/organizations?${params.toString()}`
|
|
403
|
+
);
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* Get organization by ID or UUID.
|
|
407
|
+
* Returns different response based on user's role:
|
|
408
|
+
* - Admins/Owners: AdminOrganization with full details
|
|
409
|
+
* - Members: MemberOrgView with basic info and workspace list
|
|
410
|
+
*
|
|
411
|
+
* Use `viewType` field to determine the response type:
|
|
412
|
+
* - 'admin': AdminOrganization
|
|
413
|
+
* - 'member': MemberOrgView
|
|
414
|
+
*/
|
|
415
|
+
async getOrganization(idOrUuid) {
|
|
416
|
+
return this.fetch(`o/${idOrUuid}`);
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* Get organization by numeric ID via admin endpoint.
|
|
420
|
+
* Does NOT require organization membership — superuser-only.
|
|
421
|
+
*/
|
|
422
|
+
async getOrganizationAsAdmin(id) {
|
|
423
|
+
return this.fetch(`admin/organizations/${id}`);
|
|
424
|
+
}
|
|
425
|
+
async getOrganizationMembersAsAdmin(organizationId, options) {
|
|
426
|
+
const params = new URLSearchParams();
|
|
427
|
+
if (options?.search) params.append("search", options.search);
|
|
428
|
+
if (options?.role) params.append("role", options.role);
|
|
429
|
+
if (options?.page) params.append("page", options.page.toString());
|
|
430
|
+
if (options?.pageSize) params.append("pageSize", options.pageSize.toString());
|
|
431
|
+
const qs = params.toString();
|
|
432
|
+
return this.fetch(
|
|
433
|
+
`admin/organizations/${organizationId}/members${qs ? `?${qs}` : ""}`
|
|
434
|
+
);
|
|
435
|
+
}
|
|
436
|
+
async createOrganization(data) {
|
|
437
|
+
return this.fetch("admin/organizations", {
|
|
438
|
+
method: "POST",
|
|
439
|
+
body: JSON.stringify(data)
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
async updateOrganization(id, data) {
|
|
443
|
+
return this.fetch(`admin/organizations/${id}`, {
|
|
444
|
+
method: "PUT",
|
|
445
|
+
body: JSON.stringify(data)
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
async deleteOrganization(id) {
|
|
449
|
+
return this.fetch(`admin/organizations/${id}`, {
|
|
450
|
+
method: "DELETE"
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* Join an organization with a specified role (superuser only).
|
|
455
|
+
* Creates or updates membership in the target org.
|
|
456
|
+
* @param orgUuid - Organization UUID or numeric ID as string
|
|
457
|
+
*/
|
|
458
|
+
async joinOrganization(orgUuid, role = "owner") {
|
|
459
|
+
return this.fetch(`admin/organizations/${orgUuid}/join`, {
|
|
460
|
+
method: "POST",
|
|
461
|
+
body: JSON.stringify({ role })
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Leave an organization (superuser only).
|
|
466
|
+
* @param orgUuid - Organization UUID or numeric ID as string
|
|
467
|
+
*/
|
|
468
|
+
async leaveOrganization(orgUuid) {
|
|
469
|
+
return this.fetch(`admin/organizations/${orgUuid}/join`, {
|
|
470
|
+
method: "DELETE"
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
async generateLogoUploadUrl(organizationUuid, data) {
|
|
474
|
+
return this.fetch(`o/${organizationUuid}/logo-upload-url`, {
|
|
475
|
+
method: "POST",
|
|
476
|
+
body: JSON.stringify(data)
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
// Organization Members API - moved to OrgApi at /api/v2/o/{org_uuid}/members
|
|
480
|
+
// See packages/client/src/api/org.ts
|
|
481
|
+
// Organization Invitations API - moved to OrgApi at /api/v2/o/{org_uuid}/invitations
|
|
482
|
+
// See packages/client/src/api/org.ts
|
|
483
|
+
// Admin Products API
|
|
484
|
+
async importProducts(workspaceId) {
|
|
485
|
+
return this.fetch("admin/import-products", {
|
|
486
|
+
method: "POST",
|
|
487
|
+
body: JSON.stringify({ workspaceId })
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
// ===== Product CRUD =====
|
|
491
|
+
async createProductAsAdmin(product) {
|
|
492
|
+
return this.fetch("admin/products", {
|
|
493
|
+
method: "POST",
|
|
494
|
+
body: JSON.stringify(product)
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
async getProductsAsAdmin(workspaceUuid, productTypes) {
|
|
498
|
+
const params = new URLSearchParams();
|
|
499
|
+
if (workspaceUuid) {
|
|
500
|
+
params.append("workspace_uuid", workspaceUuid);
|
|
501
|
+
}
|
|
502
|
+
if (productTypes && productTypes.length > 0) {
|
|
503
|
+
productTypes.forEach((type) => params.append("product_types", type));
|
|
504
|
+
}
|
|
505
|
+
const queryString = params.toString();
|
|
506
|
+
return this.fetch(`admin/products${queryString ? `?${queryString}` : ""}`);
|
|
507
|
+
}
|
|
508
|
+
async getProductAsAdmin(productId) {
|
|
509
|
+
return this.fetch(`admin/products/${productId}`);
|
|
510
|
+
}
|
|
511
|
+
async updateProductAsAdmin(product_id, product) {
|
|
512
|
+
return this.fetch(`admin/products/${product_id}`, {
|
|
513
|
+
method: "PUT",
|
|
514
|
+
body: JSON.stringify(product)
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
async deleteProductAsAdmin(productId) {
|
|
518
|
+
return this.fetch(`admin/products/${productId}`, {
|
|
519
|
+
method: "DELETE"
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
// Admin Workspace API
|
|
523
|
+
async getWorkspacesAsAdmin(options = {}) {
|
|
524
|
+
const params = new URLSearchParams();
|
|
525
|
+
if (options.page !== void 0) params.append("page", options.page.toString());
|
|
526
|
+
if (options.pageSize !== void 0) params.append("pageSize", options.pageSize.toString());
|
|
527
|
+
if (options.sortBy) params.append("sortBy", options.sortBy);
|
|
528
|
+
if (options.sortOrder) params.append("sortOrder", options.sortOrder);
|
|
529
|
+
if (options.search) params.append("search", options.search);
|
|
530
|
+
if (options.isReseller !== void 0)
|
|
531
|
+
params.append("isReseller", options.isReseller.toString());
|
|
532
|
+
if (options.organizationId !== void 0)
|
|
533
|
+
params.append("organizationId", options.organizationId.toString());
|
|
534
|
+
if (options.noActiveSubscription) params.append("noActiveSubscription", "true");
|
|
535
|
+
return this.fetch(`admin/workspaces?${params.toString()}`);
|
|
536
|
+
}
|
|
537
|
+
async getWorkspaceAsAdmin(wid) {
|
|
538
|
+
return this.fetch(`admin/workspaces/${wid}`);
|
|
539
|
+
}
|
|
540
|
+
async getWorkspaceByNumericIdAsAdmin(workspace_id) {
|
|
541
|
+
return this.fetch(`admin/workspaces/id/${workspace_id}`);
|
|
542
|
+
}
|
|
543
|
+
async createWorkspaceAsAdmin(ws) {
|
|
544
|
+
return this.fetch("admin/workspaces", {
|
|
545
|
+
method: "POST",
|
|
546
|
+
body: JSON.stringify(ws)
|
|
547
|
+
});
|
|
548
|
+
}
|
|
549
|
+
async updateWorkspaceAsAdmin(wid, ws) {
|
|
550
|
+
return this.fetch(`admin/workspaces/${wid}`, {
|
|
551
|
+
method: "PUT",
|
|
552
|
+
body: JSON.stringify(ws)
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
async deleteWorkspaceAsAdmin(wid) {
|
|
556
|
+
return this.fetch(`admin/workspaces/${wid}`, {
|
|
557
|
+
method: "DELETE"
|
|
558
|
+
});
|
|
559
|
+
}
|
|
560
|
+
async createSchemaAsAdmin(wid) {
|
|
561
|
+
return this.fetch(`admin/workspaces/${wid}/provision/create`, {
|
|
562
|
+
method: "POST"
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
async migrateSchemaAsAdmin(wid) {
|
|
566
|
+
return this.fetch(`admin/workspaces/${wid}/provision/migrate`, {
|
|
567
|
+
method: "POST"
|
|
568
|
+
});
|
|
569
|
+
}
|
|
570
|
+
async provisionWorkspaceAsAdmin(wid) {
|
|
571
|
+
return this.fetch(`admin/workspaces/${wid}/provision`, {
|
|
572
|
+
method: "POST"
|
|
573
|
+
});
|
|
574
|
+
}
|
|
575
|
+
async refreshProvisionStatusAsAdmin(wid) {
|
|
576
|
+
return this.fetch(`admin/workspaces/${wid}/provision/refresh`, {
|
|
577
|
+
method: "POST"
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
async enableMaintenanceMode(wid) {
|
|
581
|
+
return this.fetch(`admin/workspaces/${wid}/maintenance`, {
|
|
582
|
+
method: "PUT"
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
async disableMaintenanceMode(wid) {
|
|
586
|
+
return this.fetch(`admin/workspaces/${wid}/maintenance`, {
|
|
587
|
+
method: "DELETE"
|
|
588
|
+
});
|
|
589
|
+
}
|
|
590
|
+
// ===== Workspace Health Check =====
|
|
591
|
+
async getWorkspaceHealth(workspaceUuid) {
|
|
592
|
+
return this.fetch(`admin/workspaces/${workspaceUuid}/health`);
|
|
593
|
+
}
|
|
594
|
+
async provisionPlanFeatures(workspaceUuid, request) {
|
|
595
|
+
return this.fetch(`admin/workspaces/${workspaceUuid}/provision-plan`, {
|
|
596
|
+
method: "POST",
|
|
597
|
+
body: JSON.stringify(request || {})
|
|
598
|
+
});
|
|
599
|
+
}
|
|
600
|
+
// ===== Workflow Access Validation =====
|
|
601
|
+
async validateWorkflowAccessAsAdmin(workspaceUuid) {
|
|
602
|
+
const params = new URLSearchParams();
|
|
603
|
+
if (workspaceUuid) params.append("workspace_uuid", workspaceUuid);
|
|
604
|
+
const qs = params.toString();
|
|
605
|
+
return this.fetch(
|
|
606
|
+
`admin/workspaces/validate-workflow-access${qs ? `?${qs}` : ""}`
|
|
607
|
+
);
|
|
608
|
+
}
|
|
609
|
+
async mergeMembers(wid, request) {
|
|
610
|
+
return this.fetch(`admin/workspaces/${wid}/merge-members`, {
|
|
611
|
+
method: "POST",
|
|
612
|
+
body: JSON.stringify(request)
|
|
613
|
+
});
|
|
614
|
+
}
|
|
615
|
+
async getAdminWorkspaceMember(wid) {
|
|
616
|
+
return this.fetch(`admin/workspaces/${wid}/me`, {
|
|
617
|
+
method: "GET"
|
|
618
|
+
});
|
|
619
|
+
}
|
|
620
|
+
async createAdminWorkspaceMember(wid, data) {
|
|
621
|
+
return this.fetch(`admin/workspaces/${wid}/me`, {
|
|
622
|
+
method: "POST",
|
|
623
|
+
body: JSON.stringify(data)
|
|
624
|
+
});
|
|
625
|
+
}
|
|
626
|
+
async updateAdminWorkspaceMember(wid, data) {
|
|
627
|
+
return this.fetch(`admin/workspaces/${wid}/me`, {
|
|
628
|
+
method: "PUT",
|
|
629
|
+
body: JSON.stringify(data)
|
|
630
|
+
});
|
|
631
|
+
}
|
|
632
|
+
async getAdminWorkspaceMemberRoles(wid) {
|
|
633
|
+
return this.fetch(`admin/workspaces/${wid}/member-roles`);
|
|
634
|
+
}
|
|
635
|
+
async getUnmappedPhoneNumbers() {
|
|
636
|
+
return this.fetch(`admin/phone-numbers/unmapped`);
|
|
637
|
+
}
|
|
638
|
+
async getWorkspaceUnmappedPhoneNumbers(workspaceId) {
|
|
639
|
+
return this.fetch(
|
|
640
|
+
`admin/phone-numbers/workspace/${workspaceId}/unmapped`
|
|
641
|
+
);
|
|
642
|
+
}
|
|
643
|
+
async getWorkspacePhoneNumbersAsAdmin(workspaceId) {
|
|
644
|
+
return this.fetch(`admin/workspace/${workspaceId}/phone-numbers`);
|
|
645
|
+
}
|
|
646
|
+
// Phone Numbers API (Provider phone numbers from Twilio, AWS, etc.)
|
|
647
|
+
async getProviderPhoneNumbers(options = {}) {
|
|
648
|
+
const params = new URLSearchParams();
|
|
649
|
+
if (options.page) params.append("page", options.page.toString());
|
|
650
|
+
if (options.pageSize) params.append("pageSize", options.pageSize.toString());
|
|
651
|
+
if (options.search) params.append("search", options.search);
|
|
652
|
+
if (options.isAssigned !== void 0)
|
|
653
|
+
params.append("is_assigned", String(options.isAssigned));
|
|
654
|
+
if (options.provider) params.append("provider", options.provider);
|
|
655
|
+
if (options.organizationId !== void 0)
|
|
656
|
+
params.append("organizationId", options.organizationId.toString());
|
|
657
|
+
if (options.sortBy) params.append("sortBy", options.sortBy);
|
|
658
|
+
if (options.sortOrder) params.append("sortOrder", options.sortOrder);
|
|
659
|
+
return this.fetch(
|
|
660
|
+
`admin/phone-numbers${params.toString() ? `?${params.toString()}` : ""}`
|
|
661
|
+
);
|
|
662
|
+
}
|
|
663
|
+
async getProviderPhoneNumber(id) {
|
|
664
|
+
return this.fetch(`admin/phone-numbers/${id}`);
|
|
665
|
+
}
|
|
666
|
+
async updateProviderPhoneNumber(id, data) {
|
|
667
|
+
return this.fetch(`admin/phone-numbers/${id}`, {
|
|
668
|
+
method: "PATCH",
|
|
669
|
+
body: JSON.stringify(data)
|
|
670
|
+
});
|
|
671
|
+
}
|
|
672
|
+
async mapMainAccountPhone(data) {
|
|
673
|
+
return this.fetch(`admin/phone-numbers/map-from-main-account`, {
|
|
674
|
+
method: "POST",
|
|
675
|
+
body: JSON.stringify(data)
|
|
676
|
+
});
|
|
677
|
+
}
|
|
678
|
+
async unmapPhoneNumber(data) {
|
|
679
|
+
return this.fetch(`admin/phone-numbers/unmap`, {
|
|
680
|
+
method: "POST",
|
|
681
|
+
body: JSON.stringify(data)
|
|
682
|
+
});
|
|
683
|
+
}
|
|
684
|
+
async searchAvailablePhoneNumbersAsAdmin(data) {
|
|
685
|
+
return this.fetch(`admin/phone-numbers/search`, {
|
|
686
|
+
method: "POST",
|
|
687
|
+
body: JSON.stringify(data)
|
|
688
|
+
});
|
|
689
|
+
}
|
|
690
|
+
async purchasePhoneNumberAsAdmin(data) {
|
|
691
|
+
return this.fetch(`admin/phone-numbers/purchase`, {
|
|
692
|
+
method: "POST",
|
|
693
|
+
body: JSON.stringify(data)
|
|
694
|
+
});
|
|
695
|
+
}
|
|
696
|
+
async getOrgA2PStatusAsAdmin(organizationId) {
|
|
697
|
+
return this.fetch(`admin/organizations/${organizationId}/a2p-status`);
|
|
698
|
+
}
|
|
699
|
+
async resetOrgA2PStatusAsAdmin(organizationId) {
|
|
700
|
+
return this.fetch(`admin/organizations/${organizationId}/a2p-status`, {
|
|
701
|
+
method: "DELETE"
|
|
702
|
+
});
|
|
703
|
+
}
|
|
704
|
+
// Site Mappings API
|
|
705
|
+
async getSiteMappings(options) {
|
|
706
|
+
const queryParams = new URLSearchParams();
|
|
707
|
+
if (options?.search) queryParams.append("search", options.search);
|
|
708
|
+
if (options?.page) queryParams.append("page", options.page.toString());
|
|
709
|
+
if (options?.pageSize) queryParams.append("pageSize", options.pageSize.toString());
|
|
710
|
+
const queryString = queryParams.toString();
|
|
711
|
+
const url = `admin/site-mappings${queryString ? `?${queryString}` : ""}`;
|
|
712
|
+
return this.fetch(url);
|
|
713
|
+
}
|
|
714
|
+
async getSiteMapping(siteId) {
|
|
715
|
+
return this.fetch(`admin/site-mappings/${siteId}`);
|
|
716
|
+
}
|
|
717
|
+
async updateSiteMapping(siteId, data) {
|
|
718
|
+
return this.fetch(`admin/site-mappings/${siteId}`, {
|
|
719
|
+
method: "PUT",
|
|
720
|
+
body: JSON.stringify(data)
|
|
721
|
+
});
|
|
722
|
+
}
|
|
723
|
+
async updateSiteMappingWorkspace(siteId, workspaceId) {
|
|
724
|
+
return this.updateSiteMapping(siteId, {
|
|
725
|
+
workspaceId,
|
|
726
|
+
siteUuid: ""
|
|
727
|
+
// These fields are required by the type but will be ignored on the server
|
|
728
|
+
});
|
|
729
|
+
}
|
|
730
|
+
async adminDeleteSiteMapping(siteId) {
|
|
731
|
+
return this.fetch(`admin/site-mappings/${siteId}`, {
|
|
732
|
+
method: "DELETE"
|
|
733
|
+
});
|
|
734
|
+
}
|
|
735
|
+
async createSiteMapping(mapping) {
|
|
736
|
+
return this.fetch(`admin/site-mappings`, {
|
|
737
|
+
method: "POST",
|
|
738
|
+
body: JSON.stringify(mapping)
|
|
739
|
+
});
|
|
740
|
+
}
|
|
741
|
+
// Keep for backward compatibility
|
|
742
|
+
async createOrUpdateSiteMapping(wid, mapping) {
|
|
743
|
+
return this.fetch(`admin/workspaces/${wid}/site-mappings`, {
|
|
744
|
+
method: "POST",
|
|
745
|
+
body: JSON.stringify(mapping)
|
|
746
|
+
});
|
|
747
|
+
}
|
|
748
|
+
async deleteSiteMapping(wid, siteUuid) {
|
|
749
|
+
return this.fetch(`admin/workspaces/${wid}/site-mappings/${siteUuid}`, {
|
|
750
|
+
method: "DELETE"
|
|
751
|
+
});
|
|
752
|
+
}
|
|
753
|
+
// Admin Inbox Mappings API
|
|
754
|
+
async getInboxMappings(options = {}) {
|
|
755
|
+
const params = new URLSearchParams();
|
|
756
|
+
if (options.page) params.append("page", options.page.toString());
|
|
757
|
+
if (options.pageSize) params.append("pageSize", options.pageSize.toString());
|
|
758
|
+
if (options.search) params.append("search", options.search);
|
|
759
|
+
if (options.workspaceId) params.append("workspaceId", options.workspaceId.toString());
|
|
760
|
+
return this.fetch(
|
|
761
|
+
`admin/inbox-mappings${params.toString() ? `?${params.toString()}` : ""}`
|
|
762
|
+
);
|
|
763
|
+
}
|
|
764
|
+
async getInboxMapping(id) {
|
|
765
|
+
return this.fetch(`admin/inbox-mappings/${id}`);
|
|
766
|
+
}
|
|
767
|
+
async updateInboxMapping(id, workspaceId) {
|
|
768
|
+
return this.fetch(`admin/inbox-mappings/${id}`, {
|
|
769
|
+
method: "PUT",
|
|
770
|
+
body: JSON.stringify({ workspaceId })
|
|
771
|
+
});
|
|
772
|
+
}
|
|
773
|
+
async deleteAdminInboxMapping(id) {
|
|
774
|
+
return this.fetch(`admin/inbox-mappings/${id}`, {
|
|
775
|
+
method: "DELETE"
|
|
776
|
+
});
|
|
777
|
+
}
|
|
778
|
+
// Evaluation API
|
|
779
|
+
async generateChatSummaries(options) {
|
|
780
|
+
return this.fetch("admin/generate-summaries", {
|
|
781
|
+
method: "POST",
|
|
782
|
+
body: JSON.stringify({
|
|
783
|
+
after_date: options.afterDate ? options.afterDate.toISOString().split("T")[0] + "T" + options.afterDate.toTimeString().split(" ")[0] : void 0,
|
|
784
|
+
only_without_summaries: options.onlyWithoutSummaries ?? true
|
|
785
|
+
})
|
|
786
|
+
});
|
|
787
|
+
}
|
|
788
|
+
async executeQuery(options) {
|
|
789
|
+
return this.fetch("admin/execute-query", {
|
|
790
|
+
method: "POST",
|
|
791
|
+
body: JSON.stringify({
|
|
792
|
+
query: options.query,
|
|
793
|
+
workspace_uuid: options.workspaceUuid
|
|
794
|
+
})
|
|
795
|
+
});
|
|
796
|
+
}
|
|
797
|
+
// Admin Themes API
|
|
798
|
+
async listAllThemes() {
|
|
799
|
+
return this.fetch("admin/themes/list");
|
|
800
|
+
}
|
|
801
|
+
// One-off Redis cadence-key migration (periodiq_* → routine_*). See
|
|
802
|
+
// lib/routes/admin/admin_routine_cadence_api.py for context.
|
|
803
|
+
async migrateRoutineCadenceKeys(options) {
|
|
804
|
+
return this.fetch("admin/redis/routine-cadence/migrate", {
|
|
805
|
+
method: "POST",
|
|
806
|
+
body: JSON.stringify({
|
|
807
|
+
dryRun: options.dryRun ?? true,
|
|
808
|
+
deleteLegacy: options.deleteLegacy ?? false
|
|
809
|
+
})
|
|
810
|
+
});
|
|
811
|
+
}
|
|
812
|
+
// Missing Memberships API
|
|
813
|
+
async getMissingMemberships(workspaceId) {
|
|
814
|
+
return this.fetch(
|
|
815
|
+
`admin/workspaces/${workspaceId}/missing-memberships`
|
|
816
|
+
);
|
|
817
|
+
}
|
|
818
|
+
async linkMissingMembership(workspaceId, memberId, accountId) {
|
|
819
|
+
return this.fetch(
|
|
820
|
+
`admin/workspaces/${workspaceId}/link-membership?member_id=${memberId}&account_id=${accountId}`,
|
|
821
|
+
{
|
|
822
|
+
method: "POST"
|
|
823
|
+
}
|
|
824
|
+
);
|
|
825
|
+
}
|
|
826
|
+
// Bulk Phone Classification API
|
|
827
|
+
async startBulkPhoneClassification(workspaceUuid, includeUnknown = false) {
|
|
828
|
+
const params = new URLSearchParams();
|
|
829
|
+
params.append("include_unknown", includeUnknown.toString());
|
|
830
|
+
return this.fetch(`admin/workspaces/${workspaceUuid}/bulk-classify-phones?${params.toString()}`, {
|
|
831
|
+
method: "POST"
|
|
832
|
+
});
|
|
833
|
+
}
|
|
834
|
+
// Bulk TOS Acceptance API
|
|
835
|
+
async startBulkTOSAcceptance(workspaceUuid) {
|
|
836
|
+
return this.fetch(`admin/workspaces/${workspaceUuid}/bulk-accept-tos`, {
|
|
837
|
+
method: "POST"
|
|
838
|
+
});
|
|
839
|
+
}
|
|
840
|
+
// Token Usage Backfill API
|
|
841
|
+
async startTokenUsageBackfill(workspaceUuid) {
|
|
842
|
+
return this.fetch(`admin/workspaces/${workspaceUuid}/backfill-token-usage`, {
|
|
843
|
+
method: "POST"
|
|
844
|
+
});
|
|
845
|
+
}
|
|
846
|
+
// ===== Admin Chat Endpoints =====
|
|
847
|
+
async listWorkspaceChats(workspaceUuid, options) {
|
|
848
|
+
const params = new URLSearchParams();
|
|
849
|
+
if (options?.page) params.set("page", String(options.page));
|
|
850
|
+
if (options?.pageSize) params.set("pageSize", String(options.pageSize));
|
|
851
|
+
if (options?.search) params.set("search", options.search);
|
|
852
|
+
if (options?.chatType) params.set("chatType", options.chatType);
|
|
853
|
+
if (options?.channel) params.set("channel", options.channel);
|
|
854
|
+
if (options?.archived !== void 0) params.set("archived", String(options.archived));
|
|
855
|
+
const qs = params.toString();
|
|
856
|
+
return this.fetch(
|
|
857
|
+
`admin/workspaces/${workspaceUuid}/chats${qs ? `?${qs}` : ""}`
|
|
858
|
+
);
|
|
859
|
+
}
|
|
860
|
+
async getWorkspaceChat(workspaceUuid, chatId, options) {
|
|
861
|
+
const params = new URLSearchParams();
|
|
862
|
+
if (options?.page) params.set("page", String(options.page));
|
|
863
|
+
if (options?.pageSize) params.set("pageSize", String(options.pageSize));
|
|
864
|
+
const qs = params.toString();
|
|
865
|
+
return this.fetch(
|
|
866
|
+
`admin/workspaces/${workspaceUuid}/chats/${chatId}${qs ? `?${qs}` : ""}`
|
|
867
|
+
);
|
|
868
|
+
}
|
|
869
|
+
// Update chat message content
|
|
870
|
+
async updateChatMessage(workspaceUuid, chatId, messageId, content) {
|
|
871
|
+
return this.fetch(`admin/workspaces/${workspaceUuid}/chats/${chatId}/messages/${messageId}`, {
|
|
872
|
+
method: "POST",
|
|
873
|
+
body: JSON.stringify({ content })
|
|
874
|
+
});
|
|
875
|
+
}
|
|
876
|
+
async rateWorkspaceChatMessage(workspaceUuid, chatId, messageId, rating, comment) {
|
|
877
|
+
return this.fetch(
|
|
878
|
+
`admin/workspaces/${workspaceUuid}/chats/${chatId}/messages/${messageId}/rate`,
|
|
879
|
+
{
|
|
880
|
+
method: "POST",
|
|
881
|
+
body: JSON.stringify({ rating, comment })
|
|
882
|
+
}
|
|
883
|
+
);
|
|
884
|
+
}
|
|
885
|
+
// ===== Stripe Customer Management =====
|
|
886
|
+
async getStripeCustomer(accountId) {
|
|
887
|
+
return this.fetch(`admin/accounts/${accountId}/stripe/customer`);
|
|
888
|
+
}
|
|
889
|
+
async createStripeCustomer(accountId, data) {
|
|
890
|
+
return this.fetch(`admin/accounts/${accountId}/stripe/customer`, {
|
|
891
|
+
method: "POST",
|
|
892
|
+
body: JSON.stringify(data)
|
|
893
|
+
});
|
|
894
|
+
}
|
|
895
|
+
async updateStripeCustomer(accountId, data) {
|
|
896
|
+
return this.fetch(`admin/accounts/${accountId}/stripe/customer`, {
|
|
897
|
+
method: "PUT",
|
|
898
|
+
body: JSON.stringify(data)
|
|
899
|
+
});
|
|
900
|
+
}
|
|
901
|
+
// ===== Customer Management =====
|
|
902
|
+
async createCustomerFromAccount(accountId) {
|
|
903
|
+
return this.fetch(`admin/accounts/${accountId}/customer`, {
|
|
904
|
+
method: "POST"
|
|
905
|
+
});
|
|
906
|
+
}
|
|
907
|
+
async getCustomers(options) {
|
|
908
|
+
const params = new URLSearchParams();
|
|
909
|
+
if (options?.search) params.set("search", options.search);
|
|
910
|
+
if (options?.page) params.set("page", String(options.page));
|
|
911
|
+
if (options?.pageSize) params.set("page_size", String(options.pageSize));
|
|
912
|
+
const qs = params.toString();
|
|
913
|
+
return this.fetch(`admin/customers${qs ? `?${qs}` : ""}`);
|
|
914
|
+
}
|
|
915
|
+
async getCustomer(customerId) {
|
|
916
|
+
return this.fetch(`admin/customers/${customerId}`);
|
|
917
|
+
}
|
|
918
|
+
async createCustomer(data) {
|
|
919
|
+
return this.fetch("admin/customers", {
|
|
920
|
+
method: "POST",
|
|
921
|
+
body: JSON.stringify(data)
|
|
922
|
+
});
|
|
923
|
+
}
|
|
924
|
+
async updateCustomer(customerId, data) {
|
|
925
|
+
return this.fetch(`admin/customers/${customerId}`, {
|
|
926
|
+
method: "PUT",
|
|
927
|
+
body: JSON.stringify(data)
|
|
928
|
+
});
|
|
929
|
+
}
|
|
930
|
+
async syncCustomerToStripe(customerId) {
|
|
931
|
+
return this.fetch(`admin/customers/${customerId}/stripe/sync`, {
|
|
932
|
+
method: "POST"
|
|
933
|
+
});
|
|
934
|
+
}
|
|
935
|
+
async getCustomerAccounts(customerId) {
|
|
936
|
+
return this.fetch(`admin/customers/${customerId}/accounts`);
|
|
937
|
+
}
|
|
938
|
+
async linkCustomerToAccount(customerId, accountId, role) {
|
|
939
|
+
return this.fetch(`admin/customers/${customerId}/accounts`, {
|
|
940
|
+
method: "POST",
|
|
941
|
+
body: JSON.stringify({ accountId, role })
|
|
942
|
+
});
|
|
943
|
+
}
|
|
944
|
+
async unlinkCustomerFromAccount(customerId, accountId) {
|
|
945
|
+
await this.fetch(`admin/customers/${customerId}/accounts/${accountId}`, {
|
|
946
|
+
method: "DELETE"
|
|
947
|
+
});
|
|
948
|
+
}
|
|
949
|
+
// ===== Stripe Subscription Management =====
|
|
950
|
+
async getStripeSubscriptions(accountId) {
|
|
951
|
+
return this.fetch(`admin/accounts/${accountId}/stripe/subscriptions`);
|
|
952
|
+
}
|
|
953
|
+
async createStripeSubscription(customerId, data) {
|
|
954
|
+
return this.fetch(`admin/customers/${customerId}/stripe/subscriptions`, {
|
|
955
|
+
method: "POST",
|
|
956
|
+
body: JSON.stringify(data)
|
|
957
|
+
});
|
|
958
|
+
}
|
|
959
|
+
async createDirectSubscription(customerId, data) {
|
|
960
|
+
return this.fetch(`admin/customers/${customerId}/direct/subscriptions`, {
|
|
961
|
+
method: "POST",
|
|
962
|
+
body: JSON.stringify(data)
|
|
963
|
+
});
|
|
964
|
+
}
|
|
965
|
+
async updateStripeSubscription(accountId, subscriptionId, data) {
|
|
966
|
+
return this.fetch(
|
|
967
|
+
`admin/accounts/${accountId}/stripe/subscriptions/${subscriptionId}`,
|
|
968
|
+
{
|
|
969
|
+
method: "PUT",
|
|
970
|
+
body: JSON.stringify(data)
|
|
971
|
+
}
|
|
972
|
+
);
|
|
973
|
+
}
|
|
974
|
+
async cancelStripeSubscription(accountId, subscriptionId) {
|
|
975
|
+
return this.fetch(
|
|
976
|
+
`admin/accounts/${accountId}/stripe/subscriptions/${subscriptionId}`,
|
|
977
|
+
{
|
|
978
|
+
method: "DELETE"
|
|
979
|
+
}
|
|
980
|
+
);
|
|
981
|
+
}
|
|
982
|
+
async provisionWorkspaceForSubscription(accountId, subscriptionId) {
|
|
983
|
+
return this.fetch(
|
|
984
|
+
`admin/accounts/${accountId}/stripe/subscriptions/${subscriptionId}/provision`,
|
|
985
|
+
{
|
|
986
|
+
method: "POST"
|
|
987
|
+
}
|
|
988
|
+
);
|
|
989
|
+
}
|
|
990
|
+
async associateWorkspaceWithSubscription(accountId, subscriptionId, workspaceId) {
|
|
991
|
+
return this.fetch(
|
|
992
|
+
`admin/accounts/${accountId}/stripe/subscriptions/${subscriptionId}/associate?workspace_id=${workspaceId}`,
|
|
993
|
+
{
|
|
994
|
+
method: "POST"
|
|
995
|
+
}
|
|
996
|
+
);
|
|
997
|
+
}
|
|
998
|
+
async createSubscriptionPaymentLink(accountId, subscriptionId) {
|
|
999
|
+
return this.fetch(`admin/accounts/${accountId}/stripe/subscriptions/${subscriptionId}/payment-link`, {
|
|
1000
|
+
method: "POST"
|
|
1001
|
+
});
|
|
1002
|
+
}
|
|
1003
|
+
// ===== Stripe Payment Methods Management =====
|
|
1004
|
+
async createSetupIntent(accountId) {
|
|
1005
|
+
return this.fetch(`admin/accounts/${accountId}/stripe/setup-intent`, {
|
|
1006
|
+
method: "POST"
|
|
1007
|
+
});
|
|
1008
|
+
}
|
|
1009
|
+
async getStripePaymentMethods(accountId) {
|
|
1010
|
+
return this.fetch(
|
|
1011
|
+
`admin/accounts/${accountId}/stripe/payment-methods`
|
|
1012
|
+
);
|
|
1013
|
+
}
|
|
1014
|
+
async attachStripePaymentMethod(accountId, paymentMethodId, setAsDefault = false) {
|
|
1015
|
+
return this.fetch(`admin/accounts/${accountId}/stripe/payment-methods/${paymentMethodId}/attach`, {
|
|
1016
|
+
method: "POST",
|
|
1017
|
+
body: JSON.stringify({ setAsDefault })
|
|
1018
|
+
});
|
|
1019
|
+
}
|
|
1020
|
+
async detachStripePaymentMethod(accountId, paymentMethodId) {
|
|
1021
|
+
return this.fetch(
|
|
1022
|
+
`admin/accounts/${accountId}/stripe/payment-methods/${paymentMethodId}`,
|
|
1023
|
+
{
|
|
1024
|
+
method: "DELETE"
|
|
1025
|
+
}
|
|
1026
|
+
);
|
|
1027
|
+
}
|
|
1028
|
+
async setDefaultStripePaymentMethod(accountId, paymentMethodId) {
|
|
1029
|
+
return this.fetch(
|
|
1030
|
+
`admin/accounts/${accountId}/stripe/payment-methods/${paymentMethodId}/set-default`,
|
|
1031
|
+
{
|
|
1032
|
+
method: "PUT"
|
|
1033
|
+
}
|
|
1034
|
+
);
|
|
1035
|
+
}
|
|
1036
|
+
// ===== Convert Direct Subscription to Stripe =====
|
|
1037
|
+
async convertSubscriptionToStripe(customerId, subscriptionId) {
|
|
1038
|
+
return this.fetch(
|
|
1039
|
+
`admin/customers/${customerId}/subscriptions/${subscriptionId}/convert-to-stripe`,
|
|
1040
|
+
{ method: "POST" }
|
|
1041
|
+
);
|
|
1042
|
+
}
|
|
1043
|
+
// ===== Customer-Level Stripe Payment Methods =====
|
|
1044
|
+
async createCustomerSetupIntent(customerId) {
|
|
1045
|
+
return this.fetch(`admin/customers/${customerId}/stripe/setup-intent`, {
|
|
1046
|
+
method: "POST"
|
|
1047
|
+
});
|
|
1048
|
+
}
|
|
1049
|
+
async getCustomerPaymentMethods(customerId) {
|
|
1050
|
+
return this.fetch(
|
|
1051
|
+
`admin/customers/${customerId}/stripe/payment-methods`
|
|
1052
|
+
);
|
|
1053
|
+
}
|
|
1054
|
+
async attachCustomerPaymentMethod(customerId, paymentMethodId, setAsDefault = false) {
|
|
1055
|
+
return this.fetch(`admin/customers/${customerId}/stripe/payment-methods/${paymentMethodId}/attach`, {
|
|
1056
|
+
method: "POST",
|
|
1057
|
+
body: JSON.stringify({ setAsDefault })
|
|
1058
|
+
});
|
|
1059
|
+
}
|
|
1060
|
+
async detachCustomerPaymentMethod(customerId, paymentMethodId) {
|
|
1061
|
+
return this.fetch(
|
|
1062
|
+
`admin/customers/${customerId}/stripe/payment-methods/${paymentMethodId}`,
|
|
1063
|
+
{
|
|
1064
|
+
method: "DELETE"
|
|
1065
|
+
}
|
|
1066
|
+
);
|
|
1067
|
+
}
|
|
1068
|
+
async setDefaultCustomerPaymentMethod(customerId, paymentMethodId) {
|
|
1069
|
+
return this.fetch(
|
|
1070
|
+
`admin/customers/${customerId}/stripe/payment-methods/${paymentMethodId}/set-default`,
|
|
1071
|
+
{
|
|
1072
|
+
method: "PUT"
|
|
1073
|
+
}
|
|
1074
|
+
);
|
|
1075
|
+
}
|
|
1076
|
+
// ===== Workspace Organization Migration =====
|
|
1077
|
+
async previewWorkspaceOrganizationChange(workspaceUuid, targetOrganizationId, newCreatorId) {
|
|
1078
|
+
return this.fetch(`admin/workspaces/${workspaceUuid}/change-org/preview`, {
|
|
1079
|
+
method: "POST",
|
|
1080
|
+
headers: {
|
|
1081
|
+
"Content-Type": "application/json"
|
|
1082
|
+
},
|
|
1083
|
+
body: JSON.stringify({
|
|
1084
|
+
targetOrganizationId,
|
|
1085
|
+
newCreatorId
|
|
1086
|
+
})
|
|
1087
|
+
});
|
|
1088
|
+
}
|
|
1089
|
+
async changeWorkspaceOrganization(workspaceUuid, targetOrganizationId, newCreatorId) {
|
|
1090
|
+
return this.fetch(`admin/workspaces/${workspaceUuid}/change-org`, {
|
|
1091
|
+
method: "POST",
|
|
1092
|
+
body: JSON.stringify({
|
|
1093
|
+
targetOrganizationId,
|
|
1094
|
+
newCreatorId
|
|
1095
|
+
})
|
|
1096
|
+
});
|
|
1097
|
+
}
|
|
1098
|
+
// ===== Stripe Invoice Management =====
|
|
1099
|
+
async createStripeInvoice(accountId, data) {
|
|
1100
|
+
return this.fetch(`admin/accounts/${accountId}/stripe/invoices`, {
|
|
1101
|
+
method: "POST",
|
|
1102
|
+
body: JSON.stringify({
|
|
1103
|
+
customer: data.customer,
|
|
1104
|
+
description: data.description,
|
|
1105
|
+
collection_method: data.collectionMethod,
|
|
1106
|
+
days_until_due: data.daysUntilDue,
|
|
1107
|
+
auto_advance: data.autoAdvance,
|
|
1108
|
+
metadata: data.metadata
|
|
1109
|
+
})
|
|
1110
|
+
});
|
|
1111
|
+
}
|
|
1112
|
+
async getStripeInvoices(accountId, options) {
|
|
1113
|
+
const params = new URLSearchParams();
|
|
1114
|
+
if (options?.limit) params.append("limit", options.limit.toString());
|
|
1115
|
+
if (options?.startingAfter) params.append("starting_after", options.startingAfter);
|
|
1116
|
+
return this.fetch(`admin/accounts/${accountId}/stripe/invoices?${params.toString()}`);
|
|
1117
|
+
}
|
|
1118
|
+
async getStripeUpcomingInvoice(accountId, subscriptionId) {
|
|
1119
|
+
const params = new URLSearchParams();
|
|
1120
|
+
if (subscriptionId) params.append("subscription_id", subscriptionId);
|
|
1121
|
+
return this.fetch(`admin/accounts/${accountId}/stripe/upcoming-invoice?${params.toString()}`);
|
|
1122
|
+
}
|
|
1123
|
+
// Billing Dashboard API
|
|
1124
|
+
async getWorkspaceUsageDashboard(workspaceUuid) {
|
|
1125
|
+
return this.fetch(
|
|
1126
|
+
`admin/workspaces/${workspaceUuid}/usage-dashboard`
|
|
1127
|
+
);
|
|
1128
|
+
}
|
|
1129
|
+
// Product Stripe Sync API
|
|
1130
|
+
async compareProductsWithStripe(workspaceUuid) {
|
|
1131
|
+
const params = workspaceUuid ? `?workspace_uuid=${encodeURIComponent(workspaceUuid)}` : "";
|
|
1132
|
+
return this.fetch(`admin/products/compare-stripe${params}`);
|
|
1133
|
+
}
|
|
1134
|
+
async syncProductToStripe(productId, request) {
|
|
1135
|
+
return this.fetch(`admin/products/${productId}/sync-stripe`, {
|
|
1136
|
+
method: "POST",
|
|
1137
|
+
body: JSON.stringify({ ...request, productId })
|
|
1138
|
+
});
|
|
1139
|
+
}
|
|
1140
|
+
// Search Stripe products
|
|
1141
|
+
async searchStripeProducts(query, limit = 10) {
|
|
1142
|
+
const params = new URLSearchParams({ query, limit: limit.toString() });
|
|
1143
|
+
return this.fetch(`admin/products/stripe/search?${params.toString()}`);
|
|
1144
|
+
}
|
|
1145
|
+
// ===== Subscriptions API =====
|
|
1146
|
+
async getSubscriptionsAsAdmin(options) {
|
|
1147
|
+
const params = new URLSearchParams();
|
|
1148
|
+
if (options?.productId) params.append("product_id", options.productId.toString());
|
|
1149
|
+
if (options?.productType) params.append("product_type", options.productType);
|
|
1150
|
+
if (options?.customerId) params.append("customer_id", options.customerId.toString());
|
|
1151
|
+
if (options?.organizationId)
|
|
1152
|
+
params.append("organization_id", options.organizationId.toString());
|
|
1153
|
+
if (options?.accountId) params.append("account_id", options.accountId.toString());
|
|
1154
|
+
if (options?.isDirect !== void 0) params.append("is_direct", options.isDirect.toString());
|
|
1155
|
+
if (options?.status) params.append("status", options.status);
|
|
1156
|
+
if (options?.page) params.append("page", options.page.toString());
|
|
1157
|
+
if (options?.pageSize) params.append("page_size", options.pageSize.toString());
|
|
1158
|
+
const queryString = params.toString();
|
|
1159
|
+
return this.fetch(
|
|
1160
|
+
`admin/subscriptions${queryString ? `?${queryString}` : ""}`
|
|
1161
|
+
);
|
|
1162
|
+
}
|
|
1163
|
+
async getSubscriptionAsAdmin(subscriptionId) {
|
|
1164
|
+
return this.fetch(`admin/subscriptions/${subscriptionId}`);
|
|
1165
|
+
}
|
|
1166
|
+
async updateSubscriptionStatusAsAdmin(subscriptionId, subscriptionStatus) {
|
|
1167
|
+
return this.fetch(`admin/subscriptions/${subscriptionId}`, {
|
|
1168
|
+
method: "PUT",
|
|
1169
|
+
body: JSON.stringify({ subscription_status: subscriptionStatus })
|
|
1170
|
+
});
|
|
1171
|
+
}
|
|
1172
|
+
async updateSubscriptionCreditSettingsAsAdmin(subscriptionId, settings) {
|
|
1173
|
+
return this.fetch(`admin/subscriptions/${subscriptionId}`, {
|
|
1174
|
+
method: "PUT",
|
|
1175
|
+
body: JSON.stringify(settings)
|
|
1176
|
+
});
|
|
1177
|
+
}
|
|
1178
|
+
/** Grant credits to a subscription (superuser only). */
|
|
1179
|
+
async grantCreditsAsAdmin(subscriptionId, creditUnits, grantType, reason) {
|
|
1180
|
+
return this.fetch(`admin/subscriptions/${subscriptionId}/grant-credits`, {
|
|
1181
|
+
method: "POST",
|
|
1182
|
+
body: JSON.stringify({ credit_units: creditUnits, grant_type: grantType, reason })
|
|
1183
|
+
});
|
|
1184
|
+
}
|
|
1185
|
+
/** List credit grants for a subscription (superuser only). */
|
|
1186
|
+
async listCreditGrantsAsAdmin(subscriptionId) {
|
|
1187
|
+
return this.fetch(`admin/subscriptions/${subscriptionId}/credit-grants`);
|
|
1188
|
+
}
|
|
1189
|
+
// ===== Usage API =====
|
|
1190
|
+
async getUsageReport(request) {
|
|
1191
|
+
return this.fetch("admin/usage", {
|
|
1192
|
+
method: "POST",
|
|
1193
|
+
body: JSON.stringify(request)
|
|
1194
|
+
});
|
|
1195
|
+
}
|
|
1196
|
+
// Voice Metrics API
|
|
1197
|
+
async getVoiceMetrics(options) {
|
|
1198
|
+
const params = new URLSearchParams();
|
|
1199
|
+
if (options?.hours) params.append("hours", options.hours.toString());
|
|
1200
|
+
if (options?.period) params.append("period", options.period.toString());
|
|
1201
|
+
if (options?.workspace_uuid) params.append("workspace_uuid", options.workspace_uuid);
|
|
1202
|
+
if (options?.organization_id != null)
|
|
1203
|
+
params.append("organization_id", options.organization_id.toString());
|
|
1204
|
+
if (options?.engine) params.append("engine", options.engine);
|
|
1205
|
+
if (options?.channel) params.append("channel", options.channel);
|
|
1206
|
+
const qs = params.toString();
|
|
1207
|
+
return this.fetch(`admin/voice-metrics${qs ? `?${qs}` : ""}`);
|
|
1208
|
+
}
|
|
1209
|
+
// Health Dashboard API
|
|
1210
|
+
async getHealthMetrics(request) {
|
|
1211
|
+
return this.fetch("admin/health/metrics", {
|
|
1212
|
+
method: "POST",
|
|
1213
|
+
body: JSON.stringify(request)
|
|
1214
|
+
});
|
|
1215
|
+
}
|
|
1216
|
+
async getHealthDetail(workspaceUuid, request) {
|
|
1217
|
+
return this.fetch(`admin/health/detail/${workspaceUuid}`, {
|
|
1218
|
+
method: "POST",
|
|
1219
|
+
body: JSON.stringify(request)
|
|
1220
|
+
});
|
|
1221
|
+
}
|
|
1222
|
+
// ===== Reseller Management =====
|
|
1223
|
+
async getResellers(options) {
|
|
1224
|
+
const params = new URLSearchParams();
|
|
1225
|
+
if (options?.search) params.set("search", options.search);
|
|
1226
|
+
if (options?.page) params.set("page", String(options.page));
|
|
1227
|
+
if (options?.pageSize) params.set("page_size", String(options.pageSize));
|
|
1228
|
+
const qs = params.toString();
|
|
1229
|
+
return this.fetch(`admin/resellers${qs ? `?${qs}` : ""}`);
|
|
1230
|
+
}
|
|
1231
|
+
async getReseller(resellerId) {
|
|
1232
|
+
return this.fetch(`admin/resellers/${resellerId}`);
|
|
1233
|
+
}
|
|
1234
|
+
async createReseller(data) {
|
|
1235
|
+
return this.fetch("admin/resellers", {
|
|
1236
|
+
method: "POST",
|
|
1237
|
+
body: JSON.stringify(data)
|
|
1238
|
+
});
|
|
1239
|
+
}
|
|
1240
|
+
async updateReseller(resellerId, data) {
|
|
1241
|
+
return this.fetch(`admin/resellers/${resellerId}`, {
|
|
1242
|
+
method: "PUT",
|
|
1243
|
+
body: JSON.stringify(data)
|
|
1244
|
+
});
|
|
1245
|
+
}
|
|
1246
|
+
async getResellerAccounts(resellerId) {
|
|
1247
|
+
return this.fetch(`admin/resellers/${resellerId}/accounts`);
|
|
1248
|
+
}
|
|
1249
|
+
async linkResellerToAccount(resellerId, data) {
|
|
1250
|
+
return this.fetch(`admin/resellers/${resellerId}/accounts`, {
|
|
1251
|
+
method: "POST",
|
|
1252
|
+
body: JSON.stringify({ account_id: data.accountId, role: data.role })
|
|
1253
|
+
});
|
|
1254
|
+
}
|
|
1255
|
+
async unlinkResellerFromAccount(resellerId, accountId) {
|
|
1256
|
+
await this.fetch(`admin/resellers/${resellerId}/accounts/${accountId}`, {
|
|
1257
|
+
method: "DELETE"
|
|
1258
|
+
});
|
|
1259
|
+
}
|
|
1260
|
+
// ===== Invoice Management =====
|
|
1261
|
+
async generateInvoice(data) {
|
|
1262
|
+
return this.fetch("admin/invoices/generate", {
|
|
1263
|
+
method: "POST",
|
|
1264
|
+
body: JSON.stringify(data)
|
|
1265
|
+
});
|
|
1266
|
+
}
|
|
1267
|
+
async getInvoices(subscriptionId, pageOpts) {
|
|
1268
|
+
const params = new URLSearchParams();
|
|
1269
|
+
if (subscriptionId !== void 0) params.set("subscription_id", String(subscriptionId));
|
|
1270
|
+
if (pageOpts?.page !== void 0) params.set("page", String(pageOpts.page));
|
|
1271
|
+
if (pageOpts?.pageSize !== void 0) params.set("pageSize", String(pageOpts.pageSize));
|
|
1272
|
+
const qs = params.toString();
|
|
1273
|
+
return this.fetch(`admin/invoices${qs ? `?${qs}` : ""}`);
|
|
1274
|
+
}
|
|
1275
|
+
async getBillingPeriods(subscriptionId) {
|
|
1276
|
+
return this.fetch(
|
|
1277
|
+
`admin/invoices/periods?subscription_id=${subscriptionId}`
|
|
1278
|
+
);
|
|
1279
|
+
}
|
|
1280
|
+
async getInvoiceDownloadUrl(invoiceId) {
|
|
1281
|
+
return this.fetch(
|
|
1282
|
+
`admin/invoices/${invoiceId}/download`
|
|
1283
|
+
);
|
|
1284
|
+
}
|
|
1285
|
+
async getReceiptDownloadUrl(invoiceId) {
|
|
1286
|
+
return this.fetch(
|
|
1287
|
+
`admin/invoices/${invoiceId}/receipt`
|
|
1288
|
+
);
|
|
1289
|
+
}
|
|
1290
|
+
async recordInvoicePayment(invoiceId, data) {
|
|
1291
|
+
return this.fetch(`admin/invoices/${invoiceId}/record-payment`, {
|
|
1292
|
+
method: "POST",
|
|
1293
|
+
body: JSON.stringify(data)
|
|
1294
|
+
});
|
|
1295
|
+
}
|
|
1296
|
+
// ===== Admin Temporal Inspection (PHI-safe, read-only) =====
|
|
1297
|
+
/**
|
|
1298
|
+
* Server-enforced bounds for admin Temporal queries (lookback, thresholds,
|
|
1299
|
+
* page sizes, history event cap). Superuser only.
|
|
1300
|
+
*/
|
|
1301
|
+
async getTemporalAdminConfig() {
|
|
1302
|
+
return this.fetch("admin/temporal/config");
|
|
1303
|
+
}
|
|
1304
|
+
/**
|
|
1305
|
+
* List recent Temporal workflows in FAILED, TIMED_OUT, or TERMINATED
|
|
1306
|
+
* status. Returns only PHI-safe operational metadata. Superuser only.
|
|
1307
|
+
*
|
|
1308
|
+
* Pass `options.status` to filter to a single status and enable
|
|
1309
|
+
* deep pagination via `nextPageToken`. Merged mode (no status) returns
|
|
1310
|
+
* the first page only and always emits `nextPageToken: null`.
|
|
1311
|
+
*/
|
|
1312
|
+
async listFailedTemporalWorkflows(options = {}) {
|
|
1313
|
+
const params = new URLSearchParams();
|
|
1314
|
+
if (options.lookbackHours !== void 0)
|
|
1315
|
+
params.set("lookback_hours", String(options.lookbackHours));
|
|
1316
|
+
if (options.pageSize !== void 0) params.set("page_size", String(options.pageSize));
|
|
1317
|
+
if (options.status) params.set("status", String(options.status));
|
|
1318
|
+
if (options.nextPageToken) params.set("next_page_token", options.nextPageToken);
|
|
1319
|
+
appendTemporalWorkspaceParams(params, options);
|
|
1320
|
+
const qs = params.toString();
|
|
1321
|
+
return this.fetch(
|
|
1322
|
+
`admin/temporal/workflows/failed${qs ? `?${qs}` : ""}`
|
|
1323
|
+
);
|
|
1324
|
+
}
|
|
1325
|
+
/**
|
|
1326
|
+
* List open Temporal workflows older than the stuck threshold.
|
|
1327
|
+
* Superuser only.
|
|
1328
|
+
*/
|
|
1329
|
+
async listStuckTemporalWorkflows(options = {}) {
|
|
1330
|
+
const params = new URLSearchParams();
|
|
1331
|
+
if (options.thresholdMinutes !== void 0)
|
|
1332
|
+
params.set("threshold_minutes", String(options.thresholdMinutes));
|
|
1333
|
+
if (options.pageSize !== void 0) params.set("page_size", String(options.pageSize));
|
|
1334
|
+
if (options.nextPageToken) params.set("next_page_token", options.nextPageToken);
|
|
1335
|
+
appendTemporalWorkspaceParams(params, options);
|
|
1336
|
+
const qs = params.toString();
|
|
1337
|
+
return this.fetch(
|
|
1338
|
+
`admin/temporal/workflows/stuck${qs ? `?${qs}` : ""}`
|
|
1339
|
+
);
|
|
1340
|
+
}
|
|
1341
|
+
/**
|
|
1342
|
+
* Return grouped counts for recent Temporal executions. Superuser only.
|
|
1343
|
+
*/
|
|
1344
|
+
async getTemporalSummary(options = {}) {
|
|
1345
|
+
const params = new URLSearchParams();
|
|
1346
|
+
if (options.lookbackHours !== void 0)
|
|
1347
|
+
params.set("lookback_hours", String(options.lookbackHours));
|
|
1348
|
+
appendTemporalWorkspaceParams(params, options);
|
|
1349
|
+
const qs = params.toString();
|
|
1350
|
+
return this.fetch(
|
|
1351
|
+
`admin/temporal/workflows/summary${qs ? `?${qs}` : ""}`
|
|
1352
|
+
);
|
|
1353
|
+
}
|
|
1354
|
+
/**
|
|
1355
|
+
* Fetch metadata + bounded sanitized history summary for one Temporal
|
|
1356
|
+
* workflow. Superuser only. Does not return raw events or payloads.
|
|
1357
|
+
*/
|
|
1358
|
+
async getTemporalWorkflowDetail(workflowId, options = {}) {
|
|
1359
|
+
const params = new URLSearchParams();
|
|
1360
|
+
if (options.runId) params.set("run_id", options.runId);
|
|
1361
|
+
appendTemporalWorkspaceParams(params, options);
|
|
1362
|
+
const qs = params.toString();
|
|
1363
|
+
const encoded = encodeURIComponent(workflowId);
|
|
1364
|
+
return this.fetch(
|
|
1365
|
+
`admin/temporal/workflows/${encoded}${qs ? `?${qs}` : ""}`
|
|
1366
|
+
);
|
|
1367
|
+
}
|
|
1368
|
+
};
|
|
1369
|
+
function appendTemporalWorkspaceParams(params, options) {
|
|
1370
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1371
|
+
const push = (raw) => {
|
|
1372
|
+
if (!raw) return;
|
|
1373
|
+
const trimmed = raw.trim();
|
|
1374
|
+
if (!trimmed || seen.has(trimmed)) return;
|
|
1375
|
+
seen.add(trimmed);
|
|
1376
|
+
params.append("workspace_uuid", trimmed);
|
|
1377
|
+
};
|
|
1378
|
+
if (options.workspaceUuids) {
|
|
1379
|
+
for (const value of options.workspaceUuids) push(value);
|
|
1380
|
+
}
|
|
1381
|
+
push(options.workspaceUuid);
|
|
1382
|
+
}
|
|
1383
|
+
function bindAdminMethods(target, admin) {
|
|
1384
|
+
target.getAccounts = admin.getAccounts.bind(admin);
|
|
1385
|
+
target.getAccountDetails = admin.getAccountDetails.bind(admin);
|
|
1386
|
+
target.getAccountByUuid = admin.getAccountByUuid.bind(admin);
|
|
1387
|
+
target.getAccountMemberships = admin.getAccountMemberships.bind(admin);
|
|
1388
|
+
target.getAccountOrgMemberships = admin.getAccountOrgMemberships.bind(admin);
|
|
1389
|
+
target.createAccountOrgMembership = admin.createAccountOrgMembership.bind(admin);
|
|
1390
|
+
target.deleteAccountOrgMembership = admin.deleteAccountOrgMembership.bind(admin);
|
|
1391
|
+
target.getAccountMembership = admin.getAccountMembership.bind(admin);
|
|
1392
|
+
target.updateAccountMembership = admin.updateAccountMembership.bind(admin);
|
|
1393
|
+
target.createAccountMembership = admin.createAccountMembership.bind(admin);
|
|
1394
|
+
target.deleteAccountMembership = admin.deleteAccountMembership.bind(admin);
|
|
1395
|
+
target.updateAccountAsAdmin = admin.updateAccountAsAdmin.bind(admin);
|
|
1396
|
+
target.createAccountAsAdmin = admin.createAccountAsAdmin.bind(admin);
|
|
1397
|
+
target.deleteAccountAsAdmin = admin.deleteAccountAsAdmin.bind(admin);
|
|
1398
|
+
target.lookupAccount = admin.lookupAccount.bind(admin);
|
|
1399
|
+
target.exportAccountData = admin.exportAccountData.bind(admin);
|
|
1400
|
+
target.requestAccountDeletion = admin.requestAccountDeletion.bind(admin);
|
|
1401
|
+
target.cancelAccountDeletion = admin.cancelAccountDeletion.bind(admin);
|
|
1402
|
+
target.getOrganizations = admin.getOrganizations.bind(admin);
|
|
1403
|
+
target.getOrganization = admin.getOrganization.bind(admin);
|
|
1404
|
+
target.getOrganizationAsAdmin = admin.getOrganizationAsAdmin.bind(admin);
|
|
1405
|
+
target.getOrganizationMembersAsAdmin = admin.getOrganizationMembersAsAdmin.bind(admin);
|
|
1406
|
+
target.createOrganization = admin.createOrganization.bind(admin);
|
|
1407
|
+
target.updateOrganization = admin.updateOrganization.bind(admin);
|
|
1408
|
+
target.deleteOrganization = admin.deleteOrganization.bind(admin);
|
|
1409
|
+
target.joinOrganization = admin.joinOrganization.bind(admin);
|
|
1410
|
+
target.leaveOrganization = admin.leaveOrganization.bind(admin);
|
|
1411
|
+
target.generateLogoUploadUrl = admin.generateLogoUploadUrl.bind(admin);
|
|
1412
|
+
target.importProducts = admin.importProducts.bind(admin);
|
|
1413
|
+
target.createProductAsAdmin = admin.createProductAsAdmin.bind(admin);
|
|
1414
|
+
target.getProductsAsAdmin = admin.getProductsAsAdmin.bind(admin);
|
|
1415
|
+
target.getProductAsAdmin = admin.getProductAsAdmin.bind(admin);
|
|
1416
|
+
target.updateProductAsAdmin = admin.updateProductAsAdmin.bind(admin);
|
|
1417
|
+
target.deleteProductAsAdmin = admin.deleteProductAsAdmin.bind(admin);
|
|
1418
|
+
target.getWorkspacesAsAdmin = admin.getWorkspacesAsAdmin.bind(admin);
|
|
1419
|
+
target.getWorkspaceAsAdmin = admin.getWorkspaceAsAdmin.bind(admin);
|
|
1420
|
+
target.getWorkspaceByNumericIdAsAdmin = admin.getWorkspaceByNumericIdAsAdmin.bind(admin);
|
|
1421
|
+
target.createWorkspaceAsAdmin = admin.createWorkspaceAsAdmin.bind(admin);
|
|
1422
|
+
target.updateWorkspaceAsAdmin = admin.updateWorkspaceAsAdmin.bind(admin);
|
|
1423
|
+
target.deleteWorkspaceAsAdmin = admin.deleteWorkspaceAsAdmin.bind(admin);
|
|
1424
|
+
target.createSchemaAsAdmin = admin.createSchemaAsAdmin.bind(admin);
|
|
1425
|
+
target.migrateSchemaAsAdmin = admin.migrateSchemaAsAdmin.bind(admin);
|
|
1426
|
+
target.provisionWorkspaceAsAdmin = admin.provisionWorkspaceAsAdmin.bind(admin);
|
|
1427
|
+
target.refreshProvisionStatusAsAdmin = admin.refreshProvisionStatusAsAdmin.bind(admin);
|
|
1428
|
+
target.enableMaintenanceMode = admin.enableMaintenanceMode.bind(admin);
|
|
1429
|
+
target.disableMaintenanceMode = admin.disableMaintenanceMode.bind(admin);
|
|
1430
|
+
target.getWorkspaceHealth = admin.getWorkspaceHealth.bind(admin);
|
|
1431
|
+
target.provisionPlanFeatures = admin.provisionPlanFeatures.bind(admin);
|
|
1432
|
+
target.validateWorkflowAccessAsAdmin = admin.validateWorkflowAccessAsAdmin.bind(admin);
|
|
1433
|
+
target.mergeMembers = admin.mergeMembers.bind(admin);
|
|
1434
|
+
target.getAdminWorkspaceMember = admin.getAdminWorkspaceMember.bind(admin);
|
|
1435
|
+
target.createAdminWorkspaceMember = admin.createAdminWorkspaceMember.bind(admin);
|
|
1436
|
+
target.updateAdminWorkspaceMember = admin.updateAdminWorkspaceMember.bind(admin);
|
|
1437
|
+
target.getAdminWorkspaceMemberRoles = admin.getAdminWorkspaceMemberRoles.bind(admin);
|
|
1438
|
+
target.getMissingMemberships = admin.getMissingMemberships.bind(admin);
|
|
1439
|
+
target.linkMissingMembership = admin.linkMissingMembership.bind(admin);
|
|
1440
|
+
target.getUnmappedPhoneNumbers = admin.getUnmappedPhoneNumbers.bind(admin);
|
|
1441
|
+
target.getWorkspaceUnmappedPhoneNumbers = admin.getWorkspaceUnmappedPhoneNumbers.bind(admin);
|
|
1442
|
+
target.getWorkspacePhoneNumbersAsAdmin = admin.getWorkspacePhoneNumbersAsAdmin.bind(admin);
|
|
1443
|
+
target.getProviderPhoneNumbers = admin.getProviderPhoneNumbers.bind(admin);
|
|
1444
|
+
target.getProviderPhoneNumber = admin.getProviderPhoneNumber.bind(admin);
|
|
1445
|
+
target.updateProviderPhoneNumber = admin.updateProviderPhoneNumber.bind(admin);
|
|
1446
|
+
target.mapMainAccountPhone = admin.mapMainAccountPhone.bind(admin);
|
|
1447
|
+
target.unmapPhoneNumber = admin.unmapPhoneNumber.bind(admin);
|
|
1448
|
+
target.searchAvailablePhoneNumbersAsAdmin = admin.searchAvailablePhoneNumbersAsAdmin.bind(admin);
|
|
1449
|
+
target.purchasePhoneNumberAsAdmin = admin.purchasePhoneNumberAsAdmin.bind(admin);
|
|
1450
|
+
target.startBulkPhoneClassification = admin.startBulkPhoneClassification.bind(admin);
|
|
1451
|
+
target.getOrgA2PStatusAsAdmin = admin.getOrgA2PStatusAsAdmin.bind(admin);
|
|
1452
|
+
target.resetOrgA2PStatusAsAdmin = admin.resetOrgA2PStatusAsAdmin.bind(admin);
|
|
1453
|
+
target.getSiteMappings = admin.getSiteMappings.bind(admin);
|
|
1454
|
+
target.getSiteMapping = admin.getSiteMapping.bind(admin);
|
|
1455
|
+
target.updateSiteMapping = admin.updateSiteMapping.bind(admin);
|
|
1456
|
+
target.updateSiteMappingWorkspace = admin.updateSiteMappingWorkspace.bind(admin);
|
|
1457
|
+
target.adminDeleteSiteMapping = admin.adminDeleteSiteMapping.bind(admin);
|
|
1458
|
+
target.createSiteMapping = admin.createSiteMapping.bind(admin);
|
|
1459
|
+
target.createOrUpdateSiteMapping = admin.createOrUpdateSiteMapping.bind(admin);
|
|
1460
|
+
target.deleteSiteMapping = admin.deleteSiteMapping.bind(admin);
|
|
1461
|
+
target.getInboxMappings = admin.getInboxMappings.bind(admin);
|
|
1462
|
+
target.getInboxMapping = admin.getInboxMapping.bind(admin);
|
|
1463
|
+
target.updateInboxMapping = admin.updateInboxMapping.bind(admin);
|
|
1464
|
+
target.deleteAdminInboxMapping = admin.deleteAdminInboxMapping.bind(admin);
|
|
1465
|
+
target.generateChatSummaries = admin.generateChatSummaries.bind(admin);
|
|
1466
|
+
target.executeQuery = admin.executeQuery.bind(admin);
|
|
1467
|
+
target.listAllThemes = admin.listAllThemes.bind(admin);
|
|
1468
|
+
target.migrateRoutineCadenceKeys = admin.migrateRoutineCadenceKeys.bind(admin);
|
|
1469
|
+
target.startBulkTOSAcceptance = admin.startBulkTOSAcceptance.bind(admin);
|
|
1470
|
+
target.startTokenUsageBackfill = admin.startTokenUsageBackfill.bind(admin);
|
|
1471
|
+
target.updateChatMessage = admin.updateChatMessage.bind(admin);
|
|
1472
|
+
target.createCustomerFromAccount = admin.createCustomerFromAccount.bind(admin);
|
|
1473
|
+
target.getCustomers = admin.getCustomers.bind(admin);
|
|
1474
|
+
target.getCustomer = admin.getCustomer.bind(admin);
|
|
1475
|
+
target.createCustomer = admin.createCustomer.bind(admin);
|
|
1476
|
+
target.updateCustomer = admin.updateCustomer.bind(admin);
|
|
1477
|
+
target.getCustomerAccounts = admin.getCustomerAccounts.bind(admin);
|
|
1478
|
+
target.linkCustomerToAccount = admin.linkCustomerToAccount.bind(admin);
|
|
1479
|
+
target.unlinkCustomerFromAccount = admin.unlinkCustomerFromAccount.bind(admin);
|
|
1480
|
+
target.syncCustomerToStripe = admin.syncCustomerToStripe.bind(admin);
|
|
1481
|
+
target.getStripeCustomer = admin.getStripeCustomer.bind(admin);
|
|
1482
|
+
target.createStripeCustomer = admin.createStripeCustomer.bind(admin);
|
|
1483
|
+
target.updateStripeCustomer = admin.updateStripeCustomer.bind(admin);
|
|
1484
|
+
target.getStripeSubscriptions = admin.getStripeSubscriptions.bind(admin);
|
|
1485
|
+
target.createStripeSubscription = admin.createStripeSubscription.bind(admin);
|
|
1486
|
+
target.createDirectSubscription = admin.createDirectSubscription.bind(admin);
|
|
1487
|
+
target.updateStripeSubscription = admin.updateStripeSubscription.bind(admin);
|
|
1488
|
+
target.cancelStripeSubscription = admin.cancelStripeSubscription.bind(admin);
|
|
1489
|
+
target.provisionWorkspaceForSubscription = admin.provisionWorkspaceForSubscription.bind(admin);
|
|
1490
|
+
target.associateWorkspaceWithSubscription = admin.associateWorkspaceWithSubscription.bind(admin);
|
|
1491
|
+
target.createSubscriptionPaymentLink = admin.createSubscriptionPaymentLink.bind(admin);
|
|
1492
|
+
target.createSetupIntent = admin.createSetupIntent.bind(admin);
|
|
1493
|
+
target.getStripePaymentMethods = admin.getStripePaymentMethods.bind(admin);
|
|
1494
|
+
target.attachStripePaymentMethod = admin.attachStripePaymentMethod.bind(admin);
|
|
1495
|
+
target.detachStripePaymentMethod = admin.detachStripePaymentMethod.bind(admin);
|
|
1496
|
+
target.setDefaultStripePaymentMethod = admin.setDefaultStripePaymentMethod.bind(admin);
|
|
1497
|
+
target.convertSubscriptionToStripe = admin.convertSubscriptionToStripe.bind(admin);
|
|
1498
|
+
target.createCustomerSetupIntent = admin.createCustomerSetupIntent.bind(admin);
|
|
1499
|
+
target.getCustomerPaymentMethods = admin.getCustomerPaymentMethods.bind(admin);
|
|
1500
|
+
target.attachCustomerPaymentMethod = admin.attachCustomerPaymentMethod.bind(admin);
|
|
1501
|
+
target.detachCustomerPaymentMethod = admin.detachCustomerPaymentMethod.bind(admin);
|
|
1502
|
+
target.setDefaultCustomerPaymentMethod = admin.setDefaultCustomerPaymentMethod.bind(admin);
|
|
1503
|
+
target.previewWorkspaceOrganizationChange = admin.previewWorkspaceOrganizationChange.bind(admin);
|
|
1504
|
+
target.changeWorkspaceOrganization = admin.changeWorkspaceOrganization.bind(admin);
|
|
1505
|
+
target.createStripeInvoice = admin.createStripeInvoice.bind(admin);
|
|
1506
|
+
target.getStripeInvoices = admin.getStripeInvoices.bind(admin);
|
|
1507
|
+
target.getStripeUpcomingInvoice = admin.getStripeUpcomingInvoice.bind(admin);
|
|
1508
|
+
target.getBillingPeriods = admin.getBillingPeriods.bind(admin);
|
|
1509
|
+
target.generateInvoice = admin.generateInvoice.bind(admin);
|
|
1510
|
+
target.getInvoices = admin.getInvoices.bind(admin);
|
|
1511
|
+
target.getInvoiceDownloadUrl = admin.getInvoiceDownloadUrl.bind(admin);
|
|
1512
|
+
target.getReceiptDownloadUrl = admin.getReceiptDownloadUrl.bind(admin);
|
|
1513
|
+
target.recordInvoicePayment = admin.recordInvoicePayment.bind(admin);
|
|
1514
|
+
target.getWorkspaceUsageDashboard = admin.getWorkspaceUsageDashboard.bind(admin);
|
|
1515
|
+
target.compareProductsWithStripe = admin.compareProductsWithStripe.bind(admin);
|
|
1516
|
+
target.syncProductToStripe = admin.syncProductToStripe.bind(admin);
|
|
1517
|
+
target.searchStripeProducts = admin.searchStripeProducts.bind(admin);
|
|
1518
|
+
target.getUsageReport = admin.getUsageReport.bind(admin);
|
|
1519
|
+
target.getSubscriptionsAsAdmin = admin.getSubscriptionsAsAdmin.bind(admin);
|
|
1520
|
+
target.getSubscriptionAsAdmin = admin.getSubscriptionAsAdmin.bind(admin);
|
|
1521
|
+
target.updateSubscriptionStatusAsAdmin = admin.updateSubscriptionStatusAsAdmin.bind(admin);
|
|
1522
|
+
target.updateSubscriptionCreditSettingsAsAdmin = admin.updateSubscriptionCreditSettingsAsAdmin.bind(admin);
|
|
1523
|
+
target.grantCreditsAsAdmin = admin.grantCreditsAsAdmin.bind(admin);
|
|
1524
|
+
target.listCreditGrantsAsAdmin = admin.listCreditGrantsAsAdmin.bind(admin);
|
|
1525
|
+
target.getVoiceMetrics = admin.getVoiceMetrics.bind(admin);
|
|
1526
|
+
target.getHealthMetrics = admin.getHealthMetrics.bind(admin);
|
|
1527
|
+
target.getHealthDetail = admin.getHealthDetail.bind(admin);
|
|
1528
|
+
target.listWorkspaceChats = admin.listWorkspaceChats.bind(admin);
|
|
1529
|
+
target.getWorkspaceChat = admin.getWorkspaceChat.bind(admin);
|
|
1530
|
+
target.rateWorkspaceChatMessage = admin.rateWorkspaceChatMessage.bind(admin);
|
|
1531
|
+
target.getTemporalAdminConfig = admin.getTemporalAdminConfig.bind(admin);
|
|
1532
|
+
target.listFailedTemporalWorkflows = admin.listFailedTemporalWorkflows.bind(admin);
|
|
1533
|
+
target.listStuckTemporalWorkflows = admin.listStuckTemporalWorkflows.bind(admin);
|
|
1534
|
+
target.getTemporalSummary = admin.getTemporalSummary.bind(admin);
|
|
1535
|
+
target.getTemporalWorkflowDetail = admin.getTemporalWorkflowDetail.bind(admin);
|
|
1536
|
+
target.getResellers = admin.getResellers.bind(admin);
|
|
1537
|
+
target.getReseller = admin.getReseller.bind(admin);
|
|
1538
|
+
target.createReseller = admin.createReseller.bind(admin);
|
|
1539
|
+
target.updateReseller = admin.updateReseller.bind(admin);
|
|
1540
|
+
target.getResellerAccounts = admin.getResellerAccounts.bind(admin);
|
|
1541
|
+
target.linkResellerToAccount = admin.linkResellerToAccount.bind(admin);
|
|
1542
|
+
target.unlinkResellerFromAccount = admin.unlinkResellerFromAccount.bind(admin);
|
|
1543
|
+
}
|
|
1544
|
+
var ApiClient = class extends GravityRailClient {
|
|
1545
|
+
// Admin API
|
|
1546
|
+
getAccounts;
|
|
1547
|
+
getAccountDetails;
|
|
1548
|
+
getAccountByUuid;
|
|
1549
|
+
getAccountMemberships;
|
|
1550
|
+
getAccountOrgMemberships;
|
|
1551
|
+
createAccountOrgMembership;
|
|
1552
|
+
deleteAccountOrgMembership;
|
|
1553
|
+
getAccountMembership;
|
|
1554
|
+
updateAccountMembership;
|
|
1555
|
+
createAccountMembership;
|
|
1556
|
+
deleteAccountMembership;
|
|
1557
|
+
updateAccountAsAdmin;
|
|
1558
|
+
createAccountAsAdmin;
|
|
1559
|
+
deleteAccountAsAdmin;
|
|
1560
|
+
lookupAccount;
|
|
1561
|
+
exportAccountData;
|
|
1562
|
+
requestAccountDeletion;
|
|
1563
|
+
cancelAccountDeletion;
|
|
1564
|
+
getOrganizations;
|
|
1565
|
+
getOrganization;
|
|
1566
|
+
getOrganizationAsAdmin;
|
|
1567
|
+
getOrganizationMembersAsAdmin;
|
|
1568
|
+
createOrganization;
|
|
1569
|
+
updateOrganization;
|
|
1570
|
+
deleteOrganization;
|
|
1571
|
+
joinOrganization;
|
|
1572
|
+
leaveOrganization;
|
|
1573
|
+
generateLogoUploadUrl;
|
|
1574
|
+
importProducts;
|
|
1575
|
+
createProductAsAdmin;
|
|
1576
|
+
getProductsAsAdmin;
|
|
1577
|
+
getProductAsAdmin;
|
|
1578
|
+
updateProductAsAdmin;
|
|
1579
|
+
deleteProductAsAdmin;
|
|
1580
|
+
getWorkspacesAsAdmin;
|
|
1581
|
+
getWorkspaceAsAdmin;
|
|
1582
|
+
getWorkspaceByNumericIdAsAdmin;
|
|
1583
|
+
createWorkspaceAsAdmin;
|
|
1584
|
+
updateWorkspaceAsAdmin;
|
|
1585
|
+
deleteWorkspaceAsAdmin;
|
|
1586
|
+
createSchemaAsAdmin;
|
|
1587
|
+
migrateSchemaAsAdmin;
|
|
1588
|
+
provisionWorkspaceAsAdmin;
|
|
1589
|
+
refreshProvisionStatusAsAdmin;
|
|
1590
|
+
enableMaintenanceMode;
|
|
1591
|
+
disableMaintenanceMode;
|
|
1592
|
+
getWorkspaceHealth;
|
|
1593
|
+
provisionPlanFeatures;
|
|
1594
|
+
validateWorkflowAccessAsAdmin;
|
|
1595
|
+
mergeMembers;
|
|
1596
|
+
getAdminWorkspaceMember;
|
|
1597
|
+
createAdminWorkspaceMember;
|
|
1598
|
+
updateAdminWorkspaceMember;
|
|
1599
|
+
getAdminWorkspaceMemberRoles;
|
|
1600
|
+
getMissingMemberships;
|
|
1601
|
+
linkMissingMembership;
|
|
1602
|
+
getUnmappedPhoneNumbers;
|
|
1603
|
+
getWorkspaceUnmappedPhoneNumbers;
|
|
1604
|
+
getWorkspacePhoneNumbersAsAdmin;
|
|
1605
|
+
getProviderPhoneNumbers;
|
|
1606
|
+
getProviderPhoneNumber;
|
|
1607
|
+
updateProviderPhoneNumber;
|
|
1608
|
+
mapMainAccountPhone;
|
|
1609
|
+
unmapPhoneNumber;
|
|
1610
|
+
searchAvailablePhoneNumbersAsAdmin;
|
|
1611
|
+
purchasePhoneNumberAsAdmin;
|
|
1612
|
+
startBulkPhoneClassification;
|
|
1613
|
+
getOrgA2PStatusAsAdmin;
|
|
1614
|
+
resetOrgA2PStatusAsAdmin;
|
|
1615
|
+
getSiteMappings;
|
|
1616
|
+
getSiteMapping;
|
|
1617
|
+
updateSiteMapping;
|
|
1618
|
+
updateSiteMappingWorkspace;
|
|
1619
|
+
adminDeleteSiteMapping;
|
|
1620
|
+
createSiteMapping;
|
|
1621
|
+
createOrUpdateSiteMapping;
|
|
1622
|
+
deleteSiteMapping;
|
|
1623
|
+
getInboxMappings;
|
|
1624
|
+
getInboxMapping;
|
|
1625
|
+
updateInboxMapping;
|
|
1626
|
+
deleteAdminInboxMapping;
|
|
1627
|
+
generateChatSummaries;
|
|
1628
|
+
executeQuery;
|
|
1629
|
+
listAllThemes;
|
|
1630
|
+
migrateRoutineCadenceKeys;
|
|
1631
|
+
startBulkTOSAcceptance;
|
|
1632
|
+
startTokenUsageBackfill;
|
|
1633
|
+
updateChatMessage;
|
|
1634
|
+
createCustomerFromAccount;
|
|
1635
|
+
getCustomers;
|
|
1636
|
+
getCustomer;
|
|
1637
|
+
createCustomer;
|
|
1638
|
+
updateCustomer;
|
|
1639
|
+
getCustomerAccounts;
|
|
1640
|
+
linkCustomerToAccount;
|
|
1641
|
+
unlinkCustomerFromAccount;
|
|
1642
|
+
syncCustomerToStripe;
|
|
1643
|
+
getStripeCustomer;
|
|
1644
|
+
createStripeCustomer;
|
|
1645
|
+
updateStripeCustomer;
|
|
1646
|
+
getStripeSubscriptions;
|
|
1647
|
+
createStripeSubscription;
|
|
1648
|
+
createDirectSubscription;
|
|
1649
|
+
updateStripeSubscription;
|
|
1650
|
+
cancelStripeSubscription;
|
|
1651
|
+
provisionWorkspaceForSubscription;
|
|
1652
|
+
associateWorkspaceWithSubscription;
|
|
1653
|
+
createSubscriptionPaymentLink;
|
|
1654
|
+
createSetupIntent;
|
|
1655
|
+
getStripePaymentMethods;
|
|
1656
|
+
attachStripePaymentMethod;
|
|
1657
|
+
detachStripePaymentMethod;
|
|
1658
|
+
setDefaultStripePaymentMethod;
|
|
1659
|
+
createCustomerSetupIntent;
|
|
1660
|
+
getCustomerPaymentMethods;
|
|
1661
|
+
attachCustomerPaymentMethod;
|
|
1662
|
+
detachCustomerPaymentMethod;
|
|
1663
|
+
setDefaultCustomerPaymentMethod;
|
|
1664
|
+
convertSubscriptionToStripe;
|
|
1665
|
+
previewWorkspaceOrganizationChange;
|
|
1666
|
+
changeWorkspaceOrganization;
|
|
1667
|
+
createStripeInvoice;
|
|
1668
|
+
getStripeInvoices;
|
|
1669
|
+
getStripeUpcomingInvoice;
|
|
1670
|
+
getWorkspaceUsageDashboard;
|
|
1671
|
+
compareProductsWithStripe;
|
|
1672
|
+
syncProductToStripe;
|
|
1673
|
+
searchStripeProducts;
|
|
1674
|
+
getUsageReport;
|
|
1675
|
+
getSubscriptionsAsAdmin;
|
|
1676
|
+
getSubscriptionAsAdmin;
|
|
1677
|
+
updateSubscriptionStatusAsAdmin;
|
|
1678
|
+
updateSubscriptionCreditSettingsAsAdmin;
|
|
1679
|
+
grantCreditsAsAdmin;
|
|
1680
|
+
listCreditGrantsAsAdmin;
|
|
1681
|
+
getVoiceMetrics;
|
|
1682
|
+
getHealthMetrics;
|
|
1683
|
+
getHealthDetail;
|
|
1684
|
+
listWorkspaceChats;
|
|
1685
|
+
getWorkspaceChat;
|
|
1686
|
+
rateWorkspaceChatMessage;
|
|
1687
|
+
getTemporalAdminConfig;
|
|
1688
|
+
listFailedTemporalWorkflows;
|
|
1689
|
+
listStuckTemporalWorkflows;
|
|
1690
|
+
getTemporalSummary;
|
|
1691
|
+
getTemporalWorkflowDetail;
|
|
1692
|
+
getResellers;
|
|
1693
|
+
getReseller;
|
|
1694
|
+
createReseller;
|
|
1695
|
+
updateReseller;
|
|
1696
|
+
getResellerAccounts;
|
|
1697
|
+
linkResellerToAccount;
|
|
1698
|
+
unlinkResellerFromAccount;
|
|
1699
|
+
getBillingPeriods;
|
|
1700
|
+
generateInvoice;
|
|
1701
|
+
getInvoices;
|
|
1702
|
+
getInvoiceDownloadUrl;
|
|
1703
|
+
getReceiptDownloadUrl;
|
|
1704
|
+
recordInvoicePayment;
|
|
1705
|
+
adminApi;
|
|
1706
|
+
constructor(apiKey, baseUrl3, customFetch) {
|
|
1707
|
+
super(apiKey, baseUrl3, customFetch);
|
|
1708
|
+
this.adminApi = new AdminApi(apiKey, baseUrl3, customFetch);
|
|
1709
|
+
bindAdminMethods(this, this.adminApi);
|
|
1710
|
+
}
|
|
1711
|
+
/**
|
|
1712
|
+
* Propagates acting member switches to the admin API module as well.
|
|
1713
|
+
*/
|
|
1714
|
+
setActingMember(memberUuid) {
|
|
1715
|
+
super.setActingMember(memberUuid);
|
|
1716
|
+
if (typeof this.adminApi.setActingMember === "function") {
|
|
1717
|
+
this.adminApi.setActingMember(memberUuid);
|
|
1718
|
+
}
|
|
1719
|
+
}
|
|
1720
|
+
};
|
|
1721
|
+
|
|
1722
|
+
// src/lib/context.ts
|
|
269
1723
|
import { homedir } from "os";
|
|
270
1724
|
|
|
271
1725
|
// src/lib/output.ts
|
|
@@ -448,7 +1902,7 @@ async function tryTokenRefresh(ctx, creds) {
|
|
|
448
1902
|
ctx.env
|
|
449
1903
|
);
|
|
450
1904
|
if (!refreshed?.accessToken) return null;
|
|
451
|
-
const apiClient = new
|
|
1905
|
+
const apiClient = new ApiClient(refreshed.accessToken, ctx.envConfig.apiUrl);
|
|
452
1906
|
return { ...ctx, accessToken: refreshed.accessToken, apiClient };
|
|
453
1907
|
}
|
|
454
1908
|
function createContext(opts) {
|
|
@@ -472,12 +1926,12 @@ async function createAuthenticatedContext(opts) {
|
|
|
472
1926
|
devRealmsPath = loadDevCloudRealmFile(namespace);
|
|
473
1927
|
}
|
|
474
1928
|
const { token, workspaceUuid } = loadRealmCredentials(opts.realm, devRealmsPath);
|
|
475
|
-
const apiClient = new
|
|
1929
|
+
const apiClient = new ApiClient(token, ctx.envConfig.apiUrl);
|
|
476
1930
|
return { ...ctx, accessToken: token, apiClient, realmWorkspace: workspaceUuid };
|
|
477
1931
|
}
|
|
478
1932
|
const apiKey = process.env.GRAVITY_RAIL_API_KEY;
|
|
479
1933
|
if (apiKey) {
|
|
480
|
-
const apiClient = new
|
|
1934
|
+
const apiClient = new ApiClient(apiKey, ctx.envConfig.apiUrl);
|
|
481
1935
|
return { ...ctx, accessToken: apiKey, apiClient };
|
|
482
1936
|
}
|
|
483
1937
|
const creds = ctx.credentialsManager.load(ctx.env);
|
|
@@ -485,7 +1939,7 @@ async function createAuthenticatedContext(opts) {
|
|
|
485
1939
|
const buffer = 5 * 60 * 1e3;
|
|
486
1940
|
const notExpired = !creds.expiresAt || new Date(creds.expiresAt) > new Date(Date.now() + buffer);
|
|
487
1941
|
if (notExpired) {
|
|
488
|
-
const apiClient = new
|
|
1942
|
+
const apiClient = new ApiClient(creds.accessToken, ctx.envConfig.apiUrl);
|
|
489
1943
|
return { ...ctx, accessToken: creds.accessToken, apiClient };
|
|
490
1944
|
}
|
|
491
1945
|
const refreshed = await tryTokenRefresh(ctx, creds);
|
|
@@ -517,7 +1971,7 @@ async function createPublicAuthenticatedContext(opts) {
|
|
|
517
1971
|
const ctx = createPublicContext(opts);
|
|
518
1972
|
const apiKey = process.env.GRAVITY_RAIL_API_KEY;
|
|
519
1973
|
if (apiKey) {
|
|
520
|
-
const apiClient = new
|
|
1974
|
+
const apiClient = new ApiClient(apiKey, ctx.envConfig.apiUrl);
|
|
521
1975
|
return { ...ctx, accessToken: apiKey, apiClient };
|
|
522
1976
|
}
|
|
523
1977
|
const creds = ctx.credentialsManager.load(ctx.env);
|
|
@@ -525,7 +1979,7 @@ async function createPublicAuthenticatedContext(opts) {
|
|
|
525
1979
|
const buffer = 5 * 60 * 1e3;
|
|
526
1980
|
const notExpired = !creds.expiresAt || new Date(creds.expiresAt) > new Date(Date.now() + buffer);
|
|
527
1981
|
if (notExpired) {
|
|
528
|
-
const apiClient = new
|
|
1982
|
+
const apiClient = new ApiClient(creds.accessToken, ctx.envConfig.apiUrl);
|
|
529
1983
|
return { ...ctx, accessToken: creds.accessToken, apiClient };
|
|
530
1984
|
}
|
|
531
1985
|
const refreshed = await tryTokenRefresh(ctx, creds);
|
|
@@ -1358,6 +2812,10 @@ var MESSAGE_COLUMNS2 = [
|
|
|
1358
2812
|
getValue: (item) => String(item.content ?? "").slice(0, 80),
|
|
1359
2813
|
maxWidth: 80
|
|
1360
2814
|
},
|
|
2815
|
+
{
|
|
2816
|
+
header: "TOOL_CALLS",
|
|
2817
|
+
getValue: (item) => Array.isArray(item.tool_calls) && item.tool_calls.length > 0 ? item.tool_calls.map((t) => t.function?.name ?? "?").join(",") : ""
|
|
2818
|
+
},
|
|
1361
2819
|
COL.created()
|
|
1362
2820
|
];
|
|
1363
2821
|
var chatsDomain = {
|
|
@@ -1391,13 +2849,35 @@ var chatsDomain = {
|
|
|
1391
2849
|
// Messages
|
|
1392
2850
|
{
|
|
1393
2851
|
path: ["chats", "messages", "list"],
|
|
1394
|
-
description: "List messages for a chat",
|
|
2852
|
+
description: "List messages for a chat. Use --limit/--offset to page; the API caps a single request at 100. Tool-call shell rows that the API filter excludes (parent_message_id IS NOT NULL or parent_call_id IS NOT NULL) are still hidden \u2014 use `gr chats inspect --id <chat>` for the full debug view.",
|
|
1395
2853
|
requiresWorkspace: true,
|
|
1396
|
-
args: [
|
|
2854
|
+
args: [
|
|
2855
|
+
{ name: "chat-id", description: "Chat ID", required: true },
|
|
2856
|
+
{
|
|
2857
|
+
name: "limit",
|
|
2858
|
+
description: "Max messages to return (1-100, default 100)"
|
|
2859
|
+
},
|
|
2860
|
+
{
|
|
2861
|
+
name: "offset",
|
|
2862
|
+
description: "Offset for pagination (default 0)"
|
|
2863
|
+
}
|
|
2864
|
+
],
|
|
1397
2865
|
handler: async ({ ctx, workspace, args }) => {
|
|
2866
|
+
const rawLimit = args.limit;
|
|
2867
|
+
const rawOffset = args.offset;
|
|
2868
|
+
const limit = rawLimit === void 0 || rawLimit === null || rawLimit === "" ? 100 : Number(rawLimit);
|
|
2869
|
+
const offset = rawOffset === void 0 || rawOffset === null || rawOffset === "" ? 0 : Number(rawOffset);
|
|
2870
|
+
if (!Number.isInteger(limit) || limit < 1 || limit > 100) {
|
|
2871
|
+
throw new Error("--limit must be an integer between 1 and 100");
|
|
2872
|
+
}
|
|
2873
|
+
if (!Number.isInteger(offset) || offset < 0) {
|
|
2874
|
+
throw new Error("--offset must be a non-negative integer");
|
|
2875
|
+
}
|
|
1398
2876
|
const result = await requireAuth(ctx).apiClient.getChatMessages(
|
|
1399
2877
|
workspace,
|
|
1400
|
-
requireNumber(args, "chat-id")
|
|
2878
|
+
requireNumber(args, "chat-id"),
|
|
2879
|
+
limit,
|
|
2880
|
+
offset
|
|
1401
2881
|
);
|
|
1402
2882
|
outputData(result, ctx, MESSAGE_COLUMNS2);
|
|
1403
2883
|
}
|
|
@@ -3512,6 +4992,11 @@ var eventRulesCrud = crudCommands({
|
|
|
3512
4992
|
createMethod: "createEventRule",
|
|
3513
4993
|
updateMethod: "updateEventRule",
|
|
3514
4994
|
deleteMethod: "deleteEventRule",
|
|
4995
|
+
// The endpoint is paginated and excludes nothing by object_type. Without
|
|
4996
|
+
// 'full', the CLI silently returned only page 1 (default 25 rules), which
|
|
4997
|
+
// hid routine/journey/calendar-scoped rules in workspaces with many
|
|
4998
|
+
// task-scoped rules. 'full' wires up --page/--page-size and --all.
|
|
4999
|
+
paginationSupport: "full",
|
|
3515
5000
|
columns: RULE_COLUMNS,
|
|
3516
5001
|
createExamples: [
|
|
3517
5002
|
`gr events rules create -w $WID --data '{"name":"Label on step","objectType":"journey",`,
|
|
@@ -3559,6 +5044,48 @@ var eventsDomain = {
|
|
|
3559
5044
|
outputData(result, ctx);
|
|
3560
5045
|
}
|
|
3561
5046
|
},
|
|
5047
|
+
{
|
|
5048
|
+
// The /event-rules/search endpoint returns an unpaginated list — the
|
|
5049
|
+
// server applies the filters and returns whatever matches. No --all
|
|
5050
|
+
// flag is needed; if the result becomes too large in practice,
|
|
5051
|
+
// tighten the filter rather than paginate.
|
|
5052
|
+
path: ["events", "rules", "search"],
|
|
5053
|
+
description: "Search event rules by object/event/action type or related entity ID",
|
|
5054
|
+
requiresWorkspace: true,
|
|
5055
|
+
args: [
|
|
5056
|
+
{
|
|
5057
|
+
name: "object-type",
|
|
5058
|
+
description: "Filter by object type (task, routine, journey, workflow, calendar, ...)"
|
|
5059
|
+
},
|
|
5060
|
+
{ name: "event-type", description: "Filter by event type" },
|
|
5061
|
+
{ name: "action-type", description: "Filter by action type" },
|
|
5062
|
+
{ name: "task-id", description: "Filter by task ID" },
|
|
5063
|
+
{ name: "data-type-id", description: "Filter by data type ID" },
|
|
5064
|
+
{ name: "routine-id", description: "Filter by routine ID" },
|
|
5065
|
+
{ name: "workflow-id", description: "Filter by workflow ID" },
|
|
5066
|
+
{ name: "journey-step-id", description: "Filter by journey step ID" },
|
|
5067
|
+
{
|
|
5068
|
+
name: "include-disabled",
|
|
5069
|
+
description: "Include inactive rules (default: active only)"
|
|
5070
|
+
}
|
|
5071
|
+
],
|
|
5072
|
+
columns: RULE_COLUMNS,
|
|
5073
|
+
handler: async ({ ctx, workspace, args }) => {
|
|
5074
|
+
const opts = {};
|
|
5075
|
+
if (args["object-type"]) opts.objectType = args["object-type"];
|
|
5076
|
+
if (args["event-type"]) opts.eventType = args["event-type"];
|
|
5077
|
+
if (args["action-type"]) opts.actionType = args["action-type"];
|
|
5078
|
+
if (args["task-id"]) opts.taskId = requireNumber(args, "task-id");
|
|
5079
|
+
if (args["data-type-id"]) opts.dataTypeId = requireNumber(args, "data-type-id");
|
|
5080
|
+
if (args["routine-id"]) opts.routineId = requireNumber(args, "routine-id");
|
|
5081
|
+
if (args["workflow-id"]) opts.workflowId = requireNumber(args, "workflow-id");
|
|
5082
|
+
if (args["journey-step-id"])
|
|
5083
|
+
opts.journeyStepId = requireNumber(args, "journey-step-id");
|
|
5084
|
+
if (args["include-disabled"]) opts.includeDisabled = true;
|
|
5085
|
+
const result = await requireAuth(ctx).apiClient.searchEventRules(workspace, opts);
|
|
5086
|
+
outputData(result, ctx, RULE_COLUMNS);
|
|
5087
|
+
}
|
|
5088
|
+
},
|
|
3562
5089
|
// Routines
|
|
3563
5090
|
...crudCommands({
|
|
3564
5091
|
prefix: ["routines"],
|
|
@@ -5963,8 +7490,9 @@ var mcpServersDomain = {
|
|
|
5963
7490
|
// src/domains/member-memories.ts
|
|
5964
7491
|
var COLUMNS21 = [
|
|
5965
7492
|
{ header: "KEY", getValue: (item) => item.key ?? "" },
|
|
5966
|
-
{ header: "
|
|
5967
|
-
{ header: "
|
|
7493
|
+
{ header: "TYPE", getValue: (item) => item.type ?? "basic" },
|
|
7494
|
+
{ header: "DESCRIPTION", getValue: (item) => truncate(item.description ?? "", 60) },
|
|
7495
|
+
{ header: "PRIORITY", getValue: (item) => item.priority ?? 0 },
|
|
5968
7496
|
{ header: "UPDATED", getValue: (item) => item.updatedAt ?? item.createdAt ?? "" }
|
|
5969
7497
|
];
|
|
5970
7498
|
function truncate(s, max) {
|
|
@@ -5972,7 +7500,7 @@ function truncate(s, max) {
|
|
|
5972
7500
|
}
|
|
5973
7501
|
var memberMemoriesDomain = {
|
|
5974
7502
|
name: "member-memories",
|
|
5975
|
-
description: "Manage member
|
|
7503
|
+
description: "Manage member persistent memories",
|
|
5976
7504
|
commands: [
|
|
5977
7505
|
{
|
|
5978
7506
|
path: ["member-memories", "list"],
|
|
@@ -5981,38 +7509,18 @@ var memberMemoriesDomain = {
|
|
|
5981
7509
|
args: [
|
|
5982
7510
|
{ name: "member-id", description: "Member ID", required: true },
|
|
5983
7511
|
{
|
|
5984
|
-
name: "
|
|
5985
|
-
description: "
|
|
5986
|
-
}
|
|
5987
|
-
|
|
5988
|
-
handler: async ({ ctx, workspace, args }) => {
|
|
5989
|
-
const memberId = requireNumber(args, "member-id");
|
|
5990
|
-
const strategy = args.strategy;
|
|
5991
|
-
const result = await requireAuth(ctx).apiClient.getMemberMemories(workspace, memberId, {
|
|
5992
|
-
strategy
|
|
5993
|
-
});
|
|
5994
|
-
outputData(listResult(result, false), ctx, COLUMNS21);
|
|
5995
|
-
}
|
|
5996
|
-
},
|
|
5997
|
-
{
|
|
5998
|
-
path: ["member-memories", "search"],
|
|
5999
|
-
description: "Search memories for a member by query",
|
|
6000
|
-
requiresWorkspace: true,
|
|
6001
|
-
args: [
|
|
6002
|
-
{ name: "member-id", description: "Member ID", required: true },
|
|
6003
|
-
{ name: "query", description: "Search query", required: true },
|
|
6004
|
-
{
|
|
6005
|
-
name: "strategy",
|
|
6006
|
-
description: "Filter by strategy (preferences, semantic, summaries, episodic)"
|
|
6007
|
-
}
|
|
7512
|
+
name: "type",
|
|
7513
|
+
description: "Memory type filter (basic, preferences, semantic, summaries, episodic, all)"
|
|
7514
|
+
},
|
|
7515
|
+
{ name: "query", description: "Semantic search query (for AgentCore memory types)" }
|
|
6008
7516
|
],
|
|
6009
7517
|
handler: async ({ ctx, workspace, args }) => {
|
|
6010
7518
|
const memberId = requireNumber(args, "member-id");
|
|
6011
|
-
const
|
|
6012
|
-
const
|
|
7519
|
+
const type = args.type;
|
|
7520
|
+
const query = args.query;
|
|
6013
7521
|
const result = await requireAuth(ctx).apiClient.getMemberMemories(workspace, memberId, {
|
|
6014
|
-
|
|
6015
|
-
|
|
7522
|
+
type,
|
|
7523
|
+
query
|
|
6016
7524
|
});
|
|
6017
7525
|
outputData(listResult(result, false), ctx, COLUMNS21);
|
|
6018
7526
|
}
|
|
@@ -6025,17 +7533,20 @@ var memberMemoriesDomain = {
|
|
|
6025
7533
|
args: [
|
|
6026
7534
|
{ name: "member-id", description: "Member ID", required: true },
|
|
6027
7535
|
{ name: "key", description: "Memory key", required: true },
|
|
6028
|
-
{
|
|
7536
|
+
{
|
|
7537
|
+
name: "type",
|
|
7538
|
+
description: "Memory type (basic, preferences, semantic, summaries, episodic)"
|
|
7539
|
+
}
|
|
6029
7540
|
],
|
|
6030
7541
|
handler: async ({ ctx, workspace, args }) => {
|
|
6031
7542
|
const memberId = requireNumber(args, "member-id");
|
|
6032
7543
|
const key = requireString(args, "key");
|
|
6033
|
-
const
|
|
7544
|
+
const type = args.type;
|
|
6034
7545
|
await requireAuth(ctx).apiClient.deleteMemberMemory(
|
|
6035
7546
|
workspace,
|
|
6036
7547
|
memberId,
|
|
6037
7548
|
key,
|
|
6038
|
-
|
|
7549
|
+
type ? { type } : void 0
|
|
6039
7550
|
);
|
|
6040
7551
|
process.stdout.write(`Deleted memory ${key}
|
|
6041
7552
|
`);
|
|
@@ -6221,13 +7732,339 @@ var operatorGroupsDomain = {
|
|
|
6221
7732
|
|
|
6222
7733
|
// src/domains/org.ts
|
|
6223
7734
|
var ORG_COLUMNS = [
|
|
6224
|
-
|
|
6225
|
-
|
|
6226
|
-
{ header: "ROLE", getValue: (item) => item.role
|
|
7735
|
+
{ header: "ID", getValue: (item) => String(item.organizationId ?? "") },
|
|
7736
|
+
{ header: "NAME", getValue: (item) => item.organizationName || "" },
|
|
7737
|
+
{ header: "ROLE", getValue: (item) => item.role || "" }
|
|
7738
|
+
];
|
|
7739
|
+
var ORG_DOMAIN_COLUMNS = [
|
|
7740
|
+
{ header: "UUID", getValue: (item) => item.uuid ?? "" },
|
|
7741
|
+
{ header: "DOMAIN", getValue: (item) => item.domain ?? "" },
|
|
7742
|
+
{ header: "OWNERSHIP", getValue: (item) => item.ownershipStatus ?? "" },
|
|
7743
|
+
{ header: "EMAIL", getValue: (item) => item.emailStatus ?? "-" },
|
|
7744
|
+
{ header: "SITE", getValue: (item) => item.siteStatus ?? "-" },
|
|
7745
|
+
{ header: "TXT HOST", getValue: (item) => item.ownershipDnsRecord?.host ?? "" },
|
|
7746
|
+
{
|
|
7747
|
+
header: "TXT VALUE",
|
|
7748
|
+
getValue: (item) => item.ownershipDnsRecord?.value ?? "",
|
|
7749
|
+
maxWidth: 80
|
|
7750
|
+
}
|
|
7751
|
+
];
|
|
7752
|
+
function requireOrgId(args) {
|
|
7753
|
+
const val = args["org-uuid"] ?? args.org;
|
|
7754
|
+
if (typeof val !== "string" || !val) {
|
|
7755
|
+
throw new CLIError("Missing required argument: --org-uuid");
|
|
7756
|
+
}
|
|
7757
|
+
return val;
|
|
7758
|
+
}
|
|
7759
|
+
function requireDomainUuid(args) {
|
|
7760
|
+
const val = args["domain-uuid"] ?? args.uuid;
|
|
7761
|
+
if (typeof val !== "string" || !val) {
|
|
7762
|
+
throw new CLIError("Missing required argument: --domain-uuid");
|
|
7763
|
+
}
|
|
7764
|
+
return val;
|
|
7765
|
+
}
|
|
7766
|
+
function requireDomain(args) {
|
|
7767
|
+
const val = args.domain;
|
|
7768
|
+
if (typeof val !== "string" || !val) {
|
|
7769
|
+
throw new CLIError("Missing required argument: --domain");
|
|
7770
|
+
}
|
|
7771
|
+
return val;
|
|
7772
|
+
}
|
|
7773
|
+
var ORG_UUID_ARG = {
|
|
7774
|
+
name: "org-uuid",
|
|
7775
|
+
aliases: ["org"],
|
|
7776
|
+
description: "Organization UUID or ID",
|
|
7777
|
+
required: true
|
|
7778
|
+
};
|
|
7779
|
+
var DOMAIN_UUID_ARG = {
|
|
7780
|
+
name: "domain-uuid",
|
|
7781
|
+
aliases: ["domain-id"],
|
|
7782
|
+
description: "OrgDomain UUID",
|
|
7783
|
+
required: true
|
|
7784
|
+
};
|
|
7785
|
+
function pluralize(count, singular, plural = `${singular}s`) {
|
|
7786
|
+
return count === 1 ? singular : plural;
|
|
7787
|
+
}
|
|
7788
|
+
function emailVerifyCommand(path, description) {
|
|
7789
|
+
return {
|
|
7790
|
+
path,
|
|
7791
|
+
description,
|
|
7792
|
+
mutates: true,
|
|
7793
|
+
requiresWorkspace: false,
|
|
7794
|
+
args: [ORG_UUID_ARG, DOMAIN_UUID_ARG],
|
|
7795
|
+
examples: [
|
|
7796
|
+
`yarn gr ${path.join(" ")} --org-uuid $ORG_UUID --domain-uuid $DOMAIN_UUID --allow-write`
|
|
7797
|
+
],
|
|
7798
|
+
handler: async (hctx) => {
|
|
7799
|
+
const result = await requireAuth(hctx.ctx).apiClient.verifyOrgDomainEmail(
|
|
7800
|
+
requireOrgId(hctx.args),
|
|
7801
|
+
requireDomainUuid(hctx.args)
|
|
7802
|
+
);
|
|
7803
|
+
outputSingle(result, hctx.ctx);
|
|
7804
|
+
}
|
|
7805
|
+
};
|
|
7806
|
+
}
|
|
7807
|
+
function siteVerifyCommand(path, description) {
|
|
7808
|
+
return {
|
|
7809
|
+
path,
|
|
7810
|
+
description,
|
|
7811
|
+
mutates: true,
|
|
7812
|
+
requiresWorkspace: false,
|
|
7813
|
+
args: [ORG_UUID_ARG, DOMAIN_UUID_ARG],
|
|
7814
|
+
examples: [
|
|
7815
|
+
`yarn gr ${path.join(" ")} --org-uuid $ORG_UUID --domain-uuid $DOMAIN_UUID --allow-write`
|
|
7816
|
+
],
|
|
7817
|
+
handler: async (hctx) => {
|
|
7818
|
+
const result = await requireAuth(hctx.ctx).apiClient.verifyOrgDomainSite(
|
|
7819
|
+
requireOrgId(hctx.args),
|
|
7820
|
+
requireDomainUuid(hctx.args)
|
|
7821
|
+
);
|
|
7822
|
+
outputSingle(result, hctx.ctx);
|
|
7823
|
+
}
|
|
7824
|
+
};
|
|
7825
|
+
}
|
|
7826
|
+
function registerDomainCommand(path) {
|
|
7827
|
+
return {
|
|
7828
|
+
path,
|
|
7829
|
+
description: "Register an organization domain and return ownership TXT instructions",
|
|
7830
|
+
mutates: true,
|
|
7831
|
+
requiresWorkspace: false,
|
|
7832
|
+
args: [
|
|
7833
|
+
ORG_UUID_ARG,
|
|
7834
|
+
{ name: "domain", description: "Domain to register, e.g. example.com", required: true }
|
|
7835
|
+
],
|
|
7836
|
+
examples: [
|
|
7837
|
+
`yarn gr ${path.join(" ")} --org-uuid $ORG_UUID --domain example.com --allow-write`
|
|
7838
|
+
],
|
|
7839
|
+
handler: async (hctx) => {
|
|
7840
|
+
const result = await requireAuth(hctx.ctx).apiClient.registerOrgDomain(
|
|
7841
|
+
requireOrgId(hctx.args),
|
|
7842
|
+
requireDomain(hctx.args)
|
|
7843
|
+
);
|
|
7844
|
+
outputSingle(result, hctx.ctx, ORG_DOMAIN_COLUMNS);
|
|
7845
|
+
}
|
|
7846
|
+
};
|
|
7847
|
+
}
|
|
7848
|
+
var domainCommands = [
|
|
7849
|
+
{
|
|
7850
|
+
path: ["org", "domains", "list"],
|
|
7851
|
+
description: "List domains registered to an organization",
|
|
7852
|
+
requiresWorkspace: false,
|
|
7853
|
+
args: [ORG_UUID_ARG],
|
|
7854
|
+
examples: ["yarn gr org domains list --org-uuid $ORG_UUID"],
|
|
7855
|
+
handler: async (hctx) => {
|
|
7856
|
+
const result = await requireAuth(hctx.ctx).apiClient.listOrgDomains(
|
|
7857
|
+
requireOrgId(hctx.args)
|
|
7858
|
+
);
|
|
7859
|
+
outputData(result, hctx.ctx, ORG_DOMAIN_COLUMNS);
|
|
7860
|
+
}
|
|
7861
|
+
},
|
|
7862
|
+
{
|
|
7863
|
+
path: ["org", "domains", "get"],
|
|
7864
|
+
description: "Get a registered organization domain",
|
|
7865
|
+
requiresWorkspace: false,
|
|
7866
|
+
args: [ORG_UUID_ARG, DOMAIN_UUID_ARG],
|
|
7867
|
+
examples: ["yarn gr org domains get --org-uuid $ORG_UUID --domain-uuid $DOMAIN_UUID"],
|
|
7868
|
+
handler: async (hctx) => {
|
|
7869
|
+
const result = await requireAuth(hctx.ctx).apiClient.getOrgDomain(
|
|
7870
|
+
requireOrgId(hctx.args),
|
|
7871
|
+
requireDomainUuid(hctx.args)
|
|
7872
|
+
);
|
|
7873
|
+
outputSingle(result, hctx.ctx, ORG_DOMAIN_COLUMNS);
|
|
7874
|
+
}
|
|
7875
|
+
},
|
|
7876
|
+
registerDomainCommand(["org", "domains", "register"]),
|
|
7877
|
+
registerDomainCommand(["org", "domains", "create"]),
|
|
7878
|
+
{
|
|
7879
|
+
path: ["org", "domains", "verify-ownership"],
|
|
7880
|
+
description: "Verify domain ownership by checking the _gravity-verify TXT record",
|
|
7881
|
+
mutates: true,
|
|
7882
|
+
requiresWorkspace: false,
|
|
7883
|
+
args: [ORG_UUID_ARG, DOMAIN_UUID_ARG],
|
|
7884
|
+
examples: [
|
|
7885
|
+
"yarn gr org domains verify-ownership --org-uuid $ORG_UUID --domain-uuid $DOMAIN_UUID --allow-write"
|
|
7886
|
+
],
|
|
7887
|
+
handler: async (hctx) => {
|
|
7888
|
+
const result = await requireAuth(hctx.ctx).apiClient.verifyOrgDomainOwnership(
|
|
7889
|
+
requireOrgId(hctx.args),
|
|
7890
|
+
requireDomainUuid(hctx.args)
|
|
7891
|
+
);
|
|
7892
|
+
outputSingle(result, hctx.ctx);
|
|
7893
|
+
}
|
|
7894
|
+
},
|
|
7895
|
+
{
|
|
7896
|
+
path: ["org", "domains", "delete"],
|
|
7897
|
+
description: "Delete a registered organization domain",
|
|
7898
|
+
mutates: true,
|
|
7899
|
+
requiresWorkspace: false,
|
|
7900
|
+
args: [ORG_UUID_ARG, DOMAIN_UUID_ARG],
|
|
7901
|
+
examples: [
|
|
7902
|
+
"yarn gr org domains delete --org-uuid $ORG_UUID --domain-uuid $DOMAIN_UUID --allow-write"
|
|
7903
|
+
],
|
|
7904
|
+
handler: async (hctx) => {
|
|
7905
|
+
const domainUuid = requireDomainUuid(hctx.args);
|
|
7906
|
+
await requireAuth(hctx.ctx).apiClient.deleteOrgDomain(requireOrgId(hctx.args), domainUuid);
|
|
7907
|
+
process.stdout.write(`Deleted org domain ${domainUuid}
|
|
7908
|
+
`);
|
|
7909
|
+
}
|
|
7910
|
+
},
|
|
7911
|
+
{
|
|
7912
|
+
path: ["org", "domains", "email", "enable"],
|
|
7913
|
+
description: "Enable email DNS records on a verified organization domain",
|
|
7914
|
+
mutates: true,
|
|
7915
|
+
requiresWorkspace: false,
|
|
7916
|
+
args: [ORG_UUID_ARG, DOMAIN_UUID_ARG],
|
|
7917
|
+
examples: [
|
|
7918
|
+
"yarn gr org domains email enable --org-uuid $ORG_UUID --domain-uuid $DOMAIN_UUID --allow-write"
|
|
7919
|
+
],
|
|
7920
|
+
handler: async (hctx) => {
|
|
7921
|
+
const result = await requireAuth(hctx.ctx).apiClient.enableOrgDomainEmail(
|
|
7922
|
+
requireOrgId(hctx.args),
|
|
7923
|
+
requireDomainUuid(hctx.args)
|
|
7924
|
+
);
|
|
7925
|
+
outputSingle(result, hctx.ctx);
|
|
7926
|
+
}
|
|
7927
|
+
},
|
|
7928
|
+
{
|
|
7929
|
+
path: ["org", "domains", "email", "get"],
|
|
7930
|
+
description: "Get email DNS setup and status for an organization domain",
|
|
7931
|
+
requiresWorkspace: false,
|
|
7932
|
+
args: [ORG_UUID_ARG, DOMAIN_UUID_ARG],
|
|
7933
|
+
examples: ["yarn gr org domains email get --org-uuid $ORG_UUID --domain-uuid $DOMAIN_UUID"],
|
|
7934
|
+
handler: async (hctx) => {
|
|
7935
|
+
const result = await requireAuth(hctx.ctx).apiClient.getOrgDomainEmail(
|
|
7936
|
+
requireOrgId(hctx.args),
|
|
7937
|
+
requireDomainUuid(hctx.args)
|
|
7938
|
+
);
|
|
7939
|
+
outputSingle(result, hctx.ctx);
|
|
7940
|
+
}
|
|
7941
|
+
},
|
|
7942
|
+
emailVerifyCommand(
|
|
7943
|
+
["org", "domains", "email", "verify"],
|
|
7944
|
+
"Verify email DNS records, including MX"
|
|
7945
|
+
),
|
|
7946
|
+
emailVerifyCommand(
|
|
7947
|
+
["org", "domains", "email", "verify-mx"],
|
|
7948
|
+
"Verify email DNS records, including MX"
|
|
7949
|
+
),
|
|
7950
|
+
{
|
|
7951
|
+
path: ["org", "domains", "email", "disable"],
|
|
7952
|
+
description: "Disable email on an organization domain",
|
|
7953
|
+
mutates: true,
|
|
7954
|
+
requiresWorkspace: false,
|
|
7955
|
+
args: [
|
|
7956
|
+
ORG_UUID_ARG,
|
|
7957
|
+
DOMAIN_UUID_ARG,
|
|
7958
|
+
{
|
|
7959
|
+
name: "confirm",
|
|
7960
|
+
description: "Confirm removal of inbox routing that depends on this domain",
|
|
7961
|
+
isFlag: true
|
|
7962
|
+
}
|
|
7963
|
+
],
|
|
7964
|
+
examples: [
|
|
7965
|
+
"yarn gr org domains email disable --org-uuid $ORG_UUID --domain-uuid $DOMAIN_UUID --confirm --allow-write"
|
|
7966
|
+
],
|
|
7967
|
+
handler: async (hctx) => {
|
|
7968
|
+
const domainUuid = requireDomainUuid(hctx.args);
|
|
7969
|
+
const result = await requireAuth(hctx.ctx).apiClient.disableOrgDomainEmail(
|
|
7970
|
+
requireOrgId(hctx.args),
|
|
7971
|
+
domainUuid,
|
|
7972
|
+
hctx.args.confirm === true
|
|
7973
|
+
);
|
|
7974
|
+
if (!result.ok) {
|
|
7975
|
+
const { inboxCount } = result.impact;
|
|
7976
|
+
throw new CLIError(
|
|
7977
|
+
`Email is still used by ${inboxCount} ${pluralize(
|
|
7978
|
+
inboxCount,
|
|
7979
|
+
"inbox",
|
|
7980
|
+
"inboxes"
|
|
7981
|
+
)}. Re-run with --confirm to disable it anyway.`
|
|
7982
|
+
);
|
|
7983
|
+
}
|
|
7984
|
+
process.stdout.write(`Disabled email for org domain ${domainUuid}
|
|
7985
|
+
`);
|
|
7986
|
+
}
|
|
7987
|
+
},
|
|
7988
|
+
{
|
|
7989
|
+
path: ["org", "domains", "site", "enable"],
|
|
7990
|
+
description: "Enable custom site CNAME verification on a verified organization domain",
|
|
7991
|
+
mutates: true,
|
|
7992
|
+
requiresWorkspace: false,
|
|
7993
|
+
args: [ORG_UUID_ARG, DOMAIN_UUID_ARG],
|
|
7994
|
+
examples: [
|
|
7995
|
+
"yarn gr org domains site enable --org-uuid $ORG_UUID --domain-uuid $DOMAIN_UUID --allow-write"
|
|
7996
|
+
],
|
|
7997
|
+
handler: async (hctx) => {
|
|
7998
|
+
const result = await requireAuth(hctx.ctx).apiClient.enableOrgDomainSite(
|
|
7999
|
+
requireOrgId(hctx.args),
|
|
8000
|
+
requireDomainUuid(hctx.args)
|
|
8001
|
+
);
|
|
8002
|
+
outputSingle(result, hctx.ctx);
|
|
8003
|
+
}
|
|
8004
|
+
},
|
|
8005
|
+
{
|
|
8006
|
+
path: ["org", "domains", "site", "get"],
|
|
8007
|
+
description: "Get custom site CNAME setup and status for an organization domain",
|
|
8008
|
+
requiresWorkspace: false,
|
|
8009
|
+
args: [ORG_UUID_ARG, DOMAIN_UUID_ARG],
|
|
8010
|
+
examples: ["yarn gr org domains site get --org-uuid $ORG_UUID --domain-uuid $DOMAIN_UUID"],
|
|
8011
|
+
handler: async (hctx) => {
|
|
8012
|
+
const result = await requireAuth(hctx.ctx).apiClient.getOrgDomainSite(
|
|
8013
|
+
requireOrgId(hctx.args),
|
|
8014
|
+
requireDomainUuid(hctx.args)
|
|
8015
|
+
);
|
|
8016
|
+
outputSingle(result, hctx.ctx);
|
|
8017
|
+
}
|
|
8018
|
+
},
|
|
8019
|
+
siteVerifyCommand(
|
|
8020
|
+
["org", "domains", "site", "verify"],
|
|
8021
|
+
"Verify the site CNAME points at Gravity Rail"
|
|
8022
|
+
),
|
|
8023
|
+
siteVerifyCommand(
|
|
8024
|
+
["org", "domains", "site", "verify-cname"],
|
|
8025
|
+
"Verify the site CNAME points at Gravity Rail"
|
|
8026
|
+
),
|
|
8027
|
+
{
|
|
8028
|
+
path: ["org", "domains", "site", "disable"],
|
|
8029
|
+
description: "Disable custom site routing on an organization domain",
|
|
8030
|
+
mutates: true,
|
|
8031
|
+
requiresWorkspace: false,
|
|
8032
|
+
args: [
|
|
8033
|
+
ORG_UUID_ARG,
|
|
8034
|
+
DOMAIN_UUID_ARG,
|
|
8035
|
+
{
|
|
8036
|
+
name: "confirm",
|
|
8037
|
+
description: "Confirm removal of site mappings that depend on this domain",
|
|
8038
|
+
isFlag: true
|
|
8039
|
+
}
|
|
8040
|
+
],
|
|
8041
|
+
examples: [
|
|
8042
|
+
"yarn gr org domains site disable --org-uuid $ORG_UUID --domain-uuid $DOMAIN_UUID --confirm --allow-write"
|
|
8043
|
+
],
|
|
8044
|
+
handler: async (hctx) => {
|
|
8045
|
+
const domainUuid = requireDomainUuid(hctx.args);
|
|
8046
|
+
const result = await requireAuth(hctx.ctx).apiClient.disableOrgDomainSite(
|
|
8047
|
+
requireOrgId(hctx.args),
|
|
8048
|
+
domainUuid,
|
|
8049
|
+
hctx.args.confirm === true
|
|
8050
|
+
);
|
|
8051
|
+
if (!result.ok) {
|
|
8052
|
+
const { siteCount } = result.impact;
|
|
8053
|
+
throw new CLIError(
|
|
8054
|
+
`Site routing is still used by ${siteCount} ${pluralize(
|
|
8055
|
+
siteCount,
|
|
8056
|
+
"site"
|
|
8057
|
+
)}. Re-run with --confirm to disable it anyway.`
|
|
8058
|
+
);
|
|
8059
|
+
}
|
|
8060
|
+
process.stdout.write(`Disabled site routing for org domain ${domainUuid}
|
|
8061
|
+
`);
|
|
8062
|
+
}
|
|
8063
|
+
}
|
|
6227
8064
|
];
|
|
6228
8065
|
var orgDomain = {
|
|
6229
8066
|
name: "org",
|
|
6230
|
-
description: "Organization membership",
|
|
8067
|
+
description: "Organization membership and domains",
|
|
6231
8068
|
commands: [
|
|
6232
8069
|
{
|
|
6233
8070
|
path: ["org", "list"],
|
|
@@ -6237,7 +8074,8 @@ var orgDomain = {
|
|
|
6237
8074
|
const result = await requireAuth(ctx).apiClient.getMyOrganizations();
|
|
6238
8075
|
outputData(result, ctx, ORG_COLUMNS);
|
|
6239
8076
|
}
|
|
6240
|
-
}
|
|
8077
|
+
},
|
|
8078
|
+
...domainCommands
|
|
6241
8079
|
]
|
|
6242
8080
|
};
|
|
6243
8081
|
|