@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": "kareem",
3
- "version": "2.6.3",
3
+ "version": "3.3.0",
4
4
  "description": "Next-generation take on pre/post function hooks",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -17,12 +17,12 @@
17
17
  "acquit": "1.x",
18
18
  "acquit-ignore": "0.2.x",
19
19
  "eslint": "8.20.0",
20
- "mocha": "9.2.0",
20
+ "mocha": "11.x",
21
21
  "nyc": "15.1.0"
22
22
  },
23
23
  "author": "Valeri Karpov <val@karpov.io>",
24
24
  "license": "Apache-2.0",
25
25
  "engines": {
26
- "node": ">=12.0.0"
26
+ "node": ">=18.0.0"
27
27
  }
28
28
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toUTF8 = exports.getBigInt64LE = exports.getFloat64LE = exports.getInt32LE = exports.UUID = exports.Timestamp = exports.serialize = exports.ObjectId = exports.MinKey = exports.MaxKey = exports.Long = exports.Int32 = exports.EJSON = exports.Double = exports.deserialize = exports.Decimal128 = exports.DBRef = exports.Code = exports.calculateObjectSize = exports.BSONType = exports.BSONSymbol = exports.BSONRegExp = exports.BSONError = exports.BSON = exports.Binary = void 0;
3
+ exports.setUint32LE = exports.readInt32LE = exports.UUID = exports.Timestamp = exports.serialize = exports.ObjectId = exports.NumberUtils = exports.MinKey = exports.MaxKey = exports.Long = exports.Int32 = exports.EJSON = exports.Double = exports.deserialize = exports.Decimal128 = exports.DBRef = exports.Code = exports.calculateObjectSize = exports.ByteUtils = exports.BSONType = exports.BSONSymbol = exports.BSONRegExp = exports.BSONError = exports.BSON = exports.Binary = void 0;
4
4
  exports.parseToElementsToArray = parseToElementsToArray;
5
5
  exports.pluckBSONSerializeOptions = pluckBSONSerializeOptions;
6
6
  exports.resolveBSONOptions = resolveBSONOptions;
@@ -14,6 +14,7 @@ Object.defineProperty(exports, "BSONError", { enumerable: true, get: function ()
14
14
  Object.defineProperty(exports, "BSONRegExp", { enumerable: true, get: function () { return bson_2.BSONRegExp; } });
15
15
  Object.defineProperty(exports, "BSONSymbol", { enumerable: true, get: function () { return bson_2.BSONSymbol; } });
16
16
  Object.defineProperty(exports, "BSONType", { enumerable: true, get: function () { return bson_2.BSONType; } });
17
+ Object.defineProperty(exports, "ByteUtils", { enumerable: true, get: function () { return bson_2.ByteUtils; } });
17
18
  Object.defineProperty(exports, "calculateObjectSize", { enumerable: true, get: function () { return bson_2.calculateObjectSize; } });
18
19
  Object.defineProperty(exports, "Code", { enumerable: true, get: function () { return bson_2.Code; } });
19
20
  Object.defineProperty(exports, "DBRef", { enumerable: true, get: function () { return bson_2.DBRef; } });
@@ -25,6 +26,7 @@ Object.defineProperty(exports, "Int32", { enumerable: true, get: function () { r
25
26
  Object.defineProperty(exports, "Long", { enumerable: true, get: function () { return bson_2.Long; } });
26
27
  Object.defineProperty(exports, "MaxKey", { enumerable: true, get: function () { return bson_2.MaxKey; } });
27
28
  Object.defineProperty(exports, "MinKey", { enumerable: true, get: function () { return bson_2.MinKey; } });
29
+ Object.defineProperty(exports, "NumberUtils", { enumerable: true, get: function () { return bson_2.NumberUtils; } });
28
30
  Object.defineProperty(exports, "ObjectId", { enumerable: true, get: function () { return bson_2.ObjectId; } });
29
31
  Object.defineProperty(exports, "serialize", { enumerable: true, get: function () { return bson_2.serialize; } });
30
32
  Object.defineProperty(exports, "Timestamp", { enumerable: true, get: function () { return bson_2.Timestamp; } });
@@ -33,10 +35,30 @@ function parseToElementsToArray(bytes, offset) {
33
35
  const res = bson_1.BSON.onDemand.parseToElements(bytes, offset);
34
36
  return Array.isArray(res) ? res : [...res];
35
37
  }
36
- exports.getInt32LE = bson_1.BSON.onDemand.NumberUtils.getInt32LE;
37
- exports.getFloat64LE = bson_1.BSON.onDemand.NumberUtils.getFloat64LE;
38
- exports.getBigInt64LE = bson_1.BSON.onDemand.NumberUtils.getBigInt64LE;
39
- exports.toUTF8 = bson_1.BSON.onDemand.ByteUtils.toUTF8;
38
+ // validates buffer inputs, used for read operations
39
+ const validateBufferInputs = (buffer, offset, length) => {
40
+ if (offset < 0 || offset + length > buffer.length) {
41
+ throw new RangeError(`Attempt to access memory outside buffer bounds: buffer length: ${buffer.length}, offset: ${offset}, length: ${length}`);
42
+ }
43
+ };
44
+ // readInt32LE, reads a 32-bit integer from buffer at given offset
45
+ // throws if offset is out of bounds
46
+ const readInt32LE = (buffer, offset) => {
47
+ validateBufferInputs(buffer, offset, 4);
48
+ return bson_1.NumberUtils.getInt32LE(buffer, offset);
49
+ };
50
+ exports.readInt32LE = readInt32LE;
51
+ const setUint32LE = (destination, offset, value) => {
52
+ destination[offset] = value;
53
+ value >>>= 8;
54
+ destination[offset + 1] = value;
55
+ value >>>= 8;
56
+ destination[offset + 2] = value;
57
+ value >>>= 8;
58
+ destination[offset + 3] = value;
59
+ return 4;
60
+ };
61
+ exports.setUint32LE = setUint32LE;
40
62
  function pluckBSONSerializeOptions(options) {
41
63
  const { fieldsAsRaw, useBigInt64, promoteValues, promoteBuffers, promoteLongs, serializeFunctions, ignoreUndefined, bsonRegExp, raw, enableUtf8Validation } = options;
42
64
  return {
@@ -300,14 +300,14 @@ async function executeCommands(bulkOperation, options) {
300
300
  if (bulkOperation.s.checkKeys === false) {
301
301
  finalOptions.checkKeys = false;
302
302
  }
303
- if (finalOptions.retryWrites) {
303
+ if (bulkOperation.retryWrites) {
304
304
  if (isUpdateBatch(batch)) {
305
- finalOptions.retryWrites =
306
- finalOptions.retryWrites && !batch.operations.some(op => op.multi);
305
+ bulkOperation.retryWrites =
306
+ bulkOperation.retryWrites && !batch.operations.some(op => op.multi);
307
307
  }
308
308
  if (isDeleteBatch(batch)) {
309
- finalOptions.retryWrites =
310
- finalOptions.retryWrites && !batch.operations.some(op => op.limit === 0);
309
+ bulkOperation.retryWrites =
310
+ bulkOperation.retryWrites && !batch.operations.some(op => op.limit === 0);
311
311
  }
312
312
  }
313
313
  const operation = isInsertBatch(batch)
@@ -503,6 +503,7 @@ class BulkOperationBase {
503
503
  */
504
504
  constructor(collection, options, isOrdered) {
505
505
  this.collection = collection;
506
+ this.retryWrites = collection.db.options?.retryWrites;
506
507
  // determine whether bulkOperation is ordered or unordered
507
508
  this.isOrdered = isOrdered;
508
509
  const topology = (0, utils_1.getTopology)(collection);
@@ -528,9 +529,6 @@ class BulkOperationBase {
528
529
  // # of bytes = length of (string representation of (maxWriteBatchSize - 1))
529
530
  // + 1 bytes for null terminator
530
531
  const maxKeySize = (maxWriteBatchSize - 1).toString(10).length + 2;
531
- // Final options for retryable writes
532
- let finalOptions = Object.assign({}, options);
533
- finalOptions = (0, utils_1.applyRetryableWrites)(finalOptions, collection.db);
534
532
  // Final results
535
533
  const bulkResult = {
536
534
  ok: 1,
@@ -571,7 +569,7 @@ class BulkOperationBase {
571
569
  // Topology
572
570
  topology,
573
571
  // Options
574
- options: finalOptions,
572
+ options: options,
575
573
  // BSON options
576
574
  bsonOptions: (0, bson_1.resolveBSONOptions)(options),
577
575
  // Current operation
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ChangeStream = void 0;
4
+ exports.filterOutOptions = filterOutOptions;
4
5
  const collection_1 = require("./collection");
5
6
  const constants_1 = require("./constants");
6
7
  const abstract_cursor_1 = require("./cursor/abstract_cursor");
@@ -9,17 +10,9 @@ const db_1 = require("./db");
9
10
  const error_1 = require("./error");
10
11
  const mongo_client_1 = require("./mongo_client");
11
12
  const mongo_types_1 = require("./mongo_types");
12
- const resource_management_1 = require("./resource_management");
13
+ const server_selection_1 = require("./sdam/server_selection");
13
14
  const timeout_1 = require("./timeout");
14
15
  const utils_1 = require("./utils");
15
- const CHANGE_STREAM_OPTIONS = [
16
- 'resumeAfter',
17
- 'startAfter',
18
- 'startAtOperationTime',
19
- 'fullDocument',
20
- 'fullDocumentBeforeChange',
21
- 'showExpandedEvents'
22
- ];
23
16
  const CHANGE_DOMAIN_TYPES = {
24
17
  COLLECTION: Symbol('Collection'),
25
18
  DATABASE: Symbol('Database'),
@@ -28,15 +21,46 @@ const CHANGE_DOMAIN_TYPES = {
28
21
  const CHANGE_STREAM_EVENTS = [constants_1.RESUME_TOKEN_CHANGED, constants_1.END, constants_1.CLOSE];
29
22
  const NO_RESUME_TOKEN_ERROR = 'A change stream document has been received that lacks a resume token (_id).';
30
23
  const CHANGESTREAM_CLOSED_ERROR = 'ChangeStream is closed';
24
+ const INVALID_STAGE_OPTIONS = buildDisallowedChangeStreamOptions();
25
+ function filterOutOptions(options) {
26
+ return Object.fromEntries(Object.entries(options).filter(([k, _]) => !INVALID_STAGE_OPTIONS.has(k)));
27
+ }
31
28
  /**
32
29
  * Creates a new Change Stream instance. Normally created using {@link Collection#watch|Collection.watch()}.
33
30
  * @public
34
31
  */
35
32
  class ChangeStream extends mongo_types_1.TypedEventEmitter {
36
- /** @internal */
37
- async asyncDispose() {
33
+ /**
34
+ * @experimental
35
+ * An alias for {@link ChangeStream.close|ChangeStream.close()}.
36
+ */
37
+ async [Symbol.asyncDispose]() {
38
38
  await this.close();
39
39
  }
40
+ /** @event */
41
+ static { this.RESPONSE = constants_1.RESPONSE; }
42
+ /** @event */
43
+ static { this.MORE = constants_1.MORE; }
44
+ /** @event */
45
+ static { this.INIT = constants_1.INIT; }
46
+ /** @event */
47
+ static { this.CLOSE = constants_1.CLOSE; }
48
+ /**
49
+ * Fired for each new matching change in the specified namespace. Attaching a `change`
50
+ * event listener to a Change Stream will switch the stream into flowing mode. Data will
51
+ * then be passed as soon as it is available.
52
+ * @event
53
+ */
54
+ static { this.CHANGE = constants_1.CHANGE; }
55
+ /** @event */
56
+ static { this.END = constants_1.END; }
57
+ /** @event */
58
+ static { this.ERROR = constants_1.ERROR; }
59
+ /**
60
+ * Emitted each time the change stream stores a new resume token.
61
+ * @event
62
+ */
63
+ static { this.RESUME_TOKEN_CHANGED = constants_1.RESUME_TOKEN_CHANGED; }
40
64
  /**
41
65
  * @internal
42
66
  *
@@ -96,6 +120,10 @@ class ChangeStream extends mongo_types_1.TypedEventEmitter {
96
120
  get resumeToken() {
97
121
  return this.cursor?.resumeToken;
98
122
  }
123
+ /** Returns the currently buffered documents length of the underlying cursor. */
124
+ bufferedCount() {
125
+ return this.cursor?.bufferedCount() ?? 0;
126
+ }
99
127
  /** Check if there is any document still available in the Change Stream */
100
128
  async hasNext() {
101
129
  this._setIsIterator();
@@ -257,12 +285,11 @@ class ChangeStream extends mongo_types_1.TypedEventEmitter {
257
285
  *
258
286
  * @throws MongoChangeStreamError if the underlying cursor or the change stream is closed
259
287
  */
260
- stream(options) {
288
+ stream() {
261
289
  if (this.closed) {
262
290
  throw new error_1.MongoChangeStreamError(CHANGESTREAM_CLOSED_ERROR);
263
291
  }
264
- this.streamOptions = options;
265
- return this.cursor.stream(options);
292
+ return this.cursor.stream();
266
293
  }
267
294
  /** @internal */
268
295
  _setIsEmitter() {
@@ -285,7 +312,7 @@ class ChangeStream extends mongo_types_1.TypedEventEmitter {
285
312
  * @internal
286
313
  */
287
314
  _createChangeStreamCursor(options) {
288
- const changeStreamStageOptions = (0, utils_1.filterOptions)(options, CHANGE_STREAM_OPTIONS);
315
+ const changeStreamStageOptions = filterOutOptions(options);
289
316
  if (this.type === CHANGE_DOMAIN_TYPES.CLUSTER) {
290
317
  changeStreamStageOptions.allChangesForCluster = true;
291
318
  }
@@ -425,7 +452,8 @@ class ChangeStream extends mongo_types_1.TypedEventEmitter {
425
452
  try {
426
453
  await topology.selectServer(this.cursor.readPreference, {
427
454
  operationName: 'reconnect topology in change stream',
428
- timeoutContext: this.timeoutContext
455
+ timeoutContext: this.timeoutContext,
456
+ deprioritizedServers: new server_selection_1.DeprioritizedServers()
429
457
  });
430
458
  this.cursor = this._createChangeStreamCursor(this.cursor.resumeOptions);
431
459
  }
@@ -437,29 +465,53 @@ class ChangeStream extends mongo_types_1.TypedEventEmitter {
437
465
  }
438
466
  }
439
467
  exports.ChangeStream = ChangeStream;
440
- /** @event */
441
- ChangeStream.RESPONSE = constants_1.RESPONSE;
442
- /** @event */
443
- ChangeStream.MORE = constants_1.MORE;
444
- /** @event */
445
- ChangeStream.INIT = constants_1.INIT;
446
- /** @event */
447
- ChangeStream.CLOSE = constants_1.CLOSE;
448
468
  /**
449
- * Fired for each new matching change in the specified namespace. Attaching a `change`
450
- * event listener to a Change Stream will switch the stream into flowing mode. Data will
451
- * then be passed as soon as it is available.
452
- * @event
469
+ * This function returns a list of options that are *not* supported by the $changeStream
470
+ * aggregation stage. This is best-effort - it uses the options "officially supported" by the driver
471
+ * to derive a list of known, unsupported options for the $changeStream stage.
472
+ *
473
+ * Notably, at runtime, users can still provide options unknown to the driver and the driver will
474
+ * *not* filter them out of the options object (see NODE-5510).
453
475
  */
454
- ChangeStream.CHANGE = constants_1.CHANGE;
455
- /** @event */
456
- ChangeStream.END = constants_1.END;
457
- /** @event */
458
- ChangeStream.ERROR = constants_1.ERROR;
459
- /**
460
- * Emitted each time the change stream stores a new resume token.
461
- * @event
462
- */
463
- ChangeStream.RESUME_TOKEN_CHANGED = constants_1.RESUME_TOKEN_CHANGED;
464
- (0, resource_management_1.configureResourceManagement)(ChangeStream.prototype);
476
+ function buildDisallowedChangeStreamOptions() {
477
+ const denyList = {
478
+ allowDiskUse: '',
479
+ authdb: '',
480
+ batchSize: '',
481
+ bsonRegExp: '',
482
+ bypassDocumentValidation: '',
483
+ bypassPinningCheck: '',
484
+ checkKeys: '',
485
+ collation: '',
486
+ comment: '',
487
+ cursor: '',
488
+ dbName: '',
489
+ enableUtf8Validation: '',
490
+ explain: '',
491
+ fieldsAsRaw: '',
492
+ hint: '',
493
+ ignoreUndefined: '',
494
+ let: '',
495
+ maxAwaitTimeMS: '',
496
+ maxTimeMS: '',
497
+ omitMaxTimeMS: '',
498
+ out: '',
499
+ promoteBuffers: '',
500
+ promoteLongs: '',
501
+ promoteValues: '',
502
+ raw: '',
503
+ rawData: '',
504
+ readConcern: '',
505
+ readPreference: '',
506
+ serializeFunctions: '',
507
+ session: '',
508
+ timeoutContext: '',
509
+ timeoutMS: '',
510
+ timeoutMode: '',
511
+ useBigInt64: '',
512
+ willRetryWrite: '',
513
+ writeConcern: ''
514
+ };
515
+ return new Set(Object.keys(denyList));
516
+ }
465
517
  //# sourceMappingURL=change_stream.js.map
@@ -10,7 +10,6 @@ const error_1 = require("../error");
10
10
  const mongo_client_1 = require("../mongo_client");
11
11
  const utils_1 = require("../utils");
12
12
  const client_encryption_1 = require("./client_encryption");
13
- const cryptoCallbacks = require("./crypto_callbacks");
14
13
  const errors_1 = require("./errors");
15
14
  const mongocryptd_manager_1 = require("./mongocryptd_manager");
16
15
  const providers_1 = require("./providers");
@@ -28,6 +27,7 @@ exports.AutoEncryptionLoggerLevel = Object.freeze({
28
27
  * **NOTE**: Not meant to be instantiated directly, this is for internal use only.
29
28
  */
30
29
  class AutoEncrypter {
30
+ static { _a = constants_1.kDecorateResult; }
31
31
  /** @internal */
32
32
  static getMongoCrypt() {
33
33
  const encryption = (0, deps_1.getMongoDBClientEncryption)();
@@ -107,22 +107,30 @@ class AutoEncrypter {
107
107
  throw new errors_1.MongoCryptInvalidArgumentError('Can only provide a custom AWS credential provider when the state machine is configured for automatic AWS credential fetching');
108
108
  }
109
109
  const mongoCryptOptions = {
110
- enableMultipleCollinfo: true,
111
- cryptoCallbacks
110
+ errorWrapper: errors_1.defaultErrorWrapper
112
111
  };
113
112
  if (options.schemaMap) {
114
- mongoCryptOptions.schemaMap = Buffer.isBuffer(options.schemaMap)
115
- ? options.schemaMap
116
- : (0, bson_1.serialize)(options.schemaMap);
113
+ if (bson_1.ByteUtils.isUint8Array(options.schemaMap)) {
114
+ mongoCryptOptions.schemaMap = options.schemaMap;
115
+ }
116
+ else {
117
+ mongoCryptOptions.schemaMap = (0, bson_1.serialize)(options.schemaMap);
118
+ }
117
119
  }
118
120
  if (options.encryptedFieldsMap) {
119
- mongoCryptOptions.encryptedFieldsMap = Buffer.isBuffer(options.encryptedFieldsMap)
120
- ? options.encryptedFieldsMap
121
- : (0, bson_1.serialize)(options.encryptedFieldsMap);
121
+ if (bson_1.ByteUtils.isUint8Array(options.encryptedFieldsMap)) {
122
+ mongoCryptOptions.encryptedFieldsMap = options.encryptedFieldsMap;
123
+ }
124
+ else {
125
+ mongoCryptOptions.encryptedFieldsMap = (0, bson_1.serialize)(options.encryptedFieldsMap);
126
+ }
127
+ }
128
+ if (bson_1.ByteUtils.isUint8Array(this._kmsProviders)) {
129
+ mongoCryptOptions.kmsProviders = this._kmsProviders;
130
+ }
131
+ else {
132
+ mongoCryptOptions.kmsProviders = (0, bson_1.serialize)(this._kmsProviders);
122
133
  }
123
- mongoCryptOptions.kmsProviders = !Buffer.isBuffer(this._kmsProviders)
124
- ? (0, bson_1.serialize)(this._kmsProviders)
125
- : this._kmsProviders;
126
134
  if (options.options?.logger) {
127
135
  mongoCryptOptions.logger = options.options.logger;
128
136
  }
@@ -215,7 +223,7 @@ class AutoEncrypter {
215
223
  // If `bypassAutoEncryption` has been specified, don't encrypt
216
224
  return cmd;
217
225
  }
218
- const commandBuffer = Buffer.isBuffer(cmd) ? cmd : (0, bson_1.serialize)(cmd, options);
226
+ const commandBuffer = (0, bson_1.serialize)(cmd, options);
219
227
  const context = this._mongocrypt.makeEncryptionContext(utils_1.MongoDBCollectionNamespace.fromString(ns).db, commandBuffer);
220
228
  context.id = this._contextCounter++;
221
229
  context.ns = ns;
@@ -270,5 +278,4 @@ class AutoEncrypter {
270
278
  }
271
279
  }
272
280
  exports.AutoEncrypter = AutoEncrypter;
273
- _a = constants_1.kDecorateResult;
274
281
  //# sourceMappingURL=auto_encrypter.js.map
@@ -6,7 +6,6 @@ const bson_1 = require("../bson");
6
6
  const deps_1 = require("../deps");
7
7
  const timeout_1 = require("../timeout");
8
8
  const utils_1 = require("../utils");
9
- const cryptoCallbacks = require("./crypto_callbacks");
10
9
  const errors_1 = require("./errors");
11
10
  const index_1 = require("./providers/index");
12
11
  const state_machine_1 = require("./state_machine");
@@ -67,10 +66,8 @@ class ClientEncryption {
67
66
  }
68
67
  const mongoCryptOptions = {
69
68
  ...options,
70
- cryptoCallbacks,
71
- kmsProviders: !Buffer.isBuffer(this._kmsProviders)
72
- ? (0, bson_1.serialize)(this._kmsProviders)
73
- : this._kmsProviders
69
+ kmsProviders: (0, bson_1.serialize)(this._kmsProviders),
70
+ errorWrapper: errors_1.defaultErrorWrapper
74
71
  };
75
72
  this._keyVaultNamespace = options.keyVaultNamespace;
76
73
  this._keyVaultClient = options.keyVaultClient || client;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MongoCryptKMSRequestNetworkTimeoutError = exports.MongoCryptAzureKMSRequestError = exports.MongoCryptCreateEncryptedCollectionError = exports.MongoCryptCreateDataKeyError = exports.MongoCryptInvalidArgumentError = exports.MongoCryptError = void 0;
3
+ exports.MongoCryptKMSRequestNetworkTimeoutError = exports.MongoCryptAzureKMSRequestError = exports.MongoCryptCreateEncryptedCollectionError = exports.MongoCryptCreateDataKeyError = exports.MongoCryptInvalidArgumentError = exports.defaultErrorWrapper = exports.MongoCryptError = void 0;
4
4
  const error_1 = require("../error");
5
5
  /**
6
6
  * @public
@@ -26,6 +26,8 @@ class MongoCryptError extends error_1.MongoError {
26
26
  }
27
27
  }
28
28
  exports.MongoCryptError = MongoCryptError;
29
+ const defaultErrorWrapper = (error) => new MongoCryptError(error.message, { cause: error });
30
+ exports.defaultErrorWrapper = defaultErrorWrapper;
29
31
  /**
30
32
  * @public
31
33
  *
@@ -7,6 +7,7 @@ const error_1 = require("../error");
7
7
  * An internal class that handles spawning a mongocryptd.
8
8
  */
9
9
  class MongocryptdManager {
10
+ static { this.DEFAULT_MONGOCRYPTD_URI = 'mongodb://localhost:27020'; }
10
11
  constructor(extraOptions = {}) {
11
12
  this.spawnPath = '';
12
13
  this.spawnArgs = [];
@@ -81,5 +82,4 @@ class MongocryptdManager {
81
82
  }
82
83
  }
83
84
  exports.MongocryptdManager = MongocryptdManager;
84
- MongocryptdManager.DEFAULT_MONGOCRYPTD_URI = 'mongodb://localhost:27020';
85
85
  //# sourceMappingURL=mongocryptd_manager.js.map
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.StateMachine = void 0;
4
4
  const fs = require("fs/promises");
5
5
  const net = require("net");
6
+ const process = require("process");
6
7
  const tls = require("tls");
7
8
  const bson_1 = require("../bson");
8
9
  const abstract_cursor_1 = require("../cursor/abstract_cursor");
@@ -0,0 +1,161 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.aws4Sign = aws4Sign;
4
+ const bson_1 = require("../../bson");
5
+ /**
6
+ * Calculates the SHA-256 hash of a string.
7
+ *
8
+ * @param str - String to hash.
9
+ * @returns Hexadecimal representation of the hash.
10
+ */
11
+ const getHexSha256 = async (str) => {
12
+ const data = stringToBuffer(str);
13
+ const hashBuffer = await crypto.subtle.digest('SHA-256', data);
14
+ const hashHex = bson_1.ByteUtils.toHex(new Uint8Array(hashBuffer));
15
+ return hashHex;
16
+ };
17
+ /**
18
+ * Calculates the HMAC-SHA256 of a string using the provided key.
19
+ * @param key - Key to use for HMAC calculation. Can be a string or Uint8Array.
20
+ * @param str - String to calculate HMAC for.
21
+ * @returns Uint8Array containing the HMAC-SHA256 digest.
22
+ */
23
+ const getHmacSha256 = async (key, str) => {
24
+ let keyData;
25
+ if (typeof key === 'string') {
26
+ keyData = stringToBuffer(key);
27
+ }
28
+ else {
29
+ keyData = key;
30
+ }
31
+ const importedKey = await crypto.subtle.importKey('raw', keyData, { name: 'HMAC', hash: { name: 'SHA-256' } }, false, ['sign']);
32
+ const strData = stringToBuffer(str);
33
+ const signature = await crypto.subtle.sign('HMAC', importedKey, strData);
34
+ const digest = new Uint8Array(signature);
35
+ return digest;
36
+ };
37
+ /**
38
+ * Converts header values according to AWS requirements,
39
+ * From https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_sigv-create-signed-request.html#create-canonical-request
40
+ * For values, you must:
41
+ - trim any leading or trailing spaces.
42
+ - convert sequential spaces to a single space.
43
+ * @param value - Header value to convert.
44
+ * @returns - Converted header value.
45
+ */
46
+ const convertHeaderValue = (value) => {
47
+ return value.toString().trim().replace(/\s+/g, ' ');
48
+ };
49
+ /**
50
+ * Returns a Uint8Array representation of a string, encoded in UTF-8.
51
+ * @param str - String to convert.
52
+ * @returns Uint8Array containing the UTF-8 encoded string.
53
+ */
54
+ function stringToBuffer(str) {
55
+ const data = new Uint8Array(bson_1.ByteUtils.utf8ByteLength(str));
56
+ bson_1.ByteUtils.encodeUTF8Into(data, str, 0);
57
+ return data;
58
+ }
59
+ /**
60
+ * This method implements AWS Signature 4 logic for a very specific request format.
61
+ * The signing logic is described here: https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_sigv-create-signed-request.html
62
+ */
63
+ async function aws4Sign(options, credentials) {
64
+ /**
65
+ * From the spec: https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_sigv-create-signed-request.html
66
+ *
67
+ * Summary of signing steps
68
+ * 1. Create a canonical request
69
+ * Arrange the contents of your request (host, action, headers, etc.) into a standard canonical format. The canonical request is one of the inputs used to create the string to sign.
70
+ * 2. Create a hash of the canonical request
71
+ * Hash the canonical request using the same algorithm that you used to create the hash of the payload. The hash of the canonical request is a string of lowercase hexadecimal characters.
72
+ * 3. Create a string to sign
73
+ * Create a string to sign with the canonical request and extra information such as the algorithm, request date, credential scope, and the hash of the canonical request.
74
+ * 4. Derive a signing key
75
+ * Use the secret access key to derive the key used to sign the request.
76
+ * 5. Calculate the signature
77
+ * Perform a keyed hash operation on the string to sign using the derived signing key as the hash key.
78
+ * 6. Add the signature to the request
79
+ * Add the calculated signature to an HTTP header or to the query string of the request.
80
+ */
81
+ // 1: Create a canonical request
82
+ // Date – The date and time used to sign the request.
83
+ const date = options.date;
84
+ // RequestDateTime – The date and time used in the credential scope. This value is the current UTC time in ISO 8601 format (for example, 20130524T000000Z).
85
+ const requestDateTime = date.toISOString().replace(/[:-]|\.\d{3}/g, '');
86
+ // RequestDate – The date used in the credential scope. This value is the current UTC date in YYYYMMDD format (for example, 20130524).
87
+ const requestDate = requestDateTime.substring(0, 8);
88
+ // Method – The HTTP request method. For us, this is always 'POST'.
89
+ const method = options.method;
90
+ // CanonicalUri – The URI-encoded version of the absolute path component URI, starting with the / that follows the domain name and up to the end of the string
91
+ // For our requests, this is always '/'
92
+ const canonicalUri = options.path;
93
+ // CanonicalQueryString – The URI-encoded query string parameters. For our requests, there are no query string parameters, so this is always an empty string.
94
+ const canonicalQuerystring = '';
95
+ // CanonicalHeaders – A list of request headers with their values. Individual header name and value pairs are separated by the newline character ("\n").
96
+ // All of our known/expected headers are included here, there are no extra headers.
97
+ const headers = new Headers({
98
+ 'content-length': convertHeaderValue(options.headers['Content-Length']),
99
+ 'content-type': convertHeaderValue(options.headers['Content-Type']),
100
+ host: convertHeaderValue(options.host),
101
+ 'x-amz-date': convertHeaderValue(requestDateTime),
102
+ 'x-mongodb-gs2-cb-flag': convertHeaderValue(options.headers['X-MongoDB-GS2-CB-Flag']),
103
+ 'x-mongodb-server-nonce': convertHeaderValue(options.headers['X-MongoDB-Server-Nonce'])
104
+ });
105
+ // If session token is provided, include it in the headers
106
+ if ('sessionToken' in credentials && credentials.sessionToken) {
107
+ headers.append('x-amz-security-token', convertHeaderValue(credentials.sessionToken));
108
+ }
109
+ // Canonical headers are lowercased and sorted.
110
+ const canonicalHeaders = Array.from(headers.entries())
111
+ .map(([key, value]) => `${key.toLowerCase()}:${value}`)
112
+ .sort()
113
+ .join('\n');
114
+ const canonicalHeaderNames = Array.from(headers.keys()).map(header => header.toLowerCase());
115
+ // SignedHeaders – An alphabetically sorted, semicolon-separated list of lowercase request header names.
116
+ const signedHeaders = canonicalHeaderNames.sort().join(';');
117
+ // HashedPayload – A string created using the payload in the body of the HTTP request as input to a hash function. This string uses lowercase hexadecimal characters.
118
+ const hashedPayload = await getHexSha256(options.body);
119
+ // CanonicalRequest – A string that includes the above elements, separated by newline characters.
120
+ const canonicalRequest = [
121
+ method,
122
+ canonicalUri,
123
+ canonicalQuerystring,
124
+ canonicalHeaders + '\n',
125
+ signedHeaders,
126
+ hashedPayload
127
+ ].join('\n');
128
+ // 2. Create a hash of the canonical request
129
+ // HashedCanonicalRequest – A string created by using the canonical request as input to a hash function.
130
+ const hashedCanonicalRequest = await getHexSha256(canonicalRequest);
131
+ // 3. Create a string to sign
132
+ // Algorithm – The algorithm used to create the hash of the canonical request. For SigV4, use AWS4-HMAC-SHA256.
133
+ const algorithm = 'AWS4-HMAC-SHA256';
134
+ // CredentialScope – The credential scope, which restricts the resulting signature to the specified Region and service.
135
+ // Has the following format: YYYYMMDD/region/service/aws4_request.
136
+ const credentialScope = `${requestDate}/${options.region}/${options.service}/aws4_request`;
137
+ // StringToSign – A string that includes the above elements, separated by newline characters.
138
+ const stringToSign = [algorithm, requestDateTime, credentialScope, hashedCanonicalRequest].join('\n');
139
+ // 4. Derive a signing key
140
+ // To derive a signing key for SigV4, perform a succession of keyed hash operations (HMAC) on the request date, Region, and service, with your AWS secret access key as the key for the initial hashing operation.
141
+ const dateKey = await getHmacSha256('AWS4' + credentials.secretAccessKey, requestDate);
142
+ const dateRegionKey = await getHmacSha256(dateKey, options.region);
143
+ const dateRegionServiceKey = await getHmacSha256(dateRegionKey, options.service);
144
+ const signingKey = await getHmacSha256(dateRegionServiceKey, 'aws4_request');
145
+ // 5. Calculate the signature
146
+ const signatureBuffer = await getHmacSha256(signingKey, stringToSign);
147
+ const signature = bson_1.ByteUtils.toHex(signatureBuffer);
148
+ // 6. Add the signature to the request
149
+ // Calculate the Authorization header
150
+ const authorizationHeader = [
151
+ 'AWS4-HMAC-SHA256 Credential=' + credentials.accessKeyId + '/' + credentialScope,
152
+ 'SignedHeaders=' + signedHeaders,
153
+ 'Signature=' + signature
154
+ ].join(', ');
155
+ // Return the calculated headers
156
+ return {
157
+ Authorization: authorizationHeader,
158
+ 'X-Amz-Date': requestDateTime
159
+ };
160
+ }
161
+ //# sourceMappingURL=aws4.js.map