@astrale-os/kernel-dsl 0.2.0-beta.9 → 1.0.0-beta.2
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 +138 -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 +19 -3
- package/dist/v1/schema/compatibility/meaning.d.ts +0 -29
- package/dist/v1/schema/compatibility/meaning.js +0 -605
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type Value as JsonValue, type Object as JsonObject } from '@astrale-os/kernel-dsl/value';
|
|
2
|
+
import { type ValueProgram, type CompiledFunction } from '../../model/schema.js';
|
|
3
|
+
/** Decode one Function declaration and its callable contract. */
|
|
4
|
+
export declare function compiledFunction(input: JsonValue, values: readonly ValueProgram[], path: string): CompiledFunction;
|
|
5
|
+
/** Check the shared Function and Method wire grammar. */
|
|
6
|
+
export declare function compiledCallable(input: JsonValue | JsonObject, values: readonly ValueProgram[], method: boolean, path: string): void;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import {} from '@astrale-os/kernel-dsl/value';
|
|
2
|
+
import {} from '../../model/schema.js';
|
|
3
|
+
import { invalid, pointer } from '../diagnostic.js';
|
|
4
|
+
import { callablePolicy } from './policy.js';
|
|
5
|
+
import { definitionRef } from './reference.js';
|
|
6
|
+
import { object, exact, memberName, boolean, description, index, integer, array } from './value.js';
|
|
7
|
+
/** Decode one Function declaration and its callable contract. */
|
|
8
|
+
export function compiledFunction(input, values, path) {
|
|
9
|
+
const value = object(input, 'Compiled Function', path);
|
|
10
|
+
compiledCallable(value, values, false, path);
|
|
11
|
+
definitionRef(value.ref, 'function', 'Function ref', `${path}/ref`);
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
14
|
+
/** Check the shared Function and Method wire grammar. */
|
|
15
|
+
export function compiledCallable(input, values, method, path) {
|
|
16
|
+
const value = object(input, 'Compiled Callable', path);
|
|
17
|
+
exact(value, method
|
|
18
|
+
? ['name', 'auth', 'static', 'abstract', 'input', 'output']
|
|
19
|
+
: ['ref', 'auth', 'input', 'output'], 'Compiled Callable', path, ['policy', 'description', 'execution', 'fields']);
|
|
20
|
+
if (method) {
|
|
21
|
+
memberName(value.name, 'Method name', `${path}/name`);
|
|
22
|
+
boolean(value.static, 'Method static', `${path}/static`);
|
|
23
|
+
boolean(value.abstract, 'Method abstract', `${path}/abstract`);
|
|
24
|
+
}
|
|
25
|
+
if (value.auth !== 'anonymous' && value.auth !== 'authenticated' && value.auth !== 'authorized') {
|
|
26
|
+
invalid('Callable auth', undefined, `${path}/auth`);
|
|
27
|
+
}
|
|
28
|
+
description(value.description, 'Callable description', `${path}/description`);
|
|
29
|
+
if (value.policy !== undefined) {
|
|
30
|
+
if (value.auth !== 'authorized') {
|
|
31
|
+
invalid('Callable Policy placement', undefined, `${path}/policy`);
|
|
32
|
+
}
|
|
33
|
+
callablePolicy(value.policy, `${path}/policy`);
|
|
34
|
+
}
|
|
35
|
+
let inputIndex;
|
|
36
|
+
if (!method && typeof value.input === 'object' && value.input !== null) {
|
|
37
|
+
const inputPath = `${path}/input`;
|
|
38
|
+
const binary = object(value.input, 'Binary input', inputPath);
|
|
39
|
+
exact(binary, ['mode', 'metadata', 'maximumBytes'], 'Binary input', inputPath);
|
|
40
|
+
if (binary.mode !== 'binary')
|
|
41
|
+
invalid('Binary input mode', undefined, `${inputPath}/mode`);
|
|
42
|
+
inputIndex = index(binary.metadata, values.length, 'Binary input metadata', `${inputPath}/metadata`);
|
|
43
|
+
const maximumBytes = integer(binary.maximumBytes, 'Binary input maximumBytes', `${inputPath}/maximumBytes`);
|
|
44
|
+
if (maximumBytes < 1)
|
|
45
|
+
invalid('Binary input maximumBytes', undefined, `${inputPath}/maximumBytes`);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
inputIndex = index(value.input, values.length, 'Callable input', `${path}/input`);
|
|
49
|
+
}
|
|
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
|
+
const outputPath = `${path}/output`;
|
|
63
|
+
const output = object(value.output, 'Callable output', outputPath);
|
|
64
|
+
if (output.mode === 'binary')
|
|
65
|
+
exact(output, ['mode'], 'binary output', outputPath);
|
|
66
|
+
else {
|
|
67
|
+
if (output.mode !== 'value' && output.mode !== 'stream')
|
|
68
|
+
invalid('Callable output mode', undefined, `${outputPath}/mode`);
|
|
69
|
+
exact(output, ['mode', 'value'], 'Callable output', outputPath);
|
|
70
|
+
index(output.value, values.length, 'Callable output value', `${outputPath}/value`);
|
|
71
|
+
}
|
|
72
|
+
if (value.execution !== undefined) {
|
|
73
|
+
const executionPath = `${path}/execution`;
|
|
74
|
+
const execution = object(value.execution, 'Callable execution', executionPath);
|
|
75
|
+
exact(execution, ['durable'], 'Callable execution', executionPath);
|
|
76
|
+
// Ordinary execution is canonically absent; only the durable modifier is retained.
|
|
77
|
+
if (!boolean(execution.durable, 'Callable execution durable', `${executionPath}/durable`)) {
|
|
78
|
+
invalid('Callable execution', 'COMPILED_CANONICAL_MISMATCH', `${executionPath}/durable`);
|
|
79
|
+
}
|
|
80
|
+
if (value.auth === 'anonymous') {
|
|
81
|
+
invalid('durable Callable auth', 'COMPILED_SOURCE_INVALID', `${path}/auth`);
|
|
82
|
+
}
|
|
83
|
+
if (typeof value.input === 'object' && value.input !== null) {
|
|
84
|
+
invalid('durable Callable input', 'COMPILED_SOURCE_INVALID', `${path}/input`);
|
|
85
|
+
}
|
|
86
|
+
if (output.mode !== 'value') {
|
|
87
|
+
invalid('durable Callable output', 'COMPILED_SOURCE_INVALID', `${outputPath}/mode`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type Value as JsonValue } from '@astrale-os/kernel-dsl/value';
|
|
2
|
+
import { type ValueProgram, type CompiledClass } from '../../model/schema.js';
|
|
3
|
+
/** Decode one Node or Edge Class with its declared members. */
|
|
4
|
+
export declare function compiledClass(input: JsonValue, values: readonly ValueProgram[], path: string): CompiledClass;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import {} from '@astrale-os/kernel-dsl/value';
|
|
2
|
+
import { Key } from '../../../addressing/index.js';
|
|
3
|
+
import { MEDIA_TYPE_PATTERN } from '../../../language/class/model/data.js';
|
|
4
|
+
import {} from '../../model/schema.js';
|
|
5
|
+
import { invalid } from '../diagnostic.js';
|
|
6
|
+
import { compiledCallable } from './callable.js';
|
|
7
|
+
import { classRuleChecks } from './policy.js';
|
|
8
|
+
import { compiledProperty } from './property.js';
|
|
9
|
+
import { definitionRef } from './reference.js';
|
|
10
|
+
import { object, exact, boolean, description, array, unique, boundedString, string, memberName, } from './value.js';
|
|
11
|
+
/** Decode one Node or Edge Class with its declared members. */
|
|
12
|
+
export function compiledClass(input, values, path) {
|
|
13
|
+
const value = object(input, 'Compiled Class', path);
|
|
14
|
+
if (value.kind !== 'node' && value.kind !== 'edge')
|
|
15
|
+
invalid('Class kind', undefined, `${path}/kind`);
|
|
16
|
+
exact(value, value.kind === 'node'
|
|
17
|
+
? ['ref', 'kind', 'abstract', 'extends', 'properties', 'methods', 'policies']
|
|
18
|
+
: [
|
|
19
|
+
'ref',
|
|
20
|
+
'kind',
|
|
21
|
+
'abstract',
|
|
22
|
+
'extends',
|
|
23
|
+
'orientation',
|
|
24
|
+
'endpoints',
|
|
25
|
+
'constraints',
|
|
26
|
+
'properties',
|
|
27
|
+
'policies',
|
|
28
|
+
], 'Compiled Class', path, value.kind === 'node' ? ['data', 'description', 'icon'] : ['description']);
|
|
29
|
+
definitionRef(value.ref, 'class', 'Class ref', `${path}/ref`);
|
|
30
|
+
boolean(value.abstract, 'Class abstract', `${path}/abstract`);
|
|
31
|
+
description(value.description, 'Class description', `${path}/description`);
|
|
32
|
+
const extendsPath = `${path}/extends`;
|
|
33
|
+
const parents = array(value.extends, 'Class extends', extendsPath).map((parent, index) => definitionRef(parent, 'class', 'Class parent', `${extendsPath}/${index}`));
|
|
34
|
+
unique(parents.map(Key.of), 'Class parents', extendsPath);
|
|
35
|
+
const propertiesPath = `${path}/properties`;
|
|
36
|
+
const properties = array(value.properties, 'Class properties', propertiesPath).map((property, index) => compiledProperty(property, values, value.kind === 'node', `${propertiesPath}/${index}`));
|
|
37
|
+
unique(properties.map((property) => property.name), 'Class Properties', propertiesPath);
|
|
38
|
+
if (value.kind === 'node') {
|
|
39
|
+
if (value.data !== undefined)
|
|
40
|
+
dataDefinition(value.data, `${path}/data`);
|
|
41
|
+
boundedString(value.icon, 1, 8000, 'Class icon', `${path}/icon`);
|
|
42
|
+
classPolicies(value.policies, 'node', `${path}/policies`);
|
|
43
|
+
const methodsPath = `${path}/methods`;
|
|
44
|
+
const methods = array(value.methods, 'Class methods', methodsPath);
|
|
45
|
+
for (const [index, method] of methods.entries())
|
|
46
|
+
compiledCallable(method, values, true, `${methodsPath}/${index}`);
|
|
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);
|
|
52
|
+
}
|
|
53
|
+
return { ...value, properties };
|
|
54
|
+
}
|
|
55
|
+
function classPolicies(input, kind, path) {
|
|
56
|
+
const value = object(input, 'Class Policies', path);
|
|
57
|
+
exact(value, [], 'Class Policies', path, ['read', 'traverse']);
|
|
58
|
+
if (value.read !== undefined)
|
|
59
|
+
classPolicy(value.read, kind, 'Class read Policy', `${path}/read`);
|
|
60
|
+
if (value.traverse !== undefined)
|
|
61
|
+
classPolicy(value.traverse, kind, 'Class traverse Policy', `${path}/traverse`);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Check one observation slot: `false`, the rule no caller satisfies, a named Policy, or, on a Node
|
|
65
|
+
* Class only, Policy checks over the observed Node.
|
|
66
|
+
*/
|
|
67
|
+
function classPolicy(input, kind, label, path) {
|
|
68
|
+
if (kind === 'node' &&
|
|
69
|
+
input !== null &&
|
|
70
|
+
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);
|
|
77
|
+
}
|
|
78
|
+
function edgeContract(value, path) {
|
|
79
|
+
const constraintsPath = `${path}/constraints`;
|
|
80
|
+
const constraints = object(value.constraints, 'Edge constraints', constraintsPath);
|
|
81
|
+
exact(constraints, [], 'Edge constraints', constraintsPath, ['noSelf', 'acyclic']);
|
|
82
|
+
if (constraints.noSelf !== undefined && constraints.noSelf !== true)
|
|
83
|
+
invalid('Edge noSelf constraint', undefined, `${constraintsPath}/noSelf`);
|
|
84
|
+
if (constraints.acyclic !== undefined && constraints.acyclic !== true)
|
|
85
|
+
invalid('Edge acyclic constraint', undefined, `${constraintsPath}/acyclic`);
|
|
86
|
+
if (value.orientation === 'directed') {
|
|
87
|
+
const endpointsPath = `${path}/endpoints`;
|
|
88
|
+
const endpoints = object(value.endpoints, 'directed Edge endpoints', endpointsPath);
|
|
89
|
+
exact(endpoints, ['source', 'target'], 'directed Edge endpoints', endpointsPath);
|
|
90
|
+
edgeEndpoint(endpoints.source, 'outgoing', 'directed Edge source', `${endpointsPath}/source`);
|
|
91
|
+
edgeEndpoint(endpoints.target, 'incoming', 'directed Edge target', `${endpointsPath}/target`);
|
|
92
|
+
if (object(endpoints.source, 'directed Edge source', `${endpointsPath}/source`).role ===
|
|
93
|
+
object(endpoints.target, 'directed Edge target', `${endpointsPath}/target`).role) {
|
|
94
|
+
invalid('Edge endpoint roles', undefined, endpointsPath);
|
|
95
|
+
}
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if (value.orientation !== 'undirected' || constraints.acyclic !== undefined) {
|
|
99
|
+
invalid('Edge orientation', undefined, `${path}/orientation`);
|
|
100
|
+
}
|
|
101
|
+
const endpointsPath = `${path}/endpoints`;
|
|
102
|
+
const endpoints = array(value.endpoints, 'undirected Edge endpoints', endpointsPath);
|
|
103
|
+
if (endpoints.length !== 2)
|
|
104
|
+
invalid('undirected Edge endpoints', undefined, endpointsPath);
|
|
105
|
+
edgeEndpoint(endpoints[0], 'incident', 'undirected first endpoint', `${endpointsPath}/0`);
|
|
106
|
+
edgeEndpoint(endpoints[1], 'incident', 'undirected second endpoint', `${endpointsPath}/1`);
|
|
107
|
+
if (object(endpoints[0], 'undirected first endpoint', `${endpointsPath}/0`).role ===
|
|
108
|
+
object(endpoints[1], 'undirected second endpoint', `${endpointsPath}/1`).role) {
|
|
109
|
+
invalid('Edge endpoint roles', undefined, endpointsPath);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function edgeEndpoint(input, count, label, path) {
|
|
113
|
+
const value = object(input, label, path);
|
|
114
|
+
exact(value, ['role', 'accepts', count], label, path);
|
|
115
|
+
memberName(value.role, `${label} role`, `${path}/role`);
|
|
116
|
+
const acceptsPath = `${path}/accepts`;
|
|
117
|
+
const accepts = array(value.accepts, `${label} accepts`, acceptsPath).map((item, index) => definitionRef(item, 'class', `${label} accepted Class`, `${acceptsPath}/${index}`));
|
|
118
|
+
if (accepts.length === 0)
|
|
119
|
+
invalid(`${label} accepts`, undefined, acceptsPath);
|
|
120
|
+
unique(accepts.map(Key.of), `${label} accepts`, acceptsPath);
|
|
121
|
+
if (value[count] !== '0..*' &&
|
|
122
|
+
value[count] !== '1..*' &&
|
|
123
|
+
value[count] !== '0..1' &&
|
|
124
|
+
value[count] !== '1') {
|
|
125
|
+
invalid(`${label} ${count}`, undefined, `${path}/${count}`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
function dataDefinition(input, path) {
|
|
129
|
+
const value = object(input, 'Class data', path);
|
|
130
|
+
exact(value, ['mediaType'], 'Class data', path);
|
|
131
|
+
if (typeof value.mediaType !== 'string' || !MEDIA_TYPE_PATTERN.test(value.mediaType))
|
|
132
|
+
invalid('Class data mediaType', undefined, `${path}/mediaType`);
|
|
133
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type Value as JsonValue } from '@astrale-os/kernel-dsl/value';
|
|
2
|
+
/** Decode a Core Node declaration and its Property values. */
|
|
3
|
+
export declare function compiledCoreDefinition(input: JsonValue, path: string): never;
|
|
4
|
+
/** Decode a Core Edge fact and its endpoints. */
|
|
5
|
+
export declare function compiledCoreEdge(input: JsonValue, path: string): never;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {} from '@astrale-os/kernel-dsl/value';
|
|
2
|
+
import { PropertyValues } from '../../../language/class/property-values.js';
|
|
3
|
+
import { invalid } from '../diagnostic.js';
|
|
4
|
+
import { definitionRef, coreEndpoint } from './reference.js';
|
|
5
|
+
import { object, exact } from './value.js';
|
|
6
|
+
/** Decode a Core Node declaration and its Property values. */
|
|
7
|
+
export function compiledCoreDefinition(input, path) {
|
|
8
|
+
const value = object(input, 'Core Definition', path);
|
|
9
|
+
exact(value, ['ref', 'class', 'properties'], 'Core Definition', path);
|
|
10
|
+
definitionRef(value.ref, 'core', 'Core ref', `${path}/ref`);
|
|
11
|
+
definitionRef(value.class, 'class', 'Core Class', `${path}/class`);
|
|
12
|
+
propertyValues(value.properties, 'Core Properties', `${path}/properties`);
|
|
13
|
+
return value;
|
|
14
|
+
}
|
|
15
|
+
/** Decode a Core Edge fact and its endpoints. */
|
|
16
|
+
export function compiledCoreEdge(input, path) {
|
|
17
|
+
const value = object(input, 'Core Edge', path);
|
|
18
|
+
exact(value, ['class', 'source', 'target', 'properties'], 'Core Edge', path);
|
|
19
|
+
definitionRef(value.class, 'class', 'Core Edge Class', `${path}/class`);
|
|
20
|
+
coreEndpoint(value.source, 'Core Edge source', `${path}/source`);
|
|
21
|
+
coreEndpoint(value.target, 'Core Edge target', `${path}/target`);
|
|
22
|
+
propertyValues(value.properties, 'Core Edge Properties', `${path}/properties`);
|
|
23
|
+
return value;
|
|
24
|
+
}
|
|
25
|
+
function propertyValues(input, label, path) {
|
|
26
|
+
try {
|
|
27
|
+
PropertyValues.accept(input, path);
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
invalid(label, undefined, path);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type Value as JsonValue } from '@astrale-os/kernel-dsl/value';
|
|
2
|
+
import { type Revision } from '../../../addressing/index.js';
|
|
3
|
+
import { type CompiledSchemaEntry } from '../../model/schema.js';
|
|
4
|
+
/** Decode one exact Domain revision pin. */
|
|
5
|
+
export declare function dependency(input: JsonValue | undefined, label: string, path: string): {
|
|
6
|
+
origin: string;
|
|
7
|
+
revision: Revision;
|
|
8
|
+
};
|
|
9
|
+
/** Decode and canonically order direct dependency aliases. */
|
|
10
|
+
export declare function dependencyMap(input: JsonValue | undefined, path: string): CompiledSchemaEntry['dependencies'];
|
|
11
|
+
/** Require a canonical Domain origin. */
|
|
12
|
+
export declare function originValue(input: JsonValue | undefined, label: string, path: string): string;
|
|
13
|
+
/** Require a canonical content-addressed revision. */
|
|
14
|
+
export declare function revisionValue(input: JsonValue | undefined, label: string, path: string): Revision;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import {} from '@astrale-os/kernel-dsl/value';
|
|
2
|
+
import {} from '../../../addressing/index.js';
|
|
3
|
+
import { DEPENDENCY_ALIAS_PATTERN, DOMAIN_ORIGIN_PATTERN, DOMAIN_REVISION_PATTERN, } from '../../../addressing/patterns.js';
|
|
4
|
+
import {} from '../../model/schema.js';
|
|
5
|
+
import { pointer, invalid } from '../diagnostic.js';
|
|
6
|
+
import { object, exact, compare } from './value.js';
|
|
7
|
+
/** Decode one exact Domain revision pin. */
|
|
8
|
+
export function dependency(input, label, path) {
|
|
9
|
+
const value = object(input, label, path);
|
|
10
|
+
exact(value, ['origin', 'revision'], label, path);
|
|
11
|
+
return {
|
|
12
|
+
origin: originValue(value.origin, label, `${path}/origin`),
|
|
13
|
+
revision: revisionValue(value.revision, label, `${path}/revision`),
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/** Decode and canonically order direct dependency aliases. */
|
|
17
|
+
export function dependencyMap(input, path) {
|
|
18
|
+
const value = object(input, 'dependencies', path);
|
|
19
|
+
const accepted = Object.create(null);
|
|
20
|
+
for (const [alias, inputDependency] of Object.entries(value).sort(([left], [right]) => compare(left, right))) {
|
|
21
|
+
const aliasPath = pointer(path, alias);
|
|
22
|
+
if (!DEPENDENCY_ALIAS_PATTERN.test(alias) ||
|
|
23
|
+
alias === '__proto__' ||
|
|
24
|
+
alias === 'prototype' ||
|
|
25
|
+
alias === 'constructor') {
|
|
26
|
+
invalid('dependency alias', undefined, aliasPath);
|
|
27
|
+
}
|
|
28
|
+
accepted[alias] = dependency(inputDependency, `dependency ${alias}`, aliasPath);
|
|
29
|
+
}
|
|
30
|
+
return accepted;
|
|
31
|
+
}
|
|
32
|
+
/** Require a canonical Domain origin. */
|
|
33
|
+
export function originValue(input, label, path) {
|
|
34
|
+
if (typeof input !== 'string' || !DOMAIN_ORIGIN_PATTERN.test(input))
|
|
35
|
+
invalid(label, undefined, path);
|
|
36
|
+
return input;
|
|
37
|
+
}
|
|
38
|
+
/** Require a canonical content-addressed revision. */
|
|
39
|
+
export function revisionValue(input, label, path) {
|
|
40
|
+
if (typeof input !== 'string' || !DOMAIN_REVISION_PATTERN.test(input))
|
|
41
|
+
invalid(label, undefined, path);
|
|
42
|
+
return input;
|
|
43
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type Value as JsonValue } from '@astrale-os/kernel-dsl/value';
|
|
2
|
+
import { type CompiledSchemaEntry } from '../../model/schema.js';
|
|
3
|
+
import { type Machines } from './pattern.js';
|
|
4
|
+
/** Decode one closure entry and verify its exact semantic revision. */
|
|
5
|
+
export declare function entry(input: JsonValue, entryIndex: number, path: string, machines: Machines): CompiledSchemaEntry;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import {} from '@astrale-os/kernel-dsl/value';
|
|
2
|
+
import {} from '../../../addressing/index.js';
|
|
3
|
+
import * as metadata from '../../../language/definition/metadata.js';
|
|
4
|
+
import { bindValueProgram } from '../../../language/value/compile/load.js';
|
|
5
|
+
import {} from '../../model/schema.js';
|
|
6
|
+
import { invalid, pointer } from '../diagnostic.js';
|
|
7
|
+
import { revisionOfCompiledEntry } from '../revision.js';
|
|
8
|
+
import { compiledFunction } from './callable.js';
|
|
9
|
+
import { compiledClass } from './class.js';
|
|
10
|
+
import { compiledCoreDefinition, compiledCoreEdge } from './core.js';
|
|
11
|
+
import { originValue, revisionValue, dependencyMap } from './dependency.js';
|
|
12
|
+
import { pattern } from './pattern.js';
|
|
13
|
+
import { compiledPolicy } from './policy.js';
|
|
14
|
+
import { program } from './program.js';
|
|
15
|
+
import { definitionRef } from './reference.js';
|
|
16
|
+
import { object, exact, string, array } from './value.js';
|
|
17
|
+
import { compiledView } from './view.js';
|
|
18
|
+
/** Decode one closure entry and verify its exact semantic revision. */
|
|
19
|
+
export function entry(input, entryIndex, path, machines) {
|
|
20
|
+
const value = object(input, `closure[${entryIndex}]`, path);
|
|
21
|
+
exact(value, ['origin', 'revision', 'name', 'dependencies', 'definitions', 'facts', 'values', 'patterns'], 'entry', path, ['entrypoint']);
|
|
22
|
+
const origin = originValue(value.origin, 'entry origin', `${path}/origin`);
|
|
23
|
+
const name = string(value.name, 'entry name', `${path}/name`);
|
|
24
|
+
if (name.length < metadata.name.minLength ||
|
|
25
|
+
name.length > metadata.name.maxLength ||
|
|
26
|
+
!metadata.isDomainNameText(name))
|
|
27
|
+
invalid('entry name', undefined, `${path}/name`);
|
|
28
|
+
const entrypoint = value.entrypoint === undefined
|
|
29
|
+
? undefined
|
|
30
|
+
: definitionRef(value.entrypoint, 'view', 'entry entrypoint', `${path}/entrypoint`);
|
|
31
|
+
const revision = revisionValue(value.revision, 'entry revision', `${path}/revision`);
|
|
32
|
+
const dependenciesPath = `${path}/dependencies`;
|
|
33
|
+
const dependencies = dependencyMap(value.dependencies, dependenciesPath);
|
|
34
|
+
const dependencyOrigins = new Set();
|
|
35
|
+
for (const [alias, dependency] of Object.entries(dependencies)) {
|
|
36
|
+
if (dependencyOrigins.has(dependency.origin))
|
|
37
|
+
invalid('duplicate dependency', undefined, `${pointer(dependenciesPath, alias)}/origin`);
|
|
38
|
+
dependencyOrigins.add(dependency.origin);
|
|
39
|
+
}
|
|
40
|
+
const valuesPath = `${path}/values`;
|
|
41
|
+
const patternsPath = `${path}/patterns`;
|
|
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));
|
|
45
|
+
const definitionsPath = `${path}/definitions`;
|
|
46
|
+
const definitions = object(value.definitions, 'definitions', definitionsPath);
|
|
47
|
+
exact(definitions, ['classes', 'functions', 'policies', 'views', 'core'], 'definitions', definitionsPath);
|
|
48
|
+
const classesPath = `${definitionsPath}/classes`;
|
|
49
|
+
const classes = array(definitions.classes, 'classes', classesPath).map((item, index) => compiledClass(item, bound, `${classesPath}/${index}`));
|
|
50
|
+
const functionsPath = `${definitionsPath}/functions`;
|
|
51
|
+
const functions = array(definitions.functions, 'functions', functionsPath).map((item, index) => compiledFunction(item, bound, `${functionsPath}/${index}`));
|
|
52
|
+
const factsPath = `${path}/facts`;
|
|
53
|
+
const facts = object(value.facts, 'facts', factsPath);
|
|
54
|
+
exact(facts, ['core'], 'facts', factsPath);
|
|
55
|
+
const policiesPath = `${definitionsPath}/policies`;
|
|
56
|
+
const viewsPath = `${definitionsPath}/views`;
|
|
57
|
+
const coreDefinitionsPath = `${definitionsPath}/core`;
|
|
58
|
+
const coreFactsPath = `${factsPath}/core`;
|
|
59
|
+
const accepted = {
|
|
60
|
+
origin,
|
|
61
|
+
revision,
|
|
62
|
+
name,
|
|
63
|
+
...(entrypoint === undefined ? {} : { entrypoint }),
|
|
64
|
+
dependencies,
|
|
65
|
+
definitions: {
|
|
66
|
+
classes,
|
|
67
|
+
functions,
|
|
68
|
+
policies: array(definitions.policies, 'policies', policiesPath).map((item, index) => compiledPolicy(item, `${policiesPath}/${index}`)),
|
|
69
|
+
views: array(definitions.views, 'views', viewsPath).map((item, index) => compiledView(item, `${viewsPath}/${index}`)),
|
|
70
|
+
core: array(definitions.core, 'core definitions', coreDefinitionsPath).map((item, index) => compiledCoreDefinition(item, `${coreDefinitionsPath}/${index}`)),
|
|
71
|
+
},
|
|
72
|
+
facts: {
|
|
73
|
+
core: array(facts.core, 'core facts', coreFactsPath).map((item, index) => compiledCoreEdge(item, `${coreFactsPath}/${index}`)),
|
|
74
|
+
},
|
|
75
|
+
values,
|
|
76
|
+
patterns,
|
|
77
|
+
};
|
|
78
|
+
const collections = [
|
|
79
|
+
['classes', accepted.definitions.classes],
|
|
80
|
+
['functions', accepted.definitions.functions],
|
|
81
|
+
['policies', accepted.definitions.policies],
|
|
82
|
+
['views', accepted.definitions.views],
|
|
83
|
+
['core', accepted.definitions.core],
|
|
84
|
+
];
|
|
85
|
+
for (const [collection, definitions] of collections) {
|
|
86
|
+
for (const [index, definition] of definitions.entries()) {
|
|
87
|
+
if (definition.ref.origin !== origin)
|
|
88
|
+
invalid('Definition owner origin', undefined, `${definitionsPath}/${collection}/${index}/ref/origin`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (entrypoint !== undefined &&
|
|
92
|
+
(entrypoint.origin !== origin ||
|
|
93
|
+
!accepted.definitions.views.some(({ ref, target }) => ref.name === entrypoint.name && target.kind === 'domain'))) {
|
|
94
|
+
invalid('entry entrypoint', undefined, `${path}/entrypoint`);
|
|
95
|
+
}
|
|
96
|
+
if (revisionOfCompiledEntry(accepted) !== revision) {
|
|
97
|
+
invalid('entry revision', 'COMPILED_CANONICAL_MISMATCH', `${path}/revision`);
|
|
98
|
+
}
|
|
99
|
+
return accepted;
|
|
100
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type Value as JsonValue } from '@astrale-os/kernel-dsl/value';
|
|
2
|
+
import { type Pattern, type RunPattern } from '../../model/schema.js';
|
|
3
|
+
/** The machine compiled from each admitted I-Regexp source, shared by its occurrences. */
|
|
4
|
+
export type Machines = Map<string, Pattern | RunPattern>;
|
|
5
|
+
/**
|
|
6
|
+
* Admit one received pattern as data and return the machine compiled from its source. A received
|
|
7
|
+
* machine never decides membership: it may come from another compiler, from a host with other
|
|
8
|
+
* Unicode data, or from a forger, and the artifact carries no compiler version that could tell a
|
|
9
|
+
* current machine from those, so it is ignored rather than compared. Its source decides, through
|
|
10
|
+
* the same bounded `isIRegexp` and `compilePattern` that source resolution uses.
|
|
11
|
+
*/
|
|
12
|
+
export declare function pattern(input: JsonValue, patternIndex: number, path: string, machines: Machines): Pattern | RunPattern;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import {} from '@astrale-os/kernel-dsl/value';
|
|
2
|
+
import { compilePattern } from '../../../language/value/regexp/compile.js';
|
|
3
|
+
import { isIRegexp } from '../../../language/value/regexp/syntax.js';
|
|
4
|
+
import {} from '../../model/schema.js';
|
|
5
|
+
import { invalid } from '../diagnostic.js';
|
|
6
|
+
import { object, exact, array, integer, scalar, index, boundedInteger } from './value.js';
|
|
7
|
+
/**
|
|
8
|
+
* Admit one received pattern as data and return the machine compiled from its source. A received
|
|
9
|
+
* machine never decides membership: it may come from another compiler, from a host with other
|
|
10
|
+
* Unicode data, or from a forger, and the artifact carries no compiler version that could tell a
|
|
11
|
+
* current machine from those, so it is ignored rather than compared. Its source decides, through
|
|
12
|
+
* the same bounded `isIRegexp` and `compilePattern` that source resolution uses.
|
|
13
|
+
*/
|
|
14
|
+
export function pattern(input, patternIndex, path, machines) {
|
|
15
|
+
const value = object(input, `patterns[${patternIndex}]`, path);
|
|
16
|
+
const { source } = Object.hasOwn(value, 'runs')
|
|
17
|
+
? runPattern(value, path)
|
|
18
|
+
: nfaPattern(value, path);
|
|
19
|
+
let machine = machines.get(source);
|
|
20
|
+
if (machine === undefined) {
|
|
21
|
+
if (!isIRegexp(source))
|
|
22
|
+
invalid('Pattern source', 'COMPILED_SOURCE_INVALID', `${path}/source`);
|
|
23
|
+
machine = compilePattern(source);
|
|
24
|
+
machines.set(source, machine);
|
|
25
|
+
}
|
|
26
|
+
return machine;
|
|
27
|
+
}
|
|
28
|
+
function nfaPattern(value, path) {
|
|
29
|
+
exact(value, ['source', 'start', 'states'], 'Pattern', path);
|
|
30
|
+
if (typeof value.source !== 'string')
|
|
31
|
+
invalid('Pattern source', undefined, `${path}/source`);
|
|
32
|
+
const statesPath = `${path}/states`;
|
|
33
|
+
const states = array(value.states, 'Pattern states', statesPath).map((item, stateIndex) => {
|
|
34
|
+
const statePath = `${statesPath}/${stateIndex}`;
|
|
35
|
+
const state = object(item, 'Pattern state', statePath);
|
|
36
|
+
exact(state, ['epsilon', 'transitions'], 'Pattern state', statePath, ['accepting']);
|
|
37
|
+
if (state.accepting !== undefined && state.accepting !== true)
|
|
38
|
+
invalid('accepting', undefined, `${statePath}/accepting`);
|
|
39
|
+
const epsilonPath = `${statePath}/epsilon`;
|
|
40
|
+
const transitionsPath = `${statePath}/transitions`;
|
|
41
|
+
return {
|
|
42
|
+
epsilon: array(state.epsilon, 'epsilon', epsilonPath).map((target, index) => integer(target, 'epsilon', `${epsilonPath}/${index}`)),
|
|
43
|
+
transitions: array(state.transitions, 'transitions', transitionsPath).map((transitionValue, transitionIndex) => {
|
|
44
|
+
const transitionPath = `${transitionsPath}/${transitionIndex}`;
|
|
45
|
+
const transition = object(transitionValue, 'transition', transitionPath);
|
|
46
|
+
exact(transition, ['to', 'ranges'], 'transition', transitionPath);
|
|
47
|
+
const rangesPath = `${transitionPath}/ranges`;
|
|
48
|
+
return {
|
|
49
|
+
to: integer(transition.to, 'transition target', `${transitionPath}/to`),
|
|
50
|
+
ranges: array(transition.ranges, 'ranges', rangesPath).map((rangeValue, rangeIndex) => {
|
|
51
|
+
const rangePath = `${rangesPath}/${rangeIndex}`;
|
|
52
|
+
const range = array(rangeValue, 'range', rangePath);
|
|
53
|
+
if (range.length !== 2)
|
|
54
|
+
invalid('range', undefined, rangePath);
|
|
55
|
+
const minimum = scalar(range[0], 'range minimum', `${rangePath}/0`);
|
|
56
|
+
const maximum = scalar(range[1], 'range maximum', `${rangePath}/1`);
|
|
57
|
+
if (minimum > maximum)
|
|
58
|
+
invalid('range order', undefined, rangePath);
|
|
59
|
+
return [minimum, maximum];
|
|
60
|
+
}),
|
|
61
|
+
};
|
|
62
|
+
}),
|
|
63
|
+
...(state.accepting === true ? { accepting: true } : {}),
|
|
64
|
+
};
|
|
65
|
+
});
|
|
66
|
+
const start = index(value.start, states.length, 'Pattern start', `${path}/start`);
|
|
67
|
+
for (const [stateIndex, state] of states.entries()) {
|
|
68
|
+
state.epsilon.forEach((target, indexValue) => index(target, states.length, 'epsilon', `${statesPath}/${stateIndex}/epsilon/${indexValue}`));
|
|
69
|
+
state.transitions.forEach(({ to }, transitionIndex) => index(to, states.length, 'transition', `${statesPath}/${stateIndex}/transitions/${transitionIndex}/to`));
|
|
70
|
+
}
|
|
71
|
+
return { source: value.source, start, states };
|
|
72
|
+
}
|
|
73
|
+
function runPattern(value, path) {
|
|
74
|
+
exact(value, ['source', 'runs'], 'RunPattern', path);
|
|
75
|
+
if (typeof value.source !== 'string')
|
|
76
|
+
invalid('Pattern source', undefined, `${path}/source`);
|
|
77
|
+
const entries = array(value.runs, 'scalar runs', `${path}/runs`);
|
|
78
|
+
if (entries.length === 0 || entries.length > 4096) {
|
|
79
|
+
invalid('scalar run count', undefined, `${path}/runs`);
|
|
80
|
+
}
|
|
81
|
+
const runs = entries.map((entry, position) => {
|
|
82
|
+
const runPath = `${path}/runs/${position}`;
|
|
83
|
+
const run = object(entry, 'scalar run', runPath);
|
|
84
|
+
exact(run, ['ranges', 'minimum'], 'scalar run', runPath, ['maximum']);
|
|
85
|
+
const minimum = boundedInteger(run.minimum, 0, 1000, 'run minimum', `${runPath}/minimum`);
|
|
86
|
+
const maximum = run.maximum === undefined
|
|
87
|
+
? undefined
|
|
88
|
+
: boundedInteger(run.maximum, minimum, 1000, 'run maximum', `${runPath}/maximum`);
|
|
89
|
+
if (position !== entries.length - 1 && minimum !== maximum) {
|
|
90
|
+
invalid('exact scalar prefix', undefined, `${runPath}/maximum`);
|
|
91
|
+
}
|
|
92
|
+
let previous = -1;
|
|
93
|
+
const ranges = array(run.ranges, 'scalar ranges', `${runPath}/ranges`).map((entry, index) => {
|
|
94
|
+
const rangePath = `${runPath}/ranges/${index}`;
|
|
95
|
+
const range = array(entry, 'scalar range', rangePath);
|
|
96
|
+
if (range.length !== 2)
|
|
97
|
+
invalid('scalar range', undefined, rangePath);
|
|
98
|
+
const minimum = scalar(range[0], 'range minimum', `${rangePath}/0`);
|
|
99
|
+
const maximum = scalar(range[1], 'range maximum', `${rangePath}/1`);
|
|
100
|
+
if (minimum > maximum ||
|
|
101
|
+
minimum <= previous ||
|
|
102
|
+
(minimum >= 0xd800 && minimum <= 0xdfff) ||
|
|
103
|
+
(maximum >= 0xd800 && maximum <= 0xdfff))
|
|
104
|
+
invalid('ordered scalar range', undefined, rangePath);
|
|
105
|
+
previous = maximum;
|
|
106
|
+
return [minimum, maximum];
|
|
107
|
+
});
|
|
108
|
+
return { ranges, minimum, ...(maximum === undefined ? {} : { maximum }) };
|
|
109
|
+
});
|
|
110
|
+
return { source: value.source, runs };
|
|
111
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type Value as JsonValue } from '@astrale-os/kernel-dsl/value';
|
|
2
|
+
/** Decode a named Policy and its expression grammar. */
|
|
3
|
+
export declare function compiledPolicy(input: JsonValue, path: string): never;
|
|
4
|
+
/** Check one callable's caller rule: `true`, the rule every caller satisfies, or Policy checks. */
|
|
5
|
+
export declare function callablePolicy(input: JsonValue | undefined, path: string): void;
|
|
6
|
+
/**
|
|
7
|
+
* Check one Node Class rule: Policy checks over `self` and `ref` objects only, in their one
|
|
8
|
+
* spelling. A lone check of `self` is spelled as the Policy reference itself.
|
|
9
|
+
*/
|
|
10
|
+
export declare function classRuleChecks(input: JsonValue, path: string): void;
|