dataiku-sdk 3.7.0 → 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.
- package/dist/build-metadata.json +1 -1
- package/dist/packages/types/src/index.d.ts +40 -4
- package/dist/packages/types/src/index.js +22 -1
- package/dist/src/cli/coerce.d.ts +1 -0
- package/dist/src/cli/coerce.js +1 -1
- package/dist/src/cli/command-syntax.json +120 -0
- package/dist/src/cli/commands/dataset.js +42 -6
- package/dist/src/cli/commands/flow-zone.js +241 -46
- package/dist/src/cli/commands/job.js +18 -3
- package/dist/src/cli/commands/recipe.d.ts +4 -0
- package/dist/src/cli/commands/recipe.js +38 -1
- package/dist/src/cli/commands/wiki.js +56 -0
- package/dist/src/cli/contract.js +11 -3
- package/dist/src/cli/doctor.js +2 -0
- package/dist/src/cli/flags.d.ts +7 -0
- package/dist/src/cli/flags.js +28 -2
- package/dist/src/cli/helpers/dataset.d.ts +12 -0
- package/dist/src/cli/helpers/dataset.js +36 -0
- package/dist/src/cli/helpers/flow-zone.d.ts +21 -0
- package/dist/src/cli/helpers/flow-zone.js +144 -4
- package/dist/src/cli/output.js +6 -0
- package/dist/src/cli/plans.js +58 -2
- package/dist/src/cli/types.d.ts +2 -0
- package/dist/src/cli.js +12 -4
- package/dist/src/errors.d.ts +11 -1
- package/dist/src/errors.js +18 -3
- package/dist/src/resources/dataset-create.d.ts +19 -0
- package/dist/src/resources/dataset-create.js +69 -0
- package/dist/src/resources/datasets.d.ts +21 -0
- package/dist/src/resources/datasets.js +61 -1
- package/dist/src/resources/flow-zones.d.ts +29 -3
- package/dist/src/resources/flow-zones.js +53 -3
- package/dist/src/resources/jobs.d.ts +34 -0
- package/dist/src/resources/jobs.js +68 -1
- package/dist/src/resources/projects.d.ts +9 -0
- package/dist/src/resources/projects.js +10 -3
- package/dist/src/resources/recipe-create.d.ts +17 -3
- package/dist/src/resources/recipe-create.js +149 -33
- package/dist/src/resources/recipes.js +76 -23
- package/dist/src/resources/sql.js +52 -13
- package/dist/src/resources/wiki.d.ts +47 -1
- package/dist/src/resources/wiki.js +89 -0
- package/dist/src/utils/flow-analysis.js +4 -0
- package/package.json +1 -1
- package/plugin.json +1 -1
- package/skills/dataiku-dss/references/flow-maps.md +2 -2
- package/skills/dataiku-dss/references/troubleshooting.md +1 -1
package/dist/build-metadata.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"format":1,"buildRevision":"
|
|
1
|
+
{"format":1,"buildRevision":"6814ed4e3da988eccd85f9f50d79e1da66253b0a"}
|
|
@@ -124,6 +124,7 @@ export declare const DatasetCreateOptionsSchema: import("@sinclair/typebox").TOb
|
|
|
124
124
|
table: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
125
125
|
dbSchema: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
126
126
|
catalog: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
127
|
+
query: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
127
128
|
formatType: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
128
129
|
formatParams: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TUnknown>>;
|
|
129
130
|
managed: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
@@ -184,10 +185,18 @@ export declare const RecipeCreateOptionsSchema: import("@sinclair/typebox").TObj
|
|
|
184
185
|
dropColumns: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
|
|
185
186
|
/** Prepare: the only columns to keep. */
|
|
186
187
|
keepColumns: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
|
|
188
|
+
/**
|
|
189
|
+
* Prepare: order of the option groups (`rename`, `fillEmpty`, `formula`, `filter`,
|
|
190
|
+
* `dropColumns`, `keepColumns`); the CLI passes the order the flags were typed in.
|
|
191
|
+
* Groups left out follow in that default order.
|
|
192
|
+
*/
|
|
193
|
+
stepOrder: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
|
|
187
194
|
}>;
|
|
188
195
|
export type RecipeCreateOptions = Static<typeof RecipeCreateOptionsSchema>;
|
|
189
196
|
export declare const RecipeCreateResultSchema: import("@sinclair/typebox").TObject<{
|
|
190
197
|
recipeName: import("@sinclair/typebox").TString;
|
|
198
|
+
/** The `--name` that was asked for, present only when DSS created the recipe under a different name. */
|
|
199
|
+
requestedName: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
191
200
|
type: import("@sinclair/typebox").TString;
|
|
192
201
|
createdDatasets: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>;
|
|
193
202
|
joinConfigured: import("@sinclair/typebox").TBoolean;
|
|
@@ -530,14 +539,15 @@ export declare const FlowZoneCreateOptionsSchema: import("@sinclair/typebox").TO
|
|
|
530
539
|
}>>;
|
|
531
540
|
}>;
|
|
532
541
|
export type FlowZoneCreateOptions = Static<typeof FlowZoneCreateOptionsSchema>;
|
|
542
|
+
/**
|
|
543
|
+
* DSS's public `PUT /flow/zones/{id}` persists name and color but silently
|
|
544
|
+
* ignores `position`; repositioning an existing zone goes through
|
|
545
|
+
* `flowZones.recreate`, which creates a replacement zone at the new position.
|
|
546
|
+
*/
|
|
533
547
|
export declare const FlowZoneUpdateOptionsSchema: import("@sinclair/typebox").TObject<{
|
|
534
548
|
name: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
535
549
|
color: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
536
550
|
projectKey: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
537
|
-
position: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
|
|
538
|
-
x: import("@sinclair/typebox").TNumber;
|
|
539
|
-
y: import("@sinclair/typebox").TNumber;
|
|
540
|
-
}>>;
|
|
541
551
|
}>;
|
|
542
552
|
export type FlowZoneUpdateOptions = Static<typeof FlowZoneUpdateOptionsSchema>;
|
|
543
553
|
export declare const FolderCreateOptionsSchema: import("@sinclair/typebox").TObject<{
|
|
@@ -675,10 +685,24 @@ export declare const WikiSettingsSchema: import("@sinclair/typebox").TObject<{
|
|
|
675
685
|
homeArticleId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
676
686
|
}>;
|
|
677
687
|
export type WikiSettings = Static<typeof WikiSettingsSchema>;
|
|
688
|
+
/** One entry of a wiki article's `attachments` (uploaded FILE or linked DSS object). */
|
|
689
|
+
export declare const WikiArticleAttachmentSchema: import("@sinclair/typebox").TObject<{
|
|
690
|
+
attachmentType: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
691
|
+
smartId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
692
|
+
taggableType: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
693
|
+
details: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TUnknown>>;
|
|
694
|
+
}>;
|
|
695
|
+
export type WikiArticleAttachment = Static<typeof WikiArticleAttachmentSchema>;
|
|
678
696
|
export declare const WikiArticleMetadataSchema: import("@sinclair/typebox").TObject<{
|
|
679
697
|
id: import("@sinclair/typebox").TString;
|
|
680
698
|
name: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
681
699
|
projectKey: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
700
|
+
attachments: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
701
|
+
attachmentType: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
702
|
+
smartId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
703
|
+
taggableType: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
704
|
+
details: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TUnknown>>;
|
|
705
|
+
}>>>;
|
|
682
706
|
}>;
|
|
683
707
|
export type WikiArticleMetadata = Static<typeof WikiArticleMetadataSchema>;
|
|
684
708
|
export declare const WikiArticleDataSchema: import("@sinclair/typebox").TObject<{
|
|
@@ -686,6 +710,12 @@ export declare const WikiArticleDataSchema: import("@sinclair/typebox").TObject<
|
|
|
686
710
|
id: import("@sinclair/typebox").TString;
|
|
687
711
|
name: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
688
712
|
projectKey: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
713
|
+
attachments: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
714
|
+
attachmentType: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
715
|
+
smartId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
716
|
+
taggableType: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
717
|
+
details: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TUnknown>>;
|
|
718
|
+
}>>>;
|
|
689
719
|
}>;
|
|
690
720
|
payload: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
691
721
|
}>;
|
|
@@ -1071,6 +1101,12 @@ export declare const WikiArticleDataArraySchema: import("@sinclair/typebox").TAr
|
|
|
1071
1101
|
id: import("@sinclair/typebox").TString;
|
|
1072
1102
|
name: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
1073
1103
|
projectKey: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
1104
|
+
attachments: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
1105
|
+
attachmentType: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
1106
|
+
smartId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
1107
|
+
taggableType: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
1108
|
+
details: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TUnknown>>;
|
|
1109
|
+
}>>>;
|
|
1074
1110
|
}>;
|
|
1075
1111
|
payload: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
1076
1112
|
}>>;
|
|
@@ -169,6 +169,7 @@ export const DatasetCreateOptionsSchema = Type.Object({
|
|
|
169
169
|
table: Type.Optional(Type.String()),
|
|
170
170
|
dbSchema: Type.Optional(Type.String()),
|
|
171
171
|
catalog: Type.Optional(Type.String()),
|
|
172
|
+
query: Type.Optional(Type.String()),
|
|
172
173
|
formatType: Type.Optional(Type.String()),
|
|
173
174
|
formatParams: Type.Optional(Type.Record(Type.String(), Type.Unknown())),
|
|
174
175
|
managed: Type.Optional(Type.Boolean()),
|
|
@@ -229,9 +230,17 @@ export const RecipeCreateOptionsSchema = Type.Object({
|
|
|
229
230
|
dropColumns: Type.Optional(Type.Array(Type.String())),
|
|
230
231
|
/** Prepare: the only columns to keep. */
|
|
231
232
|
keepColumns: Type.Optional(Type.Array(Type.String())),
|
|
233
|
+
/**
|
|
234
|
+
* Prepare: order of the option groups (`rename`, `fillEmpty`, `formula`, `filter`,
|
|
235
|
+
* `dropColumns`, `keepColumns`); the CLI passes the order the flags were typed in.
|
|
236
|
+
* Groups left out follow in that default order.
|
|
237
|
+
*/
|
|
238
|
+
stepOrder: Type.Optional(Type.Array(Type.String())),
|
|
232
239
|
});
|
|
233
240
|
export const RecipeCreateResultSchema = Type.Object({
|
|
234
241
|
recipeName: Type.String(),
|
|
242
|
+
/** The `--name` that was asked for, present only when DSS created the recipe under a different name. */
|
|
243
|
+
requestedName: Type.Optional(Type.String()),
|
|
235
244
|
type: Type.String(),
|
|
236
245
|
createdDatasets: Type.Array(Type.String()),
|
|
237
246
|
joinConfigured: Type.Boolean(),
|
|
@@ -500,11 +509,15 @@ export const FlowZoneCreateOptionsSchema = Type.Object({
|
|
|
500
509
|
projectKey: Type.Optional(Type.String()),
|
|
501
510
|
position: Type.Optional(FlowZonePositionSchema),
|
|
502
511
|
}, { additionalProperties: false, });
|
|
512
|
+
/**
|
|
513
|
+
* DSS's public `PUT /flow/zones/{id}` persists name and color but silently
|
|
514
|
+
* ignores `position`; repositioning an existing zone goes through
|
|
515
|
+
* `flowZones.recreate`, which creates a replacement zone at the new position.
|
|
516
|
+
*/
|
|
503
517
|
export const FlowZoneUpdateOptionsSchema = Type.Object({
|
|
504
518
|
name: Type.Optional(Type.String()),
|
|
505
519
|
color: Type.Optional(Type.String()),
|
|
506
520
|
projectKey: Type.Optional(Type.String()),
|
|
507
|
-
position: Type.Optional(FlowZonePositionSchema),
|
|
508
521
|
}, { additionalProperties: false, });
|
|
509
522
|
// ---------------------------------------------------------------------------
|
|
510
523
|
// Folders
|
|
@@ -631,10 +644,18 @@ export const WikiSettingsSchema = Type.Object({
|
|
|
631
644
|
taxonomy: Type.Optional(Type.Array(WikiTaxonomyNodeSchema)),
|
|
632
645
|
homeArticleId: Type.Optional(Type.String()),
|
|
633
646
|
}, { additionalProperties: true, });
|
|
647
|
+
/** One entry of a wiki article's `attachments` (uploaded FILE or linked DSS object). */
|
|
648
|
+
export const WikiArticleAttachmentSchema = Type.Object({
|
|
649
|
+
attachmentType: Type.Optional(Type.String()),
|
|
650
|
+
smartId: Type.Optional(Type.String()),
|
|
651
|
+
taggableType: Type.Optional(Type.String()),
|
|
652
|
+
details: Type.Optional(Type.Record(Type.String(), Type.Unknown())),
|
|
653
|
+
}, { additionalProperties: true, });
|
|
634
654
|
export const WikiArticleMetadataSchema = Type.Object({
|
|
635
655
|
id: Type.String(),
|
|
636
656
|
name: Type.Optional(Type.String()),
|
|
637
657
|
projectKey: Type.Optional(Type.String()),
|
|
658
|
+
attachments: Type.Optional(Type.Array(WikiArticleAttachmentSchema)),
|
|
638
659
|
}, { additionalProperties: true, });
|
|
639
660
|
export const WikiArticleDataSchema = Type.Object({
|
|
640
661
|
article: WikiArticleMetadataSchema,
|
package/dist/src/cli/coerce.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export declare function expectJsonObject(value: unknown, source: string): Record
|
|
|
20
20
|
export declare function parseJsonObject(text: string, source: string): Record<string, unknown>;
|
|
21
21
|
export declare function json(v: string | boolean | undefined, source?: string): Record<string, unknown> | undefined;
|
|
22
22
|
export declare function readStdinText(): string;
|
|
23
|
+
export declare function readInputText(path: string, flag: string): string;
|
|
23
24
|
export declare function seenJsonInputCredentials(): readonly string[];
|
|
24
25
|
export declare function jsonInput(flags: Record<string, string | boolean>): Record<string, unknown> | undefined;
|
|
25
26
|
export declare function unknownJsonInput(flags: Record<string, string | boolean>): unknown;
|
package/dist/src/cli/coerce.js
CHANGED
|
@@ -4227,6 +4227,48 @@
|
|
|
4227
4227
|
]
|
|
4228
4228
|
]
|
|
4229
4229
|
},
|
|
4230
|
+
{
|
|
4231
|
+
"optional": [
|
|
4232
|
+
[
|
|
4233
|
+
{
|
|
4234
|
+
"flag": "table",
|
|
4235
|
+
"value": "TABLE"
|
|
4236
|
+
},
|
|
4237
|
+
{
|
|
4238
|
+
"optional": [
|
|
4239
|
+
[
|
|
4240
|
+
{
|
|
4241
|
+
"flag": "schema",
|
|
4242
|
+
"value": "SCHEMA"
|
|
4243
|
+
}
|
|
4244
|
+
]
|
|
4245
|
+
]
|
|
4246
|
+
},
|
|
4247
|
+
{
|
|
4248
|
+
"optional": [
|
|
4249
|
+
[
|
|
4250
|
+
{
|
|
4251
|
+
"flag": "catalog",
|
|
4252
|
+
"value": "CATALOG"
|
|
4253
|
+
}
|
|
4254
|
+
]
|
|
4255
|
+
]
|
|
4256
|
+
}
|
|
4257
|
+
],
|
|
4258
|
+
[
|
|
4259
|
+
{
|
|
4260
|
+
"flag": "query",
|
|
4261
|
+
"value": "SQL"
|
|
4262
|
+
}
|
|
4263
|
+
],
|
|
4264
|
+
[
|
|
4265
|
+
{
|
|
4266
|
+
"flag": "query-file",
|
|
4267
|
+
"value": "PATH"
|
|
4268
|
+
}
|
|
4269
|
+
]
|
|
4270
|
+
]
|
|
4271
|
+
},
|
|
4230
4272
|
{
|
|
4231
4273
|
"optional": [
|
|
4232
4274
|
[
|
|
@@ -5550,6 +5592,15 @@
|
|
|
5550
5592
|
]
|
|
5551
5593
|
]
|
|
5552
5594
|
},
|
|
5595
|
+
{
|
|
5596
|
+
"optional": [
|
|
5597
|
+
[
|
|
5598
|
+
{
|
|
5599
|
+
"flag": "recreate-on-move"
|
|
5600
|
+
}
|
|
5601
|
+
]
|
|
5602
|
+
]
|
|
5603
|
+
},
|
|
5553
5604
|
{
|
|
5554
5605
|
"optional": [
|
|
5555
5606
|
[
|
|
@@ -17184,6 +17235,36 @@
|
|
|
17184
17235
|
]
|
|
17185
17236
|
}
|
|
17186
17237
|
],
|
|
17238
|
+
"wiki.attach": [
|
|
17239
|
+
"dss",
|
|
17240
|
+
"wiki",
|
|
17241
|
+
"attach",
|
|
17242
|
+
{
|
|
17243
|
+
"arg": "id-or-name"
|
|
17244
|
+
},
|
|
17245
|
+
{
|
|
17246
|
+
"arg": "localPath"
|
|
17247
|
+
},
|
|
17248
|
+
{
|
|
17249
|
+
"optional": [
|
|
17250
|
+
[
|
|
17251
|
+
{
|
|
17252
|
+
"flag": "dry-run"
|
|
17253
|
+
}
|
|
17254
|
+
]
|
|
17255
|
+
]
|
|
17256
|
+
},
|
|
17257
|
+
{
|
|
17258
|
+
"optional": [
|
|
17259
|
+
[
|
|
17260
|
+
{
|
|
17261
|
+
"flag": "project-key",
|
|
17262
|
+
"value": "KEY"
|
|
17263
|
+
}
|
|
17264
|
+
]
|
|
17265
|
+
]
|
|
17266
|
+
}
|
|
17267
|
+
],
|
|
17187
17268
|
"wiki.create": [
|
|
17188
17269
|
"dss",
|
|
17189
17270
|
"wiki",
|
|
@@ -17283,6 +17364,45 @@
|
|
|
17283
17364
|
]
|
|
17284
17365
|
}
|
|
17285
17366
|
],
|
|
17367
|
+
"wiki.detach": [
|
|
17368
|
+
"dss",
|
|
17369
|
+
"wiki",
|
|
17370
|
+
"detach",
|
|
17371
|
+
{
|
|
17372
|
+
"arg": "id-or-name"
|
|
17373
|
+
},
|
|
17374
|
+
{
|
|
17375
|
+
"arg": "smartId"
|
|
17376
|
+
},
|
|
17377
|
+
{
|
|
17378
|
+
"optional": [
|
|
17379
|
+
[
|
|
17380
|
+
{
|
|
17381
|
+
"flag": "if-exists"
|
|
17382
|
+
}
|
|
17383
|
+
]
|
|
17384
|
+
]
|
|
17385
|
+
},
|
|
17386
|
+
{
|
|
17387
|
+
"optional": [
|
|
17388
|
+
[
|
|
17389
|
+
{
|
|
17390
|
+
"flag": "dry-run"
|
|
17391
|
+
}
|
|
17392
|
+
]
|
|
17393
|
+
]
|
|
17394
|
+
},
|
|
17395
|
+
{
|
|
17396
|
+
"optional": [
|
|
17397
|
+
[
|
|
17398
|
+
{
|
|
17399
|
+
"flag": "project-key",
|
|
17400
|
+
"value": "KEY"
|
|
17401
|
+
}
|
|
17402
|
+
]
|
|
17403
|
+
]
|
|
17404
|
+
}
|
|
17405
|
+
],
|
|
17286
17406
|
"wiki.get": [
|
|
17287
17407
|
"dss",
|
|
17288
17408
|
"wiki",
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { assertDatasetTypeCreatable, } from "../../resources/dataset-create.js";
|
|
1
|
+
import { assertDatasetTypeCreatable, buildDatasetCreateBody, } from "../../resources/dataset-create.js";
|
|
2
2
|
import { deepMerge, } from "../../utils/deep-merge.js";
|
|
3
3
|
import { isRecord, } from "../../utils/records.js";
|
|
4
4
|
import { compareStrings, stableHash, } from "../../utils/stable-hash.js";
|
|
5
5
|
import { jsonInput, num, schemaColumnsInput, splitCsvFlag, unknownJsonInput, } from "../coerce.js";
|
|
6
6
|
import { executionMode, } from "../flags.js";
|
|
7
|
-
import { datasetSourceSummary, } from "../helpers/dataset.js";
|
|
7
|
+
import { datasetSourceSummary, datasetSqlSourceFromFlags, } from "../helpers/dataset.js";
|
|
8
8
|
import { moveCreatedItemsToZone, resolveFlowZoneIdFromFlags, } from "../helpers/flow-zone.js";
|
|
9
9
|
import { enqueueCliWarning, readIfExists, skipResult, } from "../output.js";
|
|
10
10
|
import { commandUsage, withUsage, } from "../syntax.js";
|
|
@@ -366,11 +366,14 @@ export const datasetCommands = withUsage("dataset", {
|
|
|
366
366
|
if (!connection && dsType.toLowerCase() !== "uploadedfiles") {
|
|
367
367
|
throw new UsageError("--connection is required unless --type is UploadedFiles.");
|
|
368
368
|
}
|
|
369
|
+
const sqlSource = datasetSqlSourceFromFlags(f, dsType);
|
|
370
|
+
const hasSqlSource = sqlSource.table !== undefined || sqlSource.query !== undefined;
|
|
369
371
|
const payload = {
|
|
370
372
|
datasetName: name,
|
|
371
373
|
connection,
|
|
372
374
|
dsType,
|
|
373
375
|
projectKey: pk,
|
|
376
|
+
...sqlSource,
|
|
374
377
|
};
|
|
375
378
|
const zoneId = await resolveFlowZoneIdFromFlags(c, f, pk);
|
|
376
379
|
if (f["if-not-exists"] === true || executionMode(f).dryRun) {
|
|
@@ -386,20 +389,53 @@ export const datasetCommands = withUsage("dataset", {
|
|
|
386
389
|
resource: "dataset",
|
|
387
390
|
name,
|
|
388
391
|
payload,
|
|
392
|
+
...(hasSqlSource
|
|
393
|
+
? {
|
|
394
|
+
request: {
|
|
395
|
+
method: "POST",
|
|
396
|
+
endpoint: `/public/api/projects/${encodeURIComponent(c.resolveProjectKey(pk))}/datasets/`,
|
|
397
|
+
body: buildDatasetCreateBody({
|
|
398
|
+
...payload,
|
|
399
|
+
projectKey: c.resolveProjectKey(pk),
|
|
400
|
+
}),
|
|
401
|
+
},
|
|
402
|
+
schemaDetection: "After the POST, DSS detects the schema (POST /actions/testAndDetectSettings/externalSQL) and it is stored (PUT /schema).",
|
|
403
|
+
}
|
|
404
|
+
: {}),
|
|
389
405
|
...(existing ? { current: existing, } : {}),
|
|
390
406
|
...(zoneId ? { zoneId, zoneMove: [{ objectId: name, objectType: "DATASET", },], } : {}),
|
|
391
407
|
};
|
|
392
408
|
}
|
|
393
409
|
}
|
|
394
410
|
await c.datasets.create(payload);
|
|
411
|
+
const detection = hasSqlSource ? await c.datasets.detectSqlSchema(name, pk) : undefined;
|
|
412
|
+
if (detection && !detection.detected) {
|
|
413
|
+
enqueueCliWarning({
|
|
414
|
+
code: "dataset_schema_not_detected",
|
|
415
|
+
dataset: name,
|
|
416
|
+
error: detection.error,
|
|
417
|
+
hint: `The dataset was kept without columns. Fix the connection, table, or query, then set the columns with dss dataset refresh-schema ${name}.`,
|
|
418
|
+
});
|
|
419
|
+
}
|
|
395
420
|
const moved = await moveCreatedItemsToZone(c, f, [{ objectId: name, objectType: "DATASET", },], pk);
|
|
396
|
-
return {
|
|
421
|
+
return {
|
|
422
|
+
created: name,
|
|
423
|
+
resource: "dataset",
|
|
424
|
+
...(detection
|
|
425
|
+
? {
|
|
426
|
+
schemaDetected: detection.detected,
|
|
427
|
+
columns: detection.columns,
|
|
428
|
+
...(detection.error !== undefined ? { schemaError: detection.error, } : {}),
|
|
429
|
+
}
|
|
430
|
+
: {}),
|
|
431
|
+
...moved,
|
|
432
|
+
};
|
|
397
433
|
},
|
|
398
|
-
description: "Create a
|
|
434
|
+
description: "Create a dataset. SQL types: --table or --query, schema auto-detected.",
|
|
399
435
|
examples: [
|
|
400
436
|
"dss dataset create --name uploads --type UploadedFiles",
|
|
401
|
-
"dss dataset create --name
|
|
402
|
-
"dss dataset create --name
|
|
437
|
+
"dss dataset create --name sales --type Snowflake --connection sf --table SALES --schema PUBLIC",
|
|
438
|
+
"dss dataset create --name big --type PostgreSQL --connection pg --query-file big.sql --dry-run",
|
|
403
439
|
],
|
|
404
440
|
},
|
|
405
441
|
"create-managed": {
|