@astrale-os/kernel-dsl 0.1.5 → 0.2.0-beta.10
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/index.d.ts +1 -57
- package/dist/index.js +1 -31
- package/dist/upgrade/contract.d.ts +31 -0
- package/dist/upgrade/contract.js +1 -0
- package/dist/upgrade/index.d.ts +1 -0
- package/dist/upgrade/index.js +1 -0
- package/dist/v1/addressing/class-key.d.ts +12 -0
- package/dist/v1/addressing/class-key.js +39 -0
- package/dist/v1/addressing/definition-ref.d.ts +28 -0
- package/dist/v1/addressing/definition-ref.js +63 -0
- package/dist/v1/addressing/domain-dependency.d.ts +18 -0
- package/dist/v1/addressing/domain-dependency.js +6 -0
- package/dist/v1/addressing/index.d.ts +12 -0
- package/dist/v1/addressing/index.js +7 -0
- package/dist/v1/addressing/key.d.ts +19 -0
- package/dist/v1/addressing/key.js +39 -0
- package/dist/v1/addressing/method-address.d.ts +9 -0
- package/dist/v1/addressing/method-address.js +1 -0
- package/dist/v1/addressing/method-key.d.ts +15 -0
- package/dist/v1/addressing/method-key.js +60 -0
- package/dist/v1/addressing/ordering.d.ts +6 -0
- package/dist/v1/addressing/ordering.js +20 -0
- package/dist/v1/addressing/patterns.d.ts +27 -0
- package/dist/v1/addressing/patterns.js +29 -0
- package/dist/v1/addressing/property-key.d.ts +13 -0
- package/dist/v1/addressing/property-key.js +39 -0
- package/dist/v1/addressing/revision.d.ts +8 -0
- package/dist/v1/addressing/revision.js +8 -0
- package/dist/v1/builder/callable/authoring.d.ts +117 -0
- package/dist/v1/builder/callable/authoring.js +67 -0
- package/dist/v1/builder/class/authoring.d.ts +367 -0
- package/dist/v1/builder/class/authoring.js +134 -0
- package/dist/v1/builder/class/property.d.ts +52 -0
- package/dist/v1/builder/class/property.js +49 -0
- package/dist/v1/builder/core/authoring.d.ts +42 -0
- package/dist/v1/builder/core/authoring.js +39 -0
- package/dist/v1/builder/index.d.ts +26 -0
- package/dist/v1/builder/index.js +11 -0
- package/dist/v1/builder/lowering/callable.d.ts +24 -0
- package/dist/v1/builder/lowering/callable.js +135 -0
- package/dist/v1/builder/lowering/class.d.ts +22 -0
- package/dist/v1/builder/lowering/class.js +129 -0
- package/dist/v1/builder/lowering/core-properties.d.ts +10 -0
- package/dist/v1/builder/lowering/core-properties.js +76 -0
- package/dist/v1/builder/lowering/core.d.ts +22 -0
- package/dist/v1/builder/lowering/core.js +50 -0
- package/dist/v1/builder/lowering/policy.d.ts +16 -0
- package/dist/v1/builder/lowering/policy.js +59 -0
- package/dist/v1/builder/lowering/schema/capture.d.ts +4 -0
- package/dist/v1/builder/lowering/schema/capture.js +70 -0
- package/dist/v1/builder/lowering/schema/compile.d.ts +10 -0
- package/dist/v1/builder/lowering/schema/compile.js +80 -0
- package/dist/v1/builder/lowering/schema/context.d.ts +44 -0
- package/dist/v1/builder/lowering/schema/context.js +247 -0
- package/dist/v1/builder/lowering/schema/ownership.d.ts +8 -0
- package/dist/v1/builder/lowering/schema/ownership.js +29 -0
- package/dist/v1/builder/lowering/value/compile.d.ts +15 -0
- package/dist/v1/builder/lowering/value/compile.js +136 -0
- package/dist/v1/builder/lowering/value/path.d.ts +3 -0
- package/dist/v1/builder/lowering/value/path.js +20 -0
- package/dist/v1/builder/lowering/value/zod.d.ts +32 -0
- package/dist/v1/builder/lowering/value/zod.js +342 -0
- package/dist/v1/builder/lowering/view.d.ts +11 -0
- package/dist/v1/builder/lowering/view.js +27 -0
- package/dist/v1/builder/policy/authoring.d.ts +52 -0
- package/dist/v1/builder/policy/authoring.js +90 -0
- package/dist/v1/builder/schema/define.d.ts +11 -0
- package/dist/v1/builder/schema/define.js +5 -0
- package/dist/v1/builder/schema/diagnostic.d.ts +16 -0
- package/dist/v1/builder/schema/diagnostic.js +31 -0
- package/dist/v1/builder/schema/handle.d.ts +7 -0
- package/dist/v1/builder/schema/handle.js +14 -0
- package/dist/v1/builder/schema/input.d.ts +15 -0
- package/dist/v1/builder/schema/input.js +1 -0
- package/dist/v1/builder/schema/lazy.d.ts +2 -0
- package/dist/v1/builder/schema/lazy.js +13 -0
- package/dist/v1/builder/schema/projection.d.ts +364 -0
- package/dist/v1/builder/schema/projection.js +1 -0
- package/dist/v1/builder/value/full-match.d.ts +4 -0
- package/dist/v1/builder/value/full-match.js +11 -0
- package/dist/v1/builder/value/path-metadata.d.ts +4 -0
- package/dist/v1/builder/value/path-metadata.js +7 -0
- package/dist/v1/builder/value/path.d.ts +8 -0
- package/dist/v1/builder/value/path.js +11 -0
- package/dist/v1/builder/value/schema.d.ts +16 -0
- package/dist/v1/builder/value/schema.js +10 -0
- package/dist/v1/builder/view/authoring.d.ts +17 -0
- package/dist/v1/builder/view/authoring.js +16 -0
- package/dist/v1/bundle/codec.d.ts +5 -0
- package/dist/v1/bundle/codec.js +168 -0
- package/dist/v1/bundle/create.d.ts +3 -0
- package/dist/v1/bundle/create.js +5 -0
- package/dist/v1/bundle/diagnostic.d.ts +10 -0
- package/dist/v1/bundle/diagnostic.js +17 -0
- package/dist/v1/bundle/index.d.ts +18 -0
- package/dist/v1/bundle/index.js +20 -0
- package/dist/v1/bundle/model.d.ts +16 -0
- package/dist/v1/bundle/model.js +11 -0
- package/dist/v1/bundle/structure.d.ts +7 -0
- package/dist/v1/bundle/structure.js +71 -0
- package/dist/v1/bundle/transport.d.ts +8 -0
- package/dist/v1/bundle/transport.js +7 -0
- package/dist/v1/compiled/admission/accept.d.ts +3 -0
- package/dist/v1/compiled/admission/accept.js +881 -0
- package/dist/v1/compiled/admission/revision.d.ts +4 -0
- package/dist/v1/compiled/admission/revision.js +73 -0
- package/dist/v1/compiled/admission/semantics.d.ts +7 -0
- package/dist/v1/compiled/admission/semantics.js +1091 -0
- package/dist/v1/compiled/codec/json.d.ts +3 -0
- package/dist/v1/compiled/codec/json.js +9 -0
- package/dist/v1/compiled/compiler/compile.d.ts +4 -0
- package/dist/v1/compiled/compiler/compile.js +113 -0
- package/dist/v1/compiled/diagnostic.d.ts +11 -0
- package/dist/v1/compiled/diagnostic.js +13 -0
- package/dist/v1/compiled/index.d.ts +7 -0
- package/dist/v1/compiled/index.js +5 -0
- package/dist/v1/compiled/loader/index.d.ts +1 -0
- package/dist/v1/compiled/loader/index.js +1 -0
- package/dist/v1/compiled/loader/load.d.ts +4 -0
- package/dist/v1/compiled/loader/load.js +141 -0
- package/dist/v1/compiled/model/schema.d.ts +73 -0
- package/dist/v1/compiled/model/schema.js +1 -0
- package/dist/v1/domain/create.d.ts +8 -0
- package/dist/v1/domain/create.js +264 -0
- package/dist/v1/domain/index.d.ts +2 -0
- package/dist/v1/domain/index.js +1 -0
- package/dist/v1/domain/model/domain.d.ts +59 -0
- package/dist/v1/domain/model/domain.js +1 -0
- package/dist/v1/domain/model/input.d.ts +31 -0
- package/dist/v1/domain/model/input.js +1 -0
- package/dist/v1/domain/namespace/member-collection.d.ts +5 -0
- package/dist/v1/domain/namespace/member-collection.js +81 -0
- package/dist/v1/domain/projection/classes.d.ts +4 -0
- package/dist/v1/domain/projection/classes.js +200 -0
- package/dist/v1/domain/validation/create.d.ts +18 -0
- package/dist/v1/domain/validation/create.js +75 -0
- package/dist/v1/index.d.ts +16 -0
- package/dist/v1/index.js +8 -0
- package/dist/v1/language/callable/index.d.ts +2 -0
- package/dist/v1/language/callable/index.js +1 -0
- package/dist/v1/language/callable/model/callable.d.ts +33 -0
- package/dist/v1/language/callable/model/callable.js +1 -0
- package/dist/v1/language/callable/resolved.d.ts +68 -0
- package/dist/v1/language/callable/resolved.js +1 -0
- package/dist/v1/language/class/facets.d.ts +58 -0
- package/dist/v1/language/class/facets.js +1 -0
- package/dist/v1/language/class/index.d.ts +8 -0
- package/dist/v1/language/class/index.js +1 -0
- package/dist/v1/language/class/model/class.d.ts +36 -0
- package/dist/v1/language/class/model/class.js +1 -0
- package/dist/v1/language/class/model/data.d.ts +11 -0
- package/dist/v1/language/class/model/data.js +2 -0
- package/dist/v1/language/class/model/edge.d.ts +38 -0
- package/dist/v1/language/class/model/edge.js +1 -0
- package/dist/v1/language/class/model/property.d.ts +18 -0
- package/dist/v1/language/class/model/property.js +1 -0
- package/dist/v1/language/class/property-values.d.ts +15 -0
- package/dist/v1/language/class/property-values.js +30 -0
- package/dist/v1/language/class/resolved.d.ts +123 -0
- package/dist/v1/language/class/resolved.js +1 -0
- package/dist/v1/language/core/index.d.ts +2 -0
- package/dist/v1/language/core/index.js +1 -0
- package/dist/v1/language/core/model/core.d.ts +20 -0
- package/dist/v1/language/core/model/core.js +1 -0
- package/dist/v1/language/core/resolved.d.ts +21 -0
- package/dist/v1/language/core/resolved.js +1 -0
- package/dist/v1/language/definition/metadata.d.ts +12 -0
- package/dist/v1/language/definition/metadata.js +12 -0
- package/dist/v1/language/definition.d.ts +7 -0
- package/dist/v1/language/definition.js +1 -0
- package/dist/v1/language/index.d.ts +23 -0
- package/dist/v1/language/index.js +1 -0
- package/dist/v1/language/policy/analysis/branches.d.ts +19 -0
- package/dist/v1/language/policy/analysis/branches.js +132 -0
- package/dist/v1/language/policy/analysis/budgets.d.ts +16 -0
- package/dist/v1/language/policy/analysis/budgets.js +25 -0
- package/dist/v1/language/policy/index.d.ts +3 -0
- package/dist/v1/language/policy/index.js +1 -0
- package/dist/v1/language/policy/model/policy.d.ts +77 -0
- package/dist/v1/language/policy/model/policy.js +1 -0
- package/dist/v1/language/policy/normalization/normalize.d.ts +4 -0
- package/dist/v1/language/policy/normalization/normalize.js +226 -0
- package/dist/v1/language/policy/resolved.d.ts +9 -0
- package/dist/v1/language/policy/resolved.js +1 -0
- package/dist/v1/language/resolved.d.ts +10 -0
- package/dist/v1/language/resolved.js +1 -0
- package/dist/v1/language/validation/diagnostic.d.ts +8 -0
- package/dist/v1/language/validation/diagnostic.js +3 -0
- package/dist/v1/language/value/compile/fields.d.ts +3 -0
- package/dist/v1/language/value/compile/fields.js +60 -0
- package/dist/v1/language/value/compile/load.d.ts +4 -0
- package/dist/v1/language/value/compile/load.js +41 -0
- package/dist/v1/language/value/compile/model.d.ts +27 -0
- package/dist/v1/language/value/compile/model.js +1 -0
- package/dist/v1/language/value/evaluate/assertions.d.ts +6 -0
- package/dist/v1/language/value/evaluate/assertions.js +58 -0
- package/dist/v1/language/value/evaluate/evaluator.d.ts +4 -0
- package/dist/v1/language/value/evaluate/evaluator.js +361 -0
- package/dist/v1/language/value/evaluate/preparation.d.ts +13 -0
- package/dist/v1/language/value/evaluate/preparation.js +135 -0
- package/dist/v1/language/value/evaluate/program.d.ts +3 -0
- package/dist/v1/language/value/evaluate/program.js +16 -0
- package/dist/v1/language/value/evaluate/types.d.ts +36 -0
- package/dist/v1/language/value/evaluate/types.js +9 -0
- package/dist/v1/language/value/evaluate/validate.d.ts +12 -0
- package/dist/v1/language/value/evaluate/validate.js +43 -0
- package/dist/v1/language/value/index.d.ts +11 -0
- package/dist/v1/language/value/index.js +8 -0
- package/dist/v1/language/value/model/instant.d.ts +9 -0
- package/dist/v1/language/value/model/instant.js +37 -0
- package/dist/v1/language/value/model/object.d.ts +5 -0
- package/dist/v1/language/value/model/object.js +3 -0
- package/dist/v1/language/value/model/schema.d.ts +25 -0
- package/dist/v1/language/value/model/schema.js +11 -0
- package/dist/v1/language/value/ordering.d.ts +13 -0
- package/dist/v1/language/value/ordering.js +174 -0
- package/dist/v1/language/value/profile/canonicalize.d.ts +4 -0
- package/dist/v1/language/value/profile/canonicalize.js +130 -0
- package/dist/v1/language/value/profile/json.validate.d.ts +2 -0
- package/dist/v1/language/value/profile/json.validate.js +14 -0
- package/dist/v1/language/value/profile/meta-schema.compiled.d.ts +78 -0
- package/dist/v1/language/value/profile/meta-schema.compiled.js +2079 -0
- package/dist/v1/language/value/profile/meta-schema.d.ts +4 -0
- package/dist/v1/language/value/profile/meta-schema.js +19 -0
- package/dist/v1/language/value/profile/rules.d.ts +3 -0
- package/dist/v1/language/value/profile/rules.js +109 -0
- package/dist/v1/language/value/profile/validate.d.ts +4 -0
- package/dist/v1/language/value/profile/validate.js +39 -0
- package/dist/v1/language/value/profile/vocabulary.d.ts +2 -0
- package/dist/v1/language/value/profile/vocabulary.js +68 -0
- package/dist/v1/language/value/reference/closure.d.ts +11 -0
- package/dist/v1/language/value/reference/closure.js +51 -0
- package/dist/v1/language/value/reference/recursion.d.ts +5 -0
- package/dist/v1/language/value/reference/recursion.js +95 -0
- package/dist/v1/language/value/reference/references.d.ts +17 -0
- package/dist/v1/language/value/reference/references.js +45 -0
- package/dist/v1/language/value/reference/registry.d.ts +24 -0
- package/dist/v1/language/value/reference/registry.index.d.ts +14 -0
- package/dist/v1/language/value/reference/registry.index.js +76 -0
- package/dist/v1/language/value/reference/registry.js +1 -0
- package/dist/v1/language/value/regexp/ast.d.ts +21 -0
- package/dist/v1/language/value/regexp/ast.js +326 -0
- package/dist/v1/language/value/regexp/compile.d.ts +3 -0
- package/dist/v1/language/value/regexp/compile.js +96 -0
- package/dist/v1/language/value/regexp/lower.d.ts +3 -0
- package/dist/v1/language/value/regexp/lower.js +26 -0
- package/dist/v1/language/value/regexp/matcher.d.ts +7 -0
- package/dist/v1/language/value/regexp/matcher.js +50 -0
- package/dist/v1/language/value/regexp/pattern.d.ts +2 -0
- package/dist/v1/language/value/regexp/pattern.js +38 -0
- package/dist/v1/language/value/regexp/syntax.d.ts +2 -0
- package/dist/v1/language/value/regexp/syntax.js +5 -0
- package/dist/v1/language/value/syntax/full-match.d.ts +6 -0
- package/dist/v1/language/value/syntax/full-match.js +20 -0
- package/dist/v1/language/value/syntax/keywords.d.ts +3 -0
- package/dist/v1/language/value/syntax/keywords.js +20 -0
- package/dist/v1/language/value/syntax/node-path/schema.d.ts +5 -0
- package/dist/v1/language/value/syntax/node-path/schema.js +18 -0
- package/dist/v1/language/value/syntax/node-path/validate.d.ts +4 -0
- package/dist/v1/language/value/syntax/node-path/validate.js +80 -0
- package/dist/v1/language/value/syntax/pointer.d.ts +4 -0
- package/dist/v1/language/value/syntax/pointer.js +49 -0
- package/dist/v1/language/value/syntax/walk.d.ts +10 -0
- package/dist/v1/language/value/syntax/walk.js +53 -0
- package/dist/v1/language/view/index.d.ts +2 -0
- package/dist/v1/language/view/index.js +1 -0
- package/dist/v1/language/view/model/view.d.ts +11 -0
- package/dist/v1/language/view/model/view.js +1 -0
- package/dist/v1/language/view/resolved.d.ts +9 -0
- package/dist/v1/language/view/resolved.js +1 -0
- package/dist/v1/schema/admission/accept.d.ts +3 -0
- package/dist/v1/schema/admission/accept.js +26 -0
- package/dist/v1/schema/analysis/class.d.ts +41 -0
- package/dist/v1/schema/analysis/class.js +181 -0
- package/dist/v1/schema/canonical/domain.d.ts +3 -0
- package/dist/v1/schema/canonical/domain.digest.d.ts +3 -0
- package/dist/v1/schema/canonical/domain.digest.js +5 -0
- package/dist/v1/schema/canonical/domain.js +5 -0
- package/dist/v1/schema/canonical/freeze.d.ts +1 -0
- package/dist/v1/schema/canonical/freeze.js +9 -0
- package/dist/v1/schema/canonical/revision.d.ts +11 -0
- package/dist/v1/schema/canonical/revision.js +17 -0
- package/dist/v1/schema/codec/header.d.ts +17 -0
- package/dist/v1/schema/codec/header.js +26 -0
- package/dist/v1/schema/codec/schema.d.ts +5 -0
- package/dist/v1/schema/codec/schema.js +21 -0
- package/dist/v1/schema/compatibility/meaning.d.ts +29 -0
- package/dist/v1/schema/compatibility/meaning.js +605 -0
- package/dist/v1/schema/dependency/lookup.d.ts +18 -0
- package/dist/v1/schema/dependency/lookup.js +31 -0
- package/dist/v1/schema/diagnostic.d.ts +12 -0
- package/dist/v1/schema/diagnostic.js +21 -0
- package/dist/v1/schema/index.d.ts +26 -0
- package/dist/v1/schema/index.js +13 -0
- package/dist/v1/schema/model/format.d.ts +2 -0
- package/dist/v1/schema/model/format.js +2 -0
- package/dist/v1/schema/model/schema.d.ts +30 -0
- package/dist/v1/schema/model/schema.js +4 -0
- package/dist/v1/schema/normalization/domain.d.ts +2 -0
- package/dist/v1/schema/normalization/domain.js +207 -0
- package/dist/v1/schema/resolution/closure.d.ts +9 -0
- package/dist/v1/schema/resolution/closure.js +49 -0
- package/dist/v1/schema/resolution/context.d.ts +17 -0
- package/dist/v1/schema/resolution/context.js +158 -0
- package/dist/v1/schema/resolution/definition.index.d.ts +21 -0
- package/dist/v1/schema/resolution/definition.index.js +17 -0
- package/dist/v1/schema/resolution/domain.d.ts +4 -0
- package/dist/v1/schema/resolution/domain.js +112 -0
- package/dist/v1/schema/resolution/origins.d.ts +14 -0
- package/dist/v1/schema/resolution/origins.js +121 -0
- package/dist/v1/schema/resolution/value.registry.d.ts +7 -0
- package/dist/v1/schema/resolution/value.registry.js +39 -0
- package/dist/v1/schema/revision.d.ts +1 -0
- package/dist/v1/schema/revision.js +1 -0
- package/dist/v1/schema/validation/class.d.ts +5 -0
- package/dist/v1/schema/validation/class.js +208 -0
- package/dist/v1/schema/validation/core.d.ts +5 -0
- package/dist/v1/schema/validation/core.js +264 -0
- package/dist/v1/schema/validation/domain.d.ts +11 -0
- package/dist/v1/schema/validation/domain.js +36 -0
- package/dist/v1/schema/validation/domain.route.d.ts +4 -0
- package/dist/v1/schema/validation/domain.route.js +32 -0
- package/dist/v1/schema/validation/domain.structure.d.ts +4 -0
- package/dist/v1/schema/validation/domain.structure.js +427 -0
- package/dist/v1/schema/validation/policy/budgets.d.ts +4 -0
- package/dist/v1/schema/validation/policy/budgets.js +102 -0
- package/dist/v1/schema/validation/policy/context.d.ts +28 -0
- package/dist/v1/schema/validation/policy/context.js +89 -0
- package/dist/v1/schema/validation/policy/references.d.ts +2 -0
- package/dist/v1/schema/validation/policy/references.js +143 -0
- package/dist/v1/schema/validation/policy/typing.d.ts +19 -0
- package/dist/v1/schema/validation/policy/typing.js +318 -0
- package/dist/v1/schema/validation/policy/uses.d.ts +5 -0
- package/dist/v1/schema/validation/policy/uses.js +258 -0
- package/dist/v1/schema/validation/policy/validate.d.ts +11 -0
- package/dist/v1/schema/validation/policy/validate.js +23 -0
- package/dist/v1/schema/validation/value-api.d.ts +13 -0
- package/dist/v1/schema/validation/value-api.js +23 -0
- package/dist/v1/schema/validation/value.d.ts +4 -0
- package/dist/v1/schema/validation/value.js +39 -0
- package/dist/v1/schema/validation/view.d.ts +3 -0
- package/dist/v1/schema/validation/view.js +29 -0
- package/dist/v1/value/full-match.d.ts +2 -0
- package/dist/v1/value/full-match.js +2 -0
- package/dist/v1.d.ts +2 -0
- package/dist/v1.js +2 -0
- package/dist/value/accept.d.ts +8 -0
- package/dist/value/accept.js +132 -0
- package/dist/value/canonical.d.ts +4 -0
- package/dist/value/canonical.js +41 -0
- package/dist/value/decode.d.ts +4 -0
- package/dist/value/decode.js +108 -0
- package/dist/value/equal.d.ts +3 -0
- package/dist/value/equal.js +5 -0
- package/dist/value/error.d.ts +12 -0
- package/dist/value/error.js +21 -0
- package/dist/value/index.d.ts +9 -0
- package/dist/value/index.js +6 -0
- package/dist/value/json.d.ts +3 -0
- package/dist/value/json.js +3 -0
- package/dist/value/limits.d.ts +21 -0
- package/dist/value/limits.js +15 -0
- package/dist/value/types.d.ts +6 -0
- package/dist/value/types.js +1 -0
- package/dist/value/unicode.d.ts +4 -0
- package/dist/value/unicode.js +64 -0
- package/dist/version/dispatch.d.ts +24 -0
- package/dist/version/dispatch.js +47 -0
- package/dist/version/index.d.ts +2 -0
- package/dist/version/index.js +1 -0
- package/package.json +75 -15
- package/dist/builders/bitmask.d.ts +0 -5
- package/dist/builders/bitmask.d.ts.map +0 -1
- package/dist/builders/bitmask.js +0 -12
- package/dist/builders/bitmask.js.map +0 -1
- package/dist/builders/data.d.ts +0 -7
- package/dist/builders/data.d.ts.map +0 -1
- package/dist/builders/data.js +0 -18
- package/dist/builders/data.js.map +0 -1
- package/dist/builders/definition/base.d.ts +0 -13
- package/dist/builders/definition/base.d.ts.map +0 -1
- package/dist/builders/definition/base.js +0 -24
- package/dist/builders/definition/base.js.map +0 -1
- package/dist/builders/definition/edge-class.d.ts +0 -8
- package/dist/builders/definition/edge-class.d.ts.map +0 -1
- package/dist/builders/definition/edge-class.js +0 -9
- package/dist/builders/definition/edge-class.js.map +0 -1
- package/dist/builders/definition/edge-interface.d.ts +0 -8
- package/dist/builders/definition/edge-interface.d.ts.map +0 -1
- package/dist/builders/definition/edge-interface.js +0 -9
- package/dist/builders/definition/edge-interface.js.map +0 -1
- package/dist/builders/definition/node-class.d.ts +0 -7
- package/dist/builders/definition/node-class.d.ts.map +0 -1
- package/dist/builders/definition/node-class.js +0 -9
- package/dist/builders/definition/node-class.js.map +0 -1
- package/dist/builders/definition/node-interface.d.ts +0 -7
- package/dist/builders/definition/node-interface.d.ts.map +0 -1
- package/dist/builders/definition/node-interface.js +0 -9
- package/dist/builders/definition/node-interface.js.map +0 -1
- package/dist/builders/function.d.ts +0 -34
- package/dist/builders/function.d.ts.map +0 -1
- package/dist/builders/function.js +0 -8
- package/dist/builders/function.js.map +0 -1
- package/dist/builders/policy.d.ts +0 -10
- package/dist/builders/policy.d.ts.map +0 -1
- package/dist/builders/policy.js +0 -28
- package/dist/builders/policy.js.map +0 -1
- package/dist/builders/prop.d.ts +0 -7
- package/dist/builders/prop.d.ts.map +0 -1
- package/dist/builders/prop.js +0 -9
- package/dist/builders/prop.js.map +0 -1
- package/dist/builders/ref.d.ts +0 -12
- package/dist/builders/ref.d.ts.map +0 -1
- package/dist/builders/ref.js +0 -27
- package/dist/builders/ref.js.map +0 -1
- package/dist/grammar/definition/base.d.ts +0 -13
- package/dist/grammar/definition/base.d.ts.map +0 -1
- package/dist/grammar/definition/base.js +0 -2
- package/dist/grammar/definition/base.js.map +0 -1
- package/dist/grammar/definition/discriminants.d.ts +0 -31
- package/dist/grammar/definition/discriminants.d.ts.map +0 -1
- package/dist/grammar/definition/discriminants.js +0 -33
- package/dist/grammar/definition/discriminants.js.map +0 -1
- package/dist/grammar/definition/edge-class.d.ts +0 -19
- package/dist/grammar/definition/edge-class.d.ts.map +0 -1
- package/dist/grammar/definition/edge-class.js +0 -2
- package/dist/grammar/definition/edge-class.js.map +0 -1
- package/dist/grammar/definition/edge-interface.d.ts +0 -18
- package/dist/grammar/definition/edge-interface.d.ts.map +0 -1
- package/dist/grammar/definition/edge-interface.js +0 -2
- package/dist/grammar/definition/edge-interface.js.map +0 -1
- package/dist/grammar/definition/node-class.d.ts +0 -26
- package/dist/grammar/definition/node-class.d.ts.map +0 -1
- package/dist/grammar/definition/node-class.js +0 -2
- package/dist/grammar/definition/node-class.js.map +0 -1
- package/dist/grammar/definition/node-interface.d.ts +0 -14
- package/dist/grammar/definition/node-interface.d.ts.map +0 -1
- package/dist/grammar/definition/node-interface.js +0 -2
- package/dist/grammar/definition/node-interface.js.map +0 -1
- package/dist/grammar/facets/constraints.d.ts +0 -8
- package/dist/grammar/facets/constraints.d.ts.map +0 -1
- package/dist/grammar/facets/constraints.js +0 -2
- package/dist/grammar/facets/constraints.js.map +0 -1
- package/dist/grammar/facets/content.d.ts +0 -4
- package/dist/grammar/facets/content.d.ts.map +0 -1
- package/dist/grammar/facets/content.js +0 -2
- package/dist/grammar/facets/content.js.map +0 -1
- package/dist/grammar/facets/endpoints.d.ts +0 -14
- package/dist/grammar/facets/endpoints.d.ts.map +0 -1
- package/dist/grammar/facets/endpoints.js +0 -3
- package/dist/grammar/facets/endpoints.js.map +0 -1
- package/dist/grammar/facets/indexes.d.ts +0 -12
- package/dist/grammar/facets/indexes.d.ts.map +0 -1
- package/dist/grammar/facets/indexes.js +0 -9
- package/dist/grammar/facets/indexes.js.map +0 -1
- package/dist/grammar/facets/properties.d.ts +0 -26
- package/dist/grammar/facets/properties.d.ts.map +0 -1
- package/dist/grammar/facets/properties.js +0 -45
- package/dist/grammar/facets/properties.js.map +0 -1
- package/dist/grammar/function/config.d.ts +0 -16
- package/dist/grammar/function/config.d.ts.map +0 -1
- package/dist/grammar/function/config.js +0 -2
- package/dist/grammar/function/config.js.map +0 -1
- package/dist/grammar/function/def.d.ts +0 -58
- package/dist/grammar/function/def.d.ts.map +0 -1
- package/dist/grammar/function/def.js +0 -2
- package/dist/grammar/function/def.js.map +0 -1
- package/dist/grammar/function/inheritance.d.ts +0 -3
- package/dist/grammar/function/inheritance.d.ts.map +0 -1
- package/dist/grammar/function/inheritance.js +0 -2
- package/dist/grammar/function/inheritance.js.map +0 -1
- package/dist/grammar/function/output.d.ts +0 -3
- package/dist/grammar/function/output.d.ts.map +0 -1
- package/dist/grammar/function/output.js +0 -2
- package/dist/grammar/function/output.js.map +0 -1
- package/dist/grammar/policy/callable.d.ts +0 -40
- package/dist/grammar/policy/callable.d.ts.map +0 -1
- package/dist/grammar/policy/callable.js +0 -2
- package/dist/grammar/policy/callable.js.map +0 -1
- package/dist/grammar/policy/def.d.ts +0 -27
- package/dist/grammar/policy/def.d.ts.map +0 -1
- package/dist/grammar/policy/def.js +0 -2
- package/dist/grammar/policy/def.js.map +0 -1
- package/dist/grammar/policy/pattern.d.ts +0 -34
- package/dist/grammar/policy/pattern.d.ts.map +0 -1
- package/dist/grammar/policy/pattern.js +0 -2
- package/dist/grammar/policy/pattern.js.map +0 -1
- package/dist/grammar/values/bitmask.d.ts +0 -7
- package/dist/grammar/values/bitmask.d.ts.map +0 -1
- package/dist/grammar/values/bitmask.js +0 -2
- package/dist/grammar/values/bitmask.js.map +0 -1
- package/dist/grammar/values/data.d.ts +0 -30
- package/dist/grammar/values/data.d.ts.map +0 -1
- package/dist/grammar/values/data.js +0 -2
- package/dist/grammar/values/data.js.map +0 -1
- package/dist/grammar/values/ref.d.ts +0 -26
- package/dist/grammar/values/ref.d.ts.map +0 -1
- package/dist/grammar/values/ref.js +0 -2
- package/dist/grammar/values/ref.js.map +0 -1
- package/dist/grammar/values/self.d.ts +0 -12
- package/dist/grammar/values/self.d.ts.map +0 -1
- package/dist/grammar/values/self.js +0 -6
- package/dist/grammar/values/self.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/inference/content.d.ts +0 -27
- package/dist/inference/content.d.ts.map +0 -1
- package/dist/inference/content.js +0 -2
- package/dist/inference/content.js.map +0 -1
- package/dist/inference/index.d.ts +0 -7
- package/dist/inference/index.d.ts.map +0 -1
- package/dist/inference/index.js +0 -2
- package/dist/inference/index.js.map +0 -1
- package/dist/inference/inheritance.d.ts +0 -48
- package/dist/inference/inheritance.d.ts.map +0 -1
- package/dist/inference/inheritance.js +0 -2
- package/dist/inference/inheritance.js.map +0 -1
- package/dist/inference/input.d.ts +0 -30
- package/dist/inference/input.d.ts.map +0 -1
- package/dist/inference/input.js +0 -2
- package/dist/inference/input.js.map +0 -1
- package/dist/inference/methods.d.ts +0 -69
- package/dist/inference/methods.d.ts.map +0 -1
- package/dist/inference/methods.js +0 -2
- package/dist/inference/methods.js.map +0 -1
- package/dist/inference/properties.d.ts +0 -37
- package/dist/inference/properties.d.ts.map +0 -1
- package/dist/inference/properties.js +0 -2
- package/dist/inference/properties.js.map +0 -1
- package/dist/inference/schema.d.ts +0 -37
- package/dist/inference/schema.d.ts.map +0 -1
- package/dist/inference/schema.js +0 -2
- package/dist/inference/schema.js.map +0 -1
- package/dist/instance/core/define.d.ts +0 -13
- package/dist/instance/core/define.d.ts.map +0 -1
- package/dist/instance/core/define.js +0 -63
- package/dist/instance/core/define.js.map +0 -1
- package/dist/instance/core/edge.d.ts +0 -9
- package/dist/instance/core/edge.d.ts.map +0 -1
- package/dist/instance/core/edge.js +0 -11
- package/dist/instance/core/edge.js.map +0 -1
- package/dist/instance/core/endpoint.d.ts +0 -11
- package/dist/instance/core/endpoint.d.ts.map +0 -1
- package/dist/instance/core/endpoint.js +0 -19
- package/dist/instance/core/endpoint.js.map +0 -1
- package/dist/instance/core/node.d.ts +0 -7
- package/dist/instance/core/node.d.ts.map +0 -1
- package/dist/instance/core/node.js +0 -9
- package/dist/instance/core/node.js.map +0 -1
- package/dist/instance/core/path.d.ts +0 -21
- package/dist/instance/core/path.d.ts.map +0 -1
- package/dist/instance/core/path.js +0 -21
- package/dist/instance/core/path.js.map +0 -1
- package/dist/instance/core/self.d.ts +0 -15
- package/dist/instance/core/self.d.ts.map +0 -1
- package/dist/instance/core/self.js +0 -8
- package/dist/instance/core/self.js.map +0 -1
- package/dist/instance/core/types.d.ts +0 -45
- package/dist/instance/core/types.d.ts.map +0 -1
- package/dist/instance/core/types.js +0 -2
- package/dist/instance/core/types.js.map +0 -1
- package/dist/instance/seed/define.d.ts +0 -12
- package/dist/instance/seed/define.d.ts.map +0 -1
- package/dist/instance/seed/define.js +0 -34
- package/dist/instance/seed/define.js.map +0 -1
- package/dist/instance/seed/types.d.ts +0 -12
- package/dist/instance/seed/types.d.ts.map +0 -1
- package/dist/instance/seed/types.js +0 -2
- package/dist/instance/seed/types.js.map +0 -1
- package/dist/ir/classes.d.ts +0 -78
- package/dist/ir/classes.d.ts.map +0 -1
- package/dist/ir/classes.js +0 -2
- package/dist/ir/classes.js.map +0 -1
- package/dist/ir/domain.d.ts +0 -13
- package/dist/ir/domain.d.ts.map +0 -1
- package/dist/ir/domain.js +0 -2
- package/dist/ir/domain.js.map +0 -1
- package/dist/ir/endpoints.d.ts +0 -27
- package/dist/ir/endpoints.d.ts.map +0 -1
- package/dist/ir/endpoints.js +0 -2
- package/dist/ir/endpoints.js.map +0 -1
- package/dist/ir/functions.d.ts +0 -34
- package/dist/ir/functions.d.ts.map +0 -1
- package/dist/ir/functions.js +0 -2
- package/dist/ir/functions.js.map +0 -1
- package/dist/ir/index.d.ts +0 -9
- package/dist/ir/index.d.ts.map +0 -1
- package/dist/ir/index.js +0 -2
- package/dist/ir/index.js.map +0 -1
- package/dist/ir/ir.d.ts +0 -75
- package/dist/ir/ir.d.ts.map +0 -1
- package/dist/ir/ir.js +0 -5
- package/dist/ir/ir.js.map +0 -1
- package/dist/ir/json-schema.d.ts +0 -20
- package/dist/ir/json-schema.d.ts.map +0 -1
- package/dist/ir/json-schema.js +0 -2
- package/dist/ir/json-schema.js.map +0 -1
- package/dist/ir/policies.d.ts +0 -74
- package/dist/ir/policies.d.ts.map +0 -1
- package/dist/ir/policies.js +0 -2
- package/dist/ir/policies.js.map +0 -1
- package/dist/schema/classify.d.ts +0 -8
- package/dist/schema/classify.d.ts.map +0 -1
- package/dist/schema/classify.js +0 -20
- package/dist/schema/classify.js.map +0 -1
- package/dist/schema/define.d.ts +0 -23
- package/dist/schema/define.d.ts.map +0 -1
- package/dist/schema/define.js +0 -58
- package/dist/schema/define.js.map +0 -1
- package/dist/schema/error.d.ts +0 -8
- package/dist/schema/error.d.ts.map +0 -1
- package/dist/schema/error.js +0 -14
- package/dist/schema/error.js.map +0 -1
- package/dist/schema/refs.d.ts +0 -77
- package/dist/schema/refs.d.ts.map +0 -1
- package/dist/schema/refs.js +0 -100
- package/dist/schema/refs.js.map +0 -1
- package/dist/schema/resolve/index.d.ts +0 -5
- package/dist/schema/resolve/index.d.ts.map +0 -1
- package/dist/schema/resolve/index.js +0 -5
- package/dist/schema/resolve/index.js.map +0 -1
- package/dist/schema/resolve/methods.d.ts +0 -8
- package/dist/schema/resolve/methods.d.ts.map +0 -1
- package/dist/schema/resolve/methods.js +0 -18
- package/dist/schema/resolve/methods.js.map +0 -1
- package/dist/schema/resolve/properties.d.ts +0 -13
- package/dist/schema/resolve/properties.d.ts.map +0 -1
- package/dist/schema/resolve/properties.js +0 -37
- package/dist/schema/resolve/properties.js.map +0 -1
- package/dist/schema/resolve/self.d.ts +0 -7
- package/dist/schema/resolve/self.d.ts.map +0 -1
- package/dist/schema/resolve/self.js +0 -33
- package/dist/schema/resolve/self.js.map +0 -1
- package/dist/schema/resolve/thunks.d.ts +0 -12
- package/dist/schema/resolve/thunks.d.ts.map +0 -1
- package/dist/schema/resolve/thunks.js +0 -37
- package/dist/schema/resolve/thunks.js.map +0 -1
- package/dist/schema/schema.d.ts +0 -25
- package/dist/schema/schema.d.ts.map +0 -1
- package/dist/schema/schema.js +0 -2
- package/dist/schema/schema.js.map +0 -1
- package/dist/schema/validators/context.d.ts +0 -17
- package/dist/schema/validators/context.d.ts.map +0 -1
- package/dist/schema/validators/context.js +0 -2
- package/dist/schema/validators/context.js.map +0 -1
- package/dist/schema/validators/endpoints.d.ts +0 -4
- package/dist/schema/validators/endpoints.d.ts.map +0 -1
- package/dist/schema/validators/endpoints.js +0 -27
- package/dist/schema/validators/endpoints.js.map +0 -1
- package/dist/schema/validators/index.d.ts +0 -12
- package/dist/schema/validators/index.d.ts.map +0 -1
- package/dist/schema/validators/index.js +0 -25
- package/dist/schema/validators/index.js.map +0 -1
- package/dist/schema/validators/indexes.d.ts +0 -4
- package/dist/schema/validators/indexes.d.ts.map +0 -1
- package/dist/schema/validators/indexes.js +0 -19
- package/dist/schema/validators/indexes.js.map +0 -1
- package/dist/schema/validators/inheritance.d.ts +0 -4
- package/dist/schema/validators/inheritance.d.ts.map +0 -1
- package/dist/schema/validators/inheritance.js +0 -27
- package/dist/schema/validators/inheritance.js.map +0 -1
- package/dist/schema/validators/methods.d.ts +0 -9
- package/dist/schema/validators/methods.d.ts.map +0 -1
- package/dist/schema/validators/methods.js +0 -44
- package/dist/schema/validators/methods.js.map +0 -1
- package/dist/schema/validators/names.d.ts +0 -4
- package/dist/schema/validators/names.d.ts.map +0 -1
- package/dist/schema/validators/names.js +0 -19
- package/dist/schema/validators/names.js.map +0 -1
- package/dist/schema/validators/policies.d.ts +0 -4
- package/dist/schema/validators/policies.d.ts.map +0 -1
- package/dist/schema/validators/policies.js +0 -61
- package/dist/schema/validators/policies.js.map +0 -1
- package/dist/schema/validators/ref-targets.d.ts +0 -4
- package/dist/schema/validators/ref-targets.d.ts.map +0 -1
- package/dist/schema/validators/ref-targets.js +0 -54
- package/dist/schema/validators/ref-targets.js.map +0 -1
- package/dist/serializer/context.d.ts +0 -35
- package/dist/serializer/context.d.ts.map +0 -1
- package/dist/serializer/context.js +0 -359
- package/dist/serializer/context.js.map +0 -1
- package/dist/serializer/helpers.d.ts +0 -34
- package/dist/serializer/helpers.d.ts.map +0 -1
- package/dist/serializer/helpers.js +0 -116
- package/dist/serializer/helpers.js.map +0 -1
- package/dist/serializer/index.d.ts +0 -2
- package/dist/serializer/index.d.ts.map +0 -1
- package/dist/serializer/index.js +0 -2
- package/dist/serializer/index.js.map +0 -1
- package/dist/serializer/policies.d.ts +0 -34
- package/dist/serializer/policies.d.ts.map +0 -1
- package/dist/serializer/policies.js +0 -837
- package/dist/serializer/policies.js.map +0 -1
- package/dist/serializer/policy-typing.d.ts +0 -56
- package/dist/serializer/policy-typing.d.ts.map +0 -1
- package/dist/serializer/policy-typing.js +0 -490
- package/dist/serializer/policy-typing.js.map +0 -1
- package/dist/serializer/serialize.d.ts +0 -12
- package/dist/serializer/serialize.d.ts.map +0 -1
- package/dist/serializer/serialize.js +0 -6
- package/dist/serializer/serialize.js.map +0 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type DiagnosticCode = 'CALLABLE_INPUT_FIELD_UNKNOWN' | 'DOMAIN_CLASS_ABSTRACT' | 'DOMAIN_PROPERTY_INPUT_INVALID' | 'DOMAIN_PROPERTY_REQUIRED' | 'DOMAIN_PROPERTY_UNKNOWN' | 'DOMAIN_VALIDATION_TARGET_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';
|
|
2
|
+
export interface Diagnostic<out Code extends DiagnosticCode = DiagnosticCode> {
|
|
3
|
+
readonly code: Code;
|
|
4
|
+
readonly pointer: string;
|
|
5
|
+
readonly message: string;
|
|
6
|
+
readonly ref?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function diagnostic<const Code extends DiagnosticCode>(code: Code, pointer: string, message: string, ref?: string): Diagnostic<Code>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/** Exact field constraints available for independent scalar route validation. */
|
|
2
|
+
export function inputFieldNodes(program) {
|
|
3
|
+
const fields = new Map();
|
|
4
|
+
const visited = new Set();
|
|
5
|
+
let closed = false;
|
|
6
|
+
let unsupported = false;
|
|
7
|
+
const visit = (index) => {
|
|
8
|
+
if (visited.has(index))
|
|
9
|
+
return;
|
|
10
|
+
visited.add(index);
|
|
11
|
+
const node = program.nodes[index];
|
|
12
|
+
if (node === undefined ||
|
|
13
|
+
node.schema === null ||
|
|
14
|
+
typeof node.schema !== 'object' ||
|
|
15
|
+
Array.isArray(node.schema))
|
|
16
|
+
return;
|
|
17
|
+
const schema = node.schema;
|
|
18
|
+
if (schema.additionalProperties === false || schema.unevaluatedProperties === false)
|
|
19
|
+
closed = true;
|
|
20
|
+
if (schema.anyOf !== undefined || schema.oneOf !== undefined || schema.if !== undefined)
|
|
21
|
+
unsupported = true;
|
|
22
|
+
if (node.reference !== undefined)
|
|
23
|
+
visit(node.reference);
|
|
24
|
+
if (Array.isArray(schema.allOf)) {
|
|
25
|
+
schema.allOf.forEach((_, position) => {
|
|
26
|
+
const child = node.children[`allOf/${position}`];
|
|
27
|
+
if (child === undefined)
|
|
28
|
+
throw new TypeError('Compiled input allOf branch is absent.');
|
|
29
|
+
visit(child);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
if (schema.properties === null ||
|
|
33
|
+
typeof schema.properties !== 'object' ||
|
|
34
|
+
Array.isArray(schema.properties))
|
|
35
|
+
return;
|
|
36
|
+
for (const name of Object.keys(schema.properties)) {
|
|
37
|
+
const child = node.children[`properties/${escapePointer(name)}`];
|
|
38
|
+
if (child === undefined)
|
|
39
|
+
throw new TypeError(`Compiled input field ${name} is absent.`);
|
|
40
|
+
const constraints = fields.get(name) ?? new Set();
|
|
41
|
+
constraints.add(child);
|
|
42
|
+
fields.set(name, constraints);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
visit(program.root);
|
|
46
|
+
if (!closed || unsupported)
|
|
47
|
+
return undefined;
|
|
48
|
+
return Object.freeze(Object.fromEntries([...fields]
|
|
49
|
+
.sort(([left], [right]) => compare(left, right))
|
|
50
|
+
.map(([name, nodes]) => [
|
|
51
|
+
name,
|
|
52
|
+
Object.freeze([...nodes].sort((left, right) => left - right)),
|
|
53
|
+
])));
|
|
54
|
+
}
|
|
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
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CompiledInstanceSchema } from '../evaluate/types.js';
|
|
2
|
+
import type { ValueProgram } from './model.js';
|
|
3
|
+
/** Bind admitted portable indices to the canonical instance evaluator. */
|
|
4
|
+
export declare function loadValueProgram(program: ValueProgram): CompiledInstanceSchema;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { loadPattern } from '../regexp/matcher.js';
|
|
2
|
+
import { appendPointer } from '../syntax/pointer.js';
|
|
3
|
+
/** Bind admitted portable indices to the canonical instance evaluator. */
|
|
4
|
+
export function loadValueProgram(program) {
|
|
5
|
+
const resource = { key: 'compiled', schema: true, ownerOrigin: 'compiled' };
|
|
6
|
+
const locations = program.nodes.map((node, index) => ({
|
|
7
|
+
key: String(index),
|
|
8
|
+
pointer: '',
|
|
9
|
+
resource,
|
|
10
|
+
schema: node.schema,
|
|
11
|
+
}));
|
|
12
|
+
const patterns = new Map(program.patterns.map((pattern) => [pattern.source, loadPattern(pattern)]));
|
|
13
|
+
const root = locations[program.root];
|
|
14
|
+
if (root === undefined)
|
|
15
|
+
throw new TypeError('Compiled value program root is absent.');
|
|
16
|
+
return {
|
|
17
|
+
root,
|
|
18
|
+
locations: new Map(locations.map((location) => [location.key, location])),
|
|
19
|
+
resolutions: new Map(),
|
|
20
|
+
program: () => program,
|
|
21
|
+
child(location, keyword, member) {
|
|
22
|
+
const base = appendPointer('', keyword);
|
|
23
|
+
const key = (member === undefined ? base : appendPointer(base, member)).slice(1);
|
|
24
|
+
const index = program.nodes[Number(location.key)]?.children[key];
|
|
25
|
+
const child = index === undefined ? undefined : locations[index];
|
|
26
|
+
if (child === undefined)
|
|
27
|
+
throw new TypeError('Compiled value program child is absent.');
|
|
28
|
+
return child;
|
|
29
|
+
},
|
|
30
|
+
reference(location) {
|
|
31
|
+
const index = program.nodes[Number(location.key)]?.reference;
|
|
32
|
+
return index === undefined ? undefined : locations[index];
|
|
33
|
+
},
|
|
34
|
+
matcher(source) {
|
|
35
|
+
const matcher = patterns.get(source);
|
|
36
|
+
if (matcher === undefined)
|
|
37
|
+
throw new TypeError('Compiled value program pattern is absent.');
|
|
38
|
+
return matcher;
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Value as JsonValue } from '@astrale-os/kernel-dsl/value';
|
|
2
|
+
export type ScalarRange = readonly [minimum: number, maximum: number];
|
|
3
|
+
export interface PatternTransition {
|
|
4
|
+
readonly to: number;
|
|
5
|
+
readonly ranges: readonly ScalarRange[];
|
|
6
|
+
}
|
|
7
|
+
export interface PatternState {
|
|
8
|
+
readonly epsilon: readonly number[];
|
|
9
|
+
readonly transitions: readonly PatternTransition[];
|
|
10
|
+
readonly accepting?: true;
|
|
11
|
+
}
|
|
12
|
+
export interface Pattern {
|
|
13
|
+
readonly source: string;
|
|
14
|
+
readonly start: number;
|
|
15
|
+
readonly states: readonly PatternState[];
|
|
16
|
+
}
|
|
17
|
+
export interface ValueNode {
|
|
18
|
+
readonly schema: JsonValue;
|
|
19
|
+
readonly children: Readonly<Record<string, number>>;
|
|
20
|
+
readonly reference?: number;
|
|
21
|
+
}
|
|
22
|
+
/** Portable, JSON-safe evaluation program for one admitted ValueSchema. */
|
|
23
|
+
export interface ValueProgram {
|
|
24
|
+
readonly root: number;
|
|
25
|
+
readonly nodes: readonly ValueNode[];
|
|
26
|
+
readonly patterns: readonly Pattern[];
|
|
27
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Value as JsonValue } from '@astrale-os/kernel-dsl/value';
|
|
2
|
+
export declare function matchesType(input: string, value: JsonValue): boolean;
|
|
3
|
+
export declare function jsonEqual(left: JsonValue, right: JsonValue): boolean;
|
|
4
|
+
export declare function unique(values: readonly JsonValue[]): boolean;
|
|
5
|
+
/** Compare finite JSON numbers as their exact ECMAScript decimal spellings. */
|
|
6
|
+
export declare function isMultipleOf(value: number, divisor: number): boolean;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { equal, json } from '@astrale-os/kernel-dsl/value';
|
|
2
|
+
import { isValueObject as isJsonObject } from '../model/object.js';
|
|
3
|
+
export function matchesType(input, value) {
|
|
4
|
+
switch (input) {
|
|
5
|
+
case 'null':
|
|
6
|
+
return value === null;
|
|
7
|
+
case 'boolean':
|
|
8
|
+
case 'number':
|
|
9
|
+
case 'string':
|
|
10
|
+
return typeof value === input;
|
|
11
|
+
case 'integer':
|
|
12
|
+
return typeof value === 'number' && Number.isInteger(value);
|
|
13
|
+
case 'array':
|
|
14
|
+
return Array.isArray(value);
|
|
15
|
+
case 'object':
|
|
16
|
+
return isJsonObject(value);
|
|
17
|
+
default:
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export function jsonEqual(left, right) {
|
|
22
|
+
return equal(left, right);
|
|
23
|
+
}
|
|
24
|
+
export function unique(values) {
|
|
25
|
+
const seen = new Set();
|
|
26
|
+
for (const value of values) {
|
|
27
|
+
const key = json.serialize(value);
|
|
28
|
+
if (seen.has(key))
|
|
29
|
+
return false;
|
|
30
|
+
seen.add(key);
|
|
31
|
+
}
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
/** Compare finite JSON numbers as their exact ECMAScript decimal spellings. */
|
|
35
|
+
export function isMultipleOf(value, divisor) {
|
|
36
|
+
if (!(divisor > 0))
|
|
37
|
+
return false;
|
|
38
|
+
const left = decimalInteger(value);
|
|
39
|
+
const right = decimalInteger(divisor);
|
|
40
|
+
const exponent = Math.min(left.exponent, right.exponent);
|
|
41
|
+
const dividend = left.coefficient * powerOfTen(left.exponent - exponent);
|
|
42
|
+
const factor = right.coefficient * powerOfTen(right.exponent - exponent);
|
|
43
|
+
return dividend % factor === 0n;
|
|
44
|
+
}
|
|
45
|
+
function decimalInteger(input) {
|
|
46
|
+
const source = input.toString().toLowerCase();
|
|
47
|
+
const [mantissa = '', exponentSource = '0'] = source.split('e');
|
|
48
|
+
const negative = mantissa.startsWith('-');
|
|
49
|
+
const unsigned = negative ? mantissa.slice(1) : mantissa;
|
|
50
|
+
const point = unsigned.indexOf('.');
|
|
51
|
+
const fractionDigits = point === -1 ? 0 : unsigned.length - point - 1;
|
|
52
|
+
const digits = unsigned.replace('.', '');
|
|
53
|
+
const coefficient = BigInt(`${negative ? '-' : ''}${digits}`);
|
|
54
|
+
return { coefficient, exponent: Number(exponentSource) - fractionDigits };
|
|
55
|
+
}
|
|
56
|
+
function powerOfTen(exponent) {
|
|
57
|
+
return 10n ** BigInt(exponent);
|
|
58
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Value as JsonValue } from '@astrale-os/kernel-dsl/value';
|
|
2
|
+
import type { CompiledInstanceSchema, Evaluation } from './types.js';
|
|
3
|
+
/** Evaluate complete Draft 2020-12 acceptance without dynamic source generation. */
|
|
4
|
+
export declare function evaluateInstance(compiled: CompiledInstanceSchema, input: JsonValue): Evaluation;
|
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
import { isInstantValue } from '../model/instant.js';
|
|
2
|
+
import { isValueObject as isJsonObject } from '../model/object.js';
|
|
3
|
+
import { appendPointer } from '../syntax/pointer.js';
|
|
4
|
+
import { isMultipleOf, jsonEqual, matchesType, unique } from './assertions.js';
|
|
5
|
+
import { evaluation, mergeAnnotations } from './types.js';
|
|
6
|
+
/** Evaluate complete Draft 2020-12 acceptance without dynamic source generation. */
|
|
7
|
+
export function evaluateInstance(compiled, input) {
|
|
8
|
+
return new InstanceEvaluator(compiled).evaluate(compiled.root, input, '');
|
|
9
|
+
}
|
|
10
|
+
class InstanceEvaluator {
|
|
11
|
+
compiled;
|
|
12
|
+
active = new Set();
|
|
13
|
+
constructor(compiled) {
|
|
14
|
+
this.compiled = compiled;
|
|
15
|
+
}
|
|
16
|
+
evaluate(location, input, instancePointer) {
|
|
17
|
+
const activeKey = `${location.key}\u0000${instancePointer}`;
|
|
18
|
+
if (this.active.has(activeKey)) {
|
|
19
|
+
throw new TypeError('Admitted value schema entered a non-productive evaluation cycle.');
|
|
20
|
+
}
|
|
21
|
+
this.active.add(activeKey);
|
|
22
|
+
try {
|
|
23
|
+
if (location.schema === true)
|
|
24
|
+
return evaluation();
|
|
25
|
+
if (location.schema === false) {
|
|
26
|
+
return evaluation([
|
|
27
|
+
invalid(instancePointer, 'false', 'The false schema rejects every value.'),
|
|
28
|
+
]);
|
|
29
|
+
}
|
|
30
|
+
return this.evaluateObjectSchema(location, location.schema, input, instancePointer);
|
|
31
|
+
}
|
|
32
|
+
finally {
|
|
33
|
+
this.active.delete(activeKey);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
evaluateObjectSchema(location, schema, input, instancePointer) {
|
|
37
|
+
const failures = [];
|
|
38
|
+
const properties = new Set();
|
|
39
|
+
const items = new Set();
|
|
40
|
+
const absorbSameLocation = (result) => {
|
|
41
|
+
if (result.valid)
|
|
42
|
+
mergeAnnotations(properties, items, result);
|
|
43
|
+
else
|
|
44
|
+
failures.push(...result.failures);
|
|
45
|
+
};
|
|
46
|
+
if (Object.hasOwn(schema, '$ref')) {
|
|
47
|
+
const target = this.compiled.reference(location);
|
|
48
|
+
if (target === undefined) {
|
|
49
|
+
throw new TypeError('Admitted value schema reference has no prepared resolution.');
|
|
50
|
+
}
|
|
51
|
+
absorbSameLocation(this.evaluate(target, input, instancePointer));
|
|
52
|
+
}
|
|
53
|
+
this.evaluateCompositions(location, schema, input, instancePointer, failures, properties, items);
|
|
54
|
+
this.evaluateCommonAssertions(schema, input, instancePointer, failures);
|
|
55
|
+
if (typeof input === 'number') {
|
|
56
|
+
this.evaluateNumberAssertions(schema, input, instancePointer, failures);
|
|
57
|
+
}
|
|
58
|
+
if (typeof input === 'string') {
|
|
59
|
+
this.evaluateStringAssertions(schema, input, instancePointer, failures);
|
|
60
|
+
}
|
|
61
|
+
if (Array.isArray(input)) {
|
|
62
|
+
this.evaluateArray(location, schema, input, instancePointer, failures, properties, items);
|
|
63
|
+
}
|
|
64
|
+
else if (isJsonObject(input)) {
|
|
65
|
+
this.evaluateObject(location, schema, input, instancePointer, failures, properties, items);
|
|
66
|
+
}
|
|
67
|
+
return evaluation(failures, properties, items);
|
|
68
|
+
}
|
|
69
|
+
evaluateCompositions(location, schema, input, instancePointer, failures, properties, items) {
|
|
70
|
+
const absorb = (result) => {
|
|
71
|
+
if (result.valid)
|
|
72
|
+
mergeAnnotations(properties, items, result);
|
|
73
|
+
else
|
|
74
|
+
failures.push(...result.failures);
|
|
75
|
+
};
|
|
76
|
+
const allOf = schemaList(schema.allOf);
|
|
77
|
+
allOf?.forEach((_, index) => {
|
|
78
|
+
absorb(this.evaluate(this.child(location, 'allOf', index), input, instancePointer));
|
|
79
|
+
});
|
|
80
|
+
const anyOf = schemaList(schema.anyOf);
|
|
81
|
+
if (anyOf !== undefined) {
|
|
82
|
+
const results = anyOf.map((_, index) => this.evaluate(this.child(location, 'anyOf', index), input, instancePointer));
|
|
83
|
+
const admitted = results.filter(({ valid }) => valid);
|
|
84
|
+
if (admitted.length === 0) {
|
|
85
|
+
failures.push(invalid(instancePointer, 'anyOf', 'Value satisfies no anyOf branch.'));
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
admitted.forEach((result) => mergeAnnotations(properties, items, result));
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const oneOf = schemaList(schema.oneOf);
|
|
92
|
+
if (oneOf !== undefined) {
|
|
93
|
+
const admitted = oneOf
|
|
94
|
+
.map((_, index) => this.evaluate(this.child(location, 'oneOf', index), input, instancePointer))
|
|
95
|
+
.filter(({ valid }) => valid);
|
|
96
|
+
if (admitted.length !== 1) {
|
|
97
|
+
failures.push(invalid(instancePointer, 'oneOf', 'Value must satisfy exactly one oneOf branch.'));
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
mergeAnnotations(properties, items, admitted[0]);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (isSchema(schema.not)) {
|
|
104
|
+
const result = this.evaluate(this.child(location, 'not'), input, instancePointer);
|
|
105
|
+
if (result.valid)
|
|
106
|
+
failures.push(invalid(instancePointer, 'not', 'Value satisfies not.'));
|
|
107
|
+
}
|
|
108
|
+
if (isSchema(schema.if)) {
|
|
109
|
+
const condition = this.evaluate(this.child(location, 'if'), input, instancePointer);
|
|
110
|
+
if (condition.valid)
|
|
111
|
+
mergeAnnotations(properties, items, condition);
|
|
112
|
+
const branch = condition.valid ? 'then' : 'else';
|
|
113
|
+
if (isSchema(schema[branch])) {
|
|
114
|
+
absorb(this.evaluate(this.child(location, branch), input, instancePointer));
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
evaluateCommonAssertions(schema, input, instancePointer, failures) {
|
|
119
|
+
if (schema['x-astrale-value-kind'] === 'instant' && !isInstantValue(input)) {
|
|
120
|
+
failures.push(invalid(instancePointer, 'x-astrale-value-kind', 'Value is not an exact UTC millisecond Instant.'));
|
|
121
|
+
}
|
|
122
|
+
if (typeof schema.type === 'string') {
|
|
123
|
+
if (!matchesType(schema.type, input)) {
|
|
124
|
+
failures.push(invalid(instancePointer, 'type', `Value is not of type ${schema.type}.`));
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
else if (Array.isArray(schema.type) &&
|
|
128
|
+
!schema.type.some((candidate) => typeof candidate === 'string' ? matchesType(candidate, input) : false)) {
|
|
129
|
+
failures.push(invalid(instancePointer, 'type', 'Value matches none of the admitted types.'));
|
|
130
|
+
}
|
|
131
|
+
if (Object.hasOwn(schema, 'const') && !jsonEqual(input, schema.const)) {
|
|
132
|
+
failures.push(invalid(instancePointer, 'const', 'Value differs from const.'));
|
|
133
|
+
}
|
|
134
|
+
if (Array.isArray(schema.enum) &&
|
|
135
|
+
!schema.enum.some((candidate) => jsonEqual(input, candidate))) {
|
|
136
|
+
failures.push(invalid(instancePointer, 'enum', 'Value is absent from enum.'));
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
evaluateNumberAssertions(schema, input, instancePointer, failures) {
|
|
140
|
+
if (typeof schema.multipleOf === 'number' && !isMultipleOf(input, schema.multipleOf)) {
|
|
141
|
+
failures.push(invalid(instancePointer, 'multipleOf', 'Number is not an exact multiple.'));
|
|
142
|
+
}
|
|
143
|
+
if (typeof schema.maximum === 'number' && input > schema.maximum) {
|
|
144
|
+
failures.push(invalid(instancePointer, 'maximum', 'Number exceeds maximum.'));
|
|
145
|
+
}
|
|
146
|
+
if (typeof schema.exclusiveMaximum === 'number' && input >= schema.exclusiveMaximum) {
|
|
147
|
+
failures.push(invalid(instancePointer, 'exclusiveMaximum', 'Number reaches exclusiveMaximum.'));
|
|
148
|
+
}
|
|
149
|
+
if (typeof schema.minimum === 'number' && input < schema.minimum) {
|
|
150
|
+
failures.push(invalid(instancePointer, 'minimum', 'Number is below minimum.'));
|
|
151
|
+
}
|
|
152
|
+
if (typeof schema.exclusiveMinimum === 'number' && input <= schema.exclusiveMinimum) {
|
|
153
|
+
failures.push(invalid(instancePointer, 'exclusiveMinimum', 'Number reaches exclusiveMinimum.'));
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
evaluateStringAssertions(schema, input, instancePointer, failures) {
|
|
157
|
+
const length = Array.from(input).length;
|
|
158
|
+
if (typeof schema.maxLength === 'number' && length > schema.maxLength) {
|
|
159
|
+
failures.push(invalid(instancePointer, 'maxLength', 'String exceeds maxLength.'));
|
|
160
|
+
}
|
|
161
|
+
if (typeof schema.minLength === 'number' && length < schema.minLength) {
|
|
162
|
+
failures.push(invalid(instancePointer, 'minLength', 'String is below minLength.'));
|
|
163
|
+
}
|
|
164
|
+
if (typeof schema.pattern === 'string' && !this.compiled.matcher(schema.pattern).test(input)) {
|
|
165
|
+
failures.push(invalid(instancePointer, 'pattern', 'String does not match pattern.'));
|
|
166
|
+
}
|
|
167
|
+
if (typeof schema.fullMatch === 'string' &&
|
|
168
|
+
!this.compiled.matcher(schema.fullMatch).matches(input)) {
|
|
169
|
+
failures.push(invalid(instancePointer, 'fullMatch', 'String does not match fullMatch.'));
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
evaluateArray(location, schema, input, instancePointer, failures, _properties, items) {
|
|
173
|
+
if (typeof schema.maxItems === 'number' && input.length > schema.maxItems) {
|
|
174
|
+
failures.push(invalid(instancePointer, 'maxItems', 'Array exceeds maxItems.'));
|
|
175
|
+
}
|
|
176
|
+
if (typeof schema.minItems === 'number' && input.length < schema.minItems) {
|
|
177
|
+
failures.push(invalid(instancePointer, 'minItems', 'Array is below minItems.'));
|
|
178
|
+
}
|
|
179
|
+
if (schema.uniqueItems === true && !unique(input)) {
|
|
180
|
+
failures.push(invalid(instancePointer, 'uniqueItems', 'Array items are not unique.'));
|
|
181
|
+
}
|
|
182
|
+
const prefixItems = schemaList(schema.prefixItems) ?? [];
|
|
183
|
+
const presentPrefix = Math.min(prefixItems.length, input.length);
|
|
184
|
+
let prefixValid = true;
|
|
185
|
+
for (let index = 0; index < presentPrefix; index++) {
|
|
186
|
+
const result = this.evaluate(this.child(location, 'prefixItems', index), input[index], appendPointer(instancePointer, index));
|
|
187
|
+
if (!result.valid) {
|
|
188
|
+
prefixValid = false;
|
|
189
|
+
failures.push(...result.failures);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
if (prefixValid) {
|
|
193
|
+
for (let index = 0; index < presentPrefix; index++)
|
|
194
|
+
items.add(index);
|
|
195
|
+
}
|
|
196
|
+
if (isSchema(schema.items)) {
|
|
197
|
+
let itemValid = true;
|
|
198
|
+
const admitted = [];
|
|
199
|
+
for (let index = prefixItems.length; index < input.length; index++) {
|
|
200
|
+
const result = this.evaluate(this.child(location, 'items'), input[index], appendPointer(instancePointer, index));
|
|
201
|
+
if (result.valid)
|
|
202
|
+
admitted.push(index);
|
|
203
|
+
else {
|
|
204
|
+
itemValid = false;
|
|
205
|
+
failures.push(...result.failures);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
if (itemValid)
|
|
209
|
+
admitted.forEach((index) => items.add(index));
|
|
210
|
+
}
|
|
211
|
+
if (isSchema(schema.contains)) {
|
|
212
|
+
const matches = [];
|
|
213
|
+
for (let index = 0; index < input.length; index++) {
|
|
214
|
+
const result = this.evaluate(this.child(location, 'contains'), input[index], appendPointer(instancePointer, index));
|
|
215
|
+
if (result.valid)
|
|
216
|
+
matches.push(index);
|
|
217
|
+
}
|
|
218
|
+
const minimum = typeof schema.minContains === 'number' ? schema.minContains : 1;
|
|
219
|
+
const maximum = typeof schema.maxContains === 'number' ? schema.maxContains : Number.POSITIVE_INFINITY;
|
|
220
|
+
if (matches.length < minimum || matches.length > maximum) {
|
|
221
|
+
failures.push(invalid(instancePointer, 'contains', 'Array has an invalid number of contains matches.'));
|
|
222
|
+
}
|
|
223
|
+
else {
|
|
224
|
+
matches.forEach((index) => items.add(index));
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
if (isSchema(schema.unevaluatedItems)) {
|
|
228
|
+
let valid = true;
|
|
229
|
+
const admitted = [];
|
|
230
|
+
for (let index = 0; index < input.length; index++) {
|
|
231
|
+
if (items.has(index))
|
|
232
|
+
continue;
|
|
233
|
+
const result = this.evaluate(this.child(location, 'unevaluatedItems'), input[index], appendPointer(instancePointer, index));
|
|
234
|
+
if (result.valid)
|
|
235
|
+
admitted.push(index);
|
|
236
|
+
else {
|
|
237
|
+
valid = false;
|
|
238
|
+
failures.push(...result.failures);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
if (valid)
|
|
242
|
+
admitted.forEach((index) => items.add(index));
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
evaluateObject(location, schema, input, instancePointer, failures, properties, _items) {
|
|
246
|
+
const names = Object.keys(input);
|
|
247
|
+
if (typeof schema.maxProperties === 'number' && names.length > schema.maxProperties) {
|
|
248
|
+
failures.push(invalid(instancePointer, 'maxProperties', 'Object exceeds maxProperties.'));
|
|
249
|
+
}
|
|
250
|
+
if (typeof schema.minProperties === 'number' && names.length < schema.minProperties) {
|
|
251
|
+
failures.push(invalid(instancePointer, 'minProperties', 'Object is below minProperties.'));
|
|
252
|
+
}
|
|
253
|
+
if (Array.isArray(schema.required)) {
|
|
254
|
+
for (const name of schema.required) {
|
|
255
|
+
if (typeof name === 'string' && !Object.hasOwn(input, name)) {
|
|
256
|
+
failures.push(invalid(instancePointer, 'required', `Object is missing required property ${name}.`));
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
if (isJsonObject(schema.dependentRequired)) {
|
|
261
|
+
for (const [name, required] of Object.entries(schema.dependentRequired)) {
|
|
262
|
+
if (!Object.hasOwn(input, name) || !Array.isArray(required))
|
|
263
|
+
continue;
|
|
264
|
+
for (const dependency of required) {
|
|
265
|
+
if (typeof dependency === 'string' && !Object.hasOwn(input, dependency)) {
|
|
266
|
+
failures.push(invalid(instancePointer, 'dependentRequired', `Property ${name} requires property ${dependency}.`));
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
const declared = isJsonObject(schema.properties) ? schema.properties : {};
|
|
272
|
+
const declaredPresent = Object.keys(declared).filter((name) => Object.hasOwn(input, name));
|
|
273
|
+
let declaredValid = true;
|
|
274
|
+
for (const name of declaredPresent) {
|
|
275
|
+
const result = this.evaluate(this.child(location, 'properties', name), input[name], appendPointer(instancePointer, name));
|
|
276
|
+
if (!result.valid) {
|
|
277
|
+
declaredValid = false;
|
|
278
|
+
failures.push(...result.failures);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
if (declaredValid)
|
|
282
|
+
declaredPresent.forEach((name) => properties.add(name));
|
|
283
|
+
const patterns = isJsonObject(schema.patternProperties) ? schema.patternProperties : {};
|
|
284
|
+
const patternMatched = new Set();
|
|
285
|
+
let patternsValid = true;
|
|
286
|
+
for (const pattern of Object.keys(patterns)) {
|
|
287
|
+
const matcher = this.compiled.matcher(pattern);
|
|
288
|
+
for (const name of names) {
|
|
289
|
+
if (!matcher.test(name))
|
|
290
|
+
continue;
|
|
291
|
+
patternMatched.add(name);
|
|
292
|
+
const result = this.evaluate(this.child(location, 'patternProperties', pattern), input[name], appendPointer(instancePointer, name));
|
|
293
|
+
if (!result.valid) {
|
|
294
|
+
patternsValid = false;
|
|
295
|
+
failures.push(...result.failures);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
if (patternsValid)
|
|
300
|
+
patternMatched.forEach((name) => properties.add(name));
|
|
301
|
+
if (isSchema(schema.additionalProperties)) {
|
|
302
|
+
const additional = names.filter((name) => !Object.hasOwn(declared, name) && !patternMatched.has(name));
|
|
303
|
+
let additionalValid = true;
|
|
304
|
+
for (const name of additional) {
|
|
305
|
+
const result = this.evaluate(this.child(location, 'additionalProperties'), input[name], appendPointer(instancePointer, name));
|
|
306
|
+
if (!result.valid) {
|
|
307
|
+
additionalValid = false;
|
|
308
|
+
failures.push(...result.failures);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
if (additionalValid)
|
|
312
|
+
additional.forEach((name) => properties.add(name));
|
|
313
|
+
}
|
|
314
|
+
if (isSchema(schema.propertyNames)) {
|
|
315
|
+
for (const name of names) {
|
|
316
|
+
const result = this.evaluate(this.child(location, 'propertyNames'), name, appendPointer(instancePointer, name));
|
|
317
|
+
if (!result.valid)
|
|
318
|
+
failures.push(...result.failures);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
if (isJsonObject(schema.dependentSchemas)) {
|
|
322
|
+
for (const name of Object.keys(schema.dependentSchemas)) {
|
|
323
|
+
if (!Object.hasOwn(input, name))
|
|
324
|
+
continue;
|
|
325
|
+
const result = this.evaluate(this.child(location, 'dependentSchemas', name), input, instancePointer);
|
|
326
|
+
if (result.valid)
|
|
327
|
+
mergeAnnotations(properties, new Set(), result);
|
|
328
|
+
else
|
|
329
|
+
failures.push(...result.failures);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
if (isSchema(schema.unevaluatedProperties)) {
|
|
333
|
+
const unevaluated = names.filter((name) => !properties.has(name));
|
|
334
|
+
let valid = true;
|
|
335
|
+
const admitted = [];
|
|
336
|
+
for (const name of unevaluated) {
|
|
337
|
+
const result = this.evaluate(this.child(location, 'unevaluatedProperties'), input[name], appendPointer(instancePointer, name));
|
|
338
|
+
if (result.valid)
|
|
339
|
+
admitted.push(name);
|
|
340
|
+
else {
|
|
341
|
+
valid = false;
|
|
342
|
+
failures.push(...result.failures);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
if (valid)
|
|
346
|
+
admitted.forEach((name) => properties.add(name));
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
child(parent, keyword, member) {
|
|
350
|
+
return this.compiled.child(parent, keyword, member);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
function schemaList(input) {
|
|
354
|
+
return Array.isArray(input) ? input : undefined;
|
|
355
|
+
}
|
|
356
|
+
function isSchema(input) {
|
|
357
|
+
return typeof input === 'boolean' || isJsonObject(input);
|
|
358
|
+
}
|
|
359
|
+
function invalid(instancePointer, keyword, message) {
|
|
360
|
+
return { instancePointer, keyword, message };
|
|
361
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { JsonSchema } from '../model/schema.js';
|
|
2
|
+
import type { ValueSchemaRegistry } from '../reference/registry.js';
|
|
3
|
+
import type { CompiledInstanceSchema } from './types.js';
|
|
4
|
+
export type InstanceSchemaCompilation = {
|
|
5
|
+
readonly compiled: true;
|
|
6
|
+
readonly value: CompiledInstanceSchema;
|
|
7
|
+
} | {
|
|
8
|
+
readonly compiled: false;
|
|
9
|
+
readonly message: string;
|
|
10
|
+
};
|
|
11
|
+
/** Prepare reference and linear-regexp state without generating executable source. */
|
|
12
|
+
export declare function prepareValueSchema(schema: JsonSchema, registry: ValueSchemaRegistry, pointer: string): InstanceSchemaCompilation;
|
|
13
|
+
export declare function childKey(pointer: string): string;
|