@astrale-os/kernel-dsl 0.2.0-beta.9 → 1.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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
|
@@ -1,605 +0,0 @@
|
|
|
1
|
-
import { json } from '@astrale-os/kernel-dsl/value';
|
|
2
|
-
import { Key, MethodKey, PropertyKey } from '../../addressing/index.js';
|
|
3
|
-
import { compareDefinitionRefs, compareUnicode, definitionRefIndex, } from '../../addressing/ordering.js';
|
|
4
|
-
import { isValueObject as isJsonObject } from '../../language/value/model/object.js';
|
|
5
|
-
import { SCHEMA_ARRAY_KEYWORDS, SCHEMA_MAP_KEYWORDS, SCHEMA_SINGLE_KEYWORDS, } from '../../language/value/syntax/keywords.js';
|
|
6
|
-
import { digestDomainSchemaBytes } from '../canonical/domain.digest.js';
|
|
7
|
-
import { revisionOfDomainSchema } from '../canonical/revision.js';
|
|
8
|
-
import { SchemaError, diagnostic } from '../diagnostic.js';
|
|
9
|
-
import { knownDomainClosure, lookupForDomainClosure } from '../resolution/closure.js';
|
|
10
|
-
import { resolve } from '../resolution/domain.js';
|
|
11
|
-
import { collectCallableRefs, collectClassRefs, collectPolicyDefinitionRefs, collectValueDefinitionRefs, } from '../resolution/origins.js';
|
|
12
|
-
import { validateDomainSchemaSemantics } from '../validation/domain.js';
|
|
13
|
-
const VALUE_SCHEMA_ANNOTATIONS = new Set([
|
|
14
|
-
'$comment',
|
|
15
|
-
'contentEncoding',
|
|
16
|
-
'contentMediaType',
|
|
17
|
-
'contentSchema',
|
|
18
|
-
'default',
|
|
19
|
-
'deprecated',
|
|
20
|
-
'description',
|
|
21
|
-
'examples',
|
|
22
|
-
'format',
|
|
23
|
-
'readOnly',
|
|
24
|
-
'title',
|
|
25
|
-
'writeOnly',
|
|
26
|
-
]);
|
|
27
|
-
/**
|
|
28
|
-
* Compare the exact V1 meaning one accepted Domain used from a retained dependency with a
|
|
29
|
-
* candidate revision of that same dependency origin. This operation is pure and makes no
|
|
30
|
-
* lifecycle-compatibility decision.
|
|
31
|
-
*/
|
|
32
|
-
export function compareDependencyMeaning(dependent, target) {
|
|
33
|
-
resolve(dependent);
|
|
34
|
-
const closure = knownDomainClosure(dependent) ?? [];
|
|
35
|
-
const source = closure.find((candidate) => candidate.schema.origin === target.origin)?.schema;
|
|
36
|
-
if (source === undefined) {
|
|
37
|
-
throw new SchemaError([
|
|
38
|
-
diagnostic('DM_DEPENDENCY_NOT_RETAINED', '/target/origin', `Domain ${dependent.origin} was not admitted with a dependency at ${target.origin}.`),
|
|
39
|
-
]);
|
|
40
|
-
}
|
|
41
|
-
const schemas = new Map([
|
|
42
|
-
[dependent.origin, dependent],
|
|
43
|
-
...closure.map(({ schema: candidate }) => [candidate.origin, candidate]),
|
|
44
|
-
]);
|
|
45
|
-
const sourceMeanings = collectDependencyMeanings(dependent, source.origin, schemas);
|
|
46
|
-
return compareSourceMeanings(source, target, sourceMeanings);
|
|
47
|
-
}
|
|
48
|
-
/** Compare one explicit non-empty source member surface and its reachable V1 meaning. */
|
|
49
|
-
export function compareMemberMeaning(source, target, roots) {
|
|
50
|
-
if (source.origin !== target.origin) {
|
|
51
|
-
throw new SchemaError([
|
|
52
|
-
diagnostic('DM_MEMBER_ORIGIN_MISMATCH', '/target/origin', `Member comparison target ${target.origin} does not match source ${source.origin}.`),
|
|
53
|
-
]);
|
|
54
|
-
}
|
|
55
|
-
if (!Array.isArray(roots) || roots.length === 0 || new Set(roots).size !== roots.length) {
|
|
56
|
-
throw new SchemaError([
|
|
57
|
-
diagnostic('DM_MEMBER_ROOT_INVALID', '/roots', 'Member comparison roots must be one non-empty duplicate-free Key set.'),
|
|
58
|
-
]);
|
|
59
|
-
}
|
|
60
|
-
resolve(source);
|
|
61
|
-
const closure = knownDomainClosure(source) ?? [];
|
|
62
|
-
const schemas = new Map([
|
|
63
|
-
[source.origin, source],
|
|
64
|
-
...closure.map(({ schema: candidate }) => [candidate.origin, candidate]),
|
|
65
|
-
]);
|
|
66
|
-
const coordinates = roots.map((key, index) => coordinateForKey(source, key, index));
|
|
67
|
-
const sourceMeanings = collectReachableMeanings(coordinates, source.origin, schemas);
|
|
68
|
-
return compareSourceMeanings(source, target, sourceMeanings);
|
|
69
|
-
}
|
|
70
|
-
function compareSourceMeanings(source, target, sourceMeanings) {
|
|
71
|
-
// Prove the candidate still has an exact accepted semantic context before comparing it.
|
|
72
|
-
resolve(target);
|
|
73
|
-
const footprint = Object.freeze([...sourceMeanings.keys()].sort(compareUnicode));
|
|
74
|
-
const changes = [];
|
|
75
|
-
const comparisonCoordinates = [];
|
|
76
|
-
for (const key of footprint) {
|
|
77
|
-
const sourceMeaning = sourceMeanings.get(key);
|
|
78
|
-
const targetMeaning = meaningForCoordinate(target, sourceMeaning.coordinate);
|
|
79
|
-
const targetFingerprint = targetMeaning === undefined ? undefined : fingerprintMeaning(targetMeaning);
|
|
80
|
-
comparisonCoordinates.push([
|
|
81
|
-
key,
|
|
82
|
-
sourceMeaning.fingerprint,
|
|
83
|
-
targetFingerprint ?? null,
|
|
84
|
-
]);
|
|
85
|
-
if (targetFingerprint === undefined) {
|
|
86
|
-
changes.push(Object.freeze({
|
|
87
|
-
key,
|
|
88
|
-
kind: 'missing',
|
|
89
|
-
sourceFingerprint: sourceMeaning.fingerprint,
|
|
90
|
-
}));
|
|
91
|
-
}
|
|
92
|
-
else if (targetFingerprint !== sourceMeaning.fingerprint) {
|
|
93
|
-
changes.push(Object.freeze({
|
|
94
|
-
key,
|
|
95
|
-
kind: 'changed',
|
|
96
|
-
sourceFingerprint: sourceMeaning.fingerprint,
|
|
97
|
-
targetFingerprint,
|
|
98
|
-
}));
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
const sourceRevision = revisionOfDomainSchema(source);
|
|
102
|
-
const targetRevision = revisionOfDomainSchema(target);
|
|
103
|
-
const immutableChanges = Object.freeze(changes);
|
|
104
|
-
const fingerprint = fingerprintMeaning({
|
|
105
|
-
version: 1,
|
|
106
|
-
dependency: source.origin,
|
|
107
|
-
source: sourceRevision,
|
|
108
|
-
target: targetRevision,
|
|
109
|
-
coordinates: comparisonCoordinates,
|
|
110
|
-
});
|
|
111
|
-
return Object.freeze({
|
|
112
|
-
version: 1,
|
|
113
|
-
dependency: source.origin,
|
|
114
|
-
source: sourceRevision,
|
|
115
|
-
target: targetRevision,
|
|
116
|
-
footprint,
|
|
117
|
-
changes: immutableChanges,
|
|
118
|
-
fingerprint,
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
function collectDependencyMeanings(dependent, dependencyOrigin, schemas) {
|
|
122
|
-
return collectReachableMeanings(collectSchemaSemanticRefs(dependent).map(memberCoordinate), dependencyOrigin, schemas);
|
|
123
|
-
}
|
|
124
|
-
function collectReachableMeanings(roots, selectedOrigin, schemas) {
|
|
125
|
-
const meanings = new Map();
|
|
126
|
-
const pending = [];
|
|
127
|
-
const visited = new Set();
|
|
128
|
-
for (const coordinate of roots) {
|
|
129
|
-
if (coordinate.kind === 'member') {
|
|
130
|
-
pending.push(coordinate.ref);
|
|
131
|
-
continue;
|
|
132
|
-
}
|
|
133
|
-
const owner = schemas.get(Key.origin(coordinate.key));
|
|
134
|
-
const meaning = owner === undefined ? undefined : meaningForCoordinate(owner, coordinate);
|
|
135
|
-
if (owner === undefined || meaning === undefined) {
|
|
136
|
-
throw new SchemaError([
|
|
137
|
-
diagnostic('DM_MEMBER_ROOT_INVALID', '/roots', `Member comparison root ${coordinate.key} does not exist in its source context.`, coordinate.key),
|
|
138
|
-
]);
|
|
139
|
-
}
|
|
140
|
-
retainMeaning(meanings, selectedOrigin, coordinate, meaning);
|
|
141
|
-
collectCoordinateSemanticRefs(owner, coordinate, (candidate) => pending.push(requireMemberRef(candidate)));
|
|
142
|
-
}
|
|
143
|
-
for (let index = 0; index < pending.length; index += 1) {
|
|
144
|
-
const ref = pending[index];
|
|
145
|
-
const refIndex = definitionRefIndex(ref);
|
|
146
|
-
if (visited.has(refIndex))
|
|
147
|
-
continue;
|
|
148
|
-
visited.add(refIndex);
|
|
149
|
-
const owner = schemas.get(ref.origin);
|
|
150
|
-
if (owner === undefined) {
|
|
151
|
-
throw new SchemaError([
|
|
152
|
-
diagnostic('DM_DEPENDENCY_CONTEXT_INVALID', '', `Retained acceptance context cannot resolve ${keyForDefinitionRef(ref)}.`, keyForDefinitionRef(ref)),
|
|
153
|
-
]);
|
|
154
|
-
}
|
|
155
|
-
const primary = memberCoordinate(ref);
|
|
156
|
-
const primaryMeaning = meaningForCoordinate(owner, primary);
|
|
157
|
-
if (primaryMeaning === undefined) {
|
|
158
|
-
throw new SchemaError([
|
|
159
|
-
diagnostic('DM_DEPENDENCY_CONTEXT_INVALID', '', `Retained acceptance context has no meaning for ${primary.key}.`, primary.key),
|
|
160
|
-
]);
|
|
161
|
-
}
|
|
162
|
-
retainMeaning(meanings, selectedOrigin, primary, primaryMeaning);
|
|
163
|
-
collectMemberSemanticRefs(owner, ref, (candidate) => pending.push(requireMemberRef(candidate)));
|
|
164
|
-
if (!isDefinitionRef(ref))
|
|
165
|
-
continue;
|
|
166
|
-
const analysis = effectiveDefinition(owner, ref);
|
|
167
|
-
if (analysis === undefined)
|
|
168
|
-
continue;
|
|
169
|
-
collectEffectiveMeanings(analysis, selectedOrigin, meanings, (candidate) => pending.push(requireMemberRef(candidate)));
|
|
170
|
-
}
|
|
171
|
-
return meanings;
|
|
172
|
-
}
|
|
173
|
-
function collectCoordinateSemanticRefs(owner, coordinate, add) {
|
|
174
|
-
const analysis = effectiveDefinition(owner, coordinate.owner);
|
|
175
|
-
if (analysis === undefined)
|
|
176
|
-
return;
|
|
177
|
-
if (coordinate.kind === 'property') {
|
|
178
|
-
const field = analysis.properties.get(coordinate.key);
|
|
179
|
-
if (field !== undefined)
|
|
180
|
-
collectValueDefinitionRefs(semanticValueSchema(field.schema), add);
|
|
181
|
-
return;
|
|
182
|
-
}
|
|
183
|
-
const method = [...analysis.methods.values()].find((candidate) => MethodKey.of(candidate.owner, candidate.name) === coordinate.key);
|
|
184
|
-
if (method !== undefined)
|
|
185
|
-
collectCallableRefs(semanticMethod(method.declaration), add);
|
|
186
|
-
}
|
|
187
|
-
function collectEffectiveMeanings(analysis, dependencyOrigin, meanings, add) {
|
|
188
|
-
for (const field of analysis.properties.values()) {
|
|
189
|
-
const coordinate = propertyCoordinate(field.owner, field.name);
|
|
190
|
-
retainMeaning(meanings, dependencyOrigin, coordinate, propertyMeaning(field));
|
|
191
|
-
add(field.owner);
|
|
192
|
-
collectValueDefinitionRefs(semanticValueSchema(field.schema), add);
|
|
193
|
-
}
|
|
194
|
-
for (const method of analysis.methods.values()) {
|
|
195
|
-
const coordinate = methodCoordinate(method.owner, method.name);
|
|
196
|
-
retainMeaning(meanings, dependencyOrigin, coordinate, methodMeaning(method));
|
|
197
|
-
add(method.owner);
|
|
198
|
-
collectCallableRefs(semanticMethod(method.declaration), add);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
function retainMeaning(meanings, dependencyOrigin, coordinate, meaning) {
|
|
202
|
-
if (Key.origin(coordinate.key) !== dependencyOrigin)
|
|
203
|
-
return;
|
|
204
|
-
const fingerprint = fingerprintMeaning(meaning);
|
|
205
|
-
const previous = meanings.get(coordinate.key);
|
|
206
|
-
if (previous !== undefined && previous.fingerprint !== fingerprint) {
|
|
207
|
-
throw new SchemaError([
|
|
208
|
-
diagnostic('DM_MEANING_INCONSISTENT', '', `Semantic coordinate ${coordinate.key} produced inconsistent effective meaning.`, coordinate.key),
|
|
209
|
-
]);
|
|
210
|
-
}
|
|
211
|
-
meanings.set(coordinate.key, Object.freeze({ coordinate, fingerprint }));
|
|
212
|
-
}
|
|
213
|
-
function collectSchemaSemanticRefs(owner) {
|
|
214
|
-
const refs = new Map();
|
|
215
|
-
const add = (ref) => {
|
|
216
|
-
const member = requireMemberRef(ref);
|
|
217
|
-
refs.set(definitionRefIndex(member), member);
|
|
218
|
-
};
|
|
219
|
-
for (const declaration of Object.values(owner.classes)) {
|
|
220
|
-
collectClassRefs(semanticDefinition(declaration), add);
|
|
221
|
-
}
|
|
222
|
-
for (const declaration of Object.values(owner.functions)) {
|
|
223
|
-
collectCallableRefs(semanticFunction(declaration), add);
|
|
224
|
-
}
|
|
225
|
-
for (const declaration of Object.values(owner.policies)) {
|
|
226
|
-
collectPolicyDefinitionRefs(semanticPolicy(declaration), add);
|
|
227
|
-
}
|
|
228
|
-
for (const declaration of Object.values(owner.views)) {
|
|
229
|
-
if (declaration.target.kind === 'definition')
|
|
230
|
-
declaration.target.definitions.forEach(add);
|
|
231
|
-
}
|
|
232
|
-
for (const node of Object.values(owner.core.nodes))
|
|
233
|
-
add(node.class);
|
|
234
|
-
for (const edge of owner.core.edges) {
|
|
235
|
-
add(edge.class);
|
|
236
|
-
if (edge.source.kind !== 'domain')
|
|
237
|
-
add(edge.source);
|
|
238
|
-
if (edge.target.kind !== 'domain')
|
|
239
|
-
add(edge.target);
|
|
240
|
-
}
|
|
241
|
-
return [...refs.values()].sort(compareDefinitionRefs);
|
|
242
|
-
}
|
|
243
|
-
function collectMemberSemanticRefs(owner, ref, add) {
|
|
244
|
-
switch (ref.kind) {
|
|
245
|
-
case 'class': {
|
|
246
|
-
const declaration = owner.classes[ref.name];
|
|
247
|
-
if (declaration !== undefined) {
|
|
248
|
-
collectClassRefs(semanticDefinition(declaration), add);
|
|
249
|
-
}
|
|
250
|
-
return;
|
|
251
|
-
}
|
|
252
|
-
case 'function': {
|
|
253
|
-
const declaration = owner.functions[ref.name];
|
|
254
|
-
if (declaration !== undefined)
|
|
255
|
-
collectCallableRefs(semanticFunction(declaration), add);
|
|
256
|
-
return;
|
|
257
|
-
}
|
|
258
|
-
case 'policy': {
|
|
259
|
-
const declaration = owner.policies[ref.name];
|
|
260
|
-
if (declaration !== undefined) {
|
|
261
|
-
collectPolicyDefinitionRefs(semanticPolicy(declaration), add);
|
|
262
|
-
}
|
|
263
|
-
return;
|
|
264
|
-
}
|
|
265
|
-
case 'view': {
|
|
266
|
-
const declaration = owner.views[ref.name];
|
|
267
|
-
if (declaration?.target.kind === 'definition')
|
|
268
|
-
declaration.target.definitions.forEach(add);
|
|
269
|
-
return;
|
|
270
|
-
}
|
|
271
|
-
case 'core': {
|
|
272
|
-
const node = owner.core.nodes[ref.name];
|
|
273
|
-
if (node === undefined)
|
|
274
|
-
return;
|
|
275
|
-
add(node.class);
|
|
276
|
-
for (const edge of incidentCoreEdges(owner, ref.name)) {
|
|
277
|
-
add(edge.class);
|
|
278
|
-
if (edge.source.kind !== 'domain')
|
|
279
|
-
add(edge.source);
|
|
280
|
-
if (edge.target.kind !== 'domain')
|
|
281
|
-
add(edge.target);
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
function meaningForCoordinate(owner, coordinate) {
|
|
287
|
-
if (Key.origin(coordinate.key) !== owner.origin)
|
|
288
|
-
return undefined;
|
|
289
|
-
if (coordinate.kind === 'member')
|
|
290
|
-
return memberMeaning(owner, coordinate.ref);
|
|
291
|
-
const analysis = effectiveDefinition(owner, coordinate.owner);
|
|
292
|
-
if (analysis === undefined)
|
|
293
|
-
return undefined;
|
|
294
|
-
if (coordinate.kind === 'property') {
|
|
295
|
-
const field = analysis.properties.get(coordinate.key);
|
|
296
|
-
return field === undefined ? undefined : propertyMeaning(field);
|
|
297
|
-
}
|
|
298
|
-
const method = [...analysis.methods.values()].find((candidate) => MethodKey.of(candidate.owner, candidate.name) === coordinate.key);
|
|
299
|
-
return method === undefined ? undefined : methodMeaning(method);
|
|
300
|
-
}
|
|
301
|
-
function memberMeaning(owner, ref) {
|
|
302
|
-
if (ref.origin !== owner.origin)
|
|
303
|
-
return undefined;
|
|
304
|
-
switch (ref.kind) {
|
|
305
|
-
case 'class':
|
|
306
|
-
return definitionMeaning(owner, ref);
|
|
307
|
-
case 'function': {
|
|
308
|
-
const declaration = owner.functions[ref.name];
|
|
309
|
-
return declaration === undefined
|
|
310
|
-
? undefined
|
|
311
|
-
: { kind: ref.kind, declaration: semanticFunction(declaration) };
|
|
312
|
-
}
|
|
313
|
-
case 'policy': {
|
|
314
|
-
const declaration = owner.policies[ref.name];
|
|
315
|
-
return declaration === undefined
|
|
316
|
-
? undefined
|
|
317
|
-
: { kind: ref.kind, declaration: semanticPolicy(declaration) };
|
|
318
|
-
}
|
|
319
|
-
case 'view': {
|
|
320
|
-
const declaration = owner.views[ref.name];
|
|
321
|
-
return declaration === undefined
|
|
322
|
-
? undefined
|
|
323
|
-
: { kind: ref.kind, declaration: semanticView(declaration) };
|
|
324
|
-
}
|
|
325
|
-
case 'core': {
|
|
326
|
-
const node = owner.core.nodes[ref.name];
|
|
327
|
-
return node === undefined
|
|
328
|
-
? undefined
|
|
329
|
-
: {
|
|
330
|
-
kind: ref.kind,
|
|
331
|
-
node,
|
|
332
|
-
edges: incidentCoreEdges(owner, ref.name),
|
|
333
|
-
};
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
function definitionMeaning(owner, ref) {
|
|
338
|
-
const declaration = owner.classes[ref.name];
|
|
339
|
-
const effective = effectiveDefinition(owner, ref);
|
|
340
|
-
if (declaration === undefined || effective === undefined || ref.origin !== owner.origin)
|
|
341
|
-
return undefined;
|
|
342
|
-
return {
|
|
343
|
-
kind: ref.kind,
|
|
344
|
-
declaration: semanticDefinition(declaration),
|
|
345
|
-
effective: {
|
|
346
|
-
properties: [...effective.properties.keys()].sort(compareUnicode),
|
|
347
|
-
methods: [...effective.methods.values()]
|
|
348
|
-
.map((method) => MethodKey.of(method.owner, method.name))
|
|
349
|
-
.sort(compareUnicode),
|
|
350
|
-
...(effective.data === undefined
|
|
351
|
-
? {}
|
|
352
|
-
: {
|
|
353
|
-
data: {
|
|
354
|
-
owner: keyForDefinitionRef(effective.data.owner),
|
|
355
|
-
declaration: effective.data.declaration,
|
|
356
|
-
},
|
|
357
|
-
}),
|
|
358
|
-
},
|
|
359
|
-
};
|
|
360
|
-
}
|
|
361
|
-
function effectiveDefinition(owner, ref) {
|
|
362
|
-
const validation = validateDomainSchemaSemantics(owner, lookupForDomainClosure(owner));
|
|
363
|
-
if (validation.diagnostics.length > 0)
|
|
364
|
-
return undefined;
|
|
365
|
-
return validation.analysis.definitions.get(definitionRefIndex(ref));
|
|
366
|
-
}
|
|
367
|
-
function propertyMeaning(field) {
|
|
368
|
-
return {
|
|
369
|
-
kind: 'property',
|
|
370
|
-
owner: keyForDefinitionRef(field.owner),
|
|
371
|
-
name: field.name,
|
|
372
|
-
schema: semanticValueSchema(field.schema),
|
|
373
|
-
required: field.required,
|
|
374
|
-
visibility: field.visibility,
|
|
375
|
-
};
|
|
376
|
-
}
|
|
377
|
-
function methodMeaning(method) {
|
|
378
|
-
return {
|
|
379
|
-
kind: 'method',
|
|
380
|
-
owner: keyForDefinitionRef(method.owner),
|
|
381
|
-
name: method.name,
|
|
382
|
-
declaration: semanticMethod(method.declaration),
|
|
383
|
-
};
|
|
384
|
-
}
|
|
385
|
-
function semanticDefinition(declaration) {
|
|
386
|
-
const { description: _description, ...rest } = declaration;
|
|
387
|
-
const semantic = {
|
|
388
|
-
...rest,
|
|
389
|
-
properties: Object.fromEntries(Object.entries(declaration.properties).map(([name, property]) => [
|
|
390
|
-
name,
|
|
391
|
-
{
|
|
392
|
-
...property,
|
|
393
|
-
schema: semanticValueSchema(property.schema),
|
|
394
|
-
},
|
|
395
|
-
])),
|
|
396
|
-
};
|
|
397
|
-
if ('methods' in declaration) {
|
|
398
|
-
semantic.methods = Object.fromEntries(Object.entries(declaration.methods).map(([name, method]) => [name, semanticMethod(method)]));
|
|
399
|
-
}
|
|
400
|
-
return semantic;
|
|
401
|
-
}
|
|
402
|
-
function semanticFunction(declaration) {
|
|
403
|
-
const { description: _description, ...rest } = declaration;
|
|
404
|
-
return {
|
|
405
|
-
...rest,
|
|
406
|
-
input: semanticValueSchema(declaration.input),
|
|
407
|
-
output: semanticOutput(declaration.output),
|
|
408
|
-
};
|
|
409
|
-
}
|
|
410
|
-
function semanticMethod(declaration) {
|
|
411
|
-
const { description: _description, ...rest } = declaration;
|
|
412
|
-
return {
|
|
413
|
-
...rest,
|
|
414
|
-
input: semanticValueSchema(declaration.input),
|
|
415
|
-
output: semanticOutput(declaration.output),
|
|
416
|
-
};
|
|
417
|
-
}
|
|
418
|
-
function semanticOutput(output) {
|
|
419
|
-
switch (output.mode) {
|
|
420
|
-
case 'value':
|
|
421
|
-
return { mode: 'value', schema: semanticValueSchema(output.schema) };
|
|
422
|
-
case 'stream':
|
|
423
|
-
return { mode: 'stream', item: semanticValueSchema(output.item) };
|
|
424
|
-
case 'binary':
|
|
425
|
-
return { mode: 'binary' };
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
function semanticPolicy(declaration) {
|
|
429
|
-
const { description: _description, ...semantic } = declaration;
|
|
430
|
-
return semantic;
|
|
431
|
-
}
|
|
432
|
-
function semanticView(declaration) {
|
|
433
|
-
const { description: _description, ...semantic } = declaration;
|
|
434
|
-
return semantic;
|
|
435
|
-
}
|
|
436
|
-
function semanticValueSchema(value) {
|
|
437
|
-
if (typeof value === 'boolean')
|
|
438
|
-
return value;
|
|
439
|
-
const semantic = {};
|
|
440
|
-
for (const [keyword, entry] of Object.entries(value)) {
|
|
441
|
-
if (VALUE_SCHEMA_ANNOTATIONS.has(keyword))
|
|
442
|
-
continue;
|
|
443
|
-
if (SCHEMA_SINGLE_KEYWORDS.has(keyword) && isJsonSchema(entry)) {
|
|
444
|
-
semantic[keyword] = semanticValueSchema(entry);
|
|
445
|
-
}
|
|
446
|
-
else if (SCHEMA_ARRAY_KEYWORDS.has(keyword) && Array.isArray(entry)) {
|
|
447
|
-
semantic[keyword] = entry.map((item) => isJsonSchema(item) ? semanticValueSchema(item) : item);
|
|
448
|
-
}
|
|
449
|
-
else if (SCHEMA_MAP_KEYWORDS.has(keyword) && isJsonObject(entry)) {
|
|
450
|
-
semantic[keyword] = Object.fromEntries(Object.entries(entry).map(([name, item]) => [
|
|
451
|
-
name,
|
|
452
|
-
isJsonSchema(item) ? semanticValueSchema(item) : item,
|
|
453
|
-
]));
|
|
454
|
-
}
|
|
455
|
-
else {
|
|
456
|
-
semantic[keyword] = entry;
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
return semantic;
|
|
460
|
-
}
|
|
461
|
-
function coordinateForKey(source, input, index) {
|
|
462
|
-
let key;
|
|
463
|
-
try {
|
|
464
|
-
key = Key(input);
|
|
465
|
-
}
|
|
466
|
-
catch {
|
|
467
|
-
return invalidMemberRoot(input, index, 'is not a canonical semantic Key');
|
|
468
|
-
}
|
|
469
|
-
if (Key.origin(key) !== source.origin) {
|
|
470
|
-
return invalidMemberRoot(key, index, `belongs to ${Key.origin(key)}, not source ${source.origin}`);
|
|
471
|
-
}
|
|
472
|
-
const reference = keyReference(key);
|
|
473
|
-
let coordinate;
|
|
474
|
-
if ((reference.member === 'property' || reference.member === 'method') &&
|
|
475
|
-
reference.ownerKind === 'class' &&
|
|
476
|
-
reference.ownerName !== undefined) {
|
|
477
|
-
const owner = definitionRefFor(source, reference.ownerKind, reference.ownerName);
|
|
478
|
-
if (owner === undefined) {
|
|
479
|
-
return invalidMemberRoot(key, index, 'has no exact owning Definition');
|
|
480
|
-
}
|
|
481
|
-
coordinate =
|
|
482
|
-
reference.member === 'property'
|
|
483
|
-
? propertyCoordinate(owner, reference.name)
|
|
484
|
-
: methodCoordinate(owner, reference.name);
|
|
485
|
-
}
|
|
486
|
-
else if (reference.kind !== 'core') {
|
|
487
|
-
const member = memberRefFor(source, {
|
|
488
|
-
origin: source.origin,
|
|
489
|
-
kind: reference.kind,
|
|
490
|
-
name: reference.name,
|
|
491
|
-
});
|
|
492
|
-
if (member === undefined)
|
|
493
|
-
return invalidMemberRoot(key, index, 'does not exist in the source');
|
|
494
|
-
coordinate = memberCoordinate(member);
|
|
495
|
-
}
|
|
496
|
-
else {
|
|
497
|
-
coordinate = memberCoordinate({
|
|
498
|
-
origin: source.origin,
|
|
499
|
-
kind: 'core',
|
|
500
|
-
name: reference.name,
|
|
501
|
-
});
|
|
502
|
-
}
|
|
503
|
-
if (meaningForCoordinate(source, coordinate) === undefined) {
|
|
504
|
-
return invalidMemberRoot(key, index, 'does not exist in the source');
|
|
505
|
-
}
|
|
506
|
-
return coordinate;
|
|
507
|
-
}
|
|
508
|
-
function memberRefFor(source, ref) {
|
|
509
|
-
const name = ref.name;
|
|
510
|
-
const owner = definitionRefFor(source, ref.kind, name);
|
|
511
|
-
if (owner !== undefined)
|
|
512
|
-
return owner;
|
|
513
|
-
switch (ref.kind) {
|
|
514
|
-
case 'function':
|
|
515
|
-
return source.functions[name] === undefined
|
|
516
|
-
? undefined
|
|
517
|
-
: { origin: source.origin, kind: 'function', name };
|
|
518
|
-
case 'policy':
|
|
519
|
-
return source.policies[name] === undefined
|
|
520
|
-
? undefined
|
|
521
|
-
: { origin: source.origin, kind: 'policy', name };
|
|
522
|
-
case 'view':
|
|
523
|
-
return source.views[name] === undefined
|
|
524
|
-
? undefined
|
|
525
|
-
: { origin: source.origin, kind: 'view', name };
|
|
526
|
-
default:
|
|
527
|
-
return undefined;
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
function definitionRefFor(source, namespace, name) {
|
|
531
|
-
if (namespace === 'class') {
|
|
532
|
-
return source.classes[name] === undefined
|
|
533
|
-
? undefined
|
|
534
|
-
: { origin: source.origin, kind: 'class', name };
|
|
535
|
-
}
|
|
536
|
-
return undefined;
|
|
537
|
-
}
|
|
538
|
-
function invalidMemberRoot(key, index, reason) {
|
|
539
|
-
throw new SchemaError([
|
|
540
|
-
diagnostic('DM_MEMBER_ROOT_INVALID', `/roots/${index}`, `Member comparison root ${JSON.stringify(key)} ${reason}.`, typeof key === 'string' ? key : undefined),
|
|
541
|
-
]);
|
|
542
|
-
}
|
|
543
|
-
function memberCoordinate(ref) {
|
|
544
|
-
return Object.freeze({ kind: 'member', key: keyForDefinitionRef(ref), ref });
|
|
545
|
-
}
|
|
546
|
-
function propertyCoordinate(owner, name) {
|
|
547
|
-
return Object.freeze({ kind: 'property', key: PropertyKey.of(owner, name), owner, name });
|
|
548
|
-
}
|
|
549
|
-
function methodCoordinate(owner, name) {
|
|
550
|
-
return Object.freeze({ kind: 'method', key: MethodKey.of(owner, name), owner, name });
|
|
551
|
-
}
|
|
552
|
-
function keyForDefinitionRef(ref) {
|
|
553
|
-
return ref.kind === 'core'
|
|
554
|
-
? Key.of(ref)
|
|
555
|
-
: Key.of(ref);
|
|
556
|
-
}
|
|
557
|
-
function keyReference(key) {
|
|
558
|
-
const semantic = key.slice(key.indexOf(':') + 1);
|
|
559
|
-
const parts = semantic.split('.');
|
|
560
|
-
if (parts[0] === 'core' && parts.length === 2) {
|
|
561
|
-
return { kind: 'core', name: parts[1] };
|
|
562
|
-
}
|
|
563
|
-
if (parts.length === 2) {
|
|
564
|
-
return { kind: parts[0], name: parts[1] };
|
|
565
|
-
}
|
|
566
|
-
if (parts.length === 4 &&
|
|
567
|
-
parts[0] === 'class' &&
|
|
568
|
-
(parts[2] === 'property' || parts[2] === 'method')) {
|
|
569
|
-
return {
|
|
570
|
-
kind: 'class',
|
|
571
|
-
name: parts[3],
|
|
572
|
-
member: parts[2],
|
|
573
|
-
ownerKind: 'class',
|
|
574
|
-
ownerName: parts[1],
|
|
575
|
-
};
|
|
576
|
-
}
|
|
577
|
-
throw new SchemaError([
|
|
578
|
-
diagnostic('DM_MEMBER_ROOT_INVALID', '/roots', `Key ${key} has no supported V1 shape.`, key),
|
|
579
|
-
]);
|
|
580
|
-
}
|
|
581
|
-
function incidentCoreEdges(owner, name) {
|
|
582
|
-
return owner.core.edges.filter((edge) => (edge.source.kind === 'core' && edge.source.name === name) ||
|
|
583
|
-
(edge.target.kind === 'core' && edge.target.name === name));
|
|
584
|
-
}
|
|
585
|
-
function fingerprintMeaning(value) {
|
|
586
|
-
return digestDomainSchemaBytes(json.encode(value));
|
|
587
|
-
}
|
|
588
|
-
function isDefinitionRef(ref) {
|
|
589
|
-
return ref.kind === 'class';
|
|
590
|
-
}
|
|
591
|
-
function requireMemberRef(ref) {
|
|
592
|
-
switch (ref.kind) {
|
|
593
|
-
case 'class':
|
|
594
|
-
case 'function':
|
|
595
|
-
case 'policy':
|
|
596
|
-
case 'view':
|
|
597
|
-
return ref;
|
|
598
|
-
case 'core':
|
|
599
|
-
return ref;
|
|
600
|
-
}
|
|
601
|
-
return ref;
|
|
602
|
-
}
|
|
603
|
-
function isJsonSchema(value) {
|
|
604
|
-
return typeof value === 'boolean' || isJsonObject(value);
|
|
605
|
-
}
|