@json-schema-engine/compiler 0.0.1
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/LICENSE +21 -0
- package/README.md +47 -0
- package/dist/emit.d.ts +52 -0
- package/dist/emit.d.ts.map +1 -0
- package/dist/emit.js +166 -0
- package/dist/emit.js.map +1 -0
- package/dist/explain.d.ts +28 -0
- package/dist/explain.d.ts.map +1 -0
- package/dist/explain.js +42 -0
- package/dist/explain.js.map +1 -0
- package/dist/index.d.ts +132 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +169 -0
- package/dist/index.js.map +1 -0
- package/dist/plan.d.ts +83 -0
- package/dist/plan.d.ts.map +1 -0
- package/dist/plan.js +385 -0
- package/dist/plan.js.map +1 -0
- package/dist/runtime-compile.d.ts +30 -0
- package/dist/runtime-compile.d.ts.map +1 -0
- package/dist/runtime-compile.js +29 -0
- package/dist/runtime-compile.js.map +1 -0
- package/dist/runtime.d.ts +157 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +336 -0
- package/dist/runtime.js.map +1 -0
- package/dist/serialize/apply.d.ts +28 -0
- package/dist/serialize/apply.d.ts.map +1 -0
- package/dist/serialize/apply.js +211 -0
- package/dist/serialize/apply.js.map +1 -0
- package/dist/serialize/context.d.ts +143 -0
- package/dist/serialize/context.d.ts.map +1 -0
- package/dist/serialize/context.js +93 -0
- package/dist/serialize/context.js.map +1 -0
- package/dist/serialize/expressions.d.ts +7 -0
- package/dist/serialize/expressions.d.ts.map +1 -0
- package/dist/serialize/expressions.js +177 -0
- package/dist/serialize/expressions.js.map +1 -0
- package/dist/serialize/guards.d.ts +7 -0
- package/dist/serialize/guards.d.ts.map +1 -0
- package/dist/serialize/guards.js +19 -0
- package/dist/serialize/guards.js.map +1 -0
- package/dist/serialize/index.d.ts +7 -0
- package/dist/serialize/index.d.ts.map +1 -0
- package/dist/serialize/index.js +266 -0
- package/dist/serialize/index.js.map +1 -0
- package/dist/serialize/keywords.d.ts +32 -0
- package/dist/serialize/keywords.d.ts.map +1 -0
- package/dist/serialize/keywords.js +131 -0
- package/dist/serialize/keywords.js.map +1 -0
- package/dist/serialize/messages.d.ts +36 -0
- package/dist/serialize/messages.d.ts.map +1 -0
- package/dist/serialize/messages.js +100 -0
- package/dist/serialize/messages.js.map +1 -0
- package/dist/serialize/names.d.ts +47 -0
- package/dist/serialize/names.d.ts.map +1 -0
- package/dist/serialize/names.js +115 -0
- package/dist/serialize/names.js.map +1 -0
- package/dist/serialize/spans.d.ts +34 -0
- package/dist/serialize/spans.d.ts.map +1 -0
- package/dist/serialize/spans.js +61 -0
- package/dist/serialize/spans.js.map +1 -0
- package/dist/serialize/statements.d.ts +16 -0
- package/dist/serialize/statements.d.ts.map +1 -0
- package/dist/serialize/statements.js +396 -0
- package/dist/serialize/statements.js.map +1 -0
- package/dist/serialize/unit.d.ts +8 -0
- package/dist/serialize/unit.d.ts.map +1 -0
- package/dist/serialize/unit.js +107 -0
- package/dist/serialize/unit.js.map +1 -0
- package/dist/standalone.d.ts +24 -0
- package/dist/standalone.d.ts.map +1 -0
- package/dist/standalone.js +166 -0
- package/dist/standalone.js.map +1 -0
- package/package.json +38 -0
- package/src/emit.ts +196 -0
- package/src/explain.ts +67 -0
- package/src/index.ts +366 -0
- package/src/plan.ts +496 -0
- package/src/runtime-compile.ts +90 -0
- package/src/runtime.ts +599 -0
- package/src/serialize/apply.ts +251 -0
- package/src/serialize/context.ts +161 -0
- package/src/serialize/expressions.ts +202 -0
- package/src/serialize/guards.ts +20 -0
- package/src/serialize/index.ts +432 -0
- package/src/serialize/keywords.ts +144 -0
- package/src/serialize/messages.ts +120 -0
- package/src/serialize/names.ts +136 -0
- package/src/serialize/spans.ts +88 -0
- package/src/serialize/statements.ts +531 -0
- package/src/serialize/unit.ts +118 -0
- package/src/standalone.ts +187 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Henry Andrews
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# @json-schema-engine/compiler
|
|
2
|
+
|
|
3
|
+
Compiler tier for JSON Schema: turns a schema registered with `@json-schema-engine/core` into a specialized validator, trampolining to the interpreter for the dynamic islands it cannot emit statically. Add this package once interpreted evaluation shows up in a profile — a compiled artifact is exactly as correct as `Engine.evaluate` and never less complete, so switching tiers is a performance decision, not a semantic one. Needs `@json-schema-engine/core` installed alongside.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install @json-schema-engine/compiler @json-schema-engine/core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Example
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import assert from "node:assert";
|
|
15
|
+
import { createEngine } from "@json-schema-engine/core";
|
|
16
|
+
import { compileValidator, compileList } from "@json-schema-engine/compiler";
|
|
17
|
+
|
|
18
|
+
const engine = createEngine();
|
|
19
|
+
const uri = engine.registerSchema(
|
|
20
|
+
{ properties: { name: { type: "string", minLength: 1 } } },
|
|
21
|
+
"https://example.com/named",
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
const flag = compileValidator(engine, uri);
|
|
25
|
+
assert.equal(flag.validate({ name: "" }), false);
|
|
26
|
+
assert.equal(flag.validate({ name: "ok" }), true);
|
|
27
|
+
|
|
28
|
+
const list = compileList(engine, uri);
|
|
29
|
+
const result = list.evaluateList({ name: "" });
|
|
30
|
+
assert.equal(result.valid, false);
|
|
31
|
+
assert.equal(result.errors[0]?.inputLocation, "/name");
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Status
|
|
35
|
+
|
|
36
|
+
Version 0.0.1 is published for initial public feedback on both the functionality and the documentation. APIs may change before 1.0. [STATUS.md](https://github.com/handrews/json-schema-engine/blob/main/STATUS.md) is the authoritative statement of what is built and what is staged.
|
|
37
|
+
|
|
38
|
+
## Documentation
|
|
39
|
+
|
|
40
|
+
- [User guide](https://github.com/handrews/json-schema-engine/blob/main/docs/guide/index.md)
|
|
41
|
+
- [Compiling schemas](https://github.com/handrews/json-schema-engine/blob/main/docs/guide/compiled.md)
|
|
42
|
+
- [Conformance](https://github.com/handrews/json-schema-engine/blob/main/docs/conformance.md)
|
|
43
|
+
- [Repository](https://github.com/handrews/json-schema-engine)
|
|
44
|
+
|
|
45
|
+
## License
|
|
46
|
+
|
|
47
|
+
MIT
|
package/dist/emit.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { JsonValue } from "@json-schema-engine/core";
|
|
2
|
+
declare const BRAND: unique symbol;
|
|
3
|
+
/** An opaque, already-escaped fragment of emitted JavaScript. */
|
|
4
|
+
export interface CodeChunk {
|
|
5
|
+
readonly [BRAND]: true;
|
|
6
|
+
readonly text: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Tagged template for emitted code. Interpolations MUST be CodeChunks (from
|
|
10
|
+
* {@link id}/{@link str}/{@link num}/{@link json}/{@link regexTest}/{@link raw}/
|
|
11
|
+
* {@link frag}); anything else throws, so a stray schema string can never be
|
|
12
|
+
* spliced verbatim.
|
|
13
|
+
*/
|
|
14
|
+
export declare function js(strings: TemplateStringsArray, ...parts: readonly CodeChunk[]): CodeChunk;
|
|
15
|
+
/**
|
|
16
|
+
* A machine-generated identifier. NEVER pass schema-derived text here —
|
|
17
|
+
* identifiers come from the compiler's own counters and a fixed helper
|
|
18
|
+
* vocabulary. Rejects anything that is not a plain identifier or is reserved.
|
|
19
|
+
*/
|
|
20
|
+
export declare function id(name: string): CodeChunk;
|
|
21
|
+
/** A JavaScript string literal, escaped for embedding (incl. U+2028/U+2029). */
|
|
22
|
+
export declare function str(value: string): CodeChunk;
|
|
23
|
+
/** A numeric literal, JSON-sourced (finite), with an explicit -0 branch. */
|
|
24
|
+
export declare function num(value: number): CodeChunk;
|
|
25
|
+
/**
|
|
26
|
+
* A JSON constant. Emits an object/array literal only when no nested own key
|
|
27
|
+
* is `__proto__` (a literal `{"__proto__": …}` sets the prototype in source,
|
|
28
|
+
* unlike JSON.parse); otherwise routes through a JSON.parse call so the
|
|
29
|
+
* prototype is never touched.
|
|
30
|
+
*/
|
|
31
|
+
export declare function json(value: JsonValue): CodeChunk;
|
|
32
|
+
/**
|
|
33
|
+
* A regex membership test against a hoisted, pre-compiled pattern. The
|
|
34
|
+
* pattern source is escaped as a string literal; the compiled RegExp is
|
|
35
|
+
* supplied at runtime through the artifact's regex table (never
|
|
36
|
+
* `RegExp.prototype.toString`, never inline `/…/`).
|
|
37
|
+
*/
|
|
38
|
+
export declare function regexTest(tableRef: CodeChunk, source: string, target: CodeChunk): CodeChunk;
|
|
39
|
+
/** Splice previously built chunks (already escaped). */
|
|
40
|
+
export declare function frag(...chunks: readonly CodeChunk[]): CodeChunk;
|
|
41
|
+
/** Join chunks with a separator (both already escaped). */
|
|
42
|
+
export declare function join(sep: string, chunks: readonly CodeChunk[]): CodeChunk;
|
|
43
|
+
/**
|
|
44
|
+
* Internal escape hatch for structural code the compiler itself controls
|
|
45
|
+
* (keywords, operators) — NOT for schema-derived data. Guarded by ESLint so
|
|
46
|
+
* only emit-internal call sites use it. Kept explicit so audits grep one name.
|
|
47
|
+
*/
|
|
48
|
+
export declare function raw(controlledSource: string): CodeChunk;
|
|
49
|
+
/** The assembled source text of a chunk. */
|
|
50
|
+
export declare const render: (c: CodeChunk) => string;
|
|
51
|
+
export {};
|
|
52
|
+
//# sourceMappingURL=emit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emit.d.ts","sourceRoot":"","sources":["../src/emit.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAE1D,QAAA,MAAM,KAAK,eAAsB,CAAC;AAElC,iEAAiE;AACjE,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAOD;;;;;GAKG;AACH,wBAAgB,EAAE,CAChB,OAAO,EAAE,oBAAoB,EAC7B,GAAG,KAAK,EAAE,SAAS,SAAS,EAAE,GAC7B,SAAS,CAYX;AAoDD;;;;GAIG;AACH,wBAAgB,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAK1C;AAED,gFAAgF;AAChF,wBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAO5C;AAED,4EAA4E;AAC5E,wBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAM5C;AAUD;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,CAgBhD;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CACvB,QAAQ,EAAE,SAAS,EACnB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,SAAS,GAChB,SAAS,CAEX;AAED,wDAAwD;AACxD,wBAAgB,IAAI,CAAC,GAAG,MAAM,EAAE,SAAS,SAAS,EAAE,GAAG,SAAS,CAE/D;AAED,2DAA2D;AAC3D,wBAAgB,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,SAAS,EAAE,GAAG,SAAS,CAEzE;AAED;;;;GAIG;AACH,wBAAgB,GAAG,CAAC,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAEvD;AAED,4CAA4C;AAC5C,eAAO,MAAM,MAAM,GAAI,GAAG,SAAS,KAAG,MAAgB,CAAC"}
|
package/dist/emit.js
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
// The gated code serializer (D20/M6): the ONLY module that assembles
|
|
2
|
+
// JavaScript source text. Every value that reaches emitted code passes
|
|
3
|
+
// through a typed wrapper here, so schema-derived data is escaped by
|
|
4
|
+
// construction — raw string concatenation of untrusted input is impossible.
|
|
5
|
+
//
|
|
6
|
+
// The `js` tag accepts only CodeChunk arguments (the branded outputs of the
|
|
7
|
+
// wrappers below); a bare string throws. Template static parts are literals
|
|
8
|
+
// by grammar. Downstream modules traffic in CodeChunk, never string, so the
|
|
9
|
+
// type system carries the guarantee and ESLint fences the one escape hatch.
|
|
10
|
+
const BRAND = Symbol("CodeChunk");
|
|
11
|
+
const chunk = (text) => ({ [BRAND]: true, text });
|
|
12
|
+
const isChunk = (v) => typeof v === "object" && v !== null && BRAND in v;
|
|
13
|
+
/**
|
|
14
|
+
* Tagged template for emitted code. Interpolations MUST be CodeChunks (from
|
|
15
|
+
* {@link id}/{@link str}/{@link num}/{@link json}/{@link regexTest}/{@link raw}/
|
|
16
|
+
* {@link frag}); anything else throws, so a stray schema string can never be
|
|
17
|
+
* spliced verbatim.
|
|
18
|
+
*/
|
|
19
|
+
export function js(strings, ...parts) {
|
|
20
|
+
let out = strings[0];
|
|
21
|
+
for (let i = 0; i < parts.length; i++) {
|
|
22
|
+
const part = parts[i];
|
|
23
|
+
if (!isChunk(part)) {
|
|
24
|
+
throw new TypeError(`js\`\` interpolation ${i} is not a CodeChunk; wrap it (id/str/num/json/…)`);
|
|
25
|
+
}
|
|
26
|
+
out += part.text + strings[i + 1];
|
|
27
|
+
}
|
|
28
|
+
return chunk(out);
|
|
29
|
+
}
|
|
30
|
+
const IDENT = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
|
|
31
|
+
const RESERVED = new Set([
|
|
32
|
+
"break",
|
|
33
|
+
"case",
|
|
34
|
+
"catch",
|
|
35
|
+
"class",
|
|
36
|
+
"const",
|
|
37
|
+
"continue",
|
|
38
|
+
"debugger",
|
|
39
|
+
"default",
|
|
40
|
+
"delete",
|
|
41
|
+
"do",
|
|
42
|
+
"else",
|
|
43
|
+
"export",
|
|
44
|
+
"extends",
|
|
45
|
+
"false",
|
|
46
|
+
"finally",
|
|
47
|
+
"for",
|
|
48
|
+
"function",
|
|
49
|
+
"if",
|
|
50
|
+
"import",
|
|
51
|
+
"in",
|
|
52
|
+
"instanceof",
|
|
53
|
+
"new",
|
|
54
|
+
"null",
|
|
55
|
+
"return",
|
|
56
|
+
"super",
|
|
57
|
+
"switch",
|
|
58
|
+
"this",
|
|
59
|
+
"throw",
|
|
60
|
+
"true",
|
|
61
|
+
"try",
|
|
62
|
+
"typeof",
|
|
63
|
+
"var",
|
|
64
|
+
"void",
|
|
65
|
+
"while",
|
|
66
|
+
"with",
|
|
67
|
+
"yield",
|
|
68
|
+
"let",
|
|
69
|
+
"static",
|
|
70
|
+
"enum",
|
|
71
|
+
"await",
|
|
72
|
+
"implements",
|
|
73
|
+
"package",
|
|
74
|
+
"protected",
|
|
75
|
+
"interface",
|
|
76
|
+
"private",
|
|
77
|
+
"public",
|
|
78
|
+
]);
|
|
79
|
+
/**
|
|
80
|
+
* A machine-generated identifier. NEVER pass schema-derived text here —
|
|
81
|
+
* identifiers come from the compiler's own counters and a fixed helper
|
|
82
|
+
* vocabulary. Rejects anything that is not a plain identifier or is reserved.
|
|
83
|
+
*/
|
|
84
|
+
export function id(name) {
|
|
85
|
+
if (!IDENT.test(name) || RESERVED.has(name)) {
|
|
86
|
+
throw new TypeError(`unsafe identifier '${name}'`);
|
|
87
|
+
}
|
|
88
|
+
return chunk(name);
|
|
89
|
+
}
|
|
90
|
+
/** A JavaScript string literal, escaped for embedding (incl. U+2028/U+2029). */
|
|
91
|
+
export function str(value) {
|
|
92
|
+
const json = JSON.stringify(value);
|
|
93
|
+
// JSON.stringify leaves U+2028/U+2029 literal; they are valid in JSON but
|
|
94
|
+
// were line terminators in pre-ES2019 JS and still trip some tooling.
|
|
95
|
+
return chunk(json.replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029"));
|
|
96
|
+
}
|
|
97
|
+
/** A numeric literal, JSON-sourced (finite), with an explicit -0 branch. */
|
|
98
|
+
export function num(value) {
|
|
99
|
+
if (!Number.isFinite(value)) {
|
|
100
|
+
throw new TypeError(`non-finite numeric constant ${String(value)}`);
|
|
101
|
+
}
|
|
102
|
+
if (Object.is(value, -0))
|
|
103
|
+
return chunk("-0");
|
|
104
|
+
return chunk(String(value));
|
|
105
|
+
}
|
|
106
|
+
/** True when `value` or any nested value is an object with a "__proto__" own key. */
|
|
107
|
+
function hasProtoKey(value) {
|
|
108
|
+
if (value === null || typeof value !== "object")
|
|
109
|
+
return false;
|
|
110
|
+
if (Array.isArray(value))
|
|
111
|
+
return value.some(hasProtoKey);
|
|
112
|
+
if (Object.hasOwn(value, "__proto__"))
|
|
113
|
+
return true;
|
|
114
|
+
return Object.values(value).some(hasProtoKey);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* A JSON constant. Emits an object/array literal only when no nested own key
|
|
118
|
+
* is `__proto__` (a literal `{"__proto__": …}` sets the prototype in source,
|
|
119
|
+
* unlike JSON.parse); otherwise routes through a JSON.parse call so the
|
|
120
|
+
* prototype is never touched.
|
|
121
|
+
*/
|
|
122
|
+
export function json(value) {
|
|
123
|
+
if (value === null || typeof value !== "object") {
|
|
124
|
+
if (typeof value === "number")
|
|
125
|
+
return num(value);
|
|
126
|
+
if (typeof value === "string")
|
|
127
|
+
return str(value);
|
|
128
|
+
return chunk(String(value)); // boolean
|
|
129
|
+
}
|
|
130
|
+
if (hasProtoKey(value)) {
|
|
131
|
+
return chunk(`JSON.parse(${str(JSON.stringify(value)).text})`);
|
|
132
|
+
}
|
|
133
|
+
if (Array.isArray(value)) {
|
|
134
|
+
return chunk(`[${value.map((v) => json(v).text).join(",")}]`);
|
|
135
|
+
}
|
|
136
|
+
const members = Object.entries(value).map(([k, v]) => `${str(k).text}:${json(v).text}`);
|
|
137
|
+
return chunk(`{${members.join(",")}}`);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* A regex membership test against a hoisted, pre-compiled pattern. The
|
|
141
|
+
* pattern source is escaped as a string literal; the compiled RegExp is
|
|
142
|
+
* supplied at runtime through the artifact's regex table (never
|
|
143
|
+
* `RegExp.prototype.toString`, never inline `/…/`).
|
|
144
|
+
*/
|
|
145
|
+
export function regexTest(tableRef, source, target) {
|
|
146
|
+
return chunk(`${tableRef.text}[${str(source).text}].test(${target.text})`);
|
|
147
|
+
}
|
|
148
|
+
/** Splice previously built chunks (already escaped). */
|
|
149
|
+
export function frag(...chunks) {
|
|
150
|
+
return chunk(chunks.map((c) => c.text).join(""));
|
|
151
|
+
}
|
|
152
|
+
/** Join chunks with a separator (both already escaped). */
|
|
153
|
+
export function join(sep, chunks) {
|
|
154
|
+
return chunk(chunks.map((c) => c.text).join(sep));
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Internal escape hatch for structural code the compiler itself controls
|
|
158
|
+
* (keywords, operators) — NOT for schema-derived data. Guarded by ESLint so
|
|
159
|
+
* only emit-internal call sites use it. Kept explicit so audits grep one name.
|
|
160
|
+
*/
|
|
161
|
+
export function raw(controlledSource) {
|
|
162
|
+
return chunk(controlledSource);
|
|
163
|
+
}
|
|
164
|
+
/** The assembled source text of a chunk. */
|
|
165
|
+
export const render = (c) => c.text;
|
|
166
|
+
//# sourceMappingURL=emit.js.map
|
package/dist/emit.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emit.js","sourceRoot":"","sources":["../src/emit.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,uEAAuE;AACvE,qEAAqE;AACrE,4EAA4E;AAC5E,EAAE;AACF,4EAA4E;AAC5E,4EAA4E;AAC5E,4EAA4E;AAC5E,4EAA4E;AAI5E,MAAM,KAAK,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;AAQlC,MAAM,KAAK,GAAG,CAAC,IAAY,EAAa,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;AAErE,MAAM,OAAO,GAAG,CAAC,CAAU,EAAkB,EAAE,CAC7C,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAAI,KAAK,IAAI,CAAC,CAAC;AAEpD;;;;;GAKG;AACH,MAAM,UAAU,EAAE,CAChB,OAA6B,EAC7B,GAAG,KAA2B;IAE9B,IAAI,GAAG,GAAG,OAAO,CAAC,CAAC,CAAE,CAAC;IACtB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACtB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YACnB,MAAM,IAAI,SAAS,CACjB,wBAAwB,CAAC,kDAAkD,CAC5E,CAAC;QACJ,CAAC;QACD,GAAG,I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D;AAC3D,MAAM,UAAU,IAAI,CAAC,GAAW,EAAE,MAA4B;IAC5D,OAAO,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AACpD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,GAAG,CAAC,gBAAwB;IAC1C,OAAO,KAAK,CAAC,gBAAgB,CAAC,CAAC;AACjC,CAAC;AAED,4CAA4C;AAC5C,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,CAAY,EAAU,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { CompilationPlan, FallbackCause } from "./plan.js";
|
|
2
|
+
/** Aggregate view of one {@link CompilationPlan}'s unit classification. */
|
|
3
|
+
export interface CompilationExplanation {
|
|
4
|
+
/** Every planned unit, static or not. */
|
|
5
|
+
totalUnits: number;
|
|
6
|
+
staticUnits: number;
|
|
7
|
+
interpretedUnits: number;
|
|
8
|
+
/** Interpreted-unit count per fallback cause; absent cause = zero. */
|
|
9
|
+
causes: Partial<Record<FallbackCause, number>>;
|
|
10
|
+
/**
|
|
11
|
+
* Canonical `baseUri#pointer` keys of the interpreted units — for
|
|
12
|
+
* diagnosis when a census count assertion fails, not for pinning (key
|
|
13
|
+
* lists churn on suite reorganization without adding regression signal).
|
|
14
|
+
*/
|
|
15
|
+
interpretedKeys: string[];
|
|
16
|
+
/** Units whose apply paths can reach an interpreted unit. */
|
|
17
|
+
reachesInterpretedCount: number;
|
|
18
|
+
/**
|
|
19
|
+
* Static consumer units compiled with runtime evaluated-set tracking (phase
|
|
20
|
+
* B) — the flag-mode alternative to interpreting a dynamic-coverage consumer.
|
|
21
|
+
*/
|
|
22
|
+
trackingUnits: number;
|
|
23
|
+
/** Static units in some tracked unit's in-place coverage region (phase B). */
|
|
24
|
+
regionUnits: number;
|
|
25
|
+
}
|
|
26
|
+
/** Summarizes a plan's classification for census gates and diagnostics. */
|
|
27
|
+
export declare function explainCompilation(plan: CompilationPlan): CompilationExplanation;
|
|
28
|
+
//# sourceMappingURL=explain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"explain.d.ts","sourceRoot":"","sources":["../src/explain.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAEhE,2EAA2E;AAC3E,MAAM,WAAW,sBAAsB;IACrC,yCAAyC;IACzC,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,sEAAsE;IACtE,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC,CAAC;IAC/C;;;;OAIG;IACH,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,6DAA6D;IAC7D,uBAAuB,EAAE,MAAM,CAAC;IAChC;;;OAGG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB,8EAA8E;IAC9E,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,2EAA2E;AAC3E,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,eAAe,GACpB,sBAAsB,CA8BxB"}
|
package/dist/explain.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// Compilation-plan diagnostics (deferred-register item, built for the
|
|
2
|
+
// plan-census gates): interpreted fallback is always CORRECT, so a
|
|
3
|
+
// regression that silently flips units static→interpreted passes every
|
|
4
|
+
// suite/differential/fuzz gate — only a census over these summaries
|
|
5
|
+
// notices. The summarizer is pure read-only projection of plan data.
|
|
6
|
+
/** Summarizes a plan's classification for census gates and diagnostics. */
|
|
7
|
+
export function explainCompilation(plan) {
|
|
8
|
+
const causes = {};
|
|
9
|
+
const interpretedKeys = [];
|
|
10
|
+
let staticUnits = 0;
|
|
11
|
+
let reachesInterpretedCount = 0;
|
|
12
|
+
let trackingUnits = 0;
|
|
13
|
+
let regionUnits = 0;
|
|
14
|
+
for (const unit of plan.units.values()) {
|
|
15
|
+
if (unit.kind === "static")
|
|
16
|
+
staticUnits++;
|
|
17
|
+
else {
|
|
18
|
+
interpretedKeys.push(unit.key);
|
|
19
|
+
if (unit.cause !== undefined) {
|
|
20
|
+
causes[unit.cause] = (causes[unit.cause] ?? 0) + 1;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
if (unit.reachesInterpreted)
|
|
24
|
+
reachesInterpretedCount++;
|
|
25
|
+
if (unit.tracking)
|
|
26
|
+
trackingUnits++;
|
|
27
|
+
if (unit.inRegion)
|
|
28
|
+
regionUnits++;
|
|
29
|
+
}
|
|
30
|
+
interpretedKeys.sort();
|
|
31
|
+
return {
|
|
32
|
+
totalUnits: plan.units.size,
|
|
33
|
+
staticUnits,
|
|
34
|
+
interpretedUnits: plan.units.size - staticUnits,
|
|
35
|
+
causes,
|
|
36
|
+
interpretedKeys,
|
|
37
|
+
reachesInterpretedCount,
|
|
38
|
+
trackingUnits,
|
|
39
|
+
regionUnits,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=explain.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"explain.js","sourceRoot":"","sources":["../src/explain.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,mEAAmE;AACnE,uEAAuE;AACvE,oEAAoE;AACpE,qEAAqE;AA6BrE,2EAA2E;AAC3E,MAAM,UAAU,kBAAkB,CAChC,IAAqB;IAErB,MAAM,MAAM,GAA2C,EAAE,CAAC;IAC1D,MAAM,eAAe,GAAa,EAAE,CAAC;IACrC,IAAI,WAAW,GAAG,CAAC,CAAC;IACpB,IAAI,uBAAuB,GAAG,CAAC,CAAC;IAChC,IAAI,aAAa,GAAG,CAAC,CAAC;IACtB,IAAI,WAAW,GAAG,CAAC,CAAC;IACpB,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;QACvC,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ;YAAE,WAAW,EAAE,CAAC;aACrC,CAAC;YACJ,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAC/B,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;gBAC7B,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;YACrD,CAAC;QACH,CAAC;QACD,IAAI,IAAI,CAAC,kBAAkB;YAAE,uBAAuB,EAAE,CAAC;QACvD,IAAI,IAAI,CAAC,QAAQ;YAAE,aAAa,EAAE,CAAC;QACnC,IAAI,IAAI,CAAC,QAAQ;YAAE,WAAW,EAAE,CAAC;IACnC,CAAC;IACD,eAAe,CAAC,IAAI,EAAE,CAAC;IACvB,OAAO;QACL,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI;QAC3B,WAAW;QACX,gBAAgB,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,WAAW;QAC/C,MAAM;QACN,eAAe;QACf,uBAAuB;QACvB,aAAa;QACb,WAAW;KACZ,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { type AnnotationSelection, type AnnotationUnit, type BasicOutputDocument, type Engine, type ErrorUnit, type EvaluateOptions, type JsonValue, type ResultFor } from "@json-schema-engine/core";
|
|
2
|
+
import { type CompilationPlan } from "./plan.js";
|
|
3
|
+
import { type CompiledValidate } from "./runtime-compile.js";
|
|
4
|
+
export type { CompilationPlan, PlannedUnit, FallbackCause } from "./plan.js";
|
|
5
|
+
export { buildPlan } from "./plan.js";
|
|
6
|
+
export { explainCompilation } from "./explain.js";
|
|
7
|
+
export type { CompilationExplanation } from "./explain.js";
|
|
8
|
+
export { serializePlan } from "./serialize/index.js";
|
|
9
|
+
export { emitStandalone, StandaloneUnsupportedError } from "./standalone.js";
|
|
10
|
+
export type { StandaloneOptions } from "./standalone.js";
|
|
11
|
+
/** Options for {@link compileValidator}. */
|
|
12
|
+
export interface CompileOptions {
|
|
13
|
+
/** depth bound shared between compiled nesting and fragments; default core's */
|
|
14
|
+
maxDepth?: number;
|
|
15
|
+
/**
|
|
16
|
+
* Disable the D9 optimizations (inlining, plain-data fast paths). Exists
|
|
17
|
+
* so the differential fuzzer referees both configurations; not a
|
|
18
|
+
* user-facing tuning knob.
|
|
19
|
+
*/
|
|
20
|
+
conservative?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/** Options for {@link compileList}. */
|
|
23
|
+
export interface ListCompileOptions extends CompileOptions {
|
|
24
|
+
/**
|
|
25
|
+
* Include `keyword`, `vocabulary`, and structured `params` on each error
|
|
26
|
+
* unit, matching the interpreter's `errorParams` option on `list` output
|
|
27
|
+
* (D13).
|
|
28
|
+
*/
|
|
29
|
+
errorParams?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Which annotations to collect, matching the interpreter's `annotations`
|
|
32
|
+
* option: `true` or a selection makes `evaluateList` return an
|
|
33
|
+
* `annotations` array on valid instances and `basic()` render the Basic
|
|
34
|
+
* document's annotation side. A selection's allow/deny lists are
|
|
35
|
+
* specialized into the artifact at compile time; its `keep` predicate runs
|
|
36
|
+
* at evaluation.
|
|
37
|
+
*/
|
|
38
|
+
annotations?: boolean | AnnotationSelection;
|
|
39
|
+
}
|
|
40
|
+
/** A compiled list-mode result: interpreter-exact flat error units, plus annotations when collected. */
|
|
41
|
+
export interface CompiledListResult {
|
|
42
|
+
valid: boolean;
|
|
43
|
+
errors: ErrorUnit[];
|
|
44
|
+
/**
|
|
45
|
+
* Present on valid instances when compiled with `annotations` (absent on
|
|
46
|
+
* invalid ones, matching `Engine.evaluate`'s valid-only annotation
|
|
47
|
+
* contract); always absent otherwise.
|
|
48
|
+
*/
|
|
49
|
+
annotations?: AnnotationUnit[];
|
|
50
|
+
}
|
|
51
|
+
/** A compiled list-mode artifact (see {@link compileList}). */
|
|
52
|
+
export interface CompiledListArtifact {
|
|
53
|
+
/** evaluate with full error collection ({@link CompiledListResult}) */
|
|
54
|
+
evaluateList(instance: JsonValue): CompiledListResult;
|
|
55
|
+
/**
|
|
56
|
+
* The same result as the Basic document (IETF draft-03 §13.4.2), matching
|
|
57
|
+
* `Engine.evaluate(uri, x, { output: "basic" }).outputDocument`: the flat
|
|
58
|
+
* `errors` array on invalid instances; on valid instances compiled with
|
|
59
|
+
* `annotations`, the selected annotations, present only when non-empty.
|
|
60
|
+
*/
|
|
61
|
+
basic(instance: JsonValue): BasicOutputDocument;
|
|
62
|
+
plan: CompilationPlan;
|
|
63
|
+
source: string;
|
|
64
|
+
}
|
|
65
|
+
/** A compiled artifact: the validator plus its plan and source (inspection/tests). */
|
|
66
|
+
export interface CompiledArtifact {
|
|
67
|
+
validate: CompiledValidate;
|
|
68
|
+
plan: CompilationPlan;
|
|
69
|
+
source: string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Options for {@link compileEvaluator}: the flat surface's controls
|
|
73
|
+
* (`errorParams`, the annotation selection) and the level, fixed when the
|
|
74
|
+
* evaluator is compiled.
|
|
75
|
+
*/
|
|
76
|
+
export interface EvaluatorCompileOptions extends ListCompileOptions {
|
|
77
|
+
/**
|
|
78
|
+
* Retain irrelevant records (draft-03 §12.2) so the artifact can serve
|
|
79
|
+
* the verbose level: `output: "verbose"`, and `list`/`hierarchical` with
|
|
80
|
+
* `verbose: true`. A retaining artifact serves the relevant level too;
|
|
81
|
+
* the retention costs a copy per dropped record and nothing on the
|
|
82
|
+
* emitted source, which is identical at both levels.
|
|
83
|
+
*/
|
|
84
|
+
verbose?: boolean;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* The render-time choices of {@link CompiledEvaluator.evaluate}: format,
|
|
88
|
+
* level, and trace. The controls fixed at compile time are rejected here
|
|
89
|
+
* with {@link OutputOptionsError} rather than ignored.
|
|
90
|
+
*/
|
|
91
|
+
export type EvaluatorOptions = Pick<EvaluateOptions, "output" | "verbose" | "trace">;
|
|
92
|
+
/**
|
|
93
|
+
* A compiled evaluator (see {@link compileEvaluator}): every output format
|
|
94
|
+
* from one recorded application tree, with `Engine.evaluate`'s result for
|
|
95
|
+
* the same instance and options.
|
|
96
|
+
*/
|
|
97
|
+
export interface CompiledEvaluator {
|
|
98
|
+
evaluate<O extends EvaluatorOptions>(instance: JsonValue, options?: O): ResultFor<O>;
|
|
99
|
+
plan: CompilationPlan;
|
|
100
|
+
source: string;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Compile a registered schema into a flag-mode validator. The artifact
|
|
104
|
+
* binds to a snapshot of the engine's schema and dialect registries taken at
|
|
105
|
+
* compile time, plus the engine's pattern cache: schemas registered,
|
|
106
|
+
* re-registered, or given a new dialect later are invisible to it, and a
|
|
107
|
+
* reference unresolved at compile time stays unresolved for it (E1).
|
|
108
|
+
*/
|
|
109
|
+
export declare function compileValidator(engine: Engine, schemaUri: string, options?: CompileOptions): CompiledArtifact;
|
|
110
|
+
/**
|
|
111
|
+
* Compile a registered schema into a list-output validator (D9e): flat,
|
|
112
|
+
* interpreter-exact error units — the same elements
|
|
113
|
+
* `Engine.evaluate(uri, x, { output: "list" }).errors` yields, in the same
|
|
114
|
+
* order (list artifacts never short-circuit; every branch runs, DESIGN §7).
|
|
115
|
+
* Error-unit objects materialize only on failure paths. Binds to registry
|
|
116
|
+
* snapshots exactly like {@link compileValidator}.
|
|
117
|
+
*/
|
|
118
|
+
export declare function compileList(engine: Engine, schemaUri: string, options?: ListCompileOptions): CompiledListArtifact;
|
|
119
|
+
/**
|
|
120
|
+
* Compile a registered schema into an evaluator that renders every output
|
|
121
|
+
* format: a list artifact that also records each application's node —
|
|
122
|
+
* locations, keyword verdicts, and the records it raised — into core's
|
|
123
|
+
* located tree, so the documents render through the same code as the
|
|
124
|
+
* interpreter's. Format, level, and `trace` are chosen per evaluation; the
|
|
125
|
+
* annotation selection, `errorParams`, and whether irrelevant records are
|
|
126
|
+
* retained (`verbose`) are fixed here (D5). Without retention the records
|
|
127
|
+
* are discarded at the cut and a verbose-level request throws
|
|
128
|
+
* {@link OutputOptionsError}. Binds to registry snapshots exactly like
|
|
129
|
+
* {@link compileValidator}.
|
|
130
|
+
*/
|
|
131
|
+
export declare function compileEvaluator(engine: Engine, schemaUri: string, options?: EvaluatorCompileOptions): CompiledEvaluator;
|
|
132
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAML,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,MAAM,EACX,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,SAAS,EAEd,KAAK,SAAS,EACf,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAa,KAAK,eAAe,EAAE,MAAM,WAAW,CAAC;AAG5D,OAAO,EAKL,KAAK,gBAAgB,EACtB,MAAM,sBAAsB,CAAC;AAE9B,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC7E,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,YAAY,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAC7E,YAAY,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,4CAA4C;AAC5C,MAAM,WAAW,cAAc;IAC7B,gFAAgF;I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