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
@@ -1,7 +1,8 @@
1
- import { validateGitReferencePath, } from "../../resources/project-git.js";
1
+ import { validateGitReferencePath, } from "../../utils/git-reference.js";
2
2
  import { sanitizeErrorSecrets, sanitizeSecrets, } from "../../utils/secret-sanitize.js";
3
3
  import { num, parseBooleanOption, requiredStringFlag, } from "../coerce.js";
4
4
  import { CommandResultFailure, } from "../output.js";
5
+ import { commandUsage, withUsage, } from "../syntax.js";
5
6
  import { requireArgs, requireNoArgs, UsageError, } from "../usage.js";
6
7
  /** DSS names the default remote `origin`; the remote flag falls back to it. */
7
8
  const DEFAULT_REMOTE = "origin";
@@ -69,53 +70,53 @@ function libraryPassword(flags) {
69
70
  throw new UsageError("--password-env requires the name of an environment variable holding the password.", "invalid_flag_value", "Pass --password-env DSS_GIT_LIBRARY_PASSWORD, never the password itself.", { flag: "--password-env", });
70
71
  }
71
72
  const name = raw.trim();
73
+ // oxlint-disable-next-line dss/no-direct-process-env -- --password-env names the variable to read; must work under DATAIKU_DISABLE_ENV
72
74
  const value = process.env[name];
73
75
  if (value === undefined || value === "") {
74
76
  throw new UsageError(`Environment variable ${name} is not set or is empty.`, "missing_required_flag", "--password-env names the environment variable that holds the Git repository password; export that variable before running the command.", { flag: "--password-env", env: name, });
75
77
  }
76
78
  return value;
77
79
  }
78
- const STATUS_USAGE = "dss project-git status --project-key KEY";
79
- const GET_REMOTE_USAGE = "dss project-git get-remote --project-key KEY [--name NAME]";
80
- const SET_REMOTE_USAGE = "dss project-git set-remote --repository URL --project-key KEY [--name NAME]";
81
- const REMOVE_REMOTE_USAGE = "dss project-git remove-remote --project-key KEY [--name NAME]";
82
- const BRANCHES_USAGE = "dss project-git branches --project-key KEY [--remote]";
83
- const CREATE_BRANCH_USAGE = "dss project-git create-branch <name> --project-key KEY [--commit COMMIT] [--duplicate-project] [--target-project-key KEY] [--target-project-folder-id ID]";
84
- const DELETE_BRANCH_USAGE = "dss project-git delete-branch <name> --project-key KEY [--remote] [--delete-remotely] [--force-delete]";
85
- const CURRENT_BRANCH_USAGE = "dss project-git current-branch --project-key KEY";
86
- const TAGS_USAGE = "dss project-git tags --project-key KEY";
87
- const CREATE_TAG_USAGE = "dss project-git create-tag <name> --project-key KEY [--reference REF] [--message MESSAGE]";
88
- const DELETE_TAG_USAGE = "dss project-git delete-tag <name> --project-key KEY";
89
- const SWITCH_USAGE = "dss project-git switch <branch> --project-key KEY";
90
- const FETCH_USAGE = "dss project-git fetch --project-key KEY";
91
- const PULL_USAGE = "dss project-git pull --project-key KEY [--branch NAME]";
92
- const PUSH_USAGE = "dss project-git push --project-key KEY [--branch NAME]";
93
- const LOG_USAGE = "dss project-git log --project-key KEY [--path PATH] [--start-commit COMMIT] [--count N]";
94
- const DIFF_USAGE = "dss project-git diff --project-key KEY [--from COMMIT] [--to COMMIT]";
95
- const COMMIT_USAGE = "dss project-git commit --message MESSAGE --project-key KEY";
96
- const REVERT_TO_REVISION_USAGE = "dss project-git revert-to-revision <commit> --project-key KEY";
97
- const REVERT_COMMIT_USAGE = "dss project-git revert-commit <commit> --project-key KEY";
98
- const RESET_TO_HEAD_USAGE = "dss project-git reset-to-head --project-key KEY";
99
- const RESET_TO_UPSTREAM_USAGE = "dss project-git reset-to-upstream --project-key KEY";
100
- const DROP_AND_REBUILD_USAGE = "dss project-git drop-and-rebuild --i-know-what-i-am-doing --project-key KEY";
101
- const LIST_LIBRARIES_USAGE = "dss project-git list-libraries --project-key KEY";
102
- const ADD_LIBRARY_USAGE = "dss project-git add-library <target-path> --repository URL --checkout REF --project-key KEY [--path-in-repository PATH] [--login LOGIN] [--password-env ENV_NAME] [--no-add-to-python-path]";
103
- const SET_LIBRARY_USAGE = "dss project-git set-library <target-path> --repository URL --checkout REF --project-key KEY [--path-in-repository PATH] [--login LOGIN] [--password-env ENV_NAME]";
104
- const REMOVE_LIBRARY_USAGE = "dss project-git remove-library <target-path> --project-key KEY [--delete-directory]";
105
- const RESET_LIBRARY_USAGE = "dss project-git reset-library <target-path> --project-key KEY";
106
- const PUSH_LIBRARY_USAGE = "dss project-git push-library <target-path> --message MESSAGE --project-key KEY";
107
- const PUSH_ALL_LIBRARIES_USAGE = "dss project-git push-all-libraries --message MESSAGE --project-key KEY";
108
- const RESET_ALL_LIBRARIES_USAGE = "dss project-git reset-all-libraries --project-key KEY";
109
- const FUTURE_STATUS_USAGE = "dss project-git future-status <job-id> [--peek]";
110
- const FUTURE_WAIT_USAGE = "dss project-git future-wait <job-id> [--timeout MS] [--poll-interval MS]";
111
- const FUTURE_ABORT_USAGE = "dss project-git future-abort <job-id>";
112
- export const projectGitCommands = {
80
+ const STATUS_USAGE = commandUsage("project-git", "status");
81
+ const GET_REMOTE_USAGE = commandUsage("project-git", "get-remote");
82
+ const SET_REMOTE_USAGE = commandUsage("project-git", "set-remote");
83
+ const REMOVE_REMOTE_USAGE = commandUsage("project-git", "remove-remote");
84
+ const BRANCHES_USAGE = commandUsage("project-git", "branches");
85
+ const CREATE_BRANCH_USAGE = commandUsage("project-git", "create-branch");
86
+ const DELETE_BRANCH_USAGE = commandUsage("project-git", "delete-branch");
87
+ const CURRENT_BRANCH_USAGE = commandUsage("project-git", "current-branch");
88
+ const TAGS_USAGE = commandUsage("project-git", "tags");
89
+ const CREATE_TAG_USAGE = commandUsage("project-git", "create-tag");
90
+ const DELETE_TAG_USAGE = commandUsage("project-git", "delete-tag");
91
+ const SWITCH_USAGE = commandUsage("project-git", "switch");
92
+ const FETCH_USAGE = commandUsage("project-git", "fetch");
93
+ const PULL_USAGE = commandUsage("project-git", "pull");
94
+ const PUSH_USAGE = commandUsage("project-git", "push");
95
+ const LOG_USAGE = commandUsage("project-git", "log");
96
+ const DIFF_USAGE = commandUsage("project-git", "diff");
97
+ const COMMIT_USAGE = commandUsage("project-git", "commit");
98
+ const REVERT_TO_REVISION_USAGE = commandUsage("project-git", "revert-to-revision");
99
+ const REVERT_COMMIT_USAGE = commandUsage("project-git", "revert-commit");
100
+ const RESET_TO_HEAD_USAGE = commandUsage("project-git", "reset-to-head");
101
+ const RESET_TO_UPSTREAM_USAGE = commandUsage("project-git", "reset-to-upstream");
102
+ const DROP_AND_REBUILD_USAGE = commandUsage("project-git", "drop-and-rebuild");
103
+ const LIST_LIBRARIES_USAGE = commandUsage("project-git", "list-libraries");
104
+ const ADD_LIBRARY_USAGE = commandUsage("project-git", "add-library");
105
+ const SET_LIBRARY_USAGE = commandUsage("project-git", "set-library");
106
+ const REMOVE_LIBRARY_USAGE = commandUsage("project-git", "remove-library");
107
+ const RESET_LIBRARY_USAGE = commandUsage("project-git", "reset-library");
108
+ const PUSH_LIBRARY_USAGE = commandUsage("project-git", "push-library");
109
+ const PUSH_ALL_LIBRARIES_USAGE = commandUsage("project-git", "push-all-libraries");
110
+ const RESET_ALL_LIBRARIES_USAGE = commandUsage("project-git", "reset-all-libraries");
111
+ const FUTURE_STATUS_USAGE = commandUsage("project-git", "future-status");
112
+ const FUTURE_WAIT_USAGE = commandUsage("project-git", "future-wait");
113
+ const FUTURE_ABORT_USAGE = commandUsage("project-git", "future-abort");
114
+ export const projectGitCommands = withUsage("project-git", {
113
115
  status: {
114
116
  handler: async (c, a, f) => {
115
117
  requireNoArgs(a, STATUS_USAGE);
116
118
  return sanitizeProjectGitOutput(await c.projectGit.status(requiredStringFlag(f, "project-key", STATUS_USAGE)));
117
119
  },
118
- usage: STATUS_USAGE,
119
120
  description: "Get the project's Git working-copy status: current branch, remotes, tracking counts, and pending changes.",
120
121
  examples: ["dss project-git status --project-key MYPROJECT",],
121
122
  },
@@ -124,7 +125,6 @@ export const projectGitCommands = {
124
125
  requireNoArgs(a, GET_REMOTE_USAGE);
125
126
  return sanitizeProjectGitOutput(await c.projectGit.getRemote(requiredStringFlag(f, "project-key", GET_REMOTE_USAGE), optionalStringFlag(f, "name") ?? DEFAULT_REMOTE));
126
127
  },
127
- usage: GET_REMOTE_USAGE,
128
128
  description: "Read one configured Git remote, origin by default. DSS answers an empty object when the remote is not configured.",
129
129
  examples: ["dss project-git get-remote --project-key MYPROJECT",],
130
130
  },
@@ -137,7 +137,6 @@ export const projectGitCommands = {
137
137
  });
138
138
  return assertGitActionSucceeded(result, "set-remote");
139
139
  },
140
- usage: SET_REMOTE_USAGE,
141
140
  description: "Create or replace a Git remote. HTTP(S) URLs must not embed credentials; use an SSH remote or DSS-managed Git credentials instead.",
142
141
  examples: [
143
142
  "dss project-git set-remote --repository git@github.com:acme/analytics.git --project-key MYPROJECT",
@@ -150,7 +149,6 @@ export const projectGitCommands = {
150
149
  await c.projectGit.removeRemote(requiredStringFlag(f, "project-key", REMOVE_REMOTE_USAGE), name);
151
150
  return { removed: name, resource: "project-git-remote", };
152
151
  },
153
- usage: REMOVE_REMOTE_USAGE,
154
152
  description: "Delete a Git remote from the project, origin by default.",
155
153
  examples: ["dss project-git remove-remote --name upstream --project-key MYPROJECT",],
156
154
  },
@@ -159,7 +157,6 @@ export const projectGitCommands = {
159
157
  requireNoArgs(a, BRANCHES_USAGE);
160
158
  return sanitizeProjectGitOutput(await c.projectGit.listBranches(requiredStringFlag(f, "project-key", BRANCHES_USAGE), parseBooleanOption(f["remote"], "--remote")));
161
159
  },
162
- usage: BRANCHES_USAGE,
163
160
  description: "List local branch names, or remote-tracking branches with --remote.",
164
161
  examples: [
165
162
  "dss project-git branches --project-key MYPROJECT",
@@ -177,7 +174,6 @@ export const projectGitCommands = {
177
174
  });
178
175
  return assertGitActionSucceeded(result, "create-branch");
179
176
  },
180
- usage: CREATE_BRANCH_USAGE,
181
177
  description: "Create a branch, optionally from a specific commit. With --duplicate-project DSS copies the project onto the new branch instead of switching this one.",
182
178
  examples: [
183
179
  "dss project-git create-branch feature/pricing --project-key MYPROJECT",
@@ -194,7 +190,6 @@ export const projectGitCommands = {
194
190
  });
195
191
  return assertGitActionSucceeded(result, "delete-branch");
196
192
  },
197
- usage: DELETE_BRANCH_USAGE,
198
193
  description: "Delete a branch. --remote targets a remote-tracking branch, --delete-remotely also deletes it on the remote, and --force-delete drops unmerged commits.",
199
194
  examples: ["dss project-git delete-branch feature/pricing --project-key MYPROJECT",],
200
195
  },
@@ -204,7 +199,6 @@ export const projectGitCommands = {
204
199
  const branch = await c.projectGit.currentBranch(requiredStringFlag(f, "project-key", CURRENT_BRANCH_USAGE));
205
200
  return { branch, };
206
201
  },
207
- usage: CURRENT_BRANCH_USAGE,
208
202
  description: "Get the project's current branch name, or null when DSS reports none.",
209
203
  examples: ["dss project-git current-branch --project-key MYPROJECT",],
210
204
  },
@@ -213,7 +207,6 @@ export const projectGitCommands = {
213
207
  requireNoArgs(a, TAGS_USAGE);
214
208
  return sanitizeProjectGitOutput(await c.projectGit.listTags(requiredStringFlag(f, "project-key", TAGS_USAGE)));
215
209
  },
216
- usage: TAGS_USAGE,
217
210
  description: "List the project's Git tags.",
218
211
  examples: ["dss project-git tags --project-key MYPROJECT",],
219
212
  },
@@ -226,7 +219,6 @@ export const projectGitCommands = {
226
219
  });
227
220
  return assertGitActionSucceeded(result, "create-tag");
228
221
  },
229
- usage: CREATE_TAG_USAGE,
230
222
  description: "Create a Git tag. --reference defaults to HEAD; passing --message creates an annotated tag.",
231
223
  examples: [
232
224
  'dss project-git create-tag v1.2.0 --message "Release 1.2.0" --project-key MYPROJECT',
@@ -238,7 +230,6 @@ export const projectGitCommands = {
238
230
  const result = await c.projectGit.deleteTag(requiredStringFlag(f, "project-key", DELETE_TAG_USAGE), a[0]);
239
231
  return assertGitActionSucceeded(result, "delete-tag");
240
232
  },
241
- usage: DELETE_TAG_USAGE,
242
233
  description: "Delete a Git tag from the project.",
243
234
  examples: ["dss project-git delete-tag v1.2.0 --project-key MYPROJECT",],
244
235
  },
@@ -248,7 +239,6 @@ export const projectGitCommands = {
248
239
  const result = await c.projectGit.switchBranch(requiredStringFlag(f, "project-key", SWITCH_USAGE), a[0]);
249
240
  return assertGitActionSucceeded(result, "switch");
250
241
  },
251
- usage: SWITCH_USAGE,
252
242
  description: "Switch the project to another branch. DSS rewrites the project's working copy in place.",
253
243
  examples: ["dss project-git switch main --project-key MYPROJECT",],
254
244
  },
@@ -258,7 +248,6 @@ export const projectGitCommands = {
258
248
  const result = await c.projectGit.fetch(requiredStringFlag(f, "project-key", FETCH_USAGE));
259
249
  return assertGitActionSucceeded(result, "fetch");
260
250
  },
261
- usage: FETCH_USAGE,
262
251
  description: "Fetch from the project's Git remote without changing the working copy.",
263
252
  examples: ["dss project-git fetch --project-key MYPROJECT",],
264
253
  },
@@ -268,7 +257,6 @@ export const projectGitCommands = {
268
257
  const result = await c.projectGit.pull(requiredStringFlag(f, "project-key", PULL_USAGE), { branchName: optionalStringFlag(f, "branch"), });
269
258
  return assertGitActionSucceeded(result, "pull");
270
259
  },
271
- usage: PULL_USAGE,
272
260
  description: "Pull with rebase. DSS exposes no merge variant of pull.",
273
261
  examples: ["dss project-git pull --project-key MYPROJECT",],
274
262
  },
@@ -278,7 +266,6 @@ export const projectGitCommands = {
278
266
  const result = await c.projectGit.push(requiredStringFlag(f, "project-key", PUSH_USAGE), { branchName: optionalStringFlag(f, "branch"), });
279
267
  return assertGitActionSucceeded(result, "push");
280
268
  },
281
- usage: PUSH_USAGE,
282
269
  description: "Push the project's committed changes to its Git remote.",
283
270
  examples: ["dss project-git push --project-key MYPROJECT",],
284
271
  },
@@ -291,7 +278,6 @@ export const projectGitCommands = {
291
278
  count: num(f["count"], "--count"),
292
279
  }));
293
280
  },
294
- usage: LOG_USAGE,
295
281
  description: "Read a page of the project's commit log. Paginate by passing the previous response's nextCommit as --start-commit.",
296
282
  examples: ["dss project-git log --count 20 --project-key MYPROJECT",],
297
283
  },
@@ -303,7 +289,6 @@ export const projectGitCommands = {
303
289
  commitTo: optionalStringFlag(f, "to"),
304
290
  }));
305
291
  },
306
- usage: DIFF_USAGE,
307
292
  description: "Diff the project between two commits. Omitting both bounds diffs the working copy against HEAD.",
308
293
  examples: ["dss project-git diff --from 4f1c2ab --to 9de77c1 --project-key MYPROJECT",],
309
294
  },
@@ -313,7 +298,6 @@ export const projectGitCommands = {
313
298
  const result = await c.projectGit.commit(requiredStringFlag(f, "project-key", COMMIT_USAGE), { message: requiredStringFlag(f, "message", COMMIT_USAGE), });
314
299
  return assertGitActionSucceeded(result, "commit");
315
300
  },
316
- usage: COMMIT_USAGE,
317
301
  description: "Commit the project. DSS stages untracked files before committing.",
318
302
  examples: [
319
303
  'dss project-git commit --message "Update pricing recipe" --project-key MYPROJECT',
@@ -325,7 +309,6 @@ export const projectGitCommands = {
325
309
  const result = await c.projectGit.revertToRevision(requiredStringFlag(f, "project-key", REVERT_TO_REVISION_USAGE), a[0]);
326
310
  return assertGitActionSucceeded(result, "revert-to-revision");
327
311
  },
328
- usage: REVERT_TO_REVISION_USAGE,
329
312
  description: "Restore the whole project to the state of a past commit, discarding everything after it in the working copy.",
330
313
  examples: ["dss project-git revert-to-revision 4f1c2ab --project-key MYPROJECT",],
331
314
  },
@@ -335,7 +318,6 @@ export const projectGitCommands = {
335
318
  const result = await c.projectGit.revertCommit(requiredStringFlag(f, "project-key", REVERT_COMMIT_USAGE), a[0]);
336
319
  return assertGitActionSucceeded(result, "revert-commit");
337
320
  },
338
- usage: REVERT_COMMIT_USAGE,
339
321
  description: "Revert a single commit while keeping the commits that follow it.",
340
322
  examples: ["dss project-git revert-commit 4f1c2ab --project-key MYPROJECT",],
341
323
  },
@@ -345,7 +327,6 @@ export const projectGitCommands = {
345
327
  const result = await c.projectGit.resetToHead(requiredStringFlag(f, "project-key", RESET_TO_HEAD_USAGE));
346
328
  return assertGitActionSucceeded(result, "reset-to-head");
347
329
  },
348
- usage: RESET_TO_HEAD_USAGE,
349
330
  description: "Hard reset the project to local HEAD, discarding uncommitted changes.",
350
331
  examples: ["dss project-git reset-to-head --project-key MYPROJECT",],
351
332
  },
@@ -355,7 +336,6 @@ export const projectGitCommands = {
355
336
  const result = await c.projectGit.resetToUpstream(requiredStringFlag(f, "project-key", RESET_TO_UPSTREAM_USAGE));
356
337
  return assertGitActionSucceeded(result, "reset-to-upstream");
357
338
  },
358
- usage: RESET_TO_UPSTREAM_USAGE,
359
339
  description: "Hard reset the project to its tracked upstream branch, discarding local commits.",
360
340
  examples: ["dss project-git reset-to-upstream --project-key MYPROJECT",],
361
341
  },
@@ -371,7 +351,6 @@ export const projectGitCommands = {
371
351
  const result = await c.projectGit.dropAndRebuild(projectKey, { confirmed: true, });
372
352
  return assertGitActionSucceeded(result, "drop-and-rebuild");
373
353
  },
374
- usage: DROP_AND_REBUILD_USAGE,
375
354
  description: "Wipe the project's entire Git history and rebuild a fresh repository. Irreversible, so it requires --i-know-what-i-am-doing.",
376
355
  examples: [
377
356
  "dss project-git drop-and-rebuild --i-know-what-i-am-doing --project-key MYPROJECT",
@@ -382,7 +361,6 @@ export const projectGitCommands = {
382
361
  requireNoArgs(a, LIST_LIBRARIES_USAGE);
383
362
  return sanitizeProjectGitOutput(await c.projectGit.listLibraries(requiredStringFlag(f, "project-key", LIST_LIBRARIES_USAGE)));
384
363
  },
385
- usage: LIST_LIBRARIES_USAGE,
386
364
  description: "List the external Git libraries attached to the project's code library.",
387
365
  examples: ["dss project-git list-libraries --project-key MYPROJECT",],
388
366
  },
@@ -401,7 +379,6 @@ export const projectGitCommands = {
401
379
  password,
402
380
  }), password === undefined ? [] : [password,]);
403
381
  },
404
- usage: ADD_LIBRARY_USAGE,
405
382
  description: "Attach an external Git repository to the project's code library and return the DSS future that clones it. The password is read only from the environment variable named by --password-env.",
406
383
  examples: [
407
384
  "dss project-git add-library shared-utils --repository git@github.com:acme/utils.git --checkout main --project-key MYPROJECT",
@@ -420,7 +397,6 @@ export const projectGitCommands = {
420
397
  password,
421
398
  }), password === undefined ? [] : [password,]);
422
399
  },
423
- usage: SET_LIBRARY_USAGE,
424
400
  description: "Update an attached library's repository, sub-path, or checkout. The password is read only from the environment variable named by --password-env.",
425
401
  examples: [
426
402
  "dss project-git set-library shared-utils --repository git@github.com:acme/utils.git --checkout v2 --path-in-repository python --project-key MYPROJECT",
@@ -435,7 +411,6 @@ export const projectGitCommands = {
435
411
  await c.projectGit.removeLibrary(requiredStringFlag(f, "project-key", REMOVE_LIBRARY_USAGE), targetPath, deleteDirectory);
436
412
  return { removed: targetPath, resource: "project-git-library", deleteDirectory, };
437
413
  },
438
- usage: REMOVE_LIBRARY_USAGE,
439
414
  description: "Detach an external Git library. --delete-directory also removes its local directory from the project library.",
440
415
  examples: ["dss project-git remove-library shared-utils --project-key MYPROJECT",],
441
416
  },
@@ -444,7 +419,6 @@ export const projectGitCommands = {
444
419
  requireArgs(a, 1, RESET_LIBRARY_USAGE);
445
420
  return c.projectGit.resetLibrary(requiredStringFlag(f, "project-key", RESET_LIBRARY_USAGE), validateGitReferencePath(a[0]));
446
421
  },
447
- usage: RESET_LIBRARY_USAGE,
448
422
  description: "Reset one attached library to its remote state, discarding local edits. Returns the DSS future that performs the reset.",
449
423
  examples: ["dss project-git reset-library shared-utils --project-key MYPROJECT",],
450
424
  },
@@ -453,7 +427,6 @@ export const projectGitCommands = {
453
427
  requireArgs(a, 1, PUSH_LIBRARY_USAGE);
454
428
  return c.projectGit.pushLibrary(requiredStringFlag(f, "project-key", PUSH_LIBRARY_USAGE), validateGitReferencePath(a[0]), requiredStringFlag(f, "message", PUSH_LIBRARY_USAGE));
455
429
  },
456
- usage: PUSH_LIBRARY_USAGE,
457
430
  description: "Commit and push one attached library. Returns the DSS future that performs the push.",
458
431
  examples: [
459
432
  'dss project-git push-library shared-utils --message "Update helpers" --project-key MYPROJECT',
@@ -464,7 +437,6 @@ export const projectGitCommands = {
464
437
  requireNoArgs(a, PUSH_ALL_LIBRARIES_USAGE);
465
438
  return c.projectGit.pushAllLibraries(requiredStringFlag(f, "project-key", PUSH_ALL_LIBRARIES_USAGE), requiredStringFlag(f, "message", PUSH_ALL_LIBRARIES_USAGE));
466
439
  },
467
- usage: PUSH_ALL_LIBRARIES_USAGE,
468
440
  description: "Commit and push every attached library. Returns the DSS future that performs the pushes.",
469
441
  examples: [
470
442
  'dss project-git push-all-libraries --message "Sync libraries" --project-key MYPROJECT',
@@ -475,7 +447,6 @@ export const projectGitCommands = {
475
447
  requireNoArgs(a, RESET_ALL_LIBRARIES_USAGE);
476
448
  return c.projectGit.resetAllLibraries(requiredStringFlag(f, "project-key", RESET_ALL_LIBRARIES_USAGE));
477
449
  },
478
- usage: RESET_ALL_LIBRARIES_USAGE,
479
450
  description: "Reset every attached library to its remote state. Returns the DSS future that performs the resets.",
480
451
  examples: ["dss project-git reset-all-libraries --project-key MYPROJECT",],
481
452
  },
@@ -486,7 +457,6 @@ export const projectGitCommands = {
486
457
  peek: parseBooleanOption(f["peek"], "--peek"),
487
458
  }));
488
459
  },
489
- usage: FUTURE_STATUS_USAGE,
490
460
  description: "Get the state of a Git library future by job id. --peek leaves the result queued for a later read.",
491
461
  examples: ["dss project-git future-status FUTURE_ID --peek",],
492
462
  },
@@ -509,7 +479,6 @@ export const projectGitCommands = {
509
479
  throw sanitizeProjectGitError(error);
510
480
  }
511
481
  },
512
- usage: FUTURE_WAIT_USAGE,
513
482
  description: "Wait for a Git library future to finish and return its result.",
514
483
  examples: ["dss project-git future-wait FUTURE_ID --timeout 300000",],
515
484
  },
@@ -519,8 +488,7 @@ export const projectGitCommands = {
519
488
  await c.projectGit.abortFuture(a[0]);
520
489
  return { aborted: a[0], resource: "project-git-future", };
521
490
  },
522
- usage: FUTURE_ABORT_USAGE,
523
491
  description: "Abort a running Git library future by job id.",
524
492
  examples: ["dss project-git future-abort FUTURE_ID",],
525
493
  },
526
- };
494
+ });
@@ -1,8 +1,10 @@
1
1
  import * as fs from "node:fs";
2
- import { encodeLibraryPath, EXPECT_SHA256_PATTERN, validateLibraryDestinationPath, validateLibraryName, validateLibraryPath, } from "../../resources/project-library.js";
2
+ import { encodeLibraryPath, validateLibraryDestinationPath, validateLibraryName, validateLibraryPath, } from "../../resources/project-library.js";
3
+ import { SHA256_HEX_PATTERN, } from "../../utils/stable-hash.js";
3
4
  import { numFlag, readStdinText, sha256Hex, } from "../coerce.js";
4
5
  import { executionMode, } from "../flags.js";
5
6
  import { encodedProjectEndpoint, planResult, skipResult, } from "../output.js";
7
+ import { commandUsage, withUsage, } from "../syntax.js";
6
8
  import { requireArgs, UsageError, } from "../usage.js";
7
9
  const PROJECT_LIBRARY_EXIT_CODES = { usage: 1, error: 2, transient: 3, };
8
10
  const PUT_FLAG_ERROR_HINT = "Pass a 64-character SHA-256 hex digest (lowercase or uppercase).";
@@ -60,31 +62,29 @@ function expectSha256FromFlags(flags) {
60
62
  const value = flags["expect-sha256"];
61
63
  if (value === undefined || value === false)
62
64
  return undefined;
63
- if (typeof value !== "string" || !EXPECT_SHA256_PATTERN.test(value)) {
65
+ if (typeof value !== "string" || !SHA256_HEX_PATTERN.test(value)) {
64
66
  throw new UsageError("--expect-sha256 must be a 64-character SHA-256 hex digest.", "validation_failed", PUT_FLAG_ERROR_HINT);
65
67
  }
66
68
  return value;
67
69
  }
68
- export const projectLibraryCommands = {
70
+ export const projectLibraryCommands = withUsage("project-library", {
69
71
  list: {
70
72
  handler: (c, _a, f) => c.projectLibrary.listContents(f["project-key"]),
71
- usage: "dss project-library list [--project-key KEY]",
72
73
  description: "List the project code library (lib/) contents.",
73
74
  examples: ["dss project-library list",],
74
75
  },
75
76
  get: {
76
77
  handler: (c, a, f) => {
77
- requireArgs(a, 1, "dss project-library get <path> [--project-key KEY]");
78
+ requireArgs(a, 1, commandUsage("project-library", "get"));
78
79
  validateLibraryPath(a[0]);
79
80
  return c.projectLibrary.getFile(a[0], f["project-key"]);
80
81
  },
81
- usage: "dss project-library get <path> [--project-key KEY]",
82
82
  description: "Print the text content of a project library file.",
83
83
  examples: ["dss project-library get python/mylib/utils.py",],
84
84
  },
85
85
  "get-bytes": {
86
86
  handler: async (c, a, f) => {
87
- requireArgs(a, 1, "dss project-library get-bytes <path> --output PATH [--project-key KEY]");
87
+ requireArgs(a, 1, commandUsage("project-library", "get-bytes"));
88
88
  const out = f["output"];
89
89
  if (!out)
90
90
  throw new UsageError("--output PATH is required.", "missing_required_flag");
@@ -92,13 +92,12 @@ export const projectLibraryCommands = {
92
92
  const written = await Bun.write(out, bytes, { createPath: false, });
93
93
  return { path: out, bytes: written, sha256: sha256BytesHex(bytes), };
94
94
  },
95
- usage: "dss project-library get-bytes <path> --output PATH [--project-key KEY]",
96
95
  description: "Download a project library file's raw bytes to a local file.",
97
96
  examples: ["dss project-library get-bytes static/logo.png --output ./logo.png",],
98
97
  },
99
98
  "create-file": {
100
99
  handler: async (c, a, f) => {
101
- requireArgs(a, 1, "dss project-library create-file <path> [--if-not-exists] [--dry-run] [--project-key KEY]");
100
+ requireArgs(a, 1, commandUsage("project-library", "create-file"));
102
101
  const pk = f["project-key"];
103
102
  validateLibraryPath(a[0]);
104
103
  if (executionMode(f).dryRun) {
@@ -118,13 +117,12 @@ export const projectLibraryCommands = {
118
117
  await c.projectLibrary.addFile(a[0], pk);
119
118
  return { created: a[0], };
120
119
  },
121
- usage: "dss project-library create-file <path> [--if-not-exists] [--dry-run] [--project-key KEY]",
122
120
  description: "Create an empty file in the project library; refuses to overwrite an existing item.",
123
121
  examples: ["dss project-library create-file python/mylib/new.py --if-not-exists",],
124
122
  },
125
123
  "create-folder": {
126
124
  handler: async (c, a, f) => {
127
- requireArgs(a, 1, "dss project-library create-folder <path> [--if-not-exists] [--dry-run] [--project-key KEY]");
125
+ requireArgs(a, 1, commandUsage("project-library", "create-folder"));
128
126
  const pk = f["project-key"];
129
127
  validateLibraryPath(a[0]);
130
128
  if (executionMode(f).dryRun) {
@@ -144,13 +142,12 @@ export const projectLibraryCommands = {
144
142
  await c.projectLibrary.addFolder(a[0], pk);
145
143
  return { created: a[0], };
146
144
  },
147
- usage: "dss project-library create-folder <path> [--if-not-exists] [--dry-run] [--project-key KEY]",
148
145
  description: "Create a folder in the project library; refuses to overwrite an existing item.",
149
146
  examples: ["dss project-library create-folder python/mylib --if-not-exists",],
150
147
  },
151
148
  put: {
152
149
  handler: async (c, a, f) => {
153
- requireArgs(a, 1, "dss project-library put <path> (--content TEXT|--file PATH|--stdin) [--expect-sha256 SHA256] [--dry-run] [--project-key KEY]");
150
+ requireArgs(a, 1, commandUsage("project-library", "put"));
154
151
  const pk = f["project-key"];
155
152
  const expectSha256 = expectSha256FromFlags(f);
156
153
  validateLibraryPath(a[0]);
@@ -175,7 +172,6 @@ export const projectLibraryCommands = {
175
172
  ...(result.beforeSha256 !== undefined ? { beforeSha256: result.beforeSha256, } : {}),
176
173
  };
177
174
  },
178
- usage: "dss project-library put <path> (--content TEXT|--file PATH|--stdin) [--expect-sha256 SHA256] [--dry-run] [--project-key KEY]",
179
175
  description: "Create or overwrite a project library file with text or binary content; reports the written byte count and sha256.",
180
176
  examples: [
181
177
  "dss project-library put python/mylib/utils.py --file ./utils.py",
@@ -184,7 +180,7 @@ export const projectLibraryCommands = {
184
180
  },
185
181
  diff: {
186
182
  handler: async (c, a, f) => {
187
- requireArgs(a, 1, "dss project-library diff <path> (--content TEXT|--file PATH|--stdin) [--max-lines N] [--project-key KEY]");
183
+ requireArgs(a, 1, commandUsage("project-library", "diff"));
188
184
  const pk = f["project-key"];
189
185
  validateLibraryPath(a[0]);
190
186
  const maxLines = numFlag(f, ["max-lines",]);
@@ -195,7 +191,6 @@ export const projectLibraryCommands = {
195
191
  : await readStdinText();
196
192
  return c.projectLibrary.diffFile(a[0], local, pk, maxLines !== undefined ? { maxLines, } : {});
197
193
  },
198
- usage: "dss project-library diff <path> (--content TEXT|--file PATH|--stdin) [--max-lines N] [--project-key KEY]",
199
194
  description: "Diff a project library file against local content; capped unified text diff, binary files detected instead of dumped.",
200
195
  examples: [
201
196
  "dss project-library diff python/mylib/utils.py --file ./utils.py",
@@ -204,7 +199,7 @@ export const projectLibraryCommands = {
204
199
  },
205
200
  delete: {
206
201
  handler: async (c, a, f) => {
207
- requireArgs(a, 1, "dss project-library delete <path> [--dry-run] [--project-key KEY]");
202
+ requireArgs(a, 1, commandUsage("project-library", "delete"));
208
203
  const pk = f["project-key"];
209
204
  validateLibraryPath(a[0]);
210
205
  if (executionMode(f).dryRun) {
@@ -217,13 +212,12 @@ export const projectLibraryCommands = {
217
212
  await c.projectLibrary.deleteFile(a[0], pk);
218
213
  return { deleted: a[0], };
219
214
  },
220
- usage: "dss project-library delete <path> [--dry-run] [--project-key KEY]",
221
215
  description: "Delete a project library file or folder.",
222
216
  examples: ["dss project-library delete python/mylib/old.py",],
223
217
  },
224
218
  rename: {
225
219
  handler: async (c, a, f) => {
226
- requireArgs(a, 2, "dss project-library rename <path> <new-name> [--dry-run] [--project-key KEY]");
220
+ requireArgs(a, 2, commandUsage("project-library", "rename"));
227
221
  const pk = f["project-key"];
228
222
  const validPath = validateLibraryPath(a[0]);
229
223
  const validName = validateLibraryName(a[1]);
@@ -238,13 +232,12 @@ export const projectLibraryCommands = {
238
232
  await c.projectLibrary.rename(validPath, validName, pk);
239
233
  return { renamed: validPath, to: validName, };
240
234
  },
241
- usage: "dss project-library rename <path> <new-name> [--dry-run] [--project-key KEY]",
242
235
  description: "Rename a project library file or folder within its parent.",
243
236
  examples: ["dss project-library rename python/mylib/old.py new.py",],
244
237
  },
245
238
  move: {
246
239
  handler: async (c, a, f) => {
247
- requireArgs(a, 2, "dss project-library move <path> <destination-folder> [--dry-run] [--project-key KEY]");
240
+ requireArgs(a, 2, commandUsage("project-library", "move"));
248
241
  const pk = f["project-key"];
249
242
  const validPath = validateLibraryPath(a[0]);
250
243
  const destination = validateLibraryDestinationPath(a[1]);
@@ -262,8 +255,7 @@ export const projectLibraryCommands = {
262
255
  await c.projectLibrary.move(validPath, destination, pk);
263
256
  return { moved: validPath, to: destination, };
264
257
  },
265
- usage: "dss project-library move <path> <destination-folder> [--dry-run] [--project-key KEY]",
266
258
  description: "Move a project library file or folder into another folder.",
267
259
  examples: ["dss project-library move python/old.py python/mylib",],
268
260
  },
269
- };
261
+ });