@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,258 @@
|
|
|
1
|
+
import { Key } from '../../../addressing/index.js';
|
|
2
|
+
import { definitionRefIndex } from '../../../addressing/ordering.js';
|
|
3
|
+
import { normalizePolicyChecks } from '../../../language/policy/normalization/normalize.js';
|
|
4
|
+
import { GRAPH_NODE_PATH_SCHEMA_ID } from '../../../language/value/syntax/node-path/schema.js';
|
|
5
|
+
import { MAX_BRANCHES, MAX_CHECK_DEPTH, MAX_CHECK_LEAVES, measureChecks } from './budgets.js';
|
|
6
|
+
import { escapePointer } from './context.js';
|
|
7
|
+
import { contractOfNodeDefinition } from './typing.js';
|
|
8
|
+
const formatDefinitionRef = Key.of;
|
|
9
|
+
const KERNEL_ORIGIN = 'kernel.astrale.ai';
|
|
10
|
+
const PROJECTION_CLASS = nodeClassRef('Class');
|
|
11
|
+
const PROJECTION_FUNCTION = nodeClassRef('Function');
|
|
12
|
+
const PROJECTION_POLICY = nodeClassRef('Policy');
|
|
13
|
+
const PROJECTION_VIEW = nodeClassRef('View');
|
|
14
|
+
export function validateReadUses(context, typing) {
|
|
15
|
+
for (const [name, declaration] of Object.entries(context.environment.candidate.classes)) {
|
|
16
|
+
if (declaration.kind !== 'node' || declaration.policies.read === undefined) {
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
const pointer = `/classes/${escapePointer(name)}/policies/read`;
|
|
20
|
+
const ref = declaration.policies.read;
|
|
21
|
+
if (!context.resolvePolicy(ref, pointer))
|
|
22
|
+
continue;
|
|
23
|
+
const object = {
|
|
24
|
+
kind: 'exact',
|
|
25
|
+
ref: { origin: context.environment.candidate.origin, kind: 'class', name },
|
|
26
|
+
};
|
|
27
|
+
if (!typing.policyAccepts(ref.name, object)) {
|
|
28
|
+
context.add('PL_USE', pointer, `${formatDefinitionRef(ref)} is not valid for every normalized branch of protected Class ${name}.`, formatDefinitionRef(ref));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export function validateTraverseUses(context, typing) {
|
|
33
|
+
for (const [name, declaration] of Object.entries(context.environment.candidate.classes)) {
|
|
34
|
+
const ref = declaration.policies.traverse;
|
|
35
|
+
if (ref === undefined)
|
|
36
|
+
continue;
|
|
37
|
+
const pointer = `/classes/${escapePointer(name)}/policies/traverse`;
|
|
38
|
+
if (!context.resolvePolicy(ref, pointer))
|
|
39
|
+
continue;
|
|
40
|
+
if (declaration.kind === 'node') {
|
|
41
|
+
const object = {
|
|
42
|
+
kind: 'exact',
|
|
43
|
+
ref: { origin: context.environment.candidate.origin, kind: 'class', name },
|
|
44
|
+
};
|
|
45
|
+
if (!typing.policyAccepts(ref.name, object)) {
|
|
46
|
+
context.add('PL_USE', pointer, `${formatDefinitionRef(ref)} is not valid for every normalized branch of traversed Node Class ${name}.`, formatDefinitionRef(ref));
|
|
47
|
+
}
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
const endpoints = declaration.orientation === 'directed'
|
|
51
|
+
? [declaration.endpoints.source, declaration.endpoints.target]
|
|
52
|
+
: declaration.endpoints;
|
|
53
|
+
const sources = typing.concreteEndpointClasses(endpoints[0].accepts);
|
|
54
|
+
const targets = typing.concreteEndpointClasses(endpoints[1].accepts);
|
|
55
|
+
let accepted = true;
|
|
56
|
+
for (const source of sources) {
|
|
57
|
+
for (const target of targets) {
|
|
58
|
+
if (!typing.policyAcceptsEdge(ref.name, { kind: 'exact', ref: source }, { kind: 'exact', ref: target })) {
|
|
59
|
+
accepted = false;
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (!accepted)
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
if (!accepted) {
|
|
67
|
+
context.add('PL_USE', pointer, `${formatDefinitionRef(ref)} is not valid for every concrete source/target pair of traversed Edge Class ${name}.`, formatDefinitionRef(ref));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
export function validateCallableUses(context, typing) {
|
|
72
|
+
for (const [name, declaration] of Object.entries(context.environment.candidate.functions)) {
|
|
73
|
+
if (declaration.policy === undefined)
|
|
74
|
+
continue;
|
|
75
|
+
validateChecks(context, typing, declaration.policy, {
|
|
76
|
+
pointer: `/functions/${escapePointer(name)}/policy`,
|
|
77
|
+
input: declaration.input,
|
|
78
|
+
instanceMethod: false,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
for (const [name, declaration] of Object.entries(context.environment.candidate.classes)) {
|
|
82
|
+
if (declaration.kind !== 'node')
|
|
83
|
+
continue;
|
|
84
|
+
validateDeclaredMethods(context, typing, 'classes', name, declaration.methods, {
|
|
85
|
+
origin: context.environment.candidate.origin,
|
|
86
|
+
kind: 'class',
|
|
87
|
+
name,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function validateDeclaredMethods(context, typing, namespace, name, methods, receiver) {
|
|
92
|
+
const ownerAnalysis = context.analysis.definitions.get(definitionRefIndex(receiver));
|
|
93
|
+
for (const [methodName, method] of Object.entries(methods)) {
|
|
94
|
+
if (method.policy === undefined)
|
|
95
|
+
continue;
|
|
96
|
+
// Definition analysis is the authority for the effective callable. A
|
|
97
|
+
// missing entry is already a definition diagnostic, so avoid inventing a
|
|
98
|
+
// second Policy interpretation for it.
|
|
99
|
+
if (ownerAnalysis !== undefined && !ownerAnalysis.methods.has(methodName))
|
|
100
|
+
continue;
|
|
101
|
+
validateChecks(context, typing, method.policy, {
|
|
102
|
+
pointer: `/${namespace}/${escapePointer(name)}/methods/${escapePointer(methodName)}/policy`,
|
|
103
|
+
input: method.input,
|
|
104
|
+
receiver,
|
|
105
|
+
instanceMethod: !method.static,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function validateChecks(validation, typing, expression, context) {
|
|
110
|
+
const normalized = normalizePolicyChecks(expression);
|
|
111
|
+
const measure = measureChecks(normalized);
|
|
112
|
+
if (measure.depth > MAX_CHECK_DEPTH ||
|
|
113
|
+
measure.branches > MAX_BRANCHES ||
|
|
114
|
+
measure.leaves > MAX_CHECK_LEAVES) {
|
|
115
|
+
validation.add('PL_BUDGET', context.pointer, `Callable checks require depth <= ${MAX_CHECK_DEPTH}, branches <= ${MAX_BRANCHES}, and leaves <= ${MAX_CHECK_LEAVES}; got ${measure.depth}, ${measure.branches}, ${measure.leaves}.`);
|
|
116
|
+
}
|
|
117
|
+
visitChecks(validation, typing, normalized, context, context.pointer);
|
|
118
|
+
}
|
|
119
|
+
function visitChecks(validation, typing, expression, context, pointer) {
|
|
120
|
+
if ('check' in expression) {
|
|
121
|
+
if (!validation.resolvePolicy(expression.check, `${pointer}/check`))
|
|
122
|
+
return;
|
|
123
|
+
const objectPointer = `${pointer}/object`;
|
|
124
|
+
const contracts = expression.object.kind === 'self'
|
|
125
|
+
? selfContracts(validation, context, objectPointer)
|
|
126
|
+
: expression.object.kind === 'input'
|
|
127
|
+
? inputContracts(validation, context, expression.object.field, objectPointer)
|
|
128
|
+
: referenceContracts(validation, expression.object.ref, objectPointer);
|
|
129
|
+
if (contracts === undefined)
|
|
130
|
+
return;
|
|
131
|
+
for (const contract of contracts) {
|
|
132
|
+
if (!typing.policyAccepts(expression.check.name, contract)) {
|
|
133
|
+
validation.add('PL_USE', pointer, `${formatDefinitionRef(expression.check)} is incompatible with the callable object contract.`, formatDefinitionRef(expression.check));
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
const { key, values } = checkOperands(expression);
|
|
140
|
+
if (values.length === 0) {
|
|
141
|
+
validation.add('PL_COMPOSITION', `${pointer}/${key}`, `${key} must be non-empty.`);
|
|
142
|
+
}
|
|
143
|
+
values.forEach((child, index) => visitChecks(validation, typing, child, context, `${pointer}/${key}/${index}`));
|
|
144
|
+
}
|
|
145
|
+
function referenceContracts(validation, ref, pointer) {
|
|
146
|
+
const candidate = validation.environment.candidate;
|
|
147
|
+
if (ref.origin !== candidate.origin)
|
|
148
|
+
return invalidPolicyObjectRef(validation, ref, pointer);
|
|
149
|
+
switch (ref.kind) {
|
|
150
|
+
case 'class': {
|
|
151
|
+
const resolved = validation.environment.resolve(ref);
|
|
152
|
+
return resolved?.ref.kind === ref.kind
|
|
153
|
+
? [{ kind: 'exact', ref: PROJECTION_CLASS }]
|
|
154
|
+
: invalidPolicyObjectRef(validation, ref, pointer);
|
|
155
|
+
}
|
|
156
|
+
case 'function':
|
|
157
|
+
return candidate.functions[ref.name] === undefined
|
|
158
|
+
? invalidPolicyObjectRef(validation, ref, pointer)
|
|
159
|
+
: [{ kind: 'exact', ref: PROJECTION_FUNCTION }];
|
|
160
|
+
case 'policy':
|
|
161
|
+
return candidate.policies[ref.name] === undefined
|
|
162
|
+
? invalidPolicyObjectRef(validation, ref, pointer)
|
|
163
|
+
: [{ kind: 'exact', ref: PROJECTION_POLICY }];
|
|
164
|
+
case 'view':
|
|
165
|
+
return candidate.views[ref.name] === undefined
|
|
166
|
+
? invalidPolicyObjectRef(validation, ref, pointer)
|
|
167
|
+
: [{ kind: 'exact', ref: PROJECTION_VIEW }];
|
|
168
|
+
case 'core': {
|
|
169
|
+
const node = candidate.core.nodes[ref.name];
|
|
170
|
+
if (node === undefined)
|
|
171
|
+
return invalidPolicyObjectRef(validation, ref, pointer);
|
|
172
|
+
const resolved = validation.environment.resolve(node.class);
|
|
173
|
+
const analyzed = validation.analysis.definitions.get(definitionRefIndex(node.class));
|
|
174
|
+
// Core validation owns invalid Core Class diagnostics. Avoid adding Policy noise for
|
|
175
|
+
// a Node that cannot materialize in the first place.
|
|
176
|
+
if (node.class.origin !== candidate.origin ||
|
|
177
|
+
resolved?.ref.kind !== 'class' ||
|
|
178
|
+
resolved.kind !== 'node' ||
|
|
179
|
+
analyzed === undefined) {
|
|
180
|
+
return undefined;
|
|
181
|
+
}
|
|
182
|
+
return [contractOfNodeDefinition(node.class)];
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return invalidPolicyObjectRef(validation, ref, pointer);
|
|
186
|
+
}
|
|
187
|
+
function invalidPolicyObjectRef(validation, ref, pointer) {
|
|
188
|
+
validation.add('PL_REF', `${pointer}/ref`, `${formatDefinitionRef(ref)} is not an exact local projected Policy object.`, formatDefinitionRef(ref));
|
|
189
|
+
return undefined;
|
|
190
|
+
}
|
|
191
|
+
function selfContracts(validation, context, pointer) {
|
|
192
|
+
if (!context.instanceMethod || context.receiver === undefined) {
|
|
193
|
+
validation.add('PL_USE', pointer, 'self is valid only for a Node instance Method.');
|
|
194
|
+
return undefined;
|
|
195
|
+
}
|
|
196
|
+
return [contractOfNodeDefinition(context.receiver)];
|
|
197
|
+
}
|
|
198
|
+
function inputContracts(validation, context, field, pointer) {
|
|
199
|
+
const input = asRecord(context.input);
|
|
200
|
+
const properties = asRecord(input?.properties);
|
|
201
|
+
const fieldSchema = asRecord(properties?.[field]);
|
|
202
|
+
const required = input?.required;
|
|
203
|
+
const rootValid = input?.type === 'object' &&
|
|
204
|
+
properties !== undefined &&
|
|
205
|
+
Array.isArray(required) &&
|
|
206
|
+
required.includes(field) &&
|
|
207
|
+
input.additionalProperties === false &&
|
|
208
|
+
!hasCombinator(input);
|
|
209
|
+
const annotation = asRecord(fieldSchema?.['x-astrale-path']);
|
|
210
|
+
const fieldValid = rootValid &&
|
|
211
|
+
fieldSchema?.$ref === GRAPH_NODE_PATH_SCHEMA_ID &&
|
|
212
|
+
!hasCombinator(fieldSchema) &&
|
|
213
|
+
annotation?.target === 'node' &&
|
|
214
|
+
annotation.cardinality === 'one' &&
|
|
215
|
+
Array.isArray(annotation.accepts) &&
|
|
216
|
+
annotation.accepts.length > 0;
|
|
217
|
+
if (!fieldValid) {
|
|
218
|
+
validation.add('PL_USE', pointer, `input.${field} must be one direct required single-Node x-astrale-path field of a closed object input.`);
|
|
219
|
+
return undefined;
|
|
220
|
+
}
|
|
221
|
+
const contracts = [];
|
|
222
|
+
for (const ref of annotation.accepts) {
|
|
223
|
+
if (!isDefinitionRef(ref)) {
|
|
224
|
+
validation.add('PL_USE', pointer, `input.${field} has a non-Node acceptance ref.`);
|
|
225
|
+
return undefined;
|
|
226
|
+
}
|
|
227
|
+
const resolved = validation.environment.resolve(ref);
|
|
228
|
+
if (resolved === undefined || resolved.ref.kind !== 'class' || resolved.kind !== 'node') {
|
|
229
|
+
validation.add('PL_USE', pointer, `input.${field} ref ${formatDefinitionRef(ref)} does not resolve as an allowed Node Definition.`, formatDefinitionRef(ref));
|
|
230
|
+
return undefined;
|
|
231
|
+
}
|
|
232
|
+
contracts.push(contractOfNodeDefinition(ref));
|
|
233
|
+
}
|
|
234
|
+
return contracts;
|
|
235
|
+
}
|
|
236
|
+
function asRecord(value) {
|
|
237
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value)
|
|
238
|
+
? value
|
|
239
|
+
: undefined;
|
|
240
|
+
}
|
|
241
|
+
function hasCombinator(value) {
|
|
242
|
+
return ['allOf', 'anyOf', 'oneOf', 'not', 'if', 'then', 'else'].some((key) => Object.hasOwn(value, key));
|
|
243
|
+
}
|
|
244
|
+
function isDefinitionRef(value) {
|
|
245
|
+
const record = asRecord(value);
|
|
246
|
+
return (record !== undefined &&
|
|
247
|
+
typeof record.origin === 'string' &&
|
|
248
|
+
record.kind === 'class' &&
|
|
249
|
+
typeof record.name === 'string');
|
|
250
|
+
}
|
|
251
|
+
function checkOperands(value) {
|
|
252
|
+
return 'allOf' in value
|
|
253
|
+
? { key: 'allOf', values: value.allOf }
|
|
254
|
+
: { key: 'anyOf', values: value.anyOf };
|
|
255
|
+
}
|
|
256
|
+
function nodeClassRef(name) {
|
|
257
|
+
return { origin: KERNEL_ORIGIN, kind: 'class', name };
|
|
258
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { DefinitionAnalysisResult } from '../../analysis/class.js';
|
|
2
|
+
import type { SchemaDiagnostic } from '../../diagnostic.js';
|
|
3
|
+
import type { DomainResolutionContext } from '../../resolution/context.js';
|
|
4
|
+
/**
|
|
5
|
+
* Validates the closed V1 Policy language after structural parsing.
|
|
6
|
+
*
|
|
7
|
+
* This pass is deliberately backend-independent and never throws for semantic
|
|
8
|
+
* failure. Environment and definition diagnostics are owned by their respective
|
|
9
|
+
* validators and are therefore not repeated here.
|
|
10
|
+
*/
|
|
11
|
+
export declare function validatePolicies(environment: DomainResolutionContext, analysis: DefinitionAnalysisResult): readonly SchemaDiagnostic[];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { validatePolicyBudgets } from './budgets.js';
|
|
2
|
+
import { PolicyValidationContext } from './context.js';
|
|
3
|
+
import { validatePolicyReferences } from './references.js';
|
|
4
|
+
import { PolicyTyping } from './typing.js';
|
|
5
|
+
import { validateCallableUses, validateReadUses, validateTraverseUses } from './uses.js';
|
|
6
|
+
/**
|
|
7
|
+
* Validates the closed V1 Policy language after structural parsing.
|
|
8
|
+
*
|
|
9
|
+
* This pass is deliberately backend-independent and never throws for semantic
|
|
10
|
+
* failure. Environment and definition diagnostics are owned by their respective
|
|
11
|
+
* validators and are therefore not repeated here.
|
|
12
|
+
*/
|
|
13
|
+
export function validatePolicies(environment, analysis) {
|
|
14
|
+
const context = new PolicyValidationContext(environment, analysis);
|
|
15
|
+
validatePolicyReferences(context);
|
|
16
|
+
validatePolicyBudgets(context);
|
|
17
|
+
const typing = new PolicyTyping(context);
|
|
18
|
+
typing.validatePolicies();
|
|
19
|
+
validateReadUses(context, typing);
|
|
20
|
+
validateTraverseUses(context, typing);
|
|
21
|
+
validateCallableUses(context, typing);
|
|
22
|
+
return Object.freeze(context.diagnostics);
|
|
23
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** The exact V1 value-schema grammar embedded in DomainSchema declarations. */
|
|
2
|
+
import type { Diagnostic } from '../../language/validation/diagnostic.js';
|
|
3
|
+
import type { JsonSchema } from '../../language/value/model/schema.js';
|
|
4
|
+
import type { OrderingKind } from '../../language/value/ordering.js';
|
|
5
|
+
import type { DomainSchema } from '../model/schema.js';
|
|
6
|
+
export { VALUE_SCHEMA_DIALECT as DIALECT, VALUE_SCHEMA_VOCABULARY as VOCABULARY, } from '../../language/value/model/schema.js';
|
|
7
|
+
export type { JsonSchema as Schema, JsonSchemaObject as SchemaObject, PathAnnotation, PropertyObjectSchema as PropertySchema, ValueSchemaContext as Context, } from '../../language/value/model/schema.js';
|
|
8
|
+
export { instant } from '../../language/value/model/instant.js';
|
|
9
|
+
export type { OrderingKind } from '../../language/value/ordering.js';
|
|
10
|
+
/** Validate one complete JSON value under the exact accepted schema that owns the contract. */
|
|
11
|
+
export declare function validate(owner: DomainSchema, contract: JsonSchema, input: unknown, pointer?: string): readonly Diagnostic[];
|
|
12
|
+
/** Return the one portable scalar ordering domain admitted by a property schema, if any. */
|
|
13
|
+
export declare function classifyOrdering(owner: DomainSchema, contract: JsonSchema): OrderingKind | undefined;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** The exact V1 value-schema grammar embedded in DomainSchema declarations. */
|
|
2
|
+
import { validateJsonInstance } from '../../language/value/evaluate/validate.js';
|
|
3
|
+
import { classifyOrdering as classifyOrderingWithRegistry } from '../../language/value/ordering.js';
|
|
4
|
+
import { createDomainValueSchemaRegistry } from '../resolution/value.registry.js';
|
|
5
|
+
const registries = new WeakMap();
|
|
6
|
+
export { VALUE_SCHEMA_DIALECT as DIALECT, VALUE_SCHEMA_VOCABULARY as VOCABULARY, } from '../../language/value/model/schema.js';
|
|
7
|
+
export { instant } from '../../language/value/model/instant.js';
|
|
8
|
+
/** Validate one complete JSON value under the exact accepted schema that owns the contract. */
|
|
9
|
+
export function validate(owner, contract, input, pointer = '') {
|
|
10
|
+
return validateJsonInstance(contract, input, registryFor(owner), pointer);
|
|
11
|
+
}
|
|
12
|
+
/** Return the one portable scalar ordering domain admitted by a property schema, if any. */
|
|
13
|
+
export function classifyOrdering(owner, contract) {
|
|
14
|
+
return classifyOrderingWithRegistry(contract, registryFor(owner));
|
|
15
|
+
}
|
|
16
|
+
function registryFor(owner) {
|
|
17
|
+
let registry = registries.get(owner);
|
|
18
|
+
if (registry === undefined) {
|
|
19
|
+
registry = createDomainValueSchemaRegistry(owner);
|
|
20
|
+
registries.set(owner, registry);
|
|
21
|
+
}
|
|
22
|
+
return registry;
|
|
23
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ValueSchemaRegistry } from '../../language/value/reference/registry.js';
|
|
2
|
+
import type { SchemaDiagnostic } from '../diagnostic.js';
|
|
3
|
+
import type { DomainSchemaIR } from '../model/schema.js';
|
|
4
|
+
export declare function validateEmbeddedValueSchemas(schema: DomainSchemaIR, registry: ValueSchemaRegistry): readonly SchemaDiagnostic[];
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { validateValueSchema } from '../../language/value/profile/validate.js';
|
|
2
|
+
import { diagnostic } from '../diagnostic.js';
|
|
3
|
+
export function validateEmbeddedValueSchemas(schema, registry) {
|
|
4
|
+
const diagnostics = [];
|
|
5
|
+
for (const [name, declaration] of Object.entries(schema.classes)) {
|
|
6
|
+
validateDefinition(declaration, `/classes/${escapePointer(name)}`, registry, diagnostics);
|
|
7
|
+
}
|
|
8
|
+
for (const [name, declaration] of Object.entries(schema.functions)) {
|
|
9
|
+
validateCallable(declaration, `/functions/${escapePointer(name)}`, registry, diagnostics);
|
|
10
|
+
}
|
|
11
|
+
return Object.freeze(diagnostics);
|
|
12
|
+
}
|
|
13
|
+
function validateDefinition(declaration, pointer, registry, diagnostics) {
|
|
14
|
+
for (const [name, property] of Object.entries(declaration.properties)) {
|
|
15
|
+
validate(property.schema, 'property-facet', `${pointer}/properties/${escapePointer(name)}/schema`, registry, diagnostics);
|
|
16
|
+
}
|
|
17
|
+
if ('methods' in declaration) {
|
|
18
|
+
for (const [name, method] of Object.entries(declaration.methods)) {
|
|
19
|
+
validateCallable(method, `${pointer}/methods/${escapePointer(name)}`, registry, diagnostics);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function validateCallable(declaration, pointer, registry, diagnostics) {
|
|
24
|
+
validate(declaration.input, 'callable-input', `${pointer}/input`, registry, diagnostics);
|
|
25
|
+
if (declaration.output.mode === 'value') {
|
|
26
|
+
validate(declaration.output.schema, 'callable-output', `${pointer}/output/schema`, registry, diagnostics);
|
|
27
|
+
}
|
|
28
|
+
else if (declaration.output.mode === 'stream') {
|
|
29
|
+
validate(declaration.output.item, 'callable-output', `${pointer}/output/item`, registry, diagnostics);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function validate(schema, context, pointer, registry, diagnostics) {
|
|
33
|
+
for (const failure of validateValueSchema(schema, context, registry, pointer)) {
|
|
34
|
+
diagnostics.push(diagnostic('DV_VALUE_SCHEMA', failure.pointer, `[${failure.code}] ${failure.message}`, failure.ref));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function escapePointer(value) {
|
|
38
|
+
return value.replaceAll('~', '~0').replaceAll('/', '~1');
|
|
39
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Key } from '../../addressing/key.js';
|
|
2
|
+
import { diagnostic } from '../diagnostic.js';
|
|
3
|
+
const formatDefinitionRef = Key.of;
|
|
4
|
+
export function validateViews(environment) {
|
|
5
|
+
const diagnostics = [];
|
|
6
|
+
for (const [name, view] of Object.entries(environment.candidate.views)) {
|
|
7
|
+
const pointer = `/views/${escapePointer(name)}`;
|
|
8
|
+
const ref = { origin: environment.candidate.origin, kind: 'view', name };
|
|
9
|
+
if (!sameRef(view.ref, ref)) {
|
|
10
|
+
diagnostics.push(diagnostic('DV_REF_RESOLVES', `${pointer}/ref`, `View ref must be exactly ${formatDefinitionRef(ref)}.`, formatDefinitionRef(view.ref)));
|
|
11
|
+
}
|
|
12
|
+
if (view.target.kind === 'definition') {
|
|
13
|
+
view.target.definitions.forEach((ref, index) => validateDefinitionTarget(environment, ref, `${pointer}/target/definitions/${index}`, diagnostics));
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return Object.freeze(diagnostics);
|
|
17
|
+
}
|
|
18
|
+
function sameRef(left, right) {
|
|
19
|
+
return left.origin === right.origin && left.kind === right.kind && left.name === right.name;
|
|
20
|
+
}
|
|
21
|
+
function validateDefinitionTarget(environment, ref, pointer, diagnostics) {
|
|
22
|
+
const target = environment.resolve(ref);
|
|
23
|
+
if (target === undefined || target.ref.kind !== 'class' || target.kind !== 'node') {
|
|
24
|
+
diagnostics.push(diagnostic('DV_VIEW_TARGET', pointer, `Definition target ${formatDefinitionRef(ref)} does not resolve to a Node Class.`, formatDefinitionRef(ref)));
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function escapePointer(value) {
|
|
28
|
+
return value.replaceAll('~', '~0').replaceAll('/', '~1');
|
|
29
|
+
}
|
package/dist/v1.d.ts
ADDED
package/dist/v1.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Value } from './types.js';
|
|
2
|
+
import { type Options } from './limits.js';
|
|
3
|
+
/**
|
|
4
|
+
* Admit an unknown host value and return a detached portable snapshot.
|
|
5
|
+
*
|
|
6
|
+
* Every source property is obtained from one descriptor snapshot. Accessors are never invoked.
|
|
7
|
+
*/
|
|
8
|
+
export declare function accept(input: unknown, options?: Options): Value;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { BoundaryError } from './error.js';
|
|
2
|
+
import { limitsFor } from './limits.js';
|
|
3
|
+
import { assertHostString } from './unicode.js';
|
|
4
|
+
/**
|
|
5
|
+
* Admit an unknown host value and return a detached portable snapshot.
|
|
6
|
+
*
|
|
7
|
+
* Every source property is obtained from one descriptor snapshot. Accessors are never invoked.
|
|
8
|
+
*/
|
|
9
|
+
export function accept(input, options) {
|
|
10
|
+
const state = { active: new WeakSet(), limits: limitsFor(options), members: 0 };
|
|
11
|
+
try {
|
|
12
|
+
return admit(input, '', 0, state);
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
if (error instanceof BoundaryError)
|
|
16
|
+
throw error;
|
|
17
|
+
throw new BoundaryError('VALUE_REFLECTION', 'Host reflection failed while admitting a portable value', '', { cause: error });
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function admit(input, pointer, depth, state) {
|
|
21
|
+
if (input === null || typeof input === 'boolean')
|
|
22
|
+
return input;
|
|
23
|
+
if (typeof input === 'number') {
|
|
24
|
+
if (!Number.isFinite(input)) {
|
|
25
|
+
throw new BoundaryError('VALUE_NUMBER', 'Expected a finite IEEE-754 binary64 number', pointer);
|
|
26
|
+
}
|
|
27
|
+
if (Object.is(input, -0)) {
|
|
28
|
+
throw new BoundaryError('VALUE_NUMBER', 'Negative zero is outside portable JSON', pointer);
|
|
29
|
+
}
|
|
30
|
+
return input;
|
|
31
|
+
}
|
|
32
|
+
if (typeof input === 'string') {
|
|
33
|
+
assertHostString(input, pointer, state.limits.maxStringBytes);
|
|
34
|
+
return input;
|
|
35
|
+
}
|
|
36
|
+
if (typeof input !== 'object') {
|
|
37
|
+
throw new BoundaryError('VALUE_TYPE', 'Expected a portable value', pointer);
|
|
38
|
+
}
|
|
39
|
+
if (state.active.has(input)) {
|
|
40
|
+
throw new BoundaryError('VALUE_CYCLE', 'Cyclic object graphs are not portable values', pointer);
|
|
41
|
+
}
|
|
42
|
+
if (depth >= state.limits.maxDepth) {
|
|
43
|
+
throw new BoundaryError('VALUE_LIMIT', `Container depth exceeds the ${state.limits.maxDepth}-level limit`, pointer);
|
|
44
|
+
}
|
|
45
|
+
state.active.add(input);
|
|
46
|
+
try {
|
|
47
|
+
return reflect(() => Array.isArray(input), pointer, 'Cannot inspect the host value brand')
|
|
48
|
+
? admitArray(input, pointer, depth + 1, state)
|
|
49
|
+
: admitObject(input, pointer, depth + 1, state);
|
|
50
|
+
}
|
|
51
|
+
finally {
|
|
52
|
+
state.active.delete(input);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function admitArray(input, pointer, depth, state) {
|
|
56
|
+
const descriptors = reflect(() => Object.getOwnPropertyDescriptors(input), pointer, 'Cannot snapshot Array descriptors');
|
|
57
|
+
const keys = Reflect.ownKeys(descriptors);
|
|
58
|
+
const length = descriptorValue(descriptors, 'length');
|
|
59
|
+
if (!Number.isSafeInteger(length) || length < 0) {
|
|
60
|
+
throw new BoundaryError('VALUE_ARRAY', 'Expected a valid Array length', pointer);
|
|
61
|
+
}
|
|
62
|
+
const size = length;
|
|
63
|
+
addMembers(state, size, pointer);
|
|
64
|
+
if (keys.length !== size + 1 || keys.some((key) => typeof key === 'symbol')) {
|
|
65
|
+
throw new BoundaryError('VALUE_ARRAY', 'Expected a dense Array with no symbol or non-index properties', pointer);
|
|
66
|
+
}
|
|
67
|
+
const output = Array.from({ length: size }, () => null);
|
|
68
|
+
for (let index = 0; index < size; index += 1) {
|
|
69
|
+
const name = String(index);
|
|
70
|
+
const descriptor = ownDescriptor(descriptors, name);
|
|
71
|
+
if (descriptor === undefined || !descriptor.enumerable || !('value' in descriptor)) {
|
|
72
|
+
throw new BoundaryError('VALUE_ARRAY', 'Array elements must be enumerable data properties', child(pointer, name));
|
|
73
|
+
}
|
|
74
|
+
output[index] = admit(descriptor.value, child(pointer, name), depth, state);
|
|
75
|
+
}
|
|
76
|
+
return output;
|
|
77
|
+
}
|
|
78
|
+
function admitObject(input, pointer, depth, state) {
|
|
79
|
+
const prototype = reflect(() => Object.getPrototypeOf(input), pointer, 'Cannot inspect Object prototype');
|
|
80
|
+
if (prototype !== null) {
|
|
81
|
+
const parent = reflect(() => Object.getPrototypeOf(prototype), pointer, 'Cannot inspect Object prototype chain');
|
|
82
|
+
if (parent !== null) {
|
|
83
|
+
throw new BoundaryError('VALUE_OBJECT', 'Expected a plain record-like Object', pointer);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
const descriptors = reflect(() => Object.getOwnPropertyDescriptors(input), pointer, 'Cannot snapshot Object descriptors');
|
|
87
|
+
const keys = Reflect.ownKeys(descriptors);
|
|
88
|
+
addMembers(state, keys.length, pointer);
|
|
89
|
+
const output = {};
|
|
90
|
+
for (const key of keys) {
|
|
91
|
+
if (typeof key === 'symbol') {
|
|
92
|
+
throw new BoundaryError('VALUE_OBJECT', 'Portable Objects cannot have symbol members', pointer);
|
|
93
|
+
}
|
|
94
|
+
const memberPointer = child(pointer, key);
|
|
95
|
+
assertHostString(key, memberPointer, state.limits.maxStringBytes);
|
|
96
|
+
const descriptor = ownDescriptor(descriptors, key);
|
|
97
|
+
if (descriptor === undefined || !descriptor.enumerable || !('value' in descriptor)) {
|
|
98
|
+
throw new BoundaryError('VALUE_OBJECT', 'Object members must be enumerable data properties', memberPointer);
|
|
99
|
+
}
|
|
100
|
+
Object.defineProperty(output, key, {
|
|
101
|
+
configurable: true,
|
|
102
|
+
enumerable: true,
|
|
103
|
+
value: admit(descriptor.value, memberPointer, depth, state),
|
|
104
|
+
writable: true,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
return output;
|
|
108
|
+
}
|
|
109
|
+
function descriptorValue(descriptors, name) {
|
|
110
|
+
return ownDescriptor(descriptors, name)?.value;
|
|
111
|
+
}
|
|
112
|
+
function ownDescriptor(descriptors, name) {
|
|
113
|
+
const holder = Object.getOwnPropertyDescriptor(descriptors, name);
|
|
114
|
+
return holder?.value;
|
|
115
|
+
}
|
|
116
|
+
function addMembers(state, count, pointer) {
|
|
117
|
+
state.members += count;
|
|
118
|
+
if (state.members > state.limits.maxMembers) {
|
|
119
|
+
throw new BoundaryError('VALUE_LIMIT', `Value exceeds the ${state.limits.maxMembers}-member limit`, pointer);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
function reflect(operation, pointer, message) {
|
|
123
|
+
try {
|
|
124
|
+
return operation();
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
throw new BoundaryError('VALUE_REFLECTION', message, pointer, { cause: error });
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
function child(pointer, token) {
|
|
131
|
+
return `${pointer}/${token.replaceAll('~', '~0').replaceAll('/', '~1')}`;
|
|
132
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { accept } from './accept.js';
|
|
2
|
+
import { BoundaryError } from './error.js';
|
|
3
|
+
import { limitsFor } from './limits.js';
|
|
4
|
+
import { utf8Length } from './unicode.js';
|
|
5
|
+
const encoder = new TextEncoder();
|
|
6
|
+
/** RFC 8785 canonical JSON for one admitted portable snapshot. */
|
|
7
|
+
export function serialize(input, options) {
|
|
8
|
+
const limits = limitsFor(options);
|
|
9
|
+
const output = serializeValue(accept(input, options));
|
|
10
|
+
if (utf8Length(output, limits.maxBytes) > limits.maxBytes) {
|
|
11
|
+
throw new BoundaryError('VALUE_LIMIT', `Canonical JSON exceeds the ${limits.maxBytes}-byte limit`);
|
|
12
|
+
}
|
|
13
|
+
return output;
|
|
14
|
+
}
|
|
15
|
+
export function encode(input, options) {
|
|
16
|
+
return encoder.encode(serialize(input, options));
|
|
17
|
+
}
|
|
18
|
+
function serializeValue(value) {
|
|
19
|
+
if (value === null)
|
|
20
|
+
return 'null';
|
|
21
|
+
switch (typeof value) {
|
|
22
|
+
case 'boolean':
|
|
23
|
+
return value ? 'true' : 'false';
|
|
24
|
+
case 'number':
|
|
25
|
+
case 'string':
|
|
26
|
+
return JSON.stringify(value);
|
|
27
|
+
case 'object':
|
|
28
|
+
return Array.isArray(value)
|
|
29
|
+
? `[${value.map(serializeValue).join(',')}]`
|
|
30
|
+
: serializeObject(value);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function serializeObject(value) {
|
|
34
|
+
return `{${Object.keys(value)
|
|
35
|
+
.sort(compareUtf16)
|
|
36
|
+
.map((key) => `${JSON.stringify(key)}:${serializeValue(value[key])}`)
|
|
37
|
+
.join(',')}}`;
|
|
38
|
+
}
|
|
39
|
+
function compareUtf16(left, right) {
|
|
40
|
+
return left < right ? -1 : left > right ? 1 : 0;
|
|
41
|
+
}
|