dataiku-sdk 0.10.1 → 0.12.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 (151) hide show
  1. package/LICENSE +21 -0
  2. package/dist/packages/types/src/index.d.ts +19 -2
  3. package/dist/packages/types/src/index.js +13 -1
  4. package/dist/src/cli/coerce.d.ts +36 -0
  5. package/dist/src/cli/coerce.js +239 -0
  6. package/dist/src/cli/commands/analysis.d.ts +2 -0
  7. package/dist/src/cli/commands/analysis.js +66 -0
  8. package/dist/src/cli/commands/api-deployer.d.ts +2 -0
  9. package/dist/src/cli/commands/api-deployer.js +170 -0
  10. package/dist/src/cli/commands/api-service.d.ts +2 -0
  11. package/dist/src/cli/commands/api-service.js +121 -0
  12. package/dist/src/cli/commands/app.d.ts +2 -0
  13. package/dist/src/cli/commands/app.js +78 -0
  14. package/dist/src/cli/commands/bundle.d.ts +2 -0
  15. package/dist/src/cli/commands/bundle.js +107 -0
  16. package/dist/src/cli/commands/business-app.d.ts +2 -0
  17. package/dist/src/cli/commands/business-app.js +76 -0
  18. package/dist/src/cli/commands/code-env.d.ts +2 -0
  19. package/dist/src/cli/commands/code-env.js +255 -0
  20. package/dist/src/cli/commands/code.d.ts +2 -0
  21. package/dist/src/cli/commands/code.js +63 -0
  22. package/dist/src/cli/commands/connection.d.ts +2 -0
  23. package/dist/src/cli/commands/connection.js +54 -0
  24. package/dist/src/cli/commands/continuous-activity.d.ts +2 -0
  25. package/dist/src/cli/commands/continuous-activity.js +38 -0
  26. package/dist/src/cli/commands/dashboard.d.ts +2 -0
  27. package/dist/src/cli/commands/dashboard.js +99 -0
  28. package/dist/src/cli/commands/data-quality.d.ts +2 -0
  29. package/dist/src/cli/commands/data-quality.js +235 -0
  30. package/dist/src/cli/commands/dataset.d.ts +2 -0
  31. package/dist/src/cli/commands/dataset.js +288 -0
  32. package/dist/src/cli/commands/discussion.d.ts +2 -0
  33. package/dist/src/cli/commands/discussion.js +47 -0
  34. package/dist/src/cli/commands/doctor.d.ts +2 -0
  35. package/dist/src/cli/commands/doctor.js +9 -0
  36. package/dist/src/cli/commands/flow-zone.d.ts +2 -0
  37. package/dist/src/cli/commands/flow-zone.js +282 -0
  38. package/dist/src/cli/commands/folder.d.ts +2 -0
  39. package/dist/src/cli/commands/folder.js +202 -0
  40. package/dist/src/cli/commands/future.d.ts +2 -0
  41. package/dist/src/cli/commands/future.js +57 -0
  42. package/dist/src/cli/commands/index.d.ts +2 -0
  43. package/dist/src/cli/commands/index.js +78 -0
  44. package/dist/src/cli/commands/insight.d.ts +2 -0
  45. package/dist/src/cli/commands/insight.js +156 -0
  46. package/dist/src/cli/commands/job.d.ts +2 -0
  47. package/dist/src/cli/commands/job.js +406 -0
  48. package/dist/src/cli/commands/meaning.d.ts +2 -0
  49. package/dist/src/cli/commands/meaning.js +115 -0
  50. package/dist/src/cli/commands/metrics.d.ts +2 -0
  51. package/dist/src/cli/commands/metrics.js +39 -0
  52. package/dist/src/cli/commands/ml-task.d.ts +2 -0
  53. package/dist/src/cli/commands/ml-task.js +171 -0
  54. package/dist/src/cli/commands/model-evaluation-store.d.ts +2 -0
  55. package/dist/src/cli/commands/model-evaluation-store.js +83 -0
  56. package/dist/src/cli/commands/notebook.d.ts +2 -0
  57. package/dist/src/cli/commands/notebook.js +242 -0
  58. package/dist/src/cli/commands/project-deployer.d.ts +2 -0
  59. package/dist/src/cli/commands/project-deployer.js +118 -0
  60. package/dist/src/cli/commands/project-library.d.ts +2 -0
  61. package/dist/src/cli/commands/project-library.js +197 -0
  62. package/dist/src/cli/commands/project.d.ts +2 -0
  63. package/dist/src/cli/commands/project.js +133 -0
  64. package/dist/src/cli/commands/recipe.d.ts +2 -0
  65. package/dist/src/cli/commands/recipe.js +659 -0
  66. package/dist/src/cli/commands/saved-model.d.ts +2 -0
  67. package/dist/src/cli/commands/saved-model.js +85 -0
  68. package/dist/src/cli/commands/scenario.d.ts +2 -0
  69. package/dist/src/cli/commands/scenario.js +190 -0
  70. package/dist/src/cli/commands/sql.d.ts +2 -0
  71. package/dist/src/cli/commands/sql.js +109 -0
  72. package/dist/src/cli/commands/statistics.d.ts +2 -0
  73. package/dist/src/cli/commands/statistics.js +165 -0
  74. package/dist/src/cli/commands/streaming-endpoint.d.ts +2 -0
  75. package/dist/src/cli/commands/streaming-endpoint.js +50 -0
  76. package/dist/src/cli/commands/variable.d.ts +2 -0
  77. package/dist/src/cli/commands/variable.js +49 -0
  78. package/dist/src/cli/commands/webapp.d.ts +2 -0
  79. package/dist/src/cli/commands/webapp.js +67 -0
  80. package/dist/src/cli/commands/wiki.d.ts +2 -0
  81. package/dist/src/cli/commands/wiki.js +123 -0
  82. package/dist/src/cli/commands/workspace.d.ts +2 -0
  83. package/dist/src/cli/commands/workspace.js +68 -0
  84. package/dist/src/cli/contract.d.ts +104 -0
  85. package/dist/src/cli/contract.js +2041 -0
  86. package/dist/src/cli/doctor.d.ts +104 -0
  87. package/dist/src/cli/doctor.js +356 -0
  88. package/dist/src/cli/env.d.ts +2 -0
  89. package/dist/src/cli/env.js +37 -0
  90. package/dist/src/cli/flags.d.ts +16 -0
  91. package/dist/src/cli/flags.js +272 -0
  92. package/dist/src/cli/helpers/cleanup.d.ts +3 -0
  93. package/dist/src/cli/helpers/cleanup.js +204 -0
  94. package/dist/src/cli/helpers/dataset.d.ts +2 -0
  95. package/dist/src/cli/helpers/dataset.js +17 -0
  96. package/dist/src/cli/helpers/flow-zone.d.ts +69 -0
  97. package/dist/src/cli/helpers/flow-zone.js +420 -0
  98. package/dist/src/cli/helpers/recipe.d.ts +11 -0
  99. package/dist/src/cli/helpers/recipe.js +83 -0
  100. package/dist/src/cli/output.d.ts +38 -0
  101. package/dist/src/cli/output.js +159 -0
  102. package/dist/src/cli/runtime.d.ts +15 -0
  103. package/dist/src/cli/runtime.js +59 -0
  104. package/dist/src/cli/types.d.ts +25 -0
  105. package/dist/src/cli/types.js +1 -0
  106. package/dist/src/cli/usage.d.ts +16 -0
  107. package/dist/src/cli/usage.js +84 -0
  108. package/dist/src/cli/version.d.ts +14 -0
  109. package/dist/src/cli/version.js +63 -0
  110. package/dist/src/cli.js +671 -8254
  111. package/dist/src/client.d.ts +13 -1
  112. package/dist/src/client.js +34 -13
  113. package/dist/src/errors.d.ts +6 -0
  114. package/dist/src/errors.js +102 -4
  115. package/dist/src/index.d.ts +7 -3
  116. package/dist/src/index.js +6 -2
  117. package/dist/src/resources/analyses.d.ts +34 -0
  118. package/dist/src/resources/analyses.js +31 -0
  119. package/dist/src/resources/api-services.d.ts +2 -0
  120. package/dist/src/resources/api-services.js +10 -0
  121. package/dist/src/resources/applications.d.ts +1 -1
  122. package/dist/src/resources/applications.js +27 -1
  123. package/dist/src/resources/continuous-activities.js +1 -0
  124. package/dist/src/resources/data-quality.js +5 -3
  125. package/dist/src/resources/datasets.d.ts +3 -0
  126. package/dist/src/resources/datasets.js +10 -5
  127. package/dist/src/resources/flow-zones.d.ts +2 -2
  128. package/dist/src/resources/flow-zones.js +4 -1
  129. package/dist/src/resources/meanings.d.ts +2 -0
  130. package/dist/src/resources/meanings.js +4 -0
  131. package/dist/src/resources/ml-tasks.d.ts +91 -0
  132. package/dist/src/resources/ml-tasks.js +130 -0
  133. package/dist/src/resources/model-evaluation-stores.d.ts +41 -0
  134. package/dist/src/resources/model-evaluation-stores.js +36 -0
  135. package/dist/src/resources/notebooks.d.ts +5 -7
  136. package/dist/src/resources/notebooks.js +10 -7
  137. package/dist/src/resources/projects.d.ts +1 -1
  138. package/dist/src/resources/projects.js +2 -2
  139. package/dist/src/resources/recipes.d.ts +3 -3
  140. package/dist/src/resources/recipes.js +198 -38
  141. package/dist/src/resources/saved-models.d.ts +41 -0
  142. package/dist/src/resources/saved-models.js +40 -0
  143. package/dist/src/resources/scenarios.js +67 -26
  144. package/dist/src/resources/statistics.js +9 -0
  145. package/dist/src/schemas.d.ts +2 -2
  146. package/dist/src/schemas.js +1 -1
  147. package/dist/src/skill.js +2 -2
  148. package/dist/src/utils/sanitize.js +2 -1
  149. package/package.json +1 -1
  150. package/packages/types/dist/index.d.ts +19 -2
  151. package/packages/types/dist/index.js +13 -1
@@ -0,0 +1,202 @@
1
+ import { deepMerge, } from "../../utils/deep-merge.js";
2
+ import { jsonInput, } from "../coerce.js";
3
+ import { addTransientTargetContext, encodedProjectEndpoint, readIfExists, skipResult, } from "../output.js";
4
+ import { requireArgs, UsageError, } from "../usage.js";
5
+ async function resolveFolderId(client, nameOrId, flags) {
6
+ return client.folders.resolveId(nameOrId, flags["project-key"]);
7
+ }
8
+ export const folderCommands = {
9
+ list: {
10
+ handler: (c, _a, f) => c.folders.list(f["project-key"]),
11
+ usage: "dss folder list [--project-key KEY]",
12
+ description: "List managed folders in a project.",
13
+ examples: ["dss folder list",],
14
+ },
15
+ create: {
16
+ handler: async (c, _a, f) => {
17
+ const name = f["name"];
18
+ const type = f["type"];
19
+ const connection = f["connection"];
20
+ const pk = f["project-key"];
21
+ if (!name || !type || !connection) {
22
+ throw new UsageError("--name, --type, and --connection are required. Usage: dss folder create --name NAME --type TYPE --connection CONN [--path PATH]");
23
+ }
24
+ const payload = {
25
+ name,
26
+ type,
27
+ connection,
28
+ path: f["path"],
29
+ projectKey: pk,
30
+ };
31
+ if (f["if-not-exists"] === true || f["dry-run"] === true) {
32
+ const list = await c.folders.list(pk);
33
+ const existing = list.find((folder) => folder.name === name);
34
+ if (existing && f["if-not-exists"] === true && f["dry-run"] !== true) {
35
+ return skipResult("folder", existing.id ?? name, "exists", { current: existing, });
36
+ }
37
+ if (f["dry-run"] === true) {
38
+ return {
39
+ dryRun: true,
40
+ action: "create",
41
+ resource: "folder",
42
+ name,
43
+ payload,
44
+ ...(existing ? { current: existing, } : {}),
45
+ };
46
+ }
47
+ }
48
+ const created = await c.folders.create(payload);
49
+ return { created: created.id ?? name, resource: "folder", ...created, };
50
+ },
51
+ usage: "dss folder create --name NAME --type TYPE --connection CONN [--path PATH] [--if-not-exists] [--dry-run] [--project-key KEY]",
52
+ description: "Create a managed folder.",
53
+ examples: [
54
+ "dss folder create --name exports --type S3 --connection s3_connection",
55
+ "dss folder create --name exports --type S3 --connection s3_connection --path /dataiku/MYPROJ/exports --dry-run",
56
+ ],
57
+ },
58
+ get: {
59
+ handler: async (c, a, f) => {
60
+ requireArgs(a, 1, "dss folder get <name-or-id>");
61
+ return c.folders.get(await resolveFolderId(c, a[0], f), f["project-key"]);
62
+ },
63
+ usage: "dss folder get <name-or-id> [--project-key KEY]",
64
+ description: "Get managed folder settings.",
65
+ examples: ["dss folder get my_folder",],
66
+ },
67
+ update: {
68
+ handler: async (c, a, f) => {
69
+ requireArgs(a, 1, "dss folder update <name-or-id> [--data '{...}' | --data-file PATH | --stdin]");
70
+ const data = jsonInput(f);
71
+ if (!data) {
72
+ throw new UsageError("--data, --data-file, or --stdin is required. Usage: dss folder update <name-or-id> [--data '{...}' | --data-file PATH | --stdin]");
73
+ }
74
+ const pk = f["project-key"];
75
+ const folderId = await resolveFolderId(c, a[0], f);
76
+ if (f["dry-run"] === true) {
77
+ const current = await c.folders.get(folderId, pk);
78
+ const next = deepMerge(current, data);
79
+ return {
80
+ dryRun: true,
81
+ action: "update",
82
+ resource: "folder",
83
+ folder: a[0],
84
+ folderId,
85
+ current,
86
+ next,
87
+ };
88
+ }
89
+ await c.folders.update(folderId, data, pk);
90
+ return { updated: folderId, resource: "folder", };
91
+ },
92
+ usage: "dss folder update <name-or-id> [--data JSON | --data-file PATH | --stdin] [--dry-run] [--project-key KEY]",
93
+ description: "Update managed folder settings by deep-merging a JSON patch.",
94
+ examples: [
95
+ 'dss folder update exports --data \'{"tags":["agent"]}\' --dry-run',
96
+ "dss folder update exports --data-file folder-patch.json",
97
+ ],
98
+ },
99
+ delete: {
100
+ handler: async (c, a, f) => {
101
+ requireArgs(a, 1, "dss folder delete <name-or-id>");
102
+ const pk = f["project-key"];
103
+ const folderId = await resolveFolderId(c, a[0], f);
104
+ if (f["dry-run"] === true || f["if-exists"] === true) {
105
+ const current = await readIfExists(() => c.folders.get(folderId, pk));
106
+ if (!current)
107
+ return skipResult("folder", folderId, "missing");
108
+ if (f["dry-run"] === true) {
109
+ return {
110
+ dryRun: true,
111
+ action: "delete",
112
+ resource: "folder",
113
+ folder: a[0],
114
+ folderId,
115
+ current,
116
+ };
117
+ }
118
+ }
119
+ await c.folders.delete(folderId, pk);
120
+ return { deleted: folderId, resource: "folder", };
121
+ },
122
+ usage: "dss folder delete <name-or-id> [--if-exists] [--dry-run] [--project-key KEY]",
123
+ description: "Delete a managed folder.",
124
+ examples: ["dss folder delete exports --if-exists",],
125
+ },
126
+ contents: {
127
+ handler: async (c, a, f) => {
128
+ requireArgs(a, 1, "dss folder contents <name-or-id>");
129
+ const startedAt = Date.now();
130
+ let folderId = a[0];
131
+ try {
132
+ folderId = await resolveFolderId(c, a[0], f);
133
+ return await c.folders.contents(folderId, {
134
+ projectKey: f["project-key"],
135
+ });
136
+ }
137
+ catch (error) {
138
+ addTransientTargetContext(error, `folder:${folderId}`, Date.now() - startedAt);
139
+ }
140
+ },
141
+ usage: "dss folder contents <name-or-id> [--retries N] [--request-timeout MS] [--project-key KEY]",
142
+ description: "List files in a managed folder.",
143
+ examples: [
144
+ "dss folder contents my_folder",
145
+ "dss folder contents my_folder --retries 8 --request-timeout 60000",
146
+ ],
147
+ },
148
+ download: {
149
+ handler: async (c, a, f) => {
150
+ requireArgs(a, 2, "dss folder download <name-or-id> <remote-path> [local-path]");
151
+ const localPath = a[2] ?? f["output"];
152
+ return c.folders.download(await resolveFolderId(c, a[0], f), a[1], {
153
+ localPath,
154
+ projectKey: f["project-key"],
155
+ });
156
+ },
157
+ usage: "dss folder download <name-or-id> <remote-path> [local-path] [--output PATH] [--project-key KEY]",
158
+ description: "Download a file from a managed folder.",
159
+ examples: [
160
+ "dss folder download my_folder /data/report.csv",
161
+ "dss folder download my_folder /data/report.csv ./report.csv",
162
+ ],
163
+ },
164
+ upload: {
165
+ handler: async (c, a, f) => {
166
+ requireArgs(a, 3, "dss folder upload <name-or-id> <path> <localPath>");
167
+ const pk = f["project-key"];
168
+ const folderId = await resolveFolderId(c, a[0], f);
169
+ if (f["dry-run"] === true) {
170
+ return {
171
+ dryRun: true,
172
+ action: "upload",
173
+ resource: "folder",
174
+ folder: a[0],
175
+ folderId,
176
+ path: a[1],
177
+ localPath: a[2],
178
+ endpoint: encodedProjectEndpoint(c, pk, `/managedfolders/${encodeURIComponent(folderId)}/contents/${encodeURIComponent(a[1])}`),
179
+ method: "POST",
180
+ };
181
+ }
182
+ await c.folders.upload(folderId, a[1], a[2], pk);
183
+ return { uploaded: a[1], folder: a[0], localPath: a[2], resource: "folder", };
184
+ },
185
+ usage: "dss folder upload <name-or-id> <path> <localPath> [--dry-run] [--project-key KEY]",
186
+ description: "Upload a local file to a managed folder.",
187
+ examples: ["dss folder upload my_folder /data/report.csv ./report.csv --dry-run",],
188
+ },
189
+ "delete-file": {
190
+ handler: async (c, a, f) => {
191
+ requireArgs(a, 2, "dss folder delete-file <name-or-id> <path>");
192
+ if (f["dry-run"] === true) {
193
+ return { dryRun: true, action: "delete-file", resource: "folder", folder: a[0], path: a[1], };
194
+ }
195
+ await c.folders.deleteFile(await resolveFolderId(c, a[0], f), a[1], f["project-key"]);
196
+ return { deleted: a[1], folder: a[0], resource: "folder", };
197
+ },
198
+ usage: "dss folder delete-file <name-or-id> <path> [--dry-run] [--project-key KEY]",
199
+ description: "Delete a file from a managed folder.",
200
+ examples: ["dss folder delete-file my_folder /data/report.csv",],
201
+ },
202
+ };
@@ -0,0 +1,2 @@
1
+ import type { CommandMeta } from "../types.js";
2
+ export declare const futureCommands: Record<string, CommandMeta>;
@@ -0,0 +1,57 @@
1
+ import { num, } from "../coerce.js";
2
+ import { planResult, } from "../output.js";
3
+ import { requireArgs, } from "../usage.js";
4
+ export const futureCommands = {
5
+ get: {
6
+ handler: (c, a) => {
7
+ requireArgs(a, 1, "dss future get <id>");
8
+ return c.futures.get(a[0]);
9
+ },
10
+ usage: "dss future get <id>",
11
+ description: "Get a DSS future state and retrieve the result if ready.",
12
+ examples: ["dss future get FUTURE_ID",],
13
+ },
14
+ peek: {
15
+ handler: (c, a) => {
16
+ requireArgs(a, 1, "dss future peek <id>");
17
+ return c.futures.peek(a[0]);
18
+ },
19
+ usage: "dss future peek <id>",
20
+ description: "Peek at a DSS future state without consuming its result.",
21
+ examples: ["dss future peek FUTURE_ID",],
22
+ },
23
+ wait: {
24
+ handler: (c, a, f) => {
25
+ requireArgs(a, 1, "dss future wait <id>");
26
+ return c.futures.wait(a[0], {
27
+ pollIntervalMs: num(f["poll-interval"]),
28
+ timeoutMs: num(f["timeout"]),
29
+ });
30
+ },
31
+ usage: "dss future wait <id> [--timeout MS] [--poll-interval MS]",
32
+ description: "Wait for a DSS future to finish.",
33
+ examples: ["dss future wait FUTURE_ID --timeout 60000",],
34
+ },
35
+ abort: {
36
+ handler: async (c, a, f) => {
37
+ requireArgs(a, 1, "dss future abort <id>");
38
+ const id = a[0];
39
+ if (f["dry-run"] === true) {
40
+ return planResult("future", "abort", {
41
+ method: "POST",
42
+ endpoint: `/public/api/futures/${encodeURIComponent(id)}/abort`,
43
+ identifiers: { id, },
44
+ idempotency: "none",
45
+ asyncKind: "future",
46
+ exitCodesOnFailure: { usage: 1, error: 2, transient: 3, longRunningFailure: 4, },
47
+ plannedAndDryRun: true,
48
+ });
49
+ }
50
+ await c.futures.abort(id);
51
+ return { aborted: id, resource: "future", };
52
+ },
53
+ usage: "dss future abort <id> [--dry-run]",
54
+ description: "Abort a DSS future.",
55
+ examples: ["dss future abort FUTURE_ID --dry-run",],
56
+ },
57
+ };
@@ -0,0 +1,2 @@
1
+ import type { CommandMeta } from "../types.js";
2
+ export declare const commands: Record<string, Record<string, CommandMeta>>;
@@ -0,0 +1,78 @@
1
+ import { analysisCommands, } from "./analysis.js";
2
+ import { apiDeployerCommands, } from "./api-deployer.js";
3
+ import { apiServiceCommands, } from "./api-service.js";
4
+ import { appCommands, } from "./app.js";
5
+ import { bundleCommands, } from "./bundle.js";
6
+ import { businessAppCommands, } from "./business-app.js";
7
+ import { codeEnvCommands, } from "./code-env.js";
8
+ import { codeCommands, } from "./code.js";
9
+ import { connectionCommands, } from "./connection.js";
10
+ import { continuousActivityCommands, } from "./continuous-activity.js";
11
+ import { dashboardCommands, } from "./dashboard.js";
12
+ import { dataQualityCommands, } from "./data-quality.js";
13
+ import { datasetCommands, } from "./dataset.js";
14
+ import { discussionCommands, } from "./discussion.js";
15
+ import { doctorCommands, } from "./doctor.js";
16
+ import { flowZoneCommands, } from "./flow-zone.js";
17
+ import { folderCommands, } from "./folder.js";
18
+ import { futureCommands, } from "./future.js";
19
+ import { insightCommands, } from "./insight.js";
20
+ import { jobCommands, } from "./job.js";
21
+ import { meaningCommands, } from "./meaning.js";
22
+ import { metricsCommands, } from "./metrics.js";
23
+ import { mlTaskCommands, } from "./ml-task.js";
24
+ import { modelEvaluationStoreCommands, } from "./model-evaluation-store.js";
25
+ import { notebookCommands, } from "./notebook.js";
26
+ import { projectDeployerCommands, } from "./project-deployer.js";
27
+ import { projectLibraryCommands, } from "./project-library.js";
28
+ import { projectCommands, } from "./project.js";
29
+ import { recipeCommands, } from "./recipe.js";
30
+ import { savedModelCommands, } from "./saved-model.js";
31
+ import { scenarioCommands, } from "./scenario.js";
32
+ import { sqlCommands, } from "./sql.js";
33
+ import { statisticsCommands, } from "./statistics.js";
34
+ import { streamingEndpointCommands, } from "./streaming-endpoint.js";
35
+ import { variableCommands, } from "./variable.js";
36
+ import { webappCommands, } from "./webapp.js";
37
+ import { wikiCommands, } from "./wiki.js";
38
+ import { workspaceCommands, } from "./workspace.js";
39
+ export const commands = {
40
+ project: projectCommands,
41
+ analysis: analysisCommands,
42
+ "ml-task": mlTaskCommands,
43
+ "saved-model": savedModelCommands,
44
+ "model-evaluation-store": modelEvaluationStoreCommands,
45
+ app: appCommands,
46
+ "business-app": businessAppCommands,
47
+ webapp: webappCommands,
48
+ "api-service": apiServiceCommands,
49
+ "api-deployer": apiDeployerCommands,
50
+ bundle: bundleCommands,
51
+ "project-deployer": projectDeployerCommands,
52
+ "project-library": projectLibraryCommands,
53
+ "streaming-endpoint": streamingEndpointCommands,
54
+ "continuous-activity": continuousActivityCommands,
55
+ statistics: statisticsCommands,
56
+ discussion: discussionCommands,
57
+ meaning: meaningCommands,
58
+ workspace: workspaceCommands,
59
+ metrics: metricsCommands,
60
+ doctor: doctorCommands,
61
+ wiki: wikiCommands,
62
+ dashboard: dashboardCommands,
63
+ insight: insightCommands,
64
+ "data-quality": dataQualityCommands,
65
+ future: futureCommands,
66
+ "flow-zone": flowZoneCommands,
67
+ dataset: datasetCommands,
68
+ recipe: recipeCommands,
69
+ job: jobCommands,
70
+ scenario: scenarioCommands,
71
+ folder: folderCommands,
72
+ variable: variableCommands,
73
+ connection: connectionCommands,
74
+ "code-env": codeEnvCommands,
75
+ sql: sqlCommands,
76
+ code: codeCommands,
77
+ notebook: notebookCommands,
78
+ };
@@ -0,0 +1,2 @@
1
+ import type { CommandMeta } from "../types.js";
2
+ export declare const insightCommands: Record<string, CommandMeta>;
@@ -0,0 +1,156 @@
1
+ import { deepMerge, } from "../../utils/deep-merge.js";
2
+ import { json, jsonInput, parseBooleanOption, textInput, } from "../coerce.js";
3
+ import { readIfExists, skipResult, } from "../output.js";
4
+ import { requireArgs, UsageError, } from "../usage.js";
5
+ export const insightCommands = {
6
+ list: {
7
+ handler: (c, _a, f) => c.insights.list(f["project-key"]),
8
+ usage: "dss insight list [--project-key KEY]",
9
+ description: "List project insights.",
10
+ examples: ["dss insight list",],
11
+ },
12
+ get: {
13
+ handler: (c, a, f) => {
14
+ requireArgs(a, 1, "dss insight get <id>");
15
+ return c.insights.get(a[0], f["project-key"]);
16
+ },
17
+ usage: "dss insight get <id> [--project-key KEY]",
18
+ description: "Get insight definition.",
19
+ examples: ["dss insight get INSIGHT_ID",],
20
+ },
21
+ create: {
22
+ handler: async (c, _a, f) => {
23
+ const data = jsonInput(f);
24
+ const name = f["name"];
25
+ const type = f["type"];
26
+ const params = json(f["params"]);
27
+ const listed = parseBooleanOption(f["listed"], "--listed");
28
+ const contentType = f["content-type"];
29
+ const payload = textInput(f);
30
+ if (!data && (!name || !type)) {
31
+ throw new UsageError("--data or both --name and --type are required. Usage: dss insight create --name NAME --type TYPE");
32
+ }
33
+ const prototype = { ...data, };
34
+ if (name !== undefined)
35
+ prototype.name = name;
36
+ if (type !== undefined)
37
+ prototype.type = type;
38
+ if (listed !== undefined)
39
+ prototype.listed = listed;
40
+ if (params !== undefined)
41
+ prototype.params = params;
42
+ const pk = f["project-key"];
43
+ if (f["if-not-exists"] === true || f["dry-run"] === true) {
44
+ const existing = name
45
+ ? (await c.insights.list(pk)).find((insight) => insight.name === name)
46
+ : undefined;
47
+ if (existing && f["if-not-exists"] === true && f["dry-run"] !== true) {
48
+ return skipResult("insight", existing.id, "exists", { current: existing, });
49
+ }
50
+ if (f["if-not-exists"] === true && !name && f["dry-run"] !== true) {
51
+ throw new UsageError("--if-not-exists requires --name for insight create.");
52
+ }
53
+ if (f["dry-run"] === true) {
54
+ return {
55
+ dryRun: true,
56
+ action: "create",
57
+ resource: "insight",
58
+ name,
59
+ payload: prototype,
60
+ contentType,
61
+ content: payload,
62
+ ...(existing ? { current: existing, } : {}),
63
+ };
64
+ }
65
+ }
66
+ const created = await c.insights.create({
67
+ data,
68
+ name,
69
+ type,
70
+ listed,
71
+ params,
72
+ contentType,
73
+ payload,
74
+ projectKey: pk,
75
+ });
76
+ return { created: created.id, resource: "insight", ...created, };
77
+ },
78
+ usage: "dss insight create (--data JSON|--data-file PATH|--stdin | --name NAME --type TYPE [--params JSON] [--listed true|false]) [--content TEXT|--file PATH --content-type MIME] [--if-not-exists] [--dry-run] [--project-key KEY]",
79
+ description: "Create an insight from a raw prototype or minimal name/type fields.",
80
+ examples: [
81
+ "dss insight create --name 'Agent chart' --type chart --params '{\"dataset\":\"orders\"}' --dry-run",
82
+ "dss insight create --data-file insight-prototype.json --dry-run",
83
+ ],
84
+ },
85
+ update: {
86
+ handler: async (c, a, f) => {
87
+ requireArgs(a, 1, "dss insight update <id> [--name NAME|--params JSON|--data JSON]");
88
+ const data = jsonInput(f);
89
+ const name = f["name"];
90
+ const params = json(f["params"]);
91
+ const listed = parseBooleanOption(f["listed"], "--listed");
92
+ const contentType = f["content-type"];
93
+ const payload = textInput(f);
94
+ if (!data && name === undefined && params === undefined && listed === undefined
95
+ && contentType === undefined && payload === undefined) {
96
+ throw new UsageError("--name, --listed, --params, --content, --file, --data, --data-file, or --stdin is required.");
97
+ }
98
+ if (f["dry-run"] === true) {
99
+ const current = await c.insights.get(a[0], f["project-key"]);
100
+ const next = deepMerge(current, data ?? {});
101
+ if (name !== undefined)
102
+ next.name = name;
103
+ if (listed !== undefined)
104
+ next.listed = listed;
105
+ if (params !== undefined) {
106
+ const currentParams = next.params;
107
+ next.params =
108
+ currentParams && typeof currentParams === "object" && !Array.isArray(currentParams)
109
+ ? deepMerge(currentParams, params)
110
+ : params;
111
+ }
112
+ return {
113
+ dryRun: true,
114
+ action: "update",
115
+ resource: "insight",
116
+ id: a[0],
117
+ current,
118
+ next,
119
+ contentType,
120
+ payload,
121
+ };
122
+ }
123
+ return c.insights.update(a[0], {
124
+ data,
125
+ name,
126
+ listed,
127
+ params,
128
+ contentType,
129
+ payload,
130
+ projectKey: f["project-key"],
131
+ });
132
+ },
133
+ usage: "dss insight update <id> [--name NAME] [--listed true|false] [--params JSON] [--content TEXT|--file PATH --content-type MIME] [--data JSON|--data-file PATH|--stdin] [--dry-run] [--project-key KEY]",
134
+ description: "Update an insight using GET-before-POST merge semantics.",
135
+ examples: ["dss insight update INSIGHT_ID --name 'Updated' --dry-run",],
136
+ },
137
+ delete: {
138
+ handler: async (c, a, f) => {
139
+ requireArgs(a, 1, "dss insight delete <id>");
140
+ const pk = f["project-key"];
141
+ if (f["dry-run"] === true || f["if-exists"] === true) {
142
+ const current = await readIfExists(() => c.insights.get(a[0], pk));
143
+ if (!current)
144
+ return skipResult("insight", a[0], "missing");
145
+ if (f["dry-run"] === true) {
146
+ return { dryRun: true, action: "delete", resource: "insight", id: a[0], current, };
147
+ }
148
+ }
149
+ await c.insights.delete(a[0], pk);
150
+ return { deleted: a[0], resource: "insight", };
151
+ },
152
+ usage: "dss insight delete <id> [--if-exists] [--dry-run] [--project-key KEY]",
153
+ description: "Delete an insight.",
154
+ examples: ["dss insight delete INSIGHT_ID --dry-run",],
155
+ },
156
+ };
@@ -0,0 +1,2 @@
1
+ import type { CommandMeta } from "../types.js";
2
+ export declare const jobCommands: Record<string, CommandMeta>;