@oxog/querystring 1.0.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/CHANGELOG.md +22 -0
- package/LICENSE +21 -0
- package/README.md +447 -0
- package/dist/builder.d.ts +42 -0
- package/dist/builder.d.ts.map +1 -0
- package/dist/builder.js +216 -0
- package/dist/builder.js.map +1 -0
- package/dist/esm/builder.d.ts +42 -0
- package/dist/esm/builder.d.ts.map +1 -0
- package/dist/esm/builder.js.map +1 -0
- package/dist/esm/builder.mjs +212 -0
- package/dist/esm/index.d.ts +49 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/index.mjs +49 -0
- package/dist/esm/parser.d.ts +7 -0
- package/dist/esm/parser.d.ts.map +1 -0
- package/dist/esm/parser.js.map +1 -0
- package/dist/esm/parser.mjs +170 -0
- package/dist/esm/plugins.d.ts +25 -0
- package/dist/esm/plugins.d.ts.map +1 -0
- package/dist/esm/plugins.js.map +1 -0
- package/dist/esm/plugins.mjs +223 -0
- package/dist/esm/schema.d.ts +23 -0
- package/dist/esm/schema.d.ts.map +1 -0
- package/dist/esm/schema.js.map +1 -0
- package/dist/esm/schema.mjs +674 -0
- package/dist/esm/security.d.ts +14 -0
- package/dist/esm/security.d.ts.map +1 -0
- package/dist/esm/security.js.map +1 -0
- package/dist/esm/security.mjs +224 -0
- package/dist/esm/stringifier.d.ts +4 -0
- package/dist/esm/stringifier.d.ts.map +1 -0
- package/dist/esm/stringifier.js.map +1 -0
- package/dist/esm/stringifier.mjs +193 -0
- package/dist/esm/types/index.d.ts +184 -0
- package/dist/esm/types/index.d.ts.map +1 -0
- package/dist/esm/types/index.js.map +1 -0
- package/dist/esm/types/index.mjs +2 -0
- package/dist/esm/types/schema.d.ts +37 -0
- package/dist/esm/types/schema.d.ts.map +1 -0
- package/dist/esm/types/schema.js.map +1 -0
- package/dist/esm/types/schema.mjs +2 -0
- package/dist/esm/utils/array.d.ts +11 -0
- package/dist/esm/utils/array.d.ts.map +1 -0
- package/dist/esm/utils/array.js.map +1 -0
- package/dist/esm/utils/array.mjs +116 -0
- package/dist/esm/utils/encoding.d.ts +13 -0
- package/dist/esm/utils/encoding.d.ts.map +1 -0
- package/dist/esm/utils/encoding.js.map +1 -0
- package/dist/esm/utils/encoding.mjs +126 -0
- package/dist/esm/utils/object.d.ts +12 -0
- package/dist/esm/utils/object.d.ts.map +1 -0
- package/dist/esm/utils/object.js.map +1 -0
- package/dist/esm/utils/object.mjs +140 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +92 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +49 -0
- package/dist/parser.d.ts +7 -0
- package/dist/parser.d.ts.map +1 -0
- package/dist/parser.js +174 -0
- package/dist/parser.js.map +1 -0
- package/dist/plugins.d.ts +25 -0
- package/dist/plugins.d.ts.map +1 -0
- package/dist/plugins.js +229 -0
- package/dist/plugins.js.map +1 -0
- package/dist/schema.d.ts +23 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +680 -0
- package/dist/schema.js.map +1 -0
- package/dist/security.d.ts +14 -0
- package/dist/security.d.ts.map +1 -0
- package/dist/security.js +233 -0
- package/dist/security.js.map +1 -0
- package/dist/stringifier.d.ts +4 -0
- package/dist/stringifier.d.ts.map +1 -0
- package/dist/stringifier.js +197 -0
- package/dist/stringifier.js.map +1 -0
- package/dist/types/index.d.ts +184 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/schema.d.ts +37 -0
- package/dist/types/schema.d.ts.map +1 -0
- package/dist/types/schema.js +3 -0
- package/dist/types/schema.js.map +1 -0
- package/dist/utils/array.d.ts +11 -0
- package/dist/utils/array.d.ts.map +1 -0
- package/dist/utils/array.js +127 -0
- package/dist/utils/array.js.map +1 -0
- package/dist/utils/encoding.d.ts +13 -0
- package/dist/utils/encoding.d.ts.map +1 -0
- package/dist/utils/encoding.js +137 -0
- package/dist/utils/encoding.js.map +1 -0
- package/dist/utils/object.d.ts +12 -0
- package/dist/utils/object.d.ts.map +1 -0
- package/dist/utils/object.js +150 -0
- package/dist/utils/object.js.map +1 -0
- package/package.json +65 -0
|
@@ -0,0 +1,674 @@
|
|
|
1
|
+
class BaseSchemaImpl {
|
|
2
|
+
constructor() {
|
|
3
|
+
this._transforms = [];
|
|
4
|
+
this._refinements = [];
|
|
5
|
+
}
|
|
6
|
+
safeParse(value) {
|
|
7
|
+
try {
|
|
8
|
+
const data = this.parse(value);
|
|
9
|
+
return { success: true, data };
|
|
10
|
+
}
|
|
11
|
+
catch (error) {
|
|
12
|
+
return {
|
|
13
|
+
success: false,
|
|
14
|
+
errors: [{
|
|
15
|
+
path: '',
|
|
16
|
+
message: error instanceof Error ? error.message : 'Validation failed',
|
|
17
|
+
value,
|
|
18
|
+
}],
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
optional() {
|
|
23
|
+
return new OptionalSchemaImpl(this);
|
|
24
|
+
}
|
|
25
|
+
nullable() {
|
|
26
|
+
return new NullableSchemaImpl(this);
|
|
27
|
+
}
|
|
28
|
+
default(value) {
|
|
29
|
+
this._default = value;
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
transform(fn) {
|
|
33
|
+
const schema = this;
|
|
34
|
+
schema._transforms.push(fn);
|
|
35
|
+
return schema;
|
|
36
|
+
}
|
|
37
|
+
refine(fn, message = 'Validation failed') {
|
|
38
|
+
this._refinements.push({ fn, message });
|
|
39
|
+
return this;
|
|
40
|
+
}
|
|
41
|
+
applyTransforms(value) {
|
|
42
|
+
let result = value;
|
|
43
|
+
for (const transform of this._transforms) {
|
|
44
|
+
result = transform(result);
|
|
45
|
+
}
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
applyRefinements(value) {
|
|
49
|
+
for (const { fn, message } of this._refinements) {
|
|
50
|
+
if (!fn(value)) {
|
|
51
|
+
throw new Error(message);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
class StringSchemaImpl extends BaseSchemaImpl {
|
|
57
|
+
constructor() {
|
|
58
|
+
super(...arguments);
|
|
59
|
+
this.type = 'string';
|
|
60
|
+
this._trim = false;
|
|
61
|
+
this._toLowerCase = false;
|
|
62
|
+
this._toUpperCase = false;
|
|
63
|
+
}
|
|
64
|
+
parse(value) {
|
|
65
|
+
if (value === undefined && this._default !== undefined) {
|
|
66
|
+
value = this._default;
|
|
67
|
+
}
|
|
68
|
+
if (typeof value !== 'string') {
|
|
69
|
+
throw new Error(`Expected string, got ${typeof value}`);
|
|
70
|
+
}
|
|
71
|
+
let str = value;
|
|
72
|
+
if (this._trim)
|
|
73
|
+
str = str.trim();
|
|
74
|
+
if (this._toLowerCase)
|
|
75
|
+
str = str.toLowerCase();
|
|
76
|
+
if (this._toUpperCase)
|
|
77
|
+
str = str.toUpperCase();
|
|
78
|
+
if (this._length !== undefined && str.length !== this._length) {
|
|
79
|
+
throw new Error(`String must be exactly ${this._length} characters`);
|
|
80
|
+
}
|
|
81
|
+
if (this._min !== undefined && str.length < this._min) {
|
|
82
|
+
throw new Error(`String must be at least ${this._min} characters`);
|
|
83
|
+
}
|
|
84
|
+
if (this._max !== undefined && str.length > this._max) {
|
|
85
|
+
throw new Error(`String must be at most ${this._max} characters`);
|
|
86
|
+
}
|
|
87
|
+
if (this._regex && !this._regex.test(str)) {
|
|
88
|
+
throw new Error(`String does not match pattern`);
|
|
89
|
+
}
|
|
90
|
+
if (this._startsWith && !str.startsWith(this._startsWith)) {
|
|
91
|
+
throw new Error(`String must start with "${this._startsWith}"`);
|
|
92
|
+
}
|
|
93
|
+
if (this._endsWith && !str.endsWith(this._endsWith)) {
|
|
94
|
+
throw new Error(`String must end with "${this._endsWith}"`);
|
|
95
|
+
}
|
|
96
|
+
if (this._includes && !str.includes(this._includes)) {
|
|
97
|
+
throw new Error(`String must include "${this._includes}"`);
|
|
98
|
+
}
|
|
99
|
+
this.applyRefinements(str);
|
|
100
|
+
return this.applyTransforms(str);
|
|
101
|
+
}
|
|
102
|
+
min(length) {
|
|
103
|
+
this._min = length;
|
|
104
|
+
return this;
|
|
105
|
+
}
|
|
106
|
+
max(length) {
|
|
107
|
+
this._max = length;
|
|
108
|
+
return this;
|
|
109
|
+
}
|
|
110
|
+
length(length) {
|
|
111
|
+
this._length = length;
|
|
112
|
+
return this;
|
|
113
|
+
}
|
|
114
|
+
email() {
|
|
115
|
+
this._regex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
116
|
+
return this;
|
|
117
|
+
}
|
|
118
|
+
url() {
|
|
119
|
+
this._regex = /^https?:\/\/.+/;
|
|
120
|
+
return this;
|
|
121
|
+
}
|
|
122
|
+
uuid() {
|
|
123
|
+
this._regex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
124
|
+
return this;
|
|
125
|
+
}
|
|
126
|
+
regex(pattern) {
|
|
127
|
+
this._regex = pattern;
|
|
128
|
+
return this;
|
|
129
|
+
}
|
|
130
|
+
startsWith(prefix) {
|
|
131
|
+
this._startsWith = prefix;
|
|
132
|
+
return this;
|
|
133
|
+
}
|
|
134
|
+
endsWith(suffix) {
|
|
135
|
+
this._endsWith = suffix;
|
|
136
|
+
return this;
|
|
137
|
+
}
|
|
138
|
+
includes(substring) {
|
|
139
|
+
this._includes = substring;
|
|
140
|
+
return this;
|
|
141
|
+
}
|
|
142
|
+
trim() {
|
|
143
|
+
this._trim = true;
|
|
144
|
+
return this;
|
|
145
|
+
}
|
|
146
|
+
toLowerCase() {
|
|
147
|
+
this._toLowerCase = true;
|
|
148
|
+
return this;
|
|
149
|
+
}
|
|
150
|
+
toUpperCase() {
|
|
151
|
+
this._toUpperCase = true;
|
|
152
|
+
return this;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
class NumberSchemaImpl extends BaseSchemaImpl {
|
|
156
|
+
constructor() {
|
|
157
|
+
super(...arguments);
|
|
158
|
+
this.type = 'number';
|
|
159
|
+
this._int = false;
|
|
160
|
+
this._positive = false;
|
|
161
|
+
this._negative = false;
|
|
162
|
+
this._nonpositive = false;
|
|
163
|
+
this._nonnegative = false;
|
|
164
|
+
this._finite = false;
|
|
165
|
+
this._safe = false;
|
|
166
|
+
}
|
|
167
|
+
parse(value) {
|
|
168
|
+
if (value === undefined && this._default !== undefined) {
|
|
169
|
+
value = this._default;
|
|
170
|
+
}
|
|
171
|
+
// Reject boolean values explicitly
|
|
172
|
+
if (typeof value === 'boolean') {
|
|
173
|
+
throw new Error(`Expected number, got ${typeof value}`);
|
|
174
|
+
}
|
|
175
|
+
const num = Number(value);
|
|
176
|
+
if (isNaN(num)) {
|
|
177
|
+
throw new Error(`Expected number, got ${typeof value}`);
|
|
178
|
+
}
|
|
179
|
+
if (this._int && !Number.isInteger(num)) {
|
|
180
|
+
throw new Error('Expected integer');
|
|
181
|
+
}
|
|
182
|
+
if (this._positive && num <= 0) {
|
|
183
|
+
throw new Error('Expected positive number');
|
|
184
|
+
}
|
|
185
|
+
if (this._negative && num >= 0) {
|
|
186
|
+
throw new Error('Expected negative number');
|
|
187
|
+
}
|
|
188
|
+
if (this._nonpositive && num > 0) {
|
|
189
|
+
throw new Error('Expected non-positive number');
|
|
190
|
+
}
|
|
191
|
+
if (this._nonnegative && num < 0) {
|
|
192
|
+
throw new Error('Expected non-negative number');
|
|
193
|
+
}
|
|
194
|
+
if (this._min !== undefined && num < this._min) {
|
|
195
|
+
throw new Error(`Number must be at least ${this._min}`);
|
|
196
|
+
}
|
|
197
|
+
if (this._max !== undefined && num > this._max) {
|
|
198
|
+
throw new Error(`Number must be at most ${this._max}`);
|
|
199
|
+
}
|
|
200
|
+
if (this._multipleOf !== undefined && num % this._multipleOf !== 0) {
|
|
201
|
+
throw new Error(`Number must be a multiple of ${this._multipleOf}`);
|
|
202
|
+
}
|
|
203
|
+
if (this._finite && !Number.isFinite(num)) {
|
|
204
|
+
throw new Error('Expected finite number');
|
|
205
|
+
}
|
|
206
|
+
if (this._safe && !Number.isSafeInteger(num)) {
|
|
207
|
+
throw new Error('Expected safe integer');
|
|
208
|
+
}
|
|
209
|
+
this.applyRefinements(num);
|
|
210
|
+
return this.applyTransforms(num);
|
|
211
|
+
}
|
|
212
|
+
min(value) {
|
|
213
|
+
this._min = value;
|
|
214
|
+
return this;
|
|
215
|
+
}
|
|
216
|
+
max(value) {
|
|
217
|
+
this._max = value;
|
|
218
|
+
return this;
|
|
219
|
+
}
|
|
220
|
+
int() {
|
|
221
|
+
this._int = true;
|
|
222
|
+
return this;
|
|
223
|
+
}
|
|
224
|
+
positive() {
|
|
225
|
+
this._positive = true;
|
|
226
|
+
return this;
|
|
227
|
+
}
|
|
228
|
+
negative() {
|
|
229
|
+
this._negative = true;
|
|
230
|
+
return this;
|
|
231
|
+
}
|
|
232
|
+
nonpositive() {
|
|
233
|
+
this._nonpositive = true;
|
|
234
|
+
return this;
|
|
235
|
+
}
|
|
236
|
+
nonnegative() {
|
|
237
|
+
this._nonnegative = true;
|
|
238
|
+
return this;
|
|
239
|
+
}
|
|
240
|
+
multipleOf(value) {
|
|
241
|
+
this._multipleOf = value;
|
|
242
|
+
return this;
|
|
243
|
+
}
|
|
244
|
+
finite() {
|
|
245
|
+
this._finite = true;
|
|
246
|
+
return this;
|
|
247
|
+
}
|
|
248
|
+
safe() {
|
|
249
|
+
this._safe = true;
|
|
250
|
+
return this;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
class BooleanSchemaImpl extends BaseSchemaImpl {
|
|
254
|
+
constructor() {
|
|
255
|
+
super(...arguments);
|
|
256
|
+
this.type = 'boolean';
|
|
257
|
+
}
|
|
258
|
+
parse(value) {
|
|
259
|
+
if (value === undefined && this._default !== undefined) {
|
|
260
|
+
value = this._default;
|
|
261
|
+
}
|
|
262
|
+
if (typeof value === 'boolean') {
|
|
263
|
+
this.applyRefinements(value);
|
|
264
|
+
return this.applyTransforms(value);
|
|
265
|
+
}
|
|
266
|
+
if (value === 'true' || value === 1 || value === '1') {
|
|
267
|
+
this.applyRefinements(true);
|
|
268
|
+
return this.applyTransforms(true);
|
|
269
|
+
}
|
|
270
|
+
if (value === 'false' || value === 0 || value === '0') {
|
|
271
|
+
this.applyRefinements(false);
|
|
272
|
+
return this.applyTransforms(false);
|
|
273
|
+
}
|
|
274
|
+
throw new Error(`Expected boolean, got ${typeof value}`);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
class DateSchemaImpl extends BaseSchemaImpl {
|
|
278
|
+
constructor() {
|
|
279
|
+
super(...arguments);
|
|
280
|
+
this.type = 'date';
|
|
281
|
+
}
|
|
282
|
+
parse(value) {
|
|
283
|
+
if (value === undefined && this._default !== undefined) {
|
|
284
|
+
value = this._default;
|
|
285
|
+
}
|
|
286
|
+
let date;
|
|
287
|
+
if (value instanceof Date) {
|
|
288
|
+
date = value;
|
|
289
|
+
}
|
|
290
|
+
else if (typeof value === 'string' || typeof value === 'number') {
|
|
291
|
+
date = new Date(value);
|
|
292
|
+
}
|
|
293
|
+
else {
|
|
294
|
+
throw new Error(`Expected date, got ${typeof value}`);
|
|
295
|
+
}
|
|
296
|
+
if (isNaN(date.getTime())) {
|
|
297
|
+
throw new Error('Invalid date');
|
|
298
|
+
}
|
|
299
|
+
if (this._min && date < this._min) {
|
|
300
|
+
throw new Error(`Date must be after ${this._min.toISOString()}`);
|
|
301
|
+
}
|
|
302
|
+
if (this._max && date > this._max) {
|
|
303
|
+
throw new Error(`Date must be before ${this._max.toISOString()}`);
|
|
304
|
+
}
|
|
305
|
+
this.applyRefinements(date);
|
|
306
|
+
return this.applyTransforms(date);
|
|
307
|
+
}
|
|
308
|
+
min(date) {
|
|
309
|
+
this._min = date;
|
|
310
|
+
return this;
|
|
311
|
+
}
|
|
312
|
+
max(date) {
|
|
313
|
+
this._max = date;
|
|
314
|
+
return this;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
class ArraySchemaImpl extends BaseSchemaImpl {
|
|
318
|
+
constructor(itemSchema) {
|
|
319
|
+
super();
|
|
320
|
+
this.type = 'array';
|
|
321
|
+
this._nonempty = false;
|
|
322
|
+
this._itemSchema = itemSchema;
|
|
323
|
+
}
|
|
324
|
+
parse(value) {
|
|
325
|
+
if (value === undefined && this._default !== undefined) {
|
|
326
|
+
value = this._default;
|
|
327
|
+
}
|
|
328
|
+
if (!Array.isArray(value)) {
|
|
329
|
+
throw new Error(`Expected array, got ${typeof value}`);
|
|
330
|
+
}
|
|
331
|
+
if (this._length !== undefined && value.length !== this._length) {
|
|
332
|
+
throw new Error(`Array must have exactly ${this._length} items`);
|
|
333
|
+
}
|
|
334
|
+
if (this._min !== undefined && value.length < this._min) {
|
|
335
|
+
throw new Error(`Array must have at least ${this._min} items`);
|
|
336
|
+
}
|
|
337
|
+
if (this._max !== undefined && value.length > this._max) {
|
|
338
|
+
throw new Error(`Array must have at most ${this._max} items`);
|
|
339
|
+
}
|
|
340
|
+
if (this._nonempty && value.length === 0) {
|
|
341
|
+
throw new Error('Array must not be empty');
|
|
342
|
+
}
|
|
343
|
+
const parsed = this._itemSchema
|
|
344
|
+
? value.map((item, index) => {
|
|
345
|
+
try {
|
|
346
|
+
return this._itemSchema.parse(item);
|
|
347
|
+
}
|
|
348
|
+
catch (error) {
|
|
349
|
+
throw new Error(`Invalid item at index ${index}: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
350
|
+
}
|
|
351
|
+
})
|
|
352
|
+
: value;
|
|
353
|
+
this.applyRefinements(parsed);
|
|
354
|
+
return this.applyTransforms(parsed);
|
|
355
|
+
}
|
|
356
|
+
min(length) {
|
|
357
|
+
this._min = length;
|
|
358
|
+
return this;
|
|
359
|
+
}
|
|
360
|
+
max(length) {
|
|
361
|
+
this._max = length;
|
|
362
|
+
return this;
|
|
363
|
+
}
|
|
364
|
+
length(length) {
|
|
365
|
+
this._length = length;
|
|
366
|
+
return this;
|
|
367
|
+
}
|
|
368
|
+
nonempty() {
|
|
369
|
+
this._nonempty = true;
|
|
370
|
+
return this;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
class ObjectSchemaImpl extends BaseSchemaImpl {
|
|
374
|
+
constructor() {
|
|
375
|
+
super(...arguments);
|
|
376
|
+
this.type = 'object';
|
|
377
|
+
this._strict = false;
|
|
378
|
+
this._passthrough = false;
|
|
379
|
+
}
|
|
380
|
+
parse(value) {
|
|
381
|
+
if (value === undefined && this._default !== undefined) {
|
|
382
|
+
value = this._default;
|
|
383
|
+
}
|
|
384
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
385
|
+
throw new Error(`Expected object, got ${typeof value}`);
|
|
386
|
+
}
|
|
387
|
+
const result = {};
|
|
388
|
+
const input = value;
|
|
389
|
+
if (this._shape) {
|
|
390
|
+
for (const [key, schema] of Object.entries(this._shape)) {
|
|
391
|
+
try {
|
|
392
|
+
result[key] = schema.parse(input[key]);
|
|
393
|
+
}
|
|
394
|
+
catch (error) {
|
|
395
|
+
throw new Error(`Invalid value for key "${key}": ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
for (const key of Object.keys(input)) {
|
|
399
|
+
if (!(key in this._shape)) {
|
|
400
|
+
if (this._strict) {
|
|
401
|
+
throw new Error(`Unknown key "${key}"`);
|
|
402
|
+
}
|
|
403
|
+
else if (this._passthrough) {
|
|
404
|
+
result[key] = input[key];
|
|
405
|
+
}
|
|
406
|
+
else if (this._catchall) {
|
|
407
|
+
try {
|
|
408
|
+
result[key] = this._catchall.parse(input[key]);
|
|
409
|
+
}
|
|
410
|
+
catch (error) {
|
|
411
|
+
throw new Error(`Invalid value for key "${key}": ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
else {
|
|
418
|
+
Object.assign(result, input);
|
|
419
|
+
}
|
|
420
|
+
this.applyRefinements(result);
|
|
421
|
+
return this.applyTransforms(result);
|
|
422
|
+
}
|
|
423
|
+
shape(shape) {
|
|
424
|
+
this._shape = shape;
|
|
425
|
+
return this;
|
|
426
|
+
}
|
|
427
|
+
strict() {
|
|
428
|
+
this._strict = true;
|
|
429
|
+
this._passthrough = false;
|
|
430
|
+
return this;
|
|
431
|
+
}
|
|
432
|
+
passthrough() {
|
|
433
|
+
this._passthrough = true;
|
|
434
|
+
this._strict = false;
|
|
435
|
+
return this;
|
|
436
|
+
}
|
|
437
|
+
strip() {
|
|
438
|
+
// this._strip = true; // Property was commented out earlier
|
|
439
|
+
return this;
|
|
440
|
+
}
|
|
441
|
+
catchall(schema) {
|
|
442
|
+
this._catchall = schema;
|
|
443
|
+
return this;
|
|
444
|
+
}
|
|
445
|
+
pick(keys) {
|
|
446
|
+
if (!this._shape) {
|
|
447
|
+
throw new Error('Cannot pick from object without shape');
|
|
448
|
+
}
|
|
449
|
+
const newShape = {};
|
|
450
|
+
for (const key of keys) {
|
|
451
|
+
if (key in this._shape) {
|
|
452
|
+
newShape[key] = this._shape[key];
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
const schema = new ObjectSchemaImpl();
|
|
456
|
+
schema._shape = newShape;
|
|
457
|
+
return schema;
|
|
458
|
+
}
|
|
459
|
+
omit(keys) {
|
|
460
|
+
if (!this._shape) {
|
|
461
|
+
throw new Error('Cannot omit from object without shape');
|
|
462
|
+
}
|
|
463
|
+
const keySet = new Set(keys);
|
|
464
|
+
const newShape = {};
|
|
465
|
+
for (const [key, value] of Object.entries(this._shape)) {
|
|
466
|
+
if (!keySet.has(key)) {
|
|
467
|
+
newShape[key] = value;
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
const schema = new ObjectSchemaImpl();
|
|
471
|
+
schema._shape = newShape;
|
|
472
|
+
return schema;
|
|
473
|
+
}
|
|
474
|
+
extend(extension) {
|
|
475
|
+
const newShape = { ...(this._shape || {}), ...extension };
|
|
476
|
+
const schema = new ObjectSchemaImpl();
|
|
477
|
+
schema._shape = newShape;
|
|
478
|
+
return schema;
|
|
479
|
+
}
|
|
480
|
+
merge(other) {
|
|
481
|
+
const otherImpl = other;
|
|
482
|
+
const newShape = { ...(this._shape || {}), ...(otherImpl._shape || {}) };
|
|
483
|
+
const schema = new ObjectSchemaImpl();
|
|
484
|
+
schema._shape = newShape;
|
|
485
|
+
return schema;
|
|
486
|
+
}
|
|
487
|
+
partial() {
|
|
488
|
+
if (!this._shape) {
|
|
489
|
+
return this;
|
|
490
|
+
}
|
|
491
|
+
const newShape = {};
|
|
492
|
+
for (const [key, value] of Object.entries(this._shape)) {
|
|
493
|
+
newShape[key] = value.optional();
|
|
494
|
+
}
|
|
495
|
+
const schema = new ObjectSchemaImpl();
|
|
496
|
+
schema._shape = newShape;
|
|
497
|
+
return schema;
|
|
498
|
+
}
|
|
499
|
+
deepPartial() {
|
|
500
|
+
return this;
|
|
501
|
+
}
|
|
502
|
+
required() {
|
|
503
|
+
return this;
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
class EnumSchemaImpl extends BaseSchemaImpl {
|
|
507
|
+
constructor(options) {
|
|
508
|
+
super();
|
|
509
|
+
this.type = 'enum';
|
|
510
|
+
this.options = options;
|
|
511
|
+
}
|
|
512
|
+
parse(value) {
|
|
513
|
+
if (value === undefined && this._default !== undefined) {
|
|
514
|
+
value = this._default;
|
|
515
|
+
}
|
|
516
|
+
if (!this.options.includes(value)) {
|
|
517
|
+
throw new Error(`Expected one of ${this.options.join(', ')}, got ${value}`);
|
|
518
|
+
}
|
|
519
|
+
this.applyRefinements(value);
|
|
520
|
+
return this.applyTransforms(value);
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
class UnionSchemaImpl extends BaseSchemaImpl {
|
|
524
|
+
constructor(options) {
|
|
525
|
+
super();
|
|
526
|
+
this.type = 'union';
|
|
527
|
+
this.options = options;
|
|
528
|
+
}
|
|
529
|
+
parse(value) {
|
|
530
|
+
if (value === undefined && this._default !== undefined) {
|
|
531
|
+
value = this._default;
|
|
532
|
+
}
|
|
533
|
+
const errors = [];
|
|
534
|
+
for (const schema of this.options) {
|
|
535
|
+
try {
|
|
536
|
+
const result = schema.parse(value);
|
|
537
|
+
this.applyRefinements(result);
|
|
538
|
+
return this.applyTransforms(result);
|
|
539
|
+
}
|
|
540
|
+
catch (error) {
|
|
541
|
+
errors.push(error instanceof Error ? error.message : 'Unknown error');
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
throw new Error(`Union validation failed: ${errors.join('; ')}`);
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
class OptionalSchemaImpl extends BaseSchemaImpl {
|
|
548
|
+
constructor(innerType) {
|
|
549
|
+
super();
|
|
550
|
+
this.type = 'optional';
|
|
551
|
+
this.innerType = innerType;
|
|
552
|
+
}
|
|
553
|
+
parse(value) {
|
|
554
|
+
if (value === undefined) {
|
|
555
|
+
return undefined;
|
|
556
|
+
}
|
|
557
|
+
const result = this.innerType.parse(value);
|
|
558
|
+
this.applyRefinements(result);
|
|
559
|
+
return this.applyTransforms(result);
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
class NullableSchemaImpl extends BaseSchemaImpl {
|
|
563
|
+
constructor(innerType) {
|
|
564
|
+
super();
|
|
565
|
+
this.type = 'nullable';
|
|
566
|
+
this.innerType = innerType;
|
|
567
|
+
}
|
|
568
|
+
parse(value) {
|
|
569
|
+
if (value === null) {
|
|
570
|
+
return null;
|
|
571
|
+
}
|
|
572
|
+
const result = this.innerType.parse(value);
|
|
573
|
+
this.applyRefinements(result);
|
|
574
|
+
return this.applyTransforms(result);
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
export const q = {
|
|
578
|
+
string: () => new StringSchemaImpl(),
|
|
579
|
+
number: () => new NumberSchemaImpl(),
|
|
580
|
+
boolean: () => new BooleanSchemaImpl(),
|
|
581
|
+
date: () => new DateSchemaImpl(),
|
|
582
|
+
array: (schema) => new ArraySchemaImpl(schema),
|
|
583
|
+
object: () => new ObjectSchemaImpl(),
|
|
584
|
+
enum: (...values) => new EnumSchemaImpl(values),
|
|
585
|
+
union: (...schemas) => new UnionSchemaImpl(schemas),
|
|
586
|
+
literal: (value) => {
|
|
587
|
+
return new (class extends BaseSchemaImpl {
|
|
588
|
+
constructor() {
|
|
589
|
+
super(...arguments);
|
|
590
|
+
this.type = 'literal';
|
|
591
|
+
}
|
|
592
|
+
parse(input) {
|
|
593
|
+
if (input !== value) {
|
|
594
|
+
throw new Error(`Expected ${value}, got ${input}`);
|
|
595
|
+
}
|
|
596
|
+
return value;
|
|
597
|
+
}
|
|
598
|
+
})();
|
|
599
|
+
},
|
|
600
|
+
any: () => {
|
|
601
|
+
return new (class extends BaseSchemaImpl {
|
|
602
|
+
constructor() {
|
|
603
|
+
super(...arguments);
|
|
604
|
+
this.type = 'any';
|
|
605
|
+
}
|
|
606
|
+
parse(value) {
|
|
607
|
+
return value;
|
|
608
|
+
}
|
|
609
|
+
})();
|
|
610
|
+
},
|
|
611
|
+
unknown: () => {
|
|
612
|
+
return new (class extends BaseSchemaImpl {
|
|
613
|
+
constructor() {
|
|
614
|
+
super(...arguments);
|
|
615
|
+
this.type = 'unknown';
|
|
616
|
+
}
|
|
617
|
+
parse(value) {
|
|
618
|
+
return value;
|
|
619
|
+
}
|
|
620
|
+
})();
|
|
621
|
+
},
|
|
622
|
+
null: () => {
|
|
623
|
+
return new (class extends BaseSchemaImpl {
|
|
624
|
+
constructor() {
|
|
625
|
+
super(...arguments);
|
|
626
|
+
this.type = 'null';
|
|
627
|
+
}
|
|
628
|
+
parse(value) {
|
|
629
|
+
if (value !== null) {
|
|
630
|
+
throw new Error(`Expected null, got ${typeof value}`);
|
|
631
|
+
}
|
|
632
|
+
return null;
|
|
633
|
+
}
|
|
634
|
+
})();
|
|
635
|
+
},
|
|
636
|
+
undefined: () => {
|
|
637
|
+
return new (class extends BaseSchemaImpl {
|
|
638
|
+
constructor() {
|
|
639
|
+
super(...arguments);
|
|
640
|
+
this.type = 'undefined';
|
|
641
|
+
}
|
|
642
|
+
parse(value) {
|
|
643
|
+
if (value !== undefined) {
|
|
644
|
+
throw new Error(`Expected undefined, got ${typeof value}`);
|
|
645
|
+
}
|
|
646
|
+
return undefined;
|
|
647
|
+
}
|
|
648
|
+
})();
|
|
649
|
+
},
|
|
650
|
+
void: () => {
|
|
651
|
+
return new (class extends BaseSchemaImpl {
|
|
652
|
+
constructor() {
|
|
653
|
+
super(...arguments);
|
|
654
|
+
this.type = 'void';
|
|
655
|
+
}
|
|
656
|
+
parse(value) {
|
|
657
|
+
if (value !== undefined) {
|
|
658
|
+
throw new Error(`Expected void, got ${typeof value}`);
|
|
659
|
+
}
|
|
660
|
+
return undefined;
|
|
661
|
+
}
|
|
662
|
+
})();
|
|
663
|
+
},
|
|
664
|
+
};
|
|
665
|
+
export function schema(shape) {
|
|
666
|
+
return q.object().shape(shape);
|
|
667
|
+
}
|
|
668
|
+
export function validate(schema, value) {
|
|
669
|
+
return schema.parse(value);
|
|
670
|
+
}
|
|
671
|
+
export function isValid(schema, value) {
|
|
672
|
+
return schema.safeParse(value).success;
|
|
673
|
+
}
|
|
674
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SecurityOptions, ParsedQuery } from './types';
|
|
2
|
+
export declare function sanitizeInput(input: string, options?: {
|
|
3
|
+
aggressive?: boolean;
|
|
4
|
+
}): string;
|
|
5
|
+
export declare function validateSecurity(obj: ParsedQuery, options?: SecurityOptions): {
|
|
6
|
+
valid: boolean;
|
|
7
|
+
errors: string[];
|
|
8
|
+
};
|
|
9
|
+
export declare function countKeys(obj: unknown, count?: number): number;
|
|
10
|
+
export declare function hasPrototypePollution(obj: unknown): boolean;
|
|
11
|
+
export declare function detectXSS(obj: unknown, path?: string): string[];
|
|
12
|
+
export declare function secureStringify(obj: unknown, options?: SecurityOptions): string;
|
|
13
|
+
export declare function createSecureParser(baseParser: Function, securityOptions?: SecurityOptions): (input: string, options?: unknown) => ParsedQuery;
|
|
14
|
+
//# sourceMappingURL=security.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security.d.ts","sourceRoot":"","sources":["../../src/security.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAsBvD,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE;IAAE,UAAU,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,MAAM,CAuC3F;AAED,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,WAAW,EAChB,OAAO,GAAE,eAAoB,GAC5B;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAmCtC;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,SAAI,GAAG,MAAM,CAmBzD;AAED,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAmD3D;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,SAAK,GAAG,MAAM,EAAE,CA2B3D;AAkBD,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,GAAE,eAAoB,GAAG,MAAM,CAgBnF;AAuBD,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,QAAQ,EAAE,eAAe,GAAE,eAAoB,IAC/D,OAAO,MAAM,EAAE,UAAU,OAAO,KAAG,WAAW,CAe5E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security.js","sourceRoot":"","sources":["../../src/security.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAElD,MAAM,YAAY,GAAG;IACnB,8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