@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,206 +1,24 @@
|
|
|
1
1
|
import { Key } from '../../../../addressing/index.js';
|
|
2
|
-
import {
|
|
3
|
-
import { branchesOf, branchProduct, capBranches, targetMode, termKey, } from '../../../../language/policy/analysis/branches.js';
|
|
2
|
+
import { PolicyTyping } from '../../../../language/policy/analysis/typing.js';
|
|
4
3
|
import {} from '../../../../language/policy/model/policy.js';
|
|
5
4
|
import {} from '../../../model/schema.js';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { CompiledUnionFind } from './equality.js';
|
|
9
|
-
import { compiledEdgeAlternatives } from './variants.js';
|
|
5
|
+
import { isCompiledEdge } from '../context.js';
|
|
6
|
+
import { referenceContract } from './contracts.js';
|
|
10
7
|
/** Types one entry's Policies against the Node Classes of its own closure, as source admission. */
|
|
11
|
-
export
|
|
12
|
-
context
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
expandedBranches(name, visiting, namespace) {
|
|
28
|
-
if (visiting.has(name))
|
|
29
|
-
return undefined;
|
|
30
|
-
const declaration = this.normalized.get(name);
|
|
31
|
-
if (declaration === undefined)
|
|
32
|
-
return undefined;
|
|
33
|
-
if ('match' in declaration)
|
|
34
|
-
return branchesOf(declaration.match, namespace);
|
|
35
|
-
const nested = new Set(visiting);
|
|
36
|
-
nested.add(name);
|
|
37
|
-
const refs = 'allOf' in declaration ? declaration.allOf : declaration.anyOf;
|
|
38
|
-
const children = [];
|
|
39
|
-
for (const [index, ref] of refs.entries()) {
|
|
40
|
-
if (ref.origin !== this.entry.origin || ref.kind !== 'policy')
|
|
41
|
-
return undefined;
|
|
42
|
-
const expanded = this.expandedBranches(ref.name, nested, `${namespace}/${index}:${ref.name}`);
|
|
43
|
-
if (expanded === undefined)
|
|
44
|
-
return undefined;
|
|
45
|
-
children.push(expanded);
|
|
46
|
-
}
|
|
47
|
-
return 'allOf' in declaration ? branchProduct(children) : capBranches(children.flat());
|
|
48
|
-
}
|
|
49
|
-
policyAccepts(name, object) {
|
|
50
|
-
return this.policyBranchTyping(name, object)?.every(Boolean) ?? false;
|
|
51
|
-
}
|
|
52
|
-
policyBranchTyping(name, object) {
|
|
53
|
-
const branches = this.expandedBranches(name, new Set(), `$use:${name}`);
|
|
54
|
-
return branches?.map((branch) => this.branchIsTyped(branch, { kind: 'object', object }));
|
|
55
|
-
}
|
|
56
|
-
policyAcceptsEdge(name, source, target) {
|
|
57
|
-
const branches = this.expandedBranches(name, new Set(), `$edge-use:${name}`);
|
|
58
|
-
return (branches !== undefined &&
|
|
59
|
-
branches.every((branch) => this.branchIsTyped(branch, { kind: 'edge', source, target })));
|
|
60
|
-
}
|
|
61
|
-
concreteEndpointClasses(accepts) {
|
|
62
|
-
return this.concreteNodeClasses.filter((candidate) => classSatisfiesAny(this.context, candidate, accepts));
|
|
63
|
-
}
|
|
64
|
-
endpointsOverlap(left, right) {
|
|
65
|
-
const seed = [{ kind: 'open', requirements: [] }];
|
|
66
|
-
return this.applyEndpoint(this.applyEndpoint(seed, left), right).length > 0;
|
|
67
|
-
}
|
|
68
|
-
branchIsTyped(branch, use) {
|
|
69
|
-
if (targetMode(branch) !== use.kind)
|
|
70
|
-
return false;
|
|
71
|
-
return compiledEdgeAlternatives(branch.edges, this).some((variants) => this.constraintsSatisfiable(branch, variants, use));
|
|
72
|
-
}
|
|
73
|
-
constraintsSatisfiable(branch, variants, use) {
|
|
74
|
-
const terms = new Set(use.kind === 'object' ? ['subject', 'object'] : ['subject', 'source', 'target']);
|
|
75
|
-
for (const key of branch.variables.keys())
|
|
76
|
-
terms.add(key);
|
|
77
|
-
for (const key of branch.terms.keys())
|
|
78
|
-
terms.add(key);
|
|
79
|
-
for (const edge of branch.edges) {
|
|
80
|
-
terms.add(termKey(edge.pattern.source, edge.namespace));
|
|
81
|
-
terms.add(termKey(edge.pattern.target, edge.namespace));
|
|
82
|
-
}
|
|
83
|
-
const union = new CompiledUnionFind(terms);
|
|
84
|
-
for (const [left, right] of branch.equalities)
|
|
85
|
-
union.join(left, right);
|
|
86
|
-
for (const variant of variants)
|
|
87
|
-
for (const [left, right] of variant.equalities)
|
|
88
|
-
union.join(left, right);
|
|
89
|
-
const constraints = new Map();
|
|
90
|
-
for (const variant of variants) {
|
|
91
|
-
for (const [term, accepts] of variant.constraints) {
|
|
92
|
-
const root = union.find(term);
|
|
93
|
-
const values = constraints.get(root) ?? [];
|
|
94
|
-
values.push(accepts);
|
|
95
|
-
constraints.set(root, values);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
const groups = new Map();
|
|
99
|
-
for (const term of terms) {
|
|
100
|
-
const root = union.find(term);
|
|
101
|
-
const values = groups.get(root) ?? [];
|
|
102
|
-
values.push(term);
|
|
103
|
-
groups.set(root, values);
|
|
104
|
-
}
|
|
105
|
-
for (const [root, members] of groups) {
|
|
106
|
-
let candidates = [{ kind: 'open', requirements: [] }];
|
|
107
|
-
for (const member of members) {
|
|
108
|
-
candidates = this.applyInitial(candidates, member, branch, use);
|
|
109
|
-
if (candidates.length === 0)
|
|
110
|
-
return false;
|
|
111
|
-
}
|
|
112
|
-
for (const endpoint of constraints.get(root) ?? []) {
|
|
113
|
-
candidates = this.applyEndpoint(candidates, endpoint);
|
|
114
|
-
if (candidates.length === 0)
|
|
115
|
-
return false;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
return true;
|
|
119
|
-
}
|
|
120
|
-
applyInitial(candidates, term, branch, use) {
|
|
121
|
-
if (term === 'subject')
|
|
122
|
-
return this.applyAnyNodeClass(candidates);
|
|
123
|
-
const contract = compiledTargetContract(term, use);
|
|
124
|
-
if (contract !== undefined) {
|
|
125
|
-
return contract.kind === 'exact'
|
|
126
|
-
? this.applyExact(candidates, contract.ref)
|
|
127
|
-
: uniqueCompiledCandidates(this.allNodeClasses.flatMap((ref) => this.applyExact(candidates, ref)));
|
|
128
|
-
}
|
|
129
|
-
const referenced = branch.terms.get(term);
|
|
130
|
-
if (referenced?.kind === 'ref') {
|
|
131
|
-
const contract = callableObjectContracts(this.context, this.entry, 0, undefined, referenced)?.[0];
|
|
132
|
-
return contract?.kind === 'exact' ? this.applyExact(candidates, contract.ref) : [];
|
|
133
|
-
}
|
|
134
|
-
const selector = branch.variables.get(term);
|
|
135
|
-
if (selector === undefined)
|
|
136
|
-
return [];
|
|
137
|
-
if (selector.kind === 'exact')
|
|
138
|
-
return this.applyExact(candidates, selector.class);
|
|
139
|
-
if (selector.kind === 'any')
|
|
140
|
-
return candidates;
|
|
141
|
-
return this.applyRequirement(candidates, selector.class);
|
|
142
|
-
}
|
|
143
|
-
applyExact(candidates, exact) {
|
|
144
|
-
return uniqueCompiledCandidates(candidates.flatMap((candidate) => {
|
|
145
|
-
if (candidate.kind === 'exact')
|
|
146
|
-
return Key.of(candidate.ref) === Key.of(exact) ? [candidate] : [];
|
|
147
|
-
return candidate.requirements.every((required) => classSatisfiesAny(this.context, exact, [required]))
|
|
148
|
-
? [{ kind: 'exact', ref: exact }]
|
|
149
|
-
: [];
|
|
150
|
-
}));
|
|
151
|
-
}
|
|
152
|
-
applyAnyNodeClass(candidates) {
|
|
153
|
-
return uniqueCompiledCandidates(candidates.flatMap((candidate) => candidate.kind === 'exact'
|
|
154
|
-
? [candidate]
|
|
155
|
-
: this.allNodeClasses
|
|
156
|
-
.filter((ref) => candidate.requirements.every((required) => classSatisfiesAny(this.context, ref, [required])))
|
|
157
|
-
.map((ref) => ({ kind: 'exact', ref }))));
|
|
158
|
-
}
|
|
159
|
-
applyRequirement(candidates, required) {
|
|
160
|
-
const result = [];
|
|
161
|
-
for (const candidate of candidates) {
|
|
162
|
-
if (candidate.kind === 'exact') {
|
|
163
|
-
if (classSatisfiesAny(this.context, candidate.ref, [required]))
|
|
164
|
-
result.push(candidate);
|
|
165
|
-
}
|
|
166
|
-
else {
|
|
167
|
-
result.push({
|
|
168
|
-
kind: 'open',
|
|
169
|
-
requirements: uniqueClassRefs([...candidate.requirements, required]),
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
return uniqueCompiledCandidates(result);
|
|
174
|
-
}
|
|
175
|
-
applyEndpoint(candidates, accepts) {
|
|
176
|
-
const result = [];
|
|
177
|
-
for (const candidate of candidates) {
|
|
178
|
-
if (candidate.kind === 'exact') {
|
|
179
|
-
if (classSatisfiesAny(this.context, candidate.ref, accepts))
|
|
180
|
-
result.push(candidate);
|
|
181
|
-
}
|
|
182
|
-
else {
|
|
183
|
-
for (const accept of accepts) {
|
|
184
|
-
result.push({
|
|
185
|
-
kind: 'open',
|
|
186
|
-
requirements: uniqueClassRefs([...candidate.requirements, accept]),
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
return uniqueCompiledCandidates(result);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
function uniqueCompiledCandidates(values) {
|
|
195
|
-
const result = new Map();
|
|
196
|
-
for (const value of values) {
|
|
197
|
-
const key = value.kind === 'exact'
|
|
198
|
-
? `exact:${Key.of(value.ref)}`
|
|
199
|
-
: `open:${value.requirements.map(Key.of).sort(compareUnicode).join('|')}`;
|
|
200
|
-
result.set(key, value);
|
|
201
|
-
}
|
|
202
|
-
return [...result.values()];
|
|
203
|
-
}
|
|
204
|
-
function uniqueClassRefs(values) {
|
|
205
|
-
return [...new Map(values.map((value) => [Key.of(value), value])).values()];
|
|
8
|
+
export function compiledPolicyTyping(context, entry, normalized, origins) {
|
|
9
|
+
const nodeClasses = [...context.classes.values()]
|
|
10
|
+
.map(({ value }) => value)
|
|
11
|
+
.filter((value) => value.kind === 'node' && origins.has(value.ref.origin));
|
|
12
|
+
return new PolicyTyping({
|
|
13
|
+
normalized,
|
|
14
|
+
allNodeClasses: nodeClasses.map((value) => value.ref),
|
|
15
|
+
concreteNodeClasses: nodeClasses.filter((value) => !value.abstract).map((value) => value.ref),
|
|
16
|
+
isLocalPolicy: (ref) => ref.origin === entry.origin && ref.kind === 'policy',
|
|
17
|
+
resolveClass: (ref) => context.classes.get(Key.of(ref))?.value,
|
|
18
|
+
edgeDeclaration: (ref) => {
|
|
19
|
+
const value = context.classes.get(Key.of(ref))?.value;
|
|
20
|
+
return value !== undefined && isCompiledEdge(value) ? value : undefined;
|
|
21
|
+
},
|
|
22
|
+
referenceContract: (ref) => referenceContract(context, ref),
|
|
23
|
+
});
|
|
206
24
|
}
|
|
@@ -2,5 +2,8 @@ import { type Value as JsonValue, type Object as JsonObject } from '@astrale-os/
|
|
|
2
2
|
import { type ValueProgram, type CompiledFunction } from '../../model/schema.js';
|
|
3
3
|
/** Decode one Function declaration and its callable contract. */
|
|
4
4
|
export declare function compiledFunction(input: JsonValue, values: readonly ValueProgram[], path: string): CompiledFunction;
|
|
5
|
-
/**
|
|
6
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Check the shared Function and Method wire grammar and return the Callable with the fields its input
|
|
7
|
+
* derives. The revision leaves fields out, so the received ones are not read.
|
|
8
|
+
*/
|
|
9
|
+
export declare function compiledCallable(input: JsonValue, values: readonly ValueProgram[], method: boolean, path: string): JsonObject;
|
|
@@ -1,22 +1,26 @@
|
|
|
1
1
|
import {} from '@astrale-os/kernel-dsl/value';
|
|
2
|
+
import { isAdmissionMaxAge } from '../../../language/callable/admission.js';
|
|
3
|
+
import { inputFieldNodes } from '../../../language/value/compile/fields.js';
|
|
2
4
|
import {} from '../../model/schema.js';
|
|
3
|
-
import { invalid
|
|
5
|
+
import { invalid } from '../diagnostic.js';
|
|
4
6
|
import { callablePolicy } from './policy.js';
|
|
5
7
|
import { definitionRef } from './reference.js';
|
|
6
|
-
import { object, exact, memberName, boolean, description, index, integer
|
|
8
|
+
import { object, exact, memberName, boolean, description, index, integer } from './value.js';
|
|
7
9
|
/** Decode one Function declaration and its callable contract. */
|
|
8
10
|
export function compiledFunction(input, values, path) {
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return value;
|
|
11
|
+
const callable = compiledCallable(input, values, false, path);
|
|
12
|
+
definitionRef(callable.ref, 'function', 'Function ref', `${path}/ref`);
|
|
13
|
+
return callable;
|
|
13
14
|
}
|
|
14
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* Check the shared Function and Method wire grammar and return the Callable with the fields its input
|
|
17
|
+
* derives. The revision leaves fields out, so the received ones are not read.
|
|
18
|
+
*/
|
|
15
19
|
export function compiledCallable(input, values, method, path) {
|
|
16
20
|
const value = object(input, 'Compiled Callable', path);
|
|
17
21
|
exact(value, method
|
|
18
22
|
? ['name', 'auth', 'static', 'abstract', 'input', 'output']
|
|
19
|
-
: ['ref', 'auth', 'input', 'output'], 'Compiled Callable', path, ['policy', 'description', 'execution', 'fields']);
|
|
23
|
+
: ['ref', 'auth', 'input', 'output'], 'Compiled Callable', path, ['policy', 'description', 'execution', 'admission', 'fields']);
|
|
20
24
|
if (method) {
|
|
21
25
|
memberName(value.name, 'Method name', `${path}/name`);
|
|
22
26
|
boolean(value.static, 'Method static', `${path}/static`);
|
|
@@ -47,18 +51,6 @@ export function compiledCallable(input, values, method, path) {
|
|
|
47
51
|
else {
|
|
48
52
|
inputIndex = index(value.input, values.length, 'Callable input', `${path}/input`);
|
|
49
53
|
}
|
|
50
|
-
if (value.fields !== undefined) {
|
|
51
|
-
const fieldsPath = `${path}/fields`;
|
|
52
|
-
for (const [field, nodes] of Object.entries(object(value.fields, 'Callable fields', fieldsPath))) {
|
|
53
|
-
const fieldPath = pointer(fieldsPath, field);
|
|
54
|
-
const fieldNodes = array(nodes, 'Callable field nodes', fieldPath);
|
|
55
|
-
if (fieldNodes.length === 0)
|
|
56
|
-
invalid('Callable field nodes', undefined, fieldPath);
|
|
57
|
-
for (const [indexValue, node] of fieldNodes.entries()) {
|
|
58
|
-
index(node, values[inputIndex].nodes.length, 'Callable field', `${fieldPath}/${indexValue}`);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
54
|
const outputPath = `${path}/output`;
|
|
63
55
|
const output = object(value.output, 'Callable output', outputPath);
|
|
64
56
|
if (output.mode === 'binary')
|
|
@@ -87,4 +79,16 @@ export function compiledCallable(input, values, method, path) {
|
|
|
87
79
|
invalid('durable Callable output', 'COMPILED_SOURCE_INVALID', `${outputPath}/mode`);
|
|
88
80
|
}
|
|
89
81
|
}
|
|
82
|
+
if (value.admission !== undefined) {
|
|
83
|
+
const admissionPath = `${path}/admission`;
|
|
84
|
+
const admission = object(value.admission, 'Callable admission', admissionPath);
|
|
85
|
+
exact(admission, ['maxAge'], 'Callable admission', admissionPath);
|
|
86
|
+
// An absent admission age is the only spelling of a call admitted afresh.
|
|
87
|
+
if (!isAdmissionMaxAge(admission.maxAge)) {
|
|
88
|
+
invalid('Callable admission age', 'COMPILED_SOURCE_INVALID', `${admissionPath}/maxAge`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const { fields: _, ...declared } = value;
|
|
92
|
+
const fields = inputFieldNodes(values[inputIndex]);
|
|
93
|
+
return fields === undefined ? declared : { ...declared, fields };
|
|
90
94
|
}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import {} from '@astrale-os/kernel-dsl/value';
|
|
2
2
|
import { Key } from '../../../addressing/index.js';
|
|
3
3
|
import { MEDIA_TYPE_PATTERN } from '../../../language/class/model/data.js';
|
|
4
|
+
import { compareEdgeUniqueTuples, compareNodeUniqueTuples, edgeUniqueTuple, nodeUniqueTuple, } from '../../../language/class/unique.js';
|
|
5
|
+
import { CLASS_OPERATIONS, isClassObservation } from '../../../language/policy/model/policy.js';
|
|
4
6
|
import {} from '../../model/schema.js';
|
|
5
7
|
import { invalid } from '../diagnostic.js';
|
|
6
8
|
import { compiledCallable } from './callable.js';
|
|
7
9
|
import { classRuleChecks } from './policy.js';
|
|
8
10
|
import { compiledProperty } from './property.js';
|
|
9
11
|
import { definitionRef } from './reference.js';
|
|
10
|
-
import { object, exact, boolean, description, array, unique, boundedString,
|
|
12
|
+
import { object, exact, boolean, description, array, unique, boundedString, memberName, } from './value.js';
|
|
11
13
|
/** Decode one Node or Edge Class with its declared members. */
|
|
12
14
|
export function compiledClass(input, values, path) {
|
|
13
15
|
const value = object(input, 'Compiled Class', path);
|
|
@@ -25,9 +27,15 @@ export function compiledClass(input, values, path) {
|
|
|
25
27
|
'constraints',
|
|
26
28
|
'properties',
|
|
27
29
|
'policies',
|
|
28
|
-
], 'Compiled Class', path, value.kind === 'node'
|
|
30
|
+
], 'Compiled Class', path, value.kind === 'node'
|
|
31
|
+
? ['data', 'description', 'icon', 'inheritance', 'unique']
|
|
32
|
+
: ['description', 'inheritance', 'unique']);
|
|
29
33
|
definitionRef(value.ref, 'class', 'Class ref', `${path}/ref`);
|
|
30
34
|
boolean(value.abstract, 'Class abstract', `${path}/abstract`);
|
|
35
|
+
if (value.inheritance !== undefined &&
|
|
36
|
+
value.inheritance !== 'open' &&
|
|
37
|
+
value.inheritance !== 'final')
|
|
38
|
+
invalid('Class inheritance', undefined, `${path}/inheritance`);
|
|
31
39
|
description(value.description, 'Class description', `${path}/description`);
|
|
32
40
|
const extendsPath = `${path}/extends`;
|
|
33
41
|
const parents = array(value.extends, 'Class extends', extendsPath).map((parent, index) => definitionRef(parent, 'class', 'Class parent', `${extendsPath}/${index}`));
|
|
@@ -40,40 +48,43 @@ export function compiledClass(input, values, path) {
|
|
|
40
48
|
dataDefinition(value.data, `${path}/data`);
|
|
41
49
|
boundedString(value.icon, 1, 8000, 'Class icon', `${path}/icon`);
|
|
42
50
|
classPolicies(value.policies, 'node', `${path}/policies`);
|
|
51
|
+
if (value.unique !== undefined)
|
|
52
|
+
nodeUniqueTuples(value.unique, `${path}/unique`);
|
|
43
53
|
const methodsPath = `${path}/methods`;
|
|
44
|
-
const methods = array(value.methods, 'Class methods', methodsPath);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
unique(methods.map((method, index) => string(object(method, 'Compiled Method', `${methodsPath}/${index}`).name, 'Method name', `${methodsPath}/${index}/name`)), 'Class Methods', methodsPath);
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
classPolicies(value.policies, 'edge', `${path}/policies`);
|
|
51
|
-
edgeContract(value, path);
|
|
54
|
+
const methods = array(value.methods, 'Class methods', methodsPath).map((method, index) => compiledCallable(method, values, true, `${methodsPath}/${index}`));
|
|
55
|
+
unique(methods.map((method) => method.name), 'Class Methods', methodsPath);
|
|
56
|
+
return { ...value, properties, methods };
|
|
52
57
|
}
|
|
58
|
+
classPolicies(value.policies, 'edge', `${path}/policies`);
|
|
59
|
+
edgeContract(value, path);
|
|
53
60
|
return { ...value, properties };
|
|
54
61
|
}
|
|
55
62
|
function classPolicies(input, kind, path) {
|
|
56
63
|
const value = object(input, 'Class Policies', path);
|
|
57
|
-
exact(value, [], 'Class Policies', path,
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
64
|
+
exact(value, [], 'Class Policies', path, CLASS_OPERATIONS);
|
|
65
|
+
for (const operation of CLASS_OPERATIONS) {
|
|
66
|
+
const policy = value[operation];
|
|
67
|
+
if (policy === undefined)
|
|
68
|
+
continue;
|
|
69
|
+
const label = `Class ${operation} Policy`;
|
|
70
|
+
const slot = `${path}/${operation}`;
|
|
71
|
+
if (isRuleChecks(policy)) {
|
|
72
|
+
classRuleChecks(policy, slot, kind === 'node' && operation === 'create' ? 'create' : 'class');
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
// Each slot spells one constant, and a Node create rule has no Node for a named Policy alone.
|
|
76
|
+
if (policy === !isClassObservation(operation))
|
|
77
|
+
continue;
|
|
78
|
+
if (kind === 'node' && operation === 'create')
|
|
79
|
+
invalid(label, undefined, slot);
|
|
80
|
+
definitionRef(policy, 'policy', label, slot);
|
|
81
|
+
}
|
|
62
82
|
}
|
|
63
|
-
/**
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
*/
|
|
67
|
-
function classPolicy(input, kind, label, path) {
|
|
68
|
-
if (kind === 'node' &&
|
|
69
|
-
input !== null &&
|
|
83
|
+
/** Policy checks, as opposed to a constant or a named Policy. */
|
|
84
|
+
function isRuleChecks(input) {
|
|
85
|
+
return (input !== null &&
|
|
70
86
|
typeof input === 'object' &&
|
|
71
|
-
['check', 'sameNode', 'allOf', 'anyOf'].some((key) => Object.hasOwn(input, key)))
|
|
72
|
-
classRuleChecks(input, path);
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
if (input !== false)
|
|
76
|
-
definitionRef(input, 'policy', label, path);
|
|
87
|
+
['check', 'sameNode', 'allOf', 'anyOf'].some((key) => Object.hasOwn(input, key)));
|
|
77
88
|
}
|
|
78
89
|
function edgeContract(value, path) {
|
|
79
90
|
const constraintsPath = `${path}/constraints`;
|
|
@@ -93,9 +104,13 @@ function edgeContract(value, path) {
|
|
|
93
104
|
object(endpoints.target, 'directed Edge target', `${endpointsPath}/target`).role) {
|
|
94
105
|
invalid('Edge endpoint roles', undefined, endpointsPath);
|
|
95
106
|
}
|
|
107
|
+
if (value.unique !== undefined)
|
|
108
|
+
uniqueTuples(value.unique, `${path}/unique`);
|
|
96
109
|
return;
|
|
97
110
|
}
|
|
98
|
-
if (value.orientation !== 'undirected' ||
|
|
111
|
+
if (value.orientation !== 'undirected' ||
|
|
112
|
+
constraints.acyclic !== undefined ||
|
|
113
|
+
value.unique !== undefined) {
|
|
99
114
|
invalid('Edge orientation', undefined, `${path}/orientation`);
|
|
100
115
|
}
|
|
101
116
|
const endpointsPath = `${path}/endpoints`;
|
|
@@ -109,9 +124,41 @@ function edgeContract(value, path) {
|
|
|
109
124
|
invalid('Edge endpoint roles', undefined, endpointsPath);
|
|
110
125
|
}
|
|
111
126
|
}
|
|
127
|
+
/** A nonempty list of canonical tuples (`edgeUniqueTuple`), distinct and in canonical order. */
|
|
128
|
+
function uniqueTuples(input, path) {
|
|
129
|
+
const tuples = array(input, 'Edge unique tuples', path);
|
|
130
|
+
if (tuples.length === 0)
|
|
131
|
+
invalid('Edge unique tuples', undefined, path);
|
|
132
|
+
const known = tuples.map((tuple, index) => {
|
|
133
|
+
const fields = edgeUniqueTuple(array(tuple, 'Edge unique tuple', `${path}/${index}`));
|
|
134
|
+
if (fields === undefined)
|
|
135
|
+
invalid('Edge unique tuple', undefined, `${path}/${index}`);
|
|
136
|
+
return fields;
|
|
137
|
+
});
|
|
138
|
+
for (const [index, tuple] of known.entries()) {
|
|
139
|
+
if (index > 0 && compareEdgeUniqueTuples(known[index - 1], tuple) >= 0)
|
|
140
|
+
invalid('Edge unique tuples', undefined, `${path}/${index}`);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
/** A nonempty list of canonical Node tuples (`nodeUniqueTuple`), distinct and in canonical order. */
|
|
144
|
+
function nodeUniqueTuples(input, path) {
|
|
145
|
+
const tuples = array(input, 'Node unique tuples', path);
|
|
146
|
+
if (tuples.length === 0)
|
|
147
|
+
invalid('Node unique tuples', undefined, path);
|
|
148
|
+
const known = tuples.map((tuple, index) => {
|
|
149
|
+
const keys = nodeUniqueTuple(array(tuple, 'Node unique tuple', `${path}/${index}`));
|
|
150
|
+
if (keys === undefined)
|
|
151
|
+
invalid('Node unique tuple', undefined, `${path}/${index}`);
|
|
152
|
+
return keys;
|
|
153
|
+
});
|
|
154
|
+
for (const [index, tuple] of known.entries()) {
|
|
155
|
+
if (index > 0 && compareNodeUniqueTuples(known[index - 1], tuple) >= 0)
|
|
156
|
+
invalid('Node unique tuples', undefined, `${path}/${index}`);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
112
159
|
function edgeEndpoint(input, count, label, path) {
|
|
113
160
|
const value = object(input, label, path);
|
|
114
|
-
exact(value, ['role', 'accepts', count], label, path);
|
|
161
|
+
exact(value, ['role', 'accepts', count], label, path, ['onDelete']);
|
|
115
162
|
memberName(value.role, `${label} role`, `${path}/role`);
|
|
116
163
|
const acceptsPath = `${path}/accepts`;
|
|
117
164
|
const accepts = array(value.accepts, `${label} accepts`, acceptsPath).map((item, index) => definitionRef(item, 'class', `${label} accepted Class`, `${acceptsPath}/${index}`));
|
|
@@ -124,6 +171,8 @@ function edgeEndpoint(input, count, label, path) {
|
|
|
124
171
|
value[count] !== '1') {
|
|
125
172
|
invalid(`${label} ${count}`, undefined, `${path}/${count}`);
|
|
126
173
|
}
|
|
174
|
+
if (value.onDelete !== undefined && value.onDelete !== 'restrict' && value.onDelete !== 'detach')
|
|
175
|
+
invalid(`${label} onDelete`, undefined, `${path}/onDelete`);
|
|
127
176
|
}
|
|
128
177
|
function dataDefinition(input, path) {
|
|
129
178
|
const value = object(input, 'Class data', path);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Value as JsonValue } from '@astrale-os/kernel-dsl/value';
|
|
2
2
|
import { type CompiledSchemaEntry } from '../../model/schema.js';
|
|
3
|
-
import { type Machines } from './
|
|
3
|
+
import { type Machines } from './program.js';
|
|
4
4
|
/** Decode one closure entry and verify its exact semantic revision. */
|
|
5
5
|
export declare function entry(input: JsonValue, entryIndex: number, path: string, machines: Machines): CompiledSchemaEntry;
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import {} from '@astrale-os/kernel-dsl/value';
|
|
2
2
|
import {} from '../../../addressing/index.js';
|
|
3
3
|
import * as metadata from '../../../language/definition/metadata.js';
|
|
4
|
-
import {
|
|
4
|
+
import { indexValuePrograms } from '../../../language/value/compile/load.js';
|
|
5
5
|
import {} from '../../model/schema.js';
|
|
6
|
-
import { invalid, pointer } from '../diagnostic.js';
|
|
6
|
+
import { invalid, pointer, withinEncodingLimits } from '../diagnostic.js';
|
|
7
7
|
import { revisionOfCompiledEntry } from '../revision.js';
|
|
8
8
|
import { compiledFunction } from './callable.js';
|
|
9
9
|
import { compiledClass } from './class.js';
|
|
10
10
|
import { compiledCoreDefinition, compiledCoreEdge } from './core.js';
|
|
11
11
|
import { originValue, revisionValue, dependencyMap } from './dependency.js';
|
|
12
|
-
import { pattern } from './pattern.js';
|
|
13
12
|
import { compiledPolicy } from './policy.js';
|
|
14
13
|
import { program } from './program.js';
|
|
15
14
|
import { definitionRef } from './reference.js';
|
|
@@ -18,13 +17,14 @@ import { compiledView } from './view.js';
|
|
|
18
17
|
/** Decode one closure entry and verify its exact semantic revision. */
|
|
19
18
|
export function entry(input, entryIndex, path, machines) {
|
|
20
19
|
const value = object(input, `closure[${entryIndex}]`, path);
|
|
21
|
-
exact(value, ['origin', 'revision', 'name', 'dependencies', 'definitions', 'facts', 'values'
|
|
20
|
+
exact(value, ['origin', 'revision', 'name', 'dependencies', 'definitions', 'facts', 'values'], 'entry', path, ['icon', 'entrypoint', 'patterns']);
|
|
22
21
|
const origin = originValue(value.origin, 'entry origin', `${path}/origin`);
|
|
23
22
|
const name = string(value.name, 'entry name', `${path}/name`);
|
|
24
23
|
if (name.length < metadata.name.minLength ||
|
|
25
24
|
name.length > metadata.name.maxLength ||
|
|
26
25
|
!metadata.isDomainNameText(name))
|
|
27
26
|
invalid('entry name', undefined, `${path}/name`);
|
|
27
|
+
const icon = value.icon === undefined ? undefined : domainIcon(value.icon, `${path}/icon`);
|
|
28
28
|
const entrypoint = value.entrypoint === undefined
|
|
29
29
|
? undefined
|
|
30
30
|
: definitionRef(value.entrypoint, 'view', 'entry entrypoint', `${path}/entrypoint`);
|
|
@@ -38,17 +38,14 @@ export function entry(input, entryIndex, path, machines) {
|
|
|
38
38
|
dependencyOrigins.add(dependency.origin);
|
|
39
39
|
}
|
|
40
40
|
const valuesPath = `${path}/values`;
|
|
41
|
-
const
|
|
42
|
-
const patterns = array(value.patterns, 'entry patterns', patternsPath).map((item, index) => pattern(item, index, `${patternsPath}/${index}`, machines));
|
|
43
|
-
const values = array(value.values, 'values', valuesPath).map((item, index) => program(item, index, `${valuesPath}/${index}`, patterns));
|
|
44
|
-
const bound = values.map((value) => bindValueProgram(value, patterns));
|
|
41
|
+
const programs = array(value.values, 'values', valuesPath).map((item, index) => program(item, index, `${valuesPath}/${index}`, machines));
|
|
45
42
|
const definitionsPath = `${path}/definitions`;
|
|
46
43
|
const definitions = object(value.definitions, 'definitions', definitionsPath);
|
|
47
44
|
exact(definitions, ['classes', 'functions', 'policies', 'views', 'core'], 'definitions', definitionsPath);
|
|
48
45
|
const classesPath = `${definitionsPath}/classes`;
|
|
49
|
-
const classes = array(definitions.classes, 'classes', classesPath).map((item, index) => compiledClass(item,
|
|
46
|
+
const classes = array(definitions.classes, 'classes', classesPath).map((item, index) => compiledClass(item, programs, `${classesPath}/${index}`));
|
|
50
47
|
const functionsPath = `${definitionsPath}/functions`;
|
|
51
|
-
const functions = array(definitions.functions, 'functions', functionsPath).map((item, index) => compiledFunction(item,
|
|
48
|
+
const functions = array(definitions.functions, 'functions', functionsPath).map((item, index) => compiledFunction(item, programs, `${functionsPath}/${index}`));
|
|
52
49
|
const factsPath = `${path}/facts`;
|
|
53
50
|
const facts = object(value.facts, 'facts', factsPath);
|
|
54
51
|
exact(facts, ['core'], 'facts', factsPath);
|
|
@@ -60,6 +57,7 @@ export function entry(input, entryIndex, path, machines) {
|
|
|
60
57
|
origin,
|
|
61
58
|
revision,
|
|
62
59
|
name,
|
|
60
|
+
...(icon === undefined ? {} : { icon }),
|
|
63
61
|
...(entrypoint === undefined ? {} : { entrypoint }),
|
|
64
62
|
dependencies,
|
|
65
63
|
definitions: {
|
|
@@ -72,8 +70,7 @@ export function entry(input, entryIndex, path, machines) {
|
|
|
72
70
|
facts: {
|
|
73
71
|
core: array(facts.core, 'core facts', coreFactsPath).map((item, index) => compiledCoreEdge(item, `${coreFactsPath}/${index}`)),
|
|
74
72
|
},
|
|
75
|
-
|
|
76
|
-
patterns,
|
|
73
|
+
...indexValuePrograms(programs),
|
|
77
74
|
};
|
|
78
75
|
const collections = [
|
|
79
76
|
['classes', accepted.definitions.classes],
|
|
@@ -93,8 +90,34 @@ export function entry(input, entryIndex, path, machines) {
|
|
|
93
90
|
!accepted.definitions.views.some(({ ref, target }) => ref.name === entrypoint.name && target.kind === 'domain'))) {
|
|
94
91
|
invalid('entry entrypoint', undefined, `${path}/entrypoint`);
|
|
95
92
|
}
|
|
96
|
-
if (revisionOfCompiledEntry(accepted) !== revision) {
|
|
93
|
+
if (withinEncodingLimits(path, () => revisionOfCompiledEntry(accepted)) !== revision) {
|
|
97
94
|
invalid('entry revision', 'COMPILED_CANONICAL_MISMATCH', `${path}/revision`);
|
|
98
95
|
}
|
|
99
96
|
return accepted;
|
|
100
97
|
}
|
|
98
|
+
/** Decode the source Domain icon under the same admission as its source schema (DV_DOMAIN_ICON). */
|
|
99
|
+
function domainIcon(input, path) {
|
|
100
|
+
const value = object(input, 'entry icon', path);
|
|
101
|
+
exact(value, [], 'entry icon', path, metadata.DOMAIN_ICON_SIZES);
|
|
102
|
+
const icon = {};
|
|
103
|
+
for (const size of metadata.DOMAIN_ICON_SIZES) {
|
|
104
|
+
if (value[size] === undefined)
|
|
105
|
+
continue;
|
|
106
|
+
const sizePath = `${path}/${size}`;
|
|
107
|
+
const art = object(value[size], 'entry icon size', sizePath);
|
|
108
|
+
exact(art, ['svg'], 'entry icon size', sizePath, ['dark']);
|
|
109
|
+
const drawing = (variant) => {
|
|
110
|
+
const text = string(art[variant], 'entry icon drawing', `${sizePath}/${variant}`);
|
|
111
|
+
if (metadata.domainIconSvgIssue(text, size) !== undefined)
|
|
112
|
+
invalid('entry icon drawing', undefined, `${sizePath}/${variant}`);
|
|
113
|
+
return text;
|
|
114
|
+
};
|
|
115
|
+
icon[size] = {
|
|
116
|
+
svg: drawing('svg'),
|
|
117
|
+
...(art.dark === undefined ? {} : { dark: drawing('dark') }),
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
if (Object.keys(icon).length === 0)
|
|
121
|
+
invalid('entry icon', undefined, path);
|
|
122
|
+
return icon;
|
|
123
|
+
}
|
|
@@ -4,7 +4,8 @@ export declare function compiledPolicy(input: JsonValue, path: string): never;
|
|
|
4
4
|
/** Check one callable's caller rule: `true`, the rule every caller satisfies, or Policy checks. */
|
|
5
5
|
export declare function callablePolicy(input: JsonValue | undefined, path: string): void;
|
|
6
6
|
/**
|
|
7
|
-
* Check one
|
|
8
|
-
* spelling. A lone check of `self` is spelled as the Policy
|
|
7
|
+
* Check one Class rule: Policy checks over `self` and `ref` objects only, or, in a Node create
|
|
8
|
+
* rule, `ref` objects only, in their one spelling. A lone check of `self` is spelled as the Policy
|
|
9
|
+
* reference itself.
|
|
9
10
|
*/
|
|
10
|
-
export declare function classRuleChecks(input: JsonValue, path: string): void;
|
|
11
|
+
export declare function classRuleChecks(input: JsonValue, path: string, site: 'class' | 'create'): void;
|