@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.
- package/.output/nitro.json +1 -1
- package/.output/public/_nuxt/{Db4IAypj.js → 0J_bLG6U.js} +1 -1
- package/.output/public/_nuxt/{Y39o1QEi.js → 5KLjKHc1.js} +1 -1
- package/.output/public/_nuxt/{B4zoPYF-.js → B2UrsJHg.js} +1 -1
- package/.output/public/_nuxt/{BSqjh6Vk.js → BC5hGokz.js} +1 -1
- package/.output/public/_nuxt/{BS4yU4O0.js → BJwN20Xm.js} +1 -1
- package/.output/public/_nuxt/{D8_n84hl.js → BMgDPqps.js} +1 -1
- package/.output/public/_nuxt/{CqNsQbt9.js → B_sGF2qN.js} +1 -1
- package/.output/public/_nuxt/{NAqlztEN.js → BeaJ7I-K.js} +10 -10
- package/.output/public/_nuxt/{WZ0WK9cR.js → BkE1sm_1.js} +1 -1
- package/.output/public/_nuxt/{kBtP64Rx.js → CADbZwE5.js} +1 -1
- package/.output/public/_nuxt/{B8qGaxNm.js → CB0WRoVi.js} +1 -1
- package/.output/public/_nuxt/{BV6uALfO.js → CCh0PVV0.js} +1 -1
- package/.output/public/_nuxt/{CP9Z7-_9.js → Cr0GW7rA.js} +1 -1
- package/.output/public/_nuxt/{DeCqoVOS.js → DJe7Wxdv.js} +1 -1
- package/.output/public/_nuxt/{dBZQW7JD.js → DRBrUaE5.js} +1 -1
- package/.output/public/_nuxt/{Db19R32y.js → DV2n9B6m.js} +1 -1
- package/.output/public/_nuxt/{CvnpbYw0.js → DVD-jGiv.js} +1 -1
- package/.output/public/_nuxt/{BWajNATZ.js → Dk9qGA5X.js} +3 -3
- package/.output/public/_nuxt/builds/latest.json +1 -1
- package/.output/public/_nuxt/builds/meta/dc761332-547d-4953-b51d-b2d453009b48.json +1 -0
- package/.output/public/_nuxt/error-404.64pZEiDn.css +1 -0
- package/.output/public/_nuxt/error-500.DHOpI0Ir.css +1 -0
- package/.output/public/_nuxt/{BoHhCIKW.js → koEZfutw.js} +3 -3
- package/.output/public/_nuxt/{B_782F4p.js → r6LdR7DN.js} +1 -1
- package/.output/public/_nuxt/{BEI71c6K.js → rEfOp38p.js} +1 -1
- package/.output/server/chunks/_/error-500.mjs.map +1 -1
- package/.output/server/chunks/build/client.precomputed.mjs +1 -1
- package/.output/server/chunks/build/{error-404-8tbBXju4.mjs → error-404-BN-7rNE4.mjs} +4 -4
- package/.output/server/chunks/build/error-404-BN-7rNE4.mjs.map +1 -0
- package/.output/server/chunks/build/error-404-styles.Byx46oLR.mjs +8 -0
- package/.output/server/chunks/build/error-404-styles.Byx46oLR.mjs.map +1 -0
- package/.output/server/chunks/build/{error-500-DxFsom1i.mjs → error-500-DhIQ-2yt.mjs} +4 -4
- package/.output/server/chunks/build/error-500-DhIQ-2yt.mjs.map +1 -0
- package/.output/server/chunks/build/error-500-styles.BL3UT0Wa.mjs +8 -0
- package/.output/server/chunks/build/error-500-styles.BL3UT0Wa.mjs.map +1 -0
- package/.output/server/chunks/build/{index-BB-Clavm.mjs → index-Dnrh1ePF.mjs} +1 -1
- package/.output/server/chunks/build/index-Dnrh1ePF.mjs.map +1 -0
- package/.output/server/chunks/build/server.mjs +9 -9
- package/.output/server/chunks/build/styles.mjs +4 -4
- package/.output/server/chunks/nitro/nitro.mjs +333 -333
- package/.output/server/chunks/nitro/nitro.mjs.map +1 -1
- package/.output/server/chunks/routes/renderer.mjs.map +1 -1
- package/.output/server/node_modules/bson/lib/bson.cjs +157 -48
- package/.output/server/node_modules/bson/package.json +9 -11
- package/.output/server/node_modules/kareem/index.js +228 -343
- package/.output/server/node_modules/kareem/package.json +3 -3
- package/.output/server/node_modules/mongodb/lib/bson.js +27 -5
- package/.output/server/node_modules/mongodb/lib/bulk/common.js +7 -9
- package/.output/server/node_modules/mongodb/lib/change_stream.js +91 -39
- package/.output/server/node_modules/mongodb/lib/client-side-encryption/auto_encrypter.js +21 -14
- package/.output/server/node_modules/mongodb/lib/client-side-encryption/client_encryption.js +2 -5
- package/.output/server/node_modules/mongodb/lib/client-side-encryption/errors.js +3 -1
- package/.output/server/node_modules/mongodb/lib/client-side-encryption/mongocryptd_manager.js +1 -1
- package/.output/server/node_modules/mongodb/lib/client-side-encryption/state_machine.js +1 -0
- package/.output/server/node_modules/mongodb/lib/cmap/auth/aws4.js +161 -0
- package/.output/server/node_modules/mongodb/lib/cmap/auth/aws_temporary_credentials.js +11 -58
- package/.output/server/node_modules/mongodb/lib/cmap/auth/gssapi.js +4 -6
- package/.output/server/node_modules/mongodb/lib/cmap/auth/mongo_credentials.js +2 -16
- package/.output/server/node_modules/mongodb/lib/cmap/auth/mongodb_aws.js +14 -23
- package/.output/server/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/azure_machine_workflow.js +3 -3
- package/.output/server/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/gcp_machine_workflow.js +3 -3
- package/.output/server/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/k8s_machine_workflow.js +4 -3
- package/.output/server/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/token_machine_workflow.js +4 -3
- package/.output/server/node_modules/mongodb/lib/cmap/auth/mongodb_oidc.js +4 -4
- package/.output/server/node_modules/mongodb/lib/cmap/auth/plain.js +1 -1
- package/.output/server/node_modules/mongodb/lib/cmap/auth/providers.js +0 -1
- package/.output/server/node_modules/mongodb/lib/cmap/auth/scram.js +53 -40
- package/.output/server/node_modules/mongodb/lib/cmap/commands.js +46 -39
- package/.output/server/node_modules/mongodb/lib/cmap/connect.js +35 -3
- package/.output/server/node_modules/mongodb/lib/cmap/connection.js +36 -32
- package/.output/server/node_modules/mongodb/lib/cmap/connection_pool.js +67 -67
- package/.output/server/node_modules/mongodb/lib/cmap/connection_pool_events.js +3 -3
- package/.output/server/node_modules/mongodb/lib/cmap/errors.js +1 -1
- package/.output/server/node_modules/mongodb/lib/cmap/handshake/client_metadata.js +15 -13
- package/.output/server/node_modules/mongodb/lib/cmap/metrics.js +3 -3
- package/.output/server/node_modules/mongodb/lib/cmap/wire_protocol/compression.js +26 -10
- package/.output/server/node_modules/mongodb/lib/cmap/wire_protocol/constants.js +3 -1
- package/.output/server/node_modules/mongodb/lib/cmap/wire_protocol/on_data.js +0 -1
- package/.output/server/node_modules/mongodb/lib/cmap/wire_protocol/on_demand/document.js +9 -9
- package/.output/server/node_modules/mongodb/lib/cmap/wire_protocol/responses.js +2 -2
- package/.output/server/node_modules/mongodb/lib/collection.js +1 -1
- package/.output/server/node_modules/mongodb/lib/connection_string.js +30 -15
- package/.output/server/node_modules/mongodb/lib/cursor/abstract_cursor.js +17 -34
- package/.output/server/node_modules/mongodb/lib/cursor/change_stream_cursor.js +2 -2
- package/.output/server/node_modules/mongodb/lib/cursor/find_cursor.js +37 -26
- package/.output/server/node_modules/mongodb/lib/cursor/run_command_cursor.js +1 -1
- package/.output/server/node_modules/mongodb/lib/db.js +6 -7
- package/.output/server/node_modules/mongodb/lib/deps.js +0 -13
- package/.output/server/node_modules/mongodb/lib/error.js +7 -10
- package/.output/server/node_modules/mongodb/lib/gridfs/download.js +7 -6
- package/.output/server/node_modules/mongodb/lib/gridfs/index.js +9 -9
- package/.output/server/node_modules/mongodb/lib/gridfs/upload.js +17 -23
- package/.output/server/node_modules/mongodb/lib/index.js +2 -4
- package/.output/server/node_modules/mongodb/lib/mongo_client.js +58 -67
- package/.output/server/node_modules/mongodb/lib/mongo_client_auth_providers.js +0 -6
- package/.output/server/node_modules/mongodb/lib/mongo_logger.js +11 -5
- package/.output/server/node_modules/mongodb/lib/mongo_types.js +1 -2
- package/.output/server/node_modules/mongodb/lib/operations/aggregate.js +0 -3
- package/.output/server/node_modules/mongodb/lib/operations/create_collection.js +0 -1
- package/.output/server/node_modules/mongodb/lib/operations/drop.js +8 -9
- package/.output/server/node_modules/mongodb/lib/operations/end_sessions.js +34 -0
- package/.output/server/node_modules/mongodb/lib/operations/execute_operation.js +121 -45
- package/.output/server/node_modules/mongodb/lib/operations/operation.js +1 -0
- package/.output/server/node_modules/mongodb/lib/read_preference.js +10 -14
- package/.output/server/node_modules/mongodb/lib/runtime_adapters.js +32 -0
- package/.output/server/node_modules/mongodb/lib/sdam/monitor.js +8 -8
- package/.output/server/node_modules/mongodb/lib/sdam/server.js +55 -43
- package/.output/server/node_modules/mongodb/lib/sdam/server_description.js +1 -1
- package/.output/server/node_modules/mongodb/lib/sdam/server_selection.js +135 -72
- package/.output/server/node_modules/mongodb/lib/sdam/srv_polling.js +3 -3
- package/.output/server/node_modules/mongodb/lib/sdam/topology.js +37 -77
- package/.output/server/node_modules/mongodb/lib/sdam/topology_description.js +1 -1
- package/.output/server/node_modules/mongodb/lib/sessions.js +150 -40
- package/.output/server/node_modules/mongodb/lib/transactions.js +2 -13
- package/.output/server/node_modules/mongodb/lib/utils.js +42 -90
- package/.output/server/node_modules/mongodb/package.json +49 -45
- package/.output/server/node_modules/mongodb-connection-string-url/lib/index.js +45 -19
- package/.output/server/node_modules/mongodb-connection-string-url/lib/redact.js +30 -19
- package/.output/server/node_modules/mongodb-connection-string-url/package.json +25 -16
- package/.output/server/node_modules/mongoose/lib/aggregate.js +108 -127
- package/.output/server/node_modules/mongoose/lib/cast/bigint.js +3 -3
- package/.output/server/node_modules/mongoose/lib/cast/boolean.js +3 -3
- package/.output/server/node_modules/mongoose/lib/cast/double.js +4 -4
- package/.output/server/node_modules/mongoose/lib/cast/int32.js +2 -2
- package/.output/server/node_modules/mongoose/lib/cast/number.js +6 -6
- package/.output/server/node_modules/mongoose/lib/cast/string.js +3 -3
- package/.output/server/node_modules/mongoose/lib/cast/uuid.js +5 -48
- package/.output/server/node_modules/mongoose/lib/cast.js +16 -24
- package/.output/server/node_modules/mongoose/lib/collection.js +6 -6
- package/.output/server/node_modules/mongoose/lib/connection.js +108 -105
- package/.output/server/node_modules/mongoose/lib/cursor/aggregationCursor.js +23 -33
- package/.output/server/node_modules/mongoose/lib/cursor/changeStream.js +60 -40
- package/.output/server/node_modules/mongoose/lib/cursor/queryCursor.js +21 -25
- package/.output/server/node_modules/mongoose/lib/document.js +712 -531
- package/.output/server/node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js +85 -130
- package/.output/server/node_modules/mongoose/lib/drivers/node-mongodb-native/connection.js +32 -41
- package/.output/server/node_modules/mongoose/lib/error/cast.js +21 -12
- package/.output/server/node_modules/mongoose/lib/error/createCollectionsError.js +2 -2
- package/.output/server/node_modules/mongoose/lib/error/divergentArray.js +1 -1
- package/.output/server/node_modules/mongoose/lib/error/eachAsyncMultiError.js +1 -1
- package/.output/server/node_modules/mongoose/lib/error/index.js +3 -3
- package/.output/server/node_modules/mongoose/lib/error/invalidSchemaOption.js +1 -1
- package/.output/server/node_modules/mongoose/lib/error/messages.js +1 -0
- package/.output/server/node_modules/mongoose/lib/error/missingSchema.js +1 -1
- package/.output/server/node_modules/mongoose/lib/error/objectParameter.js +4 -5
- package/.output/server/node_modules/mongoose/lib/error/overwriteModel.js +1 -1
- package/.output/server/node_modules/mongoose/lib/error/setOptionError.js +3 -3
- package/.output/server/node_modules/mongoose/lib/error/strict.js +3 -3
- package/.output/server/node_modules/mongoose/lib/error/strictPopulate.js +2 -2
- package/.output/server/node_modules/mongoose/lib/error/syncIndexes.js +2 -2
- package/.output/server/node_modules/mongoose/lib/error/validation.js +2 -10
- package/.output/server/node_modules/mongoose/lib/error/validator.js +1 -1
- package/.output/server/node_modules/mongoose/lib/error/version.js +2 -2
- package/.output/server/node_modules/mongoose/lib/helpers/aggregate/prepareDiscriminatorPipeline.js +4 -4
- package/.output/server/node_modules/mongoose/lib/helpers/buildMiddlewareFilter.js +24 -0
- package/.output/server/node_modules/mongoose/lib/helpers/clone.js +35 -18
- package/.output/server/node_modules/mongoose/lib/helpers/common.js +5 -5
- package/.output/server/node_modules/mongoose/lib/helpers/cursor/eachAsync.js +4 -4
- package/.output/server/node_modules/mongoose/lib/helpers/discriminator/getConstructor.js +1 -1
- package/.output/server/node_modules/mongoose/lib/helpers/discriminator/getDiscriminatorByValue.js +1 -1
- package/.output/server/node_modules/mongoose/lib/helpers/discriminator/getSchemaDiscriminatorByValue.js +1 -1
- package/.output/server/node_modules/mongoose/lib/helpers/discriminator/mergeDiscriminatorSchema.js +10 -5
- package/.output/server/node_modules/mongoose/lib/helpers/document/applyDefaults.js +1 -1
- package/.output/server/node_modules/mongoose/lib/helpers/document/applyTimestamps.js +11 -10
- package/.output/server/node_modules/mongoose/lib/helpers/document/applyVirtuals.js +10 -9
- package/.output/server/node_modules/mongoose/lib/helpers/document/cleanModifiedSubpaths.js +1 -1
- package/.output/server/node_modules/mongoose/lib/helpers/document/compile.js +17 -14
- package/.output/server/node_modules/mongoose/lib/helpers/document/getDeepestSubdocumentForPath.js +3 -3
- package/.output/server/node_modules/mongoose/lib/helpers/document/getEmbeddedDiscriminatorPath.js +2 -2
- package/.output/server/node_modules/mongoose/lib/helpers/document/isInPathsToSave.js +24 -0
- package/.output/server/node_modules/mongoose/lib/helpers/get.js +1 -1
- package/.output/server/node_modules/mongoose/lib/helpers/indexes/decorateDiscriminatorIndexOptions.js +1 -1
- package/.output/server/node_modules/mongoose/lib/helpers/indexes/getRelatedIndexes.js +3 -3
- package/.output/server/node_modules/mongoose/lib/helpers/indexes/isIndexEqual.js +3 -4
- package/.output/server/node_modules/mongoose/lib/helpers/indexes/isIndexSpecEqual.js +3 -3
- package/.output/server/node_modules/mongoose/lib/helpers/isBsonType.js +1 -1
- package/.output/server/node_modules/mongoose/lib/helpers/isMongooseObject.js +1 -1
- package/.output/server/node_modules/mongoose/lib/helpers/isObject.js +2 -2
- package/.output/server/node_modules/mongoose/lib/helpers/isSimpleValidator.js +2 -2
- package/.output/server/node_modules/mongoose/lib/helpers/minimize.js +2 -2
- package/.output/server/node_modules/mongoose/lib/helpers/model/applyDefaultsToPOJO.js +2 -2
- package/.output/server/node_modules/mongoose/lib/helpers/model/applyHooks.js +55 -54
- package/.output/server/node_modules/mongoose/lib/helpers/model/applyMethods.js +2 -2
- package/.output/server/node_modules/mongoose/lib/helpers/model/applyStaticHooks.js +1 -48
- package/.output/server/node_modules/mongoose/lib/helpers/model/castBulkWrite.js +8 -12
- package/.output/server/node_modules/mongoose/lib/helpers/model/discriminator.js +1 -1
- package/.output/server/node_modules/mongoose/lib/helpers/parallelLimit.js +18 -36
- package/.output/server/node_modules/mongoose/lib/helpers/pluralize.js +4 -4
- package/.output/server/node_modules/mongoose/lib/helpers/populate/assignRawDocsToIdStructure.js +4 -11
- package/.output/server/node_modules/mongoose/lib/helpers/populate/assignVals.js +10 -10
- package/.output/server/node_modules/mongoose/lib/helpers/populate/createPopulateQueryFilter.js +3 -3
- package/.output/server/node_modules/mongoose/lib/helpers/populate/getModelsMapForPopulate.js +197 -69
- package/.output/server/node_modules/mongoose/lib/helpers/populate/getSchemaTypes.js +15 -15
- package/.output/server/node_modules/mongoose/lib/helpers/populate/markArraySubdocsPopulated.js +1 -1
- package/.output/server/node_modules/mongoose/lib/helpers/populate/modelNamesFromRefPath.js +10 -2
- package/.output/server/node_modules/mongoose/lib/helpers/populate/setPopulatedVirtualValue.js +5 -5
- package/.output/server/node_modules/mongoose/lib/helpers/printJestWarning.js +1 -1
- package/.output/server/node_modules/mongoose/lib/helpers/processConnectionOptions.js +1 -1
- package/.output/server/node_modules/mongoose/lib/helpers/projection/hasIncludedChildren.js +1 -1
- package/.output/server/node_modules/mongoose/lib/helpers/projection/isPathExcluded.js +3 -3
- package/.output/server/node_modules/mongoose/lib/helpers/projection/isSubpath.js +1 -1
- package/.output/server/node_modules/mongoose/lib/helpers/projection/parseProjection.js +9 -4
- package/.output/server/node_modules/mongoose/lib/helpers/query/cast$expr.js +8 -10
- package/.output/server/node_modules/mongoose/lib/helpers/query/castFilterPath.js +1 -1
- package/.output/server/node_modules/mongoose/lib/helpers/query/castUpdate.js +44 -38
- package/.output/server/node_modules/mongoose/lib/helpers/query/getEmbeddedDiscriminatorPath.js +8 -8
- package/.output/server/node_modules/mongoose/lib/helpers/query/handleImmutable.js +8 -8
- package/.output/server/node_modules/mongoose/lib/helpers/schema/applyPlugins.js +2 -2
- package/.output/server/node_modules/mongoose/lib/helpers/schema/applyReadConcern.js +1 -1
- package/.output/server/node_modules/mongoose/lib/helpers/schema/applyWriteConcern.js +4 -2
- package/.output/server/node_modules/mongoose/lib/helpers/schema/getIndexes.js +5 -11
- package/.output/server/node_modules/mongoose/lib/helpers/schema/getSubdocumentStrictValue.js +2 -2
- package/.output/server/node_modules/mongoose/lib/helpers/schema/handleIdOption.js +1 -1
- package/.output/server/node_modules/mongoose/lib/helpers/schema/idGetter.js +1 -1
- package/.output/server/node_modules/mongoose/lib/helpers/schematype/handleImmutable.js +1 -1
- package/.output/server/node_modules/mongoose/lib/helpers/setDefaultsOnInsert.js +26 -13
- package/.output/server/node_modules/mongoose/lib/helpers/timestamps/setDocumentTimestamps.js +2 -2
- package/.output/server/node_modules/mongoose/lib/helpers/timestamps/setupTimestamps.js +60 -38
- package/.output/server/node_modules/mongoose/lib/helpers/update/applyTimestampsToUpdate.js +13 -10
- package/.output/server/node_modules/mongoose/lib/helpers/update/castArrayFilters.js +4 -4
- package/.output/server/node_modules/mongoose/lib/helpers/update/decorateUpdateWithVersionKey.js +1 -1
- package/.output/server/node_modules/mongoose/lib/helpers/update/modifiedPaths.js +2 -2
- package/.output/server/node_modules/mongoose/lib/helpers/update/removeUnusedArrayFilters.js +7 -2
- package/.output/server/node_modules/mongoose/lib/helpers/updateValidators.js +58 -119
- package/.output/server/node_modules/mongoose/lib/model.js +940 -946
- package/.output/server/node_modules/mongoose/lib/mongoose.js +131 -79
- package/.output/server/node_modules/mongoose/lib/options/schemaArrayOptions.js +2 -2
- package/.output/server/node_modules/mongoose/lib/options/schemaBufferOptions.js +1 -1
- package/.output/server/node_modules/mongoose/lib/options/schemaDocumentArrayOptions.js +23 -0
- package/.output/server/node_modules/mongoose/lib/options/schemaNumberOptions.js +3 -3
- package/.output/server/node_modules/mongoose/lib/options/schemaObjectIdOptions.js +2 -2
- package/.output/server/node_modules/mongoose/lib/options/schemaStringOptions.js +6 -6
- package/.output/server/node_modules/mongoose/lib/options/schemaSubdocumentOptions.js +23 -0
- package/.output/server/node_modules/mongoose/lib/options/schemaTypeOptions.js +27 -13
- package/.output/server/node_modules/mongoose/lib/options/virtualOptions.js +12 -12
- package/.output/server/node_modules/mongoose/lib/plugins/index.js +0 -1
- package/.output/server/node_modules/mongoose/lib/plugins/saveSubdocs.js +84 -92
- package/.output/server/node_modules/mongoose/lib/plugins/sharding.js +33 -15
- package/.output/server/node_modules/mongoose/lib/plugins/trackTransaction.js +29 -25
- package/.output/server/node_modules/mongoose/lib/query.js +700 -548
- package/.output/server/node_modules/mongoose/lib/queryHelpers.js +34 -32
- package/.output/server/node_modules/mongoose/lib/schema/array.js +69 -113
- package/.output/server/node_modules/mongoose/lib/schema/bigint.js +18 -20
- package/.output/server/node_modules/mongoose/lib/schema/boolean.js +20 -22
- package/.output/server/node_modules/mongoose/lib/schema/buffer.js +23 -25
- package/.output/server/node_modules/mongoose/lib/schema/date.js +19 -21
- package/.output/server/node_modules/mongoose/lib/schema/decimal128.js +16 -18
- package/.output/server/node_modules/mongoose/lib/schema/documentArray.js +94 -131
- package/.output/server/node_modules/mongoose/lib/schema/documentArrayElement.js +50 -16
- package/.output/server/node_modules/mongoose/lib/schema/double.js +16 -18
- package/.output/server/node_modules/mongoose/lib/schema/index.js +1 -0
- package/.output/server/node_modules/mongoose/lib/schema/int32.js +17 -19
- package/.output/server/node_modules/mongoose/lib/schema/map.js +17 -24
- package/.output/server/node_modules/mongoose/lib/schema/mixed.js +14 -14
- package/.output/server/node_modules/mongoose/lib/schema/number.js +38 -28
- package/.output/server/node_modules/mongoose/lib/schema/objectId.js +18 -20
- package/.output/server/node_modules/mongoose/lib/schema/operators/exists.js +1 -1
- package/.output/server/node_modules/mongoose/lib/schema/operators/geospatial.js +1 -1
- package/.output/server/node_modules/mongoose/lib/schema/operators/text.js +4 -4
- package/.output/server/node_modules/mongoose/lib/schema/string.js +42 -27
- package/.output/server/node_modules/mongoose/lib/schema/subdocument.js +47 -58
- package/.output/server/node_modules/mongoose/lib/schema/union.js +54 -4
- package/.output/server/node_modules/mongoose/lib/schema/uuid.js +17 -40
- package/.output/server/node_modules/mongoose/lib/schema.js +235 -176
- package/.output/server/node_modules/mongoose/lib/schemaType.js +227 -158
- package/.output/server/node_modules/mongoose/lib/stateMachine.js +5 -8
- package/.output/server/node_modules/mongoose/lib/types/array/index.js +5 -5
- package/.output/server/node_modules/mongoose/lib/types/array/methods/index.js +27 -28
- package/.output/server/node_modules/mongoose/lib/types/arraySubdocument.js +11 -11
- package/.output/server/node_modules/mongoose/lib/types/buffer.js +15 -15
- package/.output/server/node_modules/mongoose/lib/types/decimal128.js +1 -1
- package/.output/server/node_modules/mongoose/lib/types/documentArray/index.js +4 -4
- package/.output/server/node_modules/mongoose/lib/types/documentArray/methods/index.js +15 -13
- package/.output/server/node_modules/mongoose/lib/types/double.js +1 -1
- package/.output/server/node_modules/mongoose/lib/types/map.js +20 -71
- package/.output/server/node_modules/mongoose/lib/types/objectid.js +1 -1
- package/.output/server/node_modules/mongoose/lib/types/subdocument.js +32 -81
- package/.output/server/node_modules/mongoose/lib/types/uuid.js +1 -1
- package/.output/server/node_modules/mongoose/lib/utils.js +91 -70
- package/.output/server/node_modules/mongoose/lib/validOptions.js +4 -3
- package/.output/server/node_modules/mongoose/lib/virtualType.js +18 -18
- package/.output/server/node_modules/mongoose/package.json +46 -63
- package/.output/server/node_modules/mquery/lib/collection/collection.js +3 -1
- package/.output/server/node_modules/mquery/lib/collection/node.js +17 -3
- package/.output/server/node_modules/mquery/lib/mquery.js +136 -93
- package/.output/server/node_modules/mquery/lib/permissions.js +21 -6
- package/.output/server/node_modules/mquery/package.json +4 -7
- package/.output/server/package.json +7 -9
- package/package.json +3 -3
- package/.output/public/_nuxt/builds/meta/0d6006db-fbb0-4297-85cf-bf92ceafcb79.json +0 -1
- package/.output/public/_nuxt/error-404.CTWLHxjC.css +0 -1
- package/.output/public/_nuxt/error-500.UBfk8-QP.css +0 -1
- package/.output/server/chunks/build/error-404-8tbBXju4.mjs.map +0 -1
- package/.output/server/chunks/build/error-404-styles.BeWfK6Py.mjs +0 -8
- package/.output/server/chunks/build/error-404-styles.BeWfK6Py.mjs.map +0 -1
- package/.output/server/chunks/build/error-500-DxFsom1i.mjs.map +0 -1
- package/.output/server/chunks/build/error-500-styles.CPUUvoY-.mjs +0 -8
- package/.output/server/chunks/build/error-500-styles.CPUUvoY-.mjs.map +0 -1
- package/.output/server/chunks/build/index-BB-Clavm.mjs.map +0 -1
- package/.output/server/node_modules/debug/package.json +0 -64
- package/.output/server/node_modules/debug/src/browser.js +0 -272
- package/.output/server/node_modules/debug/src/common.js +0 -292
- package/.output/server/node_modules/debug/src/index.js +0 -10
- package/.output/server/node_modules/debug/src/node.js +0 -263
- package/.output/server/node_modules/mongodb/lib/client-side-encryption/crypto_callbacks.js +0 -81
- package/.output/server/node_modules/mongodb/lib/resource_management.js +0 -58
- package/.output/server/node_modules/mongoose/lib/browserDocument.js +0 -101
- package/.output/server/node_modules/mongoose/lib/documentProvider.js +0 -30
- package/.output/server/node_modules/mongoose/lib/helpers/createJSONSchemaTypeDefinition.js +0 -24
- package/.output/server/node_modules/mongoose/lib/helpers/promiseOrCallback.js +0 -54
- package/.output/server/node_modules/mongoose/lib/plugins/validateBeforeSave.js +0 -51
- package/.output/server/node_modules/supports-color/index.js +0 -202
- 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 {
|
|
21
|
-
* @param {
|
|
22
|
-
* @param {
|
|
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 {
|
|
140
|
-
* @param {
|
|
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 {...
|
|
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 {
|
|
406
|
-
* @param {
|
|
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
|
|
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 {
|
|
462
|
-
* @param {
|
|
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
|
|
474
|
+
if (value != null) {
|
|
476
475
|
let msg = message || MongooseError.messages.String.maxlength;
|
|
477
|
-
|
|
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 {
|
|
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 {
|
|
567
|
+
* @param {any} value
|
|
567
568
|
* @param {Document} doc
|
|
568
|
-
* @return {
|
|
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
|
|
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 {
|
|
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 {
|
|
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
|
-
|
|
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 {
|
|
34
|
-
* @param {
|
|
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.
|
|
54
|
-
this.
|
|
55
|
-
this.
|
|
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
|
|
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 {
|
|
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 {
|
|
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
|
|
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.
|
|
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
|
|
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,
|
|
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 (
|
|
220
|
-
return new Constructor({}, selected, doc,
|
|
217
|
+
if (utils.hasOwnKeys(val) === false) {
|
|
218
|
+
return new Constructor({}, selected, doc, options);
|
|
221
219
|
}
|
|
222
220
|
|
|
223
|
-
return new Constructor(val, selected, doc,
|
|
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.
|
|
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
|
|
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
|
|
274
|
+
* @api public
|
|
279
275
|
*/
|
|
280
276
|
|
|
281
|
-
SchemaSubdocument.prototype.doValidate = function(value,
|
|
282
|
-
const Constructor = getConstructor(this.
|
|
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,
|
|
281
|
+
value = new Constructor(value, null, scope?.$__ != null ? scope : null);
|
|
286
282
|
}
|
|
287
283
|
|
|
288
|
-
if (options
|
|
284
|
+
if (options?.skipSchemaValidators) {
|
|
289
285
|
if (!value) {
|
|
290
|
-
return
|
|
286
|
+
return;
|
|
291
287
|
}
|
|
292
|
-
return value.validate()
|
|
288
|
+
return value.validate();
|
|
293
289
|
}
|
|
294
290
|
|
|
295
|
-
SchemaType.prototype.doValidate.call(this, value,
|
|
296
|
-
|
|
297
|
-
|
|
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
|
|
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 {
|
|
327
|
+
* @param {string} name
|
|
338
328
|
* @param {Schema} schema fields to add to the schema for instances of this sub-class
|
|
339
|
-
* @param {
|
|
340
|
-
* @param {
|
|
341
|
-
* @param {
|
|
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.
|
|
348
|
+
schema = discriminator(this.Constructor, name, schema, value, null, null, options.overwriteExisting);
|
|
359
349
|
|
|
360
|
-
this.
|
|
350
|
+
this.Constructor.discriminators[name] = _createConstructor(schema, this.Constructor);
|
|
361
351
|
|
|
362
|
-
return this.
|
|
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
|
|
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 {
|
|
380
|
-
* @param {
|
|
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.
|
|
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 {
|
|
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
|
-
...
|
|
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 {
|
|
21
|
-
* @param {
|
|
22
|
-
* @param {
|
|
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 (!
|
|
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|
|
|
21
|
-
* @returns {
|
|
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 {
|
|
39
|
-
* @param {
|
|
40
|
-
* @param {
|
|
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 {
|
|
119
|
-
* @param {
|
|
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 {
|
|
187
|
-
* @return {
|
|
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 {
|
|
202
|
-
* @param {
|
|
203
|
-
* @param {
|
|
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 {
|
|
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 {
|
|
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
|
-
|
|
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() {
|