SERVER-121775: prettier-format .d.ts files (#49701)

GitOrigin-RevId: 09a84b780ed2dde5d3b33f7a78702f232ec89283
This commit is contained in:
Steve McClure 2026-03-17 18:04:00 -04:00 committed by MongoDB Bot
parent 5490094a26
commit 87dede76a6
22 changed files with 586 additions and 414 deletions

View File

@ -5,7 +5,6 @@
.clang-tidy
*.code-workspace
*.d.ts
*.json
*.wxs

2
jstests/global.d.ts vendored
View File

@ -1,3 +1,3 @@
// type declarations for globals
declare function TestData()
declare function TestData();

View File

@ -1,7 +1,7 @@
// type declarations for parallelTester.js
declare class CountDownLatch {
await()
countDown()
getCount()
await();
countDown();
getCount();
}

View File

@ -1,8 +1,8 @@
// type declarations for global.h
declare var buildInfo
declare function gc()
declare function getJSHeapLimitMB()
declare function print()
declare function sleep()
declare function version()
declare var buildInfo;
declare function gc();
declare function getJSHeapLimitMB();
declare function print();
declare function sleep();
declare function version();

View File

@ -1,6 +1,6 @@
// type declarations for bson.h
declare function bsonWoCompare(a, b): number
declare function bsonUnorderedFieldsCompare(a, b): number
declare function bsonBinaryEqual(a, b): number
declare function bsonObjToArray(a, b): number
declare function bsonWoCompare(a, b): number;
declare function bsonUnorderedFieldsCompare(a, b): number;
declare function bsonBinaryEqual(a, b): number;
declare function bsonObjToArray(a, b): number;

View File

@ -1,6 +1,6 @@
// type declarations for numberdecimal.h
declare class NumberDecimal {
toString(): string
toJSON(): string
toString(): string;
toJSON(): string;
}

View File

@ -1,3 +1,3 @@
// type declarations for object.h
declare function bsonsize()
declare function bsonsize();

View File

@ -1,3 +1,3 @@
// type declarations for jsthread.h
declare function _threadInject()
declare function _threadInject();

View File

@ -1,5 +1,5 @@
// type declarations for mongo.h
declare function _forgetReplSet()
declare function load()
declare function quit()
declare function _forgetReplSet();
declare function load();
declare function quit();

View File

@ -1,5 +1,5 @@
// type declarations for resumetoken.h
declare function decodeResumeToken()
declare function eventResumeTokenType()
declare function highWaterMarkResumeTokenType()
declare function decodeResumeToken();
declare function eventResumeTokenType();
declare function highWaterMarkResumeTokenType();

View File

@ -1,4 +1,4 @@
// type declarations for utils.cpp
declare function hex_md5()
declare function tostrictjson()
declare function hex_md5();
declare function tostrictjson();

View File

@ -48,7 +48,14 @@ declare class DBCollection {
* @param options Query options
* @returns Query cursor
*/
find(filter?: object, projection?: object, limit?: number, skip?: number, batchSize?: number, options?: number): DBQuery;
find(
filter?: object,
projection?: object,
limit?: number,
skip?: number,
batchSize?: number,
options?: number,
): DBQuery;
/**
* Find a single document.
@ -60,7 +67,14 @@ declare class DBCollection {
* @param rawData Whether to return raw BSON data
* @returns The matching document or null
*/
findOne(filter?: object, projection?: object, options?: object, readConcern?: object, collation?: object, rawData?: boolean): any;
findOne(
filter?: object,
projection?: object,
options?: object,
readConcern?: object,
collation?: object,
rawData?: boolean,
): any;
/**
* Insert a document or documents.
@ -68,7 +82,10 @@ declare class DBCollection {
* @param options Insert options (ordered, writeConcern, etc.)
* @returns WriteResult or BulkWriteResult
*/
insert(obj: object | object[], options?: object): WriteResult | BulkWriteResult;
insert(
obj: object | object[],
options?: object,
): WriteResult | BulkWriteResult;
/**
* Insert a single document.
@ -94,7 +111,12 @@ declare class DBCollection {
* @param multi If true, update all matching documents
* @returns WriteResult
*/
update(query: object, updateSpec: object, upsert?: boolean, multi?: boolean): WriteResult;
update(
query: object,
updateSpec: object,
upsert?: boolean,
multi?: boolean,
): WriteResult;
/**
* Update a single document.
@ -177,7 +199,11 @@ declare class DBCollection {
* @param options Options including sort, projection, upsert, returnDocument, collation
* @returns The document (before or after replacement depending on returnDocument)
*/
findOneAndReplace(filter: object, replacement: object, options?: object): any;
findOneAndReplace(
filter: object,
replacement: object,
options?: object,
): any;
/**
* Find one document and update it.
@ -236,7 +262,12 @@ declare class DBCollection {
* @param cmdArgs Additional command arguments
* @returns Command result
*/
createIndex(keys: object, options?: object, commitQuorum?: any, cmdArgs?: object): object;
createIndex(
keys: object,
options?: object,
commitQuorum?: any,
cmdArgs?: object,
): object;
/**
* Create multiple indexes.
@ -246,7 +277,12 @@ declare class DBCollection {
* @param cmdArgs Additional command arguments
* @returns Command result
*/
createIndexes(keys: object[], options?: object, commitQuorum?: any, cmdArgs?: object): object;
createIndexes(
keys: object[],
options?: object,
commitQuorum?: any,
cmdArgs?: object,
): object;
/**
* Get all indexes for the collection.

View File

@ -1,20 +1,19 @@
// type declarations for db.js, which extends objects/methods implemented in cpp.
declare class DB {
constructor(mongo: Mongo, name: string);
/**
* Get the Mongo connection object for this database.
* @returns The Mongo connection object
*/
getMongo(): Mongo
getMongo(): Mongo;
/**
* Get the name of this database.
* @returns The database name
*/
getName(): string
getName(): string;
/**
* Dynamic property to produce a DBCollection.
@ -24,42 +23,42 @@ declare class DB {
* let coll1 = db[jsTestName()];
* let coll2 = db.myCollection;
*/
[collectionIndex: string]: DBCollection
[collectionIndex: string]: DBCollection;
/**
* Rotate server certificates, CRLs, and CA files.
* @param message Optional message to log when certificates are rotated
* @returns Command result object
*/
rotateCertificates(message?: string): object
rotateCertificates(message?: string): object;
/**
* Get another database from the same connection.
* @param name Name of the database to retrieve
* @returns The requested database object
*/
getSiblingDB(name: string): DB
getSiblingDB(name: string): DB;
/**
* Get statistics about the database.
* @param opt Scale factor (number) or options object. Scale converts sizes (1024 for KB, 1024*1024 for MB, etc.)
* @returns Database statistics object
*/
stats(opt?: number | object): object
stats(opt?: number | object): object;
/**
* Get a collection from this database.
* @param name Name of the collection
* @returns The collection object
*/
getCollection(name: string): DBCollection
getCollection(name: string): DBCollection;
/**
* Get help text for a specific database command.
* @param name Command name
* @returns Help text for the command
*/
commandHelp(name: string): string
commandHelp(name: string): string;
/**
* Run a database command with read preference applied.
@ -68,7 +67,11 @@ declare class DB {
* @param queryOptions Query options bitmask
* @returns Command result object
*/
runReadCommand(obj: object | string, extra?: object, queryOptions?: number): object
runReadCommand(
obj: object | string,
extra?: object,
queryOptions?: number,
): object;
/**
* Run a database command.
@ -78,10 +81,10 @@ declare class DB {
* @returns Command result object with ok field and command-specific fields
*/
runCommand<Req extends Partial<Commands[keyof Commands]["req"]>>(
command: GenericArguments & Req,
extra?: object,
queryOptions?: number,
): GenericReplyFieldsAnd<GetResponseType<Req>>
command: GenericArguments & Req,
extra?: object,
queryOptions?: number,
): GenericReplyFieldsAnd<GetResponseType<Req>>;
/**
* Run a command against the admin database (switches to admin db).
@ -89,7 +92,7 @@ declare class DB {
* @param extra Additional command options (if obj is a string)
* @returns Command result object
*/
adminCommand(obj: object | string, extra?: object): object
adminCommand(obj: object | string, extra?: object): object;
/**
* Perform a collectionless aggregation on the database.
@ -98,7 +101,7 @@ declare class DB {
* @param aggregateOptions Options like cursor batch size, maxTimeMS, readConcern, etc.
* @returns Aggregation result cursor
*/
aggregate(pipeline: object[], aggregateOptions?: object): object
aggregate(pipeline: object[], aggregateOptions?: object): object;
/**
* Create a new collection in the database.
@ -106,7 +109,7 @@ declare class DB {
* @param opt Options like capped, size, max, storageEngine, validator, etc.
* @returns Command result object with ok field
*/
createCollection(name: string, opt?: object): object
createCollection(name: string, opt?: object): object;
/**
* Create a view based on an aggregation pipeline.
@ -116,27 +119,32 @@ declare class DB {
* @param opt Options like collation
* @returns Command result object with ok field
*/
createView(name: string, viewOn: string, pipeline?: object | object[], opt?: object): object
createView(
name: string,
viewOn: string,
pipeline?: object | object[],
opt?: object,
): object;
/**
* @deprecated Use getProfilingStatus() instead
* Get the current profiling level.
* @returns Profiling level: 0 (off), 1 (slow operations), 2 (all operations), or null on error
*/
getProfilingLevel(): number | null
getProfilingLevel(): number | null;
/**
* Get the profiling status including level and slowms threshold.
* @returns Object with 'was' (level), 'slowms', and other profiling settings
*/
getProfilingStatus(): object
getProfilingStatus(): object;
/**
* Drop (delete) the entire database.
* @param writeConcern Write concern for the operation
* @returns Command result object with ok field
*/
dropDatabase(writeConcern?: object): object
dropDatabase(writeConcern?: object): object;
/**
* Shutdown the MongoDB server (must be run against admin database).
@ -144,17 +152,17 @@ declare class DB {
* @param opts.force Force shutdown even if not connected to a secondary
* @param opts.timeoutSecs Time to wait for secondaries to catch up before forcing
*/
shutdownServer(opts?: { force?: boolean, timeoutSecs?: number }): void
shutdownServer(opts?: {force?: boolean; timeoutSecs?: number}): void;
/**
* Print help text for database methods.
*/
help(): void
help(): void;
/**
* Print statistics for all collections in the database.
* @param scale Scale factor for sizes (e.g., 1024 for KB)
*/
printCollectionStats(scale?: number): void
printCollectionStats(scale?: number): void;
/**
* Set the database profiling level and options.
@ -162,7 +170,7 @@ declare class DB {
* @param options Slowms threshold (number) or options object with slowms and other settings
* @returns Command result object
*/
setProfilingLevel(level: number, options?: number | object): object
setProfilingLevel(level: number, options?: number | object): object;
/**
* @deprecated Server-side JavaScript execution is deprecated
@ -171,7 +179,7 @@ declare class DB {
* @param args Arguments to pass to the function
* @returns Result of the function execution
*/
eval(jsfunction: Function, ...args: any[]): any
eval(jsfunction: Function, ...args: any[]): any;
/**
* @deprecated
@ -179,190 +187,190 @@ declare class DB {
* @param parmsObj Parameters object with key, reduce, initial, etc.
* @returns Aggregation results
*/
groupeval(parmsObj: object): any
groupeval(parmsObj: object): any;
/**
* Force an error for testing purposes.
*/
forceError(): void
forceError(): void;
/**
* Get names of all collections in the database.
* @returns Array of collection name strings
*/
getCollectionNames(): string[]
getCollectionNames(): string[];
/**
* Convert database to JSON string representation.
* @returns The database name
*/
tojson(): string
tojson(): string;
/**
* Convert database to string representation.
* @returns The database name
*/
toString(): string
toString(): string;
/**
* @deprecated Use hello() instead
* Check if this node is the primary in a replica set.
* @returns isMaster command result
*/
isMaster(): object
isMaster(): object;
/**
* Check replica set status and get server topology information.
* @returns hello command result with topology and replica set information
*/
hello(): object
hello(): object;
/**
* Get information about currently executing operations.
* @param arg Pass true to include all operations, or an object to filter results
* @returns Object with 'inprog' array of current operations
*/
currentOp(arg?: boolean | object): object
currentOp(arg?: boolean | object): object;
/**
* Get a cursor for currently executing operations.
* @param arg Pass true to include all operations, or an object to filter results
* @returns Cursor over current operations
*/
currentOpCursor(arg?: boolean | object): DBCommandCursor
currentOpCursor(arg?: boolean | object): DBCommandCursor;
/**
* Kill a running operation.
* @param op Operation ID (number) or connection ID (string) to kill
* @returns Command result object
*/
killOp(op: number | string): object
killOp(op: number | string): object;
/**
* Get replication information for this database.
* @returns Object with replication lag and oplog information
*/
getReplicationInfo(): object
getReplicationInfo(): object;
/**
* Print formatted replication status information to the console.
*/
printReplicationInfo(): void
printReplicationInfo(): void;
/**
* @deprecated Use printSecondaryReplicationInfo() instead
* Print replication information for secondary nodes.
*/
printSlaveReplicationInfo(): void
printSlaveReplicationInfo(): void;
/**
* Print replication information for secondary (non-primary) nodes.
*/
printSecondaryReplicationInfo(): void
printSecondaryReplicationInfo(): void;
/**
* Get detailed server build information.
* @returns Object with version, gitVersion, modules, allocator, javascriptEngine, etc.
*/
serverBuildInfo(): object
serverBuildInfo(): object;
/**
* Get comprehensive server status including metrics and statistics.
* @param options Optional filter for specific sections (e.g., {repl: 1, metrics: 0})
* @returns Large object with server metrics, connections, operations, locks, etc.
*/
serverStatus(options?: object): object
serverStatus(options?: object): object;
/**
* Get information about the host system running MongoDB.
* @returns Object with system info, OS, CPUs, memory, etc.
*/
hostInfo(): object
hostInfo(): object;
/**
* Get the command line options used to start the server.
* @returns Object with parsed and argv arrays
*/
serverCmdLineOpts(): object
serverCmdLineOpts(): object;
/**
* Get the MongoDB server version string.
* @returns Version string (e.g., "7.0.0")
*/
version(): string
version(): string;
/**
* Get the server process architecture.
* @returns 32 or 64 (bits)
*/
serverBits(): number
serverBits(): number;
/**
* List all available database commands with descriptions.
* @returns Object mapping command names to their descriptions
*/
listCommands(): object
listCommands(): object;
/**
* Print sharding configuration and chunk distribution.
* @param verbose If true, show detailed chunk information
*/
printShardingStatus(verbose?: boolean): void
printShardingStatus(verbose?: boolean): void;
/**
* Lock the server and flush all data to disk for backup purposes.
* @returns Command result object
*/
fsyncLock(): object
fsyncLock(): object;
/**
* Unlock the server after an fsyncLock operation.
* @returns Command result object
*/
fsyncUnlock(): object
fsyncUnlock(): object;
/**
* @deprecated Use setSecondaryOk() instead
* Allow or disallow queries on secondary replica set members.
* @param value True to allow secondary reads
*/
setSlaveOk(value?: boolean): void
setSlaveOk(value?: boolean): void;
/**
* @deprecated Use getSecondaryOk() instead
* Check if secondary reads are allowed.
* @returns True if secondary reads are enabled
*/
getSlaveOk(): boolean
getSlaveOk(): boolean;
/**
* Allow queries to run on secondary replica set members.
* @param value True to allow secondary reads (default: true)
*/
setSecondaryOk(value?: boolean): void
setSecondaryOk(value?: boolean): void;
/**
* Check if queries are allowed on secondary replica set members.
* @returns True if secondary reads are enabled
*/
getSecondaryOk(): boolean
getSecondaryOk(): boolean;
/**
* Get the query options bitmask for this database.
* @returns Options bitmask (includes slaveOk, etc.)
*/
getQueryOptions(): number
getQueryOptions(): number;
/**
* Load and execute all JavaScript code stored in the db.system.js collection.
*/
loadServerScripts(): void
loadServerScripts(): void;
/**
* Create a new user in the database.
* @param userObj User document with user, pwd, roles, and optional customData, authenticationRestrictions
* @param writeConcern Write concern for the operation
* @returns Command result object
*/
createUser(userObj: object, writeConcern?: object): object
createUser(userObj: object, writeConcern?: object): object;
/**
* Update an existing user's properties (roles, password, customData, etc.).
@ -371,7 +379,11 @@ declare class DB {
* @param writeConcern Write concern for the operation
* @returns Command result object
*/
updateUser(name: string, updateObject: object, writeConcern?: object): object
updateUser(
name: string,
updateObject: object,
writeConcern?: object,
): object;
/**
* Change a user's password.
@ -380,13 +392,17 @@ declare class DB {
* @param writeConcern Write concern for the operation
* @returns Command result object
*/
changeUserPassword(username: string, password: string, writeConcern?: object): object
changeUserPassword(
username: string,
password: string,
writeConcern?: object,
): object;
/**
* Log out the currently authenticated user from this database.
* @returns Command result object
*/
logout(): object
logout(): object;
/**
* @deprecated Use dropUser() instead
@ -395,7 +411,7 @@ declare class DB {
* @param writeConcern Write concern for the operation
* @returns Command result object
*/
removeUser(username: string, writeConcern?: object): object
removeUser(username: string, writeConcern?: object): object;
/**
* Remove a user from the database.
@ -403,14 +419,14 @@ declare class DB {
* @param writeConcern Write concern for the operation
* @returns Command result object
*/
dropUser(username: string, writeConcern?: object): object
dropUser(username: string, writeConcern?: object): object;
/**
* Remove all users from the database.
* @param writeConcern Write concern for the operation
* @returns Command result object with count of users removed
*/
dropAllUsers(writeConcern?: object): object
dropAllUsers(writeConcern?: object): object;
/**
* Authenticate a user against this database.
@ -418,7 +434,7 @@ declare class DB {
* @param password Password (or omit to prompt)
* @returns Authentication result object
*/
auth(username?: string, password?: string): object
auth(username?: string, password?: string): object;
/**
* Grant additional roles to a user.
@ -427,7 +443,11 @@ declare class DB {
* @param writeConcern Write concern for the operation
* @returns Command result object
*/
grantRolesToUser(username: string, roles: string[] | object[], writeConcern?: object): object
grantRolesToUser(
username: string,
roles: string[] | object[],
writeConcern?: object,
): object;
/**
* Revoke roles from a user.
@ -436,7 +456,11 @@ declare class DB {
* @param writeConcern Write concern for the operation
* @returns Command result object
*/
revokeRolesFromUser(username: string, roles: string[] | object[], writeConcern?: object): object
revokeRolesFromUser(
username: string,
roles: string[] | object[],
writeConcern?: object,
): object;
/**
* Get information about a specific user.
@ -444,14 +468,14 @@ declare class DB {
* @param args Optional arguments like showCredentials, showPrivileges, showAuthenticationRestrictions
* @returns User document or null if not found
*/
getUser(username: string, args?: object): object | null
getUser(username: string, args?: object): object | null;
/**
* Get information about all users in the database.
* @param args Optional filter and options
* @returns Array of user documents
*/
getUsers(args?: object): object[]
getUsers(args?: object): object[];
/**
* Create a new role in the database.
@ -459,7 +483,7 @@ declare class DB {
* @param writeConcern Write concern for the operation
* @returns Command result object
*/
createRole(roleObj: object, writeConcern?: object): object
createRole(roleObj: object, writeConcern?: object): object;
/**
* Update an existing role's properties.
@ -468,7 +492,11 @@ declare class DB {
* @param writeConcern Write concern for the operation
* @returns Command result object
*/
updateRole(name: string, updateObject: object, writeConcern?: object): object
updateRole(
name: string,
updateObject: object,
writeConcern?: object,
): object;
/**
* Drop a role from the database.
@ -476,14 +504,14 @@ declare class DB {
* @param writeConcern Write concern for the operation
* @returns Command result object
*/
dropRole(name: string, writeConcern?: object): object
dropRole(name: string, writeConcern?: object): object;
/**
* Drop all user-defined roles from the database.
* @param writeConcern Write concern for the operation
* @returns Command result object with count of roles dropped
*/
dropAllRoles(writeConcern?: object): object
dropAllRoles(writeConcern?: object): object;
/**
* Grant roles to an existing role (role inheritance).
@ -492,7 +520,11 @@ declare class DB {
* @param writeConcern Write concern for the operation
* @returns Command result object
*/
grantRolesToRole(rolename: string, roles: string[] | object[], writeConcern?: object): object
grantRolesToRole(
rolename: string,
roles: string[] | object[],
writeConcern?: object,
): object;
/**
* Revoke roles from an existing role.
@ -501,7 +533,11 @@ declare class DB {
* @param writeConcern Write concern for the operation
* @returns Command result object
*/
revokeRolesFromRole(rolename: string, roles: string[] | object[], writeConcern?: object): object
revokeRolesFromRole(
rolename: string,
roles: string[] | object[],
writeConcern?: object,
): object;
/**
* Grant privileges to a role.
@ -510,7 +546,11 @@ declare class DB {
* @param writeConcern Write concern for the operation
* @returns Command result object
*/
grantPrivilegesToRole(rolename: string, privileges: object[], writeConcern?: object): object
grantPrivilegesToRole(
rolename: string,
privileges: object[],
writeConcern?: object,
): object;
/**
* Revoke privileges from a role.
@ -519,7 +559,11 @@ declare class DB {
* @param writeConcern Write concern for the operation
* @returns Command result object
*/
revokePrivilegesFromRole(rolename: string, privileges: object[], writeConcern?: object): object
revokePrivilegesFromRole(
rolename: string,
privileges: object[],
writeConcern?: object,
): object;
/**
* Get information about a specific role.
@ -527,37 +571,37 @@ declare class DB {
* @param args Optional arguments like showPrivileges, showBuiltinRoles
* @returns Role document or null if not found
*/
getRole(rolename: string, args?: object): object | null
getRole(rolename: string, args?: object): object | null;
/**
* Get information about all roles in the database.
* @param args Optional filter and options
* @returns Array of role documents
*/
getRoles(args?: object): object[]
getRoles(args?: object): object[];
/**
* Set the default write concern for operations on this database.
* @param wc Write concern object with w, j, wtimeout fields
*/
setWriteConcern(wc: object): void
setWriteConcern(wc: object): void;
/**
* Get the effective write concern for this database.
* @returns Write concern object or undefined if not set
*/
getWriteConcern(): object | undefined
getWriteConcern(): object | undefined;
/**
* Unset (remove) the write concern for this database.
*/
unsetWriteConcern(): void
unsetWriteConcern(): void;
/**
* Get the current log verbosity levels for all components.
* @returns Object with verbosity levels by component
*/
getLogComponents(): object
getLogComponents(): object;
/**
* Set the log verbosity level for a specific component.
@ -565,7 +609,7 @@ declare class DB {
* @param component Component name (e.g., "query", "replication") or omit for global
* @returns Command result object
*/
setLogLevel(logLevel: number, component?: string): object
setLogLevel(logLevel: number, component?: string): object;
/**
* Open a change stream to watch for changes across all collections in the database.
@ -573,13 +617,13 @@ declare class DB {
* @param options Options like fullDocument, resumeAfter, startAtOperationTime
* @returns Change stream cursor
*/
watch(pipeline?: object[], options?: object): DBCommandCursor
watch(pipeline?: object[], options?: object): DBCommandCursor;
/**
* Get the implicit session associated with this database connection.
* @returns The driver session object
*/
getSession(): DriverSession
getSession(): DriverSession;
/**
* Create an encrypted collection using Queryable Encryption (QE).
@ -587,31 +631,31 @@ declare class DB {
* @param opts Options including encryptedFields specification
* @returns Object with collection creation details
*/
createEncryptedCollection(name: string, opts: object): object
createEncryptedCollection(name: string, opts: object): object;
/**
* Drop an encrypted collection and its associated state collections.
* @param name Name of the encrypted collection to drop
* @returns Command result object
*/
dropEncryptedCollection(name: string): object
dropEncryptedCollection(name: string): object;
/**
* Check for metadata inconsistencies in the database (sharding metadata, indexes, etc.).
* @param options Options to control the check scope
* @returns Cursor over inconsistency results
*/
checkMetadataConsistency(options?: object): DBCommandCursor
checkMetadataConsistency(options?: object): DBCommandCursor;
/**
* Get the shard ID of the primary shard for this database (sharded clusters only).
* @returns Shard ID string
*/
getDatabasePrimaryShardId(): string
getDatabasePrimaryShardId(): string;
/**
* Get detailed server build information (alias for serverBuildInfo).
* @returns Object with version, gitVersion, modules, allocator, etc.
*/
getServerBuildInfo(): object
getServerBuildInfo(): object;
}

View File

@ -1,4 +1,4 @@
// type declarations for error_codes.tpl.js
declare var ErrorCodeStrings
declare var ErrorCodes
declare var ErrorCodeStrings;
declare var ErrorCodes;

View File

@ -41,7 +41,14 @@ declare class Explainable {
* @param options Query options
* @returns Explain output
*/
find(filter?: object, projection?: object, limit?: number, skip?: number, batchSize?: number, options?: number): object;
find(
filter?: object,
projection?: object,
limit?: number,
skip?: number,
batchSize?: number,
options?: number,
): object;
/**
* Explain a findOne query.
@ -53,7 +60,14 @@ declare class Explainable {
* @param rawData Whether to use raw data
* @returns Explain output
*/
findOne(filter?: object, projection?: object, options?: object, readConcern?: object, collation?: object, rawData?: boolean): object;
findOne(
filter?: object,
projection?: object,
options?: object,
readConcern?: object,
collation?: object,
rawData?: boolean,
): object;
/**
* Explain a count query.
@ -88,7 +102,12 @@ declare class Explainable {
* @param multi Whether to update multiple documents
* @returns Explain output
*/
update(query: object, updateSpec: object, upsert?: boolean, multi?: boolean): object;
update(
query: object,
updateSpec: object,
upsert?: boolean,
multi?: boolean,
): object;
/**
* Explain a remove operation.
@ -120,7 +139,11 @@ declare class Explainable {
* @param options Options
* @returns Explain output
*/
findOneAndReplace(filter: object, replacement: object, options?: object): object;
findOneAndReplace(
filter: object,
replacement: object,
options?: object,
): object;
/**
* Explain a findOneAndUpdate operation.

View File

@ -51,172 +51,172 @@ type TenantIdHex = string;
type DatabaseName = string;
enum CollationCaseFirst {
Upper = "upper",
Lower = "lower",
Off = "off",
Upper = "upper",
Lower = "lower",
Off = "off",
}
enum CollationStrength {
Primary = 1,
Secondary = 2,
Tertiary = 3,
Quaternary = 4,
Identical = 5,
Primary = 1,
Secondary = 2,
Tertiary = 3,
Quaternary = 4,
Identical = 5,
}
enum CollationAlternate {
NonIgnorable = "non-ignorable",
Shifted = "shifted",
NonIgnorable = "non-ignorable",
Shifted = "shifted",
}
enum CollationMaxVariable {
Punct = "punct",
Space = "space",
Punct = "punct",
Space = "space",
}
// Structs
interface OkReply {
ok: 1;
ok: 1;
}
interface ErrorReply {
ok: 0;
code: number;
codeName: string;
errmsg: string;
errorLabels?: string[];
ok: 0;
code: number;
codeName: string;
errmsg: string;
errorLabels?: string[];
}
interface SimpleCursorOptions {
batchSize?: number; // safeInt64 with gte: 0
batchSize?: number; // safeInt64 with gte: 0
}
interface Collation {
locale: string;
caseLevel?: boolean; // default: false
caseFirst?: CollationCaseFirst; // default: Off
strength?: number; // default: CollationStrength.Tertiary (int between 0 and 5)
numericOrdering?: boolean; // default: false
alternate?: CollationAlternate; // default: NonIgnorable
maxVariable?: CollationMaxVariable; // default: Punct
normalization?: boolean; // default: false
backwards?: boolean; // optionalBool
version?: string;
locale: string;
caseLevel?: boolean; // default: false
caseFirst?: CollationCaseFirst; // default: Off
strength?: number; // default: CollationStrength.Tertiary (int between 0 and 5)
numericOrdering?: boolean; // default: false
alternate?: CollationAlternate; // default: NonIgnorable
maxVariable?: CollationMaxVariable; // default: Punct
normalization?: boolean; // default: false
backwards?: boolean; // optionalBool
version?: string;
}
interface Commands {}
type ConfigureFailPointModeObject = {
/** n > 0. n: the probability that the fail point will fire. 0=never, 1=always. */
activationProbability: number;
/** n > 0. n: the probability that the fail point will fire. 0=never, 1=always. */
activationProbability: number;
/** n > 0. n: # of passes the fail point remains active. */
times: number;
/** n > 0. n: # of passes the fail point remains active. */
times: number;
/** n > 0. n: # of passes before the fail point activates and remains active. */
skip: number;
/** n > 0. n: # of passes before the fail point activates and remains active. */
skip: number;
};
interface Commands {
/** Test-only command for modifying installed fail points.
*
* Requires the 'enableTestCommands' server parameter to be set. See docs/test_commands.md.
*/
configureFailPoint: Command<
{
/** (command) Test-only command for modifying installed fail points.
*
* (Fields: `mode` `data`) */
configureFailPoint: string;
/** Test-only command for modifying installed fail points.
*
* Requires the 'enableTestCommands' server parameter to be set. See docs/test_commands.md.
*/
configureFailPoint: Command<
{
/** (command) Test-only command for modifying installed fail points.
*
* (Fields: `mode` `data`) */
configureFailPoint: string;
/** (field) The new mode to set for the failpoint. */
mode?: "off" | "alwaysOn" | ConfigureFailPointModeObject;
/** (field) The new mode to set for the failpoint. */
mode?: "off" | "alwaysOn" | ConfigureFailPointModeObject;
/** (field) optional arbitrary object to inject into the failpoint.
* When activated, the FailPoint can read this data and it can be used to inform
* the specific action taken by the code under test. */
data?: object;
},
object
>;
/** (field) optional arbitrary object to inject into the failpoint.
* When activated, the FailPoint can read this data and it can be used to inform
* the specific action taken by the code under test. */
data?: object;
},
object
>;
}
/**
* Arguments accepted by all commands.
*/
type GenericArguments = {
/** generic argument */ apiVersion?: string;
/** generic argument */ apiStrict?: boolean;
/** generic argument */ apiDeprecationErrors?: boolean;
/** generic argument */ maxTimeMS?: number;
/** generic argument */ readConcern?: ReadConcernIdl;
/** generic argument */ writeConcern?: WriteConcernIdl;
/** generic argument */ lsid?: LogicalSessionFromClient;
/** generic argument */ clientOperationKey?: UUID;
/** generic argument */ txnNumber?: TxnNumber;
/** generic argument */ autocommit?: boolean;
/** generic argument */ startTransaction?: boolean;
/** generic argument */ comment?: any;
/** generic argument */ $readPreference?: ReadPreference;
/** generic argument */ $clusterTime?: ClusterTime;
/** generic argument */ $audit?: AuditMetadata;
/** generic argument */ $client?: object;
/** generic argument */ $configServerState?: object;
/** generic argument */ allowImplicitCollectionCreation?: boolean;
/** generic argument */ $oplogQueryData?: any;
/** generic argument */ $queryOptions?: object;
/** generic argument */ $replData?: any;
/** generic argument */ databaseVersion?: DatabaseVersion;
/** generic argument */ help?: boolean;
/** generic argument */ shardVersion?: ShardVersion;
/** generic argument */ tracking_info?: object;
/** generic argument */ coordinator?: boolean;
/** generic argument */ maxTimeMSOpOnly?: number;
/** generic argument */ usesDefaultMaxTimeMS?: boolean;
/** generic argument */ $configTime?: Timestamp;
/** generic argument */ $topologyTime?: Timestamp;
/** generic argument */ txnRetryCounter?: TxnRetryCounter;
/** generic argument */ versionContext?: VersionContext;
/** generic argument */ mayBypassWriteBlocking?: boolean;
/** generic argument */ expectPrefix?: boolean;
/** generic argument */ requestGossipRoutingCache?: any[];
/** generic argument */ startOrContinueTransaction?: boolean;
/** generic argument */ rawData?: boolean | null;
/** generic argument */ apiVersion?: string;
/** generic argument */ apiStrict?: boolean;
/** generic argument */ apiDeprecationErrors?: boolean;
/** generic argument */ maxTimeMS?: number;
/** generic argument */ readConcern?: ReadConcernIdl;
/** generic argument */ writeConcern?: WriteConcernIdl;
/** generic argument */ lsid?: LogicalSessionFromClient;
/** generic argument */ clientOperationKey?: UUID;
/** generic argument */ txnNumber?: TxnNumber;
/** generic argument */ autocommit?: boolean;
/** generic argument */ startTransaction?: boolean;
/** generic argument */ comment?: any;
/** generic argument */ $readPreference?: ReadPreference;
/** generic argument */ $clusterTime?: ClusterTime;
/** generic argument */ $audit?: AuditMetadata;
/** generic argument */ $client?: object;
/** generic argument */ $configServerState?: object;
/** generic argument */ allowImplicitCollectionCreation?: boolean;
/** generic argument */ $oplogQueryData?: any;
/** generic argument */ $queryOptions?: object;
/** generic argument */ $replData?: any;
/** generic argument */ databaseVersion?: DatabaseVersion;
/** generic argument */ help?: boolean;
/** generic argument */ shardVersion?: ShardVersion;
/** generic argument */ tracking_info?: object;
/** generic argument */ coordinator?: boolean;
/** generic argument */ maxTimeMSOpOnly?: number;
/** generic argument */ usesDefaultMaxTimeMS?: boolean;
/** generic argument */ $configTime?: Timestamp;
/** generic argument */ $topologyTime?: Timestamp;
/** generic argument */ txnRetryCounter?: TxnRetryCounter;
/** generic argument */ versionContext?: VersionContext;
/** generic argument */ mayBypassWriteBlocking?: boolean;
/** generic argument */ expectPrefix?: boolean;
/** generic argument */ requestGossipRoutingCache?: any[];
/** generic argument */ startOrContinueTransaction?: boolean;
/** generic argument */ rawData?: boolean | null;
};
/**
* Fields that may appear in any command reply.
*/
type GenericReplyFields = {
/** generic reply field */ $clusterTime?: ClusterTime;
/** generic reply field */ operationTime?: LogicalTime;
/** generic reply field */ $configServerState?: object;
/** generic reply field */ $gleStats?: object;
/** generic reply field */ lastCommittedOpTime?: OpTime;
/** generic reply field */ readOnly?: boolean;
/** generic reply field */ additionalParticipants?: object[];
/** generic reply field */ $configTime?: Timestamp;
/** generic reply field */ $replData?: object;
/** generic reply field */ $topologyTime?: Timestamp;
/** generic reply field */ $oplogQueryData?: object;
/** generic reply field */ ok?: boolean;
/** generic reply field */ routingCacheGossip?: GossipedRoutingCache[];
/** generic reply field */ $clusterTime?: ClusterTime;
/** generic reply field */ operationTime?: LogicalTime;
/** generic reply field */ $configServerState?: object;
/** generic reply field */ $gleStats?: object;
/** generic reply field */ lastCommittedOpTime?: OpTime;
/** generic reply field */ readOnly?: boolean;
/** generic reply field */ additionalParticipants?: object[];
/** generic reply field */ $configTime?: Timestamp;
/** generic reply field */ $replData?: object;
/** generic reply field */ $topologyTime?: Timestamp;
/** generic reply field */ $oplogQueryData?: object;
/** generic reply field */ ok?: boolean;
/** generic reply field */ routingCacheGossip?: GossipedRoutingCache[];
};
type Command<Req extends object = {}, Res = any> = {
req: Req;
res: Res;
req: Req;
res: Res;
};
// All keys that could be passed to a Req object.
type AllReqKeys = keyof {
[K in keyof Commands as keyof Commands[K]["req"]]: any;
[K in keyof Commands as keyof Commands[K]["req"]]: any;
};
// Takes in a request object and deduces which command it came from and what its response type is.
type GetResponseType<T> = {
[K in keyof Commands]: K extends keyof T ? Commands[K]["res"] : never;
[K in keyof Commands]: K extends keyof T ? Commands[K]["res"] : never;
}[keyof Commands];
class None {}
@ -260,7 +260,15 @@ declare class Mongo {
* @param options Query options bitmask
* @returns Query cursor
*/
find(ns: string, query: object, fields: object, limit: number, skip: number, batchSize: number, options: number): DBQuery;
find(
ns: string,
query: object,
fields: object,
limit: number,
skip: number,
batchSize: number,
options: number,
): DBQuery;
/**
* Low-level insert operation on a collection namespace.
@ -289,7 +297,12 @@ declare class Mongo {
* @param upsert If true, insert if no documents match
* @returns Write result
*/
update(ns: string, query: object, obj: object, upsert: boolean): WriteResult;
update(
ns: string,
query: object,
obj: object,
upsert: boolean,
): WriteResult;
/**
* @deprecated Use setSecondaryOk() instead
@ -338,11 +351,11 @@ declare class Mongo {
* @returns Command result with ok field and command-specific fields
*/
adminCommand<Req extends Partial<Commands[keyof Commands]["req"]>>(
command: GenericArguments & Req,
command: GenericArguments & Req,
): GenericReplyFieldsAnd<GetResponseType<Req>>;
adminCommand<ReqType extends keyof Commands>(
command: GenericArguments & ReqType,
command: GenericArguments & ReqType,
): GenericReplyFieldsAnd<Commands[ReqType]["res"]>;
/**
@ -354,15 +367,15 @@ declare class Mongo {
* @returns Command result
*/
runCommand<Req extends Partial<Commands[keyof Commands]["req"]>>(
dbName: string,
command: GenericArguments & Req,
options: object,
dbName: string,
command: GenericArguments & Req,
options: object,
): MergeKeys<GenericReplyFields, GetResponseType<Req>>;
runCommand<ReqType extends keyof Commands>(
dbName: string,
command: GenericArguments & ReqType,
options: object,
dbName: string,
command: GenericArguments & ReqType,
options: object,
): GenericReplyFieldsAnd<Commands[ReqType]["res"]>;
/**
@ -525,7 +538,7 @@ declare class Mongo {
* @example
* let conn = connect("mongodb://localhost:27017").getMongo();
* let db = conn.getDB("test");
*
*
* or if you already have a mongo object and you with to reconnect with it:
* let conn = connect(db.getMongo().uri).getMongo();
*/

View File

@ -1,213 +1,223 @@
// type declarations for query.js
declare class DBQuery {
constructor(mongo: Mongo, db: DB, collection: DBCollection, ns: string, filter: object, projection?: object, limit?: number, skip?: number, batchSize?: number, options?: number)
constructor(
mongo: Mongo,
db: DB,
collection: DBCollection,
ns: string,
filter: object,
projection?: object,
limit?: number,
skip?: number,
batchSize?: number,
options?: number,
);
/**
* Add a query option flag to the cursor.
* @param option Option flag to add (e.g., DBQuery.Option.tailable)
* @returns This cursor for chaining
*/
addOption(option: number): DBQuery
addOption(option: number): DBQuery;
/**
* Allow the query to use temporary disk storage for large sorts.
* @param value Whether to allow disk use (default: true)
* @returns This cursor for chaining
*/
allowDiskUse(value?: boolean): DBQuery
allowDiskUse(value?: boolean): DBQuery;
/**
* Allow partial results from a sharded cluster if some shards are unavailable.
* @returns This cursor for chaining
*/
allowPartialResults(): DBQuery
allowPartialResults(): DBQuery;
/**
* Access a result document by numeric index.
* @param index Zero-based index of the document to retrieve
* @returns The document at the specified index
*/
arrayAccess(index: number): any
arrayAccess(index: number): any;
/**
* Set the number of documents to return per batch from the server.
* @param n Batch size (0 = server default)
* @returns This cursor for chaining
*/
batchSize(n: number): DBQuery
batchSize(n: number): DBQuery;
/**
* Create an independent copy of this query cursor.
* @returns A new DBQuery with the same settings
*/
clone(): DBQuery
clone(): DBQuery;
/**
* Close the cursor and free server resources.
*/
close(): void
close(): void;
/**
* Specify collation rules for string comparison.
* @param collationSpec Collation specification object
* @returns This cursor for chaining
*/
collation(collationSpec: object): DBQuery
collation(collationSpec: object): DBQuery;
/**
* Attach a comment to the query for identification in profiler and logs.
* @param comment Comment string to attach
* @returns This cursor for chaining
*/
comment(comment: string): DBQuery
comment(comment: string): DBQuery;
/**
* Count the number of documents matching the query.
* @param applySkipLimit If true, applies skip and limit modifiers
* @returns The count of matching documents
*/
count(applySkipLimit?: boolean): number
count(applySkipLimit?: boolean): number;
/**
* Get the query execution plan and statistics.
* @param verbose Verbosity level: "queryPlanner", "executionStats", "allPlansExecution", or boolean
* @returns Explain output object
*/
explain(verbose?: string | boolean): object
explain(verbose?: string | boolean): object;
/**
* Execute a function for each document in the result set.
* @param func Callback function to execute for each document
*/
forEach(func: (doc: any) => void): void
forEach(func: (doc: any) => void): void;
/**
* Get the cluster time from the last operation (for snapshot reads).
* @returns The cluster time timestamp, or undefined if not available
*/
getClusterTime(): Timestamp | undefined
getClusterTime(): Timestamp | undefined;
/**
* Get the server-side cursor ID.
* @returns The cursor ID as a NumberLong
*/
getId(): NumberLong
getId(): NumberLong;
/**
* Check if there are more documents available in the cursor.
* @returns True if more documents are available
*/
hasNext(): boolean
hasNext(): boolean;
/**
* Print help documentation for cursor methods.
*/
help(): void
help(): void;
/**
* Suggest a specific index for the query optimizer to use.
* @param index Index name (string) or index specification (object)
* @returns This cursor for chaining
*/
hint(index: string | object): DBQuery
hint(index: string | object): DBQuery;
/**
* Check if the cursor has been closed.
* @returns True if the cursor is closed
*/
isClosed(): boolean
isClosed(): boolean;
/**
* Check if all results have been retrieved from the server.
* @returns True if no more documents are available
*/
isExhausted(): boolean
isExhausted(): boolean;
/**
* Iterate through all documents and return the count.
* @returns The number of documents iterated
*/
itcount(): number
itcount(): number;
/**
* Get the total number of documents (materializes all results into memory).
* @returns The length of the result array
*/
length(): number
length(): number;
/**
* Limit the maximum number of documents to return.
* @param n Maximum number of documents (0 = no limit)
* @returns This cursor for chaining
*/
limit(n: number): DBQuery
limit(n: number): DBQuery;
/**
* Transform each document using a mapping function.
* @param func Function to apply to each document
* @returns Array of transformed results
*/
map<T>(func: (doc: any) => T): T[]
map<T>(func: (doc: any) => T): T[];
/**
* Set the maximum index key values for a range query.
* @param indexBounds Maximum bounds object matching the index
* @returns This cursor for chaining
*/
max(indexBounds: object): DBQuery
max(indexBounds: object): DBQuery;
/**
* Set the maximum execution time for the query.
* @param ms Maximum time in milliseconds
* @returns This cursor for chaining
*/
maxTimeMS(ms: number): DBQuery
maxTimeMS(ms: number): DBQuery;
/**
* Set the minimum index key values for a range query.
* @param indexBounds Minimum bounds object matching the index
* @returns This cursor for chaining
*/
min(indexBounds: object): DBQuery
min(indexBounds: object): DBQuery;
/**
* Get the next document from the cursor.
* @returns The next document, or throws if no more documents
*/
next(): any
next(): any;
/**
* Prevent the cursor from timing out after inactivity.
* @returns This cursor for chaining
*/
noCursorTimeout(): DBQuery
noCursorTimeout(): DBQuery;
/**
* Get the number of documents remaining in the current batch.
* @returns Count of documents left in batch
*/
objsLeftInBatch(): number
objsLeftInBatch(): number;
/**
* Enable pretty-printing for better readability in the shell.
* @returns This cursor for chaining
*/
pretty(): DBQuery
pretty(): DBQuery;
/**
* Specify which fields to include or exclude in results.
* @param spec Projection specification object
* @returns This cursor for chaining
*/
projection(spec: object): DBQuery
projection(spec: object): DBQuery;
/**
* Return results in raw BSON binary format.
* @returns This cursor for chaining
*/
rawData(): DBQuery
rawData(): DBQuery;
/**
* Set the read concern level for the query.
@ -215,13 +225,13 @@ declare class DBQuery {
* @param atClusterTime Optional cluster time for snapshot reads
* @returns This cursor for chaining
*/
readConcern(level: string, atClusterTime?: Timestamp): DBQuery
readConcern(level: string, atClusterTime?: Timestamp): DBQuery;
/**
* Mark the cursor as read-only for optimization.
* @returns This cursor for chaining
*/
readOnly(): DBQuery
readOnly(): DBQuery;
/**
* Set the read preference for replica set queries.
@ -229,71 +239,71 @@ declare class DBQuery {
* @param tagSet Optional array of tag sets for server selection
* @returns This cursor for chaining
*/
readPref(mode: string, tagSet?: object[]): DBQuery
readPref(mode: string, tagSet?: object[]): DBQuery;
/**
* Return only the index keys instead of full documents.
* @returns This cursor for chaining
*/
returnKey(): DBQuery
returnKey(): DBQuery;
/**
* Get a string representation suitable for shell output.
* @returns String representation of cursor results
*/
shellPrint(): string
shellPrint(): string;
/**
* @deprecated Use showRecordId() instead
* Include disk location information in results.
* @returns This cursor for chaining
*/
showDiskLoc(): DBQuery
showDiskLoc(): DBQuery;
/**
* Include the internal $recordId field in result documents.
* @returns This cursor for chaining
*/
showRecordId(): DBQuery
showRecordId(): DBQuery;
/**
* Count documents with skip and limit applied.
* @returns The count after applying skip/limit
*/
size(): number
size(): number;
/**
* Skip a specified number of documents.
* @param n Number of documents to skip
* @returns This cursor for chaining
*/
skip(n: number): DBQuery
skip(n: number): DBQuery;
/**
* Sort results by the specified fields.
* @param sortBy Sort specification object (e.g., {field: 1} for ascending)
* @returns This cursor for chaining
*/
sort(sortBy: object): DBQuery
sort(sortBy: object): DBQuery;
/**
* Create a tailable cursor that remains open after reaching the end (for capped collections).
* @param awaitData If true, block briefly waiting for new data before returning
* @returns This cursor for chaining
*/
tailable(awaitData?: boolean): DBQuery
tailable(awaitData?: boolean): DBQuery;
/**
* Materialize all cursor results into an array.
* @returns Array containing all result documents
*/
toArray(): any[]
toArray(): any[];
/**
* Get a string representation of the cursor.
* @returns String representation
*/
toString(): string
toString(): string;
}
/**
* Cursor returned by database commands like aggregate() and watch().
@ -303,103 +313,103 @@ declare class DBCommandCursor {
/**
* Close the cursor and release server resources.
*/
close(): void
close(): void;
/**
* Execute a function for each document in the cursor.
* @param func Callback function to execute for each document
*/
forEach(func: (doc: any) => void): void
forEach(func: (doc: any) => void): void;
/**
* Get the change stream protocol version (for change stream cursors).
* @returns The version string ("v1" or "v2"), or undefined if not a change stream
*/
getChangeStreamVersion(): string | undefined
getChangeStreamVersion(): string | undefined;
/**
* Get the cluster time from the most recent operation.
* @returns The cluster time timestamp, or undefined if not available
*/
getClusterTime(): Timestamp | undefined
getClusterTime(): Timestamp | undefined;
/**
* Get the server-side cursor ID.
* @returns The cursor ID as a NumberLong
*/
getId(): NumberLong
getId(): NumberLong;
/**
* Get the resume token for change streams (used to resume after disconnect).
* @returns The resume token object, or undefined if not a change stream
*/
getResumeToken(): object | undefined
getResumeToken(): object | undefined;
/**
* Check if there are more documents available in the cursor.
* @returns True if more documents are available
*/
hasNext(): boolean
hasNext(): boolean;
/**
* Print help documentation for cursor methods.
*/
help(): void
help(): void;
/**
* Check if the cursor has been closed.
* @returns True if the cursor is closed
*/
isClosed(): boolean
isClosed(): boolean;
/**
* Check if all results have been retrieved from the server.
* @returns True if no more documents are available
*/
isExhausted(): boolean
isExhausted(): boolean;
/**
* Iterate through all documents and return the count.
* @returns The number of documents iterated
*/
itcount(): number
itcount(): number;
/**
* Transform each document using a mapping function.
* @param func Function to apply to each document
* @returns Array of transformed results
*/
map<T>(func: (doc: any) => T): T[]
map<T>(func: (doc: any) => T): T[];
/**
* Get the next document from the cursor.
* @returns The next document, or throws if no more documents
*/
next(): any
next(): any;
/**
* Get the number of documents remaining in the current batch.
* @returns Count of documents left in batch
*/
objsLeftInBatch(): number
objsLeftInBatch(): number;
/**
* Enable pretty-printing for better readability in the shell.
* @returns This cursor for chaining
*/
pretty(): DBCommandCursor
pretty(): DBCommandCursor;
/**
* Get a string representation suitable for shell output.
* @returns String representation of cursor results
*/
shellPrint(): string
shellPrint(): string;
/**
* Materialize all cursor results into an array.
* @returns Array containing all result documents
*/
toArray(): any[]
toArray(): any[];
}
/**
@ -410,11 +420,11 @@ declare module QueryHelpers {
* Get the resume token from the most recent query operation.
* @returns The resume token object, or undefined if not available
*/
function getResumeToken(): object | undefined
function getResumeToken(): object | undefined;
}
/**
* Shell variable holding the last query result for iteration.
* Used by the shell to store results when typing `it` to iterate.
*/
declare var ___it___: any
declare var ___it___: any;

View File

@ -128,7 +128,12 @@ declare class SessionAwareClient {
* @param options Command options
* @returns Command result
*/
runCommand(driverSession: DriverSession, dbName: string, cmdObj: object, options: any): any;
runCommand(
driverSession: DriverSession,
dbName: string,
cmdObj: object,
options: any,
): any;
}
/**
@ -258,7 +263,10 @@ declare class DriverSession {
* @param txnOptsObj Transaction options
* @param startNewTxnNumber Whether to start a new transaction number
*/
startTransaction_forTesting(txnOptsObj?: object, startNewTxnNumber?: boolean): void;
startTransaction_forTesting(
txnOptsObj?: object,
startNewTxnNumber?: boolean,
): void;
/**
* Commit the active transaction.

View File

@ -6,14 +6,14 @@
* @param obj JavaScript object to convert
* @returns BSON object representation
*/
declare function _buildBsonObj(obj: object): BSONObj
declare function _buildBsonObj(obj: object): BSONObj;
/**
* Close a golden data file for testing.
* Used internally by the test framework to clean up golden data file handles.
* @param handle File handle returned by _openGoldenData()
*/
declare function _closeGoldenData(handle: any): void
declare function _closeGoldenData(handle: any): void;
/**
* Compare two strings using the specified collation rules.
@ -23,7 +23,11 @@ declare function _closeGoldenData(handle: any): void
* @param collation Collation specification object (locale, strength, caseLevel, etc.)
* @returns Negative if str1 < str2, positive if str1 > str2, zero if equal
*/
declare function _compareStringsWithCollation(str1: string, str2: string, collation: object): number
declare function _compareStringsWithCollation(
str1: string,
str2: string,
collation: object,
): number;
/**
* Create a security token for testing.
@ -31,7 +35,7 @@ declare function _compareStringsWithCollation(str1: string, str2: string, collat
* @param user User object specifying user credentials and properties
* @returns Security token object
*/
declare function _createSecurityToken(user: object): object
declare function _createSecurityToken(user: object): object;
/**
* Create a tenant token for multi-tenancy testing.
@ -39,7 +43,7 @@ declare function _createSecurityToken(user: object): object
* @param tenant Tenant object specifying tenant properties
* @returns Tenant token object
*/
declare function _createTenantToken(tenant: object): object
declare function _createTenantToken(tenant: object): object;
/**
* Get Decimal128 maximum and minimum positive and negative values.
@ -47,7 +51,7 @@ declare function _createTenantToken(tenant: object): object
* @param str String matching [+-]?(max|min), case insensitive (e.g., "max", "-min", "+max")
* @returns NumberDecimal representing the requested limit value
*/
declare function _decimal128Limit(str: string): NumberDecimal
declare function _decimal128Limit(str: string): NumberDecimal;
/**
* Hash a string using FNV-1a algorithm and return as hex string.
@ -55,13 +59,13 @@ declare function _decimal128Limit(str: string): NumberDecimal
* @param str String to hash
* @returns Hexadecimal string representation of the hash value
*/
declare function _fnvHashToHexString(str: string): string
declare function _fnvHashToHexString(str: string): string;
/**
* Check if the shell is running on Windows.
* @returns True if running on Windows, false otherwise
*/
declare function _isWindows(): boolean
declare function _isWindows(): boolean;
/**
* Open a golden data file for testing and return handle.
@ -69,14 +73,14 @@ declare function _isWindows(): boolean
* @param filename Path to the golden data file
* @returns File handle for use with _writeGoldenData() and _closeGoldenData()
*/
declare function _openGoldenData(filename: string): any
declare function _openGoldenData(filename: string): any;
/**
* Generate a random number between 0 and 1.
* Uses the shell's internal random number generator (seeded with _srand).
* @returns Random number in the range [0, 1)
*/
declare function _rand(): number
declare function _rand(): number;
/**
* Get replica set monitor statistics for a host.
@ -84,7 +88,7 @@ declare function _rand(): number
* @param host Optional host string to filter statistics for (e.g., "localhost:27017")
* @returns Object containing replica set monitor statistics
*/
declare function _replMonitorStats(host?: string): object
declare function _replMonitorStats(host?: string): object;
/**
* Compares two result sets after applying some normalizations. This function should only
* be used in the fuzzer.
@ -97,7 +101,7 @@ declare function _replMonitorStats(host?: string): object
*
* @returns True if the result sets compare equal and false otherwise.
*/
declare function _resultSetsEqualNormalized(a: object[], b: object[]): boolean
declare function _resultSetsEqualNormalized(a: object[], b: object[]): boolean;
/**
* Compares two result sets after sorting arrays.
*
@ -109,7 +113,10 @@ declare function _resultSetsEqualNormalized(a: object[], b: object[]): boolean
*
* @returns True if the result sets compare equal after sorting arrays and false otherwise.
*/
declare function _resultSetsEqualUnorderedWithUnorderedArrays(a: object[], b: object[]): boolean
declare function _resultSetsEqualUnorderedWithUnorderedArrays(
a: object[],
b: object[],
): boolean;
/**
* Compare two result sets ignoring order.
@ -118,7 +125,7 @@ declare function _resultSetsEqualUnorderedWithUnorderedArrays(a: object[], b: ob
* @param b Second result set (array of documents)
* @returns True if the result sets contain the same documents (order-independent), false otherwise
*/
declare function _resultSetsEqualUnordered(a: object[], b: object[]): boolean
declare function _resultSetsEqualUnordered(a: object[], b: object[]): boolean;
/**
* Set a shell-side fail point for testing.
@ -126,14 +133,14 @@ declare function _resultSetsEqualUnordered(a: object[], b: object[]): boolean
* @param options Fail point configuration object with mode, data, and other settings
* @returns Result object indicating success or failure
*/
declare function _setShellFailPoint(options: object): object
declare function _setShellFailPoint(options: object): object;
/**
* Seed the random number generator.
* Seeds the shell's internal random number generator for reproducible test results.
* @param seed Integer seed value
*/
declare function _srand(seed: number): void
declare function _srand(seed: number): void;
/**
* Write data to a golden data file for testing.
@ -141,7 +148,7 @@ declare function _srand(seed: number): void
* @param data Data to write to the golden file
* @param filename Path to the golden data file
*/
declare function _writeGoldenData(data: any, filename: string): void
declare function _writeGoldenData(data: any, filename: string): void;
/**
* Run a benchmark workload and return statistics.
@ -149,7 +156,7 @@ declare function _writeGoldenData(data: any, filename: string): void
* @param config Benchmark configuration object specifying operations, thread count, duration, etc.
* @returns Object containing performance statistics (ops/sec, latency, etc.)
*/
declare function benchRun(config: object): object
declare function benchRun(config: object): object;
/**
* Run a benchmark workload synchronously.
@ -157,7 +164,7 @@ declare function benchRun(config: object): object
* @param config Benchmark configuration object specifying operations, thread count, duration, etc.
* @returns Object containing performance statistics (ops/sec, latency, etc.)
*/
declare function benchRunSync(config: object): object
declare function benchRunSync(config: object): object;
/**
* Compute SHA256 hash of a message.
@ -165,7 +172,7 @@ declare function benchRunSync(config: object): object
* @param message String or BinData to hash
* @returns BinData containing the SHA-256 hash (32 bytes)
*/
declare function computeSHA256Block(message: string | BinData): BinData
declare function computeSHA256Block(message: string | BinData): BinData;
/**
* Compute HMAC-SHA256 of a message with a key.
@ -174,7 +181,10 @@ declare function computeSHA256Block(message: string | BinData): BinData
* @param message Message to authenticate as string or BinData
* @returns BinData containing the HMAC-SHA256 result (32 bytes)
*/
declare function computeSHA256Hmac(key: string | BinData, message: string | BinData): BinData
declare function computeSHA256Hmac(
key: string | BinData,
message: string | BinData,
): BinData;
/**
* Convert a shard key to its hashed value.
@ -182,42 +192,42 @@ declare function computeSHA256Hmac(key: string | BinData, message: string | BinD
* @param shardKey Shard key value to hash
* @returns NumberLong representing the hashed shard key value
*/
declare function convertShardKeyToHashed(shardKey: any): NumberLong
declare function convertShardKeyToHashed(shardKey: any): NumberLong;
/**
* Check if a file exists at the given path.
* @param path File path to check
* @returns True if the file exists, false otherwise
*/
declare function fileExists(path: string): boolean
declare function fileExists(path: string): boolean;
/**
* Get MongoDB build information.
* Returns information about the MongoDB server build, including version, modules, and features.
* @returns Object containing version, gitVersion, modules, allocator, and other build details
*/
declare function getBuildInfo(): object
declare function getBuildInfo(): object;
/**
* Get system memory information.
* Returns details about system memory usage and availability.
* @returns Object containing memory statistics (total, available, etc.)
*/
declare function getMemInfo(): object
declare function getMemInfo(): object;
/**
* Get the JavaScript interpreter version.
* Returns the version string of the JavaScript engine used by the shell.
* @returns Version string (e.g., "MozJS-115")
*/
declare function interpreterVersion(): string
declare function interpreterVersion(): string;
/**
* Check if the shell is running in interactive mode.
* Interactive mode means the shell is connected to a terminal and accepting user input.
* @returns True if running in interactive mode, false if running a script non-interactively
*/
declare function isInteractive(): boolean
declare function isInteractive(): boolean;
/**
* Check if two NumberDecimal values are almost equal within specified decimal places.
@ -227,7 +237,11 @@ declare function isInteractive(): boolean
* @param places Number of decimal places to compare (default: 15)
* @returns True if the values are equal within the specified precision
*/
declare function numberDecimalsAlmostEqual(a: NumberDecimal, b: NumberDecimal, places?: number): boolean
declare function numberDecimalsAlmostEqual(
a: NumberDecimal,
b: NumberDecimal,
places?: number,
): boolean;
/**
* Check if two NumberDecimal values are exactly equal.
@ -236,4 +250,7 @@ declare function numberDecimalsAlmostEqual(a: NumberDecimal, b: NumberDecimal, p
* @param b Second NumberDecimal value
* @returns True if the values are exactly equal, false otherwise
*/
declare function numberDecimalsEqual(a: NumberDecimal, b: NumberDecimal): boolean
declare function numberDecimalsEqual(
a: NumberDecimal,
b: NumberDecimal,
): boolean;

View File

@ -1,44 +1,44 @@
// type declarations for shell_utils_extended.h
declare function _copyFileRange()
declare function _getEnv()
declare function _copyFileRange();
declare function _getEnv();
/**
* Retrieves the nth BSONObj in a BSON dump file
*
*
* @param filename {String} filename of the dump file
* @param n {Number} index of the object to retrieve
*
*
* @returns {BSONObj} fetched object
*/
declare function _getObjInDumpFile()
declare function _getObjInDumpFile();
/**
* Retrieves the number of BSONObj in a BSON dump file
*
*
* @param filename {String} filename of the dump file
*
*
* @returns {Number} number of objects
*/
declare function _numObjsInDumpFile()
declare function _numObjsInDumpFile();
declare function _readDumpFile()
declare function appendFile()
declare function cat()
declare function cd()
declare function copyDir()
declare function copyFile()
declare function decompressBSONColumn()
declare function getFileMode()
declare function getHostName()
declare function getStringWidth()
declare function hostname()
declare function listFiles()
declare function ls()
declare function md5sumFile()
declare function mkdir()
declare function passwordPrompt()
declare function pwd()
declare function removeFile()
declare function umask()
declare function writeFile()
declare function _readDumpFile();
declare function appendFile();
declare function cat();
declare function cd();
declare function copyDir();
declare function copyFile();
declare function decompressBSONColumn();
declare function getFileMode();
declare function getHostName();
declare function getStringWidth();
declare function hostname();
declare function listFiles();
declare function ls();
declare function md5sumFile();
declare function mkdir();
declare function passwordPrompt();
declare function pwd();
declare function removeFile();
declare function umask();
declare function writeFile();

View File

@ -5,7 +5,7 @@
* Returns the names of all test pipes that have been created for inter-process communication.
* @returns Array of test pipe name strings
*/
declare function _readTestPipes(): string[]
declare function _readTestPipes(): string[];
/**
* Run a MongoDB program with arguments and wait for completion.
@ -13,14 +13,14 @@ declare function _readTestPipes(): string[]
* @param args Program name followed by command-line arguments
* @returns Exit code of the program
*/
declare function _runMongoProgram(...args: string[]): number
declare function _runMongoProgram(...args: string[]): number;
/**
* Get PIDs of all running child MongoDB processes.
* Returns process IDs of all MongoDB programs started by the shell.
* @returns Array of process IDs (PIDs)
*/
declare function _runningMongoChildProcessIds(): number[]
declare function _runningMongoChildProcessIds(): number[];
/**
* Start a MongoDB program with arguments.
@ -28,7 +28,7 @@ declare function _runningMongoChildProcessIds(): number[]
* @param args Program name followed by command-line arguments
* @returns Process ID (PID) of the started program
*/
declare function _startMongoProgram(...args: string[]): number
declare function _startMongoProgram(...args: string[]): number;
/**
* Stop a MongoDB program running on the specified port.
@ -36,7 +36,7 @@ declare function _startMongoProgram(...args: string[]): number
* @param port Port number the MongoDB process is listening on
* @param signal Optional signal number (default: SIGTERM/15)
*/
declare function _stopMongoProgram(port: number, signal?: number): void
declare function _stopMongoProgram(port: number, signal?: number): void;
/**
* Write a value to a named test pipe.
@ -44,7 +44,7 @@ declare function _stopMongoProgram(port: number, signal?: number): void
* @param pipe Name of the test pipe
* @param value Value to write (will be converted to JSON)
*/
declare function _writeTestPipe(pipe: string, value: any): void
declare function _writeTestPipe(pipe: string, value: any): void;
/**
* Write a BSON object to a test pipe file.
@ -52,7 +52,7 @@ declare function _writeTestPipe(pipe: string, value: any): void
* @param pipe Name of the test pipe
* @param obj Object to serialize as BSON
*/
declare function _writeTestPipeBsonFile(pipe: string, obj: object): void
declare function _writeTestPipeBsonFile(pipe: string, obj: object): void;
/**
* Write a BSON object to a test pipe file synchronously.
@ -60,7 +60,7 @@ declare function _writeTestPipeBsonFile(pipe: string, obj: object): void
* @param pipe Name of the test pipe
* @param obj Object to serialize as BSON
*/
declare function _writeTestPipeBsonFileSync(pipe: string, obj: object): void
declare function _writeTestPipeBsonFileSync(pipe: string, obj: object): void;
/**
* Write multiple BSON objects to a test pipe.
@ -68,7 +68,7 @@ declare function _writeTestPipeBsonFileSync(pipe: string, obj: object): void
* @param pipe Name of the test pipe
* @param objs Array of objects to serialize as BSON documents
*/
declare function _writeTestPipeObjects(pipe: string, objs: object[]): void
declare function _writeTestPipeObjects(pipe: string, objs: object[]): void;
/**
* Check if a program is running on the specified port.
@ -76,14 +76,14 @@ declare function _writeTestPipeObjects(pipe: string, objs: object[]): void
* @param port Port number to check
* @returns Object with status information about the program
*/
declare function checkProgram(port: number): object
declare function checkProgram(port: number): object;
/**
* Clear the captured output from MongoDB programs.
* Clears the output buffer for programs started with _startMongoProgram.
* @param port Optional port number to clear output for specific program (omit for all)
*/
declare function clearRawMongoProgramOutput(port?: number): void
declare function clearRawMongoProgramOutput(port?: number): void;
/**
* Convert a traffic recording file to BSON format.
@ -93,7 +93,11 @@ declare function clearRawMongoProgramOutput(port?: number): void
* @param args Additional arguments for conversion options
* @returns Result object with conversion statistics
*/
declare function convertTrafficRecordingToBSON(inputFile: string, outputFile: string, ...args: string[]): object
declare function convertTrafficRecordingToBSON(
inputFile: string,
outputFile: string,
...args: string[]
): object;
/**
* Copy a database path directory.
@ -101,14 +105,14 @@ declare function convertTrafficRecordingToBSON(inputFile: string, outputFile: st
* @param from Source dbpath directory
* @param to Destination dbpath directory
*/
declare function copyDbpath(from: string, to: string): void
declare function copyDbpath(from: string, to: string): void;
/**
* Get Feature Compatibility Version (FCV) constants.
* Returns an object containing FCV version strings for use in version testing.
* @returns Object with FCV constants (e.g., latestFCV, lastContinuousFCV, lastLTSFCV)
*/
declare function getFCVConstants(): object
declare function getFCVConstants(): object;
/**
* Check if a path exists.
@ -116,7 +120,7 @@ declare function getFCVConstants(): object
* @param path File or directory path to check
* @returns True if the path exists, false otherwise
*/
declare function pathExists(path: string): boolean
declare function pathExists(path: string): boolean;
/**
* Get the raw output from a MongoDB program by port.
@ -124,14 +128,14 @@ declare function pathExists(path: string): boolean
* @param port Optional port number to get output for specific program (omit for all)
* @returns Raw output string from the program(s)
*/
declare function rawMongoProgramOutput(port?: number): string
declare function rawMongoProgramOutput(port?: number): string;
/**
* Reset (clear) a database path directory.
* Deletes all files in a dbpath directory to start with a clean state.
* @param path Path to the dbpath directory to clear
*/
declare function resetDbpath(path: string): void
declare function resetDbpath(path: string): void;
/**
* Run a program with arguments and wait for completion.
@ -140,7 +144,7 @@ declare function resetDbpath(path: string): void
* @param args Command-line arguments
* @returns Exit code of the program
*/
declare function run(program: string, ...args: string[]): number
declare function run(program: string, ...args: string[]): number;
/**
* Run a non-MongoDB program with arguments.
@ -149,7 +153,7 @@ declare function run(program: string, ...args: string[]): number
* @param args Command-line arguments
* @returns Exit code of the program
*/
declare function runNonMongoProgram(program: string, ...args: string[]): number
declare function runNonMongoProgram(program: string, ...args: string[]): number;
/**
* Run a non-MongoDB program quietly without output.
@ -158,7 +162,10 @@ declare function runNonMongoProgram(program: string, ...args: string[]): number
* @param args Command-line arguments
* @returns Exit code of the program
*/
declare function runNonMongoProgramQuietly(program: string, ...args: string[]): number
declare function runNonMongoProgramQuietly(
program: string,
...args: string[]
): number;
/**
* Run a program with arguments.
@ -167,7 +174,7 @@ declare function runNonMongoProgramQuietly(program: string, ...args: string[]):
* @param args Command-line arguments
* @returns Exit code of the program
*/
declare function runProgram(program: string, ...args: string[]): number
declare function runProgram(program: string, ...args: string[]): number;
/**
* Stop a program by PID.
@ -175,7 +182,7 @@ declare function runProgram(program: string, ...args: string[]): number
* @param pid Process ID to stop
* @param signal Optional signal number (default: SIGTERM/15)
*/
declare function stopMongoProgramByPid(pid: number, signal?: number): void
declare function stopMongoProgramByPid(pid: number, signal?: number): void;
/**
* Wait for a MongoDB program on the specified port to exit.
@ -183,7 +190,7 @@ declare function stopMongoProgramByPid(pid: number, signal?: number): void
* @param port Port number the MongoDB process is listening on
* @returns Exit code of the program
*/
declare function waitMongoProgram(port: number): number
declare function waitMongoProgram(port: number): number;
/**
* Wait for a program with the specified PID to exit.
@ -191,7 +198,7 @@ declare function waitMongoProgram(port: number): number
* @param pid Process ID to wait for
* @returns Exit code of the program
*/
declare function waitProgram(pid: number): number
declare function waitProgram(pid: number): number;
/**
* Replay a workload recording file against a MongoDB instance.
@ -199,4 +206,7 @@ declare function waitProgram(pid: number): number
* @param filename Path to the workload recording file
* @param connectionString Optional MongoDB connection string (default: localhost:27017)
*/
declare function replayWorkloadRecordingFile(filename: string, connectionString?: string): void
declare function replayWorkloadRecordingFile(
filename: string,
connectionString?: string,
): void;

View File

@ -17,7 +17,7 @@ declare class BSONAwareMap {}
* ISODate("2024-01-15") // midnight UTC
* ISODate() // current date/time
*/
declare function ISODate(isoDateStr?: string): Date
declare function ISODate(isoDateStr?: string): Date;
/**
* Check if a value is a number.
@ -26,7 +26,7 @@ declare function ISODate(isoDateStr?: string): Date
* @param x Value to check
* @returns True if x is a number type
*/
declare function isNumber(x: any): x is number
declare function isNumber(x: any): x is number;
/**
* Check if a value is an object.
@ -37,7 +37,7 @@ declare function isNumber(x: any): x is number
* @param x Value to check
* @returns True if x is an object type (including arrays and null)
*/
declare function isObject(x: any): x is object
declare function isObject(x: any): x is object;
/**
* Check if a value is a string.
@ -46,19 +46,19 @@ declare function isObject(x: any): x is object
* @param x Value to check
* @returns True if x is a string type
*/
declare function isString(x: any): x is string
declare function isString(x: any): x is string;
/**
* Print a value as formatted JSON to the console.
* Uses multi-line formatting with indentation for readability.
*
*
* A convenience for `print(tojson(x))`.
*
* @param x Value to print
*
* See {@link tojsononeline} for more.
*/
declare function printjson(x: any): void
declare function printjson(x: any): void;
/**
* Print a value as single-line JSON to the console.
@ -66,15 +66,15 @@ declare function printjson(x: any): void
*
* @param x Value to print
*/
declare function printjsononeline(x: any): void
declare function printjsononeline(x: any): void;
/**
* Convert a value to JSON string suitable for structured logging.
*
*
* The results of `toJsonForLog` and {@link tostrictjson} should be equal for BSON objects and arrays.
* Unlike {@link tostrictjson}, `toJsonForLog` also accepts non-object types, recognizes recursive
* objects, and provides more detailed serializations for commonly used JavaScript classes.
*
*
* Handles special JavaScript types that standard JSON.stringify doesn't:
* - undefined {"$undefined": true}
* - Error {"$error": message}
@ -84,11 +84,11 @@ declare function printjsononeline(x: any): void
*
* @param x Value to convert
* @returns JSON string suitable for logging systems
*
*
* Unlike {@link tojson}, the result of `eval(toJsonForLog(x))` will not always evaluate into an object
* equivalent to `x` and may throw a syntax error.
*/
declare function toJsonForLog(x: any): string
declare function toJsonForLog(x: any): string;
/**
* Convert a value to a JSON-formatted string.
@ -117,18 +117,30 @@ declare function toJsonForLog(x: any): string
* tojson(doc, "", true) // single-line output
* tojson(doc, "\t") // tab-indented
*/
declare function tojson(val, indent?: string = "", nolint?: any, depth?: number = 0, sortKeys?: boolean): string
declare function tojson(
val,
indent?: string = "",
nolint?: any,
depth?: number = 0,
sortKeys?: boolean,
): string;
/**
* Convert an object to a json-formatted string.
* Lower-level function used by {@link tojson}.
*/
declare function tojsonObject(obj: Object, indent: string = "", nolint: any, depth: number = 0, sortKeys: boolean = false): string
declare function tojsonObject(
obj: Object,
indent: string = "",
nolint: any,
depth: number = 0,
sortKeys: boolean = false,
): string;
/**
* Convert a value to a compact single-line JSON string.
* Shorthand for tojson(x, "", true).
*
*
* See {@link tojson} for more.
*/
declare function tojsononeline(x: any): string
declare function tojsononeline(x: any): string;