@astrale-os/kernel-dsl 1.0.0-beta.24 → 1.0.0-beta.26
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/builder/class/authoring.js +0 -3
- package/dist/v1/builder/lowering/policy.js +4 -24
- package/dist/v1/builder/lowering/schema/context.js +0 -3
- package/dist/v1/builder/lowering/value/compile.js +24 -21
- package/dist/v1/builder/lowering/value/zod.js +10 -4
- package/dist/v1/builder/schema/diagnostic.d.ts +1 -1
- package/dist/v1/bundle/codec.js +50 -67
- package/dist/v1/bundle/diagnostic.d.ts +1 -1
- package/dist/v1/bundle/structure.js +2 -2
- package/dist/v1/compiled/admission/accept.js +6 -6
- package/dist/v1/compiled/admission/closure.js +16 -33
- package/dist/v1/compiled/admission/diagnostic.d.ts +8 -0
- package/dist/v1/compiled/admission/diagnostic.js +33 -0
- package/dist/v1/compiled/admission/semantics/class.js +11 -7
- package/dist/v1/compiled/admission/semantics/policy/admit.js +4 -19
- package/dist/v1/compiled/admission/wire/callable.d.ts +5 -2
- package/dist/v1/compiled/admission/wire/callable.js +13 -19
- package/dist/v1/compiled/admission/wire/class.js +6 -9
- package/dist/v1/compiled/admission/wire/entry.d.ts +1 -1
- package/dist/v1/compiled/admission/wire/entry.js +8 -13
- package/dist/v1/compiled/admission/wire/policy.js +4 -3
- package/dist/v1/compiled/admission/wire/program.d.ts +13 -3
- package/dist/v1/compiled/admission/wire/program.js +39 -44
- package/dist/v1/compiled/admission/wire/property.d.ts +4 -1
- package/dist/v1/compiled/admission/wire/property.js +8 -5
- package/dist/v1/compiled/admission/wire/value.d.ts +0 -2
- package/dist/v1/compiled/admission/wire/value.js +0 -7
- package/dist/v1/compiled/codec/json.js +4 -3
- package/dist/v1/compiled/compiler/compile.js +10 -29
- package/dist/v1/compiled/diagnostic.d.ts +1 -1
- package/dist/v1/compiled/loader/load.js +2 -7
- package/dist/v1/domain/model/input.d.ts +2 -2
- package/dist/v1/domain/validation/create.d.ts +3 -1
- package/dist/v1/domain/validation/create.js +13 -8
- package/dist/v1/language/callable/resolved.d.ts +3 -3
- package/dist/v1/language/chain.d.ts +7 -0
- package/dist/v1/language/chain.js +24 -0
- package/dist/v1/language/class/inheritance.js +0 -2
- package/dist/v1/language/cycle.d.ts +10 -0
- package/dist/v1/language/cycle.js +30 -0
- package/dist/v1/language/limits.d.ts +19 -0
- package/dist/v1/language/limits.js +17 -0
- package/dist/v1/language/policy/analysis/budgets.js +17 -13
- package/dist/v1/language/policy/analysis/composition.d.ts +4 -0
- package/dist/v1/language/policy/analysis/composition.js +11 -0
- package/dist/v1/language/suspended.d.ts +7 -0
- package/dist/v1/language/suspended.js +23 -0
- package/dist/v1/language/value/compile/fields.js +12 -8
- package/dist/v1/language/value/compile/load.d.ts +5 -0
- package/dist/v1/language/value/compile/load.js +13 -0
- package/dist/v1/language/value/evaluate/assertions.d.ts +5 -1
- package/dist/v1/language/value/evaluate/assertions.js +49 -8
- package/dist/v1/language/value/evaluate/evaluator.js +107 -105
- package/dist/v1/language/value/evaluate/preparation.d.ts +16 -0
- package/dist/v1/language/value/evaluate/preparation.js +100 -47
- package/dist/v1/language/value/evaluate/program.d.ts +2 -2
- package/dist/v1/language/value/evaluate/program.js +5 -5
- package/dist/v1/language/value/evaluate/validate.d.ts +3 -3
- package/dist/v1/language/value/evaluate/validate.js +9 -9
- package/dist/v1/language/value/evaluate/validity.optimization.js +4 -3
- package/dist/v1/language/value/inclusion/assertions.js +7 -8
- package/dist/v1/language/value/inclusion/equivalence.js +4 -2
- package/dist/v1/language/value/inclusion/evidence.js +2 -2
- package/dist/v1/language/value/inclusion/includes.d.ts +13 -4
- package/dist/v1/language/value/inclusion/includes.js +34 -5
- package/dist/v1/language/value/inclusion/location.js +10 -7
- package/dist/v1/language/value/ordering.js +62 -70
- package/dist/v1/language/value/profile/canonicalize.d.ts +6 -1
- package/dist/v1/language/value/profile/canonicalize.js +64 -83
- package/dist/v1/language/value/profile/json.validate.d.ts +13 -3
- package/dist/v1/language/value/profile/json.validate.js +18 -6
- package/dist/v1/language/value/reference/closure.js +3 -2
- package/dist/v1/language/value/reference/recursion.js +7 -26
- package/dist/v1/language/value/reference/references.d.ts +3 -1
- package/dist/v1/language/value/reference/references.js +7 -7
- package/dist/v1/language/value/syntax/walk.d.ts +5 -0
- package/dist/v1/language/value/syntax/walk.js +14 -0
- package/dist/v1/schema/.spec/schemas/domain-schema.schema.json +1 -1
- package/dist/v1/schema/admission/accept.d.ts +3 -1
- package/dist/v1/schema/admission/accept.js +4 -1
- package/dist/v1/schema/analysis/class.d.ts +4 -0
- package/dist/v1/schema/analysis/class.js +24 -2
- package/dist/v1/schema/canonical/revision.d.ts +4 -1
- package/dist/v1/schema/canonical/revision.js +4 -1
- package/dist/v1/schema/compatibility/comparators/classes.js +22 -22
- package/dist/v1/schema/compatibility/context.d.ts +5 -2
- package/dist/v1/schema/compatibility/context.js +8 -6
- package/dist/v1/schema/compatibility/meaning/footprint.js +1 -2
- package/dist/v1/schema/compatibility/model.d.ts +1 -1
- package/dist/v1/schema/compatibility/references.d.ts +0 -3
- package/dist/v1/schema/compatibility/references.js +1 -9
- package/dist/v1/schema/compatibility/structure/requirements.js +4 -6
- package/dist/v1/schema/compatibility/walk.js +2 -2
- package/dist/v1/schema/diagnostic.d.ts +1 -1
- package/dist/v1/schema/normalization/domain.js +8 -4
- package/dist/v1/schema/resolution/context.js +6 -7
- package/dist/v1/schema/resolution/domain.js +3 -11
- package/dist/v1/schema/rule.js +10 -3
- package/dist/v1/schema/validation/class.js +1 -1
- package/dist/v1/schema/validation/core.js +16 -8
- package/dist/v1/schema/validation/domain.js +20 -3
- package/dist/v1/schema/validation/policy/budgets.d.ts +5 -1
- package/dist/v1/schema/validation/policy/budgets.js +8 -1
- package/dist/v1/schema/validation/policy/references.js +5 -25
- package/dist/value/accept.d.ts +3 -3
- package/dist/value/canonical.js +2 -2
- package/dist/value/equal.d.ts +9 -1
- package/dist/value/equal.js +37 -3
- package/dist/value/index.d.ts +1 -1
- package/dist/value/limits.d.ts +11 -0
- package/package.json +1 -1
- package/dist/v1/compiled/admission/wire/pattern.d.ts +0 -12
- package/dist/v1/compiled/admission/wire/pattern.js +0 -111
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { equalDefinitionRefs } from '../../../addressing/definition-ref.js';
|
|
2
2
|
import { branchesOf, isConnected, targetMode } from '../../../language/policy/analysis/branches.js';
|
|
3
|
+
import { compositionCycles } from '../../../language/policy/analysis/composition.js';
|
|
3
4
|
import { policyVariableClass } from '../../../language/policy/model/policy.js';
|
|
4
5
|
import { normalizePolicyExpression, normalizePolicyPattern, } from '../../../language/policy/normalization/normalize.js';
|
|
5
6
|
import { escapePointerToken } from '../../../language/value/syntax/pointer.js';
|
|
@@ -103,31 +104,10 @@ function validateComposition(context, declaration, pointer) {
|
|
|
103
104
|
refs.forEach((ref, index) => context.resolvePolicy(ref, `${pointer}/${key}/${index}`));
|
|
104
105
|
}
|
|
105
106
|
function validateCycles(context) {
|
|
106
|
-
const
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
context.add('PL_COMPOSITION', `/policies/${escapePointerToken(name)}`, `Named Policy composition cycle: ${[...stack, name].join(' -> ')}.`);
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
if (visited.has(name))
|
|
114
|
-
return;
|
|
115
|
-
visiting.add(name);
|
|
116
|
-
const declaration = context.environment.candidate.policies[name];
|
|
117
|
-
const expression = declaration?.expression;
|
|
118
|
-
if (expression !== undefined && !('match' in expression)) {
|
|
119
|
-
const refs = 'allOf' in expression ? expression.allOf : expression.anyOf;
|
|
120
|
-
for (const ref of refs) {
|
|
121
|
-
if (ref.origin === context.environment.candidate.origin && ref.kind === 'policy') {
|
|
122
|
-
visit(ref.name, [...stack, name]);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
visiting.delete(name);
|
|
127
|
-
visited.add(name);
|
|
128
|
-
};
|
|
129
|
-
for (const name of Object.keys(context.environment.candidate.policies))
|
|
130
|
-
visit(name, []);
|
|
107
|
+
const { candidate } = context.environment;
|
|
108
|
+
for (const { path, target } of compositionCycles(Object.keys(candidate.policies), (name) => candidate.policies[name]?.expression, candidate.origin)) {
|
|
109
|
+
context.add('PL_COMPOSITION', `/policies/${escapePointerToken(target)}`, `Named Policy composition cycle: ${[...path, target].join(' -> ')}.`);
|
|
110
|
+
}
|
|
131
111
|
}
|
|
132
112
|
function patternOperands(value) {
|
|
133
113
|
return 'allOf' in value
|
package/dist/value/accept.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type { Value } from './types.js';
|
|
2
|
-
import { type Options } from './limits.js';
|
|
2
|
+
import { type Options, type StructuralOptions } from './limits.js';
|
|
3
3
|
/**
|
|
4
4
|
* Admit an unknown host value and return a detached portable snapshot.
|
|
5
5
|
*
|
|
6
6
|
* Every source property is obtained from one descriptor snapshot. Accessors are never invoked.
|
|
7
7
|
*/
|
|
8
|
-
export declare function accept(input: unknown, options?:
|
|
8
|
+
export declare function accept(input: unknown, options?: StructuralOptions): Value;
|
|
9
9
|
/** Admit a canonically byte-bounded immutable snapshot; owned subtrees may be shared. */
|
|
10
10
|
export declare function acceptImmutable(input: unknown, options?: Options): Value;
|
|
11
11
|
/** Admit a read-only snapshot, sharing owned immutable subtrees without freezing new wrappers. */
|
|
12
|
-
export declare function acceptForRead(input: unknown, options?:
|
|
12
|
+
export declare function acceptForRead(input: unknown, options?: StructuralOptions): Value;
|
|
13
13
|
/**
|
|
14
14
|
* Private PropertyValues owner seam. Retain immediate recursive values, not the enclosing
|
|
15
15
|
* dictionary: its canonical coordinates are re-admitted by the Property owner on every use.
|
package/dist/value/canonical.js
CHANGED
|
@@ -6,8 +6,8 @@ import { canonicalPrimitiveBytes, utf8Length } from './unicode.js';
|
|
|
6
6
|
const encoder = new TextEncoder();
|
|
7
7
|
/** RFC 8785 canonical JSON for one admitted portable snapshot. */
|
|
8
8
|
export function serialize(input, options) {
|
|
9
|
-
const
|
|
10
|
-
return serializeSnapshot(acceptForRead(input,
|
|
9
|
+
const { maxBytes, ...structure } = limitsFor(options);
|
|
10
|
+
return serializeSnapshot(acceptForRead(input, { limits: structure }), maxBytes);
|
|
11
11
|
}
|
|
12
12
|
/** Serialize a trusted portable value whose default structural admission proof is still valid. */
|
|
13
13
|
export function serializeAdmitted(input) {
|
package/dist/value/equal.d.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
import type { Value } from './types.js';
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Whether two admitted Values are the same JSON value: the same scalar, Arrays item by item, Objects
|
|
4
|
+
* with the same names whose values are the same, in any member order. This is exactly when their
|
|
5
|
+
* canonical JSON texts are equal (`proofs/Canonical.lean`).
|
|
6
|
+
*
|
|
7
|
+
* It reads what admission let through and answers for all of it: it admits nothing, so no limit of
|
|
8
|
+
* its own can refuse a value other limits admitted, and it holds neither a text nor a stack frame
|
|
9
|
+
* per level.
|
|
10
|
+
*/
|
|
3
11
|
export declare function equal(left: Value, right: Value): boolean;
|
package/dist/value/equal.js
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Whether two admitted Values are the same JSON value: the same scalar, Arrays item by item, Objects
|
|
3
|
+
* with the same names whose values are the same, in any member order. This is exactly when their
|
|
4
|
+
* canonical JSON texts are equal (`proofs/Canonical.lean`).
|
|
5
|
+
*
|
|
6
|
+
* It reads what admission let through and answers for all of it: it admits nothing, so no limit of
|
|
7
|
+
* its own can refuse a value other limits admitted, and it holds neither a text nor a stack frame
|
|
8
|
+
* per level.
|
|
9
|
+
*/
|
|
3
10
|
export function equal(left, right) {
|
|
4
|
-
|
|
11
|
+
const pending = [left, right];
|
|
12
|
+
while (pending.length > 0) {
|
|
13
|
+
const second = pending.pop();
|
|
14
|
+
const first = pending.pop();
|
|
15
|
+
if (first === second)
|
|
16
|
+
continue;
|
|
17
|
+
if (first === null || second === null)
|
|
18
|
+
return false;
|
|
19
|
+
if (typeof first !== 'object' || typeof second !== 'object')
|
|
20
|
+
return false;
|
|
21
|
+
if (Array.isArray(first) !== Array.isArray(second))
|
|
22
|
+
return false;
|
|
23
|
+
if (Array.isArray(first)) {
|
|
24
|
+
if (first.length !== second.length)
|
|
25
|
+
return false;
|
|
26
|
+
first.forEach((item, index) => pending.push(item, second[index]));
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
const names = Object.keys(first);
|
|
30
|
+
if (names.length !== Object.keys(second).length)
|
|
31
|
+
return false;
|
|
32
|
+
for (const name of names) {
|
|
33
|
+
if (!Object.hasOwn(second, name))
|
|
34
|
+
return false;
|
|
35
|
+
pending.push(first[name], second[name]);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return true;
|
|
5
39
|
}
|
package/dist/value/index.d.ts
CHANGED
|
@@ -4,6 +4,6 @@ export { equal } from './equal.js';
|
|
|
4
4
|
export { BoundaryError, DecodeError } from './error.js';
|
|
5
5
|
export type { BoundaryErrorCode, DecodeErrorCode } from './error.js';
|
|
6
6
|
export { defaultLimits } from './limits.js';
|
|
7
|
-
export type { LimitOverrides, Limits, Options } from './limits.js';
|
|
7
|
+
export type { LimitOverrides, Limits, Options, StructuralLimitOverrides, StructuralOptions, } from './limits.js';
|
|
8
8
|
export * as json from './json.js';
|
|
9
9
|
export type { Array, Object, Primitive, Value, ValueKind } from './types.js';
|
package/dist/value/limits.d.ts
CHANGED
|
@@ -17,5 +17,16 @@ export interface LimitOverrides {
|
|
|
17
17
|
export interface Options {
|
|
18
18
|
readonly limits?: LimitOverrides;
|
|
19
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* The limits of a capture that never measures canonical bytes. Holding a value to `maxBytes` takes
|
|
22
|
+
* `acceptImmutable`, or a JSON route, which measure them. `never` rather than absent, so that a shared
|
|
23
|
+
* constant naming bytes is refused as a literal is.
|
|
24
|
+
*/
|
|
25
|
+
export interface StructuralLimitOverrides extends Omit<LimitOverrides, 'maxBytes'> {
|
|
26
|
+
readonly maxBytes?: never;
|
|
27
|
+
}
|
|
28
|
+
export interface StructuralOptions {
|
|
29
|
+
readonly limits?: StructuralLimitOverrides;
|
|
30
|
+
}
|
|
20
31
|
export declare const defaultLimits: Readonly<Limits>;
|
|
21
32
|
export declare function limitsFor(options: Options | undefined): Limits;
|
package/package.json
CHANGED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { type Value as JsonValue } from '@astrale-os/kernel-dsl/value';
|
|
2
|
-
import { type Pattern, type RunPattern } from '../../model/schema.js';
|
|
3
|
-
/** The machine compiled from each admitted I-Regexp source, shared by its occurrences. */
|
|
4
|
-
export type Machines = Map<string, Pattern | RunPattern>;
|
|
5
|
-
/**
|
|
6
|
-
* Admit one received pattern as data and return the machine compiled from its source. A received
|
|
7
|
-
* machine never decides membership: it may come from another compiler, from a host with other
|
|
8
|
-
* Unicode data, or from a forger, and the artifact carries no compiler version that could tell a
|
|
9
|
-
* current machine from those, so it is ignored rather than compared. Its source decides, through
|
|
10
|
-
* the same bounded `isIRegexp` and `compilePattern` that source resolution uses.
|
|
11
|
-
*/
|
|
12
|
-
export declare function pattern(input: JsonValue, patternIndex: number, path: string, machines: Machines): Pattern | RunPattern;
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import {} from '@astrale-os/kernel-dsl/value';
|
|
2
|
-
import { compilePattern } from '../../../language/value/regexp/compile.js';
|
|
3
|
-
import { isIRegexp } from '../../../language/value/regexp/syntax.js';
|
|
4
|
-
import {} from '../../model/schema.js';
|
|
5
|
-
import { invalid } from '../diagnostic.js';
|
|
6
|
-
import { object, exact, array, integer, scalar, index, boundedInteger } from './value.js';
|
|
7
|
-
/**
|
|
8
|
-
* Admit one received pattern as data and return the machine compiled from its source. A received
|
|
9
|
-
* machine never decides membership: it may come from another compiler, from a host with other
|
|
10
|
-
* Unicode data, or from a forger, and the artifact carries no compiler version that could tell a
|
|
11
|
-
* current machine from those, so it is ignored rather than compared. Its source decides, through
|
|
12
|
-
* the same bounded `isIRegexp` and `compilePattern` that source resolution uses.
|
|
13
|
-
*/
|
|
14
|
-
export function pattern(input, patternIndex, path, machines) {
|
|
15
|
-
const value = object(input, `patterns[${patternIndex}]`, path);
|
|
16
|
-
const { source } = Object.hasOwn(value, 'runs')
|
|
17
|
-
? runPattern(value, path)
|
|
18
|
-
: nfaPattern(value, path);
|
|
19
|
-
let machine = machines.get(source);
|
|
20
|
-
if (machine === undefined) {
|
|
21
|
-
if (!isIRegexp(source))
|
|
22
|
-
invalid('Pattern source', 'COMPILED_SOURCE_INVALID', `${path}/source`);
|
|
23
|
-
machine = compilePattern(source);
|
|
24
|
-
machines.set(source, machine);
|
|
25
|
-
}
|
|
26
|
-
return machine;
|
|
27
|
-
}
|
|
28
|
-
function nfaPattern(value, path) {
|
|
29
|
-
exact(value, ['source', 'start', 'states'], 'Pattern', path);
|
|
30
|
-
if (typeof value.source !== 'string')
|
|
31
|
-
invalid('Pattern source', undefined, `${path}/source`);
|
|
32
|
-
const statesPath = `${path}/states`;
|
|
33
|
-
const states = array(value.states, 'Pattern states', statesPath).map((item, stateIndex) => {
|
|
34
|
-
const statePath = `${statesPath}/${stateIndex}`;
|
|
35
|
-
const state = object(item, 'Pattern state', statePath);
|
|
36
|
-
exact(state, ['epsilon', 'transitions'], 'Pattern state', statePath, ['accepting']);
|
|
37
|
-
if (state.accepting !== undefined && state.accepting !== true)
|
|
38
|
-
invalid('accepting', undefined, `${statePath}/accepting`);
|
|
39
|
-
const epsilonPath = `${statePath}/epsilon`;
|
|
40
|
-
const transitionsPath = `${statePath}/transitions`;
|
|
41
|
-
return {
|
|
42
|
-
epsilon: array(state.epsilon, 'epsilon', epsilonPath).map((target, index) => integer(target, 'epsilon', `${epsilonPath}/${index}`)),
|
|
43
|
-
transitions: array(state.transitions, 'transitions', transitionsPath).map((transitionValue, transitionIndex) => {
|
|
44
|
-
const transitionPath = `${transitionsPath}/${transitionIndex}`;
|
|
45
|
-
const transition = object(transitionValue, 'transition', transitionPath);
|
|
46
|
-
exact(transition, ['to', 'ranges'], 'transition', transitionPath);
|
|
47
|
-
const rangesPath = `${transitionPath}/ranges`;
|
|
48
|
-
return {
|
|
49
|
-
to: integer(transition.to, 'transition target', `${transitionPath}/to`),
|
|
50
|
-
ranges: array(transition.ranges, 'ranges', rangesPath).map((rangeValue, rangeIndex) => {
|
|
51
|
-
const rangePath = `${rangesPath}/${rangeIndex}`;
|
|
52
|
-
const range = array(rangeValue, 'range', rangePath);
|
|
53
|
-
if (range.length !== 2)
|
|
54
|
-
invalid('range', undefined, rangePath);
|
|
55
|
-
const minimum = scalar(range[0], 'range minimum', `${rangePath}/0`);
|
|
56
|
-
const maximum = scalar(range[1], 'range maximum', `${rangePath}/1`);
|
|
57
|
-
if (minimum > maximum)
|
|
58
|
-
invalid('range order', undefined, rangePath);
|
|
59
|
-
return [minimum, maximum];
|
|
60
|
-
}),
|
|
61
|
-
};
|
|
62
|
-
}),
|
|
63
|
-
...(state.accepting === true ? { accepting: true } : {}),
|
|
64
|
-
};
|
|
65
|
-
});
|
|
66
|
-
const start = index(value.start, states.length, 'Pattern start', `${path}/start`);
|
|
67
|
-
for (const [stateIndex, state] of states.entries()) {
|
|
68
|
-
state.epsilon.forEach((target, indexValue) => index(target, states.length, 'epsilon', `${statesPath}/${stateIndex}/epsilon/${indexValue}`));
|
|
69
|
-
state.transitions.forEach(({ to }, transitionIndex) => index(to, states.length, 'transition', `${statesPath}/${stateIndex}/transitions/${transitionIndex}/to`));
|
|
70
|
-
}
|
|
71
|
-
return { source: value.source, start, states };
|
|
72
|
-
}
|
|
73
|
-
function runPattern(value, path) {
|
|
74
|
-
exact(value, ['source', 'runs'], 'RunPattern', path);
|
|
75
|
-
if (typeof value.source !== 'string')
|
|
76
|
-
invalid('Pattern source', undefined, `${path}/source`);
|
|
77
|
-
const entries = array(value.runs, 'scalar runs', `${path}/runs`);
|
|
78
|
-
if (entries.length === 0 || entries.length > 4096) {
|
|
79
|
-
invalid('scalar run count', undefined, `${path}/runs`);
|
|
80
|
-
}
|
|
81
|
-
const runs = entries.map((entry, position) => {
|
|
82
|
-
const runPath = `${path}/runs/${position}`;
|
|
83
|
-
const run = object(entry, 'scalar run', runPath);
|
|
84
|
-
exact(run, ['ranges', 'minimum'], 'scalar run', runPath, ['maximum']);
|
|
85
|
-
const minimum = boundedInteger(run.minimum, 0, 1000, 'run minimum', `${runPath}/minimum`);
|
|
86
|
-
const maximum = run.maximum === undefined
|
|
87
|
-
? undefined
|
|
88
|
-
: boundedInteger(run.maximum, minimum, 1000, 'run maximum', `${runPath}/maximum`);
|
|
89
|
-
if (position !== entries.length - 1 && minimum !== maximum) {
|
|
90
|
-
invalid('exact scalar prefix', undefined, `${runPath}/maximum`);
|
|
91
|
-
}
|
|
92
|
-
let previous = -1;
|
|
93
|
-
const ranges = array(run.ranges, 'scalar ranges', `${runPath}/ranges`).map((entry, index) => {
|
|
94
|
-
const rangePath = `${runPath}/ranges/${index}`;
|
|
95
|
-
const range = array(entry, 'scalar range', rangePath);
|
|
96
|
-
if (range.length !== 2)
|
|
97
|
-
invalid('scalar range', undefined, rangePath);
|
|
98
|
-
const minimum = scalar(range[0], 'range minimum', `${rangePath}/0`);
|
|
99
|
-
const maximum = scalar(range[1], 'range maximum', `${rangePath}/1`);
|
|
100
|
-
if (minimum > maximum ||
|
|
101
|
-
minimum <= previous ||
|
|
102
|
-
(minimum >= 0xd800 && minimum <= 0xdfff) ||
|
|
103
|
-
(maximum >= 0xd800 && maximum <= 0xdfff))
|
|
104
|
-
invalid('ordered scalar range', undefined, rangePath);
|
|
105
|
-
previous = maximum;
|
|
106
|
-
return [minimum, maximum];
|
|
107
|
-
});
|
|
108
|
-
return { ranges, minimum, ...(maximum === undefined ? {} : { maximum }) };
|
|
109
|
-
});
|
|
110
|
-
return { source: value.source, runs };
|
|
111
|
-
}
|