@astrale-os/kernel-dsl 1.0.0-beta.3 → 1.0.0-beta.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/v1/addressing/class-key.js +3 -3
- package/dist/v1/addressing/definition-ref.js +21 -37
- package/dist/v1/addressing/domain-dependency.d.ts +0 -6
- package/dist/v1/addressing/domain-dependency.js +1 -6
- package/dist/v1/addressing/key.d.ts +4 -1
- package/dist/v1/addressing/key.js +23 -3
- package/dist/v1/addressing/ordering.d.ts +2 -0
- package/dist/v1/addressing/ordering.js +2 -0
- package/dist/v1/addressing/patterns.d.ts +1 -1
- package/dist/v1/addressing/patterns.js +2 -6
- package/dist/v1/builder/callable/authoring.d.ts +11 -5
- package/dist/v1/builder/callable/authoring.js +2 -0
- package/dist/v1/builder/class/authoring.d.ts +94 -224
- package/dist/v1/builder/class/authoring.js +30 -35
- package/dist/v1/builder/class/handle.d.ts +27 -0
- package/dist/v1/builder/class/handle.js +1 -0
- package/dist/v1/builder/class/input.d.ts +159 -0
- package/dist/v1/builder/class/projection.d.ts +129 -0
- package/dist/v1/builder/class/projection.js +1 -0
- package/dist/v1/builder/class/property.d.ts +3 -9
- package/dist/v1/builder/class/property.js +1 -0
- package/dist/v1/builder/core/authoring.d.ts +1 -1
- package/dist/v1/builder/index.d.ts +10 -2
- package/dist/v1/builder/index.js +2 -0
- package/dist/v1/builder/lowering/callable.js +1 -0
- package/dist/v1/builder/lowering/class.d.ts +9 -1
- package/dist/v1/builder/lowering/class.js +62 -17
- package/dist/v1/builder/lowering/policy.js +6 -24
- package/dist/v1/builder/lowering/property-keys.d.ts +27 -0
- package/dist/v1/builder/lowering/property-keys.js +108 -0
- package/dist/v1/builder/lowering/schema/compile.js +13 -6
- package/dist/v1/builder/lowering/schema/context.d.ts +9 -1
- package/dist/v1/builder/lowering/schema/context.js +36 -7
- package/dist/v1/builder/lowering/schema/lifetime.d.ts +11 -0
- package/dist/v1/builder/lowering/schema/lifetime.js +55 -0
- package/dist/v1/builder/lowering/value/compile.js +29 -22
- package/dist/v1/builder/lowering/value/file.d.ts +7 -0
- package/dist/v1/builder/lowering/value/file.js +14 -0
- package/dist/v1/builder/lowering/value/path.d.ts +1 -1
- package/dist/v1/builder/lowering/value/path.js +2 -4
- package/dist/v1/builder/lowering/value/zod.js +41 -7
- package/dist/v1/builder/policy/authoring.d.ts +80 -9
- package/dist/v1/builder/policy/authoring.js +99 -68
- package/dist/v1/builder/policy/legacy/edge.d.ts +28 -0
- package/dist/v1/builder/policy/legacy/edge.js +16 -0
- package/dist/v1/builder/schema/define.d.ts +0 -1
- package/dist/v1/builder/schema/diagnostic.d.ts +3 -2
- package/dist/v1/builder/schema/diagnostic.js +5 -10
- package/dist/v1/builder/schema/input.d.ts +4 -1
- package/dist/v1/builder/schema/projection/callable.d.ts +7 -5
- package/dist/v1/builder/schema/projection/class.d.ts +78 -16
- package/dist/v1/builder/schema/projection/core-input.d.ts +2 -1
- package/dist/v1/builder/schema/projection/domain.d.ts +13 -2
- package/dist/v1/builder/schema/projection/identity.d.ts +74 -9
- package/dist/v1/builder/schema/projection/model.d.ts +4 -2
- package/dist/v1/builder/schema/projection/property.d.ts +38 -4
- package/dist/v1/builder/schema/projection/resolved-class.d.ts +5 -4
- package/dist/v1/builder/schema/projection.d.ts +1 -1
- package/dist/v1/builder/schema/rule.d.ts +316 -0
- package/dist/v1/builder/schema/rule.js +192 -0
- package/dist/v1/builder/value/file.d.ts +34 -0
- package/dist/v1/builder/value/file.js +77 -0
- package/dist/v1/builder/value/full-match.d.ts +0 -1
- package/dist/v1/builder/value/full-match.js +0 -1
- package/dist/v1/builder/value/path-metadata.d.ts +1 -1
- package/dist/v1/builder/value/path.d.ts +1 -1
- package/dist/v1/bundle/codec.js +55 -74
- package/dist/v1/bundle/diagnostic.d.ts +3 -1
- package/dist/v1/bundle/diagnostic.js +9 -7
- package/dist/v1/bundle/index.d.ts +2 -0
- package/dist/v1/bundle/index.js +1 -0
- package/dist/v1/bundle/model.js +1 -1
- package/dist/v1/bundle/rule.d.ts +14 -0
- package/dist/v1/bundle/rule.js +41 -0
- package/dist/v1/bundle/structure.js +6 -8
- package/dist/v1/compiled/admission/accept.js +9 -15
- package/dist/v1/compiled/admission/closure.js +17 -34
- package/dist/v1/compiled/admission/diagnostic.d.ts +23 -1
- package/dist/v1/compiled/admission/diagnostic.js +40 -3
- package/dist/v1/compiled/admission/revision.d.ts +9 -1
- package/dist/v1/compiled/admission/revision.js +7 -3
- package/dist/v1/compiled/admission/semantics/class.d.ts +4 -1
- package/dist/v1/compiled/admission/semantics/class.js +48 -19
- package/dist/v1/compiled/admission/semantics/core.d.ts +1 -24
- package/dist/v1/compiled/admission/semantics/core.js +56 -24
- package/dist/v1/compiled/admission/semantics/edge.d.ts +2 -4
- package/dist/v1/compiled/admission/semantics/edge.js +6 -65
- package/dist/v1/compiled/admission/semantics/policy/admit.js +4 -19
- package/dist/v1/compiled/admission/semantics/policy/callable.js +2 -5
- package/dist/v1/compiled/admission/semantics/policy/contracts.d.ts +5 -20
- package/dist/v1/compiled/admission/semantics/policy/contracts.js +8 -21
- package/dist/v1/compiled/admission/semantics/policy/parity.js +44 -53
- package/dist/v1/compiled/admission/semantics/policy/pattern.d.ts +4 -1
- package/dist/v1/compiled/admission/semantics/policy/pattern.js +7 -21
- package/dist/v1/compiled/admission/semantics/policy/typing.d.ts +2 -24
- package/dist/v1/compiled/admission/semantics/policy/typing.js +19 -201
- package/dist/v1/compiled/admission/wire/callable.d.ts +5 -2
- package/dist/v1/compiled/admission/wire/callable.js +24 -20
- package/dist/v1/compiled/admission/wire/class.js +79 -30
- package/dist/v1/compiled/admission/wire/entry.d.ts +1 -1
- package/dist/v1/compiled/admission/wire/entry.js +36 -13
- package/dist/v1/compiled/admission/wire/policy.d.ts +4 -3
- package/dist/v1/compiled/admission/wire/policy.js +27 -20
- package/dist/v1/compiled/admission/wire/program.d.ts +13 -3
- package/dist/v1/compiled/admission/wire/program.js +39 -44
- package/dist/v1/compiled/admission/wire/property.d.ts +4 -1
- package/dist/v1/compiled/admission/wire/property.js +8 -5
- package/dist/v1/compiled/admission/wire/value.d.ts +0 -2
- package/dist/v1/compiled/admission/wire/value.js +0 -7
- package/dist/v1/compiled/codec/json.js +4 -3
- package/dist/v1/compiled/compiler/compile.js +15 -33
- package/dist/v1/compiled/diagnostic.d.ts +1 -1
- package/dist/v1/compiled/diagnostic.js +2 -3
- package/dist/v1/compiled/index.d.ts +2 -0
- package/dist/v1/compiled/index.js +1 -0
- package/dist/v1/compiled/loader/load.d.ts +3 -2
- package/dist/v1/compiled/loader/load.js +13 -52
- package/dist/v1/compiled/model/schema.d.ts +3 -0
- package/dist/v1/compiled/rule.d.ts +49 -0
- package/dist/v1/compiled/rule.js +169 -0
- package/dist/v1/domain/create.js +9 -10
- package/dist/v1/domain/model/domain.d.ts +2 -7
- package/dist/v1/domain/model/input.d.ts +19 -10
- package/dist/v1/domain/namespace/member-collection.js +8 -7
- package/dist/v1/domain/projection/classes.js +11 -8
- package/dist/v1/domain/validation/create.d.ts +7 -16
- package/dist/v1/domain/validation/create.js +35 -81
- package/dist/v1/index.d.ts +5 -3
- package/dist/v1/index.js +1 -1
- package/dist/v1/language/.spec/schemas/draft-2020-12.schema.json +462 -0
- package/dist/v1/language/.spec/schemas/value-schema.schema.json +23 -0
- package/dist/v1/language/callable/admission.d.ts +15 -0
- package/dist/v1/language/callable/admission.js +44 -0
- package/dist/v1/language/callable/model/callable.d.ts +10 -0
- package/dist/v1/language/callable/resolved.d.ts +26 -5
- package/dist/v1/language/chain.d.ts +7 -0
- package/dist/v1/language/chain.js +24 -0
- package/dist/v1/language/class/inheritance.d.ts +36 -5
- package/dist/v1/language/class/inheritance.js +85 -1
- package/dist/v1/language/class/lifetime.d.ts +50 -11
- package/dist/v1/language/class/lifetime.js +89 -20
- package/dist/v1/language/class/model/class.d.ts +45 -9
- package/dist/v1/language/class/model/edge.d.ts +31 -2
- package/dist/v1/language/class/model/property.d.ts +16 -7
- package/dist/v1/language/class/property-values.js +2 -4
- package/dist/v1/language/class/resolved.d.ts +9 -4
- package/dist/v1/language/class/unique.d.ts +143 -0
- package/dist/v1/language/class/unique.js +264 -0
- package/dist/v1/language/core/facts.d.ts +85 -0
- package/dist/v1/language/core/facts.js +116 -0
- package/dist/v1/language/cycle.d.ts +10 -0
- package/dist/v1/language/cycle.js +30 -0
- package/dist/v1/language/definition/metadata.d.ts +38 -0
- package/dist/v1/language/definition/metadata.js +51 -0
- package/dist/v1/language/freeze.d.ts +5 -0
- package/dist/v1/{schema/canonical → language}/freeze.js +4 -0
- package/dist/v1/language/index.d.ts +7 -2
- package/dist/v1/language/index.js +5 -1
- package/dist/v1/language/limits.d.ts +83 -0
- package/dist/v1/language/limits.js +77 -0
- package/dist/v1/language/policy/analysis/branches.d.ts +8 -0
- package/dist/v1/language/policy/analysis/branches.js +8 -8
- package/dist/v1/language/policy/analysis/budgets.d.ts +45 -12
- package/dist/v1/language/policy/analysis/budgets.js +140 -20
- package/dist/v1/language/policy/analysis/checks.js +8 -6
- package/dist/v1/language/policy/analysis/composition.d.ts +4 -0
- package/dist/v1/language/policy/analysis/composition.js +11 -0
- package/dist/v1/language/policy/analysis/typing.d.ts +51 -0
- package/dist/v1/language/policy/analysis/typing.js +456 -0
- package/dist/v1/language/policy/model/policy.d.ts +71 -9
- package/dist/v1/language/policy/model/policy.js +42 -4
- package/dist/v1/language/policy/normalization/normalize.d.ts +6 -6
- package/dist/v1/language/policy/normalization/normalize.js +46 -68
- package/dist/v1/language/suspended.d.ts +7 -0
- package/dist/v1/language/suspended.js +23 -0
- package/dist/v1/language/validation/diagnostic.d.ts +15 -1
- package/dist/v1/language/validation/diagnostic.js +21 -0
- package/dist/v1/language/validation/rule.d.ts +45 -0
- package/dist/v1/language/validation/rule.js +109 -0
- package/dist/v1/language/value/compile/fields.js +16 -16
- package/dist/v1/language/value/compile/load.d.ts +5 -0
- package/dist/v1/language/value/compile/load.js +13 -0
- package/dist/v1/language/value/evaluate/assertions.d.ts +5 -1
- package/dist/v1/language/value/evaluate/assertions.js +19 -8
- package/dist/v1/language/value/evaluate/evaluator.js +117 -120
- package/dist/v1/language/value/evaluate/preparation.d.ts +16 -0
- package/dist/v1/language/value/evaluate/preparation.js +100 -47
- package/dist/v1/language/value/evaluate/program.d.ts +2 -1
- package/dist/v1/language/value/evaluate/program.js +6 -6
- package/dist/v1/language/value/evaluate/validate.d.ts +3 -3
- package/dist/v1/language/value/evaluate/validate.js +15 -11
- package/dist/v1/language/value/evaluate/validity.optimization.d.ts +14 -0
- package/dist/v1/language/value/evaluate/validity.optimization.js +338 -0
- package/dist/v1/language/value/files.d.ts +44 -0
- package/dist/v1/language/value/files.js +151 -0
- package/dist/v1/language/value/inclusion/arrays.d.ts +3 -0
- package/dist/v1/language/value/inclusion/arrays.js +85 -0
- package/dist/v1/language/value/inclusion/assertions.d.ts +18 -0
- package/dist/v1/language/value/inclusion/assertions.js +28 -0
- package/dist/v1/language/value/inclusion/combinators.d.ts +3 -0
- package/dist/v1/language/value/inclusion/combinators.js +67 -0
- package/dist/v1/language/value/inclusion/equivalence.d.ts +4 -0
- package/dist/v1/language/value/inclusion/equivalence.js +76 -0
- package/dist/v1/language/value/inclusion/evidence.d.ts +34 -0
- package/dist/v1/language/value/inclusion/evidence.js +140 -0
- package/dist/v1/language/value/inclusion/includes.d.ts +29 -3
- package/dist/v1/language/value/inclusion/includes.js +58 -723
- package/dist/v1/language/value/inclusion/keywords.d.ts +5 -0
- package/dist/v1/language/value/inclusion/keywords.js +31 -0
- package/dist/v1/language/value/inclusion/kinds.d.ts +17 -0
- package/dist/v1/language/value/inclusion/kinds.js +57 -0
- package/dist/v1/language/value/inclusion/location.d.ts +24 -0
- package/dist/v1/language/value/inclusion/location.js +66 -0
- package/dist/v1/language/value/inclusion/numbers.d.ts +3 -0
- package/dist/v1/language/value/inclusion/numbers.js +41 -0
- package/dist/v1/language/value/inclusion/objects.d.ts +3 -0
- package/dist/v1/language/value/inclusion/objects.js +190 -0
- package/dist/v1/language/value/inclusion/strings.d.ts +3 -0
- package/dist/v1/language/value/inclusion/strings.js +29 -0
- package/dist/v1/language/value/inclusion/types.d.ts +3 -0
- package/dist/v1/language/value/inclusion/types.js +34 -0
- package/dist/v1/language/value/model/blob.d.ts +6 -0
- package/dist/v1/language/value/model/blob.js +8 -0
- package/dist/v1/language/value/model/file.d.ts +41 -0
- package/dist/v1/language/value/model/file.js +122 -0
- package/dist/v1/language/value/ordering.d.ts +14 -0
- package/dist/v1/language/value/ordering.js +144 -77
- package/dist/v1/language/value/profile/canonicalize.d.ts +6 -1
- package/dist/v1/language/value/profile/canonicalize.js +67 -87
- package/dist/v1/language/value/profile/json.validate.d.ts +12 -0
- package/dist/v1/language/value/profile/json.validate.js +18 -5
- package/dist/v1/language/value/profile/meta-schema.compiled.d.ts +1 -0
- package/dist/v1/language/value/profile/meta-schema.compiled.js +21 -5
- package/dist/v1/language/value/profile/rules.js +27 -44
- package/dist/v1/language/value/profile/validate.js +1 -10
- package/dist/v1/language/value/profile/vocabulary.d.ts +36 -2
- package/dist/v1/language/value/profile/vocabulary.js +58 -5
- package/dist/v1/language/value/reference/closure.js +6 -6
- package/dist/v1/language/value/reference/recursion.js +9 -48
- package/dist/v1/language/value/reference/references.d.ts +3 -1
- package/dist/v1/language/value/reference/references.js +7 -7
- package/dist/v1/language/value/reference/registry.index.d.ts +2 -0
- package/dist/v1/language/value/reference/registry.index.js +33 -16
- package/dist/v1/language/value/regexp/ast.js +6 -7
- package/dist/v1/language/value/regexp/compile.d.ts +5 -11
- package/dist/v1/language/value/regexp/compile.js +14 -12
- package/dist/v1/language/value/regexp/syntax.js +3 -2
- package/dist/v1/language/value/regexp/unicode.d.ts +1 -1
- package/dist/v1/language/value/regexp/unicode.js +1 -1
- package/dist/v1/language/value/syntax/keywords.d.ts +3 -3
- package/dist/v1/language/value/syntax/keywords.js +4 -20
- package/dist/v1/language/value/syntax/node-path/validate.js +2 -3
- package/dist/v1/language/value/syntax/pointer.d.ts +2 -0
- package/dist/v1/language/value/syntax/pointer.js +5 -2
- package/dist/v1/language/value/syntax/walk.d.ts +9 -0
- package/dist/v1/language/value/syntax/walk.js +37 -20
- package/dist/v1/schema/.spec/schemas/domain-schema.schema.json +2596 -0
- package/dist/v1/schema/admission/accept.d.ts +3 -1
- package/dist/v1/schema/admission/accept.js +6 -14
- package/dist/v1/schema/admission/callable.d.ts +21 -0
- package/dist/v1/schema/admission/callable.js +96 -0
- package/dist/v1/schema/analysis/class.d.ts +4 -0
- package/dist/v1/schema/analysis/class.js +57 -17
- package/dist/v1/schema/canonical/revision.d.ts +4 -1
- package/dist/v1/schema/canonical/revision.js +8 -5
- package/dist/v1/schema/compatibility/api.d.ts +4 -1
- package/dist/v1/schema/compatibility/api.js +2 -0
- package/dist/v1/schema/compatibility/comparators/callables.js +1 -1
- package/dist/v1/schema/compatibility/comparators/classes.d.ts +9 -4
- package/dist/v1/schema/compatibility/comparators/classes.js +50 -29
- package/dist/v1/schema/compatibility/comparators/index.d.ts +1 -1
- package/dist/v1/schema/compatibility/comparators/members.js +1 -1
- package/dist/v1/schema/compatibility/comparators/values.js +2 -2
- package/dist/v1/schema/compatibility/context.d.ts +5 -2
- package/dist/v1/schema/compatibility/context.js +8 -6
- package/dist/v1/schema/compatibility/coordinate.js +3 -3
- package/dist/v1/schema/compatibility/diff.js +2 -4
- package/dist/v1/schema/compatibility/extension.d.ts +11 -0
- package/dist/v1/schema/compatibility/extension.js +22 -0
- package/dist/v1/schema/compatibility/fields.d.ts +20 -4
- package/dist/v1/schema/compatibility/fields.js +13 -3
- package/dist/v1/schema/compatibility/meaning/footprint.js +16 -51
- package/dist/v1/schema/compatibility/model.d.ts +17 -5
- package/dist/v1/schema/compatibility/references.d.ts +0 -3
- package/dist/v1/schema/compatibility/references.js +1 -9
- package/dist/v1/schema/compatibility/report.js +1 -1
- package/dist/v1/schema/compatibility/rule.d.ts +13 -0
- package/dist/v1/schema/compatibility/rule.js +23 -0
- package/dist/v1/schema/compatibility/scope.d.ts +2 -0
- package/dist/v1/schema/compatibility/scope.js +4 -1
- package/dist/v1/schema/compatibility/structure/index.js +6 -4
- package/dist/v1/schema/compatibility/structure/requirements.js +58 -61
- package/dist/v1/schema/compatibility/versioning/index.js +1 -1
- package/dist/v1/schema/compatibility/versioning/surface.d.ts +1 -1
- package/dist/v1/schema/compatibility/versioning/surface.js +30 -2
- package/dist/v1/schema/compatibility/walk.d.ts +17 -0
- package/dist/v1/schema/compatibility/walk.js +41 -0
- package/dist/v1/schema/diagnostic.d.ts +17 -3
- package/dist/v1/schema/diagnostic.js +14 -11
- package/dist/v1/schema/enforcement/changes.d.ts +590 -0
- package/dist/v1/schema/enforcement/changes.js +566 -0
- package/dist/v1/schema/enforcement/derived.d.ts +236 -0
- package/dist/v1/schema/enforcement/derived.js +243 -0
- package/dist/v1/schema/enforcement/dispose.d.ts +308 -0
- package/dist/v1/schema/enforcement/dispose.js +275 -0
- package/dist/v1/schema/enforcement/facts.d.ts +89 -0
- package/dist/v1/schema/enforcement/facts.js +70 -0
- package/dist/v1/schema/enforcement/fields.d.ts +65 -0
- package/dist/v1/schema/enforcement/fields.js +36 -0
- package/dist/v1/schema/enforcement/index.d.ts +39 -0
- package/dist/v1/schema/enforcement/index.js +10 -0
- package/dist/v1/schema/enforcement/install.d.ts +1634 -0
- package/dist/v1/schema/enforcement/install.js +1223 -0
- package/dist/v1/schema/enforcement/lifecycle.d.ts +87 -0
- package/dist/v1/schema/enforcement/lifecycle.js +91 -0
- package/dist/v1/schema/enforcement/model.d.ts +253 -0
- package/dist/v1/schema/enforcement/model.js +1 -0
- package/dist/v1/schema/enforcement/obligations.d.ts +248 -0
- package/dist/v1/schema/enforcement/obligations.js +240 -0
- package/dist/v1/schema/enforcement/write.d.ts +1314 -0
- package/dist/v1/schema/enforcement/write.js +1017 -0
- package/dist/v1/schema/index.d.ts +11 -1
- package/dist/v1/schema/index.js +5 -0
- package/dist/v1/schema/model/schema.d.ts +23 -1
- package/dist/v1/schema/model/schema.js +1 -1
- package/dist/v1/schema/normalization/domain.d.ts +2 -0
- package/dist/v1/schema/normalization/domain.js +50 -13
- package/dist/v1/schema/resolution/closure.js +2 -1
- package/dist/v1/schema/resolution/context.js +17 -18
- package/dist/v1/schema/resolution/domain.d.ts +5 -0
- package/dist/v1/schema/resolution/domain.js +6 -12
- package/dist/v1/schema/resolution/origins.js +6 -8
- package/dist/v1/schema/rule.d.ts +25 -0
- package/dist/v1/schema/rule.js +459 -0
- package/dist/v1/schema/validation/callable.d.ts +35 -2
- package/dist/v1/schema/validation/callable.js +65 -9
- package/dist/v1/schema/validation/class.d.ts +6 -2
- package/dist/v1/schema/validation/class.js +128 -105
- package/dist/v1/schema/validation/core.js +103 -173
- package/dist/v1/schema/validation/domain.js +25 -15
- package/dist/v1/schema/validation/domain.json-schema.d.ts +15 -0
- package/dist/v1/schema/validation/domain.json-schema.js +222 -0
- package/dist/v1/schema/validation/domain.route.d.ts +6 -1
- package/dist/v1/schema/validation/domain.route.js +18 -0
- package/dist/v1/schema/validation/domain.structure.d.ts +7797 -0
- package/dist/v1/schema/validation/domain.structure.js +516 -160
- package/dist/v1/schema/validation/icon.d.ts +4 -0
- package/dist/v1/schema/validation/icon.js +29 -0
- package/dist/v1/schema/validation/json.json-schema.d.ts +40 -0
- package/dist/v1/schema/validation/json.json-schema.js +46 -0
- package/dist/v1/schema/validation/policy/budgets.d.ts +37 -2
- package/dist/v1/schema/validation/policy/budgets.js +94 -121
- package/dist/v1/schema/validation/policy/context.d.ts +6 -5
- package/dist/v1/schema/validation/policy/context.js +7 -10
- package/dist/v1/schema/validation/policy/objects.d.ts +1 -1
- package/dist/v1/schema/validation/policy/objects.js +6 -14
- package/dist/v1/schema/validation/policy/references.js +20 -62
- package/dist/v1/schema/validation/policy/typing.d.ts +3 -18
- package/dist/v1/schema/validation/policy/typing.js +22 -356
- package/dist/v1/schema/validation/policy/uses.d.ts +40 -3
- package/dist/v1/schema/validation/policy/uses.js +63 -91
- package/dist/v1/schema/validation/policy/validate.js +5 -5
- package/dist/v1/schema/validation/value-api.d.ts +27 -1
- package/dist/v1/schema/validation/value-api.js +37 -2
- package/dist/v1/schema/validation/value.d.ts +3 -0
- package/dist/v1/schema/validation/value.js +9 -17
- package/dist/v1/schema/validation/value.json-schema.d.ts +54 -0
- package/dist/v1/schema/validation/value.json-schema.js +163 -0
- package/dist/v1/schema/validation/view.js +4 -8
- package/dist/value/accept.d.ts +9 -3
- package/dist/value/accept.js +25 -1
- package/dist/value/canonical.d.ts +22 -1
- package/dist/value/canonical.js +114 -21
- package/dist/value/decode.d.ts +7 -0
- package/dist/value/decode.js +159 -9
- package/dist/value/equal.d.ts +9 -1
- package/dist/value/equal.js +37 -3
- package/dist/value/immutable.optimization.d.ts +2 -0
- package/dist/value/immutable.optimization.js +4 -0
- package/dist/value/index.d.ts +5 -3
- package/dist/value/index.js +2 -1
- package/dist/value/json.d.ts +2 -2
- package/dist/value/json.js +2 -2
- package/dist/value/limits.d.ts +11 -0
- package/dist/value/rule.d.ts +12 -0
- package/dist/value/rule.js +50 -0
- package/dist/value/types.d.ts +6 -0
- package/dist/value/unicode.d.ts +2 -1
- package/dist/value/unicode.js +2 -0
- package/package.json +15 -4
- package/dist/v1/builder/lowering/core-properties.d.ts +0 -10
- package/dist/v1/builder/lowering/core-properties.js +0 -76
- package/dist/v1/compiled/admission/semantics/cardinality.d.ts +0 -5
- package/dist/v1/compiled/admission/semantics/cardinality.js +0 -113
- package/dist/v1/compiled/admission/semantics/policy/equality.d.ts +0 -8
- package/dist/v1/compiled/admission/semantics/policy/equality.js +0 -27
- package/dist/v1/compiled/admission/semantics/policy/measure.d.ts +0 -9
- package/dist/v1/compiled/admission/semantics/policy/measure.js +0 -81
- package/dist/v1/compiled/admission/semantics/policy/variants.d.ts +0 -10
- package/dist/v1/compiled/admission/semantics/policy/variants.js +0 -65
- package/dist/v1/compiled/admission/wire/pattern.d.ts +0 -12
- package/dist/v1/compiled/admission/wire/pattern.js +0 -111
- package/dist/v1/language/class/index.d.ts +0 -8
- package/dist/v1/language/class/index.js +0 -1
- package/dist/v1/language/core/index.d.ts +0 -2
- package/dist/v1/language/value/index.d.ts +0 -11
- package/dist/v1/language/value/index.js +0 -8
- package/dist/v1/schema/canonical/domain.d.ts +0 -3
- package/dist/v1/schema/canonical/domain.digest.d.ts +0 -3
- package/dist/v1/schema/canonical/domain.digest.js +0 -5
- package/dist/v1/schema/canonical/domain.js +0 -5
- package/dist/v1/schema/canonical/freeze.d.ts +0 -1
- /package/dist/v1/{language/core/index.js → builder/class/input.js} +0 -0
|
@@ -1,12 +1,14 @@
|
|
|
1
|
+
import { equalDefinitionRefs } from '../../addressing/definition-ref.js';
|
|
1
2
|
import { Key } from '../../addressing/key.js';
|
|
3
|
+
import { escapePointerToken } from '../../language/value/syntax/pointer.js';
|
|
2
4
|
import { diagnostic } from '../diagnostic.js';
|
|
3
5
|
const formatDefinitionRef = Key.of;
|
|
4
6
|
export function validateViews(environment) {
|
|
5
7
|
const diagnostics = [];
|
|
6
8
|
for (const [name, view] of Object.entries(environment.candidate.views)) {
|
|
7
|
-
const pointer = `/views/${
|
|
9
|
+
const pointer = `/views/${escapePointerToken(name)}`;
|
|
8
10
|
const ref = { origin: environment.candidate.origin, kind: 'view', name };
|
|
9
|
-
if (!
|
|
11
|
+
if (!equalDefinitionRefs(view.ref, ref)) {
|
|
10
12
|
diagnostics.push(diagnostic('DV_REF_RESOLVES', `${pointer}/ref`, `View ref must be exactly ${formatDefinitionRef(ref)}.`, formatDefinitionRef(view.ref)));
|
|
11
13
|
}
|
|
12
14
|
}
|
|
@@ -26,9 +28,3 @@ function validateEntrypoint(environment, diagnostics) {
|
|
|
26
28
|
diagnostics.push(diagnostic('DV_ENTRYPOINT', '/entrypoint', `Entrypoint ${formatDefinitionRef(entrypoint)} is not a Domain-targeted View of ${origin}.`, formatDefinitionRef(entrypoint)));
|
|
27
29
|
}
|
|
28
30
|
}
|
|
29
|
-
function sameRef(left, right) {
|
|
30
|
-
return left.origin === right.origin && left.kind === right.kind && left.name === right.name;
|
|
31
|
-
}
|
|
32
|
-
function escapePointer(value) {
|
|
33
|
-
return value.replaceAll('~', '~0').replaceAll('/', '~1');
|
|
34
|
-
}
|
package/dist/value/accept.d.ts
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
import type { Value } from './types.js';
|
|
2
|
-
import { type Options } from './limits.js';
|
|
2
|
+
import { type Options, type StructuralOptions } from './limits.js';
|
|
3
3
|
/**
|
|
4
4
|
* Admit an unknown host value and return a detached portable snapshot.
|
|
5
5
|
*
|
|
6
6
|
* Every source property is obtained from one descriptor snapshot. Accessors are never invoked.
|
|
7
7
|
*/
|
|
8
|
-
export declare function accept(input: unknown, options?:
|
|
8
|
+
export declare function accept(input: unknown, options?: StructuralOptions): Value;
|
|
9
9
|
/** Admit a canonically byte-bounded immutable snapshot; owned subtrees may be shared. */
|
|
10
10
|
export declare function acceptImmutable(input: unknown, options?: Options): Value;
|
|
11
11
|
/** Admit a read-only snapshot, sharing owned immutable subtrees without freezing new wrappers. */
|
|
12
|
-
export declare function acceptForRead(input: unknown, options?:
|
|
12
|
+
export declare function acceptForRead(input: unknown, options?: StructuralOptions): Value;
|
|
13
|
+
/**
|
|
14
|
+
* The total of a trusted Value's Object members and Array elements, which `maxMembers` limits,
|
|
15
|
+
* without admitting it: an admission-owned immutable root counted its total when it was admitted,
|
|
16
|
+
* and any other container is counted member by member.
|
|
17
|
+
*/
|
|
18
|
+
export declare function memberCount(input: Value): number;
|
|
13
19
|
/**
|
|
14
20
|
* Private PropertyValues owner seam. Retain immediate recursive values, not the enclosing
|
|
15
21
|
* dictionary: its canonical coordinates are re-admitted by the Property owner on every use.
|
package/dist/value/accept.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BoundaryError } from './error.js';
|
|
2
|
-
import { includeSnapshot, retainImmutableSnapshot, reusableSnapshot, } from './immutable.optimization.js';
|
|
2
|
+
import { immutableSnapshotMembers, includeSnapshot, retainImmutableSnapshot, reusableSnapshot, } from './immutable.optimization.js';
|
|
3
3
|
import { limitsFor } from './limits.js';
|
|
4
4
|
import { assertHostString, canonicalPrimitiveBytes } from './unicode.js';
|
|
5
5
|
/**
|
|
@@ -23,6 +23,30 @@ export function acceptImmutable(input, options) {
|
|
|
23
23
|
export function acceptForRead(input, options) {
|
|
24
24
|
return snapshot(input, options, 'read');
|
|
25
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* The total of a trusted Value's Object members and Array elements, which `maxMembers` limits,
|
|
28
|
+
* without admitting it: an admission-owned immutable root counted its total when it was admitted,
|
|
29
|
+
* and any other container is counted member by member.
|
|
30
|
+
*/
|
|
31
|
+
export function memberCount(input) {
|
|
32
|
+
let members = 0;
|
|
33
|
+
const pending = [input];
|
|
34
|
+
while (pending.length > 0) {
|
|
35
|
+
const next = pending.pop();
|
|
36
|
+
if (next === null || typeof next !== 'object')
|
|
37
|
+
continue;
|
|
38
|
+
const owned = immutableSnapshotMembers(next);
|
|
39
|
+
if (owned !== undefined) {
|
|
40
|
+
members += owned;
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
const items = Array.isArray(next) ? next : Object.values(next);
|
|
44
|
+
members += items.length;
|
|
45
|
+
for (const item of items)
|
|
46
|
+
pending.push(item);
|
|
47
|
+
}
|
|
48
|
+
return members;
|
|
49
|
+
}
|
|
26
50
|
/**
|
|
27
51
|
* Private PropertyValues owner seam. Retain immediate recursive values, not the enclosing
|
|
28
52
|
* dictionary: its canonical coordinates are re-admitted by the Property owner on every use.
|
|
@@ -1,7 +1,28 @@
|
|
|
1
|
-
import type { Value } from './types.js';
|
|
1
|
+
import type { Primitive, Value } from './types.js';
|
|
2
2
|
import { type Options } from './limits.js';
|
|
3
3
|
/** RFC 8785 canonical JSON for one admitted portable snapshot. */
|
|
4
4
|
export declare function serialize(input: unknown, options?: Options): string;
|
|
5
5
|
/** Serialize a trusted portable value whose default structural admission proof is still valid. */
|
|
6
6
|
export declare function serializeAdmitted(input: Value): string;
|
|
7
7
|
export declare function encode(input: unknown, options?: Options): Uint8Array;
|
|
8
|
+
/**
|
|
9
|
+
* The UTF-8 byte length of a trusted Value's canonical JSON, `encode(input).byteLength`, without
|
|
10
|
+
* serializing it: an admission-owned immutable root counted its bytes when it was admitted, and any
|
|
11
|
+
* other container is counted member by member.
|
|
12
|
+
*/
|
|
13
|
+
export declare function byteLength(input: Value): number;
|
|
14
|
+
/** The order of member names in canonical JSON: by UTF-16 code unit, the order `<` gives strings. */
|
|
15
|
+
export declare function compareCodeUnits(left: string, right: string): number;
|
|
16
|
+
declare const ARRAY: unique symbol;
|
|
17
|
+
declare const OBJECT: unique symbol;
|
|
18
|
+
declare const END: unique symbol;
|
|
19
|
+
export type CanonicalToken = Primitive | typeof ARRAY | typeof OBJECT | typeof END;
|
|
20
|
+
/**
|
|
21
|
+
* A trusted Value as the tokens of its canonical JSON, in order: each scalar and member name, and
|
|
22
|
+
* where each container starts and ends, with member names in `compareCodeUnits` order. Two values
|
|
23
|
+
* have the same tokens exactly when they have the same canonical JSON text, and no value's tokens
|
|
24
|
+
* are a prefix of another's. Admission bounded the value, so the reading checks no limit of its own,
|
|
25
|
+
* and it holds neither the text, which may outgrow any string, nor a stack frame per level.
|
|
26
|
+
*/
|
|
27
|
+
export declare function canonicalTokens(value: Value): Generator<CanonicalToken, void, undefined>;
|
|
28
|
+
export {};
|
package/dist/value/canonical.js
CHANGED
|
@@ -6,8 +6,8 @@ import { canonicalPrimitiveBytes, utf8Length } from './unicode.js';
|
|
|
6
6
|
const encoder = new TextEncoder();
|
|
7
7
|
/** RFC 8785 canonical JSON for one admitted portable snapshot. */
|
|
8
8
|
export function serialize(input, options) {
|
|
9
|
-
const
|
|
10
|
-
return serializeSnapshot(acceptForRead(input,
|
|
9
|
+
const { maxBytes, ...structure } = limitsFor(options);
|
|
10
|
+
return serializeSnapshot(acceptForRead(input, { limits: structure }), maxBytes);
|
|
11
11
|
}
|
|
12
12
|
/** Serialize a trusted portable value whose default structural admission proof is still valid. */
|
|
13
13
|
export function serializeAdmitted(input) {
|
|
@@ -31,27 +31,120 @@ function serializeSnapshot(input, maxBytes) {
|
|
|
31
31
|
export function encode(input, options) {
|
|
32
32
|
return encoder.encode(serialize(input, options));
|
|
33
33
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
34
|
+
/**
|
|
35
|
+
* The UTF-8 byte length of a trusted Value's canonical JSON, `encode(input).byteLength`, without
|
|
36
|
+
* serializing it: an admission-owned immutable root counted its bytes when it was admitted, and any
|
|
37
|
+
* other container is counted member by member.
|
|
38
|
+
*/
|
|
39
|
+
export function byteLength(input) {
|
|
40
|
+
if (input !== null && typeof input === 'object') {
|
|
41
|
+
const owned = immutableSnapshotBytes(input);
|
|
42
|
+
if (owned !== undefined)
|
|
43
|
+
return owned;
|
|
44
|
+
}
|
|
45
|
+
// As serializing it would, a Value beyond the default emitted-byte bound refuses.
|
|
46
|
+
const bytes = measure(input);
|
|
47
|
+
if (bytes > defaultLimits.maxBytes)
|
|
48
|
+
throw new BoundaryError('VALUE_LIMIT', `Canonical JSON exceeds the ${defaultLimits.maxBytes}-byte limit`);
|
|
49
|
+
return bytes;
|
|
50
|
+
}
|
|
51
|
+
/** The canonical JSON bytes of a trusted Value, counted member by member, owned roots at once. */
|
|
52
|
+
function measure(value) {
|
|
53
|
+
let bytes = 0;
|
|
54
|
+
const pending = [value];
|
|
55
|
+
while (pending.length > 0) {
|
|
56
|
+
const next = pending.pop();
|
|
57
|
+
if (next === null || typeof next !== 'object') {
|
|
58
|
+
bytes += canonicalPrimitiveBytes(next);
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
const owned = immutableSnapshotBytes(next);
|
|
62
|
+
if (owned !== undefined) {
|
|
63
|
+
bytes += owned;
|
|
64
|
+
}
|
|
65
|
+
else if (Array.isArray(next)) {
|
|
66
|
+
bytes += 2 + Math.max(0, next.length - 1);
|
|
67
|
+
for (const item of next)
|
|
68
|
+
pending.push(item);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
const names = Object.keys(next);
|
|
72
|
+
bytes += 2 + Math.max(0, names.length - 1) + names.length;
|
|
73
|
+
for (const name of names) {
|
|
74
|
+
bytes += canonicalPrimitiveBytes(name);
|
|
75
|
+
pending.push(next[name]);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
47
78
|
}
|
|
79
|
+
return bytes;
|
|
48
80
|
}
|
|
49
|
-
function
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
81
|
+
function serializeValue(value) {
|
|
82
|
+
let output = '';
|
|
83
|
+
const closers = [];
|
|
84
|
+
// Whether the last token completed a value, so that the next entry follows a comma, and whether
|
|
85
|
+
// it was an Object member name, so that the next token is that member's value.
|
|
86
|
+
let complete = false;
|
|
87
|
+
let named = false;
|
|
88
|
+
for (const token of canonicalTokens(value)) {
|
|
89
|
+
if (token === END) {
|
|
90
|
+
output += closers.pop();
|
|
91
|
+
complete = true;
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
if (complete)
|
|
95
|
+
output += ',';
|
|
96
|
+
complete = false;
|
|
97
|
+
if (!named && closers.at(-1) === '}') {
|
|
98
|
+
output += `${JSON.stringify(token)}:`;
|
|
99
|
+
named = true;
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
named = false;
|
|
103
|
+
if (token === ARRAY || token === OBJECT) {
|
|
104
|
+
output += token === ARRAY ? '[' : '{';
|
|
105
|
+
closers.push(token === ARRAY ? ']' : '}');
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
output += JSON.stringify(token);
|
|
109
|
+
complete = true;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return output;
|
|
54
113
|
}
|
|
55
|
-
|
|
114
|
+
/** The order of member names in canonical JSON: by UTF-16 code unit, the order `<` gives strings. */
|
|
115
|
+
export function compareCodeUnits(left, right) {
|
|
56
116
|
return left < right ? -1 : left > right ? 1 : 0;
|
|
57
117
|
}
|
|
118
|
+
const ARRAY = Symbol('array');
|
|
119
|
+
const OBJECT = Symbol('object');
|
|
120
|
+
const END = Symbol('end');
|
|
121
|
+
/**
|
|
122
|
+
* A trusted Value as the tokens of its canonical JSON, in order: each scalar and member name, and
|
|
123
|
+
* where each container starts and ends, with member names in `compareCodeUnits` order. Two values
|
|
124
|
+
* have the same tokens exactly when they have the same canonical JSON text, and no value's tokens
|
|
125
|
+
* are a prefix of another's. Admission bounded the value, so the reading checks no limit of its own,
|
|
126
|
+
* and it holds neither the text, which may outgrow any string, nor a stack frame per level.
|
|
127
|
+
*/
|
|
128
|
+
export function* canonicalTokens(value) {
|
|
129
|
+
const pending = [value];
|
|
130
|
+
while (pending.length > 0) {
|
|
131
|
+
const next = pending.pop();
|
|
132
|
+
if (next === null || typeof next !== 'object') {
|
|
133
|
+
yield next;
|
|
134
|
+
}
|
|
135
|
+
else if (Array.isArray(next)) {
|
|
136
|
+
yield ARRAY;
|
|
137
|
+
pending.push(END);
|
|
138
|
+
for (let index = next.length - 1; index >= 0; index -= 1)
|
|
139
|
+
pending.push(next[index]);
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
yield OBJECT;
|
|
143
|
+
pending.push(END);
|
|
144
|
+
const names = Object.keys(next).sort(compareCodeUnits);
|
|
145
|
+
for (let index = names.length - 1; index >= 0; index -= 1) {
|
|
146
|
+
pending.push(next[names[index]], names[index]);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
package/dist/value/decode.d.ts
CHANGED
|
@@ -2,3 +2,10 @@ import type { Value } from './types.js';
|
|
|
2
2
|
import { type Options } from './limits.js';
|
|
3
3
|
/** Strictly decode one bounded JSON value. */
|
|
4
4
|
export declare function decode(input: string | Uint8Array, options?: Options): Value;
|
|
5
|
+
/**
|
|
6
|
+
* Strictly decode one bounded JSON value as the deeply frozen snapshot `acceptImmutable` returns
|
|
7
|
+
* for it, within the same complete canonical byte budget. Native parsing built every container
|
|
8
|
+
* from scanned text, so none needs host reflection: the scan counts its receipt, and freezing it
|
|
9
|
+
* completes its admission.
|
|
10
|
+
*/
|
|
11
|
+
export declare function decodeImmutable(input: string | Uint8Array, options?: Options): Value;
|
package/dist/value/decode.js
CHANGED
|
@@ -1,16 +1,137 @@
|
|
|
1
1
|
import { printParseErrorCode, visit } from 'jsonc-parser';
|
|
2
2
|
import { DecodeError } from './error.js';
|
|
3
|
+
import { retainImmutableSnapshot } from './immutable.optimization.js';
|
|
3
4
|
import { limitsFor } from './limits.js';
|
|
4
|
-
import { assertDecodedString, assertSourceString } from './unicode.js';
|
|
5
|
+
import { assertDecodedString, assertSourceString, canonicalPrimitiveBytes, utf8Length, } from './unicode.js';
|
|
5
6
|
const decoder = new TextDecoder('utf-8', { fatal: true, ignoreBOM: true });
|
|
6
7
|
/** Strictly decode one bounded JSON value. */
|
|
7
8
|
export function decode(input, options) {
|
|
9
|
+
return decodeWith(input, limitsFor(options), undefined);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Strictly decode one bounded JSON value as the deeply frozen snapshot `acceptImmutable` returns
|
|
13
|
+
* for it, within the same complete canonical byte budget. Native parsing built every container
|
|
14
|
+
* from scanned text, so none needs host reflection: the scan counts its receipt, and freezing it
|
|
15
|
+
* completes its admission.
|
|
16
|
+
*/
|
|
17
|
+
export function decodeImmutable(input, options) {
|
|
8
18
|
const limits = limitsFor(options);
|
|
19
|
+
const summary = { members: 0, depth: 0, stringBytes: 0, canonicalBytes: 0 };
|
|
20
|
+
// Canonical text may decode to null, so only undefined sends it to the strict scan.
|
|
21
|
+
const canonical = decodeCanonical(input, limits, summary);
|
|
22
|
+
const value = canonical === undefined ? decodeWith(input, limits, summary) : canonical;
|
|
23
|
+
if (value !== null && typeof value === 'object') {
|
|
24
|
+
freeze(value);
|
|
25
|
+
retainImmutableSnapshot(value, summary);
|
|
26
|
+
}
|
|
27
|
+
return value;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The value `input` parses to when `input` is exactly the text `JSON.stringify` writes for that
|
|
31
|
+
* value, with its receipt counted into `summary`; canonical JSON, as this package serializes it,
|
|
32
|
+
* is such text. That text holds no whitespace, no duplicate member and no number the strict scan
|
|
33
|
+
* refuses, and its byte length is the canonical length, so one walk of the parsed value checks
|
|
34
|
+
* what remains, its strings and limits, as the scan would. Any other input answers undefined, and
|
|
35
|
+
* the strict scan decides it.
|
|
36
|
+
*/
|
|
37
|
+
function decodeCanonical(input, limits, summary) {
|
|
38
|
+
let source;
|
|
39
|
+
let bytes;
|
|
40
|
+
if (typeof input === 'string') {
|
|
41
|
+
source = input;
|
|
42
|
+
bytes = utf8Length(input, limits.maxBytes);
|
|
43
|
+
if (bytes < 0)
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
bytes = input.byteLength;
|
|
48
|
+
try {
|
|
49
|
+
source = decoder.decode(input);
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (bytes > limits.maxBytes)
|
|
56
|
+
return undefined;
|
|
57
|
+
let value;
|
|
58
|
+
try {
|
|
59
|
+
value = JSON.parse(source);
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
// In ASCII text, a string holds U+0000 or a lone surrogate only through its escape; without one,
|
|
65
|
+
// each string's UTF-8 length is its length.
|
|
66
|
+
const ascii = bytes === source.length && !source.includes('\\u0000') && !source.includes('\\ud');
|
|
67
|
+
const walk = { limits, ascii, members: 0, depth: 0, strings: 0 };
|
|
68
|
+
if (!portable(value, 0, walk) || JSON.stringify(value) !== source)
|
|
69
|
+
return undefined;
|
|
70
|
+
summary.members = walk.members;
|
|
71
|
+
summary.depth = walk.depth;
|
|
72
|
+
summary.stringBytes = walk.strings;
|
|
73
|
+
summary.canonicalBytes = bytes;
|
|
74
|
+
return value;
|
|
75
|
+
}
|
|
76
|
+
/** Whether a parsed value's strings and limits hold as the strict scan checks them. */
|
|
77
|
+
function portable(value, depth, walk) {
|
|
78
|
+
if (typeof value === 'string')
|
|
79
|
+
return portableString(value, walk);
|
|
80
|
+
// A number the scan refuses, -0 or one past binary64, never reads back as the text written for it.
|
|
81
|
+
if (value === null || typeof value !== 'object')
|
|
82
|
+
return true;
|
|
83
|
+
if (depth >= walk.limits.maxDepth)
|
|
84
|
+
return false;
|
|
85
|
+
if (depth >= walk.depth)
|
|
86
|
+
walk.depth = depth + 1;
|
|
87
|
+
if (Array.isArray(value)) {
|
|
88
|
+
walk.members += value.length;
|
|
89
|
+
if (walk.members > walk.limits.maxMembers)
|
|
90
|
+
return false;
|
|
91
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
92
|
+
if (!portable(value[index], depth + 1, walk))
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
const keys = Object.keys(value);
|
|
98
|
+
walk.members += keys.length;
|
|
99
|
+
if (walk.members > walk.limits.maxMembers)
|
|
100
|
+
return false;
|
|
101
|
+
for (let index = 0; index < keys.length; index += 1) {
|
|
102
|
+
const key = keys[index];
|
|
103
|
+
if (!portableString(key, walk))
|
|
104
|
+
return false;
|
|
105
|
+
if (!portable(value[key], depth + 1, walk))
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
function portableString(value, walk) {
|
|
111
|
+
let bytes = value.length;
|
|
112
|
+
if (!walk.ascii) {
|
|
113
|
+
if (value.includes('\u0000'))
|
|
114
|
+
return false;
|
|
115
|
+
bytes = utf8Length(value, walk.limits.maxStringBytes);
|
|
116
|
+
if (bytes < 0)
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
if (bytes > walk.limits.maxStringBytes)
|
|
120
|
+
return false;
|
|
121
|
+
if (bytes > walk.strings)
|
|
122
|
+
walk.strings = bytes;
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
125
|
+
function decodeWith(input, limits, summary) {
|
|
9
126
|
const source = sourceFor(input, limits);
|
|
10
127
|
if (source.charCodeAt(0) === 0xfeff) {
|
|
11
128
|
throw new DecodeError('JSON_SYNTAX', 'A byte-order mark is not JSON whitespace', 0);
|
|
12
129
|
}
|
|
13
|
-
scan(source, limits);
|
|
130
|
+
scan(source, limits, summary);
|
|
131
|
+
// An immutable snapshot keeps to the canonical byte budget, which a value's text need not.
|
|
132
|
+
if (summary !== undefined && summary.canonicalBytes > limits.maxBytes) {
|
|
133
|
+
throw new DecodeError('JSON_LIMIT', `Canonical JSON exceeds the ${limits.maxBytes}-byte limit`, 0);
|
|
134
|
+
}
|
|
14
135
|
try {
|
|
15
136
|
return JSON.parse(source);
|
|
16
137
|
}
|
|
@@ -18,6 +139,13 @@ export function decode(input, options) {
|
|
|
18
139
|
throw new DecodeError('JSON_SYNTAX', 'Native JSON decoding rejected the strictly scanned input', 0, { cause: error });
|
|
19
140
|
}
|
|
20
141
|
}
|
|
142
|
+
function freeze(value) {
|
|
143
|
+
for (const member of Object.values(value)) {
|
|
144
|
+
if (member !== null && typeof member === 'object')
|
|
145
|
+
freeze(member);
|
|
146
|
+
}
|
|
147
|
+
Object.freeze(value);
|
|
148
|
+
}
|
|
21
149
|
function sourceFor(input, limits) {
|
|
22
150
|
if (typeof input === 'string') {
|
|
23
151
|
assertSourceString(input, limits.maxBytes);
|
|
@@ -33,14 +161,18 @@ function sourceFor(input, limits) {
|
|
|
33
161
|
throw new DecodeError('JSON_UTF8', 'Malformed UTF-8 JSON input', 0, { cause: error });
|
|
34
162
|
}
|
|
35
163
|
}
|
|
36
|
-
function scan(source, limits) {
|
|
37
|
-
const state = { frames: [], limits, members: 0 };
|
|
164
|
+
function scan(source, limits, summary) {
|
|
165
|
+
const state = { frames: [], limits, members: 0, summary };
|
|
38
166
|
const beginContainer = (kind, offset) => {
|
|
39
167
|
countArrayItem(state, offset);
|
|
40
168
|
if (state.frames.length >= limits.maxDepth) {
|
|
41
169
|
throw new DecodeError('JSON_LIMIT', `JSON nesting exceeds the ${limits.maxDepth}-level limit`, offset);
|
|
42
170
|
}
|
|
43
|
-
state.frames.push(kind === 'object' ? { kind, names: new Set() } : { kind });
|
|
171
|
+
state.frames.push(kind === 'object' ? { kind, names: new Set(), entries: 0 } : { kind, entries: 0 });
|
|
172
|
+
if (summary !== undefined) {
|
|
173
|
+
summary.depth = Math.max(summary.depth, state.frames.length);
|
|
174
|
+
summary.canonicalBytes += 2;
|
|
175
|
+
}
|
|
44
176
|
};
|
|
45
177
|
const visitor = {
|
|
46
178
|
onObjectBegin: (offset) => beginContainer('object', offset),
|
|
@@ -48,12 +180,18 @@ function scan(source, limits) {
|
|
|
48
180
|
const frame = state.frames.at(-1);
|
|
49
181
|
if (frame?.kind !== 'object')
|
|
50
182
|
failSyntax('Object member outside an Object', offset);
|
|
51
|
-
assertDecodedString(name, offset, limits.maxStringBytes);
|
|
183
|
+
const bytes = assertDecodedString(name, offset, limits.maxStringBytes);
|
|
52
184
|
if (frame.names.has(name)) {
|
|
53
185
|
throw new DecodeError('JSON_DUPLICATE_MEMBER', `Duplicate object member ${JSON.stringify(name)}`, offset);
|
|
54
186
|
}
|
|
55
187
|
frame.names.add(name);
|
|
56
188
|
addMembers(state, 1, offset);
|
|
189
|
+
if (summary !== undefined) {
|
|
190
|
+
// The name, its colon, and a comma before every member but the first.
|
|
191
|
+
summary.stringBytes = Math.max(summary.stringBytes, bytes);
|
|
192
|
+
summary.canonicalBytes += canonicalPrimitiveBytes(name) + (frame.entries > 0 ? 2 : 1);
|
|
193
|
+
}
|
|
194
|
+
frame.entries += 1;
|
|
57
195
|
},
|
|
58
196
|
onObjectEnd: (offset) => endContainer(state, 'object', offset),
|
|
59
197
|
onArrayBegin: (offset) => beginContainer('array', offset),
|
|
@@ -61,7 +199,9 @@ function scan(source, limits) {
|
|
|
61
199
|
onLiteralValue: (value, offset) => {
|
|
62
200
|
countArrayItem(state, offset);
|
|
63
201
|
if (typeof value === 'string') {
|
|
64
|
-
assertDecodedString(value, offset, limits.maxStringBytes);
|
|
202
|
+
const bytes = assertDecodedString(value, offset, limits.maxStringBytes);
|
|
203
|
+
if (summary !== undefined)
|
|
204
|
+
summary.stringBytes = Math.max(summary.stringBytes, bytes);
|
|
65
205
|
}
|
|
66
206
|
else if (typeof value === 'number') {
|
|
67
207
|
if (!Number.isFinite(value)) {
|
|
@@ -71,6 +211,8 @@ function scan(source, limits) {
|
|
|
71
211
|
throw new DecodeError('JSON_NUMBER', 'JSON number resolves to negative zero', offset);
|
|
72
212
|
}
|
|
73
213
|
}
|
|
214
|
+
if (summary !== undefined)
|
|
215
|
+
summary.canonicalBytes += canonicalPrimitiveBytes(value);
|
|
74
216
|
},
|
|
75
217
|
onError: (error, offset) => {
|
|
76
218
|
failSyntax(`Invalid JSON: ${printParseErrorCode(error)}`, offset);
|
|
@@ -88,10 +230,18 @@ function scan(source, limits) {
|
|
|
88
230
|
throw error;
|
|
89
231
|
throw new DecodeError('JSON_SYNTAX', 'JSON scanner failed', 0, { cause: error });
|
|
90
232
|
}
|
|
233
|
+
if (summary !== undefined)
|
|
234
|
+
summary.members = state.members;
|
|
91
235
|
}
|
|
92
236
|
function countArrayItem(state, offset) {
|
|
93
|
-
|
|
94
|
-
|
|
237
|
+
const frame = state.frames.at(-1);
|
|
238
|
+
if (frame?.kind !== 'array')
|
|
239
|
+
return;
|
|
240
|
+
addMembers(state, 1, offset);
|
|
241
|
+
// A comma before every item but the first.
|
|
242
|
+
if (state.summary !== undefined && frame.entries > 0)
|
|
243
|
+
state.summary.canonicalBytes += 1;
|
|
244
|
+
frame.entries += 1;
|
|
95
245
|
}
|
|
96
246
|
function addMembers(state, count, offset) {
|
|
97
247
|
state.members += count;
|
package/dist/value/equal.d.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
import type { Value } from './types.js';
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Whether two admitted Values are the same JSON value: the same scalar, Arrays item by item, Objects
|
|
4
|
+
* with the same names whose values are the same, in any member order. This is exactly when their
|
|
5
|
+
* canonical JSON texts are equal (`proofs/Canonical.lean`).
|
|
6
|
+
*
|
|
7
|
+
* It reads what admission let through and answers for all of it: it admits nothing, so no limit of
|
|
8
|
+
* its own can refuse a value other limits admitted, and it holds neither a text nor a stack frame
|
|
9
|
+
* per level.
|
|
10
|
+
*/
|
|
3
11
|
export declare function equal(left: Value, right: Value): boolean;
|
package/dist/value/equal.js
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Whether two admitted Values are the same JSON value: the same scalar, Arrays item by item, Objects
|
|
3
|
+
* with the same names whose values are the same, in any member order. This is exactly when their
|
|
4
|
+
* canonical JSON texts are equal (`proofs/Canonical.lean`).
|
|
5
|
+
*
|
|
6
|
+
* It reads what admission let through and answers for all of it: it admits nothing, so no limit of
|
|
7
|
+
* its own can refuse a value other limits admitted, and it holds neither a text nor a stack frame
|
|
8
|
+
* per level.
|
|
9
|
+
*/
|
|
3
10
|
export function equal(left, right) {
|
|
4
|
-
|
|
11
|
+
const pending = [left, right];
|
|
12
|
+
while (pending.length > 0) {
|
|
13
|
+
const second = pending.pop();
|
|
14
|
+
const first = pending.pop();
|
|
15
|
+
if (first === second)
|
|
16
|
+
continue;
|
|
17
|
+
if (first === null || second === null)
|
|
18
|
+
return false;
|
|
19
|
+
if (typeof first !== 'object' || typeof second !== 'object')
|
|
20
|
+
return false;
|
|
21
|
+
if (Array.isArray(first) !== Array.isArray(second))
|
|
22
|
+
return false;
|
|
23
|
+
if (Array.isArray(first)) {
|
|
24
|
+
if (first.length !== second.length)
|
|
25
|
+
return false;
|
|
26
|
+
first.forEach((item, index) => pending.push(item, second[index]));
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
const names = Object.keys(first);
|
|
30
|
+
if (names.length !== Object.keys(second).length)
|
|
31
|
+
return false;
|
|
32
|
+
for (const name of names) {
|
|
33
|
+
if (!Object.hasOwn(second, name))
|
|
34
|
+
return false;
|
|
35
|
+
pending.push(first[name], second[name]);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return true;
|
|
5
39
|
}
|
|
@@ -8,6 +8,8 @@ export interface SnapshotSummary {
|
|
|
8
8
|
export declare function isImmutableSnapshot(value: object): boolean;
|
|
9
9
|
/** Exact complete representation size, only for roots retained by this admission owner. */
|
|
10
10
|
export declare function immutableSnapshotBytes(value: object): number | undefined;
|
|
11
|
+
/** Exact total of members and elements, only for roots retained by this admission owner. */
|
|
12
|
+
export declare function immutableSnapshotMembers(value: object): number | undefined;
|
|
11
13
|
/** Called only after admission has constructed and deeply frozen this container. */
|
|
12
14
|
export declare function retainImmutableSnapshot(value: object, summary: SnapshotSummary): void;
|
|
13
15
|
export declare function includeSnapshot(parent: SnapshotSummary | undefined, child: SnapshotSummary, depth: number): void;
|
|
@@ -8,6 +8,10 @@ export function isImmutableSnapshot(value) {
|
|
|
8
8
|
export function immutableSnapshotBytes(value) {
|
|
9
9
|
return snapshots.get(value)?.canonicalBytes;
|
|
10
10
|
}
|
|
11
|
+
/** Exact total of members and elements, only for roots retained by this admission owner. */
|
|
12
|
+
export function immutableSnapshotMembers(value) {
|
|
13
|
+
return snapshots.get(value)?.members;
|
|
14
|
+
}
|
|
11
15
|
/** Called only after admission has constructed and deeply frozen this container. */
|
|
12
16
|
export function retainImmutableSnapshot(value, summary) {
|
|
13
17
|
if (!snapshots.has(value))
|
package/dist/value/index.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/** Portable values shared by the DSL and kernel contracts. */
|
|
2
|
-
export { accept, acceptForRead, acceptImmutable } from './accept.js';
|
|
2
|
+
export { accept, acceptForRead, acceptImmutable, memberCount } from './accept.js';
|
|
3
3
|
export { equal } from './equal.js';
|
|
4
4
|
export { BoundaryError, DecodeError } from './error.js';
|
|
5
5
|
export type { BoundaryErrorCode, DecodeErrorCode } from './error.js';
|
|
6
6
|
export { defaultLimits } from './limits.js';
|
|
7
|
-
export type { LimitOverrides, Limits, Options } from './limits.js';
|
|
7
|
+
export type { LimitOverrides, Limits, Options, StructuralLimitOverrides, StructuralOptions, } from './limits.js';
|
|
8
8
|
export * as json from './json.js';
|
|
9
|
-
export
|
|
9
|
+
export { PORTABLE_VALUE_RULES } from './rule.js';
|
|
10
|
+
export type { PortableValueRule } from './rule.js';
|
|
11
|
+
export type { Array, Object, Primitive, Value, ValueKind } from './types.js';
|
package/dist/value/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/** Portable values shared by the DSL and kernel contracts. */
|
|
2
|
-
export { accept, acceptForRead, acceptImmutable } from './accept.js';
|
|
2
|
+
export { accept, acceptForRead, acceptImmutable, memberCount } from './accept.js';
|
|
3
3
|
export { equal } from './equal.js';
|
|
4
4
|
export { BoundaryError, DecodeError } from './error.js';
|
|
5
5
|
export { defaultLimits } from './limits.js';
|
|
6
6
|
export * as json from './json.js';
|
|
7
|
+
export { PORTABLE_VALUE_RULES } from './rule.js';
|
package/dist/value/json.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { encode, serialize, serializeAdmitted } from './canonical.js';
|
|
2
|
-
export { decode } from './decode.js';
|
|
1
|
+
export { byteLength, encode, serialize, serializeAdmitted } from './canonical.js';
|
|
2
|
+
export { decode, decodeImmutable } from './decode.js';
|
|
3
3
|
export { DecodeError } from './error.js';
|
package/dist/value/json.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { encode, serialize, serializeAdmitted } from './canonical.js';
|
|
2
|
-
export { decode } from './decode.js';
|
|
1
|
+
export { byteLength, encode, serialize, serializeAdmitted } from './canonical.js';
|
|
2
|
+
export { decode, decodeImmutable } from './decode.js';
|
|
3
3
|
export { DecodeError } from './error.js';
|
package/dist/value/limits.d.ts
CHANGED
|
@@ -17,5 +17,16 @@ export interface LimitOverrides {
|
|
|
17
17
|
export interface Options {
|
|
18
18
|
readonly limits?: LimitOverrides;
|
|
19
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* The limits of a capture that never measures canonical bytes. Holding a value to `maxBytes` takes
|
|
22
|
+
* `acceptImmutable`, or a JSON route, which measure them. `never` rather than absent, so that a shared
|
|
23
|
+
* constant naming bytes is refused as a literal is.
|
|
24
|
+
*/
|
|
25
|
+
export interface StructuralLimitOverrides extends Omit<LimitOverrides, 'maxBytes'> {
|
|
26
|
+
readonly maxBytes?: never;
|
|
27
|
+
}
|
|
28
|
+
export interface StructuralOptions {
|
|
29
|
+
readonly limits?: StructuralLimitOverrides;
|
|
30
|
+
}
|
|
20
31
|
export declare const defaultLimits: Readonly<Limits>;
|
|
21
32
|
export declare function limitsFor(options: Options | undefined): Limits;
|