Skip to content

refactor!: remove deprecated items #2740

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"plugins": [
"@typescript-eslint",
"prettier",
"promise",
"eslint-plugin-tsdoc"
],
"extends": [
Expand All @@ -27,10 +26,9 @@

"tsdoc/syntax": "warn",

"no-console": "off",
"no-console": "error",
"eqeqeq": ["error", "always", { "null": "ignore" }],
"strict": ["error", "global"],
"promise/no-native": "error",

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

Expand Down
991 changes: 538 additions & 453 deletions package-lock.json

Large diffs are not rendered by default.

19 changes: 9 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
},
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.1",
"@microsoft/api-extractor": "^7.12.1",
"@microsoft/tsdoc-config": "^0.13.9",
"@microsoft/api-extractor": "^7.13.1",
"@microsoft/tsdoc-config": "^0.14.0",
"@types/aws4": "^1.5.1",
"@types/bl": "^2.1.0",
"@types/chai": "^4.2.14",
Expand All @@ -42,19 +42,18 @@
"@types/node": "^14.6.4",
"@types/saslprep": "^1.0.0",
"@types/semver": "^7.3.4",
"@typescript-eslint/eslint-plugin": "^3.10.0",
"@typescript-eslint/parser": "^3.10.0",
"@typescript-eslint/eslint-plugin": "^4.15.1",
"@typescript-eslint/parser": "^4.15.1",
"chai": "^4.2.0",
"chai-subset": "^1.6.0",
"chalk": "^4.1.0",
"co": "4.6.0",
"coveralls": "^3.0.11",
"eslint": "^6.8.0",
"eslint": "^7.20.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-jsdoc": "^30.7.8",
"eslint-plugin-prettier": "^3.1.3",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-tsdoc": "^0.2.10",
"eslint-plugin-tsdoc": "^0.2.11",
"js-yaml": "^3.14.0",
"jsdoc": "^3.6.4",
"lodash.camelcase": "^4.3.0",
Expand All @@ -72,9 +71,9 @@
"source-map-support": "^0.5.19",
"standard-version": "^8.0.2",
"through2": "^3.0.1",
"ts-node": "^9.0.0",
"typedoc": "^0.20.14",
"typescript": "^4.0.5",
"ts-node": "^9.1.1",
"typedoc": "^0.20.25",
"typescript": "^4.1.5",
"typescript-cached-transpile": "^0.0.6",
"worker-farm": "^1.5.0",
"wtfnode": "^0.8.2",
Expand Down
4 changes: 2 additions & 2 deletions src/cmap/auth/scram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as crypto from 'crypto';
import { Binary, Document } from '../../bson';
import { MongoError, AnyError } from '../../error';
import { AuthProvider, AuthContext } from './auth_provider';
import { Callback, ns } from '../../utils';
import { Callback, emitWarning, ns } from '../../utils';
import type { MongoCredentials } from './mongo_credentials';
import type { HandshakeDocument } from '../connect';

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

crypto.randomBytes(24, (err, nonce) => {
Expand Down
8 changes: 5 additions & 3 deletions src/cmap/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { OP_QUERY, OP_GETMORE, OP_KILL_CURSORS, OP_MSG } from './wire_protocol/c
import type { Long, Document, BSONSerializeOptions } from '../bson';
import type { ClientSession } from '../sessions';
import type { CommandOptions } from './connection';
import { MongoError } from '../error';

// Incrementing request id
let _requestId = 0;
Expand Down Expand Up @@ -825,14 +826,15 @@ export class BinMsg {

while (this.index < this.data.length) {
const payloadType = this.data.readUInt8(this.index++);
if (payloadType === 1) {
console.error('TYPE 1');
} else if (payloadType === 0) {
if (payloadType === 0) {
const bsonSize = this.data.readUInt32LE(this.index);
const bin = this.data.slice(this.index, this.index + bsonSize);
this.documents.push(raw ? bin : BSON.deserialize(bin, _options));

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

Expand Down
30 changes: 1 addition & 29 deletions src/cmap/connection_pool.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Denque = require('denque');
import { EventEmitter } from 'events';
import { Logger } from '../logger';
import { Connection, ConnectionOptions, CommandOptions } from './connection';
import { Connection, ConnectionOptions } from './connection';
import { connect } from './connect';
import { eachAsync, relayEvents, makeCounter, Callback } from '../utils';
import { MongoError } from '../error';
Expand All @@ -18,7 +18,6 @@ import {
ConnectionCheckedInEvent,
ConnectionPoolClearedEvent
} from './events';
import type { Document } from '../bson';

const kLogger = Symbol('logger');
const kConnections = Symbol('connections');
Expand Down Expand Up @@ -360,33 +359,6 @@ export class ConnectionPool extends EventEmitter {
});
});
}

// NOTE: remove `isConnected` and `write` as part of NODE-2745
// These functions only exist if makeServerTrampoline is
// called when using the wire protocol methods

/**
* @internal
* @deprecated Remove sever trampoline code. (NODE-2745)
*/
isConnected(): boolean {
throw new TypeError('This is not a server trampoline instance');
}

/**
* @internal
* @deprecated Remove sever trampoline code. (NODE-2745)
*/
write(
message: Document,
commandOptions: CommandOptions,
callback: (err: MongoError, ...args: Document[]) => void
): void {
message;
commandOptions;
callback;
throw new TypeError('This is not a server trampoline instance');
}
}

function ensureMinPoolSize(pool: ConnectionPool) {
Expand Down
46 changes: 33 additions & 13 deletions src/cmap/events.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { GetMore, KillCursor, Msg, WriteProtocolMessageType } from './commands';
import { calculateDurationInMs, deepCopy } from '../utils';
import type { ConnectionPool, ConnectionPoolOptions } from './connection_pool';
import { ConnectionPool, ConnectionPoolOptions } from './connection_pool';
import type { Connection } from './connection';
import type { Document } from '../bson';
import type { AnyError } from '../error';

/**
* The base export class for all monitoring events published from the connection pool
* @public
* @category Event
*/
export class ConnectionPoolMonitoringEvent {
Expand All @@ -23,6 +24,7 @@ export class ConnectionPoolMonitoringEvent {

/**
* An event published when a connection pool is created
* @public
* @category Event
*/
export class ConnectionPoolCreatedEvent extends ConnectionPoolMonitoringEvent {
Expand All @@ -37,6 +39,7 @@ export class ConnectionPoolCreatedEvent extends ConnectionPoolMonitoringEvent {

/**
* An event published when a connection pool is closed
* @public
* @category Event
*/
export class ConnectionPoolClosedEvent extends ConnectionPoolMonitoringEvent {
Expand All @@ -47,6 +50,7 @@ export class ConnectionPoolClosedEvent extends ConnectionPoolMonitoringEvent {

/**
* An event published when a connection pool creates a new connection
* @public
* @category Event
*/
export class ConnectionCreatedEvent extends ConnectionPoolMonitoringEvent {
Expand All @@ -61,6 +65,7 @@ export class ConnectionCreatedEvent extends ConnectionPoolMonitoringEvent {

/**
* An event published when a connection is ready for use
* @public
* @category Event
*/
export class ConnectionReadyEvent extends ConnectionPoolMonitoringEvent {
Expand All @@ -75,6 +80,7 @@ export class ConnectionReadyEvent extends ConnectionPoolMonitoringEvent {

/**
* An event published when a connection is closed
* @public
* @category Event
*/
export class ConnectionClosedEvent extends ConnectionPoolMonitoringEvent {
Expand All @@ -90,7 +96,11 @@ export class ConnectionClosedEvent extends ConnectionPoolMonitoringEvent {
}
}

/** An event published when a request to check a connection out begins @category Event */
/**
* An event published when a request to check a connection out begins
* @public
* @category Event
*/
export class ConnectionCheckOutStartedEvent extends ConnectionPoolMonitoringEvent {
constructor(pool: ConnectionPool) {
super(pool);
Expand All @@ -99,6 +109,7 @@ export class ConnectionCheckOutStartedEvent extends ConnectionPoolMonitoringEven

/**
* An event published when a request to check a connection out fails
* @public
* @category Event
*/
export class ConnectionCheckOutFailedEvent extends ConnectionPoolMonitoringEvent {
Expand All @@ -113,6 +124,7 @@ export class ConnectionCheckOutFailedEvent extends ConnectionPoolMonitoringEvent

/**
* An event published when a connection is checked out of the connection pool
* @public
* @category Event
*/
export class ConnectionCheckedOutEvent extends ConnectionPoolMonitoringEvent {
Expand All @@ -127,6 +139,7 @@ export class ConnectionCheckedOutEvent extends ConnectionPoolMonitoringEvent {

/**
* An event published when a connection is checked into the connection pool
* @public
* @category Event
*/
export class ConnectionCheckedInEvent extends ConnectionPoolMonitoringEvent {
Expand All @@ -141,6 +154,7 @@ export class ConnectionCheckedInEvent extends ConnectionPoolMonitoringEvent {

/**
* An event published when a connection pool is cleared
* @public
* @category Event
*/
export class ConnectionPoolClearedEvent extends ConnectionPoolMonitoringEvent {
Expand All @@ -150,20 +164,21 @@ export class ConnectionPoolClearedEvent extends ConnectionPoolMonitoringEvent {
}

export const CMAP_EVENT_NAMES = [
'connectionPoolCreated',
'connectionPoolClosed',
'connectionCreated',
'connectionReady',
'connectionClosed',
'connectionCheckOutStarted',
'connectionCheckOutFailed',
'connectionCheckedOut',
'connectionCheckedIn',
'connectionPoolCleared'
];
ConnectionPool.CONNECTION_POOL_CREATED,
ConnectionPool.CONNECTION_POOL_CLOSED,
ConnectionPool.CONNECTION_CREATED,
ConnectionPool.CONNECTION_READY,
ConnectionPool.CONNECTION_CLOSED,
ConnectionPool.CONNECTION_CHECK_OUT_STARTED,
ConnectionPool.CONNECTION_CHECK_OUT_FAILED,
ConnectionPool.CONNECTION_CHECKED_OUT,
ConnectionPool.CONNECTION_CHECKED_IN,
ConnectionPool.CONNECTION_POOL_CLEARED
] as const;

/**
* An event indicating the start of a given
* @public
* @category Event
*/
export class CommandStartedEvent {
Expand All @@ -178,6 +193,7 @@ export class CommandStartedEvent {
/**
* Create a started event
*
* @internal
* @param pool - the pool that originated the command
* @param command - the command
*/
Expand All @@ -203,6 +219,7 @@ export class CommandStartedEvent {

/**
* An event indicating the success of a given command
* @public
* @category Event
*/
export class CommandSucceededEvent {
Expand All @@ -216,6 +233,7 @@ export class CommandSucceededEvent {
/**
* Create a succeeded event
*
* @internal
* @param pool - the pool that originated the command
* @param command - the command
* @param reply - the reply for this command from the server
Expand All @@ -242,6 +260,7 @@ export class CommandSucceededEvent {

/**
* An event indicating the failure of a given command
* @public
* @category Event
*/
export class CommandFailedEvent {
Expand All @@ -254,6 +273,7 @@ export class CommandFailedEvent {
/**
* Create a failure event
*
* @internal
* @param pool - the pool that originated the command
* @param command - the command
* @param error - the generated error or a server error response
Expand Down
Loading