@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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mongodb-connection-string-url",
3
- "version": "3.0.2",
3
+ "version": "7.0.1",
4
4
  "description": "MongoDB connection strings, based on the WhatWG URL API",
5
5
  "keywords": [
6
6
  "password",
@@ -16,9 +16,16 @@
16
16
  "url": "https://github.com/mongodb-js/mongodb-connection-string-url/issues"
17
17
  },
18
18
  "main": "lib/index.js",
19
+ "types": "lib/index.d.ts",
19
20
  "exports": {
20
- "require": "./lib/index.js",
21
- "import": "./.esm-wrapper.mjs"
21
+ "require": {
22
+ "default": "./lib/index.js",
23
+ "types": "./lib/index.d.ts"
24
+ },
25
+ "import": {
26
+ "default": "./.esm-wrapper.mjs",
27
+ "types": "./lib/index.d.ts"
28
+ }
22
29
  },
23
30
  "files": [
24
31
  "LICENSE",
@@ -28,8 +35,8 @@
28
35
  ".esm-wrapper.mjs"
29
36
  ],
30
37
  "scripts": {
31
- "lint": "eslint \"{src,test}/**/*.ts\"",
32
- "test": "npm run lint && npm run build && nyc mocha --colors -r ts-node/register test/*.ts",
38
+ "lint": "ESLINT_USE_FLAT_CONFIG=false eslint \"{src,test}/**/*.ts\"",
39
+ "test": "npm run build && nyc mocha --colors -r ts-node/register test/*.ts",
33
40
  "build": "npm run compile-ts && gen-esm-wrapper . ./.esm-wrapper.mjs",
34
41
  "prepack": "npm run build",
35
42
  "compile-ts": "tsc -p tsconfig.json"
@@ -37,26 +44,28 @@
37
44
  "license": "Apache-2.0",
38
45
  "devDependencies": {
39
46
  "@types/chai": "^5.0.1",
40
- "@types/mocha": "^8.0.3",
47
+ "@types/mocha": "^10.0.10",
41
48
  "@types/node": "^22.9.0",
42
- "@typescript-eslint/eslint-plugin": "^4.2.0",
43
- "@typescript-eslint/parser": "^4.2.0",
49
+ "@typescript-eslint/eslint-plugin": "^8.39.1",
50
+ "@typescript-eslint/parser": "^8.39.1",
44
51
  "chai": "^4.2.0",
45
- "eslint": "^7.9.0",
46
- "eslint-config-semistandard": "^15.0.1",
47
- "eslint-config-standard": "^14.1.1",
52
+ "eslint": "^9.33.0",
53
+ "eslint-config-prettier": "^10.1.8",
48
54
  "eslint-plugin-import": "^2.22.0",
49
55
  "eslint-plugin-node": "^11.1.0",
56
+ "eslint-plugin-prettier": "^5.5.4",
50
57
  "eslint-plugin-promise": "^7.1.0",
51
- "eslint-plugin-standard": "^5.0.0",
52
58
  "gen-esm-wrapper": "^1.1.3",
53
59
  "mocha": "^11.0.1",
54
- "nyc": "^15.1.0",
60
+ "nyc": "^17.1.0",
55
61
  "ts-node": "^10.9.1",
56
- "typescript": "^4.7.4"
62
+ "typescript": "^5.9.2"
57
63
  },
58
64
  "dependencies": {
59
- "@types/whatwg-url": "^11.0.2",
60
- "whatwg-url": "^14.1.0 || ^13.0.0"
65
+ "@types/whatwg-url": "^13.0.0",
66
+ "whatwg-url": "^14.1.0"
67
+ },
68
+ "engines": {
69
+ "node": ">=20.19.0"
61
70
  }
62
71
  }
@@ -11,6 +11,7 @@ const { applyGlobalMaxTimeMS, applyGlobalDiskUse } = require('./helpers/query/ap
11
11
  const clone = require('./helpers/clone');
12
12
  const getConstructorName = require('./helpers/getConstructorName');
13
13
  const prepareDiscriminatorPipeline = require('./helpers/aggregate/prepareDiscriminatorPipeline');
14
+ const { buildMiddlewareFilter } = require('./helpers/buildMiddlewareFilter');
14
15
  const stringifyFunctionOperators = require('./helpers/aggregate/stringifyFunctionOperators');
15
16
  const utils = require('./utils');
16
17
  const { modelSymbol } = require('./helpers/symbols');
@@ -45,7 +46,7 @@ const validRedactStringValues = new Set(['$$DESCEND', '$$PRUNE', '$$KEEP']);
45
46
  * new Aggregate([{ $match: { _id: new mongoose.Types.ObjectId('00000000000000000000000a') } }]);
46
47
  *
47
48
  * @see MongoDB https://www.mongodb.com/docs/manual/applications/aggregation/
48
- * @see driver https://mongodb.github.io/node-mongodb-native/4.9/classes/Collection.html#aggregate
49
+ * @see driver https://mongodb.github.io/node-mongodb-native/7.0/classes/Collection.html#aggregate
49
50
  * @param {Array} [pipeline] aggregation pipeline as an array of objects
50
51
  * @param {Model|Connection} [modelOrConn] the model or connection to use with this aggregate.
51
52
  * @api public
@@ -158,7 +159,7 @@ Aggregate.prototype.model = function(model) {
158
159
  * const pipeline = [{ $match: { daw: 'Logic Audio X' }} ];
159
160
  * aggregate.append(pipeline);
160
161
  *
161
- * @param {...Object|Object[]} ops operator(s) to append. Can either be a spread of objects or a single parameter of a object array.
162
+ * @param {...object|object[]} ops operator(s) to append. Can either be a spread of objects or a single parameter of an object array.
162
163
  * @return {Aggregate}
163
164
  * @api public
164
165
  */
@@ -169,7 +170,7 @@ Aggregate.prototype.append = function() {
169
170
  : [...arguments];
170
171
 
171
172
  if (!args.every(isOperator)) {
172
- throw new Error('Arguments must be aggregate pipeline operators');
173
+ throw new MongooseError('Arguments must be aggregate pipeline operators');
173
174
  }
174
175
 
175
176
  this._pipeline = this._pipeline.concat(args);
@@ -195,14 +196,14 @@ Aggregate.prototype.append = function() {
195
196
  * // etc
196
197
  * aggregate.addFields({ salary_k: { $divide: [ "$salary", 1000 ] } });
197
198
  *
198
- * @param {Object} arg field specification
199
+ * @param {object} arg field specification
199
200
  * @see $addFields https://www.mongodb.com/docs/manual/reference/operator/aggregation/addFields/
200
201
  * @return {Aggregate}
201
202
  * @api public
202
203
  */
203
204
  Aggregate.prototype.addFields = function(arg) {
204
205
  if (typeof arg !== 'object' || arg === null || Array.isArray(arg)) {
205
- throw new Error('Invalid addFields() argument. Must be an object');
206
+ throw new MongooseError('Invalid addFields() argument. Must be an object');
206
207
  }
207
208
  return this.append({ $addFields: Object.assign({}, arg) });
208
209
  };
@@ -233,7 +234,7 @@ Aggregate.prototype.addFields = function(arg) {
233
234
  * // etc
234
235
  * aggregate.project({ salary_k: { $divide: [ "$salary", 1000 ] } });
235
236
  *
236
- * @param {Object|String} arg field specification
237
+ * @param {object|string} arg field specification
237
238
  * @see projection https://www.mongodb.com/docs/manual/reference/aggregation/project/
238
239
  * @return {Aggregate}
239
240
  * @api public
@@ -258,7 +259,7 @@ Aggregate.prototype.project = function(arg) {
258
259
  fields[field] = include;
259
260
  });
260
261
  } else {
261
- throw new Error('Invalid project() argument. Must be string or object');
262
+ throw new MongooseError('Invalid project() argument. Must be string or object');
262
263
  }
263
264
 
264
265
  return this.append({ $project: fields });
@@ -275,7 +276,7 @@ Aggregate.prototype.project = function(arg) {
275
276
  * @method group
276
277
  * @memberOf Aggregate
277
278
  * @instance
278
- * @param {Object} arg $group operator contents
279
+ * @param {object} arg $group operator contents
279
280
  * @return {Aggregate}
280
281
  * @api public
281
282
  */
@@ -291,7 +292,7 @@ Aggregate.prototype.project = function(arg) {
291
292
  * @method match
292
293
  * @memberOf Aggregate
293
294
  * @instance
294
- * @param {Object} arg $match operator contents
295
+ * @param {object} arg $match operator contents
295
296
  * @return {Aggregate}
296
297
  * @api public
297
298
  */
@@ -307,7 +308,7 @@ Aggregate.prototype.project = function(arg) {
307
308
  * @method skip
308
309
  * @memberOf Aggregate
309
310
  * @instance
310
- * @param {Number} num number of records to skip before next stage
311
+ * @param {number} num number of records to skip before next stage
311
312
  * @return {Aggregate}
312
313
  * @api public
313
314
  */
@@ -323,7 +324,7 @@ Aggregate.prototype.project = function(arg) {
323
324
  * @method limit
324
325
  * @memberOf Aggregate
325
326
  * @instance
326
- * @param {Number} num maximum number of records to pass to the next stage
327
+ * @param {number} num maximum number of records to pass to the next stage
327
328
  * @return {Aggregate}
328
329
  * @api public
329
330
  */
@@ -347,7 +348,7 @@ Aggregate.prototype.project = function(arg) {
347
348
  * @method densify
348
349
  * @memberOf Aggregate
349
350
  * @instance
350
- * @param {Object} arg $densify operator contents
351
+ * @param {object} arg $densify operator contents
351
352
  * @return {Aggregate}
352
353
  * @api public
353
354
  */
@@ -369,7 +370,7 @@ Aggregate.prototype.project = function(arg) {
369
370
  * @method fill
370
371
  * @memberOf Aggregate
371
372
  * @instance
372
- * @param {Object} arg $fill operator contents
373
+ * @param {object} arg $fill operator contents
373
374
  * @return {Aggregate}
374
375
  * @api public
375
376
  */
@@ -396,8 +397,8 @@ Aggregate.prototype.project = function(arg) {
396
397
  * @method near
397
398
  * @memberOf Aggregate
398
399
  * @instance
399
- * @param {Object} arg
400
- * @param {Object|Array<Number>} arg.near GeoJSON point or coordinates array
400
+ * @param {object} arg
401
+ * @param {object|number[]} arg.near GeoJSON point or coordinates array
401
402
  * @return {Aggregate}
402
403
  * @api public
403
404
  */
@@ -444,7 +445,7 @@ Aggregate.prototype.near = function(arg) {
444
445
  * aggregate.unwind({ path: '$tags', preserveNullAndEmptyArrays: true });
445
446
  *
446
447
  * @see $unwind https://www.mongodb.com/docs/manual/reference/aggregation/unwind/
447
- * @param {String|Object|String[]|Object[]} fields the field(s) to unwind, either as field names or as [objects with options](https://www.mongodb.com/docs/manual/reference/operator/aggregation/unwind/#document-operand-with-options). If passing a string, prefixing the field name with '$' is optional. If passing an object, `path` must start with '$'.
448
+ * @param {string|object|string[]|object[]} fields the field(s) to unwind, either as field names or as [objects with options](https://www.mongodb.com/docs/manual/reference/operator/aggregation/unwind/#document-operand-with-options). If passing a string, prefixing the field name with '$' is optional. If passing an object, `path` must start with '$'.
448
449
  * @return {Aggregate}
449
450
  * @api public
450
451
  */
@@ -461,7 +462,7 @@ Aggregate.prototype.unwind = function() {
461
462
  $unwind: (arg[0] === '$') ? arg : '$' + arg
462
463
  });
463
464
  } else {
464
- throw new Error('Invalid arg "' + arg + '" to unwind(), ' +
465
+ throw new MongooseError('Invalid arg "' + arg + '" to unwind(), ' +
465
466
  'must be string or object');
466
467
  }
467
468
  }
@@ -483,7 +484,7 @@ Aggregate.prototype.unwind = function() {
483
484
  * aggregate.replaceRoot({ x: { $concat: ['$this', '$that'] } });
484
485
  *
485
486
  * @see $replaceRoot https://www.mongodb.com/docs/manual/reference/operator/aggregation/replaceRoot
486
- * @param {String|Object} newRoot the field or document which will become the new root document
487
+ * @param {string|object} newRoot the field or document which will become the new root document
487
488
  * @return {Aggregate}
488
489
  * @api public
489
490
  */
@@ -512,7 +513,7 @@ Aggregate.prototype.replaceRoot = function(newRoot) {
512
513
  * aggregate.count("userCount");
513
514
  *
514
515
  * @see $count https://www.mongodb.com/docs/manual/reference/operator/aggregation/count
515
- * @param {String} fieldName The name of the output field which has the count as its value. It must be a non-empty string, must not start with $ and must not contain the . character.
516
+ * @param {string} fieldName The name of the output field which has the count as its value. It must be a non-empty string, must not start with $ and must not contain the . character.
516
517
  * @return {Aggregate}
517
518
  * @api public
518
519
  */
@@ -534,7 +535,7 @@ Aggregate.prototype.count = function(fieldName) {
534
535
  * aggregate.sortByCount({ $mergeObjects: [ "$employee", "$business" ] })
535
536
  *
536
537
  * @see $sortByCount https://www.mongodb.com/docs/manual/reference/operator/aggregation/sortByCount/
537
- * @param {Object|String} arg
538
+ * @param {object|string} arg
538
539
  * @return {Aggregate} this
539
540
  * @api public
540
541
  */
@@ -560,7 +561,7 @@ Aggregate.prototype.sortByCount = function(arg) {
560
561
  * aggregate.lookup({ from: 'users', localField: 'userId', foreignField: '_id', as: 'users' });
561
562
  *
562
563
  * @see $lookup https://www.mongodb.com/docs/manual/reference/operator/aggregation/lookup/#pipe._S_lookup
563
- * @param {Object} options to $lookup as described in the above link
564
+ * @param {object} options to $lookup as described in the above link
564
565
  * @return {Aggregate}
565
566
  * @api public
566
567
  */
@@ -580,7 +581,7 @@ Aggregate.prototype.lookup = function(options) {
580
581
  * aggregate.graphLookup({ from: 'courses', startWith: '$prerequisite', connectFromField: 'prerequisite', connectToField: 'name', as: 'prerequisites', maxDepth: 3 }) // this will recursively search the 'courses' collection up to 3 prerequisites
581
582
  *
582
583
  * @see $graphLookup https://www.mongodb.com/docs/manual/reference/operator/aggregation/graphLookup/#pipe._S_graphLookup
583
- * @param {Object} options to $graphLookup as described in the above link
584
+ * @param {object} options to $graphLookup as described in the above link
584
585
  * @return {Aggregate}
585
586
  * @api public
586
587
  */
@@ -613,7 +614,7 @@ Aggregate.prototype.graphLookup = function(options) {
613
614
  * aggregate.sample(3); // Add a pipeline that picks 3 random documents
614
615
  *
615
616
  * @see $sample https://www.mongodb.com/docs/manual/reference/operator/aggregation/sample/#pipe._S_sample
616
- * @param {Number} size number of random documents to pick
617
+ * @param {number} size number of random documents to pick
617
618
  * @return {Aggregate}
618
619
  * @api public
619
620
  */
@@ -636,7 +637,7 @@ Aggregate.prototype.sample = function(size) {
636
637
  * aggregate.sort('field -test');
637
638
  *
638
639
  * @see $sort https://www.mongodb.com/docs/manual/reference/aggregation/sort/
639
- * @param {Object|String} arg
640
+ * @param {object|string} arg
640
641
  * @return {Aggregate} this
641
642
  * @api public
642
643
  */
@@ -682,7 +683,7 @@ Aggregate.prototype.sort = function(arg) {
682
683
  * aggregate.unionWith({ coll: 'users', pipeline: [ { $match: { _id: 1 } } ] });
683
684
  *
684
685
  * @see $unionWith https://www.mongodb.com/docs/manual/reference/operator/aggregation/unionWith
685
- * @param {Object} options to $unionWith query as described in the above link
686
+ * @param {object} options to $unionWith query as described in the above link
686
687
  * @return {Aggregate}
687
688
  * @api public
688
689
  */
@@ -699,7 +700,7 @@ Aggregate.prototype.unionWith = function(options) {
699
700
  *
700
701
  * await Model.aggregate(pipeline).read('primaryPreferred');
701
702
  *
702
- * @param {String|ReadPreference} pref one of the listed preference options or their aliases
703
+ * @param {string|ReadPreference} pref one of the listed preference options or their aliases
703
704
  * @param {Array} [tags] optional tags for this query.
704
705
  * @return {Aggregate} this
705
706
  * @api public
@@ -718,7 +719,7 @@ Aggregate.prototype.read = function(pref, tags) {
718
719
  *
719
720
  * await Model.aggregate(pipeline).readConcern('majority');
720
721
  *
721
- * @param {String} level one of the listed read concern level or their aliases
722
+ * @param {'local'|'available'|'majority'|'snapshot'|'linearizable'|'l'|'a'|'m'|'s'|'lz'} level one of the listed read concern level or their aliases
722
723
  * @see mongodb https://www.mongodb.com/docs/manual/reference/read-concern/
723
724
  * @return {Aggregate} this
724
725
  * @api public
@@ -748,9 +749,9 @@ Aggregate.prototype.readConcern = function(level) {
748
749
  * // $redact often comes with $cond operator, you can also use the following syntax provided by mongoose
749
750
  * await Model.aggregate(pipeline).redact({ $eq: [ '$level', 5 ] }, '$$PRUNE', '$$DESCEND');
750
751
  *
751
- * @param {Object} expression redact options or conditional expression
752
- * @param {String|Object} [thenExpr] true case for the condition
753
- * @param {String|Object} [elseExpr] false case for the condition
752
+ * @param {object} expression redact options or conditional expression
753
+ * @param {string|object} [thenExpr] true case for the condition
754
+ * @param {string|object} [elseExpr] false case for the condition
754
755
  * @return {Aggregate} this
755
756
  * @see $redact https://www.mongodb.com/docs/manual/reference/operator/aggregation/redact/
756
757
  * @api public
@@ -760,7 +761,7 @@ Aggregate.prototype.redact = function(expression, thenExpr, elseExpr) {
760
761
  if (arguments.length === 3) {
761
762
  if ((typeof thenExpr === 'string' && !validRedactStringValues.has(thenExpr)) ||
762
763
  (typeof elseExpr === 'string' && !validRedactStringValues.has(elseExpr))) {
763
- throw new Error('If thenExpr or elseExpr is string, it must be either $$DESCEND, $$PRUNE or $$KEEP');
764
+ throw new MongooseError('If thenExpr or elseExpr is string, it must be either $$DESCEND, $$PRUNE or $$KEEP');
764
765
  }
765
766
 
766
767
  expression = {
@@ -784,7 +785,7 @@ Aggregate.prototype.redact = function(expression, thenExpr, elseExpr) {
784
785
  *
785
786
  * Model.aggregate(..).explain()
786
787
  *
787
- * @param {String} [verbosity]
788
+ * @param {'queryPlanner'|'executionStats'|'allPlansExecution'} [verbosity]
788
789
  * @return {Promise}
789
790
  */
790
791
 
@@ -795,25 +796,25 @@ Aggregate.prototype.explain = async function explain(verbosity) {
795
796
  const model = this._model;
796
797
 
797
798
  if (!this._pipeline.length) {
798
- throw new Error('Aggregate has empty pipeline');
799
+ throw new MongooseError('Aggregate has empty pipeline');
799
800
  }
800
801
 
801
802
  prepareDiscriminatorPipeline(this._pipeline, this._model.schema);
802
803
 
803
- await new Promise((resolve, reject) => {
804
- model.hooks.execPre('aggregate', this, error => {
805
- if (error) {
806
- const _opts = { error: error };
807
- return model.hooks.execPost('aggregate', this, [null], _opts, error => {
808
- reject(error);
809
- });
810
- } else {
811
- resolve();
812
- }
813
- });
814
- });
804
+ const preFilter = buildMiddlewareFilter(this.options, 'pre');
805
+ const postFilter = buildMiddlewareFilter(this.options, 'post');
806
+
807
+ // Remove middleware option before passing to MongoDB
808
+ const options = this.options != null ? { ...this.options } : {};
809
+ delete options.middleware;
810
+
811
+ try {
812
+ await model.hooks.execPre('aggregate', this, [], { filter: preFilter });
813
+ } catch (error) {
814
+ return await model.hooks.execPost('aggregate', this, [null], { error, filter: postFilter });
815
+ }
815
816
 
816
- const cursor = model.collection.aggregate(this._pipeline, this.options);
817
+ const cursor = await model.collection.aggregate(this._pipeline, options);
817
818
 
818
819
  if (verbosity == null) {
819
820
  verbosity = true;
@@ -823,26 +824,10 @@ Aggregate.prototype.explain = async function explain(verbosity) {
823
824
  try {
824
825
  result = await cursor.explain(verbosity);
825
826
  } catch (error) {
826
- await new Promise((resolve, reject) => {
827
- const _opts = { error: error };
828
- model.hooks.execPost('aggregate', this, [null], _opts, error => {
829
- if (error) {
830
- return reject(error);
831
- }
832
- return resolve();
833
- });
834
- });
827
+ return await model.hooks.execPost('aggregate', this, [null], { error, filter: postFilter });
835
828
  }
836
829
 
837
- const _opts = { error: null };
838
- await new Promise((resolve, reject) => {
839
- model.hooks.execPost('aggregate', this, [result], _opts, error => {
840
- if (error) {
841
- return reject(error);
842
- }
843
- return resolve();
844
- });
845
- });
830
+ await model.hooks.execPost('aggregate', this, [result], { error: null, filter: postFilter });
846
831
 
847
832
  return result;
848
833
  };
@@ -854,7 +839,7 @@ Aggregate.prototype.explain = async function explain(verbosity) {
854
839
  *
855
840
  * await Model.aggregate([{ $match: { foo: 'bar' } }]).allowDiskUse(true);
856
841
  *
857
- * @param {Boolean} value Should tell server it can use hard drive to store data during aggregation.
842
+ * @param {boolean} value Should tell server it can use hard drive to store data during aggregation.
858
843
  * @return {Aggregate} this
859
844
  * @see mongodb https://www.mongodb.com/docs/manual/reference/command/aggregate/
860
845
  */
@@ -871,7 +856,7 @@ Aggregate.prototype.allowDiskUse = function(value) {
871
856
  *
872
857
  * Model.aggregate(..).hint({ qty: 1, category: 1 }).exec();
873
858
  *
874
- * @param {Object|String} value a hint object or the index name
859
+ * @param {object|string} value a hint object or the index name
875
860
  * @return {Aggregate} this
876
861
  * @see mongodb https://www.mongodb.com/docs/manual/reference/command/aggregate/
877
862
  */
@@ -911,11 +896,14 @@ Aggregate.prototype.session = function(session) {
911
896
  * const agg = Model.aggregate(..).option({ allowDiskUse: true }); // Set the `allowDiskUse` option
912
897
  * agg.options; // `{ allowDiskUse: true }`
913
898
  *
914
- * @param {Object} options keys to merge into current options
915
- * @param {Number} [options.maxTimeMS] number limits the time this aggregation will run, see [MongoDB docs on `maxTimeMS`](https://www.mongodb.com/docs/manual/reference/operator/meta/maxTimeMS/)
916
- * @param {Boolean} [options.allowDiskUse] boolean if true, the MongoDB server will use the hard drive to store data during this aggregation
917
- * @param {Object} [options.collation] object see [`Aggregate.prototype.collation()`](https://mongoosejs.com/docs/api/aggregate.html#Aggregate.prototype.collation())
899
+ * @param {object} options keys to merge into current options
900
+ * @param {number} [options.maxTimeMS] number limits the time this aggregation will run, see [MongoDB docs on `maxTimeMS`](https://www.mongodb.com/docs/manual/reference/operator/meta/maxTimeMS/)
901
+ * @param {boolean} [options.allowDiskUse] boolean if true, the MongoDB server will use the hard drive to store data during this aggregation
902
+ * @param {object} [options.collation] object see [`Aggregate.prototype.collation()`](https://mongoosejs.com/docs/api/aggregate.html#Aggregate.prototype.collation())
918
903
  * @param {ClientSession} [options.session] ClientSession see [`Aggregate.prototype.session()`](https://mongoosejs.com/docs/api/aggregate.html#Aggregate.prototype.session())
904
+ * @param {boolean|object} [options.middleware=true] set to `false` to skip all user-defined middleware
905
+ * @param {boolean} [options.middleware.pre=true] set to `false` to skip only pre hooks
906
+ * @param {boolean} [options.middleware.post=true] set to `false` to skip only post hooks
919
907
  * @see mongodb https://www.mongodb.com/docs/manual/reference/command/aggregate/
920
908
  * @return {Aggregate} this
921
909
  * @api public
@@ -940,12 +928,12 @@ Aggregate.prototype.option = function(value) {
940
928
  * // use doc
941
929
  * });
942
930
  *
943
- * @param {Object} options
944
- * @param {Number} [options.batchSize] set the cursor batch size
945
- * @param {Boolean} [options.useMongooseAggCursor] use experimental mongoose-specific aggregation cursor (for `eachAsync()` and other query cursor semantics)
931
+ * @param {object} options
932
+ * @param {number} [options.batchSize] set the cursor batch size
933
+ * @param {boolean} [options.useMongooseAggCursor] use experimental mongoose-specific aggregation cursor (for `eachAsync()` and other query cursor semantics)
946
934
  * @return {AggregationCursor} cursor representing this aggregation
947
935
  * @api public
948
- * @see mongodb https://mongodb.github.io/node-mongodb-native/4.9/classes/AggregationCursor.html
936
+ * @see mongodb https://mongodb.github.io/node-mongodb-native/7.0/classes/AggregationCursor.html
949
937
  */
950
938
 
951
939
  Aggregate.prototype.cursor = function(options) {
@@ -961,10 +949,10 @@ Aggregate.prototype.cursor = function(options) {
961
949
  *
962
950
  * const res = await Model.aggregate(pipeline).collation({ locale: 'en_US', strength: 1 });
963
951
  *
964
- * @param {Object} collation options
952
+ * @param {object} collation options
965
953
  * @return {Aggregate} this
966
954
  * @api public
967
- * @see mongodb https://mongodb.github.io/node-mongodb-native/4.9/interfaces/CollationOptions.html
955
+ * @see mongodb https://mongodb.github.io/node-mongodb-native/7.0/interfaces/CollationOptions.html
968
956
  */
969
957
 
970
958
  Aggregate.prototype.collation = function(collation) {
@@ -984,7 +972,7 @@ Aggregate.prototype.collation = function(collation) {
984
972
  *
985
973
  * // Output: { books: [...], price: [{...}, {...}] }
986
974
  *
987
- * @param {Object} facet options
975
+ * @param {object} facet options
988
976
  * @return {Aggregate} this
989
977
  * @see $facet https://www.mongodb.com/docs/manual/reference/operator/aggregation/facet/
990
978
  * @api public
@@ -1010,7 +998,7 @@ Aggregate.prototype.facet = function(options) {
1010
998
  *
1011
999
  * // Output: [{ plot: '...', title: '...' }]
1012
1000
  *
1013
- * @param {Object} $search options
1001
+ * @param {object} $search options
1014
1002
  * @return {Aggregate} this
1015
1003
  * @see $search https://www.mongodb.com/docs/atlas/atlas-search/tutorial/
1016
1004
  * @api public
@@ -1027,7 +1015,7 @@ Aggregate.prototype.search = function(options) {
1027
1015
  *
1028
1016
  * MyModel.aggregate().match({ test: 1 }).pipeline(); // [{ $match: { test: 1 } }]
1029
1017
  *
1030
- * @return {Array} The current pipeline similar to the operation that will be executed
1018
+ * @return {PipelineStage[]} The current pipeline similar to the operation that will be executed
1031
1019
  * @api public
1032
1020
  */
1033
1021
 
@@ -1035,6 +1023,29 @@ Aggregate.prototype.pipeline = function() {
1035
1023
  return this._pipeline;
1036
1024
  };
1037
1025
 
1026
+ /**
1027
+ * Returns the current pipeline as a `$unionWith`-safe pipeline.
1028
+ * Throws if this pipeline contains `$out` or `$merge`.
1029
+ *
1030
+ * #### Example:
1031
+ *
1032
+ * const base = MyModel.aggregate().match({ test: 1 });
1033
+ * base.pipelineForUnionWith(); // [{ $match: { test: 1 } }]
1034
+ *
1035
+ * @return {PipelineStage[]} The current pipeline with `$unionWith` stage restrictions
1036
+ * @api public
1037
+ */
1038
+
1039
+ Aggregate.prototype.pipelineForUnionWith = function pipelineForUnionWith() {
1040
+ for (const stage of this._pipeline) {
1041
+ if (stage?.$out != null || stage?.$merge != null) {
1042
+ throw new MongooseError('Aggregate pipeline for $unionWith cannot include `$out` or `$merge` stages');
1043
+ }
1044
+ }
1045
+
1046
+ return this._pipeline;
1047
+ };
1048
+
1038
1049
  /**
1039
1050
  * Executes the aggregate pipeline on the currently bound Model.
1040
1051
  *
@@ -1047,7 +1058,7 @@ Aggregate.prototype.pipeline = function() {
1047
1058
 
1048
1059
  Aggregate.prototype.exec = async function exec() {
1049
1060
  if (!this._model && !this._connection) {
1050
- throw new Error('Aggregate not bound to any Model');
1061
+ throw new MongooseError('Aggregate not bound to any Model');
1051
1062
  }
1052
1063
  if (typeof arguments[0] === 'function') {
1053
1064
  throw new MongooseError('Aggregate.prototype.exec() no longer accepts a callback');
@@ -1072,59 +1083,38 @@ Aggregate.prototype.exec = async function exec() {
1072
1083
 
1073
1084
  this._optionsForExec();
1074
1085
 
1075
- if (this.options && this.options.cursor) {
1086
+ if (this.options?.cursor) {
1076
1087
  return new AggregationCursor(this);
1077
1088
  }
1078
1089
 
1079
1090
  prepareDiscriminatorPipeline(this._pipeline, this._model.schema);
1080
1091
  stringifyFunctionOperators(this._pipeline);
1081
1092
 
1082
- await new Promise((resolve, reject) => {
1083
- model.hooks.execPre('aggregate', this, error => {
1084
- if (error) {
1085
- const _opts = { error: error };
1086
- return model.hooks.execPost('aggregate', this, [null], _opts, error => {
1087
- reject(error);
1088
- });
1089
- } else {
1090
- resolve();
1091
- }
1092
- });
1093
- });
1093
+ const preFilter = buildMiddlewareFilter(this.options, 'pre');
1094
+ const postFilter = buildMiddlewareFilter(this.options, 'post');
1095
+
1096
+ try {
1097
+ await model.hooks.execPre('aggregate', this, [], { filter: preFilter });
1098
+ } catch (error) {
1099
+ return await model.hooks.execPost('aggregate', this, [null], { error, filter: postFilter });
1100
+ }
1094
1101
 
1095
1102
  if (!this._pipeline.length) {
1096
1103
  throw new MongooseError('Aggregate has empty pipeline');
1097
1104
  }
1098
1105
 
1099
1106
  const options = clone(this.options || {});
1107
+ delete options.middleware;
1100
1108
 
1101
1109
  let result;
1102
1110
  try {
1103
1111
  const cursor = await collection.aggregate(this._pipeline, options);
1104
1112
  result = await cursor.toArray();
1105
1113
  } catch (error) {
1106
- await new Promise((resolve, reject) => {
1107
- const _opts = { error: error };
1108
- model.hooks.execPost('aggregate', this, [null], _opts, (error) => {
1109
- if (error) {
1110
- return reject(error);
1111
- }
1112
-
1113
- resolve();
1114
- });
1115
- });
1114
+ return await model.hooks.execPost('aggregate', this, [null], { error, filter: postFilter });
1116
1115
  }
1117
1116
 
1118
- const _opts = { error: null };
1119
- await new Promise((resolve, reject) => {
1120
- model.hooks.execPost('aggregate', this, [result], _opts, error => {
1121
- if (error) {
1122
- return reject(error);
1123
- }
1124
- return resolve();
1125
- });
1126
- });
1127
-
1117
+ await model.hooks.execPost('aggregate', this, [result], { error: null, filter: postFilter });
1128
1118
  return result;
1129
1119
  };
1130
1120
 
@@ -1186,24 +1176,15 @@ Aggregate.prototype.finally = function(onFinally) {
1186
1176
  * console.log(doc.name);
1187
1177
  * }
1188
1178
  *
1189
- * Node.js 10.x supports async iterators natively without any flags. You can
1190
- * enable async iterators in Node.js 8.x using the [`--harmony_async_iteration` flag](https://github.com/tc39/proposal-async-iteration/issues/117#issuecomment-346695187).
1191
- *
1192
- * **Note:** This function is not set if `Symbol.asyncIterator` is undefined. If
1193
- * `Symbol.asyncIterator` is undefined, that means your Node.js version does not
1194
- * support async iterators.
1195
- *
1196
1179
  * @method [Symbol.asyncIterator]
1197
1180
  * @memberOf Aggregate
1198
1181
  * @instance
1199
1182
  * @api public
1200
1183
  */
1201
1184
 
1202
- if (Symbol.asyncIterator != null) {
1203
- Aggregate.prototype[Symbol.asyncIterator] = function() {
1204
- return this.cursor({ useMongooseAggCursor: true }).transformNull()._transformForAsyncIterator();
1205
- };
1206
- }
1185
+ Aggregate.prototype[Symbol.asyncIterator] = function() {
1186
+ return this.cursor({ useMongooseAggCursor: true }).transformNull()._transformForAsyncIterator();
1187
+ };
1207
1188
 
1208
1189
  /*!
1209
1190
  * Helpers
@@ -1212,8 +1193,8 @@ if (Symbol.asyncIterator != null) {
1212
1193
  /**
1213
1194
  * Checks whether an object is likely a pipeline operator
1214
1195
  *
1215
- * @param {Object} obj object to check
1216
- * @return {Boolean}
1196
+ * @param {object} obj object to check
1197
+ * @return {boolean}
1217
1198
  * @api private
1218
1199
  */
1219
1200
 
@@ -1,13 +1,13 @@
1
1
  'use strict';
2
2
 
3
- const { Long } = require('bson');
3
+ const { Long } = require('mongodb/lib/bson');
4
4
 
5
5
  /**
6
6
  * Given a value, cast it to a BigInt, or throw an `Error` if the value
7
7
  * cannot be casted. `null` and `undefined` are considered valid.
8
8
  *
9
- * @param {Any} value
10
- * @return {Number}
9
+ * @param {any} value
10
+ * @return {bigint|null|undefined}
11
11
  * @throws {Error} if `value` is not one of the allowed values
12
12
  * @api private
13
13
  */