@telorun/sdk 0.34.0 → 0.38.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.
@@ -11,6 +11,12 @@ export interface CompiledValue {
11
11
  * that need each interpolation as a separate value (e.g. SQL bind
12
12
  * parameters) read this instead of the joined `call()` result. */
13
13
  readonly parts?: ReadonlyArray<string | CompiledValue>;
14
+ /** Root variable identifiers the expression reads, extracted from the CEL AST
15
+ * at compile time (e.g. `["self", "request"]` for
16
+ * `self.table + request.id`). Lets consumers decide what scope an expression
17
+ * needs without re-parsing or string-matching the source. Absent for engines
18
+ * that don't surface an AST. */
19
+ readonly refs?: readonly string[];
14
20
  call(ctx: Record<string, unknown>): unknown;
15
21
  }
16
22
  export declare function isCompiledValue(v: unknown): v is CompiledValue;
@@ -1 +1 @@
1
- {"version":3,"file":"compiled-value.d.ts","sourceRoot":"","sources":["../src/compiled-value.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAC/D,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,UAAU,EAAE,IAAI,CAAC;IAC1B,uEAAuE;IACvE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB;;;;uEAImE;IACnE,QAAQ,CAAC,KAAK,CAAC,EAAE,aAAa,CAAC,MAAM,GAAG,aAAa,CAAC,CAAC;IACvD,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC;CAC7C;AAED,wBAAgB,eAAe,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,aAAa,CAE9D;AAED;;;;;gEAKgE;AAChE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,mBAAmB,EAAE,IAAI,CAAC;IACnC,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC;CAC5B;AAED,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,gBAAgB,CAIpE"}
1
+ {"version":3,"file":"compiled-value.d.ts","sourceRoot":"","sources":["../src/compiled-value.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAC/D,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,UAAU,EAAE,IAAI,CAAC;IAC1B,uEAAuE;IACvE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB;;;;uEAImE;IACnE,QAAQ,CAAC,KAAK,CAAC,EAAE,aAAa,CAAC,MAAM,GAAG,aAAa,CAAC,CAAC;IACvD;;;;qCAIiC;IACjC,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC;CAC7C;AAED,wBAAgB,eAAe,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,aAAa,CAE9D;AAED;;;;;gEAKgE;AAChE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,mBAAmB,EAAE,IAAI,CAAC;IACnC,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC;CAC5B;AAED,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,gBAAgB,CAIpE"}
@@ -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>;
@@ -85,6 +106,11 @@ export interface EvaluationContext {
85
106
  hasManifest(name: string): boolean;
86
107
  registerManifest(resource: ResourceManifest): void;
87
108
  spawnChild<T extends EvaluationContext>(child: T): T;
109
+ /** Spawn a fresh child context attached to this one — the isolated scope a
110
+ * templated definition registers its `resources:` into. Rooted here so child
111
+ * kinds/refs resolve against THIS context's imports (the defining library),
112
+ * not the consumer's. */
113
+ spawnChildContext(): EvaluationContext;
88
114
  initializeResources(): Promise<void>;
89
115
  withManifests<T>(manifests: any[], fn: () => T): T;
90
116
  createScopeHandle(manifests: ResourceManifest[]): ScopeHandle;
@@ -1 +1 @@
1
- {"version":3,"file":"evaluation-context.d.ts","sourceRoot":"","sources":["../src/evaluation-context.ts"],"names":[],"mappings":"AAAA,OAAO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,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,OAAO,GAAG,MAAM,EAAE,CAAC,CAAC,GAAG;IAAE,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAEhG,MAAM,WAAW,eA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 @@
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"}
@@ -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,6 +1,6 @@
1
1
  {
2
2
  "name": "@telorun/sdk",
3
- "version": "0.34.0",
3
+ "version": "0.38.0",
4
4
  "description": "Telo SDK - Public API for Telo module authors.",
5
5
  "keywords": [
6
6
  "telo",
@@ -11,6 +11,12 @@ export interface CompiledValue {
11
11
  * that need each interpolation as a separate value (e.g. SQL bind
12
12
  * parameters) read this instead of the joined `call()` result. */
13
13
  readonly parts?: ReadonlyArray<string | CompiledValue>;
14
+ /** Root variable identifiers the expression reads, extracted from the CEL AST
15
+ * at compile time (e.g. `["self", "request"]` for
16
+ * `self.table + request.id`). Lets consumers decide what scope an expression
17
+ * needs without re-parsing or string-matching the source. Absent for engines
18
+ * that don't surface an AST. */
19
+ readonly refs?: readonly string[];
14
20
  call(ctx: Record<string, unknown>): unknown;
15
21
  }
16
22
 
@@ -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>;
@@ -118,6 +138,11 @@ export interface EvaluationContext {
118
138
  hasManifest(name: string): boolean;
119
139
  registerManifest(resource: ResourceManifest): void;
120
140
  spawnChild<T extends EvaluationContext>(child: T): T;
141
+ /** Spawn a fresh child context attached to this one — the isolated scope a
142
+ * templated definition registers its `resources:` into. Rooted here so child
143
+ * kinds/refs resolve against THIS context's imports (the defining library),
144
+ * not the consumer's. */
145
+ spawnChildContext(): EvaluationContext;
121
146
  initializeResources(): Promise<void>;
122
147
  withManifests<T>(manifests: any[], fn: () => T): T;
123
148
  createScopeHandle(manifests: ResourceManifest[]): ScopeHandle;
@@ -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,
@@ -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;