@gravity-rail/cli 0.40.0 → 0.42.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.js CHANGED
@@ -7510,6 +7510,23 @@ async function readBindings(hctx) {
7510
7510
  }
7511
7511
  return payload;
7512
7512
  }
7513
+ var CREATE_INBOX_ARG = {
7514
+ name: "create-inbox",
7515
+ description: "Comma-separated Inbox slot keys to fill by creating an Inbox (one per installation, named for the Bundle; needs inboxes:write)"
7516
+ };
7517
+ async function readSlotTargets(hctx) {
7518
+ const bindings = await readBindings(hctx);
7519
+ const keys = (optionalString(hctx.args, "create-inbox") ?? "").split(",").map((key) => key.trim()).filter(Boolean);
7520
+ if (keys.length === 0) return bindings;
7521
+ const merged = { ...bindings };
7522
+ for (const key of keys) {
7523
+ if (merged[key]) {
7524
+ throw new CLIError(`--create-inbox "${key}" is also set in --bindings; choose one`);
7525
+ }
7526
+ merged[key] = { kind: "new_inbox" };
7527
+ }
7528
+ return merged;
7529
+ }
7513
7530
  async function guardConflict(run, hint2) {
7514
7531
  try {
7515
7532
  return await run();
@@ -7583,18 +7600,20 @@ var installationCommands = [
7583
7600
  {
7584
7601
  name: "bindings",
7585
7602
  description: "Path to a JSON object mapping slot keys to targets"
7586
- }
7603
+ },
7604
+ CREATE_INBOX_ARG
7587
7605
  ],
7588
7606
  examples: [
7589
7607
  "gr bundles install -w $WID --bundle <bundle-uuid> --allow-write",
7590
- "gr bundles install -w $WID --bundle <bundle-uuid> --bindings bindings.json --allow-write"
7608
+ "gr bundles install -w $WID --bundle <bundle-uuid> --bindings bindings.json --allow-write",
7609
+ "gr bundles install -w $WID --bundle <bundle-uuid> --create-inbox program.inbox --allow-write"
7591
7610
  ],
7592
7611
  handler: async (hctx) => {
7593
7612
  const bundle = requireBundleUuid(hctx);
7594
7613
  const summary = await getBundleSummary(hctx, bundle);
7595
7614
  const version = summary.publishedVersion;
7596
7615
  if (version == null) throw new CLIError("Publish the Bundle before installing it");
7597
- const bindings = await readBindings(hctx);
7616
+ const bindings = await readSlotTargets(hctx);
7598
7617
  const result2 = await guardConflict(
7599
7618
  () => client(hctx).installBundle(hctx.workspace, bundle, {
7600
7619
  version,
@@ -7709,6 +7728,7 @@ var installationCommands = [
7709
7728
  name: "bindings",
7710
7729
  description: "Path to a JSON object mapping new slot keys to targets"
7711
7730
  },
7731
+ CREATE_INBOX_ARG,
7712
7732
  { name: "preview", description: "Show what would change and write nothing", isFlag: true }
7713
7733
  ],
7714
7734
  examples: [
@@ -7725,7 +7745,7 @@ var installationCommands = [
7725
7745
  );
7726
7746
  return;
7727
7747
  }
7728
- const bindings = await readBindings(hctx);
7748
+ const bindings = await readSlotTargets(hctx);
7729
7749
  const result2 = await guardConflict(
7730
7750
  () => client(hctx).upgradeInstallation(hctx.workspace, uuid, {
7731
7751
  toVersion: to,
@@ -7767,17 +7787,17 @@ var installationCommands = [
7767
7787
  INSTALLATION_ARG,
7768
7788
  {
7769
7789
  name: "bindings",
7770
- description: "Path to a JSON object mapping slot keys to targets",
7771
- required: true
7772
- }
7790
+ description: "Path to a JSON object mapping slot keys to targets"
7791
+ },
7792
+ CREATE_INBOX_ARG
7773
7793
  ],
7774
7794
  examples: [
7775
7795
  "gr bundles bind -w $WID --installation <installation-uuid> --bindings bindings.json --allow-write"
7776
7796
  ],
7777
7797
  handler: async (hctx) => {
7778
- const bindings = await readBindings(hctx);
7798
+ const bindings = await readSlotTargets(hctx);
7779
7799
  if (!bindings || Object.keys(bindings).length === 0) {
7780
- throw new CLIError("--bindings must name at least one slot");
7800
+ throw new CLIError("--bindings or --create-inbox must name at least one slot");
7781
7801
  }
7782
7802
  const result2 = await guardConflict(
7783
7803
  () => client(hctx).bindInstallationSlots(hctx.workspace, installationUuid(hctx), {
@@ -7862,6 +7882,18 @@ function parseDraftItems(payload) {
7862
7882
  });
7863
7883
  return items;
7864
7884
  }
7885
+ function parseDraftLinks(payload) {
7886
+ const links = payload.links;
7887
+ if (links === void 0) return void 0;
7888
+ if (!Array.isArray(links)) throw new CLIError('"links" must be an array');
7889
+ links.forEach((link, index) => {
7890
+ const record2 = link;
7891
+ if (typeof record2 !== "object" || record2 === null || typeof record2.label !== "string" || typeof record2.url !== "string") {
7892
+ throw new CLIError(`links[${index}] needs string "label" and "url"`);
7893
+ }
7894
+ });
7895
+ return links;
7896
+ }
7865
7897
  async function currentGeneration(hctx, uuid) {
7866
7898
  const expected2 = optionalNumber(hctx.args, "expected-generation");
7867
7899
  if (expected2 !== void 0) {
@@ -7937,6 +7969,14 @@ Draft generation: ${version.draftGeneration}
7937
7969
  hctx.ctx,
7938
7970
  ITEM_COLUMNS
7939
7971
  );
7972
+ if (version.links?.length) {
7973
+ process.stdout.write(
7974
+ `
7975
+ Links:
7976
+ ${version.links.map((link) => ` ${link.label}: ${link.url}`).join("\n")}
7977
+ `
7978
+ );
7979
+ }
7940
7980
  if (version.releaseNotes) {
7941
7981
  process.stdout.write(`
7942
7982
  Release notes:
@@ -8106,7 +8146,7 @@ var bundlesDomain = {
8106
8146
  },
8107
8147
  {
8108
8148
  path: ["bundles", "draft", "set"],
8109
- description: 'Replace draft items from {"items": [...]}; use --expected-generation from draft get to protect edits.',
8149
+ description: 'Replace draft items from {"items": [...]}; an optional "links": [{"label", "url"}] replaces the draft links. Use --expected-generation from draft get to protect edits.',
8110
8150
  requiresWorkspace: true,
8111
8151
  mutates: true,
8112
8152
  args: [BUNDLE_ARG, GENERATION_ARG],
@@ -8115,11 +8155,13 @@ var bundlesDomain = {
8115
8155
  ],
8116
8156
  handler: async (hctx) => {
8117
8157
  const items = parseDraftItems(hctx.data);
8158
+ const links = parseDraftLinks(hctx.data);
8118
8159
  const uuid = bundleUuid(hctx);
8119
8160
  const expectedGeneration = await currentGeneration(hctx, uuid);
8120
8161
  const result2 = await client2(hctx).replaceBundleDraft(hctx.workspace, uuid, {
8121
8162
  expectedGeneration,
8122
- items
8163
+ items,
8164
+ ...links ? { links } : {}
8123
8165
  });
8124
8166
  writeVersionDetail(hctx, result2);
8125
8167
  }
@@ -8168,28 +8210,30 @@ var bundlesDomain = {
8168
8210
  },
8169
8211
  {
8170
8212
  path: ["bundles", "grant"],
8171
- description: "Share a published Bundle within its organization with full source visibility",
8213
+ description: "Share a published Bundle with its organization, or with everyone as a superuser",
8172
8214
  requiresWorkspace: true,
8173
8215
  mutates: true,
8174
8216
  args: [
8175
8217
  BUNDLE_ARG,
8176
8218
  ...sharingArgs.filter((arg) => arg.name !== "disclosure").map(
8177
- (arg) => arg.name === "to" ? { ...arg, description: "organization (publishing organization only)" } : arg.name === "uuid" ? { ...arg, description: "Publishing organization UUID", required: true } : arg
8219
+ (arg) => arg.name === "to" ? {
8220
+ ...arg,
8221
+ description: "organization (publishing organization only) | global (everyone; superuser only)"
8222
+ } : arg.name === "uuid" ? {
8223
+ ...arg,
8224
+ description: "Publishing organization UUID (omit with --to global)"
8225
+ } : arg
8178
8226
  )
8179
8227
  ],
8180
8228
  examples: [
8181
- "gr bundles grant -w $WID --allow-write --bundle <bundle-uuid> --to organization --uuid <org-uuid>"
8229
+ "gr bundles grant -w $WID --allow-write --bundle <bundle-uuid> --to organization --uuid <org-uuid>",
8230
+ "gr bundles grant -w $WID --allow-write --bundle <bundle-uuid> --to global"
8182
8231
  ],
8183
8232
  handler: async (hctx) => {
8184
- if (requireString(hctx.args, "to") === "global") {
8185
- throw new CLIError(
8186
- "Bundle sharing is organization-only; official solution approval uses the staff catalog command"
8187
- );
8188
- }
8189
8233
  const request = sharingRequest(hctx.args, "full");
8190
- if (request.granteeType !== "organization") {
8234
+ if (request.granteeType === "workspace") {
8191
8235
  throw new CLIError(
8192
- "Share Bundles with their organization, then install per workspace"
8236
+ "Share Bundles with their organization or with everyone, then install per workspace"
8193
8237
  );
8194
8238
  }
8195
8239
  const bundleRequest = {