Skip to content

Commit cfbada6

Browse files
feat(NODE-5545): remove deprecated objects (#4704)
Co-authored-by: Bailey Pearson <[email protected]>
1 parent 3f7196e commit cfbada6

39 files changed

+1070
-514
lines changed

src/bulk/common.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import type { Topology } from '../sdam/topology';
2020
import { type Sort } from '../sort';
2121
import { TimeoutContext } from '../timeout';
2222
import {
23-
applyRetryableWrites,
2423
getTopology,
2524
hasAtomicOperators,
2625
maybeAddIdToDocuments,
@@ -527,15 +526,15 @@ async function executeCommands(
527526
finalOptions.checkKeys = false;
528527
}
529528

530-
if (finalOptions.retryWrites) {
529+
if (bulkOperation.retryWrites) {
531530
if (isUpdateBatch(batch)) {
532-
finalOptions.retryWrites =
533-
finalOptions.retryWrites && !batch.operations.some(op => op.multi);
531+
bulkOperation.retryWrites =
532+
bulkOperation.retryWrites && !batch.operations.some(op => op.multi);
534533
}
535534

536535
if (isDeleteBatch(batch)) {
537-
finalOptions.retryWrites =
538-
finalOptions.retryWrites && !batch.operations.some(op => op.limit === 0);
536+
bulkOperation.retryWrites =
537+
bulkOperation.retryWrites && !batch.operations.some(op => op.limit === 0);
539538
}
540539
}
541540

@@ -859,13 +858,16 @@ export abstract class BulkOperationBase {
859858
s: BulkOperationPrivate;
860859
operationId?: number;
861860
private collection: Collection;
861+
/** @internal */
862+
retryWrites?: boolean;
862863

863864
/**
864865
* Create a new OrderedBulkOperation or UnorderedBulkOperation instance
865866
* @internal
866867
*/
867868
constructor(collection: Collection, options: BulkWriteOptions, isOrdered: boolean) {
868869
this.collection = collection;
870+
this.retryWrites = collection.db.options?.retryWrites;
869871
// determine whether bulkOperation is ordered or unordered
870872
this.isOrdered = isOrdered;
871873

@@ -898,10 +900,6 @@ export abstract class BulkOperationBase {
898900
// + 1 bytes for null terminator
899901
const maxKeySize = (maxWriteBatchSize - 1).toString(10).length + 2;
900902

901-
// Final options for retryable writes
902-
let finalOptions = Object.assign({}, options);
903-
finalOptions = applyRetryableWrites(finalOptions, collection.db);
904-
905903
// Final results
906904
const bulkResult: BulkResult = {
907905
ok: 1,
@@ -943,7 +941,7 @@ export abstract class BulkOperationBase {
943941
// Topology
944942
topology,
945943
// Options
946-
options: finalOptions,
944+
options: options,
947945
// BSON options
948946
bsonOptions: resolveBSONOptions(options),
949947
// Current operation

src/change_stream.ts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ import {
1717
import { MongoClient } from './mongo_client';
1818
import { type InferIdType, TypedEventEmitter } from './mongo_types';
1919
import type { AggregateOptions } from './operations/aggregate';
20-
import type { CollationOptions, OperationParent } from './operations/command';
21-
import type { ReadPreference } from './read_preference';
20+
import type { OperationParent } from './operations/command';
2221
import { type AsyncDisposable, configureResourceManagement } from './resource_management';
2322
import type { ServerSessionId } from './sessions';
2423
import { CSOTTimeoutContext, type TimeoutContext } from './timeout';
@@ -45,21 +44,6 @@ const NO_RESUME_TOKEN_ERROR =
4544
'A change stream document has been received that lacks a resume token (_id).';
4645
const CHANGESTREAM_CLOSED_ERROR = 'ChangeStream is closed';
4746

48-
/**
49-
* @public
50-
* @deprecated Please use the ChangeStreamCursorOptions type instead.
51-
*/
52-
export interface ResumeOptions {
53-
startAtOperationTime?: Timestamp;
54-
batchSize?: number;
55-
maxAwaitTimeMS?: number;
56-
collation?: CollationOptions;
57-
readPreference?: ReadPreference;
58-
resumeAfter?: ResumeToken;
59-
startAfter?: ResumeToken;
60-
fullDocument?: string;
61-
}
62-
6347
/**
6448
* Represents the logical starting point for a new ChangeStream or resuming a ChangeStream on the server.
6549
* @see https://www.mongodb.com/docs/manual/changeStreams/#std-label-change-stream-resume

src/cmap/connection.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ export interface ConnectionOptions
138138
tls: boolean;
139139
noDelay?: boolean;
140140
socketTimeoutMS?: number;
141+
/** @internal */
141142
cancellationToken?: CancellationToken;
142143
metadata: ClientMetadata;
143144
/** @internal */

src/cmap/connection_pool.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,6 @@ export const PoolState = Object.freeze({
9797

9898
type PoolState = (typeof PoolState)[keyof typeof PoolState];
9999

100-
/**
101-
* @public
102-
* @deprecated This interface is deprecated and will be removed in a future release as it is not used
103-
* in the driver
104-
*/
105-
export interface CloseOptions {
106-
force?: boolean;
107-
}
108-
109100
/** @public */
110101
export type ConnectionPoolEvents = {
111102
connectionPoolCreated(event: ConnectionPoolCreatedEvent): void;

src/cmap/handshake/client_metadata.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,6 @@ export interface ClientMetadata {
5656
};
5757
}
5858

59-
/**
60-
* @public
61-
* @deprecated This interface will be made internal in the next major release.
62-
*/
63-
export interface ClientMetadataOptions {
64-
driverInfo?: {
65-
name?: string;
66-
version?: string;
67-
platform?: string;
68-
};
69-
appName?: string;
70-
}
71-
7259
/** @internal */
7360
export class LimitedSizeDocument {
7461
private document = new Map();

src/cmap/wire_protocol/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
export const MIN_SUPPORTED_SERVER_VERSION = '4.2';
22
export const MAX_SUPPORTED_SERVER_VERSION = '8.2';
3+
export const MIN_SUPPORTED_SNAPSHOT_READS_WIRE_VERSION = 13;
4+
export const MIN_SUPPORTED_SNAPSHOT_READS_SERVER_VERSION = '5.0';
35
export const MIN_SUPPORTED_WIRE_VERSION = 8;
46
export const MAX_SUPPORTED_WIRE_VERSION = 27;
57
export const MIN_SUPPORTED_QE_WIRE_VERSION = 21;

src/collection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ export class Collection<TSchema extends Document = Document> {
546546
// Explicitly set the limit to 1 and singleBatch to true for all commands, per the spec.
547547
// noCursorTimeout must be unset as well as batchSize.
548548
// See: https://github.com/mongodb/specifications/blob/master/source/crud/crud.md#findone-api-details
549-
const { batchSize: _batchSize, noCursorTimeout: _noCursorTimeout, ...opts } = options;
549+
const { ...opts } = options;
550550
opts.singleBatch = true;
551551
const cursor = this.find(filter, opts).limit(1);
552552
const result = await cursor.next();

src/connection_string.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,16 +1283,6 @@ export const OPTIONS = {
12831283
secureProtocol: { type: 'any' },
12841284
index: { type: 'any' },
12851285
// Legacy options from v3 era
1286-
useNewUrlParser: {
1287-
type: 'boolean',
1288-
deprecated:
1289-
'useNewUrlParser has no effect since Node.js Driver version 4.0.0 and will be removed in the next major version'
1290-
} as OptionDescriptor,
1291-
useUnifiedTopology: {
1292-
type: 'boolean',
1293-
deprecated:
1294-
'useUnifiedTopology has no effect since Node.js Driver version 4.0.0 and will be removed in the next major version'
1295-
} as OptionDescriptor,
12961286
__skipPingOnConnect: { type: 'boolean' }
12971287
} as Record<keyof MongoClientOptions, OptionDescriptor>;
12981288

src/gridfs/download.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,6 @@ export interface GridFSFile {
5353
filename: string;
5454
metadata?: Document;
5555
uploadDate: Date;
56-
/** @deprecated Will be removed in the next major version. */
57-
contentType?: string;
58-
/** @deprecated Will be removed in the next major version. */
59-
aliases?: string[];
6056
}
6157

6258
/** @internal */

src/gridfs/upload.ts

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,6 @@ export interface GridFSBucketWriteStreamOptions extends WriteConcernOptions {
3232
id?: ObjectId;
3333
/** Object to store in the file document's `metadata` field */
3434
metadata?: Document;
35-
/**
36-
* String to store in the file document's `contentType` field.
37-
* @deprecated Will be removed in the next major version. Add a contentType field to the metadata document instead.
38-
*/
39-
contentType?: string;
40-
/**
41-
* Array of strings to store in the file document's `aliases` field.
42-
* @deprecated Will be removed in the next major version. Add an aliases field to the metadata document instead.
43-
*/
44-
aliases?: string[];
4535
/**
4636
* @experimental
4737
* Specifies the time an operation will run until it throws a timeout error
@@ -305,8 +295,6 @@ function checkDone(stream: GridFSBucketWriteStream, callback: Callback): void {
305295
stream.length,
306296
stream.chunkSizeBytes,
307297
stream.filename,
308-
stream.options.contentType,
309-
stream.options.aliases,
310298
stream.options.metadata
311299
);
312300

@@ -402,8 +390,6 @@ function createFilesDoc(
402390
length: number,
403391
chunkSize: number,
404392
filename: string,
405-
contentType?: string,
406-
aliases?: string[],
407393
metadata?: Document
408394
): GridFSFile {
409395
const ret: GridFSFile = {
@@ -414,14 +400,6 @@ function createFilesDoc(
414400
filename
415401
};
416402

417-
if (contentType) {
418-
ret.contentType = contentType;
419-
}
420-
421-
if (aliases) {
422-
ret.aliases = aliases;
423-
}
424-
425403
if (metadata) {
426404
ret.metadata = metadata;
427405
}

0 commit comments

Comments
 (0)