From 9d67c5d24fb5019541ff17c74fc859bdd33f7a0a Mon Sep 17 00:00:00 2001 From: Neal Beeken Date: Tue, 1 Dec 2020 11:58:33 -0500 Subject: [PATCH] fix: add all accessor tags to exported symbols The mongodb.d.ts now only includes the public API. NODE-2783 --- api-extractor.json | 17 +---- package-lock.json | 106 +++++++++++++++------------- package.json | 8 +-- src/bulk/common.ts | 8 +-- src/change_stream.ts | 7 +- src/cmap/connection.ts | 27 ++++++- src/cmap/connection_pool.ts | 54 ++++++++++---- src/cmap/wire_protocol/command.ts | 2 +- src/cmap/wire_protocol/query.ts | 2 +- src/collection.ts | 14 ++-- src/cursor/abstract_cursor.ts | 21 ++++-- src/index.ts | 13 +++- src/operations/command.ts | 2 +- src/operations/common_functions.ts | 2 +- src/operations/execute_operation.ts | 2 +- src/operations/indexes.ts | 2 +- src/operations/list_collections.ts | 1 + src/operations/operation.ts | 2 +- src/sdam/server.ts | 24 +++++-- src/sdam/server_description.ts | 2 +- src/sdam/server_selection.ts | 2 +- src/sdam/srv_polling.ts | 4 +- src/sessions.ts | 5 +- src/transactions.ts | 3 +- tsdoc.json | 1 + 25 files changed, 211 insertions(+), 120 deletions(-) diff --git a/api-extractor.json b/api-extractor.json index aa239a78eef..a76c182dda0 100644 --- a/api-extractor.json +++ b/api-extractor.json @@ -9,7 +9,8 @@ }, "dtsRollup": { "enabled": true, - "untrimmedFilePath": "/.d.ts" + "untrimmedFilePath": "/-internal.d.ts", + "publicTrimmedFilePath": "/.d.ts" }, "tsdocMetadata": { "enabled": false @@ -23,23 +24,11 @@ }, "extractorMessageReporting": { "default": { - "logLevel": "warning" + "logLevel": "error" }, "ae-internal-missing-underscore": { "logLevel": "none", "addToApiReportFile": false - }, - "ae-missing-release-tag": { - "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 8f5b9d46658..27b872a271a 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 c73ff6fded5..d93f7b7b809 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", diff --git a/src/bulk/common.ts b/src/bulk/common.ts index 2f68955a739..890a1034d55 100644 --- a/src/bulk/common.ts +++ b/src/bulk/common.ts @@ -115,7 +115,7 @@ export type AnyBulkWriteOperation = | { deleteOne: DeleteOneModel } | { deleteMany: DeleteManyModel }; -/** @internal */ +/** @public */ export interface BulkResult { ok: number; writeErrors: WriteError[]; @@ -348,7 +348,7 @@ export class WriteConcernError { } } -/** @internal */ +/** @public */ export interface BulkWriteOperationError { index: number; code: number; @@ -1301,7 +1301,7 @@ function shouldForceServerObjectId(bulkOperation: BulkOperationBase): boolean { return false; } -/** @internal */ +/** @public */ export interface UpdateStatement { /** The query that matches documents to update. */ q: Document; @@ -1368,7 +1368,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/change_stream.ts b/src/change_stream.ts index 62bb3285c42..cad041e4abe 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 e9517896a0d..f3467a8fff8 100644 --- a/src/cmap/connection.ts +++ b/src/cmap/connection.ts @@ -76,14 +76,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 */ @@ -235,7 +244,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, @@ -246,34 +257,44 @@ export class Connection extends EventEmitter { wp.command(makeServerTrampoline(this), ns, cmd, options as CommandOptions, callback); } + /** @internal */ query(ns: string, cmd: Document, options: FindOptions, 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 6289017706c..39ba7aaf079 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 a165cba9f3b..75da460800a 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/cmap/wire_protocol/query.ts b/src/cmap/wire_protocol/query.ts index af84db347a9..7df1c2d4629 100644 --- a/src/cmap/wire_protocol/query.ts +++ b/src/cmap/wire_protocol/query.ts @@ -9,7 +9,7 @@ import type { ReadPreferenceLike } from '../../read_preference'; import type { FindOptions } from '../../operations/find'; import { Explain } from '../../explain'; -/** @internal */ +/** @public */ export interface QueryOptions extends CommandOptions { readPreference?: ReadPreferenceLike; } diff --git a/src/collection.ts b/src/collection.ts index d54da1b792a..7e4506b6a8b 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 d5cc560cb1d..32cc2ab56ff 100644 --- a/src/cursor/abstract_cursor.ts +++ b/src/cursor/abstract_cursor.ts @@ -21,7 +21,7 @@ const kInitialized = Symbol('initialized'); const kClosed = Symbol('closed'); const kKilled = Symbol('killed'); -/** @internal */ +/** @public */ export const CURSOR_FLAGS = [ 'tailable', 'oplogReplay', @@ -46,7 +46,7 @@ export interface CursorStreamOptions { /** @public */ export type CursorFlag = typeof CURSOR_FLAGS[number]; -/** @internal */ +/** @public */ export interface AbstractCursorOptions extends BSONSerializeOptions { session?: ClientSession; readPreference?: ReadPreferenceLike; @@ -69,18 +69,29 @@ export type InternalAbstractCursorOptions = Omit Document; + /** @internal */ [kInitialized]: boolean; + /** @internal */ [kClosed]: boolean; + /** @internal */ [kKilled]: boolean; + /** @internal */ [kOptions]: InternalAbstractCursorOptions; /** @event */ @@ -481,13 +492,13 @@ export abstract class AbstractCursor extends EventEmitter { return this; } - /* @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 a953cebe81d..415c6795e0d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -180,7 +180,8 @@ export type { MongoURIOptions, LogLevel, Auth, - DriverInfo + DriverInfo, + MongoOptions } from './mongo_client'; export type { AddUserOptions } from './operations/add_user'; export type { @@ -286,5 +287,13 @@ 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'; diff --git a/src/operations/command.ts b/src/operations/command.ts index bf1b6462c04..d8abf4ee415 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 65dd379deee..d42bb7b321b 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 02c99c67722..e9d70a87459 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 b4a18859aea..69bbe1ecef7 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 5e63ca351b1..f32ba52e379 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: string, cmd: Document, options: FindOptions, 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 00d18c6e90c..3c5d275ad8a 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 7589eabe082..c80660e880e 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 072b45fb436..e653b5affb0 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 5c90b35d357..6ecbbd273b6 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 794edbd8f83..30798b2613f 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 { diff --git a/tsdoc.json b/tsdoc.json index 81ce5c1da85..bef5e26a92c 100644 --- a/tsdoc.json +++ b/tsdoc.json @@ -1,5 +1,6 @@ { "$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json", + // Correct url: https://developer.microsoft.com/en-us/json-schemas/tsdoc/v0/tsdoc.schema.json "tagDefinitions": [ { "syntaxKind": "block",