@cargo-ai/cdk 1.0.6 → 1.0.8
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/README.md +4 -44
- package/build/src/cli/auth.d.ts.map +1 -1
- package/build/src/cli/auth.js +16 -12
- package/build/src/cli/commands/deploy.d.ts.map +1 -1
- package/build/src/cli/commands/deploy.js +81 -107
- package/build/src/cli/commands/from.d.ts +65 -0
- package/build/src/cli/commands/from.d.ts.map +1 -0
- package/build/src/cli/commands/from.js +285 -0
- package/build/src/cli/commands/init.d.ts +1 -1
- package/build/src/cli/commands/init.d.ts.map +1 -1
- package/build/src/cli/commands/init.js +44 -20
- package/build/src/cli/commands/inputTypes.d.ts.map +1 -1
- package/build/src/cli/commands/inputTypes.js +77 -6
- package/build/src/cli/commands/types.d.ts.map +1 -1
- package/build/src/cli/commands/types.js +87 -9
- package/build/src/cli/io.js +2 -2
- package/build/src/cli/version.d.ts.map +1 -1
- package/build/src/cli/version.js +10 -6
- package/build/src/deploy/apply.d.ts.map +1 -1
- package/build/src/deploy/apply.js +37 -30
- package/build/src/deploy/compile.d.ts.map +1 -1
- package/build/src/deploy/compile.js +7 -5
- package/build/src/deploy/destroy.d.ts.map +1 -1
- package/build/src/deploy/destroy.js +24 -14
- package/build/src/deploy/executors.live.d.ts.map +1 -1
- package/build/src/deploy/executors.live.js +202 -173
- package/build/src/deploy/import.js +2 -2
- package/build/src/deploy/index.js +1 -1
- package/build/src/deploy/lock.d.ts.map +1 -1
- package/build/src/deploy/lock.js +13 -10
- package/build/src/deploy/readers.live.d.ts.map +1 -1
- package/build/src/deploy/readers.live.js +27 -15
- package/build/src/deploy/refresh.d.ts.map +1 -1
- package/build/src/deploy/refresh.js +20 -18
- package/build/src/index.d.ts +4 -4
- package/build/src/index.d.ts.map +1 -1
- package/build/src/index.js +2 -2
- package/build/src/refs.d.ts.map +1 -1
- package/build/src/refs.js +5 -1
- package/build/src/resources/actions.d.ts +1 -1
- package/build/src/resources/actions.d.ts.map +1 -1
- package/build/src/resources/actions.js +3 -2
- package/build/src/resources/agent.d.ts +23 -0
- package/build/src/resources/agent.d.ts.map +1 -1
- package/build/src/resources/agent.js +17 -0
- package/build/src/resources/capacity.d.ts +11 -0
- package/build/src/resources/capacity.d.ts.map +1 -1
- package/build/src/resources/capacity.js +81 -0
- package/build/src/resources/model.d.ts +11 -3
- package/build/src/resources/model.d.ts.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -69,7 +69,7 @@ export function registerTypesCommand(parent, getApi) {
|
|
|
69
69
|
].join("\n"));
|
|
70
70
|
info(``);
|
|
71
71
|
const extractorCount = payload.extractorConfigs.reduce((n, e) => n + e.extractors.length, 0);
|
|
72
|
-
info(`Typed ${String(payload.connectorConfigs.length)} connector config(s), ${String(extractorCount)} extractor config(s), ${String(payload.integrations.length)} integration(s), ${String(payload.native.length)} native action(s).`);
|
|
72
|
+
info(`Typed ${String(payload.connectorConfigs.length)} connector config(s), ${String(extractorCount)} extractor config(s), ${String(payload.agentTriggerConfigs.length)} agent trigger config(s), ${String(payload.integrations.length)} integration(s), ${String(payload.native.length)} native action(s).`);
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
75
|
async function fetchWorkspaceSurface(api) {
|
|
@@ -80,7 +80,16 @@ async function fetchWorkspaceSurface(api) {
|
|
|
80
80
|
const native = collectNative(nativeIntegrationResult.nativeIntegration.actions);
|
|
81
81
|
const connectorConfigs = collectConnectorConfigs(rawIntegrations);
|
|
82
82
|
const extractorConfigs = collectExtractorConfigs(rawIntegrations);
|
|
83
|
-
|
|
83
|
+
const extractorSlugs = collectExtractorSlugs(rawIntegrations);
|
|
84
|
+
const agentTriggerConfigs = collectAgentTriggerConfigs(rawIntegrations);
|
|
85
|
+
return {
|
|
86
|
+
integrations,
|
|
87
|
+
native,
|
|
88
|
+
connectorConfigs,
|
|
89
|
+
extractorConfigs,
|
|
90
|
+
extractorSlugs,
|
|
91
|
+
agentTriggerConfigs,
|
|
92
|
+
};
|
|
84
93
|
}
|
|
85
94
|
// integrationSlug → connector config type. Skips integrations whose schema
|
|
86
95
|
// prints as a bare record (no typing gained — the builder already falls back to
|
|
@@ -88,7 +97,33 @@ async function fetchWorkspaceSurface(api) {
|
|
|
88
97
|
function collectConnectorConfigs(integrations) {
|
|
89
98
|
const out = [];
|
|
90
99
|
for (const integration of integrations) {
|
|
91
|
-
const
|
|
100
|
+
const { connector } = integration;
|
|
101
|
+
const connectorConfig = connector !== undefined ? connector.config : undefined;
|
|
102
|
+
const schema = connectorConfig !== undefined ? connectorConfig.schema : undefined;
|
|
103
|
+
if (schema === undefined)
|
|
104
|
+
continue;
|
|
105
|
+
const typeSrc = printJsonSchemaType(schema);
|
|
106
|
+
if (typeSrc === "Record<string, unknown>")
|
|
107
|
+
continue;
|
|
108
|
+
out.push({
|
|
109
|
+
slug: integration.slug,
|
|
110
|
+
name: trimOrUndefined(integration.name),
|
|
111
|
+
typeSrc,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
out.sort((a, b) => a.slug.localeCompare(b.slug));
|
|
115
|
+
return out;
|
|
116
|
+
}
|
|
117
|
+
// integrationSlug → its agent connector-trigger config type. Only a few
|
|
118
|
+
// integrations expose an agent trigger (e.g. slack, http); the rest are skipped,
|
|
119
|
+
// as are those whose schema prints as a bare record.
|
|
120
|
+
function collectAgentTriggerConfigs(integrations) {
|
|
121
|
+
const out = [];
|
|
122
|
+
for (const integration of integrations) {
|
|
123
|
+
const { agent } = integration;
|
|
124
|
+
const trigger = agent !== undefined ? agent.trigger : undefined;
|
|
125
|
+
const triggerConfig = trigger !== undefined ? trigger.config : undefined;
|
|
126
|
+
const schema = triggerConfig !== undefined ? triggerConfig.schema : undefined;
|
|
92
127
|
if (schema === undefined)
|
|
93
128
|
continue;
|
|
94
129
|
const typeSrc = printJsonSchemaType(schema);
|
|
@@ -109,8 +144,10 @@ function collectExtractorConfigs(integrations) {
|
|
|
109
144
|
const out = [];
|
|
110
145
|
for (const integration of integrations) {
|
|
111
146
|
const extractors = [];
|
|
112
|
-
|
|
113
|
-
|
|
147
|
+
const { extractors: rawExtractors = {} } = integration;
|
|
148
|
+
for (const [slug, extractor] of Object.entries(rawExtractors).sort(([a], [b]) => a.localeCompare(b))) {
|
|
149
|
+
const { config } = extractor;
|
|
150
|
+
const schema = config !== undefined ? config.schema : undefined;
|
|
114
151
|
if (schema === undefined)
|
|
115
152
|
continue;
|
|
116
153
|
const typeSrc = printJsonSchemaType(schema);
|
|
@@ -125,19 +162,36 @@ function collectExtractorConfigs(integrations) {
|
|
|
125
162
|
out.sort((a, b) => a.integrationSlug.localeCompare(b.integrationSlug));
|
|
126
163
|
return out;
|
|
127
164
|
}
|
|
165
|
+
// integrationSlug → every extractor slug it exposes (the keys of `extractors`),
|
|
166
|
+
// so `defineModel`'s `extractSlug` autocompletes the full set, not just the ones
|
|
167
|
+
// that happen to add a typed config.
|
|
168
|
+
function collectExtractorSlugs(integrations) {
|
|
169
|
+
const out = [];
|
|
170
|
+
for (const integration of integrations) {
|
|
171
|
+
const { extractors = {} } = integration;
|
|
172
|
+
const slugs = Object.keys(extractors).sort((a, b) => a.localeCompare(b));
|
|
173
|
+
if (slugs.length === 0)
|
|
174
|
+
continue;
|
|
175
|
+
out.push({ integrationSlug: integration.slug, slugs });
|
|
176
|
+
}
|
|
177
|
+
out.sort((a, b) => a.integrationSlug.localeCompare(b.integrationSlug));
|
|
178
|
+
return out;
|
|
179
|
+
}
|
|
128
180
|
function collectIntegrations(integrations) {
|
|
129
181
|
const out = [];
|
|
130
182
|
for (const integration of integrations) {
|
|
131
|
-
const
|
|
183
|
+
const { actions: rawActions = {} } = integration;
|
|
184
|
+
const actionEntries = Object.entries(rawActions).sort(([a], [b]) => a.localeCompare(b));
|
|
132
185
|
if (actionEntries.length === 0)
|
|
133
186
|
continue;
|
|
134
187
|
const actions = actionEntries.map(([slug, raw]) => {
|
|
135
188
|
const meta = raw;
|
|
189
|
+
const { config } = meta;
|
|
136
190
|
return {
|
|
137
191
|
slug,
|
|
138
192
|
name: trimOrUndefined(meta.name),
|
|
139
193
|
description: trimOrUndefined(meta.description),
|
|
140
|
-
inputTypeSrc: printJsonSchemaInput(
|
|
194
|
+
inputTypeSrc: printJsonSchemaInput(config !== undefined ? config.schema : undefined),
|
|
141
195
|
};
|
|
142
196
|
});
|
|
143
197
|
out.push({
|
|
@@ -187,7 +241,10 @@ function renderTypes(payload) {
|
|
|
187
241
|
if (payload.connectorConfigs.length > 0) {
|
|
188
242
|
cdkLines.push(` interface ConnectorConfigs {`);
|
|
189
243
|
for (const c of payload.connectorConfigs) {
|
|
190
|
-
const doc = formatJsDoc({
|
|
244
|
+
const doc = formatJsDoc({
|
|
245
|
+
name: c.name !== undefined ? c.name : c.slug,
|
|
246
|
+
updatedAt: GENERATED_AT,
|
|
247
|
+
}, " ");
|
|
191
248
|
if (doc !== "")
|
|
192
249
|
cdkLines.push(doc.trimEnd());
|
|
193
250
|
cdkLines.push(` ${jsonKey(c.slug)}: ${c.typeSrc};`);
|
|
@@ -205,6 +262,27 @@ function renderTypes(payload) {
|
|
|
205
262
|
}
|
|
206
263
|
cdkLines.push(` }`);
|
|
207
264
|
}
|
|
265
|
+
if (payload.extractorSlugs.length > 0) {
|
|
266
|
+
cdkLines.push(` interface ExtractorSlugs {`);
|
|
267
|
+
for (const e of payload.extractorSlugs) {
|
|
268
|
+
const union = e.slugs.map((s) => JSON.stringify(s)).join(" | ");
|
|
269
|
+
cdkLines.push(` ${jsonKey(e.integrationSlug)}: ${union};`);
|
|
270
|
+
}
|
|
271
|
+
cdkLines.push(` }`);
|
|
272
|
+
}
|
|
273
|
+
if (payload.agentTriggerConfigs.length > 0) {
|
|
274
|
+
cdkLines.push(` interface AgentTriggerConfigs {`);
|
|
275
|
+
for (const t of payload.agentTriggerConfigs) {
|
|
276
|
+
const doc = formatJsDoc({
|
|
277
|
+
name: t.name !== undefined ? t.name : t.slug,
|
|
278
|
+
updatedAt: GENERATED_AT,
|
|
279
|
+
}, " ");
|
|
280
|
+
if (doc !== "")
|
|
281
|
+
cdkLines.push(doc.trimEnd());
|
|
282
|
+
cdkLines.push(` ${jsonKey(t.slug)}: ${t.typeSrc};`);
|
|
283
|
+
}
|
|
284
|
+
cdkLines.push(` }`);
|
|
285
|
+
}
|
|
208
286
|
if (cdkLines.length > 0) {
|
|
209
287
|
blocks.push([`declare module "@cargo-ai/cdk" {`, ...cdkLines, `}`].join("\n"));
|
|
210
288
|
}
|
|
@@ -214,7 +292,7 @@ function renderTypes(payload) {
|
|
|
214
292
|
wfLines.push(` interface Integrations {`);
|
|
215
293
|
for (const c of payload.integrations) {
|
|
216
294
|
const intDoc = formatJsDoc({
|
|
217
|
-
name: c.name
|
|
295
|
+
name: c.name !== undefined ? c.name : c.slug,
|
|
218
296
|
description: c.description,
|
|
219
297
|
updatedAt: GENERATED_AT,
|
|
220
298
|
}, " ");
|
package/build/src/cli/io.js
CHANGED
|
@@ -14,7 +14,7 @@ const useColor = process.stderr.isTTY === true &&
|
|
|
14
14
|
process.env["NO_COLOR"] === undefined &&
|
|
15
15
|
process.env["CI"] !== "true";
|
|
16
16
|
const colorize = (text, code) => {
|
|
17
|
-
if (useColor
|
|
17
|
+
if (useColor === false) {
|
|
18
18
|
return text;
|
|
19
19
|
}
|
|
20
20
|
return `\x1B[${code}m${text}\x1B[0m`;
|
|
@@ -114,7 +114,7 @@ export function startSpinner(message) {
|
|
|
114
114
|
process.stderr.write(`\r\x1B[K${line}\n`);
|
|
115
115
|
},
|
|
116
116
|
stop: () => {
|
|
117
|
-
if (stopped) {
|
|
117
|
+
if (stopped === true) {
|
|
118
118
|
return;
|
|
119
119
|
}
|
|
120
120
|
stopped = true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../../src/cli/version.ts"],"names":[],"mappings":"AAOA,wBAAgB,cAAc,IAAI,MAAM,
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../../src/cli/version.ts"],"names":[],"mappings":"AAOA,wBAAgB,cAAc,IAAI,MAAM,CAevC"}
|
package/build/src/cli/version.js
CHANGED
|
@@ -5,8 +5,8 @@ import { fileURLToPath } from "node:url";
|
|
|
5
5
|
// package.json — a walk (not a fixed relative path) so it's independent of build
|
|
6
6
|
// layout depth.
|
|
7
7
|
export function packageVersion() {
|
|
8
|
-
|
|
9
|
-
for (
|
|
8
|
+
const start = dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
for (const cursor of ancestorDirs(start, 8)) {
|
|
10
10
|
try {
|
|
11
11
|
const pkg = JSON.parse(readFileSync(join(cursor, "package.json"), "utf-8"));
|
|
12
12
|
if (pkg.name === "@cargo-ai/cdk" && typeof pkg.version === "string") {
|
|
@@ -16,10 +16,14 @@ export function packageVersion() {
|
|
|
16
16
|
catch {
|
|
17
17
|
// no package.json here (or unreadable) — keep walking up
|
|
18
18
|
}
|
|
19
|
-
const parent = dirname(cursor);
|
|
20
|
-
if (parent === cursor)
|
|
21
|
-
break;
|
|
22
|
-
cursor = parent;
|
|
23
19
|
}
|
|
24
20
|
return "0.0.0";
|
|
25
21
|
}
|
|
22
|
+
// The directory chain from `start` walking up to `max` levels, stopping at the
|
|
23
|
+
// filesystem root — so the package root can be found independent of build depth.
|
|
24
|
+
function ancestorDirs(start, max) {
|
|
25
|
+
const parent = dirname(start);
|
|
26
|
+
if (max <= 1 || parent === start)
|
|
27
|
+
return [start];
|
|
28
|
+
return [start, ...ancestorDirs(parent, max - 1)];
|
|
29
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apply.d.ts","sourceRoot":"","sources":["../../../src/deploy/apply.ts"],"names":[],"mappings":"AAgBA,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,KAAK,EACV,KAAK,UAAU,EAChB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc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AC;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAwBF,wBAAsB,KAAK,CACzB,KAAK,EAAE,YAAY,EACnB,SAAS,EAAE,SAAS,EACpB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,EAChC,OAAO,CAAC,EAAE,WAAW,EACrB,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,GAC1C,OAAO,CAAC,WAAW,CAAC,CAuHtB"}
|
|
@@ -36,16 +36,18 @@ export async function apply(input, executors, persist, readers, onProgress) {
|
|
|
36
36
|
throw new Error(`apply aborted — fix plan errors first: ${detail}`);
|
|
37
37
|
}
|
|
38
38
|
const byId = new Map(input.nodes.map((n) => [n.id, n]));
|
|
39
|
+
const priorState = input.state;
|
|
40
|
+
const priorResources = priorState === undefined ? {} : priorState.resources;
|
|
39
41
|
// Resolved outputs by resource id, seeded from prior state so unchanged
|
|
40
42
|
// ("noop") dependencies still resolve for their dependents.
|
|
41
43
|
const outputs = new Map();
|
|
42
|
-
for (const [id, entry] of Object.entries(
|
|
44
|
+
for (const [id, entry] of Object.entries(priorResources)) {
|
|
43
45
|
outputs.set(id, entry.outputs);
|
|
44
46
|
}
|
|
45
47
|
const state = {
|
|
46
|
-
version:
|
|
47
|
-
workspaceUuid:
|
|
48
|
-
resources: { ...
|
|
48
|
+
version: priorState === undefined ? 1 : priorState.version,
|
|
49
|
+
workspaceUuid: priorState === undefined ? "" : priorState.workspaceUuid,
|
|
50
|
+
resources: { ...priorResources },
|
|
49
51
|
};
|
|
50
52
|
const applied = [];
|
|
51
53
|
const skipped = [];
|
|
@@ -61,8 +63,7 @@ export async function apply(input, executors, persist, readers, onProgress) {
|
|
|
61
63
|
const node = byId.get(entry.id);
|
|
62
64
|
if (node === undefined)
|
|
63
65
|
continue; // delete entries — handled by destroy
|
|
64
|
-
|
|
65
|
-
if (change === "noop") {
|
|
66
|
+
if (entry.change === "noop") {
|
|
66
67
|
// A noop's own spec hash is unchanged, but if one of its dependencies
|
|
67
68
|
// produced a NEW output identity this run, the tokens in this spec now
|
|
68
69
|
// resolve to different values than its live config holds (e.g. it still
|
|
@@ -70,50 +71,41 @@ export async function apply(input, executors, persist, readers, onProgress) {
|
|
|
70
71
|
// re-points at the new value; otherwise it silently dangles.
|
|
71
72
|
const deps = dependenciesOf(node.spec);
|
|
72
73
|
const stale = Array.from(deps).some((d) => changedOutputs.has(d));
|
|
73
|
-
if (
|
|
74
|
+
if (stale === false) {
|
|
74
75
|
skipped.push(entry);
|
|
75
76
|
continue;
|
|
76
77
|
}
|
|
77
|
-
change = "update";
|
|
78
78
|
total += 1; // a noop promoted to a re-apply — count it
|
|
79
79
|
}
|
|
80
|
-
index += 1;
|
|
81
80
|
// `change` is create|update here (noop was skipped/promoted above; delete
|
|
82
|
-
// entries have no node and were `continue`d).
|
|
83
|
-
|
|
81
|
+
// entries have no node and were `continue`d).
|
|
82
|
+
const change = entry.change === "noop" ? "update" : entry.change;
|
|
83
|
+
index += 1;
|
|
84
|
+
// `index`/`total` are fixed for this resource, so the start/done events
|
|
85
|
+
// share one payload.
|
|
84
86
|
const progress = {
|
|
85
87
|
id: node.id,
|
|
86
88
|
change: change,
|
|
87
89
|
index,
|
|
88
90
|
total,
|
|
89
91
|
};
|
|
90
|
-
onProgress
|
|
92
|
+
if (onProgress !== undefined)
|
|
93
|
+
onProgress({ phase: "start", ...progress });
|
|
91
94
|
// tokens (deferred outputs) then secrets (deferred env reads) — both resolve
|
|
92
95
|
// to real values here, at apply, just before the executor runs.
|
|
93
96
|
const resolved = resolveSecrets(resolveTokens(node.spec, outputs));
|
|
94
97
|
assertNoPlaceholders(node.id, resolved);
|
|
95
|
-
const prior =
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
produced = await runExecutor(node, resolved, prior, executors);
|
|
99
|
-
}
|
|
100
|
-
catch (error) {
|
|
101
|
-
// Tag the failure with the resource that failed and surface the API's
|
|
102
|
-
// structured detail — executors throw `@cargo-ai/api` FetcherErrors whose
|
|
103
|
-
// bare `message` is often a terse "Invalid configuration", with the
|
|
104
|
-
// actionable bits (reason, status, which field) on `reason`/`status`/`data`.
|
|
105
|
-
throw new Error(`${node.id}: ${describeExecutorError(error)}`, {
|
|
106
|
-
cause: error,
|
|
107
|
-
});
|
|
108
|
-
}
|
|
98
|
+
const prior = priorState === undefined ? undefined : priorState.resources[node.id];
|
|
99
|
+
const produced = await runExecutorTagged(node, resolved, prior, executors);
|
|
100
|
+
const priorOutputs = prior === undefined ? undefined : prior.outputs;
|
|
109
101
|
// Carry the "adopted" marker forward across updates so destroy keeps
|
|
110
102
|
// releasing (not deleting) a resource the CDK adopted or imported, even for
|
|
111
103
|
// kinds whose executor doesn't echo it back.
|
|
112
|
-
|
|
113
|
-
|
|
104
|
+
const priorAdopted = priorOutputs === undefined ? undefined : priorOutputs["adopted"];
|
|
105
|
+
if (priorAdopted === "true" && produced["adopted"] === undefined) {
|
|
114
106
|
produced["adopted"] = "true";
|
|
115
107
|
}
|
|
116
|
-
if (outputsChanged(
|
|
108
|
+
if (outputsChanged(priorOutputs, produced)) {
|
|
117
109
|
changedOutputs.add(node.id);
|
|
118
110
|
}
|
|
119
111
|
outputs.set(node.id, produced);
|
|
@@ -139,7 +131,8 @@ export async function apply(input, executors, persist, readers, onProgress) {
|
|
|
139
131
|
}
|
|
140
132
|
if (persist !== undefined)
|
|
141
133
|
persist(state);
|
|
142
|
-
onProgress
|
|
134
|
+
if (onProgress !== undefined)
|
|
135
|
+
onProgress({ phase: "done", ...progress });
|
|
143
136
|
applied.push(change === entry.change ? entry : { ...entry, change });
|
|
144
137
|
}
|
|
145
138
|
return { state, applied, skipped };
|
|
@@ -191,6 +184,20 @@ function outputsChanged(prior, produced) {
|
|
|
191
184
|
}
|
|
192
185
|
return false;
|
|
193
186
|
}
|
|
187
|
+
// Run the executor, tagging any failure with the resource that failed and the
|
|
188
|
+
// API's structured detail — executors throw `@cargo-ai/api` FetcherErrors whose
|
|
189
|
+
// bare `message` is often a terse "Invalid configuration", with the actionable
|
|
190
|
+
// bits (reason, status, which field) on `reason`/`status`/`data`.
|
|
191
|
+
async function runExecutorTagged(node, resolved, prior, executors) {
|
|
192
|
+
try {
|
|
193
|
+
return await runExecutor(node, resolved, prior, executors);
|
|
194
|
+
}
|
|
195
|
+
catch (error) {
|
|
196
|
+
throw new Error(`${node.id}: ${describeExecutorError(error)}`, {
|
|
197
|
+
cause: error,
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
}
|
|
194
201
|
function runExecutor(node, resolved, prior, executors) {
|
|
195
202
|
switch (node.kind) {
|
|
196
203
|
case "connector":
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../../src/deploy/compile.ts"],"names":[],"mappings":"AAUA,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,YAAY,EAElB,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEjE,MAAM,MAAM,SAAS,GAAG;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,YAAY,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,UAAU,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9D,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IAIb,IAAI,EAAE,MAAM,CAAC;IAGb,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAIhC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAKhB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AACF,MAAM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B,OAAO,EAAE,MAAM,CAAC;IAGhB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,EAAE,SAAS,YAAY,EAAE,CAAC;IAC/B,KAAK,CAAC,EAAE,KAAK,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,IAAI,EAAE,SAAS,EAAE,CAAC;IAClB,MAAM,EAAE,eAAe,EAAE,CAAC;CAC3B,CAAC;AAqEF,wBAAgB,OAAO,CAAC,KAAK,EAAE,YAAY,GAAG,aAAa,CAyC1D"}
|
|
@@ -18,7 +18,8 @@ function validate(nodes, edges) {
|
|
|
18
18
|
const errors = [];
|
|
19
19
|
const ids = new Set(nodes.map((n) => n.id));
|
|
20
20
|
for (const node of nodes) {
|
|
21
|
-
|
|
21
|
+
const nodeEdges = edges.get(node.id);
|
|
22
|
+
for (const dep of nodeEdges !== undefined ? nodeEdges : new Set()) {
|
|
22
23
|
if (!ids.has(dep)) {
|
|
23
24
|
errors.push({
|
|
24
25
|
id: node.id,
|
|
@@ -42,7 +43,8 @@ function topoSort(nodes, edges) {
|
|
|
42
43
|
return false;
|
|
43
44
|
}
|
|
44
45
|
visited.set(id, "visiting");
|
|
45
|
-
|
|
46
|
+
const idEdges = edges.get(id);
|
|
47
|
+
for (const dep of idEdges !== undefined ? idEdges : new Set()) {
|
|
46
48
|
if (!edges.has(dep))
|
|
47
49
|
continue; // unknown dep — reported by validate()
|
|
48
50
|
if (!visit(dep)) {
|
|
@@ -63,7 +65,7 @@ function topoSort(nodes, edges) {
|
|
|
63
65
|
return { order, cycle };
|
|
64
66
|
}
|
|
65
67
|
export function compile(input) {
|
|
66
|
-
const { nodes } = input;
|
|
68
|
+
const { nodes, state } = input;
|
|
67
69
|
const byId = new Map(nodes.map((n) => [n.id, n]));
|
|
68
70
|
const edges = new Map();
|
|
69
71
|
for (const node of nodes) {
|
|
@@ -80,14 +82,14 @@ export function compile(input) {
|
|
|
80
82
|
const plan = order.map((id) => {
|
|
81
83
|
const node = byId.get(id);
|
|
82
84
|
const hash = hashOf(node.spec);
|
|
83
|
-
const prior =
|
|
85
|
+
const prior = state !== undefined ? state.resources[id] : undefined;
|
|
84
86
|
const change = prior === undefined ? "create" : prior.hash === hash ? "noop" : "update";
|
|
85
87
|
return { id, kind: node.kind, slug: node.slug, change, hash };
|
|
86
88
|
});
|
|
87
89
|
// Resources in state but no longer in code — candidates to prune. Appended
|
|
88
90
|
// after the apply order; the actual removal runs in dependency-safe order.
|
|
89
91
|
const deletes = [];
|
|
90
|
-
for (const [id, entry] of Object.entries(
|
|
92
|
+
for (const [id, entry] of Object.entries(state !== undefined ? state.resources : {})) {
|
|
91
93
|
if (byId.has(id))
|
|
92
94
|
continue;
|
|
93
95
|
const kind = id.slice(0, id.indexOf(":"));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"destroy.d.ts","sourceRoot":"","sources":["../../../src/deploy/destroy.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAMzC,MAAM,MAAM,aAAa,GAAG;IAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"destroy.d.ts","sourceRoot":"","sources":["../../../src/deploy/destroy.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAMzC,MAAM,MAAM,aAAa,GAAG;IAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAyJtE;;;;;GAKG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,MAAM,EAAE,GACZ,OAAO,CAAC,aAAa,CAAC,CA4BxB;AAED;;;GAGG;AACH,wBAAsB,OAAO,CAC3B,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,GAAG,EACR,IAAI,GAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAO,GAC7B,OAAO,CAAC,aAAa,CAAC,CAgCxB"}
|
|
@@ -55,7 +55,9 @@ function removalOrder(ids, state) {
|
|
|
55
55
|
if (visited.has(id))
|
|
56
56
|
return;
|
|
57
57
|
visited.add(id);
|
|
58
|
-
const
|
|
58
|
+
const entry = state.resources[id];
|
|
59
|
+
const rawDeps = entry !== undefined && entry.deps !== undefined ? entry.deps : [];
|
|
60
|
+
const deps = rawDeps
|
|
59
61
|
.filter((dep) => inSet.has(dep) && dep !== id)
|
|
60
62
|
.sort(reverseKind);
|
|
61
63
|
for (const dep of deps)
|
|
@@ -116,18 +118,21 @@ async function remove(api, kind, uuid) {
|
|
|
116
118
|
const datasetUuid = target.fromDatasetUuid;
|
|
117
119
|
const remaining = relationships
|
|
118
120
|
.filter((r) => r.fromDatasetUuid === datasetUuid && r.uuid !== uuid)
|
|
119
|
-
.map((r) =>
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
121
|
+
.map((r) => {
|
|
122
|
+
const { fromPropertySlug = null, toPropertySlug = null, fromSelectedColumnSlugs = null, toSelectedColumnSlugs = null, } = r;
|
|
123
|
+
return {
|
|
124
|
+
uuid: r.uuid,
|
|
125
|
+
fromModelUuid: r.fromModelUuid,
|
|
126
|
+
fromColumnSlug: r.fromColumnSlug,
|
|
127
|
+
fromPropertySlug,
|
|
128
|
+
toModelUuid: r.toModelUuid,
|
|
129
|
+
toColumnSlug: r.toColumnSlug,
|
|
130
|
+
toPropertySlug,
|
|
131
|
+
fromSelectedColumnSlugs,
|
|
132
|
+
toSelectedColumnSlugs,
|
|
133
|
+
relation: r.relation,
|
|
134
|
+
};
|
|
135
|
+
});
|
|
131
136
|
await api.storage.relationship.set({
|
|
132
137
|
datasetUuid,
|
|
133
138
|
relationships: remaining,
|
|
@@ -181,7 +186,12 @@ export async function destroy(root, api, opts = {}) {
|
|
|
181
186
|
if (opts.target !== undefined && opts.target in state.resources) {
|
|
182
187
|
const target = opts.target;
|
|
183
188
|
const dependents = Object.entries(state.resources)
|
|
184
|
-
.filter(([id, e]) =>
|
|
189
|
+
.filter(([id, e]) => {
|
|
190
|
+
if (id === target)
|
|
191
|
+
return false;
|
|
192
|
+
const deps = e.deps !== undefined ? e.deps : [];
|
|
193
|
+
return deps.includes(target);
|
|
194
|
+
})
|
|
185
195
|
.map(([id]) => id);
|
|
186
196
|
if (dependents.length > 0) {
|
|
187
197
|
throw new Error(`cannot destroy "${target}": ${String(dependents.length)} resource(s) ` +
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executors.live.d.ts","sourceRoot":"","sources":["../../../src/deploy/executors.live.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAIzC,OAAO,KAAK,EAAE,SAAS,EAAW,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"executors.live.d.ts","sourceRoot":"","sources":["../../../src/deploy/executors.live.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAIzC,OAAO,KAAK,EAAE,SAAS,EAAW,MAAM,YAAY,CAAC;AA4NrD,wBAAgB,aAAa,CAAC,GAAG,EAAE,GAAG,GAAG,SAAS,CA8oBjD"}
|