dataiku-sdk 0.10.0 → 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.
Files changed (133) hide show
  1. package/dist/packages/types/src/index.d.ts +15 -2
  2. package/dist/packages/types/src/index.js +9 -1
  3. package/dist/src/cli/coerce.d.ts +36 -0
  4. package/dist/src/cli/coerce.js +239 -0
  5. package/dist/src/cli/commands/api-deployer.d.ts +2 -0
  6. package/dist/src/cli/commands/api-deployer.js +170 -0
  7. package/dist/src/cli/commands/api-service.d.ts +2 -0
  8. package/dist/src/cli/commands/api-service.js +102 -0
  9. package/dist/src/cli/commands/app.d.ts +2 -0
  10. package/dist/src/cli/commands/app.js +78 -0
  11. package/dist/src/cli/commands/bundle.d.ts +2 -0
  12. package/dist/src/cli/commands/bundle.js +107 -0
  13. package/dist/src/cli/commands/business-app.d.ts +2 -0
  14. package/dist/src/cli/commands/business-app.js +76 -0
  15. package/dist/src/cli/commands/code-env.d.ts +2 -0
  16. package/dist/src/cli/commands/code-env.js +255 -0
  17. package/dist/src/cli/commands/code.d.ts +2 -0
  18. package/dist/src/cli/commands/code.js +63 -0
  19. package/dist/src/cli/commands/connection.d.ts +2 -0
  20. package/dist/src/cli/commands/connection.js +54 -0
  21. package/dist/src/cli/commands/continuous-activity.d.ts +2 -0
  22. package/dist/src/cli/commands/continuous-activity.js +38 -0
  23. package/dist/src/cli/commands/dashboard.d.ts +2 -0
  24. package/dist/src/cli/commands/dashboard.js +99 -0
  25. package/dist/src/cli/commands/data-quality.d.ts +2 -0
  26. package/dist/src/cli/commands/data-quality.js +235 -0
  27. package/dist/src/cli/commands/dataset.d.ts +2 -0
  28. package/dist/src/cli/commands/dataset.js +288 -0
  29. package/dist/src/cli/commands/discussion.d.ts +2 -0
  30. package/dist/src/cli/commands/discussion.js +47 -0
  31. package/dist/src/cli/commands/doctor.d.ts +2 -0
  32. package/dist/src/cli/commands/doctor.js +9 -0
  33. package/dist/src/cli/commands/flow-zone.d.ts +2 -0
  34. package/dist/src/cli/commands/flow-zone.js +282 -0
  35. package/dist/src/cli/commands/folder.d.ts +2 -0
  36. package/dist/src/cli/commands/folder.js +202 -0
  37. package/dist/src/cli/commands/future.d.ts +2 -0
  38. package/dist/src/cli/commands/future.js +57 -0
  39. package/dist/src/cli/commands/index.d.ts +2 -0
  40. package/dist/src/cli/commands/index.js +70 -0
  41. package/dist/src/cli/commands/insight.d.ts +2 -0
  42. package/dist/src/cli/commands/insight.js +156 -0
  43. package/dist/src/cli/commands/job.d.ts +2 -0
  44. package/dist/src/cli/commands/job.js +406 -0
  45. package/dist/src/cli/commands/meaning.d.ts +2 -0
  46. package/dist/src/cli/commands/meaning.js +115 -0
  47. package/dist/src/cli/commands/metrics.d.ts +2 -0
  48. package/dist/src/cli/commands/metrics.js +39 -0
  49. package/dist/src/cli/commands/notebook.d.ts +2 -0
  50. package/dist/src/cli/commands/notebook.js +242 -0
  51. package/dist/src/cli/commands/project-deployer.d.ts +2 -0
  52. package/dist/src/cli/commands/project-deployer.js +118 -0
  53. package/dist/src/cli/commands/project-library.d.ts +2 -0
  54. package/dist/src/cli/commands/project-library.js +197 -0
  55. package/dist/src/cli/commands/project.d.ts +2 -0
  56. package/dist/src/cli/commands/project.js +132 -0
  57. package/dist/src/cli/commands/recipe.d.ts +2 -0
  58. package/dist/src/cli/commands/recipe.js +632 -0
  59. package/dist/src/cli/commands/scenario.d.ts +2 -0
  60. package/dist/src/cli/commands/scenario.js +190 -0
  61. package/dist/src/cli/commands/sql.d.ts +2 -0
  62. package/dist/src/cli/commands/sql.js +109 -0
  63. package/dist/src/cli/commands/statistics.d.ts +2 -0
  64. package/dist/src/cli/commands/statistics.js +165 -0
  65. package/dist/src/cli/commands/streaming-endpoint.d.ts +2 -0
  66. package/dist/src/cli/commands/streaming-endpoint.js +50 -0
  67. package/dist/src/cli/commands/variable.d.ts +2 -0
  68. package/dist/src/cli/commands/variable.js +49 -0
  69. package/dist/src/cli/commands/webapp.d.ts +2 -0
  70. package/dist/src/cli/commands/webapp.js +67 -0
  71. package/dist/src/cli/commands/wiki.d.ts +2 -0
  72. package/dist/src/cli/commands/wiki.js +123 -0
  73. package/dist/src/cli/commands/workspace.d.ts +2 -0
  74. package/dist/src/cli/commands/workspace.js +68 -0
  75. package/dist/src/cli/contract.d.ts +104 -0
  76. package/dist/src/cli/contract.js +2031 -0
  77. package/dist/src/cli/doctor.d.ts +104 -0
  78. package/dist/src/cli/doctor.js +356 -0
  79. package/dist/src/cli/env.d.ts +2 -0
  80. package/dist/src/cli/env.js +37 -0
  81. package/dist/src/cli/flags.d.ts +16 -0
  82. package/dist/src/cli/flags.js +255 -0
  83. package/dist/src/cli/helpers/cleanup.d.ts +3 -0
  84. package/dist/src/cli/helpers/cleanup.js +158 -0
  85. package/dist/src/cli/helpers/dataset.d.ts +2 -0
  86. package/dist/src/cli/helpers/dataset.js +17 -0
  87. package/dist/src/cli/helpers/flow-zone.d.ts +69 -0
  88. package/dist/src/cli/helpers/flow-zone.js +420 -0
  89. package/dist/src/cli/helpers/recipe.d.ts +11 -0
  90. package/dist/src/cli/helpers/recipe.js +83 -0
  91. package/dist/src/cli/output.d.ts +38 -0
  92. package/dist/src/cli/output.js +159 -0
  93. package/dist/src/cli/runtime.d.ts +15 -0
  94. package/dist/src/cli/runtime.js +59 -0
  95. package/dist/src/cli/types.d.ts +25 -0
  96. package/dist/src/cli/types.js +1 -0
  97. package/dist/src/cli/usage.d.ts +16 -0
  98. package/dist/src/cli/usage.js +80 -0
  99. package/dist/src/cli/version.d.ts +14 -0
  100. package/dist/src/cli/version.js +63 -0
  101. package/dist/src/cli.js +671 -8254
  102. package/dist/src/client.d.ts +1 -1
  103. package/dist/src/client.js +14 -13
  104. package/dist/src/errors.d.ts +6 -0
  105. package/dist/src/errors.js +127 -4
  106. package/dist/src/index.d.ts +3 -3
  107. package/dist/src/index.js +2 -2
  108. package/dist/src/resources/applications.d.ts +1 -1
  109. package/dist/src/resources/applications.js +27 -1
  110. package/dist/src/resources/bundles.js +2 -2
  111. package/dist/src/resources/continuous-activities.js +1 -0
  112. package/dist/src/resources/data-quality.js +5 -3
  113. package/dist/src/resources/datasets.d.ts +3 -0
  114. package/dist/src/resources/datasets.js +3 -0
  115. package/dist/src/resources/flow-zones.d.ts +2 -2
  116. package/dist/src/resources/flow-zones.js +4 -1
  117. package/dist/src/resources/meanings.d.ts +2 -0
  118. package/dist/src/resources/meanings.js +4 -0
  119. package/dist/src/resources/notebooks.d.ts +5 -7
  120. package/dist/src/resources/notebooks.js +10 -7
  121. package/dist/src/resources/projects.d.ts +1 -1
  122. package/dist/src/resources/projects.js +2 -2
  123. package/dist/src/resources/recipes.d.ts +3 -3
  124. package/dist/src/resources/recipes.js +50 -7
  125. package/dist/src/resources/scenarios.js +67 -26
  126. package/dist/src/resources/statistics.js +9 -0
  127. package/dist/src/schemas.d.ts +2 -2
  128. package/dist/src/schemas.js +1 -1
  129. package/dist/src/skill.js +2 -2
  130. package/dist/src/utils/sanitize.js +2 -1
  131. package/package.json +1 -1
  132. package/packages/types/dist/index.d.ts +15 -2
  133. package/packages/types/dist/index.js +9 -1
@@ -0,0 +1,78 @@
1
+ import { requiredJsonInput, } from "../coerce.js";
2
+ import { requireArgs, requireNoArgs, } from "../usage.js";
3
+ export const appCommands = {
4
+ list: {
5
+ handler: (c) => c.applications.listApps(),
6
+ usage: "dss app list",
7
+ description: "List all Dataiku App templates.",
8
+ examples: ["dss app list",],
9
+ },
10
+ manifest: {
11
+ handler: (c, a) => {
12
+ requireArgs(a, 1, "dss app manifest <appId>");
13
+ return c.applications.getAppManifest(a[0]);
14
+ },
15
+ usage: "dss app manifest <appId>",
16
+ description: "Get the manifest of a Dataiku App template.",
17
+ examples: ["dss app manifest my-app",],
18
+ },
19
+ instances: {
20
+ handler: (c, a) => {
21
+ requireArgs(a, 1, "dss app instances <appId>");
22
+ return c.applications.listInstances(a[0]);
23
+ },
24
+ usage: "dss app instances <appId>",
25
+ description: "List instances created from a Dataiku App template.",
26
+ examples: ["dss app instances my-app",],
27
+ },
28
+ "create-instance": {
29
+ handler: (c, a, f) => {
30
+ requireArgs(a, 1, "dss app create-instance <appId> (--data JSON|--data-file PATH|--stdin)");
31
+ const body = requiredJsonInput(f, "--data, --data-file, or --stdin is required (instance creation payload).");
32
+ return c.applications.createInstance(a[0], body);
33
+ },
34
+ usage: "dss app create-instance <appId> (--data JSON|--data-file PATH|--stdin)",
35
+ description: "Create an app instance from a Dataiku App template.",
36
+ examples: ['dss app create-instance my-app --data \'{"targetProjectKey":"NEWPROJ"}\'',],
37
+ },
38
+ "instance-manifest": {
39
+ handler: (c, a, f) => {
40
+ requireNoArgs(a, "dss app instance-manifest [--project-key KEY]");
41
+ return c.applications.getInstanceManifest(f["project-key"]);
42
+ },
43
+ usage: "dss app instance-manifest [--project-key KEY]",
44
+ description: "Get the app manifest of a Dataiku App template or app-instance project.",
45
+ examples: ["dss app instance-manifest --project-key MYINSTANCE",],
46
+ },
47
+ "save-instance-manifest": {
48
+ handler: (c, a, f) => {
49
+ requireNoArgs(a, "dss app save-instance-manifest (--data JSON|--data-file PATH|--stdin) [--project-key KEY]");
50
+ const manifest = requiredJsonInput(f, "--data, --data-file, or --stdin is required (manifest JSON).");
51
+ return c.applications.saveInstanceManifest(manifest, f["project-key"]);
52
+ },
53
+ usage: "dss app save-instance-manifest (--data JSON|--data-file PATH|--stdin) [--project-key KEY]",
54
+ description: "Save the app manifest of a Dataiku App template project (homepage sections, use-as-recipe settings). Classic app-instance project manifests are read-only through this endpoint.",
55
+ examples: [
56
+ "dss app save-instance-manifest --data-file manifest.json --project-key MYAPP_TEMPLATE",
57
+ ],
58
+ },
59
+ "delete-instance": {
60
+ handler: async (c, a, f) => {
61
+ requireNoArgs(a, "dss app delete-instance [--project-key KEY]");
62
+ await c.applications.deleteInstance(f["project-key"]);
63
+ return { deleted: true, };
64
+ },
65
+ usage: "dss app delete-instance [--project-key KEY]",
66
+ description: "Delete an app-instance project (destructive: removes the instance project).",
67
+ examples: ["dss app delete-instance --project-key MYINSTANCE",],
68
+ },
69
+ "business-app-instance-permissions": {
70
+ handler: (c, a) => {
71
+ requireArgs(a, 3, "dss app business-app-instance-permissions <businessAppId> <instanceProjectKey> <userLogin>");
72
+ return c.applications.getBusinessAppInstanceUserPermissions(a[0], a[1], a[2]);
73
+ },
74
+ usage: "dss app business-app-instance-permissions <businessAppId> <instanceProjectKey> <userLogin>",
75
+ description: "Get a user's effective permissions on a Business App instance.",
76
+ examples: ["dss app business-app-instance-permissions my-bapp INSTANCEPROJ alice",],
77
+ },
78
+ };
@@ -0,0 +1,2 @@
1
+ import type { CommandMeta } from "../types.js";
2
+ export declare const bundleCommands: Record<string, CommandMeta>;
@@ -0,0 +1,107 @@
1
+ import { writeFileSync, } from "node:fs";
2
+ import { requireArgs, UsageError, } from "../usage.js";
3
+ export const bundleCommands = {
4
+ "list-exported": {
5
+ handler: (c, _a, f) => c.bundles.listExported(f["project-key"]),
6
+ usage: "dss bundle list-exported [--project-key KEY]",
7
+ description: "List bundles exported from a project on the Design node.",
8
+ examples: ["dss bundle list-exported",],
9
+ },
10
+ export: {
11
+ handler: async (c, a, f) => {
12
+ requireArgs(a, 1, "dss bundle export <bundleId> [--project-key KEY]");
13
+ await c.bundles.exportBundle(a[0], f["project-key"]);
14
+ return { exported: a[0], };
15
+ },
16
+ usage: "dss bundle export <bundleId> [--project-key KEY]",
17
+ description: "Create (or overwrite) an exported Design-node bundle.",
18
+ examples: ["dss bundle export v1",],
19
+ },
20
+ "delete-exported": {
21
+ handler: async (c, a, f) => {
22
+ requireArgs(a, 1, "dss bundle delete-exported <bundleId> [--project-key KEY]");
23
+ await c.bundles.deleteExported(a[0], f["project-key"]);
24
+ return { deleted: true, };
25
+ },
26
+ usage: "dss bundle delete-exported <bundleId> [--project-key KEY]",
27
+ description: "Delete an exported Design-node bundle.",
28
+ examples: ["dss bundle delete-exported v1",],
29
+ },
30
+ "download-exported": {
31
+ handler: async (c, a, f) => {
32
+ requireArgs(a, 1, "dss bundle download-exported <bundleId> --output PATH [--project-key KEY]");
33
+ const out = f["output"];
34
+ if (!out)
35
+ throw new UsageError("--output PATH is required.", "missing_required_flag");
36
+ const res = await c.bundles.downloadExportedArchive(a[0], f["project-key"]);
37
+ const buf = Buffer.from(await res.arrayBuffer());
38
+ writeFileSync(out, buf);
39
+ return { path: out, bytes: buf.length, };
40
+ },
41
+ usage: "dss bundle download-exported <bundleId> --output PATH [--project-key KEY]",
42
+ description: "Download an exported Design-node bundle archive to a local file.",
43
+ examples: ["dss bundle download-exported v1 --output ./bundle.zip",],
44
+ },
45
+ publish: {
46
+ handler: (c, a, f) => {
47
+ requireArgs(a, 1, "dss bundle publish <bundleId> [--project-key KEY]");
48
+ return c.bundles.publish(a[0], f["project-key"]);
49
+ },
50
+ usage: "dss bundle publish <bundleId> [--project-key KEY]",
51
+ description: "Publish a Design-node bundle to the Project Deployer.",
52
+ examples: ["dss bundle publish v1",],
53
+ },
54
+ "list-imported": {
55
+ handler: (c, _a, f) => c.bundles.listImported(f["project-key"]),
56
+ usage: "dss bundle list-imported [--project-key KEY]",
57
+ description: "List bundles imported into a project on the Automation node.",
58
+ examples: ["dss bundle list-imported",],
59
+ },
60
+ "import-from-archive": {
61
+ handler: (c, a, f) => {
62
+ requireArgs(a, 1, "dss bundle import-from-archive <serverArchivePath> [--project-key KEY]");
63
+ return c.bundles.importFromArchive(a[0], f["project-key"]);
64
+ },
65
+ usage: "dss bundle import-from-archive <serverArchivePath> [--project-key KEY]",
66
+ description: "Import a server-side bundle archive into an Automation-node project.",
67
+ examples: ["dss bundle import-from-archive /data/bundles/v1.zip",],
68
+ },
69
+ "import-from-stream": {
70
+ handler: async (c, a, f) => {
71
+ requireArgs(a, 1, "dss bundle import-from-stream <filePath> [--project-key KEY]");
72
+ await c.bundles.importFromStream(a[0], f["project-key"]);
73
+ return { imported: true, };
74
+ },
75
+ usage: "dss bundle import-from-stream <filePath> [--project-key KEY]",
76
+ description: "Upload and import a local bundle archive into an Automation-node project.",
77
+ examples: ["dss bundle import-from-stream ./v1.zip",],
78
+ },
79
+ activate: {
80
+ handler: (c, a, f) => {
81
+ requireArgs(a, 1, "dss bundle activate <bundleId> [--project-key KEY]");
82
+ return c.bundles.activate(a[0], f["project-key"]);
83
+ },
84
+ usage: "dss bundle activate <bundleId> [--project-key KEY]",
85
+ description: "Activate an imported Automation-node bundle.",
86
+ examples: ["dss bundle activate v1",],
87
+ },
88
+ preload: {
89
+ handler: (c, a, f) => {
90
+ requireArgs(a, 1, "dss bundle preload <bundleId> [--project-key KEY]");
91
+ return c.bundles.preload(a[0], f["project-key"]);
92
+ },
93
+ usage: "dss bundle preload <bundleId> [--project-key KEY]",
94
+ description: "Preload an imported Automation-node bundle (stage data/models).",
95
+ examples: ["dss bundle preload v1",],
96
+ },
97
+ "delete-imported": {
98
+ handler: async (c, a, f) => {
99
+ requireArgs(a, 1, "dss bundle delete-imported <bundleId> [--project-key KEY]");
100
+ await c.bundles.deleteImported(a[0], f["project-key"]);
101
+ return { deleted: true, };
102
+ },
103
+ usage: "dss bundle delete-imported <bundleId> [--project-key KEY]",
104
+ description: "Delete an imported Automation-node bundle.",
105
+ examples: ["dss bundle delete-imported v1",],
106
+ },
107
+ };
@@ -0,0 +1,2 @@
1
+ import type { CommandMeta } from "../types.js";
2
+ export declare const businessAppCommands: Record<string, CommandMeta>;
@@ -0,0 +1,76 @@
1
+ import { requiredJsonInput, } from "../coerce.js";
2
+ import { requireArgs, } from "../usage.js";
3
+ export const businessAppCommands = {
4
+ list: {
5
+ handler: (c) => c.applications.listBusinessApps(),
6
+ usage: "dss business-app list",
7
+ description: "List all Business Apps.",
8
+ examples: ["dss business-app list",],
9
+ },
10
+ get: {
11
+ handler: (c, a) => {
12
+ requireArgs(a, 1, "dss business-app get <id>");
13
+ return c.applications.getBusinessApp(a[0]);
14
+ },
15
+ usage: "dss business-app get <id>",
16
+ description: "Get Business App details.",
17
+ examples: ["dss business-app get my-bapp",],
18
+ },
19
+ settings: {
20
+ handler: (c, a) => {
21
+ requireArgs(a, 1, "dss business-app settings <id>");
22
+ return c.applications.getBusinessAppSettings(a[0]);
23
+ },
24
+ usage: "dss business-app settings <id>",
25
+ description: "Get Business App settings.",
26
+ examples: ["dss business-app settings my-bapp",],
27
+ },
28
+ "save-settings": {
29
+ handler: (c, a, f) => {
30
+ requireArgs(a, 1, "dss business-app save-settings <id> (--data JSON|--data-file PATH|--stdin)");
31
+ const body = requiredJsonInput(f, "--data, --data-file, or --stdin is required (settings JSON).");
32
+ return c.applications.saveBusinessAppSettings(a[0], body);
33
+ },
34
+ usage: "dss business-app save-settings <id> (--data JSON|--data-file PATH|--stdin)",
35
+ description: "Save Business App settings (admin only; includes connection remapping).",
36
+ examples: ["dss business-app save-settings my-bapp --data-file settings.json",],
37
+ },
38
+ instances: {
39
+ handler: (c, a) => {
40
+ requireArgs(a, 1, "dss business-app instances <id>");
41
+ return c.applications.listBusinessAppInstances(a[0]);
42
+ },
43
+ usage: "dss business-app instances <id>",
44
+ description: "List instances of a Business App.",
45
+ examples: ["dss business-app instances my-bapp",],
46
+ },
47
+ "create-instance": {
48
+ handler: (c, a, f) => {
49
+ requireArgs(a, 1, "dss business-app create-instance <id> (--data JSON|--data-file PATH|--stdin)");
50
+ const body = requiredJsonInput(f, "--data, --data-file, or --stdin is required (instance payload).");
51
+ return c.applications.createBusinessAppInstance(a[0], body);
52
+ },
53
+ usage: "dss business-app create-instance <id> (--data JSON|--data-file PATH|--stdin)",
54
+ description: "Create an instance of a Business App.",
55
+ examples: ["dss business-app create-instance my-bapp --data '{}'",],
56
+ },
57
+ "upgrade-instance": {
58
+ handler: (c, a) => {
59
+ requireArgs(a, 2, "dss business-app upgrade-instance <id> <projectKey>");
60
+ return c.applications.upgradeBusinessAppInstance(a[0], a[1]);
61
+ },
62
+ usage: "dss business-app upgrade-instance <id> <projectKey>",
63
+ description: "Upgrade a Business App instance to the latest version.",
64
+ examples: ["dss business-app upgrade-instance my-bapp INSTANCEPROJ",],
65
+ },
66
+ "install-from-archive": {
67
+ handler: async (c, a) => {
68
+ requireArgs(a, 1, "dss business-app install-from-archive <filePath>");
69
+ await c.applications.installBusinessAppFromArchive(a[0]);
70
+ return { installed: true, };
71
+ },
72
+ usage: "dss business-app install-from-archive <filePath>",
73
+ description: "Install or upgrade a Business App from a zip archive (admin only).",
74
+ examples: ["dss business-app install-from-archive ./my-bapp.zip",],
75
+ },
76
+ };
@@ -0,0 +1,2 @@
1
+ import type { CommandMeta } from "../types.js";
2
+ export declare const codeEnvCommands: Record<string, CommandMeta>;
@@ -0,0 +1,255 @@
1
+ import { readFileSync, } from "node:fs";
2
+ import { json, jsonInput, parseBooleanOption, } from "../coerce.js";
3
+ import { isNotFoundError, readIfExists, skipResult, } from "../output.js";
4
+ import { requireArgs, UsageError, } from "../usage.js";
5
+ function codeEnvWait(flags) {
6
+ return flags["no-wait"] !== true;
7
+ }
8
+ function codeEnvParams(flags) {
9
+ const params = json(flags["params"]) ?? jsonInput(flags) ?? {};
10
+ if (typeof flags["python-interpreter"] === "string") {
11
+ params.pythonInterpreter = flags["python-interpreter"];
12
+ }
13
+ return params;
14
+ }
15
+ function splitPackageSpec(raw) {
16
+ return raw.split(/\r?\n/).map((line) => line.trim()).filter((line) => line.length > 0);
17
+ }
18
+ function codeEnvPackageList(flags) {
19
+ const packages = [];
20
+ if (typeof flags["file"] === "string") {
21
+ packages.push(...splitPackageSpec(readFileSync(flags["file"], "utf-8")));
22
+ }
23
+ if (typeof flags["packages"] === "string") {
24
+ packages.push(...splitPackageSpec(flags["packages"]));
25
+ }
26
+ if (typeof flags["package"] === "string") {
27
+ packages.push(...splitPackageSpec(flags["package"]));
28
+ }
29
+ if (packages.length === 0) {
30
+ throw new UsageError("--packages, --package, or --file is required. Use newline-separated package specs for version constraints.");
31
+ }
32
+ return packages;
33
+ }
34
+ export const codeEnvCommands = {
35
+ list: {
36
+ handler: (c, _a, f) => c.codeEnvs.list({
37
+ envLang: f["lang"],
38
+ }),
39
+ usage: "dss code-env list [--lang LANG]",
40
+ description: "List code environments.",
41
+ examples: ["dss code-env list", "dss code-env list --lang PYTHON",],
42
+ },
43
+ get: {
44
+ handler: (c, a) => {
45
+ requireArgs(a, 2, "dss code-env get <lang> <name>");
46
+ return c.codeEnvs.get(a[0], a[1]);
47
+ },
48
+ usage: "dss code-env get <lang> <name>",
49
+ description: "Get code environment details.",
50
+ examples: ["dss code-env get PYTHON my_env",],
51
+ },
52
+ "get-definition": {
53
+ handler: (c, a) => {
54
+ requireArgs(a, 2, "dss code-env get-definition <lang> <name>");
55
+ return c.codeEnvs.getDefinition(a[0], a[1]);
56
+ },
57
+ usage: "dss code-env get-definition <lang> <name>",
58
+ description: "Get raw code environment definition.",
59
+ examples: ["dss code-env get-definition PYTHON my_env",],
60
+ },
61
+ create: {
62
+ handler: async (c, a, f) => {
63
+ requireArgs(a, 2, "dss code-env create <lang> <name> --deployment-mode MODE");
64
+ const deploymentMode = f["deployment-mode"];
65
+ if (!deploymentMode) {
66
+ throw new UsageError("--deployment-mode is required. Usage: dss code-env create <lang> <name> --deployment-mode MODE");
67
+ }
68
+ const params = codeEnvParams(f);
69
+ const wait = codeEnvWait(f);
70
+ if (f["if-not-exists"] === true || f["dry-run"] === true) {
71
+ const existing = (await c.codeEnvs.list({ envLang: a[0], }))
72
+ .find((env) => env.envName === a[1]);
73
+ if (existing && f["if-not-exists"] === true && f["dry-run"] !== true) {
74
+ return skipResult("code-env", a[1], "exists", { envLang: a[0], current: existing, });
75
+ }
76
+ if (f["dry-run"] === true) {
77
+ return {
78
+ dryRun: true,
79
+ action: "create",
80
+ resource: "code-env",
81
+ envLang: a[0],
82
+ envName: a[1],
83
+ payload: {
84
+ deploymentMode,
85
+ params,
86
+ wait,
87
+ },
88
+ ...(existing ? { current: existing, } : {}),
89
+ };
90
+ }
91
+ }
92
+ const created = await c.codeEnvs.create({
93
+ envLang: a[0],
94
+ envName: a[1],
95
+ deploymentMode,
96
+ params,
97
+ wait,
98
+ });
99
+ return { created: a[1], resource: "code-env", envLang: a[0], ...created, };
100
+ },
101
+ usage: "dss code-env create <lang> <name> --deployment-mode MODE [--params JSON|--data JSON|--data-file PATH|--stdin] [--python-interpreter PYTHON311] [--no-wait] [--if-not-exists] [--dry-run]",
102
+ description: "Create a code environment.",
103
+ examples: [
104
+ "dss code-env create PYTHON my_env --deployment-mode DESIGN_MANAGED --python-interpreter PYTHON311",
105
+ 'dss code-env create PYTHON my_env --deployment-mode DESIGN_MANAGED --params \'{"pythonInterpreter":"PYTHON311"}\' --dry-run',
106
+ ],
107
+ },
108
+ "set-definition": {
109
+ handler: async (c, a, f) => {
110
+ requireArgs(a, 2, "dss code-env set-definition <lang> <name> --data JSON");
111
+ const definition = jsonInput(f);
112
+ if (!definition) {
113
+ throw new UsageError("--data, --data-file, or --stdin is required. Usage: dss code-env set-definition <lang> <name> --data JSON");
114
+ }
115
+ if (f["dry-run"] === true) {
116
+ return {
117
+ dryRun: true,
118
+ action: "set-definition",
119
+ resource: "code-env",
120
+ envLang: a[0],
121
+ envName: a[1],
122
+ definition,
123
+ };
124
+ }
125
+ return c.codeEnvs.setDefinition(a[0], a[1], definition);
126
+ },
127
+ usage: "dss code-env set-definition <lang> <name> [--data JSON|--data-file PATH|--stdin] [--dry-run]",
128
+ description: "Replace a code environment definition previously fetched from DSS.",
129
+ examples: ["dss code-env set-definition PYTHON my_env --data-file code-env.json --dry-run",],
130
+ },
131
+ "set-packages": {
132
+ handler: async (c, a, f) => {
133
+ requireArgs(a, 2, "dss code-env set-packages <lang> <name> --packages PKGS");
134
+ const packages = codeEnvPackageList(f);
135
+ const installCorePackages = parseBooleanOption(f["install-core-packages"], "--install-core-packages");
136
+ if (f["dry-run"] === true) {
137
+ return {
138
+ dryRun: true,
139
+ action: "set-packages",
140
+ resource: "code-env",
141
+ envLang: a[0],
142
+ envName: a[1],
143
+ packages,
144
+ installCorePackages,
145
+ };
146
+ }
147
+ return c.codeEnvs.setPackages(a[0], a[1], packages, { installCorePackages, });
148
+ },
149
+ usage: "dss code-env set-packages <lang> <name> [--packages PKGS|--package PKG|--file PATH] [--install-core-packages true|false] [--dry-run]",
150
+ description: "Update requested package specs without rebuilding packages.",
151
+ examples: [
152
+ "dss code-env set-packages PYTHON my_env --packages 'tabulate\\nnameparser' --dry-run",
153
+ "dss code-env set-packages PYTHON my_env --file requirements.txt",
154
+ ],
155
+ },
156
+ "update-packages": {
157
+ handler: async (c, a, f) => {
158
+ requireArgs(a, 2, "dss code-env update-packages <lang> <name>");
159
+ const wait = codeEnvWait(f);
160
+ const versionToUpdate = typeof f["env-version"] === "string"
161
+ ? f["env-version"]
162
+ : typeof f["version"] === "string"
163
+ ? f["version"]
164
+ : undefined;
165
+ const opts = {
166
+ forceRebuildEnv: f["force-rebuild"] === true,
167
+ versionToUpdate,
168
+ wait,
169
+ };
170
+ if (f["dry-run"] === true) {
171
+ return {
172
+ dryRun: true,
173
+ action: "update-packages",
174
+ resource: "code-env",
175
+ envLang: a[0],
176
+ envName: a[1],
177
+ ...opts,
178
+ };
179
+ }
180
+ return c.codeEnvs.updatePackages(a[0], a[1], opts);
181
+ },
182
+ usage: "dss code-env update-packages <lang> <name> [--force-rebuild] [--env-version VERSION] [--no-wait] [--dry-run]",
183
+ description: "Rebuild or update code environment packages to match the requested specs.",
184
+ examples: ["dss code-env update-packages PYTHON my_env --force-rebuild --dry-run",],
185
+ },
186
+ "set-jupyter": {
187
+ handler: async (c, a, f) => {
188
+ requireArgs(a, 2, "dss code-env set-jupyter <lang> <name> --active true|false");
189
+ const active = parseBooleanOption(f["active"], "--active");
190
+ if (active === undefined) {
191
+ throw new UsageError("--active is required. Usage: dss code-env set-jupyter <lang> <name> --active true|false");
192
+ }
193
+ const wait = codeEnvWait(f);
194
+ if (f["dry-run"] === true) {
195
+ return {
196
+ dryRun: true,
197
+ action: "set-jupyter",
198
+ resource: "code-env",
199
+ envLang: a[0],
200
+ envName: a[1],
201
+ active,
202
+ wait,
203
+ };
204
+ }
205
+ return c.codeEnvs.setJupyterSupport(a[0], a[1], active, { wait, });
206
+ },
207
+ usage: "dss code-env set-jupyter <lang> <name> --active true|false [--no-wait] [--dry-run]",
208
+ description: "Enable or disable Jupyter support for a code environment.",
209
+ examples: ["dss code-env set-jupyter PYTHON my_env --active true --dry-run",],
210
+ },
211
+ delete: {
212
+ handler: async (c, a, f) => {
213
+ requireArgs(a, 2, "dss code-env delete <lang> <name>");
214
+ const wait = codeEnvWait(f);
215
+ if (f["dry-run"] === true) {
216
+ const current = await readIfExists(() => c.codeEnvs.get(a[0], a[1]));
217
+ if (!current)
218
+ return skipResult("code-env", a[1], "missing", { envLang: a[0], });
219
+ return {
220
+ dryRun: true,
221
+ action: "delete",
222
+ resource: "code-env",
223
+ envLang: a[0],
224
+ envName: a[1],
225
+ wait,
226
+ current,
227
+ };
228
+ }
229
+ if (f["if-exists"] === true) {
230
+ return await c.codeEnvs.delete(a[0], a[1], { wait, }).catch((error) => {
231
+ if (isNotFoundError(error)) {
232
+ return skipResult("code-env", a[1], "missing", { envLang: a[0], });
233
+ }
234
+ throw error;
235
+ });
236
+ }
237
+ return c.codeEnvs.delete(a[0], a[1], { wait, });
238
+ },
239
+ usage: "dss code-env delete <lang> <name> [--no-wait] [--if-exists] [--dry-run]",
240
+ description: "Delete a code environment.",
241
+ examples: ["dss code-env delete PYTHON my_env --dry-run",],
242
+ },
243
+ usages: {
244
+ handler: (c, a) => {
245
+ if (a.length === 0)
246
+ return c.codeEnvs.listUsages();
247
+ if (a.length === 2)
248
+ return c.codeEnvs.listUsages(a[0], a[1]);
249
+ throw new UsageError("Usage: dss code-env usages [<lang> <name>]");
250
+ },
251
+ usage: "dss code-env usages [<lang> <name>]",
252
+ description: "List code environment usages globally or for one environment.",
253
+ examples: ["dss code-env usages", "dss code-env usages PYTHON my_env",],
254
+ },
255
+ };
@@ -0,0 +1,2 @@
1
+ import type { CommandMeta } from "../types.js";
2
+ export declare const codeCommands: Record<string, CommandMeta>;
@@ -0,0 +1,63 @@
1
+ import { readFileSync, } from "node:fs";
2
+ import { num, readStdinText, stripUtf8Bom, } from "../coerce.js";
3
+ import { UsageError, } from "../usage.js";
4
+ const CODE_RUN_USAGE = "dss code run (--file PATH | --stdin) [--env ENV] [--timeout MS] [--keep] [--full-log] [--max-log-bytes N] [--project-key KEY]";
5
+ function resolveCodeInput(args, flags) {
6
+ if (args.length > 0) {
7
+ throw new UsageError(`code run takes no positional arguments; pass the script via --file PATH or --stdin. Usage: ${CODE_RUN_USAGE}`);
8
+ }
9
+ const sources = [];
10
+ if (typeof flags["file"] === "string") {
11
+ sources.push({ label: "--file", read: () => readFileSync(flags["file"], "utf-8"), });
12
+ }
13
+ if (flags["stdin"] === true) {
14
+ sources.push({ label: "--stdin", read: readStdinText, });
15
+ }
16
+ if (sources.length === 0) {
17
+ throw new UsageError(`Python source is required: pass --file PATH or --stdin. Usage: ${CODE_RUN_USAGE}`);
18
+ }
19
+ if (sources.length > 1) {
20
+ throw new UsageError(`Choose exactly one Python source: --file or --stdin. Usage: ${CODE_RUN_USAGE}`);
21
+ }
22
+ const script = stripUtf8Bom(sources[0].read());
23
+ if (script.trim().length === 0) {
24
+ throw new UsageError(`Python source from ${sources[0].label} must not be empty. Usage: ${CODE_RUN_USAGE}`);
25
+ }
26
+ return script;
27
+ }
28
+ export const codeCommands = {
29
+ run: {
30
+ handler: async (c, a, f) => {
31
+ const script = resolveCodeInput(a, f);
32
+ const run = await c.scenarios.runScript(script, {
33
+ envName: f["env"],
34
+ projectKey: f["project-key"],
35
+ timeoutMs: num(f["timeout"]),
36
+ keepScenario: f["keep"] === true,
37
+ maxLogBytes: num(f["max-log-bytes"]),
38
+ });
39
+ const result = {
40
+ outcome: run.outcome,
41
+ success: run.success,
42
+ runId: run.runId,
43
+ elapsedMs: run.elapsedMs,
44
+ pollCount: run.pollCount,
45
+ output: run.output ?? "",
46
+ logTruncated: run.logTruncated,
47
+ maxLogBytes: run.maxLogBytes,
48
+ };
49
+ if (f["full-log"] === true || run.output === undefined) {
50
+ result.log = run.log;
51
+ }
52
+ return result;
53
+ },
54
+ usage: CODE_RUN_USAGE,
55
+ description: "Run one-off Python in a DSS code env via a throwaway custom-python scenario; returns the script's captured output (stdout+stderr) plus outcome/success. Log retrieval is capped by --max-log-bytes (default 1048576); pass --full-log to include the capped raw DSS run log. Exits 4 on a non-SUCCESS outcome.",
56
+ examples: [
57
+ "dss code run --file inspect.py",
58
+ "dss code run --file inspect.py --env py39_pandas",
59
+ "cat snippet.py | dss code run --stdin",
60
+ "dss code run --file inspect.py --full-log",
61
+ ],
62
+ },
63
+ };
@@ -0,0 +1,2 @@
1
+ import type { CommandMeta } from "../types.js";
2
+ export declare const connectionCommands: Record<string, CommandMeta>;
@@ -0,0 +1,54 @@
1
+ import { UsageError, } from "../usage.js";
2
+ export const connectionCommands = {
3
+ list: {
4
+ handler: (c, _a, f) => c.connections.list({
5
+ type: f["type"],
6
+ }),
7
+ usage: "dss connection list [--type TYPE]",
8
+ description: "List all connection names, optionally filtered by connection type.",
9
+ examples: ["dss connection list", "dss connection list --type Filesystem",],
10
+ },
11
+ infer: {
12
+ handler: (c, _a, f) => c.connections.infer({
13
+ mode: f["mode"],
14
+ projectKey: f["project-key"],
15
+ }),
16
+ usage: "dss connection infer [--mode fast|rich] [--project-key KEY]",
17
+ description: "List connections with inferred types and metadata.",
18
+ examples: ["dss connection infer", "dss connection infer --mode rich",],
19
+ },
20
+ schemas: {
21
+ handler: (c, _a, f) => {
22
+ const connection = f["connection"];
23
+ if (!connection) {
24
+ throw new UsageError("--connection is required. Usage: dss connection schemas --connection CONN");
25
+ }
26
+ return c.connections.schemas({
27
+ connection,
28
+ projectKey: f["project-key"],
29
+ });
30
+ },
31
+ usage: "dss connection schemas --connection CONN [--project-key KEY]",
32
+ description: "List schemas in a SQL connection.",
33
+ examples: ["dss connection schemas --connection ATHENA_CONN --project-key MYPROJ",],
34
+ },
35
+ tables: {
36
+ handler: (c, _a, f) => {
37
+ const connection = f["connection"];
38
+ if (!connection) {
39
+ throw new UsageError("--connection is required. Usage: dss connection tables --connection CONN");
40
+ }
41
+ return c.connections.tables({
42
+ connection,
43
+ catalog: f["catalog"],
44
+ schema: f["schema"],
45
+ projectKey: f["project-key"],
46
+ });
47
+ },
48
+ usage: "dss connection tables --connection CONN [--catalog CATALOG] [--schema SCHEMA] [--project-key KEY]",
49
+ description: "List importable tables in a SQL connection, optionally scoped by catalog and schema.",
50
+ examples: [
51
+ "dss connection tables --connection ATHENA_CONN --schema analytics --project-key MYPROJ",
52
+ ],
53
+ },
54
+ };
@@ -0,0 +1,2 @@
1
+ import type { CommandMeta } from "../types.js";
2
+ export declare const continuousActivityCommands: Record<string, CommandMeta>;