@depup/mongodb 7.1.0-depup.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/LICENSE.md +201 -0
- package/README.md +33 -0
- package/etc/prepare.js +12 -0
- package/lib/admin.js +136 -0
- package/lib/admin.js.map +1 -0
- package/lib/bson.js +85 -0
- package/lib/bson.js.map +1 -0
- package/lib/bulk/common.js +835 -0
- package/lib/bulk/common.js.map +1 -0
- package/lib/bulk/ordered.js +67 -0
- package/lib/bulk/ordered.js.map +1 -0
- package/lib/bulk/unordered.js +92 -0
- package/lib/bulk/unordered.js.map +1 -0
- package/lib/change_stream.js +513 -0
- package/lib/change_stream.js.map +1 -0
- package/lib/client-side-encryption/auto_encrypter.js +272 -0
- package/lib/client-side-encryption/auto_encrypter.js.map +1 -0
- package/lib/client-side-encryption/client_encryption.js +609 -0
- package/lib/client-side-encryption/client_encryption.js.map +1 -0
- package/lib/client-side-encryption/errors.js +138 -0
- package/lib/client-side-encryption/errors.js.map +1 -0
- package/lib/client-side-encryption/mongocryptd_manager.js +85 -0
- package/lib/client-side-encryption/mongocryptd_manager.js.map +1 -0
- package/lib/client-side-encryption/providers/aws.js +23 -0
- package/lib/client-side-encryption/providers/aws.js.map +1 -0
- package/lib/client-side-encryption/providers/azure.js +132 -0
- package/lib/client-side-encryption/providers/azure.js.map +1 -0
- package/lib/client-side-encryption/providers/gcp.js +16 -0
- package/lib/client-side-encryption/providers/gcp.js.map +1 -0
- package/lib/client-side-encryption/providers/index.js +43 -0
- package/lib/client-side-encryption/providers/index.js.map +1 -0
- package/lib/client-side-encryption/state_machine.js +427 -0
- package/lib/client-side-encryption/state_machine.js.map +1 -0
- package/lib/cmap/auth/auth_provider.js +51 -0
- package/lib/cmap/auth/auth_provider.js.map +1 -0
- package/lib/cmap/auth/aws4.js +161 -0
- package/lib/cmap/auth/aws4.js.map +1 -0
- package/lib/cmap/auth/aws_temporary_credentials.js +103 -0
- package/lib/cmap/auth/aws_temporary_credentials.js.map +1 -0
- package/lib/cmap/auth/gssapi.js +155 -0
- package/lib/cmap/auth/gssapi.js.map +1 -0
- package/lib/cmap/auth/mongo_credentials.js +169 -0
- package/lib/cmap/auth/mongo_credentials.js.map +1 -0
- package/lib/cmap/auth/mongodb_aws.js +128 -0
- package/lib/cmap/auth/mongodb_aws.js.map +1 -0
- package/lib/cmap/auth/mongodb_oidc/automated_callback_workflow.js +84 -0
- package/lib/cmap/auth/mongodb_oidc/automated_callback_workflow.js.map +1 -0
- package/lib/cmap/auth/mongodb_oidc/azure_machine_workflow.js +62 -0
- package/lib/cmap/auth/mongodb_oidc/azure_machine_workflow.js.map +1 -0
- package/lib/cmap/auth/mongodb_oidc/callback_workflow.js +141 -0
- package/lib/cmap/auth/mongodb_oidc/callback_workflow.js.map +1 -0
- package/lib/cmap/auth/mongodb_oidc/command_builders.js +44 -0
- package/lib/cmap/auth/mongodb_oidc/command_builders.js.map +1 -0
- package/lib/cmap/auth/mongodb_oidc/gcp_machine_workflow.js +39 -0
- package/lib/cmap/auth/mongodb_oidc/gcp_machine_workflow.js.map +1 -0
- package/lib/cmap/auth/mongodb_oidc/human_callback_workflow.js +122 -0
- package/lib/cmap/auth/mongodb_oidc/human_callback_workflow.js.map +1 -0
- package/lib/cmap/auth/mongodb_oidc/k8s_machine_workflow.js +32 -0
- package/lib/cmap/auth/mongodb_oidc/k8s_machine_workflow.js.map +1 -0
- package/lib/cmap/auth/mongodb_oidc/token_cache.js +52 -0
- package/lib/cmap/auth/mongodb_oidc/token_cache.js.map +1 -0
- package/lib/cmap/auth/mongodb_oidc/token_machine_workflow.js +23 -0
- package/lib/cmap/auth/mongodb_oidc/token_machine_workflow.js.map +1 -0
- package/lib/cmap/auth/mongodb_oidc.js +73 -0
- package/lib/cmap/auth/mongodb_oidc.js.map +1 -0
- package/lib/cmap/auth/plain.js +26 -0
- package/lib/cmap/auth/plain.js.map +1 -0
- package/lib/cmap/auth/providers.js +22 -0
- package/lib/cmap/auth/providers.js.map +1 -0
- package/lib/cmap/auth/scram.js +254 -0
- package/lib/cmap/auth/scram.js.map +1 -0
- package/lib/cmap/auth/x509.js +36 -0
- package/lib/cmap/auth/x509.js.map +1 -0
- package/lib/cmap/command_monitoring_events.js +223 -0
- package/lib/cmap/command_monitoring_events.js.map +1 -0
- package/lib/cmap/commands.js +535 -0
- package/lib/cmap/commands.js.map +1 -0
- package/lib/cmap/connect.js +381 -0
- package/lib/cmap/connect.js.map +1 -0
- package/lib/cmap/connection.js +571 -0
- package/lib/cmap/connection.js.map +1 -0
- package/lib/cmap/connection_pool.js +558 -0
- package/lib/cmap/connection_pool.js.map +1 -0
- package/lib/cmap/connection_pool_events.js +190 -0
- package/lib/cmap/connection_pool_events.js.map +1 -0
- package/lib/cmap/errors.js +108 -0
- package/lib/cmap/errors.js.map +1 -0
- package/lib/cmap/handshake/client_metadata.js +242 -0
- package/lib/cmap/handshake/client_metadata.js.map +1 -0
- package/lib/cmap/metrics.js +62 -0
- package/lib/cmap/metrics.js.map +1 -0
- package/lib/cmap/stream_description.js +70 -0
- package/lib/cmap/stream_description.js.map +1 -0
- package/lib/cmap/wire_protocol/compression.js +178 -0
- package/lib/cmap/wire_protocol/compression.js.map +1 -0
- package/lib/cmap/wire_protocol/constants.js +21 -0
- package/lib/cmap/wire_protocol/constants.js.map +1 -0
- package/lib/cmap/wire_protocol/on_data.js +111 -0
- package/lib/cmap/wire_protocol/on_data.js.map +1 -0
- package/lib/cmap/wire_protocol/on_demand/document.js +222 -0
- package/lib/cmap/wire_protocol/on_demand/document.js.map +1 -0
- package/lib/cmap/wire_protocol/responses.js +315 -0
- package/lib/cmap/wire_protocol/responses.js.map +1 -0
- package/lib/cmap/wire_protocol/shared.js +35 -0
- package/lib/cmap/wire_protocol/shared.js.map +1 -0
- package/lib/collection.js +751 -0
- package/lib/collection.js.map +1 -0
- package/lib/connection_string.js +1090 -0
- package/lib/connection_string.js.map +1 -0
- package/lib/constants.js +170 -0
- package/lib/constants.js.map +1 -0
- package/lib/cursor/abstract_cursor.js +924 -0
- package/lib/cursor/abstract_cursor.js.map +1 -0
- package/lib/cursor/aggregation_cursor.js +164 -0
- package/lib/cursor/aggregation_cursor.js.map +1 -0
- package/lib/cursor/change_stream_cursor.js +104 -0
- package/lib/cursor/change_stream_cursor.js.map +1 -0
- package/lib/cursor/client_bulk_write_cursor.js +52 -0
- package/lib/cursor/client_bulk_write_cursor.js.map +1 -0
- package/lib/cursor/explainable_cursor.js +36 -0
- package/lib/cursor/explainable_cursor.js.map +1 -0
- package/lib/cursor/find_cursor.js +399 -0
- package/lib/cursor/find_cursor.js.map +1 -0
- package/lib/cursor/list_collections_cursor.js +34 -0
- package/lib/cursor/list_collections_cursor.js.map +1 -0
- package/lib/cursor/list_indexes_cursor.js +32 -0
- package/lib/cursor/list_indexes_cursor.js.map +1 -0
- package/lib/cursor/list_search_indexes_cursor.js +14 -0
- package/lib/cursor/list_search_indexes_cursor.js.map +1 -0
- package/lib/cursor/run_command_cursor.js +94 -0
- package/lib/cursor/run_command_cursor.js.map +1 -0
- package/lib/db.js +419 -0
- package/lib/db.js.map +1 -0
- package/lib/deps.js +112 -0
- package/lib/deps.js.map +1 -0
- package/lib/encrypter.js +106 -0
- package/lib/encrypter.js.map +1 -0
- package/lib/error.js +1380 -0
- package/lib/error.js.map +1 -0
- package/lib/explain.js +59 -0
- package/lib/explain.js.map +1 -0
- package/lib/gridfs/download.js +305 -0
- package/lib/gridfs/download.js.map +1 -0
- package/lib/gridfs/index.js +164 -0
- package/lib/gridfs/index.js.map +1 -0
- package/lib/gridfs/upload.js +358 -0
- package/lib/gridfs/upload.js.map +1 -0
- package/lib/index.js +193 -0
- package/lib/index.js.map +1 -0
- package/lib/mongo_client.js +557 -0
- package/lib/mongo_client.js.map +1 -0
- package/lib/mongo_client_auth_providers.js +80 -0
- package/lib/mongo_client_auth_providers.js.map +1 -0
- package/lib/mongo_logger.js +655 -0
- package/lib/mongo_logger.js.map +1 -0
- package/lib/mongo_types.js +56 -0
- package/lib/mongo_types.js.map +1 -0
- package/lib/operations/aggregate.js +90 -0
- package/lib/operations/aggregate.js.map +1 -0
- package/lib/operations/client_bulk_write/client_bulk_write.js +51 -0
- package/lib/operations/client_bulk_write/client_bulk_write.js.map +1 -0
- package/lib/operations/client_bulk_write/command_builder.js +340 -0
- package/lib/operations/client_bulk_write/command_builder.js.map +1 -0
- package/lib/operations/client_bulk_write/common.js +3 -0
- package/lib/operations/client_bulk_write/common.js.map +1 -0
- package/lib/operations/client_bulk_write/executor.js +120 -0
- package/lib/operations/client_bulk_write/executor.js.map +1 -0
- package/lib/operations/client_bulk_write/results_merger.js +204 -0
- package/lib/operations/client_bulk_write/results_merger.js.map +1 -0
- package/lib/operations/command.js +83 -0
- package/lib/operations/command.js.map +1 -0
- package/lib/operations/count.js +45 -0
- package/lib/operations/count.js.map +1 -0
- package/lib/operations/create_collection.js +109 -0
- package/lib/operations/create_collection.js.map +1 -0
- package/lib/operations/delete.js +125 -0
- package/lib/operations/delete.js.map +1 -0
- package/lib/operations/distinct.js +61 -0
- package/lib/operations/distinct.js.map +1 -0
- package/lib/operations/drop.js +93 -0
- package/lib/operations/drop.js.map +1 -0
- package/lib/operations/end_sessions.js +34 -0
- package/lib/operations/end_sessions.js.map +1 -0
- package/lib/operations/estimated_document_count.js +41 -0
- package/lib/operations/estimated_document_count.js.map +1 -0
- package/lib/operations/execute_operation.js +239 -0
- package/lib/operations/execute_operation.js.map +1 -0
- package/lib/operations/find.js +148 -0
- package/lib/operations/find.js.map +1 -0
- package/lib/operations/find_and_modify.js +158 -0
- package/lib/operations/find_and_modify.js.map +1 -0
- package/lib/operations/get_more.js +62 -0
- package/lib/operations/get_more.js.map +1 -0
- package/lib/operations/indexes.js +186 -0
- package/lib/operations/indexes.js.map +1 -0
- package/lib/operations/insert.js +70 -0
- package/lib/operations/insert.js.map +1 -0
- package/lib/operations/kill_cursors.js +43 -0
- package/lib/operations/kill_cursors.js.map +1 -0
- package/lib/operations/list_collections.js +53 -0
- package/lib/operations/list_collections.js.map +1 -0
- package/lib/operations/list_databases.js +40 -0
- package/lib/operations/list_databases.js.map +1 -0
- package/lib/operations/operation.js +102 -0
- package/lib/operations/operation.js.map +1 -0
- package/lib/operations/profiling_level.js +43 -0
- package/lib/operations/profiling_level.js.map +1 -0
- package/lib/operations/remove_user.js +27 -0
- package/lib/operations/remove_user.js.map +1 -0
- package/lib/operations/rename.js +38 -0
- package/lib/operations/rename.js.map +1 -0
- package/lib/operations/run_command.js +47 -0
- package/lib/operations/run_command.js.map +1 -0
- package/lib/operations/search_indexes/create.js +33 -0
- package/lib/operations/search_indexes/create.js.map +1 -0
- package/lib/operations/search_indexes/drop.js +43 -0
- package/lib/operations/search_indexes/drop.js.map +1 -0
- package/lib/operations/search_indexes/update.js +35 -0
- package/lib/operations/search_indexes/update.js.map +1 -0
- package/lib/operations/set_profiling_level.js +53 -0
- package/lib/operations/set_profiling_level.js.map +1 -0
- package/lib/operations/stats.js +27 -0
- package/lib/operations/stats.js.map +1 -0
- package/lib/operations/update.js +188 -0
- package/lib/operations/update.js.map +1 -0
- package/lib/operations/validate_collection.js +37 -0
- package/lib/operations/validate_collection.js.map +1 -0
- package/lib/read_concern.js +73 -0
- package/lib/read_concern.js.map +1 -0
- package/lib/read_preference.js +191 -0
- package/lib/read_preference.js.map +1 -0
- package/lib/sdam/common.js +49 -0
- package/lib/sdam/common.js.map +1 -0
- package/lib/sdam/events.js +146 -0
- package/lib/sdam/events.js.map +1 -0
- package/lib/sdam/monitor.js +544 -0
- package/lib/sdam/monitor.js.map +1 -0
- package/lib/sdam/server.js +404 -0
- package/lib/sdam/server.js.map +1 -0
- package/lib/sdam/server_description.js +204 -0
- package/lib/sdam/server_description.js.map +1 -0
- package/lib/sdam/server_selection.js +294 -0
- package/lib/sdam/server_selection.js.map +1 -0
- package/lib/sdam/server_selection_events.js +85 -0
- package/lib/sdam/server_selection_events.js.map +1 -0
- package/lib/sdam/srv_polling.js +108 -0
- package/lib/sdam/srv_polling.js.map +1 -0
- package/lib/sdam/topology.js +652 -0
- package/lib/sdam/topology.js.map +1 -0
- package/lib/sdam/topology_description.js +383 -0
- package/lib/sdam/topology_description.js.map +1 -0
- package/lib/sessions.js +892 -0
- package/lib/sessions.js.map +1 -0
- package/lib/sort.js +103 -0
- package/lib/sort.js.map +1 -0
- package/lib/timeout.js +296 -0
- package/lib/timeout.js.map +1 -0
- package/lib/transactions.js +135 -0
- package/lib/transactions.js.map +1 -0
- package/lib/utils.js +1163 -0
- package/lib/utils.js.map +1 -0
- package/lib/write_concern.js +100 -0
- package/lib/write_concern.js.map +1 -0
- package/mongodb.d.ts +9018 -0
- package/package.json +197 -0
- package/src/admin.ts +173 -0
- package/src/bson.ts +149 -0
- package/src/bulk/common.ts +1251 -0
- package/src/bulk/ordered.ts +83 -0
- package/src/bulk/unordered.ts +115 -0
- package/src/change_stream.ts +1160 -0
- package/src/client-side-encryption/auto_encrypter.ts +469 -0
- package/src/client-side-encryption/client_encryption.ts +1150 -0
- package/src/client-side-encryption/errors.ts +144 -0
- package/src/client-side-encryption/mongocryptd_manager.ts +100 -0
- package/src/client-side-encryption/providers/aws.ts +33 -0
- package/src/client-side-encryption/providers/azure.ts +181 -0
- package/src/client-side-encryption/providers/gcp.ts +16 -0
- package/src/client-side-encryption/providers/index.ts +207 -0
- package/src/client-side-encryption/state_machine.ts +651 -0
- package/src/cmap/auth/auth_provider.ts +77 -0
- package/src/cmap/auth/aws4.ts +207 -0
- package/src/cmap/auth/aws_temporary_credentials.ts +129 -0
- package/src/cmap/auth/gssapi.ts +203 -0
- package/src/cmap/auth/mongo_credentials.ts +292 -0
- package/src/cmap/auth/mongodb_aws.ts +179 -0
- package/src/cmap/auth/mongodb_oidc/automated_callback_workflow.ts +88 -0
- package/src/cmap/auth/mongodb_oidc/azure_machine_workflow.ts +73 -0
- package/src/cmap/auth/mongodb_oidc/callback_workflow.ts +188 -0
- package/src/cmap/auth/mongodb_oidc/command_builders.ts +53 -0
- package/src/cmap/auth/mongodb_oidc/gcp_machine_workflow.ts +46 -0
- package/src/cmap/auth/mongodb_oidc/human_callback_workflow.ts +141 -0
- package/src/cmap/auth/mongodb_oidc/k8s_machine_workflow.ts +31 -0
- package/src/cmap/auth/mongodb_oidc/token_cache.ts +62 -0
- package/src/cmap/auth/mongodb_oidc/token_machine_workflow.ts +22 -0
- package/src/cmap/auth/mongodb_oidc.ts +185 -0
- package/src/cmap/auth/plain.ts +25 -0
- package/src/cmap/auth/providers.ts +22 -0
- package/src/cmap/auth/scram.ts +344 -0
- package/src/cmap/auth/x509.ts +43 -0
- package/src/cmap/command_monitoring_events.ts +316 -0
- package/src/cmap/commands.ts +788 -0
- package/src/cmap/connect.ts +518 -0
- package/src/cmap/connection.ts +931 -0
- package/src/cmap/connection_pool.ts +831 -0
- package/src/cmap/connection_pool_events.ts +300 -0
- package/src/cmap/errors.ts +119 -0
- package/src/cmap/handshake/client_metadata.ts +353 -0
- package/src/cmap/metrics.ts +58 -0
- package/src/cmap/stream_description.ts +96 -0
- package/src/cmap/wire_protocol/compression.ts +211 -0
- package/src/cmap/wire_protocol/constants.ts +17 -0
- package/src/cmap/wire_protocol/on_data.ts +139 -0
- package/src/cmap/wire_protocol/on_demand/document.ts +358 -0
- package/src/cmap/wire_protocol/responses.ts +393 -0
- package/src/cmap/wire_protocol/shared.ts +48 -0
- package/src/collection.ts +1314 -0
- package/src/connection_string.ts +1297 -0
- package/src/constants.ts +176 -0
- package/src/cursor/abstract_cursor.ts +1247 -0
- package/src/cursor/aggregation_cursor.ts +245 -0
- package/src/cursor/change_stream_cursor.ts +171 -0
- package/src/cursor/client_bulk_write_cursor.ts +83 -0
- package/src/cursor/explainable_cursor.ts +51 -0
- package/src/cursor/find_cursor.ts +497 -0
- package/src/cursor/list_collections_cursor.ts +50 -0
- package/src/cursor/list_indexes_cursor.ts +37 -0
- package/src/cursor/list_search_indexes_cursor.ts +20 -0
- package/src/cursor/run_command_cursor.ts +178 -0
- package/src/db.ts +621 -0
- package/src/deps.ts +227 -0
- package/src/encrypter.ts +127 -0
- package/src/error.ts +1567 -0
- package/src/explain.ts +124 -0
- package/src/gridfs/download.ts +483 -0
- package/src/gridfs/index.ts +264 -0
- package/src/gridfs/upload.ts +537 -0
- package/src/index.ts +633 -0
- package/src/mongo_client.ts +1155 -0
- package/src/mongo_client_auth_providers.ts +87 -0
- package/src/mongo_logger.ts +1081 -0
- package/src/mongo_types.ts +678 -0
- package/src/operations/aggregate.ts +153 -0
- package/src/operations/client_bulk_write/client_bulk_write.ts +72 -0
- package/src/operations/client_bulk_write/command_builder.ts +487 -0
- package/src/operations/client_bulk_write/common.ts +276 -0
- package/src/operations/client_bulk_write/executor.ts +149 -0
- package/src/operations/client_bulk_write/results_merger.ts +260 -0
- package/src/operations/command.ts +171 -0
- package/src/operations/count.ts +74 -0
- package/src/operations/create_collection.ts +218 -0
- package/src/operations/delete.ts +183 -0
- package/src/operations/distinct.ts +92 -0
- package/src/operations/drop.ts +130 -0
- package/src/operations/end_sessions.ts +44 -0
- package/src/operations/estimated_document_count.ts +61 -0
- package/src/operations/execute_operation.ts +319 -0
- package/src/operations/find.ts +254 -0
- package/src/operations/find_and_modify.ts +319 -0
- package/src/operations/get_more.ts +108 -0
- package/src/operations/indexes.ts +418 -0
- package/src/operations/insert.ts +108 -0
- package/src/operations/kill_cursors.ts +64 -0
- package/src/operations/list_collections.ts +108 -0
- package/src/operations/list_databases.ts +68 -0
- package/src/operations/operation.ts +181 -0
- package/src/operations/profiling_level.ts +46 -0
- package/src/operations/remove_user.ts +36 -0
- package/src/operations/rename.ts +60 -0
- package/src/operations/run_command.ts +79 -0
- package/src/operations/search_indexes/create.ts +56 -0
- package/src/operations/search_indexes/drop.ts +58 -0
- package/src/operations/search_indexes/update.ts +45 -0
- package/src/operations/set_profiling_level.ts +74 -0
- package/src/operations/stats.ts +37 -0
- package/src/operations/update.ts +318 -0
- package/src/operations/validate_collection.ts +50 -0
- package/src/read_concern.ts +88 -0
- package/src/read_preference.ts +256 -0
- package/src/sdam/common.ts +74 -0
- package/src/sdam/events.ts +219 -0
- package/src/sdam/monitor.ts +771 -0
- package/src/sdam/server.ts +595 -0
- package/src/sdam/server_description.ts +297 -0
- package/src/sdam/server_selection.ts +415 -0
- package/src/sdam/server_selection_events.ts +142 -0
- package/src/sdam/srv_polling.ts +146 -0
- package/src/sdam/topology.ts +1100 -0
- package/src/sdam/topology_description.ts +548 -0
- package/src/sessions.ts +1244 -0
- package/src/sort.ts +141 -0
- package/src/timeout.ts +405 -0
- package/src/transactions.ts +181 -0
- package/src/utils.ts +1434 -0
- package/src/write_concern.ts +183 -0
- package/tsconfig.json +46 -0
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
import * as os from 'os';
|
|
2
|
+
import * as process from 'process';
|
|
3
|
+
|
|
4
|
+
import { BSON, type Document, Int32, NumberUtils } from '../../bson';
|
|
5
|
+
import { MongoInvalidArgumentError } from '../../error';
|
|
6
|
+
import type { DriverInfo, MongoOptions } from '../../mongo_client';
|
|
7
|
+
import { fileIsAccessible } from '../../utils';
|
|
8
|
+
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
10
|
+
const NODE_DRIVER_VERSION = require('../../../package.json').version;
|
|
11
|
+
|
|
12
|
+
/** @internal */
|
|
13
|
+
export function isDriverInfoEqual(info1: DriverInfo, info2: DriverInfo): boolean {
|
|
14
|
+
/** for equality comparison, we consider "" as unset */
|
|
15
|
+
const nonEmptyCmp = (s1: string | undefined, s2: string | undefined): boolean => {
|
|
16
|
+
s1 ||= undefined;
|
|
17
|
+
s2 ||= undefined;
|
|
18
|
+
|
|
19
|
+
return s1 === s2;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
nonEmptyCmp(info1.name, info2.name) &&
|
|
24
|
+
nonEmptyCmp(info1.platform, info2.platform) &&
|
|
25
|
+
nonEmptyCmp(info1.version, info2.version)
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @internal
|
|
31
|
+
* @see https://github.com/mongodb/specifications/blob/master/source/mongodb-handshake/handshake.md#hello-command
|
|
32
|
+
*/
|
|
33
|
+
export interface ClientMetadata {
|
|
34
|
+
driver: {
|
|
35
|
+
name: string;
|
|
36
|
+
version: string;
|
|
37
|
+
};
|
|
38
|
+
os: {
|
|
39
|
+
type: string;
|
|
40
|
+
name?: NodeJS.Platform;
|
|
41
|
+
architecture?: string;
|
|
42
|
+
version?: string;
|
|
43
|
+
};
|
|
44
|
+
platform: string;
|
|
45
|
+
application?: {
|
|
46
|
+
name: string;
|
|
47
|
+
};
|
|
48
|
+
/** FaaS environment information */
|
|
49
|
+
env?: {
|
|
50
|
+
name?: 'aws.lambda' | 'gcp.func' | 'azure.func' | 'vercel';
|
|
51
|
+
timeout_sec?: Int32;
|
|
52
|
+
memory_mb?: Int32;
|
|
53
|
+
region?: string;
|
|
54
|
+
container?: {
|
|
55
|
+
runtime?: string;
|
|
56
|
+
orchestrator?: string;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** @internal */
|
|
62
|
+
export class LimitedSizeDocument {
|
|
63
|
+
private document = new Map();
|
|
64
|
+
/** BSON overhead: Int32 + Null byte */
|
|
65
|
+
private documentSize = 5;
|
|
66
|
+
private maxSize: number;
|
|
67
|
+
|
|
68
|
+
constructor(maxSize: number) {
|
|
69
|
+
this.maxSize = maxSize;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Only adds key/value if the bsonByteLength is less than MAX_SIZE */
|
|
73
|
+
public ifItFitsItSits(key: string, value: Record<string, any> | string): boolean {
|
|
74
|
+
// The BSON byteLength of the new element is the same as serializing it to its own document
|
|
75
|
+
// subtracting the document size int32 and the null terminator.
|
|
76
|
+
const newElementSize = BSON.serialize(new Map().set(key, value)).byteLength - 5;
|
|
77
|
+
|
|
78
|
+
if (newElementSize + this.documentSize > this.maxSize) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
this.documentSize += newElementSize;
|
|
83
|
+
|
|
84
|
+
this.document.set(key, value);
|
|
85
|
+
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
toObject(): Document {
|
|
90
|
+
return BSON.deserialize(BSON.serialize(this.document), {
|
|
91
|
+
promoteLongs: false,
|
|
92
|
+
promoteBuffers: false,
|
|
93
|
+
promoteValues: false,
|
|
94
|
+
useBigInt64: false
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
type MakeClientMetadataOptions = Pick<MongoOptions, 'appName'>;
|
|
100
|
+
/**
|
|
101
|
+
* From the specs:
|
|
102
|
+
* Implementors SHOULD cumulatively update fields in the following order until the document is under the size limit:
|
|
103
|
+
* 1. Omit fields from `env` except `env.name`.
|
|
104
|
+
* 2. Omit fields from `os` except `os.type`.
|
|
105
|
+
* 3. Omit the `env` document entirely.
|
|
106
|
+
* 4. Truncate `platform`. -- special we do not truncate this field
|
|
107
|
+
*/
|
|
108
|
+
export async function makeClientMetadata(
|
|
109
|
+
driverInfoList: DriverInfo[],
|
|
110
|
+
{ appName = '' }: MakeClientMetadataOptions
|
|
111
|
+
): Promise<ClientMetadata> {
|
|
112
|
+
const metadataDocument = new LimitedSizeDocument(512);
|
|
113
|
+
|
|
114
|
+
// Add app name first, it must be sent
|
|
115
|
+
if (appName.length > 0) {
|
|
116
|
+
const name =
|
|
117
|
+
Buffer.byteLength(appName, 'utf8') <= 128
|
|
118
|
+
? appName
|
|
119
|
+
: Buffer.from(appName, 'utf8').subarray(0, 128).toString('utf8');
|
|
120
|
+
metadataDocument.ifItFitsItSits('application', { name });
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const driverInfo = {
|
|
124
|
+
name: 'nodejs',
|
|
125
|
+
version: NODE_DRIVER_VERSION
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
// This is where we handle additional driver info added after client construction.
|
|
129
|
+
for (const { name: n = '', version: v = '' } of driverInfoList) {
|
|
130
|
+
if (n.length > 0) {
|
|
131
|
+
driverInfo.name = `${driverInfo.name}|${n}`;
|
|
132
|
+
}
|
|
133
|
+
if (v.length > 0) {
|
|
134
|
+
driverInfo.version = `${driverInfo.version}|${v}`;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (!metadataDocument.ifItFitsItSits('driver', driverInfo)) {
|
|
139
|
+
throw new MongoInvalidArgumentError(
|
|
140
|
+
'Unable to include driverInfo name and version, metadata cannot exceed 512 bytes'
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
let runtimeInfo = getRuntimeInfo();
|
|
145
|
+
// This is where we handle additional driver info added after client construction.
|
|
146
|
+
for (const { platform = '' } of driverInfoList) {
|
|
147
|
+
if (platform.length > 0) {
|
|
148
|
+
runtimeInfo = `${runtimeInfo}|${platform}`;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (!metadataDocument.ifItFitsItSits('platform', runtimeInfo)) {
|
|
153
|
+
throw new MongoInvalidArgumentError(
|
|
154
|
+
'Unable to include driverInfo platform, metadata cannot exceed 512 bytes'
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Note: order matters, os.type is last so it will be removed last if we're at maxSize
|
|
159
|
+
const osInfo = new Map()
|
|
160
|
+
.set('name', os.platform())
|
|
161
|
+
.set('architecture', os.arch())
|
|
162
|
+
.set('version', os.release())
|
|
163
|
+
.set('type', os.type());
|
|
164
|
+
|
|
165
|
+
if (!metadataDocument.ifItFitsItSits('os', osInfo)) {
|
|
166
|
+
for (const key of osInfo.keys()) {
|
|
167
|
+
osInfo.delete(key);
|
|
168
|
+
if (osInfo.size === 0) break;
|
|
169
|
+
if (metadataDocument.ifItFitsItSits('os', osInfo)) break;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const faasEnv = getFAASEnv();
|
|
174
|
+
if (faasEnv != null) {
|
|
175
|
+
if (!metadataDocument.ifItFitsItSits('env', faasEnv)) {
|
|
176
|
+
for (const key of faasEnv.keys()) {
|
|
177
|
+
faasEnv.delete(key);
|
|
178
|
+
if (faasEnv.size === 0) break;
|
|
179
|
+
if (metadataDocument.ifItFitsItSits('env', faasEnv)) break;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return await addContainerMetadata(metadataDocument.toObject() as ClientMetadata);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
let dockerPromise: Promise<boolean>;
|
|
187
|
+
type ContainerMetadata = NonNullable<NonNullable<ClientMetadata['env']>['container']>;
|
|
188
|
+
/** @internal */
|
|
189
|
+
async function getContainerMetadata(): Promise<ContainerMetadata> {
|
|
190
|
+
dockerPromise ??= fileIsAccessible('/.dockerenv');
|
|
191
|
+
const isDocker = await dockerPromise;
|
|
192
|
+
|
|
193
|
+
const { KUBERNETES_SERVICE_HOST = '' } = process.env;
|
|
194
|
+
const isKubernetes = KUBERNETES_SERVICE_HOST.length > 0 ? true : false;
|
|
195
|
+
|
|
196
|
+
const containerMetadata: ContainerMetadata = {};
|
|
197
|
+
|
|
198
|
+
if (isDocker) containerMetadata.runtime = 'docker';
|
|
199
|
+
if (isKubernetes) containerMetadata.orchestrator = 'kubernetes';
|
|
200
|
+
|
|
201
|
+
return containerMetadata;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* @internal
|
|
206
|
+
* Re-add each metadata value.
|
|
207
|
+
* Attempt to add new env container metadata, but keep old data if it does not fit.
|
|
208
|
+
*/
|
|
209
|
+
async function addContainerMetadata(originalMetadata: ClientMetadata): Promise<ClientMetadata> {
|
|
210
|
+
const containerMetadata = await getContainerMetadata();
|
|
211
|
+
if (Object.keys(containerMetadata).length === 0) return originalMetadata;
|
|
212
|
+
|
|
213
|
+
const extendedMetadata = new LimitedSizeDocument(512);
|
|
214
|
+
|
|
215
|
+
const extendedEnvMetadata: NonNullable<ClientMetadata['env']> = {
|
|
216
|
+
...originalMetadata?.env,
|
|
217
|
+
container: containerMetadata
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
for (const [key, val] of Object.entries(originalMetadata)) {
|
|
221
|
+
if (key !== 'env') {
|
|
222
|
+
extendedMetadata.ifItFitsItSits(key, val);
|
|
223
|
+
} else {
|
|
224
|
+
if (!extendedMetadata.ifItFitsItSits('env', extendedEnvMetadata)) {
|
|
225
|
+
// add in old data if newer / extended metadata does not fit
|
|
226
|
+
extendedMetadata.ifItFitsItSits('env', val);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
if (!('env' in originalMetadata)) {
|
|
232
|
+
extendedMetadata.ifItFitsItSits('env', extendedEnvMetadata);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
return extendedMetadata.toObject() as ClientMetadata;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Collects FaaS metadata.
|
|
240
|
+
* - `name` MUST be the last key in the Map returned.
|
|
241
|
+
*/
|
|
242
|
+
export function getFAASEnv(): Map<string, string | Int32> | null {
|
|
243
|
+
const {
|
|
244
|
+
AWS_EXECUTION_ENV = '',
|
|
245
|
+
AWS_LAMBDA_RUNTIME_API = '',
|
|
246
|
+
FUNCTIONS_WORKER_RUNTIME = '',
|
|
247
|
+
K_SERVICE = '',
|
|
248
|
+
FUNCTION_NAME = '',
|
|
249
|
+
VERCEL = '',
|
|
250
|
+
AWS_LAMBDA_FUNCTION_MEMORY_SIZE = '',
|
|
251
|
+
AWS_REGION = '',
|
|
252
|
+
FUNCTION_MEMORY_MB = '',
|
|
253
|
+
FUNCTION_REGION = '',
|
|
254
|
+
FUNCTION_TIMEOUT_SEC = '',
|
|
255
|
+
VERCEL_REGION = ''
|
|
256
|
+
} = process.env;
|
|
257
|
+
|
|
258
|
+
const isAWSFaaS =
|
|
259
|
+
AWS_EXECUTION_ENV.startsWith('AWS_Lambda_') || AWS_LAMBDA_RUNTIME_API.length > 0;
|
|
260
|
+
const isAzureFaaS = FUNCTIONS_WORKER_RUNTIME.length > 0;
|
|
261
|
+
const isGCPFaaS = K_SERVICE.length > 0 || FUNCTION_NAME.length > 0;
|
|
262
|
+
const isVercelFaaS = VERCEL.length > 0;
|
|
263
|
+
|
|
264
|
+
// Note: order matters, name must always be the last key
|
|
265
|
+
const faasEnv = new Map();
|
|
266
|
+
|
|
267
|
+
// When isVercelFaaS is true so is isAWSFaaS; Vercel inherits the AWS env
|
|
268
|
+
if (isVercelFaaS && !(isAzureFaaS || isGCPFaaS)) {
|
|
269
|
+
if (VERCEL_REGION.length > 0) {
|
|
270
|
+
faasEnv.set('region', VERCEL_REGION);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
faasEnv.set('name', 'vercel');
|
|
274
|
+
return faasEnv;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
if (isAWSFaaS && !(isAzureFaaS || isGCPFaaS || isVercelFaaS)) {
|
|
278
|
+
if (AWS_REGION.length > 0) {
|
|
279
|
+
faasEnv.set('region', AWS_REGION);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
if (
|
|
283
|
+
AWS_LAMBDA_FUNCTION_MEMORY_SIZE.length > 0 &&
|
|
284
|
+
Number.isInteger(+AWS_LAMBDA_FUNCTION_MEMORY_SIZE)
|
|
285
|
+
) {
|
|
286
|
+
faasEnv.set('memory_mb', new Int32(AWS_LAMBDA_FUNCTION_MEMORY_SIZE));
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
faasEnv.set('name', 'aws.lambda');
|
|
290
|
+
return faasEnv;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
if (isAzureFaaS && !(isGCPFaaS || isAWSFaaS || isVercelFaaS)) {
|
|
294
|
+
faasEnv.set('name', 'azure.func');
|
|
295
|
+
return faasEnv;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
if (isGCPFaaS && !(isAzureFaaS || isAWSFaaS || isVercelFaaS)) {
|
|
299
|
+
if (FUNCTION_REGION.length > 0) {
|
|
300
|
+
faasEnv.set('region', FUNCTION_REGION);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
if (FUNCTION_MEMORY_MB.length > 0 && Number.isInteger(+FUNCTION_MEMORY_MB)) {
|
|
304
|
+
faasEnv.set('memory_mb', new Int32(FUNCTION_MEMORY_MB));
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
if (FUNCTION_TIMEOUT_SEC.length > 0 && Number.isInteger(+FUNCTION_TIMEOUT_SEC)) {
|
|
308
|
+
faasEnv.set('timeout_sec', new Int32(FUNCTION_TIMEOUT_SEC));
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
faasEnv.set('name', 'gcp.func');
|
|
312
|
+
return faasEnv;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
return null;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* @internal
|
|
320
|
+
* This type represents the global Deno object and the minimal type contract we expect it to satisfy.
|
|
321
|
+
*/
|
|
322
|
+
declare const Deno: { version?: { deno?: string } } | undefined;
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* @internal
|
|
326
|
+
* This type represents the global Bun object and the minimal type contract we expect it to satisfy.
|
|
327
|
+
*/
|
|
328
|
+
declare const Bun: { (): void; version?: string } | undefined;
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* @internal
|
|
332
|
+
* Get current JavaScript runtime platform
|
|
333
|
+
*
|
|
334
|
+
* NOTE: The version information fetching is intentionally written defensively
|
|
335
|
+
* to avoid having a released driver version that becomes incompatible
|
|
336
|
+
* with a future change to these global objects.
|
|
337
|
+
*/
|
|
338
|
+
function getRuntimeInfo(): string {
|
|
339
|
+
const endianness = NumberUtils.isBigEndian ? 'BE' : 'LE';
|
|
340
|
+
if ('Deno' in globalThis) {
|
|
341
|
+
const version = typeof Deno?.version?.deno === 'string' ? Deno?.version?.deno : '0.0.0-unknown';
|
|
342
|
+
|
|
343
|
+
return `Deno v${version}, ${endianness}`;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
if ('Bun' in globalThis) {
|
|
347
|
+
const version = typeof Bun?.version === 'string' ? Bun?.version : '0.0.0-unknown';
|
|
348
|
+
|
|
349
|
+
return `Bun v${version}, ${endianness}`;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
return `Node.js ${process.version}, ${endianness}`;
|
|
353
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/** @internal */
|
|
2
|
+
export class ConnectionPoolMetrics {
|
|
3
|
+
static readonly TXN = 'txn' as const;
|
|
4
|
+
static readonly CURSOR = 'cursor' as const;
|
|
5
|
+
static readonly OTHER = 'other' as const;
|
|
6
|
+
|
|
7
|
+
txnConnections = 0;
|
|
8
|
+
cursorConnections = 0;
|
|
9
|
+
otherConnections = 0;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Mark a connection as pinned for a specific operation.
|
|
13
|
+
*/
|
|
14
|
+
markPinned(pinType: string): void {
|
|
15
|
+
if (pinType === ConnectionPoolMetrics.TXN) {
|
|
16
|
+
this.txnConnections += 1;
|
|
17
|
+
} else if (pinType === ConnectionPoolMetrics.CURSOR) {
|
|
18
|
+
this.cursorConnections += 1;
|
|
19
|
+
} else {
|
|
20
|
+
this.otherConnections += 1;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Unmark a connection as pinned for an operation.
|
|
26
|
+
*/
|
|
27
|
+
markUnpinned(pinType: string): void {
|
|
28
|
+
if (pinType === ConnectionPoolMetrics.TXN) {
|
|
29
|
+
this.txnConnections -= 1;
|
|
30
|
+
} else if (pinType === ConnectionPoolMetrics.CURSOR) {
|
|
31
|
+
this.cursorConnections -= 1;
|
|
32
|
+
} else {
|
|
33
|
+
this.otherConnections -= 1;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Return information about the cmap metrics as a string.
|
|
39
|
+
*/
|
|
40
|
+
info(maxPoolSize: number): string {
|
|
41
|
+
return (
|
|
42
|
+
'Timed out while checking out a connection from connection pool: ' +
|
|
43
|
+
`maxPoolSize: ${maxPoolSize}, ` +
|
|
44
|
+
`connections in use by cursors: ${this.cursorConnections}, ` +
|
|
45
|
+
`connections in use by transactions: ${this.txnConnections}, ` +
|
|
46
|
+
`connections in use by other operations: ${this.otherConnections}`
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Reset the metrics to the initial values.
|
|
52
|
+
*/
|
|
53
|
+
reset(): void {
|
|
54
|
+
this.txnConnections = 0;
|
|
55
|
+
this.cursorConnections = 0;
|
|
56
|
+
this.otherConnections = 0;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { type Document, type Double, Long } from '../bson';
|
|
2
|
+
import { ServerType } from '../sdam/common';
|
|
3
|
+
import { parseServerType } from '../sdam/server_description';
|
|
4
|
+
import type { CompressorName } from './wire_protocol/compression';
|
|
5
|
+
|
|
6
|
+
const RESPONSE_FIELDS = [
|
|
7
|
+
'minWireVersion',
|
|
8
|
+
'maxWireVersion',
|
|
9
|
+
'maxBsonObjectSize',
|
|
10
|
+
'maxMessageSizeBytes',
|
|
11
|
+
'maxWriteBatchSize',
|
|
12
|
+
'logicalSessionTimeoutMinutes'
|
|
13
|
+
] as const;
|
|
14
|
+
|
|
15
|
+
/** @public */
|
|
16
|
+
export interface StreamDescriptionOptions {
|
|
17
|
+
compressors?: CompressorName[];
|
|
18
|
+
logicalSessionTimeoutMinutes?: number;
|
|
19
|
+
loadBalanced: boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** @public */
|
|
23
|
+
export class StreamDescription {
|
|
24
|
+
address: string;
|
|
25
|
+
type: ServerType;
|
|
26
|
+
minWireVersion?: number;
|
|
27
|
+
maxWireVersion?: number;
|
|
28
|
+
maxBsonObjectSize: number;
|
|
29
|
+
maxMessageSizeBytes: number;
|
|
30
|
+
maxWriteBatchSize: number;
|
|
31
|
+
compressors: CompressorName[];
|
|
32
|
+
compressor?: CompressorName;
|
|
33
|
+
logicalSessionTimeoutMinutes?: number;
|
|
34
|
+
loadBalanced: boolean;
|
|
35
|
+
|
|
36
|
+
__nodejs_mock_server__?: boolean;
|
|
37
|
+
|
|
38
|
+
zlibCompressionLevel?: number;
|
|
39
|
+
serverConnectionId: bigint | null;
|
|
40
|
+
|
|
41
|
+
public hello: Document | null = null;
|
|
42
|
+
|
|
43
|
+
constructor(address: string, options?: StreamDescriptionOptions) {
|
|
44
|
+
this.address = address;
|
|
45
|
+
this.type = ServerType.Unknown;
|
|
46
|
+
this.minWireVersion = undefined;
|
|
47
|
+
this.maxWireVersion = undefined;
|
|
48
|
+
this.maxBsonObjectSize = 16777216;
|
|
49
|
+
this.maxMessageSizeBytes = 48000000;
|
|
50
|
+
this.maxWriteBatchSize = 100000;
|
|
51
|
+
this.logicalSessionTimeoutMinutes = options?.logicalSessionTimeoutMinutes;
|
|
52
|
+
this.loadBalanced = !!options?.loadBalanced;
|
|
53
|
+
this.compressors =
|
|
54
|
+
options && options.compressors && Array.isArray(options.compressors)
|
|
55
|
+
? options.compressors
|
|
56
|
+
: [];
|
|
57
|
+
this.serverConnectionId = null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
receiveResponse(response: Document | null): void {
|
|
61
|
+
if (response == null) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
this.hello = response;
|
|
65
|
+
this.type = parseServerType(response);
|
|
66
|
+
if ('connectionId' in response) {
|
|
67
|
+
this.serverConnectionId = this.parseServerConnectionID(response.connectionId);
|
|
68
|
+
} else {
|
|
69
|
+
this.serverConnectionId = null;
|
|
70
|
+
}
|
|
71
|
+
for (const field of RESPONSE_FIELDS) {
|
|
72
|
+
if (response[field] != null) {
|
|
73
|
+
this[field] = response[field];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// testing case
|
|
77
|
+
if ('__nodejs_mock_server__' in response) {
|
|
78
|
+
this.__nodejs_mock_server__ = response['__nodejs_mock_server__'];
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (response.compression) {
|
|
83
|
+
this.compressor = this.compressors.filter(c => response.compression?.includes(c))[0];
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/* @internal */
|
|
88
|
+
parseServerConnectionID(serverConnectionId: number | Double | bigint | Long): bigint {
|
|
89
|
+
// Connection ids are always integral, so it's safe to coerce doubles as well as
|
|
90
|
+
// any integral type.
|
|
91
|
+
return Long.isLong(serverConnectionId)
|
|
92
|
+
? serverConnectionId.toBigInt()
|
|
93
|
+
: // @ts-expect-error: Doubles are coercible to number
|
|
94
|
+
BigInt(serverConnectionId);
|
|
95
|
+
}
|
|
96
|
+
}
|