@astrale-os/kernel-dsl 1.0.0-beta.3 → 1.0.0-beta.31
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 +2 -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 +30 -35
- 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 +10 -2
- package/dist/v1/builder/index.js +2 -0
- 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 +6 -24
- 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 +13 -6
- package/dist/v1/builder/lowering/schema/context.d.ts +9 -1
- package/dist/v1/builder/lowering/schema/context.js +36 -7
- 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/compile.js +29 -22
- package/dist/v1/builder/lowering/value/file.d.ts +7 -0
- package/dist/v1/builder/lowering/value/file.js +14 -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 +41 -7
- package/dist/v1/builder/policy/authoring.d.ts +80 -9
- package/dist/v1/builder/policy/authoring.js +99 -68
- package/dist/v1/builder/policy/legacy/edge.d.ts +28 -0
- package/dist/v1/builder/policy/legacy/edge.js +16 -0
- 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 +4 -1
- package/dist/v1/builder/schema/projection/callable.d.ts +7 -5
- package/dist/v1/builder/schema/projection/class.d.ts +78 -16
- package/dist/v1/builder/schema/projection/core-input.d.ts +2 -1
- package/dist/v1/builder/schema/projection/domain.d.ts +13 -2
- package/dist/v1/builder/schema/projection/identity.d.ts +74 -9
- package/dist/v1/builder/schema/projection/model.d.ts +4 -2
- package/dist/v1/builder/schema/projection/property.d.ts +38 -4
- package/dist/v1/builder/schema/projection/resolved-class.d.ts +5 -4
- package/dist/v1/builder/schema/projection.d.ts +1 -1
- package/dist/v1/builder/schema/rule.d.ts +316 -0
- package/dist/v1/builder/schema/rule.js +192 -0
- package/dist/v1/builder/value/file.d.ts +34 -0
- package/dist/v1/builder/value/file.js +77 -0
- 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 +55 -74
- package/dist/v1/bundle/diagnostic.d.ts +3 -1
- package/dist/v1/bundle/diagnostic.js +9 -7
- package/dist/v1/bundle/index.d.ts +2 -0
- package/dist/v1/bundle/index.js +1 -0
- package/dist/v1/bundle/model.js +1 -1
- package/dist/v1/bundle/rule.d.ts +14 -0
- package/dist/v1/bundle/rule.js +41 -0
- package/dist/v1/bundle/structure.js +6 -8
- package/dist/v1/compiled/admission/accept.js +9 -15
- package/dist/v1/compiled/admission/closure.js +17 -34
- package/dist/v1/compiled/admission/diagnostic.d.ts +23 -1
- package/dist/v1/compiled/admission/diagnostic.js +40 -3
- package/dist/v1/compiled/admission/revision.d.ts +9 -1
- package/dist/v1/compiled/admission/revision.js +7 -3
- package/dist/v1/compiled/admission/semantics/class.d.ts +4 -1
- package/dist/v1/compiled/admission/semantics/class.js +48 -19
- 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/admit.js +4 -19
- package/dist/v1/compiled/admission/semantics/policy/callable.js +2 -5
- 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 +44 -53
- package/dist/v1/compiled/admission/semantics/policy/pattern.d.ts +4 -1
- package/dist/v1/compiled/admission/semantics/policy/pattern.js +7 -21
- 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.d.ts +5 -2
- package/dist/v1/compiled/admission/wire/callable.js +24 -20
- package/dist/v1/compiled/admission/wire/class.js +79 -30
- package/dist/v1/compiled/admission/wire/entry.d.ts +1 -1
- package/dist/v1/compiled/admission/wire/entry.js +36 -13
- package/dist/v1/compiled/admission/wire/policy.d.ts +4 -3
- package/dist/v1/compiled/admission/wire/policy.js +27 -20
- package/dist/v1/compiled/admission/wire/program.d.ts +13 -3
- package/dist/v1/compiled/admission/wire/program.js +39 -44
- package/dist/v1/compiled/admission/wire/property.d.ts +4 -1
- package/dist/v1/compiled/admission/wire/property.js +8 -5
- package/dist/v1/compiled/admission/wire/value.d.ts +0 -2
- package/dist/v1/compiled/admission/wire/value.js +0 -7
- package/dist/v1/compiled/codec/json.js +4 -3
- package/dist/v1/compiled/compiler/compile.js +15 -33
- package/dist/v1/compiled/diagnostic.d.ts +1 -1
- package/dist/v1/compiled/diagnostic.js +2 -3
- package/dist/v1/compiled/index.d.ts +2 -0
- package/dist/v1/compiled/index.js +1 -0
- package/dist/v1/compiled/loader/load.d.ts +3 -2
- package/dist/v1/compiled/loader/load.js +13 -52
- package/dist/v1/compiled/model/schema.d.ts +3 -0
- package/dist/v1/compiled/rule.d.ts +49 -0
- package/dist/v1/compiled/rule.js +169 -0
- package/dist/v1/domain/create.js +9 -10
- package/dist/v1/domain/model/domain.d.ts +2 -7
- package/dist/v1/domain/model/input.d.ts +19 -10
- package/dist/v1/domain/namespace/member-collection.js +8 -7
- package/dist/v1/domain/projection/classes.js +11 -8
- package/dist/v1/domain/validation/create.d.ts +7 -16
- package/dist/v1/domain/validation/create.js +35 -81
- package/dist/v1/index.d.ts +5 -3
- package/dist/v1/index.js +1 -1
- package/dist/v1/language/.spec/schemas/draft-2020-12.schema.json +462 -0
- package/dist/v1/language/.spec/schemas/value-schema.schema.json +23 -0
- package/dist/v1/language/callable/admission.d.ts +15 -0
- package/dist/v1/language/callable/admission.js +44 -0
- package/dist/v1/language/callable/model/callable.d.ts +10 -0
- package/dist/v1/language/callable/resolved.d.ts +26 -5
- package/dist/v1/language/chain.d.ts +7 -0
- package/dist/v1/language/chain.js +24 -0
- package/dist/v1/language/class/inheritance.d.ts +36 -5
- package/dist/v1/language/class/inheritance.js +85 -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/resolved.d.ts +9 -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/cycle.d.ts +10 -0
- package/dist/v1/language/cycle.js +30 -0
- package/dist/v1/language/definition/metadata.d.ts +38 -0
- package/dist/v1/language/definition/metadata.js +51 -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 +83 -0
- package/dist/v1/language/limits.js +77 -0
- package/dist/v1/language/policy/analysis/branches.d.ts +8 -0
- package/dist/v1/language/policy/analysis/branches.js +8 -8
- package/dist/v1/language/policy/analysis/budgets.d.ts +45 -12
- package/dist/v1/language/policy/analysis/budgets.js +140 -20
- package/dist/v1/language/policy/analysis/checks.js +8 -6
- package/dist/v1/language/policy/analysis/composition.d.ts +4 -0
- package/dist/v1/language/policy/analysis/composition.js +11 -0
- package/dist/v1/language/policy/analysis/typing.d.ts +51 -0
- package/dist/v1/language/policy/analysis/typing.js +456 -0
- package/dist/v1/language/policy/model/policy.d.ts +71 -9
- package/dist/v1/language/policy/model/policy.js +42 -4
- package/dist/v1/language/policy/normalization/normalize.d.ts +6 -6
- package/dist/v1/language/policy/normalization/normalize.js +46 -68
- package/dist/v1/language/suspended.d.ts +7 -0
- package/dist/v1/language/suspended.js +23 -0
- 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 +16 -16
- package/dist/v1/language/value/compile/load.d.ts +5 -0
- package/dist/v1/language/value/compile/load.js +13 -0
- package/dist/v1/language/value/evaluate/assertions.d.ts +5 -1
- package/dist/v1/language/value/evaluate/assertions.js +19 -8
- package/dist/v1/language/value/evaluate/evaluator.js +117 -120
- package/dist/v1/language/value/evaluate/preparation.d.ts +16 -0
- package/dist/v1/language/value/evaluate/preparation.js +100 -47
- package/dist/v1/language/value/evaluate/program.d.ts +2 -1
- package/dist/v1/language/value/evaluate/program.js +6 -6
- package/dist/v1/language/value/evaluate/validate.d.ts +3 -3
- package/dist/v1/language/value/evaluate/validate.js +15 -11
- package/dist/v1/language/value/evaluate/validity.optimization.d.ts +14 -0
- package/dist/v1/language/value/evaluate/validity.optimization.js +338 -0
- package/dist/v1/language/value/files.d.ts +44 -0
- package/dist/v1/language/value/files.js +151 -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 +28 -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 +76 -0
- package/dist/v1/language/value/inclusion/evidence.d.ts +34 -0
- package/dist/v1/language/value/inclusion/evidence.js +140 -0
- package/dist/v1/language/value/inclusion/includes.d.ts +29 -3
- package/dist/v1/language/value/inclusion/includes.js +58 -723
- 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 +66 -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 +34 -0
- package/dist/v1/language/value/model/blob.d.ts +6 -0
- package/dist/v1/language/value/model/blob.js +8 -0
- package/dist/v1/language/value/model/file.d.ts +41 -0
- package/dist/v1/language/value/model/file.js +122 -0
- package/dist/v1/language/value/ordering.d.ts +14 -0
- package/dist/v1/language/value/ordering.js +144 -77
- package/dist/v1/language/value/profile/canonicalize.d.ts +6 -1
- package/dist/v1/language/value/profile/canonicalize.js +67 -87
- package/dist/v1/language/value/profile/json.validate.d.ts +12 -0
- package/dist/v1/language/value/profile/json.validate.js +18 -5
- package/dist/v1/language/value/profile/meta-schema.compiled.d.ts +1 -0
- package/dist/v1/language/value/profile/meta-schema.compiled.js +21 -5
- package/dist/v1/language/value/profile/rules.js +27 -44
- package/dist/v1/language/value/profile/validate.js +1 -10
- package/dist/v1/language/value/profile/vocabulary.d.ts +36 -2
- package/dist/v1/language/value/profile/vocabulary.js +58 -5
- package/dist/v1/language/value/reference/closure.js +6 -6
- package/dist/v1/language/value/reference/recursion.js +9 -48
- package/dist/v1/language/value/reference/references.d.ts +3 -1
- package/dist/v1/language/value/reference/references.js +7 -7
- 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/regexp/unicode.d.ts +1 -1
- package/dist/v1/language/value/regexp/unicode.js +1 -1
- 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 +9 -0
- package/dist/v1/language/value/syntax/walk.js +37 -20
- package/dist/v1/schema/.spec/schemas/domain-schema.schema.json +2596 -0
- package/dist/v1/schema/admission/accept.d.ts +3 -1
- package/dist/v1/schema/admission/accept.js +6 -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.d.ts +4 -0
- package/dist/v1/schema/analysis/class.js +57 -17
- package/dist/v1/schema/canonical/revision.d.ts +4 -1
- package/dist/v1/schema/canonical/revision.js +8 -5
- package/dist/v1/schema/compatibility/api.d.ts +4 -1
- package/dist/v1/schema/compatibility/api.js +2 -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 +50 -29
- 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/context.d.ts +5 -2
- package/dist/v1/schema/compatibility/context.js +8 -6
- 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 -51
- package/dist/v1/schema/compatibility/model.d.ts +17 -5
- package/dist/v1/schema/compatibility/references.d.ts +0 -3
- package/dist/v1/schema/compatibility/references.js +1 -9
- package/dist/v1/schema/compatibility/report.js +1 -1
- package/dist/v1/schema/compatibility/rule.d.ts +13 -0
- package/dist/v1/schema/compatibility/rule.js +23 -0
- 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 +58 -61
- 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/enforcement/changes.d.ts +590 -0
- package/dist/v1/schema/enforcement/changes.js +566 -0
- package/dist/v1/schema/enforcement/derived.d.ts +236 -0
- package/dist/v1/schema/enforcement/derived.js +243 -0
- package/dist/v1/schema/enforcement/dispose.d.ts +308 -0
- package/dist/v1/schema/enforcement/dispose.js +275 -0
- package/dist/v1/schema/enforcement/facts.d.ts +89 -0
- package/dist/v1/schema/enforcement/facts.js +70 -0
- package/dist/v1/schema/enforcement/fields.d.ts +65 -0
- package/dist/v1/schema/enforcement/fields.js +36 -0
- package/dist/v1/schema/enforcement/index.d.ts +39 -0
- package/dist/v1/schema/enforcement/index.js +10 -0
- package/dist/v1/schema/enforcement/install.d.ts +1634 -0
- package/dist/v1/schema/enforcement/install.js +1223 -0
- package/dist/v1/schema/enforcement/lifecycle.d.ts +87 -0
- package/dist/v1/schema/enforcement/lifecycle.js +91 -0
- package/dist/v1/schema/enforcement/model.d.ts +253 -0
- package/dist/v1/schema/enforcement/model.js +1 -0
- package/dist/v1/schema/enforcement/obligations.d.ts +248 -0
- package/dist/v1/schema/enforcement/obligations.js +240 -0
- package/dist/v1/schema/enforcement/write.d.ts +1314 -0
- package/dist/v1/schema/enforcement/write.js +1017 -0
- package/dist/v1/schema/index.d.ts +11 -1
- package/dist/v1/schema/index.js +5 -0
- package/dist/v1/schema/model/schema.d.ts +23 -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 +50 -13
- package/dist/v1/schema/resolution/closure.js +2 -1
- package/dist/v1/schema/resolution/context.js +17 -18
- package/dist/v1/schema/resolution/domain.d.ts +5 -0
- package/dist/v1/schema/resolution/domain.js +6 -12
- package/dist/v1/schema/resolution/origins.js +6 -8
- package/dist/v1/schema/rule.d.ts +25 -0
- package/dist/v1/schema/rule.js +459 -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 +128 -105
- package/dist/v1/schema/validation/core.js +103 -173
- package/dist/v1/schema/validation/domain.js +25 -15
- package/dist/v1/schema/validation/domain.json-schema.d.ts +15 -0
- package/dist/v1/schema/validation/domain.json-schema.js +222 -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 +7797 -0
- package/dist/v1/schema/validation/domain.structure.js +516 -160
- package/dist/v1/schema/validation/icon.d.ts +4 -0
- package/dist/v1/schema/validation/icon.js +29 -0
- 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 +37 -2
- package/dist/v1/schema/validation/policy/budgets.js +94 -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 +20 -62
- 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 +63 -91
- package/dist/v1/schema/validation/policy/validate.js +5 -5
- package/dist/v1/schema/validation/value-api.d.ts +27 -1
- package/dist/v1/schema/validation/value-api.js +37 -2
- 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 +54 -0
- package/dist/v1/schema/validation/value.json-schema.js +163 -0
- package/dist/v1/schema/validation/view.js +4 -8
- package/dist/value/accept.d.ts +9 -3
- package/dist/value/accept.js +25 -1
- package/dist/value/canonical.d.ts +22 -1
- package/dist/value/canonical.js +114 -21
- package/dist/value/decode.d.ts +7 -0
- package/dist/value/decode.js +159 -9
- package/dist/value/equal.d.ts +9 -1
- package/dist/value/equal.js +37 -3
- package/dist/value/immutable.optimization.d.ts +2 -0
- package/dist/value/immutable.optimization.js +4 -0
- package/dist/value/index.d.ts +5 -3
- package/dist/value/index.js +2 -1
- package/dist/value/json.d.ts +2 -2
- package/dist/value/json.js +2 -2
- package/dist/value/limits.d.ts +11 -0
- package/dist/value/rule.d.ts +12 -0
- package/dist/value/rule.js +50 -0
- 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 +15 -4
- 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/compiled/admission/wire/pattern.d.ts +0 -12
- package/dist/v1/compiled/admission/wire/pattern.js +0 -111
- 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,8 +1,12 @@
|
|
|
1
1
|
import type { Value as JsonValue } from '@astrale-os/kernel-dsl/value';
|
|
2
2
|
export declare function matchesType(input: string, value: JsonValue): boolean;
|
|
3
|
-
export declare function jsonEqual(left: JsonValue, right: JsonValue): boolean;
|
|
4
3
|
/** Count Unicode code points with string-iterator semantics, without a character array. */
|
|
5
4
|
export declare function codePointLength(input: string): number;
|
|
5
|
+
/**
|
|
6
|
+
* Whether no two items are the same JSON value, at any size their admission allowed, in time linear
|
|
7
|
+
* in their canonical tokens: an item whose tokens add no node to the trie of the items before it
|
|
8
|
+
* repeats one of them, since no item's tokens are a prefix of another's.
|
|
9
|
+
*/
|
|
6
10
|
export declare function unique(values: readonly JsonValue[]): boolean;
|
|
7
11
|
/** Compare finite JSON numbers as their exact ECMAScript decimal spellings. */
|
|
8
12
|
export declare function isMultipleOf(value: number, divisor: number): boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { canonicalTokens } from '../../../../value/canonical.js';
|
|
2
2
|
import { isValueObject as isJsonObject } from '../model/object.js';
|
|
3
3
|
export function matchesType(input, value) {
|
|
4
4
|
switch (input) {
|
|
@@ -18,9 +18,6 @@ export function matchesType(input, value) {
|
|
|
18
18
|
return false;
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
export function jsonEqual(left, right) {
|
|
22
|
-
return equal(left, right);
|
|
23
|
-
}
|
|
24
21
|
/** Count Unicode code points with string-iterator semantics, without a character array. */
|
|
25
22
|
export function codePointLength(input) {
|
|
26
23
|
let length = 0;
|
|
@@ -34,13 +31,27 @@ export function codePointLength(input) {
|
|
|
34
31
|
}
|
|
35
32
|
return length;
|
|
36
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Whether no two items are the same JSON value, at any size their admission allowed, in time linear
|
|
36
|
+
* in their canonical tokens: an item whose tokens add no node to the trie of the items before it
|
|
37
|
+
* repeats one of them, since no item's tokens are a prefix of another's.
|
|
38
|
+
*/
|
|
37
39
|
export function unique(values) {
|
|
38
|
-
const
|
|
40
|
+
const readings = new Map();
|
|
39
41
|
for (const value of values) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
let node = readings;
|
|
43
|
+
let repeated = true;
|
|
44
|
+
for (const token of canonicalTokens(value)) {
|
|
45
|
+
let next = node.get(token);
|
|
46
|
+
if (next === undefined) {
|
|
47
|
+
next = new Map();
|
|
48
|
+
node.set(token, next);
|
|
49
|
+
repeated = false;
|
|
50
|
+
}
|
|
51
|
+
node = next;
|
|
52
|
+
}
|
|
53
|
+
if (repeated)
|
|
42
54
|
return false;
|
|
43
|
-
seen.add(key);
|
|
44
55
|
}
|
|
45
56
|
return true;
|
|
46
57
|
}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
+
import { equal } from '@astrale-os/kernel-dsl/value';
|
|
2
|
+
import { runSuspended } from '../../suspended.js';
|
|
1
3
|
import { isCanonicalBlobRef } from '../model/blob.js';
|
|
2
4
|
import { isInstantValue } from '../model/instant.js';
|
|
3
5
|
import { isValueObject as isJsonObject } from '../model/object.js';
|
|
4
6
|
import { appendPointer } from '../syntax/pointer.js';
|
|
5
|
-
import {
|
|
7
|
+
import { isJsonSchema, schemaList } from '../syntax/walk.js';
|
|
8
|
+
import { codePointLength, isMultipleOf, matchesType, unique } from './assertions.js';
|
|
6
9
|
import { evaluation, mergeAnnotations } from './types.js';
|
|
7
10
|
/** Evaluate complete Draft 2020-12 acceptance without dynamic source generation. */
|
|
8
11
|
export function evaluateInstance(compiled, input) {
|
|
9
|
-
return new InstanceEvaluator(compiled).evaluate(compiled.root, input, '');
|
|
12
|
+
return runSuspended(new InstanceEvaluator(compiled).evaluate(compiled.root, input, ''));
|
|
10
13
|
}
|
|
11
14
|
/** Bound per-call retention independently of the size or diversity of an input value. */
|
|
12
15
|
const MAX_CACHED_PATTERN_RESULTS = 256;
|
|
@@ -20,7 +23,7 @@ class InstanceEvaluator {
|
|
|
20
23
|
constructor(compiled) {
|
|
21
24
|
this.compiled = compiled;
|
|
22
25
|
}
|
|
23
|
-
evaluate(location, input, instancePointer) {
|
|
26
|
+
*evaluate(location, input, instancePointer) {
|
|
24
27
|
const key = `${location.key}\u0000${instancePointer}`;
|
|
25
28
|
// propertyNames evaluates the name at the property's value pointer. Cache by the actual
|
|
26
29
|
// input too, retaining one result per repeated sub-problem within this call. A null entry
|
|
@@ -37,45 +40,31 @@ class InstanceEvaluator {
|
|
|
37
40
|
this.resultCache.set(input, byLocation);
|
|
38
41
|
}
|
|
39
42
|
byLocation.set(key, null);
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
result = evaluation();
|
|
44
|
-
}
|
|
45
|
-
else if (location.schema === false) {
|
|
46
|
-
result = evaluation([
|
|
47
|
-
invalid(instancePointer, 'false', 'The false schema rejects every value.'),
|
|
48
|
-
]);
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
result = this.evaluateObjectSchema(location, location.schema, input, instancePointer);
|
|
52
|
-
}
|
|
43
|
+
const { schema } = location;
|
|
44
|
+
if (typeof schema === 'boolean') {
|
|
45
|
+
const result = evaluation(schema ? [] : [invalid(instancePointer, 'false', 'The false schema rejects every value.')]);
|
|
53
46
|
byLocation.set(key, result);
|
|
54
47
|
return result;
|
|
55
48
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
throw error;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
evaluateObjectSchema(location, schema, input, instancePointer) {
|
|
62
|
-
const failures = [];
|
|
49
|
+
// A set: a location two references reach answers one result, whose failures count once.
|
|
50
|
+
const failures = new Set();
|
|
63
51
|
const properties = new Set();
|
|
64
52
|
const items = new Set();
|
|
65
|
-
const absorbSameLocation = (result) => {
|
|
66
|
-
if (result.valid)
|
|
67
|
-
mergeAnnotations(properties, items, result);
|
|
68
|
-
else
|
|
69
|
-
failures.push(...result.failures);
|
|
70
|
-
};
|
|
71
53
|
if (Object.hasOwn(schema, '$ref')) {
|
|
72
54
|
const target = this.compiled.reference(location);
|
|
73
55
|
if (target === undefined) {
|
|
74
56
|
throw new TypeError('Admitted value schema reference has no prepared resolution.');
|
|
75
57
|
}
|
|
76
|
-
|
|
58
|
+
const result = yield this.evaluate(target, input, instancePointer);
|
|
59
|
+
absorb(result, failures, properties, items);
|
|
60
|
+
}
|
|
61
|
+
if (schema.allOf !== undefined ||
|
|
62
|
+
schema.anyOf !== undefined ||
|
|
63
|
+
schema.oneOf !== undefined ||
|
|
64
|
+
schema.not !== undefined ||
|
|
65
|
+
schema.if !== undefined) {
|
|
66
|
+
yield* this.evaluateCompositions(location, schema, input, instancePointer, failures, properties, items);
|
|
77
67
|
}
|
|
78
|
-
this.evaluateCompositions(location, schema, input, instancePointer, failures, properties, items);
|
|
79
68
|
this.evaluateCommonAssertions(schema, input, instancePointer, failures);
|
|
80
69
|
if (typeof input === 'number') {
|
|
81
70
|
this.evaluateNumberAssertions(schema, input, instancePointer, failures);
|
|
@@ -84,107 +73,110 @@ class InstanceEvaluator {
|
|
|
84
73
|
this.evaluateStringAssertions(schema, input, instancePointer, failures);
|
|
85
74
|
}
|
|
86
75
|
if (Array.isArray(input)) {
|
|
87
|
-
this.evaluateArray(location, schema, input, instancePointer, failures,
|
|
76
|
+
yield* this.evaluateArray(location, schema, input, instancePointer, failures, items);
|
|
88
77
|
}
|
|
89
78
|
else if (isJsonObject(input)) {
|
|
90
|
-
this.evaluateObject(location, schema, input, instancePointer, failures, properties
|
|
79
|
+
yield* this.evaluateObject(location, schema, input, instancePointer, failures, properties);
|
|
91
80
|
}
|
|
92
|
-
|
|
81
|
+
const result = evaluation([...failures], properties, items);
|
|
82
|
+
byLocation.set(key, result);
|
|
83
|
+
return result;
|
|
93
84
|
}
|
|
94
|
-
evaluateCompositions(location, schema, input, instancePointer, failures, properties, items) {
|
|
95
|
-
const absorb = (result) => {
|
|
96
|
-
if (result.valid)
|
|
97
|
-
mergeAnnotations(properties, items, result);
|
|
98
|
-
else
|
|
99
|
-
failures.push(...result.failures);
|
|
100
|
-
};
|
|
85
|
+
*evaluateCompositions(location, schema, input, instancePointer, failures, properties, items) {
|
|
101
86
|
const allOf = schemaList(schema.allOf);
|
|
102
|
-
allOf
|
|
103
|
-
|
|
104
|
-
|
|
87
|
+
if (allOf !== undefined) {
|
|
88
|
+
for (let index = 0; index < allOf.length; index++) {
|
|
89
|
+
const branch = this.child(location, 'allOf', index);
|
|
90
|
+
absorb(yield this.evaluate(branch, input, instancePointer), failures, properties, items);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
105
93
|
const anyOf = schemaList(schema.anyOf);
|
|
106
94
|
if (anyOf !== undefined) {
|
|
107
95
|
let admitted = 0;
|
|
108
|
-
anyOf.
|
|
96
|
+
for (let index = 0; index < anyOf.length; index++) {
|
|
109
97
|
const branch = this.child(location, 'anyOf', index);
|
|
110
98
|
if (contradictsRequiredConst(branch.schema, input))
|
|
111
|
-
|
|
112
|
-
const result = this.evaluate(branch, input, instancePointer);
|
|
99
|
+
continue;
|
|
100
|
+
const result = yield this.evaluate(branch, input, instancePointer);
|
|
113
101
|
if (!result.valid)
|
|
114
|
-
|
|
102
|
+
continue;
|
|
115
103
|
admitted += 1;
|
|
116
104
|
mergeAnnotations(properties, items, result);
|
|
117
|
-
}
|
|
105
|
+
}
|
|
118
106
|
if (admitted === 0) {
|
|
119
|
-
failures.
|
|
107
|
+
failures.add(invalid(instancePointer, 'anyOf', 'Value satisfies no anyOf branch.'));
|
|
120
108
|
}
|
|
121
109
|
}
|
|
122
110
|
const oneOf = schemaList(schema.oneOf);
|
|
123
111
|
if (oneOf !== undefined) {
|
|
124
|
-
const admitted =
|
|
125
|
-
|
|
126
|
-
.
|
|
112
|
+
const admitted = [];
|
|
113
|
+
for (let index = 0; index < oneOf.length; index++) {
|
|
114
|
+
const branch = this.child(location, 'oneOf', index);
|
|
115
|
+
const result = yield this.evaluate(branch, input, instancePointer);
|
|
116
|
+
if (result.valid)
|
|
117
|
+
admitted.push(result);
|
|
118
|
+
}
|
|
127
119
|
if (admitted.length !== 1) {
|
|
128
|
-
failures.
|
|
120
|
+
failures.add(invalid(instancePointer, 'oneOf', 'Value must satisfy exactly one oneOf branch.'));
|
|
129
121
|
}
|
|
130
122
|
else {
|
|
131
123
|
mergeAnnotations(properties, items, admitted[0]);
|
|
132
124
|
}
|
|
133
125
|
}
|
|
134
|
-
if (
|
|
135
|
-
const result = this.evaluate(this.child(location, 'not'), input, instancePointer);
|
|
126
|
+
if (isJsonSchema(schema.not)) {
|
|
127
|
+
const result = yield this.evaluate(this.child(location, 'not'), input, instancePointer);
|
|
136
128
|
if (result.valid)
|
|
137
|
-
failures.
|
|
129
|
+
failures.add(invalid(instancePointer, 'not', 'Value satisfies not.'));
|
|
138
130
|
}
|
|
139
|
-
if (
|
|
140
|
-
const condition = this.evaluate(this.child(location, 'if'), input, instancePointer);
|
|
131
|
+
if (isJsonSchema(schema.if)) {
|
|
132
|
+
const condition = yield this.evaluate(this.child(location, 'if'), input, instancePointer);
|
|
141
133
|
if (condition.valid)
|
|
142
134
|
mergeAnnotations(properties, items, condition);
|
|
143
135
|
const branch = condition.valid ? 'then' : 'else';
|
|
144
|
-
if (
|
|
145
|
-
|
|
136
|
+
if (isJsonSchema(schema[branch])) {
|
|
137
|
+
const result = yield this.evaluate(this.child(location, branch), input, instancePointer);
|
|
138
|
+
absorb(result, failures, properties, items);
|
|
146
139
|
}
|
|
147
140
|
}
|
|
148
141
|
}
|
|
149
142
|
evaluateCommonAssertions(schema, input, instancePointer, failures) {
|
|
150
143
|
if (schema['x-astrale-value-kind'] === 'instant' && !isInstantValue(input)) {
|
|
151
|
-
failures.
|
|
144
|
+
failures.add(invalid(instancePointer, 'x-astrale-value-kind', 'Value is not an exact UTC millisecond Instant.'));
|
|
152
145
|
}
|
|
153
146
|
if (schema['x-astrale-value-kind'] === 'blob' && !isCanonicalBlobRef(input)) {
|
|
154
|
-
failures.
|
|
147
|
+
failures.add(invalid(instancePointer, 'x-astrale-value-kind', 'Value is not a canonical blob Ref.'));
|
|
155
148
|
}
|
|
156
149
|
if (typeof schema.type === 'string') {
|
|
157
150
|
if (!matchesType(schema.type, input)) {
|
|
158
|
-
failures.
|
|
151
|
+
failures.add(invalid(instancePointer, 'type', `Value is not of type ${schema.type}.`));
|
|
159
152
|
}
|
|
160
153
|
}
|
|
161
154
|
else if (Array.isArray(schema.type) &&
|
|
162
155
|
!schema.type.some((candidate) => typeof candidate === 'string' ? matchesType(candidate, input) : false)) {
|
|
163
|
-
failures.
|
|
156
|
+
failures.add(invalid(instancePointer, 'type', 'Value matches none of the admitted types.'));
|
|
164
157
|
}
|
|
165
|
-
if (Object.hasOwn(schema, 'const') && !
|
|
166
|
-
failures.
|
|
158
|
+
if (Object.hasOwn(schema, 'const') && !equal(input, schema.const)) {
|
|
159
|
+
failures.add(invalid(instancePointer, 'const', 'Value differs from const.'));
|
|
167
160
|
}
|
|
168
|
-
if (Array.isArray(schema.enum) &&
|
|
169
|
-
|
|
170
|
-
failures.push(invalid(instancePointer, 'enum', 'Value is absent from enum.'));
|
|
161
|
+
if (Array.isArray(schema.enum) && !schema.enum.some((candidate) => equal(input, candidate))) {
|
|
162
|
+
failures.add(invalid(instancePointer, 'enum', 'Value is absent from enum.'));
|
|
171
163
|
}
|
|
172
164
|
}
|
|
173
165
|
evaluateNumberAssertions(schema, input, instancePointer, failures) {
|
|
174
166
|
if (typeof schema.multipleOf === 'number' && !isMultipleOf(input, schema.multipleOf)) {
|
|
175
|
-
failures.
|
|
167
|
+
failures.add(invalid(instancePointer, 'multipleOf', 'Number is not an exact multiple.'));
|
|
176
168
|
}
|
|
177
169
|
if (typeof schema.maximum === 'number' && input > schema.maximum) {
|
|
178
|
-
failures.
|
|
170
|
+
failures.add(invalid(instancePointer, 'maximum', 'Number exceeds maximum.'));
|
|
179
171
|
}
|
|
180
172
|
if (typeof schema.exclusiveMaximum === 'number' && input >= schema.exclusiveMaximum) {
|
|
181
|
-
failures.
|
|
173
|
+
failures.add(invalid(instancePointer, 'exclusiveMaximum', 'Number reaches exclusiveMaximum.'));
|
|
182
174
|
}
|
|
183
175
|
if (typeof schema.minimum === 'number' && input < schema.minimum) {
|
|
184
|
-
failures.
|
|
176
|
+
failures.add(invalid(instancePointer, 'minimum', 'Number is below minimum.'));
|
|
185
177
|
}
|
|
186
178
|
if (typeof schema.exclusiveMinimum === 'number' && input <= schema.exclusiveMinimum) {
|
|
187
|
-
failures.
|
|
179
|
+
failures.add(invalid(instancePointer, 'exclusiveMinimum', 'Number reaches exclusiveMinimum.'));
|
|
188
180
|
}
|
|
189
181
|
}
|
|
190
182
|
evaluateStringAssertions(schema, input, instancePointer, failures) {
|
|
@@ -194,105 +186,105 @@ class InstanceEvaluator {
|
|
|
194
186
|
(typeof schema.minLength === 'number' && Math.ceil(input.length / 2) < schema.minLength)) {
|
|
195
187
|
const length = codePointLength(input);
|
|
196
188
|
if (typeof schema.maxLength === 'number' && length > schema.maxLength) {
|
|
197
|
-
failures.
|
|
189
|
+
failures.add(invalid(instancePointer, 'maxLength', 'String exceeds maxLength.'));
|
|
198
190
|
}
|
|
199
191
|
if (typeof schema.minLength === 'number' && length < schema.minLength) {
|
|
200
|
-
failures.
|
|
192
|
+
failures.add(invalid(instancePointer, 'minLength', 'String is below minLength.'));
|
|
201
193
|
}
|
|
202
194
|
}
|
|
203
195
|
if (typeof schema.pattern === 'string' && !this.matchesPattern(schema.pattern, input, false)) {
|
|
204
|
-
failures.
|
|
196
|
+
failures.add(invalid(instancePointer, 'pattern', 'String does not match pattern.'));
|
|
205
197
|
}
|
|
206
198
|
if (typeof schema.fullMatch === 'string' &&
|
|
207
199
|
!this.matchesPattern(schema.fullMatch, input, true)) {
|
|
208
|
-
failures.
|
|
200
|
+
failures.add(invalid(instancePointer, 'fullMatch', 'String does not match fullMatch.'));
|
|
209
201
|
}
|
|
210
202
|
}
|
|
211
|
-
evaluateArray(location, schema, input, instancePointer, failures,
|
|
203
|
+
*evaluateArray(location, schema, input, instancePointer, failures, items) {
|
|
212
204
|
if (typeof schema.maxItems === 'number' && input.length > schema.maxItems) {
|
|
213
|
-
failures.
|
|
205
|
+
failures.add(invalid(instancePointer, 'maxItems', 'Array exceeds maxItems.'));
|
|
214
206
|
}
|
|
215
207
|
if (typeof schema.minItems === 'number' && input.length < schema.minItems) {
|
|
216
|
-
failures.
|
|
208
|
+
failures.add(invalid(instancePointer, 'minItems', 'Array is below minItems.'));
|
|
217
209
|
}
|
|
218
210
|
if (schema.uniqueItems === true && !unique(input)) {
|
|
219
|
-
failures.
|
|
211
|
+
failures.add(invalid(instancePointer, 'uniqueItems', 'Array items are not unique.'));
|
|
220
212
|
}
|
|
221
213
|
const prefixItems = schemaList(schema.prefixItems) ?? [];
|
|
222
214
|
const presentPrefix = Math.min(prefixItems.length, input.length);
|
|
223
215
|
let prefixValid = true;
|
|
224
216
|
for (let index = 0; index < presentPrefix; index++) {
|
|
225
|
-
const result = this.evaluate(this.child(location, 'prefixItems', index), input[index], appendPointer(instancePointer, index));
|
|
217
|
+
const result = yield this.evaluate(this.child(location, 'prefixItems', index), input[index], appendPointer(instancePointer, index));
|
|
226
218
|
if (!result.valid) {
|
|
227
219
|
prefixValid = false;
|
|
228
|
-
failures
|
|
220
|
+
addFailures(failures, result);
|
|
229
221
|
}
|
|
230
222
|
}
|
|
231
223
|
if (prefixValid) {
|
|
232
224
|
for (let index = 0; index < presentPrefix; index++)
|
|
233
225
|
items.add(index);
|
|
234
226
|
}
|
|
235
|
-
if (
|
|
227
|
+
if (isJsonSchema(schema.items)) {
|
|
236
228
|
let itemValid = true;
|
|
237
229
|
const admitted = [];
|
|
238
230
|
for (let index = prefixItems.length; index < input.length; index++) {
|
|
239
|
-
const result = this.evaluate(this.child(location, 'items'), input[index], appendPointer(instancePointer, index));
|
|
231
|
+
const result = yield this.evaluate(this.child(location, 'items'), input[index], appendPointer(instancePointer, index));
|
|
240
232
|
if (result.valid)
|
|
241
233
|
admitted.push(index);
|
|
242
234
|
else {
|
|
243
235
|
itemValid = false;
|
|
244
|
-
failures
|
|
236
|
+
addFailures(failures, result);
|
|
245
237
|
}
|
|
246
238
|
}
|
|
247
239
|
if (itemValid)
|
|
248
240
|
admitted.forEach((index) => items.add(index));
|
|
249
241
|
}
|
|
250
|
-
if (
|
|
242
|
+
if (isJsonSchema(schema.contains)) {
|
|
251
243
|
const matches = [];
|
|
252
244
|
for (let index = 0; index < input.length; index++) {
|
|
253
|
-
const result = this.evaluate(this.child(location, 'contains'), input[index], appendPointer(instancePointer, index));
|
|
245
|
+
const result = yield this.evaluate(this.child(location, 'contains'), input[index], appendPointer(instancePointer, index));
|
|
254
246
|
if (result.valid)
|
|
255
247
|
matches.push(index);
|
|
256
248
|
}
|
|
257
249
|
const minimum = typeof schema.minContains === 'number' ? schema.minContains : 1;
|
|
258
250
|
const maximum = typeof schema.maxContains === 'number' ? schema.maxContains : Number.POSITIVE_INFINITY;
|
|
259
251
|
if (matches.length < minimum || matches.length > maximum) {
|
|
260
|
-
failures.
|
|
252
|
+
failures.add(invalid(instancePointer, 'contains', 'Array has an invalid number of contains matches.'));
|
|
261
253
|
}
|
|
262
254
|
else {
|
|
263
255
|
matches.forEach((index) => items.add(index));
|
|
264
256
|
}
|
|
265
257
|
}
|
|
266
|
-
if (
|
|
258
|
+
if (isJsonSchema(schema.unevaluatedItems)) {
|
|
267
259
|
let valid = true;
|
|
268
260
|
const admitted = [];
|
|
269
261
|
for (let index = 0; index < input.length; index++) {
|
|
270
262
|
if (items.has(index))
|
|
271
263
|
continue;
|
|
272
|
-
const result = this.evaluate(this.child(location, 'unevaluatedItems'), input[index], appendPointer(instancePointer, index));
|
|
264
|
+
const result = yield this.evaluate(this.child(location, 'unevaluatedItems'), input[index], appendPointer(instancePointer, index));
|
|
273
265
|
if (result.valid)
|
|
274
266
|
admitted.push(index);
|
|
275
267
|
else {
|
|
276
268
|
valid = false;
|
|
277
|
-
failures
|
|
269
|
+
addFailures(failures, result);
|
|
278
270
|
}
|
|
279
271
|
}
|
|
280
272
|
if (valid)
|
|
281
273
|
admitted.forEach((index) => items.add(index));
|
|
282
274
|
}
|
|
283
275
|
}
|
|
284
|
-
evaluateObject(location, schema, input, instancePointer, failures, properties
|
|
276
|
+
*evaluateObject(location, schema, input, instancePointer, failures, properties) {
|
|
285
277
|
const names = Object.keys(input);
|
|
286
278
|
if (typeof schema.maxProperties === 'number' && names.length > schema.maxProperties) {
|
|
287
|
-
failures.
|
|
279
|
+
failures.add(invalid(instancePointer, 'maxProperties', 'Object exceeds maxProperties.'));
|
|
288
280
|
}
|
|
289
281
|
if (typeof schema.minProperties === 'number' && names.length < schema.minProperties) {
|
|
290
|
-
failures.
|
|
282
|
+
failures.add(invalid(instancePointer, 'minProperties', 'Object is below minProperties.'));
|
|
291
283
|
}
|
|
292
284
|
if (Array.isArray(schema.required)) {
|
|
293
285
|
for (const name of schema.required) {
|
|
294
286
|
if (typeof name === 'string' && !Object.hasOwn(input, name)) {
|
|
295
|
-
failures.
|
|
287
|
+
failures.add(invalid(instancePointer, 'required', `Object is missing required property ${name}.`));
|
|
296
288
|
}
|
|
297
289
|
}
|
|
298
290
|
}
|
|
@@ -302,7 +294,7 @@ class InstanceEvaluator {
|
|
|
302
294
|
continue;
|
|
303
295
|
for (const dependency of required) {
|
|
304
296
|
if (typeof dependency === 'string' && !Object.hasOwn(input, dependency)) {
|
|
305
|
-
failures.
|
|
297
|
+
failures.add(invalid(instancePointer, 'dependentRequired', `Property ${name} requires property ${dependency}.`));
|
|
306
298
|
}
|
|
307
299
|
}
|
|
308
300
|
}
|
|
@@ -311,10 +303,10 @@ class InstanceEvaluator {
|
|
|
311
303
|
const declaredPresent = Object.keys(declared).filter((name) => Object.hasOwn(input, name));
|
|
312
304
|
let declaredValid = true;
|
|
313
305
|
for (const name of declaredPresent) {
|
|
314
|
-
const result = this.evaluate(this.child(location, 'properties', name), input[name], appendPointer(instancePointer, name));
|
|
306
|
+
const result = yield this.evaluate(this.child(location, 'properties', name), input[name], appendPointer(instancePointer, name));
|
|
315
307
|
if (!result.valid) {
|
|
316
308
|
declaredValid = false;
|
|
317
|
-
failures
|
|
309
|
+
addFailures(failures, result);
|
|
318
310
|
}
|
|
319
311
|
}
|
|
320
312
|
if (declaredValid)
|
|
@@ -327,57 +319,57 @@ class InstanceEvaluator {
|
|
|
327
319
|
if (!this.matchesPattern(pattern, name, false))
|
|
328
320
|
continue;
|
|
329
321
|
patternMatched.add(name);
|
|
330
|
-
const result = this.evaluate(this.child(location, 'patternProperties', pattern), input[name], appendPointer(instancePointer, name));
|
|
322
|
+
const result = yield this.evaluate(this.child(location, 'patternProperties', pattern), input[name], appendPointer(instancePointer, name));
|
|
331
323
|
if (!result.valid) {
|
|
332
324
|
patternsValid = false;
|
|
333
|
-
failures
|
|
325
|
+
addFailures(failures, result);
|
|
334
326
|
}
|
|
335
327
|
}
|
|
336
328
|
}
|
|
337
329
|
if (patternsValid)
|
|
338
330
|
patternMatched.forEach((name) => properties.add(name));
|
|
339
|
-
if (
|
|
331
|
+
if (isJsonSchema(schema.additionalProperties)) {
|
|
340
332
|
const additional = names.filter((name) => !Object.hasOwn(declared, name) && !patternMatched.has(name));
|
|
341
333
|
let additionalValid = true;
|
|
342
334
|
for (const name of additional) {
|
|
343
|
-
const result = this.evaluate(this.child(location, 'additionalProperties'), input[name], appendPointer(instancePointer, name));
|
|
335
|
+
const result = yield this.evaluate(this.child(location, 'additionalProperties'), input[name], appendPointer(instancePointer, name));
|
|
344
336
|
if (!result.valid) {
|
|
345
337
|
additionalValid = false;
|
|
346
|
-
failures
|
|
338
|
+
addFailures(failures, result);
|
|
347
339
|
}
|
|
348
340
|
}
|
|
349
341
|
if (additionalValid)
|
|
350
342
|
additional.forEach((name) => properties.add(name));
|
|
351
343
|
}
|
|
352
|
-
if (
|
|
344
|
+
if (isJsonSchema(schema.propertyNames)) {
|
|
353
345
|
for (const name of names) {
|
|
354
|
-
const result = this.evaluate(this.child(location, 'propertyNames'), name, appendPointer(instancePointer, name));
|
|
346
|
+
const result = yield this.evaluate(this.child(location, 'propertyNames'), name, appendPointer(instancePointer, name));
|
|
355
347
|
if (!result.valid)
|
|
356
|
-
failures
|
|
348
|
+
addFailures(failures, result);
|
|
357
349
|
}
|
|
358
350
|
}
|
|
359
351
|
if (isJsonObject(schema.dependentSchemas)) {
|
|
360
352
|
for (const name of Object.keys(schema.dependentSchemas)) {
|
|
361
353
|
if (!Object.hasOwn(input, name))
|
|
362
354
|
continue;
|
|
363
|
-
const result = this.evaluate(this.child(location, 'dependentSchemas', name), input, instancePointer);
|
|
355
|
+
const result = yield this.evaluate(this.child(location, 'dependentSchemas', name), input, instancePointer);
|
|
364
356
|
if (result.valid)
|
|
365
357
|
mergeAnnotations(properties, new Set(), result);
|
|
366
358
|
else
|
|
367
|
-
failures
|
|
359
|
+
addFailures(failures, result);
|
|
368
360
|
}
|
|
369
361
|
}
|
|
370
|
-
if (
|
|
362
|
+
if (isJsonSchema(schema.unevaluatedProperties)) {
|
|
371
363
|
const unevaluated = names.filter((name) => !properties.has(name));
|
|
372
364
|
let valid = true;
|
|
373
365
|
const admitted = [];
|
|
374
366
|
for (const name of unevaluated) {
|
|
375
|
-
const result = this.evaluate(this.child(location, 'unevaluatedProperties'), input[name], appendPointer(instancePointer, name));
|
|
367
|
+
const result = yield this.evaluate(this.child(location, 'unevaluatedProperties'), input[name], appendPointer(instancePointer, name));
|
|
376
368
|
if (result.valid)
|
|
377
369
|
admitted.push(name);
|
|
378
370
|
else {
|
|
379
371
|
valid = false;
|
|
380
|
-
failures
|
|
372
|
+
addFailures(failures, result);
|
|
381
373
|
}
|
|
382
374
|
}
|
|
383
375
|
if (valid)
|
|
@@ -409,6 +401,17 @@ class InstanceEvaluator {
|
|
|
409
401
|
return result;
|
|
410
402
|
}
|
|
411
403
|
}
|
|
404
|
+
/** What a location answering for the same value adds to the location that applies it. */
|
|
405
|
+
function absorb(result, failures, properties, items) {
|
|
406
|
+
if (result.valid)
|
|
407
|
+
mergeAnnotations(properties, items, result);
|
|
408
|
+
else
|
|
409
|
+
addFailures(failures, result);
|
|
410
|
+
}
|
|
411
|
+
function addFailures(failures, result) {
|
|
412
|
+
for (const failure of result.failures)
|
|
413
|
+
failures.add(failure);
|
|
414
|
+
}
|
|
412
415
|
/** A required property with a different primitive const makes the entire branch impossible. */
|
|
413
416
|
function contradictsRequiredConst(schema, input) {
|
|
414
417
|
if (!isJsonObject(schema) || !isJsonObject(input) || !Array.isArray(schema.required)) {
|
|
@@ -433,12 +436,6 @@ function contradictsRequiredConst(schema, input) {
|
|
|
433
436
|
}
|
|
434
437
|
return false;
|
|
435
438
|
}
|
|
436
|
-
function schemaList(input) {
|
|
437
|
-
return Array.isArray(input) ? input : undefined;
|
|
438
|
-
}
|
|
439
|
-
function isSchema(input) {
|
|
440
|
-
return typeof input === 'boolean' || isJsonObject(input);
|
|
441
|
-
}
|
|
442
439
|
function invalid(instancePointer, keyword, message) {
|
|
443
440
|
return { instancePointer, keyword, message };
|
|
444
441
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { Diagnostic } from '../../validation/diagnostic.js';
|
|
2
|
+
import type { ValueProgram } from '../compile/model.js';
|
|
1
3
|
import type { JsonSchema } from '../model/schema.js';
|
|
2
4
|
import type { ValueSchemaRegistry } from '../reference/registry.js';
|
|
3
5
|
import type { IRegexpMatcher } from '../regexp/matcher.js';
|
|
@@ -18,5 +20,19 @@ interface PreparedPattern {
|
|
|
18
20
|
export type PatternPool = Map<string, PreparedPattern>;
|
|
19
21
|
/** Prepare reference and linear-regexp state without generating executable source. */
|
|
20
22
|
export declare function prepareValueSchema(schema: JsonSchema, registry: ValueSchemaRegistry, pointer: string, pool?: PatternPool): InstanceSchemaCompilation;
|
|
23
|
+
/** The one graph a program's root schema has: compiling emits it, admission reads it. */
|
|
24
|
+
export type ValueGraph = Pick<ValueProgram, 'root' | 'nodes'>;
|
|
25
|
+
/**
|
|
26
|
+
* Derive the graph of a schema no admission has seen and the pattern sources it uses, or the refusal
|
|
27
|
+
* of one with no graph to read: a reference with no target, a cycle consuming nothing, or a subschema
|
|
28
|
+
* slot holding anything else. Closed under the two reference forms, it needs no registry and compiles
|
|
29
|
+
* no pattern.
|
|
30
|
+
*/
|
|
31
|
+
export declare function deriveValueGraph(schema: JsonSchema, pointer: string): {
|
|
32
|
+
readonly graph: ValueGraph;
|
|
33
|
+
readonly sources: readonly string[];
|
|
34
|
+
} | {
|
|
35
|
+
readonly refusal: Diagnostic;
|
|
36
|
+
};
|
|
21
37
|
export declare function childKey(pointer: string): string;
|
|
22
38
|
export {};
|