@astrale-os/kernel-dsl 1.0.0-beta.10 → 1.0.0-beta.12
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/key.d.ts +4 -1
- package/dist/v1/addressing/key.js +21 -2
- package/dist/v1/builder/callable/authoring.d.ts +1 -1
- package/dist/v1/builder/class/authoring.d.ts +6 -256
- 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 +129 -0
- package/dist/v1/builder/class/input.js +1 -0
- package/dist/v1/builder/class/projection.d.ts +129 -0
- package/dist/v1/builder/class/projection.js +1 -0
- package/dist/v1/builder/core/authoring.d.ts +1 -1
- package/dist/v1/builder/index.d.ts +3 -1
- package/dist/v1/builder/lowering/class.d.ts +1 -1
- package/dist/v1/builder/lowering/schema/context.d.ts +2 -1
- package/dist/v1/builder/lowering/value/path.d.ts +1 -1
- package/dist/v1/builder/policy/authoring.d.ts +1 -1
- package/dist/v1/builder/schema/input.d.ts +1 -1
- package/dist/v1/builder/schema/projection/class.d.ts +2 -1
- 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/property.d.ts +1 -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/language/index.d.ts +1 -0
- package/dist/v1/language/index.js +1 -0
- package/dist/v1/language/validation/diagnostic.d.ts +1 -1
- 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/index.d.ts +1 -1
- package/dist/v1/language/value/index.js +1 -1
- package/dist/v1/language/value/ordering.d.ts +9 -0
- package/dist/v1/language/value/ordering.js +72 -9
- package/dist/v1/schema/validation/value-api.d.ts +9 -0
- package/dist/v1/schema/validation/value-api.js +23 -1
- package/dist/value/canonical.d.ts +3 -2
- package/dist/value/canonical.js +30 -6
- 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 +1 -1
- package/dist/value/json.js +1 -1
- 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 +1 -1
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { jsonEqual } from '../evaluate/assertions.js';
|
|
2
|
+
import { isValueObject as isJsonObject } from '../model/object.js';
|
|
3
|
+
import { ANY, OBJECT, STRING, finiteKinds, kindOf, typeMask } from './kinds.js';
|
|
4
|
+
import { conjunctsOf, schemaOf } from './location.js';
|
|
5
|
+
/** Whether `evidence` may admit a value of one of `kinds`. */
|
|
6
|
+
export function has(evidence, kinds) {
|
|
7
|
+
return (evidence.kinds & kinds) !== 0;
|
|
8
|
+
}
|
|
9
|
+
/** The evidence the conjuncts of `location` carry together. */
|
|
10
|
+
export function evidenceOf(location) {
|
|
11
|
+
const conjuncts = conjunctsOf(location);
|
|
12
|
+
let kinds = ANY;
|
|
13
|
+
let values;
|
|
14
|
+
let upper;
|
|
15
|
+
let lower;
|
|
16
|
+
const multipleOf = [];
|
|
17
|
+
let maxLength;
|
|
18
|
+
let minLength = 0;
|
|
19
|
+
const patterns = new Set();
|
|
20
|
+
const fullMatches = new Set();
|
|
21
|
+
let maxItems;
|
|
22
|
+
let minItems = 0;
|
|
23
|
+
let uniqueItems = false;
|
|
24
|
+
let maxProperties;
|
|
25
|
+
let minProperties = 0;
|
|
26
|
+
const required = new Set();
|
|
27
|
+
const dependentRequired = new Map();
|
|
28
|
+
const valueKinds = new Set();
|
|
29
|
+
const narrow = (candidates) => {
|
|
30
|
+
values =
|
|
31
|
+
values === undefined
|
|
32
|
+
? [...candidates]
|
|
33
|
+
: values.filter((value) => candidates.some((candidate) => jsonEqual(value, candidate)));
|
|
34
|
+
};
|
|
35
|
+
for (const conjunct of conjuncts) {
|
|
36
|
+
const schema = schemaOf(conjunct);
|
|
37
|
+
if (schema === false)
|
|
38
|
+
kinds = 0;
|
|
39
|
+
if (!isJsonObject(schema))
|
|
40
|
+
continue;
|
|
41
|
+
kinds &= typeMask(schema.type);
|
|
42
|
+
if (Object.hasOwn(schema, 'const')) {
|
|
43
|
+
narrow([schema.const]);
|
|
44
|
+
kinds &= kindOf(schema.const);
|
|
45
|
+
}
|
|
46
|
+
if (Array.isArray(schema.enum)) {
|
|
47
|
+
narrow(schema.enum);
|
|
48
|
+
kinds &= schema.enum.reduce((mask, value) => mask | kindOf(value), 0);
|
|
49
|
+
}
|
|
50
|
+
const valueKind = schema['x-astrale-value-kind'];
|
|
51
|
+
if (typeof valueKind === 'string') {
|
|
52
|
+
valueKinds.add(valueKind);
|
|
53
|
+
if (valueKind === 'instant')
|
|
54
|
+
kinds &= STRING;
|
|
55
|
+
if (valueKind === 'blob')
|
|
56
|
+
kinds &= OBJECT;
|
|
57
|
+
}
|
|
58
|
+
upper = tighter(upper, schema.maximum, false, (a, b) => a < b);
|
|
59
|
+
upper = tighter(upper, schema.exclusiveMaximum, true, (a, b) => a < b);
|
|
60
|
+
lower = tighter(lower, schema.minimum, false, (a, b) => a > b);
|
|
61
|
+
lower = tighter(lower, schema.exclusiveMinimum, true, (a, b) => a > b);
|
|
62
|
+
if (typeof schema.multipleOf === 'number')
|
|
63
|
+
multipleOf.push(schema.multipleOf);
|
|
64
|
+
if (typeof schema.maxLength === 'number')
|
|
65
|
+
maxLength = min(maxLength, schema.maxLength);
|
|
66
|
+
if (typeof schema.minLength === 'number')
|
|
67
|
+
minLength = Math.max(minLength, schema.minLength);
|
|
68
|
+
if (typeof schema.pattern === 'string')
|
|
69
|
+
patterns.add(schema.pattern);
|
|
70
|
+
if (typeof schema.fullMatch === 'string')
|
|
71
|
+
fullMatches.add(schema.fullMatch);
|
|
72
|
+
if (typeof schema.maxItems === 'number')
|
|
73
|
+
maxItems = min(maxItems, schema.maxItems);
|
|
74
|
+
if (typeof schema.minItems === 'number')
|
|
75
|
+
minItems = Math.max(minItems, schema.minItems);
|
|
76
|
+
if (schema.uniqueItems === true)
|
|
77
|
+
uniqueItems = true;
|
|
78
|
+
if (typeof schema.maxProperties === 'number') {
|
|
79
|
+
maxProperties = min(maxProperties, schema.maxProperties);
|
|
80
|
+
}
|
|
81
|
+
if (typeof schema.minProperties === 'number') {
|
|
82
|
+
minProperties = Math.max(minProperties, schema.minProperties);
|
|
83
|
+
}
|
|
84
|
+
if (Array.isArray(schema.required)) {
|
|
85
|
+
for (const name of schema.required)
|
|
86
|
+
if (typeof name === 'string')
|
|
87
|
+
required.add(name);
|
|
88
|
+
}
|
|
89
|
+
if (isJsonObject(schema.dependentRequired)) {
|
|
90
|
+
for (const [name, dependencies] of Object.entries(schema.dependentRequired)) {
|
|
91
|
+
if (!Array.isArray(dependencies))
|
|
92
|
+
continue;
|
|
93
|
+
const known = dependentRequired.get(name) ?? new Set();
|
|
94
|
+
for (const dependency of dependencies) {
|
|
95
|
+
if (typeof dependency === 'string')
|
|
96
|
+
known.add(dependency);
|
|
97
|
+
}
|
|
98
|
+
dependentRequired.set(name, known);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
const finite = values === undefined
|
|
103
|
+
? finiteKinds(kinds)
|
|
104
|
+
: values.filter((value) => (kindOf(value) & kinds) !== 0);
|
|
105
|
+
return Object.freeze({
|
|
106
|
+
conjuncts,
|
|
107
|
+
kinds,
|
|
108
|
+
...(finite === undefined ? {} : { values: finite }),
|
|
109
|
+
...(upper === undefined ? {} : { upper }),
|
|
110
|
+
...(lower === undefined ? {} : { lower }),
|
|
111
|
+
multipleOf,
|
|
112
|
+
...(maxLength === undefined ? {} : { maxLength }),
|
|
113
|
+
minLength,
|
|
114
|
+
patterns,
|
|
115
|
+
fullMatches,
|
|
116
|
+
...(maxItems === undefined ? {} : { maxItems }),
|
|
117
|
+
minItems,
|
|
118
|
+
uniqueItems,
|
|
119
|
+
...(maxProperties === undefined ? {} : { maxProperties }),
|
|
120
|
+
minProperties,
|
|
121
|
+
required,
|
|
122
|
+
dependentRequired,
|
|
123
|
+
valueKinds,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
function tighter(current, value, exclusive, stricter) {
|
|
127
|
+
if (typeof value !== 'number')
|
|
128
|
+
return current;
|
|
129
|
+
if (current === undefined ||
|
|
130
|
+
stricter(value, current.value) ||
|
|
131
|
+
(value === current.value && exclusive)) {
|
|
132
|
+
return { value, exclusive };
|
|
133
|
+
}
|
|
134
|
+
return current;
|
|
135
|
+
}
|
|
136
|
+
function min(current, value) {
|
|
137
|
+
return current === undefined ? value : Math.min(current, value);
|
|
138
|
+
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { ValueProgram } from '../compile/model.js';
|
|
2
|
+
import type { Evidence } from './evidence.js';
|
|
3
|
+
import type { At } from './location.js';
|
|
2
4
|
/**
|
|
3
5
|
* Whether `outer` admits every value `inner` admits, under the one V1 evaluator.
|
|
4
6
|
*
|
|
@@ -7,3 +9,18 @@ import type { ValueProgram } from '../compile/model.js';
|
|
|
7
9
|
* `inner`; a finite `inner` is decided exactly by evaluating its candidates.
|
|
8
10
|
*/
|
|
9
11
|
export declare function valueProgramIncludes(outer: ValueProgram, inner: ValueProgram): boolean;
|
|
12
|
+
/** One inclusion question: the decided pairs, the pairs being decided and the evidence cache. */
|
|
13
|
+
export declare class Inclusion {
|
|
14
|
+
private readonly programs;
|
|
15
|
+
private readonly decided;
|
|
16
|
+
private readonly pending;
|
|
17
|
+
private readonly evidenceByAt;
|
|
18
|
+
/** Whether `outer` admits every value `inner` admits; a cyclic premise proves nothing. */
|
|
19
|
+
includes(outer: At, inner: At): boolean;
|
|
20
|
+
/** The evidence of one location, computed once per question. */
|
|
21
|
+
evidence(location: At): Evidence;
|
|
22
|
+
/** A key identifying an ordered pair of locations within this question. */
|
|
23
|
+
pair(outer: At, inner: At): string;
|
|
24
|
+
private decide;
|
|
25
|
+
private location;
|
|
26
|
+
}
|