dataiku-sdk 0.10.0 → 0.11.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 (133) hide show
  1. package/dist/packages/types/src/index.d.ts +15 -2
  2. package/dist/packages/types/src/index.js +9 -1
  3. package/dist/src/cli/coerce.d.ts +36 -0
  4. package/dist/src/cli/coerce.js +239 -0
  5. package/dist/src/cli/commands/api-deployer.d.ts +2 -0
  6. package/dist/src/cli/commands/api-deployer.js +170 -0
  7. package/dist/src/cli/commands/api-service.d.ts +2 -0
  8. package/dist/src/cli/commands/api-service.js +102 -0
  9. package/dist/src/cli/commands/app.d.ts +2 -0
  10. package/dist/src/cli/commands/app.js +78 -0
  11. package/dist/src/cli/commands/bundle.d.ts +2 -0
  12. package/dist/src/cli/commands/bundle.js +107 -0
  13. package/dist/src/cli/commands/business-app.d.ts +2 -0
  14. package/dist/src/cli/commands/business-app.js +76 -0
  15. package/dist/src/cli/commands/code-env.d.ts +2 -0
  16. package/dist/src/cli/commands/code-env.js +255 -0
  17. package/dist/src/cli/commands/code.d.ts +2 -0
  18. package/dist/src/cli/commands/code.js +63 -0
  19. package/dist/src/cli/commands/connection.d.ts +2 -0
  20. package/dist/src/cli/commands/connection.js +54 -0
  21. package/dist/src/cli/commands/continuous-activity.d.ts +2 -0
  22. package/dist/src/cli/commands/continuous-activity.js +38 -0
  23. package/dist/src/cli/commands/dashboard.d.ts +2 -0
  24. package/dist/src/cli/commands/dashboard.js +99 -0
  25. package/dist/src/cli/commands/data-quality.d.ts +2 -0
  26. package/dist/src/cli/commands/data-quality.js +235 -0
  27. package/dist/src/cli/commands/dataset.d.ts +2 -0
  28. package/dist/src/cli/commands/dataset.js +288 -0
  29. package/dist/src/cli/commands/discussion.d.ts +2 -0
  30. package/dist/src/cli/commands/discussion.js +47 -0
  31. package/dist/src/cli/commands/doctor.d.ts +2 -0
  32. package/dist/src/cli/commands/doctor.js +9 -0
  33. package/dist/src/cli/commands/flow-zone.d.ts +2 -0
  34. package/dist/src/cli/commands/flow-zone.js +282 -0
  35. package/dist/src/cli/commands/folder.d.ts +2 -0
  36. package/dist/src/cli/commands/folder.js +202 -0
  37. package/dist/src/cli/commands/future.d.ts +2 -0
  38. package/dist/src/cli/commands/future.js +57 -0
  39. package/dist/src/cli/commands/index.d.ts +2 -0
  40. package/dist/src/cli/commands/index.js +70 -0
  41. package/dist/src/cli/commands/insight.d.ts +2 -0
  42. package/dist/src/cli/commands/insight.js +156 -0
  43. package/dist/src/cli/commands/job.d.ts +2 -0
  44. package/dist/src/cli/commands/job.js +406 -0
  45. package/dist/src/cli/commands/meaning.d.ts +2 -0
  46. package/dist/src/cli/commands/meaning.js +115 -0
  47. package/dist/src/cli/commands/metrics.d.ts +2 -0
  48. package/dist/src/cli/commands/metrics.js +39 -0
  49. package/dist/src/cli/commands/notebook.d.ts +2 -0
  50. package/dist/src/cli/commands/notebook.js +242 -0
  51. package/dist/src/cli/commands/project-deployer.d.ts +2 -0
  52. package/dist/src/cli/commands/project-deployer.js +118 -0
  53. package/dist/src/cli/commands/project-library.d.ts +2 -0
  54. package/dist/src/cli/commands/project-library.js +197 -0
  55. package/dist/src/cli/commands/project.d.ts +2 -0
  56. package/dist/src/cli/commands/project.js +132 -0
  57. package/dist/src/cli/commands/recipe.d.ts +2 -0
  58. package/dist/src/cli/commands/recipe.js +632 -0
  59. package/dist/src/cli/commands/scenario.d.ts +2 -0
  60. package/dist/src/cli/commands/scenario.js +190 -0
  61. package/dist/src/cli/commands/sql.d.ts +2 -0
  62. package/dist/src/cli/commands/sql.js +109 -0
  63. package/dist/src/cli/commands/statistics.d.ts +2 -0
  64. package/dist/src/cli/commands/statistics.js +165 -0
  65. package/dist/src/cli/commands/streaming-endpoint.d.ts +2 -0
  66. package/dist/src/cli/commands/streaming-endpoint.js +50 -0
  67. package/dist/src/cli/commands/variable.d.ts +2 -0
  68. package/dist/src/cli/commands/variable.js +49 -0
  69. package/dist/src/cli/commands/webapp.d.ts +2 -0
  70. package/dist/src/cli/commands/webapp.js +67 -0
  71. package/dist/src/cli/commands/wiki.d.ts +2 -0
  72. package/dist/src/cli/commands/wiki.js +123 -0
  73. package/dist/src/cli/commands/workspace.d.ts +2 -0
  74. package/dist/src/cli/commands/workspace.js +68 -0
  75. package/dist/src/cli/contract.d.ts +104 -0
  76. package/dist/src/cli/contract.js +2031 -0
  77. package/dist/src/cli/doctor.d.ts +104 -0
  78. package/dist/src/cli/doctor.js +356 -0
  79. package/dist/src/cli/env.d.ts +2 -0
  80. package/dist/src/cli/env.js +37 -0
  81. package/dist/src/cli/flags.d.ts +16 -0
  82. package/dist/src/cli/flags.js +255 -0
  83. package/dist/src/cli/helpers/cleanup.d.ts +3 -0
  84. package/dist/src/cli/helpers/cleanup.js +158 -0
  85. package/dist/src/cli/helpers/dataset.d.ts +2 -0
  86. package/dist/src/cli/helpers/dataset.js +17 -0
  87. package/dist/src/cli/helpers/flow-zone.d.ts +69 -0
  88. package/dist/src/cli/helpers/flow-zone.js +420 -0
  89. package/dist/src/cli/helpers/recipe.d.ts +11 -0
  90. package/dist/src/cli/helpers/recipe.js +83 -0
  91. package/dist/src/cli/output.d.ts +38 -0
  92. package/dist/src/cli/output.js +159 -0
  93. package/dist/src/cli/runtime.d.ts +15 -0
  94. package/dist/src/cli/runtime.js +59 -0
  95. package/dist/src/cli/types.d.ts +25 -0
  96. package/dist/src/cli/types.js +1 -0
  97. package/dist/src/cli/usage.d.ts +16 -0
  98. package/dist/src/cli/usage.js +80 -0
  99. package/dist/src/cli/version.d.ts +14 -0
  100. package/dist/src/cli/version.js +63 -0
  101. package/dist/src/cli.js +671 -8254
  102. package/dist/src/client.d.ts +1 -1
  103. package/dist/src/client.js +14 -13
  104. package/dist/src/errors.d.ts +6 -0
  105. package/dist/src/errors.js +127 -4
  106. package/dist/src/index.d.ts +3 -3
  107. package/dist/src/index.js +2 -2
  108. package/dist/src/resources/applications.d.ts +1 -1
  109. package/dist/src/resources/applications.js +27 -1
  110. package/dist/src/resources/bundles.js +2 -2
  111. package/dist/src/resources/continuous-activities.js +1 -0
  112. package/dist/src/resources/data-quality.js +5 -3
  113. package/dist/src/resources/datasets.d.ts +3 -0
  114. package/dist/src/resources/datasets.js +3 -0
  115. package/dist/src/resources/flow-zones.d.ts +2 -2
  116. package/dist/src/resources/flow-zones.js +4 -1
  117. package/dist/src/resources/meanings.d.ts +2 -0
  118. package/dist/src/resources/meanings.js +4 -0
  119. package/dist/src/resources/notebooks.d.ts +5 -7
  120. package/dist/src/resources/notebooks.js +10 -7
  121. package/dist/src/resources/projects.d.ts +1 -1
  122. package/dist/src/resources/projects.js +2 -2
  123. package/dist/src/resources/recipes.d.ts +3 -3
  124. package/dist/src/resources/recipes.js +50 -7
  125. package/dist/src/resources/scenarios.js +67 -26
  126. package/dist/src/resources/statistics.js +9 -0
  127. package/dist/src/schemas.d.ts +2 -2
  128. package/dist/src/schemas.js +1 -1
  129. package/dist/src/skill.js +2 -2
  130. package/dist/src/utils/sanitize.js +2 -1
  131. package/package.json +1 -1
  132. package/packages/types/dist/index.d.ts +15 -2
  133. package/packages/types/dist/index.js +9 -1
@@ -0,0 +1,406 @@
1
+ import { mkdir, writeFile, } from "node:fs/promises";
2
+ import { dirname, resolve, } from "node:path";
3
+ import { parseJobLogProgress, } from "../../resources/jobs.js";
4
+ import { jobBuildTargetTypeFromFlags, jobLogFilterFromFlag, maxLogLinesFromFlags, num, plainRecord, } from "../coerce.js";
5
+ import { encodedProjectEndpoint, } from "../output.js";
6
+ import { requireArgs, UsageError, } from "../usage.js";
7
+ // ---------------------------------------------------------------------------
8
+ // Utility helpers
9
+ // ---------------------------------------------------------------------------
10
+ function nestedValue(value, path) {
11
+ let current = value;
12
+ for (const key of path) {
13
+ const record = plainRecord(current);
14
+ if (!record)
15
+ return undefined;
16
+ current = record[key];
17
+ }
18
+ return current;
19
+ }
20
+ function stringPath(value, path) {
21
+ const item = nestedValue(value, path);
22
+ return typeof item === "string" && item.length > 0 ? item : undefined;
23
+ }
24
+ function numberPath(value, path) {
25
+ const item = nestedValue(value, path);
26
+ return typeof item === "number" && Number.isFinite(item) ? item : undefined;
27
+ }
28
+ function firstNumberPath(value, paths) {
29
+ for (const path of paths) {
30
+ const item = numberPath(value, path);
31
+ if (item !== undefined)
32
+ return item;
33
+ }
34
+ return undefined;
35
+ }
36
+ function jobSummaryId(job, fallback) {
37
+ return stringPath(job, ["baseStatus", "def", "id",])
38
+ ?? stringPath(job, ["def", "id",])
39
+ ?? stringPath(job, ["id",])
40
+ ?? fallback
41
+ ?? "unknown";
42
+ }
43
+ function jobSummaryType(job) {
44
+ return stringPath(job, ["baseStatus", "def", "type",])
45
+ ?? stringPath(job, ["def", "type",])
46
+ ?? stringPath(job, ["type",])
47
+ ?? "unknown";
48
+ }
49
+ function jobSummaryState(job) {
50
+ return stringPath(job, ["baseStatus", "state",])
51
+ ?? stringPath(job, ["state",])
52
+ ?? "unknown";
53
+ }
54
+ function filteredJobList(jobs, flags) {
55
+ const state = typeof flags["state"] === "string" ? flags["state"].trim().toUpperCase() : "";
56
+ const contains = typeof flags["contains"] === "string"
57
+ ? flags["contains"].trim().toLowerCase()
58
+ : "";
59
+ const output = typeof flags["output"] === "string" ? flags["output"].trim().toLowerCase() : "";
60
+ let result = jobs.filter((job) => {
61
+ if (state && jobSummaryState(job).toUpperCase() !== state)
62
+ return false;
63
+ const text = JSON.stringify(job).toLowerCase();
64
+ if (contains && !text.includes(contains))
65
+ return false;
66
+ if (output && !text.includes(output))
67
+ return false;
68
+ return true;
69
+ });
70
+ const limit = flags["latest"] === true ? 1 : num(flags["limit"]);
71
+ if (limit !== undefined)
72
+ result = result.slice(0, Math.max(0, limit));
73
+ return result;
74
+ }
75
+ function maxNumber(values) {
76
+ return values.length === 0 ? 0 : Math.max(...values);
77
+ }
78
+ function collectWarningCounts(value, inActivity, counts) {
79
+ if (Array.isArray(value)) {
80
+ for (const item of value)
81
+ collectWarningCounts(item, inActivity, counts);
82
+ return;
83
+ }
84
+ const record = plainRecord(value);
85
+ if (!record)
86
+ return;
87
+ for (const [key, item,] of Object.entries(record)) {
88
+ const lower = key.toLowerCase();
89
+ const nextInActivity = inActivity || lower.includes("activit");
90
+ if (lower.includes("warn")) {
91
+ const target = nextInActivity ? counts.activity : counts.dss;
92
+ if (typeof item === "number" && Number.isFinite(item))
93
+ target.push(item);
94
+ else if (Array.isArray(item))
95
+ target.push(item.length);
96
+ }
97
+ collectWarningCounts(item, nextInActivity, counts);
98
+ }
99
+ }
100
+ function jobWarningSummary(details, log) {
101
+ const counts = { dss: [], activity: [], };
102
+ collectWarningCounts(details, false, counts);
103
+ const warningLines = log
104
+ ? log.split(/\r?\n/).map((line) => line.trim()).filter((line) => /\bwarn(?:ing)?\b/i.test(line))
105
+ : [];
106
+ return {
107
+ dssSummaryWarningCount: maxNumber(counts.dss),
108
+ activityWarningCount: maxNumber(counts.activity),
109
+ logWarnLineCount: warningLines.length,
110
+ sampledWarningMessages: warningLines.slice(0, 5),
111
+ };
112
+ }
113
+ function jobDurationMs(details) {
114
+ const started = firstNumberPath(details, [
115
+ ["baseStatus", "startTime",],
116
+ ["baseStatus", "start",],
117
+ ["startTime",],
118
+ ["start",],
119
+ ]);
120
+ const ended = firstNumberPath(details, [
121
+ ["baseStatus", "endTime",],
122
+ ["baseStatus", "end",],
123
+ ["endTime",],
124
+ ["end",],
125
+ ]);
126
+ return started !== undefined && ended !== undefined && ended >= started
127
+ ? ended - started
128
+ : undefined;
129
+ }
130
+ async function jobInspectionSummary(client, jobId, flags) {
131
+ const projectKey = flags["project-key"];
132
+ const details = await client.jobs.get(jobId, projectKey);
133
+ let log;
134
+ let logError;
135
+ try {
136
+ log = await client.jobs.log(jobId, {
137
+ activity: flags["activity"],
138
+ logId: flags["log-id"],
139
+ maxLogLines: maxLogLinesFromFlags(flags),
140
+ projectKey,
141
+ });
142
+ }
143
+ catch (error) {
144
+ logError = error instanceof Error ? error.message : String(error);
145
+ }
146
+ const durationMs = jobDurationMs(details);
147
+ const progress = log ? parseJobLogProgress(log, durationMs) : undefined;
148
+ const logLines = log
149
+ ? log.split(/\r?\n/).map((line) => line.trim()).filter((line) => line.length > 0)
150
+ : [];
151
+ const maxSummaryLines = Math.max(1, maxLogLinesFromFlags(flags) ?? 20);
152
+ const outputs = nestedValue(details, ["baseStatus", "def", "outputs",])
153
+ ?? nestedValue(details, ["def", "outputs",])
154
+ ?? details.outputs;
155
+ return {
156
+ resource: "job",
157
+ jobId: jobSummaryId(details, jobId),
158
+ state: jobSummaryState(details),
159
+ type: jobSummaryType(details),
160
+ ...(durationMs !== undefined ? { durationMs, } : {}),
161
+ ...(outputs !== undefined ? { outputs, } : {}),
162
+ warnings: jobWarningSummary(details, log),
163
+ ...(progress
164
+ ? {
165
+ progress,
166
+ latestUsefulProgressLine: progress.lastProgressLine,
167
+ doneLine: progress.doneLine,
168
+ }
169
+ : {}),
170
+ logSummary: {
171
+ lineCount: logLines.length,
172
+ lines: logLines.slice(-maxSummaryLines),
173
+ ...(logError ? { error: logError, } : {}),
174
+ },
175
+ };
176
+ }
177
+ export const jobCommands = {
178
+ list: {
179
+ handler: async (c, _a, f) => filteredJobList(await c.jobs.list(f["project-key"]), f),
180
+ usage: "dss job list [--state STATE] [--contains TEXT] [--output ID] [--latest] [--limit N] [--project-key KEY]",
181
+ description: "List recent jobs, optionally filtered for automation.",
182
+ examples: ["dss job list --state DONE --latest", "dss job list --contains WLM225S --limit 10",],
183
+ },
184
+ get: {
185
+ handler: (c, a, f) => {
186
+ requireArgs(a, 1, "dss job get <id>");
187
+ return c.jobs.get(a[0], f["project-key"]);
188
+ },
189
+ usage: "dss job get <id> [--project-key KEY]",
190
+ description: "Get job details.",
191
+ examples: ["dss job get JOB_ID",],
192
+ },
193
+ summary: {
194
+ handler: (c, a, f) => {
195
+ requireArgs(a, 1, "dss job summary <id>");
196
+ return jobInspectionSummary(c, a[0], f);
197
+ },
198
+ usage: "dss job summary <id> [--activity ACTIVITY_ID] [--log-id LOG_ID] [--max-lines N|--max-log-lines N] [--project-key KEY]",
199
+ description: "Summarize job state, outputs, warnings, progress, and useful terminal log lines.",
200
+ examples: ["dss job summary JOB_ID --max-log-lines 200",],
201
+ },
202
+ log: {
203
+ handler: async (c, a, f) => {
204
+ requireArgs(a, 1, "dss job log <id>");
205
+ const logFilter = f["errors-only"] === true
206
+ ? "errors"
207
+ : jobLogFilterFromFlag(f["log-filter"]);
208
+ const log = await c.jobs.log(a[0], {
209
+ activity: f["activity"],
210
+ logId: f["log-id"],
211
+ logFilter,
212
+ maxLogLines: maxLogLinesFromFlags(f),
213
+ projectKey: f["project-key"],
214
+ });
215
+ const outputFile = f["output"]
216
+ ?? f["output-file"];
217
+ if (!outputFile)
218
+ return log;
219
+ const outputPath = resolve(outputFile);
220
+ await mkdir(dirname(outputPath), { recursive: true, });
221
+ await writeFile(outputPath, log.endsWith("\n") ? log : `${log}\n`, "utf-8");
222
+ return outputPath;
223
+ },
224
+ usage: "dss job log <id> [--activity ACTIVITY_ID] [--log-id LOG_ID] [--log-filter stdout|stderr|user|errors] [--errors-only] [--max-lines N|--max-log-lines N] [--output PATH] [--project-key KEY]",
225
+ description: "Get public API job log output. Use --errors-only (or --log-filter errors) to surface just error/traceback lines, and --output PATH to write the log to a file (stdout returns the path). --log-id is accepted for UI parity but DSS API-key auth cannot select browser-only cat-activity-log files.",
226
+ examples: [
227
+ "dss job log JOB_ID",
228
+ "dss job log JOB_ID --activity main --max-log-lines 200",
229
+ ],
230
+ },
231
+ "log-url": {
232
+ handler: (c, a, f) => {
233
+ requireArgs(a, 1, "dss job log-url <url>");
234
+ let parsed;
235
+ try {
236
+ parsed = new URL(a[0], "http://dss.local");
237
+ }
238
+ catch {
239
+ throw new UsageError("Log URL must be a valid URL.");
240
+ }
241
+ const projectKey = parsed.searchParams.get("projectKey");
242
+ const jobId = parsed.searchParams.get("jobId");
243
+ const activity = parsed.searchParams.get("activityId");
244
+ if (!projectKey || !jobId || !activity) {
245
+ throw new UsageError("Log URL must include projectKey, jobId, and activityId query parameters.");
246
+ }
247
+ return c.jobs.logFromUrl(a[0], { maxLogLines: maxLogLinesFromFlags(f), });
248
+ },
249
+ usage: "dss job log-url <url> [--max-lines N|--max-log-lines N]",
250
+ description: "Fetch a DSS cat-activity-log URL pasted from the UI.",
251
+ examples: [
252
+ 'dss job log-url "https://dss/dip/api/flow/jobs/cat-activity-log?projectKey=TEST&jobId=JOB&activityId=A&logId=L"',
253
+ ],
254
+ },
255
+ build: {
256
+ handler: async (c, a, f) => {
257
+ requireArgs(a, 1, "dss job build <target>");
258
+ const pk = f["project-key"];
259
+ const options = {
260
+ buildMode: f["build-mode"],
261
+ partition: f["partition"],
262
+ pollIntervalMs: num(f["poll-interval"]),
263
+ targetType: jobBuildTargetTypeFromFlags(f),
264
+ timeoutMs: num(f["timeout"]),
265
+ };
266
+ if (f["dry-run"] === true) {
267
+ return {
268
+ dryRun: true,
269
+ action: "build",
270
+ resource: "job",
271
+ target: a[0],
272
+ ...options,
273
+ endpoint: encodedProjectEndpoint(c, pk, "/jobs/"),
274
+ method: "POST",
275
+ };
276
+ }
277
+ if (f["wait"] === true) {
278
+ return c.jobs.buildAndWait(a[0], { ...options, projectKey: pk, });
279
+ }
280
+ return c.jobs.build(a[0], { ...options, projectKey: pk, });
281
+ },
282
+ usage: "dss job build <target> [--target-type dataset|managed-folder] [--type DATASET|MANAGED_FOLDER] [--build-mode MODE] [--wait] [--timeout MS] [--poll-interval MS] [--partition PARTITION] [--dry-run] [--project-key KEY]",
283
+ description: "Start a dataset or managed-folder build, optionally waiting for completion.",
284
+ examples: [
285
+ "dss job build orders",
286
+ "dss job build orders --build-mode RECURSIVE_BUILD --wait",
287
+ "dss job build LT7TUHJ8 --target-type managed-folder --dry-run",
288
+ ],
289
+ },
290
+ "build-and-wait": {
291
+ handler: async (c, a, f) => {
292
+ requireArgs(a, 1, "dss job build-and-wait <target>");
293
+ const pk = f["project-key"];
294
+ const options = {
295
+ buildMode: f["build-mode"],
296
+ includeLogs: f["include-logs"] === true,
297
+ logFilter: jobLogFilterFromFlag(f["log-filter"]),
298
+ maxLogLines: maxLogLinesFromFlags(f),
299
+ partition: f["partition"],
300
+ pollIntervalMs: num(f["poll-interval"]),
301
+ timeoutMs: num(f["timeout"]),
302
+ summary: f["summary"] === true,
303
+ targetType: jobBuildTargetTypeFromFlags(f),
304
+ };
305
+ if (f["dry-run"] === true) {
306
+ return {
307
+ dryRun: true,
308
+ action: "build-and-wait",
309
+ resource: "job",
310
+ target: a[0],
311
+ ...options,
312
+ endpoint: encodedProjectEndpoint(c, pk, "/jobs/"),
313
+ method: "POST",
314
+ };
315
+ }
316
+ return c.jobs.buildAndWait(a[0], { ...options, projectKey: pk, });
317
+ },
318
+ usage: "dss job build-and-wait <target> [--target-type dataset|managed-folder] [--type DATASET|MANAGED_FOLDER] [--build-mode MODE] [--include-logs] [--log-filter stdout|stderr|user|errors] [--summary] [--max-log-lines N] [--timeout MS] [--poll-interval MS] [--partition PARTITION] [--dry-run] [--project-key KEY]",
319
+ description: "Build a dataset or managed folder and wait for completion.",
320
+ examples: [
321
+ "dss job build-and-wait orders",
322
+ "dss job build-and-wait orders --include-logs --log-filter stdout --summary",
323
+ "dss job build-and-wait orders --timeout 300000",
324
+ "dss job build-and-wait LT7TUHJ8 --target-type managed-folder --dry-run",
325
+ ],
326
+ },
327
+ wait: {
328
+ handler: (c, a, f) => {
329
+ requireArgs(a, 1, "dss job wait <id>");
330
+ return c.jobs.wait(a[0], {
331
+ includeLogs: f["include-logs"] === true,
332
+ logFilter: jobLogFilterFromFlag(f["log-filter"]),
333
+ maxLogLines: maxLogLinesFromFlags(f),
334
+ pollIntervalMs: num(f["poll-interval"]),
335
+ timeoutMs: num(f["timeout"]),
336
+ summary: f["summary"] === true,
337
+ projectKey: f["project-key"],
338
+ });
339
+ },
340
+ usage: "dss job wait <id> [--include-logs] [--log-filter stdout|stderr|user|errors] [--summary] [--max-log-lines N] [--timeout MS] [--poll-interval MS] [--project-key KEY]",
341
+ description: "Wait for an existing job to complete.",
342
+ examples: [
343
+ "dss job wait JOB_ID",
344
+ "dss job wait JOB_ID --include-logs --log-filter stdout --summary --timeout 60000",
345
+ ],
346
+ },
347
+ monitor: {
348
+ handler: async (c, a, f) => {
349
+ requireArgs(a, 1, "dss job monitor <id...>");
350
+ const options = {
351
+ includeLogs: f["include-logs"] === true,
352
+ logFilter: jobLogFilterFromFlag(f["log-filter"]),
353
+ maxLogLines: maxLogLinesFromFlags(f),
354
+ pollIntervalMs: num(f["poll-interval"]),
355
+ timeoutMs: num(f["timeout"]),
356
+ summary: f["summary"] !== false,
357
+ projectKey: f["project-key"],
358
+ };
359
+ const jobs = await Promise.all(a.map((jobId) => c.jobs.wait(jobId, options)));
360
+ return a.length === 1 ? jobs[0] : { jobs, until: f["until"] ?? "all-done", };
361
+ },
362
+ usage: "dss job monitor <id...> [--summary] [--include-logs] [--log-filter stdout|stderr|user|errors] [--max-log-lines N] [--timeout MS] [--poll-interval MS] [--until all-done] [--project-key KEY]",
363
+ description: "Monitor one or more existing jobs and summarize progress counters from logs.",
364
+ examples: ["dss job monitor JOB_ID --summary", "dss job monitor JOB1 JOB2 --until all-done",],
365
+ },
366
+ watch: {
367
+ handler: async (c, a, f) => {
368
+ requireArgs(a, 1, "dss job watch <id...>");
369
+ const options = {
370
+ includeLogs: f["include-logs"] === true,
371
+ logFilter: jobLogFilterFromFlag(f["log-filter"]),
372
+ maxLogLines: maxLogLinesFromFlags(f),
373
+ pollIntervalMs: num(f["poll-interval"]),
374
+ timeoutMs: num(f["timeout"]),
375
+ summary: true,
376
+ projectKey: f["project-key"],
377
+ };
378
+ const jobs = await Promise.all(a.map((jobId) => c.jobs.wait(jobId, options)));
379
+ return a.length === 1 ? jobs[0] : { jobs, until: f["until"] ?? "all-done", };
380
+ },
381
+ usage: "dss job watch <id...> [--include-logs] [--log-filter stdout|stderr|user|errors] [--max-log-lines N] [--timeout MS] [--poll-interval MS] [--until all-done] [--project-key KEY]",
382
+ description: "Watch one or more existing jobs with progress extraction enabled.",
383
+ examples: ["dss job watch JOB_ID", "dss job watch JOB1 JOB2 --until all-done",],
384
+ },
385
+ abort: {
386
+ handler: async (c, a, f) => {
387
+ requireArgs(a, 1, "dss job abort <id>");
388
+ const pk = f["project-key"];
389
+ if (f["dry-run"] === true) {
390
+ return {
391
+ dryRun: true,
392
+ action: "abort",
393
+ resource: "job",
394
+ id: a[0],
395
+ endpoint: encodedProjectEndpoint(c, pk, `/jobs/${encodeURIComponent(a[0])}/abort/`),
396
+ method: "POST",
397
+ };
398
+ }
399
+ await c.jobs.abort(a[0], pk);
400
+ return { aborted: a[0], resource: "job", };
401
+ },
402
+ usage: "dss job abort <id> [--dry-run] [--project-key KEY]",
403
+ description: "Abort a running job.",
404
+ examples: ["dss job abort JOB_ID", "dss job abort JOB_ID --dry-run",],
405
+ },
406
+ };
@@ -0,0 +1,2 @@
1
+ import type { CommandMeta } from "../types.js";
2
+ export declare const meaningCommands: Record<string, CommandMeta>;
@@ -0,0 +1,115 @@
1
+ import { jsonInput, requiredJsonInput, } from "../coerce.js";
2
+ import { isNotFoundError, planResult, skipResult, } from "../output.js";
3
+ import { requireArgs, } from "../usage.js";
4
+ const MEANING_PLAN_FAILURE_CODES = { usage: 1, error: 2, transient: 3, };
5
+ function meaningEndpoint(meaningId) {
6
+ return `/public/api/meanings/${encodeURIComponent(meaningId)}`;
7
+ }
8
+ function meaningCreatePayload(id, label, type, body) {
9
+ return {
10
+ ...body,
11
+ id,
12
+ label,
13
+ type,
14
+ description: body.description ?? null,
15
+ entries: body.entries ?? null,
16
+ mappings: body.mappings ?? null,
17
+ pattern: body.pattern ?? null,
18
+ normalizationMode: body.normalizationMode ?? null,
19
+ detectable: body.detectable ?? false,
20
+ };
21
+ }
22
+ export const meaningCommands = {
23
+ list: {
24
+ handler: (c) => c.meanings.list(),
25
+ usage: "dss meaning list",
26
+ description: "List user-defined meanings (column semantic types) on the instance.",
27
+ examples: ["dss meaning list",],
28
+ },
29
+ get: {
30
+ handler: (c, a) => {
31
+ requireArgs(a, 1, "dss meaning get <meaningId>");
32
+ return c.meanings.get(a[0]);
33
+ },
34
+ usage: "dss meaning get <meaningId>",
35
+ description: "Get a user-defined meaning definition.",
36
+ examples: ["dss meaning get customer_type",],
37
+ },
38
+ create: {
39
+ handler: async (c, a, f) => {
40
+ requireArgs(a, 3, "dss meaning create <id> <label> <type> [--data JSON|--data-file PATH|--stdin] [--dry-run]");
41
+ const body = jsonInput(f) ?? {};
42
+ const payload = meaningCreatePayload(a[0], a[1], a[2], body);
43
+ if (f["dry-run"] === true) {
44
+ return planResult("meaning", "create", {
45
+ asyncKind: "none",
46
+ method: "POST",
47
+ endpoint: "/public/api/meanings/",
48
+ identifiers: { id: a[0], },
49
+ payload,
50
+ idempotency: "none",
51
+ exitCodesOnFailure: MEANING_PLAN_FAILURE_CODES,
52
+ plannedAndDryRun: true,
53
+ });
54
+ }
55
+ return c.meanings.create(a[0], a[1], a[2], body);
56
+ },
57
+ usage: "dss meaning create <id> <label> <type> [--data JSON|--data-file PATH|--stdin] [--dry-run]",
58
+ description: "Create a user-defined meaning (type e.g. VALUES_LIST, VALUES_MAPPING, PATTERN).",
59
+ examples: ["dss meaning create vip VIP VALUES_LIST --dry-run",],
60
+ },
61
+ update: {
62
+ handler: async (c, a, f) => {
63
+ requireArgs(a, 1, "dss meaning update <meaningId> (--data JSON|--data-file PATH|--stdin) [--dry-run]");
64
+ const body = requiredJsonInput(f, "--data, --data-file, or --stdin is required (meaning definition).");
65
+ if (f["dry-run"] === true) {
66
+ return planResult("meaning", "update", {
67
+ asyncKind: "none",
68
+ method: "PUT",
69
+ endpoint: meaningEndpoint(a[0]),
70
+ identifiers: { id: a[0], },
71
+ payload: body,
72
+ idempotency: "none",
73
+ exitCodesOnFailure: MEANING_PLAN_FAILURE_CODES,
74
+ plannedAndDryRun: true,
75
+ });
76
+ }
77
+ return c.meanings.update(a[0], body);
78
+ },
79
+ usage: "dss meaning update <meaningId> (--data JSON|--data-file PATH|--stdin) [--dry-run]",
80
+ description: "Replace a user-defined meaning definition.",
81
+ examples: ["dss meaning update vip --data-file meaning.json --dry-run",],
82
+ },
83
+ delete: {
84
+ handler: async (c, a, f) => {
85
+ requireArgs(a, 1, "dss meaning delete <meaningId>");
86
+ if (f["dry-run"] === true || f["if-exists"] === true) {
87
+ const current = await c.meanings.get(a[0]).catch((error) => {
88
+ if (isNotFoundError(error)
89
+ || (error instanceof Error && /unknown meaning/i.test(error.message))) {
90
+ return undefined;
91
+ }
92
+ throw error;
93
+ });
94
+ if (!current)
95
+ return skipResult("meaning", a[0], "missing");
96
+ if (f["dry-run"] === true) {
97
+ return planResult("meaning", "delete", {
98
+ asyncKind: "none",
99
+ method: "DELETE",
100
+ endpoint: meaningEndpoint(a[0]),
101
+ identifiers: { id: a[0], },
102
+ idempotency: "if-exists",
103
+ exitCodesOnFailure: MEANING_PLAN_FAILURE_CODES,
104
+ plannedAndDryRun: true,
105
+ });
106
+ }
107
+ }
108
+ await c.meanings.delete(a[0]);
109
+ return { deleted: a[0], resource: "meaning", };
110
+ },
111
+ usage: "dss meaning delete <meaningId> [--if-exists] [--dry-run]",
112
+ description: "Delete a user-defined meaning definition.",
113
+ examples: ["dss meaning delete vip --dry-run",],
114
+ },
115
+ };
@@ -0,0 +1,2 @@
1
+ import type { CommandMeta } from "../types.js";
2
+ export declare const metricsCommands: Record<string, CommandMeta>;
@@ -0,0 +1,39 @@
1
+ import { requireArgs, } from "../usage.js";
2
+ export const metricsCommands = {
3
+ "dataset-get": {
4
+ handler: (c, a, f) => {
5
+ requireArgs(a, 1, "dss metrics dataset-get <dataset> [--project-key KEY]");
6
+ return c.metrics.getDatasetMetrics(a[0], f["project-key"]);
7
+ },
8
+ usage: "dss metrics dataset-get <dataset> [--project-key KEY]",
9
+ description: "Get the last computed metric values for a dataset.",
10
+ examples: ["dss metrics dataset-get customers",],
11
+ },
12
+ "dataset-compute": {
13
+ handler: (c, a, f) => {
14
+ requireArgs(a, 1, "dss metrics dataset-compute <dataset> [--project-key KEY]");
15
+ return c.metrics.computeDatasetMetrics(a[0], f["project-key"]);
16
+ },
17
+ usage: "dss metrics dataset-compute <dataset> [--project-key KEY]",
18
+ description: "Compute the DSS-configured metrics for a dataset.",
19
+ examples: ["dss metrics dataset-compute customers",],
20
+ },
21
+ "dataset-history": {
22
+ handler: (c, a, f) => {
23
+ requireArgs(a, 2, "dss metrics dataset-history <dataset> <metricId> [--project-key KEY]");
24
+ return c.metrics.getDatasetMetricHistory(a[0], a[1], f["project-key"]);
25
+ },
26
+ usage: "dss metrics dataset-history <dataset> <metricId> [--project-key KEY]",
27
+ description: "Get the history of one dataset metric.",
28
+ examples: ["dss metrics dataset-history customers records:COUNT_RECORDS",],
29
+ },
30
+ "folder-get": {
31
+ handler: (c, a, f) => {
32
+ requireArgs(a, 1, "dss metrics folder-get <folderId> [--project-key KEY]");
33
+ return c.metrics.getFolderMetrics(a[0], f["project-key"]);
34
+ },
35
+ usage: "dss metrics folder-get <folderId> [--project-key KEY]",
36
+ description: "Get the last computed metric values for a managed folder.",
37
+ examples: ["dss metrics folder-get aBcDeFgH",],
38
+ },
39
+ };
@@ -0,0 +1,2 @@
1
+ import type { CommandMeta } from "../types.js";
2
+ export declare const notebookCommands: Record<string, CommandMeta>;