@astrale-os/kernel-dsl 1.0.0-beta.2 → 1.0.0-beta.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/v1/addressing/class-key.js +3 -3
- package/dist/v1/addressing/definition-ref.js +21 -37
- package/dist/v1/addressing/domain-dependency.d.ts +0 -6
- package/dist/v1/addressing/domain-dependency.js +1 -6
- package/dist/v1/addressing/key.d.ts +4 -1
- package/dist/v1/addressing/key.js +23 -3
- package/dist/v1/addressing/ordering.d.ts +2 -0
- package/dist/v1/addressing/ordering.js +4 -0
- package/dist/v1/addressing/patterns.d.ts +1 -1
- package/dist/v1/addressing/patterns.js +2 -6
- package/dist/v1/builder/callable/authoring.d.ts +11 -5
- package/dist/v1/builder/callable/authoring.js +2 -0
- package/dist/v1/builder/class/authoring.d.ts +94 -224
- package/dist/v1/builder/class/authoring.js +31 -33
- package/dist/v1/builder/class/handle.d.ts +27 -0
- package/dist/v1/builder/class/handle.js +1 -0
- package/dist/v1/builder/class/input.d.ts +159 -0
- package/dist/v1/builder/class/projection.d.ts +129 -0
- package/dist/v1/builder/class/projection.js +1 -0
- package/dist/v1/builder/class/property.d.ts +3 -9
- package/dist/v1/builder/class/property.js +1 -0
- package/dist/v1/builder/core/authoring.d.ts +1 -1
- package/dist/v1/builder/index.d.ts +5 -2
- package/dist/v1/builder/lowering/callable.js +1 -0
- package/dist/v1/builder/lowering/class.d.ts +9 -1
- package/dist/v1/builder/lowering/class.js +62 -17
- package/dist/v1/builder/lowering/policy.js +2 -0
- package/dist/v1/builder/lowering/property-keys.d.ts +27 -0
- package/dist/v1/builder/lowering/property-keys.js +108 -0
- package/dist/v1/builder/lowering/schema/compile.js +11 -6
- package/dist/v1/builder/lowering/schema/context.d.ts +9 -1
- package/dist/v1/builder/lowering/schema/context.js +36 -4
- package/dist/v1/builder/lowering/schema/lifetime.d.ts +11 -0
- package/dist/v1/builder/lowering/schema/lifetime.js +55 -0
- package/dist/v1/builder/lowering/value/path.d.ts +1 -1
- package/dist/v1/builder/lowering/value/path.js +2 -4
- package/dist/v1/builder/lowering/value/zod.js +1 -3
- package/dist/v1/builder/policy/authoring.d.ts +85 -5
- package/dist/v1/builder/policy/authoring.js +107 -68
- package/dist/v1/builder/schema/define.d.ts +0 -1
- package/dist/v1/builder/schema/diagnostic.d.ts +3 -2
- package/dist/v1/builder/schema/diagnostic.js +5 -10
- package/dist/v1/builder/schema/input.d.ts +1 -1
- package/dist/v1/builder/schema/projection/callable.d.ts +7 -5
- package/dist/v1/builder/schema/projection/class.d.ts +118 -15
- package/dist/v1/builder/schema/projection/core-input.d.ts +2 -1
- package/dist/v1/builder/schema/projection/identity.d.ts +2 -1
- package/dist/v1/builder/schema/projection/model.d.ts +4 -2
- package/dist/v1/builder/schema/projection/property.d.ts +1 -1
- package/dist/v1/builder/schema/projection/resolved-class.d.ts +2 -1
- package/dist/v1/builder/schema/projection.d.ts +1 -1
- package/dist/v1/builder/value/full-match.d.ts +0 -1
- package/dist/v1/builder/value/full-match.js +0 -1
- package/dist/v1/builder/value/path-metadata.d.ts +1 -1
- package/dist/v1/builder/value/path.d.ts +1 -1
- package/dist/v1/bundle/codec.js +11 -13
- package/dist/v1/bundle/diagnostic.d.ts +2 -0
- package/dist/v1/bundle/diagnostic.js +9 -7
- package/dist/v1/bundle/model.js +1 -1
- package/dist/v1/bundle/structure.js +4 -6
- package/dist/v1/compiled/admission/accept.js +4 -10
- package/dist/v1/compiled/admission/closure.js +2 -2
- package/dist/v1/compiled/admission/diagnostic.d.ts +1 -1
- package/dist/v1/compiled/admission/diagnostic.js +1 -3
- package/dist/v1/compiled/admission/revision.d.ts +9 -1
- package/dist/v1/compiled/admission/revision.js +6 -3
- package/dist/v1/compiled/admission/semantics/class.d.ts +4 -1
- package/dist/v1/compiled/admission/semantics/class.js +37 -12
- package/dist/v1/compiled/admission/semantics/core.d.ts +1 -24
- package/dist/v1/compiled/admission/semantics/core.js +56 -24
- package/dist/v1/compiled/admission/semantics/edge.d.ts +2 -4
- package/dist/v1/compiled/admission/semantics/edge.js +6 -65
- package/dist/v1/compiled/admission/semantics/policy/callable.js +0 -2
- package/dist/v1/compiled/admission/semantics/policy/contracts.d.ts +5 -20
- package/dist/v1/compiled/admission/semantics/policy/contracts.js +8 -21
- package/dist/v1/compiled/admission/semantics/policy/parity.js +40 -43
- package/dist/v1/compiled/admission/semantics/policy/pattern.d.ts +4 -1
- package/dist/v1/compiled/admission/semantics/policy/pattern.js +4 -16
- package/dist/v1/compiled/admission/semantics/policy/typing.d.ts +2 -24
- package/dist/v1/compiled/admission/semantics/policy/typing.js +19 -201
- package/dist/v1/compiled/admission/wire/callable.js +11 -1
- package/dist/v1/compiled/admission/wire/class.js +73 -21
- package/dist/v1/compiled/admission/wire/policy.d.ts +4 -3
- package/dist/v1/compiled/admission/wire/policy.js +8 -7
- package/dist/v1/compiled/compiler/compile.js +8 -8
- package/dist/v1/compiled/diagnostic.js +2 -3
- package/dist/v1/compiled/loader/load.d.ts +3 -2
- package/dist/v1/compiled/loader/load.js +11 -45
- package/dist/v1/domain/create.js +5 -6
- package/dist/v1/domain/model/domain.d.ts +2 -7
- package/dist/v1/domain/model/input.d.ts +2 -1
- package/dist/v1/domain/namespace/member-collection.js +4 -6
- package/dist/v1/domain/projection/classes.js +4 -1
- package/dist/v1/domain/validation/create.d.ts +6 -3
- package/dist/v1/domain/validation/create.js +21 -69
- package/dist/v1/index.d.ts +2 -1
- package/dist/v1/language/.spec/schemas/draft-2020-12.schema.json +462 -0
- package/dist/v1/language/.spec/schemas/value-schema.schema.json +22 -0
- package/dist/v1/language/callable/admission.d.ts +15 -0
- package/dist/v1/language/callable/admission.js +43 -0
- package/dist/v1/language/callable/model/callable.d.ts +10 -0
- package/dist/v1/language/callable/resolved.d.ts +16 -3
- package/dist/v1/language/class/inheritance.d.ts +36 -5
- package/dist/v1/language/class/inheritance.js +87 -1
- package/dist/v1/language/class/lifetime.d.ts +50 -11
- package/dist/v1/language/class/lifetime.js +89 -20
- package/dist/v1/language/class/model/class.d.ts +45 -9
- package/dist/v1/language/class/model/edge.d.ts +31 -2
- package/dist/v1/language/class/model/property.d.ts +16 -7
- package/dist/v1/language/class/property-values.js +2 -4
- package/dist/v1/language/class/unique.d.ts +143 -0
- package/dist/v1/language/class/unique.js +264 -0
- package/dist/v1/language/core/facts.d.ts +85 -0
- package/dist/v1/language/core/facts.js +116 -0
- package/dist/v1/language/definition/metadata.d.ts +5 -0
- package/dist/v1/language/definition/metadata.js +7 -0
- package/dist/v1/language/freeze.d.ts +5 -0
- package/dist/v1/{schema/canonical → language}/freeze.js +4 -0
- package/dist/v1/language/index.d.ts +7 -2
- package/dist/v1/language/index.js +5 -1
- package/dist/v1/language/limits.d.ts +64 -0
- package/dist/v1/language/limits.js +60 -0
- package/dist/v1/language/policy/analysis/branches.d.ts +8 -0
- package/dist/v1/language/policy/analysis/branches.js +2 -1
- package/dist/v1/language/policy/analysis/budgets.d.ts +45 -12
- package/dist/v1/language/policy/analysis/budgets.js +133 -19
- package/dist/v1/language/policy/analysis/checks.js +3 -2
- package/dist/v1/language/policy/analysis/typing.d.ts +51 -0
- package/dist/v1/language/policy/analysis/typing.js +455 -0
- package/dist/v1/language/policy/model/policy.d.ts +49 -9
- package/dist/v1/language/policy/model/policy.js +14 -0
- package/dist/v1/language/policy/normalization/normalize.d.ts +6 -6
- package/dist/v1/language/policy/normalization/normalize.js +22 -21
- package/dist/v1/language/validation/diagnostic.d.ts +15 -1
- package/dist/v1/language/validation/diagnostic.js +21 -0
- package/dist/v1/language/validation/rule.d.ts +45 -0
- package/dist/v1/language/validation/rule.js +109 -0
- package/dist/v1/language/value/compile/fields.js +4 -8
- package/dist/v1/language/value/evaluate/program.d.ts +2 -1
- package/dist/v1/language/value/evaluate/program.js +2 -2
- package/dist/v1/language/value/evaluate/validate.d.ts +2 -2
- package/dist/v1/language/value/evaluate/validate.js +6 -2
- package/dist/v1/language/value/evaluate/validity.optimization.d.ts +14 -0
- package/dist/v1/language/value/evaluate/validity.optimization.js +342 -0
- package/dist/v1/language/value/inclusion/arrays.d.ts +3 -0
- package/dist/v1/language/value/inclusion/arrays.js +85 -0
- package/dist/v1/language/value/inclusion/assertions.d.ts +18 -0
- package/dist/v1/language/value/inclusion/assertions.js +29 -0
- package/dist/v1/language/value/inclusion/combinators.d.ts +3 -0
- package/dist/v1/language/value/inclusion/combinators.js +67 -0
- package/dist/v1/language/value/inclusion/equivalence.d.ts +4 -0
- package/dist/v1/language/value/inclusion/equivalence.js +74 -0
- package/dist/v1/language/value/inclusion/evidence.d.ts +34 -0
- package/dist/v1/language/value/inclusion/evidence.js +138 -0
- package/dist/v1/language/value/inclusion/includes.d.ts +17 -0
- package/dist/v1/language/value/inclusion/includes.js +25 -719
- package/dist/v1/language/value/inclusion/keywords.d.ts +5 -0
- package/dist/v1/language/value/inclusion/keywords.js +31 -0
- package/dist/v1/language/value/inclusion/kinds.d.ts +17 -0
- package/dist/v1/language/value/inclusion/kinds.js +57 -0
- package/dist/v1/language/value/inclusion/location.d.ts +24 -0
- package/dist/v1/language/value/inclusion/location.js +63 -0
- package/dist/v1/language/value/inclusion/numbers.d.ts +3 -0
- package/dist/v1/language/value/inclusion/numbers.js +41 -0
- package/dist/v1/language/value/inclusion/objects.d.ts +3 -0
- package/dist/v1/language/value/inclusion/objects.js +190 -0
- package/dist/v1/language/value/inclusion/strings.d.ts +3 -0
- package/dist/v1/language/value/inclusion/strings.js +29 -0
- package/dist/v1/language/value/inclusion/types.d.ts +3 -0
- package/dist/v1/language/value/inclusion/types.js +11 -0
- package/dist/v1/language/value/ordering.d.ts +14 -0
- package/dist/v1/language/value/ordering.js +86 -9
- package/dist/v1/language/value/profile/canonicalize.js +6 -5
- package/dist/v1/language/value/profile/json.validate.d.ts +3 -1
- package/dist/v1/language/value/profile/json.validate.js +3 -2
- package/dist/v1/language/value/profile/meta-schema.compiled.js +4 -1
- package/dist/v1/language/value/profile/rules.js +17 -43
- package/dist/v1/language/value/profile/validate.js +1 -10
- package/dist/v1/language/value/profile/vocabulary.d.ts +35 -2
- package/dist/v1/language/value/profile/vocabulary.js +52 -5
- package/dist/v1/language/value/reference/closure.js +3 -4
- package/dist/v1/language/value/reference/recursion.js +2 -22
- package/dist/v1/language/value/reference/registry.index.d.ts +2 -0
- package/dist/v1/language/value/reference/registry.index.js +33 -16
- package/dist/v1/language/value/regexp/ast.js +6 -7
- package/dist/v1/language/value/regexp/compile.d.ts +5 -11
- package/dist/v1/language/value/regexp/compile.js +14 -12
- package/dist/v1/language/value/regexp/syntax.js +3 -2
- package/dist/v1/language/value/syntax/keywords.d.ts +3 -3
- package/dist/v1/language/value/syntax/keywords.js +4 -20
- package/dist/v1/language/value/syntax/node-path/validate.js +2 -3
- package/dist/v1/language/value/syntax/pointer.d.ts +2 -0
- package/dist/v1/language/value/syntax/pointer.js +5 -2
- package/dist/v1/language/value/syntax/walk.d.ts +2 -0
- package/dist/v1/language/value/syntax/walk.js +19 -20
- package/dist/v1/schema/.spec/schemas/domain-schema.schema.json +2519 -0
- package/dist/v1/schema/admission/accept.js +3 -14
- package/dist/v1/schema/admission/callable.d.ts +21 -0
- package/dist/v1/schema/admission/callable.js +96 -0
- package/dist/v1/schema/analysis/class.js +33 -15
- package/dist/v1/schema/canonical/revision.js +4 -4
- package/dist/v1/schema/compatibility/api.d.ts +2 -1
- package/dist/v1/schema/compatibility/api.js +1 -0
- package/dist/v1/schema/compatibility/comparators/callables.js +1 -1
- package/dist/v1/schema/compatibility/comparators/classes.d.ts +9 -4
- package/dist/v1/schema/compatibility/comparators/classes.js +29 -8
- package/dist/v1/schema/compatibility/comparators/index.d.ts +1 -1
- package/dist/v1/schema/compatibility/comparators/members.js +1 -1
- package/dist/v1/schema/compatibility/comparators/values.js +2 -2
- package/dist/v1/schema/compatibility/coordinate.js +3 -3
- package/dist/v1/schema/compatibility/diff.js +2 -4
- package/dist/v1/schema/compatibility/extension.d.ts +11 -0
- package/dist/v1/schema/compatibility/extension.js +22 -0
- package/dist/v1/schema/compatibility/fields.d.ts +20 -4
- package/dist/v1/schema/compatibility/fields.js +13 -3
- package/dist/v1/schema/compatibility/meaning/footprint.js +16 -50
- package/dist/v1/schema/compatibility/model.d.ts +17 -5
- package/dist/v1/schema/compatibility/report.js +1 -1
- package/dist/v1/schema/compatibility/scope.d.ts +2 -0
- package/dist/v1/schema/compatibility/scope.js +4 -1
- package/dist/v1/schema/compatibility/structure/index.js +6 -4
- package/dist/v1/schema/compatibility/structure/requirements.js +57 -58
- package/dist/v1/schema/compatibility/versioning/index.js +1 -1
- package/dist/v1/schema/compatibility/versioning/surface.d.ts +1 -1
- package/dist/v1/schema/compatibility/versioning/surface.js +30 -2
- package/dist/v1/schema/compatibility/walk.d.ts +17 -0
- package/dist/v1/schema/compatibility/walk.js +41 -0
- package/dist/v1/schema/diagnostic.d.ts +17 -3
- package/dist/v1/schema/diagnostic.js +14 -11
- package/dist/v1/schema/index.d.ts +10 -1
- package/dist/v1/schema/index.js +4 -0
- package/dist/v1/schema/model/schema.d.ts +20 -1
- package/dist/v1/schema/model/schema.js +1 -1
- package/dist/v1/schema/normalization/domain.d.ts +2 -0
- package/dist/v1/schema/normalization/domain.js +29 -9
- package/dist/v1/schema/resolution/closure.js +2 -1
- package/dist/v1/schema/resolution/context.js +13 -13
- package/dist/v1/schema/resolution/domain.d.ts +5 -0
- package/dist/v1/schema/resolution/domain.js +2 -2
- package/dist/v1/schema/resolution/origins.js +3 -2
- package/dist/v1/schema/rule.d.ts +26 -0
- package/dist/v1/schema/rule.js +440 -0
- package/dist/v1/schema/validation/callable.d.ts +35 -2
- package/dist/v1/schema/validation/callable.js +65 -9
- package/dist/v1/schema/validation/class.d.ts +6 -2
- package/dist/v1/schema/validation/class.js +127 -104
- package/dist/v1/schema/validation/core.js +90 -168
- package/dist/v1/schema/validation/domain.js +4 -13
- package/dist/v1/schema/validation/domain.json-schema.d.ts +15 -0
- package/dist/v1/schema/validation/domain.json-schema.js +197 -0
- package/dist/v1/schema/validation/domain.route.d.ts +6 -1
- package/dist/v1/schema/validation/domain.route.js +18 -0
- package/dist/v1/schema/validation/domain.structure.d.ts +7780 -0
- package/dist/v1/schema/validation/domain.structure.js +398 -147
- package/dist/v1/schema/validation/json.json-schema.d.ts +40 -0
- package/dist/v1/schema/validation/json.json-schema.js +46 -0
- package/dist/v1/schema/validation/policy/budgets.d.ts +33 -2
- package/dist/v1/schema/validation/policy/budgets.js +87 -121
- package/dist/v1/schema/validation/policy/context.d.ts +6 -5
- package/dist/v1/schema/validation/policy/context.js +7 -10
- package/dist/v1/schema/validation/policy/objects.d.ts +1 -1
- package/dist/v1/schema/validation/policy/objects.js +6 -14
- package/dist/v1/schema/validation/policy/references.js +11 -27
- package/dist/v1/schema/validation/policy/typing.d.ts +3 -18
- package/dist/v1/schema/validation/policy/typing.js +22 -356
- package/dist/v1/schema/validation/policy/uses.d.ts +40 -3
- package/dist/v1/schema/validation/policy/uses.js +66 -89
- package/dist/v1/schema/validation/policy/validate.js +5 -5
- package/dist/v1/schema/validation/value-api.d.ts +22 -0
- package/dist/v1/schema/validation/value-api.js +34 -1
- package/dist/v1/schema/validation/value.d.ts +3 -0
- package/dist/v1/schema/validation/value.js +9 -17
- package/dist/v1/schema/validation/value.json-schema.d.ts +49 -0
- package/dist/v1/schema/validation/value.json-schema.js +137 -0
- package/dist/v1/schema/validation/view.js +4 -8
- package/dist/value/canonical.d.ts +6 -0
- package/dist/value/canonical.js +36 -0
- package/dist/value/decode.d.ts +7 -0
- package/dist/value/decode.js +159 -9
- package/dist/value/index.d.ts +1 -1
- package/dist/value/json.d.ts +2 -2
- package/dist/value/json.js +2 -2
- package/dist/value/types.d.ts +6 -0
- package/dist/value/unicode.d.ts +2 -1
- package/dist/value/unicode.js +2 -0
- package/package.json +8 -1
- package/dist/v1/builder/lowering/core-properties.d.ts +0 -10
- package/dist/v1/builder/lowering/core-properties.js +0 -76
- package/dist/v1/compiled/admission/semantics/cardinality.d.ts +0 -5
- package/dist/v1/compiled/admission/semantics/cardinality.js +0 -113
- package/dist/v1/compiled/admission/semantics/policy/equality.d.ts +0 -8
- package/dist/v1/compiled/admission/semantics/policy/equality.js +0 -27
- package/dist/v1/compiled/admission/semantics/policy/measure.d.ts +0 -9
- package/dist/v1/compiled/admission/semantics/policy/measure.js +0 -81
- package/dist/v1/compiled/admission/semantics/policy/variants.d.ts +0 -10
- package/dist/v1/compiled/admission/semantics/policy/variants.js +0 -65
- package/dist/v1/language/class/index.d.ts +0 -8
- package/dist/v1/language/class/index.js +0 -1
- package/dist/v1/language/core/index.d.ts +0 -2
- package/dist/v1/language/value/index.d.ts +0 -11
- package/dist/v1/language/value/index.js +0 -8
- package/dist/v1/schema/canonical/domain.d.ts +0 -3
- package/dist/v1/schema/canonical/domain.digest.d.ts +0 -3
- package/dist/v1/schema/canonical/domain.digest.js +0 -5
- package/dist/v1/schema/canonical/domain.js +0 -5
- package/dist/v1/schema/canonical/freeze.d.ts +0 -1
- /package/dist/v1/{language/core/index.js → builder/class/input.js} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { assertKnownKeys, fail } from '../schema/diagnostic.js';
|
|
1
|
+
import { assertKnownKeys, escapeToken, fail } from '../schema/diagnostic.js';
|
|
2
2
|
import { authoringValue } from '../schema/handle.js';
|
|
3
3
|
const declarations = new WeakMap();
|
|
4
4
|
const compositions = new WeakSet();
|
|
@@ -21,76 +21,24 @@ function createPolicy(input) {
|
|
|
21
21
|
declarations.set(value, input);
|
|
22
22
|
return value;
|
|
23
23
|
}
|
|
24
|
-
export const policy = Object.freeze(Object.assign(createPolicy, {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
24
|
+
export const policy = Object.freeze(Object.assign(createPolicy, { allOf: composer('allOf'), anyOf: composer('anyOf') }));
|
|
25
|
+
function composer(operator) {
|
|
26
|
+
return (first, ...rest) => createPolicy(composition(operator, first === undefined ? [] : [first, ...rest]));
|
|
27
|
+
}
|
|
28
28
|
export function createPatternContext(options) {
|
|
29
|
-
|
|
30
|
-
const subject = Object.freeze({ kind: 'subject' });
|
|
31
|
-
const object = Object.freeze({ kind: 'object' });
|
|
32
|
-
const source = Object.freeze({ kind: 'source' });
|
|
33
|
-
const target = Object.freeze({ kind: 'target' });
|
|
29
|
+
const nextVariable = variableIds();
|
|
34
30
|
const context = {
|
|
35
31
|
ref: (member) => ({
|
|
36
32
|
kind: 'ref',
|
|
37
33
|
ref: options.resolveObject(member, `${options.pointer}/match/ref`),
|
|
38
34
|
}),
|
|
39
35
|
sameNode: (left, right) => ({ sameNode: { left, right } }),
|
|
40
|
-
subject,
|
|
41
|
-
object,
|
|
42
|
-
source,
|
|
43
|
-
target,
|
|
44
|
-
edge(
|
|
45
|
-
|
|
46
|
-
if (input.repeat !== undefined)
|
|
47
|
-
assertKnownKeys(input.repeat, ['min', 'max']);
|
|
48
|
-
return {
|
|
49
|
-
source: input.source,
|
|
50
|
-
class: options.resolveEdgeClass(input.class, `${options.pointer}/match/class`),
|
|
51
|
-
target: input.target,
|
|
52
|
-
...(input.repeat === undefined ? {} : { repeat: { ...input.repeat } }),
|
|
53
|
-
};
|
|
54
|
-
},
|
|
55
|
-
exists(build) {
|
|
56
|
-
const nodes = [];
|
|
57
|
-
const bind = (selector, definition) => {
|
|
58
|
-
const variable = Object.freeze({ kind: 'variable', id: nextVariable++ });
|
|
59
|
-
if (selector === 'any') {
|
|
60
|
-
nodes.push({ variable, selector: Object.freeze({ kind: 'any' }) });
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
const classRef = options.resolveNodeClass(definition, `${options.pointer}/match/exists/nodes`);
|
|
64
|
-
nodes.push(selector === 'exact'
|
|
65
|
-
? { variable, class: classRef }
|
|
66
|
-
: { variable, selector: Object.freeze({ kind: 'satisfies', class: classRef }) });
|
|
67
|
-
}
|
|
68
|
-
return variable;
|
|
69
|
-
};
|
|
70
|
-
const node = function (...args) {
|
|
71
|
-
if (args.length > 1 || (args.length === 1 && args[0] === undefined)) {
|
|
72
|
-
fail('BUILDER_POLICY', `${options.pointer}/match/exists/nodes`, 'node(...) accepts either no arguments or one Node Class.');
|
|
73
|
-
}
|
|
74
|
-
return args.length === 0
|
|
75
|
-
? bind('any')
|
|
76
|
-
: bind('satisfies', args[0]);
|
|
77
|
-
};
|
|
78
|
-
Object.defineProperty(node, 'exact', {
|
|
79
|
-
enumerable: true,
|
|
80
|
-
value(definition) {
|
|
81
|
-
if (arguments.length !== 1 || definition === undefined) {
|
|
82
|
-
fail('BUILDER_POLICY', `${options.pointer}/match/exists/nodes`, 'node.exact(...) requires exactly one Node Class.');
|
|
83
|
-
}
|
|
84
|
-
return bind('exact', definition);
|
|
85
|
-
},
|
|
86
|
-
});
|
|
87
|
-
Object.freeze(node);
|
|
88
|
-
const where = build({ node });
|
|
89
|
-
if (nodes.length === 0) {
|
|
90
|
-
fail('BUILDER_POLICY_EMPTY_EXISTS', `${options.pointer}/match/exists/nodes`, 'exists(...) must declare at least one variable Node.');
|
|
91
|
-
}
|
|
92
|
-
return { exists: { nodes, where } };
|
|
93
|
-
},
|
|
36
|
+
subject: Object.freeze({ kind: 'subject' }),
|
|
37
|
+
object: Object.freeze({ kind: 'object' }),
|
|
38
|
+
source: Object.freeze({ kind: 'source' }),
|
|
39
|
+
target: Object.freeze({ kind: 'target' }),
|
|
40
|
+
edge: (...args) => edge(options, args),
|
|
41
|
+
exists: (build) => exists(options, nextVariable, build),
|
|
94
42
|
allOf(...expressions) {
|
|
95
43
|
nonEmpty(expressions, `${options.pointer}/match/allOf`);
|
|
96
44
|
return { allOf: expressions };
|
|
@@ -102,12 +50,103 @@ export function createPatternContext(options) {
|
|
|
102
50
|
};
|
|
103
51
|
return Object.freeze(context);
|
|
104
52
|
}
|
|
53
|
+
/** Variable ids, unique across every `exists(...)` of one pattern. */
|
|
54
|
+
function variableIds() {
|
|
55
|
+
let next = 0;
|
|
56
|
+
return () => next++;
|
|
57
|
+
}
|
|
58
|
+
function edge(options, args) {
|
|
59
|
+
const pointer = `${options.pointer}/match/edge`;
|
|
60
|
+
if (args[1] === undefined)
|
|
61
|
+
return legacyEdge(options, args[0], pointer);
|
|
62
|
+
const [classValue, ends, edgeOptions] = args;
|
|
63
|
+
const ref = options.resolveEdgeClass(classValue, `${options.pointer}/match/class`);
|
|
64
|
+
const [sourceRole, targetRole] = options.edgeRoles(ref);
|
|
65
|
+
if (typeof ends !== 'object' || ends === null) {
|
|
66
|
+
fail('BUILDER_POLICY', pointer, 'edge(classValue, ends) names both ends by their roles.');
|
|
67
|
+
}
|
|
68
|
+
assertKnownKeys(ends, [sourceRole, targetRole], pointer);
|
|
69
|
+
const missing = `edge(...) names both ends of ${ref.origin}:class.${ref.name}: "${sourceRole}" and "${targetRole}".`;
|
|
70
|
+
const sourceTerm = endTerm(ends, sourceRole, pointer, missing);
|
|
71
|
+
const targetTerm = endTerm(ends, targetRole, pointer, missing);
|
|
72
|
+
if (edgeOptions !== undefined)
|
|
73
|
+
assertKnownKeys(edgeOptions, ['repeat'], pointer);
|
|
74
|
+
if (edgeOptions?.repeat !== undefined) {
|
|
75
|
+
assertKnownKeys(edgeOptions.repeat, ['min', 'max'], `${pointer}/repeat`);
|
|
76
|
+
}
|
|
77
|
+
return edgePattern(sourceTerm, ref, targetTerm, edgeOptions?.repeat);
|
|
78
|
+
}
|
|
79
|
+
function legacyEdge(options, input, pointer) {
|
|
80
|
+
// Typed callers cannot pass an Edge Class without ends; untyped ones can, and `kind` is read
|
|
81
|
+
// without `in` so a primitive still reaches `assertKnownKeys`.
|
|
82
|
+
if (typeof input === 'function' || input.kind === 'edge') {
|
|
83
|
+
fail('BUILDER_POLICY', pointer, 'edge(classValue, ends) names both ends by their roles.');
|
|
84
|
+
}
|
|
85
|
+
assertKnownKeys(input, ['source', 'class', 'target', 'repeat']);
|
|
86
|
+
if (input.repeat !== undefined)
|
|
87
|
+
assertKnownKeys(input.repeat, ['min', 'max']);
|
|
88
|
+
const ref = options.resolveEdgeClass(input.class, `${options.pointer}/match/class`);
|
|
89
|
+
return edgePattern(input.source, ref, input.target, input.repeat);
|
|
90
|
+
}
|
|
91
|
+
/** The term of one role. An own key holding `undefined` passes through, as it always has. */
|
|
92
|
+
function endTerm(ends, role, pointer, missing) {
|
|
93
|
+
if (!Object.hasOwn(ends, role))
|
|
94
|
+
fail('BUILDER_POLICY', `${pointer}/${escapeToken(role)}`, missing);
|
|
95
|
+
return ends[role];
|
|
96
|
+
}
|
|
97
|
+
/** One Edge pattern, whichever form named its ends. */
|
|
98
|
+
function edgePattern(source, classRef, target, repeat) {
|
|
99
|
+
return {
|
|
100
|
+
source,
|
|
101
|
+
class: classRef,
|
|
102
|
+
target,
|
|
103
|
+
...(repeat === undefined ? {} : { repeat: { ...repeat } }),
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function exists(options, nextVariable, build) {
|
|
107
|
+
const pointer = `${options.pointer}/match/exists/nodes`;
|
|
108
|
+
const nodes = [];
|
|
109
|
+
const bind = (selector) => {
|
|
110
|
+
const variable = Object.freeze({ kind: 'variable', id: nextVariable() });
|
|
111
|
+
nodes.push(nodeVariable(options, variable, selector, pointer));
|
|
112
|
+
return variable;
|
|
113
|
+
};
|
|
114
|
+
const where = build({ node: nodeBinder(bind, pointer) });
|
|
115
|
+
const [first, ...rest] = nodes;
|
|
116
|
+
if (first === undefined) {
|
|
117
|
+
fail('BUILDER_POLICY_EMPTY_EXISTS', pointer, 'exists(...) must declare at least one variable Node.');
|
|
118
|
+
}
|
|
119
|
+
return { exists: { nodes: [first, ...rest], where } };
|
|
120
|
+
}
|
|
121
|
+
function nodeVariable(options, variable, selector, pointer) {
|
|
122
|
+
if (selector.kind === 'any')
|
|
123
|
+
return { variable, selector: Object.freeze({ kind: 'any' }) };
|
|
124
|
+
const classRef = options.resolveNodeClass(selector.definition, pointer);
|
|
125
|
+
if (selector.kind === 'exact')
|
|
126
|
+
return { variable, class: classRef };
|
|
127
|
+
return { variable, selector: Object.freeze({ kind: 'satisfies', class: classRef }) };
|
|
128
|
+
}
|
|
129
|
+
function nodeBinder(bind, pointer) {
|
|
130
|
+
function node(...args) {
|
|
131
|
+
const definition = args[0];
|
|
132
|
+
if (args.length > 1 || (args.length === 1 && definition === undefined)) {
|
|
133
|
+
fail('BUILDER_POLICY', pointer, 'node(...) accepts either no arguments or one Node Class.');
|
|
134
|
+
}
|
|
135
|
+
return definition === undefined
|
|
136
|
+
? bind({ kind: 'any' })
|
|
137
|
+
: bind({ kind: 'satisfies', definition });
|
|
138
|
+
}
|
|
139
|
+
function exact(definition) {
|
|
140
|
+
if (arguments.length !== 1 || definition === undefined) {
|
|
141
|
+
fail('BUILDER_POLICY', pointer, 'node.exact(...) requires exactly one Node Class.');
|
|
142
|
+
}
|
|
143
|
+
return bind({ kind: 'exact', definition });
|
|
144
|
+
}
|
|
145
|
+
return Object.freeze(Object.assign(node, { exact }));
|
|
146
|
+
}
|
|
105
147
|
function composition(operator, policies) {
|
|
106
148
|
nonEmpty(policies, `/${operator}`);
|
|
107
|
-
const value = {
|
|
108
|
-
operator,
|
|
109
|
-
policies: [...policies],
|
|
110
|
-
};
|
|
149
|
+
const value = { operator, policies: [...policies] };
|
|
111
150
|
compositions.add(value);
|
|
112
151
|
return value;
|
|
113
152
|
}
|
|
@@ -2,7 +2,6 @@ import type { Domain } from '../../domain/model/domain.js';
|
|
|
2
2
|
import type { DomainSchema } from '../../schema/model/schema.js';
|
|
3
3
|
import type { DomainSchemaInput, EntrypointOf } from './input.js';
|
|
4
4
|
import type { ResolvedDomainOfInput } from './projection.js';
|
|
5
|
-
export type { DomainSchemaInput } from './input.js';
|
|
6
5
|
/** Exact named Schema produced from one authored input. */
|
|
7
6
|
export interface DefinedSchema<Origin extends string, Resolved extends Domain> extends DomainSchema<Origin, Resolved> {
|
|
8
7
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { DiagnosticCode as LanguageDiagnosticCode } from '../../language/validation/diagnostic.js';
|
|
2
|
-
|
|
2
|
+
import { escapePointerToken as escapeToken } from '../../language/value/syntax/pointer.js';
|
|
3
|
+
export { escapeToken };
|
|
4
|
+
export type BuilderDiagnosticCode = LanguageDiagnosticCode | 'BUILDER_ABSTRACT_POLICY' | 'BUILDER_AMBIGUOUS_OWNERSHIP' | 'BUILDER_AUTO_EVENT_INVALID' | 'BUILDER_AUTO_IMMUTABLE' | 'BUILDER_AUTO_NESTED' | 'BUILDER_AUTO_SET_INVALID' | 'BUILDER_CALLABLE_AUTH' | 'BUILDER_CALLABLE_PLACEMENT' | 'BUILDER_CALLABLE_POLICY_AUTH' | 'BUILDER_CLASS_INHERITANCE' | 'BUILDER_CORE_CLASS' | 'BUILDER_CORE_EDGE' | 'BUILDER_CORE_NODE' | 'BUILDER_CORE_PROPERTY' | 'BUILDER_CORE_REF' | 'BUILDER_DEFINITION' | 'BUILDER_DEPENDENCY_CONFLICT' | 'BUILDER_DEPENDENCY_ALIAS' | 'BUILDER_DEPENDENCY_DIRECT' | 'BUILDER_DUPLICATE_MEMBER' | 'BUILDER_EDGE_LIFETIME' | 'BUILDER_FOREIGN_POLICY' | 'BUILDER_FULL_MATCH_INVALID' | 'BUILDER_FUNCTION' | 'BUILDER_METHOD' | 'BUILDER_PATH_DUPLICATE' | 'BUILDER_PATH_EMPTY' | 'BUILDER_POLICY' | 'BUILDER_POLICY_COMPOSITION' | 'BUILDER_POLICY_CYCLE' | 'BUILDER_POLICY_EMPTY_COMPOSITION' | 'BUILDER_POLICY_EMPTY_EXISTS' | 'BUILDER_POLICY_INPUT' | 'BUILDER_POLICY_REF' | 'BUILDER_POLICY_SELF' | 'BUILDER_PROPERTY_IMMUTABLE_INVALID' | 'BUILDER_REFERENCE_CYCLE' | 'BUILDER_REFERENCE_KIND' | 'BUILDER_REFERENCE_MISSING' | 'BUILDER_UNIQUE_PROPERTY' | 'BUILDER_UNKNOWN_FIELD' | 'BUILDER_UNOWNED_REFERENCE' | 'BUILDER_VIEW' | 'ZOD_SCHEMA_NOT_LOSSLESS';
|
|
3
5
|
export interface BuilderDiagnostic<out Code extends BuilderDiagnosticCode = BuilderDiagnosticCode> {
|
|
4
6
|
readonly code: Code;
|
|
5
7
|
readonly pointer: string;
|
|
@@ -13,4 +15,3 @@ export declare class BuilderError extends Error {
|
|
|
13
15
|
}
|
|
14
16
|
export declare function assertKnownKeys(value: object, allowed: readonly string[], pointer?: string): void;
|
|
15
17
|
export declare function fail(code: BuilderDiagnosticCode, pointer: string, message: string): never;
|
|
16
|
-
export declare function escapeToken(value: string): string;
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { formatDiagnostics, orderDiagnostics } from '../../language/validation/diagnostic.js';
|
|
2
|
+
import { escapePointerToken as escapeToken } from '../../language/value/syntax/pointer.js';
|
|
3
|
+
export { escapeToken };
|
|
2
4
|
export function diagnostic(code, pointer, message, ref) {
|
|
3
5
|
return Object.freeze({ code, pointer, message, ...(ref === undefined ? {} : { ref }) });
|
|
4
6
|
}
|
|
5
7
|
export class BuilderError extends Error {
|
|
6
8
|
diagnostics;
|
|
7
9
|
constructor(diagnostics) {
|
|
8
|
-
const ordered =
|
|
9
|
-
|
|
10
|
-
compareUnicode(left.message, right.message));
|
|
11
|
-
super(ordered
|
|
12
|
-
.map(({ code, pointer, message }) => `${pointer || '/'} [${code}] ${message}`)
|
|
13
|
-
.join('\n'));
|
|
10
|
+
const ordered = orderDiagnostics(diagnostics);
|
|
11
|
+
super(formatDiagnostics(ordered));
|
|
14
12
|
this.name = 'BuilderError';
|
|
15
13
|
this.diagnostics = Object.freeze(ordered);
|
|
16
14
|
}
|
|
@@ -26,6 +24,3 @@ export function assertKnownKeys(value, allowed, pointer = '') {
|
|
|
26
24
|
export function fail(code, pointer, message) {
|
|
27
25
|
throw new BuilderError([diagnostic(code, pointer, message)]);
|
|
28
26
|
}
|
|
29
|
-
export function escapeToken(value) {
|
|
30
|
-
return value.replaceAll('~', '~0').replaceAll('/', '~1');
|
|
31
|
-
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { DomainSchema } from '../../schema/model/schema.js';
|
|
2
2
|
import type { Function } from '../callable/authoring.js';
|
|
3
|
-
import type { Class } from '../class/
|
|
3
|
+
import type { Class } from '../class/handle.js';
|
|
4
4
|
import type { CoreInput } from '../core/authoring.js';
|
|
5
5
|
import type { Policy } from '../policy/authoring.js';
|
|
6
6
|
import type { View } from '../view/authoring.js';
|
|
@@ -18,6 +18,7 @@ type CallableConfig<Value> = Value extends Method<infer Config> ? Config extends
|
|
|
18
18
|
type CallableInputValue<Value extends Method | Function> = CallableConfig<Value>['input'];
|
|
19
19
|
type CallableOutputValue<Value extends Method | Function> = CallableConfig<Value>['output'];
|
|
20
20
|
type CallableExecutionOf<Value extends Method | Function> = CallableConfig<Value>['execution'];
|
|
21
|
+
type CallableAdmissionOf<Value extends Method | Function> = CallableConfig<Value>['admission'];
|
|
21
22
|
type CallableStaticOf<Value extends Method> = CallableConfig<Value> extends {
|
|
22
23
|
readonly static: true;
|
|
23
24
|
} ? true : false;
|
|
@@ -25,11 +26,11 @@ type CallableAbstractOf<Value extends Method> = CallableConfig<Value> extends {
|
|
|
25
26
|
readonly abstract: infer Abstract extends boolean;
|
|
26
27
|
} ? Abstract : false;
|
|
27
28
|
type CallableAuthOf<Value extends Method | Function> = CallableConfig<Value>['auth'];
|
|
28
|
-
type MethodProjectionOfEntry<Origin extends string, OwnerName extends string, Entry> = Entry extends language.ResolvedMethod ? MethodProjectionOfResolved<Entry> : Entry extends AuthoredMethodEntry<infer Owner, infer Name, infer Value> ? MethodProjection<CallableInputValue<Value>, CallableOutputValue<Value>, CallableStaticOf<Value>, CallableAbstractOf<Value>, CallableAuthOf<Value>, Name, language.MethodKey<Origin, OwnerName, Name>, MethodExecutableOf<AbstractOf<ClassInputOf<Owner>>, CallableAbstractOf<Value>>, CallableExecutionOf<Value>> : never;
|
|
29
|
+
type MethodProjectionOfEntry<Origin extends string, OwnerName extends string, Entry> = Entry extends language.ResolvedMethod ? MethodProjectionOfResolved<Entry> : Entry extends AuthoredMethodEntry<infer Owner, infer Name, infer Value> ? MethodProjection<CallableInputValue<Value>, CallableOutputValue<Value>, CallableStaticOf<Value>, CallableAbstractOf<Value>, CallableAuthOf<Value>, Name, language.MethodKey<Origin, OwnerName, Name>, MethodExecutableOf<AbstractOf<ClassInputOf<Owner>>, CallableAbstractOf<Value>>, CallableExecutionOf<Value>, CallableAdmissionOf<Value>> : never;
|
|
29
30
|
type MethodProjectionOfEntries<Origin extends string, OwnerName extends string, Entries> = Entries extends unknown ? MethodProjectionOfEntry<Origin, OwnerName, Entries> : never;
|
|
30
31
|
type MethodProjectionOfResolved<Value> = Value extends language.ResolvedMethod<infer Input, infer Output, infer Static, infer Abstract, infer Auth, infer _Policy, infer Key> & {
|
|
31
32
|
readonly name: infer Name extends string;
|
|
32
|
-
} ? MethodProjection<Input, Output, Static, Abstract, Auth, Name, Key, Value['executable'], Value['execution']> : never;
|
|
33
|
+
} ? MethodProjection<Input, Output, Static, Abstract, Auth, Name, Key, Value['executable'], Value['execution'], Value['admission']> : never;
|
|
33
34
|
/** Capture each Method through its qualified lookup key. */
|
|
34
35
|
export type MethodsOfCollection<Value> = Value extends {
|
|
35
36
|
readonly byKey: infer ByKey extends Readonly<Record<language.MethodKey, language.ResolvedMethod>>;
|
|
@@ -41,11 +42,12 @@ export type OwnStaticMethodProjectionsOf<Origin extends string, Name extends str
|
|
|
41
42
|
/** Bind an authored Function to its exact Domain coordinates. */
|
|
42
43
|
export type FunctionProjectionOfAuthoring<Origin extends string, Name extends string, Value> = Value extends Function ? FunctionProjection<CallableInputValue<Value>, CallableOutputValue<Value>, CallableAuthOf<Value>, language.FunctionRef<Name> & {
|
|
43
44
|
readonly origin: Origin;
|
|
44
|
-
}, language.DefinitionKey<Origin, 'function', Name>, CallableExecutionOf<Value>> : never;
|
|
45
|
-
/** Restore a resolved Function while preserving its execution modifier. */
|
|
46
|
-
export type ResolvedFunctionOfProjection<Value extends FunctionProjection> = Value extends FunctionProjection<infer Input, infer Output, infer Auth, infer Ref, infer Key, infer Execution> ? language.ResolvedFunction<Input, Output, Auth, language.CallablePolicy> & {
|
|
45
|
+
}, language.DefinitionKey<Origin, 'function', Name>, CallableExecutionOf<Value>, CallableAdmissionOf<Value>> : never;
|
|
46
|
+
/** Restore a resolved Function while preserving its execution modifier and admission age. */
|
|
47
|
+
export type ResolvedFunctionOfProjection<Value extends FunctionProjection> = Value extends FunctionProjection<infer Input, infer Output, infer Auth, infer Ref, infer Key, infer Execution, infer Admission> ? language.ResolvedFunction<Input, Output, Auth, language.CallablePolicy> & {
|
|
47
48
|
readonly ref: Ref;
|
|
48
49
|
readonly key: Key;
|
|
49
50
|
readonly execution: Execution;
|
|
51
|
+
readonly admission: Admission;
|
|
50
52
|
} : never;
|
|
51
53
|
export {};
|
|
@@ -1,12 +1,119 @@
|
|
|
1
1
|
import type * as language from '../../../language/index.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { DomainSchema, DomainOfSchema } from '../../../schema/model/schema.js';
|
|
3
|
+
import type { NodeClass, DirectedEdgeClass, UndirectedEdgeClass, Class, ProjectionOfClass } from '../../class/handle.js';
|
|
4
|
+
import type { ClassReferenceProjection } from '../../class/projection.js';
|
|
3
5
|
import type { DomainSchemaInput } from '../input.js';
|
|
4
6
|
import type { OwnInstanceMethodProjectionsOf, OwnStaticMethodProjectionsOf } from './callable.js';
|
|
5
|
-
import type { AbstractOf, ConstraintsOf, ResolveLazy, LocalNameOfReference, ClassesInputOf, LocalNameOf } from './identity.js';
|
|
7
|
+
import type { AbstractOf, ConstraintsOf, ResolveLazy, LocalNameOfReference, ClassesInputOf, LocalNameOf, RecordField } from './identity.js';
|
|
6
8
|
import type { ClassProjection } from './model.js';
|
|
7
9
|
import type { EffectivePropertyProjectionsOf, OwnPropertyProjectionsOf } from './property.js';
|
|
8
10
|
import type { ClassProjectionOfResolved, ExactClass } from './resolved-class.js';
|
|
9
|
-
|
|
11
|
+
/**
|
|
12
|
+
* A Class an endpoint accepts as the Schema names it: an authored Class by the ref of every Class
|
|
13
|
+
* that bears its mark, else the ref it carries.
|
|
14
|
+
*/
|
|
15
|
+
type AcceptedRefOf<Origin extends string, Reference, Root extends DomainSchemaInput> = Reference extends unknown ? ResolveLazy<Reference> extends infer Resolved ? Resolved extends {
|
|
16
|
+
readonly kind: 'node';
|
|
17
|
+
} ? MarkedClassRefOf<Origin, Resolved, Root> : Resolved extends {
|
|
18
|
+
readonly origin: infer RefOrigin extends string;
|
|
19
|
+
readonly kind: 'class';
|
|
20
|
+
readonly name: infer RefName extends string;
|
|
21
|
+
} ? language.ClassRef<RefName> & {
|
|
22
|
+
readonly origin: RefOrigin;
|
|
23
|
+
} : language.ClassRef : never : never;
|
|
24
|
+
/** The mark the class authoring module gives an accepted Node Class (`AcceptedClassMark`). */
|
|
25
|
+
type ClassMarkOf<Value> = Value extends NodeClass<infer Config> ? {
|
|
26
|
+
readonly kind: 'node';
|
|
27
|
+
readonly abstract: Config extends {
|
|
28
|
+
readonly abstract: infer Abstract;
|
|
29
|
+
} ? Abstract : never;
|
|
30
|
+
readonly depth: Config extends {
|
|
31
|
+
readonly depth: infer Depth;
|
|
32
|
+
} ? Depth : never;
|
|
33
|
+
readonly properties: Config extends {
|
|
34
|
+
readonly effectiveProperties: infer Properties;
|
|
35
|
+
} ? Properties extends {
|
|
36
|
+
readonly name: infer Name;
|
|
37
|
+
} ? Name : never : never;
|
|
38
|
+
readonly methods: Config extends {
|
|
39
|
+
readonly effectiveInstanceMethods: infer Instance;
|
|
40
|
+
readonly effectiveStaticMethods: infer Static;
|
|
41
|
+
} ? Instance | Static extends infer Method ? Method extends {
|
|
42
|
+
readonly name: infer Name;
|
|
43
|
+
} ? Name : never : never : never;
|
|
44
|
+
} : never;
|
|
45
|
+
type Same<Left, Right> = [Left] extends [Right] ? ([Right] extends [Left] ? true : false) : false;
|
|
46
|
+
/** Every local Class name whose mark is the accepted mark. */
|
|
47
|
+
type LocalNameOfMark<Root extends DomainSchemaInput, Mark> = {
|
|
48
|
+
[Name in keyof ClassesInputOf<Root>]: Same<ClassMarkOf<ClassesInputOf<Root>[Name]>, Mark> extends true ? Name : never;
|
|
49
|
+
}[keyof ClassesInputOf<Root>];
|
|
50
|
+
/**
|
|
51
|
+
* Every Class an authored handle bearing the mark may be: the builder resolves the handle of a
|
|
52
|
+
* Class of the Schema or of a direct dependency, so either may bear it. The ref stays broad when no
|
|
53
|
+
* Class bears it or a dependency's Classes are not named in the types.
|
|
54
|
+
*/
|
|
55
|
+
type MarkedClassRefOf<Origin extends string, Mark, Root extends DomainSchemaInput> = LocalClassRefOf<Origin, LocalNameOfMark<Root, Mark>> | DependencyClassRefOfMark<Root, Mark> extends infer Refs ? [Refs] extends [never] ? language.ClassRef : Refs : never;
|
|
56
|
+
type LocalClassRefOf<Origin extends string, Name> = Name extends string ? language.ClassRef<Name> & {
|
|
57
|
+
readonly origin: Origin;
|
|
58
|
+
} : never;
|
|
59
|
+
/** The names of the members of a resolved collection. */
|
|
60
|
+
type MemberNamesOf<Collection> = Collection extends {
|
|
61
|
+
readonly byKey: infer ByKey;
|
|
62
|
+
} ? ByKey[keyof ByKey] extends infer Member ? Member extends {
|
|
63
|
+
readonly name: infer Name;
|
|
64
|
+
} ? Name : never : never : never;
|
|
65
|
+
/**
|
|
66
|
+
* A dependency Class may bear a mark when it agrees with it in abstractness and the names of its
|
|
67
|
+
* effective Properties, and its own Methods are among the mark's. Its resolved type keeps neither
|
|
68
|
+
* its depth nor the abstract Methods it inherits, so neither is compared.
|
|
69
|
+
*/
|
|
70
|
+
type ResolvedBearsMark<Value, Mark> = Value extends {
|
|
71
|
+
readonly kind: 'node';
|
|
72
|
+
readonly definition: {
|
|
73
|
+
readonly abstract: infer Abstract;
|
|
74
|
+
};
|
|
75
|
+
readonly properties: infer Properties;
|
|
76
|
+
readonly methods: infer Methods;
|
|
77
|
+
readonly static: {
|
|
78
|
+
readonly methods: infer StaticMethods;
|
|
79
|
+
};
|
|
80
|
+
} ? Mark extends {
|
|
81
|
+
readonly abstract: infer MarkAbstract;
|
|
82
|
+
readonly properties: infer MarkProperties;
|
|
83
|
+
readonly methods: infer MarkMethods;
|
|
84
|
+
} ? Same<{
|
|
85
|
+
readonly abstract: Abstract;
|
|
86
|
+
readonly properties: MemberNamesOf<Properties>;
|
|
87
|
+
}, {
|
|
88
|
+
readonly abstract: MarkAbstract;
|
|
89
|
+
readonly properties: MarkProperties;
|
|
90
|
+
}> extends true ? [MemberNamesOf<Methods> | MemberNamesOf<StaticMethods>] extends [MarkMethods] ? true : false : false : false : false;
|
|
91
|
+
/** Every Node Class of a direct dependency that may bear the mark. */
|
|
92
|
+
type DependencyClassRefOfMark<Root extends DomainSchemaInput, Mark> = {
|
|
93
|
+
[Alias in keyof RecordField<Root, 'dependencies'>]: RecordField<Root, 'dependencies'>[Alias] extends infer Schema extends DomainSchema ? DomainOfSchema<Schema>['classes'] extends infer Classes ? string extends keyof Classes ? language.ClassRef : {
|
|
94
|
+
[Name in keyof Classes]: ResolvedBearsMark<Classes[Name], Mark> extends true ? Classes[Name] extends {
|
|
95
|
+
readonly ref: {
|
|
96
|
+
readonly origin: infer RefOrigin extends string;
|
|
97
|
+
readonly name: infer RefName extends string;
|
|
98
|
+
};
|
|
99
|
+
} ? language.ClassRef<RefName> & {
|
|
100
|
+
readonly origin: RefOrigin;
|
|
101
|
+
} : never : never;
|
|
102
|
+
}[keyof Classes] : never : never;
|
|
103
|
+
}[keyof RecordField<Root, 'dependencies'>];
|
|
104
|
+
/** Every Class an endpoint accepts, in any order: the runtime list is canonically sorted. */
|
|
105
|
+
type AcceptedRefsOf<Origin extends string, Accepts, Root extends DomainSchemaInput> = Accepts extends readonly (infer Reference)[] ? readonly [AcceptedRefOf<Origin, Reference, Root>, ...AcceptedRefOf<Origin, Reference, Root>[]] : readonly [language.ClassRef, ...language.ClassRef[]];
|
|
106
|
+
/** One endpoint as the Schema stores it: its role and its exact accepted Classes. */
|
|
107
|
+
type ProjectedEndpoint<Origin extends string, Endpoint, Root extends DomainSchemaInput> = Endpoint extends {
|
|
108
|
+
readonly as: infer Role;
|
|
109
|
+
readonly accepts: infer Accepts;
|
|
110
|
+
} ? {
|
|
111
|
+
readonly role: Role;
|
|
112
|
+
readonly accepts: AcceptedRefsOf<Origin, Accepts, Root>;
|
|
113
|
+
readonly onDelete?: language.EdgeLifetime;
|
|
114
|
+
} : never;
|
|
115
|
+
type EdgeDefinitionFields = 'ref' | 'kind' | 'abstract' | 'orientation' | 'endpoints' | 'constraints';
|
|
116
|
+
type ProjectedClassDefinition<Origin extends string, Name extends string, Value, Root extends DomainSchemaInput> = Value extends NodeClass<infer Config> ? language.NodeClassDefinition & {
|
|
10
117
|
readonly ref: language.ClassRef<Name> & {
|
|
11
118
|
readonly origin: Origin;
|
|
12
119
|
};
|
|
@@ -21,7 +128,7 @@ type ProjectedClassDefinition<Origin extends string, Name extends string, Value>
|
|
|
21
128
|
readonly as: string;
|
|
22
129
|
readonly incoming: language.EdgeCount;
|
|
23
130
|
};
|
|
24
|
-
} ? language.
|
|
131
|
+
} ? Omit<language.DirectedEdgeDefinition, EdgeDefinitionFields> & {
|
|
25
132
|
readonly ref: language.ClassRef<Name> & {
|
|
26
133
|
readonly origin: Origin;
|
|
27
134
|
};
|
|
@@ -29,12 +136,10 @@ type ProjectedClassDefinition<Origin extends string, Name extends string, Value>
|
|
|
29
136
|
readonly abstract: AbstractOf<Input>;
|
|
30
137
|
readonly orientation: 'directed';
|
|
31
138
|
readonly endpoints: {
|
|
32
|
-
readonly source:
|
|
33
|
-
readonly role: Source['as'];
|
|
139
|
+
readonly source: ProjectedEndpoint<Origin, Source, Root> & {
|
|
34
140
|
readonly outgoing: Source['outgoing'];
|
|
35
141
|
};
|
|
36
|
-
readonly target:
|
|
37
|
-
readonly role: Target['as'];
|
|
142
|
+
readonly target: ProjectedEndpoint<Origin, Target, Root> & {
|
|
38
143
|
readonly incoming: Target['incoming'];
|
|
39
144
|
};
|
|
40
145
|
};
|
|
@@ -50,7 +155,7 @@ type ProjectedClassDefinition<Origin extends string, Name extends string, Value>
|
|
|
50
155
|
readonly incident: language.EdgeCount;
|
|
51
156
|
}
|
|
52
157
|
];
|
|
53
|
-
} ? language.
|
|
158
|
+
} ? Omit<language.UndirectedEdgeDefinition, EdgeDefinitionFields> & {
|
|
54
159
|
readonly ref: language.ClassRef<Name> & {
|
|
55
160
|
readonly origin: Origin;
|
|
56
161
|
};
|
|
@@ -58,12 +163,10 @@ type ProjectedClassDefinition<Origin extends string, Name extends string, Value>
|
|
|
58
163
|
readonly abstract: AbstractOf<Input>;
|
|
59
164
|
readonly orientation: 'undirected';
|
|
60
165
|
readonly endpoints: readonly [
|
|
61
|
-
|
|
62
|
-
readonly role: First['as'];
|
|
166
|
+
ProjectedEndpoint<Origin, First, Root> & {
|
|
63
167
|
readonly incident: First['incident'];
|
|
64
168
|
},
|
|
65
|
-
|
|
66
|
-
readonly role: Second['as'];
|
|
169
|
+
ProjectedEndpoint<Origin, Second, Root> & {
|
|
67
170
|
readonly incident: Second['incident'];
|
|
68
171
|
}
|
|
69
172
|
];
|
|
@@ -81,9 +184,9 @@ type ParentClassProjectionTuple<Origin extends string, Parents extends readonly
|
|
|
81
184
|
type ShallowClassProjectionOfAuthoring<Origin extends string, Name extends string, Value, Root extends DomainSchemaInput> = ClassProjectionWithParents<Origin, Name, Value, Root, readonly language.AnyResolvedClass[]>;
|
|
82
185
|
/** Project each authored Class independently before computing its parent tuple. */
|
|
83
186
|
export type ClassProjectionOfAuthoring<Origin extends string, Name extends string, Value, Root extends DomainSchemaInput, Seen = Value> = Value extends Class ? ClassProjectionWithParents<Origin, Name, Value, Root, ParentClassProjectionTuple<Origin, ParentInputsOfConfig<ProjectionOfClass<Extract<Value, Class>>>, Root, Seen>> : never;
|
|
84
|
-
type ClassProjectionWithParents<Origin extends string, Name extends string, Value, Root extends DomainSchemaInput, Parents extends readonly unknown[]> = Value extends NodeClass<infer _Config> ? ClassProjection<'node', Extract<ProjectedClassDefinition<Origin, Name, Value>, language.NodeClassDefinition>, language.ClassRef<Name> & {
|
|
187
|
+
type ClassProjectionWithParents<Origin extends string, Name extends string, Value, Root extends DomainSchemaInput, Parents extends readonly unknown[]> = Value extends NodeClass<infer _Config> ? ClassProjection<'node', Extract<ProjectedClassDefinition<Origin, Name, Value, Root>, language.NodeClassDefinition>, language.ClassRef<Name> & {
|
|
85
188
|
readonly origin: Origin;
|
|
86
|
-
}, language.DefinitionKey<Origin, 'class', Name>, Parents, EffectivePropertyProjectionsOf<Origin, Name, Value, Root>, OwnInstanceMethodProjectionsOf<Origin, Name, Value>, OwnStaticMethodProjectionsOf<Origin, Name, Value>, OwnPropertyProjectionsOf<Origin, Name, Value>, OwnInstanceMethodProjectionsOf<Origin, Name, Value>, OwnStaticMethodProjectionsOf<Origin, Name, Value>> : Value extends DirectedEdgeClass | UndirectedEdgeClass ? ClassProjection<'edge', Extract<ProjectedClassDefinition<Origin, Name, Value>, language.EdgeClassDefinition>, language.ClassRef<Name> & {
|
|
189
|
+
}, language.DefinitionKey<Origin, 'class', Name>, Parents, EffectivePropertyProjectionsOf<Origin, Name, Value, Root>, OwnInstanceMethodProjectionsOf<Origin, Name, Value>, OwnStaticMethodProjectionsOf<Origin, Name, Value>, OwnPropertyProjectionsOf<Origin, Name, Value>, OwnInstanceMethodProjectionsOf<Origin, Name, Value>, OwnStaticMethodProjectionsOf<Origin, Name, Value>> : Value extends DirectedEdgeClass | UndirectedEdgeClass ? ClassProjection<'edge', Extract<ProjectedClassDefinition<Origin, Name, Value, Root>, language.EdgeClassDefinition>, language.ClassRef<Name> & {
|
|
87
190
|
readonly origin: Origin;
|
|
88
191
|
}, language.DefinitionKey<Origin, 'class', Name>, Parents, EffectivePropertyProjectionsOf<Origin, Name, Value, Root>, never, never, OwnPropertyProjectionsOf<Origin, Name, Value>, never, never> : never;
|
|
89
192
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type * as language from '../../../language/index.js';
|
|
2
2
|
import type { BlobReceipt } from '../../../language/value/model/blob.js';
|
|
3
|
-
import type { Class
|
|
3
|
+
import type { Class } from '../../class/handle.js';
|
|
4
|
+
import type { AuthoredPropertyProjection } from '../../class/projection.js';
|
|
4
5
|
import type { ResolveLazy, IsMultiple } from './identity.js';
|
|
5
6
|
import type { EffectivePropertyEntriesOfClass } from './property.js';
|
|
6
7
|
/** Derive required, optional and forbidden Core Property inputs by name. */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { NodeClass, DirectedEdgeClass, UndirectedEdgeClass,
|
|
1
|
+
import type { NodeClass, DirectedEdgeClass, UndirectedEdgeClass, Class } from '../../class/handle.js';
|
|
2
|
+
import type { ClassReferenceProjection, ClassReferenceProjectionOf, ClassIdentityProjectionOf, ClassOwnerProjectionOf, ClassOwnerProjection, ClassIdentityProjection } from '../../class/projection.js';
|
|
2
3
|
import type { DomainSchemaInput } from '../input.js';
|
|
3
4
|
/** Extract an authored abstract modifier with its default. */
|
|
4
5
|
export type AbstractOf<Config> = Config extends {
|
|
@@ -10,7 +10,7 @@ export interface PropertyProjection<Value = unknown, Required extends boolean =
|
|
|
10
10
|
readonly input: Input;
|
|
11
11
|
}
|
|
12
12
|
/** A Method’s exact callable, ownership and executable contracts. */
|
|
13
|
-
export interface MethodProjection<Input = unknown, Output = unknown, Static extends boolean = boolean, Abstract extends boolean = boolean, Auth extends language.FunctionAuth = language.FunctionAuth, Name extends string = string, Key extends language.MethodKey = language.MethodKey, Executable extends boolean = boolean, Execution extends language.CallableExecution | undefined = language.CallableExecution | undefined> {
|
|
13
|
+
export interface MethodProjection<Input = unknown, Output = unknown, Static extends boolean = boolean, Abstract extends boolean = boolean, Auth extends language.FunctionAuth = language.FunctionAuth, Name extends string = string, Key extends language.MethodKey = language.MethodKey, Executable extends boolean = boolean, Execution extends language.CallableExecution | undefined = language.CallableExecution | undefined, Admission extends language.CallableAdmission | undefined = language.CallableAdmission | undefined> {
|
|
14
14
|
readonly input: Input;
|
|
15
15
|
readonly output: Output;
|
|
16
16
|
readonly static: Static;
|
|
@@ -20,15 +20,17 @@ export interface MethodProjection<Input = unknown, Output = unknown, Static exte
|
|
|
20
20
|
readonly name: Name;
|
|
21
21
|
readonly key: Key;
|
|
22
22
|
readonly execution: Execution;
|
|
23
|
+
readonly admission: Admission;
|
|
23
24
|
}
|
|
24
25
|
/** A Function’s exact callable and declaration contracts. */
|
|
25
|
-
export interface FunctionProjection<Input = unknown, Output = unknown, Auth extends language.FunctionAuth = language.FunctionAuth, Ref extends language.FunctionRef = language.FunctionRef, Key extends language.DefinitionKey<string, 'function'> = language.DefinitionKey<string, 'function'>, Execution extends language.CallableExecution | undefined = language.CallableExecution | undefined> {
|
|
26
|
+
export interface FunctionProjection<Input = unknown, Output = unknown, Auth extends language.FunctionAuth = language.FunctionAuth, Ref extends language.FunctionRef = language.FunctionRef, Key extends language.DefinitionKey<string, 'function'> = language.DefinitionKey<string, 'function'>, Execution extends language.CallableExecution | undefined = language.CallableExecution | undefined, Admission extends language.CallableAdmission | undefined = language.CallableAdmission | undefined> {
|
|
26
27
|
readonly input: Input;
|
|
27
28
|
readonly output: Output;
|
|
28
29
|
readonly auth: Auth;
|
|
29
30
|
readonly ref: Ref;
|
|
30
31
|
readonly key: Key;
|
|
31
32
|
readonly execution: Execution;
|
|
33
|
+
readonly admission: Admission;
|
|
32
34
|
}
|
|
33
35
|
/** A compact Class witness with effective members and exact self facets. */
|
|
34
36
|
export interface ClassProjection<Kind extends language.ClassKind = language.ClassKind, Definition extends Extract<language.ClassDefinition, {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type * as language from '../../../language/index.js';
|
|
2
|
-
import type { AuthoredPropertyProjection } from '../../class/
|
|
2
|
+
import type { AuthoredPropertyProjection } from '../../class/projection.js';
|
|
3
3
|
import type { DomainSchemaInput } from '../input.js';
|
|
4
4
|
import type { RecordField, ClassInputOf, OwnerNameOf } from './identity.js';
|
|
5
5
|
import type { PropertyProjection } from './model.js';
|
|
@@ -56,10 +56,11 @@ type ProjectionPropertyByName<Entries extends PropertyProjection> = Readonly<{
|
|
|
56
56
|
/** Restore qualified lookup and unambiguous named Property access. */
|
|
57
57
|
type PropertyCollectionOfProjection<Entries extends PropertyProjection> = language.ResolvedPropertyCollection<ProjectionPropertyByKey<Entries>, ProjectionPropertyByName<Entries>>;
|
|
58
58
|
type MethodCollectionOperation = 'byKey' | 'get';
|
|
59
|
-
type ResolvedMethodOfProjection<Value> = Value extends MethodProjection<infer Input, infer Output, infer Static, infer Abstract, infer Auth, infer Name, infer Key, infer Executable, infer Execution> ? language.ResolvedMethod<Input, Output, Static, Abstract, Auth, language.CallablePolicy, Key> & {
|
|
59
|
+
type ResolvedMethodOfProjection<Value> = Value extends MethodProjection<infer Input, infer Output, infer Static, infer Abstract, infer Auth, infer Name, infer Key, infer Executable, infer Execution, infer Admission> ? language.ResolvedMethod<Input, Output, Static, Abstract, Auth, language.CallablePolicy, Key> & {
|
|
60
60
|
readonly name: Name;
|
|
61
61
|
readonly executable: Executable;
|
|
62
62
|
readonly execution: Execution;
|
|
63
|
+
readonly admission: Admission;
|
|
63
64
|
} : never;
|
|
64
65
|
type ProjectionMethodByKey<Entries extends MethodProjection> = Readonly<{
|
|
65
66
|
[Key in Entries['key']]: ResolvedMethodOfProjection<Extract<Entries, {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { PropertyProjection, MethodProjection, FunctionProjection, ClassProjection,
|
|
1
|
+
export type { PropertyProjection, MethodProjection, FunctionProjection, ClassProjection, } from './projection/model.js';
|
|
2
2
|
export type { ResolvedDomainOfInput } from './projection/domain.js';
|
|
3
3
|
export type { CoreNamedPropertyInput, CorePropertyInput } from './projection/core-input.js';
|
|
4
4
|
export type { ClassProjectionOfResolved } from './projection/resolved-class.js';
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { type FullMatch } from '../../language/value/syntax/full-match.js';
|
|
2
|
-
export { fullMatchSource, type FullMatch } from '../../language/value/syntax/full-match.js';
|
|
3
2
|
/** Authoring facade preserving the Builder-owned diagnostic for invalid source syntax. */
|
|
4
3
|
export declare function fullMatch(source: string): FullMatch;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { refuseIRegexp, stateBudgetMessage } from '../../language/value/regexp/syntax.js';
|
|
2
2
|
import { fullMatch as languageFullMatch, } from '../../language/value/syntax/full-match.js';
|
|
3
3
|
import { fail } from '../schema/diagnostic.js';
|
|
4
|
-
export { fullMatchSource } from '../../language/value/syntax/full-match.js';
|
|
5
4
|
/** Authoring facade preserving the Builder-owned diagnostic for invalid source syntax. */
|
|
6
5
|
export function fullMatch(source) {
|
|
7
6
|
const refusal = refuseIRegexp(source);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { z } from 'zod';
|
|
2
|
-
import type { NodeClassReferenceInput } from '../class/
|
|
2
|
+
import type { NodeClassReferenceInput } from '../class/input.js';
|
|
3
3
|
export declare function rememberPath(schema: z.ZodType, accepts: readonly NodeClassReferenceInput[]): void;
|
|
4
4
|
export declare function pathAccepts(schema: z.ZodType): readonly NodeClassReferenceInput[] | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ZodString } from 'zod';
|
|
2
|
-
import type { NodeClassReferenceInput } from '../class/
|
|
2
|
+
import type { NodeClassReferenceInput } from '../class/input.js';
|
|
3
3
|
declare const PATH_ACCEPTS: unique symbol;
|
|
4
4
|
export type PathAuthoring<Accepts extends readonly NodeClassReferenceInput[] = readonly NodeClassReferenceInput[]> = ZodString & {
|
|
5
5
|
readonly [PATH_ACCEPTS]: Accepts;
|