dataiku-sdk 3.3.0 → 3.5.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 (126) hide show
  1. package/README.md +6 -4
  2. package/dist/build-metadata.json +1 -1
  3. package/dist/src/cli/command-syntax.json +14524 -0
  4. package/dist/src/cli/commands/analysis.js +6 -9
  5. package/dist/src/cli/commands/api-deployer.js +15 -33
  6. package/dist/src/cli/commands/api-service.js +17 -27
  7. package/dist/src/cli/commands/app.js +22 -39
  8. package/dist/src/cli/commands/bundle.js +15 -24
  9. package/dist/src/cli/commands/business-app.js +10 -17
  10. package/dist/src/cli/commands/code-env.js +23 -36
  11. package/dist/src/cli/commands/code.js +5 -5
  12. package/dist/src/cli/commands/connection.js +12 -22
  13. package/dist/src/cli/commands/continuous-activity.js +6 -9
  14. package/dist/src/cli/commands/dashboard.js +8 -13
  15. package/dist/src/cli/commands/data-collection.js +9 -16
  16. package/dist/src/cli/commands/data-quality.js +14 -26
  17. package/dist/src/cli/commands/dataset.js +28 -51
  18. package/dist/src/cli/commands/discussion.js +7 -10
  19. package/dist/src/cli/commands/doctor.js +3 -3
  20. package/dist/src/cli/commands/flow-zone.js +8 -17
  21. package/dist/src/cli/commands/folder.js +12 -20
  22. package/dist/src/cli/commands/future.js +7 -10
  23. package/dist/src/cli/commands/group.js +7 -11
  24. package/dist/src/cli/commands/insight.js +7 -11
  25. package/dist/src/cli/commands/job.js +17 -25
  26. package/dist/src/cli/commands/knowledge-bank.js +5 -6
  27. package/dist/src/cli/commands/llm.js +5 -8
  28. package/dist/src/cli/commands/macro.js +11 -18
  29. package/dist/src/cli/commands/meaning.js +7 -11
  30. package/dist/src/cli/commands/metrics.js +7 -10
  31. package/dist/src/cli/commands/ml-task.js +12 -20
  32. package/dist/src/cli/commands/model-evaluation-store.js +7 -11
  33. package/dist/src/cli/commands/notebook.js +15 -27
  34. package/dist/src/cli/commands/plugin.js +35 -68
  35. package/dist/src/cli/commands/project-deployer.js +10 -22
  36. package/dist/src/cli/commands/project-folder.js +10 -17
  37. package/dist/src/cli/commands/project-git.js +39 -71
  38. package/dist/src/cli/commands/project-library.js +15 -23
  39. package/dist/src/cli/commands/project.js +9 -26
  40. package/dist/src/cli/commands/recipe.d.ts +16 -0
  41. package/dist/src/cli/commands/recipe.js +83 -94
  42. package/dist/src/cli/commands/saved-model.js +23 -39
  43. package/dist/src/cli/commands/scenario.js +21 -35
  44. package/dist/src/cli/commands/sql.js +4 -4
  45. package/dist/src/cli/commands/statistics.js +11 -18
  46. package/dist/src/cli/commands/streaming-endpoint.js +7 -11
  47. package/dist/src/cli/commands/user.js +11 -22
  48. package/dist/src/cli/commands/variable.js +3 -4
  49. package/dist/src/cli/commands/webapp.js +10 -16
  50. package/dist/src/cli/commands/wiki.js +9 -13
  51. package/dist/src/cli/commands/workspace.js +8 -14
  52. package/dist/src/cli/contract.d.ts +5 -15
  53. package/dist/src/cli/contract.js +179 -461
  54. package/dist/src/cli/doctor.js +1 -0
  55. package/dist/src/cli/env.d.ts +2 -0
  56. package/dist/src/cli/env.js +15 -1
  57. package/dist/src/cli/helpers/app-permissions.js +2 -1
  58. package/dist/src/cli/helpers/flow-zone.js +2 -1
  59. package/dist/src/cli/helpers/recipe.js +2 -1
  60. package/dist/src/cli/output-schemas.d.ts +24 -0
  61. package/dist/src/cli/output-schemas.js +233 -0
  62. package/dist/src/cli/syntax.d.ts +83 -0
  63. package/dist/src/cli/syntax.js +217 -0
  64. package/dist/src/cli/types.d.ts +3 -0
  65. package/dist/src/cli/usage.d.ts +1 -1
  66. package/dist/src/cli/usage.js +4 -2
  67. package/dist/src/cli/version.js +2 -0
  68. package/dist/src/cli.js +37 -64
  69. package/dist/src/client.d.ts +10 -1
  70. package/dist/src/client.js +27 -11
  71. package/dist/src/errors.d.ts +12 -1
  72. package/dist/src/errors.js +34 -7
  73. package/dist/src/generated/action-output-schemas.json +1735 -0
  74. package/dist/src/index.d.ts +1 -3
  75. package/dist/src/index.js +2 -2
  76. package/dist/src/resources/api-services.js +2 -3
  77. package/dist/src/resources/applications.js +2 -4
  78. package/dist/src/resources/code-envs.js +2 -2
  79. package/dist/src/resources/data-quality.js +4 -3
  80. package/dist/src/resources/datasets.d.ts +13 -0
  81. package/dist/src/resources/datasets.js +42 -8
  82. package/dist/src/resources/flow-zones.d.ts +6 -2
  83. package/dist/src/resources/flow-zones.js +10 -5
  84. package/dist/src/resources/folders.js +4 -2
  85. package/dist/src/resources/futures.d.ts +2 -0
  86. package/dist/src/resources/futures.js +39 -27
  87. package/dist/src/resources/insights.js +3 -2
  88. package/dist/src/resources/jobs.js +41 -31
  89. package/dist/src/resources/macros.js +2 -4
  90. package/dist/src/resources/ml-tasks.js +28 -19
  91. package/dist/src/resources/notebooks.js +2 -3
  92. package/dist/src/resources/plugins.d.ts +0 -2
  93. package/dist/src/resources/plugins.js +0 -3
  94. package/dist/src/resources/project-git.d.ts +6 -12
  95. package/dist/src/resources/project-git.js +31 -58
  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.d.ts +4 -2
  99. package/dist/src/resources/projects.js +37 -36
  100. package/dist/src/resources/recipes.d.ts +28 -0
  101. package/dist/src/resources/recipes.js +116 -84
  102. package/dist/src/resources/sql.js +8 -3
  103. package/dist/src/resources/statistics.js +2 -1
  104. package/dist/src/resources/variables.js +2 -1
  105. package/dist/src/resources/webapps.js +2 -3
  106. package/dist/src/schemas.d.ts +1 -2
  107. package/dist/src/schemas.js +1 -1
  108. package/dist/src/skill.js +6 -7
  109. package/dist/src/utils/cleanup-ledger.js +9 -8
  110. package/dist/src/utils/git-reference.d.ts +12 -0
  111. package/dist/src/utils/git-reference.js +38 -0
  112. package/dist/src/utils/polling.d.ts +3 -0
  113. package/dist/src/utils/polling.js +3 -0
  114. package/dist/src/utils/project-archive.js +2 -2
  115. package/dist/src/utils/stable-hash.d.ts +3 -1
  116. package/dist/src/utils/stable-hash.js +2 -0
  117. package/package.json +8 -8
  118. package/plugin.json +1 -1
  119. package/skills/dataiku-dss/SKILL.md +3 -2
  120. package/skills/dataiku-dss/references/app-releases.md +2 -3
  121. package/skills/dataiku-dss/references/authentication.md +7 -7
  122. package/skills/dataiku-dss/references/coding.md +1 -1
  123. package/skills/dataiku-dss/references/mutations.md +1 -1
  124. package/skills/dataiku-dss/references/troubleshooting.md +2 -2
  125. package/dist/src/utils/pagination.d.ts +0 -8
  126. package/dist/src/utils/pagination.js +0 -23
@@ -3,6 +3,7 @@ import { validatedPluginGitUrl, validatePluginDestinationPath, validatePluginId,
3
3
  import { num, readStdinText, } from "../coerce.js";
4
4
  import { executionMode, } from "../flags.js";
5
5
  import { planResult, } from "../output.js";
6
+ import { commandUsage, withUsage, } from "../syntax.js";
6
7
  import { requireArgs, requireNoArgs, UsageError, } from "../usage.js";
7
8
  const PLUGIN_EXIT_CODES = { usage: 1, error: 2, transient: 3, };
8
9
  /** Plan-time endpoint helpers. Paths are validated, then encoded per segment. */
@@ -63,39 +64,38 @@ function optionalStringFlag(flags, name) {
63
64
  }
64
65
  return value.trim();
65
66
  }
66
- const LIST_USAGE = "dss plugin list";
67
- const INSTALL_ZIP_USAGE = "dss plugin install-from-zip --file PATH [--dry-run] [--plan]";
68
- const INSTALL_STORE_USAGE = "dss plugin install-from-store <pluginId> [--dry-run] [--plan]";
69
- const INSTALL_GIT_USAGE = "dss plugin install-from-git --repository URL [--checkout REF] [--path-in-repository PATH] [--dry-run] [--plan]";
70
- const DOWNLOAD_USAGE = "dss plugin download <pluginId> --output PATH";
71
- const UPDATE_ZIP_USAGE = "dss plugin update-from-zip <pluginId> --file PATH [--dry-run] [--plan]";
72
- const UPDATE_STORE_USAGE = "dss plugin update-from-store <pluginId> [--dry-run] [--plan]";
73
- const UPDATE_GIT_USAGE = "dss plugin update-from-git <pluginId> --repository URL [--checkout REF] [--path-in-repository PATH] [--dry-run] [--plan]";
74
- const SETTINGS_GET_USAGE = "dss plugin settings-get <pluginId> [--project-key KEY]";
75
- const SETTINGS_SET_USAGE = "dss plugin settings-set <pluginId> (--content JSON|--file PATH|--stdin) [--project-key KEY] [--dry-run] [--plan]";
76
- const CODE_ENV_CREATE_USAGE = "dss plugin code-env-create <pluginId> [--conda] [--python-interpreter PY] [--wait] [--timeout MS] [--poll-interval MS] [--dry-run] [--plan]";
77
- const CODE_ENV_UPDATE_USAGE = "dss plugin code-env-update <pluginId> [--wait] [--timeout MS] [--poll-interval MS] [--dry-run] [--plan]";
78
- const MOVE_TO_DEV_USAGE = "dss plugin move-to-dev <pluginId> [--dry-run] [--plan]";
79
- const USAGES_USAGE = "dss plugin usages <pluginId> [--project-key KEY]";
80
- const DELETE_USAGE = "dss plugin delete <pluginId> [--force] [--dry-run] [--plan]";
81
- const CREATE_DEV_USAGE = "dss plugin create-dev <pluginId> --creation-mode EMPTY|GIT_CLONE|GIT_EXPORT [--repository URL] [--checkout REF] [--path-in-repository PATH] [--dry-run] [--plan]";
82
- const GET_GIT_REMOTE_USAGE = "dss plugin get-git-remote <pluginId>";
83
- const SET_GIT_REMOTE_USAGE = "dss plugin set-git-remote <pluginId> --repository URL [--dry-run] [--plan]";
84
- const DELETE_GIT_REMOTE_USAGE = "dss plugin delete-git-remote <pluginId> [--dry-run] [--plan]";
85
- const GIT_BRANCHES_USAGE = "dss plugin git-branches <pluginId>";
86
- const PUSH_USAGE = "dss plugin push <pluginId> [--dry-run] [--plan]";
87
- const PULL_USAGE = "dss plugin pull <pluginId> [--dry-run] [--plan]";
88
- const FETCH_USAGE = "dss plugin fetch <pluginId> [--dry-run] [--plan]";
89
- const RESET_LOCAL_USAGE = "dss plugin reset-local <pluginId> [--dry-run] [--plan]";
90
- const RESET_REMOTE_USAGE = "dss plugin reset-remote <pluginId> [--dry-run] [--plan]";
91
- const CONTENTS_LIST_USAGE = "dss plugin contents-list <pluginId>";
92
- const CONTENTS_GET_USAGE = "dss plugin contents-get <pluginId> <path> [--output PATH]";
93
- const CONTENTS_PUT_USAGE = "dss plugin contents-put <pluginId> <path> (--content TEXT|--file PATH|--stdin) [--dry-run] [--plan]";
94
- const CONTENTS_DELETE_USAGE = "dss plugin contents-delete <pluginId> <path> [--dry-run] [--plan]";
95
- const DETAILS_USAGE = "dss plugin details <pluginId> <path>";
96
- const FOLDER_ADD_USAGE = "dss plugin folder-add <pluginId> <path> [--dry-run] [--plan]";
97
- const RENAME_USAGE = "dss plugin rename <pluginId> <path> <new-name> [--dry-run] [--plan]";
98
- const MOVE_USAGE = "dss plugin move <pluginId> <path> <destination-folder> [--dry-run] [--plan]";
67
+ const INSTALL_ZIP_USAGE = commandUsage("plugin", "install-from-zip");
68
+ const INSTALL_STORE_USAGE = commandUsage("plugin", "install-from-store");
69
+ const INSTALL_GIT_USAGE = commandUsage("plugin", "install-from-git");
70
+ const DOWNLOAD_USAGE = commandUsage("plugin", "download");
71
+ const UPDATE_ZIP_USAGE = commandUsage("plugin", "update-from-zip");
72
+ const UPDATE_STORE_USAGE = commandUsage("plugin", "update-from-store");
73
+ const UPDATE_GIT_USAGE = commandUsage("plugin", "update-from-git");
74
+ const SETTINGS_GET_USAGE = commandUsage("plugin", "settings-get");
75
+ const SETTINGS_SET_USAGE = commandUsage("plugin", "settings-set");
76
+ const CODE_ENV_CREATE_USAGE = commandUsage("plugin", "code-env-create");
77
+ const CODE_ENV_UPDATE_USAGE = commandUsage("plugin", "code-env-update");
78
+ const MOVE_TO_DEV_USAGE = commandUsage("plugin", "move-to-dev");
79
+ const USAGES_USAGE = commandUsage("plugin", "usages");
80
+ const DELETE_USAGE = commandUsage("plugin", "delete");
81
+ const CREATE_DEV_USAGE = commandUsage("plugin", "create-dev");
82
+ const GET_GIT_REMOTE_USAGE = commandUsage("plugin", "get-git-remote");
83
+ const SET_GIT_REMOTE_USAGE = commandUsage("plugin", "set-git-remote");
84
+ const DELETE_GIT_REMOTE_USAGE = commandUsage("plugin", "delete-git-remote");
85
+ const GIT_BRANCHES_USAGE = commandUsage("plugin", "git-branches");
86
+ const PUSH_USAGE = commandUsage("plugin", "push");
87
+ const PULL_USAGE = commandUsage("plugin", "pull");
88
+ const FETCH_USAGE = commandUsage("plugin", "fetch");
89
+ const RESET_LOCAL_USAGE = commandUsage("plugin", "reset-local");
90
+ const RESET_REMOTE_USAGE = commandUsage("plugin", "reset-remote");
91
+ const CONTENTS_LIST_USAGE = commandUsage("plugin", "contents-list");
92
+ const CONTENTS_GET_USAGE = commandUsage("plugin", "contents-get");
93
+ const CONTENTS_PUT_USAGE = commandUsage("plugin", "contents-put");
94
+ const CONTENTS_DELETE_USAGE = commandUsage("plugin", "contents-delete");
95
+ const DETAILS_USAGE = commandUsage("plugin", "details");
96
+ const FOLDER_ADD_USAGE = commandUsage("plugin", "folder-add");
97
+ const RENAME_USAGE = commandUsage("plugin", "rename");
98
+ const MOVE_USAGE = commandUsage("plugin", "move");
99
99
  async function waitFuture(client, jobId, flags) {
100
100
  return client
101
101
  .futures.wait(jobId, {
@@ -103,10 +103,9 @@ async function waitFuture(client, jobId, flags) {
103
103
  timeoutMs: num(flags["timeout"], "--timeout"),
104
104
  });
105
105
  }
106
- export const pluginCommands = {
106
+ export const pluginCommands = withUsage("plugin", {
107
107
  list: {
108
108
  handler: (c) => c.plugins.list(),
109
- usage: LIST_USAGE,
110
109
  description: "List installed plugins (including development plugins).",
111
110
  examples: ["dss plugin list",],
112
111
  },
@@ -125,7 +124,6 @@ export const pluginCommands = {
125
124
  await c.plugins.installFromZip(file);
126
125
  return { installed: true, from: "zip", };
127
126
  },
128
- usage: INSTALL_ZIP_USAGE,
129
127
  description: "Install a plugin from a zip file. Fails when the plugin is already installed (use update-from-zip to replace).",
130
128
  examples: ["dss plugin install-from-zip --file ./my-plugin.zip",],
131
129
  },
@@ -144,7 +142,6 @@ export const pluginCommands = {
144
142
  await c.plugins.installFromStore(pluginId);
145
143
  return { installed: pluginId, from: "store", };
146
144
  },
147
- usage: INSTALL_STORE_USAGE,
148
145
  description: "Install a plugin from the Dataiku store. Fails when already installed.",
149
146
  examples: ["dss plugin install-from-store my-plugin",],
150
147
  },
@@ -177,7 +174,6 @@ export const pluginCommands = {
177
174
  });
178
175
  return { installed: true, from: "git", repositoryUrl: url, };
179
176
  },
180
- usage: INSTALL_GIT_USAGE,
181
177
  description: "Install a plugin by checking out a Git repository (must contain plugin.json). Fails when already installed. HTTP(S) URLs must not embed credentials.",
182
178
  examples: [
183
179
  "dss plugin install-from-git --repository git@github.com:acme/my-plugin.git --checkout main",
@@ -195,7 +191,6 @@ export const pluginCommands = {
195
191
  const bytes = await writeResponseToFileForPlugin(out, res);
196
192
  return { path: out, bytes, };
197
193
  },
198
- usage: DOWNLOAD_USAGE,
199
194
  description: "Download a development plugin as a zip archive to a local file.",
200
195
  examples: ["dss plugin download my-plugin --output ./my-plugin.zip",],
201
196
  },
@@ -215,7 +210,6 @@ export const pluginCommands = {
215
210
  await c.plugins.updateFromZip(pluginId, file);
216
211
  return { updated: pluginId, from: "zip", };
217
212
  },
218
- usage: UPDATE_ZIP_USAGE,
219
213
  description: "Re-install a plugin from a zip file. Fails when the plugin is not already installed.",
220
214
  examples: ["dss plugin update-from-zip my-plugin --file ./my-plugin.zip",],
221
215
  },
@@ -233,7 +227,6 @@ export const pluginCommands = {
233
227
  await c.plugins.updateFromStore(pluginId);
234
228
  return { updated: pluginId, from: "store", };
235
229
  },
236
- usage: UPDATE_STORE_USAGE,
237
230
  description: "Update a plugin from the Dataiku Store.",
238
231
  examples: ["dss plugin update-from-store my-plugin",],
239
232
  },
@@ -267,7 +260,6 @@ export const pluginCommands = {
267
260
  });
268
261
  return { updated: true, from: "git", repositoryUrl: url, };
269
262
  },
270
- usage: UPDATE_GIT_USAGE,
271
263
  description: "Update an installed plugin from a Git repository (must contain plugin.json). Fails when not installed. HTTP(S) URLs must not embed credentials.",
272
264
  examples: [
273
265
  "dss plugin update-from-git my-plugin --repository git@github.com:acme/my-plugin.git --checkout v2",
@@ -280,7 +272,6 @@ export const pluginCommands = {
280
272
  projectKey: optionalStringFlag(f, "project-key"),
281
273
  });
282
274
  },
283
- usage: SETTINGS_GET_USAGE,
284
275
  description: "Get plugin settings (config parameters and code env name), optionally scoped to a project.",
285
276
  examples: ["dss plugin settings-get my-plugin --project-key MYPROJECT",],
286
277
  },
@@ -307,7 +298,6 @@ export const pluginCommands = {
307
298
  });
308
299
  return { updated: pluginId, settingsKeys: Object.keys(settings), };
309
300
  },
310
- usage: SETTINGS_SET_USAGE,
311
301
  description: "Replace plugin settings. Send only settings previously obtained through settings-get; DSS rejects unknown shapes.",
312
302
  examples: [
313
303
  'dss plugin settings-set my-plugin --content \'{"config":{"key":"value"},"codeEnvName":"py-env"}\'',
@@ -337,7 +327,6 @@ export const pluginCommands = {
337
327
  return future;
338
328
  return await waitFuture(c, future.jobId, f);
339
329
  },
340
- usage: CODE_ENV_CREATE_USAGE,
341
330
  description: "Create the code env of a plugin. Returns the DSS future (jobId); --wait polls it to completion.",
342
331
  examples: [
343
332
  "dss plugin code-env-create my-plugin --python-interpreter PYTHON36",
@@ -361,7 +350,6 @@ export const pluginCommands = {
361
350
  return future;
362
351
  return await waitFuture(c, future.jobId, f);
363
352
  },
364
- usage: CODE_ENV_UPDATE_USAGE,
365
353
  description: "Update (rebuild) the code env of a plugin. Returns the DSS future (jobId); --wait polls it to completion.",
366
354
  examples: ["dss plugin code-env-update my-plugin --wait",],
367
355
  },
@@ -379,7 +367,6 @@ export const pluginCommands = {
379
367
  await c.plugins.moveToDev(pluginId);
380
368
  return { moved: pluginId, to: "dev", };
381
369
  },
382
- usage: MOVE_TO_DEV_USAGE,
383
370
  description: "Move an installed plugin to the development environment for editing.",
384
371
  examples: ["dss plugin move-to-dev my-plugin",],
385
372
  },
@@ -390,7 +377,6 @@ export const pluginCommands = {
390
377
  projectKey: optionalStringFlag(f, "project-key"),
391
378
  });
392
379
  },
393
- usage: USAGES_USAGE,
394
380
  description: "List usages of a plugin's elements in projects or globally; missingTypes reports types the usage analysis could not resolve.",
395
381
  examples: ["dss plugin usages my-plugin --project-key MYPROJECT",],
396
382
  },
@@ -411,7 +397,6 @@ export const pluginCommands = {
411
397
  await c.plugins.delete(pluginId, { force, });
412
398
  return { deleted: pluginId, force, };
413
399
  },
414
- usage: DELETE_USAGE,
415
400
  description: "Delete a plugin. DSS refuses when usages are detected unless --force is passed.",
416
401
  examples: ["dss plugin delete my-plugin", "dss plugin delete my-plugin --force",],
417
402
  },
@@ -450,7 +435,6 @@ export const pluginCommands = {
450
435
  });
451
436
  return { created: pluginId, creationMode, };
452
437
  },
453
- usage: CREATE_DEV_USAGE,
454
438
  description: "Create a new development plugin: EMPTY, GIT_CLONE (clone the repository as the plugin), or GIT_EXPORT (use a subpath of the repository). HTTP(S) URLs must not embed credentials.",
455
439
  examples: [
456
440
  "dss plugin create-dev my-plugin",
@@ -462,7 +446,6 @@ export const pluginCommands = {
462
446
  requireArgs(a, 1, GET_GIT_REMOTE_USAGE);
463
447
  return c.plugins.getGitRemote(validatePluginId(a[0]));
464
448
  },
465
- usage: GET_GIT_REMOTE_USAGE,
466
449
  description: "Get the Git remote declared for a development plugin (repositoryUrl is null when unset).",
467
450
  examples: ["dss plugin get-git-remote my-plugin",],
468
451
  },
@@ -486,7 +469,6 @@ export const pluginCommands = {
486
469
  const result = await c.plugins.setGitRemote(pluginId, url);
487
470
  return { pluginId, ...result, };
488
471
  },
489
- usage: SET_GIT_REMOTE_USAGE,
490
472
  description: "Declare the Git remote for a development plugin. HTTP(S) URLs must not embed credentials; use SSH remotes or DSS-managed Git credentials.",
491
473
  examples: ["dss plugin set-git-remote my-plugin --repository git@github.com:acme/my-plugin.git",],
492
474
  },
@@ -504,7 +486,6 @@ export const pluginCommands = {
504
486
  await c.plugins.deleteGitRemote(pluginId);
505
487
  return { deleted: "gitRemote", pluginId, };
506
488
  },
507
- usage: DELETE_GIT_REMOTE_USAGE,
508
489
  description: "Delete the Git remote declared for a development plugin.",
509
490
  examples: ["dss plugin delete-git-remote my-plugin",],
510
491
  },
@@ -513,7 +494,6 @@ export const pluginCommands = {
513
494
  requireArgs(a, 1, GIT_BRANCHES_USAGE);
514
495
  return c.plugins.listGitBranches(validatePluginId(a[0]));
515
496
  },
516
- usage: GIT_BRANCHES_USAGE,
517
497
  description: "List the Git branches of a development plugin's declared remote.",
518
498
  examples: ["dss plugin git-branches my-plugin",],
519
499
  },
@@ -531,7 +511,6 @@ export const pluginCommands = {
531
511
  const result = await c.plugins.push(pluginId);
532
512
  return { pushed: pluginId, result, };
533
513
  },
534
- usage: PUSH_USAGE,
535
514
  description: "Push the development plugin's content to its previously-declared Git remote.",
536
515
  examples: ["dss plugin push my-plugin",],
537
516
  },
@@ -549,7 +528,6 @@ export const pluginCommands = {
549
528
  const result = await c.plugins.pull(pluginId);
550
529
  return { pulled: pluginId, result, };
551
530
  },
552
- usage: PULL_USAGE,
553
531
  description: "Pull (and rebase) the development plugin's content from its Git remote.",
554
532
  examples: ["dss plugin pull my-plugin",],
555
533
  },
@@ -567,7 +545,6 @@ export const pluginCommands = {
567
545
  const result = await c.plugins.fetch(pluginId);
568
546
  return { fetched: pluginId, result, };
569
547
  },
570
- usage: FETCH_USAGE,
571
548
  description: "Fetch the development plugin's content from its Git remote without changing files.",
572
549
  examples: ["dss plugin fetch my-plugin",],
573
550
  },
@@ -585,7 +562,6 @@ export const pluginCommands = {
585
562
  const result = await c.plugins.resetToLocalHeadState(pluginId);
586
563
  return { reset: "localHeadState", pluginId, result, };
587
564
  },
588
- usage: RESET_LOCAL_USAGE,
589
565
  description: "Reset the development plugin to its local HEAD state, discarding uncommitted edits.",
590
566
  examples: ["dss plugin reset-local my-plugin",],
591
567
  },
@@ -603,7 +579,6 @@ export const pluginCommands = {
603
579
  const result = await c.plugins.resetToRemoteHeadState(pluginId);
604
580
  return { reset: "remoteHeadState", pluginId, result, };
605
581
  },
606
- usage: RESET_REMOTE_USAGE,
607
582
  description: "Reset the development plugin to the remote HEAD state, discarding local work. The remote must be declared first.",
608
583
  examples: ["dss plugin reset-remote my-plugin",],
609
584
  },
@@ -612,7 +587,6 @@ export const pluginCommands = {
612
587
  requireArgs(a, 1, CONTENTS_LIST_USAGE);
613
588
  return c.plugins.listContents(validatePluginId(a[0]));
614
589
  },
615
- usage: CONTENTS_LIST_USAGE,
616
590
  description: "List the file tree of a development plugin.",
617
591
  examples: ["dss plugin contents-list my-plugin",],
618
592
  },
@@ -629,7 +603,6 @@ export const pluginCommands = {
629
603
  }
630
604
  return { data: await c.plugins.getFile(pluginId, path), };
631
605
  },
632
- usage: CONTENTS_GET_USAGE,
633
606
  description: "Read a development plugin file as text. --output PATH writes the raw bytes to a local file instead.",
634
607
  examples: [
635
608
  "dss plugin contents-get my-plugin python/my-plugin.py",
@@ -666,7 +639,6 @@ export const pluginCommands = {
666
639
  const sha256 = hasher.digest("hex");
667
640
  return { written: path, pluginId, bytes, sha256, };
668
641
  },
669
- usage: CONTENTS_PUT_USAGE,
670
642
  description: "Create or replace a development plugin file with text or binary content; reports the written byte count and sha256.",
671
643
  examples: [
672
644
  "dss plugin contents-put my-plugin python/lib.py --file ./lib.py",
@@ -688,7 +660,6 @@ export const pluginCommands = {
688
660
  await c.plugins.deleteFile(pluginId, path);
689
661
  return { deleted: path, pluginId, };
690
662
  },
691
- usage: CONTENTS_DELETE_USAGE,
692
663
  description: "Delete a file (or folder) from a development plugin.",
693
664
  examples: ["dss plugin contents-delete my-plugin python/old.py",],
694
665
  },
@@ -697,7 +668,6 @@ export const pluginCommands = {
697
668
  requireArgs(a, 2, DETAILS_USAGE);
698
669
  return c.plugins.getFileDetails(validatePluginId(a[0]), validatePluginPath(a[1]));
699
670
  },
700
- usage: DETAILS_USAGE,
701
671
  description: "Get a single development plugin file's detail record (size, mime type, timestamps).",
702
672
  examples: ["dss plugin details my-plugin python/my-plugin.py",],
703
673
  },
@@ -716,7 +686,6 @@ export const pluginCommands = {
716
686
  await c.plugins.addFolder(pluginId, path);
717
687
  return { created: path, pluginId, kind: "folder", };
718
688
  },
719
- usage: FOLDER_ADD_USAGE,
720
689
  description: "Add a folder to a development plugin.",
721
690
  examples: ["dss plugin folder-add my-plugin python/mylib",],
722
691
  },
@@ -737,7 +706,6 @@ export const pluginCommands = {
737
706
  await c.plugins.rename(pluginId, path, newName);
738
707
  return { renamed: path, to: newName, pluginId, };
739
708
  },
740
- usage: RENAME_USAGE,
741
709
  description: "Rename a file or folder inside a development plugin (same parent folder).",
742
710
  examples: ["dss plugin rename my-plugin python/old.py new.py",],
743
711
  },
@@ -758,11 +726,10 @@ export const pluginCommands = {
758
726
  await c.plugins.move(pluginId, path, destination);
759
727
  return { moved: path, to: destination, pluginId, };
760
728
  },
761
- usage: MOVE_USAGE,
762
729
  description: "Move a file or folder inside a development plugin. The destination folder must already exist.",
763
730
  examples: ["dss plugin move my-plugin python/old.py python/mylib",],
764
731
  },
765
- };
732
+ });
766
733
  /* ------------------------------------------------------------------ */
767
734
  /* Helpers */
768
735
  /* ------------------------------------------------------------------ */
@@ -1,9 +1,9 @@
1
1
  import { requiredJsonInput, } from "../coerce.js";
2
+ import { commandUsage, withUsage, } from "../syntax.js";
2
3
  import { requireArgs, } from "../usage.js";
3
- export const projectDeployerCommands = {
4
+ export const projectDeployerCommands = withUsage("project-deployer", {
4
5
  "list-projects": {
5
6
  handler: (c) => c.projectDeployer.listProjects(),
6
- usage: "dss project-deployer list-projects",
7
7
  description: "List published projects on the Project Deployer.",
8
8
  examples: ["dss project-deployer list-projects",],
9
9
  },
@@ -12,32 +12,28 @@ export const projectDeployerCommands = {
12
12
  const body = requiredJsonInput(f, "--data, --data-file, or --stdin is required (published project settings).");
13
13
  return c.projectDeployer.createProject(body);
14
14
  },
15
- usage: "dss project-deployer create-project (--data JSON|--data-file PATH|--stdin)",
16
15
  description: "Create a published project on the Project Deployer.",
17
16
  examples: ["dss project-deployer create-project --data-file project.json",],
18
17
  },
19
18
  "upload-bundle": {
20
19
  handler: async (c, a) => {
21
- requireArgs(a, 1, "dss project-deployer upload-bundle <filePath>");
20
+ requireArgs(a, 1, commandUsage("project-deployer", "upload-bundle"));
22
21
  await c.projectDeployer.uploadBundle(a[0]);
23
22
  return { uploaded: true, };
24
23
  },
25
- usage: "dss project-deployer upload-bundle <filePath>",
26
24
  description: "Upload a project bundle archive to the Project Deployer.",
27
25
  examples: ["dss project-deployer upload-bundle ./v1.zip",],
28
26
  },
29
27
  "project-status": {
30
28
  handler: (c, a) => {
31
- requireArgs(a, 1, "dss project-deployer project-status <publishedProjectKey>");
29
+ requireArgs(a, 1, commandUsage("project-deployer", "project-status"));
32
30
  return c.projectDeployer.getProjectStatus(a[0]);
33
31
  },
34
- usage: "dss project-deployer project-status <publishedProjectKey>",
35
32
  description: "Get a published project's status and available bundles.",
36
33
  examples: ["dss project-deployer project-status MYPROJ",],
37
34
  },
38
35
  "list-deployments": {
39
36
  handler: (c) => c.projectDeployer.listDeployments(),
40
- usage: "dss project-deployer list-deployments",
41
37
  description: "List Project Deployer deployments.",
42
38
  examples: ["dss project-deployer list-deployments",],
43
39
  },
@@ -46,36 +42,32 @@ export const projectDeployerCommands = {
46
42
  const body = requiredJsonInput(f, "--data, --data-file, or --stdin is required (deployment settings).");
47
43
  return c.projectDeployer.createDeployment(body);
48
44
  },
49
- usage: "dss project-deployer create-deployment (--data JSON|--data-file PATH|--stdin)",
50
45
  description: "Create a Project Deployer deployment (bundle to infra mapping).",
51
46
  examples: ["dss project-deployer create-deployment --data-file deployment.json",],
52
47
  },
53
48
  "get-deployment": {
54
49
  handler: (c, a) => {
55
- requireArgs(a, 1, "dss project-deployer get-deployment <deploymentId>");
50
+ requireArgs(a, 1, commandUsage("project-deployer", "get-deployment"));
56
51
  return c.projectDeployer.getDeployment(a[0]);
57
52
  },
58
- usage: "dss project-deployer get-deployment <deploymentId>",
59
53
  description: "Get a Project Deployer deployment.",
60
54
  examples: ["dss project-deployer get-deployment my-deployment",],
61
55
  },
62
56
  "deployment-status": {
63
57
  handler: (c, a) => {
64
- requireArgs(a, 1, "dss project-deployer deployment-status <deploymentId>");
58
+ requireArgs(a, 1, commandUsage("project-deployer", "deployment-status"));
65
59
  return c.projectDeployer.getDeploymentStatus(a[0]);
66
60
  },
67
- usage: "dss project-deployer deployment-status <deploymentId>",
68
61
  description: "Get a Project Deployer deployment's full health/status.",
69
62
  examples: ["dss project-deployer deployment-status my-deployment",],
70
63
  },
71
64
  "save-deployment-settings": {
72
65
  handler: async (c, a, f) => {
73
- requireArgs(a, 1, "dss project-deployer save-deployment-settings <deploymentId> (--data JSON|--data-file PATH|--stdin)");
66
+ requireArgs(a, 1, commandUsage("project-deployer", "save-deployment-settings"));
74
67
  const body = requiredJsonInput(f, "--data, --data-file, or --stdin is required (deployment settings).");
75
68
  await c.projectDeployer.saveDeploymentSettings(a[0], body);
76
69
  return { saved: true, };
77
70
  },
78
- usage: "dss project-deployer save-deployment-settings <deploymentId> (--data JSON|--data-file PATH|--stdin)",
79
71
  description: "Save a Project Deployer deployment's settings (e.g. bundleId).",
80
72
  examples: [
81
73
  "dss project-deployer save-deployment-settings my-deployment --data-file settings.json",
@@ -83,26 +75,23 @@ export const projectDeployerCommands = {
83
75
  },
84
76
  deploy: {
85
77
  handler: (c, a) => {
86
- requireArgs(a, 1, "dss project-deployer deploy <deploymentId>");
78
+ requireArgs(a, 1, commandUsage("project-deployer", "deploy"));
87
79
  return c.projectDeployer.startUpdate(a[0]);
88
80
  },
89
- usage: "dss project-deployer deploy <deploymentId>",
90
81
  description: "Apply a deployment to the Automation node (start update).",
91
82
  examples: ["dss project-deployer deploy my-deployment",],
92
83
  },
93
84
  "delete-deployment": {
94
85
  handler: async (c, a) => {
95
- requireArgs(a, 1, "dss project-deployer delete-deployment <deploymentId>");
86
+ requireArgs(a, 1, commandUsage("project-deployer", "delete-deployment"));
96
87
  await c.projectDeployer.deleteDeployment(a[0]);
97
88
  return { deleted: true, };
98
89
  },
99
- usage: "dss project-deployer delete-deployment <deploymentId>",
100
90
  description: "Delete a Project Deployer deployment.",
101
91
  examples: ["dss project-deployer delete-deployment my-deployment",],
102
92
  },
103
93
  "list-infras": {
104
94
  handler: (c) => c.projectDeployer.listInfras(),
105
- usage: "dss project-deployer list-infras",
106
95
  description: "List Project Deployer infrastructures.",
107
96
  examples: ["dss project-deployer list-infras",],
108
97
  },
@@ -111,8 +100,7 @@ export const projectDeployerCommands = {
111
100
  const body = requiredJsonInput(f, "--data, --data-file, or --stdin is required (infra settings).");
112
101
  return c.projectDeployer.createInfra(body);
113
102
  },
114
- usage: "dss project-deployer create-infra (--data JSON|--data-file PATH|--stdin)",
115
103
  description: "Create a Project Deployer infrastructure.",
116
104
  examples: ["dss project-deployer create-infra --data-file infra.json",],
117
105
  },
118
- };
106
+ });
@@ -1,6 +1,7 @@
1
1
  import { requiredJsonInput, } from "../coerce.js";
2
2
  import { executionMode, } from "../flags.js";
3
3
  import { isNotFoundError, planResult, skipResult, } from "../output.js";
4
+ import { commandUsage, withUsage, } from "../syntax.js";
4
5
  import { requireArgs, UsageError, } from "../usage.js";
5
6
  const PLAN_FAILURE_CODES = { usage: 1, error: 2, transient: 3, };
6
7
  function folderEndpoint(folderId, suffix = "") {
@@ -19,17 +20,16 @@ function nonEmptyPositionals(args, names, usage) {
19
20
  }
20
21
  });
21
22
  }
22
- const GET_USAGE = "dss project-folder get <folderId>";
23
- const SETTINGS_GET_USAGE = "dss project-folder settings-get <folderId>";
24
- const SETTINGS_SET_USAGE = "dss project-folder settings-set <folderId> (--data JSON|--data-file PATH|--stdin) [--dry-run]";
25
- const MOVE_USAGE = "dss project-folder move <folderId> <destinationFolderId> [--dry-run]";
26
- const DELETE_USAGE = "dss project-folder delete <folderId> [--if-exists] [--dry-run]";
27
- const CREATE_CHILD_USAGE = "dss project-folder create-child <parentFolderId> --name NAME [--dry-run]";
28
- const MOVE_PROJECT_USAGE = "dss project-folder move-project <folderId> <projectKey> <destinationFolderId> [--dry-run]";
29
- export const projectFolderCommands = {
23
+ const GET_USAGE = commandUsage("project-folder", "get");
24
+ const SETTINGS_GET_USAGE = commandUsage("project-folder", "settings-get");
25
+ const SETTINGS_SET_USAGE = commandUsage("project-folder", "settings-set");
26
+ const MOVE_USAGE = commandUsage("project-folder", "move");
27
+ const DELETE_USAGE = commandUsage("project-folder", "delete");
28
+ const CREATE_CHILD_USAGE = commandUsage("project-folder", "create-child");
29
+ const MOVE_PROJECT_USAGE = commandUsage("project-folder", "move-project");
30
+ export const projectFolderCommands = withUsage("project-folder", {
30
31
  root: {
31
32
  handler: (c) => c.projectFolders.root(),
32
- usage: "dss project-folder root",
33
33
  description: "Get the root project folder definition (visible children and projects).",
34
34
  examples: ["dss project-folder root",],
35
35
  },
@@ -39,7 +39,6 @@ export const projectFolderCommands = {
39
39
  nonEmptyPositionals(a, ["folderId",], GET_USAGE);
40
40
  },
41
41
  handler: (c, a) => c.projectFolders.get(a[0]),
42
- usage: GET_USAGE,
43
42
  description: "Get a project folder definition (children and project keys).",
44
43
  examples: ["dss project-folder get KdLmPU6",],
45
44
  },
@@ -49,7 +48,6 @@ export const projectFolderCommands = {
49
48
  nonEmptyPositionals(a, ["folderId",], SETTINGS_GET_USAGE);
50
49
  },
51
50
  handler: (c, a) => c.projectFolders.getSettings(a[0]),
52
- usage: SETTINGS_GET_USAGE,
53
51
  description: "Get project folder settings (name, owner, permissions). Admin required.",
54
52
  examples: ["dss project-folder settings-get KdLmPU6",],
55
53
  },
@@ -75,7 +73,6 @@ export const projectFolderCommands = {
75
73
  await c.projectFolders.updateSettings(a[0], settings);
76
74
  return { updated: a[0], resource: "project-folder", };
77
75
  },
78
- usage: SETTINGS_SET_USAGE,
79
76
  description: "Replace project folder settings (name, owner, permissions). Admin required.",
80
77
  examples: [
81
78
  "dss project-folder settings-set KdLmPU6 --data-file settings.json --dry-run",
@@ -101,7 +98,6 @@ export const projectFolderCommands = {
101
98
  await c.projectFolders.move(a[0], a[1]);
102
99
  return { moved: a[0], destination: a[1], resource: "project-folder", };
103
100
  },
104
- usage: MOVE_USAGE,
105
101
  description: "Move a project folder (and its content) into another project folder. Cannot move into a sub-folder of itself.",
106
102
  examples: ["dss project-folder move KdLmPU6 dgKywsx",],
107
103
  },
@@ -136,7 +132,6 @@ export const projectFolderCommands = {
136
132
  await c.projectFolders.delete(a[0]);
137
133
  return { deleted: a[0], resource: "project-folder", };
138
134
  },
139
- usage: DELETE_USAGE,
140
135
  description: "Delete an empty project folder (no sub-folders, no projects). Admin required.",
141
136
  examples: ["dss project-folder delete KdLmPU6 --dry-run",],
142
137
  },
@@ -166,7 +161,6 @@ export const projectFolderCommands = {
166
161
  const created = await c.projectFolders.createChild(a[0], name);
167
162
  return { created: created.id ?? name, resource: "project-folder", ...created, };
168
163
  },
169
- usage: CREATE_CHILD_USAGE,
170
164
  description: "Create a sub-project folder. WRITE_CONTENTS required on the parent.",
171
165
  examples: ["dss project-folder create-child KdLmPU6 --name my_sub_folder",],
172
166
  },
@@ -190,8 +184,7 @@ export const projectFolderCommands = {
190
184
  await c.projectFolders.moveProject(a[0], a[1], a[2]);
191
185
  return { moved: a[1], destination: a[2], resource: "project-folder", };
192
186
  },
193
- usage: MOVE_PROJECT_USAGE,
194
187
  description: "Move a project from its project folder to another project folder. WRITE_CONTENTS on destination and project admin required.",
195
188
  examples: ["dss project-folder move-project KdLmPU6 MYPROJECT dgKywsx",],
196
189
  },
197
- };
190
+ });