zinkee 0.1.23 → 0.1.24

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/index.js CHANGED
@@ -436,6 +436,62 @@ var commandRegistry = {
436
436
  supportsRaw: false,
437
437
  output: writeOutput
438
438
  },
439
+ "document-templates list": {
440
+ command: "document-templates list",
441
+ accessLevel: "read",
442
+ supportsExample: true,
443
+ supportsRaw: false,
444
+ output: readOutput
445
+ },
446
+ "document-templates get": {
447
+ command: "document-templates get",
448
+ accessLevel: "read",
449
+ supportsExample: true,
450
+ supportsRaw: false,
451
+ output: readOutput
452
+ },
453
+ "document-templates create": {
454
+ command: "document-templates create",
455
+ accessLevel: "write",
456
+ supportsExample: true,
457
+ supportsRaw: true,
458
+ output: writeOutput
459
+ },
460
+ "document-templates update": {
461
+ command: "document-templates update",
462
+ accessLevel: "write",
463
+ supportsExample: true,
464
+ supportsRaw: false,
465
+ output: writeOutput
466
+ },
467
+ "document-templates delete": {
468
+ command: "document-templates delete",
469
+ accessLevel: "destructive",
470
+ supportsExample: true,
471
+ supportsRaw: false,
472
+ output: writeOutput
473
+ },
474
+ "document-templates assets add": {
475
+ command: "document-templates assets add",
476
+ accessLevel: "write",
477
+ supportsExample: true,
478
+ supportsRaw: false,
479
+ output: writeOutput
480
+ },
481
+ "document-templates assets delete": {
482
+ command: "document-templates assets delete",
483
+ accessLevel: "destructive",
484
+ supportsExample: true,
485
+ supportsRaw: false,
486
+ output: writeOutput
487
+ },
488
+ "document-templates assets download": {
489
+ command: "document-templates assets download",
490
+ accessLevel: "read",
491
+ supportsExample: true,
492
+ supportsRaw: false,
493
+ output: "binary"
494
+ },
439
495
  "files upload": {
440
496
  command: "files upload",
441
497
  accessLevel: "write",
@@ -5721,6 +5777,171 @@ var specificExamples = {
5721
5777
  "isRoot": false
5722
5778
  }`
5723
5779
  }
5780
+ ]),
5781
+ "document-templates list": buildCommandExamples([
5782
+ {
5783
+ description: "List every document template in the workspace. Each asset's link is a relative path to the asset download endpoint, ready to call without composition.",
5784
+ command: "zinkee --json document-templates list",
5785
+ response: `[
5786
+ {
5787
+ "id": "7c4a8d3f-1b2e-4a5c-9d6e-1f2a3b4c5d6e",
5788
+ "name": "Quarterly report",
5789
+ "assets": [
5790
+ {
5791
+ "id": "9e8d7c6b-5a4f-3e2d-1c0b-9a8b7c6d5e4f",
5792
+ "name": "Requirements.docx",
5793
+ "link": "/api/v2/document-templates/7c4a8d3f-1b2e-4a5c-9d6e-1f2a3b4c5d6e/assets/9e8d7c6b-5a4f-3e2d-1c0b-9a8b7c6d5e4f/download"
5794
+ }
5795
+ ],
5796
+ "createdAt": "2026-01-15T10:00:00Z",
5797
+ "updatedAt": "2026-01-20T14:30:00Z",
5798
+ "createdBy": "creator@example.com",
5799
+ "updatedBy": "updater@example.com"
5800
+ }
5801
+ ]`
5802
+ }
5803
+ ]),
5804
+ "document-templates get": buildCommandExamples([
5805
+ {
5806
+ description: "Look up one template by UUID. The CLI filters the list endpoint locally (the backend does not expose a get-one route).",
5807
+ command: "zinkee --json document-templates get 7c4a8d3f-1b2e-4a5c-9d6e-1f2a3b4c5d6e",
5808
+ response: `{
5809
+ "id": "7c4a8d3f-1b2e-4a5c-9d6e-1f2a3b4c5d6e",
5810
+ "name": "Quarterly report",
5811
+ "assets": [
5812
+ {
5813
+ "id": "9e8d7c6b-5a4f-3e2d-1c0b-9a8b7c6d5e4f",
5814
+ "name": "Requirements.docx",
5815
+ "link": "/api/v2/document-templates/7c4a8d3f-1b2e-4a5c-9d6e-1f2a3b4c5d6e/assets/9e8d7c6b-5a4f-3e2d-1c0b-9a8b7c6d5e4f/download"
5816
+ }
5817
+ ],
5818
+ "createdAt": "2026-01-15T10:00:00Z",
5819
+ "updatedAt": "2026-01-20T14:30:00Z",
5820
+ "createdBy": "creator@example.com",
5821
+ "updatedBy": "creator@example.com"
5822
+ }`
5823
+ },
5824
+ {
5825
+ description: "Look up by exact template name. Names are unique within the workspace; ambiguity is reported as an error.",
5826
+ command: 'zinkee --json document-templates get "Quarterly report"'
5827
+ }
5828
+ ]),
5829
+ "document-templates create": buildCommandExamples([
5830
+ {
5831
+ description: "Typical create: empty template by name. Assets are uploaded afterwards via document-templates assets add.",
5832
+ command: 'zinkee --json document-templates create --name "Quarterly report"',
5833
+ raw: `{
5834
+ "name": "Quarterly report",
5835
+ "assets": []
5836
+ }`,
5837
+ response: `{
5838
+ "id": "7c4a8d3f-1b2e-4a5c-9d6e-1f2a3b4c5d6e",
5839
+ "name": "Quarterly report",
5840
+ "assets": [],
5841
+ "createdAt": "2026-01-15T10:00:00Z",
5842
+ "updatedAt": "2026-01-15T10:00:00Z",
5843
+ "createdBy": "creator@example.com",
5844
+ "updatedBy": "creator@example.com"
5845
+ }`
5846
+ },
5847
+ {
5848
+ description: "Create with pre-existing asset records via --raw. Used for import/migration flows where the assets already exist elsewhere; the typical UX is to create empty and upload via assets add.",
5849
+ command: `zinkee --json document-templates create --raw '{"name":"Annual report","assets":[{"id":"9e8d7c6b-5a4f-3e2d-1c0b-9a8b7c6d5e4f","name":"Cover.docx","link":"/existing/cover.docx"},{"id":"3f2e1d0c-9b8a-7654-3210-fedcba987654","name":"Appendix.docx","link":"/existing/appendix.docx"}]}'`,
5850
+ raw: `{
5851
+ "name": "Annual report",
5852
+ "assets": [
5853
+ {
5854
+ "id": "9e8d7c6b-5a4f-3e2d-1c0b-9a8b7c6d5e4f",
5855
+ "name": "Cover.docx",
5856
+ "link": "/existing/cover.docx"
5857
+ },
5858
+ {
5859
+ "id": "3f2e1d0c-9b8a-7654-3210-fedcba987654",
5860
+ "name": "Appendix.docx",
5861
+ "link": "/existing/appendix.docx"
5862
+ }
5863
+ ]
5864
+ }`
5865
+ }
5866
+ ]),
5867
+ "document-templates update": buildCommandExamples([
5868
+ {
5869
+ description: "Rename a template. The template argument accepts a UUID or an exact current name. Only the name is updatable through this endpoint; assets are managed via the assets subcommands.",
5870
+ command: 'zinkee --json document-templates update "Quarterly report" --name "Annual report"',
5871
+ raw: `{
5872
+ "name": "Annual report"
5873
+ }`,
5874
+ response: `{
5875
+ "id": "7c4a8d3f-1b2e-4a5c-9d6e-1f2a3b4c5d6e",
5876
+ "name": "Annual report",
5877
+ "assets": [
5878
+ {
5879
+ "id": "9e8d7c6b-5a4f-3e2d-1c0b-9a8b7c6d5e4f",
5880
+ "name": "Requirements.docx",
5881
+ "link": "/api/v2/document-templates/7c4a8d3f-1b2e-4a5c-9d6e-1f2a3b4c5d6e/assets/9e8d7c6b-5a4f-3e2d-1c0b-9a8b7c6d5e4f/download"
5882
+ }
5883
+ ],
5884
+ "createdAt": "2026-01-15T10:00:00Z",
5885
+ "updatedAt": "2026-01-22T09:15:00Z",
5886
+ "createdBy": "creator@example.com",
5887
+ "updatedBy": "updater@example.com"
5888
+ }`
5889
+ }
5890
+ ]),
5891
+ "document-templates delete": buildCommandExamples([
5892
+ {
5893
+ description: "Delete a template and remove its asset files from storage. Record fields that reference previously generated documents are not modified.",
5894
+ command: "zinkee --json document-templates delete 7c4a8d3f-1b2e-4a5c-9d6e-1f2a3b4c5d6e",
5895
+ response: `{
5896
+ "id": "7c4a8d3f-1b2e-4a5c-9d6e-1f2a3b4c5d6e",
5897
+ "deleted": true
5898
+ }`
5899
+ }
5900
+ ]),
5901
+ "document-templates assets add": buildCommandExamples([
5902
+ {
5903
+ description: 'Upload a local file as an asset of a template. The CLI sends a multipart form with a part named "file"; the asset display name defaults to the uploaded filename.',
5904
+ command: 'zinkee --json document-templates assets add "Quarterly report" ./contract.docx',
5905
+ response: `{
5906
+ "id": "7c4a8d3f-1b2e-4a5c-9d6e-1f2a3b4c5d6e",
5907
+ "name": "Quarterly report",
5908
+ "assets": [
5909
+ {
5910
+ "id": "9e8d7c6b-5a4f-3e2d-1c0b-9a8b7c6d5e4f",
5911
+ "name": "contract.docx",
5912
+ "link": "/api/v2/document-templates/7c4a8d3f-1b2e-4a5c-9d6e-1f2a3b4c5d6e/assets/9e8d7c6b-5a4f-3e2d-1c0b-9a8b7c6d5e4f/download"
5913
+ }
5914
+ ],
5915
+ "createdAt": "2026-01-15T10:00:00Z",
5916
+ "updatedAt": "2026-01-22T09:15:00Z",
5917
+ "createdBy": "creator@example.com",
5918
+ "updatedBy": "updater@example.com"
5919
+ }`
5920
+ },
5921
+ {
5922
+ description: "Override the asset display name with --name (otherwise the uploaded filename is used).",
5923
+ command: 'zinkee --json document-templates assets add "Quarterly report" ./contract.docx --name "Customer Contract"'
5924
+ }
5925
+ ]),
5926
+ "document-templates assets delete": buildCommandExamples([
5927
+ {
5928
+ description: "Delete one asset from a template and remove its file from storage.",
5929
+ command: "zinkee --json document-templates assets delete 7c4a8d3f-1b2e-4a5c-9d6e-1f2a3b4c5d6e 9e8d7c6b-5a4f-3e2d-1c0b-9a8b7c6d5e4f",
5930
+ response: `{
5931
+ "id": "9e8d7c6b-5a4f-3e2d-1c0b-9a8b7c6d5e4f",
5932
+ "deleted": true
5933
+ }`
5934
+ }
5935
+ ]),
5936
+ "document-templates assets download": buildCommandExamples([
5937
+ {
5938
+ description: "Download asset bytes to disk. The CLI streams the raw bytes to --output; in --json mode --output is required and the JSON envelope only carries metadata.",
5939
+ command: "zinkee --json document-templates assets download 7c4a8d3f-1b2e-4a5c-9d6e-1f2a3b4c5d6e 9e8d7c6b-5a4f-3e2d-1c0b-9a8b7c6d5e4f --output ./contract.docx"
5940
+ },
5941
+ {
5942
+ description: "Stream asset bytes to stdout (omit --json and --output). Useful for piping into other tools.",
5943
+ command: "zinkee document-templates assets download 7c4a8d3f-1b2e-4a5c-9d6e-1f2a3b4c5d6e 9e8d7c6b-5a4f-3e2d-1c0b-9a8b7c6d5e4f > contract.docx"
5944
+ }
5724
5945
  ])
5725
5946
  };
5726
5947
  function fallbackExamples(commandName) {
@@ -5840,7 +6061,7 @@ ${index + 1}. ${example.description}
5840
6061
 
5841
6062
  // src/program.ts
5842
6063
  import { createRequire } from "module";
5843
- import { Command as Command10 } from "commander";
6064
+ import { Command as Command11 } from "commander";
5844
6065
 
5845
6066
  // src/config.ts
5846
6067
  import { mkdirSync, readFileSync, writeFileSync } from "fs";
@@ -6601,11 +6822,11 @@ function hasSetPath(target, path) {
6601
6822
  return Object.hasOwn(target, path);
6602
6823
  }
6603
6824
  let current = target;
6604
- for (const segment3 of segments) {
6605
- if (!isJsonObject2(current) || !Object.hasOwn(current, segment3)) {
6825
+ for (const segment4 of segments) {
6826
+ if (!isJsonObject2(current) || !Object.hasOwn(current, segment4)) {
6606
6827
  return false;
6607
6828
  }
6608
- current = current[segment3];
6829
+ current = current[segment4];
6609
6830
  }
6610
6831
  return true;
6611
6832
  }
@@ -8749,40 +8970,72 @@ function registerDisplaysCommands(program, options = {}) {
8749
8970
  });
8750
8971
  }
8751
8972
 
8752
- // src/commands/files.ts
8973
+ // src/commands/document-templates.ts
8753
8974
  import { readFileSync as readFileSync5, writeFileSync as writeFileSync2 } from "fs";
8754
8975
  import { basename } from "path";
8755
8976
  import { InvalidArgumentError as InvalidArgumentError4 } from "commander";
8756
8977
 
8757
- // src/api/files.ts
8978
+ // src/api/document-templates.ts
8979
+ function jsonOptions4(body, method) {
8980
+ return {
8981
+ method,
8982
+ headers: {
8983
+ "content-type": "application/json"
8984
+ },
8985
+ body: JSON.stringify(body)
8986
+ };
8987
+ }
8758
8988
  function selectorValue4(selector) {
8759
- return selector.value;
8989
+ return encodeURIComponent(selector.value);
8760
8990
  }
8761
- var FilesApi = class {
8991
+ function segment3(value) {
8992
+ return encodeURIComponent(value);
8993
+ }
8994
+ var DocumentTemplatesApi = class {
8762
8995
  constructor(client) {
8763
8996
  this.client = client;
8764
8997
  }
8765
- uploadFile(input) {
8766
- return this.client.requestJson("/api/v2/files", {
8767
- method: "POST",
8768
- body: input
8769
- });
8998
+ listTemplates() {
8999
+ return this.client.getJson("/api/v2/document-templates");
8770
9000
  }
8771
- downloadFile(file) {
8772
- return this.client.requestBinary(`/api/v2/files/${selectorValue4(file)}`);
9001
+ createTemplate(input) {
9002
+ return this.client.requestJson(
9003
+ "/api/v2/document-templates",
9004
+ jsonOptions4(input, "POST")
9005
+ );
8773
9006
  }
8774
- deleteFile(file) {
9007
+ updateTemplate(template, input) {
9008
+ return this.client.requestJson(
9009
+ `/api/v2/document-templates/${selectorValue4(template)}`,
9010
+ jsonOptions4(input, "PATCH")
9011
+ );
9012
+ }
9013
+ deleteTemplate(template) {
8775
9014
  return this.client.requestJson(
8776
- `/api/v2/files/${selectorValue4(file)}`,
9015
+ `/api/v2/document-templates/${selectorValue4(template)}`,
8777
9016
  { method: "DELETE" }
8778
9017
  );
8779
9018
  }
8780
- getStorageInfo() {
8781
- return this.client.getJson("/api/v2/files/storage-info");
9019
+ addAsset(template, input) {
9020
+ return this.client.requestJson(
9021
+ `/api/v2/document-templates/${selectorValue4(template)}/assets`,
9022
+ { method: "POST", body: input }
9023
+ );
9024
+ }
9025
+ deleteAsset(template, assetId) {
9026
+ return this.client.requestJson(
9027
+ `/api/v2/document-templates/${selectorValue4(template)}/assets/${segment3(assetId)}`,
9028
+ { method: "DELETE" }
9029
+ );
9030
+ }
9031
+ downloadAsset(template, assetId) {
9032
+ return this.client.requestBinary(
9033
+ `/api/v2/document-templates/${selectorValue4(template)}/assets/${segment3(assetId)}/download`
9034
+ );
8782
9035
  }
8783
9036
  };
8784
9037
 
8785
- // src/commands/files.ts
9038
+ // src/commands/document-templates.ts
8786
9039
  function getCommandIo5(stdout) {
8787
9040
  return stdout ?? process.stdout;
8788
9041
  }
@@ -8814,7 +9067,7 @@ function toConfigurationError5(filePath, error) {
8814
9067
  }
8815
9068
  throw error;
8816
9069
  }
8817
- function createFilesApi(command, filePath) {
9070
+ function createDocumentTemplatesApi(command, filePath) {
8818
9071
  try {
8819
9072
  const config = readRuntimeConfig(filePath);
8820
9073
  const runtime = resolveRuntimeContext(config, getGlobalOptions5(command));
@@ -8825,7 +9078,7 @@ function createFilesApi(command, filePath) {
8825
9078
  );
8826
9079
  }
8827
9080
  return {
8828
- api: new FilesApi(
9081
+ api: new DocumentTemplatesApi(
8829
9082
  new ApiClient({
8830
9083
  baseUrl: runtime.baseUrl,
8831
9084
  apiKey: runtime.apiKey
@@ -8858,9 +9111,57 @@ function parseUuidOrSlugSelector4(input) {
8858
9111
  throw new InvalidArgumentError4(message);
8859
9112
  }
8860
9113
  }
8861
- function isRecord3(value) {
9114
+ function isJsonObject4(value) {
8862
9115
  return typeof value === "object" && value !== null && !Array.isArray(value);
8863
9116
  }
9117
+ function isEmptyObject4(value) {
9118
+ return Object.keys(value).length === 0;
9119
+ }
9120
+ function parseJsonValue2(input, sourceLabel) {
9121
+ try {
9122
+ return JSON.parse(input);
9123
+ } catch (error) {
9124
+ const message = error instanceof Error ? error.message : "Invalid JSON.";
9125
+ throw new CliError(
9126
+ "invalid_cli_usage",
9127
+ `Failed to parse JSON from ${sourceLabel}: ${message}`
9128
+ );
9129
+ }
9130
+ }
9131
+ function readTextFile2(filePath, label) {
9132
+ try {
9133
+ return readFileSync5(filePath, "utf8");
9134
+ } catch (error) {
9135
+ const message = error instanceof Error ? error.message : "Unable to read file.";
9136
+ throw new CliError(
9137
+ "invalid_cli_usage",
9138
+ `Failed to read ${label} from ${filePath}: ${message}`
9139
+ );
9140
+ }
9141
+ }
9142
+ function readJsonObjectOption2(raw, rawFile, rawLabel, rawFileLabel) {
9143
+ if (raw && rawFile) {
9144
+ throw new CliError(
9145
+ "invalid_cli_usage",
9146
+ `Provide either "${rawLabel}" or "${rawFileLabel}", not both.`
9147
+ );
9148
+ }
9149
+ let parsed;
9150
+ if (raw) {
9151
+ parsed = parseJsonValue2(raw, rawLabel);
9152
+ } else if (rawFile) {
9153
+ parsed = parseJsonValue2(readTextFile2(rawFile, rawFileLabel), `${rawFileLabel} ${rawFile}`);
9154
+ } else {
9155
+ return {};
9156
+ }
9157
+ if (!isJsonObject4(parsed)) {
9158
+ throw new CliError(
9159
+ "invalid_cli_usage",
9160
+ `Expected ${raw ? rawLabel : rawFileLabel} to contain a JSON object.`
9161
+ );
9162
+ }
9163
+ return parsed;
9164
+ }
8864
9165
  function readLocalFile(filePath) {
8865
9166
  try {
8866
9167
  return readFileSync5(filePath);
@@ -8880,25 +9181,348 @@ function writeDownloadedFile(outputPath, value) {
8880
9181
  );
8881
9182
  }
8882
9183
  }
8883
- function registerFilesCommands(program, options = {}) {
9184
+ function templateRows(templates) {
9185
+ return templates.map((template) => ({
9186
+ id: template.id ?? "",
9187
+ name: template.name ?? "",
9188
+ assetCount: Array.isArray(template.assets) ? template.assets.length : 0,
9189
+ updatedAt: template.updatedAt ?? ""
9190
+ }));
9191
+ }
9192
+ function resolveTemplate(templates, selector) {
9193
+ if (selector.kind === "uuid") {
9194
+ const match = templates.find((template) => template.id === selector.value);
9195
+ if (match) {
9196
+ return match;
9197
+ }
9198
+ throw new CliError(
9199
+ "invalid_cli_usage",
9200
+ `Document template "${selector.value}" was not found.`
9201
+ );
9202
+ }
9203
+ const matches = templates.filter((template) => template.name === selector.value);
9204
+ if (matches.length === 1) {
9205
+ return matches[0];
9206
+ }
9207
+ if (matches.length > 1) {
9208
+ throw new CliError(
9209
+ "invalid_cli_usage",
9210
+ `Document template "${selector.value}" is ambiguous. Found ${matches.length} matches.`
9211
+ );
9212
+ }
9213
+ throw new CliError(
9214
+ "invalid_cli_usage",
9215
+ `Document template "${selector.value}" was not found.`
9216
+ );
9217
+ }
9218
+ async function resolveTemplateSelector(api, selector) {
9219
+ if (selector.kind === "uuid") {
9220
+ return selector;
9221
+ }
9222
+ const templates = await api.listTemplates();
9223
+ const resolved = resolveTemplate(templates, selector);
9224
+ if (typeof resolved.id !== "string" || resolved.id.length === 0) {
9225
+ throw new CliError(
9226
+ "invalid_cli_usage",
9227
+ `Document template "${selector.value}" is missing an id in the API response.`
9228
+ );
9229
+ }
9230
+ return { kind: "uuid", value: resolved.id };
9231
+ }
9232
+ function buildCreateInput(options) {
9233
+ const raw = readJsonObjectOption2(options.raw, options.rawFile, "--raw", "--raw-file");
9234
+ const input = { ...raw };
9235
+ if (options.name !== void 0) {
9236
+ input.name = options.name;
9237
+ }
9238
+ if (typeof input.name !== "string" || input.name.trim().length === 0) {
9239
+ throw new CliError("invalid_cli_usage", 'Provide template name via "--name".');
9240
+ }
9241
+ if (input.assets === void 0) {
9242
+ input.assets = [];
9243
+ }
9244
+ return input;
9245
+ }
9246
+ function buildUpdateInput(options) {
9247
+ const input = {};
9248
+ if (options.name !== void 0) {
9249
+ input.name = options.name;
9250
+ }
9251
+ if (isEmptyObject4(input)) {
9252
+ throw new CliError("invalid_cli_usage", 'Provide template updates via "--name".');
9253
+ }
9254
+ return input;
9255
+ }
9256
+ function registerDocumentTemplatesCommands(program, options = {}) {
8884
9257
  const filePath = options.configPath ?? defaultConfigPath;
8885
9258
  const stdout = getCommandIo5(options.stdout);
8886
- const files = program.command("files").description("Manage files and storage");
8887
- files.command("upload").description("Upload a local file").argument("<path>", "path to the local file").action(function action(path) {
8888
- const { api, json, readOnly } = createFilesApi(this, filePath);
8889
- ensureWritable4("files upload", readOnly, "write");
8890
- const contents = readLocalFile(path);
8891
- const formData = new FormData();
8892
- formData.append("file", new Blob([contents]), basename(path));
8893
- return api.uploadFile(formData).then((data) => {
8894
- if (json) {
8895
- emitJson5(stdout, "files upload", data, filePath);
8896
- return;
8897
- }
8898
- writeLine5(stdout, `Uploaded file "${basename(path)}".`);
8899
- });
8900
- });
8901
- files.command("download").description("Download a file").argument("<file>", "file identifier").option("--output <path>", "write the downloaded file to a path").action(function action(file, commandOptions) {
9259
+ const templates = program.command("document-templates").description("Manage document templates and their assets");
9260
+ templates.command("list").description("List document templates").action(async function action() {
9261
+ const { api, json } = createDocumentTemplatesApi(this, filePath);
9262
+ const data = await api.listTemplates();
9263
+ if (json) {
9264
+ emitJson5(stdout, "document-templates list", data, filePath);
9265
+ return;
9266
+ }
9267
+ printTable(templateRows(data), ["id", "name", "assetCount", "updatedAt"], stdout);
9268
+ });
9269
+ templates.command("get").description("Get a document template by UUID or exact name").argument("<template>", "template UUID or exact name", parseUuidOrSlugSelector4).action(async function action(template) {
9270
+ const { api, json } = createDocumentTemplatesApi(this, filePath);
9271
+ const list = await api.listTemplates();
9272
+ const data = resolveTemplate(list, template);
9273
+ if (json) {
9274
+ emitJson5(stdout, "document-templates get", data, filePath);
9275
+ return;
9276
+ }
9277
+ printTable([data], void 0, stdout);
9278
+ });
9279
+ templates.command("create").description("Create a document template").option("--name <name>", "template name").option("--raw <json>", "raw create JSON payload").option("--raw-file <path>", "path to raw create JSON payload").action(async function action(commandOptions) {
9280
+ const { api, json, readOnly } = createDocumentTemplatesApi(this, filePath);
9281
+ ensureWritable4("document-templates create", readOnly, "write");
9282
+ const data = await api.createTemplate(buildCreateInput(commandOptions));
9283
+ if (json) {
9284
+ emitJson5(stdout, "document-templates create", data, filePath);
9285
+ return;
9286
+ }
9287
+ writeLine5(stdout, `Created document template "${String(data.name ?? commandOptions.name)}".`);
9288
+ });
9289
+ templates.command("update").description("Rename a document template").argument("<template>", "template UUID or exact name", parseUuidOrSlugSelector4).option("--name <name>", "new template name").action(async function action(template, commandOptions) {
9290
+ const { api, json, readOnly } = createDocumentTemplatesApi(this, filePath);
9291
+ ensureWritable4("document-templates update", readOnly, "write");
9292
+ const resolved = await resolveTemplateSelector(api, template);
9293
+ const data = await api.updateTemplate(resolved, buildUpdateInput(commandOptions));
9294
+ if (json) {
9295
+ emitJson5(stdout, "document-templates update", data, filePath);
9296
+ return;
9297
+ }
9298
+ writeLine5(stdout, `Updated document template "${String(data.name ?? template.value)}".`);
9299
+ });
9300
+ templates.command("delete").description("Delete a document template (and its assets)").argument("<template>", "template UUID or exact name", parseUuidOrSlugSelector4).action(async function action(template) {
9301
+ const { api, json, readOnly } = createDocumentTemplatesApi(this, filePath);
9302
+ ensureWritable4("document-templates delete", readOnly, "destructive");
9303
+ const resolved = await resolveTemplateSelector(api, template);
9304
+ const data = await api.deleteTemplate(resolved);
9305
+ if (json) {
9306
+ emitJson5(stdout, "document-templates delete", data, filePath);
9307
+ return;
9308
+ }
9309
+ writeLine5(stdout, `Deleted document template "${template.value}".`);
9310
+ });
9311
+ const assets = templates.command("assets").description("Manage document template assets");
9312
+ assets.command("add").description("Upload an asset file to a document template").argument("<template>", "template UUID or exact name", parseUuidOrSlugSelector4).argument("<path>", "path to the local file").option("--name <name>", "override the asset display name").action(async function action(template, localPath, commandOptions) {
9313
+ const { api, json, readOnly } = createDocumentTemplatesApi(this, filePath);
9314
+ ensureWritable4("document-templates assets add", readOnly, "write");
9315
+ const contents = readLocalFile(localPath);
9316
+ const formData = new FormData();
9317
+ formData.append("file", new Blob([contents]), basename(localPath));
9318
+ if (commandOptions.name !== void 0) {
9319
+ formData.append("name", commandOptions.name);
9320
+ }
9321
+ const resolved = await resolveTemplateSelector(api, template);
9322
+ const data = await api.addAsset(resolved, formData);
9323
+ if (json) {
9324
+ emitJson5(stdout, "document-templates assets add", data, filePath);
9325
+ return;
9326
+ }
9327
+ writeLine5(
9328
+ stdout,
9329
+ `Added asset "${commandOptions.name ?? basename(localPath)}" to template "${template.value}".`
9330
+ );
9331
+ });
9332
+ assets.command("delete").description("Delete one asset from a document template").argument("<template>", "template UUID or exact name", parseUuidOrSlugSelector4).argument("<asset>", "asset UUID").action(async function action(template, assetId) {
9333
+ const { api, json, readOnly } = createDocumentTemplatesApi(this, filePath);
9334
+ ensureWritable4("document-templates assets delete", readOnly, "destructive");
9335
+ const resolved = await resolveTemplateSelector(api, template);
9336
+ const data = await api.deleteAsset(resolved, assetId);
9337
+ if (json) {
9338
+ emitJson5(stdout, "document-templates assets delete", data, filePath);
9339
+ return;
9340
+ }
9341
+ writeLine5(stdout, `Deleted asset "${assetId}" from template "${template.value}".`);
9342
+ });
9343
+ assets.command("download").description("Download the raw bytes of a document template asset").argument("<template>", "template UUID or exact name", parseUuidOrSlugSelector4).argument("<asset>", "asset UUID").option("--output <path>", "write the downloaded bytes to a path").action(async function action(template, assetId, commandOptions) {
9344
+ const { api, json } = createDocumentTemplatesApi(this, filePath);
9345
+ if (json && !commandOptions.output) {
9346
+ throw new CliError(
9347
+ "invalid_cli_usage",
9348
+ 'Provide "--output" when using "--json" with "document-templates assets download".'
9349
+ );
9350
+ }
9351
+ const resolved = await resolveTemplateSelector(api, template);
9352
+ const data = await api.downloadAsset(resolved, assetId);
9353
+ if (commandOptions.output) {
9354
+ writeDownloadedFile(commandOptions.output, data);
9355
+ if (json) {
9356
+ emitJson5(
9357
+ stdout,
9358
+ "document-templates assets download",
9359
+ {
9360
+ template: resolved.value,
9361
+ asset: assetId,
9362
+ output: commandOptions.output,
9363
+ bytes: data.byteLength
9364
+ },
9365
+ filePath
9366
+ );
9367
+ return;
9368
+ }
9369
+ writeLine5(stdout, `Downloaded asset to "${commandOptions.output}".`);
9370
+ return;
9371
+ }
9372
+ writeBinary(stdout, data);
9373
+ });
9374
+ }
9375
+
9376
+ // src/commands/files.ts
9377
+ import { readFileSync as readFileSync6, writeFileSync as writeFileSync3 } from "fs";
9378
+ import { basename as basename2 } from "path";
9379
+ import { InvalidArgumentError as InvalidArgumentError5 } from "commander";
9380
+
9381
+ // src/api/files.ts
9382
+ function selectorValue5(selector) {
9383
+ return selector.value;
9384
+ }
9385
+ var FilesApi = class {
9386
+ constructor(client) {
9387
+ this.client = client;
9388
+ }
9389
+ uploadFile(input) {
9390
+ return this.client.requestJson("/api/v2/files", {
9391
+ method: "POST",
9392
+ body: input
9393
+ });
9394
+ }
9395
+ downloadFile(file) {
9396
+ return this.client.requestBinary(`/api/v2/files/${selectorValue5(file)}`);
9397
+ }
9398
+ deleteFile(file) {
9399
+ return this.client.requestJson(
9400
+ `/api/v2/files/${selectorValue5(file)}`,
9401
+ { method: "DELETE" }
9402
+ );
9403
+ }
9404
+ getStorageInfo() {
9405
+ return this.client.getJson("/api/v2/files/storage-info");
9406
+ }
9407
+ };
9408
+
9409
+ // src/commands/files.ts
9410
+ function getCommandIo6(stdout) {
9411
+ return stdout ?? process.stdout;
9412
+ }
9413
+ function writeLine6(stdout, value) {
9414
+ stdout.write(`${value}
9415
+ `);
9416
+ }
9417
+ function writeBinary2(stdout, value) {
9418
+ stdout.write(Buffer.from(value));
9419
+ }
9420
+ function getGlobalOptions6(command) {
9421
+ return command.optsWithGlobals();
9422
+ }
9423
+ function emitJson6(stdout, commandName, data, configPath, meta = {}) {
9424
+ writeLine6(
9425
+ stdout,
9426
+ JSON.stringify(buildJsonSuccess(data, { command: commandName, configPath, ...meta }))
9427
+ );
9428
+ }
9429
+ function toConfigurationError6(filePath, error) {
9430
+ if (error instanceof CliError) {
9431
+ throw error;
9432
+ }
9433
+ if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") {
9434
+ throw new CliError("configuration_error", `Config file not found at ${filePath}.`);
9435
+ }
9436
+ if (error instanceof Error) {
9437
+ throw new CliError("configuration_error", error.message);
9438
+ }
9439
+ throw error;
9440
+ }
9441
+ function createFilesApi(command, filePath) {
9442
+ try {
9443
+ const config = readRuntimeConfig(filePath);
9444
+ const runtime = resolveRuntimeContext(config, getGlobalOptions6(command));
9445
+ if (!runtime.baseUrl) {
9446
+ throw new CliError(
9447
+ "configuration_error",
9448
+ `Resolved profile "${runtime.profile}" is missing a base URL.`
9449
+ );
9450
+ }
9451
+ return {
9452
+ api: new FilesApi(
9453
+ new ApiClient({
9454
+ baseUrl: runtime.baseUrl,
9455
+ apiKey: runtime.apiKey
9456
+ })
9457
+ ),
9458
+ json: runtime.json,
9459
+ readOnly: runtime.readOnly
9460
+ };
9461
+ } catch (error) {
9462
+ toConfigurationError6(filePath, error);
9463
+ }
9464
+ }
9465
+ function ensureWritable5(commandName, readOnly, commandMode) {
9466
+ if (readOnly) {
9467
+ throw new CliError(
9468
+ "command_not_allowed_in_read_only_mode",
9469
+ `Command "${commandName}" is not allowed in read-only mode.`,
9470
+ {
9471
+ commandMode,
9472
+ executionMode: "read-only"
9473
+ }
9474
+ );
9475
+ }
9476
+ }
9477
+ function parseUuidOrSlugSelector5(input) {
9478
+ try {
9479
+ return normalizeUuidOrSlug(input);
9480
+ } catch (error) {
9481
+ const message = error instanceof Error ? error.message : "Invalid selector.";
9482
+ throw new InvalidArgumentError5(message);
9483
+ }
9484
+ }
9485
+ function isRecord3(value) {
9486
+ return typeof value === "object" && value !== null && !Array.isArray(value);
9487
+ }
9488
+ function readLocalFile2(filePath) {
9489
+ try {
9490
+ return readFileSync6(filePath);
9491
+ } catch (error) {
9492
+ const message = error instanceof Error ? error.message : "Unable to read file.";
9493
+ throw new CliError("invalid_cli_usage", `Failed to read file at ${filePath}: ${message}`);
9494
+ }
9495
+ }
9496
+ function writeDownloadedFile2(outputPath, value) {
9497
+ try {
9498
+ writeFileSync3(outputPath, Buffer.from(value));
9499
+ } catch (error) {
9500
+ const message = error instanceof Error ? error.message : "Unable to write file.";
9501
+ throw new CliError(
9502
+ "invalid_cli_usage",
9503
+ `Failed to write downloaded file to ${outputPath}: ${message}`
9504
+ );
9505
+ }
9506
+ }
9507
+ function registerFilesCommands(program, options = {}) {
9508
+ const filePath = options.configPath ?? defaultConfigPath;
9509
+ const stdout = getCommandIo6(options.stdout);
9510
+ const files = program.command("files").description("Manage files and storage");
9511
+ files.command("upload").description("Upload a local file").argument("<path>", "path to the local file").action(function action(path) {
9512
+ const { api, json, readOnly } = createFilesApi(this, filePath);
9513
+ ensureWritable5("files upload", readOnly, "write");
9514
+ const contents = readLocalFile2(path);
9515
+ const formData = new FormData();
9516
+ formData.append("file", new Blob([contents]), basename2(path));
9517
+ return api.uploadFile(formData).then((data) => {
9518
+ if (json) {
9519
+ emitJson6(stdout, "files upload", data, filePath);
9520
+ return;
9521
+ }
9522
+ writeLine6(stdout, `Uploaded file "${basename2(path)}".`);
9523
+ });
9524
+ });
9525
+ files.command("download").description("Download a file").argument("<file>", "file identifier").option("--output <path>", "write the downloaded file to a path").action(function action(file, commandOptions) {
8902
9526
  const { api, json } = createFilesApi(this, filePath);
8903
9527
  if (json && !commandOptions.output) {
8904
9528
  throw new CliError(
@@ -8906,12 +9530,12 @@ function registerFilesCommands(program, options = {}) {
8906
9530
  'Provide "--output" when using "--json" with "files download".'
8907
9531
  );
8908
9532
  }
8909
- const fileSelector = parseUuidOrSlugSelector4(file);
9533
+ const fileSelector = parseUuidOrSlugSelector5(file);
8910
9534
  return api.downloadFile(fileSelector).then((data) => {
8911
9535
  if (commandOptions.output) {
8912
- writeDownloadedFile(commandOptions.output, data);
9536
+ writeDownloadedFile2(commandOptions.output, data);
8913
9537
  if (json) {
8914
- emitJson5(
9538
+ emitJson6(
8915
9539
  stdout,
8916
9540
  "files download",
8917
9541
  {
@@ -8923,45 +9547,45 @@ function registerFilesCommands(program, options = {}) {
8923
9547
  );
8924
9548
  return;
8925
9549
  }
8926
- writeLine5(stdout, `Downloaded file to "${commandOptions.output}".`);
9550
+ writeLine6(stdout, `Downloaded file to "${commandOptions.output}".`);
8927
9551
  return;
8928
9552
  }
8929
- writeBinary(stdout, data);
9553
+ writeBinary2(stdout, data);
8930
9554
  });
8931
9555
  });
8932
9556
  files.command("delete").description("Delete a file").argument("<file>", "file identifier").action(function action(file) {
8933
9557
  const { api, json, readOnly } = createFilesApi(this, filePath);
8934
- ensureWritable4("files delete", readOnly, "destructive");
8935
- const fileSelector = parseUuidOrSlugSelector4(file);
9558
+ ensureWritable5("files delete", readOnly, "destructive");
9559
+ const fileSelector = parseUuidOrSlugSelector5(file);
8936
9560
  return api.deleteFile(fileSelector).then((data) => {
8937
9561
  if (json) {
8938
- emitJson5(stdout, "files delete", data, filePath);
9562
+ emitJson6(stdout, "files delete", data, filePath);
8939
9563
  return;
8940
9564
  }
8941
- writeLine5(stdout, `Deleted file "${fileSelector.value}".`);
9565
+ writeLine6(stdout, `Deleted file "${fileSelector.value}".`);
8942
9566
  });
8943
9567
  });
8944
9568
  files.command("storage").description("Show storage usage information").action(function action() {
8945
9569
  const { api, json } = createFilesApi(this, filePath);
8946
9570
  return api.getStorageInfo().then((data) => {
8947
9571
  if (json) {
8948
- emitJson5(stdout, "files storage", data, filePath);
9572
+ emitJson6(stdout, "files storage", data, filePath);
8949
9573
  return;
8950
9574
  }
8951
9575
  if (isRecord3(data)) {
8952
9576
  printTable([data], Object.keys(data), stdout);
8953
9577
  return;
8954
9578
  }
8955
- writeLine5(stdout, String(data));
9579
+ writeLine6(stdout, String(data));
8956
9580
  });
8957
9581
  });
8958
9582
  }
8959
9583
 
8960
9584
  // src/commands/logs.ts
8961
- import { InvalidArgumentError as InvalidArgumentError5 } from "commander";
9585
+ import { InvalidArgumentError as InvalidArgumentError6 } from "commander";
8962
9586
 
8963
9587
  // src/api/logs.ts
8964
- function selectorValue5(selector) {
9588
+ function selectorValue6(selector) {
8965
9589
  return selector.value;
8966
9590
  }
8967
9591
  var LogsApi = class {
@@ -8970,29 +9594,29 @@ var LogsApi = class {
8970
9594
  }
8971
9595
  listLogs(schema, recordId) {
8972
9596
  return this.client.getJson(
8973
- `/api/v2/schemas/${selectorValue5(schema)}/records/${recordId}/logs`
9597
+ `/api/v2/schemas/${selectorValue6(schema)}/records/${recordId}/logs`
8974
9598
  );
8975
9599
  }
8976
9600
  };
8977
9601
 
8978
9602
  // src/commands/logs.ts
8979
- function getCommandIo6(stdout) {
9603
+ function getCommandIo7(stdout) {
8980
9604
  return stdout ?? process.stdout;
8981
9605
  }
8982
- function writeLine6(stdout, value) {
9606
+ function writeLine7(stdout, value) {
8983
9607
  stdout.write(`${value}
8984
9608
  `);
8985
9609
  }
8986
- function getGlobalOptions6(command) {
9610
+ function getGlobalOptions7(command) {
8987
9611
  return command.optsWithGlobals();
8988
9612
  }
8989
- function emitJson6(stdout, commandName, data, ..._extra) {
8990
- writeLine6(
9613
+ function emitJson7(stdout, commandName, data, ..._extra) {
9614
+ writeLine7(
8991
9615
  stdout,
8992
9616
  JSON.stringify(buildJsonSuccess(data, { command: commandName }))
8993
9617
  );
8994
9618
  }
8995
- function toConfigurationError6(filePath, error) {
9619
+ function toConfigurationError7(filePath, error) {
8996
9620
  if (error instanceof CliError) {
8997
9621
  throw error;
8998
9622
  }
@@ -9007,7 +9631,7 @@ function toConfigurationError6(filePath, error) {
9007
9631
  function createLogsApi(command, filePath) {
9008
9632
  try {
9009
9633
  const config = readRuntimeConfig(filePath);
9010
- const runtime = resolveRuntimeContext(config, getGlobalOptions6(command));
9634
+ const runtime = resolveRuntimeContext(config, getGlobalOptions7(command));
9011
9635
  if (!runtime.baseUrl) {
9012
9636
  throw new CliError(
9013
9637
  "configuration_error",
@@ -9024,25 +9648,25 @@ function createLogsApi(command, filePath) {
9024
9648
  json: runtime.json
9025
9649
  };
9026
9650
  } catch (error) {
9027
- toConfigurationError6(filePath, error);
9651
+ toConfigurationError7(filePath, error);
9028
9652
  }
9029
9653
  }
9030
- function parseUuidOrSlugSelector5(input) {
9654
+ function parseUuidOrSlugSelector6(input) {
9031
9655
  try {
9032
9656
  return normalizeUuidOrSlug(input);
9033
9657
  } catch (error) {
9034
9658
  const message = error instanceof Error ? error.message : "Invalid selector.";
9035
- throw new InvalidArgumentError5(message);
9659
+ throw new InvalidArgumentError6(message);
9036
9660
  }
9037
9661
  }
9038
- function isJsonObject4(value) {
9662
+ function isJsonObject5(value) {
9039
9663
  return typeof value === "object" && value !== null && !Array.isArray(value);
9040
9664
  }
9041
9665
  function toTableRows3(data) {
9042
9666
  if (Array.isArray(data)) {
9043
- return data.map((entry) => isJsonObject4(entry) ? entry : { value: entry });
9667
+ return data.map((entry) => isJsonObject5(entry) ? entry : { value: entry });
9044
9668
  }
9045
- if (isJsonObject4(data)) {
9669
+ if (isJsonObject5(data)) {
9046
9670
  return [data];
9047
9671
  }
9048
9672
  return [{ value: data }];
@@ -9052,13 +9676,13 @@ function emitTable3(stdout, data) {
9052
9676
  }
9053
9677
  function registerLogsCommands(program, options = {}) {
9054
9678
  const filePath = options.configPath ?? defaultConfigPath;
9055
- const stdout = getCommandIo6(options.stdout);
9679
+ const stdout = getCommandIo7(options.stdout);
9056
9680
  const logs = program.command("logs").description("Inspect record change logs");
9057
- logs.command("list").description("List change logs for a record").argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector5).argument("<record>", "record uuid or slug", parseUuidOrSlugSelector5).action(async function action(schema, record) {
9681
+ logs.command("list").description("List change logs for a record").argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector6).argument("<record>", "record uuid or slug", parseUuidOrSlugSelector6).action(async function action(schema, record) {
9058
9682
  const { api, json } = createLogsApi(this, filePath);
9059
9683
  const data = await api.listLogs(schema, record.value);
9060
9684
  if (json) {
9061
- emitJson6(stdout, "logs list", data, filePath);
9685
+ emitJson7(stdout, "logs list", data, filePath);
9062
9686
  return;
9063
9687
  }
9064
9688
  emitTable3(stdout, data);
@@ -9066,11 +9690,11 @@ function registerLogsCommands(program, options = {}) {
9066
9690
  }
9067
9691
 
9068
9692
  // src/commands/navigation.ts
9069
- import { readFileSync as readFileSync6 } from "fs";
9070
- import { InvalidArgumentError as InvalidArgumentError6 } from "commander";
9693
+ import { readFileSync as readFileSync7 } from "fs";
9694
+ import { InvalidArgumentError as InvalidArgumentError7 } from "commander";
9071
9695
 
9072
9696
  // src/api/navigation.ts
9073
- function jsonOptions4(body, method) {
9697
+ function jsonOptions5(body, method) {
9074
9698
  return {
9075
9699
  method,
9076
9700
  headers: {
@@ -9079,7 +9703,7 @@ function jsonOptions4(body, method) {
9079
9703
  body: JSON.stringify(body)
9080
9704
  };
9081
9705
  }
9082
- function selectorValue6(selector) {
9706
+ function selectorValue7(selector) {
9083
9707
  return selector.value;
9084
9708
  }
9085
9709
  var NavigationApi = class {
@@ -9092,44 +9716,44 @@ var NavigationApi = class {
9092
9716
  createFolder(body) {
9093
9717
  return this.client.requestJson(
9094
9718
  "/api/v2/navigation/folders",
9095
- jsonOptions4(body, "POST")
9719
+ jsonOptions5(body, "POST")
9096
9720
  );
9097
9721
  }
9098
9722
  updateFolder(folder, body) {
9099
9723
  return this.client.requestJson(
9100
- `/api/v2/navigation/folders/${selectorValue6(folder)}`,
9101
- jsonOptions4(body, "PATCH")
9724
+ `/api/v2/navigation/folders/${selectorValue7(folder)}`,
9725
+ jsonOptions5(body, "PATCH")
9102
9726
  );
9103
9727
  }
9104
9728
  deleteFolder(folder) {
9105
9729
  return this.client.requestJson(
9106
- `/api/v2/navigation/folders/${selectorValue6(folder)}`,
9730
+ `/api/v2/navigation/folders/${selectorValue7(folder)}`,
9107
9731
  { method: "DELETE" }
9108
9732
  );
9109
9733
  }
9110
9734
  moveResource(body) {
9111
9735
  return this.client.requestJson(
9112
9736
  "/api/v2/navigation/resources:move",
9113
- jsonOptions4(body, "POST")
9737
+ jsonOptions5(body, "POST")
9114
9738
  );
9115
9739
  }
9116
9740
  };
9117
9741
 
9118
9742
  // src/commands/navigation.ts
9119
- function getCommandIo7(stdout) {
9743
+ function getCommandIo8(stdout) {
9120
9744
  return stdout ?? process.stdout;
9121
9745
  }
9122
- function writeLine7(stdout, value) {
9746
+ function writeLine8(stdout, value) {
9123
9747
  stdout.write(`${value}
9124
9748
  `);
9125
9749
  }
9126
- function getGlobalOptions7(command) {
9750
+ function getGlobalOptions8(command) {
9127
9751
  return command.optsWithGlobals();
9128
9752
  }
9129
- function emitJson7(stdout, commandName, data, configPath) {
9130
- writeLine7(stdout, JSON.stringify(buildJsonSuccess(data, { command: commandName, configPath })));
9753
+ function emitJson8(stdout, commandName, data, configPath) {
9754
+ writeLine8(stdout, JSON.stringify(buildJsonSuccess(data, { command: commandName, configPath })));
9131
9755
  }
9132
- function toConfigurationError7(filePath, error) {
9756
+ function toConfigurationError8(filePath, error) {
9133
9757
  if (error instanceof CliError) {
9134
9758
  throw error;
9135
9759
  }
@@ -9144,7 +9768,7 @@ function toConfigurationError7(filePath, error) {
9144
9768
  function createNavigationApi(command, filePath) {
9145
9769
  try {
9146
9770
  const config = readRuntimeConfig(filePath);
9147
- const runtime = resolveRuntimeContext(config, getGlobalOptions7(command));
9771
+ const runtime = resolveRuntimeContext(config, getGlobalOptions8(command));
9148
9772
  if (!runtime.baseUrl) {
9149
9773
  throw new CliError("configuration_error", `Resolved profile "${runtime.profile}" is missing a base URL.`);
9150
9774
  }
@@ -9159,10 +9783,10 @@ function createNavigationApi(command, filePath) {
9159
9783
  readOnly: runtime.readOnly
9160
9784
  };
9161
9785
  } catch (error) {
9162
- toConfigurationError7(filePath, error);
9786
+ toConfigurationError8(filePath, error);
9163
9787
  }
9164
9788
  }
9165
- function ensureWritable5(commandName, readOnly, mode) {
9789
+ function ensureWritable6(commandName, readOnly, mode) {
9166
9790
  if (readOnly) {
9167
9791
  throw new CliError(
9168
9792
  "command_not_allowed_in_read_only_mode",
@@ -9171,12 +9795,12 @@ function ensureWritable5(commandName, readOnly, mode) {
9171
9795
  );
9172
9796
  }
9173
9797
  }
9174
- function parseUuidOrSlugSelector6(input) {
9798
+ function parseUuidOrSlugSelector7(input) {
9175
9799
  try {
9176
9800
  return normalizeUuidOrSlug(input);
9177
9801
  } catch (error) {
9178
9802
  const message = error instanceof Error ? error.message : "Invalid selector.";
9179
- throw new InvalidArgumentError6(message);
9803
+ throw new InvalidArgumentError7(message);
9180
9804
  }
9181
9805
  }
9182
9806
  function parseInteger(value, flagName) {
@@ -9193,7 +9817,7 @@ function readJsonObject(raw, rawFile) {
9193
9817
  if (raw && rawFile) {
9194
9818
  throw new CliError("invalid_cli_usage", 'Use either "--props" or "--props-file", not both.');
9195
9819
  }
9196
- const source = rawFile ? readFileSync6(rawFile, "utf8") : raw;
9820
+ const source = rawFile ? readFileSync7(rawFile, "utf8") : raw;
9197
9821
  if (!source) {
9198
9822
  return {};
9199
9823
  }
@@ -9255,41 +9879,41 @@ function folderRows2(folders) {
9255
9879
  }
9256
9880
  function registerNavigationCommands(program, options = {}) {
9257
9881
  const filePath = options.configPath ?? defaultConfigPath;
9258
- const stdout = getCommandIo7(options.stdout);
9882
+ const stdout = getCommandIo8(options.stdout);
9259
9883
  const navigation = program.command("navigation").description("Manage workspace navigation");
9260
9884
  const folders = navigation.command("folders").description("Manage navigation folders");
9261
9885
  folders.command("list").description("List navigation folders").action(async function action() {
9262
9886
  const { api, json } = createNavigationApi(this, filePath);
9263
9887
  const data = await api.listFolders();
9264
9888
  if (json) {
9265
- emitJson7(stdout, "navigation folders list", data, filePath);
9889
+ emitJson8(stdout, "navigation folders list", data, filePath);
9266
9890
  return;
9267
9891
  }
9268
9892
  printTable(folderRows2(data), ["id", "order", "name", "resourceCount"], stdout);
9269
9893
  });
9270
- folders.command("get").description("Get a navigation folder by UUID or exact name").argument("<folder>", "folder UUID or exact name", parseUuidOrSlugSelector6).action(async function action(folder) {
9894
+ folders.command("get").description("Get a navigation folder by UUID or exact name").argument("<folder>", "folder UUID or exact name", parseUuidOrSlugSelector7).action(async function action(folder) {
9271
9895
  const { api, json } = createNavigationApi(this, filePath);
9272
9896
  const data = await api.listFolders();
9273
9897
  const resolved = resolveFolder2(data, folder);
9274
9898
  if (json) {
9275
- emitJson7(stdout, "navigation folders get", resolved, filePath);
9899
+ emitJson8(stdout, "navigation folders get", resolved, filePath);
9276
9900
  return;
9277
9901
  }
9278
9902
  printTable(folderRows2([resolved]), ["id", "order", "name", "resourceCount"], stdout);
9279
9903
  });
9280
9904
  folders.command("create").description("Create a navigation folder").requiredOption("--name <name>", "folder name").option("--order <n>", "folder order").option("--props <json>", "folder additionalProperties JSON").option("--props-file <path>", "folder additionalProperties JSON file").action(async function action(commandOptions) {
9281
9905
  const { api, json, readOnly } = createNavigationApi(this, filePath);
9282
- ensureWritable5("navigation folders create", readOnly, "write");
9906
+ ensureWritable6("navigation folders create", readOnly, "write");
9283
9907
  const data = await api.createFolder(buildFolderBody(commandOptions));
9284
9908
  if (json) {
9285
- emitJson7(stdout, "navigation folders create", data, filePath);
9909
+ emitJson8(stdout, "navigation folders create", data, filePath);
9286
9910
  return;
9287
9911
  }
9288
- writeLine7(stdout, `Created navigation folder "${String(data.name ?? commandOptions.name)}".`);
9912
+ writeLine8(stdout, `Created navigation folder "${String(data.name ?? commandOptions.name)}".`);
9289
9913
  });
9290
- folders.command("update").description("Update a navigation folder").argument("<folder>", "folder UUID or exact name", parseUuidOrSlugSelector6).option("--name <name>", "folder name").option("--order <n>", "folder order").option("--props <json>", "folder additionalProperties JSON").option("--props-file <path>", "folder additionalProperties JSON file").action(async function action(folder, commandOptions) {
9914
+ folders.command("update").description("Update a navigation folder").argument("<folder>", "folder UUID or exact name", parseUuidOrSlugSelector7).option("--name <name>", "folder name").option("--order <n>", "folder order").option("--props <json>", "folder additionalProperties JSON").option("--props-file <path>", "folder additionalProperties JSON file").action(async function action(folder, commandOptions) {
9291
9915
  const { api, json, readOnly } = createNavigationApi(this, filePath);
9292
- ensureWritable5("navigation folders update", readOnly, "write");
9916
+ ensureWritable6("navigation folders update", readOnly, "write");
9293
9917
  const allFolders = await api.listFolders();
9294
9918
  const resolved = resolveFolder2(allFolders, folder);
9295
9919
  const body = buildFolderBody(commandOptions);
@@ -9298,54 +9922,54 @@ function registerNavigationCommands(program, options = {}) {
9298
9922
  }
9299
9923
  const data = await api.updateFolder({ kind: "uuid", value: resolved.id }, body);
9300
9924
  if (json) {
9301
- emitJson7(stdout, "navigation folders update", data, filePath);
9925
+ emitJson8(stdout, "navigation folders update", data, filePath);
9302
9926
  return;
9303
9927
  }
9304
- writeLine7(stdout, `Updated navigation folder "${String(data.name ?? resolved.name ?? resolved.id)}".`);
9928
+ writeLine8(stdout, `Updated navigation folder "${String(data.name ?? resolved.name ?? resolved.id)}".`);
9305
9929
  });
9306
- folders.command("delete").description("Delete a navigation folder").argument("<folder>", "folder UUID or exact name", parseUuidOrSlugSelector6).action(async function action(folder) {
9930
+ folders.command("delete").description("Delete a navigation folder").argument("<folder>", "folder UUID or exact name", parseUuidOrSlugSelector7).action(async function action(folder) {
9307
9931
  const { api, json, readOnly } = createNavigationApi(this, filePath);
9308
- ensureWritable5("navigation folders delete", readOnly, "destructive");
9932
+ ensureWritable6("navigation folders delete", readOnly, "destructive");
9309
9933
  const allFolders = await api.listFolders();
9310
9934
  const resolved = resolveFolder2(allFolders, folder);
9311
9935
  const data = await api.deleteFolder({ kind: "uuid", value: resolved.id });
9312
9936
  if (json) {
9313
- emitJson7(stdout, "navigation folders delete", data, filePath);
9937
+ emitJson8(stdout, "navigation folders delete", data, filePath);
9314
9938
  return;
9315
9939
  }
9316
- writeLine7(stdout, `Deleted navigation folder "${resolved.name ?? resolved.id}".`);
9940
+ writeLine8(stdout, `Deleted navigation folder "${resolved.name ?? resolved.id}".`);
9317
9941
  });
9318
9942
  navigation.command("resources").description("Manage navigation resources").command("move").description("Move a resource into a folder").argument("<resource>", "resource UUID").requiredOption("--type <type>", "resource type").requiredOption("--to <folder>", "target folder UUID or exact name").action(async function action(resourceId, commandOptions) {
9319
9943
  const { api, json, readOnly } = createNavigationApi(this, filePath);
9320
- ensureWritable5("navigation resources move", readOnly, "write");
9944
+ ensureWritable6("navigation resources move", readOnly, "write");
9321
9945
  const allFolders = await api.listFolders();
9322
- const resolved = resolveFolder2(allFolders, parseUuidOrSlugSelector6(commandOptions.to));
9946
+ const resolved = resolveFolder2(allFolders, parseUuidOrSlugSelector7(commandOptions.to));
9323
9947
  const data = await api.moveResource({
9324
9948
  resourceId,
9325
9949
  resourceType: commandOptions.type.toUpperCase(),
9326
9950
  targetFolderId: resolved.id
9327
9951
  });
9328
9952
  if (json) {
9329
- emitJson7(stdout, "navigation resources move", data, filePath);
9953
+ emitJson8(stdout, "navigation resources move", data, filePath);
9330
9954
  return;
9331
9955
  }
9332
- writeLine7(stdout, `Moved resource "${resourceId}" to "${resolved.name ?? resolved.id}".`);
9956
+ writeLine8(stdout, `Moved resource "${resourceId}" to "${resolved.name ?? resolved.id}".`);
9333
9957
  });
9334
9958
  }
9335
9959
 
9336
9960
  // src/commands/profiles.ts
9337
- function getCommandIo8(stdout) {
9961
+ function getCommandIo9(stdout) {
9338
9962
  return stdout ?? process.stdout;
9339
9963
  }
9340
- function writeLine8(stdout, value) {
9964
+ function writeLine9(stdout, value) {
9341
9965
  stdout.write(`${value}
9342
9966
  `);
9343
9967
  }
9344
- function getGlobalOptions8(command) {
9968
+ function getGlobalOptions9(command) {
9345
9969
  return command.optsWithGlobals();
9346
9970
  }
9347
- function emitJson8(stdout, commandName, data, configPath) {
9348
- writeLine8(
9971
+ function emitJson9(stdout, commandName, data, configPath) {
9972
+ writeLine9(
9349
9973
  stdout,
9350
9974
  JSON.stringify(buildJsonSuccess(data, { command: commandName, configPath }))
9351
9975
  );
@@ -9401,15 +10025,15 @@ function emitProfilesTable(stdout, data) {
9401
10025
  }
9402
10026
  function registerProfilesCommands(program, options = {}) {
9403
10027
  const filePath = options.configPath ?? defaultConfigPath;
9404
- const stdout = getCommandIo8(options.stdout);
10028
+ const stdout = getCommandIo9(options.stdout);
9405
10029
  const profiles = program.command("profiles").description("Manage local CLI profiles");
9406
10030
  profiles.command("list").description("List configured profiles").action(function action() {
9407
10031
  const config = readRequiredConfig(filePath);
9408
10032
  const data = Object.entries(config.profiles).map(
9409
10033
  ([name, profile]) => toDisplayProfile(name, profile, config.defaultProfile)
9410
10034
  );
9411
- if (getGlobalOptions8(this).json) {
9412
- emitJson8(stdout, "profiles list", data, filePath);
10035
+ if (getGlobalOptions9(this).json) {
10036
+ emitJson9(stdout, "profiles list", data, filePath);
9413
10037
  return;
9414
10038
  }
9415
10039
  emitProfilesTable(stdout, data);
@@ -9418,8 +10042,8 @@ function registerProfilesCommands(program, options = {}) {
9418
10042
  const config = readRequiredConfig(filePath);
9419
10043
  const profile = getRequiredProfile(config, profileName);
9420
10044
  const data = toDisplayProfile(profileName, profile, config.defaultProfile);
9421
- if (getGlobalOptions8(this).json) {
9422
- emitJson8(stdout, "profiles get", data, filePath);
10045
+ if (getGlobalOptions9(this).json) {
10046
+ emitJson9(stdout, "profiles get", data, filePath);
9423
10047
  return;
9424
10048
  }
9425
10049
  emitProfilesTable(stdout, [data]);
@@ -9433,11 +10057,11 @@ function registerProfilesCommands(program, options = {}) {
9433
10057
  profile: profileName,
9434
10058
  defaultProfile: nextConfig.defaultProfile
9435
10059
  };
9436
- if (getGlobalOptions8(this).json) {
9437
- emitJson8(stdout, "profiles use", data, filePath);
10060
+ if (getGlobalOptions9(this).json) {
10061
+ emitJson9(stdout, "profiles use", data, filePath);
9438
10062
  return;
9439
10063
  }
9440
- writeLine8(stdout, `Using profile "${profileName}".`);
10064
+ writeLine9(stdout, `Using profile "${profileName}".`);
9441
10065
  });
9442
10066
  profiles.command("add").description("Add a profile to the local config").argument("<profile>", "profile name").requiredOption("--api-key <token>", "API key").option("--base-url <url>", "base URL").action(function action(profileName, commandOptions) {
9443
10067
  const config = loadConfigForAdd(filePath);
@@ -9461,11 +10085,11 @@ function registerProfilesCommands(program, options = {}) {
9461
10085
  nextConfig.profiles[profileName] ?? {},
9462
10086
  nextConfig.defaultProfile
9463
10087
  );
9464
- if (getGlobalOptions8(this).json) {
9465
- emitJson8(stdout, "profiles add", data, filePath);
10088
+ if (getGlobalOptions9(this).json) {
10089
+ emitJson9(stdout, "profiles add", data, filePath);
9466
10090
  return;
9467
10091
  }
9468
- writeLine8(stdout, `Added profile "${profileName}".`);
10092
+ writeLine9(stdout, `Added profile "${profileName}".`);
9469
10093
  });
9470
10094
  profiles.command("update").description("Update an existing profile").argument("<profile>", "profile name").option("--api-key <token>", "API key").option("--base-url <url>", "base URL").action(function action(profileName, commandOptions) {
9471
10095
  if (commandOptions.apiKey === void 0 && commandOptions.baseUrl === void 0) {
@@ -9487,11 +10111,11 @@ function registerProfilesCommands(program, options = {}) {
9487
10111
  nextConfig.profiles[profileName] ?? {},
9488
10112
  nextConfig.defaultProfile
9489
10113
  );
9490
- if (getGlobalOptions8(this).json) {
9491
- emitJson8(stdout, "profiles update", data, filePath);
10114
+ if (getGlobalOptions9(this).json) {
10115
+ emitJson9(stdout, "profiles update", data, filePath);
9492
10116
  return;
9493
10117
  }
9494
- writeLine8(stdout, `Updated profile "${profileName}".`);
10118
+ writeLine9(stdout, `Updated profile "${profileName}".`);
9495
10119
  });
9496
10120
  profiles.command("remove").description("Remove a profile from the local config").argument("<profile>", "profile name").action(function action(profileName) {
9497
10121
  const config = readRequiredConfig(filePath);
@@ -9502,20 +10126,20 @@ function registerProfilesCommands(program, options = {}) {
9502
10126
  profile: profileName,
9503
10127
  defaultProfile: nextConfig.defaultProfile
9504
10128
  };
9505
- if (getGlobalOptions8(this).json) {
9506
- emitJson8(stdout, "profiles remove", data, filePath);
10129
+ if (getGlobalOptions9(this).json) {
10130
+ emitJson9(stdout, "profiles remove", data, filePath);
9507
10131
  return;
9508
10132
  }
9509
- writeLine8(stdout, `Removed profile "${profileName}".`);
10133
+ writeLine9(stdout, `Removed profile "${profileName}".`);
9510
10134
  });
9511
10135
  }
9512
10136
 
9513
10137
  // src/commands/records.ts
9514
- import { readFileSync as readFileSync7 } from "fs";
9515
- import { InvalidArgumentError as InvalidArgumentError7 } from "commander";
10138
+ import { readFileSync as readFileSync8 } from "fs";
10139
+ import { InvalidArgumentError as InvalidArgumentError8 } from "commander";
9516
10140
 
9517
10141
  // src/api/records.ts
9518
- function jsonOptions5(body, method) {
10142
+ function jsonOptions6(body, method) {
9519
10143
  return {
9520
10144
  method,
9521
10145
  headers: {
@@ -9524,7 +10148,7 @@ function jsonOptions5(body, method) {
9524
10148
  body: JSON.stringify(body)
9525
10149
  };
9526
10150
  }
9527
- function selectorValue7(selector) {
10151
+ function selectorValue8(selector) {
9528
10152
  return selector.value;
9529
10153
  }
9530
10154
  var RecordsApi = class {
@@ -9539,7 +10163,7 @@ var RecordsApi = class {
9539
10163
  if (query.offset !== void 0) {
9540
10164
  params.set("offset", String(query.offset));
9541
10165
  }
9542
- const path = `/api/v2/schemas/${selectorValue7(schema)}/records`;
10166
+ const path = `/api/v2/schemas/${selectorValue8(schema)}/records`;
9543
10167
  const queryString = params.toString();
9544
10168
  return this.client.getJson(
9545
10169
  queryString ? `${path}?${queryString}` : path
@@ -9548,36 +10172,36 @@ var RecordsApi = class {
9548
10172
  queryRecords(schema, query) {
9549
10173
  const body = this.normalizeQueryInput(query);
9550
10174
  return this.client.requestJson(
9551
- `/api/v2/schemas/${selectorValue7(schema)}/records:query`,
9552
- jsonOptions5(body, "POST")
10175
+ `/api/v2/schemas/${selectorValue8(schema)}/records:query`,
10176
+ jsonOptions6(body, "POST")
9553
10177
  );
9554
10178
  }
9555
10179
  getRecord(schema, record) {
9556
10180
  return this.client.getJson(
9557
- `/api/v2/schemas/${selectorValue7(schema)}/records/${selectorValue7(record)}`
10181
+ `/api/v2/schemas/${selectorValue8(schema)}/records/${selectorValue8(record)}`
9558
10182
  );
9559
10183
  }
9560
10184
  createRecord(schema, input) {
9561
10185
  return this.client.requestJson(
9562
- `/api/v2/schemas/${selectorValue7(schema)}/records`,
9563
- jsonOptions5(input, "POST")
10186
+ `/api/v2/schemas/${selectorValue8(schema)}/records`,
10187
+ jsonOptions6(input, "POST")
9564
10188
  );
9565
10189
  }
9566
10190
  updateRecord(schema, record, input) {
9567
10191
  return this.client.requestJson(
9568
- `/api/v2/schemas/${selectorValue7(schema)}/records/${selectorValue7(record)}`,
9569
- jsonOptions5(input, "PATCH")
10192
+ `/api/v2/schemas/${selectorValue8(schema)}/records/${selectorValue8(record)}`,
10193
+ jsonOptions6(input, "PATCH")
9570
10194
  );
9571
10195
  }
9572
10196
  deleteRecord(schema, record) {
9573
10197
  return this.client.requestJson(
9574
- `/api/v2/schemas/${selectorValue7(schema)}/records/${selectorValue7(record)}`,
10198
+ `/api/v2/schemas/${selectorValue8(schema)}/records/${selectorValue8(record)}`,
9575
10199
  { method: "DELETE" }
9576
10200
  );
9577
10201
  }
9578
10202
  clearRecords(schema) {
9579
10203
  return this.client.requestJson(
9580
- `/api/v2/schemas/${selectorValue7(schema)}/records:clear`,
10204
+ `/api/v2/schemas/${selectorValue8(schema)}/records:clear`,
9581
10205
  { method: "DELETE" }
9582
10206
  );
9583
10207
  }
@@ -9610,7 +10234,7 @@ var RecordsApi = class {
9610
10234
  };
9611
10235
 
9612
10236
  // src/api/schemas.ts
9613
- function jsonOptions6(body, method) {
10237
+ function jsonOptions7(body, method) {
9614
10238
  return {
9615
10239
  method,
9616
10240
  headers: {
@@ -9619,7 +10243,7 @@ function jsonOptions6(body, method) {
9619
10243
  body: JSON.stringify(body)
9620
10244
  };
9621
10245
  }
9622
- function selectorValue8(selector) {
10246
+ function selectorValue9(selector) {
9623
10247
  return selector.value;
9624
10248
  }
9625
10249
  var SchemasApi = class {
@@ -9630,20 +10254,20 @@ var SchemasApi = class {
9630
10254
  return this.client.getJson("/api/v2/schemas");
9631
10255
  }
9632
10256
  getSchema(schema) {
9633
- return this.client.getJson(`/api/v2/schemas/${selectorValue8(schema)}`);
10257
+ return this.client.getJson(`/api/v2/schemas/${selectorValue9(schema)}`);
9634
10258
  }
9635
10259
  createSchema(input) {
9636
- return this.client.requestJson("/api/v2/schemas", jsonOptions6(input, "POST"));
10260
+ return this.client.requestJson("/api/v2/schemas", jsonOptions7(input, "POST"));
9637
10261
  }
9638
10262
  updateSchema(schema, input) {
9639
10263
  return this.client.requestJson(
9640
- `/api/v2/schemas/${selectorValue8(schema)}`,
9641
- jsonOptions6(input, "PATCH")
10264
+ `/api/v2/schemas/${selectorValue9(schema)}`,
10265
+ jsonOptions7(input, "PATCH")
9642
10266
  );
9643
10267
  }
9644
10268
  deleteSchema(schema) {
9645
10269
  return this.client.requestJson(
9646
- `/api/v2/schemas/${selectorValue8(schema)}`,
10270
+ `/api/v2/schemas/${selectorValue9(schema)}`,
9647
10271
  { method: "DELETE" }
9648
10272
  );
9649
10273
  }
@@ -9653,47 +10277,47 @@ var SchemasApi = class {
9653
10277
  }
9654
10278
  getField(schema, field) {
9655
10279
  return this.client.getJson(
9656
- `/api/v2/schemas/${selectorValue8(schema)}/fields/${selectorValue8(field)}`
10280
+ `/api/v2/schemas/${selectorValue9(schema)}/fields/${selectorValue9(field)}`
9657
10281
  );
9658
10282
  }
9659
10283
  createField(schema, input) {
9660
10284
  return this.client.requestJson(
9661
- `/api/v2/schemas/${selectorValue8(schema)}/fields`,
9662
- jsonOptions6(input, "POST")
10285
+ `/api/v2/schemas/${selectorValue9(schema)}/fields`,
10286
+ jsonOptions7(input, "POST")
9663
10287
  );
9664
10288
  }
9665
10289
  updateField(schema, field, input) {
9666
10290
  return this.client.requestJson(
9667
- `/api/v2/schemas/${selectorValue8(schema)}/fields/${selectorValue8(field)}`,
9668
- jsonOptions6(input, "PATCH")
10291
+ `/api/v2/schemas/${selectorValue9(schema)}/fields/${selectorValue9(field)}`,
10292
+ jsonOptions7(input, "PATCH")
9669
10293
  );
9670
10294
  }
9671
10295
  deleteField(schema, field) {
9672
10296
  return this.client.requestJson(
9673
- `/api/v2/schemas/${selectorValue8(schema)}/fields/${selectorValue8(field)}`,
10297
+ `/api/v2/schemas/${selectorValue9(schema)}/fields/${selectorValue9(field)}`,
9674
10298
  { method: "DELETE" }
9675
10299
  );
9676
10300
  }
9677
10301
  };
9678
10302
 
9679
10303
  // src/commands/records.ts
9680
- function getCommandIo9(stdout) {
10304
+ function getCommandIo10(stdout) {
9681
10305
  return stdout ?? process.stdout;
9682
10306
  }
9683
- function writeLine9(stdout, value) {
10307
+ function writeLine10(stdout, value) {
9684
10308
  stdout.write(`${value}
9685
10309
  `);
9686
10310
  }
9687
- function getGlobalOptions9(command) {
10311
+ function getGlobalOptions10(command) {
9688
10312
  return command.optsWithGlobals();
9689
10313
  }
9690
- function emitJson9(stdout, commandName, data, configPath, meta = {}) {
9691
- writeLine9(
10314
+ function emitJson10(stdout, commandName, data, configPath, meta = {}) {
10315
+ writeLine10(
9692
10316
  stdout,
9693
10317
  JSON.stringify(buildJsonSuccess(data, { command: commandName, configPath, ...meta }))
9694
10318
  );
9695
10319
  }
9696
- function toConfigurationError8(filePath, error) {
10320
+ function toConfigurationError9(filePath, error) {
9697
10321
  if (error instanceof CliError) {
9698
10322
  throw error;
9699
10323
  }
@@ -9708,7 +10332,7 @@ function toConfigurationError8(filePath, error) {
9708
10332
  function createRecordsApi(command, filePath) {
9709
10333
  try {
9710
10334
  const config = readRuntimeConfig(filePath);
9711
- const runtime = resolveRuntimeContext(config, getGlobalOptions9(command));
10335
+ const runtime = resolveRuntimeContext(config, getGlobalOptions10(command));
9712
10336
  if (!runtime.baseUrl) {
9713
10337
  throw new CliError(
9714
10338
  "configuration_error",
@@ -9727,10 +10351,10 @@ function createRecordsApi(command, filePath) {
9727
10351
  readOnly: runtime.readOnly
9728
10352
  };
9729
10353
  } catch (error) {
9730
- toConfigurationError8(filePath, error);
10354
+ toConfigurationError9(filePath, error);
9731
10355
  }
9732
10356
  }
9733
- function ensureWritable6(commandName, readOnly, commandMode) {
10357
+ function ensureWritable7(commandName, readOnly, commandMode) {
9734
10358
  if (readOnly) {
9735
10359
  throw new CliError(
9736
10360
  "command_not_allowed_in_read_only_mode",
@@ -9742,24 +10366,24 @@ function ensureWritable6(commandName, readOnly, commandMode) {
9742
10366
  );
9743
10367
  }
9744
10368
  }
9745
- function parseUuidOrSlugSelector7(input) {
10369
+ function parseUuidOrSlugSelector8(input) {
9746
10370
  try {
9747
10371
  return normalizeUuidOrSlug(input);
9748
10372
  } catch (error) {
9749
10373
  const message = error instanceof Error ? error.message : "Invalid selector.";
9750
- throw new InvalidArgumentError7(message);
10374
+ throw new InvalidArgumentError8(message);
9751
10375
  }
9752
10376
  }
9753
10377
  function parseNonNegativeInteger2(input) {
9754
10378
  if (!/^\d+$/.test(input.trim())) {
9755
- throw new InvalidArgumentError7(`Expected a non-negative integer, received "${input}".`);
10379
+ throw new InvalidArgumentError8(`Expected a non-negative integer, received "${input}".`);
9756
10380
  }
9757
10381
  return Number(input);
9758
10382
  }
9759
10383
  function parseCommaSeparatedValues(input, label) {
9760
10384
  const values = input.split(",").map((value) => value.trim()).filter(Boolean);
9761
10385
  if (values.length === 0) {
9762
- throw new InvalidArgumentError7(`Expected ${label} to contain at least one value.`);
10386
+ throw new InvalidArgumentError8(`Expected ${label} to contain at least one value.`);
9763
10387
  }
9764
10388
  return values;
9765
10389
  }
@@ -9768,7 +10392,7 @@ function parseExpressionValue(input) {
9768
10392
  return parseExpression(input);
9769
10393
  } catch (error) {
9770
10394
  const message = error instanceof Error ? error.message : "Invalid expression.";
9771
- throw new InvalidArgumentError7(message);
10395
+ throw new InvalidArgumentError8(message);
9772
10396
  }
9773
10397
  }
9774
10398
  function parseKeyValueAssignment(input) {
@@ -9776,7 +10400,7 @@ function parseKeyValueAssignment(input) {
9776
10400
  return parseKeyValue(input);
9777
10401
  } catch (error) {
9778
10402
  const message = error instanceof Error ? error.message : "Invalid assignment.";
9779
- throw new InvalidArgumentError7(message);
10403
+ throw new InvalidArgumentError8(message);
9780
10404
  }
9781
10405
  }
9782
10406
  function parseJsonKeyValueAssignment(input) {
@@ -9784,7 +10408,7 @@ function parseJsonKeyValueAssignment(input) {
9784
10408
  return parseJsonAssignment(input);
9785
10409
  } catch (error) {
9786
10410
  const message = error instanceof Error ? error.message : "Invalid JSON assignment.";
9787
- throw new InvalidArgumentError7(message);
10411
+ throw new InvalidArgumentError8(message);
9788
10412
  }
9789
10413
  }
9790
10414
  function collectStringValues(value, previous = []) {
@@ -9802,7 +10426,7 @@ function collectKeyValueAssignments(value, previous = []) {
9802
10426
  function collectJsonAssignments(value, previous = []) {
9803
10427
  return [...previous, parseJsonKeyValueAssignment(value)];
9804
10428
  }
9805
- function isJsonObject5(value) {
10429
+ function isJsonObject6(value) {
9806
10430
  return typeof value === "object" && value !== null && !Array.isArray(value);
9807
10431
  }
9808
10432
  function parseRawJsonObject2(input, sourceLabel) {
@@ -9816,7 +10440,7 @@ function parseRawJsonObject2(input, sourceLabel) {
9816
10440
  `Failed to parse JSON from ${sourceLabel}: ${message}`
9817
10441
  );
9818
10442
  }
9819
- if (!isJsonObject5(parsed)) {
10443
+ if (!isJsonObject6(parsed)) {
9820
10444
  throw new CliError(
9821
10445
  "invalid_cli_usage",
9822
10446
  `Expected ${sourceLabel} to contain a JSON object.`
@@ -9837,7 +10461,7 @@ function readRawObject3(raw, rawFile) {
9837
10461
  if (rawFile) {
9838
10462
  let contents;
9839
10463
  try {
9840
- contents = readFileSync7(rawFile, "utf8");
10464
+ contents = readFileSync8(rawFile, "utf8");
9841
10465
  } catch (error) {
9842
10466
  const message = error instanceof Error ? error.message : "Unable to read file.";
9843
10467
  throw new CliError(
@@ -9849,7 +10473,7 @@ function readRawObject3(raw, rawFile) {
9849
10473
  }
9850
10474
  return {};
9851
10475
  }
9852
- function isEmptyObject4(value) {
10476
+ function isEmptyObject5(value) {
9853
10477
  return Object.keys(value).length === 0;
9854
10478
  }
9855
10479
  function buildAssignmentObject(assignments = [], jsonAssignments = []) {
@@ -9897,7 +10521,7 @@ function buildRecordCreateInput(options) {
9897
10521
  ...readRawObject3(options.raw, options.rawFile),
9898
10522
  ...buildAssignmentObject(options.set, options.setJson)
9899
10523
  };
9900
- if (isEmptyObject4(values)) {
10524
+ if (isEmptyObject5(values)) {
9901
10525
  throw new CliError(
9902
10526
  "invalid_cli_usage",
9903
10527
  'Provide record fields via "--set", "--set-json", "--raw", or "--raw-file".'
@@ -9910,7 +10534,7 @@ function readRawSetPayload2(raw) {
9910
10534
  if (setValue === void 0) {
9911
10535
  return {};
9912
10536
  }
9913
- if (!isJsonObject5(setValue)) {
10537
+ if (!isJsonObject6(setValue)) {
9914
10538
  throw new CliError(
9915
10539
  "invalid_cli_usage",
9916
10540
  'Expected raw update payload field "set" to be a JSON object.'
@@ -9955,7 +10579,7 @@ function buildRecordUpdateInput(options) {
9955
10579
  } else {
9956
10580
  delete input.unset;
9957
10581
  }
9958
- if (isEmptyObject4(input)) {
10582
+ if (isEmptyObject5(input)) {
9959
10583
  throw new CliError(
9960
10584
  "invalid_cli_usage",
9961
10585
  'Provide record updates via "--set", "--set-json", "--unset", "--raw", or "--raw-file".'
@@ -9965,9 +10589,9 @@ function buildRecordUpdateInput(options) {
9965
10589
  }
9966
10590
  function toTableRows4(data) {
9967
10591
  if (Array.isArray(data)) {
9968
- return data.map((entry) => isJsonObject5(entry) ? entry : { value: entry });
10592
+ return data.map((entry) => isJsonObject6(entry) ? entry : { value: entry });
9969
10593
  }
9970
- if (isJsonObject5(data)) {
10594
+ if (isJsonObject6(data)) {
9971
10595
  return [data];
9972
10596
  }
9973
10597
  return [{ value: data }];
@@ -9997,9 +10621,9 @@ async function resolveSchemaSelector(api, selector) {
9997
10621
  }
9998
10622
  function registerRecordsCommands(program, options = {}) {
9999
10623
  const filePath = options.configPath ?? defaultConfigPath;
10000
- const stdout = getCommandIo9(options.stdout);
10624
+ const stdout = getCommandIo10(options.stdout);
10001
10625
  const records = program.command("records").description("Manage schema records");
10002
- records.command("list").description("List records for a schema with simple pagination").argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector7).option("--limit <number>", "limit results", parseNonNegativeInteger2).option("--offset <number>", "offset results", parseNonNegativeInteger2).action(async function action(schema, commandOptions) {
10626
+ records.command("list").description("List records for a schema with simple pagination").argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector8).option("--limit <number>", "limit results", parseNonNegativeInteger2).option("--offset <number>", "offset results", parseNonNegativeInteger2).action(async function action(schema, commandOptions) {
10003
10627
  const { api, schemasApi, json } = createRecordsApi(this, filePath);
10004
10628
  const resolvedSchema = await resolveSchemaSelector(schemasApi, schema);
10005
10629
  const data = await api.listRecords(
@@ -10008,7 +10632,7 @@ function registerRecordsCommands(program, options = {}) {
10008
10632
  );
10009
10633
  const recordsData = getQueryRecords(data);
10010
10634
  if (json) {
10011
- emitJson9(
10635
+ emitJson10(
10012
10636
  stdout,
10013
10637
  "records list",
10014
10638
  recordsData,
@@ -10019,7 +10643,7 @@ function registerRecordsCommands(program, options = {}) {
10019
10643
  }
10020
10644
  emitTable4(stdout, recordsData);
10021
10645
  });
10022
- records.command("query").description("Query records for a schema").argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector7).option("--select <fields>", "comma-separated field selection", (value) => parseCommaSeparatedValues(value, "--select")).option("--where <expression>", "where expression", collectWhereExpressions, []).option("--sort <field:direction>", "sort field(s)", collectSortValues, []).option("--limit <number>", "limit results", parseNonNegativeInteger2).option("--offset <number>", "offset results", parseNonNegativeInteger2).option("--raw <json>", "raw JSON object payload").option("--raw-file <path>", "path to a raw JSON object payload").action(async function action(schema, commandOptions) {
10646
+ records.command("query").description("Query records for a schema").argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector8).option("--select <fields>", "comma-separated field selection", (value) => parseCommaSeparatedValues(value, "--select")).option("--where <expression>", "where expression", collectWhereExpressions, []).option("--sort <field:direction>", "sort field(s)", collectSortValues, []).option("--limit <number>", "limit results", parseNonNegativeInteger2).option("--offset <number>", "offset results", parseNonNegativeInteger2).option("--raw <json>", "raw JSON object payload").option("--raw-file <path>", "path to a raw JSON object payload").action(async function action(schema, commandOptions) {
10023
10647
  const { api, schemasApi, json } = createRecordsApi(this, filePath);
10024
10648
  const resolvedSchema = await resolveSchemaSelector(schemasApi, schema);
10025
10649
  const data = await api.queryRecords(
@@ -10028,7 +10652,7 @@ function registerRecordsCommands(program, options = {}) {
10028
10652
  );
10029
10653
  const recordsData = getQueryRecords(data);
10030
10654
  if (json) {
10031
- emitJson9(
10655
+ emitJson10(
10032
10656
  stdout,
10033
10657
  "records query",
10034
10658
  recordsData,
@@ -10039,33 +10663,33 @@ function registerRecordsCommands(program, options = {}) {
10039
10663
  }
10040
10664
  emitTable4(stdout, recordsData);
10041
10665
  });
10042
- records.command("get").description("Get a record by UUID or slug").argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector7).argument("<record>", "record uuid or slug", parseUuidOrSlugSelector7).action(async function action(schema, record) {
10666
+ records.command("get").description("Get a record by UUID or slug").argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector8).argument("<record>", "record uuid or slug", parseUuidOrSlugSelector8).action(async function action(schema, record) {
10043
10667
  const { api, schemasApi, json } = createRecordsApi(this, filePath);
10044
10668
  const resolvedSchema = await resolveSchemaSelector(schemasApi, schema);
10045
10669
  const data = await api.getRecord(resolvedSchema, record);
10046
10670
  if (json) {
10047
- emitJson9(stdout, "records get", data, filePath);
10671
+ emitJson10(stdout, "records get", data, filePath);
10048
10672
  return;
10049
10673
  }
10050
10674
  emitTable4(stdout, data);
10051
10675
  });
10052
- records.command("create").description("Create a record").argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector7).option("--set <field=value>", "set a string field", collectKeyValueAssignments, []).option("--set-json <field=json>", "set a structured field", collectJsonAssignments, []).option("--raw <json>", "raw JSON object payload").option("--raw-file <path>", "path to a raw JSON object payload").action(async function action(schema, commandOptions) {
10676
+ records.command("create").description("Create a record").argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector8).option("--set <field=value>", "set a string field", collectKeyValueAssignments, []).option("--set-json <field=json>", "set a structured field", collectJsonAssignments, []).option("--raw <json>", "raw JSON object payload").option("--raw-file <path>", "path to a raw JSON object payload").action(async function action(schema, commandOptions) {
10053
10677
  const { api, schemasApi, json, readOnly } = createRecordsApi(this, filePath);
10054
- ensureWritable6("records create", readOnly, "write");
10678
+ ensureWritable7("records create", readOnly, "write");
10055
10679
  const resolvedSchema = await resolveSchemaSelector(schemasApi, schema);
10056
10680
  const data = await api.createRecord(
10057
10681
  resolvedSchema,
10058
10682
  buildRecordCreateInput(commandOptions)
10059
10683
  );
10060
10684
  if (json) {
10061
- emitJson9(stdout, "records create", data, filePath);
10685
+ emitJson10(stdout, "records create", data, filePath);
10062
10686
  return;
10063
10687
  }
10064
- writeLine9(stdout, `Created record "${getRecordIdentifier(data)}".`);
10688
+ writeLine10(stdout, `Created record "${getRecordIdentifier(data)}".`);
10065
10689
  });
10066
- records.command("update").description("Update a record").argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector7).argument("<record>", "record uuid or slug", parseUuidOrSlugSelector7).option("--set <field=value>", "set a string field", collectKeyValueAssignments, []).option("--set-json <field=json>", "set a structured field", collectJsonAssignments, []).option("--unset <field>", "unset a field", collectStringValues, []).option("--raw <json>", "raw JSON object payload").option("--raw-file <path>", "path to a raw JSON object payload").action(async function action(schema, record, commandOptions) {
10690
+ records.command("update").description("Update a record").argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector8).argument("<record>", "record uuid or slug", parseUuidOrSlugSelector8).option("--set <field=value>", "set a string field", collectKeyValueAssignments, []).option("--set-json <field=json>", "set a structured field", collectJsonAssignments, []).option("--unset <field>", "unset a field", collectStringValues, []).option("--raw <json>", "raw JSON object payload").option("--raw-file <path>", "path to a raw JSON object payload").action(async function action(schema, record, commandOptions) {
10067
10691
  const { api, schemasApi, json, readOnly } = createRecordsApi(this, filePath);
10068
- ensureWritable6("records update", readOnly, "write");
10692
+ ensureWritable7("records update", readOnly, "write");
10069
10693
  const resolvedSchema = await resolveSchemaSelector(schemasApi, schema);
10070
10694
  const data = await api.updateRecord(
10071
10695
  resolvedSchema,
@@ -10073,14 +10697,14 @@ function registerRecordsCommands(program, options = {}) {
10073
10697
  buildRecordUpdateInput(commandOptions)
10074
10698
  );
10075
10699
  if (json) {
10076
- emitJson9(stdout, "records update", data, filePath);
10700
+ emitJson10(stdout, "records update", data, filePath);
10077
10701
  return;
10078
10702
  }
10079
- writeLine9(stdout, `Updated record "${getRecordIdentifier(data)}".`);
10703
+ writeLine10(stdout, `Updated record "${getRecordIdentifier(data)}".`);
10080
10704
  });
10081
- records.command("delete").description("Delete a record").argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector7).argument("<record>", "record uuid or slug", parseUuidOrSlugSelector7).action(async function action(schema, record) {
10705
+ records.command("delete").description("Delete a record").argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector8).argument("<record>", "record uuid or slug", parseUuidOrSlugSelector8).action(async function action(schema, record) {
10082
10706
  const { api, schemasApi, json, readOnly } = createRecordsApi(this, filePath);
10083
- ensureWritable6("records delete", readOnly, "destructive");
10707
+ ensureWritable7("records delete", readOnly, "destructive");
10084
10708
  const resolvedSchema = await resolveSchemaSelector(schemasApi, schema);
10085
10709
  await api.deleteRecord(resolvedSchema, record);
10086
10710
  const data = {
@@ -10089,44 +10713,44 @@ function registerRecordsCommands(program, options = {}) {
10089
10713
  deleted: true
10090
10714
  };
10091
10715
  if (json) {
10092
- emitJson9(stdout, "records delete", data, filePath);
10716
+ emitJson10(stdout, "records delete", data, filePath);
10093
10717
  return;
10094
10718
  }
10095
- writeLine9(stdout, `Deleted record "${record.value}" from schema "${schema.value}".`);
10719
+ writeLine10(stdout, `Deleted record "${record.value}" from schema "${schema.value}".`);
10096
10720
  });
10097
- records.command("clear").description("Delete all records from a schema's table").argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector7).action(async function action(schema) {
10721
+ records.command("clear").description("Delete all records from a schema's table").argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector8).action(async function action(schema) {
10098
10722
  const { api, schemasApi, json, readOnly } = createRecordsApi(this, filePath);
10099
- ensureWritable6("records clear", readOnly, "destructive");
10723
+ ensureWritable7("records clear", readOnly, "destructive");
10100
10724
  const resolvedSchema = await resolveSchemaSelector(schemasApi, schema);
10101
10725
  const data = await api.clearRecords(resolvedSchema);
10102
10726
  if (json) {
10103
- emitJson9(stdout, "records clear", data, filePath);
10727
+ emitJson10(stdout, "records clear", data, filePath);
10104
10728
  return;
10105
10729
  }
10106
- writeLine9(stdout, `Cleared all records from schema "${schema.value}".`);
10730
+ writeLine10(stdout, `Cleared all records from schema "${schema.value}".`);
10107
10731
  });
10108
10732
  }
10109
10733
 
10110
10734
  // src/commands/schemas.ts
10111
- import { readFileSync as readFileSync8 } from "fs";
10112
- import { InvalidArgumentError as InvalidArgumentError8 } from "commander";
10113
- function getCommandIo10(stdout) {
10735
+ import { readFileSync as readFileSync9 } from "fs";
10736
+ import { InvalidArgumentError as InvalidArgumentError9 } from "commander";
10737
+ function getCommandIo11(stdout) {
10114
10738
  return stdout ?? process.stdout;
10115
10739
  }
10116
- function writeLine10(stdout, value) {
10740
+ function writeLine11(stdout, value) {
10117
10741
  stdout.write(`${value}
10118
10742
  `);
10119
10743
  }
10120
- function getGlobalOptions10(command) {
10744
+ function getGlobalOptions11(command) {
10121
10745
  return command.optsWithGlobals();
10122
10746
  }
10123
- function emitJson10(stdout, commandName, data, configPath) {
10124
- writeLine10(
10747
+ function emitJson11(stdout, commandName, data, configPath) {
10748
+ writeLine11(
10125
10749
  stdout,
10126
10750
  JSON.stringify(buildJsonSuccess(data, { command: commandName, configPath }))
10127
10751
  );
10128
10752
  }
10129
- function toConfigurationError9(filePath, error) {
10753
+ function toConfigurationError10(filePath, error) {
10130
10754
  if (error instanceof CliError) {
10131
10755
  throw error;
10132
10756
  }
@@ -10141,7 +10765,7 @@ function toConfigurationError9(filePath, error) {
10141
10765
  function createSchemasApi(command, filePath) {
10142
10766
  try {
10143
10767
  const config = readRuntimeConfig(filePath);
10144
- const runtime = resolveRuntimeContext(config, getGlobalOptions10(command));
10768
+ const runtime = resolveRuntimeContext(config, getGlobalOptions11(command));
10145
10769
  if (!runtime.baseUrl) {
10146
10770
  throw new CliError(
10147
10771
  "configuration_error",
@@ -10160,10 +10784,10 @@ function createSchemasApi(command, filePath) {
10160
10784
  readOnly: runtime.readOnly
10161
10785
  };
10162
10786
  } catch (error) {
10163
- toConfigurationError9(filePath, error);
10787
+ toConfigurationError10(filePath, error);
10164
10788
  }
10165
10789
  }
10166
- function ensureWritable7(commandName, readOnly, commandMode) {
10790
+ function ensureWritable8(commandName, readOnly, commandMode) {
10167
10791
  if (readOnly) {
10168
10792
  throw new CliError(
10169
10793
  "command_not_allowed_in_read_only_mode",
@@ -10175,12 +10799,12 @@ function ensureWritable7(commandName, readOnly, commandMode) {
10175
10799
  );
10176
10800
  }
10177
10801
  }
10178
- function parseUuidOrSlugSelector8(input) {
10802
+ function parseUuidOrSlugSelector9(input) {
10179
10803
  try {
10180
10804
  return normalizeUuidOrSlug(input);
10181
10805
  } catch (error) {
10182
10806
  const message = error instanceof Error ? error.message : "Invalid selector.";
10183
- throw new InvalidArgumentError8(message);
10807
+ throw new InvalidArgumentError9(message);
10184
10808
  }
10185
10809
  }
10186
10810
  function parseBooleanFlag(input) {
@@ -10191,9 +10815,9 @@ function parseBooleanFlag(input) {
10191
10815
  if (["false", "0", "no", "n", "off"].includes(normalized)) {
10192
10816
  return false;
10193
10817
  }
10194
- throw new InvalidArgumentError8(`Expected a boolean value, received "${input}".`);
10818
+ throw new InvalidArgumentError9(`Expected a boolean value, received "${input}".`);
10195
10819
  }
10196
- function isJsonObject6(value) {
10820
+ function isJsonObject7(value) {
10197
10821
  return typeof value === "object" && value !== null && !Array.isArray(value);
10198
10822
  }
10199
10823
  function parseRawJsonObject3(input, sourceLabel) {
@@ -10207,7 +10831,7 @@ function parseRawJsonObject3(input, sourceLabel) {
10207
10831
  `Failed to parse JSON from ${sourceLabel}: ${message}`
10208
10832
  );
10209
10833
  }
10210
- if (!isJsonObject6(parsed)) {
10834
+ if (!isJsonObject7(parsed)) {
10211
10835
  throw new CliError(
10212
10836
  "invalid_cli_usage",
10213
10837
  `Expected ${sourceLabel} to contain a JSON object.`
@@ -10228,7 +10852,7 @@ function readRawObject4(raw, rawFile) {
10228
10852
  if (rawFile) {
10229
10853
  let contents;
10230
10854
  try {
10231
- contents = readFileSync8(rawFile, "utf8");
10855
+ contents = readFileSync9(rawFile, "utf8");
10232
10856
  } catch (error) {
10233
10857
  const message = error instanceof Error ? error.message : "Unable to read file.";
10234
10858
  throw new CliError(
@@ -10287,7 +10911,7 @@ function applyFieldDefaultValue(input, defaultValue) {
10287
10911
  return;
10288
10912
  }
10289
10913
  const config = input.config;
10290
- if (config !== void 0 && !isJsonObject6(config)) {
10914
+ if (config !== void 0 && !isJsonObject7(config)) {
10291
10915
  throw new CliError(
10292
10916
  "invalid_cli_usage",
10293
10917
  'Expected field "config" to be a JSON object when using "--default".'
@@ -10327,7 +10951,7 @@ function buildFieldCreateInput(options) {
10327
10951
  input.required = options.required;
10328
10952
  }
10329
10953
  applyFieldDefaultValue(input, options.default);
10330
- if ("config" in input && isJsonObject6(input.config) && isEmptyObject5(input.config)) {
10954
+ if ("config" in input && isJsonObject7(input.config) && isEmptyObject6(input.config)) {
10331
10955
  delete input.config;
10332
10956
  }
10333
10957
  return input;
@@ -10400,35 +11024,35 @@ async function resolveFieldSelector(api, schema, selector) {
10400
11024
  value: match.id
10401
11025
  };
10402
11026
  }
10403
- function isEmptyObject5(value) {
11027
+ function isEmptyObject6(value) {
10404
11028
  return Object.keys(value).length === 0;
10405
11029
  }
10406
11030
  function registerSchemasCommands(program, options = {}) {
10407
11031
  const filePath = options.configPath ?? defaultConfigPath;
10408
- const stdout = getCommandIo10(options.stdout);
11032
+ const stdout = getCommandIo11(options.stdout);
10409
11033
  const schemas = program.command("schemas").description("Manage schemas and schema fields");
10410
11034
  schemas.command("list").description("List schemas").action(async function action() {
10411
11035
  const { api, json } = createSchemasApi(this, filePath);
10412
11036
  const data = await api.listSchemas();
10413
11037
  if (json) {
10414
- emitJson10(stdout, "schemas list", data, filePath);
11038
+ emitJson11(stdout, "schemas list", data, filePath);
10415
11039
  return;
10416
11040
  }
10417
11041
  emitSchemasTable(stdout, data);
10418
11042
  });
10419
- schemas.command("get").description("Get a schema by UUID or slug").argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector8).action(async function action(schema) {
11043
+ schemas.command("get").description("Get a schema by UUID or slug").argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector9).action(async function action(schema) {
10420
11044
  const { api, json } = createSchemasApi(this, filePath);
10421
11045
  const resolvedSchema = await resolveSchemaSelector2(api, schema);
10422
11046
  const data = await api.getSchema(resolvedSchema);
10423
11047
  if (json) {
10424
- emitJson10(stdout, "schemas get", data, filePath);
11048
+ emitJson11(stdout, "schemas get", data, filePath);
10425
11049
  return;
10426
11050
  }
10427
11051
  emitSchemasTable(stdout, [data]);
10428
11052
  });
10429
11053
  schemas.command("create").description("Create a schema").requiredOption("--name <name>", "schema name").requiredOption("--slug <slug>", "schema slug").option("--auditable", "mark schema as auditable").option("--commentable", "mark schema as commentable").action(async function action(commandOptions) {
10430
11054
  const { api, json, readOnly } = createSchemasApi(this, filePath);
10431
- ensureWritable7("schemas create", readOnly, "write");
11055
+ ensureWritable8("schemas create", readOnly, "write");
10432
11056
  const input = {
10433
11057
  name: commandOptions.name,
10434
11058
  slug: commandOptions.slug,
@@ -10437,17 +11061,17 @@ function registerSchemasCommands(program, options = {}) {
10437
11061
  };
10438
11062
  const data = await api.createSchema(input);
10439
11063
  if (json) {
10440
- emitJson10(stdout, "schemas create", data, filePath);
11064
+ emitJson11(stdout, "schemas create", data, filePath);
10441
11065
  return;
10442
11066
  }
10443
- writeLine10(stdout, `Created schema "${data.slug ?? commandOptions.slug}".`);
11067
+ writeLine11(stdout, `Created schema "${data.slug ?? commandOptions.slug}".`);
10444
11068
  });
10445
- schemas.command("update").description("Update a schema").argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector8).option("--name <name>", "schema name").option("--slug <slug>", "schema slug").option("--auditable <bool>", "auditable flag", parseBooleanFlag).option("--commentable <bool>", "commentable flag", parseBooleanFlag).action(async function action(schema, commandOptions) {
11069
+ schemas.command("update").description("Update a schema").argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector9).option("--name <name>", "schema name").option("--slug <slug>", "schema slug").option("--auditable <bool>", "auditable flag", parseBooleanFlag).option("--commentable <bool>", "commentable flag", parseBooleanFlag).action(async function action(schema, commandOptions) {
10446
11070
  const { api, json, readOnly } = createSchemasApi(this, filePath);
10447
- ensureWritable7("schemas update", readOnly, "write");
11071
+ ensureWritable8("schemas update", readOnly, "write");
10448
11072
  const resolvedSchema = await resolveSchemaSelector2(api, schema);
10449
11073
  const input = buildSchemaUpdateInput(commandOptions);
10450
- if (isEmptyObject5(input)) {
11074
+ if (isEmptyObject6(input)) {
10451
11075
  throw new CliError(
10452
11076
  "invalid_cli_usage",
10453
11077
  'Provide at least one schema field to update via "--name", "--slug", "--auditable", or "--commentable".'
@@ -10455,14 +11079,14 @@ function registerSchemasCommands(program, options = {}) {
10455
11079
  }
10456
11080
  const data = await api.updateSchema(resolvedSchema, input);
10457
11081
  if (json) {
10458
- emitJson10(stdout, "schemas update", data, filePath);
11082
+ emitJson11(stdout, "schemas update", data, filePath);
10459
11083
  return;
10460
11084
  }
10461
- writeLine10(stdout, `Updated schema "${data.slug ?? schema.value}".`);
11085
+ writeLine11(stdout, `Updated schema "${data.slug ?? schema.value}".`);
10462
11086
  });
10463
- schemas.command("delete").description("Delete a schema").argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector8).action(async function action(schema) {
11087
+ schemas.command("delete").description("Delete a schema").argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector9).action(async function action(schema) {
10464
11088
  const { api, json, readOnly } = createSchemasApi(this, filePath);
10465
- ensureWritable7("schemas delete", readOnly, "destructive");
11089
+ ensureWritable8("schemas delete", readOnly, "destructive");
10466
11090
  const resolvedSchema = await resolveSchemaSelector2(api, schema);
10467
11091
  await api.deleteSchema(resolvedSchema);
10468
11092
  const data = {
@@ -10470,36 +11094,36 @@ function registerSchemasCommands(program, options = {}) {
10470
11094
  deleted: true
10471
11095
  };
10472
11096
  if (json) {
10473
- emitJson10(stdout, "schemas delete", data, filePath);
11097
+ emitJson11(stdout, "schemas delete", data, filePath);
10474
11098
  return;
10475
11099
  }
10476
- writeLine10(stdout, `Deleted schema "${schema.value}".`);
11100
+ writeLine11(stdout, `Deleted schema "${schema.value}".`);
10477
11101
  });
10478
11102
  const fields = schemas.command("fields").description("Manage schema fields");
10479
- fields.command("list").description("List fields for a schema").argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector8).action(async function action(schema) {
11103
+ fields.command("list").description("List fields for a schema").argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector9).action(async function action(schema) {
10480
11104
  const { api, json } = createSchemasApi(this, filePath);
10481
11105
  const resolvedSchema = await resolveSchemaSelector2(api, schema);
10482
11106
  const data = await api.listFields(resolvedSchema);
10483
11107
  if (json) {
10484
- emitJson10(stdout, "schemas fields list", data, filePath);
11108
+ emitJson11(stdout, "schemas fields list", data, filePath);
10485
11109
  return;
10486
11110
  }
10487
11111
  emitFieldsTable(stdout, data);
10488
11112
  });
10489
- fields.command("get").description("Get a field by UUID or slug").argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector8).argument("<field>", "field uuid or slug", parseUuidOrSlugSelector8).action(async function action(schema, field) {
11113
+ fields.command("get").description("Get a field by UUID or slug").argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector9).argument("<field>", "field uuid or slug", parseUuidOrSlugSelector9).action(async function action(schema, field) {
10490
11114
  const { api, json } = createSchemasApi(this, filePath);
10491
11115
  const resolvedSchema = await resolveSchemaSelector2(api, schema);
10492
11116
  const resolvedField = await resolveFieldSelector(api, resolvedSchema, field);
10493
11117
  const data = await api.getField(resolvedSchema, resolvedField);
10494
11118
  if (json) {
10495
- emitJson10(stdout, "schemas fields get", data, filePath);
11119
+ emitJson11(stdout, "schemas fields get", data, filePath);
10496
11120
  return;
10497
11121
  }
10498
11122
  emitFieldsTable(stdout, [data]);
10499
11123
  });
10500
- fields.command("create").description(`Create a field in a schema.${buildSchemaFieldCreateHelpText()}`).argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector8).option("--type <type>", `field type (${formatSchemaFieldTypes()})`).option("--slug <slug>", "field slug").option("--label <label>", "field label").option("--required <bool>", "required flag", parseBooleanFlag).option("--default <value>", "default field value").option("--raw <json>", "raw JSON object payload (see type-specific shapes in --help)").option("--raw-file <path>", "path to a raw JSON object payload").action(async function action(schema, commandOptions) {
11124
+ fields.command("create").description(`Create a field in a schema.${buildSchemaFieldCreateHelpText()}`).argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector9).option("--type <type>", `field type (${formatSchemaFieldTypes()})`).option("--slug <slug>", "field slug").option("--label <label>", "field label").option("--required <bool>", "required flag", parseBooleanFlag).option("--default <value>", "default field value").option("--raw <json>", "raw JSON object payload (see type-specific shapes in --help)").option("--raw-file <path>", "path to a raw JSON object payload").action(async function action(schema, commandOptions) {
10501
11125
  const { api, json, readOnly } = createSchemasApi(this, filePath);
10502
- ensureWritable7("schemas fields create", readOnly, "write");
11126
+ ensureWritable8("schemas fields create", readOnly, "write");
10503
11127
  const input = buildFieldCreateInput(commandOptions);
10504
11128
  const resolvedSchema = await resolveSchemaSelector2(api, schema);
10505
11129
  let data;
@@ -10509,14 +11133,14 @@ function registerSchemasCommands(program, options = {}) {
10509
11133
  toFieldCreateError(error, input);
10510
11134
  }
10511
11135
  if (json) {
10512
- emitJson10(stdout, "schemas fields create", data, filePath);
11136
+ emitJson11(stdout, "schemas fields create", data, filePath);
10513
11137
  return;
10514
11138
  }
10515
- writeLine10(stdout, `Created field "${data.slug ?? commandOptions.slug}".`);
11139
+ writeLine11(stdout, `Created field "${data.slug ?? commandOptions.slug}".`);
10516
11140
  });
10517
- fields.command("update").description("Update a field in a schema").argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector8).argument("<field>", "field uuid or slug", parseUuidOrSlugSelector8).option("--label <label>", "field label").option("--required <bool>", "required flag", parseBooleanFlag).option("--default <value>", "default field value").option("--raw <json>", "raw JSON object payload").option("--raw-file <path>", "path to a raw JSON object payload").action(async function action(schema, field, commandOptions) {
11141
+ fields.command("update").description("Update a field in a schema").argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector9).argument("<field>", "field uuid or slug", parseUuidOrSlugSelector9).option("--label <label>", "field label").option("--required <bool>", "required flag", parseBooleanFlag).option("--default <value>", "default field value").option("--raw <json>", "raw JSON object payload").option("--raw-file <path>", "path to a raw JSON object payload").action(async function action(schema, field, commandOptions) {
10518
11142
  const { api, json, readOnly } = createSchemasApi(this, filePath);
10519
- ensureWritable7("schemas fields update", readOnly, "write");
11143
+ ensureWritable8("schemas fields update", readOnly, "write");
10520
11144
  const resolvedSchema = await resolveSchemaSelector2(api, schema);
10521
11145
  const resolvedField = await resolveFieldSelector(api, resolvedSchema, field);
10522
11146
  const currentField = await api.getField(resolvedSchema, resolvedField);
@@ -10525,7 +11149,7 @@ function registerSchemasCommands(program, options = {}) {
10525
11149
  throw new CliError("invalid_cli_usage", `Field "${field.value}" is missing type metadata.`);
10526
11150
  }
10527
11151
  const input = buildFieldUpdateInput(currentType, commandOptions);
10528
- if (isEmptyObject5(input)) {
11152
+ if (isEmptyObject6(input)) {
10529
11153
  throw new CliError(
10530
11154
  "invalid_cli_usage",
10531
11155
  'Provide at least one field update via "--label", "--required", "--raw", or "--raw-file".'
@@ -10533,14 +11157,14 @@ function registerSchemasCommands(program, options = {}) {
10533
11157
  }
10534
11158
  const data = await api.updateField(resolvedSchema, resolvedField, input);
10535
11159
  if (json) {
10536
- emitJson10(stdout, "schemas fields update", data, filePath);
11160
+ emitJson11(stdout, "schemas fields update", data, filePath);
10537
11161
  return;
10538
11162
  }
10539
- writeLine10(stdout, `Updated field "${data.slug ?? field.value}".`);
11163
+ writeLine11(stdout, `Updated field "${data.slug ?? field.value}".`);
10540
11164
  });
10541
- fields.command("delete").description("Delete a field from a schema").argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector8).argument("<field>", "field uuid or slug", parseUuidOrSlugSelector8).action(async function action(schema, field) {
11165
+ fields.command("delete").description("Delete a field from a schema").argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector9).argument("<field>", "field uuid or slug", parseUuidOrSlugSelector9).action(async function action(schema, field) {
10542
11166
  const { api, json, readOnly } = createSchemasApi(this, filePath);
10543
- ensureWritable7("schemas fields delete", readOnly, "destructive");
11167
+ ensureWritable8("schemas fields delete", readOnly, "destructive");
10544
11168
  const resolvedSchema = await resolveSchemaSelector2(api, schema);
10545
11169
  const resolvedField = await resolveFieldSelector(api, resolvedSchema, field);
10546
11170
  await api.deleteField(resolvedSchema, resolvedField);
@@ -10550,19 +11174,19 @@ function registerSchemasCommands(program, options = {}) {
10550
11174
  deleted: true
10551
11175
  };
10552
11176
  if (json) {
10553
- emitJson10(stdout, "schemas fields delete", data, filePath);
11177
+ emitJson11(stdout, "schemas fields delete", data, filePath);
10554
11178
  return;
10555
11179
  }
10556
- writeLine10(stdout, `Deleted field "${field.value}" from schema "${schema.value}".`);
11180
+ writeLine11(stdout, `Deleted field "${field.value}" from schema "${schema.value}".`);
10557
11181
  });
10558
11182
  }
10559
11183
 
10560
11184
  // src/commands/teamspace.ts
10561
- import { readFileSync as readFileSync9 } from "fs";
10562
- import { InvalidArgumentError as InvalidArgumentError9 } from "commander";
11185
+ import { readFileSync as readFileSync10 } from "fs";
11186
+ import { InvalidArgumentError as InvalidArgumentError10 } from "commander";
10563
11187
 
10564
11188
  // src/api/teamspace.ts
10565
- function jsonOptions7(body, method) {
11189
+ function jsonOptions8(body, method) {
10566
11190
  return {
10567
11191
  method,
10568
11192
  headers: {
@@ -10571,7 +11195,7 @@ function jsonOptions7(body, method) {
10571
11195
  body: JSON.stringify(body)
10572
11196
  };
10573
11197
  }
10574
- function selectorValue9(selector) {
11198
+ function selectorValue10(selector) {
10575
11199
  return selector.value;
10576
11200
  }
10577
11201
  var TeamspaceApi = class {
@@ -10592,53 +11216,53 @@ var TeamspaceApi = class {
10592
11216
  createFolder(input) {
10593
11217
  return this.client.requestJson(
10594
11218
  "/api/v2/teamspaces/folders",
10595
- jsonOptions7(input, "POST")
11219
+ jsonOptions8(input, "POST")
10596
11220
  );
10597
11221
  }
10598
11222
  updateFolder(folder, input) {
10599
11223
  return this.client.requestJson(
10600
- `/api/v2/teamspaces/folders/${selectorValue9(folder)}`,
10601
- jsonOptions7(input, "PATCH")
11224
+ `/api/v2/teamspaces/folders/${selectorValue10(folder)}`,
11225
+ jsonOptions8(input, "PATCH")
10602
11226
  );
10603
11227
  }
10604
11228
  deleteFolder(folder) {
10605
11229
  return this.client.requestJson(
10606
- `/api/v2/teamspaces/folders/${selectorValue9(folder)}`,
11230
+ `/api/v2/teamspaces/folders/${selectorValue10(folder)}`,
10607
11231
  { method: "DELETE" }
10608
11232
  );
10609
11233
  }
10610
11234
  publishResource(input) {
10611
11235
  return this.client.requestJson(
10612
11236
  "/api/v2/teamspaces/resources:publish",
10613
- jsonOptions7(input, "POST")
11237
+ jsonOptions8(input, "POST")
10614
11238
  );
10615
11239
  }
10616
11240
  unpublishResource(resourceId) {
10617
11241
  return this.client.requestJson(
10618
11242
  "/api/v2/teamspaces/resources:unpublish",
10619
- jsonOptions7({ resourceId }, "POST")
11243
+ jsonOptions8({ resourceId }, "POST")
10620
11244
  );
10621
11245
  }
10622
11246
  };
10623
11247
 
10624
11248
  // src/commands/teamspace.ts
10625
- function getCommandIo11(stdout) {
11249
+ function getCommandIo12(stdout) {
10626
11250
  return stdout ?? process.stdout;
10627
11251
  }
10628
- function writeLine11(stdout, value) {
11252
+ function writeLine12(stdout, value) {
10629
11253
  stdout.write(`${value}
10630
11254
  `);
10631
11255
  }
10632
- function getGlobalOptions11(command) {
11256
+ function getGlobalOptions12(command) {
10633
11257
  return command.optsWithGlobals();
10634
11258
  }
10635
- function emitJson11(stdout, commandName, data, configPath) {
10636
- writeLine11(
11259
+ function emitJson12(stdout, commandName, data, configPath) {
11260
+ writeLine12(
10637
11261
  stdout,
10638
11262
  JSON.stringify(buildJsonSuccess(data, { command: commandName, configPath }))
10639
11263
  );
10640
11264
  }
10641
- function toConfigurationError10(filePath, error) {
11265
+ function toConfigurationError11(filePath, error) {
10642
11266
  if (error instanceof CliError) {
10643
11267
  throw error;
10644
11268
  }
@@ -10653,7 +11277,7 @@ function toConfigurationError10(filePath, error) {
10653
11277
  function createTeamspaceApi(command, filePath) {
10654
11278
  try {
10655
11279
  const config = readRuntimeConfig(filePath);
10656
- const runtime = resolveRuntimeContext(config, getGlobalOptions11(command));
11280
+ const runtime = resolveRuntimeContext(config, getGlobalOptions12(command));
10657
11281
  if (!runtime.baseUrl) {
10658
11282
  throw new CliError(
10659
11283
  "configuration_error",
@@ -10671,10 +11295,10 @@ function createTeamspaceApi(command, filePath) {
10671
11295
  readOnly: runtime.readOnly
10672
11296
  };
10673
11297
  } catch (error) {
10674
- toConfigurationError10(filePath, error);
11298
+ toConfigurationError11(filePath, error);
10675
11299
  }
10676
11300
  }
10677
- function ensureWritable8(commandName, readOnly, commandMode) {
11301
+ function ensureWritable9(commandName, readOnly, commandMode) {
10678
11302
  if (readOnly) {
10679
11303
  throw new CliError(
10680
11304
  "command_not_allowed_in_read_only_mode",
@@ -10686,21 +11310,21 @@ function ensureWritable8(commandName, readOnly, commandMode) {
10686
11310
  );
10687
11311
  }
10688
11312
  }
10689
- function parseUuidOrSlugSelector9(input) {
11313
+ function parseUuidOrSlugSelector10(input) {
10690
11314
  try {
10691
11315
  return normalizeUuidOrSlug(input);
10692
11316
  } catch (error) {
10693
11317
  const message = error instanceof Error ? error.message : "Invalid selector.";
10694
- throw new InvalidArgumentError9(message);
11318
+ throw new InvalidArgumentError10(message);
10695
11319
  }
10696
11320
  }
10697
11321
  function parseNonNegativeInteger3(input) {
10698
11322
  if (!/^\d+$/.test(input.trim())) {
10699
- throw new InvalidArgumentError9(`Expected a non-negative integer, received "${input}".`);
11323
+ throw new InvalidArgumentError10(`Expected a non-negative integer, received "${input}".`);
10700
11324
  }
10701
11325
  return Number(input);
10702
11326
  }
10703
- function isJsonObject7(value) {
11327
+ function isJsonObject8(value) {
10704
11328
  return typeof value === "object" && value !== null && !Array.isArray(value);
10705
11329
  }
10706
11330
  function parseRawJsonObject4(input, sourceLabel) {
@@ -10714,7 +11338,7 @@ function parseRawJsonObject4(input, sourceLabel) {
10714
11338
  `Failed to parse JSON from ${sourceLabel}: ${message}`
10715
11339
  );
10716
11340
  }
10717
- if (!isJsonObject7(parsed)) {
11341
+ if (!isJsonObject8(parsed)) {
10718
11342
  throw new CliError(
10719
11343
  "invalid_cli_usage",
10720
11344
  `Expected ${sourceLabel} to contain a JSON object.`
@@ -10735,7 +11359,7 @@ function readRawObject5(raw, rawFile) {
10735
11359
  if (rawFile) {
10736
11360
  let contents;
10737
11361
  try {
10738
- contents = readFileSync9(rawFile, "utf8");
11362
+ contents = readFileSync10(rawFile, "utf8");
10739
11363
  } catch (error) {
10740
11364
  const message = error instanceof Error ? error.message : "Unable to read file.";
10741
11365
  throw new CliError(
@@ -10747,7 +11371,7 @@ function readRawObject5(raw, rawFile) {
10747
11371
  }
10748
11372
  return void 0;
10749
11373
  }
10750
- function isEmptyObject6(value) {
11374
+ function isEmptyObject7(value) {
10751
11375
  return Object.keys(value).length === 0;
10752
11376
  }
10753
11377
  function buildFolderCreateInput(options) {
@@ -10778,7 +11402,7 @@ function buildFolderUpdateInput(options) {
10778
11402
  if (props !== void 0) {
10779
11403
  input.additionalProperties = props;
10780
11404
  }
10781
- if (isEmptyObject6(input)) {
11405
+ if (isEmptyObject7(input)) {
10782
11406
  throw new CliError(
10783
11407
  "invalid_cli_usage",
10784
11408
  'Provide folder updates via "--name", "--order", "--props", or "--props-file".'
@@ -10788,9 +11412,9 @@ function buildFolderUpdateInput(options) {
10788
11412
  }
10789
11413
  function toTableRows5(data) {
10790
11414
  if (Array.isArray(data)) {
10791
- return data.map((entry) => isJsonObject7(entry) ? entry : { value: entry });
11415
+ return data.map((entry) => isJsonObject8(entry) ? entry : { value: entry });
10792
11416
  }
10793
- if (isJsonObject7(data)) {
11417
+ if (isJsonObject8(data)) {
10794
11418
  return [data];
10795
11419
  }
10796
11420
  return [{ value: data }];
@@ -10852,85 +11476,85 @@ async function resolveFolderSelector2(api, selector) {
10852
11476
  }
10853
11477
  function registerTeamspaceCommands(program, options = {}) {
10854
11478
  const filePath = options.configPath ?? defaultConfigPath;
10855
- const stdout = getCommandIo11(options.stdout);
11479
+ const stdout = getCommandIo12(options.stdout);
10856
11480
  const teamspace = program.command("teamspace").description("Manage teamspace folders and resources");
10857
11481
  const folders = teamspace.command("folders").description("Manage teamspace folders");
10858
11482
  folders.command("list").description("List teamspace folders").option("--include-resources", "include nested resources").action(async function action(commandOptions) {
10859
11483
  const { api, json } = createTeamspaceApi(this, filePath);
10860
11484
  const data = await api.listFolders(Boolean(commandOptions.includeResources));
10861
11485
  if (json) {
10862
- emitJson11(stdout, "teamspace folders list", data, filePath);
11486
+ emitJson12(stdout, "teamspace folders list", data, filePath);
10863
11487
  return;
10864
11488
  }
10865
11489
  emitTable5(stdout, data);
10866
11490
  });
10867
- folders.command("get").description("Get a teamspace folder by exact name or UUID").argument("<folder>", "folder UUID or exact name", parseUuidOrSlugSelector9).option("--include-resources", "include nested resources").action(async function action(folder, commandOptions) {
11491
+ folders.command("get").description("Get a teamspace folder by exact name or UUID").argument("<folder>", "folder UUID or exact name", parseUuidOrSlugSelector10).option("--include-resources", "include nested resources").action(async function action(folder, commandOptions) {
10868
11492
  const { api, json } = createTeamspaceApi(this, filePath);
10869
11493
  const resolvedFolder = await resolveFolderSelector2(api, folder);
10870
11494
  const allFolders = await api.listFolders(Boolean(commandOptions.includeResources));
10871
11495
  const data = findFolderEntity(allFolders, resolvedFolder);
10872
11496
  if (json) {
10873
- emitJson11(stdout, "teamspace folders get", data, filePath);
11497
+ emitJson12(stdout, "teamspace folders get", data, filePath);
10874
11498
  return;
10875
11499
  }
10876
11500
  emitTable5(stdout, data);
10877
11501
  });
10878
11502
  folders.command("create").description("Create a teamspace folder").requiredOption("--name <name>", "folder name").option("--order <n>", "folder order", parseNonNegativeInteger3).option("--props <json>", "folder properties payload").option("--props-file <path>", "path to a folder properties JSON payload").action(async function action(commandOptions) {
10879
11503
  const { api, json, readOnly } = createTeamspaceApi(this, filePath);
10880
- ensureWritable8("teamspace folders create", readOnly, "write");
11504
+ ensureWritable9("teamspace folders create", readOnly, "write");
10881
11505
  const data = await api.createFolder(buildFolderCreateInput(commandOptions));
10882
11506
  if (json) {
10883
- emitJson11(stdout, "teamspace folders create", data, filePath);
11507
+ emitJson12(stdout, "teamspace folders create", data, filePath);
10884
11508
  return;
10885
11509
  }
10886
- writeLine11(stdout, `Created folder "${getFolderIdentifier(data)}".`);
11510
+ writeLine12(stdout, `Created folder "${getFolderIdentifier(data)}".`);
10887
11511
  });
10888
- folders.command("update").description("Update a teamspace folder").argument("<folder>", "folder UUID or exact name", parseUuidOrSlugSelector9).option("--name <name>", "folder name").option("--order <n>", "folder order", parseNonNegativeInteger3).option("--props <json>", "folder properties payload").option("--props-file <path>", "path to a folder properties JSON payload").action(async function action(folder, commandOptions) {
11512
+ folders.command("update").description("Update a teamspace folder").argument("<folder>", "folder UUID or exact name", parseUuidOrSlugSelector10).option("--name <name>", "folder name").option("--order <n>", "folder order", parseNonNegativeInteger3).option("--props <json>", "folder properties payload").option("--props-file <path>", "path to a folder properties JSON payload").action(async function action(folder, commandOptions) {
10889
11513
  const { api, json, readOnly } = createTeamspaceApi(this, filePath);
10890
- ensureWritable8("teamspace folders update", readOnly, "write");
11514
+ ensureWritable9("teamspace folders update", readOnly, "write");
10891
11515
  const resolvedFolder = await resolveFolderSelector2(api, folder);
10892
11516
  const data = await api.updateFolder(resolvedFolder, buildFolderUpdateInput(commandOptions));
10893
11517
  if (json) {
10894
- emitJson11(stdout, "teamspace folders update", data, filePath);
11518
+ emitJson12(stdout, "teamspace folders update", data, filePath);
10895
11519
  return;
10896
11520
  }
10897
- writeLine11(stdout, `Updated folder "${getFolderIdentifier(data)}".`);
11521
+ writeLine12(stdout, `Updated folder "${getFolderIdentifier(data)}".`);
10898
11522
  });
10899
- folders.command("delete").description("Delete a teamspace folder").argument("<folder>", "folder UUID or exact name", parseUuidOrSlugSelector9).action(async function action(folder) {
11523
+ folders.command("delete").description("Delete a teamspace folder").argument("<folder>", "folder UUID or exact name", parseUuidOrSlugSelector10).action(async function action(folder) {
10900
11524
  const { api, json, readOnly } = createTeamspaceApi(this, filePath);
10901
- ensureWritable8("teamspace folders delete", readOnly, "destructive");
11525
+ ensureWritable9("teamspace folders delete", readOnly, "destructive");
10902
11526
  const resolvedFolder = await resolveFolderSelector2(api, folder);
10903
11527
  const data = await api.deleteFolder(resolvedFolder);
10904
11528
  if (json) {
10905
- emitJson11(stdout, "teamspace folders delete", data, filePath);
11529
+ emitJson12(stdout, "teamspace folders delete", data, filePath);
10906
11530
  return;
10907
11531
  }
10908
- writeLine11(stdout, `Deleted folder "${resolvedFolder.value}".`);
11532
+ writeLine12(stdout, `Deleted folder "${resolvedFolder.value}".`);
10909
11533
  });
10910
11534
  const resources = teamspace.command("resources").description("Manage teamspace resources");
10911
- resources.command("publish").description("Publish a resource to a teamspace folder").argument("<resource>", "resource UUID or exact name", parseUuidOrSlugSelector9).requiredOption("--to <folder>", "target folder", parseUuidOrSlugSelector9).action(async function action(resource, commandOptions) {
11535
+ resources.command("publish").description("Publish a resource to a teamspace folder").argument("<resource>", "resource UUID or exact name", parseUuidOrSlugSelector10).requiredOption("--to <folder>", "target folder", parseUuidOrSlugSelector10).action(async function action(resource, commandOptions) {
10912
11536
  const { api, json, readOnly } = createTeamspaceApi(this, filePath);
10913
- ensureWritable8("teamspace resources publish", readOnly, "write");
11537
+ ensureWritable9("teamspace resources publish", readOnly, "write");
10914
11538
  const folder = await resolveFolderSelector2(api, commandOptions.to);
10915
11539
  const data = await api.publishResource({
10916
11540
  resourceId: resource.value,
10917
11541
  targetFolderId: folder.value
10918
11542
  });
10919
11543
  if (json) {
10920
- emitJson11(stdout, "teamspace resources publish", data, filePath);
11544
+ emitJson12(stdout, "teamspace resources publish", data, filePath);
10921
11545
  return;
10922
11546
  }
10923
- writeLine11(stdout, `Published resource "${resource.value}" to folder "${folder.value}".`);
11547
+ writeLine12(stdout, `Published resource "${resource.value}" to folder "${folder.value}".`);
10924
11548
  });
10925
- resources.command("unpublish").description("Unpublish a resource from teamspace").argument("<resource>", "resource UUID or exact name", parseUuidOrSlugSelector9).action(async function action(resource) {
11549
+ resources.command("unpublish").description("Unpublish a resource from teamspace").argument("<resource>", "resource UUID or exact name", parseUuidOrSlugSelector10).action(async function action(resource) {
10926
11550
  const { api, json, readOnly } = createTeamspaceApi(this, filePath);
10927
- ensureWritable8("teamspace resources unpublish", readOnly, "write");
11551
+ ensureWritable9("teamspace resources unpublish", readOnly, "write");
10928
11552
  const data = await api.unpublishResource(resource.value);
10929
11553
  if (json) {
10930
- emitJson11(stdout, "teamspace resources unpublish", data, filePath);
11554
+ emitJson12(stdout, "teamspace resources unpublish", data, filePath);
10931
11555
  return;
10932
11556
  }
10933
- writeLine11(stdout, `Unpublished resource "${resource.value}".`);
11557
+ writeLine12(stdout, `Unpublished resource "${resource.value}".`);
10934
11558
  });
10935
11559
  }
10936
11560
 
@@ -10938,12 +11562,13 @@ function registerTeamspaceCommands(program, options = {}) {
10938
11562
  var require2 = createRequire(import.meta.url);
10939
11563
  var { version } = require2("../package.json");
10940
11564
  function buildProgram(options = {}) {
10941
- const program = new Command10();
11565
+ const program = new Command11();
10942
11566
  program.name("zinkee").description("CLI for Zinkee API v2").version(version).enablePositionalOptions().showHelpAfterError().option("--profile <name>", "select a profile from config").option("--base-url <url>", "override the configured base URL").option("--api-key <token>", "override the configured API key").option("--read-only", "run in read-only mode").option("--example", "show examples for a command").option("--json", "emit JSON output").option("--install-completion [shell]", "install shell completion (bash, zsh, fish, powershell)").option("--show-completion [shell]", "print shell completion script for the current shell");
10943
11567
  registerProfilesCommands(program, options);
10944
11568
  registerAutomationsCommands(program, options);
10945
11569
  registerConfigCommands(program, options);
10946
11570
  registerDisplaysCommands(program, options);
11571
+ registerDocumentTemplatesCommands(program, options);
10947
11572
  registerFilesCommands(program, options);
10948
11573
  registerNavigationCommands(program, options);
10949
11574
  registerSchemasCommands(program, options);
@@ -11088,9 +11713,9 @@ function getCompletions(program, request, deps = {}) {
11088
11713
 
11089
11714
  // src/completion/install.ts
11090
11715
  import { execFileSync } from "child_process";
11091
- import { mkdirSync as mkdirSync2, readFileSync as readFileSync10, writeFileSync as writeFileSync3 } from "fs";
11716
+ import { mkdirSync as mkdirSync2, readFileSync as readFileSync11, writeFileSync as writeFileSync4 } from "fs";
11092
11717
  import { homedir as homedir2, platform } from "os";
11093
- import { basename as basename2, dirname as dirname2, join as join2 } from "path";
11718
+ import { basename as basename3, dirname as dirname2, join as join2 } from "path";
11094
11719
 
11095
11720
  // src/completion/scripts.ts
11096
11721
  var PROGRAM = "zinkee";
@@ -11212,7 +11837,7 @@ function defaultPowerShellProfile(env) {
11212
11837
  function detectShell(env) {
11213
11838
  const fromEnv = env.shellEnv;
11214
11839
  if (fromEnv) {
11215
- const name = basename2(fromEnv).toLowerCase().replace(/\.exe$/, "");
11840
+ const name = basename3(fromEnv).toLowerCase().replace(/\.exe$/, "");
11216
11841
  if (name === "bash") {
11217
11842
  return "bash";
11218
11843
  }
@@ -11310,7 +11935,7 @@ ${BLOCK_END}
11310
11935
  }
11311
11936
  function readFileOrEmpty(path) {
11312
11937
  try {
11313
- return readFileSync10(path, "utf8");
11938
+ return readFileSync11(path, "utf8");
11314
11939
  } catch (error) {
11315
11940
  if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") {
11316
11941
  return "";
@@ -11320,7 +11945,7 @@ function readFileOrEmpty(path) {
11320
11945
  }
11321
11946
  function writeFileEnsuringDir(path, content) {
11322
11947
  mkdirSync2(dirname2(path), { recursive: true });
11323
- writeFileSync3(path, content, "utf8");
11948
+ writeFileSync4(path, content, "utf8");
11324
11949
  }
11325
11950
  function installCompletion(shell, env) {
11326
11951
  const target = resolveTarget(shell, env);