@nullix/zod-mongoose-studio 1.0.13 → 2.0.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 (314) hide show
  1. package/.output/nitro.json +1 -1
  2. package/.output/public/_nuxt/{Db4IAypj.js → 0J_bLG6U.js} +1 -1
  3. package/.output/public/_nuxt/{Y39o1QEi.js → 5KLjKHc1.js} +1 -1
  4. package/.output/public/_nuxt/{B4zoPYF-.js → B2UrsJHg.js} +1 -1
  5. package/.output/public/_nuxt/{BSqjh6Vk.js → BC5hGokz.js} +1 -1
  6. package/.output/public/_nuxt/{BS4yU4O0.js → BJwN20Xm.js} +1 -1
  7. package/.output/public/_nuxt/{D8_n84hl.js → BMgDPqps.js} +1 -1
  8. package/.output/public/_nuxt/{CqNsQbt9.js → B_sGF2qN.js} +1 -1
  9. package/.output/public/_nuxt/{NAqlztEN.js → BeaJ7I-K.js} +10 -10
  10. package/.output/public/_nuxt/{WZ0WK9cR.js → BkE1sm_1.js} +1 -1
  11. package/.output/public/_nuxt/{kBtP64Rx.js → CADbZwE5.js} +1 -1
  12. package/.output/public/_nuxt/{B8qGaxNm.js → CB0WRoVi.js} +1 -1
  13. package/.output/public/_nuxt/{BV6uALfO.js → CCh0PVV0.js} +1 -1
  14. package/.output/public/_nuxt/{CP9Z7-_9.js → Cr0GW7rA.js} +1 -1
  15. package/.output/public/_nuxt/{DeCqoVOS.js → DJe7Wxdv.js} +1 -1
  16. package/.output/public/_nuxt/{dBZQW7JD.js → DRBrUaE5.js} +1 -1
  17. package/.output/public/_nuxt/{Db19R32y.js → DV2n9B6m.js} +1 -1
  18. package/.output/public/_nuxt/{CvnpbYw0.js → DVD-jGiv.js} +1 -1
  19. package/.output/public/_nuxt/{BWajNATZ.js → Dk9qGA5X.js} +3 -3
  20. package/.output/public/_nuxt/builds/latest.json +1 -1
  21. package/.output/public/_nuxt/builds/meta/dc761332-547d-4953-b51d-b2d453009b48.json +1 -0
  22. package/.output/public/_nuxt/error-404.64pZEiDn.css +1 -0
  23. package/.output/public/_nuxt/error-500.DHOpI0Ir.css +1 -0
  24. package/.output/public/_nuxt/{BoHhCIKW.js → koEZfutw.js} +3 -3
  25. package/.output/public/_nuxt/{B_782F4p.js → r6LdR7DN.js} +1 -1
  26. package/.output/public/_nuxt/{BEI71c6K.js → rEfOp38p.js} +1 -1
  27. package/.output/server/chunks/_/error-500.mjs.map +1 -1
  28. package/.output/server/chunks/build/client.precomputed.mjs +1 -1
  29. package/.output/server/chunks/build/{error-404-8tbBXju4.mjs → error-404-BN-7rNE4.mjs} +4 -4
  30. package/.output/server/chunks/build/error-404-BN-7rNE4.mjs.map +1 -0
  31. package/.output/server/chunks/build/error-404-styles.Byx46oLR.mjs +8 -0
  32. package/.output/server/chunks/build/error-404-styles.Byx46oLR.mjs.map +1 -0
  33. package/.output/server/chunks/build/{error-500-DxFsom1i.mjs → error-500-DhIQ-2yt.mjs} +4 -4
  34. package/.output/server/chunks/build/error-500-DhIQ-2yt.mjs.map +1 -0
  35. package/.output/server/chunks/build/error-500-styles.BL3UT0Wa.mjs +8 -0
  36. package/.output/server/chunks/build/error-500-styles.BL3UT0Wa.mjs.map +1 -0
  37. package/.output/server/chunks/build/{index-BB-Clavm.mjs → index-Dnrh1ePF.mjs} +1 -1
  38. package/.output/server/chunks/build/index-Dnrh1ePF.mjs.map +1 -0
  39. package/.output/server/chunks/build/server.mjs +9 -9
  40. package/.output/server/chunks/build/styles.mjs +4 -4
  41. package/.output/server/chunks/nitro/nitro.mjs +333 -333
  42. package/.output/server/chunks/nitro/nitro.mjs.map +1 -1
  43. package/.output/server/chunks/routes/renderer.mjs.map +1 -1
  44. package/.output/server/node_modules/bson/lib/bson.cjs +157 -48
  45. package/.output/server/node_modules/bson/package.json +9 -11
  46. package/.output/server/node_modules/kareem/index.js +228 -343
  47. package/.output/server/node_modules/kareem/package.json +3 -3
  48. package/.output/server/node_modules/mongodb/lib/bson.js +27 -5
  49. package/.output/server/node_modules/mongodb/lib/bulk/common.js +7 -9
  50. package/.output/server/node_modules/mongodb/lib/change_stream.js +91 -39
  51. package/.output/server/node_modules/mongodb/lib/client-side-encryption/auto_encrypter.js +21 -14
  52. package/.output/server/node_modules/mongodb/lib/client-side-encryption/client_encryption.js +2 -5
  53. package/.output/server/node_modules/mongodb/lib/client-side-encryption/errors.js +3 -1
  54. package/.output/server/node_modules/mongodb/lib/client-side-encryption/mongocryptd_manager.js +1 -1
  55. package/.output/server/node_modules/mongodb/lib/client-side-encryption/state_machine.js +1 -0
  56. package/.output/server/node_modules/mongodb/lib/cmap/auth/aws4.js +161 -0
  57. package/.output/server/node_modules/mongodb/lib/cmap/auth/aws_temporary_credentials.js +11 -58
  58. package/.output/server/node_modules/mongodb/lib/cmap/auth/gssapi.js +4 -6
  59. package/.output/server/node_modules/mongodb/lib/cmap/auth/mongo_credentials.js +2 -16
  60. package/.output/server/node_modules/mongodb/lib/cmap/auth/mongodb_aws.js +14 -23
  61. package/.output/server/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/azure_machine_workflow.js +3 -3
  62. package/.output/server/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/gcp_machine_workflow.js +3 -3
  63. package/.output/server/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/k8s_machine_workflow.js +4 -3
  64. package/.output/server/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/token_machine_workflow.js +4 -3
  65. package/.output/server/node_modules/mongodb/lib/cmap/auth/mongodb_oidc.js +4 -4
  66. package/.output/server/node_modules/mongodb/lib/cmap/auth/plain.js +1 -1
  67. package/.output/server/node_modules/mongodb/lib/cmap/auth/providers.js +0 -1
  68. package/.output/server/node_modules/mongodb/lib/cmap/auth/scram.js +53 -40
  69. package/.output/server/node_modules/mongodb/lib/cmap/commands.js +46 -39
  70. package/.output/server/node_modules/mongodb/lib/cmap/connect.js +35 -3
  71. package/.output/server/node_modules/mongodb/lib/cmap/connection.js +36 -32
  72. package/.output/server/node_modules/mongodb/lib/cmap/connection_pool.js +67 -67
  73. package/.output/server/node_modules/mongodb/lib/cmap/connection_pool_events.js +3 -3
  74. package/.output/server/node_modules/mongodb/lib/cmap/errors.js +1 -1
  75. package/.output/server/node_modules/mongodb/lib/cmap/handshake/client_metadata.js +15 -13
  76. package/.output/server/node_modules/mongodb/lib/cmap/metrics.js +3 -3
  77. package/.output/server/node_modules/mongodb/lib/cmap/wire_protocol/compression.js +26 -10
  78. package/.output/server/node_modules/mongodb/lib/cmap/wire_protocol/constants.js +3 -1
  79. package/.output/server/node_modules/mongodb/lib/cmap/wire_protocol/on_data.js +0 -1
  80. package/.output/server/node_modules/mongodb/lib/cmap/wire_protocol/on_demand/document.js +9 -9
  81. package/.output/server/node_modules/mongodb/lib/cmap/wire_protocol/responses.js +2 -2
  82. package/.output/server/node_modules/mongodb/lib/collection.js +1 -1
  83. package/.output/server/node_modules/mongodb/lib/connection_string.js +30 -15
  84. package/.output/server/node_modules/mongodb/lib/cursor/abstract_cursor.js +17 -34
  85. package/.output/server/node_modules/mongodb/lib/cursor/change_stream_cursor.js +2 -2
  86. package/.output/server/node_modules/mongodb/lib/cursor/find_cursor.js +37 -26
  87. package/.output/server/node_modules/mongodb/lib/cursor/run_command_cursor.js +1 -1
  88. package/.output/server/node_modules/mongodb/lib/db.js +6 -7
  89. package/.output/server/node_modules/mongodb/lib/deps.js +0 -13
  90. package/.output/server/node_modules/mongodb/lib/error.js +7 -10
  91. package/.output/server/node_modules/mongodb/lib/gridfs/download.js +7 -6
  92. package/.output/server/node_modules/mongodb/lib/gridfs/index.js +9 -9
  93. package/.output/server/node_modules/mongodb/lib/gridfs/upload.js +17 -23
  94. package/.output/server/node_modules/mongodb/lib/index.js +2 -4
  95. package/.output/server/node_modules/mongodb/lib/mongo_client.js +58 -67
  96. package/.output/server/node_modules/mongodb/lib/mongo_client_auth_providers.js +0 -6
  97. package/.output/server/node_modules/mongodb/lib/mongo_logger.js +11 -5
  98. package/.output/server/node_modules/mongodb/lib/mongo_types.js +1 -2
  99. package/.output/server/node_modules/mongodb/lib/operations/aggregate.js +0 -3
  100. package/.output/server/node_modules/mongodb/lib/operations/create_collection.js +0 -1
  101. package/.output/server/node_modules/mongodb/lib/operations/drop.js +8 -9
  102. package/.output/server/node_modules/mongodb/lib/operations/end_sessions.js +34 -0
  103. package/.output/server/node_modules/mongodb/lib/operations/execute_operation.js +121 -45
  104. package/.output/server/node_modules/mongodb/lib/operations/operation.js +1 -0
  105. package/.output/server/node_modules/mongodb/lib/read_preference.js +10 -14
  106. package/.output/server/node_modules/mongodb/lib/runtime_adapters.js +32 -0
  107. package/.output/server/node_modules/mongodb/lib/sdam/monitor.js +8 -8
  108. package/.output/server/node_modules/mongodb/lib/sdam/server.js +55 -43
  109. package/.output/server/node_modules/mongodb/lib/sdam/server_description.js +1 -1
  110. package/.output/server/node_modules/mongodb/lib/sdam/server_selection.js +135 -72
  111. package/.output/server/node_modules/mongodb/lib/sdam/srv_polling.js +3 -3
  112. package/.output/server/node_modules/mongodb/lib/sdam/topology.js +37 -77
  113. package/.output/server/node_modules/mongodb/lib/sdam/topology_description.js +1 -1
  114. package/.output/server/node_modules/mongodb/lib/sessions.js +150 -40
  115. package/.output/server/node_modules/mongodb/lib/transactions.js +2 -13
  116. package/.output/server/node_modules/mongodb/lib/utils.js +42 -90
  117. package/.output/server/node_modules/mongodb/package.json +49 -45
  118. package/.output/server/node_modules/mongodb-connection-string-url/lib/index.js +45 -19
  119. package/.output/server/node_modules/mongodb-connection-string-url/lib/redact.js +30 -19
  120. package/.output/server/node_modules/mongodb-connection-string-url/package.json +25 -16
  121. package/.output/server/node_modules/mongoose/lib/aggregate.js +108 -127
  122. package/.output/server/node_modules/mongoose/lib/cast/bigint.js +3 -3
  123. package/.output/server/node_modules/mongoose/lib/cast/boolean.js +3 -3
  124. package/.output/server/node_modules/mongoose/lib/cast/double.js +4 -4
  125. package/.output/server/node_modules/mongoose/lib/cast/int32.js +2 -2
  126. package/.output/server/node_modules/mongoose/lib/cast/number.js +6 -6
  127. package/.output/server/node_modules/mongoose/lib/cast/string.js +3 -3
  128. package/.output/server/node_modules/mongoose/lib/cast/uuid.js +5 -48
  129. package/.output/server/node_modules/mongoose/lib/cast.js +16 -24
  130. package/.output/server/node_modules/mongoose/lib/collection.js +6 -6
  131. package/.output/server/node_modules/mongoose/lib/connection.js +108 -105
  132. package/.output/server/node_modules/mongoose/lib/cursor/aggregationCursor.js +23 -33
  133. package/.output/server/node_modules/mongoose/lib/cursor/changeStream.js +60 -40
  134. package/.output/server/node_modules/mongoose/lib/cursor/queryCursor.js +21 -25
  135. package/.output/server/node_modules/mongoose/lib/document.js +712 -531
  136. package/.output/server/node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js +85 -130
  137. package/.output/server/node_modules/mongoose/lib/drivers/node-mongodb-native/connection.js +32 -41
  138. package/.output/server/node_modules/mongoose/lib/error/cast.js +21 -12
  139. package/.output/server/node_modules/mongoose/lib/error/createCollectionsError.js +2 -2
  140. package/.output/server/node_modules/mongoose/lib/error/divergentArray.js +1 -1
  141. package/.output/server/node_modules/mongoose/lib/error/eachAsyncMultiError.js +1 -1
  142. package/.output/server/node_modules/mongoose/lib/error/index.js +3 -3
  143. package/.output/server/node_modules/mongoose/lib/error/invalidSchemaOption.js +1 -1
  144. package/.output/server/node_modules/mongoose/lib/error/messages.js +1 -0
  145. package/.output/server/node_modules/mongoose/lib/error/missingSchema.js +1 -1
  146. package/.output/server/node_modules/mongoose/lib/error/objectParameter.js +4 -5
  147. package/.output/server/node_modules/mongoose/lib/error/overwriteModel.js +1 -1
  148. package/.output/server/node_modules/mongoose/lib/error/setOptionError.js +3 -3
  149. package/.output/server/node_modules/mongoose/lib/error/strict.js +3 -3
  150. package/.output/server/node_modules/mongoose/lib/error/strictPopulate.js +2 -2
  151. package/.output/server/node_modules/mongoose/lib/error/syncIndexes.js +2 -2
  152. package/.output/server/node_modules/mongoose/lib/error/validation.js +2 -10
  153. package/.output/server/node_modules/mongoose/lib/error/validator.js +1 -1
  154. package/.output/server/node_modules/mongoose/lib/error/version.js +2 -2
  155. package/.output/server/node_modules/mongoose/lib/helpers/aggregate/prepareDiscriminatorPipeline.js +4 -4
  156. package/.output/server/node_modules/mongoose/lib/helpers/buildMiddlewareFilter.js +24 -0
  157. package/.output/server/node_modules/mongoose/lib/helpers/clone.js +35 -18
  158. package/.output/server/node_modules/mongoose/lib/helpers/common.js +5 -5
  159. package/.output/server/node_modules/mongoose/lib/helpers/cursor/eachAsync.js +4 -4
  160. package/.output/server/node_modules/mongoose/lib/helpers/discriminator/getConstructor.js +1 -1
  161. package/.output/server/node_modules/mongoose/lib/helpers/discriminator/getDiscriminatorByValue.js +1 -1
  162. package/.output/server/node_modules/mongoose/lib/helpers/discriminator/getSchemaDiscriminatorByValue.js +1 -1
  163. package/.output/server/node_modules/mongoose/lib/helpers/discriminator/mergeDiscriminatorSchema.js +10 -5
  164. package/.output/server/node_modules/mongoose/lib/helpers/document/applyDefaults.js +1 -1
  165. package/.output/server/node_modules/mongoose/lib/helpers/document/applyTimestamps.js +11 -10
  166. package/.output/server/node_modules/mongoose/lib/helpers/document/applyVirtuals.js +10 -9
  167. package/.output/server/node_modules/mongoose/lib/helpers/document/cleanModifiedSubpaths.js +1 -1
  168. package/.output/server/node_modules/mongoose/lib/helpers/document/compile.js +17 -14
  169. package/.output/server/node_modules/mongoose/lib/helpers/document/getDeepestSubdocumentForPath.js +3 -3
  170. package/.output/server/node_modules/mongoose/lib/helpers/document/getEmbeddedDiscriminatorPath.js +2 -2
  171. package/.output/server/node_modules/mongoose/lib/helpers/document/isInPathsToSave.js +24 -0
  172. package/.output/server/node_modules/mongoose/lib/helpers/get.js +1 -1
  173. package/.output/server/node_modules/mongoose/lib/helpers/indexes/decorateDiscriminatorIndexOptions.js +1 -1
  174. package/.output/server/node_modules/mongoose/lib/helpers/indexes/getRelatedIndexes.js +3 -3
  175. package/.output/server/node_modules/mongoose/lib/helpers/indexes/isIndexEqual.js +3 -4
  176. package/.output/server/node_modules/mongoose/lib/helpers/indexes/isIndexSpecEqual.js +3 -3
  177. package/.output/server/node_modules/mongoose/lib/helpers/isBsonType.js +1 -1
  178. package/.output/server/node_modules/mongoose/lib/helpers/isMongooseObject.js +1 -1
  179. package/.output/server/node_modules/mongoose/lib/helpers/isObject.js +2 -2
  180. package/.output/server/node_modules/mongoose/lib/helpers/isSimpleValidator.js +2 -2
  181. package/.output/server/node_modules/mongoose/lib/helpers/minimize.js +2 -2
  182. package/.output/server/node_modules/mongoose/lib/helpers/model/applyDefaultsToPOJO.js +2 -2
  183. package/.output/server/node_modules/mongoose/lib/helpers/model/applyHooks.js +55 -54
  184. package/.output/server/node_modules/mongoose/lib/helpers/model/applyMethods.js +2 -2
  185. package/.output/server/node_modules/mongoose/lib/helpers/model/applyStaticHooks.js +1 -48
  186. package/.output/server/node_modules/mongoose/lib/helpers/model/castBulkWrite.js +8 -12
  187. package/.output/server/node_modules/mongoose/lib/helpers/model/discriminator.js +1 -1
  188. package/.output/server/node_modules/mongoose/lib/helpers/parallelLimit.js +18 -36
  189. package/.output/server/node_modules/mongoose/lib/helpers/pluralize.js +4 -4
  190. package/.output/server/node_modules/mongoose/lib/helpers/populate/assignRawDocsToIdStructure.js +4 -11
  191. package/.output/server/node_modules/mongoose/lib/helpers/populate/assignVals.js +10 -10
  192. package/.output/server/node_modules/mongoose/lib/helpers/populate/createPopulateQueryFilter.js +3 -3
  193. package/.output/server/node_modules/mongoose/lib/helpers/populate/getModelsMapForPopulate.js +197 -69
  194. package/.output/server/node_modules/mongoose/lib/helpers/populate/getSchemaTypes.js +15 -15
  195. package/.output/server/node_modules/mongoose/lib/helpers/populate/markArraySubdocsPopulated.js +1 -1
  196. package/.output/server/node_modules/mongoose/lib/helpers/populate/modelNamesFromRefPath.js +10 -2
  197. package/.output/server/node_modules/mongoose/lib/helpers/populate/setPopulatedVirtualValue.js +5 -5
  198. package/.output/server/node_modules/mongoose/lib/helpers/printJestWarning.js +1 -1
  199. package/.output/server/node_modules/mongoose/lib/helpers/processConnectionOptions.js +1 -1
  200. package/.output/server/node_modules/mongoose/lib/helpers/projection/hasIncludedChildren.js +1 -1
  201. package/.output/server/node_modules/mongoose/lib/helpers/projection/isPathExcluded.js +3 -3
  202. package/.output/server/node_modules/mongoose/lib/helpers/projection/isSubpath.js +1 -1
  203. package/.output/server/node_modules/mongoose/lib/helpers/projection/parseProjection.js +9 -4
  204. package/.output/server/node_modules/mongoose/lib/helpers/query/cast$expr.js +8 -10
  205. package/.output/server/node_modules/mongoose/lib/helpers/query/castFilterPath.js +1 -1
  206. package/.output/server/node_modules/mongoose/lib/helpers/query/castUpdate.js +44 -38
  207. package/.output/server/node_modules/mongoose/lib/helpers/query/getEmbeddedDiscriminatorPath.js +8 -8
  208. package/.output/server/node_modules/mongoose/lib/helpers/query/handleImmutable.js +8 -8
  209. package/.output/server/node_modules/mongoose/lib/helpers/schema/applyPlugins.js +2 -2
  210. package/.output/server/node_modules/mongoose/lib/helpers/schema/applyReadConcern.js +1 -1
  211. package/.output/server/node_modules/mongoose/lib/helpers/schema/applyWriteConcern.js +4 -2
  212. package/.output/server/node_modules/mongoose/lib/helpers/schema/getIndexes.js +5 -11
  213. package/.output/server/node_modules/mongoose/lib/helpers/schema/getSubdocumentStrictValue.js +2 -2
  214. package/.output/server/node_modules/mongoose/lib/helpers/schema/handleIdOption.js +1 -1
  215. package/.output/server/node_modules/mongoose/lib/helpers/schema/idGetter.js +1 -1
  216. package/.output/server/node_modules/mongoose/lib/helpers/schematype/handleImmutable.js +1 -1
  217. package/.output/server/node_modules/mongoose/lib/helpers/setDefaultsOnInsert.js +26 -13
  218. package/.output/server/node_modules/mongoose/lib/helpers/timestamps/setDocumentTimestamps.js +2 -2
  219. package/.output/server/node_modules/mongoose/lib/helpers/timestamps/setupTimestamps.js +60 -38
  220. package/.output/server/node_modules/mongoose/lib/helpers/update/applyTimestampsToUpdate.js +13 -10
  221. package/.output/server/node_modules/mongoose/lib/helpers/update/castArrayFilters.js +4 -4
  222. package/.output/server/node_modules/mongoose/lib/helpers/update/decorateUpdateWithVersionKey.js +1 -1
  223. package/.output/server/node_modules/mongoose/lib/helpers/update/modifiedPaths.js +2 -2
  224. package/.output/server/node_modules/mongoose/lib/helpers/update/removeUnusedArrayFilters.js +7 -2
  225. package/.output/server/node_modules/mongoose/lib/helpers/updateValidators.js +58 -119
  226. package/.output/server/node_modules/mongoose/lib/model.js +940 -946
  227. package/.output/server/node_modules/mongoose/lib/mongoose.js +131 -79
  228. package/.output/server/node_modules/mongoose/lib/options/schemaArrayOptions.js +2 -2
  229. package/.output/server/node_modules/mongoose/lib/options/schemaBufferOptions.js +1 -1
  230. package/.output/server/node_modules/mongoose/lib/options/schemaDocumentArrayOptions.js +23 -0
  231. package/.output/server/node_modules/mongoose/lib/options/schemaNumberOptions.js +3 -3
  232. package/.output/server/node_modules/mongoose/lib/options/schemaObjectIdOptions.js +2 -2
  233. package/.output/server/node_modules/mongoose/lib/options/schemaStringOptions.js +6 -6
  234. package/.output/server/node_modules/mongoose/lib/options/schemaSubdocumentOptions.js +23 -0
  235. package/.output/server/node_modules/mongoose/lib/options/schemaTypeOptions.js +27 -13
  236. package/.output/server/node_modules/mongoose/lib/options/virtualOptions.js +12 -12
  237. package/.output/server/node_modules/mongoose/lib/plugins/index.js +0 -1
  238. package/.output/server/node_modules/mongoose/lib/plugins/saveSubdocs.js +84 -92
  239. package/.output/server/node_modules/mongoose/lib/plugins/sharding.js +33 -15
  240. package/.output/server/node_modules/mongoose/lib/plugins/trackTransaction.js +29 -25
  241. package/.output/server/node_modules/mongoose/lib/query.js +700 -548
  242. package/.output/server/node_modules/mongoose/lib/queryHelpers.js +34 -32
  243. package/.output/server/node_modules/mongoose/lib/schema/array.js +69 -113
  244. package/.output/server/node_modules/mongoose/lib/schema/bigint.js +18 -20
  245. package/.output/server/node_modules/mongoose/lib/schema/boolean.js +20 -22
  246. package/.output/server/node_modules/mongoose/lib/schema/buffer.js +23 -25
  247. package/.output/server/node_modules/mongoose/lib/schema/date.js +19 -21
  248. package/.output/server/node_modules/mongoose/lib/schema/decimal128.js +16 -18
  249. package/.output/server/node_modules/mongoose/lib/schema/documentArray.js +94 -131
  250. package/.output/server/node_modules/mongoose/lib/schema/documentArrayElement.js +50 -16
  251. package/.output/server/node_modules/mongoose/lib/schema/double.js +16 -18
  252. package/.output/server/node_modules/mongoose/lib/schema/index.js +1 -0
  253. package/.output/server/node_modules/mongoose/lib/schema/int32.js +17 -19
  254. package/.output/server/node_modules/mongoose/lib/schema/map.js +17 -24
  255. package/.output/server/node_modules/mongoose/lib/schema/mixed.js +14 -14
  256. package/.output/server/node_modules/mongoose/lib/schema/number.js +38 -28
  257. package/.output/server/node_modules/mongoose/lib/schema/objectId.js +18 -20
  258. package/.output/server/node_modules/mongoose/lib/schema/operators/exists.js +1 -1
  259. package/.output/server/node_modules/mongoose/lib/schema/operators/geospatial.js +1 -1
  260. package/.output/server/node_modules/mongoose/lib/schema/operators/text.js +4 -4
  261. package/.output/server/node_modules/mongoose/lib/schema/string.js +42 -27
  262. package/.output/server/node_modules/mongoose/lib/schema/subdocument.js +47 -58
  263. package/.output/server/node_modules/mongoose/lib/schema/union.js +54 -4
  264. package/.output/server/node_modules/mongoose/lib/schema/uuid.js +17 -40
  265. package/.output/server/node_modules/mongoose/lib/schema.js +235 -176
  266. package/.output/server/node_modules/mongoose/lib/schemaType.js +227 -158
  267. package/.output/server/node_modules/mongoose/lib/stateMachine.js +5 -8
  268. package/.output/server/node_modules/mongoose/lib/types/array/index.js +5 -5
  269. package/.output/server/node_modules/mongoose/lib/types/array/methods/index.js +27 -28
  270. package/.output/server/node_modules/mongoose/lib/types/arraySubdocument.js +11 -11
  271. package/.output/server/node_modules/mongoose/lib/types/buffer.js +15 -15
  272. package/.output/server/node_modules/mongoose/lib/types/decimal128.js +1 -1
  273. package/.output/server/node_modules/mongoose/lib/types/documentArray/index.js +4 -4
  274. package/.output/server/node_modules/mongoose/lib/types/documentArray/methods/index.js +15 -13
  275. package/.output/server/node_modules/mongoose/lib/types/double.js +1 -1
  276. package/.output/server/node_modules/mongoose/lib/types/map.js +20 -71
  277. package/.output/server/node_modules/mongoose/lib/types/objectid.js +1 -1
  278. package/.output/server/node_modules/mongoose/lib/types/subdocument.js +32 -81
  279. package/.output/server/node_modules/mongoose/lib/types/uuid.js +1 -1
  280. package/.output/server/node_modules/mongoose/lib/utils.js +91 -70
  281. package/.output/server/node_modules/mongoose/lib/validOptions.js +4 -3
  282. package/.output/server/node_modules/mongoose/lib/virtualType.js +18 -18
  283. package/.output/server/node_modules/mongoose/package.json +46 -63
  284. package/.output/server/node_modules/mquery/lib/collection/collection.js +3 -1
  285. package/.output/server/node_modules/mquery/lib/collection/node.js +17 -3
  286. package/.output/server/node_modules/mquery/lib/mquery.js +136 -93
  287. package/.output/server/node_modules/mquery/lib/permissions.js +21 -6
  288. package/.output/server/node_modules/mquery/package.json +4 -7
  289. package/.output/server/package.json +7 -9
  290. package/package.json +3 -3
  291. package/.output/public/_nuxt/builds/meta/0d6006db-fbb0-4297-85cf-bf92ceafcb79.json +0 -1
  292. package/.output/public/_nuxt/error-404.CTWLHxjC.css +0 -1
  293. package/.output/public/_nuxt/error-500.UBfk8-QP.css +0 -1
  294. package/.output/server/chunks/build/error-404-8tbBXju4.mjs.map +0 -1
  295. package/.output/server/chunks/build/error-404-styles.BeWfK6Py.mjs +0 -8
  296. package/.output/server/chunks/build/error-404-styles.BeWfK6Py.mjs.map +0 -1
  297. package/.output/server/chunks/build/error-500-DxFsom1i.mjs.map +0 -1
  298. package/.output/server/chunks/build/error-500-styles.CPUUvoY-.mjs +0 -8
  299. package/.output/server/chunks/build/error-500-styles.CPUUvoY-.mjs.map +0 -1
  300. package/.output/server/chunks/build/index-BB-Clavm.mjs.map +0 -1
  301. package/.output/server/node_modules/debug/package.json +0 -64
  302. package/.output/server/node_modules/debug/src/browser.js +0 -272
  303. package/.output/server/node_modules/debug/src/common.js +0 -292
  304. package/.output/server/node_modules/debug/src/index.js +0 -10
  305. package/.output/server/node_modules/debug/src/node.js +0 -263
  306. package/.output/server/node_modules/mongodb/lib/client-side-encryption/crypto_callbacks.js +0 -81
  307. package/.output/server/node_modules/mongodb/lib/resource_management.js +0 -58
  308. package/.output/server/node_modules/mongoose/lib/browserDocument.js +0 -101
  309. package/.output/server/node_modules/mongoose/lib/documentProvider.js +0 -30
  310. package/.output/server/node_modules/mongoose/lib/helpers/createJSONSchemaTypeDefinition.js +0 -24
  311. package/.output/server/node_modules/mongoose/lib/helpers/promiseOrCallback.js +0 -54
  312. package/.output/server/node_modules/mongoose/lib/plugins/validateBeforeSave.js +0 -51
  313. package/.output/server/node_modules/supports-color/index.js +0 -202
  314. package/.output/server/node_modules/supports-color/package.json +0 -64
@@ -7,15 +7,14 @@
7
7
  const CastError = require('../error/cast');
8
8
  const SchemaType = require('../schemaType');
9
9
  const castInt32 = require('../cast/int32');
10
- const createJSONSchemaTypeDefinition = require('../helpers/createJSONSchemaTypeDefinition');
11
10
  const handleBitwiseOperator = require('./operators/bitwise');
12
11
 
13
12
  /**
14
13
  * Int32 SchemaType constructor.
15
14
  *
16
- * @param {String} path
17
- * @param {Object} options
18
- * @param {Object} schemaOptions
15
+ * @param {string} path
16
+ * @param {object} options
17
+ * @param {object} schemaOptions
19
18
  * @param {Schema} parentSchema
20
19
  * @inherits SchemaType
21
20
  * @api public
@@ -53,10 +52,10 @@ SchemaInt32._cast = castInt32;
53
52
  * #### Example:
54
53
  *
55
54
  * // Make all Int32 fields required by default
56
- * mongoose.Schema.Int32.set('required', true);
55
+ * mongoose.Schema.Types.Int32.set('required', true);
57
56
  *
58
- * @param {String} option The option you'd like to set the value for
59
- * @param {Any} value value for option
57
+ * @param {string} option The option you'd like to set the value for
58
+ * @param {any} value value for option
60
59
  * @return {undefined}
61
60
  * @function set
62
61
  * @static
@@ -73,7 +72,7 @@ SchemaInt32.setters = [];
73
72
  * #### Example:
74
73
  *
75
74
  * // Converts int32 to be a represent milliseconds upon access
76
- * mongoose.Schema.Int32.get(v => v == null ? '0 ms' : v.toString() + ' ms');
75
+ * mongoose.Schema.Types.Int32.get(v => v == null ? '0 ms' : v.toString() + ' ms');
77
76
  *
78
77
  * @param {Function} getter
79
78
  * @return {this}
@@ -116,7 +115,7 @@ SchemaInt32._defaultCaster = v => {
116
115
  * });
117
116
  *
118
117
  * // Or disable casting for Int32s entirely (only JS numbers within 32-bit integer bounds and null-ish values are permitted)
119
- * mongoose.Schema.Int32.cast(false);
118
+ * mongoose.Schema.Types.Int32.cast(false);
120
119
  *
121
120
  *
122
121
  * @param {Function} caster
@@ -161,8 +160,8 @@ SchemaInt32.checkRequired = SchemaType.checkRequired;
161
160
  /**
162
161
  * Check if the given value satisfies a required validator.
163
162
  *
164
- * @param {Any} value
165
- * @return {Boolean}
163
+ * @param {any} value
164
+ * @return {boolean}
166
165
  * @api public
167
166
  */
168
167
 
@@ -173,8 +172,8 @@ SchemaInt32.prototype.checkRequired = function(value) {
173
172
  /**
174
173
  * Casts to Int32
175
174
  *
176
- * @param {Object} value
177
- * @param {Object} model this value is optional
175
+ * @param {object} value
176
+ * @param {object} model this value is optional
178
177
  * @api private
179
178
  */
180
179
 
@@ -237,7 +236,7 @@ function handleSingle(val, context) {
237
236
  /**
238
237
  * Casts contents for queries.
239
238
  *
240
- * @param {String} $conditional
239
+ * @param {string} $conditional
241
240
  * @param {any} val
242
241
  * @api private
243
242
  */
@@ -267,14 +266,13 @@ SchemaInt32.prototype.castForQuery = function($conditional, val, context) {
267
266
  /**
268
267
  * Returns this schema type's representation in a JSON schema.
269
268
  *
270
- * @param [options]
271
- * @param [options.useBsonType=false] If true, return a representation with `bsonType` for use with MongoDB's `$jsonSchema`.
272
- * @returns {Object} JSON schema properties
269
+ * @param {object} [options]
270
+ * @param {boolean} [options.useBsonType=false] If true, return a representation with `bsonType` for use with MongoDB's `$jsonSchema`.
271
+ * @returns {object} JSON schema properties
273
272
  */
274
273
 
275
274
  SchemaInt32.prototype.toJSONSchema = function toJSONSchema(options) {
276
- const isRequired = this.options.required && typeof this.options.required !== 'function';
277
- return createJSONSchemaTypeDefinition('number', 'int', options?.useBsonType, isRequired);
275
+ return this._createJSONSchemaTypeDefinition('number', 'int', options);
278
276
  };
279
277
 
280
278
  SchemaInt32.prototype.autoEncryptionType = function autoEncryptionType() {
@@ -7,7 +7,6 @@
7
7
  const MongooseMap = require('../types/map');
8
8
  const SchemaMapOptions = require('../options/schemaMapOptions');
9
9
  const SchemaType = require('../schemaType');
10
- const createJSONSchemaTypeDefinition = require('../helpers/createJSONSchemaTypeDefinition');
11
10
  const MongooseError = require('../error/mongooseError');
12
11
  const Schema = require('../schema');
13
12
  const utils = require('../utils');
@@ -16,9 +15,9 @@ class SchemaMap extends SchemaType {
16
15
  /**
17
16
  * Map SchemaType constructor.
18
17
  *
19
- * @param {String} path
20
- * @param {Object} options
21
- * @param {Object} schemaOptions
18
+ * @param {string} path
19
+ * @param {object} options
20
+ * @param {object} schemaOptions
22
21
  * @param {Schema} parentSchema
23
22
  * @inherits SchemaType
24
23
  * @api public
@@ -34,8 +33,8 @@ class SchemaMap extends SchemaType {
34
33
  /**
35
34
  * Sets a default option for all Map instances.
36
35
  *
37
- * @param {String} option The option you'd like to set the value for
38
- * @param {Any} value value for option
36
+ * @param {string} option The option you'd like to set the value for
37
+ * @param {any} value value for option
39
38
  * @return {undefined}
40
39
  * @function set
41
40
  * @api public
@@ -48,8 +47,8 @@ class SchemaMap extends SchemaType {
48
47
  /**
49
48
  * Casts to Map
50
49
  *
51
- * @param {Object} value
52
- * @param {Object} model this value is optional
50
+ * @param {object} value
51
+ * @param {object} model this value is optional
53
52
  * @api private
54
53
  */
55
54
 
@@ -58,14 +57,10 @@ class SchemaMap extends SchemaType {
58
57
  return val;
59
58
  }
60
59
 
61
- const path = this.path;
60
+ const path = options?.path ?? this.path;
62
61
 
63
62
  if (init) {
64
- const map = new MongooseMap({}, path, doc, this.$__schemaType, options);
65
-
66
- // Use the map's path for passing to nested casts.
67
- // If map's parent is a subdocument, use the relative path so nested casts get relative paths.
68
- const mapPath = map.$__pathRelativeToParent != null ? map.$__pathRelativeToParent : map.$__path;
63
+ const map = new MongooseMap({}, path, doc, this.$__schemaType);
69
64
 
70
65
  if (val instanceof global.Map) {
71
66
  for (const key of val.keys()) {
@@ -73,7 +68,7 @@ class SchemaMap extends SchemaType {
73
68
  if (_val == null) {
74
69
  _val = map.$__schemaType._castNullish(_val);
75
70
  } else {
76
- _val = map.$__schemaType.cast(_val, doc, true, null, { ...options, path: mapPath + '.' + key });
71
+ _val = map.$__schemaType.cast(_val, doc, true, null, { ...options, path: path + '.' + key });
77
72
  }
78
73
  map.$init(key, _val);
79
74
  }
@@ -83,7 +78,7 @@ class SchemaMap extends SchemaType {
83
78
  if (_val == null) {
84
79
  _val = map.$__schemaType._castNullish(_val);
85
80
  } else {
86
- _val = map.$__schemaType.cast(_val, doc, true, null, { ...options, path: mapPath + '.' + key });
81
+ _val = map.$__schemaType.cast(_val, doc, true, null, { ...options, path: path + '.' + key });
87
82
  }
88
83
  map.$init(key, _val);
89
84
  }
@@ -92,7 +87,7 @@ class SchemaMap extends SchemaType {
92
87
  return map;
93
88
  }
94
89
 
95
- return new MongooseMap(val, path, doc, this.$__schemaType, options);
90
+ return new MongooseMap(val, path, doc, this.$__schemaType);
96
91
  }
97
92
 
98
93
  /**
@@ -123,17 +118,15 @@ class SchemaMap extends SchemaType {
123
118
  /**
124
119
  * Returns this schema type's representation in a JSON schema.
125
120
  *
126
- * @param [options]
127
- * @param [options.useBsonType=false] If true, return a representation with `bsonType` for use with MongoDB's `$jsonSchema`.
128
- * @returns {Object} JSON schema properties
121
+ * @param {object} [options]
122
+ * @param {boolean} [options.useBsonType=false] If true, return a representation with `bsonType` for use with MongoDB's `$jsonSchema`.
123
+ * @returns {object} JSON schema properties
129
124
  */
130
125
 
131
126
  toJSONSchema(options) {
132
- const useBsonType = options?.useBsonType;
133
127
  const embeddedSchemaType = this.getEmbeddedSchemaType();
134
128
 
135
- const isRequired = this.options.required && typeof this.options.required !== 'function';
136
- const result = createJSONSchemaTypeDefinition('object', 'object', useBsonType, isRequired);
129
+ const result = this._createJSONSchemaTypeDefinition('object', 'object', options);
137
130
  result.additionalProperties = embeddedSchemaType.toJSONSchema(options);
138
131
 
139
132
  return result;
@@ -172,7 +165,7 @@ SchemaMap.prototype._createNestedSchemaType = function _createNestedSchemaType(s
172
165
  let _mapType = { type: {} };
173
166
  if (utils.hasUserDefinedProperty(obj, 'of')) {
174
167
  const isInlineSchema = utils.isPOJO(obj.of) &&
175
- Object.keys(obj.of).length > 0 &&
168
+ utils.hasOwnKeys(obj.of) &&
176
169
  !utils.hasUserDefinedProperty(obj.of, schema.options.typeKey);
177
170
  if (isInlineSchema) {
178
171
  _mapType = { [schema.options.typeKey]: new Schema(obj.of) };
@@ -12,21 +12,21 @@ const utils = require('../utils');
12
12
  /**
13
13
  * Mixed SchemaType constructor.
14
14
  *
15
- * @param {String} path
16
- * @param {Object} options
17
- * @param {Object} _schemaOptions
15
+ * @param {string} path
16
+ * @param {object} options
17
+ * @param {object} _schemaOptions
18
18
  * @param {Schema} parentSchema
19
19
  * @inherits SchemaType
20
20
  * @api public
21
21
  */
22
22
 
23
23
  function SchemaMixed(path, options, _schemaOptions, parentSchema) {
24
- if (options && options.default) {
24
+ if (options?.default) {
25
25
  const def = options.default;
26
26
  if (Array.isArray(def) && def.length === 0) {
27
27
  // make sure empty array defaults are handled
28
28
  options.default = Array;
29
- } else if (!options.shared && isObject(def) && Object.keys(def).length === 0) {
29
+ } else if (!options.shared && isObject(def) && utils.hasOwnKeys(def) === false) {
30
30
  // prevent odd "shared" objects between documents
31
31
  options.default = function() {
32
32
  return {};
@@ -61,7 +61,7 @@ SchemaMixed.prototype.constructor = SchemaMixed;
61
61
  * #### Example:
62
62
  *
63
63
  * // Hide the 'hidden' path
64
- * mongoose.Schema.Mixed.get(v => Object.assign({}, v, { hidden: null }));
64
+ * mongoose.Schema.Types.Mixed.get(v => Object.assign({}, v, { hidden: null }));
65
65
  *
66
66
  * const Model = mongoose.model('Test', new Schema({ test: {} }));
67
67
  * new Model({ test: { hidden: 'Secret!' } }).test.hidden; // null
@@ -81,13 +81,13 @@ SchemaMixed.get = SchemaType.get;
81
81
  * #### Example:
82
82
  *
83
83
  * // Make all mixed instances have `required` of true by default.
84
- * mongoose.Schema.Mixed.set('required', true);
84
+ * mongoose.Schema.Types.Mixed.set('required', true);
85
85
  *
86
86
  * const User = mongoose.model('User', new Schema({ test: mongoose.Mixed }));
87
87
  * new User({ }).validateSync().errors.test.message; // Path `test` is required.
88
88
  *
89
- * @param {String} option The option you'd like to set the value for
90
- * @param {Any} value value for option
89
+ * @param {string} option The option you'd like to set the value for
90
+ * @param {any} value value for option
91
91
  * @return {undefined}
92
92
  * @function set
93
93
  * @static
@@ -103,7 +103,7 @@ SchemaMixed.setters = [];
103
103
  *
104
104
  * _this is a no-op_
105
105
  *
106
- * @param {Object} value to cast
106
+ * @param {object} value to cast
107
107
  * @api private
108
108
  */
109
109
 
@@ -117,7 +117,7 @@ SchemaMixed.prototype.cast = function(val) {
117
117
  /**
118
118
  * Casts contents for queries.
119
119
  *
120
- * @param {String} $cond
120
+ * @param {string} $cond
121
121
  * @param {any} [val]
122
122
  * @api private
123
123
  */
@@ -129,9 +129,9 @@ SchemaMixed.prototype.castForQuery = function($cond, val) {
129
129
  /**
130
130
  * Returns this schema type's representation in a JSON schema.
131
131
  *
132
- * @param [options]
133
- * @param [options.useBsonType=false] If true, return a representation with `bsonType` for use with MongoDB's `$jsonSchema`.
134
- * @returns {Object} JSON schema properties
132
+ * @param {object} [options]
133
+ * @param {boolean} [options.useBsonType=false] If true, return a representation with `bsonType` for use with MongoDB's `$jsonSchema`.
134
+ * @returns {object} JSON schema properties
135
135
  */
136
136
 
137
137
  // eslint-disable-next-line no-unused-vars
@@ -8,7 +8,6 @@ const MongooseError = require('../error/index');
8
8
  const SchemaNumberOptions = require('../options/schemaNumberOptions');
9
9
  const SchemaType = require('../schemaType');
10
10
  const castNumber = require('../cast/number');
11
- const createJSONSchemaTypeDefinition = require('../helpers/createJSONSchemaTypeDefinition');
12
11
  const handleBitwiseOperator = require('./operators/bitwise');
13
12
  const utils = require('../utils');
14
13
 
@@ -17,15 +16,16 @@ const CastError = SchemaType.CastError;
17
16
  /**
18
17
  * Number SchemaType constructor.
19
18
  *
20
- * @param {String} key
21
- * @param {Object} options
22
- * @param {Object} schemaOptions
19
+ * @param {string} key
20
+ * @param {object} options
21
+ * @param {object} schemaOptions
23
22
  * @param {Schema} parentSchema
24
23
  * @inherits SchemaType
25
24
  * @api public
26
25
  */
27
26
 
28
27
  function SchemaNumber(key, options, _schemaOptions, parentSchema) {
28
+ this.enumValues = [];
29
29
  SchemaType.call(this, key, options, 'Number', parentSchema);
30
30
  }
31
31
 
@@ -55,13 +55,13 @@ SchemaNumber.get = SchemaType.get;
55
55
  * #### Example:
56
56
  *
57
57
  * // Make all numbers have option `min` equal to 0.
58
- * mongoose.Schema.Number.set('min', 0);
58
+ * mongoose.Schema.Types.Number.set('min', 0);
59
59
  *
60
60
  * const Order = mongoose.model('Order', new Schema({ amount: Number }));
61
61
  * new Order({ amount: -10 }).validateSync().errors.amount.message; // Path `amount` must be larger than 0.
62
62
  *
63
- * @param {String} option The option you'd like to set the value for
64
- * @param {Any} value value for option
63
+ * @param {string} option The option you'd like to set the value for
64
+ * @param {any} value value for option
65
65
  * @return {undefined}
66
66
  * @function set
67
67
  * @static
@@ -162,9 +162,9 @@ SchemaNumber.checkRequired = SchemaType.checkRequired;
162
162
  /**
163
163
  * Check if the given value satisfies a required validator.
164
164
  *
165
- * @param {Any} value
165
+ * @param {any} value
166
166
  * @param {Document} doc
167
- * @return {Boolean}
167
+ * @return {boolean}
168
168
  * @api public
169
169
  */
170
170
 
@@ -206,8 +206,8 @@ SchemaNumber.prototype.checkRequired = function checkRequired(value, doc) {
206
206
  * console.log(String(err)) // ValidationError: The value of path `n` (4) is beneath the limit (10).
207
207
  * })
208
208
  *
209
- * @param {Number} value minimum number
210
- * @param {String} [message] optional custom error message
209
+ * @param {number} value minimum number
210
+ * @param {string} [message] optional custom error message
211
211
  * @return {SchemaType} this
212
212
  * @see Customized Error Messages https://mongoosejs.com/docs/api/error.html#Error.messages
213
213
  * @api public
@@ -220,7 +220,7 @@ SchemaNumber.prototype.min = function(value, message) {
220
220
  }, this);
221
221
  }
222
222
 
223
- if (value !== null && value !== undefined) {
223
+ if (value != null) {
224
224
  let msg = message || MongooseError.messages.Number.min;
225
225
  msg = msg.replace(/{MIN}/, value);
226
226
  this.validators.push({
@@ -260,8 +260,8 @@ SchemaNumber.prototype.min = function(value, message) {
260
260
  * console.log(String(err)) // ValidationError: The value of path `n` (4) exceeds the limit (10).
261
261
  * })
262
262
  *
263
- * @param {Number} maximum number
264
- * @param {String} [message] optional custom error message
263
+ * @param {number} maximum number
264
+ * @param {string} [message] optional custom error message
265
265
  * @return {SchemaType} this
266
266
  * @see Customized Error Messages https://mongoosejs.com/docs/api/error.html#Error.messages
267
267
  * @api public
@@ -274,7 +274,7 @@ SchemaNumber.prototype.max = function(value, message) {
274
274
  }, this);
275
275
  }
276
276
 
277
- if (value !== null && value !== undefined) {
277
+ if (value != null) {
278
278
  let msg = message || MongooseError.messages.Number.max;
279
279
  msg = msg.replace(/{MAX}/, value);
280
280
  this.validators.push({
@@ -305,7 +305,7 @@ SchemaNumber.prototype.max = function(value, message) {
305
305
  * await m.save(); // succeeds
306
306
  *
307
307
  * @param {Array} values allowed values
308
- * @param {String} [message] optional custom error message
308
+ * @param {string} [message] optional custom error message
309
309
  * @return {SchemaType} this
310
310
  * @see Customized Error Messages https://mongoosejs.com/docs/api/error.html#Error.messages
311
311
  * @api public
@@ -316,8 +316,12 @@ SchemaNumber.prototype.enum = function(values, message) {
316
316
  this.validators = this.validators.filter(function(v) {
317
317
  return v.validator !== this.enumValidator;
318
318
  }, this);
319
+ this.enumValidator = false;
319
320
  }
320
321
 
322
+ if (values === void 0 || values === false) {
323
+ return this;
324
+ }
321
325
 
322
326
  if (!Array.isArray(values)) {
323
327
  const isObjectSyntax = utils.isPOJO(values) && values.values != null;
@@ -355,12 +359,19 @@ SchemaNumber.prototype.enum = function(values, message) {
355
359
 
356
360
  message = message == null ? MongooseError.messages.Number.enum : message;
357
361
 
358
- this.enumValidator = v => v == null || values.indexOf(v) !== -1;
362
+ for (const value of values) {
363
+ if (value !== undefined) {
364
+ this.enumValues.push(this.cast(value));
365
+ }
366
+ }
367
+
368
+ const vals = this.enumValues;
369
+ this.enumValidator = v => v == null || vals.indexOf(v) !== -1;
359
370
  this.validators.push({
360
371
  validator: this.enumValidator,
361
372
  message: message,
362
373
  type: 'enum',
363
- enumValues: values
374
+ enumValues: vals
364
375
  });
365
376
 
366
377
  return this;
@@ -369,9 +380,9 @@ SchemaNumber.prototype.enum = function(values, message) {
369
380
  /**
370
381
  * Casts to number
371
382
  *
372
- * @param {Object} value value to cast
383
+ * @param {object} value value to cast
373
384
  * @param {Document} doc document that triggers the casting
374
- * @param {Boolean} init
385
+ * @param {boolean} init
375
386
  * @api private
376
387
  */
377
388
 
@@ -382,7 +393,7 @@ SchemaNumber.prototype.cast = function(value, doc, init, prev, options) {
382
393
  }
383
394
  }
384
395
 
385
- const val = value && typeof value._id !== 'undefined' ?
396
+ const val = value?._id !== undefined ?
386
397
  value._id : // documents
387
398
  value;
388
399
 
@@ -451,7 +462,7 @@ Object.defineProperty(SchemaNumber.prototype, '$conditionalHandlers', {
451
462
  /**
452
463
  * Casts contents for queries.
453
464
  *
454
- * @param {String} $conditional
465
+ * @param {string} $conditional
455
466
  * @param {any} [value]
456
467
  * @api private
457
468
  */
@@ -461,7 +472,7 @@ SchemaNumber.prototype.castForQuery = function($conditional, val, context) {
461
472
  if ($conditional != null) {
462
473
  handler = this.$conditionalHandlers[$conditional];
463
474
  if (!handler) {
464
- throw new CastError('number', val, this.path, null, this);
475
+ throw new MongooseError('Can\'t use ' + $conditional + ' with Number.');
465
476
  }
466
477
  return handler.call(this, val, context);
467
478
  }
@@ -481,14 +492,13 @@ SchemaNumber.prototype.castForQuery = function($conditional, val, context) {
481
492
  /**
482
493
  * Returns this schema type's representation in a JSON schema.
483
494
  *
484
- * @param [options]
485
- * @param [options.useBsonType=false] If true, return a representation with `bsonType` for use with MongoDB's `$jsonSchema`.
486
- * @returns {Object} JSON schema properties
495
+ * @param {object} [options]
496
+ * @param {boolean} [options.useBsonType=false] If true, return a representation with `bsonType` for use with MongoDB's `$jsonSchema`.
497
+ * @returns {object} JSON schema properties
487
498
  */
488
499
 
489
500
  SchemaNumber.prototype.toJSONSchema = function toJSONSchema(options) {
490
- const isRequired = (this.options.required && typeof this.options.required !== 'function') || this.path === '_id';
491
- return createJSONSchemaTypeDefinition('number', 'number', options?.useBsonType, isRequired);
501
+ return this._createJSONSchemaTypeDefinition('number', 'number', options);
492
502
  };
493
503
 
494
504
  /*!
@@ -7,7 +7,6 @@
7
7
  const SchemaObjectIdOptions = require('../options/schemaObjectIdOptions');
8
8
  const SchemaType = require('../schemaType');
9
9
  const castObjectId = require('../cast/objectid');
10
- const createJSONSchemaTypeDefinition = require('../helpers/createJSONSchemaTypeDefinition');
11
10
  const getConstructorName = require('../helpers/getConstructorName');
12
11
  const oid = require('../types/objectid');
13
12
  const isBsonType = require('../helpers/isBsonType');
@@ -19,9 +18,9 @@ let Document;
19
18
  /**
20
19
  * ObjectId SchemaType constructor.
21
20
  *
22
- * @param {String} key
23
- * @param {Object} options
24
- * @param {Object} schemaOptions
21
+ * @param {string} key
22
+ * @param {object} options
23
+ * @param {object} schemaOptions
25
24
  * @param {Schema} parentSchema
26
25
  * @inherits SchemaType
27
26
  * @api public
@@ -29,11 +28,11 @@ let Document;
29
28
 
30
29
  function SchemaObjectId(key, options, _schemaOptions, parentSchema) {
31
30
  const isKeyHexStr = typeof key === 'string' && key.length === 24 && /^[a-f0-9]+$/i.test(key);
32
- const suppressWarning = options && options.suppressWarning;
31
+ const suppressWarning = options?.suppressWarning;
33
32
  if ((isKeyHexStr || typeof key === 'undefined') && !suppressWarning) {
34
33
  utils.warn('mongoose: To create a new ObjectId please try ' +
35
34
  '`Mongoose.Types.ObjectId` instead of using ' +
36
- '`Mongoose.Schema.ObjectId`. Set the `suppressWarning` option if ' +
35
+ '`Mongoose.Schema.Types.ObjectId`. Set the `suppressWarning` option if ' +
37
36
  'you\'re trying to create a hex char path in your schema.');
38
37
  }
39
38
  SchemaType.call(this, key, options, 'ObjectId', parentSchema);
@@ -82,13 +81,13 @@ SchemaObjectId.get = SchemaType.get;
82
81
  * #### Example:
83
82
  *
84
83
  * // Make all object ids have option `required` equal to true.
85
- * mongoose.Schema.ObjectId.set('required', true);
84
+ * mongoose.Schema.Types.ObjectId.set('required', true);
86
85
  *
87
86
  * const Order = mongoose.model('Order', new Schema({ userId: ObjectId }));
88
87
  * new Order({ }).validateSync().errors.userId.message; // Path `userId` is required.
89
88
  *
90
- * @param {String} option The option you'd like to set the value for
91
- * @param {Any} value value for option
89
+ * @param {string} option The option you'd like to set the value for
90
+ * @param {any} value value for option
92
91
  * @return {undefined}
93
92
  * @function set
94
93
  * @static
@@ -101,7 +100,7 @@ SchemaObjectId.setters = [];
101
100
 
102
101
  /**
103
102
  * Adds an auto-generated ObjectId default if turnOn is true.
104
- * @param {Boolean} turnOn auto generated ObjectId defaults
103
+ * @param {boolean} turnOn auto generated ObjectId defaults
105
104
  * @api public
106
105
  * @return {SchemaType} this
107
106
  */
@@ -197,9 +196,9 @@ SchemaObjectId.checkRequired = SchemaType.checkRequired;
197
196
  /**
198
197
  * Check if the given value satisfies a required validator.
199
198
  *
200
- * @param {Any} value
199
+ * @param {any} value
201
200
  * @param {Document} doc
202
- * @return {Boolean}
201
+ * @return {boolean}
203
202
  * @api public
204
203
  */
205
204
 
@@ -220,9 +219,9 @@ SchemaObjectId.prototype.checkRequired = function checkRequired(value, doc) {
220
219
  /**
221
220
  * Casts to ObjectId
222
221
  *
223
- * @param {Object} value
224
- * @param {Object} doc
225
- * @param {Boolean} init whether this is an initialization cast
222
+ * @param {object} value
223
+ * @param {object} doc
224
+ * @param {boolean} init whether this is an initialization cast
226
225
  * @api private
227
226
  */
228
227
 
@@ -311,15 +310,14 @@ function resetId(v) {
311
310
  /**
312
311
  * Returns this schema type's representation in a JSON schema.
313
312
  *
314
- * @param [options]
315
- * @param [options.useBsonType=false] If true, return a representation with `bsonType` for use with MongoDB's `$jsonSchema`.
316
- * @returns {Object} JSON schema properties
313
+ * @param {object} [options]
314
+ * @param {boolean} [options.useBsonType=false] If true, return a representation with `bsonType` for use with MongoDB's `$jsonSchema`.
315
+ * @returns {object} JSON schema properties
317
316
  * @api public
318
317
  */
319
318
 
320
319
  SchemaObjectId.prototype.toJSONSchema = function toJSONSchema(options) {
321
- const isRequired = (this.options.required && typeof this.options.required !== 'function') || this.path === '_id';
322
- return createJSONSchemaTypeDefinition('string', 'objectId', options?.useBsonType, isRequired);
320
+ return this._createJSONSchemaTypeDefinition('string', 'objectId', options);
323
321
  };
324
322
 
325
323
  SchemaObjectId.prototype.autoEncryptionType = function autoEncryptionType() {
@@ -7,6 +7,6 @@ const castBoolean = require('../../cast/boolean');
7
7
  */
8
8
 
9
9
  module.exports = function(val) {
10
- const path = this != null ? this.path : null;
10
+ const path = this?.path ?? null;
11
11
  return castBoolean(val, path);
12
12
  };
@@ -25,7 +25,7 @@ function cast$near(val) {
25
25
 
26
26
  _castMinMaxDistance(this, val);
27
27
 
28
- if (val && val.$geometry) {
28
+ if (val?.$geometry) {
29
29
  return cast$geometry(val, this);
30
30
  }
31
31
 
@@ -8,9 +8,9 @@ const castString = require('../../cast/string');
8
8
  * Casts val to an object suitable for `$text`. Throws an error if the object
9
9
  * can't be casted.
10
10
  *
11
- * @param {Any} val value to cast
12
- * @param {String} [path] path to associate with any errors that occured
13
- * @return {Object} casted object
11
+ * @param {any} val value to cast
12
+ * @param {string} [path] path to associate with any errors that occurred
13
+ * @return {object} casted object
14
14
  * @see https://www.mongodb.com/docs/manual/reference/operator/query/text/
15
15
  * @api private
16
16
  */
@@ -28,7 +28,7 @@ module.exports = function castTextSearch(val, path) {
28
28
  }
29
29
  if (val.$caseSensitive != null) {
30
30
  val.$caseSensitive = castBoolean(val.$caseSensitive,
31
- path + '.$castSensitive');
31
+ path + '.$caseSensitive');
32
32
  }
33
33
  if (val.$diacriticSensitive != null) {
34
34
  val.$diacriticSensitive = castBoolean(val.$diacriticSensitive,