@kora-platform/cli 0.7.0-rc1 → 0.8.0-rc10

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 (49) hide show
  1. package/README.md +21 -0
  2. package/dist/api-client.d.ts +274 -106
  3. package/dist/api-client.js +192 -167
  4. package/dist/api-types.d.ts +301 -163
  5. package/dist/artifact-api-client.d.ts +28 -1
  6. package/dist/artifact-api-client.js +33 -0
  7. package/dist/artifact-commands.d.ts +5 -0
  8. package/dist/artifact-commands.js +177 -4
  9. package/dist/audit-commands.d.ts +12 -0
  10. package/dist/audit-commands.js +74 -0
  11. package/dist/auth-commands.d.ts +1 -0
  12. package/dist/auth-commands.js +195 -32
  13. package/dist/cli-errors.d.ts +7 -1
  14. package/dist/cli-errors.js +12 -1
  15. package/dist/command-builders.d.ts +1 -0
  16. package/dist/command-builders.js +1 -0
  17. package/dist/command-flags.d.ts +1 -0
  18. package/dist/command-flags.js +7 -0
  19. package/dist/command-groups.js +10 -12
  20. package/dist/command-registry.js +595 -277
  21. package/dist/commands.js +728 -636
  22. package/dist/environment-context.d.ts +9 -0
  23. package/dist/environment-context.js +32 -0
  24. package/dist/error-code.d.ts +2 -0
  25. package/dist/error-code.js +9 -0
  26. package/dist/{integration-commands.d.ts → extension-commands.d.ts} +3 -2
  27. package/dist/extension-commands.js +446 -0
  28. package/dist/files.d.ts +44 -4
  29. package/dist/files.js +349 -26
  30. package/dist/format.d.ts +6 -0
  31. package/dist/format.js +83 -1
  32. package/dist/runner.js +28 -10
  33. package/dist/schema-registry-data.d.ts +318 -571
  34. package/dist/schema-registry-data.js +356 -698
  35. package/dist/session-store.js +80 -0
  36. package/dist/session.d.ts +1 -0
  37. package/dist/transport-refresh.d.ts +10 -0
  38. package/dist/transport-refresh.js +51 -0
  39. package/dist/transport.d.ts +31 -0
  40. package/dist/transport.js +102 -36
  41. package/dist/types.d.ts +2 -1
  42. package/dist/workspace-source.d.ts +1 -0
  43. package/dist/workspace-source.js +13 -0
  44. package/package.json +2 -1
  45. package/dist/dotenv.d.ts +0 -1
  46. package/dist/dotenv.js +0 -26
  47. package/dist/integration-api-client.d.ts +0 -29
  48. package/dist/integration-api-client.js +0 -50
  49. package/dist/integration-commands.js +0 -208
@@ -1,208 +0,0 @@
1
- import { shouldAutoOpenBrowser, openBrowser } from "./browser.js";
2
- import { genericProblem, notFoundProblem, usageProblem } from "./cli-errors.js";
3
- import { readOptionalStringFlag } from "./command-flags.js";
4
- import { readJsonInputSpecifier } from "./files.js";
5
- import { renderPrettyJson, renderTable } from "./format.js";
6
- import { createPlatformIntegrationApiClient } from "./integration-api-client.js";
7
- import { isInteractive } from "./prompts.js";
8
- export async function executeIntegrations(parsed, context, api, resolveOrgScope) {
9
- const { org, session } = await resolveOrgScope(parsed, context, api);
10
- const integrationApi = createPlatformIntegrationApiClient({
11
- sessionStore: context.sessionStore
12
- });
13
- switch (parsed.definition.id) {
14
- case "integrations.list": {
15
- const data = redactIntegrationCliOutput(await integrationApi.listManagedIntegrations(session, org.id));
16
- return {
17
- data,
18
- human: renderTable(data.integrations, [
19
- { key: "id", label: "Integration" },
20
- { key: "displayName", label: "Name" },
21
- { key: "description", label: "Description" }
22
- ]),
23
- kind: "integrations_list",
24
- meta: { command: parsed.definition.path.join(" "), orgId: org.id }
25
- };
26
- }
27
- case "integrations.diagnostics": {
28
- const data = redactIntegrationCliOutput(await integrationApi.listManagedIntegrationDiagnostics(session, org.id));
29
- return {
30
- data,
31
- human: renderTable(data.integrations, [
32
- { key: "id", label: "Integration" },
33
- { key: "displayName", label: "Name" },
34
- { key: "status", label: "Status" },
35
- { key: "message", label: "Message" },
36
- { key: "missingConfigFields", label: "Missing config" },
37
- { key: "invalidConfigFields", label: "Invalid config" }
38
- ]),
39
- kind: "integrations_diagnostics",
40
- meta: { command: parsed.definition.path.join(" "), orgId: org.id }
41
- };
42
- }
43
- case "integrations.get": {
44
- const data = redactIntegrationCliOutput(await integrationApi.getManagedIntegration(session, org.id, readRequiredArg(parsed, "integration-id")));
45
- return {
46
- data,
47
- human: renderPrettyJson(data.integration),
48
- kind: "integrations_get",
49
- meta: { command: parsed.definition.path.join(" "), orgId: org.id }
50
- };
51
- }
52
- case "integrations.actions": {
53
- const data = redactIntegrationCliOutput(await integrationApi.listManagedIntegrationActions(session, org.id, readRequiredArg(parsed, "integration-id")));
54
- return {
55
- data,
56
- human: renderTable(data.actions, [
57
- { key: "id", label: "Action" },
58
- { key: "label", label: "Label" },
59
- { key: "cliSafe", label: "CLI" },
60
- { key: "description", label: "Description" }
61
- ]),
62
- kind: "integrations_actions",
63
- meta: { command: parsed.definition.path.join(" "), orgId: org.id }
64
- };
65
- }
66
- case "integrations.connections": {
67
- const data = redactIntegrationCliOutput(await integrationApi.listManagedIntegrationConnections(session, org.id, readRequiredArg(parsed, "integration-id")));
68
- return {
69
- data,
70
- human: renderTable(data.connections, [
71
- { key: "connectionRef", label: "Connection" },
72
- { key: "displayName", label: "Name" },
73
- { key: "status", label: "Status" },
74
- { key: "labels", label: "Labels" }
75
- ]),
76
- kind: "integrations_connections",
77
- meta: { command: parsed.definition.path.join(" "), orgId: org.id }
78
- };
79
- }
80
- case "integrations.action": {
81
- const integrationId = readRequiredArg(parsed, "integration-id");
82
- const actionId = readRequiredArg(parsed, "action-id");
83
- const actions = (await integrationApi.listManagedIntegrationActions(session, org.id, integrationId)).actions;
84
- const action = requireFound(actions.find((entry) => entry.id === actionId) ?? null, `Integration action '${actionId}' was not found.`, parsed.definition.id);
85
- if (!action.cliSafe) {
86
- throw usageProblem(`Integration action '${actionId}' requires the Settings UI.`, parsed.definition.id);
87
- }
88
- const input = await buildIntegrationActionInput(parsed, context);
89
- const data = redactIntegrationCliOutput(await integrationApi.executeManagedIntegrationAction(session, org.id, integrationId, actionId, input));
90
- await handleIntegrationExternalUrls(data.result.effects, parsed, context);
91
- return {
92
- data,
93
- human: renderIntegrationActionHuman(data.result),
94
- kind: "integrations_action_execute",
95
- meta: { command: parsed.definition.path.join(" "), orgId: org.id }
96
- };
97
- }
98
- default:
99
- throw genericProblem(`Unhandled integrations command ${parsed.definition.id}.`, parsed.definition.id);
100
- }
101
- }
102
- async function buildIntegrationActionInput(parsed, context) {
103
- const input = {};
104
- const connectionRef = readOptionalStringFlag(parsed, "connection");
105
- if (connectionRef) {
106
- input.connectionRef = connectionRef;
107
- }
108
- const inputSpecifier = readOptionalStringFlag(parsed, "input");
109
- if (inputSpecifier) {
110
- const value = await readJsonInputSpecifier(inputSpecifier, context.stdin, parsed.definition.id);
111
- if (!isManagedIntegrationJsonObject(value)) {
112
- throw usageProblem("Integration action input must be a JSON object.", parsed.definition.id);
113
- }
114
- input.input = value;
115
- }
116
- return input;
117
- }
118
- async function handleIntegrationExternalUrls(effects, parsed, context) {
119
- const externalUrls = effects.filter((effect) => effect.kind === "open_external_url");
120
- if (externalUrls.length === 0) {
121
- return;
122
- }
123
- const explicitOpen = parsed.flags.open === true;
124
- const shouldOpen = shouldAutoOpenBrowser({
125
- env: context.env,
126
- explicitNoOpen: parsed.flags["no-open"] === true,
127
- explicitOpen,
128
- interactive: isInteractive(context),
129
- openBrowserConfig: context.config.openBrowser
130
- });
131
- if (!shouldOpen) {
132
- return;
133
- }
134
- for (const effect of externalUrls) {
135
- const opened = await openBrowser(effect.url);
136
- if (explicitOpen && !opened) {
137
- throw genericProblem(`Could not open a browser automatically. Visit ${effect.url}`, parsed.definition.id);
138
- }
139
- }
140
- }
141
- function renderIntegrationActionHuman(result) {
142
- const lines = [`Integration action ${result.actionId} completed.`];
143
- for (const effect of result.effects) {
144
- switch (effect.kind) {
145
- case "user_message":
146
- lines.push(effect.message);
147
- break;
148
- case "open_external_url":
149
- lines.push(`${effect.label ?? "Open"}: ${effect.url}`);
150
- break;
151
- case "connection_ready":
152
- lines.push(`Connection ready: ${effect.displayName} (${effect.connectionRef})`);
153
- break;
154
- case "terminal_failure":
155
- lines.push(`Failure: ${effect.message}`);
156
- break;
157
- case "schedule_poll":
158
- lines.push(`Polling scheduled in ${String(effect.intervalMs)}ms${effect.reason ? `: ${effect.reason}` : ""}.`);
159
- break;
160
- case "refresh_state":
161
- lines.push(`State refresh requested${effect.reason ? `: ${effect.reason}` : ""}.`);
162
- break;
163
- default:
164
- assertNever(effect);
165
- }
166
- }
167
- return lines.join("\n");
168
- }
169
- function redactIntegrationCliOutput(value) {
170
- return redactIntegrationCliValue(value, null);
171
- }
172
- function redactIntegrationCliValue(value, key) {
173
- if (key !== null && isSecretLikeKey(key) && value !== null && value !== undefined) {
174
- return "[redacted]";
175
- }
176
- if (Array.isArray(value)) {
177
- return value.map((entry) => redactIntegrationCliValue(entry, null));
178
- }
179
- if (typeof value === "object" && value !== null) {
180
- return Object.fromEntries(Object.entries(value).map(([entryKey, entryValue]) => [
181
- entryKey,
182
- redactIntegrationCliValue(entryValue, entryKey)
183
- ]));
184
- }
185
- return value;
186
- }
187
- function isSecretLikeKey(key) {
188
- return /(?:access|refresh)?token|secret|private[_-]?key|password|credential|authorization/i.test(key);
189
- }
190
- function isManagedIntegrationJsonObject(value) {
191
- return typeof value === "object" && value !== null && !Array.isArray(value);
192
- }
193
- function readRequiredArg(parsed, name) {
194
- const value = parsed.args[name];
195
- if (!value) {
196
- throw usageProblem(`Missing required argument <${name}>.`, parsed.definition.id);
197
- }
198
- return value;
199
- }
200
- function requireFound(value, detail, instance) {
201
- if (value === null || value === undefined) {
202
- throw notFoundProblem(detail, instance);
203
- }
204
- return value;
205
- }
206
- function assertNever(value) {
207
- throw new Error(`Unhandled integration host effect: ${JSON.stringify(value)}`);
208
- }