-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat(NODE-4607): add exports needed by legacy client #3396
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
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
dbcd372
feat(NODE-4607): add exports needed by legacy client
nbbeeken b800552
docs: internal flags on all exported constructors
nbbeeken 144b03b
test: fix for ts-node strangeness
nbbeeken d681d46
fixup
nbbeeken cfb0ad3
sort lines
nbbeeken ce60aa3
question -> action
nbbeeken File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,161 @@ | ||
| import { expect } from 'chai'; | ||
|
|
||
| import * as mongodb from '../../src/index'; | ||
| import { setDifference } from '../../src/utils'; | ||
| import { byStrings, sorted } from '../tools/utils'; | ||
|
|
||
| // prettier-ignore | ||
| const expectedExports = new Map([ | ||
| // BSON | ||
| ['BSON', 'reason'], | ||
| ['Binary', 'reason'], | ||
| ['BSONRegExp', 'reason'], | ||
| ['BSONSymbol', 'reason'], | ||
| ['Code', 'reason'], | ||
| ['DBRef', 'reason'], | ||
| ['Decimal128', 'reason'], | ||
| ['Double', 'reason'], | ||
| ['Int32', 'reason'], | ||
| ['Long', 'reason'], | ||
| ['Map', 'reason'], | ||
| ['MaxKey', 'reason'], | ||
| ['MinKey', 'reason'], | ||
| ['ObjectId', 'reason'], | ||
| ['Timestamp', 'reason'], | ||
| ['ChangeStreamCursor', 'reason'], | ||
| ['ObjectID', 'reason'], | ||
| // errors | ||
| ['MongoBulkWriteError', 'reason'], | ||
| ['MongoAPIError', 'reason'], | ||
| ['MongoAWSError', 'reason'], | ||
| ['MongoBatchReExecutionError', 'reason'], | ||
| ['MongoChangeStreamError', 'reason'], | ||
| ['MongoCompatibilityError', 'reason'], | ||
| ['MongoCursorExhaustedError', 'reason'], | ||
| ['MongoCursorInUseError', 'reason'], | ||
| ['MongoDecompressionError', 'reason'], | ||
| ['MongoDriverError', 'reason'], | ||
| ['MongoError', 'reason'], | ||
| ['MongoExpiredSessionError', 'reason'], | ||
| ['MongoGridFSChunkError', 'reason'], | ||
| ['MongoGridFSStreamError', 'reason'], | ||
| ['MongoInvalidArgumentError', 'reason'], | ||
| ['MongoKerberosError', 'reason'], | ||
| ['MongoMissingCredentialsError', 'reason'], | ||
| ['MongoMissingDependencyError', 'reason'], | ||
| ['MongoNetworkError', 'reason'], | ||
| ['MongoNetworkTimeoutError', 'reason'], | ||
| ['MongoNotConnectedError', 'reason'], | ||
| ['MongoParseError', 'reason'], | ||
| ['MongoRuntimeError', 'reason'], | ||
| ['MongoServerClosedError', 'reason'], | ||
| ['MongoServerError', 'reason'], | ||
| ['MongoServerSelectionError', 'reason'], | ||
| ['MongoSystemError', 'reason'], | ||
| ['MongoTailableCursorError', 'reason'], | ||
| ['MongoTopologyClosedError', 'reason'], | ||
| ['MongoTransactionError', 'reason'], | ||
| ['MongoUnexpectedServerResponseError', 'reason'], | ||
| ['MongoWriteConcernError', 'reason'], | ||
| // classes | ||
| ['AbstractCursor', 'reason'], | ||
| ['Admin', 'reason'], | ||
| ['AggregationCursor', 'reason'], | ||
| ['CancellationToken', 'reason'], | ||
| ['ChangeStream', 'reason'], | ||
| ['ClientSession', 'reason'], | ||
| ['Collection', 'reason'], | ||
| ['Db', 'reason'], | ||
| ['FindCursor', 'reason'], | ||
| ['GridFSBucket', 'reason'], | ||
| ['ListCollectionsCursor', 'reason'], | ||
| ['ListIndexesCursor', 'reason'], | ||
| ['Logger', 'reason'], | ||
| ['MongoClient', 'reason'], | ||
| // global promise setter | ||
| ['Promise', 'global promise setter'], | ||
| // enums | ||
| ['BatchType', 'reason'], | ||
| ['GSSAPICanonicalizationValue', 'reason'], | ||
| ['AuthMechanism', 'reason'], | ||
| ['Compressor', 'reason'], | ||
| ['CURSOR_FLAGS', 'reason'], | ||
| ['AutoEncryptionLoggerLevel', 'reason'], | ||
| ['MongoErrorLabel', 'reason'], | ||
| ['ExplainVerbosity', 'reason'], | ||
| ['LoggerLevel', 'reason'], | ||
| ['ServerApiVersion', 'reason'], | ||
| ['BSONType', 'reason'], | ||
| ['ReturnDocument', 'reason'], | ||
| ['ProfilingLevel', 'reason'], | ||
| ['ReadConcernLevel', 'reason'], | ||
| ['ReadPreferenceMode', 'reason'], | ||
| ['ServerType', 'reason'], | ||
| ['TopologyType', 'reason'], | ||
| ['ReadConcern', 'reason'], | ||
| ['ReadPreference', 'reason'], | ||
| ['WriteConcern', 'reason'], | ||
| // events | ||
| ['CommandFailedEvent', 'reason'], | ||
| ['CommandStartedEvent', 'reason'], | ||
| ['CommandSucceededEvent', 'reason'], | ||
| ['ConnectionCheckedInEvent', 'reason'], | ||
| ['ConnectionCheckedOutEvent', 'reason'], | ||
| ['ConnectionCheckOutFailedEvent', 'reason'], | ||
| ['ConnectionCheckOutStartedEvent', 'reason'], | ||
| ['ConnectionClosedEvent', 'reason'], | ||
| ['ConnectionCreatedEvent', 'reason'], | ||
| ['ConnectionPoolClearedEvent', 'reason'], | ||
| ['ConnectionPoolClosedEvent', 'reason'], | ||
| ['ConnectionPoolCreatedEvent', 'reason'], | ||
| ['ConnectionPoolMonitoringEvent', 'reason'], | ||
| ['ConnectionReadyEvent', 'reason'], | ||
| ['ServerClosedEvent', 'reason'], | ||
| ['ServerDescriptionChangedEvent', 'reason'], | ||
| ['ServerHeartbeatFailedEvent', 'reason'], | ||
| ['ServerHeartbeatStartedEvent', 'reason'], | ||
| ['ServerHeartbeatSucceededEvent', 'reason'], | ||
| ['ServerOpeningEvent', 'reason'], | ||
| ['TopologyClosedEvent', 'reason'], | ||
| ['TopologyDescriptionChangedEvent', 'reason'], | ||
| ['TopologyOpeningEvent', 'reason'], | ||
| ['SrvPollingEvent', 'reason'], | ||
|
|
||
| ['GridFSBucketReadStream', 'reason'], | ||
| ['GridFSBucketWriteStream', 'reason'], | ||
| ['OrderedBulkOperation', 'reason'], | ||
| ['UnorderedBulkOperation', 'reason'], | ||
|
|
||
| // TS-NODE Adds these keys but they are undefined... weird | ||
dariakp marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ['AnyBulkWriteOperation', 'ts-node'], | ||
| ['BulkWriteOptions', 'ts-node'], | ||
| ]); | ||
|
|
||
| describe('mongodb entrypoint', () => { | ||
| it('should export all keys in our exports list', () => { | ||
| expect(sorted(Object.keys(mongodb), byStrings)).to.deep.equal( | ||
| sorted(expectedExports.keys(), byStrings) | ||
| ); | ||
| }); | ||
|
|
||
| it('should export only keys in our exports list', () => { | ||
| const currentExports = Object.keys(mongodb); | ||
| const difference = setDifference(currentExports, expectedExports.keys()); | ||
| expect( | ||
| difference, | ||
| `Found extra exports [${Array.from(difference).join( | ||
dariakp marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ', ' | ||
| )}], if these are expected, just add them to the list in this file` | ||
| ).to.have.lengthOf(0); | ||
| }); | ||
|
|
||
| it('meta test: ts-node adds keys to the module that point to undefined', () => { | ||
dariakp marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| const tsNodeKeys = Array.from(expectedExports.entries()).filter( | ||
| ([, value]) => value === 'ts-node' | ||
| ); | ||
|
|
||
| for (const [tsNodeKey] of tsNodeKeys) { | ||
| expect(mongodb).to.have.property(tsNodeKey, undefined); | ||
| } | ||
| }); | ||
| }); | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.