dataiku-sdk 3.0.0 → 3.2.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 (109) hide show
  1. package/README.md +246 -19
  2. package/dist/build-metadata.json +1 -1
  3. package/dist/packages/types/src/index.d.ts +39 -4
  4. package/dist/packages/types/src/index.js +31 -2
  5. package/dist/src/auth.js +1 -1
  6. package/dist/src/cli/coerce.js +11 -2
  7. package/dist/src/cli/commands/analysis.js +4 -3
  8. package/dist/src/cli/commands/api-service.js +66 -18
  9. package/dist/src/cli/commands/app.js +4 -3
  10. package/dist/src/cli/commands/bundle.js +51 -16
  11. package/dist/src/cli/commands/code-env.js +219 -57
  12. package/dist/src/cli/commands/code.d.ts +19 -0
  13. package/dist/src/cli/commands/code.js +87 -15
  14. package/dist/src/cli/commands/dashboard.js +7 -6
  15. package/dist/src/cli/commands/data-quality.js +9 -8
  16. package/dist/src/cli/commands/dataset.js +17 -11
  17. package/dist/src/cli/commands/doctor.js +4 -2
  18. package/dist/src/cli/commands/flow-zone.js +42 -13
  19. package/dist/src/cli/commands/folder.js +9 -8
  20. package/dist/src/cli/commands/future.js +2 -1
  21. package/dist/src/cli/commands/insight.js +8 -7
  22. package/dist/src/cli/commands/job.js +4 -3
  23. package/dist/src/cli/commands/meaning.js +5 -4
  24. package/dist/src/cli/commands/ml-task.js +3 -2
  25. package/dist/src/cli/commands/model-evaluation-store.js +4 -3
  26. package/dist/src/cli/commands/notebook.js +82 -50
  27. package/dist/src/cli/commands/project-git.js +8 -5
  28. package/dist/src/cli/commands/project-library.d.ts +21 -0
  29. package/dist/src/cli/commands/project-library.js +128 -56
  30. package/dist/src/cli/commands/project.js +19 -4
  31. package/dist/src/cli/commands/recipe.js +51 -25
  32. package/dist/src/cli/commands/saved-model.js +4 -3
  33. package/dist/src/cli/commands/scenario.js +9 -8
  34. package/dist/src/cli/commands/sql.d.ts +10 -0
  35. package/dist/src/cli/commands/sql.js +42 -19
  36. package/dist/src/cli/commands/statistics.js +7 -6
  37. package/dist/src/cli/commands/variable.js +2 -1
  38. package/dist/src/cli/commands/webapp.js +68 -13
  39. package/dist/src/cli/commands/wiki.js +7 -6
  40. package/dist/src/cli/contract.d.ts +16 -1
  41. package/dist/src/cli/contract.js +967 -186
  42. package/dist/src/cli/env.d.ts +9 -0
  43. package/dist/src/cli/env.js +20 -2
  44. package/dist/src/cli/flags.d.ts +4 -0
  45. package/dist/src/cli/flags.js +29 -1
  46. package/dist/src/cli/helpers/cleanup.js +104 -3
  47. package/dist/src/cli/helpers/flow-zone.d.ts +3 -0
  48. package/dist/src/cli/helpers/flow-zone.js +33 -3
  49. package/dist/src/cli/helpers/recipe.d.ts +20 -0
  50. package/dist/src/cli/helpers/recipe.js +158 -3
  51. package/dist/src/cli/output.d.ts +2 -0
  52. package/dist/src/cli/output.js +33 -6
  53. package/dist/src/cli/runtime.d.ts +35 -1
  54. package/dist/src/cli/runtime.js +125 -18
  55. package/dist/src/cli/types.d.ts +7 -0
  56. package/dist/src/cli.js +226 -95
  57. package/dist/src/client.d.ts +63 -1
  58. package/dist/src/client.js +305 -53
  59. package/dist/src/errors.d.ts +8 -2
  60. package/dist/src/errors.js +42 -0
  61. package/dist/src/index.d.ts +4 -3
  62. package/dist/src/index.js +2 -1
  63. package/dist/src/resources/api-services.d.ts +48 -6
  64. package/dist/src/resources/api-services.js +54 -8
  65. package/dist/src/resources/bundles.d.ts +51 -6
  66. package/dist/src/resources/bundles.js +39 -9
  67. package/dist/src/resources/code-envs.d.ts +25 -3
  68. package/dist/src/resources/code-envs.js +104 -2
  69. package/dist/src/resources/datasets.d.ts +20 -0
  70. package/dist/src/resources/datasets.js +232 -52
  71. package/dist/src/resources/folders.js +2 -1
  72. package/dist/src/resources/jobs.d.ts +35 -10
  73. package/dist/src/resources/jobs.js +92 -17
  74. package/dist/src/resources/notebooks.d.ts +77 -7
  75. package/dist/src/resources/notebooks.js +143 -19
  76. package/dist/src/resources/project-git.d.ts +12 -0
  77. package/dist/src/resources/project-git.js +39 -8
  78. package/dist/src/resources/project-library.d.ts +122 -7
  79. package/dist/src/resources/project-library.js +494 -25
  80. package/dist/src/resources/projects.d.ts +5 -4
  81. package/dist/src/resources/projects.js +21 -19
  82. package/dist/src/resources/scenarios.d.ts +30 -0
  83. package/dist/src/resources/scenarios.js +73 -27
  84. package/dist/src/resources/sql.d.ts +6 -0
  85. package/dist/src/resources/sql.js +23 -3
  86. package/dist/src/resources/webapps.d.ts +35 -4
  87. package/dist/src/resources/webapps.js +54 -5
  88. package/dist/src/schemas.d.ts +2 -2
  89. package/dist/src/schemas.js +1 -1
  90. package/dist/src/skill.d.ts +18 -0
  91. package/dist/src/skill.js +93 -9
  92. package/dist/src/utils/flow-analysis.d.ts +53 -0
  93. package/dist/src/utils/flow-analysis.js +382 -0
  94. package/dist/src/utils/project-archive.d.ts +41 -2
  95. package/dist/src/utils/project-archive.js +159 -16
  96. package/dist/src/utils/response-file.d.ts +2 -0
  97. package/dist/src/utils/response-file.js +34 -0
  98. package/package.json +9 -7
  99. package/packages/types/dist/index.d.ts +39 -4
  100. package/packages/types/dist/index.js +31 -2
  101. package/plugin.json +1 -1
  102. package/skills/dataiku-dss/SKILL.md +44 -197
  103. package/skills/dataiku-dss/references/app-releases.md +27 -0
  104. package/skills/dataiku-dss/references/authentication.md +39 -0
  105. package/skills/dataiku-dss/references/coding.md +8 -0
  106. package/skills/dataiku-dss/references/discovery.md +30 -0
  107. package/skills/dataiku-dss/references/flow-maps.md +12 -0
  108. package/skills/dataiku-dss/references/mutations.md +33 -0
  109. package/skills/dataiku-dss/references/troubleshooting.md +29 -0
@@ -1,6 +1,27 @@
1
1
  import { type DssCredentials } from "../config.js";
2
2
  export type TlsSettings = Pick<DssCredentials, "tlsRejectUnauthorized" | "caCertPath">;
3
- export declare function resolveTlsSettings(flags: Record<string, string | boolean>, saved?: TlsSettings): TlsSettings;
3
+ /**
4
+ * Where a resolved credential or TLS setting originated. `project` marks values
5
+ * supplied by the invocation directory's `.env` working-tree file; they are the
6
+ * only untrusted source and must never select the endpoint for a key from any
7
+ * other source.
8
+ */
9
+ export type CredentialSource = "flag" | "env" | "project" | "install" | "saved";
10
+ export type CredentialSources = {
11
+ url?: CredentialSource;
12
+ apiKey?: CredentialSource;
13
+ tlsRejectUnauthorized?: CredentialSource;
14
+ caCertPath?: CredentialSource;
15
+ };
16
+ /**
17
+ * Reject an endpoint (URL/TLS) taken from the project `.env` when the API key
18
+ * would come from anywhere else: project-supplied endpoints must not harvest a
19
+ * user key and transmit it. A project `.env` that supplies the URL and the key
20
+ * together stays supported, as does `DATAIKU_DISABLE_ENV=1`, which stops the
21
+ * loader from recording any project provenance.
22
+ */
23
+ export declare function assertCredentialBinding(sources: CredentialSources): void;
24
+ export declare function resolveTlsSettings(flags: Record<string, string | boolean>, saved?: TlsSettings, sources?: Partial<Pick<CredentialSources, "tlsRejectUnauthorized" | "caCertPath">>): TlsSettings;
4
25
  export declare const currentCommandContext: {
5
26
  resource?: string;
6
27
  action?: string;
@@ -13,3 +34,16 @@ export declare function resolveCredentials(flags: Record<string, string | boolea
13
34
  tlsRejectUnauthorized?: boolean;
14
35
  caCertPath?: string;
15
36
  };
37
+ /**
38
+ * Resolve credentials for `auth login` from explicit flags and the process
39
+ * environment only — never from saved credentials — with provenance tracking
40
+ * and binding enforcement. The call throws before transmitting anything when
41
+ * the project `.env` supplies the URL/TLS configuration while the API key
42
+ * comes from another source.
43
+ */
44
+ export declare function resolveLoginCredentials(flags: Record<string, string | boolean>): {
45
+ url: string;
46
+ apiKey: string;
47
+ projectKey?: string;
48
+ tlsSettings: TlsSettings;
49
+ };
@@ -1,5 +1,35 @@
1
1
  import { loadCredentials, } from "../config.js";
2
- import { dataikuEnvironmentEnabled, } from "./env.js";
2
+ import { dataikuEnvironmentEnabled, envFileProvenance, } from "./env.js";
3
+ import { UsageError, } from "./usage.js";
4
+ function envVarSource(name) {
5
+ return envFileProvenance(name) ?? "env";
6
+ }
7
+ /**
8
+ * Reject an endpoint (URL/TLS) taken from the project `.env` when the API key
9
+ * would come from anywhere else: project-supplied endpoints must not harvest a
10
+ * user key and transmit it. A project `.env` that supplies the URL and the key
11
+ * together stays supported, as does `DATAIKU_DISABLE_ENV=1`, which stops the
12
+ * loader from recording any project provenance.
13
+ */
14
+ export function assertCredentialBinding(sources) {
15
+ if (sources.apiKey === undefined || sources.apiKey === "project")
16
+ return;
17
+ const projectEndpoint = sources.url === "project"
18
+ || sources.tlsRejectUnauthorized === "project"
19
+ || sources.caCertPath === "project";
20
+ if (!projectEndpoint)
21
+ return;
22
+ throw new UsageError("Refusing to pair credentials: the DSS URL/TLS configuration comes from the project .env, but the API key comes from another source.", "conflicting_input_sources", "Supply both DATAIKU_URL and DATAIKU_API_KEY in the project .env, pass --url/--api-key explicitly, or set DATAIKU_DISABLE_ENV=1 to ignore the project .env.", {
23
+ url: sources.url,
24
+ apiKey: sources.apiKey,
25
+ ...(sources.tlsRejectUnauthorized === "project"
26
+ ? { tlsRejectUnauthorized: sources.tlsRejectUnauthorized, }
27
+ : {}),
28
+ ...(sources.caCertPath === "project"
29
+ ? { caCertPath: sources.caCertPath, }
30
+ : {}),
31
+ });
32
+ }
3
33
  function parseTlsRejectUnauthorizedEnv(value) {
4
34
  if (value === undefined)
5
35
  return undefined;
@@ -10,15 +40,38 @@ function parseTlsRejectUnauthorizedEnv(value) {
10
40
  return true;
11
41
  return undefined;
12
42
  }
13
- export function resolveTlsSettings(flags, saved) {
43
+ export function resolveTlsSettings(flags, saved, sources = {}) {
14
44
  let tlsRejectUnauthorized = flags["insecure"] === true ? false : undefined;
15
45
  let caCertPath = flags["ca-cert"];
16
- tlsRejectUnauthorized ??= parseTlsRejectUnauthorizedEnv(process.env.NODE_TLS_REJECT_UNAUTHORIZED);
17
- caCertPath ??= process.env.NODE_EXTRA_CA_CERTS;
46
+ if (flags["insecure"] === true)
47
+ sources.tlsRejectUnauthorized = "flag";
48
+ if (caCertPath !== undefined)
49
+ sources.caCertPath = "flag";
50
+ if (tlsRejectUnauthorized === undefined) {
51
+ const envValue = process.env.NODE_TLS_REJECT_UNAUTHORIZED;
52
+ const parsed = parseTlsRejectUnauthorizedEnv(envValue);
53
+ if (envValue !== undefined && parsed !== undefined) {
54
+ tlsRejectUnauthorized = parsed;
55
+ sources.tlsRejectUnauthorized = envVarSource("NODE_TLS_REJECT_UNAUTHORIZED");
56
+ }
57
+ }
58
+ if (caCertPath === undefined) {
59
+ const envCaCert = process.env.NODE_EXTRA_CA_CERTS;
60
+ if (envCaCert !== undefined) {
61
+ caCertPath = envCaCert;
62
+ sources.caCertPath = envVarSource("NODE_EXTRA_CA_CERTS");
63
+ }
64
+ }
18
65
  if (tlsRejectUnauthorized === undefined) {
19
66
  tlsRejectUnauthorized = saved?.tlsRejectUnauthorized;
67
+ if (tlsRejectUnauthorized !== undefined)
68
+ sources.tlsRejectUnauthorized = "saved";
69
+ }
70
+ if (caCertPath === undefined) {
71
+ caCertPath = saved?.caCertPath;
72
+ if (caCertPath !== undefined)
73
+ sources.caCertPath = "saved";
20
74
  }
21
- caCertPath ??= saved?.caCertPath;
22
75
  return { tlsRejectUnauthorized, caCertPath, };
23
76
  }
24
77
  export const currentCommandContext = {};
@@ -32,28 +85,82 @@ export function resolveCredentials(flags) {
32
85
  let url = hasUrlFlag ? flags["url"] : undefined;
33
86
  let apiKey = hasApiKeyFlag ? flags["api-key"] : undefined;
34
87
  let projectKey = hasProjectKeyFlag ? flags["project-key"] : undefined;
88
+ const sources = {};
89
+ if (hasUrlFlag)
90
+ sources.url = "flag";
91
+ if (hasApiKeyFlag)
92
+ sources.apiKey = "flag";
35
93
  const saved = loadCredentials();
36
94
  const useEnv = dataikuEnvironmentEnabled();
37
95
  if (useEnv) {
38
- if (!hasUrlFlag)
39
- url ??= process.env.DATAIKU_URL;
40
- if (!hasApiKeyFlag)
41
- apiKey ??= process.env.DATAIKU_API_KEY;
42
- if (!hasProjectKeyFlag)
43
- projectKey ??= process.env.DATAIKU_PROJECT_KEY;
96
+ if (!hasUrlFlag && process.env.DATAIKU_URL !== undefined) {
97
+ url = process.env.DATAIKU_URL;
98
+ sources.url = envVarSource("DATAIKU_URL");
99
+ }
100
+ if (!hasApiKeyFlag && process.env.DATAIKU_API_KEY !== undefined) {
101
+ apiKey = process.env.DATAIKU_API_KEY;
102
+ sources.apiKey = envVarSource("DATAIKU_API_KEY");
103
+ }
104
+ if (!hasProjectKeyFlag && process.env.DATAIKU_PROJECT_KEY !== undefined) {
105
+ projectKey = process.env.DATAIKU_PROJECT_KEY;
106
+ }
44
107
  }
45
108
  if (saved) {
46
- if (!hasUrlFlag)
47
- url ??= saved.url;
48
- if (!hasApiKeyFlag)
49
- apiKey ??= saved.apiKey;
50
- if (!hasProjectKeyFlag)
51
- projectKey ??= saved.projectKey;
109
+ if (!hasUrlFlag && url === undefined) {
110
+ url = saved.url;
111
+ sources.url = "saved";
112
+ }
113
+ if (!hasApiKeyFlag && apiKey === undefined) {
114
+ apiKey = saved.apiKey;
115
+ sources.apiKey = "saved";
116
+ }
117
+ if (!hasProjectKeyFlag && projectKey === undefined) {
118
+ projectKey = saved.projectKey;
119
+ }
52
120
  }
121
+ const tlsSettings = resolveTlsSettings(flags, saved ?? undefined, sources);
122
+ assertCredentialBinding(sources);
53
123
  return {
54
124
  url: url ?? "",
55
125
  apiKey: apiKey ?? "",
56
126
  projectKey,
57
- ...resolveTlsSettings(flags, saved ?? undefined),
127
+ ...tlsSettings,
58
128
  };
59
129
  }
130
+ /**
131
+ * Resolve credentials for `auth login` from explicit flags and the process
132
+ * environment only — never from saved credentials — with provenance tracking
133
+ * and binding enforcement. The call throws before transmitting anything when
134
+ * the project `.env` supplies the URL/TLS configuration while the API key
135
+ * comes from another source.
136
+ */
137
+ export function resolveLoginCredentials(flags) {
138
+ const hasUrlFlag = typeof flags["url"] === "string";
139
+ const hasApiKeyFlag = typeof flags["api-key"] === "string";
140
+ const hasProjectKeyFlag = typeof flags["project-key"] === "string";
141
+ let url = hasUrlFlag ? flags["url"] : undefined;
142
+ let apiKey = hasApiKeyFlag ? flags["api-key"] : undefined;
143
+ let projectKey = hasProjectKeyFlag ? flags["project-key"] : undefined;
144
+ const sources = {};
145
+ if (hasUrlFlag)
146
+ sources.url = "flag";
147
+ if (hasApiKeyFlag)
148
+ sources.apiKey = "flag";
149
+ const useEnv = dataikuEnvironmentEnabled();
150
+ if (useEnv) {
151
+ if (!hasUrlFlag && process.env.DATAIKU_URL !== undefined) {
152
+ url = process.env.DATAIKU_URL;
153
+ sources.url = envVarSource("DATAIKU_URL");
154
+ }
155
+ if (!hasApiKeyFlag && process.env.DATAIKU_API_KEY !== undefined) {
156
+ apiKey = process.env.DATAIKU_API_KEY;
157
+ sources.apiKey = envVarSource("DATAIKU_API_KEY");
158
+ }
159
+ if (!hasProjectKeyFlag && process.env.DATAIKU_PROJECT_KEY !== undefined) {
160
+ projectKey = process.env.DATAIKU_PROJECT_KEY;
161
+ }
162
+ }
163
+ const tlsSettings = resolveTlsSettings(flags, undefined, sources);
164
+ assertCredentialBinding(sources);
165
+ return { url: url ?? "", apiKey: apiKey ?? "", projectKey, tlsSettings, };
166
+ }
@@ -5,6 +5,7 @@ export interface CommandPayloadSchema {
5
5
  stdin?: boolean;
6
6
  dataFlag?: boolean;
7
7
  dataFileFlag?: boolean;
8
+ contentType?: "application/json" | "text/plain";
8
9
  jsonShape?: "object" | "array";
9
10
  }
10
11
  export interface CommandFlagChoice {
@@ -21,6 +22,12 @@ export interface CommandRegistryOverride {
21
22
  export interface CommandMeta extends CommandRegistryOverride {
22
23
  handler: CommandHandler;
23
24
  localHandler?: LocalCommandHandler;
25
+ /**
26
+ * Pure, DSS-free argument validation run before credentials are resolved,
27
+ * so a bad flag value is reported as its own usage error even when no
28
+ * credentials are configured, instead of being masked by a missing-URL error.
29
+ */
30
+ validate?: (args: string[], flags: Record<string, string | boolean>) => void;
24
31
  usage: string;
25
32
  description?: string;
26
33
  examples?: string[];