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
|
@@ -160,6 +160,7 @@ export declare const RecipeCreateResultSchema: import("@sinclair/typebox").TObje
|
|
|
160
160
|
outputFolder: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
161
161
|
temporaryOutputDataset: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
162
162
|
temporaryOutputDatasetDeleted: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
163
|
+
syncOutputSchemaPropagated: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
|
|
163
164
|
}>;
|
|
164
165
|
export type RecipeCreateResult = Static<typeof RecipeCreateResultSchema>;
|
|
165
166
|
export declare const JobSummarySchema: import("@sinclair/typebox").TObject<{
|
|
@@ -264,6 +265,12 @@ export declare const ScenarioStatusSchema: import("@sinclair/typebox").TObject<{
|
|
|
264
265
|
}>>;
|
|
265
266
|
}>;
|
|
266
267
|
export type ScenarioStatus = Static<typeof ScenarioStatusSchema>;
|
|
268
|
+
export declare const ScenarioStepRunSchema: import("@sinclair/typebox").TObject<{
|
|
269
|
+
name: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
270
|
+
type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
271
|
+
outcome: import("@sinclair/typebox").TString;
|
|
272
|
+
}>;
|
|
273
|
+
export type ScenarioStepRun = Static<typeof ScenarioStepRunSchema>;
|
|
267
274
|
export declare const ScenarioWaitResultSchema: import("@sinclair/typebox").TObject<{
|
|
268
275
|
scenarioId: import("@sinclair/typebox").TString;
|
|
269
276
|
runId: import("@sinclair/typebox").TString;
|
|
@@ -272,6 +279,12 @@ export declare const ScenarioWaitResultSchema: import("@sinclair/typebox").TObje
|
|
|
272
279
|
elapsedMs: import("@sinclair/typebox").TNumber;
|
|
273
280
|
pollCount: import("@sinclair/typebox").TNumber;
|
|
274
281
|
timedOut: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
282
|
+
triggerRunId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
283
|
+
steps: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
284
|
+
name: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
285
|
+
type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
286
|
+
outcome: import("@sinclair/typebox").TString;
|
|
287
|
+
}>>>;
|
|
275
288
|
}>;
|
|
276
289
|
export type ScenarioWaitResult = Static<typeof ScenarioWaitResultSchema>;
|
|
277
290
|
export declare const FlowZoneObjectTypeSchema: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"DATASET">, import("@sinclair/typebox").TLiteral<"MANAGED_FOLDER">, import("@sinclair/typebox").TLiteral<"SAVED_MODEL">, import("@sinclair/typebox").TLiteral<"RECIPE">, import("@sinclair/typebox").TLiteral<"MODEL_EVALUATION_STORE">, import("@sinclair/typebox").TLiteral<"STREAMING_ENDPOINT">, import("@sinclair/typebox").TLiteral<"LABELING_TASK">, import("@sinclair/typebox").TLiteral<"RETRIEVABLE_KNOWLEDGE">]>;
|
|
@@ -552,7 +565,7 @@ export declare const JupyterCellSchema: import("@sinclair/typebox").TObject<{
|
|
|
552
565
|
source: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>;
|
|
553
566
|
metadata: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TUnknown>>;
|
|
554
567
|
outputs: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnknown>>;
|
|
555
|
-
execution_count: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").
|
|
568
|
+
execution_count: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TNull, import("@sinclair/typebox").TNumber]>>;
|
|
556
569
|
}>;
|
|
557
570
|
export type JupyterCell = Static<typeof JupyterCellSchema>;
|
|
558
571
|
export declare const JupyterNotebookSummarySchema: import("@sinclair/typebox").TObject<{
|
|
@@ -575,7 +588,7 @@ export declare const JupyterNotebookContentSchema: import("@sinclair/typebox").T
|
|
|
575
588
|
source: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>;
|
|
576
589
|
metadata: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TUnknown>>;
|
|
577
590
|
outputs: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnknown>>;
|
|
578
|
-
execution_count: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").
|
|
591
|
+
execution_count: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TNull, import("@sinclair/typebox").TNumber]>>;
|
|
579
592
|
}>>;
|
|
580
593
|
}>;
|
|
581
594
|
export type JupyterNotebookContent = Static<typeof JupyterNotebookContentSchema>;
|
|
@@ -207,6 +207,7 @@ export const RecipeCreateResultSchema = Type.Object({
|
|
|
207
207
|
outputFolder: Type.Optional(Type.String()),
|
|
208
208
|
temporaryOutputDataset: Type.Optional(Type.String()),
|
|
209
209
|
temporaryOutputDatasetDeleted: Type.Optional(Type.Boolean()),
|
|
210
|
+
syncOutputSchemaPropagated: Type.Optional(Type.Array(Type.String())),
|
|
210
211
|
});
|
|
211
212
|
// ---------------------------------------------------------------------------
|
|
212
213
|
// Jobs
|
|
@@ -313,6 +314,11 @@ export const ScenarioStatusSchema = Type.Object({
|
|
|
313
314
|
}, { additionalProperties: true, })),
|
|
314
315
|
}, { additionalProperties: true, })),
|
|
315
316
|
}, { additionalProperties: true, });
|
|
317
|
+
export const ScenarioStepRunSchema = Type.Object({
|
|
318
|
+
name: Type.Optional(Type.String()),
|
|
319
|
+
type: Type.Optional(Type.String()),
|
|
320
|
+
outcome: Type.String(),
|
|
321
|
+
}, { additionalProperties: false, });
|
|
316
322
|
export const ScenarioWaitResultSchema = Type.Object({
|
|
317
323
|
scenarioId: Type.String(),
|
|
318
324
|
runId: Type.String(),
|
|
@@ -321,6 +327,8 @@ export const ScenarioWaitResultSchema = Type.Object({
|
|
|
321
327
|
elapsedMs: Type.Number(),
|
|
322
328
|
pollCount: Type.Number(),
|
|
323
329
|
timedOut: Type.Optional(Type.Boolean()),
|
|
330
|
+
triggerRunId: Type.Optional(Type.String()),
|
|
331
|
+
steps: Type.Optional(Type.Array(ScenarioStepRunSchema)),
|
|
324
332
|
});
|
|
325
333
|
// ---------------------------------------------------------------------------
|
|
326
334
|
// Flow zones
|
|
@@ -548,7 +556,7 @@ export const JupyterCellSchema = Type.Object({
|
|
|
548
556
|
source: Type.Array(Type.String()),
|
|
549
557
|
metadata: Type.Optional(Type.Record(Type.String(), Type.Unknown())),
|
|
550
558
|
outputs: Type.Optional(Type.Array(Type.Unknown())),
|
|
551
|
-
execution_count: Type.Optional(Type.Union([Type.
|
|
559
|
+
execution_count: Type.Optional(Type.Union([Type.Null(), Type.Number(),])),
|
|
552
560
|
}, { additionalProperties: true, });
|
|
553
561
|
export const JupyterNotebookSummarySchema = Type.Object({
|
|
554
562
|
name: Type.String(),
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { JobBuildTargetType, JobLogFilter } from "../resources/jobs.js";
|
|
2
|
+
export declare function num(v: string | boolean | undefined): number | undefined;
|
|
3
|
+
export declare function jobBuildTargetType(v: string | boolean | undefined): JobBuildTargetType;
|
|
4
|
+
export declare function jobBuildTargetTypeFromFlags(flags: Record<string, string | boolean>): JobBuildTargetType;
|
|
5
|
+
export declare function maxLogLinesFromFlags(flags: Record<string, string | boolean>): number | undefined;
|
|
6
|
+
export declare function jobLogFilterFromFlag(v: string | boolean | undefined): JobLogFilter | undefined;
|
|
7
|
+
export declare function sha256Hex(value: string): string;
|
|
8
|
+
export declare function normalizeLineEndings(value: string): string;
|
|
9
|
+
export declare function stableJson(value: unknown): string;
|
|
10
|
+
export declare function stableHash(value: unknown): string;
|
|
11
|
+
export declare function splitCsvFlag(v: string | boolean | undefined): string[];
|
|
12
|
+
export declare function recipeInputDatasetsFromFlags(flags: Record<string, string | boolean>): string[] | undefined;
|
|
13
|
+
export declare function rewritePairsFromFlags(flags: Record<string, string | boolean>, flagName: string): Record<string, string>;
|
|
14
|
+
export declare function plainRecord(value: unknown): Record<string, unknown> | undefined;
|
|
15
|
+
export declare function requiredStringFlag(flags: Record<string, string | boolean>, name: string, usage: string): string;
|
|
16
|
+
export declare function optionalStringField(record: Record<string, unknown>, keys: string[]): string | undefined;
|
|
17
|
+
export declare function requiredStringArray(value: unknown, source: string): string[];
|
|
18
|
+
export declare function finiteNumberField(record: Record<string, unknown>, key: string, source: string): number;
|
|
19
|
+
export declare function stripUtf8Bom(text: string): string;
|
|
20
|
+
export declare function parseJsonValue(text: string, source: string): unknown;
|
|
21
|
+
export declare function expectJsonObject(value: unknown, source: string): Record<string, unknown>;
|
|
22
|
+
export declare function parseJsonObject(text: string, source: string): Record<string, unknown>;
|
|
23
|
+
export declare function json(v: string | boolean | undefined, source?: string): Record<string, unknown> | undefined;
|
|
24
|
+
export declare function readStdinText(): string;
|
|
25
|
+
export declare function jsonInput(flags: Record<string, string | boolean>): Record<string, unknown> | undefined;
|
|
26
|
+
export declare function unknownJsonInput(flags: Record<string, string | boolean>): unknown;
|
|
27
|
+
export declare function schemaColumnsInput(flags: Record<string, string | boolean>, usage: string): Array<{
|
|
28
|
+
comment?: string;
|
|
29
|
+
name: string;
|
|
30
|
+
type: string;
|
|
31
|
+
}>;
|
|
32
|
+
export declare function textInput(flags: Record<string, string | boolean>): string | undefined;
|
|
33
|
+
export declare function requiredJsonInput(flags: Record<string, string | boolean>, message: string): Record<string, unknown>;
|
|
34
|
+
export declare function parseBooleanOption(value: string | boolean | undefined, flagName: string): boolean | undefined;
|
|
35
|
+
export declare function stringField(record: Record<string, unknown>, fields: string[]): string | undefined;
|
|
36
|
+
export declare function resultRecord(result: unknown): Record<string, unknown>;
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { createHash, } from "node:crypto";
|
|
2
|
+
import { readFileSync, } from "node:fs";
|
|
3
|
+
import { UsageError, } from "./usage.js";
|
|
4
|
+
export function num(v) {
|
|
5
|
+
if (typeof v !== "string")
|
|
6
|
+
return undefined;
|
|
7
|
+
const n = Number(v);
|
|
8
|
+
return Number.isFinite(n) ? n : undefined;
|
|
9
|
+
}
|
|
10
|
+
export function jobBuildTargetType(v) {
|
|
11
|
+
if (v === undefined)
|
|
12
|
+
return "DATASET";
|
|
13
|
+
if (typeof v !== "string") {
|
|
14
|
+
throw new UsageError("Invalid job target type. Use dataset or managed-folder.", "invalid_enum");
|
|
15
|
+
}
|
|
16
|
+
const normalized = v.trim().toUpperCase().replace(/-/g, "_");
|
|
17
|
+
if (normalized === "DATASET" || normalized === "MANAGED_FOLDER")
|
|
18
|
+
return normalized;
|
|
19
|
+
throw new UsageError("Invalid job target type. Use dataset or managed-folder.", "invalid_enum");
|
|
20
|
+
}
|
|
21
|
+
export function jobBuildTargetTypeFromFlags(flags) {
|
|
22
|
+
return jobBuildTargetType(flags["target-type"] ?? flags["type"]);
|
|
23
|
+
}
|
|
24
|
+
export function maxLogLinesFromFlags(flags) {
|
|
25
|
+
return num(flags["max-log-lines"] ?? flags["max-lines"]);
|
|
26
|
+
}
|
|
27
|
+
export function jobLogFilterFromFlag(v) {
|
|
28
|
+
if (v === undefined)
|
|
29
|
+
return undefined;
|
|
30
|
+
if (typeof v !== "string") {
|
|
31
|
+
throw new UsageError("Invalid --log-filter value. Use stdout, stderr, user, or errors.", "invalid_enum");
|
|
32
|
+
}
|
|
33
|
+
const normalized = v.trim().toLowerCase();
|
|
34
|
+
if (normalized === "stdout" || normalized === "stderr" || normalized === "user"
|
|
35
|
+
|| normalized === "errors") {
|
|
36
|
+
return normalized;
|
|
37
|
+
}
|
|
38
|
+
throw new UsageError("Invalid --log-filter value. Use stdout, stderr, user, or errors.", "invalid_enum");
|
|
39
|
+
}
|
|
40
|
+
export function sha256Hex(value) {
|
|
41
|
+
return createHash("sha256").update(value).digest("hex");
|
|
42
|
+
}
|
|
43
|
+
export function normalizeLineEndings(value) {
|
|
44
|
+
return value.replace(/\r\n/g, "\n");
|
|
45
|
+
}
|
|
46
|
+
export function stableJson(value) {
|
|
47
|
+
if (value === undefined)
|
|
48
|
+
return "undefined";
|
|
49
|
+
if (value === null || typeof value !== "object")
|
|
50
|
+
return JSON.stringify(value);
|
|
51
|
+
if (Array.isArray(value))
|
|
52
|
+
return `[${value.map((item) => stableJson(item)).join(",")}]`;
|
|
53
|
+
const entries = Object.entries(value).sort(([a,], [b,]) => a.localeCompare(b));
|
|
54
|
+
return `{${entries.map(([key, item,]) => `${JSON.stringify(key)}:${stableJson(item)}`).join(",")}}`;
|
|
55
|
+
}
|
|
56
|
+
export function stableHash(value) {
|
|
57
|
+
return sha256Hex(stableJson(value));
|
|
58
|
+
}
|
|
59
|
+
export function splitCsvFlag(v) {
|
|
60
|
+
if (typeof v !== "string")
|
|
61
|
+
return [];
|
|
62
|
+
return v.split(",").map((item) => item.trim()).filter((item) => item.length > 0);
|
|
63
|
+
}
|
|
64
|
+
export function recipeInputDatasetsFromFlags(flags) {
|
|
65
|
+
const inputs = splitCsvFlag(flags["input"]);
|
|
66
|
+
return inputs.length > 0 ? inputs : undefined;
|
|
67
|
+
}
|
|
68
|
+
export function rewritePairsFromFlags(flags, flagName) {
|
|
69
|
+
const rewrites = {};
|
|
70
|
+
for (const spec of splitCsvFlag(flags[flagName])) {
|
|
71
|
+
const idx = spec.indexOf("=");
|
|
72
|
+
if (idx <= 0 || idx === spec.length - 1) {
|
|
73
|
+
throw new UsageError(`--${flagName} values must use FROM=TO.`, "invalid_enum");
|
|
74
|
+
}
|
|
75
|
+
const from = spec.slice(0, idx).trim();
|
|
76
|
+
const to = spec.slice(idx + 1).trim();
|
|
77
|
+
if (!from || !to)
|
|
78
|
+
throw new UsageError(`--${flagName} values must use FROM=TO.`, "invalid_enum");
|
|
79
|
+
rewrites[from] = to;
|
|
80
|
+
}
|
|
81
|
+
return rewrites;
|
|
82
|
+
}
|
|
83
|
+
export function plainRecord(value) {
|
|
84
|
+
return value && typeof value === "object" && !Array.isArray(value)
|
|
85
|
+
? value
|
|
86
|
+
: undefined;
|
|
87
|
+
}
|
|
88
|
+
export function requiredStringFlag(flags, name, usage) {
|
|
89
|
+
const value = flags[name];
|
|
90
|
+
if (typeof value !== "string" || value.trim().length === 0) {
|
|
91
|
+
throw new UsageError(`--${name} is required. Usage: ${usage}`, "missing_required_flag");
|
|
92
|
+
}
|
|
93
|
+
return value.trim();
|
|
94
|
+
}
|
|
95
|
+
export function optionalStringField(record, keys) {
|
|
96
|
+
for (const key of keys) {
|
|
97
|
+
const value = record[key];
|
|
98
|
+
if (typeof value === "string" && value.trim().length > 0)
|
|
99
|
+
return value.trim();
|
|
100
|
+
}
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
103
|
+
export function requiredStringArray(value, source) {
|
|
104
|
+
if (!Array.isArray(value)) {
|
|
105
|
+
throw new UsageError(`${source} must be an array of strings.`, "validation_failed");
|
|
106
|
+
}
|
|
107
|
+
return value.map((item, index) => {
|
|
108
|
+
if (typeof item !== "string" || item.trim().length === 0) {
|
|
109
|
+
throw new UsageError(`${source}[${index}] must be a non-empty string.`, "validation_failed");
|
|
110
|
+
}
|
|
111
|
+
return item.trim();
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
export function finiteNumberField(record, key, source) {
|
|
115
|
+
const value = record[key];
|
|
116
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
117
|
+
throw new UsageError(`${source}.${key} must be a finite number.`, "validation_failed");
|
|
118
|
+
}
|
|
119
|
+
return value;
|
|
120
|
+
}
|
|
121
|
+
export function stripUtf8Bom(text) {
|
|
122
|
+
return text.charCodeAt(0) === 0xfeff ? text.slice(1) : text;
|
|
123
|
+
}
|
|
124
|
+
export function parseJsonValue(text, source) {
|
|
125
|
+
try {
|
|
126
|
+
return JSON.parse(stripUtf8Bom(text));
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
130
|
+
throw new UsageError(`Invalid JSON in ${source}: ${message}`, "validation_failed");
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
export function expectJsonObject(value, source) {
|
|
134
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
135
|
+
return value;
|
|
136
|
+
}
|
|
137
|
+
throw new UsageError(`Expected JSON object in ${source}.`, "validation_failed");
|
|
138
|
+
}
|
|
139
|
+
export function parseJsonObject(text, source) {
|
|
140
|
+
return expectJsonObject(parseJsonValue(text, source), source);
|
|
141
|
+
}
|
|
142
|
+
export function json(v, source = "JSON flag") {
|
|
143
|
+
if (typeof v !== "string")
|
|
144
|
+
return undefined;
|
|
145
|
+
return parseJsonObject(v, source);
|
|
146
|
+
}
|
|
147
|
+
export function readStdinText() {
|
|
148
|
+
return readFileSync(0, "utf-8");
|
|
149
|
+
}
|
|
150
|
+
export function jsonInput(flags) {
|
|
151
|
+
if (flags["stdin"] === true)
|
|
152
|
+
return parseJsonObject(readStdinText(), "stdin");
|
|
153
|
+
if (typeof flags["data-file"] === "string") {
|
|
154
|
+
return parseJsonObject(readFileSync(flags["data-file"], "utf-8"), flags["data-file"]);
|
|
155
|
+
}
|
|
156
|
+
if (typeof flags["data"] === "string")
|
|
157
|
+
return parseJsonObject(flags["data"], "--data");
|
|
158
|
+
return undefined;
|
|
159
|
+
}
|
|
160
|
+
export function unknownJsonInput(flags) {
|
|
161
|
+
if (flags["stdin"] === true)
|
|
162
|
+
return parseJsonValue(readStdinText(), "stdin");
|
|
163
|
+
if (typeof flags["data-file"] === "string") {
|
|
164
|
+
return parseJsonValue(readFileSync(flags["data-file"], "utf-8"), flags["data-file"]);
|
|
165
|
+
}
|
|
166
|
+
if (typeof flags["data"] === "string")
|
|
167
|
+
return parseJsonValue(flags["data"], "--data");
|
|
168
|
+
return undefined;
|
|
169
|
+
}
|
|
170
|
+
export function schemaColumnsInput(flags, usage) {
|
|
171
|
+
const input = unknownJsonInput(flags);
|
|
172
|
+
if (input === undefined) {
|
|
173
|
+
throw new UsageError(`--data, --data-file, or --stdin is required. Usage: ${usage}`);
|
|
174
|
+
}
|
|
175
|
+
const columns = Array.isArray(input)
|
|
176
|
+
? input
|
|
177
|
+
: input && typeof input === "object" && Array.isArray(input.columns)
|
|
178
|
+
? input.columns
|
|
179
|
+
: undefined;
|
|
180
|
+
if (!columns) {
|
|
181
|
+
throw new UsageError("Schema input must be an array of columns or an object with a columns array.");
|
|
182
|
+
}
|
|
183
|
+
return columns.map((column, index) => {
|
|
184
|
+
if (!column || typeof column !== "object" || Array.isArray(column)) {
|
|
185
|
+
throw new UsageError(`Schema column at index ${index} must be an object.`);
|
|
186
|
+
}
|
|
187
|
+
const record = column;
|
|
188
|
+
if (typeof record.name !== "string" || record.name.length === 0) {
|
|
189
|
+
throw new UsageError(`Schema column at index ${index} is missing string field "name".`);
|
|
190
|
+
}
|
|
191
|
+
if (typeof record.type !== "string" || record.type.length === 0) {
|
|
192
|
+
throw new UsageError(`Schema column "${record.name}" is missing string field "type".`);
|
|
193
|
+
}
|
|
194
|
+
return {
|
|
195
|
+
...record,
|
|
196
|
+
name: record.name,
|
|
197
|
+
type: record.type,
|
|
198
|
+
...(typeof record.comment === "string" ? { comment: record.comment, } : {}),
|
|
199
|
+
};
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
export function textInput(flags) {
|
|
203
|
+
if (typeof flags["content"] === "string")
|
|
204
|
+
return flags["content"];
|
|
205
|
+
if (typeof flags["file"] === "string")
|
|
206
|
+
return readFileSync(flags["file"], "utf-8");
|
|
207
|
+
return undefined;
|
|
208
|
+
}
|
|
209
|
+
export function requiredJsonInput(flags, message) {
|
|
210
|
+
const data = jsonInput(flags);
|
|
211
|
+
if (data === undefined)
|
|
212
|
+
throw new UsageError(message);
|
|
213
|
+
return data;
|
|
214
|
+
}
|
|
215
|
+
export function parseBooleanOption(value, flagName) {
|
|
216
|
+
if (value === undefined)
|
|
217
|
+
return undefined;
|
|
218
|
+
if (typeof value === "boolean")
|
|
219
|
+
return value;
|
|
220
|
+
const normalized = value.trim().toLowerCase();
|
|
221
|
+
if (["1", "true", "yes", "y", "on",].includes(normalized))
|
|
222
|
+
return true;
|
|
223
|
+
if (["0", "false", "no", "n", "off",].includes(normalized))
|
|
224
|
+
return false;
|
|
225
|
+
throw new UsageError(`${flagName} must be true or false.`, "invalid_enum");
|
|
226
|
+
}
|
|
227
|
+
export function stringField(record, fields) {
|
|
228
|
+
for (const field of fields) {
|
|
229
|
+
const value = record[field];
|
|
230
|
+
if (typeof value === "string" && value.length > 0)
|
|
231
|
+
return value;
|
|
232
|
+
}
|
|
233
|
+
return undefined;
|
|
234
|
+
}
|
|
235
|
+
export function resultRecord(result) {
|
|
236
|
+
return result !== null && typeof result === "object" && !Array.isArray(result)
|
|
237
|
+
? result
|
|
238
|
+
: {};
|
|
239
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { requiredJsonInput, } from "../coerce.js";
|
|
2
|
+
import { requireArgs, } from "../usage.js";
|
|
3
|
+
export const apiDeployerCommands = {
|
|
4
|
+
"list-infras": {
|
|
5
|
+
handler: (c) => c.apiDeployer.listInfras(),
|
|
6
|
+
usage: "dss api-deployer list-infras",
|
|
7
|
+
description: "List API Deployer infrastructures.",
|
|
8
|
+
examples: ["dss api-deployer list-infras",],
|
|
9
|
+
},
|
|
10
|
+
"create-infra": {
|
|
11
|
+
handler: (c, _a, f) => {
|
|
12
|
+
const body = requiredJsonInput(f, "--data, --data-file, or --stdin is required (infra settings).");
|
|
13
|
+
return c.apiDeployer.createInfra(body);
|
|
14
|
+
},
|
|
15
|
+
usage: "dss api-deployer create-infra (--data JSON|--data-file PATH|--stdin)",
|
|
16
|
+
description: "Create an API Deployer infrastructure.",
|
|
17
|
+
examples: ["dss api-deployer create-infra --data-file infra.json",],
|
|
18
|
+
},
|
|
19
|
+
"get-infra": {
|
|
20
|
+
handler: (c, a) => {
|
|
21
|
+
requireArgs(a, 1, "dss api-deployer get-infra <infraId>");
|
|
22
|
+
return c.apiDeployer.getInfra(a[0]);
|
|
23
|
+
},
|
|
24
|
+
usage: "dss api-deployer get-infra <infraId>",
|
|
25
|
+
description: "Get an API Deployer infrastructure status.",
|
|
26
|
+
examples: ["dss api-deployer get-infra prod-infra",],
|
|
27
|
+
},
|
|
28
|
+
"delete-infra": {
|
|
29
|
+
handler: async (c, a) => {
|
|
30
|
+
requireArgs(a, 1, "dss api-deployer delete-infra <infraId>");
|
|
31
|
+
await c.apiDeployer.deleteInfra(a[0]);
|
|
32
|
+
return { deleted: true, };
|
|
33
|
+
},
|
|
34
|
+
usage: "dss api-deployer delete-infra <infraId>",
|
|
35
|
+
description: "Delete an API Deployer infrastructure.",
|
|
36
|
+
examples: ["dss api-deployer delete-infra prod-infra",],
|
|
37
|
+
},
|
|
38
|
+
"list-stages": {
|
|
39
|
+
handler: (c) => c.apiDeployer.listStages(),
|
|
40
|
+
usage: "dss api-deployer list-stages",
|
|
41
|
+
description: "List API Deployer lifecycle stages.",
|
|
42
|
+
examples: ["dss api-deployer list-stages",],
|
|
43
|
+
},
|
|
44
|
+
"list-services": {
|
|
45
|
+
handler: (c) => c.apiDeployer.listServices(),
|
|
46
|
+
usage: "dss api-deployer list-services",
|
|
47
|
+
description: "List published API Deployer services.",
|
|
48
|
+
examples: ["dss api-deployer list-services",],
|
|
49
|
+
},
|
|
50
|
+
"create-service": {
|
|
51
|
+
handler: (c, _a, f) => {
|
|
52
|
+
const body = requiredJsonInput(f, "--data, --data-file, or --stdin is required (service definition).");
|
|
53
|
+
return c.apiDeployer.createService(body);
|
|
54
|
+
},
|
|
55
|
+
usage: "dss api-deployer create-service (--data JSON|--data-file PATH|--stdin)",
|
|
56
|
+
description: "Create a published API Deployer service.",
|
|
57
|
+
examples: ['dss api-deployer create-service --data \'{"id":"my-service"}\'',],
|
|
58
|
+
},
|
|
59
|
+
"get-service": {
|
|
60
|
+
handler: (c, a) => {
|
|
61
|
+
requireArgs(a, 1, "dss api-deployer get-service <serviceId>");
|
|
62
|
+
return c.apiDeployer.getService(a[0]);
|
|
63
|
+
},
|
|
64
|
+
usage: "dss api-deployer get-service <serviceId>",
|
|
65
|
+
description: "Get a published service's status (versions + deployments).",
|
|
66
|
+
examples: ["dss api-deployer get-service my-service",],
|
|
67
|
+
},
|
|
68
|
+
"delete-service": {
|
|
69
|
+
handler: async (c, a) => {
|
|
70
|
+
requireArgs(a, 1, "dss api-deployer delete-service <serviceId>");
|
|
71
|
+
await c.apiDeployer.deleteService(a[0]);
|
|
72
|
+
return { deleted: true, };
|
|
73
|
+
},
|
|
74
|
+
usage: "dss api-deployer delete-service <serviceId>",
|
|
75
|
+
description: "Delete a published API Deployer service.",
|
|
76
|
+
examples: ["dss api-deployer delete-service my-service",],
|
|
77
|
+
},
|
|
78
|
+
"publish-version": {
|
|
79
|
+
handler: async (c, a) => {
|
|
80
|
+
requireArgs(a, 2, "dss api-deployer publish-version <serviceId> <archive.zip>");
|
|
81
|
+
await c.apiDeployer.publishServiceVersion(a[0], a[1]);
|
|
82
|
+
return { published: true, };
|
|
83
|
+
},
|
|
84
|
+
usage: "dss api-deployer publish-version <serviceId> <archive.zip>",
|
|
85
|
+
description: "Publish (upload) a service version package to the API Deployer.",
|
|
86
|
+
examples: ["dss api-deployer publish-version my-service ./pkg.zip",],
|
|
87
|
+
},
|
|
88
|
+
"delete-version": {
|
|
89
|
+
handler: async (c, a) => {
|
|
90
|
+
requireArgs(a, 2, "dss api-deployer delete-version <serviceId> <version>");
|
|
91
|
+
await c.apiDeployer.deleteServiceVersion(a[0], a[1]);
|
|
92
|
+
return { deleted: true, };
|
|
93
|
+
},
|
|
94
|
+
usage: "dss api-deployer delete-version <serviceId> <version>",
|
|
95
|
+
description: "Delete a published service version.",
|
|
96
|
+
examples: ["dss api-deployer delete-version my-service v1",],
|
|
97
|
+
},
|
|
98
|
+
"list-deployments": {
|
|
99
|
+
handler: (c) => c.apiDeployer.listDeployments(),
|
|
100
|
+
usage: "dss api-deployer list-deployments",
|
|
101
|
+
description: "List API Deployer deployments.",
|
|
102
|
+
examples: ["dss api-deployer list-deployments",],
|
|
103
|
+
},
|
|
104
|
+
"create-deployment": {
|
|
105
|
+
handler: (c, _a, f) => {
|
|
106
|
+
const body = requiredJsonInput(f, "--data, --data-file, or --stdin is required (deployment settings).");
|
|
107
|
+
return c.apiDeployer.createDeployment(body);
|
|
108
|
+
},
|
|
109
|
+
usage: "dss api-deployer create-deployment (--data JSON|--data-file PATH|--stdin)",
|
|
110
|
+
description: "Create an API Deployer deployment (maps a service version to an infra).",
|
|
111
|
+
examples: ["dss api-deployer create-deployment --data-file deployment.json",],
|
|
112
|
+
},
|
|
113
|
+
"get-deployment": {
|
|
114
|
+
handler: (c, a) => {
|
|
115
|
+
requireArgs(a, 1, "dss api-deployer get-deployment <deploymentId>");
|
|
116
|
+
return c.apiDeployer.getDeployment(a[0]);
|
|
117
|
+
},
|
|
118
|
+
usage: "dss api-deployer get-deployment <deploymentId>",
|
|
119
|
+
description: "Get an API Deployer deployment.",
|
|
120
|
+
examples: ["dss api-deployer get-deployment my-deployment",],
|
|
121
|
+
},
|
|
122
|
+
"deployment-status": {
|
|
123
|
+
handler: (c, a) => {
|
|
124
|
+
requireArgs(a, 1, "dss api-deployer deployment-status <deploymentId>");
|
|
125
|
+
return c.apiDeployer.getDeploymentStatus(a[0]);
|
|
126
|
+
},
|
|
127
|
+
usage: "dss api-deployer deployment-status <deploymentId>",
|
|
128
|
+
description: "Get an API Deployer deployment's full health/status.",
|
|
129
|
+
examples: ["dss api-deployer deployment-status my-deployment",],
|
|
130
|
+
},
|
|
131
|
+
"deployment-settings": {
|
|
132
|
+
handler: (c, a) => {
|
|
133
|
+
requireArgs(a, 1, "dss api-deployer deployment-settings <deploymentId>");
|
|
134
|
+
return c.apiDeployer.getDeploymentSettings(a[0]);
|
|
135
|
+
},
|
|
136
|
+
usage: "dss api-deployer deployment-settings <deploymentId>",
|
|
137
|
+
description: "Get an API Deployer deployment's settings.",
|
|
138
|
+
examples: ["dss api-deployer deployment-settings my-deployment",],
|
|
139
|
+
},
|
|
140
|
+
"save-deployment-settings": {
|
|
141
|
+
handler: async (c, a, f) => {
|
|
142
|
+
requireArgs(a, 1, "dss api-deployer save-deployment-settings <deploymentId> (--data JSON|--data-file PATH|--stdin)");
|
|
143
|
+
const body = requiredJsonInput(f, "--data, --data-file, or --stdin is required (deployment settings).");
|
|
144
|
+
await c.apiDeployer.saveDeploymentSettings(a[0], body);
|
|
145
|
+
return { saved: true, };
|
|
146
|
+
},
|
|
147
|
+
usage: "dss api-deployer save-deployment-settings <deploymentId> (--data JSON|--data-file PATH|--stdin)",
|
|
148
|
+
description: "Save an API Deployer deployment's settings.",
|
|
149
|
+
examples: ["dss api-deployer save-deployment-settings my-deployment --data-file settings.json",],
|
|
150
|
+
},
|
|
151
|
+
deploy: {
|
|
152
|
+
handler: (c, a) => {
|
|
153
|
+
requireArgs(a, 1, "dss api-deployer deploy <deploymentId>");
|
|
154
|
+
return c.apiDeployer.startDeploymentUpdate(a[0]);
|
|
155
|
+
},
|
|
156
|
+
usage: "dss api-deployer deploy <deploymentId>",
|
|
157
|
+
description: "Apply a deployment's settings to its infrastructure (start update).",
|
|
158
|
+
examples: ["dss api-deployer deploy my-deployment",],
|
|
159
|
+
},
|
|
160
|
+
"delete-deployment": {
|
|
161
|
+
handler: async (c, a) => {
|
|
162
|
+
requireArgs(a, 1, "dss api-deployer delete-deployment <deploymentId>");
|
|
163
|
+
await c.apiDeployer.deleteDeployment(a[0]);
|
|
164
|
+
return { deleted: true, };
|
|
165
|
+
},
|
|
166
|
+
usage: "dss api-deployer delete-deployment <deploymentId>",
|
|
167
|
+
description: "Delete an API Deployer deployment.",
|
|
168
|
+
examples: ["dss api-deployer delete-deployment my-deployment",],
|
|
169
|
+
},
|
|
170
|
+
};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { writeFileSync, } from "node:fs";
|
|
2
|
+
import { requiredJsonInput, } from "../coerce.js";
|
|
3
|
+
import { requireArgs, UsageError, } from "../usage.js";
|
|
4
|
+
export const apiServiceCommands = {
|
|
5
|
+
list: {
|
|
6
|
+
handler: (c, _a, f) => c.apiServices.list(f["project-key"]),
|
|
7
|
+
usage: "dss api-service list [--project-key KEY]",
|
|
8
|
+
description: "List API services in a project.",
|
|
9
|
+
examples: ["dss api-service list",],
|
|
10
|
+
},
|
|
11
|
+
create: {
|
|
12
|
+
handler: (c, a, f) => {
|
|
13
|
+
requireArgs(a, 1, "dss api-service create <serviceId> [--project-key KEY]");
|
|
14
|
+
return c.apiServices.create(a[0], f["project-key"]);
|
|
15
|
+
},
|
|
16
|
+
usage: "dss api-service create <serviceId> [--project-key KEY]",
|
|
17
|
+
description: "Create an empty API service.",
|
|
18
|
+
examples: ["dss api-service create my-service",],
|
|
19
|
+
},
|
|
20
|
+
"get-settings": {
|
|
21
|
+
handler: (c, a, f) => {
|
|
22
|
+
requireArgs(a, 1, "dss api-service get-settings <serviceId> [--project-key KEY]");
|
|
23
|
+
return c.apiServices.getSettings(a[0], f["project-key"]);
|
|
24
|
+
},
|
|
25
|
+
usage: "dss api-service get-settings <serviceId> [--project-key KEY]",
|
|
26
|
+
description: "Get an API service's settings (endpoint definitions).",
|
|
27
|
+
examples: ["dss api-service get-settings my-service",],
|
|
28
|
+
},
|
|
29
|
+
"save-settings": {
|
|
30
|
+
handler: (c, a, f) => {
|
|
31
|
+
requireArgs(a, 1, "dss api-service save-settings <serviceId> (--data JSON|--data-file PATH|--stdin) [--project-key KEY]");
|
|
32
|
+
const body = requiredJsonInput(f, "--data, --data-file, or --stdin is required (service settings).");
|
|
33
|
+
return c.apiServices.saveSettings(a[0], body, f["project-key"]);
|
|
34
|
+
},
|
|
35
|
+
usage: "dss api-service save-settings <serviceId> (--data JSON|--data-file PATH|--stdin) [--project-key KEY]",
|
|
36
|
+
description: "Save an API service's settings.",
|
|
37
|
+
examples: ["dss api-service save-settings my-service --data-file service.json",],
|
|
38
|
+
},
|
|
39
|
+
"list-packages": {
|
|
40
|
+
handler: async (c, a, f) => {
|
|
41
|
+
requireArgs(a, 1, "dss api-service list-packages <serviceId> [--project-key KEY]");
|
|
42
|
+
const projectKey = f["project-key"];
|
|
43
|
+
await c.apiServices.getSettings(a[0], projectKey);
|
|
44
|
+
return c.apiServices.listPackages(a[0], projectKey);
|
|
45
|
+
},
|
|
46
|
+
usage: "dss api-service list-packages <serviceId> [--project-key KEY]",
|
|
47
|
+
description: "List deployable packages of an API service.",
|
|
48
|
+
examples: ["dss api-service list-packages my-service",],
|
|
49
|
+
},
|
|
50
|
+
"package-summary": {
|
|
51
|
+
handler: (c, a, f) => {
|
|
52
|
+
requireArgs(a, 2, "dss api-service package-summary <serviceId> <packageId> [--project-key KEY]");
|
|
53
|
+
return c.apiServices.getPackageSummary(a[0], a[1], f["project-key"]);
|
|
54
|
+
},
|
|
55
|
+
usage: "dss api-service package-summary <serviceId> <packageId> [--project-key KEY]",
|
|
56
|
+
description: "Get a package summary.",
|
|
57
|
+
examples: ["dss api-service package-summary my-service v1",],
|
|
58
|
+
},
|
|
59
|
+
"create-package": {
|
|
60
|
+
handler: (c, a, f) => {
|
|
61
|
+
requireArgs(a, 2, "dss api-service create-package <serviceId> <packageId> [--project-key KEY]");
|
|
62
|
+
return c.apiServices.createPackage(a[0], a[1], f["project-key"]);
|
|
63
|
+
},
|
|
64
|
+
usage: "dss api-service create-package <serviceId> <packageId> [--project-key KEY]",
|
|
65
|
+
description: "Build a deployable package from the current service state.",
|
|
66
|
+
examples: ["dss api-service create-package my-service v1",],
|
|
67
|
+
},
|
|
68
|
+
"delete-package": {
|
|
69
|
+
handler: async (c, a, f) => {
|
|
70
|
+
requireArgs(a, 2, "dss api-service delete-package <serviceId> <packageId> [--project-key KEY]");
|
|
71
|
+
await c.apiServices.deletePackage(a[0], a[1], f["project-key"]);
|
|
72
|
+
return { deleted: true, };
|
|
73
|
+
},
|
|
74
|
+
usage: "dss api-service delete-package <serviceId> <packageId> [--project-key KEY]",
|
|
75
|
+
description: "Delete an API service package.",
|
|
76
|
+
examples: ["dss api-service delete-package my-service v1",],
|
|
77
|
+
},
|
|
78
|
+
"download-package": {
|
|
79
|
+
handler: async (c, a, f) => {
|
|
80
|
+
requireArgs(a, 2, "dss api-service download-package <serviceId> <packageId> --output PATH [--project-key KEY]");
|
|
81
|
+
const out = f["output"];
|
|
82
|
+
if (!out)
|
|
83
|
+
throw new UsageError("--output PATH is required.", "missing_required_flag");
|
|
84
|
+
const res = await c.apiServices.downloadPackageArchive(a[0], a[1], f["project-key"]);
|
|
85
|
+
const buf = Buffer.from(await res.arrayBuffer());
|
|
86
|
+
writeFileSync(out, buf);
|
|
87
|
+
return { path: out, bytes: buf.length, };
|
|
88
|
+
},
|
|
89
|
+
usage: "dss api-service download-package <serviceId> <packageId> --output PATH [--project-key KEY]",
|
|
90
|
+
description: "Download an API service package archive to a local file.",
|
|
91
|
+
examples: ["dss api-service download-package my-service v1 --output ./pkg.zip",],
|
|
92
|
+
},
|
|
93
|
+
"publish-package": {
|
|
94
|
+
handler: (c, a, f) => {
|
|
95
|
+
requireArgs(a, 2, "dss api-service publish-package <serviceId> <packageId> [--project-key KEY]");
|
|
96
|
+
return c.apiServices.publishPackage(a[0], a[1], f["project-key"]);
|
|
97
|
+
},
|
|
98
|
+
usage: "dss api-service publish-package <serviceId> <packageId> [--project-key KEY]",
|
|
99
|
+
description: "Publish a package to the API Deployer.",
|
|
100
|
+
examples: ["dss api-service publish-package my-service v1",],
|
|
101
|
+
},
|
|
102
|
+
};
|