Skip to content

chore: fix symbols & public / internal one-liners #2602

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 2 commits into from
Nov 2, 2020
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
5 changes: 4 additions & 1 deletion src/admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ export class Admin {
/** @internal */
s: AdminPrivate;

/** @internal Create a new Admin instance (INTERNAL TYPE, do not instantiate directly) */
/**
* Create a new Admin instance
* @internal
*/
constructor(db: Db) {
this.s = { db };
}
Expand Down
6 changes: 5 additions & 1 deletion src/bson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ export interface Document {

import type { SerializeOptions } from 'bson';

/** @public BSON Serialization options. TODO: Remove me when types from BSON are updated */
// TODO: Remove me when types from BSON are updated
/**
* BSON Serialization options.
* @public
*/
export interface BSONSerializeOptions extends SerializeOptions {
/** Return document results as raw BSON buffers */
fieldsAsRaw?: { [key: string]: boolean };
Expand Down
6 changes: 5 additions & 1 deletion src/change_stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ interface UpdateDescription {
removedFields: string[];
}

/** @internal */
export class ChangeStreamStream extends CursorStream {
constructor(cursor: ChangeStreamCursor) {
super(cursor);
Expand Down Expand Up @@ -465,7 +466,10 @@ export class ChangeStreamCursor extends Cursor<AggregateOperation, ChangeStreamC
}
}

/** @internal Create a new change stream cursor based on self's configuration */
/**
* Create a new change stream cursor based on self's configuration
* @internal
*/
function createChangeStreamCursor(
self: ChangeStream,
options: ChangeStreamOptions
Expand Down
8 changes: 6 additions & 2 deletions src/cmap/connection_pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ export interface CloseOptions {
force?: boolean;
}

/** @public NOTE: to be removed as part of NODE-2745 */
// NOTE: to be removed as part of NODE-2745
/** @public */
export interface ConnectionPool {
isConnected(): boolean;
write(
Expand All @@ -137,7 +138,10 @@ export interface ConnectionPool {
): void;
}

/** @public A pool of connections which dynamically resizes, and emit events related to pool activity */
/**
* A pool of connections which dynamically resizes, and emit events related to pool activity
* @public
*/
export class ConnectionPool extends EventEmitter {
closed: boolean;
options: Readonly<ConnectionPoolOptions>;
Expand Down
5 changes: 4 additions & 1 deletion src/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,10 @@ export class Collection implements OperationParent {
/** @internal */
s: CollectionPrivate;

/** @internal Create a new Collection instance (INTERNAL TYPE, do not instantiate directly) */
/**
* Create a new Collection instance
* @internal
*/
constructor(db: Db, name: string, options?: CollectionOptions) {
checkCollectionName(name);
emitDeprecatedOptionWarning(options, ['promiseLibrary']);
Expand Down
17 changes: 13 additions & 4 deletions src/cursor/cursor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ import type { ClientSession } from '../sessions';

const kCursor = Symbol('cursor');

/** @public Flags allowed for cursor */
/**
* Flags allowed for cursor
* @public
*/
export const FLAGS = [
'tailable',
'oplogReplay',
Expand All @@ -47,7 +50,7 @@ export interface DocumentTransforms {
}

/** @internal */
interface CursorPrivate {
export interface CursorPrivate {
/** Transforms functions */
transforms?: DocumentTransforms;
numberOfRetries: number;
Expand All @@ -60,7 +63,10 @@ interface CursorPrivate {
readConcern?: ReadConcern;
}

/** @public Possible states for a cursor */
/**
* Possible states for a cursor
* @public
*/
export enum CursorState {
INIT = 0,
OPEN = 1,
Expand Down Expand Up @@ -1647,7 +1653,10 @@ export function each(cursor: Cursor, callback: EachCallback): void {
}
}

/** @internal Trampoline emptying the number of retrieved items without incurring a nextTick operation */
/**
* Trampoline emptying the number of retrieved items without incurring a nextTick operation
* @internal
*/
function loop(cursor: Cursor, callback: Callback) {
// No more items we are done
if (cursor.bufferedCount() === 0) return;
Expand Down
5 changes: 4 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export type {
} from './bulk/common';
export type {
ChangeStream,
ChangeStreamStream,
ChangeStreamOptions,
ChangeStreamCursor,
ResumeToken,
Expand Down Expand Up @@ -150,12 +151,14 @@ export type {
CursorCloseOptions,
DocumentTransforms,
CursorStreamOptions,
CursorStream,
CursorState,
CursorOptions,
FIELDS as CURSOR_FIELDS,
FLAGS as CURSOR_FLAGS,
CursorFlag,
EachCallback
EachCallback,
CursorPrivate
} from './cursor/cursor';
export type { DbPrivate, DbOptions } from './db';
export type { AutoEncryptionOptions, AutoEncryptionLoggerLevels, AutoEncrypter } from './deps';
Expand Down
5 changes: 4 additions & 1 deletion src/operations/distinct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import type { Collection } from '../collection';
/** @public */
export type DistinctOptions = CommandOperationOptions;

/** @internal Return a list of distinct values for the given key across a collection. */
/**
* Return a list of distinct values for the given key across a collection.
* @internal
*/
export class DistinctOperation extends CommandOperation<DistinctOptions, Document[]> {
collection: Collection;
/** Field of the document to find distinct values for. */
Expand Down
5 changes: 4 additions & 1 deletion src/operations/map_reduce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ interface MapReduceStats {
timing?: number;
}

/** @internal Run Map Reduce across a collection. Be aware that the inline option for out will return an array of results not a collection. */
/**
* Run Map Reduce across a collection. Be aware that the inline option for out will return an array of results not a collection.
* @internal
*/
export class MapReduceOperation extends CommandOperation<MapReduceOptions, Document | Document[]> {
collection: Collection;
/** The mapping function. */
Expand Down
5 changes: 4 additions & 1 deletion src/operations/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ export interface CollStatsOptions extends CommandOperationOptions {
scale?: number;
}

/** @internal Get all the collection statistics. */
/**
* Get all the collection statistics.
* @internal
*/
export class CollStatsOperation extends CommandOperation<CollStatsOptions, Document> {
collectionName: string;

Expand Down
10 changes: 8 additions & 2 deletions src/sdam/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ export const STATE_CLOSED = 'closed';
export const STATE_CONNECTING = 'connecting';
export const STATE_CONNECTED = 'connected';

/** @public An enumeration of topology types we know about */
/**
* An enumeration of topology types we know about
* @public
*/
export enum TopologyType {
Single = 'Single',
ReplicaSetNoPrimary = 'ReplicaSetNoPrimary',
Expand All @@ -17,7 +20,10 @@ export enum TopologyType {
Unknown = 'Unknown'
}

/** @public An enumeration of server types we know about */
/**
* An enumeration of server types we know about
* @public
*/
export enum ServerType {
Standalone = 'Standalone',
Mongos = 'Mongos',
Expand Down
5 changes: 4 additions & 1 deletion src/sdam/topology_description.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ export interface TopologyDescriptionOptions {
localThresholdMS?: number;
}

/** @public Representation of a deployment of servers */
/**
* Representation of a deployment of servers
* @public
*/
export class TopologyDescription {
type: TopologyType;
setName?: string;
Expand Down
5 changes: 4 additions & 1 deletion src/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ const stateMachine = {
]
};

/** @public Configuration options for a transaction. */
/**
* Configuration options for a transaction.
* @public
*/
export interface TransactionOptions extends CommandOperationOptions {
/** A default read concern for commands in this transaction */
readConcern?: ReadConcern;
Expand Down
15 changes: 12 additions & 3 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ import { resolve } from 'path';
import type { Document } from './bson';
import type { IndexSpecification, IndexDirection } from './operations/indexes';

/** @public MongoDB Driver style callback */
/**
* MongoDB Driver style callback
* @public
*/
export type Callback<T = any> = (error?: AnyError, result?: T) => void;
/** @public */
export type CallbackWithType<E = AnyError, T0 = any> = (error?: E, result?: T0) => void;
Expand Down Expand Up @@ -668,7 +671,10 @@ export function collectionNamespace(ns: string): string {
return ns.split('.').slice(1).join('.');
}

/** @internal Synchronously Generate a UUIDv4 */
/**
* Synchronously Generate a UUIDv4
* @internal
*/
export function uuidV4(): Buffer {
const result = crypto.randomBytes(16);
result[6] = (result[6] & 0x0f) | 0x40;
Expand Down Expand Up @@ -978,7 +984,10 @@ export interface InterruptableAsyncIntervalOptions {
/** Whether the method should be called immediately when the interval is started */
immediate: boolean;

/* @internal only used for testing unreliable timer environments */
/**
* Only used for testing unreliable timer environments
* @internal
*/
clock: () => number;
}

Expand Down