@astrale-os/kernel-dsl 1.0.0-beta.27 → 1.0.0-beta.29
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/ordering.d.ts +2 -2
- package/dist/v1/addressing/ordering.js +2 -4
- package/dist/v1/builder/index.d.ts +2 -0
- package/dist/v1/builder/index.js +1 -0
- package/dist/v1/builder/schema/projection/identity.d.ts +15 -0
- package/dist/v1/builder/schema/projection/property.d.ts +3 -3
- package/dist/v1/builder/schema/projection/resolved-class.d.ts +3 -3
- package/dist/v1/builder/schema/rule.d.ts +316 -0
- package/dist/v1/builder/schema/rule.js +192 -0
- package/dist/v1/bundle/index.d.ts +2 -0
- package/dist/v1/bundle/index.js +1 -0
- package/dist/v1/bundle/rule.d.ts +14 -0
- package/dist/v1/bundle/rule.js +41 -0
- package/dist/v1/compiled/admission/diagnostic.d.ts +14 -0
- package/dist/v1/compiled/admission/diagnostic.js +6 -0
- package/dist/v1/compiled/admission/semantics/policy/callable.js +2 -3
- package/dist/v1/compiled/admission/semantics/policy/parity.js +8 -13
- package/dist/v1/compiled/admission/semantics/policy/pattern.js +3 -5
- package/dist/v1/compiled/admission/wire/policy.js +16 -11
- package/dist/v1/compiled/index.d.ts +2 -0
- package/dist/v1/compiled/index.js +1 -0
- package/dist/v1/compiled/rule.d.ts +49 -0
- package/dist/v1/compiled/rule.js +169 -0
- package/dist/v1/domain/namespace/member-collection.js +4 -1
- package/dist/v1/language/callable/admission.js +2 -1
- package/dist/v1/language/class/resolved.d.ts +9 -4
- package/dist/v1/language/policy/analysis/branches.js +6 -7
- package/dist/v1/language/policy/analysis/budgets.js +8 -6
- package/dist/v1/language/policy/analysis/checks.js +5 -4
- package/dist/v1/language/policy/analysis/composition.js +2 -2
- package/dist/v1/language/policy/analysis/typing.js +3 -2
- package/dist/v1/language/policy/model/policy.d.ts +22 -0
- package/dist/v1/language/policy/model/policy.js +28 -4
- package/dist/v1/language/policy/normalization/normalize.js +33 -56
- package/dist/v1/language/value/evaluate/assertions.d.ts +2 -2
- package/dist/v1/language/value/evaluate/assertions.js +4 -34
- package/dist/v1/language/value/evaluate/evaluator.js +10 -15
- package/dist/v1/language/value/evaluate/validity.optimization.js +9 -14
- package/dist/v1/language/value/files.js +2 -1
- package/dist/v1/language/value/model/blob.d.ts +6 -0
- package/dist/v1/language/value/model/blob.js +8 -0
- package/dist/v1/language/value/ordering.js +1 -3
- package/dist/v1/language/value/profile/canonicalize.js +1 -3
- package/dist/v1/language/value/syntax/walk.d.ts +2 -0
- package/dist/v1/language/value/syntax/walk.js +4 -0
- package/dist/v1/schema/compatibility/api.d.ts +2 -0
- package/dist/v1/schema/compatibility/api.js +1 -0
- package/dist/v1/schema/compatibility/rule.d.ts +13 -0
- package/dist/v1/schema/compatibility/rule.js +23 -0
- package/dist/v1/schema/enforcement/changes.d.ts +590 -0
- package/dist/v1/schema/enforcement/changes.js +566 -0
- package/dist/v1/schema/enforcement/derived.d.ts +236 -0
- package/dist/v1/schema/enforcement/derived.js +243 -0
- package/dist/v1/schema/enforcement/dispose.d.ts +308 -0
- package/dist/v1/schema/enforcement/dispose.js +275 -0
- package/dist/v1/schema/enforcement/facts.d.ts +89 -0
- package/dist/v1/schema/enforcement/facts.js +70 -0
- package/dist/v1/schema/enforcement/fields.d.ts +65 -0
- package/dist/v1/schema/enforcement/fields.js +36 -0
- package/dist/v1/schema/enforcement/index.d.ts +39 -0
- package/dist/v1/schema/enforcement/index.js +10 -0
- package/dist/v1/schema/enforcement/install.d.ts +1634 -0
- package/dist/v1/schema/enforcement/install.js +1223 -0
- package/dist/v1/schema/enforcement/lifecycle.d.ts +87 -0
- package/dist/v1/schema/enforcement/lifecycle.js +91 -0
- package/dist/v1/schema/enforcement/model.d.ts +253 -0
- package/dist/v1/schema/enforcement/model.js +1 -0
- package/dist/v1/schema/enforcement/obligations.d.ts +248 -0
- package/dist/v1/schema/enforcement/obligations.js +240 -0
- package/dist/v1/schema/enforcement/write.d.ts +1314 -0
- package/dist/v1/schema/enforcement/write.js +1017 -0
- package/dist/v1/schema/index.d.ts +1 -0
- package/dist/v1/schema/index.js +1 -0
- package/dist/v1/schema/resolution/origins.js +4 -7
- package/dist/v1/schema/rule.d.ts +4 -5
- package/dist/v1/schema/rule.js +19 -13
- package/dist/v1/schema/validation/policy/references.js +5 -11
- package/dist/v1/schema/validation/policy/uses.js +3 -8
- package/dist/v1/schema/validation/value-api.d.ts +1 -1
- package/dist/v1/schema/validation/value-api.js +1 -1
- package/dist/value/accept.d.ts +6 -0
- package/dist/value/accept.js +25 -1
- package/dist/value/canonical.d.ts +16 -1
- package/dist/value/canonical.js +90 -33
- package/dist/value/immutable.optimization.d.ts +2 -0
- package/dist/value/immutable.optimization.js +4 -0
- package/dist/value/index.d.ts +3 -1
- package/dist/value/index.js +2 -1
- package/dist/value/rule.d.ts +12 -0
- package/dist/value/rule.js +50 -0
- package/package.json +5 -1
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { deepFreeze } from '../language/freeze.js';
|
|
2
|
+
import { DOMAIN_BUNDLE_FORMAT, DOMAIN_BUNDLE_VERSION } from './model.js';
|
|
3
|
+
const PIN = ['/root/dependencies/{alias}', '/closure/{index}/dependencies/{alias}'];
|
|
4
|
+
/**
|
|
5
|
+
* Every diagnostic code a Bundle owns with the rule it reports, frozen. A refused Schema of a
|
|
6
|
+
* Bundle answers with the codes of `schema.RULES`, rebased under its place in the Bundle.
|
|
7
|
+
*/
|
|
8
|
+
export const BUNDLE_RULES = deepFreeze({
|
|
9
|
+
BUNDLE_STRUCTURE: {
|
|
10
|
+
positions: ['', '/{field}'],
|
|
11
|
+
statement: 'A Bundle is an object holding `format`, `version`, `root` and `closure` and no other field, its `closure` an array.',
|
|
12
|
+
},
|
|
13
|
+
UNSUPPORTED_BUNDLE_FORMAT: {
|
|
14
|
+
positions: ['/format'],
|
|
15
|
+
statement: `The \`format\` of a Bundle is \`${DOMAIN_BUNDLE_FORMAT}\`.`,
|
|
16
|
+
},
|
|
17
|
+
UNSUPPORTED_BUNDLE_VERSION: {
|
|
18
|
+
positions: ['/version'],
|
|
19
|
+
statement: `The \`version\` of a Bundle is \`${DOMAIN_BUNDLE_VERSION}\`.`,
|
|
20
|
+
},
|
|
21
|
+
BUNDLE_ROOT_DUPLICATED: {
|
|
22
|
+
positions: ['/closure/{index}'],
|
|
23
|
+
statement: 'The closure of a Bundle does not hold its root.',
|
|
24
|
+
},
|
|
25
|
+
BUNDLE_SCHEMA_DUPLICATED: {
|
|
26
|
+
positions: ['/closure/{index}'],
|
|
27
|
+
statement: 'The closure of a Bundle holds each origin at each revision once.',
|
|
28
|
+
},
|
|
29
|
+
BUNDLE_CLOSURE_EXTRA: {
|
|
30
|
+
positions: ['/closure/{index}'],
|
|
31
|
+
statement: 'The closure of a Bundle holds only Schemas its root reaches through exact pins.',
|
|
32
|
+
},
|
|
33
|
+
BUNDLE_CLOSURE_MISSING: {
|
|
34
|
+
positions: PIN,
|
|
35
|
+
statement: 'The closure of a Bundle holds the exact revision of every pin its root reaches.',
|
|
36
|
+
},
|
|
37
|
+
BUNDLE_REVISION_COHERENCE: {
|
|
38
|
+
positions: PIN,
|
|
39
|
+
statement: 'The pins a root reaches ask one revision of each origin.',
|
|
40
|
+
},
|
|
41
|
+
});
|
|
@@ -3,6 +3,20 @@ import { type CompiledDiagnosticCode } from '../diagnostic.js';
|
|
|
3
3
|
export { appendPointer as pointer } from '../../language/value/syntax/pointer.js';
|
|
4
4
|
/** Report a structural compiled-input violation with its stable diagnostic code. */
|
|
5
5
|
export declare function invalid(label: string, code?: CompiledDiagnosticCode, path?: string): never;
|
|
6
|
+
/** How a refusal names the Policy checks of each use site and, once typed, their object contract. */
|
|
7
|
+
export declare const POLICY_CHECK_SITE: {
|
|
8
|
+
readonly callable: {
|
|
9
|
+
readonly name: 'Callable Policy';
|
|
10
|
+
readonly objects: 'the callable object contract';
|
|
11
|
+
};
|
|
12
|
+
readonly class: {
|
|
13
|
+
readonly name: 'Class rule';
|
|
14
|
+
readonly objects: 'the Class rule object contract';
|
|
15
|
+
};
|
|
16
|
+
readonly create: {
|
|
17
|
+
readonly name: 'Create rule';
|
|
18
|
+
};
|
|
19
|
+
};
|
|
6
20
|
/** Report a contextual compiled-language violation at its original source pointer. */
|
|
7
21
|
export declare function fail(pointer: string, message: string): never;
|
|
8
22
|
/** Cross the portable value boundary with a compiled document, whose refusal is answered as one. */
|
|
@@ -6,6 +6,12 @@ export { appendPointer as pointer } from '../../language/value/syntax/pointer.js
|
|
|
6
6
|
export function invalid(label, code = 'COMPILED_STRUCTURE_INVALID', path = '') {
|
|
7
7
|
return invalidCompiled(code, `Invalid compiled Schema ${label}.`, path);
|
|
8
8
|
}
|
|
9
|
+
/** How a refusal names the Policy checks of each use site and, once typed, their object contract. */
|
|
10
|
+
export const POLICY_CHECK_SITE = {
|
|
11
|
+
callable: { name: 'Callable Policy', objects: 'the callable object contract' },
|
|
12
|
+
class: { name: 'Class rule', objects: 'the Class rule object contract' },
|
|
13
|
+
create: { name: 'Create rule' },
|
|
14
|
+
};
|
|
9
15
|
/** Report a contextual compiled-language violation at its original source pointer. */
|
|
10
16
|
export function fail(pointer, message) {
|
|
11
17
|
return invalidCompiled('COMPILED_SOURCE_INVALID', message, pointer);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Key } from '../../../../addressing/index.js';
|
|
2
|
-
import {} from '../../../../language/policy/model/policy.js';
|
|
2
|
+
import { PolicyComposition, } from '../../../../language/policy/model/policy.js';
|
|
3
3
|
import { GRAPH_NODE_PATH_SCHEMA_ID } from '../../../../language/value/syntax/node-path/schema.js';
|
|
4
4
|
import {} from '../../../model/schema.js';
|
|
5
5
|
import { fail } from '../../diagnostic.js';
|
|
@@ -27,8 +27,7 @@ export function validateCallablePolicy(context, entry, expression, inputIndex, f
|
|
|
27
27
|
}
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
|
-
|
|
31
|
-
children.forEach((child, index) => validateCallablePolicy(context, entry, child, inputIndex, fields, instanceMethod, `${path}/${index}`));
|
|
30
|
+
PolicyComposition.of(expression).operands.forEach((child, index) => validateCallablePolicy(context, entry, child, inputIndex, fields, instanceMethod, `${path}/${index}`));
|
|
32
31
|
}
|
|
33
32
|
function isSingleNodePathField(context, entry, inputIndex, field) {
|
|
34
33
|
const rootValue = entry.values[inputIndex]?.nodes[entry.values[inputIndex].root]?.schema;
|
|
@@ -3,10 +3,10 @@ import { branchesOf, targetMode, isConnected, } from '../../../../language/polic
|
|
|
3
3
|
import { exceededLimits, measureChecks, policyMeasurer, } from '../../../../language/policy/analysis/budgets.js';
|
|
4
4
|
import { neverAdmittedClasses, } from '../../../../language/policy/analysis/checks.js';
|
|
5
5
|
import {} from '../../../../language/policy/analysis/typing.js';
|
|
6
|
-
import { CLASS_OPERATIONS, checksNameTheCaller, isClassRuleChecks, } from '../../../../language/policy/model/policy.js';
|
|
6
|
+
import { CLASS_OPERATIONS, checksNameTheCaller, isClassRuleChecks, PolicyComposition, } from '../../../../language/policy/model/policy.js';
|
|
7
7
|
import { normalizePolicyExpression } from '../../../../language/policy/normalization/normalize.js';
|
|
8
8
|
import {} from '../../../model/schema.js';
|
|
9
|
-
import { fail } from '../../diagnostic.js';
|
|
9
|
+
import { fail, POLICY_CHECK_SITE } from '../../diagnostic.js';
|
|
10
10
|
import { isCompiledEdge, } from '../context.js';
|
|
11
11
|
import { callableObjectContracts } from './contracts.js';
|
|
12
12
|
import { compiledPolicyTyping } from './typing.js';
|
|
@@ -84,17 +84,13 @@ export function validatePolicyParity(context, entry, entryIndex, policies, origi
|
|
|
84
84
|
function declarationIndex(entry, kind, name) {
|
|
85
85
|
return entry.definitions[kind].findIndex(({ ref }) => ref.name === name);
|
|
86
86
|
}
|
|
87
|
-
/** How a refusal names the checks of each site and the contract of their objects. */
|
|
88
|
-
const SITE = {
|
|
89
|
-
callable: { checks: 'Callable Policy checks', objects: 'the callable object contract' },
|
|
90
|
-
class: { checks: 'Class rule checks', objects: 'the Class rule object contract' },
|
|
91
|
-
};
|
|
92
87
|
function validatePolicyChecks(context, typing, entry, expression, input, receiver, path, site, edge) {
|
|
88
|
+
const label = POLICY_CHECK_SITE[site];
|
|
93
89
|
if (!checksNameTheCaller(expression)) {
|
|
94
|
-
fail(path, `${
|
|
90
|
+
fail(path, `${label.name} checks must check a Policy on every branch: sameNode alone names no caller.`);
|
|
95
91
|
}
|
|
96
92
|
if (exceededLimits(measureChecks(expression)).length > 0) {
|
|
97
|
-
fail(path, `${
|
|
93
|
+
fail(path, `${label.name} checks exceed the V1 depth, branch, or leaf budget.`);
|
|
98
94
|
}
|
|
99
95
|
const leaves = new Map();
|
|
100
96
|
const visit = (value, pointer) => {
|
|
@@ -106,8 +102,7 @@ function validatePolicyChecks(context, typing, entry, expression, input, receive
|
|
|
106
102
|
return;
|
|
107
103
|
}
|
|
108
104
|
if (!('check' in value)) {
|
|
109
|
-
|
|
110
|
-
children.forEach((child, index) => visit(child, `${pointer}/${index}`));
|
|
105
|
+
PolicyComposition.of(value).operands.forEach((child, index) => visit(child, `${pointer}/${index}`));
|
|
111
106
|
return;
|
|
112
107
|
}
|
|
113
108
|
if (edge !== undefined && value.object.kind === 'self') {
|
|
@@ -123,13 +118,13 @@ function validatePolicyChecks(context, typing, entry, expression, input, receive
|
|
|
123
118
|
return;
|
|
124
119
|
const classes = typing.checkLeafClasses(value.check.name, contracts);
|
|
125
120
|
if (classes === undefined) {
|
|
126
|
-
fail(pointer, `Named Policy is incompatible with ${
|
|
121
|
+
fail(pointer, `Named Policy is incompatible with ${label.objects}.`);
|
|
127
122
|
}
|
|
128
123
|
leaves.set(value, classes);
|
|
129
124
|
};
|
|
130
125
|
visit(expression, path);
|
|
131
126
|
const [never] = neverAdmittedClasses(expression, leaves);
|
|
132
127
|
if (never !== undefined) {
|
|
133
|
-
fail(path, `${
|
|
128
|
+
fail(path, `${label.name} checks can never admit ${never[0]} of Class ${never[1]}.`);
|
|
134
129
|
}
|
|
135
130
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Key } from '../../../../addressing/index.js';
|
|
2
2
|
import { isMethodExecutable } from '../../../../language/callable/executable.js';
|
|
3
3
|
import { policyVariableClass } from '../../../../language/index.js';
|
|
4
|
-
import {} from '../../../../language/policy/model/policy.js';
|
|
4
|
+
import { PolicyComposition, } from '../../../../language/policy/model/policy.js';
|
|
5
5
|
import {} from '../../../model/schema.js';
|
|
6
6
|
import { fail } from '../../diagnostic.js';
|
|
7
7
|
import {} from '../context.js';
|
|
@@ -14,8 +14,7 @@ export function validatePolicyExpression(context, entry, expression, path, local
|
|
|
14
14
|
validatePattern(context, expression.match, `${path}/match`, new Set(), new Set());
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
|
-
const
|
|
18
|
-
for (const [index, ref] of values.entries()) {
|
|
17
|
+
for (const [index, ref] of PolicyComposition.of(expression).operands.entries()) {
|
|
19
18
|
if (ref.origin !== entry.origin || ref.kind !== 'policy' || !local.has(ref.name))
|
|
20
19
|
fail(`${path}/${index}`, 'Named Policy composition must reference a local Policy.');
|
|
21
20
|
}
|
|
@@ -48,8 +47,7 @@ function validatePattern(context, expression, path, scope, declared) {
|
|
|
48
47
|
validatePattern(context, expression.exists.where, `${path}/exists/where`, nested, declared);
|
|
49
48
|
return;
|
|
50
49
|
}
|
|
51
|
-
|
|
52
|
-
values.forEach((value, index) => validatePattern(context, value, `${path}/${index}`, scope, declared));
|
|
50
|
+
PolicyComposition.of(expression).operands.forEach((value, index) => validatePattern(context, value, `${path}/${index}`, scope, declared));
|
|
53
51
|
}
|
|
54
52
|
function validatePolicyTerm(context, term, path, scope) {
|
|
55
53
|
if (term.kind === 'ref' && term.ref.kind === 'method')
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { equal } from '@astrale-os/kernel-dsl/value';
|
|
2
2
|
import { Key } from '../../../addressing/index.js';
|
|
3
|
+
import { limits } from '../../../language/limits.js';
|
|
3
4
|
import { normalizeClassRule } from '../../../language/policy/normalization/normalize.js';
|
|
4
|
-
import { invalid, pointer } from '../diagnostic.js';
|
|
5
|
+
import { invalid, pointer, POLICY_CHECK_SITE } from '../diagnostic.js';
|
|
5
6
|
import { definitionRef, policyObjectRef } from './reference.js';
|
|
6
7
|
import { object, exact, description, array, unique, boundedInteger, integer, memberName, } from './value.js';
|
|
8
|
+
/**
|
|
9
|
+
* The nesting a decoder follows before refusing: a structural guard for the recursion, far above
|
|
10
|
+
* the depths `limits.policy` admits, which the semantic checks enforce.
|
|
11
|
+
*/
|
|
12
|
+
const WIRE_DEPTH = 64;
|
|
7
13
|
/** Decode a named Policy and its expression grammar. */
|
|
8
14
|
export function compiledPolicy(input, path) {
|
|
9
15
|
const value = object(input, 'Policy', path);
|
|
@@ -14,7 +20,7 @@ export function compiledPolicy(input, path) {
|
|
|
14
20
|
return value;
|
|
15
21
|
}
|
|
16
22
|
function policyExpression(input, depth, path) {
|
|
17
|
-
if (depth >
|
|
23
|
+
if (depth > WIRE_DEPTH)
|
|
18
24
|
invalid('Policy expression depth', undefined, path);
|
|
19
25
|
const value = object(input, 'Policy expression', path);
|
|
20
26
|
if (Object.hasOwn(value, 'match')) {
|
|
@@ -31,7 +37,7 @@ function policyExpression(input, depth, path) {
|
|
|
31
37
|
unique(refs.map(Key.of), `Policy ${member}`, memberPath);
|
|
32
38
|
}
|
|
33
39
|
function policyPattern(input, depth, path) {
|
|
34
|
-
if (depth >
|
|
40
|
+
if (depth > WIRE_DEPTH)
|
|
35
41
|
invalid('Policy pattern depth', undefined, path);
|
|
36
42
|
const value = object(input, 'Policy pattern', path);
|
|
37
43
|
if (Object.hasOwn(value, 'sameNode')) {
|
|
@@ -49,7 +55,7 @@ function policyPattern(input, depth, path) {
|
|
|
49
55
|
exact(exists, ['nodes', 'where'], 'Policy exists', existsPath);
|
|
50
56
|
const nodesPath = `${existsPath}/nodes`;
|
|
51
57
|
const nodes = array(exists.nodes, 'Policy variables', nodesPath);
|
|
52
|
-
if (nodes.length < 1 || nodes.length >
|
|
58
|
+
if (nodes.length < 1 || nodes.length > limits.policy.variablesPerExists)
|
|
53
59
|
invalid('Policy variables', undefined, nodesPath);
|
|
54
60
|
for (const [index, node] of nodes.entries()) {
|
|
55
61
|
const variablePath = `${nodesPath}/${index}`;
|
|
@@ -97,8 +103,9 @@ function policyPattern(input, depth, path) {
|
|
|
97
103
|
const repeatPath = `${path}/repeat`;
|
|
98
104
|
const repeat = object(value.repeat, 'Policy repeat', repeatPath);
|
|
99
105
|
exact(repeat, ['min', 'max'], 'Policy repeat', repeatPath);
|
|
100
|
-
const
|
|
101
|
-
const
|
|
106
|
+
const { repetition } = limits.policy;
|
|
107
|
+
const minimum = boundedInteger(repeat.min, 0, repetition, 'Policy repeat minimum', `${repeatPath}/min`);
|
|
108
|
+
const maximum = boundedInteger(repeat.max, 0, repetition, 'Policy repeat maximum', `${repeatPath}/max`);
|
|
102
109
|
if (minimum > maximum)
|
|
103
110
|
invalid('Policy repeat order', undefined, repeatPath);
|
|
104
111
|
}
|
|
@@ -141,12 +148,10 @@ export function classRuleChecks(input, path, site) {
|
|
|
141
148
|
invalid('Class rule spelling', undefined, path);
|
|
142
149
|
}
|
|
143
150
|
}
|
|
144
|
-
/** What a site calls its checks in a refusal. */
|
|
145
|
-
const SITE = { callable: 'Callable Policy', class: 'Class rule', create: 'Create rule' };
|
|
146
151
|
/** Check the recursive Policy check wire grammar of one use site. */
|
|
147
152
|
function policyCheck(input, depth, path, site = 'callable') {
|
|
148
|
-
const name =
|
|
149
|
-
if (depth >
|
|
153
|
+
const { name } = POLICY_CHECK_SITE[site];
|
|
154
|
+
if (depth > WIRE_DEPTH)
|
|
150
155
|
invalid(`${name} depth`, undefined, path);
|
|
151
156
|
const value = object(input, name, path);
|
|
152
157
|
if (Object.hasOwn(value, 'sameNode')) {
|
|
@@ -174,7 +179,7 @@ function policyCheck(input, depth, path, site = 'callable') {
|
|
|
174
179
|
policyCheck(expression, depth + 1, `${memberPath}/${index}`, site);
|
|
175
180
|
}
|
|
176
181
|
function policyCheckObject(input, objectPath, site) {
|
|
177
|
-
const name =
|
|
182
|
+
const { name } = POLICY_CHECK_SITE[site];
|
|
178
183
|
const target = object(input, `${name} object`, objectPath);
|
|
179
184
|
if (target.kind === 'self' && site !== 'create')
|
|
180
185
|
exact(target, ['kind'], `${name} self`, objectPath);
|
|
@@ -2,6 +2,8 @@ export { acceptCompiledSchema as accept } from './admission/accept.js';
|
|
|
2
2
|
export { compile } from './compiler/compile.js';
|
|
3
3
|
export { decode, encode } from './codec/json.js';
|
|
4
4
|
export { load } from './loader/load.js';
|
|
5
|
+
export { COMPILED_RULES as RULES, READMITTED_RULES, READMITTED_VALUE_RULES } from './rule.js';
|
|
6
|
+
export type { CompiledRule as Rule, ReadmittedRule } from './rule.js';
|
|
5
7
|
export { CompiledSchemaError as Error } from './diagnostic.js';
|
|
6
8
|
export type { CompiledDiagnostic as Diagnostic, CompiledDiagnosticCode as DiagnosticCode, } from './diagnostic.js';
|
|
7
9
|
export type * from './model/schema.js';
|
|
@@ -2,4 +2,5 @@ export { acceptCompiledSchema as accept } from './admission/accept.js';
|
|
|
2
2
|
export { compile } from './compiler/compile.js';
|
|
3
3
|
export { decode, encode } from './codec/json.js';
|
|
4
4
|
export { load } from './loader/load.js';
|
|
5
|
+
export { COMPILED_RULES as RULES, READMITTED_RULES, READMITTED_VALUE_RULES } from './rule.js';
|
|
5
6
|
export { CompiledSchemaError as Error } from './diagnostic.js';
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { BoundaryErrorCode } from '@astrale-os/kernel-dsl/value';
|
|
2
|
+
import type { LimitKey } from '../language/limits.js';
|
|
3
|
+
import type { DiagnosticCode as ValueDiagnosticCode } from '../language/validation/diagnostic.js';
|
|
4
|
+
import type { SchemaDiagnosticCode } from '../schema/diagnostic.js';
|
|
5
|
+
import type { CompiledDiagnosticCode } from './diagnostic.js';
|
|
6
|
+
/** The rule one diagnostic code of a compiled Schema reports. */
|
|
7
|
+
export interface CompiledRule {
|
|
8
|
+
/** The positions its diagnostics point at, as the positions of `schema.Rule`. */
|
|
9
|
+
readonly positions: readonly [string, ...string[]];
|
|
10
|
+
/** The rule, in one plain sentence. */
|
|
11
|
+
readonly statement: string;
|
|
12
|
+
/** The limits of `schema.limits` the rule enforces, by key, where it enforces some. */
|
|
13
|
+
readonly limits?: readonly [LimitKey, ...LimitKey[]];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Every diagnostic code of a compiled Schema with the rule it reports, frozen. A code added here
|
|
17
|
+
* does not compile until it is described.
|
|
18
|
+
*/
|
|
19
|
+
export declare const COMPILED_RULES: Readonly<Record<CompiledDiagnosticCode, CompiledRule>>;
|
|
20
|
+
/** How admission of a compiled Schema holds one rule of the language. */
|
|
21
|
+
export type ReadmittedRule = {
|
|
22
|
+
/** A compiled Schema breaking the rule is refused, under one of these codes. */
|
|
23
|
+
readonly kind: 'refused';
|
|
24
|
+
readonly answers: readonly [CompiledDiagnosticCode, ...CompiledDiagnosticCode[]];
|
|
25
|
+
/** The part of the rule a compiled Schema may break and still load. */
|
|
26
|
+
readonly except?: string;
|
|
27
|
+
} | {
|
|
28
|
+
/** The portable value boundary refuses it before admission: `COMPILED_STRUCTURE_INVALID`, caused by one of these. */
|
|
29
|
+
readonly kind: 'portable';
|
|
30
|
+
readonly answers: readonly [BoundaryErrorCode, ...BoundaryErrorCode[]];
|
|
31
|
+
} | {
|
|
32
|
+
/** A compiled Schema has no position for what the rule reads. */
|
|
33
|
+
readonly kind: 'unsayable';
|
|
34
|
+
readonly because: string;
|
|
35
|
+
} | {
|
|
36
|
+
/** A compiled Schema breaking the rule loads, for the reason given. */
|
|
37
|
+
readonly kind: 'unapplied';
|
|
38
|
+
readonly because: string;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Every rule of a source with how admission of a compiled Schema holds it, frozen. A rule added to
|
|
42
|
+
* the language does not compile until it is placed here.
|
|
43
|
+
*/
|
|
44
|
+
export declare const READMITTED_RULES: Readonly<Record<SchemaDiagnosticCode, ReadmittedRule>>;
|
|
45
|
+
/**
|
|
46
|
+
* Every rule of a value schema with how admission of a compiled Schema holds it, frozen. A rule added
|
|
47
|
+
* to the value language does not compile until it is placed here.
|
|
48
|
+
*/
|
|
49
|
+
export declare const READMITTED_VALUE_RULES: Readonly<Record<Extract<ValueDiagnosticCode, `VS_${string}`>, ReadmittedRule>>;
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { deepFreeze } from '../language/freeze.js';
|
|
2
|
+
import { limits } from '../language/limits.js';
|
|
3
|
+
/**
|
|
4
|
+
* Every diagnostic code of a compiled Schema with the rule it reports, frozen. A code added here
|
|
5
|
+
* does not compile until it is described.
|
|
6
|
+
*/
|
|
7
|
+
export const COMPILED_RULES = deepFreeze({
|
|
8
|
+
COMPILED_STRUCTURE_INVALID: {
|
|
9
|
+
positions: ['{/path*}'],
|
|
10
|
+
statement: `A compiled Schema is a portable value, has its format and version and exactly the fields of its wire shape, holds each origin once in its closure, spells each Class rule in its normal form, and its root and every pin name a revision of that closure. It holds at most ${limits.closure.members} members and items. An entry past the limits of the canonical encoder has no revision, so it is refused here.`,
|
|
11
|
+
limits: ['closure.members'],
|
|
12
|
+
},
|
|
13
|
+
COMPILED_CANONICAL_MISMATCH: {
|
|
14
|
+
positions: ['/closure/{index}/revision', '/closure/{index}{/path*}/execution/durable'],
|
|
15
|
+
statement: 'A compiled Schema holds the canonical form of what it says: an entry the revision of its own content, a Callable no execution unless durable. What a revision leaves out stands outside this rule: the graph and machines of a value program, the pattern table of an entry, the ordering of a Property and the input fields of a Callable are derived from what the revision covers, so a document saying otherwise loads and answers as that part says.',
|
|
16
|
+
},
|
|
17
|
+
COMPILED_DEPENDENCY_LIMITS: {
|
|
18
|
+
positions: ['/closure', '/closure/{index}/dependencies'],
|
|
19
|
+
statement: `A compiled Schema has a closure of at most ${limits.dependency.closure} Domains, each with at most ${limits.dependency.direct} direct dependencies, at most ${limits.dependency.depth} deep.`,
|
|
20
|
+
limits: ['dependency.closure', 'dependency.direct', 'dependency.depth'],
|
|
21
|
+
},
|
|
22
|
+
COMPILED_SOURCE_INVALID: {
|
|
23
|
+
positions: ['/closure/{index}{/path*}'],
|
|
24
|
+
statement: 'A compiled entry holds the rules of the language `READMITTED_RULES` places under this code: admission applies them to it again.',
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
const WIRE = { kind: 'refused', answers: ['COMPILED_STRUCTURE_INVALID'] };
|
|
28
|
+
const SOURCE = { kind: 'refused', answers: ['COMPILED_SOURCE_INVALID'] };
|
|
29
|
+
const WIRE_OR_SOURCE = {
|
|
30
|
+
kind: 'refused',
|
|
31
|
+
answers: ['COMPILED_STRUCTURE_INVALID', 'COMPILED_SOURCE_INVALID'],
|
|
32
|
+
};
|
|
33
|
+
const PORTABLE = {
|
|
34
|
+
kind: 'portable',
|
|
35
|
+
answers: [
|
|
36
|
+
'VALUE_TYPE',
|
|
37
|
+
'VALUE_NUMBER',
|
|
38
|
+
'VALUE_STRING',
|
|
39
|
+
'VALUE_ARRAY',
|
|
40
|
+
'VALUE_OBJECT',
|
|
41
|
+
'VALUE_CYCLE',
|
|
42
|
+
'VALUE_LIMIT',
|
|
43
|
+
'VALUE_REFLECTION',
|
|
44
|
+
],
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Every rule of a source with how admission of a compiled Schema holds it, frozen. A rule added to
|
|
48
|
+
* the language does not compile until it is placed here.
|
|
49
|
+
*/
|
|
50
|
+
export const READMITTED_RULES = deepFreeze({
|
|
51
|
+
UNSUPPORTED_DOCUMENT_FORMAT: WIRE,
|
|
52
|
+
UNSUPPORTED_DSL_VERSION: WIRE,
|
|
53
|
+
DV_JSON_VALUE: PORTABLE,
|
|
54
|
+
STRUCTURE_BINARY_INPUT: WIRE,
|
|
55
|
+
STRUCTURE_CALLABLE_POLICY_AUTH: WIRE,
|
|
56
|
+
STRUCTURE_DEPENDENCY_ALIAS: WIRE,
|
|
57
|
+
STRUCTURE_DOMAIN_NAME: WIRE,
|
|
58
|
+
STRUCTURE_DUPLICATE_ITEM: WIRE,
|
|
59
|
+
STRUCTURE_EDGE_BLOB: {
|
|
60
|
+
kind: 'unapplied',
|
|
61
|
+
because: 'Admission does not read the value kind of an Edge Property.',
|
|
62
|
+
},
|
|
63
|
+
STRUCTURE_EDGE_ORIENTATION: WIRE,
|
|
64
|
+
STRUCTURE_FORMAT: WIRE,
|
|
65
|
+
STRUCTURE_KEY: WIRE,
|
|
66
|
+
STRUCTURE_MAXIMUM: WIRE,
|
|
67
|
+
STRUCTURE_MINIMUM: WIRE,
|
|
68
|
+
STRUCTURE_PROPERTY_KEY: WIRE_OR_SOURCE,
|
|
69
|
+
STRUCTURE_PROTO_KEY: WIRE,
|
|
70
|
+
STRUCTURE_REQUIRED: WIRE,
|
|
71
|
+
STRUCTURE_STATE_TRANSITIONS: SOURCE,
|
|
72
|
+
STRUCTURE_TYPE: WIRE,
|
|
73
|
+
STRUCTURE_UNION: WIRE,
|
|
74
|
+
STRUCTURE_UNKNOWN_FIELD: WIRE_OR_SOURCE,
|
|
75
|
+
STRUCTURE_VALUE: WIRE,
|
|
76
|
+
DV_ACCEPTANCE_CONTEXT: {
|
|
77
|
+
kind: 'unsayable',
|
|
78
|
+
because: 'A compiled Schema carries its closure, so no acceptance in this process precedes it.',
|
|
79
|
+
},
|
|
80
|
+
DV_CALLABLE_ADMISSION: SOURCE,
|
|
81
|
+
DV_CALLABLE_AUTH: SOURCE,
|
|
82
|
+
DV_CALLABLE_IO: SOURCE,
|
|
83
|
+
DV_CLASS_ABSTRACT: SOURCE,
|
|
84
|
+
DV_CLASS_ACYCLIC: SOURCE,
|
|
85
|
+
DV_CLASS_INHERITANCE: SOURCE,
|
|
86
|
+
DV_CLASS_KIND: SOURCE,
|
|
87
|
+
DV_CORE_EDGE_CLASS: SOURCE,
|
|
88
|
+
DV_CORE_EDGE_CONSTRAINTS: SOURCE,
|
|
89
|
+
DV_CORE_EDGE_KEY: SOURCE,
|
|
90
|
+
DV_CORE_EDGE_PROPERTIES: SOURCE,
|
|
91
|
+
DV_CORE_EDGE_UNIQUE: SOURCE,
|
|
92
|
+
DV_CORE_NODE_CLASS: SOURCE,
|
|
93
|
+
DV_CORE_NODE_PROPERTIES: SOURCE,
|
|
94
|
+
DV_CORE_NODE_UNIQUE: SOURCE,
|
|
95
|
+
DV_CORE_REF: SOURCE,
|
|
96
|
+
DV_DATA_COMPOSITION: SOURCE,
|
|
97
|
+
DV_DEPENDENCY_ACYCLIC: WIRE,
|
|
98
|
+
DV_DEPENDENCY_DIRECT: SOURCE,
|
|
99
|
+
DV_DEPENDENCY_EXACT: WIRE,
|
|
100
|
+
DV_DEPENDENCY_LIMITS: { kind: 'refused', answers: ['COMPILED_DEPENDENCY_LIMITS'] },
|
|
101
|
+
DV_DEPENDENCY_REVISION_COHERENCE: WIRE,
|
|
102
|
+
DV_DEPENDENCY_UNIQUE: WIRE,
|
|
103
|
+
DV_DOMAIN_ICON: WIRE,
|
|
104
|
+
DV_EDGE_ACCEPTS: SOURCE,
|
|
105
|
+
DV_EDGE_CLASS_COMPOSITION: SOURCE,
|
|
106
|
+
DV_EDGE_FOREIGN_MINIMUM: {
|
|
107
|
+
kind: 'unapplied',
|
|
108
|
+
because: 'Admission reads an Edge count only against the Core facts of its entry.',
|
|
109
|
+
},
|
|
110
|
+
DV_EDGE_LIFETIME: {
|
|
111
|
+
kind: 'unapplied',
|
|
112
|
+
because: 'Admission reads `onDelete` only as a value of its position.',
|
|
113
|
+
},
|
|
114
|
+
DV_EDGE_ROLE: WIRE,
|
|
115
|
+
DV_EDGE_UNIQUE: SOURCE,
|
|
116
|
+
DV_ENTRYPOINT: WIRE,
|
|
117
|
+
DV_INHERITANCE_LIMITS: SOURCE,
|
|
118
|
+
DV_METHOD_ABSTRACT: SOURCE,
|
|
119
|
+
DV_METHOD_COMPOSITION: SOURCE,
|
|
120
|
+
DV_NODE_UNIQUE: SOURCE,
|
|
121
|
+
DV_PROPERTY_AUTO: SOURCE,
|
|
122
|
+
DV_PROPERTY_IMMUTABLE: SOURCE,
|
|
123
|
+
DV_PROPERTY_STATE: SOURCE,
|
|
124
|
+
DV_REF_RESOLVES: WIRE_OR_SOURCE,
|
|
125
|
+
DV_VALUE_SCHEMA: {
|
|
126
|
+
kind: 'refused',
|
|
127
|
+
answers: ['COMPILED_STRUCTURE_INVALID', 'COMPILED_SOURCE_INVALID'],
|
|
128
|
+
except: 'Every rule of a value schema but its pattern sources, its numbers and what deriving its graph reads, as `READMITTED_VALUE_RULES` places each.',
|
|
129
|
+
},
|
|
130
|
+
PL_BUDGET: SOURCE,
|
|
131
|
+
PL_COMPOSITION: SOURCE,
|
|
132
|
+
PL_CONNECTIVITY: SOURCE,
|
|
133
|
+
PL_REF: SOURCE,
|
|
134
|
+
PL_REPEAT: WIRE,
|
|
135
|
+
PL_TARGET: SOURCE,
|
|
136
|
+
PL_TYPING: SOURCE,
|
|
137
|
+
PL_USE: SOURCE,
|
|
138
|
+
PL_VARIABLE_SCOPE: SOURCE,
|
|
139
|
+
});
|
|
140
|
+
const VALUE_INDICES = {
|
|
141
|
+
kind: 'unapplied',
|
|
142
|
+
because: 'Admission derives the graph, the machines and the ordering of a value program from its root schema, which it evaluates as it stands.',
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* Every rule of a value schema with how admission of a compiled Schema holds it, frozen. A rule added
|
|
146
|
+
* to the value language does not compile until it is placed here.
|
|
147
|
+
*/
|
|
148
|
+
export const READMITTED_VALUE_RULES = deepFreeze({
|
|
149
|
+
VS_DIALECT: VALUE_INDICES,
|
|
150
|
+
VS_DYNAMIC_FORBIDDEN: VALUE_INDICES,
|
|
151
|
+
VS_KEYWORD_CLOSED: VALUE_INDICES,
|
|
152
|
+
VS_META_SCHEMA: {
|
|
153
|
+
kind: 'refused',
|
|
154
|
+
answers: ['COMPILED_SOURCE_INVALID'],
|
|
155
|
+
except: 'Every other form of a keyword: its graph derives all the same.',
|
|
156
|
+
},
|
|
157
|
+
VS_NUMBER_DOMAIN: PORTABLE,
|
|
158
|
+
VS_PATH_EXTENSION: VALUE_INDICES,
|
|
159
|
+
VS_RECURSION_PRODUCTIVE: SOURCE,
|
|
160
|
+
VS_REFERENCE_FORM: SOURCE,
|
|
161
|
+
VS_REFERENCE_RESOLUTION: SOURCE,
|
|
162
|
+
VS_REGEX_PORTABLE: SOURCE,
|
|
163
|
+
VS_RESOURCE_ID: VALUE_INDICES,
|
|
164
|
+
VS_VALUE_KIND: VALUE_INDICES,
|
|
165
|
+
VS_VALUE_KIND_JSON: {
|
|
166
|
+
kind: 'unapplied',
|
|
167
|
+
because: 'It warns the author of a source, and a compiled Schema has no author to warn.',
|
|
168
|
+
},
|
|
169
|
+
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { PropertyKey as PropertyKeyValue } from '../../addressing/index.js';
|
|
2
2
|
import { compareCodeUnits } from '../../addressing/ordering.js';
|
|
3
3
|
import { createPropertyValues } from '../../language/class/property-values.js';
|
|
4
|
+
import { isBlobReceipt, isBlobValueSchema } from '../../language/value/model/blob.js';
|
|
4
5
|
const PROPERTY_OPERATIONS = new Set(['byKey', 'get', 'from']);
|
|
5
6
|
const METHOD_OPERATIONS = new Set(['byKey', 'get']);
|
|
6
7
|
export function createPropertyCollection(values) {
|
|
@@ -23,7 +24,9 @@ export function createPropertyCollection(values) {
|
|
|
23
24
|
if (entries.has(property.key)) {
|
|
24
25
|
throw new TypeError(`Property ${property.key} is supplied through both ${JSON.stringify(source.get(property.key))} and ${JSON.stringify(candidate)}.`);
|
|
25
26
|
}
|
|
26
|
-
|
|
27
|
+
// A receipt stands in for a blob's Ref until a write; only the issuing Kernel can judge it.
|
|
28
|
+
const receipt = isBlobReceipt(value) && isBlobValueSchema(property.definition.schema);
|
|
29
|
+
const diagnostics = receipt ? [] : property.validate(value);
|
|
27
30
|
if (diagnostics.length > 0) {
|
|
28
31
|
throw new TypeError(`Invalid value for Property ${property.key}: ${diagnostics.map(({ message }) => message).join('; ')}`);
|
|
29
32
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { compareUnicode } from '../../addressing/ordering.js';
|
|
2
|
+
import { PolicyComposition } from '../policy/model/policy.js';
|
|
2
3
|
/**
|
|
3
4
|
* The language ceiling of a declared admission age, in seconds. Raising it later widens the
|
|
4
5
|
* language; lowering it would refuse accepted Schemas.
|
|
@@ -37,7 +38,7 @@ function collectInputFields(expression, fields) {
|
|
|
37
38
|
}
|
|
38
39
|
return;
|
|
39
40
|
}
|
|
40
|
-
for (const child of
|
|
41
|
+
for (const child of PolicyComposition.of(expression).operands) {
|
|
41
42
|
collectInputFields(child, fields);
|
|
42
43
|
}
|
|
43
44
|
}
|
|
@@ -19,6 +19,7 @@ export interface ResolvedProperty<out Value = PortableValue, out Required extend
|
|
|
19
19
|
};
|
|
20
20
|
/** The one portable scalar ordering domain, when the Property is orderable. */
|
|
21
21
|
readonly ordering?: OrderingKind;
|
|
22
|
+
/** Check a value the Property holds, which a read returns: a `Ref` for a blob. */
|
|
22
23
|
validate(input: unknown): readonly Diagnostic[];
|
|
23
24
|
/** The admitted program `validate` evaluates. */
|
|
24
25
|
program(): ValueProgram;
|
|
@@ -33,7 +34,11 @@ export type ResolvedPropertyCollection<ByKey extends Readonly<Record<PropertyKey
|
|
|
33
34
|
readonly byKey: ByKey;
|
|
34
35
|
get<Key extends keyof ByKey>(key: Key): ByKey[Key];
|
|
35
36
|
get(key: PropertyKey): ResolvedProperty | undefined;
|
|
36
|
-
|
|
37
|
+
/**
|
|
38
|
+
* A set of values by name or key, each checked by `validate`. A blob also takes the text of an
|
|
39
|
+
* upload receipt, which a write exchanges for its Ref and only the issuing Kernel can judge.
|
|
40
|
+
*/
|
|
41
|
+
from(input: PropertyValuesInput<ByKey, ByName>): PropertyValues;
|
|
37
42
|
};
|
|
38
43
|
export interface ResolvedClass<Kind extends ClassKind = ClassKind, Properties extends ResolvedPropertyCollection = ResolvedPropertyCollection, InstanceMethods extends ResolvedMethodCollection = ResolvedMethodCollection, StaticMethods extends ResolvedMethodCollection = ResolvedMethodCollection, SelfProperties extends ResolvedPropertyCollection = ResolvedPropertyCollection, SelfInstanceMethods extends ResolvedMethodCollection = ResolvedMethodCollection, SelfStaticMethods extends ResolvedMethodCollection = ResolvedMethodCollection, Definition extends Extract<ClassDefinition, {
|
|
39
44
|
readonly kind: Kind;
|
|
@@ -113,10 +118,10 @@ export type SelfStaticMethodsOf<Class> = Class extends {
|
|
|
113
118
|
};
|
|
114
119
|
};
|
|
115
120
|
} ? Methods : ResolvedMethodCollection<Record<never, never>>;
|
|
116
|
-
type
|
|
117
|
-
[Key in keyof ByKey]?: PropertyValueOf<ByKey[Key]>;
|
|
121
|
+
type PropertyValuesInput<ByKey extends Readonly<Record<PropertyKey, ResolvedProperty<unknown>>>, ByName extends Readonly<Record<string, ResolvedProperty<unknown>>>> = Readonly<{
|
|
122
|
+
[Key in keyof ByKey]?: PropertyValueOf<ByKey[Key]> | PropertyWriteValueOf<ByKey[Key]>;
|
|
118
123
|
} & {
|
|
119
|
-
[Name in keyof ByName]?: PropertyValueOf<ByName[Name]>;
|
|
124
|
+
[Name in keyof ByName]?: PropertyValueOf<ByName[Name]> | PropertyWriteValueOf<ByName[Name]>;
|
|
120
125
|
}>;
|
|
121
126
|
type PropertyWriteInput<ByKey extends Readonly<Record<PropertyKey, ResolvedProperty<unknown>>>, ByName extends Readonly<Record<string, ResolvedProperty<unknown>>>> = Readonly<{
|
|
122
127
|
[Key in keyof ByKey]?: PropertyWriteValueOf<ByKey[Key]>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { definitionRefIndex } from '../../../addressing/ordering.js';
|
|
2
|
-
import { policyObjectKey, policyVariableSelector } from '../model/policy.js';
|
|
2
|
+
import { PolicyComposition, policyObjectKey, policyVariableSelector } from '../model/policy.js';
|
|
3
3
|
import { BRANCH_OVERFLOW } from './budgets.js';
|
|
4
4
|
export function branchesOf(pattern, namespace) {
|
|
5
5
|
const variables = collectVariableClasses(pattern, namespace);
|
|
@@ -103,8 +103,9 @@ function branchesForNode(pattern, namespace, variables) {
|
|
|
103
103
|
requiredVariables: new Set([...branch.requiredVariables, ...direct]),
|
|
104
104
|
}));
|
|
105
105
|
}
|
|
106
|
-
const
|
|
107
|
-
|
|
106
|
+
const { operator, operands } = PolicyComposition.of(pattern);
|
|
107
|
+
const children = operands.map((child) => branchesForNode(child, namespace, variables));
|
|
108
|
+
return operator === 'allOf' ? branchProduct(children) : capBranches(children.flat());
|
|
108
109
|
}
|
|
109
110
|
function emptyBranch() {
|
|
110
111
|
return {
|
|
@@ -135,10 +136,8 @@ function collectVariableClasses(pattern, namespace) {
|
|
|
135
136
|
}
|
|
136
137
|
visit(node.exists.where);
|
|
137
138
|
}
|
|
138
|
-
else if (
|
|
139
|
-
node.
|
|
140
|
-
else if ('anyOf' in node)
|
|
141
|
-
node.anyOf.forEach(visit);
|
|
139
|
+
else if (PolicyComposition.is(node))
|
|
140
|
+
PolicyComposition.of(node).operands.forEach(visit);
|
|
142
141
|
};
|
|
143
142
|
visit(pattern);
|
|
144
143
|
return result;
|