oxygen-cli 1.40.1 → 1.40.2-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1742 -1742
- package/LICENSE +672 -672
- package/README.md +37 -37
- package/build/core/OxygenCore.js +1 -1
- package/build/core/OxygenEvents.js +1 -1
- package/build/core/OxygenModule.js +1 -1
- package/build/core/OxygenService.js +1 -1
- package/build/core/OxygenSubModule.js +1 -1
- package/build/core/WebDriverModule.js +1 -1
- package/build/core/utils.js +1 -1
- package/build/errors/HookError.js +1 -1
- package/build/errors/ModuleError.js +1 -1
- package/build/errors/ModuleUnavailableError.js +1 -1
- package/build/errors/OxygenError.js +1 -1
- package/build/errors/ScriptNotFound.js +1 -1
- package/build/errors/helper.js +2 -1
- package/build/index.js +1 -1
- package/build/lib/cli-util.js +5 -1
- package/build/lib/debugger.js +1 -1
- package/build/lib/img-merge.js +1 -1
- package/build/lib/launcher.js +1 -1
- package/build/lib/logger.js +43 -43
- package/build/lib/moduleRequire.js +1 -1
- package/build/lib/parallel-launcher.js +1 -1
- package/build/lib/param-manager.js +1 -1
- package/build/lib/param-reader-csv.js +1 -1
- package/build/lib/param-reader-excel.js +1 -1
- package/build/lib/param-reader-json.js +1 -1
- package/build/lib/text-to-image.js +1 -1
- package/build/lib/util.js +1 -1
- package/build/model/case-result.js +1 -1
- package/build/model/failure.js +1 -1
- package/build/model/status.js +1 -1
- package/build/model/step-result.js +1 -1
- package/build/model/suite-result.js +1 -1
- package/build/model/test-result.js +1 -1
- package/build/model/testcase.js +1 -1
- package/build/model/testsuite.js +1 -1
- package/build/ox_modules/index.js +9 -1
- package/build/ox_modules/module-assert.js +37 -37
- package/build/ox_modules/module-date.js +24 -24
- package/build/ox_modules/module-db.js +52 -52
- package/build/ox_modules/module-email.js +59 -59
- package/build/ox_modules/module-eyes.js +34 -34
- package/build/ox_modules/module-http/ntlm-util.js +10 -10
- package/build/ox_modules/module-http/ntlm.js +15 -15
- package/build/ox_modules/module-http.js +132 -132
- package/build/ox_modules/module-log.js +27 -27
- package/build/ox_modules/module-mailinator.js +87 -87
- package/build/ox_modules/module-mob/commands/alertAccept.js +17 -17
- package/build/ox_modules/module-mob/commands/alertDismiss.js +17 -17
- package/build/ox_modules/module-mob/commands/assertAlert.js +20 -20
- package/build/ox_modules/module-mob/commands/assertText.js +21 -21
- package/build/ox_modules/module-mob/commands/assertTitle.js +19 -19
- package/build/ox_modules/module-mob/commands/assertValue.js +18 -18
- package/build/ox_modules/module-mob/commands/back.js +16 -16
- package/build/ox_modules/module-mob/commands/clear.js +19 -19
- package/build/ox_modules/module-mob/commands/click.js +17 -17
- package/build/ox_modules/module-mob/commands/clickHidden.js +17 -17
- package/build/ox_modules/module-mob/commands/clickLong.js +18 -18
- package/build/ox_modules/module-mob/commands/clickMultipleTimes.js +18 -18
- package/build/ox_modules/module-mob/commands/closeApp.js +16 -16
- package/build/ox_modules/module-mob/commands/debug.js +16 -16
- package/build/ox_modules/module-mob/commands/dragAndDrop.js +19 -19
- package/build/ox_modules/module-mob/commands/enableNetwork.js +27 -27
- package/build/ox_modules/module-mob/commands/execute.js +21 -21
- package/build/ox_modules/module-mob/commands/findElement.js +20 -20
- package/build/ox_modules/module-mob/commands/findElements.js +23 -23
- package/build/ox_modules/module-mob/commands/getAlertText.js +17 -17
- package/build/ox_modules/module-mob/commands/getAppiumLogs.js +16 -16
- package/build/ox_modules/module-mob/commands/getBrowserLogs.js +16 -16
- package/build/ox_modules/module-mob/commands/getCurrentActivity.js +15 -15
- package/build/ox_modules/module-mob/commands/getCurrentPackage.js +15 -15
- package/build/ox_modules/module-mob/commands/getDeviceLogs.js +16 -16
- package/build/ox_modules/module-mob/commands/getDeviceTime.js +16 -16
- package/build/ox_modules/module-mob/commands/getLocation.js +20 -20
- package/build/ox_modules/module-mob/commands/getSource.js +16 -16
- package/build/ox_modules/module-mob/commands/getText.js +18 -18
- package/build/ox_modules/module-mob/commands/getTitle.js +13 -13
- package/build/ox_modules/module-mob/commands/getUrl.js +17 -17
- package/build/ox_modules/module-mob/commands/getValue.js +18 -18
- package/build/ox_modules/module-mob/commands/getWindowHandles.js +17 -17
- package/build/ox_modules/module-mob/commands/hideKeyboard.js +21 -21
- package/build/ox_modules/module-mob/commands/index.js +1 -1
- package/build/ox_modules/module-mob/commands/installApp.js +16 -16
- package/build/ox_modules/module-mob/commands/isAppInstalled.js +16 -16
- package/build/ox_modules/module-mob/commands/isCheckable.js +18 -18
- package/build/ox_modules/module-mob/commands/isChecked.js +18 -18
- package/build/ox_modules/module-mob/commands/isClickable.js +18 -18
- package/build/ox_modules/module-mob/commands/isExist.js +19 -19
- package/build/ox_modules/module-mob/commands/isSelected.js +23 -23
- package/build/ox_modules/module-mob/commands/isVisible.js +19 -19
- package/build/ox_modules/module-mob/commands/isWebViewContext.js +16 -16
- package/build/ox_modules/module-mob/commands/launchApp.js +15 -15
- package/build/ox_modules/module-mob/commands/longPressKeyCode.js +18 -18
- package/build/ox_modules/module-mob/commands/open.js +17 -17
- package/build/ox_modules/module-mob/commands/pause.js +16 -16
- package/build/ox_modules/module-mob/commands/removeApp.js +16 -16
- package/build/ox_modules/module-mob/commands/resetApp.js +15 -15
- package/build/ox_modules/module-mob/commands/scrollIntoElement.js +22 -22
- package/build/ox_modules/module-mob/commands/scrollIntoView.js +27 -27
- package/build/ox_modules/module-mob/commands/select.js +24 -24
- package/build/ox_modules/module-mob/commands/selectFrame.js +23 -23
- package/build/ox_modules/module-mob/commands/selectWindow.js +28 -28
- package/build/ox_modules/module-mob/commands/sendKeys.js +29 -29
- package/build/ox_modules/module-mob/commands/setContext.js +16 -16
- package/build/ox_modules/module-mob/commands/setNativeContext.js +15 -15
- package/build/ox_modules/module-mob/commands/setTimeout.js +21 -21
- package/build/ox_modules/module-mob/commands/setWebViewContext.js +16 -16
- package/build/ox_modules/module-mob/commands/shake.js +16 -16
- package/build/ox_modules/module-mob/commands/smsClickLink.js +19 -19
- package/build/ox_modules/module-mob/commands/smsGetText.js +20 -20
- package/build/ox_modules/module-mob/commands/swipe.js +20 -20
- package/build/ox_modules/module-mob/commands/swipeElement.js +20 -20
- package/build/ox_modules/module-mob/commands/swipeScreen.js +20 -20
- package/build/ox_modules/module-mob/commands/takeScreenshot.js +17 -17
- package/build/ox_modules/module-mob/commands/tap.js +17 -17
- package/build/ox_modules/module-mob/commands/type.js +20 -20
- package/build/ox_modules/module-mob/commands/unlockPattern.js +22 -22
- package/build/ox_modules/module-mob/commands/waitForExist.js +18 -18
- package/build/ox_modules/module-mob/commands/waitForInteractable.js +17 -17
- package/build/ox_modules/module-mob/commands/waitForVisible.js +17 -17
- package/build/ox_modules/module-mob.js +74 -74
- package/build/ox_modules/module-mongo.js +302 -0
- package/build/ox_modules/module-pdf.js +35 -35
- package/build/ox_modules/module-proxy.js +77 -77
- package/build/ox_modules/module-serial.js +55 -55
- package/build/ox_modules/module-shell.js +25 -25
- package/build/ox_modules/module-soap.js +72 -72
- package/build/ox_modules/module-twilio.js +41 -41
- package/build/ox_modules/module-utils.js +91 -91
- package/build/ox_modules/module-web/commands/alertAccept.js +17 -17
- package/build/ox_modules/module-web/commands/alertDismiss.js +17 -17
- package/build/ox_modules/module-web/commands/assertAlert.js +20 -20
- package/build/ox_modules/module-web/commands/assertExist.js +17 -17
- package/build/ox_modules/module-web/commands/assertSelectedLabel.js +21 -21
- package/build/ox_modules/module-web/commands/assertSelectedValue.js +21 -21
- package/build/ox_modules/module-web/commands/assertText.js +21 -21
- package/build/ox_modules/module-web/commands/assertTextNotPresent.js +18 -18
- package/build/ox_modules/module-web/commands/assertTextPresent.js +18 -18
- package/build/ox_modules/module-web/commands/assertTitle.js +19 -19
- package/build/ox_modules/module-web/commands/assertValue.js +20 -20
- package/build/ox_modules/module-web/commands/back.js +16 -16
- package/build/ox_modules/module-web/commands/clear.js +18 -18
- package/build/ox_modules/module-web/commands/click.js +25 -25
- package/build/ox_modules/module-web/commands/clickHidden.js +23 -23
- package/build/ox_modules/module-web/commands/closeWindow.js +15 -15
- package/build/ox_modules/module-web/commands/debug.js +15 -15
- package/build/ox_modules/module-web/commands/deleteCookies.js +12 -12
- package/build/ox_modules/module-web/commands/deselect.js +22 -22
- package/build/ox_modules/module-web/commands/doubleClick.js +17 -17
- package/build/ox_modules/module-web/commands/dragAndDrop.js +20 -20
- package/build/ox_modules/module-web/commands/execute.js +24 -24
- package/build/ox_modules/module-web/commands/fileBrowse.js +18 -18
- package/build/ox_modules/module-web/commands/findElement.js +19 -19
- package/build/ox_modules/module-web/commands/findElements.js +22 -22
- package/build/ox_modules/module-web/commands/fullscreenWindow.js +14 -14
- package/build/ox_modules/module-web/commands/getAlertText.js +16 -16
- package/build/ox_modules/module-web/commands/getAttribute.js +19 -19
- package/build/ox_modules/module-web/commands/getBrowserLogs.js +17 -17
- package/build/ox_modules/module-web/commands/getCookies.js +13 -13
- package/build/ox_modules/module-web/commands/getCssValue.js +19 -19
- package/build/ox_modules/module-web/commands/getElementCount.js +17 -17
- package/build/ox_modules/module-web/commands/getHTML.js +17 -17
- package/build/ox_modules/module-web/commands/getSource.js +16 -16
- package/build/ox_modules/module-web/commands/getText.js +18 -18
- package/build/ox_modules/module-web/commands/getTitle.js +12 -12
- package/build/ox_modules/module-web/commands/getUrl.js +16 -16
- package/build/ox_modules/module-web/commands/getValue.js +18 -18
- package/build/ox_modules/module-web/commands/getWindowHandles.js +16 -16
- package/build/ox_modules/module-web/commands/getWindowSize.js +16 -16
- package/build/ox_modules/module-web/commands/getXMLPageSource.js +16 -16
- package/build/ox_modules/module-web/commands/index.js +1 -1
- package/build/ox_modules/module-web/commands/isAlertPresent.js +16 -16
- package/build/ox_modules/module-web/commands/isChecked.js +18 -18
- package/build/ox_modules/module-web/commands/isExist.js +19 -19
- package/build/ox_modules/module-web/commands/isInteractable.js +22 -22
- package/build/ox_modules/module-web/commands/isSelected.js +23 -23
- package/build/ox_modules/module-web/commands/isVisible.js +19 -19
- package/build/ox_modules/module-web/commands/makeVisible.js +25 -25
- package/build/ox_modules/module-web/commands/maximizeWindow.js +14 -14
- package/build/ox_modules/module-web/commands/minimizeWindow.js +14 -14
- package/build/ox_modules/module-web/commands/mock.js +20 -20
- package/build/ox_modules/module-web/commands/mockClearAll.js +12 -12
- package/build/ox_modules/module-web/commands/mockRestoreAll.js +12 -12
- package/build/ox_modules/module-web/commands/newWindow.js +16 -16
- package/build/ox_modules/module-web/commands/open.js +16 -16
- package/build/ox_modules/module-web/commands/pause.js +15 -15
- package/build/ox_modules/module-web/commands/point.js +21 -21
- package/build/ox_modules/module-web/commands/pointJS.js +15 -15
- package/build/ox_modules/module-web/commands/refresh.js +15 -15
- package/build/ox_modules/module-web/commands/rightClick.js +17 -17
- package/build/ox_modules/module-web/commands/rightClickActions.js +19 -19
- package/build/ox_modules/module-web/commands/scrollToElement.js +21 -21
- package/build/ox_modules/module-web/commands/select.js +23 -23
- package/build/ox_modules/module-web/commands/selectFrame.js +24 -24
- package/build/ox_modules/module-web/commands/selectWindow.js +27 -27
- package/build/ox_modules/module-web/commands/sendKeys.js +22 -22
- package/build/ox_modules/module-web/commands/setAutoWaitForAngular.js +20 -20
- package/build/ox_modules/module-web/commands/setTimeout.js +21 -21
- package/build/ox_modules/module-web/commands/setWindowSize.js +17 -17
- package/build/ox_modules/module-web/commands/takeScreenshot.js +17 -17
- package/build/ox_modules/module-web/commands/type.js +20 -20
- package/build/ox_modules/module-web/commands/verifyAlert.js +20 -20
- package/build/ox_modules/module-web/commands/verifyExist.js +17 -17
- package/build/ox_modules/module-web/commands/verifySelectedLabel.js +21 -21
- package/build/ox_modules/module-web/commands/verifySelectedValue.js +21 -21
- package/build/ox_modules/module-web/commands/verifyText.js +21 -21
- package/build/ox_modules/module-web/commands/verifyTextNotPresent.js +18 -18
- package/build/ox_modules/module-web/commands/verifyTextPresent.js +18 -18
- package/build/ox_modules/module-web/commands/verifyTitle.js +19 -19
- package/build/ox_modules/module-web/commands/verifyValue.js +20 -20
- package/build/ox_modules/module-web/commands/waitForAngular.js +19 -19
- package/build/ox_modules/module-web/commands/waitForExist.js +17 -17
- package/build/ox_modules/module-web/commands/waitForInteractable.js +17 -17
- package/build/ox_modules/module-web/commands/waitForNotExist.js +17 -17
- package/build/ox_modules/module-web/commands/waitForNotText.js +20 -20
- package/build/ox_modules/module-web/commands/waitForNotValue.js +20 -20
- package/build/ox_modules/module-web/commands/waitForText.js +20 -20
- package/build/ox_modules/module-web/commands/waitForValue.js +20 -20
- package/build/ox_modules/module-web/commands/waitForVisible.js +17 -17
- package/build/ox_modules/module-web/commands/waitForWindow.js +22 -22
- package/build/ox_modules/module-web.js +94 -94
- package/build/ox_modules/module-win/commands/assertText.js +17 -17
- package/build/ox_modules/module-win/commands/assertTitle.js +15 -15
- package/build/ox_modules/module-win/commands/assertValue.js +14 -14
- package/build/ox_modules/module-win/commands/back.js +11 -11
- package/build/ox_modules/module-win/commands/clear.js +13 -13
- package/build/ox_modules/module-win/commands/click.js +13 -13
- package/build/ox_modules/module-win/commands/clickLong.js +14 -14
- package/build/ox_modules/module-win/commands/clickMultipleTimes.js +14 -14
- package/build/ox_modules/module-win/commands/findElement.js +15 -15
- package/build/ox_modules/module-win/commands/findElements.js +15 -15
- package/build/ox_modules/module-win/commands/getAppiumLogs.js +12 -12
- package/build/ox_modules/module-win/commands/getCurrentWindowHandle.js +15 -15
- package/build/ox_modules/module-win/commands/getLocation.js +14 -14
- package/build/ox_modules/module-win/commands/getSource.js +12 -12
- package/build/ox_modules/module-win/commands/getText.js +14 -14
- package/build/ox_modules/module-win/commands/getValue.js +14 -14
- package/build/ox_modules/module-win/commands/getWindowHandles.js +15 -15
- package/build/ox_modules/module-win/commands/index.js +1 -1
- package/build/ox_modules/module-win/commands/isCheckable.js +14 -14
- package/build/ox_modules/module-win/commands/isChecked.js +14 -14
- package/build/ox_modules/module-win/commands/isClickable.js +14 -14
- package/build/ox_modules/module-win/commands/isExist.js +15 -15
- package/build/ox_modules/module-win/commands/isSelected.js +14 -14
- package/build/ox_modules/module-win/commands/isVisible.js +15 -15
- package/build/ox_modules/module-win/commands/open.js +13 -13
- package/build/ox_modules/module-win/commands/pause.js +12 -12
- package/build/ox_modules/module-win/commands/rightClick.js +13 -13
- package/build/ox_modules/module-win/commands/selectWindow.js +23 -23
- package/build/ox_modules/module-win/commands/sendKeys.js +22 -22
- package/build/ox_modules/module-win/commands/setTimeout.js +17 -17
- package/build/ox_modules/module-win/commands/takeScreenshot.js +16 -16
- package/build/ox_modules/module-win/commands/tap.js +13 -13
- package/build/ox_modules/module-win/commands/type.js +16 -16
- package/build/ox_modules/module-win/commands/waitForExist.js +14 -14
- package/build/ox_modules/module-win/commands/waitForInteractable.js +16 -16
- package/build/ox_modules/module-win/commands/waitForVisible.js +13 -13
- package/build/ox_modules/module-win.js +47 -47
- package/build/ox_modules/utils.js +8 -8
- package/build/ox_reporters/excel/template.json +48 -48
- package/build/ox_reporters/html/index.ejs +163 -163
- package/build/ox_reporters/html/summary.ejs +77 -77
- package/build/ox_reporters/html/tests-details.ejs +134 -134
- package/build/ox_reporters/html/tests-devices-browsers.ejs +83 -83
- package/build/ox_reporters/reporter-excel.js +1 -1
- package/build/ox_reporters/reporter-html.js +1 -1
- package/build/ox_reporters/reporter-json.js +1 -1
- package/build/ox_reporters/reporter-junit.js +1 -1
- package/build/ox_reporters/reporter-pdf.js +1 -1
- package/build/ox_reporters/reporter-rp.js +1 -1
- package/build/ox_reporters/reporter-xml.js +1 -1
- package/build/ox_services/service-devtools/submodule-network.js +1 -1
- package/build/ox_services/service-devtools.js +1 -1
- package/build/reporter/FileReporterBase.js +1 -1
- package/build/reporter/ReportAggregator.js +13 -5
- package/build/reporter/ReporterBase.js +1 -1
- package/build/reporter/WebSocketReporter.js +1 -1
- package/build/runners/WorkerProcess.js +1 -1
- package/build/runners/cucumber/CucumberEventListener.js +1 -1
- package/build/runners/cucumber/CucumberReporter.js +1 -1
- package/build/runners/cucumber/CucumberWorker.js +1 -1
- package/build/runners/cucumber/index.js +1 -1
- package/build/runners/cucumber/worker.js +1 -1
- package/build/runners/index.js +1 -1
- package/build/runners/oxygen/OxygenWorker.js +1 -1
- package/build/runners/oxygen/index.js +1 -1
- package/build/runners/oxygen/worker.js +1 -1
- package/config/default.json +6 -6
- package/log.txt +1614 -0
- package/package.json +139 -137
- package/reports/2025-06-08_231627/report.html +440 -0
- package/reports/2025-06-09_223615/report.html +440 -0
- package/transpiled/mongodb/etc/prepare.js +18 -0
- package/transpiled/mongodb/lib/admin.js +182 -0
- package/transpiled/mongodb/lib/beta.js +26 -0
- package/transpiled/mongodb/lib/bson.js +220 -0
- package/transpiled/mongodb/lib/bulk/common.js +1041 -0
- package/transpiled/mongodb/lib/bulk/ordered.js +76 -0
- package/transpiled/mongodb/lib/bulk/unordered.js +102 -0
- package/transpiled/mongodb/lib/change_stream.js +517 -0
- package/transpiled/mongodb/lib/client-side-encryption/auto_encrypter.js +329 -0
- package/transpiled/mongodb/lib/client-side-encryption/client_encryption.js +779 -0
- package/transpiled/mongodb/lib/client-side-encryption/crypto_callbacks.js +95 -0
- package/transpiled/mongodb/lib/client-side-encryption/errors.js +171 -0
- package/transpiled/mongodb/lib/client-side-encryption/mongocryptd_manager.js +98 -0
- package/transpiled/mongodb/lib/client-side-encryption/providers/aws.js +34 -0
- package/transpiled/mongodb/lib/client-side-encryption/providers/azure.js +186 -0
- package/transpiled/mongodb/lib/client-side-encryption/providers/gcp.js +29 -0
- package/transpiled/mongodb/lib/client-side-encryption/providers/index.js +58 -0
- package/transpiled/mongodb/lib/client-side-encryption/state_machine.js +505 -0
- package/transpiled/mongodb/lib/cmap/auth/auth_provider.js +63 -0
- package/transpiled/mongodb/lib/cmap/auth/aws_temporary_credentials.js +167 -0
- package/transpiled/mongodb/lib/cmap/auth/gssapi.js +207 -0
- package/transpiled/mongodb/lib/cmap/auth/mongo_credentials.js +193 -0
- package/transpiled/mongodb/lib/cmap/auth/mongodb_aws.js +181 -0
- package/transpiled/mongodb/lib/cmap/auth/mongodb_oidc/automated_callback_workflow.js +101 -0
- package/transpiled/mongodb/lib/cmap/auth/mongodb_oidc/azure_machine_workflow.js +81 -0
- package/transpiled/mongodb/lib/cmap/auth/mongodb_oidc/callback_workflow.js +174 -0
- package/transpiled/mongodb/lib/cmap/auth/mongodb_oidc/command_builders.js +59 -0
- package/transpiled/mongodb/lib/cmap/auth/mongodb_oidc/gcp_machine_workflow.js +58 -0
- package/transpiled/mongodb/lib/cmap/auth/mongodb_oidc/human_callback_workflow.js +138 -0
- package/transpiled/mongodb/lib/cmap/auth/mongodb_oidc/k8s_machine_workflow.js +42 -0
- package/transpiled/mongodb/lib/cmap/auth/mongodb_oidc/token_cache.js +71 -0
- package/transpiled/mongodb/lib/cmap/auth/mongodb_oidc/token_machine_workflow.js +34 -0
- package/transpiled/mongodb/lib/cmap/auth/mongodb_oidc.js +111 -0
- package/transpiled/mongodb/lib/cmap/auth/plain.js +43 -0
- package/transpiled/mongodb/lib/cmap/auth/providers.js +22 -0
- package/transpiled/mongodb/lib/cmap/auth/scram.js +318 -0
- package/transpiled/mongodb/lib/cmap/auth/x509.js +61 -0
- package/transpiled/mongodb/lib/cmap/command_monitoring_events.js +266 -0
- package/transpiled/mongodb/lib/cmap/commands.js +605 -0
- package/transpiled/mongodb/lib/cmap/connect.js +418 -0
- package/transpiled/mongodb/lib/cmap/connection.js +673 -0
- package/transpiled/mongodb/lib/cmap/connection_pool.js +688 -0
- package/transpiled/mongodb/lib/cmap/connection_pool_events.js +254 -0
- package/transpiled/mongodb/lib/cmap/errors.js +128 -0
- package/transpiled/mongodb/lib/cmap/handshake/client_metadata.js +278 -0
- package/transpiled/mongodb/lib/cmap/metrics.js +67 -0
- package/transpiled/mongodb/lib/cmap/stream_description.js +74 -0
- package/transpiled/mongodb/lib/cmap/wire_protocol/compression.js +196 -0
- package/transpiled/mongodb/lib/cmap/wire_protocol/constants.js +19 -0
- package/transpiled/mongodb/lib/cmap/wire_protocol/on_data.js +144 -0
- package/transpiled/mongodb/lib/cmap/wire_protocol/on_demand/document.js +278 -0
- package/transpiled/mongodb/lib/cmap/wire_protocol/responses.js +376 -0
- package/transpiled/mongodb/lib/cmap/wire_protocol/shared.js +49 -0
- package/transpiled/mongodb/lib/collection.js +852 -0
- package/transpiled/mongodb/lib/connection_string.js +1452 -0
- package/transpiled/mongodb/lib/constants.js +162 -0
- package/transpiled/mongodb/lib/cursor/abstract_cursor.js +1082 -0
- package/transpiled/mongodb/lib/cursor/aggregation_cursor.js +227 -0
- package/transpiled/mongodb/lib/cursor/change_stream_cursor.js +136 -0
- package/transpiled/mongodb/lib/cursor/client_bulk_write_cursor.js +69 -0
- package/transpiled/mongodb/lib/cursor/find_cursor.js +476 -0
- package/transpiled/mongodb/lib/cursor/list_collections_cursor.js +48 -0
- package/transpiled/mongodb/lib/cursor/list_indexes_cursor.js +46 -0
- package/transpiled/mongodb/lib/cursor/list_search_indexes_cursor.js +30 -0
- package/transpiled/mongodb/lib/cursor/run_command_cursor.js +125 -0
- package/transpiled/mongodb/lib/db.js +467 -0
- package/transpiled/mongodb/lib/deps.js +174 -0
- package/transpiled/mongodb/lib/encrypter.js +129 -0
- package/transpiled/mongodb/lib/error.js +1550 -0
- package/transpiled/mongodb/lib/explain.js +122 -0
- package/transpiled/mongodb/lib/gridfs/download.js +369 -0
- package/transpiled/mongodb/lib/gridfs/index.js +240 -0
- package/transpiled/mongodb/lib/gridfs/upload.js +446 -0
- package/transpiled/mongodb/lib/index.js +975 -0
- package/transpiled/mongodb/lib/mongo_client.js +626 -0
- package/transpiled/mongodb/lib/mongo_client_auth_providers.js +98 -0
- package/transpiled/mongodb/lib/mongo_logger.js +812 -0
- package/transpiled/mongodb/lib/mongo_types.js +71 -0
- package/transpiled/mongodb/lib/operations/aggregate.js +129 -0
- package/transpiled/mongodb/lib/operations/bulk_write.js +48 -0
- package/transpiled/mongodb/lib/operations/client_bulk_write/client_bulk_write.js +96 -0
- package/transpiled/mongodb/lib/operations/client_bulk_write/command_builder.js +409 -0
- package/transpiled/mongodb/lib/operations/client_bulk_write/common.js +5 -0
- package/transpiled/mongodb/lib/operations/client_bulk_write/executor.js +144 -0
- package/transpiled/mongodb/lib/operations/client_bulk_write/results_merger.js +228 -0
- package/transpiled/mongodb/lib/operations/collections.js +49 -0
- package/transpiled/mongodb/lib/operations/command.js +102 -0
- package/transpiled/mongodb/lib/operations/count.js +60 -0
- package/transpiled/mongodb/lib/operations/create_collection.js +109 -0
- package/transpiled/mongodb/lib/operations/delete.js +134 -0
- package/transpiled/mongodb/lib/operations/distinct.js +77 -0
- package/transpiled/mongodb/lib/operations/drop.js +102 -0
- package/transpiled/mongodb/lib/operations/estimated_document_count.js +47 -0
- package/transpiled/mongodb/lib/operations/execute_operation.js +251 -0
- package/transpiled/mongodb/lib/operations/find.js +197 -0
- package/transpiled/mongodb/lib/operations/find_and_modify.js +191 -0
- package/transpiled/mongodb/lib/operations/get_more.js +84 -0
- package/transpiled/mongodb/lib/operations/indexes.js +197 -0
- package/transpiled/mongodb/lib/operations/insert.js +138 -0
- package/transpiled/mongodb/lib/operations/is_capped.js +44 -0
- package/transpiled/mongodb/lib/operations/kill_cursors.js +58 -0
- package/transpiled/mongodb/lib/operations/list_collections.js +66 -0
- package/transpiled/mongodb/lib/operations/list_databases.js +56 -0
- package/transpiled/mongodb/lib/operations/operation.js +88 -0
- package/transpiled/mongodb/lib/operations/options_operation.js +44 -0
- package/transpiled/mongodb/lib/operations/profiling_level.js +42 -0
- package/transpiled/mongodb/lib/operations/remove_user.js +35 -0
- package/transpiled/mongodb/lib/operations/rename.js +48 -0
- package/transpiled/mongodb/lib/operations/run_command.js +64 -0
- package/transpiled/mongodb/lib/operations/search_indexes/create.js +41 -0
- package/transpiled/mongodb/lib/operations/search_indexes/drop.js +51 -0
- package/transpiled/mongodb/lib/operations/search_indexes/update.js +40 -0
- package/transpiled/mongodb/lib/operations/set_profiling_level.js +70 -0
- package/transpiled/mongodb/lib/operations/stats.js +39 -0
- package/transpiled/mongodb/lib/operations/update.js +218 -0
- package/transpiled/mongodb/lib/operations/validate_collection.js +49 -0
- package/transpiled/mongodb/lib/read_concern.js +92 -0
- package/transpiled/mongodb/lib/read_preference.js +215 -0
- package/transpiled/mongodb/lib/resource_management.js +74 -0
- package/transpiled/mongodb/lib/sdam/common.js +53 -0
- package/transpiled/mongodb/lib/sdam/events.js +177 -0
- package/transpiled/mongodb/lib/sdam/monitor.js +656 -0
- package/transpiled/mongodb/lib/sdam/server.js +463 -0
- package/transpiled/mongodb/lib/sdam/server_description.js +196 -0
- package/transpiled/mongodb/lib/sdam/server_selection.js +283 -0
- package/transpiled/mongodb/lib/sdam/server_selection_events.js +112 -0
- package/transpiled/mongodb/lib/sdam/srv_polling.js +139 -0
- package/transpiled/mongodb/lib/sdam/topology.js +833 -0
- package/transpiled/mongodb/lib/sdam/topology_description.js +447 -0
- package/transpiled/mongodb/lib/sessions.js +988 -0
- package/transpiled/mongodb/lib/sort.js +123 -0
- package/transpiled/mongodb/lib/timeout.js +349 -0
- package/transpiled/mongodb/lib/transactions.js +149 -0
- package/transpiled/mongodb/lib/utils.js +1502 -0
- package/transpiled/mongodb/lib/write_concern.js +115 -0
- package/types/index.d.ts +70 -70
- package/types/module-eyes.d.ts +39 -39
- package/types/module-http.d.ts +163 -163
- package/types/module-log.d.ts +34 -34
- package/types/module-mob.d.ts +966 -966
- package/types/module-pdf.d.ts +40 -40
- package/types/module-proxy.d.ts +100 -100
- package/types/module-shell.d.ts +24 -24
- package/types/module-utils.d.ts +99 -99
- package/types/module-web.d.ts +1053 -1053
- package/types/module-win.d.ts +352 -352
- package/types/oxygen.d.ts +53 -53
|
@@ -0,0 +1,1452 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.DEFAULT_OPTIONS = exports.OPTIONS = void 0;
|
|
7
|
+
exports.resolveSRVRecord = resolveSRVRecord;
|
|
8
|
+
exports.parseOptions = parseOptions;
|
|
9
|
+
|
|
10
|
+
const dns = require("dns");
|
|
11
|
+
|
|
12
|
+
const mongodb_connection_string_url_1 = require("mongodb-connection-string-url");
|
|
13
|
+
|
|
14
|
+
const url_1 = require("url");
|
|
15
|
+
|
|
16
|
+
const mongo_credentials_1 = require("./cmap/auth/mongo_credentials");
|
|
17
|
+
|
|
18
|
+
const providers_1 = require("./cmap/auth/providers");
|
|
19
|
+
|
|
20
|
+
const client_metadata_1 = require("./cmap/handshake/client_metadata");
|
|
21
|
+
|
|
22
|
+
const compression_1 = require("./cmap/wire_protocol/compression");
|
|
23
|
+
|
|
24
|
+
const encrypter_1 = require("./encrypter");
|
|
25
|
+
|
|
26
|
+
const error_1 = require("./error");
|
|
27
|
+
|
|
28
|
+
const mongo_client_1 = require("./mongo_client");
|
|
29
|
+
|
|
30
|
+
const mongo_logger_1 = require("./mongo_logger");
|
|
31
|
+
|
|
32
|
+
const read_concern_1 = require("./read_concern");
|
|
33
|
+
|
|
34
|
+
const read_preference_1 = require("./read_preference");
|
|
35
|
+
|
|
36
|
+
const monitor_1 = require("./sdam/monitor");
|
|
37
|
+
|
|
38
|
+
const utils_1 = require("./utils");
|
|
39
|
+
|
|
40
|
+
const write_concern_1 = require("./write_concern");
|
|
41
|
+
|
|
42
|
+
const VALID_TXT_RECORDS = ['authSource', 'replicaSet', 'loadBalanced'];
|
|
43
|
+
const LB_SINGLE_HOST_ERROR = 'loadBalanced option only supported with a single host in the URI';
|
|
44
|
+
const LB_REPLICA_SET_ERROR = 'loadBalanced option not supported with a replicaSet option';
|
|
45
|
+
const LB_DIRECT_CONNECTION_ERROR = 'loadBalanced option not supported when directConnection is provided';
|
|
46
|
+
|
|
47
|
+
function retryDNSTimeoutFor(api) {
|
|
48
|
+
return async function dnsReqRetryTimeout(lookupAddress) {
|
|
49
|
+
try {
|
|
50
|
+
return await dns.promises[api](lookupAddress);
|
|
51
|
+
} catch (firstDNSError) {
|
|
52
|
+
if (firstDNSError.code === dns.TIMEOUT) {
|
|
53
|
+
return await dns.promises[api](lookupAddress);
|
|
54
|
+
} else {
|
|
55
|
+
throw firstDNSError;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const resolveSrv = retryDNSTimeoutFor('resolveSrv');
|
|
62
|
+
const resolveTxt = retryDNSTimeoutFor('resolveTxt');
|
|
63
|
+
/**
|
|
64
|
+
* Lookup a `mongodb+srv` connection string, combine the parts and reparse it as a normal
|
|
65
|
+
* connection string.
|
|
66
|
+
*
|
|
67
|
+
* @param uri - The connection string to parse
|
|
68
|
+
* @param options - Optional user provided connection string options
|
|
69
|
+
*/
|
|
70
|
+
|
|
71
|
+
async function resolveSRVRecord(options) {
|
|
72
|
+
if (typeof options.srvHost !== 'string') {
|
|
73
|
+
throw new error_1.MongoAPIError('Option "srvHost" must not be empty');
|
|
74
|
+
} // Asynchronously start TXT resolution so that we do not have to wait until
|
|
75
|
+
// the SRV record is resolved before starting a second DNS query.
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
const lookupAddress = options.srvHost;
|
|
79
|
+
const txtResolutionPromise = resolveTxt(lookupAddress);
|
|
80
|
+
txtResolutionPromise.then(undefined, utils_1.squashError); // rejections will be handled later
|
|
81
|
+
|
|
82
|
+
const hostname = `_${options.srvServiceName}._tcp.${lookupAddress}`; // Resolve the SRV record and use the result as the list of hosts to connect to.
|
|
83
|
+
|
|
84
|
+
const addresses = await resolveSrv(hostname);
|
|
85
|
+
|
|
86
|
+
if (addresses.length === 0) {
|
|
87
|
+
throw new error_1.MongoAPIError('No addresses found at host');
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
for (const {
|
|
91
|
+
name
|
|
92
|
+
} of addresses) {
|
|
93
|
+
(0, utils_1.checkParentDomainMatch)(name, lookupAddress);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const hostAddresses = addresses.map(r => utils_1.HostAddress.fromString(`${r.name}:${r.port ?? 27017}`));
|
|
97
|
+
validateLoadBalancedOptions(hostAddresses, options, true); // Use the result of resolving the TXT record and add options from there if they exist.
|
|
98
|
+
|
|
99
|
+
let record;
|
|
100
|
+
|
|
101
|
+
try {
|
|
102
|
+
record = await txtResolutionPromise;
|
|
103
|
+
} catch (error) {
|
|
104
|
+
if (error.code !== 'ENODATA' && error.code !== 'ENOTFOUND') {
|
|
105
|
+
throw error;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return hostAddresses;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (record.length > 1) {
|
|
112
|
+
throw new error_1.MongoParseError('Multiple text records not allowed');
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const txtRecordOptions = new url_1.URLSearchParams(record[0].join(''));
|
|
116
|
+
const txtRecordOptionKeys = [...txtRecordOptions.keys()];
|
|
117
|
+
|
|
118
|
+
if (txtRecordOptionKeys.some(key => !VALID_TXT_RECORDS.includes(key))) {
|
|
119
|
+
throw new error_1.MongoParseError(`Text record may only set any of: ${VALID_TXT_RECORDS.join(', ')}`);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (VALID_TXT_RECORDS.some(option => txtRecordOptions.get(option) === '')) {
|
|
123
|
+
throw new error_1.MongoParseError('Cannot have empty URI params in DNS TXT Record');
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const source = txtRecordOptions.get('authSource') ?? undefined;
|
|
127
|
+
const replicaSet = txtRecordOptions.get('replicaSet') ?? undefined;
|
|
128
|
+
const loadBalanced = txtRecordOptions.get('loadBalanced') ?? undefined;
|
|
129
|
+
|
|
130
|
+
if (!options.userSpecifiedAuthSource && source && options.credentials && !providers_1.AUTH_MECHS_AUTH_SRC_EXTERNAL.has(options.credentials.mechanism)) {
|
|
131
|
+
options.credentials = mongo_credentials_1.MongoCredentials.merge(options.credentials, {
|
|
132
|
+
source
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (!options.userSpecifiedReplicaSet && replicaSet) {
|
|
137
|
+
options.replicaSet = replicaSet;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (loadBalanced === 'true') {
|
|
141
|
+
options.loadBalanced = true;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (options.replicaSet && options.srvMaxHosts > 0) {
|
|
145
|
+
throw new error_1.MongoParseError('Cannot combine replicaSet option with srvMaxHosts');
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
validateLoadBalancedOptions(hostAddresses, options, true);
|
|
149
|
+
return hostAddresses;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Checks if TLS options are valid
|
|
153
|
+
*
|
|
154
|
+
* @param allOptions - All options provided by user or included in default options map
|
|
155
|
+
* @throws MongoAPIError if TLS options are invalid
|
|
156
|
+
*/
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
function checkTLSOptions(allOptions) {
|
|
160
|
+
if (!allOptions) return;
|
|
161
|
+
|
|
162
|
+
const check = (a, b) => {
|
|
163
|
+
if (allOptions.has(a) && allOptions.has(b)) {
|
|
164
|
+
throw new error_1.MongoAPIError(`The '${a}' option cannot be used with the '${b}' option`);
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
check('tlsInsecure', 'tlsAllowInvalidCertificates');
|
|
169
|
+
check('tlsInsecure', 'tlsAllowInvalidHostnames');
|
|
170
|
+
check('tlsInsecure', 'tlsDisableCertificateRevocationCheck');
|
|
171
|
+
check('tlsInsecure', 'tlsDisableOCSPEndpointCheck');
|
|
172
|
+
check('tlsAllowInvalidCertificates', 'tlsDisableCertificateRevocationCheck');
|
|
173
|
+
check('tlsAllowInvalidCertificates', 'tlsDisableOCSPEndpointCheck');
|
|
174
|
+
check('tlsDisableCertificateRevocationCheck', 'tlsDisableOCSPEndpointCheck');
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function getBoolean(name, value) {
|
|
178
|
+
if (typeof value === 'boolean') return value;
|
|
179
|
+
|
|
180
|
+
switch (value) {
|
|
181
|
+
case 'true':
|
|
182
|
+
return true;
|
|
183
|
+
|
|
184
|
+
case 'false':
|
|
185
|
+
return false;
|
|
186
|
+
|
|
187
|
+
default:
|
|
188
|
+
throw new error_1.MongoParseError(`${name} must be either "true" or "false"`);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function getIntFromOptions(name, value) {
|
|
193
|
+
const parsedInt = (0, utils_1.parseInteger)(value);
|
|
194
|
+
|
|
195
|
+
if (parsedInt != null) {
|
|
196
|
+
return parsedInt;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
throw new error_1.MongoParseError(`Expected ${name} to be stringified int value, got: ${value}`);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function getUIntFromOptions(name, value) {
|
|
203
|
+
const parsedValue = getIntFromOptions(name, value);
|
|
204
|
+
|
|
205
|
+
if (parsedValue < 0) {
|
|
206
|
+
throw new error_1.MongoParseError(`${name} can only be a positive int value, got: ${value}`);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
return parsedValue;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function* entriesFromString(value) {
|
|
213
|
+
if (value === '') {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const keyValuePairs = value.split(',');
|
|
218
|
+
|
|
219
|
+
for (const keyValue of keyValuePairs) {
|
|
220
|
+
const [key, value] = keyValue.split(/:(.*)/);
|
|
221
|
+
|
|
222
|
+
if (value == null) {
|
|
223
|
+
throw new error_1.MongoParseError('Cannot have undefined values in key value pairs');
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
yield [key, value];
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
class CaseInsensitiveMap extends Map {
|
|
231
|
+
constructor(entries = []) {
|
|
232
|
+
super(entries.map(([k, v]) => [k.toLowerCase(), v]));
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
has(k) {
|
|
236
|
+
return super.has(k.toLowerCase());
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
get(k) {
|
|
240
|
+
return super.get(k.toLowerCase());
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
set(k, v) {
|
|
244
|
+
return super.set(k.toLowerCase(), v);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
delete(k) {
|
|
248
|
+
return super.delete(k.toLowerCase());
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
function parseOptions(uri, mongoClient = undefined, options = {}) {
|
|
254
|
+
if (mongoClient != null && !(mongoClient instanceof mongo_client_1.MongoClient)) {
|
|
255
|
+
options = mongoClient;
|
|
256
|
+
mongoClient = undefined;
|
|
257
|
+
} // validate BSONOptions
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
if (options.useBigInt64 && typeof options.promoteLongs === 'boolean' && !options.promoteLongs) {
|
|
261
|
+
throw new error_1.MongoAPIError('Must request either bigint or Long for int64 deserialization');
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
if (options.useBigInt64 && typeof options.promoteValues === 'boolean' && !options.promoteValues) {
|
|
265
|
+
throw new error_1.MongoAPIError('Must request either bigint or Long for int64 deserialization');
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
const url = new mongodb_connection_string_url_1.default(uri);
|
|
269
|
+
const {
|
|
270
|
+
hosts,
|
|
271
|
+
isSRV
|
|
272
|
+
} = url;
|
|
273
|
+
const mongoOptions = Object.create(null);
|
|
274
|
+
mongoOptions.hosts = isSRV ? [] : hosts.map(utils_1.HostAddress.fromString);
|
|
275
|
+
const urlOptions = new CaseInsensitiveMap();
|
|
276
|
+
|
|
277
|
+
if (url.pathname !== '/' && url.pathname !== '') {
|
|
278
|
+
const dbName = decodeURIComponent(url.pathname[0] === '/' ? url.pathname.slice(1) : url.pathname);
|
|
279
|
+
|
|
280
|
+
if (dbName) {
|
|
281
|
+
urlOptions.set('dbName', [dbName]);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
if (url.username !== '') {
|
|
286
|
+
const auth = {
|
|
287
|
+
username: decodeURIComponent(url.username)
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
if (typeof url.password === 'string') {
|
|
291
|
+
auth.password = decodeURIComponent(url.password);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
urlOptions.set('auth', [auth]);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
for (const key of url.searchParams.keys()) {
|
|
298
|
+
const values = url.searchParams.getAll(key);
|
|
299
|
+
const isReadPreferenceTags = /readPreferenceTags/i.test(key);
|
|
300
|
+
|
|
301
|
+
if (!isReadPreferenceTags && values.length > 1) {
|
|
302
|
+
throw new error_1.MongoInvalidArgumentError(`URI option "${key}" cannot appear more than once in the connection string`);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
if (!isReadPreferenceTags && values.includes('')) {
|
|
306
|
+
throw new error_1.MongoAPIError(`URI option "${key}" cannot be specified with no value`);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
if (!urlOptions.has(key)) {
|
|
310
|
+
urlOptions.set(key, values);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
const objectOptions = new CaseInsensitiveMap(Object.entries(options).filter(([, v]) => v != null)); // Validate options that can only be provided by one of uri or object
|
|
315
|
+
|
|
316
|
+
if (urlOptions.has('serverApi')) {
|
|
317
|
+
throw new error_1.MongoParseError('URI cannot contain `serverApi`, it can only be passed to the client');
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
const uriMechanismProperties = urlOptions.get('authMechanismProperties');
|
|
321
|
+
|
|
322
|
+
if (uriMechanismProperties) {
|
|
323
|
+
for (const property of uriMechanismProperties) {
|
|
324
|
+
if (/(^|,)ALLOWED_HOSTS:/.test(property)) {
|
|
325
|
+
throw new error_1.MongoParseError('Auth mechanism property ALLOWED_HOSTS is not allowed in the connection string.');
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
if (objectOptions.has('loadBalanced')) {
|
|
331
|
+
throw new error_1.MongoParseError('loadBalanced is only a valid option in the URI');
|
|
332
|
+
} // All option collection
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
const allProvidedOptions = new CaseInsensitiveMap();
|
|
336
|
+
const allProvidedKeys = new Set([...urlOptions.keys(), ...objectOptions.keys()]);
|
|
337
|
+
|
|
338
|
+
for (const key of allProvidedKeys) {
|
|
339
|
+
const values = [];
|
|
340
|
+
const objectOptionValue = objectOptions.get(key);
|
|
341
|
+
|
|
342
|
+
if (objectOptionValue != null) {
|
|
343
|
+
values.push(objectOptionValue);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
const urlValues = urlOptions.get(key) ?? [];
|
|
347
|
+
values.push(...urlValues);
|
|
348
|
+
allProvidedOptions.set(key, values);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
if (allProvidedOptions.has('tls') || allProvidedOptions.has('ssl')) {
|
|
352
|
+
const tlsAndSslOpts = (allProvidedOptions.get('tls') || []).concat(allProvidedOptions.get('ssl') || []).map(getBoolean.bind(null, 'tls/ssl'));
|
|
353
|
+
|
|
354
|
+
if (new Set(tlsAndSslOpts).size !== 1) {
|
|
355
|
+
throw new error_1.MongoParseError('All values of tls/ssl must be the same.');
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
checkTLSOptions(allProvidedOptions);
|
|
360
|
+
const unsupportedOptions = (0, utils_1.setDifference)(allProvidedKeys, Array.from(Object.keys(exports.OPTIONS)).map(s => s.toLowerCase()));
|
|
361
|
+
|
|
362
|
+
if (unsupportedOptions.size !== 0) {
|
|
363
|
+
const optionWord = unsupportedOptions.size > 1 ? 'options' : 'option';
|
|
364
|
+
const isOrAre = unsupportedOptions.size > 1 ? 'are' : 'is';
|
|
365
|
+
throw new error_1.MongoParseError(`${optionWord} ${Array.from(unsupportedOptions).join(', ')} ${isOrAre} not supported`);
|
|
366
|
+
} // Option parsing and setting
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
for (const [key, descriptor] of Object.entries(exports.OPTIONS)) {
|
|
370
|
+
const values = allProvidedOptions.get(key);
|
|
371
|
+
|
|
372
|
+
if (!values || values.length === 0) {
|
|
373
|
+
if (exports.DEFAULT_OPTIONS.has(key)) {
|
|
374
|
+
setOption(mongoOptions, key, descriptor, [exports.DEFAULT_OPTIONS.get(key)]);
|
|
375
|
+
}
|
|
376
|
+
} else {
|
|
377
|
+
const {
|
|
378
|
+
deprecated
|
|
379
|
+
} = descriptor;
|
|
380
|
+
|
|
381
|
+
if (deprecated) {
|
|
382
|
+
const deprecatedMsg = typeof deprecated === 'string' ? `: ${deprecated}` : '';
|
|
383
|
+
(0, utils_1.emitWarning)(`${key} is a deprecated option${deprecatedMsg}`);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
setOption(mongoOptions, key, descriptor, values);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
if (mongoOptions.credentials) {
|
|
391
|
+
const isGssapi = mongoOptions.credentials.mechanism === providers_1.AuthMechanism.MONGODB_GSSAPI;
|
|
392
|
+
const isX509 = mongoOptions.credentials.mechanism === providers_1.AuthMechanism.MONGODB_X509;
|
|
393
|
+
const isAws = mongoOptions.credentials.mechanism === providers_1.AuthMechanism.MONGODB_AWS;
|
|
394
|
+
const isOidc = mongoOptions.credentials.mechanism === providers_1.AuthMechanism.MONGODB_OIDC;
|
|
395
|
+
|
|
396
|
+
if ((isGssapi || isX509) && allProvidedOptions.has('authSource') && mongoOptions.credentials.source !== '$external') {
|
|
397
|
+
// If authSource was explicitly given and its incorrect, we error
|
|
398
|
+
throw new error_1.MongoParseError(`authMechanism ${mongoOptions.credentials.mechanism} requires an authSource of '$external'`);
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
if (!(isGssapi || isX509 || isAws || isOidc) && mongoOptions.dbName && !allProvidedOptions.has('authSource')) {
|
|
402
|
+
// inherit the dbName unless GSSAPI or X509, then silently ignore dbName
|
|
403
|
+
// and there was no specific authSource given
|
|
404
|
+
mongoOptions.credentials = mongo_credentials_1.MongoCredentials.merge(mongoOptions.credentials, {
|
|
405
|
+
source: mongoOptions.dbName
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
if (isAws && mongoOptions.credentials.username && !mongoOptions.credentials.password) {
|
|
410
|
+
throw new error_1.MongoMissingCredentialsError(`When using ${mongoOptions.credentials.mechanism} password must be set when a username is specified`);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
mongoOptions.credentials.validate(); // Check if the only auth related option provided was authSource, if so we can remove credentials
|
|
414
|
+
|
|
415
|
+
if (mongoOptions.credentials.password === '' && mongoOptions.credentials.username === '' && mongoOptions.credentials.mechanism === providers_1.AuthMechanism.MONGODB_DEFAULT && Object.keys(mongoOptions.credentials.mechanismProperties).length === 0) {
|
|
416
|
+
delete mongoOptions.credentials;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
if (!mongoOptions.dbName) {
|
|
421
|
+
// dbName default is applied here because of the credential validation above
|
|
422
|
+
mongoOptions.dbName = 'test';
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
validateLoadBalancedOptions(hosts, mongoOptions, isSRV);
|
|
426
|
+
|
|
427
|
+
if (mongoClient && mongoOptions.autoEncryption) {
|
|
428
|
+
encrypter_1.Encrypter.checkForMongoCrypt();
|
|
429
|
+
mongoOptions.encrypter = new encrypter_1.Encrypter(mongoClient, uri, options);
|
|
430
|
+
mongoOptions.autoEncrypter = mongoOptions.encrypter.autoEncrypter;
|
|
431
|
+
} // Potential SRV Overrides and SRV connection string validations
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
mongoOptions.userSpecifiedAuthSource = objectOptions.has('authSource') || urlOptions.has('authSource');
|
|
435
|
+
mongoOptions.userSpecifiedReplicaSet = objectOptions.has('replicaSet') || urlOptions.has('replicaSet');
|
|
436
|
+
|
|
437
|
+
if (isSRV) {
|
|
438
|
+
// SRV Record is resolved upon connecting
|
|
439
|
+
mongoOptions.srvHost = hosts[0];
|
|
440
|
+
|
|
441
|
+
if (mongoOptions.directConnection) {
|
|
442
|
+
throw new error_1.MongoAPIError('SRV URI does not support directConnection');
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
if (mongoOptions.srvMaxHosts > 0 && typeof mongoOptions.replicaSet === 'string') {
|
|
446
|
+
throw new error_1.MongoParseError('Cannot use srvMaxHosts option with replicaSet');
|
|
447
|
+
} // SRV turns on TLS by default, but users can override and turn it off
|
|
448
|
+
|
|
449
|
+
|
|
450
|
+
const noUserSpecifiedTLS = !objectOptions.has('tls') && !urlOptions.has('tls');
|
|
451
|
+
const noUserSpecifiedSSL = !objectOptions.has('ssl') && !urlOptions.has('ssl');
|
|
452
|
+
|
|
453
|
+
if (noUserSpecifiedTLS && noUserSpecifiedSSL) {
|
|
454
|
+
mongoOptions.tls = true;
|
|
455
|
+
}
|
|
456
|
+
} else {
|
|
457
|
+
const userSpecifiedSrvOptions = urlOptions.has('srvMaxHosts') || objectOptions.has('srvMaxHosts') || urlOptions.has('srvServiceName') || objectOptions.has('srvServiceName');
|
|
458
|
+
|
|
459
|
+
if (userSpecifiedSrvOptions) {
|
|
460
|
+
throw new error_1.MongoParseError('Cannot use srvMaxHosts or srvServiceName with a non-srv connection string');
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
if (mongoOptions.directConnection && mongoOptions.hosts.length !== 1) {
|
|
465
|
+
throw new error_1.MongoParseError('directConnection option requires exactly one host');
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
if (!mongoOptions.proxyHost && (mongoOptions.proxyPort || mongoOptions.proxyUsername || mongoOptions.proxyPassword)) {
|
|
469
|
+
throw new error_1.MongoParseError('Must specify proxyHost if other proxy options are passed');
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
if (mongoOptions.proxyUsername && !mongoOptions.proxyPassword || !mongoOptions.proxyUsername && mongoOptions.proxyPassword) {
|
|
473
|
+
throw new error_1.MongoParseError('Can only specify both of proxy username/password or neither');
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
const proxyOptions = ['proxyHost', 'proxyPort', 'proxyUsername', 'proxyPassword'].map(key => urlOptions.get(key) ?? []);
|
|
477
|
+
|
|
478
|
+
if (proxyOptions.some(options => options.length > 1)) {
|
|
479
|
+
throw new error_1.MongoParseError('Proxy options cannot be specified multiple times in the connection string');
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
mongoOptions.mongoLoggerOptions = mongo_logger_1.MongoLogger.resolveOptions({
|
|
483
|
+
MONGODB_LOG_COMMAND: process.env.MONGODB_LOG_COMMAND,
|
|
484
|
+
MONGODB_LOG_TOPOLOGY: process.env.MONGODB_LOG_TOPOLOGY,
|
|
485
|
+
MONGODB_LOG_SERVER_SELECTION: process.env.MONGODB_LOG_SERVER_SELECTION,
|
|
486
|
+
MONGODB_LOG_CONNECTION: process.env.MONGODB_LOG_CONNECTION,
|
|
487
|
+
MONGODB_LOG_CLIENT: process.env.MONGODB_LOG_CLIENT,
|
|
488
|
+
MONGODB_LOG_ALL: process.env.MONGODB_LOG_ALL,
|
|
489
|
+
MONGODB_LOG_MAX_DOCUMENT_LENGTH: process.env.MONGODB_LOG_MAX_DOCUMENT_LENGTH,
|
|
490
|
+
MONGODB_LOG_PATH: process.env.MONGODB_LOG_PATH
|
|
491
|
+
}, {
|
|
492
|
+
mongodbLogPath: mongoOptions.mongodbLogPath,
|
|
493
|
+
mongodbLogComponentSeverities: mongoOptions.mongodbLogComponentSeverities,
|
|
494
|
+
mongodbLogMaxDocumentLength: mongoOptions.mongodbLogMaxDocumentLength
|
|
495
|
+
});
|
|
496
|
+
mongoOptions.metadata = (0, client_metadata_1.makeClientMetadata)(mongoOptions);
|
|
497
|
+
mongoOptions.extendedMetadata = (0, client_metadata_1.addContainerMetadata)(mongoOptions.metadata).then(undefined, utils_1.squashError); // rejections will be handled later
|
|
498
|
+
|
|
499
|
+
return mongoOptions;
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* #### Throws if LB mode is true:
|
|
503
|
+
* - hosts contains more than one host
|
|
504
|
+
* - there is a replicaSet name set
|
|
505
|
+
* - directConnection is set
|
|
506
|
+
* - if srvMaxHosts is used when an srv connection string is passed in
|
|
507
|
+
*
|
|
508
|
+
* @throws MongoParseError
|
|
509
|
+
*/
|
|
510
|
+
|
|
511
|
+
|
|
512
|
+
function validateLoadBalancedOptions(hosts, mongoOptions, isSrv) {
|
|
513
|
+
if (mongoOptions.loadBalanced) {
|
|
514
|
+
if (hosts.length > 1) {
|
|
515
|
+
throw new error_1.MongoParseError(LB_SINGLE_HOST_ERROR);
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
if (mongoOptions.replicaSet) {
|
|
519
|
+
throw new error_1.MongoParseError(LB_REPLICA_SET_ERROR);
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
if (mongoOptions.directConnection) {
|
|
523
|
+
throw new error_1.MongoParseError(LB_DIRECT_CONNECTION_ERROR);
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
if (isSrv && mongoOptions.srvMaxHosts > 0) {
|
|
527
|
+
throw new error_1.MongoParseError('Cannot limit srv hosts with loadBalanced enabled');
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
return;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
function setOption(mongoOptions, key, descriptor, values) {
|
|
535
|
+
const {
|
|
536
|
+
target,
|
|
537
|
+
type,
|
|
538
|
+
transform
|
|
539
|
+
} = descriptor;
|
|
540
|
+
const name = target ?? key;
|
|
541
|
+
|
|
542
|
+
switch (type) {
|
|
543
|
+
case 'boolean':
|
|
544
|
+
mongoOptions[name] = getBoolean(name, values[0]);
|
|
545
|
+
break;
|
|
546
|
+
|
|
547
|
+
case 'int':
|
|
548
|
+
mongoOptions[name] = getIntFromOptions(name, values[0]);
|
|
549
|
+
break;
|
|
550
|
+
|
|
551
|
+
case 'uint':
|
|
552
|
+
mongoOptions[name] = getUIntFromOptions(name, values[0]);
|
|
553
|
+
break;
|
|
554
|
+
|
|
555
|
+
case 'string':
|
|
556
|
+
if (values[0] == null) {
|
|
557
|
+
break;
|
|
558
|
+
} // eslint-disable-next-line @typescript-eslint/no-base-to-string
|
|
559
|
+
|
|
560
|
+
|
|
561
|
+
mongoOptions[name] = String(values[0]);
|
|
562
|
+
break;
|
|
563
|
+
|
|
564
|
+
case 'record':
|
|
565
|
+
if (!(0, utils_1.isRecord)(values[0])) {
|
|
566
|
+
throw new error_1.MongoParseError(`${name} must be an object`);
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
mongoOptions[name] = values[0];
|
|
570
|
+
break;
|
|
571
|
+
|
|
572
|
+
case 'any':
|
|
573
|
+
mongoOptions[name] = values[0];
|
|
574
|
+
break;
|
|
575
|
+
|
|
576
|
+
default:
|
|
577
|
+
{
|
|
578
|
+
if (!transform) {
|
|
579
|
+
throw new error_1.MongoParseError('Descriptors missing a type must define a transform');
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
const transformValue = transform({
|
|
583
|
+
name,
|
|
584
|
+
options: mongoOptions,
|
|
585
|
+
values
|
|
586
|
+
});
|
|
587
|
+
mongoOptions[name] = transformValue;
|
|
588
|
+
break;
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
exports.OPTIONS = {
|
|
594
|
+
appName: {
|
|
595
|
+
type: 'string'
|
|
596
|
+
},
|
|
597
|
+
auth: {
|
|
598
|
+
target: 'credentials',
|
|
599
|
+
|
|
600
|
+
transform({
|
|
601
|
+
name,
|
|
602
|
+
options,
|
|
603
|
+
values: [value]
|
|
604
|
+
}) {
|
|
605
|
+
if (!(0, utils_1.isRecord)(value, ['username', 'password'])) {
|
|
606
|
+
throw new error_1.MongoParseError(`${name} must be an object with 'username' and 'password' properties`);
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
return mongo_credentials_1.MongoCredentials.merge(options.credentials, {
|
|
610
|
+
username: value.username,
|
|
611
|
+
password: value.password
|
|
612
|
+
});
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
},
|
|
616
|
+
authMechanism: {
|
|
617
|
+
target: 'credentials',
|
|
618
|
+
|
|
619
|
+
transform({
|
|
620
|
+
options,
|
|
621
|
+
values: [value]
|
|
622
|
+
}) {
|
|
623
|
+
const mechanisms = Object.values(providers_1.AuthMechanism);
|
|
624
|
+
const [mechanism] = mechanisms.filter(m => m.match(RegExp(String.raw`\b${value}\b`, 'i')));
|
|
625
|
+
|
|
626
|
+
if (!mechanism) {
|
|
627
|
+
throw new error_1.MongoParseError(`authMechanism one of ${mechanisms}, got ${value}`);
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
let source = options.credentials?.source;
|
|
631
|
+
|
|
632
|
+
if (mechanism === providers_1.AuthMechanism.MONGODB_PLAIN || providers_1.AUTH_MECHS_AUTH_SRC_EXTERNAL.has(mechanism)) {
|
|
633
|
+
// some mechanisms have '$external' as the Auth Source
|
|
634
|
+
source = '$external';
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
let password = options.credentials?.password;
|
|
638
|
+
|
|
639
|
+
if (mechanism === providers_1.AuthMechanism.MONGODB_X509 && password === '') {
|
|
640
|
+
password = undefined;
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
return mongo_credentials_1.MongoCredentials.merge(options.credentials, {
|
|
644
|
+
mechanism,
|
|
645
|
+
source,
|
|
646
|
+
password
|
|
647
|
+
});
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
},
|
|
651
|
+
// Note that if the authMechanismProperties contain a TOKEN_RESOURCE that has a
|
|
652
|
+
// comma in it, it MUST be supplied as a MongoClient option instead of in the
|
|
653
|
+
// connection string.
|
|
654
|
+
authMechanismProperties: {
|
|
655
|
+
target: 'credentials',
|
|
656
|
+
|
|
657
|
+
transform({
|
|
658
|
+
options,
|
|
659
|
+
values
|
|
660
|
+
}) {
|
|
661
|
+
// We can have a combination of options passed in the URI and options passed
|
|
662
|
+
// as an object to the MongoClient. So we must transform the string options
|
|
663
|
+
// as well as merge them together with a potentially provided object.
|
|
664
|
+
let mechanismProperties = Object.create(null);
|
|
665
|
+
|
|
666
|
+
for (const optionValue of values) {
|
|
667
|
+
if (typeof optionValue === 'string') {
|
|
668
|
+
for (const [key, value] of entriesFromString(optionValue)) {
|
|
669
|
+
try {
|
|
670
|
+
mechanismProperties[key] = getBoolean(key, value);
|
|
671
|
+
} catch {
|
|
672
|
+
mechanismProperties[key] = value;
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
} else {
|
|
676
|
+
if (!(0, utils_1.isRecord)(optionValue)) {
|
|
677
|
+
throw new error_1.MongoParseError('AuthMechanismProperties must be an object');
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
mechanismProperties = { ...optionValue
|
|
681
|
+
};
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
return mongo_credentials_1.MongoCredentials.merge(options.credentials, {
|
|
686
|
+
mechanismProperties
|
|
687
|
+
});
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
},
|
|
691
|
+
authSource: {
|
|
692
|
+
target: 'credentials',
|
|
693
|
+
|
|
694
|
+
transform({
|
|
695
|
+
options,
|
|
696
|
+
values: [value]
|
|
697
|
+
}) {
|
|
698
|
+
const source = String(value);
|
|
699
|
+
return mongo_credentials_1.MongoCredentials.merge(options.credentials, {
|
|
700
|
+
source
|
|
701
|
+
});
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
},
|
|
705
|
+
autoEncryption: {
|
|
706
|
+
type: 'record'
|
|
707
|
+
},
|
|
708
|
+
autoSelectFamily: {
|
|
709
|
+
type: 'boolean',
|
|
710
|
+
default: true
|
|
711
|
+
},
|
|
712
|
+
autoSelectFamilyAttemptTimeout: {
|
|
713
|
+
type: 'uint'
|
|
714
|
+
},
|
|
715
|
+
bsonRegExp: {
|
|
716
|
+
type: 'boolean'
|
|
717
|
+
},
|
|
718
|
+
serverApi: {
|
|
719
|
+
target: 'serverApi',
|
|
720
|
+
|
|
721
|
+
transform({
|
|
722
|
+
values: [version]
|
|
723
|
+
}) {
|
|
724
|
+
const serverApiToValidate = typeof version === 'string' ? {
|
|
725
|
+
version
|
|
726
|
+
} : version;
|
|
727
|
+
const versionToValidate = serverApiToValidate && serverApiToValidate.version;
|
|
728
|
+
|
|
729
|
+
if (!versionToValidate) {
|
|
730
|
+
throw new error_1.MongoParseError(`Invalid \`serverApi\` property; must specify a version from the following enum: ["${Object.values(mongo_client_1.ServerApiVersion).join('", "')}"]`);
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
if (!Object.values(mongo_client_1.ServerApiVersion).some(v => v === versionToValidate)) {
|
|
734
|
+
throw new error_1.MongoParseError(`Invalid server API version=${versionToValidate}; must be in the following enum: ["${Object.values(mongo_client_1.ServerApiVersion).join('", "')}"]`);
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
return serverApiToValidate;
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
},
|
|
741
|
+
checkKeys: {
|
|
742
|
+
type: 'boolean'
|
|
743
|
+
},
|
|
744
|
+
compressors: {
|
|
745
|
+
default: 'none',
|
|
746
|
+
target: 'compressors',
|
|
747
|
+
|
|
748
|
+
transform({
|
|
749
|
+
values
|
|
750
|
+
}) {
|
|
751
|
+
const compressionList = new Set();
|
|
752
|
+
|
|
753
|
+
for (const compVal of values) {
|
|
754
|
+
const compValArray = typeof compVal === 'string' ? compVal.split(',') : compVal;
|
|
755
|
+
|
|
756
|
+
if (!Array.isArray(compValArray)) {
|
|
757
|
+
throw new error_1.MongoInvalidArgumentError('compressors must be an array or a comma-delimited list of strings');
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
for (const c of compValArray) {
|
|
761
|
+
if (Object.keys(compression_1.Compressor).includes(String(c))) {
|
|
762
|
+
compressionList.add(String(c));
|
|
763
|
+
} else {
|
|
764
|
+
throw new error_1.MongoInvalidArgumentError(`${c} is not a valid compression mechanism. Must be one of: ${Object.keys(compression_1.Compressor)}.`);
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
return [...compressionList];
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
},
|
|
773
|
+
connectTimeoutMS: {
|
|
774
|
+
default: 30000,
|
|
775
|
+
type: 'uint'
|
|
776
|
+
},
|
|
777
|
+
dbName: {
|
|
778
|
+
type: 'string'
|
|
779
|
+
},
|
|
780
|
+
directConnection: {
|
|
781
|
+
default: false,
|
|
782
|
+
type: 'boolean'
|
|
783
|
+
},
|
|
784
|
+
driverInfo: {
|
|
785
|
+
default: {},
|
|
786
|
+
type: 'record'
|
|
787
|
+
},
|
|
788
|
+
enableUtf8Validation: {
|
|
789
|
+
type: 'boolean',
|
|
790
|
+
default: true
|
|
791
|
+
},
|
|
792
|
+
family: {
|
|
793
|
+
transform({
|
|
794
|
+
name,
|
|
795
|
+
values: [value]
|
|
796
|
+
}) {
|
|
797
|
+
const transformValue = getIntFromOptions(name, value);
|
|
798
|
+
|
|
799
|
+
if (transformValue === 4 || transformValue === 6) {
|
|
800
|
+
return transformValue;
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
throw new error_1.MongoParseError(`Option 'family' must be 4 or 6 got ${transformValue}.`);
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
},
|
|
807
|
+
fieldsAsRaw: {
|
|
808
|
+
type: 'record'
|
|
809
|
+
},
|
|
810
|
+
forceServerObjectId: {
|
|
811
|
+
default: false,
|
|
812
|
+
type: 'boolean'
|
|
813
|
+
},
|
|
814
|
+
fsync: {
|
|
815
|
+
deprecated: 'Please use journal instead',
|
|
816
|
+
target: 'writeConcern',
|
|
817
|
+
|
|
818
|
+
transform({
|
|
819
|
+
name,
|
|
820
|
+
options,
|
|
821
|
+
values: [value]
|
|
822
|
+
}) {
|
|
823
|
+
const wc = write_concern_1.WriteConcern.fromOptions({
|
|
824
|
+
writeConcern: { ...options.writeConcern,
|
|
825
|
+
fsync: getBoolean(name, value)
|
|
826
|
+
}
|
|
827
|
+
});
|
|
828
|
+
if (!wc) throw new error_1.MongoParseError(`Unable to make a writeConcern from fsync=${value}`);
|
|
829
|
+
return wc;
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
},
|
|
833
|
+
heartbeatFrequencyMS: {
|
|
834
|
+
default: 10000,
|
|
835
|
+
type: 'uint'
|
|
836
|
+
},
|
|
837
|
+
ignoreUndefined: {
|
|
838
|
+
type: 'boolean'
|
|
839
|
+
},
|
|
840
|
+
j: {
|
|
841
|
+
deprecated: 'Please use journal instead',
|
|
842
|
+
target: 'writeConcern',
|
|
843
|
+
|
|
844
|
+
transform({
|
|
845
|
+
name,
|
|
846
|
+
options,
|
|
847
|
+
values: [value]
|
|
848
|
+
}) {
|
|
849
|
+
const wc = write_concern_1.WriteConcern.fromOptions({
|
|
850
|
+
writeConcern: { ...options.writeConcern,
|
|
851
|
+
journal: getBoolean(name, value)
|
|
852
|
+
}
|
|
853
|
+
});
|
|
854
|
+
if (!wc) throw new error_1.MongoParseError(`Unable to make a writeConcern from journal=${value}`);
|
|
855
|
+
return wc;
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
},
|
|
859
|
+
journal: {
|
|
860
|
+
target: 'writeConcern',
|
|
861
|
+
|
|
862
|
+
transform({
|
|
863
|
+
name,
|
|
864
|
+
options,
|
|
865
|
+
values: [value]
|
|
866
|
+
}) {
|
|
867
|
+
const wc = write_concern_1.WriteConcern.fromOptions({
|
|
868
|
+
writeConcern: { ...options.writeConcern,
|
|
869
|
+
journal: getBoolean(name, value)
|
|
870
|
+
}
|
|
871
|
+
});
|
|
872
|
+
if (!wc) throw new error_1.MongoParseError(`Unable to make a writeConcern from journal=${value}`);
|
|
873
|
+
return wc;
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
},
|
|
877
|
+
loadBalanced: {
|
|
878
|
+
default: false,
|
|
879
|
+
type: 'boolean'
|
|
880
|
+
},
|
|
881
|
+
localThresholdMS: {
|
|
882
|
+
default: 15,
|
|
883
|
+
type: 'uint'
|
|
884
|
+
},
|
|
885
|
+
maxConnecting: {
|
|
886
|
+
default: 2,
|
|
887
|
+
|
|
888
|
+
transform({
|
|
889
|
+
name,
|
|
890
|
+
values: [value]
|
|
891
|
+
}) {
|
|
892
|
+
const maxConnecting = getUIntFromOptions(name, value);
|
|
893
|
+
|
|
894
|
+
if (maxConnecting === 0) {
|
|
895
|
+
throw new error_1.MongoInvalidArgumentError('maxConnecting must be > 0 if specified');
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
return maxConnecting;
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
},
|
|
902
|
+
maxIdleTimeMS: {
|
|
903
|
+
default: 0,
|
|
904
|
+
type: 'uint'
|
|
905
|
+
},
|
|
906
|
+
maxPoolSize: {
|
|
907
|
+
default: 100,
|
|
908
|
+
type: 'uint'
|
|
909
|
+
},
|
|
910
|
+
maxStalenessSeconds: {
|
|
911
|
+
target: 'readPreference',
|
|
912
|
+
|
|
913
|
+
transform({
|
|
914
|
+
name,
|
|
915
|
+
options,
|
|
916
|
+
values: [value]
|
|
917
|
+
}) {
|
|
918
|
+
const maxStalenessSeconds = getUIntFromOptions(name, value);
|
|
919
|
+
|
|
920
|
+
if (options.readPreference) {
|
|
921
|
+
return read_preference_1.ReadPreference.fromOptions({
|
|
922
|
+
readPreference: { ...options.readPreference,
|
|
923
|
+
maxStalenessSeconds
|
|
924
|
+
}
|
|
925
|
+
});
|
|
926
|
+
} else {
|
|
927
|
+
return new read_preference_1.ReadPreference('secondary', undefined, {
|
|
928
|
+
maxStalenessSeconds
|
|
929
|
+
});
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
},
|
|
934
|
+
minInternalBufferSize: {
|
|
935
|
+
type: 'uint'
|
|
936
|
+
},
|
|
937
|
+
minPoolSize: {
|
|
938
|
+
default: 0,
|
|
939
|
+
type: 'uint'
|
|
940
|
+
},
|
|
941
|
+
minHeartbeatFrequencyMS: {
|
|
942
|
+
default: 500,
|
|
943
|
+
type: 'uint'
|
|
944
|
+
},
|
|
945
|
+
monitorCommands: {
|
|
946
|
+
default: false,
|
|
947
|
+
type: 'boolean'
|
|
948
|
+
},
|
|
949
|
+
name: {
|
|
950
|
+
target: 'driverInfo',
|
|
951
|
+
|
|
952
|
+
transform({
|
|
953
|
+
values: [value],
|
|
954
|
+
options
|
|
955
|
+
}) {
|
|
956
|
+
return { ...options.driverInfo,
|
|
957
|
+
name: String(value)
|
|
958
|
+
};
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
},
|
|
962
|
+
noDelay: {
|
|
963
|
+
default: true,
|
|
964
|
+
type: 'boolean'
|
|
965
|
+
},
|
|
966
|
+
pkFactory: {
|
|
967
|
+
default: utils_1.DEFAULT_PK_FACTORY,
|
|
968
|
+
|
|
969
|
+
transform({
|
|
970
|
+
values: [value]
|
|
971
|
+
}) {
|
|
972
|
+
if ((0, utils_1.isRecord)(value, ['createPk']) && typeof value.createPk === 'function') {
|
|
973
|
+
return value;
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
throw new error_1.MongoParseError(`Option pkFactory must be an object with a createPk function, got ${value}`);
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
},
|
|
980
|
+
promoteBuffers: {
|
|
981
|
+
type: 'boolean'
|
|
982
|
+
},
|
|
983
|
+
promoteLongs: {
|
|
984
|
+
type: 'boolean'
|
|
985
|
+
},
|
|
986
|
+
promoteValues: {
|
|
987
|
+
type: 'boolean'
|
|
988
|
+
},
|
|
989
|
+
useBigInt64: {
|
|
990
|
+
type: 'boolean'
|
|
991
|
+
},
|
|
992
|
+
proxyHost: {
|
|
993
|
+
type: 'string'
|
|
994
|
+
},
|
|
995
|
+
proxyPassword: {
|
|
996
|
+
type: 'string'
|
|
997
|
+
},
|
|
998
|
+
proxyPort: {
|
|
999
|
+
type: 'uint'
|
|
1000
|
+
},
|
|
1001
|
+
proxyUsername: {
|
|
1002
|
+
type: 'string'
|
|
1003
|
+
},
|
|
1004
|
+
raw: {
|
|
1005
|
+
default: false,
|
|
1006
|
+
type: 'boolean'
|
|
1007
|
+
},
|
|
1008
|
+
readConcern: {
|
|
1009
|
+
transform({
|
|
1010
|
+
values: [value],
|
|
1011
|
+
options
|
|
1012
|
+
}) {
|
|
1013
|
+
if (value instanceof read_concern_1.ReadConcern || (0, utils_1.isRecord)(value, ['level'])) {
|
|
1014
|
+
return read_concern_1.ReadConcern.fromOptions({ ...options.readConcern,
|
|
1015
|
+
...value
|
|
1016
|
+
});
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
throw new error_1.MongoParseError(`ReadConcern must be an object, got ${JSON.stringify(value)}`);
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
},
|
|
1023
|
+
readConcernLevel: {
|
|
1024
|
+
target: 'readConcern',
|
|
1025
|
+
|
|
1026
|
+
transform({
|
|
1027
|
+
values: [level],
|
|
1028
|
+
options
|
|
1029
|
+
}) {
|
|
1030
|
+
return read_concern_1.ReadConcern.fromOptions({ ...options.readConcern,
|
|
1031
|
+
level: level
|
|
1032
|
+
});
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
},
|
|
1036
|
+
readPreference: {
|
|
1037
|
+
default: read_preference_1.ReadPreference.primary,
|
|
1038
|
+
|
|
1039
|
+
transform({
|
|
1040
|
+
values: [value],
|
|
1041
|
+
options
|
|
1042
|
+
}) {
|
|
1043
|
+
if (value instanceof read_preference_1.ReadPreference) {
|
|
1044
|
+
return read_preference_1.ReadPreference.fromOptions({
|
|
1045
|
+
readPreference: { ...options.readPreference,
|
|
1046
|
+
...value
|
|
1047
|
+
},
|
|
1048
|
+
...value
|
|
1049
|
+
});
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
if ((0, utils_1.isRecord)(value, ['mode'])) {
|
|
1053
|
+
const rp = read_preference_1.ReadPreference.fromOptions({
|
|
1054
|
+
readPreference: { ...options.readPreference,
|
|
1055
|
+
...value
|
|
1056
|
+
},
|
|
1057
|
+
...value
|
|
1058
|
+
});
|
|
1059
|
+
if (rp) return rp;else throw new error_1.MongoParseError(`Cannot make read preference from ${JSON.stringify(value)}`);
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
if (typeof value === 'string') {
|
|
1063
|
+
const rpOpts = {
|
|
1064
|
+
hedge: options.readPreference?.hedge,
|
|
1065
|
+
maxStalenessSeconds: options.readPreference?.maxStalenessSeconds
|
|
1066
|
+
};
|
|
1067
|
+
return new read_preference_1.ReadPreference(value, options.readPreference?.tags, rpOpts);
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
throw new error_1.MongoParseError(`Unknown ReadPreference value: ${value}`);
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
},
|
|
1074
|
+
readPreferenceTags: {
|
|
1075
|
+
target: 'readPreference',
|
|
1076
|
+
|
|
1077
|
+
transform({
|
|
1078
|
+
values,
|
|
1079
|
+
options
|
|
1080
|
+
}) {
|
|
1081
|
+
const tags = Array.isArray(values[0]) ? values[0] : values;
|
|
1082
|
+
const readPreferenceTags = [];
|
|
1083
|
+
|
|
1084
|
+
for (const tag of tags) {
|
|
1085
|
+
const readPreferenceTag = Object.create(null);
|
|
1086
|
+
|
|
1087
|
+
if (typeof tag === 'string') {
|
|
1088
|
+
for (const [k, v] of entriesFromString(tag)) {
|
|
1089
|
+
readPreferenceTag[k] = v;
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
if ((0, utils_1.isRecord)(tag)) {
|
|
1094
|
+
for (const [k, v] of Object.entries(tag)) {
|
|
1095
|
+
readPreferenceTag[k] = v;
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
readPreferenceTags.push(readPreferenceTag);
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
return read_preference_1.ReadPreference.fromOptions({
|
|
1103
|
+
readPreference: options.readPreference,
|
|
1104
|
+
readPreferenceTags
|
|
1105
|
+
});
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
},
|
|
1109
|
+
replicaSet: {
|
|
1110
|
+
type: 'string'
|
|
1111
|
+
},
|
|
1112
|
+
retryReads: {
|
|
1113
|
+
default: true,
|
|
1114
|
+
type: 'boolean'
|
|
1115
|
+
},
|
|
1116
|
+
retryWrites: {
|
|
1117
|
+
default: true,
|
|
1118
|
+
type: 'boolean'
|
|
1119
|
+
},
|
|
1120
|
+
serializeFunctions: {
|
|
1121
|
+
type: 'boolean'
|
|
1122
|
+
},
|
|
1123
|
+
serverMonitoringMode: {
|
|
1124
|
+
default: 'auto',
|
|
1125
|
+
|
|
1126
|
+
transform({
|
|
1127
|
+
values: [value]
|
|
1128
|
+
}) {
|
|
1129
|
+
if (!Object.values(monitor_1.ServerMonitoringMode).includes(value)) {
|
|
1130
|
+
throw new error_1.MongoParseError('serverMonitoringMode must be one of `auto`, `poll`, or `stream`');
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
return value;
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
},
|
|
1137
|
+
serverSelectionTimeoutMS: {
|
|
1138
|
+
default: 30000,
|
|
1139
|
+
type: 'uint'
|
|
1140
|
+
},
|
|
1141
|
+
servername: {
|
|
1142
|
+
type: 'string'
|
|
1143
|
+
},
|
|
1144
|
+
socketTimeoutMS: {
|
|
1145
|
+
// TODO(NODE-6491): deprecated: 'Please use timeoutMS instead',
|
|
1146
|
+
default: 0,
|
|
1147
|
+
type: 'uint'
|
|
1148
|
+
},
|
|
1149
|
+
srvMaxHosts: {
|
|
1150
|
+
type: 'uint',
|
|
1151
|
+
default: 0
|
|
1152
|
+
},
|
|
1153
|
+
srvServiceName: {
|
|
1154
|
+
type: 'string',
|
|
1155
|
+
default: 'mongodb'
|
|
1156
|
+
},
|
|
1157
|
+
ssl: {
|
|
1158
|
+
target: 'tls',
|
|
1159
|
+
type: 'boolean'
|
|
1160
|
+
},
|
|
1161
|
+
timeoutMS: {
|
|
1162
|
+
type: 'uint'
|
|
1163
|
+
},
|
|
1164
|
+
tls: {
|
|
1165
|
+
type: 'boolean'
|
|
1166
|
+
},
|
|
1167
|
+
tlsAllowInvalidCertificates: {
|
|
1168
|
+
target: 'rejectUnauthorized',
|
|
1169
|
+
|
|
1170
|
+
transform({
|
|
1171
|
+
name,
|
|
1172
|
+
values: [value]
|
|
1173
|
+
}) {
|
|
1174
|
+
// allowInvalidCertificates is the inverse of rejectUnauthorized
|
|
1175
|
+
return !getBoolean(name, value);
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1178
|
+
},
|
|
1179
|
+
tlsAllowInvalidHostnames: {
|
|
1180
|
+
target: 'checkServerIdentity',
|
|
1181
|
+
|
|
1182
|
+
transform({
|
|
1183
|
+
name,
|
|
1184
|
+
values: [value]
|
|
1185
|
+
}) {
|
|
1186
|
+
// tlsAllowInvalidHostnames means setting the checkServerIdentity function to a noop
|
|
1187
|
+
return getBoolean(name, value) ? () => undefined : undefined;
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1190
|
+
},
|
|
1191
|
+
tlsCAFile: {
|
|
1192
|
+
type: 'string'
|
|
1193
|
+
},
|
|
1194
|
+
tlsCRLFile: {
|
|
1195
|
+
type: 'string'
|
|
1196
|
+
},
|
|
1197
|
+
tlsCertificateKeyFile: {
|
|
1198
|
+
type: 'string'
|
|
1199
|
+
},
|
|
1200
|
+
tlsCertificateKeyFilePassword: {
|
|
1201
|
+
target: 'passphrase',
|
|
1202
|
+
type: 'any'
|
|
1203
|
+
},
|
|
1204
|
+
tlsInsecure: {
|
|
1205
|
+
transform({
|
|
1206
|
+
name,
|
|
1207
|
+
options,
|
|
1208
|
+
values: [value]
|
|
1209
|
+
}) {
|
|
1210
|
+
const tlsInsecure = getBoolean(name, value);
|
|
1211
|
+
|
|
1212
|
+
if (tlsInsecure) {
|
|
1213
|
+
options.checkServerIdentity = () => undefined;
|
|
1214
|
+
|
|
1215
|
+
options.rejectUnauthorized = false;
|
|
1216
|
+
} else {
|
|
1217
|
+
options.checkServerIdentity = options.tlsAllowInvalidHostnames ? () => undefined : undefined;
|
|
1218
|
+
options.rejectUnauthorized = options.tlsAllowInvalidCertificates ? false : true;
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1221
|
+
return tlsInsecure;
|
|
1222
|
+
}
|
|
1223
|
+
|
|
1224
|
+
},
|
|
1225
|
+
w: {
|
|
1226
|
+
target: 'writeConcern',
|
|
1227
|
+
|
|
1228
|
+
transform({
|
|
1229
|
+
values: [value],
|
|
1230
|
+
options
|
|
1231
|
+
}) {
|
|
1232
|
+
return write_concern_1.WriteConcern.fromOptions({
|
|
1233
|
+
writeConcern: { ...options.writeConcern,
|
|
1234
|
+
w: value
|
|
1235
|
+
}
|
|
1236
|
+
});
|
|
1237
|
+
}
|
|
1238
|
+
|
|
1239
|
+
},
|
|
1240
|
+
waitQueueTimeoutMS: {
|
|
1241
|
+
// TODO(NODE-6491): deprecated: 'Please use timeoutMS instead',
|
|
1242
|
+
default: 0,
|
|
1243
|
+
type: 'uint'
|
|
1244
|
+
},
|
|
1245
|
+
writeConcern: {
|
|
1246
|
+
target: 'writeConcern',
|
|
1247
|
+
|
|
1248
|
+
transform({
|
|
1249
|
+
values: [value],
|
|
1250
|
+
options
|
|
1251
|
+
}) {
|
|
1252
|
+
if ((0, utils_1.isRecord)(value) || value instanceof write_concern_1.WriteConcern) {
|
|
1253
|
+
return write_concern_1.WriteConcern.fromOptions({
|
|
1254
|
+
writeConcern: { ...options.writeConcern,
|
|
1255
|
+
...value
|
|
1256
|
+
}
|
|
1257
|
+
});
|
|
1258
|
+
} else if (value === 'majority' || typeof value === 'number') {
|
|
1259
|
+
return write_concern_1.WriteConcern.fromOptions({
|
|
1260
|
+
writeConcern: { ...options.writeConcern,
|
|
1261
|
+
w: value
|
|
1262
|
+
}
|
|
1263
|
+
});
|
|
1264
|
+
}
|
|
1265
|
+
|
|
1266
|
+
throw new error_1.MongoParseError(`Invalid WriteConcern cannot parse: ${JSON.stringify(value)}`);
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
},
|
|
1270
|
+
wtimeout: {
|
|
1271
|
+
deprecated: 'Please use wtimeoutMS instead',
|
|
1272
|
+
target: 'writeConcern',
|
|
1273
|
+
|
|
1274
|
+
transform({
|
|
1275
|
+
values: [value],
|
|
1276
|
+
options
|
|
1277
|
+
}) {
|
|
1278
|
+
const wc = write_concern_1.WriteConcern.fromOptions({
|
|
1279
|
+
writeConcern: { ...options.writeConcern,
|
|
1280
|
+
wtimeout: getUIntFromOptions('wtimeout', value)
|
|
1281
|
+
}
|
|
1282
|
+
});
|
|
1283
|
+
if (wc) return wc;
|
|
1284
|
+
throw new error_1.MongoParseError(`Cannot make WriteConcern from wtimeout`);
|
|
1285
|
+
}
|
|
1286
|
+
|
|
1287
|
+
},
|
|
1288
|
+
wtimeoutMS: {
|
|
1289
|
+
target: 'writeConcern',
|
|
1290
|
+
|
|
1291
|
+
transform({
|
|
1292
|
+
values: [value],
|
|
1293
|
+
options
|
|
1294
|
+
}) {
|
|
1295
|
+
const wc = write_concern_1.WriteConcern.fromOptions({
|
|
1296
|
+
writeConcern: { ...options.writeConcern,
|
|
1297
|
+
wtimeoutMS: getUIntFromOptions('wtimeoutMS', value)
|
|
1298
|
+
}
|
|
1299
|
+
});
|
|
1300
|
+
if (wc) return wc;
|
|
1301
|
+
throw new error_1.MongoParseError(`Cannot make WriteConcern from wtimeout`);
|
|
1302
|
+
}
|
|
1303
|
+
|
|
1304
|
+
},
|
|
1305
|
+
zlibCompressionLevel: {
|
|
1306
|
+
default: 0,
|
|
1307
|
+
type: 'int'
|
|
1308
|
+
},
|
|
1309
|
+
mongodbLogPath: {
|
|
1310
|
+
transform({
|
|
1311
|
+
values: [value]
|
|
1312
|
+
}) {
|
|
1313
|
+
if (!(typeof value === 'string' && ['stderr', 'stdout'].includes(value) || value && typeof value === 'object' && 'write' in value && typeof value.write === 'function')) {
|
|
1314
|
+
throw new error_1.MongoAPIError(`Option 'mongodbLogPath' must be of type 'stderr' | 'stdout' | MongoDBLogWritable`);
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1317
|
+
return value;
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1320
|
+
},
|
|
1321
|
+
mongodbLogComponentSeverities: {
|
|
1322
|
+
transform({
|
|
1323
|
+
values: [value]
|
|
1324
|
+
}) {
|
|
1325
|
+
if (typeof value !== 'object' || !value) {
|
|
1326
|
+
throw new error_1.MongoAPIError(`Option 'mongodbLogComponentSeverities' must be a non-null object`);
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
for (const [k, v] of Object.entries(value)) {
|
|
1330
|
+
if (typeof v !== 'string' || typeof k !== 'string') {
|
|
1331
|
+
throw new error_1.MongoAPIError(`User input for option 'mongodbLogComponentSeverities' object cannot include a non-string key or value`);
|
|
1332
|
+
}
|
|
1333
|
+
|
|
1334
|
+
if (!Object.values(mongo_logger_1.MongoLoggableComponent).some(val => val === k) && k !== 'default') {
|
|
1335
|
+
throw new error_1.MongoAPIError(`User input for option 'mongodbLogComponentSeverities' contains invalid key: ${k}`);
|
|
1336
|
+
}
|
|
1337
|
+
|
|
1338
|
+
if (!Object.values(mongo_logger_1.SeverityLevel).some(val => val === v)) {
|
|
1339
|
+
throw new error_1.MongoAPIError(`Option 'mongodbLogComponentSeverities' does not support ${v} as a value for ${k}`);
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
return value;
|
|
1344
|
+
}
|
|
1345
|
+
|
|
1346
|
+
},
|
|
1347
|
+
mongodbLogMaxDocumentLength: {
|
|
1348
|
+
type: 'uint'
|
|
1349
|
+
},
|
|
1350
|
+
// Custom types for modifying core behavior
|
|
1351
|
+
connectionType: {
|
|
1352
|
+
type: 'any'
|
|
1353
|
+
},
|
|
1354
|
+
srvPoller: {
|
|
1355
|
+
type: 'any'
|
|
1356
|
+
},
|
|
1357
|
+
// Accepted Node.js Options
|
|
1358
|
+
allowPartialTrustChain: {
|
|
1359
|
+
type: 'any'
|
|
1360
|
+
},
|
|
1361
|
+
minDHSize: {
|
|
1362
|
+
type: 'any'
|
|
1363
|
+
},
|
|
1364
|
+
pskCallback: {
|
|
1365
|
+
type: 'any'
|
|
1366
|
+
},
|
|
1367
|
+
secureContext: {
|
|
1368
|
+
type: 'any'
|
|
1369
|
+
},
|
|
1370
|
+
enableTrace: {
|
|
1371
|
+
type: 'any'
|
|
1372
|
+
},
|
|
1373
|
+
requestCert: {
|
|
1374
|
+
type: 'any'
|
|
1375
|
+
},
|
|
1376
|
+
rejectUnauthorized: {
|
|
1377
|
+
type: 'any'
|
|
1378
|
+
},
|
|
1379
|
+
checkServerIdentity: {
|
|
1380
|
+
type: 'any'
|
|
1381
|
+
},
|
|
1382
|
+
keepAliveInitialDelay: {
|
|
1383
|
+
type: 'any'
|
|
1384
|
+
},
|
|
1385
|
+
ALPNProtocols: {
|
|
1386
|
+
type: 'any'
|
|
1387
|
+
},
|
|
1388
|
+
SNICallback: {
|
|
1389
|
+
type: 'any'
|
|
1390
|
+
},
|
|
1391
|
+
session: {
|
|
1392
|
+
type: 'any'
|
|
1393
|
+
},
|
|
1394
|
+
requestOCSP: {
|
|
1395
|
+
type: 'any'
|
|
1396
|
+
},
|
|
1397
|
+
localAddress: {
|
|
1398
|
+
type: 'any'
|
|
1399
|
+
},
|
|
1400
|
+
localPort: {
|
|
1401
|
+
type: 'any'
|
|
1402
|
+
},
|
|
1403
|
+
hints: {
|
|
1404
|
+
type: 'any'
|
|
1405
|
+
},
|
|
1406
|
+
lookup: {
|
|
1407
|
+
type: 'any'
|
|
1408
|
+
},
|
|
1409
|
+
ca: {
|
|
1410
|
+
type: 'any'
|
|
1411
|
+
},
|
|
1412
|
+
cert: {
|
|
1413
|
+
type: 'any'
|
|
1414
|
+
},
|
|
1415
|
+
ciphers: {
|
|
1416
|
+
type: 'any'
|
|
1417
|
+
},
|
|
1418
|
+
crl: {
|
|
1419
|
+
type: 'any'
|
|
1420
|
+
},
|
|
1421
|
+
ecdhCurve: {
|
|
1422
|
+
type: 'any'
|
|
1423
|
+
},
|
|
1424
|
+
key: {
|
|
1425
|
+
type: 'any'
|
|
1426
|
+
},
|
|
1427
|
+
passphrase: {
|
|
1428
|
+
type: 'any'
|
|
1429
|
+
},
|
|
1430
|
+
pfx: {
|
|
1431
|
+
type: 'any'
|
|
1432
|
+
},
|
|
1433
|
+
secureProtocol: {
|
|
1434
|
+
type: 'any'
|
|
1435
|
+
},
|
|
1436
|
+
index: {
|
|
1437
|
+
type: 'any'
|
|
1438
|
+
},
|
|
1439
|
+
// Legacy options from v3 era
|
|
1440
|
+
useNewUrlParser: {
|
|
1441
|
+
type: 'boolean',
|
|
1442
|
+
deprecated: 'useNewUrlParser has no effect since Node.js Driver version 4.0.0 and will be removed in the next major version'
|
|
1443
|
+
},
|
|
1444
|
+
useUnifiedTopology: {
|
|
1445
|
+
type: 'boolean',
|
|
1446
|
+
deprecated: 'useUnifiedTopology has no effect since Node.js Driver version 4.0.0 and will be removed in the next major version'
|
|
1447
|
+
},
|
|
1448
|
+
__skipPingOnConnect: {
|
|
1449
|
+
type: 'boolean'
|
|
1450
|
+
}
|
|
1451
|
+
};
|
|
1452
|
+
exports.DEFAULT_OPTIONS = new CaseInsensitiveMap(Object.entries(exports.OPTIONS).filter(([, descriptor]) => descriptor.default != null).map(([k, d]) => [k, d.default]));
|