ata-validator 1.62.1 → 1.63.0
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/README.md +63 -8
- package/build.mjs +1 -0
- package/index.browser.mjs +23 -4
- package/index.bundle.mjs +14 -4
- package/index.edge.mjs +14 -4
- package/index.js +7 -2
- package/lib/aot-build.js +18 -0
- package/lib/codegen-engine.js +72 -3
- package/lib/compiled-common.js +2 -1
- package/lib/email-literal.js +4 -1
- package/lib/formats-source.js +39 -40
- package/lib/interpreter-core.js +17 -9
- package/lib/ir/emit-deps.mjs +131 -0
- package/lib/ir/emit.mjs +560 -0
- package/lib/ir/front.mjs +834 -0
- package/lib/ir/index.mjs +10 -0
- package/lib/ir/refs.mjs +108 -0
- package/lib/ir/run.mjs +520 -0
- package/lib/ir/table.mjs +233 -0
- package/lib/js-compiler-errors.js +9 -4
- package/lib/kernels/collapse.mjs +114 -0
- package/lib/kernels/custom.mjs +70 -0
- package/lib/kernels/fill.mjs +6 -0
- package/lib/kernels/formats-small.mjs +40 -0
- package/lib/kernels/formats.mjs +29 -0
- package/lib/kernels/index.mjs +11 -0
- package/lib/kernels/kernels.mjs +285 -0
- package/lib/kernels/leaves.mjs +28 -0
- package/lib/kernels/order.mjs +25 -0
- package/lib/kernels/plan-rich.mjs +17 -0
- package/lib/kernels/plan.d.ts +9 -0
- package/lib/kernels/plan.mjs +128 -0
- package/lib/kernels/preprocess.mjs +223 -0
- package/lib/kernels/rank.mjs +97 -0
- package/lib/kernels/rt.mjs +249 -0
- package/lib/kernels/table.mjs +182 -0
- package/lib/kernels/unique.mjs +157 -0
- package/lib/native-positions.js +1 -1
- package/lib/openapi.d.ts +2 -0
- package/lib/openapi.js +128 -0
- package/lib/plan-compiler.js +84 -7
- package/lib/public-api.js +7 -2
- package/lib/rejections.js +3 -1
- package/lib/schema-helpers.js +12 -0
- package/lib/schema-helpers.mjs +20 -0
- package/lib/schema-order.js +4 -2
- package/lib/standard-schema.js +1 -1
- package/lib/validator-core.js +35 -30
- package/lib/version.js +1 -1
- package/lite.js +7 -2
- package/package.json +26 -8
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
// Generated by scripts/gen-ir-emit-deps.js from lib/js-compiler.js and lib/suggestions.js. Do not edit.
|
|
2
|
+
const FIXED_LITERAL = /[A-Za-z0-9 _\-:@#%&=,;'"<>!~`\/]/
|
|
3
|
+
function compilePatternInline(pattern, varName) {
|
|
4
|
+
let m = pattern.match(/^\^(\[[\w\-]+\])\{(\d+)\}\$$/)
|
|
5
|
+
if (m) {
|
|
6
|
+
const len = parseInt(m[2])
|
|
7
|
+
if (len <= 16) {
|
|
8
|
+
const checks = []
|
|
9
|
+
for (let i = 0; i < len; i++) {
|
|
10
|
+
const ck = charClassToCheck(m[1], `${varName}.charCodeAt(${i})`)
|
|
11
|
+
if (!ck) return null
|
|
12
|
+
checks.push(ck)
|
|
13
|
+
}
|
|
14
|
+
return `${varName}.length===${len}&&${checks.join('&&')}`
|
|
15
|
+
}
|
|
16
|
+
const rangeCheck = charClassToCheck(m[1], `${varName}.charCodeAt(_pi)`)
|
|
17
|
+
if (!rangeCheck) return null
|
|
18
|
+
return `${varName}.length===${len}&&(()=>{for(let _pi=0;_pi<${len};_pi++){if(!(${rangeCheck}))return false}return true})()`
|
|
19
|
+
}
|
|
20
|
+
m = pattern.match(/^\^(\[[\w\-]+\])\+\$$/)
|
|
21
|
+
if (m) {
|
|
22
|
+
const rangeCheck = charClassToCheck(m[1], `${varName}.charCodeAt(_pi)`)
|
|
23
|
+
if (!rangeCheck) return null
|
|
24
|
+
return `${varName}.length>0&&(()=>{for(let _pi=0;_pi<${varName}.length;_pi++){if(!(${rangeCheck}))return false}return true})()`
|
|
25
|
+
}
|
|
26
|
+
m = pattern.match(/^\^(\[[\w\-]+\])\{(\d+),(\d+)\}\$$/)
|
|
27
|
+
if (m) {
|
|
28
|
+
const rangeCheck = charClassToCheck(m[1], `${varName}.charCodeAt(_pi)`)
|
|
29
|
+
if (!rangeCheck) return null
|
|
30
|
+
const min = parseInt(m[2]), max = parseInt(m[3])
|
|
31
|
+
return `${varName}.length>=${min}&&${varName}.length<=${max}&&(()=>{for(let _pi=0;_pi<${varName}.length;_pi++){if(!(${rangeCheck}))return false}return true})()`
|
|
32
|
+
}
|
|
33
|
+
return fixedSequenceInline(pattern, varName)
|
|
34
|
+
}
|
|
35
|
+
function fixedSequenceInline(pattern, varName) {
|
|
36
|
+
if (pattern.length < 3 || pattern[0] !== '^' || pattern[pattern.length - 1] !== '$' || pattern[pattern.length - 2] === '\\') return null
|
|
37
|
+
const end = pattern.length - 1
|
|
38
|
+
const pieces = []
|
|
39
|
+
let i = 1
|
|
40
|
+
while (i < end) {
|
|
41
|
+
let piece
|
|
42
|
+
const c = pattern[i]
|
|
43
|
+
if (c === '[') {
|
|
44
|
+
const j = pattern.indexOf(']', i)
|
|
45
|
+
if (j < 0 || j >= end) return null
|
|
46
|
+
const cls = pattern.slice(i, j + 1)
|
|
47
|
+
if (!/^\[[\w-]+\]$/.test(cls)) return null
|
|
48
|
+
piece = { cls }
|
|
49
|
+
i = j + 1
|
|
50
|
+
} else if (c === '\\') {
|
|
51
|
+
const e = pattern[i + 1]
|
|
52
|
+
if (e === 'd') piece = { cls: '[0-9]' }
|
|
53
|
+
else if (e !== undefined && './()[]{}+*?^$|\\'.includes(e)) piece = { lit: e }
|
|
54
|
+
else return null
|
|
55
|
+
i += 2
|
|
56
|
+
} else if (FIXED_LITERAL.test(c)) {
|
|
57
|
+
piece = { lit: c }
|
|
58
|
+
i += 1
|
|
59
|
+
} else {
|
|
60
|
+
return null
|
|
61
|
+
}
|
|
62
|
+
let count = 1
|
|
63
|
+
if (pattern[i] === '{') {
|
|
64
|
+
const q = /^\{(\d+)\}/.exec(pattern.slice(i))
|
|
65
|
+
if (!q) return null
|
|
66
|
+
count = Number(q[1])
|
|
67
|
+
if (!Number.isSafeInteger(count) || count > 32 - pieces.length) return null
|
|
68
|
+
i += q[0].length
|
|
69
|
+
} else if (i < end && '*+?'.includes(pattern[i])) {
|
|
70
|
+
return null
|
|
71
|
+
}
|
|
72
|
+
for (let k = 0; k < count; k++) pieces.push(piece)
|
|
73
|
+
if (pieces.length > 32) return null
|
|
74
|
+
}
|
|
75
|
+
if (pieces.length === 0) return null
|
|
76
|
+
const checks = []
|
|
77
|
+
for (let k = 0; k < pieces.length; k++) {
|
|
78
|
+
const at = `${varName}.charCodeAt(${k})`
|
|
79
|
+
if (pieces[k].lit !== undefined) checks.push(`${at}===${pieces[k].lit.charCodeAt(0)}`)
|
|
80
|
+
else {
|
|
81
|
+
const ck = charClassToCheck(pieces[k].cls, at)
|
|
82
|
+
if (!ck) return null
|
|
83
|
+
checks.push(`(${ck})`)
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return `${varName}.length===${pieces.length}&&${checks.join('&&')}`
|
|
87
|
+
}
|
|
88
|
+
function charClassToCheck(charClass, codeExpr) {
|
|
89
|
+
const inner = charClass.slice(1, -1)
|
|
90
|
+
const ranges = []
|
|
91
|
+
let i = 0
|
|
92
|
+
while (i < inner.length) {
|
|
93
|
+
if (i + 2 < inner.length && inner[i + 1] === '-') {
|
|
94
|
+
ranges.push([inner.charCodeAt(i), inner.charCodeAt(i + 2)])
|
|
95
|
+
i += 3
|
|
96
|
+
} else {
|
|
97
|
+
ranges.push([inner.charCodeAt(i), inner.charCodeAt(i)])
|
|
98
|
+
i++
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (ranges.length === 0) return null
|
|
102
|
+
const checks = ranges.map(([lo, hi]) =>
|
|
103
|
+
lo === hi ? `${codeExpr}===${lo}` : `(${codeExpr}>=${lo}&&${codeExpr}<=${hi})`
|
|
104
|
+
)
|
|
105
|
+
return `(${checks.join('||')})`
|
|
106
|
+
}
|
|
107
|
+
const FORMAT_HINTS = {
|
|
108
|
+
email: (val) => {
|
|
109
|
+
if (typeof val !== 'string') return null;
|
|
110
|
+
if (!val.includes('@')) return "missing '@' and domain part";
|
|
111
|
+
if (val.split('@').length > 2) return "multiple '@' characters";
|
|
112
|
+
const [, dom] = val.split('@');
|
|
113
|
+
if (!dom || !dom.includes('.')) return 'domain part missing dot';
|
|
114
|
+
return null;
|
|
115
|
+
},
|
|
116
|
+
date: (val) => {
|
|
117
|
+
if (typeof val !== 'string') return null;
|
|
118
|
+
const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(val);
|
|
119
|
+
if (!m) return 'expected YYYY-MM-DD layout';
|
|
120
|
+
const mo = +m[2]; if (mo < 1 || mo > 12) return 'month must be 01-12';
|
|
121
|
+
const d = +m[3]; if (d < 1 || d > 31) return 'day must be 01-31';
|
|
122
|
+
return null;
|
|
123
|
+
},
|
|
124
|
+
uuid: (val) => {
|
|
125
|
+
if (typeof val !== 'string') return null;
|
|
126
|
+
if (!/^[0-9a-fA-F-]+$/.test(val)) return 'expected hex digits and dashes';
|
|
127
|
+
return 'expected 8-4-4-4-12 hex layout';
|
|
128
|
+
},
|
|
129
|
+
ipv4: (val) => typeof val === 'string' ? 'expected four 0-255 octets separated by dots' : null,
|
|
130
|
+
};
|
|
131
|
+
export { compilePatternInline, FORMAT_HINTS };
|