dataiku-sdk 0.10.1 → 0.12.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 (151) hide show
  1. package/LICENSE +21 -0
  2. package/dist/packages/types/src/index.d.ts +19 -2
  3. package/dist/packages/types/src/index.js +13 -1
  4. package/dist/src/cli/coerce.d.ts +36 -0
  5. package/dist/src/cli/coerce.js +239 -0
  6. package/dist/src/cli/commands/analysis.d.ts +2 -0
  7. package/dist/src/cli/commands/analysis.js +66 -0
  8. package/dist/src/cli/commands/api-deployer.d.ts +2 -0
  9. package/dist/src/cli/commands/api-deployer.js +170 -0
  10. package/dist/src/cli/commands/api-service.d.ts +2 -0
  11. package/dist/src/cli/commands/api-service.js +121 -0
  12. package/dist/src/cli/commands/app.d.ts +2 -0
  13. package/dist/src/cli/commands/app.js +78 -0
  14. package/dist/src/cli/commands/bundle.d.ts +2 -0
  15. package/dist/src/cli/commands/bundle.js +107 -0
  16. package/dist/src/cli/commands/business-app.d.ts +2 -0
  17. package/dist/src/cli/commands/business-app.js +76 -0
  18. package/dist/src/cli/commands/code-env.d.ts +2 -0
  19. package/dist/src/cli/commands/code-env.js +255 -0
  20. package/dist/src/cli/commands/code.d.ts +2 -0
  21. package/dist/src/cli/commands/code.js +63 -0
  22. package/dist/src/cli/commands/connection.d.ts +2 -0
  23. package/dist/src/cli/commands/connection.js +54 -0
  24. package/dist/src/cli/commands/continuous-activity.d.ts +2 -0
  25. package/dist/src/cli/commands/continuous-activity.js +38 -0
  26. package/dist/src/cli/commands/dashboard.d.ts +2 -0
  27. package/dist/src/cli/commands/dashboard.js +99 -0
  28. package/dist/src/cli/commands/data-quality.d.ts +2 -0
  29. package/dist/src/cli/commands/data-quality.js +235 -0
  30. package/dist/src/cli/commands/dataset.d.ts +2 -0
  31. package/dist/src/cli/commands/dataset.js +288 -0
  32. package/dist/src/cli/commands/discussion.d.ts +2 -0
  33. package/dist/src/cli/commands/discussion.js +47 -0
  34. package/dist/src/cli/commands/doctor.d.ts +2 -0
  35. package/dist/src/cli/commands/doctor.js +9 -0
  36. package/dist/src/cli/commands/flow-zone.d.ts +2 -0
  37. package/dist/src/cli/commands/flow-zone.js +282 -0
  38. package/dist/src/cli/commands/folder.d.ts +2 -0
  39. package/dist/src/cli/commands/folder.js +202 -0
  40. package/dist/src/cli/commands/future.d.ts +2 -0
  41. package/dist/src/cli/commands/future.js +57 -0
  42. package/dist/src/cli/commands/index.d.ts +2 -0
  43. package/dist/src/cli/commands/index.js +78 -0
  44. package/dist/src/cli/commands/insight.d.ts +2 -0
  45. package/dist/src/cli/commands/insight.js +156 -0
  46. package/dist/src/cli/commands/job.d.ts +2 -0
  47. package/dist/src/cli/commands/job.js +406 -0
  48. package/dist/src/cli/commands/meaning.d.ts +2 -0
  49. package/dist/src/cli/commands/meaning.js +115 -0
  50. package/dist/src/cli/commands/metrics.d.ts +2 -0
  51. package/dist/src/cli/commands/metrics.js +39 -0
  52. package/dist/src/cli/commands/ml-task.d.ts +2 -0
  53. package/dist/src/cli/commands/ml-task.js +171 -0
  54. package/dist/src/cli/commands/model-evaluation-store.d.ts +2 -0
  55. package/dist/src/cli/commands/model-evaluation-store.js +83 -0
  56. package/dist/src/cli/commands/notebook.d.ts +2 -0
  57. package/dist/src/cli/commands/notebook.js +242 -0
  58. package/dist/src/cli/commands/project-deployer.d.ts +2 -0
  59. package/dist/src/cli/commands/project-deployer.js +118 -0
  60. package/dist/src/cli/commands/project-library.d.ts +2 -0
  61. package/dist/src/cli/commands/project-library.js +197 -0
  62. package/dist/src/cli/commands/project.d.ts +2 -0
  63. package/dist/src/cli/commands/project.js +133 -0
  64. package/dist/src/cli/commands/recipe.d.ts +2 -0
  65. package/dist/src/cli/commands/recipe.js +659 -0
  66. package/dist/src/cli/commands/saved-model.d.ts +2 -0
  67. package/dist/src/cli/commands/saved-model.js +85 -0
  68. package/dist/src/cli/commands/scenario.d.ts +2 -0
  69. package/dist/src/cli/commands/scenario.js +190 -0
  70. package/dist/src/cli/commands/sql.d.ts +2 -0
  71. package/dist/src/cli/commands/sql.js +109 -0
  72. package/dist/src/cli/commands/statistics.d.ts +2 -0
  73. package/dist/src/cli/commands/statistics.js +165 -0
  74. package/dist/src/cli/commands/streaming-endpoint.d.ts +2 -0
  75. package/dist/src/cli/commands/streaming-endpoint.js +50 -0
  76. package/dist/src/cli/commands/variable.d.ts +2 -0
  77. package/dist/src/cli/commands/variable.js +49 -0
  78. package/dist/src/cli/commands/webapp.d.ts +2 -0
  79. package/dist/src/cli/commands/webapp.js +67 -0
  80. package/dist/src/cli/commands/wiki.d.ts +2 -0
  81. package/dist/src/cli/commands/wiki.js +123 -0
  82. package/dist/src/cli/commands/workspace.d.ts +2 -0
  83. package/dist/src/cli/commands/workspace.js +68 -0
  84. package/dist/src/cli/contract.d.ts +104 -0
  85. package/dist/src/cli/contract.js +2041 -0
  86. package/dist/src/cli/doctor.d.ts +104 -0
  87. package/dist/src/cli/doctor.js +356 -0
  88. package/dist/src/cli/env.d.ts +2 -0
  89. package/dist/src/cli/env.js +37 -0
  90. package/dist/src/cli/flags.d.ts +16 -0
  91. package/dist/src/cli/flags.js +272 -0
  92. package/dist/src/cli/helpers/cleanup.d.ts +3 -0
  93. package/dist/src/cli/helpers/cleanup.js +204 -0
  94. package/dist/src/cli/helpers/dataset.d.ts +2 -0
  95. package/dist/src/cli/helpers/dataset.js +17 -0
  96. package/dist/src/cli/helpers/flow-zone.d.ts +69 -0
  97. package/dist/src/cli/helpers/flow-zone.js +420 -0
  98. package/dist/src/cli/helpers/recipe.d.ts +11 -0
  99. package/dist/src/cli/helpers/recipe.js +83 -0
  100. package/dist/src/cli/output.d.ts +38 -0
  101. package/dist/src/cli/output.js +159 -0
  102. package/dist/src/cli/runtime.d.ts +15 -0
  103. package/dist/src/cli/runtime.js +59 -0
  104. package/dist/src/cli/types.d.ts +25 -0
  105. package/dist/src/cli/types.js +1 -0
  106. package/dist/src/cli/usage.d.ts +16 -0
  107. package/dist/src/cli/usage.js +84 -0
  108. package/dist/src/cli/version.d.ts +14 -0
  109. package/dist/src/cli/version.js +63 -0
  110. package/dist/src/cli.js +671 -8254
  111. package/dist/src/client.d.ts +13 -1
  112. package/dist/src/client.js +34 -13
  113. package/dist/src/errors.d.ts +6 -0
  114. package/dist/src/errors.js +102 -4
  115. package/dist/src/index.d.ts +7 -3
  116. package/dist/src/index.js +6 -2
  117. package/dist/src/resources/analyses.d.ts +34 -0
  118. package/dist/src/resources/analyses.js +31 -0
  119. package/dist/src/resources/api-services.d.ts +2 -0
  120. package/dist/src/resources/api-services.js +10 -0
  121. package/dist/src/resources/applications.d.ts +1 -1
  122. package/dist/src/resources/applications.js +27 -1
  123. package/dist/src/resources/continuous-activities.js +1 -0
  124. package/dist/src/resources/data-quality.js +5 -3
  125. package/dist/src/resources/datasets.d.ts +3 -0
  126. package/dist/src/resources/datasets.js +10 -5
  127. package/dist/src/resources/flow-zones.d.ts +2 -2
  128. package/dist/src/resources/flow-zones.js +4 -1
  129. package/dist/src/resources/meanings.d.ts +2 -0
  130. package/dist/src/resources/meanings.js +4 -0
  131. package/dist/src/resources/ml-tasks.d.ts +91 -0
  132. package/dist/src/resources/ml-tasks.js +130 -0
  133. package/dist/src/resources/model-evaluation-stores.d.ts +41 -0
  134. package/dist/src/resources/model-evaluation-stores.js +36 -0
  135. package/dist/src/resources/notebooks.d.ts +5 -7
  136. package/dist/src/resources/notebooks.js +10 -7
  137. package/dist/src/resources/projects.d.ts +1 -1
  138. package/dist/src/resources/projects.js +2 -2
  139. package/dist/src/resources/recipes.d.ts +3 -3
  140. package/dist/src/resources/recipes.js +198 -38
  141. package/dist/src/resources/saved-models.d.ts +41 -0
  142. package/dist/src/resources/saved-models.js +40 -0
  143. package/dist/src/resources/scenarios.js +67 -26
  144. package/dist/src/resources/statistics.js +9 -0
  145. package/dist/src/schemas.d.ts +2 -2
  146. package/dist/src/schemas.js +1 -1
  147. package/dist/src/skill.js +2 -2
  148. package/dist/src/utils/sanitize.js +2 -1
  149. package/package.json +1 -1
  150. package/packages/types/dist/index.d.ts +19 -2
  151. package/packages/types/dist/index.js +13 -1
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 clssck
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -147,6 +147,10 @@ export declare const RecipeCreateOptionsSchema: import("@sinclair/typebox").TObj
147
147
  outputConnection: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
148
148
  joinOn: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>]>>;
149
149
  joinType: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
150
+ fuzzyOn: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>]>>;
151
+ fuzzyDistance: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
152
+ fuzzyThreshold: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
153
+ fuzzyNormalize: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
150
154
  projectKey: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
151
155
  outputFolder: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
152
156
  }>;
@@ -160,6 +164,7 @@ export declare const RecipeCreateResultSchema: import("@sinclair/typebox").TObje
160
164
  outputFolder: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
161
165
  temporaryOutputDataset: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
162
166
  temporaryOutputDatasetDeleted: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
167
+ syncOutputSchemaPropagated: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
163
168
  }>;
164
169
  export type RecipeCreateResult = Static<typeof RecipeCreateResultSchema>;
165
170
  export declare const JobSummarySchema: import("@sinclair/typebox").TObject<{
@@ -264,6 +269,12 @@ export declare const ScenarioStatusSchema: import("@sinclair/typebox").TObject<{
264
269
  }>>;
265
270
  }>;
266
271
  export type ScenarioStatus = Static<typeof ScenarioStatusSchema>;
272
+ export declare const ScenarioStepRunSchema: import("@sinclair/typebox").TObject<{
273
+ name: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
274
+ type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
275
+ outcome: import("@sinclair/typebox").TString;
276
+ }>;
277
+ export type ScenarioStepRun = Static<typeof ScenarioStepRunSchema>;
267
278
  export declare const ScenarioWaitResultSchema: import("@sinclair/typebox").TObject<{
268
279
  scenarioId: import("@sinclair/typebox").TString;
269
280
  runId: import("@sinclair/typebox").TString;
@@ -272,6 +283,12 @@ export declare const ScenarioWaitResultSchema: import("@sinclair/typebox").TObje
272
283
  elapsedMs: import("@sinclair/typebox").TNumber;
273
284
  pollCount: import("@sinclair/typebox").TNumber;
274
285
  timedOut: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
286
+ triggerRunId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
287
+ steps: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
288
+ name: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
289
+ type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
290
+ outcome: import("@sinclair/typebox").TString;
291
+ }>>>;
275
292
  }>;
276
293
  export type ScenarioWaitResult = Static<typeof ScenarioWaitResultSchema>;
277
294
  export declare const FlowZoneObjectTypeSchema: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"DATASET">, import("@sinclair/typebox").TLiteral<"MANAGED_FOLDER">, import("@sinclair/typebox").TLiteral<"SAVED_MODEL">, import("@sinclair/typebox").TLiteral<"RECIPE">, import("@sinclair/typebox").TLiteral<"MODEL_EVALUATION_STORE">, import("@sinclair/typebox").TLiteral<"STREAMING_ENDPOINT">, import("@sinclair/typebox").TLiteral<"LABELING_TASK">, import("@sinclair/typebox").TLiteral<"RETRIEVABLE_KNOWLEDGE">]>;
@@ -552,7 +569,7 @@ export declare const JupyterCellSchema: import("@sinclair/typebox").TObject<{
552
569
  source: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>;
553
570
  metadata: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TUnknown>>;
554
571
  outputs: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnknown>>;
555
- execution_count: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TNull]>>;
572
+ execution_count: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TNull, import("@sinclair/typebox").TNumber]>>;
556
573
  }>;
557
574
  export type JupyterCell = Static<typeof JupyterCellSchema>;
558
575
  export declare const JupyterNotebookSummarySchema: import("@sinclair/typebox").TObject<{
@@ -575,7 +592,7 @@ export declare const JupyterNotebookContentSchema: import("@sinclair/typebox").T
575
592
  source: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>;
576
593
  metadata: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TUnknown>>;
577
594
  outputs: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnknown>>;
578
- execution_count: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TNull]>>;
595
+ execution_count: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TNull, import("@sinclair/typebox").TNumber]>>;
579
596
  }>>;
580
597
  }>;
581
598
  export type JupyterNotebookContent = Static<typeof JupyterNotebookContentSchema>;
@@ -195,6 +195,10 @@ export const RecipeCreateOptionsSchema = Type.Object({
195
195
  outputConnection: Type.Optional(Type.String()),
196
196
  joinOn: Type.Optional(Type.Union([Type.String(), Type.Array(Type.String()),])),
197
197
  joinType: Type.Optional(Type.String()),
198
+ fuzzyOn: Type.Optional(Type.Union([Type.String(), Type.Array(Type.String()),])),
199
+ fuzzyDistance: Type.Optional(Type.String()),
200
+ fuzzyThreshold: Type.Optional(Type.Number()),
201
+ fuzzyNormalize: Type.Optional(Type.Boolean()),
198
202
  projectKey: Type.Optional(Type.String()),
199
203
  outputFolder: Type.Optional(Type.String()),
200
204
  });
@@ -207,6 +211,7 @@ export const RecipeCreateResultSchema = Type.Object({
207
211
  outputFolder: Type.Optional(Type.String()),
208
212
  temporaryOutputDataset: Type.Optional(Type.String()),
209
213
  temporaryOutputDatasetDeleted: Type.Optional(Type.Boolean()),
214
+ syncOutputSchemaPropagated: Type.Optional(Type.Array(Type.String())),
210
215
  });
211
216
  // ---------------------------------------------------------------------------
212
217
  // Jobs
@@ -313,6 +318,11 @@ export const ScenarioStatusSchema = Type.Object({
313
318
  }, { additionalProperties: true, })),
314
319
  }, { additionalProperties: true, })),
315
320
  }, { additionalProperties: true, });
321
+ export const ScenarioStepRunSchema = Type.Object({
322
+ name: Type.Optional(Type.String()),
323
+ type: Type.Optional(Type.String()),
324
+ outcome: Type.String(),
325
+ }, { additionalProperties: false, });
316
326
  export const ScenarioWaitResultSchema = Type.Object({
317
327
  scenarioId: Type.String(),
318
328
  runId: Type.String(),
@@ -321,6 +331,8 @@ export const ScenarioWaitResultSchema = Type.Object({
321
331
  elapsedMs: Type.Number(),
322
332
  pollCount: Type.Number(),
323
333
  timedOut: Type.Optional(Type.Boolean()),
334
+ triggerRunId: Type.Optional(Type.String()),
335
+ steps: Type.Optional(Type.Array(ScenarioStepRunSchema)),
324
336
  });
325
337
  // ---------------------------------------------------------------------------
326
338
  // Flow zones
@@ -548,7 +560,7 @@ export const JupyterCellSchema = Type.Object({
548
560
  source: Type.Array(Type.String()),
549
561
  metadata: Type.Optional(Type.Record(Type.String(), Type.Unknown())),
550
562
  outputs: Type.Optional(Type.Array(Type.Unknown())),
551
- execution_count: Type.Optional(Type.Union([Type.Number(), Type.Null(),])),
563
+ execution_count: Type.Optional(Type.Union([Type.Null(), Type.Number(),])),
552
564
  }, { additionalProperties: true, });
553
565
  export const JupyterNotebookSummarySchema = Type.Object({
554
566
  name: Type.String(),
@@ -0,0 +1,36 @@
1
+ import type { JobBuildTargetType, JobLogFilter } from "../resources/jobs.js";
2
+ export declare function num(v: string | boolean | undefined): number | undefined;
3
+ export declare function jobBuildTargetType(v: string | boolean | undefined): JobBuildTargetType;
4
+ export declare function jobBuildTargetTypeFromFlags(flags: Record<string, string | boolean>): JobBuildTargetType;
5
+ export declare function maxLogLinesFromFlags(flags: Record<string, string | boolean>): number | undefined;
6
+ export declare function jobLogFilterFromFlag(v: string | boolean | undefined): JobLogFilter | undefined;
7
+ export declare function sha256Hex(value: string): string;
8
+ export declare function normalizeLineEndings(value: string): string;
9
+ export declare function stableJson(value: unknown): string;
10
+ export declare function stableHash(value: unknown): string;
11
+ export declare function splitCsvFlag(v: string | boolean | undefined): string[];
12
+ export declare function recipeInputDatasetsFromFlags(flags: Record<string, string | boolean>): string[] | undefined;
13
+ export declare function rewritePairsFromFlags(flags: Record<string, string | boolean>, flagName: string): Record<string, string>;
14
+ export declare function plainRecord(value: unknown): Record<string, unknown> | undefined;
15
+ export declare function requiredStringFlag(flags: Record<string, string | boolean>, name: string, usage: string): string;
16
+ export declare function optionalStringField(record: Record<string, unknown>, keys: string[]): string | undefined;
17
+ export declare function requiredStringArray(value: unknown, source: string): string[];
18
+ export declare function finiteNumberField(record: Record<string, unknown>, key: string, source: string): number;
19
+ export declare function stripUtf8Bom(text: string): string;
20
+ export declare function parseJsonValue(text: string, source: string): unknown;
21
+ export declare function expectJsonObject(value: unknown, source: string): Record<string, unknown>;
22
+ export declare function parseJsonObject(text: string, source: string): Record<string, unknown>;
23
+ export declare function json(v: string | boolean | undefined, source?: string): Record<string, unknown> | undefined;
24
+ export declare function readStdinText(): string;
25
+ export declare function jsonInput(flags: Record<string, string | boolean>): Record<string, unknown> | undefined;
26
+ export declare function unknownJsonInput(flags: Record<string, string | boolean>): unknown;
27
+ export declare function schemaColumnsInput(flags: Record<string, string | boolean>, usage: string): Array<{
28
+ comment?: string;
29
+ name: string;
30
+ type: string;
31
+ }>;
32
+ export declare function textInput(flags: Record<string, string | boolean>): string | undefined;
33
+ export declare function requiredJsonInput(flags: Record<string, string | boolean>, message: string): Record<string, unknown>;
34
+ export declare function parseBooleanOption(value: string | boolean | undefined, flagName: string): boolean | undefined;
35
+ export declare function stringField(record: Record<string, unknown>, fields: string[]): string | undefined;
36
+ export declare function resultRecord(result: unknown): Record<string, unknown>;
@@ -0,0 +1,239 @@
1
+ import { createHash, } from "node:crypto";
2
+ import { readFileSync, } from "node:fs";
3
+ import { UsageError, } from "./usage.js";
4
+ export function num(v) {
5
+ if (typeof v !== "string")
6
+ return undefined;
7
+ const n = Number(v);
8
+ return Number.isFinite(n) ? n : undefined;
9
+ }
10
+ export function jobBuildTargetType(v) {
11
+ if (v === undefined)
12
+ return "DATASET";
13
+ if (typeof v !== "string") {
14
+ throw new UsageError("Invalid job target type. Use dataset or managed-folder.", "invalid_enum");
15
+ }
16
+ const normalized = v.trim().toUpperCase().replace(/-/g, "_");
17
+ if (normalized === "DATASET" || normalized === "MANAGED_FOLDER")
18
+ return normalized;
19
+ throw new UsageError("Invalid job target type. Use dataset or managed-folder.", "invalid_enum");
20
+ }
21
+ export function jobBuildTargetTypeFromFlags(flags) {
22
+ return jobBuildTargetType(flags["target-type"] ?? flags["type"]);
23
+ }
24
+ export function maxLogLinesFromFlags(flags) {
25
+ return num(flags["max-log-lines"] ?? flags["max-lines"]);
26
+ }
27
+ export function jobLogFilterFromFlag(v) {
28
+ if (v === undefined)
29
+ return undefined;
30
+ if (typeof v !== "string") {
31
+ throw new UsageError("Invalid --log-filter value. Use stdout, stderr, user, or errors.", "invalid_enum");
32
+ }
33
+ const normalized = v.trim().toLowerCase();
34
+ if (normalized === "stdout" || normalized === "stderr" || normalized === "user"
35
+ || normalized === "errors") {
36
+ return normalized;
37
+ }
38
+ throw new UsageError("Invalid --log-filter value. Use stdout, stderr, user, or errors.", "invalid_enum");
39
+ }
40
+ export function sha256Hex(value) {
41
+ return createHash("sha256").update(value).digest("hex");
42
+ }
43
+ export function normalizeLineEndings(value) {
44
+ return value.replace(/\r\n/g, "\n");
45
+ }
46
+ export function stableJson(value) {
47
+ if (value === undefined)
48
+ return "undefined";
49
+ if (value === null || typeof value !== "object")
50
+ return JSON.stringify(value);
51
+ if (Array.isArray(value))
52
+ return `[${value.map((item) => stableJson(item)).join(",")}]`;
53
+ const entries = Object.entries(value).sort(([a,], [b,]) => a.localeCompare(b));
54
+ return `{${entries.map(([key, item,]) => `${JSON.stringify(key)}:${stableJson(item)}`).join(",")}}`;
55
+ }
56
+ export function stableHash(value) {
57
+ return sha256Hex(stableJson(value));
58
+ }
59
+ export function splitCsvFlag(v) {
60
+ if (typeof v !== "string")
61
+ return [];
62
+ return v.split(",").map((item) => item.trim()).filter((item) => item.length > 0);
63
+ }
64
+ export function recipeInputDatasetsFromFlags(flags) {
65
+ const inputs = splitCsvFlag(flags["input"]);
66
+ return inputs.length > 0 ? inputs : undefined;
67
+ }
68
+ export function rewritePairsFromFlags(flags, flagName) {
69
+ const rewrites = {};
70
+ for (const spec of splitCsvFlag(flags[flagName])) {
71
+ const idx = spec.indexOf("=");
72
+ if (idx <= 0 || idx === spec.length - 1) {
73
+ throw new UsageError(`--${flagName} values must use FROM=TO.`, "invalid_enum");
74
+ }
75
+ const from = spec.slice(0, idx).trim();
76
+ const to = spec.slice(idx + 1).trim();
77
+ if (!from || !to)
78
+ throw new UsageError(`--${flagName} values must use FROM=TO.`, "invalid_enum");
79
+ rewrites[from] = to;
80
+ }
81
+ return rewrites;
82
+ }
83
+ export function plainRecord(value) {
84
+ return value && typeof value === "object" && !Array.isArray(value)
85
+ ? value
86
+ : undefined;
87
+ }
88
+ export function requiredStringFlag(flags, name, usage) {
89
+ const value = flags[name];
90
+ if (typeof value !== "string" || value.trim().length === 0) {
91
+ throw new UsageError(`--${name} is required. Usage: ${usage}`, "missing_required_flag");
92
+ }
93
+ return value.trim();
94
+ }
95
+ export function optionalStringField(record, keys) {
96
+ for (const key of keys) {
97
+ const value = record[key];
98
+ if (typeof value === "string" && value.trim().length > 0)
99
+ return value.trim();
100
+ }
101
+ return undefined;
102
+ }
103
+ export function requiredStringArray(value, source) {
104
+ if (!Array.isArray(value)) {
105
+ throw new UsageError(`${source} must be an array of strings.`, "validation_failed");
106
+ }
107
+ return value.map((item, index) => {
108
+ if (typeof item !== "string" || item.trim().length === 0) {
109
+ throw new UsageError(`${source}[${index}] must be a non-empty string.`, "validation_failed");
110
+ }
111
+ return item.trim();
112
+ });
113
+ }
114
+ export function finiteNumberField(record, key, source) {
115
+ const value = record[key];
116
+ if (typeof value !== "number" || !Number.isFinite(value)) {
117
+ throw new UsageError(`${source}.${key} must be a finite number.`, "validation_failed");
118
+ }
119
+ return value;
120
+ }
121
+ export function stripUtf8Bom(text) {
122
+ return text.charCodeAt(0) === 0xfeff ? text.slice(1) : text;
123
+ }
124
+ export function parseJsonValue(text, source) {
125
+ try {
126
+ return JSON.parse(stripUtf8Bom(text));
127
+ }
128
+ catch (error) {
129
+ const message = error instanceof Error ? error.message : String(error);
130
+ throw new UsageError(`Invalid JSON in ${source}: ${message}`, "validation_failed");
131
+ }
132
+ }
133
+ export function expectJsonObject(value, source) {
134
+ if (value && typeof value === "object" && !Array.isArray(value)) {
135
+ return value;
136
+ }
137
+ throw new UsageError(`Expected JSON object in ${source}.`, "validation_failed");
138
+ }
139
+ export function parseJsonObject(text, source) {
140
+ return expectJsonObject(parseJsonValue(text, source), source);
141
+ }
142
+ export function json(v, source = "JSON flag") {
143
+ if (typeof v !== "string")
144
+ return undefined;
145
+ return parseJsonObject(v, source);
146
+ }
147
+ export function readStdinText() {
148
+ return readFileSync(0, "utf-8");
149
+ }
150
+ export function jsonInput(flags) {
151
+ if (flags["stdin"] === true)
152
+ return parseJsonObject(readStdinText(), "stdin");
153
+ if (typeof flags["data-file"] === "string") {
154
+ return parseJsonObject(readFileSync(flags["data-file"], "utf-8"), flags["data-file"]);
155
+ }
156
+ if (typeof flags["data"] === "string")
157
+ return parseJsonObject(flags["data"], "--data");
158
+ return undefined;
159
+ }
160
+ export function unknownJsonInput(flags) {
161
+ if (flags["stdin"] === true)
162
+ return parseJsonValue(readStdinText(), "stdin");
163
+ if (typeof flags["data-file"] === "string") {
164
+ return parseJsonValue(readFileSync(flags["data-file"], "utf-8"), flags["data-file"]);
165
+ }
166
+ if (typeof flags["data"] === "string")
167
+ return parseJsonValue(flags["data"], "--data");
168
+ return undefined;
169
+ }
170
+ export function schemaColumnsInput(flags, usage) {
171
+ const input = unknownJsonInput(flags);
172
+ if (input === undefined) {
173
+ throw new UsageError(`--data, --data-file, or --stdin is required. Usage: ${usage}`);
174
+ }
175
+ const columns = Array.isArray(input)
176
+ ? input
177
+ : input && typeof input === "object" && Array.isArray(input.columns)
178
+ ? input.columns
179
+ : undefined;
180
+ if (!columns) {
181
+ throw new UsageError("Schema input must be an array of columns or an object with a columns array.");
182
+ }
183
+ return columns.map((column, index) => {
184
+ if (!column || typeof column !== "object" || Array.isArray(column)) {
185
+ throw new UsageError(`Schema column at index ${index} must be an object.`);
186
+ }
187
+ const record = column;
188
+ if (typeof record.name !== "string" || record.name.length === 0) {
189
+ throw new UsageError(`Schema column at index ${index} is missing string field "name".`);
190
+ }
191
+ if (typeof record.type !== "string" || record.type.length === 0) {
192
+ throw new UsageError(`Schema column "${record.name}" is missing string field "type".`);
193
+ }
194
+ return {
195
+ ...record,
196
+ name: record.name,
197
+ type: record.type,
198
+ ...(typeof record.comment === "string" ? { comment: record.comment, } : {}),
199
+ };
200
+ });
201
+ }
202
+ export function textInput(flags) {
203
+ if (typeof flags["content"] === "string")
204
+ return flags["content"];
205
+ if (typeof flags["file"] === "string")
206
+ return readFileSync(flags["file"], "utf-8");
207
+ return undefined;
208
+ }
209
+ export function requiredJsonInput(flags, message) {
210
+ const data = jsonInput(flags);
211
+ if (data === undefined)
212
+ throw new UsageError(message);
213
+ return data;
214
+ }
215
+ export function parseBooleanOption(value, flagName) {
216
+ if (value === undefined)
217
+ return undefined;
218
+ if (typeof value === "boolean")
219
+ return value;
220
+ const normalized = value.trim().toLowerCase();
221
+ if (["1", "true", "yes", "y", "on",].includes(normalized))
222
+ return true;
223
+ if (["0", "false", "no", "n", "off",].includes(normalized))
224
+ return false;
225
+ throw new UsageError(`${flagName} must be true or false.`, "invalid_enum");
226
+ }
227
+ export function stringField(record, fields) {
228
+ for (const field of fields) {
229
+ const value = record[field];
230
+ if (typeof value === "string" && value.length > 0)
231
+ return value;
232
+ }
233
+ return undefined;
234
+ }
235
+ export function resultRecord(result) {
236
+ return result !== null && typeof result === "object" && !Array.isArray(result)
237
+ ? result
238
+ : {};
239
+ }
@@ -0,0 +1,2 @@
1
+ import type { CommandMeta } from "../types.js";
2
+ export declare const analysisCommands: Record<string, CommandMeta>;
@@ -0,0 +1,66 @@
1
+ import { requiredStringFlag, } from "../coerce.js";
2
+ import { readIfExists, skipResult, } from "../output.js";
3
+ import { requireArgs, } from "../usage.js";
4
+ export const analysisCommands = {
5
+ list: {
6
+ handler: (c, _a, f) => c.analyses.list(f["project-key"]),
7
+ usage: "dss analysis list [--project-key KEY]",
8
+ description: "List Visual ML analyses in a project.",
9
+ examples: ["dss analysis list --project-key PROJECT",],
10
+ },
11
+ get: {
12
+ handler: (c, a, f) => {
13
+ requireArgs(a, 1, "dss analysis get <analysisId> [--project-key KEY]");
14
+ return c.analyses.get(a[0], f["project-key"]);
15
+ },
16
+ usage: "dss analysis get <analysisId> [--project-key KEY]",
17
+ description: "Get a Visual ML analysis.",
18
+ examples: ["dss analysis get ANALYSIS_ID --project-key PROJECT",],
19
+ },
20
+ create: {
21
+ handler: async (c, _a, f) => {
22
+ const usage = "dss analysis create --input-dataset DS [--dry-run] [--project-key KEY]";
23
+ const inputDataset = requiredStringFlag(f, "input-dataset", usage);
24
+ const projectKey = f["project-key"];
25
+ const options = { inputDataset, projectKey, };
26
+ if (f["dry-run"] === true) {
27
+ return {
28
+ dryRun: true,
29
+ action: "create",
30
+ resource: "analysis",
31
+ payload: options,
32
+ };
33
+ }
34
+ const created = await c.analyses.create(options);
35
+ return { created: created.id, resource: "analysis", ...created, };
36
+ },
37
+ usage: "dss analysis create --input-dataset DS [--dry-run] [--project-key KEY]",
38
+ description: "Create a Visual ML analysis for an input dataset.",
39
+ examples: [
40
+ "dss analysis create --input-dataset customers --project-key PROJECT",
41
+ "dss analysis create --input-dataset customers --dry-run --project-key PROJECT",
42
+ ],
43
+ },
44
+ delete: {
45
+ handler: async (c, a, f) => {
46
+ requireArgs(a, 1, "dss analysis delete <analysisId> [--if-exists] [--dry-run] [--project-key KEY]");
47
+ const projectKey = f["project-key"];
48
+ if (f["dry-run"] === true || f["if-exists"] === true) {
49
+ const current = await readIfExists(() => c.analyses.get(a[0], projectKey));
50
+ if (!current)
51
+ return skipResult("analysis", a[0], "missing");
52
+ if (f["dry-run"] === true) {
53
+ return { dryRun: true, action: "delete", resource: "analysis", id: a[0], current, };
54
+ }
55
+ }
56
+ await c.analyses.delete(a[0], projectKey);
57
+ return { deleted: a[0], resource: "analysis", };
58
+ },
59
+ usage: "dss analysis delete <analysisId> [--if-exists] [--dry-run] [--project-key KEY]",
60
+ description: "Delete a Visual ML analysis.",
61
+ examples: [
62
+ "dss analysis delete ANALYSIS_ID --if-exists --project-key PROJECT",
63
+ "dss analysis delete ANALYSIS_ID --dry-run --project-key PROJECT",
64
+ ],
65
+ },
66
+ };
@@ -0,0 +1,2 @@
1
+ import type { CommandMeta } from "../types.js";
2
+ export declare const apiDeployerCommands: Record<string, CommandMeta>;
@@ -0,0 +1,170 @@
1
+ import { requiredJsonInput, } from "../coerce.js";
2
+ import { requireArgs, } from "../usage.js";
3
+ export const apiDeployerCommands = {
4
+ "list-infras": {
5
+ handler: (c) => c.apiDeployer.listInfras(),
6
+ usage: "dss api-deployer list-infras",
7
+ description: "List API Deployer infrastructures.",
8
+ examples: ["dss api-deployer list-infras",],
9
+ },
10
+ "create-infra": {
11
+ handler: (c, _a, f) => {
12
+ const body = requiredJsonInput(f, "--data, --data-file, or --stdin is required (infra settings).");
13
+ return c.apiDeployer.createInfra(body);
14
+ },
15
+ usage: "dss api-deployer create-infra (--data JSON|--data-file PATH|--stdin)",
16
+ description: "Create an API Deployer infrastructure.",
17
+ examples: ["dss api-deployer create-infra --data-file infra.json",],
18
+ },
19
+ "get-infra": {
20
+ handler: (c, a) => {
21
+ requireArgs(a, 1, "dss api-deployer get-infra <infraId>");
22
+ return c.apiDeployer.getInfra(a[0]);
23
+ },
24
+ usage: "dss api-deployer get-infra <infraId>",
25
+ description: "Get an API Deployer infrastructure status.",
26
+ examples: ["dss api-deployer get-infra prod-infra",],
27
+ },
28
+ "delete-infra": {
29
+ handler: async (c, a) => {
30
+ requireArgs(a, 1, "dss api-deployer delete-infra <infraId>");
31
+ await c.apiDeployer.deleteInfra(a[0]);
32
+ return { deleted: true, };
33
+ },
34
+ usage: "dss api-deployer delete-infra <infraId>",
35
+ description: "Delete an API Deployer infrastructure.",
36
+ examples: ["dss api-deployer delete-infra prod-infra",],
37
+ },
38
+ "list-stages": {
39
+ handler: (c) => c.apiDeployer.listStages(),
40
+ usage: "dss api-deployer list-stages",
41
+ description: "List API Deployer lifecycle stages.",
42
+ examples: ["dss api-deployer list-stages",],
43
+ },
44
+ "list-services": {
45
+ handler: (c) => c.apiDeployer.listServices(),
46
+ usage: "dss api-deployer list-services",
47
+ description: "List published API Deployer services.",
48
+ examples: ["dss api-deployer list-services",],
49
+ },
50
+ "create-service": {
51
+ handler: (c, _a, f) => {
52
+ const body = requiredJsonInput(f, "--data, --data-file, or --stdin is required (service definition).");
53
+ return c.apiDeployer.createService(body);
54
+ },
55
+ usage: "dss api-deployer create-service (--data JSON|--data-file PATH|--stdin)",
56
+ description: "Create a published API Deployer service.",
57
+ examples: ['dss api-deployer create-service --data \'{"id":"my-service"}\'',],
58
+ },
59
+ "get-service": {
60
+ handler: (c, a) => {
61
+ requireArgs(a, 1, "dss api-deployer get-service <serviceId>");
62
+ return c.apiDeployer.getService(a[0]);
63
+ },
64
+ usage: "dss api-deployer get-service <serviceId>",
65
+ description: "Get a published service's status (versions + deployments).",
66
+ examples: ["dss api-deployer get-service my-service",],
67
+ },
68
+ "delete-service": {
69
+ handler: async (c, a) => {
70
+ requireArgs(a, 1, "dss api-deployer delete-service <serviceId>");
71
+ await c.apiDeployer.deleteService(a[0]);
72
+ return { deleted: true, };
73
+ },
74
+ usage: "dss api-deployer delete-service <serviceId>",
75
+ description: "Delete a published API Deployer service.",
76
+ examples: ["dss api-deployer delete-service my-service",],
77
+ },
78
+ "publish-version": {
79
+ handler: async (c, a) => {
80
+ requireArgs(a, 2, "dss api-deployer publish-version <serviceId> <archive.zip>");
81
+ await c.apiDeployer.publishServiceVersion(a[0], a[1]);
82
+ return { published: true, };
83
+ },
84
+ usage: "dss api-deployer publish-version <serviceId> <archive.zip>",
85
+ description: "Publish (upload) a service version package to the API Deployer.",
86
+ examples: ["dss api-deployer publish-version my-service ./pkg.zip",],
87
+ },
88
+ "delete-version": {
89
+ handler: async (c, a) => {
90
+ requireArgs(a, 2, "dss api-deployer delete-version <serviceId> <version>");
91
+ await c.apiDeployer.deleteServiceVersion(a[0], a[1]);
92
+ return { deleted: true, };
93
+ },
94
+ usage: "dss api-deployer delete-version <serviceId> <version>",
95
+ description: "Delete a published service version.",
96
+ examples: ["dss api-deployer delete-version my-service v1",],
97
+ },
98
+ "list-deployments": {
99
+ handler: (c) => c.apiDeployer.listDeployments(),
100
+ usage: "dss api-deployer list-deployments",
101
+ description: "List API Deployer deployments.",
102
+ examples: ["dss api-deployer list-deployments",],
103
+ },
104
+ "create-deployment": {
105
+ handler: (c, _a, f) => {
106
+ const body = requiredJsonInput(f, "--data, --data-file, or --stdin is required (deployment settings).");
107
+ return c.apiDeployer.createDeployment(body);
108
+ },
109
+ usage: "dss api-deployer create-deployment (--data JSON|--data-file PATH|--stdin)",
110
+ description: "Create an API Deployer deployment (maps a service version to an infra).",
111
+ examples: ["dss api-deployer create-deployment --data-file deployment.json",],
112
+ },
113
+ "get-deployment": {
114
+ handler: (c, a) => {
115
+ requireArgs(a, 1, "dss api-deployer get-deployment <deploymentId>");
116
+ return c.apiDeployer.getDeployment(a[0]);
117
+ },
118
+ usage: "dss api-deployer get-deployment <deploymentId>",
119
+ description: "Get an API Deployer deployment.",
120
+ examples: ["dss api-deployer get-deployment my-deployment",],
121
+ },
122
+ "deployment-status": {
123
+ handler: (c, a) => {
124
+ requireArgs(a, 1, "dss api-deployer deployment-status <deploymentId>");
125
+ return c.apiDeployer.getDeploymentStatus(a[0]);
126
+ },
127
+ usage: "dss api-deployer deployment-status <deploymentId>",
128
+ description: "Get an API Deployer deployment's full health/status.",
129
+ examples: ["dss api-deployer deployment-status my-deployment",],
130
+ },
131
+ "deployment-settings": {
132
+ handler: (c, a) => {
133
+ requireArgs(a, 1, "dss api-deployer deployment-settings <deploymentId>");
134
+ return c.apiDeployer.getDeploymentSettings(a[0]);
135
+ },
136
+ usage: "dss api-deployer deployment-settings <deploymentId>",
137
+ description: "Get an API Deployer deployment's settings.",
138
+ examples: ["dss api-deployer deployment-settings my-deployment",],
139
+ },
140
+ "save-deployment-settings": {
141
+ handler: async (c, a, f) => {
142
+ requireArgs(a, 1, "dss api-deployer save-deployment-settings <deploymentId> (--data JSON|--data-file PATH|--stdin)");
143
+ const body = requiredJsonInput(f, "--data, --data-file, or --stdin is required (deployment settings).");
144
+ await c.apiDeployer.saveDeploymentSettings(a[0], body);
145
+ return { saved: true, };
146
+ },
147
+ usage: "dss api-deployer save-deployment-settings <deploymentId> (--data JSON|--data-file PATH|--stdin)",
148
+ description: "Save an API Deployer deployment's settings.",
149
+ examples: ["dss api-deployer save-deployment-settings my-deployment --data-file settings.json",],
150
+ },
151
+ deploy: {
152
+ handler: (c, a) => {
153
+ requireArgs(a, 1, "dss api-deployer deploy <deploymentId>");
154
+ return c.apiDeployer.startDeploymentUpdate(a[0]);
155
+ },
156
+ usage: "dss api-deployer deploy <deploymentId>",
157
+ description: "Apply a deployment's settings to its infrastructure (start update).",
158
+ examples: ["dss api-deployer deploy my-deployment",],
159
+ },
160
+ "delete-deployment": {
161
+ handler: async (c, a) => {
162
+ requireArgs(a, 1, "dss api-deployer delete-deployment <deploymentId>");
163
+ await c.apiDeployer.deleteDeployment(a[0]);
164
+ return { deleted: true, };
165
+ },
166
+ usage: "dss api-deployer delete-deployment <deploymentId>",
167
+ description: "Delete an API Deployer deployment.",
168
+ examples: ["dss api-deployer delete-deployment my-deployment",],
169
+ },
170
+ };
@@ -0,0 +1,2 @@
1
+ import type { CommandMeta } from "../types.js";
2
+ export declare const apiServiceCommands: Record<string, CommandMeta>;