mongodb 6.8.2 → 6.9.0-dev.20240917.sha.20396e1b
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/README.md +14 -1
- package/lib/beta.d.ts +7940 -0
- package/lib/beta.js +21 -0
- package/lib/beta.js.map +1 -0
- package/lib/bson.js +5 -5
- package/lib/bson.js.map +1 -1
- package/lib/bulk/common.js +16 -21
- package/lib/bulk/common.js.map +1 -1
- package/lib/bulk/ordered.js.map +1 -1
- package/lib/bulk/unordered.js.map +1 -1
- package/lib/change_stream.js +10 -8
- package/lib/change_stream.js.map +1 -1
- package/lib/client-side-encryption/auto_encrypter.js +14 -3
- package/lib/client-side-encryption/auto_encrypter.js.map +1 -1
- package/lib/client-side-encryption/client_encryption.js +25 -7
- package/lib/client-side-encryption/client_encryption.js.map +1 -1
- package/lib/client-side-encryption/crypto_callbacks.js +6 -6
- package/lib/client-side-encryption/crypto_callbacks.js.map +1 -1
- package/lib/client-side-encryption/mongocryptd_manager.js +9 -5
- package/lib/client-side-encryption/mongocryptd_manager.js.map +1 -1
- package/lib/client-side-encryption/providers/aws.js +1 -2
- package/lib/client-side-encryption/providers/aws.js.map +1 -1
- package/lib/client-side-encryption/providers/azure.js +5 -5
- package/lib/client-side-encryption/providers/azure.js.map +1 -1
- package/lib/client-side-encryption/providers/gcp.js +1 -2
- package/lib/client-side-encryption/providers/gcp.js.map +1 -1
- package/lib/client-side-encryption/providers/index.js +2 -3
- package/lib/client-side-encryption/providers/index.js.map +1 -1
- package/lib/client-side-encryption/state_machine.js +9 -4
- package/lib/client-side-encryption/state_machine.js.map +1 -1
- package/lib/cmap/auth/auth_provider.js.map +1 -1
- package/lib/cmap/auth/aws_temporary_credentials.js.map +1 -1
- package/lib/cmap/auth/gssapi.js +4 -4
- package/lib/cmap/auth/gssapi.js.map +1 -1
- package/lib/cmap/auth/mongo_credentials.js +2 -7
- package/lib/cmap/auth/mongo_credentials.js.map +1 -1
- package/lib/cmap/auth/mongodb_aws.js.map +1 -1
- package/lib/cmap/auth/mongodb_oidc/automated_callback_workflow.js.map +1 -1
- package/lib/cmap/auth/mongodb_oidc/azure_machine_workflow.js.map +1 -1
- package/lib/cmap/auth/mongodb_oidc/callback_workflow.js +0 -2
- package/lib/cmap/auth/mongodb_oidc/callback_workflow.js.map +1 -1
- package/lib/cmap/auth/mongodb_oidc/command_builders.js +2 -3
- package/lib/cmap/auth/mongodb_oidc/command_builders.js.map +1 -1
- package/lib/cmap/auth/mongodb_oidc/gcp_machine_workflow.js.map +1 -1
- package/lib/cmap/auth/mongodb_oidc/human_callback_workflow.js.map +1 -1
- package/lib/cmap/auth/mongodb_oidc/machine_workflow.js +0 -2
- package/lib/cmap/auth/mongodb_oidc/machine_workflow.js.map +1 -1
- package/lib/cmap/auth/mongodb_oidc/token_cache.js.map +1 -1
- package/lib/cmap/auth/mongodb_oidc/token_machine_workflow.js.map +1 -1
- package/lib/cmap/auth/mongodb_oidc.js.map +1 -1
- package/lib/cmap/auth/plain.js.map +1 -1
- package/lib/cmap/auth/scram.js.map +1 -1
- package/lib/cmap/auth/x509.js.map +1 -1
- package/lib/cmap/command_monitoring_events.js.map +1 -1
- package/lib/cmap/commands.js +62 -5
- package/lib/cmap/commands.js.map +1 -1
- package/lib/cmap/connect.js +10 -7
- package/lib/cmap/connect.js.map +1 -1
- package/lib/cmap/connection.js +3 -5
- package/lib/cmap/connection.js.map +1 -1
- package/lib/cmap/connection_pool.js +11 -9
- package/lib/cmap/connection_pool.js.map +1 -1
- package/lib/cmap/connection_pool_events.js +7 -3
- package/lib/cmap/connection_pool_events.js.map +1 -1
- package/lib/cmap/handshake/client_metadata.js +5 -5
- package/lib/cmap/handshake/client_metadata.js.map +1 -1
- package/lib/cmap/metrics.js +1 -1
- package/lib/cmap/metrics.js.map +1 -1
- package/lib/cmap/stream_description.js.map +1 -1
- package/lib/cmap/wire_protocol/compression.js +5 -5
- package/lib/cmap/wire_protocol/compression.js.map +1 -1
- package/lib/cmap/wire_protocol/constants.js +4 -4
- package/lib/cmap/wire_protocol/on_data.js +1 -2
- package/lib/cmap/wire_protocol/on_data.js.map +1 -1
- package/lib/cmap/wire_protocol/on_demand/document.js.map +1 -1
- package/lib/cmap/wire_protocol/responses.js +4 -4
- package/lib/cmap/wire_protocol/responses.js.map +1 -1
- package/lib/cmap/wire_protocol/shared.js +2 -3
- package/lib/cmap/wire_protocol/shared.js.map +1 -1
- package/lib/collection.js.map +1 -1
- package/lib/connection_string.js +12 -6
- package/lib/connection_string.js.map +1 -1
- package/lib/constants.js +1 -0
- package/lib/constants.js.map +1 -1
- package/lib/cursor/abstract_cursor.js +21 -6
- package/lib/cursor/abstract_cursor.js.map +1 -1
- package/lib/cursor/aggregation_cursor.js +1 -1
- package/lib/cursor/aggregation_cursor.js.map +1 -1
- package/lib/cursor/change_stream_cursor.js.map +1 -1
- package/lib/cursor/find_cursor.js +3 -3
- package/lib/cursor/find_cursor.js.map +1 -1
- package/lib/db.js +2 -2
- package/lib/db.js.map +1 -1
- package/lib/deps.js +16 -8
- package/lib/deps.js.map +1 -1
- package/lib/encrypter.js.map +1 -1
- package/lib/error.js +19 -14
- package/lib/error.js.map +1 -1
- package/lib/explain.js +6 -6
- package/lib/explain.js.map +1 -1
- package/lib/gridfs/download.js +1 -4
- package/lib/gridfs/download.js.map +1 -1
- package/lib/gridfs/index.js +1 -1
- package/lib/gridfs/index.js.map +1 -1
- package/lib/gridfs/upload.js +0 -4
- package/lib/gridfs/upload.js.map +1 -1
- package/lib/index.js +4 -2
- package/lib/index.js.map +1 -1
- package/lib/mongo_client.js +15 -1
- package/lib/mongo_client.js.map +1 -1
- package/lib/mongo_client_auth_providers.js +6 -2
- package/lib/mongo_client_auth_providers.js.map +1 -1
- package/lib/mongo_logger.js +8 -8
- package/lib/mongo_logger.js.map +1 -1
- package/lib/mongo_types.js +1 -0
- package/lib/mongo_types.js.map +1 -1
- package/lib/operations/aggregate.js +1 -0
- package/lib/operations/aggregate.js.map +1 -1
- package/lib/operations/bulk_write.js.map +1 -1
- package/lib/operations/client_bulk_write/command_builder.js +198 -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/collections.js.map +1 -1
- package/lib/operations/command.js +1 -1
- package/lib/operations/command.js.map +1 -1
- package/lib/operations/count.js.map +1 -1
- package/lib/operations/create_collection.js.map +1 -1
- package/lib/operations/delete.js +2 -2
- package/lib/operations/delete.js.map +1 -1
- package/lib/operations/distinct.js.map +1 -1
- package/lib/operations/drop.js.map +1 -1
- package/lib/operations/estimated_document_count.js.map +1 -1
- package/lib/operations/execute_operation.js +111 -109
- package/lib/operations/execute_operation.js.map +1 -1
- package/lib/operations/find.js.map +1 -1
- package/lib/operations/find_and_modify.js +2 -8
- package/lib/operations/find_and_modify.js.map +1 -1
- package/lib/operations/get_more.js.map +1 -1
- package/lib/operations/indexes.js.map +1 -1
- package/lib/operations/insert.js.map +1 -1
- package/lib/operations/is_capped.js.map +1 -1
- package/lib/operations/kill_cursors.js.map +1 -1
- package/lib/operations/list_collections.js.map +1 -1
- package/lib/operations/list_databases.js.map +1 -1
- package/lib/operations/operation.js +5 -5
- package/lib/operations/operation.js.map +1 -1
- package/lib/operations/options_operation.js.map +1 -1
- package/lib/operations/profiling_level.js.map +1 -1
- package/lib/operations/search_indexes/drop.js.map +1 -1
- package/lib/operations/set_profiling_level.js.map +1 -1
- package/lib/operations/stats.js.map +1 -1
- package/lib/operations/update.js +2 -2
- package/lib/operations/update.js.map +1 -1
- package/lib/operations/validate_collection.js.map +1 -1
- package/lib/read_concern.js.map +1 -1
- package/lib/read_preference.js +1 -1
- package/lib/read_preference.js.map +1 -1
- package/lib/resource_management.js +58 -0
- package/lib/resource_management.js.map +1 -0
- package/lib/sdam/common.js +3 -3
- package/lib/sdam/common.js.map +1 -1
- package/lib/sdam/monitor.js +1 -5
- package/lib/sdam/monitor.js.map +1 -1
- package/lib/sdam/server.js +2 -2
- package/lib/sdam/server.js.map +1 -1
- package/lib/sdam/server_description.js +3 -3
- package/lib/sdam/server_description.js.map +1 -1
- package/lib/sdam/server_selection.js +5 -5
- package/lib/sdam/server_selection.js.map +1 -1
- package/lib/sdam/srv_polling.js +2 -3
- package/lib/sdam/srv_polling.js.map +1 -1
- package/lib/sdam/topology.js +1 -1
- package/lib/sdam/topology.js.map +1 -1
- package/lib/sdam/topology_description.js.map +1 -1
- package/lib/sessions.js +221 -218
- package/lib/sessions.js.map +1 -1
- package/lib/sort.js +2 -3
- package/lib/sort.js.map +1 -1
- package/lib/timeout.js +0 -1
- package/lib/timeout.js.map +1 -1
- package/lib/transactions.js +2 -2
- package/lib/transactions.js.map +1 -1
- package/lib/utils.js +54 -54
- package/lib/utils.js.map +1 -1
- package/lib/write_concern.js +2 -2
- package/lib/write_concern.js.map +1 -1
- package/mongodb.d.ts +191 -148
- package/package.json +27 -28
- package/src/beta.ts +22 -0
- package/src/bson.ts +1 -2
- package/src/bulk/common.ts +18 -18
- package/src/change_stream.ts +33 -15
- package/src/client-side-encryption/auto_encrypter.ts +18 -82
- package/src/client-side-encryption/client_encryption.ts +51 -54
- package/src/client-side-encryption/mongocryptd_manager.ts +10 -6
- package/src/client-side-encryption/state_machine.ts +28 -6
- package/src/cmap/auth/gssapi.ts +1 -1
- package/src/cmap/auth/mongo_credentials.ts +2 -8
- package/src/cmap/auth/mongodb_aws.ts +2 -2
- package/src/cmap/auth/mongodb_oidc/callback_workflow.ts +2 -2
- package/src/cmap/auth/mongodb_oidc/machine_workflow.ts +2 -2
- package/src/cmap/commands.ts +70 -5
- package/src/cmap/connect.ts +4 -1
- package/src/cmap/connection.ts +2 -2
- package/src/cmap/connection_pool.ts +17 -9
- package/src/cmap/connection_pool_events.ts +34 -2
- package/src/cmap/handshake/client_metadata.ts +1 -1
- package/src/cmap/wire_protocol/constants.ts +4 -4
- package/src/cmap/wire_protocol/shared.ts +1 -2
- package/src/collection.ts +16 -15
- package/src/connection_string.ts +10 -3
- package/src/constants.ts +1 -0
- package/src/cursor/abstract_cursor.ts +38 -13
- package/src/cursor/aggregation_cursor.ts +8 -6
- package/src/cursor/find_cursor.ts +2 -2
- package/src/db.ts +1 -1
- package/src/deps.ts +8 -1
- package/src/error.ts +33 -14
- package/src/explain.ts +47 -11
- package/src/gridfs/download.ts +28 -4
- package/src/gridfs/upload.ts +1 -6
- package/src/index.ts +11 -2
- package/src/mongo_client.ts +29 -5
- package/src/mongo_client_auth_providers.ts +8 -2
- package/src/mongo_logger.ts +5 -3
- package/src/mongo_types.ts +69 -68
- package/src/operations/aggregate.ts +2 -1
- package/src/operations/bulk_write.ts +2 -2
- package/src/operations/client_bulk_write/command_builder.ts +283 -0
- package/src/operations/client_bulk_write/common.ts +146 -0
- package/src/operations/command.ts +1 -1
- package/src/operations/execute_operation.ts +137 -131
- package/src/operations/find_and_modify.ts +2 -7
- package/src/operations/insert.ts +3 -4
- package/src/operations/operation.ts +7 -10
- package/src/operations/search_indexes/drop.ts +4 -1
- package/src/resource_management.ts +74 -0
- package/src/sdam/monitor.ts +3 -5
- package/src/sdam/server.ts +1 -1
- package/src/sdam/server_description.ts +5 -6
- package/src/sdam/srv_polling.ts +1 -2
- package/src/sessions.ts +291 -277
- package/src/sort.ts +1 -1
- package/src/timeout.ts +0 -1
- package/src/transactions.ts +1 -2
- package/src/utils.ts +25 -9
- package/src/write_concern.ts +2 -2
- package/tsconfig.json +2 -1
- package/lib/cmap/auth/mongocr.js +0 -35
- package/lib/cmap/auth/mongocr.js.map +0 -1
- package/src/cmap/auth/mongocr.ts +0 -38
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mongodb",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.9.0-dev.20240917.sha.20396e1b",
|
|
4
4
|
"description": "The official MongoDB driver for Node.js",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -62,55 +62,53 @@
|
|
|
62
62
|
}
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
|
-
"@aws-sdk/credential-providers": "^3.
|
|
65
|
+
"@aws-sdk/credential-providers": "^3.632.0",
|
|
66
66
|
"@iarna/toml": "^2.2.5",
|
|
67
67
|
"@istanbuljs/nyc-config-typescript": "^1.0.2",
|
|
68
|
-
"@microsoft/api-extractor": "^7.
|
|
69
|
-
"@microsoft/tsdoc-config": "^0.
|
|
68
|
+
"@microsoft/api-extractor": "^7.47.5",
|
|
69
|
+
"@microsoft/tsdoc-config": "^0.17.0",
|
|
70
70
|
"@mongodb-js/zstd": "^1.2.0",
|
|
71
|
-
"@types/chai": "^4.3.
|
|
71
|
+
"@types/chai": "^4.3.17",
|
|
72
72
|
"@types/chai-subset": "^1.3.5",
|
|
73
73
|
"@types/express": "^4.17.21",
|
|
74
74
|
"@types/kerberos": "^1.1.5",
|
|
75
|
-
"@types/mocha": "^10.0.
|
|
76
|
-
"@types/node": "^
|
|
75
|
+
"@types/mocha": "^10.0.7",
|
|
76
|
+
"@types/node": "^22.4.1",
|
|
77
77
|
"@types/saslprep": "^1.0.3",
|
|
78
78
|
"@types/semver": "^7.5.8",
|
|
79
79
|
"@types/sinon": "^17.0.3",
|
|
80
80
|
"@types/sinon-chai": "^3.2.12",
|
|
81
|
-
"@types/whatwg-url": "^11.0.
|
|
82
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
83
|
-
"@typescript-eslint/parser": "^
|
|
81
|
+
"@types/whatwg-url": "^11.0.5",
|
|
82
|
+
"@typescript-eslint/eslint-plugin": "^8.2.0",
|
|
83
|
+
"@typescript-eslint/parser": "^8.2.0",
|
|
84
84
|
"chai": "^4.4.1",
|
|
85
85
|
"chai-subset": "^1.6.0",
|
|
86
86
|
"chalk": "^4.1.2",
|
|
87
|
-
"eslint": "^
|
|
88
|
-
"eslint-config-prettier": "^
|
|
89
|
-
"eslint-plugin-github": "^4.10.2",
|
|
90
|
-
"eslint-plugin-import": "^2.29.1",
|
|
87
|
+
"eslint": "^9.0.0",
|
|
88
|
+
"eslint-config-prettier": "^9.1.0",
|
|
91
89
|
"eslint-plugin-mocha": "^10.4.1",
|
|
92
|
-
"eslint-plugin-prettier": "^
|
|
93
|
-
"eslint-plugin-simple-import-sort": "^
|
|
94
|
-
"eslint-plugin-tsdoc": "^0.
|
|
95
|
-
"eslint-plugin-unused-imports": "^
|
|
90
|
+
"eslint-plugin-prettier": "^5.2.1",
|
|
91
|
+
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
92
|
+
"eslint-plugin-tsdoc": "^0.3.0",
|
|
93
|
+
"eslint-plugin-unused-imports": "^4.0.0",
|
|
96
94
|
"express": "^4.19.2",
|
|
97
95
|
"gcp-metadata": "^5.3.0",
|
|
98
96
|
"js-yaml": "^4.1.0",
|
|
99
97
|
"mocha": "^10.4.0",
|
|
100
98
|
"mocha-sinon": "^2.1.2",
|
|
101
|
-
"mongodb-client-encryption": "^6.0
|
|
102
|
-
"mongodb-legacy": "^6.0
|
|
99
|
+
"mongodb-client-encryption": "^6.1.0",
|
|
100
|
+
"mongodb-legacy": "^6.1.0",
|
|
103
101
|
"nyc": "^15.1.0",
|
|
104
|
-
"prettier": "^
|
|
105
|
-
"semver": "^7.6.
|
|
106
|
-
"sinon": "^
|
|
102
|
+
"prettier": "^3.3.3",
|
|
103
|
+
"semver": "^7.6.3",
|
|
104
|
+
"sinon": "^18.0.0",
|
|
107
105
|
"sinon-chai": "^3.7.0",
|
|
108
106
|
"snappy": "^7.2.2",
|
|
109
107
|
"socks": "^2.8.1",
|
|
110
108
|
"source-map-support": "^0.5.21",
|
|
111
109
|
"ts-node": "^10.9.2",
|
|
112
|
-
"tsd": "^0.31.
|
|
113
|
-
"typescript": "5.
|
|
110
|
+
"tsd": "^0.31.1",
|
|
111
|
+
"typescript": "5.5",
|
|
114
112
|
"typescript-cached-transpile": "^0.0.6",
|
|
115
113
|
"v8-heapsnapshot": "^1.3.1",
|
|
116
114
|
"yargs": "^17.7.2"
|
|
@@ -126,7 +124,7 @@
|
|
|
126
124
|
"scripts": {
|
|
127
125
|
"build:evergreen": "node .evergreen/generate_evergreen_tasks.js",
|
|
128
126
|
"build:ts": "node ./node_modules/typescript/bin/tsc",
|
|
129
|
-
"build:dts": "npm run build:ts && api-extractor run && node etc/clean_definition_files.cjs && eslint mongodb.d.ts
|
|
127
|
+
"build:dts": "npm run build:ts && api-extractor run && node etc/clean_definition_files.cjs && ESLINT_USE_FLAT_CONFIG=false eslint --no-ignore --fix mongodb.d.ts lib/beta.d.ts",
|
|
130
128
|
"build:docs": "./etc/docs/build.ts",
|
|
131
129
|
"build:typedoc": "typedoc",
|
|
132
130
|
"build:nightly": "node ./.github/scripts/nightly.mjs",
|
|
@@ -136,7 +134,7 @@
|
|
|
136
134
|
"check:lambda": "mocha --config test/mocha_lambda.json test/integration/node-specific/examples/handler.test.js",
|
|
137
135
|
"check:lambda:aws": "mocha --config test/mocha_lambda.json test/integration/node-specific/examples/aws_handler.test.js",
|
|
138
136
|
"check:lint": "npm run build:dts && npm run check:dts && npm run check:eslint && npm run check:tsd",
|
|
139
|
-
"check:eslint": "eslint -v && eslint --max-warnings=0 --ext '.js,.ts' src test",
|
|
137
|
+
"check:eslint": "npm run build:dts && ESLINT_USE_FLAT_CONFIG=false eslint -v && ESLINT_USE_FLAT_CONFIG=false eslint --max-warnings=0 --ext '.js,.ts' src test",
|
|
140
138
|
"check:tsd": "tsd --version && tsd",
|
|
141
139
|
"check:dependencies": "mocha test/action/dependency.test.ts",
|
|
142
140
|
"check:dts": "node ./node_modules/typescript/bin/tsc --noEmit mongodb.d.ts && tsd",
|
|
@@ -145,6 +143,7 @@
|
|
|
145
143
|
"check:unit": "mocha test/unit",
|
|
146
144
|
"check:ts": "node ./node_modules/typescript/bin/tsc -v && node ./node_modules/typescript/bin/tsc --noEmit",
|
|
147
145
|
"check:atlas": "mocha --config test/manual/mocharc.json test/manual/atlas_connectivity.test.ts",
|
|
146
|
+
"check:resource-management": "mocha --config test/manual/mocharc.json test/manual/resource_management.test.ts",
|
|
148
147
|
"check:drivers-atlas-testing": "mocha --config test/mocha_mongodb.json test/atlas/drivers_atlas_testing.test.ts",
|
|
149
148
|
"check:adl": "mocha --config test/mocha_mongodb.json test/manual/atlas-data-lake-testing",
|
|
150
149
|
"check:aws": "nyc mocha --config test/mocha_mongodb.json test/integration/auth/mongodb_aws.test.ts",
|
|
@@ -176,4 +175,4 @@
|
|
|
176
175
|
"moduleResolution": "node"
|
|
177
176
|
}
|
|
178
177
|
}
|
|
179
|
-
}
|
|
178
|
+
}
|
package/src/beta.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type Document } from 'bson';
|
|
2
|
+
|
|
3
|
+
export * from './index';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @internal
|
|
7
|
+
*
|
|
8
|
+
* Since we don't bundle tslib helpers, we need to polyfill this method.
|
|
9
|
+
*
|
|
10
|
+
* This is used in the generated JS. Adapted from https://github.com/microsoft/TypeScript/blob/aafdfe5b3f76f5c41abeec412ce73c86da94c75f/src/compiler/factory/emitHelpers.ts#L1202.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
function __exportStar(mod: Document) {
|
|
14
|
+
for (const key of Object.keys(mod)) {
|
|
15
|
+
Object.defineProperty(exports, key, {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () {
|
|
18
|
+
return mod[key];
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
package/src/bson.ts
CHANGED
package/src/bulk/common.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { promisify } from 'util';
|
|
2
2
|
|
|
3
|
-
import { type BSONSerializeOptions, type Document, resolveBSONOptions } from '../bson';
|
|
3
|
+
import { type BSONSerializeOptions, type Document, EJSON, resolveBSONOptions } from '../bson';
|
|
4
4
|
import type { Collection } from '../collection';
|
|
5
5
|
import {
|
|
6
6
|
type AnyError,
|
|
@@ -20,12 +20,12 @@ import { makeUpdateStatement, UpdateOperation, type UpdateStatement } from '../o
|
|
|
20
20
|
import type { Server } from '../sdam/server';
|
|
21
21
|
import type { Topology } from '../sdam/topology';
|
|
22
22
|
import type { ClientSession } from '../sessions';
|
|
23
|
-
import { maybeAddIdToDocuments } from '../utils';
|
|
24
23
|
import {
|
|
25
24
|
applyRetryableWrites,
|
|
26
25
|
type Callback,
|
|
27
26
|
getTopology,
|
|
28
27
|
hasAtomicOperators,
|
|
28
|
+
maybeAddIdToDocuments,
|
|
29
29
|
type MongoDBNamespace,
|
|
30
30
|
resolveOptions
|
|
31
31
|
} from '../utils';
|
|
@@ -294,7 +294,7 @@ export class BulkWriteResult {
|
|
|
294
294
|
}
|
|
295
295
|
|
|
296
296
|
toString(): string {
|
|
297
|
-
return `BulkWriteResult(${this.result})`;
|
|
297
|
+
return `BulkWriteResult(${EJSON.stringify(this.result)})`;
|
|
298
298
|
}
|
|
299
299
|
|
|
300
300
|
isOk(): boolean {
|
|
@@ -583,13 +583,12 @@ function executeCommands(
|
|
|
583
583
|
const operation = isInsertBatch(batch)
|
|
584
584
|
? new InsertOperation(bulkOperation.s.namespace, batch.operations, finalOptions)
|
|
585
585
|
: isUpdateBatch(batch)
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
586
|
+
? new UpdateOperation(bulkOperation.s.namespace, batch.operations, finalOptions)
|
|
587
|
+
: isDeleteBatch(batch)
|
|
588
|
+
? new DeleteOperation(bulkOperation.s.namespace, batch.operations, finalOptions)
|
|
589
|
+
: null;
|
|
590
590
|
|
|
591
591
|
if (operation != null) {
|
|
592
|
-
// eslint-disable-next-line github/no-then
|
|
593
592
|
executeOperation(bulkOperation.s.collection.client, operation).then(
|
|
594
593
|
result => resultHandler(undefined, result),
|
|
595
594
|
error => resultHandler(error)
|
|
@@ -616,8 +615,8 @@ function handleMongoWriteConcernError(
|
|
|
616
615
|
callback(
|
|
617
616
|
new MongoBulkWriteError(
|
|
618
617
|
{
|
|
619
|
-
message: err.result
|
|
620
|
-
code: err.result
|
|
618
|
+
message: err.result.writeConcernError.errmsg,
|
|
619
|
+
code: err.result.writeConcernError.code
|
|
621
620
|
},
|
|
622
621
|
new BulkWriteResult(bulkResult, isOrdered)
|
|
623
622
|
)
|
|
@@ -919,7 +918,11 @@ export abstract class BulkOperationBase {
|
|
|
919
918
|
* Create a new OrderedBulkOperation or UnorderedBulkOperation instance
|
|
920
919
|
* @internal
|
|
921
920
|
*/
|
|
922
|
-
constructor(
|
|
921
|
+
constructor(
|
|
922
|
+
private collection: Collection,
|
|
923
|
+
options: BulkWriteOptions,
|
|
924
|
+
isOrdered: boolean
|
|
925
|
+
) {
|
|
923
926
|
// determine whether bulkOperation is ordered or unordered
|
|
924
927
|
this.isOrdered = isOrdered;
|
|
925
928
|
|
|
@@ -1178,6 +1181,10 @@ export abstract class BulkOperationBase {
|
|
|
1178
1181
|
);
|
|
1179
1182
|
}
|
|
1180
1183
|
|
|
1184
|
+
get length(): number {
|
|
1185
|
+
return this.s.currentIndex;
|
|
1186
|
+
}
|
|
1187
|
+
|
|
1181
1188
|
get bsonOptions(): BSONSerializeOptions {
|
|
1182
1189
|
return this.s.bsonOptions;
|
|
1183
1190
|
}
|
|
@@ -1274,13 +1281,6 @@ export abstract class BulkOperationBase {
|
|
|
1274
1281
|
}
|
|
1275
1282
|
}
|
|
1276
1283
|
|
|
1277
|
-
Object.defineProperty(BulkOperationBase.prototype, 'length', {
|
|
1278
|
-
enumerable: true,
|
|
1279
|
-
get() {
|
|
1280
|
-
return this.s.currentIndex;
|
|
1281
|
-
}
|
|
1282
|
-
});
|
|
1283
|
-
|
|
1284
1284
|
function isInsertBatch(batch: Batch): boolean {
|
|
1285
1285
|
return batch.batchType === BatchType.INSERT;
|
|
1286
1286
|
}
|
package/src/change_stream.ts
CHANGED
|
@@ -18,6 +18,7 @@ import { type InferIdType, TypedEventEmitter } from './mongo_types';
|
|
|
18
18
|
import type { AggregateOptions } from './operations/aggregate';
|
|
19
19
|
import type { CollationOptions, OperationParent } from './operations/command';
|
|
20
20
|
import type { ReadPreference } from './read_preference';
|
|
21
|
+
import { type AsyncDisposable, configureResourceManagement } from './resource_management';
|
|
21
22
|
import type { ServerSessionId } from './sessions';
|
|
22
23
|
import { filterOptions, getTopology, type MongoDBNamespace, squashError } from './utils';
|
|
23
24
|
|
|
@@ -43,7 +44,7 @@ const CHANGE_DOMAIN_TYPES = {
|
|
|
43
44
|
CLUSTER: Symbol('Cluster')
|
|
44
45
|
};
|
|
45
46
|
|
|
46
|
-
const CHANGE_STREAM_EVENTS = [RESUME_TOKEN_CHANGED, END, CLOSE];
|
|
47
|
+
const CHANGE_STREAM_EVENTS = [RESUME_TOKEN_CHANGED, END, CLOSE] as const;
|
|
47
48
|
|
|
48
49
|
const NO_RESUME_TOKEN_ERROR =
|
|
49
50
|
'A change stream document has been received that lacks a resume token (_id).';
|
|
@@ -544,9 +545,23 @@ export type ChangeStreamEvents<
|
|
|
544
545
|
* @public
|
|
545
546
|
*/
|
|
546
547
|
export class ChangeStream<
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
>
|
|
548
|
+
TSchema extends Document = Document,
|
|
549
|
+
TChange extends Document = ChangeStreamDocument<TSchema>
|
|
550
|
+
>
|
|
551
|
+
extends TypedEventEmitter<ChangeStreamEvents<TSchema, TChange>>
|
|
552
|
+
implements AsyncDisposable
|
|
553
|
+
{
|
|
554
|
+
/**
|
|
555
|
+
* @beta
|
|
556
|
+
* @experimental
|
|
557
|
+
* An alias for {@link ChangeStream.close|ChangeStream.close()}.
|
|
558
|
+
*/
|
|
559
|
+
declare [Symbol.asyncDispose]: () => Promise<void>;
|
|
560
|
+
/** @internal */
|
|
561
|
+
async asyncDispose() {
|
|
562
|
+
await this.close();
|
|
563
|
+
}
|
|
564
|
+
|
|
550
565
|
pipeline: Document[];
|
|
551
566
|
/**
|
|
552
567
|
* @remarks WriteConcern can still be present on the options because
|
|
@@ -665,7 +680,7 @@ export class ChangeStream<
|
|
|
665
680
|
// Change streams must resume indefinitely while each resume event succeeds.
|
|
666
681
|
// This loop continues until either a change event is received or until a resume attempt
|
|
667
682
|
// fails.
|
|
668
|
-
|
|
683
|
+
|
|
669
684
|
while (true) {
|
|
670
685
|
try {
|
|
671
686
|
const hasNext = await this.cursor.hasNext();
|
|
@@ -691,7 +706,7 @@ export class ChangeStream<
|
|
|
691
706
|
// Change streams must resume indefinitely while each resume event succeeds.
|
|
692
707
|
// This loop continues until either a change event is received or until a resume attempt
|
|
693
708
|
// fails.
|
|
694
|
-
|
|
709
|
+
|
|
695
710
|
while (true) {
|
|
696
711
|
try {
|
|
697
712
|
const change = await this.cursor.next();
|
|
@@ -720,7 +735,7 @@ export class ChangeStream<
|
|
|
720
735
|
// Change streams must resume indefinitely while each resume event succeeds.
|
|
721
736
|
// This loop continues until either a change event is received or until a resume attempt
|
|
722
737
|
// fails.
|
|
723
|
-
|
|
738
|
+
|
|
724
739
|
while (true) {
|
|
725
740
|
try {
|
|
726
741
|
const change = await this.cursor.tryNext();
|
|
@@ -765,7 +780,9 @@ export class ChangeStream<
|
|
|
765
780
|
return this[kClosed] || this.cursor.closed;
|
|
766
781
|
}
|
|
767
782
|
|
|
768
|
-
/**
|
|
783
|
+
/**
|
|
784
|
+
* Frees the internal resources used by the change stream.
|
|
785
|
+
*/
|
|
769
786
|
async close(): Promise<void> {
|
|
770
787
|
this[kClosed] = true;
|
|
771
788
|
|
|
@@ -833,10 +850,10 @@ export class ChangeStream<
|
|
|
833
850
|
this.type === CHANGE_DOMAIN_TYPES.CLUSTER
|
|
834
851
|
? (this.parent as MongoClient)
|
|
835
852
|
: this.type === CHANGE_DOMAIN_TYPES.DATABASE
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
853
|
+
? (this.parent as Db).client
|
|
854
|
+
: this.type === CHANGE_DOMAIN_TYPES.COLLECTION
|
|
855
|
+
? (this.parent as Collection).client
|
|
856
|
+
: null;
|
|
840
857
|
|
|
841
858
|
if (client == null) {
|
|
842
859
|
// This should never happen because of the assertion in the constructor
|
|
@@ -867,7 +884,6 @@ export class ChangeStream<
|
|
|
867
884
|
private _closeEmitterModeWithError(error: AnyError): void {
|
|
868
885
|
this.emit(ChangeStream.ERROR, error);
|
|
869
886
|
|
|
870
|
-
// eslint-disable-next-line github/no-then
|
|
871
887
|
this.close().then(undefined, squashError);
|
|
872
888
|
}
|
|
873
889
|
|
|
@@ -932,7 +948,7 @@ export class ChangeStream<
|
|
|
932
948
|
|
|
933
949
|
if (isResumableError(changeStreamError, this.cursor.maxWireVersion)) {
|
|
934
950
|
this._endStream();
|
|
935
|
-
|
|
951
|
+
|
|
936
952
|
this.cursor.close().then(undefined, squashError);
|
|
937
953
|
|
|
938
954
|
const topology = getTopology(this.parent);
|
|
@@ -940,7 +956,7 @@ export class ChangeStream<
|
|
|
940
956
|
.selectServer(this.cursor.readPreference, {
|
|
941
957
|
operationName: 'reconnect topology in change stream'
|
|
942
958
|
})
|
|
943
|
-
|
|
959
|
+
|
|
944
960
|
.then(
|
|
945
961
|
() => {
|
|
946
962
|
this.cursor = this._createChangeStreamCursor(this.cursor.resumeOptions);
|
|
@@ -986,3 +1002,5 @@ export class ChangeStream<
|
|
|
986
1002
|
}
|
|
987
1003
|
}
|
|
988
1004
|
}
|
|
1005
|
+
|
|
1006
|
+
configureResourceManagement(ChangeStream.prototype);
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
type MongoCryptConstructor,
|
|
4
4
|
type MongoCryptOptions
|
|
5
5
|
} from 'mongodb-client-encryption';
|
|
6
|
+
import * as net from 'net';
|
|
6
7
|
|
|
7
8
|
import { deserialize, type Document, serialize } from '../bson';
|
|
8
9
|
import { type CommandOptions, type ProxyOptions } from '../cmap/connection';
|
|
@@ -11,6 +12,7 @@ import { getMongoDBClientEncryption } from '../deps';
|
|
|
11
12
|
import { MongoRuntimeError } from '../error';
|
|
12
13
|
import { MongoClient, type MongoClientOptions } from '../mongo_client';
|
|
13
14
|
import { MongoDBCollectionNamespace } from '../utils';
|
|
15
|
+
import { autoSelectSocketOptions } from './client_encryption';
|
|
14
16
|
import * as cryptoCallbacks from './crypto_callbacks';
|
|
15
17
|
import { MongoCryptInvalidArgumentError } from './errors';
|
|
16
18
|
import { MongocryptdManager } from './mongocryptd_manager';
|
|
@@ -26,85 +28,7 @@ export interface AutoEncryptionOptions {
|
|
|
26
28
|
/** The namespace where keys are stored in the key vault */
|
|
27
29
|
keyVaultNamespace?: string;
|
|
28
30
|
/** Configuration options that are used by specific KMS providers during key generation, encryption, and decryption. */
|
|
29
|
-
kmsProviders?:
|
|
30
|
-
/** Configuration options for using 'aws' as your KMS provider */
|
|
31
|
-
aws?:
|
|
32
|
-
| {
|
|
33
|
-
/** The access key used for the AWS KMS provider */
|
|
34
|
-
accessKeyId: string;
|
|
35
|
-
/** The secret access key used for the AWS KMS provider */
|
|
36
|
-
secretAccessKey: string;
|
|
37
|
-
/**
|
|
38
|
-
* An optional AWS session token that will be used as the
|
|
39
|
-
* X-Amz-Security-Token header for AWS requests.
|
|
40
|
-
*/
|
|
41
|
-
sessionToken?: string;
|
|
42
|
-
}
|
|
43
|
-
| Record<string, never>;
|
|
44
|
-
/** Configuration options for using 'local' as your KMS provider */
|
|
45
|
-
local?: {
|
|
46
|
-
/**
|
|
47
|
-
* The master key used to encrypt/decrypt data keys.
|
|
48
|
-
* A 96-byte long Buffer or base64 encoded string.
|
|
49
|
-
*/
|
|
50
|
-
key: Buffer | string;
|
|
51
|
-
};
|
|
52
|
-
/** Configuration options for using 'azure' as your KMS provider */
|
|
53
|
-
azure?:
|
|
54
|
-
| {
|
|
55
|
-
/** The tenant ID identifies the organization for the account */
|
|
56
|
-
tenantId: string;
|
|
57
|
-
/** The client ID to authenticate a registered application */
|
|
58
|
-
clientId: string;
|
|
59
|
-
/** The client secret to authenticate a registered application */
|
|
60
|
-
clientSecret: string;
|
|
61
|
-
/**
|
|
62
|
-
* If present, a host with optional port. E.g. "example.com" or "example.com:443".
|
|
63
|
-
* This is optional, and only needed if customer is using a non-commercial Azure instance
|
|
64
|
-
* (e.g. a government or China account, which use different URLs).
|
|
65
|
-
* Defaults to "login.microsoftonline.com"
|
|
66
|
-
*/
|
|
67
|
-
identityPlatformEndpoint?: string | undefined;
|
|
68
|
-
}
|
|
69
|
-
| {
|
|
70
|
-
/**
|
|
71
|
-
* If present, an access token to authenticate with Azure.
|
|
72
|
-
*/
|
|
73
|
-
accessToken: string;
|
|
74
|
-
}
|
|
75
|
-
| Record<string, never>;
|
|
76
|
-
/** Configuration options for using 'gcp' as your KMS provider */
|
|
77
|
-
gcp?:
|
|
78
|
-
| {
|
|
79
|
-
/** The service account email to authenticate */
|
|
80
|
-
email: string;
|
|
81
|
-
/** A PKCS#8 encrypted key. This can either be a base64 string or a binary representation */
|
|
82
|
-
privateKey: string | Buffer;
|
|
83
|
-
/**
|
|
84
|
-
* If present, a host with optional port. E.g. "example.com" or "example.com:443".
|
|
85
|
-
* Defaults to "oauth2.googleapis.com"
|
|
86
|
-
*/
|
|
87
|
-
endpoint?: string | undefined;
|
|
88
|
-
}
|
|
89
|
-
| {
|
|
90
|
-
/**
|
|
91
|
-
* If present, an access token to authenticate with GCP.
|
|
92
|
-
*/
|
|
93
|
-
accessToken: string;
|
|
94
|
-
}
|
|
95
|
-
| Record<string, never>;
|
|
96
|
-
/**
|
|
97
|
-
* Configuration options for using 'kmip' as your KMS provider
|
|
98
|
-
*/
|
|
99
|
-
kmip?: {
|
|
100
|
-
/**
|
|
101
|
-
* The output endpoint string.
|
|
102
|
-
* The endpoint consists of a hostname and port separated by a colon.
|
|
103
|
-
* E.g. "example.com:123". A port is always present.
|
|
104
|
-
*/
|
|
105
|
-
endpoint?: string;
|
|
106
|
-
};
|
|
107
|
-
};
|
|
31
|
+
kmsProviders?: KMSProviders;
|
|
108
32
|
/**
|
|
109
33
|
* A map of namespaces to a local JSON schema for encryption
|
|
110
34
|
*
|
|
@@ -375,10 +299,20 @@ export class AutoEncrypter {
|
|
|
375
299
|
serverSelectionTimeoutMS: 10000
|
|
376
300
|
};
|
|
377
301
|
|
|
378
|
-
if (
|
|
302
|
+
if (
|
|
303
|
+
(options.extraOptions == null || typeof options.extraOptions.mongocryptdURI !== 'string') &&
|
|
304
|
+
!net.getDefaultAutoSelectFamily
|
|
305
|
+
) {
|
|
306
|
+
// Only set family if autoSelectFamily options are not supported.
|
|
379
307
|
clientOptions.family = 4;
|
|
380
308
|
}
|
|
381
309
|
|
|
310
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
311
|
+
// @ts-ignore: TS complains as this always returns true on versions where it is present.
|
|
312
|
+
if (net.getDefaultAutoSelectFamily) {
|
|
313
|
+
Object.assign(clientOptions, autoSelectSocketOptions(this._client.options));
|
|
314
|
+
}
|
|
315
|
+
|
|
382
316
|
this._mongocryptdClient = new MongoClient(this._mongocryptdManager.uri, clientOptions);
|
|
383
317
|
}
|
|
384
318
|
}
|
|
@@ -457,7 +391,8 @@ export class AutoEncrypter {
|
|
|
457
391
|
promoteValues: false,
|
|
458
392
|
promoteLongs: false,
|
|
459
393
|
proxyOptions: this._proxyOptions,
|
|
460
|
-
tlsOptions: this._tlsOptions
|
|
394
|
+
tlsOptions: this._tlsOptions,
|
|
395
|
+
socketOptions: autoSelectSocketOptions(this._client.options)
|
|
461
396
|
});
|
|
462
397
|
|
|
463
398
|
return deserialize(await stateMachine.execute(this, context), {
|
|
@@ -477,7 +412,8 @@ export class AutoEncrypter {
|
|
|
477
412
|
const stateMachine = new StateMachine({
|
|
478
413
|
...options,
|
|
479
414
|
proxyOptions: this._proxyOptions,
|
|
480
|
-
tlsOptions: this._tlsOptions
|
|
415
|
+
tlsOptions: this._tlsOptions,
|
|
416
|
+
socketOptions: autoSelectSocketOptions(this._client.options)
|
|
481
417
|
});
|
|
482
418
|
|
|
483
419
|
return await stateMachine.execute(this, context);
|