SERVER-101688: Add .d.ts typings for each global (#33063)

GitOrigin-RevId: 0214feb289748dd4ed9bf042719aa6e2e4cbac4d
This commit is contained in:
Steve McClure 2025-03-06 16:37:08 -05:00 committed by MongoDB Bot
parent 66acf9be3e
commit b602f90f7f
43 changed files with 795 additions and 205 deletions

View File

@ -18,227 +18,300 @@ export default [
...compat
.extends("eslint:recommended"),
{
ignores: ["src/mongo/gotools/*", "**/*.tpl.js", "jstests/third_party/**/*.js"],
ignores: [
"src/mongo/gotools/*",
"**/*.tpl.js",
"jstests/third_party/**/*.js",
],
},
{
languageOptions: {
globals: {
...globals.mongo,
// jstests/global.d.ts
TestData: true,
WriteError: true,
WriteCommandError: true,
BulkWriteError: true,
DB: true,
DBCollection: true,
DBQuery: true,
DBExplainQuery: true,
DBCommandCursor: true,
MongoBridge: true,
MongoURI: true,
WriteConcern: true,
SessionOptions: true,
CollInfos: true,
// jstests/libs/parallelTester.d.ts
CountDownLatch: true,
BSONAwareMap: true,
latestFCV: true,
lastLTSFCV: true,
lastContinuousFCV: true,
checkFCV: true,
isFCVEqual: true,
binVersionToFCV: true,
numVersionsSinceLastLTS: true,
getFCVConstants: true,
removeFCVDocument: true,
targetFCV: true,
// src/mongo/shell/assert.d.ts
assert: true,
doassert: true,
authutil: true,
tojson: true,
tojsononeline: true,
tostrictjson: true,
tojsonObject: true,
toJsonForLog: true,
print: true,
printjson: true,
printjsononeline: true,
jsTest: true,
jsTestLog: true,
jsonTestLog: true,
ErrorCodes: true,
ErrorCodeStrings: true,
checkProgram: true,
Random: true,
sortDoc: true,
// src/mongo/shell/bridge.d.ts
MongoBridge: true,
// src/mongo/shell/bulk_api.d.ts
BulkWriteError: true,
WriteCommandError: true,
WriteConcern: true,
WriteError: true,
// src/mongo/shell/check_log.d.ts
checkLog: true,
sleep: true,
resetDbpath: true,
copyDbpath: true,
jsTestName: true,
startParallelShell: true,
buildInfo: true,
getBuildInfo: true,
jsTestOptions: true,
printShardingStatus: true,
_getErrorWithCode: true,
isNetworkError: true,
__magicNoPrint: true,
computeSHA256Block: true,
emit: true,
_awaitRSHostViaRSMonitor: true,
convertShardKeyToHashed: true,
benchRun: true,
benchRunSync: true,
gc: true,
// src/mongo/shell/collection.d.ts
DBCollection: true,
// src/mongo/shell/data_consistency_checker.d.ts
CollInfos: true,
DataConsistencyChecker: true,
isNumber: true,
isObject: true,
isString: true,
stringifyErrorMessageAndAttributes: true,
_createSecurityToken: true,
_createTenantToken: true,
_isAddressSanitizerActive: true,
_isLeakSanitizerActive: true,
_isThreadSanitizerActive: true,
_isUndefinedBehaviorSanitizerActive: true,
_isSpiderMonkeyDebugEnabled: true,
_optimizationsEnabled: true,
// src/mongo/shell/db.d.ts
DB: true,
// src/mongo/shell/error_codes.d.ts
ErrorCodeStrings: true,
ErrorCodes: true,
// src/mongo/shell/explain_query.d.ts
DBExplainQuery: true,
// src/mongo/shell/explainable.d.ts
Explainable: true,
// src/mongo/shell/feature_compatibility_version.d.ts
binVersionToFCV: true,
checkFCV: true,
isFCVEqual: true,
lastContinuousFCV: true,
lastLTSFCV: true,
latestFCV: true,
numVersionsSinceLastLTS: true,
removeFCVDocument: true,
runFeatureFlagMultiversionTest: true,
targetFCV: true,
// src/mongo/shell/query.d.ts
DBQuery: true,
DBCommandCursor: true,
QueryHelpers: true,
___it___: true,
// src/mongo/shell/servers.d.ts
MongoRunner: true,
myPort: true,
runMongoProgram: true,
startMongoProgram: true,
startMongoProgramNoConnect: true,
// src/mongo/shell/servers_misc.d.ts
ToolTest: true,
allocatePort: true,
allocatePorts: true,
resetAllocatedPorts: true,
bsonObjToArray: true,
_writeTestPipeObjects: true,
_writeTestPipe: true,
_writeTestPipeBsonFile: true,
_readTestPipes: true,
runFeatureFlagMultiversionTest: true,
isRetryableError: true,
numberDecimalsAlmostEqual: true,
numberDecimalsEqual: true,
debug: true,
bsonsize: true,
startParallelShell: true,
testingReplication: true,
uncheckedParallelShellPidsString: true,
// src/mongo/shell/session.d.ts
DriverSession: true,
SessionOptions: true,
_DelegatingDriverSession: true,
_DummyDriverSession: true,
_ServerSession: true,
sortDoc: true,
executeNoThrowNetworkError: true,
_readDumpFile: true,
_openGoldenData: true,
_writeGoldenData: true,
_threadInject: true,
port: true,
// src/mongo/shell/shell_utils.d.ts
_buildBsonObj: true,
convertTrafficRecordingToBSON: true,
_setShellFailPoint: true,
shellHelper: true,
_srand: true,
_shouldUseImplicitSessions: true,
testingReplication: true,
myPort: true,
retryOnNetworkError: true,
getJSHeapLimitMB: true,
_getEnv: true,
indentStr: true,
_forgetReplSet: true,
_fnvHashToHexString: true,
_resultSetsEqualUnordered: true,
getStringWidth: true,
_closeGoldenData: true,
_compareStringsWithCollation: true,
_createSecurityToken: true,
_createTenantToken: true,
_fnvHashToHexString: true,
_isWindows: true,
_openGoldenData: true,
_rand: true,
_replMonitorStats: true,
_resultSetsEqualUnordered: true,
_setShellFailPoint: true,
_srand: true,
_writeGoldenData: true,
benchRun: true,
benchRunSync: true,
computeSHA256Block: true,
convertShardKeyToHashed: true,
fileExists: true,
getBuildInfo: true,
interpreterVersion: true,
isInteractive: true,
numberDecimalsAlmostEqual: true,
numberDecimalsEqual: true,
// src/mongo/shell/shell_utils_extended.d.ts
_copyFileRange: true,
_getEnv: true,
_readDumpFile: true,
appendFile: true,
copyDir: true,
copyFile: true,
decompressBSONColumn: true,
getFileMode: true,
getStringWidth: true,
passwordPrompt: true,
umask: true,
writeFile: true,
// src/mongo/shell/shell_utils_launcher.d.ts
_readTestPipes: true,
_runMongoProgram: true,
_runningMongoChildProcessIds: true,
_startMongoProgram: true,
_stopMongoProgram: true,
_writeTestPipe: true,
_writeTestPipeBsonFile: true,
_writeTestPipeBsonFileSync: true,
_writeTestPipeObjects: true,
checkProgram: true,
clearRawMongoProgramOutput: true,
convertTrafficRecordingToBSON: true,
copyDbpath: true,
getFCVConstants: true,
pathExists: true,
rawMongoProgramOutput: true,
resetDbpath: true,
run: true,
runNonMongoProgram: true,
runNonMongoProgramQuietly: true,
runProgram: true,
stopMongoProgramByPid: true,
waitMongoProgram: true,
waitProgram: true,
// src/mongo/shell/types.d.ts
BSONAwareMap: true,
isNumber: true,
isObject: true,
isString: true,
printjson: true,
printjsononeline: true,
stringifyErrorMessageAndAttributes: true,
toJsonForLog: true,
tojson: true,
tojsonObject: true,
tojsononeline: true,
// src/mongo/shell/utils.d.ts
Geo: true,
Random: true,
__autocomplete__: true,
__magicNoPrint: true,
__promptWrapper__: true,
__prompt__: true,
__quiet: true,
_awaitRSHostViaRSMonitor: true,
_barFormat: true,
_getErrorWithCode: true,
_isSpiderMonkeyDebugEnabled: true,
_originalPrint: true,
_shouldRetryWrites: true,
_shouldUseImplicitSessions: true,
_validateMemberIndex: true,
_verboseShell: true,
chatty: true,
compare: true,
compareOn: true,
defaultPrompt: true,
disablePrint: true,
enablePrint: true,
executeNoThrowNetworkError: true,
friendlyEqual: true,
hasErrorCode: true,
helloStatePrompt: true,
help: true,
indentStr: true,
isNetworkError: true,
isRetryableError: true,
jsTest: true,
jsTestOptions: true,
jsTestLog: true,
jsonTestLog: true,
jsTestName: true,
printStackTrace: true,
replSetMemberStatePrompt: true,
retryOnNetworkError: true,
retryOnRetryableError: true,
shellAutocomplete: true,
shellHelper: true,
shellPrint: true,
shellPrintHelper: true,
setVerboseShell: true,
timestampCmp: true,
// src/mongo/shell/utils_auth.d.ts
authutil: true,
// src/mongo/shell/utils_sh.d.ts
printShardingStatus: true,
// src/mongo/scripting/mozjs/bindata.d.ts
BinData: true,
HexData: true,
MD5: true,
// src/mongo/scripting/mozjs/bson.d.ts
bsonBinaryEqual: true,
bsonObjToArray: true,
bsonUnorderedFieldsCompare: true,
bsonWoCompare: true,
// src/mongo/scripting/mozjs/code.d.ts
Code: true,
// src/mongo/scripting/mozjs/dbpointer.d.ts
DBPointer: true,
// src/mongo/scripting/mozjs/dbref.d.ts
DBRef: true,
// src/mongo/scripting/mozjs/global.d.ts
buildInfo: true,
gc: true,
getJSHeapLimitMB: true,
print: true,
sleep: true,
// src/mongo/scripting/mozjs/jsthread.d.ts
_threadInject: true,
// src/mongo/scripting/mozjs/maxkey.d.ts
MaxKey: true,
// src/mongo/scripting/mozjs/minkey.d.ts
MinKey: true,
// src/mongo/scripting/mozjs/mongo.d.ts
_forgetReplSet: true,
// src/mongo/scripting/mozjs/numberdecimal.d.ts
NumberDecimal: true,
// src/mongo/scripting/mozjs/numberlong.d.ts
NumberLong: true,
// src/mongo/scripting/mozjs/object.d.ts
bsonsize: true,
// src/mongo/scripting/mozjs/resumetoken.d.ts
decodeResumeToken: true,
eventResumeTokenType: true,
highWaterMarkResumeTokenType: true,
// likely could be replaced with `path`
_copyFileRange: true,
appendFile: true,
copyFile: true,
writeFile: true,
fileExists: true,
pathExists: true,
umask: true,
getFileMode: true,
copyDir: true,
// likely could be replaced with `child_process`
MongoRunner: true,
run: true,
runProgram: true,
runMongoProgram: true,
runNonMongoProgram: true,
runNonMongoProgramQuietly: true,
_runMongoProgram: true,
_startMongoProgram: true,
startMongoProgram: true,
_stopMongoProgram: true,
stopMongoProgramByPid: true,
clearRawMongoProgramOutput: true,
rawMongoProgramOutput: true,
waitProgram: true,
waitMongoProgram: true,
_runningMongoChildProcessIds: true,
startMongoProgramNoConnect: true,
// shell-specific
shellPrintHelper: true,
shellAutocomplete: true,
__autocomplete__: true,
defaultPrompt: true,
___it___: true,
__promptWrapper__: true,
passwordPrompt: true,
isInteractive: true,
// built-in BSON types and helpers
Code: true,
MaxKey: true,
MinKey: true,
HexData: true,
DBPointer: true,
DBRef: true,
BinData: true,
NumberLong: true,
NumberDecimal: true,
// src/mongo/scripting/mozjs/timestamp.d.ts
Timestamp: true,
MD5: true,
Geo: true,
decodeResumeToken: true,
bsonWoCompare: true,
bsonUnorderedFieldsCompare: true,
bsonBinaryEqual: true,
friendlyEqual: true,
timestampCmp: true,
decompressBSONColumn: true,
// src/mongo/scripting/mozjs/uri.d.ts
MongoURI: true,
// src/mongo/scripting/utils.d.ts
hex_md5: true,
QueryHelpers: true,
chatty: true,
DriverSession: true,
ToolTest: true,
uncheckedParallelShellPidsString: true,
_shouldRetryWrites: true,
tostrictjson: true,
// from_cpp:
__prompt__: true,
_replMonitorStats: true,
// explainable.js
Explainable: true,
// utils.js
_verboseShell: true,
__quiet: true,
printStackTrace: true,
setVerboseShell: true,
_barFormat: true,
compare: true,
compareOn: true,
shellPrint: true,
_originalPrint: true,
disablePrint: true,
enablePrint: true,
replSetMemberStatePrompt: true,
hasErrorCode: true,
helloStatePrompt: true,
_validateMemberIndex: true,
help: true,
retryOnRetryableError: true,
// TODO: where are these defined?
debug: true,
emit: true,
port: true,
},
ecmaVersion: 2022,

View File

@ -6,6 +6,8 @@
},
"include": [
"jstests/**/*.js",
"jstests/**/*.d.ts",
"src/mongo/scripting/**/*.d.ts",
"src/mongo/shell/*.js",
"src/mongo/shell/*.d.ts",
"src/third_party/fast_check/**/*"

3
jstests/global.d.ts vendored Normal file
View File

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

7
jstests/libs/parallelTester.d.ts vendored Normal file
View File

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

View File

@ -0,0 +1,5 @@
// type declarations for bindata.h
declare class BinData {}
declare class HexData {}
declare class MD5 {}

6
src/mongo/scripting/mozjs/bson.d.ts vendored Normal file
View File

@ -0,0 +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

3
src/mongo/scripting/mozjs/code.d.ts vendored Normal file
View File

@ -0,0 +1,3 @@
// type declarations for code.h
declare class Code {}

View File

@ -0,0 +1,3 @@
// type declarations for dbpointer.h
declare class DBPointer {}

3
src/mongo/scripting/mozjs/dbref.d.ts vendored Normal file
View File

@ -0,0 +1,3 @@
// type declarations for dbref.h
declare class DBRef {}

7
src/mongo/scripting/mozjs/global.d.ts vendored Normal file
View File

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

View File

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

3
src/mongo/scripting/mozjs/maxkey.d.ts vendored Normal file
View File

@ -0,0 +1,3 @@
// type declarations for maxkey.h
declare class MaxKey {}

3
src/mongo/scripting/mozjs/minkey.d.ts vendored Normal file
View File

@ -0,0 +1,3 @@
// type declarations for minkey.h
declare class MinKey {}

3
src/mongo/scripting/mozjs/mongo.d.ts vendored Normal file
View File

@ -0,0 +1,3 @@
// type declarations for mongo.h
declare function _forgetReplSet()

View File

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

View File

@ -0,0 +1,3 @@
// type declarations for numberlong.h
declare class NumberLong {}

3
src/mongo/scripting/mozjs/object.d.ts vendored Normal file
View File

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

View File

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

View File

@ -0,0 +1,3 @@
// type declarations for timestamp.h
declare class Timestamp {}

3
src/mongo/scripting/mozjs/uri.d.ts vendored Normal file
View File

@ -0,0 +1,3 @@
// type declarations for uri.h
declare class MongoURI {}

4
src/mongo/scripting/utils.d.ts vendored Normal file
View File

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

View File

@ -31,6 +31,8 @@ declare function doassert(
})
: never
declare function sortDoc()
declare module assert {
/**

5
src/mongo/shell/bridge.d.ts vendored Normal file
View File

@ -0,0 +1,5 @@
// type declarations for bridge.js
declare class MongoBridge {
}

20
src/mongo/shell/check_log.d.ts vendored Normal file
View File

@ -0,0 +1,20 @@
// type declarations for check_log.js
declare module checkLog {
function getGlobalLog()
function getLogMessage()
function checkContainsOnce()
function checkContainsOnceJson()
function checkContainsWithCountJson()
function checkContainsWithAtLeastCountJson()
function checkContainsOnceJsonStringMatch()
function contains()
function containsLog()
function containsJson()
function containsRelaxedJson()
function containsWithCount()
function containsWithAtLeastCount()
function formatAsLogLine()
function formatAsJsonLogLine()
function getFilteredLogMessages()
}

77
src/mongo/shell/collection.d.ts vendored Normal file
View File

@ -0,0 +1,77 @@
// type declarations for collection.js
declare class DBCollection {
constructor(mongo, db, shortName, fullName);
insert(opts)
compact(extra = {})
cleanup(extra = {})
verify()
getName()
help()
getFullName()
getMongo()
getDB()
find(filter, projection, limit, skip, batchSize, options)
insert(obj, options)
remove(t, justOne)
update(query, updateSpec, upsert, multi)
save(obj, opts)
createIndex(keys, options, commitQuorum)
createIndexes(keys, options, commitQuorum)
reIndex()
dropIndexes(indexNames)
drop(options = {})
findAndModify(args)
renameCollection(newName, dropTarget)
validate(options)
getShardVersion()
getIndexes()
getIndexKeys()
hashAllDocs()
dropIndex(index)
hideIndex(index)
unhideIndex(index)
getCollection(subName)
stats(args)
dataSize()
storageSize()
totalIndexSize(verbose)
totalSize()
convertToCapped(bytes)
getMetadata()
exists()
isCapped()
getUUID()
aggregate(pipeline, aggregateOptions)
convertToSingleObject(valueField)
mapReduce(map, reduce, optionsOrOutString)
toString()
tojson =toString;
shellPrint =toString;
getShardDistribution()
getShardKey()
getSplitKeysForChunks(chunkSize)
enableBalancing()
disableBalancing()
setSlaveOk(value)
getSlaveOk()
setSecondaryOk(value = true)
getSecondaryOk()
getQueryOptions()
getPlanCache()
setWriteConcern(wc)
getWriteConcern()
unsetWriteConcern()
disableAutoMerger()
enableAutoMerger()
count(query, options)
countDocuments(query, options)
estimatedDocumentCount(options)
distinct(keyString, query, options)
latencyStats(options)
watch(pipeline, options)
checkMetadataConsistency(options = {})
}

View File

@ -0,0 +1,4 @@
// type declarations for data_consistency_checker.js
declare class CollInfos {}
declare module DataConsistencyChecker {}

104
src/mongo/shell/db.d.ts vendored Normal file
View File

@ -0,0 +1,104 @@
// type declarations for db.js
declare class DB {
constructor(mongo: Mongo, name: string);
getMongo(): Mongo
getName(): string
/**
* Dynamic property to produce a DBCollection.
*
* @example
* let coll1 = db[jsTestName()];
* let coll2 = db.anotherCollectionUnderTest;
*/
[collectionIndex: string]: DBCollection
rotateCertificates(message)
getMongo()
getSiblingDB(name)
getName()
stats(opt)
getCollection(name)
commandHelp(name)
runReadCommand()
runCommand(obj, extra, queryOptions)
adminCommand(obj, extra)
aggregate(pipeline, aggregateOptions)
createCollection(name, opt)
createView(name, viewOn, pipeline, opt)
getProfilingLevel()
getProfilingStatus()
dropDatabase(writeConcern)
shutdownServer(opts)
help()
printCollectionStats(scale)
setProfilingLevel(level, options)
eval(jsfunction)
groupeval(parmsObj)
forceError()
getCollectionNames()
tojson()
toString()
isMaster()
hello()
currentOp(arg)
currentOpCursor(arg)
killOp(op)
getReplicationInfo()
printReplicationInfo()
printSlaveReplicationInfo()
printSecondaryReplicationInfo()
serverBuildInfo()
serverStatus(options)
hostInfo()
serverCmdLineOpts()
version()
serverBits()
listCommands()
printShardingStatus(verbose)
fsyncLock()
fsyncUnlock()
setSlaveOk(value = true)
getSlaveOk()
setSecondaryOk(value = true)
getSecondaryOk()
getQueryOptions()
loadServerScripts()
createUser(userObj, writeConcern)
updateUser(name, updateObject, writeConcern)
changeUserPassword(username, password, writeConcern)
logout()
removeUser(username, writeConcern)
dropUser(username, writeConcern)
dropAllUsers(writeConcern)
auth()
grantRolesToUser(username, roles, writeConcern)
revokeRolesFromUser(username, roles, writeConcern)
getUser(username, args)
getUsers(args)
createRole(roleObj, writeConcern)
updateRole(name, updateObject, writeConcern)
dropRole(name, writeConcern)
dropAllRoles(writeConcern)
grantRolesToRole(rolename, roles, writeConcern)
revokeRolesFromRole(rolename, roles, writeConcern)
grantPrivilegesToRole(rolename, privileges, writeConcern)
revokePrivilegesFromRole(rolename, privileges, writeConcern)
getRole(rolename, args)
getRoles(args)
setWriteConcern(wc)
getWriteConcern()
unsetWriteConcern()
getLogComponents()
setLogLevel(logLevel, component)
watch(pipeline, options)
getSession()
createEncryptedCollection(name, opts)
dropEncryptedCollection(name)
checkMetadataConsistency(options = {})
getDatabasePrimaryShardId()
getServerBuildInfo()
}

4
src/mongo/shell/error_codes.d.ts vendored Normal file
View File

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

3
src/mongo/shell/explain_query.d.ts vendored Normal file
View File

@ -0,0 +1,3 @@
// type declarations for explain_query.js
declare class DBExplainQuery {}

3
src/mongo/shell/explainable.d.ts vendored Normal file
View File

@ -0,0 +1,3 @@
// type declarations for explainable.js
declare module Explainable {}

View File

@ -0,0 +1,12 @@
// type declarations for feature_compatibility_version.js
declare function binVersionToFCV()
declare function checkFCV()
declare function isFCVEqual()
declare function lastContinuousFCV()
declare function lastLTSFCV()
declare function latestFCV()
declare function numVersionsSinceLastLTS()
declare function removeFCVDocument()
declare function runFeatureFlagMultiversionTest()
declare function targetFCV()

45
src/mongo/shell/mongo.d.ts vendored Normal file
View File

@ -0,0 +1,45 @@
// type declarations for mongo.js
declare class Mongo {
constructor(uri?: string, encryptedDBClientCallback?, options?: object)
getDB(name): DB
startSession(opts?): DriverSession
find(ns, query, fields, limit, skip, batchSize, options)
insert(ns, obj)
remove(ns, pattern)
update(ns, query, obj, upsert)
setSlaveOk(value)
getSlaveOk()
setSecondaryOk(value = true)
getSecondaryOk()
getDB(name)
getDBs(driverSession)
adminCommand(cmd)
runCommand(dbname, cmd, options)
getLogComponents(driverSession)
setLogLevel()
getDBNames()
getCollection(ns)
toString()
tojson()
setReadPref(mode, tagSet)
getReadPrefMode()
getReadPrefTagSet()
getReadPref()
setReadConcern(level)
getReadConcern()
setWriteConcern(wc)
getWriteConcern()
unsetWriteConcern()
advanceClusterTime(newTime)
resetClusterTime_forTesting()
getClusterTime()
startSession(options = {})
isCausalConsistency()
setCausalConsistency(causalConsistency = true)
waitForClusterTime(maxRetries = 10)
watch(pipeline, options)
}

6
src/mongo/shell/query.d.ts vendored Normal file
View File

@ -0,0 +1,6 @@
// type declarations for query.js
declare module DBQuery {}
declare class DBCommandCursor {}
declare module QueryHelpers {}
declare var ___it___

11
src/mongo/shell/servers.d.ts vendored Normal file
View File

@ -0,0 +1,11 @@
// type declarations for servers.js
declare module MongoRunner {
export function runMongod(opts?: object): Mongo
export function stopMongod(connection: Mongo): void
}
declare function myPort()
declare function runMongoProgram()
declare function startMongoProgram()
declare function startMongoProgramNoConnect()

9
src/mongo/shell/servers_misc.d.ts vendored Normal file
View File

@ -0,0 +1,9 @@
// type declarations for servers_misc.js
declare function ToolTest()
declare function allocatePort()
declare function allocatePorts()
declare function resetAllocatedPorts()
declare function startParallelShell()
declare var testingReplication
declare function uncheckedParallelShellPidsString()

7
src/mongo/shell/session.d.ts vendored Normal file
View File

@ -0,0 +1,7 @@
// type declarations for session.js
declare class DriverSession {}
declare class SessionOptions {}
declare class _DelegatingDriverSession {}
declare class _DummyDriverSession {}
declare class _ServerSession {}

26
src/mongo/shell/shell_utils.d.ts vendored Normal file
View File

@ -0,0 +1,26 @@
// type declarations for shell_utils.h
declare function _buildBsonObj()
declare function _closeGoldenData()
declare function _compareStringsWithCollation()
declare function _createSecurityToken()
declare function _createTenantToken()
declare function _fnvHashToHexString()
declare function _isWindows()
declare function _openGoldenData()
declare function _rand()
declare function _replMonitorStats()
declare function _resultSetsEqualUnordered()
declare function _setShellFailPoint()
declare function _srand()
declare function _writeGoldenData()
declare function benchRun()
declare function benchRunSync()
declare function computeSHA256Block()
declare function convertShardKeyToHashed()
declare function fileExists()
declare function getBuildInfo()
declare function interpreterVersion()
declare function isInteractive()
declare function numberDecimalsAlmostEqual()
declare function numberDecimalsEqual()

View File

@ -0,0 +1,14 @@
// type declarations for shell_utils_extended.h
declare function _copyFileRange()
declare function _getEnv()
declare function _readDumpFile()
declare function appendFile()
declare function copyDir()
declare function copyFile()
declare function decompressBSONColumn()
declare function getFileMode()
declare function getStringWidth()
declare function passwordPrompt()
declare function umask()
declare function writeFile()

View File

@ -0,0 +1,26 @@
// type declarations for shell_utils_launcher.h
declare function _readTestPipes()
declare function _runMongoProgram()
declare function _runningMongoChildProcessIds()
declare function _startMongoProgram()
declare function _stopMongoProgram()
declare function _writeTestPipe()
declare function _writeTestPipeBsonFile()
declare function _writeTestPipeBsonFileSync()
declare function _writeTestPipeObjects()
declare function checkProgram()
declare function clearRawMongoProgramOutput()
declare function convertTrafficRecordingToBSON()
declare function copyDbpath()
declare function getFCVConstants()
declare function pathExists()
declare function rawMongoProgramOutput()
declare function resetDbpath()
declare function run()
declare function runNonMongoProgram()
declare function runNonMongoProgramQuietly()
declare function runProgram()
declare function stopMongoProgramByPid()
declare function waitMongoProgram()
declare function waitProgram()

13
src/mongo/shell/types.d.ts vendored Normal file
View File

@ -0,0 +1,13 @@
// type declarations for types.js
declare class BSONAwareMap {}
declare function isNumber()
declare function isObject()
declare function isString()
declare function printjson()
declare function printjsononeline()
declare function stringifyErrorMessageAndAttributes()
declare function toJsonForLog()
declare function tojson()
declare function tojsonObject()
declare function tojsononeline()

View File

@ -1,12 +1,54 @@
// type declarations for utils.js
declare {
/**
* Returns the name of the current jsTest to be used as an identifier.
* This may be prefixed and/or hashed to improve traceability.
*
* @example
* const coll = db[jsTestName()];
*/
export function jsTestName(): string
}
declare module Geo {}
declare module Random {}
declare function __autocomplete__()
declare function __magicNoPrint()
declare function __promptWrapper__()
declare function __prompt__()
declare function __quiet()
declare function _awaitRSHostViaRSMonitor()
declare function _barFormat()
declare function _getErrorWithCode()
declare function _isSpiderMonkeyDebugEnabled()
declare function _originalPrint()
declare function _shouldRetryWrites()
declare function _shouldUseImplicitSessions()
declare function _validateMemberIndex()
declare function _verboseShell()
declare function chatty()
declare function compare()
declare function compareOn()
declare function defaultPrompt()
declare function disablePrint()
declare function enablePrint()
declare function executeNoThrowNetworkError()
declare function friendlyEqual()
declare function hasErrorCode()
declare function helloStatePrompt()
declare function help()
declare function indentStr()
declare function isNetworkError()
declare function isRetryableError()
declare function jsTest()
declare function jsTestOptions()
declare function jsTestLog()
declare function jsonTestLog()
/**
* Returns the name of the current jsTest to be used as an identifier.
* This may be prefixed and/or hashed to improve traceability.
*
* @example
* const coll = db[jsTestName()];
*/
declare function jsTestName(): string
declare function printStackTrace()
declare function replSetMemberStatePrompt()
declare function retryOnNetworkError()
declare function retryOnRetryableError()
declare function shellAutocomplete()
declare module shellHelper {}
declare function shellPrint()
declare function shellPrintHelper()
declare function setVerboseShell()
declare function timestampCmp()

3
src/mongo/shell/utils_auth.d.ts vendored Normal file
View File

@ -0,0 +1,3 @@
// type declarations for utils_auth.js
declare module authutil {}

3
src/mongo/shell/utils_sh.d.ts vendored Normal file
View File

@ -0,0 +1,3 @@
// type declarations for utils_sh.js
declare function printShardingStatus()