@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
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ClassDefinition } from '../../language/class/model/class.js';
|
|
2
|
+
import type { CoreContent } from '../../language/core/model/core.js';
|
|
3
|
+
import type { DefinitionAnalysis } from '../../schema/analysis/class.js';
|
|
4
|
+
import type { DomainSchemaLookup } from '../../schema/dependency/lookup.js';
|
|
5
|
+
import type { DomainSchemaIR } from '../../schema/model/schema.js';
|
|
6
|
+
import type { UnqualifiedCoreContent } from './core.js';
|
|
7
|
+
type UnqualifiedDomainSchema = Omit<DomainSchemaIR, 'core'> & {
|
|
8
|
+
readonly core: UnqualifiedCoreContent;
|
|
9
|
+
};
|
|
10
|
+
/** The effective Properties of every Class `candidate` resolves, by `definitionRefIndex`. */
|
|
11
|
+
export type PropertyOwners = ReadonlyMap<string, DefinitionAnalysis>;
|
|
12
|
+
/**
|
|
13
|
+
* Analyze the already-canonical Definition surface of `candidate` once, so Property shorthand
|
|
14
|
+
* resolves against each Class's own and inherited Properties. Core values and key tuples take no
|
|
15
|
+
* part in Class composition, so they are left out of the analysis.
|
|
16
|
+
*/
|
|
17
|
+
export declare function analyzePropertyOwners(candidate: UnqualifiedDomainSchema, lookup: DomainSchemaLookup): PropertyOwners;
|
|
18
|
+
/** Lower rich builder shorthand to the canonical full-key Core representation. */
|
|
19
|
+
export declare function canonicalizeCorePropertyKeys(core: UnqualifiedCoreContent, owners: PropertyOwners): CoreContent;
|
|
20
|
+
/**
|
|
21
|
+
* Lower each Property a key tuple names by its name to its full key among the Class's own and
|
|
22
|
+
* inherited Properties; a full key stays as authored. Ambiguity and absence are refused here, so a
|
|
23
|
+
* tuple never names a Property the author did not mean. A Node tuple names Properties only; an Edge
|
|
24
|
+
* tuple names them as `{ property }` beside its structural fields.
|
|
25
|
+
*/
|
|
26
|
+
export declare function canonicalizeUniquePropertyKeys(classes: Readonly<Record<string, ClassDefinition>>, origin: string, owners: PropertyOwners): Readonly<Record<string, ClassDefinition>>;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { PropertyKey as admitPropertyKey } from '../../addressing/index.js';
|
|
2
|
+
import { definitionRefIndex } from '../../addressing/ordering.js';
|
|
3
|
+
import { createPropertyValues } from '../../language/class/property-values.js';
|
|
4
|
+
import { analyzeDefinitions } from '../../schema/analysis/class.js';
|
|
5
|
+
import { buildDomainResolutionContext } from '../../schema/resolution/context.js';
|
|
6
|
+
import { escapeToken, fail } from '../schema/diagnostic.js';
|
|
7
|
+
/**
|
|
8
|
+
* Analyze the already-canonical Definition surface of `candidate` once, so Property shorthand
|
|
9
|
+
* resolves against each Class's own and inherited Properties. Core values and key tuples take no
|
|
10
|
+
* part in Class composition, so they are left out of the analysis.
|
|
11
|
+
*/
|
|
12
|
+
export function analyzePropertyOwners(candidate, lookup) {
|
|
13
|
+
const analysisCandidate = {
|
|
14
|
+
...candidate,
|
|
15
|
+
core: { nodes: {}, edges: [] },
|
|
16
|
+
};
|
|
17
|
+
return analyzeDefinitions(buildDomainResolutionContext(analysisCandidate, lookup)).definitions;
|
|
18
|
+
}
|
|
19
|
+
/** Lower rich builder shorthand to the canonical full-key Core representation. */
|
|
20
|
+
export function canonicalizeCorePropertyKeys(core, owners) {
|
|
21
|
+
const nodes = Object.fromEntries(Object.entries(core.nodes).map(([slug, node]) => {
|
|
22
|
+
const definition = owners.get(definitionRefIndex(node.class));
|
|
23
|
+
if (definition === undefined) {
|
|
24
|
+
fail('BUILDER_CORE_PROPERTY', `/core/nodes/${escapeToken(slug)}/class`, 'Core property shorthand requires a resolvable concrete Class.');
|
|
25
|
+
}
|
|
26
|
+
return [
|
|
27
|
+
slug,
|
|
28
|
+
{
|
|
29
|
+
...node,
|
|
30
|
+
properties: qualify(node.properties, definition, `/core/nodes/${escapeToken(slug)}/properties`),
|
|
31
|
+
},
|
|
32
|
+
];
|
|
33
|
+
}));
|
|
34
|
+
const edges = core.edges.map((edge, index) => {
|
|
35
|
+
const definition = owners.get(definitionRefIndex(edge.class));
|
|
36
|
+
if (definition === undefined) {
|
|
37
|
+
fail('BUILDER_CORE_PROPERTY', `/core/edges/${index}/class`, 'Core property shorthand requires a resolvable concrete Class.');
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
...edge,
|
|
41
|
+
properties: qualify(edge.properties, definition, `/core/edges/${index}/properties`),
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
return { nodes, edges };
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Lower each Property a key tuple names by its name to its full key among the Class's own and
|
|
48
|
+
* inherited Properties; a full key stays as authored. Ambiguity and absence are refused here, so a
|
|
49
|
+
* tuple never names a Property the author did not mean. A Node tuple names Properties only; an Edge
|
|
50
|
+
* tuple names them as `{ property }` beside its structural fields.
|
|
51
|
+
*/
|
|
52
|
+
export function canonicalizeUniquePropertyKeys(classes, origin, owners) {
|
|
53
|
+
return Object.fromEntries(Object.entries(classes).map(([name, declaration]) => {
|
|
54
|
+
if (declaration.kind === 'edge' && declaration.orientation !== 'directed') {
|
|
55
|
+
return [name, declaration];
|
|
56
|
+
}
|
|
57
|
+
if (declaration.unique === undefined)
|
|
58
|
+
return [name, declaration];
|
|
59
|
+
const ref = { origin, kind: 'class', name };
|
|
60
|
+
const definition = owners.get(definitionRefIndex(ref));
|
|
61
|
+
const pointer = `/classes/${escapeToken(name)}/unique`;
|
|
62
|
+
const resolve = (input, at) => {
|
|
63
|
+
if (definition === undefined) {
|
|
64
|
+
fail('BUILDER_UNIQUE_PROPERTY', at, 'A key Property requires a resolvable Class.');
|
|
65
|
+
}
|
|
66
|
+
return resolveInputKey(input, definition, 'BUILDER_UNIQUE_PROPERTY', at);
|
|
67
|
+
};
|
|
68
|
+
if (declaration.kind === 'node') {
|
|
69
|
+
const unique = declaration.unique.map((tuple, t) => tuple.map((key, f) => resolve(key, `${pointer}/${t}/${f}`)));
|
|
70
|
+
return [name, { ...declaration, unique }];
|
|
71
|
+
}
|
|
72
|
+
const unique = declaration.unique.map((tuple, t) => tuple.map((field, f) => typeof field === 'string'
|
|
73
|
+
? field
|
|
74
|
+
: { property: resolve(field.property, `${pointer}/${t}/${f}/property`) }));
|
|
75
|
+
return [name, { ...declaration, unique }];
|
|
76
|
+
}));
|
|
77
|
+
}
|
|
78
|
+
function qualify(input, definition, pointer) {
|
|
79
|
+
const result = {};
|
|
80
|
+
const sourceByKey = new Map();
|
|
81
|
+
for (const [inputKey, value] of Object.entries(input)) {
|
|
82
|
+
const key = resolveInputKey(inputKey, definition, 'BUILDER_CORE_PROPERTY', `${pointer}/${escapeToken(inputKey)}`);
|
|
83
|
+
const previous = sourceByKey.get(key);
|
|
84
|
+
if (previous !== undefined) {
|
|
85
|
+
fail('BUILDER_CORE_PROPERTY', `${pointer}/${escapeToken(inputKey)}`, `Property is supplied twice through ${JSON.stringify(previous)} and ${JSON.stringify(inputKey)}.`);
|
|
86
|
+
}
|
|
87
|
+
sourceByKey.set(key, inputKey);
|
|
88
|
+
result[key] = value;
|
|
89
|
+
}
|
|
90
|
+
return createPropertyValues(Object.entries(result).map(([key, value]) => [admitPropertyKey(key), value]));
|
|
91
|
+
}
|
|
92
|
+
/** The full key of the Property `input` names on `definition`: its full key, or its unique name. */
|
|
93
|
+
function resolveInputKey(input, definition, code, pointer) {
|
|
94
|
+
if (admitPropertyKey.is(input)) {
|
|
95
|
+
const key = admitPropertyKey(input);
|
|
96
|
+
if (!definition.properties.has(key)) {
|
|
97
|
+
fail(code, pointer, `Property ${input} is not present on the Class.`);
|
|
98
|
+
}
|
|
99
|
+
return key;
|
|
100
|
+
}
|
|
101
|
+
const candidates = [...definition.properties].flatMap(([key, field]) => field.name === input ? [key] : []);
|
|
102
|
+
if (candidates.length === 1)
|
|
103
|
+
return candidates[0];
|
|
104
|
+
if (candidates.length === 0) {
|
|
105
|
+
fail(code, pointer, `Property ${JSON.stringify(input)} does not exist.`);
|
|
106
|
+
}
|
|
107
|
+
fail(code, pointer, `Property ${JSON.stringify(input)} is ambiguous; use one of: ${candidates.join(', ')}.`);
|
|
108
|
+
}
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
+
import { deepFreeze } from '../../../language/freeze.js';
|
|
1
2
|
import { acceptDomainSchema } from '../../../schema/admission/accept.js';
|
|
2
|
-
import { canonicalizeDomainSchema } from '../../../schema/canonical/domain.js';
|
|
3
|
-
import { deepFreeze } from '../../../schema/canonical/freeze.js';
|
|
4
3
|
import { MemoryDomainSchemaLookup } from '../../../schema/dependency/lookup.js';
|
|
4
|
+
import { normalizeDomainSchema } from '../../../schema/normalization/domain.js';
|
|
5
5
|
import { lookupEntriesForDependencies } from '../../../schema/resolution/closure.js';
|
|
6
6
|
import { parseDomainSchemaStructure } from '../../../schema/validation/domain.structure.js';
|
|
7
7
|
import { assertKnownKeys, escapeToken } from '../../schema/diagnostic.js';
|
|
8
8
|
import { V1CallableCompiler } from '../callable.js';
|
|
9
9
|
import { V1DefinitionCompiler } from '../class.js';
|
|
10
|
-
import { canonicalizeCorePropertyKeys } from '../core-properties.js';
|
|
11
10
|
import { compileCore } from '../core.js';
|
|
12
11
|
import { assertPolicyCompositionAcyclic, V1PolicyCompiler } from '../policy.js';
|
|
12
|
+
import { analyzePropertyOwners, canonicalizeCorePropertyKeys, canonicalizeUniquePropertyKeys, } from '../property-keys.js';
|
|
13
13
|
import { BuilderValueSchemas } from '../value/compile.js';
|
|
14
14
|
import { V1ViewCompiler } from '../view.js';
|
|
15
15
|
import { captureSchema, commitSchemaOwnership } from './capture.js';
|
|
16
16
|
import { BuilderContext } from './context.js';
|
|
17
|
+
import { assertAuthoredLifetimes } from './lifetime.js';
|
|
17
18
|
/**
|
|
18
19
|
* Compile the V1 TypeScript builder graph through the same semantic acceptance
|
|
19
20
|
* path used for untrusted decoded schemas.
|
|
@@ -21,9 +22,11 @@ import { BuilderContext } from './context.js';
|
|
|
21
22
|
* This is the private implementation behind defineSchema.
|
|
22
23
|
*/
|
|
23
24
|
export function compileSchema(origin, input) {
|
|
24
|
-
const
|
|
25
|
+
const dependencies = lookupEntriesForDependencies(input.dependencies ?? {});
|
|
26
|
+
const lookup = new MemoryDomainSchemaLookup(dependencies);
|
|
25
27
|
const candidate = assembleDomainSchema(origin, input, lookup);
|
|
26
28
|
const accepted = acceptDomainSchema(candidate, lookup);
|
|
29
|
+
assertAuthoredLifetimes(accepted, dependencies);
|
|
27
30
|
commitSchemaOwnership(input, origin);
|
|
28
31
|
return accepted;
|
|
29
32
|
}
|
|
@@ -31,6 +34,7 @@ export function compileSchema(origin, input) {
|
|
|
31
34
|
function assembleDomainSchema(origin, input, lookup) {
|
|
32
35
|
assertKnownKeys(input, [
|
|
33
36
|
'name',
|
|
37
|
+
'icon',
|
|
34
38
|
'entrypoint',
|
|
35
39
|
'dependencies',
|
|
36
40
|
'classes',
|
|
@@ -63,6 +67,7 @@ function assembleDomainSchema(origin, input, lookup) {
|
|
|
63
67
|
version: 'v1',
|
|
64
68
|
origin,
|
|
65
69
|
name: input.name,
|
|
70
|
+
...(input.icon === undefined ? {} : { icon: input.icon }),
|
|
66
71
|
...(input.entrypoint === undefined
|
|
67
72
|
? {}
|
|
68
73
|
: { entrypoint: { origin, kind: 'view', name: input.entrypoint } }),
|
|
@@ -75,9 +80,11 @@ function assembleDomainSchema(origin, input, lookup) {
|
|
|
75
80
|
views,
|
|
76
81
|
core,
|
|
77
82
|
};
|
|
83
|
+
const owners = analyzePropertyOwners(semanticContent, lookup);
|
|
78
84
|
const qualifiedContent = {
|
|
79
85
|
...semanticContent,
|
|
80
|
-
|
|
86
|
+
classes: canonicalizeUniquePropertyKeys(classes, origin, owners),
|
|
87
|
+
core: canonicalizeCorePropertyKeys(core, owners),
|
|
81
88
|
};
|
|
82
89
|
context.noteDomainEndpointReferences(qualifiedContent);
|
|
83
90
|
const candidate = {
|
|
@@ -85,7 +92,7 @@ function assembleDomainSchema(origin, input, lookup) {
|
|
|
85
92
|
dependencies: context.dependencies(),
|
|
86
93
|
};
|
|
87
94
|
const structured = parseDomainSchemaStructure(candidate);
|
|
88
|
-
const canonical = parseDomainSchemaStructure(
|
|
95
|
+
const canonical = parseDomainSchemaStructure(normalizeDomainSchema(structured));
|
|
89
96
|
return deepFreeze(canonical);
|
|
90
97
|
}
|
|
91
98
|
function mapRecord(record, map) {
|
|
@@ -6,7 +6,8 @@ import type { PolicyObjectRef } from '../../../language/index.js';
|
|
|
6
6
|
import type { ValueSchemaRegistry } from '../../../language/value/reference/registry.js';
|
|
7
7
|
import type { DomainSchema, DomainSchemaIR } from '../../../schema/model/schema.js';
|
|
8
8
|
import type { Function, PolicyObjectInput } from '../../callable/authoring.js';
|
|
9
|
-
import type { Class
|
|
9
|
+
import type { Class } from '../../class/handle.js';
|
|
10
|
+
import type { ClassReferenceInput } from '../../class/input.js';
|
|
10
11
|
import type { CoreEndpoint, CoreNode } from '../../core/authoring.js';
|
|
11
12
|
import type { Policy } from '../../policy/authoring.js';
|
|
12
13
|
import type { View } from '../../view/authoring.js';
|
|
@@ -29,8 +30,15 @@ export declare class BuilderContext {
|
|
|
29
30
|
captureFunction(value: Function, ref: FunctionRef, pointer: string): void;
|
|
30
31
|
captureView(value: View, ref: ViewRef, pointer: string): void;
|
|
31
32
|
resolveClass(input: ClassReferenceInput, kind: ClassKind, pointer: string): ClassRef;
|
|
33
|
+
/** A parent of another Domain must be open to it in the dependency revision authored against. */
|
|
34
|
+
resolveParent(input: ClassReferenceInput, kind: ClassKind, pointer: string): ClassRef;
|
|
32
35
|
resolveNodeClass(input: ClassReferenceInput, pointer: string): ClassRef;
|
|
33
36
|
resolveEdgeClass(input: ClassReferenceInput, pointer: string): ClassRef;
|
|
37
|
+
/**
|
|
38
|
+
* The roles of a resolved Edge Class's source and target, or of an undirected Class's two
|
|
39
|
+
* endpoints in their stored order, which is the authored one.
|
|
40
|
+
*/
|
|
41
|
+
edgeRoles(ref: ClassRef): readonly [source: string, target: string];
|
|
34
42
|
resolvePolicy(input: Lazy<unknown>, pointer: string): PolicyRef;
|
|
35
43
|
resolvePolicyObject(input: PolicyObjectInput | PolicyObjectRef, pointer: string): PolicyObjectRef;
|
|
36
44
|
/** A Core fact belongs to the Domain that declares it, so a dependency endpoint never resolves. */
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { compareDefinitionRefs, compareUnicode, definitionRefIndex, } from '../../../addressing/ordering.js';
|
|
2
2
|
import { DEPENDENCY_ALIAS_PATTERN } from '../../../addressing/patterns.js';
|
|
3
3
|
import { isMethodExecutable } from '../../../language/callable/executable.js';
|
|
4
|
+
import { admitsForeignSubclass, inheritanceOf } from '../../../language/class/inheritance.js';
|
|
4
5
|
import { policyObjectKey, policyObjectOrigin } from '../../../language/index.js';
|
|
5
6
|
import { graphNodePathSchema } from '../../../language/value/syntax/node-path/schema.js';
|
|
7
|
+
import { escapePointerToken } from '../../../language/value/syntax/pointer.js';
|
|
6
8
|
import { revisionOfDomainSchema } from '../../../schema/canonical/revision.js';
|
|
7
9
|
import { requireDomainClosure } from '../../../schema/resolution/closure.js';
|
|
8
10
|
import { collectUsedForeignOrigins } from '../../../schema/resolution/origins.js';
|
|
11
|
+
import { classConfiguration } from '../../class/authoring.js';
|
|
9
12
|
import { fail } from '../../schema/diagnostic.js';
|
|
10
13
|
import { resolveLazy } from '../../schema/lazy.js';
|
|
11
14
|
import { OwnershipCapture } from './ownership.js';
|
|
@@ -14,6 +17,7 @@ export class BuilderContext {
|
|
|
14
17
|
ownership = new OwnershipCapture();
|
|
15
18
|
localDefinitions = new Map();
|
|
16
19
|
localClassKinds = new Map();
|
|
20
|
+
#localClasses = new Map();
|
|
17
21
|
policies = new Map();
|
|
18
22
|
policyObjects = new Map();
|
|
19
23
|
policyObjectRefs = new Set();
|
|
@@ -22,7 +26,7 @@ export class BuilderContext {
|
|
|
22
26
|
constructor(origin, dependencies) {
|
|
23
27
|
this.origin = origin;
|
|
24
28
|
for (const [alias, schema] of Object.entries(dependencies)) {
|
|
25
|
-
const pointer = `/dependencies/${
|
|
29
|
+
const pointer = `/dependencies/${escapePointerToken(alias)}`;
|
|
26
30
|
if (!DEPENDENCY_ALIAS_PATTERN.test(alias)) {
|
|
27
31
|
fail('BUILDER_DEPENDENCY_ALIAS', pointer, `Dependency alias ${JSON.stringify(alias)} must be an ASCII lower-camel identifier.`);
|
|
28
32
|
}
|
|
@@ -42,11 +46,9 @@ export class BuilderContext {
|
|
|
42
46
|
}
|
|
43
47
|
captureDefinition(value, ref, pointer) {
|
|
44
48
|
const key = definitionRefIndex(ref);
|
|
45
|
-
if (this.localDefinitions.has(key)) {
|
|
46
|
-
fail('BUILDER_DUPLICATE_MEMBER', pointer, `Definition ${ref.kind}.${ref.name} is duplicated.`);
|
|
47
|
-
}
|
|
48
49
|
this.localDefinitions.set(key, ref);
|
|
49
50
|
this.localClassKinds.set(key, value.kind);
|
|
51
|
+
this.#localClasses.set(key, value);
|
|
50
52
|
this.ownership.captureDefinition(value, ref, pointer);
|
|
51
53
|
this.capturePolicyObject(value, ref);
|
|
52
54
|
}
|
|
@@ -90,12 +92,42 @@ export class BuilderContext {
|
|
|
90
92
|
}
|
|
91
93
|
return { ...ref };
|
|
92
94
|
}
|
|
95
|
+
/** A parent of another Domain must be open to it in the dependency revision authored against. */
|
|
96
|
+
resolveParent(input, kind, pointer) {
|
|
97
|
+
const ref = this.resolveClass(input, kind, pointer);
|
|
98
|
+
if (ref.origin === this.origin)
|
|
99
|
+
return ref;
|
|
100
|
+
const parent = this.#dependencies.get(ref.origin).schema.classes[ref.name];
|
|
101
|
+
if (!admitsForeignSubclass(parent)) {
|
|
102
|
+
fail('BUILDER_CLASS_INHERITANCE', pointer, `Class ${ref.origin}:class.${ref.name} is ${inheritanceOf(parent)}: only an open Class admits a subclass of another Domain.`);
|
|
103
|
+
}
|
|
104
|
+
return ref;
|
|
105
|
+
}
|
|
93
106
|
resolveNodeClass(input, pointer) {
|
|
94
107
|
return this.resolveClass(input, 'node', pointer);
|
|
95
108
|
}
|
|
96
109
|
resolveEdgeClass(input, pointer) {
|
|
97
110
|
return this.resolveClass(input, 'edge', pointer);
|
|
98
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* The roles of a resolved Edge Class's source and target, or of an undirected Class's two
|
|
114
|
+
* endpoints in their stored order, which is the authored one.
|
|
115
|
+
*/
|
|
116
|
+
edgeRoles(ref) {
|
|
117
|
+
if (ref.origin === this.origin) {
|
|
118
|
+
const value = this.#localClasses.get(definitionRefIndex(ref));
|
|
119
|
+
if (value.orientation === 'directed') {
|
|
120
|
+
const input = classConfiguration(value);
|
|
121
|
+
return [input.source.as, input.target.as];
|
|
122
|
+
}
|
|
123
|
+
const input = classConfiguration(value);
|
|
124
|
+
return [input.endpoints[0].as, input.endpoints[1].as];
|
|
125
|
+
}
|
|
126
|
+
const definition = this.#dependencies.get(ref.origin).schema.classes[ref.name];
|
|
127
|
+
return definition.orientation === 'directed'
|
|
128
|
+
? [definition.endpoints.source.role, definition.endpoints.target.role]
|
|
129
|
+
: [definition.endpoints[0].role, definition.endpoints[1].role];
|
|
130
|
+
}
|
|
99
131
|
resolvePolicy(input, pointer) {
|
|
100
132
|
const value = resolveLazy(input, pointer);
|
|
101
133
|
if (typeof value !== 'object' || value === null) {
|
|
@@ -211,9 +243,6 @@ export class BuilderContext {
|
|
|
211
243
|
this.policyObjectRefs.add(policyObjectKey(ref));
|
|
212
244
|
}
|
|
213
245
|
}
|
|
214
|
-
function escapePointer(value) {
|
|
215
|
-
return value.replaceAll('~', '~0').replaceAll('/', '~1');
|
|
216
|
-
}
|
|
217
246
|
function isResolvedClass(value) {
|
|
218
247
|
if (typeof value !== 'object' || value === null)
|
|
219
248
|
return false;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { DomainSchemaEntry } from '../../../schema/dependency/lookup.js';
|
|
2
|
+
import type { DomainSchema } from '../../../schema/model/schema.js';
|
|
3
|
+
/**
|
|
4
|
+
* Authoring refuses two Edge Classes that acceptance keeps, because a stored Schema must decode
|
|
5
|
+
* again with the lifetimes it derives (BUILDER-EDGE-LIFETIMES):
|
|
6
|
+
* - one with an endpoint that can hold a Node of another Domain while an endpoint requires an Edge.
|
|
7
|
+
* It can neither restrict that Domain's deletions nor detach below the required count, so the
|
|
8
|
+
* required endpoint must become optional;
|
|
9
|
+
* - one whose lifetimes differ from those of an Edge Class it extends, the root Edge aside.
|
|
10
|
+
*/
|
|
11
|
+
export declare function assertAuthoredLifetimes(schema: DomainSchema, dependencies: readonly DomainSchemaEntry[]): void;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Key } from '../../../addressing/key.js';
|
|
2
|
+
import { definitionRefIndex } from '../../../addressing/ordering.js';
|
|
3
|
+
import { isGraphRoot } from '../../../language/class/inheritance.js';
|
|
4
|
+
import { contractEndpoints, edgeLifetimes, lifetimeScope, reachesAnotherDomain, requiredEndpoint, } from '../../../language/class/lifetime.js';
|
|
5
|
+
import { BuilderError, diagnostic, escapeToken } from '../../schema/diagnostic.js';
|
|
6
|
+
/**
|
|
7
|
+
* Authoring refuses two Edge Classes that acceptance keeps, because a stored Schema must decode
|
|
8
|
+
* again with the lifetimes it derives (BUILDER-EDGE-LIFETIMES):
|
|
9
|
+
* - one with an endpoint that can hold a Node of another Domain while an endpoint requires an Edge.
|
|
10
|
+
* It can neither restrict that Domain's deletions nor detach below the required count, so the
|
|
11
|
+
* required endpoint must become optional;
|
|
12
|
+
* - one whose lifetimes differ from those of an Edge Class it extends, the root Edge aside.
|
|
13
|
+
*/
|
|
14
|
+
export function assertAuthoredLifetimes(schema, dependencies) {
|
|
15
|
+
const classes = [
|
|
16
|
+
...Object.values(schema.classes),
|
|
17
|
+
...dependencies.flatMap((entry) => Object.values(entry.schema.classes)),
|
|
18
|
+
];
|
|
19
|
+
const scope = lifetimeScope(classes);
|
|
20
|
+
const declarations = new Map(classes.map((declaration) => [definitionRefIndex(declaration.ref), declaration]));
|
|
21
|
+
const diagnostics = Object.entries(schema.classes).flatMap(([name, declaration]) => {
|
|
22
|
+
if (declaration.kind !== 'edge')
|
|
23
|
+
return [];
|
|
24
|
+
const pointer = `/classes/${escapeToken(name)}`;
|
|
25
|
+
const endpoints = contractEndpoints(declaration);
|
|
26
|
+
const keys = declaration.orientation === 'directed' ? ['source', 'target'] : ['0', '1'];
|
|
27
|
+
const counts = declaration.orientation === 'directed' ? ['outgoing', 'incoming'] : ['incident', 'incident'];
|
|
28
|
+
const found = [];
|
|
29
|
+
const required = requiredEndpoint(declaration);
|
|
30
|
+
const reaching = endpoints.find(({ endpoint }) => reachesAnotherDomain(schema.origin, endpoint, scope));
|
|
31
|
+
if (required !== undefined && reaching !== undefined)
|
|
32
|
+
found.push(diagnostic('BUILDER_EDGE_LIFETIME', `${pointer}/endpoints/${keys[required.index]}/${counts[required.index]}`, `${Key.of(declaration.ref)} endpoint ${reaching.endpoint.role} can hold Nodes of another ` +
|
|
33
|
+
`Domain, so it cannot restrict their deletion, and endpoint ${required.endpoint.role} ` +
|
|
34
|
+
`requires ${required.count} Edges, so it cannot detach: make ${required.endpoint.role} optional.`));
|
|
35
|
+
const lifetimes = edgeLifetimes(declaration, scope);
|
|
36
|
+
declaration.extends.forEach((ref, index) => {
|
|
37
|
+
const parent = declarations.get(definitionRefIndex(ref));
|
|
38
|
+
if (parent?.kind !== 'edge' || isGraphRoot(parent))
|
|
39
|
+
return;
|
|
40
|
+
const inherited = edgeLifetimes(parent, scope);
|
|
41
|
+
const same = (order) => order.every((at, position) => lifetimes[position] === inherited[at]);
|
|
42
|
+
if (same([0, 1]) || (declaration.orientation === 'undirected' && same([1, 0])))
|
|
43
|
+
return;
|
|
44
|
+
found.push(diagnostic('BUILDER_EDGE_LIFETIME', `${pointer}/extends/${index}`, `${Key.of(declaration.ref)} has lifetimes ${spell(endpoints, lifetimes)}, and ` +
|
|
45
|
+
`${Key.of(parent.ref)} it extends has ${spell(contractEndpoints(parent), inherited)}: ` +
|
|
46
|
+
`an Edge Class keeps the lifetimes of the Classes it extends.`));
|
|
47
|
+
});
|
|
48
|
+
return found;
|
|
49
|
+
});
|
|
50
|
+
if (diagnostics.length > 0)
|
|
51
|
+
throw new BuilderError(diagnostics);
|
|
52
|
+
}
|
|
53
|
+
function spell(endpoints, lifetimes) {
|
|
54
|
+
return `${endpoints[0].endpoint.role} ${lifetimes[0]} and ${endpoints[1].endpoint.role} ${lifetimes[1]}`;
|
|
55
|
+
}
|
|
@@ -7,6 +7,7 @@ import { autoPropertyAuthoringInput, propertyAuthoringInput } from '../../class/
|
|
|
7
7
|
import { BuilderError } from '../../schema/diagnostic.js';
|
|
8
8
|
import { escapeToken, fail } from '../../schema/diagnostic.js';
|
|
9
9
|
import { isAuthoringValue } from '../../schema/handle.js';
|
|
10
|
+
import { lowerFileSchema } from './file.js';
|
|
10
11
|
import { lowerPathSchema } from './path.js';
|
|
11
12
|
import { convertZodToValueSchema, zodObjectPropertyIsOptional } from './zod.js';
|
|
12
13
|
export class BuilderValueSchemas {
|
|
@@ -23,7 +24,7 @@ export class BuilderValueSchemas {
|
|
|
23
24
|
}
|
|
24
25
|
properties(input, pointer) {
|
|
25
26
|
const fields = input ?? {};
|
|
26
|
-
const compiled =
|
|
27
|
+
const compiled = [];
|
|
27
28
|
for (const [name, value] of Object.entries(fields)) {
|
|
28
29
|
const auto = isAutoProperty(value) ? value : undefined;
|
|
29
30
|
const autoInput = auto === undefined ? undefined : autoPropertyAuthoringInput(auto);
|
|
@@ -33,27 +34,30 @@ export class BuilderValueSchemas {
|
|
|
33
34
|
const schemaInput = authoredInput === undefined ? value : authoredInput.schema;
|
|
34
35
|
const schema = this.lower(schemaInput, 'callable-output', `${propertyPointer}/schema`, 'object-property');
|
|
35
36
|
this.assertValid(schema, 'property-facet', `${propertyPointer}/schema`);
|
|
36
|
-
compiled[
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
? {}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
37
|
+
compiled.push([
|
|
38
|
+
name,
|
|
39
|
+
{
|
|
40
|
+
schema: canonicalizeValueSchema(schema, 'property-facet', this.registry),
|
|
41
|
+
required: authoredInput?.options.required ?? isRequired(schemaInput),
|
|
42
|
+
...(autoInput === undefined ? {} : { auto: autoInput.options }),
|
|
43
|
+
...(authoredInput?.options.immutable === undefined
|
|
44
|
+
? {}
|
|
45
|
+
: { immutable: authoredInput.options.immutable }),
|
|
46
|
+
...(authoredInput?.options.description === undefined
|
|
47
|
+
? {}
|
|
48
|
+
: { description: authoredInput.options.description }),
|
|
49
|
+
...(authoredInput?.machine === undefined
|
|
50
|
+
? {}
|
|
51
|
+
: {
|
|
52
|
+
state: {
|
|
53
|
+
initial: authoredInput.machine.initial,
|
|
54
|
+
transitions: authoredInput.machine.transitions,
|
|
55
|
+
},
|
|
56
|
+
}),
|
|
57
|
+
},
|
|
58
|
+
]);
|
|
55
59
|
}
|
|
56
|
-
return compiled;
|
|
60
|
+
return Object.fromEntries(compiled);
|
|
57
61
|
}
|
|
58
62
|
lower(input, conversionContext, pointer, zodPosition = 'value') {
|
|
59
63
|
let schema;
|
|
@@ -61,7 +65,10 @@ export class BuilderValueSchemas {
|
|
|
61
65
|
const converted = convertZodToValueSchema(input, conversionContext, this.registry, pointer, {
|
|
62
66
|
position: zodPosition,
|
|
63
67
|
validate: false,
|
|
64
|
-
override: (context) =>
|
|
68
|
+
override: (context) => {
|
|
69
|
+
lowerFileSchema(context);
|
|
70
|
+
lowerPathSchema(context, (accepts, markerPointer) => this.resolvePathAccepts(accepts, markerPointer), pointer);
|
|
71
|
+
},
|
|
65
72
|
});
|
|
66
73
|
if (!converted.ok)
|
|
67
74
|
throw new BuilderError(converted.diagnostics);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ZodValueSchemaOverrideContext } from './zod.js';
|
|
2
|
+
/**
|
|
3
|
+
* Lower an authored `file(...)` field to its `schema.values.file` shape. Every other keyword the
|
|
4
|
+
* Zod schema wrote stays: an annotation is kept, and a constraint makes the field non-canonical,
|
|
5
|
+
* which admission refuses.
|
|
6
|
+
*/
|
|
7
|
+
export declare function lowerFileSchema(context: ZodValueSchemaOverrideContext): void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { file } from '../../../language/value/model/file.js';
|
|
2
|
+
import { fileOptionsOfAuthoring } from '../../value/file.js';
|
|
3
|
+
/**
|
|
4
|
+
* Lower an authored `file(...)` field to its `schema.values.file` shape. Every other keyword the
|
|
5
|
+
* Zod schema wrote stays: an annotation is kept, and a constraint makes the field non-canonical,
|
|
6
|
+
* which admission refuses.
|
|
7
|
+
*/
|
|
8
|
+
export function lowerFileSchema(context) {
|
|
9
|
+
const options = fileOptionsOfAuthoring(context.zodSchema);
|
|
10
|
+
if (options === undefined)
|
|
11
|
+
return;
|
|
12
|
+
delete context.jsonSchema.type;
|
|
13
|
+
Object.assign(context.jsonSchema, file(options));
|
|
14
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { NodeClassReferenceInput } from '../../class/
|
|
1
|
+
import type { NodeClassReferenceInput } from '../../class/input.js';
|
|
2
2
|
import type { ZodValueSchemaOverrideContext } from './zod.js';
|
|
3
3
|
export declare function lowerPathSchema(context: ZodValueSchemaOverrideContext, resolveAccepts: (inputs: readonly NodeClassReferenceInput[], pointer: string) => readonly unknown[], pointer: string): void;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { escapePointerToken } from '../../../language/value/syntax/pointer.js';
|
|
1
2
|
import { pathAccepts } from '../../value/path-metadata.js';
|
|
2
3
|
export function lowerPathSchema(context, resolveAccepts, pointer) {
|
|
3
4
|
const inputs = pathAccepts(context.zodSchema);
|
|
4
5
|
if (inputs === undefined)
|
|
5
6
|
return;
|
|
6
|
-
const location = context.path.reduce((current, segment) => `${current}/${
|
|
7
|
+
const location = context.path.reduce((current, segment) => `${current}/${escapePointerToken(String(segment))}`, pointer);
|
|
7
8
|
for (const key of Object.keys(context.jsonSchema))
|
|
8
9
|
delete context.jsonSchema[key];
|
|
9
10
|
Object.assign(context.jsonSchema, {
|
|
@@ -15,6 +16,3 @@ export function lowerPathSchema(context, resolveAccepts, pointer) {
|
|
|
15
16
|
},
|
|
16
17
|
});
|
|
17
18
|
}
|
|
18
|
-
function escapeToken(value) {
|
|
19
|
-
return value.replaceAll('~', '~0').replaceAll('/', '~1');
|
|
20
|
-
}
|
|
@@ -4,7 +4,8 @@ import { canonicalizeValueSchema } from '../../../language/value/profile/canonic
|
|
|
4
4
|
import { validateValueSchema } from '../../../language/value/profile/validate.js';
|
|
5
5
|
import { isIRegexp } from '../../../language/value/regexp/syntax.js';
|
|
6
6
|
import { fullMatchSource } from '../../../language/value/syntax/full-match.js';
|
|
7
|
-
import {
|
|
7
|
+
import { escapePointerToken } from '../../../language/value/syntax/pointer.js';
|
|
8
|
+
import { BuilderError, diagnostic } from '../../schema/diagnostic.js';
|
|
8
9
|
/**
|
|
9
10
|
* Converts only Zod contracts whose JSON-value acceptance is represented
|
|
10
11
|
* without coercion, effects, custom predicates, or format assertions.
|
|
@@ -34,6 +35,7 @@ export function convertZodToValueSchema(zodSchema, context, registry, pointer =
|
|
|
34
35
|
path,
|
|
35
36
|
zodSchema: source,
|
|
36
37
|
});
|
|
38
|
+
keepLoweredShape(source, jsonSchema);
|
|
37
39
|
}
|
|
38
40
|
},
|
|
39
41
|
});
|
|
@@ -43,6 +45,9 @@ export function convertZodToValueSchema(zodSchema, context, registry, pointer =
|
|
|
43
45
|
}
|
|
44
46
|
}
|
|
45
47
|
catch (error) {
|
|
48
|
+
// Zod runs the override inside its conversion, so a refusal the override raises passes through here.
|
|
49
|
+
if (error instanceof BuilderError)
|
|
50
|
+
return { ok: false, diagnostics: error.diagnostics };
|
|
46
51
|
return {
|
|
47
52
|
ok: false,
|
|
48
53
|
diagnostics: [
|
|
@@ -61,6 +66,28 @@ export function convertZodToValueSchema(zodSchema, context, registry, pointer =
|
|
|
61
66
|
diagnostics: [],
|
|
62
67
|
};
|
|
63
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* The lowering keeps one spelling per contract, whatever Zod version renders it, so that a Domain
|
|
71
|
+
* built from unchanged source keeps its schema digest. Every node lowers as its own Zod schema: a
|
|
72
|
+
* union by `anyOf`, an intersection by `allOf`, a tuple by its `prefixItems` and rest alone. Zod
|
|
73
|
+
* 4.6 compacts bare-type unions into a `type` array, folds object intersections, and closes tuples;
|
|
74
|
+
* the marker leaves no node bare, so the first two do not apply, and the tuple bounds are removed.
|
|
75
|
+
* `copyZodJson` drops the marker.
|
|
76
|
+
*/
|
|
77
|
+
function keepLoweredShape(schema, jsonSchema) {
|
|
78
|
+
const def = getSchemaDefinition(schema);
|
|
79
|
+
if (def?.type === 'tuple' && Array.isArray(def.items)) {
|
|
80
|
+
if (jsonSchema.items === false)
|
|
81
|
+
delete jsonSchema.items;
|
|
82
|
+
if (jsonSchema.maxItems === def.items.length)
|
|
83
|
+
delete jsonSchema.maxItems;
|
|
84
|
+
if (typeof jsonSchema.minItems === 'number' && jsonSchema.minItems <= def.items.length) {
|
|
85
|
+
delete jsonSchema.minItems;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
jsonSchema[LOWERED_NODE] = true;
|
|
89
|
+
}
|
|
90
|
+
const LOWERED_NODE = '~astrale-lowered-node';
|
|
64
91
|
function copyZodJson(value) {
|
|
65
92
|
if (value === null || ['boolean', 'number', 'string'].includes(typeof value))
|
|
66
93
|
return value;
|
|
@@ -69,10 +96,12 @@ function copyZodJson(value) {
|
|
|
69
96
|
if (value === null || typeof value !== 'object') {
|
|
70
97
|
throw new TypeError('Zod emitted a non-JSON schema value.');
|
|
71
98
|
}
|
|
72
|
-
const
|
|
99
|
+
const members = [];
|
|
73
100
|
for (const key of Reflect.ownKeys(value)) {
|
|
74
101
|
if (typeof key === 'symbol')
|
|
75
102
|
throw new TypeError('Zod emitted symbol-keyed schema metadata.');
|
|
103
|
+
if (key === LOWERED_NODE)
|
|
104
|
+
continue;
|
|
76
105
|
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
77
106
|
if (descriptor === undefined)
|
|
78
107
|
continue;
|
|
@@ -83,9 +112,9 @@ function copyZodJson(value) {
|
|
|
83
112
|
}
|
|
84
113
|
if (!('value' in descriptor))
|
|
85
114
|
throw new TypeError(`Zod emitted accessor schema member ${key}.`);
|
|
86
|
-
|
|
115
|
+
members.push([key, copyZodJson(descriptor.value)]);
|
|
87
116
|
}
|
|
88
|
-
return
|
|
117
|
+
return Object.fromEntries(members);
|
|
89
118
|
}
|
|
90
119
|
/** Whether explicit Zod optionality makes a containing object property absent-able. */
|
|
91
120
|
export function zodObjectPropertyIsOptional(schema) {
|
|
@@ -116,6 +145,14 @@ function inspectZodSchema(root, pointer, position) {
|
|
|
116
145
|
if (def.coerce === true) {
|
|
117
146
|
diagnostics.push(diagnostic('ZOD_SCHEMA_NOT_LOSSLESS', schemaPointer, 'Zod coercion changes the accepted input domain and is not serializable as JSON Schema.'));
|
|
118
147
|
}
|
|
148
|
+
if (type === 'object' && Object.hasOwn(Object(def.shape), '__proto__')) {
|
|
149
|
+
diagnostics.push(diagnostic('ZOD_SCHEMA_NOT_LOSSLESS', `${schemaPointer}/properties/__proto__`, 'Zod renders no member named __proto__, while its object still requires that member.'));
|
|
150
|
+
}
|
|
151
|
+
if (type === 'record' && isZodType(def.keyType)) {
|
|
152
|
+
if (getSchemaDefinition(def.keyType)?.type === 'number') {
|
|
153
|
+
diagnostics.push(diagnostic('ZOD_SCHEMA_NOT_LOSSLESS', `${schemaPointer}/propertyNames`, 'Zod number record keys accept the member names that spell a number, which V1 states by no portable pattern.'));
|
|
154
|
+
}
|
|
155
|
+
}
|
|
119
156
|
inspectCheck(def, schemaPointer, diagnostics);
|
|
120
157
|
if (Array.isArray(def.checks)) {
|
|
121
158
|
def.checks.forEach((check, index) => {
|
|
@@ -289,9 +326,6 @@ function getCheckDefinition(value) {
|
|
|
289
326
|
function isZodType(value) {
|
|
290
327
|
return value instanceof ZodType;
|
|
291
328
|
}
|
|
292
|
-
function escapePointerToken(value) {
|
|
293
|
-
return value.replaceAll('~', '~0').replaceAll('/', '~1');
|
|
294
|
-
}
|
|
295
329
|
function isPlainRecord(value) {
|
|
296
330
|
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
297
331
|
}
|