@kora-platform/cli 0.8.0-rc2 → 0.8.0-rc6
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/api-client.d.ts +25 -21
- package/dist/api-client.js +19 -27
- package/dist/api-types.d.ts +22 -2
- package/dist/artifact-commands.js +5 -3
- package/dist/auth-commands.js +84 -8
- package/dist/cli-errors.d.ts +7 -1
- package/dist/cli-errors.js +12 -1
- package/dist/command-registry.js +40 -44
- package/dist/commands.js +65 -47
- package/dist/error-code.d.ts +2 -0
- package/dist/error-code.js +9 -0
- package/dist/extension-commands.js +2 -2
- package/dist/files.d.ts +12 -5
- package/dist/files.js +114 -26
- package/dist/format.d.ts +1 -0
- package/dist/format.js +11 -6
- package/dist/runner.js +1 -0
- package/dist/schema-registry-data.d.ts +71 -27
- package/dist/schema-registry-data.js +87 -36
- package/dist/transport.d.ts +20 -0
- package/dist/transport.js +54 -2
- package/package.json +1 -1
- package/dist/dotenv.d.ts +0 -1
- package/dist/dotenv.js +0 -26
package/dist/command-registry.js
CHANGED
|
@@ -31,6 +31,12 @@ export const CLI_ALIASES = Object.freeze({
|
|
|
31
31
|
process: ["workflow"],
|
|
32
32
|
project: ["org"],
|
|
33
33
|
});
|
|
34
|
+
const releaseReadFlag = (description, required = false) => flag("release", description, { acceptsValue: true, ...(required ? { required: true } : {}), valueType: "string" });
|
|
35
|
+
const releaseEnvironmentReadFlag = (description) => flag("environment", description, { acceptsValue: true, valueType: "string" });
|
|
36
|
+
const releaseSnapshotReadFlags = (releaseDescription, environmentDescription) => [
|
|
37
|
+
releaseReadFlag(releaseDescription),
|
|
38
|
+
releaseEnvironmentReadFlag(environmentDescription)
|
|
39
|
+
];
|
|
34
40
|
const RAW_CLI_COMMANDS = [
|
|
35
41
|
command(["help"], "Show human or machine-readable help for a command path.", {
|
|
36
42
|
labels: ["read", "chat-read", "help"],
|
|
@@ -64,13 +70,14 @@ const RAW_CLI_COMMANDS = [
|
|
|
64
70
|
command(["auth", "whoami"], "Show the current authenticated user and selected organization.", {
|
|
65
71
|
labels: ["local", "auth"]
|
|
66
72
|
}),
|
|
67
|
-
command(["auth", "login"], "
|
|
73
|
+
command(["auth", "login"], "Log in and select the active organization. Uses browser device approval with --device or when the terminal is not interactive.", {
|
|
68
74
|
labels: ["credential", "auth"],
|
|
69
75
|
flags: [
|
|
70
76
|
flag("base-url", "Platform base URL for this login.", {
|
|
71
77
|
acceptsValue: true,
|
|
72
78
|
valueType: "string"
|
|
73
|
-
})
|
|
79
|
+
}),
|
|
80
|
+
flag("device", "Use the browser device-approval flow instead of interactive email/password login.")
|
|
74
81
|
]
|
|
75
82
|
}),
|
|
76
83
|
command(["auth", "signup"], "Create a local account and start a CLI session.", {
|
|
@@ -182,52 +189,37 @@ const RAW_CLI_COMMANDS = [
|
|
|
182
189
|
labels: ["read", "activity", "chat-read"],
|
|
183
190
|
requiresActiveOrg: true
|
|
184
191
|
}),
|
|
185
|
-
command(["workflow", "list"], "List workflows.", {
|
|
186
|
-
labels: ["read", "workflow"],
|
|
187
|
-
|
|
188
|
-
flags:
|
|
189
|
-
acceptsValue: true,
|
|
190
|
-
valueType: "string"
|
|
191
|
-
})],
|
|
192
|
+
command(["workflow", "list"], "List live deployed workflows, filter live deployments with --environment, or list workflows from a release with --release.", {
|
|
193
|
+
labels: ["read", "workflow"], aliases: [["process", "list"]],
|
|
194
|
+
examples: ["kora workflow list", "kora workflow list --environment <environment>", "kora workflow list --release <release>"],
|
|
195
|
+
flags: releaseSnapshotReadFlags("Read workflows from an immutable release instead of live deployments.", "Filter live deployed workflows to one environment's live deployment."),
|
|
192
196
|
requiresActiveOrg: true
|
|
193
197
|
}),
|
|
194
198
|
command(["workflow", "get"], "Show workflow detail.", {
|
|
195
199
|
labels: ["read", "workflow"],
|
|
196
200
|
aliases: [["process", "get"]],
|
|
197
201
|
args: [arg("name", "Workflow name.")],
|
|
198
|
-
flags:
|
|
199
|
-
acceptsValue: true,
|
|
200
|
-
valueType: "string"
|
|
201
|
-
})],
|
|
202
|
+
flags: releaseSnapshotReadFlags("Read workflow detail from a release.", "Read workflow detail from an environment's live deployment release."),
|
|
202
203
|
requiresActiveOrg: true
|
|
203
204
|
}),
|
|
204
205
|
command(["workflow", "version", "get"], "Show one workflow version.", {
|
|
205
206
|
labels: ["read", "workflow"],
|
|
206
207
|
aliases: [["process", "version", "get"]],
|
|
207
208
|
args: [arg("name", "Workflow name."), arg("version", "Workflow version.")],
|
|
208
|
-
flags:
|
|
209
|
-
acceptsValue: true,
|
|
210
|
-
valueType: "string"
|
|
211
|
-
})],
|
|
209
|
+
flags: releaseSnapshotReadFlags("Read workflow version from a release.", "Read workflow version from an environment's live deployment release."),
|
|
212
210
|
requiresActiveOrg: true
|
|
213
211
|
}),
|
|
214
212
|
command(["workflow", "dependencies"], "Show workflow dependency detail.", {
|
|
215
213
|
labels: ["read", "workflow"],
|
|
216
214
|
aliases: [["process", "dependencies"]],
|
|
217
215
|
args: [arg("name", "Workflow name."), arg("version", "Workflow version.")],
|
|
218
|
-
flags:
|
|
219
|
-
acceptsValue: true,
|
|
220
|
-
valueType: "string"
|
|
221
|
-
})],
|
|
216
|
+
flags: releaseSnapshotReadFlags("Read workflow dependencies from a release.", "Read workflow dependencies from an environment's live deployment release."),
|
|
222
217
|
requiresActiveOrg: true
|
|
223
218
|
}),
|
|
224
219
|
command(["workflow", "context"], "Show workflow inspection context.", {
|
|
225
220
|
labels: ["read", "workflow"],
|
|
226
221
|
aliases: [["process", "context"]],
|
|
227
|
-
flags:
|
|
228
|
-
acceptsValue: true,
|
|
229
|
-
valueType: "string"
|
|
230
|
-
})],
|
|
222
|
+
flags: releaseSnapshotReadFlags("Read workflow context from a release.", "Read workflow context from an environment's live deployment release."),
|
|
231
223
|
requiresActiveOrg: true
|
|
232
224
|
}),
|
|
233
225
|
command(["workflow", "start"], "Start a workflow.", {
|
|
@@ -294,10 +286,7 @@ const RAW_CLI_COMMANDS = [
|
|
|
294
286
|
command(["release", "create"], "Create an immutable release artifact from source files; this mutates Platform state and is not a test command.", {
|
|
295
287
|
labels: ["write", "chat-write", "release"],
|
|
296
288
|
args: [arg("workspace", "Path to the source folder or zip archive.")],
|
|
297
|
-
flags: [
|
|
298
|
-
acceptsValue: true,
|
|
299
|
-
valueType: "string"
|
|
300
|
-
})],
|
|
289
|
+
flags: [],
|
|
301
290
|
requiresActiveOrg: true
|
|
302
291
|
}),
|
|
303
292
|
command(["release", "validate"], "Validate release readiness without deploying.", {
|
|
@@ -701,51 +690,68 @@ const RAW_CLI_COMMANDS = [
|
|
|
701
690
|
requiresActiveOrg: true
|
|
702
691
|
}),
|
|
703
692
|
command(["org-model", "people", "list"], "List modeled people.", {
|
|
693
|
+
flags: releaseSnapshotReadFlags("Read modeled people from a release.", "Read modeled people from an environment's live deployment release."),
|
|
704
694
|
labels: ["read", "org-model"], requiresActiveOrg: true
|
|
705
695
|
}),
|
|
706
696
|
command(["org-model", "people", "get"], "Show one modeled person.", {
|
|
707
697
|
labels: ["read", "org-model"],
|
|
708
698
|
args: [arg("name", "Person name.")],
|
|
699
|
+
flags: releaseSnapshotReadFlags("Read modeled person detail from a release.", "Read modeled person detail from an environment's live deployment release."),
|
|
709
700
|
requiresActiveOrg: true
|
|
710
701
|
}),
|
|
711
702
|
command(["org-model", "agents", "list"], "List modeled agents.", {
|
|
712
|
-
|
|
703
|
+
flags: releaseSnapshotReadFlags("Read modeled agents from a release.", "Read modeled agents from an environment's live deployment release."),
|
|
704
|
+
labels: ["read", "org-model"],
|
|
705
|
+
requiresActiveOrg: true
|
|
713
706
|
}),
|
|
714
707
|
command(["org-model", "agents", "get"], "Show one modeled agent.", {
|
|
715
708
|
labels: ["read", "org-model"],
|
|
716
709
|
args: [arg("name", "Agent name.")],
|
|
710
|
+
flags: releaseSnapshotReadFlags("Read modeled agent detail from a release.", "Read modeled agent detail from an environment's live deployment release."),
|
|
717
711
|
requiresActiveOrg: true
|
|
718
712
|
}),
|
|
719
713
|
command(["org-model", "roles", "list"], "List modeled roles.", {
|
|
720
|
-
|
|
714
|
+
flags: releaseSnapshotReadFlags("Read modeled roles from a release.", "Read modeled roles from an environment's live deployment release."),
|
|
715
|
+
labels: ["read", "org-model"],
|
|
716
|
+
requiresActiveOrg: true
|
|
721
717
|
}),
|
|
722
718
|
command(["org-model", "roles", "get"], "Show one modeled role.", {
|
|
723
719
|
labels: ["read", "org-model"],
|
|
724
720
|
args: [arg("name", "Role name.")],
|
|
721
|
+
flags: releaseSnapshotReadFlags("Read modeled role detail from a release.", "Read modeled role detail from an environment's live deployment release."),
|
|
725
722
|
requiresActiveOrg: true
|
|
726
723
|
}),
|
|
727
724
|
command(["org-model", "assignments", "list"], "List modeled assignments.", {
|
|
728
|
-
|
|
725
|
+
flags: releaseSnapshotReadFlags("Read modeled assignments from a release.", "Read modeled assignments from an environment's live deployment release."),
|
|
726
|
+
labels: ["read", "org-model"],
|
|
727
|
+
requiresActiveOrg: true
|
|
729
728
|
}),
|
|
730
729
|
command(["org-model", "assignments", "get"], "Show one modeled assignment group by role.", {
|
|
731
730
|
labels: ["read", "org-model"],
|
|
732
731
|
args: [arg("role-name", "Role name.")],
|
|
732
|
+
flags: releaseSnapshotReadFlags("Read modeled assignment detail from a release.", "Read modeled assignment detail from an environment's live deployment release."),
|
|
733
733
|
requiresActiveOrg: true
|
|
734
734
|
}),
|
|
735
735
|
command(["org-model", "capabilities", "list"], "List capabilities.", {
|
|
736
|
-
|
|
736
|
+
flags: releaseSnapshotReadFlags("Read capabilities from a release.", "Read capabilities from an environment's live deployment release."),
|
|
737
|
+
labels: ["read", "org-model"],
|
|
738
|
+
requiresActiveOrg: true
|
|
737
739
|
}),
|
|
738
740
|
command(["org-model", "capabilities", "get"], "Show one capability.", {
|
|
739
741
|
labels: ["read", "org-model"],
|
|
740
742
|
args: [arg("name", "Capability name.")],
|
|
743
|
+
flags: releaseSnapshotReadFlags("Read capability detail from a release.", "Read capability detail from an environment's live deployment release."),
|
|
741
744
|
requiresActiveOrg: true
|
|
742
745
|
}),
|
|
743
746
|
command(["org-model", "operations", "list"], "List operations.", {
|
|
744
|
-
|
|
747
|
+
flags: releaseSnapshotReadFlags("Read operations from a release.", "Read operations from an environment's live deployment release."),
|
|
748
|
+
labels: ["read", "org-model"],
|
|
749
|
+
requiresActiveOrg: true
|
|
745
750
|
}),
|
|
746
751
|
command(["org-model", "operations", "get"], "Show one operation.", {
|
|
747
752
|
labels: ["read", "org-model"],
|
|
748
753
|
args: [arg("name", "Operation name.")],
|
|
754
|
+
flags: releaseSnapshotReadFlags("Read operation detail from a release.", "Read operation detail from an environment's live deployment release."),
|
|
749
755
|
requiresActiveOrg: true
|
|
750
756
|
}),
|
|
751
757
|
command(["access", "members", "list"], "List organization members.", {
|
|
@@ -1119,16 +1125,6 @@ const RAW_CLI_COMMANDS = [
|
|
|
1119
1125
|
],
|
|
1120
1126
|
requiresActiveOrg: true
|
|
1121
1127
|
}),
|
|
1122
|
-
command(["env", "import"], "Import runtime variables from a .env file.", {
|
|
1123
|
-
labels: ["write", "env"],
|
|
1124
|
-
args: [arg("path-to-.env", "Path to a .env file.")],
|
|
1125
|
-
flags: [flag("environment", "Target environment.", {
|
|
1126
|
-
acceptsValue: true,
|
|
1127
|
-
required: true,
|
|
1128
|
-
valueType: "string"
|
|
1129
|
-
})],
|
|
1130
|
-
requiresActiveOrg: true
|
|
1131
|
-
}),
|
|
1132
1128
|
command(["secrets", "list"], "List organization secret names without values.", {
|
|
1133
1129
|
labels: ["read", "secret"],
|
|
1134
1130
|
flags: [flag("environment", "Target environment.", {
|
package/dist/commands.js
CHANGED
|
@@ -6,7 +6,7 @@ import { authProblem, genericProblem, notFoundProblem, usageProblem } from "./cl
|
|
|
6
6
|
import { readOptionalNumberFlag, readOptionalStringFlag, readRequiredStringFlag } from "./command-flags.js";
|
|
7
7
|
import { executeArtifactDownload, executeArtifactArchive, executeArtifactInspect, executeArtifactInventory, executeArtifactList, executeArtifactPurge, executeArtifactRead, executeArtifactRestore, executeArtifactUpload } from "./artifact-commands.js";
|
|
8
8
|
import { executeAudit } from "./audit-commands.js";
|
|
9
|
-
import { isZipArchivePath, readArchiveBytes, readImportEntries, readJsonInputSpecifier, readWorkspaceTestEntries, readTextInputSpecifier,
|
|
9
|
+
import { isZipArchivePath, readArchiveBytes, readImportEntries, readJsonInputSpecifier, readWorkspaceTestEntries, readTextInputSpecifier, writeReleaseSourceFiles } from "./files.js";
|
|
10
10
|
import { renderDiffSummary, renderKeyValue, renderPrettyJson, renderSuccess, renderTable } from "./format.js";
|
|
11
11
|
import { buildTaskDetailPresentation } from "./task-detail.js";
|
|
12
12
|
import { confirmDestructive } from "./interaction.js";
|
|
@@ -165,7 +165,6 @@ export async function executeParsedCommand(parsed, context) {
|
|
|
165
165
|
case "env.list":
|
|
166
166
|
case "env.get":
|
|
167
167
|
case "env.replace":
|
|
168
|
-
case "env.import":
|
|
169
168
|
return executeEnv(parsed, context, api);
|
|
170
169
|
case "secrets.list":
|
|
171
170
|
case "secrets.set":
|
|
@@ -422,58 +421,98 @@ async function executeActivityOptions(parsed, context, api) {
|
|
|
422
421
|
meta: { command: "activity options", orgId: org.id }
|
|
423
422
|
};
|
|
424
423
|
}
|
|
424
|
+
function readOptionalReleaseSnapshotSelector(parsed) {
|
|
425
|
+
const releaseId = readOptionalStringFlag(parsed, "release");
|
|
426
|
+
const environment = readCliEnvironmentFlag(parsed);
|
|
427
|
+
if (releaseId && environment) {
|
|
428
|
+
throw usageProblem("Use either --release or --environment, not both.", parsed.definition.id);
|
|
429
|
+
}
|
|
430
|
+
if (releaseId) {
|
|
431
|
+
return { releaseId };
|
|
432
|
+
}
|
|
433
|
+
if (environment) {
|
|
434
|
+
return { environment };
|
|
435
|
+
}
|
|
436
|
+
return undefined;
|
|
437
|
+
}
|
|
438
|
+
function readRequiredReleaseSnapshotSelector(parsed) {
|
|
439
|
+
const selector = readOptionalReleaseSnapshotSelector(parsed);
|
|
440
|
+
if (!selector) {
|
|
441
|
+
throw usageProblem("Provide either --release or --environment.", parsed.definition.id);
|
|
442
|
+
}
|
|
443
|
+
return selector;
|
|
444
|
+
}
|
|
445
|
+
function releaseSnapshotSelectorMeta(selector) {
|
|
446
|
+
if (!selector) {
|
|
447
|
+
return {};
|
|
448
|
+
}
|
|
449
|
+
if (typeof selector.releaseId === "string") {
|
|
450
|
+
return { releaseId: selector.releaseId };
|
|
451
|
+
}
|
|
452
|
+
if (typeof selector.environment === "string") {
|
|
453
|
+
return { environment: selector.environment };
|
|
454
|
+
}
|
|
455
|
+
return {};
|
|
456
|
+
}
|
|
425
457
|
async function executeWorkflowList(parsed, context, api) {
|
|
426
458
|
const { org, session } = await resolveOrgScope(parsed, context, api);
|
|
427
|
-
const
|
|
459
|
+
const selector = readOptionalReleaseSnapshotSelector(parsed);
|
|
460
|
+
const data = await api.listWorkflows(session, org.id, selector ?? { live: true });
|
|
428
461
|
return {
|
|
429
462
|
data,
|
|
430
463
|
human: renderTable(data.processes, [
|
|
431
464
|
{ key: "name", label: "Name" },
|
|
465
|
+
{ key: "environmentKey", label: "Environment" },
|
|
466
|
+
{ key: "liveReleaseId", label: "Live release" },
|
|
432
467
|
{ key: "latestVersion", label: "Latest" },
|
|
433
468
|
{ key: "deployedVersion", label: "Deployed" }
|
|
434
469
|
]),
|
|
435
470
|
kind: "authoring_workflow_list",
|
|
436
|
-
meta: { command: "workflow list", orgId: org.id }
|
|
471
|
+
meta: { command: "workflow list", orgId: org.id, ...releaseSnapshotSelectorMeta(selector) }
|
|
437
472
|
};
|
|
438
473
|
}
|
|
439
474
|
async function executeWorkflowGet(parsed, context, api) {
|
|
440
475
|
const { org, session } = await resolveOrgScope(parsed, context, api);
|
|
441
|
-
const
|
|
476
|
+
const selector = readRequiredReleaseSnapshotSelector(parsed);
|
|
477
|
+
const data = await api.getWorkflow(session, org.id, readRequiredArg(parsed, "name"), selector);
|
|
442
478
|
return {
|
|
443
479
|
data,
|
|
444
480
|
human: renderPrettyJson(data.process),
|
|
445
481
|
kind: "authoring_workflow_get",
|
|
446
|
-
meta: { command: "workflow get", orgId: org.id }
|
|
482
|
+
meta: { command: "workflow get", orgId: org.id, ...releaseSnapshotSelectorMeta(selector) }
|
|
447
483
|
};
|
|
448
484
|
}
|
|
449
485
|
async function executeWorkflowVersionGet(parsed, context, api) {
|
|
450
486
|
const { org, session } = await resolveOrgScope(parsed, context, api);
|
|
451
|
-
const
|
|
487
|
+
const selector = readRequiredReleaseSnapshotSelector(parsed);
|
|
488
|
+
const data = await api.getWorkflowVersion(session, org.id, readRequiredArg(parsed, "name"), readRequiredIntegerArg(parsed, "version"), selector);
|
|
452
489
|
return {
|
|
453
490
|
data,
|
|
454
491
|
human: renderPrettyJson(data.process),
|
|
455
492
|
kind: "authoring_workflow_version_get",
|
|
456
|
-
meta: { command: "workflow version get", orgId: org.id }
|
|
493
|
+
meta: { command: "workflow version get", orgId: org.id, ...releaseSnapshotSelectorMeta(selector) }
|
|
457
494
|
};
|
|
458
495
|
}
|
|
459
496
|
async function executeWorkflowDependencies(parsed, context, api) {
|
|
460
497
|
const { org, session } = await resolveOrgScope(parsed, context, api);
|
|
461
|
-
const
|
|
498
|
+
const selector = readRequiredReleaseSnapshotSelector(parsed);
|
|
499
|
+
const data = await api.getWorkflowDependencies(session, org.id, readRequiredArg(parsed, "name"), readRequiredIntegerArg(parsed, "version"), selector);
|
|
462
500
|
return {
|
|
463
501
|
data,
|
|
464
502
|
human: renderPrettyJson(data.dependencies),
|
|
465
503
|
kind: "authoring_workflow_dependencies",
|
|
466
|
-
meta: { command: "workflow dependencies", orgId: org.id }
|
|
504
|
+
meta: { command: "workflow dependencies", orgId: org.id, ...releaseSnapshotSelectorMeta(selector) }
|
|
467
505
|
};
|
|
468
506
|
}
|
|
469
507
|
async function executeWorkflowContext(parsed, context, api) {
|
|
470
508
|
const { org, session } = await resolveOrgScope(parsed, context, api);
|
|
471
|
-
const
|
|
509
|
+
const selector = readRequiredReleaseSnapshotSelector(parsed);
|
|
510
|
+
const data = await api.getWorkflowContext(session, org.id, selector);
|
|
472
511
|
return {
|
|
473
512
|
data,
|
|
474
513
|
human: renderPrettyJson(data.context),
|
|
475
514
|
kind: "authoring_workflow_context",
|
|
476
|
-
meta: { command: "workflow context", orgId: org.id }
|
|
515
|
+
meta: { command: "workflow context", orgId: org.id, ...releaseSnapshotSelectorMeta(selector) }
|
|
477
516
|
};
|
|
478
517
|
}
|
|
479
518
|
async function executeWorkflowStart(parsed, context, api) {
|
|
@@ -484,7 +523,7 @@ async function executeWorkflowStart(parsed, context, api) {
|
|
|
484
523
|
}
|
|
485
524
|
const inputSpecifier = readOptionalStringFlag(parsed, "input");
|
|
486
525
|
const inputData = inputSpecifier
|
|
487
|
-
? await readJsonInputSpecifier(inputSpecifier, context.stdin, "workflow start")
|
|
526
|
+
? await readJsonInputSpecifier(inputSpecifier, context.stdin, "workflow start", { flag: "input" })
|
|
488
527
|
: undefined;
|
|
489
528
|
const workflowName = readRequiredArg(parsed, "name");
|
|
490
529
|
const resolvedEnvironment = resolveCliEnvironment(parsed, session);
|
|
@@ -514,7 +553,7 @@ async function executeWorkflowNodeTest(parsed, context, api) {
|
|
|
514
553
|
const environment = readOptionalStringFlag(parsed, "environment");
|
|
515
554
|
const inputSpecifier = readOptionalStringFlag(parsed, "input");
|
|
516
555
|
const inputData = inputSpecifier
|
|
517
|
-
? await readJsonInputSpecifier(inputSpecifier, context.stdin, "test node")
|
|
556
|
+
? await readJsonInputSpecifier(inputSpecifier, context.stdin, "test node", { flag: "input" })
|
|
518
557
|
: undefined;
|
|
519
558
|
const data = await api.testWorkflowNode(session, org.id, workflowName, nodeId, {
|
|
520
559
|
...(environment ? { environment } : {}),
|
|
@@ -646,11 +685,8 @@ async function executeReleaseSource(parsed, context, api) {
|
|
|
646
685
|
async function executeReleaseCreate(parsed, context, api) {
|
|
647
686
|
const { org, session } = await resolveOrgScope(parsed, context, api);
|
|
648
687
|
const workspacePath = readRequiredArg(parsed, "workspace");
|
|
649
|
-
const label = readOptionalStringFlag(parsed, "label");
|
|
650
688
|
if (isZipArchivePath(workspacePath)) {
|
|
651
|
-
const data = await api.createReleaseArchive(session, org.id, await readArchiveBytes(workspacePath, "release create")
|
|
652
|
-
...(label ? { label } : {})
|
|
653
|
-
});
|
|
689
|
+
const data = await api.createReleaseArchive(session, org.id, await readArchiveBytes(workspacePath, "release create"));
|
|
654
690
|
const summary = summarizeReleaseCreation(data.created.release.id);
|
|
655
691
|
return {
|
|
656
692
|
data,
|
|
@@ -661,8 +697,7 @@ async function executeReleaseCreate(parsed, context, api) {
|
|
|
661
697
|
}
|
|
662
698
|
const files = await readImportEntries(workspacePath);
|
|
663
699
|
const data = await api.createRelease(session, org.id, {
|
|
664
|
-
files
|
|
665
|
-
...(label ? { label } : {})
|
|
700
|
+
files
|
|
666
701
|
});
|
|
667
702
|
const summary = summarizeReleaseCreation(data.created.release.id);
|
|
668
703
|
return {
|
|
@@ -703,7 +738,7 @@ async function executeEnvironment(parsed, context, api) {
|
|
|
703
738
|
const data = await api.getEnvironment(session, org.id, readRequiredArg(parsed, "environment"));
|
|
704
739
|
return {
|
|
705
740
|
data,
|
|
706
|
-
human: renderPrettyJson(data
|
|
741
|
+
human: renderPrettyJson(data),
|
|
707
742
|
kind: "environment_get",
|
|
708
743
|
meta: { command: "environment get", orgId: org.id }
|
|
709
744
|
};
|
|
@@ -943,7 +978,7 @@ async function executeTaskGet(parsed, context, api) {
|
|
|
943
978
|
}
|
|
944
979
|
async function executeTaskComplete(parsed, context, api) {
|
|
945
980
|
const { org, session } = await resolveOrgScope(parsed, context, api);
|
|
946
|
-
const outputData = await readJsonInputSpecifier(String(parsed.flags.output), context.stdin, "task complete");
|
|
981
|
+
const outputData = await readJsonInputSpecifier(String(parsed.flags.output), context.stdin, "task complete", { flag: "output" });
|
|
947
982
|
const data = await api.completeTask(session, org.id, readRequiredArg(parsed, "task-id"), {
|
|
948
983
|
outputData,
|
|
949
984
|
workflowId: String(parsed.flags.run)
|
|
@@ -959,8 +994,9 @@ async function executeOrgModel(parsed, context, api) {
|
|
|
959
994
|
const { org, session } = await resolveOrgScope(parsed, context, api);
|
|
960
995
|
const section = parsed.definition.path[1] ?? "";
|
|
961
996
|
const verb = parsed.definition.path[2] ?? "";
|
|
997
|
+
const selector = readRequiredReleaseSnapshotSelector(parsed);
|
|
962
998
|
if (section === "operations") {
|
|
963
|
-
const editor = (await api.getOperationsEditor(session, org.id)).editor;
|
|
999
|
+
const editor = (await api.getOperationsEditor(session, org.id, selector)).editor;
|
|
964
1000
|
const record = verb === "get"
|
|
965
1001
|
? requireFound(editor.operations.find((entry) => entry.name === parsed.args.name), `Operation '${parsed.args.name}' was not found.`, parsed.definition.id)
|
|
966
1002
|
: undefined;
|
|
@@ -973,17 +1009,17 @@ async function executeOrgModel(parsed, context, api) {
|
|
|
973
1009
|
{ key: "command", label: "Command" }
|
|
974
1010
|
]),
|
|
975
1011
|
kind: `authoring_${sanitizeKind(section)}_${verb}`,
|
|
976
|
-
meta: { command: parsed.definition.path.join(" "), orgId: org.id }
|
|
1012
|
+
meta: { command: parsed.definition.path.join(" "), orgId: org.id, ...releaseSnapshotSelectorMeta(selector) }
|
|
977
1013
|
};
|
|
978
1014
|
}
|
|
979
|
-
const management = (await api.getOrganizationManagementContext(session, org.id)).context;
|
|
1015
|
+
const management = (await api.getOrganizationManagementContext(session, org.id, selector)).context;
|
|
980
1016
|
if (section === "capabilities" && verb === "get") {
|
|
981
|
-
const detail = await api.getCapabilityEditor(session, org.id, readRequiredArg(parsed, "name"));
|
|
1017
|
+
const detail = await api.getCapabilityEditor(session, org.id, readRequiredArg(parsed, "name"), selector);
|
|
982
1018
|
return {
|
|
983
1019
|
data: detail,
|
|
984
1020
|
human: renderPrettyJson(detail.editor),
|
|
985
1021
|
kind: "authoring_capabilities_get",
|
|
986
|
-
meta: { command: parsed.definition.path.join(" "), orgId: org.id }
|
|
1022
|
+
meta: { command: parsed.definition.path.join(" "), orgId: org.id, ...releaseSnapshotSelectorMeta(selector) }
|
|
987
1023
|
};
|
|
988
1024
|
}
|
|
989
1025
|
const selection = selectOrgModelSection(management, section, verb === "get" ? parsed.args[section === "assignments" ? "role-name" : "name"] : undefined);
|
|
@@ -991,7 +1027,7 @@ async function executeOrgModel(parsed, context, api) {
|
|
|
991
1027
|
data: selection.data,
|
|
992
1028
|
human: selection.human,
|
|
993
1029
|
kind: `authoring_${sanitizeKind(section)}_${verb}`,
|
|
994
|
-
meta: { command: parsed.definition.path.join(" "), orgId: org.id }
|
|
1030
|
+
meta: { command: parsed.definition.path.join(" "), orgId: org.id, ...releaseSnapshotSelectorMeta(selector) }
|
|
995
1031
|
};
|
|
996
1032
|
}
|
|
997
1033
|
async function executeAccess(parsed, context, api) {
|
|
@@ -1190,7 +1226,7 @@ async function executeEnv(parsed, context, api) {
|
|
|
1190
1226
|
}
|
|
1191
1227
|
case "env.replace": {
|
|
1192
1228
|
const environment = readRequiredCliEnvironmentFlag(parsed);
|
|
1193
|
-
const body = await readJsonInputSpecifier(String(parsed.flags.file), context.stdin, parsed.definition.id);
|
|
1229
|
+
const body = await readJsonInputSpecifier(String(parsed.flags.file), context.stdin, parsed.definition.id, { flag: "file" });
|
|
1194
1230
|
const rawVariables = body.variables;
|
|
1195
1231
|
if (!Array.isArray(rawVariables)) {
|
|
1196
1232
|
throw usageProblem("Environment replace payload must contain a variables array.", parsed.definition.id);
|
|
@@ -1224,24 +1260,6 @@ async function executeEnv(parsed, context, api) {
|
|
|
1224
1260
|
meta: { command: parsed.definition.path.join(" "), environment, orgId: org.id }
|
|
1225
1261
|
};
|
|
1226
1262
|
}
|
|
1227
|
-
case "env.import": {
|
|
1228
|
-
const environment = readRequiredCliEnvironmentFlag(parsed);
|
|
1229
|
-
const filePath = readRequiredArg(parsed, "path-to-.env");
|
|
1230
|
-
const content = await readTextInputSpecifier(`@${filePath}`, context.stdin, parsed.definition.id);
|
|
1231
|
-
const preview = await parseEnvFile(filePath);
|
|
1232
|
-
announceResolvedEnvironment(parsed, context, environment);
|
|
1233
|
-
const data = await api.importRuntimeVariables(session, org.id, {
|
|
1234
|
-
content,
|
|
1235
|
-
environment,
|
|
1236
|
-
fileName: filePath
|
|
1237
|
-
});
|
|
1238
|
-
return {
|
|
1239
|
-
data,
|
|
1240
|
-
human: renderSuccess(`Imported ${data.importedCount} variables from ${filePath} into ${environment}. Parsed ${preview.length}.`),
|
|
1241
|
-
kind: "authoring_env_import",
|
|
1242
|
-
meta: { command: parsed.definition.path.join(" "), environment, orgId: org.id }
|
|
1243
|
-
};
|
|
1244
|
-
}
|
|
1245
1263
|
default:
|
|
1246
1264
|
throw genericProblem(`Unhandled env command ${parsed.definition.id}.`, parsed.definition.id);
|
|
1247
1265
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const PUBLIC_ERROR_CODE_PATTERN = /^[a-z][a-z0-9_]*(?:\/[a-z][a-z0-9_]*)?$/u;
|
|
2
|
+
export function normalizePublicErrorCode(code) {
|
|
3
|
+
return PUBLIC_ERROR_CODE_PATTERN.test(code) ? code : "internal/error";
|
|
4
|
+
}
|
|
5
|
+
export function readPublicErrorCodeFromType(type) {
|
|
6
|
+
return type.startsWith("https://errors.kora.dev/")
|
|
7
|
+
? type.slice("https://errors.kora.dev/".length)
|
|
8
|
+
: "internal/error";
|
|
9
|
+
}
|
|
@@ -395,11 +395,11 @@ async function readOptionalPermissions(parsed, context) {
|
|
|
395
395
|
if (!specifier) {
|
|
396
396
|
return undefined;
|
|
397
397
|
}
|
|
398
|
-
return normalizePermissions(await readJsonInputSpecifier(specifier, context.stdin, parsed.definition.id), parsed.definition.id);
|
|
398
|
+
return normalizePermissions(await readJsonInputSpecifier(specifier, context.stdin, parsed.definition.id, { flag: "permissions" }), parsed.definition.id);
|
|
399
399
|
}
|
|
400
400
|
async function readRequiredPermissions(parsed, context) {
|
|
401
401
|
const specifier = readRequiredStringFlag(parsed, "permissions");
|
|
402
|
-
return normalizePermissions(await readJsonInputSpecifier(specifier, context.stdin, parsed.definition.id), parsed.definition.id);
|
|
402
|
+
return normalizePermissions(await readJsonInputSpecifier(specifier, context.stdin, parsed.definition.id, { flag: "permissions" }), parsed.definition.id);
|
|
403
403
|
}
|
|
404
404
|
function normalizePermissions(input, instance) {
|
|
405
405
|
const permissions = input.grantedPermissions && isRecord(input.grantedPermissions)
|
package/dist/files.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import { Buffer } from "node:buffer";
|
|
1
2
|
import type { Readable } from "node:stream";
|
|
2
|
-
|
|
3
|
+
interface ReadStructuredInputOptions {
|
|
4
|
+
flag?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function readJsonInputSpecifier(specifier: string, stdin: Readable, instance: string, options?: ReadStructuredInputOptions): Promise<Record<string, unknown>>;
|
|
3
7
|
export declare function readTextInputSpecifier(specifier: string, stdin: Readable, instance: string): Promise<string>;
|
|
4
8
|
export declare function readImportEntries(pathValue: string): Promise<Array<{
|
|
5
9
|
content: string;
|
|
@@ -7,6 +11,12 @@ export declare function readImportEntries(pathValue: string): Promise<Array<{
|
|
|
7
11
|
}>>;
|
|
8
12
|
export declare function isZipArchivePath(pathValue: string): boolean;
|
|
9
13
|
export declare function readArchiveBytes(pathValue: string, instance: string): Promise<Uint8Array>;
|
|
14
|
+
export declare function readLocalFileBytes(pathValue: string, instance: string, options?: {
|
|
15
|
+
regularFileMessage?: string;
|
|
16
|
+
}): Promise<{
|
|
17
|
+
absolutePath: string;
|
|
18
|
+
bytes: Buffer;
|
|
19
|
+
}>;
|
|
10
20
|
export declare function readWorkspaceTestEntries(pathValue: string): Promise<Array<{
|
|
11
21
|
content: string;
|
|
12
22
|
path: string;
|
|
@@ -38,7 +48,4 @@ export declare function readPackageFileEntries(pathValue: string, instance: stri
|
|
|
38
48
|
contentBase64: string;
|
|
39
49
|
path: string;
|
|
40
50
|
}>>;
|
|
41
|
-
export
|
|
42
|
-
name: string;
|
|
43
|
-
value: string;
|
|
44
|
-
}>>;
|
|
51
|
+
export {};
|