dataiku-sdk 3.2.0 → 3.3.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 +149 -46
- package/dist/build-metadata.json +1 -1
- package/dist/packages/types/src/index.d.ts +102 -0
- package/dist/packages/types/src/index.js +76 -0
- package/dist/src/cli/commands/app.js +57 -15
- package/dist/src/cli/commands/bundle.js +1 -1
- package/dist/src/cli/commands/code-env.js +13 -7
- package/dist/src/cli/commands/connection.d.ts +9 -0
- package/dist/src/cli/commands/connection.js +267 -1
- package/dist/src/cli/commands/data-collection.d.ts +2 -0
- package/dist/src/cli/commands/data-collection.js +164 -0
- package/dist/src/cli/commands/dataset.js +161 -32
- package/dist/src/cli/commands/future.js +2 -2
- package/dist/src/cli/commands/group.d.ts +2 -0
- package/dist/src/cli/commands/group.js +109 -0
- package/dist/src/cli/commands/index.js +151 -78
- package/dist/src/cli/commands/knowledge-bank.d.ts +2 -0
- package/dist/src/cli/commands/knowledge-bank.js +80 -0
- package/dist/src/cli/commands/llm.d.ts +2 -0
- package/dist/src/cli/commands/llm.js +93 -0
- package/dist/src/cli/commands/macro.d.ts +2 -0
- package/dist/src/cli/commands/macro.js +221 -0
- package/dist/src/cli/commands/ml-task.js +18 -6
- package/dist/src/cli/commands/notebook.js +6 -2
- package/dist/src/cli/commands/plugin.d.ts +2 -0
- package/dist/src/cli/commands/plugin.js +799 -0
- package/dist/src/cli/commands/project-folder.d.ts +2 -0
- package/dist/src/cli/commands/project-folder.js +197 -0
- package/dist/src/cli/commands/project-git.js +14 -54
- package/dist/src/cli/commands/project.js +52 -6
- package/dist/src/cli/commands/recipe.js +36 -1
- package/dist/src/cli/commands/saved-model.d.ts +5 -0
- package/dist/src/cli/commands/saved-model.js +388 -1
- package/dist/src/cli/commands/scenario.js +138 -1
- package/dist/src/cli/commands/user.d.ts +8 -0
- package/dist/src/cli/commands/user.js +296 -0
- package/dist/src/cli/contract.d.ts +1 -2
- package/dist/src/cli/contract.js +1089 -103
- package/dist/src/cli/flags.js +30 -1
- package/dist/src/cli/helpers/app-successor.d.ts +19 -4
- package/dist/src/cli/helpers/app-successor.js +90 -30
- package/dist/src/cli/helpers/cleanup.js +3 -1
- package/dist/src/cli/helpers/flow-zone.js +1 -2
- package/dist/src/cli/output.d.ts +1 -1
- package/dist/src/cli/output.js +23 -10
- package/dist/src/cli/usage.d.ts +1 -0
- package/dist/src/cli/usage.js +47 -1
- package/dist/src/cli.js +147 -41
- package/dist/src/client.d.ts +83 -5
- package/dist/src/client.js +185 -29
- package/dist/src/errors.d.ts +3 -0
- package/dist/src/errors.js +2 -0
- package/dist/src/index.d.ts +16 -7
- package/dist/src/index.js +11 -2
- package/dist/src/resources/analyses.js +1 -8
- package/dist/src/resources/applications.d.ts +8 -6
- package/dist/src/resources/applications.js +21 -21
- package/dist/src/resources/base.d.ts +4 -0
- package/dist/src/resources/base.js +15 -0
- package/dist/src/resources/bundles.d.ts +9 -4
- package/dist/src/resources/bundles.js +10 -5
- package/dist/src/resources/connections.d.ts +78 -1
- package/dist/src/resources/connections.js +132 -1
- package/dist/src/resources/data-collections.d.ts +118 -0
- package/dist/src/resources/data-collections.js +49 -0
- package/dist/src/resources/datasets.d.ts +69 -0
- package/dist/src/resources/datasets.js +99 -1
- package/dist/src/resources/futures.d.ts +4 -1
- package/dist/src/resources/futures.js +38 -6
- package/dist/src/resources/groups.d.ts +47 -0
- package/dist/src/resources/groups.js +56 -0
- package/dist/src/resources/jobs.d.ts +8 -13
- package/dist/src/resources/jobs.js +41 -16
- package/dist/src/resources/knowledge-banks.d.ts +58 -0
- package/dist/src/resources/knowledge-banks.js +61 -0
- package/dist/src/resources/llms.d.ts +92 -0
- package/dist/src/resources/llms.js +62 -0
- package/dist/src/resources/macros.d.ts +121 -0
- package/dist/src/resources/macros.js +231 -0
- package/dist/src/resources/ml-tasks.d.ts +37 -2
- package/dist/src/resources/ml-tasks.js +100 -20
- package/dist/src/resources/model-evaluation-stores.js +1 -8
- package/dist/src/resources/notebooks.d.ts +43 -7
- package/dist/src/resources/notebooks.js +53 -13
- package/dist/src/resources/plugins.d.ts +265 -0
- package/dist/src/resources/plugins.js +458 -0
- package/dist/src/resources/project-folders.d.ts +71 -0
- package/dist/src/resources/project-folders.js +57 -0
- package/dist/src/resources/project-git.d.ts +6 -0
- package/dist/src/resources/project-git.js +69 -42
- package/dist/src/resources/project-library.d.ts +0 -1
- package/dist/src/resources/project-library.js +1 -17
- package/dist/src/resources/projects.d.ts +19 -1
- package/dist/src/resources/projects.js +27 -1
- package/dist/src/resources/recipes.d.ts +15 -1
- package/dist/src/resources/recipes.js +73 -6
- package/dist/src/resources/saved-models.d.ts +134 -1
- package/dist/src/resources/saved-models.js +214 -6
- package/dist/src/resources/scenarios.d.ts +105 -0
- package/dist/src/resources/scenarios.js +232 -106
- package/dist/src/resources/sql.js +5 -1
- package/dist/src/resources/users.d.ts +129 -0
- package/dist/src/resources/users.js +128 -0
- package/dist/src/resources/webapps.d.ts +15 -2
- package/dist/src/resources/webapps.js +18 -4
- package/dist/src/schemas.d.ts +2 -2
- package/dist/src/schemas.js +1 -1
- package/dist/src/utils/deep-merge.d.ts +1 -1
- package/dist/src/utils/polling.d.ts +20 -0
- package/dist/src/utils/polling.js +27 -0
- package/dist/src/utils/response-file.js +1 -1
- package/dist/src/utils/secret-sanitize.d.ts +54 -0
- package/dist/src/utils/secret-sanitize.js +101 -0
- package/package.json +6 -5
- package/packages/types/dist/index.d.ts +102 -0
- package/packages/types/dist/index.js +76 -0
- package/plugin.json +1 -1
- package/skills/dataiku-dss/SKILL.md +7 -5
- package/skills/dataiku-dss/references/app-releases.md +8 -7
- package/skills/dataiku-dss/references/discovery.md +4 -4
|
@@ -4,13 +4,13 @@ import { compareStrings, stableHash, stableJson, } from "../utils/stable-hash.js
|
|
|
4
4
|
import { BaseResource, } from "./base.js";
|
|
5
5
|
/**
|
|
6
6
|
* Source-verifiable app-manifest reference locations. Validation is scoped to
|
|
7
|
-
* homepage tiles so identically named keys in arbitrary custom
|
|
7
|
+
* homepage tiles so identically named keys in arbitrary custom tile `config`
|
|
8
8
|
* objects are never treated as references.
|
|
9
9
|
*/
|
|
10
10
|
export const APP_MANIFEST_REFERENCE_KEYS = {
|
|
11
11
|
scenario: ["SCENARIO_RUN.scenarioId",],
|
|
12
|
-
folder: ["
|
|
13
|
-
variable: ["params[].name",],
|
|
12
|
+
folder: ["DOWNLOAD_MANAGED_FOLDER_FILE.folderId",],
|
|
13
|
+
variable: ["PROJECT_VARIABLES_EDIT.params[].name",],
|
|
14
14
|
};
|
|
15
15
|
/**
|
|
16
16
|
* The only concurrency control the public app-manifest endpoint permits. DSS
|
|
@@ -382,11 +382,13 @@ export class ApplicationsResource extends BaseResource {
|
|
|
382
382
|
}
|
|
383
383
|
/**
|
|
384
384
|
* Validate source-verifiable references in app homepage tiles:
|
|
385
|
-
* SCENARIO_RUN scenario IDs,
|
|
386
|
-
*
|
|
387
|
-
*
|
|
388
|
-
*
|
|
389
|
-
*
|
|
385
|
+
* SCENARIO_RUN scenario IDs, DOWNLOAD_MANAGED_FOLDER_FILE managed-folder IDs,
|
|
386
|
+
* and PROJECT_VARIABLES_EDIT parameter names (which DSS maps to project
|
|
387
|
+
* variables). Tile types outside that set, including custom tiles and their
|
|
388
|
+
* `config` objects, remain opaque and are never parsed for references. The
|
|
389
|
+
* manifest is never mutated. Missing/malformed references are returned
|
|
390
|
+
* deterministically; a reference kind with no applicable tiles does not
|
|
391
|
+
* trigger its project API.
|
|
390
392
|
*/
|
|
391
393
|
async validateAppManifest(manifest, projectKey) {
|
|
392
394
|
const pk = this.resolveProjectKey(projectKey);
|
|
@@ -416,21 +418,19 @@ export class ApplicationsResource extends BaseResource {
|
|
|
416
418
|
if (tile["type"] === "SCENARIO_RUN") {
|
|
417
419
|
collectReferenceValue(tile["scenarioId"], propertyPath(tilePath, "scenarioId"), "scenarioId", "scenario", references, referenceIssues);
|
|
418
420
|
}
|
|
419
|
-
if (tile["type"] === "
|
|
420
|
-
|
|
421
|
-
if (!Object.prototype.hasOwnProperty.call(tile, key))
|
|
422
|
-
continue;
|
|
423
|
-
collectReferenceValue(tile[key], propertyPath(tilePath, key), key, "folder", references, referenceIssues);
|
|
424
|
-
}
|
|
421
|
+
if (tile["type"] === "DOWNLOAD_MANAGED_FOLDER_FILE") {
|
|
422
|
+
collectReferenceValue(tile["folderId"], propertyPath(tilePath, "folderId"), "folderId", "folder", references, referenceIssues);
|
|
425
423
|
}
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
for (let paramIndex = 0; paramIndex < params.length; paramIndex += 1) {
|
|
430
|
-
const param = params[paramIndex];
|
|
431
|
-
if (!isPlainRecord(param))
|
|
424
|
+
if (tile["type"] === "PROJECT_VARIABLES_EDIT") {
|
|
425
|
+
const params = tile["params"];
|
|
426
|
+
if (!Array.isArray(params))
|
|
432
427
|
continue;
|
|
433
|
-
|
|
428
|
+
for (let paramIndex = 0; paramIndex < params.length; paramIndex += 1) {
|
|
429
|
+
const param = params[paramIndex];
|
|
430
|
+
if (!isPlainRecord(param))
|
|
431
|
+
continue;
|
|
432
|
+
collectReferenceValue(param["name"], `${propertyPath(tilePath, "params")}[${paramIndex}]["name"]`, "name", "variable", references, referenceIssues);
|
|
433
|
+
}
|
|
434
434
|
}
|
|
435
435
|
}
|
|
436
436
|
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import type { DataikuClient } from "../client.js";
|
|
2
|
+
/** Never disguise an unexpected successful HTTP payload as an empty listing. */
|
|
3
|
+
export declare function requireArrayResponse<T>(value: unknown, operation: string): T[];
|
|
4
|
+
/** Validate identifiers without changing significant whitespace or encoding. */
|
|
5
|
+
export declare function requireNonEmpty(value: unknown, name: string): string;
|
|
2
6
|
export declare abstract class BaseResource {
|
|
3
7
|
protected readonly client: DataikuClient;
|
|
4
8
|
constructor(client: DataikuClient);
|
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
import { ClientValidationError, DataikuError, } from "../errors.js";
|
|
2
|
+
/** Never disguise an unexpected successful HTTP payload as an empty listing. */
|
|
3
|
+
export function requireArrayResponse(value, operation) {
|
|
4
|
+
if (!Array.isArray(value)) {
|
|
5
|
+
throw new DataikuError(200, "Unexpected Response", `${operation}: DSS did not return an array.`);
|
|
6
|
+
}
|
|
7
|
+
return value;
|
|
8
|
+
}
|
|
9
|
+
/** Validate identifiers without changing significant whitespace or encoding. */
|
|
10
|
+
export function requireNonEmpty(value, name) {
|
|
11
|
+
if (typeof value !== "string" || value.trim().length === 0) {
|
|
12
|
+
throw new ClientValidationError(`${name} must be a non-empty string.`, "validation_failed");
|
|
13
|
+
}
|
|
14
|
+
return value;
|
|
15
|
+
}
|
|
1
16
|
export class BaseResource {
|
|
2
17
|
client;
|
|
3
18
|
constructor(client) {
|
|
@@ -31,10 +31,15 @@ export declare class BundlesResource extends BaseResource {
|
|
|
31
31
|
/** List bundles exported from a project on the Design node. */
|
|
32
32
|
listExported(projectKey?: string): Promise<Record<string, unknown>[]>;
|
|
33
33
|
/**
|
|
34
|
-
* Create
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
34
|
+
* Create an exported Design-node bundle. The documented optional
|
|
35
|
+
* parameters are forwarded as query parameters: `releaseNotes` when
|
|
36
|
+
* provided, and `evaluateProjectStandardsChecks` (defaults to true,
|
|
37
|
+
* matching the official client which always sends it). The official
|
|
38
|
+
* client sends this PUT without a request body, and this resource
|
|
39
|
+
* mirrors that; DSS 15 additionally refuses re-exporting an existing
|
|
40
|
+
* bundle id ("Bundle <id> already exists"), so the documented
|
|
41
|
+
* "create or overwrite" claim does not hold — callers must delete the
|
|
42
|
+
* bundle first to replace it.
|
|
38
43
|
*/
|
|
39
44
|
exportBundle(bundleId: string, projectKey?: string, options?: BundleExportOptions): Promise<void>;
|
|
40
45
|
/** Delete an exported Design-node bundle. */
|
|
@@ -6,17 +6,22 @@ export class BundlesResource extends BaseResource {
|
|
|
6
6
|
return res.bundles ?? [];
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
|
-
* Create
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
9
|
+
* Create an exported Design-node bundle. The documented optional
|
|
10
|
+
* parameters are forwarded as query parameters: `releaseNotes` when
|
|
11
|
+
* provided, and `evaluateProjectStandardsChecks` (defaults to true,
|
|
12
|
+
* matching the official client which always sends it). The official
|
|
13
|
+
* client sends this PUT without a request body, and this resource
|
|
14
|
+
* mirrors that; DSS 15 additionally refuses re-exporting an existing
|
|
15
|
+
* bundle id ("Bundle <id> already exists"), so the documented
|
|
16
|
+
* "create or overwrite" claim does not hold — callers must delete the
|
|
17
|
+
* bundle first to replace it.
|
|
13
18
|
*/
|
|
14
19
|
async exportBundle(bundleId, projectKey, options = {}) {
|
|
15
20
|
const params = new URLSearchParams();
|
|
16
21
|
if (options.releaseNotes !== undefined)
|
|
17
22
|
params.set("releaseNotes", options.releaseNotes);
|
|
18
23
|
params.set("evaluateProjectStandardsChecks", String(options.evaluateProjectStandardsChecks ?? true));
|
|
19
|
-
await this.client.
|
|
24
|
+
await this.client.putVoidNoBody(`/public/api/projects/${this.enc(projectKey)}/bundles/exported/${encodeURIComponent(bundleId)}?${params.toString()}`);
|
|
20
25
|
}
|
|
21
26
|
/** Delete an exported Design-node bundle. */
|
|
22
27
|
async deleteExported(bundleId, projectKey) {
|
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
import type { DataikuClient } from "../client.js";
|
|
2
|
-
import type
|
|
2
|
+
import { type ConnectionSummary, type FutureState } from "../schemas.js";
|
|
3
3
|
import { BaseResource } from "./base.js";
|
|
4
|
+
/**
|
|
5
|
+
* Connection definition for admin create/update. `name` and `type` are
|
|
6
|
+
* required on create; params are connection-type specific per the docs and may
|
|
7
|
+
* carry credentials (e.g. `params.password`), which this SDK forwards verbatim
|
|
8
|
+
* over TLS and never logs.
|
|
9
|
+
*/
|
|
10
|
+
export interface ConnectionAdminInput extends Record<string, unknown> {
|
|
11
|
+
name?: string;
|
|
12
|
+
type?: string;
|
|
13
|
+
params?: Record<string, unknown>;
|
|
14
|
+
allowWrite?: boolean;
|
|
15
|
+
allowManagedDatasets?: boolean;
|
|
16
|
+
usableBy?: string;
|
|
17
|
+
allowedGroups?: string[];
|
|
18
|
+
}
|
|
4
19
|
export declare function resolveAdminManagedStorageConnection(client: DataikuClient, capability: "allowManagedDatasets" | "allowManagedFolders", preferredName?: string): Promise<string | undefined>;
|
|
5
20
|
export interface ConnectionSchemaListOptions {
|
|
6
21
|
connection: string;
|
|
@@ -31,4 +46,66 @@ export declare class ConnectionsResource extends BaseResource {
|
|
|
31
46
|
}): Promise<ConnectionSummary[]>;
|
|
32
47
|
schemas(opts: ConnectionSchemaListOptions): Promise<string[]>;
|
|
33
48
|
tables(opts: ConnectionTableListOptions): Promise<Record<string, unknown>>;
|
|
49
|
+
/**
|
|
50
|
+
* Lists all connections on the DSS instance (Admin required). Returns the
|
|
51
|
+
* documented dictionary of connection name to Connection object. Connection
|
|
52
|
+
* params may contain credentials (e.g. `params.password`); the SDK returns
|
|
53
|
+
* the server payload faithfully, and CLI output/plan layers redact them.
|
|
54
|
+
*/
|
|
55
|
+
adminList(): Promise<Record<string, Record<string, unknown>>>;
|
|
56
|
+
/** Gets one connection by name (Admin required). */
|
|
57
|
+
adminGet(connectionName: string): Promise<Record<string, unknown>>;
|
|
58
|
+
/**
|
|
59
|
+
* Creates a connection (Admin required). Body is the Connection definition
|
|
60
|
+
* (`{name, type, params, ...}`); params are connection-type specific per
|
|
61
|
+
* the docs. DSS answers 200 with an empty body.
|
|
62
|
+
*/
|
|
63
|
+
adminCreate(body: ConnectionAdminInput): Promise<Record<string, unknown>>;
|
|
64
|
+
/**
|
|
65
|
+
* Updates a connection (Admin required). Per the docs the body MUST have
|
|
66
|
+
* been obtained from a prior GET at the same URL; `type` and `name` may not
|
|
67
|
+
* be modified and undocumented attributes should pass through unchanged.
|
|
68
|
+
* DSS answers 204 with an empty body.
|
|
69
|
+
*/
|
|
70
|
+
adminUpdate(connectionName: string, body: ConnectionAdminInput): Promise<Record<string, unknown>>;
|
|
71
|
+
/**
|
|
72
|
+
* Deletes a connection (Admin required). Per the docs DSS performs no check
|
|
73
|
+
* that the connection is not in use by a dataset, so this is destructive.
|
|
74
|
+
*/
|
|
75
|
+
adminDelete(connectionName: string): Promise<{
|
|
76
|
+
deleted: string;
|
|
77
|
+
}>;
|
|
78
|
+
/**
|
|
79
|
+
* Tests whether a connection is available. Routed like the official
|
|
80
|
+
* dataikuapi Python client (`DSSConnection.test()`):
|
|
81
|
+
* `GET /connections/{connectionName}/test` — a pure availability test, not
|
|
82
|
+
* a settings read. Returns an error when testing is not supported for the
|
|
83
|
+
* connection type; the result carries `connectionOK` (true when available).
|
|
84
|
+
* The REST reference documents a same-URL "Test connection" variant of
|
|
85
|
+
* `GET /admin/connections/{name}`; this route is preferred because it
|
|
86
|
+
* cannot be confused with a settings retrieval.
|
|
87
|
+
*/
|
|
88
|
+
adminTest(connectionName: string): Promise<Record<string, unknown>>;
|
|
89
|
+
/**
|
|
90
|
+
* Prepares the import of selected SQL or Hive tables (WRITE_CONF required).
|
|
91
|
+
* `keys` entries carry `{connectionName, name}` plus optional
|
|
92
|
+
* `catalog`/`schema`; Hive keys use the `@virtual(hive-jdbc):...`
|
|
93
|
+
* connection-name form documented by DSS. Returns a future reference; poll
|
|
94
|
+
* with `client.futures` when the result is not inline.
|
|
95
|
+
*/
|
|
96
|
+
prepareTablesImport(opts: {
|
|
97
|
+
keys: Array<Record<string, unknown>>;
|
|
98
|
+
projectKey?: string;
|
|
99
|
+
}): Promise<FutureState>;
|
|
100
|
+
/**
|
|
101
|
+
* Performs an import from table candidates (WRITE_CONF required). At least
|
|
102
|
+
* one of `sqlImportCandidates` or `hiveImportCandidates` must be supplied;
|
|
103
|
+
* shapes follow the DSS SQL/Hive import candidate objects. Returns a future
|
|
104
|
+
* reference; poll with `client.futures`.
|
|
105
|
+
*/
|
|
106
|
+
executeTablesImport(opts: {
|
|
107
|
+
sqlImportCandidates?: Array<Record<string, unknown>>;
|
|
108
|
+
hiveImportCandidates?: Array<Record<string, unknown>>;
|
|
109
|
+
projectKey?: string;
|
|
110
|
+
}): Promise<FutureState>;
|
|
34
111
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ClientValidationError, } from "../errors.js";
|
|
2
|
+
import { FutureStateSchema, } from "../schemas.js";
|
|
3
|
+
import { BaseResource, requireNonEmpty, } from "./base.js";
|
|
2
4
|
// ---------------------------------------------------------------------------
|
|
3
5
|
// Helpers
|
|
4
6
|
// ---------------------------------------------------------------------------
|
|
@@ -9,6 +11,12 @@ function normalizeConnectionNames(value) {
|
|
|
9
11
|
.filter((v) => typeof v === "string" && v.length > 0)
|
|
10
12
|
.sort();
|
|
11
13
|
}
|
|
14
|
+
function validateConnectionAdminInput(body, method) {
|
|
15
|
+
if (body === null || body === undefined || typeof body !== "object" || Array.isArray(body)) {
|
|
16
|
+
throw new ClientValidationError(`${method}: body must be a Connection object.`);
|
|
17
|
+
}
|
|
18
|
+
return body;
|
|
19
|
+
}
|
|
12
20
|
export async function resolveAdminManagedStorageConnection(client, capability, preferredName) {
|
|
13
21
|
try {
|
|
14
22
|
const raw = await client.get("/public/api/admin/connections/");
|
|
@@ -156,4 +164,127 @@ export class ConnectionsResource extends BaseResource {
|
|
|
156
164
|
params.set("schemaName", opts.schema);
|
|
157
165
|
return this.client.get(`/public/api/projects/${encodeURIComponent(pk)}/datasets/tables-import/actions/list-tables?${params.toString()}`);
|
|
158
166
|
}
|
|
167
|
+
/* ----------------------------------------------------------------- */
|
|
168
|
+
/* Admin connection management (GET/POST/PUT/DELETE /admin/connections) */
|
|
169
|
+
/* ----------------------------------------------------------------- */
|
|
170
|
+
/**
|
|
171
|
+
* Lists all connections on the DSS instance (Admin required). Returns the
|
|
172
|
+
* documented dictionary of connection name to Connection object. Connection
|
|
173
|
+
* params may contain credentials (e.g. `params.password`); the SDK returns
|
|
174
|
+
* the server payload faithfully, and CLI output/plan layers redact them.
|
|
175
|
+
*/
|
|
176
|
+
async adminList() {
|
|
177
|
+
const raw = await this.client.get("/public/api/admin/connections");
|
|
178
|
+
if (raw === undefined || raw === null || typeof raw !== "object" || Array.isArray(raw)) {
|
|
179
|
+
return {};
|
|
180
|
+
}
|
|
181
|
+
return raw;
|
|
182
|
+
}
|
|
183
|
+
/** Gets one connection by name (Admin required). */
|
|
184
|
+
async adminGet(connectionName) {
|
|
185
|
+
const enc = requireNonEmpty(connectionName, "connectionName").trim();
|
|
186
|
+
return this.client.get(`/public/api/admin/connections/${encodeURIComponent(enc)}`);
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Creates a connection (Admin required). Body is the Connection definition
|
|
190
|
+
* (`{name, type, params, ...}`); params are connection-type specific per
|
|
191
|
+
* the docs. DSS answers 200 with an empty body.
|
|
192
|
+
*/
|
|
193
|
+
async adminCreate(body) {
|
|
194
|
+
const validated = validateConnectionAdminInput(body, "connections.adminCreate");
|
|
195
|
+
const raw = await this.client.post("/public/api/admin/connections", validated);
|
|
196
|
+
return raw !== undefined && raw !== null && typeof raw === "object" && !Array.isArray(raw)
|
|
197
|
+
? raw
|
|
198
|
+
: {};
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Updates a connection (Admin required). Per the docs the body MUST have
|
|
202
|
+
* been obtained from a prior GET at the same URL; `type` and `name` may not
|
|
203
|
+
* be modified and undocumented attributes should pass through unchanged.
|
|
204
|
+
* DSS answers 204 with an empty body.
|
|
205
|
+
*/
|
|
206
|
+
async adminUpdate(connectionName, body) {
|
|
207
|
+
const enc = requireNonEmpty(connectionName, "connectionName").trim();
|
|
208
|
+
const validated = validateConnectionAdminInput(body, "connections.adminUpdate");
|
|
209
|
+
const raw = await this.client.put(`/public/api/admin/connections/${encodeURIComponent(enc)}`, validated);
|
|
210
|
+
return raw !== undefined && raw !== null && typeof raw === "object" && !Array.isArray(raw)
|
|
211
|
+
? raw
|
|
212
|
+
: {};
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Deletes a connection (Admin required). Per the docs DSS performs no check
|
|
216
|
+
* that the connection is not in use by a dataset, so this is destructive.
|
|
217
|
+
*/
|
|
218
|
+
async adminDelete(connectionName) {
|
|
219
|
+
const enc = requireNonEmpty(connectionName, "connectionName").trim();
|
|
220
|
+
await this.client.del(`/public/api/admin/connections/${encodeURIComponent(enc)}`);
|
|
221
|
+
return { deleted: enc, };
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Tests whether a connection is available. Routed like the official
|
|
225
|
+
* dataikuapi Python client (`DSSConnection.test()`):
|
|
226
|
+
* `GET /connections/{connectionName}/test` — a pure availability test, not
|
|
227
|
+
* a settings read. Returns an error when testing is not supported for the
|
|
228
|
+
* connection type; the result carries `connectionOK` (true when available).
|
|
229
|
+
* The REST reference documents a same-URL "Test connection" variant of
|
|
230
|
+
* `GET /admin/connections/{name}`; this route is preferred because it
|
|
231
|
+
* cannot be confused with a settings retrieval.
|
|
232
|
+
*/
|
|
233
|
+
async adminTest(connectionName) {
|
|
234
|
+
const enc = requireNonEmpty(connectionName, "connectionName").trim();
|
|
235
|
+
const raw = await this.client.get(`/public/api/connections/${encodeURIComponent(enc)}/test`);
|
|
236
|
+
return raw !== undefined && raw !== null && typeof raw === "object" && !Array.isArray(raw)
|
|
237
|
+
? raw
|
|
238
|
+
: {};
|
|
239
|
+
}
|
|
240
|
+
/* ----------------------------------------------------------------- */
|
|
241
|
+
/* Tables import (prepare-from-keys / execute-from-candidates) */
|
|
242
|
+
/* ----------------------------------------------------------------- */
|
|
243
|
+
/**
|
|
244
|
+
* Prepares the import of selected SQL or Hive tables (WRITE_CONF required).
|
|
245
|
+
* `keys` entries carry `{connectionName, name}` plus optional
|
|
246
|
+
* `catalog`/`schema`; Hive keys use the `@virtual(hive-jdbc):...`
|
|
247
|
+
* connection-name form documented by DSS. Returns a future reference; poll
|
|
248
|
+
* with `client.futures` when the result is not inline.
|
|
249
|
+
*/
|
|
250
|
+
async prepareTablesImport(opts) {
|
|
251
|
+
if (!Array.isArray(opts?.keys) || opts.keys.length === 0
|
|
252
|
+
|| opts.keys.some((k) => k === null || typeof k !== "object" || Array.isArray(k))) {
|
|
253
|
+
throw new ClientValidationError("connections.prepareTablesImport: keys must be a non-empty array of key objects.");
|
|
254
|
+
}
|
|
255
|
+
for (const key of opts.keys) {
|
|
256
|
+
const connectionName = key["connectionName"];
|
|
257
|
+
const name = key["name"];
|
|
258
|
+
if (typeof connectionName !== "string" || connectionName.trim().length === 0
|
|
259
|
+
|| typeof name !== "string" || name.trim().length === 0) {
|
|
260
|
+
throw new ClientValidationError("connections.prepareTablesImport: each key must carry non-empty string connectionName and name per the DSS tables-import contract.");
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
const pk = this.resolveProjectKey(opts.projectKey);
|
|
264
|
+
const raw = await this.client.post(`/public/api/projects/${encodeURIComponent(pk)}/datasets/tables-import/actions/prepare-from-keys`, { keys: opts.keys, });
|
|
265
|
+
return this.client.safeParse(FutureStateSchema, raw, "connections.prepareTablesImport");
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Performs an import from table candidates (WRITE_CONF required). At least
|
|
269
|
+
* one of `sqlImportCandidates` or `hiveImportCandidates` must be supplied;
|
|
270
|
+
* shapes follow the DSS SQL/Hive import candidate objects. Returns a future
|
|
271
|
+
* reference; poll with `client.futures`.
|
|
272
|
+
*/
|
|
273
|
+
async executeTablesImport(opts) {
|
|
274
|
+
const sql = opts?.sqlImportCandidates;
|
|
275
|
+
const hive = opts?.hiveImportCandidates;
|
|
276
|
+
if ((sql !== undefined && (!Array.isArray(sql) || sql.length === 0))
|
|
277
|
+
|| (hive !== undefined && (!Array.isArray(hive) || hive.length === 0))
|
|
278
|
+
|| (sql === undefined && hive === undefined)) {
|
|
279
|
+
throw new ClientValidationError("connections.executeTablesImport: sqlImportCandidates or hiveImportCandidates must be a non-empty array (at least one required).");
|
|
280
|
+
}
|
|
281
|
+
const pk = this.resolveProjectKey(opts.projectKey);
|
|
282
|
+
const body = {};
|
|
283
|
+
if (sql !== undefined)
|
|
284
|
+
body.sqlImportCandidates = sql;
|
|
285
|
+
if (hive !== undefined)
|
|
286
|
+
body.hiveImportCandidates = hive;
|
|
287
|
+
const raw = await this.client.post(`/public/api/projects/${encodeURIComponent(pk)}/datasets/tables-import/actions/execute-from-candidates`, body);
|
|
288
|
+
return this.client.safeParse(FutureStateSchema, raw, "connections.executeTablesImport");
|
|
289
|
+
}
|
|
159
290
|
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { BaseResource } from "./base.js";
|
|
2
|
+
/**
|
|
3
|
+
* Data collections are instance-level curated groupings of DSS objects
|
|
4
|
+
* (datasets, saved models, agents, fine-tuned models, agent tools, semantic
|
|
5
|
+
* models) shared across projects.
|
|
6
|
+
*
|
|
7
|
+
* @see https://doc.dataiku.com/dss/api/15/rest/ (Data Collections section)
|
|
8
|
+
*/
|
|
9
|
+
export type DataCollectionObjectReferenceType = "DATASET" | "SAVED_MODEL" | "FINE_TUNED_MODEL" | "AGENT" | "AGENT_TOOL" | "SEMANTIC_MODEL" | (string & {});
|
|
10
|
+
export interface DataCollectionPermission extends Record<string, unknown> {
|
|
11
|
+
/** Name of the user this permission applies to (exclusive with group). */
|
|
12
|
+
user?: string;
|
|
13
|
+
/** Name of the group this permission applies to (exclusive with user). */
|
|
14
|
+
group?: string;
|
|
15
|
+
/** true if the permission grants administrator access. */
|
|
16
|
+
admin?: boolean;
|
|
17
|
+
/** true if the permission grants contributor access. */
|
|
18
|
+
write?: boolean;
|
|
19
|
+
/** true if the permission grants member access. */
|
|
20
|
+
read?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface DataCollectionSummary extends Record<string, unknown> {
|
|
23
|
+
/** Name of the collection. */
|
|
24
|
+
displayName?: string;
|
|
25
|
+
/** Color of the collection (#RRGBB syntax). */
|
|
26
|
+
color?: string | null;
|
|
27
|
+
/** The description of the collection (markdown). */
|
|
28
|
+
description?: string | null;
|
|
29
|
+
/** List of tags of the collection. */
|
|
30
|
+
tags?: string[] | null;
|
|
31
|
+
/** Id of the collection. */
|
|
32
|
+
id?: string;
|
|
33
|
+
/** Number of objects in the collection. */
|
|
34
|
+
itemCount?: number;
|
|
35
|
+
/** Number of datasets in the collection. */
|
|
36
|
+
datasetsCount?: number;
|
|
37
|
+
/** Number of saved models in the collection, excluding agents and fine tuned models. */
|
|
38
|
+
savedModelsCount?: number;
|
|
39
|
+
/** Number of fine tuned models in the collection. */
|
|
40
|
+
fineTunedModelsCount?: number;
|
|
41
|
+
/** Number of agents in the collection. */
|
|
42
|
+
agentsCount?: number;
|
|
43
|
+
/** Number of agent tools in the collection. */
|
|
44
|
+
agentToolsCount?: number;
|
|
45
|
+
/** Number of semantic models in the collection. */
|
|
46
|
+
semanticModelsCount?: number;
|
|
47
|
+
/** Timestamp of the last collection modification. */
|
|
48
|
+
lastModifiedOn?: number;
|
|
49
|
+
}
|
|
50
|
+
export interface DataCollectionSettings extends Record<string, unknown> {
|
|
51
|
+
/** Id of the collection. */
|
|
52
|
+
id?: string;
|
|
53
|
+
/** Name of the collection. */
|
|
54
|
+
displayName: string;
|
|
55
|
+
/** Color of the collection (#RRGGBB syntax). */
|
|
56
|
+
color?: string | null;
|
|
57
|
+
/** The description of the collection (markdown). */
|
|
58
|
+
description?: string | null;
|
|
59
|
+
/** List of tags of the collection. */
|
|
60
|
+
tags?: string[] | null;
|
|
61
|
+
/** List of permissions of the collection (READER, CONTRIBUTOR or ADMIN). */
|
|
62
|
+
permissions?: DataCollectionPermission[] | null;
|
|
63
|
+
}
|
|
64
|
+
export interface DataCollectionCreateRequest extends Omit<DataCollectionSettings, "id"> {
|
|
65
|
+
/**
|
|
66
|
+
* Id of the Collection (a random id is generated if not provided).
|
|
67
|
+
* Must match the [A-Za-z0-9]{8} server-side format when provided.
|
|
68
|
+
*/
|
|
69
|
+
id?: string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* An object inside a collection: a reference to a DSS object hosted by a
|
|
73
|
+
* project. The documented shape covers datasets; `type` accepts the other
|
|
74
|
+
* collection member kinds the instance may report.
|
|
75
|
+
*/
|
|
76
|
+
export interface DataCollectionObject extends Record<string, unknown> {
|
|
77
|
+
/** The type of this object (e.g. "DATASET"). */
|
|
78
|
+
type: DataCollectionObjectReferenceType;
|
|
79
|
+
/** The key of the project hosting the object. */
|
|
80
|
+
projectKey: string;
|
|
81
|
+
/** The id (name) of the object in its project. */
|
|
82
|
+
id: string;
|
|
83
|
+
}
|
|
84
|
+
export declare class DataCollectionsResource extends BaseResource {
|
|
85
|
+
/** List the collections on which the API key has READ privilege. */
|
|
86
|
+
list(): Promise<DataCollectionSummary[]>;
|
|
87
|
+
/**
|
|
88
|
+
* Create a collection. The creating user is added as an administrator.
|
|
89
|
+
* Requires the mayCreateDataCollections global permission. DSS returns
|
|
90
|
+
* `{ msg, id }`; the created id is surfaced to the caller.
|
|
91
|
+
*/
|
|
92
|
+
create(body: DataCollectionCreateRequest): Promise<{
|
|
93
|
+
msg?: string;
|
|
94
|
+
id?: string;
|
|
95
|
+
}>;
|
|
96
|
+
/**
|
|
97
|
+
* Get the settings of a collection. Requires READ on the collection; the
|
|
98
|
+
* permissions array is omitted unless the caller is an ADMIN.
|
|
99
|
+
*/
|
|
100
|
+
get(dataCollectionId: string): Promise<DataCollectionSettings>;
|
|
101
|
+
/**
|
|
102
|
+
* Update the settings of a collection. Only set a settings object obtained
|
|
103
|
+
* through {@link get}. Requires ADMIN on the collection.
|
|
104
|
+
*/
|
|
105
|
+
update(dataCollectionId: string, settings: DataCollectionSettings): Promise<DataCollectionSettings>;
|
|
106
|
+
/** Permanently delete a collection. Requires ADMIN on the collection. */
|
|
107
|
+
delete(dataCollectionId: string): Promise<void>;
|
|
108
|
+
/** List the objects in a collection. Requires READ on the collection. */
|
|
109
|
+
listObjects(dataCollectionId: string): Promise<DataCollectionObject[]>;
|
|
110
|
+
/**
|
|
111
|
+
* Add an object to a collection. Requires WRITE (Contributor) on the
|
|
112
|
+
* collection, the mayPublishToDataCollections global group permission, and
|
|
113
|
+
* publishToDataCollections on the project hosting the object (if relevant).
|
|
114
|
+
*/
|
|
115
|
+
addObject(dataCollectionId: string, object: DataCollectionObject): Promise<void>;
|
|
116
|
+
/** Remove a dataset from a collection. Requires WRITE on the collection. */
|
|
117
|
+
removeDataset(dataCollectionId: string, projectKey: string, datasetName: string): Promise<void>;
|
|
118
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { BaseResource, } from "./base.js";
|
|
2
|
+
export class DataCollectionsResource extends BaseResource {
|
|
3
|
+
/** List the collections on which the API key has READ privilege. */
|
|
4
|
+
async list() {
|
|
5
|
+
return this.client.get("/public/api/data-collections/");
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Create a collection. The creating user is added as an administrator.
|
|
9
|
+
* Requires the mayCreateDataCollections global permission. DSS returns
|
|
10
|
+
* `{ msg, id }`; the created id is surfaced to the caller.
|
|
11
|
+
*/
|
|
12
|
+
async create(body) {
|
|
13
|
+
return this.client.post("/public/api/data-collections/", body);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Get the settings of a collection. Requires READ on the collection; the
|
|
17
|
+
* permissions array is omitted unless the caller is an ADMIN.
|
|
18
|
+
*/
|
|
19
|
+
async get(dataCollectionId) {
|
|
20
|
+
return this.client.get(`/public/api/data-collections/${encodeURIComponent(dataCollectionId)}`);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Update the settings of a collection. Only set a settings object obtained
|
|
24
|
+
* through {@link get}. Requires ADMIN on the collection.
|
|
25
|
+
*/
|
|
26
|
+
async update(dataCollectionId, settings) {
|
|
27
|
+
return this.client.put(`/public/api/data-collections/${encodeURIComponent(dataCollectionId)}`, settings);
|
|
28
|
+
}
|
|
29
|
+
/** Permanently delete a collection. Requires ADMIN on the collection. */
|
|
30
|
+
async delete(dataCollectionId) {
|
|
31
|
+
await this.client.del(`/public/api/data-collections/${encodeURIComponent(dataCollectionId)}`);
|
|
32
|
+
}
|
|
33
|
+
/** List the objects in a collection. Requires READ on the collection. */
|
|
34
|
+
async listObjects(dataCollectionId) {
|
|
35
|
+
return this.client.get(`/public/api/data-collections/${encodeURIComponent(dataCollectionId)}/objects`);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Add an object to a collection. Requires WRITE (Contributor) on the
|
|
39
|
+
* collection, the mayPublishToDataCollections global group permission, and
|
|
40
|
+
* publishToDataCollections on the project hosting the object (if relevant).
|
|
41
|
+
*/
|
|
42
|
+
async addObject(dataCollectionId, object) {
|
|
43
|
+
await this.client.post(`/public/api/data-collections/${encodeURIComponent(dataCollectionId)}/objects`, object);
|
|
44
|
+
}
|
|
45
|
+
/** Remove a dataset from a collection. Requires WRITE on the collection. */
|
|
46
|
+
async removeDataset(dataCollectionId, projectKey, datasetName) {
|
|
47
|
+
await this.client.del(`/public/api/data-collections/${encodeURIComponent(dataCollectionId)}/objects/dataset/${encodeURIComponent(projectKey)}/${encodeURIComponent(datasetName)}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -17,6 +17,37 @@ export interface DatasetSchemaColumnInput {
|
|
|
17
17
|
type: string;
|
|
18
18
|
comment?: string;
|
|
19
19
|
}
|
|
20
|
+
/** Options for creating a managed dataset through the dedicated endpoint. */
|
|
21
|
+
export interface DatasetManagedCreateOptions {
|
|
22
|
+
/** Name of the new dataset (unique in the project). */
|
|
23
|
+
name: string;
|
|
24
|
+
/** Connection where the dataset is stored. */
|
|
25
|
+
connection: string;
|
|
26
|
+
/** When the connection accepts several dataset types, the type to use. */
|
|
27
|
+
typeOptionId?: string;
|
|
28
|
+
/** Optional identifier of a file format option (e.g. CSV_EXCEL_GZIP, PARQUET_HIVE). */
|
|
29
|
+
formatOptionId?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Partitioning option id. Use {@link DatasetManagedCreateOptions.copyPartitioningFrom}
|
|
32
|
+
* to build one from an existing dataset or folder reference.
|
|
33
|
+
*/
|
|
34
|
+
partitioningOptionId?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Copy partitioning from an existing dataset or folder instead of passing a
|
|
37
|
+
* raw `partitioningOptionId`. `type` defaults to `DATASET` and may be
|
|
38
|
+
* `FOLDER`.
|
|
39
|
+
*/
|
|
40
|
+
copyPartitioningFrom?: {
|
|
41
|
+
ref: string;
|
|
42
|
+
type?: "DATASET" | "FOLDER";
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/** Result of creating a managed dataset (the endpoint answers 204 with no body). */
|
|
46
|
+
export interface DatasetManagedCreateResult {
|
|
47
|
+
datasetName: string;
|
|
48
|
+
projectKey: string;
|
|
49
|
+
creationSettings: Record<string, unknown>;
|
|
50
|
+
}
|
|
20
51
|
export interface DatasetCloneOptions {
|
|
21
52
|
projectKey?: string;
|
|
22
53
|
path?: string;
|
|
@@ -120,6 +151,44 @@ export declare class DatasetsResource extends BaseResource {
|
|
|
120
151
|
}>;
|
|
121
152
|
/** Get dataset metadata (tags, custom fields, checklists). */
|
|
122
153
|
metadata(datasetName: string, projectKey?: string): Promise<Record<string, unknown>>;
|
|
154
|
+
/**
|
|
155
|
+
* Replace dataset metadata with the given object (faithful PUT per the DSS
|
|
156
|
+
* API contract: the caller GETs the metadata, edits it, and PUTs the full
|
|
157
|
+
* object back — no partial merge is applied client-side). `label`,
|
|
158
|
+
* `description`, `tags`, and `custom` are the documented writable fields;
|
|
159
|
+
* any additional server-provided metadata fields present in the object are
|
|
160
|
+
* preserved verbatim.
|
|
161
|
+
*/
|
|
162
|
+
updateMetadata(datasetName: string, metadata: Record<string, unknown>, projectKey?: string): Promise<Record<string, unknown>>;
|
|
163
|
+
/**
|
|
164
|
+
* Create a managed dataset through the dedicated
|
|
165
|
+
* `POST /projects/{projectKey}/datasets/managed` endpoint. DSS handles the
|
|
166
|
+
* format/storage details: you select the name, the connection, and optional
|
|
167
|
+
* type/format/partitioning options. The endpoint answers `204` with no
|
|
168
|
+
* body; the returned settings echo what was sent.
|
|
169
|
+
*/
|
|
170
|
+
createManaged(opts: DatasetManagedCreateOptions, projectKey?: string): Promise<DatasetManagedCreateResult>;
|
|
171
|
+
/**
|
|
172
|
+
* Get the full info object for a dataset (type, parameters, last build
|
|
173
|
+
* information, schema, etc.). The server returns a complex opaque object;
|
|
174
|
+
* it is surfaced without validation.
|
|
175
|
+
*/
|
|
176
|
+
info(datasetName: string, projectKey?: string): Promise<Record<string, unknown>>;
|
|
177
|
+
/**
|
|
178
|
+
* Get the full column lineage (auto-computed and manual) of a column in
|
|
179
|
+
* this dataset. Relations with datasets from both local and foreign
|
|
180
|
+
* projects are included.
|
|
181
|
+
*
|
|
182
|
+
* Route per the official Python client:
|
|
183
|
+
* `GET /projects/{projectKey}/datasets/{datasetName}/column-lineage`
|
|
184
|
+
* with query `columnName` (required) and `maxDatasetCount` (optional,
|
|
185
|
+
* positive integer — the docs page renders a merged project-scoped path,
|
|
186
|
+
* but DSS's own client and route registry use this per-dataset form).
|
|
187
|
+
*/
|
|
188
|
+
getColumnLineage(datasetName: string, column: string, opts?: {
|
|
189
|
+
maxDatasetCount?: number;
|
|
190
|
+
projectKey?: string;
|
|
191
|
+
}): Promise<unknown>;
|
|
123
192
|
/**
|
|
124
193
|
* Download dataset rows as a gzipped (or .csv) file, capped at `limit` rows
|
|
125
194
|
* (default 100k). Returns the written path, the number of data rows written,
|