@bedrockio/model 0.1.26 → 0.1.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.
@@ -44,6 +44,11 @@ function applyInclude(schema) {
44
44
  }
45
45
  return next();
46
46
  });
47
+ schema.pre(/^count/, function (next) {
48
+ const filter = this.getFilter();
49
+ delete filter.include;
50
+ return next();
51
+ });
47
52
 
48
53
  // Static Methods
49
54
 
@@ -268,7 +268,14 @@ function getSchemaForTypedef(typedef, options = {}) {
268
268
  schema = schema.required();
269
269
  }
270
270
  if (typedef.default) {
271
- schema = schema.default(typedef.default);
271
+ // Note that adding a default in the validation is
272
+ // technically unnecessary as this will be handled
273
+ // at the model level, however fixed values can be
274
+ // reported to the OpenAPI definition to enrich
275
+ // documentation.
276
+ if (typeof typedef.default !== 'function') {
277
+ schema = schema.default(typedef.default);
278
+ }
272
279
  }
273
280
  if (typedef.validate?.schema) {
274
281
  schema = schema.append(typedef.validate.schema);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bedrockio/model",
3
- "version": "0.1.26",
3
+ "version": "0.1.28",
4
4
  "description": "Bedrock utilities for model creation.",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -29,7 +29,7 @@
29
29
  "lodash": "^4.17.21"
30
30
  },
31
31
  "peerDependencies": {
32
- "@bedrockio/yada": "^1.0.27",
32
+ "@bedrockio/yada": "^1.0.30",
33
33
  "mongoose": ">=6.9.0"
34
34
  },
35
35
  "devDependencies": {
@@ -37,7 +37,7 @@
37
37
  "@babel/core": "^7.20.12",
38
38
  "@babel/preset-env": "^7.20.2",
39
39
  "@bedrockio/prettier-config": "^1.0.2",
40
- "@bedrockio/yada": "^1.0.28",
40
+ "@bedrockio/yada": "^1.0.30",
41
41
  "@shelf/jest-mongodb": "^4.1.6",
42
42
  "babel-plugin-import-replacement": "^1.0.1",
43
43
  "eslint": "^8.33.0",
package/src/include.js CHANGED
@@ -39,6 +39,12 @@ export function applyInclude(schema) {
39
39
  return next();
40
40
  });
41
41
 
42
+ schema.pre(/^count/, function (next) {
43
+ const filter = this.getFilter();
44
+ delete filter.include;
45
+ return next();
46
+ });
47
+
42
48
  // Static Methods
43
49
 
44
50
  // Async method runs the create first then calls into
package/src/validation.js CHANGED
@@ -280,7 +280,14 @@ function getSchemaForTypedef(typedef, options = {}) {
280
280
  schema = schema.required();
281
281
  }
282
282
  if (typedef.default) {
283
- schema = schema.default(typedef.default);
283
+ // Note that adding a default in the validation is
284
+ // technically unnecessary as this will be handled
285
+ // at the model level, however fixed values can be
286
+ // reported to the OpenAPI definition to enrich
287
+ // documentation.
288
+ if (typeof typedef.default !== 'function') {
289
+ schema = schema.default(typedef.default);
290
+ }
284
291
  }
285
292
  if (typedef.validate?.schema) {
286
293
  schema = schema.append(typedef.validate.schema);
@@ -12,7 +12,7 @@ export const INCLUDE_FIELD_SCHEMA: {
12
12
  assertions: any[];
13
13
  meta: {};
14
14
  required(): any;
15
- default(value: any): any;
15
+ default(arg: any): any;
16
16
  custom(...args: import("@bedrockio/yada/types/Schema").CustomSignature): any;
17
17
  strip(strip: any): any;
18
18
  allow(...set: any[]): any;
@@ -1 +1 @@
1
- {"version":3,"file":"include.d.ts","sourceRoot":"","sources":["../src/include.js"],"names":[],"mappings":"AA2BA,gDAiEC;AAMD,uDA4BC;AAGD,2DAIC;AAjHD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKG"}
1
+ {"version":3,"file":"include.d.ts","sourceRoot":"","sources":["../src/include.js"],"names":[],"mappings":"AA2BA,gDAuEC;AAMD,uDA4BC;AAGD,2DAIC;AAvHD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKG"}
package/types/search.d.ts CHANGED
@@ -10,7 +10,7 @@ export function searchValidation(options?: {}): {
10
10
  assertions: any[];
11
11
  meta: {};
12
12
  required(): any;
13
- default(value: any): any;
13
+ default(arg: any): any;
14
14
  custom(...args: import("@bedrockio/yada/types/Schema").CustomSignature): any;
15
15
  strip(strip: any): any;
16
16
  allow(...set: any[]): any;
@@ -10,6 +10,7 @@ export function getTupleValidator(types: any): {
10
10
  schema: any;
11
11
  };
12
12
  export const OBJECT_ID_SCHEMA: {
13
+ required(): any;
13
14
  length(length: number): any;
14
15
  min(length: number): any;
15
16
  max(length: number): any;
@@ -69,8 +70,7 @@ export const OBJECT_ID_SCHEMA: {
69
70
  toString(): any;
70
71
  assertions: any[];
71
72
  meta: {};
72
- required(): any;
73
- default(value: any): any;
73
+ default(arg: any): any;
74
74
  custom(...args: import("@bedrockio/yada/types/Schema").CustomSignature): any;
75
75
  strip(strip: any): any;
76
76
  allow(...set: any[]): any;
@@ -1 +1 @@
1
- {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.js"],"names":[],"mappings":"AAiFA,kDAEC;AAED,oEAiFC;AAsBD,wEAkBC;AA6QD;;;EAEC;AAED;;;EAOC;AApdD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAQK"}
1
+ {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.js"],"names":[],"mappings":"AAiFA,kDAEC;AAED,oEAiFC;AAsBD,wEAkBC;AAoRD;;;EAEC;AAED;;;EAOC;AA3dD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAQK"}