dataiku-sdk 3.7.0 → 3.9.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 (62) hide show
  1. package/README.md +4 -2
  2. package/dist/build-metadata.json +1 -1
  3. package/dist/packages/types/src/index.d.ts +40 -4
  4. package/dist/packages/types/src/index.js +22 -1
  5. package/dist/src/cli/coerce.d.ts +1 -0
  6. package/dist/src/cli/coerce.js +1 -1
  7. package/dist/src/cli/command-syntax.json +156 -0
  8. package/dist/src/cli/commands/dataset.js +44 -8
  9. package/dist/src/cli/commands/flow-zone.js +241 -46
  10. package/dist/src/cli/commands/job.js +52 -9
  11. package/dist/src/cli/commands/project.js +4 -3
  12. package/dist/src/cli/commands/recipe.d.ts +4 -0
  13. package/dist/src/cli/commands/recipe.js +38 -1
  14. package/dist/src/cli/commands/wiki.js +56 -0
  15. package/dist/src/cli/contract.js +13 -8
  16. package/dist/src/cli/doctor.js +2 -0
  17. package/dist/src/cli/flags.d.ts +7 -0
  18. package/dist/src/cli/flags.js +28 -2
  19. package/dist/src/cli/helpers/dataset.d.ts +12 -0
  20. package/dist/src/cli/helpers/dataset.js +36 -0
  21. package/dist/src/cli/helpers/flow-zone.d.ts +21 -0
  22. package/dist/src/cli/helpers/flow-zone.js +144 -4
  23. package/dist/src/cli/output-schemas.js +27 -3
  24. package/dist/src/cli/output.js +6 -0
  25. package/dist/src/cli/plans.js +58 -2
  26. package/dist/src/cli/project-map-output.d.ts +24 -0
  27. package/dist/src/cli/project-map-output.js +21 -0
  28. package/dist/src/cli/read-shapes.d.ts +14 -0
  29. package/dist/src/cli/read-shapes.js +114 -0
  30. package/dist/src/cli/result-shapes.d.ts +6 -0
  31. package/dist/src/cli/result-shapes.js +235 -0
  32. package/dist/src/cli/types.d.ts +2 -0
  33. package/dist/src/cli/version.d.ts +2 -2
  34. package/dist/src/cli/version.js +2 -2
  35. package/dist/src/cli.js +23 -20
  36. package/dist/src/errors.d.ts +11 -1
  37. package/dist/src/errors.js +18 -3
  38. package/dist/src/generated/action-output-schemas.json +224 -35
  39. package/dist/src/resources/dataset-create.d.ts +19 -0
  40. package/dist/src/resources/dataset-create.js +69 -0
  41. package/dist/src/resources/datasets.d.ts +21 -0
  42. package/dist/src/resources/datasets.js +61 -1
  43. package/dist/src/resources/flow-zones.d.ts +29 -3
  44. package/dist/src/resources/flow-zones.js +53 -3
  45. package/dist/src/resources/jobs.d.ts +36 -1
  46. package/dist/src/resources/jobs.js +111 -5
  47. package/dist/src/resources/projects.d.ts +9 -0
  48. package/dist/src/resources/projects.js +10 -3
  49. package/dist/src/resources/recipe-create.d.ts +17 -3
  50. package/dist/src/resources/recipe-create.js +149 -33
  51. package/dist/src/resources/recipes.js +76 -23
  52. package/dist/src/resources/sql.js +52 -13
  53. package/dist/src/resources/wiki.d.ts +47 -1
  54. package/dist/src/resources/wiki.js +89 -0
  55. package/dist/src/utils/flow-analysis.js +4 -0
  56. package/dist/src/utils/secret-sanitize.d.ts +11 -2
  57. package/dist/src/utils/secret-sanitize.js +23 -6
  58. package/package.json +4 -4
  59. package/plugin.json +1 -1
  60. package/skills/dataiku-dss/references/discovery.md +2 -2
  61. package/skills/dataiku-dss/references/flow-maps.md +2 -2
  62. package/skills/dataiku-dss/references/troubleshooting.md +3 -3
package/README.md CHANGED
@@ -520,8 +520,10 @@ UI-click smoke test. The CLI does not guess private endpoints for those operatio
520
520
 
521
521
  `project map` returns one agent-oriented JSON view of the Flow: normalized nodes and edges,
522
522
  joined zone metadata, cycle-safe topological layers, weakly connected components, diagnostics, and
523
- a stable `topologyFingerprint`. Zone joins add `zoneId`/`zoneName` to each node; the top-level
524
- `zones` array preserves zone color, position, item count, and visible node IDs.
523
+ a stable `topologyFingerprint`. Output is deduplicated: node `name` appears only when it differs from
524
+ `id`; each node carries `zoneId`/`componentId` (zone names live in `zones[]`, membership is derived
525
+ from those ids, so `zones[]`/`components[]` omit `nodeIds`); `warnings` appears only when non-empty and
526
+ `truncation` only when the map was cut. `zones` preserves zone color, position, and item count.
525
527
 
526
528
  ```bash
527
529
  dss project map --project-key MYPROJ
@@ -1 +1 @@
1
- {"format":1,"buildRevision":"a980b6ec9bd11f68d319f7034152d7f9dd4ccd83"}
1
+ {"format":1,"buildRevision":"3f9f0582b0fa45ee3708215954761d75f6edf9b7"}
@@ -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,
@@ -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;
@@ -165,7 +165,7 @@ function selectSingleSource(flags, sourceFlags) {
165
165
  }
166
166
  return provided[0];
167
167
  }
168
- function readInputText(path, flag) {
168
+ export function readInputText(path, flag) {
169
169
  try {
170
170
  return readFileSync(path, "utf-8");
171
171
  }
@@ -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
  [
@@ -4471,6 +4513,15 @@
4471
4513
  {
4472
4514
  "arg": "name"
4473
4515
  },
4516
+ {
4517
+ "optional": [
4518
+ [
4519
+ {
4520
+ "flag": "full"
4521
+ }
4522
+ ]
4523
+ ]
4524
+ },
4474
4525
  {
4475
4526
  "optional": [
4476
4527
  [
@@ -4489,6 +4540,15 @@
4489
4540
  {
4490
4541
  "arg": "name"
4491
4542
  },
4543
+ {
4544
+ "optional": [
4545
+ [
4546
+ {
4547
+ "flag": "full"
4548
+ }
4549
+ ]
4550
+ ]
4551
+ },
4492
4552
  {
4493
4553
  "optional": [
4494
4554
  [
@@ -5550,6 +5610,15 @@
5550
5610
  ]
5551
5611
  ]
5552
5612
  },
5613
+ {
5614
+ "optional": [
5615
+ [
5616
+ {
5617
+ "flag": "recreate-on-move"
5618
+ }
5619
+ ]
5620
+ ]
5621
+ },
5553
5622
  {
5554
5623
  "optional": [
5555
5624
  [
@@ -7057,6 +7126,15 @@
7057
7126
  {
7058
7127
  "arg": "id"
7059
7128
  },
7129
+ {
7130
+ "optional": [
7131
+ [
7132
+ {
7133
+ "flag": "full"
7134
+ }
7135
+ ]
7136
+ ]
7137
+ },
7060
7138
  {
7061
7139
  "optional": [
7062
7140
  [
@@ -12839,6 +12917,15 @@
12839
12917
  "dss",
12840
12918
  "project",
12841
12919
  "get",
12920
+ {
12921
+ "optional": [
12922
+ [
12923
+ {
12924
+ "flag": "full"
12925
+ }
12926
+ ]
12927
+ ]
12928
+ },
12842
12929
  {
12843
12930
  "optional": [
12844
12931
  [
@@ -17184,6 +17271,36 @@
17184
17271
  ]
17185
17272
  }
17186
17273
  ],
17274
+ "wiki.attach": [
17275
+ "dss",
17276
+ "wiki",
17277
+ "attach",
17278
+ {
17279
+ "arg": "id-or-name"
17280
+ },
17281
+ {
17282
+ "arg": "localPath"
17283
+ },
17284
+ {
17285
+ "optional": [
17286
+ [
17287
+ {
17288
+ "flag": "dry-run"
17289
+ }
17290
+ ]
17291
+ ]
17292
+ },
17293
+ {
17294
+ "optional": [
17295
+ [
17296
+ {
17297
+ "flag": "project-key",
17298
+ "value": "KEY"
17299
+ }
17300
+ ]
17301
+ ]
17302
+ }
17303
+ ],
17187
17304
  "wiki.create": [
17188
17305
  "dss",
17189
17306
  "wiki",
@@ -17283,6 +17400,45 @@
17283
17400
  ]
17284
17401
  }
17285
17402
  ],
17403
+ "wiki.detach": [
17404
+ "dss",
17405
+ "wiki",
17406
+ "detach",
17407
+ {
17408
+ "arg": "id-or-name"
17409
+ },
17410
+ {
17411
+ "arg": "smartId"
17412
+ },
17413
+ {
17414
+ "optional": [
17415
+ [
17416
+ {
17417
+ "flag": "if-exists"
17418
+ }
17419
+ ]
17420
+ ]
17421
+ },
17422
+ {
17423
+ "optional": [
17424
+ [
17425
+ {
17426
+ "flag": "dry-run"
17427
+ }
17428
+ ]
17429
+ ]
17430
+ },
17431
+ {
17432
+ "optional": [
17433
+ [
17434
+ {
17435
+ "flag": "project-key",
17436
+ "value": "KEY"
17437
+ }
17438
+ ]
17439
+ ]
17440
+ }
17441
+ ],
17286
17442
  "wiki.get": [
17287
17443
  "dss",
17288
17444
  "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";
@@ -143,7 +143,7 @@ export const datasetCommands = withUsage("dataset", {
143
143
  requireArgs(a, 1, commandUsage("dataset", "get"));
144
144
  return c.datasets.get(a[0], f["project-key"]);
145
145
  },
146
- description: "Get full settings for a dataset.",
146
+ description: "Get the settings for a dataset (compact by default: empty values and metrics/version metadata are dropped, structure kept for get-edit-update; --full returns the raw DSS object).",
147
147
  examples: ["dss dataset get orders", "dss dataset get orders --project-key MYPROJ",],
148
148
  },
149
149
  schema: {
@@ -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 { created: name, resource: "dataset", ...moved, };
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 new dataset. UploadedFiles uses the server's default upload connection when omitted.",
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 orders --connection filesystem --type Filesystem",
402
- "dss dataset create --name orders --connection filesystem --type Filesystem --zone Experiments --dry-run",
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": {
@@ -470,7 +506,7 @@ export const datasetCommands = withUsage("dataset", {
470
506
  requireArgs(a, 1, commandUsage("dataset", "info"));
471
507
  return c.datasets.info(a[0], f["project-key"]);
472
508
  },
473
- description: "Get the full info object for a dataset (type, parameters, last build information, schema, etc.).",
509
+ description: "Get dataset info: type, connection, format, schema columns, flow recipes, buildability, data quality, and last modification (compact by default; --full returns the raw DSS info object).",
474
510
  examples: ["dss dataset info orders", "dss dataset info orders --project-key MYPROJ",],
475
511
  },
476
512
  "column-lineage": {