@bastani/atomic-schema 0.0.0-stage → 0.9.88-alpha.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/CHANGELOG.md +11 -0
- package/LICENSE +22 -0
- package/NOTICE.md +13 -0
- package/README.md +63 -2
- package/THIRD_PARTY_NOTICES/typebox-LICENSE +23 -0
- package/dist/annotations.d.ts +44 -0
- package/dist/annotations.d.ts.map +1 -0
- package/dist/annotations.js +193 -0
- package/dist/annotations.js.map +1 -0
- package/dist/builders.d.ts +143 -0
- package/dist/builders.d.ts.map +1 -0
- package/dist/builders.js +126 -0
- package/dist/builders.js.map +1 -0
- package/dist/checks.d.ts +114 -0
- package/dist/checks.d.ts.map +1 -0
- package/dist/checks.js +578 -0
- package/dist/checks.js.map +1 -0
- package/dist/coerce.d.ts +53 -0
- package/dist/coerce.d.ts.map +1 -0
- package/dist/coerce.js +624 -0
- package/dist/coerce.js.map +1 -0
- package/dist/compiler.d.ts +53 -0
- package/dist/compiler.d.ts.map +1 -0
- package/dist/compiler.js +551 -0
- package/dist/compiler.js.map +1 -0
- package/dist/explain.d.ts +29 -0
- package/dist/explain.d.ts.map +1 -0
- package/dist/explain.js +392 -0
- package/dist/explain.js.map +1 -0
- package/dist/formats/index.d.ts +7 -0
- package/dist/formats/index.d.ts.map +1 -0
- package/dist/formats/index.js +51 -0
- package/dist/formats/index.js.map +1 -0
- package/dist/formats/typebox/date.d.ts +7 -0
- package/dist/formats/typebox/date.d.ts.map +1 -0
- package/dist/formats/typebox/date.js +47 -0
- package/dist/formats/typebox/date.js.map +1 -0
- package/dist/formats/typebox/date_time.d.ts +7 -0
- package/dist/formats/typebox/date_time.d.ts.map +1 -0
- package/dist/formats/typebox/date_time.js +39 -0
- package/dist/formats/typebox/date_time.js.map +1 -0
- package/dist/formats/typebox/duration.d.ts +6 -0
- package/dist/formats/typebox/duration.d.ts.map +1 -0
- package/dist/formats/typebox/duration.js +36 -0
- package/dist/formats/typebox/duration.js.map +1 -0
- package/dist/formats/typebox/email.d.ts +6 -0
- package/dist/formats/typebox/email.d.ts.map +1 -0
- package/dist/formats/typebox/email.js +36 -0
- package/dist/formats/typebox/email.js.map +1 -0
- package/dist/formats/typebox/hostname.d.ts +8 -0
- package/dist/formats/typebox/hostname.d.ts.map +1 -0
- package/dist/formats/typebox/hostname.js +38 -0
- package/dist/formats/typebox/hostname.js.map +1 -0
- package/dist/formats/typebox/idn_email.d.ts +6 -0
- package/dist/formats/typebox/idn_email.d.ts.map +1 -0
- package/dist/formats/typebox/idn_email.js +36 -0
- package/dist/formats/typebox/idn_email.js.map +1 -0
- package/dist/formats/typebox/idn_hostname.d.ts +9 -0
- package/dist/formats/typebox/idn_hostname.d.ts.map +1 -0
- package/dist/formats/typebox/idn_hostname.js +39 -0
- package/dist/formats/typebox/idn_hostname.js.map +1 -0
- package/dist/formats/typebox/idna/format/bidi.d.ts +4 -0
- package/dist/formats/typebox/idna/format/bidi.d.ts.map +1 -0
- package/dist/formats/typebox/idna/format/bidi.js +132 -0
- package/dist/formats/typebox/idna/format/bidi.js.map +1 -0
- package/dist/formats/typebox/idna/format/puny.d.ts +4 -0
- package/dist/formats/typebox/idna/format/puny.d.ts.map +1 -0
- package/dist/formats/typebox/idna/format/puny.js +172 -0
- package/dist/formats/typebox/idna/format/puny.js.map +1 -0
- package/dist/formats/typebox/idna/hostname.d.ts +2 -0
- package/dist/formats/typebox/idna/hostname.d.ts.map +1 -0
- package/dist/formats/typebox/idna/hostname.js +43 -0
- package/dist/formats/typebox/idna/hostname.js.map +1 -0
- package/dist/formats/typebox/idna/idn-hostname.d.ts +2 -0
- package/dist/formats/typebox/idna/idn-hostname.d.ts.map +1 -0
- package/dist/formats/typebox/idna/idn-hostname.js +71 -0
- package/dist/formats/typebox/idna/idn-hostname.js.map +1 -0
- package/dist/formats/typebox/idna/index.d.ts +3 -0
- package/dist/formats/typebox/idna/index.d.ts.map +1 -0
- package/dist/formats/typebox/idna/index.js +30 -0
- package/dist/formats/typebox/idna/index.js.map +1 -0
- package/dist/formats/typebox/idna/label/ascii.d.ts +2 -0
- package/dist/formats/typebox/idna/label/ascii.d.ts.map +1 -0
- package/dist/formats/typebox/idna/label/ascii.js +37 -0
- package/dist/formats/typebox/idna/label/ascii.js.map +1 -0
- package/dist/formats/typebox/idna/label/puny.d.ts +2 -0
- package/dist/formats/typebox/idna/label/puny.d.ts.map +1 -0
- package/dist/formats/typebox/idna/label/puny.js +56 -0
- package/dist/formats/typebox/idna/label/puny.js.map +1 -0
- package/dist/formats/typebox/idna/label/unicode.d.ts +2 -0
- package/dist/formats/typebox/idna/label/unicode.d.ts.map +1 -0
- package/dist/formats/typebox/idna/label/unicode.js +134 -0
- package/dist/formats/typebox/idna/label/unicode.js.map +1 -0
- package/dist/formats/typebox/idna/pattern/pattern.d.ts +31 -0
- package/dist/formats/typebox/idna/pattern/pattern.d.ts.map +1 -0
- package/dist/formats/typebox/idna/pattern/pattern.js +98 -0
- package/dist/formats/typebox/idna/pattern/pattern.js.map +1 -0
- package/dist/formats/typebox/ipv4.d.ts +6 -0
- package/dist/formats/typebox/ipv4.d.ts.map +1 -0
- package/dist/formats/typebox/ipv4.js +36 -0
- package/dist/formats/typebox/ipv4.js.map +1 -0
- package/dist/formats/typebox/ipv6.d.ts +6 -0
- package/dist/formats/typebox/ipv6.d.ts.map +1 -0
- package/dist/formats/typebox/ipv6.js +36 -0
- package/dist/formats/typebox/ipv6.js.map +1 -0
- package/dist/formats/typebox/iri.d.ts +6 -0
- package/dist/formats/typebox/iri.d.ts.map +1 -0
- package/dist/formats/typebox/iri.js +63 -0
- package/dist/formats/typebox/iri.js.map +1 -0
- package/dist/formats/typebox/iri_reference.d.ts +6 -0
- package/dist/formats/typebox/iri_reference.d.ts.map +1 -0
- package/dist/formats/typebox/iri_reference.js +40 -0
- package/dist/formats/typebox/iri_reference.js.map +1 -0
- package/dist/formats/typebox/json_pointer.d.ts +7 -0
- package/dist/formats/typebox/json_pointer.d.ts.map +1 -0
- package/dist/formats/typebox/json_pointer.js +37 -0
- package/dist/formats/typebox/json_pointer.js.map +1 -0
- package/dist/formats/typebox/json_pointer_uri_fragment.d.ts +7 -0
- package/dist/formats/typebox/json_pointer_uri_fragment.d.ts.map +1 -0
- package/dist/formats/typebox/json_pointer_uri_fragment.js +37 -0
- package/dist/formats/typebox/json_pointer_uri_fragment.js.map +1 -0
- package/dist/formats/typebox/regex.d.ts +6 -0
- package/dist/formats/typebox/regex.d.ts.map +1 -0
- package/dist/formats/typebox/regex.js +41 -0
- package/dist/formats/typebox/regex.js.map +1 -0
- package/dist/formats/typebox/relative_json_pointer.d.ts +7 -0
- package/dist/formats/typebox/relative_json_pointer.d.ts.map +1 -0
- package/dist/formats/typebox/relative_json_pointer.js +37 -0
- package/dist/formats/typebox/relative_json_pointer.js.map +1 -0
- package/dist/formats/typebox/time.d.ts +6 -0
- package/dist/formats/typebox/time.d.ts.map +1 -0
- package/dist/formats/typebox/time.js +60 -0
- package/dist/formats/typebox/time.js.map +1 -0
- package/dist/formats/typebox/uri.d.ts +6 -0
- package/dist/formats/typebox/uri.d.ts.map +1 -0
- package/dist/formats/typebox/uri.js +36 -0
- package/dist/formats/typebox/uri.js.map +1 -0
- package/dist/formats/typebox/uri_reference.d.ts +6 -0
- package/dist/formats/typebox/uri_reference.d.ts.map +1 -0
- package/dist/formats/typebox/uri_reference.js +36 -0
- package/dist/formats/typebox/uri_reference.js.map +1 -0
- package/dist/formats/typebox/uri_template.d.ts +6 -0
- package/dist/formats/typebox/uri_template.d.ts.map +1 -0
- package/dist/formats/typebox/uri_template.js +37 -0
- package/dist/formats/typebox/uri_template.js.map +1 -0
- package/dist/formats/typebox/url.d.ts +7 -0
- package/dist/formats/typebox/url.d.ts.map +1 -0
- package/dist/formats/typebox/url.js +36 -0
- package/dist/formats/typebox/url.js.map +1 -0
- package/dist/formats/typebox/uuid.d.ts +7 -0
- package/dist/formats/typebox/uuid.d.ts.map +1 -0
- package/dist/formats/typebox/uuid.js +37 -0
- package/dist/formats/typebox/uuid.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/resolver.d.ts +58 -0
- package/dist/resolver.d.ts.map +1 -0
- package/dist/resolver.js +209 -0
- package/dist/resolver.js.map +1 -0
- package/dist/shared.d.ts +9 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +33 -0
- package/dist/shared.js.map +1 -0
- package/dist/typebox-static.d.ts +56 -0
- package/dist/typebox-static.d.ts.map +1 -0
- package/dist/typebox-static.js +7 -0
- package/dist/typebox-static.js.map +1 -0
- package/dist/types.d.ts +48 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/validator.d.ts +48 -0
- package/dist/validator.d.ts.map +1 -0
- package/dist/validator.js +81 -0
- package/dist/validator.js.map +1 -0
- package/package.json +64 -4
package/dist/checks.js
ADDED
|
@@ -0,0 +1,578 @@
|
|
|
1
|
+
// Check factories: each returns a closure that captures only its arguments, never the compiler, so a compiled
|
|
2
|
+
// schema keeps no compile-time state alive. Leaf checks (a type, a const, an enum, bounds) are registered with a code
|
|
3
|
+
// and an argument, so object and array loops run them inline instead of calling them.
|
|
4
|
+
export const ALWAYS = () => true;
|
|
5
|
+
export const NEVER = () => false;
|
|
6
|
+
const IS_STRING = (v) => typeof v === "string";
|
|
7
|
+
const IS_NUMBER = (v) => Number.isFinite(v);
|
|
8
|
+
const IS_INTEGER = (v) => Number.isInteger(v);
|
|
9
|
+
const IS_BOOLEAN = (v) => typeof v === "boolean";
|
|
10
|
+
const IS_NULL = (v) => v === null;
|
|
11
|
+
export const IS_ARRAY = (v) => Array.isArray(v);
|
|
12
|
+
const IS_BYTES = (v) => v instanceof Uint8Array;
|
|
13
|
+
const IS_BIGINT = (v) => typeof v === "bigint";
|
|
14
|
+
const IS_UNDEFINED = (v) => v === undefined;
|
|
15
|
+
export const IS_OBJECT = (v) => isObject(v);
|
|
16
|
+
/** Whether `v` is a JSON object: not null, an array or bytes. */
|
|
17
|
+
export function isObject(v) {
|
|
18
|
+
return typeof v === "object" && v !== null && !Array.isArray(v) && !(v instanceof Uint8Array);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The check of a `type` name. `bytes` (a Uint8Array), `bigint` (TypeBox's `Type.BigInt`) and `undefined` (TypeBox's
|
|
22
|
+
* `Type.Undefined`) extend JSON Schema for values that never pass through JSON. A `number` is finite, as in TypeBox:
|
|
23
|
+
* JSON has no NaN or Infinity, so only a value built in code can be one.
|
|
24
|
+
*/
|
|
25
|
+
export const TYPE_CHECKS = new Map([
|
|
26
|
+
["string", IS_STRING],
|
|
27
|
+
["number", IS_NUMBER],
|
|
28
|
+
["integer", IS_INTEGER],
|
|
29
|
+
["boolean", IS_BOOLEAN],
|
|
30
|
+
["null", IS_NULL],
|
|
31
|
+
["array", IS_ARRAY],
|
|
32
|
+
["object", IS_OBJECT],
|
|
33
|
+
["bytes", IS_BYTES],
|
|
34
|
+
["bigint", IS_BIGINT],
|
|
35
|
+
["undefined", IS_UNDEFINED],
|
|
36
|
+
]);
|
|
37
|
+
const leaves = new WeakMap([
|
|
38
|
+
[IS_STRING, [1, undefined]],
|
|
39
|
+
[IS_NUMBER, [2, undefined]],
|
|
40
|
+
[IS_INTEGER, [3, undefined]],
|
|
41
|
+
[IS_BOOLEAN, [4, undefined]],
|
|
42
|
+
[IS_NULL, [5, undefined]],
|
|
43
|
+
[ALWAYS, [6, undefined]],
|
|
44
|
+
]);
|
|
45
|
+
/** The leaf form of `check`, undefined when it is not a leaf. */
|
|
46
|
+
export function leafOf(check) {
|
|
47
|
+
return leaves.get(check);
|
|
48
|
+
}
|
|
49
|
+
function leaf(code, arg, check) {
|
|
50
|
+
leaves.set(check, [code, arg]);
|
|
51
|
+
return check;
|
|
52
|
+
}
|
|
53
|
+
/** Bounds of a number or a string length leaf. */
|
|
54
|
+
class Bounds {
|
|
55
|
+
min;
|
|
56
|
+
max;
|
|
57
|
+
xmin;
|
|
58
|
+
xmax;
|
|
59
|
+
constructor(min, max, xmin, xmax) {
|
|
60
|
+
this.min = min;
|
|
61
|
+
this.max = max;
|
|
62
|
+
this.xmin = xmin;
|
|
63
|
+
this.xmax = xmax;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
// Codes 1-6 are the bare types and `true`; the others read their argument.
|
|
67
|
+
function leafOk(code, x, arg) {
|
|
68
|
+
switch (code) {
|
|
69
|
+
case 1:
|
|
70
|
+
return typeof x === "string";
|
|
71
|
+
case 2:
|
|
72
|
+
return Number.isFinite(x);
|
|
73
|
+
case 3:
|
|
74
|
+
return Number.isInteger(x);
|
|
75
|
+
case 4:
|
|
76
|
+
return typeof x === "boolean";
|
|
77
|
+
case 5:
|
|
78
|
+
return x === null;
|
|
79
|
+
case 7:
|
|
80
|
+
return x === arg;
|
|
81
|
+
case 8: {
|
|
82
|
+
const list = arg;
|
|
83
|
+
for (let i = 0; i < list.length; i++)
|
|
84
|
+
if (list[i] === x)
|
|
85
|
+
return true;
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
case 9:
|
|
89
|
+
return (typeBits(x) & arg) !== 0;
|
|
90
|
+
case 10:
|
|
91
|
+
return Number.isInteger(x) && inBounds(x, arg);
|
|
92
|
+
case 11:
|
|
93
|
+
return Number.isFinite(x) && inBounds(x, arg);
|
|
94
|
+
case 12:
|
|
95
|
+
return typeof x === "string" && lengthOk(x, arg.min, arg.max);
|
|
96
|
+
case 13:
|
|
97
|
+
return typeof x === "string" && arg.test(x);
|
|
98
|
+
default:
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function inBounds(x, b) {
|
|
103
|
+
return x >= b.min && x <= b.max && x > b.xmin && x < b.xmax;
|
|
104
|
+
}
|
|
105
|
+
/** Whether a combined object or array check also checks the type: not at all, strictly, or passing other types. */
|
|
106
|
+
export const GUARD_NONE = 0;
|
|
107
|
+
export const GUARD_STRICT = 1;
|
|
108
|
+
export const GUARD_LOOSE = 2;
|
|
109
|
+
/** Flags of a declared property in an object check's entries: its leaf code and two bits. */
|
|
110
|
+
export const CODE = 15;
|
|
111
|
+
export const REQUIRED = 16;
|
|
112
|
+
export const INHERITED = 32;
|
|
113
|
+
/** All of `parts`; two and three parts get closures without a loop. */
|
|
114
|
+
export function and(parts) {
|
|
115
|
+
switch (parts.length) {
|
|
116
|
+
case 0:
|
|
117
|
+
return ALWAYS;
|
|
118
|
+
case 1:
|
|
119
|
+
return parts[0];
|
|
120
|
+
case 2: {
|
|
121
|
+
const [a, b] = parts;
|
|
122
|
+
return (v) => a(v) && b(v);
|
|
123
|
+
}
|
|
124
|
+
case 3: {
|
|
125
|
+
const [a, b, c] = parts;
|
|
126
|
+
return (v) => a(v) && b(v) && c(v);
|
|
127
|
+
}
|
|
128
|
+
default:
|
|
129
|
+
return (v) => {
|
|
130
|
+
for (let i = 0; i < parts.length; i++)
|
|
131
|
+
if (!parts[i](v))
|
|
132
|
+
return false;
|
|
133
|
+
return true;
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
/** A check whose implementation is set later: the indirection a recursive reference goes through. */
|
|
138
|
+
export function indirect(slot) {
|
|
139
|
+
return (v) => slot.check(v);
|
|
140
|
+
}
|
|
141
|
+
/** `check` with `uri` pushed onto the dynamic scope while it runs (only for schemas with `$dynamicRef`). */
|
|
142
|
+
export function scopedCheck(scope, uri, check) {
|
|
143
|
+
return (v) => {
|
|
144
|
+
scope.push(uri);
|
|
145
|
+
const ok = check(v);
|
|
146
|
+
scope.pop();
|
|
147
|
+
return ok;
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
/** Any of the named types. */
|
|
151
|
+
export function typeCheck(types) {
|
|
152
|
+
if (types.length === 1)
|
|
153
|
+
return (typeof types[0] === "string" ? TYPE_CHECKS.get(types[0]) : undefined) ?? NEVER;
|
|
154
|
+
return maskCheck(typeMask(types));
|
|
155
|
+
}
|
|
156
|
+
const TYPE_BITS = new Map([
|
|
157
|
+
["string", 1],
|
|
158
|
+
["number", 2],
|
|
159
|
+
["integer", 4],
|
|
160
|
+
["boolean", 8],
|
|
161
|
+
["null", 16],
|
|
162
|
+
["array", 32],
|
|
163
|
+
["object", 64],
|
|
164
|
+
["bytes", 128],
|
|
165
|
+
["bigint", 256],
|
|
166
|
+
["undefined", 512],
|
|
167
|
+
]);
|
|
168
|
+
/** The bits of the named types; unknown names add none. */
|
|
169
|
+
export function typeMask(types) {
|
|
170
|
+
let mask = 0;
|
|
171
|
+
for (const t of types)
|
|
172
|
+
if (typeof t === "string")
|
|
173
|
+
mask |= TYPE_BITS.get(t) ?? 0;
|
|
174
|
+
return mask;
|
|
175
|
+
}
|
|
176
|
+
/** The type bits of `v`: an integer has the bits of `number` and `integer`; NaN and Infinity have neither. */
|
|
177
|
+
function typeBits(v) {
|
|
178
|
+
switch (typeof v) {
|
|
179
|
+
case "string":
|
|
180
|
+
return 1;
|
|
181
|
+
case "number":
|
|
182
|
+
return Number.isInteger(v) ? 6 : Number.isFinite(v) ? 2 : 0;
|
|
183
|
+
case "boolean":
|
|
184
|
+
return 8;
|
|
185
|
+
case "object":
|
|
186
|
+
return v === null ? 16 : Array.isArray(v) ? 32 : v instanceof Uint8Array ? 128 : 64;
|
|
187
|
+
case "bigint":
|
|
188
|
+
return 256;
|
|
189
|
+
case "undefined":
|
|
190
|
+
return 512;
|
|
191
|
+
default:
|
|
192
|
+
return 0;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
function maskCheck(mask) {
|
|
196
|
+
return leaf(9, mask, (v) => (typeBits(v) & mask) !== 0);
|
|
197
|
+
}
|
|
198
|
+
/** `anyOf` whose bare-type branches have the types of `mask`: those by one type test, the others by their checks. */
|
|
199
|
+
export function maskedAnyCheck(mask, checks) {
|
|
200
|
+
if (checks.length === 0)
|
|
201
|
+
return maskCheck(mask);
|
|
202
|
+
const rest = checks.length === 1 ? checks[0] : anyCheck(checks);
|
|
203
|
+
return (v) => (typeBits(v) & mask) !== 0 || rest(v);
|
|
204
|
+
}
|
|
205
|
+
/** A Uint8Array within the length bounds. */
|
|
206
|
+
export function bytesCheck(min, max) {
|
|
207
|
+
return (v) => v instanceof Uint8Array && v.length >= min && v.length <= max;
|
|
208
|
+
}
|
|
209
|
+
/** The number of Unicode code points of `s`: JSON Schema string lengths count code points, not UTF-16 units. */
|
|
210
|
+
export function codePoints(s) {
|
|
211
|
+
let n = 0;
|
|
212
|
+
for (let i = 0; i < s.length; i++, n++) {
|
|
213
|
+
const c = s.charCodeAt(i);
|
|
214
|
+
// A high surrogate starts a pair only when a low surrogate follows; an unpaired one is a code point of its own.
|
|
215
|
+
if (c >= 0xd800 && c <= 0xdbff && i + 1 < s.length) {
|
|
216
|
+
const next = s.charCodeAt(i + 1);
|
|
217
|
+
if (next >= 0xdc00 && next <= 0xdfff)
|
|
218
|
+
i++;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
return n;
|
|
222
|
+
}
|
|
223
|
+
// UTF-16 units bound code points from both sides (units / 2 <= points <= units), so most strings need no count.
|
|
224
|
+
function lengthOk(s, min, max) {
|
|
225
|
+
const units = s.length;
|
|
226
|
+
if (units < min)
|
|
227
|
+
return false;
|
|
228
|
+
if (units < 2 * min && codePoints(s) < min)
|
|
229
|
+
return false;
|
|
230
|
+
return units <= max || codePoints(s) <= max;
|
|
231
|
+
}
|
|
232
|
+
/** The string keywords: length bounds, pattern and format. */
|
|
233
|
+
export function stringCheck(strict, min, max, re, format) {
|
|
234
|
+
if (re !== undefined && min === 0 && max === Number.POSITIVE_INFINITY && format === undefined) {
|
|
235
|
+
return strict
|
|
236
|
+
? leaf(13, re, (v) => typeof v === "string" && re.test(v))
|
|
237
|
+
: (v) => typeof v !== "string" || re.test(v);
|
|
238
|
+
}
|
|
239
|
+
if (re === undefined && format === undefined) {
|
|
240
|
+
return strict
|
|
241
|
+
? leaf(12, new Bounds(min, max, 0, 0), (v) => typeof v === "string" && lengthOk(v, min, max))
|
|
242
|
+
: (v) => typeof v !== "string" || lengthOk(v, min, max);
|
|
243
|
+
}
|
|
244
|
+
return (v) => {
|
|
245
|
+
if (typeof v !== "string")
|
|
246
|
+
return !strict;
|
|
247
|
+
return lengthOk(v, min, max) && (re === undefined || re.test(v)) && (format === undefined || format(v));
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* The number keywords, for numbers and bigints alike (as TypeBox applies them): bounds of either kind compare with
|
|
252
|
+
* values of either kind. `mode`: 0 passes other types, 1 requires a number, 2 an integer, 3 a bigint.
|
|
253
|
+
*/
|
|
254
|
+
export function numberCheck(mode, min, max, xmin, xmax, multipleOf) {
|
|
255
|
+
const check = (v) => {
|
|
256
|
+
if (typeof v !== "number" && typeof v !== "bigint")
|
|
257
|
+
return mode === 0;
|
|
258
|
+
if (mode === 3 ? typeof v !== "bigint" : mode !== 0 && !Number.isFinite(v))
|
|
259
|
+
return false;
|
|
260
|
+
if (mode === 2 && !Number.isInteger(v))
|
|
261
|
+
return false;
|
|
262
|
+
return v >= min && v <= max && v > xmin && v < xmax && (multipleOf === undefined || isMultiple(v, multipleOf));
|
|
263
|
+
};
|
|
264
|
+
const plain = typeof min === "number" && typeof max === "number" && typeof xmin === "number" && typeof xmax === "number";
|
|
265
|
+
if (mode === 0 || mode === 3 || multipleOf !== undefined || !plain)
|
|
266
|
+
return check;
|
|
267
|
+
return leaf(mode === 2 ? 10 : 11, new Bounds(min, max, xmin, xmax), check);
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Whether `v` is a multiple of `d`, exactly for decimals: 0.0075 / 0.0001 is 74.99999999999999 in floating point. With
|
|
271
|
+
* a bigint on either side, exact integer arithmetic; a bigint is no multiple of 0 or of a fraction.
|
|
272
|
+
*
|
|
273
|
+
* Deliberately unlike TypeBox, which throws there (`BigInt(0.5)`, division by zero): a check answers for every value
|
|
274
|
+
* and never throws, and no real schema pairs a bigint with a fractional or zero `multipleOf`.
|
|
275
|
+
*/
|
|
276
|
+
export function isMultiple(v, d) {
|
|
277
|
+
if (typeof v === "bigint" || typeof d === "bigint") {
|
|
278
|
+
if ((typeof v === "number" && !Number.isInteger(v)) || (typeof d === "number" && !Number.isInteger(d)))
|
|
279
|
+
return false;
|
|
280
|
+
const divisor = BigInt(d);
|
|
281
|
+
return divisor !== 0n && BigInt(v) % divisor === 0n;
|
|
282
|
+
}
|
|
283
|
+
const q = v / d;
|
|
284
|
+
if (Number.isInteger(q))
|
|
285
|
+
return true;
|
|
286
|
+
if (!Number.isFinite(q))
|
|
287
|
+
return v % d === 0;
|
|
288
|
+
const [vc, ve] = decimal(v);
|
|
289
|
+
const [dc, de] = decimal(d);
|
|
290
|
+
return ve >= de ? (vc * 10n ** BigInt(ve - de)) % dc === 0n : vc % (dc * 10n ** BigInt(de - ve)) === 0n;
|
|
291
|
+
}
|
|
292
|
+
function decimal(x) {
|
|
293
|
+
const [mantissa, exponent = "0"] = Math.abs(x).toString().split("e");
|
|
294
|
+
const point = mantissa.indexOf(".");
|
|
295
|
+
const fraction = point < 0 ? 0 : mantissa.length - point - 1;
|
|
296
|
+
return [BigInt(mantissa.replace(".", "")), Number(exponent) - fraction];
|
|
297
|
+
}
|
|
298
|
+
/** `inner` for objects; other values pass unless `strict`. */
|
|
299
|
+
export function guardObject(inner, strict) {
|
|
300
|
+
return strict ? (v) => isObject(v) && inner(v) : (v) => !isObject(v) || inner(v);
|
|
301
|
+
}
|
|
302
|
+
/** `inner` for arrays; other values pass unless `strict`. */
|
|
303
|
+
export function guardArray(inner, strict) {
|
|
304
|
+
return strict ? (v) => Array.isArray(v) && inner(v) : (v) => !Array.isArray(v) || inner(v);
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* An object with declared properties: `entries` is `[key, check, flags]` per property. The value's own keys are
|
|
308
|
+
* walked with for...in (whose `o[k]` V8 reads from the enum cache, unlike a load by a name from a list), each found
|
|
309
|
+
* among the declared names; `closed` rejects any other key. A property whose value is `undefined` counts as absent.
|
|
310
|
+
*/
|
|
311
|
+
export function declaredObject(entries, requiredCount, closed, guard) {
|
|
312
|
+
const n = entries.length;
|
|
313
|
+
return (v) => {
|
|
314
|
+
if (guard !== GUARD_NONE && !isObject(v))
|
|
315
|
+
return guard === GUARD_LOOSE;
|
|
316
|
+
// Guarded: by the check above, or by the caller for GUARD_NONE.
|
|
317
|
+
const o = v;
|
|
318
|
+
let required = 0;
|
|
319
|
+
let next = 0;
|
|
320
|
+
for (const k in o) {
|
|
321
|
+
// Keys usually come in the declared order: try the entry after the last match before searching.
|
|
322
|
+
let i = next;
|
|
323
|
+
if (entries[i] !== k) {
|
|
324
|
+
i = 0;
|
|
325
|
+
while (i < n && entries[i] !== k)
|
|
326
|
+
i += 3;
|
|
327
|
+
if (i === n) {
|
|
328
|
+
if (closed)
|
|
329
|
+
return false;
|
|
330
|
+
continue;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
next = i + 3;
|
|
334
|
+
const x = o[k];
|
|
335
|
+
const f = entries[i + 2];
|
|
336
|
+
// An optional property set to undefined counts as absent; a required one is present, and its schema decides
|
|
337
|
+
// whether undefined is a value of it (TypeBox's Type.Undefined, Unknown, Any).
|
|
338
|
+
if (x === undefined && !(f & REQUIRED))
|
|
339
|
+
continue;
|
|
340
|
+
const c = f & CODE;
|
|
341
|
+
if (c !== 0 ? !leafOk(c, x, entries[i + 1]) : !entries[i + 1](x))
|
|
342
|
+
return false;
|
|
343
|
+
if (f & REQUIRED)
|
|
344
|
+
required++;
|
|
345
|
+
}
|
|
346
|
+
return required === requiredCount;
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
/** An object with declared properties, required keys not declared, pattern properties and additional properties. */
|
|
350
|
+
export function openObject(entries, keys, extraRequired, patterns, additional, guard) {
|
|
351
|
+
const known = patterns.length > 0 || additional !== undefined ? new Set(keys) : undefined;
|
|
352
|
+
return (v) => {
|
|
353
|
+
if (guard !== GUARD_NONE && !isObject(v))
|
|
354
|
+
return guard === GUARD_LOOSE;
|
|
355
|
+
const o = v;
|
|
356
|
+
for (let i = 0; i < entries.length; i += 3) {
|
|
357
|
+
const k = entries[i];
|
|
358
|
+
const x = o[k];
|
|
359
|
+
const f = entries[i + 2];
|
|
360
|
+
// Absent, or an optional property set to undefined (which counts as absent); see declaredObject.
|
|
361
|
+
if ((x === undefined && !(f & REQUIRED && Object.hasOwn(o, k))) || (f & INHERITED && !Object.hasOwn(o, k))) {
|
|
362
|
+
if (f & REQUIRED)
|
|
363
|
+
return false;
|
|
364
|
+
continue;
|
|
365
|
+
}
|
|
366
|
+
const c = f & CODE;
|
|
367
|
+
if (c !== 0 ? !leafOk(c, x, entries[i + 1]) : !entries[i + 1](x))
|
|
368
|
+
return false;
|
|
369
|
+
}
|
|
370
|
+
for (let i = 0; i < extraRequired.length; i++)
|
|
371
|
+
if (!Object.hasOwn(o, extraRequired[i]))
|
|
372
|
+
return false;
|
|
373
|
+
if (known === undefined)
|
|
374
|
+
return true;
|
|
375
|
+
for (const k of Object.keys(o)) {
|
|
376
|
+
let matched = known.has(k);
|
|
377
|
+
for (let i = 0; i < patterns.length; i++) {
|
|
378
|
+
if (patterns[i][0].test(k)) {
|
|
379
|
+
matched = true;
|
|
380
|
+
if (!patterns[i][1](o[k]))
|
|
381
|
+
return false;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
if (!matched && additional !== undefined && !additional(o[k]))
|
|
385
|
+
return false;
|
|
386
|
+
}
|
|
387
|
+
return true;
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
/** Every property name passes `check` (`v` is an object). */
|
|
391
|
+
export function propertyNamesCheck(check) {
|
|
392
|
+
return (v) => {
|
|
393
|
+
for (const k in v)
|
|
394
|
+
if (!check(k))
|
|
395
|
+
return false;
|
|
396
|
+
return true;
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
/** `minProperties` and `maxProperties` (`v` is an object). */
|
|
400
|
+
export function propertyCountCheck(min, max) {
|
|
401
|
+
return (v) => {
|
|
402
|
+
let n = 0;
|
|
403
|
+
for (const _ in v)
|
|
404
|
+
n++;
|
|
405
|
+
return n >= min && n <= max;
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
/** `dependentRequired` (`v` is an object). */
|
|
409
|
+
export function dependentRequiredCheck(entries) {
|
|
410
|
+
return (v) => {
|
|
411
|
+
const o = v;
|
|
412
|
+
for (const [k, list] of entries)
|
|
413
|
+
if (Object.hasOwn(o, k))
|
|
414
|
+
for (const r of list)
|
|
415
|
+
if (!Object.hasOwn(o, r))
|
|
416
|
+
return false;
|
|
417
|
+
return true;
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
/** `dependentSchemas` (`v` is an object). */
|
|
421
|
+
export function dependentSchemasCheck(entries) {
|
|
422
|
+
return (v) => {
|
|
423
|
+
for (const [k, check] of entries)
|
|
424
|
+
if (Object.hasOwn(v, k) && !check(v))
|
|
425
|
+
return false;
|
|
426
|
+
return true;
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
const NO_LEAF = [0, undefined];
|
|
430
|
+
/** The common array: guard, length bounds, prefix items and the items after them, in one closure. */
|
|
431
|
+
export function listCheck(guard, min, max, prefix, rest) {
|
|
432
|
+
const n = prefix.length;
|
|
433
|
+
const [code, arg] = (rest === undefined ? undefined : leafOf(rest)) ?? NO_LEAF;
|
|
434
|
+
return (v) => {
|
|
435
|
+
if (!Array.isArray(v))
|
|
436
|
+
return guard === GUARD_LOOSE;
|
|
437
|
+
const length = v.length;
|
|
438
|
+
if (length < min || length > max)
|
|
439
|
+
return false;
|
|
440
|
+
const m = length < n ? length : n;
|
|
441
|
+
for (let i = 0; i < m; i++)
|
|
442
|
+
if (!prefix[i](v[i]))
|
|
443
|
+
return false;
|
|
444
|
+
if (rest === undefined)
|
|
445
|
+
return true;
|
|
446
|
+
if (code !== 0) {
|
|
447
|
+
for (let i = n; i < length; i++)
|
|
448
|
+
if (!leafOk(code, v[i], arg))
|
|
449
|
+
return false;
|
|
450
|
+
return true;
|
|
451
|
+
}
|
|
452
|
+
for (let i = n; i < length; i++)
|
|
453
|
+
if (!rest(v[i]))
|
|
454
|
+
return false;
|
|
455
|
+
return true;
|
|
456
|
+
};
|
|
457
|
+
}
|
|
458
|
+
/** Prefix items and the items after them (`v` is an array). */
|
|
459
|
+
export function itemsCheck(prefix, rest) {
|
|
460
|
+
return listCheck(GUARD_NONE, 0, Number.POSITIVE_INFINITY, prefix, rest);
|
|
461
|
+
}
|
|
462
|
+
/** `minItems` and `maxItems` (`v` is an array). */
|
|
463
|
+
export function lengthCheck(min, max) {
|
|
464
|
+
return (v) => v.length >= min && v.length <= max;
|
|
465
|
+
}
|
|
466
|
+
/** `contains` with its bounds (`v` is an array). */
|
|
467
|
+
export function containsCheck(check, min, max) {
|
|
468
|
+
return (v) => {
|
|
469
|
+
const list = v;
|
|
470
|
+
let n = 0;
|
|
471
|
+
for (let i = 0; i < list.length; i++)
|
|
472
|
+
if (check(list[i]) && ++n > max)
|
|
473
|
+
return false;
|
|
474
|
+
return n >= min;
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
/** `uniqueItems` (`v` is an array). */
|
|
478
|
+
export function uniqueCheck(v) {
|
|
479
|
+
const list = v;
|
|
480
|
+
for (let i = 1; i < list.length; i++)
|
|
481
|
+
for (let j = 0; j < i; j++)
|
|
482
|
+
if (deepEqual(list[i], list[j]))
|
|
483
|
+
return false;
|
|
484
|
+
return true;
|
|
485
|
+
}
|
|
486
|
+
/** `enum`: up to 8 primitives by a scan, more by a Set, objects and arrays by deep equality. */
|
|
487
|
+
export function enumCheck(values) {
|
|
488
|
+
const primitives = values.filter((x) => typeof x !== "object" || x === null);
|
|
489
|
+
if (primitives.length === values.length && primitives.length <= 8) {
|
|
490
|
+
return leaf(8, primitives, (v) => {
|
|
491
|
+
for (let i = 0; i < primitives.length; i++)
|
|
492
|
+
if (primitives[i] === v)
|
|
493
|
+
return true;
|
|
494
|
+
return false;
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
const set = new Set(primitives);
|
|
498
|
+
const objects = values.filter((x) => typeof x === "object" && x !== null);
|
|
499
|
+
return (v) => set.has(v) || (typeof v === "object" && objects.some((o) => deepEqual(v, o)));
|
|
500
|
+
}
|
|
501
|
+
/** `const`. */
|
|
502
|
+
export function constCheck(value) {
|
|
503
|
+
if (typeof value !== "object" || value === null)
|
|
504
|
+
return leaf(7, value, (v) => v === value);
|
|
505
|
+
return (v) => deepEqual(v, value);
|
|
506
|
+
}
|
|
507
|
+
/** `anyOf`. */
|
|
508
|
+
export function anyCheck(checks) {
|
|
509
|
+
return (v) => {
|
|
510
|
+
for (let i = 0; i < checks.length; i++)
|
|
511
|
+
if (checks[i](v))
|
|
512
|
+
return true;
|
|
513
|
+
return false;
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
/** `oneOf`. */
|
|
517
|
+
export function oneCheck(checks) {
|
|
518
|
+
return (v) => {
|
|
519
|
+
let n = 0;
|
|
520
|
+
for (let i = 0; i < checks.length; i++)
|
|
521
|
+
if (checks[i](v) && ++n > 1)
|
|
522
|
+
return false;
|
|
523
|
+
return n === 1;
|
|
524
|
+
};
|
|
525
|
+
}
|
|
526
|
+
/** `not`. */
|
|
527
|
+
export function notCheck(check) {
|
|
528
|
+
return (v) => !check(v);
|
|
529
|
+
}
|
|
530
|
+
/** `if`, `then` and `else`. */
|
|
531
|
+
export function ifCheck(cond, then, otherwise) {
|
|
532
|
+
return (v) => (cond(v) ? then(v) : otherwise(v));
|
|
533
|
+
}
|
|
534
|
+
/** A union of objects tagged by a const on `key`: the tag selects the one branch that can match. */
|
|
535
|
+
export function taggedCheck(key, tags, checks) {
|
|
536
|
+
return (v) => {
|
|
537
|
+
if (!isObject(v))
|
|
538
|
+
return false;
|
|
539
|
+
const tag = v[key];
|
|
540
|
+
for (let i = 0; i < tags.length; i++)
|
|
541
|
+
if (tags[i] === tag)
|
|
542
|
+
return checks[i](v);
|
|
543
|
+
return false;
|
|
544
|
+
};
|
|
545
|
+
}
|
|
546
|
+
/**
|
|
547
|
+
* JSON equality, as `const`, `enum` and `uniqueItems` compare: the same primitives, arrays with equal items in order,
|
|
548
|
+
* objects with the same keys and equal values (key order does not matter).
|
|
549
|
+
*/
|
|
550
|
+
export function deepEqual(a, b) {
|
|
551
|
+
if (a === b)
|
|
552
|
+
return true;
|
|
553
|
+
if (typeof a !== "object" || typeof b !== "object" || a === null || b === null)
|
|
554
|
+
return false;
|
|
555
|
+
const array = Array.isArray(a);
|
|
556
|
+
if (array !== Array.isArray(b))
|
|
557
|
+
return false;
|
|
558
|
+
if (array) {
|
|
559
|
+
const x = a;
|
|
560
|
+
const y = b;
|
|
561
|
+
if (x.length !== y.length)
|
|
562
|
+
return false;
|
|
563
|
+
for (let i = 0; i < x.length; i++)
|
|
564
|
+
if (!deepEqual(x[i], y[i]))
|
|
565
|
+
return false;
|
|
566
|
+
return true;
|
|
567
|
+
}
|
|
568
|
+
const x = a;
|
|
569
|
+
const y = b;
|
|
570
|
+
const keys = Object.keys(x);
|
|
571
|
+
if (keys.length !== Object.keys(y).length)
|
|
572
|
+
return false;
|
|
573
|
+
for (const k of keys)
|
|
574
|
+
if (!Object.hasOwn(y, k) || !deepEqual(x[k], y[k]))
|
|
575
|
+
return false;
|
|
576
|
+
return true;
|
|
577
|
+
}
|
|
578
|
+
//# sourceMappingURL=checks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checks.js","sourceRoot":"","sources":["../src/checks.ts"],"names":[],"mappings":"AAAA,8GAA8G;AAC9G,sHAAsH;AACtH,sFAAsF;AAItF,MAAM,CAAC,MAAM,MAAM,GAAU,GAAG,EAAE,CAAC,IAAI,CAAC;AACxC,MAAM,CAAC,MAAM,KAAK,GAAU,GAAG,EAAE,CAAC,KAAK,CAAC;AACxC,MAAM,SAAS,GAAU,CAAC,CAAC,EAAE,EAAE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E,CAAC,CAAC,CAAC,CAAC,CAAC;gBAAE,OAAO,KAAK,CAAC;QAC5E,OAAO,IAAI,CAAC;IACb,CAAC;IACD,MAAM,CAAC,GAAG,CAA4B,CAAC;IACvC,MAAM,CAAC,GAAG,CAA4B,CAAC;IACvC,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC5B,IAAI,IAAI,CAAC,MAAM,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IACxD,KAAK,MAAM,CAAC,IAAI,IAAI;QAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;YAAE,OAAO,KAAK,CAAC;IACvF,OAAO,IAAI,CAAC;AACb,CAAC","sourcesContent":["// Check factories: each returns a closure that captures only its arguments, never the compiler, so a compiled\n// schema keeps no compile-time state alive. Leaf checks (a type, a const, an enum, bounds) are registered with a code\n// and an argument, so object and array loops run them inline instead of calling them.\n\nimport type { Check } from \"./types.ts\";\n\nexport const ALWAYS: Check = () => true;\nexport const NEVER: Check = () => false;\nconst IS_STRING: Check = (v) => typeof v === \"string\";\nconst IS_NUMBER: Check = (v) => Number.isFinite(v);\nconst IS_INTEGER: Check = (v) => Number.isInteger(v);\nconst IS_BOOLEAN: Check = (v) => typeof v === \"boolean\";\nconst IS_NULL: Check = (v) => v === null;\nexport const IS_ARRAY: Check = (v) => Array.isArray(v);\nconst IS_BYTES: Check = (v) => v instanceof Uint8Array;\nconst IS_BIGINT: Check = (v) => typeof v === \"bigint\";\nconst IS_UNDEFINED: Check = (v) => v === undefined;\nexport const IS_OBJECT: Check = (v) => isObject(v);\n\n/** Whether `v` is a JSON object: not null, an array or bytes. */\nexport function isObject(v: unknown): v is Record<string, unknown> {\n\treturn typeof v === \"object\" && v !== null && !Array.isArray(v) && !(v instanceof Uint8Array);\n}\n\n/**\n * The check of a `type` name. `bytes` (a Uint8Array), `bigint` (TypeBox's `Type.BigInt`) and `undefined` (TypeBox's\n * `Type.Undefined`) extend JSON Schema for values that never pass through JSON. A `number` is finite, as in TypeBox:\n * JSON has no NaN or Infinity, so only a value built in code can be one.\n */\nexport const TYPE_CHECKS: ReadonlyMap<string, Check> = new Map([\n\t[\"string\", IS_STRING],\n\t[\"number\", IS_NUMBER],\n\t[\"integer\", IS_INTEGER],\n\t[\"boolean\", IS_BOOLEAN],\n\t[\"null\", IS_NULL],\n\t[\"array\", IS_ARRAY],\n\t[\"object\", IS_OBJECT],\n\t[\"bytes\", IS_BYTES],\n\t[\"bigint\", IS_BIGINT],\n\t[\"undefined\", IS_UNDEFINED],\n]);\n\n/**\n * A leaf check as a code and its argument, which object and array loops run by `leafOk` instead of calling the\n * check: a call through a list of checks is not inlined, a switch is.\n */\nexport type Leaf = readonly [code: number, arg: unknown];\n\nconst leaves = new WeakMap<Check, Leaf>([\n\t[IS_STRING, [1, undefined]],\n\t[IS_NUMBER, [2, undefined]],\n\t[IS_INTEGER, [3, undefined]],\n\t[IS_BOOLEAN, [4, undefined]],\n\t[IS_NULL, [5, undefined]],\n\t[ALWAYS, [6, undefined]],\n]);\n\n/** The leaf form of `check`, undefined when it is not a leaf. */\nexport function leafOf(check: Check): Leaf | undefined {\n\treturn leaves.get(check);\n}\n\nfunction leaf(code: number, arg: unknown, check: Check): Check {\n\tleaves.set(check, [code, arg]);\n\treturn check;\n}\n\n/** Bounds of a number or a string length leaf. */\nclass Bounds {\n\treadonly min: number;\n\treadonly max: number;\n\treadonly xmin: number;\n\treadonly xmax: number;\n\n\tconstructor(min: number, max: number, xmin: number, xmax: number) {\n\t\tthis.min = min;\n\t\tthis.max = max;\n\t\tthis.xmin = xmin;\n\t\tthis.xmax = xmax;\n\t}\n}\n\n// Codes 1-6 are the bare types and `true`; the others read their argument.\nfunction leafOk(code: number, x: unknown, arg: unknown): boolean {\n\tswitch (code) {\n\t\tcase 1:\n\t\t\treturn typeof x === \"string\";\n\t\tcase 2:\n\t\t\treturn Number.isFinite(x);\n\t\tcase 3:\n\t\t\treturn Number.isInteger(x);\n\t\tcase 4:\n\t\t\treturn typeof x === \"boolean\";\n\t\tcase 5:\n\t\t\treturn x === null;\n\t\tcase 7:\n\t\t\treturn x === arg;\n\t\tcase 8: {\n\t\t\tconst list = arg as readonly unknown[];\n\t\t\tfor (let i = 0; i < list.length; i++) if (list[i] === x) return true;\n\t\t\treturn false;\n\t\t}\n\t\tcase 9:\n\t\t\treturn (typeBits(x) & (arg as number)) !== 0;\n\t\tcase 10:\n\t\t\treturn Number.isInteger(x) && inBounds(x as number, arg as Bounds);\n\t\tcase 11:\n\t\t\treturn Number.isFinite(x) && inBounds(x as number, arg as Bounds);\n\t\tcase 12:\n\t\t\treturn typeof x === \"string\" && lengthOk(x, (arg as Bounds).min, (arg as Bounds).max);\n\t\tcase 13:\n\t\t\treturn typeof x === \"string\" && (arg as RegExp).test(x);\n\t\tdefault:\n\t\t\treturn true;\n\t}\n}\n\nfunction inBounds(x: number, b: Bounds): boolean {\n\treturn x >= b.min && x <= b.max && x > b.xmin && x < b.xmax;\n}\n\n/** Whether a combined object or array check also checks the type: not at all, strictly, or passing other types. */\nexport const GUARD_NONE = 0;\nexport const GUARD_STRICT = 1;\nexport const GUARD_LOOSE = 2;\nexport type Guard = typeof GUARD_NONE | typeof GUARD_STRICT | typeof GUARD_LOOSE;\n\n/** Flags of a declared property in an object check's entries: its leaf code and two bits. */\nexport const CODE = 15;\nexport const REQUIRED = 16;\nexport const INHERITED = 32;\n\n/** All of `parts`; two and three parts get closures without a loop. */\nexport function and(parts: readonly Check[]): Check {\n\tswitch (parts.length) {\n\t\tcase 0:\n\t\t\treturn ALWAYS;\n\t\tcase 1:\n\t\t\treturn parts[0];\n\t\tcase 2: {\n\t\t\tconst [a, b] = parts;\n\t\t\treturn (v) => a(v) && b(v);\n\t\t}\n\t\tcase 3: {\n\t\t\tconst [a, b, c] = parts;\n\t\t\treturn (v) => a(v) && b(v) && c(v);\n\t\t}\n\t\tdefault:\n\t\t\treturn (v) => {\n\t\t\t\tfor (let i = 0; i < parts.length; i++) if (!parts[i](v)) return false;\n\t\t\t\treturn true;\n\t\t\t};\n\t}\n}\n\n/** A check whose implementation is set later: the indirection a recursive reference goes through. */\nexport function indirect(slot: { check: Check | undefined }): Check {\n\treturn (v) => (slot.check as Check)(v);\n}\n\n/** `check` with `uri` pushed onto the dynamic scope while it runs (only for schemas with `$dynamicRef`). */\nexport function scopedCheck(scope: string[], uri: string, check: Check): Check {\n\treturn (v) => {\n\t\tscope.push(uri);\n\t\tconst ok = check(v);\n\t\tscope.pop();\n\t\treturn ok;\n\t};\n}\n\n/** Any of the named types. */\nexport function typeCheck(types: readonly unknown[]): Check {\n\tif (types.length === 1) return (typeof types[0] === \"string\" ? TYPE_CHECKS.get(types[0]) : undefined) ?? NEVER;\n\treturn maskCheck(typeMask(types));\n}\n\nconst TYPE_BITS: ReadonlyMap<string, number> = new Map([\n\t[\"string\", 1],\n\t[\"number\", 2],\n\t[\"integer\", 4],\n\t[\"boolean\", 8],\n\t[\"null\", 16],\n\t[\"array\", 32],\n\t[\"object\", 64],\n\t[\"bytes\", 128],\n\t[\"bigint\", 256],\n\t[\"undefined\", 512],\n]);\n\n/** The bits of the named types; unknown names add none. */\nexport function typeMask(types: readonly unknown[]): number {\n\tlet mask = 0;\n\tfor (const t of types) if (typeof t === \"string\") mask |= TYPE_BITS.get(t) ?? 0;\n\treturn mask;\n}\n\n/** The type bits of `v`: an integer has the bits of `number` and `integer`; NaN and Infinity have neither. */\nfunction typeBits(v: unknown): number {\n\tswitch (typeof v) {\n\t\tcase \"string\":\n\t\t\treturn 1;\n\t\tcase \"number\":\n\t\t\treturn Number.isInteger(v) ? 6 : Number.isFinite(v) ? 2 : 0;\n\t\tcase \"boolean\":\n\t\t\treturn 8;\n\t\tcase \"object\":\n\t\t\treturn v === null ? 16 : Array.isArray(v) ? 32 : v instanceof Uint8Array ? 128 : 64;\n\t\tcase \"bigint\":\n\t\t\treturn 256;\n\t\tcase \"undefined\":\n\t\t\treturn 512;\n\t\tdefault:\n\t\t\treturn 0;\n\t}\n}\n\nfunction maskCheck(mask: number): Check {\n\treturn leaf(9, mask, (v) => (typeBits(v) & mask) !== 0);\n}\n\n/** `anyOf` whose bare-type branches have the types of `mask`: those by one type test, the others by their checks. */\nexport function maskedAnyCheck(mask: number, checks: readonly Check[]): Check {\n\tif (checks.length === 0) return maskCheck(mask);\n\tconst rest = checks.length === 1 ? checks[0] : anyCheck(checks);\n\treturn (v) => (typeBits(v) & mask) !== 0 || rest(v);\n}\n\n/** A Uint8Array within the length bounds. */\nexport function bytesCheck(min: number, max: number): Check {\n\treturn (v) => v instanceof Uint8Array && v.length >= min && v.length <= max;\n}\n\n/** The number of Unicode code points of `s`: JSON Schema string lengths count code points, not UTF-16 units. */\nexport function codePoints(s: string): number {\n\tlet n = 0;\n\tfor (let i = 0; i < s.length; i++, n++) {\n\t\tconst c = s.charCodeAt(i);\n\t\t// A high surrogate starts a pair only when a low surrogate follows; an unpaired one is a code point of its own.\n\t\tif (c >= 0xd800 && c <= 0xdbff && i + 1 < s.length) {\n\t\t\tconst next = s.charCodeAt(i + 1);\n\t\t\tif (next >= 0xdc00 && next <= 0xdfff) i++;\n\t\t}\n\t}\n\treturn n;\n}\n\n// UTF-16 units bound code points from both sides (units / 2 <= points <= units), so most strings need no count.\nfunction lengthOk(s: string, min: number, max: number): boolean {\n\tconst units = s.length;\n\tif (units < min) return false;\n\tif (units < 2 * min && codePoints(s) < min) return false;\n\treturn units <= max || codePoints(s) <= max;\n}\n\n/** The string keywords: length bounds, pattern and format. */\nexport function stringCheck(\n\tstrict: boolean,\n\tmin: number,\n\tmax: number,\n\tre: RegExp | undefined,\n\tformat: ((value: string) => boolean) | undefined,\n): Check {\n\tif (re !== undefined && min === 0 && max === Number.POSITIVE_INFINITY && format === undefined) {\n\t\treturn strict\n\t\t\t? leaf(13, re, (v) => typeof v === \"string\" && re.test(v))\n\t\t\t: (v) => typeof v !== \"string\" || re.test(v);\n\t}\n\tif (re === undefined && format === undefined) {\n\t\treturn strict\n\t\t\t? leaf(12, new Bounds(min, max, 0, 0), (v) => typeof v === \"string\" && lengthOk(v, min, max))\n\t\t\t: (v) => typeof v !== \"string\" || lengthOk(v, min, max);\n\t}\n\treturn (v) => {\n\t\tif (typeof v !== \"string\") return !strict;\n\t\treturn lengthOk(v, min, max) && (re === undefined || re.test(v)) && (format === undefined || format(v));\n\t};\n}\n\n/** A number bound: a number, or a bigint (TypeBox's `Type.BigInt` writes its bounds as bigints). */\nexport type Bound = number | bigint;\n\n/**\n * The number keywords, for numbers and bigints alike (as TypeBox applies them): bounds of either kind compare with\n * values of either kind. `mode`: 0 passes other types, 1 requires a number, 2 an integer, 3 a bigint.\n */\nexport function numberCheck(\n\tmode: 0 | 1 | 2 | 3,\n\tmin: Bound,\n\tmax: Bound,\n\txmin: Bound,\n\txmax: Bound,\n\tmultipleOf: Bound | undefined,\n): Check {\n\tconst check: Check = (v) => {\n\t\tif (typeof v !== \"number\" && typeof v !== \"bigint\") return mode === 0;\n\t\tif (mode === 3 ? typeof v !== \"bigint\" : mode !== 0 && !Number.isFinite(v)) return false;\n\t\tif (mode === 2 && !Number.isInteger(v)) return false;\n\t\treturn v >= min && v <= max && v > xmin && v < xmax && (multipleOf === undefined || isMultiple(v, multipleOf));\n\t};\n\tconst plain =\n\t\ttypeof min === \"number\" && typeof max === \"number\" && typeof xmin === \"number\" && typeof xmax === \"number\";\n\tif (mode === 0 || mode === 3 || multipleOf !== undefined || !plain) return check;\n\treturn leaf(mode === 2 ? 10 : 11, new Bounds(min, max, xmin, xmax), check);\n}\n\n/**\n * Whether `v` is a multiple of `d`, exactly for decimals: 0.0075 / 0.0001 is 74.99999999999999 in floating point. With\n * a bigint on either side, exact integer arithmetic; a bigint is no multiple of 0 or of a fraction.\n *\n * Deliberately unlike TypeBox, which throws there (`BigInt(0.5)`, division by zero): a check answers for every value\n * and never throws, and no real schema pairs a bigint with a fractional or zero `multipleOf`.\n */\nexport function isMultiple(v: Bound, d: Bound): boolean {\n\tif (typeof v === \"bigint\" || typeof d === \"bigint\") {\n\t\tif ((typeof v === \"number\" && !Number.isInteger(v)) || (typeof d === \"number\" && !Number.isInteger(d)))\n\t\t\treturn false;\n\t\tconst divisor = BigInt(d);\n\t\treturn divisor !== 0n && BigInt(v) % divisor === 0n;\n\t}\n\tconst q = v / d;\n\tif (Number.isInteger(q)) return true;\n\tif (!Number.isFinite(q)) return v % d === 0;\n\tconst [vc, ve] = decimal(v);\n\tconst [dc, de] = decimal(d);\n\treturn ve >= de ? (vc * 10n ** BigInt(ve - de)) % dc === 0n : vc % (dc * 10n ** BigInt(de - ve)) === 0n;\n}\n\nfunction decimal(x: number): [bigint, number] {\n\tconst [mantissa, exponent = \"0\"] = Math.abs(x).toString().split(\"e\");\n\tconst point = mantissa.indexOf(\".\");\n\tconst fraction = point < 0 ? 0 : mantissa.length - point - 1;\n\treturn [BigInt(mantissa.replace(\".\", \"\")), Number(exponent) - fraction];\n}\n\n/** `inner` for objects; other values pass unless `strict`. */\nexport function guardObject(inner: Check, strict: boolean): Check {\n\treturn strict ? (v) => isObject(v) && inner(v) : (v) => !isObject(v) || inner(v);\n}\n\n/** `inner` for arrays; other values pass unless `strict`. */\nexport function guardArray(inner: Check, strict: boolean): Check {\n\treturn strict ? (v) => Array.isArray(v) && inner(v) : (v) => !Array.isArray(v) || inner(v);\n}\n\n/**\n * An object with declared properties: `entries` is `[key, check, flags]` per property. The value's own keys are\n * walked with for...in (whose `o[k]` V8 reads from the enum cache, unlike a load by a name from a list), each found\n * among the declared names; `closed` rejects any other key. A property whose value is `undefined` counts as absent.\n */\nexport function declaredObject(\n\tentries: readonly unknown[],\n\trequiredCount: number,\n\tclosed: boolean,\n\tguard: Guard,\n): Check {\n\tconst n = entries.length;\n\treturn (v) => {\n\t\tif (guard !== GUARD_NONE && !isObject(v)) return guard === GUARD_LOOSE;\n\t\t// Guarded: by the check above, or by the caller for GUARD_NONE.\n\t\tconst o = v as Record<string, unknown>;\n\t\tlet required = 0;\n\t\tlet next = 0;\n\t\tfor (const k in o) {\n\t\t\t// Keys usually come in the declared order: try the entry after the last match before searching.\n\t\t\tlet i = next;\n\t\t\tif (entries[i] !== k) {\n\t\t\t\ti = 0;\n\t\t\t\twhile (i < n && entries[i] !== k) i += 3;\n\t\t\t\tif (i === n) {\n\t\t\t\t\tif (closed) return false;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t\tnext = i + 3;\n\t\t\tconst x = o[k];\n\t\t\tconst f = entries[i + 2] as number;\n\t\t\t// An optional property set to undefined counts as absent; a required one is present, and its schema decides\n\t\t\t// whether undefined is a value of it (TypeBox's Type.Undefined, Unknown, Any).\n\t\t\tif (x === undefined && !(f & REQUIRED)) continue;\n\t\t\tconst c = f & CODE;\n\t\t\tif (c !== 0 ? !leafOk(c, x, entries[i + 1]) : !(entries[i + 1] as Check)(x)) return false;\n\t\t\tif (f & REQUIRED) required++;\n\t\t}\n\t\treturn required === requiredCount;\n\t};\n}\n\n/** An object with declared properties, required keys not declared, pattern properties and additional properties. */\nexport function openObject(\n\tentries: readonly unknown[],\n\tkeys: readonly string[],\n\textraRequired: readonly string[],\n\tpatterns: readonly (readonly [RegExp, Check])[],\n\tadditional: Check | undefined,\n\tguard: Guard,\n): Check {\n\tconst known = patterns.length > 0 || additional !== undefined ? new Set(keys) : undefined;\n\treturn (v) => {\n\t\tif (guard !== GUARD_NONE && !isObject(v)) return guard === GUARD_LOOSE;\n\t\tconst o = v as Record<string, unknown>;\n\t\tfor (let i = 0; i < entries.length; i += 3) {\n\t\t\tconst k = entries[i] as string;\n\t\t\tconst x = o[k];\n\t\t\tconst f = entries[i + 2] as number;\n\t\t\t// Absent, or an optional property set to undefined (which counts as absent); see declaredObject.\n\t\t\tif ((x === undefined && !(f & REQUIRED && Object.hasOwn(o, k))) || (f & INHERITED && !Object.hasOwn(o, k))) {\n\t\t\t\tif (f & REQUIRED) return false;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst c = f & CODE;\n\t\t\tif (c !== 0 ? !leafOk(c, x, entries[i + 1]) : !(entries[i + 1] as Check)(x)) return false;\n\t\t}\n\t\tfor (let i = 0; i < extraRequired.length; i++) if (!Object.hasOwn(o, extraRequired[i])) return false;\n\t\tif (known === undefined) return true;\n\t\tfor (const k of Object.keys(o)) {\n\t\t\tlet matched = known.has(k);\n\t\t\tfor (let i = 0; i < patterns.length; i++) {\n\t\t\t\tif (patterns[i][0].test(k)) {\n\t\t\t\t\tmatched = true;\n\t\t\t\t\tif (!patterns[i][1](o[k])) return false;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!matched && additional !== undefined && !additional(o[k])) return false;\n\t\t}\n\t\treturn true;\n\t};\n}\n\n/** Every property name passes `check` (`v` is an object). */\nexport function propertyNamesCheck(check: Check): Check {\n\treturn (v) => {\n\t\tfor (const k in v as object) if (!check(k)) return false;\n\t\treturn true;\n\t};\n}\n\n/** `minProperties` and `maxProperties` (`v` is an object). */\nexport function propertyCountCheck(min: number, max: number): Check {\n\treturn (v) => {\n\t\tlet n = 0;\n\t\tfor (const _ in v as object) n++;\n\t\treturn n >= min && n <= max;\n\t};\n}\n\n/** `dependentRequired` (`v` is an object). */\nexport function dependentRequiredCheck(entries: readonly (readonly [string, readonly string[]])[]): Check {\n\treturn (v) => {\n\t\tconst o = v as object;\n\t\tfor (const [k, list] of entries)\n\t\t\tif (Object.hasOwn(o, k)) for (const r of list) if (!Object.hasOwn(o, r)) return false;\n\t\treturn true;\n\t};\n}\n\n/** `dependentSchemas` (`v` is an object). */\nexport function dependentSchemasCheck(entries: readonly (readonly [string, Check])[]): Check {\n\treturn (v) => {\n\t\tfor (const [k, check] of entries) if (Object.hasOwn(v as object, k) && !check(v)) return false;\n\t\treturn true;\n\t};\n}\n\nconst NO_LEAF: Leaf = [0, undefined];\n\n/** The common array: guard, length bounds, prefix items and the items after them, in one closure. */\nexport function listCheck(\n\tguard: Guard,\n\tmin: number,\n\tmax: number,\n\tprefix: readonly Check[],\n\trest: Check | undefined,\n): Check {\n\tconst n = prefix.length;\n\tconst [code, arg] = (rest === undefined ? undefined : leafOf(rest)) ?? NO_LEAF;\n\treturn (v) => {\n\t\tif (!Array.isArray(v)) return guard === GUARD_LOOSE;\n\t\tconst length = v.length;\n\t\tif (length < min || length > max) return false;\n\t\tconst m = length < n ? length : n;\n\t\tfor (let i = 0; i < m; i++) if (!prefix[i](v[i])) return false;\n\t\tif (rest === undefined) return true;\n\t\tif (code !== 0) {\n\t\t\tfor (let i = n; i < length; i++) if (!leafOk(code, v[i], arg)) return false;\n\t\t\treturn true;\n\t\t}\n\t\tfor (let i = n; i < length; i++) if (!rest(v[i])) return false;\n\t\treturn true;\n\t};\n}\n\n/** Prefix items and the items after them (`v` is an array). */\nexport function itemsCheck(prefix: readonly Check[], rest: Check | undefined): Check {\n\treturn listCheck(GUARD_NONE, 0, Number.POSITIVE_INFINITY, prefix, rest);\n}\n\n/** `minItems` and `maxItems` (`v` is an array). */\nexport function lengthCheck(min: number, max: number): Check {\n\treturn (v) => (v as unknown[]).length >= min && (v as unknown[]).length <= max;\n}\n\n/** `contains` with its bounds (`v` is an array). */\nexport function containsCheck(check: Check, min: number, max: number): Check {\n\treturn (v) => {\n\t\tconst list = v as unknown[];\n\t\tlet n = 0;\n\t\tfor (let i = 0; i < list.length; i++) if (check(list[i]) && ++n > max) return false;\n\t\treturn n >= min;\n\t};\n}\n\n/** `uniqueItems` (`v` is an array). */\nexport function uniqueCheck(v: unknown): boolean {\n\tconst list = v as unknown[];\n\tfor (let i = 1; i < list.length; i++) for (let j = 0; j < i; j++) if (deepEqual(list[i], list[j])) return false;\n\treturn true;\n}\n\n/** `enum`: up to 8 primitives by a scan, more by a Set, objects and arrays by deep equality. */\nexport function enumCheck(values: readonly unknown[]): Check {\n\tconst primitives = values.filter((x) => typeof x !== \"object\" || x === null);\n\tif (primitives.length === values.length && primitives.length <= 8) {\n\t\treturn leaf(8, primitives, (v) => {\n\t\t\tfor (let i = 0; i < primitives.length; i++) if (primitives[i] === v) return true;\n\t\t\treturn false;\n\t\t});\n\t}\n\tconst set = new Set(primitives);\n\tconst objects = values.filter((x) => typeof x === \"object\" && x !== null);\n\treturn (v) => set.has(v) || (typeof v === \"object\" && objects.some((o) => deepEqual(v, o)));\n}\n\n/** `const`. */\nexport function constCheck(value: unknown): Check {\n\tif (typeof value !== \"object\" || value === null) return leaf(7, value, (v) => v === value);\n\treturn (v) => deepEqual(v, value);\n}\n\n/** `anyOf`. */\nexport function anyCheck(checks: readonly Check[]): Check {\n\treturn (v) => {\n\t\tfor (let i = 0; i < checks.length; i++) if (checks[i](v)) return true;\n\t\treturn false;\n\t};\n}\n\n/** `oneOf`. */\nexport function oneCheck(checks: readonly Check[]): Check {\n\treturn (v) => {\n\t\tlet n = 0;\n\t\tfor (let i = 0; i < checks.length; i++) if (checks[i](v) && ++n > 1) return false;\n\t\treturn n === 1;\n\t};\n}\n\n/** `not`. */\nexport function notCheck(check: Check): Check {\n\treturn (v) => !check(v);\n}\n\n/** `if`, `then` and `else`. */\nexport function ifCheck(cond: Check, then: Check, otherwise: Check): Check {\n\treturn (v) => (cond(v) ? then(v) : otherwise(v));\n}\n\n/** A union of objects tagged by a const on `key`: the tag selects the one branch that can match. */\nexport function taggedCheck(key: string, tags: readonly unknown[], checks: readonly Check[]): Check {\n\treturn (v) => {\n\t\tif (!isObject(v)) return false;\n\t\tconst tag = v[key];\n\t\tfor (let i = 0; i < tags.length; i++) if (tags[i] === tag) return checks[i](v);\n\t\treturn false;\n\t};\n}\n\n/**\n * JSON equality, as `const`, `enum` and `uniqueItems` compare: the same primitives, arrays with equal items in order,\n * objects with the same keys and equal values (key order does not matter).\n */\nexport function deepEqual(a: unknown, b: unknown): boolean {\n\tif (a === b) return true;\n\tif (typeof a !== \"object\" || typeof b !== \"object\" || a === null || b === null) return false;\n\tconst array = Array.isArray(a);\n\tif (array !== Array.isArray(b)) return false;\n\tif (array) {\n\t\tconst x = a as unknown[];\n\t\tconst y = b as unknown[];\n\t\tif (x.length !== y.length) return false;\n\t\tfor (let i = 0; i < x.length; i++) if (!deepEqual(x[i], y[i])) return false;\n\t\treturn true;\n\t}\n\tconst x = a as Record<string, unknown>;\n\tconst y = b as Record<string, unknown>;\n\tconst keys = Object.keys(x);\n\tif (keys.length !== Object.keys(y).length) return false;\n\tfor (const k of keys) if (!Object.hasOwn(y, k) || !deepEqual(x[k], y[k])) return false;\n\treturn true;\n}\n"]}
|