@nullix/zod-mongoose-studio 1.0.13 → 2.1.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.
Files changed (268) hide show
  1. package/.output/nitro.json +1 -1
  2. package/.output/public/_nuxt/builds/latest.json +1 -1
  3. package/.output/public/_nuxt/builds/meta/8b851c04-1848-472a-b5cd-0727aaaf90f4.json +1 -0
  4. package/.output/server/chunks/nitro/nitro.mjs +232 -232
  5. package/.output/server/chunks/routes/api/parse.post.mjs +54 -11
  6. package/.output/server/chunks/routes/api/parse.post.mjs.map +1 -1
  7. package/.output/server/node_modules/bson/lib/bson.cjs +157 -48
  8. package/.output/server/node_modules/bson/package.json +9 -11
  9. package/.output/server/node_modules/kareem/index.js +228 -343
  10. package/.output/server/node_modules/kareem/package.json +3 -3
  11. package/.output/server/node_modules/mongodb/lib/bson.js +27 -5
  12. package/.output/server/node_modules/mongodb/lib/bulk/common.js +7 -9
  13. package/.output/server/node_modules/mongodb/lib/change_stream.js +91 -39
  14. package/.output/server/node_modules/mongodb/lib/client-side-encryption/auto_encrypter.js +21 -14
  15. package/.output/server/node_modules/mongodb/lib/client-side-encryption/client_encryption.js +2 -5
  16. package/.output/server/node_modules/mongodb/lib/client-side-encryption/errors.js +3 -1
  17. package/.output/server/node_modules/mongodb/lib/client-side-encryption/mongocryptd_manager.js +1 -1
  18. package/.output/server/node_modules/mongodb/lib/client-side-encryption/state_machine.js +1 -0
  19. package/.output/server/node_modules/mongodb/lib/cmap/auth/aws4.js +161 -0
  20. package/.output/server/node_modules/mongodb/lib/cmap/auth/aws_temporary_credentials.js +11 -58
  21. package/.output/server/node_modules/mongodb/lib/cmap/auth/gssapi.js +4 -6
  22. package/.output/server/node_modules/mongodb/lib/cmap/auth/mongo_credentials.js +2 -16
  23. package/.output/server/node_modules/mongodb/lib/cmap/auth/mongodb_aws.js +14 -23
  24. package/.output/server/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/azure_machine_workflow.js +3 -3
  25. package/.output/server/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/gcp_machine_workflow.js +3 -3
  26. package/.output/server/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/k8s_machine_workflow.js +4 -3
  27. package/.output/server/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/token_machine_workflow.js +4 -3
  28. package/.output/server/node_modules/mongodb/lib/cmap/auth/mongodb_oidc.js +4 -4
  29. package/.output/server/node_modules/mongodb/lib/cmap/auth/plain.js +1 -1
  30. package/.output/server/node_modules/mongodb/lib/cmap/auth/providers.js +0 -1
  31. package/.output/server/node_modules/mongodb/lib/cmap/auth/scram.js +53 -40
  32. package/.output/server/node_modules/mongodb/lib/cmap/commands.js +46 -39
  33. package/.output/server/node_modules/mongodb/lib/cmap/connect.js +35 -3
  34. package/.output/server/node_modules/mongodb/lib/cmap/connection.js +36 -32
  35. package/.output/server/node_modules/mongodb/lib/cmap/connection_pool.js +67 -67
  36. package/.output/server/node_modules/mongodb/lib/cmap/connection_pool_events.js +3 -3
  37. package/.output/server/node_modules/mongodb/lib/cmap/errors.js +1 -1
  38. package/.output/server/node_modules/mongodb/lib/cmap/handshake/client_metadata.js +15 -13
  39. package/.output/server/node_modules/mongodb/lib/cmap/metrics.js +3 -3
  40. package/.output/server/node_modules/mongodb/lib/cmap/wire_protocol/compression.js +26 -10
  41. package/.output/server/node_modules/mongodb/lib/cmap/wire_protocol/constants.js +3 -1
  42. package/.output/server/node_modules/mongodb/lib/cmap/wire_protocol/on_data.js +0 -1
  43. package/.output/server/node_modules/mongodb/lib/cmap/wire_protocol/on_demand/document.js +9 -9
  44. package/.output/server/node_modules/mongodb/lib/cmap/wire_protocol/responses.js +2 -2
  45. package/.output/server/node_modules/mongodb/lib/collection.js +1 -1
  46. package/.output/server/node_modules/mongodb/lib/connection_string.js +30 -15
  47. package/.output/server/node_modules/mongodb/lib/cursor/abstract_cursor.js +17 -34
  48. package/.output/server/node_modules/mongodb/lib/cursor/change_stream_cursor.js +2 -2
  49. package/.output/server/node_modules/mongodb/lib/cursor/find_cursor.js +37 -26
  50. package/.output/server/node_modules/mongodb/lib/cursor/run_command_cursor.js +1 -1
  51. package/.output/server/node_modules/mongodb/lib/db.js +6 -7
  52. package/.output/server/node_modules/mongodb/lib/deps.js +0 -13
  53. package/.output/server/node_modules/mongodb/lib/error.js +7 -10
  54. package/.output/server/node_modules/mongodb/lib/gridfs/download.js +7 -6
  55. package/.output/server/node_modules/mongodb/lib/gridfs/index.js +9 -9
  56. package/.output/server/node_modules/mongodb/lib/gridfs/upload.js +17 -23
  57. package/.output/server/node_modules/mongodb/lib/index.js +2 -4
  58. package/.output/server/node_modules/mongodb/lib/mongo_client.js +58 -67
  59. package/.output/server/node_modules/mongodb/lib/mongo_client_auth_providers.js +0 -6
  60. package/.output/server/node_modules/mongodb/lib/mongo_logger.js +11 -5
  61. package/.output/server/node_modules/mongodb/lib/mongo_types.js +1 -2
  62. package/.output/server/node_modules/mongodb/lib/operations/aggregate.js +0 -3
  63. package/.output/server/node_modules/mongodb/lib/operations/create_collection.js +0 -1
  64. package/.output/server/node_modules/mongodb/lib/operations/drop.js +8 -9
  65. package/.output/server/node_modules/mongodb/lib/operations/end_sessions.js +34 -0
  66. package/.output/server/node_modules/mongodb/lib/operations/execute_operation.js +121 -45
  67. package/.output/server/node_modules/mongodb/lib/operations/operation.js +1 -0
  68. package/.output/server/node_modules/mongodb/lib/read_preference.js +10 -14
  69. package/.output/server/node_modules/mongodb/lib/runtime_adapters.js +32 -0
  70. package/.output/server/node_modules/mongodb/lib/sdam/monitor.js +8 -8
  71. package/.output/server/node_modules/mongodb/lib/sdam/server.js +55 -43
  72. package/.output/server/node_modules/mongodb/lib/sdam/server_description.js +1 -1
  73. package/.output/server/node_modules/mongodb/lib/sdam/server_selection.js +135 -72
  74. package/.output/server/node_modules/mongodb/lib/sdam/srv_polling.js +3 -3
  75. package/.output/server/node_modules/mongodb/lib/sdam/topology.js +37 -77
  76. package/.output/server/node_modules/mongodb/lib/sdam/topology_description.js +1 -1
  77. package/.output/server/node_modules/mongodb/lib/sessions.js +150 -40
  78. package/.output/server/node_modules/mongodb/lib/transactions.js +2 -13
  79. package/.output/server/node_modules/mongodb/lib/utils.js +42 -90
  80. package/.output/server/node_modules/mongodb/package.json +49 -45
  81. package/.output/server/node_modules/mongodb-connection-string-url/lib/index.js +45 -19
  82. package/.output/server/node_modules/mongodb-connection-string-url/lib/redact.js +30 -19
  83. package/.output/server/node_modules/mongodb-connection-string-url/package.json +25 -16
  84. package/.output/server/node_modules/mongoose/lib/aggregate.js +108 -127
  85. package/.output/server/node_modules/mongoose/lib/cast/bigint.js +3 -3
  86. package/.output/server/node_modules/mongoose/lib/cast/boolean.js +3 -3
  87. package/.output/server/node_modules/mongoose/lib/cast/double.js +4 -4
  88. package/.output/server/node_modules/mongoose/lib/cast/int32.js +2 -2
  89. package/.output/server/node_modules/mongoose/lib/cast/number.js +6 -6
  90. package/.output/server/node_modules/mongoose/lib/cast/string.js +3 -3
  91. package/.output/server/node_modules/mongoose/lib/cast/uuid.js +5 -48
  92. package/.output/server/node_modules/mongoose/lib/cast.js +16 -24
  93. package/.output/server/node_modules/mongoose/lib/collection.js +6 -6
  94. package/.output/server/node_modules/mongoose/lib/connection.js +108 -105
  95. package/.output/server/node_modules/mongoose/lib/cursor/aggregationCursor.js +23 -33
  96. package/.output/server/node_modules/mongoose/lib/cursor/changeStream.js +60 -40
  97. package/.output/server/node_modules/mongoose/lib/cursor/queryCursor.js +21 -25
  98. package/.output/server/node_modules/mongoose/lib/document.js +712 -531
  99. package/.output/server/node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js +85 -130
  100. package/.output/server/node_modules/mongoose/lib/drivers/node-mongodb-native/connection.js +32 -41
  101. package/.output/server/node_modules/mongoose/lib/error/cast.js +21 -12
  102. package/.output/server/node_modules/mongoose/lib/error/createCollectionsError.js +2 -2
  103. package/.output/server/node_modules/mongoose/lib/error/divergentArray.js +1 -1
  104. package/.output/server/node_modules/mongoose/lib/error/eachAsyncMultiError.js +1 -1
  105. package/.output/server/node_modules/mongoose/lib/error/index.js +3 -3
  106. package/.output/server/node_modules/mongoose/lib/error/invalidSchemaOption.js +1 -1
  107. package/.output/server/node_modules/mongoose/lib/error/messages.js +1 -0
  108. package/.output/server/node_modules/mongoose/lib/error/missingSchema.js +1 -1
  109. package/.output/server/node_modules/mongoose/lib/error/objectParameter.js +4 -5
  110. package/.output/server/node_modules/mongoose/lib/error/overwriteModel.js +1 -1
  111. package/.output/server/node_modules/mongoose/lib/error/setOptionError.js +3 -3
  112. package/.output/server/node_modules/mongoose/lib/error/strict.js +3 -3
  113. package/.output/server/node_modules/mongoose/lib/error/strictPopulate.js +2 -2
  114. package/.output/server/node_modules/mongoose/lib/error/syncIndexes.js +2 -2
  115. package/.output/server/node_modules/mongoose/lib/error/validation.js +2 -10
  116. package/.output/server/node_modules/mongoose/lib/error/validator.js +1 -1
  117. package/.output/server/node_modules/mongoose/lib/error/version.js +2 -2
  118. package/.output/server/node_modules/mongoose/lib/helpers/aggregate/prepareDiscriminatorPipeline.js +4 -4
  119. package/.output/server/node_modules/mongoose/lib/helpers/buildMiddlewareFilter.js +24 -0
  120. package/.output/server/node_modules/mongoose/lib/helpers/clone.js +35 -18
  121. package/.output/server/node_modules/mongoose/lib/helpers/common.js +5 -5
  122. package/.output/server/node_modules/mongoose/lib/helpers/cursor/eachAsync.js +4 -4
  123. package/.output/server/node_modules/mongoose/lib/helpers/discriminator/getConstructor.js +1 -1
  124. package/.output/server/node_modules/mongoose/lib/helpers/discriminator/getDiscriminatorByValue.js +1 -1
  125. package/.output/server/node_modules/mongoose/lib/helpers/discriminator/getSchemaDiscriminatorByValue.js +1 -1
  126. package/.output/server/node_modules/mongoose/lib/helpers/discriminator/mergeDiscriminatorSchema.js +10 -5
  127. package/.output/server/node_modules/mongoose/lib/helpers/document/applyDefaults.js +1 -1
  128. package/.output/server/node_modules/mongoose/lib/helpers/document/applyTimestamps.js +11 -10
  129. package/.output/server/node_modules/mongoose/lib/helpers/document/applyVirtuals.js +10 -9
  130. package/.output/server/node_modules/mongoose/lib/helpers/document/cleanModifiedSubpaths.js +1 -1
  131. package/.output/server/node_modules/mongoose/lib/helpers/document/compile.js +17 -14
  132. package/.output/server/node_modules/mongoose/lib/helpers/document/getDeepestSubdocumentForPath.js +3 -3
  133. package/.output/server/node_modules/mongoose/lib/helpers/document/getEmbeddedDiscriminatorPath.js +2 -2
  134. package/.output/server/node_modules/mongoose/lib/helpers/document/isInPathsToSave.js +24 -0
  135. package/.output/server/node_modules/mongoose/lib/helpers/get.js +1 -1
  136. package/.output/server/node_modules/mongoose/lib/helpers/indexes/decorateDiscriminatorIndexOptions.js +1 -1
  137. package/.output/server/node_modules/mongoose/lib/helpers/indexes/getRelatedIndexes.js +3 -3
  138. package/.output/server/node_modules/mongoose/lib/helpers/indexes/isIndexEqual.js +3 -4
  139. package/.output/server/node_modules/mongoose/lib/helpers/indexes/isIndexSpecEqual.js +3 -3
  140. package/.output/server/node_modules/mongoose/lib/helpers/isBsonType.js +1 -1
  141. package/.output/server/node_modules/mongoose/lib/helpers/isMongooseObject.js +1 -1
  142. package/.output/server/node_modules/mongoose/lib/helpers/isObject.js +2 -2
  143. package/.output/server/node_modules/mongoose/lib/helpers/isSimpleValidator.js +2 -2
  144. package/.output/server/node_modules/mongoose/lib/helpers/minimize.js +2 -2
  145. package/.output/server/node_modules/mongoose/lib/helpers/model/applyDefaultsToPOJO.js +2 -2
  146. package/.output/server/node_modules/mongoose/lib/helpers/model/applyHooks.js +55 -54
  147. package/.output/server/node_modules/mongoose/lib/helpers/model/applyMethods.js +2 -2
  148. package/.output/server/node_modules/mongoose/lib/helpers/model/applyStaticHooks.js +1 -48
  149. package/.output/server/node_modules/mongoose/lib/helpers/model/castBulkWrite.js +8 -12
  150. package/.output/server/node_modules/mongoose/lib/helpers/model/discriminator.js +1 -1
  151. package/.output/server/node_modules/mongoose/lib/helpers/parallelLimit.js +18 -36
  152. package/.output/server/node_modules/mongoose/lib/helpers/pluralize.js +4 -4
  153. package/.output/server/node_modules/mongoose/lib/helpers/populate/assignRawDocsToIdStructure.js +4 -11
  154. package/.output/server/node_modules/mongoose/lib/helpers/populate/assignVals.js +10 -10
  155. package/.output/server/node_modules/mongoose/lib/helpers/populate/createPopulateQueryFilter.js +3 -3
  156. package/.output/server/node_modules/mongoose/lib/helpers/populate/getModelsMapForPopulate.js +197 -69
  157. package/.output/server/node_modules/mongoose/lib/helpers/populate/getSchemaTypes.js +15 -15
  158. package/.output/server/node_modules/mongoose/lib/helpers/populate/markArraySubdocsPopulated.js +1 -1
  159. package/.output/server/node_modules/mongoose/lib/helpers/populate/modelNamesFromRefPath.js +10 -2
  160. package/.output/server/node_modules/mongoose/lib/helpers/populate/setPopulatedVirtualValue.js +5 -5
  161. package/.output/server/node_modules/mongoose/lib/helpers/printJestWarning.js +1 -1
  162. package/.output/server/node_modules/mongoose/lib/helpers/processConnectionOptions.js +1 -1
  163. package/.output/server/node_modules/mongoose/lib/helpers/projection/hasIncludedChildren.js +1 -1
  164. package/.output/server/node_modules/mongoose/lib/helpers/projection/isPathExcluded.js +3 -3
  165. package/.output/server/node_modules/mongoose/lib/helpers/projection/isSubpath.js +1 -1
  166. package/.output/server/node_modules/mongoose/lib/helpers/projection/parseProjection.js +9 -4
  167. package/.output/server/node_modules/mongoose/lib/helpers/query/cast$expr.js +8 -10
  168. package/.output/server/node_modules/mongoose/lib/helpers/query/castFilterPath.js +1 -1
  169. package/.output/server/node_modules/mongoose/lib/helpers/query/castUpdate.js +44 -38
  170. package/.output/server/node_modules/mongoose/lib/helpers/query/getEmbeddedDiscriminatorPath.js +8 -8
  171. package/.output/server/node_modules/mongoose/lib/helpers/query/handleImmutable.js +8 -8
  172. package/.output/server/node_modules/mongoose/lib/helpers/schema/applyPlugins.js +2 -2
  173. package/.output/server/node_modules/mongoose/lib/helpers/schema/applyReadConcern.js +1 -1
  174. package/.output/server/node_modules/mongoose/lib/helpers/schema/applyWriteConcern.js +4 -2
  175. package/.output/server/node_modules/mongoose/lib/helpers/schema/getIndexes.js +5 -11
  176. package/.output/server/node_modules/mongoose/lib/helpers/schema/getSubdocumentStrictValue.js +2 -2
  177. package/.output/server/node_modules/mongoose/lib/helpers/schema/handleIdOption.js +1 -1
  178. package/.output/server/node_modules/mongoose/lib/helpers/schema/idGetter.js +1 -1
  179. package/.output/server/node_modules/mongoose/lib/helpers/schematype/handleImmutable.js +1 -1
  180. package/.output/server/node_modules/mongoose/lib/helpers/setDefaultsOnInsert.js +26 -13
  181. package/.output/server/node_modules/mongoose/lib/helpers/timestamps/setDocumentTimestamps.js +2 -2
  182. package/.output/server/node_modules/mongoose/lib/helpers/timestamps/setupTimestamps.js +60 -38
  183. package/.output/server/node_modules/mongoose/lib/helpers/update/applyTimestampsToUpdate.js +13 -10
  184. package/.output/server/node_modules/mongoose/lib/helpers/update/castArrayFilters.js +4 -4
  185. package/.output/server/node_modules/mongoose/lib/helpers/update/decorateUpdateWithVersionKey.js +1 -1
  186. package/.output/server/node_modules/mongoose/lib/helpers/update/modifiedPaths.js +2 -2
  187. package/.output/server/node_modules/mongoose/lib/helpers/update/removeUnusedArrayFilters.js +7 -2
  188. package/.output/server/node_modules/mongoose/lib/helpers/updateValidators.js +58 -119
  189. package/.output/server/node_modules/mongoose/lib/model.js +940 -946
  190. package/.output/server/node_modules/mongoose/lib/mongoose.js +131 -79
  191. package/.output/server/node_modules/mongoose/lib/options/schemaArrayOptions.js +2 -2
  192. package/.output/server/node_modules/mongoose/lib/options/schemaBufferOptions.js +1 -1
  193. package/.output/server/node_modules/mongoose/lib/options/schemaDocumentArrayOptions.js +23 -0
  194. package/.output/server/node_modules/mongoose/lib/options/schemaNumberOptions.js +3 -3
  195. package/.output/server/node_modules/mongoose/lib/options/schemaObjectIdOptions.js +2 -2
  196. package/.output/server/node_modules/mongoose/lib/options/schemaStringOptions.js +6 -6
  197. package/.output/server/node_modules/mongoose/lib/options/schemaSubdocumentOptions.js +23 -0
  198. package/.output/server/node_modules/mongoose/lib/options/schemaTypeOptions.js +27 -13
  199. package/.output/server/node_modules/mongoose/lib/options/virtualOptions.js +12 -12
  200. package/.output/server/node_modules/mongoose/lib/plugins/index.js +0 -1
  201. package/.output/server/node_modules/mongoose/lib/plugins/saveSubdocs.js +84 -92
  202. package/.output/server/node_modules/mongoose/lib/plugins/sharding.js +33 -15
  203. package/.output/server/node_modules/mongoose/lib/plugins/trackTransaction.js +29 -25
  204. package/.output/server/node_modules/mongoose/lib/query.js +700 -548
  205. package/.output/server/node_modules/mongoose/lib/queryHelpers.js +34 -32
  206. package/.output/server/node_modules/mongoose/lib/schema/array.js +69 -113
  207. package/.output/server/node_modules/mongoose/lib/schema/bigint.js +18 -20
  208. package/.output/server/node_modules/mongoose/lib/schema/boolean.js +20 -22
  209. package/.output/server/node_modules/mongoose/lib/schema/buffer.js +23 -25
  210. package/.output/server/node_modules/mongoose/lib/schema/date.js +19 -21
  211. package/.output/server/node_modules/mongoose/lib/schema/decimal128.js +16 -18
  212. package/.output/server/node_modules/mongoose/lib/schema/documentArray.js +94 -131
  213. package/.output/server/node_modules/mongoose/lib/schema/documentArrayElement.js +50 -16
  214. package/.output/server/node_modules/mongoose/lib/schema/double.js +16 -18
  215. package/.output/server/node_modules/mongoose/lib/schema/index.js +1 -0
  216. package/.output/server/node_modules/mongoose/lib/schema/int32.js +17 -19
  217. package/.output/server/node_modules/mongoose/lib/schema/map.js +17 -24
  218. package/.output/server/node_modules/mongoose/lib/schema/mixed.js +14 -14
  219. package/.output/server/node_modules/mongoose/lib/schema/number.js +38 -28
  220. package/.output/server/node_modules/mongoose/lib/schema/objectId.js +18 -20
  221. package/.output/server/node_modules/mongoose/lib/schema/operators/exists.js +1 -1
  222. package/.output/server/node_modules/mongoose/lib/schema/operators/geospatial.js +1 -1
  223. package/.output/server/node_modules/mongoose/lib/schema/operators/text.js +4 -4
  224. package/.output/server/node_modules/mongoose/lib/schema/string.js +42 -27
  225. package/.output/server/node_modules/mongoose/lib/schema/subdocument.js +47 -58
  226. package/.output/server/node_modules/mongoose/lib/schema/union.js +54 -4
  227. package/.output/server/node_modules/mongoose/lib/schema/uuid.js +17 -40
  228. package/.output/server/node_modules/mongoose/lib/schema.js +235 -176
  229. package/.output/server/node_modules/mongoose/lib/schemaType.js +227 -158
  230. package/.output/server/node_modules/mongoose/lib/stateMachine.js +5 -8
  231. package/.output/server/node_modules/mongoose/lib/types/array/index.js +5 -5
  232. package/.output/server/node_modules/mongoose/lib/types/array/methods/index.js +27 -28
  233. package/.output/server/node_modules/mongoose/lib/types/arraySubdocument.js +11 -11
  234. package/.output/server/node_modules/mongoose/lib/types/buffer.js +15 -15
  235. package/.output/server/node_modules/mongoose/lib/types/decimal128.js +1 -1
  236. package/.output/server/node_modules/mongoose/lib/types/documentArray/index.js +4 -4
  237. package/.output/server/node_modules/mongoose/lib/types/documentArray/methods/index.js +15 -13
  238. package/.output/server/node_modules/mongoose/lib/types/double.js +1 -1
  239. package/.output/server/node_modules/mongoose/lib/types/map.js +20 -71
  240. package/.output/server/node_modules/mongoose/lib/types/objectid.js +1 -1
  241. package/.output/server/node_modules/mongoose/lib/types/subdocument.js +32 -81
  242. package/.output/server/node_modules/mongoose/lib/types/uuid.js +1 -1
  243. package/.output/server/node_modules/mongoose/lib/utils.js +91 -70
  244. package/.output/server/node_modules/mongoose/lib/validOptions.js +4 -3
  245. package/.output/server/node_modules/mongoose/lib/virtualType.js +18 -18
  246. package/.output/server/node_modules/mongoose/package.json +46 -63
  247. package/.output/server/node_modules/mquery/lib/collection/collection.js +3 -1
  248. package/.output/server/node_modules/mquery/lib/collection/node.js +17 -3
  249. package/.output/server/node_modules/mquery/lib/mquery.js +136 -93
  250. package/.output/server/node_modules/mquery/lib/permissions.js +21 -6
  251. package/.output/server/node_modules/mquery/package.json +4 -7
  252. package/.output/server/package.json +7 -9
  253. package/package.json +3 -3
  254. package/.output/public/_nuxt/builds/meta/0d6006db-fbb0-4297-85cf-bf92ceafcb79.json +0 -1
  255. package/.output/server/node_modules/debug/package.json +0 -64
  256. package/.output/server/node_modules/debug/src/browser.js +0 -272
  257. package/.output/server/node_modules/debug/src/common.js +0 -292
  258. package/.output/server/node_modules/debug/src/index.js +0 -10
  259. package/.output/server/node_modules/debug/src/node.js +0 -263
  260. package/.output/server/node_modules/mongodb/lib/client-side-encryption/crypto_callbacks.js +0 -81
  261. package/.output/server/node_modules/mongodb/lib/resource_management.js +0 -58
  262. package/.output/server/node_modules/mongoose/lib/browserDocument.js +0 -101
  263. package/.output/server/node_modules/mongoose/lib/documentProvider.js +0 -30
  264. package/.output/server/node_modules/mongoose/lib/helpers/createJSONSchemaTypeDefinition.js +0 -24
  265. package/.output/server/node_modules/mongoose/lib/helpers/promiseOrCallback.js +0 -54
  266. package/.output/server/node_modules/mongoose/lib/plugins/validateBeforeSave.js +0 -51
  267. package/.output/server/node_modules/supports-color/index.js +0 -202
  268. package/.output/server/node_modules/supports-color/package.json +0 -64
@@ -20,7 +20,7 @@ const formatToObjectOptions = Object.freeze({ ...internalToObjectOptions, copyTr
20
20
  *
21
21
  * All methods methods from the [node-mongodb-native](https://github.com/mongodb/node-mongodb-native) driver are copied and wrapped in queue management.
22
22
  *
23
- * @inherits Collection https://mongodb.github.io/node-mongodb-native/4.9/classes/Collection.html
23
+ * @inherits Collection https://mongodb.github.io/node-mongodb-native/7.0/classes/Collection.html
24
24
  * @api private
25
25
  */
26
26
 
@@ -80,35 +80,20 @@ NativeCollection.prototype._getCollection = function _getCollection() {
80
80
  return null;
81
81
  };
82
82
 
83
- /*!
84
- * ignore
85
- */
86
-
87
- const syncCollectionMethods = { watch: true, find: true, aggregate: true };
88
-
89
83
  /**
90
84
  * Copy the collection methods and make them subject to queues
91
- * @param {Number|String} I
85
+ * @param {number|string} I
92
86
  * @api private
93
87
  */
94
88
 
95
89
  function iter(i) {
96
90
  NativeCollection.prototype[i] = function() {
97
91
  const collection = this._getCollection();
98
- const args = Array.from(arguments);
92
+ const args = arguments;
99
93
  const _this = this;
100
- const globalDebug = _this &&
101
- _this.conn &&
102
- _this.conn.base &&
103
- _this.conn.base.options &&
104
- _this.conn.base.options.debug;
105
- const connectionDebug = _this &&
106
- _this.conn &&
107
- _this.conn.options &&
108
- _this.conn.options.debug;
94
+ const globalDebug = _this?.conn?.base?.options?.debug;
95
+ const connectionDebug = _this?.conn?.options?.debug;
109
96
  const debug = connectionDebug == null ? globalDebug : connectionDebug;
110
- const lastArg = arguments[arguments.length - 1];
111
- const opId = new ObjectId();
112
97
 
113
98
  // If user force closed, queueing will hang forever. See #5664
114
99
  if (this.conn.$wasForceClosed) {
@@ -122,9 +107,21 @@ function iter(i) {
122
107
  }
123
108
  }
124
109
 
125
- let _args = args;
126
- let callback = null;
110
+ // Lazily generate opId and argsArray only if necessary because they have
111
+ // a non-trivial performance cost.
112
+ let opId = null;
113
+ let argsArray = null;
114
+ const hasOperationListeners = this.conn.listenerCount('operation-start') > 0 || this.conn.listenerCount('operation-end') > 0;
115
+ if (hasOperationListeners || debug) {
116
+ opId = new ObjectId();
117
+ }
118
+
119
+ let timeout = null;
120
+ let waitForBufferPromise = null;
127
121
  if (this._shouldBufferCommands() && this.buffer) {
122
+ if (opId == null) {
123
+ opId = new ObjectId();
124
+ }
128
125
  this.conn.emit('buffer', {
129
126
  _id: opId,
130
127
  modelName: _this.modelName,
@@ -133,88 +130,40 @@ function iter(i) {
133
130
  args: args
134
131
  });
135
132
 
136
- let callback;
137
- let _args = args;
138
- let promise = null;
139
- let timeout = null;
140
- if (syncCollectionMethods[i] && typeof lastArg === 'function') {
141
- this.addQueue(i, _args);
142
- callback = lastArg;
143
- } else if (syncCollectionMethods[i]) {
144
- promise = new this.Promise((resolve, reject) => {
145
- callback = function collectionOperationCallback(err, res) {
146
- if (timeout != null) {
147
- clearTimeout(timeout);
148
- }
149
- if (err != null) {
150
- return reject(err);
151
- }
152
- resolve(res);
153
- };
154
- _args = args.concat([callback]);
155
- this.addQueue(i, _args);
156
- });
157
- } else if (typeof lastArg === 'function') {
158
- callback = function collectionOperationCallback() {
159
- if (timeout != null) {
160
- clearTimeout(timeout);
161
- }
162
- return lastArg.apply(this, arguments);
163
- };
164
- _args = args.slice(0, args.length - 1).concat([callback]);
165
- } else {
166
- promise = new Promise((resolve, reject) => {
167
- callback = function collectionOperationCallback(err, res) {
168
- if (timeout != null) {
169
- clearTimeout(timeout);
170
- }
171
- if (err != null) {
172
- return reject(err);
173
- }
174
- resolve(res);
175
- };
176
- _args = args.concat([callback]);
177
- this.addQueue(i, _args);
178
- });
179
- }
180
-
181
133
  const bufferTimeoutMS = this._getBufferTimeoutMS();
182
- timeout = setTimeout(() => {
183
- const removed = this.removeQueue(i, _args);
184
- if (removed) {
185
- const message = 'Operation `' + this.name + '.' + i + '()` buffering timed out after ' +
186
- bufferTimeoutMS + 'ms';
187
- const err = new MongooseError(message);
188
- this.conn.emit('buffer-end', { _id: opId, modelName: _this.modelName, collectionName: _this.name, method: i, error: err });
189
- callback(err);
190
- }
191
- }, bufferTimeoutMS);
192
-
193
- if (!syncCollectionMethods[i] && typeof lastArg === 'function') {
194
- this.addQueue(i, _args);
195
- return;
196
- }
134
+ waitForBufferPromise = new Promise((resolve, reject) => {
135
+ this.addQueue(resolve);
136
+
137
+ timeout = setTimeout(() => {
138
+ const removed = this.removeQueue(resolve);
139
+ if (removed) {
140
+ const message = 'Operation `' + this.name + '.' + i + '()` buffering timed out after ' +
141
+ bufferTimeoutMS + 'ms';
142
+ const err = new MongooseError(message);
143
+ this.conn.emit('buffer-end', { _id: opId, modelName: _this.modelName, collectionName: _this.name, method: i, error: err });
144
+ reject(err);
145
+ }
146
+ }, bufferTimeoutMS);
147
+ });
197
148
 
198
- return promise;
199
- } else if (!syncCollectionMethods[i] && typeof lastArg === 'function') {
200
- callback = function collectionOperationCallback(err, res) {
201
- if (err != null) {
202
- _this.conn.emit('operation-end', { _id: opId, modelName: _this.modelName, collectionName: _this.name, method: i, error: err });
203
- } else {
204
- _this.conn.emit('operation-end', { _id: opId, modelName: _this.modelName, collectionName: _this.name, method: i, result: res });
149
+ return waitForBufferPromise.then(() => {
150
+ if (timeout) {
151
+ clearTimeout(timeout);
205
152
  }
206
- return lastArg.apply(this, arguments);
207
- };
208
- _args = args.slice(0, args.length - 1).concat([callback]);
153
+ return this[i].apply(this, args);
154
+ });
209
155
  }
210
156
 
211
157
  if (debug) {
212
158
  if (typeof debug === 'function') {
159
+ if (argsArray == null) {
160
+ argsArray = Array.from(args);
161
+ }
213
162
  let argsToAdd = null;
214
- if (typeof args[args.length - 1] == 'function') {
215
- argsToAdd = args.slice(0, args.length - 1);
163
+ if (typeof argsArray[argsArray.length - 1] == 'function') {
164
+ argsToAdd = argsArray.slice(0, argsArray.length - 1);
216
165
  } else {
217
- argsToAdd = args;
166
+ argsToAdd = argsArray;
218
167
  }
219
168
  debug.apply(_this,
220
169
  [_this.name, i].concat(argsToAdd));
@@ -223,11 +172,17 @@ function iter(i) {
223
172
  } else {
224
173
  const color = debug.color == null ? true : debug.color;
225
174
  const shell = debug.shell == null ? false : debug.shell;
226
- this.$print(_this.name, i, args, color, shell);
175
+ const timestamp = debug.timestamp == null ? false : debug.timestamp;
176
+ this.$print(_this.name, i, args, color, shell, timestamp);
227
177
  }
228
178
  }
229
179
 
230
- this.conn.emit('operation-start', { _id: opId, modelName: _this.modelName, collectionName: this.name, method: i, params: _args });
180
+ if (hasOperationListeners) {
181
+ if (argsArray == null) {
182
+ argsArray = Array.from(args);
183
+ }
184
+ this.conn.emit('operation-start', { _id: opId, modelName: _this.modelName, collectionName: this.name, method: i, params: argsArray });
185
+ }
231
186
 
232
187
  try {
233
188
  if (collection == null) {
@@ -237,45 +192,45 @@ function iter(i) {
237
192
  throw new MongooseError(message);
238
193
  }
239
194
 
240
- if (syncCollectionMethods[i] && typeof lastArg === 'function') {
241
- const result = collection[i].apply(collection, _args.slice(0, _args.length - 1));
242
- this.conn.emit('operation-end', { _id: opId, modelName: _this.modelName, collectionName: this.name, method: i, result });
243
- return lastArg.call(this, null, result);
244
- }
245
-
246
- const ret = collection[i].apply(collection, _args);
247
- if (ret != null && typeof ret.then === 'function') {
195
+ const ret = collection[i].apply(collection, args);
196
+ if (typeof ret?.then === 'function') {
248
197
  return ret.then(
249
198
  result => {
250
- if (typeof lastArg === 'function') {
251
- lastArg(null, result);
252
- } else {
199
+ if (timeout != null) {
200
+ clearTimeout(timeout);
201
+ }
202
+ if (hasOperationListeners) {
253
203
  this.conn.emit('operation-end', { _id: opId, modelName: _this.modelName, collectionName: this.name, method: i, result });
254
204
  }
255
205
  return result;
256
206
  },
257
207
  error => {
258
- if (typeof lastArg === 'function') {
259
- lastArg(error);
260
- return;
261
- } else {
208
+ if (timeout != null) {
209
+ clearTimeout(timeout);
210
+ }
211
+ if (hasOperationListeners) {
262
212
  this.conn.emit('operation-end', { _id: opId, modelName: _this.modelName, collectionName: this.name, method: i, error });
263
213
  }
264
214
  throw error;
265
215
  }
266
216
  );
267
217
  }
218
+
219
+ if (hasOperationListeners) {
220
+ this.conn.emit('operation-end', { _id: opId, modelName: _this.modelName, collectionName: this.name, method: i, result: ret });
221
+ }
222
+ if (timeout != null) {
223
+ clearTimeout(timeout);
224
+ }
268
225
  return ret;
269
226
  } catch (error) {
270
- // Collection operation may throw because of max bson size, catch it here
271
- // See gh-3906
272
- if (typeof lastArg === 'function') {
273
- return lastArg(error);
274
- } else {
227
+ if (timeout != null) {
228
+ clearTimeout(timeout);
229
+ }
230
+ if (hasOperationListeners) {
275
231
  this.conn.emit('operation-end', { _id: opId, modelName: _this.modelName, collectionName: this.name, method: i, error: error });
276
-
277
- throw error;
278
232
  }
233
+ throw error;
279
234
  }
280
235
  };
281
236
  }
@@ -302,7 +257,12 @@ for (const key of Object.getOwnPropertyNames(Collection.prototype)) {
302
257
  * @method $print
303
258
  */
304
259
 
305
- NativeCollection.prototype.$print = function(name, i, args, color, shell) {
260
+ NativeCollection.prototype.$print = function(name, i, args, color, shell, timestamp) {
261
+ let prefix = '';
262
+ if (timestamp) {
263
+ const ts = new Date().toISOString();
264
+ prefix = color ? `\x1B[0;90m[${ts}]\x1B[0m ` : `[${ts}] `;
265
+ }
306
266
  const moduleName = color ? '\x1B[0;36mMongoose:\x1B[0m ' : 'Mongoose: ';
307
267
  const functionCall = [name, i].join('.');
308
268
  const _args = [];
@@ -313,14 +273,14 @@ NativeCollection.prototype.$print = function(name, i, args, color, shell) {
313
273
  }
314
274
  const params = '(' + _args.join(', ') + ')';
315
275
 
316
- console.info(moduleName + functionCall + params);
276
+ console.info(prefix + moduleName + functionCall + params);
317
277
  };
318
278
 
319
279
  /**
320
280
  * Debug print helper
321
281
  *
322
282
  * @api public
323
- * @method $print
283
+ * @method $printToStream
324
284
  */
325
285
 
326
286
  NativeCollection.prototype.$printToStream = function(name, i, args, stream) {
@@ -351,7 +311,7 @@ NativeCollection.prototype.$format = function(arg, color, shell) {
351
311
 
352
312
  /**
353
313
  * Debug print helper
354
- * @param {Any} representation
314
+ * @param {any} representation
355
315
  * @api private
356
316
  */
357
317
 
@@ -378,7 +338,7 @@ function formatDate(x, key, shell) {
378
338
  }
379
339
  }
380
340
  function format(obj, sub, color, shell) {
381
- if (obj && typeof obj.toBSON === 'function') {
341
+ if (typeof obj?.toBSON === 'function') {
382
342
  obj = obj.toBSON();
383
343
  }
384
344
  if (obj == null) {
@@ -428,12 +388,7 @@ function format(obj, sub, color, shell) {
428
388
  formatDate(x, key, shell);
429
389
  } else if (_constructorName === 'ClientSession') {
430
390
  x[key] = inspectable('ClientSession("' +
431
- (
432
- x[key] &&
433
- x[key].id &&
434
- x[key].id.id &&
435
- x[key].id.id.buffer || ''
436
- ).toString('hex') + '")');
391
+ (x[key]?.id?.id?.buffer || '').toString('hex') + '")');
437
392
  } else if (Array.isArray(x[key])) {
438
393
  x[key] = x[key].map(map);
439
394
  } else if (error != null) {
@@ -14,6 +14,10 @@ const setTimeout = require('../../helpers/timers').setTimeout;
14
14
  const utils = require('../../utils');
15
15
  const Schema = require('../../schema');
16
16
 
17
+ // Snapshot the native Date constructor to ensure Date.now()
18
+ // bypasses timer mocks such as those set up by useFakeTimers().
19
+ const Date = globalThis.Date;
20
+
17
21
  /**
18
22
  * A [node-mongodb-native](https://github.com/mongodb/node-mongodb-native) connection implementation.
19
23
  *
@@ -52,10 +56,9 @@ Object.setPrototypeOf(NativeConnection.prototype, MongooseConnection.prototype);
52
56
  *
53
57
  * **Note:** Calling `close()` on a `useDb()` connection will close the base connection as well.
54
58
  *
55
- * @param {String} name The database name
56
- * @param {Object} [options]
57
- * @param {Boolean} [options.useCache=false] If true, cache results so calling `useDb()` multiple times with the same name only creates 1 connection object.
58
- * @param {Boolean} [options.noListener=false] If true, the new connection object won't listen to any events on the base connection. This is better for memory usage in cases where you're calling `useDb()` for every request.
59
+ * @param {string} name The database name
60
+ * @param {object} [options]
61
+ * @param {boolean} [options.useCache=false] If true, cache results so calling `useDb()` multiple times with the same name only creates 1 connection object.
59
62
  * @return {Connection} New Connection Object
60
63
  * @api public
61
64
  */
@@ -107,25 +110,19 @@ NativeConnection.prototype.useDb = function(name, options) {
107
110
 
108
111
  function wireup() {
109
112
  newConn.client = _this.client;
110
- const _opts = {};
111
- if (Object.hasOwn(options, 'noListener')) {
112
- _opts.noListener = options.noListener;
113
- }
114
- newConn.db = _this.client.db(name, _opts);
113
+ newConn.db = _this.client.db(name);
115
114
  newConn._lastHeartbeatAt = _this._lastHeartbeatAt;
116
115
  newConn.onOpen();
117
116
  }
118
117
 
119
118
  newConn.name = name;
120
119
 
121
- // push onto the otherDbs stack, this is used when state changes and when heartbeat is received
122
- if (options.noListener !== true) {
123
- this.otherDbs.push(newConn);
124
- }
120
+ // push onto the otherDbs stack, this is used when state changes
121
+ this.otherDbs.push(newConn);
125
122
  newConn.otherDbs.push(this);
126
123
 
127
124
  // push onto the relatedDbs cache, this is used when state changes
128
- if (options && options.useCache) {
125
+ if (options?.useCache) {
129
126
  this.relatedDbs[newConn.name] = newConn;
130
127
  newConn.relatedDbs = this.relatedDbs;
131
128
  }
@@ -137,7 +134,7 @@ NativeConnection.prototype.useDb = function(name, options) {
137
134
  * Runs a [db-level aggregate()](https://www.mongodb.com/docs/manual/reference/method/db.aggregate/) on this connection's underlying `db`
138
135
  *
139
136
  * @param {Array} pipeline
140
- * @param {Object} [options]
137
+ * @param {object} [options]
141
138
  */
142
139
 
143
140
  NativeConnection.prototype.aggregate = function aggregate(pipeline, options) {
@@ -162,7 +159,7 @@ NativeConnection.prototype.aggregate = function aggregate(pipeline, options) {
162
159
  *
163
160
  * @method removeDb
164
161
  * @memberOf Connection
165
- * @param {String} name The database name
162
+ * @param {string} name The database name
166
163
  * @return {Connection} this
167
164
  */
168
165
 
@@ -185,7 +182,7 @@ NativeConnection.prototype.removeDb = function removeDb(name) {
185
182
  /**
186
183
  * Closes the connection
187
184
  *
188
- * @param {Boolean} [force]
185
+ * @param {boolean} [force]
189
186
  * @return {Connection} this
190
187
  * @api private
191
188
  */
@@ -218,7 +215,7 @@ NativeConnection.prototype.doClose = async function doClose(force) {
218
215
  /**
219
216
  * Implementation of `listDatabases()` for MongoDB driver
220
217
  *
221
- * @return Promise
218
+ * @return {Promise}
222
219
  * @api public
223
220
  */
224
221
 
@@ -258,9 +255,7 @@ NativeConnection.prototype.createClient = async function createClient(uri, optio
258
255
 
259
256
  if (options) {
260
257
 
261
- const autoIndex = options.config && options.config.autoIndex != null ?
262
- options.config.autoIndex :
263
- options.autoIndex;
258
+ const autoIndex = options.config?.autoIndex ?? options.autoIndex;
264
259
  if (autoIndex != null) {
265
260
  this.config.autoIndex = autoIndex !== false;
266
261
  delete options.config;
@@ -323,15 +318,15 @@ NativeConnection.prototype.createClient = async function createClient(uri, optio
323
318
 
324
319
  const { schemaMap, encryptedFieldsMap } = this._buildEncryptionSchemas();
325
320
 
326
- if ((Object.keys(schemaMap).length > 0 || Object.keys(encryptedFieldsMap).length) && !options.autoEncryption) {
321
+ if ((utils.hasOwnKeys(schemaMap) || utils.hasOwnKeys(encryptedFieldsMap)) && !options.autoEncryption) {
327
322
  throw new Error('Must provide `autoEncryption` when connecting with encrypted schemas.');
328
323
  }
329
324
 
330
- if (Object.keys(schemaMap).length > 0) {
325
+ if (utils.hasOwnKeys(schemaMap)) {
331
326
  options.autoEncryption.schemaMap = schemaMap;
332
327
  }
333
328
 
334
- if (Object.keys(encryptedFieldsMap).length > 0) {
329
+ if (utils.hasOwnKeys(encryptedFieldsMap)) {
335
330
  options.autoEncryption.encryptedFieldsMap = encryptedFieldsMap;
336
331
  }
337
332
 
@@ -363,7 +358,7 @@ NativeConnection.prototype.createClient = async function createClient(uri, optio
363
358
  * a schemaMap and/or an encryptedFieldsMap for the connection, combining all models
364
359
  * into a single schemaMap and encryptedFields map.
365
360
  *
366
- * @returns the generated schemaMap and encryptedFieldsMap
361
+ * @returns {object} the generated schemaMap and encryptedFieldsMap
367
362
  */
368
363
  NativeConnection.prototype._buildEncryptionSchemas = function() {
369
364
  const qeMappings = {};
@@ -442,18 +437,8 @@ function _setClient(conn, client, options, dbName) {
442
437
  const db = dbName != null ? client.db(dbName) : client.db();
443
438
  conn.db = db;
444
439
  conn.client = client;
445
- conn.host = client &&
446
- client.s &&
447
- client.s.options &&
448
- client.s.options.hosts &&
449
- client.s.options.hosts[0] &&
450
- client.s.options.hosts[0].host || void 0;
451
- conn.port = client &&
452
- client.s &&
453
- client.s.options &&
454
- client.s.options.hosts &&
455
- client.s.options.hosts[0] &&
456
- client.s.options.hosts[0].port || void 0;
440
+ conn.host = client?.s?.options?.hosts?.[0]?.host;
441
+ conn.port = client?.s?.options?.hosts?.[0]?.port;
457
442
  conn.name = dbName != null ? dbName : db.databaseName;
458
443
  conn._closeCalled = client._closeCalled;
459
444
 
@@ -470,10 +455,7 @@ function _setClient(conn, client, options, dbName) {
470
455
  }
471
456
  };
472
457
 
473
- const type = client &&
474
- client.topology &&
475
- client.topology.description &&
476
- client.topology.description.type || '';
458
+ const type = client?.topology?.description?.type || '';
477
459
 
478
460
  if (type === 'Single') {
479
461
  client.on('serverDescriptionChanged', ev => {
@@ -504,6 +486,15 @@ function _setClient(conn, client, options, dbName) {
504
486
  for (const otherDb of conn.otherDbs) {
505
487
  otherDb._lastHeartbeatAt = conn._lastHeartbeatAt;
506
488
  }
489
+ // Flush buffered operations if the connection is no longer stale (gh-16183)
490
+ if (conn._queue.length > 0 && conn.readyState === STATES.connected) {
491
+ conn._flushQueue();
492
+ }
493
+ for (const otherDb of conn.otherDbs) {
494
+ if (otherDb._queue.length > 0 && otherDb.readyState === STATES.connected) {
495
+ otherDb._flushQueue();
496
+ }
497
+ }
507
498
  });
508
499
 
509
500
  if (options.monitorCommands) {
@@ -10,8 +10,8 @@ const util = require('util');
10
10
  /**
11
11
  * Casting Error constructor.
12
12
  *
13
- * @param {String} type
14
- * @param {String} value
13
+ * @param {string} type
14
+ * @param {string} value
15
15
  * @inherits MongooseError
16
16
  * @api private
17
17
  */
@@ -42,6 +42,7 @@ class CastError extends MongooseError {
42
42
  message: this.message
43
43
  };
44
44
  }
45
+
45
46
  /*!
46
47
  * ignore
47
48
  */
@@ -76,7 +77,7 @@ class CastError extends MongooseError {
76
77
  */
77
78
  setModel(model) {
78
79
  this.message = formatMessage(model, this.kind, this.value, this.path,
79
- this.messageFormat, this.valueType);
80
+ this.messageFormat, this.valueType, this.reason);
80
81
  }
81
82
  }
82
83
 
@@ -109,7 +110,7 @@ function getValueType(value) {
109
110
  }
110
111
 
111
112
  function getMessageFormat(schemaType) {
112
- const messageFormat = schemaType && schemaType._castErrorMessage || null;
113
+ const messageFormat = schemaType?._castErrorMessage || null;
113
114
  if (typeof messageFormat === 'string' || typeof messageFormat === 'function') {
114
115
  return messageFormat;
115
116
  }
@@ -122,10 +123,11 @@ function getMessageFormat(schemaType) {
122
123
  function formatMessage(model, kind, value, path, messageFormat, valueType, reason) {
123
124
  if (typeof messageFormat === 'string') {
124
125
  const stringValue = getStringValue(value);
125
- let ret = messageFormat.
126
- replace('{KIND}', kind).
127
- replace('{VALUE}', stringValue).
128
- replace('{PATH}', path);
126
+ let ret = messageFormat
127
+ .replace('{KIND}', kind)
128
+ .replace('{VALUE}', stringValue)
129
+ .replace('{PATH}', path);
130
+
129
131
  if (model != null) {
130
132
  ret = ret.replace('{MODEL}', model.modelName);
131
133
  }
@@ -136,17 +138,24 @@ function formatMessage(model, kind, value, path, messageFormat, valueType, reaso
136
138
  } else {
137
139
  const stringValue = getStringValue(value);
138
140
  const valueTypeMsg = valueType ? ' (type ' + valueType + ')' : '';
141
+
139
142
  let ret = 'Cast to ' + kind + ' failed for value ' +
140
143
  stringValue + valueTypeMsg + ' at path "' + path + '"';
144
+
141
145
  if (model != null) {
142
146
  ret += ' for model "' + model.modelName + '"';
143
147
  }
144
- if (reason != null &&
145
- typeof reason.constructor === 'function' &&
146
- reason.constructor.name !== 'AssertionError' &&
147
- reason.constructor.name !== 'Error') {
148
+
149
+ if (
150
+ reason != null &&
151
+ typeof reason.constructor === 'function' &&
152
+ reason.constructor.name !== 'AssertionError' &&
153
+ reason.constructor.name !== 'Error' &&
154
+ reason.constructor.name !== 'BSONError'
155
+ ) {
148
156
  ret += ' because of "' + reason.constructor.name + '"';
149
157
  }
158
+
150
159
  return ret;
151
160
  }
152
161
  }
@@ -5,8 +5,8 @@ const MongooseError = require('./mongooseError');
5
5
  /**
6
6
  * createCollections Error constructor
7
7
  *
8
- * @param {String} message
9
- * @param {String} errorsMap
8
+ * @param {string} message
9
+ * @param {string} errorsMap
10
10
  * @inherits MongooseError
11
11
  * @api private
12
12
  */
@@ -9,7 +9,7 @@ const MongooseError = require('./mongooseError');
9
9
 
10
10
  /**
11
11
  * DivergentArrayError constructor.
12
- * @param {Array<String>} paths
12
+ * @param {string[]} paths
13
13
  * @api private
14
14
  */
15
15
 
@@ -17,7 +17,7 @@ const MongooseError = require('./mongooseError');
17
17
 
18
18
  class EachAsyncMultiError extends MongooseError {
19
19
  /**
20
- * @param {String} connectionString
20
+ * @param {string} connectionString
21
21
  */
22
22
  constructor(errors) {
23
23
  let preview = errors.map(e => e.message).join(', ');
@@ -13,7 +13,7 @@
13
13
  * err instanceof mongoose.Error.ValidationError; // true
14
14
  *
15
15
  * @constructor Error
16
- * @param {String} msg Error message
16
+ * @param {string} msg Error message
17
17
  * @inherits Error https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Error
18
18
  */
19
19
 
@@ -32,14 +32,14 @@ const MongooseError = require('./mongooseError');
32
32
  * - `ValidationError`: error returned from [`validate()`](https://mongoosejs.com/docs/api/document.html#Document.prototype.validate()) or [`validateSync()`](https://mongoosejs.com/docs/api/document.html#Document.prototype.validateSync()). Contains zero or more `ValidatorError` instances in `.errors` property.
33
33
  * - `MissingSchemaError`: You called `mongoose.Document()` without a schema
34
34
  * - `ObjectExpectedError`: Thrown when you set a nested path to a non-object value with [strict mode set](https://mongoosejs.com/docs/guide.html#strict).
35
- * - `ObjectParameterError`: Thrown when you pass a non-object value to a function which expects an object as a paramter
35
+ * - `ObjectParameterError`: Thrown when you pass a non-object value to a function which expects an object as a parameter
36
36
  * - `OverwriteModelError`: Thrown when you call [`mongoose.model()`](https://mongoosejs.com/docs/api/mongoose.html#Mongoose.model()) to re-define a model that was already defined.
37
37
  * - `ParallelSaveError`: Thrown when you call [`save()`](https://mongoosejs.com/docs/api/model.html#Model.prototype.save()) on a document when the same document instance is already saving.
38
38
  * - `StrictModeError`: Thrown when you set a path that isn't the schema and [strict mode](https://mongoosejs.com/docs/guide.html#strict) is set to `throw`.
39
39
  * - `VersionError`: Thrown when the [document is out of sync](https://mongoosejs.com/docs/guide.html#versionKey)
40
40
  *
41
41
  * @api public
42
- * @property {String} name
42
+ * @property {string} name
43
43
  * @memberOf Error
44
44
  * @instance
45
45
  */
@@ -9,7 +9,7 @@ const MongooseError = require('./mongooseError');
9
9
 
10
10
  /**
11
11
  * InvalidSchemaOption Error constructor.
12
- * @param {String} name
12
+ * @param {string} name
13
13
  * @api private
14
14
  */
15
15
 
@@ -30,6 +30,7 @@ msg.DocumentNotFoundError = null;
30
30
  msg.general = {};
31
31
  msg.general.default = 'Validator failed for path `{PATH}` with value `{VALUE}`';
32
32
  msg.general.required = 'Path `{PATH}` is required.';
33
+ msg.general.allowNull = 'Path `{PATH}` does not allow null values.';
33
34
 
34
35
  msg.Number = {};
35
36
  msg.Number.min = 'Path `{PATH}` ({VALUE}) is less than minimum allowed value ({MIN}).';