oxygen-cli 1.40.2-beta.1 → 1.41.0

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.
Files changed (442) hide show
  1. package/CHANGELOG.md +1755 -1742
  2. package/LICENSE +672 -672
  3. package/README.md +37 -37
  4. package/build/core/OxygenCore.js +1 -1
  5. package/build/core/OxygenEvents.js +1 -1
  6. package/build/core/OxygenModule.js +1 -1
  7. package/build/core/OxygenService.js +1 -1
  8. package/build/core/OxygenSubModule.js +1 -1
  9. package/build/core/WebDriverModule.js +1 -1
  10. package/build/core/utils.js +1 -1
  11. package/build/errors/HookError.js +1 -1
  12. package/build/errors/ModuleError.js +1 -1
  13. package/build/errors/ModuleUnavailableError.js +1 -1
  14. package/build/errors/OxygenError.js +1 -1
  15. package/build/errors/ScriptNotFound.js +1 -1
  16. package/build/errors/helper.js +1 -1
  17. package/build/index.js +1 -1
  18. package/build/lib/cli-util.js +1 -1
  19. package/build/lib/cli.js +1 -1
  20. package/build/lib/debugger.js +1 -1
  21. package/build/lib/img-merge.js +1 -1
  22. package/build/lib/launcher.js +1 -1
  23. package/build/lib/logger.js +43 -43
  24. package/build/lib/moduleRequire.js +1 -1
  25. package/build/lib/parallel-launcher.js +1 -1
  26. package/build/lib/param-manager.js +1 -1
  27. package/build/lib/param-reader-csv.js +1 -1
  28. package/build/lib/param-reader-excel.js +1 -1
  29. package/build/lib/param-reader-json.js +1 -1
  30. package/build/lib/text-to-image.js +1 -1
  31. package/build/lib/util.js +1 -1
  32. package/build/model/case-result.js +1 -1
  33. package/build/model/failure.js +1 -1
  34. package/build/model/status.js +1 -1
  35. package/build/model/step-result.js +1 -1
  36. package/build/model/suite-result.js +1 -1
  37. package/build/model/test-result.js +1 -1
  38. package/build/model/testcase.js +1 -1
  39. package/build/model/testsuite.js +1 -1
  40. package/build/ox_modules/index.js +1 -1
  41. package/build/ox_modules/module-assert.js +37 -37
  42. package/build/ox_modules/module-date.js +24 -24
  43. package/build/ox_modules/module-db.js +52 -52
  44. package/build/ox_modules/module-email.js +59 -59
  45. package/build/ox_modules/module-eyes.js +34 -34
  46. package/build/ox_modules/module-http/ntlm-util.js +10 -10
  47. package/build/ox_modules/module-http/ntlm.js +15 -15
  48. package/build/ox_modules/module-http.js +132 -132
  49. package/build/ox_modules/module-log.js +27 -27
  50. package/build/ox_modules/module-mailinator.js +87 -87
  51. package/build/ox_modules/module-mob/commands/alertAccept.js +17 -17
  52. package/build/ox_modules/module-mob/commands/alertDismiss.js +17 -17
  53. package/build/ox_modules/module-mob/commands/assertAlert.js +20 -20
  54. package/build/ox_modules/module-mob/commands/assertText.js +21 -21
  55. package/build/ox_modules/module-mob/commands/assertTitle.js +19 -19
  56. package/build/ox_modules/module-mob/commands/assertValue.js +18 -18
  57. package/build/ox_modules/module-mob/commands/back.js +16 -16
  58. package/build/ox_modules/module-mob/commands/clear.js +19 -19
  59. package/build/ox_modules/module-mob/commands/click.js +17 -17
  60. package/build/ox_modules/module-mob/commands/clickHidden.js +17 -17
  61. package/build/ox_modules/module-mob/commands/clickLong.js +18 -18
  62. package/build/ox_modules/module-mob/commands/clickMultipleTimes.js +18 -18
  63. package/build/ox_modules/module-mob/commands/closeApp.js +16 -16
  64. package/build/ox_modules/module-mob/commands/debug.js +16 -16
  65. package/build/ox_modules/module-mob/commands/dragAndDrop.js +19 -19
  66. package/build/ox_modules/module-mob/commands/enableNetwork.js +27 -27
  67. package/build/ox_modules/module-mob/commands/execute.js +21 -21
  68. package/build/ox_modules/module-mob/commands/findElement.js +20 -20
  69. package/build/ox_modules/module-mob/commands/findElements.js +23 -23
  70. package/build/ox_modules/module-mob/commands/getAlertText.js +17 -17
  71. package/build/ox_modules/module-mob/commands/getAppiumLogs.js +16 -16
  72. package/build/ox_modules/module-mob/commands/getBrowserLogs.js +16 -16
  73. package/build/ox_modules/module-mob/commands/getCurrentActivity.js +15 -15
  74. package/build/ox_modules/module-mob/commands/getCurrentPackage.js +15 -15
  75. package/build/ox_modules/module-mob/commands/getDeviceLogs.js +16 -16
  76. package/build/ox_modules/module-mob/commands/getDeviceTime.js +16 -16
  77. package/build/ox_modules/module-mob/commands/getLocation.js +20 -20
  78. package/build/ox_modules/module-mob/commands/getSource.js +16 -16
  79. package/build/ox_modules/module-mob/commands/getText.js +18 -18
  80. package/build/ox_modules/module-mob/commands/getTitle.js +13 -13
  81. package/build/ox_modules/module-mob/commands/getUrl.js +17 -17
  82. package/build/ox_modules/module-mob/commands/getValue.js +18 -18
  83. package/build/ox_modules/module-mob/commands/getWindowHandles.js +17 -17
  84. package/build/ox_modules/module-mob/commands/hideKeyboard.js +21 -21
  85. package/build/ox_modules/module-mob/commands/index.js +1 -1
  86. package/build/ox_modules/module-mob/commands/installApp.js +16 -16
  87. package/build/ox_modules/module-mob/commands/isAppInstalled.js +16 -16
  88. package/build/ox_modules/module-mob/commands/isCheckable.js +18 -18
  89. package/build/ox_modules/module-mob/commands/isChecked.js +18 -18
  90. package/build/ox_modules/module-mob/commands/isClickable.js +18 -18
  91. package/build/ox_modules/module-mob/commands/isExist.js +19 -19
  92. package/build/ox_modules/module-mob/commands/isSelected.js +23 -23
  93. package/build/ox_modules/module-mob/commands/isVisible.js +19 -19
  94. package/build/ox_modules/module-mob/commands/isWebViewContext.js +16 -16
  95. package/build/ox_modules/module-mob/commands/launchApp.js +15 -15
  96. package/build/ox_modules/module-mob/commands/longPressKeyCode.js +18 -18
  97. package/build/ox_modules/module-mob/commands/open.js +17 -17
  98. package/build/ox_modules/module-mob/commands/pause.js +16 -16
  99. package/build/ox_modules/module-mob/commands/removeApp.js +16 -16
  100. package/build/ox_modules/module-mob/commands/resetApp.js +15 -15
  101. package/build/ox_modules/module-mob/commands/scrollIntoElement.js +22 -22
  102. package/build/ox_modules/module-mob/commands/scrollIntoView.js +27 -27
  103. package/build/ox_modules/module-mob/commands/select.js +24 -24
  104. package/build/ox_modules/module-mob/commands/selectFrame.js +23 -23
  105. package/build/ox_modules/module-mob/commands/selectWindow.js +28 -28
  106. package/build/ox_modules/module-mob/commands/sendKeys.js +29 -29
  107. package/build/ox_modules/module-mob/commands/setContext.js +16 -16
  108. package/build/ox_modules/module-mob/commands/setNativeContext.js +15 -15
  109. package/build/ox_modules/module-mob/commands/setTimeout.js +21 -21
  110. package/build/ox_modules/module-mob/commands/setWebViewContext.js +16 -16
  111. package/build/ox_modules/module-mob/commands/shake.js +16 -16
  112. package/build/ox_modules/module-mob/commands/smsClickLink.js +19 -19
  113. package/build/ox_modules/module-mob/commands/smsGetText.js +20 -20
  114. package/build/ox_modules/module-mob/commands/swipe.js +20 -20
  115. package/build/ox_modules/module-mob/commands/swipeElement.js +20 -20
  116. package/build/ox_modules/module-mob/commands/swipeScreen.js +20 -20
  117. package/build/ox_modules/module-mob/commands/takeScreenshot.js +17 -17
  118. package/build/ox_modules/module-mob/commands/tap.js +17 -17
  119. package/build/ox_modules/module-mob/commands/type.js +20 -20
  120. package/build/ox_modules/module-mob/commands/unlockPattern.js +22 -22
  121. package/build/ox_modules/module-mob/commands/waitForExist.js +18 -18
  122. package/build/ox_modules/module-mob/commands/waitForInteractable.js +17 -17
  123. package/build/ox_modules/module-mob/commands/waitForVisible.js +17 -17
  124. package/build/ox_modules/module-mob.js +74 -74
  125. package/build/ox_modules/module-mongo.js +82 -82
  126. package/build/ox_modules/module-pdf.js +35 -35
  127. package/build/ox_modules/module-proxy.js +77 -77
  128. package/build/ox_modules/module-serial.js +55 -55
  129. package/build/ox_modules/module-shell.js +52 -33
  130. package/build/ox_modules/module-soap.js +72 -72
  131. package/build/ox_modules/module-twilio.js +41 -41
  132. package/build/ox_modules/module-utils.js +91 -91
  133. package/build/ox_modules/module-web/commands/alertAccept.js +17 -17
  134. package/build/ox_modules/module-web/commands/alertDismiss.js +17 -17
  135. package/build/ox_modules/module-web/commands/assertAlert.js +20 -20
  136. package/build/ox_modules/module-web/commands/assertExist.js +17 -17
  137. package/build/ox_modules/module-web/commands/assertSelectedLabel.js +21 -21
  138. package/build/ox_modules/module-web/commands/assertSelectedValue.js +21 -21
  139. package/build/ox_modules/module-web/commands/assertText.js +21 -21
  140. package/build/ox_modules/module-web/commands/assertTextNotPresent.js +18 -18
  141. package/build/ox_modules/module-web/commands/assertTextPresent.js +18 -18
  142. package/build/ox_modules/module-web/commands/assertTitle.js +19 -19
  143. package/build/ox_modules/module-web/commands/assertValue.js +20 -20
  144. package/build/ox_modules/module-web/commands/back.js +16 -16
  145. package/build/ox_modules/module-web/commands/clear.js +18 -18
  146. package/build/ox_modules/module-web/commands/click.js +25 -25
  147. package/build/ox_modules/module-web/commands/clickHidden.js +23 -23
  148. package/build/ox_modules/module-web/commands/closeWindow.js +15 -15
  149. package/build/ox_modules/module-web/commands/debug.js +15 -15
  150. package/build/ox_modules/module-web/commands/deleteCookies.js +12 -12
  151. package/build/ox_modules/module-web/commands/deselect.js +22 -22
  152. package/build/ox_modules/module-web/commands/doubleClick.js +17 -17
  153. package/build/ox_modules/module-web/commands/dragAndDrop.js +20 -20
  154. package/build/ox_modules/module-web/commands/execute.js +24 -24
  155. package/build/ox_modules/module-web/commands/fileBrowse.js +18 -18
  156. package/build/ox_modules/module-web/commands/findElement.js +19 -19
  157. package/build/ox_modules/module-web/commands/findElements.js +22 -22
  158. package/build/ox_modules/module-web/commands/fullscreenWindow.js +14 -14
  159. package/build/ox_modules/module-web/commands/getAlertText.js +16 -16
  160. package/build/ox_modules/module-web/commands/getAttribute.js +19 -19
  161. package/build/ox_modules/module-web/commands/getBrowserLogs.js +17 -17
  162. package/build/ox_modules/module-web/commands/getCookies.js +13 -13
  163. package/build/ox_modules/module-web/commands/getCssValue.js +19 -19
  164. package/build/ox_modules/module-web/commands/getElementCount.js +17 -17
  165. package/build/ox_modules/module-web/commands/getHTML.js +17 -17
  166. package/build/ox_modules/module-web/commands/getSource.js +16 -16
  167. package/build/ox_modules/module-web/commands/getText.js +18 -18
  168. package/build/ox_modules/module-web/commands/getTitle.js +12 -12
  169. package/build/ox_modules/module-web/commands/getUrl.js +16 -16
  170. package/build/ox_modules/module-web/commands/getValue.js +18 -18
  171. package/build/ox_modules/module-web/commands/getWindowHandles.js +16 -16
  172. package/build/ox_modules/module-web/commands/getWindowSize.js +16 -16
  173. package/build/ox_modules/module-web/commands/getXMLPageSource.js +16 -16
  174. package/build/ox_modules/module-web/commands/index.js +1 -1
  175. package/build/ox_modules/module-web/commands/isAlertPresent.js +16 -16
  176. package/build/ox_modules/module-web/commands/isChecked.js +18 -18
  177. package/build/ox_modules/module-web/commands/isExist.js +19 -19
  178. package/build/ox_modules/module-web/commands/isInteractable.js +22 -22
  179. package/build/ox_modules/module-web/commands/isSelected.js +23 -23
  180. package/build/ox_modules/module-web/commands/isVisible.js +19 -19
  181. package/build/ox_modules/module-web/commands/makeVisible.js +25 -25
  182. package/build/ox_modules/module-web/commands/maximizeWindow.js +14 -14
  183. package/build/ox_modules/module-web/commands/minimizeWindow.js +14 -14
  184. package/build/ox_modules/module-web/commands/mock.js +20 -20
  185. package/build/ox_modules/module-web/commands/mockClearAll.js +12 -12
  186. package/build/ox_modules/module-web/commands/mockRestoreAll.js +12 -12
  187. package/build/ox_modules/module-web/commands/newWindow.js +16 -16
  188. package/build/ox_modules/module-web/commands/open.js +16 -16
  189. package/build/ox_modules/module-web/commands/pause.js +15 -15
  190. package/build/ox_modules/module-web/commands/point.js +21 -21
  191. package/build/ox_modules/module-web/commands/pointJS.js +15 -15
  192. package/build/ox_modules/module-web/commands/refresh.js +15 -15
  193. package/build/ox_modules/module-web/commands/rightClick.js +17 -17
  194. package/build/ox_modules/module-web/commands/rightClickActions.js +19 -19
  195. package/build/ox_modules/module-web/commands/scrollToElement.js +21 -21
  196. package/build/ox_modules/module-web/commands/select.js +23 -23
  197. package/build/ox_modules/module-web/commands/selectFrame.js +24 -24
  198. package/build/ox_modules/module-web/commands/selectWindow.js +27 -27
  199. package/build/ox_modules/module-web/commands/sendKeys.js +22 -22
  200. package/build/ox_modules/module-web/commands/setAutoWaitForAngular.js +20 -20
  201. package/build/ox_modules/module-web/commands/setTimeout.js +21 -21
  202. package/build/ox_modules/module-web/commands/setWindowSize.js +17 -17
  203. package/build/ox_modules/module-web/commands/takeScreenshot.js +17 -17
  204. package/build/ox_modules/module-web/commands/type.js +20 -20
  205. package/build/ox_modules/module-web/commands/verifyAlert.js +20 -20
  206. package/build/ox_modules/module-web/commands/verifyExist.js +17 -17
  207. package/build/ox_modules/module-web/commands/verifySelectedLabel.js +21 -21
  208. package/build/ox_modules/module-web/commands/verifySelectedValue.js +21 -21
  209. package/build/ox_modules/module-web/commands/verifyText.js +21 -21
  210. package/build/ox_modules/module-web/commands/verifyTextNotPresent.js +18 -18
  211. package/build/ox_modules/module-web/commands/verifyTextPresent.js +18 -18
  212. package/build/ox_modules/module-web/commands/verifyTitle.js +19 -19
  213. package/build/ox_modules/module-web/commands/verifyValue.js +20 -20
  214. package/build/ox_modules/module-web/commands/waitForAngular.js +19 -19
  215. package/build/ox_modules/module-web/commands/waitForExist.js +17 -17
  216. package/build/ox_modules/module-web/commands/waitForInteractable.js +17 -17
  217. package/build/ox_modules/module-web/commands/waitForNotExist.js +17 -17
  218. package/build/ox_modules/module-web/commands/waitForNotText.js +20 -20
  219. package/build/ox_modules/module-web/commands/waitForNotValue.js +20 -20
  220. package/build/ox_modules/module-web/commands/waitForText.js +20 -20
  221. package/build/ox_modules/module-web/commands/waitForValue.js +20 -20
  222. package/build/ox_modules/module-web/commands/waitForVisible.js +17 -17
  223. package/build/ox_modules/module-web/commands/waitForWindow.js +22 -22
  224. package/build/ox_modules/module-web.js +94 -94
  225. package/build/ox_modules/module-win/commands/assertText.js +17 -17
  226. package/build/ox_modules/module-win/commands/assertTitle.js +15 -15
  227. package/build/ox_modules/module-win/commands/assertValue.js +14 -14
  228. package/build/ox_modules/module-win/commands/back.js +11 -11
  229. package/build/ox_modules/module-win/commands/clear.js +13 -13
  230. package/build/ox_modules/module-win/commands/click.js +13 -13
  231. package/build/ox_modules/module-win/commands/clickLong.js +14 -14
  232. package/build/ox_modules/module-win/commands/clickMultipleTimes.js +14 -14
  233. package/build/ox_modules/module-win/commands/findElement.js +15 -15
  234. package/build/ox_modules/module-win/commands/findElements.js +15 -15
  235. package/build/ox_modules/module-win/commands/getAppiumLogs.js +12 -12
  236. package/build/ox_modules/module-win/commands/getCurrentWindowHandle.js +15 -15
  237. package/build/ox_modules/module-win/commands/getLocation.js +14 -14
  238. package/build/ox_modules/module-win/commands/getSource.js +12 -12
  239. package/build/ox_modules/module-win/commands/getText.js +14 -14
  240. package/build/ox_modules/module-win/commands/getValue.js +14 -14
  241. package/build/ox_modules/module-win/commands/getWindowHandles.js +15 -15
  242. package/build/ox_modules/module-win/commands/index.js +1 -1
  243. package/build/ox_modules/module-win/commands/isCheckable.js +14 -14
  244. package/build/ox_modules/module-win/commands/isChecked.js +14 -14
  245. package/build/ox_modules/module-win/commands/isClickable.js +14 -14
  246. package/build/ox_modules/module-win/commands/isExist.js +15 -15
  247. package/build/ox_modules/module-win/commands/isSelected.js +14 -14
  248. package/build/ox_modules/module-win/commands/isVisible.js +15 -15
  249. package/build/ox_modules/module-win/commands/open.js +13 -13
  250. package/build/ox_modules/module-win/commands/pause.js +12 -12
  251. package/build/ox_modules/module-win/commands/rightClick.js +13 -13
  252. package/build/ox_modules/module-win/commands/selectWindow.js +23 -23
  253. package/build/ox_modules/module-win/commands/sendKeys.js +22 -22
  254. package/build/ox_modules/module-win/commands/setTimeout.js +17 -17
  255. package/build/ox_modules/module-win/commands/takeScreenshot.js +16 -16
  256. package/build/ox_modules/module-win/commands/tap.js +13 -13
  257. package/build/ox_modules/module-win/commands/type.js +16 -16
  258. package/build/ox_modules/module-win/commands/waitForExist.js +14 -14
  259. package/build/ox_modules/module-win/commands/waitForInteractable.js +16 -16
  260. package/build/ox_modules/module-win/commands/waitForVisible.js +13 -13
  261. package/build/ox_modules/module-win.js +47 -47
  262. package/build/ox_modules/utils.js +8 -8
  263. package/build/ox_reporters/excel/template.json +48 -48
  264. package/build/ox_reporters/html/index.ejs +163 -163
  265. package/build/ox_reporters/html/summary.ejs +77 -77
  266. package/build/ox_reporters/html/tests-details.ejs +134 -134
  267. package/build/ox_reporters/html/tests-devices-browsers.ejs +83 -83
  268. package/build/ox_reporters/reporter-excel.js +1 -1
  269. package/build/ox_reporters/reporter-html.js +1 -1
  270. package/build/ox_reporters/reporter-json.js +1 -1
  271. package/build/ox_reporters/reporter-junit.js +1 -1
  272. package/build/ox_reporters/reporter-pdf.js +1 -1
  273. package/build/ox_reporters/reporter-rp.js +73 -42
  274. package/build/ox_reporters/reporter-xml.js +1 -1
  275. package/build/ox_services/service-devtools/submodule-network.js +1 -1
  276. package/build/ox_services/service-devtools.js +1 -1
  277. package/build/reporter/FileReporterBase.js +1 -1
  278. package/build/reporter/ReportAggregator.js +1 -1
  279. package/build/reporter/ReporterBase.js +1 -1
  280. package/build/reporter/WebSocketReporter.js +1 -1
  281. package/build/runners/WorkerProcess.js +1 -1
  282. package/build/runners/cucumber/CucumberEventListener.js +1 -1
  283. package/build/runners/cucumber/CucumberReporter.js +1 -1
  284. package/build/runners/cucumber/CucumberWorker.js +1 -1
  285. package/build/runners/cucumber/index.js +1 -1
  286. package/build/runners/cucumber/worker.js +1 -1
  287. package/build/runners/index.js +1 -1
  288. package/build/runners/oxygen/OxygenWorker.js +1 -1
  289. package/build/runners/oxygen/index.js +1 -1
  290. package/build/runners/oxygen/worker.js +1 -1
  291. package/config/default.json +6 -6
  292. package/package.json +139 -139
  293. package/types/index.d.ts +70 -70
  294. package/types/module-eyes.d.ts +39 -39
  295. package/types/module-http.d.ts +163 -163
  296. package/types/module-log.d.ts +34 -34
  297. package/types/module-mob.d.ts +966 -966
  298. package/types/module-pdf.d.ts +40 -40
  299. package/types/module-proxy.d.ts +100 -100
  300. package/types/module-shell.d.ts +24 -24
  301. package/types/module-utils.d.ts +99 -99
  302. package/types/module-web.d.ts +1053 -1053
  303. package/types/module-win.d.ts +352 -352
  304. package/types/oxygen.d.ts +53 -53
  305. package/log.txt +0 -1614
  306. package/reports/2025-06-08_231627/report.html +0 -440
  307. package/reports/2025-06-09_223615/report.html +0 -440
  308. package/transpiled/mongodb/etc/prepare.js +0 -18
  309. package/transpiled/mongodb/lib/admin.js +0 -182
  310. package/transpiled/mongodb/lib/beta.js +0 -26
  311. package/transpiled/mongodb/lib/bson.js +0 -220
  312. package/transpiled/mongodb/lib/bulk/common.js +0 -1041
  313. package/transpiled/mongodb/lib/bulk/ordered.js +0 -76
  314. package/transpiled/mongodb/lib/bulk/unordered.js +0 -102
  315. package/transpiled/mongodb/lib/change_stream.js +0 -517
  316. package/transpiled/mongodb/lib/client-side-encryption/auto_encrypter.js +0 -329
  317. package/transpiled/mongodb/lib/client-side-encryption/client_encryption.js +0 -779
  318. package/transpiled/mongodb/lib/client-side-encryption/crypto_callbacks.js +0 -95
  319. package/transpiled/mongodb/lib/client-side-encryption/errors.js +0 -171
  320. package/transpiled/mongodb/lib/client-side-encryption/mongocryptd_manager.js +0 -98
  321. package/transpiled/mongodb/lib/client-side-encryption/providers/aws.js +0 -34
  322. package/transpiled/mongodb/lib/client-side-encryption/providers/azure.js +0 -186
  323. package/transpiled/mongodb/lib/client-side-encryption/providers/gcp.js +0 -29
  324. package/transpiled/mongodb/lib/client-side-encryption/providers/index.js +0 -58
  325. package/transpiled/mongodb/lib/client-side-encryption/state_machine.js +0 -505
  326. package/transpiled/mongodb/lib/cmap/auth/auth_provider.js +0 -63
  327. package/transpiled/mongodb/lib/cmap/auth/aws_temporary_credentials.js +0 -167
  328. package/transpiled/mongodb/lib/cmap/auth/gssapi.js +0 -207
  329. package/transpiled/mongodb/lib/cmap/auth/mongo_credentials.js +0 -193
  330. package/transpiled/mongodb/lib/cmap/auth/mongodb_aws.js +0 -181
  331. package/transpiled/mongodb/lib/cmap/auth/mongodb_oidc/automated_callback_workflow.js +0 -101
  332. package/transpiled/mongodb/lib/cmap/auth/mongodb_oidc/azure_machine_workflow.js +0 -81
  333. package/transpiled/mongodb/lib/cmap/auth/mongodb_oidc/callback_workflow.js +0 -174
  334. package/transpiled/mongodb/lib/cmap/auth/mongodb_oidc/command_builders.js +0 -59
  335. package/transpiled/mongodb/lib/cmap/auth/mongodb_oidc/gcp_machine_workflow.js +0 -58
  336. package/transpiled/mongodb/lib/cmap/auth/mongodb_oidc/human_callback_workflow.js +0 -138
  337. package/transpiled/mongodb/lib/cmap/auth/mongodb_oidc/k8s_machine_workflow.js +0 -42
  338. package/transpiled/mongodb/lib/cmap/auth/mongodb_oidc/token_cache.js +0 -71
  339. package/transpiled/mongodb/lib/cmap/auth/mongodb_oidc/token_machine_workflow.js +0 -34
  340. package/transpiled/mongodb/lib/cmap/auth/mongodb_oidc.js +0 -111
  341. package/transpiled/mongodb/lib/cmap/auth/plain.js +0 -43
  342. package/transpiled/mongodb/lib/cmap/auth/providers.js +0 -22
  343. package/transpiled/mongodb/lib/cmap/auth/scram.js +0 -318
  344. package/transpiled/mongodb/lib/cmap/auth/x509.js +0 -61
  345. package/transpiled/mongodb/lib/cmap/command_monitoring_events.js +0 -266
  346. package/transpiled/mongodb/lib/cmap/commands.js +0 -605
  347. package/transpiled/mongodb/lib/cmap/connect.js +0 -418
  348. package/transpiled/mongodb/lib/cmap/connection.js +0 -673
  349. package/transpiled/mongodb/lib/cmap/connection_pool.js +0 -688
  350. package/transpiled/mongodb/lib/cmap/connection_pool_events.js +0 -254
  351. package/transpiled/mongodb/lib/cmap/errors.js +0 -128
  352. package/transpiled/mongodb/lib/cmap/handshake/client_metadata.js +0 -278
  353. package/transpiled/mongodb/lib/cmap/metrics.js +0 -67
  354. package/transpiled/mongodb/lib/cmap/stream_description.js +0 -74
  355. package/transpiled/mongodb/lib/cmap/wire_protocol/compression.js +0 -196
  356. package/transpiled/mongodb/lib/cmap/wire_protocol/constants.js +0 -19
  357. package/transpiled/mongodb/lib/cmap/wire_protocol/on_data.js +0 -144
  358. package/transpiled/mongodb/lib/cmap/wire_protocol/on_demand/document.js +0 -278
  359. package/transpiled/mongodb/lib/cmap/wire_protocol/responses.js +0 -376
  360. package/transpiled/mongodb/lib/cmap/wire_protocol/shared.js +0 -49
  361. package/transpiled/mongodb/lib/collection.js +0 -852
  362. package/transpiled/mongodb/lib/connection_string.js +0 -1452
  363. package/transpiled/mongodb/lib/constants.js +0 -162
  364. package/transpiled/mongodb/lib/cursor/abstract_cursor.js +0 -1082
  365. package/transpiled/mongodb/lib/cursor/aggregation_cursor.js +0 -227
  366. package/transpiled/mongodb/lib/cursor/change_stream_cursor.js +0 -136
  367. package/transpiled/mongodb/lib/cursor/client_bulk_write_cursor.js +0 -69
  368. package/transpiled/mongodb/lib/cursor/find_cursor.js +0 -476
  369. package/transpiled/mongodb/lib/cursor/list_collections_cursor.js +0 -48
  370. package/transpiled/mongodb/lib/cursor/list_indexes_cursor.js +0 -46
  371. package/transpiled/mongodb/lib/cursor/list_search_indexes_cursor.js +0 -30
  372. package/transpiled/mongodb/lib/cursor/run_command_cursor.js +0 -125
  373. package/transpiled/mongodb/lib/db.js +0 -467
  374. package/transpiled/mongodb/lib/deps.js +0 -174
  375. package/transpiled/mongodb/lib/encrypter.js +0 -129
  376. package/transpiled/mongodb/lib/error.js +0 -1550
  377. package/transpiled/mongodb/lib/explain.js +0 -122
  378. package/transpiled/mongodb/lib/gridfs/download.js +0 -369
  379. package/transpiled/mongodb/lib/gridfs/index.js +0 -240
  380. package/transpiled/mongodb/lib/gridfs/upload.js +0 -446
  381. package/transpiled/mongodb/lib/index.js +0 -975
  382. package/transpiled/mongodb/lib/mongo_client.js +0 -626
  383. package/transpiled/mongodb/lib/mongo_client_auth_providers.js +0 -98
  384. package/transpiled/mongodb/lib/mongo_logger.js +0 -812
  385. package/transpiled/mongodb/lib/mongo_types.js +0 -71
  386. package/transpiled/mongodb/lib/operations/aggregate.js +0 -129
  387. package/transpiled/mongodb/lib/operations/bulk_write.js +0 -48
  388. package/transpiled/mongodb/lib/operations/client_bulk_write/client_bulk_write.js +0 -96
  389. package/transpiled/mongodb/lib/operations/client_bulk_write/command_builder.js +0 -409
  390. package/transpiled/mongodb/lib/operations/client_bulk_write/common.js +0 -5
  391. package/transpiled/mongodb/lib/operations/client_bulk_write/executor.js +0 -144
  392. package/transpiled/mongodb/lib/operations/client_bulk_write/results_merger.js +0 -228
  393. package/transpiled/mongodb/lib/operations/collections.js +0 -49
  394. package/transpiled/mongodb/lib/operations/command.js +0 -102
  395. package/transpiled/mongodb/lib/operations/count.js +0 -60
  396. package/transpiled/mongodb/lib/operations/create_collection.js +0 -109
  397. package/transpiled/mongodb/lib/operations/delete.js +0 -134
  398. package/transpiled/mongodb/lib/operations/distinct.js +0 -77
  399. package/transpiled/mongodb/lib/operations/drop.js +0 -102
  400. package/transpiled/mongodb/lib/operations/estimated_document_count.js +0 -47
  401. package/transpiled/mongodb/lib/operations/execute_operation.js +0 -251
  402. package/transpiled/mongodb/lib/operations/find.js +0 -197
  403. package/transpiled/mongodb/lib/operations/find_and_modify.js +0 -191
  404. package/transpiled/mongodb/lib/operations/get_more.js +0 -84
  405. package/transpiled/mongodb/lib/operations/indexes.js +0 -197
  406. package/transpiled/mongodb/lib/operations/insert.js +0 -138
  407. package/transpiled/mongodb/lib/operations/is_capped.js +0 -44
  408. package/transpiled/mongodb/lib/operations/kill_cursors.js +0 -58
  409. package/transpiled/mongodb/lib/operations/list_collections.js +0 -66
  410. package/transpiled/mongodb/lib/operations/list_databases.js +0 -56
  411. package/transpiled/mongodb/lib/operations/operation.js +0 -88
  412. package/transpiled/mongodb/lib/operations/options_operation.js +0 -44
  413. package/transpiled/mongodb/lib/operations/profiling_level.js +0 -42
  414. package/transpiled/mongodb/lib/operations/remove_user.js +0 -35
  415. package/transpiled/mongodb/lib/operations/rename.js +0 -48
  416. package/transpiled/mongodb/lib/operations/run_command.js +0 -64
  417. package/transpiled/mongodb/lib/operations/search_indexes/create.js +0 -41
  418. package/transpiled/mongodb/lib/operations/search_indexes/drop.js +0 -51
  419. package/transpiled/mongodb/lib/operations/search_indexes/update.js +0 -40
  420. package/transpiled/mongodb/lib/operations/set_profiling_level.js +0 -70
  421. package/transpiled/mongodb/lib/operations/stats.js +0 -39
  422. package/transpiled/mongodb/lib/operations/update.js +0 -218
  423. package/transpiled/mongodb/lib/operations/validate_collection.js +0 -49
  424. package/transpiled/mongodb/lib/read_concern.js +0 -92
  425. package/transpiled/mongodb/lib/read_preference.js +0 -215
  426. package/transpiled/mongodb/lib/resource_management.js +0 -74
  427. package/transpiled/mongodb/lib/sdam/common.js +0 -53
  428. package/transpiled/mongodb/lib/sdam/events.js +0 -177
  429. package/transpiled/mongodb/lib/sdam/monitor.js +0 -656
  430. package/transpiled/mongodb/lib/sdam/server.js +0 -463
  431. package/transpiled/mongodb/lib/sdam/server_description.js +0 -196
  432. package/transpiled/mongodb/lib/sdam/server_selection.js +0 -283
  433. package/transpiled/mongodb/lib/sdam/server_selection_events.js +0 -112
  434. package/transpiled/mongodb/lib/sdam/srv_polling.js +0 -139
  435. package/transpiled/mongodb/lib/sdam/topology.js +0 -833
  436. package/transpiled/mongodb/lib/sdam/topology_description.js +0 -447
  437. package/transpiled/mongodb/lib/sessions.js +0 -988
  438. package/transpiled/mongodb/lib/sort.js +0 -123
  439. package/transpiled/mongodb/lib/timeout.js +0 -349
  440. package/transpiled/mongodb/lib/transactions.js +0 -149
  441. package/transpiled/mongodb/lib/utils.js +0 -1502
  442. package/transpiled/mongodb/lib/write_concern.js +0 -115
@@ -1,605 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.OpCompressedRequest = exports.OpMsgResponse = exports.OpMsgRequest = exports.DocumentSequence = exports.OpReply = exports.OpQueryRequest = void 0;
7
-
8
- const BSON = require("../bson");
9
-
10
- const error_1 = require("../error");
11
-
12
- const compression_1 = require("./wire_protocol/compression");
13
-
14
- const constants_1 = require("./wire_protocol/constants"); // Incrementing request id
15
-
16
-
17
- let _requestId = 0; // Query flags
18
-
19
- const OPTS_TAILABLE_CURSOR = 2;
20
- const OPTS_SECONDARY = 4;
21
- const OPTS_OPLOG_REPLAY = 8;
22
- const OPTS_NO_CURSOR_TIMEOUT = 16;
23
- const OPTS_AWAIT_DATA = 32;
24
- const OPTS_EXHAUST = 64;
25
- const OPTS_PARTIAL = 128; // Response flags
26
-
27
- const CURSOR_NOT_FOUND = 1;
28
- const QUERY_FAILURE = 2;
29
- const SHARD_CONFIG_STALE = 4;
30
- const AWAIT_CAPABLE = 8;
31
- const encodeUTF8Into = BSON.BSON.onDemand.ByteUtils.encodeUTF8Into;
32
- /** @internal */
33
-
34
- class OpQueryRequest {
35
- constructor(databaseName, query, options) {
36
- this.databaseName = databaseName;
37
- this.query = query;
38
- /** moreToCome is an OP_MSG only concept */
39
-
40
- this.moreToCome = false; // Basic options needed to be passed in
41
- // TODO(NODE-3483): Replace with MongoCommandError
42
-
43
- const ns = `${databaseName}.$cmd`;
44
-
45
- if (typeof databaseName !== 'string') {
46
- throw new error_1.MongoRuntimeError('Database name must be a string for a query');
47
- } // TODO(NODE-3483): Replace with MongoCommandError
48
-
49
-
50
- if (query == null) throw new error_1.MongoRuntimeError('A query document must be specified for query'); // Validate that we are not passing 0x00 in the collection name
51
-
52
- if (ns.indexOf('\x00') !== -1) {
53
- // TODO(NODE-3483): Use MongoNamespace static method
54
- throw new error_1.MongoRuntimeError('Namespace cannot contain a null character');
55
- } // Basic options
56
-
57
-
58
- this.ns = ns; // Additional options
59
-
60
- this.numberToSkip = options.numberToSkip || 0;
61
- this.numberToReturn = options.numberToReturn || 0;
62
- this.returnFieldSelector = options.returnFieldSelector || undefined;
63
- this.requestId = options.requestId ?? OpQueryRequest.getRequestId(); // special case for pre-3.2 find commands, delete ASAP
64
-
65
- this.pre32Limit = options.pre32Limit; // Serialization option
66
-
67
- this.serializeFunctions = typeof options.serializeFunctions === 'boolean' ? options.serializeFunctions : false;
68
- this.ignoreUndefined = typeof options.ignoreUndefined === 'boolean' ? options.ignoreUndefined : false;
69
- this.maxBsonSize = options.maxBsonSize || 1024 * 1024 * 16;
70
- this.checkKeys = typeof options.checkKeys === 'boolean' ? options.checkKeys : false;
71
- this.batchSize = this.numberToReturn; // Flags
72
-
73
- this.tailable = false;
74
- this.secondaryOk = typeof options.secondaryOk === 'boolean' ? options.secondaryOk : false;
75
- this.oplogReplay = false;
76
- this.noCursorTimeout = false;
77
- this.awaitData = false;
78
- this.exhaust = false;
79
- this.partial = false;
80
- }
81
- /** Assign next request Id. */
82
-
83
-
84
- incRequestId() {
85
- this.requestId = _requestId++;
86
- }
87
- /** Peek next request Id. */
88
-
89
-
90
- nextRequestId() {
91
- return _requestId + 1;
92
- }
93
- /** Increment then return next request Id. */
94
-
95
-
96
- static getRequestId() {
97
- return ++_requestId;
98
- } // Uses a single allocated buffer for the process, avoiding multiple memory allocations
99
-
100
-
101
- toBin() {
102
- const buffers = [];
103
- let projection = null; // Set up the flags
104
-
105
- let flags = 0;
106
-
107
- if (this.tailable) {
108
- flags |= OPTS_TAILABLE_CURSOR;
109
- }
110
-
111
- if (this.secondaryOk) {
112
- flags |= OPTS_SECONDARY;
113
- }
114
-
115
- if (this.oplogReplay) {
116
- flags |= OPTS_OPLOG_REPLAY;
117
- }
118
-
119
- if (this.noCursorTimeout) {
120
- flags |= OPTS_NO_CURSOR_TIMEOUT;
121
- }
122
-
123
- if (this.awaitData) {
124
- flags |= OPTS_AWAIT_DATA;
125
- }
126
-
127
- if (this.exhaust) {
128
- flags |= OPTS_EXHAUST;
129
- }
130
-
131
- if (this.partial) {
132
- flags |= OPTS_PARTIAL;
133
- } // If batchSize is different to this.numberToReturn
134
-
135
-
136
- if (this.batchSize !== this.numberToReturn) this.numberToReturn = this.batchSize; // Allocate write protocol header buffer
137
-
138
- const header = Buffer.alloc(4 * 4 + // Header
139
- 4 + // Flags
140
- Buffer.byteLength(this.ns) + 1 + // namespace
141
- 4 + // numberToSkip
142
- 4 // numberToReturn
143
- ); // Add header to buffers
144
-
145
- buffers.push(header); // Serialize the query
146
-
147
- const query = BSON.serialize(this.query, {
148
- checkKeys: this.checkKeys,
149
- serializeFunctions: this.serializeFunctions,
150
- ignoreUndefined: this.ignoreUndefined
151
- }); // Add query document
152
-
153
- buffers.push(query);
154
-
155
- if (this.returnFieldSelector && Object.keys(this.returnFieldSelector).length > 0) {
156
- // Serialize the projection document
157
- projection = BSON.serialize(this.returnFieldSelector, {
158
- checkKeys: this.checkKeys,
159
- serializeFunctions: this.serializeFunctions,
160
- ignoreUndefined: this.ignoreUndefined
161
- }); // Add projection document
162
-
163
- buffers.push(projection);
164
- } // Total message size
165
-
166
-
167
- const totalLength = header.length + query.length + (projection ? projection.length : 0); // Set up the index
168
-
169
- let index = 4; // Write total document length
170
-
171
- header[3] = totalLength >> 24 & 0xff;
172
- header[2] = totalLength >> 16 & 0xff;
173
- header[1] = totalLength >> 8 & 0xff;
174
- header[0] = totalLength & 0xff; // Write header information requestId
175
-
176
- header[index + 3] = this.requestId >> 24 & 0xff;
177
- header[index + 2] = this.requestId >> 16 & 0xff;
178
- header[index + 1] = this.requestId >> 8 & 0xff;
179
- header[index] = this.requestId & 0xff;
180
- index = index + 4; // Write header information responseTo
181
-
182
- header[index + 3] = 0 >> 24 & 0xff;
183
- header[index + 2] = 0 >> 16 & 0xff;
184
- header[index + 1] = 0 >> 8 & 0xff;
185
- header[index] = 0 & 0xff;
186
- index = index + 4; // Write header information OP_QUERY
187
-
188
- header[index + 3] = constants_1.OP_QUERY >> 24 & 0xff;
189
- header[index + 2] = constants_1.OP_QUERY >> 16 & 0xff;
190
- header[index + 1] = constants_1.OP_QUERY >> 8 & 0xff;
191
- header[index] = constants_1.OP_QUERY & 0xff;
192
- index = index + 4; // Write header information flags
193
-
194
- header[index + 3] = flags >> 24 & 0xff;
195
- header[index + 2] = flags >> 16 & 0xff;
196
- header[index + 1] = flags >> 8 & 0xff;
197
- header[index] = flags & 0xff;
198
- index = index + 4; // Write collection name
199
-
200
- index = index + header.write(this.ns, index, 'utf8') + 1;
201
- header[index - 1] = 0; // Write header information flags numberToSkip
202
-
203
- header[index + 3] = this.numberToSkip >> 24 & 0xff;
204
- header[index + 2] = this.numberToSkip >> 16 & 0xff;
205
- header[index + 1] = this.numberToSkip >> 8 & 0xff;
206
- header[index] = this.numberToSkip & 0xff;
207
- index = index + 4; // Write header information flags numberToReturn
208
-
209
- header[index + 3] = this.numberToReturn >> 24 & 0xff;
210
- header[index + 2] = this.numberToReturn >> 16 & 0xff;
211
- header[index + 1] = this.numberToReturn >> 8 & 0xff;
212
- header[index] = this.numberToReturn & 0xff;
213
- index = index + 4; // Return the buffers
214
-
215
- return buffers;
216
- }
217
-
218
- }
219
-
220
- exports.OpQueryRequest = OpQueryRequest;
221
- /** @internal */
222
-
223
- class OpReply {
224
- constructor(message, msgHeader, msgBody, opts) {
225
- this.index = 0;
226
- this.sections = [];
227
- /** moreToCome is an OP_MSG only concept */
228
-
229
- this.moreToCome = false;
230
- this.parsed = false;
231
- this.raw = message;
232
- this.data = msgBody;
233
- this.opts = opts ?? {
234
- useBigInt64: false,
235
- promoteLongs: true,
236
- promoteValues: true,
237
- promoteBuffers: false,
238
- bsonRegExp: false
239
- }; // Read the message header
240
-
241
- this.length = msgHeader.length;
242
- this.requestId = msgHeader.requestId;
243
- this.responseTo = msgHeader.responseTo;
244
- this.opCode = msgHeader.opCode;
245
- this.fromCompressed = msgHeader.fromCompressed; // Flag values
246
-
247
- this.useBigInt64 = typeof this.opts.useBigInt64 === 'boolean' ? this.opts.useBigInt64 : false;
248
- this.promoteLongs = typeof this.opts.promoteLongs === 'boolean' ? this.opts.promoteLongs : true;
249
- this.promoteValues = typeof this.opts.promoteValues === 'boolean' ? this.opts.promoteValues : true;
250
- this.promoteBuffers = typeof this.opts.promoteBuffers === 'boolean' ? this.opts.promoteBuffers : false;
251
- this.bsonRegExp = typeof this.opts.bsonRegExp === 'boolean' ? this.opts.bsonRegExp : false;
252
- }
253
-
254
- isParsed() {
255
- return this.parsed;
256
- }
257
-
258
- parse() {
259
- // Don't parse again if not needed
260
- if (this.parsed) return this.sections[0]; // Position within OP_REPLY at which documents start
261
- // (See https://www.mongodb.com/docs/manual/reference/mongodb-wire-protocol/#wire-op-reply)
262
-
263
- this.index = 20; // Read the message body
264
-
265
- this.responseFlags = this.data.readInt32LE(0);
266
- this.cursorId = new BSON.Long(this.data.readInt32LE(4), this.data.readInt32LE(8));
267
- this.startingFrom = this.data.readInt32LE(12);
268
- this.numberReturned = this.data.readInt32LE(16);
269
-
270
- if (this.numberReturned < 0 || this.numberReturned > 2 ** 32 - 1) {
271
- throw new RangeError(`OP_REPLY numberReturned is an invalid array length ${this.numberReturned}`);
272
- }
273
-
274
- this.cursorNotFound = (this.responseFlags & CURSOR_NOT_FOUND) !== 0;
275
- this.queryFailure = (this.responseFlags & QUERY_FAILURE) !== 0;
276
- this.shardConfigStale = (this.responseFlags & SHARD_CONFIG_STALE) !== 0;
277
- this.awaitCapable = (this.responseFlags & AWAIT_CAPABLE) !== 0; // Parse Body
278
-
279
- for (let i = 0; i < this.numberReturned; i++) {
280
- const bsonSize = this.data[this.index] | this.data[this.index + 1] << 8 | this.data[this.index + 2] << 16 | this.data[this.index + 3] << 24;
281
- const section = this.data.subarray(this.index, this.index + bsonSize);
282
- this.sections.push(section); // Adjust the index
283
-
284
- this.index = this.index + bsonSize;
285
- } // Set parsed
286
-
287
-
288
- this.parsed = true;
289
- return this.sections[0];
290
- }
291
-
292
- }
293
-
294
- exports.OpReply = OpReply; // Msg Flags
295
-
296
- const OPTS_CHECKSUM_PRESENT = 1;
297
- const OPTS_MORE_TO_COME = 2;
298
- const OPTS_EXHAUST_ALLOWED = 1 << 16;
299
- /** @internal */
300
-
301
- class DocumentSequence {
302
- /**
303
- * Create a new document sequence for the provided field.
304
- * @param field - The field it will replace.
305
- */
306
- constructor(field, documents) {
307
- this.field = field;
308
- this.documents = [];
309
- this.chunks = [];
310
- this.serializedDocumentsLength = 0; // Document sequences starts with type 1 at the first byte.
311
- // Field strings must always be UTF-8.
312
-
313
- const buffer = Buffer.allocUnsafe(1 + 4 + this.field.length + 1);
314
- buffer[0] = 1; // Third part is the field name at offset 5 with trailing null byte.
315
-
316
- encodeUTF8Into(buffer, `${this.field}\0`, 5);
317
- this.chunks.push(buffer);
318
- this.header = buffer;
319
-
320
- if (documents) {
321
- for (const doc of documents) {
322
- this.push(doc, BSON.serialize(doc));
323
- }
324
- }
325
- }
326
- /**
327
- * Push a document to the document sequence. Will serialize the document
328
- * as well and return the current serialized length of all documents.
329
- * @param document - The document to add.
330
- * @param buffer - The serialized document in raw BSON.
331
- * @returns The new total document sequence length.
332
- */
333
-
334
-
335
- push(document, buffer) {
336
- this.serializedDocumentsLength += buffer.length; // Push the document.
337
-
338
- this.documents.push(document); // Push the document raw bson.
339
-
340
- this.chunks.push(buffer); // Write the new length.
341
-
342
- this.header?.writeInt32LE(4 + this.field.length + 1 + this.serializedDocumentsLength, 1);
343
- return this.serializedDocumentsLength + this.header.length;
344
- }
345
- /**
346
- * Get the fully serialized bytes for the document sequence section.
347
- * @returns The section bytes.
348
- */
349
-
350
-
351
- toBin() {
352
- return Buffer.concat(this.chunks);
353
- }
354
-
355
- }
356
-
357
- exports.DocumentSequence = DocumentSequence;
358
- /** @internal */
359
-
360
- class OpMsgRequest {
361
- constructor(databaseName, command, options) {
362
- this.databaseName = databaseName;
363
- this.command = command;
364
- this.options = options; // Basic options needed to be passed in
365
-
366
- if (command == null) throw new error_1.MongoInvalidArgumentError('Query document must be specified for query'); // Basic options
367
-
368
- this.command.$db = databaseName; // Ensure empty options
369
-
370
- this.options = options ?? {}; // Additional options
371
-
372
- this.requestId = options.requestId ? options.requestId : OpMsgRequest.getRequestId(); // Serialization option
373
-
374
- this.serializeFunctions = typeof options.serializeFunctions === 'boolean' ? options.serializeFunctions : false;
375
- this.ignoreUndefined = typeof options.ignoreUndefined === 'boolean' ? options.ignoreUndefined : false;
376
- this.checkKeys = typeof options.checkKeys === 'boolean' ? options.checkKeys : false;
377
- this.maxBsonSize = options.maxBsonSize || 1024 * 1024 * 16; // flags
378
-
379
- this.checksumPresent = false;
380
- this.moreToCome = options.moreToCome ?? command.writeConcern?.w === 0;
381
- this.exhaustAllowed = typeof options.exhaustAllowed === 'boolean' ? options.exhaustAllowed : false;
382
- }
383
-
384
- toBin() {
385
- const buffers = [];
386
- let flags = 0;
387
-
388
- if (this.checksumPresent) {
389
- flags |= OPTS_CHECKSUM_PRESENT;
390
- }
391
-
392
- if (this.moreToCome) {
393
- flags |= OPTS_MORE_TO_COME;
394
- }
395
-
396
- if (this.exhaustAllowed) {
397
- flags |= OPTS_EXHAUST_ALLOWED;
398
- }
399
-
400
- const header = Buffer.alloc(4 * 4 + // Header
401
- 4 // Flags
402
- );
403
- buffers.push(header);
404
- let totalLength = header.length;
405
- const command = this.command;
406
- totalLength += this.makeSections(buffers, command);
407
- header.writeInt32LE(totalLength, 0); // messageLength
408
-
409
- header.writeInt32LE(this.requestId, 4); // requestID
410
-
411
- header.writeInt32LE(0, 8); // responseTo
412
-
413
- header.writeInt32LE(constants_1.OP_MSG, 12); // opCode
414
-
415
- header.writeUInt32LE(flags, 16); // flags
416
-
417
- return buffers;
418
- }
419
- /**
420
- * Add the sections to the OP_MSG request's buffers and returns the length.
421
- */
422
-
423
-
424
- makeSections(buffers, document) {
425
- const sequencesBuffer = this.extractDocumentSequences(document);
426
- const payloadTypeBuffer = Buffer.allocUnsafe(1);
427
- payloadTypeBuffer[0] = 0;
428
- const documentBuffer = this.serializeBson(document); // First section, type 0
429
-
430
- buffers.push(payloadTypeBuffer);
431
- buffers.push(documentBuffer); // Subsequent sections, type 1
432
-
433
- buffers.push(sequencesBuffer);
434
- return payloadTypeBuffer.length + documentBuffer.length + sequencesBuffer.length;
435
- }
436
- /**
437
- * Extracts the document sequences from the command document and returns
438
- * a buffer to be added as multiple sections after the initial type 0
439
- * section in the message.
440
- */
441
-
442
-
443
- extractDocumentSequences(document) {
444
- // Pull out any field in the command document that's value is a document sequence.
445
- const chunks = [];
446
-
447
- for (const [key, value] of Object.entries(document)) {
448
- if (value instanceof DocumentSequence) {
449
- chunks.push(value.toBin()); // Why are we removing the field from the command? This is because it needs to be
450
- // removed in the OP_MSG request first section, and DocumentSequence is not a
451
- // BSON type and is specific to the MongoDB wire protocol so there's nothing
452
- // our BSON serializer can do about this. Since DocumentSequence is not exposed
453
- // in the public API and only used internally, we are never mutating an original
454
- // command provided by the user, just our own, and it's cheaper to delete from
455
- // our own command than copying it.
456
-
457
- delete document[key];
458
- }
459
- }
460
-
461
- if (chunks.length > 0) {
462
- return Buffer.concat(chunks);
463
- } // If we have no document sequences we return an empty buffer for nothing to add
464
- // to the payload.
465
-
466
-
467
- return Buffer.alloc(0);
468
- }
469
-
470
- serializeBson(document) {
471
- return BSON.serialize(document, {
472
- checkKeys: this.checkKeys,
473
- serializeFunctions: this.serializeFunctions,
474
- ignoreUndefined: this.ignoreUndefined
475
- });
476
- }
477
-
478
- static getRequestId() {
479
- _requestId = _requestId + 1 & 0x7fffffff;
480
- return _requestId;
481
- }
482
-
483
- }
484
-
485
- exports.OpMsgRequest = OpMsgRequest;
486
- /** @internal */
487
-
488
- class OpMsgResponse {
489
- constructor(message, msgHeader, msgBody, opts) {
490
- this.index = 0;
491
- this.sections = [];
492
- this.parsed = false;
493
- this.raw = message;
494
- this.data = msgBody;
495
- this.opts = opts ?? {
496
- useBigInt64: false,
497
- promoteLongs: true,
498
- promoteValues: true,
499
- promoteBuffers: false,
500
- bsonRegExp: false
501
- }; // Read the message header
502
-
503
- this.length = msgHeader.length;
504
- this.requestId = msgHeader.requestId;
505
- this.responseTo = msgHeader.responseTo;
506
- this.opCode = msgHeader.opCode;
507
- this.fromCompressed = msgHeader.fromCompressed; // Read response flags
508
-
509
- this.responseFlags = msgBody.readInt32LE(0);
510
- this.checksumPresent = (this.responseFlags & OPTS_CHECKSUM_PRESENT) !== 0;
511
- this.moreToCome = (this.responseFlags & OPTS_MORE_TO_COME) !== 0;
512
- this.exhaustAllowed = (this.responseFlags & OPTS_EXHAUST_ALLOWED) !== 0;
513
- this.useBigInt64 = typeof this.opts.useBigInt64 === 'boolean' ? this.opts.useBigInt64 : false;
514
- this.promoteLongs = typeof this.opts.promoteLongs === 'boolean' ? this.opts.promoteLongs : true;
515
- this.promoteValues = typeof this.opts.promoteValues === 'boolean' ? this.opts.promoteValues : true;
516
- this.promoteBuffers = typeof this.opts.promoteBuffers === 'boolean' ? this.opts.promoteBuffers : false;
517
- this.bsonRegExp = typeof this.opts.bsonRegExp === 'boolean' ? this.opts.bsonRegExp : false;
518
- }
519
-
520
- isParsed() {
521
- return this.parsed;
522
- }
523
-
524
- parse() {
525
- // Don't parse again if not needed
526
- if (this.parsed) return this.sections[0];
527
- this.index = 4;
528
-
529
- while (this.index < this.data.length) {
530
- const payloadType = this.data.readUInt8(this.index++);
531
-
532
- if (payloadType === 0) {
533
- const bsonSize = this.data.readUInt32LE(this.index);
534
- const bin = this.data.subarray(this.index, this.index + bsonSize);
535
- this.sections.push(bin);
536
- this.index += bsonSize;
537
- } else if (payloadType === 1) {
538
- // It was decided that no driver makes use of payload type 1
539
- // TODO(NODE-3483): Replace with MongoDeprecationError
540
- throw new error_1.MongoRuntimeError('OP_MSG Payload Type 1 detected unsupported protocol');
541
- }
542
- }
543
-
544
- this.parsed = true;
545
- return this.sections[0];
546
- }
547
-
548
- }
549
-
550
- exports.OpMsgResponse = OpMsgResponse;
551
- const MESSAGE_HEADER_SIZE = 16;
552
- const COMPRESSION_DETAILS_SIZE = 9; // originalOpcode + uncompressedSize, compressorID
553
-
554
- /**
555
- * @internal
556
- *
557
- * An OP_COMPRESSED request wraps either an OP_QUERY or OP_MSG message.
558
- */
559
-
560
- class OpCompressedRequest {
561
- constructor(command, options) {
562
- this.command = command;
563
- this.options = options;
564
- } // Return whether a command contains an uncompressible command term
565
- // Will return true if command contains no uncompressible command terms
566
-
567
-
568
- static canCompress(command) {
569
- const commandDoc = command instanceof OpMsgRequest ? command.command : command.query;
570
- const commandName = Object.keys(commandDoc)[0];
571
- return !compression_1.uncompressibleCommands.has(commandName);
572
- }
573
-
574
- async toBin() {
575
- const concatenatedOriginalCommandBuffer = Buffer.concat(this.command.toBin()); // otherwise, compress the message
576
-
577
- const messageToBeCompressed = concatenatedOriginalCommandBuffer.slice(MESSAGE_HEADER_SIZE); // Extract information needed for OP_COMPRESSED from the uncompressed message
578
-
579
- const originalCommandOpCode = concatenatedOriginalCommandBuffer.readInt32LE(12); // Compress the message body
580
-
581
- const compressedMessage = await (0, compression_1.compress)(this.options, messageToBeCompressed); // Create the msgHeader of OP_COMPRESSED
582
-
583
- const msgHeader = Buffer.alloc(MESSAGE_HEADER_SIZE);
584
- msgHeader.writeInt32LE(MESSAGE_HEADER_SIZE + COMPRESSION_DETAILS_SIZE + compressedMessage.length, 0); // messageLength
585
-
586
- msgHeader.writeInt32LE(this.command.requestId, 4); // requestID
587
-
588
- msgHeader.writeInt32LE(0, 8); // responseTo (zero)
589
-
590
- msgHeader.writeInt32LE(constants_1.OP_COMPRESSED, 12); // opCode
591
- // Create the compression details of OP_COMPRESSED
592
-
593
- const compressionDetails = Buffer.alloc(COMPRESSION_DETAILS_SIZE);
594
- compressionDetails.writeInt32LE(originalCommandOpCode, 0); // originalOpcode
595
-
596
- compressionDetails.writeInt32LE(messageToBeCompressed.length, 4); // Size of the uncompressed compressedMessage, excluding the MsgHeader
597
-
598
- compressionDetails.writeUInt8(compression_1.Compressor[this.options.agreedCompressor], 8); // compressorID
599
-
600
- return [msgHeader, compressionDetails, compressedMessage];
601
- }
602
-
603
- }
604
-
605
- exports.OpCompressedRequest = OpCompressedRequest;