Skip to content

Commit ee1a4d3

Browse files
authored
refactor!: remove deprecated items (#2740)
Removals are noted in JIRA ticket. NODE-2317
1 parent d52c00e commit ee1a4d3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1036
-1850
lines changed

.eslintrc.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
"plugins": [
88
"@typescript-eslint",
99
"prettier",
10-
"promise",
1110
"eslint-plugin-tsdoc"
1211
],
1312
"extends": [
@@ -27,10 +26,9 @@
2726

2827
"tsdoc/syntax": "warn",
2928

30-
"no-console": "off",
29+
"no-console": "error",
3130
"eqeqeq": ["error", "always", { "null": "ignore" }],
3231
"strict": ["error", "global"],
33-
"promise/no-native": "error",
3432

3533
"@typescript-eslint/no-explicit-any": "off",
3634

package-lock.json

+538-453
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+9-10
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
},
3232
"devDependencies": {
3333
"@istanbuljs/nyc-config-typescript": "^1.0.1",
34-
"@microsoft/api-extractor": "^7.12.1",
35-
"@microsoft/tsdoc-config": "^0.13.9",
34+
"@microsoft/api-extractor": "^7.13.1",
35+
"@microsoft/tsdoc-config": "^0.14.0",
3636
"@types/aws4": "^1.5.1",
3737
"@types/bl": "^2.1.0",
3838
"@types/chai": "^4.2.14",
@@ -42,19 +42,18 @@
4242
"@types/node": "^14.6.4",
4343
"@types/saslprep": "^1.0.0",
4444
"@types/semver": "^7.3.4",
45-
"@typescript-eslint/eslint-plugin": "^3.10.0",
46-
"@typescript-eslint/parser": "^3.10.0",
45+
"@typescript-eslint/eslint-plugin": "^4.15.1",
46+
"@typescript-eslint/parser": "^4.15.1",
4747
"chai": "^4.2.0",
4848
"chai-subset": "^1.6.0",
4949
"chalk": "^4.1.0",
5050
"co": "4.6.0",
5151
"coveralls": "^3.0.11",
52-
"eslint": "^6.8.0",
52+
"eslint": "^7.20.0",
5353
"eslint-config-prettier": "^6.11.0",
5454
"eslint-plugin-jsdoc": "^30.7.8",
5555
"eslint-plugin-prettier": "^3.1.3",
56-
"eslint-plugin-promise": "^4.2.1",
57-
"eslint-plugin-tsdoc": "^0.2.10",
56+
"eslint-plugin-tsdoc": "^0.2.11",
5857
"js-yaml": "^3.14.0",
5958
"jsdoc": "^3.6.4",
6059
"lodash.camelcase": "^4.3.0",
@@ -72,9 +71,9 @@
7271
"source-map-support": "^0.5.19",
7372
"standard-version": "^8.0.2",
7473
"through2": "^3.0.1",
75-
"ts-node": "^9.0.0",
76-
"typedoc": "^0.20.14",
77-
"typescript": "^4.0.5",
74+
"ts-node": "^9.1.1",
75+
"typedoc": "^0.20.25",
76+
"typescript": "^4.1.5",
7877
"typescript-cached-transpile": "^0.0.6",
7978
"worker-farm": "^1.5.0",
8079
"wtfnode": "^0.8.2",

src/cmap/auth/scram.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as crypto from 'crypto';
22
import { Binary, Document } from '../../bson';
33
import { MongoError, AnyError } from '../../error';
44
import { AuthProvider, AuthContext } from './auth_provider';
5-
import { Callback, ns } from '../../utils';
5+
import { Callback, emitWarning, ns } from '../../utils';
66
import type { MongoCredentials } from './mongo_credentials';
77
import type { HandshakeDocument } from '../connect';
88

@@ -25,7 +25,7 @@ class ScramSHA extends AuthProvider {
2525
return callback(new MongoError('AuthContext must provide credentials.'));
2626
}
2727
if (cryptoMethod === 'sha256' && saslprep == null) {
28-
console.warn('Warning: no saslprep library specified. Passwords will not be sanitized');
28+
emitWarning('Warning: no saslprep library specified. Passwords will not be sanitized');
2929
}
3030

3131
crypto.randomBytes(24, (err, nonce) => {

src/cmap/commands.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { OP_QUERY, OP_GETMORE, OP_KILL_CURSORS, OP_MSG } from './wire_protocol/c
55
import type { Long, Document, BSONSerializeOptions } from '../bson';
66
import type { ClientSession } from '../sessions';
77
import type { CommandOptions } from './connection';
8+
import { MongoError } from '../error';
89

910
// Incrementing request id
1011
let _requestId = 0;
@@ -825,14 +826,15 @@ export class BinMsg {
825826

826827
while (this.index < this.data.length) {
827828
const payloadType = this.data.readUInt8(this.index++);
828-
if (payloadType === 1) {
829-
console.error('TYPE 1');
830-
} else if (payloadType === 0) {
829+
if (payloadType === 0) {
831830
const bsonSize = this.data.readUInt32LE(this.index);
832831
const bin = this.data.slice(this.index, this.index + bsonSize);
833832
this.documents.push(raw ? bin : BSON.deserialize(bin, _options));
834833

835834
this.index += bsonSize;
835+
} else if (payloadType === 1) {
836+
// It was decided that no driver makes use of payload type 1
837+
throw new MongoError('OP_MSG Payload Type 1 detected unsupported protocol');
836838
}
837839
}
838840

src/cmap/connection_pool.ts

+1-29
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Denque = require('denque');
22
import { EventEmitter } from 'events';
33
import { Logger } from '../logger';
4-
import { Connection, ConnectionOptions, CommandOptions } from './connection';
4+
import { Connection, ConnectionOptions } from './connection';
55
import { connect } from './connect';
66
import { eachAsync, relayEvents, makeCounter, Callback } from '../utils';
77
import { MongoError } from '../error';
@@ -18,7 +18,6 @@ import {
1818
ConnectionCheckedInEvent,
1919
ConnectionPoolClearedEvent
2020
} from './events';
21-
import type { Document } from '../bson';
2221

2322
const kLogger = Symbol('logger');
2423
const kConnections = Symbol('connections');
@@ -360,33 +359,6 @@ export class ConnectionPool extends EventEmitter {
360359
});
361360
});
362361
}
363-
364-
// NOTE: remove `isConnected` and `write` as part of NODE-2745
365-
// These functions only exist if makeServerTrampoline is
366-
// called when using the wire protocol methods
367-
368-
/**
369-
* @internal
370-
* @deprecated Remove sever trampoline code. (NODE-2745)
371-
*/
372-
isConnected(): boolean {
373-
throw new TypeError('This is not a server trampoline instance');
374-
}
375-
376-
/**
377-
* @internal
378-
* @deprecated Remove sever trampoline code. (NODE-2745)
379-
*/
380-
write(
381-
message: Document,
382-
commandOptions: CommandOptions,
383-
callback: (err: MongoError, ...args: Document[]) => void
384-
): void {
385-
message;
386-
commandOptions;
387-
callback;
388-
throw new TypeError('This is not a server trampoline instance');
389-
}
390362
}
391363

392364
function ensureMinPoolSize(pool: ConnectionPool) {

src/cmap/events.ts

+33-13
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { GetMore, KillCursor, Msg, WriteProtocolMessageType } from './commands';
22
import { calculateDurationInMs, deepCopy } from '../utils';
3-
import type { ConnectionPool, ConnectionPoolOptions } from './connection_pool';
3+
import { ConnectionPool, ConnectionPoolOptions } from './connection_pool';
44
import type { Connection } from './connection';
55
import type { Document } from '../bson';
66
import type { AnyError } from '../error';
77

88
/**
99
* The base export class for all monitoring events published from the connection pool
10+
* @public
1011
* @category Event
1112
*/
1213
export class ConnectionPoolMonitoringEvent {
@@ -23,6 +24,7 @@ export class ConnectionPoolMonitoringEvent {
2324

2425
/**
2526
* An event published when a connection pool is created
27+
* @public
2628
* @category Event
2729
*/
2830
export class ConnectionPoolCreatedEvent extends ConnectionPoolMonitoringEvent {
@@ -37,6 +39,7 @@ export class ConnectionPoolCreatedEvent extends ConnectionPoolMonitoringEvent {
3739

3840
/**
3941
* An event published when a connection pool is closed
42+
* @public
4043
* @category Event
4144
*/
4245
export class ConnectionPoolClosedEvent extends ConnectionPoolMonitoringEvent {
@@ -47,6 +50,7 @@ export class ConnectionPoolClosedEvent extends ConnectionPoolMonitoringEvent {
4750

4851
/**
4952
* An event published when a connection pool creates a new connection
53+
* @public
5054
* @category Event
5155
*/
5256
export class ConnectionCreatedEvent extends ConnectionPoolMonitoringEvent {
@@ -61,6 +65,7 @@ export class ConnectionCreatedEvent extends ConnectionPoolMonitoringEvent {
6165

6266
/**
6367
* An event published when a connection is ready for use
68+
* @public
6469
* @category Event
6570
*/
6671
export class ConnectionReadyEvent extends ConnectionPoolMonitoringEvent {
@@ -75,6 +80,7 @@ export class ConnectionReadyEvent extends ConnectionPoolMonitoringEvent {
7580

7681
/**
7782
* An event published when a connection is closed
83+
* @public
7884
* @category Event
7985
*/
8086
export class ConnectionClosedEvent extends ConnectionPoolMonitoringEvent {
@@ -90,7 +96,11 @@ export class ConnectionClosedEvent extends ConnectionPoolMonitoringEvent {
9096
}
9197
}
9298

93-
/** An event published when a request to check a connection out begins @category Event */
99+
/**
100+
* An event published when a request to check a connection out begins
101+
* @public
102+
* @category Event
103+
*/
94104
export class ConnectionCheckOutStartedEvent extends ConnectionPoolMonitoringEvent {
95105
constructor(pool: ConnectionPool) {
96106
super(pool);
@@ -99,6 +109,7 @@ export class ConnectionCheckOutStartedEvent extends ConnectionPoolMonitoringEven
99109

100110
/**
101111
* An event published when a request to check a connection out fails
112+
* @public
102113
* @category Event
103114
*/
104115
export class ConnectionCheckOutFailedEvent extends ConnectionPoolMonitoringEvent {
@@ -113,6 +124,7 @@ export class ConnectionCheckOutFailedEvent extends ConnectionPoolMonitoringEvent
113124

114125
/**
115126
* An event published when a connection is checked out of the connection pool
127+
* @public
116128
* @category Event
117129
*/
118130
export class ConnectionCheckedOutEvent extends ConnectionPoolMonitoringEvent {
@@ -127,6 +139,7 @@ export class ConnectionCheckedOutEvent extends ConnectionPoolMonitoringEvent {
127139

128140
/**
129141
* An event published when a connection is checked into the connection pool
142+
* @public
130143
* @category Event
131144
*/
132145
export class ConnectionCheckedInEvent extends ConnectionPoolMonitoringEvent {
@@ -141,6 +154,7 @@ export class ConnectionCheckedInEvent extends ConnectionPoolMonitoringEvent {
141154

142155
/**
143156
* An event published when a connection pool is cleared
157+
* @public
144158
* @category Event
145159
*/
146160
export class ConnectionPoolClearedEvent extends ConnectionPoolMonitoringEvent {
@@ -150,20 +164,21 @@ export class ConnectionPoolClearedEvent extends ConnectionPoolMonitoringEvent {
150164
}
151165

152166
export const CMAP_EVENT_NAMES = [
153-
'connectionPoolCreated',
154-
'connectionPoolClosed',
155-
'connectionCreated',
156-
'connectionReady',
157-
'connectionClosed',
158-
'connectionCheckOutStarted',
159-
'connectionCheckOutFailed',
160-
'connectionCheckedOut',
161-
'connectionCheckedIn',
162-
'connectionPoolCleared'
163-
];
167+
ConnectionPool.CONNECTION_POOL_CREATED,
168+
ConnectionPool.CONNECTION_POOL_CLOSED,
169+
ConnectionPool.CONNECTION_CREATED,
170+
ConnectionPool.CONNECTION_READY,
171+
ConnectionPool.CONNECTION_CLOSED,
172+
ConnectionPool.CONNECTION_CHECK_OUT_STARTED,
173+
ConnectionPool.CONNECTION_CHECK_OUT_FAILED,
174+
ConnectionPool.CONNECTION_CHECKED_OUT,
175+
ConnectionPool.CONNECTION_CHECKED_IN,
176+
ConnectionPool.CONNECTION_POOL_CLEARED
177+
] as const;
164178

165179
/**
166180
* An event indicating the start of a given
181+
* @public
167182
* @category Event
168183
*/
169184
export class CommandStartedEvent {
@@ -178,6 +193,7 @@ export class CommandStartedEvent {
178193
/**
179194
* Create a started event
180195
*
196+
* @internal
181197
* @param pool - the pool that originated the command
182198
* @param command - the command
183199
*/
@@ -203,6 +219,7 @@ export class CommandStartedEvent {
203219

204220
/**
205221
* An event indicating the success of a given command
222+
* @public
206223
* @category Event
207224
*/
208225
export class CommandSucceededEvent {
@@ -216,6 +233,7 @@ export class CommandSucceededEvent {
216233
/**
217234
* Create a succeeded event
218235
*
236+
* @internal
219237
* @param pool - the pool that originated the command
220238
* @param command - the command
221239
* @param reply - the reply for this command from the server
@@ -242,6 +260,7 @@ export class CommandSucceededEvent {
242260

243261
/**
244262
* An event indicating the failure of a given command
263+
* @public
245264
* @category Event
246265
*/
247266
export class CommandFailedEvent {
@@ -254,6 +273,7 @@ export class CommandFailedEvent {
254273
/**
255274
* Create a failure event
256275
*
276+
* @internal
257277
* @param pool - the pool that originated the command
258278
* @param command - the command
259279
* @param error - the generated error or a server error response

0 commit comments

Comments
 (0)