@bedrockio/model 0.12.1 → 0.12.3

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 CHANGED
@@ -1,3 +1,11 @@
1
+ ## 0.12.3
2
+
3
+ - Support for `include` with top level dynamic references.
4
+
5
+ ## 0.12.2
6
+
7
+ - Updated validators for string ranges.
8
+
1
9
  ## 0.12.1
2
10
 
3
11
  - Allow range-based search on string fields.
package/README.md CHANGED
@@ -597,9 +597,9 @@ advanced features:
597
597
 
598
598
  will be flattened to:
599
599
 
600
- ```
600
+ ```json
601
601
  {
602
- 'profile.age': 20
602
+ "profile.age": 20
603
603
  }
604
604
  ```
605
605
 
@@ -609,7 +609,7 @@ Passing an array to `search` will perform a query using `$in`, which matches on
609
609
  the intersection of any elements. For example,
610
610
 
611
611
  ```json
612
- tags: ["one", "two"]
612
+ "tags": ["one", "two"]
613
613
  ```
614
614
 
615
615
  is effectively saying "match any documents whose `tags` array contains any of
@@ -652,9 +652,9 @@ match.
652
652
  Additionally, date and number fields allow range queries in the form:
653
653
 
654
654
  ```json
655
- age: {
656
- gt: 1
657
- lt: 2
655
+ "age": {
656
+ "gt": 1,
657
+ "lt": 2
658
658
  }
659
659
  ```
660
660
 
@@ -1050,6 +1050,10 @@ await Product.findById(id).include('shop.user.^name').
1050
1050
  }
1051
1051
  ```
1052
1052
 
1053
+ > [!WARNING] Fields that are dynamically referenced using `refPath` are unable
1054
+ > to resolve the schemas beforehand (ie. before query execution), therefore they
1055
+ > can only be populated at the top level.
1056
+
1053
1057
  #### Excluded Fields
1054
1058
 
1055
1059
  Fields can be excluded rather than included using `-`:
@@ -325,6 +325,12 @@ function setNodePath(node, options) {
325
325
  exclusive
326
326
  });
327
327
  halt = true;
328
+ } else if (field.refPath) {
329
+ // Note that dynamic references with refPath cannot "see"
330
+ // into a field for which they don't know the type yet (ie.
331
+ // before the query executes), therefore by definition
332
+ // dynamic references can only be populated one layer deep.
333
+ node[key] ||= {};
328
334
  } else if ((0, _utils.isSchemaTypedef)(field)) {
329
335
  node[key] = LEAF_NODE;
330
336
  }
@@ -11,7 +11,7 @@ var _mongoose = _interopRequireDefault(require("mongoose"));
11
11
  var _lodash = require("lodash");
12
12
  var _utils = require("./utils");
13
13
  var _const = require("./const");
14
- var _validation = require("./validation");
14
+ var _validationSchemas = require("./validation-schemas");
15
15
  var _env = require("./env");
16
16
  var _query = require("./query");
17
17
  var _warn = _interopRequireDefault(require("./warn"));
@@ -49,7 +49,7 @@ function searchValidation(options = {}) {
49
49
  sort
50
50
  } = searchOptions;
51
51
  return _yada.default.object({
52
- ids: _yada.default.array(_validation.OBJECT_ID_SCHEMA),
52
+ ids: _yada.default.array(_validationSchemas.OBJECT_ID_SCHEMA),
53
53
  keyword: _yada.default.string().description('A keyword to perform a text search against.'),
54
54
  skip: _yada.default.number().default(0).description('Number of records to skip.'),
55
55
  sort: getSortSchema(sort),
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.STRING_RANGE_SCHEMA = exports.REFERENCE_SCHEMA = exports.OBJECT_ID_SCHEMA = exports.NUMBER_RANGE_SCHEMA = exports.DATE_SCHEMA = exports.DATE_RANGE_SCHEMA = void 0;
7
+ var _yada = _interopRequireDefault(require("@bedrockio/yada"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ const DATE_TAGS = {
10
+ 'x-schema': 'DateTime',
11
+ 'x-description': 'A `string` in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format.'
12
+ };
13
+ const DATE_SCHEMA = exports.DATE_SCHEMA = _yada.default.date().iso().tag(DATE_TAGS);
14
+ const OBJECT_ID_SCHEMA = exports.OBJECT_ID_SCHEMA = _yada.default.string().mongo().message('Must be a valid object id.').tag({
15
+ 'x-schema': 'ObjectId',
16
+ 'x-description': 'A 24 character hexadecimal string representing a Mongo [ObjectId](https://bit.ly/3YPtGlU).'
17
+ });
18
+ const NUMBER_RANGE_SCHEMA = exports.NUMBER_RANGE_SCHEMA = _yada.default.object({
19
+ lt: _yada.default.number().description('Select values less than.'),
20
+ gt: _yada.default.number().description('Select values greater than.'),
21
+ lte: _yada.default.number().description('Select values less than or equal.'),
22
+ gte: _yada.default.number().description('Select values greater than or equal.')
23
+ }).tag({
24
+ 'x-schema': 'NumberRange',
25
+ 'x-description': 'An object representing numbers falling within a range.'
26
+ });
27
+ const STRING_RANGE_SCHEMA = exports.STRING_RANGE_SCHEMA = _yada.default.object({
28
+ lt: _yada.default.string().description('Select values less than.'),
29
+ gt: _yada.default.string().description('Select values greater than.'),
30
+ lte: _yada.default.string().description('Select values less than or equal.'),
31
+ gte: _yada.default.string().description('Select values greater than or equal.')
32
+ }).tag({
33
+ 'x-schema': 'StringRange',
34
+ 'x-description': 'An object representing strings falling within a range.'
35
+ });
36
+ const DATE_RANGE_SCHEMA = exports.DATE_RANGE_SCHEMA = _yada.default.object({
37
+ lt: _yada.default.date().iso().tag({
38
+ ...DATE_TAGS,
39
+ description: 'Select dates occurring before.'
40
+ }),
41
+ gt: _yada.default.date().iso().tag({
42
+ ...DATE_TAGS,
43
+ description: 'Select dates occurring after.'
44
+ }),
45
+ lte: _yada.default.date().iso().tag({
46
+ ...DATE_TAGS,
47
+ description: 'Select dates occurring on or before.'
48
+ }),
49
+ gte: _yada.default.date().iso().tag({
50
+ ...DATE_TAGS,
51
+ description: 'Select dates occurring on or after.'
52
+ })
53
+ }).tag({
54
+ 'x-schema': 'DateRange',
55
+ 'x-description': 'An object representing dates falling within a range.'
56
+ });
57
+ const REFERENCE_SCHEMA = exports.REFERENCE_SCHEMA = _yada.default.allow(OBJECT_ID_SCHEMA, _yada.default.object({
58
+ id: OBJECT_ID_SCHEMA.required()
59
+ }).options({
60
+ stripUnknown: true
61
+ }).custom(obj => {
62
+ return obj.id;
63
+ })).message('Must be an id or object containing an "id" field.').tag({
64
+ 'x-schema': 'Reference',
65
+ 'x-description': `
66
+ A 24 character hexadecimal string representing a Mongo [ObjectId](https://bit.ly/3YPtGlU).
67
+ An object with an \`id\` field may also be passed, which will be converted into a string.
68
+ `.trim()
69
+ });
@@ -3,7 +3,6 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.OBJECT_ID_SCHEMA = void 0;
7
6
  exports.addValidators = addValidators;
8
7
  exports.applyValidation = applyValidation;
9
8
  exports.getNamedValidator = getNamedValidator;
@@ -18,35 +17,15 @@ var _softDelete = require("./soft-delete");
18
17
  var _errors = require("./errors");
19
18
  var _utils = require("./utils");
20
19
  var _include = require("./include");
20
+ var _validationSchemas = require("./validation-schemas");
21
21
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
22
- const DATE_TAGS = {
23
- 'x-schema': 'DateTime',
24
- 'x-description': 'A `string` in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format.'
25
- };
26
- const OBJECT_ID_SCHEMA = exports.OBJECT_ID_SCHEMA = _yada.default.string().mongo().message('Must be a valid object id.').tag({
27
- 'x-schema': 'ObjectId',
28
- 'x-description': 'A 24 character hexadecimal string representing a Mongo [ObjectId](https://bit.ly/3YPtGlU).'
29
- });
30
- const REFERENCE_SCHEMA = _yada.default.allow(OBJECT_ID_SCHEMA, _yada.default.object({
31
- id: OBJECT_ID_SCHEMA.required()
32
- }).options({
33
- stripUnknown: true
34
- }).custom(obj => {
35
- return obj.id;
36
- })).message('Must be an id or object containing an "id" field.').tag({
37
- 'x-schema': 'Reference',
38
- 'x-description': `
39
- A 24 character hexadecimal string representing a Mongo [ObjectId](https://bit.ly/3YPtGlU).
40
- An object with an \`id\` field may also be passed, which will be converted into a string.
41
- `.trim()
42
- });
43
22
  const NAMED_SCHEMAS = {
44
23
  // Email is special as we are assuming that in
45
24
  // all cases lowercase should be allowed but coerced.
46
25
  email: _yada.default.string().lowercase().email(),
47
26
  // Force "objectId" to have parity with refs.
48
27
  // "mongo" is notably excluded here for this reason.
49
- objectId: OBJECT_ID_SCHEMA,
28
+ objectId: _validationSchemas.OBJECT_ID_SCHEMA,
50
29
  ascii: _yada.default.string().ascii(),
51
30
  base64: _yada.default.string().base64(),
52
31
  btc: _yada.default.string().btc(),
@@ -356,7 +335,7 @@ function getSchemaForType(type, options) {
356
335
  case 'Boolean':
357
336
  return _yada.default.boolean();
358
337
  case 'Date':
359
- return _yada.default.date().iso().tag(DATE_TAGS);
338
+ return _validationSchemas.DATE_SCHEMA;
360
339
  case 'Object':
361
340
  return _yada.default.object();
362
341
  case 'Array':
@@ -365,48 +344,22 @@ function getSchemaForType(type, options) {
365
344
  return _yada.default.any();
366
345
  case 'ObjectId':
367
346
  if (options.allowExpandedRefs) {
368
- return REFERENCE_SCHEMA;
347
+ return _validationSchemas.REFERENCE_SCHEMA;
369
348
  } else {
370
- return OBJECT_ID_SCHEMA;
349
+ return _validationSchemas.OBJECT_ID_SCHEMA;
371
350
  }
372
351
  default:
373
352
  throw new TypeError(`Unknown schema type ${type}`);
374
353
  }
375
354
  }
376
355
  function getSearchSchema(schema, type) {
377
- if (type === 'Number') {
378
- return _yada.default.allow(schema, _yada.default.array(schema), _yada.default.object({
379
- lt: _yada.default.number().description('Select values less than.'),
380
- gt: _yada.default.number().description('Select values greater than.'),
381
- lte: _yada.default.number().description('Select values less than or equal.'),
382
- gte: _yada.default.number().description('Select values greater than or equal.')
383
- }).tag({
384
- 'x-schema': 'NumberRange',
385
- 'x-description': 'An object representing numbers falling within a range.'
386
- })).description('Allows searching by a value, array of values, or a numeric range.');
356
+ if (type === 'String') {
357
+ return _yada.default.allow(schema, _yada.default.array(schema), _validationSchemas.STRING_RANGE_SCHEMA).description('Allows searching by a string, array of strings, or a range.');
358
+ } else if (type === 'Number') {
359
+ return _yada.default.allow(schema, _yada.default.array(schema), _validationSchemas.NUMBER_RANGE_SCHEMA).description('Allows searching by a value, array of values, or a range.');
387
360
  } else if (type === 'Date') {
388
- return _yada.default.allow(schema, _yada.default.array(schema), _yada.default.object({
389
- lt: _yada.default.date().iso().tag({
390
- ...DATE_TAGS,
391
- description: 'Select dates occurring before.'
392
- }),
393
- gt: _yada.default.date().iso().tag({
394
- ...DATE_TAGS,
395
- description: 'Select dates occurring after.'
396
- }),
397
- lte: _yada.default.date().iso().tag({
398
- ...DATE_TAGS,
399
- description: 'Select dates occurring on or before.'
400
- }),
401
- gte: _yada.default.date().iso().tag({
402
- ...DATE_TAGS,
403
- description: 'Select dates occurring on or after.'
404
- })
405
- }).tag({
406
- 'x-schema': 'DateRange',
407
- 'x-description': 'An object representing dates falling within a range.'
408
- })).description('Allows searching by a date, array of dates, or a range.');
409
- } else if (type === 'String' || type === 'ObjectId') {
361
+ return _yada.default.allow(schema, _yada.default.array(schema), _validationSchemas.DATE_RANGE_SCHEMA).description('Allows searching by a date, array of dates, or a range.');
362
+ } else if (type === 'ObjectId') {
410
363
  return _yada.default.allow(schema, _yada.default.array(schema));
411
364
  } else {
412
365
  return schema;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bedrockio/model",
3
- "version": "0.12.1",
3
+ "version": "0.12.3",
4
4
  "description": "Bedrock utilities for model creation.",
5
5
  "type": "module",
6
6
  "scripts": {
package/src/include.js CHANGED
@@ -233,6 +233,7 @@ function setNodePath(node, options) {
233
233
  }
234
234
 
235
235
  const schema = mongoose.models[modelName]?.schema;
236
+
236
237
  if (!schema) {
237
238
  throw new Error(`Could not derive schema for ${modelName}.`);
238
239
  }
@@ -318,6 +319,12 @@ function setNodePath(node, options) {
318
319
  exclusive,
319
320
  });
320
321
  halt = true;
322
+ } else if (field.refPath) {
323
+ // Note that dynamic references with refPath cannot "see"
324
+ // into a field for which they don't know the type yet (ie.
325
+ // before the query executes), therefore by definition
326
+ // dynamic references can only be populated one layer deep.
327
+ node[key] ||= {};
321
328
  } else if (isSchemaTypedef(field)) {
322
329
  node[key] = LEAF_NODE;
323
330
  }
package/src/search.js CHANGED
@@ -13,7 +13,7 @@ import {
13
13
  } from './utils';
14
14
 
15
15
  import { SEARCH_DEFAULTS } from './const';
16
- import { OBJECT_ID_SCHEMA } from './validation';
16
+ import { OBJECT_ID_SCHEMA } from './validation-schemas';
17
17
  import { debug } from './env';
18
18
  import { mergeQuery, wrapQuery } from './query';
19
19
 
@@ -0,0 +1,102 @@
1
+ import yd from '@bedrockio/yada';
2
+
3
+ const DATE_TAGS = {
4
+ 'x-schema': 'DateTime',
5
+ 'x-description':
6
+ 'A `string` in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format.',
7
+ };
8
+
9
+ export const DATE_SCHEMA = yd.date().iso().tag(DATE_TAGS);
10
+
11
+ export const OBJECT_ID_SCHEMA = yd
12
+ .string()
13
+ .mongo()
14
+ .message('Must be a valid object id.')
15
+ .tag({
16
+ 'x-schema': 'ObjectId',
17
+ 'x-description':
18
+ 'A 24 character hexadecimal string representing a Mongo [ObjectId](https://bit.ly/3YPtGlU).',
19
+ });
20
+
21
+ export const NUMBER_RANGE_SCHEMA = yd
22
+ .object({
23
+ lt: yd.number().description('Select values less than.'),
24
+ gt: yd.number().description('Select values greater than.'),
25
+ lte: yd.number().description('Select values less than or equal.'),
26
+ gte: yd.number().description('Select values greater than or equal.'),
27
+ })
28
+ .tag({
29
+ 'x-schema': 'NumberRange',
30
+ 'x-description': 'An object representing numbers falling within a range.',
31
+ });
32
+
33
+ export const STRING_RANGE_SCHEMA = yd
34
+ .object({
35
+ lt: yd.string().description('Select values less than.'),
36
+ gt: yd.string().description('Select values greater than.'),
37
+ lte: yd.string().description('Select values less than or equal.'),
38
+ gte: yd.string().description('Select values greater than or equal.'),
39
+ })
40
+ .tag({
41
+ 'x-schema': 'StringRange',
42
+ 'x-description': 'An object representing strings falling within a range.',
43
+ });
44
+
45
+ export const DATE_RANGE_SCHEMA = yd
46
+ .object({
47
+ lt: yd
48
+ .date()
49
+ .iso()
50
+ .tag({
51
+ ...DATE_TAGS,
52
+ description: 'Select dates occurring before.',
53
+ }),
54
+ gt: yd
55
+ .date()
56
+ .iso()
57
+ .tag({
58
+ ...DATE_TAGS,
59
+ description: 'Select dates occurring after.',
60
+ }),
61
+ lte: yd
62
+ .date()
63
+ .iso()
64
+ .tag({
65
+ ...DATE_TAGS,
66
+ description: 'Select dates occurring on or before.',
67
+ }),
68
+ gte: yd
69
+ .date()
70
+ .iso()
71
+ .tag({
72
+ ...DATE_TAGS,
73
+ description: 'Select dates occurring on or after.',
74
+ }),
75
+ })
76
+ .tag({
77
+ 'x-schema': 'DateRange',
78
+ 'x-description': 'An object representing dates falling within a range.',
79
+ });
80
+
81
+ export const REFERENCE_SCHEMA = yd
82
+ .allow(
83
+ OBJECT_ID_SCHEMA,
84
+ yd
85
+ .object({
86
+ id: OBJECT_ID_SCHEMA.required(),
87
+ })
88
+ .options({
89
+ stripUnknown: true,
90
+ })
91
+ .custom((obj) => {
92
+ return obj.id;
93
+ }),
94
+ )
95
+ .message('Must be an id or object containing an "id" field.')
96
+ .tag({
97
+ 'x-schema': 'Reference',
98
+ 'x-description': `
99
+ A 24 character hexadecimal string representing a Mongo [ObjectId](https://bit.ly/3YPtGlU).
100
+ An object with an \`id\` field may also be passed, which will be converted into a string.
101
+ `.trim(),
102
+ });
package/src/validation.js CHANGED
@@ -9,45 +9,14 @@ import { assertUnique } from './soft-delete';
9
9
  import { PermissionsError, ImplementationError } from './errors';
10
10
  import { isMongooseSchema, isSchemaTypedef } from './utils';
11
11
  import { INCLUDE_FIELD_SCHEMA } from './include';
12
-
13
- const DATE_TAGS = {
14
- 'x-schema': 'DateTime',
15
- 'x-description':
16
- 'A `string` in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format.',
17
- };
18
-
19
- export const OBJECT_ID_SCHEMA = yd
20
- .string()
21
- .mongo()
22
- .message('Must be a valid object id.')
23
- .tag({
24
- 'x-schema': 'ObjectId',
25
- 'x-description':
26
- 'A 24 character hexadecimal string representing a Mongo [ObjectId](https://bit.ly/3YPtGlU).',
27
- });
28
-
29
- const REFERENCE_SCHEMA = yd
30
- .allow(
31
- OBJECT_ID_SCHEMA,
32
- yd
33
- .object({
34
- id: OBJECT_ID_SCHEMA.required(),
35
- })
36
- .options({
37
- stripUnknown: true,
38
- })
39
- .custom((obj) => {
40
- return obj.id;
41
- }),
42
- )
43
- .message('Must be an id or object containing an "id" field.')
44
- .tag({
45
- 'x-schema': 'Reference',
46
- 'x-description': `
47
- A 24 character hexadecimal string representing a Mongo [ObjectId](https://bit.ly/3YPtGlU).
48
- An object with an \`id\` field may also be passed, which will be converted into a string.
49
- `.trim(),
50
- });
12
+ import {
13
+ DATE_SCHEMA,
14
+ REFERENCE_SCHEMA,
15
+ OBJECT_ID_SCHEMA,
16
+ NUMBER_RANGE_SCHEMA,
17
+ STRING_RANGE_SCHEMA,
18
+ DATE_RANGE_SCHEMA,
19
+ } from './validation-schemas';
51
20
 
52
21
  const NAMED_SCHEMAS = {
53
22
  // Email is special as we are assuming that in
@@ -377,7 +346,7 @@ function getSchemaForType(type, options) {
377
346
  case 'Boolean':
378
347
  return yd.boolean();
379
348
  case 'Date':
380
- return yd.date().iso().tag(DATE_TAGS);
349
+ return DATE_SCHEMA;
381
350
  case 'Object':
382
351
  return yd.object();
383
352
  case 'Array':
@@ -396,73 +365,23 @@ function getSchemaForType(type, options) {
396
365
  }
397
366
 
398
367
  function getSearchSchema(schema, type) {
399
- if (type === 'Number') {
368
+ if (type === 'String') {
369
+ return yd
370
+ .allow(schema, yd.array(schema), STRING_RANGE_SCHEMA)
371
+ .description(
372
+ 'Allows searching by a string, array of strings, or a range.',
373
+ );
374
+ } else if (type === 'Number') {
400
375
  return yd
401
- .allow(
402
- schema,
403
- yd.array(schema),
404
- yd
405
- .object({
406
- lt: yd.number().description('Select values less than.'),
407
- gt: yd.number().description('Select values greater than.'),
408
- lte: yd.number().description('Select values less than or equal.'),
409
- gte: yd
410
- .number()
411
- .description('Select values greater than or equal.'),
412
- })
413
- .tag({
414
- 'x-schema': 'NumberRange',
415
- 'x-description':
416
- 'An object representing numbers falling within a range.',
417
- }),
418
- )
376
+ .allow(schema, yd.array(schema), NUMBER_RANGE_SCHEMA)
419
377
  .description(
420
- 'Allows searching by a value, array of values, or a numeric range.',
378
+ 'Allows searching by a value, array of values, or a range.',
421
379
  );
422
380
  } else if (type === 'Date') {
423
381
  return yd
424
- .allow(
425
- schema,
426
- yd.array(schema),
427
- yd
428
- .object({
429
- lt: yd
430
- .date()
431
- .iso()
432
- .tag({
433
- ...DATE_TAGS,
434
- description: 'Select dates occurring before.',
435
- }),
436
- gt: yd
437
- .date()
438
- .iso()
439
- .tag({
440
- ...DATE_TAGS,
441
- description: 'Select dates occurring after.',
442
- }),
443
- lte: yd
444
- .date()
445
- .iso()
446
- .tag({
447
- ...DATE_TAGS,
448
- description: 'Select dates occurring on or before.',
449
- }),
450
- gte: yd
451
- .date()
452
- .iso()
453
- .tag({
454
- ...DATE_TAGS,
455
- description: 'Select dates occurring on or after.',
456
- }),
457
- })
458
- .tag({
459
- 'x-schema': 'DateRange',
460
- 'x-description':
461
- 'An object representing dates falling within a range.',
462
- }),
463
- )
382
+ .allow(schema, yd.array(schema), DATE_RANGE_SCHEMA)
464
383
  .description('Allows searching by a date, array of dates, or a range.');
465
- } else if (type === 'String' || type === 'ObjectId') {
384
+ } else if (type === 'ObjectId') {
466
385
  return yd.allow(schema, yd.array(schema));
467
386
  } else {
468
387
  return schema;
@@ -1 +1 @@
1
- {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../src/search.js"],"names":[],"mappings":"AAuBA,gEAaC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eA4CwC,CAAC;;;;;;;;;;;;;;;;;EAnBxC"}
1
+ {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../src/search.js"],"names":[],"mappings":"AAuBA,gEAaC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eA4CgC,CAAC;;;;;;;;;;;;;;;;;EAnBhC"}
@@ -0,0 +1,303 @@
1
+ export const DATE_SCHEMA: {
2
+ min(min: string | number | Date): /*elided*/ any;
3
+ max(max: string | number | Date): /*elided*/ any;
4
+ before(max: string | number | Date): /*elided*/ any;
5
+ after(min: string | number | Date): /*elided*/ any;
6
+ past(): /*elided*/ any;
7
+ future(): /*elided*/ any;
8
+ iso(format?: "date" | "date-time"): /*elided*/ any;
9
+ timestamp(): /*elided*/ any;
10
+ unix(): /*elided*/ any;
11
+ assertions: any[];
12
+ meta: {};
13
+ required(): /*elided*/ any;
14
+ default(arg: any): /*elided*/ any;
15
+ custom(fn: Function): /*elided*/ any;
16
+ missing(fn: Function): /*elided*/ any;
17
+ strip(strip: any): /*elided*/ any;
18
+ allow(...set: any[]): /*elided*/ any;
19
+ reject(...set: any[]): /*elided*/ any;
20
+ nullable(): /*elided*/ any;
21
+ message(message: any): /*elided*/ any;
22
+ tag(tags: any): /*elided*/ any;
23
+ description(description: any): /*elided*/ any;
24
+ options(options: any): /*elided*/ any;
25
+ validate(value: any, options?: {}): Promise<any>;
26
+ clone(meta: any): /*elided*/ any;
27
+ append(schema: any): import("@bedrockio/yada/types/Schema").default;
28
+ toOpenApi(extra: any): any;
29
+ getAnyType(): {
30
+ type: string[];
31
+ };
32
+ getDefault(): {
33
+ default?: undefined;
34
+ } | {
35
+ default: any;
36
+ };
37
+ getNullable(): {
38
+ nullable: boolean;
39
+ };
40
+ expandExtra(extra?: {}): {};
41
+ inspect(): string;
42
+ get(): void;
43
+ assertEnum(set: any, allow: any): /*elided*/ any;
44
+ assert(type: any, fn: any): /*elided*/ any;
45
+ pushAssertion(assertion: any): void;
46
+ canSkipAssertion(value: any, assertion: any, options: any): any;
47
+ transform(fn: any): /*elided*/ any;
48
+ getSortIndex(type: any): number;
49
+ runAssertion(value: any, assertion: any, options?: {}): Promise<any>;
50
+ enumToOpenApi(): any;
51
+ };
52
+ export const OBJECT_ID_SCHEMA: {
53
+ required(): /*elided*/ any;
54
+ length(length: number): /*elided*/ any;
55
+ min(length: number): /*elided*/ any;
56
+ max(length: number): /*elided*/ any;
57
+ trim(): /*elided*/ any;
58
+ lowercase(assert?: boolean): /*elided*/ any;
59
+ uppercase(assert?: boolean): /*elided*/ any;
60
+ match(reg: RegExp): /*elided*/ any;
61
+ email(): /*elided*/ any;
62
+ phone(code: any): /*elided*/ any;
63
+ hex(): /*elided*/ any;
64
+ md5(): /*elided*/ any;
65
+ sha1(): /*elided*/ any;
66
+ ascii(): /*elided*/ any;
67
+ base64(options?: {
68
+ urlSafe?: boolean;
69
+ }): /*elided*/ any;
70
+ creditCard(): /*elided*/ any;
71
+ ip(): /*elided*/ any;
72
+ country(): /*elided*/ any;
73
+ locale(): /*elided*/ any;
74
+ jwt(): /*elided*/ any;
75
+ slug(): /*elided*/ any;
76
+ latlng(): /*elided*/ any;
77
+ postalCode(locale?: string): /*elided*/ any;
78
+ zipcode(): /*elided*/ any;
79
+ password(options?: {
80
+ minLength?: number;
81
+ minNumbers?: number;
82
+ minSymbols?: number;
83
+ minLowercase?: number;
84
+ minUppercase?: number;
85
+ }): /*elided*/ any;
86
+ url(options?: {
87
+ require_protocol?: boolean;
88
+ require_valid_protocol?: boolean;
89
+ require_host?: boolean;
90
+ require_port?: boolean;
91
+ allow_protocol_relative_urls?: boolean;
92
+ allow_fragments?: boolean;
93
+ allow_query_components?: boolean;
94
+ validate_length?: boolean;
95
+ protocols?: string[];
96
+ }): /*elided*/ any;
97
+ domain(options?: {
98
+ require_tld?: boolean;
99
+ allow_underscores?: boolean;
100
+ allow_trailing_dot?: boolean;
101
+ allow_numeric_tld?: boolean;
102
+ allow_wildcard?: boolean;
103
+ ignore_max_length?: boolean;
104
+ }): /*elided*/ any;
105
+ uuid(version?: 1 | 2 | 3 | 4 | 5): /*elided*/ any;
106
+ btc(): /*elided*/ any;
107
+ eth(): /*elided*/ any;
108
+ swift(): /*elided*/ any;
109
+ mongo(): /*elided*/ any;
110
+ format(name: any, fn: any): /*elided*/ any;
111
+ toString(): any;
112
+ assertions: any[];
113
+ meta: {};
114
+ default(arg: any): /*elided*/ any;
115
+ custom(fn: Function): /*elided*/ any;
116
+ missing(fn: Function): /*elided*/ any;
117
+ strip(strip: any): /*elided*/ any;
118
+ allow(...set: any[]): /*elided*/ any;
119
+ reject(...set: any[]): /*elided*/ any;
120
+ nullable(): /*elided*/ any;
121
+ message(message: any): /*elided*/ any;
122
+ tag(tags: any): /*elided*/ any;
123
+ description(description: any): /*elided*/ any;
124
+ options(options: any): /*elided*/ any;
125
+ validate(value: any, options?: {}): Promise<any>;
126
+ clone(meta: any): /*elided*/ any;
127
+ append(schema: any): import("@bedrockio/yada/types/Schema").default;
128
+ toOpenApi(extra: any): any;
129
+ getAnyType(): {
130
+ type: string[];
131
+ };
132
+ getDefault(): {
133
+ default?: undefined;
134
+ } | {
135
+ default: any;
136
+ };
137
+ getNullable(): {
138
+ nullable: boolean;
139
+ };
140
+ expandExtra(extra?: {}): {};
141
+ inspect(): string;
142
+ get(): void;
143
+ assertEnum(set: any, allow: any): /*elided*/ any;
144
+ assert(type: any, fn: any): /*elided*/ any;
145
+ pushAssertion(assertion: any): void;
146
+ canSkipAssertion(value: any, assertion: any, options: any): any;
147
+ transform(fn: any): /*elided*/ any;
148
+ getSortIndex(type: any): number;
149
+ runAssertion(value: any, assertion: any, options?: {}): Promise<any>;
150
+ enumToOpenApi(): any;
151
+ };
152
+ export const NUMBER_RANGE_SCHEMA: {
153
+ setup(): void;
154
+ get(path?: string | Array<string>): any;
155
+ unwind(path?: string | Array<string>): any;
156
+ pick(...names?: string[]): /*elided*/ any;
157
+ omit(...names?: string[]): /*elided*/ any;
158
+ require(...fields: string[]): /*elided*/ any;
159
+ export(): any;
160
+ append(arg: import("@bedrockio/yada/types/object").SchemaMap | import("@bedrockio/yada/types/Schema").default): /*elided*/ any;
161
+ format(name: any, fn: any): /*elided*/ any;
162
+ toString(): any;
163
+ assertions: any[];
164
+ meta: {};
165
+ required(): /*elided*/ any;
166
+ default(arg: any): /*elided*/ any;
167
+ custom(fn: Function): /*elided*/ any;
168
+ missing(fn: Function): /*elided*/ any;
169
+ strip(strip: any): /*elided*/ any;
170
+ allow(...set: any[]): /*elided*/ any;
171
+ reject(...set: any[]): /*elided*/ any;
172
+ nullable(): /*elided*/ any;
173
+ message(message: any): /*elided*/ any;
174
+ tag(tags: any): /*elided*/ any;
175
+ description(description: any): /*elided*/ any;
176
+ options(options: any): /*elided*/ any;
177
+ validate(value: any, options?: {}): Promise<any>;
178
+ clone(meta: any): /*elided*/ any;
179
+ toOpenApi(extra: any): any;
180
+ getAnyType(): {
181
+ type: string[];
182
+ };
183
+ getDefault(): {
184
+ default?: undefined;
185
+ } | {
186
+ default: any;
187
+ };
188
+ getNullable(): {
189
+ nullable: boolean;
190
+ };
191
+ expandExtra(extra?: {}): {};
192
+ inspect(): string;
193
+ assertEnum(set: any, allow: any): /*elided*/ any;
194
+ assert(type: any, fn: any): /*elided*/ any;
195
+ pushAssertion(assertion: any): void;
196
+ canSkipAssertion(value: any, assertion: any, options: any): any;
197
+ transform(fn: any): /*elided*/ any;
198
+ getSortIndex(type: any): number;
199
+ runAssertion(value: any, assertion: any, options?: {}): Promise<any>;
200
+ enumToOpenApi(): any;
201
+ };
202
+ export const STRING_RANGE_SCHEMA: {
203
+ setup(): void;
204
+ get(path?: string | Array<string>): any;
205
+ unwind(path?: string | Array<string>): any;
206
+ pick(...names?: string[]): /*elided*/ any;
207
+ omit(...names?: string[]): /*elided*/ any;
208
+ require(...fields: string[]): /*elided*/ any;
209
+ export(): any;
210
+ append(arg: import("@bedrockio/yada/types/object").SchemaMap | import("@bedrockio/yada/types/Schema").default): /*elided*/ any;
211
+ format(name: any, fn: any): /*elided*/ any;
212
+ toString(): any;
213
+ assertions: any[];
214
+ meta: {};
215
+ required(): /*elided*/ any;
216
+ default(arg: any): /*elided*/ any;
217
+ custom(fn: Function): /*elided*/ any;
218
+ missing(fn: Function): /*elided*/ any;
219
+ strip(strip: any): /*elided*/ any;
220
+ allow(...set: any[]): /*elided*/ any;
221
+ reject(...set: any[]): /*elided*/ any;
222
+ nullable(): /*elided*/ any;
223
+ message(message: any): /*elided*/ any;
224
+ tag(tags: any): /*elided*/ any;
225
+ description(description: any): /*elided*/ any;
226
+ options(options: any): /*elided*/ any;
227
+ validate(value: any, options?: {}): Promise<any>;
228
+ clone(meta: any): /*elided*/ any;
229
+ toOpenApi(extra: any): any;
230
+ getAnyType(): {
231
+ type: string[];
232
+ };
233
+ getDefault(): {
234
+ default?: undefined;
235
+ } | {
236
+ default: any;
237
+ };
238
+ getNullable(): {
239
+ nullable: boolean;
240
+ };
241
+ expandExtra(extra?: {}): {};
242
+ inspect(): string;
243
+ assertEnum(set: any, allow: any): /*elided*/ any;
244
+ assert(type: any, fn: any): /*elided*/ any;
245
+ pushAssertion(assertion: any): void;
246
+ canSkipAssertion(value: any, assertion: any, options: any): any;
247
+ transform(fn: any): /*elided*/ any;
248
+ getSortIndex(type: any): number;
249
+ runAssertion(value: any, assertion: any, options?: {}): Promise<any>;
250
+ enumToOpenApi(): any;
251
+ };
252
+ export const DATE_RANGE_SCHEMA: {
253
+ setup(): void;
254
+ get(path?: string | Array<string>): any;
255
+ unwind(path?: string | Array<string>): any;
256
+ pick(...names?: string[]): /*elided*/ any;
257
+ omit(...names?: string[]): /*elided*/ any;
258
+ require(...fields: string[]): /*elided*/ any;
259
+ export(): any;
260
+ append(arg: import("@bedrockio/yada/types/object").SchemaMap | import("@bedrockio/yada/types/Schema").default): /*elided*/ any;
261
+ format(name: any, fn: any): /*elided*/ any;
262
+ toString(): any;
263
+ assertions: any[];
264
+ meta: {};
265
+ required(): /*elided*/ any;
266
+ default(arg: any): /*elided*/ any;
267
+ custom(fn: Function): /*elided*/ any;
268
+ missing(fn: Function): /*elided*/ any;
269
+ strip(strip: any): /*elided*/ any;
270
+ allow(...set: any[]): /*elided*/ any;
271
+ reject(...set: any[]): /*elided*/ any;
272
+ nullable(): /*elided*/ any;
273
+ message(message: any): /*elided*/ any;
274
+ tag(tags: any): /*elided*/ any;
275
+ description(description: any): /*elided*/ any;
276
+ options(options: any): /*elided*/ any;
277
+ validate(value: any, options?: {}): Promise<any>;
278
+ clone(meta: any): /*elided*/ any;
279
+ toOpenApi(extra: any): any;
280
+ getAnyType(): {
281
+ type: string[];
282
+ };
283
+ getDefault(): {
284
+ default?: undefined;
285
+ } | {
286
+ default: any;
287
+ };
288
+ getNullable(): {
289
+ nullable: boolean;
290
+ };
291
+ expandExtra(extra?: {}): {};
292
+ inspect(): string;
293
+ assertEnum(set: any, allow: any): /*elided*/ any;
294
+ assert(type: any, fn: any): /*elided*/ any;
295
+ pushAssertion(assertion: any): void;
296
+ canSkipAssertion(value: any, assertion: any, options: any): any;
297
+ transform(fn: any): /*elided*/ any;
298
+ getSortIndex(type: any): number;
299
+ runAssertion(value: any, assertion: any, options?: {}): Promise<any>;
300
+ enumToOpenApi(): any;
301
+ };
302
+ export const REFERENCE_SCHEMA: import("@bedrockio/yada/types/Schema").default;
303
+ //# sourceMappingURL=validation-schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation-schemas.d.ts","sourceRoot":"","sources":["../src/validation-schemas.js"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAoEI,CAAA;;;;;;;;;;;;;;;;;;EApEsD;AAE1D;;;;;;;;;;;;;;;;eAyBwB,CAAC;;;;;;;;;;;;iBAuBjB,CAAA;kBAA4B,CAAC;kBAEjC,CAAF;oBAEI,CAAC;oBAEI,CAAC;;;wBA2BC,CAAC;8BAGI,CAAC;oBAA+B,CAAC;oBAE1C,CAAC;oCAEL,CAAC;uBAAkC,CAAC;8BAAyC,CAAC;uBACzD,CAAC;iBAA4B,CAAC;;;mBAG0V,CAAC;yBAAoC,CAAC;0BAAqC,CAAC;yBAAoC,CAAC;sBAAiC,CAAC;yBAAoC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eA1BtkB,CAAA;;;;;;;;;;;;;;;;;;EA1DC;AAEL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAwDI,CAAA;;;;;;;;;;;;;;;;;EA9CC;AAEL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eA4CI,CAAA;;;;;;;;;;;;;;;;;EAlCC;AAEL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAgCI,CAAA;;;;;;;;;;;;;;;;;EAEC;AAEL,8EAqBK"}
@@ -9,104 +9,4 @@ export function getTupleValidator(types: any): {
9
9
  (val: any): Promise<void>;
10
10
  schema: any;
11
11
  };
12
- export const OBJECT_ID_SCHEMA: {
13
- required(): /*elided*/ any;
14
- length(length: number): /*elided*/ any;
15
- min(length: number): /*elided*/ any;
16
- max(length: number): /*elided*/ any;
17
- trim(): /*elided*/ any;
18
- lowercase(assert?: boolean): /*elided*/ any;
19
- uppercase(assert?: boolean): /*elided*/ any;
20
- match(reg: RegExp): /*elided*/ any;
21
- email(): /*elided*/ any;
22
- phone(code: any): /*elided*/ any;
23
- hex(): /*elided*/ any;
24
- md5(): /*elided*/ any;
25
- sha1(): /*elided*/ any;
26
- ascii(): /*elided*/ any;
27
- base64(options?: {
28
- urlSafe?: boolean;
29
- }): /*elided*/ any;
30
- creditCard(): /*elided*/ any;
31
- ip(): /*elided*/ any;
32
- country(): /*elided*/ any;
33
- locale(): /*elided*/ any;
34
- jwt(): /*elided*/ any;
35
- slug(): /*elided*/ any;
36
- latlng(): /*elided*/ any;
37
- postalCode(locale?: string): /*elided*/ any;
38
- zipcode(): /*elided*/ any;
39
- password(options?: {
40
- minLength?: number;
41
- minNumbers?: number;
42
- minSymbols?: number;
43
- minLowercase?: number;
44
- minUppercase?: number;
45
- }): /*elided*/ any;
46
- url(options?: {
47
- require_protocol?: boolean;
48
- require_valid_protocol?: boolean;
49
- require_host?: boolean;
50
- require_port?: boolean;
51
- allow_protocol_relative_urls?: boolean;
52
- allow_fragments?: boolean;
53
- allow_query_components?: boolean;
54
- validate_length?: boolean;
55
- protocols?: string[];
56
- }): /*elided*/ any;
57
- domain(options?: {
58
- require_tld?: boolean;
59
- allow_underscores?: boolean;
60
- allow_trailing_dot?: boolean;
61
- allow_numeric_tld?: boolean;
62
- allow_wildcard?: boolean;
63
- ignore_max_length?: boolean;
64
- }): /*elided*/ any;
65
- uuid(version?: 1 | 2 | 3 | 4 | 5): /*elided*/ any;
66
- btc(): /*elided*/ any;
67
- eth(): /*elided*/ any;
68
- swift(): /*elided*/ any;
69
- mongo(): /*elided*/ any;
70
- format(name: any, fn: any): /*elided*/ any;
71
- toString(): any;
72
- assertions: any[];
73
- meta: {};
74
- default(arg: any): /*elided*/ any;
75
- custom(fn: Function): /*elided*/ any;
76
- missing(fn: Function): /*elided*/ any;
77
- strip(strip: any): /*elided*/ any;
78
- allow(...set: any[]): /*elided*/ any;
79
- reject(...set: any[]): /*elided*/ any;
80
- nullable(): /*elided*/ any;
81
- message(message: any): /*elided*/ any;
82
- tag(tags: any): /*elided*/ any;
83
- description(description: any): /*elided*/ any;
84
- options(options: any): /*elided*/ any;
85
- validate(value: any, options?: {}): Promise<any>;
86
- clone(meta: any): /*elided*/ any;
87
- append(schema: any): import("@bedrockio/yada/types/Schema").default;
88
- toOpenApi(extra: any): any;
89
- getAnyType(): {
90
- type: string[];
91
- };
92
- getDefault(): {
93
- default?: undefined;
94
- } | {
95
- default: any;
96
- };
97
- getNullable(): {
98
- nullable: boolean;
99
- };
100
- expandExtra(extra?: {}): {};
101
- inspect(): string;
102
- get(): void;
103
- assertEnum(set: any, allow: any): /*elided*/ any;
104
- assert(type: any, fn: any): /*elided*/ any;
105
- pushAssertion(assertion: any): void;
106
- canSkipAssertion(value: any, assertion: any, options: any): any;
107
- transform(fn: any): /*elided*/ any;
108
- getSortIndex(type: any): number;
109
- runAssertion(value: any, assertion: any, options?: {}): Promise<any>;
110
- enumToOpenApi(): any;
111
- };
112
12
  //# sourceMappingURL=validation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.js"],"names":[],"mappings":"AAoFA,kDAEC;AAED,oEAkFC;AAsBD,wEAoBC;AAgWD;;;EAEC;AAED;;;EAOC;AA7iBD;;;;;;;;;;;;;;;;eAwBQ,CAAC;;;;;;;;;;;;iBAcmC,CAAC;kBAC3B,CAAC;kBAEH,CAAC;oBACA,CAAC;oBACF,CAAC;;;wBAmBZ,CAAC;8BACe,CAAC;oBAGD,CAAC;oBACV,CAAC;oCAGG,CAAC;uBAAmC,CAAA;8BAE9B,CAAC;uBACO,CAAC;iBACrB,CAAC;;;mBAkBL,CAAL;yBAAoC,CAAC;0BACpB,CAAC;yBACT,CAAC;sBAEH,CAAN;yBACc,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eA9CQ,CAAC;;;;;;;;;;;;;;;;;;EA3CrB"}
1
+ {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.js"],"names":[],"mappings":"AAqDA,kDAEC;AAED,oEAkFC;AAsBD,wEAoBC;AA8SD;;;EAEC;AAED;;;EAOC"}