@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
|
@@ -18,6 +18,16 @@ exports.ReadPreferenceMode = Object.freeze({
|
|
|
18
18
|
* @see https://www.mongodb.com/docs/manual/core/read-preference/
|
|
19
19
|
*/
|
|
20
20
|
class ReadPreference {
|
|
21
|
+
static { this.PRIMARY = exports.ReadPreferenceMode.primary; }
|
|
22
|
+
static { this.PRIMARY_PREFERRED = exports.ReadPreferenceMode.primaryPreferred; }
|
|
23
|
+
static { this.SECONDARY = exports.ReadPreferenceMode.secondary; }
|
|
24
|
+
static { this.SECONDARY_PREFERRED = exports.ReadPreferenceMode.secondaryPreferred; }
|
|
25
|
+
static { this.NEAREST = exports.ReadPreferenceMode.nearest; }
|
|
26
|
+
static { this.primary = new ReadPreference(exports.ReadPreferenceMode.primary); }
|
|
27
|
+
static { this.primaryPreferred = new ReadPreference(exports.ReadPreferenceMode.primaryPreferred); }
|
|
28
|
+
static { this.secondary = new ReadPreference(exports.ReadPreferenceMode.secondary); }
|
|
29
|
+
static { this.secondaryPreferred = new ReadPreference(exports.ReadPreferenceMode.secondaryPreferred); }
|
|
30
|
+
static { this.nearest = new ReadPreference(exports.ReadPreferenceMode.nearest); }
|
|
21
31
|
/**
|
|
22
32
|
* @param mode - A string describing the read preference mode (primary|primaryPreferred|secondary|secondaryPreferred|nearest)
|
|
23
33
|
* @param tags - A tag set used to target reads to members with the specified tag(s). tagSet is not available if using read preference mode primary.
|
|
@@ -38,16 +48,12 @@ class ReadPreference {
|
|
|
38
48
|
this.tags = tags;
|
|
39
49
|
this.hedge = options?.hedge;
|
|
40
50
|
this.maxStalenessSeconds = undefined;
|
|
41
|
-
this.minWireVersion = undefined;
|
|
42
51
|
options = options ?? {};
|
|
43
52
|
if (options.maxStalenessSeconds != null) {
|
|
44
53
|
if (options.maxStalenessSeconds <= 0) {
|
|
45
54
|
throw new error_1.MongoInvalidArgumentError('maxStalenessSeconds must be a positive integer');
|
|
46
55
|
}
|
|
47
56
|
this.maxStalenessSeconds = options.maxStalenessSeconds;
|
|
48
|
-
// NOTE: The minimum required wire version is 5 for this read preference. If the existing
|
|
49
|
-
// topology has a lower value then a MongoError will be thrown during server selection.
|
|
50
|
-
this.minWireVersion = 5;
|
|
51
57
|
}
|
|
52
58
|
if (this.mode === ReadPreference.PRIMARY) {
|
|
53
59
|
if (this.tags && Array.isArray(this.tags) && this.tags.length > 0) {
|
|
@@ -182,14 +188,4 @@ class ReadPreference {
|
|
|
182
188
|
}
|
|
183
189
|
}
|
|
184
190
|
exports.ReadPreference = ReadPreference;
|
|
185
|
-
ReadPreference.PRIMARY = exports.ReadPreferenceMode.primary;
|
|
186
|
-
ReadPreference.PRIMARY_PREFERRED = exports.ReadPreferenceMode.primaryPreferred;
|
|
187
|
-
ReadPreference.SECONDARY = exports.ReadPreferenceMode.secondary;
|
|
188
|
-
ReadPreference.SECONDARY_PREFERRED = exports.ReadPreferenceMode.secondaryPreferred;
|
|
189
|
-
ReadPreference.NEAREST = exports.ReadPreferenceMode.nearest;
|
|
190
|
-
ReadPreference.primary = new ReadPreference(exports.ReadPreferenceMode.primary);
|
|
191
|
-
ReadPreference.primaryPreferred = new ReadPreference(exports.ReadPreferenceMode.primaryPreferred);
|
|
192
|
-
ReadPreference.secondary = new ReadPreference(exports.ReadPreferenceMode.secondary);
|
|
193
|
-
ReadPreference.secondaryPreferred = new ReadPreference(exports.ReadPreferenceMode.secondaryPreferred);
|
|
194
|
-
ReadPreference.nearest = new ReadPreference(exports.ReadPreferenceMode.nearest);
|
|
195
191
|
//# sourceMappingURL=read_preference.js.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable no-restricted-imports*/
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.ALLOWED_DRIVER_REQUIRE_PROPERTY_NAME = void 0;
|
|
5
|
+
exports.resolveRuntimeAdapters = resolveRuntimeAdapters;
|
|
6
|
+
/**
|
|
7
|
+
* @internal
|
|
8
|
+
*
|
|
9
|
+
* This propery can be set on the global object to allow the driver to require otherwise blocked modules.
|
|
10
|
+
* This is used by our test suite to allow tests to access the `os` module without allowing user code to do so.
|
|
11
|
+
*/
|
|
12
|
+
exports.ALLOWED_DRIVER_REQUIRE_PROPERTY_NAME = 'allowedDriverRequire';
|
|
13
|
+
/**
|
|
14
|
+
* @internal
|
|
15
|
+
*
|
|
16
|
+
* Given a MongoClientOptions, this function resolves the set of runtime options, providing Nodejs implementations if
|
|
17
|
+
* not provided by in `options`, and returns a `Runtime`.
|
|
18
|
+
*/
|
|
19
|
+
function resolveRuntimeAdapters(options) {
|
|
20
|
+
globalThis[exports.ALLOWED_DRIVER_REQUIRE_PROPERTY_NAME] = true;
|
|
21
|
+
try {
|
|
22
|
+
const runtime = {
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
24
|
+
os: options.runtimeAdapters?.os ?? require('os')
|
|
25
|
+
};
|
|
26
|
+
return runtime;
|
|
27
|
+
}
|
|
28
|
+
finally {
|
|
29
|
+
globalThis[exports.ALLOWED_DRIVER_REQUIRE_PROPERTY_NAME] = false;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=runtime_adapters.js.map
|
|
@@ -207,7 +207,7 @@ function checkServer(monitor, callback) {
|
|
|
207
207
|
monitor.emitAndLogHeartbeat(server_1.Server.SERVER_HEARTBEAT_STARTED, monitor.server.topology.s.id, undefined, new events_1.ServerHeartbeatStartedEvent(monitor.address, true));
|
|
208
208
|
// We have not actually sent an outgoing handshake, but when we get the next response we
|
|
209
209
|
// want the duration to reflect the time since we last heard from the server
|
|
210
|
-
start = (0, utils_1.
|
|
210
|
+
start = (0, utils_1.processTimeMS)();
|
|
211
211
|
}
|
|
212
212
|
else {
|
|
213
213
|
monitor.rttPinger?.close();
|
|
@@ -236,7 +236,7 @@ function checkServer(monitor, callback) {
|
|
|
236
236
|
monitor.rttPinger = new RTTPinger(monitor);
|
|
237
237
|
}
|
|
238
238
|
// Record new start time before sending handshake
|
|
239
|
-
start = (0, utils_1.
|
|
239
|
+
start = (0, utils_1.processTimeMS)();
|
|
240
240
|
if (isAwaitable) {
|
|
241
241
|
awaited = true;
|
|
242
242
|
return connection.exhaustCommand((0, utils_1.ns)('admin.$cmd'), cmd, options, (error, hello) => {
|
|
@@ -256,7 +256,7 @@ function checkServer(monitor, callback) {
|
|
|
256
256
|
const socket = await (0, connect_1.makeSocket)(monitor.connectOptions);
|
|
257
257
|
const connection = (0, connect_1.makeConnection)(monitor.connectOptions, socket);
|
|
258
258
|
// The start time is after socket creation but before the handshake
|
|
259
|
-
start = (0, utils_1.
|
|
259
|
+
start = (0, utils_1.processTimeMS)();
|
|
260
260
|
try {
|
|
261
261
|
await (0, connect_1.performInitialHandshake)(connection, monitor.connectOptions);
|
|
262
262
|
return connection;
|
|
@@ -284,7 +284,7 @@ function checkServer(monitor, callback) {
|
|
|
284
284
|
function monitorServer(monitor) {
|
|
285
285
|
return (callback) => {
|
|
286
286
|
if (monitor.s.state === STATE_MONITORING) {
|
|
287
|
-
|
|
287
|
+
queueMicrotask(callback);
|
|
288
288
|
return;
|
|
289
289
|
}
|
|
290
290
|
stateTransition(monitor, STATE_MONITORING);
|
|
@@ -356,7 +356,7 @@ class RTTPinger {
|
|
|
356
356
|
this.monitorId = (0, timers_1.setTimeout)(() => this.measureRoundTripTime(), this.monitor.options.heartbeatFrequencyMS);
|
|
357
357
|
}
|
|
358
358
|
measureRoundTripTime() {
|
|
359
|
-
const start = (0, utils_1.
|
|
359
|
+
const start = (0, utils_1.processTimeMS)();
|
|
360
360
|
if (this.closed) {
|
|
361
361
|
return;
|
|
362
362
|
}
|
|
@@ -396,7 +396,7 @@ class MonitorInterval {
|
|
|
396
396
|
this.isExpeditedCallToFnScheduled = false;
|
|
397
397
|
this.isExecutionInProgress = true;
|
|
398
398
|
this.fn(() => {
|
|
399
|
-
this.lastExecutionEnded = (0, utils_1.
|
|
399
|
+
this.lastExecutionEnded = (0, utils_1.processTimeMS)();
|
|
400
400
|
this.isExecutionInProgress = false;
|
|
401
401
|
this._reschedule(this.heartbeatFrequencyMS);
|
|
402
402
|
});
|
|
@@ -413,7 +413,7 @@ class MonitorInterval {
|
|
|
413
413
|
}
|
|
414
414
|
}
|
|
415
415
|
wake() {
|
|
416
|
-
const currentTime = (0, utils_1.
|
|
416
|
+
const currentTime = (0, utils_1.processTimeMS)();
|
|
417
417
|
const timeSinceLastCall = currentTime - this.lastExecutionEnded;
|
|
418
418
|
// TODO(NODE-4674): Add error handling and logging to the monitor
|
|
419
419
|
if (timeSinceLastCall < 0) {
|
|
@@ -448,7 +448,7 @@ class MonitorInterval {
|
|
|
448
448
|
return JSON.stringify(this);
|
|
449
449
|
}
|
|
450
450
|
toJSON() {
|
|
451
|
-
const currentTime = (0, utils_1.
|
|
451
|
+
const currentTime = (0, utils_1.processTimeMS)();
|
|
452
452
|
const timeSinceLastCall = currentTime - this.lastExecutionEnded;
|
|
453
453
|
return {
|
|
454
454
|
timerId: this.timerId != null ? 'set' : 'cleared',
|
|
@@ -23,6 +23,20 @@ const stateTransition = (0, utils_1.makeStateMachine)({
|
|
|
23
23
|
});
|
|
24
24
|
/** @internal */
|
|
25
25
|
class Server extends mongo_types_1.TypedEventEmitter {
|
|
26
|
+
/** @event */
|
|
27
|
+
static { this.SERVER_HEARTBEAT_STARTED = constants_1.SERVER_HEARTBEAT_STARTED; }
|
|
28
|
+
/** @event */
|
|
29
|
+
static { this.SERVER_HEARTBEAT_SUCCEEDED = constants_1.SERVER_HEARTBEAT_SUCCEEDED; }
|
|
30
|
+
/** @event */
|
|
31
|
+
static { this.SERVER_HEARTBEAT_FAILED = constants_1.SERVER_HEARTBEAT_FAILED; }
|
|
32
|
+
/** @event */
|
|
33
|
+
static { this.CONNECT = constants_1.CONNECT; }
|
|
34
|
+
/** @event */
|
|
35
|
+
static { this.DESCRIPTION_RECEIVED = constants_1.DESCRIPTION_RECEIVED; }
|
|
36
|
+
/** @event */
|
|
37
|
+
static { this.CLOSED = constants_1.CLOSED; }
|
|
38
|
+
/** @event */
|
|
39
|
+
static { this.ENDED = constants_1.ENDED; }
|
|
26
40
|
/**
|
|
27
41
|
* Create a server
|
|
28
42
|
*/
|
|
@@ -201,7 +215,7 @@ class Server extends mongo_types_1.TypedEventEmitter {
|
|
|
201
215
|
}
|
|
202
216
|
catch (operationError) {
|
|
203
217
|
if (operationError instanceof error_1.MongoError &&
|
|
204
|
-
operationError.code === error_1.MONGODB_ERROR_CODES.Reauthenticate) {
|
|
218
|
+
operationError.code?.valueOf() === error_1.MONGODB_ERROR_CODES.Reauthenticate) {
|
|
205
219
|
reauthPromise = this.pool.reauthenticate(conn);
|
|
206
220
|
reauthPromise.then(undefined, error => {
|
|
207
221
|
reauthPromise = null;
|
|
@@ -234,39 +248,47 @@ class Server extends mongo_types_1.TypedEventEmitter {
|
|
|
234
248
|
if (!(error instanceof error_1.MongoError)) {
|
|
235
249
|
return;
|
|
236
250
|
}
|
|
237
|
-
|
|
238
|
-
if (isStaleError) {
|
|
251
|
+
if (isStaleError(this, error)) {
|
|
239
252
|
return;
|
|
240
253
|
}
|
|
241
254
|
const isNetworkNonTimeoutError = error instanceof error_1.MongoNetworkError && !(error instanceof error_1.MongoNetworkTimeoutError);
|
|
242
255
|
const isNetworkTimeoutBeforeHandshakeError = error instanceof error_1.MongoNetworkError && error.beforeHandshake;
|
|
243
|
-
const
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
256
|
+
const isAuthOrEstablishmentHandshakeError = error.hasErrorLabel(error_1.MongoErrorLabel.HandshakeError);
|
|
257
|
+
const isSystemOverloadError = error.hasErrorLabel(error_1.MongoErrorLabel.SystemOverloadedError);
|
|
258
|
+
// Perhaps questionable and divergent from the spec, but considering MongoParseErrors like state change errors was legacy behavior.
|
|
259
|
+
if ((0, error_1.isStateChangeError)(error) || error instanceof error_1.MongoParseError) {
|
|
260
|
+
const shouldClearPool = (0, error_1.isNodeShuttingDownError)(error);
|
|
261
|
+
// from the SDAM spec: The driver MUST synchronize clearing the pool with updating the topology.
|
|
262
|
+
// In load balanced mode: there is no monitoring, so there is no topology to update. We simply clear the pool.
|
|
263
|
+
// For other topologies: the `ResetPool` label instructs the topology to clear the server's pool in `updateServer()`.
|
|
247
264
|
if (!this.loadBalanced) {
|
|
248
|
-
|
|
265
|
+
if (shouldClearPool) {
|
|
266
|
+
error.addErrorLabel(error_1.MongoErrorLabel.ResetPool);
|
|
267
|
+
}
|
|
249
268
|
markServerUnknown(this, error);
|
|
269
|
+
queueMicrotask(() => this.requestCheck());
|
|
270
|
+
return;
|
|
250
271
|
}
|
|
251
|
-
|
|
272
|
+
if (connection && shouldClearPool) {
|
|
252
273
|
this.pool.clear({ serviceId: connection.serviceId });
|
|
253
274
|
}
|
|
254
275
|
}
|
|
255
|
-
else
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
276
|
+
else if (isNetworkNonTimeoutError ||
|
|
277
|
+
isNetworkTimeoutBeforeHandshakeError ||
|
|
278
|
+
isAuthOrEstablishmentHandshakeError) {
|
|
279
|
+
// Do NOT clear the pool if we encounter a system overloaded error.
|
|
280
|
+
if (isSystemOverloadError) {
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
// from the SDAM spec: The driver MUST synchronize clearing the pool with updating the topology.
|
|
284
|
+
// In load balanced mode: there is no monitoring, so there is no topology to update. We simply clear the pool.
|
|
285
|
+
// For other topologies: the `ResetPool` label instructs the topology to clear the server's pool in `updateServer()`.
|
|
286
|
+
if (!this.loadBalanced) {
|
|
287
|
+
error.addErrorLabel(error_1.MongoErrorLabel.ResetPool);
|
|
288
|
+
markServerUnknown(this, error);
|
|
289
|
+
}
|
|
290
|
+
else if (connection) {
|
|
291
|
+
this.pool.clear({ serviceId: connection.serviceId });
|
|
270
292
|
}
|
|
271
293
|
}
|
|
272
294
|
}
|
|
@@ -333,20 +355,6 @@ class Server extends mongo_types_1.TypedEventEmitter {
|
|
|
333
355
|
}
|
|
334
356
|
}
|
|
335
357
|
exports.Server = Server;
|
|
336
|
-
/** @event */
|
|
337
|
-
Server.SERVER_HEARTBEAT_STARTED = constants_1.SERVER_HEARTBEAT_STARTED;
|
|
338
|
-
/** @event */
|
|
339
|
-
Server.SERVER_HEARTBEAT_SUCCEEDED = constants_1.SERVER_HEARTBEAT_SUCCEEDED;
|
|
340
|
-
/** @event */
|
|
341
|
-
Server.SERVER_HEARTBEAT_FAILED = constants_1.SERVER_HEARTBEAT_FAILED;
|
|
342
|
-
/** @event */
|
|
343
|
-
Server.CONNECT = constants_1.CONNECT;
|
|
344
|
-
/** @event */
|
|
345
|
-
Server.DESCRIPTION_RECEIVED = constants_1.DESCRIPTION_RECEIVED;
|
|
346
|
-
/** @event */
|
|
347
|
-
Server.CLOSED = constants_1.CLOSED;
|
|
348
|
-
/** @event */
|
|
349
|
-
Server.ENDED = constants_1.ENDED;
|
|
350
358
|
function markServerUnknown(server, error) {
|
|
351
359
|
// Load balancer servers can never be marked unknown.
|
|
352
360
|
if (server.loadBalanced) {
|
|
@@ -376,11 +384,6 @@ function connectionIsStale(pool, connection) {
|
|
|
376
384
|
}
|
|
377
385
|
return connection.generation !== pool.generation;
|
|
378
386
|
}
|
|
379
|
-
function shouldHandleStateChangeError(server, err) {
|
|
380
|
-
const etv = err.topologyVersion;
|
|
381
|
-
const stv = server.description.topologyVersion;
|
|
382
|
-
return (0, server_description_1.compareTopologyVersion)(stv, etv) < 0;
|
|
383
|
-
}
|
|
384
387
|
function inActiveTransaction(session, cmd) {
|
|
385
388
|
return session && session.inTransaction() && !(0, transactions_1.isTransactionCommand)(cmd);
|
|
386
389
|
}
|
|
@@ -389,4 +392,13 @@ function inActiveTransaction(session, cmd) {
|
|
|
389
392
|
function isRetryableWritesEnabled(topology) {
|
|
390
393
|
return topology.s.options.retryWrites !== false;
|
|
391
394
|
}
|
|
395
|
+
function isStaleError(server, error) {
|
|
396
|
+
const currentGeneration = server.pool.generation;
|
|
397
|
+
const generation = error.connectionGeneration;
|
|
398
|
+
if (generation && generation < currentGeneration) {
|
|
399
|
+
return true;
|
|
400
|
+
}
|
|
401
|
+
const currentTopologyVersion = server.description.topologyVersion;
|
|
402
|
+
return (0, server_description_1.compareTopologyVersion)(currentTopologyVersion, error.topologyVersion) >= 0;
|
|
403
|
+
}
|
|
392
404
|
//# sourceMappingURL=server.js.map
|
|
@@ -51,7 +51,7 @@ class ServerDescription {
|
|
|
51
51
|
this.maxWireVersion = hello?.maxWireVersion ?? 0;
|
|
52
52
|
this.roundTripTime = options?.roundTripTime ?? -1;
|
|
53
53
|
this.minRoundTripTime = options?.minRoundTripTime ?? 0;
|
|
54
|
-
this.lastUpdateTime = (0, utils_1.
|
|
54
|
+
this.lastUpdateTime = (0, utils_1.processTimeMS)();
|
|
55
55
|
this.lastWriteDate = hello?.lastWrite?.lastWriteDate ?? 0;
|
|
56
56
|
// NOTE: This actually builds the stack string instead of holding onto the getter and all its
|
|
57
57
|
// associated references. This is done to prevent a memory leak.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MIN_SECONDARY_WRITE_WIRE_VERSION = void 0;
|
|
3
|
+
exports.DeprioritizedServers = exports.MIN_SECONDARY_WRITE_WIRE_VERSION = void 0;
|
|
4
4
|
exports.writableServerSelector = writableServerSelector;
|
|
5
5
|
exports.sameServerSelector = sameServerSelector;
|
|
6
6
|
exports.secondaryWritableServerSelector = secondaryWritableServerSelector;
|
|
@@ -13,12 +13,33 @@ const IDLE_WRITE_PERIOD = 10000;
|
|
|
13
13
|
const SMALLEST_MAX_STALENESS_SECONDS = 90;
|
|
14
14
|
// Minimum version to try writes on secondaries.
|
|
15
15
|
exports.MIN_SECONDARY_WRITE_WIRE_VERSION = 13;
|
|
16
|
+
/** @internal */
|
|
17
|
+
class DeprioritizedServers {
|
|
18
|
+
constructor(descriptions) {
|
|
19
|
+
this.deprioritized = new Set();
|
|
20
|
+
for (const description of descriptions ?? []) {
|
|
21
|
+
this.add(description);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
add({ address }) {
|
|
25
|
+
this.deprioritized.add(address);
|
|
26
|
+
}
|
|
27
|
+
has({ address }) {
|
|
28
|
+
return this.deprioritized.has(address);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.DeprioritizedServers = DeprioritizedServers;
|
|
32
|
+
function filterDeprioritized(candidates, deprioritized) {
|
|
33
|
+
const filtered = candidates.filter(candidate => !deprioritized.has(candidate));
|
|
34
|
+
return filtered.length ? filtered : candidates;
|
|
35
|
+
}
|
|
16
36
|
/**
|
|
17
37
|
* Returns a server selector that selects for writable servers
|
|
18
38
|
*/
|
|
19
39
|
function writableServerSelector() {
|
|
20
|
-
return function writableServer(topologyDescription, servers) {
|
|
21
|
-
|
|
40
|
+
return function writableServer(topologyDescription, servers, deprioritized) {
|
|
41
|
+
const eligibleServers = filterDeprioritized(servers.filter(({ isWritable }) => isWritable), deprioritized);
|
|
42
|
+
return latencyWindowReducer(topologyDescription, eligibleServers);
|
|
22
43
|
};
|
|
23
44
|
}
|
|
24
45
|
/**
|
|
@@ -26,7 +47,7 @@ function writableServerSelector() {
|
|
|
26
47
|
* if it is in a state that it can have commands sent to it.
|
|
27
48
|
*/
|
|
28
49
|
function sameServerSelector(description) {
|
|
29
|
-
return function sameServerSelector(
|
|
50
|
+
return function sameServerSelector(_topologyDescription, servers, _deprioritized) {
|
|
30
51
|
if (!description)
|
|
31
52
|
return [];
|
|
32
53
|
// Filter the servers to match the provided description only if
|
|
@@ -77,52 +98,47 @@ function maxStalenessReducer(readPreference, topologyDescription, servers) {
|
|
|
77
98
|
}
|
|
78
99
|
if (topologyDescription.type === common_1.TopologyType.ReplicaSetWithPrimary) {
|
|
79
100
|
const primary = Array.from(topologyDescription.servers.values()).filter(primaryFilter)[0];
|
|
80
|
-
return servers.
|
|
101
|
+
return servers.filter((server) => {
|
|
81
102
|
const stalenessMS = server.lastUpdateTime -
|
|
82
103
|
server.lastWriteDate -
|
|
83
104
|
(primary.lastUpdateTime - primary.lastWriteDate) +
|
|
84
105
|
topologyDescription.heartbeatFrequencyMS;
|
|
85
106
|
const staleness = stalenessMS / 1000;
|
|
86
107
|
const maxStalenessSeconds = readPreference.maxStalenessSeconds ?? 0;
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
return result;
|
|
91
|
-
}, []);
|
|
108
|
+
return staleness <= maxStalenessSeconds;
|
|
109
|
+
});
|
|
92
110
|
}
|
|
93
111
|
if (topologyDescription.type === common_1.TopologyType.ReplicaSetNoPrimary) {
|
|
94
112
|
if (servers.length === 0) {
|
|
95
113
|
return servers;
|
|
96
114
|
}
|
|
97
115
|
const sMax = servers.reduce((max, s) => s.lastWriteDate > max.lastWriteDate ? s : max);
|
|
98
|
-
return servers.
|
|
116
|
+
return servers.filter((server) => {
|
|
99
117
|
const stalenessMS = sMax.lastWriteDate - server.lastWriteDate + topologyDescription.heartbeatFrequencyMS;
|
|
100
118
|
const staleness = stalenessMS / 1000;
|
|
101
119
|
const maxStalenessSeconds = readPreference.maxStalenessSeconds ?? 0;
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
return result;
|
|
106
|
-
}, []);
|
|
120
|
+
return staleness <= maxStalenessSeconds;
|
|
121
|
+
});
|
|
107
122
|
}
|
|
108
123
|
return servers;
|
|
109
124
|
}
|
|
110
125
|
/**
|
|
111
|
-
* Determines whether a server's tags match a given set of tags
|
|
126
|
+
* Determines whether a server's tags match a given set of tags.
|
|
127
|
+
*
|
|
128
|
+
* A tagset matches the server's tags if every k-v pair in the tagset
|
|
129
|
+
* is also in the server's tagset.
|
|
130
|
+
*
|
|
131
|
+
* Note that this does not requires that every k-v pair in the server's tagset is also
|
|
132
|
+
* in the client's tagset. The server's tagset is required only to be a superset of the
|
|
133
|
+
* client's tags.
|
|
134
|
+
*
|
|
135
|
+
* @see https://github.com/mongodb/specifications/blob/master/source/server-selection/server-selection.md#tag_sets
|
|
112
136
|
*
|
|
113
137
|
* @param tagSet - The requested tag set to match
|
|
114
138
|
* @param serverTags - The server's tags
|
|
115
139
|
*/
|
|
116
140
|
function tagSetMatch(tagSet, serverTags) {
|
|
117
|
-
|
|
118
|
-
const serverTagKeys = Object.keys(serverTags);
|
|
119
|
-
for (let i = 0; i < keys.length; ++i) {
|
|
120
|
-
const key = keys[i];
|
|
121
|
-
if (serverTagKeys.indexOf(key) === -1 || serverTags[key] !== tagSet[key]) {
|
|
122
|
-
return false;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
return true;
|
|
141
|
+
return Object.entries(tagSet).every(([key, value]) => serverTags[key] != null && serverTags[key] === value);
|
|
126
142
|
}
|
|
127
143
|
/**
|
|
128
144
|
* Reduces a set of server descriptions based on tags requested by the read preference
|
|
@@ -131,18 +147,13 @@ function tagSetMatch(tagSet, serverTags) {
|
|
|
131
147
|
* @param servers - The list of server descriptions to reduce
|
|
132
148
|
* @returns The list of servers matching the requested tags
|
|
133
149
|
*/
|
|
134
|
-
function tagSetReducer(
|
|
135
|
-
if (
|
|
136
|
-
|
|
150
|
+
function tagSetReducer({ tags }, servers) {
|
|
151
|
+
if (tags == null || tags.length === 0) {
|
|
152
|
+
// empty tag sets match all servers
|
|
137
153
|
return servers;
|
|
138
154
|
}
|
|
139
|
-
for (
|
|
140
|
-
const
|
|
141
|
-
const serversMatchingTagset = servers.reduce((matched, server) => {
|
|
142
|
-
if (tagSetMatch(tagSet, server.tags))
|
|
143
|
-
matched.push(server);
|
|
144
|
-
return matched;
|
|
145
|
-
}, []);
|
|
155
|
+
for (const tagSet of tags) {
|
|
156
|
+
const serversMatchingTagset = servers.filter((s) => tagSetMatch(tagSet, s.tags));
|
|
146
157
|
if (serversMatchingTagset.length) {
|
|
147
158
|
return serversMatchingTagset;
|
|
148
159
|
}
|
|
@@ -162,11 +173,7 @@ function tagSetReducer(readPreference, servers) {
|
|
|
162
173
|
function latencyWindowReducer(topologyDescription, servers) {
|
|
163
174
|
const low = servers.reduce((min, server) => Math.min(server.roundTripTime, min), Infinity);
|
|
164
175
|
const high = low + topologyDescription.localThresholdMS;
|
|
165
|
-
return servers.
|
|
166
|
-
if (server.roundTripTime <= high && server.roundTripTime >= low)
|
|
167
|
-
result.push(server);
|
|
168
|
-
return result;
|
|
169
|
-
}, []);
|
|
176
|
+
return servers.filter(server => server.roundTripTime <= high && server.roundTripTime >= low);
|
|
170
177
|
}
|
|
171
178
|
// filters
|
|
172
179
|
function primaryFilter(server) {
|
|
@@ -184,6 +191,75 @@ function knownFilter(server) {
|
|
|
184
191
|
function loadBalancerFilter(server) {
|
|
185
192
|
return server.type === common_1.ServerType.LoadBalancer;
|
|
186
193
|
}
|
|
194
|
+
function isDeprioritizedFactory(deprioritized) {
|
|
195
|
+
return server =>
|
|
196
|
+
// if any deprioritized servers equal the server, here we are.
|
|
197
|
+
!deprioritized.has(server);
|
|
198
|
+
}
|
|
199
|
+
function secondarySelector(readPreference, topologyDescription, servers, deprioritized) {
|
|
200
|
+
const mode = readPreference.mode;
|
|
201
|
+
switch (mode) {
|
|
202
|
+
case 'primary':
|
|
203
|
+
// Note: no need to filter for deprioritized servers. A replica set has only one primary; that means that
|
|
204
|
+
// we are in one of two scenarios:
|
|
205
|
+
// 1. deprioritized servers is empty - return the primary.
|
|
206
|
+
// 2. deprioritized servers contains the primary - return the primary.
|
|
207
|
+
return servers.filter(primaryFilter);
|
|
208
|
+
case 'primaryPreferred': {
|
|
209
|
+
const primary = servers.filter(primaryFilter);
|
|
210
|
+
// If there is a primary and it is not deprioritized, use the primary. Otherwise,
|
|
211
|
+
// check for secondaries.
|
|
212
|
+
const eligiblePrimary = primary.filter(isDeprioritizedFactory(deprioritized));
|
|
213
|
+
if (eligiblePrimary.length) {
|
|
214
|
+
return eligiblePrimary;
|
|
215
|
+
}
|
|
216
|
+
// If we make it here, we either have:
|
|
217
|
+
// 1. a deprioritized primary
|
|
218
|
+
// 2. no eligible primary
|
|
219
|
+
// secondaries take precedence of deprioritized primaries.
|
|
220
|
+
const secondaries = tagSetReducer(readPreference, maxStalenessReducer(readPreference, topologyDescription, servers.filter(secondaryFilter)));
|
|
221
|
+
const eligibleSecondaries = secondaries.filter(isDeprioritizedFactory(deprioritized));
|
|
222
|
+
if (eligibleSecondaries.length) {
|
|
223
|
+
return latencyWindowReducer(topologyDescription, eligibleSecondaries);
|
|
224
|
+
}
|
|
225
|
+
// if we make it here, we have no primaries or secondaries that not deprioritized.
|
|
226
|
+
// prefer the primary (which may not exist, if the topology has no primary).
|
|
227
|
+
// otherwise, return the secondaries (which also may not exist, but there is nothing else to check here).
|
|
228
|
+
return primary.length ? primary : latencyWindowReducer(topologyDescription, secondaries);
|
|
229
|
+
}
|
|
230
|
+
case 'nearest': {
|
|
231
|
+
const eligible = filterDeprioritized(tagSetReducer(readPreference, maxStalenessReducer(readPreference, topologyDescription, servers.filter(nearestFilter))), deprioritized);
|
|
232
|
+
return latencyWindowReducer(topologyDescription, eligible);
|
|
233
|
+
}
|
|
234
|
+
case 'secondary':
|
|
235
|
+
case 'secondaryPreferred': {
|
|
236
|
+
const secondaries = tagSetReducer(readPreference, maxStalenessReducer(readPreference, topologyDescription, servers.filter(secondaryFilter)));
|
|
237
|
+
const eligibleSecondaries = secondaries.filter(isDeprioritizedFactory(deprioritized));
|
|
238
|
+
if (eligibleSecondaries.length) {
|
|
239
|
+
return latencyWindowReducer(topologyDescription, eligibleSecondaries);
|
|
240
|
+
}
|
|
241
|
+
// we have no eligible secondaries, try for a primary if we can.
|
|
242
|
+
if (mode === read_preference_1.ReadPreference.SECONDARY_PREFERRED) {
|
|
243
|
+
const primary = servers.filter(primaryFilter);
|
|
244
|
+
// unlike readPreference=primary, here we do filter for deprioritized servers.
|
|
245
|
+
// if the primary is deprioritized, deprioritized secondaries take precedence.
|
|
246
|
+
const eligiblePrimary = primary.filter(isDeprioritizedFactory(deprioritized));
|
|
247
|
+
if (eligiblePrimary.length)
|
|
248
|
+
return eligiblePrimary;
|
|
249
|
+
// we have no eligible primary nor secondaries that have not been deprioritized
|
|
250
|
+
return secondaries.length
|
|
251
|
+
? latencyWindowReducer(topologyDescription, secondaries)
|
|
252
|
+
: primary;
|
|
253
|
+
}
|
|
254
|
+
// return all secondaries in the latency window.
|
|
255
|
+
return latencyWindowReducer(topologyDescription, secondaries);
|
|
256
|
+
}
|
|
257
|
+
default: {
|
|
258
|
+
const _exhaustiveCheck = mode;
|
|
259
|
+
throw new error_1.MongoRuntimeError(`unexpected readPreference=${mode} (should never happen). Please report a bug in the Node driver Jira project.`);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
187
263
|
/**
|
|
188
264
|
* Returns a function which selects servers based on a provided read preference
|
|
189
265
|
*
|
|
@@ -193,39 +269,26 @@ function readPreferenceServerSelector(readPreference) {
|
|
|
193
269
|
if (!readPreference.isValid()) {
|
|
194
270
|
throw new error_1.MongoInvalidArgumentError('Invalid read preference specified');
|
|
195
271
|
}
|
|
196
|
-
return function readPreferenceServers(topologyDescription, servers, deprioritized
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
return
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
if (mode === read_preference_1.ReadPreference.PRIMARY) {
|
|
215
|
-
return servers.filter(primaryFilter);
|
|
216
|
-
}
|
|
217
|
-
if (mode === read_preference_1.ReadPreference.PRIMARY_PREFERRED) {
|
|
218
|
-
const result = servers.filter(primaryFilter);
|
|
219
|
-
if (result.length) {
|
|
220
|
-
return result;
|
|
272
|
+
return function readPreferenceServers(topologyDescription, servers, deprioritized) {
|
|
273
|
+
switch (topologyDescription.type) {
|
|
274
|
+
case 'Single':
|
|
275
|
+
return latencyWindowReducer(topologyDescription, servers.filter(knownFilter));
|
|
276
|
+
case 'ReplicaSetNoPrimary':
|
|
277
|
+
case 'ReplicaSetWithPrimary':
|
|
278
|
+
return secondarySelector(readPreference, topologyDescription, servers, deprioritized);
|
|
279
|
+
case 'Sharded': {
|
|
280
|
+
const selectable = filterDeprioritized(servers, deprioritized);
|
|
281
|
+
return latencyWindowReducer(topologyDescription, selectable.filter(knownFilter));
|
|
282
|
+
}
|
|
283
|
+
case 'Unknown':
|
|
284
|
+
return [];
|
|
285
|
+
case 'LoadBalanced':
|
|
286
|
+
return servers.filter(loadBalancerFilter);
|
|
287
|
+
default: {
|
|
288
|
+
const _exhaustiveCheck = topologyDescription.type;
|
|
289
|
+
throw new error_1.MongoRuntimeError(`unexpected topology type: ${topologyDescription.type} (this should never happen). Please file a bug in the Node driver Jira project.`);
|
|
221
290
|
}
|
|
222
291
|
}
|
|
223
|
-
const filter = mode === read_preference_1.ReadPreference.NEAREST ? nearestFilter : secondaryFilter;
|
|
224
|
-
const selectedServers = latencyWindowReducer(topologyDescription, tagSetReducer(readPreference, maxStalenessReducer(readPreference, topologyDescription, servers.filter(filter))));
|
|
225
|
-
if (mode === read_preference_1.ReadPreference.SECONDARY_PREFERRED && selectedServers.length === 0) {
|
|
226
|
-
return servers.filter(primaryFilter);
|
|
227
|
-
}
|
|
228
|
-
return selectedServers;
|
|
229
292
|
};
|
|
230
293
|
}
|
|
231
294
|
//# sourceMappingURL=server_selection.js.map
|
|
@@ -21,6 +21,8 @@ class SrvPollingEvent {
|
|
|
21
21
|
exports.SrvPollingEvent = SrvPollingEvent;
|
|
22
22
|
/** @internal */
|
|
23
23
|
class SrvPoller extends mongo_types_1.TypedEventEmitter {
|
|
24
|
+
/** @event */
|
|
25
|
+
static { this.SRV_RECORD_DISCOVERY = 'srvRecordDiscovery'; }
|
|
24
26
|
constructor(options) {
|
|
25
27
|
super();
|
|
26
28
|
this.on('error', utils_1.noop);
|
|
@@ -76,7 +78,7 @@ class SrvPoller extends mongo_types_1.TypedEventEmitter {
|
|
|
76
78
|
const generation = this.generation;
|
|
77
79
|
let srvRecords;
|
|
78
80
|
try {
|
|
79
|
-
srvRecords = await dns.promises.
|
|
81
|
+
srvRecords = await dns.promises.resolve(this.srvAddress, 'SRV');
|
|
80
82
|
}
|
|
81
83
|
catch {
|
|
82
84
|
this.failure();
|
|
@@ -103,6 +105,4 @@ class SrvPoller extends mongo_types_1.TypedEventEmitter {
|
|
|
103
105
|
}
|
|
104
106
|
}
|
|
105
107
|
exports.SrvPoller = SrvPoller;
|
|
106
|
-
/** @event */
|
|
107
|
-
SrvPoller.SRV_RECORD_DISCOVERY = 'srvRecordDiscovery';
|
|
108
108
|
//# sourceMappingURL=srv_polling.js.map
|