@telorun/kernel 0.2.9 → 0.3.2
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 +7 -7
- package/dist/controllers/module/import-controller.d.ts.map +1 -1
- package/dist/controllers/module/import-controller.js +22 -23
- package/dist/controllers/module/import-controller.js.map +1 -1
- package/dist/controllers/resource-definition/resource-definition-controller.d.ts +1 -1
- package/dist/controllers/resource-definition/resource-definition-controller.d.ts.map +1 -1
- package/dist/evaluation-context.d.ts +21 -4
- package/dist/evaluation-context.d.ts.map +1 -1
- package/dist/evaluation-context.js +216 -26
- package/dist/evaluation-context.js.map +1 -1
- package/dist/kernel.d.ts +11 -8
- package/dist/kernel.d.ts.map +1 -1
- package/dist/kernel.js +38 -16
- package/dist/kernel.js.map +1 -1
- package/dist/manifest-schemas.d.ts +44 -1
- package/dist/manifest-schemas.d.ts.map +1 -1
- package/dist/manifest-schemas.js +59 -15
- package/dist/manifest-schemas.js.map +1 -1
- package/dist/module-context.d.ts +1 -1
- package/dist/module-context.js +1 -1
- package/dist/resource-context.d.ts +6 -2
- package/dist/resource-context.d.ts.map +1 -1
- package/dist/resource-context.js +24 -4
- package/dist/resource-context.js.map +1 -1
- package/package.json +3 -3
- package/src/controllers/module/import-controller.ts +28 -28
- package/src/controllers/resource-definition/resource-definition-controller.ts +1 -1
- package/src/evaluation-context.ts +227 -32
- package/src/kernel.ts +52 -18
- package/src/manifest-schemas.ts +61 -15
- package/src/module-context.ts +1 -1
- package/src/resource-context.ts +38 -3
- package/dist/base-definition.d.ts +0 -14
- package/dist/base-definition.d.ts.map +0 -1
- package/dist/base-definition.js +0 -17
- package/dist/base-definition.js.map +0 -1
- package/dist/capabilities/capabilities/component.yaml +0 -4
- package/dist/capabilities/capabilities/executable.yaml +0 -8
- package/dist/capabilities/capabilities/handler.yaml +0 -4
- package/dist/capabilities/capabilities/listener.yaml +0 -4
- package/dist/capabilities/capabilities/provider.yaml +0 -4
- package/dist/capabilities/capabilities/template.yaml +0 -4
- package/dist/capabilities/capabilities/type.yaml +0 -4
- package/dist/capabilities/component.d.ts +0 -3
- package/dist/capabilities/component.d.ts.map +0 -1
- package/dist/capabilities/component.js +0 -4
- package/dist/capabilities/component.js.map +0 -1
- package/dist/capabilities/component.yaml +0 -3
- package/dist/capabilities/executable.d.ts +0 -3
- package/dist/capabilities/executable.d.ts.map +0 -1
- package/dist/capabilities/executable.js +0 -5
- package/dist/capabilities/executable.js.map +0 -1
- package/dist/capabilities/executable.yaml +0 -7
- package/dist/capabilities/handler.d.ts +0 -3
- package/dist/capabilities/handler.d.ts.map +0 -1
- package/dist/capabilities/handler.js +0 -4
- package/dist/capabilities/handler.js.map +0 -1
- package/dist/capabilities/handler.yaml +0 -3
- package/dist/capabilities/invokable.d.ts +0 -3
- package/dist/capabilities/invokable.d.ts.map +0 -1
- package/dist/capabilities/invokable.js +0 -5
- package/dist/capabilities/invokable.js.map +0 -1
- package/dist/capabilities/listener.d.ts +0 -3
- package/dist/capabilities/listener.d.ts.map +0 -1
- package/dist/capabilities/listener.js +0 -5
- package/dist/capabilities/listener.js.map +0 -1
- package/dist/capabilities/listener.yaml +0 -3
- package/dist/capabilities/mount.d.ts +0 -3
- package/dist/capabilities/mount.d.ts.map +0 -1
- package/dist/capabilities/mount.js +0 -5
- package/dist/capabilities/mount.js.map +0 -1
- package/dist/capabilities/provider.d.ts +0 -3
- package/dist/capabilities/provider.d.ts.map +0 -1
- package/dist/capabilities/provider.js +0 -8
- package/dist/capabilities/provider.js.map +0 -1
- package/dist/capabilities/provider.yaml +0 -3
- package/dist/capabilities/runnable.d.ts +0 -3
- package/dist/capabilities/runnable.d.ts.map +0 -1
- package/dist/capabilities/runnable.js +0 -5
- package/dist/capabilities/runnable.js.map +0 -1
- package/dist/capabilities/service.d.ts +0 -3
- package/dist/capabilities/service.d.ts.map +0 -1
- package/dist/capabilities/service.js +0 -5
- package/dist/capabilities/service.js.map +0 -1
- package/dist/capabilities/template.d.ts +0 -3
- package/dist/capabilities/template.d.ts.map +0 -1
- package/dist/capabilities/template.js +0 -5
- package/dist/capabilities/template.js.map +0 -1
- package/dist/capabilities/template.yaml +0 -3
- package/dist/capabilities/type.d.ts +0 -3
- package/dist/capabilities/type.d.ts.map +0 -1
- package/dist/capabilities/type.js +0 -5
- package/dist/capabilities/type.js.map +0 -1
- package/dist/capabilities/type.yaml +0 -3
- package/dist/controllers/capability/capability-controller.d.ts +0 -32
- package/dist/controllers/capability/capability-controller.d.ts.map +0 -1
- package/dist/controllers/capability/capability-controller.js +0 -26
- package/dist/controllers/capability/capability-controller.js.map +0 -1
- package/dist/controllers/module/module.json +0 -48
- package/dist/loader.d.ts +0 -18
- package/dist/loader.d.ts.map +0 -1
- package/dist/loader.js +0 -127
- package/dist/loader.js.map +0 -1
- package/dist/manifest-adapters/http-adapter.d.ts +0 -8
- package/dist/manifest-adapters/http-adapter.d.ts.map +0 -1
- package/dist/manifest-adapters/http-adapter.js +0 -31
- package/dist/manifest-adapters/http-adapter.js.map +0 -1
- package/dist/manifest-adapters/registry-adapter.d.ts +0 -9
- package/dist/manifest-adapters/registry-adapter.d.ts.map +0 -1
- package/dist/manifest-adapters/registry-adapter.js +0 -48
- package/dist/manifest-adapters/registry-adapter.js.map +0 -1
- package/dist/module-context-registry.d.ts +0 -48
- package/dist/module-context-registry.d.ts.map +0 -1
- package/dist/module-context-registry.js +0 -91
- package/dist/module-context-registry.js.map +0 -1
- package/dist/schema-valiator.d.ts +0 -15
- package/dist/schema-valiator.d.ts.map +0 -1
- package/dist/schema-valiator.js +0 -127
- package/dist/schema-valiator.js.map +0 -1
- package/dist/snapshot-serializer.d.ts +0 -62
- package/dist/snapshot-serializer.d.ts.map +0 -1
- package/dist/snapshot-serializer.js +0 -164
- package/dist/snapshot-serializer.js.map +0 -1
- package/dist/types.d.ts +0 -65
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -8
- package/dist/types.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource-context.js","sourceRoot":"","sources":["../src/resource-context.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,
|
|
1
|
+
{"version":3,"file":"resource-context.js","sourceRoot":"","sources":["../src/resource-context.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EAIb,YAAY,EAEZ,eAAe,GAMhB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,SAAS,MAAM,KAAK,CAAC;AAC5B,OAAO,UAAU,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,MAAM,GAAG,GAAG,SAAS,CAAC,OAAO,IAAI,SAAS,CAAC;AAE3C,MAAM,OAAO,mBAAmB;IAO9B,YACW,MAAc,EACd,aAA4B,EACpB,QAA6B,EAC7B,YAA6B,IAAI,eAAe,EAAE,EACnE,GAAwC,EACxC,KAA6B,EAC7B,MAA8B,EAC9B,MAA8B,EAC9B,IAAiB;QARR,WAAM,GAAN,MAAM,CAAQ;QACd,kBAAa,GAAb,aAAa,CAAe;QACpB,aAAQ,GAAR,QAAQ,CAAqB;QAC7B,cAAS,GAAT,SAAS,CAAyC;QAOnE,IAAI,CAAC,GAAG,GAAG,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC;QAC9B,IAAI,CAAC,KAAK,GAAG,KAAK,IAAI,OAAO,CAAC,KAAK,CAAC;QACpC,IAAI,CAAC,MAAM,GAAG,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC;QACvC,IAAI,CAAC,MAAM,GAAG,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC;QACvC,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC;IAChC,CAAC;IAED,qBAAqB,CAAC,MAAW;QAC/B,IAAI,CA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C,GAAG,CAAC,mBAAmB,CAAC,CAAC;IACxD,IAAI,CAAC,KAAK,IAAI,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;QACxC,MAAM,GAAG,GAA4B,EAAE,CAAC;QACxC,KAAK,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,CAA4B,CAAC,EAAE,CAAC;YACpE,GAAG,CAAC,CAAC,CAAC,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC;QACpC,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@telorun/kernel",
|
|
3
|
-
"version": "0.2
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "Telo Runtime - A lightweight, polyglot execution host.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"digly",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"ajv-formats": "^3.0.1",
|
|
42
42
|
"minimatch": "^10.2.5",
|
|
43
43
|
"packageurl-js": "^2.0.1",
|
|
44
|
-
"@telorun/analyzer": "0.1
|
|
45
|
-
"@telorun/sdk": "0.2
|
|
44
|
+
"@telorun/analyzer": "0.2.1",
|
|
45
|
+
"@telorun/sdk": "0.3.2",
|
|
46
46
|
"@telorun/yaml-cel-templating": "1.0.4"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
@@ -1,25 +1,34 @@
|
|
|
1
|
-
import { DiagnosticSeverity,
|
|
1
|
+
import { DiagnosticSeverity, StaticAnalyzer } from "@telorun/analyzer";
|
|
2
2
|
import type { ResourceContext, ResourceInstance } from "@telorun/sdk";
|
|
3
3
|
import { RuntimeError } from "@telorun/sdk";
|
|
4
4
|
import { ModuleContext } from "../../module-context.js";
|
|
5
|
-
import { LocalFileAdapter } from "../../manifest-adapters/local-file-adapter.js";
|
|
6
5
|
|
|
7
6
|
const importAnalysisCache = new Map<
|
|
8
7
|
string,
|
|
9
8
|
{ signature: string; errors: string[] }
|
|
10
9
|
>();
|
|
11
10
|
|
|
11
|
+
// Only resolve relative/absolute-path sources against the importer's URL. Registry refs
|
|
12
|
+
// (std/foo@1.2.3) and absolute URLs (https://, file://) must pass through unchanged so the
|
|
13
|
+
// loader's adapter chain can dispatch them — otherwise `new URL("std/foo@1", "file:///srv/telo.yaml")`
|
|
14
|
+
// turns a registry ref into a bogus file path and LocalFileAdapter ENOENTs on it.
|
|
15
|
+
function resolveImportSource(source: string, baseSource: string): string {
|
|
16
|
+
if (source.startsWith(".") || source.startsWith("/")) {
|
|
17
|
+
return new URL(source, baseSource).toString();
|
|
18
|
+
}
|
|
19
|
+
return source;
|
|
20
|
+
}
|
|
21
|
+
|
|
12
22
|
export async function create(resource: any, ctx: ResourceContext): Promise<ResourceInstance> {
|
|
13
23
|
const alias = resource.metadata.name as string;
|
|
14
|
-
const loader = new Loader([new LocalFileAdapter()]);
|
|
15
24
|
|
|
16
25
|
const moduleSource: string = resource.module ?? resource.source;
|
|
17
26
|
|
|
18
27
|
// Validate the imported module and all its transitive imports before loading for runtime.
|
|
19
|
-
// loadManifests() follows
|
|
28
|
+
// loadManifests() follows Telo.Import chains so definitions from sub-imports are present,
|
|
20
29
|
// preventing false UNDEFINED_KIND errors for kinds that come from the module's own imports.
|
|
21
|
-
const resolvedUrl =
|
|
22
|
-
const analysisManifests = await
|
|
30
|
+
const resolvedUrl = resolveImportSource(moduleSource, ctx.moduleContext.source);
|
|
31
|
+
const analysisManifests = await ctx.loadManifests(resolvedUrl);
|
|
23
32
|
const signature = JSON.stringify(analysisManifests);
|
|
24
33
|
const cached = importAnalysisCache.get(resolvedUrl);
|
|
25
34
|
let errors: string[];
|
|
@@ -44,16 +53,20 @@ export async function create(resource: any, ctx: ResourceContext): Promise<Resou
|
|
|
44
53
|
// Load target module manifests for runtime. Inject variables/secrets as compile context so
|
|
45
54
|
// that ${{ variables.x }} / ${{ secrets.y }} templates in the child module resolve correctly.
|
|
46
55
|
// No env — child modules are isolated from host environment.
|
|
47
|
-
const manifests = await
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
);
|
|
53
|
-
// Find the kind: Module manifest to learn the target module name and contract.
|
|
54
|
-
const moduleManifest = manifests.find((m: any) => m.kind === "Kernel.Module");
|
|
56
|
+
const manifests = await ctx.loadModule(resolvedUrl, {
|
|
57
|
+
compile: true,
|
|
58
|
+
});
|
|
59
|
+
// Import targets must be Telo.Library — Applications are run directly, not imported.
|
|
60
|
+
const moduleManifest = manifests.find((m: any) => m.kind === "Telo.Library");
|
|
55
61
|
if (!moduleManifest) {
|
|
56
|
-
|
|
62
|
+
const applicationManifest = manifests.find((m: any) => m.kind === "Telo.Application");
|
|
63
|
+
if (applicationManifest) {
|
|
64
|
+
throw new RuntimeError(
|
|
65
|
+
"ERR_MANIFEST_VALIDATION_FAILED",
|
|
66
|
+
`Telo.Import target '${resource.source as string}' is a Telo.Application. Only Telo.Library modules may be imported. Applications are run directly, not imported.`,
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
throw new Error(`No Telo.Library manifest found in source "${resource.source as string}"`);
|
|
57
70
|
}
|
|
58
71
|
const targetModule: string = moduleManifest.metadata.name;
|
|
59
72
|
|
|
@@ -102,19 +115,6 @@ export async function create(resource: any, ctx: ResourceContext): Promise<Resou
|
|
|
102
115
|
variables: ctx.expandValue(resource.variables, {}) ?? {},
|
|
103
116
|
secrets: ctx.expandValue(resource.secrets, {}) ?? {},
|
|
104
117
|
}),
|
|
105
|
-
run: async () => {
|
|
106
|
-
// Proxy run to target module
|
|
107
|
-
for (const target of (moduleManifest.targets as string[]) ?? []) {
|
|
108
|
-
await child.run(target);
|
|
109
|
-
}
|
|
110
|
-
},
|
|
111
|
-
invoke: async () => {
|
|
112
|
-
// Proxy run to target module
|
|
113
|
-
// for (const target of (moduleManifest.targets as string[]) ?? []) {
|
|
114
|
-
// child.invoke(target);
|
|
115
|
-
// }
|
|
116
|
-
console.log("invoking");
|
|
117
|
-
},
|
|
118
118
|
init: async () => {
|
|
119
119
|
await child.initializeResources();
|
|
120
120
|
},
|
|
@@ -9,7 +9,7 @@ import { formatAjvErrors, validateResourceDefinition } from "../../manifest-sche
|
|
|
9
9
|
import { createTemplateController } from "./resource-template-controller.js";
|
|
10
10
|
|
|
11
11
|
type ResourceDefinitionResource = RuntimeResource & {
|
|
12
|
-
kind: "
|
|
12
|
+
kind: "Telo.Definition";
|
|
13
13
|
metadata: {
|
|
14
14
|
[key: string]: any;
|
|
15
15
|
name: string;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isCompiledValue,
|
|
3
|
+
isInvokeError,
|
|
3
4
|
resourceKey,
|
|
4
5
|
type EvaluationContext as IEvaluationContext,
|
|
5
6
|
type EmitEvent,
|
|
6
7
|
type InstanceFactory,
|
|
7
8
|
type LifecycleState,
|
|
8
9
|
type PreInitHook,
|
|
10
|
+
type ResourceDefinition,
|
|
9
11
|
type ResourceInstance,
|
|
10
12
|
type ResourceManifest,
|
|
11
13
|
type RuntimeDiagnostic,
|
|
@@ -62,6 +64,13 @@ export class EvaluationContext implements IEvaluationContext {
|
|
|
62
64
|
*/
|
|
63
65
|
preInitHook?: PreInitHook;
|
|
64
66
|
|
|
67
|
+
/**
|
|
68
|
+
* Optional definition lookup used by invoke()/invokeResolved() to check
|
|
69
|
+
* thrown InvokeError.code against the declared throw union (rule 9).
|
|
70
|
+
* Set by the kernel; propagates through spawnChild() like preInitHook.
|
|
71
|
+
*/
|
|
72
|
+
getDefinition?: (kind: string) => ResourceDefinition | undefined;
|
|
73
|
+
|
|
65
74
|
constructor(
|
|
66
75
|
readonly source: string,
|
|
67
76
|
context: Record<string, unknown>,
|
|
@@ -139,6 +148,9 @@ export class EvaluationContext implements IEvaluationContext {
|
|
|
139
148
|
if (this.preInitHook && !child.preInitHook) {
|
|
140
149
|
child.preInitHook = this.preInitHook;
|
|
141
150
|
}
|
|
151
|
+
if (this.getDefinition && !child.getDefinition) {
|
|
152
|
+
child.getDefinition = this.getDefinition;
|
|
153
|
+
}
|
|
142
154
|
return child;
|
|
143
155
|
}
|
|
144
156
|
|
|
@@ -152,18 +164,18 @@ export class EvaluationContext implements IEvaluationContext {
|
|
|
152
164
|
* resource. Successful results go into resourceInstances.
|
|
153
165
|
*
|
|
154
166
|
* Interleaving is necessary because some resources' create() depends on effects
|
|
155
|
-
* produced by other resources' init() (e.g.
|
|
167
|
+
* produced by other resources' init() (e.g. Telo.Import.init() runs
|
|
156
168
|
* child.initializeResources() which registers controllers needed by sibling
|
|
157
169
|
* resources' create()). Running both sub-phases each pass lets those effects
|
|
158
170
|
* propagate before the next create attempt.
|
|
159
171
|
*
|
|
160
172
|
* Each resource is created at most once and inited at most once.
|
|
161
|
-
* ERR_VISIBILITY_DENIED
|
|
173
|
+
* ERR_VISIBILITY_DENIED and ERR_FATAL are re-thrown immediately.
|
|
162
174
|
* All other errors are tracked and retried until no progress is made.
|
|
163
175
|
*/
|
|
164
176
|
async initializeResources(): Promise<void> {
|
|
165
177
|
const MAX_PASSES = 10;
|
|
166
|
-
const errors = new Map<string, string>();
|
|
178
|
+
const errors = new Map<string, { message: string; code?: string; details?: string }>();
|
|
167
179
|
|
|
168
180
|
let pass = 1;
|
|
169
181
|
do {
|
|
@@ -189,8 +201,8 @@ export class EvaluationContext implements IEvaluationContext {
|
|
|
189
201
|
progress = true;
|
|
190
202
|
}
|
|
191
203
|
} catch (error) {
|
|
192
|
-
if (error instanceof RuntimeError && error.code === "ERR_VISIBILITY_DENIED") throw error;
|
|
193
|
-
errors.set(name,
|
|
204
|
+
if (error instanceof RuntimeError && (error.code === "ERR_VISIBILITY_DENIED" || error.code === "ERR_FATAL")) throw error;
|
|
205
|
+
errors.set(name, formatErrorForDiagnostic(error));
|
|
194
206
|
}
|
|
195
207
|
}
|
|
196
208
|
|
|
@@ -211,8 +223,8 @@ export class EvaluationContext implements IEvaluationContext {
|
|
|
211
223
|
errors.delete(name);
|
|
212
224
|
progress = true;
|
|
213
225
|
} catch (error) {
|
|
214
|
-
if (error instanceof RuntimeError && error.code === "ERR_VISIBILITY_DENIED") throw error;
|
|
215
|
-
errors.set(name,
|
|
226
|
+
if (error instanceof RuntimeError && (error.code === "ERR_VISIBILITY_DENIED" || error.code === "ERR_FATAL")) throw error;
|
|
227
|
+
errors.set(name, formatErrorForDiagnostic(error));
|
|
216
228
|
}
|
|
217
229
|
}
|
|
218
230
|
|
|
@@ -222,21 +234,37 @@ export class EvaluationContext implements IEvaluationContext {
|
|
|
222
234
|
|
|
223
235
|
if (this.pendingResources.length > 0 || this.createdInstances.size > 0) {
|
|
224
236
|
const diagnostics: RuntimeDiagnostic[] = [
|
|
225
|
-
...this.pendingResources.map((r) =>
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
237
|
+
...this.pendingResources.map((r) => {
|
|
238
|
+
const info = errors.get(r.metadata.name) ?? { message: "Unknown error" };
|
|
239
|
+
return {
|
|
240
|
+
resource: r.metadata.name,
|
|
241
|
+
kind: r.kind,
|
|
242
|
+
message: info.message,
|
|
243
|
+
details: info.details,
|
|
244
|
+
code: info.code,
|
|
245
|
+
};
|
|
246
|
+
}),
|
|
247
|
+
...[...this.createdInstances].map(([name, { resource }]) => {
|
|
248
|
+
const info = errors.get(name) ?? { message: "Unknown error" };
|
|
249
|
+
return {
|
|
250
|
+
resource: name,
|
|
251
|
+
kind: resource.kind,
|
|
252
|
+
message: info.message,
|
|
253
|
+
details: info.details,
|
|
254
|
+
code: info.code,
|
|
255
|
+
};
|
|
256
|
+
}),
|
|
233
257
|
];
|
|
234
|
-
const
|
|
235
|
-
.map((d) =>
|
|
258
|
+
const textDetails = diagnostics
|
|
259
|
+
.map((d) => {
|
|
260
|
+
const head = ` ${d.kind ? `${d.kind} ` : ""}${d.resource}: ${d.message}${d.code ? ` [${d.code}]` : ""}`;
|
|
261
|
+
const extra = d.details ? "\n" + d.details.split("\n").map((l) => ` ${l}`).join("\n") : "";
|
|
262
|
+
return head + extra;
|
|
263
|
+
})
|
|
236
264
|
.join("\n");
|
|
237
265
|
throw new RuntimeError(
|
|
238
266
|
"ERR_RESOURCE_INITIALIZATION_FAILED",
|
|
239
|
-
`Unable to process resources:\n${
|
|
267
|
+
`Unable to process resources:\n${textDetails}`,
|
|
240
268
|
diagnostics,
|
|
241
269
|
);
|
|
242
270
|
}
|
|
@@ -362,27 +390,98 @@ export class EvaluationContext implements IEvaluationContext {
|
|
|
362
390
|
|
|
363
391
|
/**
|
|
364
392
|
* Invoke a resource by kind and name within this context's resourceInstances.
|
|
365
|
-
* Emits a scoped Invoked event via the injected
|
|
393
|
+
* Emits a scoped Invoked/InvokeRejected/InvokeFailed event via the injected
|
|
394
|
+
* emit callback. The single emission point for invoke-level events — callers
|
|
395
|
+
* holding an already-resolved instance should use invokeResolved() instead.
|
|
366
396
|
*/
|
|
367
397
|
async invoke<TInputs>(kind: string, name: string, inputs: TInputs): Promise<any> {
|
|
368
398
|
const entry = this.resourceInstances.get(name);
|
|
369
399
|
|
|
370
|
-
if (entry) {
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
400
|
+
if (!entry) {
|
|
401
|
+
throw new RuntimeError(
|
|
402
|
+
"ERR_RESOURCE_NOT_FOUND",
|
|
403
|
+
`Resource not found for invocation: ${kind}.${name}. Available resources: ${[...this.resourceInstances.keys()].join(", ")}`,
|
|
404
|
+
);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
if (typeof entry.instance.invoke !== "function") {
|
|
408
|
+
throw new RuntimeError(
|
|
409
|
+
"ERR_RESOURCE_NOT_INVOKABLE",
|
|
410
|
+
`Resource ${kind}.${name} does not have an invoke method`,
|
|
411
|
+
);
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
return this.runInvoke(kind, name, entry.instance, inputs);
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* Like invoke(), but the caller has already resolved the instance (e.g. the
|
|
419
|
+
* scope path in Run.Sequence, or the live-injected Http.Api route handler).
|
|
420
|
+
* Shares the single emission point so events fire exactly once per call
|
|
421
|
+
* regardless of which path reached the instance.
|
|
422
|
+
*/
|
|
423
|
+
async invokeResolved<TInputs>(
|
|
424
|
+
kind: string,
|
|
425
|
+
name: string,
|
|
426
|
+
instance: ResourceInstance,
|
|
427
|
+
inputs: TInputs,
|
|
428
|
+
): Promise<any> {
|
|
429
|
+
if (typeof instance.invoke !== "function") {
|
|
430
|
+
throw new RuntimeError(
|
|
431
|
+
"ERR_RESOURCE_NOT_INVOKABLE",
|
|
432
|
+
`Resource ${kind}.${name} does not have an invoke method`,
|
|
433
|
+
);
|
|
434
|
+
}
|
|
435
|
+
return this.runInvoke(kind, name, instance, inputs);
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
private async runInvoke<TInputs>(
|
|
439
|
+
kind: string,
|
|
440
|
+
name: string,
|
|
441
|
+
instance: ResourceInstance,
|
|
442
|
+
inputs: TInputs,
|
|
443
|
+
): Promise<any> {
|
|
444
|
+
try {
|
|
445
|
+
const outputs = await (instance.invoke as (i: any) => any)(inputs as any);
|
|
378
446
|
await this.emit(`${kind}.${name}.Invoked`, { outputs });
|
|
379
447
|
return outputs;
|
|
448
|
+
} catch (err) {
|
|
449
|
+
if (isInvokeError(err)) {
|
|
450
|
+
const payload = { code: err.code, message: err.message, data: err.data };
|
|
451
|
+
await this.emit(`${kind}.${name}.InvokeRejected`, payload);
|
|
452
|
+
const declaredCodes = this.getDeclaredThrowCodes(kind);
|
|
453
|
+
if (declaredCodes && !declaredCodes.has(err.code)) {
|
|
454
|
+
await this.emit(`${kind}.${name}.InvokeRejected.Undeclared`, payload);
|
|
455
|
+
}
|
|
456
|
+
} else if (err instanceof Error) {
|
|
457
|
+
await this.emit(`${kind}.${name}.InvokeFailed`, {
|
|
458
|
+
name: err.name,
|
|
459
|
+
message: err.message,
|
|
460
|
+
});
|
|
461
|
+
} else {
|
|
462
|
+
await this.emit(`${kind}.${name}.InvokeFailed`, {
|
|
463
|
+
name: "UnknownError",
|
|
464
|
+
message: String(err),
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
throw err;
|
|
380
468
|
}
|
|
469
|
+
}
|
|
381
470
|
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
);
|
|
471
|
+
private getDeclaredThrowCodes(kind: string): Set<string> | null {
|
|
472
|
+
if (!this.getDefinition) return null;
|
|
473
|
+
const def = this.getDefinition(kind);
|
|
474
|
+
if (!def) return null;
|
|
475
|
+
const throws = def.throws;
|
|
476
|
+
if (!throws) return new Set();
|
|
477
|
+
// inherit / passthrough unions are dynamic — resolved statically by the
|
|
478
|
+
// analyzer, not re-derivable here without a manifest-wide traversal. Skip
|
|
479
|
+
// the rule 9 check rather than mis-report every propagated code as
|
|
480
|
+
// undeclared at runtime.
|
|
481
|
+
if (throws.inherit || throws.passthrough) return null;
|
|
482
|
+
const codes = throws.codes;
|
|
483
|
+
if (!codes) return new Set();
|
|
484
|
+
return new Set(Object.keys(codes));
|
|
386
485
|
}
|
|
387
486
|
|
|
388
487
|
async run(name: string): Promise<void> {
|
|
@@ -402,7 +501,13 @@ export class EvaluationContext implements IEvaluationContext {
|
|
|
402
501
|
*/
|
|
403
502
|
expand(value: unknown): unknown {
|
|
404
503
|
if (isCompiledValue(value)) {
|
|
405
|
-
|
|
504
|
+
try {
|
|
505
|
+
return value.call(this._context);
|
|
506
|
+
} catch (error) {
|
|
507
|
+
const expr = value.source ? `\${{ ${value.source} }}` : "unknown expression";
|
|
508
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
509
|
+
throw new Error(`Expression ${expr} failed: ${msg}`);
|
|
510
|
+
}
|
|
406
511
|
}
|
|
407
512
|
if (Array.isArray(value)) {
|
|
408
513
|
return value.map((entry) => this.expand(entry));
|
|
@@ -488,3 +593,93 @@ function setNestedValue(obj: Record<string, unknown>, parts: string[], value: un
|
|
|
488
593
|
}
|
|
489
594
|
current[parts[parts.length - 1]] = value;
|
|
490
595
|
}
|
|
596
|
+
|
|
597
|
+
/**
|
|
598
|
+
* Build a detailed diagnostic from an arbitrary error. Walks the `cause` chain
|
|
599
|
+
* and surfaces structured fields from well-known error shapes (AWS SDK
|
|
600
|
+
* ServiceException, pg DatabaseError, Node system errors) so the user sees the
|
|
601
|
+
* actual failure instead of just an opaque summary string.
|
|
602
|
+
*/
|
|
603
|
+
function formatErrorForDiagnostic(err: unknown): {
|
|
604
|
+
message: string;
|
|
605
|
+
code?: string;
|
|
606
|
+
details?: string;
|
|
607
|
+
} {
|
|
608
|
+
if (!(err instanceof Error)) {
|
|
609
|
+
return { message: String(err) };
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
const detailLines: string[] = [];
|
|
613
|
+
const seen = new Set<unknown>();
|
|
614
|
+
let current: unknown = err;
|
|
615
|
+
let depth = 0;
|
|
616
|
+
let topCode: string | undefined;
|
|
617
|
+
let topMessage = "";
|
|
618
|
+
|
|
619
|
+
while (current instanceof Error && !seen.has(current)) {
|
|
620
|
+
seen.add(current);
|
|
621
|
+
const info = extractErrorInfo(current);
|
|
622
|
+
if (depth === 0) {
|
|
623
|
+
topMessage = info.summary;
|
|
624
|
+
topCode = info.code;
|
|
625
|
+
} else {
|
|
626
|
+
detailLines.push(`Caused by: ${info.summary}`);
|
|
627
|
+
}
|
|
628
|
+
for (const field of info.fields) {
|
|
629
|
+
detailLines.push(field);
|
|
630
|
+
}
|
|
631
|
+
current = (current as { cause?: unknown }).cause;
|
|
632
|
+
depth++;
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
return {
|
|
636
|
+
message: topMessage || err.message || err.name || String(err),
|
|
637
|
+
code: topCode,
|
|
638
|
+
details: detailLines.length ? detailLines.join("\n") : undefined,
|
|
639
|
+
};
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
function extractErrorInfo(e: Error): { summary: string; code?: string; fields: string[] } {
|
|
643
|
+
const fields: string[] = [];
|
|
644
|
+
const anyE = e as unknown as Record<string, unknown>;
|
|
645
|
+
|
|
646
|
+
const name = e.name && e.name.toLowerCase() !== "error" ? e.name : undefined;
|
|
647
|
+
const code = anyE.code !== undefined && anyE.code !== null ? String(anyE.code) : undefined;
|
|
648
|
+
const message = e.message && e.message.trim() ? e.message : "(no message)";
|
|
649
|
+
|
|
650
|
+
const summary = name ? `${name}: ${message}` : message;
|
|
651
|
+
|
|
652
|
+
const metadata = anyE.$metadata as Record<string, unknown> | undefined;
|
|
653
|
+
if (metadata && typeof metadata === "object") {
|
|
654
|
+
if (metadata.httpStatusCode != null) fields.push(`HTTP status: ${metadata.httpStatusCode}`);
|
|
655
|
+
if (metadata.requestId) fields.push(`Request ID: ${metadata.requestId}`);
|
|
656
|
+
if (metadata.extendedRequestId) fields.push(`Extended request ID: ${metadata.extendedRequestId}`);
|
|
657
|
+
if (metadata.cfId) fields.push(`CF ID: ${metadata.cfId}`);
|
|
658
|
+
if (metadata.attempts != null) fields.push(`Attempts: ${metadata.attempts}`);
|
|
659
|
+
if (metadata.totalRetryDelay != null) fields.push(`Total retry delay: ${metadata.totalRetryDelay}ms`);
|
|
660
|
+
}
|
|
661
|
+
if (anyE.$fault) fields.push(`Fault: ${String(anyE.$fault)}`);
|
|
662
|
+
|
|
663
|
+
if (anyE.severity) fields.push(`Severity: ${String(anyE.severity)}`);
|
|
664
|
+
if (anyE.detail) fields.push(`Detail: ${String(anyE.detail)}`);
|
|
665
|
+
if (anyE.hint) fields.push(`Hint: ${String(anyE.hint)}`);
|
|
666
|
+
if (anyE.schema) fields.push(`Schema: ${String(anyE.schema)}`);
|
|
667
|
+
if (anyE.table) fields.push(`Table: ${String(anyE.table)}`);
|
|
668
|
+
if (anyE.column) fields.push(`Column: ${String(anyE.column)}`);
|
|
669
|
+
if (anyE.dataType) fields.push(`Data type: ${String(anyE.dataType)}`);
|
|
670
|
+
if (anyE.constraint) fields.push(`Constraint: ${String(anyE.constraint)}`);
|
|
671
|
+
if (anyE.routine) fields.push(`Routine: ${String(anyE.routine)}`);
|
|
672
|
+
if (anyE.where) fields.push(`Where: ${String(anyE.where)}`);
|
|
673
|
+
if (anyE.position) fields.push(`Position: ${String(anyE.position)}`);
|
|
674
|
+
if (anyE.internalPosition) fields.push(`Internal position: ${String(anyE.internalPosition)}`);
|
|
675
|
+
if (anyE.internalQuery) fields.push(`Internal query: ${String(anyE.internalQuery)}`);
|
|
676
|
+
|
|
677
|
+
if (anyE.syscall) fields.push(`Syscall: ${String(anyE.syscall)}`);
|
|
678
|
+
if (anyE.errno != null) fields.push(`Errno: ${String(anyE.errno)}`);
|
|
679
|
+
if (anyE.address) fields.push(`Address: ${String(anyE.address)}`);
|
|
680
|
+
if (anyE.port != null) fields.push(`Port: ${String(anyE.port)}`);
|
|
681
|
+
if (anyE.hostname) fields.push(`Hostname: ${String(anyE.hostname)}`);
|
|
682
|
+
if (anyE.path && !anyE.routine) fields.push(`Path: ${String(anyE.path)}`);
|
|
683
|
+
|
|
684
|
+
return { summary, code, fields };
|
|
685
|
+
}
|