dataiku-sdk 3.4.0 → 3.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/README.md +4 -4
  2. package/bin/dss.js +28 -2
  3. package/dist/build-metadata.json +1 -1
  4. package/dist/src/cli/coerce.d.ts +0 -1
  5. package/dist/src/cli/coerce.js +0 -5
  6. package/dist/src/cli/command-syntax.json +14524 -0
  7. package/dist/src/cli/commands/analysis.js +6 -9
  8. package/dist/src/cli/commands/api-deployer.js +15 -33
  9. package/dist/src/cli/commands/api-service.js +17 -27
  10. package/dist/src/cli/commands/app.js +25 -41
  11. package/dist/src/cli/commands/bundle.js +15 -24
  12. package/dist/src/cli/commands/business-app.js +10 -17
  13. package/dist/src/cli/commands/code-env.js +23 -36
  14. package/dist/src/cli/commands/code.js +4 -4
  15. package/dist/src/cli/commands/connection.js +12 -22
  16. package/dist/src/cli/commands/continuous-activity.js +6 -9
  17. package/dist/src/cli/commands/dashboard.js +8 -13
  18. package/dist/src/cli/commands/data-collection.js +9 -16
  19. package/dist/src/cli/commands/data-quality.js +14 -26
  20. package/dist/src/cli/commands/dataset.js +29 -54
  21. package/dist/src/cli/commands/discussion.js +7 -10
  22. package/dist/src/cli/commands/doctor.js +3 -3
  23. package/dist/src/cli/commands/flow-zone.js +8 -17
  24. package/dist/src/cli/commands/folder.js +12 -20
  25. package/dist/src/cli/commands/future.js +7 -10
  26. package/dist/src/cli/commands/group.js +7 -11
  27. package/dist/src/cli/commands/insight.js +7 -11
  28. package/dist/src/cli/commands/job.js +17 -26
  29. package/dist/src/cli/commands/knowledge-bank.js +5 -6
  30. package/dist/src/cli/commands/llm.js +5 -8
  31. package/dist/src/cli/commands/macro.js +9 -16
  32. package/dist/src/cli/commands/meaning.js +7 -11
  33. package/dist/src/cli/commands/metrics.js +7 -10
  34. package/dist/src/cli/commands/ml-task.js +12 -20
  35. package/dist/src/cli/commands/model-evaluation-store.js +7 -11
  36. package/dist/src/cli/commands/notebook.js +15 -27
  37. package/dist/src/cli/commands/plugin.js +35 -68
  38. package/dist/src/cli/commands/project-deployer.js +10 -22
  39. package/dist/src/cli/commands/project-folder.js +10 -17
  40. package/dist/src/cli/commands/project-git.js +38 -70
  41. package/dist/src/cli/commands/project-library.js +15 -23
  42. package/dist/src/cli/commands/project.js +9 -26
  43. package/dist/src/cli/commands/recipe.d.ts +16 -0
  44. package/dist/src/cli/commands/recipe.js +83 -94
  45. package/dist/src/cli/commands/saved-model.js +23 -39
  46. package/dist/src/cli/commands/scenario.js +20 -34
  47. package/dist/src/cli/commands/sql.js +4 -4
  48. package/dist/src/cli/commands/statistics.js +11 -18
  49. package/dist/src/cli/commands/streaming-endpoint.js +7 -11
  50. package/dist/src/cli/commands/user.js +11 -22
  51. package/dist/src/cli/commands/variable.js +3 -4
  52. package/dist/src/cli/commands/webapp.js +10 -16
  53. package/dist/src/cli/commands/wiki.js +9 -13
  54. package/dist/src/cli/commands/workspace.js +8 -14
  55. package/dist/src/cli/contract.d.ts +5 -15
  56. package/dist/src/cli/contract.js +157 -254
  57. package/dist/src/cli/doctor.js +1 -0
  58. package/dist/src/cli/env.d.ts +2 -0
  59. package/dist/src/cli/env.js +16 -1
  60. package/dist/src/cli/flags.d.ts +1 -0
  61. package/dist/src/cli/flags.js +4 -9
  62. package/dist/src/cli/helpers/app-permissions.js +7 -5
  63. package/dist/src/cli/helpers/flow-zone.js +8 -6
  64. package/dist/src/cli/helpers/recipe.js +2 -1
  65. package/dist/src/cli/syntax.d.ts +83 -0
  66. package/dist/src/cli/syntax.js +217 -0
  67. package/dist/src/cli/types.d.ts +3 -0
  68. package/dist/src/cli/usage.d.ts +1 -1
  69. package/dist/src/cli/usage.js +4 -2
  70. package/dist/src/cli/version.d.ts +0 -2
  71. package/dist/src/cli/version.js +6 -7
  72. package/dist/src/cli.js +132 -274
  73. package/dist/src/client.d.ts +2 -1
  74. package/dist/src/client.js +32 -17
  75. package/dist/src/errors.d.ts +12 -1
  76. package/dist/src/errors.js +28 -3
  77. package/dist/src/index.d.ts +1 -3
  78. package/dist/src/index.js +2 -2
  79. package/dist/src/resources/api-services.js +2 -3
  80. package/dist/src/resources/applications.js +2 -4
  81. package/dist/src/resources/base.d.ts +2 -0
  82. package/dist/src/resources/base.js +14 -2
  83. package/dist/src/resources/code-envs.js +3 -5
  84. package/dist/src/resources/data-quality.js +14 -13
  85. package/dist/src/resources/datasets.d.ts +13 -0
  86. package/dist/src/resources/datasets.js +5 -4
  87. package/dist/src/resources/flow-zones.js +4 -2
  88. package/dist/src/resources/folders.js +4 -2
  89. package/dist/src/resources/futures.js +1 -3
  90. package/dist/src/resources/insights.js +3 -2
  91. package/dist/src/resources/jobs.js +4 -6
  92. package/dist/src/resources/macros.d.ts +1 -1
  93. package/dist/src/resources/macros.js +3 -7
  94. package/dist/src/resources/notebooks.js +2 -3
  95. package/dist/src/resources/project-git.js +9 -11
  96. package/dist/src/resources/project-library.d.ts +0 -2
  97. package/dist/src/resources/project-library.js +2 -7
  98. package/dist/src/resources/projects.js +4 -3
  99. package/dist/src/resources/recipes.d.ts +28 -0
  100. package/dist/src/resources/recipes.js +117 -89
  101. package/dist/src/resources/saved-models.js +1 -13
  102. package/dist/src/resources/scenarios.js +1 -3
  103. package/dist/src/resources/sql.js +9 -8
  104. package/dist/src/resources/statistics.js +3 -4
  105. package/dist/src/resources/variables.js +2 -1
  106. package/dist/src/resources/webapps.js +2 -3
  107. package/dist/src/schemas.d.ts +1 -2
  108. package/dist/src/schemas.js +1 -1
  109. package/dist/src/skill.js +6 -7
  110. package/dist/src/utils/cleanup-ledger.js +9 -8
  111. package/dist/src/utils/deep-merge.js +2 -4
  112. package/dist/src/utils/flow-map.js +1 -6
  113. package/dist/src/utils/polling.d.ts +3 -0
  114. package/dist/src/utils/polling.js +3 -0
  115. package/dist/src/utils/project-archive.js +10 -14
  116. package/dist/src/utils/project-incarnation.js +3 -7
  117. package/dist/src/utils/records.d.ts +4 -0
  118. package/dist/src/utils/records.js +8 -0
  119. package/dist/src/utils/stable-hash.d.ts +3 -1
  120. package/dist/src/utils/stable-hash.js +2 -0
  121. package/package.json +10 -14
  122. package/plugin.json +1 -1
  123. package/skills/dataiku-dss/SKILL.md +3 -4
  124. package/skills/dataiku-dss/references/authentication.md +3 -3
  125. package/skills/dataiku-dss/references/coding.md +1 -1
  126. package/skills/dataiku-dss/references/discovery.md +1 -1
  127. package/skills/dataiku-dss/references/mutations.md +0 -1
  128. package/dist/src/utils/pagination.d.ts +0 -8
  129. package/dist/src/utils/pagination.js +0 -23
  130. package/packages/types/dist/index.d.ts +0 -1062
  131. package/packages/types/dist/index.js +0 -871
@@ -1,19 +1,21 @@
1
1
  import { ClientValidationError, DataikuError, } from "../../errors.js";
2
2
  import { projectIncarnationHash, } from "../../utils/project-incarnation.js";
3
- import { jsonInput, num, parseBooleanOption, plainRecord, requiredJsonInput, requiredStringFlag, stringField, } from "../coerce.js";
3
+ import { asRecord, } from "../../utils/records.js";
4
+ import { jsonInput, num, parseBooleanOption, requiredJsonInput, requiredStringFlag, stringField, } from "../coerce.js";
4
5
  import { executionMode, } from "../flags.js";
5
6
  import { appPermissionsHash, appPermissionsVerificationError, assertAppPermissionsSnapshotBinding, buildAppPermissionsSnapshot, diffAppPermissions, readAppPermissionsSnapshot, writeAppPermissionsSnapshot, } from "../helpers/app-permissions.js";
6
7
  import { createSuccessorInstance, futureTargetIdentity, generatedInstanceKey, isDefinitiveRejection, preflightSuccessorInstance, requireAbsentProjectTarget, safeErrorSummary, verifyAppInstance, VISUAL_UI_GATE, } from "../helpers/app-successor.js";
7
8
  import { CommandResultFailure, } from "../output.js";
9
+ import { commandUsage, withUsage, } from "../syntax.js";
8
10
  import { requireArgs, requireNoArgs, UsageError, } from "../usage.js";
9
- const CREATE_INSTANCE_USAGE = "dss app create-instance <appId> (--data JSON|--data-file PATH|--stdin) [--wait] [--timeout MS] [--poll-interval MS]";
10
- const MANIFEST_VERSION_USAGE = "dss app manifest-version [--project-key KEY]";
11
- const SET_MANIFEST_VERSION_USAGE = "dss app set-manifest-version (--manifest-version V|--version-notes NOTES) [--expect-hash SHA256] [--dry-run] [--project-key KEY]";
12
- const CREATE_SUCCESSOR_USAGE = "dss app create-successor-instance <appId> --from KEY [--to KEY] [--name NAME] [--copy-permissions] [--timeout MS] [--poll-interval MS] [--dry-run] [--record-cleanup PATH]";
13
- const SUCCESSOR_PREFLIGHT_USAGE = "dss app successor-preflight <appId> --from KEY [--to KEY] [--name NAME] [--copy-permissions]";
14
- const VERIFY_INSTANCE_USAGE = "dss app verify-instance <appId> --project-key KEY [--expect-version V]";
15
- const DELETE_INSTANCE_USAGE = "dss app delete-instance --project-key KEY [--future-id ID] [--expect-project-incarnation SHA256] [--unconfirmed-creation] [--timeout MS] [--poll-interval MS]";
16
- const CREATE_INSTANCE_INDETERMINATE_REMEDIATION = "DSS may have accepted the creation, but no future ID or project incarnation authorizes cleanup. Inspect `dss app instances <appId>` and DSS task history; delete only after creation is known terminal and the target identity is verified.";
11
+ const CREATE_INSTANCE_USAGE = commandUsage("app", "create-instance");
12
+ const MANIFEST_VERSION_USAGE = commandUsage("app", "manifest-version");
13
+ const SET_MANIFEST_VERSION_USAGE = commandUsage("app", "set-manifest-version");
14
+ const CREATE_SUCCESSOR_USAGE = commandUsage("app", "create-successor-instance");
15
+ const SUCCESSOR_PREFLIGHT_USAGE = commandUsage("app", "successor-preflight");
16
+ const VERIFY_INSTANCE_USAGE = commandUsage("app", "verify-instance");
17
+ const DELETE_INSTANCE_USAGE = commandUsage("app", "delete-instance");
18
+ const CREATE_INSTANCE_INDETERMINATE_REMEDIATION = `DSS may have accepted the creation, but no future ID or project incarnation authorizes cleanup. Inspect \`${commandUsage("app", "instances")}\` and DSS task history; delete only after creation is known terminal and the target identity is verified.`;
17
19
  const CREATE_INSTANCE_REJECTED_REMEDIATION = "DSS refused the creation request, so no instance project was created: fix the reported problem and retry. If the target key itself is the problem, rerun create-instance with targetProjectKey omitted to generate a fresh random key (the generated key is a new key, never the rejected one).";
18
20
  const DELETE_INSTANCE_FUTURE_REMEDIATION = "The supplied creation future could not authorize deletion. Inspect that future and the target project, then retry only with a future whose terminal result reports this project.";
19
21
  const DELETE_INSTANCE_UNCONFIRMED_REMEDIATION = "Creation may still be running and DSS returned no future ID. Inspect the app's instances and wait until creation is known terminal before running delete-instance without --unconfirmed-creation.";
@@ -67,28 +69,25 @@ function optionalSuccessorTarget(flags, usage) {
67
69
  }
68
70
  return value.trim();
69
71
  }
70
- export const appCommands = {
72
+ export const appCommands = withUsage("app", {
71
73
  list: {
72
74
  handler: (c) => c.applications.listApps(),
73
- usage: "dss app list",
74
75
  description: "List all Dataiku App templates.",
75
76
  examples: ["dss app list",],
76
77
  },
77
78
  manifest: {
78
79
  handler: (c, a) => {
79
- requireArgs(a, 1, "dss app manifest <appId>");
80
+ requireArgs(a, 1, commandUsage("app", "manifest"));
80
81
  return c.applications.getAppManifest(a[0]);
81
82
  },
82
- usage: "dss app manifest <appId>",
83
83
  description: "Get the manifest of a Dataiku App template.",
84
84
  examples: ["dss app manifest my-app",],
85
85
  },
86
86
  instances: {
87
87
  handler: (c, a) => {
88
- requireArgs(a, 1, "dss app instances <appId>");
88
+ requireArgs(a, 1, commandUsage("app", "instances"));
89
89
  return c.applications.listInstances(a[0]);
90
90
  },
91
- usage: "dss app instances <appId>",
92
91
  description: "List instances created from a Dataiku App template.",
93
92
  examples: ["dss app instances my-app",],
94
93
  },
@@ -97,7 +96,6 @@ export const appCommands = {
97
96
  requireNoArgs(a, MANIFEST_VERSION_USAGE);
98
97
  return c.applications.getManifestVersion(f["project-key"]);
99
98
  },
100
- usage: MANIFEST_VERSION_USAGE,
101
99
  description: "Read the app-manifest version of a Dataiku App template or app-instance project: the raw persisted string only, never a synthesized default.",
102
100
  examples: ["dss app manifest-version --project-key MYAPP_TEMPLATE",],
103
101
  },
@@ -117,7 +115,6 @@ export const appCommands = {
117
115
  requiredExternalGates: [VISUAL_UI_GATE,],
118
116
  };
119
117
  },
120
- usage: VERIFY_INSTANCE_USAGE,
121
118
  description: "Read-only API readiness check for an app instance: project type, registration under the app, authoritative raw manifest version, and manifest reference validation. The visual UI remains an explicit external SSO gate.",
122
119
  examples: [
123
120
  "dss app verify-instance my-app --project-key RELEASE_INSTANCE",
@@ -184,7 +181,7 @@ export const appCommands = {
184
181
  ...safeErrorSummary(error),
185
182
  };
186
183
  }
187
- const instance = plainRecord(created);
184
+ const instance = asRecord(created);
188
185
  if (!instance) {
189
186
  return {
190
187
  success: false,
@@ -388,7 +385,6 @@ export const appCommands = {
388
385
  : {}),
389
386
  };
390
387
  },
391
- usage: CREATE_INSTANCE_USAGE,
392
388
  description: "Create an app instance from a Dataiku App template, optionally waiting for the creation future. Omit targetProjectKey to generate a random APP_ key (the default display name); explicit keys are trimmed and must be absent.",
393
389
  examples: [
394
390
  'dss app create-instance my-app --data \'{"targetProjectKey":"NEWPROJ"}\'',
@@ -409,7 +405,6 @@ export const appCommands = {
409
405
  dryRun: true,
410
406
  }, SUCCESSOR_PREFLIGHT_USAGE);
411
407
  },
412
- usage: SUCCESSOR_PREFLIGHT_USAGE,
413
408
  description: "Run every read-only successor gate before changing the template version: validate the template, verify the predecessor, prove an explicit --to target absent, and optionally snapshot the predecessor ACL. Omit --to to preflight generated-key mode, where no target exists yet and nothing is probed or allocated.",
414
409
  examples: [
415
410
  "dss app successor-preflight my-app --from OLD_INSTANCE --to NEW_INSTANCE",
@@ -432,7 +427,6 @@ export const appCommands = {
432
427
  pollIntervalMs: num(f["poll-interval"], "--poll-interval"),
433
428
  }, CREATE_SUCCESSOR_USAGE);
434
429
  },
435
- usage: CREATE_SUCCESSOR_USAGE,
436
430
  description: "Create a new app instance from the current template version alongside an existing instance. An explicit --to keeps the strict caller-chosen-key contract (proven absent before the single POST); omit --to to generate the successor key once during apply and let the terminal future name it. The predecessor is never modified and is retired separately and deliberately; the creation future is always awaited.",
437
431
  examples: [
438
432
  "dss app create-successor-instance my-app --from OLD_INSTANCE --to NEW_INSTANCE",
@@ -442,20 +436,18 @@ export const appCommands = {
442
436
  },
443
437
  "instance-manifest": {
444
438
  handler: (c, a, f) => {
445
- requireNoArgs(a, "dss app instance-manifest [--project-key KEY]");
439
+ requireNoArgs(a, commandUsage("app", "instance-manifest"));
446
440
  return c.applications.getInstanceManifest(f["project-key"]);
447
441
  },
448
- usage: "dss app instance-manifest [--project-key KEY]",
449
442
  description: "Get the app manifest of a Dataiku App template or app-instance project.",
450
443
  examples: ["dss app instance-manifest --project-key MYINSTANCE",],
451
444
  },
452
445
  "save-instance-manifest": {
453
446
  handler: (c, a, f) => {
454
- requireNoArgs(a, "dss app save-instance-manifest (--data JSON|--data-file PATH|--stdin) [--project-key KEY]");
447
+ requireNoArgs(a, commandUsage("app", "save-instance-manifest"));
455
448
  const manifest = requiredJsonInput(f, "--data, --data-file, or --stdin is required (manifest JSON).");
456
449
  return c.applications.saveInstanceManifest(manifest, f["project-key"]);
457
450
  },
458
- usage: "dss app save-instance-manifest (--data JSON|--data-file PATH|--stdin) [--project-key KEY]",
459
451
  description: "Save the app manifest of a Dataiku App template project (homepage sections, use-as-recipe settings). Classic app-instance project manifests are read-only through this endpoint.",
460
452
  examples: [
461
453
  "dss app save-instance-manifest --data-file manifest.json --project-key MYAPP_TEMPLATE",
@@ -506,7 +498,6 @@ export const appCommands = {
506
498
  uiPublicationVerified: false,
507
499
  };
508
500
  },
509
- usage: SET_MANIFEST_VERSION_USAGE,
510
501
  description: "Set the raw app-manifest version and/or version notes of a Dataiku App template through the public app-manifest endpoint. This is not a publish transaction: the persisted string becomes the template version that new instances inherit, and the visual UI remains an external gate.",
511
502
  examples: [
512
503
  "dss app set-manifest-version --manifest-version 2.0.0 --project-key MYAPP_TEMPLATE",
@@ -515,7 +506,7 @@ export const appCommands = {
515
506
  },
516
507
  "validate-manifest": {
517
508
  handler: async (c, a, f) => {
518
- requireNoArgs(a, "dss app validate-manifest [--data JSON|--data-file PATH|--stdin] [--project-key KEY]");
509
+ requireNoArgs(a, commandUsage("app", "validate-manifest"));
519
510
  const payload = jsonInput(f);
520
511
  const manifest = payload ?? await c.applications.getInstanceManifest(f["project-key"]);
521
512
  const result = await c.applications.validateAppManifest(manifest, f["project-key"]);
@@ -524,7 +515,6 @@ export const appCommands = {
524
515
  }
525
516
  return result;
526
517
  },
527
- usage: "dss app validate-manifest [--data JSON|--data-file PATH|--stdin] [--project-key KEY]",
528
518
  description: "Validate an app manifest against source-verifiable reference data (scenario IDs, managed-folder IDs, variable names). Without a payload, reads the target project's app manifest.",
529
519
  examples: [
530
520
  "dss app validate-manifest --data-file manifest.json --project-key MYAPP_TEMPLATE",
@@ -533,11 +523,10 @@ export const appCommands = {
533
523
  },
534
524
  "compare-manifest": {
535
525
  handler: (c, a, f) => {
536
- requireArgs(a, 1, "dss app compare-manifest <appId> --project-key KEY");
537
- const projectKey = requiredStringFlag(f, "project-key", "dss app compare-manifest <appId> --project-key KEY");
526
+ requireArgs(a, 1, commandUsage("app", "compare-manifest"));
527
+ const projectKey = requiredStringFlag(f, "project-key", commandUsage("app", "compare-manifest"));
538
528
  return c.applications.compareAppManifest(a[0], projectKey);
539
529
  },
540
- usage: "dss app compare-manifest <appId> --project-key KEY",
541
530
  description: "Compare a Dataiku App template with the target app instance (normalized hashes and deterministic path-level differences; only project identity fields are omitted).",
542
531
  examples: ["dss app compare-manifest my-app --project-key MYINSTANCE",],
543
532
  },
@@ -720,7 +709,6 @@ export const appCommands = {
720
709
  pollCount: waited.pollCount,
721
710
  };
722
711
  },
723
- usage: DELETE_INSTANCE_USAGE,
724
712
  description: "Delete an app-instance project (destructive: removes the instance project). With --future-id, requires the recorded project-incarnation hash, waits without aborting, verifies that the terminal future reports this target, rechecks the incarnation, then deletes.",
725
713
  examples: [
726
714
  "dss app delete-instance --project-key MYINSTANCE",
@@ -729,16 +717,15 @@ export const appCommands = {
729
717
  },
730
718
  "business-app-instance-permissions": {
731
719
  handler: (c, a) => {
732
- requireArgs(a, 3, "dss app business-app-instance-permissions <businessAppId> <instanceProjectKey> <userLogin>");
720
+ requireArgs(a, 3, commandUsage("app", "business-app-instance-permissions"));
733
721
  return c.applications.getBusinessAppInstanceUserPermissions(a[0], a[1], a[2]);
734
722
  },
735
- usage: "dss app business-app-instance-permissions <businessAppId> <instanceProjectKey> <userLogin>",
736
723
  description: "Get a user's effective permissions on a Business App instance.",
737
724
  examples: ["dss app business-app-instance-permissions my-bapp INSTANCEPROJ alice",],
738
725
  },
739
726
  "permissions-snapshot": {
740
727
  handler: async (c, _a, f) => {
741
- const usage = "dss app permissions-snapshot --output PATH [--project-key KEY]";
728
+ const usage = commandUsage("app", "permissions-snapshot");
742
729
  requireNoArgs(_a, usage);
743
730
  const output = requiredStringFlag(f, "output", usage);
744
731
  const projectKey = c.resolveProjectKey(f["project-key"]);
@@ -757,7 +744,6 @@ export const appCommands = {
757
744
  capturedAt: snapshot.capturedAt,
758
745
  };
759
746
  },
760
- usage: "dss app permissions-snapshot --output PATH [--project-key KEY]",
761
747
  description: "Snapshot a project's access-control permissions to a local owner-only JSON file with a canonical integrity hash; commit it only when repository policy permits.",
762
748
  examples: [
763
749
  "dss app permissions-snapshot --output app-permissions.json --project-key MYINSTANCE",
@@ -765,7 +751,7 @@ export const appCommands = {
765
751
  },
766
752
  "permissions-diff": {
767
753
  handler: async (c, _a, f) => {
768
- const usage = "dss app permissions-diff --file PATH [--project-key KEY]";
754
+ const usage = commandUsage("app", "permissions-diff");
769
755
  requireNoArgs(_a, usage);
770
756
  const file = requiredStringFlag(f, "file", usage);
771
757
  const snapshot = readAppPermissionsSnapshot(file);
@@ -785,13 +771,12 @@ export const appCommands = {
785
771
  differences: diff.differences,
786
772
  };
787
773
  },
788
- usage: "dss app permissions-diff --file PATH [--project-key KEY]",
789
774
  description: "Compare a permission snapshot file against the live project permissions, returning deterministic path-level differences.",
790
775
  examples: ["dss app permissions-diff --file app-permissions.json --project-key MYINSTANCE",],
791
776
  },
792
777
  "permissions-restore": {
793
778
  handler: async (c, _a, f) => {
794
- const usage = "dss app permissions-restore --file PATH [--project-key KEY] [--dry-run]";
779
+ const usage = commandUsage("app", "permissions-restore");
795
780
  requireNoArgs(_a, usage);
796
781
  const file = requiredStringFlag(f, "file", usage);
797
782
  const snapshot = readAppPermissionsSnapshot(file);
@@ -840,10 +825,9 @@ export const appCommands = {
840
825
  applied: true,
841
826
  };
842
827
  },
843
- usage: "dss app permissions-restore --file PATH [--project-key KEY] [--dry-run]",
844
828
  description: "Restore a project's permissions from a snapshot file: hash-verifies the file, refuses cross-project restores, reads before writing, only PUTs when changed, and refetches to verify the result.",
845
829
  examples: [
846
830
  "dss app permissions-restore --file app-permissions.json --project-key MYINSTANCE --dry-run",
847
831
  ],
848
832
  },
849
- };
833
+ });
@@ -1,16 +1,17 @@
1
+ import { unexpectedResponseError, } from "../../errors.js";
1
2
  import { writeResponseToFile, } from "../../utils/response-file.js";
2
3
  import { json, parseBooleanOption, } from "../coerce.js";
4
+ import { commandUsage, withUsage, } from "../syntax.js";
3
5
  import { requireArgs, UsageError, } from "../usage.js";
4
- export const bundleCommands = {
6
+ export const bundleCommands = withUsage("bundle", {
5
7
  "list-exported": {
6
8
  handler: (c, _a, f) => c.bundles.listExported(f["project-key"]),
7
- usage: "dss bundle list-exported [--project-key KEY]",
8
9
  description: "List bundles exported from a project on the Design node.",
9
10
  examples: ["dss bundle list-exported",],
10
11
  },
11
12
  export: {
12
13
  handler: async (c, a, f) => {
13
- const usage = "dss bundle export <bundleId> [--release-notes TEXT] [--evaluate-standards-checks true|false] [--project-key KEY]";
14
+ const usage = commandUsage("bundle", "export");
14
15
  requireArgs(a, 1, usage);
15
16
  await c.bundles.exportBundle(a[0], f["project-key"], {
16
17
  ...(typeof f["release-notes"] === "string" ? { releaseNotes: f["release-notes"], } : {}),
@@ -22,7 +23,6 @@ export const bundleCommands = {
22
23
  });
23
24
  return { exported: a[0], };
24
25
  },
25
- usage: "dss bundle export <bundleId> [--release-notes TEXT] [--evaluate-standards-checks true|false] [--project-key KEY]",
26
26
  description: "Create an exported Design-node bundle. --release-notes forwards the documented releaseNotes parameter; --evaluate-standards-checks toggles the documented Project Standards Checks evaluation (default true; this instance forbids disabling it). DSS refuses re-exporting an existing bundle id — delete-exported first to replace one.",
27
27
  examples: [
28
28
  "dss bundle export v1",
@@ -31,40 +31,37 @@ export const bundleCommands = {
31
31
  },
32
32
  "delete-exported": {
33
33
  handler: async (c, a, f) => {
34
- requireArgs(a, 1, "dss bundle delete-exported <bundleId> [--project-key KEY]");
34
+ requireArgs(a, 1, commandUsage("bundle", "delete-exported"));
35
35
  await c.bundles.deleteExported(a[0], f["project-key"]);
36
36
  return { deleted: true, };
37
37
  },
38
- usage: "dss bundle delete-exported <bundleId> [--project-key KEY]",
39
38
  description: "Delete an exported Design-node bundle.",
40
39
  examples: ["dss bundle delete-exported v1",],
41
40
  },
42
41
  "download-exported": {
43
42
  handler: async (c, a, f) => {
44
- requireArgs(a, 1, "dss bundle download-exported <bundleId> --output PATH [--project-key KEY]");
43
+ requireArgs(a, 1, commandUsage("bundle", "download-exported"));
45
44
  const out = f["output"];
46
45
  if (!out)
47
46
  throw new UsageError("--output PATH is required.", "missing_required_flag");
48
47
  const res = await c.bundles.downloadExportedArchive(a[0], f["project-key"]);
49
48
  if (!res.body) {
50
- throw new Error("bundles.downloadExportedArchive response did not include a body");
49
+ throw unexpectedResponseError("bundles.downloadExportedArchive response did not include a body");
51
50
  }
52
51
  const bytes = await writeResponseToFile(out, res);
53
52
  return { path: out, bytes, };
54
53
  },
55
- usage: "dss bundle download-exported <bundleId> --output PATH [--project-key KEY]",
56
54
  description: "Download an exported Design-node bundle archive to a local file.",
57
55
  examples: ["dss bundle download-exported v1 --output ./bundle.zip",],
58
56
  },
59
57
  publish: {
60
58
  handler: (c, a, f) => {
61
- const usage = "dss bundle publish <bundleId> [--published-project-key KEY] [--project-key KEY]";
59
+ const usage = commandUsage("bundle", "publish");
62
60
  requireArgs(a, 1, usage);
63
61
  return c.bundles.publish(a[0], f["project-key"], typeof f["published-project-key"] === "string"
64
62
  ? { publishedProjectKey: f["published-project-key"], }
65
63
  : {});
66
64
  },
67
- usage: "dss bundle publish <bundleId> [--published-project-key KEY] [--project-key KEY]",
68
65
  description: "Publish a Design-node bundle to the Project Deployer; --published-project-key forwards the documented publishedProjectKey query parameter (a new published project is created when no match exists; the source project's key is the server-side default).",
69
66
  examples: [
70
67
  "dss bundle publish v1",
@@ -73,32 +70,29 @@ export const bundleCommands = {
73
70
  },
74
71
  "list-imported": {
75
72
  handler: (c, _a, f) => c.bundles.listImported(f["project-key"]),
76
- usage: "dss bundle list-imported [--project-key KEY]",
77
73
  description: "List bundles imported into a project on the Automation node.",
78
74
  examples: ["dss bundle list-imported",],
79
75
  },
80
76
  "import-from-archive": {
81
77
  handler: (c, a, f) => {
82
- requireArgs(a, 1, "dss bundle import-from-archive <serverArchivePath> [--project-key KEY]");
78
+ requireArgs(a, 1, commandUsage("bundle", "import-from-archive"));
83
79
  return c.bundles.importFromArchive(a[0], f["project-key"]);
84
80
  },
85
- usage: "dss bundle import-from-archive <serverArchivePath> [--project-key KEY]",
86
81
  description: "Import a server-side bundle archive into an Automation-node project.",
87
82
  examples: ["dss bundle import-from-archive /data/bundles/v1.zip",],
88
83
  },
89
84
  "import-from-stream": {
90
85
  handler: async (c, a, f) => {
91
- requireArgs(a, 1, "dss bundle import-from-stream <filePath> [--project-key KEY]");
86
+ requireArgs(a, 1, commandUsage("bundle", "import-from-stream"));
92
87
  await c.bundles.importFromStream(a[0], f["project-key"]);
93
88
  return { imported: true, };
94
89
  },
95
- usage: "dss bundle import-from-stream <filePath> [--project-key KEY]",
96
90
  description: "Upload and import a local bundle archive into an Automation-node project.",
97
91
  examples: ["dss bundle import-from-stream ./v1.zip",],
98
92
  },
99
93
  activate: {
100
94
  handler: (c, a, f) => {
101
- const usage = "dss bundle activate <bundleId> [--scenarios JSON] [--project-key KEY]";
95
+ const usage = commandUsage("bundle", "activate");
102
96
  requireArgs(a, 1, usage);
103
97
  const rawScenarios = f["scenarios"];
104
98
  let scenariosToEnable;
@@ -108,13 +102,12 @@ export const bundleCommands = {
108
102
  || parsed === null
109
103
  || Array.isArray(parsed)
110
104
  || !Object.values(parsed).every((value) => typeof value === "boolean")) {
111
- throw new UsageError("--scenarios must be a JSON object mapping scenario IDs to true|false. Usage: dss bundle activate <bundleId> --scenarios '{\"daily_build\":true}'");
105
+ throw new UsageError(`--scenarios must be a JSON object mapping scenario IDs to true|false. Usage: ${commandUsage("bundle", "activate")}`);
112
106
  }
113
107
  scenariosToEnable = parsed;
114
108
  }
115
109
  return c.bundles.activate(a[0], f["project-key"], scenariosToEnable !== undefined ? { scenariosToEnable, } : {});
116
110
  },
117
- usage: "dss bundle activate <bundleId> [--scenarios JSON] [--project-key KEY]",
118
111
  description: "Activate an imported Automation-node bundle; --scenarios forwards the documented scenario-ID-to-enabled dict as the scenariosActiveOnActivation body.",
119
112
  examples: [
120
113
  "dss bundle activate v1",
@@ -123,21 +116,19 @@ export const bundleCommands = {
123
116
  },
124
117
  preload: {
125
118
  handler: (c, a, f) => {
126
- requireArgs(a, 1, "dss bundle preload <bundleId> [--project-key KEY]");
119
+ requireArgs(a, 1, commandUsage("bundle", "preload"));
127
120
  return c.bundles.preload(a[0], f["project-key"]);
128
121
  },
129
- usage: "dss bundle preload <bundleId> [--project-key KEY]",
130
122
  description: "Preload an imported Automation-node bundle (stage data/models).",
131
123
  examples: ["dss bundle preload v1",],
132
124
  },
133
125
  "delete-imported": {
134
126
  handler: async (c, a, f) => {
135
- requireArgs(a, 1, "dss bundle delete-imported <bundleId> [--project-key KEY]");
127
+ requireArgs(a, 1, commandUsage("bundle", "delete-imported"));
136
128
  await c.bundles.deleteImported(a[0], f["project-key"]);
137
129
  return { deleted: true, };
138
130
  },
139
- usage: "dss bundle delete-imported <bundleId> [--project-key KEY]",
140
131
  description: "Delete an imported Automation-node bundle.",
141
132
  examples: ["dss bundle delete-imported v1",],
142
133
  },
143
- };
134
+ });
@@ -1,76 +1,69 @@
1
1
  import { requiredJsonInput, } from "../coerce.js";
2
+ import { commandUsage, withUsage, } from "../syntax.js";
2
3
  import { requireArgs, } from "../usage.js";
3
- export const businessAppCommands = {
4
+ export const businessAppCommands = withUsage("business-app", {
4
5
  list: {
5
6
  handler: (c) => c.applications.listBusinessApps(),
6
- usage: "dss business-app list",
7
7
  description: "List all Business Apps.",
8
8
  examples: ["dss business-app list",],
9
9
  },
10
10
  get: {
11
11
  handler: (c, a) => {
12
- requireArgs(a, 1, "dss business-app get <id>");
12
+ requireArgs(a, 1, commandUsage("business-app", "get"));
13
13
  return c.applications.getBusinessApp(a[0]);
14
14
  },
15
- usage: "dss business-app get <id>",
16
15
  description: "Get Business App details.",
17
16
  examples: ["dss business-app get my-bapp",],
18
17
  },
19
18
  settings: {
20
19
  handler: (c, a) => {
21
- requireArgs(a, 1, "dss business-app settings <id>");
20
+ requireArgs(a, 1, commandUsage("business-app", "settings"));
22
21
  return c.applications.getBusinessAppSettings(a[0]);
23
22
  },
24
- usage: "dss business-app settings <id>",
25
23
  description: "Get Business App settings.",
26
24
  examples: ["dss business-app settings my-bapp",],
27
25
  },
28
26
  "save-settings": {
29
27
  handler: (c, a, f) => {
30
- requireArgs(a, 1, "dss business-app save-settings <id> (--data JSON|--data-file PATH|--stdin)");
28
+ requireArgs(a, 1, commandUsage("business-app", "save-settings"));
31
29
  const body = requiredJsonInput(f, "--data, --data-file, or --stdin is required (settings JSON).");
32
30
  return c.applications.saveBusinessAppSettings(a[0], body);
33
31
  },
34
- usage: "dss business-app save-settings <id> (--data JSON|--data-file PATH|--stdin)",
35
32
  description: "Save Business App settings (admin only; includes connection remapping).",
36
33
  examples: ["dss business-app save-settings my-bapp --data-file settings.json",],
37
34
  },
38
35
  instances: {
39
36
  handler: (c, a) => {
40
- requireArgs(a, 1, "dss business-app instances <id>");
37
+ requireArgs(a, 1, commandUsage("business-app", "instances"));
41
38
  return c.applications.listBusinessAppInstances(a[0]);
42
39
  },
43
- usage: "dss business-app instances <id>",
44
40
  description: "List instances of a Business App.",
45
41
  examples: ["dss business-app instances my-bapp",],
46
42
  },
47
43
  "create-instance": {
48
44
  handler: (c, a, f) => {
49
- requireArgs(a, 1, "dss business-app create-instance <id> (--data JSON|--data-file PATH|--stdin)");
45
+ requireArgs(a, 1, commandUsage("business-app", "create-instance"));
50
46
  const body = requiredJsonInput(f, "--data, --data-file, or --stdin is required (instance payload).");
51
47
  return c.applications.createBusinessAppInstance(a[0], body);
52
48
  },
53
- usage: "dss business-app create-instance <id> (--data JSON|--data-file PATH|--stdin)",
54
49
  description: "Create an instance of a Business App.",
55
50
  examples: ["dss business-app create-instance my-bapp --data '{}'",],
56
51
  },
57
52
  "upgrade-instance": {
58
53
  handler: (c, a) => {
59
- requireArgs(a, 2, "dss business-app upgrade-instance <id> <projectKey>");
54
+ requireArgs(a, 2, commandUsage("business-app", "upgrade-instance"));
60
55
  return c.applications.upgradeBusinessAppInstance(a[0], a[1]);
61
56
  },
62
- usage: "dss business-app upgrade-instance <id> <projectKey>",
63
57
  description: "Upgrade a Business App instance to the latest version.",
64
58
  examples: ["dss business-app upgrade-instance my-bapp INSTANCEPROJ",],
65
59
  },
66
60
  "install-from-archive": {
67
61
  handler: async (c, a) => {
68
- requireArgs(a, 1, "dss business-app install-from-archive <filePath>");
62
+ requireArgs(a, 1, commandUsage("business-app", "install-from-archive"));
69
63
  await c.applications.installBusinessAppFromArchive(a[0]);
70
64
  return { installed: true, };
71
65
  },
72
- usage: "dss business-app install-from-archive <filePath>",
73
66
  description: "Install or upgrade a Business App from a zip archive (admin only).",
74
67
  examples: ["dss business-app install-from-archive ./my-bapp.zip",],
75
68
  },
76
- };
69
+ });