diff --git a/api-extractor.json b/api-extractor.json index aa239a78ee..bda873c16b 100644 --- a/api-extractor.json +++ b/api-extractor.json @@ -9,7 +9,8 @@ }, "dtsRollup": { "enabled": true, - "untrimmedFilePath": "/.d.ts" + "untrimmedFilePath": "", + "publicTrimmedFilePath": "/.d.ts" }, "tsdocMetadata": { "enabled": false @@ -23,23 +24,15 @@ }, "extractorMessageReporting": { "default": { - "logLevel": "warning" + "logLevel": "error" }, "ae-internal-missing-underscore": { "logLevel": "none", "addToApiReportFile": false }, - "ae-missing-release-tag": { + "ae-forgotten-export": { "logLevel": "error", "addToApiReportFile": false - }, - "ae-incompatible-release-tags": { - "logLevel": "none", - "addToApiReportFile": false - }, - "ae-unresolved-link": { - "addToApiReportFile": false, - "logLevel": "none" } }, "tsdocMessageReporting": { diff --git a/package-lock.json b/package-lock.json index 8f5b9d4665..27b872a271 100644 --- a/package-lock.json +++ b/package-lock.json @@ -355,29 +355,42 @@ "dev": true }, "@microsoft/tsdoc-config": { - "version": "0.13.6", - "resolved": "https://registry.npmjs.org/@microsoft/tsdoc-config/-/tsdoc-config-0.13.6.tgz", - "integrity": "sha512-VJjV35PnrNISoX2WMemZjnCIdOUPTRpCz6pu8inISotLd3SgoDSJygGaE7+lOYdCtDl+4c8PWJdZivxxXgOnLw==", + "version": "0.13.7", + "resolved": "https://registry.npmjs.org/@microsoft/tsdoc-config/-/tsdoc-config-0.13.7.tgz", + "integrity": "sha512-JYYda/56gWeLIvJof4SaFFwVUeRvIJ+7kDIsr0GZQ7IAtk9HXqzCZRfUnZirRN0NwVPMx4IhU0RK20Wx54iefg==", "dev": true, "requires": { - "@microsoft/tsdoc": "0.12.21", - "ajv": "~6.12.3", + "@microsoft/tsdoc": "0.12.22", + "ajv": "~6.12.6", "jju": "~1.4.0", - "resolve": "~1.12.0" + "resolve": "~1.19.0" }, "dependencies": { "@microsoft/tsdoc": { - "version": "0.12.21", - "resolved": "https://registry.npmjs.org/@microsoft/tsdoc/-/tsdoc-0.12.21.tgz", - "integrity": "sha512-j+9OJ0A0buZZaUn6NxeHUVpoa05tY2PgVs7kXJhJQiKRB0G1zQqbJxer3T7jWtzpqQWP89OBDluyIeyTsMk8Sg==", + "version": "0.12.22", + "resolved": "https://registry.npmjs.org/@microsoft/tsdoc/-/tsdoc-0.12.22.tgz", + "integrity": "sha512-CAHpI8CR0SaoIxDqw4BydOW9odti6AWfYYADil6/0h1TjUBNpMTrcbSVo96Kr4aiyGDHsDPmn7VRU+jfN9e7ow==", "dev": true }, + "ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "dev": true, + "requires": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + } + }, "resolve": { - "version": "1.12.3", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.3.tgz", - "integrity": "sha512-hF6+hAPlxjqHWrw4p1rF3Wztbgxd4AjA5VlUzY5zcTb4J8D3JK4/1RjU48pHz2PJWzGVsLB1VWZkvJzhK2CCOA==", + "version": "1.19.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.19.0.tgz", + "integrity": "sha512-rArEXAgsBG4UgRGcynxWIWKFvh/XZCcS8UJdHhwy91zwAvCZIbcs+vAbflgBnNjYMs/i/i+/Ux6IZhML1yPvxg==", "dev": true, "requires": { + "is-core-module": "^2.1.0", "path-parse": "^1.0.6" } } @@ -2337,13 +2350,13 @@ } }, "eslint-plugin-jsdoc": { - "version": "30.3.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-30.3.1.tgz", - "integrity": "sha512-185ARou6Wj/68DP0g9kLLBnvmVwgg6/E/7Z8Z7Dz7Z63WgvRNaSvOLQiXkzIOEwstQfwI9PCuFPh4qBJov907A==", + "version": "30.7.8", + "resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-30.7.8.tgz", + "integrity": "sha512-OWm2AYvXjCl7nRbpcw5xisfSVkpVAyp4lGqL9T+DeK4kaPm6ecnmTc/G5s1PtcRrwbaI8bIWGzwScqv5CdGyxA==", "dev": true, "requires": { "comment-parser": "^0.7.6", - "debug": "^4.1.1", + "debug": "^4.2.0", "jsdoctypeparser": "^9.0.0", "lodash": "^4.17.20", "regextras": "^0.7.1", @@ -2351,6 +2364,15 @@ "spdx-expression-parse": "^3.0.1" }, "dependencies": { + "debug": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", + "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", + "dev": true, + "requires": { + "ms": "2.1.2" + } + }, "semver": { "version": "7.3.2", "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz", @@ -2375,41 +2397,20 @@ "dev": true }, "eslint-plugin-tsdoc": { - "version": "0.2.6", - "resolved": "https://registry.npmjs.org/eslint-plugin-tsdoc/-/eslint-plugin-tsdoc-0.2.6.tgz", - "integrity": "sha512-pU6/VVEOlC85BrUjsqZGGSRy41N+PHfWXokqjpQRWT1LSpBsAEbRpsueNYSFS+93Sx9CFD0511kjLKVySRbLbg==", + "version": "0.2.8", + "resolved": "https://registry.npmjs.org/eslint-plugin-tsdoc/-/eslint-plugin-tsdoc-0.2.8.tgz", + "integrity": "sha512-gLmCo2e89JqPnULZUuqILrxZSrmlynJV441cOpn7rFbHhaa+sKi0Hbs2npAi+ijl/ljSH7GoJyBr7KAFF/JIbA==", "dev": true, "requires": { - "@microsoft/tsdoc": "0.12.20", - "@microsoft/tsdoc-config": "0.13.5" + "@microsoft/tsdoc": "0.12.22", + "@microsoft/tsdoc-config": "0.13.7" }, "dependencies": { "@microsoft/tsdoc": { - "version": "0.12.20", - "resolved": "https://registry.npmjs.org/@microsoft/tsdoc/-/tsdoc-0.12.20.tgz", - "integrity": "sha512-/b13m37QZYPV6nCOiqkFyvlQjlTNvAcQpgFZ6ZKIqtStJxNdqVo/frULubxMUMWi6p9Uo5f4BRlguv5ViFcL0A==", + "version": "0.12.22", + "resolved": "https://registry.npmjs.org/@microsoft/tsdoc/-/tsdoc-0.12.22.tgz", + "integrity": "sha512-CAHpI8CR0SaoIxDqw4BydOW9odti6AWfYYADil6/0h1TjUBNpMTrcbSVo96Kr4aiyGDHsDPmn7VRU+jfN9e7ow==", "dev": true - }, - "@microsoft/tsdoc-config": { - "version": "0.13.5", - "resolved": "https://registry.npmjs.org/@microsoft/tsdoc-config/-/tsdoc-config-0.13.5.tgz", - "integrity": "sha512-KlnIdTRnPSsU9Coz9wzDAkT8JCLopP3ec1sgsgo7trwE6QLMKRpM4hZi2uzVX897SW49Q4f439auGBcQLnZQfA==", - "dev": true, - "requires": { - "@microsoft/tsdoc": "0.12.20", - "ajv": "~6.12.3", - "jju": "~1.4.0", - "resolve": "~1.12.0" - } - }, - "resolve": { - "version": "1.12.3", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.3.tgz", - "integrity": "sha512-hF6+hAPlxjqHWrw4p1rF3Wztbgxd4AjA5VlUzY5zcTb4J8D3JK4/1RjU48pHz2PJWzGVsLB1VWZkvJzhK2CCOA==", - "dev": true, - "requires": { - "path-parse": "^1.0.6" - } } } }, @@ -3702,6 +3703,15 @@ "integrity": "sha512-pyVD9AaGLxtg6srb2Ng6ynWJqkHU9bEM087AKck0w8QwDarTfNcpIYoU8x8Hv2Icm8u6kFJM18Dag8lyqGkviw==", "dev": true }, + "is-core-module": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.2.0.tgz", + "integrity": "sha512-XRAfAdyyY5F5cOXn7hYQDqh2Xmii+DEfIcQGxK/uNwMHhIkPWO0g8msXcbzLe+MpGoR951MlqM/2iIlU4vKDdQ==", + "dev": true, + "requires": { + "has": "^1.0.3" + } + }, "is-date-object": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.2.tgz", @@ -7254,9 +7264,9 @@ } }, "typedoc-plugin-pages": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/typedoc-plugin-pages/-/typedoc-plugin-pages-1.0.1.tgz", - "integrity": "sha512-eOcjcvXZPxyvcpl6U5uP08SqjYz20F7DGZC4kOD1ES2p+2hde6rbF4MPuOjtzcGUOrQeev2HhiaIi+07SiGNsQ==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/typedoc-plugin-pages/-/typedoc-plugin-pages-1.1.0.tgz", + "integrity": "sha512-pmCCp3G2aCeEWb829dcVe9Pl+pI5OsaqfyrkEutcAHZi6IMVfQ5G5NdrkIkFCGhJU/DY04rGrVdynWqnaO5/jg==", "dev": true, "requires": { "compare-versions": "^3.6.0", diff --git a/package.json b/package.json index c73ff6fded..1bb55a3c69 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "devDependencies": { "@istanbuljs/nyc-config-typescript": "^1.0.1", "@microsoft/api-extractor": "^7.12.0", - "@microsoft/tsdoc-config": "^0.13.6", + "@microsoft/tsdoc-config": "^0.13.7", "@types/aws4": "^1.5.1", "@types/bl": "^2.1.0", "@types/bson": "^4.0.2", @@ -51,10 +51,10 @@ "coveralls": "^3.0.11", "eslint": "^6.8.0", "eslint-config-prettier": "^6.11.0", - "eslint-plugin-jsdoc": "^30.3.1", + "eslint-plugin-jsdoc": "^30.7.8", "eslint-plugin-prettier": "^3.1.3", "eslint-plugin-promise": "^4.2.1", - "eslint-plugin-tsdoc": "^0.2.6", + "eslint-plugin-tsdoc": "^0.2.8", "jsdoc": "^3.6.4", "lodash.camelcase": "^4.3.0", "madge": "^3.9.0", @@ -74,7 +74,7 @@ "through2": "^3.0.1", "ts-node": "^9.0.0", "typedoc": "^0.19.2", - "typedoc-plugin-pages": "^1.0.1", + "typedoc-plugin-pages": "^1.1.0", "typescript": "^4.0.5", "typescript-cached-transpile": "^0.0.6", "worker-farm": "^1.5.0", @@ -91,11 +91,12 @@ "scripts": { "build:evergreen": "node .evergreen/generate_evergreen_tasks.js", "build:ts": "rimraf lib && tsc", - "build:dts": "npm run build:ts && api-extractor run --typescript-compiler-folder node_modules/typescript --local && rimraf 'lib/**/*.d.ts*'", + "build:dts": "npm run build:ts && api-extractor run && rimraf 'lib/**/*.d.ts*'", "build:docs": "npm run build:dts && typedoc", "check:bench": "node test/benchmarks/driverBench", "check:coverage": "nyc npm run check:test", - "check:lint": "npm run check:ts && eslint -v && eslint --max-warnings=0 --ext '.js,.ts' src test", + "check:lint": "npm run build:dts && npm run check:eslint", + "check:eslint": "eslint -v && eslint --max-warnings=0 --ext '.js,.ts' src test", "check:test": "mocha --recursive test/functional test/unit", "check:ts": "tsc -v && tsc --noEmit", "check:atlas": "mocha --config \"test/manual/mocharc.json\" test/manual/atlas_connectivity.test.js", diff --git a/src/bulk/common.ts b/src/bulk/common.ts index 44265dfc73..238520a402 100644 --- a/src/bulk/common.ts +++ b/src/bulk/common.ts @@ -25,11 +25,15 @@ import type { Hint } from '../operations/operation'; // Error codes const WRITE_CONCERN_ERROR = 64; -export enum BatchType { - INSERT = 1, - UPDATE = 2, - REMOVE = 3 -} +/** @public */ +export const BatchType = { + INSERT: 1, + UPDATE: 2, + REMOVE: 3 +} as const; + +/** @public */ +export type BatchTypeId = typeof BatchType[keyof typeof BatchType]; /** @public */ export interface InsertOneModel { @@ -115,7 +119,7 @@ export type AnyBulkWriteOperation = | { deleteOne: DeleteOneModel } | { deleteMany: DeleteManyModel }; -/** @internal */ +/** @public */ export interface BulkResult { ok: number; writeErrors: WriteError[]; @@ -133,17 +137,19 @@ export interface BulkResult { /** * Keeps the state of a unordered batch so we can rewrite the results * correctly after command execution + * + * @internal */ export class Batch { originalZeroIndex: number; currentIndex: number; originalIndexes: number[]; - batchType: BatchType; + batchType: BatchTypeId; operations: Document[]; size: number; sizeBytes: number; - constructor(batchType: BatchType, originalZeroIndex: number) { + constructor(batchType: BatchTypeId, originalZeroIndex: number) { this.originalZeroIndex = originalZeroIndex; this.currentIndex = 0; this.originalIndexes = []; @@ -348,7 +354,7 @@ export class WriteConcernError { } } -/** @internal */ +/** @public */ export interface BulkWriteOperationError { index: number; code: number; @@ -704,8 +710,10 @@ export class MongoBulkWriteError extends MongoError { /** * A builder object that is returned from {@link BulkOperationBase#find}. * Is used to build a write operation that involves a query filter. + * + * @public */ -class FindOperators { +export class FindOperators { bulkOperation: BulkOperationBase; /** @@ -855,16 +863,17 @@ class FindOperators { return this.bulkOperation.addToOperationsList(BatchType.REMOVE, document); } - removeOne() { + removeOne(): BulkOperationBase { return this.deleteOne(); } - remove() { + remove(): BulkOperationBase { return this.delete(); } } -interface BulkOperationPrivate { +/** @internal */ +export interface BulkOperationPrivate { bulkResult: BulkResult; currentBatch?: Batch; currentIndex: number; @@ -916,8 +925,10 @@ export interface BulkWriteOptions extends CommandOperationOptions { forceServerObjectId?: boolean; } +/** @public */ export abstract class BulkOperationBase { isOrdered: boolean; + /** @internal */ s: BulkOperationPrivate; operationId?: number; @@ -1263,7 +1274,7 @@ export abstract class BulkOperationBase { } abstract addToOperationsList( - batchType: BatchType, + batchType: BatchTypeId, document: Document | UpdateStatement | DeleteStatement ): this; } @@ -1301,7 +1312,7 @@ function shouldForceServerObjectId(bulkOperation: BulkOperationBase): boolean { return false; } -/** @internal */ +/** @public */ export interface UpdateStatement { /** The query that matches documents to update. */ q: Document; @@ -1368,7 +1379,7 @@ function isUpdateStatement(model: Document): model is UpdateStatement { return 'q' in model; } -/** @internal */ +/** @public */ export interface DeleteStatement { /** The query that matches documents to delete. */ q: Document; diff --git a/src/bulk/ordered.ts b/src/bulk/ordered.ts index ec53223ce4..92d7dc0da6 100644 --- a/src/bulk/ordered.ts +++ b/src/bulk/ordered.ts @@ -5,18 +5,20 @@ import { BatchType, BulkWriteOptions, UpdateStatement, - DeleteStatement + DeleteStatement, + BatchTypeId } from './common'; import type { Document } from '../bson'; import type { Collection } from '../collection'; +/** @public */ export class OrderedBulkOperation extends BulkOperationBase { constructor(collection: Collection, options: BulkWriteOptions) { super(collection, options, true); } addToOperationsList( - batchType: BatchType, + batchType: BatchTypeId, document: Document | UpdateStatement | DeleteStatement ): this { // Get the bsonSize diff --git a/src/bulk/unordered.ts b/src/bulk/unordered.ts index 1d7b4a97dc..469bdbb0c3 100644 --- a/src/bulk/unordered.ts +++ b/src/bulk/unordered.ts @@ -6,12 +6,14 @@ import { BulkWriteOptions, UpdateStatement, DeleteStatement, - BulkWriteResult + BulkWriteResult, + BatchTypeId } from './common'; import type { Callback } from '../utils'; import type { Document } from '../bson'; import type { Collection } from '../collection'; +/** @public */ export class UnorderedBulkOperation extends BulkOperationBase { constructor(collection: Collection, options: BulkWriteOptions) { super(collection, options, false); @@ -26,7 +28,7 @@ export class UnorderedBulkOperation extends BulkOperationBase { } addToOperationsList( - batchType: BatchType, + batchType: BatchTypeId, document: Document | UpdateStatement | DeleteStatement ): this { // Get the bsonSize diff --git a/src/change_stream.ts b/src/change_stream.ts index b2532845b6..e005505b92 100644 --- a/src/change_stream.ts +++ b/src/change_stream.ts @@ -65,7 +65,7 @@ export interface ResumeOptions { export type ResumeToken = unknown; /** - * Represents a specific point in time on a server. Can be retrieved by using {@link Db.command} + * Represents a specific point in time on a server. Can be retrieved by using {@link Db#command} * @public * @remarks * See {@link https://docs.mongodb.com/manual/reference/method/db.runCommand/#response| Run Command Response} @@ -180,6 +180,7 @@ export class ChangeStream extends EventEmitter { parent: MongoClient | Db | Collection; namespace: MongoDBNamespace; type: symbol; + /** @internal */ cursor?: ChangeStreamCursor; streamOptions?: CursorStreamOptions; [kResumeQueue]: Denque; @@ -206,6 +207,8 @@ export class ChangeStream extends EventEmitter { static readonly RESUME_TOKEN_CHANGED = 'resumeTokenChanged' as const; /** + * @internal + * * @param parent - The parent object that created this change stream * @param pipeline - An array of {@link https://docs.mongodb.com/manual/reference/operator/aggregation-pipeline/|aggregation pipeline stages} through which to pass change stream documents */ @@ -332,7 +335,7 @@ export class ChangeStream extends EventEmitter { } } -/** @public */ +/** @internal */ export interface ChangeStreamCursorOptions extends AbstractCursorOptions { startAtOperationTime?: OperationTime; resumeAfter?: ResumeToken; diff --git a/src/cmap/connection.ts b/src/cmap/connection.ts index fe7dbdfbed..1af62ab77f 100644 --- a/src/cmap/connection.ts +++ b/src/cmap/connection.ts @@ -83,14 +83,23 @@ export class Connection extends EventEmitter { closed: boolean; destroyed: boolean; lastIsMasterMS?: number; + /** @internal */ [kDescription]: StreamDescription; + /** @internal */ [kGeneration]: number; + /** @internal */ [kLastUseTime]: number; + /** @internal */ [kAutoEncrypter]?: unknown; + /** @internal */ [kQueue]: Map; + /** @internal */ [kMessageStream]: MessageStream; + /** @internal */ [kStream]: Stream; + /** @internal */ [kIsMaster]: Document; + /** @internal */ [kClusterTime]: Document; /** @event */ @@ -242,7 +251,9 @@ export class Connection extends EventEmitter { } // Wire protocol methods + /** @internal */ command(ns: string, cmd: Document, callback: Callback): void; + /** @internal */ command(ns: string, cmd: Document, options: CommandOptions, callback: Callback): void; command( ns: string, @@ -253,34 +264,44 @@ export class Connection extends EventEmitter { wp.command(makeServerTrampoline(this), ns, cmd, options as CommandOptions, callback); } + /** @internal */ query(ns: MongoDBNamespace, cmd: Document, options: QueryOptions, callback: Callback): void { wp.query(makeServerTrampoline(this), ns, cmd, options, callback); } + /** @internal */ getMore(ns: string, cursorId: Long, options: GetMoreOptions, callback: Callback): void { wp.getMore(makeServerTrampoline(this), ns, cursorId, options, callback); } + /** @internal */ killCursors(ns: string, cursorIds: Long[], options: CommandOptions, callback: Callback): void { wp.killCursors(makeServerTrampoline(this), ns, cursorIds, options, callback); } + /** @internal */ insert(ns: string, ops: Document[], options: InsertOptions, callback: Callback): void { wp.insert(makeServerTrampoline(this), ns, ops, options, callback); } + /** @internal */ update(ns: string, ops: Document[], options: UpdateOptions, callback: Callback): void { wp.update(makeServerTrampoline(this), ns, ops, options, callback); } + /** @internal */ remove(ns: string, ops: Document[], options: RemoveOptions, callback: Callback): void { wp.remove(makeServerTrampoline(this), ns, ops, options, callback); } } -/// This lets us emulate a legacy `Server` instance so we can work with the existing wire -/// protocol methods. Eventually, the operation executor will return a `Connection` to execute -/// against. +/** + * This lets us emulate a legacy `Server` instance so we can work with the existing wire + * protocol methods. Eventually, the operation executor will return a `Connection` to execute + * against. + * @internal + * @deprecated Remove (NODE-2745) + */ function makeServerTrampoline(connection: Connection): Server { return ({ description: connection.description, diff --git a/src/cmap/connection_pool.ts b/src/cmap/connection_pool.ts index 6289017706..39ba7aaf07 100644 --- a/src/cmap/connection_pool.ts +++ b/src/cmap/connection_pool.ts @@ -127,17 +127,6 @@ export interface CloseOptions { force?: boolean; } -// NOTE: to be removed as part of NODE-2745 -/** @public */ -export interface ConnectionPool { - isConnected(): boolean; - write( - message: any, - commandOptions: CommandOptions, - callback: (err: MongoError, ...args: Document[]) => void - ): void; -} - /** * A pool of connections which dynamically resizes, and emit events related to pool activity * @public @@ -145,15 +134,27 @@ export interface ConnectionPool { export class ConnectionPool extends EventEmitter { closed: boolean; options: Readonly; + /** @internal */ [kLogger]: Logger; + /** @internal */ [kConnections]: Denque; - /** An integer expressing how many total connections are permitted */ + /** + * An integer expressing how many total connections are permitted + * @internal + */ [kPermits]: number; + /** @internal */ [kMinPoolSizeTimer]?: NodeJS.Timeout; - /** An integer representing the SDAM generation of the pool */ + /** + * An integer representing the SDAM generation of the pool + * @internal + */ [kGeneration]: number; + /** @internal */ [kConnectionCounter]: Generator; + /** @internal */ [kCancellationToken]: EventEmitter; + /** @internal */ [kWaitQueue]: Denque; /** @@ -431,6 +432,33 @@ 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) { diff --git a/src/cmap/wire_protocol/command.ts b/src/cmap/wire_protocol/command.ts index a165cba9f3..75da460800 100644 --- a/src/cmap/wire_protocol/command.ts +++ b/src/cmap/wire_protocol/command.ts @@ -11,7 +11,7 @@ import type { ReadPreferenceLike } from '../../read_preference'; import type { WriteConcernOptions, WriteConcern, W } from '../../write_concern'; import type { WriteCommandOptions } from './write_command'; -/** @internal */ +/** @public */ export interface CommandOptions extends BSONSerializeOptions { command?: boolean; slaveOk?: boolean; diff --git a/src/collection.ts b/src/collection.ts index c305fa28cd..509cb09cb3 100644 --- a/src/collection.ts +++ b/src/collection.ts @@ -90,7 +90,7 @@ import { FindCursor } from './cursor/find_cursor'; /** @public */ export interface Collection { - /** @deprecated Use {@link Collection.dropIndexes#Class} instead */ + /** @deprecated Use {@link Collection#dropIndexes} instead */ dropAllIndexes(): void; removeMany( filter: Document, @@ -754,7 +754,7 @@ export class Collection implements OperationParent { * MongoDB 2.6 or higher. Earlier version of MongoDB will throw a command not supported * error. * - * **Note**: Unlike {@link (Collection:class).createIndex| createIndex}, this function takes in raw index specifications. + * **Note**: Unlike {@link Collection#createIndex| createIndex}, this function takes in raw index specifications. * Index specifications are defined {@link http://docs.mongodb.org/manual/reference/command/createIndexes/| here}. * * @param indexSpecs - An array of index specifications to be created @@ -948,8 +948,8 @@ export class Collection implements OperationParent { /** * Gets the number of documents matching the filter. - * For a fast count of the total documents in a collection see {@link Collection.estimatedDocumentCount| estimatedDocumentCount}. - * **Note**: When migrating from {@link Collection.count| count} to {@link Collection.countDocuments| countDocuments} + * For a fast count of the total documents in a collection see {@link Collection#estimatedDocumentCount| estimatedDocumentCount}. + * **Note**: When migrating from {@link Collection#count| count} to {@link Collection#countDocuments| countDocuments} * the following query operators must be replaced: * * | Operator | Replacement | @@ -1420,10 +1420,10 @@ export class Collection implements OperationParent { * An estimated count of matching documents in the db to a query. * * **NOTE:** This method has been deprecated, since it does not provide an accurate count of the documents - * in a collection. To obtain an accurate count of documents in the collection, use {@link Collection.countDocuments| countDocuments}. - * To obtain an estimated count of all documents in the collection, use {@link Collection.estimatedDocumentCount| estimatedDocumentCount}. + * in a collection. To obtain an accurate count of documents in the collection, use {@link Collection#countDocuments| countDocuments}. + * To obtain an estimated count of all documents in the collection, use {@link Collection#estimatedDocumentCount| estimatedDocumentCount}. * - * @deprecated use {@link Collection.countDocuments| countDocuments} or {@link Collection.estimatedDocumentCount| estimatedDocumentCount} instead + * @deprecated use {@link Collection#countDocuments| countDocuments} or {@link Collection#estimatedDocumentCount| estimatedDocumentCount} instead * * @param query - The query for the count. * @param options - Optional settings for the command diff --git a/src/cursor/abstract_cursor.ts b/src/cursor/abstract_cursor.ts index d24911d013..b8d800cfa6 100644 --- a/src/cursor/abstract_cursor.ts +++ b/src/cursor/abstract_cursor.ts @@ -22,7 +22,7 @@ const kInitialized = Symbol('initialized'); const kClosed = Symbol('closed'); const kKilled = Symbol('killed'); -/** @internal */ +/** @public */ export const CURSOR_FLAGS = [ 'tailable', 'oplogReplay', @@ -47,7 +47,7 @@ export interface CursorStreamOptions { /** @public */ export type CursorFlag = typeof CURSOR_FLAGS[number]; -/** @internal */ +/** @public */ export interface AbstractCursorOptions extends BSONSerializeOptions { session?: ClientSession; readPreference?: ReadPreferenceLike; @@ -72,18 +72,29 @@ export type InternalAbstractCursorOptions = Omit Document; + /** @internal */ [kInitialized]: boolean; + /** @internal */ [kClosed]: boolean; + /** @internal */ [kKilled]: boolean; + /** @internal */ [kOptions]: InternalAbstractCursorOptions; /** @event */ @@ -540,13 +551,13 @@ export abstract class AbstractCursor extends EventEmitter { */ abstract clone(): AbstractCursor; - /* @internal */ + /** @internal */ abstract _initialize( session: ClientSession | undefined, callback: Callback ): void; - /* @internal */ + /** @internal */ _getMore(batchSize: number, callback: Callback): void { const cursorId = this[kId]; const cursorNs = this[kNamespace]; diff --git a/src/index.ts b/src/index.ts index 58e38af436..0bf40949e8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -144,6 +144,7 @@ export type { RemoveOptions as WireRemoveOptions } from './cmap/wire_protocol/index'; export type { CollationOptions, WriteCommandOptions } from './cmap/wire_protocol/write_command'; +export type { QueryOptions } from './cmap/wire_protocol/query'; export type { CollectionPrivate, CollectionOptions } from './collection'; export type { AggregationCursorOptions } from './cursor/aggregation_cursor'; export type { @@ -179,7 +180,8 @@ export type { MongoURIOptions, LogLevel, Auth, - DriverInfo + DriverInfo, + MongoOptions } from './mongo_client'; export type { AddUserOptions } from './operations/add_user'; export type { @@ -285,5 +287,23 @@ export type { WithTransactionCallback } from './sessions'; export type { TransactionOptions, Transaction, TxnState } from './transactions'; -export type { Callback, ClientMetadata, ClientMetadataOptions } from './utils'; +export type { + Callback, + ClientMetadata, + ClientMetadataOptions, + MongoDBNamespace, + InterruptableAsyncInterval +} from './utils'; export type { WriteConcern, W, WriteConcernOptions } from './write_concern'; +export type { ExecutionResult } from './operations/execute_operation'; +export type { InternalAbstractCursorOptions } from './cursor/abstract_cursor'; +export type { + BulkOperationBase, + BulkOperationPrivate, + BatchType, + BatchTypeId, + FindOperators, + Batch +} from './bulk/common'; +export type { OrderedBulkOperation } from './bulk/ordered'; +export type { UnorderedBulkOperation } from './bulk/unordered'; diff --git a/src/operations/command.ts b/src/operations/command.ts index bf1b6462c0..d8abf4ee41 100644 --- a/src/operations/command.ts +++ b/src/operations/command.ts @@ -37,7 +37,7 @@ export interface CommandOperationOptions noResponse?: boolean; } -/** @internal */ +/** @public */ export interface OperationParent { s: { namespace: MongoDBNamespace }; readConcern?: ReadConcern; diff --git a/src/operations/common_functions.ts b/src/operations/common_functions.ts index 65dd379dee..d42bb7b321 100644 --- a/src/operations/common_functions.ts +++ b/src/operations/common_functions.ts @@ -16,7 +16,7 @@ import type { UpdateOptions } from './update'; import type { WriteCommandOptions } from '../cmap/wire_protocol/write_command'; import type { DeleteOptions } from './delete'; -/** @internal */ +/** @public */ export interface IndexInformationOptions { full?: boolean; readPreference?: ReadPreference; diff --git a/src/operations/execute_operation.ts b/src/operations/execute_operation.ts index 02c99c6772..e9d70a8745 100644 --- a/src/operations/execute_operation.ts +++ b/src/operations/execute_operation.ts @@ -22,7 +22,7 @@ type OptionsFromOperation = TOperation extends OperationBase): void { const operation = new ListCollectionsOperation(this.parent, this.filter, { ...this.cursorOptions, diff --git a/src/operations/operation.ts b/src/operations/operation.ts index b4a18859ae..69bbe1ecef 100644 --- a/src/operations/operation.ts +++ b/src/operations/operation.ts @@ -18,7 +18,7 @@ export interface OperationConstructor extends Function { aspects?: Set; } -/** @internal */ +/** @public */ export interface OperationOptions extends BSONSerializeOptions { /** Specify ClientSession for this command */ session?: ClientSession; diff --git a/src/sdam/server.ts b/src/sdam/server.ts index 8e3f1799b2..caa29a9c97 100644 --- a/src/sdam/server.ts +++ b/src/sdam/server.ts @@ -242,8 +242,12 @@ export class Server extends EventEmitter { this[kMonitor].requestCheck(); } - /** Execute a command */ + /** + * Execute a command + * @internal + */ command(ns: string, cmd: Document, callback: Callback): void; + /** @internal */ command(ns: string, cmd: Document, options: CommandOptions, callback: Callback): void; command( ns: string, @@ -301,7 +305,10 @@ export class Server extends EventEmitter { }, callback); } - /** Execute a query against the server */ + /** + * Execute a query against the server + * @internal + */ query(ns: MongoDBNamespace, cmd: Document, options: QueryOptions, callback: Callback): void { if (this.s.state === STATE_CLOSING || this.s.state === STATE_CLOSED) { callback(new MongoError('server is closed')); @@ -318,7 +325,10 @@ export class Server extends EventEmitter { }, callback); } - /** Execute a `getMore` against the server */ + /** + * Execute a `getMore` against the server + * @internal + */ getMore(ns: string, cursorId: Long, options: GetMoreOptions, callback: Callback): void { if (this.s.state === STATE_CLOSING || this.s.state === STATE_CLOSED) { callback(new MongoError('server is closed')); @@ -340,7 +350,10 @@ export class Server extends EventEmitter { }, callback); } - /** Execute a `killCursors` command against the server */ + /** + * Execute a `killCursors` command against the server + * @internal + */ killCursors(ns: string, cursorIds: Long[], options: CommandOptions, callback?: Callback): void { if (this.s.state === STATE_CLOSING || this.s.state === STATE_CLOSED) { if (typeof callback === 'function') { @@ -367,6 +380,7 @@ export class Server extends EventEmitter { /** * Insert one or more documents + * @internal * * @param ns - The MongoDB fully qualified namespace (ex: db1.collection1) * @param ops - An array of documents to insert @@ -377,6 +391,7 @@ export class Server extends EventEmitter { /** * Perform one or more update operations + * @internal * * @param ns - The MongoDB fully qualified namespace (ex: db1.collection1) * @param ops - An array of updates @@ -387,6 +402,7 @@ export class Server extends EventEmitter { /** * Perform one or more remove operations + * @internal * * @param ns - The MongoDB fully qualified namespace (ex: db1.collection1) * @param ops - An array of removes diff --git a/src/sdam/server_description.ts b/src/sdam/server_description.ts index 00d18c6e90..3c5d275ad8 100644 --- a/src/sdam/server_description.ts +++ b/src/sdam/server_description.ts @@ -17,7 +17,7 @@ const DATA_BEARING_SERVER_TYPES = new Set([ ServerType.Standalone ]); -/** @internal */ +/** @public */ export interface TopologyVersion { processId: ObjectId; counter: Long; diff --git a/src/sdam/server_selection.ts b/src/sdam/server_selection.ts index 7589eabe08..c80660e880 100644 --- a/src/sdam/server_selection.ts +++ b/src/sdam/server_selection.ts @@ -8,7 +8,7 @@ import type { ServerDescription, TagSet } from './server_description'; const IDLE_WRITE_PERIOD = 10000; const SMALLEST_MAX_STALENESS_SECONDS = 90; -/** @internal */ +/** @public */ export type ServerSelector = ( topologyDescription: TopologyDescription, servers: ServerDescription[] diff --git a/src/sdam/srv_polling.ts b/src/sdam/srv_polling.ts index 072b45fb43..e653b5affb 100644 --- a/src/sdam/srv_polling.ts +++ b/src/sdam/srv_polling.ts @@ -32,13 +32,13 @@ export class SrvPollingEvent { } } -/** @internal */ +/** @public */ export interface SrvPollerOptions extends LoggerOptions { srvHost: string; heartbeatFrequencyMS: number; } -/** @internal */ +/** @public */ export class SrvPoller extends EventEmitter { srvHost: string; rescanSrvIntervalMS: number; diff --git a/src/sessions.ts b/src/sessions.ts index 5c90b35d35..6ecbbd273b 100644 --- a/src/sessions.ts +++ b/src/sessions.ts @@ -63,6 +63,7 @@ const kServerSession = Symbol('serverSession'); */ class ClientSession extends EventEmitter { topology: Topology; + /** @internal */ sessionPool: ServerSessionPool; hasEnded: boolean; clientOptions?: MongoClientOptions; @@ -77,7 +78,7 @@ class ClientSession extends EventEmitter { /** * Create a client session. - * + * @internal * @param topology - The current client's topology (Internal Class) * @param sessionPool - The server session pool (Internal Class) * @param options - Optional settings @@ -585,7 +586,7 @@ function supportsRecoveryToken(session: ClientSession) { return !!topology.s.options.useRecoveryToken; } -/** @internal */ +/** @public */ export type ServerSessionId = { id: Binary }; /** diff --git a/src/transactions.ts b/src/transactions.ts index 794edbd8f8..30798b2613 100644 --- a/src/transactions.ts +++ b/src/transactions.ts @@ -62,6 +62,7 @@ export interface TransactionOptions extends CommandOperationOptions { * A class maintaining state related to a server transaction. Internal Only */ export class Transaction { + /** @internal */ state: TxnState; options: TransactionOptions; _pinnedServer?: Server; @@ -123,7 +124,7 @@ export class Transaction { /** * Transition the transaction in the state machine - * + * @internal * @param nextState - The new state to transition to */ transition(nextState: TxnState): void {