valrs 0.1.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.
@@ -0,0 +1,349 @@
1
+ /**
2
+ * JSON Schema to JavaScript Compiler
3
+ *
4
+ * Compiles JSON Schema definitions into optimized JavaScript validation functions.
5
+ * This approach generates direct property checks similar to TypeBox's TypeCompiler,
6
+ * providing high-performance validation without WASM overhead.
7
+ *
8
+ * @packageDocumentation
9
+ */
10
+ /**
11
+ * Generates JavaScript validation code from a JSON Schema.
12
+ *
13
+ * This function recursively traverses the schema and generates a string
14
+ * of JavaScript code that performs direct property checks.
15
+ *
16
+ * @param schema - The JSON Schema to compile
17
+ * @param path - The current path expression (e.g., 'data', 'data["name"]')
18
+ * @returns A JavaScript expression string that evaluates to boolean
19
+ *
20
+ * @internal
21
+ */
22
+ function generateValidatorCode(schema, path) {
23
+ const checks = [];
24
+ // Type check
25
+ const type = schema.type;
26
+ if (type !== undefined) {
27
+ switch (type) {
28
+ case 'string':
29
+ checks.push(`typeof ${path} === 'string'`);
30
+ break;
31
+ case 'number':
32
+ checks.push(`typeof ${path} === 'number' && !Number.isNaN(${path})`);
33
+ break;
34
+ case 'integer':
35
+ checks.push(`typeof ${path} === 'number' && Number.isInteger(${path})`);
36
+ break;
37
+ case 'boolean':
38
+ checks.push(`typeof ${path} === 'boolean'`);
39
+ break;
40
+ case 'null':
41
+ checks.push(`${path} === null`);
42
+ break;
43
+ case 'object':
44
+ checks.push(`typeof ${path} === 'object' && ${path} !== null && !Array.isArray(${path})`);
45
+ break;
46
+ case 'array':
47
+ checks.push(`Array.isArray(${path})`);
48
+ break;
49
+ }
50
+ }
51
+ // String constraints
52
+ if (typeof schema.minLength === 'number') {
53
+ checks.push(`${path}.length >= ${schema.minLength}`);
54
+ }
55
+ if (typeof schema.maxLength === 'number') {
56
+ checks.push(`${path}.length <= ${schema.maxLength}`);
57
+ }
58
+ if (typeof schema.pattern === 'string') {
59
+ // Escape the pattern for use in a RegExp constructor call
60
+ const escapedPattern = schema.pattern.replace(/\\/g, '\\\\').replace(/'/g, "\\'");
61
+ checks.push(`new RegExp('${escapedPattern}').test(${path})`);
62
+ }
63
+ // Number constraints
64
+ if (typeof schema.minimum === 'number') {
65
+ checks.push(`${path} >= ${schema.minimum}`);
66
+ }
67
+ if (typeof schema.maximum === 'number') {
68
+ checks.push(`${path} <= ${schema.maximum}`);
69
+ }
70
+ if (typeof schema.exclusiveMinimum === 'number') {
71
+ checks.push(`${path} > ${schema.exclusiveMinimum}`);
72
+ }
73
+ if (typeof schema.exclusiveMaximum === 'number') {
74
+ checks.push(`${path} < ${schema.exclusiveMaximum}`);
75
+ }
76
+ if (typeof schema.multipleOf === 'number') {
77
+ checks.push(`${path} % ${schema.multipleOf} === 0`);
78
+ }
79
+ // Array constraints
80
+ if (typeof schema.minItems === 'number') {
81
+ checks.push(`${path}.length >= ${schema.minItems}`);
82
+ }
83
+ if (typeof schema.maxItems === 'number') {
84
+ checks.push(`${path}.length <= ${schema.maxItems}`);
85
+ }
86
+ // Array items validation
87
+ const items = schema.items;
88
+ if (items !== undefined) {
89
+ const itemCheck = generateValidatorCode(items, 'item');
90
+ checks.push(`${path}.every(item => ${itemCheck})`);
91
+ }
92
+ // Unique items check
93
+ if (schema.uniqueItems === true) {
94
+ // For primitive types, use Set comparison; for objects, use JSON.stringify
95
+ checks.push(`new Set(${path}.map(v => typeof v === 'object' ? JSON.stringify(v) : v)).size === ${path}.length`);
96
+ }
97
+ // Enum check
98
+ if (schema.enum !== undefined) {
99
+ const enumValues = JSON.stringify(schema.enum);
100
+ checks.push(`${enumValues}.includes(${path})`);
101
+ }
102
+ // Const check
103
+ if (schema.const !== undefined) {
104
+ const constValue = JSON.stringify(schema.const);
105
+ checks.push(`${path} === ${constValue}`);
106
+ }
107
+ // Object properties validation
108
+ const properties = schema.properties;
109
+ const required = schema.required ?? [];
110
+ if (properties !== undefined) {
111
+ for (const [key, propSchema] of Object.entries(properties)) {
112
+ // Escape the key for use in property access
113
+ const escapedKey = key.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
114
+ const propPath = `${path}["${escapedKey}"]`;
115
+ const propCheck = generateValidatorCode(propSchema, propPath);
116
+ if (required.includes(key)) {
117
+ // Required property - must exist and validate
118
+ checks.push(`(${propPath} !== undefined && ${propCheck})`);
119
+ }
120
+ else {
121
+ // Optional property - if exists, must validate
122
+ checks.push(`(${propPath} === undefined || ${propCheck})`);
123
+ }
124
+ }
125
+ }
126
+ // Additional properties validation
127
+ if (schema.additionalProperties === false && properties !== undefined) {
128
+ const allowedKeys = JSON.stringify(Object.keys(properties));
129
+ checks.push(`Object.keys(${path}).every(k => ${allowedKeys}.includes(k))`);
130
+ }
131
+ else if (typeof schema.additionalProperties === 'object' &&
132
+ schema.additionalProperties !== null) {
133
+ const propKeys = properties !== undefined ? Object.keys(properties) : [];
134
+ const propKeysJson = JSON.stringify(propKeys);
135
+ const additionalCheck = generateValidatorCode(schema.additionalProperties, 'v');
136
+ checks.push(`Object.entries(${path}).every(([k, v]) => ${propKeysJson}.includes(k) || (${additionalCheck}))`);
137
+ }
138
+ // Composition keywords
139
+ if (schema.allOf !== undefined) {
140
+ const allOfChecks = schema.allOf.map((s) => generateValidatorCode(s, path));
141
+ checks.push(`(${allOfChecks.join(' && ')})`);
142
+ }
143
+ if (schema.anyOf !== undefined) {
144
+ const anyOfChecks = schema.anyOf.map((s) => generateValidatorCode(s, path));
145
+ checks.push(`(${anyOfChecks.join(' || ')})`);
146
+ }
147
+ if (schema.oneOf !== undefined) {
148
+ const oneOfChecks = schema.oneOf.map((s) => `(${generateValidatorCode(s, path)} ? 1 : 0)`);
149
+ checks.push(`([${oneOfChecks.join(', ')}].reduce((a, b) => a + b, 0) === 1)`);
150
+ }
151
+ if (schema.not !== undefined) {
152
+ const notCheck = generateValidatorCode(schema.not, path);
153
+ checks.push(`!(${notCheck})`);
154
+ }
155
+ if (checks.length === 0) {
156
+ return 'true';
157
+ }
158
+ return `(${checks.join(' && ')})`;
159
+ }
160
+ /**
161
+ * Compiles a JSON Schema into an optimized JavaScript validation function.
162
+ *
163
+ * This generates direct property checks like TypeBox's TypeCompiler,
164
+ * creating highly efficient validators without the overhead of schema
165
+ * interpretation at runtime.
166
+ *
167
+ * @param schema - The JSON Schema to compile
168
+ * @returns A compiled validation function
169
+ *
170
+ * @example
171
+ * ```typescript
172
+ * import { compileSchema } from 'valrs';
173
+ *
174
+ * const userSchema = {
175
+ * type: 'object',
176
+ * properties: {
177
+ * name: { type: 'string', minLength: 1 },
178
+ * age: { type: 'integer', minimum: 0 },
179
+ * },
180
+ * required: ['name', 'age'],
181
+ * };
182
+ *
183
+ * const validate = compileSchema(userSchema);
184
+ *
185
+ * validate({ name: 'John', age: 30 }); // true
186
+ * validate({ name: '', age: 30 }); // false (minLength violation)
187
+ * validate({ name: 'John', age: -1 }); // false (minimum violation)
188
+ * ```
189
+ */
190
+ export function compileSchema(schema) {
191
+ const code = generateValidatorCode(schema, 'data');
192
+ // Use Function constructor to create the validator
193
+ // This is safe as we control the generated code entirely
194
+ return new Function('data', `return ${code}`);
195
+ }
196
+ /**
197
+ * Generates the JavaScript source code for a validator function.
198
+ *
199
+ * Useful for debugging or generating static validator files.
200
+ *
201
+ * @param schema - The JSON Schema to compile
202
+ * @returns The JavaScript function body as a string
203
+ *
204
+ * @example
205
+ * ```typescript
206
+ * import { compileSchemaToCode } from 'valrs';
207
+ *
208
+ * const code = compileSchemaToCode({
209
+ * type: 'string',
210
+ * minLength: 1,
211
+ * });
212
+ * // Returns: "return (typeof data === 'string' && data.length >= 1)"
213
+ * ```
214
+ */
215
+ export function compileSchemaToCode(schema) {
216
+ const code = generateValidatorCode(schema, 'data');
217
+ return `return ${code}`;
218
+ }
219
+ /**
220
+ * Schema registry with pre-compiled validators.
221
+ *
222
+ * Provides a convenient way to register schemas by name and validate
223
+ * data against them. All schemas are compiled on registration for
224
+ * optimal validation performance.
225
+ *
226
+ * @example
227
+ * ```typescript
228
+ * import { CompiledRegistry } from 'valrs';
229
+ *
230
+ * const registry = new CompiledRegistry();
231
+ *
232
+ * registry.register('User', {
233
+ * type: 'object',
234
+ * properties: {
235
+ * name: { type: 'string' },
236
+ * email: { type: 'string' },
237
+ * },
238
+ * required: ['name', 'email'],
239
+ * });
240
+ *
241
+ * registry.validate('User', { name: 'John', email: 'john@example.com' }); // true
242
+ * registry.validate('User', { name: 'John' }); // false (missing email)
243
+ * ```
244
+ */
245
+ export class CompiledRegistry {
246
+ validators = new Map();
247
+ schemas = new Map();
248
+ generatedCode = new Map();
249
+ /**
250
+ * Registers a schema with the registry.
251
+ *
252
+ * The schema is immediately compiled for optimal validation performance.
253
+ *
254
+ * @param name - The name to register the schema under
255
+ * @param schema - The JSON Schema to register
256
+ */
257
+ register(name, schema) {
258
+ this.schemas.set(name, schema);
259
+ this.validators.set(name, compileSchema(schema));
260
+ this.generatedCode.set(name, compileSchemaToCode(schema));
261
+ }
262
+ /**
263
+ * Validates data against a registered schema.
264
+ *
265
+ * @param name - The name of the registered schema
266
+ * @param data - The data to validate
267
+ * @returns true if valid, false otherwise
268
+ * @throws Error if schema is not registered
269
+ */
270
+ validate(name, data) {
271
+ const validator = this.validators.get(name);
272
+ if (validator === undefined) {
273
+ throw new Error(`Schema '${name}' not found in registry`);
274
+ }
275
+ return validator(data);
276
+ }
277
+ /**
278
+ * Gets a registered schema by name.
279
+ *
280
+ * @param name - The name of the schema
281
+ * @returns The schema, or undefined if not registered
282
+ */
283
+ getSchema(name) {
284
+ return this.schemas.get(name);
285
+ }
286
+ /**
287
+ * Gets the compiled validator function for a schema.
288
+ *
289
+ * @param name - The name of the schema
290
+ * @returns The compiled validator, or undefined if not registered
291
+ */
292
+ getValidator(name) {
293
+ return this.validators.get(name);
294
+ }
295
+ /**
296
+ * Gets the generated JavaScript code for a schema.
297
+ *
298
+ * Useful for debugging or static code generation.
299
+ *
300
+ * @param name - The name of the schema
301
+ * @returns The generated code, or undefined if not registered
302
+ */
303
+ getGeneratedCode(name) {
304
+ return this.generatedCode.get(name);
305
+ }
306
+ /**
307
+ * Checks if a schema is registered.
308
+ *
309
+ * @param name - The name to check
310
+ * @returns true if registered, false otherwise
311
+ */
312
+ has(name) {
313
+ return this.validators.has(name);
314
+ }
315
+ /**
316
+ * Removes a schema from the registry.
317
+ *
318
+ * @param name - The name of the schema to remove
319
+ * @returns true if removed, false if not found
320
+ */
321
+ delete(name) {
322
+ const existed = this.validators.has(name);
323
+ this.validators.delete(name);
324
+ this.schemas.delete(name);
325
+ this.generatedCode.delete(name);
326
+ return existed;
327
+ }
328
+ /**
329
+ * Removes all schemas from the registry.
330
+ */
331
+ clear() {
332
+ this.validators.clear();
333
+ this.schemas.clear();
334
+ this.generatedCode.clear();
335
+ }
336
+ /**
337
+ * Gets the names of all registered schemas.
338
+ */
339
+ get names() {
340
+ return Array.from(this.validators.keys());
341
+ }
342
+ /**
343
+ * Gets the number of registered schemas.
344
+ */
345
+ get size() {
346
+ return this.validators.size;
347
+ }
348
+ }
349
+ //# sourceMappingURL=compiler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compiler.js","sourceRoot":"","sources":["../src/compiler.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAwCH;;;;;;;;;;;GAWG;AACH,SAAS,qBAAqB,CAAC,MAAkB,EAAE,IAAY;IAC7D,MAAM,MAAM,GAAa,EAAE,CAAC;IAE5B,aAAa;IACb,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;IACzB,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,QAAQ;gBACX,MAAM,CAAC,IAAI,CAAC,UAAU,IAAI,eAAe,CAAC,CAAC;gBAC3C,MAAM;YACR,KAAK,QAAQ;gBACX,MAAM,CAAC,IAAI,CAAC,UAAU,IAAI,kCAAkC,IAAI,GAAG,CAAC,CAAC;gBACrE,MAAM;YACR,KAAK,SAAS;gBACZ,MAAM,CAAC,IAAI,C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