@gravity-rail/cli 0.47.0 → 0.50.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/lib.d.ts CHANGED
@@ -709,7 +709,11 @@ declare function importDevProfiles(credentialsManager: CredentialsManager, env:
709
709
  declare function manageCommand(hctx: CommandHandlerContext): Promise<void>;
710
710
  declare function chatCommand(hctx: CommandHandlerContext): Promise<void>;
711
711
 
712
- declare function organizationsListCommand(ctx: AuthenticatedContext): Promise<void>;
712
+ declare function organizationsListCommand(ctx: AuthenticatedContext, options?: {
713
+ page?: number;
714
+ pageSize?: number;
715
+ search?: string;
716
+ }): Promise<void>;
713
717
 
714
718
  declare function whoamiCommand(ctx: AuthenticatedContext): Promise<void>;
715
719
 
package/dist/lib.js CHANGED
@@ -33,7 +33,7 @@ import {
33
33
  startAccountPhoneVerify,
34
34
  stderr,
35
35
  unwrapItems
36
- } from "./chunk-CQVOVKKR.js";
36
+ } from "./chunk-FQMZ2EBF.js";
37
37
  import {
38
38
  AGUIClient,
39
39
  formatTimestamp,
@@ -4307,7 +4307,9 @@ async function exportTemplateArchive(client3, templateUuid) {
4307
4307
  return withTransferProgress(
4308
4308
  "template archive",
4309
4309
  templateUuid,
4310
- () => client3.exportWorkspaceZip(templateUuid, void 0, void 0, REAPPLY_EXPORT_EXCLUDE)
4310
+ () => client3.exportWorkspaceZip(templateUuid, void 0, void 0, REAPPLY_EXPORT_EXCLUDE, {
4311
+ revisionMode: "active"
4312
+ })
4311
4313
  );
4312
4314
  }
4313
4315
  async function readBindingsFile(filePath, targets) {
@@ -4641,26 +4643,27 @@ var workspacesDomain = {
4641
4643
  }),
4642
4644
  {
4643
4645
  path: ["workspaces", "list"],
4644
- description: "List workspaces",
4646
+ description: "List a searchable page of workspaces",
4645
4647
  requiresWorkspace: false,
4646
4648
  columns: COLUMNS6,
4647
4649
  args: [
4650
+ { name: "page", description: "Page number" },
4651
+ { name: "page-size", description: "Page size (at most 100)" },
4652
+ { name: "search", description: "Search name, slug or UUID" },
4648
4653
  {
4649
4654
  name: "org",
4650
4655
  aliases: ["org-uuid"],
4651
- description: "Only workspaces in this organization (UUID). Filters the list client-side on organizationUuid."
4656
+ description: "Only workspaces in this organization (UUID)."
4652
4657
  }
4653
4658
  ],
4654
4659
  examples: ["gr workspaces list --org <org-uuid> -o json"],
4655
4660
  handler: async ({ ctx, args }) => {
4656
- const result2 = await requireAuth(ctx).apiClient.getWorkspaces();
4657
- const org = typeof args.org === "string" ? args.org.trim().toLowerCase() : "";
4658
- const items = org ? unwrapItems(result2).filter(
4659
- (ws) => String(
4660
- ws.organizationUuid ?? ""
4661
- ).toLowerCase() === org
4662
- ) : result2;
4663
- outputData(listResult(items, false), ctx, COLUMNS6);
4661
+ const result2 = await requireAuth(ctx).apiClient.getWorkspaces({
4662
+ ...parsePaginationArgs(args),
4663
+ search: typeof args.search === "string" ? args.search : void 0,
4664
+ organizationUuid: typeof args.org === "string" ? args.org.trim() : void 0
4665
+ });
4666
+ outputData(listResult(result2, false), ctx, COLUMNS6);
4664
4667
  }
4665
4668
  },
4666
4669
  // Custom get that accepts either --id or -w as the workspace identifier
@@ -4796,6 +4799,14 @@ Provisioning started. Watch it come up with:
4796
4799
  name: "workflow-id",
4797
4800
  description: "Export a single workflow by ID"
4798
4801
  },
4802
+ {
4803
+ name: "revision-id",
4804
+ description: "Export one revision ID. Requires --workflow-id; import updates an editable draft."
4805
+ },
4806
+ {
4807
+ name: "revision-mode",
4808
+ description: "active (default, current snapshot only) or all (history including drafts)"
4809
+ },
4799
4810
  {
4800
4811
  name: "exclude",
4801
4812
  description: 'Comma-separated categories to exclude (e.g. "channels")'
@@ -4819,6 +4830,15 @@ Provisioning started. Watch it come up with:
4819
4830
  handler: async ({ ctx, workspace, args }) => {
4820
4831
  const scope = args["scope"];
4821
4832
  const workflowIdStr = args["workflow-id"];
4833
+ const revisionIdStr = args["revision-id"];
4834
+ const revisionId = revisionIdStr === void 0 ? void 0 : Number(revisionIdStr);
4835
+ const revisionMode = args["revision-mode"] ?? (revisionId !== void 0 ? "all" : "active");
4836
+ if (revisionId !== void 0 && (!Number.isSafeInteger(revisionId) || revisionId <= 0)) {
4837
+ throw new CLIError("--revision-id must be a positive integer");
4838
+ }
4839
+ if (revisionMode !== "all" && revisionMode !== "active") {
4840
+ throw new CLIError('--revision-mode must be "all" or "active"');
4841
+ }
4822
4842
  const exclude = args["exclude"];
4823
4843
  const outputPath = args["output"];
4824
4844
  const formatArg = args["format"];
@@ -4829,6 +4849,12 @@ Provisioning started. Watch it come up with:
4829
4849
  if (scope && workflowId !== void 0) {
4830
4850
  throw new CLIError("Cannot specify both --scope and --workflow-id");
4831
4851
  }
4852
+ if (revisionId !== void 0 && (workflowId === void 0 || revisionMode !== "all")) {
4853
+ throw new CLIError(
4854
+ "--revision-id requires --workflow-id and cannot be combined with active mode"
4855
+ );
4856
+ }
4857
+ const revisionOptions = { revisionId, revisionMode };
4832
4858
  if (scope && scope !== "workflows") {
4833
4859
  throw new CLIError('--scope must be "workflows"');
4834
4860
  }
@@ -4845,7 +4871,8 @@ Provisioning started. Watch it come up with:
4845
4871
  workspace,
4846
4872
  workflowId,
4847
4873
  scope,
4848
- exclude
4874
+ exclude,
4875
+ revisionOptions
4849
4876
  );
4850
4877
  await writeFile(outputPath, Buffer.from(zip));
4851
4878
  process.stdout.write(`Saved ZIP export to ${outputPath}
@@ -4856,7 +4883,8 @@ Provisioning started. Watch it come up with:
4856
4883
  workspace,
4857
4884
  workflowId,
4858
4885
  scope,
4859
- exclude
4886
+ exclude,
4887
+ revisionOptions
4860
4888
  );
4861
4889
  if (outputPath) {
4862
4890
  await writeFile(outputPath, `${JSON.stringify(result2, null, 2)}
@@ -5984,11 +6012,19 @@ Each entry in "fields" (a schema field)
5984
6012
  required (bool) Whether the field must be supplied
5985
6013
  description (string) Optional help text
5986
6014
  options (array) For fieldType "enum": [{"label":"\u2026","value":"\u2026"}, \u2026]
5987
- referencedTypeId (number) For reference fields: target data type id
6015
+ referencedTypeId (number) For reference fields: target Form integer id
6016
+ referenceFieldId (number) Server-issued reference identity. Preserve on update;
6017
+ omit for a new reference field.
5988
6018
 
5989
6019
  Valid fieldType values
5990
6020
  text, longtext, email, phone, number, integer, boolean, date, datetime,
5991
- time_of_day, us_zip_code, enum, array, object, function
6021
+ time_of_day, us_zip_code, enum, array, object, function, reference
6022
+
6023
+ Record references
6024
+ {"slug":"customer","name":"Customer","fieldType":"reference","referencedTypeId":8}
6025
+ Record fieldValues use a positive existing integer record id, or null to clear.
6026
+ Reference fields require authenticated reads/writes. Portable transfer and CSV
6027
+ import/export for Forms with references are unsupported.
5992
6028
 
5993
6029
  Example
5994
6030
  gr data-types create -w $WID --allow-write --data '{"name":"Patient","fields":[
@@ -6291,8 +6327,15 @@ var ACTION_PARAM_HINTS = {
6291
6327
  },
6292
6328
  "assistant:message": {
6293
6329
  summary: "inject an assistant message into the chat",
6294
- shape: ['{"message":"Welcome! \u2026","suggestions":["Yes","No"],"waitForResponse":<bool>}'],
6295
- notes: ['message is required. The key is "message", not "messageTemplate".']
6330
+ shape: [
6331
+ '{"message":"Welcome! \u2026","suggestions":["Yes","No"],"waitForResponse":<bool>,"allowInterrupt":<bool>}'
6332
+ ],
6333
+ notes: [
6334
+ 'message is required. The key is "message", not "messageTemplate".',
6335
+ "allowInterrupt (default true) is barge-in; waitForResponse (default true) is turn",
6336
+ "ownership. They are independent \u2014 do not derive one from the other. allowInterrupt=false",
6337
+ "is honoured only on a native canned-speech voice provider (xAI force_message)."
6338
+ ]
6296
6339
  },
6297
6340
  "chat:pause": {
6298
6341
  summary: "pause the chat for a human response",
@@ -11811,7 +11854,7 @@ var NO_UUID_LOOKUP = /* @__PURE__ */ new Set([
11811
11854
  ]);
11812
11855
  var HYDRATORS = {
11813
11856
  workspace: async ({ client: client3 }, ref) => (await client3.getWorkspace(ref.uuid)).name,
11814
- org: async ({ orgNames }, ref) => (await orgNames()).get(ref.uuid),
11857
+ org: async ({ orgNames }, ref) => (await orgNames(ref.uuid)).get(ref.uuid),
11815
11858
  workflow: async ({ client: client3 }, ref) => {
11816
11859
  const detail = await client3.getWorkflow(requireWorkspace(ref), ref.uuid);
11817
11860
  return detail.workflow?.name;
@@ -11873,7 +11916,7 @@ var ActivityRefResolver = class {
11873
11916
  inFlight = /* @__PURE__ */ new Map();
11874
11917
  fetches = 0;
11875
11918
  /** The org membership listing, fetched at most once per invocation. */
11876
- orgNamesPromise;
11919
+ orgNamesPromises = /* @__PURE__ */ new Map();
11877
11920
  /** How many API calls hydration actually made. `--ids` must keep this at 0. */
11878
11921
  get fetchCount() {
11879
11922
  return this.fetches;
@@ -12055,21 +12098,24 @@ var ActivityRefResolver = class {
12055
12098
  return resolution.label;
12056
12099
  }
12057
12100
  /**
12058
- * The caller's org memberships as uuid → name, fetched once.
12101
+ * The caller's matching organization membership, fetched once per UUID.
12059
12102
  *
12060
12103
  * The promise is cached, not its value, so N org refs resolving at once
12061
12104
  * share one request — the same rule the ref cache follows.
12062
12105
  */
12063
- orgNames() {
12064
- this.orgNamesPromise ??= this.client.getMyOrganizations().then(
12106
+ orgNames(uuid) {
12107
+ const cached = this.orgNamesPromises.get(uuid);
12108
+ if (cached) return cached;
12109
+ const pending = this.client.getMyOrganizations({ search: uuid, pageSize: 1 }).then(
12065
12110
  (memberships) => new Map(
12066
- memberships.map((membership) => [
12111
+ memberships.items.map((membership) => [
12067
12112
  membership.organizationUuid,
12068
12113
  membership.organizationName
12069
12114
  ])
12070
12115
  )
12071
12116
  );
12072
- return this.orgNamesPromise;
12117
+ this.orgNamesPromises.set(uuid, pending);
12118
+ return pending;
12073
12119
  }
12074
12120
  async lookup(ref) {
12075
12121
  const hydrator = HYDRATORS[ref.kind];
@@ -12082,7 +12128,10 @@ var ActivityRefResolver = class {
12082
12128
  }
12083
12129
  this.fetches += 1;
12084
12130
  try {
12085
- const name = await hydrator({ client: this.client, orgNames: () => this.orgNames() }, ref);
12131
+ const name = await hydrator(
12132
+ { client: this.client, orgNames: (uuid) => this.orgNames(uuid) },
12133
+ ref
12134
+ );
12086
12135
  if (!name) return { label: bareLabel(ref), status: "unresolved" };
12087
12136
  return { label: name, status: "resolved" };
12088
12137
  } catch (error) {
@@ -14816,8 +14865,21 @@ var orgDomain = {
14816
14865
  path: ["org", "list"],
14817
14866
  description: "List my organizations",
14818
14867
  requiresWorkspace: false,
14819
- handler: async ({ ctx }) => {
14820
- const result2 = await requireAuth(ctx).apiClient.getMyOrganizations();
14868
+ args: [
14869
+ { name: "page", description: "Page number", default: "1" },
14870
+ {
14871
+ name: "page-size",
14872
+ description: "Entries per page (maximum 100)",
14873
+ default: "25"
14874
+ },
14875
+ { name: "search", description: "Search organization name or slug" }
14876
+ ],
14877
+ handler: async ({ ctx, args }) => {
14878
+ const result2 = await requireAuth(ctx).apiClient.getMyOrganizations({
14879
+ page: Number(args.page ?? 1),
14880
+ pageSize: Number(args["page-size"] ?? 25),
14881
+ search: args.search
14882
+ });
14821
14883
  outputData(result2, ctx, ORG_COLUMNS);
14822
14884
  }
14823
14885
  },
@@ -25762,7 +25824,15 @@ import { execSync as execSync2 } from "child_process";
25762
25824
  import { join } from "path";
25763
25825
  async function devImportLocalCommand(ctx, workspace) {
25764
25826
  stderr(`Exporting workspace ${workspace}...`);
25765
- const exportData = await ctx.apiClient.exportWorkspace(workspace);
25827
+ const exportData = await ctx.apiClient.exportWorkspace(
25828
+ workspace,
25829
+ void 0,
25830
+ void 0,
25831
+ void 0,
25832
+ {
25833
+ revisionMode: "active"
25834
+ }
25835
+ );
25766
25836
  stderr("Export successful!");
25767
25837
  stderr(` Workflows: ${(exportData.workflows || []).length}`);
25768
25838
  stderr(` Tasks: ${(exportData.tasks || []).length}`);
@@ -26122,8 +26192,8 @@ var COLUMNS36 = [
26122
26192
  { header: "UUID", getValue: (o) => o.organizationUuid },
26123
26193
  { header: "ROLE", getValue: (o) => o.role || "" }
26124
26194
  ];
26125
- async function organizationsListCommand(ctx) {
26126
- const organizations = await ctx.apiClient.getMyOrganizations();
26195
+ async function organizationsListCommand(ctx, options = {}) {
26196
+ const organizations = await ctx.apiClient.getMyOrganizations(options);
26127
26197
  outputData(organizations, ctx, COLUMNS36);
26128
26198
  }
26129
26199
 
@@ -26359,7 +26429,7 @@ var topLevelCommands = [
26359
26429
  mutates: true,
26360
26430
  args: [{ name: "phone", description: "E.164 phone number (optional; prompts if omitted)" }],
26361
26431
  handler: async (hctx) => {
26362
- const { accountVerifyPhoneCommand } = await import("./account-verify-phone-KEYD64YM.js");
26432
+ const { accountVerifyPhoneCommand } = await import("./account-verify-phone-ABHHHGCC.js");
26363
26433
  await accountVerifyPhoneCommand(hctx);
26364
26434
  }
26365
26435
  },
@@ -26428,16 +26498,34 @@ var topLevelCommands = [
26428
26498
  },
26429
26499
  {
26430
26500
  path: ["organizations", "list"],
26431
- description: "List organizations",
26432
- handler: async ({ ctx }) => {
26433
- await organizationsListCommand(requireAuth(ctx));
26501
+ description: "List a searchable page of organizations",
26502
+ args: [
26503
+ { name: "page", description: "Page number", default: "1" },
26504
+ { name: "page-size", description: "Entries per page (maximum 100)", default: "25" },
26505
+ { name: "search", description: "Search organization name or slug" }
26506
+ ],
26507
+ handler: async ({ ctx, args }) => {
26508
+ await organizationsListCommand(requireAuth(ctx), {
26509
+ page: Number(args.page ?? 1),
26510
+ pageSize: Number(args["page-size"] ?? 25),
26511
+ search: args.search
26512
+ });
26434
26513
  }
26435
26514
  },
26436
26515
  {
26437
26516
  path: ["orgs", "list"],
26438
- description: "List organizations",
26439
- handler: async ({ ctx }) => {
26440
- await organizationsListCommand(requireAuth(ctx));
26517
+ description: "List a searchable page of organizations",
26518
+ args: [
26519
+ { name: "page", description: "Page number", default: "1" },
26520
+ { name: "page-size", description: "Entries per page (maximum 100)", default: "25" },
26521
+ { name: "search", description: "Search organization name or slug" }
26522
+ ],
26523
+ handler: async ({ ctx, args }) => {
26524
+ await organizationsListCommand(requireAuth(ctx), {
26525
+ page: Number(args.page ?? 1),
26526
+ pageSize: Number(args["page-size"] ?? 25),
26527
+ search: args.search
26528
+ });
26441
26529
  }
26442
26530
  }
26443
26531
  ];