@bedrockio/model 0.2.0 → 0.2.1

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.
@@ -142,9 +142,6 @@ function attributesToMongoose(attributes) {
142
142
  return definition;
143
143
  }
144
144
  function assertSchemaType(type, path) {
145
- if (type === 'Mixed') {
146
- throw new Error('Type "Mixed" is not allowed. Use "Object" instead.');
147
- }
148
145
  if (typeof type === 'string') {
149
146
  if (!isMongooseType(type)) {
150
147
  const p = path.join('.');
@@ -315,11 +315,12 @@ function getSchemaForType(type, options) {
315
315
  return _yada.default.boolean();
316
316
  case 'Date':
317
317
  return _yada.default.date().iso().tag(DATE_TAGS);
318
- case 'Mixed':
319
318
  case 'Object':
320
319
  return _yada.default.object();
321
320
  case 'Array':
322
321
  return _yada.default.array();
322
+ case 'Mixed':
323
+ return _yada.default.any();
323
324
  case 'ObjectId':
324
325
  if (options.allowExpandedRefs) {
325
326
  return REFERENCE_SCHEMA;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bedrockio/model",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
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.33",
32
+ "@bedrockio/yada": "^1.0.34",
33
33
  "mongoose": "^6.9.0 || ^7.6.4"
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.33",
40
+ "@bedrockio/yada": "^1.0.34",
41
41
  "@shelf/jest-mongodb": "^4.1.7",
42
42
  "babel-plugin-import-replacement": "^1.0.1",
43
43
  "eslint": "^8.33.0",
package/src/schema.js CHANGED
@@ -156,10 +156,6 @@ function attributesToMongoose(attributes) {
156
156
  }
157
157
 
158
158
  function assertSchemaType(type, path) {
159
- if (type === 'Mixed') {
160
- throw new Error('Type "Mixed" is not allowed. Use "Object" instead.');
161
- }
162
-
163
159
  if (typeof type === 'string') {
164
160
  if (!isMongooseType(type)) {
165
161
  const p = path.join('.');
package/src/validation.js CHANGED
@@ -333,11 +333,12 @@ function getSchemaForType(type, options) {
333
333
  return yd.boolean();
334
334
  case 'Date':
335
335
  return yd.date().iso().tag(DATE_TAGS);
336
- case 'Mixed':
337
336
  case 'Object':
338
337
  return yd.object();
339
338
  case 'Array':
340
339
  return yd.array();
340
+ case 'Mixed':
341
+ return yd.any();
341
342
  case 'ObjectId':
342
343
  if (options.allowExpandedRefs) {
343
344
  return REFERENCE_SCHEMA;
@@ -24,6 +24,9 @@ export const INCLUDE_FIELD_SCHEMA: {
24
24
  validate(value: any, options?: {}): Promise<any>;
25
25
  clone(meta: any): any;
26
26
  toOpenApi(extra: any): any;
27
+ getAnyType(): {
28
+ type: string[];
29
+ };
27
30
  getDefault(): {
28
31
  default?: undefined;
29
32
  } | {
@@ -1 +1 @@
1
- {"version":3,"file":"include.d.ts","sourceRoot":"","sources":["../src/include.js"],"names":[],"mappings":"AA2BA,gDAuEC;AAMD,uDA4BC;AAGD,2DAIC;AAvHD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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
@@ -22,6 +22,9 @@ export function searchValidation(options?: {}): {
22
22
  validate(value: any, options?: {}): Promise<any>;
23
23
  clone(meta: any): any;
24
24
  toOpenApi(extra: any): any;
25
+ getAnyType(): {
26
+ type: string[];
27
+ };
25
28
  getDefault(): {
26
29
  default?: undefined;
27
30
  } | {
@@ -1 +1 @@
1
- {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../src/search.js"],"names":[],"mappings":"AAeA,gEAmDC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyBC"}
1
+ {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../src/search.js"],"names":[],"mappings":"AAeA,gEAmDC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyBC"}
@@ -83,6 +83,9 @@ export const OBJECT_ID_SCHEMA: {
83
83
  clone(meta: any): any;
84
84
  append(schema: any): any;
85
85
  toOpenApi(extra: any): any;
86
+ getAnyType(): {
87
+ type: string[];
88
+ };
86
89
  getDefault(): {
87
90
  default?: undefined;
88
91
  } | {
@@ -1 +1 @@
1
- {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.js"],"names":[],"mappings":"AAiFA,kDAEC;AAED,oEAkFC;AAsBD,wEAkBC;AAuRD;;;EAEC;AAED;;;EAOC;AA/dD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAQK"}
1
+ {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.js"],"names":[],"mappings":"AAiFA,kDAEC;AAED,oEAkFC;AAsBD,wEAkBC;AAwRD;;;EAEC;AAED;;;EAOC;AAheD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAQK"}