dataiku-sdk 0.7.0 → 0.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 (2) hide show
  1. package/dist/src/cli.js +42 -10
  2. package/package.json +5 -5
package/dist/src/cli.js CHANGED
@@ -1119,6 +1119,23 @@ function formatLineDiff(remoteName, localPath, remoteContent, localContent) {
1119
1119
  return lines.join("\n");
1120
1120
  }
1121
1121
  let outputFieldProjection;
1122
+ /**
1123
+ * Non-fatal diagnostics queued during a command and flushed to stderr as one
1124
+ * JSON envelope, so agents get a loud, machine-parseable signal (e.g. truncated
1125
+ * exports) without polluting the stdout result contract.
1126
+ */
1127
+ let pendingCliWarnings = [];
1128
+ function enqueueCliWarning(warning) {
1129
+ pendingCliWarnings.push(warning);
1130
+ }
1131
+ /** Emit queued warnings as a single `{ warnings: [...] }` object on stderr. Idempotent. */
1132
+ function flushCliWarnings() {
1133
+ if (pendingCliWarnings.length === 0)
1134
+ return;
1135
+ const warnings = pendingCliWarnings;
1136
+ pendingCliWarnings = [];
1137
+ process.stderr.write(`${JSON.stringify({ warnings, }, null, 2)}\n`);
1138
+ }
1122
1139
  function resolveFieldPath(source, field) {
1123
1140
  let current = source;
1124
1141
  for (const segment of field.split(".")) {
@@ -1148,6 +1165,7 @@ function projectResultFields(result, fields) {
1148
1165
  return pickResultFields(result, fields);
1149
1166
  }
1150
1167
  function writeCommandResult(result) {
1168
+ flushCliWarnings();
1151
1169
  const projected = outputFieldProjection
1152
1170
  ? projectResultFields(result, outputFieldProjection)
1153
1171
  : result;
@@ -1495,6 +1513,7 @@ const FLAG_ALIASES = {
1495
1513
  "extra-ca-certs": "ca-cert",
1496
1514
  explain: "plan",
1497
1515
  "zone-name": "zone",
1516
+ rows: "max-rows",
1498
1517
  };
1499
1518
  const VALUE_FLAGS = new Set([
1500
1519
  "fields",
@@ -2737,9 +2756,9 @@ const commands = {
2737
2756
  timeoutMs: num(f["timeout"]),
2738
2757
  });
2739
2758
  },
2740
- usage: "dss dataset preview <name> [--max-rows N] [--project-key KEY] [--timeout MS]",
2741
- description: "Preview dataset rows.",
2742
- examples: ["dss dataset preview orders", "dss dataset preview orders --max-rows 5",],
2759
+ usage: "dss dataset preview <name> [--max-rows N|--rows N] [--project-key KEY] [--timeout MS]",
2760
+ description: "Preview dataset rows (--rows is an alias for --max-rows).",
2761
+ examples: ["dss dataset preview orders", "dss dataset preview orders --rows 5",],
2743
2762
  },
2744
2763
  metadata: {
2745
2764
  handler: (c, a, f) => {
@@ -2751,16 +2770,28 @@ const commands = {
2751
2770
  examples: ["dss dataset metadata orders",],
2752
2771
  },
2753
2772
  download: {
2754
- handler: (c, a, f) => {
2773
+ handler: async (c, a, f) => {
2755
2774
  requireArgs(a, 1, "dss dataset download <name>");
2756
- return c.datasets.download(a[0], {
2775
+ const result = await c.datasets.download(a[0], {
2757
2776
  outputPath: f["output"],
2758
2777
  projectKey: f["project-key"],
2759
2778
  limit: num(f["limit"]),
2760
2779
  });
2780
+ if (result.truncated) {
2781
+ enqueueCliWarning({
2782
+ code: "dataset_download_truncated",
2783
+ message: `Download of '${a[0]}' stopped at the ${result.limit}-row cap; the dataset has more rows. `
2784
+ + "Re-run with --limit N for more, or read inside a recipe (get_dataframe) for the full data.",
2785
+ dataset: a[0],
2786
+ rows: result.rows,
2787
+ limit: result.limit,
2788
+ path: result.path,
2789
+ });
2790
+ }
2791
+ return result;
2761
2792
  },
2762
2793
  usage: "dss dataset download <name> [--output PATH] [--limit N] [--project-key KEY]",
2763
- description: "Download up to --limit rows (default 100k) as CSV; returns { path, rows, truncated, limit } so truncation is visible.",
2794
+ description: "Download up to --limit rows (default 100k) as CSV; returns { path, rows, truncated, limit }. When truncated, a dataset_download_truncated warning is also written to stderr so the cap is never silent.",
2764
2795
  examples: ["dss dataset download orders", "dss dataset download orders --output ./data/",],
2765
2796
  },
2766
2797
  create: {
@@ -4743,8 +4774,8 @@ function missingActionError(resource, validActions, usage) {
4743
4774
  function unknownResourceError(resource) {
4744
4775
  return new UsageError(`Unknown resource: ${resource}.`, "usage_error", COMMANDS_RUN_HINT, { resource, validResources: RESOURCE_NAMES, });
4745
4776
  }
4746
- function unknownActionError(resource, action, validActions) {
4747
- return new UsageError(`Unknown action: ${resource} ${action ?? ""}`.trim(), "usage_error", COMMANDS_RUN_HINT, { resource, action, validActions, });
4777
+ function unknownActionError(resource, action, validActions, hint) {
4778
+ return new UsageError(`Unknown action: ${resource} ${action ?? ""}`.trim(), "usage_error", hint ?? COMMANDS_RUN_HINT, { resource, action, validActions, });
4748
4779
  }
4749
4780
  function requireArgs(args, count, usage) {
4750
4781
  if (args.length < count) {
@@ -6774,8 +6805,9 @@ async function main() {
6774
6805
  }
6775
6806
  currentCommandContext.action = action;
6776
6807
  const authMeta = AUTH_ACTIONS[action];
6777
- if (!authMeta)
6778
- throw unknownActionError("auth", action, validActions);
6808
+ if (!authMeta) {
6809
+ throw unknownActionError("auth", action, validActions, "auth only supports 'login'. To check credentials/connectivity, run 'dss doctor'.");
6810
+ }
6779
6811
  const result = await authMeta.handler(flags);
6780
6812
  writeCommandResult(result);
6781
6813
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dataiku-sdk",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "Dataiku DSS SDK and CLI for programmatic access to DSS REST APIs",
5
5
  "type": "module",
6
6
  "workspaces": [
@@ -35,10 +35,10 @@
35
35
  "test:integration:rigorous:mutating": "RUN_DATAIKU_INTEGRATION=1 RUN_DATAIKU_INTEGRATION_MUTATING=1 bun test tests/integration-rigorous.test.ts"
36
36
  },
37
37
  "devDependencies": {
38
- "@types/bun": "^1.3.13",
39
- "dprint": "^0.53.2",
40
- "oxlint": "^1.62.0",
41
- "typescript": "^5.9.3"
38
+ "@types/bun": "^1.3.14",
39
+ "dprint": "^0.54.0",
40
+ "oxlint": "^1.68.0",
41
+ "typescript": "^6.0.3"
42
42
  },
43
43
  "dependencies": {
44
44
  "@sinclair/typebox": "^0.34.49"