dataiku-sdk 3.6.1 → 3.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/README.md +14 -6
  2. package/bin/bun-version.js +14 -0
  3. package/bin/dss.js +11 -15
  4. package/dist/build-metadata.json +1 -1
  5. package/dist/packages/types/src/index.d.ts +114 -5
  6. package/dist/packages/types/src/index.js +75 -2
  7. package/dist/src/cli/coerce.d.ts +2 -0
  8. package/dist/src/cli/coerce.js +20 -16
  9. package/dist/src/cli/command-syntax.json +3369 -144
  10. package/dist/src/cli/commands/analysis.js +19 -1
  11. package/dist/src/cli/commands/bundle.js +22 -0
  12. package/dist/src/cli/commands/connection.js +26 -2
  13. package/dist/src/cli/commands/data-quality.js +33 -1
  14. package/dist/src/cli/commands/dataset.js +76 -9
  15. package/dist/src/cli/commands/discussion.js +15 -0
  16. package/dist/src/cli/commands/doctor.js +1 -1
  17. package/dist/src/cli/commands/flow-zone.js +241 -46
  18. package/dist/src/cli/commands/flow.d.ts +5 -0
  19. package/dist/src/cli/commands/flow.js +57 -0
  20. package/dist/src/cli/commands/future.js +8 -0
  21. package/dist/src/cli/commands/index.js +6 -0
  22. package/dist/src/cli/commands/job.js +44 -6
  23. package/dist/src/cli/commands/metrics.js +21 -1
  24. package/dist/src/cli/commands/ml-task.d.ts +5 -0
  25. package/dist/src/cli/commands/ml-task.js +86 -16
  26. package/dist/src/cli/commands/mlflow.d.ts +11 -0
  27. package/dist/src/cli/commands/mlflow.js +121 -0
  28. package/dist/src/cli/commands/plugin.js +5 -11
  29. package/dist/src/cli/commands/project-deployer.js +70 -0
  30. package/dist/src/cli/commands/project-library.js +2 -5
  31. package/dist/src/cli/commands/project.js +8 -0
  32. package/dist/src/cli/commands/recipe.d.ts +13 -0
  33. package/dist/src/cli/commands/recipe.js +130 -7
  34. package/dist/src/cli/commands/saved-model.d.ts +1 -1
  35. package/dist/src/cli/commands/saved-model.js +9 -76
  36. package/dist/src/cli/commands/streaming-endpoint.js +30 -1
  37. package/dist/src/cli/commands/webapp.js +8 -0
  38. package/dist/src/cli/commands/wiki.js +78 -0
  39. package/dist/src/cli/commands/workspace.js +8 -0
  40. package/dist/src/cli/contract.d.ts +16 -15
  41. package/dist/src/cli/contract.js +150 -3407
  42. package/dist/src/cli/doctor.d.ts +13 -0
  43. package/dist/src/cli/doctor.js +43 -1
  44. package/dist/src/cli/flags.d.ts +14 -1
  45. package/dist/src/cli/flags.js +106 -8
  46. package/dist/src/cli/helpers/app-successor.js +1 -2
  47. package/dist/src/cli/helpers/dataset.d.ts +12 -0
  48. package/dist/src/cli/helpers/dataset.js +36 -0
  49. package/dist/src/cli/helpers/documentation.d.ts +21 -0
  50. package/dist/src/cli/helpers/documentation.js +53 -0
  51. package/dist/src/cli/helpers/flow-zone.d.ts +21 -0
  52. package/dist/src/cli/helpers/flow-zone.js +144 -4
  53. package/dist/src/cli/helpers/trained-model.d.ts +26 -0
  54. package/dist/src/cli/helpers/trained-model.js +144 -0
  55. package/dist/src/cli/list-output.d.ts +7 -0
  56. package/dist/src/cli/list-output.js +77 -0
  57. package/dist/src/cli/list-shapes.d.ts +21 -0
  58. package/dist/src/cli/list-shapes.js +111 -0
  59. package/dist/src/cli/output-schemas.d.ts +0 -14
  60. package/dist/src/cli/output-schemas.js +4 -7
  61. package/dist/src/cli/output.d.ts +0 -1
  62. package/dist/src/cli/output.js +33 -19
  63. package/dist/src/cli/plans.d.ts +14 -0
  64. package/dist/src/cli/plans.js +3740 -0
  65. package/dist/src/cli/types.d.ts +2 -0
  66. package/dist/src/cli/usage.d.ts +7 -0
  67. package/dist/src/cli/usage.js +20 -1
  68. package/dist/src/cli/version.d.ts +2 -2
  69. package/dist/src/cli/version.js +2 -2
  70. package/dist/src/cli.js +137 -115
  71. package/dist/src/client.d.ts +52 -43
  72. package/dist/src/client.js +267 -96
  73. package/dist/src/errors.d.ts +22 -2
  74. package/dist/src/errors.js +49 -50
  75. package/dist/src/generated/action-output-schemas.json +345 -89
  76. package/dist/src/index.d.ts +5 -1
  77. package/dist/src/index.js +3 -0
  78. package/dist/src/resources/analyses.d.ts +8 -0
  79. package/dist/src/resources/analyses.js +13 -1
  80. package/dist/src/resources/bundles.d.ts +34 -0
  81. package/dist/src/resources/bundles.js +67 -0
  82. package/dist/src/resources/connections.d.ts +9 -0
  83. package/dist/src/resources/connections.js +15 -0
  84. package/dist/src/resources/data-quality.d.ts +20 -0
  85. package/dist/src/resources/data-quality.js +30 -0
  86. package/dist/src/resources/dataset-create.d.ts +38 -0
  87. package/dist/src/resources/dataset-create.js +135 -0
  88. package/dist/src/resources/datasets.d.ts +46 -15
  89. package/dist/src/resources/datasets.js +120 -112
  90. package/dist/src/resources/discussions.d.ts +5 -0
  91. package/dist/src/resources/discussions.js +7 -0
  92. package/dist/src/resources/documentation.d.ts +25 -0
  93. package/dist/src/resources/documentation.js +16 -0
  94. package/dist/src/resources/flow-zones.d.ts +29 -3
  95. package/dist/src/resources/flow-zones.js +53 -3
  96. package/dist/src/resources/flow.d.ts +48 -0
  97. package/dist/src/resources/flow.js +65 -0
  98. package/dist/src/resources/futures.d.ts +23 -0
  99. package/dist/src/resources/futures.js +32 -0
  100. package/dist/src/resources/jobs.d.ts +34 -0
  101. package/dist/src/resources/jobs.js +170 -3
  102. package/dist/src/resources/metrics.d.ts +10 -0
  103. package/dist/src/resources/metrics.js +10 -0
  104. package/dist/src/resources/ml-tasks.d.ts +65 -2
  105. package/dist/src/resources/ml-tasks.js +102 -28
  106. package/dist/src/resources/mlflow-extension.d.ts +73 -0
  107. package/dist/src/resources/mlflow-extension.js +105 -0
  108. package/dist/src/resources/projects.d.ts +15 -0
  109. package/dist/src/resources/projects.js +18 -3
  110. package/dist/src/resources/recipe-create.d.ts +79 -0
  111. package/dist/src/resources/recipe-create.js +454 -0
  112. package/dist/src/resources/recipes.d.ts +28 -29
  113. package/dist/src/resources/recipes.js +201 -267
  114. package/dist/src/resources/saved-models.d.ts +10 -6
  115. package/dist/src/resources/saved-models.js +16 -14
  116. package/dist/src/resources/scenarios.js +8 -14
  117. package/dist/src/resources/sql.js +52 -13
  118. package/dist/src/resources/streaming-endpoints.d.ts +12 -0
  119. package/dist/src/resources/streaming-endpoints.js +15 -0
  120. package/dist/src/resources/trained-model.d.ts +60 -0
  121. package/dist/src/resources/trained-model.js +98 -0
  122. package/dist/src/resources/webapps.d.ts +8 -0
  123. package/dist/src/resources/webapps.js +10 -0
  124. package/dist/src/resources/wiki.d.ts +52 -1
  125. package/dist/src/resources/wiki.js +96 -0
  126. package/dist/src/resources/workspaces.d.ts +2 -0
  127. package/dist/src/resources/workspaces.js +4 -0
  128. package/dist/src/utils/flow-analysis.js +4 -0
  129. package/dist/src/utils/response-file.js +20 -9
  130. package/dist/src/utils/secret-sanitize.d.ts +7 -0
  131. package/dist/src/utils/secret-sanitize.js +46 -0
  132. package/package.json +25 -26
  133. package/plugin.json +1 -1
  134. package/skills/dataiku-dss/SKILL.md +1 -1
  135. package/skills/dataiku-dss/references/authentication.md +3 -1
  136. package/skills/dataiku-dss/references/coding.md +1 -0
  137. package/skills/dataiku-dss/references/discovery.md +4 -6
  138. package/skills/dataiku-dss/references/flow-maps.md +2 -2
  139. package/skills/dataiku-dss/references/troubleshooting.md +3 -2
@@ -46,6 +46,18 @@ export declare class BundlesResource extends BaseResource {
46
46
  deleteExported(bundleId: string, projectKey?: string): Promise<void>;
47
47
  /** Download an exported Design-node bundle archive. */
48
48
  downloadExportedArchive(bundleId: string, projectKey?: string): Promise<Response>;
49
+ /** Get an exported Design-node bundle's details (content summary, export manifest, changelog). */
50
+ getExported(bundleId: string, projectKey?: string): Promise<Record<string, unknown>>;
51
+ /**
52
+ * Create a project from a bundle on an Automation node (global admin):
53
+ * upload a local bundle zip (`filePath`) or use an archive already on the
54
+ * node host (`archivePath`). `projectFolderId` places the new project.
55
+ */
56
+ createProjectFromBundle(source: {
57
+ filePath: string;
58
+ } | {
59
+ archivePath: string;
60
+ }, projectFolderId?: string): Promise<Record<string, unknown> | undefined>;
49
61
  /**
50
62
  * Publish a Design-node bundle to the Project Deployer. The documented
51
63
  * optional `publishedProjectKey` parameter selects the published project
@@ -100,4 +112,26 @@ export declare class ProjectDeployerResource extends BaseResource {
100
112
  listInfras(): Promise<Record<string, unknown>[]>;
101
113
  /** Create a Project Deployer infrastructure. */
102
114
  createInfra(body: Record<string, unknown>): Promise<Record<string, unknown>>;
115
+ /** Get a Project Deployer infrastructure (basic info, deployments). */
116
+ getInfra(infraId: string): Promise<Record<string, unknown>>;
117
+ /** Get an infrastructure's settings (permissions, automation node, remappings). */
118
+ getInfraSettings(infraId: string): Promise<Record<string, unknown>>;
119
+ /** Save infrastructure settings obtained from `getInfraSettings`, edited. */
120
+ saveInfraSettings(infraId: string, body: Record<string, unknown>): Promise<void>;
121
+ /** Delete an infrastructure no deployment uses. */
122
+ deleteInfra(infraId: string): Promise<void>;
123
+ /** List the Project Deployer stages (Development, Test, Production, ...). */
124
+ listStages(): Promise<Record<string, unknown>[]>;
125
+ /** Get a deployment's settings (infra, bundle, remappings). */
126
+ getDeploymentSettings(deploymentId: string): Promise<Record<string, unknown>>;
127
+ /** Governance status of the deployment's bundle (or `bundleId`'s): messages on whether it may deploy. */
128
+ getGovernanceStatus(deploymentId: string, bundleId?: string): Promise<Record<string, unknown>>;
129
+ /** Delete a published project no deployment uses. */
130
+ deleteProject(publishedProjectKey: string): Promise<void>;
131
+ /** Get a published project's settings (permissions, owner). */
132
+ getProjectSettings(publishedProjectKey: string): Promise<Record<string, unknown>>;
133
+ /** Save published project settings obtained from `getProjectSettings`, edited. */
134
+ saveProjectSettings(publishedProjectKey: string, body: Record<string, unknown>): Promise<void>;
135
+ /** Delete a bundle of a published project that no deployment uses. */
136
+ deleteBundle(publishedProjectKey: string, bundleId: string): Promise<void>;
103
137
  }
@@ -31,6 +31,28 @@ export class BundlesResource extends BaseResource {
31
31
  async downloadExportedArchive(bundleId, projectKey) {
32
32
  return this.client.stream(`/public/api/projects/${this.enc(projectKey)}/bundles/exported/${encodeURIComponent(bundleId)}/archive`);
33
33
  }
34
+ /** Get an exported Design-node bundle's details (content summary, export manifest, changelog). */
35
+ async getExported(bundleId, projectKey) {
36
+ return this.client.get(`/public/api/projects/${this.enc(projectKey)}/bundles/exported/${encodeURIComponent(bundleId)}`);
37
+ }
38
+ /**
39
+ * Create a project from a bundle on an Automation node (global admin):
40
+ * upload a local bundle zip (`filePath`) or use an archive already on the
41
+ * node host (`archivePath`). `projectFolderId` places the new project.
42
+ */
43
+ async createProjectFromBundle(source, projectFolderId) {
44
+ const query = new URLSearchParams();
45
+ if ("archivePath" in source)
46
+ query.set("archivePath", source.archivePath);
47
+ if (projectFolderId)
48
+ query.set("projectFolderId", projectFolderId);
49
+ const suffix = query.size > 0 ? `?${query}` : "";
50
+ if ("archivePath" in source) {
51
+ return this.client.post(`/public/api/projectsFromBundle/fromArchive${suffix}`);
52
+ }
53
+ await this.client.upload(`/public/api/projectsFromBundle/${suffix}`, source.filePath);
54
+ return undefined;
55
+ }
34
56
  /**
35
57
  * Publish a Design-node bundle to the Project Deployer. The documented
36
58
  * optional `publishedProjectKey` parameter selects the published project
@@ -135,4 +157,49 @@ export class ProjectDeployerResource extends BaseResource {
135
157
  async createInfra(body) {
136
158
  return this.client.post("/public/api/project-deployer/infras", body);
137
159
  }
160
+ /** Get a Project Deployer infrastructure (basic info, deployments). */
161
+ async getInfra(infraId) {
162
+ return this.client.get(`/public/api/project-deployer/infras/${encodeURIComponent(infraId)}`);
163
+ }
164
+ /** Get an infrastructure's settings (permissions, automation node, remappings). */
165
+ async getInfraSettings(infraId) {
166
+ return this.client.get(`/public/api/project-deployer/infras/${encodeURIComponent(infraId)}/settings`);
167
+ }
168
+ /** Save infrastructure settings obtained from `getInfraSettings`, edited. */
169
+ async saveInfraSettings(infraId, body) {
170
+ await this.client.putVoid(`/public/api/project-deployer/infras/${encodeURIComponent(infraId)}/settings`, body);
171
+ }
172
+ /** Delete an infrastructure no deployment uses. */
173
+ async deleteInfra(infraId) {
174
+ await this.client.del(`/public/api/project-deployer/infras/${encodeURIComponent(infraId)}`);
175
+ }
176
+ /** List the Project Deployer stages (Development, Test, Production, ...). */
177
+ async listStages() {
178
+ return this.client.get("/public/api/project-deployer/stages");
179
+ }
180
+ /** Get a deployment's settings (infra, bundle, remappings). */
181
+ async getDeploymentSettings(deploymentId) {
182
+ return this.client.get(`/public/api/project-deployer/deployments/${encodeURIComponent(deploymentId)}/settings`);
183
+ }
184
+ /** Governance status of the deployment's bundle (or `bundleId`'s): messages on whether it may deploy. */
185
+ async getGovernanceStatus(deploymentId, bundleId) {
186
+ const query = bundleId ? `?bundleId=${encodeURIComponent(bundleId)}` : "";
187
+ return this.client.get(`/public/api/project-deployer/deployments/${encodeURIComponent(deploymentId)}/governance-status${query}`);
188
+ }
189
+ /** Delete a published project no deployment uses. */
190
+ async deleteProject(publishedProjectKey) {
191
+ await this.client.del(`/public/api/project-deployer/projects/${encodeURIComponent(publishedProjectKey)}`);
192
+ }
193
+ /** Get a published project's settings (permissions, owner). */
194
+ async getProjectSettings(publishedProjectKey) {
195
+ return this.client.get(`/public/api/project-deployer/projects/${encodeURIComponent(publishedProjectKey)}/settings`);
196
+ }
197
+ /** Save published project settings obtained from `getProjectSettings`, edited. */
198
+ async saveProjectSettings(publishedProjectKey, body) {
199
+ await this.client.putVoid(`/public/api/project-deployer/projects/${encodeURIComponent(publishedProjectKey)}/settings`, body);
200
+ }
201
+ /** Delete a bundle of a published project that no deployment uses. */
202
+ async deleteBundle(publishedProjectKey, bundleId) {
203
+ await this.client.del(`/public/api/project-deployer/projects/${encodeURIComponent(publishedProjectKey)}/bundles/${encodeURIComponent(bundleId)}`);
204
+ }
138
205
  }
@@ -55,6 +55,15 @@ export declare class ConnectionsResource extends BaseResource {
55
55
  adminList(): Promise<Record<string, Record<string, unknown>>>;
56
56
  /** Gets one connection by name (Admin required). */
57
57
  adminGet(connectionName: string): Promise<Record<string, unknown>>;
58
+ /**
59
+ * Reads one connection's usage view (no admin privilege required): the
60
+ * non-admin Python-client route `GET /connections/{name}/info`
61
+ * (`DSSConnection.get_info()`). Works for every connection the key can
62
+ * query, where the admin definition GET answers 403 for non-admin keys.
63
+ * Returns `{type, params, credentialsMode, ...}` per the server payload;
64
+ * CLI output layers redact credential-bearing params.
65
+ */
66
+ info(connectionName: string): Promise<Record<string, unknown>>;
58
67
  /**
59
68
  * Creates a connection (Admin required). Body is the Connection definition
60
69
  * (`{name, type, params, ...}`); params are connection-type specific per
@@ -185,6 +185,21 @@ export class ConnectionsResource extends BaseResource {
185
185
  const enc = requireNonEmpty(connectionName, "connectionName").trim();
186
186
  return this.client.get(`/public/api/admin/connections/${encodeURIComponent(enc)}`);
187
187
  }
188
+ /**
189
+ * Reads one connection's usage view (no admin privilege required): the
190
+ * non-admin Python-client route `GET /connections/{name}/info`
191
+ * (`DSSConnection.get_info()`). Works for every connection the key can
192
+ * query, where the admin definition GET answers 403 for non-admin keys.
193
+ * Returns `{type, params, credentialsMode, ...}` per the server payload;
194
+ * CLI output layers redact credential-bearing params.
195
+ */
196
+ async info(connectionName) {
197
+ const enc = requireNonEmpty(connectionName, "connectionName").trim();
198
+ const raw = await this.client.get(`/public/api/connections/${encodeURIComponent(enc)}/info`);
199
+ return raw !== undefined && raw !== null && typeof raw === "object" && !Array.isArray(raw)
200
+ ? raw
201
+ : {};
202
+ }
188
203
  /**
189
204
  * Creates a connection (Admin required). Body is the Connection definition
190
205
  * (`{name, type, params, ...}`); params are connection-type specific per
@@ -51,4 +51,24 @@ export declare class DataQualityResource extends BaseResource {
51
51
  computeRulesAndWait(datasetName: string, opts?: DataQualityComputeAndWaitOptions): Promise<FutureWaitResult>;
52
52
  projectStatus(opts?: DataQualityProjectStatusOptions): Promise<DataQualityProjectStatus>;
53
53
  projectTimeline(opts?: DataQualityProjectTimelineOptions): Promise<DataQualityTimeline>;
54
+ /**
55
+ * Current Data Quality status of every monitored project the caller can
56
+ * read (GET /data-quality/status), keyed by project key.
57
+ */
58
+ instanceStatus(): Promise<Record<string, unknown>>;
59
+ /**
60
+ * Last rule outcome per partition (POST /data-quality/get-partitions-status,
61
+ * `partitions` query parameter repeated as dataikuapi sends it). Without
62
+ * partitions this asks for `NP`: DSS 15 answers a parameterless call with a
63
+ * NullPointerException although the docs make it optional.
64
+ */
65
+ partitionsStatus(datasetName: string, opts?: DataQualityProjectOptions & {
66
+ partitions?: string[];
67
+ }): Promise<Record<string, unknown>>;
68
+ /**
69
+ * Delete rule computation history for one partition (`NP` for a
70
+ * non-partitioned dataset, `ALL` for every partition): DELETE
71
+ * /data-quality/history/{partition}.
72
+ */
73
+ deleteHistory(datasetName: string, opts?: DataQualityPartitionOptions): Promise<void>;
54
74
  }
@@ -119,4 +119,34 @@ export class DataQualityResource extends BaseResource {
119
119
  const raw = await this.client.get(`${projectPath(pk)}/timeline${queryString(params)}`);
120
120
  return this.client.safeParse(DataQualityTimelineSchema, raw, "dataQuality.projectTimeline");
121
121
  }
122
+ /**
123
+ * Current Data Quality status of every monitored project the caller can
124
+ * read (GET /data-quality/status), keyed by project key.
125
+ */
126
+ async instanceStatus() {
127
+ return this.client.get("/public/api/data-quality/status");
128
+ }
129
+ /**
130
+ * Last rule outcome per partition (POST /data-quality/get-partitions-status,
131
+ * `partitions` query parameter repeated as dataikuapi sends it). Without
132
+ * partitions this asks for `NP`: DSS 15 answers a parameterless call with a
133
+ * NullPointerException although the docs make it optional.
134
+ */
135
+ async partitionsStatus(datasetName, opts = {}) {
136
+ const pk = this.resolveProjectKey(opts.projectKey);
137
+ const params = new URLSearchParams();
138
+ const partitions = opts.partitions?.length ? opts.partitions : ["NP",];
139
+ for (const partition of partitions)
140
+ params.append("partitions", partition);
141
+ return this.client.post(`${dataQualityPath(pk, datasetName)}/get-partitions-status${queryString(params)}`);
142
+ }
143
+ /**
144
+ * Delete rule computation history for one partition (`NP` for a
145
+ * non-partitioned dataset, `ALL` for every partition): DELETE
146
+ * /data-quality/history/{partition}.
147
+ */
148
+ async deleteHistory(datasetName, opts = {}) {
149
+ const pk = this.resolveProjectKey(opts.projectKey);
150
+ await this.client.del(`${dataQualityPath(pk, datasetName)}/history/${encodeURIComponent(opts.partition ?? "NP")}`);
151
+ }
122
152
  }
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Reject dataset types the public API can create but never populate. An
3
+ * editable (`Inline`) dataset keeps its rows in a DSS config file that no
4
+ * public endpoint writes; without it every downstream build fails.
5
+ */
6
+ export declare function assertDatasetTypeCreatable(dsType: string): void;
7
+ /**
8
+ * Dataset types that read from a SQL connection. These are the types DSS
9
+ * detects schemas for through `testAndDetectSettings/externalSQL` (the list
10
+ * dataikuapi's `DSSDataset.autodetect_settings` uses).
11
+ */
12
+ export declare const SQL_DATASET_TYPES: readonly ["JDBC", "PostgreSQL", "MySQL", "Vertica", "Snowflake", "Redshift", "Greenplum", "Teradata", "Oracle", "SQLServer", "SAPHANA", "Netezza", "BigQuery", "Athena", "hiveserver2", "Synapse", "FabricWarehouse", "Databricks", "DatabricksLakebase"];
13
+ export declare function isSqlDatasetType(dsType: string): boolean;
14
+ /**
15
+ * Validate the SQL source options (`table`/`dbSchema`/`catalog`/`query`) of a
16
+ * dataset creation against its type. Shared by `dataset create`, its plan, and
17
+ * the SDK so every entry point rejects the same combinations.
18
+ */
19
+ export declare function assertSqlDatasetSource(dsType: string, source: {
20
+ table?: string;
21
+ dbSchema?: string;
22
+ catalog?: string;
23
+ query?: string;
24
+ }): void;
25
+ /** Wire body for POST /datasets/; shared with `dataset create --plan` so the plan matches the request. */
26
+ export declare function buildDatasetCreateBody(opts: {
27
+ projectKey: string;
28
+ datasetName: string;
29
+ connection?: string;
30
+ dsType: string;
31
+ table?: string;
32
+ dbSchema?: string;
33
+ catalog?: string;
34
+ query?: string;
35
+ formatType?: string;
36
+ formatParams?: Record<string, unknown>;
37
+ managed?: boolean;
38
+ }): Record<string, unknown>;
@@ -0,0 +1,135 @@
1
+ import { ClientValidationError, } from "../errors.js";
2
+ /**
3
+ * Reject dataset types the public API can create but never populate. An
4
+ * editable (`Inline`) dataset keeps its rows in a DSS config file that no
5
+ * public endpoint writes; without it every downstream build fails.
6
+ */
7
+ export function assertDatasetTypeCreatable(dsType) {
8
+ if (dsType.toLowerCase() !== "inline")
9
+ return;
10
+ throw new ClientValidationError("Inline (editable) datasets cannot be created here: the DSS public API cannot write their rows, and an Inline dataset without rows fails every downstream build (SourceDatasetNotReadyException). For a small static table, create an UploadedFiles dataset and upload a CSV with dss dataset upload-file, or write the rows from a python recipe into a managed dataset.", "validation_failed");
11
+ }
12
+ /**
13
+ * Dataset types that read from a SQL connection. These are the types DSS
14
+ * detects schemas for through `testAndDetectSettings/externalSQL` (the list
15
+ * dataikuapi's `DSSDataset.autodetect_settings` uses).
16
+ */
17
+ export const SQL_DATASET_TYPES = [
18
+ "JDBC",
19
+ "PostgreSQL",
20
+ "MySQL",
21
+ "Vertica",
22
+ "Snowflake",
23
+ "Redshift",
24
+ "Greenplum",
25
+ "Teradata",
26
+ "Oracle",
27
+ "SQLServer",
28
+ "SAPHANA",
29
+ "Netezza",
30
+ "BigQuery",
31
+ "Athena",
32
+ "hiveserver2",
33
+ "Synapse",
34
+ "FabricWarehouse",
35
+ "Databricks",
36
+ "DatabricksLakebase",
37
+ ];
38
+ export function isSqlDatasetType(dsType) {
39
+ const lower = dsType.toLowerCase();
40
+ return SQL_DATASET_TYPES.some((type) => type.toLowerCase() === lower);
41
+ }
42
+ /**
43
+ * Validate the SQL source options (`table`/`dbSchema`/`catalog`/`query`) of a
44
+ * dataset creation against its type. Shared by `dataset create`, its plan, and
45
+ * the SDK so every entry point rejects the same combinations.
46
+ */
47
+ export function assertSqlDatasetSource(dsType, source) {
48
+ const hasTable = source.table !== undefined;
49
+ const hasQuery = source.query !== undefined;
50
+ if (hasTable && hasQuery) {
51
+ throw new ClientValidationError("Pass either a table or a query for a SQL dataset, not both.", "conflicting_input_sources");
52
+ }
53
+ if (!hasTable && (source.dbSchema !== undefined || source.catalog !== undefined)) {
54
+ throw new ClientValidationError("A schema or catalog only applies together with a table.", "validation_failed", "Add --table, or drop --schema/--catalog (a query names its own tables).");
55
+ }
56
+ if (hasTable && source.table.trim() === "") {
57
+ throw new ClientValidationError("table must be a non-empty table name.", "invalid_flag_value");
58
+ }
59
+ if (hasQuery && source.query.trim() === "") {
60
+ throw new ClientValidationError("query must be a non-empty SQL query.", "invalid_flag_value");
61
+ }
62
+ if ((hasTable || hasQuery) && !isSqlDatasetType(dsType)) {
63
+ throw new ClientValidationError(`A table or query only applies to SQL dataset types, not "${dsType}".`, "validation_failed", `SQL types: ${SQL_DATASET_TYPES.join(", ")}.`);
64
+ }
65
+ }
66
+ /** Wire body for POST /datasets/; shared with `dataset create --plan` so the plan matches the request. */
67
+ export function buildDatasetCreateBody(opts) {
68
+ assertDatasetTypeCreatable(opts.dsType);
69
+ if (opts.dsType.toLowerCase() === "uploadedfiles") {
70
+ return {
71
+ projectKey: opts.projectKey,
72
+ name: opts.datasetName,
73
+ type: opts.dsType,
74
+ params: opts.connection ? { uploadConnection: opts.connection, } : {},
75
+ };
76
+ }
77
+ if (!opts.connection) {
78
+ throw new ClientValidationError("connection is required unless dsType is UploadedFiles.");
79
+ }
80
+ if (opts.query !== undefined) {
81
+ if (opts.table !== undefined) {
82
+ throw new ClientValidationError("Pass either a table or a query for a SQL dataset, not both.", "conflicting_input_sources");
83
+ }
84
+ if (opts.query.trim() === "") {
85
+ throw new ClientValidationError("query must be a non-empty SQL query.", "invalid_flag_value");
86
+ }
87
+ return {
88
+ projectKey: opts.projectKey,
89
+ name: opts.datasetName,
90
+ type: opts.dsType,
91
+ params: { connection: opts.connection, mode: "query", query: opts.query, },
92
+ managed: opts.managed ?? false,
93
+ };
94
+ }
95
+ if (opts.table) {
96
+ const params = {
97
+ connection: opts.connection,
98
+ mode: "table",
99
+ table: opts.table,
100
+ };
101
+ if (opts.dbSchema)
102
+ params.schema = opts.dbSchema;
103
+ if (opts.catalog)
104
+ params.catalog = opts.catalog;
105
+ return {
106
+ projectKey: opts.projectKey,
107
+ name: opts.datasetName,
108
+ type: opts.dsType,
109
+ params,
110
+ managed: opts.managed ?? false,
111
+ };
112
+ }
113
+ return {
114
+ projectKey: opts.projectKey,
115
+ name: opts.datasetName,
116
+ type: opts.dsType,
117
+ params: {
118
+ connection: opts.connection,
119
+ path: `/dataiku/${opts.projectKey}/${opts.datasetName}`,
120
+ },
121
+ formatType: opts.formatType ?? "csv",
122
+ formatParams: opts.formatParams ?? {
123
+ style: "excel",
124
+ charset: "utf8",
125
+ separator: "\t",
126
+ quoteChar: '"',
127
+ escapeChar: "\\",
128
+ dateSerializationFormat: "ISO",
129
+ arrayMapFormat: "json",
130
+ parseHeaderRow: true,
131
+ compress: "gz",
132
+ },
133
+ managed: opts.managed ?? true,
134
+ };
135
+ }
@@ -1,5 +1,12 @@
1
1
  import { BaseResource } from "./base.js";
2
2
  import type { DatasetCreateOptions, DatasetDetails, DatasetSchema, DatasetSummary } from "../schemas.js";
3
+ /** Column and partition selection for dataset data reads (POST /data body). */
4
+ export interface DatasetDataSelection {
5
+ /** Only these columns, in this order. */
6
+ columns?: string[];
7
+ /** DSS partition spec, e.g. `2026-01` or `2026-01,2026-02`. */
8
+ partitions?: string;
9
+ }
3
10
  export interface DatasetBuildValidationResult {
4
11
  valid: boolean;
5
12
  datasetName: string;
@@ -48,6 +55,18 @@ export interface DatasetManagedCreateResult {
48
55
  projectKey: string;
49
56
  creationSettings: Record<string, unknown>;
50
57
  }
58
+ /** Outcome of {@link DatasetsResource.detectSqlSchema}. */
59
+ export interface DatasetSqlSchemaDetection {
60
+ /** True when DSS suggested a schema and it was stored on the dataset. */
61
+ detected: boolean;
62
+ /** Stored columns (empty when detection failed). */
63
+ columns: Array<{
64
+ name: string;
65
+ type: string;
66
+ }>;
67
+ /** Why detection failed. */
68
+ error?: string;
69
+ }
51
70
  export interface DatasetCloneOptions {
52
71
  projectKey?: string;
53
72
  path?: string;
@@ -89,19 +108,6 @@ export interface UploadDatasetFileResult {
89
108
  export declare function validateStreamColumns(headerRow: string[], expectedColumns: {
90
109
  name: string;
91
110
  }[]): string[];
92
- /** Wire body for POST /datasets/; shared with `dataset create --plan` so the plan matches the request. */
93
- export declare function buildDatasetCreateBody(opts: {
94
- projectKey: string;
95
- datasetName: string;
96
- connection?: string;
97
- dsType: string;
98
- table?: string;
99
- dbSchema?: string;
100
- catalog?: string;
101
- formatType?: string;
102
- formatParams?: Record<string, unknown>;
103
- managed?: boolean;
104
- }): Record<string, unknown>;
105
111
  export declare function buildDatasetCloneSettings(source: DatasetDetails, targetName: string, projectKey: string, opts: DatasetCloneOptions): Record<string, unknown>;
106
112
  export declare class DatasetsResource extends BaseResource {
107
113
  /** List all datasets in a project. */
@@ -112,11 +118,26 @@ export declare class DatasetsResource extends BaseResource {
112
118
  schema(datasetName: string, projectKey?: string): Promise<DatasetSchema>;
113
119
  /** Replace dataset schema columns directly through the schema endpoint. */
114
120
  updateSchema(datasetName: string, columns: DatasetSchemaColumnInput[], projectKey?: string): Promise<void>;
121
+ /**
122
+ * Detect the schema of a SQL dataset (table or query mode) with DSS and
123
+ * store it: `POST /actions/testAndDetectSettings/externalSQL` (what
124
+ * dataikuapi's `autodetect_settings` calls), then `PUT /schema` with the
125
+ * suggested schema. DSS reports connection, table, and query problems in the
126
+ * response body (HTTP 200), so a failed detection is returned with
127
+ * `detected: false` and the reason instead of thrown.
128
+ */
129
+ detectSqlSchema(datasetName: string, projectKey?: string): Promise<DatasetSqlSchemaDetection>;
115
130
  /**
116
131
  * Get the raw dataset schema object exactly as the DSS schema endpoint
117
132
  * returns it, without schema validation — used for deterministic comparison.
118
133
  */
119
134
  getSchemaObject(datasetName: string, projectKey?: string): Promise<unknown>;
135
+ /**
136
+ * TSV data stream of at most `limit` rows. A column or partition selection
137
+ * uses the documented POST variant of the data endpoint (body `columns`,
138
+ * `partitions`, `format`, `sampling`); otherwise the GET endpoint.
139
+ */
140
+ private dataStream;
120
141
  /**
121
142
  * Preview dataset rows as structured data: column names plus row arrays,
122
143
  * mirroring the sql query shape ({ columns, rows, rowCount }). Streams TSV
@@ -136,7 +157,7 @@ export declare class DatasetsResource extends BaseResource {
136
157
  name: string;
137
158
  }[];
138
159
  timeoutMs?: number;
139
- }): Promise<{
160
+ } & DatasetDataSelection): Promise<{
140
161
  columns: Array<{
141
162
  name: string;
142
163
  }>;
@@ -173,6 +194,16 @@ export declare class DatasetsResource extends BaseResource {
173
194
  * preserved verbatim.
174
195
  */
175
196
  updateMetadata(datasetName: string, metadata: Record<string, unknown>, projectKey?: string): Promise<Record<string, unknown>>;
197
+ /**
198
+ * Create or update the Hive table of an HDFS dataset so it matches the
199
+ * dataset schema (POST /actions/synchronizeHiveMetastore).
200
+ */
201
+ synchronizeHiveMetastore(datasetName: string, projectKey?: string): Promise<void>;
202
+ /**
203
+ * Update an HDFS dataset (path, schema, partitioning, format) from its
204
+ * Hive table (POST /actions/updateFromHive).
205
+ */
206
+ updateFromHive(datasetName: string, projectKey?: string): Promise<void>;
176
207
  /**
177
208
  * Create a managed dataset through the dedicated
178
209
  * `POST /projects/{projectKey}/datasets/managed` endpoint. DSS handles the
@@ -227,7 +258,7 @@ export declare class DatasetsResource extends BaseResource {
227
258
  limit?: number;
228
259
  /** Preserve exact cell bytes (no spreadsheet-safe formula neutralization), default false. */
229
260
  rawData?: boolean;
230
- }): Promise<{
261
+ } & DatasetDataSelection): Promise<{
231
262
  path: string;
232
263
  rows: number;
233
264
  truncated: boolean;