@astrale-os/kernel-dsl 0.2.0-beta.9 → 1.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/v1/addressing/class-key.js +5 -4
- package/dist/v1/addressing/method-key.js +3 -2
- package/dist/v1/addressing/patterns.d.ts +0 -5
- package/dist/v1/addressing/patterns.js +5 -5
- package/dist/v1/builder/callable/authoring.d.ts +87 -41
- package/dist/v1/builder/callable/authoring.js +29 -14
- package/dist/v1/builder/class/authoring.d.ts +311 -36
- package/dist/v1/builder/class/authoring.js +3 -4
- package/dist/v1/builder/class/property.d.ts +16 -8
- package/dist/v1/builder/class/property.js +21 -5
- package/dist/v1/builder/core/authoring.d.ts +28 -13
- package/dist/v1/builder/core/authoring.js +22 -2
- package/dist/v1/builder/index.d.ts +9 -8
- package/dist/v1/builder/index.js +2 -2
- package/dist/v1/builder/lowering/callable.d.ts +3 -1
- package/dist/v1/builder/lowering/callable.js +43 -51
- package/dist/v1/builder/lowering/class.d.ts +7 -0
- package/dist/v1/builder/lowering/class.js +79 -29
- package/dist/v1/builder/lowering/core.d.ts +3 -2
- package/dist/v1/builder/lowering/core.js +9 -6
- package/dist/v1/builder/lowering/policy.d.ts +8 -1
- package/dist/v1/builder/lowering/policy.js +35 -0
- package/dist/v1/builder/lowering/schema/capture.js +9 -4
- package/dist/v1/builder/lowering/schema/compile.d.ts +2 -2
- package/dist/v1/builder/lowering/schema/compile.js +15 -2
- package/dist/v1/builder/lowering/schema/context.d.ts +11 -8
- package/dist/v1/builder/lowering/schema/context.js +59 -29
- package/dist/v1/builder/lowering/schema/ownership.d.ts +3 -3
- package/dist/v1/builder/lowering/schema/ownership.js +2 -1
- package/dist/v1/builder/lowering/value/compile.js +14 -4
- package/dist/v1/builder/lowering/value/zod.d.ts +7 -6
- package/dist/v1/builder/lowering/value/zod.js +16 -7
- package/dist/v1/builder/lowering/view.d.ts +4 -3
- package/dist/v1/builder/lowering/view.js +2 -14
- package/dist/v1/builder/policy/authoring.d.ts +23 -6
- package/dist/v1/builder/policy/authoring.js +35 -8
- package/dist/v1/builder/schema/define.d.ts +8 -5
- package/dist/v1/builder/schema/diagnostic.d.ts +1 -1
- package/dist/v1/builder/schema/handle.d.ts +2 -1
- package/dist/v1/builder/schema/input.d.ts +9 -1
- package/dist/v1/builder/schema/projection/callable.d.ts +51 -0
- package/dist/v1/builder/schema/projection/callable.js +1 -0
- package/dist/v1/builder/schema/projection/class.d.ts +89 -0
- package/dist/v1/builder/schema/projection/class.js +1 -0
- package/dist/v1/builder/schema/projection/core-input.d.ts +32 -0
- package/dist/v1/builder/schema/projection/core-input.js +1 -0
- package/dist/v1/builder/schema/projection/domain.d.ts +59 -0
- package/dist/v1/builder/schema/projection/domain.js +1 -0
- package/dist/v1/builder/schema/projection/identity.d.ts +39 -0
- package/dist/v1/builder/schema/projection/identity.js +1 -0
- package/dist/v1/builder/schema/projection/model.d.ts +59 -0
- package/dist/v1/builder/schema/projection/model.js +1 -0
- package/dist/v1/builder/schema/projection/property.d.ts +32 -0
- package/dist/v1/builder/schema/projection/property.js +1 -0
- package/dist/v1/builder/schema/projection/resolved-class.d.ts +76 -0
- package/dist/v1/builder/schema/projection/resolved-class.js +1 -0
- package/dist/v1/builder/schema/projection.d.ts +4 -258
- package/dist/v1/builder/value/full-match.js +6 -3
- package/dist/v1/builder/value/path.d.ts +2 -2
- package/dist/v1/builder/value/path.js +2 -2
- package/dist/v1/builder/view/authoring.d.ts +6 -14
- package/dist/v1/builder/view/authoring.js +13 -5
- package/dist/v1/bundle/structure.d.ts +2 -1
- package/dist/v1/compiled/admission/accept.d.ts +1 -1
- package/dist/v1/compiled/admission/accept.js +11 -814
- package/dist/v1/compiled/admission/closure.d.ts +3 -0
- package/dist/v1/compiled/admission/closure.js +173 -0
- package/dist/v1/compiled/admission/diagnostic.d.ts +7 -0
- package/dist/v1/compiled/admission/diagnostic.js +13 -0
- package/dist/v1/compiled/admission/revision.js +9 -1
- package/dist/v1/compiled/admission/semantics/cardinality.d.ts +5 -0
- package/dist/v1/compiled/admission/semantics/cardinality.js +113 -0
- package/dist/v1/compiled/admission/semantics/class.d.ts +5 -0
- package/dist/v1/compiled/admission/semantics/class.js +125 -0
- package/dist/v1/compiled/admission/semantics/context.d.ts +60 -0
- package/dist/v1/compiled/admission/semantics/context.js +81 -0
- package/dist/v1/compiled/admission/semantics/core.d.ts +35 -0
- package/dist/v1/compiled/admission/semantics/core.js +123 -0
- package/dist/v1/compiled/admission/semantics/edge.d.ts +8 -0
- package/dist/v1/compiled/admission/semantics/edge.js +89 -0
- package/dist/v1/compiled/admission/semantics/policy/admit.d.ts +4 -0
- package/dist/v1/compiled/admission/semantics/policy/admit.js +63 -0
- package/dist/v1/compiled/admission/semantics/policy/callable.d.ts +5 -0
- package/dist/v1/compiled/admission/semantics/policy/callable.js +72 -0
- package/dist/v1/compiled/admission/semantics/policy/contracts.d.ts +24 -0
- package/dist/v1/compiled/admission/semantics/policy/contracts.js +45 -0
- package/dist/v1/compiled/admission/semantics/policy/equality.d.ts +8 -0
- package/dist/v1/compiled/admission/semantics/policy/equality.js +27 -0
- package/dist/v1/compiled/admission/semantics/policy/measure.d.ts +9 -0
- package/dist/v1/compiled/admission/semantics/policy/measure.js +81 -0
- package/dist/v1/compiled/admission/semantics/policy/parity.d.ts +4 -0
- package/dist/v1/compiled/admission/semantics/policy/parity.js +138 -0
- package/dist/v1/compiled/admission/semantics/policy/pattern.d.ts +8 -0
- package/dist/v1/compiled/admission/semantics/policy/pattern.js +78 -0
- package/dist/v1/compiled/admission/semantics/policy/typing.d.ts +28 -0
- package/dist/v1/compiled/admission/semantics/policy/typing.js +206 -0
- package/dist/v1/compiled/admission/semantics/policy/variants.d.ts +10 -0
- package/dist/v1/compiled/admission/semantics/policy/variants.js +65 -0
- package/dist/v1/compiled/admission/semantics.d.ts +1 -1
- package/dist/v1/compiled/admission/semantics.js +8 -1078
- package/dist/v1/compiled/admission/wire/callable.d.ts +6 -0
- package/dist/v1/compiled/admission/wire/callable.js +90 -0
- package/dist/v1/compiled/admission/wire/class.d.ts +4 -0
- package/dist/v1/compiled/admission/wire/class.js +133 -0
- package/dist/v1/compiled/admission/wire/core.d.ts +5 -0
- package/dist/v1/compiled/admission/wire/core.js +32 -0
- package/dist/v1/compiled/admission/wire/dependency.d.ts +14 -0
- package/dist/v1/compiled/admission/wire/dependency.js +43 -0
- package/dist/v1/compiled/admission/wire/entry.d.ts +5 -0
- package/dist/v1/compiled/admission/wire/entry.js +100 -0
- package/dist/v1/compiled/admission/wire/pattern.d.ts +12 -0
- package/dist/v1/compiled/admission/wire/pattern.js +111 -0
- package/dist/v1/compiled/admission/wire/policy.d.ts +10 -0
- package/dist/v1/compiled/admission/wire/policy.js +189 -0
- package/dist/v1/compiled/admission/wire/program.d.ts +4 -0
- package/dist/v1/compiled/admission/wire/program.js +52 -0
- package/dist/v1/compiled/admission/wire/property.d.ts +4 -0
- package/dist/v1/compiled/admission/wire/property.js +74 -0
- package/dist/v1/compiled/admission/wire/reference.d.ts +8 -0
- package/dist/v1/compiled/admission/wire/reference.js +33 -0
- package/dist/v1/compiled/admission/wire/value.d.ts +29 -0
- package/dist/v1/compiled/admission/wire/value.js +98 -0
- package/dist/v1/compiled/admission/wire/view.d.ts +3 -0
- package/dist/v1/compiled/admission/wire/view.js +17 -0
- package/dist/v1/compiled/compiler/compile.js +43 -11
- package/dist/v1/compiled/generated.d.ts +10 -0
- package/dist/v1/compiled/generated.js +15 -0
- package/dist/v1/compiled/loader/load.d.ts +5 -0
- package/dist/v1/compiled/loader/load.js +18 -4
- package/dist/v1/compiled/model/schema.d.ts +16 -7
- package/dist/v1/domain/create.js +18 -28
- package/dist/v1/domain/model/domain.d.ts +0 -1
- package/dist/v1/domain/model/input.d.ts +3 -0
- package/dist/v1/domain/projection/classes.js +13 -41
- package/dist/v1/domain/validation/create.d.ts +2 -0
- package/dist/v1/domain/validation/create.js +12 -0
- package/dist/v1/index.d.ts +5 -2
- package/dist/v1/index.js +3 -1
- package/dist/v1/language/callable/composition.d.ts +27 -0
- package/dist/v1/language/callable/composition.js +52 -0
- package/dist/v1/language/callable/executable.d.ts +6 -0
- package/dist/v1/language/callable/executable.js +4 -0
- package/dist/v1/language/callable/model/callable.d.ts +34 -9
- package/dist/v1/language/callable/model/callable.js +3 -1
- package/dist/v1/language/callable/resolved.d.ts +23 -8
- package/dist/v1/language/class/facets.d.ts +5 -2
- package/dist/v1/language/class/inheritance.d.ts +12 -0
- package/dist/v1/language/class/inheritance.js +25 -0
- package/dist/v1/language/class/lifetime.d.ts +17 -0
- package/dist/v1/language/class/lifetime.js +26 -0
- package/dist/v1/language/class/model/class.d.ts +8 -4
- package/dist/v1/language/class/model/property.d.ts +4 -2
- package/dist/v1/language/class/property-values.js +5 -2
- package/dist/v1/language/class/resolved.d.ts +25 -15
- package/dist/v1/language/core/model/core.d.ts +7 -1
- package/dist/v1/language/core/resolved.d.ts +6 -2
- package/dist/v1/language/definition/metadata.d.ts +8 -0
- package/dist/v1/language/definition/metadata.js +12 -0
- package/dist/v1/language/index.d.ts +9 -0
- package/dist/v1/language/index.js +6 -0
- package/dist/v1/language/policy/analysis/branches.d.ts +4 -3
- package/dist/v1/language/policy/analysis/branches.js +54 -12
- package/dist/v1/language/policy/analysis/budgets.js +1 -1
- package/dist/v1/language/policy/analysis/checks.d.ts +28 -0
- package/dist/v1/language/policy/analysis/checks.js +80 -0
- package/dist/v1/language/policy/index.d.ts +1 -0
- package/dist/v1/language/policy/index.js +1 -0
- package/dist/v1/language/policy/model/policy.d.ts +71 -5
- package/dist/v1/language/policy/model/policy.js +52 -1
- package/dist/v1/language/policy/normalization/normalize.d.ts +12 -1
- package/dist/v1/language/policy/normalization/normalize.js +178 -44
- package/dist/v1/language/state/index.d.ts +3 -0
- package/dist/v1/language/state/index.js +1 -0
- package/dist/v1/language/state/machine.d.ts +28 -0
- package/dist/v1/language/state/machine.js +40 -0
- package/dist/v1/language/state/topology.d.ts +14 -0
- package/dist/v1/language/state/topology.js +69 -0
- package/dist/v1/language/value/compile/fields.d.ts +1 -1
- package/dist/v1/language/value/compile/load.d.ts +4 -2
- package/dist/v1/language/value/compile/load.js +22 -1
- package/dist/v1/language/value/compile/model.d.ts +16 -1
- package/dist/v1/language/value/evaluate/assertions.d.ts +2 -0
- package/dist/v1/language/value/evaluate/assertions.js +13 -0
- package/dist/v1/language/value/evaluate/evaluator.js +111 -28
- package/dist/v1/language/value/evaluate/preparation.d.ts +10 -1
- package/dist/v1/language/value/evaluate/preparation.js +17 -26
- package/dist/v1/language/value/evaluate/program.js +1 -1
- package/dist/v1/language/value/evaluate/validate.d.ts +6 -2
- package/dist/v1/language/value/evaluate/validate.js +18 -11
- package/dist/v1/language/value/inclusion/includes.d.ts +9 -0
- package/dist/v1/language/value/inclusion/includes.js +777 -0
- package/dist/v1/language/value/model/blob.d.ts +31 -0
- package/dist/v1/language/value/model/blob.js +90 -0
- package/dist/v1/language/value/model/instant.d.ts +0 -2
- package/dist/v1/language/value/model/instant.js +1 -1
- package/dist/v1/language/value/model/schema.d.ts +2 -1
- package/dist/v1/language/value/model/schema.js +1 -5
- package/dist/v1/language/value/ordering.d.ts +2 -0
- package/dist/v1/language/value/ordering.js +4 -8
- package/dist/v1/language/value/profile/json.validate.js +1 -1
- package/dist/v1/language/value/profile/rules.js +48 -12
- package/dist/v1/language/value/reference/registry.d.ts +2 -1
- package/dist/v1/language/value/regexp/ast.js +3 -64
- package/dist/v1/language/value/regexp/compile.d.ts +32 -3
- package/dist/v1/language/value/regexp/compile.js +117 -21
- package/dist/v1/language/value/regexp/matcher.d.ts +6 -3
- package/dist/v1/language/value/regexp/matcher.js +185 -28
- package/dist/v1/language/value/regexp/syntax.d.ts +12 -1
- package/dist/v1/language/value/regexp/syntax.js +14 -2
- package/dist/v1/language/value/regexp/unicode.d.ts +32 -0
- package/dist/v1/language/value/regexp/unicode.js +139 -0
- package/dist/v1/language/value/syntax/full-match.js +8 -5
- package/dist/v1/language/value/syntax/node-path/validate.js +4 -6
- package/dist/v1/language/view/model/view.d.ts +2 -4
- package/dist/v1/language/view/resolved.d.ts +2 -2
- package/dist/v1/schema/analysis/class.d.ts +36 -6
- package/dist/v1/schema/analysis/class.js +31 -66
- package/dist/v1/schema/canonical/revision.d.ts +2 -1
- package/dist/v1/schema/canonical/revision.js +4 -1
- package/dist/v1/schema/compatibility/api.d.ts +3 -0
- package/dist/v1/schema/compatibility/api.js +2 -0
- package/dist/v1/schema/compatibility/comparators/callables.d.ts +39 -0
- package/dist/v1/schema/compatibility/comparators/callables.js +101 -0
- package/dist/v1/schema/compatibility/comparators/classes.d.ts +47 -0
- package/dist/v1/schema/compatibility/comparators/classes.js +160 -0
- package/dist/v1/schema/compatibility/comparators/index.d.ts +12 -0
- package/dist/v1/schema/compatibility/comparators/index.js +53 -0
- package/dist/v1/schema/compatibility/comparators/members.d.ts +4 -0
- package/dist/v1/schema/compatibility/comparators/members.js +49 -0
- package/dist/v1/schema/compatibility/comparators/values.d.ts +5 -0
- package/dist/v1/schema/compatibility/comparators/values.js +37 -0
- package/dist/v1/schema/compatibility/compare.d.ts +5 -0
- package/dist/v1/schema/compatibility/compare.js +23 -0
- package/dist/v1/schema/compatibility/context.d.ts +19 -0
- package/dist/v1/schema/compatibility/context.js +49 -0
- package/dist/v1/schema/compatibility/coordinate.d.ts +40 -0
- package/dist/v1/schema/compatibility/coordinate.js +38 -0
- package/dist/v1/schema/compatibility/diff.d.ts +12 -0
- package/dist/v1/schema/compatibility/diff.js +39 -0
- package/dist/v1/schema/compatibility/evidence.d.ts +16 -0
- package/dist/v1/schema/compatibility/evidence.js +62 -0
- package/dist/v1/schema/compatibility/fields.d.ts +194 -0
- package/dist/v1/schema/compatibility/fields.js +94 -0
- package/dist/v1/schema/compatibility/index.d.ts +6 -0
- package/dist/v1/schema/compatibility/index.js +3 -0
- package/dist/v1/schema/compatibility/meaning/footprint.d.ts +7 -0
- package/dist/v1/schema/compatibility/meaning/footprint.js +59 -0
- package/dist/v1/schema/compatibility/meaning/index.d.ts +3 -0
- package/dist/v1/schema/compatibility/meaning/index.js +16 -0
- package/dist/v1/schema/compatibility/model.d.ts +131 -0
- package/dist/v1/schema/compatibility/model.js +1 -0
- package/dist/v1/schema/compatibility/references.d.ts +38 -0
- package/dist/v1/schema/compatibility/references.js +149 -0
- package/dist/v1/schema/compatibility/report.d.ts +27 -0
- package/dist/v1/schema/compatibility/report.js +100 -0
- package/dist/v1/schema/compatibility/scope.d.ts +36 -0
- package/dist/v1/schema/compatibility/scope.js +110 -0
- package/dist/v1/schema/compatibility/structure/index.d.ts +3 -0
- package/dist/v1/schema/compatibility/structure/index.js +40 -0
- package/dist/v1/schema/compatibility/structure/inheritance.d.ts +7 -0
- package/dist/v1/schema/compatibility/structure/inheritance.js +68 -0
- package/dist/v1/schema/compatibility/structure/requirements.d.ts +7 -0
- package/dist/v1/schema/compatibility/structure/requirements.js +97 -0
- package/dist/v1/schema/compatibility/subjects.d.ts +39 -0
- package/dist/v1/schema/compatibility/subjects.js +143 -0
- package/dist/v1/schema/compatibility/versioning/index.d.ts +8 -0
- package/dist/v1/schema/compatibility/versioning/index.js +50 -0
- package/dist/v1/schema/compatibility/versioning/members.d.ts +12 -0
- package/dist/v1/schema/compatibility/versioning/members.js +47 -0
- package/dist/v1/schema/compatibility/versioning/surface.d.ts +11 -0
- package/dist/v1/schema/compatibility/versioning/surface.js +61 -0
- package/dist/v1/schema/diagnostic.d.ts +1 -1
- package/dist/v1/schema/fingerprint.d.ts +2 -0
- package/dist/v1/schema/fingerprint.js +1 -0
- package/dist/v1/schema/index.d.ts +4 -3
- package/dist/v1/schema/index.js +2 -1
- package/dist/v1/schema/model/schema.d.ts +8 -11
- package/dist/v1/schema/normalization/domain.js +57 -13
- package/dist/v1/schema/resolution/definition.index.d.ts +1 -2
- package/dist/v1/schema/resolution/definition.index.js +0 -3
- package/dist/v1/schema/resolution/domain.d.ts +4 -1
- package/dist/v1/schema/resolution/domain.js +26 -18
- package/dist/v1/schema/resolution/origins.d.ts +28 -5
- package/dist/v1/schema/resolution/origins.js +68 -31
- package/dist/v1/schema/validation/callable.d.ts +4 -0
- package/dist/v1/schema/validation/callable.js +39 -0
- package/dist/v1/schema/validation/class.d.ts +10 -0
- package/dist/v1/schema/validation/class.js +79 -60
- package/dist/v1/schema/validation/core.js +83 -55
- package/dist/v1/schema/validation/domain.d.ts +2 -1
- package/dist/v1/schema/validation/domain.js +2 -0
- package/dist/v1/schema/validation/domain.structure.d.ts +0 -2
- package/dist/v1/schema/validation/domain.structure.js +214 -171
- package/dist/v1/schema/validation/policy/budgets.js +36 -6
- package/dist/v1/schema/validation/policy/context.js +5 -16
- package/dist/v1/schema/validation/policy/objects.d.ts +4 -0
- package/dist/v1/schema/validation/policy/objects.js +71 -0
- package/dist/v1/schema/validation/policy/references.js +16 -4
- package/dist/v1/schema/validation/policy/typing.d.ts +2 -0
- package/dist/v1/schema/validation/policy/typing.js +55 -7
- package/dist/v1/schema/validation/policy/uses.js +73 -99
- package/dist/v1/schema/validation/value-api.d.ts +2 -0
- package/dist/v1/schema/validation/value-api.js +1 -0
- package/dist/v1/schema/validation/value.js +7 -1
- package/dist/v1/schema/validation/view.js +14 -9
- package/dist/value/accept.d.ts +9 -0
- package/dist/value/accept.js +106 -7
- package/dist/value/canonical.d.ts +3 -0
- package/dist/value/canonical.js +22 -6
- package/dist/value/immutable.optimization.d.ts +15 -0
- package/dist/value/immutable.optimization.js +34 -0
- package/dist/value/index.d.ts +1 -1
- package/dist/value/index.js +1 -1
- package/dist/value/json.d.ts +1 -1
- package/dist/value/json.js +1 -1
- package/dist/value/limits.d.ts +1 -1
- package/dist/value/unicode.d.ts +4 -1
- package/dist/value/unicode.js +28 -0
- package/package.json +19 -3
- package/dist/v1/schema/compatibility/meaning.d.ts +0 -29
- package/dist/v1/schema/compatibility/meaning.js +0 -605
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { methodInheritance } from '../comparators/callables.js';
|
|
2
|
+
import { compareAddedProperties } from '../comparators/classes.js';
|
|
3
|
+
import { compareFacet } from '../comparators/index.js';
|
|
4
|
+
import { fingerprintMeaning } from '../comparators/values.js';
|
|
5
|
+
import { classCoordinate, methodCoordinate } from '../coordinate.js';
|
|
6
|
+
/**
|
|
7
|
+
* Compare inherited contracts and newly imposed obligations on existing Classes.
|
|
8
|
+
* Obligations are reported at their declaring Method: changed signatures retain their comparison;
|
|
9
|
+
* an unchanged obligation newly inherited by a Class is added and unsatisfied.
|
|
10
|
+
*/
|
|
11
|
+
export function compareSurface({ context, report, }) {
|
|
12
|
+
const established = new Map();
|
|
13
|
+
const imposed = new Map();
|
|
14
|
+
for (const declaration of Object.values(context.source.classes)) {
|
|
15
|
+
if (context.target.classes[declaration.ref.name] === undefined)
|
|
16
|
+
continue;
|
|
17
|
+
const pair = context.pair(classCoordinate(declaration.ref));
|
|
18
|
+
const { source, target } = pair;
|
|
19
|
+
if (source?.kind !== 'class' || target?.kind !== 'class')
|
|
20
|
+
continue;
|
|
21
|
+
report.record({
|
|
22
|
+
pair,
|
|
23
|
+
facet: 'class.inherit',
|
|
24
|
+
...compareFacet({ context, pair, facet: 'class.inherit' }),
|
|
25
|
+
requirement: { kind: 'class.inherit' },
|
|
26
|
+
});
|
|
27
|
+
compareAddedProperties({ context, pair, report });
|
|
28
|
+
for (const [key, method] of source.analysis.requirements)
|
|
29
|
+
if (!established.has(key))
|
|
30
|
+
established.set(key, method);
|
|
31
|
+
for (const [key, method] of target.analysis.requirements)
|
|
32
|
+
if (!source.analysis.requirements.has(key) && !imposed.has(key))
|
|
33
|
+
imposed.set(key, method);
|
|
34
|
+
}
|
|
35
|
+
for (const key of new Set([...established.keys(), ...imposed.keys()])) {
|
|
36
|
+
const added = imposed.get(key);
|
|
37
|
+
const method = established.get(key) ?? added;
|
|
38
|
+
const pair = context.pair(methodCoordinate(method.owner, method.name));
|
|
39
|
+
const comparison = established.has(key)
|
|
40
|
+
? compareFacet({ context, pair, facet: 'method.inheritance' })
|
|
41
|
+
: undefined;
|
|
42
|
+
report.record(comparison !== undefined && (added === undefined || changed(comparison))
|
|
43
|
+
? {
|
|
44
|
+
pair,
|
|
45
|
+
facet: 'method.inheritance',
|
|
46
|
+
...comparison,
|
|
47
|
+
requirement: { kind: 'method.inheritance' },
|
|
48
|
+
}
|
|
49
|
+
: {
|
|
50
|
+
pair,
|
|
51
|
+
facet: 'method.inheritance',
|
|
52
|
+
after: methodInheritance(added),
|
|
53
|
+
requirement: { kind: 'method.inheritance', satisfied: false },
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function changed({ before, after }) {
|
|
58
|
+
return (before === undefined ||
|
|
59
|
+
after === undefined ||
|
|
60
|
+
fingerprintMeaning(before) !== fingerprintMeaning(after));
|
|
61
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type SchemaDiagnosticCode = 'DM_MEMBER_ROOT_INVALID' | 'DM_DEPENDENCY_CONTEXT_INVALID' | 'DM_DEPENDENCY_NOT_RETAINED' | 'DM_MEANING_INCONSISTENT' | 'DM_MEMBER_ORIGIN_MISMATCH' | 'DV_ACCEPTANCE_CONTEXT' | 'DV_CALLABLE_AUTH' | 'DV_CALLABLE_IO' | 'DV_CALLABLE_POLICY_AUTH' | 'DV_CLASS_ABSTRACT' | 'DV_CLASS_ACYCLIC' | 'DV_CLASS_KIND' | 'DV_CORE_EDGE_CLASS' | 'DV_CORE_EDGE_CONSTRAINTS' | 'DV_CORE_EDGE_KEY' | 'DV_CORE_EDGE_PROPERTIES' | 'DV_CORE_NODE_CLASS' | 'DV_CORE_NODE_PROPERTIES' | 'DV_CORE_REF' | 'DV_DATA_COMPOSITION' | 'DV_DEPENDENCY_ACYCLIC' | 'DV_DEPENDENCY_DIRECT' | 'DV_DEPENDENCY_EXACT' | 'DV_DEPENDENCY_LIMITS' | 'DV_DEPENDENCY_REVISION_COHERENCE' | 'DV_DEPENDENCY_UNIQUE' | 'DV_EDGE_ACCEPTS' | 'DV_EDGE_CLASS_COMPOSITION' | 'DV_EDGE_CONSTRAINT' | 'DV_EDGE_ROLE' | 'DV_EDGE_UNDIRECTED' | 'DV_JSON_VALUE' | 'DV_METHOD_ABSTRACT' | 'DV_METHOD_COMPOSITION' | 'DV_PROPERTY_AUTO' | 'DV_PROPERTY_COMPOSITION' | '
|
|
1
|
+
export type SchemaDiagnosticCode = 'DM_CAPABILITY_INVALID' | 'DM_MEMBER_ROOT_INVALID' | 'DM_DEPENDENCY_CONTEXT_INVALID' | 'DM_DEPENDENCY_NOT_RETAINED' | 'DM_MEANING_INCONSISTENT' | 'DM_MEMBER_ORIGIN_MISMATCH' | 'DV_ACCEPTANCE_CONTEXT' | 'DV_CALLABLE_AUTH' | 'DV_CALLABLE_IO' | 'DV_CALLABLE_POLICY_AUTH' | 'DV_CLASS_ABSTRACT' | 'DV_CLASS_ACYCLIC' | 'DV_CLASS_KIND' | 'DV_CORE_EDGE_CLASS' | 'DV_CORE_EDGE_CONSTRAINTS' | 'DV_CORE_EDGE_KEY' | 'DV_CORE_EDGE_PROPERTIES' | 'DV_CORE_NODE_CLASS' | 'DV_CORE_NODE_PROPERTIES' | 'DV_CORE_REF' | 'DV_DATA_COMPOSITION' | 'DV_DEPENDENCY_ACYCLIC' | 'DV_DEPENDENCY_DIRECT' | 'DV_DEPENDENCY_EXACT' | 'DV_DEPENDENCY_LIMITS' | 'DV_DEPENDENCY_REVISION_COHERENCE' | 'DV_DEPENDENCY_UNIQUE' | 'DV_EDGE_ACCEPTS' | 'DV_EDGE_CLASS_COMPOSITION' | 'DV_EDGE_CONSTRAINT' | 'DV_EDGE_FOREIGN_MINIMUM' | 'DV_EDGE_ROLE' | 'DV_EDGE_UNDIRECTED' | 'DV_ENTRYPOINT' | 'DV_JSON_VALUE' | 'DV_METHOD_ABSTRACT' | 'DV_METHOD_COMPOSITION' | 'DV_PROPERTY_AUTO' | 'DV_PROPERTY_COMPOSITION' | 'DV_PROPERTY_IMMUTABLE' | 'DV_PROPERTY_STATE' | 'DV_REF_RESOLVES' | 'DV_VALUE_SCHEMA' | 'PL_BUDGET' | 'PL_COMPOSITION' | 'PL_CONNECTIVITY' | 'PL_REF' | 'PL_REPEAT' | 'PL_TARGET' | 'PL_TYPING' | 'PL_USE' | 'PL_VARIABLE_SCOPE' | 'STRUCTURE_ABSTRACT_POLICY' | 'STRUCTURE_CALLABLE_POLICY_AUTH' | 'STRUCTURE_DUPLICATE_ITEM' | 'STRUCTURE_EDGE_ORIENTATION' | 'STRUCTURE_FORMAT' | 'STRUCTURE_INVALID' | 'STRUCTURE_KEY' | 'STRUCTURE_MAXIMUM' | 'STRUCTURE_MINIMUM' | 'STRUCTURE_MULTIPLE' | 'STRUCTURE_REQUIRED' | 'STRUCTURE_TYPE' | 'STRUCTURE_UNION' | 'STRUCTURE_UNKNOWN_FIELD' | 'STRUCTURE_VALUE' | 'UNSUPPORTED_DOCUMENT_FORMAT' | 'UNSUPPORTED_DSL_VERSION';
|
|
2
2
|
export interface SchemaDiagnostic<out Code extends SchemaDiagnosticCode = SchemaDiagnosticCode> {
|
|
3
3
|
readonly code: Code;
|
|
4
4
|
readonly pointer: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { callableFingerprint } from './compatibility/comparators/callables.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** Admit, encode, inspect, and semantically resolve canonical V1 DomainSchemas. */
|
|
2
2
|
import type { SourceDomain } from '../domain/index.js';
|
|
3
3
|
import type { DomainSchema } from './model/schema.js';
|
|
4
|
-
export type { DomainSchema, DomainSchemaIR, DomainOfSchema as DomainOf
|
|
4
|
+
export type { DomainSchema, DomainSchemaIR, DomainOfSchema as DomainOf } from './model/schema.js';
|
|
5
5
|
export type ResolvedDomainOf<Schema extends DomainSchema> = SourceDomain<Schema>;
|
|
6
6
|
export interface Resolve {
|
|
7
7
|
<const Schema extends DomainSchema>(schema: Schema): ResolvedDomainOf<Schema>;
|
|
@@ -11,8 +11,9 @@ export type { SchemaDiagnosticCode as DiagnosticCode } from './diagnostic.js';
|
|
|
11
11
|
export { acceptDomainSchema as accept } from './admission/accept.js';
|
|
12
12
|
export { decodeDomainSchema as decode, encodeDomainSchema as encode, serializeDomainSchema as serialize, } from './codec/schema.js';
|
|
13
13
|
export { revisionOfDomainSchema as revision } from './canonical/revision.js';
|
|
14
|
-
export {
|
|
15
|
-
export type {
|
|
14
|
+
export { ANNOTATION_KEYWORDS, FIELD_ROLES, callableFingerprint } from './compatibility/index.js';
|
|
15
|
+
export type { FieldRole, MeaningDifference, MeaningFingerprint } from './compatibility/index.js';
|
|
16
|
+
export * as compatibility from './compatibility/api.js';
|
|
16
17
|
export { header } from './codec/header.js';
|
|
17
18
|
export { DOMAIN_FORMAT as FORMAT, DOMAIN_VERSION as VERSION } from './model/format.js';
|
|
18
19
|
export { compile, load } from '../compiled/index.js';
|
package/dist/v1/schema/index.js
CHANGED
|
@@ -4,7 +4,8 @@ export const resolve = resolveDomainSchema;
|
|
|
4
4
|
export { acceptDomainSchema as accept } from './admission/accept.js';
|
|
5
5
|
export { decodeDomainSchema as decode, encodeDomainSchema as encode, serializeDomainSchema as serialize, } from './codec/schema.js';
|
|
6
6
|
export { revisionOfDomainSchema as revision } from './canonical/revision.js';
|
|
7
|
-
export {
|
|
7
|
+
export { ANNOTATION_KEYWORDS, FIELD_ROLES, callableFingerprint } from './compatibility/index.js';
|
|
8
|
+
export * as compatibility from './compatibility/api.js';
|
|
8
9
|
export { header } from './codec/header.js';
|
|
9
10
|
export { DOMAIN_FORMAT as FORMAT, DOMAIN_VERSION as VERSION } from './model/format.js';
|
|
10
11
|
export { compile, load } from '../compiled/index.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Key } from '../../addressing/index.js';
|
|
2
|
-
import type { DomainDependencyMap } from '../../addressing/index.js';
|
|
2
|
+
import type { DomainDependencyMap, ViewRef } from '../../addressing/index.js';
|
|
3
3
|
import type { Domain, DomainOfSource, DomainSource } from '../../domain/model/domain.js';
|
|
4
4
|
import type { FunctionDefinition } from '../../language/callable/model/callable.js';
|
|
5
5
|
import type { ClassDefinition } from '../../language/class/model/class.js';
|
|
@@ -10,6 +10,10 @@ export interface DomainSchemaIR {
|
|
|
10
10
|
readonly format: 'astrale.dsl';
|
|
11
11
|
readonly version: 'v1';
|
|
12
12
|
readonly origin: Key.Origin;
|
|
13
|
+
/** Human-facing display name of the Domain, projected as its Domain Node `name`. */
|
|
14
|
+
readonly name: string;
|
|
15
|
+
/** The one View this Domain opens by default, projected as its `entrypoint` Edge. */
|
|
16
|
+
readonly entrypoint?: ViewRef;
|
|
13
17
|
readonly dependencies: DomainDependencyMap;
|
|
14
18
|
readonly classes: Readonly<Record<string, ClassDefinition>>;
|
|
15
19
|
readonly functions: Readonly<Record<string, FunctionDefinition>>;
|
|
@@ -18,20 +22,13 @@ export interface DomainSchemaIR {
|
|
|
18
22
|
readonly core: CoreContent;
|
|
19
23
|
}
|
|
20
24
|
declare const DOMAIN_SCHEMA_BRAND: unique symbol;
|
|
21
|
-
declare const DOMAIN_SCHEMA_INPUT: unique symbol;
|
|
22
25
|
/**
|
|
23
|
-
* Accepted canonical schema
|
|
24
|
-
*
|
|
25
|
-
* The input marker never exists as a JavaScript property and therefore cannot
|
|
26
|
-
* affect canonical JSON, bytes, or revision identity.
|
|
26
|
+
* Accepted canonical schema carrying its exact resolved Domain projection.
|
|
27
27
|
*/
|
|
28
|
-
export type DomainSchema<Origin extends string = string,
|
|
28
|
+
export type DomainSchema<Origin extends string = string, Resolved extends Domain = Domain> = DomainSchemaIR & DomainSource<Resolved> & {
|
|
29
29
|
readonly origin: Origin;
|
|
30
30
|
readonly [DOMAIN_SCHEMA_BRAND]: true;
|
|
31
|
-
readonly [DOMAIN_SCHEMA_INPUT]: Input;
|
|
32
31
|
};
|
|
33
|
-
/** Recover the exact builder input retained by a locally defined schema. */
|
|
34
|
-
export type DomainSchemaInputOf<Schema extends DomainSchema> = Schema[typeof DOMAIN_SCHEMA_INPUT];
|
|
35
32
|
export type DomainOfSchema<Schema extends DomainSchema> = DomainOfSource<Schema>;
|
|
36
|
-
export declare function asDomainSchema<Origin extends string = string,
|
|
33
|
+
export declare function asDomainSchema<Origin extends string = string, Resolved extends Domain = Domain>(value: DomainSchemaIR): DomainSchema<Origin, Resolved>;
|
|
37
34
|
export {};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { json } from '@astrale-os/kernel-dsl/value';
|
|
2
2
|
import { compareDefinitionRefs, compareUnicode } from '../../addressing/ordering.js';
|
|
3
|
-
import {
|
|
3
|
+
import { isBinaryInput } from '../../language/callable/model/callable.js';
|
|
4
|
+
import { normalizeClassRule, normalizePolicyChecks, normalizePolicyExpression, } from '../../language/policy/normalization/normalize.js';
|
|
5
|
+
import { admitStateTopology } from '../../language/state/topology.js';
|
|
4
6
|
import { canonicalizeValueSchema } from '../../language/value/profile/canonicalize.js';
|
|
5
7
|
export function normalizeDomainSchema(schema) {
|
|
6
8
|
const classes = mapRecord(schema.classes, canonicalizeClass);
|
|
@@ -11,6 +13,16 @@ export function normalizeDomainSchema(schema) {
|
|
|
11
13
|
format: 'astrale.dsl',
|
|
12
14
|
version: 'v1',
|
|
13
15
|
origin: schema.origin,
|
|
16
|
+
name: schema.name,
|
|
17
|
+
...(schema.entrypoint === undefined
|
|
18
|
+
? {}
|
|
19
|
+
: {
|
|
20
|
+
entrypoint: {
|
|
21
|
+
origin: schema.entrypoint.origin,
|
|
22
|
+
kind: 'view',
|
|
23
|
+
name: schema.entrypoint.name,
|
|
24
|
+
},
|
|
25
|
+
}),
|
|
14
26
|
dependencies: mapRecord(schema.dependencies, (dependency) => ({ ...dependency })),
|
|
15
27
|
classes,
|
|
16
28
|
functions: mapRecord(schema.functions, canonicalizeFunction),
|
|
@@ -40,12 +52,7 @@ function canonicalizeView(value) {
|
|
|
40
52
|
return {
|
|
41
53
|
ref: value.ref,
|
|
42
54
|
...withDescription(value),
|
|
43
|
-
target:
|
|
44
|
-
? { kind: 'domain' }
|
|
45
|
-
: {
|
|
46
|
-
kind: 'definition',
|
|
47
|
-
definitions: [...value.target.definitions].sort(compareDefinitionRefs),
|
|
48
|
-
},
|
|
55
|
+
target: { kind: 'domain' },
|
|
49
56
|
};
|
|
50
57
|
}
|
|
51
58
|
function canonicalizeClass(value) {
|
|
@@ -63,7 +70,7 @@ function canonicalizeClass(value) {
|
|
|
63
70
|
methods: mapRecord(value.methods, canonicalizeMethod),
|
|
64
71
|
...(value.data === undefined ? {} : { data: { mediaType: value.data.mediaType } }),
|
|
65
72
|
...(value.icon === undefined ? {} : { icon: value.icon }),
|
|
66
|
-
policies: value.policies,
|
|
73
|
+
policies: canonicalizeNodePolicies(value.policies),
|
|
67
74
|
};
|
|
68
75
|
}
|
|
69
76
|
return value.orientation === 'directed'
|
|
@@ -82,6 +89,13 @@ function canonicalizeClass(value) {
|
|
|
82
89
|
constraints: value.constraints,
|
|
83
90
|
};
|
|
84
91
|
}
|
|
92
|
+
/** A rule keeps one spelling: normalized checks, or the Policy a lone `self` check names. */
|
|
93
|
+
function canonicalizeNodePolicies(value) {
|
|
94
|
+
return {
|
|
95
|
+
...(value.read === undefined ? {} : { read: normalizeClassRule(value.read) }),
|
|
96
|
+
...(value.traverse === undefined ? {} : { traverse: normalizeClassRule(value.traverse) }),
|
|
97
|
+
};
|
|
98
|
+
}
|
|
85
99
|
function canonicalizeFunction(value) {
|
|
86
100
|
return {
|
|
87
101
|
ref: value.ref,
|
|
@@ -91,22 +105,35 @@ function canonicalizeFunction(value) {
|
|
|
91
105
|
function canonicalizeCallable(value) {
|
|
92
106
|
const base = {
|
|
93
107
|
...withDescription(value),
|
|
94
|
-
input:
|
|
108
|
+
input: isBinaryInput(value.input)
|
|
109
|
+
? {
|
|
110
|
+
mode: 'binary',
|
|
111
|
+
metadata: canonicalizeValueSchema(value.input.metadata, 'callable-input'),
|
|
112
|
+
maximumBytes: value.input.maximumBytes,
|
|
113
|
+
}
|
|
114
|
+
: canonicalizeValueSchema(value.input, 'callable-input'),
|
|
95
115
|
output: canonicalizeCallableOutput(value.output),
|
|
116
|
+
// Ordinary execution has one canonical form, so existing revisions never move.
|
|
117
|
+
...(value.execution?.durable === true ? { execution: { durable: true } } : {}),
|
|
96
118
|
};
|
|
97
119
|
return value.auth === 'authorized'
|
|
98
120
|
? {
|
|
99
121
|
...base,
|
|
100
122
|
auth: value.auth,
|
|
101
|
-
...(value.policy === undefined ? {} : { policy:
|
|
123
|
+
...(value.policy === undefined ? {} : { policy: canonicalizeCallablePolicy(value.policy) }),
|
|
102
124
|
}
|
|
103
125
|
: { ...base, auth: value.auth };
|
|
104
126
|
}
|
|
127
|
+
/** `true` has one spelling; Policy checks keep their normal form. */
|
|
128
|
+
function canonicalizeCallablePolicy(value) {
|
|
129
|
+
return value === true ? true : normalizePolicyChecks(value);
|
|
130
|
+
}
|
|
105
131
|
function canonicalizeMethod(value) {
|
|
106
132
|
return {
|
|
107
133
|
...canonicalizeCallable(value),
|
|
134
|
+
input: canonicalizeValueSchema(value.input, 'callable-input'),
|
|
108
135
|
static: value.static,
|
|
109
|
-
|
|
136
|
+
abstract: value.abstract,
|
|
110
137
|
};
|
|
111
138
|
}
|
|
112
139
|
function canonicalizeCallableOutput(value) {
|
|
@@ -123,7 +150,6 @@ function canonicalizeProperty(value) {
|
|
|
123
150
|
return {
|
|
124
151
|
schema: canonicalizeValueSchema(value.schema, 'property-facet'),
|
|
125
152
|
required: value.required,
|
|
126
|
-
visibility: value.visibility,
|
|
127
153
|
...(value.auto === undefined
|
|
128
154
|
? {}
|
|
129
155
|
: {
|
|
@@ -132,7 +158,11 @@ function canonicalizeProperty(value) {
|
|
|
132
158
|
set: value.auto.set,
|
|
133
159
|
},
|
|
134
160
|
}),
|
|
161
|
+
...(value.immutable === undefined ? {} : { immutable: value.immutable }),
|
|
135
162
|
...(value.description === undefined ? {} : { description: value.description }),
|
|
163
|
+
...(value.state === undefined
|
|
164
|
+
? {}
|
|
165
|
+
: { state: admitStateTopology(value.state) }),
|
|
136
166
|
};
|
|
137
167
|
}
|
|
138
168
|
function canonicalizeDirectedEndpoints(value) {
|
|
@@ -172,7 +202,21 @@ function compareCoreEndpoints(left, right) {
|
|
|
172
202
|
return right.kind === 'domain' ? 0 : -1;
|
|
173
203
|
if (right.kind === 'domain')
|
|
174
204
|
return 1;
|
|
175
|
-
|
|
205
|
+
const [a, b] = [coreEndpointOrder(left), coreEndpointOrder(right)];
|
|
206
|
+
return (compareUnicode(a.origin, b.origin) ||
|
|
207
|
+
compareUnicode(a.kind, b.kind) ||
|
|
208
|
+
compareUnicode(a.name, b.name) ||
|
|
209
|
+
compareUnicode(a.member, b.member));
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* A Method orders under its owner Class through the synthetic kind `method`; every other endpoint
|
|
213
|
+
* keeps the exact `compareDefinitionRefs` tuple with an empty member, so the canonical order of
|
|
214
|
+
* already-authored Core Edges — and therefore their revisions — never moves.
|
|
215
|
+
*/
|
|
216
|
+
function coreEndpointOrder(ref) {
|
|
217
|
+
return ref.kind === 'method'
|
|
218
|
+
? { origin: ref.owner.origin, kind: ref.kind, name: ref.owner.name, member: ref.name }
|
|
219
|
+
: { origin: ref.origin, kind: ref.kind, name: ref.name, member: '' };
|
|
176
220
|
}
|
|
177
221
|
function compareBytes(left, right) {
|
|
178
222
|
const encoder = new TextEncoder();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ClassRef
|
|
1
|
+
import type { ClassRef } from '../../addressing/index.js';
|
|
2
2
|
import type { ClassDefinition } from '../../language/class/model/class.js';
|
|
3
3
|
import type { DomainSchemaIR } from '../model/schema.js';
|
|
4
4
|
/** One exact Class declaration resolved within the retained Domain closure. */
|
|
@@ -18,4 +18,3 @@ export type IndexedClassDefinition = {
|
|
|
18
18
|
}>;
|
|
19
19
|
};
|
|
20
20
|
export declare function indexSchemaDefinitions(schema: DomainSchemaIR): ReadonlyMap<string, IndexedClassDefinition>;
|
|
21
|
-
export declare function resolveIndexedReference(indexes: ReadonlyMap<string, IndexedClassDefinition>, ref: DefinitionRef): IndexedClassDefinition | undefined;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import type { SourceDomain } from '../../domain/model/domain.js';
|
|
2
2
|
import type { DomainSchema } from '../model/schema.js';
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Resolve one accepted Schema through its exact retained source closure. Acceptance validated it
|
|
5
|
+
* against that closure, which is the only way a Schema retains one, so it is not validated again.
|
|
6
|
+
*/
|
|
4
7
|
export declare function resolve<const S extends DomainSchema>(schema: S): SourceDomain<S>;
|
|
@@ -2,18 +2,21 @@ import { Key, MethodKey, PropertyKey } from '../../addressing/index.js';
|
|
|
2
2
|
import { compareUnicode } from '../../addressing/ordering.js';
|
|
3
3
|
import { createDomain, createSourceDomain } from '../../domain/create.js';
|
|
4
4
|
import { createDomainValidation, unknownInputField } from '../../domain/validation/create.js';
|
|
5
|
+
import { isBinaryInput } from '../../language/callable/model/callable.js';
|
|
5
6
|
import { inputFieldNodes } from '../../language/value/compile/fields.js';
|
|
6
7
|
import { prepareValueSchema } from '../../language/value/evaluate/preparation.js';
|
|
7
8
|
import { validateValueProgram } from '../../language/value/evaluate/program.js';
|
|
8
|
-
import { validateJsonInstance } from '../../language/value/evaluate/validate.js';
|
|
9
|
-
import {
|
|
9
|
+
import { validateJsonInstance, validatePreparedInstance, } from '../../language/value/evaluate/validate.js';
|
|
10
|
+
import { classifyPreparedOrdering } from '../../language/value/ordering.js';
|
|
10
11
|
import { revisionOfDomainSchema } from '../canonical/revision.js';
|
|
11
|
-
import { SchemaError } from '../diagnostic.js';
|
|
12
|
-
import { validateDomainSchemaSemantics } from '../validation/domain.js';
|
|
13
12
|
import { lookupForDomainClosure } from './closure.js';
|
|
13
|
+
import { buildDomainResolutionContext } from './context.js';
|
|
14
14
|
import { createDomainValueSchemaRegistry } from './value.registry.js';
|
|
15
15
|
const resolvedSchemas = new WeakMap();
|
|
16
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* Resolve one accepted Schema through its exact retained source closure. Acceptance validated it
|
|
18
|
+
* against that closure, which is the only way a Schema retains one, so it is not validated again.
|
|
19
|
+
*/
|
|
17
20
|
export function resolve(schema) {
|
|
18
21
|
const cached = resolvedSchemas.get(schema);
|
|
19
22
|
if (cached !== undefined)
|
|
@@ -23,10 +26,7 @@ export function resolve(schema) {
|
|
|
23
26
|
return resolved;
|
|
24
27
|
}
|
|
25
28
|
function resolveWithLookup(schema, lookup) {
|
|
26
|
-
const
|
|
27
|
-
if (validation.diagnostics.length > 0)
|
|
28
|
-
throw new SchemaError(validation.diagnostics);
|
|
29
|
-
const closure = [schema, ...validation.context.dependencies.values()];
|
|
29
|
+
const closure = [schema, ...buildDomainResolutionContext(schema, lookup).dependencies.values()];
|
|
30
30
|
const registries = new Map(closure.map((owner) => [owner.origin, createDomainValueSchemaRegistry(owner, lookup)]));
|
|
31
31
|
const input = {
|
|
32
32
|
root: Object.freeze({
|
|
@@ -51,15 +51,21 @@ function resolveWithLookup(schema, lookup) {
|
|
|
51
51
|
function sourceValidation(closure, registries) {
|
|
52
52
|
const properties = new Map();
|
|
53
53
|
const callables = new Map();
|
|
54
|
+
const patterns = new Map();
|
|
54
55
|
for (const owner of closure) {
|
|
55
56
|
const registry = registries.get(owner.origin);
|
|
56
57
|
if (registry === undefined)
|
|
57
58
|
throw new TypeError(`No Value registry exists for ${owner.origin}.`);
|
|
58
59
|
for (const definition of Object.values(owner.classes)) {
|
|
59
60
|
for (const [name, property] of Object.entries(definition.properties)) {
|
|
61
|
+
const prepared = prepareValueSchema(property.schema, registry, '', patterns);
|
|
62
|
+
if (!prepared.compiled) {
|
|
63
|
+
throw new TypeError(`Accepted Property cannot be prepared: ${prepared.message}`);
|
|
64
|
+
}
|
|
60
65
|
properties.set(PropertyKey.of(definition.ref, name), Object.freeze({
|
|
61
|
-
ordering:
|
|
62
|
-
validate: (input) =>
|
|
66
|
+
ordering: classifyPreparedOrdering(prepared.value),
|
|
67
|
+
validate: (input) => validatePreparedInstance(prepared.value, input),
|
|
68
|
+
program: () => prepared.value.program(),
|
|
63
69
|
}));
|
|
64
70
|
}
|
|
65
71
|
if (definition.kind !== 'node')
|
|
@@ -69,21 +75,21 @@ function sourceValidation(closure, registries) {
|
|
|
69
75
|
? undefined
|
|
70
76
|
: method.output.mode === 'value'
|
|
71
77
|
? method.output.schema
|
|
72
|
-
: method.output.item, registry));
|
|
78
|
+
: method.output.item, registry, patterns));
|
|
73
79
|
}
|
|
74
80
|
}
|
|
75
81
|
for (const definition of Object.values(owner.functions)) {
|
|
76
|
-
callables.set(Key.of(definition.ref), callableValidation(definition.input, definition.output.mode === 'binary'
|
|
82
|
+
callables.set(Key.of(definition.ref), callableValidation(isBinaryInput(definition.input) ? definition.input.metadata : definition.input, definition.output.mode === 'binary'
|
|
77
83
|
? undefined
|
|
78
84
|
: definition.output.mode === 'value'
|
|
79
85
|
? definition.output.schema
|
|
80
|
-
: definition.output.item, registry));
|
|
86
|
+
: definition.output.item, registry, patterns));
|
|
81
87
|
}
|
|
82
88
|
}
|
|
83
89
|
return createDomainValidation(properties, callables);
|
|
84
90
|
}
|
|
85
|
-
function callableValidation(input, output, registry) {
|
|
86
|
-
const prepared = prepareValueSchema(input, registry, '');
|
|
91
|
+
function callableValidation(input, output, registry, patterns) {
|
|
92
|
+
const prepared = prepareValueSchema(input, registry, '', patterns);
|
|
87
93
|
if (!prepared.compiled) {
|
|
88
94
|
throw new TypeError(`Accepted callable input cannot be prepared: ${prepared.message}`);
|
|
89
95
|
}
|
|
@@ -91,14 +97,16 @@ function callableValidation(input, output, registry) {
|
|
|
91
97
|
const fields = inputFieldNodes(inputProgram);
|
|
92
98
|
return Object.freeze({
|
|
93
99
|
...(fields === undefined ? {} : { fields: Object.freeze(Object.keys(fields)) }),
|
|
94
|
-
validateInput: (value) =>
|
|
100
|
+
validateInput: (value) => validatePreparedInstance(prepared.value, value),
|
|
95
101
|
validateInputField(field, value) {
|
|
96
102
|
const nodes = fields?.[field];
|
|
97
103
|
return nodes === undefined
|
|
98
104
|
? unknownInputField(field)
|
|
99
105
|
: validateValueProgram(inputProgram, value, nodes);
|
|
100
106
|
},
|
|
101
|
-
validateOutput: (value) => output === undefined
|
|
107
|
+
validateOutput: (value) => output === undefined
|
|
108
|
+
? []
|
|
109
|
+
: validateJsonInstance(output, value, registry, '', patterns),
|
|
102
110
|
});
|
|
103
111
|
}
|
|
104
112
|
function definitionsOf(schema) {
|
|
@@ -1,14 +1,37 @@
|
|
|
1
|
-
import type { DefinitionRef } from '../../addressing/index.js';
|
|
1
|
+
import type { DefinitionRef, MethodAddress } from '../../addressing/index.js';
|
|
2
2
|
import type { FunctionDefinition, MethodDefinition } from '../../language/callable/model/callable.js';
|
|
3
3
|
import type { ClassDefinition } from '../../language/class/model/class.js';
|
|
4
|
+
import type { CoreEndpointRef } from '../../language/core/model/core.js';
|
|
4
5
|
import type { PolicyDefinition } from '../../language/policy/model/policy.js';
|
|
5
6
|
import type { JsonSchema } from '../../language/value/model/schema.js';
|
|
6
7
|
import type { DomainSchemaIR } from '../model/schema.js';
|
|
8
|
+
/**
|
|
9
|
+
* Where one schema references a Definition. `extends` and `core` mean the schema inherits from or
|
|
10
|
+
* instantiates the Definition; every other site only refers to it. `pattern` is the Edge Class a
|
|
11
|
+
* Policy pattern matches, whose orientation and accepted endpoint Classes Policy typing reads.
|
|
12
|
+
*/
|
|
13
|
+
export type ReferenceSite = 'extends' | 'endpoint' | 'value' | 'policy' | 'pattern' | 'core';
|
|
14
|
+
/**
|
|
15
|
+
* What a site names: a Definition, or the Class-owned Method a Policy object term names. A Policy
|
|
16
|
+
* keeps the Method itself, since it resolves that Method's own executable declaration; a collector
|
|
17
|
+
* that needs Definitions only takes its owner Class.
|
|
18
|
+
*/
|
|
19
|
+
export type ReferencedDefinition = DefinitionRef | MethodAddress;
|
|
20
|
+
export type ReferenceCollector = (ref: ReferencedDefinition, site: ReferenceSite) => void;
|
|
7
21
|
/** Collect only semantic refs, never strings or objects embedded as JSON data. */
|
|
8
22
|
export declare function collectUsedForeignOrigins(schema: DomainSchemaIR): ReadonlySet<string>;
|
|
9
23
|
/** Complete structured references in one schema, in canonical order. */
|
|
10
24
|
export declare function collectDomainDefinitionRefs(schema: DomainSchemaIR): readonly DefinitionRef[];
|
|
11
|
-
export declare function
|
|
12
|
-
|
|
13
|
-
export declare function
|
|
14
|
-
export declare function
|
|
25
|
+
export declare function collectCoreRefs(schema: DomainSchemaIR, add: ReferenceCollector): void;
|
|
26
|
+
/** The owning Domain addresses no Definition, and a Method is addressed through its owner Class. */
|
|
27
|
+
export declare function coreEndpointDefinitionRef(endpoint: CoreEndpointRef): DefinitionRef | undefined;
|
|
28
|
+
export declare function collectClassRefs(declaration: ClassDefinition, add: ReferenceCollector): void;
|
|
29
|
+
export declare function collectClassPolicyRefs(declaration: ClassDefinition, add: ReferenceCollector): void;
|
|
30
|
+
export declare function collectEndpointRefs(declaration: Extract<ClassDefinition, {
|
|
31
|
+
readonly kind: 'edge';
|
|
32
|
+
}>, add: ReferenceCollector): void;
|
|
33
|
+
export declare function collectCallableRefs(declaration: FunctionDefinition | MethodDefinition, add: ReferenceCollector): void;
|
|
34
|
+
/** References inside the contract a caller compiles against: the input and output value schemas. */
|
|
35
|
+
export declare function collectCallableContractRefs(declaration: Pick<FunctionDefinition | MethodDefinition, 'input' | 'output'>, add: ReferenceCollector): void;
|
|
36
|
+
export declare function collectPolicyDefinitionRefs(declaration: PolicyDefinition, add: ReferenceCollector): void;
|
|
37
|
+
export declare function collectValueDefinitionRefs(schema: JsonSchema, add: ReferenceCollector): void;
|