@astrale-os/kernel-dsl 0.2.0-beta.2 → 0.2.0-beta.4
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/callable.d.ts +1 -2
- package/dist/v1/builder/callable.d.ts.map +1 -1
- package/dist/v1/builder/callable.js.map +1 -1
- package/dist/v1/builder/compiler/value.zod.js +1 -1
- package/dist/v1/builder/compiler/value.zod.js.map +1 -1
- package/dist/v1/builder/full-match.d.ts +3 -10
- package/dist/v1/builder/full-match.d.ts.map +1 -1
- package/dist/v1/builder/full-match.js +4 -13
- package/dist/v1/builder/full-match.js.map +1 -1
- package/dist/v1/schema/compiled/admission.d.ts +4 -0
- package/dist/v1/schema/compiled/admission.d.ts.map +1 -0
- package/dist/v1/schema/compiled/admission.js +217 -0
- package/dist/v1/schema/compiled/admission.js.map +1 -0
- package/dist/v1/schema/compiled/authored-validator.d.ts +5 -0
- package/dist/v1/schema/compiled/authored-validator.d.ts.map +1 -0
- package/dist/v1/schema/compiled/authored-validator.js +7 -0
- package/dist/v1/schema/compiled/authored-validator.js.map +1 -0
- package/dist/v1/schema/compiled/compiler.d.ts +5 -0
- package/dist/v1/schema/compiled/compiler.d.ts.map +1 -0
- package/dist/v1/schema/compiled/compiler.js +86 -0
- package/dist/v1/schema/compiled/compiler.js.map +1 -0
- package/dist/v1/schema/compiled/model.d.ts +61 -0
- package/dist/v1/schema/compiled/model.d.ts.map +1 -0
- package/dist/v1/schema/compiled/model.js +2 -0
- package/dist/v1/schema/compiled/model.js.map +1 -0
- package/dist/v1/schema/compiled/program.d.ts +5 -0
- package/dist/v1/schema/compiled/program.d.ts.map +1 -0
- package/dist/v1/schema/compiled/program.js +42 -0
- package/dist/v1/schema/compiled/program.js.map +1 -0
- package/dist/v1/schema/compiled/validator.d.ts +23 -0
- package/dist/v1/schema/compiled/validator.d.ts.map +1 -0
- package/dist/v1/schema/compiled/validator.js +62 -0
- package/dist/v1/schema/compiled/validator.js.map +1 -0
- package/dist/v1/schema/index.d.ts +6 -0
- package/dist/v1/schema/index.d.ts.map +1 -1
- package/dist/v1/schema/index.js +4 -0
- package/dist/v1/schema/index.js.map +1 -1
- package/dist/v1/schema/value/full-match.d.ts +7 -0
- package/dist/v1/schema/value/full-match.d.ts.map +1 -0
- package/dist/v1/schema/value/full-match.js +21 -0
- package/dist/v1/schema/value/full-match.js.map +1 -0
- package/dist/v1/schema/value/instance/evaluator.d.ts.map +1 -1
- package/dist/v1/schema/value/instance/evaluator.js +3 -14
- package/dist/v1/schema/value/instance/evaluator.js.map +1 -1
- package/dist/v1/schema/value/instance/{compiler.d.ts → preparation.d.ts} +3 -2
- package/dist/v1/schema/value/instance/preparation.d.ts.map +1 -0
- package/dist/v1/schema/value/instance/preparation.js +137 -0
- package/dist/v1/schema/value/instance/preparation.js.map +1 -0
- package/dist/v1/schema/value/instance/types.d.ts +5 -1
- package/dist/v1/schema/value/instance/types.d.ts.map +1 -1
- package/dist/v1/schema/value/instance/types.js.map +1 -1
- package/dist/v1/schema/value/instance.validate.js +2 -2
- package/dist/v1/schema/value/instance.validate.js.map +1 -1
- package/dist/v1/schema/value/ordering.js +2 -2
- package/dist/v1/schema/value/ordering.js.map +1 -1
- package/dist/v1/schema/value/profile/meta-schema.compiled.js +1 -1
- package/dist/v1/schema/value/profile/{meta-schema.validate.d.ts → meta-schema.d.ts} +2 -1
- package/dist/v1/schema/value/profile/meta-schema.d.ts.map +1 -0
- package/dist/v1/schema/value/profile/{meta-schema.validate.js → meta-schema.js} +2 -1
- package/dist/v1/schema/value/profile/meta-schema.js.map +1 -0
- package/dist/v1/schema/value/profile/validate.js +1 -1
- package/dist/v1/schema/value/profile/validate.js.map +1 -1
- package/dist/v1/schema/value/regexp/ast.d.ts +22 -0
- package/dist/v1/schema/value/regexp/ast.d.ts.map +1 -0
- package/dist/v1/schema/value/regexp/ast.js +327 -0
- package/dist/v1/schema/value/regexp/ast.js.map +1 -0
- package/dist/v1/schema/value/regexp/compile.d.ts +4 -0
- package/dist/v1/schema/value/regexp/compile.d.ts.map +1 -0
- package/dist/v1/schema/value/regexp/compile.js +97 -0
- package/dist/v1/schema/value/regexp/compile.js.map +1 -0
- package/dist/v1/schema/value/regexp/matcher.d.ts +8 -0
- package/dist/v1/schema/value/regexp/matcher.d.ts.map +1 -0
- package/dist/v1/schema/value/regexp/matcher.js +51 -0
- package/dist/v1/schema/value/regexp/matcher.js.map +1 -0
- package/dist/v1/schema/value/regexp/syntax.d.ts +1 -1
- package/dist/v1/schema/value/regexp/syntax.d.ts.map +1 -1
- package/dist/v1/schema/value/regexp/syntax.js +3 -214
- package/dist/v1/schema/value/regexp/syntax.js.map +1 -1
- package/package.json +31 -2
- package/dist/v1/schema/value/instance/compiler.d.ts.map +0 -1
- package/dist/v1/schema/value/instance/compiler.js +0 -69
- package/dist/v1/schema/value/instance/compiler.js.map +0 -1
- package/dist/v1/schema/value/profile/meta-schema.validate.d.ts.map +0 -1
- package/dist/v1/schema/value/profile/meta-schema.validate.js.map +0 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Pattern } from '../../compiled/model.js';
|
|
2
|
+
export interface IRegexpMatcher {
|
|
3
|
+
test(value: string): boolean;
|
|
4
|
+
matches(value: string): boolean;
|
|
5
|
+
}
|
|
6
|
+
/** Load portable NFA data without a regex engine or dynamic compilation. */
|
|
7
|
+
export declare function loadPattern(pattern: Pattern): IRegexpMatcher;
|
|
8
|
+
//# sourceMappingURL=matcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"matcher.d.ts","sourceRoot":"","sources":["../../../../../v1/schema/value/regexp/matcher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAgB,MAAM,yBAAyB,CAAA;AAEpE,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAA;IAC5B,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAA;CAChC;AAED,4EAA4E;AAC5E,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,cAAc,CA2B5D"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/** Load portable NFA data without a regex engine or dynamic compilation. */
|
|
2
|
+
export function loadPattern(pattern) {
|
|
3
|
+
const start = closure(pattern.states, new Set([pattern.start]));
|
|
4
|
+
const run = (input, search) => {
|
|
5
|
+
let active = new Set(start);
|
|
6
|
+
if ((search || input.length === 0) && accepts(pattern.states, active))
|
|
7
|
+
return true;
|
|
8
|
+
for (const character of input) {
|
|
9
|
+
const scalar = character.codePointAt(0);
|
|
10
|
+
const next = new Set();
|
|
11
|
+
for (const index of active) {
|
|
12
|
+
for (const transition of pattern.states[index].transitions) {
|
|
13
|
+
if (transition.ranges.some(([minimum, maximum]) => scalar >= minimum && scalar <= maximum)) {
|
|
14
|
+
next.add(transition.to);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
active = closure(pattern.states, next);
|
|
19
|
+
if (search)
|
|
20
|
+
for (const index of start)
|
|
21
|
+
active.add(index);
|
|
22
|
+
if (search && accepts(pattern.states, active))
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
return accepts(pattern.states, active);
|
|
26
|
+
};
|
|
27
|
+
return Object.freeze({
|
|
28
|
+
test: (input) => run(input, true),
|
|
29
|
+
matches: (input) => run(input, false),
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function closure(states, seed) {
|
|
33
|
+
const output = new Set(seed);
|
|
34
|
+
const pending = [...seed];
|
|
35
|
+
while (pending.length > 0) {
|
|
36
|
+
for (const next of states[pending.pop()].epsilon) {
|
|
37
|
+
if (output.has(next))
|
|
38
|
+
continue;
|
|
39
|
+
output.add(next);
|
|
40
|
+
pending.push(next);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return output;
|
|
44
|
+
}
|
|
45
|
+
function accepts(states, active) {
|
|
46
|
+
for (const index of active)
|
|
47
|
+
if (states[index]?.accepting === true)
|
|
48
|
+
return true;
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=matcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"matcher.js","sourceRoot":"","sources":["../../../../../v1/schema/value/regexp/matcher.ts"],"names":[],"mappings":"AAOA,4EAA4E;AAC5E,MAAM,UAAU,WAAW,CAAC,OAAgB;IAC1C,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IAC/D,MAAM,GAAG,GAAG,CAAC,KAAa,EAAE,MAAe,EAAW,EAAE;QACtD,IAAI,MAAM,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAA;QAC3B,IAAI,CAAC,MAAM,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC;YAAE,OAAO,IAAI,CAAA;QAClF,KAAK,MAAM,SAAS,IAAI,KAAK,EAAE,CAAC;YAC9B,MAAM,MAAM,GAAG,SAAS,CAAC,WAAW,CAAC,CAAC,CAAE,CAAA;YACxC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAA;YAC9B,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;gBAC3B,KAAK,MAAM,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC,KAAK,CAAE,CAAC,WAAW,EAAE,CAAC;oBAC5D,IACE,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,MAAM,IAAI,OAAO,IAAI,MAAM,IAAI,OAAO,CAAC,EACtF,CAAC;wBACD,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC,CAAA;oBACzB,CAAC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AM;QAAE,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,SAAS,KAAK,IAAI;YAAE,OAAO,IAAI,CAAA;IAC9E,OAAO,KAAK,CAAA;AACd,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"syntax.d.ts","sourceRoot":"","sources":["../../../../../v1/schema/value/regexp/syntax.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"syntax.d.ts","sourceRoot":"","sources":["../../../../../v1/schema/value/regexp/syntax.ts"],"names":[],"mappings":"AAEA,uFAAuF;AACvF,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEjD"}
|
|
@@ -1,217 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
const CATEGORY = /^(?:L[lmotu]?|M[cen]?|N[dlo]?|P[cdfios]?|Z[lps]?|S[ckmo]?|C[cfno]?)$/u;
|
|
4
|
-
const MAX_IREGEXP_CODE_POINTS = 4096;
|
|
5
|
-
const MAX_IREGEXP_NESTING = 32;
|
|
6
|
-
const MAX_IREGEXP_REPEAT = 1000;
|
|
7
|
-
/** A complete syntax checker for the ABNF in RFC 9485 section 3. */
|
|
1
|
+
import { parseIRegexp } from './ast.js';
|
|
2
|
+
/** Complete RFC 9485 syntax admission through the same AST consumed by compilation. */
|
|
8
3
|
export function isIRegexp(source) {
|
|
9
|
-
|
|
10
|
-
return false;
|
|
11
|
-
const characters = Array.from(source);
|
|
12
|
-
if (characters.length > MAX_IREGEXP_CODE_POINTS)
|
|
13
|
-
return false;
|
|
14
|
-
const parser = new IRegexpParser(characters);
|
|
15
|
-
if (!parser.parse())
|
|
16
|
-
return false;
|
|
17
|
-
return compilesWithLinearRegExp(lowerIRegexpPattern(source));
|
|
18
|
-
}
|
|
19
|
-
class IRegexpParser {
|
|
20
|
-
chars;
|
|
21
|
-
index = 0;
|
|
22
|
-
constructor(chars) {
|
|
23
|
-
this.chars = chars;
|
|
24
|
-
}
|
|
25
|
-
parse() {
|
|
26
|
-
return this.parseExpression(undefined, 0) && this.index === this.chars.length;
|
|
27
|
-
}
|
|
28
|
-
parseExpression(stop, depth) {
|
|
29
|
-
if (depth > MAX_IREGEXP_NESTING || !this.parseBranch(stop, depth))
|
|
30
|
-
return false;
|
|
31
|
-
while (this.peek() === '|') {
|
|
32
|
-
this.index++;
|
|
33
|
-
if (!this.parseBranch(stop, depth))
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
36
|
-
return true;
|
|
37
|
-
}
|
|
38
|
-
parseBranch(stop, depth) {
|
|
39
|
-
while (this.index < this.chars.length) {
|
|
40
|
-
const next = this.peek();
|
|
41
|
-
if (next === '|' || next === stop)
|
|
42
|
-
return true;
|
|
43
|
-
if (!this.parsePiece(depth))
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
return stop === undefined;
|
|
47
|
-
}
|
|
48
|
-
parsePiece(depth) {
|
|
49
|
-
if (!this.parseAtom(depth))
|
|
50
|
-
return false;
|
|
51
|
-
const next = this.peek();
|
|
52
|
-
if (next === '*' || next === '+' || next === '?') {
|
|
53
|
-
this.index++;
|
|
54
|
-
return true;
|
|
55
|
-
}
|
|
56
|
-
if (next === '{')
|
|
57
|
-
return this.parseRangeQuantifier();
|
|
58
|
-
return true;
|
|
59
|
-
}
|
|
60
|
-
parseAtom(depth) {
|
|
61
|
-
const next = this.peek();
|
|
62
|
-
if (next === undefined)
|
|
63
|
-
return false;
|
|
64
|
-
if (next === '(') {
|
|
65
|
-
this.index++;
|
|
66
|
-
if (!this.parseExpression(')', depth + 1) || this.peek() !== ')')
|
|
67
|
-
return false;
|
|
68
|
-
this.index++;
|
|
69
|
-
return true;
|
|
70
|
-
}
|
|
71
|
-
if (next === '.') {
|
|
72
|
-
this.index++;
|
|
73
|
-
return true;
|
|
74
|
-
}
|
|
75
|
-
if (next === '[')
|
|
76
|
-
return this.parseCharacterClass();
|
|
77
|
-
if (next === '\\')
|
|
78
|
-
return this.parseEscape(true);
|
|
79
|
-
if (!isNormalCharacter(next))
|
|
80
|
-
return false;
|
|
81
|
-
this.index++;
|
|
82
|
-
return true;
|
|
83
|
-
}
|
|
84
|
-
parseRangeQuantifier() {
|
|
85
|
-
this.index++;
|
|
86
|
-
const minimum = this.consumeInteger();
|
|
87
|
-
if (minimum === undefined || minimum > MAX_IREGEXP_REPEAT)
|
|
88
|
-
return false;
|
|
89
|
-
let maximum = minimum;
|
|
90
|
-
if (this.peek() === ',') {
|
|
91
|
-
this.index++;
|
|
92
|
-
maximum = this.consumeInteger() ?? MAX_IREGEXP_REPEAT;
|
|
93
|
-
}
|
|
94
|
-
if (maximum > MAX_IREGEXP_REPEAT || maximum < minimum || this.peek() !== '}') {
|
|
95
|
-
return false;
|
|
96
|
-
}
|
|
97
|
-
this.index++;
|
|
98
|
-
return true;
|
|
99
|
-
}
|
|
100
|
-
parseCharacterClass() {
|
|
101
|
-
const start = this.index;
|
|
102
|
-
this.index++;
|
|
103
|
-
if (this.peek() === '^')
|
|
104
|
-
this.index++;
|
|
105
|
-
if (this.peek() === undefined || this.peek() === ']')
|
|
106
|
-
return false;
|
|
107
|
-
if (this.peek() === '-')
|
|
108
|
-
this.index++;
|
|
109
|
-
else if (!this.parseCharacterClassEntry())
|
|
110
|
-
return false;
|
|
111
|
-
while (this.peek() !== ']') {
|
|
112
|
-
if (this.peek() === undefined)
|
|
113
|
-
return false;
|
|
114
|
-
if (this.peek() === '-' && this.peek(1) === ']') {
|
|
115
|
-
this.index++;
|
|
116
|
-
break;
|
|
117
|
-
}
|
|
118
|
-
if (!this.parseCharacterClassEntry())
|
|
119
|
-
return false;
|
|
120
|
-
}
|
|
121
|
-
if (this.peek() !== ']')
|
|
122
|
-
return false;
|
|
123
|
-
this.index++;
|
|
124
|
-
return this.chars.slice(start, this.index).join('') !== '[^]';
|
|
125
|
-
}
|
|
126
|
-
parseCharacterClassEntry() {
|
|
127
|
-
if (this.peek() === '\\' && (this.peek(1) === 'p' || this.peek(1) === 'P')) {
|
|
128
|
-
return this.parseCategoryEscape();
|
|
129
|
-
}
|
|
130
|
-
if (!this.parseClassCharacter())
|
|
131
|
-
return false;
|
|
132
|
-
if (this.peek() === '-' && this.peek(1) !== ']') {
|
|
133
|
-
this.index++;
|
|
134
|
-
if (!this.parseClassCharacter())
|
|
135
|
-
return false;
|
|
136
|
-
}
|
|
137
|
-
return true;
|
|
138
|
-
}
|
|
139
|
-
parseClassCharacter() {
|
|
140
|
-
const next = this.peek();
|
|
141
|
-
if (next === '\\')
|
|
142
|
-
return this.parseEscape(false);
|
|
143
|
-
if (next === undefined || next === '-' || next === '[' || next === ']' || next === '\\') {
|
|
144
|
-
return false;
|
|
145
|
-
}
|
|
146
|
-
this.index++;
|
|
147
|
-
return true;
|
|
148
|
-
}
|
|
149
|
-
parseEscape(allowCategory) {
|
|
150
|
-
if (allowCategory && (this.peek(1) === 'p' || this.peek(1) === 'P')) {
|
|
151
|
-
return this.parseCategoryEscape();
|
|
152
|
-
}
|
|
153
|
-
if (this.peek() !== '\\')
|
|
154
|
-
return false;
|
|
155
|
-
const escaped = this.peek(1);
|
|
156
|
-
if (escaped === undefined || !'()*+-.?[\\]^nrt{}'.includes(escaped))
|
|
157
|
-
return false;
|
|
158
|
-
this.index += 2;
|
|
159
|
-
return true;
|
|
160
|
-
}
|
|
161
|
-
parseCategoryEscape() {
|
|
162
|
-
if (this.peek() !== '\\' ||
|
|
163
|
-
(this.peek(1) !== 'p' && this.peek(1) !== 'P') ||
|
|
164
|
-
this.peek(2) !== '{') {
|
|
165
|
-
return false;
|
|
166
|
-
}
|
|
167
|
-
this.index += 3;
|
|
168
|
-
let category = '';
|
|
169
|
-
while (this.peek() !== '}' && this.peek() !== undefined) {
|
|
170
|
-
category += this.peek();
|
|
171
|
-
this.index++;
|
|
172
|
-
}
|
|
173
|
-
if (this.peek() !== '}' || !CATEGORY.test(category))
|
|
174
|
-
return false;
|
|
175
|
-
this.index++;
|
|
176
|
-
return true;
|
|
177
|
-
}
|
|
178
|
-
consumeInteger() {
|
|
179
|
-
const start = this.index;
|
|
180
|
-
while (/^[0-9]$/u.test(this.peek() ?? ''))
|
|
181
|
-
this.index++;
|
|
182
|
-
if (this.index === start)
|
|
183
|
-
return undefined;
|
|
184
|
-
const value = Number(this.chars.slice(start, this.index).join(''));
|
|
185
|
-
return Number.isSafeInteger(value) ? value : undefined;
|
|
186
|
-
}
|
|
187
|
-
peek(offset = 0) {
|
|
188
|
-
return this.chars[this.index + offset];
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
function isNormalCharacter(value) {
|
|
192
|
-
const code = value.codePointAt(0);
|
|
193
|
-
if (code === undefined)
|
|
194
|
-
return false;
|
|
195
|
-
return ((code >= 0x00 && code <= 0x27) ||
|
|
196
|
-
code === 0x2c ||
|
|
197
|
-
code === 0x2d ||
|
|
198
|
-
(code >= 0x2f && code <= 0x3e) ||
|
|
199
|
-
(code >= 0x40 && code <= 0x5a) ||
|
|
200
|
-
(code >= 0x5e && code <= 0x7a) ||
|
|
201
|
-
(code >= 0x7e && code <= 0xd7ff) ||
|
|
202
|
-
(code >= 0xe000 && code <= 0x10ffff));
|
|
203
|
-
}
|
|
204
|
-
function isUnicodeScalarString(value) {
|
|
205
|
-
for (let index = 0; index < value.length; index++) {
|
|
206
|
-
const unit = value.charCodeAt(index);
|
|
207
|
-
if (unit < 0xd800 || unit > 0xdfff)
|
|
208
|
-
continue;
|
|
209
|
-
if (unit > 0xdbff || index + 1 >= value.length)
|
|
210
|
-
return false;
|
|
211
|
-
const next = value.charCodeAt(++index);
|
|
212
|
-
if (next < 0xdc00 || next > 0xdfff)
|
|
213
|
-
return false;
|
|
214
|
-
}
|
|
215
|
-
return true;
|
|
4
|
+
return parseIRegexp(source) !== undefined;
|
|
216
5
|
}
|
|
217
6
|
//# sourceMappingURL=syntax.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"syntax.js","sourceRoot":"","sources":["../../../../../v1/schema/value/regexp/syntax.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"syntax.js","sourceRoot":"","sources":["../../../../../v1/schema/value/regexp/syntax.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAEvC,uFAAuF;AACvF,MAAM,UAAU,SAAS,CAAC,MAAc;IACtC,OAAO,YAAY,CAAC,MAAM,CAAC,KAAK,SAAS,CAAA;AAC3C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrale-os/kernel-dsl",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.4",
|
|
4
4
|
"description": "Astrale Kernel DSL - Schema authoring, inference, and IR serialization",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/astrale-os/kernel.git",
|
|
9
|
+
"directory": "dsl"
|
|
10
|
+
},
|
|
6
11
|
"files": [
|
|
7
12
|
"dist"
|
|
8
13
|
],
|
|
@@ -18,6 +23,30 @@
|
|
|
18
23
|
"types": "./dist/v1/index.d.ts",
|
|
19
24
|
"import": "./dist/v1/index.js"
|
|
20
25
|
},
|
|
26
|
+
"./v1/addressing": {
|
|
27
|
+
"types": "./dist/v1/addressing/index.d.ts",
|
|
28
|
+
"import": "./dist/v1/addressing/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./v1/bundle": {
|
|
31
|
+
"types": "./dist/v1/bundle/index.d.ts",
|
|
32
|
+
"import": "./dist/v1/bundle/index.js"
|
|
33
|
+
},
|
|
34
|
+
"./v1/schema": {
|
|
35
|
+
"types": "./dist/v1/schema/index.d.ts",
|
|
36
|
+
"import": "./dist/v1/schema/index.js"
|
|
37
|
+
},
|
|
38
|
+
"./v1/schema/full-match": {
|
|
39
|
+
"types": "./dist/v1/schema/value/full-match.d.ts",
|
|
40
|
+
"import": "./dist/v1/schema/value/full-match.js"
|
|
41
|
+
},
|
|
42
|
+
"./v1/schema/revision": {
|
|
43
|
+
"types": "./dist/v1/schema/domain.revision.d.ts",
|
|
44
|
+
"import": "./dist/v1/schema/domain.revision.js"
|
|
45
|
+
},
|
|
46
|
+
"./v1/schema/validator": {
|
|
47
|
+
"types": "./dist/v1/schema/compiled/validator.d.ts",
|
|
48
|
+
"import": "./dist/v1/schema/compiled/validator.js"
|
|
49
|
+
},
|
|
21
50
|
"./value": {
|
|
22
51
|
"types": "./dist/value/index.d.ts",
|
|
23
52
|
"import": "./dist/value/index.js"
|
|
@@ -30,13 +59,13 @@
|
|
|
30
59
|
"dependencies": {
|
|
31
60
|
"@noble/hashes": "2.2.0",
|
|
32
61
|
"jsonc-parser": "3.3.1",
|
|
33
|
-
"re2js": "2.8.6",
|
|
34
62
|
"zod": "4.4.3"
|
|
35
63
|
},
|
|
36
64
|
"devDependencies": {
|
|
37
65
|
"@astrale/typescript-config": "npm:@jsr/astrale__typescript-config@~1.1.0",
|
|
38
66
|
"@typescript/native-preview": "latest",
|
|
39
67
|
"ajv": "^8.20.0",
|
|
68
|
+
"re2js": "2.8.6",
|
|
40
69
|
"typescript": "~6.0.1-rc",
|
|
41
70
|
"vitest": "^4.0.18",
|
|
42
71
|
"yaml": "2.9.0"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"compiler.d.ts","sourceRoot":"","sources":["../../../../../v1/schema/value/instance/compiler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,KAAK,EAAE,sBAAsB,EAAkB,MAAM,YAAY,CAAA;AAQxE,MAAM,MAAM,yBAAyB,GACjC;IAAE,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,sBAAsB,CAAA;CAAE,GACnE;IAAE,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAA;AAE1D,sFAAsF;AACtF,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,UAAU,EAClB,QAAQ,EAAE,mBAAmB,EAC7B,OAAO,EAAE,MAAM,GACd,yBAAyB,CAyD3B"}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { walkSchema } from '../location/walk.js';
|
|
2
|
-
import { isValueObject as isJsonObject } from '../object.js';
|
|
3
|
-
import { compileIRegexp } from '../regexp/linear.js';
|
|
4
|
-
import { collectResourceClosure, locationKey } from '../resources/closure.js';
|
|
5
|
-
import { indexRegistry, inferNamedTypePlacement } from '../resources/registry.index.js';
|
|
6
|
-
/** Prepare reference and linear-regexp state without generating executable source. */
|
|
7
|
-
export function compileInstanceSchema(schema, registry, pointer) {
|
|
8
|
-
const indexed = indexRegistry(registry, pointer);
|
|
9
|
-
if (indexed.diagnostics.length > 0)
|
|
10
|
-
return failed(indexed.diagnostics);
|
|
11
|
-
const namedType = inferNamedTypePlacement(schema, indexed.index, pointer);
|
|
12
|
-
const closure = collectResourceClosure(schema, namedType === undefined ? 'callable-input' : 'named-type', indexed.index, pointer, namedType);
|
|
13
|
-
if (closure.diagnostics.length > 0)
|
|
14
|
-
return failed(closure.diagnostics);
|
|
15
|
-
const locations = new Map();
|
|
16
|
-
const matchers = new Map();
|
|
17
|
-
for (const resource of closure.resources.values()) {
|
|
18
|
-
walkSchema(resource.schema, (location) => {
|
|
19
|
-
const key = locationKey(resource.key, location.pointer);
|
|
20
|
-
locations.set(key, {
|
|
21
|
-
key,
|
|
22
|
-
pointer: location.pointer,
|
|
23
|
-
resource,
|
|
24
|
-
schema: location.schema,
|
|
25
|
-
});
|
|
26
|
-
if (!isJsonObject(location.schema))
|
|
27
|
-
return;
|
|
28
|
-
rememberMatcher(matchers, location.schema.pattern);
|
|
29
|
-
rememberMatcher(matchers, location.schema.fullMatch);
|
|
30
|
-
if (isJsonObject(location.schema.patternProperties)) {
|
|
31
|
-
for (const pattern of Object.keys(location.schema.patternProperties)) {
|
|
32
|
-
rememberMatcher(matchers, pattern);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
const initial = closure.resources.values().next().value;
|
|
38
|
-
const root = initial === undefined ? undefined : locations.get(locationKey(initial.key, ''));
|
|
39
|
-
if (root === undefined) {
|
|
40
|
-
return { compiled: false, message: 'The root value schema is absent from its closure.' };
|
|
41
|
-
}
|
|
42
|
-
return {
|
|
43
|
-
compiled: true,
|
|
44
|
-
value: {
|
|
45
|
-
root,
|
|
46
|
-
locations,
|
|
47
|
-
resolutions: closure.resolutions,
|
|
48
|
-
matcher(source) {
|
|
49
|
-
const matcher = matchers.get(source);
|
|
50
|
-
if (matcher === undefined) {
|
|
51
|
-
throw new TypeError('Value schema uses an unprepared I-Regexp source.');
|
|
52
|
-
}
|
|
53
|
-
return matcher;
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
function rememberMatcher(matchers, input) {
|
|
59
|
-
if (typeof input === 'string' && !matchers.has(input)) {
|
|
60
|
-
matchers.set(input, compileIRegexp(input));
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
function failed(diagnostics) {
|
|
64
|
-
return {
|
|
65
|
-
compiled: false,
|
|
66
|
-
message: diagnostics.map(({ code, message }) => `${code}: ${message}`).join('; '),
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
//# sourceMappingURL=compiler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"compiler.js","sourceRoot":"","sources":["../../../../../v1/schema/value/instance/compiler.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAChD,OAAO,EAAE,aAAa,IAAI,YAAY,EAAE,MAAM,cAAc,CAA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AAE,CAAC;oBAC1B,MAAM,IAAI,SAAS,CAAC,kDAAkD,CAAC,CAAA;gBACzE,CAAC;gBACD,OAAO,OAAO,CAAA;YAChB,CAAC;SACF;KACF,CAAA;AACH,CAAC;AAED,SAAS,eAAe,CAAC,QAAqC,EAAE,KAAc;IAC5E,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;QACtD,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC,CAAC,CAAA;IAC5C,CAAC;AACH,CAAC;AAED,SAAS,MAAM,CACb,WAA2E;IAE3E,OAAO;QACL,QAAQ,EAAE,KAAK;QACf,OAAO,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,GAAG,IAAI,KAAK,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;KAClF,CAAA;AACH,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"meta-schema.validate.d.ts","sourceRoot":"","sources":["../../../../../v1/schema/value/profile/meta-schema.validate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAe9C,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE,MAAM,GACd,SAAS,gBAAgB,EAAE,CAmB7B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"meta-schema.validate.js","sourceRoot":"","sources":["../../../../../v1/schema/value/profile/meta-schema.validate.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAChD,OAAO,kBAAkB,MAAM,2BAA2B,CAAA;AAQ1D,MAAM,QAAQ,GAAG,kBAEhB,CAAA;AAED,MAAM,UAAU,6BAA6B,CAC3C,MAAkB,EAClB,OAAe;IAEf,IAAI,CAAC;QACH,IAAI,QAAQ,CAAC,MAAM,CAAC;YAAE,OAAO,EAAE,CAAA;QAC/B,OAAO,CAAC,QAAQ,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAC3C,UAAU,CACR,gBAAgB,EAChB,GAAG,OAAO,GAAG,KAAK,CAAC,YAAY,EAAE,EACjC,4DAA4D,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO,GAAG,CAC9F,CACF,CAAA;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,UAAU,CACR,gBAAgB,EAChB,OAAO,EACP,iEAAiE,YAAY,CAAC,KAAK,CAAC,GAAG,CACxF;SACF,CAAA;IACH,CAAC;AACH,CAAC;AAED,SAAS,YAAY,CAAC,KAAc;IAClC,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AAC/D,CAAC"}
|