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,9 +1,10 @@
1
1
  import { readFileSync, writeFileSync, } from "node:fs";
2
2
  import { ClientValidationError, } from "../../errors.js";
3
- import { stableHash, } from "../../utils/stable-hash.js";
3
+ import { SHA256_HEX_PATTERN, stableHash, } from "../../utils/stable-hash.js";
4
4
  import { json, jsonInput, num, numFlag, parseBooleanOption, } from "../coerce.js";
5
5
  import { executionMode, } from "../flags.js";
6
6
  import { enqueueCliWarning, isNotFoundError, readIfExists, skipResult, } from "../output.js";
7
+ import { commandUsage, withUsage, } from "../syntax.js";
7
8
  import { requireArgs, UsageError, } from "../usage.js";
8
9
  const CODE_ENV_LANGS = ["PYTHON", "R",];
9
10
  /** Validate a positional `<lang>` argument: required, must be PYTHON or R. */
@@ -24,10 +25,10 @@ function definitionHashMismatch(envLang, envName, expected, current) {
24
25
  function validateExpectHash(value) {
25
26
  if (value === undefined || value === false)
26
27
  return undefined;
27
- if (typeof value !== "string" || !/^[0-9a-fA-F]{64}$/.test(value)) {
28
+ if (typeof value !== "string" || !SHA256_HEX_PATTERN.test(value)) {
28
29
  throw new ClientValidationError("Expected code env definition hash must be a 64-character SHA-256 hex digest.", "validation_failed", "Use the definitionHash value returned by dss code-env get.");
29
30
  }
30
- return value;
31
+ return value.toLowerCase();
31
32
  }
32
33
  function codeEnvWait(flags) {
33
34
  return flags["no-wait"] !== true;
@@ -64,10 +65,10 @@ function codeEnvPackageList(flags) {
64
65
  }
65
66
  return packages;
66
67
  }
67
- export const codeEnvCommands = {
68
+ export const codeEnvCommands = withUsage("code-env", {
68
69
  list: {
69
70
  handler: (c, _a, f) => {
70
- const usage = "dss code-env list [--lang PYTHON|R]";
71
+ const usage = commandUsage("code-env", "list");
71
72
  const lang = f["lang"];
72
73
  return c.codeEnvs.list({
73
74
  envLang: typeof lang === "string"
@@ -75,46 +76,42 @@ export const codeEnvCommands = {
75
76
  : undefined,
76
77
  });
77
78
  },
78
- usage: "dss code-env list [--lang PYTHON|R]",
79
79
  description: "List code environments, optionally filtered to one language.",
80
80
  examples: ["dss code-env list", "dss code-env list --lang PYTHON",],
81
81
  },
82
82
  get: {
83
83
  handler: (c, a) => {
84
- const usage = "dss code-env get <lang> <name>";
84
+ const usage = commandUsage("code-env", "get");
85
85
  requireArgs(a, 2, usage);
86
86
  const envLang = requireEnvLang(a[0], usage);
87
87
  return c.codeEnvs.get(envLang, a[1]);
88
88
  },
89
- usage: "dss code-env get <lang> <name>",
90
89
  description: "Get code environment details: requested vs installed packages, Python interpreter, deployment mode, and the stable definition hash (definitionHash) used by set-definition --expect-hash.",
91
90
  examples: ["dss code-env get PYTHON my_env",],
92
91
  },
93
92
  "get-definition": {
94
93
  handler: (c, a) => {
95
- const usage = "dss code-env get-definition <lang> <name>";
94
+ const usage = commandUsage("code-env", "get-definition");
96
95
  requireArgs(a, 2, usage);
97
96
  const envLang = requireEnvLang(a[0], usage);
98
97
  return c.codeEnvs.getDefinition(envLang, a[1]);
99
98
  },
100
- usage: "dss code-env get-definition <lang> <name>",
101
99
  description: "Get the raw code environment definition exactly as DSS stores it; capture its hash (definitionHash from code-env get) before replacing it with set-definition --expect-hash.",
102
100
  examples: ["dss code-env get-definition PYTHON my_env",],
103
101
  },
104
102
  "list-logs": {
105
103
  handler: (c, a) => {
106
- const usage = "dss code-env list-logs <lang> <name>";
104
+ const usage = commandUsage("code-env", "list-logs");
107
105
  requireArgs(a, 2, usage);
108
106
  const envLang = requireEnvLang(a[0], usage);
109
107
  return c.codeEnvs.listLogs(envLang, a[1]);
110
108
  },
111
- usage: "dss code-env list-logs <lang> <name>",
112
109
  description: "List the build log files DSS keeps for a code environment.",
113
110
  examples: ["dss code-env list-logs PYTHON my_env",],
114
111
  },
115
112
  "get-log": {
116
113
  handler: async (c, a, f) => {
117
- const usage = "dss code-env get-log <lang> <name> <logName> [--max-lines N|--max-log-lines N] [--max-log-bytes N] [--output PATH]";
114
+ const usage = commandUsage("code-env", "get-log");
118
115
  requireArgs(a, 3, usage);
119
116
  const envLang = requireEnvLang(a[0], usage);
120
117
  const maxLines = numFlag(f, ["max-lines", "max-log-lines",]);
@@ -153,7 +150,6 @@ export const codeEnvCommands = {
153
150
  }
154
151
  return { ...result, envLang, envName: a[1], logName: a[2], };
155
152
  },
156
- usage: "dss code-env get-log <lang> <name> <logName> [--max-lines N|--max-log-lines N] [--max-log-bytes N] [--output PATH]",
157
153
  description: "Fetch one code-env build log, bounded for safe output: the last --max-lines lines (default 500, 0 for all) and at most --max-log-bytes bytes (default 10 MiB, 0 for all). --output PATH writes the kept content to a file; stdout then carries the path metadata. A truncation warning names which cap hit.",
158
154
  examples: [
159
155
  "dss code-env get-log PYTHON my_env install.log --max-lines 200",
@@ -162,23 +158,22 @@ export const codeEnvCommands = {
162
158
  },
163
159
  version: {
164
160
  handler: (c, a) => {
165
- const usage = "dss code-env version <lang> <name> <projectKey>";
161
+ const usage = commandUsage("code-env", "version");
166
162
  requireArgs(a, 3, usage);
167
163
  const envLang = requireEnvLang(a[0], usage);
168
164
  return c.codeEnvs.getVersionForProject(envLang, a[1], a[2]);
169
165
  },
170
- usage: "dss code-env version <lang> <name> <projectKey>",
171
166
  description: "Resolve the code environment version a project uses (versioned automation environments); empty version for unversioned environments.",
172
167
  examples: ["dss code-env version PYTHON my_env MY_PROJ",],
173
168
  },
174
169
  create: {
175
170
  handler: async (c, a, f) => {
176
- const usage = "dss code-env create <lang> <name> --deployment-mode MODE";
171
+ const usage = commandUsage("code-env", "create");
177
172
  requireArgs(a, 2, usage);
178
173
  const envLang = requireEnvLang(a[0], usage);
179
174
  const deploymentMode = f["deployment-mode"];
180
175
  if (!deploymentMode) {
181
- throw new UsageError("--deployment-mode is required. Usage: dss code-env create <lang> <name> --deployment-mode MODE");
176
+ throw new UsageError(`--deployment-mode is required. Usage: ${commandUsage("code-env", "create")}`);
182
177
  }
183
178
  const params = codeEnvParams(f);
184
179
  const wait = codeEnvWait(f);
@@ -213,7 +208,6 @@ export const codeEnvCommands = {
213
208
  });
214
209
  return { created: a[1], resource: "code-env", envLang, ...created, };
215
210
  },
216
- usage: "dss code-env create <lang> <name> --deployment-mode MODE [--params JSON|--data JSON|--data-file PATH|--stdin] [--python-interpreter PYTHON311] [--no-wait] [--if-not-exists] [--dry-run]",
217
211
  description: "Create a code environment; --no-wait hands back a DSS future payload you can settle with dss future wait.",
218
212
  examples: [
219
213
  "dss code-env create PYTHON my_env --deployment-mode DESIGN_MANAGED --python-interpreter PYTHON311",
@@ -222,12 +216,12 @@ export const codeEnvCommands = {
222
216
  },
223
217
  "set-definition": {
224
218
  handler: async (c, a, f) => {
225
- const usage = "dss code-env set-definition <lang> <name> (--data JSON|--data-file PATH|--stdin) [--expect-hash SHA256]";
219
+ const usage = commandUsage("code-env", "set-definition");
226
220
  requireArgs(a, 2, usage);
227
221
  const envLang = requireEnvLang(a[0], usage);
228
222
  const definition = jsonInput(f);
229
223
  if (!definition) {
230
- throw new UsageError("--data, --data-file, or --stdin is required. Usage: dss code-env set-definition <lang> <name> --data JSON");
224
+ throw new UsageError(`--data, --data-file, or --stdin is required. Usage: ${commandUsage("code-env", "set-definition")}`);
231
225
  }
232
226
  const expectHash = validateExpectHash(f["expect-hash"]);
233
227
  const definitionHash = stableHash(definition);
@@ -253,7 +247,6 @@ export const codeEnvCommands = {
253
247
  }
254
248
  return c.codeEnvs.setDefinition(envLang, a[1], definition, { expectHash, });
255
249
  },
256
- usage: "dss code-env set-definition <lang> <name> (--data JSON|--data-file PATH|--stdin) [--expect-hash SHA256] [--dry-run]",
257
250
  description: "Replace a code environment definition previously fetched from DSS (get-definition). --expect-hash SHA256 refuses the PUT unless the current definition still hashes to the hash captured with code-env get, so concurrent edits are never clobbered; --dry-run also fetches the current definition and reports both hashes plus a changed flag.",
258
251
  examples: [
259
252
  "dss code-env set-definition PYTHON my_env --data-file code-env.json --expect-hash $HASH --dry-run",
@@ -261,7 +254,7 @@ export const codeEnvCommands = {
261
254
  },
262
255
  "set-packages": {
263
256
  handler: async (c, a, f) => {
264
- const usage = "dss code-env set-packages <lang> <name> (--packages PKGS|--package PKG|--file PATH)";
257
+ const usage = commandUsage("code-env", "set-packages");
265
258
  requireArgs(a, 2, usage);
266
259
  const envLang = requireEnvLang(a[0], usage);
267
260
  const packages = codeEnvPackageList(f);
@@ -281,7 +274,6 @@ export const codeEnvCommands = {
281
274
  }
282
275
  return c.codeEnvs.setPackages(envLang, a[1], packages, { installCorePackages, expectHash, });
283
276
  },
284
- usage: "dss code-env set-packages <lang> <name> (--packages PKGS|--package PKG|--file PATH) [--install-core-packages true|false] [--expect-hash SHA256] [--dry-run]",
285
277
  description: "Fetch the current definition, merge the requested package specs (and --install-core-packages) into it, then PUT the merged definition, so fields outside the package list are never dropped; --expect-hash refuses the merge when DSS changed since the hash was captured. The package list is replaced wholesale, so an explicitly empty --packages value or an empty --file clears the requested packages.",
286
278
  examples: [
287
279
  "dss code-env set-packages PYTHON my_env --packages 'tabulate\\nnameparser' --dry-run",
@@ -290,7 +282,7 @@ export const codeEnvCommands = {
290
282
  },
291
283
  "update-packages": {
292
284
  handler: async (c, a, f) => {
293
- const usage = "dss code-env update-packages <lang> <name>";
285
+ const usage = commandUsage("code-env", "update-packages");
294
286
  requireArgs(a, 2, usage);
295
287
  const envLang = requireEnvLang(a[0], usage);
296
288
  const wait = codeEnvWait(f);
@@ -316,13 +308,12 @@ export const codeEnvCommands = {
316
308
  }
317
309
  return c.codeEnvs.updatePackages(envLang, a[1], opts);
318
310
  },
319
- usage: "dss code-env update-packages <lang> <name> [--force-rebuild] [--env-version VERSION] [--no-wait] [--dry-run]",
320
311
  description: "Rebuild or update code environment packages to match the requested specs; --no-wait hands back a DSS future payload you can settle with dss future wait.",
321
312
  examples: ["dss code-env update-packages PYTHON my_env --force-rebuild --dry-run",],
322
313
  },
323
314
  "update-images": {
324
315
  handler: async (c, a, f) => {
325
- const usage = "dss code-env update-images <lang> <name>";
316
+ const usage = commandUsage("code-env", "update-images");
326
317
  requireArgs(a, 2, usage);
327
318
  const envLang = requireEnvLang(a[0], usage);
328
319
  const wait = codeEnvWait(f);
@@ -340,7 +331,6 @@ export const codeEnvCommands = {
340
331
  }
341
332
  return c.codeEnvs.updateImages(envLang, a[1], { envVersion, wait, });
342
333
  },
343
- usage: "dss code-env update-images <lang> <name> [--env-version VERSION] [--no-wait] [--dry-run]",
344
334
  description: "Rebuild the Docker image(s) of a code environment to match its settings; --env-version targets one version of a versioned environment and --no-wait hands back a DSS future payload you can settle with dss future wait.",
345
335
  examples: [
346
336
  "dss code-env update-images PYTHON my_env --dry-run",
@@ -349,12 +339,12 @@ export const codeEnvCommands = {
349
339
  },
350
340
  "set-jupyter": {
351
341
  handler: async (c, a, f) => {
352
- const usage = "dss code-env set-jupyter <lang> <name> --active true|false";
342
+ const usage = commandUsage("code-env", "set-jupyter");
353
343
  requireArgs(a, 2, usage);
354
344
  const envLang = requireEnvLang(a[0], usage);
355
345
  const active = parseBooleanOption(f["active"], "--active");
356
346
  if (active === undefined) {
357
- throw new UsageError("--active is required. Usage: dss code-env set-jupyter <lang> <name> --active true|false");
347
+ throw new UsageError(`--active is required. Usage: ${commandUsage("code-env", "set-jupyter")}`);
358
348
  }
359
349
  const wait = codeEnvWait(f);
360
350
  if (executionMode(f).dryRun) {
@@ -370,13 +360,12 @@ export const codeEnvCommands = {
370
360
  }
371
361
  return c.codeEnvs.setJupyterSupport(envLang, a[1], active, { wait, });
372
362
  },
373
- usage: "dss code-env set-jupyter <lang> <name> --active true|false [--no-wait] [--dry-run]",
374
363
  description: "Enable or disable Jupyter support for a code environment; --no-wait hands back a DSS future payload you can settle with dss future wait.",
375
364
  examples: ["dss code-env set-jupyter PYTHON my_env --active true --dry-run",],
376
365
  },
377
366
  delete: {
378
367
  handler: async (c, a, f) => {
379
- const usage = "dss code-env delete <lang> <name>";
368
+ const usage = commandUsage("code-env", "delete");
380
369
  requireArgs(a, 2, usage);
381
370
  const envLang = requireEnvLang(a[0], usage);
382
371
  const wait = codeEnvWait(f);
@@ -404,7 +393,6 @@ export const codeEnvCommands = {
404
393
  }
405
394
  return c.codeEnvs.delete(envLang, a[1], { wait, });
406
395
  },
407
- usage: "dss code-env delete <lang> <name> [--no-wait] [--if-exists] [--dry-run]",
408
396
  description: "Delete a code environment; --no-wait hands back a DSS future payload you can settle with dss future wait.",
409
397
  examples: ["dss code-env delete PYTHON my_env --dry-run",],
410
398
  },
@@ -414,10 +402,9 @@ export const codeEnvCommands = {
414
402
  return c.codeEnvs.listUsages();
415
403
  if (a.length === 2)
416
404
  return c.codeEnvs.listUsages(a[0], a[1]);
417
- throw new UsageError("Usage: dss code-env usages [<lang> <name>]");
405
+ throw new UsageError(`Usage: ${commandUsage("code-env", "usages")}`);
418
406
  },
419
- usage: "dss code-env usages [<lang> <name>]",
420
407
  description: "List code environment usages globally or for one environment.",
421
408
  examples: ["dss code-env usages", "dss code-env usages PYTHON my_env",],
422
409
  },
423
- };
410
+ });
@@ -1,8 +1,9 @@
1
1
  import { readFileSync, } from "node:fs";
2
2
  import { num, readStdinText, stripUtf8Bom, } from "../coerce.js";
3
3
  import { enqueueCliWarning, } from "../output.js";
4
+ import { commandUsage, withUsage, } from "../syntax.js";
4
5
  import { UsageError, } from "../usage.js";
5
- const CODE_RUN_USAGE = "dss code run (--file PATH | --stdin) [--env ENV] [--timeout MS (default 120000)] [--keep] [--full-log] [--max-log-bytes N (default 1048576)] [--project-key KEY]";
6
+ const CODE_RUN_USAGE = commandUsage("code", "run");
6
7
  function previewFlagValue(value) {
7
8
  const text = typeof value === "string" ? value : String(value);
8
9
  return text.length <= 32 ? text : `${text.slice(0, 32)}…`;
@@ -84,7 +85,7 @@ function unwrapCodeRunError(error) {
84
85
  }
85
86
  return error;
86
87
  }
87
- export const codeCommands = {
88
+ export const codeCommands = withUsage("code", {
88
89
  run: {
89
90
  handler: async (c, a, f) => {
90
91
  const timeoutMs = parseCodeRunIntegerFlag(f["timeout"], "--timeout");
@@ -123,7 +124,6 @@ export const codeCommands = {
123
124
  }
124
125
  return result;
125
126
  },
126
- usage: CODE_RUN_USAGE,
127
127
  description: "Run Python through a throwaway custom-python scenario and return captured output plus outcome. --timeout caps waiting; --max-log-bytes caps logs; --full-log returns the capped raw log. Exits 4 unless outcome is SUCCESS.",
128
128
  examples: [
129
129
  "dss code run --file inspect.py",
@@ -132,4 +132,4 @@ export const codeCommands = {
132
132
  "dss code run --file inspect.py --full-log",
133
133
  ],
134
134
  },
135
- };
135
+ });
@@ -2,6 +2,7 @@ import { sanitizeErrorSecrets, sanitizeSecrets, } from "../../utils/secret-sanit
2
2
  import { requiredJsonInput, } from "../coerce.js";
3
3
  import { executionMode, } from "../flags.js";
4
4
  import { readIfExists, skipResult, } from "../output.js";
5
+ import { commandUsage, withUsage, } from "../syntax.js";
5
6
  import { requireArgs, UsageError, } from "../usage.js";
6
7
  /**
7
8
  * Keys of a connection payload that carry credentials. CLI plan/error/output
@@ -76,12 +77,11 @@ function requireConnectionName(value, usage) {
76
77
  }
77
78
  return trimmed;
78
79
  }
79
- export const connectionCommands = {
80
+ export const connectionCommands = withUsage("connection", {
80
81
  list: {
81
82
  handler: (c, _a, f) => c.connections.list({
82
83
  type: f["type"],
83
84
  }),
84
- usage: "dss connection list [--type TYPE]",
85
85
  description: "List all connection names, optionally filtered by connection type.",
86
86
  examples: ["dss connection list", "dss connection list --type Filesystem",],
87
87
  },
@@ -90,24 +90,22 @@ export const connectionCommands = {
90
90
  mode: f["mode"],
91
91
  projectKey: f["project-key"],
92
92
  }),
93
- usage: "dss connection infer [--mode fast|rich] [--project-key KEY]",
94
93
  description: "List connections with inferred types and metadata.",
95
94
  examples: ["dss connection infer", "dss connection infer --mode rich",],
96
95
  },
97
96
  get: {
98
97
  handler: async (c, a) => {
99
- const usage = "dss connection get <name>";
98
+ const usage = commandUsage("connection", "get");
100
99
  requireArgs(a, 1, usage);
101
100
  const details = await c.connections.adminGet(requireConnectionName(a[0], usage));
102
101
  return sanitizeConnectionSecrets(details);
103
102
  },
104
- usage: "dss connection get <name>",
105
103
  description: "Get a connection by name (admin). Credential-bearing params (e.g. params.password) are redacted in output.",
106
104
  examples: ["dss connection get postgres",],
107
105
  },
108
106
  create: {
109
107
  handler: async (c, _a, f) => {
110
- const usage = "dss connection create (--data JSON|--data-file PATH|--stdin)";
108
+ const usage = commandUsage("connection", "create");
111
109
  const body = requiredConnectionJson(f, usage);
112
110
  if (executionMode(f).dryRun) {
113
111
  return {
@@ -127,7 +125,6 @@ export const connectionCommands = {
127
125
  throw sanitizeConnectionError(error, connectionSecretsFromBody(body));
128
126
  }
129
127
  },
130
- usage: "dss connection create (--data JSON|--data-file PATH|--stdin) [--dry-run]",
131
128
  description: 'Create a connection (admin). Body is the Connection definition, e.g. {"name":"new-connection","type":"PostgreSQL","params":{"host":"...","user":"...","password":"..."}}. Secrets are never echoed in errors or output.',
132
129
  examples: [
133
130
  `dss connection create --data '{"name":"new-connection","type":"PostgreSQL","params":{"db":"dbname","user":"myuser","password":"s3cret"}}'`,
@@ -135,7 +132,7 @@ export const connectionCommands = {
135
132
  },
136
133
  update: {
137
134
  handler: async (c, a, f) => {
138
- const usage = "dss connection update <name> (--data JSON|--data-file PATH|--stdin) [--dry-run]";
135
+ const usage = commandUsage("connection", "update");
139
136
  requireArgs(a, 1, usage);
140
137
  const name = requireConnectionName(a[0], usage);
141
138
  const body = requiredConnectionJson(f, usage);
@@ -160,7 +157,6 @@ export const connectionCommands = {
160
157
  throw sanitizeConnectionError(error, secrets);
161
158
  }
162
159
  },
163
- usage: "dss connection update <name> (--data JSON|--data-file PATH|--stdin) [--dry-run]",
164
160
  description: "Update a connection (admin). The body MUST be the Connection object obtained from `dss connection get` (PUT semantics); type and name cannot be modified. Use --dry-run to preview the merged result without writing.",
165
161
  examples: [
166
162
  `dss connection update postgres --data '{"type":"PostgreSQL","name":"postgres","allowWrite":true,"params":{"db":"dbname","user":"myuser","password":"s3cret"}}'`,
@@ -168,7 +164,7 @@ export const connectionCommands = {
168
164
  },
169
165
  delete: {
170
166
  handler: async (c, a, f) => {
171
- const usage = "dss connection delete <name> [--if-exists] [--dry-run]";
167
+ const usage = commandUsage("connection", "delete");
172
168
  requireArgs(a, 1, usage);
173
169
  const name = requireConnectionName(a[0], usage);
174
170
  if (executionMode(f).dryRun) {
@@ -191,18 +187,16 @@ export const connectionCommands = {
191
187
  }
192
188
  return c.connections.adminDelete(name);
193
189
  },
194
- usage: "dss connection delete <name> [--if-exists] [--dry-run]",
195
190
  description: "Delete a connection (admin). Destructive: per the DSS docs no check is performed that the connection is not in use by a dataset.",
196
191
  examples: ["dss connection delete old-conn", "dss connection delete old-conn --if-exists",],
197
192
  },
198
193
  test: {
199
194
  handler: async (c, a) => {
200
- const usage = "dss connection test <name>";
195
+ const usage = commandUsage("connection", "test");
201
196
  requireArgs(a, 1, usage);
202
197
  const result = await c.connections.adminTest(requireConnectionName(a[0], usage));
203
198
  return sanitizeConnectionSecrets(result);
204
199
  },
205
- usage: "dss connection test <name>",
206
200
  description: "Test whether a connection is available (uses the same GET /connections/{name}/test route as the official Python client; returns connectionOK, errors when testing is unsupported for the type). Credential-bearing fields are redacted in output.",
207
201
  examples: ["dss connection test postgres",],
208
202
  },
@@ -210,14 +204,13 @@ export const connectionCommands = {
210
204
  handler: (c, _a, f) => {
211
205
  const connection = f["connection"];
212
206
  if (!connection) {
213
- throw new UsageError("--connection is required. Usage: dss connection schemas --connection CONN");
207
+ throw new UsageError(`--connection is required. Usage: ${commandUsage("connection", "schemas")}`);
214
208
  }
215
209
  return c.connections.schemas({
216
210
  connection,
217
211
  projectKey: f["project-key"],
218
212
  });
219
213
  },
220
- usage: "dss connection schemas --connection CONN [--project-key KEY]",
221
214
  description: "List schemas in a SQL connection.",
222
215
  examples: ["dss connection schemas --connection ATHENA_CONN --project-key MYPROJ",],
223
216
  },
@@ -225,7 +218,7 @@ export const connectionCommands = {
225
218
  handler: (c, _a, f) => {
226
219
  const connection = f["connection"];
227
220
  if (!connection) {
228
- throw new UsageError("--connection is required. Usage: dss connection tables --connection CONN");
221
+ throw new UsageError(`--connection is required. Usage: ${commandUsage("connection", "tables")}`);
229
222
  }
230
223
  return c.connections.tables({
231
224
  connection,
@@ -234,7 +227,6 @@ export const connectionCommands = {
234
227
  projectKey: f["project-key"],
235
228
  });
236
229
  },
237
- usage: "dss connection tables --connection CONN [--catalog CATALOG] [--schema SCHEMA] [--project-key KEY]",
238
230
  description: "List importable tables in a SQL connection, optionally scoped by catalog and schema.",
239
231
  examples: [
240
232
  "dss connection tables --connection ATHENA_CONN --schema analytics --project-key MYPROJ",
@@ -242,7 +234,7 @@ export const connectionCommands = {
242
234
  },
243
235
  "prepare-import": {
244
236
  handler: async (c, _a, f) => {
245
- const usage = "dss connection prepare-import (--data JSON|--data-file PATH|--stdin) [--project-key KEY]";
237
+ const usage = commandUsage("connection", "prepare-import");
246
238
  const body = requiredJsonInput(f, `--data, --data-file, or --stdin is required (tables-import request). Usage: ${usage}`);
247
239
  const keys = body["keys"];
248
240
  if (!Array.isArray(keys) || keys.length === 0) {
@@ -273,7 +265,6 @@ export const connectionCommands = {
273
265
  projectKey: f["project-key"],
274
266
  });
275
267
  },
276
- usage: "dss connection prepare-import (--data JSON|--data-file PATH|--stdin) [--project-key KEY] [--dry-run]",
277
268
  description: 'Prepare the import of selected SQL or Hive tables (WRITE_CONF). Body is {"keys":[...]} per the DSS tables-import docs. Returns a DSS future; poll with `dss future wait <jobId>`.',
278
269
  examples: [
279
270
  `dss connection prepare-import --data '{"keys":[{"connectionName":"postgres","name":"my_table"}]}' --project-key MYPROJ`,
@@ -281,7 +272,7 @@ export const connectionCommands = {
281
272
  },
282
273
  "execute-import": {
283
274
  handler: async (c, _a, f) => {
284
- const usage = "dss connection execute-import (--data JSON|--data-file PATH|--stdin) [--project-key KEY]";
275
+ const usage = commandUsage("connection", "execute-import");
285
276
  const body = requiredJsonInput(f, `--data, --data-file, or --stdin is required (tables-import request). Usage: ${usage}`);
286
277
  const sql = body["sqlImportCandidates"];
287
278
  const hive = body["hiveImportCandidates"];
@@ -311,10 +302,9 @@ export const connectionCommands = {
311
302
  projectKey: f["project-key"],
312
303
  });
313
304
  },
314
- usage: "dss connection execute-import (--data JSON|--data-file PATH|--stdin) [--project-key KEY] [--dry-run]",
315
305
  description: "Perform an import from SQL/Hive table candidates (WRITE_CONF). Body carries sqlImportCandidates and/or hiveImportCandidates per the DSS tables-import docs. Returns a DSS future.",
316
306
  examples: [
317
307
  `dss connection execute-import --data '{"sqlImportCandidates":[{"connectionName":"pgsql","table":"my_table","checked":false,"datasetName":"imported_from_db","existingDatasetsNames":[]}]}' --project-key MYPROJ`,
318
308
  ],
319
309
  },
320
- };
310
+ });
@@ -1,38 +1,35 @@
1
1
  import { jsonInput, } from "../coerce.js";
2
+ import { commandUsage, withUsage, } from "../syntax.js";
2
3
  import { requireArgs, } from "../usage.js";
3
- export const continuousActivityCommands = {
4
+ export const continuousActivityCommands = withUsage("continuous-activity", {
4
5
  list: {
5
6
  handler: (c, _a, f) => c.continuousActivities.list(f["project-key"]),
6
- usage: "dss continuous-activity list [--project-key KEY]",
7
7
  description: "List continuous activities in a project.",
8
8
  examples: ["dss continuous-activity list",],
9
9
  },
10
10
  status: {
11
11
  handler: (c, a, f) => {
12
- requireArgs(a, 1, "dss continuous-activity status <recipeId> [--project-key KEY]");
12
+ requireArgs(a, 1, commandUsage("continuous-activity", "status"));
13
13
  return c.continuousActivities.getStatus(a[0], f["project-key"]);
14
14
  },
15
- usage: "dss continuous-activity status <recipeId> [--project-key KEY]",
16
15
  description: "Get a continuous recipe's desired and effective state.",
17
16
  examples: ["dss continuous-activity status compute_stream",],
18
17
  },
19
18
  start: {
20
19
  handler: (c, a, f) => {
21
- requireArgs(a, 1, "dss continuous-activity start <recipeId> [--data JSON|--data-file PATH|--stdin] [--project-key KEY]");
20
+ requireArgs(a, 1, commandUsage("continuous-activity", "start"));
22
21
  return c.continuousActivities.start(a[0], jsonInput(f), f["project-key"]);
23
22
  },
24
- usage: "dss continuous-activity start <recipeId> [--data JSON|--data-file PATH|--stdin] [--project-key KEY]",
25
23
  description: "Start a continuous recipe (optional loop restart params via JSON).",
26
24
  examples: ["dss continuous-activity start compute_stream",],
27
25
  },
28
26
  stop: {
29
27
  handler: async (c, a, f) => {
30
- requireArgs(a, 1, "dss continuous-activity stop <recipeId> [--project-key KEY]");
28
+ requireArgs(a, 1, commandUsage("continuous-activity", "stop"));
31
29
  await c.continuousActivities.stop(a[0], f["project-key"]);
32
30
  return { stopped: a[0], };
33
31
  },
34
- usage: "dss continuous-activity stop <recipeId> [--project-key KEY]",
35
32
  description: "Stop a continuous recipe.",
36
33
  examples: ["dss continuous-activity stop compute_stream",],
37
34
  },
38
- };
35
+ });
@@ -4,26 +4,25 @@ import { deepMerge, } from "../../utils/deep-merge.js";
4
4
  import { jsonInput, parseBooleanOption, } from "../coerce.js";
5
5
  import { executionMode, } from "../flags.js";
6
6
  import { readIfExists, skipResult, } from "../output.js";
7
+ import { commandUsage, withUsage, } from "../syntax.js";
7
8
  import { requireArgs, UsageError, } from "../usage.js";
8
- export const dashboardCommands = {
9
+ export const dashboardCommands = withUsage("dashboard", {
9
10
  list: {
10
11
  handler: (c, _a, f) => c.dashboards.list(f["project-key"]),
11
- usage: "dss dashboard list [--project-key KEY]",
12
12
  description: "List project dashboards.",
13
13
  examples: ["dss dashboard list",],
14
14
  },
15
15
  get: {
16
16
  handler: (c, a, f) => {
17
- requireArgs(a, 1, "dss dashboard get <id>");
17
+ requireArgs(a, 1, commandUsage("dashboard", "get"));
18
18
  return c.dashboards.get(a[0], f["project-key"]);
19
19
  },
20
- usage: "dss dashboard get <id> [--project-key KEY]",
21
20
  description: "Get dashboard definition.",
22
21
  examples: ["dss dashboard get DASHBOARD_ID",],
23
22
  },
24
23
  export: {
25
24
  handler: async (c, a, f) => {
26
- requireArgs(a, 1, "dss dashboard export <id> --output PATH [--paper-size SIZE] [--orientation PORTRAIT|LANDSCAPE] [--file-type PDF] [--slide-index N] [--project-key KEY]");
25
+ requireArgs(a, 1, commandUsage("dashboard", "export"));
27
26
  const outputPath = f["output"];
28
27
  if (typeof outputPath !== "string" || !outputPath.trim()) {
29
28
  throw new UsageError("--output PATH is required.", "missing_required_flag");
@@ -86,7 +85,6 @@ export const dashboardCommands = {
86
85
  slideIndex,
87
86
  };
88
87
  },
89
- usage: "dss dashboard export <id> --output PATH [--paper-size SIZE] [--orientation PORTRAIT|LANDSCAPE] [--file-type PDF] [--slide-index N] [--project-key KEY]",
90
88
  description: "Render a dashboard page as PDF. Requires DSS graphics export to be configured.",
91
89
  examples: [
92
90
  "dss dashboard export DASHBOARD_ID --output dashboard.pdf",
@@ -101,7 +99,7 @@ export const dashboardCommands = {
101
99
  const name = flagName ?? (typeof settingsName === "string" ? settingsName : undefined);
102
100
  const listed = parseBooleanOption(f["listed"], "--listed");
103
101
  if (!name) {
104
- throw new UsageError("--name or dashboard settings containing a string name are required. Usage: dss dashboard create --name NAME");
102
+ throw new UsageError(`--name or dashboard settings containing a string name are required. Usage: ${commandUsage("dashboard", "create")}`);
105
103
  }
106
104
  const payload = { ...(settings ?? { pages: [], }), name, };
107
105
  if (listed !== undefined)
@@ -131,7 +129,6 @@ export const dashboardCommands = {
131
129
  });
132
130
  return { created: created.id, resource: "dashboard", ...created, };
133
131
  },
134
- usage: "dss dashboard create (--name NAME|--data JSON|--data-file PATH|--stdin) [--listed true|false] [--if-not-exists] [--dry-run] [--project-key KEY]",
135
132
  description: "Create a dashboard from raw settings or minimal name/listed fields. Defaults to an empty pages array.",
136
133
  examples: [
137
134
  "dss dashboard create --name 'Agent dashboard' --listed true --dry-run",
@@ -140,7 +137,7 @@ export const dashboardCommands = {
140
137
  },
141
138
  update: {
142
139
  handler: async (c, a, f) => {
143
- requireArgs(a, 1, "dss dashboard update <id> [--name NAME|--listed true|false|--data JSON]");
140
+ requireArgs(a, 1, commandUsage("dashboard", "update"));
144
141
  const name = f["name"];
145
142
  const listed = parseBooleanOption(f["listed"], "--listed");
146
143
  const data = jsonInput(f);
@@ -163,13 +160,12 @@ export const dashboardCommands = {
163
160
  projectKey: f["project-key"],
164
161
  });
165
162
  },
166
- usage: "dss dashboard update <id> (--name NAME|--listed true|false|--data JSON|--data-file PATH|--stdin) [--dry-run] [--project-key KEY]",
167
163
  description: "Update dashboard settings via merge.",
168
164
  examples: ["dss dashboard update DASHBOARD_ID --listed true --dry-run",],
169
165
  },
170
166
  delete: {
171
167
  handler: async (c, a, f) => {
172
- requireArgs(a, 1, "dss dashboard delete <id>");
168
+ requireArgs(a, 1, commandUsage("dashboard", "delete"));
173
169
  const pk = f["project-key"];
174
170
  if (executionMode(f).dryRun || f["if-exists"] === true) {
175
171
  const current = await readIfExists(() => c.dashboards.get(a[0], pk));
@@ -182,8 +178,7 @@ export const dashboardCommands = {
182
178
  await c.dashboards.delete(a[0], pk);
183
179
  return { deleted: a[0], resource: "dashboard", };
184
180
  },
185
- usage: "dss dashboard delete <id> [--if-exists] [--dry-run] [--project-key KEY]",
186
181
  description: "Delete a dashboard.",
187
182
  examples: ["dss dashboard delete DASHBOARD_ID --dry-run",],
188
183
  },
189
- };
184
+ });