dataiku-sdk 0.12.4 → 0.12.5
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.
- package/README.md +118 -7
- package/dist/packages/types/src/index.d.ts +5 -0
- package/dist/packages/types/src/index.js +5 -0
- package/dist/src/cli/coerce.d.ts +1 -3
- package/dist/src/cli/coerce.js +1 -17
- package/dist/src/cli/commands/app.js +709 -14
- package/dist/src/cli/commands/code-env.js +2 -2
- package/dist/src/cli/commands/dashboard.js +1 -1
- package/dist/src/cli/commands/dataset.js +2 -2
- package/dist/src/cli/commands/folder.js +1 -1
- package/dist/src/cli/commands/insight.js +2 -2
- package/dist/src/cli/commands/notebook.js +2 -2
- package/dist/src/cli/commands/recipe.js +3 -3
- package/dist/src/cli/commands/scenario.js +1 -1
- package/dist/src/cli/commands/sql.js +1 -1
- package/dist/src/cli/commands/variable.js +1 -1
- package/dist/src/cli/commands/wiki.js +1 -1
- package/dist/src/cli/contract.d.ts +12 -3
- package/dist/src/cli/contract.js +805 -49
- package/dist/src/cli/flags.js +8 -0
- package/dist/src/cli/helpers/app-permissions.d.ts +63 -0
- package/dist/src/cli/helpers/app-permissions.js +239 -0
- package/dist/src/cli/helpers/app-successor.d.ts +106 -0
- package/dist/src/cli/helpers/app-successor.js +625 -0
- package/dist/src/cli/helpers/cleanup.js +46 -12
- package/dist/src/cli/output.d.ts +12 -1
- package/dist/src/cli/output.js +53 -6
- package/dist/src/cli/usage.d.ts +1 -1
- package/dist/src/cli/usage.js +5 -2
- package/dist/src/cli.js +329 -32
- package/dist/src/client.d.ts +6 -0
- package/dist/src/client.js +28 -1
- package/dist/src/errors.d.ts +1 -1
- package/dist/src/resources/applications.d.ts +191 -1
- package/dist/src/resources/applications.js +549 -10
- package/dist/src/resources/datasets.js +8 -0
- package/dist/src/resources/futures.js +7 -2
- package/dist/src/skill.js +76 -18
- package/dist/src/utils/cleanup-ledger.d.ts +34 -1
- package/dist/src/utils/cleanup-ledger.js +118 -7
- package/dist/src/utils/dss-url.d.ts +6 -0
- package/dist/src/utils/dss-url.js +17 -0
- package/dist/src/utils/project-incarnation.d.ts +6 -0
- package/dist/src/utils/project-incarnation.js +27 -0
- package/dist/src/utils/stable-hash.d.ts +11 -0
- package/dist/src/utils/stable-hash.js +27 -0
- package/node_modules/@sinclair/typebox/build/cjs/compiler/compiler.js +26 -46
- package/node_modules/@sinclair/typebox/build/cjs/parser/runtime/guard.d.ts +1 -1
- package/node_modules/@sinclair/typebox/build/cjs/parser/runtime/token.d.ts +2 -2
- package/node_modules/@sinclair/typebox/build/cjs/syntax/mapping.d.ts +1 -1
- package/node_modules/@sinclair/typebox/build/cjs/system/evaluate.d.ts +5 -0
- package/node_modules/@sinclair/typebox/build/cjs/system/evaluate.js +11 -0
- package/node_modules/@sinclair/typebox/build/cjs/system/index.d.ts +1 -0
- package/node_modules/@sinclair/typebox/build/cjs/system/index.js +1 -0
- package/node_modules/@sinclair/typebox/build/cjs/type/object/object.d.ts +2 -2
- package/node_modules/@sinclair/typebox/build/cjs/type/object/object.js +18 -2
- package/node_modules/@sinclair/typebox/build/cjs/value/parse/parse.d.ts +1 -1
- package/node_modules/@sinclair/typebox/build/esm/compiler/compiler.mjs +27 -47
- package/node_modules/@sinclair/typebox/build/esm/parser/runtime/guard.d.mts +1 -1
- package/node_modules/@sinclair/typebox/build/esm/parser/runtime/token.d.mts +2 -2
- package/node_modules/@sinclair/typebox/build/esm/syntax/mapping.d.mts +1 -1
- package/node_modules/@sinclair/typebox/build/esm/system/evaluate.d.mts +5 -0
- package/node_modules/@sinclair/typebox/build/esm/system/evaluate.mjs +7 -0
- package/node_modules/@sinclair/typebox/build/esm/system/index.d.mts +1 -0
- package/node_modules/@sinclair/typebox/build/esm/system/index.mjs +1 -0
- package/node_modules/@sinclair/typebox/build/esm/type/composite/composite.mjs +2 -2
- package/node_modules/@sinclair/typebox/build/esm/type/const/const.mjs +3 -3
- package/node_modules/@sinclair/typebox/build/esm/type/instantiate/instantiate.mjs +2 -2
- package/node_modules/@sinclair/typebox/build/esm/type/mapped/mapped.mjs +3 -3
- package/node_modules/@sinclair/typebox/build/esm/type/module/compute.mjs +2 -2
- package/node_modules/@sinclair/typebox/build/esm/type/object/object.d.mts +2 -2
- package/node_modules/@sinclair/typebox/build/esm/type/object/object.mjs +18 -2
- package/node_modules/@sinclair/typebox/build/esm/type/omit/omit.mjs +3 -3
- package/node_modules/@sinclair/typebox/build/esm/type/partial/partial.mjs +3 -3
- package/node_modules/@sinclair/typebox/build/esm/type/pick/pick.mjs +3 -3
- package/node_modules/@sinclair/typebox/build/esm/type/record/record.mjs +3 -3
- package/node_modules/@sinclair/typebox/build/esm/type/required/required.mjs +3 -3
- package/node_modules/@sinclair/typebox/build/esm/type/type/json.mjs +2 -2
- package/node_modules/@sinclair/typebox/build/esm/value/delta/delta.mjs +4 -4
- package/node_modules/@sinclair/typebox/build/esm/value/parse/parse.d.mts +1 -1
- package/node_modules/@sinclair/typebox/package.json +1 -1
- package/package.json +7 -5
- package/packages/types/dist/index.d.ts +5 -0
- package/packages/types/dist/index.js +5 -0
|
@@ -9,6 +9,10 @@ export function cleanupLedgerEntry(resource, action, args, flags, result, projec
|
|
|
9
9
|
const record = resultRecord(result);
|
|
10
10
|
if (record.skipped !== undefined)
|
|
11
11
|
return undefined;
|
|
12
|
+
// Only an explicit `cleanupEligible:false` suppresses the ledger: absent or
|
|
13
|
+
// true (including indeterminate post-POST outcomes) must stay addressable.
|
|
14
|
+
if (record.cleanupEligible === false)
|
|
15
|
+
return undefined;
|
|
12
16
|
const project = flags["project-key"] ?? projectKey;
|
|
13
17
|
const withProject = projectArg(project);
|
|
14
18
|
const ts = new Date().toISOString();
|
|
@@ -179,18 +183,6 @@ export function cleanupLedgerEntry(resource, action, args, flags, result, projec
|
|
|
179
183
|
cleanup: { argv: ["code-env", "delete", lang, name, "--if-exists",], },
|
|
180
184
|
};
|
|
181
185
|
}
|
|
182
|
-
case "project.duplicate": {
|
|
183
|
-
const targetKey = args[1];
|
|
184
|
-
if (!targetKey)
|
|
185
|
-
return undefined;
|
|
186
|
-
return {
|
|
187
|
-
ts,
|
|
188
|
-
action,
|
|
189
|
-
resource,
|
|
190
|
-
name: targetKey,
|
|
191
|
-
cleanup: { argv: ["project", "delete", targetKey, "--drop-data",], },
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
186
|
case "folder.upload":
|
|
195
187
|
return {
|
|
196
188
|
...base,
|
|
@@ -198,6 +190,48 @@ export function cleanupLedgerEntry(resource, action, args, flags, result, projec
|
|
|
198
190
|
path: args[1],
|
|
199
191
|
cleanup: { argv: ["folder", "delete-file", args[0], args[1], ...withProject,], },
|
|
200
192
|
};
|
|
193
|
+
case "app.create-instance":
|
|
194
|
+
case "app.create-successor-instance": {
|
|
195
|
+
const targetKey = stringField(record, ["projectKey", "targetProjectKey",]);
|
|
196
|
+
if (!targetKey)
|
|
197
|
+
return undefined;
|
|
198
|
+
const nestedInstance = resultRecord(record.instance);
|
|
199
|
+
const futureId = stringField(record, ["futureId", "jobId",])
|
|
200
|
+
?? stringField(nestedInstance, ["futureId", "jobId",]);
|
|
201
|
+
const projectIncarnationHash = stringField(record, ["projectIncarnationHash",]);
|
|
202
|
+
const boundIncarnation = projectIncarnationHash
|
|
203
|
+
&& /^[0-9a-f]{64}$/.test(projectIncarnationHash)
|
|
204
|
+
? projectIncarnationHash
|
|
205
|
+
: undefined;
|
|
206
|
+
// Cleanup can delete only the concrete project incarnation created by
|
|
207
|
+
// this lifecycle. A terminal future proves the requested key, but not
|
|
208
|
+
// that the same project still occupies that key at replay time.
|
|
209
|
+
const settled = record.futureTargetVerified === true;
|
|
210
|
+
const lifecycleArgs = !boundIncarnation || (!settled && !futureId)
|
|
211
|
+
? ["--unconfirmed-creation",]
|
|
212
|
+
: futureId && !settled
|
|
213
|
+
? [
|
|
214
|
+
"--future-id",
|
|
215
|
+
futureId,
|
|
216
|
+
"--expect-project-incarnation",
|
|
217
|
+
boundIncarnation,
|
|
218
|
+
]
|
|
219
|
+
: ["--expect-project-incarnation", boundIncarnation,];
|
|
220
|
+
return {
|
|
221
|
+
...base,
|
|
222
|
+
projectKey: targetKey,
|
|
223
|
+
name: targetKey,
|
|
224
|
+
cleanup: {
|
|
225
|
+
argv: [
|
|
226
|
+
"app",
|
|
227
|
+
"delete-instance",
|
|
228
|
+
"--project-key",
|
|
229
|
+
targetKey,
|
|
230
|
+
...lifecycleArgs,
|
|
231
|
+
],
|
|
232
|
+
},
|
|
233
|
+
};
|
|
234
|
+
}
|
|
201
235
|
default:
|
|
202
236
|
return undefined;
|
|
203
237
|
}
|
package/dist/src/cli/output.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { DataikuClient } from "../client.js";
|
|
2
|
+
import { type StableErrorCode } from "../errors.js";
|
|
3
|
+
export declare function setCompactJsonOutput(compact: boolean): void;
|
|
2
4
|
export declare function setOutputFieldProjection(fields: string[] | undefined): void;
|
|
3
5
|
export declare function enqueueCliWarning(warning: Record<string, unknown>): void;
|
|
4
6
|
export declare function pickResultFields(item: unknown, fields: string[]): unknown;
|
|
@@ -12,11 +14,20 @@ export declare function writeCommandResult(result: unknown): void;
|
|
|
12
14
|
export declare function transientBodyWithTargetContext(body: string, target: string, elapsedMs: number): string;
|
|
13
15
|
export declare function addTransientTargetContext(error: unknown, target: string, elapsedMs: number): never;
|
|
14
16
|
export declare function isFailedWaitResult(result: unknown): boolean;
|
|
17
|
+
export declare function isAssertionFailureResult(result: unknown): boolean;
|
|
15
18
|
export declare function commandFailureExitCode(result: unknown): number | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Stable error code for a command-level failure report. A failed synchronous
|
|
21
|
+
* assertion (exit 4) is a distinct outcome from a failed long-running remote
|
|
22
|
+
* operation (also exit 4), so agents must never see `long_running_failure`
|
|
23
|
+
* for a result that finished synchronously with `unchanged: false`.
|
|
24
|
+
*/
|
|
25
|
+
export declare function commandFailureCode(result: unknown, exitCode: number): StableErrorCode;
|
|
16
26
|
export declare class CommandResultFailure extends Error {
|
|
17
27
|
readonly result: unknown;
|
|
18
28
|
readonly exitCode: number;
|
|
19
|
-
|
|
29
|
+
readonly code: StableErrorCode;
|
|
30
|
+
constructor(result: unknown, exitCode: number, code?: StableErrorCode);
|
|
20
31
|
}
|
|
21
32
|
export declare function commandFailureMessage(result: unknown): string;
|
|
22
33
|
export declare function isNotFoundError(error: unknown): boolean;
|
package/dist/src/cli/output.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { DataikuError, } from "../errors.js";
|
|
2
2
|
let outputFieldProjection;
|
|
3
|
+
let compactJsonOutput = false;
|
|
4
|
+
export function setCompactJsonOutput(compact) {
|
|
5
|
+
compactJsonOutput = compact;
|
|
6
|
+
}
|
|
3
7
|
export function setOutputFieldProjection(fields) {
|
|
4
8
|
outputFieldProjection = fields;
|
|
5
9
|
}
|
|
@@ -53,7 +57,7 @@ export function writeCommandResult(result) {
|
|
|
53
57
|
const projected = outputFieldProjection
|
|
54
58
|
? projectResultFields(result, outputFieldProjection)
|
|
55
59
|
: result;
|
|
56
|
-
process.stdout.write(`${JSON.stringify(projected ?? { ok: true, }, null, 2)}\n`);
|
|
60
|
+
process.stdout.write(`${JSON.stringify(projected ?? { ok: true, }, null, compactJsonOutput ? undefined : 2)}\n`);
|
|
57
61
|
}
|
|
58
62
|
export function transientBodyWithTargetContext(body, target, elapsedMs) {
|
|
59
63
|
try {
|
|
@@ -86,21 +90,61 @@ export function isFailedWaitResult(result) {
|
|
|
86
90
|
&& typeof record.pollCount === "number"
|
|
87
91
|
&& (typeof record.state === "string" || typeof record.outcome === "string");
|
|
88
92
|
}
|
|
93
|
+
export function isAssertionFailureResult(result) {
|
|
94
|
+
return result !== null
|
|
95
|
+
&& typeof result === "object"
|
|
96
|
+
&& !Array.isArray(result)
|
|
97
|
+
&& result.unchanged === false;
|
|
98
|
+
}
|
|
99
|
+
function isNestedAssertionFailureResult(result) {
|
|
100
|
+
if (result === null || typeof result !== "object" || Array.isArray(result))
|
|
101
|
+
return false;
|
|
102
|
+
const steps = result.steps;
|
|
103
|
+
if (!Array.isArray(steps))
|
|
104
|
+
return false;
|
|
105
|
+
for (const step of steps) {
|
|
106
|
+
if (step === null || typeof step !== "object" || Array.isArray(step))
|
|
107
|
+
continue;
|
|
108
|
+
const stepRecord = step;
|
|
109
|
+
if (stepRecord.ok !== false)
|
|
110
|
+
continue;
|
|
111
|
+
const error = stepRecord.error;
|
|
112
|
+
return error !== null
|
|
113
|
+
&& typeof error === "object"
|
|
114
|
+
&& !Array.isArray(error)
|
|
115
|
+
&& error.code === "assertion_failed";
|
|
116
|
+
}
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
89
119
|
export function commandFailureExitCode(result) {
|
|
90
|
-
if (isFailedWaitResult(result))
|
|
91
|
-
return 4;
|
|
92
|
-
if (result && typeof result === "object" && result.unchanged === false)
|
|
120
|
+
if (isFailedWaitResult(result) || isAssertionFailureResult(result))
|
|
93
121
|
return 4;
|
|
94
122
|
return undefined;
|
|
95
123
|
}
|
|
124
|
+
/**
|
|
125
|
+
* Stable error code for a command-level failure report. A failed synchronous
|
|
126
|
+
* assertion (exit 4) is a distinct outcome from a failed long-running remote
|
|
127
|
+
* operation (also exit 4), so agents must never see `long_running_failure`
|
|
128
|
+
* for a result that finished synchronously with `unchanged: false`.
|
|
129
|
+
*/
|
|
130
|
+
export function commandFailureCode(result, exitCode) {
|
|
131
|
+
if (isAssertionFailureResult(result) || isNestedAssertionFailureResult(result)) {
|
|
132
|
+
return "assertion_failed";
|
|
133
|
+
}
|
|
134
|
+
if (isFailedWaitResult(result))
|
|
135
|
+
return "long_running_failure";
|
|
136
|
+
return exitCode === 4 ? "long_running_failure" : "command_result_failure";
|
|
137
|
+
}
|
|
96
138
|
export class CommandResultFailure extends Error {
|
|
97
139
|
result;
|
|
98
140
|
exitCode;
|
|
99
|
-
|
|
141
|
+
code;
|
|
142
|
+
constructor(result, exitCode, code) {
|
|
100
143
|
super(commandFailureMessage(result));
|
|
101
144
|
this.name = "CommandResultFailure";
|
|
102
145
|
this.result = result;
|
|
103
146
|
this.exitCode = exitCode;
|
|
147
|
+
this.code = code ?? commandFailureCode(result, exitCode);
|
|
104
148
|
}
|
|
105
149
|
}
|
|
106
150
|
export function commandFailureMessage(result) {
|
|
@@ -109,9 +153,12 @@ export function commandFailureMessage(result) {
|
|
|
109
153
|
const state = typeof record.state === "string" ? record.state : record.outcome;
|
|
110
154
|
return `Command completed with failed long-running result${state ? `: ${state}` : ""}.`;
|
|
111
155
|
}
|
|
112
|
-
if (result
|
|
156
|
+
if (isAssertionFailureResult(result)) {
|
|
113
157
|
return "Command completed with failed assertion result.";
|
|
114
158
|
}
|
|
159
|
+
if (isNestedAssertionFailureResult(result)) {
|
|
160
|
+
return "Command completed with nested failed assertion result.";
|
|
161
|
+
}
|
|
115
162
|
return "Command completed with failed result.";
|
|
116
163
|
}
|
|
117
164
|
export function isNotFoundError(error) {
|
package/dist/src/cli/usage.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export declare class UsageError extends Error {
|
|
|
6
6
|
readonly details?: Record<string, unknown>;
|
|
7
7
|
constructor(message: string, code?: StableErrorCode, hint?: string, details?: Record<string, unknown>);
|
|
8
8
|
}
|
|
9
|
-
export declare const COMMANDS_RUN_HINT = "Use `dss commands run` for
|
|
9
|
+
export declare const COMMANDS_RUN_HINT = "Use `dss commands run --fields RESOURCE.ACTION --json` for scoped, compact command discovery; omit --fields only when you need the full registry.";
|
|
10
10
|
export declare function unsupportedHelpFlag(): UsageError;
|
|
11
11
|
export declare function noCommandError(): UsageError;
|
|
12
12
|
export declare function missingActionError(resource: string, validActions: string[], usage?: string): UsageError;
|
package/dist/src/cli/usage.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export const RESOURCE_NAMES = [
|
|
2
|
-
"
|
|
2
|
+
"agent",
|
|
3
3
|
"app",
|
|
4
|
+
"batch",
|
|
4
5
|
"business-app",
|
|
5
6
|
"webapp",
|
|
6
7
|
"api-service",
|
|
@@ -42,6 +43,8 @@ export const RESOURCE_NAMES = [
|
|
|
42
43
|
"commands",
|
|
43
44
|
"fixtures",
|
|
44
45
|
"install-skill",
|
|
46
|
+
"project",
|
|
47
|
+
"version",
|
|
45
48
|
]
|
|
46
49
|
.sort();
|
|
47
50
|
export class UsageError extends Error {
|
|
@@ -56,7 +59,7 @@ export class UsageError extends Error {
|
|
|
56
59
|
this.details = details;
|
|
57
60
|
}
|
|
58
61
|
}
|
|
59
|
-
export const COMMANDS_RUN_HINT = "Use `dss commands run` for
|
|
62
|
+
export const COMMANDS_RUN_HINT = "Use `dss commands run --fields RESOURCE.ACTION --json` for scoped, compact command discovery; omit --fields only when you need the full registry.";
|
|
60
63
|
export function unsupportedHelpFlag() {
|
|
61
64
|
return new UsageError("Help screens are not supported.", "usage_error", COMMANDS_RUN_HINT, { command: "dss commands run", });
|
|
62
65
|
}
|