@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
|
@@ -6,9 +6,9 @@ export function normalizePolicyExpression(value) {
|
|
|
6
6
|
return { match: normalizePolicyPattern(value.match) };
|
|
7
7
|
}
|
|
8
8
|
if ('allOf' in value) {
|
|
9
|
-
return { allOf: uniqueRefs(value.allOf) };
|
|
9
|
+
return { allOf: operands(uniqueRefs(value.allOf)) };
|
|
10
10
|
}
|
|
11
|
-
return { anyOf: uniqueRefs(value.anyOf) };
|
|
11
|
+
return { anyOf: operands(uniqueRefs(value.anyOf)) };
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
14
|
* Passes after the first, while one still changes the Pattern. A pass numbers variables by the
|
|
@@ -40,16 +40,16 @@ function normalizePatternOnce(value) {
|
|
|
40
40
|
return normalizePatternNode(rewritten);
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
|
-
* The one spelling of a
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
43
|
+
* The one spelling of a Class rule: normalized Policy checks without a composition of one operand,
|
|
44
|
+
* or the Policy that a lone check of `self` names, which is how a Class has always declared one.
|
|
45
|
+
* Callable checks keep their compositions of one operand: their revisions predate this rule. A
|
|
46
|
+
* create rule checks no `self`, so it keeps its checks.
|
|
47
47
|
*/
|
|
48
48
|
export function normalizeClassRule(value) {
|
|
49
49
|
if (!isClassRuleChecks(value))
|
|
50
50
|
return value;
|
|
51
51
|
const checks = unwrapSingleOperands(normalizePolicyChecks(value));
|
|
52
|
-
return 'check' in checks && checks.object.kind === 'self' ? checks.check : checks;
|
|
52
|
+
return ('check' in checks && checks.object.kind === 'self' ? checks.check : checks);
|
|
53
53
|
}
|
|
54
54
|
/** Replace each composition of one operand by that operand, merging what it then nests. */
|
|
55
55
|
function unwrapSingleOperands(value) {
|
|
@@ -66,8 +66,7 @@ function unwrapSingleOperands(value) {
|
|
|
66
66
|
}));
|
|
67
67
|
if (children.length === 1)
|
|
68
68
|
return children[0];
|
|
69
|
-
|
|
70
|
-
return all ? { allOf: operands } : { anyOf: operands };
|
|
69
|
+
return all ? { allOf: operands(children) } : { anyOf: operands(children) };
|
|
71
70
|
}
|
|
72
71
|
export function normalizePolicyChecks(value) {
|
|
73
72
|
if ('check' in value)
|
|
@@ -79,17 +78,19 @@ export function normalizePolicyChecks(value) {
|
|
|
79
78
|
const normalized = normalizePolicyChecks(child);
|
|
80
79
|
return 'allOf' in normalized ? normalized.allOf : [normalized];
|
|
81
80
|
});
|
|
82
|
-
return { allOf:
|
|
81
|
+
return { allOf: operands(uniqueJson(children)) };
|
|
83
82
|
}
|
|
84
83
|
const children = value.anyOf.flatMap((child) => {
|
|
85
84
|
const normalized = normalizePolicyChecks(child);
|
|
86
85
|
return 'anyOf' in normalized ? normalized.anyOf : [normalized];
|
|
87
86
|
});
|
|
88
|
-
return { anyOf:
|
|
87
|
+
return { anyOf: operands(uniqueJson(children)) };
|
|
89
88
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
89
|
+
/**
|
|
90
|
+
* The operands of a non-empty list, mapped, flattened, deduplicated or sorted one by one: still at
|
|
91
|
+
* least one. The structure and compiled admission refuse an empty list.
|
|
92
|
+
*/
|
|
93
|
+
function operands(values) {
|
|
93
94
|
return values;
|
|
94
95
|
}
|
|
95
96
|
function normalizePatternNode(value) {
|
|
@@ -106,7 +107,7 @@ function normalizePatternNode(value) {
|
|
|
106
107
|
if ('exists' in value) {
|
|
107
108
|
return {
|
|
108
109
|
exists: {
|
|
109
|
-
nodes: [...value.exists.nodes].sort((left, right) => left.variable.id - right.variable.id),
|
|
110
|
+
nodes: operands([...value.exists.nodes].sort((left, right) => left.variable.id - right.variable.id)),
|
|
110
111
|
where: normalizePatternNode(value.exists.where),
|
|
111
112
|
},
|
|
112
113
|
};
|
|
@@ -116,13 +117,13 @@ function normalizePatternNode(value) {
|
|
|
116
117
|
const normalized = normalizePatternNode(child);
|
|
117
118
|
return 'allOf' in normalized ? normalized.allOf : [normalized];
|
|
118
119
|
});
|
|
119
|
-
return { allOf: uniqueJson(children) };
|
|
120
|
+
return { allOf: operands(uniqueJson(children)) };
|
|
120
121
|
}
|
|
121
122
|
const children = value.anyOf.flatMap((child) => {
|
|
122
123
|
const normalized = normalizePatternNode(child);
|
|
123
124
|
return 'anyOf' in normalized ? normalized.anyOf : [normalized];
|
|
124
125
|
});
|
|
125
|
-
return { anyOf: uniqueJson(children) };
|
|
126
|
+
return { anyOf: operands(uniqueJson(children)) };
|
|
126
127
|
}
|
|
127
128
|
function canonicalVariableIds(value) {
|
|
128
129
|
const declarations = new Map();
|
|
@@ -297,7 +298,7 @@ function rewriteVariables(value, ids) {
|
|
|
297
298
|
if ('exists' in value) {
|
|
298
299
|
return {
|
|
299
300
|
exists: {
|
|
300
|
-
nodes: value.exists.nodes.map((node) => {
|
|
301
|
+
nodes: operands(value.exists.nodes.map((node) => {
|
|
301
302
|
const variable = {
|
|
302
303
|
kind: 'variable',
|
|
303
304
|
id: ids.get(node.variable.id) ?? node.variable.id,
|
|
@@ -305,14 +306,14 @@ function rewriteVariables(value, ids) {
|
|
|
305
306
|
return 'class' in node
|
|
306
307
|
? { variable, class: node.class }
|
|
307
308
|
: { variable, selector: node.selector };
|
|
308
|
-
}),
|
|
309
|
+
})),
|
|
309
310
|
where: rewriteVariables(value.exists.where, ids),
|
|
310
311
|
},
|
|
311
312
|
};
|
|
312
313
|
}
|
|
313
314
|
if ('allOf' in value)
|
|
314
|
-
return { allOf: value.allOf.map((child) => rewriteVariables(child, ids)) };
|
|
315
|
-
return { anyOf: value.anyOf.map((child) => rewriteVariables(child, ids)) };
|
|
315
|
+
return { allOf: operands(value.allOf.map((child) => rewriteVariables(child, ids))) };
|
|
316
|
+
return { anyOf: operands(value.anyOf.map((child) => rewriteVariables(child, ids))) };
|
|
316
317
|
}
|
|
317
318
|
function selectorSignature(node) {
|
|
318
319
|
const selector = policyVariableSelector(node);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type DiagnosticCode = 'CALLABLE_INPUT_FIELD_UNKNOWN' | 'DOMAIN_CLASS_ABSTRACT' | 'DOMAIN_PROPERTY_INPUT_INVALID' | 'DOMAIN_PROPERTY_REQUIRED' | 'DOMAIN_PROPERTY_UNKNOWN' | '
|
|
1
|
+
export type DiagnosticCode = 'CALLABLE_INPUT_FIELD_UNKNOWN' | 'DOMAIN_CLASS_ABSTRACT' | 'DOMAIN_PROPERTY_INPUT_INVALID' | 'DOMAIN_PROPERTY_REQUIRED' | 'DOMAIN_PROPERTY_UNKNOWN' | 'VALUE_SCHEMA_INSTANCE_INVALID' | 'VS_DIALECT' | 'VS_DYNAMIC_FORBIDDEN' | 'VS_KEYWORD_CLOSED' | 'VS_META_SCHEMA' | 'VS_NUMBER_DOMAIN' | 'VS_PATH_EXTENSION' | 'VS_RECURSION_PRODUCTIVE' | 'VS_REFERENCE_FORM' | 'VS_REFERENCE_RESOLUTION' | 'VS_REGEX_PORTABLE' | 'VS_RESOURCE_ID' | 'VS_VALUE_KIND' | 'VS_VALUE_KIND_JSON';
|
|
2
2
|
export interface Diagnostic<out Code extends DiagnosticCode = DiagnosticCode> {
|
|
3
3
|
readonly code: Code;
|
|
4
4
|
readonly pointer: string;
|
|
@@ -6,3 +6,17 @@ export interface Diagnostic<out Code extends DiagnosticCode = DiagnosticCode> {
|
|
|
6
6
|
readonly ref?: string;
|
|
7
7
|
}
|
|
8
8
|
export declare function diagnostic<const Code extends DiagnosticCode>(code: Code, pointer: string, message: string, ref?: string): Diagnostic<Code>;
|
|
9
|
+
/** The fields every diagnostic family shares. */
|
|
10
|
+
interface DiagnosticFields {
|
|
11
|
+
readonly code: string;
|
|
12
|
+
readonly pointer: string;
|
|
13
|
+
readonly message: string;
|
|
14
|
+
readonly ref?: string;
|
|
15
|
+
}
|
|
16
|
+
/** Order diagnostics by pointer, then code, then message. */
|
|
17
|
+
export declare function orderDiagnostics<Value extends DiagnosticFields>(diagnostics: readonly Value[]): Value[];
|
|
18
|
+
/** Keep one of each pointer, code, ref and message, then order them. */
|
|
19
|
+
export declare function orderAndDeduplicate<Value extends DiagnosticFields>(diagnostics: readonly Value[]): Value[];
|
|
20
|
+
/** One line per diagnostic: its pointer (`/` for the root), its code and its message. */
|
|
21
|
+
export declare function formatDiagnostics(diagnostics: readonly DiagnosticFields[]): string;
|
|
22
|
+
export {};
|
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
import { compareUnicode } from '../../addressing/ordering.js';
|
|
1
2
|
export function diagnostic(code, pointer, message, ref) {
|
|
2
3
|
return Object.freeze({ code, pointer, message, ...(ref === undefined ? {} : { ref }) });
|
|
3
4
|
}
|
|
5
|
+
/** Order diagnostics by pointer, then code, then message. */
|
|
6
|
+
export function orderDiagnostics(diagnostics) {
|
|
7
|
+
return [...diagnostics].sort((left, right) => compareUnicode(left.pointer, right.pointer) ||
|
|
8
|
+
compareUnicode(left.code, right.code) ||
|
|
9
|
+
compareUnicode(left.message, right.message));
|
|
10
|
+
}
|
|
11
|
+
/** Keep one of each pointer, code, ref and message, then order them. */
|
|
12
|
+
export function orderAndDeduplicate(diagnostics) {
|
|
13
|
+
const unique = new Map();
|
|
14
|
+
for (const value of diagnostics) {
|
|
15
|
+
unique.set(`${value.pointer}\u0000${value.code}\u0000${value.ref ?? ''}\u0000${value.message}`, value);
|
|
16
|
+
}
|
|
17
|
+
return orderDiagnostics([...unique.values()]);
|
|
18
|
+
}
|
|
19
|
+
/** One line per diagnostic: its pointer (`/` for the root), its code and its message. */
|
|
20
|
+
export function formatDiagnostics(diagnostics) {
|
|
21
|
+
return diagnostics
|
|
22
|
+
.map(({ code, pointer, message }) => `${pointer || '/'} [${code}] ${message}`)
|
|
23
|
+
.join('\n');
|
|
24
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { LimitKey } from '../limits.js';
|
|
2
|
+
import type { DiagnosticCode } from './diagnostic.js';
|
|
3
|
+
/**
|
|
4
|
+
* What a rule reads to decide. `schema`: a value schema alone, with its place in the declaration
|
|
5
|
+
* that holds it (a Property, a callable input or output). `context`: a value schema and what its
|
|
6
|
+
* Domain can reach, the Node Classes of the Domain and of its direct dependencies and the exact
|
|
7
|
+
* dependency closure. `value`: a value, under an accepted schema or a contract of the Domain.
|
|
8
|
+
* `warning`: a value schema, which the rule reports without refusing it.
|
|
9
|
+
*/
|
|
10
|
+
export type ValueRuleStage = 'schema' | 'context' | 'value' | 'warning';
|
|
11
|
+
/**
|
|
12
|
+
* The rule one diagnostic code reports, whatever it checks: what `schema.RULES` and `VALUE_RULES`
|
|
13
|
+
* say of every code, each with the stages of its own checks.
|
|
14
|
+
*/
|
|
15
|
+
export interface DiagnosticRule {
|
|
16
|
+
/**
|
|
17
|
+
* The positions the rule constrains, which its diagnostics point at: JSON Pointer templates in
|
|
18
|
+
* which a `{name}` token stands for one token of the kind it names and `{/path*}` for any number
|
|
19
|
+
* of tokens.
|
|
20
|
+
*/
|
|
21
|
+
readonly positions: readonly [string, ...string[]];
|
|
22
|
+
/** The rule, in one plain sentence. */
|
|
23
|
+
readonly statement: string;
|
|
24
|
+
/** The limits of `schema.limits` the rule enforces, by key, where it enforces some. */
|
|
25
|
+
readonly limits?: readonly [LimitKey, ...LimitKey[]];
|
|
26
|
+
/**
|
|
27
|
+
* The conditions of the published JSON Schema of the document that state the rule, where some
|
|
28
|
+
* do: the URI fragment of each `if` or `not` subschema whose failure refuses the document with
|
|
29
|
+
* this rule's code.
|
|
30
|
+
*/
|
|
31
|
+
readonly conditions?: readonly [string, ...string[]];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The rule one value diagnostic code reports. Its positions are relative to the value schema, the
|
|
35
|
+
* value or the Domain input it checks. A condition refuses a value schema of the document with
|
|
36
|
+
* `DV_VALUE_SCHEMA` and this rule's code as its `valueCode`.
|
|
37
|
+
*/
|
|
38
|
+
export interface ValueRule extends DiagnosticRule {
|
|
39
|
+
readonly stage: ValueRuleStage;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Every value diagnostic code with the rule it reports. A code added to the language does not
|
|
43
|
+
* compile until it is described here.
|
|
44
|
+
*/
|
|
45
|
+
export declare const VALUE_RULES: Readonly<Record<DiagnosticCode, ValueRule>>;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { deepFreeze } from '../freeze.js';
|
|
2
|
+
/**
|
|
3
|
+
* Every value diagnostic code with the rule it reports. A code added to the language does not
|
|
4
|
+
* compile until it is described here.
|
|
5
|
+
*/
|
|
6
|
+
export const VALUE_RULES = deepFreeze({
|
|
7
|
+
CALLABLE_INPUT_FIELD_UNKNOWN: {
|
|
8
|
+
stage: 'value',
|
|
9
|
+
positions: [''],
|
|
10
|
+
statement: 'An input field validated on its own is a field of the Callable input, which has fields only when it is a closed object.',
|
|
11
|
+
},
|
|
12
|
+
DOMAIN_CLASS_ABSTRACT: {
|
|
13
|
+
stage: 'value',
|
|
14
|
+
positions: ['/class'],
|
|
15
|
+
statement: 'Properties are validated for a concrete Class only.',
|
|
16
|
+
},
|
|
17
|
+
DOMAIN_PROPERTY_INPUT_INVALID: {
|
|
18
|
+
stage: 'value',
|
|
19
|
+
positions: ['/properties'],
|
|
20
|
+
statement: 'The Properties of a Class are a canonical map of Property keys to portable values.',
|
|
21
|
+
},
|
|
22
|
+
DOMAIN_PROPERTY_REQUIRED: {
|
|
23
|
+
stage: 'value',
|
|
24
|
+
positions: ['/properties/{key}'],
|
|
25
|
+
statement: 'Every required Property of the Class has a value.',
|
|
26
|
+
},
|
|
27
|
+
DOMAIN_PROPERTY_UNKNOWN: {
|
|
28
|
+
stage: 'value',
|
|
29
|
+
positions: ['/properties/{key}'],
|
|
30
|
+
statement: 'Every Property given a value is a Property of the Class, its own or inherited.',
|
|
31
|
+
},
|
|
32
|
+
VALUE_SCHEMA_INSTANCE_INVALID: {
|
|
33
|
+
stage: 'value',
|
|
34
|
+
positions: ['{/path*}'],
|
|
35
|
+
statement: 'A value satisfies its complete value schema.',
|
|
36
|
+
},
|
|
37
|
+
VS_DIALECT: {
|
|
38
|
+
stage: 'schema',
|
|
39
|
+
positions: ['{/path*}/$schema'],
|
|
40
|
+
statement: 'A value schema names $schema at its root only, and there names the dialect https://schemas.astrale.ai/dsl/v1/value-schema.',
|
|
41
|
+
},
|
|
42
|
+
VS_DYNAMIC_FORBIDDEN: {
|
|
43
|
+
stage: 'schema',
|
|
44
|
+
positions: [
|
|
45
|
+
'{/path*}/$anchor',
|
|
46
|
+
'{/path*}/$dynamicAnchor',
|
|
47
|
+
'{/path*}/$dynamicRef',
|
|
48
|
+
'{/path*}/$vocabulary',
|
|
49
|
+
],
|
|
50
|
+
statement: 'A value schema names none of $anchor, $dynamicAnchor, $dynamicRef and $vocabulary.',
|
|
51
|
+
},
|
|
52
|
+
VS_KEYWORD_CLOSED: {
|
|
53
|
+
stage: 'schema',
|
|
54
|
+
positions: ['{/path*}/{keyword}'],
|
|
55
|
+
statement: 'Every keyword of a value schema is one of the closed V1 vocabulary.',
|
|
56
|
+
},
|
|
57
|
+
VS_META_SCHEMA: {
|
|
58
|
+
stage: 'schema',
|
|
59
|
+
positions: ['{/path*}'],
|
|
60
|
+
statement: 'A value schema is JSON valid under the meta-schema of the dialect, with fullMatch a string and no two equal values in an enum, at every location.',
|
|
61
|
+
},
|
|
62
|
+
VS_NUMBER_DOMAIN: {
|
|
63
|
+
stage: 'value',
|
|
64
|
+
positions: ['{/path*}'],
|
|
65
|
+
statement: 'A value, like a value schema, is portable JSON: its numbers are finite and not negative zero, its strings well formed, and its size within the value limits.',
|
|
66
|
+
},
|
|
67
|
+
VS_PATH_EXTENSION: {
|
|
68
|
+
stage: 'schema',
|
|
69
|
+
positions: ['{/path*}/x-astrale-path{/path*}', '{/path*}'],
|
|
70
|
+
statement: 'x-astrale-path annotates only a direct Property of a callable input object, beside exactly the $ref of the graph NodePath schema, and reads target node, cardinality one and a non-empty set of Node Class refs it accepts.',
|
|
71
|
+
},
|
|
72
|
+
VS_RECURSION_PRODUCTIVE: {
|
|
73
|
+
stage: 'schema',
|
|
74
|
+
positions: ['{/path*}'],
|
|
75
|
+
statement: 'Every reference cycle of a value schema crosses a keyword that steps into the value: to a member, a member name or an item.',
|
|
76
|
+
},
|
|
77
|
+
VS_REFERENCE_FORM: {
|
|
78
|
+
stage: 'schema',
|
|
79
|
+
positions: ['{/path*}/$ref'],
|
|
80
|
+
statement: 'A $ref is a JSON Pointer fragment into its own value schema, or the id of the graph NodePath schema beside x-astrale-path.',
|
|
81
|
+
},
|
|
82
|
+
VS_REFERENCE_RESOLUTION: {
|
|
83
|
+
stage: 'context',
|
|
84
|
+
positions: ['{/path*}/$ref', '{/path*}/x-astrale-path/accepts/{index}', ''],
|
|
85
|
+
statement: 'A $ref resolves to a location of its own value schema, x-astrale-path accepts Node Classes of the Domain or of a direct dependency, and the schema is checked with the exact dependency closure of its Domain.',
|
|
86
|
+
},
|
|
87
|
+
VS_REGEX_PORTABLE: {
|
|
88
|
+
stage: 'schema',
|
|
89
|
+
positions: ['{/path*}/pattern', '{/path*}/fullMatch', '{/path*}/patternProperties/{pattern}'],
|
|
90
|
+
statement: 'Every pattern, fullMatch and patternProperties name is an RFC 9485 I-Regexp within the regular-expression limits.',
|
|
91
|
+
limits: ['regexp.maxCodePoints', 'regexp.maxNesting', 'regexp.maxRepeat', 'regexp.maxStates'],
|
|
92
|
+
},
|
|
93
|
+
VS_RESOURCE_ID: {
|
|
94
|
+
stage: 'schema',
|
|
95
|
+
positions: ['{/path*}/$id'],
|
|
96
|
+
statement: 'A value schema declares no $id: it is embedded, not a resource of its own.',
|
|
97
|
+
},
|
|
98
|
+
VS_VALUE_KIND: {
|
|
99
|
+
stage: 'schema',
|
|
100
|
+
positions: ['{/path*}/x-astrale-value-kind'],
|
|
101
|
+
statement: 'x-astrale-value-kind declares instant beside type string at any location, or blob as the whole schema of a Property, exactly as values.blob writes it.',
|
|
102
|
+
conditions: ['#/$defs/value-location/anyOf/1/if'],
|
|
103
|
+
},
|
|
104
|
+
VS_VALUE_KIND_JSON: {
|
|
105
|
+
stage: 'warning',
|
|
106
|
+
positions: ['/classes/{class}/properties/{property}'],
|
|
107
|
+
statement: 'A Property of value kind json is filtered by equality only, so its author is warned.',
|
|
108
|
+
},
|
|
109
|
+
});
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { compareCodeUnits } from '../../../addressing/ordering.js';
|
|
2
|
+
import { escapePointerToken } from '../syntax/pointer.js';
|
|
1
3
|
/** Exact field constraints available for independent scalar route validation. */
|
|
2
4
|
export function inputFieldNodes(program) {
|
|
3
5
|
const fields = new Map();
|
|
@@ -34,7 +36,7 @@ export function inputFieldNodes(program) {
|
|
|
34
36
|
Array.isArray(schema.properties))
|
|
35
37
|
return;
|
|
36
38
|
for (const name of Object.keys(schema.properties)) {
|
|
37
|
-
const child = node.children[`properties/${
|
|
39
|
+
const child = node.children[`properties/${escapePointerToken(name)}`];
|
|
38
40
|
if (child === undefined)
|
|
39
41
|
throw new TypeError(`Compiled input field ${name} is absent.`);
|
|
40
42
|
const constraints = fields.get(name) ?? new Set();
|
|
@@ -46,15 +48,9 @@ export function inputFieldNodes(program) {
|
|
|
46
48
|
if (!closed || unsupported)
|
|
47
49
|
return undefined;
|
|
48
50
|
return Object.freeze(Object.fromEntries([...fields]
|
|
49
|
-
.sort(([left], [right]) =>
|
|
51
|
+
.sort(([left], [right]) => compareCodeUnits(left, right))
|
|
50
52
|
.map(([name, nodes]) => [
|
|
51
53
|
name,
|
|
52
54
|
Object.freeze([...nodes].sort((left, right) => left - right)),
|
|
53
55
|
])));
|
|
54
56
|
}
|
|
55
|
-
function escapePointer(value) {
|
|
56
|
-
return value.replaceAll('~', '~0').replaceAll('/', '~1');
|
|
57
|
-
}
|
|
58
|
-
function compare(left, right) {
|
|
59
|
-
return left < right ? -1 : left > right ? 1 : 0;
|
|
60
|
-
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Options } from '@astrale-os/kernel-dsl/value';
|
|
1
2
|
import type { Diagnostic } from '../../validation/diagnostic.js';
|
|
2
3
|
import type { ValueProgram } from '../compile/model.js';
|
|
3
|
-
export declare function validateValueProgram(program: ValueProgram, input: unknown, roots?: readonly number[]): readonly Diagnostic[];
|
|
4
|
+
export declare function validateValueProgram(program: ValueProgram, input: unknown, roots?: readonly number[], options?: Options): readonly Diagnostic[];
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { loadValueProgram } from '../compile/load.js';
|
|
2
2
|
import { validateCanonicalJsonDomain } from '../profile/json.validate.js';
|
|
3
3
|
import { evaluateInstance } from './evaluator.js';
|
|
4
|
-
export function validateValueProgram(program, input, roots = [program.root]) {
|
|
5
|
-
const canonical = validateCanonicalJsonDomain(input, '');
|
|
4
|
+
export function validateValueProgram(program, input, roots = [program.root], options) {
|
|
5
|
+
const canonical = validateCanonicalJsonDomain(input, '', options);
|
|
6
6
|
if (canonical.length > 0)
|
|
7
7
|
return canonical;
|
|
8
8
|
return roots.flatMap((root) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Value as JsonValue } from '@astrale-os/kernel-dsl/value';
|
|
1
|
+
import type { Value as JsonValue, Options } from '@astrale-os/kernel-dsl/value';
|
|
2
2
|
import type { Diagnostic } from '../../validation/diagnostic.js';
|
|
3
3
|
import type { JsonSchema } from '../model/schema.js';
|
|
4
4
|
import type { ValueSchemaRegistry } from '../reference/registry.js';
|
|
@@ -13,4 +13,4 @@ import { type PatternPool } from './preparation.js';
|
|
|
13
13
|
*/
|
|
14
14
|
export declare function validateJsonInstance(schema: JsonSchema, value: JsonValue, registry: ValueSchemaRegistry, pointer?: string, patterns?: PatternPool): Diagnostic[];
|
|
15
15
|
/** Validate with the exact preparation already retained by a source-resolved Property or Callable. */
|
|
16
|
-
export declare function validatePreparedInstance(compiled: CompiledInstanceSchema, value: unknown): Diagnostic[];
|
|
16
|
+
export declare function validatePreparedInstance(compiled: CompiledInstanceSchema, value: unknown, options?: Options): Diagnostic[];
|
|
@@ -2,6 +2,7 @@ import { diagnostic } from '../../validation/diagnostic.js';
|
|
|
2
2
|
import { validateCanonicalJsonDomain } from '../profile/json.validate.js';
|
|
3
3
|
import { evaluateInstance } from './evaluator.js';
|
|
4
4
|
import { prepareValueSchema, } from './preparation.js';
|
|
5
|
+
import { satisfies } from './validity.optimization.js';
|
|
5
6
|
const validatorCache = new WeakMap();
|
|
6
7
|
/**
|
|
7
8
|
* Validate one complete portable value with the admitted V1 Draft 2020-12 profile.
|
|
@@ -23,13 +24,16 @@ export function validateJsonInstance(schema, value, registry, pointer = '', patt
|
|
|
23
24
|
return instanceDiagnostics(prepared.value, value, pointer);
|
|
24
25
|
}
|
|
25
26
|
/** Validate with the exact preparation already retained by a source-resolved Property or Callable. */
|
|
26
|
-
export function validatePreparedInstance(compiled, value) {
|
|
27
|
-
const diagnostics = [...validateCanonicalJsonDomain(value, '')];
|
|
27
|
+
export function validatePreparedInstance(compiled, value, options) {
|
|
28
|
+
const diagnostics = [...validateCanonicalJsonDomain(value, '', options)];
|
|
28
29
|
return diagnostics.length > 0
|
|
29
30
|
? diagnostics
|
|
30
31
|
: instanceDiagnostics(compiled, value, '');
|
|
31
32
|
}
|
|
32
33
|
function instanceDiagnostics(compiled, value, pointer) {
|
|
34
|
+
// A value the compiled check finds valid has nothing to report; any other is evaluated.
|
|
35
|
+
if (satisfies(compiled, value) === true)
|
|
36
|
+
return [];
|
|
33
37
|
const result = evaluateInstance(compiled, value);
|
|
34
38
|
if (result.valid)
|
|
35
39
|
return [];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Value as JsonValue } from '@astrale-os/kernel-dsl/value';
|
|
2
|
+
import type { CompiledInstanceSchema } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Whether a value satisfies its prepared schema, as the evaluator decides it, without building a
|
|
5
|
+
* failure, an instance pointer or an annotation: the evaluator's verdict, or undefined when this
|
|
6
|
+
* check cannot give it. Only the evaluator reports why a value fails, so a caller keeps it for
|
|
7
|
+
* every value this check does not find valid.
|
|
8
|
+
*
|
|
9
|
+
* Each schema location is compiled once into a closure over its keywords, retained with the
|
|
10
|
+
* prepared schema. A schema whose closure holds an annotation-dependent keyword
|
|
11
|
+
* (`unevaluatedItems`, `unevaluatedProperties`) is left to the evaluator, as is a value nested
|
|
12
|
+
* deeper than this check follows, and any value whose check throws.
|
|
13
|
+
*/
|
|
14
|
+
export declare function satisfies(compiled: CompiledInstanceSchema, value: JsonValue): boolean | undefined;
|