@telorun/sdk 0.36.0 → 0.41.0
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/dispatch-invoke-ref.d.ts +6 -2
- package/dist/dispatch-invoke-ref.d.ts.map +1 -1
- package/dist/dispatch-invoke-ref.js +7 -2
- package/dist/evaluation-context.d.ts +21 -0
- package/dist/evaluation-context.d.ts.map +1 -1
- package/dist/resource-context.d.ts +7 -0
- package/dist/resource-context.d.ts.map +1 -1
- package/dist/type-schema-ref.d.ts +24 -0
- package/dist/type-schema-ref.d.ts.map +1 -1
- package/dist/type-schema-ref.js +86 -0
- package/package.json +1 -1
- package/src/dispatch-invoke-ref.ts +11 -4
- package/src/evaluation-context.ts +20 -0
- package/src/resource-context.ts +7 -0
- package/src/type-schema-ref.ts +79 -0
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import type { InvokeContext } from "./cancellation.js";
|
|
1
2
|
import type { ModuleContext } from "./module-context.js";
|
|
2
3
|
import { type ResourceInstance } from "./resource-instance.js";
|
|
3
4
|
/** The context a decorator kind composes to dispatch its wrapped target. */
|
|
4
5
|
export interface DispatchContext {
|
|
5
|
-
invokeResolved<TInputs>(kind: string, name: string, instance: ResourceInstance, inputs: TInputs): Promise<unknown>;
|
|
6
|
+
invokeResolved<TInputs>(kind: string, name: string, instance: ResourceInstance, inputs: TInputs, ctx?: InvokeContext): Promise<unknown>;
|
|
6
7
|
readonly moduleContext: ModuleContext;
|
|
7
8
|
}
|
|
8
9
|
/**
|
|
@@ -12,6 +13,9 @@ export interface DispatchContext {
|
|
|
12
13
|
* against the module context. Resolution is eager (fail-fast on a bad ref);
|
|
13
14
|
* dispatch is deferred, so a caller can run it synchronously (Cache.View) or
|
|
14
15
|
* detached (Run.Detach). `describe` labels the error with the owning resource.
|
|
16
|
+
* The thunk's optional second argument seeds the dispatch's {@link InvokeContext}
|
|
17
|
+
* (e.g. a decorator-owned cancellation scope); when omitted the ambient
|
|
18
|
+
* invocation context applies unchanged.
|
|
15
19
|
*/
|
|
16
|
-
export declare function resolveInvocableDispatcher(field: unknown, ctx: DispatchContext, describe: () => string): (inputs: Record<string, unknown
|
|
20
|
+
export declare function resolveInvocableDispatcher(field: unknown, ctx: DispatchContext, describe: () => string): (inputs: Record<string, unknown>, invokeCtx?: InvokeContext) => Promise<unknown>;
|
|
17
21
|
//# sourceMappingURL=dispatch-invoke-ref.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatch-invoke-ref.d.ts","sourceRoot":"","sources":["../src/dispatch-invoke-ref.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dispatch-invoke-ref.d.ts","sourceRoot":"","sources":["../src/dispatch-invoke-ref.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAkB,KAAK,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/E,4EAA4E;AAC5E,MAAM,WAAW,eAAe;IAC9B,cAAc,CAAC,OAAO,EACpB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,gBAAgB,EAC1B,MAAM,EAAE,OAAO,EACf,GAAG,CAAC,EAAE,aAAa,GAClB,OAAO,CAAC,OAAO,CAAC,CAAC;IACpB,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;CACvC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,eAAe,EACpB,QAAQ,EAAE,MAAM,MAAM,GACrB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS,CAAC,EAAE,aAAa,KAAK,OAAO,CAAC,OAAO,CAAC,CAsBlF"}
|
|
@@ -6,12 +6,17 @@ import { getRefIdentity } from "./resource-instance.js";
|
|
|
6
6
|
* against the module context. Resolution is eager (fail-fast on a bad ref);
|
|
7
7
|
* dispatch is deferred, so a caller can run it synchronously (Cache.View) or
|
|
8
8
|
* detached (Run.Detach). `describe` labels the error with the owning resource.
|
|
9
|
+
* The thunk's optional second argument seeds the dispatch's {@link InvokeContext}
|
|
10
|
+
* (e.g. a decorator-owned cancellation scope); when omitted the ambient
|
|
11
|
+
* invocation context applies unchanged.
|
|
9
12
|
*/
|
|
10
13
|
export function resolveInvocableDispatcher(field, ctx, describe) {
|
|
11
14
|
if (field && typeof field.invoke === "function") {
|
|
12
15
|
const instance = field;
|
|
13
16
|
const id = getRefIdentity(field);
|
|
14
|
-
return (inputs) => id
|
|
17
|
+
return (inputs, invokeCtx) => id
|
|
18
|
+
? ctx.invokeResolved(id.kind, id.name, instance, inputs, invokeCtx)
|
|
19
|
+
: instance.invoke(inputs, invokeCtx);
|
|
15
20
|
}
|
|
16
21
|
const ref = field;
|
|
17
22
|
if (!ref || typeof ref.name !== "string") {
|
|
@@ -23,5 +28,5 @@ export function resolveInvocableDispatcher(field, ctx, describe) {
|
|
|
23
28
|
if (!resolved || typeof resolved.invoke !== "function") {
|
|
24
29
|
throw new Error(`${describe()}: 'invoke' reference '${ref.name}' did not resolve to an invocable.`);
|
|
25
30
|
}
|
|
26
|
-
return (inputs) => ctx.invokeResolved(ref.kind, ref.name, resolved, inputs);
|
|
31
|
+
return (inputs, invokeCtx) => ctx.invokeResolved(ref.kind, ref.name, resolved, inputs, invokeCtx);
|
|
27
32
|
}
|
|
@@ -54,6 +54,15 @@ export type InstanceFactory = (context: EvaluationContext, resource: ResourceMan
|
|
|
54
54
|
export type PreInitHook = (resource: ResourceManifest, getInstance: (name: string, alias?: string) => ResourceInstance | undefined, isPending?: (name: string) => boolean) => void;
|
|
55
55
|
/** Canonical key for a resource instance: "<module>.<kind>.<name>" */
|
|
56
56
|
export declare function resourceKey(r: ResourceManifest): string;
|
|
57
|
+
/** The resource that owns a spawned child context — the parent in the resource
|
|
58
|
+
* topology. `id` is the owner's full hierarchical id (`<owner.id>/<kind>.<name>`,
|
|
59
|
+
* or just `<kind>.<name>` at the top level), so a child's own id qualifies under
|
|
60
|
+
* it and stays unique across instances of the same templated kind. */
|
|
61
|
+
export type ResourceOwner = {
|
|
62
|
+
kind: string;
|
|
63
|
+
name: string;
|
|
64
|
+
id: string;
|
|
65
|
+
};
|
|
57
66
|
/**
|
|
58
67
|
* Public contract for the base evaluation context.
|
|
59
68
|
*
|
|
@@ -78,6 +87,18 @@ export interface EvaluationContext {
|
|
|
78
87
|
/** Per-kernel invocation tracer. Set by the kernel on the root context and
|
|
79
88
|
* propagated through `spawnChild`; drives invocation-id minting in `invoke`. */
|
|
80
89
|
tracer?: Tracer;
|
|
90
|
+
/** The resource that spawned this context's resources, if any. A template
|
|
91
|
+
* controller stamps it on the child context it registers its `resources:`
|
|
92
|
+
* into, so the lifecycle/dispatch events those children emit carry the owning
|
|
93
|
+
* resource — letting a debug consumer nest them under their parent and keep
|
|
94
|
+
* two instances of the same templated kind from colliding by name. `id` is the
|
|
95
|
+
* owner's full hierarchical id (`<owner.id>/<kind>.<name>`); undefined on a
|
|
96
|
+
* context whose resources are top-level. */
|
|
97
|
+
owner?: ResourceOwner;
|
|
98
|
+
/** The id prefix to prepend to a resource created in this context:
|
|
99
|
+
* `owner ? owner.id + "/" : ""`. A controller that spawns sub-resources reads
|
|
100
|
+
* it (via {@link ResourceContext.ownerPrefix}) to compose their hierarchical ids. */
|
|
101
|
+
readonly ownerPrefix: string;
|
|
81
102
|
readonly createInstance: InstanceFactory;
|
|
82
103
|
readonly context: Record<string, unknown>;
|
|
83
104
|
readonly secretValues: Set<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evaluation-context.d.ts","sourceRoot":"","sources":["../src/evaluation-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,m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AE,MAAM,EACZ,QAAQ,EAAE,gBAAgB,EAC1B,MAAM,EAAE,OAAO,EACf,GAAG,CAAC,EAAE,aAAa,GAClB,OAAO,CAAC,GAAG,CAAC,CAAC;IAChB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtD,QAAQ,CAAC,IAAI,EAAE,aAAa,GAAG,SAAS,EAAE,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IACpF;;6DAEyD;IACzD,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IACjD,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC;IAChC,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC;IAC3E,WAAW,CACT,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,KAAK,EAAE,MAAM,EAAE,EACf,YAAY,CAAC,EAAE,MAAM,EAAE,GACtB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC5B"}
|
|
@@ -34,6 +34,13 @@ export type ParsedArgs = Partial<Record<string, string | boolean | string[]>> &
|
|
|
34
34
|
};
|
|
35
35
|
export interface ResourceContext extends ControllerContext {
|
|
36
36
|
readonly args: ParsedArgs;
|
|
37
|
+
/** The id prefix of the context this resource was created in (the creating
|
|
38
|
+
* {@link EvaluationContext}'s `ownerPrefix`). A controller that spawns
|
|
39
|
+
* sub-resources composes their hierarchical ids as
|
|
40
|
+
* `ownerPrefix + <kind>.<name>` and stamps the owner on the child context it
|
|
41
|
+
* registers them into, so two instances of the same templated kind don't
|
|
42
|
+
* collide and the children nest under their parent in a debug view. */
|
|
43
|
+
readonly ownerPrefix: string;
|
|
37
44
|
acquireHold(reason?: string): () => void;
|
|
38
45
|
emitEvent(event: string, payload?: any): Promise<void>;
|
|
39
46
|
/** Mint a writable cancellation source for a trigger to own (HTTP request,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource-context.d.ts","sourceRoot":"","sources":["../src/resource-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACtG,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,MAAM,WAAW,WAAW;IAC1B;gFAC4E;IAC5E,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;4EAGwE;IACxE,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI,CAAC;IAC1B,OAAO,CAAC,IAAI,EAAE,GAAG,GAAG,OAAO,CAAC;CAC7B;AAED,MAAM,WAAW,QAAQ;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,aAAc,YAAW,aAAa;IACjD,OAAO;IAIP,QAAQ;CAGT;AAED,MAAM,MAAM,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,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AAC,MAAM,EAAE,MAAM,CAAC,cAAc,CAAC;IACvC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,cAAc,CAAC;CACxC"}
|
|
@@ -13,6 +13,30 @@
|
|
|
13
13
|
export declare const TELO_TYPE_SCHEME = "telo://";
|
|
14
14
|
/** The canonical, alias-resolved `$id` a named type schema is registered under. */
|
|
15
15
|
export declare function canonicalTypeSchemaId(moduleName: string, typeName: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* Resolve `extends` into a single self-contained object schema by deep-merging an
|
|
18
|
+
* ordered list of already-resolved schemas (parents first, the own schema last):
|
|
19
|
+
*
|
|
20
|
+
* - `properties` — union; the more-derived (later) schema wins on a key conflict.
|
|
21
|
+
* - `required` — union across all levels.
|
|
22
|
+
* - `additionalProperties` — the most-derived schema that sets it.
|
|
23
|
+
* - `allOf` / `oneOf` / `anyOf` — **preserved, never dropped**: every schema's
|
|
24
|
+
* composition keywords are collected into the result's `allOf` (each `oneOf` /
|
|
25
|
+
* `anyOf` wrapped as its own branch), which intersects them — a value must
|
|
26
|
+
* satisfy the merged object shape AND every inherited/own composition
|
|
27
|
+
* constraint. A plain object-inheritance schema declares none of these, so the
|
|
28
|
+
* result carries no `allOf` and stays free of the `allOf` +
|
|
29
|
+
* `additionalProperties: false` footgun.
|
|
30
|
+
* - everything else — carried over, more-derived wins.
|
|
31
|
+
*
|
|
32
|
+
* Assumes object schemas (`type` defaults to `"object"` when unset). The result
|
|
33
|
+
* carries no `$ref`s, so it is directly usable as a validation schema.
|
|
34
|
+
*
|
|
35
|
+
* Single source of truth for `Type.JsonSchema` inheritance: the runtime `type`
|
|
36
|
+
* controller and the analyzer both call this, so static analysis and runtime
|
|
37
|
+
* validation can never disagree on a type's effective shape.
|
|
38
|
+
*/
|
|
39
|
+
export declare function mergeTypeSchemas(schemas: Record<string, unknown>[]): Record<string, unknown>;
|
|
16
40
|
/** Parsed parts of a `telo://<authority>/<typeName>` schema reference. */
|
|
17
41
|
export interface TeloTypeRef {
|
|
18
42
|
authority: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-schema-ref.d.ts","sourceRoot":"","sources":["../src/type-schema-ref.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,eAAO,MAAM,gBAAgB,YAAY,CAAC;AAE1C,mFAAmF;AACnF,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAElF;AAED,0EAA0E;AAC1E,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,WAAW,GAAG,IAAI,CAKjE"}
|
|
1
|
+
{"version":3,"file":"type-schema-ref.d.ts","sourceRoot":"","sources":["../src/type-schema-ref.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,eAAO,MAAM,gBAAgB,YAAY,CAAC;AAE1C,mFAAmF;AACnF,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAElF;AAiBD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GACjC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAqCzB;AAED,0EAA0E;AAC1E,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,WAAW,GAAG,IAAI,CAKjE"}
|
package/dist/type-schema-ref.js
CHANGED
|
@@ -15,6 +15,92 @@ export const TELO_TYPE_SCHEME = "telo://";
|
|
|
15
15
|
export function canonicalTypeSchemaId(moduleName, typeName) {
|
|
16
16
|
return `${TELO_TYPE_SCHEME}${moduleName}/${typeName}`;
|
|
17
17
|
}
|
|
18
|
+
/** Top-level keywords merged structurally rather than copied wholesale when
|
|
19
|
+
* resolving `extends`: object shape (`properties` / `required` /
|
|
20
|
+
* `additionalProperties`) is deep-merged, and composition keywords (`allOf` /
|
|
21
|
+
* `oneOf` / `anyOf`) are preserved as intersected `allOf` branches. Everything
|
|
22
|
+
* else (`type`, `title`, `description`, …) is carried over with the more-derived
|
|
23
|
+
* schema winning. */
|
|
24
|
+
const STRUCTURAL_KEYS = new Set([
|
|
25
|
+
"properties",
|
|
26
|
+
"required",
|
|
27
|
+
"additionalProperties",
|
|
28
|
+
"allOf",
|
|
29
|
+
"oneOf",
|
|
30
|
+
"anyOf",
|
|
31
|
+
]);
|
|
32
|
+
/**
|
|
33
|
+
* Resolve `extends` into a single self-contained object schema by deep-merging an
|
|
34
|
+
* ordered list of already-resolved schemas (parents first, the own schema last):
|
|
35
|
+
*
|
|
36
|
+
* - `properties` — union; the more-derived (later) schema wins on a key conflict.
|
|
37
|
+
* - `required` — union across all levels.
|
|
38
|
+
* - `additionalProperties` — the most-derived schema that sets it.
|
|
39
|
+
* - `allOf` / `oneOf` / `anyOf` — **preserved, never dropped**: every schema's
|
|
40
|
+
* composition keywords are collected into the result's `allOf` (each `oneOf` /
|
|
41
|
+
* `anyOf` wrapped as its own branch), which intersects them — a value must
|
|
42
|
+
* satisfy the merged object shape AND every inherited/own composition
|
|
43
|
+
* constraint. A plain object-inheritance schema declares none of these, so the
|
|
44
|
+
* result carries no `allOf` and stays free of the `allOf` +
|
|
45
|
+
* `additionalProperties: false` footgun.
|
|
46
|
+
* - everything else — carried over, more-derived wins.
|
|
47
|
+
*
|
|
48
|
+
* Assumes object schemas (`type` defaults to `"object"` when unset). The result
|
|
49
|
+
* carries no `$ref`s, so it is directly usable as a validation schema.
|
|
50
|
+
*
|
|
51
|
+
* Single source of truth for `Type.JsonSchema` inheritance: the runtime `type`
|
|
52
|
+
* controller and the analyzer both call this, so static analysis and runtime
|
|
53
|
+
* validation can never disagree on a type's effective shape.
|
|
54
|
+
*/
|
|
55
|
+
export function mergeTypeSchemas(schemas) {
|
|
56
|
+
const out = {};
|
|
57
|
+
const properties = {};
|
|
58
|
+
const required = new Set();
|
|
59
|
+
let additionalProperties;
|
|
60
|
+
let hasAdditionalProperties = false;
|
|
61
|
+
// Inherited/own `allOf` / `oneOf` / `anyOf`, intersected into the result's
|
|
62
|
+
// `allOf` so no declared constraint is silently lost.
|
|
63
|
+
const composition = [];
|
|
64
|
+
for (const schema of schemas) {
|
|
65
|
+
if (!schema || typeof schema !== "object")
|
|
66
|
+
continue;
|
|
67
|
+
for (const [key, value] of Object.entries(schema)) {
|
|
68
|
+
if (!STRUCTURAL_KEYS.has(key))
|
|
69
|
+
out[key] = value;
|
|
70
|
+
}
|
|
71
|
+
const props = schema.properties;
|
|
72
|
+
if (props && typeof props === "object")
|
|
73
|
+
Object.assign(properties, props);
|
|
74
|
+
const req = schema.required;
|
|
75
|
+
if (Array.isArray(req))
|
|
76
|
+
for (const name of req)
|
|
77
|
+
required.add(name);
|
|
78
|
+
if ("additionalProperties" in schema) {
|
|
79
|
+
additionalProperties = schema.additionalProperties;
|
|
80
|
+
hasAdditionalProperties = true;
|
|
81
|
+
}
|
|
82
|
+
const allOf = schema.allOf;
|
|
83
|
+
if (Array.isArray(allOf))
|
|
84
|
+
composition.push(...allOf);
|
|
85
|
+
const oneOf = schema.oneOf;
|
|
86
|
+
if (Array.isArray(oneOf))
|
|
87
|
+
composition.push({ oneOf });
|
|
88
|
+
const anyOf = schema.anyOf;
|
|
89
|
+
if (Array.isArray(anyOf))
|
|
90
|
+
composition.push({ anyOf });
|
|
91
|
+
}
|
|
92
|
+
if (Object.keys(properties).length > 0)
|
|
93
|
+
out.properties = properties;
|
|
94
|
+
if (required.size > 0)
|
|
95
|
+
out.required = [...required];
|
|
96
|
+
if (hasAdditionalProperties)
|
|
97
|
+
out.additionalProperties = additionalProperties;
|
|
98
|
+
if (composition.length > 0)
|
|
99
|
+
out.allOf = composition;
|
|
100
|
+
if (out.type === undefined)
|
|
101
|
+
out.type = "object";
|
|
102
|
+
return out;
|
|
103
|
+
}
|
|
18
104
|
/**
|
|
19
105
|
* Parse a `telo://<authority>/<typeName>` schema `$ref`. Returns null for any
|
|
20
106
|
* other string — notably fragment-bearing built-ins like
|
package/package.json
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { InvokeContext } from "./cancellation.js";
|
|
1
2
|
import type { Invocable } from "./capabilities/invokable.js";
|
|
2
3
|
import type { ModuleContext } from "./module-context.js";
|
|
3
4
|
import { getRefIdentity, type ResourceInstance } from "./resource-instance.js";
|
|
@@ -9,6 +10,7 @@ export interface DispatchContext {
|
|
|
9
10
|
name: string,
|
|
10
11
|
instance: ResourceInstance,
|
|
11
12
|
inputs: TInputs,
|
|
13
|
+
ctx?: InvokeContext,
|
|
12
14
|
): Promise<unknown>;
|
|
13
15
|
readonly moduleContext: ModuleContext;
|
|
14
16
|
}
|
|
@@ -20,17 +22,22 @@ export interface DispatchContext {
|
|
|
20
22
|
* against the module context. Resolution is eager (fail-fast on a bad ref);
|
|
21
23
|
* dispatch is deferred, so a caller can run it synchronously (Cache.View) or
|
|
22
24
|
* detached (Run.Detach). `describe` labels the error with the owning resource.
|
|
25
|
+
* The thunk's optional second argument seeds the dispatch's {@link InvokeContext}
|
|
26
|
+
* (e.g. a decorator-owned cancellation scope); when omitted the ambient
|
|
27
|
+
* invocation context applies unchanged.
|
|
23
28
|
*/
|
|
24
29
|
export function resolveInvocableDispatcher(
|
|
25
30
|
field: unknown,
|
|
26
31
|
ctx: DispatchContext,
|
|
27
32
|
describe: () => string,
|
|
28
|
-
): (inputs: Record<string, unknown
|
|
33
|
+
): (inputs: Record<string, unknown>, invokeCtx?: InvokeContext) => Promise<unknown> {
|
|
29
34
|
if (field && typeof (field as Invocable).invoke === "function") {
|
|
30
35
|
const instance = field as ResourceInstance & Invocable;
|
|
31
36
|
const id = getRefIdentity(field as object);
|
|
32
|
-
return (inputs) =>
|
|
33
|
-
id
|
|
37
|
+
return (inputs, invokeCtx) =>
|
|
38
|
+
id
|
|
39
|
+
? ctx.invokeResolved(id.kind, id.name, instance, inputs, invokeCtx)
|
|
40
|
+
: instance.invoke(inputs, invokeCtx);
|
|
34
41
|
}
|
|
35
42
|
const ref = field as { kind: string; name: string; alias?: string } | undefined;
|
|
36
43
|
if (!ref || typeof ref.name !== "string") {
|
|
@@ -44,5 +51,5 @@ export function resolveInvocableDispatcher(
|
|
|
44
51
|
if (!resolved || typeof resolved.invoke !== "function") {
|
|
45
52
|
throw new Error(`${describe()}: 'invoke' reference '${ref.name}' did not resolve to an invocable.`);
|
|
46
53
|
}
|
|
47
|
-
return (inputs) => ctx.invokeResolved(ref.kind, ref.name, resolved, inputs);
|
|
54
|
+
return (inputs, invokeCtx) => ctx.invokeResolved(ref.kind, ref.name, resolved, inputs, invokeCtx);
|
|
48
55
|
}
|
|
@@ -79,6 +79,12 @@ export function resourceKey(r: ResourceManifest): string {
|
|
|
79
79
|
return `${r.kind}.${r.metadata.name}`;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
/** The resource that owns a spawned child context — the parent in the resource
|
|
83
|
+
* topology. `id` is the owner's full hierarchical id (`<owner.id>/<kind>.<name>`,
|
|
84
|
+
* or just `<kind>.<name>` at the top level), so a child's own id qualifies under
|
|
85
|
+
* it and stays unique across instances of the same templated kind. */
|
|
86
|
+
export type ResourceOwner = { kind: string; name: string; id: string };
|
|
87
|
+
|
|
82
88
|
/**
|
|
83
89
|
* Public contract for the base evaluation context.
|
|
84
90
|
*
|
|
@@ -110,6 +116,20 @@ export interface EvaluationContext {
|
|
|
110
116
|
* propagated through `spawnChild`; drives invocation-id minting in `invoke`. */
|
|
111
117
|
tracer?: Tracer;
|
|
112
118
|
|
|
119
|
+
/** The resource that spawned this context's resources, if any. A template
|
|
120
|
+
* controller stamps it on the child context it registers its `resources:`
|
|
121
|
+
* into, so the lifecycle/dispatch events those children emit carry the owning
|
|
122
|
+
* resource — letting a debug consumer nest them under their parent and keep
|
|
123
|
+
* two instances of the same templated kind from colliding by name. `id` is the
|
|
124
|
+
* owner's full hierarchical id (`<owner.id>/<kind>.<name>`); undefined on a
|
|
125
|
+
* context whose resources are top-level. */
|
|
126
|
+
owner?: ResourceOwner;
|
|
127
|
+
|
|
128
|
+
/** The id prefix to prepend to a resource created in this context:
|
|
129
|
+
* `owner ? owner.id + "/" : ""`. A controller that spawns sub-resources reads
|
|
130
|
+
* it (via {@link ResourceContext.ownerPrefix}) to compose their hierarchical ids. */
|
|
131
|
+
readonly ownerPrefix: string;
|
|
132
|
+
|
|
113
133
|
readonly createInstance: InstanceFactory;
|
|
114
134
|
readonly context: Record<string, unknown>;
|
|
115
135
|
readonly secretValues: Set<string>;
|
package/src/resource-context.ts
CHANGED
|
@@ -43,6 +43,13 @@ export type ParsedArgs = Partial<Record<string, string | boolean | string[]>> &
|
|
|
43
43
|
|
|
44
44
|
export interface ResourceContext extends ControllerContext {
|
|
45
45
|
readonly args: ParsedArgs;
|
|
46
|
+
/** The id prefix of the context this resource was created in (the creating
|
|
47
|
+
* {@link EvaluationContext}'s `ownerPrefix`). A controller that spawns
|
|
48
|
+
* sub-resources composes their hierarchical ids as
|
|
49
|
+
* `ownerPrefix + <kind>.<name>` and stamps the owner on the child context it
|
|
50
|
+
* registers them into, so two instances of the same templated kind don't
|
|
51
|
+
* collide and the children nest under their parent in a debug view. */
|
|
52
|
+
readonly ownerPrefix: string;
|
|
46
53
|
acquireHold(reason?: string): () => void;
|
|
47
54
|
emitEvent(event: string, payload?: any): Promise<void>;
|
|
48
55
|
/** Mint a writable cancellation source for a trigger to own (HTTP request,
|
package/src/type-schema-ref.ts
CHANGED
|
@@ -18,6 +18,85 @@ export function canonicalTypeSchemaId(moduleName: string, typeName: string): str
|
|
|
18
18
|
return `${TELO_TYPE_SCHEME}${moduleName}/${typeName}`;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
/** Top-level keywords merged structurally rather than copied wholesale when
|
|
22
|
+
* resolving `extends`: object shape (`properties` / `required` /
|
|
23
|
+
* `additionalProperties`) is deep-merged, and composition keywords (`allOf` /
|
|
24
|
+
* `oneOf` / `anyOf`) are preserved as intersected `allOf` branches. Everything
|
|
25
|
+
* else (`type`, `title`, `description`, …) is carried over with the more-derived
|
|
26
|
+
* schema winning. */
|
|
27
|
+
const STRUCTURAL_KEYS = new Set([
|
|
28
|
+
"properties",
|
|
29
|
+
"required",
|
|
30
|
+
"additionalProperties",
|
|
31
|
+
"allOf",
|
|
32
|
+
"oneOf",
|
|
33
|
+
"anyOf",
|
|
34
|
+
]);
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Resolve `extends` into a single self-contained object schema by deep-merging an
|
|
38
|
+
* ordered list of already-resolved schemas (parents first, the own schema last):
|
|
39
|
+
*
|
|
40
|
+
* - `properties` — union; the more-derived (later) schema wins on a key conflict.
|
|
41
|
+
* - `required` — union across all levels.
|
|
42
|
+
* - `additionalProperties` — the most-derived schema that sets it.
|
|
43
|
+
* - `allOf` / `oneOf` / `anyOf` — **preserved, never dropped**: every schema's
|
|
44
|
+
* composition keywords are collected into the result's `allOf` (each `oneOf` /
|
|
45
|
+
* `anyOf` wrapped as its own branch), which intersects them — a value must
|
|
46
|
+
* satisfy the merged object shape AND every inherited/own composition
|
|
47
|
+
* constraint. A plain object-inheritance schema declares none of these, so the
|
|
48
|
+
* result carries no `allOf` and stays free of the `allOf` +
|
|
49
|
+
* `additionalProperties: false` footgun.
|
|
50
|
+
* - everything else — carried over, more-derived wins.
|
|
51
|
+
*
|
|
52
|
+
* Assumes object schemas (`type` defaults to `"object"` when unset). The result
|
|
53
|
+
* carries no `$ref`s, so it is directly usable as a validation schema.
|
|
54
|
+
*
|
|
55
|
+
* Single source of truth for `Type.JsonSchema` inheritance: the runtime `type`
|
|
56
|
+
* controller and the analyzer both call this, so static analysis and runtime
|
|
57
|
+
* validation can never disagree on a type's effective shape.
|
|
58
|
+
*/
|
|
59
|
+
export function mergeTypeSchemas(
|
|
60
|
+
schemas: Record<string, unknown>[],
|
|
61
|
+
): Record<string, unknown> {
|
|
62
|
+
const out: Record<string, unknown> = {};
|
|
63
|
+
const properties: Record<string, unknown> = {};
|
|
64
|
+
const required = new Set<string>();
|
|
65
|
+
let additionalProperties: unknown;
|
|
66
|
+
let hasAdditionalProperties = false;
|
|
67
|
+
// Inherited/own `allOf` / `oneOf` / `anyOf`, intersected into the result's
|
|
68
|
+
// `allOf` so no declared constraint is silently lost.
|
|
69
|
+
const composition: unknown[] = [];
|
|
70
|
+
|
|
71
|
+
for (const schema of schemas) {
|
|
72
|
+
if (!schema || typeof schema !== "object") continue;
|
|
73
|
+
for (const [key, value] of Object.entries(schema)) {
|
|
74
|
+
if (!STRUCTURAL_KEYS.has(key)) out[key] = value;
|
|
75
|
+
}
|
|
76
|
+
const props = (schema as { properties?: unknown }).properties;
|
|
77
|
+
if (props && typeof props === "object") Object.assign(properties, props);
|
|
78
|
+
const req = (schema as { required?: unknown }).required;
|
|
79
|
+
if (Array.isArray(req)) for (const name of req) required.add(name as string);
|
|
80
|
+
if ("additionalProperties" in schema) {
|
|
81
|
+
additionalProperties = (schema as { additionalProperties?: unknown }).additionalProperties;
|
|
82
|
+
hasAdditionalProperties = true;
|
|
83
|
+
}
|
|
84
|
+
const allOf = (schema as { allOf?: unknown }).allOf;
|
|
85
|
+
if (Array.isArray(allOf)) composition.push(...allOf);
|
|
86
|
+
const oneOf = (schema as { oneOf?: unknown }).oneOf;
|
|
87
|
+
if (Array.isArray(oneOf)) composition.push({ oneOf });
|
|
88
|
+
const anyOf = (schema as { anyOf?: unknown }).anyOf;
|
|
89
|
+
if (Array.isArray(anyOf)) composition.push({ anyOf });
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (Object.keys(properties).length > 0) out.properties = properties;
|
|
93
|
+
if (required.size > 0) out.required = [...required];
|
|
94
|
+
if (hasAdditionalProperties) out.additionalProperties = additionalProperties;
|
|
95
|
+
if (composition.length > 0) out.allOf = composition;
|
|
96
|
+
if (out.type === undefined) out.type = "object";
|
|
97
|
+
return out;
|
|
98
|
+
}
|
|
99
|
+
|
|
21
100
|
/** Parsed parts of a `telo://<authority>/<typeName>` schema reference. */
|
|
22
101
|
export interface TeloTypeRef {
|
|
23
102
|
authority: string;
|