dataiku-sdk 0.1.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 (48) hide show
  1. package/bin/dss.js +2 -0
  2. package/dist/packages/types/src/index.d.ts +458 -0
  3. package/dist/packages/types/src/index.js +384 -0
  4. package/dist/src/cli.d.ts +2 -0
  5. package/dist/src/cli.js +689 -0
  6. package/dist/src/client.d.ts +89 -0
  7. package/dist/src/client.js +301 -0
  8. package/dist/src/errors.d.ts +29 -0
  9. package/dist/src/errors.js +141 -0
  10. package/dist/src/index.d.ts +20 -0
  11. package/dist/src/index.js +24 -0
  12. package/dist/src/resources/base.d.ts +7 -0
  13. package/dist/src/resources/base.js +12 -0
  14. package/dist/src/resources/code-envs.d.ts +8 -0
  15. package/dist/src/resources/code-envs.js +36 -0
  16. package/dist/src/resources/connections.d.ts +20 -0
  17. package/dist/src/resources/connections.js +77 -0
  18. package/dist/src/resources/datasets.d.ts +57 -0
  19. package/dist/src/resources/datasets.js +423 -0
  20. package/dist/src/resources/folders.d.ts +15 -0
  21. package/dist/src/resources/folders.js +58 -0
  22. package/dist/src/resources/jobs.d.ts +72 -0
  23. package/dist/src/resources/jobs.js +184 -0
  24. package/dist/src/resources/notebooks.d.ts +34 -0
  25. package/dist/src/resources/notebooks.js +75 -0
  26. package/dist/src/resources/projects.d.ts +38 -0
  27. package/dist/src/resources/projects.js +185 -0
  28. package/dist/src/resources/recipes.d.ts +35 -0
  29. package/dist/src/resources/recipes.js +281 -0
  30. package/dist/src/resources/scenarios.d.ts +26 -0
  31. package/dist/src/resources/scenarios.js +57 -0
  32. package/dist/src/resources/sql.d.ts +40 -0
  33. package/dist/src/resources/sql.js +40 -0
  34. package/dist/src/resources/variables.d.ts +10 -0
  35. package/dist/src/resources/variables.js +22 -0
  36. package/dist/src/schemas.d.ts +7 -0
  37. package/dist/src/schemas.js +6 -0
  38. package/dist/src/utils/deep-merge.d.ts +1 -0
  39. package/dist/src/utils/deep-merge.js +15 -0
  40. package/dist/src/utils/flow-map.d.ts +37 -0
  41. package/dist/src/utils/flow-map.js +296 -0
  42. package/dist/src/utils/pagination.d.ts +8 -0
  43. package/dist/src/utils/pagination.js +23 -0
  44. package/dist/src/utils/sanitize.d.ts +2 -0
  45. package/dist/src/utils/sanitize.js +16 -0
  46. package/package.json +47 -0
  47. package/packages/types/dist/index.d.ts +458 -0
  48. package/packages/types/dist/index.js +384 -0
@@ -0,0 +1,384 @@
1
+ import { Type, } from "@sinclair/typebox";
2
+ import { Value, } from "@sinclair/typebox/value";
3
+ // ---------------------------------------------------------------------------
4
+ // Runtime validation helper
5
+ // ---------------------------------------------------------------------------
6
+ /**
7
+ * Validate `data` against a TypeBox schema, throwing on structural mismatch.
8
+ * Uses Value.Assert so extra DSS fields (additionalProperties) are preserved.
9
+ */
10
+ export function parseSchema(schema, data) {
11
+ Value.Assert(schema, data);
12
+ return data;
13
+ }
14
+ /**
15
+ * Validate `data` against a TypeBox schema without throwing.
16
+ * Always returns the data (cast as T) — on mismatch, includes human-readable
17
+ * error strings so callers can warn instead of crash.
18
+ */
19
+ export function safeParseSchema(schema, data) {
20
+ if (Value.Check(schema, data)) {
21
+ return { success: true, data: data, };
22
+ }
23
+ const errors = [...Value.Errors(schema, data),].map((e) => `${e.path}: ${e.message} (got ${JSON.stringify(e.value)})`);
24
+ return { success: false, data: data, errors, };
25
+ }
26
+ // ---------------------------------------------------------------------------
27
+ // Projects
28
+ // ---------------------------------------------------------------------------
29
+ export const ProjectSummarySchema = Type.Object({
30
+ projectKey: Type.String(),
31
+ name: Type.String(),
32
+ shortDesc: Type.Optional(Type.String()),
33
+ }, { additionalProperties: true, });
34
+ export const ProjectDetailsSchema = Type.Object({
35
+ projectKey: Type.String(),
36
+ name: Type.String(),
37
+ shortDesc: Type.Optional(Type.String()),
38
+ projectStatus: Type.Optional(Type.String()),
39
+ ownerLogin: Type.Optional(Type.String()),
40
+ tags: Type.Optional(Type.Array(Type.String())),
41
+ versionTag: Type.Optional(Type.Object({
42
+ versionNumber: Type.Number(),
43
+ lastModifiedOn: Type.Number(),
44
+ }, { additionalProperties: true, })),
45
+ }, { additionalProperties: true, });
46
+ export const ProjectMetadataSchema = Type.Object({
47
+ label: Type.Optional(Type.String()),
48
+ shortDesc: Type.Optional(Type.String()),
49
+ description: Type.Optional(Type.String()),
50
+ tags: Type.Optional(Type.Array(Type.String())),
51
+ customFields: Type.Optional(Type.Record(Type.String(), Type.Unknown())),
52
+ checklists: Type.Optional(Type.Object({
53
+ checklists: Type.Optional(Type.Array(Type.Object({
54
+ title: Type.String(),
55
+ items: Type.Optional(Type.Array(Type.Object({
56
+ done: Type.Boolean(),
57
+ }, { additionalProperties: true, }))),
58
+ }, { additionalProperties: true, }))),
59
+ }, { additionalProperties: true, })),
60
+ }, { additionalProperties: true, });
61
+ // ---------------------------------------------------------------------------
62
+ // Datasets
63
+ // ---------------------------------------------------------------------------
64
+ export const DatasetSummarySchema = Type.Object({
65
+ name: Type.String(),
66
+ type: Type.Optional(Type.String()),
67
+ shortDesc: Type.Optional(Type.String()),
68
+ managed: Type.Optional(Type.Boolean()),
69
+ params: Type.Optional(Type.Object({
70
+ connection: Type.Optional(Type.String()),
71
+ schema: Type.Optional(Type.String()),
72
+ catalog: Type.Optional(Type.String()),
73
+ }, { additionalProperties: true, })),
74
+ }, { additionalProperties: true, });
75
+ export const DatasetSchemaSchema = Type.Object({
76
+ columns: Type.Array(Type.Object({
77
+ name: Type.String(),
78
+ type: Type.String(),
79
+ comment: Type.Optional(Type.String()),
80
+ }, { additionalProperties: true, })),
81
+ }, { additionalProperties: true, });
82
+ export const DatasetDetailsSchema = Type.Object({
83
+ name: Type.String(),
84
+ type: Type.Optional(Type.String()),
85
+ projectKey: Type.Optional(Type.String()),
86
+ managed: Type.Optional(Type.Boolean()),
87
+ params: Type.Optional(Type.Object({
88
+ connection: Type.Optional(Type.String()),
89
+ path: Type.Optional(Type.String()),
90
+ table: Type.Optional(Type.String()),
91
+ schema: Type.Optional(Type.String()),
92
+ catalog: Type.Optional(Type.String()),
93
+ folderSmartId: Type.Optional(Type.String()),
94
+ }, { additionalProperties: true, })),
95
+ formatType: Type.Optional(Type.String()),
96
+ formatParams: Type.Optional(Type.Object({
97
+ separator: Type.Optional(Type.String()),
98
+ charset: Type.Optional(Type.String()),
99
+ compress: Type.Optional(Type.String()),
100
+ }, { additionalProperties: true, })),
101
+ schema: Type.Optional(DatasetSchemaSchema),
102
+ tags: Type.Optional(Type.Array(Type.String())),
103
+ shortDesc: Type.Optional(Type.String()),
104
+ }, { additionalProperties: true, });
105
+ export const DatasetCreateOptionsSchema = Type.Object({
106
+ datasetName: Type.String(),
107
+ connection: Type.String(),
108
+ dsType: Type.Optional(Type.String()),
109
+ table: Type.Optional(Type.String()),
110
+ dbSchema: Type.Optional(Type.String()),
111
+ catalog: Type.Optional(Type.String()),
112
+ formatType: Type.Optional(Type.String()),
113
+ formatParams: Type.Optional(Type.Record(Type.String(), Type.Unknown())),
114
+ managed: Type.Optional(Type.Boolean()),
115
+ projectKey: Type.Optional(Type.String()),
116
+ });
117
+ // ---------------------------------------------------------------------------
118
+ // Recipes
119
+ // ---------------------------------------------------------------------------
120
+ export const RecipeSummarySchema = Type.Object({
121
+ name: Type.String(),
122
+ type: Type.Optional(Type.String()),
123
+ }, { additionalProperties: true, });
124
+ export const RecipeDetailsSchema = Type.Object({
125
+ name: Type.String(),
126
+ type: Type.Optional(Type.String()),
127
+ projectKey: Type.Optional(Type.String()),
128
+ inputs: Type.Optional(Type.Record(Type.String(), Type.Unknown())),
129
+ outputs: Type.Optional(Type.Record(Type.String(), Type.Unknown())),
130
+ params: Type.Optional(Type.Record(Type.String(), Type.Unknown())),
131
+ payload: Type.Optional(Type.String()),
132
+ versionTag: Type.Optional(Type.Object({
133
+ versionNumber: Type.Number(),
134
+ }, { additionalProperties: true, })),
135
+ neverBuilt: Type.Optional(Type.Boolean()),
136
+ }, { additionalProperties: true, });
137
+ export const RecipeCreateOptionsSchema = Type.Object({
138
+ type: Type.String(),
139
+ name: Type.Optional(Type.String()),
140
+ inputDatasets: Type.Optional(Type.Array(Type.String())),
141
+ outputDataset: Type.Optional(Type.String()),
142
+ inputs: Type.Optional(Type.Record(Type.String(), Type.Unknown())),
143
+ outputs: Type.Optional(Type.Record(Type.String(), Type.Unknown())),
144
+ payload: Type.Optional(Type.String()),
145
+ outputConnection: Type.Optional(Type.String()),
146
+ joinOn: Type.Optional(Type.Union([Type.String(), Type.Array(Type.String()),])),
147
+ joinType: Type.Optional(Type.String()),
148
+ projectKey: Type.Optional(Type.String()),
149
+ });
150
+ export const RecipeCreateResultSchema = Type.Object({
151
+ recipeName: Type.String(),
152
+ type: Type.String(),
153
+ createdDatasets: Type.Array(Type.String()),
154
+ joinConfigured: Type.Boolean(),
155
+ outputProvisioningFallbackUsed: Type.Boolean(),
156
+ });
157
+ // ---------------------------------------------------------------------------
158
+ // Jobs
159
+ // ---------------------------------------------------------------------------
160
+ export const JobSummarySchema = Type.Object({
161
+ def: Type.Optional(Type.Object({
162
+ id: Type.Optional(Type.String()),
163
+ type: Type.Optional(Type.String()),
164
+ }, { additionalProperties: true, })),
165
+ baseStatus: Type.Optional(Type.Object({
166
+ def: Type.Optional(Type.Object({
167
+ id: Type.Optional(Type.String()),
168
+ type: Type.Optional(Type.String()),
169
+ }, { additionalProperties: true, })),
170
+ state: Type.Optional(Type.String()),
171
+ }, { additionalProperties: true, })),
172
+ }, { additionalProperties: true, });
173
+ export const JobWaitResultSchema = Type.Object({
174
+ jobId: Type.String(),
175
+ state: Type.String(),
176
+ type: Type.String(),
177
+ elapsedMs: Type.Number(),
178
+ pollCount: Type.Number(),
179
+ success: Type.Boolean(),
180
+ timedOut: Type.Optional(Type.Boolean()),
181
+ progress: Type.Object({
182
+ done: Type.Number(),
183
+ failed: Type.Number(),
184
+ running: Type.Number(),
185
+ total: Type.Union([Type.Number(), Type.Null(),]),
186
+ }),
187
+ log: Type.Optional(Type.String()),
188
+ });
189
+ export const BuildModeSchema = Type.Union([
190
+ Type.Literal("RECURSIVE_BUILD"),
191
+ Type.Literal("NON_RECURSIVE_FORCED_BUILD"),
192
+ Type.Literal("RECURSIVE_FORCED_BUILD"),
193
+ Type.Literal("RECURSIVE_MISSING_ONLY_BUILD"),
194
+ ]);
195
+ // ---------------------------------------------------------------------------
196
+ // Scenarios
197
+ // ---------------------------------------------------------------------------
198
+ export const ScenarioSummarySchema = Type.Object({
199
+ id: Type.String(),
200
+ name: Type.Optional(Type.String()),
201
+ active: Type.Optional(Type.Boolean()),
202
+ }, { additionalProperties: true, });
203
+ export const ScenarioDetailsSchema = Type.Object({
204
+ id: Type.String(),
205
+ name: Type.Optional(Type.String()),
206
+ active: Type.Optional(Type.Boolean()),
207
+ type: Type.Optional(Type.String()),
208
+ projectKey: Type.Optional(Type.String()),
209
+ params: Type.Optional(Type.Object({
210
+ steps: Type.Optional(Type.Array(Type.Unknown())),
211
+ triggers: Type.Optional(Type.Array(Type.Unknown())),
212
+ reporters: Type.Optional(Type.Array(Type.Unknown())),
213
+ customScript: Type.Optional(Type.Object({
214
+ script: Type.Optional(Type.String()),
215
+ }, { additionalProperties: true, })),
216
+ }, { additionalProperties: true, })),
217
+ versionTag: Type.Optional(Type.Object({
218
+ versionNumber: Type.Number(),
219
+ }, { additionalProperties: true, })),
220
+ }, { additionalProperties: true, });
221
+ export const ScenarioStatusSchema = Type.Object({
222
+ id: Type.Optional(Type.String()),
223
+ name: Type.Optional(Type.String()),
224
+ active: Type.Optional(Type.Boolean()),
225
+ running: Type.Optional(Type.Boolean()),
226
+ nextRun: Type.Optional(Type.Number()),
227
+ lastRun: Type.Optional(Type.Object({
228
+ runId: Type.Optional(Type.String()),
229
+ outcome: Type.Optional(Type.String()),
230
+ start: Type.Optional(Type.Number()),
231
+ end: Type.Optional(Type.Number()),
232
+ trigger: Type.Optional(Type.Object({
233
+ type: Type.Optional(Type.String()),
234
+ }, { additionalProperties: true, })),
235
+ }, { additionalProperties: true, })),
236
+ }, { additionalProperties: true, });
237
+ // ---------------------------------------------------------------------------
238
+ // Folders
239
+ // ---------------------------------------------------------------------------
240
+ export const FolderSummarySchema = Type.Object({
241
+ id: Type.String(),
242
+ name: Type.Optional(Type.String()),
243
+ type: Type.Optional(Type.String()),
244
+ }, { additionalProperties: true, });
245
+ export const FolderDetailsSchema = Type.Object({
246
+ id: Type.String(),
247
+ name: Type.Optional(Type.String()),
248
+ type: Type.Optional(Type.String()),
249
+ projectKey: Type.Optional(Type.String()),
250
+ params: Type.Optional(Type.Object({
251
+ connection: Type.Optional(Type.String()),
252
+ path: Type.Optional(Type.String()),
253
+ }, { additionalProperties: true, })),
254
+ tags: Type.Optional(Type.Array(Type.String())),
255
+ }, { additionalProperties: true, });
256
+ export const FolderItemSchema = Type.Object({
257
+ path: Type.String(),
258
+ size: Type.Optional(Type.Number()),
259
+ lastModified: Type.Optional(Type.Number()),
260
+ }, { additionalProperties: true, });
261
+ // ---------------------------------------------------------------------------
262
+ // Variables
263
+ // ---------------------------------------------------------------------------
264
+ export const ProjectVariablesSchema = Type.Object({
265
+ standard: Type.Record(Type.String(), Type.Unknown()),
266
+ local: Type.Record(Type.String(), Type.Unknown()),
267
+ }, { additionalProperties: true, });
268
+ // ---------------------------------------------------------------------------
269
+ // Connections
270
+ // ---------------------------------------------------------------------------
271
+ export const ConnectionSummarySchema = Type.Object({
272
+ name: Type.String(),
273
+ types: Type.Optional(Type.Array(Type.String())),
274
+ managed: Type.Optional(Type.Boolean()),
275
+ dbSchemas: Type.Optional(Type.Array(Type.String())),
276
+ }, { additionalProperties: true, });
277
+ // ---------------------------------------------------------------------------
278
+ // Code Envs
279
+ // ---------------------------------------------------------------------------
280
+ export const CodeEnvSummarySchema = Type.Object({
281
+ envName: Type.String(),
282
+ envLang: Type.String(),
283
+ pythonInterpreter: Type.Optional(Type.String()),
284
+ deploymentMode: Type.Optional(Type.String()),
285
+ }, { additionalProperties: true, });
286
+ export const CodeEnvDetailsSchema = Type.Object({
287
+ envName: Type.String(),
288
+ envLang: Type.String(),
289
+ pythonInterpreter: Type.Optional(Type.String()),
290
+ requestedPackages: Type.Array(Type.String()),
291
+ installedPackages: Type.Array(Type.String()),
292
+ });
293
+ // ---------------------------------------------------------------------------
294
+ // Jupyter Notebooks
295
+ // ---------------------------------------------------------------------------
296
+ export const JupyterCellSchema = Type.Object({
297
+ cell_type: Type.String(),
298
+ source: Type.Array(Type.String()),
299
+ metadata: Type.Optional(Type.Record(Type.String(), Type.Unknown())),
300
+ outputs: Type.Optional(Type.Array(Type.Unknown())),
301
+ execution_count: Type.Optional(Type.Union([Type.Number(), Type.Null(),])),
302
+ }, { additionalProperties: true, });
303
+ export const JupyterNotebookSummarySchema = Type.Object({
304
+ name: Type.String(),
305
+ projectKey: Type.String(),
306
+ language: Type.String(),
307
+ kernelSpec: Type.Optional(Type.Object({
308
+ name: Type.String(),
309
+ display_name: Type.String(),
310
+ language: Type.String(),
311
+ }, { additionalProperties: true, })),
312
+ }, { additionalProperties: true, });
313
+ export const JupyterNotebookContentSchema = Type.Object({
314
+ metadata: Type.Record(Type.String(), Type.Unknown()),
315
+ nbformat: Type.Number(),
316
+ nbformat_minor: Type.Number(),
317
+ cells: Type.Array(JupyterCellSchema),
318
+ }, { additionalProperties: true, });
319
+ export const NotebookSessionSchema = Type.Object({
320
+ sessionId: Type.String(),
321
+ kernelId: Type.Optional(Type.String()),
322
+ projectKey: Type.Optional(Type.String()),
323
+ notebookName: Type.Optional(Type.String()),
324
+ sessionCreator: Type.Optional(Type.String()),
325
+ kernelExecutionState: Type.Optional(Type.String()),
326
+ }, { additionalProperties: true, });
327
+ // ---------------------------------------------------------------------------
328
+ // SQL Notebooks
329
+ // ---------------------------------------------------------------------------
330
+ export const SqlNotebookCellSchema = Type.Object({
331
+ id: Type.String(),
332
+ type: Type.String(),
333
+ name: Type.Optional(Type.String()),
334
+ code: Type.String(),
335
+ }, { additionalProperties: true, });
336
+ export const SqlNotebookSummarySchema = Type.Object({
337
+ id: Type.String(),
338
+ projectKey: Type.Optional(Type.String()),
339
+ language: Type.String(),
340
+ connection: Type.String(),
341
+ }, { additionalProperties: true, });
342
+ export const SqlNotebookContentSchema = Type.Object({
343
+ connection: Type.String(),
344
+ cells: Type.Array(SqlNotebookCellSchema),
345
+ }, { additionalProperties: true, });
346
+ // ---------------------------------------------------------------------------
347
+ // SQL Queries
348
+ // ---------------------------------------------------------------------------
349
+ export const SqlQuerySchemaSchema = Type.Object({
350
+ name: Type.String(),
351
+ type: Type.String(),
352
+ }, { additionalProperties: true, });
353
+ export const SqlQueryResultSchema = Type.Object({
354
+ queryId: Type.String(),
355
+ hasResults: Type.Boolean(),
356
+ schema: Type.Array(SqlQuerySchemaSchema),
357
+ }, { additionalProperties: true, });
358
+ export const SqlQueryResponseSchema = Type.Object({
359
+ queryId: Type.String(),
360
+ schema: Type.Array(SqlQuerySchemaSchema),
361
+ rows: Type.Array(Type.Array(Type.Unknown())),
362
+ });
363
+ // ---------------------------------------------------------------------------
364
+ // Flow Map (moved from projects.ts)
365
+ // ---------------------------------------------------------------------------
366
+ export const FlowMapOptionsSchema = Type.Object({
367
+ maxNodes: Type.Optional(Type.Number()),
368
+ maxEdges: Type.Optional(Type.Number()),
369
+ includeRaw: Type.Optional(Type.Boolean()),
370
+ });
371
+ // ---------------------------------------------------------------------------
372
+ // Array wrappers (for runtime validation of list() responses)
373
+ // ---------------------------------------------------------------------------
374
+ export const ProjectSummaryArraySchema = Type.Array(ProjectSummarySchema);
375
+ export const DatasetSummaryArraySchema = Type.Array(DatasetSummarySchema);
376
+ export const RecipeSummaryArraySchema = Type.Array(RecipeSummarySchema);
377
+ export const JobSummaryArraySchema = Type.Array(JobSummarySchema);
378
+ export const ScenarioSummaryArraySchema = Type.Array(ScenarioSummarySchema);
379
+ export const FolderSummaryArraySchema = Type.Array(FolderSummarySchema);
380
+ export const FolderItemArraySchema = Type.Array(FolderItemSchema);
381
+ export const CodeEnvSummaryArraySchema = Type.Array(CodeEnvSummarySchema);
382
+ export const JupyterNotebookSummaryArraySchema = Type.Array(JupyterNotebookSummarySchema);
383
+ export const SqlNotebookSummaryArraySchema = Type.Array(SqlNotebookSummarySchema);
384
+ export const NotebookSessionArraySchema = Type.Array(NotebookSessionSchema);
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};