@nullix/zod-mongoose-studio 1.0.13 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (268) hide show
  1. package/.output/nitro.json +1 -1
  2. package/.output/public/_nuxt/builds/latest.json +1 -1
  3. package/.output/public/_nuxt/builds/meta/8b851c04-1848-472a-b5cd-0727aaaf90f4.json +1 -0
  4. package/.output/server/chunks/nitro/nitro.mjs +232 -232
  5. package/.output/server/chunks/routes/api/parse.post.mjs +54 -11
  6. package/.output/server/chunks/routes/api/parse.post.mjs.map +1 -1
  7. package/.output/server/node_modules/bson/lib/bson.cjs +157 -48
  8. package/.output/server/node_modules/bson/package.json +9 -11
  9. package/.output/server/node_modules/kareem/index.js +228 -343
  10. package/.output/server/node_modules/kareem/package.json +3 -3
  11. package/.output/server/node_modules/mongodb/lib/bson.js +27 -5
  12. package/.output/server/node_modules/mongodb/lib/bulk/common.js +7 -9
  13. package/.output/server/node_modules/mongodb/lib/change_stream.js +91 -39
  14. package/.output/server/node_modules/mongodb/lib/client-side-encryption/auto_encrypter.js +21 -14
  15. package/.output/server/node_modules/mongodb/lib/client-side-encryption/client_encryption.js +2 -5
  16. package/.output/server/node_modules/mongodb/lib/client-side-encryption/errors.js +3 -1
  17. package/.output/server/node_modules/mongodb/lib/client-side-encryption/mongocryptd_manager.js +1 -1
  18. package/.output/server/node_modules/mongodb/lib/client-side-encryption/state_machine.js +1 -0
  19. package/.output/server/node_modules/mongodb/lib/cmap/auth/aws4.js +161 -0
  20. package/.output/server/node_modules/mongodb/lib/cmap/auth/aws_temporary_credentials.js +11 -58
  21. package/.output/server/node_modules/mongodb/lib/cmap/auth/gssapi.js +4 -6
  22. package/.output/server/node_modules/mongodb/lib/cmap/auth/mongo_credentials.js +2 -16
  23. package/.output/server/node_modules/mongodb/lib/cmap/auth/mongodb_aws.js +14 -23
  24. package/.output/server/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/azure_machine_workflow.js +3 -3
  25. package/.output/server/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/gcp_machine_workflow.js +3 -3
  26. package/.output/server/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/k8s_machine_workflow.js +4 -3
  27. package/.output/server/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/token_machine_workflow.js +4 -3
  28. package/.output/server/node_modules/mongodb/lib/cmap/auth/mongodb_oidc.js +4 -4
  29. package/.output/server/node_modules/mongodb/lib/cmap/auth/plain.js +1 -1
  30. package/.output/server/node_modules/mongodb/lib/cmap/auth/providers.js +0 -1
  31. package/.output/server/node_modules/mongodb/lib/cmap/auth/scram.js +53 -40
  32. package/.output/server/node_modules/mongodb/lib/cmap/commands.js +46 -39
  33. package/.output/server/node_modules/mongodb/lib/cmap/connect.js +35 -3
  34. package/.output/server/node_modules/mongodb/lib/cmap/connection.js +36 -32
  35. package/.output/server/node_modules/mongodb/lib/cmap/connection_pool.js +67 -67
  36. package/.output/server/node_modules/mongodb/lib/cmap/connection_pool_events.js +3 -3
  37. package/.output/server/node_modules/mongodb/lib/cmap/errors.js +1 -1
  38. package/.output/server/node_modules/mongodb/lib/cmap/handshake/client_metadata.js +15 -13
  39. package/.output/server/node_modules/mongodb/lib/cmap/metrics.js +3 -3
  40. package/.output/server/node_modules/mongodb/lib/cmap/wire_protocol/compression.js +26 -10
  41. package/.output/server/node_modules/mongodb/lib/cmap/wire_protocol/constants.js +3 -1
  42. package/.output/server/node_modules/mongodb/lib/cmap/wire_protocol/on_data.js +0 -1
  43. package/.output/server/node_modules/mongodb/lib/cmap/wire_protocol/on_demand/document.js +9 -9
  44. package/.output/server/node_modules/mongodb/lib/cmap/wire_protocol/responses.js +2 -2
  45. package/.output/server/node_modules/mongodb/lib/collection.js +1 -1
  46. package/.output/server/node_modules/mongodb/lib/connection_string.js +30 -15
  47. package/.output/server/node_modules/mongodb/lib/cursor/abstract_cursor.js +17 -34
  48. package/.output/server/node_modules/mongodb/lib/cursor/change_stream_cursor.js +2 -2
  49. package/.output/server/node_modules/mongodb/lib/cursor/find_cursor.js +37 -26
  50. package/.output/server/node_modules/mongodb/lib/cursor/run_command_cursor.js +1 -1
  51. package/.output/server/node_modules/mongodb/lib/db.js +6 -7
  52. package/.output/server/node_modules/mongodb/lib/deps.js +0 -13
  53. package/.output/server/node_modules/mongodb/lib/error.js +7 -10
  54. package/.output/server/node_modules/mongodb/lib/gridfs/download.js +7 -6
  55. package/.output/server/node_modules/mongodb/lib/gridfs/index.js +9 -9
  56. package/.output/server/node_modules/mongodb/lib/gridfs/upload.js +17 -23
  57. package/.output/server/node_modules/mongodb/lib/index.js +2 -4
  58. package/.output/server/node_modules/mongodb/lib/mongo_client.js +58 -67
  59. package/.output/server/node_modules/mongodb/lib/mongo_client_auth_providers.js +0 -6
  60. package/.output/server/node_modules/mongodb/lib/mongo_logger.js +11 -5
  61. package/.output/server/node_modules/mongodb/lib/mongo_types.js +1 -2
  62. package/.output/server/node_modules/mongodb/lib/operations/aggregate.js +0 -3
  63. package/.output/server/node_modules/mongodb/lib/operations/create_collection.js +0 -1
  64. package/.output/server/node_modules/mongodb/lib/operations/drop.js +8 -9
  65. package/.output/server/node_modules/mongodb/lib/operations/end_sessions.js +34 -0
  66. package/.output/server/node_modules/mongodb/lib/operations/execute_operation.js +121 -45
  67. package/.output/server/node_modules/mongodb/lib/operations/operation.js +1 -0
  68. package/.output/server/node_modules/mongodb/lib/read_preference.js +10 -14
  69. package/.output/server/node_modules/mongodb/lib/runtime_adapters.js +32 -0
  70. package/.output/server/node_modules/mongodb/lib/sdam/monitor.js +8 -8
  71. package/.output/server/node_modules/mongodb/lib/sdam/server.js +55 -43
  72. package/.output/server/node_modules/mongodb/lib/sdam/server_description.js +1 -1
  73. package/.output/server/node_modules/mongodb/lib/sdam/server_selection.js +135 -72
  74. package/.output/server/node_modules/mongodb/lib/sdam/srv_polling.js +3 -3
  75. package/.output/server/node_modules/mongodb/lib/sdam/topology.js +37 -77
  76. package/.output/server/node_modules/mongodb/lib/sdam/topology_description.js +1 -1
  77. package/.output/server/node_modules/mongodb/lib/sessions.js +150 -40
  78. package/.output/server/node_modules/mongodb/lib/transactions.js +2 -13
  79. package/.output/server/node_modules/mongodb/lib/utils.js +42 -90
  80. package/.output/server/node_modules/mongodb/package.json +49 -45
  81. package/.output/server/node_modules/mongodb-connection-string-url/lib/index.js +45 -19
  82. package/.output/server/node_modules/mongodb-connection-string-url/lib/redact.js +30 -19
  83. package/.output/server/node_modules/mongodb-connection-string-url/package.json +25 -16
  84. package/.output/server/node_modules/mongoose/lib/aggregate.js +108 -127
  85. package/.output/server/node_modules/mongoose/lib/cast/bigint.js +3 -3
  86. package/.output/server/node_modules/mongoose/lib/cast/boolean.js +3 -3
  87. package/.output/server/node_modules/mongoose/lib/cast/double.js +4 -4
  88. package/.output/server/node_modules/mongoose/lib/cast/int32.js +2 -2
  89. package/.output/server/node_modules/mongoose/lib/cast/number.js +6 -6
  90. package/.output/server/node_modules/mongoose/lib/cast/string.js +3 -3
  91. package/.output/server/node_modules/mongoose/lib/cast/uuid.js +5 -48
  92. package/.output/server/node_modules/mongoose/lib/cast.js +16 -24
  93. package/.output/server/node_modules/mongoose/lib/collection.js +6 -6
  94. package/.output/server/node_modules/mongoose/lib/connection.js +108 -105
  95. package/.output/server/node_modules/mongoose/lib/cursor/aggregationCursor.js +23 -33
  96. package/.output/server/node_modules/mongoose/lib/cursor/changeStream.js +60 -40
  97. package/.output/server/node_modules/mongoose/lib/cursor/queryCursor.js +21 -25
  98. package/.output/server/node_modules/mongoose/lib/document.js +712 -531
  99. package/.output/server/node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js +85 -130
  100. package/.output/server/node_modules/mongoose/lib/drivers/node-mongodb-native/connection.js +32 -41
  101. package/.output/server/node_modules/mongoose/lib/error/cast.js +21 -12
  102. package/.output/server/node_modules/mongoose/lib/error/createCollectionsError.js +2 -2
  103. package/.output/server/node_modules/mongoose/lib/error/divergentArray.js +1 -1
  104. package/.output/server/node_modules/mongoose/lib/error/eachAsyncMultiError.js +1 -1
  105. package/.output/server/node_modules/mongoose/lib/error/index.js +3 -3
  106. package/.output/server/node_modules/mongoose/lib/error/invalidSchemaOption.js +1 -1
  107. package/.output/server/node_modules/mongoose/lib/error/messages.js +1 -0
  108. package/.output/server/node_modules/mongoose/lib/error/missingSchema.js +1 -1
  109. package/.output/server/node_modules/mongoose/lib/error/objectParameter.js +4 -5
  110. package/.output/server/node_modules/mongoose/lib/error/overwriteModel.js +1 -1
  111. package/.output/server/node_modules/mongoose/lib/error/setOptionError.js +3 -3
  112. package/.output/server/node_modules/mongoose/lib/error/strict.js +3 -3
  113. package/.output/server/node_modules/mongoose/lib/error/strictPopulate.js +2 -2
  114. package/.output/server/node_modules/mongoose/lib/error/syncIndexes.js +2 -2
  115. package/.output/server/node_modules/mongoose/lib/error/validation.js +2 -10
  116. package/.output/server/node_modules/mongoose/lib/error/validator.js +1 -1
  117. package/.output/server/node_modules/mongoose/lib/error/version.js +2 -2
  118. package/.output/server/node_modules/mongoose/lib/helpers/aggregate/prepareDiscriminatorPipeline.js +4 -4
  119. package/.output/server/node_modules/mongoose/lib/helpers/buildMiddlewareFilter.js +24 -0
  120. package/.output/server/node_modules/mongoose/lib/helpers/clone.js +35 -18
  121. package/.output/server/node_modules/mongoose/lib/helpers/common.js +5 -5
  122. package/.output/server/node_modules/mongoose/lib/helpers/cursor/eachAsync.js +4 -4
  123. package/.output/server/node_modules/mongoose/lib/helpers/discriminator/getConstructor.js +1 -1
  124. package/.output/server/node_modules/mongoose/lib/helpers/discriminator/getDiscriminatorByValue.js +1 -1
  125. package/.output/server/node_modules/mongoose/lib/helpers/discriminator/getSchemaDiscriminatorByValue.js +1 -1
  126. package/.output/server/node_modules/mongoose/lib/helpers/discriminator/mergeDiscriminatorSchema.js +10 -5
  127. package/.output/server/node_modules/mongoose/lib/helpers/document/applyDefaults.js +1 -1
  128. package/.output/server/node_modules/mongoose/lib/helpers/document/applyTimestamps.js +11 -10
  129. package/.output/server/node_modules/mongoose/lib/helpers/document/applyVirtuals.js +10 -9
  130. package/.output/server/node_modules/mongoose/lib/helpers/document/cleanModifiedSubpaths.js +1 -1
  131. package/.output/server/node_modules/mongoose/lib/helpers/document/compile.js +17 -14
  132. package/.output/server/node_modules/mongoose/lib/helpers/document/getDeepestSubdocumentForPath.js +3 -3
  133. package/.output/server/node_modules/mongoose/lib/helpers/document/getEmbeddedDiscriminatorPath.js +2 -2
  134. package/.output/server/node_modules/mongoose/lib/helpers/document/isInPathsToSave.js +24 -0
  135. package/.output/server/node_modules/mongoose/lib/helpers/get.js +1 -1
  136. package/.output/server/node_modules/mongoose/lib/helpers/indexes/decorateDiscriminatorIndexOptions.js +1 -1
  137. package/.output/server/node_modules/mongoose/lib/helpers/indexes/getRelatedIndexes.js +3 -3
  138. package/.output/server/node_modules/mongoose/lib/helpers/indexes/isIndexEqual.js +3 -4
  139. package/.output/server/node_modules/mongoose/lib/helpers/indexes/isIndexSpecEqual.js +3 -3
  140. package/.output/server/node_modules/mongoose/lib/helpers/isBsonType.js +1 -1
  141. package/.output/server/node_modules/mongoose/lib/helpers/isMongooseObject.js +1 -1
  142. package/.output/server/node_modules/mongoose/lib/helpers/isObject.js +2 -2
  143. package/.output/server/node_modules/mongoose/lib/helpers/isSimpleValidator.js +2 -2
  144. package/.output/server/node_modules/mongoose/lib/helpers/minimize.js +2 -2
  145. package/.output/server/node_modules/mongoose/lib/helpers/model/applyDefaultsToPOJO.js +2 -2
  146. package/.output/server/node_modules/mongoose/lib/helpers/model/applyHooks.js +55 -54
  147. package/.output/server/node_modules/mongoose/lib/helpers/model/applyMethods.js +2 -2
  148. package/.output/server/node_modules/mongoose/lib/helpers/model/applyStaticHooks.js +1 -48
  149. package/.output/server/node_modules/mongoose/lib/helpers/model/castBulkWrite.js +8 -12
  150. package/.output/server/node_modules/mongoose/lib/helpers/model/discriminator.js +1 -1
  151. package/.output/server/node_modules/mongoose/lib/helpers/parallelLimit.js +18 -36
  152. package/.output/server/node_modules/mongoose/lib/helpers/pluralize.js +4 -4
  153. package/.output/server/node_modules/mongoose/lib/helpers/populate/assignRawDocsToIdStructure.js +4 -11
  154. package/.output/server/node_modules/mongoose/lib/helpers/populate/assignVals.js +10 -10
  155. package/.output/server/node_modules/mongoose/lib/helpers/populate/createPopulateQueryFilter.js +3 -3
  156. package/.output/server/node_modules/mongoose/lib/helpers/populate/getModelsMapForPopulate.js +197 -69
  157. package/.output/server/node_modules/mongoose/lib/helpers/populate/getSchemaTypes.js +15 -15
  158. package/.output/server/node_modules/mongoose/lib/helpers/populate/markArraySubdocsPopulated.js +1 -1
  159. package/.output/server/node_modules/mongoose/lib/helpers/populate/modelNamesFromRefPath.js +10 -2
  160. package/.output/server/node_modules/mongoose/lib/helpers/populate/setPopulatedVirtualValue.js +5 -5
  161. package/.output/server/node_modules/mongoose/lib/helpers/printJestWarning.js +1 -1
  162. package/.output/server/node_modules/mongoose/lib/helpers/processConnectionOptions.js +1 -1
  163. package/.output/server/node_modules/mongoose/lib/helpers/projection/hasIncludedChildren.js +1 -1
  164. package/.output/server/node_modules/mongoose/lib/helpers/projection/isPathExcluded.js +3 -3
  165. package/.output/server/node_modules/mongoose/lib/helpers/projection/isSubpath.js +1 -1
  166. package/.output/server/node_modules/mongoose/lib/helpers/projection/parseProjection.js +9 -4
  167. package/.output/server/node_modules/mongoose/lib/helpers/query/cast$expr.js +8 -10
  168. package/.output/server/node_modules/mongoose/lib/helpers/query/castFilterPath.js +1 -1
  169. package/.output/server/node_modules/mongoose/lib/helpers/query/castUpdate.js +44 -38
  170. package/.output/server/node_modules/mongoose/lib/helpers/query/getEmbeddedDiscriminatorPath.js +8 -8
  171. package/.output/server/node_modules/mongoose/lib/helpers/query/handleImmutable.js +8 -8
  172. package/.output/server/node_modules/mongoose/lib/helpers/schema/applyPlugins.js +2 -2
  173. package/.output/server/node_modules/mongoose/lib/helpers/schema/applyReadConcern.js +1 -1
  174. package/.output/server/node_modules/mongoose/lib/helpers/schema/applyWriteConcern.js +4 -2
  175. package/.output/server/node_modules/mongoose/lib/helpers/schema/getIndexes.js +5 -11
  176. package/.output/server/node_modules/mongoose/lib/helpers/schema/getSubdocumentStrictValue.js +2 -2
  177. package/.output/server/node_modules/mongoose/lib/helpers/schema/handleIdOption.js +1 -1
  178. package/.output/server/node_modules/mongoose/lib/helpers/schema/idGetter.js +1 -1
  179. package/.output/server/node_modules/mongoose/lib/helpers/schematype/handleImmutable.js +1 -1
  180. package/.output/server/node_modules/mongoose/lib/helpers/setDefaultsOnInsert.js +26 -13
  181. package/.output/server/node_modules/mongoose/lib/helpers/timestamps/setDocumentTimestamps.js +2 -2
  182. package/.output/server/node_modules/mongoose/lib/helpers/timestamps/setupTimestamps.js +60 -38
  183. package/.output/server/node_modules/mongoose/lib/helpers/update/applyTimestampsToUpdate.js +13 -10
  184. package/.output/server/node_modules/mongoose/lib/helpers/update/castArrayFilters.js +4 -4
  185. package/.output/server/node_modules/mongoose/lib/helpers/update/decorateUpdateWithVersionKey.js +1 -1
  186. package/.output/server/node_modules/mongoose/lib/helpers/update/modifiedPaths.js +2 -2
  187. package/.output/server/node_modules/mongoose/lib/helpers/update/removeUnusedArrayFilters.js +7 -2
  188. package/.output/server/node_modules/mongoose/lib/helpers/updateValidators.js +58 -119
  189. package/.output/server/node_modules/mongoose/lib/model.js +940 -946
  190. package/.output/server/node_modules/mongoose/lib/mongoose.js +131 -79
  191. package/.output/server/node_modules/mongoose/lib/options/schemaArrayOptions.js +2 -2
  192. package/.output/server/node_modules/mongoose/lib/options/schemaBufferOptions.js +1 -1
  193. package/.output/server/node_modules/mongoose/lib/options/schemaDocumentArrayOptions.js +23 -0
  194. package/.output/server/node_modules/mongoose/lib/options/schemaNumberOptions.js +3 -3
  195. package/.output/server/node_modules/mongoose/lib/options/schemaObjectIdOptions.js +2 -2
  196. package/.output/server/node_modules/mongoose/lib/options/schemaStringOptions.js +6 -6
  197. package/.output/server/node_modules/mongoose/lib/options/schemaSubdocumentOptions.js +23 -0
  198. package/.output/server/node_modules/mongoose/lib/options/schemaTypeOptions.js +27 -13
  199. package/.output/server/node_modules/mongoose/lib/options/virtualOptions.js +12 -12
  200. package/.output/server/node_modules/mongoose/lib/plugins/index.js +0 -1
  201. package/.output/server/node_modules/mongoose/lib/plugins/saveSubdocs.js +84 -92
  202. package/.output/server/node_modules/mongoose/lib/plugins/sharding.js +33 -15
  203. package/.output/server/node_modules/mongoose/lib/plugins/trackTransaction.js +29 -25
  204. package/.output/server/node_modules/mongoose/lib/query.js +700 -548
  205. package/.output/server/node_modules/mongoose/lib/queryHelpers.js +34 -32
  206. package/.output/server/node_modules/mongoose/lib/schema/array.js +69 -113
  207. package/.output/server/node_modules/mongoose/lib/schema/bigint.js +18 -20
  208. package/.output/server/node_modules/mongoose/lib/schema/boolean.js +20 -22
  209. package/.output/server/node_modules/mongoose/lib/schema/buffer.js +23 -25
  210. package/.output/server/node_modules/mongoose/lib/schema/date.js +19 -21
  211. package/.output/server/node_modules/mongoose/lib/schema/decimal128.js +16 -18
  212. package/.output/server/node_modules/mongoose/lib/schema/documentArray.js +94 -131
  213. package/.output/server/node_modules/mongoose/lib/schema/documentArrayElement.js +50 -16
  214. package/.output/server/node_modules/mongoose/lib/schema/double.js +16 -18
  215. package/.output/server/node_modules/mongoose/lib/schema/index.js +1 -0
  216. package/.output/server/node_modules/mongoose/lib/schema/int32.js +17 -19
  217. package/.output/server/node_modules/mongoose/lib/schema/map.js +17 -24
  218. package/.output/server/node_modules/mongoose/lib/schema/mixed.js +14 -14
  219. package/.output/server/node_modules/mongoose/lib/schema/number.js +38 -28
  220. package/.output/server/node_modules/mongoose/lib/schema/objectId.js +18 -20
  221. package/.output/server/node_modules/mongoose/lib/schema/operators/exists.js +1 -1
  222. package/.output/server/node_modules/mongoose/lib/schema/operators/geospatial.js +1 -1
  223. package/.output/server/node_modules/mongoose/lib/schema/operators/text.js +4 -4
  224. package/.output/server/node_modules/mongoose/lib/schema/string.js +42 -27
  225. package/.output/server/node_modules/mongoose/lib/schema/subdocument.js +47 -58
  226. package/.output/server/node_modules/mongoose/lib/schema/union.js +54 -4
  227. package/.output/server/node_modules/mongoose/lib/schema/uuid.js +17 -40
  228. package/.output/server/node_modules/mongoose/lib/schema.js +235 -176
  229. package/.output/server/node_modules/mongoose/lib/schemaType.js +227 -158
  230. package/.output/server/node_modules/mongoose/lib/stateMachine.js +5 -8
  231. package/.output/server/node_modules/mongoose/lib/types/array/index.js +5 -5
  232. package/.output/server/node_modules/mongoose/lib/types/array/methods/index.js +27 -28
  233. package/.output/server/node_modules/mongoose/lib/types/arraySubdocument.js +11 -11
  234. package/.output/server/node_modules/mongoose/lib/types/buffer.js +15 -15
  235. package/.output/server/node_modules/mongoose/lib/types/decimal128.js +1 -1
  236. package/.output/server/node_modules/mongoose/lib/types/documentArray/index.js +4 -4
  237. package/.output/server/node_modules/mongoose/lib/types/documentArray/methods/index.js +15 -13
  238. package/.output/server/node_modules/mongoose/lib/types/double.js +1 -1
  239. package/.output/server/node_modules/mongoose/lib/types/map.js +20 -71
  240. package/.output/server/node_modules/mongoose/lib/types/objectid.js +1 -1
  241. package/.output/server/node_modules/mongoose/lib/types/subdocument.js +32 -81
  242. package/.output/server/node_modules/mongoose/lib/types/uuid.js +1 -1
  243. package/.output/server/node_modules/mongoose/lib/utils.js +91 -70
  244. package/.output/server/node_modules/mongoose/lib/validOptions.js +4 -3
  245. package/.output/server/node_modules/mongoose/lib/virtualType.js +18 -18
  246. package/.output/server/node_modules/mongoose/package.json +46 -63
  247. package/.output/server/node_modules/mquery/lib/collection/collection.js +3 -1
  248. package/.output/server/node_modules/mquery/lib/collection/node.js +17 -3
  249. package/.output/server/node_modules/mquery/lib/mquery.js +136 -93
  250. package/.output/server/node_modules/mquery/lib/permissions.js +21 -6
  251. package/.output/server/node_modules/mquery/package.json +4 -7
  252. package/.output/server/package.json +7 -9
  253. package/package.json +3 -3
  254. package/.output/public/_nuxt/builds/meta/0d6006db-fbb0-4297-85cf-bf92ceafcb79.json +0 -1
  255. package/.output/server/node_modules/debug/package.json +0 -64
  256. package/.output/server/node_modules/debug/src/browser.js +0 -272
  257. package/.output/server/node_modules/debug/src/common.js +0 -292
  258. package/.output/server/node_modules/debug/src/index.js +0 -10
  259. package/.output/server/node_modules/debug/src/node.js +0 -263
  260. package/.output/server/node_modules/mongodb/lib/client-side-encryption/crypto_callbacks.js +0 -81
  261. package/.output/server/node_modules/mongodb/lib/resource_management.js +0 -58
  262. package/.output/server/node_modules/mongoose/lib/browserDocument.js +0 -101
  263. package/.output/server/node_modules/mongoose/lib/documentProvider.js +0 -30
  264. package/.output/server/node_modules/mongoose/lib/helpers/createJSONSchemaTypeDefinition.js +0 -24
  265. package/.output/server/node_modules/mongoose/lib/helpers/promiseOrCallback.js +0 -54
  266. package/.output/server/node_modules/mongoose/lib/plugins/validateBeforeSave.js +0 -51
  267. package/.output/server/node_modules/supports-color/index.js +0 -202
  268. package/.output/server/node_modules/supports-color/package.json +0 -64
@@ -8,7 +8,6 @@ const SchemaType = require('../schemaType');
8
8
  const MongooseError = require('../error/index');
9
9
  const SchemaStringOptions = require('../options/schemaStringOptions');
10
10
  const castString = require('../cast/string');
11
- const createJSONSchemaTypeDefinition = require('../helpers/createJSONSchemaTypeDefinition');
12
11
  const utils = require('../utils');
13
12
  const isBsonType = require('../helpers/isBsonType');
14
13
 
@@ -17,9 +16,9 @@ const CastError = SchemaType.CastError;
17
16
  /**
18
17
  * String SchemaType constructor.
19
18
  *
20
- * @param {String} key
21
- * @param {Object} options
22
- * @param {Object} schemaOptions
19
+ * @param {string} key
20
+ * @param {object} options
21
+ * @param {object} schemaOptions
23
22
  * @param {Schema} parentSchema
24
23
  * @inherits SchemaType
25
24
  * @api public
@@ -111,7 +110,7 @@ SchemaString._defaultCaster = v => {
111
110
  * #### Example:
112
111
  *
113
112
  * // Make all numbers round down
114
- * mongoose.Schema.String.get(v => v.toLowerCase());
113
+ * mongoose.Schema.Types.String.get(v => v.toLowerCase());
115
114
  *
116
115
  * const Model = mongoose.model('Test', new Schema({ test: String }));
117
116
  * new Model({ test: 'FOO' }).test; // 'foo'
@@ -131,13 +130,13 @@ SchemaString.get = SchemaType.get;
131
130
  * #### Example:
132
131
  *
133
132
  * // Make all strings have option `trim` equal to true.
134
- * mongoose.Schema.String.set('trim', true);
133
+ * mongoose.Schema.Types.String.set('trim', true);
135
134
  *
136
135
  * const User = mongoose.model('User', new Schema({ name: String }));
137
136
  * new User({ name: ' John Doe ' }).name; // 'John Doe'
138
137
  *
139
- * @param {String} option The option you'd like to set the value for
140
- * @param {Any} value value for option
138
+ * @param {string} option The option you'd like to set the value for
139
+ * @param {any} value value for option
141
140
  * @return {undefined}
142
141
  * @function set
143
142
  * @static
@@ -204,7 +203,7 @@ SchemaString.checkRequired = SchemaType.checkRequired;
204
203
  * await m.save();
205
204
  * // success
206
205
  *
207
- * @param {...String|Object} [args] enumeration values
206
+ * @param {...string|object} [args] enumeration values
208
207
  * @return {SchemaType} this
209
208
  * @see Customized Error Messages https://mongoosejs.com/docs/api/error.html#Error.messages
210
209
  * @see Enums in JavaScript https://masteringjs.io/tutorials/fundamentals/enum
@@ -402,8 +401,8 @@ SchemaString.prototype.trim = function(shouldTrim) {
402
401
  * console.log(String(err)) // ValidationError: The value of path `postalCode` (`9512`) is shorter than the minimum length (5).
403
402
  * })
404
403
  *
405
- * @param {Number} value minimum string length
406
- * @param {String} [message] optional custom error message
404
+ * @param {number} value minimum string length
405
+ * @param {string} [message] optional custom error message
407
406
  * @return {SchemaType} this
408
407
  * @see Customized Error Messages https://mongoosejs.com/docs/api/error.html#Error.messages
409
408
  * @api public
@@ -416,7 +415,7 @@ SchemaString.prototype.minlength = function(value, message) {
416
415
  }, this);
417
416
  }
418
417
 
419
- if (value !== null && value !== undefined) {
418
+ if (value != null) {
420
419
  let msg = message || MongooseError.messages.String.minlength;
421
420
  msg = msg.replace(/{MINLENGTH}/, value);
422
421
  this.validators.push({
@@ -458,8 +457,8 @@ SchemaString.prototype.minLength = SchemaString.prototype.minlength;
458
457
  * console.log(String(err)) // ValidationError: The value of path `postalCode` (`9512512345`) exceeds the maximum allowed length (9).
459
458
  * })
460
459
  *
461
- * @param {Number} value maximum string length
462
- * @param {String} [message] optional custom error message
460
+ * @param {number} value maximum string length
461
+ * @param {string} [message] optional custom error message
463
462
  * @return {SchemaType} this
464
463
  * @see Customized Error Messages https://mongoosejs.com/docs/api/error.html#Error.messages
465
464
  * @api public
@@ -472,14 +471,16 @@ SchemaString.prototype.maxlength = function(value, message) {
472
471
  }, this);
473
472
  }
474
473
 
475
- if (value !== null && value !== undefined) {
474
+ if (value != null) {
476
475
  let msg = message || MongooseError.messages.String.maxlength;
477
- msg = msg.replace(/{MAXLENGTH}/, value);
476
+ if (typeof msg !== 'function') {
477
+ msg = msg.replace(/{MAXLENGTH}/, value);
478
+ }
478
479
  this.validators.push({
479
480
  validator: this.maxlengthValidator = function(v) {
480
481
  return v === null || v.length <= value;
481
482
  },
482
- message: msg,
483
+ message: formatMaxLengthValidatorMessage(msg),
483
484
  type: 'maxlength',
484
485
  maxlength: value
485
486
  });
@@ -522,7 +523,7 @@ SchemaString.prototype.maxLength = SchemaString.prototype.maxlength;
522
523
  * const s = new Schema({ name: { type: String, match: /^a/, required: true }})
523
524
  *
524
525
  * @param {RegExp} regExp regular expression to test against
525
- * @param {String} [message] optional custom error message
526
+ * @param {string} [message] optional custom error message
526
527
  * @return {SchemaType} this
527
528
  * @see Customized Error Messages https://mongoosejs.com/docs/api/error.html#Error.messages
528
529
  * @api public
@@ -563,9 +564,9 @@ SchemaString.prototype.match = function match(regExp, message) {
563
564
  * has positive length. The `required` validator **will** fail for empty
564
565
  * strings.
565
566
  *
566
- * @param {Any} value
567
+ * @param {any} value
567
568
  * @param {Document} doc
568
- * @return {Boolean}
569
+ * @return {boolean}
569
570
  * @api public
570
571
  */
571
572
 
@@ -605,7 +606,7 @@ SchemaString.prototype.cast = function(value, doc, init, prev, options) {
605
606
 
606
607
  try {
607
608
  return castString(value);
608
- } catch (error) {
609
+ } catch {
609
610
  throw new CastError('string', value, this.path, null, this);
610
611
  }
611
612
  };
@@ -680,7 +681,7 @@ Object.defineProperty(SchemaString.prototype, '$conditionalHandlers', {
680
681
  /**
681
682
  * Casts contents for queries.
682
683
  *
683
- * @param {String} $conditional
684
+ * @param {string} $conditional
684
685
  * @param {any} [val]
685
686
  * @api private
686
687
  */
@@ -712,14 +713,13 @@ SchemaString.prototype.castForQuery = function($conditional, val, context) {
712
713
  /**
713
714
  * Returns this schema type's representation in a JSON schema.
714
715
  *
715
- * @param [options]
716
- * @param [options.useBsonType=false] If true, return a representation with `bsonType` for use with MongoDB's `$jsonSchema`.
717
- * @returns {Object} JSON schema properties
716
+ * @param {object} [options]
717
+ * @param {boolean} [options.useBsonType=false] If true, return a representation with `bsonType` for use with MongoDB's `$jsonSchema`.
718
+ * @returns {object} JSON schema properties
718
719
  */
719
720
 
720
721
  SchemaString.prototype.toJSONSchema = function toJSONSchema(options) {
721
- const isRequired = this.options.required && typeof this.options.required !== 'function';
722
- return createJSONSchemaTypeDefinition('string', 'string', options?.useBsonType, isRequired);
722
+ return this._createJSONSchemaTypeDefinition('string', 'string', options);
723
723
  };
724
724
 
725
725
  SchemaString.prototype.autoEncryptionType = function autoEncryptionType() {
@@ -731,3 +731,18 @@ SchemaString.prototype.autoEncryptionType = function autoEncryptionType() {
731
731
  */
732
732
 
733
733
  module.exports = SchemaString;
734
+
735
+ function formatMaxLengthValidatorMessage(msg) {
736
+ return function(props, doc) {
737
+ if (typeof msg === 'function') {
738
+ return MongooseError.ValidatorError.prototype.formatMessage(msg, props, doc);
739
+ }
740
+
741
+ if (typeof msg === 'string' && typeof props.value === 'string' && props.value.length > 30) {
742
+ props = Object.assign({}, props, {
743
+ value: props.value.slice(0, 30) + '...'
744
+ });
745
+ }
746
+ return MongooseError.ValidatorError.prototype.formatMessage(msg, props, doc);
747
+ };
748
+ }
@@ -12,7 +12,6 @@ const SchemaType = require('../schemaType');
12
12
  const applyDefaults = require('../helpers/document/applyDefaults');
13
13
  const $exists = require('./operators/exists');
14
14
  const castToNumber = require('./operators/helpers').castToNumber;
15
- const createJSONSchemaTypeDefinition = require('../helpers/createJSONSchemaTypeDefinition');
16
15
  const discriminator = require('../helpers/model/discriminator');
17
16
  const geospatial = require('./operators/geospatial');
18
17
  const getConstructor = require('../helpers/discriminator/getConstructor');
@@ -30,8 +29,8 @@ module.exports = SchemaSubdocument;
30
29
  * Single nested subdocument SchemaType constructor.
31
30
  *
32
31
  * @param {Schema} schema
33
- * @param {String} path
34
- * @param {Object} options
32
+ * @param {string} path
33
+ * @param {object} options
35
34
  * @param {Schema} parentSchema
36
35
  * @inherits SchemaType
37
36
  * @api public
@@ -41,8 +40,7 @@ function SchemaSubdocument(schema, path, options, parentSchema) {
41
40
  if (schema.options.timeseries) {
42
41
  throw new InvalidSchemaOptionError(path, 'timeseries');
43
42
  }
44
- const schemaTypeIdOption = SchemaSubdocument.defaultOptions &&
45
- SchemaSubdocument.defaultOptions._id;
43
+ const schemaTypeIdOption = SchemaSubdocument.defaultOptions?._id;
46
44
  if (schemaTypeIdOption != null) {
47
45
  options = options || {};
48
46
  options._id = schemaTypeIdOption;
@@ -50,9 +48,9 @@ function SchemaSubdocument(schema, path, options, parentSchema) {
50
48
 
51
49
  schema = handleIdOption(schema, options);
52
50
 
53
- this.caster = _createConstructor(schema, null, options);
54
- this.caster.path = path;
55
- this.caster.prototype.$basePath = path;
51
+ this.Constructor = _createConstructor(schema, null, options);
52
+ this.Constructor.path = path;
53
+ this.Constructor.prototype.$basePath = path;
56
54
  this.schema = schema;
57
55
  this.$isSingleNested = true;
58
56
  this.base = schema.base;
@@ -87,7 +85,7 @@ function _createConstructor(schema, baseClass, options) {
87
85
 
88
86
  schema._preCompile();
89
87
 
90
- const proto = baseClass != null ? baseClass.prototype : SubdocumentType.prototype;
88
+ const proto = baseClass?.prototype ?? SubdocumentType.prototype;
91
89
  _embedded.prototype = Object.create(proto);
92
90
  _embedded.prototype.$__setSchema(schema);
93
91
  _embedded.prototype.constructor = _embedded;
@@ -128,7 +126,7 @@ const $conditionalHandlers = { ...SchemaType.prototype.$conditionalHandlers };
128
126
  * locations for use with $geoWithin.
129
127
  * https://www.mongodb.com/docs/manual/reference/operator/query/geoWithin/
130
128
  *
131
- * @param {Object} val
129
+ * @param {object} val
132
130
  * @api private
133
131
  */
134
132
 
@@ -172,27 +170,27 @@ Object.defineProperty(SchemaSubdocument.prototype, '$conditionalHandlers', {
172
170
  /**
173
171
  * Casts contents
174
172
  *
175
- * @param {Object} value
173
+ * @param {object} value
176
174
  * @api private
177
175
  */
178
176
 
179
177
  SchemaSubdocument.prototype.cast = function(val, doc, init, priorVal, options) {
180
- if (val && val.$isSingleNested && val.parent === doc) {
178
+ if (val?.$isSingleNested && val.parent === doc) {
181
179
  return val;
182
180
  }
183
181
 
184
- if (val != null && (typeof val !== 'object' || Array.isArray(val))) {
182
+ if (!init && val != null && (typeof val !== 'object' || Array.isArray(val))) {
185
183
  throw new ObjectExpectedError(this.path, val);
186
184
  }
187
185
 
188
186
  const discriminatorKeyPath = this.schema.path(this.schema.options.discriminatorKey);
189
187
  const defaultDiscriminatorValue = discriminatorKeyPath == null ? null : discriminatorKeyPath.getDefault(doc);
190
- const Constructor = getConstructor(this.caster, val, defaultDiscriminatorValue);
188
+ const Constructor = getConstructor(this.Constructor, val, defaultDiscriminatorValue);
191
189
 
192
190
  let subdoc;
193
191
 
194
192
  // Only pull relevant selected paths and pull out the base path
195
- const parentSelected = doc && doc.$__ && doc.$__.selected;
193
+ const parentSelected = doc?.$__?.selected;
196
194
  const path = this.path;
197
195
  const selected = parentSelected == null ? null : Object.keys(parentSelected).reduce((obj, key) => {
198
196
  if (key.startsWith(path + '.')) {
@@ -202,7 +200,7 @@ SchemaSubdocument.prototype.cast = function(val, doc, init, priorVal, options) {
202
200
  return obj;
203
201
  }, null);
204
202
  if (init) {
205
- subdoc = new Constructor(void 0, selected, doc, false, { defaults: false });
203
+ subdoc = new Constructor(void 0, selected, doc, { defaults: false });
206
204
  delete subdoc.$__.defaults;
207
205
  // Don't pass `path` to $init - it's only for the subdocument itself, not its fields.
208
206
  // For change tracking, subdocuments use relative paths internally.
@@ -216,11 +214,11 @@ SchemaSubdocument.prototype.cast = function(val, doc, init, priorVal, options) {
216
214
  applyDefaults(subdoc, selected, exclude);
217
215
  } else {
218
216
  options = Object.assign({}, options, { priorDoc: priorVal });
219
- if (Object.keys(val).length === 0) {
220
- return new Constructor({}, selected, doc, undefined, options);
217
+ if (utils.hasOwnKeys(val) === false) {
218
+ return new Constructor({}, selected, doc, options);
221
219
  }
222
220
 
223
- return new Constructor(val, selected, doc, undefined, options);
221
+ return new Constructor(val, selected, doc, options);
224
222
  }
225
223
 
226
224
  return subdoc;
@@ -247,7 +245,7 @@ SchemaSubdocument.prototype.castForQuery = function($conditional, val, context,
247
245
  return val;
248
246
  }
249
247
 
250
- const Constructor = getConstructor(this.caster, val);
248
+ const Constructor = getConstructor(this.Constructor, val);
251
249
  if (val instanceof Constructor) {
252
250
  return val;
253
251
  }
@@ -256,9 +254,7 @@ SchemaSubdocument.prototype.castForQuery = function($conditional, val, context,
256
254
  val = this._applySetters(val, context);
257
255
  }
258
256
 
259
- const overrideStrict = options != null && options.strict != null ?
260
- options.strict :
261
- void 0;
257
+ const overrideStrict = options?.strict ?? void 0;
262
258
 
263
259
  try {
264
260
  val = new Constructor(val, overrideStrict);
@@ -275,33 +271,27 @@ SchemaSubdocument.prototype.castForQuery = function($conditional, val, context,
275
271
  /**
276
272
  * Async validation on this single nested doc.
277
273
  *
278
- * @api private
274
+ * @api public
279
275
  */
280
276
 
281
- SchemaSubdocument.prototype.doValidate = function(value, fn, scope, options) {
282
- const Constructor = getConstructor(this.caster, value);
277
+ SchemaSubdocument.prototype.doValidate = async function doValidate(value, scope, options) {
278
+ const Constructor = getConstructor(this.Constructor, value);
283
279
 
284
280
  if (value && !(value instanceof Constructor)) {
285
- value = new Constructor(value, null, (scope != null && scope.$__ != null) ? scope : null);
281
+ value = new Constructor(value, null, scope?.$__ != null ? scope : null);
286
282
  }
287
283
 
288
- if (options && options.skipSchemaValidators) {
284
+ if (options?.skipSchemaValidators) {
289
285
  if (!value) {
290
- return fn(null);
286
+ return;
291
287
  }
292
- return value.validate().then(() => fn(null), err => fn(err));
288
+ return value.validate();
293
289
  }
294
290
 
295
- SchemaType.prototype.doValidate.call(this, value, function(error) {
296
- if (error) {
297
- return fn(error);
298
- }
299
- if (!value) {
300
- return fn(null);
301
- }
302
-
303
- value.validate().then(() => fn(null), err => fn(err));
304
- }, scope, options);
291
+ await SchemaType.prototype.doValidate.call(this, value, scope, options);
292
+ if (value != null) {
293
+ await value.validate();
294
+ }
305
295
  };
306
296
 
307
297
  /**
@@ -311,7 +301,7 @@ SchemaSubdocument.prototype.doValidate = function(value, fn, scope, options) {
311
301
  */
312
302
 
313
303
  SchemaSubdocument.prototype.doValidateSync = function(value, scope, options) {
314
- if (!options || !options.skipSchemaValidators) {
304
+ if (!options?.skipSchemaValidators) {
315
305
  const schemaTypeError = SchemaType.prototype.doValidateSync.call(this, value, scope);
316
306
  if (schemaTypeError) {
317
307
  return schemaTypeError;
@@ -334,11 +324,11 @@ SchemaSubdocument.prototype.doValidateSync = function(value, scope, options) {
334
324
  * const singleNestedPath = parentSchema.path('shape');
335
325
  * singleNestedPath.discriminator('Circle', Schema({ radius: Number }));
336
326
  *
337
- * @param {String} name
327
+ * @param {string} name
338
328
  * @param {Schema} schema fields to add to the schema for instances of this sub-class
339
- * @param {Object|string} [options] If string, same as `options.value`.
340
- * @param {String} [options.value] the string stored in the `discriminatorKey` property. If not specified, Mongoose uses the `name` parameter.
341
- * @param {Boolean} [options.clone=true] By default, `discriminator()` clones the given `schema`. Set to `false` to skip cloning.
329
+ * @param {object|string} [options] If string, same as `options.value`.
330
+ * @param {string} [options.value] the string stored in the `discriminatorKey` property. If not specified, Mongoose uses the `name` parameter.
331
+ * @param {boolean} [options.clone=true] By default, `discriminator()` clones the given `schema`. Set to `false` to skip cloning.
342
332
  * @return {Function} the constructor Mongoose will use for creating instances of this discriminator model
343
333
  * @see discriminators https://mongoosejs.com/docs/discriminators.html
344
334
  * @api public
@@ -355,11 +345,11 @@ SchemaSubdocument.prototype.discriminator = function(name, schema, options) {
355
345
  schema = schema.clone();
356
346
  }
357
347
 
358
- schema = discriminator(this.caster, name, schema, value, null, null, options.overwriteExisting);
348
+ schema = discriminator(this.Constructor, name, schema, value, null, null, options.overwriteExisting);
359
349
 
360
- this.caster.discriminators[name] = _createConstructor(schema, this.caster);
350
+ this.Constructor.discriminators[name] = _createConstructor(schema, this.Constructor);
361
351
 
362
- return this.caster.discriminators[name];
352
+ return this.Constructor.discriminators[name];
363
353
  };
364
354
 
365
355
  /*!
@@ -373,11 +363,11 @@ SchemaSubdocument.defaultOptions = {};
373
363
  *
374
364
  * #### Example:
375
365
  *
376
- * // Make all numbers have option `min` equal to 0.
377
- * mongoose.Schema.Subdocument.set('required', true);
366
+ * // Make all subdocuments required by default.
367
+ * mongoose.Schema.Types.Subdocument.set('required', true);
378
368
  *
379
- * @param {String} option The option you'd like to set the value for
380
- * @param {Any} value value for option
369
+ * @param {string} option The option you'd like to set the value for
370
+ * @param {any} value value for option
381
371
  * @return {void}
382
372
  * @function set
383
373
  * @static
@@ -423,7 +413,7 @@ SchemaSubdocument.prototype.clone = function() {
423
413
  if (this.requiredValidator !== undefined) {
424
414
  schematype.requiredValidator = this.requiredValidator;
425
415
  }
426
- schematype.caster.discriminators = Object.assign({}, this.caster.discriminators);
416
+ schematype.Constructor.discriminators = Object.assign({}, this.Constructor.discriminators);
427
417
  schematype._appliedDiscriminators = this._appliedDiscriminators;
428
418
  return schematype;
429
419
  };
@@ -431,15 +421,14 @@ SchemaSubdocument.prototype.clone = function() {
431
421
  /**
432
422
  * Returns this schema type's representation in a JSON schema.
433
423
  *
434
- * @param [options]
435
- * @param [options.useBsonType=false] If true, return a representation with `bsonType` for use with MongoDB's `$jsonSchema`.
436
- * @returns {Object} JSON schema properties
424
+ * @param {object} [options]
425
+ * @param {boolean} [options.useBsonType=false] If true, return a representation with `bsonType` for use with MongoDB's `$jsonSchema`.
426
+ * @returns {object} JSON schema properties
437
427
  */
438
428
 
439
429
  SchemaSubdocument.prototype.toJSONSchema = function toJSONSchema(options) {
440
- const isRequired = this.options.required && typeof this.options.required !== 'function';
441
430
  return {
442
431
  ...this.schema.toJSONSchema(options),
443
- ...createJSONSchemaTypeDefinition('object', 'object', options?.useBsonType, isRequired)
432
+ ...this._createJSONSchemaTypeDefinition('object', 'object', options)
444
433
  };
445
434
  };
@@ -17,17 +17,18 @@ class Union extends SchemaType {
17
17
  /**
18
18
  * Create a Union schema type.
19
19
  *
20
- * @param {String} key the path in the schema for this schema type
21
- * @param {Object} options SchemaType-specific options (must have 'of' as array)
22
- * @param {Object} schemaOptions additional options from the schema this schematype belongs to
20
+ * @param {string} key the path in the schema for this schema type
21
+ * @param {object} options SchemaType-specific options (must have 'of' as array)
22
+ * @param {object} schemaOptions additional options from the schema this schematype belongs to
23
23
  * @param {Schema} parentSchema the schema this schematype belongs to
24
24
  */
25
25
  constructor(key, options, schemaOptions, parentSchema) {
26
26
  super(key, options, 'Union', parentSchema);
27
- if (!options || !Array.isArray(options.of) || options.of.length === 0) {
27
+ if (!Array.isArray(options?.of) || options.of.length === 0) {
28
28
  throw new Error('Union schema type requires an array of types');
29
29
  }
30
30
  this.schemaTypes = options.of.map(obj => parentSchema.interpretAsType(key, obj, schemaOptions));
31
+ this.$isSchemaUnion = true;
31
32
  }
32
33
 
33
34
  cast(val, doc, init, prev, options) {
@@ -90,12 +91,61 @@ class Union extends SchemaType {
90
91
  throw lastError;
91
92
  }
92
93
 
94
+ async doValidate(value, scope, options) {
95
+ if (options && options.skipSchemaValidators) {
96
+ if (value != null && typeof value.validate === 'function') {
97
+ return value.validate();
98
+ }
99
+ return;
100
+ }
101
+
102
+ await super.doValidate(value, scope, options);
103
+ if (value != null && typeof value.validate === 'function') {
104
+ await value.validate();
105
+ }
106
+ }
107
+
108
+ doValidateSync(value, scope, options) {
109
+ if (!options || !options.skipSchemaValidators) {
110
+ const schemaTypeError = super.doValidateSync(value, scope, options);
111
+ if (schemaTypeError) {
112
+ return schemaTypeError;
113
+ }
114
+ }
115
+ if (value != null && typeof value.validateSync === 'function') {
116
+ return value.validateSync();
117
+ }
118
+ }
119
+
93
120
  clone() {
94
121
  const schematype = super.clone();
95
122
 
96
123
  schematype.schemaTypes = this.schemaTypes.map(schemaType => schemaType.clone());
97
124
  return schematype;
98
125
  }
126
+
127
+ /**
128
+ * Returns this schema type's representation in a JSON schema.
129
+ *
130
+ * @param {object} [options]
131
+ * @param {boolean} [options.useBsonType=false] If true, return a representation with `bsonType` for use with MongoDB's `$jsonSchema`.
132
+ * @returns {object} JSON schema properties
133
+ */
134
+ toJSONSchema(options) {
135
+ const isRequired = this.options.required && typeof this.options.required !== 'function';
136
+ const childOptions = { ...options, _overrideRequired: true };
137
+ const jsonSchemas = this.schemaTypes.map(schemaType => schemaType.toJSONSchema(childOptions));
138
+ if (isRequired) {
139
+ return { anyOf: jsonSchemas };
140
+ }
141
+
142
+ return {
143
+ anyOf: [
144
+ options?.useBsonType ? { bsonType: 'null' } : { type: 'null' },
145
+ ...jsonSchemas
146
+ ]
147
+ };
148
+ }
99
149
  }
100
150
 
101
151
  /**
@@ -4,21 +4,18 @@
4
4
 
5
5
  'use strict';
6
6
 
7
- const MongooseBuffer = require('../types/buffer');
8
7
  const SchemaType = require('../schemaType');
9
8
  const CastError = SchemaType.CastError;
10
9
  const castUUID = require('../cast/uuid');
11
- const createJSONSchemaTypeDefinition = require('../helpers/createJSONSchemaTypeDefinition');
12
10
  const utils = require('../utils');
13
11
  const handleBitwiseOperator = require('./operators/bitwise');
14
12
 
15
13
  const UUID_FORMAT = castUUID.UUID_FORMAT;
16
- const Binary = MongooseBuffer.Binary;
17
14
 
18
15
  /**
19
16
  * Convert binary to a uuid string
20
- * @param {Buffer|Binary|String} uuidBin The value to process
21
- * @returns {String} The completed uuid-string
17
+ * @param {Buffer|Binary|string} uuidBin The value to process
18
+ * @returns {string} The completed uuid-string
22
19
  * @api private
23
20
  */
24
21
  function binaryToString(uuidBin) {
@@ -35,9 +32,9 @@ function binaryToString(uuidBin) {
35
32
  /**
36
33
  * UUIDv1 SchemaType constructor.
37
34
  *
38
- * @param {String} key
39
- * @param {Object} options
40
- * @param {Object} _schemaOptions
35
+ * @param {string} key
36
+ * @param {object} options
37
+ * @param {object} _schemaOptions
41
38
  * @param {Schema} parentSchema
42
39
  * @inherits SchemaType
43
40
  * @api public
@@ -45,21 +42,6 @@ function binaryToString(uuidBin) {
45
42
 
46
43
  function SchemaUUID(key, options, _schemaOptions, parentSchema) {
47
44
  SchemaType.call(this, key, options, 'UUID', parentSchema);
48
- this.getters.push(function(value) {
49
- // For populated
50
- if (value != null && value.$__ != null) {
51
- return value;
52
- }
53
- if (Buffer.isBuffer(value)) {
54
- return binaryToString(value);
55
- } else if (value instanceof Binary) {
56
- return binaryToString(value.buffer);
57
- } else if (utils.isPOJO(value) && value.type === 'Buffer' && Array.isArray(value.data)) {
58
- // Cloned buffers look like `{ type: 'Buffer', data: [5, 224, ...] }`
59
- return binaryToString(Buffer.from(value.data));
60
- }
61
- return value;
62
- });
63
45
  }
64
46
 
65
47
  /**
@@ -115,8 +97,8 @@ SchemaUUID.get = SchemaType.get;
115
97
  * const User = mongoose.model('User', new Schema({ test: mongoose.UUID }));
116
98
  * new User({ }).validateSync().errors.test.message; // Path `test` is required.
117
99
  *
118
- * @param {String} option The option you'd like to set the value for
119
- * @param {Any} value value for option
100
+ * @param {string} option The option you'd like to set the value for
101
+ * @param {any} value value for option
120
102
  * @return {undefined}
121
103
  * @function set
122
104
  * @static
@@ -183,8 +165,8 @@ SchemaUUID.checkRequired = SchemaType.checkRequired;
183
165
  /**
184
166
  * Check if the given value satisfies a required validator.
185
167
  *
186
- * @param {Any} value
187
- * @return {Boolean}
168
+ * @param {any} value
169
+ * @return {boolean}
188
170
  * @api public
189
171
  */
190
172
 
@@ -198,9 +180,9 @@ SchemaUUID.prototype.checkRequired = function checkRequired(value) {
198
180
  /**
199
181
  * Casts to UUID
200
182
  *
201
- * @param {Object} value
202
- * @param {Object} doc
203
- * @param {Boolean} init whether this is an initialization cast
183
+ * @param {object} value
184
+ * @param {object} doc
185
+ * @param {boolean} init whether this is an initialization cast
204
186
  * @api private
205
187
  */
206
188
 
@@ -251,11 +233,7 @@ const $conditionalHandlers = {
251
233
  $bitsAllSet: handleBitwiseOperator,
252
234
  $bitsAnySet: handleBitwiseOperator,
253
235
  $all: handleArray,
254
- $gt: handleSingle,
255
- $gte: handleSingle,
256
236
  $in: handleArray,
257
- $lt: handleSingle,
258
- $lte: handleSingle,
259
237
  $ne: handleSingle,
260
238
  $nin: handleArray
261
239
  };
@@ -278,7 +256,7 @@ Object.defineProperty(SchemaUUID.prototype, '$conditionalHandlers', {
278
256
  /**
279
257
  * Casts contents for queries.
280
258
  *
281
- * @param {String} $conditional
259
+ * @param {string} $conditional
282
260
  * @param {any} val
283
261
  * @api private
284
262
  */
@@ -305,14 +283,13 @@ SchemaUUID.prototype.castForQuery = function($conditional, val, context) {
305
283
  /**
306
284
  * Returns this schema type's representation in a JSON schema.
307
285
  *
308
- * @param [options]
309
- * @param [options.useBsonType=false] If true, return a representation with `bsonType` for use with MongoDB's `$jsonSchema`.
310
- * @returns {Object} JSON schema properties
286
+ * @param {object} [options]
287
+ * @param {boolean} [options.useBsonType=false] If true, return a representation with `bsonType` for use with MongoDB's `$jsonSchema`.
288
+ * @returns {object} JSON schema properties
311
289
  */
312
290
 
313
291
  SchemaUUID.prototype.toJSONSchema = function toJSONSchema(options) {
314
- const isRequired = this.options.required && typeof this.options.required !== 'function';
315
- return createJSONSchemaTypeDefinition('string', 'binData', options?.useBsonType, isRequired);
292
+ return this._createJSONSchemaTypeDefinition('string', 'binData', options);
316
293
  };
317
294
 
318
295
  SchemaUUID.prototype.autoEncryptionType = function autoEncryptionType() {