dataiku-sdk 3.0.0 → 3.2.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 (109) hide show
  1. package/README.md +246 -19
  2. package/dist/build-metadata.json +1 -1
  3. package/dist/packages/types/src/index.d.ts +39 -4
  4. package/dist/packages/types/src/index.js +31 -2
  5. package/dist/src/auth.js +1 -1
  6. package/dist/src/cli/coerce.js +11 -2
  7. package/dist/src/cli/commands/analysis.js +4 -3
  8. package/dist/src/cli/commands/api-service.js +66 -18
  9. package/dist/src/cli/commands/app.js +4 -3
  10. package/dist/src/cli/commands/bundle.js +51 -16
  11. package/dist/src/cli/commands/code-env.js +219 -57
  12. package/dist/src/cli/commands/code.d.ts +19 -0
  13. package/dist/src/cli/commands/code.js +87 -15
  14. package/dist/src/cli/commands/dashboard.js +7 -6
  15. package/dist/src/cli/commands/data-quality.js +9 -8
  16. package/dist/src/cli/commands/dataset.js +17 -11
  17. package/dist/src/cli/commands/doctor.js +4 -2
  18. package/dist/src/cli/commands/flow-zone.js +42 -13
  19. package/dist/src/cli/commands/folder.js +9 -8
  20. package/dist/src/cli/commands/future.js +2 -1
  21. package/dist/src/cli/commands/insight.js +8 -7
  22. package/dist/src/cli/commands/job.js +4 -3
  23. package/dist/src/cli/commands/meaning.js +5 -4
  24. package/dist/src/cli/commands/ml-task.js +3 -2
  25. package/dist/src/cli/commands/model-evaluation-store.js +4 -3
  26. package/dist/src/cli/commands/notebook.js +82 -50
  27. package/dist/src/cli/commands/project-git.js +8 -5
  28. package/dist/src/cli/commands/project-library.d.ts +21 -0
  29. package/dist/src/cli/commands/project-library.js +128 -56
  30. package/dist/src/cli/commands/project.js +19 -4
  31. package/dist/src/cli/commands/recipe.js +51 -25
  32. package/dist/src/cli/commands/saved-model.js +4 -3
  33. package/dist/src/cli/commands/scenario.js +9 -8
  34. package/dist/src/cli/commands/sql.d.ts +10 -0
  35. package/dist/src/cli/commands/sql.js +42 -19
  36. package/dist/src/cli/commands/statistics.js +7 -6
  37. package/dist/src/cli/commands/variable.js +2 -1
  38. package/dist/src/cli/commands/webapp.js +68 -13
  39. package/dist/src/cli/commands/wiki.js +7 -6
  40. package/dist/src/cli/contract.d.ts +16 -1
  41. package/dist/src/cli/contract.js +967 -186
  42. package/dist/src/cli/env.d.ts +9 -0
  43. package/dist/src/cli/env.js +20 -2
  44. package/dist/src/cli/flags.d.ts +4 -0
  45. package/dist/src/cli/flags.js +29 -1
  46. package/dist/src/cli/helpers/cleanup.js +104 -3
  47. package/dist/src/cli/helpers/flow-zone.d.ts +3 -0
  48. package/dist/src/cli/helpers/flow-zone.js +33 -3
  49. package/dist/src/cli/helpers/recipe.d.ts +20 -0
  50. package/dist/src/cli/helpers/recipe.js +158 -3
  51. package/dist/src/cli/output.d.ts +2 -0
  52. package/dist/src/cli/output.js +33 -6
  53. package/dist/src/cli/runtime.d.ts +35 -1
  54. package/dist/src/cli/runtime.js +125 -18
  55. package/dist/src/cli/types.d.ts +7 -0
  56. package/dist/src/cli.js +226 -95
  57. package/dist/src/client.d.ts +63 -1
  58. package/dist/src/client.js +305 -53
  59. package/dist/src/errors.d.ts +8 -2
  60. package/dist/src/errors.js +42 -0
  61. package/dist/src/index.d.ts +4 -3
  62. package/dist/src/index.js +2 -1
  63. package/dist/src/resources/api-services.d.ts +48 -6
  64. package/dist/src/resources/api-services.js +54 -8
  65. package/dist/src/resources/bundles.d.ts +51 -6
  66. package/dist/src/resources/bundles.js +39 -9
  67. package/dist/src/resources/code-envs.d.ts +25 -3
  68. package/dist/src/resources/code-envs.js +104 -2
  69. package/dist/src/resources/datasets.d.ts +20 -0
  70. package/dist/src/resources/datasets.js +232 -52
  71. package/dist/src/resources/folders.js +2 -1
  72. package/dist/src/resources/jobs.d.ts +35 -10
  73. package/dist/src/resources/jobs.js +92 -17
  74. package/dist/src/resources/notebooks.d.ts +77 -7
  75. package/dist/src/resources/notebooks.js +143 -19
  76. package/dist/src/resources/project-git.d.ts +12 -0
  77. package/dist/src/resources/project-git.js +39 -8
  78. package/dist/src/resources/project-library.d.ts +122 -7
  79. package/dist/src/resources/project-library.js +494 -25
  80. package/dist/src/resources/projects.d.ts +5 -4
  81. package/dist/src/resources/projects.js +21 -19
  82. package/dist/src/resources/scenarios.d.ts +30 -0
  83. package/dist/src/resources/scenarios.js +73 -27
  84. package/dist/src/resources/sql.d.ts +6 -0
  85. package/dist/src/resources/sql.js +23 -3
  86. package/dist/src/resources/webapps.d.ts +35 -4
  87. package/dist/src/resources/webapps.js +54 -5
  88. package/dist/src/schemas.d.ts +2 -2
  89. package/dist/src/schemas.js +1 -1
  90. package/dist/src/skill.d.ts +18 -0
  91. package/dist/src/skill.js +93 -9
  92. package/dist/src/utils/flow-analysis.d.ts +53 -0
  93. package/dist/src/utils/flow-analysis.js +382 -0
  94. package/dist/src/utils/project-archive.d.ts +41 -2
  95. package/dist/src/utils/project-archive.js +159 -16
  96. package/dist/src/utils/response-file.d.ts +2 -0
  97. package/dist/src/utils/response-file.js +34 -0
  98. package/package.json +9 -7
  99. package/packages/types/dist/index.d.ts +39 -4
  100. package/packages/types/dist/index.js +31 -2
  101. package/plugin.json +1 -1
  102. package/skills/dataiku-dss/SKILL.md +44 -197
  103. package/skills/dataiku-dss/references/app-releases.md +27 -0
  104. package/skills/dataiku-dss/references/authentication.md +39 -0
  105. package/skills/dataiku-dss/references/coding.md +8 -0
  106. package/skills/dataiku-dss/references/discovery.md +30 -0
  107. package/skills/dataiku-dss/references/flow-maps.md +12 -0
  108. package/skills/dataiku-dss/references/mutations.md +33 -0
  109. package/skills/dataiku-dss/references/troubleshooting.md +29 -0
@@ -1,5 +1,17 @@
1
+ import { ClientValidationError, } from "../../errors.js";
2
+ import { writeResponseToFile, } from "../../utils/response-file.js";
3
+ import { stableHash, } from "../../utils/stable-hash.js";
1
4
  import { requiredJsonInput, } from "../coerce.js";
5
+ import { executionMode, } from "../flags.js";
2
6
  import { requireArgs, UsageError, } from "../usage.js";
7
+ function validateExpectHash(value) {
8
+ if (value === undefined || value === false)
9
+ return undefined;
10
+ if (typeof value !== "string" || !/^[0-9a-fA-F]{64}$/.test(value)) {
11
+ throw new ClientValidationError("Expected API service settings hash must be a 64-character SHA-256 hex digest.", "validation_failed", "Run this update with --dry-run and capture currentHash before retrying.");
12
+ }
13
+ return value;
14
+ }
3
15
  export const apiServiceCommands = {
4
16
  list: {
5
17
  handler: (c, _a, f) => c.apiServices.list(f["project-key"]),
@@ -26,14 +38,42 @@ export const apiServiceCommands = {
26
38
  examples: ["dss api-service get-settings my-service",],
27
39
  },
28
40
  "save-settings": {
29
- handler: (c, a, f) => {
30
- requireArgs(a, 1, "dss api-service save-settings <serviceId> (--data JSON|--data-file PATH|--stdin) [--project-key KEY]");
41
+ handler: async (c, a, f) => {
42
+ const usage = "dss api-service save-settings <serviceId> (--data JSON|--data-file PATH|--stdin) [--expect-hash SHA256] [--dry-run] [--project-key KEY]";
43
+ requireArgs(a, 1, usage);
31
44
  const body = requiredJsonInput(f, "--data, --data-file, or --stdin is required (service settings).");
32
- return c.apiServices.saveSettings(a[0], body, f["project-key"]);
45
+ const projectKey = f["project-key"];
46
+ const expectHash = validateExpectHash(f["expect-hash"]);
47
+ if (executionMode(f).dryRun) {
48
+ const current = await c.apiServices.getSettings(a[0], projectKey);
49
+ const currentHash = stableHash(current);
50
+ if (expectHash !== undefined && currentHash !== expectHash.toLowerCase()) {
51
+ throw new ClientValidationError(`The API service ${JSON.stringify(a[0])} changed since it was read.`, "validation_failed", "Re-read the service settings and retry with the current hash value.", {
52
+ serviceId: a[0],
53
+ expectedHash: expectHash.toLowerCase(),
54
+ actualHash: currentHash,
55
+ });
56
+ }
57
+ return {
58
+ dryRun: true,
59
+ action: "save-settings",
60
+ resource: "api-service",
61
+ serviceId: a[0],
62
+ current,
63
+ next: body,
64
+ currentHash,
65
+ nextHash: stableHash(body),
66
+ ...(expectHash !== undefined
67
+ ? { expectHash: expectHash.toLowerCase(), provenanceVerified: true, }
68
+ : {}),
69
+ };
70
+ }
71
+ const saved = await c.apiServices.saveSettings(a[0], body, projectKey, { expectHash, });
72
+ return { saved: a[0], ...saved, };
33
73
  },
34
- usage: "dss api-service save-settings <serviceId> (--data JSON|--data-file PATH|--stdin) [--project-key KEY]",
35
- description: "Save an API service's settings.",
36
- examples: ["dss api-service save-settings my-service --data-file service.json",],
74
+ usage: "dss api-service save-settings <serviceId> (--data JSON|--data-file PATH|--stdin) [--expect-hash SHA256] [--dry-run] [--project-key KEY]",
75
+ description: "Replace an API service's settings wholesale (explicit replacement: the supplied object is PUT as-is, so fetch get-settings first). --expect-hash refuses the write when the stored settings changed since they were fetched; --dry-run reports current, next, and both hashes without writing.",
76
+ examples: ["dss api-service save-settings my-service --data-file service.json --dry-run",],
37
77
  },
38
78
  "add-prediction-endpoint": {
39
79
  handler: async (c, a, f) => {
@@ -43,7 +83,7 @@ export const apiServiceCommands = {
43
83
  type: "STD_PREDICTION",
44
84
  modelRef: a[2],
45
85
  };
46
- if (f["dry-run"] === true)
86
+ if (executionMode(f).dryRun)
47
87
  return endpoint;
48
88
  return c.apiServices.addPredictionEndpoint(a[0], a[1], a[2], f["project-key"]);
49
89
  },
@@ -75,12 +115,15 @@ export const apiServiceCommands = {
75
115
  },
76
116
  "create-package": {
77
117
  handler: (c, a, f) => {
78
- requireArgs(a, 2, "dss api-service create-package <serviceId> <packageId> [--project-key KEY]");
79
- return c.apiServices.createPackage(a[0], a[1], f["project-key"]);
118
+ requireArgs(a, 2, "dss api-service create-package <serviceId> <packageId> [--release-notes TEXT] [--project-key KEY]");
119
+ return c.apiServices.createPackage(a[0], a[1], f["project-key"], typeof f["release-notes"] === "string" ? { releaseNotes: f["release-notes"], } : {});
80
120
  },
81
- usage: "dss api-service create-package <serviceId> <packageId> [--project-key KEY]",
82
- description: "Build a deployable package from the current service state.",
83
- examples: ["dss api-service create-package my-service v1",],
121
+ usage: "dss api-service create-package <serviceId> <packageId> [--release-notes TEXT] [--project-key KEY]",
122
+ description: "Build a deployable package from the current service state; --release-notes forwards the documented releaseNotes query parameter.",
123
+ examples: [
124
+ "dss api-service create-package my-service v1",
125
+ "dss api-service create-package my-service v1 --release-notes='Adds churn endpoint'",
126
+ ],
84
127
  },
85
128
  "delete-package": {
86
129
  handler: async (c, a, f) => {
@@ -102,7 +145,7 @@ export const apiServiceCommands = {
102
145
  if (!res.body) {
103
146
  throw new Error("apiServices.downloadPackageArchive response did not include a body");
104
147
  }
105
- const bytes = await Bun.write(out, new Response(res.body), { createPath: false, });
148
+ const bytes = await writeResponseToFile(out, res);
106
149
  return { path: out, bytes, };
107
150
  },
108
151
  usage: "dss api-service download-package <serviceId> <packageId> --output PATH [--project-key KEY]",
@@ -111,11 +154,16 @@ export const apiServiceCommands = {
111
154
  },
112
155
  "publish-package": {
113
156
  handler: (c, a, f) => {
114
- requireArgs(a, 2, "dss api-service publish-package <serviceId> <packageId> [--project-key KEY]");
115
- return c.apiServices.publishPackage(a[0], a[1], f["project-key"]);
157
+ requireArgs(a, 2, "dss api-service publish-package <serviceId> <packageId> [--published-service-id ID] [--project-key KEY]");
158
+ return c.apiServices.publishPackage(a[0], a[1], f["project-key"], typeof f["published-service-id"] === "string"
159
+ ? { publishedServiceId: f["published-service-id"], }
160
+ : {});
116
161
  },
117
- usage: "dss api-service publish-package <serviceId> <packageId> [--project-key KEY]",
118
- description: "Publish a package to the API Deployer.",
119
- examples: ["dss api-service publish-package my-service v1",],
162
+ usage: "dss api-service publish-package <serviceId> <packageId> [--published-service-id ID] [--project-key KEY]",
163
+ description: "Publish a package to the API Deployer; --published-service-id forwards the documented publishedServiceId query parameter (a new published service is created when no match exists; the service's own id is the server-side default).",
164
+ examples: [
165
+ "dss api-service publish-package my-service v1",
166
+ "dss api-service publish-package my-service v1 --published-service-id=prod-churn",
167
+ ],
120
168
  },
121
169
  };
@@ -1,6 +1,7 @@
1
1
  import { ClientValidationError, DataikuError, } from "../../errors.js";
2
2
  import { projectIncarnationHash, } from "../../utils/project-incarnation.js";
3
3
  import { jsonInput, num, parseBooleanOption, plainRecord, requiredJsonInput, requiredStringFlag, stringField, } from "../coerce.js";
4
+ import { executionMode, } from "../flags.js";
4
5
  import { appPermissionsHash, appPermissionsVerificationError, assertAppPermissionsSnapshotBinding, buildAppPermissionsSnapshot, diffAppPermissions, readAppPermissionsSnapshot, writeAppPermissionsSnapshot, } from "../helpers/app-permissions.js";
5
6
  import { createSuccessorInstance, futureTargetIdentity, isDefinitiveRejection, preflightSuccessorInstance, requireAbsentProjectTarget, safeErrorSummary, verifyAppInstance, VISUAL_UI_GATE, } from "../helpers/app-successor.js";
6
7
  import { CommandResultFailure, } from "../output.js";
@@ -385,7 +386,7 @@ export const appCommands = {
385
386
  to: requiredStringFlag(f, "to", CREATE_SUCCESSOR_USAGE),
386
387
  ...(f["name"] !== undefined ? { name: f["name"], } : {}),
387
388
  copyPermissions: parseBooleanOption(f["copy-permissions"], "--copy-permissions") ?? false,
388
- dryRun: parseBooleanOption(f["dry-run"], "--dry-run") ?? false,
389
+ dryRun: executionMode(f).dryRun,
389
390
  timeoutMs: num(f["timeout"], "--timeout"),
390
391
  pollIntervalMs: num(f["poll-interval"], "--poll-interval"),
391
392
  }, CREATE_SUCCESSOR_USAGE);
@@ -445,7 +446,7 @@ export const appCommands = {
445
446
  ...(version !== undefined ? { version, } : {}),
446
447
  ...(versionNotes !== undefined ? { versionNotes, } : {}),
447
448
  ...(f["expect-hash"] !== undefined ? { expectHash: f["expect-hash"], } : {}),
448
- dryRun: parseBooleanOption(f["dry-run"], "--dry-run") ?? false,
449
+ dryRun: executionMode(f).dryRun,
449
450
  }, f["project-key"]);
450
451
  if (result.outcome === "indeterminate") {
451
452
  // The PUT may or may not have landed. Fail nonzero without
@@ -756,7 +757,7 @@ export const appCommands = {
756
757
  assertAppPermissionsSnapshotBinding(snapshot, projectKey, c.getBaseUrl());
757
758
  const currentProjectIncarnationHash = await requireProjectIncarnationHash(c, projectKey);
758
759
  assertAppPermissionsSnapshotBinding(snapshot, projectKey, c.getBaseUrl(), currentProjectIncarnationHash);
759
- const dryRun = parseBooleanOption(f["dry-run"], "--dry-run") ?? false;
760
+ const dryRun = executionMode(f).dryRun;
760
761
  const before = await c.projects.getPermissions(projectKey);
761
762
  await assertProjectIncarnationHash(c, projectKey, snapshot.projectIncarnationHash);
762
763
  const beforeHash = appPermissionsHash(before);
@@ -1,3 +1,5 @@
1
+ import { writeResponseToFile, } from "../../utils/response-file.js";
2
+ import { json, parseBooleanOption, } from "../coerce.js";
1
3
  import { requireArgs, UsageError, } from "../usage.js";
2
4
  export const bundleCommands = {
3
5
  "list-exported": {
@@ -8,13 +10,24 @@ export const bundleCommands = {
8
10
  },
9
11
  export: {
10
12
  handler: async (c, a, f) => {
11
- requireArgs(a, 1, "dss bundle export <bundleId> [--project-key KEY]");
12
- await c.bundles.exportBundle(a[0], f["project-key"]);
13
+ const usage = "dss bundle export <bundleId> [--release-notes TEXT] [--evaluate-standards-checks true|false] [--project-key KEY]";
14
+ requireArgs(a, 1, usage);
15
+ await c.bundles.exportBundle(a[0], f["project-key"], {
16
+ ...(typeof f["release-notes"] === "string" ? { releaseNotes: f["release-notes"], } : {}),
17
+ ...(f["evaluate-standards-checks"] !== undefined
18
+ ? {
19
+ evaluateProjectStandardsChecks: parseBooleanOption(f["evaluate-standards-checks"], "--evaluate-standards-checks") ?? true,
20
+ }
21
+ : {}),
22
+ });
13
23
  return { exported: a[0], };
14
24
  },
15
- usage: "dss bundle export <bundleId> [--project-key KEY]",
16
- description: "Create (or overwrite) an exported Design-node bundle.",
17
- examples: ["dss bundle export v1",],
25
+ usage: "dss bundle export <bundleId> [--release-notes TEXT] [--evaluate-standards-checks true|false] [--project-key KEY]",
26
+ description: "Create (or overwrite) an exported Design-node bundle. --release-notes forwards the documented releaseNotes parameter; --evaluate-standards-checks toggles the documented Project Standards Checks evaluation (default true).",
27
+ examples: [
28
+ "dss bundle export v1",
29
+ "dss bundle export v1 --release-notes='Adds churn model' --evaluate-standards-checks=false",
30
+ ],
18
31
  },
19
32
  "delete-exported": {
20
33
  handler: async (c, a, f) => {
@@ -36,7 +49,7 @@ export const bundleCommands = {
36
49
  if (!res.body) {
37
50
  throw new Error("bundles.downloadExportedArchive response did not include a body");
38
51
  }
39
- const bytes = await Bun.write(out, new Response(res.body), { createPath: false, });
52
+ const bytes = await writeResponseToFile(out, res);
40
53
  return { path: out, bytes, };
41
54
  },
42
55
  usage: "dss bundle download-exported <bundleId> --output PATH [--project-key KEY]",
@@ -45,12 +58,18 @@ export const bundleCommands = {
45
58
  },
46
59
  publish: {
47
60
  handler: (c, a, f) => {
48
- requireArgs(a, 1, "dss bundle publish <bundleId> [--project-key KEY]");
49
- return c.bundles.publish(a[0], f["project-key"]);
61
+ const usage = "dss bundle publish <bundleId> [--published-project-key KEY] [--project-key KEY]";
62
+ requireArgs(a, 1, usage);
63
+ return c.bundles.publish(a[0], f["project-key"], typeof f["published-project-key"] === "string"
64
+ ? { publishedProjectKey: f["published-project-key"], }
65
+ : {});
50
66
  },
51
- usage: "dss bundle publish <bundleId> [--project-key KEY]",
52
- description: "Publish a Design-node bundle to the Project Deployer.",
53
- examples: ["dss bundle publish v1",],
67
+ usage: "dss bundle publish <bundleId> [--published-project-key KEY] [--project-key KEY]",
68
+ description: "Publish a Design-node bundle to the Project Deployer; --published-project-key forwards the documented publishedProjectKey query parameter (a new published project is created when no match exists; the source project's key is the server-side default).",
69
+ examples: [
70
+ "dss bundle publish v1",
71
+ "dss bundle publish v1 --published-project-key=PROD-CHURN",
72
+ ],
54
73
  },
55
74
  "list-imported": {
56
75
  handler: (c, _a, f) => c.bundles.listImported(f["project-key"]),
@@ -79,12 +98,28 @@ export const bundleCommands = {
79
98
  },
80
99
  activate: {
81
100
  handler: (c, a, f) => {
82
- requireArgs(a, 1, "dss bundle activate <bundleId> [--project-key KEY]");
83
- return c.bundles.activate(a[0], f["project-key"]);
101
+ const usage = "dss bundle activate <bundleId> [--scenarios JSON] [--project-key KEY]";
102
+ requireArgs(a, 1, usage);
103
+ const rawScenarios = f["scenarios"];
104
+ let scenariosToEnable;
105
+ if (rawScenarios !== undefined && rawScenarios !== false) {
106
+ const parsed = json(rawScenarios);
107
+ if (typeof parsed !== "object"
108
+ || parsed === null
109
+ || Array.isArray(parsed)
110
+ || !Object.values(parsed).every((value) => typeof value === "boolean")) {
111
+ throw new UsageError("--scenarios must be a JSON object mapping scenario IDs to true|false. Usage: dss bundle activate <bundleId> --scenarios '{\"daily_build\":true}'");
112
+ }
113
+ scenariosToEnable = parsed;
114
+ }
115
+ return c.bundles.activate(a[0], f["project-key"], scenariosToEnable !== undefined ? { scenariosToEnable, } : {});
84
116
  },
85
- usage: "dss bundle activate <bundleId> [--project-key KEY]",
86
- description: "Activate an imported Automation-node bundle.",
87
- examples: ["dss bundle activate v1",],
117
+ usage: "dss bundle activate <bundleId> [--scenarios JSON] [--project-key KEY]",
118
+ description: "Activate an imported Automation-node bundle; --scenarios forwards the documented scenario-ID-to-enabled dict as the scenariosActiveOnActivation body.",
119
+ examples: [
120
+ "dss bundle activate v1",
121
+ 'dss bundle activate v1 --scenarios=\'{"daily_build":true,"hourly_retrain":false}\'',
122
+ ],
88
123
  },
89
124
  preload: {
90
125
  handler: (c, a, f) => {