@astrale-os/kernel-dsl 1.0.0-beta.2 → 1.0.0-beta.20
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 +3 -3
- package/dist/v1/addressing/definition-ref.js +21 -37
- package/dist/v1/addressing/domain-dependency.d.ts +0 -6
- package/dist/v1/addressing/domain-dependency.js +1 -6
- package/dist/v1/addressing/key.d.ts +4 -1
- package/dist/v1/addressing/key.js +23 -3
- package/dist/v1/addressing/ordering.d.ts +2 -0
- package/dist/v1/addressing/ordering.js +4 -0
- package/dist/v1/addressing/patterns.d.ts +1 -1
- package/dist/v1/addressing/patterns.js +2 -6
- package/dist/v1/builder/callable/authoring.d.ts +11 -5
- package/dist/v1/builder/callable/authoring.js +2 -0
- package/dist/v1/builder/class/authoring.d.ts +94 -224
- package/dist/v1/builder/class/authoring.js +31 -33
- package/dist/v1/builder/class/handle.d.ts +27 -0
- package/dist/v1/builder/class/handle.js +1 -0
- package/dist/v1/builder/class/input.d.ts +159 -0
- package/dist/v1/builder/class/projection.d.ts +129 -0
- package/dist/v1/builder/class/projection.js +1 -0
- package/dist/v1/builder/class/property.d.ts +3 -9
- package/dist/v1/builder/class/property.js +1 -0
- package/dist/v1/builder/core/authoring.d.ts +1 -1
- package/dist/v1/builder/index.d.ts +5 -2
- package/dist/v1/builder/lowering/callable.js +1 -0
- package/dist/v1/builder/lowering/class.d.ts +9 -1
- package/dist/v1/builder/lowering/class.js +62 -17
- package/dist/v1/builder/lowering/policy.js +2 -0
- package/dist/v1/builder/lowering/property-keys.d.ts +27 -0
- package/dist/v1/builder/lowering/property-keys.js +108 -0
- package/dist/v1/builder/lowering/schema/compile.js +11 -6
- package/dist/v1/builder/lowering/schema/context.d.ts +9 -1
- package/dist/v1/builder/lowering/schema/context.js +36 -4
- package/dist/v1/builder/lowering/schema/lifetime.d.ts +11 -0
- package/dist/v1/builder/lowering/schema/lifetime.js +55 -0
- package/dist/v1/builder/lowering/value/path.d.ts +1 -1
- package/dist/v1/builder/lowering/value/path.js +2 -4
- package/dist/v1/builder/lowering/value/zod.js +1 -3
- package/dist/v1/builder/policy/authoring.d.ts +85 -5
- package/dist/v1/builder/policy/authoring.js +107 -68
- package/dist/v1/builder/schema/define.d.ts +0 -1
- package/dist/v1/builder/schema/diagnostic.d.ts +3 -2
- package/dist/v1/builder/schema/diagnostic.js +5 -10
- package/dist/v1/builder/schema/input.d.ts +1 -1
- package/dist/v1/builder/schema/projection/callable.d.ts +7 -5
- package/dist/v1/builder/schema/projection/class.d.ts +118 -15
- package/dist/v1/builder/schema/projection/core-input.d.ts +2 -1
- package/dist/v1/builder/schema/projection/identity.d.ts +2 -1
- package/dist/v1/builder/schema/projection/model.d.ts +4 -2
- package/dist/v1/builder/schema/projection/property.d.ts +1 -1
- package/dist/v1/builder/schema/projection/resolved-class.d.ts +2 -1
- package/dist/v1/builder/schema/projection.d.ts +1 -1
- package/dist/v1/builder/value/full-match.d.ts +0 -1
- package/dist/v1/builder/value/full-match.js +0 -1
- package/dist/v1/builder/value/path-metadata.d.ts +1 -1
- package/dist/v1/builder/value/path.d.ts +1 -1
- package/dist/v1/bundle/codec.js +11 -13
- package/dist/v1/bundle/diagnostic.d.ts +2 -0
- package/dist/v1/bundle/diagnostic.js +9 -7
- package/dist/v1/bundle/model.js +1 -1
- package/dist/v1/bundle/structure.js +4 -6
- package/dist/v1/compiled/admission/accept.js +4 -10
- package/dist/v1/compiled/admission/closure.js +2 -2
- package/dist/v1/compiled/admission/diagnostic.d.ts +1 -1
- package/dist/v1/compiled/admission/diagnostic.js +1 -3
- package/dist/v1/compiled/admission/revision.d.ts +9 -1
- package/dist/v1/compiled/admission/revision.js +6 -3
- package/dist/v1/compiled/admission/semantics/class.d.ts +4 -1
- package/dist/v1/compiled/admission/semantics/class.js +37 -12
- package/dist/v1/compiled/admission/semantics/core.d.ts +1 -24
- package/dist/v1/compiled/admission/semantics/core.js +56 -24
- package/dist/v1/compiled/admission/semantics/edge.d.ts +2 -4
- package/dist/v1/compiled/admission/semantics/edge.js +6 -65
- package/dist/v1/compiled/admission/semantics/policy/callable.js +0 -2
- package/dist/v1/compiled/admission/semantics/policy/contracts.d.ts +5 -20
- package/dist/v1/compiled/admission/semantics/policy/contracts.js +8 -21
- package/dist/v1/compiled/admission/semantics/policy/parity.js +40 -43
- package/dist/v1/compiled/admission/semantics/policy/pattern.d.ts +4 -1
- package/dist/v1/compiled/admission/semantics/policy/pattern.js +4 -16
- package/dist/v1/compiled/admission/semantics/policy/typing.d.ts +2 -24
- package/dist/v1/compiled/admission/semantics/policy/typing.js +19 -201
- package/dist/v1/compiled/admission/wire/callable.js +11 -1
- package/dist/v1/compiled/admission/wire/class.js +73 -21
- package/dist/v1/compiled/admission/wire/policy.d.ts +4 -3
- package/dist/v1/compiled/admission/wire/policy.js +8 -7
- package/dist/v1/compiled/compiler/compile.js +8 -8
- package/dist/v1/compiled/diagnostic.js +2 -3
- package/dist/v1/compiled/loader/load.d.ts +3 -2
- package/dist/v1/compiled/loader/load.js +11 -45
- package/dist/v1/domain/create.js +5 -6
- package/dist/v1/domain/model/domain.d.ts +2 -7
- package/dist/v1/domain/model/input.d.ts +2 -1
- package/dist/v1/domain/namespace/member-collection.js +4 -6
- package/dist/v1/domain/projection/classes.js +4 -1
- package/dist/v1/domain/validation/create.d.ts +6 -3
- package/dist/v1/domain/validation/create.js +21 -69
- package/dist/v1/index.d.ts +2 -1
- package/dist/v1/language/.spec/schemas/draft-2020-12.schema.json +462 -0
- package/dist/v1/language/.spec/schemas/value-schema.schema.json +22 -0
- package/dist/v1/language/callable/admission.d.ts +15 -0
- package/dist/v1/language/callable/admission.js +43 -0
- package/dist/v1/language/callable/model/callable.d.ts +10 -0
- package/dist/v1/language/callable/resolved.d.ts +16 -3
- package/dist/v1/language/class/inheritance.d.ts +36 -5
- package/dist/v1/language/class/inheritance.js +87 -1
- package/dist/v1/language/class/lifetime.d.ts +50 -11
- package/dist/v1/language/class/lifetime.js +89 -20
- package/dist/v1/language/class/model/class.d.ts +45 -9
- package/dist/v1/language/class/model/edge.d.ts +31 -2
- package/dist/v1/language/class/model/property.d.ts +16 -7
- package/dist/v1/language/class/property-values.js +2 -4
- package/dist/v1/language/class/unique.d.ts +143 -0
- package/dist/v1/language/class/unique.js +264 -0
- package/dist/v1/language/core/facts.d.ts +85 -0
- package/dist/v1/language/core/facts.js +116 -0
- package/dist/v1/language/definition/metadata.d.ts +5 -0
- package/dist/v1/language/definition/metadata.js +7 -0
- package/dist/v1/language/freeze.d.ts +5 -0
- package/dist/v1/{schema/canonical → language}/freeze.js +4 -0
- package/dist/v1/language/index.d.ts +7 -2
- package/dist/v1/language/index.js +5 -1
- package/dist/v1/language/limits.d.ts +64 -0
- package/dist/v1/language/limits.js +60 -0
- package/dist/v1/language/policy/analysis/branches.d.ts +8 -0
- package/dist/v1/language/policy/analysis/branches.js +2 -1
- package/dist/v1/language/policy/analysis/budgets.d.ts +45 -12
- package/dist/v1/language/policy/analysis/budgets.js +133 -19
- package/dist/v1/language/policy/analysis/checks.js +3 -2
- package/dist/v1/language/policy/analysis/typing.d.ts +51 -0
- package/dist/v1/language/policy/analysis/typing.js +455 -0
- package/dist/v1/language/policy/model/policy.d.ts +49 -9
- package/dist/v1/language/policy/model/policy.js +14 -0
- package/dist/v1/language/policy/normalization/normalize.d.ts +6 -6
- package/dist/v1/language/policy/normalization/normalize.js +22 -21
- package/dist/v1/language/validation/diagnostic.d.ts +15 -1
- package/dist/v1/language/validation/diagnostic.js +21 -0
- package/dist/v1/language/validation/rule.d.ts +45 -0
- package/dist/v1/language/validation/rule.js +109 -0
- package/dist/v1/language/value/compile/fields.js +4 -8
- package/dist/v1/language/value/evaluate/program.d.ts +2 -1
- package/dist/v1/language/value/evaluate/program.js +2 -2
- package/dist/v1/language/value/evaluate/validate.d.ts +2 -2
- package/dist/v1/language/value/evaluate/validate.js +6 -2
- package/dist/v1/language/value/evaluate/validity.optimization.d.ts +14 -0
- package/dist/v1/language/value/evaluate/validity.optimization.js +342 -0
- package/dist/v1/language/value/inclusion/arrays.d.ts +3 -0
- package/dist/v1/language/value/inclusion/arrays.js +85 -0
- package/dist/v1/language/value/inclusion/assertions.d.ts +18 -0
- package/dist/v1/language/value/inclusion/assertions.js +29 -0
- package/dist/v1/language/value/inclusion/combinators.d.ts +3 -0
- package/dist/v1/language/value/inclusion/combinators.js +67 -0
- package/dist/v1/language/value/inclusion/equivalence.d.ts +4 -0
- package/dist/v1/language/value/inclusion/equivalence.js +74 -0
- package/dist/v1/language/value/inclusion/evidence.d.ts +34 -0
- package/dist/v1/language/value/inclusion/evidence.js +138 -0
- package/dist/v1/language/value/inclusion/includes.d.ts +17 -0
- package/dist/v1/language/value/inclusion/includes.js +25 -719
- package/dist/v1/language/value/inclusion/keywords.d.ts +5 -0
- package/dist/v1/language/value/inclusion/keywords.js +31 -0
- package/dist/v1/language/value/inclusion/kinds.d.ts +17 -0
- package/dist/v1/language/value/inclusion/kinds.js +57 -0
- package/dist/v1/language/value/inclusion/location.d.ts +24 -0
- package/dist/v1/language/value/inclusion/location.js +63 -0
- package/dist/v1/language/value/inclusion/numbers.d.ts +3 -0
- package/dist/v1/language/value/inclusion/numbers.js +41 -0
- package/dist/v1/language/value/inclusion/objects.d.ts +3 -0
- package/dist/v1/language/value/inclusion/objects.js +190 -0
- package/dist/v1/language/value/inclusion/strings.d.ts +3 -0
- package/dist/v1/language/value/inclusion/strings.js +29 -0
- package/dist/v1/language/value/inclusion/types.d.ts +3 -0
- package/dist/v1/language/value/inclusion/types.js +11 -0
- package/dist/v1/language/value/ordering.d.ts +14 -0
- package/dist/v1/language/value/ordering.js +86 -9
- package/dist/v1/language/value/profile/canonicalize.js +6 -5
- package/dist/v1/language/value/profile/json.validate.d.ts +3 -1
- package/dist/v1/language/value/profile/json.validate.js +3 -2
- package/dist/v1/language/value/profile/meta-schema.compiled.js +4 -1
- package/dist/v1/language/value/profile/rules.js +17 -43
- package/dist/v1/language/value/profile/validate.js +1 -10
- package/dist/v1/language/value/profile/vocabulary.d.ts +35 -2
- package/dist/v1/language/value/profile/vocabulary.js +52 -5
- package/dist/v1/language/value/reference/closure.js +3 -4
- package/dist/v1/language/value/reference/recursion.js +2 -22
- package/dist/v1/language/value/reference/registry.index.d.ts +2 -0
- package/dist/v1/language/value/reference/registry.index.js +33 -16
- package/dist/v1/language/value/regexp/ast.js +6 -7
- package/dist/v1/language/value/regexp/compile.d.ts +5 -11
- package/dist/v1/language/value/regexp/compile.js +14 -12
- package/dist/v1/language/value/regexp/syntax.js +3 -2
- package/dist/v1/language/value/syntax/keywords.d.ts +3 -3
- package/dist/v1/language/value/syntax/keywords.js +4 -20
- package/dist/v1/language/value/syntax/node-path/validate.js +2 -3
- package/dist/v1/language/value/syntax/pointer.d.ts +2 -0
- package/dist/v1/language/value/syntax/pointer.js +5 -2
- package/dist/v1/language/value/syntax/walk.d.ts +2 -0
- package/dist/v1/language/value/syntax/walk.js +19 -20
- package/dist/v1/schema/.spec/schemas/domain-schema.schema.json +2519 -0
- package/dist/v1/schema/admission/accept.js +3 -14
- package/dist/v1/schema/admission/callable.d.ts +21 -0
- package/dist/v1/schema/admission/callable.js +96 -0
- package/dist/v1/schema/analysis/class.js +33 -15
- package/dist/v1/schema/canonical/revision.js +4 -4
- package/dist/v1/schema/compatibility/api.d.ts +2 -1
- package/dist/v1/schema/compatibility/api.js +1 -0
- package/dist/v1/schema/compatibility/comparators/callables.js +1 -1
- package/dist/v1/schema/compatibility/comparators/classes.d.ts +9 -4
- package/dist/v1/schema/compatibility/comparators/classes.js +29 -8
- package/dist/v1/schema/compatibility/comparators/index.d.ts +1 -1
- package/dist/v1/schema/compatibility/comparators/members.js +1 -1
- package/dist/v1/schema/compatibility/comparators/values.js +2 -2
- package/dist/v1/schema/compatibility/coordinate.js +3 -3
- package/dist/v1/schema/compatibility/diff.js +2 -4
- package/dist/v1/schema/compatibility/extension.d.ts +11 -0
- package/dist/v1/schema/compatibility/extension.js +22 -0
- package/dist/v1/schema/compatibility/fields.d.ts +20 -4
- package/dist/v1/schema/compatibility/fields.js +13 -3
- package/dist/v1/schema/compatibility/meaning/footprint.js +16 -50
- package/dist/v1/schema/compatibility/model.d.ts +17 -5
- package/dist/v1/schema/compatibility/report.js +1 -1
- package/dist/v1/schema/compatibility/scope.d.ts +2 -0
- package/dist/v1/schema/compatibility/scope.js +4 -1
- package/dist/v1/schema/compatibility/structure/index.js +6 -4
- package/dist/v1/schema/compatibility/structure/requirements.js +57 -58
- package/dist/v1/schema/compatibility/versioning/index.js +1 -1
- package/dist/v1/schema/compatibility/versioning/surface.d.ts +1 -1
- package/dist/v1/schema/compatibility/versioning/surface.js +30 -2
- package/dist/v1/schema/compatibility/walk.d.ts +17 -0
- package/dist/v1/schema/compatibility/walk.js +41 -0
- package/dist/v1/schema/diagnostic.d.ts +17 -3
- package/dist/v1/schema/diagnostic.js +14 -11
- package/dist/v1/schema/index.d.ts +10 -1
- package/dist/v1/schema/index.js +4 -0
- package/dist/v1/schema/model/schema.d.ts +20 -1
- package/dist/v1/schema/model/schema.js +1 -1
- package/dist/v1/schema/normalization/domain.d.ts +2 -0
- package/dist/v1/schema/normalization/domain.js +29 -9
- package/dist/v1/schema/resolution/closure.js +2 -1
- package/dist/v1/schema/resolution/context.js +13 -13
- package/dist/v1/schema/resolution/domain.d.ts +5 -0
- package/dist/v1/schema/resolution/domain.js +2 -2
- package/dist/v1/schema/resolution/origins.js +3 -2
- package/dist/v1/schema/rule.d.ts +26 -0
- package/dist/v1/schema/rule.js +440 -0
- package/dist/v1/schema/validation/callable.d.ts +35 -2
- package/dist/v1/schema/validation/callable.js +65 -9
- package/dist/v1/schema/validation/class.d.ts +6 -2
- package/dist/v1/schema/validation/class.js +127 -104
- package/dist/v1/schema/validation/core.js +90 -168
- package/dist/v1/schema/validation/domain.js +4 -13
- package/dist/v1/schema/validation/domain.json-schema.d.ts +15 -0
- package/dist/v1/schema/validation/domain.json-schema.js +197 -0
- package/dist/v1/schema/validation/domain.route.d.ts +6 -1
- package/dist/v1/schema/validation/domain.route.js +18 -0
- package/dist/v1/schema/validation/domain.structure.d.ts +7780 -0
- package/dist/v1/schema/validation/domain.structure.js +398 -147
- package/dist/v1/schema/validation/json.json-schema.d.ts +40 -0
- package/dist/v1/schema/validation/json.json-schema.js +46 -0
- package/dist/v1/schema/validation/policy/budgets.d.ts +33 -2
- package/dist/v1/schema/validation/policy/budgets.js +87 -121
- package/dist/v1/schema/validation/policy/context.d.ts +6 -5
- package/dist/v1/schema/validation/policy/context.js +7 -10
- package/dist/v1/schema/validation/policy/objects.d.ts +1 -1
- package/dist/v1/schema/validation/policy/objects.js +6 -14
- package/dist/v1/schema/validation/policy/references.js +11 -27
- package/dist/v1/schema/validation/policy/typing.d.ts +3 -18
- package/dist/v1/schema/validation/policy/typing.js +22 -356
- package/dist/v1/schema/validation/policy/uses.d.ts +40 -3
- package/dist/v1/schema/validation/policy/uses.js +66 -89
- package/dist/v1/schema/validation/policy/validate.js +5 -5
- package/dist/v1/schema/validation/value-api.d.ts +22 -0
- package/dist/v1/schema/validation/value-api.js +34 -1
- package/dist/v1/schema/validation/value.d.ts +3 -0
- package/dist/v1/schema/validation/value.js +9 -17
- package/dist/v1/schema/validation/value.json-schema.d.ts +49 -0
- package/dist/v1/schema/validation/value.json-schema.js +137 -0
- package/dist/v1/schema/validation/view.js +4 -8
- package/dist/value/canonical.d.ts +6 -0
- package/dist/value/canonical.js +36 -0
- package/dist/value/decode.d.ts +7 -0
- package/dist/value/decode.js +159 -9
- package/dist/value/index.d.ts +1 -1
- package/dist/value/json.d.ts +2 -2
- package/dist/value/json.js +2 -2
- package/dist/value/types.d.ts +6 -0
- package/dist/value/unicode.d.ts +2 -1
- package/dist/value/unicode.js +2 -0
- package/package.json +8 -1
- package/dist/v1/builder/lowering/core-properties.d.ts +0 -10
- package/dist/v1/builder/lowering/core-properties.js +0 -76
- package/dist/v1/compiled/admission/semantics/cardinality.d.ts +0 -5
- package/dist/v1/compiled/admission/semantics/cardinality.js +0 -113
- package/dist/v1/compiled/admission/semantics/policy/equality.d.ts +0 -8
- package/dist/v1/compiled/admission/semantics/policy/equality.js +0 -27
- package/dist/v1/compiled/admission/semantics/policy/measure.d.ts +0 -9
- package/dist/v1/compiled/admission/semantics/policy/measure.js +0 -81
- package/dist/v1/compiled/admission/semantics/policy/variants.d.ts +0 -10
- package/dist/v1/compiled/admission/semantics/policy/variants.js +0 -65
- package/dist/v1/language/class/index.d.ts +0 -8
- package/dist/v1/language/class/index.js +0 -1
- package/dist/v1/language/core/index.d.ts +0 -2
- package/dist/v1/language/value/index.d.ts +0 -11
- package/dist/v1/language/value/index.js +0 -8
- package/dist/v1/schema/canonical/domain.d.ts +0 -3
- package/dist/v1/schema/canonical/domain.digest.d.ts +0 -3
- package/dist/v1/schema/canonical/domain.digest.js +0 -5
- package/dist/v1/schema/canonical/domain.js +0 -5
- package/dist/v1/schema/canonical/freeze.d.ts +0 -1
- /package/dist/v1/{language/core/index.js → builder/class/input.js} +0 -0
|
@@ -1,206 +1,24 @@
|
|
|
1
1
|
import { Key } from '../../../../addressing/index.js';
|
|
2
|
-
import {
|
|
3
|
-
import { branchesOf, branchProduct, capBranches, targetMode, termKey, } from '../../../../language/policy/analysis/branches.js';
|
|
2
|
+
import { PolicyTyping } from '../../../../language/policy/analysis/typing.js';
|
|
4
3
|
import {} from '../../../../language/policy/model/policy.js';
|
|
5
4
|
import {} from '../../../model/schema.js';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { CompiledUnionFind } from './equality.js';
|
|
9
|
-
import { compiledEdgeAlternatives } from './variants.js';
|
|
5
|
+
import { isCompiledEdge } from '../context.js';
|
|
6
|
+
import { referenceContract } from './contracts.js';
|
|
10
7
|
/** Types one entry's Policies against the Node Classes of its own closure, as source admission. */
|
|
11
|
-
export
|
|
12
|
-
context
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
expandedBranches(name, visiting, namespace) {
|
|
28
|
-
if (visiting.has(name))
|
|
29
|
-
return undefined;
|
|
30
|
-
const declaration = this.normalized.get(name);
|
|
31
|
-
if (declaration === undefined)
|
|
32
|
-
return undefined;
|
|
33
|
-
if ('match' in declaration)
|
|
34
|
-
return branchesOf(declaration.match, namespace);
|
|
35
|
-
const nested = new Set(visiting);
|
|
36
|
-
nested.add(name);
|
|
37
|
-
const refs = 'allOf' in declaration ? declaration.allOf : declaration.anyOf;
|
|
38
|
-
const children = [];
|
|
39
|
-
for (const [index, ref] of refs.entries()) {
|
|
40
|
-
if (ref.origin !== this.entry.origin || ref.kind !== 'policy')
|
|
41
|
-
return undefined;
|
|
42
|
-
const expanded = this.expandedBranches(ref.name, nested, `${namespace}/${index}:${ref.name}`);
|
|
43
|
-
if (expanded === undefined)
|
|
44
|
-
return undefined;
|
|
45
|
-
children.push(expanded);
|
|
46
|
-
}
|
|
47
|
-
return 'allOf' in declaration ? branchProduct(children) : capBranches(children.flat());
|
|
48
|
-
}
|
|
49
|
-
policyAccepts(name, object) {
|
|
50
|
-
return this.policyBranchTyping(name, object)?.every(Boolean) ?? false;
|
|
51
|
-
}
|
|
52
|
-
policyBranchTyping(name, object) {
|
|
53
|
-
const branches = this.expandedBranches(name, new Set(), `$use:${name}`);
|
|
54
|
-
return branches?.map((branch) => this.branchIsTyped(branch, { kind: 'object', object }));
|
|
55
|
-
}
|
|
56
|
-
policyAcceptsEdge(name, source, target) {
|
|
57
|
-
const branches = this.expandedBranches(name, new Set(), `$edge-use:${name}`);
|
|
58
|
-
return (branches !== undefined &&
|
|
59
|
-
branches.every((branch) => this.branchIsTyped(branch, { kind: 'edge', source, target })));
|
|
60
|
-
}
|
|
61
|
-
concreteEndpointClasses(accepts) {
|
|
62
|
-
return this.concreteNodeClasses.filter((candidate) => classSatisfiesAny(this.context, candidate, accepts));
|
|
63
|
-
}
|
|
64
|
-
endpointsOverlap(left, right) {
|
|
65
|
-
const seed = [{ kind: 'open', requirements: [] }];
|
|
66
|
-
return this.applyEndpoint(this.applyEndpoint(seed, left), right).length > 0;
|
|
67
|
-
}
|
|
68
|
-
branchIsTyped(branch, use) {
|
|
69
|
-
if (targetMode(branch) !== use.kind)
|
|
70
|
-
return false;
|
|
71
|
-
return compiledEdgeAlternatives(branch.edges, this).some((variants) => this.constraintsSatisfiable(branch, variants, use));
|
|
72
|
-
}
|
|
73
|
-
constraintsSatisfiable(branch, variants, use) {
|
|
74
|
-
const terms = new Set(use.kind === 'object' ? ['subject', 'object'] : ['subject', 'source', 'target']);
|
|
75
|
-
for (const key of branch.variables.keys())
|
|
76
|
-
terms.add(key);
|
|
77
|
-
for (const key of branch.terms.keys())
|
|
78
|
-
terms.add(key);
|
|
79
|
-
for (const edge of branch.edges) {
|
|
80
|
-
terms.add(termKey(edge.pattern.source, edge.namespace));
|
|
81
|
-
terms.add(termKey(edge.pattern.target, edge.namespace));
|
|
82
|
-
}
|
|
83
|
-
const union = new CompiledUnionFind(terms);
|
|
84
|
-
for (const [left, right] of branch.equalities)
|
|
85
|
-
union.join(left, right);
|
|
86
|
-
for (const variant of variants)
|
|
87
|
-
for (const [left, right] of variant.equalities)
|
|
88
|
-
union.join(left, right);
|
|
89
|
-
const constraints = new Map();
|
|
90
|
-
for (const variant of variants) {
|
|
91
|
-
for (const [term, accepts] of variant.constraints) {
|
|
92
|
-
const root = union.find(term);
|
|
93
|
-
const values = constraints.get(root) ?? [];
|
|
94
|
-
values.push(accepts);
|
|
95
|
-
constraints.set(root, values);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
const groups = new Map();
|
|
99
|
-
for (const term of terms) {
|
|
100
|
-
const root = union.find(term);
|
|
101
|
-
const values = groups.get(root) ?? [];
|
|
102
|
-
values.push(term);
|
|
103
|
-
groups.set(root, values);
|
|
104
|
-
}
|
|
105
|
-
for (const [root, members] of groups) {
|
|
106
|
-
let candidates = [{ kind: 'open', requirements: [] }];
|
|
107
|
-
for (const member of members) {
|
|
108
|
-
candidates = this.applyInitial(candidates, member, branch, use);
|
|
109
|
-
if (candidates.length === 0)
|
|
110
|
-
return false;
|
|
111
|
-
}
|
|
112
|
-
for (const endpoint of constraints.get(root) ?? []) {
|
|
113
|
-
candidates = this.applyEndpoint(candidates, endpoint);
|
|
114
|
-
if (candidates.length === 0)
|
|
115
|
-
return false;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
return true;
|
|
119
|
-
}
|
|
120
|
-
applyInitial(candidates, term, branch, use) {
|
|
121
|
-
if (term === 'subject')
|
|
122
|
-
return this.applyAnyNodeClass(candidates);
|
|
123
|
-
const contract = compiledTargetContract(term, use);
|
|
124
|
-
if (contract !== undefined) {
|
|
125
|
-
return contract.kind === 'exact'
|
|
126
|
-
? this.applyExact(candidates, contract.ref)
|
|
127
|
-
: uniqueCompiledCandidates(this.allNodeClasses.flatMap((ref) => this.applyExact(candidates, ref)));
|
|
128
|
-
}
|
|
129
|
-
const referenced = branch.terms.get(term);
|
|
130
|
-
if (referenced?.kind === 'ref') {
|
|
131
|
-
const contract = callableObjectContracts(this.context, this.entry, 0, undefined, referenced)?.[0];
|
|
132
|
-
return contract?.kind === 'exact' ? this.applyExact(candidates, contract.ref) : [];
|
|
133
|
-
}
|
|
134
|
-
const selector = branch.variables.get(term);
|
|
135
|
-
if (selector === undefined)
|
|
136
|
-
return [];
|
|
137
|
-
if (selector.kind === 'exact')
|
|
138
|
-
return this.applyExact(candidates, selector.class);
|
|
139
|
-
if (selector.kind === 'any')
|
|
140
|
-
return candidates;
|
|
141
|
-
return this.applyRequirement(candidates, selector.class);
|
|
142
|
-
}
|
|
143
|
-
applyExact(candidates, exact) {
|
|
144
|
-
return uniqueCompiledCandidates(candidates.flatMap((candidate) => {
|
|
145
|
-
if (candidate.kind === 'exact')
|
|
146
|
-
return Key.of(candidate.ref) === Key.of(exact) ? [candidate] : [];
|
|
147
|
-
return candidate.requirements.every((required) => classSatisfiesAny(this.context, exact, [required]))
|
|
148
|
-
? [{ kind: 'exact', ref: exact }]
|
|
149
|
-
: [];
|
|
150
|
-
}));
|
|
151
|
-
}
|
|
152
|
-
applyAnyNodeClass(candidates) {
|
|
153
|
-
return uniqueCompiledCandidates(candidates.flatMap((candidate) => candidate.kind === 'exact'
|
|
154
|
-
? [candidate]
|
|
155
|
-
: this.allNodeClasses
|
|
156
|
-
.filter((ref) => candidate.requirements.every((required) => classSatisfiesAny(this.context, ref, [required])))
|
|
157
|
-
.map((ref) => ({ kind: 'exact', ref }))));
|
|
158
|
-
}
|
|
159
|
-
applyRequirement(candidates, required) {
|
|
160
|
-
const result = [];
|
|
161
|
-
for (const candidate of candidates) {
|
|
162
|
-
if (candidate.kind === 'exact') {
|
|
163
|
-
if (classSatisfiesAny(this.context, candidate.ref, [required]))
|
|
164
|
-
result.push(candidate);
|
|
165
|
-
}
|
|
166
|
-
else {
|
|
167
|
-
result.push({
|
|
168
|
-
kind: 'open',
|
|
169
|
-
requirements: uniqueClassRefs([...candidate.requirements, required]),
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
return uniqueCompiledCandidates(result);
|
|
174
|
-
}
|
|
175
|
-
applyEndpoint(candidates, accepts) {
|
|
176
|
-
const result = [];
|
|
177
|
-
for (const candidate of candidates) {
|
|
178
|
-
if (candidate.kind === 'exact') {
|
|
179
|
-
if (classSatisfiesAny(this.context, candidate.ref, accepts))
|
|
180
|
-
result.push(candidate);
|
|
181
|
-
}
|
|
182
|
-
else {
|
|
183
|
-
for (const accept of accepts) {
|
|
184
|
-
result.push({
|
|
185
|
-
kind: 'open',
|
|
186
|
-
requirements: uniqueClassRefs([...candidate.requirements, accept]),
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
return uniqueCompiledCandidates(result);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
function uniqueCompiledCandidates(values) {
|
|
195
|
-
const result = new Map();
|
|
196
|
-
for (const value of values) {
|
|
197
|
-
const key = value.kind === 'exact'
|
|
198
|
-
? `exact:${Key.of(value.ref)}`
|
|
199
|
-
: `open:${value.requirements.map(Key.of).sort(compareUnicode).join('|')}`;
|
|
200
|
-
result.set(key, value);
|
|
201
|
-
}
|
|
202
|
-
return [...result.values()];
|
|
203
|
-
}
|
|
204
|
-
function uniqueClassRefs(values) {
|
|
205
|
-
return [...new Map(values.map((value) => [Key.of(value), value])).values()];
|
|
8
|
+
export function compiledPolicyTyping(context, entry, normalized, origins) {
|
|
9
|
+
const nodeClasses = [...context.classes.values()]
|
|
10
|
+
.map(({ value }) => value)
|
|
11
|
+
.filter((value) => value.kind === 'node' && origins.has(value.ref.origin));
|
|
12
|
+
return new PolicyTyping({
|
|
13
|
+
normalized,
|
|
14
|
+
allNodeClasses: nodeClasses.map((value) => value.ref),
|
|
15
|
+
concreteNodeClasses: nodeClasses.filter((value) => !value.abstract).map((value) => value.ref),
|
|
16
|
+
isLocalPolicy: (ref) => ref.origin === entry.origin && ref.kind === 'policy',
|
|
17
|
+
resolveClass: (ref) => context.classes.get(Key.of(ref))?.value,
|
|
18
|
+
edgeDeclaration: (ref) => {
|
|
19
|
+
const value = context.classes.get(Key.of(ref))?.value;
|
|
20
|
+
return value !== undefined && isCompiledEdge(value) ? value : undefined;
|
|
21
|
+
},
|
|
22
|
+
referenceContract: (ref) => referenceContract(context, ref),
|
|
23
|
+
});
|
|
206
24
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {} from '@astrale-os/kernel-dsl/value';
|
|
2
|
+
import { isAdmissionMaxAge } from '../../../language/callable/admission.js';
|
|
2
3
|
import {} from '../../model/schema.js';
|
|
3
4
|
import { invalid, pointer } from '../diagnostic.js';
|
|
4
5
|
import { callablePolicy } from './policy.js';
|
|
@@ -16,7 +17,7 @@ export function compiledCallable(input, values, method, path) {
|
|
|
16
17
|
const value = object(input, 'Compiled Callable', path);
|
|
17
18
|
exact(value, method
|
|
18
19
|
? ['name', 'auth', 'static', 'abstract', 'input', 'output']
|
|
19
|
-
: ['ref', 'auth', 'input', 'output'], 'Compiled Callable', path, ['policy', 'description', 'execution', 'fields']);
|
|
20
|
+
: ['ref', 'auth', 'input', 'output'], 'Compiled Callable', path, ['policy', 'description', 'execution', 'admission', 'fields']);
|
|
20
21
|
if (method) {
|
|
21
22
|
memberName(value.name, 'Method name', `${path}/name`);
|
|
22
23
|
boolean(value.static, 'Method static', `${path}/static`);
|
|
@@ -87,4 +88,13 @@ export function compiledCallable(input, values, method, path) {
|
|
|
87
88
|
invalid('durable Callable output', 'COMPILED_SOURCE_INVALID', `${outputPath}/mode`);
|
|
88
89
|
}
|
|
89
90
|
}
|
|
91
|
+
if (value.admission !== undefined) {
|
|
92
|
+
const admissionPath = `${path}/admission`;
|
|
93
|
+
const admission = object(value.admission, 'Callable admission', admissionPath);
|
|
94
|
+
exact(admission, ['maxAge'], 'Callable admission', admissionPath);
|
|
95
|
+
// An absent admission age is the only spelling of a call admitted afresh.
|
|
96
|
+
if (!isAdmissionMaxAge(admission.maxAge)) {
|
|
97
|
+
invalid('Callable admission age', 'COMPILED_SOURCE_INVALID', `${admissionPath}/maxAge`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
90
100
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import {} from '@astrale-os/kernel-dsl/value';
|
|
2
2
|
import { Key } from '../../../addressing/index.js';
|
|
3
3
|
import { MEDIA_TYPE_PATTERN } from '../../../language/class/model/data.js';
|
|
4
|
+
import { compareEdgeUniqueTuples, compareNodeUniqueTuples, edgeUniqueTuple, nodeUniqueTuple, } from '../../../language/class/unique.js';
|
|
5
|
+
import { CLASS_OPERATIONS, isClassObservation } from '../../../language/policy/model/policy.js';
|
|
4
6
|
import {} from '../../model/schema.js';
|
|
5
7
|
import { invalid } from '../diagnostic.js';
|
|
6
8
|
import { compiledCallable } from './callable.js';
|
|
@@ -25,9 +27,15 @@ export function compiledClass(input, values, path) {
|
|
|
25
27
|
'constraints',
|
|
26
28
|
'properties',
|
|
27
29
|
'policies',
|
|
28
|
-
], 'Compiled Class', path, value.kind === 'node'
|
|
30
|
+
], 'Compiled Class', path, value.kind === 'node'
|
|
31
|
+
? ['data', 'description', 'icon', 'inheritance', 'unique']
|
|
32
|
+
: ['description', 'inheritance', 'unique']);
|
|
29
33
|
definitionRef(value.ref, 'class', 'Class ref', `${path}/ref`);
|
|
30
34
|
boolean(value.abstract, 'Class abstract', `${path}/abstract`);
|
|
35
|
+
if (value.inheritance !== undefined &&
|
|
36
|
+
value.inheritance !== 'open' &&
|
|
37
|
+
value.inheritance !== 'final')
|
|
38
|
+
invalid('Class inheritance', undefined, `${path}/inheritance`);
|
|
31
39
|
description(value.description, 'Class description', `${path}/description`);
|
|
32
40
|
const extendsPath = `${path}/extends`;
|
|
33
41
|
const parents = array(value.extends, 'Class extends', extendsPath).map((parent, index) => definitionRef(parent, 'class', 'Class parent', `${extendsPath}/${index}`));
|
|
@@ -40,6 +48,8 @@ export function compiledClass(input, values, path) {
|
|
|
40
48
|
dataDefinition(value.data, `${path}/data`);
|
|
41
49
|
boundedString(value.icon, 1, 8000, 'Class icon', `${path}/icon`);
|
|
42
50
|
classPolicies(value.policies, 'node', `${path}/policies`);
|
|
51
|
+
if (value.unique !== undefined)
|
|
52
|
+
nodeUniqueTuples(value.unique, `${path}/unique`);
|
|
43
53
|
const methodsPath = `${path}/methods`;
|
|
44
54
|
const methods = array(value.methods, 'Class methods', methodsPath);
|
|
45
55
|
for (const [index, method] of methods.entries())
|
|
@@ -54,26 +64,30 @@ export function compiledClass(input, values, path) {
|
|
|
54
64
|
}
|
|
55
65
|
function classPolicies(input, kind, path) {
|
|
56
66
|
const value = object(input, 'Class Policies', path);
|
|
57
|
-
exact(value, [], 'Class Policies', path,
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
67
|
+
exact(value, [], 'Class Policies', path, CLASS_OPERATIONS);
|
|
68
|
+
for (const operation of CLASS_OPERATIONS) {
|
|
69
|
+
const policy = value[operation];
|
|
70
|
+
if (policy === undefined)
|
|
71
|
+
continue;
|
|
72
|
+
const label = `Class ${operation} Policy`;
|
|
73
|
+
const slot = `${path}/${operation}`;
|
|
74
|
+
if (isRuleChecks(policy)) {
|
|
75
|
+
classRuleChecks(policy, slot, kind === 'node' && operation === 'create' ? 'create' : 'class');
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
// Each slot spells one constant, and a Node create rule has no Node for a named Policy alone.
|
|
79
|
+
if (policy === !isClassObservation(operation))
|
|
80
|
+
continue;
|
|
81
|
+
if (kind === 'node' && operation === 'create')
|
|
82
|
+
invalid(label, undefined, slot);
|
|
83
|
+
definitionRef(policy, 'policy', label, slot);
|
|
84
|
+
}
|
|
62
85
|
}
|
|
63
|
-
/**
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
*/
|
|
67
|
-
function classPolicy(input, kind, label, path) {
|
|
68
|
-
if (kind === 'node' &&
|
|
69
|
-
input !== null &&
|
|
86
|
+
/** Policy checks, as opposed to a constant or a named Policy. */
|
|
87
|
+
function isRuleChecks(input) {
|
|
88
|
+
return (input !== null &&
|
|
70
89
|
typeof input === 'object' &&
|
|
71
|
-
['check', 'sameNode', 'allOf', 'anyOf'].some((key) => Object.hasOwn(input, key)))
|
|
72
|
-
classRuleChecks(input, path);
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
if (input !== false)
|
|
76
|
-
definitionRef(input, 'policy', label, path);
|
|
90
|
+
['check', 'sameNode', 'allOf', 'anyOf'].some((key) => Object.hasOwn(input, key)));
|
|
77
91
|
}
|
|
78
92
|
function edgeContract(value, path) {
|
|
79
93
|
const constraintsPath = `${path}/constraints`;
|
|
@@ -93,9 +107,13 @@ function edgeContract(value, path) {
|
|
|
93
107
|
object(endpoints.target, 'directed Edge target', `${endpointsPath}/target`).role) {
|
|
94
108
|
invalid('Edge endpoint roles', undefined, endpointsPath);
|
|
95
109
|
}
|
|
110
|
+
if (value.unique !== undefined)
|
|
111
|
+
uniqueTuples(value.unique, `${path}/unique`);
|
|
96
112
|
return;
|
|
97
113
|
}
|
|
98
|
-
if (value.orientation !== 'undirected' ||
|
|
114
|
+
if (value.orientation !== 'undirected' ||
|
|
115
|
+
constraints.acyclic !== undefined ||
|
|
116
|
+
value.unique !== undefined) {
|
|
99
117
|
invalid('Edge orientation', undefined, `${path}/orientation`);
|
|
100
118
|
}
|
|
101
119
|
const endpointsPath = `${path}/endpoints`;
|
|
@@ -109,9 +127,41 @@ function edgeContract(value, path) {
|
|
|
109
127
|
invalid('Edge endpoint roles', undefined, endpointsPath);
|
|
110
128
|
}
|
|
111
129
|
}
|
|
130
|
+
/** A nonempty list of canonical tuples (`edgeUniqueTuple`), distinct and in canonical order. */
|
|
131
|
+
function uniqueTuples(input, path) {
|
|
132
|
+
const tuples = array(input, 'Edge unique tuples', path);
|
|
133
|
+
if (tuples.length === 0)
|
|
134
|
+
invalid('Edge unique tuples', undefined, path);
|
|
135
|
+
const known = tuples.map((tuple, index) => {
|
|
136
|
+
const fields = edgeUniqueTuple(array(tuple, 'Edge unique tuple', `${path}/${index}`));
|
|
137
|
+
if (fields === undefined)
|
|
138
|
+
invalid('Edge unique tuple', undefined, `${path}/${index}`);
|
|
139
|
+
return fields;
|
|
140
|
+
});
|
|
141
|
+
for (const [index, tuple] of known.entries()) {
|
|
142
|
+
if (index > 0 && compareEdgeUniqueTuples(known[index - 1], tuple) >= 0)
|
|
143
|
+
invalid('Edge unique tuples', undefined, `${path}/${index}`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
/** A nonempty list of canonical Node tuples (`nodeUniqueTuple`), distinct and in canonical order. */
|
|
147
|
+
function nodeUniqueTuples(input, path) {
|
|
148
|
+
const tuples = array(input, 'Node unique tuples', path);
|
|
149
|
+
if (tuples.length === 0)
|
|
150
|
+
invalid('Node unique tuples', undefined, path);
|
|
151
|
+
const known = tuples.map((tuple, index) => {
|
|
152
|
+
const keys = nodeUniqueTuple(array(tuple, 'Node unique tuple', `${path}/${index}`));
|
|
153
|
+
if (keys === undefined)
|
|
154
|
+
invalid('Node unique tuple', undefined, `${path}/${index}`);
|
|
155
|
+
return keys;
|
|
156
|
+
});
|
|
157
|
+
for (const [index, tuple] of known.entries()) {
|
|
158
|
+
if (index > 0 && compareNodeUniqueTuples(known[index - 1], tuple) >= 0)
|
|
159
|
+
invalid('Node unique tuples', undefined, `${path}/${index}`);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
112
162
|
function edgeEndpoint(input, count, label, path) {
|
|
113
163
|
const value = object(input, label, path);
|
|
114
|
-
exact(value, ['role', 'accepts', count], label, path);
|
|
164
|
+
exact(value, ['role', 'accepts', count], label, path, ['onDelete']);
|
|
115
165
|
memberName(value.role, `${label} role`, `${path}/role`);
|
|
116
166
|
const acceptsPath = `${path}/accepts`;
|
|
117
167
|
const accepts = array(value.accepts, `${label} accepts`, acceptsPath).map((item, index) => definitionRef(item, 'class', `${label} accepted Class`, `${acceptsPath}/${index}`));
|
|
@@ -124,6 +174,8 @@ function edgeEndpoint(input, count, label, path) {
|
|
|
124
174
|
value[count] !== '1') {
|
|
125
175
|
invalid(`${label} ${count}`, undefined, `${path}/${count}`);
|
|
126
176
|
}
|
|
177
|
+
if (value.onDelete !== undefined && value.onDelete !== 'restrict' && value.onDelete !== 'detach')
|
|
178
|
+
invalid(`${label} onDelete`, undefined, `${path}/onDelete`);
|
|
127
179
|
}
|
|
128
180
|
function dataDefinition(input, path) {
|
|
129
181
|
const value = object(input, 'Class data', path);
|
|
@@ -4,7 +4,8 @@ export declare function compiledPolicy(input: JsonValue, path: string): never;
|
|
|
4
4
|
/** Check one callable's caller rule: `true`, the rule every caller satisfies, or Policy checks. */
|
|
5
5
|
export declare function callablePolicy(input: JsonValue | undefined, path: string): void;
|
|
6
6
|
/**
|
|
7
|
-
* Check one
|
|
8
|
-
* spelling. A lone check of `self` is spelled as the Policy
|
|
7
|
+
* Check one Class rule: Policy checks over `self` and `ref` objects only, or, in a Node create
|
|
8
|
+
* rule, `ref` objects only, in their one spelling. A lone check of `self` is spelled as the Policy
|
|
9
|
+
* reference itself.
|
|
9
10
|
*/
|
|
10
|
-
export declare function classRuleChecks(input: JsonValue, path: string): void;
|
|
11
|
+
export declare function classRuleChecks(input: JsonValue, path: string, site: 'class' | 'create'): void;
|
|
@@ -130,17 +130,18 @@ export function callablePolicy(input, path) {
|
|
|
130
130
|
policyCheck(input, 0, path);
|
|
131
131
|
}
|
|
132
132
|
/**
|
|
133
|
-
* Check one
|
|
134
|
-
* spelling. A lone check of `self` is spelled as the Policy
|
|
133
|
+
* Check one Class rule: Policy checks over `self` and `ref` objects only, or, in a Node create
|
|
134
|
+
* rule, `ref` objects only, in their one spelling. A lone check of `self` is spelled as the Policy
|
|
135
|
+
* reference itself.
|
|
135
136
|
*/
|
|
136
|
-
export function classRuleChecks(input, path) {
|
|
137
|
-
policyCheck(input, 0, path,
|
|
137
|
+
export function classRuleChecks(input, path, site) {
|
|
138
|
+
policyCheck(input, 0, path, site);
|
|
138
139
|
const rule = input;
|
|
139
140
|
if (json.serialize(normalizeClassRule(rule)) !== json.serialize(rule))
|
|
140
141
|
invalid('Class rule spelling', undefined, path);
|
|
141
142
|
}
|
|
142
143
|
/** What a site calls its checks in a refusal. */
|
|
143
|
-
const SITE = { callable: 'Callable Policy', class: 'Class rule' };
|
|
144
|
+
const SITE = { callable: 'Callable Policy', class: 'Class rule', create: 'Create rule' };
|
|
144
145
|
/** Check the recursive Policy check wire grammar of one use site. */
|
|
145
146
|
function policyCheck(input, depth, path, site = 'callable') {
|
|
146
147
|
const name = SITE[site];
|
|
@@ -148,7 +149,7 @@ function policyCheck(input, depth, path, site = 'callable') {
|
|
|
148
149
|
invalid(`${name} depth`, undefined, path);
|
|
149
150
|
const value = object(input, name, path);
|
|
150
151
|
if (Object.hasOwn(value, 'sameNode')) {
|
|
151
|
-
const equality = site === '
|
|
152
|
+
const equality = site === 'callable' ? 'Callable equality' : `${name} equality`;
|
|
152
153
|
exact(value, ['sameNode'], equality, path);
|
|
153
154
|
const pair = object(value.sameNode, equality, `${path}/sameNode`);
|
|
154
155
|
exact(pair, ['left', 'right'], `${equality} operands`, `${path}/sameNode`);
|
|
@@ -174,7 +175,7 @@ function policyCheck(input, depth, path, site = 'callable') {
|
|
|
174
175
|
function policyCheckObject(input, objectPath, site) {
|
|
175
176
|
const name = SITE[site];
|
|
176
177
|
const target = object(input, `${name} object`, objectPath);
|
|
177
|
-
if (target.kind === 'self')
|
|
178
|
+
if (target.kind === 'self' && site !== 'create')
|
|
178
179
|
exact(target, ['kind'], `${name} self`, objectPath);
|
|
179
180
|
else if (target.kind === 'input' && site === 'callable') {
|
|
180
181
|
exact(target, ['kind', 'field'], `${name} input`, objectPath);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { compareCodeUnits } from '../../addressing/ordering.js';
|
|
1
2
|
import { isBinaryInput } from '../../language/callable/model/callable.js';
|
|
2
3
|
import { inputFieldNodes } from '../../language/value/compile/fields.js';
|
|
3
4
|
import { prepareValueSchema } from '../../language/value/evaluate/preparation.js';
|
|
@@ -13,7 +14,7 @@ export function compile(schema) {
|
|
|
13
14
|
...requireDomainClosure(schema).map(({ schema: dependency }) => dependency),
|
|
14
15
|
]
|
|
15
16
|
.filter((value, index, all) => all.findIndex(({ origin }) => origin === value.origin) === index)
|
|
16
|
-
.sort((left, right) =>
|
|
17
|
+
.sort((left, right) => compareCodeUnits(left.origin, right.origin));
|
|
17
18
|
const closure = Object.freeze(sources.map((source) => compileEntry(source, lookup)));
|
|
18
19
|
return Object.freeze({
|
|
19
20
|
format: 'astrale.dsl.compiled-schema',
|
|
@@ -46,7 +47,7 @@ function compileEntry(schema, lookup) {
|
|
|
46
47
|
};
|
|
47
48
|
const add = (contract, pointer) => addProgram(prepare(contract, pointer).program());
|
|
48
49
|
const properties = (definition, pointer) => Object.entries(definition.properties)
|
|
49
|
-
.sort(([left], [right]) =>
|
|
50
|
+
.sort(([left], [right]) => compareCodeUnits(left, right))
|
|
50
51
|
.map(([name, property]) => {
|
|
51
52
|
const prepared = prepare(property.schema, `${pointer}/properties/${name}/schema`);
|
|
52
53
|
const ordering = classifyPreparedOrdering(prepared);
|
|
@@ -68,7 +69,7 @@ function compileEntry(schema, lookup) {
|
|
|
68
69
|
value: add(value.mode === 'value' ? value.schema : value.item, pointer),
|
|
69
70
|
};
|
|
70
71
|
const classes = Object.values(schema.classes)
|
|
71
|
-
.sort((left, right) =>
|
|
72
|
+
.sort((left, right) => compareCodeUnits(left.ref.name, right.ref.name))
|
|
72
73
|
.map((definition) => {
|
|
73
74
|
const pointer = `/classes/${definition.ref.name}`;
|
|
74
75
|
if (definition.kind === 'edge') {
|
|
@@ -77,7 +78,7 @@ function compileEntry(schema, lookup) {
|
|
|
77
78
|
}
|
|
78
79
|
const { properties: _, methods: __, ...rest } = definition;
|
|
79
80
|
const methods = Object.entries(definition.methods)
|
|
80
|
-
.sort(([left], [right]) =>
|
|
81
|
+
.sort(([left], [right]) => compareCodeUnits(left, right))
|
|
81
82
|
.map(([name, method]) => {
|
|
82
83
|
const input = add(method.input, `${pointer}/methods/${name}/input`);
|
|
83
84
|
const fields = inputFieldNodes(values[input]);
|
|
@@ -89,6 +90,7 @@ function compileEntry(schema, lookup) {
|
|
|
89
90
|
static: method.static,
|
|
90
91
|
abstract: method.abstract,
|
|
91
92
|
...(method.execution === undefined ? {} : { execution: method.execution }),
|
|
93
|
+
...(method.admission === undefined ? {} : { admission: method.admission }),
|
|
92
94
|
input,
|
|
93
95
|
...(fields === undefined ? {} : { fields }),
|
|
94
96
|
output: output(method.output, `${pointer}/methods/${name}/output`),
|
|
@@ -97,7 +99,7 @@ function compileEntry(schema, lookup) {
|
|
|
97
99
|
return { ...rest, properties: properties(definition, pointer), methods };
|
|
98
100
|
});
|
|
99
101
|
const functions = Object.values(schema.functions)
|
|
100
|
-
.sort((left, right) =>
|
|
102
|
+
.sort((left, right) => compareCodeUnits(left.ref.name, right.ref.name))
|
|
101
103
|
.map((definition) => {
|
|
102
104
|
const binary = isBinaryInput(definition.input);
|
|
103
105
|
const inputIndex = add(binary ? definition.input.metadata : definition.input, binary
|
|
@@ -117,6 +119,7 @@ function compileEntry(schema, lookup) {
|
|
|
117
119
|
...(definition.policy === undefined ? {} : { policy: definition.policy }),
|
|
118
120
|
...(definition.description === undefined ? {} : { description: definition.description }),
|
|
119
121
|
...(definition.execution === undefined ? {} : { execution: definition.execution }),
|
|
122
|
+
...(definition.admission === undefined ? {} : { admission: definition.admission }),
|
|
120
123
|
input,
|
|
121
124
|
...(fields === undefined ? {} : { fields }),
|
|
122
125
|
output: output(definition.output, `/functions/${definition.ref.name}/output`),
|
|
@@ -140,6 +143,3 @@ function compileEntry(schema, lookup) {
|
|
|
140
143
|
patterns: Object.freeze([...patternIndices.keys()]),
|
|
141
144
|
});
|
|
142
145
|
}
|
|
143
|
-
function compare(left, right) {
|
|
144
|
-
return left < right ? -1 : left > right ? 1 : 0;
|
|
145
|
-
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
+
import { formatDiagnostics } from '../language/validation/diagnostic.js';
|
|
1
2
|
export class CompiledSchemaError extends Error {
|
|
2
3
|
diagnostics;
|
|
3
4
|
constructor(diagnostics, options) {
|
|
4
|
-
super(diagnostics
|
|
5
|
-
.map(({ code, pointer, message }) => `${pointer || '/'} [${code}] ${message}`)
|
|
6
|
-
.join('\n'), options);
|
|
5
|
+
super(formatDiagnostics(diagnostics), options);
|
|
7
6
|
this.name = 'CompiledSchemaError';
|
|
8
7
|
this.diagnostics = Object.freeze([...diagnostics]);
|
|
9
8
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import type { Domain } from '../../domain/model/domain.js';
|
|
1
2
|
import type { CompiledSchema, DomainOfCompiled } from '../model/schema.js';
|
|
2
3
|
/** Load admitted compiled data through the one resolved Domain constructor. */
|
|
3
4
|
export declare function load<const Input extends CompiledSchema>(input: Input): DomainOfCompiled<Input>;
|
|
4
|
-
export declare function load(input: unknown):
|
|
5
|
+
export declare function load(input: unknown): Domain;
|
|
5
6
|
/**
|
|
6
7
|
* Realize compiled material whose exact embedded bytes were already proven by generated build code.
|
|
7
8
|
* External bytes and caller-provided values must continue through {@link load}.
|
|
8
9
|
*/
|
|
9
|
-
export declare function realize(compiled: CompiledSchema):
|
|
10
|
+
export declare function realize(compiled: CompiledSchema): Domain;
|