dataiku-sdk 0.10.1 → 0.11.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/packages/types/src/index.d.ts +15 -2
- package/dist/packages/types/src/index.js +9 -1
- package/dist/src/cli/coerce.d.ts +36 -0
- package/dist/src/cli/coerce.js +239 -0
- package/dist/src/cli/commands/api-deployer.d.ts +2 -0
- package/dist/src/cli/commands/api-deployer.js +170 -0
- package/dist/src/cli/commands/api-service.d.ts +2 -0
- package/dist/src/cli/commands/api-service.js +102 -0
- package/dist/src/cli/commands/app.d.ts +2 -0
- package/dist/src/cli/commands/app.js +78 -0
- package/dist/src/cli/commands/bundle.d.ts +2 -0
- package/dist/src/cli/commands/bundle.js +107 -0
- package/dist/src/cli/commands/business-app.d.ts +2 -0
- package/dist/src/cli/commands/business-app.js +76 -0
- package/dist/src/cli/commands/code-env.d.ts +2 -0
- package/dist/src/cli/commands/code-env.js +255 -0
- package/dist/src/cli/commands/code.d.ts +2 -0
- package/dist/src/cli/commands/code.js +63 -0
- package/dist/src/cli/commands/connection.d.ts +2 -0
- package/dist/src/cli/commands/connection.js +54 -0
- package/dist/src/cli/commands/continuous-activity.d.ts +2 -0
- package/dist/src/cli/commands/continuous-activity.js +38 -0
- package/dist/src/cli/commands/dashboard.d.ts +2 -0
- package/dist/src/cli/commands/dashboard.js +99 -0
- package/dist/src/cli/commands/data-quality.d.ts +2 -0
- package/dist/src/cli/commands/data-quality.js +235 -0
- package/dist/src/cli/commands/dataset.d.ts +2 -0
- package/dist/src/cli/commands/dataset.js +288 -0
- package/dist/src/cli/commands/discussion.d.ts +2 -0
- package/dist/src/cli/commands/discussion.js +47 -0
- package/dist/src/cli/commands/doctor.d.ts +2 -0
- package/dist/src/cli/commands/doctor.js +9 -0
- package/dist/src/cli/commands/flow-zone.d.ts +2 -0
- package/dist/src/cli/commands/flow-zone.js +282 -0
- package/dist/src/cli/commands/folder.d.ts +2 -0
- package/dist/src/cli/commands/folder.js +202 -0
- package/dist/src/cli/commands/future.d.ts +2 -0
- package/dist/src/cli/commands/future.js +57 -0
- package/dist/src/cli/commands/index.d.ts +2 -0
- package/dist/src/cli/commands/index.js +70 -0
- package/dist/src/cli/commands/insight.d.ts +2 -0
- package/dist/src/cli/commands/insight.js +156 -0
- package/dist/src/cli/commands/job.d.ts +2 -0
- package/dist/src/cli/commands/job.js +406 -0
- package/dist/src/cli/commands/meaning.d.ts +2 -0
- package/dist/src/cli/commands/meaning.js +115 -0
- package/dist/src/cli/commands/metrics.d.ts +2 -0
- package/dist/src/cli/commands/metrics.js +39 -0
- package/dist/src/cli/commands/notebook.d.ts +2 -0
- package/dist/src/cli/commands/notebook.js +242 -0
- package/dist/src/cli/commands/project-deployer.d.ts +2 -0
- package/dist/src/cli/commands/project-deployer.js +118 -0
- package/dist/src/cli/commands/project-library.d.ts +2 -0
- package/dist/src/cli/commands/project-library.js +197 -0
- package/dist/src/cli/commands/project.d.ts +2 -0
- package/dist/src/cli/commands/project.js +132 -0
- package/dist/src/cli/commands/recipe.d.ts +2 -0
- package/dist/src/cli/commands/recipe.js +632 -0
- package/dist/src/cli/commands/scenario.d.ts +2 -0
- package/dist/src/cli/commands/scenario.js +190 -0
- package/dist/src/cli/commands/sql.d.ts +2 -0
- package/dist/src/cli/commands/sql.js +109 -0
- package/dist/src/cli/commands/statistics.d.ts +2 -0
- package/dist/src/cli/commands/statistics.js +165 -0
- package/dist/src/cli/commands/streaming-endpoint.d.ts +2 -0
- package/dist/src/cli/commands/streaming-endpoint.js +50 -0
- package/dist/src/cli/commands/variable.d.ts +2 -0
- package/dist/src/cli/commands/variable.js +49 -0
- package/dist/src/cli/commands/webapp.d.ts +2 -0
- package/dist/src/cli/commands/webapp.js +67 -0
- package/dist/src/cli/commands/wiki.d.ts +2 -0
- package/dist/src/cli/commands/wiki.js +123 -0
- package/dist/src/cli/commands/workspace.d.ts +2 -0
- package/dist/src/cli/commands/workspace.js +68 -0
- package/dist/src/cli/contract.d.ts +104 -0
- package/dist/src/cli/contract.js +2031 -0
- package/dist/src/cli/doctor.d.ts +104 -0
- package/dist/src/cli/doctor.js +356 -0
- package/dist/src/cli/env.d.ts +2 -0
- package/dist/src/cli/env.js +37 -0
- package/dist/src/cli/flags.d.ts +16 -0
- package/dist/src/cli/flags.js +255 -0
- package/dist/src/cli/helpers/cleanup.d.ts +3 -0
- package/dist/src/cli/helpers/cleanup.js +158 -0
- package/dist/src/cli/helpers/dataset.d.ts +2 -0
- package/dist/src/cli/helpers/dataset.js +17 -0
- package/dist/src/cli/helpers/flow-zone.d.ts +69 -0
- package/dist/src/cli/helpers/flow-zone.js +420 -0
- package/dist/src/cli/helpers/recipe.d.ts +11 -0
- package/dist/src/cli/helpers/recipe.js +83 -0
- package/dist/src/cli/output.d.ts +38 -0
- package/dist/src/cli/output.js +159 -0
- package/dist/src/cli/runtime.d.ts +15 -0
- package/dist/src/cli/runtime.js +59 -0
- package/dist/src/cli/types.d.ts +25 -0
- package/dist/src/cli/types.js +1 -0
- package/dist/src/cli/usage.d.ts +16 -0
- package/dist/src/cli/usage.js +80 -0
- package/dist/src/cli/version.d.ts +14 -0
- package/dist/src/cli/version.js +63 -0
- package/dist/src/cli.js +671 -8254
- package/dist/src/client.d.ts +1 -1
- package/dist/src/client.js +14 -13
- package/dist/src/errors.d.ts +6 -0
- package/dist/src/errors.js +102 -4
- package/dist/src/index.d.ts +3 -3
- package/dist/src/index.js +2 -2
- package/dist/src/resources/applications.d.ts +1 -1
- package/dist/src/resources/applications.js +27 -1
- package/dist/src/resources/continuous-activities.js +1 -0
- package/dist/src/resources/data-quality.js +5 -3
- package/dist/src/resources/datasets.d.ts +3 -0
- package/dist/src/resources/datasets.js +3 -0
- package/dist/src/resources/flow-zones.d.ts +2 -2
- package/dist/src/resources/flow-zones.js +4 -1
- package/dist/src/resources/meanings.d.ts +2 -0
- package/dist/src/resources/meanings.js +4 -0
- package/dist/src/resources/notebooks.d.ts +5 -7
- package/dist/src/resources/notebooks.js +10 -7
- package/dist/src/resources/projects.d.ts +1 -1
- package/dist/src/resources/projects.js +2 -2
- package/dist/src/resources/recipes.d.ts +3 -3
- package/dist/src/resources/recipes.js +50 -7
- package/dist/src/resources/scenarios.js +67 -26
- package/dist/src/resources/statistics.js +9 -0
- package/dist/src/schemas.d.ts +2 -2
- package/dist/src/schemas.js +1 -1
- package/dist/src/skill.js +2 -2
- package/dist/src/utils/sanitize.js +2 -1
- package/package.json +1 -1
- package/packages/types/dist/index.d.ts +15 -2
- package/packages/types/dist/index.js +9 -1
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import { jsonInput, num, } from "../coerce.js";
|
|
2
|
+
import { encodedProjectEndpoint, isNotFoundError, readIfExists, skipResult, } from "../output.js";
|
|
3
|
+
import { requireArgs, UsageError, } from "../usage.js";
|
|
4
|
+
export const notebookCommands = {
|
|
5
|
+
"list-jupyter": {
|
|
6
|
+
handler: (c, _a, f) => c.notebooks.listJupyter(f["project-key"]),
|
|
7
|
+
usage: "dss notebook list-jupyter [--project-key KEY]",
|
|
8
|
+
description: "List Jupyter notebooks.",
|
|
9
|
+
examples: ["dss notebook list-jupyter",],
|
|
10
|
+
},
|
|
11
|
+
"get-jupyter": {
|
|
12
|
+
handler: (c, a, f) => {
|
|
13
|
+
requireArgs(a, 1, "dss notebook get-jupyter <name>");
|
|
14
|
+
return c.notebooks.getJupyter(a[0], f["project-key"]);
|
|
15
|
+
},
|
|
16
|
+
usage: "dss notebook get-jupyter <name> [--project-key KEY]",
|
|
17
|
+
description: "Get a Jupyter notebook.",
|
|
18
|
+
examples: ["dss notebook get-jupyter my_notebook",],
|
|
19
|
+
},
|
|
20
|
+
"delete-jupyter": {
|
|
21
|
+
handler: async (c, a, f) => {
|
|
22
|
+
requireArgs(a, 1, "dss notebook delete-jupyter <name>");
|
|
23
|
+
const pk = f["project-key"];
|
|
24
|
+
if (f["dry-run"] === true || f["if-exists"] === true) {
|
|
25
|
+
const current = await readIfExists(() => c.notebooks.getJupyter(a[0], pk));
|
|
26
|
+
if (!current)
|
|
27
|
+
return skipResult("jupyter-notebook", a[0], "missing");
|
|
28
|
+
if (f["dry-run"] === true) {
|
|
29
|
+
return { dryRun: true, action: "delete", resource: "jupyter-notebook", name: a[0], current, };
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
await c.notebooks.deleteJupyter(a[0], pk);
|
|
33
|
+
return { deleted: a[0], resource: "jupyter-notebook", };
|
|
34
|
+
},
|
|
35
|
+
usage: "dss notebook delete-jupyter <name> [--if-exists] [--dry-run] [--project-key KEY]",
|
|
36
|
+
description: "Delete a Jupyter notebook.",
|
|
37
|
+
examples: ["dss notebook delete-jupyter my_notebook --dry-run",],
|
|
38
|
+
},
|
|
39
|
+
"clear-jupyter-outputs": {
|
|
40
|
+
handler: async (c, a, f) => {
|
|
41
|
+
requireArgs(a, 1, "dss notebook clear-jupyter-outputs <name>");
|
|
42
|
+
const pk = f["project-key"];
|
|
43
|
+
if (f["dry-run"] === true) {
|
|
44
|
+
const current = await c.notebooks.getJupyter(a[0], pk);
|
|
45
|
+
const next = {
|
|
46
|
+
...current,
|
|
47
|
+
cells: current.cells.map((cell) => ({ ...cell, outputs: [], execution_count: null, })),
|
|
48
|
+
};
|
|
49
|
+
return {
|
|
50
|
+
dryRun: true,
|
|
51
|
+
action: "clear-jupyter-outputs",
|
|
52
|
+
resource: "jupyter-notebook",
|
|
53
|
+
name: a[0],
|
|
54
|
+
current,
|
|
55
|
+
next,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
await c.notebooks.clearJupyterOutputs(a[0], pk);
|
|
59
|
+
return { cleared: a[0], resource: "jupyter-notebook", };
|
|
60
|
+
},
|
|
61
|
+
usage: "dss notebook clear-jupyter-outputs <name> [--dry-run] [--project-key KEY]",
|
|
62
|
+
description: "Clear all cell outputs from a Jupyter notebook.",
|
|
63
|
+
examples: ["dss notebook clear-jupyter-outputs my_notebook --dry-run",],
|
|
64
|
+
},
|
|
65
|
+
"sessions-jupyter": {
|
|
66
|
+
handler: (c, a, f) => {
|
|
67
|
+
requireArgs(a, 1, "dss notebook sessions-jupyter <name>");
|
|
68
|
+
return c.notebooks.listJupyterSessions(a[0], f["project-key"]);
|
|
69
|
+
},
|
|
70
|
+
usage: "dss notebook sessions-jupyter <name> [--project-key KEY]",
|
|
71
|
+
description: "List active kernel sessions for a Jupyter notebook.",
|
|
72
|
+
examples: ["dss notebook sessions-jupyter my_notebook",],
|
|
73
|
+
},
|
|
74
|
+
"unload-jupyter": {
|
|
75
|
+
handler: async (c, a, f) => {
|
|
76
|
+
requireArgs(a, 2, "dss notebook unload-jupyter <name> <sessionId>");
|
|
77
|
+
const pk = f["project-key"];
|
|
78
|
+
if (f["dry-run"] === true) {
|
|
79
|
+
const sessions = await c.notebooks.listJupyterSessions(a[0], pk);
|
|
80
|
+
const current = sessions.find((session) => session.sessionId === a[1]);
|
|
81
|
+
return {
|
|
82
|
+
dryRun: true,
|
|
83
|
+
action: "unload-jupyter",
|
|
84
|
+
resource: "jupyter-notebook",
|
|
85
|
+
name: a[0],
|
|
86
|
+
sessionId: a[1],
|
|
87
|
+
current,
|
|
88
|
+
endpoint: encodedProjectEndpoint(c, pk, `/jupyter-notebooks/${encodeURIComponent(a[0])}/sessions/${encodeURIComponent(a[1])}`),
|
|
89
|
+
method: "DELETE",
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
await c.notebooks.unloadJupyter(a[0], a[1], pk);
|
|
93
|
+
return { unloaded: a[0], sessionId: a[1], resource: "jupyter-notebook", };
|
|
94
|
+
},
|
|
95
|
+
usage: "dss notebook unload-jupyter <name> <sessionId> [--dry-run] [--project-key KEY]",
|
|
96
|
+
description: "Unload a Jupyter notebook kernel session.",
|
|
97
|
+
examples: ["dss notebook unload-jupyter my_notebook SESSION_ID --dry-run",],
|
|
98
|
+
},
|
|
99
|
+
"list-sql": {
|
|
100
|
+
handler: (c, _a, f) => c.notebooks.listSql(f["project-key"]),
|
|
101
|
+
usage: "dss notebook list-sql [--project-key KEY]",
|
|
102
|
+
description: "List SQL notebooks.",
|
|
103
|
+
examples: ["dss notebook list-sql",],
|
|
104
|
+
},
|
|
105
|
+
"get-sql": {
|
|
106
|
+
handler: (c, a, f) => {
|
|
107
|
+
requireArgs(a, 1, "dss notebook get-sql <id>");
|
|
108
|
+
return c.notebooks.getSql(a[0], f["project-key"]);
|
|
109
|
+
},
|
|
110
|
+
usage: "dss notebook get-sql <id> [--project-key KEY]",
|
|
111
|
+
description: "Get a SQL notebook.",
|
|
112
|
+
examples: ["dss notebook get-sql my_sql_notebook",],
|
|
113
|
+
},
|
|
114
|
+
"delete-sql": {
|
|
115
|
+
handler: async (c, a, f) => {
|
|
116
|
+
requireArgs(a, 1, "dss notebook delete-sql <id>");
|
|
117
|
+
const pk = f["project-key"];
|
|
118
|
+
if (f["dry-run"] === true || f["if-exists"] === true) {
|
|
119
|
+
const current = await readIfExists(() => c.notebooks.getSql(a[0], pk));
|
|
120
|
+
if (!current)
|
|
121
|
+
return skipResult("sql-notebook", a[0], "missing");
|
|
122
|
+
if (f["dry-run"] === true) {
|
|
123
|
+
return { dryRun: true, action: "delete", resource: "sql-notebook", id: a[0], current, };
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
await c.notebooks.deleteSql(a[0], pk);
|
|
127
|
+
return { deleted: a[0], resource: "sql-notebook", };
|
|
128
|
+
},
|
|
129
|
+
usage: "dss notebook delete-sql <id> [--if-exists] [--dry-run] [--project-key KEY]",
|
|
130
|
+
description: "Delete a SQL notebook.",
|
|
131
|
+
examples: ["dss notebook delete-sql my_sql_notebook --dry-run",],
|
|
132
|
+
},
|
|
133
|
+
"history-sql": {
|
|
134
|
+
handler: (c, a, f) => {
|
|
135
|
+
requireArgs(a, 1, "dss notebook history-sql <id>");
|
|
136
|
+
return c.notebooks.getSqlHistory(a[0], f["project-key"]);
|
|
137
|
+
},
|
|
138
|
+
usage: "dss notebook history-sql <id> [--project-key KEY]",
|
|
139
|
+
description: "Get query history for a SQL notebook.",
|
|
140
|
+
examples: ["dss notebook history-sql my_sql_notebook",],
|
|
141
|
+
},
|
|
142
|
+
"save-jupyter": {
|
|
143
|
+
handler: async (c, a, f) => {
|
|
144
|
+
requireArgs(a, 1, "dss notebook save-jupyter <name> [--data '{...}' | --data-file PATH | --stdin]");
|
|
145
|
+
const data = jsonInput(f);
|
|
146
|
+
if (!data) {
|
|
147
|
+
throw new UsageError("--data, --data-file, or --stdin is required (notebook JSON content).");
|
|
148
|
+
}
|
|
149
|
+
const pk = f["project-key"];
|
|
150
|
+
if (f["dry-run"] === true) {
|
|
151
|
+
const current = await readIfExists(() => c.notebooks.getJupyter(a[0], pk));
|
|
152
|
+
return {
|
|
153
|
+
dryRun: true,
|
|
154
|
+
action: "save-jupyter",
|
|
155
|
+
resource: "jupyter-notebook",
|
|
156
|
+
name: a[0],
|
|
157
|
+
current,
|
|
158
|
+
next: data,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
try {
|
|
162
|
+
await c.notebooks.saveJupyter(a[0], data, pk);
|
|
163
|
+
}
|
|
164
|
+
catch (error) {
|
|
165
|
+
if (!isNotFoundError(error))
|
|
166
|
+
throw error;
|
|
167
|
+
await c.notebooks.createJupyter(a[0], data, pk);
|
|
168
|
+
}
|
|
169
|
+
return { saved: a[0], resource: "jupyter-notebook", };
|
|
170
|
+
},
|
|
171
|
+
usage: "dss notebook save-jupyter <name> [--data '{...}' | --data-file PATH | --stdin] [--dry-run] [--project-key KEY]",
|
|
172
|
+
description: "Save content to a Jupyter notebook, creating it if missing.",
|
|
173
|
+
examples: [
|
|
174
|
+
"dss notebook save-jupyter my_notebook --data-file notebook.json --dry-run",
|
|
175
|
+
"cat notebook.json | dss notebook save-jupyter my_notebook --stdin",
|
|
176
|
+
],
|
|
177
|
+
},
|
|
178
|
+
"save-sql": {
|
|
179
|
+
handler: async (c, a, f) => {
|
|
180
|
+
requireArgs(a, 1, "dss notebook save-sql <id> [--data '{...}' | --data-file PATH | --stdin]");
|
|
181
|
+
const data = jsonInput(f);
|
|
182
|
+
if (!data) {
|
|
183
|
+
throw new UsageError("--data, --data-file, or --stdin is required (SQL notebook content JSON).");
|
|
184
|
+
}
|
|
185
|
+
const pk = f["project-key"];
|
|
186
|
+
if (f["dry-run"] === true) {
|
|
187
|
+
const current = await readIfExists(() => c.notebooks.getSql(a[0], pk));
|
|
188
|
+
return {
|
|
189
|
+
dryRun: true,
|
|
190
|
+
action: "save-sql",
|
|
191
|
+
resource: "sql-notebook",
|
|
192
|
+
id: a[0],
|
|
193
|
+
current,
|
|
194
|
+
next: data,
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
const current = await readIfExists(() => c.notebooks.getSql(a[0], pk));
|
|
198
|
+
if (current) {
|
|
199
|
+
await c.notebooks.saveSql(a[0], data, pk);
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
await c.notebooks.createSql(a[0], data, pk);
|
|
203
|
+
}
|
|
204
|
+
return { saved: a[0], resource: "sql-notebook", };
|
|
205
|
+
},
|
|
206
|
+
usage: "dss notebook save-sql <id> [--data '{...}' | --data-file PATH | --stdin] [--dry-run] [--project-key KEY]",
|
|
207
|
+
description: "Save content to a SQL notebook, creating it if missing.",
|
|
208
|
+
examples: ["dss notebook save-sql my_sql_notebook --data-file content.json --dry-run",],
|
|
209
|
+
},
|
|
210
|
+
"clear-sql-history": {
|
|
211
|
+
handler: async (c, a, f) => {
|
|
212
|
+
requireArgs(a, 1, "dss notebook clear-sql-history <id>");
|
|
213
|
+
const pk = f["project-key"];
|
|
214
|
+
const options = {
|
|
215
|
+
cellId: f["cell-id"],
|
|
216
|
+
numRunsToRetain: num(f["retain"]),
|
|
217
|
+
projectKey: pk,
|
|
218
|
+
};
|
|
219
|
+
if (f["dry-run"] === true) {
|
|
220
|
+
const current = await c.notebooks.getSqlHistory(a[0], pk);
|
|
221
|
+
return {
|
|
222
|
+
dryRun: true,
|
|
223
|
+
action: "clear-sql-history",
|
|
224
|
+
resource: "sql-notebook",
|
|
225
|
+
id: a[0],
|
|
226
|
+
current,
|
|
227
|
+
next: options,
|
|
228
|
+
endpoint: encodedProjectEndpoint(c, pk, `/sql-notebooks/${encodeURIComponent(a[0])}/history/clear`),
|
|
229
|
+
method: "POST",
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
await c.notebooks.clearSqlHistory(a[0], options);
|
|
233
|
+
return { cleared: a[0], resource: "sql-notebook", };
|
|
234
|
+
},
|
|
235
|
+
usage: "dss notebook clear-sql-history <id> [--cell-id CID] [--retain N] [--dry-run] [--project-key KEY]",
|
|
236
|
+
description: "Clear query history for a SQL notebook.",
|
|
237
|
+
examples: [
|
|
238
|
+
"dss notebook clear-sql-history my_sql_notebook --dry-run",
|
|
239
|
+
"dss notebook clear-sql-history my_sql_notebook --cell-id CELL1 --retain 5",
|
|
240
|
+
],
|
|
241
|
+
},
|
|
242
|
+
};
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { requiredJsonInput, } from "../coerce.js";
|
|
2
|
+
import { requireArgs, } from "../usage.js";
|
|
3
|
+
export const projectDeployerCommands = {
|
|
4
|
+
"list-projects": {
|
|
5
|
+
handler: (c) => c.projectDeployer.listProjects(),
|
|
6
|
+
usage: "dss project-deployer list-projects",
|
|
7
|
+
description: "List published projects on the Project Deployer.",
|
|
8
|
+
examples: ["dss project-deployer list-projects",],
|
|
9
|
+
},
|
|
10
|
+
"create-project": {
|
|
11
|
+
handler: (c, _a, f) => {
|
|
12
|
+
const body = requiredJsonInput(f, "--data, --data-file, or --stdin is required (published project settings).");
|
|
13
|
+
return c.projectDeployer.createProject(body);
|
|
14
|
+
},
|
|
15
|
+
usage: "dss project-deployer create-project (--data JSON|--data-file PATH|--stdin)",
|
|
16
|
+
description: "Create a published project on the Project Deployer.",
|
|
17
|
+
examples: ["dss project-deployer create-project --data-file project.json",],
|
|
18
|
+
},
|
|
19
|
+
"upload-bundle": {
|
|
20
|
+
handler: async (c, a) => {
|
|
21
|
+
requireArgs(a, 1, "dss project-deployer upload-bundle <filePath>");
|
|
22
|
+
await c.projectDeployer.uploadBundle(a[0]);
|
|
23
|
+
return { uploaded: true, };
|
|
24
|
+
},
|
|
25
|
+
usage: "dss project-deployer upload-bundle <filePath>",
|
|
26
|
+
description: "Upload a project bundle archive to the Project Deployer.",
|
|
27
|
+
examples: ["dss project-deployer upload-bundle ./v1.zip",],
|
|
28
|
+
},
|
|
29
|
+
"project-status": {
|
|
30
|
+
handler: (c, a) => {
|
|
31
|
+
requireArgs(a, 1, "dss project-deployer project-status <publishedProjectKey>");
|
|
32
|
+
return c.projectDeployer.getProjectStatus(a[0]);
|
|
33
|
+
},
|
|
34
|
+
usage: "dss project-deployer project-status <publishedProjectKey>",
|
|
35
|
+
description: "Get a published project's status and available bundles.",
|
|
36
|
+
examples: ["dss project-deployer project-status MYPROJ",],
|
|
37
|
+
},
|
|
38
|
+
"list-deployments": {
|
|
39
|
+
handler: (c) => c.projectDeployer.listDeployments(),
|
|
40
|
+
usage: "dss project-deployer list-deployments",
|
|
41
|
+
description: "List Project Deployer deployments.",
|
|
42
|
+
examples: ["dss project-deployer list-deployments",],
|
|
43
|
+
},
|
|
44
|
+
"create-deployment": {
|
|
45
|
+
handler: (c, _a, f) => {
|
|
46
|
+
const body = requiredJsonInput(f, "--data, --data-file, or --stdin is required (deployment settings).");
|
|
47
|
+
return c.projectDeployer.createDeployment(body);
|
|
48
|
+
},
|
|
49
|
+
usage: "dss project-deployer create-deployment (--data JSON|--data-file PATH|--stdin)",
|
|
50
|
+
description: "Create a Project Deployer deployment (bundle to infra mapping).",
|
|
51
|
+
examples: ["dss project-deployer create-deployment --data-file deployment.json",],
|
|
52
|
+
},
|
|
53
|
+
"get-deployment": {
|
|
54
|
+
handler: (c, a) => {
|
|
55
|
+
requireArgs(a, 1, "dss project-deployer get-deployment <deploymentId>");
|
|
56
|
+
return c.projectDeployer.getDeployment(a[0]);
|
|
57
|
+
},
|
|
58
|
+
usage: "dss project-deployer get-deployment <deploymentId>",
|
|
59
|
+
description: "Get a Project Deployer deployment.",
|
|
60
|
+
examples: ["dss project-deployer get-deployment my-deployment",],
|
|
61
|
+
},
|
|
62
|
+
"deployment-status": {
|
|
63
|
+
handler: (c, a) => {
|
|
64
|
+
requireArgs(a, 1, "dss project-deployer deployment-status <deploymentId>");
|
|
65
|
+
return c.projectDeployer.getDeploymentStatus(a[0]);
|
|
66
|
+
},
|
|
67
|
+
usage: "dss project-deployer deployment-status <deploymentId>",
|
|
68
|
+
description: "Get a Project Deployer deployment's full health/status.",
|
|
69
|
+
examples: ["dss project-deployer deployment-status my-deployment",],
|
|
70
|
+
},
|
|
71
|
+
"save-deployment-settings": {
|
|
72
|
+
handler: async (c, a, f) => {
|
|
73
|
+
requireArgs(a, 1, "dss project-deployer save-deployment-settings <deploymentId> (--data JSON|--data-file PATH|--stdin)");
|
|
74
|
+
const body = requiredJsonInput(f, "--data, --data-file, or --stdin is required (deployment settings).");
|
|
75
|
+
await c.projectDeployer.saveDeploymentSettings(a[0], body);
|
|
76
|
+
return { saved: true, };
|
|
77
|
+
},
|
|
78
|
+
usage: "dss project-deployer save-deployment-settings <deploymentId> (--data JSON|--data-file PATH|--stdin)",
|
|
79
|
+
description: "Save a Project Deployer deployment's settings (e.g. bundleId).",
|
|
80
|
+
examples: [
|
|
81
|
+
"dss project-deployer save-deployment-settings my-deployment --data-file settings.json",
|
|
82
|
+
],
|
|
83
|
+
},
|
|
84
|
+
deploy: {
|
|
85
|
+
handler: (c, a) => {
|
|
86
|
+
requireArgs(a, 1, "dss project-deployer deploy <deploymentId>");
|
|
87
|
+
return c.projectDeployer.startUpdate(a[0]);
|
|
88
|
+
},
|
|
89
|
+
usage: "dss project-deployer deploy <deploymentId>",
|
|
90
|
+
description: "Apply a deployment to the Automation node (start update).",
|
|
91
|
+
examples: ["dss project-deployer deploy my-deployment",],
|
|
92
|
+
},
|
|
93
|
+
"delete-deployment": {
|
|
94
|
+
handler: async (c, a) => {
|
|
95
|
+
requireArgs(a, 1, "dss project-deployer delete-deployment <deploymentId>");
|
|
96
|
+
await c.projectDeployer.deleteDeployment(a[0]);
|
|
97
|
+
return { deleted: true, };
|
|
98
|
+
},
|
|
99
|
+
usage: "dss project-deployer delete-deployment <deploymentId>",
|
|
100
|
+
description: "Delete a Project Deployer deployment.",
|
|
101
|
+
examples: ["dss project-deployer delete-deployment my-deployment",],
|
|
102
|
+
},
|
|
103
|
+
"list-infras": {
|
|
104
|
+
handler: (c) => c.projectDeployer.listInfras(),
|
|
105
|
+
usage: "dss project-deployer list-infras",
|
|
106
|
+
description: "List Project Deployer infrastructures.",
|
|
107
|
+
examples: ["dss project-deployer list-infras",],
|
|
108
|
+
},
|
|
109
|
+
"create-infra": {
|
|
110
|
+
handler: (c, _a, f) => {
|
|
111
|
+
const body = requiredJsonInput(f, "--data, --data-file, or --stdin is required (infra settings).");
|
|
112
|
+
return c.projectDeployer.createInfra(body);
|
|
113
|
+
},
|
|
114
|
+
usage: "dss project-deployer create-infra (--data JSON|--data-file PATH|--stdin)",
|
|
115
|
+
description: "Create a Project Deployer infrastructure.",
|
|
116
|
+
examples: ["dss project-deployer create-infra --data-file infra.json",],
|
|
117
|
+
},
|
|
118
|
+
};
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { readFileSync, writeFileSync, } from "node:fs";
|
|
2
|
+
import { readStdinText, } from "../coerce.js";
|
|
3
|
+
import { encodedProjectEndpoint, planResult, } from "../output.js";
|
|
4
|
+
import { requireArgs, UsageError, } from "../usage.js";
|
|
5
|
+
const PROJECT_LIBRARY_EXIT_CODES = { usage: 1, error: 2, transient: 3, };
|
|
6
|
+
function normalizeLibraryPath(path) {
|
|
7
|
+
const normalized = path.replace(/^\/+/, "");
|
|
8
|
+
if (!normalized)
|
|
9
|
+
throw new Error("Project library path is required");
|
|
10
|
+
return normalized;
|
|
11
|
+
}
|
|
12
|
+
function normalizeLibraryDestinationPath(path) {
|
|
13
|
+
if (path === "/")
|
|
14
|
+
return "/";
|
|
15
|
+
return `/${normalizeLibraryPath(path)}`;
|
|
16
|
+
}
|
|
17
|
+
function encodeLibraryPath(path) {
|
|
18
|
+
return normalizeLibraryPath(path)
|
|
19
|
+
.split("/")
|
|
20
|
+
.map((segment) => encodeURIComponent(segment))
|
|
21
|
+
.join("/");
|
|
22
|
+
}
|
|
23
|
+
function projectLibraryContentsEndpoint(client, projectKey, path) {
|
|
24
|
+
return encodedProjectEndpoint(client, projectKey, `/libraries/contents/${encodeLibraryPath(path)}`);
|
|
25
|
+
}
|
|
26
|
+
function projectLibraryFolderEndpoint(client, projectKey, path) {
|
|
27
|
+
return encodedProjectEndpoint(client, projectKey, `/libraries/folders/${encodeLibraryPath(path)}`);
|
|
28
|
+
}
|
|
29
|
+
function projectLibraryActionEndpoint(client, projectKey, action) {
|
|
30
|
+
return encodedProjectEndpoint(client, projectKey, `/libraries/contents-actions/${action}`);
|
|
31
|
+
}
|
|
32
|
+
function projectLibraryPutPayload(flags) {
|
|
33
|
+
if (typeof flags["content"] === "string")
|
|
34
|
+
return { contentSource: "flag", };
|
|
35
|
+
if (typeof flags["file"] === "string")
|
|
36
|
+
return { contentSource: "file", file: flags["file"], };
|
|
37
|
+
return { contentSource: "stdin", };
|
|
38
|
+
}
|
|
39
|
+
function projectLibraryPlan(action, options) {
|
|
40
|
+
return planResult("project-library", action, {
|
|
41
|
+
...options,
|
|
42
|
+
asyncKind: "none",
|
|
43
|
+
exitCodesOnFailure: PROJECT_LIBRARY_EXIT_CODES,
|
|
44
|
+
idempotency: "none",
|
|
45
|
+
plannedAndDryRun: true,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
export const projectLibraryCommands = {
|
|
49
|
+
list: {
|
|
50
|
+
handler: (c, _a, f) => c.projectLibrary.listContents(f["project-key"]),
|
|
51
|
+
usage: "dss project-library list [--project-key KEY]",
|
|
52
|
+
description: "List the project code library (lib/) contents.",
|
|
53
|
+
examples: ["dss project-library list",],
|
|
54
|
+
},
|
|
55
|
+
get: {
|
|
56
|
+
handler: (c, a, f) => {
|
|
57
|
+
requireArgs(a, 1, "dss project-library get <path> [--project-key KEY]");
|
|
58
|
+
return c.projectLibrary.getFile(a[0], f["project-key"]);
|
|
59
|
+
},
|
|
60
|
+
usage: "dss project-library get <path> [--project-key KEY]",
|
|
61
|
+
description: "Print the text content of a project library file.",
|
|
62
|
+
examples: ["dss project-library get python/mylib/utils.py",],
|
|
63
|
+
},
|
|
64
|
+
"get-bytes": {
|
|
65
|
+
handler: async (c, a, f) => {
|
|
66
|
+
requireArgs(a, 1, "dss project-library get-bytes <path> --output PATH [--project-key KEY]");
|
|
67
|
+
const out = f["output"];
|
|
68
|
+
if (!out)
|
|
69
|
+
throw new UsageError("--output PATH is required.", "missing_required_flag");
|
|
70
|
+
const bytes = await c.projectLibrary.getFileBytes(a[0], f["project-key"]);
|
|
71
|
+
writeFileSync(out, bytes);
|
|
72
|
+
return { path: out, bytes: bytes.length, };
|
|
73
|
+
},
|
|
74
|
+
usage: "dss project-library get-bytes <path> --output PATH [--project-key KEY]",
|
|
75
|
+
description: "Download a project library file's raw bytes to a local file.",
|
|
76
|
+
examples: ["dss project-library get-bytes static/logo.png --output ./logo.png",],
|
|
77
|
+
},
|
|
78
|
+
"create-file": {
|
|
79
|
+
handler: async (c, a, f) => {
|
|
80
|
+
requireArgs(a, 1, "dss project-library create-file <path> [--dry-run] [--project-key KEY]");
|
|
81
|
+
const pk = f["project-key"];
|
|
82
|
+
if (f["dry-run"] === true) {
|
|
83
|
+
return projectLibraryPlan("create-file", {
|
|
84
|
+
method: "POST",
|
|
85
|
+
endpoint: projectLibraryContentsEndpoint(c, pk, a[0]),
|
|
86
|
+
identifiers: { path: a[0], },
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
await c.projectLibrary.addFile(a[0], pk);
|
|
90
|
+
return { created: a[0], };
|
|
91
|
+
},
|
|
92
|
+
usage: "dss project-library create-file <path> [--dry-run] [--project-key KEY]",
|
|
93
|
+
description: "Create an empty file in the project library.",
|
|
94
|
+
examples: ["dss project-library create-file python/mylib/new.py",],
|
|
95
|
+
},
|
|
96
|
+
"create-folder": {
|
|
97
|
+
handler: async (c, a, f) => {
|
|
98
|
+
requireArgs(a, 1, "dss project-library create-folder <path> [--dry-run] [--project-key KEY]");
|
|
99
|
+
const pk = f["project-key"];
|
|
100
|
+
if (f["dry-run"] === true) {
|
|
101
|
+
return projectLibraryPlan("create-folder", {
|
|
102
|
+
method: "POST",
|
|
103
|
+
endpoint: projectLibraryFolderEndpoint(c, pk, a[0]),
|
|
104
|
+
identifiers: { path: a[0], },
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
await c.projectLibrary.addFolder(a[0], pk);
|
|
108
|
+
return { created: a[0], };
|
|
109
|
+
},
|
|
110
|
+
usage: "dss project-library create-folder <path> [--dry-run] [--project-key KEY]",
|
|
111
|
+
description: "Create a folder in the project library.",
|
|
112
|
+
examples: ["dss project-library create-folder python/mylib",],
|
|
113
|
+
},
|
|
114
|
+
put: {
|
|
115
|
+
handler: async (c, a, f) => {
|
|
116
|
+
requireArgs(a, 1, "dss project-library put <path> (--content TEXT|--file PATH|--stdin) [--dry-run] [--project-key KEY]");
|
|
117
|
+
const pk = f["project-key"];
|
|
118
|
+
if (f["dry-run"] === true) {
|
|
119
|
+
return projectLibraryPlan("put", {
|
|
120
|
+
method: "POST",
|
|
121
|
+
endpoint: projectLibraryContentsEndpoint(c, pk, a[0]),
|
|
122
|
+
identifiers: { path: a[0], },
|
|
123
|
+
payload: projectLibraryPutPayload(f),
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
const content = typeof f["content"] === "string"
|
|
127
|
+
? f["content"]
|
|
128
|
+
: typeof f["file"] === "string"
|
|
129
|
+
? readFileSync(f["file"], "utf-8")
|
|
130
|
+
: await readStdinText();
|
|
131
|
+
await c.projectLibrary.addOrUpdateFile(a[0], content, pk);
|
|
132
|
+
return { updated: a[0], };
|
|
133
|
+
},
|
|
134
|
+
usage: "dss project-library put <path> (--content TEXT|--file PATH|--stdin) [--dry-run] [--project-key KEY]",
|
|
135
|
+
description: "Create or overwrite a project library file with raw text content.",
|
|
136
|
+
examples: ["dss project-library put python/mylib/utils.py --file ./utils.py",],
|
|
137
|
+
},
|
|
138
|
+
delete: {
|
|
139
|
+
handler: async (c, a, f) => {
|
|
140
|
+
requireArgs(a, 1, "dss project-library delete <path> [--dry-run] [--project-key KEY]");
|
|
141
|
+
const pk = f["project-key"];
|
|
142
|
+
if (f["dry-run"] === true) {
|
|
143
|
+
return projectLibraryPlan("delete", {
|
|
144
|
+
method: "DELETE",
|
|
145
|
+
endpoint: projectLibraryContentsEndpoint(c, pk, a[0]),
|
|
146
|
+
identifiers: { path: a[0], },
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
await c.projectLibrary.deleteFile(a[0], pk);
|
|
150
|
+
return { deleted: a[0], };
|
|
151
|
+
},
|
|
152
|
+
usage: "dss project-library delete <path> [--dry-run] [--project-key KEY]",
|
|
153
|
+
description: "Delete a project library file or folder.",
|
|
154
|
+
examples: ["dss project-library delete python/mylib/old.py",],
|
|
155
|
+
},
|
|
156
|
+
rename: {
|
|
157
|
+
handler: async (c, a, f) => {
|
|
158
|
+
requireArgs(a, 2, "dss project-library rename <path> <new-name> [--dry-run] [--project-key KEY]");
|
|
159
|
+
const pk = f["project-key"];
|
|
160
|
+
if (f["dry-run"] === true) {
|
|
161
|
+
return projectLibraryPlan("rename", {
|
|
162
|
+
method: "POST",
|
|
163
|
+
endpoint: projectLibraryActionEndpoint(c, pk, "rename/"),
|
|
164
|
+
identifiers: { path: a[0], newName: a[1], },
|
|
165
|
+
payload: { oldPath: `/${normalizeLibraryPath(a[0])}`, newName: a[1], },
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
await c.projectLibrary.rename(a[0], a[1], pk);
|
|
169
|
+
return { renamed: a[0], to: a[1], };
|
|
170
|
+
},
|
|
171
|
+
usage: "dss project-library rename <path> <new-name> [--dry-run] [--project-key KEY]",
|
|
172
|
+
description: "Rename a project library file or folder within its parent.",
|
|
173
|
+
examples: ["dss project-library rename python/mylib/old.py new.py",],
|
|
174
|
+
},
|
|
175
|
+
move: {
|
|
176
|
+
handler: async (c, a, f) => {
|
|
177
|
+
requireArgs(a, 2, "dss project-library move <path> <destination-folder> [--dry-run] [--project-key KEY]");
|
|
178
|
+
const pk = f["project-key"];
|
|
179
|
+
if (f["dry-run"] === true) {
|
|
180
|
+
return projectLibraryPlan("move", {
|
|
181
|
+
method: "POST",
|
|
182
|
+
endpoint: projectLibraryActionEndpoint(c, pk, "move"),
|
|
183
|
+
identifiers: { path: a[0], destinationFolder: a[1], },
|
|
184
|
+
payload: {
|
|
185
|
+
oldPath: `/${normalizeLibraryPath(a[0])}`,
|
|
186
|
+
newPath: normalizeLibraryDestinationPath(a[1]),
|
|
187
|
+
},
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
await c.projectLibrary.move(a[0], a[1], pk);
|
|
191
|
+
return { moved: a[0], to: a[1], };
|
|
192
|
+
},
|
|
193
|
+
usage: "dss project-library move <path> <destination-folder> [--dry-run] [--project-key KEY]",
|
|
194
|
+
description: "Move a project library file or folder into another folder.",
|
|
195
|
+
examples: ["dss project-library move python/old.py python/mylib",],
|
|
196
|
+
},
|
|
197
|
+
};
|