@astrale-os/kernel-dsl 0.2.0-beta.8 → 0.2.0
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 +5 -4
- package/dist/v1/addressing/method-key.js +3 -2
- package/dist/v1/addressing/patterns.d.ts +0 -5
- package/dist/v1/addressing/patterns.js +5 -5
- package/dist/v1/builder/callable/authoring.d.ts +87 -41
- package/dist/v1/builder/callable/authoring.js +29 -14
- package/dist/v1/builder/class/authoring.d.ts +311 -36
- package/dist/v1/builder/class/authoring.js +3 -4
- package/dist/v1/builder/class/property.d.ts +16 -8
- package/dist/v1/builder/class/property.js +21 -5
- package/dist/v1/builder/core/authoring.d.ts +28 -13
- package/dist/v1/builder/core/authoring.js +22 -2
- package/dist/v1/builder/index.d.ts +9 -8
- package/dist/v1/builder/index.js +2 -2
- package/dist/v1/builder/lowering/callable.d.ts +3 -1
- package/dist/v1/builder/lowering/callable.js +43 -51
- package/dist/v1/builder/lowering/class.d.ts +7 -0
- package/dist/v1/builder/lowering/class.js +79 -29
- package/dist/v1/builder/lowering/core.d.ts +3 -2
- package/dist/v1/builder/lowering/core.js +9 -6
- package/dist/v1/builder/lowering/policy.d.ts +8 -1
- package/dist/v1/builder/lowering/policy.js +35 -0
- package/dist/v1/builder/lowering/schema/capture.js +9 -4
- package/dist/v1/builder/lowering/schema/compile.d.ts +2 -2
- package/dist/v1/builder/lowering/schema/compile.js +15 -2
- package/dist/v1/builder/lowering/schema/context.d.ts +11 -8
- package/dist/v1/builder/lowering/schema/context.js +59 -29
- package/dist/v1/builder/lowering/schema/ownership.d.ts +3 -3
- package/dist/v1/builder/lowering/schema/ownership.js +2 -1
- package/dist/v1/builder/lowering/value/compile.js +14 -4
- package/dist/v1/builder/lowering/value/zod.d.ts +7 -6
- package/dist/v1/builder/lowering/value/zod.js +16 -7
- package/dist/v1/builder/lowering/view.d.ts +4 -3
- package/dist/v1/builder/lowering/view.js +2 -14
- package/dist/v1/builder/policy/authoring.d.ts +23 -6
- package/dist/v1/builder/policy/authoring.js +35 -8
- package/dist/v1/builder/schema/define.d.ts +8 -5
- package/dist/v1/builder/schema/diagnostic.d.ts +1 -1
- package/dist/v1/builder/schema/handle.d.ts +2 -1
- package/dist/v1/builder/schema/input.d.ts +9 -1
- package/dist/v1/builder/schema/projection/callable.d.ts +51 -0
- package/dist/v1/builder/schema/projection/callable.js +1 -0
- package/dist/v1/builder/schema/projection/class.d.ts +89 -0
- package/dist/v1/builder/schema/projection/class.js +1 -0
- package/dist/v1/builder/schema/projection/core-input.d.ts +32 -0
- package/dist/v1/builder/schema/projection/core-input.js +1 -0
- package/dist/v1/builder/schema/projection/domain.d.ts +59 -0
- package/dist/v1/builder/schema/projection/domain.js +1 -0
- package/dist/v1/builder/schema/projection/identity.d.ts +39 -0
- package/dist/v1/builder/schema/projection/identity.js +1 -0
- package/dist/v1/builder/schema/projection/model.d.ts +59 -0
- package/dist/v1/builder/schema/projection/model.js +1 -0
- package/dist/v1/builder/schema/projection/property.d.ts +32 -0
- package/dist/v1/builder/schema/projection/property.js +1 -0
- package/dist/v1/builder/schema/projection/resolved-class.d.ts +76 -0
- package/dist/v1/builder/schema/projection/resolved-class.js +1 -0
- package/dist/v1/builder/schema/projection.d.ts +4 -258
- package/dist/v1/builder/value/full-match.js +6 -3
- package/dist/v1/builder/value/path.d.ts +2 -2
- package/dist/v1/builder/value/path.js +2 -2
- package/dist/v1/builder/view/authoring.d.ts +6 -14
- package/dist/v1/builder/view/authoring.js +13 -5
- package/dist/v1/bundle/structure.d.ts +2 -1
- package/dist/v1/compiled/admission/accept.d.ts +1 -1
- package/dist/v1/compiled/admission/accept.js +11 -814
- package/dist/v1/compiled/admission/closure.d.ts +3 -0
- package/dist/v1/compiled/admission/closure.js +173 -0
- package/dist/v1/compiled/admission/diagnostic.d.ts +7 -0
- package/dist/v1/compiled/admission/diagnostic.js +13 -0
- package/dist/v1/compiled/admission/revision.js +9 -1
- package/dist/v1/compiled/admission/semantics/cardinality.d.ts +5 -0
- package/dist/v1/compiled/admission/semantics/cardinality.js +113 -0
- package/dist/v1/compiled/admission/semantics/class.d.ts +5 -0
- package/dist/v1/compiled/admission/semantics/class.js +125 -0
- package/dist/v1/compiled/admission/semantics/context.d.ts +60 -0
- package/dist/v1/compiled/admission/semantics/context.js +81 -0
- package/dist/v1/compiled/admission/semantics/core.d.ts +35 -0
- package/dist/v1/compiled/admission/semantics/core.js +123 -0
- package/dist/v1/compiled/admission/semantics/edge.d.ts +8 -0
- package/dist/v1/compiled/admission/semantics/edge.js +89 -0
- package/dist/v1/compiled/admission/semantics/policy/admit.d.ts +4 -0
- package/dist/v1/compiled/admission/semantics/policy/admit.js +63 -0
- package/dist/v1/compiled/admission/semantics/policy/callable.d.ts +5 -0
- package/dist/v1/compiled/admission/semantics/policy/callable.js +72 -0
- package/dist/v1/compiled/admission/semantics/policy/contracts.d.ts +24 -0
- package/dist/v1/compiled/admission/semantics/policy/contracts.js +45 -0
- package/dist/v1/compiled/admission/semantics/policy/equality.d.ts +8 -0
- package/dist/v1/compiled/admission/semantics/policy/equality.js +27 -0
- package/dist/v1/compiled/admission/semantics/policy/measure.d.ts +9 -0
- package/dist/v1/compiled/admission/semantics/policy/measure.js +81 -0
- package/dist/v1/compiled/admission/semantics/policy/parity.d.ts +4 -0
- package/dist/v1/compiled/admission/semantics/policy/parity.js +139 -0
- package/dist/v1/compiled/admission/semantics/policy/pattern.d.ts +8 -0
- package/dist/v1/compiled/admission/semantics/policy/pattern.js +78 -0
- package/dist/v1/compiled/admission/semantics/policy/typing.d.ts +28 -0
- package/dist/v1/compiled/admission/semantics/policy/typing.js +206 -0
- package/dist/v1/compiled/admission/semantics/policy/variants.d.ts +10 -0
- package/dist/v1/compiled/admission/semantics/policy/variants.js +65 -0
- package/dist/v1/compiled/admission/semantics.d.ts +1 -1
- package/dist/v1/compiled/admission/semantics.js +8 -1078
- package/dist/v1/compiled/admission/wire/callable.d.ts +6 -0
- package/dist/v1/compiled/admission/wire/callable.js +90 -0
- package/dist/v1/compiled/admission/wire/class.d.ts +4 -0
- package/dist/v1/compiled/admission/wire/class.js +133 -0
- package/dist/v1/compiled/admission/wire/core.d.ts +5 -0
- package/dist/v1/compiled/admission/wire/core.js +32 -0
- package/dist/v1/compiled/admission/wire/dependency.d.ts +14 -0
- package/dist/v1/compiled/admission/wire/dependency.js +43 -0
- package/dist/v1/compiled/admission/wire/entry.d.ts +5 -0
- package/dist/v1/compiled/admission/wire/entry.js +100 -0
- package/dist/v1/compiled/admission/wire/pattern.d.ts +12 -0
- package/dist/v1/compiled/admission/wire/pattern.js +111 -0
- package/dist/v1/compiled/admission/wire/policy.d.ts +10 -0
- package/dist/v1/compiled/admission/wire/policy.js +189 -0
- package/dist/v1/compiled/admission/wire/program.d.ts +4 -0
- package/dist/v1/compiled/admission/wire/program.js +52 -0
- package/dist/v1/compiled/admission/wire/property.d.ts +4 -0
- package/dist/v1/compiled/admission/wire/property.js +74 -0
- package/dist/v1/compiled/admission/wire/reference.d.ts +8 -0
- package/dist/v1/compiled/admission/wire/reference.js +33 -0
- package/dist/v1/compiled/admission/wire/value.d.ts +29 -0
- package/dist/v1/compiled/admission/wire/value.js +98 -0
- package/dist/v1/compiled/admission/wire/view.d.ts +3 -0
- package/dist/v1/compiled/admission/wire/view.js +17 -0
- package/dist/v1/compiled/compiler/compile.js +43 -11
- package/dist/v1/compiled/generated.d.ts +10 -0
- package/dist/v1/compiled/generated.js +15 -0
- package/dist/v1/compiled/loader/load.d.ts +5 -0
- package/dist/v1/compiled/loader/load.js +18 -4
- package/dist/v1/compiled/model/schema.d.ts +16 -7
- package/dist/v1/domain/create.js +18 -28
- package/dist/v1/domain/model/domain.d.ts +0 -1
- package/dist/v1/domain/model/input.d.ts +3 -0
- package/dist/v1/domain/projection/classes.js +13 -41
- package/dist/v1/domain/validation/create.d.ts +2 -0
- package/dist/v1/domain/validation/create.js +12 -0
- package/dist/v1/index.d.ts +5 -2
- package/dist/v1/index.js +3 -1
- package/dist/v1/language/callable/composition.d.ts +27 -0
- package/dist/v1/language/callable/composition.js +52 -0
- package/dist/v1/language/callable/executable.d.ts +6 -0
- package/dist/v1/language/callable/executable.js +4 -0
- package/dist/v1/language/callable/model/callable.d.ts +34 -9
- package/dist/v1/language/callable/model/callable.js +3 -1
- package/dist/v1/language/callable/resolved.d.ts +23 -8
- package/dist/v1/language/class/facets.d.ts +5 -2
- package/dist/v1/language/class/inheritance.d.ts +12 -0
- package/dist/v1/language/class/inheritance.js +25 -0
- package/dist/v1/language/class/lifetime.d.ts +17 -0
- package/dist/v1/language/class/lifetime.js +26 -0
- package/dist/v1/language/class/model/class.d.ts +8 -4
- package/dist/v1/language/class/model/property.d.ts +4 -2
- package/dist/v1/language/class/property-values.js +5 -2
- package/dist/v1/language/class/resolved.d.ts +25 -15
- package/dist/v1/language/core/model/core.d.ts +7 -1
- package/dist/v1/language/core/resolved.d.ts +6 -2
- package/dist/v1/language/definition/metadata.d.ts +8 -0
- package/dist/v1/language/definition/metadata.js +12 -0
- package/dist/v1/language/index.d.ts +9 -0
- package/dist/v1/language/index.js +6 -0
- package/dist/v1/language/policy/analysis/branches.d.ts +4 -3
- package/dist/v1/language/policy/analysis/branches.js +54 -12
- package/dist/v1/language/policy/analysis/budgets.js +1 -1
- package/dist/v1/language/policy/analysis/checks.d.ts +28 -0
- package/dist/v1/language/policy/analysis/checks.js +80 -0
- package/dist/v1/language/policy/index.d.ts +1 -0
- package/dist/v1/language/policy/index.js +1 -0
- package/dist/v1/language/policy/model/policy.d.ts +71 -5
- package/dist/v1/language/policy/model/policy.js +52 -1
- package/dist/v1/language/policy/normalization/normalize.d.ts +12 -1
- package/dist/v1/language/policy/normalization/normalize.js +178 -44
- package/dist/v1/language/state/index.d.ts +3 -0
- package/dist/v1/language/state/index.js +1 -0
- package/dist/v1/language/state/machine.d.ts +28 -0
- package/dist/v1/language/state/machine.js +40 -0
- package/dist/v1/language/state/topology.d.ts +14 -0
- package/dist/v1/language/state/topology.js +69 -0
- package/dist/v1/language/value/compile/fields.d.ts +1 -1
- package/dist/v1/language/value/compile/load.d.ts +4 -2
- package/dist/v1/language/value/compile/load.js +22 -1
- package/dist/v1/language/value/compile/model.d.ts +16 -1
- package/dist/v1/language/value/evaluate/assertions.d.ts +2 -0
- package/dist/v1/language/value/evaluate/assertions.js +13 -0
- package/dist/v1/language/value/evaluate/evaluator.js +111 -28
- package/dist/v1/language/value/evaluate/preparation.d.ts +10 -1
- package/dist/v1/language/value/evaluate/preparation.js +17 -26
- package/dist/v1/language/value/evaluate/program.js +1 -1
- package/dist/v1/language/value/evaluate/validate.d.ts +6 -2
- package/dist/v1/language/value/evaluate/validate.js +18 -11
- package/dist/v1/language/value/inclusion/includes.d.ts +9 -0
- package/dist/v1/language/value/inclusion/includes.js +777 -0
- package/dist/v1/language/value/model/blob.d.ts +31 -0
- package/dist/v1/language/value/model/blob.js +90 -0
- package/dist/v1/language/value/model/instant.d.ts +0 -2
- package/dist/v1/language/value/model/instant.js +1 -1
- package/dist/v1/language/value/model/schema.d.ts +2 -1
- package/dist/v1/language/value/model/schema.js +1 -5
- package/dist/v1/language/value/ordering.d.ts +2 -0
- package/dist/v1/language/value/ordering.js +4 -8
- package/dist/v1/language/value/profile/json.validate.js +1 -1
- package/dist/v1/language/value/profile/rules.js +48 -12
- package/dist/v1/language/value/reference/registry.d.ts +2 -1
- package/dist/v1/language/value/regexp/ast.js +3 -64
- package/dist/v1/language/value/regexp/compile.d.ts +32 -3
- package/dist/v1/language/value/regexp/compile.js +117 -21
- package/dist/v1/language/value/regexp/matcher.d.ts +6 -3
- package/dist/v1/language/value/regexp/matcher.js +185 -28
- package/dist/v1/language/value/regexp/syntax.d.ts +12 -1
- package/dist/v1/language/value/regexp/syntax.js +14 -2
- package/dist/v1/language/value/regexp/unicode.d.ts +32 -0
- package/dist/v1/language/value/regexp/unicode.js +139 -0
- package/dist/v1/language/value/syntax/full-match.js +8 -5
- package/dist/v1/language/value/syntax/node-path/validate.js +4 -6
- package/dist/v1/language/view/model/view.d.ts +2 -4
- package/dist/v1/language/view/resolved.d.ts +2 -2
- package/dist/v1/schema/analysis/class.d.ts +36 -6
- package/dist/v1/schema/analysis/class.js +31 -66
- package/dist/v1/schema/canonical/revision.d.ts +2 -1
- package/dist/v1/schema/canonical/revision.js +4 -1
- package/dist/v1/schema/compatibility/api.d.ts +3 -0
- package/dist/v1/schema/compatibility/api.js +2 -0
- package/dist/v1/schema/compatibility/comparators/callables.d.ts +39 -0
- package/dist/v1/schema/compatibility/comparators/callables.js +101 -0
- package/dist/v1/schema/compatibility/comparators/classes.d.ts +47 -0
- package/dist/v1/schema/compatibility/comparators/classes.js +160 -0
- package/dist/v1/schema/compatibility/comparators/index.d.ts +12 -0
- package/dist/v1/schema/compatibility/comparators/index.js +53 -0
- package/dist/v1/schema/compatibility/comparators/members.d.ts +4 -0
- package/dist/v1/schema/compatibility/comparators/members.js +49 -0
- package/dist/v1/schema/compatibility/comparators/values.d.ts +5 -0
- package/dist/v1/schema/compatibility/comparators/values.js +37 -0
- package/dist/v1/schema/compatibility/compare.d.ts +5 -0
- package/dist/v1/schema/compatibility/compare.js +23 -0
- package/dist/v1/schema/compatibility/context.d.ts +19 -0
- package/dist/v1/schema/compatibility/context.js +49 -0
- package/dist/v1/schema/compatibility/coordinate.d.ts +40 -0
- package/dist/v1/schema/compatibility/coordinate.js +38 -0
- package/dist/v1/schema/compatibility/diff.d.ts +12 -0
- package/dist/v1/schema/compatibility/diff.js +39 -0
- package/dist/v1/schema/compatibility/evidence.d.ts +16 -0
- package/dist/v1/schema/compatibility/evidence.js +62 -0
- package/dist/v1/schema/compatibility/fields.d.ts +194 -0
- package/dist/v1/schema/compatibility/fields.js +94 -0
- package/dist/v1/schema/compatibility/index.d.ts +6 -0
- package/dist/v1/schema/compatibility/index.js +3 -0
- package/dist/v1/schema/compatibility/meaning/footprint.d.ts +7 -0
- package/dist/v1/schema/compatibility/meaning/footprint.js +59 -0
- package/dist/v1/schema/compatibility/meaning/index.d.ts +3 -0
- package/dist/v1/schema/compatibility/meaning/index.js +16 -0
- package/dist/v1/schema/compatibility/model.d.ts +131 -0
- package/dist/v1/schema/compatibility/model.js +1 -0
- package/dist/v1/schema/compatibility/references.d.ts +38 -0
- package/dist/v1/schema/compatibility/references.js +149 -0
- package/dist/v1/schema/compatibility/report.d.ts +27 -0
- package/dist/v1/schema/compatibility/report.js +100 -0
- package/dist/v1/schema/compatibility/scope.d.ts +36 -0
- package/dist/v1/schema/compatibility/scope.js +110 -0
- package/dist/v1/schema/compatibility/structure/index.d.ts +3 -0
- package/dist/v1/schema/compatibility/structure/index.js +40 -0
- package/dist/v1/schema/compatibility/structure/inheritance.d.ts +7 -0
- package/dist/v1/schema/compatibility/structure/inheritance.js +68 -0
- package/dist/v1/schema/compatibility/structure/requirements.d.ts +7 -0
- package/dist/v1/schema/compatibility/structure/requirements.js +97 -0
- package/dist/v1/schema/compatibility/subjects.d.ts +39 -0
- package/dist/v1/schema/compatibility/subjects.js +143 -0
- package/dist/v1/schema/compatibility/versioning/index.d.ts +8 -0
- package/dist/v1/schema/compatibility/versioning/index.js +50 -0
- package/dist/v1/schema/compatibility/versioning/members.d.ts +12 -0
- package/dist/v1/schema/compatibility/versioning/members.js +47 -0
- package/dist/v1/schema/compatibility/versioning/surface.d.ts +11 -0
- package/dist/v1/schema/compatibility/versioning/surface.js +61 -0
- package/dist/v1/schema/diagnostic.d.ts +1 -1
- package/dist/v1/schema/fingerprint.d.ts +2 -0
- package/dist/v1/schema/fingerprint.js +1 -0
- package/dist/v1/schema/index.d.ts +4 -3
- package/dist/v1/schema/index.js +2 -1
- package/dist/v1/schema/model/schema.d.ts +8 -11
- package/dist/v1/schema/normalization/domain.js +57 -13
- package/dist/v1/schema/resolution/definition.index.d.ts +1 -2
- package/dist/v1/schema/resolution/definition.index.js +0 -3
- package/dist/v1/schema/resolution/domain.d.ts +4 -1
- package/dist/v1/schema/resolution/domain.js +26 -18
- package/dist/v1/schema/resolution/origins.d.ts +28 -5
- package/dist/v1/schema/resolution/origins.js +68 -31
- package/dist/v1/schema/validation/callable.d.ts +4 -0
- package/dist/v1/schema/validation/callable.js +39 -0
- package/dist/v1/schema/validation/class.d.ts +10 -0
- package/dist/v1/schema/validation/class.js +79 -60
- package/dist/v1/schema/validation/core.js +83 -55
- package/dist/v1/schema/validation/domain.d.ts +2 -1
- package/dist/v1/schema/validation/domain.js +2 -0
- package/dist/v1/schema/validation/domain.structure.d.ts +0 -2
- package/dist/v1/schema/validation/domain.structure.js +214 -171
- package/dist/v1/schema/validation/policy/budgets.js +36 -6
- package/dist/v1/schema/validation/policy/context.js +5 -16
- package/dist/v1/schema/validation/policy/objects.d.ts +4 -0
- package/dist/v1/schema/validation/policy/objects.js +71 -0
- package/dist/v1/schema/validation/policy/references.js +16 -4
- package/dist/v1/schema/validation/policy/typing.d.ts +2 -0
- package/dist/v1/schema/validation/policy/typing.js +55 -7
- package/dist/v1/schema/validation/policy/uses.js +73 -99
- package/dist/v1/schema/validation/value-api.d.ts +2 -0
- package/dist/v1/schema/validation/value-api.js +1 -0
- package/dist/v1/schema/validation/value.js +7 -1
- package/dist/v1/schema/validation/view.js +14 -9
- package/dist/value/accept.d.ts +9 -0
- package/dist/value/accept.js +106 -7
- package/dist/value/canonical.d.ts +3 -0
- package/dist/value/canonical.js +22 -6
- package/dist/value/immutable.optimization.d.ts +15 -0
- package/dist/value/immutable.optimization.js +34 -0
- package/dist/value/index.d.ts +1 -1
- package/dist/value/index.js +1 -1
- package/dist/value/json.d.ts +1 -1
- package/dist/value/json.js +1 -1
- package/dist/value/limits.d.ts +1 -1
- package/dist/value/unicode.d.ts +4 -1
- package/dist/value/unicode.js +28 -0
- package/package.json +20 -5
- package/dist/v1/schema/compatibility/meaning.d.ts +0 -29
- package/dist/v1/schema/compatibility/meaning.js +0 -605
|
@@ -2,6 +2,7 @@ import { compareUnicode } from '../../addressing/ordering.js';
|
|
|
2
2
|
import { analyzeDefinitions } from '../analysis/class.js';
|
|
3
3
|
import { buildDomainResolutionContext } from '../resolution/context.js';
|
|
4
4
|
import { createValueSchemaRegistry } from '../resolution/value.registry.js';
|
|
5
|
+
import { validateCallables } from './callable.js';
|
|
5
6
|
import { validateDefinitions } from './class.js';
|
|
6
7
|
import { validateCore } from './core.js';
|
|
7
8
|
import { validatePolicies } from './policy/validate.js';
|
|
@@ -15,6 +16,7 @@ export function validateDomainSchemaSemantics(schema, lookup) {
|
|
|
15
16
|
...context.diagnostics,
|
|
16
17
|
...validateEmbeddedValueSchemas(schema, registry),
|
|
17
18
|
...validateDefinitions(context, analysis),
|
|
19
|
+
...validateCallables(schema),
|
|
18
20
|
...validatePolicies(context, analysis),
|
|
19
21
|
...validateViews(context),
|
|
20
22
|
...validateCore(context, analysis, registry),
|
|
@@ -1,53 +1,58 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { array, boolean, custom, discriminatedUnion, enum as enumeration, lazy, literal, null as nullSchema, number, record, strictObject, string, tuple, union, } from 'zod';
|
|
2
2
|
import { PropertyKey as SemanticPropertyKey } from '../../addressing/index.js';
|
|
3
3
|
import { CORE_SLUG_PATTERN, DEPENDENCY_ALIAS_PATTERN, DOMAIN_ORIGIN_PATTERN, DOMAIN_REVISION_PATTERN, MEMBER_NAME_PATTERN, } from '../../addressing/patterns.js';
|
|
4
4
|
import { MEDIA_TYPE_PATTERN } from '../../language/class/model/data.js';
|
|
5
5
|
import * as metadata from '../../language/definition/metadata.js';
|
|
6
6
|
import { SchemaError, diagnostic } from '../diagnostic.js';
|
|
7
7
|
import { DOMAIN_FORMAT, DOMAIN_VERSION } from '../model/format.js';
|
|
8
|
-
const originSchema =
|
|
9
|
-
const memberNameSchema =
|
|
10
|
-
const dependencyAliasSchema =
|
|
11
|
-
.string()
|
|
8
|
+
const originSchema = string().min(3).max(253).regex(DOMAIN_ORIGIN_PATTERN);
|
|
9
|
+
const memberNameSchema = string().regex(MEMBER_NAME_PATTERN);
|
|
10
|
+
const dependencyAliasSchema = string()
|
|
12
11
|
.regex(DEPENDENCY_ALIAS_PATTERN)
|
|
13
12
|
.refine((value) => value !== '__proto__' && value !== 'prototype' && value !== 'constructor', 'Expected a non-reserved dependency alias.');
|
|
14
|
-
const propertyKeySchema =
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
const revisionSchema = z.string().regex(DOMAIN_REVISION_PATTERN);
|
|
19
|
-
const descriptionSchema = z
|
|
20
|
-
.string()
|
|
13
|
+
const propertyKeySchema = string().refine(SemanticPropertyKey.is, 'Expected a canonical PropertyKey.');
|
|
14
|
+
const coreSlugSchema = string().min(1).max(100).regex(CORE_SLUG_PATTERN);
|
|
15
|
+
const revisionSchema = string().regex(DOMAIN_REVISION_PATTERN);
|
|
16
|
+
const descriptionSchema = string()
|
|
21
17
|
.min(metadata.description.minLength)
|
|
22
18
|
.max(metadata.description.maxLength);
|
|
23
|
-
const iconSchema =
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
19
|
+
const iconSchema = string().min(metadata.icon.minLength).max(metadata.icon.maxLength);
|
|
20
|
+
const domainNameSchema = string()
|
|
21
|
+
.min(metadata.name.minLength)
|
|
22
|
+
.max(metadata.name.maxLength)
|
|
23
|
+
.refine(metadata.isDomainNameText, 'Expected one trimmed line of text.');
|
|
24
|
+
const jsonValueSchema = lazy(() => union([
|
|
25
|
+
nullSchema(),
|
|
26
|
+
boolean(),
|
|
27
|
+
number(),
|
|
28
|
+
string(),
|
|
29
|
+
array(jsonValueSchema),
|
|
30
|
+
record(string(), jsonValueSchema),
|
|
31
31
|
]));
|
|
32
|
-
const jsonObjectSchema =
|
|
33
|
-
const jsonSchemaSchema =
|
|
34
|
-
const dataDeclarationSchema =
|
|
35
|
-
mediaType:
|
|
32
|
+
const jsonObjectSchema = record(string(), jsonValueSchema);
|
|
33
|
+
const jsonSchemaSchema = union([boolean(), jsonObjectSchema]);
|
|
34
|
+
const dataDeclarationSchema = strictObject({
|
|
35
|
+
mediaType: string().regex(MEDIA_TYPE_PATTERN),
|
|
36
36
|
});
|
|
37
|
-
const
|
|
37
|
+
const stateNameSchema = string().min(1);
|
|
38
|
+
const stateTransitionsSchema = custom(isStateTransitions);
|
|
39
|
+
const stateTopologySchema = strictObject({
|
|
40
|
+
initial: stateNameSchema,
|
|
41
|
+
transitions: stateTransitionsSchema,
|
|
42
|
+
});
|
|
43
|
+
const propertyDefinitionSchema = strictObject({
|
|
38
44
|
schema: jsonSchemaSchema,
|
|
39
|
-
required:
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
})
|
|
46
|
-
.optional(),
|
|
45
|
+
required: boolean(),
|
|
46
|
+
auto: strictObject({
|
|
47
|
+
on: uniqueArray(enumeration(['create', 'update'])).min(1),
|
|
48
|
+
set: literal('instant'),
|
|
49
|
+
}).optional(),
|
|
50
|
+
immutable: enumeration(['create', 'once']).optional(),
|
|
47
51
|
description: descriptionSchema.optional(),
|
|
52
|
+
state: stateTopologySchema.optional(),
|
|
48
53
|
});
|
|
49
|
-
const propertyRecordSchema =
|
|
50
|
-
const domainDependencySchema =
|
|
54
|
+
const propertyRecordSchema = record(memberNameSchema, propertyDefinitionSchema);
|
|
55
|
+
const domainDependencySchema = strictObject({
|
|
51
56
|
origin: originSchema,
|
|
52
57
|
revision: revisionSchema,
|
|
53
58
|
});
|
|
@@ -55,139 +60,154 @@ const classRefSchema = absoluteRefSchema('class');
|
|
|
55
60
|
const functionRefSchema = absoluteRefSchema('function');
|
|
56
61
|
const policyRefSchema = absoluteRefSchema('policy');
|
|
57
62
|
const viewRefSchema = absoluteRefSchema('view');
|
|
58
|
-
const coreRefSchema =
|
|
63
|
+
const coreRefSchema = strictObject({
|
|
59
64
|
origin: originSchema,
|
|
60
|
-
kind:
|
|
65
|
+
kind: literal('core'),
|
|
61
66
|
name: coreSlugSchema,
|
|
62
67
|
});
|
|
63
|
-
const domainRefSchema =
|
|
64
|
-
|
|
65
|
-
const
|
|
68
|
+
const domainRefSchema = strictObject({ kind: literal('domain') });
|
|
69
|
+
/** Every Definition whose installed projection resolves through one exact member Path. */
|
|
70
|
+
const projectedMemberRefOptions = [
|
|
71
|
+
strictObject({ kind: literal('method'), owner: classRefSchema, name: memberNameSchema }),
|
|
66
72
|
classRefSchema,
|
|
67
73
|
functionRefSchema,
|
|
68
74
|
policyRefSchema,
|
|
69
75
|
viewRefSchema,
|
|
70
76
|
coreRefSchema,
|
|
77
|
+
];
|
|
78
|
+
const policyObjectRefSchema = discriminatedUnion('kind', projectedMemberRefOptions);
|
|
79
|
+
const coreEndpointRefSchema = discriminatedUnion('kind', [
|
|
80
|
+
...projectedMemberRefOptions,
|
|
81
|
+
domainRefSchema,
|
|
71
82
|
]);
|
|
72
83
|
const edgeEndpointBaseShape = {
|
|
73
84
|
role: memberNameSchema,
|
|
74
85
|
accepts: uniqueArray(classRefSchema).min(1),
|
|
75
86
|
};
|
|
76
|
-
const edgeCountSchema =
|
|
77
|
-
const directedEdgeEndpointsSchema =
|
|
78
|
-
source:
|
|
79
|
-
target:
|
|
87
|
+
const edgeCountSchema = enumeration(['0..*', '1..*', '0..1', '1']);
|
|
88
|
+
const directedEdgeEndpointsSchema = strictObject({
|
|
89
|
+
source: strictObject({ ...edgeEndpointBaseShape, outgoing: edgeCountSchema }),
|
|
90
|
+
target: strictObject({ ...edgeEndpointBaseShape, incoming: edgeCountSchema }),
|
|
80
91
|
});
|
|
81
|
-
const incidentEndpointSchema =
|
|
92
|
+
const incidentEndpointSchema = strictObject({
|
|
82
93
|
...edgeEndpointBaseShape,
|
|
83
94
|
incident: edgeCountSchema,
|
|
84
95
|
});
|
|
85
|
-
const undirectedEdgeEndpointsSchema =
|
|
86
|
-
const edgeConstraintsSchema =
|
|
87
|
-
noSelf:
|
|
88
|
-
acyclic:
|
|
96
|
+
const undirectedEdgeEndpointsSchema = tuple([incidentEndpointSchema, incidentEndpointSchema]);
|
|
97
|
+
const edgeConstraintsSchema = strictObject({
|
|
98
|
+
noSelf: literal(true).optional(),
|
|
99
|
+
acyclic: literal(true).optional(),
|
|
89
100
|
});
|
|
90
|
-
const policyPatternSubjectSchema =
|
|
91
|
-
const policyPatternObjectSchema =
|
|
92
|
-
const policyPatternSourceSchema =
|
|
93
|
-
const policyPatternTargetSchema =
|
|
94
|
-
const policyPatternVariableSchema =
|
|
95
|
-
kind:
|
|
96
|
-
id:
|
|
101
|
+
const policyPatternSubjectSchema = strictObject({ kind: literal('subject') });
|
|
102
|
+
const policyPatternObjectSchema = strictObject({ kind: literal('object') });
|
|
103
|
+
const policyPatternSourceSchema = strictObject({ kind: literal('source') });
|
|
104
|
+
const policyPatternTargetSchema = strictObject({ kind: literal('target') });
|
|
105
|
+
const policyPatternVariableSchema = strictObject({
|
|
106
|
+
kind: literal('variable'),
|
|
107
|
+
id: number().int().min(0),
|
|
97
108
|
});
|
|
98
|
-
const policyPatternNodeSchema =
|
|
109
|
+
const policyPatternNodeSchema = discriminatedUnion('kind', [
|
|
99
110
|
policyPatternSubjectSchema,
|
|
100
111
|
policyPatternObjectSchema,
|
|
101
112
|
policyPatternSourceSchema,
|
|
102
113
|
policyPatternTargetSchema,
|
|
103
114
|
policyPatternVariableSchema,
|
|
115
|
+
strictObject({ kind: literal('ref'), ref: policyObjectRefSchema }),
|
|
104
116
|
]);
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
class: classRefSchema,
|
|
108
|
-
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
|
|
117
|
+
const policyVariableSelectorSchema = discriminatedUnion('kind', [
|
|
118
|
+
strictObject({ kind: literal('any') }),
|
|
119
|
+
strictObject({ kind: literal('satisfies'), class: classRefSchema }),
|
|
120
|
+
]);
|
|
121
|
+
const policyVariableSchema = union([
|
|
122
|
+
strictObject({ variable: policyPatternVariableSchema, class: classRefSchema }),
|
|
123
|
+
strictObject({ variable: policyPatternVariableSchema, selector: policyVariableSelectorSchema }),
|
|
124
|
+
]);
|
|
125
|
+
const policyRepeatSchema = strictObject({
|
|
126
|
+
min: number().int().min(0).max(3),
|
|
127
|
+
max: number().int().min(0).max(3),
|
|
112
128
|
});
|
|
113
|
-
const policyPatternExpressionSchema =
|
|
114
|
-
|
|
129
|
+
const policyPatternExpressionSchema = lazy(() => union([
|
|
130
|
+
strictObject({
|
|
131
|
+
sameNode: strictObject({ left: policyPatternNodeSchema, right: policyPatternNodeSchema }),
|
|
132
|
+
}),
|
|
133
|
+
strictObject({
|
|
115
134
|
source: policyPatternNodeSchema,
|
|
116
135
|
class: classRefSchema,
|
|
117
136
|
target: policyPatternNodeSchema,
|
|
118
137
|
repeat: policyRepeatSchema.optional(),
|
|
119
138
|
}),
|
|
120
|
-
|
|
121
|
-
exists:
|
|
122
|
-
nodes:
|
|
139
|
+
strictObject({
|
|
140
|
+
exists: strictObject({
|
|
141
|
+
nodes: array(policyVariableSchema).min(1).max(4),
|
|
123
142
|
where: policyPatternExpressionSchema,
|
|
124
143
|
}),
|
|
125
144
|
}),
|
|
126
|
-
|
|
127
|
-
allOf:
|
|
145
|
+
strictObject({
|
|
146
|
+
allOf: array(policyPatternExpressionSchema).min(1),
|
|
128
147
|
}),
|
|
129
|
-
|
|
130
|
-
anyOf:
|
|
148
|
+
strictObject({
|
|
149
|
+
anyOf: array(policyPatternExpressionSchema).min(1),
|
|
131
150
|
}),
|
|
132
151
|
]));
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
152
|
+
const selfObjectSchema = strictObject({ kind: literal('self') });
|
|
153
|
+
const refObjectSchema = strictObject({ kind: literal('ref'), ref: policyObjectRefSchema });
|
|
154
|
+
const policyCheckObjectSchema = discriminatedUnion('kind', [
|
|
155
|
+
selfObjectSchema,
|
|
156
|
+
strictObject({
|
|
157
|
+
kind: literal('input'),
|
|
137
158
|
field: memberNameSchema,
|
|
138
159
|
}),
|
|
139
|
-
|
|
140
|
-
kind: z.literal('ref'),
|
|
141
|
-
ref: policyObjectRefSchema,
|
|
142
|
-
}),
|
|
160
|
+
refObjectSchema,
|
|
143
161
|
]);
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
|
|
162
|
+
/** A Node Class rule checks the observed Node or one exact member: it has no input. */
|
|
163
|
+
const classRuleObjectSchema = discriminatedUnion('kind', [selfObjectSchema, refObjectSchema]);
|
|
164
|
+
/** The recursive Policy check grammar, over the objects one use site admits. */
|
|
165
|
+
function policyChecksSchema(objectSchema) {
|
|
166
|
+
const checks = lazy(() => union([
|
|
167
|
+
strictObject({ sameNode: strictObject({ left: objectSchema, right: objectSchema }) }),
|
|
168
|
+
strictObject({ check: policyRefSchema, object: objectSchema }),
|
|
169
|
+
strictObject({ allOf: array(checks).min(1) }),
|
|
170
|
+
strictObject({ anyOf: array(checks).min(1) }),
|
|
171
|
+
]));
|
|
172
|
+
return checks;
|
|
173
|
+
}
|
|
174
|
+
const policyCheckExpressionSchema = policyChecksSchema(policyCheckObjectSchema);
|
|
175
|
+
const classRuleChecksSchema = policyChecksSchema(classRuleObjectSchema);
|
|
176
|
+
const callableOutputSchema = discriminatedUnion('mode', [
|
|
177
|
+
strictObject({
|
|
178
|
+
mode: literal('value'),
|
|
159
179
|
schema: jsonSchemaSchema,
|
|
160
180
|
}),
|
|
161
|
-
|
|
162
|
-
mode:
|
|
181
|
+
strictObject({
|
|
182
|
+
mode: literal('stream'),
|
|
163
183
|
item: jsonSchemaSchema,
|
|
164
184
|
}),
|
|
165
|
-
|
|
166
|
-
mode:
|
|
185
|
+
strictObject({
|
|
186
|
+
mode: literal('binary'),
|
|
167
187
|
}),
|
|
168
188
|
]);
|
|
189
|
+
const binaryInputSchema = strictObject({
|
|
190
|
+
mode: literal('binary'),
|
|
191
|
+
metadata: jsonSchemaSchema,
|
|
192
|
+
maximumBytes: number().int().min(1).max(Number.MAX_SAFE_INTEGER),
|
|
193
|
+
});
|
|
194
|
+
const valueFunctionInputSchema = jsonSchemaSchema.refine((value) => typeof value !== 'object' || value === null || value.mode !== 'binary', 'Binary input must declare metadata and maximumBytes.');
|
|
195
|
+
const callableExecutionSchema = strictObject({
|
|
196
|
+
durable: boolean(),
|
|
197
|
+
});
|
|
169
198
|
const callableShape = {
|
|
170
199
|
description: descriptionSchema.optional(),
|
|
171
200
|
input: jsonSchemaSchema,
|
|
172
201
|
output: callableOutputSchema,
|
|
173
|
-
|
|
174
|
-
|
|
202
|
+
execution: callableExecutionSchema.optional(),
|
|
203
|
+
auth: enumeration(['anonymous', 'authenticated', 'authorized']),
|
|
204
|
+
policy: union([literal(true), policyCheckExpressionSchema]).optional(),
|
|
175
205
|
};
|
|
176
|
-
const methodDeclarationSchema =
|
|
177
|
-
.strictObject({
|
|
206
|
+
const methodDeclarationSchema = strictObject({
|
|
178
207
|
...callableShape,
|
|
179
|
-
static:
|
|
180
|
-
|
|
181
|
-
})
|
|
182
|
-
.superRefine((method, context) => {
|
|
183
|
-
if (method.inheritance === 'abstract' && method.policy !== undefined) {
|
|
184
|
-
context.addIssue({
|
|
185
|
-
code: 'custom',
|
|
186
|
-
path: ['policy'],
|
|
187
|
-
message: 'An abstract method cannot declare a policy.',
|
|
188
|
-
params: { structureCode: 'STRUCTURE_ABSTRACT_POLICY' },
|
|
189
|
-
});
|
|
190
|
-
}
|
|
208
|
+
static: boolean(),
|
|
209
|
+
abstract: boolean(),
|
|
210
|
+
}).superRefine((method, context) => {
|
|
191
211
|
if (method.auth !== 'authorized' && method.policy !== undefined) {
|
|
192
212
|
context.addIssue({
|
|
193
213
|
code: 'custom',
|
|
@@ -197,18 +217,21 @@ const methodDeclarationSchema = z
|
|
|
197
217
|
});
|
|
198
218
|
}
|
|
199
219
|
});
|
|
200
|
-
const methodRecordSchema =
|
|
201
|
-
const
|
|
202
|
-
|
|
203
|
-
|
|
220
|
+
const methodRecordSchema = record(memberNameSchema, methodDeclarationSchema);
|
|
221
|
+
const classPolicySchema = union([literal(false), policyRefSchema]);
|
|
222
|
+
const nodeClassPolicySchema = union([classPolicySchema, classRuleChecksSchema]);
|
|
223
|
+
const nodeClassPoliciesSchema = strictObject({
|
|
224
|
+
read: nodeClassPolicySchema.optional(),
|
|
225
|
+
traverse: nodeClassPolicySchema.optional(),
|
|
204
226
|
});
|
|
205
|
-
const edgeClassPoliciesSchema =
|
|
206
|
-
|
|
227
|
+
const edgeClassPoliciesSchema = strictObject({
|
|
228
|
+
read: classPolicySchema.optional(),
|
|
229
|
+
traverse: classPolicySchema.optional(),
|
|
207
230
|
});
|
|
208
|
-
const nodeClassSchema =
|
|
231
|
+
const nodeClassSchema = strictObject({
|
|
209
232
|
ref: classRefSchema,
|
|
210
|
-
kind:
|
|
211
|
-
abstract:
|
|
233
|
+
kind: literal('node'),
|
|
234
|
+
abstract: boolean(),
|
|
212
235
|
description: descriptionSchema.optional(),
|
|
213
236
|
extends: uniqueArray(classRefSchema),
|
|
214
237
|
properties: propertyRecordSchema,
|
|
@@ -219,22 +242,20 @@ const nodeClassSchema = z.strictObject({
|
|
|
219
242
|
});
|
|
220
243
|
const edgeClassShape = {
|
|
221
244
|
ref: classRefSchema,
|
|
222
|
-
kind:
|
|
223
|
-
abstract:
|
|
245
|
+
kind: literal('edge'),
|
|
246
|
+
abstract: boolean(),
|
|
224
247
|
description: descriptionSchema.optional(),
|
|
225
248
|
extends: uniqueArray(classRefSchema),
|
|
226
249
|
properties: propertyRecordSchema,
|
|
227
250
|
constraints: edgeConstraintsSchema,
|
|
228
251
|
};
|
|
229
|
-
const edgeClassSchema =
|
|
230
|
-
.strictObject({
|
|
252
|
+
const edgeClassSchema = strictObject({
|
|
231
253
|
...edgeClassShape,
|
|
232
|
-
orientation:
|
|
233
|
-
endpoints:
|
|
254
|
+
orientation: enumeration(['directed', 'undirected']),
|
|
255
|
+
endpoints: union([directedEdgeEndpointsSchema, undirectedEdgeEndpointsSchema]),
|
|
234
256
|
policies: edgeClassPoliciesSchema,
|
|
235
|
-
})
|
|
236
|
-
|
|
237
|
-
const classDeclarationSchema = z.discriminatedUnion('kind', [nodeClassSchema, edgeClassSchema]);
|
|
257
|
+
}).superRefine(validateEdgeOrientationShape);
|
|
258
|
+
const classDeclarationSchema = discriminatedUnion('kind', [nodeClassSchema, edgeClassSchema]);
|
|
238
259
|
function validateEdgeOrientationShape(value, context) {
|
|
239
260
|
if ((value.orientation === 'undirected') === Array.isArray(value.endpoints))
|
|
240
261
|
return;
|
|
@@ -245,9 +266,11 @@ function validateEdgeOrientationShape(value, context) {
|
|
|
245
266
|
params: { structureCode: 'STRUCTURE_EDGE_ORIENTATION' },
|
|
246
267
|
});
|
|
247
268
|
}
|
|
248
|
-
const functionDefinitionSchema =
|
|
249
|
-
|
|
250
|
-
|
|
269
|
+
const functionDefinitionSchema = strictObject({
|
|
270
|
+
ref: functionRefSchema,
|
|
271
|
+
...callableShape,
|
|
272
|
+
input: union([binaryInputSchema, valueFunctionInputSchema]),
|
|
273
|
+
}).superRefine((callable, context) => {
|
|
251
274
|
if (callable.auth !== 'authorized' && callable.policy !== undefined) {
|
|
252
275
|
context.addIssue({
|
|
253
276
|
code: 'custom',
|
|
@@ -257,61 +280,57 @@ const functionDefinitionSchema = z
|
|
|
257
280
|
});
|
|
258
281
|
}
|
|
259
282
|
});
|
|
260
|
-
const policyExpressionSchema =
|
|
261
|
-
|
|
283
|
+
const policyExpressionSchema = union([
|
|
284
|
+
strictObject({
|
|
262
285
|
match: policyPatternExpressionSchema,
|
|
263
286
|
}),
|
|
264
|
-
|
|
265
|
-
allOf:
|
|
287
|
+
strictObject({
|
|
288
|
+
allOf: array(policyRefSchema).min(1),
|
|
266
289
|
}),
|
|
267
|
-
|
|
268
|
-
anyOf:
|
|
290
|
+
strictObject({
|
|
291
|
+
anyOf: array(policyRefSchema).min(1),
|
|
269
292
|
}),
|
|
270
293
|
]);
|
|
271
|
-
const policyDefinitionSchema =
|
|
294
|
+
const policyDefinitionSchema = strictObject({
|
|
272
295
|
ref: policyRefSchema,
|
|
273
296
|
expression: policyExpressionSchema,
|
|
274
297
|
description: descriptionSchema.optional(),
|
|
275
298
|
});
|
|
276
|
-
const viewTargetSchema =
|
|
277
|
-
|
|
278
|
-
z.strictObject({
|
|
279
|
-
kind: z.literal('definition'),
|
|
280
|
-
definitions: uniqueArray(classRefSchema).min(1),
|
|
281
|
-
}),
|
|
282
|
-
]);
|
|
283
|
-
const viewDefinitionSchema = z.strictObject({
|
|
299
|
+
const viewTargetSchema = strictObject({ kind: literal('domain') });
|
|
300
|
+
const viewDefinitionSchema = strictObject({
|
|
284
301
|
ref: viewRefSchema,
|
|
285
302
|
description: descriptionSchema.optional(),
|
|
286
303
|
target: viewTargetSchema,
|
|
287
304
|
});
|
|
288
|
-
const coreNodeSchema =
|
|
305
|
+
const coreNodeSchema = strictObject({
|
|
289
306
|
ref: coreRefSchema,
|
|
290
307
|
class: classRefSchema,
|
|
291
|
-
properties:
|
|
308
|
+
properties: record(propertyKeySchema, jsonValueSchema),
|
|
292
309
|
});
|
|
293
|
-
const coreEdgeSchema =
|
|
310
|
+
const coreEdgeSchema = strictObject({
|
|
294
311
|
class: classRefSchema,
|
|
295
312
|
source: coreEndpointRefSchema,
|
|
296
313
|
target: coreEndpointRefSchema,
|
|
297
|
-
properties:
|
|
314
|
+
properties: record(propertyKeySchema, jsonValueSchema),
|
|
298
315
|
});
|
|
299
|
-
const coreSchema =
|
|
300
|
-
nodes:
|
|
301
|
-
edges:
|
|
316
|
+
const coreSchema = strictObject({
|
|
317
|
+
nodes: record(coreSlugSchema, coreNodeSchema),
|
|
318
|
+
edges: array(coreEdgeSchema),
|
|
302
319
|
});
|
|
303
|
-
const structuralSchema =
|
|
304
|
-
format:
|
|
305
|
-
version:
|
|
320
|
+
const structuralSchema = strictObject({
|
|
321
|
+
format: literal(DOMAIN_FORMAT),
|
|
322
|
+
version: literal(DOMAIN_VERSION),
|
|
306
323
|
origin: originSchema,
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
324
|
+
name: domainNameSchema,
|
|
325
|
+
entrypoint: viewRefSchema.optional(),
|
|
326
|
+
dependencies: record(dependencyAliasSchema, domainDependencySchema),
|
|
327
|
+
classes: record(memberNameSchema, classDeclarationSchema),
|
|
328
|
+
functions: record(memberNameSchema, functionDefinitionSchema),
|
|
329
|
+
policies: record(memberNameSchema, policyDefinitionSchema),
|
|
330
|
+
views: record(memberNameSchema, viewDefinitionSchema),
|
|
312
331
|
core: coreSchema,
|
|
313
332
|
});
|
|
314
|
-
|
|
333
|
+
const domainSchemaStructuralSchema = structuralSchema;
|
|
315
334
|
export function parseDomainSchemaStructure(input) {
|
|
316
335
|
const result = domainSchemaStructuralSchema.safeParse(input);
|
|
317
336
|
if (result.success)
|
|
@@ -319,14 +338,38 @@ export function parseDomainSchemaStructure(input) {
|
|
|
319
338
|
throw new SchemaError(result.error.issues.flatMap((issue) => diagnosticsForIssue(issue, input)));
|
|
320
339
|
}
|
|
321
340
|
function absoluteRefSchema(kind) {
|
|
322
|
-
return
|
|
341
|
+
return strictObject({
|
|
323
342
|
origin: originSchema,
|
|
324
|
-
kind:
|
|
343
|
+
kind: literal(kind),
|
|
325
344
|
name: memberNameSchema,
|
|
326
345
|
});
|
|
327
346
|
}
|
|
347
|
+
function isStateTransitions(input) {
|
|
348
|
+
if (!isRecord(input))
|
|
349
|
+
return false;
|
|
350
|
+
for (const state of Reflect.ownKeys(input)) {
|
|
351
|
+
if (typeof state !== 'string' || state.length === 0)
|
|
352
|
+
return false;
|
|
353
|
+
const outgoing = Reflect.get(input, state);
|
|
354
|
+
if (!isRecord(outgoing))
|
|
355
|
+
return false;
|
|
356
|
+
for (const event of Reflect.ownKeys(outgoing)) {
|
|
357
|
+
const target = Reflect.get(outgoing, event);
|
|
358
|
+
if (typeof event !== 'string' ||
|
|
359
|
+
event.length === 0 ||
|
|
360
|
+
typeof target !== 'string' ||
|
|
361
|
+
target.length === 0) {
|
|
362
|
+
return false;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
return true;
|
|
367
|
+
}
|
|
368
|
+
function isRecord(input) {
|
|
369
|
+
return input !== null && typeof input === 'object' && !Array.isArray(input);
|
|
370
|
+
}
|
|
328
371
|
function uniqueArray(element) {
|
|
329
|
-
return
|
|
372
|
+
return array(element).superRefine((values, context) => {
|
|
330
373
|
const firstIndexByValue = new Map();
|
|
331
374
|
values.forEach((value, index) => {
|
|
332
375
|
const key = canonicalJson(value);
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
+
import { policyObjectOrigin, policyVariableClass } from '../../../language/index.js';
|
|
1
2
|
import { BRANCH_OVERFLOW, MAX_BRANCHES, MAX_CHECK_DEPTH, MAX_CHECK_LEAVES, MAX_DOMAINS, MAX_EDGES, MAX_PATTERN_DEPTH, MAX_REPEAT, MAX_VARIABLES, measureChecks, } from '../../../language/policy/analysis/budgets.js';
|
|
2
3
|
import { escapePointer } from './context.js';
|
|
3
4
|
export { BRANCH_OVERFLOW, MAX_BRANCHES, MAX_CHECK_DEPTH, MAX_CHECK_LEAVES, MAX_DOMAINS, MAX_EDGES, MAX_PATTERN_DEPTH, MAX_REPEAT, MAX_VARIABLES, measureChecks, };
|
|
4
5
|
export function validatePolicyBudgets(context) {
|
|
6
|
+
// Measure every distinct composition node once. A node's expanded measure is independent of the
|
|
7
|
+
// path that reaches it (the only path-sensitive outcome, the back-edge `undefined`, already holds
|
|
8
|
+
// for every node on or reaching a composition cycle, regardless of entry), so caching the
|
|
9
|
+
// completed result by node identity turns path enumeration over the composition DAG into work
|
|
10
|
+
// linear in the number of nodes while preserving the exact measure and PL_BUDGET decision.
|
|
11
|
+
const measures = new Map();
|
|
5
12
|
for (const name of Object.keys(context.environment.candidate.policies)) {
|
|
6
|
-
const measure = measurePolicy(context, name, new Set());
|
|
13
|
+
const measure = measurePolicy(context, name, new Set(), measures);
|
|
7
14
|
if (measure === undefined)
|
|
8
15
|
continue;
|
|
9
16
|
const pointer = `/policies/${escapePointer(name)}`;
|
|
@@ -15,21 +22,28 @@ export function validatePolicyBudgets(context) {
|
|
|
15
22
|
}
|
|
16
23
|
const edgeMaximum = Math.max(0, ...measure.edgeCounts);
|
|
17
24
|
if (edgeMaximum > MAX_EDGES) {
|
|
18
|
-
context.add('PL_BUDGET', pointer, `A normalized branch contains ${edgeMaximum}
|
|
25
|
+
context.add('PL_BUDGET', pointer, `A normalized branch contains ${edgeMaximum} graph predicates; the maximum is ${MAX_EDGES}.`);
|
|
19
26
|
}
|
|
20
27
|
if (measure.domains.size > MAX_DOMAINS) {
|
|
21
28
|
context.add('PL_BUDGET', pointer, `Expanded Pattern references ${measure.domains.size} Domains; the maximum is ${MAX_DOMAINS}.`);
|
|
22
29
|
}
|
|
23
30
|
}
|
|
24
31
|
}
|
|
25
|
-
function measurePolicy(context, name, visiting) {
|
|
32
|
+
function measurePolicy(context, name, visiting, measures) {
|
|
26
33
|
if (visiting.has(name))
|
|
27
34
|
return undefined;
|
|
35
|
+
if (measures.has(name))
|
|
36
|
+
return measures.get(name);
|
|
28
37
|
const declaration = context.normalized.get(name);
|
|
29
38
|
if (declaration === undefined)
|
|
30
39
|
return undefined;
|
|
31
40
|
const nested = new Set(visiting);
|
|
32
41
|
nested.add(name);
|
|
42
|
+
const measure = measureDeclaration(context, declaration, nested, measures);
|
|
43
|
+
measures.set(name, measure);
|
|
44
|
+
return measure;
|
|
45
|
+
}
|
|
46
|
+
function measureDeclaration(context, declaration, nested, measures) {
|
|
33
47
|
if ('match' in declaration) {
|
|
34
48
|
return measurePattern(declaration.match, context.environment.candidate.origin);
|
|
35
49
|
}
|
|
@@ -37,7 +51,7 @@ function measurePolicy(context, name, visiting) {
|
|
|
37
51
|
const children = refs.flatMap((ref) => {
|
|
38
52
|
if (!context.isLocalPolicy(ref))
|
|
39
53
|
return [];
|
|
40
|
-
const value = measurePolicy(context, ref.name, nested);
|
|
54
|
+
const value = measurePolicy(context, ref.name, nested, measures);
|
|
41
55
|
return value === undefined ? [] : [value];
|
|
42
56
|
});
|
|
43
57
|
if (children.length !== refs.length || children.length === 0)
|
|
@@ -45,11 +59,24 @@ function measurePolicy(context, name, visiting) {
|
|
|
45
59
|
return combineMeasures('allOf' in declaration ? 'allOf' : 'anyOf', children);
|
|
46
60
|
}
|
|
47
61
|
function measurePattern(pattern, ownOrigin) {
|
|
62
|
+
if ('sameNode' in pattern)
|
|
63
|
+
return {
|
|
64
|
+
depth: 1,
|
|
65
|
+
edgeCounts: [1],
|
|
66
|
+
domains: new Set([
|
|
67
|
+
ownOrigin,
|
|
68
|
+
...[pattern.sameNode.left, pattern.sameNode.right].flatMap((term) => term.kind === 'ref' ? [policyObjectOrigin(term.ref)] : []),
|
|
69
|
+
]),
|
|
70
|
+
};
|
|
48
71
|
if (isEdge(pattern)) {
|
|
49
72
|
return {
|
|
50
73
|
depth: 1,
|
|
51
74
|
edgeCounts: [1],
|
|
52
|
-
domains: new Set([
|
|
75
|
+
domains: new Set([
|
|
76
|
+
ownOrigin,
|
|
77
|
+
pattern.class.origin,
|
|
78
|
+
...[pattern.source, pattern.target].flatMap((term) => term.kind === 'ref' ? [policyObjectOrigin(term.ref)] : []),
|
|
79
|
+
]),
|
|
53
80
|
};
|
|
54
81
|
}
|
|
55
82
|
if ('exists' in pattern) {
|
|
@@ -59,7 +86,10 @@ function measurePattern(pattern, ownOrigin) {
|
|
|
59
86
|
edgeCounts: child.edgeCounts,
|
|
60
87
|
domains: new Set([
|
|
61
88
|
...child.domains,
|
|
62
|
-
...pattern.exists.nodes.
|
|
89
|
+
...pattern.exists.nodes.flatMap((node) => {
|
|
90
|
+
const ref = policyVariableClass(node);
|
|
91
|
+
return ref === undefined ? [] : [ref.origin];
|
|
92
|
+
}),
|
|
63
93
|
]),
|
|
64
94
|
};
|
|
65
95
|
}
|