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.
- package/README.md +246 -19
- package/dist/build-metadata.json +1 -1
- package/dist/packages/types/src/index.d.ts +39 -4
- package/dist/packages/types/src/index.js +31 -2
- package/dist/src/auth.js +1 -1
- package/dist/src/cli/coerce.js +11 -2
- package/dist/src/cli/commands/analysis.js +4 -3
- package/dist/src/cli/commands/api-service.js +66 -18
- package/dist/src/cli/commands/app.js +4 -3
- package/dist/src/cli/commands/bundle.js +51 -16
- package/dist/src/cli/commands/code-env.js +219 -57
- package/dist/src/cli/commands/code.d.ts +19 -0
- package/dist/src/cli/commands/code.js +87 -15
- package/dist/src/cli/commands/dashboard.js +7 -6
- package/dist/src/cli/commands/data-quality.js +9 -8
- package/dist/src/cli/commands/dataset.js +17 -11
- package/dist/src/cli/commands/doctor.js +4 -2
- package/dist/src/cli/commands/flow-zone.js +42 -13
- package/dist/src/cli/commands/folder.js +9 -8
- package/dist/src/cli/commands/future.js +2 -1
- package/dist/src/cli/commands/insight.js +8 -7
- package/dist/src/cli/commands/job.js +4 -3
- package/dist/src/cli/commands/meaning.js +5 -4
- package/dist/src/cli/commands/ml-task.js +3 -2
- package/dist/src/cli/commands/model-evaluation-store.js +4 -3
- package/dist/src/cli/commands/notebook.js +82 -50
- package/dist/src/cli/commands/project-git.js +8 -5
- package/dist/src/cli/commands/project-library.d.ts +21 -0
- package/dist/src/cli/commands/project-library.js +128 -56
- package/dist/src/cli/commands/project.js +19 -4
- package/dist/src/cli/commands/recipe.js +51 -25
- package/dist/src/cli/commands/saved-model.js +4 -3
- package/dist/src/cli/commands/scenario.js +9 -8
- package/dist/src/cli/commands/sql.d.ts +10 -0
- package/dist/src/cli/commands/sql.js +42 -19
- package/dist/src/cli/commands/statistics.js +7 -6
- package/dist/src/cli/commands/variable.js +2 -1
- package/dist/src/cli/commands/webapp.js +68 -13
- package/dist/src/cli/commands/wiki.js +7 -6
- package/dist/src/cli/contract.d.ts +16 -1
- package/dist/src/cli/contract.js +967 -186
- package/dist/src/cli/env.d.ts +9 -0
- package/dist/src/cli/env.js +20 -2
- package/dist/src/cli/flags.d.ts +4 -0
- package/dist/src/cli/flags.js +29 -1
- package/dist/src/cli/helpers/cleanup.js +104 -3
- package/dist/src/cli/helpers/flow-zone.d.ts +3 -0
- package/dist/src/cli/helpers/flow-zone.js +33 -3
- package/dist/src/cli/helpers/recipe.d.ts +20 -0
- package/dist/src/cli/helpers/recipe.js +158 -3
- package/dist/src/cli/output.d.ts +2 -0
- package/dist/src/cli/output.js +33 -6
- package/dist/src/cli/runtime.d.ts +35 -1
- package/dist/src/cli/runtime.js +125 -18
- package/dist/src/cli/types.d.ts +7 -0
- package/dist/src/cli.js +226 -95
- package/dist/src/client.d.ts +63 -1
- package/dist/src/client.js +305 -53
- package/dist/src/errors.d.ts +8 -2
- package/dist/src/errors.js +42 -0
- package/dist/src/index.d.ts +4 -3
- package/dist/src/index.js +2 -1
- package/dist/src/resources/api-services.d.ts +48 -6
- package/dist/src/resources/api-services.js +54 -8
- package/dist/src/resources/bundles.d.ts +51 -6
- package/dist/src/resources/bundles.js +39 -9
- package/dist/src/resources/code-envs.d.ts +25 -3
- package/dist/src/resources/code-envs.js +104 -2
- package/dist/src/resources/datasets.d.ts +20 -0
- package/dist/src/resources/datasets.js +232 -52
- package/dist/src/resources/folders.js +2 -1
- package/dist/src/resources/jobs.d.ts +35 -10
- package/dist/src/resources/jobs.js +92 -17
- package/dist/src/resources/notebooks.d.ts +77 -7
- package/dist/src/resources/notebooks.js +143 -19
- package/dist/src/resources/project-git.d.ts +12 -0
- package/dist/src/resources/project-git.js +39 -8
- package/dist/src/resources/project-library.d.ts +122 -7
- package/dist/src/resources/project-library.js +494 -25
- package/dist/src/resources/projects.d.ts +5 -4
- package/dist/src/resources/projects.js +21 -19
- package/dist/src/resources/scenarios.d.ts +30 -0
- package/dist/src/resources/scenarios.js +73 -27
- package/dist/src/resources/sql.d.ts +6 -0
- package/dist/src/resources/sql.js +23 -3
- package/dist/src/resources/webapps.d.ts +35 -4
- package/dist/src/resources/webapps.js +54 -5
- package/dist/src/schemas.d.ts +2 -2
- package/dist/src/schemas.js +1 -1
- package/dist/src/skill.d.ts +18 -0
- package/dist/src/skill.js +93 -9
- package/dist/src/utils/flow-analysis.d.ts +53 -0
- package/dist/src/utils/flow-analysis.js +382 -0
- package/dist/src/utils/project-archive.d.ts +41 -2
- package/dist/src/utils/project-archive.js +159 -16
- package/dist/src/utils/response-file.d.ts +2 -0
- package/dist/src/utils/response-file.js +34 -0
- package/package.json +9 -7
- package/packages/types/dist/index.d.ts +39 -4
- package/packages/types/dist/index.js +31 -2
- package/plugin.json +1 -1
- package/skills/dataiku-dss/SKILL.md +44 -197
- package/skills/dataiku-dss/references/app-releases.md +27 -0
- package/skills/dataiku-dss/references/authentication.md +39 -0
- package/skills/dataiku-dss/references/coding.md +8 -0
- package/skills/dataiku-dss/references/discovery.md +30 -0
- package/skills/dataiku-dss/references/flow-maps.md +12 -0
- package/skills/dataiku-dss/references/mutations.md +33 -0
- package/skills/dataiku-dss/references/troubleshooting.md +29 -0
|
@@ -17,11 +17,39 @@ function sleep(ms) {
|
|
|
17
17
|
setTimeout(resolve, ms);
|
|
18
18
|
return promise;
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function gitReferencePathError(path, message) {
|
|
21
|
+
return new ClientValidationError(message, "validation_failed", "Use a Git library reference path relative to the project library root: '/' -separated segment names, with no '.' or '..' segments.", { path, });
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Validate and canonicalize a Git library reference path. This is the single
|
|
25
|
+
* validator used by both SDK dispatch and CLI mutation planning.
|
|
26
|
+
*
|
|
27
|
+
* Strip only the permitted outer '/' separators, then require nonempty
|
|
28
|
+
* ordinary segments: no empty segments and no '.' or '..' segments. A hostile
|
|
29
|
+
* path therefore cannot change which API resource a dispatcher's URL
|
|
30
|
+
* normalization would otherwise select.
|
|
31
|
+
*/
|
|
32
|
+
export function validateGitReferencePath(path) {
|
|
33
|
+
if (typeof path !== "string" || path.trim() === "") {
|
|
34
|
+
throw gitReferencePathError(path, "A Git library reference path is required.");
|
|
35
|
+
}
|
|
21
36
|
const normalized = path.replace(/^\/+/, "").replace(/\/+$/, "");
|
|
22
|
-
if (
|
|
23
|
-
throw
|
|
24
|
-
|
|
37
|
+
if (normalized === "") {
|
|
38
|
+
throw gitReferencePathError(path, "A Git library reference path is required.");
|
|
39
|
+
}
|
|
40
|
+
for (const segment of normalized.split("/")) {
|
|
41
|
+
if (segment === "") {
|
|
42
|
+
throw gitReferencePathError(path, "A Git library reference path must not contain empty segments (consecutive or repeated '/').");
|
|
43
|
+
}
|
|
44
|
+
if (segment === "." || segment === "..") {
|
|
45
|
+
throw gitReferencePathError(path, "A Git library reference path must not contain '.' or '..' segments.");
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return normalized;
|
|
49
|
+
}
|
|
50
|
+
/** Validate a Git library reference path and URL-encode it per segment. */
|
|
51
|
+
export function encodeGitReferencePath(path) {
|
|
52
|
+
return validateGitReferencePath(path)
|
|
25
53
|
.split("/")
|
|
26
54
|
.map((segment) => encodeURIComponent(segment))
|
|
27
55
|
.join("/");
|
|
@@ -280,7 +308,8 @@ export class ProjectGitResource extends BaseResource {
|
|
|
280
308
|
async setLibrary(projectKey, gitReferencePath, options) {
|
|
281
309
|
const repository = validatedRepository(options.repository, "Git library repository URL");
|
|
282
310
|
const secrets = [options.password,].filter((secret) => secret !== undefined && secret !== "");
|
|
283
|
-
const
|
|
311
|
+
const encodedPath = encodeGitReferencePath(gitReferencePath);
|
|
312
|
+
const raw = await this.request("PUT", `${this.libraryPath(projectKey)}/${encodedPath}`, {
|
|
284
313
|
repository,
|
|
285
314
|
login: options.login ?? null,
|
|
286
315
|
password: options.password ?? null,
|
|
@@ -291,19 +320,21 @@ export class ProjectGitResource extends BaseResource {
|
|
|
291
320
|
}
|
|
292
321
|
/** Detach a library, optionally deleting its local directory. */
|
|
293
322
|
async removeLibrary(projectKey, gitReferencePath, deleteDirectory = false) {
|
|
294
|
-
await this.request("DELETE", `${this.libraryPath(projectKey)}/${
|
|
323
|
+
await this.request("DELETE", `${this.libraryPath(projectKey)}/${encodeGitReferencePath(gitReferencePath)}${this.query({ deleteDirectory, })}`);
|
|
295
324
|
}
|
|
296
325
|
/** Reset one library to its remote state. Runs as a DSS future. */
|
|
297
326
|
async resetLibrary(projectKey, gitReferencePath) {
|
|
327
|
+
const gitRef = validateGitReferencePath(gitReferencePath);
|
|
298
328
|
const raw = await this.request("POST", `${this.libraryPath(projectKey)}/action/reset`, {
|
|
299
|
-
gitRef
|
|
329
|
+
gitRef,
|
|
300
330
|
});
|
|
301
331
|
return this.client.safeParse(ProjectGitFutureResponseSchema, raw ?? {}, "projectGit.resetLibrary");
|
|
302
332
|
}
|
|
303
333
|
/** Commit and push one library. Runs as a DSS future. */
|
|
304
334
|
async pushLibrary(projectKey, gitReferencePath, commitMessage) {
|
|
335
|
+
const gitRef = validateGitReferencePath(gitReferencePath);
|
|
305
336
|
const raw = await this.request("POST", `${this.libraryPath(projectKey)}/action/push`, {
|
|
306
|
-
gitRef
|
|
337
|
+
gitRef,
|
|
307
338
|
commitMessage,
|
|
308
339
|
});
|
|
309
340
|
return this.client.safeParse(ProjectGitFutureResponseSchema, raw ?? {}, "projectGit.pushLibrary");
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { BaseResource } from "./base.js";
|
|
2
2
|
export interface ProjectLibraryItem {
|
|
3
3
|
name: string;
|
|
4
|
+
/** Full library path of the item, as observed from DSS contents listings. */
|
|
5
|
+
path?: string;
|
|
6
|
+
/** File size in bytes, as observed from DSS contents listings. */
|
|
7
|
+
size?: number;
|
|
8
|
+
/** MIME type of the file content, as observed from DSS contents listings. */
|
|
9
|
+
mimeType?: string;
|
|
10
|
+
/** Whether the item carries data, as observed from DSS contents listings. */
|
|
11
|
+
hasData?: boolean;
|
|
12
|
+
/** Last modification timestamp (epoch milliseconds), as observed from DSS contents listings. */
|
|
13
|
+
lastModified?: number;
|
|
4
14
|
children?: ProjectLibraryItem[];
|
|
5
15
|
}
|
|
6
16
|
export interface ProjectLibraryFileContent {
|
|
@@ -14,25 +24,130 @@ export interface ProjectLibraryMoveRequest {
|
|
|
14
24
|
oldPath: string;
|
|
15
25
|
newPath: string;
|
|
16
26
|
}
|
|
27
|
+
export interface ProjectLibraryWriteOptions {
|
|
28
|
+
/**
|
|
29
|
+
* 64-character SHA-256 hex digest the caller last read from this file.
|
|
30
|
+
* Non-atomic stale-read guard: the write is refused when the remote
|
|
31
|
+
* content already differs at the verification read. It cannot prevent a
|
|
32
|
+
* concurrent write landing between that read and this write.
|
|
33
|
+
*/
|
|
34
|
+
expectSha256?: string;
|
|
35
|
+
}
|
|
36
|
+
export interface ProjectLibraryWriteResult {
|
|
37
|
+
path: string;
|
|
38
|
+
/** Number of bytes written. */
|
|
39
|
+
bytes: number;
|
|
40
|
+
/** SHA-256 hex digest of the exact bytes written. */
|
|
41
|
+
sha256: string;
|
|
42
|
+
/** SHA-256 hex digest observed before the write; present when a precondition was checked. */
|
|
43
|
+
beforeSha256?: string;
|
|
44
|
+
}
|
|
45
|
+
export interface ProjectLibraryDiffOptions {
|
|
46
|
+
/** Cap on reported diff lines (default 200). */
|
|
47
|
+
maxLines?: number;
|
|
48
|
+
}
|
|
49
|
+
export interface ProjectLibraryDiffResult {
|
|
50
|
+
path: string;
|
|
51
|
+
/** True when remote and local content are byte-identical. */
|
|
52
|
+
unchanged: boolean;
|
|
53
|
+
/** Lines added in the local content relative to the remote file. */
|
|
54
|
+
added: number;
|
|
55
|
+
/** Lines removed from the remote file relative to the local content. */
|
|
56
|
+
removed: number;
|
|
57
|
+
/** Unified diff text; capped at `maxLines`. Empty for binary or byte-identical content. */
|
|
58
|
+
diff: string;
|
|
59
|
+
/** True when the diff text was truncated at `maxLines`. */
|
|
60
|
+
diffTruncated: boolean;
|
|
61
|
+
/** True when either side is not valid UTF-8 text; diff is never emitted for binary. */
|
|
62
|
+
binary?: boolean;
|
|
63
|
+
/** True when the remote file does not exist. */
|
|
64
|
+
remoteAbsent?: boolean;
|
|
65
|
+
remoteSha256?: string;
|
|
66
|
+
remoteBytes?: number;
|
|
67
|
+
localSha256: string;
|
|
68
|
+
localBytes: number;
|
|
69
|
+
maxLines: number;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* The only concurrency control the public project-library API permits. DSS
|
|
73
|
+
* exposes no conditional write (no ETag, no If-Match, no version token), so
|
|
74
|
+
* `expectSha256` can only detect a hash that is already stale when it is
|
|
75
|
+
* checked; it can never turn the subsequent POST into a conditional write.
|
|
76
|
+
*/
|
|
77
|
+
export declare const PROJECT_LIBRARY_CONCURRENCY_CONTROL = "client-side-non-atomic-stale-read-check";
|
|
78
|
+
/** Lowercase or uppercase SHA-256 hex digest. */
|
|
79
|
+
export declare const EXPECT_SHA256_PATTERN: RegExp;
|
|
80
|
+
/**
|
|
81
|
+
* Validate and canonicalize a project library path.
|
|
82
|
+
*
|
|
83
|
+
* Rejects empty paths, control characters, backslash separators, empty
|
|
84
|
+
* segments (leading/trailing/doubled '/'), '.'/'..' segments (including
|
|
85
|
+
* mid-path traversals), whitespace-only or edge-whitespace segments, and
|
|
86
|
+
* trailing dot/space segments that differ across filesystem normalizations.
|
|
87
|
+
*
|
|
88
|
+
* Returns the canonical path with any leading '/' prefix stripped (the DSS
|
|
89
|
+
* contents endpoints take paths relative to the library root).
|
|
90
|
+
*/
|
|
91
|
+
export declare function validateLibraryPath(path: string): string;
|
|
92
|
+
/**
|
|
93
|
+
* Validate a rename target: a single library segment (no '/'), with the same
|
|
94
|
+
* character rules as path segments. Returns the validated name unchanged.
|
|
95
|
+
*/
|
|
96
|
+
export declare function validateLibraryName(name: string): string;
|
|
97
|
+
/**
|
|
98
|
+
* Validate a destination folder path for a library move. '/' (the library
|
|
99
|
+
* root) is valid; any other path must pass {@link validateLibraryPath}.
|
|
100
|
+
* Returns the canonical destination ('/' or '/<path>').
|
|
101
|
+
*/
|
|
102
|
+
export declare function validateLibraryDestinationPath(path: string): string;
|
|
103
|
+
/** Validate and URL-encode each segment of a library path for endpoint use. */
|
|
104
|
+
export declare function encodeLibraryPath(path: string): string;
|
|
17
105
|
export declare class ProjectLibraryResource extends BaseResource {
|
|
18
|
-
/**
|
|
106
|
+
/**
|
|
107
|
+
* List the full project code-library contents tree. Items carry the DSS
|
|
108
|
+
* observed fields (path, size, mimeType, hasData, lastModified) when the
|
|
109
|
+
* server reports them; folders carry children, files do not.
|
|
110
|
+
*/
|
|
19
111
|
listContents(projectKey?: string): Promise<ProjectLibraryItem[]>;
|
|
20
112
|
/** Read a project code-library file as text. */
|
|
21
113
|
getFile(path: string, projectKey?: string): Promise<string>;
|
|
22
114
|
/** Read a project code-library file as bytes. */
|
|
23
115
|
getFileBytes(path: string, projectKey?: string): Promise<Uint8Array>;
|
|
24
|
-
/**
|
|
116
|
+
/**
|
|
117
|
+
* True when a file or folder exists at the given library path. Existence is
|
|
118
|
+
* verified against the live contents tree read from DSS.
|
|
119
|
+
*/
|
|
120
|
+
hasLibraryItem(path: string, projectKey?: string): Promise<boolean>;
|
|
121
|
+
/** Create an empty project code-library file; refuses to overwrite an existing item. */
|
|
25
122
|
addFile(path: string, projectKey?: string): Promise<void>;
|
|
26
|
-
/** Create a project code-library folder. */
|
|
123
|
+
/** Create a project code-library folder; refuses to overwrite an existing item. */
|
|
27
124
|
addFolder(path: string, projectKey?: string): Promise<void>;
|
|
28
|
-
/**
|
|
29
|
-
|
|
30
|
-
|
|
125
|
+
/**
|
|
126
|
+
* Create or replace a project code-library file with raw content. `content`
|
|
127
|
+
* may be a string (UTF-8 text) or raw bytes (binary-safe); the exact bytes
|
|
128
|
+
* sent are returned as a SHA-256 digest and byte count.
|
|
129
|
+
*
|
|
130
|
+
* When `options.expectSha256` is set, the current remote content is read
|
|
131
|
+
* first and the write is refused with an `assertion_failed` error when its
|
|
132
|
+
* SHA-256 differs. The check is non-atomic (see
|
|
133
|
+
* {@link PROJECT_LIBRARY_CONCURRENCY_CONTROL}).
|
|
134
|
+
*/
|
|
135
|
+
addOrUpdateFile(path: string, content: string | Uint8Array, projectKey?: string, options?: ProjectLibraryWriteOptions): Promise<ProjectLibraryWriteResult>;
|
|
136
|
+
/**
|
|
137
|
+
* Diff a library file against local content. The remote side is read as
|
|
138
|
+
* bytes (so binary files are detected instead of dumped); the reported
|
|
139
|
+
* unified diff is capped at `options.maxLines` (default 200) and never
|
|
140
|
+
* contains binary payloads.
|
|
141
|
+
*/
|
|
142
|
+
diffFile(path: string, local: string | Uint8Array, projectKey?: string, options?: ProjectLibraryDiffOptions): Promise<ProjectLibraryDiffResult>;
|
|
143
|
+
/** Delete a project code-library file or folder. */
|
|
31
144
|
deleteFile(path: string, projectKey?: string): Promise<void>;
|
|
32
145
|
/** Rename a project code-library file or folder within its current parent folder. */
|
|
33
146
|
rename(path: string, newName: string, projectKey?: string): Promise<void>;
|
|
34
147
|
/** Move a project code-library file or folder into another library folder. */
|
|
35
148
|
move(path: string, destinationFolderPath: string, projectKey?: string): Promise<void>;
|
|
36
149
|
private contentsPath;
|
|
37
|
-
private
|
|
150
|
+
private postRawBody;
|
|
151
|
+
private alreadyExistsError;
|
|
152
|
+
private assertLibraryFileAbsent;
|
|
38
153
|
}
|