Skip to content

Commit 8f8ea45

Browse files
feat(NODE-4925)!: remove deprecated options and types (#3513)
1 parent fe65746 commit 8f8ea45

25 files changed

+323
-398
lines changed

etc/notes/CHANGES_5.0.0.md

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,50 @@ The following is a detailed collection of the changes in the major v5 release of
1616

1717
## Changes
1818

19-
### salveOk options removed
19+
### `AddUserOptions.digestPassword` removed
20+
21+
The `digestPassword` option has been removed from the add user helper.
22+
23+
### Removal of Internal Types from Public API
24+
25+
The following types are used internally the driver but were accidentally exported. They have now been
26+
marked internal and are no longer exported.
27+
28+
- ServerSelector
29+
- PipeOptions
30+
- ServerOptions
31+
32+
### `DeleteOptions.single` Option Removed
33+
34+
TODO - merge in Neal's removal of `collection.remove` and combine notes
35+
36+
### Remove of `ObjectID` Type in Favor Of `ObjectId`
37+
38+
For clarity the deprecated and duplicate export ObjectID has been removed. ObjectId matches the class name and is equal in every way to the capital "D" export.
39+
40+
### Kerberos Option `gssapiCanonicalizeHostName` Removed
41+
42+
`gssapiCanonicalizeHostName` has been removed in favor of the `CANONICALIZE_HOST_NAME` value.
43+
44+
### `Projection` and `ProjectionOperations` Types Removed
45+
46+
Both of these types were unused but exported. These types have been removed. Please
47+
use `Document` instead.
48+
49+
### `CommandOperationOptions.fullResponse` Option Removed
50+
51+
The `fullResponse` option on the `CommandOperationOptions` as unused in the driver and has been removed.
52+
53+
### `BulkWriteOptions.keepGoing` Option Removed
54+
55+
The `keepGoing` option on the `BulkWriteOptions` has been removed. Please use the `ordered` option instead.
56+
57+
### `WriteConcernError.err()` Removed
58+
59+
The `err()` getter on the WriteConcernError class has been removed. The `toJSON()` method can be in place
60+
of `err()`.
61+
62+
### slaveOk options removed
2063

2164
The deprecated `slaveOk` option and `slaveOk()` method on the `Collection` class have been removed. Please
2265
now use `secondaryOk` as the replacement for the option and the method.

package-lock.json

Lines changed: 262 additions & 233 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"@aws-sdk/credential-providers": "^3.201.0",
4949
"@iarna/toml": "^2.2.5",
5050
"@istanbuljs/nyc-config-typescript": "^1.0.2",
51-
"@microsoft/api-extractor": "^7.33.3",
51+
"@microsoft/api-extractor": "^7.33.7",
5252
"@microsoft/tsdoc-config": "^0.16.2",
5353
"@mongodb-js/zstd": "^1.0.0",
5454
"@types/chai": "^4.3.3",
@@ -62,12 +62,12 @@
6262
"@types/sinon": "^10.0.13",
6363
"@types/sinon-chai": "^3.2.8",
6464
"@types/whatwg-url": "^11.0.0",
65-
"@typescript-eslint/eslint-plugin": "^5.40.0",
66-
"@typescript-eslint/parser": "^5.40.0",
65+
"@typescript-eslint/eslint-plugin": "^5.48.0",
66+
"@typescript-eslint/parser": "^5.48.0",
6767
"chai": "^4.3.6",
6868
"chai-subset": "^1.6.0",
6969
"chalk": "^4.1.2",
70-
"eslint": "^8.25.0",
70+
"eslint": "^8.31.0",
7171
"eslint-config-prettier": "^8.5.0",
7272
"eslint-plugin-import": "^2.26.0",
7373
"eslint-plugin-prettier": "^4.2.1",
@@ -87,8 +87,8 @@
8787
"source-map-support": "^0.5.21",
8888
"standard-version": "^9.5.0",
8989
"ts-node": "^10.9.1",
90-
"tsd": "^0.24.1",
91-
"typescript": "^4.8.4",
90+
"tsd": "^0.25.0",
91+
"typescript": "^4.9.4",
9292
"typescript-cached-transpile": "^0.0.6",
9393
"xml2js": "^0.4.23",
9494
"yargs": "^17.6.0"

src/bulk/common.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -363,11 +363,6 @@ export class WriteConcernError {
363363
return this[kServerError].errInfo;
364364
}
365365

366-
/** @deprecated The `err` prop that contained a MongoServerError has been deprecated. */
367-
get err(): WriteConcernErrorData {
368-
return this[kServerError];
369-
}
370-
371366
toJSON(): WriteConcernErrorData {
372367
return this[kServerError];
373368
}
@@ -876,8 +871,6 @@ export interface BulkWriteOptions extends CommandOperationOptions {
876871
bypassDocumentValidation?: boolean;
877872
/** If true, when an insert fails, don't execute the remaining writes. If false, continue with remaining inserts when one fails. */
878873
ordered?: boolean;
879-
/** @deprecated use `ordered` instead */
880-
keepGoing?: boolean;
881874
/** Force server to assign _id values instead of driver. */
882875
forceServerObjectId?: boolean;
883876
/** Map of parameter names and values that can be accessed using $$var (requires MongoDB 5.0). */

src/change_stream.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,6 @@ export type ResumeToken = unknown;
7878
*/
7979
export type OperationTime = Timestamp;
8080

81-
/**
82-
* @public
83-
* @deprecated This interface is unused and will be removed in the next major version of the driver.
84-
*/
85-
export interface PipeOptions {
86-
end?: boolean;
87-
}
88-
8981
/**
9082
* Options that can be passed to a ChangeStream. Note that startAfter, resumeAfter, and startAtOperationTime are all mutually exclusive, and the server will error if more than one is specified.
9183
* @public

src/cmap/auth/gssapi.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ export type GSSAPICanonicalizationValue =
2626
typeof GSSAPICanonicalizationValue[keyof typeof GSSAPICanonicalizationValue];
2727

2828
type MechanismProperties = {
29-
/** @deprecated use `CANONICALIZE_HOST_NAME` instead */
30-
gssapiCanonicalizeHostName?: boolean;
3129
CANONICALIZE_HOST_NAME?: GSSAPICanonicalizationValue;
3230
SERVICE_HOST?: string;
3331
SERVICE_NAME?: string;

src/cmap/auth/mongo_credentials.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Resolves the default auth mechanism according to
22
import type { Document } from '../../bson';
33
import { MongoAPIError, MongoMissingCredentialsError } from '../../error';
4-
import { emitWarningOnce } from '../../utils';
54
import { GSSAPICanonicalizationValue } from './gssapi';
65
import { AUTH_MECHS_AUTH_SRC_EXTERNAL, AuthMechanism } from './providers';
76

@@ -91,14 +90,6 @@ export class MongoCredentials {
9190
}
9291
}
9392

94-
if ('gssapiCanonicalizeHostName' in this.mechanismProperties) {
95-
emitWarningOnce(
96-
'gssapiCanonicalizeHostName is deprecated. Please use CANONICALIZE_HOST_NAME instead.'
97-
);
98-
this.mechanismProperties.CANONICALIZE_HOST_NAME =
99-
this.mechanismProperties.gssapiCanonicalizeHostName;
100-
}
101-
10293
Object.freeze(this.mechanismProperties);
10394
Object.freeze(this);
10495
}

src/collection.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1652,10 +1652,6 @@ export class Collection<TSchema extends Document = Document> {
16521652
options = options || { ordered: false };
16531653
docs = !Array.isArray(docs) ? [docs] : docs;
16541654

1655-
if (options.keepGoing === true) {
1656-
options.ordered = false;
1657-
}
1658-
16591655
return this.insertMany(docs, options, callback);
16601656
}
16611657

src/index.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Admin } from './admin';
2-
import { ObjectId } from './bson';
32
import { OrderedBulkOperation } from './bulk/ordered';
43
import { UnorderedBulkOperation } from './bulk/unordered';
54
import { ChangeStream } from './change_stream';
@@ -36,14 +35,8 @@ export {
3635
ObjectId,
3736
Timestamp
3837
} from './bson';
39-
export { ChangeStreamCursor } from './cursor/change_stream_cursor';
40-
/**
41-
* @public
42-
* @deprecated Please use `ObjectId`
43-
*/
44-
export const ObjectID = ObjectId;
45-
4638
export { AnyBulkWriteOperation, BulkWriteOptions, MongoBulkWriteError } from './bulk/common';
39+
export { ChangeStreamCursor } from './cursor/change_stream_cursor';
4740
export {
4841
MongoAPIError,
4942
MongoAWSError,
@@ -204,7 +197,6 @@ export type {
204197
ChangeStreamShardCollectionDocument,
205198
ChangeStreamUpdateDocument,
206199
OperationTime,
207-
PipeOptions,
208200
ResumeOptions,
209201
ResumeToken,
210202
UpdateDescription
@@ -339,8 +331,6 @@ export type {
339331
OnlyFieldsOfType,
340332
OptionalId,
341333
OptionalUnlessRequiredId,
342-
Projection,
343-
ProjectionOperators,
344334
PropertyType,
345335
PullAllOperator,
346336
PullOperator,

src/mongo_types.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -192,20 +192,6 @@ export type BSONType = typeof BSONType[keyof typeof BSONType];
192192
/** @public */
193193
export type BSONTypeAlias = keyof typeof BSONType;
194194

195-
/**
196-
* @public
197-
* Projection is flexible to permit the wide array of aggregation operators
198-
* @deprecated since v4.1.0: Since projections support all aggregation operations we have no plans to narrow this type further
199-
*/
200-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
201-
export type Projection<TSchema extends Document = Document> = Document;
202-
203-
/**
204-
* @public
205-
* @deprecated since v4.1.0: Since projections support all aggregation operations we have no plans to narrow this type further
206-
*/
207-
export type ProjectionOperators = Document;
208-
209195
/** @public */
210196
export type IsAny<Type, ResultIfAny, ResultIfNotAny> = true extends false & Type
211197
? ResultIfAny

src/operations/add_user.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ export interface RoleSpecification {
2222

2323
/** @public */
2424
export interface AddUserOptions extends CommandOperationOptions {
25-
/** @deprecated Please use db.command('createUser', ...) instead for this option */
26-
digestPassword?: null;
2725
/** Roles associated with the created user */
2826
roles?: string | string[] | RoleSpecification | RoleSpecification[];
2927
/** Custom data associated with the user (only Mongodb 2.6 or higher) */
@@ -57,7 +55,9 @@ export class AddUserOperation extends CommandOperation<Document> {
5755
const options = this.options;
5856

5957
// Error out if digestPassword set
60-
if (options.digestPassword != null) {
58+
// v5 removed the digestPassword option from AddUserOptions but we still want to throw
59+
// an error when digestPassword is provided.
60+
if ('digestPassword' in options && options.digestPassword != null) {
6161
return callback(
6262
new MongoInvalidArgumentError(
6363
'Option "digestPassword" not supported via addUser, use db.command(...) instead'

src/operations/command.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ export interface CommandOperationOptions
3636
extends OperationOptions,
3737
WriteConcernOptions,
3838
ExplainOptions {
39-
/** @deprecated This option does nothing */
40-
fullResponse?: boolean;
4139
/** Specify a read concern and level for the collection. (only MongoDB 3.2 or higher supported) */
4240
readConcern?: ReadConcernLike;
4341
/** Collation */

src/operations/delete.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ export interface DeleteOptions extends CommandOperationOptions, WriteConcernOpti
1818
hint?: string | Document;
1919
/** Map of parameter names and values that can be accessed using $$var (requires MongoDB 5.0). */
2020
let?: Document;
21-
22-
/** @deprecated use `removeOne` or `removeMany` to implicitly specify the limit */
23-
single?: boolean;
2421
}
2522

2623
/** @public */
@@ -152,10 +149,6 @@ export function makeDeleteStatement(
152149
limit: typeof options.limit === 'number' ? options.limit : 0
153150
};
154151

155-
if (options.single === true) {
156-
op.limit = 1;
157-
}
158-
159152
if (options.collation) {
160153
op.collation = options.collation;
161154
}

src/sdam/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ const stateTransition = makeStateMachine({
7575
/** @internal */
7676
const kMonitor = Symbol('monitor');
7777

78-
/** @public */
78+
/** @internal */
7979
export type ServerOptions = Omit<ConnectionPoolOptions, 'id' | 'generation' | 'hostAddress'> &
8080
MonitorOptions;
8181

src/sdam/server_selection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const SMALLEST_MAX_STALENESS_SECONDS = 90;
1111
// Minimum version to try writes on secondaries.
1212
export const MIN_SECONDARY_WRITE_WIRE_VERSION = 13;
1313

14-
/** @public */
14+
/** @internal */
1515
export type ServerSelector = (
1616
topologyDescription: TopologyDescription,
1717
servers: ServerDescription[]

src/sdam/topology.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export interface TopologyPrivate {
127127
detectSrvRecords: (event: SrvPollingEvent) => void;
128128
}
129129

130-
/** @public */
130+
/** @internal */
131131
export interface TopologyOptions extends BSONSerializeOptions, ServerOptions {
132132
srvMaxHosts: number;
133133
srvServiceName: string;

test/integration/crud/crud_api.test.ts

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -670,21 +670,7 @@ describe('CRUD API', function () {
670670
// Legacy update method
671671
// -------------------------------------------------
672672
const legacyRemove = function () {
673-
db.collection('t4_1').insertMany(
674-
[{ a: 1 }, { a: 1 }],
675-
{ writeConcern: { w: 1 } },
676-
function (err, r) {
677-
expect(err).to.not.exist;
678-
test.equal(2, r.insertedCount);
679-
680-
db.collection('t4_1').remove({ a: 1 }, { single: true }, function (err, r) {
681-
expect(err).to.not.exist;
682-
test.equal(1, r.deletedCount);
683-
684-
deleteOne();
685-
});
686-
}
687-
);
673+
deleteOne();
688674
};
689675

690676
//

test/integration/crud/remove.test.js

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -107,52 +107,6 @@ describe('Remove', function () {
107107
}
108108
});
109109

110-
it('should correctly remove only first document', {
111-
metadata: {
112-
requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] }
113-
},
114-
115-
test: function (done) {
116-
const self = this;
117-
const client = self.configuration.newClient(self.configuration.writeConcernMax(), {
118-
maxPoolSize: 1
119-
});
120-
121-
client.connect(function (err, client) {
122-
const db = client.db(self.configuration.db);
123-
expect(err).to.not.exist;
124-
125-
db.createCollection('shouldCorrectlyRemoveOnlyFirstDocument', function (err) {
126-
expect(err).to.not.exist;
127-
128-
const collection = db.collection('shouldCorrectlyRemoveOnlyFirstDocument');
129-
130-
collection.insert(
131-
[{ a: 1 }, { a: 1 }, { a: 1 }, { a: 1 }],
132-
{ writeConcern: { w: 1 } },
133-
function (err) {
134-
expect(err).to.not.exist;
135-
136-
// Remove the first
137-
collection.remove(
138-
{ a: 1 },
139-
{ writeConcern: { w: 1 }, single: true },
140-
function (err, r) {
141-
expect(r).property('deletedCount').to.equal(1);
142-
143-
collection.find({ a: 1 }).count(function (err, result) {
144-
expect(result).to.equal(3);
145-
client.close(done);
146-
});
147-
}
148-
);
149-
}
150-
);
151-
});
152-
});
153-
}
154-
});
155-
156110
it('should not error on empty remove', {
157111
metadata: {
158112
requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'] }

test/integration/node-specific/operation_example.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2541,7 +2541,7 @@ describe('Operation Examples', function () {
25412541
{ name: 'Sarah', title: 'Princess' },
25422542
{ name: 'Gump', title: 'Gump' }
25432543
],
2544-
{ writeConcern: { w: 1 }, keepGoing: true },
2544+
{ writeConcern: { w: 1 }, ordered: false },
25452545
function (err, result) {
25462546
expect(result).to.not.exist;
25472547
test.ok(err);

test/integration/node-specific/operation_promises_example.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1854,7 +1854,7 @@ describe('Operation (Promises)', function () {
18541854
{ name: 'Sarah', title: 'Princess' },
18551855
{ name: 'Gump', title: 'Gump' }
18561856
],
1857-
{ writeConcern: { w: 1 }, keepGoing: true }
1857+
{ writeConcern: { w: 1 }, ordered: false }
18581858
);
18591859
})
18601860
.catch(function () {

0 commit comments

Comments
 (0)