@telorun/kernel 0.15.0 → 0.16.1
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/controller-loaders/npm-loader.d.ts.map +1 -1
- package/dist/controller-loaders/npm-loader.js +24 -1
- package/dist/controller-loaders/npm-loader.js.map +1 -1
- package/dist/controllers/module/import-controller.d.ts.map +1 -1
- package/dist/controllers/module/import-controller.js +50 -8
- package/dist/controllers/module/import-controller.js.map +1 -1
- package/dist/evaluation-context.d.ts +7 -0
- package/dist/evaluation-context.d.ts.map +1 -1
- package/dist/evaluation-context.js +24 -3
- package/dist/evaluation-context.js.map +1 -1
- package/dist/kernel.d.ts.map +1 -1
- package/dist/kernel.js +21 -4
- package/dist/kernel.js.map +1 -1
- package/dist/module-context.d.ts +25 -1
- package/dist/module-context.d.ts.map +1 -1
- package/dist/module-context.js +47 -2
- package/dist/module-context.js.map +1 -1
- package/dist/resource-context.d.ts +2 -0
- package/dist/resource-context.d.ts.map +1 -1
- package/dist/resource-context.js +19 -1
- package/dist/resource-context.js.map +1 -1
- package/package.json +6 -5
- package/src/controller-loaders/npm-loader.ts +26 -1
- package/src/controllers/module/import-controller.ts +66 -17
- package/src/evaluation-context.ts +30 -5
- package/src/kernel.ts +31 -6
- package/src/module-context.ts +62 -2
- package/src/resource-context.ts +27 -2
- 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/local-file-adapter.d.ts +0 -15
- package/dist/manifest-adapters/local-file-adapter.d.ts.map +0 -1
- package/dist/manifest-adapters/local-file-adapter.js +0 -95
- package/dist/manifest-adapters/local-file-adapter.js.map +0 -1
- package/dist/manifest-adapters/manifest-adapter.d.ts +0 -35
- package/dist/manifest-adapters/manifest-adapter.d.ts.map +0 -1
- package/dist/manifest-adapters/manifest-adapter.js +0 -2
- package/dist/manifest-adapters/manifest-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
|
@@ -202,6 +202,16 @@ export class EvaluationContext implements IEvaluationContext {
|
|
|
202
202
|
return child;
|
|
203
203
|
}
|
|
204
204
|
|
|
205
|
+
/**
|
|
206
|
+
* Resolve a cross-module exported instance (`!ref Alias.name`) to its live instance.
|
|
207
|
+
* Overridable hook: the base context has no imports, so it returns undefined; ModuleContext
|
|
208
|
+
* overrides it to route into the named import's child context. Declared here so the
|
|
209
|
+
* injection / scope closures in this base class can call it without downcasting.
|
|
210
|
+
*/
|
|
211
|
+
resolveImportedInstance(alias: string, name: string): ResourceInstance | undefined {
|
|
212
|
+
return undefined;
|
|
213
|
+
}
|
|
214
|
+
|
|
205
215
|
/**
|
|
206
216
|
* Interleaved create/init loop.
|
|
207
217
|
*
|
|
@@ -259,7 +269,11 @@ export class EvaluationContext implements IEvaluationContext {
|
|
|
259
269
|
if (this.resourceInstances.has(name)) continue;
|
|
260
270
|
try {
|
|
261
271
|
if (this.preInitHook) {
|
|
262
|
-
this.preInitHook(resource, (n) =>
|
|
272
|
+
this.preInitHook(resource, (n, alias) =>
|
|
273
|
+
alias && alias !== "Self"
|
|
274
|
+
? this.resolveImportedInstance(alias, n)
|
|
275
|
+
: this.resourceInstances.get(n)?.instance,
|
|
276
|
+
);
|
|
263
277
|
}
|
|
264
278
|
if (instance.init) await instance.init(ctx);
|
|
265
279
|
if (instance.snapshot) {
|
|
@@ -370,9 +384,10 @@ export class EvaluationContext implements IEvaluationContext {
|
|
|
370
384
|
if (parent.preInitHook) {
|
|
371
385
|
const parentHook = parent.preInitHook;
|
|
372
386
|
child.preInitHook = (resource, childGetInstance) => {
|
|
373
|
-
parentHook(
|
|
374
|
-
|
|
375
|
-
|
|
387
|
+
parentHook(resource, (name, alias) =>
|
|
388
|
+
alias && alias !== "Self"
|
|
389
|
+
? parent.resolveImportedInstance(alias, name)
|
|
390
|
+
: childGetInstance(name) ?? parent.resourceInstances.get(name)?.instance,
|
|
376
391
|
);
|
|
377
392
|
};
|
|
378
393
|
}
|
|
@@ -383,7 +398,17 @@ export class EvaluationContext implements IEvaluationContext {
|
|
|
383
398
|
}
|
|
384
399
|
await child.initializeResources();
|
|
385
400
|
const scope: ScopeContext = {
|
|
386
|
-
getInstance(name: string): ResourceInstance {
|
|
401
|
+
getInstance(name: string, alias?: string): ResourceInstance {
|
|
402
|
+
// Cross-module exported instance (`!ref Alias.name` inside the scope) —
|
|
403
|
+
// route into the owning import's child context, not scope-local resources.
|
|
404
|
+
if (alias && alias !== "Self") {
|
|
405
|
+
const imported = parent.resolveImportedInstance(alias, name);
|
|
406
|
+
if (imported) return imported;
|
|
407
|
+
throw new RuntimeError(
|
|
408
|
+
"ERR_SCOPE_RESOURCE_NOT_FOUND",
|
|
409
|
+
`Cross-module reference '${alias}.${name}' did not resolve to an exported instance.`,
|
|
410
|
+
);
|
|
411
|
+
}
|
|
387
412
|
const childEntry = child.resourceInstances.get(name);
|
|
388
413
|
if (childEntry) return childEntry.instance;
|
|
389
414
|
const parentEntry = parent.resourceInstances.get(name);
|
package/src/kernel.ts
CHANGED
|
@@ -381,7 +381,14 @@ export class Kernel implements IKernel {
|
|
|
381
381
|
// into first-class named manifests and replace them in-place with {kind, name} references.
|
|
382
382
|
// Update staticManifests so Phase 3 (validateReferences) and Phase 4 (DAG) see
|
|
383
383
|
// the same normalized structure.
|
|
384
|
-
|
|
384
|
+
// Pass the analyzer-flattened set (entry + forwarded library exports) as cross-module
|
|
385
|
+
// resolution targets so `!ref Alias.name` in the entry-only runtime manifests resolves
|
|
386
|
+
// to imported libraries' exported instances.
|
|
387
|
+
const normalizedManifests = this.analyzer.normalize(
|
|
388
|
+
allManifests,
|
|
389
|
+
this.registry,
|
|
390
|
+
staticManifests,
|
|
391
|
+
);
|
|
385
392
|
this.staticManifests = normalizedManifests;
|
|
386
393
|
|
|
387
394
|
let rootApplicationManifest: ResourceManifest | undefined;
|
|
@@ -855,7 +862,7 @@ export class Kernel implements IKernel {
|
|
|
855
862
|
*/
|
|
856
863
|
private _injectDependencies(
|
|
857
864
|
resource: ResourceManifest,
|
|
858
|
-
getInstance: (name: string) => ResourceInstance | undefined,
|
|
865
|
+
getInstance: (name: string, alias?: string) => ResourceInstance | undefined,
|
|
859
866
|
): void {
|
|
860
867
|
this.registry.iterateFieldEntries(
|
|
861
868
|
resource,
|
|
@@ -1039,10 +1046,28 @@ function collectEvalPathsNode(
|
|
|
1039
1046
|
function injectAtPath(
|
|
1040
1047
|
resource: ResourceManifest,
|
|
1041
1048
|
fieldPath: string,
|
|
1042
|
-
getInstance: (name: string) => ResourceInstance | undefined,
|
|
1049
|
+
getInstance: (name: string, alias?: string) => ResourceInstance | undefined,
|
|
1043
1050
|
): void {
|
|
1044
1051
|
const parts = fieldPath.split(".");
|
|
1045
1052
|
|
|
1053
|
+
// Resolve a {kind, name, alias?} reference to its live instance. A non-`Self` alias is a
|
|
1054
|
+
// cross-module reference into an import's published exports; if that import hasn't
|
|
1055
|
+
// finished init() yet the instance is absent, so we throw to defer this resource to a
|
|
1056
|
+
// later pass of the multi-pass init loop (which catches and retries) rather than leaving
|
|
1057
|
+
// the ref unresolved. Local refs (no alias) that miss are left for topo ordering / later
|
|
1058
|
+
// diagnostics, matching prior behaviour.
|
|
1059
|
+
function resolveInto(ref: Record<string, unknown>): ResourceInstance | undefined {
|
|
1060
|
+
const alias = typeof ref.alias === "string" ? ref.alias : undefined;
|
|
1061
|
+
const instance = getInstance(ref.name as string, alias);
|
|
1062
|
+
if (!instance && alias && alias !== "Self") {
|
|
1063
|
+
throw new RuntimeError(
|
|
1064
|
+
"ERR_CROSS_MODULE_REF_PENDING",
|
|
1065
|
+
`Cross-module reference '${alias}.${String(ref.name)}' is not available yet (import not initialized)`,
|
|
1066
|
+
);
|
|
1067
|
+
}
|
|
1068
|
+
return instance;
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1046
1071
|
function traverse(obj: unknown, partsLeft: string[]): void {
|
|
1047
1072
|
if (!obj || typeof obj !== "object" || partsLeft.length === 0) return;
|
|
1048
1073
|
const [head, ...rest] = partsLeft;
|
|
@@ -1057,7 +1082,7 @@ function injectAtPath(
|
|
|
1057
1082
|
if (rest.length === 0) {
|
|
1058
1083
|
const ref = elem as Record<string, unknown>;
|
|
1059
1084
|
if (typeof ref.kind === "string" && typeof ref.name === "string") {
|
|
1060
|
-
const instance =
|
|
1085
|
+
const instance = resolveInto(ref);
|
|
1061
1086
|
if (instance) container[mapKey] = instance;
|
|
1062
1087
|
}
|
|
1063
1088
|
} else {
|
|
@@ -1081,7 +1106,7 @@ function injectAtPath(
|
|
|
1081
1106
|
if (rest.length === 0) {
|
|
1082
1107
|
const ref = elem as Record<string, unknown>;
|
|
1083
1108
|
if (typeof ref.kind === "string" && typeof ref.name === "string") {
|
|
1084
|
-
const instance =
|
|
1109
|
+
const instance = resolveInto(ref);
|
|
1085
1110
|
if (instance) val[i] = instance;
|
|
1086
1111
|
}
|
|
1087
1112
|
} else {
|
|
@@ -1093,7 +1118,7 @@ function injectAtPath(
|
|
|
1093
1118
|
if (val && typeof val === "object" && !Array.isArray(val)) {
|
|
1094
1119
|
const ref = val as Record<string, unknown>;
|
|
1095
1120
|
if (typeof ref.kind === "string" && typeof ref.name === "string") {
|
|
1096
|
-
const instance =
|
|
1121
|
+
const instance = resolveInto(ref);
|
|
1097
1122
|
if (instance) container[key] = instance;
|
|
1098
1123
|
}
|
|
1099
1124
|
}
|
package/src/module-context.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type {
|
|
|
6
6
|
InvokeStep,
|
|
7
7
|
InvokeStepContext,
|
|
8
8
|
ModuleContext as IModuleContext,
|
|
9
|
+
ResourceInstance,
|
|
9
10
|
} from "@telorun/sdk";
|
|
10
11
|
import type { EmitEvent, InstanceFactory } from "@telorun/sdk";
|
|
11
12
|
import { EvaluationContext } from "./evaluation-context.js";
|
|
@@ -72,6 +73,18 @@ export class ModuleContext extends EvaluationContext implements IModuleContext {
|
|
|
72
73
|
/** Maps import alias → allowed kind names. Absent entry = unrestricted (e.g. Kernel). */
|
|
73
74
|
private readonly importedKinds = new Map<string, Set<string>>();
|
|
74
75
|
|
|
76
|
+
/** Maps import alias → its child context's exported instances. Registered by the
|
|
77
|
+
* Telo.Import controller; read when resolving a cross-module `!ref Alias.name`
|
|
78
|
+
* reference (Phase 5 injection and boot targets). `names` is the import's
|
|
79
|
+
* `exports.resources` gate — only listed instances are reachable. */
|
|
80
|
+
private readonly importedScopes = new Map<
|
|
81
|
+
string,
|
|
82
|
+
{
|
|
83
|
+
names: Set<string>;
|
|
84
|
+
get: (name: string) => { kind: string; instance: ResourceInstance } | undefined;
|
|
85
|
+
}
|
|
86
|
+
>();
|
|
87
|
+
|
|
75
88
|
/**
|
|
76
89
|
* Resolved controller-selection policy for this module's `Telo.Definition`s.
|
|
77
90
|
* Stamped by the parent `Telo.Import` controller from the import's `runtime:`
|
|
@@ -161,6 +174,37 @@ export class ModuleContext extends EvaluationContext implements IModuleContext {
|
|
|
161
174
|
}
|
|
162
175
|
}
|
|
163
176
|
|
|
177
|
+
/** Register an import alias's exported instances for cross-module reference resolution.
|
|
178
|
+
* `names` is the gate (the import's `exports.resources`); `get` reads the child context's
|
|
179
|
+
* live instance + its canonical kind lazily — they exist only after the import's `init()`
|
|
180
|
+
* runs. */
|
|
181
|
+
registerImportedScope(
|
|
182
|
+
alias: string,
|
|
183
|
+
names: string[],
|
|
184
|
+
get: (name: string) => { kind: string; instance: ResourceInstance } | undefined,
|
|
185
|
+
): void {
|
|
186
|
+
this.importedScopes.set(alias, { names: new Set(names), get });
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/** Resolve `Alias.name` to a live exported instance, gated by `exports.resources`.
|
|
190
|
+
* Returns undefined when the alias is unknown, the name isn't exported, or the import
|
|
191
|
+
* hasn't initialized its instances yet (the injection path defers and retries). */
|
|
192
|
+
override resolveImportedInstance(alias: string, name: string): ResourceInstance | undefined {
|
|
193
|
+
const scope = this.importedScopes.get(alias);
|
|
194
|
+
if (!scope || !scope.names.has(name)) return undefined;
|
|
195
|
+
return scope.get(name)?.instance;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/** Like `resolveImportedInstance`, but returns the `{kind, name}` ref (canonical kind)
|
|
199
|
+
* for controllers that resolve step/handler invokes to refs rather than live instances
|
|
200
|
+
* (e.g. Run.Sequence via `resolveChildren`). The alias is reattached by the caller. */
|
|
201
|
+
resolveImportedRef(alias: string, name: string): { kind: string; name: string } | undefined {
|
|
202
|
+
const scope = this.importedScopes.get(alias);
|
|
203
|
+
if (!scope || !scope.names.has(name)) return undefined;
|
|
204
|
+
const entry = scope.get(name);
|
|
205
|
+
return entry ? { kind: entry.kind, name } : undefined;
|
|
206
|
+
}
|
|
207
|
+
|
|
164
208
|
hasImport(alias: string): boolean {
|
|
165
209
|
return this.importAliases.has(alias);
|
|
166
210
|
}
|
|
@@ -266,6 +310,7 @@ export class ModuleContext extends EvaluationContext implements IModuleContext {
|
|
|
266
310
|
invoke: (kind, name, inputs) => this.invoke(kind, name, inputs),
|
|
267
311
|
invokeResolved: (kind, name, instance, inputs) =>
|
|
268
312
|
this.invokeResolved(kind, name, instance, inputs),
|
|
313
|
+
resolveImportedInstance: (alias, name) => this.resolveImportedInstance(alias, name),
|
|
269
314
|
};
|
|
270
315
|
for (let i = 0; i < this.targets.length; i++) {
|
|
271
316
|
const target = this.targets[i]!;
|
|
@@ -277,6 +322,9 @@ export class ModuleContext extends EvaluationContext implements IModuleContext {
|
|
|
277
322
|
const step: InvokeStep = {
|
|
278
323
|
name: target.name ?? `Target${i}`,
|
|
279
324
|
when: target.when,
|
|
325
|
+
// A cross-module `!ref Alias.name` stays a `{kind, name, alias}` ref; the leaf's
|
|
326
|
+
// alias branch resolves it via `resolveImportedInstance` and dispatches through
|
|
327
|
+
// `invokeResolved` so invocation events and error wrapping still fire.
|
|
280
328
|
invoke: target.invoke,
|
|
281
329
|
inputs: target.inputs,
|
|
282
330
|
};
|
|
@@ -284,9 +332,21 @@ export class ModuleContext extends EvaluationContext implements IModuleContext {
|
|
|
284
332
|
continue;
|
|
285
333
|
}
|
|
286
334
|
if ("ref" in target && target.ref != null) {
|
|
287
|
-
const refName = typeof target.ref === "string" ? target.ref : target.ref.name;
|
|
288
335
|
if (target.when === undefined || this.expandWith(target.when, { steps })) {
|
|
289
|
-
|
|
336
|
+
const ref = target.ref as unknown;
|
|
337
|
+
const r =
|
|
338
|
+
ref && typeof ref === "object" ? (ref as { name: string; alias?: string }) : undefined;
|
|
339
|
+
if (r && typeof r.alias === "string" && r.alias !== "Self") {
|
|
340
|
+
const inst = this.resolveImportedInstance(r.alias, r.name);
|
|
341
|
+
if (!inst || typeof inst.run !== "function") {
|
|
342
|
+
throw new Error(
|
|
343
|
+
`Boot target '${r.alias}.${r.name}' is not a runnable exported instance`,
|
|
344
|
+
);
|
|
345
|
+
}
|
|
346
|
+
await inst.run();
|
|
347
|
+
} else {
|
|
348
|
+
await this.run(typeof ref === "string" ? ref : r!.name);
|
|
349
|
+
}
|
|
290
350
|
}
|
|
291
351
|
continue;
|
|
292
352
|
}
|
package/src/resource-context.ts
CHANGED
|
@@ -161,6 +161,10 @@ export class ResourceContextImpl implements ResourceContext {
|
|
|
161
161
|
return this.moduleContext.invokeResolved(kind, name, instance, inputs);
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
+
resolveImportedInstance(alias: string, name: string): ResourceInstance | undefined {
|
|
165
|
+
return this.moduleContext.resolveImportedInstance(alias, name);
|
|
166
|
+
}
|
|
167
|
+
|
|
164
168
|
async run(name: string) {
|
|
165
169
|
await this.moduleContext.run(name);
|
|
166
170
|
}
|
|
@@ -195,7 +199,10 @@ export class ResourceContextImpl implements ResourceContext {
|
|
|
195
199
|
* @returns Normalized {kind, name} reference
|
|
196
200
|
* @throws RuntimeError if 'kind' is missing
|
|
197
201
|
*/
|
|
198
|
-
resolveChildren(
|
|
202
|
+
resolveChildren(
|
|
203
|
+
resource: any,
|
|
204
|
+
resourceName?: string,
|
|
205
|
+
): { kind: string; name: string; alias?: string } {
|
|
199
206
|
if (!resource || typeof resource !== "object") {
|
|
200
207
|
throw new RuntimeError(
|
|
201
208
|
"ERR_INVALID_VALUE",
|
|
@@ -217,7 +224,25 @@ export class ResourceContextImpl implements ResourceContext {
|
|
|
217
224
|
// this rescue — schemas exercising those hidden slots must use the
|
|
218
225
|
// legacy string or `{kind, name}` forms for now.
|
|
219
226
|
if (isRefSentinel(resource)) {
|
|
220
|
-
const
|
|
227
|
+
const source = resource.source;
|
|
228
|
+
const dot = source.indexOf(".");
|
|
229
|
+
const alias = dot > 0 ? source.slice(0, dot) : undefined;
|
|
230
|
+
// Cross-module exported instance (`!ref Alias.name`) — resolve the {kind, name} ref
|
|
231
|
+
// from the import's exported scope and reattach the alias so downstream scope
|
|
232
|
+
// resolution (executeInvokeStep → ScopeContext.getInstance) routes into the import's
|
|
233
|
+
// child context rather than scope-local resources.
|
|
234
|
+
if (alias && alias !== "Self") {
|
|
235
|
+
const name = source.slice(dot + 1);
|
|
236
|
+
const ref = this.moduleContext.resolveImportedRef(alias, name);
|
|
237
|
+
if (!ref) {
|
|
238
|
+
throw new RuntimeError(
|
|
239
|
+
"ERR_RESOURCE_NOT_FOUND",
|
|
240
|
+
`[${this.metadata.name}] !ref '${source}' is not an exported instance of import '${alias}'.`,
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
return { kind: ref.kind, name: ref.name, alias };
|
|
244
|
+
}
|
|
245
|
+
const refName = alias === "Self" ? source.slice(dot + 1) : source;
|
|
221
246
|
const entry = this.moduleContext.resourceInstances.get(refName);
|
|
222
247
|
if (!entry) {
|
|
223
248
|
throw new RuntimeError(
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { ModuleContext, ResourceContext, ResourceDefinition, ResourceInstance, ResourceManifest } from "@telorun/sdk";
|
|
2
|
-
export interface BaseDefinition {
|
|
3
|
-
name: string;
|
|
4
|
-
expand?: {
|
|
5
|
-
compile?: string[];
|
|
6
|
-
runtime?: string[];
|
|
7
|
-
};
|
|
8
|
-
onDefinition?(definition: ResourceDefinition, ctx: ResourceContext): void | Promise<void>;
|
|
9
|
-
onManifest?(manifest: ResourceManifest, ctx: ModuleContext): ResourceManifest | Promise<ResourceManifest>;
|
|
10
|
-
onInit?(instance: ResourceInstance, ctx: ResourceContext): Promise<void>;
|
|
11
|
-
onInvoke?(instance: ResourceInstance, inputs: any, ctx: ResourceContext): Promise<any>;
|
|
12
|
-
}
|
|
13
|
-
export declare function createBaseDefinition(def: BaseDefinition): BaseDefinition;
|
|
14
|
-
//# sourceMappingURL=base-definition.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base-definition.d.ts","sourceRoot":"","sources":["../src/base-definition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,cAAc,CAAC;AAEtB,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE;QACP,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;QACnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;KACpB,CAAC;IACF,YAAY,CAAC,CAAC,UAAU,EAAE,kBAAkB,EAAE,GAAG,EAAE,eAAe,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1F,UAAU,CAAC,CACT,QAAQ,EAAE,gBAAgB,EAC1B,GAAG,EAAE,aAAa,GACjB,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAChD,MAAM,CAAC,CAAC,QAAQ,EAAE,gBAAgB,EAAE,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACzE,QAAQ,CAAC,CAAC,QAAQ,EAAE,gBAAgB,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;CACxF;AAED,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,cAAc,GAAG,cAAc,CAoBxE"}
|
package/dist/base-definition.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export function createBaseDefinition(def) {
|
|
2
|
-
const compile = def.expand?.compile ?? [];
|
|
3
|
-
const runtime = def.expand?.runtime ?? [];
|
|
4
|
-
return {
|
|
5
|
-
...def,
|
|
6
|
-
onManifest: compile.length
|
|
7
|
-
? (manifest, ctx) => ctx.expandPaths(manifest, compile, runtime)
|
|
8
|
-
: def.onManifest,
|
|
9
|
-
onInvoke: runtime.length
|
|
10
|
-
? async (instance, inputs, _ctx) => {
|
|
11
|
-
const expanded = _ctx.moduleContext.expandPaths(inputs, runtime);
|
|
12
|
-
return instance.invoke(expanded);
|
|
13
|
-
}
|
|
14
|
-
: def.onInvoke,
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=base-definition.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base-definition.js","sourceRoot":"","sources":["../src/base-definition.ts"],"names":[],"mappings":"AAuBA,MAAM,UAAU,oBAAoB,CAAC,GAAmB;IACtD,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,EAAE,OAAO,IAAI,EAAE,CAAC;IAC1C,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,EAAE,OAAO,IAAI,EAAE,CAAC;IAE1C,OAAO;QACL,GAAG,GAAG;QACN,UAAU,EAAE,OAAO,CAAC,MAAM;YACxB,CAAC,CAAC,CAAC,QAAQ,EAAE,GAAG,EAAE,EAAE,CAChB,GAAG,CAAC,WAAW,CAAC,QAAmC,EAAE,OAAO,EAAE,OAAO,CAAqB;YAC9F,CAAC,CAAC,GAAG,CAAC,UAAU;QAClB,QAAQ,EAAE,OAAO,CAAC,MAAM;YACtB,CAAC,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE;gBAC/B,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,WAAW,CAC7C,MAAiC,EACjC,OAAO,CACR,CAAC;gBACF,OAAO,QAAQ,CAAC,MAAO,CAAC,QAAQ,CAAC,CAAC;YACpC,CAAC;YACH,CAAC,CAAC,GAAG,CAAC,QAAQ;KACjB,CAAC;AACJ,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../src/capabilities/component.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,eAAO,MAAM,SAAS,EAAE,cAEvB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sourceRoot":"","sources":["../../src/capabilities/component.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,SAAS,GAAmB;IACvC,IAAI,EAAE,WAAW;CAClB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"executable.d.ts","sourceRoot":"","sources":["../../src/capabilities/executable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEvD,eAAO,MAAM,QAAQ,EAAE,kBAGtB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"executable.js","sourceRoot":"","sources":["../../src/capabilities/executable.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,QAAQ,GAAuB;IAC1C,IAAI,EAAE,iBAAiB;IACvB,QAAQ,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE;CACjD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/capabilities/handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,eAAO,MAAM,OAAO,EAAE,cAErB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../../src/capabilities/handler.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,OAAO,GAAmB;IACrC,IAAI,EAAE,SAAS;CAChB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"invokable.d.ts","sourceRoot":"","sources":["../../src/capabilities/invokable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEvD,eAAO,MAAM,SAAS,EAAE,kBAGvB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"invokable.js","sourceRoot":"","sources":["../../src/capabilities/invokable.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,SAAS,GAAuB;IAC3C,IAAI,EAAE,iBAAiB;IACvB,QAAQ,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE;CAClD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"listener.d.ts","sourceRoot":"","sources":["../../src/capabilities/listener.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEvD,eAAO,MAAM,OAAO,EAAE,kBAGrB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"listener.js","sourceRoot":"","sources":["../../src/capabilities/listener.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,OAAO,GAAuB;IACzC,IAAI,EAAE,iBAAiB;IACvB,QAAQ,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE;CAChD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mount.d.ts","sourceRoot":"","sources":["../../src/capabilities/mount.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEvD,eAAO,MAAM,KAAK,EAAE,kBAGnB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mount.js","sourceRoot":"","sources":["../../src/capabilities/mount.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,KAAK,GAAuB;IACvC,IAAI,EAAE,iBAAiB;IACvB,QAAQ,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE;CAC9C,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/capabilities/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEvD,eAAO,MAAM,QAAQ,EAAE,kBAMtB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../src/capabilities/provider.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,QAAQ,GAAuB;IAC1C,IAAI,EAAE,iBAAiB;IACvB,QAAQ,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE;IAChD,MAAM,EAAE;QACN,OAAO,EAAE,CAAC,IAAI,CAAC;KAChB;CACF,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runnable.d.ts","sourceRoot":"","sources":["../../src/capabilities/runnable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEvD,eAAO,MAAM,QAAQ,EAAE,kBAGtB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runnable.js","sourceRoot":"","sources":["../../src/capabilities/runnable.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,QAAQ,GAAuB;IAC1C,IAAI,EAAE,iBAAiB;IACvB,QAAQ,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE;CACjD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/capabilities/service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEvD,eAAO,MAAM,OAAO,EAAE,kBAGrB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/capabilities/service.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,OAAO,GAAuB;IACzC,IAAI,EAAE,iBAAiB;IACvB,QAAQ,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE;CAChD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../../src/capabilities/template.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEvD,eAAO,MAAM,QAAQ,EAAE,kBAGtB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../src/capabilities/template.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,QAAQ,GAAuB;IAC1C,IAAI,EAAE,iBAAiB;IACvB,QAAQ,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE;CACjD,CAAC"}
|