@bedrockio/model 0.12.2 → 0.13.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 +11 -0
- package/README.md +10 -5
- package/dist/cjs/include.js +6 -0
- package/dist/cjs/search.js +14 -0
- package/dist/cjs/validation.js +25 -29
- package/package.json +3 -3
- package/src/include.js +7 -0
- package/src/search.js +15 -0
- package/src/validation.js +51 -47
- package/types/search.d.ts +204 -0
- package/types/search.d.ts.map +1 -1
- package/types/validation-schemas.d.ts +2 -1
- package/types/validation-schemas.d.ts.map +1 -1
- package/types/validation.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
## 0.13.0
|
|
2
|
+
|
|
3
|
+
- Removed support for passing schemas into `getCreateValidation` etc. now that
|
|
4
|
+
other methods available on yada exist. Instead allow more flexibility in
|
|
5
|
+
schema options.
|
|
6
|
+
- Allow appending export schema as an option.
|
|
7
|
+
|
|
8
|
+
## 0.12.3
|
|
9
|
+
|
|
10
|
+
- Support for `include` with top level dynamic references.
|
|
11
|
+
|
|
1
12
|
## 0.12.2
|
|
2
13
|
|
|
3
14
|
- Updated validators for string ranges.
|
package/README.md
CHANGED
|
@@ -456,8 +456,9 @@ validation which will:
|
|
|
456
456
|
- `Model.restoreMany`
|
|
457
457
|
- `Model.insertMany`
|
|
458
458
|
- `Model.replaceOne`
|
|
459
|
-
- Append the same validation to `Model.
|
|
460
|
-
`Model.
|
|
459
|
+
- Append the same validation to `Model.getCreateValidation` and
|
|
460
|
+
`Model.getUpdateValidation` to allow this constraint to trickle down to the
|
|
461
|
+
API.
|
|
461
462
|
|
|
462
463
|
> [!WARNING] Note that calling `Model.updateOne` will throw an error when a
|
|
463
464
|
> unique field exists on any document **including the document being updated**.
|
|
@@ -480,7 +481,7 @@ const router = new Router();
|
|
|
480
481
|
router.post(
|
|
481
482
|
'/',
|
|
482
483
|
validateBody(
|
|
483
|
-
User.getCreateValidation({
|
|
484
|
+
User.getCreateValidation().append({
|
|
484
485
|
password: yd.string().password().required(),
|
|
485
486
|
}),
|
|
486
487
|
),
|
|
@@ -547,7 +548,7 @@ new ones:
|
|
|
547
548
|
import yd from '@bedrockio/yada';
|
|
548
549
|
|
|
549
550
|
const signupSchema = yd.object({
|
|
550
|
-
...User.
|
|
551
|
+
...User.getCreateValidation().export(),
|
|
551
552
|
additionalField: yd.string().required(),
|
|
552
553
|
});
|
|
553
554
|
```
|
|
@@ -1050,6 +1051,10 @@ await Product.findById(id).include('shop.user.^name').
|
|
|
1050
1051
|
}
|
|
1051
1052
|
```
|
|
1052
1053
|
|
|
1054
|
+
> [!WARNING] Fields that are dynamically referenced using `refPath` are unable
|
|
1055
|
+
> to resolve the schemas beforehand (ie. before query execution), therefore they
|
|
1056
|
+
> can only be populated at the top level.
|
|
1057
|
+
|
|
1053
1058
|
#### Excluded Fields
|
|
1054
1059
|
|
|
1055
1060
|
Fields can be excluded rather than included using `-`:
|
|
@@ -1286,7 +1291,7 @@ against scopes in the generated validations or when serializing:
|
|
|
1286
1291
|
|
|
1287
1292
|
```js
|
|
1288
1293
|
// In validation middleware:
|
|
1289
|
-
const schema = User.
|
|
1294
|
+
const schema = User.getCreateValidation();
|
|
1290
1295
|
await schema.validate(ctx.request.body, {
|
|
1291
1296
|
scopes: authUser.getScopes(),
|
|
1292
1297
|
// Also accepted:
|
package/dist/cjs/include.js
CHANGED
|
@@ -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
|
}
|
package/dist/cjs/search.js
CHANGED
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.applySearch = applySearch;
|
|
7
|
+
exports.exportValidation = exportValidation;
|
|
7
8
|
exports.searchValidation = searchValidation;
|
|
8
9
|
var _yada = _interopRequireDefault(require("@bedrockio/yada"));
|
|
9
10
|
var _logger = _interopRequireDefault(require("@bedrockio/logger"));
|
|
@@ -57,6 +58,19 @@ function searchValidation(options = {}) {
|
|
|
57
58
|
...appendSchema
|
|
58
59
|
});
|
|
59
60
|
}
|
|
61
|
+
function exportValidation(options = {}) {
|
|
62
|
+
const {
|
|
63
|
+
defaults,
|
|
64
|
+
formats = ['csv']
|
|
65
|
+
} = options;
|
|
66
|
+
const {
|
|
67
|
+
filename = 'export.csv'
|
|
68
|
+
} = defaults || {};
|
|
69
|
+
return {
|
|
70
|
+
filename: _yada.default.string().default(filename).description('Filename when search is exported.'),
|
|
71
|
+
format: _yada.default.string().allow('json', ...formats).default('json')
|
|
72
|
+
};
|
|
73
|
+
}
|
|
60
74
|
function searchQuery(Model, options, config) {
|
|
61
75
|
const {
|
|
62
76
|
schema
|
package/dist/cjs/validation.js
CHANGED
|
@@ -54,65 +54,65 @@ function addValidators(schemas) {
|
|
|
54
54
|
Object.assign(NAMED_SCHEMAS, schemas);
|
|
55
55
|
}
|
|
56
56
|
function applyValidation(schema, definition) {
|
|
57
|
-
schema.static('getCreateValidation', function getCreateValidation(options
|
|
58
|
-
const {
|
|
59
|
-
allowInclude,
|
|
60
|
-
...appendSchema
|
|
61
|
-
} = options;
|
|
57
|
+
schema.static('getCreateValidation', function getCreateValidation(options) {
|
|
62
58
|
return getSchemaFromMongoose(schema, {
|
|
63
59
|
model: this,
|
|
64
|
-
appendSchema,
|
|
65
|
-
allowInclude,
|
|
66
60
|
stripEmpty: true,
|
|
67
61
|
stripDeleted: true,
|
|
62
|
+
allowInclude: false,
|
|
68
63
|
stripTimestamps: true,
|
|
69
64
|
allowDefaultTags: true,
|
|
70
65
|
allowExpandedRefs: true,
|
|
71
|
-
requireWriteAccess: true
|
|
66
|
+
requireWriteAccess: true,
|
|
67
|
+
...options
|
|
72
68
|
});
|
|
73
69
|
});
|
|
74
|
-
schema.static('getUpdateValidation', function getUpdateValidation(options
|
|
75
|
-
const {
|
|
76
|
-
allowInclude,
|
|
77
|
-
...appendSchema
|
|
78
|
-
} = options;
|
|
70
|
+
schema.static('getUpdateValidation', function getUpdateValidation(options) {
|
|
79
71
|
return getSchemaFromMongoose(schema, {
|
|
80
72
|
model: this,
|
|
81
|
-
appendSchema,
|
|
82
|
-
allowInclude,
|
|
83
73
|
allowNull: true,
|
|
84
74
|
skipRequired: true,
|
|
85
75
|
stripUnknown: true,
|
|
86
76
|
stripDeleted: true,
|
|
77
|
+
allowInclude: false,
|
|
87
78
|
stripTimestamps: true,
|
|
88
79
|
allowExpandedRefs: true,
|
|
89
80
|
requireWriteAccess: true,
|
|
90
|
-
updateAccess: definition.access?.update
|
|
81
|
+
updateAccess: definition.access?.update,
|
|
82
|
+
...options
|
|
91
83
|
});
|
|
92
84
|
});
|
|
93
85
|
schema.static('getSearchValidation', function getSearchValidation(options = {}) {
|
|
94
86
|
const {
|
|
87
|
+
allowExport,
|
|
95
88
|
defaults,
|
|
96
|
-
|
|
97
|
-
...
|
|
89
|
+
formats,
|
|
90
|
+
...rest
|
|
98
91
|
} = options;
|
|
99
|
-
|
|
92
|
+
let validation = getSchemaFromMongoose(schema, {
|
|
100
93
|
model: this,
|
|
101
94
|
allowNull: true,
|
|
102
95
|
stripEmpty: true,
|
|
103
96
|
allowSearch: true,
|
|
104
97
|
skipRequired: true,
|
|
105
98
|
allowInclude: true,
|
|
99
|
+
stripDeleted: true,
|
|
106
100
|
expandDotSyntax: true,
|
|
107
101
|
unwindArrayFields: true,
|
|
108
102
|
requireReadAccess: true,
|
|
109
|
-
|
|
110
|
-
appendSchema: (0, _search.searchValidation)({
|
|
111
|
-
defaults,
|
|
112
|
-
definition,
|
|
113
|
-
appendSchema
|
|
114
|
-
})
|
|
103
|
+
...rest
|
|
115
104
|
});
|
|
105
|
+
validation = validation.append((0, _search.searchValidation)({
|
|
106
|
+
defaults,
|
|
107
|
+
definition
|
|
108
|
+
}));
|
|
109
|
+
if (allowExport) {
|
|
110
|
+
validation = validation.append((0, _search.exportValidation)({
|
|
111
|
+
formats,
|
|
112
|
+
defaults
|
|
113
|
+
}));
|
|
114
|
+
}
|
|
115
|
+
return validation;
|
|
116
116
|
});
|
|
117
117
|
schema.static('getDeleteValidation', function getDeleteValidation() {
|
|
118
118
|
const allowed = definition.access?.delete || 'all';
|
|
@@ -157,14 +157,10 @@ function getMongooseFields(schema, options) {
|
|
|
157
157
|
// Exported for testing
|
|
158
158
|
function getValidationSchema(attributes, options = {}) {
|
|
159
159
|
const {
|
|
160
|
-
appendSchema,
|
|
161
160
|
allowInclude,
|
|
162
161
|
updateAccess
|
|
163
162
|
} = options;
|
|
164
163
|
let schema = getObjectSchema(attributes, options);
|
|
165
|
-
if (appendSchema) {
|
|
166
|
-
schema = schema.append(appendSchema);
|
|
167
|
-
}
|
|
168
164
|
if (allowInclude) {
|
|
169
165
|
schema = schema.append(_include.INCLUDE_FIELD_SCHEMA);
|
|
170
166
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bedrockio/model",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "Bedrock utilities for model creation.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"lodash": "^4.17.21"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"@bedrockio/yada": "^1.
|
|
33
|
+
"@bedrockio/yada": "^1.5.0",
|
|
34
34
|
"mongoose": "^8.13.1"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@babel/preset-env": "^7.26.0",
|
|
40
40
|
"@bedrockio/eslint-plugin": "^1.1.7",
|
|
41
41
|
"@bedrockio/prettier-config": "^1.0.2",
|
|
42
|
-
"@bedrockio/yada": "^1.
|
|
42
|
+
"@bedrockio/yada": "^1.5.0",
|
|
43
43
|
"@shelf/jest-mongodb": "^5.1.0",
|
|
44
44
|
"eslint": "^9.19.0",
|
|
45
45
|
"jest": "^29.7.0",
|
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
|
@@ -63,6 +63,21 @@ export function searchValidation(options = {}) {
|
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
export function exportValidation(options = {}) {
|
|
67
|
+
const { defaults, formats = ['csv'] } = options;
|
|
68
|
+
const { filename = 'export.csv' } = defaults || {};
|
|
69
|
+
return {
|
|
70
|
+
filename: yd
|
|
71
|
+
.string()
|
|
72
|
+
.default(filename)
|
|
73
|
+
.description('Filename when search is exported.'),
|
|
74
|
+
format: yd
|
|
75
|
+
.string()
|
|
76
|
+
.allow('json', ...formats)
|
|
77
|
+
.default('json'),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
66
81
|
function searchQuery(Model, options, config) {
|
|
67
82
|
const { schema } = Model;
|
|
68
83
|
|
package/src/validation.js
CHANGED
|
@@ -4,7 +4,7 @@ import yd from '@bedrockio/yada';
|
|
|
4
4
|
import { get, omit, lowerFirst } from 'lodash';
|
|
5
5
|
|
|
6
6
|
import { hasAccess } from './access';
|
|
7
|
-
import { searchValidation } from './search';
|
|
7
|
+
import { searchValidation, exportValidation } from './search';
|
|
8
8
|
import { assertUnique } from './soft-delete';
|
|
9
9
|
import { PermissionsError, ImplementationError } from './errors';
|
|
10
10
|
import { isMongooseSchema, isSchemaTypedef } from './utils';
|
|
@@ -56,65 +56,72 @@ export function addValidators(schemas) {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
export function applyValidation(schema, definition) {
|
|
59
|
-
schema.static(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
requireWriteAccess: true,
|
|
73
|
-
});
|
|
74
|
-
},
|
|
75
|
-
);
|
|
59
|
+
schema.static('getCreateValidation', function getCreateValidation(options) {
|
|
60
|
+
return getSchemaFromMongoose(schema, {
|
|
61
|
+
model: this,
|
|
62
|
+
stripEmpty: true,
|
|
63
|
+
stripDeleted: true,
|
|
64
|
+
allowInclude: false,
|
|
65
|
+
stripTimestamps: true,
|
|
66
|
+
allowDefaultTags: true,
|
|
67
|
+
allowExpandedRefs: true,
|
|
68
|
+
requireWriteAccess: true,
|
|
69
|
+
...options,
|
|
70
|
+
});
|
|
71
|
+
});
|
|
76
72
|
|
|
77
|
-
schema.static(
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
updateAccess: definition.access?.update,
|
|
93
|
-
});
|
|
94
|
-
},
|
|
95
|
-
);
|
|
73
|
+
schema.static('getUpdateValidation', function getUpdateValidation(options) {
|
|
74
|
+
return getSchemaFromMongoose(schema, {
|
|
75
|
+
model: this,
|
|
76
|
+
allowNull: true,
|
|
77
|
+
skipRequired: true,
|
|
78
|
+
stripUnknown: true,
|
|
79
|
+
stripDeleted: true,
|
|
80
|
+
allowInclude: false,
|
|
81
|
+
stripTimestamps: true,
|
|
82
|
+
allowExpandedRefs: true,
|
|
83
|
+
requireWriteAccess: true,
|
|
84
|
+
updateAccess: definition.access?.update,
|
|
85
|
+
...options,
|
|
86
|
+
});
|
|
87
|
+
});
|
|
96
88
|
|
|
97
89
|
schema.static(
|
|
98
90
|
'getSearchValidation',
|
|
99
91
|
function getSearchValidation(options = {}) {
|
|
100
|
-
const { defaults,
|
|
101
|
-
|
|
92
|
+
const { allowExport, defaults, formats, ...rest } = options;
|
|
93
|
+
|
|
94
|
+
let validation = getSchemaFromMongoose(schema, {
|
|
102
95
|
model: this,
|
|
103
96
|
allowNull: true,
|
|
104
97
|
stripEmpty: true,
|
|
105
98
|
allowSearch: true,
|
|
106
99
|
skipRequired: true,
|
|
107
100
|
allowInclude: true,
|
|
101
|
+
stripDeleted: true,
|
|
108
102
|
expandDotSyntax: true,
|
|
109
103
|
unwindArrayFields: true,
|
|
110
104
|
requireReadAccess: true,
|
|
111
|
-
|
|
112
|
-
|
|
105
|
+
...rest,
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
validation = validation.append(
|
|
109
|
+
searchValidation({
|
|
113
110
|
defaults,
|
|
114
111
|
definition,
|
|
115
|
-
appendSchema,
|
|
116
112
|
}),
|
|
117
|
-
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
if (allowExport) {
|
|
116
|
+
validation = validation.append(
|
|
117
|
+
exportValidation({
|
|
118
|
+
formats,
|
|
119
|
+
defaults,
|
|
120
|
+
}),
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return validation;
|
|
118
125
|
},
|
|
119
126
|
);
|
|
120
127
|
|
|
@@ -160,13 +167,10 @@ function getMongooseFields(schema, options) {
|
|
|
160
167
|
|
|
161
168
|
// Exported for testing
|
|
162
169
|
export function getValidationSchema(attributes, options = {}) {
|
|
163
|
-
const {
|
|
170
|
+
const { allowInclude, updateAccess } = options;
|
|
164
171
|
|
|
165
172
|
let schema = getObjectSchema(attributes, options);
|
|
166
173
|
|
|
167
|
-
if (appendSchema) {
|
|
168
|
-
schema = schema.append(appendSchema);
|
|
169
|
-
}
|
|
170
174
|
if (allowInclude) {
|
|
171
175
|
schema = schema.append(INCLUDE_FIELD_SCHEMA);
|
|
172
176
|
}
|
package/types/search.d.ts
CHANGED
|
@@ -49,4 +49,208 @@ export function searchValidation(options?: {}): {
|
|
|
49
49
|
runAssertion(value: any, assertion: any, options?: {}): Promise<any>;
|
|
50
50
|
enumToOpenApi(): any;
|
|
51
51
|
};
|
|
52
|
+
export function exportValidation(options?: {}): {
|
|
53
|
+
filename: {
|
|
54
|
+
required(): /*elided*/ any;
|
|
55
|
+
length(length: number): /*elided*/ any;
|
|
56
|
+
min(length: number): /*elided*/ any;
|
|
57
|
+
max(length: number): /*elided*/ any;
|
|
58
|
+
trim(): /*elided*/ any;
|
|
59
|
+
lowercase(assert?: boolean): /*elided*/ any;
|
|
60
|
+
uppercase(assert?: boolean): /*elided*/ any;
|
|
61
|
+
match(reg: RegExp): /*elided*/ any;
|
|
62
|
+
email(): /*elided*/ any;
|
|
63
|
+
phone(code: any): /*elided*/ any;
|
|
64
|
+
hex(): /*elided*/ any;
|
|
65
|
+
md5(): /*elided*/ any;
|
|
66
|
+
sha1(): /*elided*/ any;
|
|
67
|
+
ascii(): /*elided*/ any;
|
|
68
|
+
base64(options?: {
|
|
69
|
+
urlSafe?: boolean;
|
|
70
|
+
}): /*elided*/ any;
|
|
71
|
+
creditCard(): /*elided*/ any;
|
|
72
|
+
ip(): /*elided*/ any;
|
|
73
|
+
country(): /*elided*/ any;
|
|
74
|
+
locale(): /*elided*/ any;
|
|
75
|
+
jwt(): /*elided*/ any;
|
|
76
|
+
slug(): /*elided*/ any;
|
|
77
|
+
latlng(): /*elided*/ any;
|
|
78
|
+
postalCode(locale?: string): /*elided*/ any;
|
|
79
|
+
zipcode(): /*elided*/ any;
|
|
80
|
+
password(options?: {
|
|
81
|
+
minLength?: number;
|
|
82
|
+
minNumbers?: number;
|
|
83
|
+
minSymbols?: number;
|
|
84
|
+
minLowercase?: number;
|
|
85
|
+
minUppercase?: number;
|
|
86
|
+
}): /*elided*/ any;
|
|
87
|
+
url(options?: {
|
|
88
|
+
require_protocol?: boolean;
|
|
89
|
+
require_valid_protocol?: boolean;
|
|
90
|
+
require_host?: boolean;
|
|
91
|
+
require_port?: boolean;
|
|
92
|
+
allow_protocol_relative_urls?: boolean;
|
|
93
|
+
allow_fragments?: boolean;
|
|
94
|
+
allow_query_components?: boolean;
|
|
95
|
+
validate_length?: boolean;
|
|
96
|
+
protocols?: string[];
|
|
97
|
+
}): /*elided*/ any;
|
|
98
|
+
domain(options?: {
|
|
99
|
+
require_tld?: boolean;
|
|
100
|
+
allow_underscores?: boolean;
|
|
101
|
+
allow_trailing_dot?: boolean;
|
|
102
|
+
allow_numeric_tld?: boolean;
|
|
103
|
+
allow_wildcard?: boolean;
|
|
104
|
+
ignore_max_length?: boolean;
|
|
105
|
+
}): /*elided*/ any;
|
|
106
|
+
uuid(version?: 1 | 2 | 3 | 4 | 5): /*elided*/ any;
|
|
107
|
+
btc(): /*elided*/ any;
|
|
108
|
+
eth(): /*elided*/ any;
|
|
109
|
+
swift(): /*elided*/ any;
|
|
110
|
+
mongo(): /*elided*/ any;
|
|
111
|
+
calendar(): /*elided*/ any;
|
|
112
|
+
format(name: any, fn: any): /*elided*/ any;
|
|
113
|
+
toString(): any;
|
|
114
|
+
assertions: any[];
|
|
115
|
+
meta: {};
|
|
116
|
+
default(arg: any): /*elided*/ any;
|
|
117
|
+
custom(fn: Function): /*elided*/ any;
|
|
118
|
+
missing(fn: Function): /*elided*/ any;
|
|
119
|
+
strip(strip: any): /*elided*/ any;
|
|
120
|
+
allow(...set: any[]): /*elided*/ any;
|
|
121
|
+
reject(...set: any[]): /*elided*/ any;
|
|
122
|
+
nullable(): /*elided*/ any;
|
|
123
|
+
message(message: any): /*elided*/ any;
|
|
124
|
+
tag(tags: any): /*elided*/ any;
|
|
125
|
+
description(description: any): /*elided*/ any;
|
|
126
|
+
options(options: any): /*elided*/ any;
|
|
127
|
+
validate(value: any, options?: {}): Promise<any>;
|
|
128
|
+
clone(meta: any): /*elided*/ any;
|
|
129
|
+
append(schema: any): import("@bedrockio/yada/types/Schema").default;
|
|
130
|
+
toOpenApi(extra: any): any;
|
|
131
|
+
getAnyType(): {
|
|
132
|
+
type: string[];
|
|
133
|
+
};
|
|
134
|
+
getDefault(): {
|
|
135
|
+
default?: undefined;
|
|
136
|
+
} | {
|
|
137
|
+
default: any;
|
|
138
|
+
};
|
|
139
|
+
getNullable(): {
|
|
140
|
+
nullable: boolean;
|
|
141
|
+
};
|
|
142
|
+
expandExtra(extra?: {}): {};
|
|
143
|
+
inspect(): string;
|
|
144
|
+
get(): void;
|
|
145
|
+
assertEnum(set: any, allow: any): /*elided*/ any;
|
|
146
|
+
assert(type: any, fn: any): /*elided*/ any;
|
|
147
|
+
pushAssertion(assertion: any): void;
|
|
148
|
+
canSkipAssertion(value: any, assertion: any, options: any): any;
|
|
149
|
+
transform(fn: any): /*elided*/ any;
|
|
150
|
+
getSortIndex(type: any): number;
|
|
151
|
+
runAssertion(value: any, assertion: any, options?: {}): Promise<any>;
|
|
152
|
+
enumToOpenApi(): any;
|
|
153
|
+
};
|
|
154
|
+
format: {
|
|
155
|
+
required(): /*elided*/ any;
|
|
156
|
+
length(length: number): /*elided*/ any;
|
|
157
|
+
min(length: number): /*elided*/ any;
|
|
158
|
+
max(length: number): /*elided*/ any;
|
|
159
|
+
trim(): /*elided*/ any;
|
|
160
|
+
lowercase(assert?: boolean): /*elided*/ any;
|
|
161
|
+
uppercase(assert?: boolean): /*elided*/ any;
|
|
162
|
+
match(reg: RegExp): /*elided*/ any;
|
|
163
|
+
email(): /*elided*/ any;
|
|
164
|
+
phone(code: any): /*elided*/ any;
|
|
165
|
+
hex(): /*elided*/ any;
|
|
166
|
+
md5(): /*elided*/ any;
|
|
167
|
+
sha1(): /*elided*/ any;
|
|
168
|
+
ascii(): /*elided*/ any;
|
|
169
|
+
base64(options?: {
|
|
170
|
+
urlSafe?: boolean;
|
|
171
|
+
}): /*elided*/ any;
|
|
172
|
+
creditCard(): /*elided*/ any;
|
|
173
|
+
ip(): /*elided*/ any;
|
|
174
|
+
country(): /*elided*/ any;
|
|
175
|
+
locale(): /*elided*/ any;
|
|
176
|
+
jwt(): /*elided*/ any;
|
|
177
|
+
slug(): /*elided*/ any;
|
|
178
|
+
latlng(): /*elided*/ any;
|
|
179
|
+
postalCode(locale?: string): /*elided*/ any;
|
|
180
|
+
zipcode(): /*elided*/ any;
|
|
181
|
+
password(options?: {
|
|
182
|
+
minLength?: number;
|
|
183
|
+
minNumbers?: number;
|
|
184
|
+
minSymbols?: number;
|
|
185
|
+
minLowercase?: number;
|
|
186
|
+
minUppercase?: number;
|
|
187
|
+
}): /*elided*/ any;
|
|
188
|
+
url(options?: {
|
|
189
|
+
require_protocol?: boolean;
|
|
190
|
+
require_valid_protocol?: boolean;
|
|
191
|
+
require_host?: boolean;
|
|
192
|
+
require_port?: boolean;
|
|
193
|
+
allow_protocol_relative_urls?: boolean;
|
|
194
|
+
allow_fragments?: boolean;
|
|
195
|
+
allow_query_components?: boolean;
|
|
196
|
+
validate_length?: boolean;
|
|
197
|
+
protocols?: string[];
|
|
198
|
+
}): /*elided*/ any;
|
|
199
|
+
domain(options?: {
|
|
200
|
+
require_tld?: boolean;
|
|
201
|
+
allow_underscores?: boolean;
|
|
202
|
+
allow_trailing_dot?: boolean;
|
|
203
|
+
allow_numeric_tld?: boolean;
|
|
204
|
+
allow_wildcard?: boolean;
|
|
205
|
+
ignore_max_length?: boolean;
|
|
206
|
+
}): /*elided*/ any;
|
|
207
|
+
uuid(version?: 1 | 2 | 3 | 4 | 5): /*elided*/ any;
|
|
208
|
+
btc(): /*elided*/ any;
|
|
209
|
+
eth(): /*elided*/ any;
|
|
210
|
+
swift(): /*elided*/ any;
|
|
211
|
+
mongo(): /*elided*/ any;
|
|
212
|
+
calendar(): /*elided*/ any;
|
|
213
|
+
format(name: any, fn: any): /*elided*/ any;
|
|
214
|
+
toString(): any;
|
|
215
|
+
assertions: any[];
|
|
216
|
+
meta: {};
|
|
217
|
+
default(arg: any): /*elided*/ any;
|
|
218
|
+
custom(fn: Function): /*elided*/ any;
|
|
219
|
+
missing(fn: Function): /*elided*/ any;
|
|
220
|
+
strip(strip: any): /*elided*/ any;
|
|
221
|
+
allow(...set: any[]): /*elided*/ any;
|
|
222
|
+
reject(...set: any[]): /*elided*/ any;
|
|
223
|
+
nullable(): /*elided*/ any;
|
|
224
|
+
message(message: any): /*elided*/ any;
|
|
225
|
+
tag(tags: any): /*elided*/ any;
|
|
226
|
+
description(description: any): /*elided*/ any;
|
|
227
|
+
options(options: any): /*elided*/ any;
|
|
228
|
+
validate(value: any, options?: {}): Promise<any>;
|
|
229
|
+
clone(meta: any): /*elided*/ any;
|
|
230
|
+
append(schema: any): import("@bedrockio/yada/types/Schema").default;
|
|
231
|
+
toOpenApi(extra: any): any;
|
|
232
|
+
getAnyType(): {
|
|
233
|
+
type: string[];
|
|
234
|
+
};
|
|
235
|
+
getDefault(): {
|
|
236
|
+
default?: undefined;
|
|
237
|
+
} | {
|
|
238
|
+
default: any;
|
|
239
|
+
};
|
|
240
|
+
getNullable(): {
|
|
241
|
+
nullable: boolean;
|
|
242
|
+
};
|
|
243
|
+
expandExtra(extra?: {}): {};
|
|
244
|
+
inspect(): string;
|
|
245
|
+
get(): void;
|
|
246
|
+
assertEnum(set: any, allow: any): /*elided*/ any;
|
|
247
|
+
assert(type: any, fn: any): /*elided*/ any;
|
|
248
|
+
pushAssertion(assertion: any): void;
|
|
249
|
+
canSkipAssertion(value: any, assertion: any, options: any): any;
|
|
250
|
+
transform(fn: any): /*elided*/ any;
|
|
251
|
+
getSortIndex(type: any): number;
|
|
252
|
+
runAssertion(value: any, assertion: any, options?: {}): Promise<any>;
|
|
253
|
+
enumToOpenApi(): any;
|
|
254
|
+
};
|
|
255
|
+
};
|
|
52
256
|
//# sourceMappingURL=search.d.ts.map
|
package/types/search.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../src/search.js"],"names":[],"mappings":"AAuBA,gEAaC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../src/search.js"],"names":[],"mappings":"AAuBA,gEAaC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eA0CyC,CAAC;;;;;;;;;;;;;;;;;EAjBzC;AAED;;;;;;;;;;;;;;;;;mBAtBI,CAAA;;;;;;;;;;;;qBAuBC,CAAC;sBAA4B,CAAC;sBACvB,CAAC;wBAA8B,CAAC;wBAEnC,CAAC;;;4BA2BK,CAAC;kCACwB,CAAC;wBACrC,CAAA;wBAA+B,CAAC;wCAK9B,CAAJ;2BAAkC,CAAC;kCACP,CAAC;2BAIhB,CAAC;qBAA4B,CAAC;;;uBAsBT,CAAC;6BACH,CAAC;8BAI7B,CAAF;6BAAoC,CAAC;0BAClB,CAAC;6BAIhB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBA5DiC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBArCtC,CAAA;;;;;;;;;;;;qBAuBC,CAAC;sBAA4B,CAAC;sBACvB,CAAC;wBAA8B,CAAC;wBAEnC,CAAC;;;4BA2BK,CAAC;kCACwB,CAAC;wBACrC,CAAA;wBAA+B,CAAC;wCAK9B,CAAJ;2BAAkC,CAAC;kCACP,CAAC;2BAIhB,CAAC;qBAA4B,CAAC;;;uBAsBT,CAAC;6BACH,CAAC;8BAI7B,CAAF;6BAAoC,CAAC;0BAClB,CAAC;6BAIhB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBA5DiC,CAAC;;;;;;;;;;;;;;;;;;;EAFzC"}
|
|
@@ -5,7 +5,7 @@ export const DATE_SCHEMA: {
|
|
|
5
5
|
after(min: string | number | Date): /*elided*/ any;
|
|
6
6
|
past(): /*elided*/ any;
|
|
7
7
|
future(): /*elided*/ any;
|
|
8
|
-
iso(
|
|
8
|
+
iso(): /*elided*/ any;
|
|
9
9
|
timestamp(): /*elided*/ any;
|
|
10
10
|
unix(): /*elided*/ any;
|
|
11
11
|
assertions: any[];
|
|
@@ -107,6 +107,7 @@ export const OBJECT_ID_SCHEMA: {
|
|
|
107
107
|
eth(): /*elided*/ any;
|
|
108
108
|
swift(): /*elided*/ any;
|
|
109
109
|
mongo(): /*elided*/ any;
|
|
110
|
+
calendar(): /*elided*/ any;
|
|
110
111
|
format(name: any, fn: any): /*elided*/ any;
|
|
111
112
|
toString(): any;
|
|
112
113
|
assertions: any[];
|
|
@@ -1 +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
|
|
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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.js"],"names":[],"mappings":"AAqDA,kDAEC;AAED,
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.js"],"names":[],"mappings":"AAqDA,kDAEC;AAED,oEAyFC;AAsBD,wEAiBC;AA8SD;;;EAEC;AAED;;;EAOC"}
|