@innet/server 2.0.0-beta.26 → 2.0.0-beta.28

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.
Files changed (58) hide show
  1. package/constants.d.ts +3 -0
  2. package/constants.es6.js +28 -1
  3. package/constants.js +29 -0
  4. package/hooks/index.d.ts +1 -1
  5. package/hooks/index.es6.js +1 -1
  6. package/hooks/index.js +1 -1
  7. package/hooks/useBodyContext/index.d.ts +1 -0
  8. package/hooks/useBodyContext/index.es6.js +1 -0
  9. package/hooks/useBodyContext/index.js +10 -0
  10. package/hooks/useBodyContext/useBodyContext.d.ts +6 -0
  11. package/hooks/{useBodyFile/useBodyFile.es6.js → useBodyContext/useBodyContext.es6.js} +6 -6
  12. package/hooks/{useBodyFile/useBodyFile.js → useBodyContext/useBodyContext.js} +7 -7
  13. package/index.es6.js +2 -2
  14. package/index.js +5 -3
  15. package/package.json +1 -1
  16. package/plugins/main/api/api.d.ts +7 -0
  17. package/plugins/main/api/api.es6.js +2 -4
  18. package/plugins/main/api/api.js +2 -4
  19. package/plugins/main/body/body.es6.js +6 -4
  20. package/plugins/main/body/body.js +6 -4
  21. package/plugins/main/endpoint/endpoint.d.ts +2 -0
  22. package/plugins/main/endpoint/endpoint.es6.js +78 -2
  23. package/plugins/main/endpoint/endpoint.js +78 -2
  24. package/plugins/schema/any/any.es6.js +6 -1
  25. package/plugins/schema/any/any.js +5 -0
  26. package/plugins/schema/array/array.es6.js +9 -4
  27. package/plugins/schema/array/array.js +9 -4
  28. package/plugins/schema/binary/binary.d.ts +3 -8
  29. package/plugins/schema/binary/binary.es6.js +12 -5
  30. package/plugins/schema/binary/binary.js +11 -4
  31. package/plugins/schema/boolean/boolean.es6.js +13 -5
  32. package/plugins/schema/boolean/boolean.js +12 -4
  33. package/plugins/schema/date/date.es6.js +12 -4
  34. package/plugins/schema/date/date.js +11 -3
  35. package/plugins/schema/integer/integer.es6.js +12 -4
  36. package/plugins/schema/integer/integer.js +11 -3
  37. package/plugins/schema/null/null.es6.js +8 -2
  38. package/plugins/schema/null/null.js +7 -1
  39. package/plugins/schema/number/number.es6.js +12 -4
  40. package/plugins/schema/number/number.js +11 -3
  41. package/plugins/schema/object/object.es6.js +36 -29
  42. package/plugins/schema/object/object.js +35 -28
  43. package/plugins/schema/string/string.es6.js +10 -3
  44. package/plugins/schema/string/string.js +9 -2
  45. package/plugins/schema/tuple/tuple.es6.js +29 -23
  46. package/plugins/schema/tuple/tuple.js +28 -22
  47. package/plugins/schema/uuid/uuid.es6.js +12 -4
  48. package/plugins/schema/uuid/uuid.js +11 -3
  49. package/types/appTypes.d.ts +3 -1
  50. package/utils/rules/constants.d.ts +4 -0
  51. package/utils/rules/constants.es6.js +547 -1
  52. package/utils/rules/constants.js +548 -0
  53. package/utils/rules/index.es6.js +1 -1
  54. package/utils/rules/index.js +2 -0
  55. package/hooks/useBodyFile/index.d.ts +0 -1
  56. package/hooks/useBodyFile/index.es6.js +0 -1
  57. package/hooks/useBodyFile/index.js +0 -10
  58. package/hooks/useBodyFile/useBodyFile.d.ts +0 -3
@@ -1,3 +1,4 @@
1
+ const inValidationValues = ['body', 'query', 'cookie', 'header', 'path'];
1
2
  const rulesErrors = [
2
3
  'oneOf',
3
4
  'number',
@@ -24,5 +25,550 @@ const rulesErrors = [
24
25
  'minBin',
25
26
  'maxBin',
26
27
  ];
28
+ const rulesErrorSchemas = {
29
+ array: {
30
+ description: 'The value should be an array',
31
+ properties: {
32
+ error: {
33
+ const: 'array',
34
+ type: 'string',
35
+ },
36
+ in: {
37
+ enum: inValidationValues,
38
+ type: 'string',
39
+ },
40
+ key: {
41
+ type: 'string',
42
+ },
43
+ },
44
+ required: ['error', 'in'],
45
+ title: 'array',
46
+ type: 'object',
47
+ },
48
+ binary: {
49
+ description: 'The value should be a binary file',
50
+ properties: {
51
+ error: {
52
+ const: 'binary',
53
+ type: 'string',
54
+ },
55
+ in: {
56
+ enum: inValidationValues,
57
+ type: 'string',
58
+ },
59
+ key: {
60
+ type: 'string',
61
+ },
62
+ value: {},
63
+ },
64
+ required: ['error', 'in', 'value'],
65
+ title: 'binary',
66
+ type: 'object',
67
+ },
68
+ binaryAccept: {
69
+ description: 'The file should match the accepted MIME types or extensions',
70
+ properties: {
71
+ accept: {
72
+ type: 'string',
73
+ },
74
+ error: {
75
+ const: 'binaryAccept',
76
+ type: 'string',
77
+ },
78
+ in: {
79
+ enum: inValidationValues,
80
+ type: 'string',
81
+ },
82
+ key: {
83
+ type: 'string',
84
+ },
85
+ value: {},
86
+ },
87
+ required: ['error', 'in', 'accept', 'value'],
88
+ title: 'binaryAccept',
89
+ type: 'object',
90
+ },
91
+ boolean: {
92
+ description: 'The value should be a boolean',
93
+ properties: {
94
+ error: {
95
+ const: 'boolean',
96
+ type: 'string',
97
+ },
98
+ in: {
99
+ enum: inValidationValues,
100
+ type: 'string',
101
+ },
102
+ key: {
103
+ type: 'string',
104
+ },
105
+ },
106
+ required: ['error', 'in'],
107
+ title: 'boolean',
108
+ type: 'object',
109
+ },
110
+ date: {
111
+ description: 'The value should be a valid date',
112
+ properties: {
113
+ error: {
114
+ const: 'date',
115
+ type: 'string',
116
+ },
117
+ in: {
118
+ enum: inValidationValues,
119
+ type: 'string',
120
+ },
121
+ key: {
122
+ type: 'string',
123
+ },
124
+ value: {},
125
+ },
126
+ required: ['error', 'in', 'value'],
127
+ title: 'date',
128
+ type: 'object',
129
+ },
130
+ integer: {
131
+ description: 'The value should be a valid integer within the specified format range',
132
+ properties: {
133
+ error: {
134
+ const: 'integer',
135
+ type: 'string',
136
+ },
137
+ format: {
138
+ enum: ['int32', 'int64'],
139
+ type: 'string',
140
+ },
141
+ in: {
142
+ enum: inValidationValues,
143
+ type: 'string',
144
+ },
145
+ key: {
146
+ type: 'string',
147
+ },
148
+ max: {
149
+ type: ['integer', 'string'],
150
+ },
151
+ min: {
152
+ type: ['integer', 'string'],
153
+ },
154
+ value: {},
155
+ },
156
+ required: ['error', 'in', 'format', 'value'],
157
+ title: 'integer',
158
+ type: 'object',
159
+ },
160
+ maxBin: {
161
+ description: 'The file size should not exceed the maximum limit',
162
+ properties: {
163
+ error: {
164
+ const: 'maxBin',
165
+ type: 'string',
166
+ },
167
+ in: {
168
+ enum: inValidationValues,
169
+ type: 'string',
170
+ },
171
+ key: {
172
+ type: 'string',
173
+ },
174
+ max: {
175
+ type: 'integer',
176
+ },
177
+ value: {},
178
+ },
179
+ required: ['error', 'in', 'max', 'value'],
180
+ title: 'maxBin',
181
+ type: 'object',
182
+ },
183
+ maxDate: {
184
+ description: 'The date should not exceed the maximum limit',
185
+ properties: {
186
+ error: {
187
+ const: 'maxDate',
188
+ type: 'string',
189
+ },
190
+ in: {
191
+ enum: inValidationValues,
192
+ type: 'string',
193
+ },
194
+ key: {
195
+ type: 'string',
196
+ },
197
+ max: {
198
+ format: 'date-time',
199
+ type: 'string',
200
+ },
201
+ value: {
202
+ format: 'date-time',
203
+ type: 'string',
204
+ },
205
+ },
206
+ required: ['error', 'in', 'max', 'value'],
207
+ title: 'maxDate',
208
+ type: 'object',
209
+ },
210
+ maximum: {
211
+ description: 'The number should not exceed the maximum limit',
212
+ properties: {
213
+ error: {
214
+ const: 'maximum',
215
+ type: 'string',
216
+ },
217
+ in: {
218
+ enum: inValidationValues,
219
+ type: 'string',
220
+ },
221
+ key: {
222
+ type: 'string',
223
+ },
224
+ max: {
225
+ oneOf: [
226
+ { type: 'number' },
227
+ { type: 'string' },
228
+ ],
229
+ },
230
+ value: {},
231
+ },
232
+ required: ['error', 'in', 'max', 'value'],
233
+ title: 'maximum',
234
+ type: 'object',
235
+ },
236
+ maxLength: {
237
+ description: 'The string length should not exceed the maximum limit',
238
+ properties: {
239
+ error: {
240
+ const: 'maxLength',
241
+ type: 'string',
242
+ },
243
+ in: {
244
+ enum: inValidationValues,
245
+ type: 'string',
246
+ },
247
+ key: {
248
+ type: 'string',
249
+ },
250
+ max: {
251
+ type: 'integer',
252
+ },
253
+ value: {
254
+ type: 'string',
255
+ },
256
+ },
257
+ required: ['error', 'in', 'max', 'value'],
258
+ title: 'maxLength',
259
+ type: 'object',
260
+ },
261
+ minBin: {
262
+ description: 'The file size should meet the minimum limit',
263
+ properties: {
264
+ error: {
265
+ const: 'minBin',
266
+ type: 'string',
267
+ },
268
+ in: {
269
+ enum: inValidationValues,
270
+ type: 'string',
271
+ },
272
+ key: {
273
+ type: 'string',
274
+ },
275
+ min: {
276
+ type: 'integer',
277
+ },
278
+ value: {},
279
+ },
280
+ required: ['error', 'in', 'min', 'value'],
281
+ title: 'minBin',
282
+ type: 'object',
283
+ },
284
+ minDate: {
285
+ description: 'The date should not be earlier than the minimum limit',
286
+ properties: {
287
+ error: {
288
+ const: 'minDate',
289
+ type: 'string',
290
+ },
291
+ in: {
292
+ enum: inValidationValues,
293
+ type: 'string',
294
+ },
295
+ key: {
296
+ type: 'string',
297
+ },
298
+ min: {
299
+ format: 'date-time',
300
+ type: 'string',
301
+ },
302
+ value: {
303
+ format: 'date-time',
304
+ type: 'string',
305
+ },
306
+ },
307
+ required: ['error', 'in', 'min', 'value'],
308
+ title: 'minDate',
309
+ type: 'object',
310
+ },
311
+ minimum: {
312
+ description: 'The number should meet the minimum limit',
313
+ properties: {
314
+ error: {
315
+ const: 'minimum',
316
+ type: 'string',
317
+ },
318
+ in: {
319
+ enum: inValidationValues,
320
+ type: 'string',
321
+ },
322
+ key: {
323
+ type: 'string',
324
+ },
325
+ min: {
326
+ oneOf: [
327
+ { type: 'number' },
328
+ { type: 'string' },
329
+ ],
330
+ },
331
+ value: {},
332
+ },
333
+ required: ['error', 'in', 'min', 'value'],
334
+ title: 'minimum',
335
+ type: 'object',
336
+ },
337
+ minLength: {
338
+ description: 'The string length should meet the minimum limit',
339
+ properties: {
340
+ error: {
341
+ const: 'minLength',
342
+ type: 'string',
343
+ },
344
+ in: {
345
+ enum: inValidationValues,
346
+ type: 'string',
347
+ },
348
+ key: {
349
+ type: 'string',
350
+ },
351
+ min: {
352
+ type: 'integer',
353
+ },
354
+ value: {
355
+ type: 'string',
356
+ },
357
+ },
358
+ required: ['error', 'in', 'min', 'value'],
359
+ title: 'minLength',
360
+ type: 'object',
361
+ },
362
+ null: {
363
+ description: 'The value should be null',
364
+ properties: {
365
+ error: {
366
+ const: 'null',
367
+ type: 'string',
368
+ },
369
+ in: {
370
+ enum: inValidationValues,
371
+ type: 'string',
372
+ },
373
+ key: {
374
+ type: 'string',
375
+ },
376
+ },
377
+ required: ['error', 'in'],
378
+ title: 'null',
379
+ type: 'object',
380
+ },
381
+ number: {
382
+ description: 'The value should be a valid number',
383
+ properties: {
384
+ error: {
385
+ const: 'number',
386
+ type: 'string',
387
+ },
388
+ in: {
389
+ enum: inValidationValues,
390
+ type: 'string',
391
+ },
392
+ key: {
393
+ type: 'string',
394
+ },
395
+ value: {},
396
+ },
397
+ required: ['error', 'in', 'value'],
398
+ title: 'number',
399
+ type: 'object',
400
+ },
401
+ object: {
402
+ description: 'The value should be an object',
403
+ properties: {
404
+ error: {
405
+ const: 'object',
406
+ type: 'string',
407
+ },
408
+ in: {
409
+ enum: inValidationValues,
410
+ type: 'string',
411
+ },
412
+ key: {
413
+ type: 'string',
414
+ },
415
+ value: {},
416
+ },
417
+ required: ['error', 'in', 'value'],
418
+ title: 'object',
419
+ type: 'object',
420
+ },
421
+ oneOf: {
422
+ description: 'The value should match exactly one of the provided schemas',
423
+ properties: {
424
+ error: {
425
+ const: 'oneOf',
426
+ type: 'string',
427
+ },
428
+ errors: {
429
+ items: {
430
+ type: 'object',
431
+ },
432
+ type: 'array',
433
+ },
434
+ in: {
435
+ enum: inValidationValues,
436
+ type: 'string',
437
+ },
438
+ key: {
439
+ type: 'string',
440
+ },
441
+ },
442
+ required: ['error', 'in', 'errors'],
443
+ title: 'oneOf',
444
+ type: 'object',
445
+ },
446
+ pattern: {
447
+ description: 'The value should match the specified regex pattern',
448
+ properties: {
449
+ error: {
450
+ const: 'pattern',
451
+ type: 'string',
452
+ },
453
+ in: {
454
+ enum: inValidationValues,
455
+ type: 'string',
456
+ },
457
+ key: {
458
+ type: 'string',
459
+ },
460
+ pattern: {
461
+ type: 'string',
462
+ },
463
+ patternId: {
464
+ type: 'string',
465
+ },
466
+ value: {},
467
+ },
468
+ required: ['error', 'in', 'pattern', 'patternId', 'value'],
469
+ title: 'pattern',
470
+ type: 'object',
471
+ },
472
+ required: {
473
+ description: 'The field is required and must not be undefined',
474
+ properties: {
475
+ error: {
476
+ const: 'required',
477
+ type: 'string',
478
+ },
479
+ in: {
480
+ enum: inValidationValues,
481
+ type: 'string',
482
+ },
483
+ key: {
484
+ type: 'string',
485
+ },
486
+ },
487
+ required: ['error', 'in'],
488
+ title: 'required',
489
+ type: 'object',
490
+ },
491
+ string: {
492
+ description: 'The value should be a string',
493
+ properties: {
494
+ error: {
495
+ const: 'string',
496
+ type: 'string',
497
+ },
498
+ in: {
499
+ enum: inValidationValues,
500
+ type: 'string',
501
+ },
502
+ key: {
503
+ type: 'string',
504
+ },
505
+ },
506
+ required: ['error', 'in'],
507
+ title: 'string',
508
+ type: 'object',
509
+ },
510
+ tuple: {
511
+ description: 'The value should be a tuple',
512
+ properties: {
513
+ error: {
514
+ const: 'tuple',
515
+ type: 'string',
516
+ },
517
+ in: {
518
+ enum: inValidationValues,
519
+ type: 'string',
520
+ },
521
+ key: {
522
+ type: 'string',
523
+ },
524
+ },
525
+ required: ['error', 'in'],
526
+ title: 'tuple',
527
+ type: 'object',
528
+ },
529
+ uuid: {
530
+ description: 'The value should be a valid UUID',
531
+ properties: {
532
+ error: {
533
+ const: 'uuid',
534
+ type: 'string',
535
+ },
536
+ in: {
537
+ enum: inValidationValues,
538
+ type: 'string',
539
+ },
540
+ key: {
541
+ type: 'string',
542
+ },
543
+ },
544
+ required: ['error', 'in'],
545
+ title: 'uuid',
546
+ type: 'object',
547
+ },
548
+ values: {
549
+ description: 'The value should be one of the allowed values',
550
+ properties: {
551
+ error: {
552
+ const: 'values',
553
+ type: 'string',
554
+ },
555
+ in: {
556
+ enum: inValidationValues,
557
+ type: 'string',
558
+ },
559
+ key: {
560
+ type: 'string',
561
+ },
562
+ value: {},
563
+ values: {
564
+ items: {},
565
+ type: 'array',
566
+ },
567
+ },
568
+ required: ['error', 'in', 'value', 'values'],
569
+ title: 'values',
570
+ type: 'object',
571
+ },
572
+ };
27
573
 
28
- export { rulesErrors };
574
+ export { inValidationValues, rulesErrorSchemas, rulesErrors };