@telorun/analyzer 0.72.0 → 0.74.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/analyzer.d.ts.map +1 -1
- package/dist/analyzer.js +76 -20
- package/dist/artifact-axes.d.ts +14 -0
- package/dist/artifact-axes.d.ts.map +1 -0
- package/dist/artifact-axes.js +12 -0
- package/dist/artifact-layer-index.d.ts +2 -2
- package/dist/artifact-layer-index.d.ts.map +1 -1
- package/dist/artifact-layer-index.js +9 -4
- package/dist/artifact-selector.d.ts +47 -21
- package/dist/artifact-selector.d.ts.map +1 -1
- package/dist/artifact-selector.js +85 -16
- package/dist/builtins.d.ts.map +1 -1
- package/dist/builtins.js +144 -113
- package/dist/call-graph.d.ts +12 -1
- package/dist/call-graph.d.ts.map +1 -1
- package/dist/call-graph.js +22 -0
- package/dist/catch-scope.js +1 -1
- package/dist/cel-scope-query.d.ts.map +1 -1
- package/dist/cel-scope-query.js +32 -11
- package/dist/cel-scope.d.ts.map +1 -1
- package/dist/cel-scope.js +1 -0
- package/dist/eval-paths.d.ts +36 -5
- package/dist/eval-paths.d.ts.map +1 -1
- package/dist/eval-paths.js +47 -6
- package/dist/extends-resolution.d.ts +12 -0
- package/dist/extends-resolution.d.ts.map +1 -1
- package/dist/extends-resolution.js +23 -0
- package/dist/forwarded-declaration.d.ts +26 -0
- package/dist/forwarded-declaration.d.ts.map +1 -0
- package/dist/forwarded-declaration.js +31 -0
- package/dist/index.d.ts +10 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -2
- package/dist/kernel-globals.d.ts.map +1 -1
- package/dist/kernel-globals.js +21 -5
- package/dist/module-alias-scope.d.ts +11 -0
- package/dist/module-alias-scope.d.ts.map +1 -1
- package/dist/module-alias-scope.js +10 -0
- package/dist/module-file-claims.d.ts +17 -1
- package/dist/module-file-claims.d.ts.map +1 -1
- package/dist/module-file-claims.js +38 -3
- package/dist/module-named-files.d.ts +72 -0
- package/dist/module-named-files.d.ts.map +1 -0
- package/dist/module-named-files.js +115 -0
- package/dist/native-entries.d.ts +83 -0
- package/dist/native-entries.d.ts.map +1 -0
- package/dist/native-entries.js +169 -0
- package/dist/nearest-name.d.ts +22 -0
- package/dist/nearest-name.d.ts.map +1 -0
- package/dist/nearest-name.js +43 -0
- package/dist/normalize-inline-resources.d.ts +41 -13
- package/dist/normalize-inline-resources.d.ts.map +1 -1
- package/dist/normalize-inline-resources.js +236 -54
- package/dist/reference-field-map.d.ts +59 -1
- package/dist/reference-field-map.d.ts.map +1 -1
- package/dist/reference-field-map.js +200 -34
- package/dist/release/destinations.d.ts +59 -0
- package/dist/release/destinations.d.ts.map +1 -0
- package/dist/release/destinations.js +75 -0
- package/dist/release/index.d.ts +6 -2
- package/dist/release/index.d.ts.map +1 -1
- package/dist/release/index.js +3 -1
- package/dist/release/ledger.d.ts +20 -11
- package/dist/release/ledger.d.ts.map +1 -1
- package/dist/release/ledger.js +43 -14
- package/dist/release/payload-digest.d.ts +2 -1
- package/dist/release/payload-digest.d.ts.map +1 -1
- package/dist/release/payload-digest.js +2 -1
- package/dist/release/release-plan.d.ts +3 -2
- package/dist/release/release-plan.d.ts.map +1 -1
- package/dist/release/release-plan.js +12 -19
- package/dist/release/workspace-config.d.ts +114 -34
- package/dist/release/workspace-config.d.ts.map +1 -1
- package/dist/release/workspace-config.js +322 -38
- package/dist/release/workspace-schema.d.ts +41 -0
- package/dist/release/workspace-schema.d.ts.map +1 -0
- package/dist/release/workspace-schema.js +77 -0
- package/dist/resolve-ref-sentinels.d.ts.map +1 -1
- package/dist/resolve-ref-sentinels.js +8 -5
- package/dist/resolve-throws-union.d.ts +25 -4
- package/dist/resolve-throws-union.d.ts.map +1 -1
- package/dist/resolve-throws-union.js +62 -32
- package/dist/resolve-zone-requirements.d.ts.map +1 -1
- package/dist/resolve-zone-requirements.js +2 -1
- package/dist/rewrite-synthetic-origins.d.ts +6 -1
- package/dist/rewrite-synthetic-origins.d.ts.map +1 -1
- package/dist/rewrite-synthetic-origins.js +107 -13
- package/dist/schema-compat.d.ts.map +1 -1
- package/dist/schema-compat.js +18 -5
- package/dist/schema-error-report.d.ts +7 -0
- package/dist/schema-error-report.d.ts.map +1 -1
- package/dist/schema-error-report.js +9 -4
- package/dist/schema-walk.d.ts +47 -13
- package/dist/schema-walk.d.ts.map +1 -1
- package/dist/schema-walk.js +150 -30
- package/dist/scope-declarations.d.ts +59 -0
- package/dist/scope-declarations.d.ts.map +1 -0
- package/dist/scope-declarations.js +45 -0
- package/dist/source-entries.d.ts +119 -0
- package/dist/source-entries.d.ts.map +1 -0
- package/dist/source-entries.js +349 -0
- package/dist/step-bodies.d.ts +24 -0
- package/dist/step-bodies.d.ts.map +1 -0
- package/dist/step-bodies.js +28 -0
- package/dist/telo-version.d.ts +1 -1
- package/dist/telo-version.js +1 -1
- package/dist/template-body.d.ts +10 -0
- package/dist/template-body.d.ts.map +1 -1
- package/dist/template-body.js +25 -0
- package/dist/validate-cel-context.d.ts +23 -8
- package/dist/validate-cel-context.d.ts.map +1 -1
- package/dist/validate-cel-context.js +51 -18
- package/dist/validate-exports.d.ts +28 -0
- package/dist/validate-exports.d.ts.map +1 -0
- package/dist/validate-exports.js +146 -0
- package/dist/validate-extends.d.ts.map +1 -1
- package/dist/validate-extends.js +37 -1
- package/dist/validate-module-artifact.d.ts +4 -2
- package/dist/validate-module-artifact.d.ts.map +1 -1
- package/dist/validate-module-artifact.js +43 -4
- package/dist/validate-native-entries.d.ts +15 -0
- package/dist/validate-native-entries.d.ts.map +1 -0
- package/dist/validate-native-entries.js +103 -0
- package/dist/validate-observed-state.d.ts +7 -1
- package/dist/validate-observed-state.d.ts.map +1 -1
- package/dist/validate-observed-state.js +24 -6
- package/dist/validate-provider-coherence.d.ts +4 -8
- package/dist/validate-provider-coherence.d.ts.map +1 -1
- package/dist/validate-provider-coherence.js +12 -123
- package/dist/validate-reference-forms.d.ts.map +1 -1
- package/dist/validate-reference-forms.js +2 -2
- package/dist/validate-references.d.ts.map +1 -1
- package/dist/validate-references.js +152 -65
- package/dist/validate-scope-reach.d.ts +31 -0
- package/dist/validate-scope-reach.d.ts.map +1 -0
- package/dist/validate-scope-reach.js +180 -0
- package/dist/validate-source-entries.d.ts +16 -0
- package/dist/validate-source-entries.d.ts.map +1 -0
- package/dist/validate-source-entries.js +90 -0
- package/dist/validate-template-body.d.ts +36 -0
- package/dist/validate-template-body.d.ts.map +1 -0
- package/dist/validate-template-body.js +246 -0
- package/dist/validate-throws-coverage.d.ts.map +1 -1
- package/dist/validate-throws-coverage.js +21 -39
- package/dist/value-type-keyword.d.ts +22 -5
- package/dist/value-type-keyword.d.ts.map +1 -1
- package/dist/value-type-keyword.js +16 -7
- package/package.json +4 -3
- package/src/analyzer.ts +97 -20
- package/src/artifact-axes.ts +24 -0
- package/src/artifact-layer-index.ts +9 -6
- package/src/artifact-selector.ts +110 -35
- package/src/builtins.ts +160 -113
- package/src/call-graph.ts +30 -0
- package/src/catch-scope.ts +1 -1
- package/src/cel-scope-query.ts +28 -9
- package/src/cel-scope.ts +1 -0
- package/src/eval-paths.ts +53 -6
- package/src/extends-resolution.ts +24 -0
- package/src/forwarded-declaration.ts +32 -0
- package/src/index.ts +37 -1
- package/src/kernel-globals.ts +28 -5
- package/src/migrations/CLAUDE.md +35 -0
- package/src/module-alias-scope.ts +17 -0
- package/src/module-file-claims.ts +63 -4
- package/src/module-named-files.ts +162 -0
- package/src/native-entries.ts +227 -0
- package/src/nearest-name.ts +47 -0
- package/src/normalize-inline-resources.ts +326 -70
- package/src/reference-field-map.ts +257 -52
- package/src/release/CLAUDE.md +32 -0
- package/src/release/destinations.ts +105 -0
- package/src/release/index.ts +33 -2
- package/src/release/ledger.ts +51 -21
- package/src/release/payload-digest.ts +2 -1
- package/src/release/release-plan.ts +16 -26
- package/src/release/workspace-config.ts +483 -47
- package/src/release/workspace-schema.ts +99 -0
- package/src/resolve-ref-sentinels.ts +7 -6
- package/src/resolve-throws-union.ts +87 -32
- package/src/resolve-zone-requirements.ts +2 -1
- package/src/rewrite-synthetic-origins.ts +107 -16
- package/src/schema-compat.ts +18 -4
- package/src/schema-error-report.ts +16 -4
- package/src/schema-walk.ts +162 -34
- package/src/scope-declarations.ts +98 -0
- package/src/source-entries.ts +502 -0
- package/src/step-bodies.ts +55 -0
- package/src/telo-version.ts +1 -1
- package/src/template-body.ts +25 -0
- package/src/validate-cel-context.ts +60 -18
- package/src/validate-exports.ts +185 -0
- package/src/validate-extends.ts +43 -0
- package/src/validate-module-artifact.ts +46 -3
- package/src/validate-native-entries.ts +147 -0
- package/src/validate-observed-state.ts +36 -7
- package/src/validate-provider-coherence.ts +17 -127
- package/src/validate-reference-forms.ts +2 -3
- package/src/validate-references.ts +151 -66
- package/src/validate-scope-reach.ts +213 -0
- package/src/validate-source-entries.ts +120 -0
- package/src/validate-template-body.ts +274 -0
- package/src/validate-throws-coverage.ts +24 -31
- package/src/value-type-keyword.ts +35 -9
- package/dist/validate-template-dispatch.d.ts +0 -27
- package/dist/validate-template-dispatch.d.ts.map +0 -1
- package/dist/validate-template-dispatch.js +0 -95
- package/src/validate-template-dispatch.ts +0 -99
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { isTaggedSentinel } from "@telorun/templating";
|
|
2
2
|
import { scopeResolverForModule } from "./alias-resolver.js";
|
|
3
|
-
import { resolveScopedName } from "./call-graph.js";
|
|
3
|
+
import { resolveScopedName, resolveSlotUseAt } from "./call-graph.js";
|
|
4
4
|
import { refSentinelTarget } from "./ref-sentinel-target.js";
|
|
5
|
-
import { possibleUses, transfersControl } from "./ref-slot.js";
|
|
6
|
-
import { readStepSlot } from "./step-slot.js";
|
|
5
|
+
import { hasDeclaredUse, possibleUses, transfersControl, } from "./ref-slot.js";
|
|
7
6
|
import { forEachDrivenSlot } from "./schema-walk.js";
|
|
8
7
|
/** Code a non-`InvokeError` failure surfaces as inside a `catch` block. Mirrors
|
|
9
8
|
* `PLAIN_ERROR_CODE` in `@telorun/run`'s `toSequenceError`: any invoke can throw
|
|
@@ -127,10 +126,10 @@ function codesFromDefinition(definition) {
|
|
|
127
126
|
return out;
|
|
128
127
|
}
|
|
129
128
|
/** Resolve the effective throw union for a named manifest. The result combines
|
|
130
|
-
* explicit `throws.codes`, `throws.inherit: true` dataflow (step
|
|
131
|
-
*
|
|
132
|
-
* unresolvable passthrough call sites. Cycles
|
|
133
|
-
* result so resolution always terminates. */
|
|
129
|
+
* explicit `throws.codes`, `throws.inherit: true` dataflow (step bodies with
|
|
130
|
+
* try/catch subtraction, plus reference slots that hand a failure back), and
|
|
131
|
+
* unbounded markers for unresolvable passthrough call sites. Cycles
|
|
132
|
+
* short-circuit to an empty result so resolution always terminates. */
|
|
134
133
|
export function resolveThrowsUnion(manifest, ctx) {
|
|
135
134
|
const name = memoKey(manifest);
|
|
136
135
|
if (name) {
|
|
@@ -182,29 +181,52 @@ export function resolveThrowsUnion(manifest, ctx) {
|
|
|
182
181
|
}
|
|
183
182
|
}
|
|
184
183
|
/**
|
|
185
|
-
*
|
|
184
|
+
* True for a use through which a target's failure reaches the declaring
|
|
185
|
+
* resource's CALLER: `call` returns into my invocation, and `trigger.consumer`
|
|
186
|
+
* rejects the value my caller drains. `detached` and `trigger.inbound` run where
|
|
187
|
+
* no caller of mine awaits them; `dependency` and `schema` dispatch nothing.
|
|
186
188
|
*
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
189
|
+
* The reduction `inherit` is read through — by the resolver and by the check
|
|
190
|
+
* that a definition declaring it has something to inherit from.
|
|
191
|
+
*/
|
|
192
|
+
export function handsFailureBack(use) {
|
|
193
|
+
return use === "call" || use === "trigger.consumer";
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* The uses a throws consumer reads off a slot. A slot that declares no use —
|
|
197
|
+
* the legacy bare-string form — reads as `call`: the throws union must assume
|
|
198
|
+
* `call` to keep an error path, the direction the call graph takes for the same
|
|
199
|
+
* slot. The zone projection reads it the opposite way, deliberately.
|
|
200
|
+
*
|
|
201
|
+
* `uses` defaults to every use the slot can take; a consumer that resolved the
|
|
202
|
+
* slot's case map for one instance passes that answer instead.
|
|
203
|
+
*/
|
|
204
|
+
export function throwsUses(slot, uses = possibleUses(slot)) {
|
|
205
|
+
return hasDeclaredUse(slot) ? uses : ["call"];
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* `throws.inherit: true` — the union of what the resource dispatches: its step
|
|
209
|
+
* bodies (try/catch subtraction included) and every reference slot whose use,
|
|
210
|
+
* resolved for THIS instance, hands a failure back ({@link handsFailureBack}).
|
|
211
|
+
*
|
|
212
|
+
* Only on a kind that DECLARES `inherit`: it is a claim that the kind lets what
|
|
213
|
+
* it dispatches escape, and a kind catching a slot internally does not make it.
|
|
214
|
+
* What a CATCH SCOPE encloses is a different question, answered below.
|
|
193
215
|
*/
|
|
194
216
|
function resolveInherited(manifest, definition, ctx, ownerModule) {
|
|
195
217
|
const result = { codes: new Map(), unbounded: false };
|
|
196
|
-
const
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
}
|
|
218
|
+
const schema = definition.schema;
|
|
219
|
+
forEachDrivenSlot(schema, manifest, (driven) => {
|
|
220
|
+
if (driven.kind === "step") {
|
|
221
|
+
unionInto(result, stepSiteThrows(driven.data, driven.slots, ctx, ownerModule));
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
// Several slots at one site are the branches declaring it; any one that
|
|
225
|
+
// hands a failure back counts, since a branch not applying can only add codes.
|
|
226
|
+
const handsBack = driven.slots.some(({ slot, fieldPath }) => throwsUses(slot, resolveSlotUseAt(slot, manifest, schema, driven.path, fieldPath).use).some(handsFailureBack));
|
|
227
|
+
if (handsBack)
|
|
228
|
+
unionInto(result, resolveRefTargetThrows(driven.data, ctx, ownerModule));
|
|
229
|
+
});
|
|
208
230
|
return result;
|
|
209
231
|
}
|
|
210
232
|
/**
|
|
@@ -233,10 +255,13 @@ export function resolveScopeUnion(manifest, definition, ctx, seen = new Set()) {
|
|
|
233
255
|
const ownerModule = manifest.metadata?.module;
|
|
234
256
|
forEachDrivenSlot(definition.schema, manifest, (driven) => {
|
|
235
257
|
if (driven.kind === "step") {
|
|
236
|
-
unionInto(result,
|
|
258
|
+
unionInto(result, stepSiteThrows(driven.data, driven.slots, ctx, ownerModule));
|
|
237
259
|
return;
|
|
238
260
|
}
|
|
239
|
-
if (driven.slot.throwsThrough) {
|
|
261
|
+
if (driven.slots.some(({ slot }) => !slot.throwsThrough && throwsUses(slot).some(transfersControl))) {
|
|
262
|
+
unionInto(result, resolveRefTargetThrows(driven.data, ctx, ownerModule));
|
|
263
|
+
}
|
|
264
|
+
if (driven.slots.some(({ slot }) => slot.throwsThrough)) {
|
|
240
265
|
const target = resolveRefManifest(driven.data, ctx, ownerModule);
|
|
241
266
|
const targetDef = target
|
|
242
267
|
? definitionFor(target.kind, ctx.defs, ctx.aliases, scopeResolverFor(ctx, target.metadata?.module))
|
|
@@ -247,14 +272,19 @@ export function resolveScopeUnion(manifest, definition, ctx, seen = new Set()) {
|
|
|
247
272
|
// the scope's union is no longer enumerable.
|
|
248
273
|
else
|
|
249
274
|
result.unbounded = true;
|
|
250
|
-
return;
|
|
251
275
|
}
|
|
252
|
-
if (!possibleUses(driven.slot).some(transfersControl))
|
|
253
|
-
return;
|
|
254
|
-
unionInto(result, resolveRefTargetThrows(driven.data, ctx, ownerModule));
|
|
255
276
|
});
|
|
256
277
|
return result;
|
|
257
278
|
}
|
|
279
|
+
/** The union a step-body site reaches — once per distinct invoke field, since
|
|
280
|
+
* several branches may declare a body at one site. */
|
|
281
|
+
function stepSiteThrows(steps, slots, ctx, ownerModule) {
|
|
282
|
+
const result = emptyUnion();
|
|
283
|
+
for (const invoke of new Set(slots.map((slot) => slot.invoke))) {
|
|
284
|
+
unionInto(result, collectStepArrayThrows(steps, invoke, undefined, ctx, ownerModule));
|
|
285
|
+
}
|
|
286
|
+
return result;
|
|
287
|
+
}
|
|
258
288
|
function collectStepArrayThrows(steps, invokeField, enclosingTryCodes, ctx, ownerModule) {
|
|
259
289
|
const result = emptyUnion();
|
|
260
290
|
for (const step of steps) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-zone-requirements.d.ts","sourceRoot":"","sources":["../src/resolve-zone-requirements.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EAAsB,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAEL,KAAK,SAAS,EAEd,KAAK,iBAAiB,EACvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAMnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,EAAsB,KAAK,kBAAkB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"resolve-zone-requirements.d.ts","sourceRoot":"","sources":["../src/resolve-zone-requirements.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EAAsB,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAEL,KAAK,SAAS,EAEd,KAAK,iBAAiB,EACvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAMnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,EAAsB,KAAK,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAMzE;;uCAEuC;AACvC,MAAM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;AACzC,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,cAAc,GAAG,gBAAgB,CAoZ9E;AAED;;;;iEAIiE;AACjE,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,SAAS,gBAAgB,EAAE,GAAG,MAAM,CAUrF;AAED;;;;GAIG;AACH,wBAAgB,+BAA+B,CAC7C,IAAI,EAAE,eAAe,EACrB,IAAI,EAAE,kBAAkB,EACxB,OAAO,EAAE,aAAa,EACtB,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,EAC3C,KAAK,CAAC,EAAE,eAAe,GACtB,sBAAsB,CAkBxB;AAED,MAAM,WAAW,gBAAgB;IAC/B,gFAAgF;IAChF,SAAS,EAAE,gBAAgB,EAAE,CAAC;IAC9B,KAAK,EAAE,SAAS,CAAC;IACjB,IAAI,EAAE,kBAAkB,CAAC;IACzB,OAAO,EAAE,aAAa,CAAC;IACvB,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAC5C,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACjC,eAAe,CAAC,EAAE,SAAS,eAAe,EAAE,CAAC;IAC7C,KAAK,CAAC,EAAE,eAAe,CAAC;CACzB;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,gBAAgB,GAAG,kBAAkB,EAAE,CAwF5E"}
|
|
@@ -4,6 +4,7 @@ import { enclosingOf, propertySchemas, resolveLocalRef, } from "./manifest-navig
|
|
|
4
4
|
import { readProvidesZone, readRequiresZone } from "./zone-slot.js";
|
|
5
5
|
import { DiagnosticSeverity } from "./types.js";
|
|
6
6
|
import { moduleAliasScope } from "./module-alias-scope.js";
|
|
7
|
+
import { isForwardedDeclaration } from "./forwarded-declaration.js";
|
|
7
8
|
const SOURCE = "telo-analyzer";
|
|
8
9
|
/** Resolve a possibly alias-form kind to its definition in the DECLARING
|
|
9
10
|
* module's scope — the same layering `AnalysisRegistry.resolveDefinitionIn`
|
|
@@ -379,7 +380,7 @@ export function projectZoneRequirements(args) {
|
|
|
379
380
|
// (with the internal graph in hand) and seeded below — deriving them here
|
|
380
381
|
// against the flattened view would resolve correlation against a graph
|
|
381
382
|
// that no longer holds the library's internals.
|
|
382
|
-
if (
|
|
383
|
+
if (isForwardedDeclaration(node.manifest))
|
|
383
384
|
continue;
|
|
384
385
|
const def = resolveDef(node.kind, meta?.module);
|
|
385
386
|
const schema = def?.schema;
|
|
@@ -5,6 +5,11 @@ import type { AnalysisDiagnostic } from "./types.js";
|
|
|
5
5
|
* `data.resource`, which has no YAML source. Rewrite each such diagnostic
|
|
6
6
|
* back to the chain root: walk up `metadata.xTeloOrigin` until a manifest
|
|
7
7
|
* with no origin is reached, and prepend each hop's `pathFromParent` to
|
|
8
|
-
* `data.path` so position-index lookups against the root doc resolve.
|
|
8
|
+
* `data.path` so position-index lookups against the root doc resolve.
|
|
9
|
+
*
|
|
10
|
+
* An extraction from a scope member lives INSIDE the scope array rather than at
|
|
11
|
+
* the top level, so a diagnostic about it names the top-level owner and a path
|
|
12
|
+
* through an array index the author never wrote (`with[3]`). That prefix is
|
|
13
|
+
* unfolded the same way, into the position the declaration was written at. */
|
|
9
14
|
export declare function rewriteSyntheticOrigins(diagnostics: AnalysisDiagnostic[], manifests: ResourceManifest[]): AnalysisDiagnostic[];
|
|
10
15
|
//# sourceMappingURL=rewrite-synthetic-origins.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rewrite-synthetic-origins.d.ts","sourceRoot":"","sources":["../src/rewrite-synthetic-origins.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAsBrD
|
|
1
|
+
{"version":3,"file":"rewrite-synthetic-origins.d.ts","sourceRoot":"","sources":["../src/rewrite-synthetic-origins.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAsBrD;;;;;;;;;;+EAU+E;AAC/E,wBAAgB,uBAAuB,CACrC,WAAW,EAAE,kBAAkB,EAAE,EACjC,SAAS,EAAE,gBAAgB,EAAE,GAC5B,kBAAkB,EAAE,CA0CtB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function readOrigin(manifest) {
|
|
2
|
-
if (!manifest)
|
|
2
|
+
if (!manifest || typeof manifest !== "object")
|
|
3
3
|
return undefined;
|
|
4
4
|
const origin = manifest.metadata?.xTeloOrigin;
|
|
5
5
|
if (!origin ||
|
|
@@ -15,7 +15,12 @@ function readOrigin(manifest) {
|
|
|
15
15
|
* `data.resource`, which has no YAML source. Rewrite each such diagnostic
|
|
16
16
|
* back to the chain root: walk up `metadata.xTeloOrigin` until a manifest
|
|
17
17
|
* with no origin is reached, and prepend each hop's `pathFromParent` to
|
|
18
|
-
* `data.path` so position-index lookups against the root doc resolve.
|
|
18
|
+
* `data.path` so position-index lookups against the root doc resolve.
|
|
19
|
+
*
|
|
20
|
+
* An extraction from a scope member lives INSIDE the scope array rather than at
|
|
21
|
+
* the top level, so a diagnostic about it names the top-level owner and a path
|
|
22
|
+
* through an array index the author never wrote (`with[3]`). That prefix is
|
|
23
|
+
* unfolded the same way, into the position the declaration was written at. */
|
|
19
24
|
export function rewriteSyntheticOrigins(diagnostics, manifests) {
|
|
20
25
|
const byName = new Map();
|
|
21
26
|
for (const m of manifests) {
|
|
@@ -29,27 +34,116 @@ export function rewriteSyntheticOrigins(diagnostics, manifests) {
|
|
|
29
34
|
return d;
|
|
30
35
|
let current = byName.get(data.resource.name);
|
|
31
36
|
let origin = readOrigin(current);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
let
|
|
35
|
-
let rootKind = origin.parentKind;
|
|
36
|
-
let rootName = origin.parentName;
|
|
37
|
+
const path = typeof data.path === "string" ? data.path : "";
|
|
38
|
+
let accumPath = path;
|
|
39
|
+
let root = data.resource;
|
|
37
40
|
while (origin) {
|
|
38
41
|
accumPath = accumPath ? `${origin.pathFromParent}.${accumPath}` : origin.pathFromParent;
|
|
39
|
-
|
|
40
|
-
rootName = origin.parentName;
|
|
42
|
+
root = { kind: origin.parentKind, name: origin.parentName };
|
|
41
43
|
current = byName.get(origin.parentName);
|
|
42
44
|
origin = readOrigin(current);
|
|
43
45
|
}
|
|
44
|
-
const
|
|
46
|
+
const rerouted = root !== data.resource;
|
|
47
|
+
const unfolded = current ? unfoldScopedOrigins(current, accumPath) : accumPath;
|
|
48
|
+
if (!rerouted && unfolded === path)
|
|
49
|
+
return d;
|
|
45
50
|
return {
|
|
46
51
|
...d,
|
|
47
52
|
data: {
|
|
48
53
|
...data,
|
|
49
|
-
resource:
|
|
50
|
-
filePath:
|
|
51
|
-
|
|
54
|
+
resource: root,
|
|
55
|
+
filePath: rerouted
|
|
56
|
+
? (current?.metadata?.source ?? data.filePath)
|
|
57
|
+
: data.filePath,
|
|
58
|
+
path: unfolded,
|
|
52
59
|
},
|
|
53
60
|
};
|
|
54
61
|
});
|
|
55
62
|
}
|
|
63
|
+
/** Replace every scope-array index that holds an extraction with the position
|
|
64
|
+
* the extraction was written at, until none is left. */
|
|
65
|
+
function unfoldScopedOrigins(root, path) {
|
|
66
|
+
let segments = parseSegments(path);
|
|
67
|
+
let unfoldedAny = false;
|
|
68
|
+
// Each unfolding replaces one extraction with its parent, which is strictly
|
|
69
|
+
// closer to what the author wrote, so the chain is as long as the nesting.
|
|
70
|
+
for (let hops = 0; hops <= segments.length + 16; hops++) {
|
|
71
|
+
const next = unfoldOnce(root, segments);
|
|
72
|
+
if (!next)
|
|
73
|
+
break;
|
|
74
|
+
segments = next;
|
|
75
|
+
unfoldedAny = true;
|
|
76
|
+
}
|
|
77
|
+
// Re-formatting is lossy (an empty segment in `entries../x` is dropped), so a
|
|
78
|
+
// path nothing unfolded is returned as written.
|
|
79
|
+
return unfoldedAny ? formatSegments(segments) : path;
|
|
80
|
+
}
|
|
81
|
+
function unfoldOnce(root, segments) {
|
|
82
|
+
let node = root;
|
|
83
|
+
for (let i = 0; i < segments.length; i++) {
|
|
84
|
+
const segment = segments[i];
|
|
85
|
+
const container = node;
|
|
86
|
+
node =
|
|
87
|
+
typeof segment === "number"
|
|
88
|
+
? Array.isArray(container)
|
|
89
|
+
? container[segment]
|
|
90
|
+
: undefined
|
|
91
|
+
: container && typeof container === "object" && !Array.isArray(container)
|
|
92
|
+
? container[segment]
|
|
93
|
+
: undefined;
|
|
94
|
+
if (node === undefined || node === null)
|
|
95
|
+
return undefined;
|
|
96
|
+
if (typeof segment !== "number" || i === 0)
|
|
97
|
+
continue;
|
|
98
|
+
const origin = readOrigin(node);
|
|
99
|
+
if (!origin)
|
|
100
|
+
continue;
|
|
101
|
+
// Its parent is either the resource holding this scope array (a slot of
|
|
102
|
+
// the resource that declares the scope) or a sibling member of the array.
|
|
103
|
+
const holderPath = segments.slice(0, i - 1);
|
|
104
|
+
let parentPath;
|
|
105
|
+
if (nameOf(at(root, holderPath)) === origin.parentName) {
|
|
106
|
+
parentPath = holderPath;
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
const sibling = container.findIndex((m) => nameOf(m) === origin.parentName);
|
|
110
|
+
if (sibling >= 0)
|
|
111
|
+
parentPath = [...segments.slice(0, i), sibling];
|
|
112
|
+
}
|
|
113
|
+
if (!parentPath)
|
|
114
|
+
return undefined;
|
|
115
|
+
return [...parentPath, ...parseSegments(origin.pathFromParent), ...segments.slice(i + 1)];
|
|
116
|
+
}
|
|
117
|
+
return undefined;
|
|
118
|
+
}
|
|
119
|
+
function at(root, segments) {
|
|
120
|
+
let node = root;
|
|
121
|
+
for (const segment of segments) {
|
|
122
|
+
if (!node || typeof node !== "object")
|
|
123
|
+
return undefined;
|
|
124
|
+
node = node[segment];
|
|
125
|
+
}
|
|
126
|
+
return node;
|
|
127
|
+
}
|
|
128
|
+
function nameOf(value) {
|
|
129
|
+
const name = value?.metadata?.name;
|
|
130
|
+
return typeof name === "string" ? name : undefined;
|
|
131
|
+
}
|
|
132
|
+
/** `with[3].steps[0].invoke` → `["with", 3, "steps", 0, "invoke"]`. */
|
|
133
|
+
function parseSegments(path) {
|
|
134
|
+
const out = [];
|
|
135
|
+
for (const match of path.matchAll(/\[(\d+)\]|([^.[\]]+)/g)) {
|
|
136
|
+
out.push(match[1] !== undefined ? Number(match[1]) : match[2]);
|
|
137
|
+
}
|
|
138
|
+
return out;
|
|
139
|
+
}
|
|
140
|
+
function formatSegments(segments) {
|
|
141
|
+
let out = "";
|
|
142
|
+
for (const segment of segments) {
|
|
143
|
+
if (typeof segment === "number")
|
|
144
|
+
out += `[${segment}]`;
|
|
145
|
+
else
|
|
146
|
+
out += out ? `.${segment}` : segment;
|
|
147
|
+
}
|
|
148
|
+
return out;
|
|
149
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-compat.d.ts","sourceRoot":"","sources":["../src/schema-compat.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"schema-compat.d.ts","sourceRoot":"","sources":["../src/schema-compat.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAgB,KAAK,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAG1E,QAAA,MAAM,GAAG,KAA0C,CAAC;AAEpD;;;;;;;mCAOmC;AACnC,wBAAgB,SAAS,IAAI,YAAY,CAAC,OAAO,GAAG,CAAC,CAapD;AAKD,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,OAAO,CAAC;IACpB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAYD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC3B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC3B,UAAU,CAAC,EAAE,CAA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M,KAAK,IAAI,CAAC;IACtC,qEAAqE;IACrE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;iEAG6D;IAC7D,QAAQ,CAAC,EAAE,sBAAsB,CAAC;CACnC;AAED,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,OAAO,EACb,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC3B,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAChC,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAmFT"}
|
package/dist/schema-compat.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import AjvModule from "ajv";
|
|
2
2
|
import addFormats from "ajv-formats";
|
|
3
3
|
import { isRefSentinel, isTaggedSentinel, producedTypeOf, } from "@telorun/templating";
|
|
4
|
-
import { celBaseOfValueType, celTypeOfValueType, isCompiledValue, readValueTypeSlot, valueBrandBases, valueTypeOf, valueTypePlaceholder, } from "@telorun/sdk";
|
|
4
|
+
import { celBaseOfValueType, celTypeOfValueType, isCompiledValue, readValueTypeSlot, VALUE_TYPE_BINDINGS, valueBrandBases, valueTypeOf, valueTypePlaceholder, } from "@telorun/sdk";
|
|
5
5
|
import { ManifestRootSchema } from "./manifest-schemas.js";
|
|
6
6
|
import { schemaIssues } from "./schema-error-report.js";
|
|
7
7
|
import { registerTeloKeywords } from "./value-type-keyword.js";
|
|
@@ -22,8 +22,9 @@ export function createAjv() {
|
|
|
22
22
|
// One registration site for every Telo keyword — the annotations as no-ops and
|
|
23
23
|
// `x-telo-type` as the one that checks. Registered here and in the kernel's
|
|
24
24
|
// validators from one definition, so a literal at an instance-typed slot is
|
|
25
|
-
// rejected statically and at dispatch by the identical rule.
|
|
26
|
-
|
|
25
|
+
// rejected statically and at dispatch by the identical rule. This instance is
|
|
26
|
+
// static analysis alone, so it also asserts a `live` type: no literal can be one.
|
|
27
|
+
registerTeloKeywords(instance, { assertLive: true });
|
|
27
28
|
instance.addSchema(ManifestRootSchema);
|
|
28
29
|
return instance;
|
|
29
30
|
}
|
|
@@ -463,6 +464,18 @@ function foldedConstraints(schema) {
|
|
|
463
464
|
}
|
|
464
465
|
return out;
|
|
465
466
|
}
|
|
467
|
+
/** The stand-in for a CEL leaf at a `live` slot. Static analysis asserts a live
|
|
468
|
+
* type like any instance type (a literal can never be one), so the leaf's
|
|
469
|
+
* stand-in has to BE one. A live binding declares no factory, and building an
|
|
470
|
+
* instance would mean knowing its constructor's signature; an object on the
|
|
471
|
+
* constructor's prototype satisfies `instanceof` and is never used as one. */
|
|
472
|
+
function liveValuePlaceholder(schema) {
|
|
473
|
+
const entry = readValueTypeSlot(schema)?.entry;
|
|
474
|
+
if (!entry?.live || entry.representation !== "instance")
|
|
475
|
+
return undefined;
|
|
476
|
+
const binding = VALUE_TYPE_BINDINGS[entry.binding];
|
|
477
|
+
return binding ? Object.create(binding.constructor.prototype) : undefined;
|
|
478
|
+
}
|
|
466
479
|
export function celPlaceholderForSchema(rawSchema) {
|
|
467
480
|
const schema = foldedConstraints(rawSchema);
|
|
468
481
|
// An instance-typed slot's placeholder must BE an instance: the same keyword
|
|
@@ -471,8 +484,8 @@ export function celPlaceholderForSchema(rawSchema) {
|
|
|
471
484
|
// rejected because no YAML literal is a byte buffer, while a value arriving by
|
|
472
485
|
// reference passes. The stand-in comes from the binding table, so a new
|
|
473
486
|
// instance type brings its own rather than adding a branch here; a `live` type
|
|
474
|
-
// declares none, because nothing validates it.
|
|
475
|
-
const placeholder = valueTypePlaceholder(schema);
|
|
487
|
+
// declares none, because nothing validates it at dispatch.
|
|
488
|
+
const placeholder = valueTypePlaceholder(schema) ?? liveValuePlaceholder(schema);
|
|
476
489
|
if (placeholder !== undefined)
|
|
477
490
|
return placeholder;
|
|
478
491
|
if (schema.default !== undefined)
|
|
@@ -42,6 +42,13 @@ export interface SchemaIssue {
|
|
|
42
42
|
message: string;
|
|
43
43
|
/** Dotted path to the field (e.g. "config.handler"). Empty string means root. */
|
|
44
44
|
path: string;
|
|
45
|
+
/** The AJV keyword that produced it, so a consumer can key on WHAT failed
|
|
46
|
+
* rather than on how the sentence reads. Prose is the renderer's to change;
|
|
47
|
+
* a caller matching on it breaks silently when it does, and mis-fires on any
|
|
48
|
+
* other issue whose text happens to quote the same name. */
|
|
49
|
+
keyword?: string;
|
|
50
|
+
/** For `required`, the property that is missing. */
|
|
51
|
+
missingProperty?: string;
|
|
45
52
|
}
|
|
46
53
|
export declare function formatSingleError(err: AjvErrorLike): string;
|
|
47
54
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-error-report.d.ts","sourceRoot":"","sources":["../src/schema-error-report.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH;gDACgD;AAChD,MAAM,WAAW,YAAY;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC7B,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,mFAAmF;AACnF,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,iFAAiF;IACjF,IAAI,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"schema-error-report.d.ts","sourceRoot":"","sources":["../src/schema-error-report.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH;gDACgD;AAChD,MAAM,WAAW,YAAY;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC7B,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,mFAAmF;AACnF,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,iFAAiF;IACjF,IAAI,EAAE,MAAM,CAAC;IACb;;;iEAG6D;IAC7D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oDAAoD;IACpD,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAuCD,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,YAAY,GAAG,MAAM,CA6B3D;AAoGD;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,YAAY,EAAE,GAAG,IAAI,GAAG,SAAS,GAAG,YAAY,EAAE,CAsF5F;AAqHD;;sFAEsF;AACtF,wBAAgB,cAAc,CAAC,GAAG,EAAE,YAAY,GAAG,MAAM,CAaxD;AAED,4EAA4E;AAC5E,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,EAAE,GAAG,IAAI,GAAG,SAAS,GAAG,WAAW,EAAE,CAUrF;AAED,+EAA+E;AAC/E,wBAAgB,eAAe,CAAC,MAAM,EAAE,YAAY,EAAE,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAIjF"}
|
|
@@ -386,10 +386,15 @@ export function ajvErrorToPath(err) {
|
|
|
386
386
|
}
|
|
387
387
|
/** Reduced, path-anchored issues — what a diagnostic list is built from. */
|
|
388
388
|
export function schemaIssues(errors) {
|
|
389
|
-
return reduceSchemaErrors(errors).map((err) =>
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
389
|
+
return reduceSchemaErrors(errors).map((err) => {
|
|
390
|
+
const missing = (err.params ?? {}).missingProperty;
|
|
391
|
+
return {
|
|
392
|
+
message: formatSingleError(err),
|
|
393
|
+
path: ajvErrorToPath(err),
|
|
394
|
+
...(err.keyword ? { keyword: err.keyword } : {}),
|
|
395
|
+
...(typeof missing === "string" ? { missingProperty: missing } : {}),
|
|
396
|
+
};
|
|
397
|
+
});
|
|
393
398
|
}
|
|
394
399
|
/** Reduced, rendered as one sentence — what a thrown runtime error carries. */
|
|
395
400
|
export function formatAjvErrors(errors) {
|
package/dist/schema-walk.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { RefSlot } from "./ref-slot.js";
|
|
2
|
+
import type { StepSlot } from "./step-slot.js";
|
|
3
3
|
/** Resolve a local `$ref` (only `#/$defs/<name>` form) against the root schema.
|
|
4
4
|
* Non-refs and unresolved refs pass through unchanged. */
|
|
5
5
|
export declare function resolveLocalRef(schema: Record<string, any> | undefined, root: Record<string, any>): Record<string, any> | undefined;
|
|
@@ -24,29 +24,63 @@ export declare function gatherPropertySchemas(schema: Record<string, any>, root?
|
|
|
24
24
|
* hardcoded; recursion is driven entirely by the schema annotations.
|
|
25
25
|
*/
|
|
26
26
|
export declare function walkStepArray(steps: unknown[], stepItemSchema: Record<string, any> | undefined, rootSchema: Record<string, any>, basePath: string, visit: (step: Record<string, any>, stepPath: string) => void): void;
|
|
27
|
-
/** A slot through which
|
|
27
|
+
/** A slot a kind's schema declares through which its resources drive another.
|
|
28
|
+
* `path` is the field-map form (`routes[].handler`, `content.{}.encoder`);
|
|
29
|
+
* `slots` holds every slot any branch declares there. */
|
|
30
|
+
export type DeclaredSlot = {
|
|
31
|
+
kind: "step";
|
|
32
|
+
slots: StepSlot[];
|
|
33
|
+
path: string;
|
|
34
|
+
} | {
|
|
35
|
+
kind: "ref";
|
|
36
|
+
slots: RefSlot[];
|
|
37
|
+
path: string;
|
|
38
|
+
};
|
|
39
|
+
/** A reference slot at a site, with the declaration it came from — which is
|
|
40
|
+
* what a case-map selector's schema default is read against. */
|
|
41
|
+
export interface DrivenRef {
|
|
42
|
+
slot: RefSlot;
|
|
43
|
+
fieldPath: string;
|
|
44
|
+
}
|
|
45
|
+
/** The slots at one concrete site of one resource (`routes[0].handler`): every
|
|
46
|
+
* slot any branch or recursion route declares there. A consumer reads them as
|
|
47
|
+
* a union — a branch that does not apply to this resource can only add what
|
|
48
|
+
* counts, never remove it. */
|
|
28
49
|
export type DrivenSlot = {
|
|
29
50
|
kind: "step";
|
|
30
|
-
|
|
51
|
+
slots: StepSlot[];
|
|
31
52
|
data: unknown[];
|
|
32
53
|
path: string;
|
|
33
54
|
} | {
|
|
34
55
|
kind: "ref";
|
|
35
|
-
|
|
56
|
+
slots: DrivenRef[];
|
|
36
57
|
data: unknown;
|
|
37
58
|
path: string;
|
|
38
59
|
};
|
|
60
|
+
/**
|
|
61
|
+
* Every slot a kind's schema declares through which its resources drive
|
|
62
|
+
* another — the schema-only mode of {@link forEachDrivenSlot}, read off the
|
|
63
|
+
* same {@link buildDrivenSlotMap}.
|
|
64
|
+
*/
|
|
65
|
+
export declare function forEachDeclaredSlot(schema: unknown, visit: (slot: DeclaredSlot) => void): void;
|
|
39
66
|
/**
|
|
40
67
|
* Every slot of one resource through which it drives another, schema and data in
|
|
41
68
|
* tandem.
|
|
42
69
|
*
|
|
43
|
-
* One traversal
|
|
44
|
-
* scope enclosure
|
|
45
|
-
* structural question and two copies would eventually
|
|
46
|
-
* walk stops.
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
70
|
+
* One traversal for every throws question — a kind's `inherit` union, a scope
|
|
71
|
+
* list's denominator, catch-scope enclosure, and whether `inherit` is legal —
|
|
72
|
+
* because they ask the same structural question and two copies would eventually
|
|
73
|
+
* disagree about where the walk stops. The slots are the driven-slot map's, so
|
|
74
|
+
* the reach is the reference field map's plus local `$ref`; a step slot is a
|
|
75
|
+
* stop (that traversal owns everything below it, `try`/`catch` subtraction
|
|
76
|
+
* included) and so is a reference slot (a resolved ref is a leaf).
|
|
77
|
+
*
|
|
78
|
+
* Each concrete site is visited once, with every slot that reaches it. A
|
|
79
|
+
* map-value (`additionalProperties`) slot applies only to keys its schema does
|
|
80
|
+
* not declare, and never to the resource envelope at the root, as JSON Schema
|
|
81
|
+
* applies it. A recursive schema's back-edge is followed as deep as the data
|
|
82
|
+
* goes, guarded against data that aliases one of its own ancestors. A schema
|
|
83
|
+
* whose map holds no step or reference slot is not walked at all.
|
|
50
84
|
*/
|
|
51
|
-
export declare function forEachDrivenSlot(schema: unknown, data: unknown, visit: (slot: DrivenSlot) => void
|
|
85
|
+
export declare function forEachDrivenSlot(schema: unknown, data: unknown, visit: (slot: DrivenSlot) => void): void;
|
|
52
86
|
//# sourceMappingURL=schema-walk.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-walk.d.ts","sourceRoot":"","sources":["../src/schema-walk.ts"],"names":[],"mappings":"AAWA,OAAO,
|
|
1
|
+
{"version":3,"file":"schema-walk.d.ts","sourceRoot":"","sources":["../src/schema-walk.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG/C;2DAC2D;AAC3D,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,EACvC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GACxB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,CAqBjC;AAID;;;;;;;;iDAQiD;AACjD,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC3B,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GACzB,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAsBtC;AAED;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,OAAO,EAAE,EAChB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,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