dataiku-sdk 0.12.4 → 0.12.6

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 (86) hide show
  1. package/README.md +119 -7
  2. package/dist/packages/types/src/index.d.ts +5 -0
  3. package/dist/packages/types/src/index.js +5 -0
  4. package/dist/src/cli/coerce.d.ts +1 -3
  5. package/dist/src/cli/coerce.js +1 -17
  6. package/dist/src/cli/commands/app.js +709 -14
  7. package/dist/src/cli/commands/code-env.js +2 -2
  8. package/dist/src/cli/commands/dashboard.js +1 -1
  9. package/dist/src/cli/commands/dataset.js +2 -2
  10. package/dist/src/cli/commands/folder.js +1 -1
  11. package/dist/src/cli/commands/insight.js +2 -2
  12. package/dist/src/cli/commands/notebook.js +2 -2
  13. package/dist/src/cli/commands/recipe.js +3 -3
  14. package/dist/src/cli/commands/scenario.js +1 -1
  15. package/dist/src/cli/commands/sql.js +17 -2
  16. package/dist/src/cli/commands/variable.js +1 -1
  17. package/dist/src/cli/commands/wiki.js +1 -1
  18. package/dist/src/cli/contract.d.ts +12 -3
  19. package/dist/src/cli/contract.js +805 -49
  20. package/dist/src/cli/flags.js +9 -0
  21. package/dist/src/cli/helpers/app-permissions.d.ts +63 -0
  22. package/dist/src/cli/helpers/app-permissions.js +239 -0
  23. package/dist/src/cli/helpers/app-successor.d.ts +106 -0
  24. package/dist/src/cli/helpers/app-successor.js +625 -0
  25. package/dist/src/cli/helpers/cleanup.js +46 -12
  26. package/dist/src/cli/output.d.ts +12 -1
  27. package/dist/src/cli/output.js +53 -6
  28. package/dist/src/cli/usage.d.ts +1 -1
  29. package/dist/src/cli/usage.js +5 -2
  30. package/dist/src/cli.js +329 -32
  31. package/dist/src/client.d.ts +13 -1
  32. package/dist/src/client.js +46 -6
  33. package/dist/src/errors.d.ts +1 -1
  34. package/dist/src/resources/applications.d.ts +191 -1
  35. package/dist/src/resources/applications.js +549 -10
  36. package/dist/src/resources/datasets.js +8 -0
  37. package/dist/src/resources/futures.js +7 -2
  38. package/dist/src/resources/sql.d.ts +5 -0
  39. package/dist/src/resources/sql.js +5 -4
  40. package/dist/src/skill.js +78 -19
  41. package/dist/src/utils/cleanup-ledger.d.ts +34 -1
  42. package/dist/src/utils/cleanup-ledger.js +118 -7
  43. package/dist/src/utils/dss-url.d.ts +6 -0
  44. package/dist/src/utils/dss-url.js +17 -0
  45. package/dist/src/utils/project-incarnation.d.ts +6 -0
  46. package/dist/src/utils/project-incarnation.js +27 -0
  47. package/dist/src/utils/stable-hash.d.ts +11 -0
  48. package/dist/src/utils/stable-hash.js +27 -0
  49. package/node_modules/@sinclair/typebox/build/cjs/compiler/compiler.js +26 -46
  50. package/node_modules/@sinclair/typebox/build/cjs/parser/runtime/guard.d.ts +1 -1
  51. package/node_modules/@sinclair/typebox/build/cjs/parser/runtime/token.d.ts +2 -2
  52. package/node_modules/@sinclair/typebox/build/cjs/syntax/mapping.d.ts +1 -1
  53. package/node_modules/@sinclair/typebox/build/cjs/system/evaluate.d.ts +5 -0
  54. package/node_modules/@sinclair/typebox/build/cjs/system/evaluate.js +11 -0
  55. package/node_modules/@sinclair/typebox/build/cjs/system/index.d.ts +1 -0
  56. package/node_modules/@sinclair/typebox/build/cjs/system/index.js +1 -0
  57. package/node_modules/@sinclair/typebox/build/cjs/type/object/object.d.ts +2 -2
  58. package/node_modules/@sinclair/typebox/build/cjs/type/object/object.js +18 -2
  59. package/node_modules/@sinclair/typebox/build/cjs/value/parse/parse.d.ts +1 -1
  60. package/node_modules/@sinclair/typebox/build/esm/compiler/compiler.mjs +27 -47
  61. package/node_modules/@sinclair/typebox/build/esm/parser/runtime/guard.d.mts +1 -1
  62. package/node_modules/@sinclair/typebox/build/esm/parser/runtime/token.d.mts +2 -2
  63. package/node_modules/@sinclair/typebox/build/esm/syntax/mapping.d.mts +1 -1
  64. package/node_modules/@sinclair/typebox/build/esm/system/evaluate.d.mts +5 -0
  65. package/node_modules/@sinclair/typebox/build/esm/system/evaluate.mjs +7 -0
  66. package/node_modules/@sinclair/typebox/build/esm/system/index.d.mts +1 -0
  67. package/node_modules/@sinclair/typebox/build/esm/system/index.mjs +1 -0
  68. package/node_modules/@sinclair/typebox/build/esm/type/composite/composite.mjs +2 -2
  69. package/node_modules/@sinclair/typebox/build/esm/type/const/const.mjs +3 -3
  70. package/node_modules/@sinclair/typebox/build/esm/type/instantiate/instantiate.mjs +2 -2
  71. package/node_modules/@sinclair/typebox/build/esm/type/mapped/mapped.mjs +3 -3
  72. package/node_modules/@sinclair/typebox/build/esm/type/module/compute.mjs +2 -2
  73. package/node_modules/@sinclair/typebox/build/esm/type/object/object.d.mts +2 -2
  74. package/node_modules/@sinclair/typebox/build/esm/type/object/object.mjs +18 -2
  75. package/node_modules/@sinclair/typebox/build/esm/type/omit/omit.mjs +3 -3
  76. package/node_modules/@sinclair/typebox/build/esm/type/partial/partial.mjs +3 -3
  77. package/node_modules/@sinclair/typebox/build/esm/type/pick/pick.mjs +3 -3
  78. package/node_modules/@sinclair/typebox/build/esm/type/record/record.mjs +3 -3
  79. package/node_modules/@sinclair/typebox/build/esm/type/required/required.mjs +3 -3
  80. package/node_modules/@sinclair/typebox/build/esm/type/type/json.mjs +2 -2
  81. package/node_modules/@sinclair/typebox/build/esm/value/delta/delta.mjs +4 -4
  82. package/node_modules/@sinclair/typebox/build/esm/value/parse/parse.d.mts +1 -1
  83. package/node_modules/@sinclair/typebox/package.json +1 -1
  84. package/package.json +9 -5
  85. package/packages/types/dist/index.d.ts +5 -0
  86. package/packages/types/dist/index.js +5 -0
package/README.md CHANGED
@@ -23,23 +23,29 @@ Bun is the primary development runtime and package manager. Examples below assum
23
23
 
24
24
  ## CLI contract
25
25
 
26
- - Success: stdout contains one JSON result.
27
- - Failure: stderr contains one JSONL error event with `type:"error"`, `ok:false`, `error`, `code`, and `exitCode`.
26
+ - Command results write exactly one JSON value to stdout, including `doctor`, `batch`, and `cleanup` failure reports; use the exit code and result fields.
27
+ - Dispatch/runtime failures write one JSONL error event to stderr with `type:"error"`, `ok:false`, `error`, `code`, and `exitCode`, while stdout stays empty.
28
28
  - Non-fatal diagnostics and `--verbose` traces are JSONL stderr events (`type:"warning"` / `type:"trace"`); no prose trace lines are part of the contract.
29
29
  - `--fields a,b,c` projects those fields from an object or array-of-objects result; dotted paths (`a.b.c`) drill into nested objects, and missing fields become `null`; string and scalar results pass through unchanged.
30
30
  - No prompts, help screens, tables, banners, or prose output are part of the contract.
31
- - Exit codes: `0` success, `1` usage/configuration error, `2` DSS/internal error, `3` transient DSS error, `4` completed command with failed long-running DSS work.
31
+ - Exit codes: `0` success, `1` usage/configuration error, `2` DSS/internal error, `3` transient DSS error, `4` a failed long-running result or synchronous assertion.
32
+ - `--retries N` controls idempotent GET retries only. `dss sql query --start-retries N` explicitly retries transient failures while starting a query; use it only when executing the SQL more than once is safe.
32
33
  - The exit code is the success signal. For portable multi-step mutations, prefer `dss batch`; shell chaining and pipeline exit semantics differ across POSIX shells, Windows PowerShell, PowerShell 7, and Command Prompt.
33
34
  - `--raw` is only for recipe payload commands. Without `--output`, stdout is raw bytes; with `--output PATH`, stdout is the JSON string equal to `PATH` and the file contains the exact raw bytes.
34
35
 
35
- Discover the agent protocol and complete machine-readable command surface:
36
+ Discover the agent contract and command surface with compact, scoped, `--json` calls:
36
37
 
37
38
  ```text
38
- dss agent contract
39
- dss commands run
39
+ dss agent contract --fields protocol,agentContractVersion,cli,stdio,planning,compatibility --json
40
+ dss commands run --fields dataset.create --json
41
+ dss commands run --fields dataset.create.usage,dataset.create.description,dataset.create.flags,dataset.create.examples --json
42
+ dss commands run --fields dataset --json
43
+ dss agent contract --fields commands.actions --json
40
44
  ```
41
45
 
42
- Agents should parse `agent contract` once for protocol/schema compatibility, then parse `commands run` before choosing syntax; inspect `flags`, `structuredExamples`, `schemas`, `requiresAuth`, `requiresProject`, `sideEffect`, `unsafeOutputs`, and `outputShape` instead of guessing.
46
+ For JSON outputs, prefer `--json`: compact single-line JSON cuts the full registry's context usage by about 40% (~220k tokens versus ~358k pretty-printed). Bootstrap by scoping `agent contract` to `protocol,agentContractVersion,cli,stdio,planning,compatibility` (~250 tokens); request `schemas` or `commands` only when you actually need them. Before choosing syntax, scope `commands run` with `--fields`: `--fields RESOURCE.ACTION` returns one complete registry entry, and appending `.FIELD` paths projects the metadata you need — the four-field per-action projection `usage,description,flags,examples` is the smallest self-sufficient starting point for constructing an invocation. Inspect `flags`, `structuredExamples`, `schemas`, `requiresAuth`, `requiresProject`, `sideEffect`, `async`, `idempotency`, `dryRun`, `cleanupCommand`, `unsafeOutputs`, `outputShape`, `inputContract`, and `exitCodes` instead of guessing.
47
+
48
+ `--fields` takes a comma-separated list, so request several actions in one call. Each key is echoed exactly as requested (`--fields dataset.create` returns `{"dataset.create": {...}}`). Enumerate every resource and action with `dss agent contract --fields commands.actions --json` (~1k tokens); the ~220k-token unscoped registry remains a compatibility surface, not a discovery workflow. An unknown resource or action exits with code 1 and a JSON error envelope on stderr containing the valid options.
43
49
 
44
50
  ## Agent skill installation
45
51
 
@@ -116,6 +122,112 @@ dss recipe get-payload compute_orders --project-key MYPROJ
116
122
  dss recipe get-payload compute_orders --raw --project-key MYPROJ
117
123
  dss recipe get-payload compute_orders --raw --output code.py --project-key MYPROJ
118
124
  dss install-skill --dry-run
125
+ dss app validate-manifest --project-key MYAPP_INSTANCE
126
+ dss app compare-manifest my-app --project-key MYAPP_INSTANCE
127
+ dss app create-instance my-app --data '{"targetProjectKey":"MYAPP_INSTANCE"}' --wait --record-cleanup cleanup.jsonl
128
+ dss app manifest-version --project-key MYAPP_TEMPLATE
129
+ dss app set-manifest-version --manifest-version 1.4.0 --project-key MYAPP_TEMPLATE
130
+ dss app create-successor-instance my-app --from MYAPP_INSTANCE --to MYAPP_INSTANCE_V2 --copy-permissions --record-cleanup cleanup.jsonl
131
+ dss app verify-instance my-app --project-key MYAPP_INSTANCE_V2 --expect-version 1.4.0
132
+ dss app permissions-snapshot --project-key MYAPP_INSTANCE --output permissions.json
133
+ dss app permissions-diff --project-key MYAPP_INSTANCE --file permissions.json
134
+ dss app permissions-restore --project-key MYAPP_INSTANCE --file permissions.json --dry-run
135
+ dss cleanup --file cleanup.jsonl
136
+ dss cleanup --file cleanup.jsonl --apply
119
137
  ```
120
138
 
139
+ ### Application release safety
140
+
141
+ Use the app commands as explicit release gates around a stable template, instance project key,
142
+ and permission set:
143
+
144
+ ```bash
145
+ # Validate source-verifiable manifest references.
146
+ dss app validate-manifest --project-key APP_TEMPLATE
147
+
148
+ # Detect governed template/instance drift. Only projectKey and projectAppType are normalized away.
149
+ dss app compare-manifest APP_ID --project-key RELEASE_INSTANCE
150
+
151
+ # Read the raw `version` from the public app manifest (string fields only; never appVersion).
152
+ dss app manifest-version --project-key APP_TEMPLATE
153
+
154
+ # Write version/versionNotes through the public app-manifest endpoint. This is NOT a publish
155
+ # transaction: it only changes the raw manifest metadata. --expect-hash SHA256 is a non-atomic
156
+ # stale-read guard, not a conditional write: it refuses the write when the manifest already
157
+ # changed since you read that hash, but DSS accepts every PUT unconditionally. This command can
158
+ # overwrite a write landing between its read and PUT, and the final read cannot detect that lost
159
+ # update when this command's payload wins. Every result reports
160
+ # concurrencyControl: "client-side-non-atomic-stale-read-check".
161
+ dss app set-manifest-version --manifest-version 1.4.0 --project-key APP_TEMPLATE
162
+
163
+ # Create an instance only after its target key is confirmed absent, wait on the DSS future, and
164
+ # record deterministic cleanup.
165
+ dss app create-instance APP_ID \
166
+ --data '{"targetProjectKey":"RELEASE_INSTANCE","targetProjectName":"Release instance"}' \
167
+ --wait --record-cleanup cleanup.jsonl
168
+
169
+ # Roll out a new template version to an existing instance as an additive successor: the old
170
+ # instance is never modified or deleted, and the command always waits on the DSS future
171
+ # (there is no --wait flag). The recorded cleanup entry targets only the new project key. If DSS
172
+ # accepts creation but returns no future ID, cleanup stops unresolved instead of racing creation.
173
+ dss app create-successor-instance APP_ID \
174
+ --from RELEASE_INSTANCE --to RELEASE_INSTANCE_V2 \
175
+ --name "Release instance v2" --copy-permissions --record-cleanup cleanup.jsonl
176
+
177
+ # API readiness gate for the successor. apiReady:true with status API_VERIFIED_UI_PENDING is an
178
+ # API-verified state only — never visual verification. The API key authenticates public REST only;
179
+ # visual confirmation stays an external SSO gate (pre-authenticated SSO browser session or a
180
+ # dedicated UI test identity).
181
+ dss app verify-instance APP_ID --project-key RELEASE_INSTANCE_V2 --expect-version 1.4.0
182
+
183
+ # Retirement of the predecessor is a separate, separately guarded step after the successor is
184
+ # verified. It is never performed implicitly by the successor flow.
185
+ dss app delete-instance --project-key RELEASE_INSTANCE
186
+
187
+ # Snapshot, compare, preview, and restore project permissions.
188
+ dss app permissions-snapshot --project-key RELEASE_INSTANCE --output permissions.json
189
+ dss app permissions-diff --project-key RELEASE_INSTANCE --file permissions.json
190
+ dss app permissions-restore --project-key RELEASE_INSTANCE --file permissions.json --dry-run
191
+ dss app permissions-restore --project-key RELEASE_INSTANCE --file permissions.json
192
+ ```
193
+
194
+ Permission snapshots are written with mode `0600` and an integrity hash covering the canonical DSS
195
+ URL, the concrete project incarnation (`creationTag`), capture metadata, and permissions. Diff and
196
+ restore reject snapshots from another DSS server, project key, or observed incarnation. These are
197
+ client-side, non-atomic stale-identity checks: DSS exposes no conditional permission PUT, so the
198
+ checks narrow and detect key-reuse races but cannot serialize the final check with the write.
199
+ Snapshots contain access-control identities; commit them only when repository policy permits.
200
+ `validate-manifest` checks `SCENARIO_RUN` scenario IDs, `DOWNLOAD_FILE`
201
+ managed-folder IDs, and runtime-form parameter names against supported public project APIs.
202
+
203
+ Some DSS deployments hide unknown project keys behind `403` instead of returning `404`.
204
+ Instance creation requires confirmed target absence before POST: an inaccessible target not present
205
+ in the visible project list is still unconfirmed and is rejected rather than risking cleanup
206
+ against a pre-existing project. A definitive create rejection never produces a cleanup entry.
207
+
208
+ Every new cleanup entry records the canonical DSS URL. App-instance cleanup records a
209
+ `creationTag` hash observed after the DSS future identifies the target key; unconfirmed creation
210
+ stops unresolved. The future target and later `creationTag` are independent, non-atomic
211
+ observations: the public API exposes neither an immutable project ID joined to the future nor a
212
+ conditional DELETE. Cleanup rechecks type and `creationTag` immediately before deletion, rejecting
213
+ detected key reuse, but cannot eliminate replacement in the remaining check-to-DELETE gap.
214
+ `cleanup --apply` validates the full ledger before issuing any request and rejects legacy entries
215
+ without server identity, mixed-server ledgers, entries for another DSS URL, and app cleanup entries
216
+ without a valid incarnation binding.
217
+
218
+ Saving `version`/`versionNotes` in the public app manifest is a metadata write, not a publish
219
+ transaction. If the manifest PUT or its verification read has an ambiguous transport/server
220
+ failure, the command exits non-zero with `persisted:null`, `after:null`, and
221
+ `outcome:"indeterminate"` rather than claiming the write failed or succeeded. Existing instances
222
+ are never upgraded in place: new instances inherit the template's
223
+ raw `version`, and an existing instance is rolled forward by creating an additive successor (the
224
+ old instance is preserved) followed by a separate, guarded retirement. `verify-instance` never
225
+ reports visual verification: its output is `apiReady:true` with
226
+ `status:"API_VERIFIED_UI_PENDING"` and `uiPublicationVerified:false`. Its `visual-ui` gate names
227
+ the required authentication and evidence: open the instance in a pre-authenticated SSO browser or
228
+ with a dedicated UI test identity, then exercise the affected tiles, forms, and actions. The CLI
229
+ never marks that external check complete. The public DSS APIs used by this SDK do not expose a
230
+ supported app-template publish/recreate/rename workflow, recipient-level app sharing setter, or
231
+ UI-click smoke test. The CLI does not guess private endpoints for those operations.
232
+
121
233
  For fake-DSS smoke tests, return project lists as JSON arrays such as `[{ "projectKey": "MYPROJ", "name": "My Project" }]` from `/public/api/projects/`; recipe payload commands read `/public/api/projects/<PROJECT>/recipes/<NAME>?includePayload=true` and expect a JSON object shaped like `{ "recipe": { "name": "<NAME>", "type": "python" }, "payload": "..." }`.
@@ -30,6 +30,11 @@ export declare const ProjectDetailsSchema: import("@sinclair/typebox").TObject<{
30
30
  name: import("@sinclair/typebox").TString;
31
31
  shortDesc: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
32
32
  projectStatus: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
33
+ projectAppType: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
34
+ creationTag: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
35
+ versionNumber: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
36
+ lastModifiedOn: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TString]>>;
37
+ }>>;
33
38
  ownerLogin: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
34
39
  tags: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
35
40
  versionTag: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
@@ -86,6 +86,11 @@ export const ProjectDetailsSchema = Type.Object({
86
86
  name: Type.String(),
87
87
  shortDesc: Type.Optional(Type.String()),
88
88
  projectStatus: Type.Optional(Type.String()),
89
+ projectAppType: Type.Optional(Type.String()),
90
+ creationTag: Type.Optional(Type.Object({
91
+ versionNumber: Type.Optional(Type.Number()),
92
+ lastModifiedOn: Type.Optional(Type.Union([Type.Number(), Type.String(),])),
93
+ }, { additionalProperties: true, })),
89
94
  ownerLogin: Type.Optional(Type.String()),
90
95
  tags: Type.Optional(Type.Array(Type.String())),
91
96
  versionTag: Type.Optional(Type.Object({
@@ -4,10 +4,8 @@ export declare function jobBuildTargetType(v: string | boolean | undefined): Job
4
4
  export declare function jobBuildTargetTypeFromFlags(flags: Record<string, string | boolean>): JobBuildTargetType;
5
5
  export declare function maxLogLinesFromFlags(flags: Record<string, string | boolean>): number | undefined;
6
6
  export declare function jobLogFilterFromFlag(v: string | boolean | undefined): JobLogFilter | undefined;
7
- export declare function sha256Hex(value: string): string;
7
+ export { sha256Hex, stableHash, stableJson, } from "../utils/stable-hash.js";
8
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
9
  export declare function splitCsvFlag(v: string | boolean | undefined): string[];
12
10
  export declare function recipeInputDatasetsFromFlags(flags: Record<string, string | boolean>): string[] | undefined;
13
11
  export declare function rewritePairsFromFlags(flags: Record<string, string | boolean>, flagName: string): Record<string, string>;
@@ -1,4 +1,3 @@
1
- import { createHash, } from "node:crypto";
2
1
  import { readFileSync, } from "node:fs";
3
2
  import { UsageError, } from "./usage.js";
4
3
  export function num(v) {
@@ -37,25 +36,10 @@ export function jobLogFilterFromFlag(v) {
37
36
  }
38
37
  throw new UsageError("Invalid --log-filter value. Use stdout, stderr, user, or errors.", "invalid_enum");
39
38
  }
40
- export function sha256Hex(value) {
41
- return createHash("sha256").update(value).digest("hex");
42
- }
39
+ export { sha256Hex, stableHash, stableJson, } from "../utils/stable-hash.js";
43
40
  export function normalizeLineEndings(value) {
44
41
  return value.replace(/\r\n/g, "\n");
45
42
  }
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
43
  export function splitCsvFlag(v) {
60
44
  if (typeof v !== "string")
61
45
  return [];