zinkee 0.1.23 → 0.1.25

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
@@ -275,6 +275,41 @@ var commandRegistry = {
275
275
  supportsRaw: false,
276
276
  output: writeOutput
277
277
  },
278
+ "displays folders list": {
279
+ command: "displays folders list",
280
+ accessLevel: "read",
281
+ supportsExample: true,
282
+ supportsRaw: false,
283
+ output: readOutput
284
+ },
285
+ "displays folders create": {
286
+ command: "displays folders create",
287
+ accessLevel: "write",
288
+ supportsExample: true,
289
+ supportsRaw: false,
290
+ output: writeOutput
291
+ },
292
+ "displays folders update": {
293
+ command: "displays folders update",
294
+ accessLevel: "write",
295
+ supportsExample: true,
296
+ supportsRaw: false,
297
+ output: writeOutput
298
+ },
299
+ "displays folders delete": {
300
+ command: "displays folders delete",
301
+ accessLevel: "destructive",
302
+ supportsExample: true,
303
+ supportsRaw: false,
304
+ output: writeOutput
305
+ },
306
+ "displays folders move": {
307
+ command: "displays folders move",
308
+ accessLevel: "write",
309
+ supportsExample: true,
310
+ supportsRaw: false,
311
+ output: writeOutput
312
+ },
278
313
  "displays layout get": {
279
314
  command: "displays layout get",
280
315
  accessLevel: "read",
@@ -436,6 +471,62 @@ var commandRegistry = {
436
471
  supportsRaw: false,
437
472
  output: writeOutput
438
473
  },
474
+ "document-templates list": {
475
+ command: "document-templates list",
476
+ accessLevel: "read",
477
+ supportsExample: true,
478
+ supportsRaw: false,
479
+ output: readOutput
480
+ },
481
+ "document-templates get": {
482
+ command: "document-templates get",
483
+ accessLevel: "read",
484
+ supportsExample: true,
485
+ supportsRaw: false,
486
+ output: readOutput
487
+ },
488
+ "document-templates create": {
489
+ command: "document-templates create",
490
+ accessLevel: "write",
491
+ supportsExample: true,
492
+ supportsRaw: true,
493
+ output: writeOutput
494
+ },
495
+ "document-templates update": {
496
+ command: "document-templates update",
497
+ accessLevel: "write",
498
+ supportsExample: true,
499
+ supportsRaw: false,
500
+ output: writeOutput
501
+ },
502
+ "document-templates delete": {
503
+ command: "document-templates delete",
504
+ accessLevel: "destructive",
505
+ supportsExample: true,
506
+ supportsRaw: false,
507
+ output: writeOutput
508
+ },
509
+ "document-templates assets add": {
510
+ command: "document-templates assets add",
511
+ accessLevel: "write",
512
+ supportsExample: true,
513
+ supportsRaw: false,
514
+ output: writeOutput
515
+ },
516
+ "document-templates assets delete": {
517
+ command: "document-templates assets delete",
518
+ accessLevel: "destructive",
519
+ supportsExample: true,
520
+ supportsRaw: false,
521
+ output: writeOutput
522
+ },
523
+ "document-templates assets download": {
524
+ command: "document-templates assets download",
525
+ accessLevel: "read",
526
+ supportsExample: true,
527
+ supportsRaw: false,
528
+ output: "binary"
529
+ },
439
530
  "files upload": {
440
531
  command: "files upload",
441
532
  accessLevel: "write",
@@ -2863,11 +2954,10 @@ var specificExamples = {
2863
2954
  ]),
2864
2955
  "navigation resources move": buildCommandExamples([
2865
2956
  {
2866
- description: "Move a schema into a navigation folder.",
2867
- command: "zinkee --json navigation resources move 2eb8bdcf-6d9c-4fbb-9018-7fa8180f4c5e --type SCHEMA --to Sales",
2957
+ description: "Move a schema into a navigation folder. Only schemas can be moved; the navigation menu holds databases.",
2958
+ command: "zinkee --json navigation resources move 2eb8bdcf-6d9c-4fbb-9018-7fa8180f4c5e --to Sales",
2868
2959
  raw: `{
2869
2960
  "resourceId": "2eb8bdcf-6d9c-4fbb-9018-7fa8180f4c5e",
2870
- "resourceType": "SCHEMA",
2871
2961
  "targetFolderId": "84a0fca4-37ef-4c83-a8ed-9ef67ad9324a"
2872
2962
  }`,
2873
2963
  response: `{
@@ -2876,39 +2966,11 @@ var specificExamples = {
2876
2966
  }`
2877
2967
  },
2878
2968
  {
2879
- description: "Move a workflow.",
2880
- command: "zinkee --json navigation resources move 3f8a2c1b-9d4e-4a5b-8c6d-7e8f90123456 --type WORKFLOW --to Operations",
2881
- raw: `{
2882
- "resourceId": "3f8a2c1b-9d4e-4a5b-8c6d-7e8f90123456",
2883
- "resourceType": "WORKFLOW",
2884
- "targetFolderId": "b8c9d0e1-f2a3-4b5c-6d7e-8f9012345678"
2885
- }`
2886
- },
2887
- {
2888
- description: "Move a display.",
2889
- command: "zinkee --json navigation resources move 0f6f062f-1478-4df2-96a1-c495d037d260 --type DISPLAY --to Operations",
2890
- raw: `{
2891
- "resourceId": "0f6f062f-1478-4df2-96a1-c495d037d260",
2892
- "resourceType": "DISPLAY",
2893
- "targetFolderId": "b8c9d0e1-f2a3-4b5c-6d7e-8f9012345678"
2894
- }`
2895
- },
2896
- {
2897
- description: "Move a resource back to the root folder (root is always UUID 00000000-0000-0000-0000-000000000000).",
2898
- command: "zinkee --json navigation resources move 5223cbc8-8c6c-4694-93bc-dd176364df9b --type SCHEMA --to 00000000-0000-0000-0000-000000000000",
2969
+ description: "Move a schema back to the root folder (root is always UUID 00000000-0000-0000-0000-000000000000).",
2970
+ command: "zinkee --json navigation resources move 5223cbc8-8c6c-4694-93bc-dd176364df9b --to 00000000-0000-0000-0000-000000000000",
2899
2971
  raw: `{
2900
2972
  "resourceId": "5223cbc8-8c6c-4694-93bc-dd176364df9b",
2901
- "resourceType": "SCHEMA",
2902
2973
  "targetFolderId": "00000000-0000-0000-0000-000000000000"
2903
- }`
2904
- },
2905
- {
2906
- description: "Move a schedule resource.",
2907
- command: "zinkee --json navigation resources move a1b2c3d4-e5f6-7890-1234-567890abcdef --type SCHEDULE --to Operations",
2908
- raw: `{
2909
- "resourceId": "a1b2c3d4-e5f6-7890-1234-567890abcdef",
2910
- "resourceType": "SCHEDULE",
2911
- "targetFolderId": "b8c9d0e1-f2a3-4b5c-6d7e-8f9012345678"
2912
2974
  }`
2913
2975
  }
2914
2976
  ]),
@@ -4397,7 +4459,7 @@ var specificExamples = {
4397
4459
  "resources": [
4398
4460
  {
4399
4461
  "id": "2eb8bdcf-6d9c-4fbb-9018-7fa8180f4c5e",
4400
- "name": "Contacts",
4462
+ "name": "Customer records",
4401
4463
  "type": "SCHEMA",
4402
4464
  "isInSpace": false,
4403
4465
  "additionalProperties": {}
@@ -4421,19 +4483,10 @@ var specificExamples = {
4421
4483
  "resources": [
4422
4484
  {
4423
4485
  "id": "3f8a2c1b-9d4e-4a5b-8c6d-7e8f90123456",
4424
- "name": "Quote approval",
4425
- "type": "WORKFLOW",
4486
+ "name": "Shipments",
4487
+ "type": "SCHEMA",
4426
4488
  "isInSpace": false,
4427
4489
  "additionalProperties": {}
4428
- },
4429
- {
4430
- "id": "0f6f062f-1478-4df2-96a1-c495d037d260",
4431
- "name": "Executive Revenue",
4432
- "type": "DISPLAY",
4433
- "isInSpace": true,
4434
- "additionalProperties": {
4435
- "pinned": true
4436
- }
4437
4490
  }
4438
4491
  ],
4439
4492
  "additionalProperties": {
@@ -4480,8 +4533,13 @@ var specificExamples = {
4480
4533
  "name": "Shared Dashboards",
4481
4534
  "order": 1,
4482
4535
  "isRoot": false,
4483
- "resourceCount": 1,
4536
+ "resourceCount": 2,
4484
4537
  "resources": [
4538
+ {
4539
+ "id": "2eb8bdcf-6d9c-4fbb-9018-7fa8180f4c5e",
4540
+ "name": "Customer records",
4541
+ "type": "SCHEMA"
4542
+ },
4485
4543
  {
4486
4544
  "id": "0f6f062f-1478-4df2-96a1-c495d037d260",
4487
4545
  "name": "Executive Revenue",
@@ -4700,6 +4758,83 @@ var specificExamples = {
4700
4758
  command: "zinkee --json displays delete 0f6f062f-1478-4df2-96a1-c495d037d260"
4701
4759
  }
4702
4760
  ]),
4761
+ "displays folders list": buildCommandExamples([
4762
+ {
4763
+ description: "List flat display folders (non-root folders plus the root bucket).",
4764
+ command: "zinkee --json displays folders list",
4765
+ response: `[
4766
+ {
4767
+ "id": "e7a1c3d2-5f4b-4a6c-9d8e-1f2a3b4c5d6e",
4768
+ "name": "Executive Dashboards",
4769
+ "isRoot": false,
4770
+ "displayCount": 2
4771
+ },
4772
+ {
4773
+ "id": "8b22282b-3db3-4dd7-87f7-b29365dcf3f6",
4774
+ "name": null,
4775
+ "isRoot": true,
4776
+ "displayCount": 4
4777
+ }
4778
+ ]`
4779
+ }
4780
+ ]),
4781
+ "displays folders create": buildCommandExamples([
4782
+ {
4783
+ description: "Create one flat display folder.",
4784
+ command: 'zinkee --json displays folders create --name "Executive Dashboards"',
4785
+ raw: `{
4786
+ "name": "Executive Dashboards"
4787
+ }`,
4788
+ response: `{
4789
+ "id": "e7a1c3d2-5f4b-4a6c-9d8e-1f2a3b4c5d6e",
4790
+ "name": "Executive Dashboards",
4791
+ "isRoot": false,
4792
+ "displayCount": 0
4793
+ }`
4794
+ }
4795
+ ]),
4796
+ "displays folders update": buildCommandExamples([
4797
+ {
4798
+ description: "Rename a display folder. The folder argument accepts a UUID or an exact name.",
4799
+ command: 'zinkee --json displays folders update "Executive Dashboards" --name "Executive Dashboards (2026)"',
4800
+ raw: `{
4801
+ "name": "Executive Dashboards (2026)"
4802
+ }`,
4803
+ response: `{
4804
+ "id": "e7a1c3d2-5f4b-4a6c-9d8e-1f2a3b4c5d6e",
4805
+ "name": "Executive Dashboards (2026)",
4806
+ "isRoot": false,
4807
+ "displayCount": 2
4808
+ }`
4809
+ }
4810
+ ]),
4811
+ "displays folders delete": buildCommandExamples([
4812
+ {
4813
+ description: "Delete a non-root display folder. Its displays move back to the root folder.",
4814
+ command: 'zinkee --json displays folders delete "Executive Dashboards"',
4815
+ response: `{
4816
+ "id": "e7a1c3d2-5f4b-4a6c-9d8e-1f2a3b4c5d6e",
4817
+ "name": "Executive Dashboards",
4818
+ "isRoot": false,
4819
+ "displayCount": 2
4820
+ }`
4821
+ }
4822
+ ]),
4823
+ "displays folders move": buildCommandExamples([
4824
+ {
4825
+ description: "Move one display into a target folder by exact folder name.",
4826
+ command: 'zinkee --json displays folders move 0f6f062f-1478-4df2-96a1-c495d037d260 --to "Executive Dashboards"',
4827
+ raw: `{
4828
+ "displayId": "0f6f062f-1478-4df2-96a1-c495d037d260",
4829
+ "targetFolderId": "e7a1c3d2-5f4b-4a6c-9d8e-1f2a3b4c5d6e"
4830
+ }`,
4831
+ response: `{
4832
+ "id": "e7a1c3d2-5f4b-4a6c-9d8e-1f2a3b4c5d6e",
4833
+ "name": "Executive Dashboards",
4834
+ "isRoot": false
4835
+ }`
4836
+ }
4837
+ ]),
4703
4838
  "displays layout get": buildCommandExamples([
4704
4839
  {
4705
4840
  description: "Get the layout block of a display (template + tabs/freeformLayouts/slots).",
@@ -5713,7 +5848,8 @@ var specificExamples = {
5713
5848
  description: "Move one automation into a target folder by exact folder name.",
5714
5849
  command: 'zinkee --json automations folders move automation-1 --to "Codex Frontend Demo"',
5715
5850
  raw: `{
5716
- "automationId": "automation-1"
5851
+ "automationId": "automation-1",
5852
+ "targetFolderId": "cdfc14e3-3169-4ffb-8d9b-b11858a9240f"
5717
5853
  }`,
5718
5854
  response: `{
5719
5855
  "id": "cdfc14e3-3169-4ffb-8d9b-b11858a9240f",
@@ -5721,6 +5857,171 @@ var specificExamples = {
5721
5857
  "isRoot": false
5722
5858
  }`
5723
5859
  }
5860
+ ]),
5861
+ "document-templates list": buildCommandExamples([
5862
+ {
5863
+ 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.",
5864
+ command: "zinkee --json document-templates list",
5865
+ response: `[
5866
+ {
5867
+ "id": "7c4a8d3f-1b2e-4a5c-9d6e-1f2a3b4c5d6e",
5868
+ "name": "Quarterly report",
5869
+ "assets": [
5870
+ {
5871
+ "id": "9e8d7c6b-5a4f-3e2d-1c0b-9a8b7c6d5e4f",
5872
+ "name": "Requirements.docx",
5873
+ "link": "/api/v2/document-templates/7c4a8d3f-1b2e-4a5c-9d6e-1f2a3b4c5d6e/assets/9e8d7c6b-5a4f-3e2d-1c0b-9a8b7c6d5e4f/download"
5874
+ }
5875
+ ],
5876
+ "createdAt": "2026-01-15T10:00:00Z",
5877
+ "updatedAt": "2026-01-20T14:30:00Z",
5878
+ "createdBy": "creator@example.com",
5879
+ "updatedBy": "updater@example.com"
5880
+ }
5881
+ ]`
5882
+ }
5883
+ ]),
5884
+ "document-templates get": buildCommandExamples([
5885
+ {
5886
+ description: "Look up one template by UUID. The CLI filters the list endpoint locally (the backend does not expose a get-one route).",
5887
+ command: "zinkee --json document-templates get 7c4a8d3f-1b2e-4a5c-9d6e-1f2a3b4c5d6e",
5888
+ response: `{
5889
+ "id": "7c4a8d3f-1b2e-4a5c-9d6e-1f2a3b4c5d6e",
5890
+ "name": "Quarterly report",
5891
+ "assets": [
5892
+ {
5893
+ "id": "9e8d7c6b-5a4f-3e2d-1c0b-9a8b7c6d5e4f",
5894
+ "name": "Requirements.docx",
5895
+ "link": "/api/v2/document-templates/7c4a8d3f-1b2e-4a5c-9d6e-1f2a3b4c5d6e/assets/9e8d7c6b-5a4f-3e2d-1c0b-9a8b7c6d5e4f/download"
5896
+ }
5897
+ ],
5898
+ "createdAt": "2026-01-15T10:00:00Z",
5899
+ "updatedAt": "2026-01-20T14:30:00Z",
5900
+ "createdBy": "creator@example.com",
5901
+ "updatedBy": "creator@example.com"
5902
+ }`
5903
+ },
5904
+ {
5905
+ description: "Look up by exact template name. Names are unique within the workspace; ambiguity is reported as an error.",
5906
+ command: 'zinkee --json document-templates get "Quarterly report"'
5907
+ }
5908
+ ]),
5909
+ "document-templates create": buildCommandExamples([
5910
+ {
5911
+ description: "Typical create: empty template by name. Assets are uploaded afterwards via document-templates assets add.",
5912
+ command: 'zinkee --json document-templates create --name "Quarterly report"',
5913
+ raw: `{
5914
+ "name": "Quarterly report",
5915
+ "assets": []
5916
+ }`,
5917
+ response: `{
5918
+ "id": "7c4a8d3f-1b2e-4a5c-9d6e-1f2a3b4c5d6e",
5919
+ "name": "Quarterly report",
5920
+ "assets": [],
5921
+ "createdAt": "2026-01-15T10:00:00Z",
5922
+ "updatedAt": "2026-01-15T10:00:00Z",
5923
+ "createdBy": "creator@example.com",
5924
+ "updatedBy": "creator@example.com"
5925
+ }`
5926
+ },
5927
+ {
5928
+ 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.",
5929
+ 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"}]}'`,
5930
+ raw: `{
5931
+ "name": "Annual report",
5932
+ "assets": [
5933
+ {
5934
+ "id": "9e8d7c6b-5a4f-3e2d-1c0b-9a8b7c6d5e4f",
5935
+ "name": "Cover.docx",
5936
+ "link": "/existing/cover.docx"
5937
+ },
5938
+ {
5939
+ "id": "3f2e1d0c-9b8a-7654-3210-fedcba987654",
5940
+ "name": "Appendix.docx",
5941
+ "link": "/existing/appendix.docx"
5942
+ }
5943
+ ]
5944
+ }`
5945
+ }
5946
+ ]),
5947
+ "document-templates update": buildCommandExamples([
5948
+ {
5949
+ 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.",
5950
+ command: 'zinkee --json document-templates update "Quarterly report" --name "Annual report"',
5951
+ raw: `{
5952
+ "name": "Annual report"
5953
+ }`,
5954
+ response: `{
5955
+ "id": "7c4a8d3f-1b2e-4a5c-9d6e-1f2a3b4c5d6e",
5956
+ "name": "Annual report",
5957
+ "assets": [
5958
+ {
5959
+ "id": "9e8d7c6b-5a4f-3e2d-1c0b-9a8b7c6d5e4f",
5960
+ "name": "Requirements.docx",
5961
+ "link": "/api/v2/document-templates/7c4a8d3f-1b2e-4a5c-9d6e-1f2a3b4c5d6e/assets/9e8d7c6b-5a4f-3e2d-1c0b-9a8b7c6d5e4f/download"
5962
+ }
5963
+ ],
5964
+ "createdAt": "2026-01-15T10:00:00Z",
5965
+ "updatedAt": "2026-01-22T09:15:00Z",
5966
+ "createdBy": "creator@example.com",
5967
+ "updatedBy": "updater@example.com"
5968
+ }`
5969
+ }
5970
+ ]),
5971
+ "document-templates delete": buildCommandExamples([
5972
+ {
5973
+ description: "Delete a template and remove its asset files from storage. Record fields that reference previously generated documents are not modified.",
5974
+ command: "zinkee --json document-templates delete 7c4a8d3f-1b2e-4a5c-9d6e-1f2a3b4c5d6e",
5975
+ response: `{
5976
+ "id": "7c4a8d3f-1b2e-4a5c-9d6e-1f2a3b4c5d6e",
5977
+ "deleted": true
5978
+ }`
5979
+ }
5980
+ ]),
5981
+ "document-templates assets add": buildCommandExamples([
5982
+ {
5983
+ 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.',
5984
+ command: 'zinkee --json document-templates assets add "Quarterly report" ./contract.docx',
5985
+ response: `{
5986
+ "id": "7c4a8d3f-1b2e-4a5c-9d6e-1f2a3b4c5d6e",
5987
+ "name": "Quarterly report",
5988
+ "assets": [
5989
+ {
5990
+ "id": "9e8d7c6b-5a4f-3e2d-1c0b-9a8b7c6d5e4f",
5991
+ "name": "contract.docx",
5992
+ "link": "/api/v2/document-templates/7c4a8d3f-1b2e-4a5c-9d6e-1f2a3b4c5d6e/assets/9e8d7c6b-5a4f-3e2d-1c0b-9a8b7c6d5e4f/download"
5993
+ }
5994
+ ],
5995
+ "createdAt": "2026-01-15T10:00:00Z",
5996
+ "updatedAt": "2026-01-22T09:15:00Z",
5997
+ "createdBy": "creator@example.com",
5998
+ "updatedBy": "updater@example.com"
5999
+ }`
6000
+ },
6001
+ {
6002
+ description: "Override the asset display name with --name (otherwise the uploaded filename is used).",
6003
+ command: 'zinkee --json document-templates assets add "Quarterly report" ./contract.docx --name "Customer Contract"'
6004
+ }
6005
+ ]),
6006
+ "document-templates assets delete": buildCommandExamples([
6007
+ {
6008
+ description: "Delete one asset from a template and remove its file from storage.",
6009
+ command: "zinkee --json document-templates assets delete 7c4a8d3f-1b2e-4a5c-9d6e-1f2a3b4c5d6e 9e8d7c6b-5a4f-3e2d-1c0b-9a8b7c6d5e4f",
6010
+ response: `{
6011
+ "id": "9e8d7c6b-5a4f-3e2d-1c0b-9a8b7c6d5e4f",
6012
+ "deleted": true
6013
+ }`
6014
+ }
6015
+ ]),
6016
+ "document-templates assets download": buildCommandExamples([
6017
+ {
6018
+ 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.",
6019
+ command: "zinkee --json document-templates assets download 7c4a8d3f-1b2e-4a5c-9d6e-1f2a3b4c5d6e 9e8d7c6b-5a4f-3e2d-1c0b-9a8b7c6d5e4f --output ./contract.docx"
6020
+ },
6021
+ {
6022
+ description: "Stream asset bytes to stdout (omit --json and --output). Useful for piping into other tools.",
6023
+ command: "zinkee document-templates assets download 7c4a8d3f-1b2e-4a5c-9d6e-1f2a3b4c5d6e 9e8d7c6b-5a4f-3e2d-1c0b-9a8b7c6d5e4f > contract.docx"
6024
+ }
5724
6025
  ])
5725
6026
  };
5726
6027
  function fallbackExamples(commandName) {
@@ -5840,7 +6141,7 @@ ${index + 1}. ${example.description}
5840
6141
 
5841
6142
  // src/program.ts
5842
6143
  import { createRequire } from "module";
5843
- import { Command as Command10 } from "commander";
6144
+ import { Command as Command11 } from "commander";
5844
6145
 
5845
6146
  // src/config.ts
5846
6147
  import { mkdirSync, readFileSync, writeFileSync } from "fs";
@@ -6194,7 +6495,7 @@ var AutomationsApi = class {
6194
6495
  }
6195
6496
  moveAutomation(input) {
6196
6497
  return this.client.requestJson(
6197
- `/api/v2/automation-folders/${segment(input.targetFolderId)}/automations:move`,
6498
+ "/api/v2/automation-folders/automations:move",
6198
6499
  jsonOptions(input, "POST")
6199
6500
  );
6200
6501
  }
@@ -6601,11 +6902,11 @@ function hasSetPath(target, path) {
6601
6902
  return Object.hasOwn(target, path);
6602
6903
  }
6603
6904
  let current = target;
6604
- for (const segment3 of segments) {
6605
- if (!isJsonObject2(current) || !Object.hasOwn(current, segment3)) {
6905
+ for (const segment4 of segments) {
6906
+ if (!isJsonObject2(current) || !Object.hasOwn(current, segment4)) {
6606
6907
  return false;
6607
6908
  }
6608
- current = current[segment3];
6909
+ current = current[segment4];
6609
6910
  }
6610
6911
  return true;
6611
6912
  }
@@ -7339,8 +7640,8 @@ function registerAutomationsCommands(program, options = {}) {
7339
7640
  const filePath = options.configPath ?? defaultConfigPath;
7340
7641
  const stdout = getCommandIo2(options.stdout);
7341
7642
  const automations = program.command("automations").description("Manage automations, triggers, actions, and connections");
7342
- const folders = automations.command("folders").description("Manage automation folders");
7343
- folders.command("list").description("List automation folders").action(async function action() {
7643
+ const folders = automations.command("folders").description("Manage automation folders (flat: a folder only has a name, no order or properties)");
7644
+ folders.command("list").description("List automation folders (non-root folders plus the root bucket, whose name is null)").action(async function action() {
7344
7645
  const { api, json } = createAutomationsApi(this, filePath);
7345
7646
  const data = await api.listFolders();
7346
7647
  if (json) {
@@ -7390,7 +7691,11 @@ function registerAutomationsCommands(program, options = {}) {
7390
7691
  }
7391
7692
  writeLine2(stdout, `Deleted automation folder "${folder.value}".`);
7392
7693
  });
7393
- folders.command("move").description("Move an automation into a folder").argument("<automation>", "automation UUID", parseUuidOrSlugSelector).requiredOption("--to <folder>", "target folder UUID or exact name", parseUuidOrSlugSelector).action(async function action(automation, commandOptions) {
7694
+ folders.command("move").description("Move an automation into a folder").argument("<automation>", "automation UUID", parseUuidOrSlugSelector).requiredOption(
7695
+ "--to <folder>",
7696
+ "target folder UUID or exact name (use the root folder to move it out of any folder)",
7697
+ parseUuidOrSlugSelector
7698
+ ).action(async function action(automation, commandOptions) {
7394
7699
  const { api, json, readOnly } = createAutomationsApi(this, filePath);
7395
7700
  ensureWritable("automations folders move", readOnly, "write");
7396
7701
  if (!commandOptions.to) {
@@ -8075,6 +8380,33 @@ var DisplaysApi = class {
8075
8380
  { method: "DELETE" }
8076
8381
  );
8077
8382
  }
8383
+ listFolders() {
8384
+ return this.client.getJson("/api/v2/display-folders");
8385
+ }
8386
+ createFolder(body) {
8387
+ return this.client.requestJson(
8388
+ "/api/v2/display-folders",
8389
+ jsonOptions3(body, "POST")
8390
+ );
8391
+ }
8392
+ updateFolder(folder, body) {
8393
+ return this.client.requestJson(
8394
+ `/api/v2/display-folders/${selectorValue3(folder)}`,
8395
+ jsonOptions3(body, "PATCH")
8396
+ );
8397
+ }
8398
+ deleteFolder(folder) {
8399
+ return this.client.requestJson(
8400
+ `/api/v2/display-folders/${selectorValue3(folder)}`,
8401
+ { method: "DELETE" }
8402
+ );
8403
+ }
8404
+ moveDisplay(input) {
8405
+ return this.client.requestJson(
8406
+ "/api/v2/display-folders/displays:move",
8407
+ jsonOptions3(input, "POST")
8408
+ );
8409
+ }
8078
8410
  };
8079
8411
 
8080
8412
  // src/parsers/expressions.ts
@@ -8302,6 +8634,31 @@ function getDisplaySubresource(value) {
8302
8634
  }
8303
8635
  return value.filter((entry) => Boolean(entry) && typeof entry === "object");
8304
8636
  }
8637
+ function displayFolderRows(folders) {
8638
+ return folders.map((folder) => ({
8639
+ id: folder.id ?? "",
8640
+ name: folder.name ?? "",
8641
+ isRoot: folder.isRoot ?? "",
8642
+ displayCount: folder.displayCount ?? ""
8643
+ }));
8644
+ }
8645
+ async function resolveDisplayFolderId(api, selector) {
8646
+ if (selector.kind === "uuid") {
8647
+ return selector.value;
8648
+ }
8649
+ const folders = await api.listFolders();
8650
+ const matches = folders.filter((folder) => folder.name === selector.value);
8651
+ if (matches.length === 1 && typeof matches[0]?.id === "string" && matches[0].id.length > 0) {
8652
+ return matches[0].id;
8653
+ }
8654
+ if (matches.length > 1) {
8655
+ throw new CliError(
8656
+ "invalid_cli_usage",
8657
+ `Folder "${selector.value}" is ambiguous. Found ${matches.length} matches.`
8658
+ );
8659
+ }
8660
+ throw new CliError("invalid_cli_usage", `Folder "${selector.value}" was not found.`);
8661
+ }
8305
8662
  function buildVariableBody(options) {
8306
8663
  const body = {
8307
8664
  ...readRawObject2(options.raw, options.rawFile)
@@ -8507,23 +8864,89 @@ function registerDisplaysCommands(program, options = {}) {
8507
8864
  }
8508
8865
  writeLine4(stdout, `Deleted display "${display.value}".`);
8509
8866
  });
8510
- const layout = displays.command("layout").description("Manage display layout");
8511
- layout.command("get").description("Get display layout").argument("<display>", "display uuid or slug", parseUuidOrSlugSelector3).action(async function action(display) {
8867
+ const folders = displays.command("folders").description("Manage display folders (flat: a folder only has a name, no order or properties)");
8868
+ folders.command("list").description("List display folders (non-root folders plus the root bucket, whose name is null)").action(async function action() {
8512
8869
  const { api, json } = createDisplaysApi(this, filePath);
8513
- const data = await api.getDisplay(display);
8514
- const layoutData = data.layout ?? null;
8870
+ const data = await api.listFolders();
8515
8871
  if (json) {
8516
- emitJson4(stdout, "displays layout get", layoutData);
8872
+ emitJson4(stdout, "displays folders list", data);
8517
8873
  return;
8518
8874
  }
8519
- printTable(layoutData ? [{ template: layoutData.template ?? "", freeformLayouts: layoutData.freeformLayouts ?? "" }] : [], ["template", "freeformLayouts"], stdout);
8875
+ printTable(displayFolderRows(data), ["id", "name", "isRoot", "displayCount"], stdout);
8520
8876
  });
8521
- layout.command("update").description("Update display layout").argument("<display>", "display uuid or slug", parseUuidOrSlugSelector3).requiredOption("--template <template>", "layout template").option("--freeform-layouts <json>", "freeform layouts JSON").option("--freeform-layouts-file <path>", "freeform layouts JSON file").action(async function action(display, commandOptions) {
8877
+ folders.command("create").description("Create a display folder").requiredOption("--name <name>", "folder name").action(async function action(commandOptions) {
8522
8878
  const { api, json, readOnly } = createDisplaysApi(this, filePath);
8523
- ensureWritable3("displays layout update", readOnly, "write");
8524
- const body = { template: commandOptions.template };
8525
- const freeformLayouts = readNamedJsonOption(commandOptions.freeformLayouts, commandOptions.freeformLayoutsFile, "--freeform-layouts", "--freeform-layouts-file");
8526
- if (freeformLayouts !== void 0) body.freeformLayouts = freeformLayouts;
8879
+ ensureWritable3("displays folders create", readOnly, "write");
8880
+ if (commandOptions.name === void 0) {
8881
+ throw new CliError("invalid_cli_usage", 'Provide folder name via "--name".');
8882
+ }
8883
+ const data = await api.createFolder({ name: commandOptions.name });
8884
+ if (json) {
8885
+ emitJson4(stdout, "displays folders create", data);
8886
+ return;
8887
+ }
8888
+ writeLine4(stdout, `Created display folder "${String(data.name ?? commandOptions.name)}".`);
8889
+ });
8890
+ folders.command("update").description("Rename a display folder").argument("<folder>", "folder UUID or exact name", parseUuidOrSlugSelector3).requiredOption("--name <name>", "folder name").action(async function action(folder, commandOptions) {
8891
+ const { api, json, readOnly } = createDisplaysApi(this, filePath);
8892
+ ensureWritable3("displays folders update", readOnly, "write");
8893
+ if (commandOptions.name === void 0) {
8894
+ throw new CliError("invalid_cli_usage", 'Provide folder name via "--name".');
8895
+ }
8896
+ const folderId = await resolveDisplayFolderId(api, folder);
8897
+ const data = await api.updateFolder({ kind: "uuid", value: folderId }, { name: commandOptions.name });
8898
+ if (json) {
8899
+ emitJson4(stdout, "displays folders update", data);
8900
+ return;
8901
+ }
8902
+ writeLine4(stdout, `Updated display folder "${String(data.name ?? folder.value)}".`);
8903
+ });
8904
+ folders.command("delete").description("Delete a display folder (its displays move back to the root folder)").argument("<folder>", "folder UUID or exact name", parseUuidOrSlugSelector3).action(async function action(folder) {
8905
+ const { api, json, readOnly } = createDisplaysApi(this, filePath);
8906
+ ensureWritable3("displays folders delete", readOnly, "destructive");
8907
+ const folderId = await resolveDisplayFolderId(api, folder);
8908
+ const data = await api.deleteFolder({ kind: "uuid", value: folderId });
8909
+ if (json) {
8910
+ emitJson4(stdout, "displays folders delete", data);
8911
+ return;
8912
+ }
8913
+ writeLine4(stdout, `Deleted display folder "${folder.value}".`);
8914
+ });
8915
+ folders.command("move").description("Move a display into a folder").argument("<display>", "display UUID", parseUuidOrSlugSelector3).requiredOption(
8916
+ "--to <folder>",
8917
+ "target folder UUID or exact name (use the root folder to move it out of any folder)",
8918
+ parseUuidOrSlugSelector3
8919
+ ).action(async function action(display, commandOptions) {
8920
+ const { api, json, readOnly } = createDisplaysApi(this, filePath);
8921
+ ensureWritable3("displays folders move", readOnly, "write");
8922
+ if (!commandOptions.to) {
8923
+ throw new CliError("invalid_cli_usage", 'Provide target folder via "--to".');
8924
+ }
8925
+ const targetFolderId = await resolveDisplayFolderId(api, commandOptions.to);
8926
+ const data = await api.moveDisplay({ displayId: display.value, targetFolderId });
8927
+ if (json) {
8928
+ emitJson4(stdout, "displays folders move", data);
8929
+ return;
8930
+ }
8931
+ writeLine4(stdout, `Moved display "${display.value}" to folder "${targetFolderId}".`);
8932
+ });
8933
+ const layout = displays.command("layout").description("Manage display layout");
8934
+ layout.command("get").description("Get display layout").argument("<display>", "display uuid or slug", parseUuidOrSlugSelector3).action(async function action(display) {
8935
+ const { api, json } = createDisplaysApi(this, filePath);
8936
+ const data = await api.getDisplay(display);
8937
+ const layoutData = data.layout ?? null;
8938
+ if (json) {
8939
+ emitJson4(stdout, "displays layout get", layoutData);
8940
+ return;
8941
+ }
8942
+ printTable(layoutData ? [{ template: layoutData.template ?? "", freeformLayouts: layoutData.freeformLayouts ?? "" }] : [], ["template", "freeformLayouts"], stdout);
8943
+ });
8944
+ layout.command("update").description("Update display layout").argument("<display>", "display uuid or slug", parseUuidOrSlugSelector3).requiredOption("--template <template>", "layout template").option("--freeform-layouts <json>", "freeform layouts JSON").option("--freeform-layouts-file <path>", "freeform layouts JSON file").action(async function action(display, commandOptions) {
8945
+ const { api, json, readOnly } = createDisplaysApi(this, filePath);
8946
+ ensureWritable3("displays layout update", readOnly, "write");
8947
+ const body = { template: commandOptions.template };
8948
+ const freeformLayouts = readNamedJsonOption(commandOptions.freeformLayouts, commandOptions.freeformLayoutsFile, "--freeform-layouts", "--freeform-layouts-file");
8949
+ if (freeformLayouts !== void 0) body.freeformLayouts = freeformLayouts;
8527
8950
  const data = await api.patchLayout(display, body);
8528
8951
  if (json) {
8529
8952
  emitJson4(stdout, "displays layout update", data);
@@ -8701,61 +9124,464 @@ function registerDisplaysCommands(program, options = {}) {
8701
9124
  ensureWritable3("displays navigation-targets update", readOnly, "write");
8702
9125
  const data = await api.updateNavigationTarget(display, targetId, buildNavigationTargetBody(commandOptions));
8703
9126
  if (json) {
8704
- emitJson4(stdout, "displays navigation-targets update", data);
9127
+ emitJson4(stdout, "displays navigation-targets update", data);
9128
+ return;
9129
+ }
9130
+ writeLine4(stdout, `Updated navigation target "${targetId}".`);
9131
+ });
9132
+ targets.command("delete").description("Delete navigation target").argument("<display>", "display uuid or slug", parseUuidOrSlugSelector3).argument("<target>", "target id").action(async function action(display, targetId) {
9133
+ const { api, json, readOnly } = createDisplaysApi(this, filePath);
9134
+ ensureWritable3("displays navigation-targets delete", readOnly, "destructive");
9135
+ const data = await api.deleteNavigationTarget(display, targetId);
9136
+ if (json) {
9137
+ emitJson4(stdout, "displays navigation-targets delete", data);
9138
+ return;
9139
+ }
9140
+ writeLine4(stdout, `Deleted navigation target "${targetId}".`);
9141
+ });
9142
+ const cross = displays.command("cross-widget-filter").description("Manage cross widget filter");
9143
+ cross.command("get").description("Get cross widget filter").argument("<display>", "display uuid or slug", parseUuidOrSlugSelector3).action(async function action(display) {
9144
+ const { api, json } = createDisplaysApi(this, filePath);
9145
+ const data = await api.getDisplay(display);
9146
+ const item = data.crossWidgetFilter ?? null;
9147
+ if (json) {
9148
+ emitJson4(stdout, "displays cross-widget-filter get", item);
9149
+ return;
9150
+ }
9151
+ printTable(item ? [item] : [], void 0, stdout);
9152
+ });
9153
+ cross.command("set").description("Set cross widget filter").argument("<display>", "display uuid or slug", parseUuidOrSlugSelector3).requiredOption("--source-widget <id>").requiredOption("--source-field <id>").requiredOption("--target <widget:field>", "repeatable target", (v, p = []) => [...p, v], []).action(async function action(display, commandOptions) {
9154
+ const { api, json, readOnly } = createDisplaysApi(this, filePath);
9155
+ ensureWritable3("displays cross-widget-filter set", readOnly, "write");
9156
+ const data = await api.setCrossWidgetFilter(display, buildCrossWidgetFilterBody(commandOptions));
9157
+ if (json) {
9158
+ emitJson4(stdout, "displays cross-widget-filter set", data);
9159
+ return;
9160
+ }
9161
+ writeLine4(stdout, `Updated cross widget filter for display "${display.value}".`);
9162
+ });
9163
+ cross.command("delete").description("Delete cross widget filter").argument("<display>", "display uuid or slug", parseUuidOrSlugSelector3).action(async function action(display) {
9164
+ const { api, json, readOnly } = createDisplaysApi(this, filePath);
9165
+ ensureWritable3("displays cross-widget-filter delete", readOnly, "destructive");
9166
+ const data = await api.deleteCrossWidgetFilter(display);
9167
+ if (json) {
9168
+ emitJson4(stdout, "displays cross-widget-filter delete", data);
9169
+ return;
9170
+ }
9171
+ writeLine4(stdout, `Deleted cross widget filter for display "${display.value}".`);
9172
+ });
9173
+ }
9174
+
9175
+ // src/commands/document-templates.ts
9176
+ import { readFileSync as readFileSync5, writeFileSync as writeFileSync2 } from "fs";
9177
+ import { basename } from "path";
9178
+ import { InvalidArgumentError as InvalidArgumentError4 } from "commander";
9179
+
9180
+ // src/api/document-templates.ts
9181
+ function jsonOptions4(body, method) {
9182
+ return {
9183
+ method,
9184
+ headers: {
9185
+ "content-type": "application/json"
9186
+ },
9187
+ body: JSON.stringify(body)
9188
+ };
9189
+ }
9190
+ function selectorValue4(selector) {
9191
+ return encodeURIComponent(selector.value);
9192
+ }
9193
+ function segment3(value) {
9194
+ return encodeURIComponent(value);
9195
+ }
9196
+ var DocumentTemplatesApi = class {
9197
+ constructor(client) {
9198
+ this.client = client;
9199
+ }
9200
+ listTemplates() {
9201
+ return this.client.getJson("/api/v2/document-templates");
9202
+ }
9203
+ createTemplate(input) {
9204
+ return this.client.requestJson(
9205
+ "/api/v2/document-templates",
9206
+ jsonOptions4(input, "POST")
9207
+ );
9208
+ }
9209
+ updateTemplate(template, input) {
9210
+ return this.client.requestJson(
9211
+ `/api/v2/document-templates/${selectorValue4(template)}`,
9212
+ jsonOptions4(input, "PATCH")
9213
+ );
9214
+ }
9215
+ deleteTemplate(template) {
9216
+ return this.client.requestJson(
9217
+ `/api/v2/document-templates/${selectorValue4(template)}`,
9218
+ { method: "DELETE" }
9219
+ );
9220
+ }
9221
+ addAsset(template, input) {
9222
+ return this.client.requestJson(
9223
+ `/api/v2/document-templates/${selectorValue4(template)}/assets`,
9224
+ { method: "POST", body: input }
9225
+ );
9226
+ }
9227
+ deleteAsset(template, assetId) {
9228
+ return this.client.requestJson(
9229
+ `/api/v2/document-templates/${selectorValue4(template)}/assets/${segment3(assetId)}`,
9230
+ { method: "DELETE" }
9231
+ );
9232
+ }
9233
+ downloadAsset(template, assetId) {
9234
+ return this.client.requestBinary(
9235
+ `/api/v2/document-templates/${selectorValue4(template)}/assets/${segment3(assetId)}/download`
9236
+ );
9237
+ }
9238
+ };
9239
+
9240
+ // src/commands/document-templates.ts
9241
+ function getCommandIo5(stdout) {
9242
+ return stdout ?? process.stdout;
9243
+ }
9244
+ function writeLine5(stdout, value) {
9245
+ stdout.write(`${value}
9246
+ `);
9247
+ }
9248
+ function writeBinary(stdout, value) {
9249
+ stdout.write(Buffer.from(value));
9250
+ }
9251
+ function getGlobalOptions5(command) {
9252
+ return command.optsWithGlobals();
9253
+ }
9254
+ function emitJson5(stdout, commandName, data, configPath, meta = {}) {
9255
+ writeLine5(
9256
+ stdout,
9257
+ JSON.stringify(buildJsonSuccess(data, { command: commandName, configPath, ...meta }))
9258
+ );
9259
+ }
9260
+ function toConfigurationError5(filePath, error) {
9261
+ if (error instanceof CliError) {
9262
+ throw error;
9263
+ }
9264
+ if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") {
9265
+ throw new CliError("configuration_error", `Config file not found at ${filePath}.`);
9266
+ }
9267
+ if (error instanceof Error) {
9268
+ throw new CliError("configuration_error", error.message);
9269
+ }
9270
+ throw error;
9271
+ }
9272
+ function createDocumentTemplatesApi(command, filePath) {
9273
+ try {
9274
+ const config = readRuntimeConfig(filePath);
9275
+ const runtime = resolveRuntimeContext(config, getGlobalOptions5(command));
9276
+ if (!runtime.baseUrl) {
9277
+ throw new CliError(
9278
+ "configuration_error",
9279
+ `Resolved profile "${runtime.profile}" is missing a base URL.`
9280
+ );
9281
+ }
9282
+ return {
9283
+ api: new DocumentTemplatesApi(
9284
+ new ApiClient({
9285
+ baseUrl: runtime.baseUrl,
9286
+ apiKey: runtime.apiKey
9287
+ })
9288
+ ),
9289
+ json: runtime.json,
9290
+ readOnly: runtime.readOnly
9291
+ };
9292
+ } catch (error) {
9293
+ toConfigurationError5(filePath, error);
9294
+ }
9295
+ }
9296
+ function ensureWritable4(commandName, readOnly, commandMode) {
9297
+ if (readOnly) {
9298
+ throw new CliError(
9299
+ "command_not_allowed_in_read_only_mode",
9300
+ `Command "${commandName}" is not allowed in read-only mode.`,
9301
+ {
9302
+ commandMode,
9303
+ executionMode: "read-only"
9304
+ }
9305
+ );
9306
+ }
9307
+ }
9308
+ function parseUuidOrSlugSelector4(input) {
9309
+ try {
9310
+ return normalizeUuidOrSlug(input);
9311
+ } catch (error) {
9312
+ const message = error instanceof Error ? error.message : "Invalid selector.";
9313
+ throw new InvalidArgumentError4(message);
9314
+ }
9315
+ }
9316
+ function isJsonObject4(value) {
9317
+ return typeof value === "object" && value !== null && !Array.isArray(value);
9318
+ }
9319
+ function isEmptyObject4(value) {
9320
+ return Object.keys(value).length === 0;
9321
+ }
9322
+ function parseJsonValue2(input, sourceLabel) {
9323
+ try {
9324
+ return JSON.parse(input);
9325
+ } catch (error) {
9326
+ const message = error instanceof Error ? error.message : "Invalid JSON.";
9327
+ throw new CliError(
9328
+ "invalid_cli_usage",
9329
+ `Failed to parse JSON from ${sourceLabel}: ${message}`
9330
+ );
9331
+ }
9332
+ }
9333
+ function readTextFile2(filePath, label) {
9334
+ try {
9335
+ return readFileSync5(filePath, "utf8");
9336
+ } catch (error) {
9337
+ const message = error instanceof Error ? error.message : "Unable to read file.";
9338
+ throw new CliError(
9339
+ "invalid_cli_usage",
9340
+ `Failed to read ${label} from ${filePath}: ${message}`
9341
+ );
9342
+ }
9343
+ }
9344
+ function readJsonObjectOption2(raw, rawFile, rawLabel, rawFileLabel) {
9345
+ if (raw && rawFile) {
9346
+ throw new CliError(
9347
+ "invalid_cli_usage",
9348
+ `Provide either "${rawLabel}" or "${rawFileLabel}", not both.`
9349
+ );
9350
+ }
9351
+ let parsed;
9352
+ if (raw) {
9353
+ parsed = parseJsonValue2(raw, rawLabel);
9354
+ } else if (rawFile) {
9355
+ parsed = parseJsonValue2(readTextFile2(rawFile, rawFileLabel), `${rawFileLabel} ${rawFile}`);
9356
+ } else {
9357
+ return {};
9358
+ }
9359
+ if (!isJsonObject4(parsed)) {
9360
+ throw new CliError(
9361
+ "invalid_cli_usage",
9362
+ `Expected ${raw ? rawLabel : rawFileLabel} to contain a JSON object.`
9363
+ );
9364
+ }
9365
+ return parsed;
9366
+ }
9367
+ function readLocalFile(filePath) {
9368
+ try {
9369
+ return readFileSync5(filePath);
9370
+ } catch (error) {
9371
+ const message = error instanceof Error ? error.message : "Unable to read file.";
9372
+ throw new CliError("invalid_cli_usage", `Failed to read file at ${filePath}: ${message}`);
9373
+ }
9374
+ }
9375
+ function writeDownloadedFile(outputPath, value) {
9376
+ try {
9377
+ writeFileSync2(outputPath, Buffer.from(value));
9378
+ } catch (error) {
9379
+ const message = error instanceof Error ? error.message : "Unable to write file.";
9380
+ throw new CliError(
9381
+ "invalid_cli_usage",
9382
+ `Failed to write downloaded file to ${outputPath}: ${message}`
9383
+ );
9384
+ }
9385
+ }
9386
+ function templateRows(templates) {
9387
+ return templates.map((template) => ({
9388
+ id: template.id ?? "",
9389
+ name: template.name ?? "",
9390
+ assetCount: Array.isArray(template.assets) ? template.assets.length : 0,
9391
+ updatedAt: template.updatedAt ?? ""
9392
+ }));
9393
+ }
9394
+ function resolveTemplate(templates, selector) {
9395
+ if (selector.kind === "uuid") {
9396
+ const match = templates.find((template) => template.id === selector.value);
9397
+ if (match) {
9398
+ return match;
9399
+ }
9400
+ throw new CliError(
9401
+ "invalid_cli_usage",
9402
+ `Document template "${selector.value}" was not found.`
9403
+ );
9404
+ }
9405
+ const matches = templates.filter((template) => template.name === selector.value);
9406
+ if (matches.length === 1) {
9407
+ return matches[0];
9408
+ }
9409
+ if (matches.length > 1) {
9410
+ throw new CliError(
9411
+ "invalid_cli_usage",
9412
+ `Document template "${selector.value}" is ambiguous. Found ${matches.length} matches.`
9413
+ );
9414
+ }
9415
+ throw new CliError(
9416
+ "invalid_cli_usage",
9417
+ `Document template "${selector.value}" was not found.`
9418
+ );
9419
+ }
9420
+ async function resolveTemplateSelector(api, selector) {
9421
+ if (selector.kind === "uuid") {
9422
+ return selector;
9423
+ }
9424
+ const templates = await api.listTemplates();
9425
+ const resolved = resolveTemplate(templates, selector);
9426
+ if (typeof resolved.id !== "string" || resolved.id.length === 0) {
9427
+ throw new CliError(
9428
+ "invalid_cli_usage",
9429
+ `Document template "${selector.value}" is missing an id in the API response.`
9430
+ );
9431
+ }
9432
+ return { kind: "uuid", value: resolved.id };
9433
+ }
9434
+ function buildCreateInput(options) {
9435
+ const raw = readJsonObjectOption2(options.raw, options.rawFile, "--raw", "--raw-file");
9436
+ const input = { ...raw };
9437
+ if (options.name !== void 0) {
9438
+ input.name = options.name;
9439
+ }
9440
+ if (typeof input.name !== "string" || input.name.trim().length === 0) {
9441
+ throw new CliError("invalid_cli_usage", 'Provide template name via "--name".');
9442
+ }
9443
+ if (input.assets === void 0) {
9444
+ input.assets = [];
9445
+ }
9446
+ return input;
9447
+ }
9448
+ function buildUpdateInput(options) {
9449
+ const input = {};
9450
+ if (options.name !== void 0) {
9451
+ input.name = options.name;
9452
+ }
9453
+ if (isEmptyObject4(input)) {
9454
+ throw new CliError("invalid_cli_usage", 'Provide template updates via "--name".');
9455
+ }
9456
+ return input;
9457
+ }
9458
+ function registerDocumentTemplatesCommands(program, options = {}) {
9459
+ const filePath = options.configPath ?? defaultConfigPath;
9460
+ const stdout = getCommandIo5(options.stdout);
9461
+ const templates = program.command("document-templates").description("Manage document templates and their assets");
9462
+ templates.command("list").description("List document templates").action(async function action() {
9463
+ const { api, json } = createDocumentTemplatesApi(this, filePath);
9464
+ const data = await api.listTemplates();
9465
+ if (json) {
9466
+ emitJson5(stdout, "document-templates list", data, filePath);
9467
+ return;
9468
+ }
9469
+ printTable(templateRows(data), ["id", "name", "assetCount", "updatedAt"], stdout);
9470
+ });
9471
+ 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) {
9472
+ const { api, json } = createDocumentTemplatesApi(this, filePath);
9473
+ const list = await api.listTemplates();
9474
+ const data = resolveTemplate(list, template);
9475
+ if (json) {
9476
+ emitJson5(stdout, "document-templates get", data, filePath);
9477
+ return;
9478
+ }
9479
+ printTable([data], void 0, stdout);
9480
+ });
9481
+ 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) {
9482
+ const { api, json, readOnly } = createDocumentTemplatesApi(this, filePath);
9483
+ ensureWritable4("document-templates create", readOnly, "write");
9484
+ const data = await api.createTemplate(buildCreateInput(commandOptions));
9485
+ if (json) {
9486
+ emitJson5(stdout, "document-templates create", data, filePath);
8705
9487
  return;
8706
9488
  }
8707
- writeLine4(stdout, `Updated navigation target "${targetId}".`);
9489
+ writeLine5(stdout, `Created document template "${String(data.name ?? commandOptions.name)}".`);
8708
9490
  });
8709
- targets.command("delete").description("Delete navigation target").argument("<display>", "display uuid or slug", parseUuidOrSlugSelector3).argument("<target>", "target id").action(async function action(display, targetId) {
8710
- const { api, json, readOnly } = createDisplaysApi(this, filePath);
8711
- ensureWritable3("displays navigation-targets delete", readOnly, "destructive");
8712
- const data = await api.deleteNavigationTarget(display, targetId);
9491
+ 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) {
9492
+ const { api, json, readOnly } = createDocumentTemplatesApi(this, filePath);
9493
+ ensureWritable4("document-templates update", readOnly, "write");
9494
+ const resolved = await resolveTemplateSelector(api, template);
9495
+ const data = await api.updateTemplate(resolved, buildUpdateInput(commandOptions));
8713
9496
  if (json) {
8714
- emitJson4(stdout, "displays navigation-targets delete", data);
9497
+ emitJson5(stdout, "document-templates update", data, filePath);
8715
9498
  return;
8716
9499
  }
8717
- writeLine4(stdout, `Deleted navigation target "${targetId}".`);
9500
+ writeLine5(stdout, `Updated document template "${String(data.name ?? template.value)}".`);
8718
9501
  });
8719
- const cross = displays.command("cross-widget-filter").description("Manage cross widget filter");
8720
- cross.command("get").description("Get cross widget filter").argument("<display>", "display uuid or slug", parseUuidOrSlugSelector3).action(async function action(display) {
8721
- const { api, json } = createDisplaysApi(this, filePath);
8722
- const data = await api.getDisplay(display);
8723
- const item = data.crossWidgetFilter ?? null;
9502
+ templates.command("delete").description("Delete a document template (and its assets)").argument("<template>", "template UUID or exact name", parseUuidOrSlugSelector4).action(async function action(template) {
9503
+ const { api, json, readOnly } = createDocumentTemplatesApi(this, filePath);
9504
+ ensureWritable4("document-templates delete", readOnly, "destructive");
9505
+ const resolved = await resolveTemplateSelector(api, template);
9506
+ const data = await api.deleteTemplate(resolved);
8724
9507
  if (json) {
8725
- emitJson4(stdout, "displays cross-widget-filter get", item);
9508
+ emitJson5(stdout, "document-templates delete", data, filePath);
8726
9509
  return;
8727
9510
  }
8728
- printTable(item ? [item] : [], void 0, stdout);
9511
+ writeLine5(stdout, `Deleted document template "${template.value}".`);
8729
9512
  });
8730
- cross.command("set").description("Set cross widget filter").argument("<display>", "display uuid or slug", parseUuidOrSlugSelector3).requiredOption("--source-widget <id>").requiredOption("--source-field <id>").requiredOption("--target <widget:field>", "repeatable target", (v, p = []) => [...p, v], []).action(async function action(display, commandOptions) {
8731
- const { api, json, readOnly } = createDisplaysApi(this, filePath);
8732
- ensureWritable3("displays cross-widget-filter set", readOnly, "write");
8733
- const data = await api.setCrossWidgetFilter(display, buildCrossWidgetFilterBody(commandOptions));
9513
+ const assets = templates.command("assets").description("Manage document template assets");
9514
+ 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) {
9515
+ const { api, json, readOnly } = createDocumentTemplatesApi(this, filePath);
9516
+ ensureWritable4("document-templates assets add", readOnly, "write");
9517
+ const contents = readLocalFile(localPath);
9518
+ const formData = new FormData();
9519
+ formData.append("file", new Blob([contents]), basename(localPath));
9520
+ if (commandOptions.name !== void 0) {
9521
+ formData.append("name", commandOptions.name);
9522
+ }
9523
+ const resolved = await resolveTemplateSelector(api, template);
9524
+ const data = await api.addAsset(resolved, formData);
8734
9525
  if (json) {
8735
- emitJson4(stdout, "displays cross-widget-filter set", data);
9526
+ emitJson5(stdout, "document-templates assets add", data, filePath);
8736
9527
  return;
8737
9528
  }
8738
- writeLine4(stdout, `Updated cross widget filter for display "${display.value}".`);
9529
+ writeLine5(
9530
+ stdout,
9531
+ `Added asset "${commandOptions.name ?? basename(localPath)}" to template "${template.value}".`
9532
+ );
8739
9533
  });
8740
- cross.command("delete").description("Delete cross widget filter").argument("<display>", "display uuid or slug", parseUuidOrSlugSelector3).action(async function action(display) {
8741
- const { api, json, readOnly } = createDisplaysApi(this, filePath);
8742
- ensureWritable3("displays cross-widget-filter delete", readOnly, "destructive");
8743
- const data = await api.deleteCrossWidgetFilter(display);
9534
+ 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) {
9535
+ const { api, json, readOnly } = createDocumentTemplatesApi(this, filePath);
9536
+ ensureWritable4("document-templates assets delete", readOnly, "destructive");
9537
+ const resolved = await resolveTemplateSelector(api, template);
9538
+ const data = await api.deleteAsset(resolved, assetId);
8744
9539
  if (json) {
8745
- emitJson4(stdout, "displays cross-widget-filter delete", data);
9540
+ emitJson5(stdout, "document-templates assets delete", data, filePath);
8746
9541
  return;
8747
9542
  }
8748
- writeLine4(stdout, `Deleted cross widget filter for display "${display.value}".`);
9543
+ writeLine5(stdout, `Deleted asset "${assetId}" from template "${template.value}".`);
9544
+ });
9545
+ 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) {
9546
+ const { api, json } = createDocumentTemplatesApi(this, filePath);
9547
+ if (json && !commandOptions.output) {
9548
+ throw new CliError(
9549
+ "invalid_cli_usage",
9550
+ 'Provide "--output" when using "--json" with "document-templates assets download".'
9551
+ );
9552
+ }
9553
+ const resolved = await resolveTemplateSelector(api, template);
9554
+ const data = await api.downloadAsset(resolved, assetId);
9555
+ if (commandOptions.output) {
9556
+ writeDownloadedFile(commandOptions.output, data);
9557
+ if (json) {
9558
+ emitJson5(
9559
+ stdout,
9560
+ "document-templates assets download",
9561
+ {
9562
+ template: resolved.value,
9563
+ asset: assetId,
9564
+ output: commandOptions.output,
9565
+ bytes: data.byteLength
9566
+ },
9567
+ filePath
9568
+ );
9569
+ return;
9570
+ }
9571
+ writeLine5(stdout, `Downloaded asset to "${commandOptions.output}".`);
9572
+ return;
9573
+ }
9574
+ writeBinary(stdout, data);
8749
9575
  });
8750
9576
  }
8751
9577
 
8752
9578
  // src/commands/files.ts
8753
- import { readFileSync as readFileSync5, writeFileSync as writeFileSync2 } from "fs";
8754
- import { basename } from "path";
8755
- import { InvalidArgumentError as InvalidArgumentError4 } from "commander";
9579
+ import { readFileSync as readFileSync6, writeFileSync as writeFileSync3 } from "fs";
9580
+ import { basename as basename2 } from "path";
9581
+ import { InvalidArgumentError as InvalidArgumentError5 } from "commander";
8756
9582
 
8757
9583
  // src/api/files.ts
8758
- function selectorValue4(selector) {
9584
+ function selectorValue5(selector) {
8759
9585
  return selector.value;
8760
9586
  }
8761
9587
  var FilesApi = class {
@@ -8769,11 +9595,11 @@ var FilesApi = class {
8769
9595
  });
8770
9596
  }
8771
9597
  downloadFile(file) {
8772
- return this.client.requestBinary(`/api/v2/files/${selectorValue4(file)}`);
9598
+ return this.client.requestBinary(`/api/v2/files/${selectorValue5(file)}`);
8773
9599
  }
8774
9600
  deleteFile(file) {
8775
9601
  return this.client.requestJson(
8776
- `/api/v2/files/${selectorValue4(file)}`,
9602
+ `/api/v2/files/${selectorValue5(file)}`,
8777
9603
  { method: "DELETE" }
8778
9604
  );
8779
9605
  }
@@ -8783,26 +9609,26 @@ var FilesApi = class {
8783
9609
  };
8784
9610
 
8785
9611
  // src/commands/files.ts
8786
- function getCommandIo5(stdout) {
9612
+ function getCommandIo6(stdout) {
8787
9613
  return stdout ?? process.stdout;
8788
9614
  }
8789
- function writeLine5(stdout, value) {
9615
+ function writeLine6(stdout, value) {
8790
9616
  stdout.write(`${value}
8791
9617
  `);
8792
9618
  }
8793
- function writeBinary(stdout, value) {
9619
+ function writeBinary2(stdout, value) {
8794
9620
  stdout.write(Buffer.from(value));
8795
9621
  }
8796
- function getGlobalOptions5(command) {
9622
+ function getGlobalOptions6(command) {
8797
9623
  return command.optsWithGlobals();
8798
9624
  }
8799
- function emitJson5(stdout, commandName, data, configPath, meta = {}) {
8800
- writeLine5(
9625
+ function emitJson6(stdout, commandName, data, configPath, meta = {}) {
9626
+ writeLine6(
8801
9627
  stdout,
8802
9628
  JSON.stringify(buildJsonSuccess(data, { command: commandName, configPath, ...meta }))
8803
9629
  );
8804
9630
  }
8805
- function toConfigurationError5(filePath, error) {
9631
+ function toConfigurationError6(filePath, error) {
8806
9632
  if (error instanceof CliError) {
8807
9633
  throw error;
8808
9634
  }
@@ -8817,7 +9643,7 @@ function toConfigurationError5(filePath, error) {
8817
9643
  function createFilesApi(command, filePath) {
8818
9644
  try {
8819
9645
  const config = readRuntimeConfig(filePath);
8820
- const runtime = resolveRuntimeContext(config, getGlobalOptions5(command));
9646
+ const runtime = resolveRuntimeContext(config, getGlobalOptions6(command));
8821
9647
  if (!runtime.baseUrl) {
8822
9648
  throw new CliError(
8823
9649
  "configuration_error",
@@ -8835,10 +9661,10 @@ function createFilesApi(command, filePath) {
8835
9661
  readOnly: runtime.readOnly
8836
9662
  };
8837
9663
  } catch (error) {
8838
- toConfigurationError5(filePath, error);
9664
+ toConfigurationError6(filePath, error);
8839
9665
  }
8840
9666
  }
8841
- function ensureWritable4(commandName, readOnly, commandMode) {
9667
+ function ensureWritable5(commandName, readOnly, commandMode) {
8842
9668
  if (readOnly) {
8843
9669
  throw new CliError(
8844
9670
  "command_not_allowed_in_read_only_mode",
@@ -8850,28 +9676,28 @@ function ensureWritable4(commandName, readOnly, commandMode) {
8850
9676
  );
8851
9677
  }
8852
9678
  }
8853
- function parseUuidOrSlugSelector4(input) {
9679
+ function parseUuidOrSlugSelector5(input) {
8854
9680
  try {
8855
9681
  return normalizeUuidOrSlug(input);
8856
9682
  } catch (error) {
8857
9683
  const message = error instanceof Error ? error.message : "Invalid selector.";
8858
- throw new InvalidArgumentError4(message);
9684
+ throw new InvalidArgumentError5(message);
8859
9685
  }
8860
9686
  }
8861
9687
  function isRecord3(value) {
8862
9688
  return typeof value === "object" && value !== null && !Array.isArray(value);
8863
9689
  }
8864
- function readLocalFile(filePath) {
9690
+ function readLocalFile2(filePath) {
8865
9691
  try {
8866
- return readFileSync5(filePath);
9692
+ return readFileSync6(filePath);
8867
9693
  } catch (error) {
8868
9694
  const message = error instanceof Error ? error.message : "Unable to read file.";
8869
9695
  throw new CliError("invalid_cli_usage", `Failed to read file at ${filePath}: ${message}`);
8870
9696
  }
8871
9697
  }
8872
- function writeDownloadedFile(outputPath, value) {
9698
+ function writeDownloadedFile2(outputPath, value) {
8873
9699
  try {
8874
- writeFileSync2(outputPath, Buffer.from(value));
9700
+ writeFileSync3(outputPath, Buffer.from(value));
8875
9701
  } catch (error) {
8876
9702
  const message = error instanceof Error ? error.message : "Unable to write file.";
8877
9703
  throw new CliError(
@@ -8882,20 +9708,20 @@ function writeDownloadedFile(outputPath, value) {
8882
9708
  }
8883
9709
  function registerFilesCommands(program, options = {}) {
8884
9710
  const filePath = options.configPath ?? defaultConfigPath;
8885
- const stdout = getCommandIo5(options.stdout);
9711
+ const stdout = getCommandIo6(options.stdout);
8886
9712
  const files = program.command("files").description("Manage files and storage");
8887
9713
  files.command("upload").description("Upload a local file").argument("<path>", "path to the local file").action(function action(path) {
8888
9714
  const { api, json, readOnly } = createFilesApi(this, filePath);
8889
- ensureWritable4("files upload", readOnly, "write");
8890
- const contents = readLocalFile(path);
9715
+ ensureWritable5("files upload", readOnly, "write");
9716
+ const contents = readLocalFile2(path);
8891
9717
  const formData = new FormData();
8892
- formData.append("file", new Blob([contents]), basename(path));
9718
+ formData.append("file", new Blob([contents]), basename2(path));
8893
9719
  return api.uploadFile(formData).then((data) => {
8894
9720
  if (json) {
8895
- emitJson5(stdout, "files upload", data, filePath);
9721
+ emitJson6(stdout, "files upload", data, filePath);
8896
9722
  return;
8897
9723
  }
8898
- writeLine5(stdout, `Uploaded file "${basename(path)}".`);
9724
+ writeLine6(stdout, `Uploaded file "${basename2(path)}".`);
8899
9725
  });
8900
9726
  });
8901
9727
  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) {
@@ -8906,12 +9732,12 @@ function registerFilesCommands(program, options = {}) {
8906
9732
  'Provide "--output" when using "--json" with "files download".'
8907
9733
  );
8908
9734
  }
8909
- const fileSelector = parseUuidOrSlugSelector4(file);
9735
+ const fileSelector = parseUuidOrSlugSelector5(file);
8910
9736
  return api.downloadFile(fileSelector).then((data) => {
8911
9737
  if (commandOptions.output) {
8912
- writeDownloadedFile(commandOptions.output, data);
9738
+ writeDownloadedFile2(commandOptions.output, data);
8913
9739
  if (json) {
8914
- emitJson5(
9740
+ emitJson6(
8915
9741
  stdout,
8916
9742
  "files download",
8917
9743
  {
@@ -8923,45 +9749,45 @@ function registerFilesCommands(program, options = {}) {
8923
9749
  );
8924
9750
  return;
8925
9751
  }
8926
- writeLine5(stdout, `Downloaded file to "${commandOptions.output}".`);
9752
+ writeLine6(stdout, `Downloaded file to "${commandOptions.output}".`);
8927
9753
  return;
8928
9754
  }
8929
- writeBinary(stdout, data);
9755
+ writeBinary2(stdout, data);
8930
9756
  });
8931
9757
  });
8932
9758
  files.command("delete").description("Delete a file").argument("<file>", "file identifier").action(function action(file) {
8933
9759
  const { api, json, readOnly } = createFilesApi(this, filePath);
8934
- ensureWritable4("files delete", readOnly, "destructive");
8935
- const fileSelector = parseUuidOrSlugSelector4(file);
9760
+ ensureWritable5("files delete", readOnly, "destructive");
9761
+ const fileSelector = parseUuidOrSlugSelector5(file);
8936
9762
  return api.deleteFile(fileSelector).then((data) => {
8937
9763
  if (json) {
8938
- emitJson5(stdout, "files delete", data, filePath);
9764
+ emitJson6(stdout, "files delete", data, filePath);
8939
9765
  return;
8940
9766
  }
8941
- writeLine5(stdout, `Deleted file "${fileSelector.value}".`);
9767
+ writeLine6(stdout, `Deleted file "${fileSelector.value}".`);
8942
9768
  });
8943
9769
  });
8944
9770
  files.command("storage").description("Show storage usage information").action(function action() {
8945
9771
  const { api, json } = createFilesApi(this, filePath);
8946
9772
  return api.getStorageInfo().then((data) => {
8947
9773
  if (json) {
8948
- emitJson5(stdout, "files storage", data, filePath);
9774
+ emitJson6(stdout, "files storage", data, filePath);
8949
9775
  return;
8950
9776
  }
8951
9777
  if (isRecord3(data)) {
8952
9778
  printTable([data], Object.keys(data), stdout);
8953
9779
  return;
8954
9780
  }
8955
- writeLine5(stdout, String(data));
9781
+ writeLine6(stdout, String(data));
8956
9782
  });
8957
9783
  });
8958
9784
  }
8959
9785
 
8960
9786
  // src/commands/logs.ts
8961
- import { InvalidArgumentError as InvalidArgumentError5 } from "commander";
9787
+ import { InvalidArgumentError as InvalidArgumentError6 } from "commander";
8962
9788
 
8963
9789
  // src/api/logs.ts
8964
- function selectorValue5(selector) {
9790
+ function selectorValue6(selector) {
8965
9791
  return selector.value;
8966
9792
  }
8967
9793
  var LogsApi = class {
@@ -8970,29 +9796,29 @@ var LogsApi = class {
8970
9796
  }
8971
9797
  listLogs(schema, recordId) {
8972
9798
  return this.client.getJson(
8973
- `/api/v2/schemas/${selectorValue5(schema)}/records/${recordId}/logs`
9799
+ `/api/v2/schemas/${selectorValue6(schema)}/records/${recordId}/logs`
8974
9800
  );
8975
9801
  }
8976
9802
  };
8977
9803
 
8978
9804
  // src/commands/logs.ts
8979
- function getCommandIo6(stdout) {
9805
+ function getCommandIo7(stdout) {
8980
9806
  return stdout ?? process.stdout;
8981
9807
  }
8982
- function writeLine6(stdout, value) {
9808
+ function writeLine7(stdout, value) {
8983
9809
  stdout.write(`${value}
8984
9810
  `);
8985
9811
  }
8986
- function getGlobalOptions6(command) {
9812
+ function getGlobalOptions7(command) {
8987
9813
  return command.optsWithGlobals();
8988
9814
  }
8989
- function emitJson6(stdout, commandName, data, ..._extra) {
8990
- writeLine6(
9815
+ function emitJson7(stdout, commandName, data, ..._extra) {
9816
+ writeLine7(
8991
9817
  stdout,
8992
9818
  JSON.stringify(buildJsonSuccess(data, { command: commandName }))
8993
9819
  );
8994
9820
  }
8995
- function toConfigurationError6(filePath, error) {
9821
+ function toConfigurationError7(filePath, error) {
8996
9822
  if (error instanceof CliError) {
8997
9823
  throw error;
8998
9824
  }
@@ -9007,7 +9833,7 @@ function toConfigurationError6(filePath, error) {
9007
9833
  function createLogsApi(command, filePath) {
9008
9834
  try {
9009
9835
  const config = readRuntimeConfig(filePath);
9010
- const runtime = resolveRuntimeContext(config, getGlobalOptions6(command));
9836
+ const runtime = resolveRuntimeContext(config, getGlobalOptions7(command));
9011
9837
  if (!runtime.baseUrl) {
9012
9838
  throw new CliError(
9013
9839
  "configuration_error",
@@ -9024,25 +9850,25 @@ function createLogsApi(command, filePath) {
9024
9850
  json: runtime.json
9025
9851
  };
9026
9852
  } catch (error) {
9027
- toConfigurationError6(filePath, error);
9853
+ toConfigurationError7(filePath, error);
9028
9854
  }
9029
9855
  }
9030
- function parseUuidOrSlugSelector5(input) {
9856
+ function parseUuidOrSlugSelector6(input) {
9031
9857
  try {
9032
9858
  return normalizeUuidOrSlug(input);
9033
9859
  } catch (error) {
9034
9860
  const message = error instanceof Error ? error.message : "Invalid selector.";
9035
- throw new InvalidArgumentError5(message);
9861
+ throw new InvalidArgumentError6(message);
9036
9862
  }
9037
9863
  }
9038
- function isJsonObject4(value) {
9864
+ function isJsonObject5(value) {
9039
9865
  return typeof value === "object" && value !== null && !Array.isArray(value);
9040
9866
  }
9041
9867
  function toTableRows3(data) {
9042
9868
  if (Array.isArray(data)) {
9043
- return data.map((entry) => isJsonObject4(entry) ? entry : { value: entry });
9869
+ return data.map((entry) => isJsonObject5(entry) ? entry : { value: entry });
9044
9870
  }
9045
- if (isJsonObject4(data)) {
9871
+ if (isJsonObject5(data)) {
9046
9872
  return [data];
9047
9873
  }
9048
9874
  return [{ value: data }];
@@ -9052,13 +9878,13 @@ function emitTable3(stdout, data) {
9052
9878
  }
9053
9879
  function registerLogsCommands(program, options = {}) {
9054
9880
  const filePath = options.configPath ?? defaultConfigPath;
9055
- const stdout = getCommandIo6(options.stdout);
9881
+ const stdout = getCommandIo7(options.stdout);
9056
9882
  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) {
9883
+ 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
9884
  const { api, json } = createLogsApi(this, filePath);
9059
9885
  const data = await api.listLogs(schema, record.value);
9060
9886
  if (json) {
9061
- emitJson6(stdout, "logs list", data, filePath);
9887
+ emitJson7(stdout, "logs list", data, filePath);
9062
9888
  return;
9063
9889
  }
9064
9890
  emitTable3(stdout, data);
@@ -9066,11 +9892,11 @@ function registerLogsCommands(program, options = {}) {
9066
9892
  }
9067
9893
 
9068
9894
  // src/commands/navigation.ts
9069
- import { readFileSync as readFileSync6 } from "fs";
9070
- import { InvalidArgumentError as InvalidArgumentError6 } from "commander";
9895
+ import { readFileSync as readFileSync7 } from "fs";
9896
+ import { InvalidArgumentError as InvalidArgumentError7 } from "commander";
9071
9897
 
9072
9898
  // src/api/navigation.ts
9073
- function jsonOptions4(body, method) {
9899
+ function jsonOptions5(body, method) {
9074
9900
  return {
9075
9901
  method,
9076
9902
  headers: {
@@ -9079,7 +9905,7 @@ function jsonOptions4(body, method) {
9079
9905
  body: JSON.stringify(body)
9080
9906
  };
9081
9907
  }
9082
- function selectorValue6(selector) {
9908
+ function selectorValue7(selector) {
9083
9909
  return selector.value;
9084
9910
  }
9085
9911
  var NavigationApi = class {
@@ -9092,44 +9918,44 @@ var NavigationApi = class {
9092
9918
  createFolder(body) {
9093
9919
  return this.client.requestJson(
9094
9920
  "/api/v2/navigation/folders",
9095
- jsonOptions4(body, "POST")
9921
+ jsonOptions5(body, "POST")
9096
9922
  );
9097
9923
  }
9098
9924
  updateFolder(folder, body) {
9099
9925
  return this.client.requestJson(
9100
- `/api/v2/navigation/folders/${selectorValue6(folder)}`,
9101
- jsonOptions4(body, "PATCH")
9926
+ `/api/v2/navigation/folders/${selectorValue7(folder)}`,
9927
+ jsonOptions5(body, "PATCH")
9102
9928
  );
9103
9929
  }
9104
9930
  deleteFolder(folder) {
9105
9931
  return this.client.requestJson(
9106
- `/api/v2/navigation/folders/${selectorValue6(folder)}`,
9932
+ `/api/v2/navigation/folders/${selectorValue7(folder)}`,
9107
9933
  { method: "DELETE" }
9108
9934
  );
9109
9935
  }
9110
9936
  moveResource(body) {
9111
9937
  return this.client.requestJson(
9112
9938
  "/api/v2/navigation/resources:move",
9113
- jsonOptions4(body, "POST")
9939
+ jsonOptions5(body, "POST")
9114
9940
  );
9115
9941
  }
9116
9942
  };
9117
9943
 
9118
9944
  // src/commands/navigation.ts
9119
- function getCommandIo7(stdout) {
9945
+ function getCommandIo8(stdout) {
9120
9946
  return stdout ?? process.stdout;
9121
9947
  }
9122
- function writeLine7(stdout, value) {
9948
+ function writeLine8(stdout, value) {
9123
9949
  stdout.write(`${value}
9124
9950
  `);
9125
9951
  }
9126
- function getGlobalOptions7(command) {
9952
+ function getGlobalOptions8(command) {
9127
9953
  return command.optsWithGlobals();
9128
9954
  }
9129
- function emitJson7(stdout, commandName, data, configPath) {
9130
- writeLine7(stdout, JSON.stringify(buildJsonSuccess(data, { command: commandName, configPath })));
9955
+ function emitJson8(stdout, commandName, data, configPath) {
9956
+ writeLine8(stdout, JSON.stringify(buildJsonSuccess(data, { command: commandName, configPath })));
9131
9957
  }
9132
- function toConfigurationError7(filePath, error) {
9958
+ function toConfigurationError8(filePath, error) {
9133
9959
  if (error instanceof CliError) {
9134
9960
  throw error;
9135
9961
  }
@@ -9144,7 +9970,7 @@ function toConfigurationError7(filePath, error) {
9144
9970
  function createNavigationApi(command, filePath) {
9145
9971
  try {
9146
9972
  const config = readRuntimeConfig(filePath);
9147
- const runtime = resolveRuntimeContext(config, getGlobalOptions7(command));
9973
+ const runtime = resolveRuntimeContext(config, getGlobalOptions8(command));
9148
9974
  if (!runtime.baseUrl) {
9149
9975
  throw new CliError("configuration_error", `Resolved profile "${runtime.profile}" is missing a base URL.`);
9150
9976
  }
@@ -9159,10 +9985,10 @@ function createNavigationApi(command, filePath) {
9159
9985
  readOnly: runtime.readOnly
9160
9986
  };
9161
9987
  } catch (error) {
9162
- toConfigurationError7(filePath, error);
9988
+ toConfigurationError8(filePath, error);
9163
9989
  }
9164
9990
  }
9165
- function ensureWritable5(commandName, readOnly, mode) {
9991
+ function ensureWritable6(commandName, readOnly, mode) {
9166
9992
  if (readOnly) {
9167
9993
  throw new CliError(
9168
9994
  "command_not_allowed_in_read_only_mode",
@@ -9171,12 +9997,12 @@ function ensureWritable5(commandName, readOnly, mode) {
9171
9997
  );
9172
9998
  }
9173
9999
  }
9174
- function parseUuidOrSlugSelector6(input) {
10000
+ function parseUuidOrSlugSelector7(input) {
9175
10001
  try {
9176
10002
  return normalizeUuidOrSlug(input);
9177
10003
  } catch (error) {
9178
10004
  const message = error instanceof Error ? error.message : "Invalid selector.";
9179
- throw new InvalidArgumentError6(message);
10005
+ throw new InvalidArgumentError7(message);
9180
10006
  }
9181
10007
  }
9182
10008
  function parseInteger(value, flagName) {
@@ -9193,7 +10019,7 @@ function readJsonObject(raw, rawFile) {
9193
10019
  if (raw && rawFile) {
9194
10020
  throw new CliError("invalid_cli_usage", 'Use either "--props" or "--props-file", not both.');
9195
10021
  }
9196
- const source = rawFile ? readFileSync6(rawFile, "utf8") : raw;
10022
+ const source = rawFile ? readFileSync7(rawFile, "utf8") : raw;
9197
10023
  if (!source) {
9198
10024
  return {};
9199
10025
  }
@@ -9255,41 +10081,41 @@ function folderRows2(folders) {
9255
10081
  }
9256
10082
  function registerNavigationCommands(program, options = {}) {
9257
10083
  const filePath = options.configPath ?? defaultConfigPath;
9258
- const stdout = getCommandIo7(options.stdout);
10084
+ const stdout = getCommandIo8(options.stdout);
9259
10085
  const navigation = program.command("navigation").description("Manage workspace navigation");
9260
10086
  const folders = navigation.command("folders").description("Manage navigation folders");
9261
10087
  folders.command("list").description("List navigation folders").action(async function action() {
9262
10088
  const { api, json } = createNavigationApi(this, filePath);
9263
10089
  const data = await api.listFolders();
9264
10090
  if (json) {
9265
- emitJson7(stdout, "navigation folders list", data, filePath);
10091
+ emitJson8(stdout, "navigation folders list", data, filePath);
9266
10092
  return;
9267
10093
  }
9268
10094
  printTable(folderRows2(data), ["id", "order", "name", "resourceCount"], stdout);
9269
10095
  });
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) {
10096
+ 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
10097
  const { api, json } = createNavigationApi(this, filePath);
9272
10098
  const data = await api.listFolders();
9273
10099
  const resolved = resolveFolder2(data, folder);
9274
10100
  if (json) {
9275
- emitJson7(stdout, "navigation folders get", resolved, filePath);
10101
+ emitJson8(stdout, "navigation folders get", resolved, filePath);
9276
10102
  return;
9277
10103
  }
9278
10104
  printTable(folderRows2([resolved]), ["id", "order", "name", "resourceCount"], stdout);
9279
10105
  });
9280
- 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) {
10106
+ folders.command("create").description("Create a navigation folder").requiredOption("--name <name>", "folder name").option("--order <n>", "display order (lower values appear first)").option("--props <json>", 'additionalProperties JSON: free-form client metadata, e.g. {"color":"blue","icon":"chart-line"}').option("--props-file <path>", "path to a file with the additionalProperties JSON").action(async function action(commandOptions) {
9281
10107
  const { api, json, readOnly } = createNavigationApi(this, filePath);
9282
- ensureWritable5("navigation folders create", readOnly, "write");
10108
+ ensureWritable6("navigation folders create", readOnly, "write");
9283
10109
  const data = await api.createFolder(buildFolderBody(commandOptions));
9284
10110
  if (json) {
9285
- emitJson7(stdout, "navigation folders create", data, filePath);
10111
+ emitJson8(stdout, "navigation folders create", data, filePath);
9286
10112
  return;
9287
10113
  }
9288
- writeLine7(stdout, `Created navigation folder "${String(data.name ?? commandOptions.name)}".`);
10114
+ writeLine8(stdout, `Created navigation folder "${String(data.name ?? commandOptions.name)}".`);
9289
10115
  });
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) {
10116
+ folders.command("update").description("Update a navigation folder").argument("<folder>", "folder UUID or exact name", parseUuidOrSlugSelector7).option("--name <name>", "folder name").option("--order <n>", "display order (lower values appear first)").option("--props <json>", 'additionalProperties JSON: free-form client metadata, e.g. {"color":"blue","icon":"chart-line"}').option("--props-file <path>", "path to a file with the additionalProperties JSON").action(async function action(folder, commandOptions) {
9291
10117
  const { api, json, readOnly } = createNavigationApi(this, filePath);
9292
- ensureWritable5("navigation folders update", readOnly, "write");
10118
+ ensureWritable6("navigation folders update", readOnly, "write");
9293
10119
  const allFolders = await api.listFolders();
9294
10120
  const resolved = resolveFolder2(allFolders, folder);
9295
10121
  const body = buildFolderBody(commandOptions);
@@ -9298,54 +10124,55 @@ function registerNavigationCommands(program, options = {}) {
9298
10124
  }
9299
10125
  const data = await api.updateFolder({ kind: "uuid", value: resolved.id }, body);
9300
10126
  if (json) {
9301
- emitJson7(stdout, "navigation folders update", data, filePath);
10127
+ emitJson8(stdout, "navigation folders update", data, filePath);
9302
10128
  return;
9303
10129
  }
9304
- writeLine7(stdout, `Updated navigation folder "${String(data.name ?? resolved.name ?? resolved.id)}".`);
10130
+ writeLine8(stdout, `Updated navigation folder "${String(data.name ?? resolved.name ?? resolved.id)}".`);
9305
10131
  });
9306
- folders.command("delete").description("Delete a navigation folder").argument("<folder>", "folder UUID or exact name", parseUuidOrSlugSelector6).action(async function action(folder) {
10132
+ folders.command("delete").description("Delete a navigation folder").argument("<folder>", "folder UUID or exact name", parseUuidOrSlugSelector7).action(async function action(folder) {
9307
10133
  const { api, json, readOnly } = createNavigationApi(this, filePath);
9308
- ensureWritable5("navigation folders delete", readOnly, "destructive");
10134
+ ensureWritable6("navigation folders delete", readOnly, "destructive");
9309
10135
  const allFolders = await api.listFolders();
9310
10136
  const resolved = resolveFolder2(allFolders, folder);
9311
10137
  const data = await api.deleteFolder({ kind: "uuid", value: resolved.id });
9312
10138
  if (json) {
9313
- emitJson7(stdout, "navigation folders delete", data, filePath);
10139
+ emitJson8(stdout, "navigation folders delete", data, filePath);
9314
10140
  return;
9315
10141
  }
9316
- writeLine7(stdout, `Deleted navigation folder "${resolved.name ?? resolved.id}".`);
10142
+ writeLine8(stdout, `Deleted navigation folder "${resolved.name ?? resolved.id}".`);
9317
10143
  });
9318
- 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) {
10144
+ navigation.command("resources").description("Manage navigation resources").command("move").description(
10145
+ "Move a schema into a navigation folder. Only schemas can be moved (the navigation menu holds databases); schedules and sub-schemas follow their parent schema. Use the root folder UUID 00000000-0000-0000-0000-000000000000 to move it back to the workspace root."
10146
+ ).argument("<resource>", "schema UUID").requiredOption("--to <folder>", "target folder UUID or exact name").action(async function action(resourceId, commandOptions) {
9319
10147
  const { api, json, readOnly } = createNavigationApi(this, filePath);
9320
- ensureWritable5("navigation resources move", readOnly, "write");
10148
+ ensureWritable6("navigation resources move", readOnly, "write");
9321
10149
  const allFolders = await api.listFolders();
9322
- const resolved = resolveFolder2(allFolders, parseUuidOrSlugSelector6(commandOptions.to));
10150
+ const resolved = resolveFolder2(allFolders, parseUuidOrSlugSelector7(commandOptions.to));
9323
10151
  const data = await api.moveResource({
9324
10152
  resourceId,
9325
- resourceType: commandOptions.type.toUpperCase(),
9326
10153
  targetFolderId: resolved.id
9327
10154
  });
9328
10155
  if (json) {
9329
- emitJson7(stdout, "navigation resources move", data, filePath);
10156
+ emitJson8(stdout, "navigation resources move", data, filePath);
9330
10157
  return;
9331
10158
  }
9332
- writeLine7(stdout, `Moved resource "${resourceId}" to "${resolved.name ?? resolved.id}".`);
10159
+ writeLine8(stdout, `Moved resource "${resourceId}" to "${resolved.name ?? resolved.id}".`);
9333
10160
  });
9334
10161
  }
9335
10162
 
9336
10163
  // src/commands/profiles.ts
9337
- function getCommandIo8(stdout) {
10164
+ function getCommandIo9(stdout) {
9338
10165
  return stdout ?? process.stdout;
9339
10166
  }
9340
- function writeLine8(stdout, value) {
10167
+ function writeLine9(stdout, value) {
9341
10168
  stdout.write(`${value}
9342
10169
  `);
9343
10170
  }
9344
- function getGlobalOptions8(command) {
10171
+ function getGlobalOptions9(command) {
9345
10172
  return command.optsWithGlobals();
9346
10173
  }
9347
- function emitJson8(stdout, commandName, data, configPath) {
9348
- writeLine8(
10174
+ function emitJson9(stdout, commandName, data, configPath) {
10175
+ writeLine9(
9349
10176
  stdout,
9350
10177
  JSON.stringify(buildJsonSuccess(data, { command: commandName, configPath }))
9351
10178
  );
@@ -9401,15 +10228,15 @@ function emitProfilesTable(stdout, data) {
9401
10228
  }
9402
10229
  function registerProfilesCommands(program, options = {}) {
9403
10230
  const filePath = options.configPath ?? defaultConfigPath;
9404
- const stdout = getCommandIo8(options.stdout);
10231
+ const stdout = getCommandIo9(options.stdout);
9405
10232
  const profiles = program.command("profiles").description("Manage local CLI profiles");
9406
10233
  profiles.command("list").description("List configured profiles").action(function action() {
9407
10234
  const config = readRequiredConfig(filePath);
9408
10235
  const data = Object.entries(config.profiles).map(
9409
10236
  ([name, profile]) => toDisplayProfile(name, profile, config.defaultProfile)
9410
10237
  );
9411
- if (getGlobalOptions8(this).json) {
9412
- emitJson8(stdout, "profiles list", data, filePath);
10238
+ if (getGlobalOptions9(this).json) {
10239
+ emitJson9(stdout, "profiles list", data, filePath);
9413
10240
  return;
9414
10241
  }
9415
10242
  emitProfilesTable(stdout, data);
@@ -9418,8 +10245,8 @@ function registerProfilesCommands(program, options = {}) {
9418
10245
  const config = readRequiredConfig(filePath);
9419
10246
  const profile = getRequiredProfile(config, profileName);
9420
10247
  const data = toDisplayProfile(profileName, profile, config.defaultProfile);
9421
- if (getGlobalOptions8(this).json) {
9422
- emitJson8(stdout, "profiles get", data, filePath);
10248
+ if (getGlobalOptions9(this).json) {
10249
+ emitJson9(stdout, "profiles get", data, filePath);
9423
10250
  return;
9424
10251
  }
9425
10252
  emitProfilesTable(stdout, [data]);
@@ -9433,11 +10260,11 @@ function registerProfilesCommands(program, options = {}) {
9433
10260
  profile: profileName,
9434
10261
  defaultProfile: nextConfig.defaultProfile
9435
10262
  };
9436
- if (getGlobalOptions8(this).json) {
9437
- emitJson8(stdout, "profiles use", data, filePath);
10263
+ if (getGlobalOptions9(this).json) {
10264
+ emitJson9(stdout, "profiles use", data, filePath);
9438
10265
  return;
9439
10266
  }
9440
- writeLine8(stdout, `Using profile "${profileName}".`);
10267
+ writeLine9(stdout, `Using profile "${profileName}".`);
9441
10268
  });
9442
10269
  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
10270
  const config = loadConfigForAdd(filePath);
@@ -9461,11 +10288,11 @@ function registerProfilesCommands(program, options = {}) {
9461
10288
  nextConfig.profiles[profileName] ?? {},
9462
10289
  nextConfig.defaultProfile
9463
10290
  );
9464
- if (getGlobalOptions8(this).json) {
9465
- emitJson8(stdout, "profiles add", data, filePath);
10291
+ if (getGlobalOptions9(this).json) {
10292
+ emitJson9(stdout, "profiles add", data, filePath);
9466
10293
  return;
9467
10294
  }
9468
- writeLine8(stdout, `Added profile "${profileName}".`);
10295
+ writeLine9(stdout, `Added profile "${profileName}".`);
9469
10296
  });
9470
10297
  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
10298
  if (commandOptions.apiKey === void 0 && commandOptions.baseUrl === void 0) {
@@ -9487,11 +10314,11 @@ function registerProfilesCommands(program, options = {}) {
9487
10314
  nextConfig.profiles[profileName] ?? {},
9488
10315
  nextConfig.defaultProfile
9489
10316
  );
9490
- if (getGlobalOptions8(this).json) {
9491
- emitJson8(stdout, "profiles update", data, filePath);
10317
+ if (getGlobalOptions9(this).json) {
10318
+ emitJson9(stdout, "profiles update", data, filePath);
9492
10319
  return;
9493
10320
  }
9494
- writeLine8(stdout, `Updated profile "${profileName}".`);
10321
+ writeLine9(stdout, `Updated profile "${profileName}".`);
9495
10322
  });
9496
10323
  profiles.command("remove").description("Remove a profile from the local config").argument("<profile>", "profile name").action(function action(profileName) {
9497
10324
  const config = readRequiredConfig(filePath);
@@ -9502,20 +10329,20 @@ function registerProfilesCommands(program, options = {}) {
9502
10329
  profile: profileName,
9503
10330
  defaultProfile: nextConfig.defaultProfile
9504
10331
  };
9505
- if (getGlobalOptions8(this).json) {
9506
- emitJson8(stdout, "profiles remove", data, filePath);
10332
+ if (getGlobalOptions9(this).json) {
10333
+ emitJson9(stdout, "profiles remove", data, filePath);
9507
10334
  return;
9508
10335
  }
9509
- writeLine8(stdout, `Removed profile "${profileName}".`);
10336
+ writeLine9(stdout, `Removed profile "${profileName}".`);
9510
10337
  });
9511
10338
  }
9512
10339
 
9513
10340
  // src/commands/records.ts
9514
- import { readFileSync as readFileSync7 } from "fs";
9515
- import { InvalidArgumentError as InvalidArgumentError7 } from "commander";
10341
+ import { readFileSync as readFileSync8 } from "fs";
10342
+ import { InvalidArgumentError as InvalidArgumentError8 } from "commander";
9516
10343
 
9517
10344
  // src/api/records.ts
9518
- function jsonOptions5(body, method) {
10345
+ function jsonOptions6(body, method) {
9519
10346
  return {
9520
10347
  method,
9521
10348
  headers: {
@@ -9524,7 +10351,7 @@ function jsonOptions5(body, method) {
9524
10351
  body: JSON.stringify(body)
9525
10352
  };
9526
10353
  }
9527
- function selectorValue7(selector) {
10354
+ function selectorValue8(selector) {
9528
10355
  return selector.value;
9529
10356
  }
9530
10357
  var RecordsApi = class {
@@ -9539,7 +10366,7 @@ var RecordsApi = class {
9539
10366
  if (query.offset !== void 0) {
9540
10367
  params.set("offset", String(query.offset));
9541
10368
  }
9542
- const path = `/api/v2/schemas/${selectorValue7(schema)}/records`;
10369
+ const path = `/api/v2/schemas/${selectorValue8(schema)}/records`;
9543
10370
  const queryString = params.toString();
9544
10371
  return this.client.getJson(
9545
10372
  queryString ? `${path}?${queryString}` : path
@@ -9548,36 +10375,36 @@ var RecordsApi = class {
9548
10375
  queryRecords(schema, query) {
9549
10376
  const body = this.normalizeQueryInput(query);
9550
10377
  return this.client.requestJson(
9551
- `/api/v2/schemas/${selectorValue7(schema)}/records:query`,
9552
- jsonOptions5(body, "POST")
10378
+ `/api/v2/schemas/${selectorValue8(schema)}/records:query`,
10379
+ jsonOptions6(body, "POST")
9553
10380
  );
9554
10381
  }
9555
10382
  getRecord(schema, record) {
9556
10383
  return this.client.getJson(
9557
- `/api/v2/schemas/${selectorValue7(schema)}/records/${selectorValue7(record)}`
10384
+ `/api/v2/schemas/${selectorValue8(schema)}/records/${selectorValue8(record)}`
9558
10385
  );
9559
10386
  }
9560
10387
  createRecord(schema, input) {
9561
10388
  return this.client.requestJson(
9562
- `/api/v2/schemas/${selectorValue7(schema)}/records`,
9563
- jsonOptions5(input, "POST")
10389
+ `/api/v2/schemas/${selectorValue8(schema)}/records`,
10390
+ jsonOptions6(input, "POST")
9564
10391
  );
9565
10392
  }
9566
10393
  updateRecord(schema, record, input) {
9567
10394
  return this.client.requestJson(
9568
- `/api/v2/schemas/${selectorValue7(schema)}/records/${selectorValue7(record)}`,
9569
- jsonOptions5(input, "PATCH")
10395
+ `/api/v2/schemas/${selectorValue8(schema)}/records/${selectorValue8(record)}`,
10396
+ jsonOptions6(input, "PATCH")
9570
10397
  );
9571
10398
  }
9572
10399
  deleteRecord(schema, record) {
9573
10400
  return this.client.requestJson(
9574
- `/api/v2/schemas/${selectorValue7(schema)}/records/${selectorValue7(record)}`,
10401
+ `/api/v2/schemas/${selectorValue8(schema)}/records/${selectorValue8(record)}`,
9575
10402
  { method: "DELETE" }
9576
10403
  );
9577
10404
  }
9578
10405
  clearRecords(schema) {
9579
10406
  return this.client.requestJson(
9580
- `/api/v2/schemas/${selectorValue7(schema)}/records:clear`,
10407
+ `/api/v2/schemas/${selectorValue8(schema)}/records:clear`,
9581
10408
  { method: "DELETE" }
9582
10409
  );
9583
10410
  }
@@ -9610,7 +10437,7 @@ var RecordsApi = class {
9610
10437
  };
9611
10438
 
9612
10439
  // src/api/schemas.ts
9613
- function jsonOptions6(body, method) {
10440
+ function jsonOptions7(body, method) {
9614
10441
  return {
9615
10442
  method,
9616
10443
  headers: {
@@ -9619,7 +10446,7 @@ function jsonOptions6(body, method) {
9619
10446
  body: JSON.stringify(body)
9620
10447
  };
9621
10448
  }
9622
- function selectorValue8(selector) {
10449
+ function selectorValue9(selector) {
9623
10450
  return selector.value;
9624
10451
  }
9625
10452
  var SchemasApi = class {
@@ -9630,20 +10457,20 @@ var SchemasApi = class {
9630
10457
  return this.client.getJson("/api/v2/schemas");
9631
10458
  }
9632
10459
  getSchema(schema) {
9633
- return this.client.getJson(`/api/v2/schemas/${selectorValue8(schema)}`);
10460
+ return this.client.getJson(`/api/v2/schemas/${selectorValue9(schema)}`);
9634
10461
  }
9635
10462
  createSchema(input) {
9636
- return this.client.requestJson("/api/v2/schemas", jsonOptions6(input, "POST"));
10463
+ return this.client.requestJson("/api/v2/schemas", jsonOptions7(input, "POST"));
9637
10464
  }
9638
10465
  updateSchema(schema, input) {
9639
10466
  return this.client.requestJson(
9640
- `/api/v2/schemas/${selectorValue8(schema)}`,
9641
- jsonOptions6(input, "PATCH")
10467
+ `/api/v2/schemas/${selectorValue9(schema)}`,
10468
+ jsonOptions7(input, "PATCH")
9642
10469
  );
9643
10470
  }
9644
10471
  deleteSchema(schema) {
9645
10472
  return this.client.requestJson(
9646
- `/api/v2/schemas/${selectorValue8(schema)}`,
10473
+ `/api/v2/schemas/${selectorValue9(schema)}`,
9647
10474
  { method: "DELETE" }
9648
10475
  );
9649
10476
  }
@@ -9653,47 +10480,47 @@ var SchemasApi = class {
9653
10480
  }
9654
10481
  getField(schema, field) {
9655
10482
  return this.client.getJson(
9656
- `/api/v2/schemas/${selectorValue8(schema)}/fields/${selectorValue8(field)}`
10483
+ `/api/v2/schemas/${selectorValue9(schema)}/fields/${selectorValue9(field)}`
9657
10484
  );
9658
10485
  }
9659
10486
  createField(schema, input) {
9660
10487
  return this.client.requestJson(
9661
- `/api/v2/schemas/${selectorValue8(schema)}/fields`,
9662
- jsonOptions6(input, "POST")
10488
+ `/api/v2/schemas/${selectorValue9(schema)}/fields`,
10489
+ jsonOptions7(input, "POST")
9663
10490
  );
9664
10491
  }
9665
10492
  updateField(schema, field, input) {
9666
10493
  return this.client.requestJson(
9667
- `/api/v2/schemas/${selectorValue8(schema)}/fields/${selectorValue8(field)}`,
9668
- jsonOptions6(input, "PATCH")
10494
+ `/api/v2/schemas/${selectorValue9(schema)}/fields/${selectorValue9(field)}`,
10495
+ jsonOptions7(input, "PATCH")
9669
10496
  );
9670
10497
  }
9671
10498
  deleteField(schema, field) {
9672
10499
  return this.client.requestJson(
9673
- `/api/v2/schemas/${selectorValue8(schema)}/fields/${selectorValue8(field)}`,
10500
+ `/api/v2/schemas/${selectorValue9(schema)}/fields/${selectorValue9(field)}`,
9674
10501
  { method: "DELETE" }
9675
10502
  );
9676
10503
  }
9677
10504
  };
9678
10505
 
9679
10506
  // src/commands/records.ts
9680
- function getCommandIo9(stdout) {
10507
+ function getCommandIo10(stdout) {
9681
10508
  return stdout ?? process.stdout;
9682
10509
  }
9683
- function writeLine9(stdout, value) {
10510
+ function writeLine10(stdout, value) {
9684
10511
  stdout.write(`${value}
9685
10512
  `);
9686
10513
  }
9687
- function getGlobalOptions9(command) {
10514
+ function getGlobalOptions10(command) {
9688
10515
  return command.optsWithGlobals();
9689
10516
  }
9690
- function emitJson9(stdout, commandName, data, configPath, meta = {}) {
9691
- writeLine9(
10517
+ function emitJson10(stdout, commandName, data, configPath, meta = {}) {
10518
+ writeLine10(
9692
10519
  stdout,
9693
10520
  JSON.stringify(buildJsonSuccess(data, { command: commandName, configPath, ...meta }))
9694
10521
  );
9695
10522
  }
9696
- function toConfigurationError8(filePath, error) {
10523
+ function toConfigurationError9(filePath, error) {
9697
10524
  if (error instanceof CliError) {
9698
10525
  throw error;
9699
10526
  }
@@ -9708,7 +10535,7 @@ function toConfigurationError8(filePath, error) {
9708
10535
  function createRecordsApi(command, filePath) {
9709
10536
  try {
9710
10537
  const config = readRuntimeConfig(filePath);
9711
- const runtime = resolveRuntimeContext(config, getGlobalOptions9(command));
10538
+ const runtime = resolveRuntimeContext(config, getGlobalOptions10(command));
9712
10539
  if (!runtime.baseUrl) {
9713
10540
  throw new CliError(
9714
10541
  "configuration_error",
@@ -9727,10 +10554,10 @@ function createRecordsApi(command, filePath) {
9727
10554
  readOnly: runtime.readOnly
9728
10555
  };
9729
10556
  } catch (error) {
9730
- toConfigurationError8(filePath, error);
10557
+ toConfigurationError9(filePath, error);
9731
10558
  }
9732
10559
  }
9733
- function ensureWritable6(commandName, readOnly, commandMode) {
10560
+ function ensureWritable7(commandName, readOnly, commandMode) {
9734
10561
  if (readOnly) {
9735
10562
  throw new CliError(
9736
10563
  "command_not_allowed_in_read_only_mode",
@@ -9742,24 +10569,24 @@ function ensureWritable6(commandName, readOnly, commandMode) {
9742
10569
  );
9743
10570
  }
9744
10571
  }
9745
- function parseUuidOrSlugSelector7(input) {
10572
+ function parseUuidOrSlugSelector8(input) {
9746
10573
  try {
9747
10574
  return normalizeUuidOrSlug(input);
9748
10575
  } catch (error) {
9749
10576
  const message = error instanceof Error ? error.message : "Invalid selector.";
9750
- throw new InvalidArgumentError7(message);
10577
+ throw new InvalidArgumentError8(message);
9751
10578
  }
9752
10579
  }
9753
10580
  function parseNonNegativeInteger2(input) {
9754
10581
  if (!/^\d+$/.test(input.trim())) {
9755
- throw new InvalidArgumentError7(`Expected a non-negative integer, received "${input}".`);
10582
+ throw new InvalidArgumentError8(`Expected a non-negative integer, received "${input}".`);
9756
10583
  }
9757
10584
  return Number(input);
9758
10585
  }
9759
10586
  function parseCommaSeparatedValues(input, label) {
9760
10587
  const values = input.split(",").map((value) => value.trim()).filter(Boolean);
9761
10588
  if (values.length === 0) {
9762
- throw new InvalidArgumentError7(`Expected ${label} to contain at least one value.`);
10589
+ throw new InvalidArgumentError8(`Expected ${label} to contain at least one value.`);
9763
10590
  }
9764
10591
  return values;
9765
10592
  }
@@ -9768,7 +10595,7 @@ function parseExpressionValue(input) {
9768
10595
  return parseExpression(input);
9769
10596
  } catch (error) {
9770
10597
  const message = error instanceof Error ? error.message : "Invalid expression.";
9771
- throw new InvalidArgumentError7(message);
10598
+ throw new InvalidArgumentError8(message);
9772
10599
  }
9773
10600
  }
9774
10601
  function parseKeyValueAssignment(input) {
@@ -9776,7 +10603,7 @@ function parseKeyValueAssignment(input) {
9776
10603
  return parseKeyValue(input);
9777
10604
  } catch (error) {
9778
10605
  const message = error instanceof Error ? error.message : "Invalid assignment.";
9779
- throw new InvalidArgumentError7(message);
10606
+ throw new InvalidArgumentError8(message);
9780
10607
  }
9781
10608
  }
9782
10609
  function parseJsonKeyValueAssignment(input) {
@@ -9784,7 +10611,7 @@ function parseJsonKeyValueAssignment(input) {
9784
10611
  return parseJsonAssignment(input);
9785
10612
  } catch (error) {
9786
10613
  const message = error instanceof Error ? error.message : "Invalid JSON assignment.";
9787
- throw new InvalidArgumentError7(message);
10614
+ throw new InvalidArgumentError8(message);
9788
10615
  }
9789
10616
  }
9790
10617
  function collectStringValues(value, previous = []) {
@@ -9802,7 +10629,7 @@ function collectKeyValueAssignments(value, previous = []) {
9802
10629
  function collectJsonAssignments(value, previous = []) {
9803
10630
  return [...previous, parseJsonKeyValueAssignment(value)];
9804
10631
  }
9805
- function isJsonObject5(value) {
10632
+ function isJsonObject6(value) {
9806
10633
  return typeof value === "object" && value !== null && !Array.isArray(value);
9807
10634
  }
9808
10635
  function parseRawJsonObject2(input, sourceLabel) {
@@ -9816,7 +10643,7 @@ function parseRawJsonObject2(input, sourceLabel) {
9816
10643
  `Failed to parse JSON from ${sourceLabel}: ${message}`
9817
10644
  );
9818
10645
  }
9819
- if (!isJsonObject5(parsed)) {
10646
+ if (!isJsonObject6(parsed)) {
9820
10647
  throw new CliError(
9821
10648
  "invalid_cli_usage",
9822
10649
  `Expected ${sourceLabel} to contain a JSON object.`
@@ -9837,7 +10664,7 @@ function readRawObject3(raw, rawFile) {
9837
10664
  if (rawFile) {
9838
10665
  let contents;
9839
10666
  try {
9840
- contents = readFileSync7(rawFile, "utf8");
10667
+ contents = readFileSync8(rawFile, "utf8");
9841
10668
  } catch (error) {
9842
10669
  const message = error instanceof Error ? error.message : "Unable to read file.";
9843
10670
  throw new CliError(
@@ -9849,7 +10676,7 @@ function readRawObject3(raw, rawFile) {
9849
10676
  }
9850
10677
  return {};
9851
10678
  }
9852
- function isEmptyObject4(value) {
10679
+ function isEmptyObject5(value) {
9853
10680
  return Object.keys(value).length === 0;
9854
10681
  }
9855
10682
  function buildAssignmentObject(assignments = [], jsonAssignments = []) {
@@ -9897,7 +10724,7 @@ function buildRecordCreateInput(options) {
9897
10724
  ...readRawObject3(options.raw, options.rawFile),
9898
10725
  ...buildAssignmentObject(options.set, options.setJson)
9899
10726
  };
9900
- if (isEmptyObject4(values)) {
10727
+ if (isEmptyObject5(values)) {
9901
10728
  throw new CliError(
9902
10729
  "invalid_cli_usage",
9903
10730
  'Provide record fields via "--set", "--set-json", "--raw", or "--raw-file".'
@@ -9910,7 +10737,7 @@ function readRawSetPayload2(raw) {
9910
10737
  if (setValue === void 0) {
9911
10738
  return {};
9912
10739
  }
9913
- if (!isJsonObject5(setValue)) {
10740
+ if (!isJsonObject6(setValue)) {
9914
10741
  throw new CliError(
9915
10742
  "invalid_cli_usage",
9916
10743
  'Expected raw update payload field "set" to be a JSON object.'
@@ -9955,7 +10782,7 @@ function buildRecordUpdateInput(options) {
9955
10782
  } else {
9956
10783
  delete input.unset;
9957
10784
  }
9958
- if (isEmptyObject4(input)) {
10785
+ if (isEmptyObject5(input)) {
9959
10786
  throw new CliError(
9960
10787
  "invalid_cli_usage",
9961
10788
  'Provide record updates via "--set", "--set-json", "--unset", "--raw", or "--raw-file".'
@@ -9965,9 +10792,9 @@ function buildRecordUpdateInput(options) {
9965
10792
  }
9966
10793
  function toTableRows4(data) {
9967
10794
  if (Array.isArray(data)) {
9968
- return data.map((entry) => isJsonObject5(entry) ? entry : { value: entry });
10795
+ return data.map((entry) => isJsonObject6(entry) ? entry : { value: entry });
9969
10796
  }
9970
- if (isJsonObject5(data)) {
10797
+ if (isJsonObject6(data)) {
9971
10798
  return [data];
9972
10799
  }
9973
10800
  return [{ value: data }];
@@ -9997,9 +10824,9 @@ async function resolveSchemaSelector(api, selector) {
9997
10824
  }
9998
10825
  function registerRecordsCommands(program, options = {}) {
9999
10826
  const filePath = options.configPath ?? defaultConfigPath;
10000
- const stdout = getCommandIo9(options.stdout);
10827
+ const stdout = getCommandIo10(options.stdout);
10001
10828
  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) {
10829
+ 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
10830
  const { api, schemasApi, json } = createRecordsApi(this, filePath);
10004
10831
  const resolvedSchema = await resolveSchemaSelector(schemasApi, schema);
10005
10832
  const data = await api.listRecords(
@@ -10008,7 +10835,7 @@ function registerRecordsCommands(program, options = {}) {
10008
10835
  );
10009
10836
  const recordsData = getQueryRecords(data);
10010
10837
  if (json) {
10011
- emitJson9(
10838
+ emitJson10(
10012
10839
  stdout,
10013
10840
  "records list",
10014
10841
  recordsData,
@@ -10019,7 +10846,7 @@ function registerRecordsCommands(program, options = {}) {
10019
10846
  }
10020
10847
  emitTable4(stdout, recordsData);
10021
10848
  });
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) {
10849
+ 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
10850
  const { api, schemasApi, json } = createRecordsApi(this, filePath);
10024
10851
  const resolvedSchema = await resolveSchemaSelector(schemasApi, schema);
10025
10852
  const data = await api.queryRecords(
@@ -10028,7 +10855,7 @@ function registerRecordsCommands(program, options = {}) {
10028
10855
  );
10029
10856
  const recordsData = getQueryRecords(data);
10030
10857
  if (json) {
10031
- emitJson9(
10858
+ emitJson10(
10032
10859
  stdout,
10033
10860
  "records query",
10034
10861
  recordsData,
@@ -10039,33 +10866,33 @@ function registerRecordsCommands(program, options = {}) {
10039
10866
  }
10040
10867
  emitTable4(stdout, recordsData);
10041
10868
  });
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) {
10869
+ 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
10870
  const { api, schemasApi, json } = createRecordsApi(this, filePath);
10044
10871
  const resolvedSchema = await resolveSchemaSelector(schemasApi, schema);
10045
10872
  const data = await api.getRecord(resolvedSchema, record);
10046
10873
  if (json) {
10047
- emitJson9(stdout, "records get", data, filePath);
10874
+ emitJson10(stdout, "records get", data, filePath);
10048
10875
  return;
10049
10876
  }
10050
10877
  emitTable4(stdout, data);
10051
10878
  });
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) {
10879
+ 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
10880
  const { api, schemasApi, json, readOnly } = createRecordsApi(this, filePath);
10054
- ensureWritable6("records create", readOnly, "write");
10881
+ ensureWritable7("records create", readOnly, "write");
10055
10882
  const resolvedSchema = await resolveSchemaSelector(schemasApi, schema);
10056
10883
  const data = await api.createRecord(
10057
10884
  resolvedSchema,
10058
10885
  buildRecordCreateInput(commandOptions)
10059
10886
  );
10060
10887
  if (json) {
10061
- emitJson9(stdout, "records create", data, filePath);
10888
+ emitJson10(stdout, "records create", data, filePath);
10062
10889
  return;
10063
10890
  }
10064
- writeLine9(stdout, `Created record "${getRecordIdentifier(data)}".`);
10891
+ writeLine10(stdout, `Created record "${getRecordIdentifier(data)}".`);
10065
10892
  });
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) {
10893
+ 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
10894
  const { api, schemasApi, json, readOnly } = createRecordsApi(this, filePath);
10068
- ensureWritable6("records update", readOnly, "write");
10895
+ ensureWritable7("records update", readOnly, "write");
10069
10896
  const resolvedSchema = await resolveSchemaSelector(schemasApi, schema);
10070
10897
  const data = await api.updateRecord(
10071
10898
  resolvedSchema,
@@ -10073,14 +10900,14 @@ function registerRecordsCommands(program, options = {}) {
10073
10900
  buildRecordUpdateInput(commandOptions)
10074
10901
  );
10075
10902
  if (json) {
10076
- emitJson9(stdout, "records update", data, filePath);
10903
+ emitJson10(stdout, "records update", data, filePath);
10077
10904
  return;
10078
10905
  }
10079
- writeLine9(stdout, `Updated record "${getRecordIdentifier(data)}".`);
10906
+ writeLine10(stdout, `Updated record "${getRecordIdentifier(data)}".`);
10080
10907
  });
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) {
10908
+ 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
10909
  const { api, schemasApi, json, readOnly } = createRecordsApi(this, filePath);
10083
- ensureWritable6("records delete", readOnly, "destructive");
10910
+ ensureWritable7("records delete", readOnly, "destructive");
10084
10911
  const resolvedSchema = await resolveSchemaSelector(schemasApi, schema);
10085
10912
  await api.deleteRecord(resolvedSchema, record);
10086
10913
  const data = {
@@ -10089,44 +10916,44 @@ function registerRecordsCommands(program, options = {}) {
10089
10916
  deleted: true
10090
10917
  };
10091
10918
  if (json) {
10092
- emitJson9(stdout, "records delete", data, filePath);
10919
+ emitJson10(stdout, "records delete", data, filePath);
10093
10920
  return;
10094
10921
  }
10095
- writeLine9(stdout, `Deleted record "${record.value}" from schema "${schema.value}".`);
10922
+ writeLine10(stdout, `Deleted record "${record.value}" from schema "${schema.value}".`);
10096
10923
  });
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) {
10924
+ 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
10925
  const { api, schemasApi, json, readOnly } = createRecordsApi(this, filePath);
10099
- ensureWritable6("records clear", readOnly, "destructive");
10926
+ ensureWritable7("records clear", readOnly, "destructive");
10100
10927
  const resolvedSchema = await resolveSchemaSelector(schemasApi, schema);
10101
10928
  const data = await api.clearRecords(resolvedSchema);
10102
10929
  if (json) {
10103
- emitJson9(stdout, "records clear", data, filePath);
10930
+ emitJson10(stdout, "records clear", data, filePath);
10104
10931
  return;
10105
10932
  }
10106
- writeLine9(stdout, `Cleared all records from schema "${schema.value}".`);
10933
+ writeLine10(stdout, `Cleared all records from schema "${schema.value}".`);
10107
10934
  });
10108
10935
  }
10109
10936
 
10110
10937
  // src/commands/schemas.ts
10111
- import { readFileSync as readFileSync8 } from "fs";
10112
- import { InvalidArgumentError as InvalidArgumentError8 } from "commander";
10113
- function getCommandIo10(stdout) {
10938
+ import { readFileSync as readFileSync9 } from "fs";
10939
+ import { InvalidArgumentError as InvalidArgumentError9 } from "commander";
10940
+ function getCommandIo11(stdout) {
10114
10941
  return stdout ?? process.stdout;
10115
10942
  }
10116
- function writeLine10(stdout, value) {
10943
+ function writeLine11(stdout, value) {
10117
10944
  stdout.write(`${value}
10118
10945
  `);
10119
10946
  }
10120
- function getGlobalOptions10(command) {
10947
+ function getGlobalOptions11(command) {
10121
10948
  return command.optsWithGlobals();
10122
10949
  }
10123
- function emitJson10(stdout, commandName, data, configPath) {
10124
- writeLine10(
10950
+ function emitJson11(stdout, commandName, data, configPath) {
10951
+ writeLine11(
10125
10952
  stdout,
10126
10953
  JSON.stringify(buildJsonSuccess(data, { command: commandName, configPath }))
10127
10954
  );
10128
10955
  }
10129
- function toConfigurationError9(filePath, error) {
10956
+ function toConfigurationError10(filePath, error) {
10130
10957
  if (error instanceof CliError) {
10131
10958
  throw error;
10132
10959
  }
@@ -10141,7 +10968,7 @@ function toConfigurationError9(filePath, error) {
10141
10968
  function createSchemasApi(command, filePath) {
10142
10969
  try {
10143
10970
  const config = readRuntimeConfig(filePath);
10144
- const runtime = resolveRuntimeContext(config, getGlobalOptions10(command));
10971
+ const runtime = resolveRuntimeContext(config, getGlobalOptions11(command));
10145
10972
  if (!runtime.baseUrl) {
10146
10973
  throw new CliError(
10147
10974
  "configuration_error",
@@ -10160,10 +10987,10 @@ function createSchemasApi(command, filePath) {
10160
10987
  readOnly: runtime.readOnly
10161
10988
  };
10162
10989
  } catch (error) {
10163
- toConfigurationError9(filePath, error);
10990
+ toConfigurationError10(filePath, error);
10164
10991
  }
10165
10992
  }
10166
- function ensureWritable7(commandName, readOnly, commandMode) {
10993
+ function ensureWritable8(commandName, readOnly, commandMode) {
10167
10994
  if (readOnly) {
10168
10995
  throw new CliError(
10169
10996
  "command_not_allowed_in_read_only_mode",
@@ -10175,12 +11002,12 @@ function ensureWritable7(commandName, readOnly, commandMode) {
10175
11002
  );
10176
11003
  }
10177
11004
  }
10178
- function parseUuidOrSlugSelector8(input) {
11005
+ function parseUuidOrSlugSelector9(input) {
10179
11006
  try {
10180
11007
  return normalizeUuidOrSlug(input);
10181
11008
  } catch (error) {
10182
11009
  const message = error instanceof Error ? error.message : "Invalid selector.";
10183
- throw new InvalidArgumentError8(message);
11010
+ throw new InvalidArgumentError9(message);
10184
11011
  }
10185
11012
  }
10186
11013
  function parseBooleanFlag(input) {
@@ -10191,9 +11018,9 @@ function parseBooleanFlag(input) {
10191
11018
  if (["false", "0", "no", "n", "off"].includes(normalized)) {
10192
11019
  return false;
10193
11020
  }
10194
- throw new InvalidArgumentError8(`Expected a boolean value, received "${input}".`);
11021
+ throw new InvalidArgumentError9(`Expected a boolean value, received "${input}".`);
10195
11022
  }
10196
- function isJsonObject6(value) {
11023
+ function isJsonObject7(value) {
10197
11024
  return typeof value === "object" && value !== null && !Array.isArray(value);
10198
11025
  }
10199
11026
  function parseRawJsonObject3(input, sourceLabel) {
@@ -10207,7 +11034,7 @@ function parseRawJsonObject3(input, sourceLabel) {
10207
11034
  `Failed to parse JSON from ${sourceLabel}: ${message}`
10208
11035
  );
10209
11036
  }
10210
- if (!isJsonObject6(parsed)) {
11037
+ if (!isJsonObject7(parsed)) {
10211
11038
  throw new CliError(
10212
11039
  "invalid_cli_usage",
10213
11040
  `Expected ${sourceLabel} to contain a JSON object.`
@@ -10228,7 +11055,7 @@ function readRawObject4(raw, rawFile) {
10228
11055
  if (rawFile) {
10229
11056
  let contents;
10230
11057
  try {
10231
- contents = readFileSync8(rawFile, "utf8");
11058
+ contents = readFileSync9(rawFile, "utf8");
10232
11059
  } catch (error) {
10233
11060
  const message = error instanceof Error ? error.message : "Unable to read file.";
10234
11061
  throw new CliError(
@@ -10287,7 +11114,7 @@ function applyFieldDefaultValue(input, defaultValue) {
10287
11114
  return;
10288
11115
  }
10289
11116
  const config = input.config;
10290
- if (config !== void 0 && !isJsonObject6(config)) {
11117
+ if (config !== void 0 && !isJsonObject7(config)) {
10291
11118
  throw new CliError(
10292
11119
  "invalid_cli_usage",
10293
11120
  'Expected field "config" to be a JSON object when using "--default".'
@@ -10327,7 +11154,7 @@ function buildFieldCreateInput(options) {
10327
11154
  input.required = options.required;
10328
11155
  }
10329
11156
  applyFieldDefaultValue(input, options.default);
10330
- if ("config" in input && isJsonObject6(input.config) && isEmptyObject5(input.config)) {
11157
+ if ("config" in input && isJsonObject7(input.config) && isEmptyObject6(input.config)) {
10331
11158
  delete input.config;
10332
11159
  }
10333
11160
  return input;
@@ -10400,35 +11227,35 @@ async function resolveFieldSelector(api, schema, selector) {
10400
11227
  value: match.id
10401
11228
  };
10402
11229
  }
10403
- function isEmptyObject5(value) {
11230
+ function isEmptyObject6(value) {
10404
11231
  return Object.keys(value).length === 0;
10405
11232
  }
10406
11233
  function registerSchemasCommands(program, options = {}) {
10407
11234
  const filePath = options.configPath ?? defaultConfigPath;
10408
- const stdout = getCommandIo10(options.stdout);
11235
+ const stdout = getCommandIo11(options.stdout);
10409
11236
  const schemas = program.command("schemas").description("Manage schemas and schema fields");
10410
11237
  schemas.command("list").description("List schemas").action(async function action() {
10411
11238
  const { api, json } = createSchemasApi(this, filePath);
10412
11239
  const data = await api.listSchemas();
10413
11240
  if (json) {
10414
- emitJson10(stdout, "schemas list", data, filePath);
11241
+ emitJson11(stdout, "schemas list", data, filePath);
10415
11242
  return;
10416
11243
  }
10417
11244
  emitSchemasTable(stdout, data);
10418
11245
  });
10419
- schemas.command("get").description("Get a schema by UUID or slug").argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector8).action(async function action(schema) {
11246
+ schemas.command("get").description("Get a schema by UUID or slug").argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector9).action(async function action(schema) {
10420
11247
  const { api, json } = createSchemasApi(this, filePath);
10421
11248
  const resolvedSchema = await resolveSchemaSelector2(api, schema);
10422
11249
  const data = await api.getSchema(resolvedSchema);
10423
11250
  if (json) {
10424
- emitJson10(stdout, "schemas get", data, filePath);
11251
+ emitJson11(stdout, "schemas get", data, filePath);
10425
11252
  return;
10426
11253
  }
10427
11254
  emitSchemasTable(stdout, [data]);
10428
11255
  });
10429
11256
  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
11257
  const { api, json, readOnly } = createSchemasApi(this, filePath);
10431
- ensureWritable7("schemas create", readOnly, "write");
11258
+ ensureWritable8("schemas create", readOnly, "write");
10432
11259
  const input = {
10433
11260
  name: commandOptions.name,
10434
11261
  slug: commandOptions.slug,
@@ -10437,17 +11264,17 @@ function registerSchemasCommands(program, options = {}) {
10437
11264
  };
10438
11265
  const data = await api.createSchema(input);
10439
11266
  if (json) {
10440
- emitJson10(stdout, "schemas create", data, filePath);
11267
+ emitJson11(stdout, "schemas create", data, filePath);
10441
11268
  return;
10442
11269
  }
10443
- writeLine10(stdout, `Created schema "${data.slug ?? commandOptions.slug}".`);
11270
+ writeLine11(stdout, `Created schema "${data.slug ?? commandOptions.slug}".`);
10444
11271
  });
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) {
11272
+ 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
11273
  const { api, json, readOnly } = createSchemasApi(this, filePath);
10447
- ensureWritable7("schemas update", readOnly, "write");
11274
+ ensureWritable8("schemas update", readOnly, "write");
10448
11275
  const resolvedSchema = await resolveSchemaSelector2(api, schema);
10449
11276
  const input = buildSchemaUpdateInput(commandOptions);
10450
- if (isEmptyObject5(input)) {
11277
+ if (isEmptyObject6(input)) {
10451
11278
  throw new CliError(
10452
11279
  "invalid_cli_usage",
10453
11280
  'Provide at least one schema field to update via "--name", "--slug", "--auditable", or "--commentable".'
@@ -10455,14 +11282,14 @@ function registerSchemasCommands(program, options = {}) {
10455
11282
  }
10456
11283
  const data = await api.updateSchema(resolvedSchema, input);
10457
11284
  if (json) {
10458
- emitJson10(stdout, "schemas update", data, filePath);
11285
+ emitJson11(stdout, "schemas update", data, filePath);
10459
11286
  return;
10460
11287
  }
10461
- writeLine10(stdout, `Updated schema "${data.slug ?? schema.value}".`);
11288
+ writeLine11(stdout, `Updated schema "${data.slug ?? schema.value}".`);
10462
11289
  });
10463
- schemas.command("delete").description("Delete a schema").argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector8).action(async function action(schema) {
11290
+ schemas.command("delete").description("Delete a schema").argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector9).action(async function action(schema) {
10464
11291
  const { api, json, readOnly } = createSchemasApi(this, filePath);
10465
- ensureWritable7("schemas delete", readOnly, "destructive");
11292
+ ensureWritable8("schemas delete", readOnly, "destructive");
10466
11293
  const resolvedSchema = await resolveSchemaSelector2(api, schema);
10467
11294
  await api.deleteSchema(resolvedSchema);
10468
11295
  const data = {
@@ -10470,36 +11297,36 @@ function registerSchemasCommands(program, options = {}) {
10470
11297
  deleted: true
10471
11298
  };
10472
11299
  if (json) {
10473
- emitJson10(stdout, "schemas delete", data, filePath);
11300
+ emitJson11(stdout, "schemas delete", data, filePath);
10474
11301
  return;
10475
11302
  }
10476
- writeLine10(stdout, `Deleted schema "${schema.value}".`);
11303
+ writeLine11(stdout, `Deleted schema "${schema.value}".`);
10477
11304
  });
10478
11305
  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) {
11306
+ fields.command("list").description("List fields for a schema").argument("<schema>", "schema uuid or slug", parseUuidOrSlugSelector9).action(async function action(schema) {
10480
11307
  const { api, json } = createSchemasApi(this, filePath);
10481
11308
  const resolvedSchema = await resolveSchemaSelector2(api, schema);
10482
11309
  const data = await api.listFields(resolvedSchema);
10483
11310
  if (json) {
10484
- emitJson10(stdout, "schemas fields list", data, filePath);
11311
+ emitJson11(stdout, "schemas fields list", data, filePath);
10485
11312
  return;
10486
11313
  }
10487
11314
  emitFieldsTable(stdout, data);
10488
11315
  });
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) {
11316
+ 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
11317
  const { api, json } = createSchemasApi(this, filePath);
10491
11318
  const resolvedSchema = await resolveSchemaSelector2(api, schema);
10492
11319
  const resolvedField = await resolveFieldSelector(api, resolvedSchema, field);
10493
11320
  const data = await api.getField(resolvedSchema, resolvedField);
10494
11321
  if (json) {
10495
- emitJson10(stdout, "schemas fields get", data, filePath);
11322
+ emitJson11(stdout, "schemas fields get", data, filePath);
10496
11323
  return;
10497
11324
  }
10498
11325
  emitFieldsTable(stdout, [data]);
10499
11326
  });
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) {
11327
+ 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
11328
  const { api, json, readOnly } = createSchemasApi(this, filePath);
10502
- ensureWritable7("schemas fields create", readOnly, "write");
11329
+ ensureWritable8("schemas fields create", readOnly, "write");
10503
11330
  const input = buildFieldCreateInput(commandOptions);
10504
11331
  const resolvedSchema = await resolveSchemaSelector2(api, schema);
10505
11332
  let data;
@@ -10509,14 +11336,14 @@ function registerSchemasCommands(program, options = {}) {
10509
11336
  toFieldCreateError(error, input);
10510
11337
  }
10511
11338
  if (json) {
10512
- emitJson10(stdout, "schemas fields create", data, filePath);
11339
+ emitJson11(stdout, "schemas fields create", data, filePath);
10513
11340
  return;
10514
11341
  }
10515
- writeLine10(stdout, `Created field "${data.slug ?? commandOptions.slug}".`);
11342
+ writeLine11(stdout, `Created field "${data.slug ?? commandOptions.slug}".`);
10516
11343
  });
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) {
11344
+ 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
11345
  const { api, json, readOnly } = createSchemasApi(this, filePath);
10519
- ensureWritable7("schemas fields update", readOnly, "write");
11346
+ ensureWritable8("schemas fields update", readOnly, "write");
10520
11347
  const resolvedSchema = await resolveSchemaSelector2(api, schema);
10521
11348
  const resolvedField = await resolveFieldSelector(api, resolvedSchema, field);
10522
11349
  const currentField = await api.getField(resolvedSchema, resolvedField);
@@ -10525,7 +11352,7 @@ function registerSchemasCommands(program, options = {}) {
10525
11352
  throw new CliError("invalid_cli_usage", `Field "${field.value}" is missing type metadata.`);
10526
11353
  }
10527
11354
  const input = buildFieldUpdateInput(currentType, commandOptions);
10528
- if (isEmptyObject5(input)) {
11355
+ if (isEmptyObject6(input)) {
10529
11356
  throw new CliError(
10530
11357
  "invalid_cli_usage",
10531
11358
  'Provide at least one field update via "--label", "--required", "--raw", or "--raw-file".'
@@ -10533,14 +11360,14 @@ function registerSchemasCommands(program, options = {}) {
10533
11360
  }
10534
11361
  const data = await api.updateField(resolvedSchema, resolvedField, input);
10535
11362
  if (json) {
10536
- emitJson10(stdout, "schemas fields update", data, filePath);
11363
+ emitJson11(stdout, "schemas fields update", data, filePath);
10537
11364
  return;
10538
11365
  }
10539
- writeLine10(stdout, `Updated field "${data.slug ?? field.value}".`);
11366
+ writeLine11(stdout, `Updated field "${data.slug ?? field.value}".`);
10540
11367
  });
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) {
11368
+ 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
11369
  const { api, json, readOnly } = createSchemasApi(this, filePath);
10543
- ensureWritable7("schemas fields delete", readOnly, "destructive");
11370
+ ensureWritable8("schemas fields delete", readOnly, "destructive");
10544
11371
  const resolvedSchema = await resolveSchemaSelector2(api, schema);
10545
11372
  const resolvedField = await resolveFieldSelector(api, resolvedSchema, field);
10546
11373
  await api.deleteField(resolvedSchema, resolvedField);
@@ -10550,19 +11377,19 @@ function registerSchemasCommands(program, options = {}) {
10550
11377
  deleted: true
10551
11378
  };
10552
11379
  if (json) {
10553
- emitJson10(stdout, "schemas fields delete", data, filePath);
11380
+ emitJson11(stdout, "schemas fields delete", data, filePath);
10554
11381
  return;
10555
11382
  }
10556
- writeLine10(stdout, `Deleted field "${field.value}" from schema "${schema.value}".`);
11383
+ writeLine11(stdout, `Deleted field "${field.value}" from schema "${schema.value}".`);
10557
11384
  });
10558
11385
  }
10559
11386
 
10560
11387
  // src/commands/teamspace.ts
10561
- import { readFileSync as readFileSync9 } from "fs";
10562
- import { InvalidArgumentError as InvalidArgumentError9 } from "commander";
11388
+ import { readFileSync as readFileSync10 } from "fs";
11389
+ import { InvalidArgumentError as InvalidArgumentError10 } from "commander";
10563
11390
 
10564
11391
  // src/api/teamspace.ts
10565
- function jsonOptions7(body, method) {
11392
+ function jsonOptions8(body, method) {
10566
11393
  return {
10567
11394
  method,
10568
11395
  headers: {
@@ -10571,7 +11398,7 @@ function jsonOptions7(body, method) {
10571
11398
  body: JSON.stringify(body)
10572
11399
  };
10573
11400
  }
10574
- function selectorValue9(selector) {
11401
+ function selectorValue10(selector) {
10575
11402
  return selector.value;
10576
11403
  }
10577
11404
  var TeamspaceApi = class {
@@ -10592,53 +11419,53 @@ var TeamspaceApi = class {
10592
11419
  createFolder(input) {
10593
11420
  return this.client.requestJson(
10594
11421
  "/api/v2/teamspaces/folders",
10595
- jsonOptions7(input, "POST")
11422
+ jsonOptions8(input, "POST")
10596
11423
  );
10597
11424
  }
10598
11425
  updateFolder(folder, input) {
10599
11426
  return this.client.requestJson(
10600
- `/api/v2/teamspaces/folders/${selectorValue9(folder)}`,
10601
- jsonOptions7(input, "PATCH")
11427
+ `/api/v2/teamspaces/folders/${selectorValue10(folder)}`,
11428
+ jsonOptions8(input, "PATCH")
10602
11429
  );
10603
11430
  }
10604
11431
  deleteFolder(folder) {
10605
11432
  return this.client.requestJson(
10606
- `/api/v2/teamspaces/folders/${selectorValue9(folder)}`,
11433
+ `/api/v2/teamspaces/folders/${selectorValue10(folder)}`,
10607
11434
  { method: "DELETE" }
10608
11435
  );
10609
11436
  }
10610
11437
  publishResource(input) {
10611
11438
  return this.client.requestJson(
10612
11439
  "/api/v2/teamspaces/resources:publish",
10613
- jsonOptions7(input, "POST")
11440
+ jsonOptions8(input, "POST")
10614
11441
  );
10615
11442
  }
10616
11443
  unpublishResource(resourceId) {
10617
11444
  return this.client.requestJson(
10618
11445
  "/api/v2/teamspaces/resources:unpublish",
10619
- jsonOptions7({ resourceId }, "POST")
11446
+ jsonOptions8({ resourceId }, "POST")
10620
11447
  );
10621
11448
  }
10622
11449
  };
10623
11450
 
10624
11451
  // src/commands/teamspace.ts
10625
- function getCommandIo11(stdout) {
11452
+ function getCommandIo12(stdout) {
10626
11453
  return stdout ?? process.stdout;
10627
11454
  }
10628
- function writeLine11(stdout, value) {
11455
+ function writeLine12(stdout, value) {
10629
11456
  stdout.write(`${value}
10630
11457
  `);
10631
11458
  }
10632
- function getGlobalOptions11(command) {
11459
+ function getGlobalOptions12(command) {
10633
11460
  return command.optsWithGlobals();
10634
11461
  }
10635
- function emitJson11(stdout, commandName, data, configPath) {
10636
- writeLine11(
11462
+ function emitJson12(stdout, commandName, data, configPath) {
11463
+ writeLine12(
10637
11464
  stdout,
10638
11465
  JSON.stringify(buildJsonSuccess(data, { command: commandName, configPath }))
10639
11466
  );
10640
11467
  }
10641
- function toConfigurationError10(filePath, error) {
11468
+ function toConfigurationError11(filePath, error) {
10642
11469
  if (error instanceof CliError) {
10643
11470
  throw error;
10644
11471
  }
@@ -10653,7 +11480,7 @@ function toConfigurationError10(filePath, error) {
10653
11480
  function createTeamspaceApi(command, filePath) {
10654
11481
  try {
10655
11482
  const config = readRuntimeConfig(filePath);
10656
- const runtime = resolveRuntimeContext(config, getGlobalOptions11(command));
11483
+ const runtime = resolveRuntimeContext(config, getGlobalOptions12(command));
10657
11484
  if (!runtime.baseUrl) {
10658
11485
  throw new CliError(
10659
11486
  "configuration_error",
@@ -10671,10 +11498,10 @@ function createTeamspaceApi(command, filePath) {
10671
11498
  readOnly: runtime.readOnly
10672
11499
  };
10673
11500
  } catch (error) {
10674
- toConfigurationError10(filePath, error);
11501
+ toConfigurationError11(filePath, error);
10675
11502
  }
10676
11503
  }
10677
- function ensureWritable8(commandName, readOnly, commandMode) {
11504
+ function ensureWritable9(commandName, readOnly, commandMode) {
10678
11505
  if (readOnly) {
10679
11506
  throw new CliError(
10680
11507
  "command_not_allowed_in_read_only_mode",
@@ -10686,21 +11513,21 @@ function ensureWritable8(commandName, readOnly, commandMode) {
10686
11513
  );
10687
11514
  }
10688
11515
  }
10689
- function parseUuidOrSlugSelector9(input) {
11516
+ function parseUuidOrSlugSelector10(input) {
10690
11517
  try {
10691
11518
  return normalizeUuidOrSlug(input);
10692
11519
  } catch (error) {
10693
11520
  const message = error instanceof Error ? error.message : "Invalid selector.";
10694
- throw new InvalidArgumentError9(message);
11521
+ throw new InvalidArgumentError10(message);
10695
11522
  }
10696
11523
  }
10697
11524
  function parseNonNegativeInteger3(input) {
10698
11525
  if (!/^\d+$/.test(input.trim())) {
10699
- throw new InvalidArgumentError9(`Expected a non-negative integer, received "${input}".`);
11526
+ throw new InvalidArgumentError10(`Expected a non-negative integer, received "${input}".`);
10700
11527
  }
10701
11528
  return Number(input);
10702
11529
  }
10703
- function isJsonObject7(value) {
11530
+ function isJsonObject8(value) {
10704
11531
  return typeof value === "object" && value !== null && !Array.isArray(value);
10705
11532
  }
10706
11533
  function parseRawJsonObject4(input, sourceLabel) {
@@ -10714,7 +11541,7 @@ function parseRawJsonObject4(input, sourceLabel) {
10714
11541
  `Failed to parse JSON from ${sourceLabel}: ${message}`
10715
11542
  );
10716
11543
  }
10717
- if (!isJsonObject7(parsed)) {
11544
+ if (!isJsonObject8(parsed)) {
10718
11545
  throw new CliError(
10719
11546
  "invalid_cli_usage",
10720
11547
  `Expected ${sourceLabel} to contain a JSON object.`
@@ -10735,7 +11562,7 @@ function readRawObject5(raw, rawFile) {
10735
11562
  if (rawFile) {
10736
11563
  let contents;
10737
11564
  try {
10738
- contents = readFileSync9(rawFile, "utf8");
11565
+ contents = readFileSync10(rawFile, "utf8");
10739
11566
  } catch (error) {
10740
11567
  const message = error instanceof Error ? error.message : "Unable to read file.";
10741
11568
  throw new CliError(
@@ -10747,7 +11574,7 @@ function readRawObject5(raw, rawFile) {
10747
11574
  }
10748
11575
  return void 0;
10749
11576
  }
10750
- function isEmptyObject6(value) {
11577
+ function isEmptyObject7(value) {
10751
11578
  return Object.keys(value).length === 0;
10752
11579
  }
10753
11580
  function buildFolderCreateInput(options) {
@@ -10778,7 +11605,7 @@ function buildFolderUpdateInput(options) {
10778
11605
  if (props !== void 0) {
10779
11606
  input.additionalProperties = props;
10780
11607
  }
10781
- if (isEmptyObject6(input)) {
11608
+ if (isEmptyObject7(input)) {
10782
11609
  throw new CliError(
10783
11610
  "invalid_cli_usage",
10784
11611
  'Provide folder updates via "--name", "--order", "--props", or "--props-file".'
@@ -10788,9 +11615,9 @@ function buildFolderUpdateInput(options) {
10788
11615
  }
10789
11616
  function toTableRows5(data) {
10790
11617
  if (Array.isArray(data)) {
10791
- return data.map((entry) => isJsonObject7(entry) ? entry : { value: entry });
11618
+ return data.map((entry) => isJsonObject8(entry) ? entry : { value: entry });
10792
11619
  }
10793
- if (isJsonObject7(data)) {
11620
+ if (isJsonObject8(data)) {
10794
11621
  return [data];
10795
11622
  }
10796
11623
  return [{ value: data }];
@@ -10852,85 +11679,91 @@ async function resolveFolderSelector2(api, selector) {
10852
11679
  }
10853
11680
  function registerTeamspaceCommands(program, options = {}) {
10854
11681
  const filePath = options.configPath ?? defaultConfigPath;
10855
- const stdout = getCommandIo11(options.stdout);
11682
+ const stdout = getCommandIo12(options.stdout);
10856
11683
  const teamspace = program.command("teamspace").description("Manage teamspace folders and resources");
10857
11684
  const folders = teamspace.command("folders").description("Manage teamspace folders");
10858
- folders.command("list").description("List teamspace folders").option("--include-resources", "include nested resources").action(async function action(commandOptions) {
11685
+ folders.command("list").description("List teamspace folders").option("--include-resources", "include the published resources inside each folder").action(async function action(commandOptions) {
10859
11686
  const { api, json } = createTeamspaceApi(this, filePath);
10860
11687
  const data = await api.listFolders(Boolean(commandOptions.includeResources));
10861
11688
  if (json) {
10862
- emitJson11(stdout, "teamspace folders list", data, filePath);
11689
+ emitJson12(stdout, "teamspace folders list", data, filePath);
10863
11690
  return;
10864
11691
  }
10865
11692
  emitTable5(stdout, data);
10866
11693
  });
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) {
11694
+ 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 the published resources inside each folder").action(async function action(folder, commandOptions) {
10868
11695
  const { api, json } = createTeamspaceApi(this, filePath);
10869
11696
  const resolvedFolder = await resolveFolderSelector2(api, folder);
10870
11697
  const allFolders = await api.listFolders(Boolean(commandOptions.includeResources));
10871
11698
  const data = findFolderEntity(allFolders, resolvedFolder);
10872
11699
  if (json) {
10873
- emitJson11(stdout, "teamspace folders get", data, filePath);
11700
+ emitJson12(stdout, "teamspace folders get", data, filePath);
10874
11701
  return;
10875
11702
  }
10876
11703
  emitTable5(stdout, data);
10877
11704
  });
10878
- 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) {
11705
+ folders.command("create").description("Create a teamspace folder").requiredOption("--name <name>", "folder name").option("--order <n>", "display order (lower values appear first)", parseNonNegativeInteger3).option("--props <json>", 'additionalProperties JSON: free-form client metadata, e.g. {"icon":"folder-users","color":"gold"}').option("--props-file <path>", "path to a file with the additionalProperties JSON").action(async function action(commandOptions) {
10879
11706
  const { api, json, readOnly } = createTeamspaceApi(this, filePath);
10880
- ensureWritable8("teamspace folders create", readOnly, "write");
11707
+ ensureWritable9("teamspace folders create", readOnly, "write");
10881
11708
  const data = await api.createFolder(buildFolderCreateInput(commandOptions));
10882
11709
  if (json) {
10883
- emitJson11(stdout, "teamspace folders create", data, filePath);
11710
+ emitJson12(stdout, "teamspace folders create", data, filePath);
10884
11711
  return;
10885
11712
  }
10886
- writeLine11(stdout, `Created folder "${getFolderIdentifier(data)}".`);
11713
+ writeLine12(stdout, `Created folder "${getFolderIdentifier(data)}".`);
10887
11714
  });
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) {
11715
+ folders.command("update").description("Update a teamspace folder").argument("<folder>", "folder UUID or exact name", parseUuidOrSlugSelector10).option("--name <name>", "folder name").option("--order <n>", "display order (lower values appear first)", parseNonNegativeInteger3).option("--props <json>", 'additionalProperties JSON: free-form client metadata, e.g. {"icon":"folder-users","color":"gold"}').option("--props-file <path>", "path to a file with the additionalProperties JSON").action(async function action(folder, commandOptions) {
10889
11716
  const { api, json, readOnly } = createTeamspaceApi(this, filePath);
10890
- ensureWritable8("teamspace folders update", readOnly, "write");
11717
+ ensureWritable9("teamspace folders update", readOnly, "write");
10891
11718
  const resolvedFolder = await resolveFolderSelector2(api, folder);
10892
11719
  const data = await api.updateFolder(resolvedFolder, buildFolderUpdateInput(commandOptions));
10893
11720
  if (json) {
10894
- emitJson11(stdout, "teamspace folders update", data, filePath);
11721
+ emitJson12(stdout, "teamspace folders update", data, filePath);
10895
11722
  return;
10896
11723
  }
10897
- writeLine11(stdout, `Updated folder "${getFolderIdentifier(data)}".`);
11724
+ writeLine12(stdout, `Updated folder "${getFolderIdentifier(data)}".`);
10898
11725
  });
10899
- folders.command("delete").description("Delete a teamspace folder").argument("<folder>", "folder UUID or exact name", parseUuidOrSlugSelector9).action(async function action(folder) {
11726
+ folders.command("delete").description("Delete a teamspace folder").argument("<folder>", "folder UUID or exact name", parseUuidOrSlugSelector10).action(async function action(folder) {
10900
11727
  const { api, json, readOnly } = createTeamspaceApi(this, filePath);
10901
- ensureWritable8("teamspace folders delete", readOnly, "destructive");
11728
+ ensureWritable9("teamspace folders delete", readOnly, "destructive");
10902
11729
  const resolvedFolder = await resolveFolderSelector2(api, folder);
10903
11730
  const data = await api.deleteFolder(resolvedFolder);
10904
11731
  if (json) {
10905
- emitJson11(stdout, "teamspace folders delete", data, filePath);
11732
+ emitJson12(stdout, "teamspace folders delete", data, filePath);
10906
11733
  return;
10907
11734
  }
10908
- writeLine11(stdout, `Deleted folder "${resolvedFolder.value}".`);
11735
+ writeLine12(stdout, `Deleted folder "${resolvedFolder.value}".`);
10909
11736
  });
10910
11737
  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) {
11738
+ resources.command("publish").description(
11739
+ "Publish a resource to a teamspace folder. Publishing an already-published resource moves it to the new folder."
11740
+ ).argument("<resource>", "schema UUID, schema slug, or display UUID", parseUuidOrSlugSelector10).requiredOption(
11741
+ "--to <folder>",
11742
+ "target folder UUID or exact name (root folder UUID is 00000000-0000-0000-0000-000000000000)",
11743
+ parseUuidOrSlugSelector10
11744
+ ).action(async function action(resource, commandOptions) {
10912
11745
  const { api, json, readOnly } = createTeamspaceApi(this, filePath);
10913
- ensureWritable8("teamspace resources publish", readOnly, "write");
11746
+ ensureWritable9("teamspace resources publish", readOnly, "write");
10914
11747
  const folder = await resolveFolderSelector2(api, commandOptions.to);
10915
11748
  const data = await api.publishResource({
10916
11749
  resourceId: resource.value,
10917
11750
  targetFolderId: folder.value
10918
11751
  });
10919
11752
  if (json) {
10920
- emitJson11(stdout, "teamspace resources publish", data, filePath);
11753
+ emitJson12(stdout, "teamspace resources publish", data, filePath);
10921
11754
  return;
10922
11755
  }
10923
- writeLine11(stdout, `Published resource "${resource.value}" to folder "${folder.value}".`);
11756
+ writeLine12(stdout, `Published resource "${resource.value}" to folder "${folder.value}".`);
10924
11757
  });
10925
- resources.command("unpublish").description("Unpublish a resource from teamspace").argument("<resource>", "resource UUID or exact name", parseUuidOrSlugSelector9).action(async function action(resource) {
11758
+ resources.command("unpublish").description("Unpublish a resource from teamspace (removes it from its shared folder)").argument("<resource>", "schema UUID, schema slug, or display UUID", parseUuidOrSlugSelector10).action(async function action(resource) {
10926
11759
  const { api, json, readOnly } = createTeamspaceApi(this, filePath);
10927
- ensureWritable8("teamspace resources unpublish", readOnly, "write");
11760
+ ensureWritable9("teamspace resources unpublish", readOnly, "write");
10928
11761
  const data = await api.unpublishResource(resource.value);
10929
11762
  if (json) {
10930
- emitJson11(stdout, "teamspace resources unpublish", data, filePath);
11763
+ emitJson12(stdout, "teamspace resources unpublish", data, filePath);
10931
11764
  return;
10932
11765
  }
10933
- writeLine11(stdout, `Unpublished resource "${resource.value}".`);
11766
+ writeLine12(stdout, `Unpublished resource "${resource.value}".`);
10934
11767
  });
10935
11768
  }
10936
11769
 
@@ -10938,12 +11771,13 @@ function registerTeamspaceCommands(program, options = {}) {
10938
11771
  var require2 = createRequire(import.meta.url);
10939
11772
  var { version } = require2("../package.json");
10940
11773
  function buildProgram(options = {}) {
10941
- const program = new Command10();
11774
+ const program = new Command11();
10942
11775
  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
11776
  registerProfilesCommands(program, options);
10944
11777
  registerAutomationsCommands(program, options);
10945
11778
  registerConfigCommands(program, options);
10946
11779
  registerDisplaysCommands(program, options);
11780
+ registerDocumentTemplatesCommands(program, options);
10947
11781
  registerFilesCommands(program, options);
10948
11782
  registerNavigationCommands(program, options);
10949
11783
  registerSchemasCommands(program, options);
@@ -11088,9 +11922,9 @@ function getCompletions(program, request, deps = {}) {
11088
11922
 
11089
11923
  // src/completion/install.ts
11090
11924
  import { execFileSync } from "child_process";
11091
- import { mkdirSync as mkdirSync2, readFileSync as readFileSync10, writeFileSync as writeFileSync3 } from "fs";
11925
+ import { mkdirSync as mkdirSync2, readFileSync as readFileSync11, writeFileSync as writeFileSync4 } from "fs";
11092
11926
  import { homedir as homedir2, platform } from "os";
11093
- import { basename as basename2, dirname as dirname2, join as join2 } from "path";
11927
+ import { basename as basename3, dirname as dirname2, join as join2 } from "path";
11094
11928
 
11095
11929
  // src/completion/scripts.ts
11096
11930
  var PROGRAM = "zinkee";
@@ -11212,7 +12046,7 @@ function defaultPowerShellProfile(env) {
11212
12046
  function detectShell(env) {
11213
12047
  const fromEnv = env.shellEnv;
11214
12048
  if (fromEnv) {
11215
- const name = basename2(fromEnv).toLowerCase().replace(/\.exe$/, "");
12049
+ const name = basename3(fromEnv).toLowerCase().replace(/\.exe$/, "");
11216
12050
  if (name === "bash") {
11217
12051
  return "bash";
11218
12052
  }
@@ -11310,7 +12144,7 @@ ${BLOCK_END}
11310
12144
  }
11311
12145
  function readFileOrEmpty(path) {
11312
12146
  try {
11313
- return readFileSync10(path, "utf8");
12147
+ return readFileSync11(path, "utf8");
11314
12148
  } catch (error) {
11315
12149
  if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") {
11316
12150
  return "";
@@ -11320,7 +12154,7 @@ function readFileOrEmpty(path) {
11320
12154
  }
11321
12155
  function writeFileEnsuringDir(path, content) {
11322
12156
  mkdirSync2(dirname2(path), { recursive: true });
11323
- writeFileSync3(path, content, "utf8");
12157
+ writeFileSync4(path, content, "utf8");
11324
12158
  }
11325
12159
  function installCompletion(shell, env) {
11326
12160
  const target = resolveTarget(shell, env);