@bedrockio/model 0.18.4 → 0.18.5

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,8 @@
1
+ ## 0.18.5
2
+
3
+ - Moved warnings to `process.emitWarning`.
4
+ - Fixed reload issue with mixed array types.
5
+
1
6
  ## 0.18.4
2
7
 
3
8
  - Bumped yada to fix JSON schema issues.
package/dist/cjs/utils.js CHANGED
@@ -142,7 +142,15 @@ function getInnerField(obj, path) {
142
142
  }
143
143
  function resolveInnerField(field) {
144
144
  if (Array.isArray(field?.type)) {
145
- field = field.type[0];
145
+ // An unspecified array type has no inner
146
+ // fields so return Array as the type.
147
+ if (field.type.length === 0) {
148
+ return {
149
+ type: 'Array'
150
+ };
151
+ } else {
152
+ field = field.type[0];
153
+ }
146
154
  }
147
155
  if (field?.type instanceof _mongoose.default.Schema) {
148
156
  field = field.type.obj;
package/dist/cjs/warn.js CHANGED
@@ -4,10 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = warn;
7
- var _logger = _interopRequireDefault(require("@bedrockio/logger"));
8
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
7
  function warn(...lines) {
10
8
  if (process.env.ENV_NAME !== 'test') {
11
- _logger.default.warn(lines.join('\n'));
9
+ // Allow warnings to be traced.
10
+ process.emitWarning(lines.join('\n'));
12
11
  }
13
12
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bedrockio/model",
3
- "version": "0.18.4",
3
+ "version": "0.18.5",
4
4
  "description": "Bedrock utilities for model creation.",
5
5
  "type": "module",
6
6
  "scripts": {
package/src/utils.js CHANGED
@@ -130,7 +130,15 @@ export function getInnerField(obj, path) {
130
130
 
131
131
  function resolveInnerField(field) {
132
132
  if (Array.isArray(field?.type)) {
133
- field = field.type[0];
133
+ // An unspecified array type has no inner
134
+ // fields so return Array as the type.
135
+ if (field.type.length === 0) {
136
+ return {
137
+ type: 'Array',
138
+ };
139
+ } else {
140
+ field = field.type[0];
141
+ }
134
142
  }
135
143
  if (field?.type instanceof mongoose.Schema) {
136
144
  field = field.type.obj;
package/src/warn.js CHANGED
@@ -1,7 +1,6 @@
1
- import logger from '@bedrockio/logger';
2
-
3
1
  export default function warn(...lines) {
4
2
  if (process.env.ENV_NAME !== 'test') {
5
- logger.warn(lines.join('\n'));
3
+ // Allow warnings to be traced.
4
+ process.emitWarning(lines.join('\n'));
6
5
  }
7
6
  }
package/types/schema.d.ts CHANGED
@@ -19,7 +19,6 @@ export function createSchema(definition: object, options?: mongoose.SchemaOption
19
19
  };
20
20
  collation?: mongoose.mongo.CollationOptions;
21
21
  collectionOptions?: mongoose.mongo.CreateCollectionOptions;
22
- lean?: boolean | mongoose.LeanOptions;
23
22
  timeseries?: mongoose.mongo.TimeSeriesCollectionOptions;
24
23
  expireAfterSeconds?: number;
25
24
  expires?: number | string;
@@ -29,9 +28,7 @@ export function createSchema(definition: object, options?: mongoose.SchemaOption
29
28
  id?: boolean;
30
29
  _id?: boolean;
31
30
  minimize?: boolean;
32
- optimisticConcurrency?: boolean | string[] | {
33
- exclude: string[];
34
- };
31
+ optimisticConcurrency?: boolean;
35
32
  pluginTags?: string[];
36
33
  read?: string;
37
34
  readConcern?: {
@@ -50,16 +47,16 @@ export function createSchema(definition: object, options?: mongoose.SchemaOption
50
47
  getters: boolean;
51
48
  versionKey: boolean;
52
49
  transform: (doc: any, ret: any, options: any) => void;
53
- } | mongoose.ToObjectOptions<any, any>;
50
+ } | mongoose.ToObjectOptions<any>;
54
51
  toObject: {
55
52
  getters: boolean;
56
53
  versionKey: boolean;
57
54
  transform: (doc: any, ret: any, options: any) => void;
58
- } | mongoose.ToObjectOptions<any, any>;
55
+ } | mongoose.ToObjectOptions<any>;
59
56
  typeKey?: string;
60
57
  validateBeforeSave?: boolean;
61
58
  validateModifiedOnly?: boolean;
62
- versionKey?: string | false;
59
+ versionKey?: string | boolean;
63
60
  selectPopulatedPaths?: boolean;
64
61
  skipVersioning?: {
65
62
  [key: string]: boolean;
@@ -67,13 +64,12 @@ export function createSchema(definition: object, options?: mongoose.SchemaOption
67
64
  storeSubdocValidationError?: boolean;
68
65
  timestamps: boolean | mongoose.SchemaTimestampsConfig;
69
66
  suppressReservedKeysWarning?: boolean;
70
- statics?: mongoose.AddThisParameter<any, mongoose.Model<any, any, any, any, any, any>>;
67
+ statics?: mongoose.AddThisParameter<any, mongoose.Model<any, {}, {}, {}, any, any>>;
71
68
  methods?: mongoose.AddThisParameter<any, any> & mongoose.AnyObject;
72
69
  query?: any;
73
70
  castNonArrays?: boolean;
74
71
  virtuals?: mongoose.SchemaOptionsVirtualsPropertyType<any, any, any>;
75
72
  overwriteModels?: boolean;
76
- encryptionType?: "csfle" | "queryableEncryption";
77
73
  }, any, any>;
78
74
  export function normalizeAttributes(arg: any, path?: any[]): any;
79
75
  import mongoose from 'mongoose';
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.js"],"names":[],"mappings":"AAyBA;;;;;;;GAOG;AACH,yCAJW,MAAM,YACN,QAAQ,CAAC,aAAa;;;;;;;YA2C7B,CAAC;WAAa,CAAC;mBACH,CAAC;;;;;;;;;;;;;;;;;;;;;;;;SAqIH,CAAC;gBACL,CAAC;SAAW,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAjItB;AAED,iEAcC;qBA9FoB,UAAU"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.js"],"names":[],"mappings":"AAyBA;;;;;;;GAOG;AACH,yCAJW,MAAM,YACN,QAAQ,CAAC,aAAa;;;;;;;YAuC/B,CAAC;WAAa,CAAC;mBACF,CAAC;;;;;;;;;;;;;;;;;;;;;SAsHkC,CAAC;gBACzC,CAAA;SAAW,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aA9GrB;AAED,iEAcC;qBA9FoB,UAAU"}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.js"],"names":[],"mappings":"AAQA,iDAcC;AAED,gHAEC;AAED,+DAEC;AAED,0DAEC;AAED,4DAEC;AAED,4DAEC;AAED,2DAGC;AAOD,mDAGC;AAuBD,mDAgBC;AAKD;;;;EAoBC;AAKD,wDAEC;AAcD,iDAYC;qBA1JoB,UAAU"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.js"],"names":[],"mappings":"AAQA,iDAcC;AAED,gHAEC;AAED,+DAEC;AAED,0DAEC;AAED,4DAEC;AAED,4DAEC;AAED,2DAGC;AAOD,mDAGC;AAuBD,mDAgBC;AAKD;;;;EAoBC;AAKD,wDAEC;AAsBD,iDAYC;qBAlKoB,UAAU"}
@@ -1 +1 @@
1
- {"version":3,"file":"warn.d.ts","sourceRoot":"","sources":["../src/warn.js"],"names":[],"mappings":"AAEA,oDAIC"}
1
+ {"version":3,"file":"warn.d.ts","sourceRoot":"","sources":["../src/warn.js"],"names":[],"mappings":"AAAA,oDAKC"}