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,278 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.OnDemandDocument = void 0;
|
|
7
|
+
|
|
8
|
+
const bson_1 = require("../../../bson");
|
|
9
|
+
/** @internal */
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class OnDemandDocument {
|
|
13
|
+
constructor(
|
|
14
|
+
/** BSON bytes, this document begins at offset */
|
|
15
|
+
bson,
|
|
16
|
+
/** The start of the document */
|
|
17
|
+
offset = 0,
|
|
18
|
+
/** If this is an embedded document, indicates if this was a BSON array */
|
|
19
|
+
isArray = false,
|
|
20
|
+
/** If elements was already calculated */
|
|
21
|
+
elements) {
|
|
22
|
+
this.bson = bson;
|
|
23
|
+
this.offset = offset;
|
|
24
|
+
this.isArray = isArray;
|
|
25
|
+
/**
|
|
26
|
+
* Maps JS strings to elements and jsValues for speeding up subsequent lookups.
|
|
27
|
+
* - If `false` then name does not exist in the BSON document
|
|
28
|
+
* - If `CachedBSONElement` instance name exists
|
|
29
|
+
* - If `cache[name].value == null` jsValue has not yet been parsed
|
|
30
|
+
* - Null/Undefined values do not get cached because they are zero-length values.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
this.cache = Object.create(null);
|
|
34
|
+
/** Caches the index of elements that have been named */
|
|
35
|
+
|
|
36
|
+
this.indexFound = Object.create(null);
|
|
37
|
+
this.elements = elements ?? (0, bson_1.parseToElementsToArray)(this.bson, offset);
|
|
38
|
+
}
|
|
39
|
+
/** Only supports basic latin strings */
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
isElementName(name, element) {
|
|
43
|
+
const nameLength = element[2
|
|
44
|
+
/* BSONElementOffset.nameLength */
|
|
45
|
+
];
|
|
46
|
+
const nameOffset = element[1
|
|
47
|
+
/* BSONElementOffset.nameOffset */
|
|
48
|
+
];
|
|
49
|
+
if (name.length !== nameLength) return false;
|
|
50
|
+
const nameEnd = nameOffset + nameLength;
|
|
51
|
+
|
|
52
|
+
for (let byteIndex = nameOffset, charIndex = 0; charIndex < name.length && byteIndex < nameEnd; charIndex++, byteIndex++) {
|
|
53
|
+
if (this.bson[byteIndex] !== name.charCodeAt(charIndex)) return false;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Seeks into the elements array for an element matching the given name.
|
|
60
|
+
*
|
|
61
|
+
* @remarks
|
|
62
|
+
* Caching:
|
|
63
|
+
* - Caches the existence of a property making subsequent look ups for non-existent properties return immediately
|
|
64
|
+
* - Caches names mapped to elements to avoid reiterating the array and comparing the name again
|
|
65
|
+
* - Caches the index at which an element has been found to prevent rechecking against elements already determined to belong to another name
|
|
66
|
+
*
|
|
67
|
+
* @param name - a basic latin string name of a BSON element
|
|
68
|
+
* @returns
|
|
69
|
+
*/
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
getElement(name) {
|
|
73
|
+
const cachedElement = this.cache[name];
|
|
74
|
+
if (cachedElement === false) return null;
|
|
75
|
+
|
|
76
|
+
if (cachedElement != null) {
|
|
77
|
+
return cachedElement;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (typeof name === 'number') {
|
|
81
|
+
if (this.isArray) {
|
|
82
|
+
if (name < this.elements.length) {
|
|
83
|
+
const element = this.elements[name];
|
|
84
|
+
const cachedElement = {
|
|
85
|
+
element,
|
|
86
|
+
value: undefined
|
|
87
|
+
};
|
|
88
|
+
this.cache[name] = cachedElement;
|
|
89
|
+
this.indexFound[name] = true;
|
|
90
|
+
return cachedElement;
|
|
91
|
+
} else {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
} else {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
for (let index = 0; index < this.elements.length; index++) {
|
|
100
|
+
const element = this.elements[index]; // skip this element if it has already been associated with a name
|
|
101
|
+
|
|
102
|
+
if (!(index in this.indexFound) && this.isElementName(name, element)) {
|
|
103
|
+
const cachedElement = {
|
|
104
|
+
element,
|
|
105
|
+
value: undefined
|
|
106
|
+
};
|
|
107
|
+
this.cache[name] = cachedElement;
|
|
108
|
+
this.indexFound[index] = true;
|
|
109
|
+
return cachedElement;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
this.cache[name] = false;
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
toJSValue(element, as) {
|
|
118
|
+
const type = element[0
|
|
119
|
+
/* BSONElementOffset.type */
|
|
120
|
+
];
|
|
121
|
+
const offset = element[3
|
|
122
|
+
/* BSONElementOffset.offset */
|
|
123
|
+
];
|
|
124
|
+
const length = element[4
|
|
125
|
+
/* BSONElementOffset.length */
|
|
126
|
+
];
|
|
127
|
+
|
|
128
|
+
if (as !== type) {
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
switch (as) {
|
|
133
|
+
case bson_1.BSONType.null:
|
|
134
|
+
case bson_1.BSONType.undefined:
|
|
135
|
+
return null;
|
|
136
|
+
|
|
137
|
+
case bson_1.BSONType.double:
|
|
138
|
+
return (0, bson_1.getFloat64LE)(this.bson, offset);
|
|
139
|
+
|
|
140
|
+
case bson_1.BSONType.int:
|
|
141
|
+
return (0, bson_1.getInt32LE)(this.bson, offset);
|
|
142
|
+
|
|
143
|
+
case bson_1.BSONType.long:
|
|
144
|
+
return (0, bson_1.getBigInt64LE)(this.bson, offset);
|
|
145
|
+
|
|
146
|
+
case bson_1.BSONType.bool:
|
|
147
|
+
return Boolean(this.bson[offset]);
|
|
148
|
+
|
|
149
|
+
case bson_1.BSONType.objectId:
|
|
150
|
+
return new bson_1.ObjectId(this.bson.subarray(offset, offset + 12));
|
|
151
|
+
|
|
152
|
+
case bson_1.BSONType.timestamp:
|
|
153
|
+
return new bson_1.Timestamp((0, bson_1.getBigInt64LE)(this.bson, offset));
|
|
154
|
+
|
|
155
|
+
case bson_1.BSONType.string:
|
|
156
|
+
return (0, bson_1.toUTF8)(this.bson, offset + 4, offset + length - 1, false);
|
|
157
|
+
|
|
158
|
+
case bson_1.BSONType.binData:
|
|
159
|
+
{
|
|
160
|
+
const totalBinarySize = (0, bson_1.getInt32LE)(this.bson, offset);
|
|
161
|
+
const subType = this.bson[offset + 4];
|
|
162
|
+
|
|
163
|
+
if (subType === 2) {
|
|
164
|
+
const subType2BinarySize = (0, bson_1.getInt32LE)(this.bson, offset + 1 + 4);
|
|
165
|
+
if (subType2BinarySize < 0) throw new bson_1.BSONError('Negative binary type element size found for subtype 0x02');
|
|
166
|
+
if (subType2BinarySize > totalBinarySize - 4) throw new bson_1.BSONError('Binary type with subtype 0x02 contains too long binary size');
|
|
167
|
+
if (subType2BinarySize < totalBinarySize - 4) throw new bson_1.BSONError('Binary type with subtype 0x02 contains too short binary size');
|
|
168
|
+
return new bson_1.Binary(this.bson.subarray(offset + 1 + 4 + 4, offset + 1 + 4 + 4 + subType2BinarySize), 2);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return new bson_1.Binary(this.bson.subarray(offset + 1 + 4, offset + 1 + 4 + totalBinarySize), subType);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
case bson_1.BSONType.date:
|
|
175
|
+
// Pretend this is correct.
|
|
176
|
+
return new Date(Number((0, bson_1.getBigInt64LE)(this.bson, offset)));
|
|
177
|
+
|
|
178
|
+
case bson_1.BSONType.object:
|
|
179
|
+
return new OnDemandDocument(this.bson, offset);
|
|
180
|
+
|
|
181
|
+
case bson_1.BSONType.array:
|
|
182
|
+
return new OnDemandDocument(this.bson, offset, true);
|
|
183
|
+
|
|
184
|
+
default:
|
|
185
|
+
throw new bson_1.BSONError(`Unsupported BSON type: ${as}`);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Returns the number of elements in this BSON document
|
|
190
|
+
*/
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
size() {
|
|
194
|
+
return this.elements.length;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Checks for the existence of an element by name.
|
|
198
|
+
*
|
|
199
|
+
* @remarks
|
|
200
|
+
* Uses `getElement` with the expectation that will populate caches such that a `has` call
|
|
201
|
+
* followed by a `getElement` call will not repeat the cost paid by the first look up.
|
|
202
|
+
*
|
|
203
|
+
* @param name - element name
|
|
204
|
+
*/
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
has(name) {
|
|
208
|
+
const cachedElement = this.cache[name];
|
|
209
|
+
if (cachedElement === false) return false;
|
|
210
|
+
if (cachedElement != null) return true;
|
|
211
|
+
return this.getElement(name) != null;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
get(name, as, required) {
|
|
215
|
+
const element = this.getElement(name);
|
|
216
|
+
|
|
217
|
+
if (element == null) {
|
|
218
|
+
if (required === true) {
|
|
219
|
+
throw new bson_1.BSONError(`BSON element "${name}" is missing`);
|
|
220
|
+
} else {
|
|
221
|
+
return null;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if (element.value == null) {
|
|
226
|
+
const value = this.toJSValue(element.element, as);
|
|
227
|
+
|
|
228
|
+
if (value == null) {
|
|
229
|
+
if (required === true) {
|
|
230
|
+
throw new bson_1.BSONError(`BSON element "${name}" is missing`);
|
|
231
|
+
} else {
|
|
232
|
+
return null;
|
|
233
|
+
}
|
|
234
|
+
} // It is important to never store null
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
element.value = value;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
return element.value;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
getNumber(name, required) {
|
|
244
|
+
const maybeBool = this.get(name, bson_1.BSONType.bool);
|
|
245
|
+
const bool = maybeBool == null ? null : maybeBool ? 1 : 0;
|
|
246
|
+
const maybeLong = this.get(name, bson_1.BSONType.long);
|
|
247
|
+
const long = maybeLong == null ? null : Number(maybeLong);
|
|
248
|
+
const result = bool ?? long ?? this.get(name, bson_1.BSONType.int) ?? this.get(name, bson_1.BSONType.double);
|
|
249
|
+
|
|
250
|
+
if (required === true && result == null) {
|
|
251
|
+
throw new bson_1.BSONError(`BSON element "${name}" is missing`);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
return result;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Deserialize this object, DOES NOT cache result so avoid multiple invocations
|
|
258
|
+
* @param options - BSON deserialization options
|
|
259
|
+
*/
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
toObject(options) {
|
|
263
|
+
return (0, bson_1.deserialize)(this.bson, { ...options,
|
|
264
|
+
index: this.offset,
|
|
265
|
+
allowObjectSmallerThanBufferSize: true
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
/** Returns this document's bytes only */
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
toBytes() {
|
|
272
|
+
const size = (0, bson_1.getInt32LE)(this.bson, this.offset);
|
|
273
|
+
return this.bson.subarray(this.offset, this.offset + size);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
exports.OnDemandDocument = OnDemandDocument;
|
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ClientBulkWriteCursorResponse = exports.ExplainedCursorResponse = exports.CursorResponse = exports.MongoDBResponse = void 0;
|
|
7
|
+
exports.isErrorResponse = isErrorResponse;
|
|
8
|
+
|
|
9
|
+
const bson_1 = require("../../bson");
|
|
10
|
+
|
|
11
|
+
const error_1 = require("../../error");
|
|
12
|
+
|
|
13
|
+
const utils_1 = require("../../utils");
|
|
14
|
+
|
|
15
|
+
const document_1 = require("./on_demand/document");
|
|
16
|
+
/**
|
|
17
|
+
* Accepts a BSON payload and checks for na "ok: 0" element.
|
|
18
|
+
* This utility is intended to prevent calling response class constructors
|
|
19
|
+
* that expect the result to be a success and demand certain properties to exist.
|
|
20
|
+
*
|
|
21
|
+
* For example, a cursor response always expects a cursor embedded document.
|
|
22
|
+
* In order to write the class such that the properties reflect that assertion (non-null)
|
|
23
|
+
* we cannot invoke the subclass constructor if the BSON represents an error.
|
|
24
|
+
*
|
|
25
|
+
* @param bytes - BSON document returned from the server
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
function isErrorResponse(bson, elements) {
|
|
30
|
+
for (let eIdx = 0; eIdx < elements.length; eIdx++) {
|
|
31
|
+
const element = elements[eIdx];
|
|
32
|
+
|
|
33
|
+
if (element[2
|
|
34
|
+
/* BSONElementOffset.nameLength */
|
|
35
|
+
] === 2) {
|
|
36
|
+
const nameOffset = element[1
|
|
37
|
+
/* BSONElementOffset.nameOffset */
|
|
38
|
+
]; // 111 == "o", 107 == "k"
|
|
39
|
+
|
|
40
|
+
if (bson[nameOffset] === 111 && bson[nameOffset + 1] === 107) {
|
|
41
|
+
const valueOffset = element[3
|
|
42
|
+
/* BSONElementOffset.offset */
|
|
43
|
+
];
|
|
44
|
+
const valueLength = element[4
|
|
45
|
+
/* BSONElementOffset.length */
|
|
46
|
+
]; // If any byte in the length of the ok number (works for any type) is non zero,
|
|
47
|
+
// then it is considered "ok: 1"
|
|
48
|
+
|
|
49
|
+
for (let i = valueOffset; i < valueOffset + valueLength; i++) {
|
|
50
|
+
if (bson[i] !== 0x00) return false;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
/** @internal */
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
class MongoDBResponse extends document_1.OnDemandDocument {
|
|
64
|
+
get(name, as, required) {
|
|
65
|
+
try {
|
|
66
|
+
return super.get(name, as, required);
|
|
67
|
+
} catch (cause) {
|
|
68
|
+
throw new error_1.MongoUnexpectedServerResponseError(cause.message, {
|
|
69
|
+
cause
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
static is(value) {
|
|
75
|
+
return value instanceof MongoDBResponse;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
static make(bson) {
|
|
79
|
+
const elements = (0, bson_1.parseToElementsToArray)(bson, 0);
|
|
80
|
+
const isError = isErrorResponse(bson, elements);
|
|
81
|
+
return isError ? new MongoDBResponse(bson, 0, false, elements) : new this(bson, 0, false, elements);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Returns true iff:
|
|
85
|
+
* - ok is 0 and the top-level code === 50
|
|
86
|
+
* - ok is 1 and the writeErrors array contains a code === 50
|
|
87
|
+
* - ok is 1 and the writeConcern object contains a code === 50
|
|
88
|
+
*/
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
get isMaxTimeExpiredError() {
|
|
92
|
+
// {ok: 0, code: 50 ... }
|
|
93
|
+
const isTopLevel = this.ok === 0 && this.code === error_1.MONGODB_ERROR_CODES.MaxTimeMSExpired;
|
|
94
|
+
if (isTopLevel) return true;
|
|
95
|
+
if (this.ok === 0) return false; // {ok: 1, writeConcernError: {code: 50 ... }}
|
|
96
|
+
|
|
97
|
+
const isWriteConcern = this.get('writeConcernError', bson_1.BSONType.object)?.getNumber('code') === error_1.MONGODB_ERROR_CODES.MaxTimeMSExpired;
|
|
98
|
+
if (isWriteConcern) return true;
|
|
99
|
+
const writeErrors = this.get('writeErrors', bson_1.BSONType.array);
|
|
100
|
+
|
|
101
|
+
if (writeErrors?.size()) {
|
|
102
|
+
for (let i = 0; i < writeErrors.size(); i++) {
|
|
103
|
+
const isWriteError = writeErrors.get(i, bson_1.BSONType.object)?.getNumber('code') === error_1.MONGODB_ERROR_CODES.MaxTimeMSExpired; // {ok: 1, writeErrors: [{code: 50 ... }]}
|
|
104
|
+
|
|
105
|
+
if (isWriteError) return true;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Drivers can safely assume that the `recoveryToken` field is always a BSON document but drivers MUST NOT modify the
|
|
113
|
+
* contents of the document.
|
|
114
|
+
*/
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
get recoveryToken() {
|
|
118
|
+
return this.get('recoveryToken', bson_1.BSONType.object)?.toObject({
|
|
119
|
+
promoteValues: false,
|
|
120
|
+
promoteLongs: false,
|
|
121
|
+
promoteBuffers: false,
|
|
122
|
+
validation: {
|
|
123
|
+
utf8: true
|
|
124
|
+
}
|
|
125
|
+
}) ?? null;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* The server creates a cursor in response to a snapshot find/aggregate command and reports atClusterTime within the cursor field in the response.
|
|
129
|
+
* For the distinct command the server adds a top-level atClusterTime field to the response.
|
|
130
|
+
* The atClusterTime field represents the timestamp of the read and is guaranteed to be majority committed.
|
|
131
|
+
*/
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
get atClusterTime() {
|
|
135
|
+
return this.get('cursor', bson_1.BSONType.object)?.get('atClusterTime', bson_1.BSONType.timestamp) ?? this.get('atClusterTime', bson_1.BSONType.timestamp);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
get operationTime() {
|
|
139
|
+
return this.get('operationTime', bson_1.BSONType.timestamp);
|
|
140
|
+
}
|
|
141
|
+
/** Normalizes whatever BSON value is "ok" to a JS number 1 or 0. */
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
get ok() {
|
|
145
|
+
return this.getNumber('ok') ? 1 : 0;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
get $err() {
|
|
149
|
+
return this.get('$err', bson_1.BSONType.string);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
get errmsg() {
|
|
153
|
+
return this.get('errmsg', bson_1.BSONType.string);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
get code() {
|
|
157
|
+
return this.getNumber('code');
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
get $clusterTime() {
|
|
161
|
+
if (!('clusterTime' in this)) {
|
|
162
|
+
const clusterTimeDoc = this.get('$clusterTime', bson_1.BSONType.object);
|
|
163
|
+
|
|
164
|
+
if (clusterTimeDoc == null) {
|
|
165
|
+
this.clusterTime = null;
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const clusterTime = clusterTimeDoc.get('clusterTime', bson_1.BSONType.timestamp, true);
|
|
170
|
+
const signature = clusterTimeDoc.get('signature', bson_1.BSONType.object)?.toObject(); // @ts-expect-error: `signature` is incorrectly typed. It is public API.
|
|
171
|
+
|
|
172
|
+
this.clusterTime = {
|
|
173
|
+
clusterTime,
|
|
174
|
+
signature
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
return this.clusterTime ?? null;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
toObject(options) {
|
|
182
|
+
const exactBSONOptions = { ...(0, bson_1.pluckBSONSerializeOptions)(options ?? {}),
|
|
183
|
+
validation: (0, bson_1.parseUtf8ValidationOption)(options)
|
|
184
|
+
};
|
|
185
|
+
return super.toObject(exactBSONOptions);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
exports.MongoDBResponse = MongoDBResponse; // {ok:1}
|
|
191
|
+
|
|
192
|
+
MongoDBResponse.empty = new MongoDBResponse(new Uint8Array([13, 0, 0, 0, 16, 111, 107, 0, 1, 0, 0, 0, 0]));
|
|
193
|
+
/** @internal */
|
|
194
|
+
|
|
195
|
+
class CursorResponse extends MongoDBResponse {
|
|
196
|
+
constructor() {
|
|
197
|
+
super(...arguments);
|
|
198
|
+
this._batch = null;
|
|
199
|
+
this.iterated = 0;
|
|
200
|
+
this._encryptedBatch = null;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* This supports a feature of the FindCursor.
|
|
204
|
+
* It is an optimization to avoid an extra getMore when the limit has been reached
|
|
205
|
+
*/
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
static get emptyGetMore() {
|
|
209
|
+
return new CursorResponse((0, bson_1.serialize)({
|
|
210
|
+
ok: 1,
|
|
211
|
+
cursor: {
|
|
212
|
+
id: 0n,
|
|
213
|
+
nextBatch: []
|
|
214
|
+
}
|
|
215
|
+
}));
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
static is(value) {
|
|
219
|
+
return value instanceof CursorResponse || value === CursorResponse.emptyGetMore;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
get cursor() {
|
|
223
|
+
return this.get('cursor', bson_1.BSONType.object, true);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
get id() {
|
|
227
|
+
try {
|
|
228
|
+
return bson_1.Long.fromBigInt(this.cursor.get('id', bson_1.BSONType.long, true));
|
|
229
|
+
} catch (cause) {
|
|
230
|
+
throw new error_1.MongoUnexpectedServerResponseError(cause.message, {
|
|
231
|
+
cause
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
get ns() {
|
|
237
|
+
const namespace = this.cursor.get('ns', bson_1.BSONType.string);
|
|
238
|
+
if (namespace != null) return (0, utils_1.ns)(namespace);
|
|
239
|
+
return null;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
get length() {
|
|
243
|
+
return Math.max(this.batchSize - this.iterated, 0);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
get encryptedBatch() {
|
|
247
|
+
if (this.encryptedResponse == null) return null;
|
|
248
|
+
if (this._encryptedBatch != null) return this._encryptedBatch;
|
|
249
|
+
const cursor = this.encryptedResponse?.get('cursor', bson_1.BSONType.object);
|
|
250
|
+
if (cursor?.has('firstBatch')) this._encryptedBatch = cursor.get('firstBatch', bson_1.BSONType.array, true);else if (cursor?.has('nextBatch')) this._encryptedBatch = cursor.get('nextBatch', bson_1.BSONType.array, true);else throw new error_1.MongoUnexpectedServerResponseError('Cursor document did not contain a batch');
|
|
251
|
+
return this._encryptedBatch;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
get batch() {
|
|
255
|
+
if (this._batch != null) return this._batch;
|
|
256
|
+
const cursor = this.cursor;
|
|
257
|
+
if (cursor.has('firstBatch')) this._batch = cursor.get('firstBatch', bson_1.BSONType.array, true);else if (cursor.has('nextBatch')) this._batch = cursor.get('nextBatch', bson_1.BSONType.array, true);else throw new error_1.MongoUnexpectedServerResponseError('Cursor document did not contain a batch');
|
|
258
|
+
return this._batch;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
get batchSize() {
|
|
262
|
+
return this.batch?.size();
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
get postBatchResumeToken() {
|
|
266
|
+
return this.cursor.get('postBatchResumeToken', bson_1.BSONType.object)?.toObject({
|
|
267
|
+
promoteValues: false,
|
|
268
|
+
promoteLongs: false,
|
|
269
|
+
promoteBuffers: false,
|
|
270
|
+
validation: {
|
|
271
|
+
utf8: true
|
|
272
|
+
}
|
|
273
|
+
}) ?? null;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
shift(options) {
|
|
277
|
+
if (this.iterated >= this.batchSize) {
|
|
278
|
+
return null;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
const result = this.batch.get(this.iterated, bson_1.BSONType.object, true) ?? null;
|
|
282
|
+
const encryptedResult = this.encryptedBatch?.get(this.iterated, bson_1.BSONType.object, true) ?? null;
|
|
283
|
+
this.iterated += 1;
|
|
284
|
+
|
|
285
|
+
if (options?.raw) {
|
|
286
|
+
return result.toBytes();
|
|
287
|
+
} else {
|
|
288
|
+
const object = result.toObject(options);
|
|
289
|
+
|
|
290
|
+
if (encryptedResult) {
|
|
291
|
+
(0, utils_1.decorateDecryptionResult)(object, encryptedResult.toObject(options), true);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
return object;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
clear() {
|
|
299
|
+
this.iterated = this.batchSize;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
exports.CursorResponse = CursorResponse;
|
|
305
|
+
/**
|
|
306
|
+
* Explain responses have nothing to do with cursor responses
|
|
307
|
+
* This class serves to temporarily avoid refactoring how cursors handle
|
|
308
|
+
* explain responses which is to detect that the response is not cursor-like and return the explain
|
|
309
|
+
* result as the "first and only" document in the "batch" and end the "cursor"
|
|
310
|
+
*/
|
|
311
|
+
|
|
312
|
+
class ExplainedCursorResponse extends CursorResponse {
|
|
313
|
+
constructor() {
|
|
314
|
+
super(...arguments);
|
|
315
|
+
this.isExplain = true;
|
|
316
|
+
this._length = 1;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
get id() {
|
|
320
|
+
return bson_1.Long.fromBigInt(0n);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
get batchSize() {
|
|
324
|
+
return 0;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
get ns() {
|
|
328
|
+
return null;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
get length() {
|
|
332
|
+
return this._length;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
shift(options) {
|
|
336
|
+
if (this._length === 0) return null;
|
|
337
|
+
this._length -= 1;
|
|
338
|
+
return this.toObject(options);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
exports.ExplainedCursorResponse = ExplainedCursorResponse;
|
|
344
|
+
/**
|
|
345
|
+
* Client bulk writes have some extra metadata at the top level that needs to be
|
|
346
|
+
* included in the result returned to the user.
|
|
347
|
+
*/
|
|
348
|
+
|
|
349
|
+
class ClientBulkWriteCursorResponse extends CursorResponse {
|
|
350
|
+
get insertedCount() {
|
|
351
|
+
return this.get('nInserted', bson_1.BSONType.int, true);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
get upsertedCount() {
|
|
355
|
+
return this.get('nUpserted', bson_1.BSONType.int, true);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
get matchedCount() {
|
|
359
|
+
return this.get('nMatched', bson_1.BSONType.int, true);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
get modifiedCount() {
|
|
363
|
+
return this.get('nModified', bson_1.BSONType.int, true);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
get deletedCount() {
|
|
367
|
+
return this.get('nDeleted', bson_1.BSONType.int, true);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
get writeConcernError() {
|
|
371
|
+
return this.get('writeConcernError', bson_1.BSONType.object, false);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
exports.ClientBulkWriteCursorResponse = ClientBulkWriteCursorResponse;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getReadPreference = getReadPreference;
|
|
7
|
+
exports.isSharded = isSharded;
|
|
8
|
+
|
|
9
|
+
const error_1 = require("../../error");
|
|
10
|
+
|
|
11
|
+
const read_preference_1 = require("../../read_preference");
|
|
12
|
+
|
|
13
|
+
const common_1 = require("../../sdam/common");
|
|
14
|
+
|
|
15
|
+
const topology_description_1 = require("../../sdam/topology_description");
|
|
16
|
+
|
|
17
|
+
function getReadPreference(options) {
|
|
18
|
+
// Default to command version of the readPreference.
|
|
19
|
+
let readPreference = options?.readPreference ?? read_preference_1.ReadPreference.primary;
|
|
20
|
+
|
|
21
|
+
if (typeof readPreference === 'string') {
|
|
22
|
+
readPreference = read_preference_1.ReadPreference.fromString(readPreference);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (!(readPreference instanceof read_preference_1.ReadPreference)) {
|
|
26
|
+
throw new error_1.MongoInvalidArgumentError('Option "readPreference" must be a ReadPreference instance');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return readPreference;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function isSharded(topologyOrServer) {
|
|
33
|
+
if (topologyOrServer == null) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (topologyOrServer.description && topologyOrServer.description.type === common_1.ServerType.Mongos) {
|
|
38
|
+
return true;
|
|
39
|
+
} // NOTE: This is incredibly inefficient, and should be removed once command construction
|
|
40
|
+
// happens based on `Server` not `Topology`.
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
if (topologyOrServer.description && topologyOrServer.description instanceof topology_description_1.TopologyDescription) {
|
|
44
|
+
const servers = Array.from(topologyOrServer.description.servers.values());
|
|
45
|
+
return servers.some(server => server.type === common_1.ServerType.Mongos);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return false;
|
|
49
|
+
}
|