@mablhq/playwright-tools 2.49.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.
Files changed (436) hide show
  1. package/Globals.js +69 -0
  2. package/LICENSE.txt +29 -0
  3. package/README.md +219 -0
  4. package/api/ApiError.js +11 -0
  5. package/api/atlassian/bitBucketApiClient.js +81 -0
  6. package/api/atlassian/entities/CodeAnnotation.js +9 -0
  7. package/api/atlassian/entities/CodeReport.js +15 -0
  8. package/api/atlassian/entities/PullRequest.js +2 -0
  9. package/api/basicApiClient.js +293 -0
  10. package/api/entities/Browser.js +11 -0
  11. package/api/entities/Email.js +14 -0
  12. package/api/entities/FindStrategy.js +10 -0
  13. package/api/entities/Label.js +2 -0
  14. package/api/entities/VersionedObject.js +2 -0
  15. package/api/entities/Workspace.js +2 -0
  16. package/api/featureSet.js +44 -0
  17. package/api/mablApiClient.js +1070 -0
  18. package/api/mablApiClientFactory.js +79 -0
  19. package/api/types.js +10 -0
  20. package/auth/AuthClient.js +38 -0
  21. package/auth/OktaClient.js +97 -0
  22. package/browserEngines/browserEngine.js +41 -0
  23. package/browserEngines/browserEngines.js +14 -0
  24. package/browserEngines/chromiumBrowserEngine.js +177 -0
  25. package/browserEngines/firefoxBrowserEngine.js +134 -0
  26. package/browserEngines/unsupportedBrowserEngine.js +29 -0
  27. package/browserEngines/webkitBrowerEngine.js +50 -0
  28. package/browserLauncher/browser.js +2 -0
  29. package/browserLauncher/browserEvent.js +11 -0
  30. package/browserLauncher/browserLauncher.js +17 -0
  31. package/browserLauncher/browserLauncherEventEmitter.js +2 -0
  32. package/browserLauncher/browserLauncherFactory.js +30 -0
  33. package/browserLauncher/elementHandle.js +30 -0
  34. package/browserLauncher/errors.js +26 -0
  35. package/browserLauncher/frame.js +17 -0
  36. package/browserLauncher/frameBase.js +10 -0
  37. package/browserLauncher/httpRequest.js +2 -0
  38. package/browserLauncher/httpResponse.js +2 -0
  39. package/browserLauncher/jsHandle.js +2 -0
  40. package/browserLauncher/page.js +2 -0
  41. package/browserLauncher/pageEvent.js +17 -0
  42. package/browserLauncher/playwrightBrowserLauncher/browserDelegate.js +2 -0
  43. package/browserLauncher/playwrightBrowserLauncher/chromium/chromiumBrowserDelegate.js +61 -0
  44. package/browserLauncher/playwrightBrowserLauncher/chromium/chromiumElementHandleDelegate.js +129 -0
  45. package/browserLauncher/playwrightBrowserLauncher/chromium/chromiumFrameDelegate.js +24 -0
  46. package/browserLauncher/playwrightBrowserLauncher/chromium/chromiumPageDelegate.js +145 -0
  47. package/browserLauncher/playwrightBrowserLauncher/elementHandleDelegate.js +2 -0
  48. package/browserLauncher/playwrightBrowserLauncher/firefox/firefoxBrowserDelegate.js +50 -0
  49. package/browserLauncher/playwrightBrowserLauncher/firefox/firefoxElementHandleDelegate.js +11 -0
  50. package/browserLauncher/playwrightBrowserLauncher/firefox/firefoxFrameDelegate.js +36 -0
  51. package/browserLauncher/playwrightBrowserLauncher/firefox/firefoxPageDelegate.js +15 -0
  52. package/browserLauncher/playwrightBrowserLauncher/frameDelegate.js +2 -0
  53. package/browserLauncher/playwrightBrowserLauncher/internals.js +2 -0
  54. package/browserLauncher/playwrightBrowserLauncher/nonChromium/nonChromiumAbstractBrowserDelegate.js +15 -0
  55. package/browserLauncher/playwrightBrowserLauncher/nonChromium/nonChromiumAbstractElementHandleDelegate.js +73 -0
  56. package/browserLauncher/playwrightBrowserLauncher/nonChromium/nonChromiumAbstractFrameDelegate.js +13 -0
  57. package/browserLauncher/playwrightBrowserLauncher/nonChromium/nonChromiumAbstractPageDelegate.js +81 -0
  58. package/browserLauncher/playwrightBrowserLauncher/pageDelegate.js +2 -0
  59. package/browserLauncher/playwrightBrowserLauncher/playwrightApiResponse.js +18 -0
  60. package/browserLauncher/playwrightBrowserLauncher/playwrightBrowser.js +259 -0
  61. package/browserLauncher/playwrightBrowserLauncher/playwrightBrowserLauncher.js +97 -0
  62. package/browserLauncher/playwrightBrowserLauncher/playwrightDom.js +319 -0
  63. package/browserLauncher/playwrightBrowserLauncher/playwrightFrame.js +265 -0
  64. package/browserLauncher/playwrightBrowserLauncher/playwrightHttpRequest.js +76 -0
  65. package/browserLauncher/playwrightBrowserLauncher/playwrightHttpResponse.js +26 -0
  66. package/browserLauncher/playwrightBrowserLauncher/playwrightPage.js +377 -0
  67. package/browserLauncher/playwrightBrowserLauncher/simplePlaywrightLogger.js +36 -0
  68. package/browserLauncher/playwrightBrowserLauncher/webkit/webkitBrowserDelegate.js +50 -0
  69. package/browserLauncher/playwrightBrowserLauncher/webkit/webkitElementHandleDelegate.js +16 -0
  70. package/browserLauncher/playwrightBrowserLauncher/webkit/webkitFrameDelegate.js +19 -0
  71. package/browserLauncher/playwrightBrowserLauncher/webkit/webkitPageDelegate.js +15 -0
  72. package/browserLauncher/playwrightBrowserLauncher/wrappers.js +25 -0
  73. package/browserLauncher/types.js +28 -0
  74. package/browserLauncher/utils.js +9 -0
  75. package/cli.js +66 -0
  76. package/commands/applications/applications.js +5 -0
  77. package/commands/applications/applications_cmds/describe.js +21 -0
  78. package/commands/applications/applications_cmds/list.js +56 -0
  79. package/commands/auth/auth.js +5 -0
  80. package/commands/auth/auth_cmds/activate-key.js +38 -0
  81. package/commands/auth/auth_cmds/clear.js +10 -0
  82. package/commands/auth/auth_cmds/info.js +10 -0
  83. package/commands/auth/auth_cmds/login.js +10 -0
  84. package/commands/branches/branches.js +5 -0
  85. package/commands/branches/branches_cmds/create.js +56 -0
  86. package/commands/branches/branches_cmds/describe.js +50 -0
  87. package/commands/branches/branches_cmds/list.js +84 -0
  88. package/commands/branches/branches_cmds/merge.js +56 -0
  89. package/commands/browserTypes.js +20 -0
  90. package/commands/commandUtil/awaitCompletion.js +67 -0
  91. package/commands/commandUtil/branches.js +44 -0
  92. package/commands/commandUtil/codeInsights.js +181 -0
  93. package/commands/commandUtil/describe.js +32 -0
  94. package/commands/commandUtil/fileUtil.js +50 -0
  95. package/commands/commandUtil/interfaces.js +4 -0
  96. package/commands/commandUtil/list.js +70 -0
  97. package/commands/commandUtil/util.js +127 -0
  98. package/commands/commandUtil/versionUtil.js +33 -0
  99. package/commands/config/config.js +5 -0
  100. package/commands/config/config_cmds/configKeys.js +28 -0
  101. package/commands/config/config_cmds/delete.js +29 -0
  102. package/commands/config/config_cmds/get.js +52 -0
  103. package/commands/config/config_cmds/install.js +119 -0
  104. package/commands/config/config_cmds/list.js +39 -0
  105. package/commands/config/config_cmds/set.js +80 -0
  106. package/commands/constants.js +160 -0
  107. package/commands/credentials/credentials.js +5 -0
  108. package/commands/credentials/credentials_cmds/list.js +66 -0
  109. package/commands/datatables/datatables.js +5 -0
  110. package/commands/datatables/datatables_cmds/create.js +61 -0
  111. package/commands/datatables/datatables_cmds/describe.js +17 -0
  112. package/commands/datatables/datatables_cmds/export.js +86 -0
  113. package/commands/datatables/datatables_cmds/list.js +18 -0
  114. package/commands/datatables/datatables_cmds/scenarios.js +35 -0
  115. package/commands/datatables/datatables_cmds/update.js +120 -0
  116. package/commands/datatables/utils.js +145 -0
  117. package/commands/deploy/deploy.js +5 -0
  118. package/commands/deploy/deploy_cmds/awaitDeploymentCompletion.js +100 -0
  119. package/commands/deploy/deploy_cmds/create.js +342 -0
  120. package/commands/deploy/deploy_cmds/describe.js +54 -0
  121. package/commands/deploy/deploy_cmds/executionResultPresenter.js +117 -0
  122. package/commands/deploy/deploy_cmds/list.js +74 -0
  123. package/commands/deploy/deploy_cmds/watch.js +44 -0
  124. package/commands/environments/environments.js +5 -0
  125. package/commands/environments/environments_cmds/build-files.js +5 -0
  126. package/commands/environments/environments_cmds/build-files_cmds/add.js +73 -0
  127. package/commands/environments/environments_cmds/build-files_cmds/list.js +54 -0
  128. package/commands/environments/environments_cmds/build-files_cmds/update.js +71 -0
  129. package/commands/environments/environments_cmds/create.js +153 -0
  130. package/commands/environments/environments_cmds/delete.js +32 -0
  131. package/commands/environments/environments_cmds/describe.js +28 -0
  132. package/commands/environments/environments_cmds/list.js +56 -0
  133. package/commands/environments/environments_cmds/update.js +46 -0
  134. package/commands/environments/environments_cmds/urls.js +5 -0
  135. package/commands/environments/environments_cmds/urls_cmds/add.js +91 -0
  136. package/commands/environments/environments_cmds/urls_cmds/list.js +49 -0
  137. package/commands/flows/flows.js +5 -0
  138. package/commands/flows/flows_cmds/export.js +78 -0
  139. package/commands/flows/flows_cmds/list.js +64 -0
  140. package/commands/internal/internal.js +6 -0
  141. package/commands/link-agents/link-agents.js +5 -0
  142. package/commands/link-agents/link-agents_cmds/delete.js +38 -0
  143. package/commands/link-agents/link-agents_cmds/list.js +131 -0
  144. package/commands/link-agents/link-agents_cmds/terminate.js +31 -0
  145. package/commands/mobile-build-files/mobile-build-files.js +5 -0
  146. package/commands/mobile-build-files/mobile-build-files_cmds/delete.js +31 -0
  147. package/commands/mobile-build-files/mobile-build-files_cmds/download.js +50 -0
  148. package/commands/mobile-build-files/mobile-build-files_cmds/list.js +72 -0
  149. package/commands/mobile-build-files/mobile-build-files_cmds/upload.js +101 -0
  150. package/commands/plans/plans.js +5 -0
  151. package/commands/plans/plans_cmds/describe.js +23 -0
  152. package/commands/plans/plans_cmds/list.js +63 -0
  153. package/commands/test-runs/test-runs.js +5 -0
  154. package/commands/test-runs/test-runs_cmds/export.js +62 -0
  155. package/commands/tests/mobileEmulationUtil.js +46 -0
  156. package/commands/tests/tests.js +5 -0
  157. package/commands/tests/testsUtil.js +538 -0
  158. package/commands/tests/tests_cmds/create.js +130 -0
  159. package/commands/tests/tests_cmds/edit.js +111 -0
  160. package/commands/tests/tests_cmds/export.js +145 -0
  161. package/commands/tests/tests_cmds/import.js +5 -0
  162. package/commands/tests/tests_cmds/import_cmds/import_playwright.js +439 -0
  163. package/commands/tests/tests_cmds/import_cmds/import_selenium.js +295 -0
  164. package/commands/tests/tests_cmds/list.js +94 -0
  165. package/commands/tests/tests_cmds/run-cloud.js +314 -0
  166. package/commands/tests/tests_cmds/run-mobile.js +260 -0
  167. package/commands/tests/tests_cmds/run.js +314 -0
  168. package/commands/tests/tests_cmds/runUtils.js +60 -0
  169. package/commands/tests/tests_cmds/trainerUtil.js +12 -0
  170. package/commands/users/users.js +5 -0
  171. package/commands/users/users_cmds/list.js +58 -0
  172. package/commands/workspaces/workspace_cmds/copy.js +108 -0
  173. package/commands/workspaces/workspace_cmds/describe.js +21 -0
  174. package/commands/workspaces/workspace_cmds/list.js +67 -0
  175. package/commands/workspaces/workspaces.js +5 -0
  176. package/core/entityValidation/environmentsValidation.js +7 -0
  177. package/core/entityValidation/stepValidation.js +15 -0
  178. package/core/execution/ApiTestUtils.js +1060 -0
  179. package/core/execution/MailboxConstants.js +4 -0
  180. package/core/execution/PostmanUtils.js +53 -0
  181. package/core/execution/RunConfig.js +2 -0
  182. package/core/execution/TestResult.js +15 -0
  183. package/core/execution/VariableUtils.js +154 -0
  184. package/core/execution/VariablesSummary.js +2 -0
  185. package/core/execution/basic-types.js +2 -0
  186. package/core/execution/newman-types.js +42 -0
  187. package/core/messaging/actions/MobileTrainingActions.js +17 -0
  188. package/core/messaging/actions/pdfActions.js +27 -0
  189. package/core/messaging/actions/runnerActions.js +18 -0
  190. package/core/messaging/actions/trainingSessionActions.js +38 -0
  191. package/core/messaging/logLineMessaging.js +50 -0
  192. package/core/messaging/messaging.js +130 -0
  193. package/core/messaging/pageMessaging.js +9 -0
  194. package/core/trainer/openUtils.js +47 -0
  195. package/core/trainer/trainingSessions-types.js +35 -0
  196. package/core/trainer/trainingSessions.js +151 -0
  197. package/core/util.js +52 -0
  198. package/coreWebVitals/index.js +77 -0
  199. package/domUtil/index.js +1 -0
  200. package/env/defaultEnv.js +17 -0
  201. package/env/dev.js +17 -0
  202. package/env/env.js +76 -0
  203. package/env/local.js +17 -0
  204. package/env/prod.js +17 -0
  205. package/execution/index.js +8 -0
  206. package/execution/index.js.LICENSE.txt +254 -0
  207. package/execution/runAppiumServer.js +145 -0
  208. package/functions/apiTest/utils.js +47 -0
  209. package/functions/types.js +2 -0
  210. package/functions/utils.js +12 -0
  211. package/http/MablHttpAgent.js +73 -0
  212. package/http/RequestFilteringHttpAgent.js +119 -0
  213. package/http/RequestSecurityError.js +13 -0
  214. package/http/axiosProxyConfig.js +101 -0
  215. package/http/httpUtil.js +73 -0
  216. package/http/requestInterceptor.js +206 -0
  217. package/index.d.ts +241 -0
  218. package/index.js +14 -0
  219. package/mablApi/index.js +1 -0
  220. package/mablscript/MablAction.js +102 -0
  221. package/mablscript/MablStep.js +191 -0
  222. package/mablscript/MablStepV2.js +73 -0
  223. package/mablscript/MablSymbol.js +35 -0
  224. package/mablscript/actions/AwaitDownloadAction.js +14 -0
  225. package/mablscript/actions/AwaitPDFDownloadAction.js +19 -0
  226. package/mablscript/actions/ConditionAction.js +123 -0
  227. package/mablscript/actions/CountAction.js +16 -0
  228. package/mablscript/actions/ExtractAction.js +71 -0
  229. package/mablscript/actions/FindAction.js +301 -0
  230. package/mablscript/actions/GenerateEmailAddressAction.js +14 -0
  231. package/mablscript/actions/GenerateRandomStringAction.js +20 -0
  232. package/mablscript/actions/GetUrlAction.js +22 -0
  233. package/mablscript/actions/GetVariableValue.js +31 -0
  234. package/mablscript/actions/GetViewportAction.js +17 -0
  235. package/mablscript/actions/JavaScriptAction.js +219 -0
  236. package/mablscript/diffing/diffingUtil.js +229 -0
  237. package/mablscript/importer.js +576 -0
  238. package/mablscript/mobile/steps/CreateVariableMobileStep.js +53 -0
  239. package/mablscript/mobile/steps/EnterTextStep.js +45 -0
  240. package/mablscript/mobile/steps/HideKeyboardStep.js +20 -0
  241. package/mablscript/mobile/steps/InstallAppStep.js +22 -0
  242. package/mablscript/mobile/steps/NavigateBackStep.js +20 -0
  243. package/mablscript/mobile/steps/NavigateHomeStep.js +21 -0
  244. package/mablscript/mobile/steps/OpenAppStep.js +22 -0
  245. package/mablscript/mobile/steps/OpenLinkStep.js +19 -0
  246. package/mablscript/mobile/steps/PrepareSessionStep.js +19 -0
  247. package/mablscript/mobile/steps/PushFileStep.js +27 -0
  248. package/mablscript/mobile/steps/ScrollStep.js +87 -0
  249. package/mablscript/mobile/steps/SetOrientationStep.js +20 -0
  250. package/mablscript/mobile/steps/TapStep.js +37 -0
  251. package/mablscript/mobile/steps/UninstallAppStep.js +22 -0
  252. package/mablscript/mobile/steps/actions/MobileFindAction.js +23 -0
  253. package/mablscript/mobile/steps/stepUtil.js +113 -0
  254. package/mablscript/mobile/tests/StepTestsUtil.js +20 -0
  255. package/mablscript/mobile/tests/TestMobileFindDescriptors.js +282 -0
  256. package/mablscript/mobile/tests/steps/CreateVariableMobileStep.mobiletest.js +298 -0
  257. package/mablscript/mobile/tests/steps/EnterTextStep.mobiletest.js +79 -0
  258. package/mablscript/mobile/tests/steps/GeneralHumanization.mobiletest.js +304 -0
  259. package/mablscript/mobile/tests/steps/HideKeyboardStep.mobiletest.js +27 -0
  260. package/mablscript/mobile/tests/steps/InstallAppStep.mobiletest.js +20 -0
  261. package/mablscript/mobile/tests/steps/NavigateBackStep.mobiletest.js +27 -0
  262. package/mablscript/mobile/tests/steps/NavigateHomeStep.mobiletest.js +27 -0
  263. package/mablscript/mobile/tests/steps/OpenLinkStep.mobiletest.js +20 -0
  264. package/mablscript/mobile/tests/steps/PushFileStep.mobiletest.js +55 -0
  265. package/mablscript/mobile/tests/steps/ScrollStep.mobiletest.js +386 -0
  266. package/mablscript/mobile/tests/steps/SetOrientationStep.mobiletest.js +32 -0
  267. package/mablscript/mobile/tests/steps/TapStep.mobiletest.js +57 -0
  268. package/mablscript/mobile/tests/steps/UninstallAppStep.mobiletest.js +20 -0
  269. package/mablscript/steps/AbstractAssertionsAndVariablesStep.js +52 -0
  270. package/mablscript/steps/AccessibilityCheck.js +108 -0
  271. package/mablscript/steps/ActionsUtils.js +18 -0
  272. package/mablscript/steps/AssertStep.js +318 -0
  273. package/mablscript/steps/AssertStepOld.js +159 -0
  274. package/mablscript/steps/AwaitTabStep.js +69 -0
  275. package/mablscript/steps/AwaitUploadsStep.js +26 -0
  276. package/mablscript/steps/ClearCookiesStep.js +26 -0
  277. package/mablscript/steps/ClickAndHoldStep.js +76 -0
  278. package/mablscript/steps/ClickStep.js +58 -0
  279. package/mablscript/steps/CookieUtils.js +54 -0
  280. package/mablscript/steps/CreateVariableStep.js +236 -0
  281. package/mablscript/steps/DatabaseQueryStep.js +28 -0
  282. package/mablscript/steps/DoubleClickStep.js +64 -0
  283. package/mablscript/steps/DownloadStep.js +96 -0
  284. package/mablscript/steps/EchoStep.js +34 -0
  285. package/mablscript/steps/ElseIfConditionStep.js +32 -0
  286. package/mablscript/steps/ElseStep.js +27 -0
  287. package/mablscript/steps/EndStep.js +27 -0
  288. package/mablscript/steps/EnterAuthCodeStep.js +59 -0
  289. package/mablscript/steps/EnterTextStep.js +96 -0
  290. package/mablscript/steps/EvaluateFlowStep.js +51 -0
  291. package/mablscript/steps/EvaluateJavaScriptStep.js +50 -0
  292. package/mablscript/steps/HoverStep.js +63 -0
  293. package/mablscript/steps/IfConditionStep.js +191 -0
  294. package/mablscript/steps/NavigateStep.js +30 -0
  295. package/mablscript/steps/OpenEmailStep.js +46 -0
  296. package/mablscript/steps/ReleaseStep.js +76 -0
  297. package/mablscript/steps/RemoveCookieStep.js +36 -0
  298. package/mablscript/steps/RightClickStep.js +58 -0
  299. package/mablscript/steps/SelectStep.js +82 -0
  300. package/mablscript/steps/SendHttpRequestStep.js +48 -0
  301. package/mablscript/steps/SendKeyStep.js +84 -0
  302. package/mablscript/steps/SetCookieStep.js +70 -0
  303. package/mablscript/steps/SetFilesStep.js +71 -0
  304. package/mablscript/steps/SetViewportStep.js +38 -0
  305. package/mablscript/steps/SwitchContextStep.js +122 -0
  306. package/mablscript/steps/SyntheticStep.js +20 -0
  307. package/mablscript/steps/VisitUrlStep.js +68 -0
  308. package/mablscript/steps/WaitStep.js +37 -0
  309. package/mablscript/steps/WaitUntilStep.js +46 -0
  310. package/mablscript/types/AccessibilityCheckStepDescriptor.js +2 -0
  311. package/mablscript/types/AccessibilityCheckTypes.js +9 -0
  312. package/mablscript/types/AssertionsAndVariablesStepDescriptor.js +2 -0
  313. package/mablscript/types/AwaitTabDescriptor.js +2 -0
  314. package/mablscript/types/AwaitUploadStepDescriptor.js +2 -0
  315. package/mablscript/types/ClearCookiesStepDescriptor.js +2 -0
  316. package/mablscript/types/ClickAndHoldStepDescriptor.js +2 -0
  317. package/mablscript/types/ClickStepDescriptor.js +2 -0
  318. package/mablscript/types/ConditionDescriptor.js +133 -0
  319. package/mablscript/types/CountDescriptor.js +2 -0
  320. package/mablscript/types/CreateVariableStepDescriptor.js +12 -0
  321. package/mablscript/types/DownloadStepDescriptor.js +2 -0
  322. package/mablscript/types/EchoStepDescriptor.js +2 -0
  323. package/mablscript/types/EnterTextStepDescriptor.js +2 -0
  324. package/mablscript/types/EvaluateFlowStepDescriptor.js +2 -0
  325. package/mablscript/types/EvaluateJavaScriptStepDescriptor.js +2 -0
  326. package/mablscript/types/ExtractDescriptor.js +21 -0
  327. package/mablscript/types/GetCurrentLocationDescriptor.js +12 -0
  328. package/mablscript/types/GetVariableDescriptor.js +16 -0
  329. package/mablscript/types/GetViewportDescriptor.js +12 -0
  330. package/mablscript/types/HoverStepDescriptor.js +2 -0
  331. package/mablscript/types/NavigateStepDescriptor.js +7 -0
  332. package/mablscript/types/OpenEmailStepDescriptor.js +2 -0
  333. package/mablscript/types/OperatingSystemDescriptor.js +45 -0
  334. package/mablscript/types/ReleaseStepDescriptor.js +7 -0
  335. package/mablscript/types/RemoveCookieStepDescriptor.js +2 -0
  336. package/mablscript/types/SelectStepDescriptor.js +2 -0
  337. package/mablscript/types/SendHttpRequestTypes.js +2 -0
  338. package/mablscript/types/SendKeyStepDescriptor.js +30 -0
  339. package/mablscript/types/SetCookieStepDescriptor.js +2 -0
  340. package/mablscript/types/SetFilesStepDescriptor.js +2 -0
  341. package/mablscript/types/SetViewportStepDescriptor.js +2 -0
  342. package/mablscript/types/SnippetsDescriptor.js +36 -0
  343. package/mablscript/types/StepDescriptor.js +2 -0
  344. package/mablscript/types/SwitchContextStepDescriptor.js +15 -0
  345. package/mablscript/types/VariableNamespace.js +17 -0
  346. package/mablscript/types/VisitUrlStepDescriptor.js +2 -0
  347. package/mablscript/types/WaitStepDescriptor.js +2 -0
  348. package/mablscript/types/WaitUntilStepDescriptor.js +2 -0
  349. package/mablscript/types/mobile/CreateVariableMobileStepDescriptor.js +9 -0
  350. package/mablscript/types/mobile/EnterTextStepDescriptor.js +2 -0
  351. package/mablscript/types/mobile/HideKeyboardStepDescriptor.js +2 -0
  352. package/mablscript/types/mobile/InstallAppStepDescriptor.js +2 -0
  353. package/mablscript/types/mobile/NavigateBackStepDescriptor.js +2 -0
  354. package/mablscript/types/mobile/NavigateHomeStepDescriptor.js +2 -0
  355. package/mablscript/types/mobile/OpenAppStepDescriptor.js +2 -0
  356. package/mablscript/types/mobile/OpenLinkStepDescriptor.js +2 -0
  357. package/mablscript/types/mobile/PrepareSessionStepDescriptor.js +2 -0
  358. package/mablscript/types/mobile/PushFileDescriptor.js +2 -0
  359. package/mablscript/types/mobile/ScrollStepDescriptor.js +32 -0
  360. package/mablscript/types/mobile/SetOrientationStepDescriptor.js +8 -0
  361. package/mablscript/types/mobile/StepWithMobileFindDescriptor.js +8 -0
  362. package/mablscript/types/mobile/TapStepDescriptor.js +8 -0
  363. package/mablscript/types/mobile/UninstallAppStepDescriptor.js +2 -0
  364. package/mablscriptFind/index.js +2 -0
  365. package/mablscriptFind/index.js.LICENSE.txt +25 -0
  366. package/middleware.js +42 -0
  367. package/mobile/index.js +2 -0
  368. package/mobile/types.js +8 -0
  369. package/observers/ObserverBase.js +11 -0
  370. package/observers/mockObserver.js +47 -0
  371. package/package.json +107 -0
  372. package/popupDismissal/candidate.js +2 -0
  373. package/popupDismissal/index.js +255 -0
  374. package/providers/authenticationProvider.js +254 -0
  375. package/providers/cliConfigProvider.js +271 -0
  376. package/providers/exportRequestProvider.js +196 -0
  377. package/providers/logging/loggingProvider.js +90 -0
  378. package/providers/scmContextInterfaces.js +14 -0
  379. package/providers/scmContextProvider.js +335 -0
  380. package/providers/scmContextProviderV2.js +122 -0
  381. package/providers/types.js +9 -0
  382. package/proxy/index.js +2 -0
  383. package/proxy/index.js.LICENSE.txt +12 -0
  384. package/proxy/lib/xpath.js +1 -0
  385. package/reporters/__tests__/resources/sampleData.js +162 -0
  386. package/reporters/mochAwesome/interfaces.js +2 -0
  387. package/reporters/mochAwesome/mochAwesomeReporter.js +227 -0
  388. package/reporters/reporter.js +46 -0
  389. package/resources/actionabilityCheck.js +160 -0
  390. package/resources/coreWebVitals.js +1 -0
  391. package/resources/mablFind.js +2 -0
  392. package/resources/media/mabl_test_audio.wav +0 -0
  393. package/resources/media/mabl_test_pattern.y4m +3 -0
  394. package/resources/pdf-viewer/EmbeddedPdfHandler.js +1 -0
  395. package/resources/pdf-viewer/embeddedPdfDetection.js +225 -0
  396. package/resources/pdf-viewer/index.html +1 -0
  397. package/resources/pdf-viewer/index.js +2 -0
  398. package/resources/pdf-viewer/libEmbeddedPdfHandler.js +279 -0
  399. package/resources/pdf-viewer/libmablPdfViewer.js +21909 -0
  400. package/resources/pdf-viewer/mabl_attention_move.gif +0 -0
  401. package/resources/pdf-viewer/mabl_error_artwork_Unplugged.gif +0 -0
  402. package/resources/pdf-viewer/pdf.worker.9251738a897f697389be.js +2 -0
  403. package/resources/pdf-viewer/pdf.worker.9e2021092643447a5b9f.js +81 -0
  404. package/resources/popupDismissal.js +1 -0
  405. package/resources/webdriver.js +19 -0
  406. package/socketTunnel/index.js +2 -0
  407. package/socketTunnel/index.js.LICENSE.txt +68 -0
  408. package/upload/index.js +2 -0
  409. package/upload/index.js.LICENSE.txt +27 -0
  410. package/util/CloudStorageWriter.js +45 -0
  411. package/util/FileCache.js +180 -0
  412. package/util/IdentifierUtil.js +57 -0
  413. package/util/InternalMetricsTrackingSingleton.js +36 -0
  414. package/util/Lazy.js +90 -0
  415. package/util/MobileAppFileCache.js +103 -0
  416. package/util/RichPromise.js +53 -0
  417. package/util/TestOutputWriter.js +104 -0
  418. package/util/actionabilityUtil.js +165 -0
  419. package/util/analytics-events.js +14 -0
  420. package/util/analytics.js +176 -0
  421. package/util/asyncUtil.js +61 -0
  422. package/util/browserTestUtils.js +17 -0
  423. package/util/clickUtil.js +68 -0
  424. package/util/downloadUtil.js +87 -0
  425. package/util/encodingUtil.js +50 -0
  426. package/util/fileUploadUtil.js +146 -0
  427. package/util/javaScriptStepMigration.js +115 -0
  428. package/util/jestUtil.js +21 -0
  429. package/util/logUtils.js +131 -0
  430. package/util/markdownUtil.js +125 -0
  431. package/util/postInstallMessage.js +14 -0
  432. package/util/pureUtil.js +175 -0
  433. package/util/resourceUtil.js +90 -0
  434. package/util/timeUtil.js +31 -0
  435. package/utilities.js +7 -0
  436. package/webdriver/index.js +44 -0
@@ -0,0 +1,1070 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.MablApiClient = void 0;
7
+ const ApiError_1 = require("./ApiError");
8
+ const env_1 = require("../env/env");
9
+ const mablApi_1 = require("../mablApi");
10
+ const cliConfigProvider_1 = require("../providers/cliConfigProvider");
11
+ const basicApiClient_1 = require("./basicApiClient");
12
+ const query_string_1 = __importDefault(require("query-string"));
13
+ const featureSet_1 = require("./featureSet");
14
+ const GENAI_RETRY_OPTIONS = {
15
+ retryCount: 10,
16
+ minRetryIntervalMillis: 10000,
17
+ maxRetryIntervalMillis: 60000,
18
+ maxRetryTimeMillis: 180000,
19
+ };
20
+ class MablApiClient extends basicApiClient_1.BasicApiClient {
21
+ constructor(options) {
22
+ var _a, _b;
23
+ super(options);
24
+ this.baseApiUrl =
25
+ (_b = (_a = options.apiUrl) !== null && _a !== void 0 ? _a : process.env.MABL_API_URL) !== null && _b !== void 0 ? _b : env_1.BASE_API_URL;
26
+ }
27
+ async getPlan(planId) {
28
+ try {
29
+ return await this.makeGetRequest(`${this.baseApiUrl}/schedule/runPolicy/${planId}`);
30
+ }
31
+ catch (error) {
32
+ throw toApiError(`Failed to get plan (${planId})`, error);
33
+ }
34
+ }
35
+ async getPlans(options) {
36
+ var _a, _b;
37
+ try {
38
+ const queryArg = query_string_1.default.stringify(options);
39
+ const plans = await this.makeGetRequest(`${this.baseApiUrl}/schedule/runPolicy/?${queryArg}`);
40
+ sortTemporallyAscending((_a = plans.run_policies) !== null && _a !== void 0 ? _a : []);
41
+ return (_b = plans.run_policies) !== null && _b !== void 0 ? _b : [];
42
+ }
43
+ catch (error) {
44
+ throw toApiError(`Failed to get plans (workspace: ${options.organization_id})`, error);
45
+ }
46
+ }
47
+ async getApplication(applicationId) {
48
+ try {
49
+ return await this.makeGetRequest(`${this.baseApiUrl}/v1/applications/${applicationId}`);
50
+ }
51
+ catch (error) {
52
+ throw toApiError(`Failed to get application (${applicationId})`, error);
53
+ }
54
+ }
55
+ async getApplications(workspaceId, limit) {
56
+ try {
57
+ const applicationQueryString = query_string_1.default.stringify({
58
+ organization_id: workspaceId,
59
+ limit,
60
+ });
61
+ const applications = await this.makeGetRequest(`${this.baseApiUrl}/applications?${applicationQueryString}`).then((result) => { var _a; return (_a = result.applications) !== null && _a !== void 0 ? _a : []; });
62
+ sortTemporallyAscending(applications);
63
+ return applications;
64
+ }
65
+ catch (error) {
66
+ throw toApiError(`Failed to get applications`, error);
67
+ }
68
+ }
69
+ async getEnvironment(environmentId, decryptVariables) {
70
+ try {
71
+ const queryStringArgs = {
72
+ decrypt: decryptVariables,
73
+ };
74
+ const envQueryString = query_string_1.default.stringify(queryStringArgs);
75
+ return await this.makeGetRequest(`${this.baseApiUrl}/v1/environments/${environmentId}?${envQueryString}`);
76
+ }
77
+ catch (error) {
78
+ throw toApiError(`Failed to get environment (${environmentId})`, error);
79
+ }
80
+ }
81
+ async deleteEnvironment(id) {
82
+ try {
83
+ return await this.makeDeleteRequest(`${this.baseApiUrl}/environments/${id}`);
84
+ }
85
+ catch (error) {
86
+ throw toApiError(`Failed to delete environment`, error);
87
+ }
88
+ }
89
+ async createEnvironment(environment) {
90
+ try {
91
+ return await this.makePostRequest(`${this.baseApiUrl}/environments`, environment);
92
+ }
93
+ catch (error) {
94
+ throw toApiError(`Failed to create environment`, error);
95
+ }
96
+ }
97
+ async updateEnvironment(id, environment) {
98
+ try {
99
+ return await this.makePatchRequest(`${this.baseApiUrl}/environments/${id}`, environment);
100
+ }
101
+ catch (error) {
102
+ throw toApiError(`Failed to update environment`, error);
103
+ }
104
+ }
105
+ async getEnvironments(workspaceId, limit) {
106
+ try {
107
+ const environmentQueryString = query_string_1.default.stringify({
108
+ organization_id: workspaceId,
109
+ limit,
110
+ });
111
+ const environments = await this.makeGetRequest(`${this.baseApiUrl}/v1/environments/?${environmentQueryString}`).then((result) => { var _a; return (_a = result.environments) !== null && _a !== void 0 ? _a : []; });
112
+ sortTemporallyAscending(environments);
113
+ return environments;
114
+ }
115
+ catch (error) {
116
+ throw toApiError(`Failed to get environments`, error);
117
+ }
118
+ }
119
+ async createDeployment(deployment) {
120
+ try {
121
+ return await this.makePostRequest(`${this.baseApiUrl}/deployments`, deployment);
122
+ }
123
+ catch (error) {
124
+ throw toApiError(`Failed to create deployment`, error);
125
+ }
126
+ }
127
+ async updateDeployment(id, deployment) {
128
+ try {
129
+ return await this.makePatchRequest(`${this.baseApiUrl}/deployments/${id}`, deployment);
130
+ }
131
+ catch (error) {
132
+ throw toApiError(`Failed to update environment`, error);
133
+ }
134
+ }
135
+ async selectLinkServers(workspaceId, labels) {
136
+ try {
137
+ const queryParams = query_string_1.default.stringify({
138
+ workspace_id: workspaceId,
139
+ labels,
140
+ }, { arrayFormat: 'comma' });
141
+ return (await this.makeGetRequest(`${this.baseApiUrl}/link/servers/select-multiple?${queryParams}`)).link_servers;
142
+ }
143
+ catch (error) {
144
+ throw toApiError(`Failed to get selected link server`, error);
145
+ }
146
+ }
147
+ async deleteLinkLabel(workspaceId, linkLabel) {
148
+ try {
149
+ return await this.makeDeleteRequest(`${this.baseApiUrl}/link/${workspaceId}/label/${linkLabel}`);
150
+ }
151
+ catch (error) {
152
+ throw toApiError(`Failed to delete link label`, error);
153
+ }
154
+ }
155
+ async getLinkAgentsWithRecentHeartbeats(workspaceId, limit, maxHeartbeatAgeSeconds) {
156
+ var _a;
157
+ try {
158
+ return ((_a = (await this.makeGetRequest(`${env_1.BASE_API_URL}/link/agents?workspace_id=${workspaceId}&limit=${limit}&max_heartbeat_age_sec=${maxHeartbeatAgeSeconds}`)).link_agents) !== null && _a !== void 0 ? _a : []);
159
+ }
160
+ catch (error) {
161
+ throw toApiError(`Failed to get active link agents`, error);
162
+ }
163
+ }
164
+ async terminateLinkAgent(id) {
165
+ try {
166
+ await this.makePostRequest(`${env_1.BASE_API_URL}/link/agents/${id}/terminate`);
167
+ }
168
+ catch (error) {
169
+ throw toApiError(`Failed to terminate link agent`, error);
170
+ }
171
+ }
172
+ async getExportRequest(id) {
173
+ return this.getEntity(id, 'exports', 'ExportRequest');
174
+ }
175
+ async getEntity(id, path, entityName = 'Entity') {
176
+ try {
177
+ return await this.makeGetRequest(`${this.baseApiUrl}/v1/${path}/${id}`);
178
+ }
179
+ catch (error) {
180
+ throw toApiError(`Failed to get ${entityName} (${id})`, error);
181
+ }
182
+ }
183
+ async getCredentials(workspaceId, limit) {
184
+ try {
185
+ const credentialsQueryString = query_string_1.default.stringify({
186
+ organization_id: workspaceId,
187
+ limit,
188
+ });
189
+ return await this.makeGetRequest(`${this.baseApiUrl}/credentials?${credentialsQueryString}`).then((result) => { var _a; return (_a = result.credentials) !== null && _a !== void 0 ? _a : []; });
190
+ }
191
+ catch (error) {
192
+ throw toApiError(`Failed to get credentials`, error);
193
+ }
194
+ }
195
+ async getCredential(credentialId, withSecrets, withComputedTotpCount) {
196
+ const queryStringParams = query_string_1.default.stringify({
197
+ with_secrets: withSecrets,
198
+ with_computed_totp_count: withComputedTotpCount,
199
+ });
200
+ try {
201
+ return await this.makeGetRequest(`${this.baseApiUrl}/credentials/${credentialId}?${queryStringParams}`);
202
+ }
203
+ catch (error) {
204
+ throw toApiError(`Failed to get credential`, error);
205
+ }
206
+ }
207
+ async getDeploymentEvents(workspaceId, limit) {
208
+ try {
209
+ const deploymentQueryString = query_string_1.default.stringify({
210
+ workspace_id: workspaceId,
211
+ limit,
212
+ });
213
+ return await this.makeGetRequest(`${this.baseApiUrl}/events/deployment?${deploymentQueryString}`).then((result) => { var _a; return (_a = result.deployments) !== null && _a !== void 0 ? _a : []; });
214
+ }
215
+ catch (error) {
216
+ throw toApiError(`Failed to get deployment events`, error);
217
+ }
218
+ }
219
+ async getDeploymentEvent(deploymentId) {
220
+ try {
221
+ return await this.makeGetRequest(`${this.baseApiUrl}/events/deployment/${deploymentId}`);
222
+ }
223
+ catch (error) {
224
+ throw toApiError(`Failed to get deployment event`, error);
225
+ }
226
+ }
227
+ async getDeploymentEntity(deploymentId) {
228
+ try {
229
+ return await this.makeGetRequest(`${this.baseApiUrl}/deployments/${deploymentId}`);
230
+ }
231
+ catch (error) {
232
+ throw toApiError(`Failed to get deployment entity`, error);
233
+ }
234
+ }
235
+ async queryDeploymentEntities(workspaceId, environmentId, applicationId, limit = 50) {
236
+ try {
237
+ const queryStringParams = query_string_1.default.stringify({
238
+ organization_id: workspaceId,
239
+ environment_id: environmentId,
240
+ application_id: applicationId,
241
+ limit,
242
+ });
243
+ const query = `${this.baseApiUrl}/deployments?${queryStringParams}`;
244
+ return await this.makeGetRequest(query);
245
+ }
246
+ catch (error) {
247
+ throw toApiError(`Failed to query url entities`, error);
248
+ }
249
+ }
250
+ async getDeploymentResults(deploymentEventId) {
251
+ try {
252
+ return await this.makeGetRequest(`${this.baseApiUrl}/execution/result/event/${deploymentEventId}`);
253
+ }
254
+ catch (error) {
255
+ throw toApiError(`Failed to get deployment results`, error);
256
+ }
257
+ }
258
+ async evaluateFindAttributes(workspaceId, evaluateAttributes) {
259
+ try {
260
+ return await this.makePostRequest(`${this.baseApiUrl}/find/${workspaceId}/evaluate/attributes`, evaluateAttributes);
261
+ }
262
+ catch (error) {
263
+ return undefined;
264
+ }
265
+ }
266
+ async evaluateFindCandidatesText(workspaceId, request) {
267
+ try {
268
+ return await this.makePostRequest(`${this.baseApiUrl}/find/${workspaceId}/evaluate/textSimilarity`, request);
269
+ }
270
+ catch (error) {
271
+ return undefined;
272
+ }
273
+ }
274
+ async getTestFindSummaries(testId, environmentId) {
275
+ try {
276
+ return await this.makeGetRequest(`${this.baseApiUrl}/findSummary?journey_id=${testId}&environment_id=${environmentId}`).then((result) => { var _a; return (_a = result.findsummaries) !== null && _a !== void 0 ? _a : []; });
277
+ }
278
+ catch (error) {
279
+ throw toApiError(`Failed to get test find summaries results`, error);
280
+ }
281
+ }
282
+ async getTestFindModels(testId, environmentId) {
283
+ try {
284
+ return await this.makeGetRequest(`${this.baseApiUrl}/findModel/test/${testId}?environment_id=${environmentId}`).then((result) => { var _a; return (_a = result.findModels) !== null && _a !== void 0 ? _a : []; });
285
+ }
286
+ catch (error) {
287
+ throw toApiError(`Failed to get test find model results`, error);
288
+ }
289
+ }
290
+ async getTestOverrides(testId, environmentId, selectorOverrideLimit = 10) {
291
+ try {
292
+ return await this.makeGetRequest(`${this.baseApiUrl}/tests/testScripts/${testId}/overrides?environment_id=${environmentId}&selector_override_limit=${selectorOverrideLimit}`).then((result) => { var _a; return (_a = result.overrides) !== null && _a !== void 0 ? _a : []; });
293
+ }
294
+ catch (error) {
295
+ throw toApiError(`Failed to get selector overrides`, error);
296
+ }
297
+ }
298
+ async getTestRun(testRunId) {
299
+ try {
300
+ return await this.makeGetRequest(`${this.baseApiUrl}/journeyRuns/${testRunId}`);
301
+ }
302
+ catch (error) {
303
+ throw toApiError(`Failed to get test run info`, error);
304
+ }
305
+ }
306
+ async getPlanRun(planRunId) {
307
+ try {
308
+ return await this.makeGetRequest(`${this.baseApiUrl}/planRuns/${planRunId}`);
309
+ }
310
+ catch (error) {
311
+ throw toApiError(`Failed to get plan run info`, error);
312
+ }
313
+ }
314
+ async getWorkspaces(limit) {
315
+ var _a, _b;
316
+ try {
317
+ const userInfo = await this.getSelf();
318
+ const requests = (_b = (_a = userInfo.roles) === null || _a === void 0 ? void 0 : _a.slice(0, limit).map((role) => this.getWorkspace(role.organization_id))) !== null && _b !== void 0 ? _b : [];
319
+ const workspaces = await Promise.all(requests);
320
+ sortTemporallyAscending(workspaces);
321
+ return workspaces;
322
+ }
323
+ catch (error) {
324
+ throw toApiError(`Failed to get workspaces`, error);
325
+ }
326
+ }
327
+ async getWorkspace(workspaceId) {
328
+ try {
329
+ return await this.makeGetRequest(`${this.baseApiUrl}/organizations/${workspaceId}`);
330
+ }
331
+ catch (error) {
332
+ throw toApiError(`Failed to get workspace`, error);
333
+ }
334
+ }
335
+ async getAccount(accountId) {
336
+ try {
337
+ return await this.makeGetRequest(`${this.baseApiUrl}/accounts/${accountId}`);
338
+ }
339
+ catch (error) {
340
+ throw toApiError(`Failed to get account`, error);
341
+ }
342
+ }
343
+ async getAccountByWorkspaceId(workspaceId) {
344
+ try {
345
+ return await this.makeGetRequest(`${this.baseApiUrl}/organizations/${workspaceId}/account`);
346
+ }
347
+ catch (error) {
348
+ throw toApiError(`Failed to get account from workspace id`, error);
349
+ }
350
+ }
351
+ async getApiKeyDetails() {
352
+ try {
353
+ return await this.makeGetRequest(`${this.baseApiUrl}/apiKeys/self`);
354
+ }
355
+ catch (error) {
356
+ throw toApiError(`Failed to validate API Key`, error);
357
+ }
358
+ }
359
+ async getSelf() {
360
+ var _a, _b;
361
+ try {
362
+ const selfInfo = await this.makeGetRequest(`${this.baseApiUrl}/self`);
363
+ if (((_a = selfInfo.preferences) === null || _a === void 0 ? void 0 : _a.default_workspace_id) &&
364
+ !(await cliConfigProvider_1.CliConfigProvider.getWorkspace())) {
365
+ const workspace = await this.getWorkspace(selfInfo.preferences.default_workspace_id);
366
+ await cliConfigProvider_1.CliConfigProvider.setWorkspace(workspace);
367
+ }
368
+ else if (((_b = selfInfo.roles) === null || _b === void 0 ? void 0 : _b.length) === 1) {
369
+ const workspace = await this.getWorkspace(selfInfo.roles[0].organization_id);
370
+ await cliConfigProvider_1.CliConfigProvider.setWorkspace(workspace);
371
+ }
372
+ return selfInfo;
373
+ }
374
+ catch (error) {
375
+ throw toApiError(`Failed to validate user`, error);
376
+ }
377
+ }
378
+ async getJourney(journeyId, branchName = 'none', forExportFormat = 'none') {
379
+ try {
380
+ const queryStringArgs = {
381
+ cliExport: forExportFormat,
382
+ sourceControlTag: branchName,
383
+ };
384
+ const journeyQueryString = query_string_1.default.stringify(queryStringArgs);
385
+ return await this.makeGetRequest(`${this.baseApiUrl}/test/journey/${journeyId}?${journeyQueryString}`);
386
+ }
387
+ catch (error) {
388
+ throw toApiError(`Failed to get Test [${journeyId}]`, error);
389
+ }
390
+ }
391
+ async getJourneys(options) {
392
+ var _a;
393
+ try {
394
+ const queryArg = query_string_1.default.stringify(options);
395
+ const journeys = (_a = (await this.makeGetRequest(`${this.baseApiUrl}/test/journeys?${queryArg}`)).journeys) !== null && _a !== void 0 ? _a : [];
396
+ sortTemporallyAscending(journeys);
397
+ return journeys;
398
+ }
399
+ catch (error) {
400
+ throw toApiError(`Failed to get Tests`, error);
401
+ }
402
+ }
403
+ async getFlow(flowId, branchName) {
404
+ try {
405
+ const queryStringArgs = {
406
+ sourceControlTag: branchName,
407
+ };
408
+ const flowQueryString = query_string_1.default.stringify(queryStringArgs);
409
+ return await this.makeGetRequest(`${this.baseApiUrl}/flows/${flowId}?${flowQueryString}`);
410
+ }
411
+ catch (error) {
412
+ throw toApiError(`Failed to get Flow [${flowId}]`, error);
413
+ }
414
+ }
415
+ async getFlows(options) {
416
+ var _a;
417
+ try {
418
+ const queryArg = query_string_1.default.stringify(options);
419
+ const flows = (_a = (await this.makeGetRequest(`${this.baseApiUrl}/flows?${queryArg}`)).flows) !== null && _a !== void 0 ? _a : [];
420
+ sortTemporallyAscending(flows);
421
+ return flows;
422
+ }
423
+ catch (error) {
424
+ throw toApiError(`Failed to get Flows`, error);
425
+ }
426
+ }
427
+ async getSnippet(snippetId, isQuery, preferLatestIfReusable, workspaceId) {
428
+ const entity = isQuery ? 'query' : 'snippet';
429
+ try {
430
+ const queryParameter = typeof preferLatestIfReusable === 'boolean'
431
+ ? `?=preferLatestIfReusable=${preferLatestIfReusable}`
432
+ : '';
433
+ return await this.makeGetRequest(`${this.baseApiUrl}/snippets/${snippetId}${queryParameter}`);
434
+ }
435
+ catch (error) {
436
+ throw toApiError(`Failed to get ${entity} [${snippetId}]. ${workspaceId
437
+ ? `The ${entity} was likely deleted. To recover this ${entity}, visit the activity feed [workspaces/${workspaceId}/settings/activity-log?activityLogEntity=${entity}&activityLogEvent=delete]`
438
+ : `The ${entity} was likely deleted. To recover this ${entity}, visit the activity feed.`}`, error);
439
+ }
440
+ }
441
+ async getBranchById(branchId) {
442
+ try {
443
+ return await this.makeGetRequest(`${this.baseApiUrl}/branch/${branchId}`);
444
+ }
445
+ catch (error) {
446
+ throw toApiError(`Failed to get Branch [${branchId}] by id`, error);
447
+ }
448
+ }
449
+ async getBranchByName(workspaceId, branchName) {
450
+ try {
451
+ return await this.makeGetRequest(`${this.baseApiUrl}/branch/${workspaceId}/${branchName}`);
452
+ }
453
+ catch (error) {
454
+ throw toApiError(`Failed to get Branch [${branchName}] by name`, error);
455
+ }
456
+ }
457
+ async getBranches(workspaceId, limit, statusFilter) {
458
+ try {
459
+ const branchQueryString = query_string_1.default.stringify({
460
+ workspace_id: workspaceId,
461
+ limit,
462
+ status: statusFilter,
463
+ });
464
+ return await this.makeGetRequest(`${this.baseApiUrl}/branch?${branchQueryString}`).then((result) => { var _a; return (_a = result.branches) !== null && _a !== void 0 ? _a : []; });
465
+ }
466
+ catch (error) {
467
+ throw toApiError(`Failed to get Branches`, error);
468
+ }
469
+ }
470
+ async getFileUploadUrl(fileId) {
471
+ try {
472
+ return await this.makeGetRequest(`${this.baseApiUrl}/files/fileUpload/url/${fileId}`);
473
+ }
474
+ catch (error) {
475
+ throw toApiError(`Failed to get File Upload URL`, error);
476
+ }
477
+ }
478
+ async queryDataTables(workspaceId, limit, cursor) {
479
+ try {
480
+ const dataTablesQueryString = query_string_1.default.stringify({
481
+ workspace_id: workspaceId,
482
+ limit,
483
+ cursor,
484
+ });
485
+ return await this.makeGetRequest(`${this.baseApiUrl}/dataTables?${dataTablesQueryString}`).then((result) => result);
486
+ }
487
+ catch (error) {
488
+ throw toApiError(`Failed to retrieve DataTables`, error);
489
+ }
490
+ }
491
+ async getDataTable(dataTableId) {
492
+ try {
493
+ return await this.makeGetRequest(`${this.baseApiUrl}/dataTables/${dataTableId}`);
494
+ }
495
+ catch (error) {
496
+ throw toApiError(`Failed to get DataTable`, error);
497
+ }
498
+ }
499
+ async createDataTable(dataTableCreateRequest) {
500
+ try {
501
+ return await this.makePostRequest(`${this.baseApiUrl}/dataTables`, dataTableCreateRequest);
502
+ }
503
+ catch (error) {
504
+ throw toApiError(`Failed to create DataTable`, error);
505
+ }
506
+ }
507
+ async queryScenarios(dataTableId, limit, cursor) {
508
+ try {
509
+ const scenariosQueryString = query_string_1.default.stringify({
510
+ data_table_id: dataTableId,
511
+ limit,
512
+ cursor,
513
+ });
514
+ return await this.makeGetRequest(`${this.baseApiUrl}/dataTables/scenarios?${scenariosQueryString}`);
515
+ }
516
+ catch (error) {
517
+ throw toApiError(`Failed to get Scenarios`, error);
518
+ }
519
+ }
520
+ async getScenario(scenarioId) {
521
+ try {
522
+ return await this.makeGetRequest(`${this.baseApiUrl}/dataTables/scenarios/${scenarioId}`);
523
+ }
524
+ catch (error) {
525
+ throw toApiError(`Failed to get Scenario`, error);
526
+ }
527
+ }
528
+ async updateDataTable(tableId, updateRequest) {
529
+ try {
530
+ return await this.makePatchRequest(`${this.baseApiUrl}/variables/tables/${tableId}`, updateRequest);
531
+ }
532
+ catch (error) {
533
+ throw toApiError(`Failed to create DataTable`, error);
534
+ }
535
+ }
536
+ async getSessionEmails(sessionId) {
537
+ try {
538
+ const emailQueryString = query_string_1.default.stringify({
539
+ context_id: sessionId === null || sessionId === void 0 ? void 0 : sessionId.slice(0, 8),
540
+ });
541
+ return await this.makeGetRequest(`${this.baseApiUrl}/execution/inputs?${emailQueryString}`);
542
+ }
543
+ catch (error) {
544
+ throw toApiError(`Failed to get emails for session ID ${sessionId} with error`, error);
545
+ }
546
+ }
547
+ async getEmailsToPermanentAddress(address, earliestReceivedTime) {
548
+ try {
549
+ const emailQueryString = query_string_1.default.stringify({
550
+ email_address: address,
551
+ earliest_received_time: earliestReceivedTime,
552
+ });
553
+ return await this.makeGetRequest(`${this.baseApiUrl}/execution/inputs?${emailQueryString}`);
554
+ }
555
+ catch (error) {
556
+ throw toApiError(`Failed to get emails for permanent address ${address} with error`, error);
557
+ }
558
+ }
559
+ async createMailboxAddress(workspaceId, sessionId) {
560
+ const contextId = sessionId === null || sessionId === void 0 ? void 0 : sessionId.slice(0, 8);
561
+ try {
562
+ const body = {
563
+ context_id: contextId,
564
+ workspace_id: workspaceId,
565
+ };
566
+ return await this.makePostRequestWithRetries(`${this.baseApiUrl}/mailbox/address`, body);
567
+ }
568
+ catch (error) {
569
+ throw toApiError('Failed to create mailbox email address', error);
570
+ }
571
+ }
572
+ async getMailboxAddress(emailAddressOrId) {
573
+ try {
574
+ return await this.makeGetRequest(`${this.baseApiUrl}/mailbox/address/${emailAddressOrId}`);
575
+ }
576
+ catch (error) {
577
+ throw toApiError(`Failed to get mailbox ${emailAddressOrId} with error`, error);
578
+ }
579
+ }
580
+ async updateMailboxStatus(mailboxId, status) {
581
+ try {
582
+ const body = { status };
583
+ return await this.makePatchRequest(`${this.baseApiUrl}/mailbox/address/${mailboxId}/status`, body);
584
+ }
585
+ catch (error) {
586
+ throw toApiError(`Failed to update mailbox ${mailboxId} with error`, error);
587
+ }
588
+ }
589
+ async generateSteps(workspaceId, intent, context) {
590
+ const body = {
591
+ intent,
592
+ context,
593
+ };
594
+ try {
595
+ return await this.makePostRequestWithRetries(`${this.baseApiUrl}/generate/steps?workspaceId=${workspaceId}`, body, GENAI_RETRY_OPTIONS);
596
+ }
597
+ catch (error) {
598
+ throw toApiError('Failed to generate steps', error);
599
+ }
600
+ }
601
+ async evaluateAiAssertion(workspaceId, testRunId, screenshot, userPrompt, metaPrompt, criteria, test, variables) {
602
+ try {
603
+ const body = {
604
+ test_run_id: testRunId,
605
+ assertion_prompt: userPrompt,
606
+ assertion_criteria: criteria,
607
+ screenshot: Buffer.from(screenshot).toString('base64'),
608
+ test_invariant_id: test === null || test === void 0 ? void 0 : test.invariant_id,
609
+ test_type: test === null || test === void 0 ? void 0 : test.test_type,
610
+ variables,
611
+ };
612
+ if (metaPrompt !== undefined) {
613
+ body.override = {
614
+ meta_prompt: metaPrompt,
615
+ };
616
+ }
617
+ return await this.makePostRequestWithRetries(`${this.baseApiUrl}/analysis/${workspaceId}/assertion/evaluate`, body, GENAI_RETRY_OPTIONS);
618
+ }
619
+ catch (error) {
620
+ throw toApiError('Failed to evaluate the AI prompt assertion', error);
621
+ }
622
+ }
623
+ async createBranch(workspaceId, branchName) {
624
+ try {
625
+ const body = {
626
+ workspace_id: workspaceId,
627
+ name: branchName,
628
+ };
629
+ return await this.makePostRequest(`${this.baseApiUrl}/branch`, body);
630
+ }
631
+ catch (error) {
632
+ throw toApiError(`Failed to create Branch [${branchName}]`, error);
633
+ }
634
+ }
635
+ async mergeBranch(workspaceId, fromBranchName, toBranchName) {
636
+ try {
637
+ const queryStringArgs = {
638
+ from: fromBranchName,
639
+ to: toBranchName,
640
+ };
641
+ const mergeQueryString = query_string_1.default.stringify(queryStringArgs);
642
+ const url = `${this.baseApiUrl}/branch/${workspaceId}/merge?${mergeQueryString}`;
643
+ return await this.makePostRequest(url, {});
644
+ }
645
+ catch (error) {
646
+ throw toApiError(`Failed to merge from branch [${fromBranchName}] to branch [${toBranchName}]`, error);
647
+ }
648
+ }
649
+ async createExportRequest(journeyRunId, targetContent) {
650
+ try {
651
+ const body = {
652
+ target_content: targetContent,
653
+ target_entity_id: journeyRunId,
654
+ };
655
+ return await this.makePostRequest(`${this.baseApiUrl}/exports/journeyRuns/${journeyRunId}`, body);
656
+ }
657
+ catch (error) {
658
+ throw toApiError(`Failed to create export`, error);
659
+ }
660
+ }
661
+ async postDeploymentEvent(options) {
662
+ try {
663
+ const requestBody = this.buildDeploymentRequestBody(options);
664
+ return await this.makePostRequestWithRetries(`${this.baseApiUrl}/events/deployment/`, requestBody);
665
+ }
666
+ catch (error) {
667
+ throw toApiError(`Failed to create deployment`, error);
668
+ }
669
+ }
670
+ buildDeploymentRequestBody(options) {
671
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
672
+ const requestBody = { properties: {} };
673
+ if (options.environmentId) {
674
+ requestBody.environment_id = options.environmentId;
675
+ }
676
+ if (options.applicationId) {
677
+ requestBody.application_id = options.applicationId;
678
+ }
679
+ requestBody.revision = (_a = options.sourceControlMetadata) === null || _a === void 0 ? void 0 : _a.revision;
680
+ if (options.mablBranch) {
681
+ requestBody.source_control_tag = options.mablBranch;
682
+ }
683
+ requestBody.properties.repository_branch_name =
684
+ (_b = options.sourceControlMetadata) === null || _b === void 0 ? void 0 : _b.branchName;
685
+ requestBody.properties.repository_tag_name =
686
+ (_c = options.sourceControlMetadata) === null || _c === void 0 ? void 0 : _c.branchName;
687
+ requestBody.properties.repository_url =
688
+ (_d = options.sourceControlMetadata) === null || _d === void 0 ? void 0 : _d.repoUrl;
689
+ requestBody.properties.repository_name =
690
+ (_e = options.sourceControlMetadata) === null || _e === void 0 ? void 0 : _e.repoName;
691
+ requestBody.properties.build_info_url =
692
+ (_f = options.sourceControlMetadata) === null || _f === void 0 ? void 0 : _f.buildInfoUrl;
693
+ requestBody.properties.deployment_origin = ((_g = options.sourceControlMetadata) === null || _g === void 0 ? void 0 : _g.integrationType)
694
+ ?
695
+ `mabl-${options.sourceControlMetadata.integrationType}`
696
+ : undefined;
697
+ requestBody.properties.build_id = (_h = options.sourceControlMetadata) === null || _h === void 0 ? void 0 : _h.buildId;
698
+ const planOverrides = {};
699
+ if ((_j = options.browserTypes) === null || _j === void 0 ? void 0 : _j.length) {
700
+ planOverrides.browser_types = options.browserTypes;
701
+ }
702
+ if ((_k = options.labels) === null || _k === void 0 ? void 0 : _k.length) {
703
+ requestBody.plan_labels = options.labels;
704
+ }
705
+ if (options.uri) {
706
+ planOverrides.uri = options.uri;
707
+ }
708
+ if (options.appUrl) {
709
+ planOverrides.web_url = options.appUrl;
710
+ }
711
+ if (options.apiUrl) {
712
+ planOverrides.api_url = options.apiUrl;
713
+ }
714
+ if (options.deploymentIds) {
715
+ planOverrides.deployment_ids = options.deploymentIds;
716
+ }
717
+ if (options.androidMobileAppFileId) {
718
+ planOverrides.mobile_app_file_ids = {
719
+ ...planOverrides.mobile_app_file_ids,
720
+ [mablApi_1.MobilePlatformEnum.Android]: options.androidMobileAppFileId,
721
+ };
722
+ }
723
+ if (options.iOSMobileAppFileId) {
724
+ planOverrides.mobile_app_file_ids = {
725
+ ...planOverrides.mobile_app_file_ids,
726
+ [mablApi_1.MobilePlatformEnum.Ios]: options.iOSMobileAppFileId,
727
+ };
728
+ }
729
+ if ((_l = options.httpHeaders) === null || _l === void 0 ? void 0 : _l.length) {
730
+ planOverrides.http_headers = options.httpHeaders.map((header) => {
731
+ const parts = header.split(':', 2);
732
+ return {
733
+ name: parts[0],
734
+ value: parts[1],
735
+ log_header_value: false,
736
+ };
737
+ });
738
+ planOverrides.http_headers_required = true;
739
+ }
740
+ requestBody.plan_overrides = planOverrides;
741
+ const actions = {};
742
+ if (options.rebaselineImages) {
743
+ actions.rebaseline_images = options.rebaselineImages;
744
+ }
745
+ if (options.setStaticBaseline) {
746
+ actions.set_static_baseline = options.setStaticBaseline;
747
+ }
748
+ if (options.snapshotFromBranch) {
749
+ actions.snapshot = { from: options.snapshotFromBranch };
750
+ }
751
+ if (options.targetRuntimeVersion) {
752
+ requestBody.target_runtime_version = options.targetRuntimeVersion;
753
+ }
754
+ requestBody.actions = actions;
755
+ return requestBody;
756
+ }
757
+ async getTestRunsForPlan(planRunId) {
758
+ try {
759
+ return this.makeGetRequest(`${this.baseApiUrl}/journeyRuns/planRun/${planRunId}`);
760
+ }
761
+ catch (error) {
762
+ throw toApiError(`Failed to retrieve tests for plan`, error);
763
+ }
764
+ }
765
+ async postPlanRun(organizationId, testId, branchName, browserTypes, appUrl, apiUrl, deploymentId, credentialsId, deploymentIds, basicAuthCredentialsId, localizationOptions) {
766
+ try {
767
+ const requestBody = this.buildAdHocPlanRunRequestBody(organizationId, testId, browserTypes, branchName, appUrl, apiUrl, deploymentId, credentialsId, deploymentIds, basicAuthCredentialsId, localizationOptions);
768
+ return await this.makePostRequest(`${this.baseApiUrl}/planRuns/`, requestBody);
769
+ }
770
+ catch (error) {
771
+ throw toApiError(`Failed to create planRun`, error);
772
+ }
773
+ }
774
+ buildAdHocPlanRunRequestBody(organizationId, testId, browserTypes, branchName, appUrl, apiUrl, deploymentId, credentialsId, deploymentIds, basicAuthCredentialsId, localizationOptions) {
775
+ const requestBody = {
776
+ ad_hoc_run_info: {
777
+ is_ad_hoc_run: true,
778
+ },
779
+ };
780
+ const planOverrides = {};
781
+ if (organizationId) {
782
+ planOverrides.organization_id = organizationId;
783
+ }
784
+ if (deploymentId) {
785
+ planOverrides.deployment_id = deploymentId;
786
+ }
787
+ if (browserTypes === null || browserTypes === void 0 ? void 0 : browserTypes.length) {
788
+ planOverrides.browser_types = browserTypes;
789
+ }
790
+ if (appUrl) {
791
+ planOverrides.web_url = appUrl;
792
+ }
793
+ if (apiUrl) {
794
+ planOverrides.api_url = apiUrl;
795
+ }
796
+ if (credentialsId) {
797
+ planOverrides.credentials_id = credentialsId;
798
+ planOverrides.credentials_required = true;
799
+ }
800
+ if (basicAuthCredentialsId) {
801
+ planOverrides.http_auth_credentials_id = basicAuthCredentialsId;
802
+ planOverrides.http_auth_credentials_required = true;
803
+ }
804
+ if (localizationOptions) {
805
+ planOverrides.localization_options = [localizationOptions];
806
+ }
807
+ if (testId) {
808
+ planOverrides.journeys = [{ journey_id: testId }];
809
+ planOverrides.execution_stages = [
810
+ {
811
+ concurrency: mablApi_1.ExecutionStage.ConcurrencyEnum.Parallel,
812
+ journeys: [
813
+ {
814
+ journey_id: testId,
815
+ },
816
+ ],
817
+ },
818
+ ];
819
+ }
820
+ if (deploymentIds) {
821
+ planOverrides.deployment_ids = deploymentIds;
822
+ }
823
+ requestBody.plan_overrides = planOverrides;
824
+ if (branchName) {
825
+ requestBody.source_control_tag_override = branchName;
826
+ }
827
+ return requestBody;
828
+ }
829
+ async createFlow(prototype) {
830
+ try {
831
+ return await this.makePostRequest(`${this.baseApiUrl}/flows`, prototype);
832
+ }
833
+ catch (error) {
834
+ throw toApiError(`Failed to create flow`, error);
835
+ }
836
+ }
837
+ async createJourney(prototype) {
838
+ try {
839
+ return await this.makePostRequest(`${this.baseApiUrl}/test/journeys`, prototype);
840
+ }
841
+ catch (error) {
842
+ throw toApiError(`Failed to create journey`, error);
843
+ }
844
+ }
845
+ async getJourneyRun(journeyRunId) {
846
+ try {
847
+ return await this.makeGetRequestWithETag(`${this.baseApiUrl}/journeyRuns/${journeyRunId}`);
848
+ }
849
+ catch (error) {
850
+ throw toApiError(`Failed to get journey run info`, error);
851
+ }
852
+ }
853
+ async updateJourneyRun(journeyRunId, journeyRunUpdate, ifMatch, retry) {
854
+ try {
855
+ const response = retry
856
+ ? await this.makePatchRequestWithRetries(`${this.baseApiUrl}/journeyRuns/${journeyRunId}`, journeyRunUpdate, ifMatch)
857
+ : await this.makePatchRequest(`${this.baseApiUrl}/journeyRuns/${journeyRunId}`, journeyRunUpdate, ifMatch);
858
+ return response;
859
+ }
860
+ catch (error) {
861
+ throw toApiError(`Failed to update journey run ${journeyRunId}`, error);
862
+ }
863
+ }
864
+ async failJourneyRun(journeyRunId, cause) {
865
+ try {
866
+ const response = await this.makePatchRequest(`${this.baseApiUrl}/journeyRuns/${journeyRunId}`, {
867
+ functionally_completed: false,
868
+ status: mablApi_1.TestRun.StatusEnum.Failed,
869
+ status_cause: cause,
870
+ });
871
+ return response;
872
+ }
873
+ catch (error) {
874
+ throw toApiError(`Failed to update journey run ${journeyRunId}`, error);
875
+ }
876
+ }
877
+ async terminateJourneyRun(journeyRunId, terminationReason) {
878
+ const terminateParams = query_string_1.default.stringify({
879
+ terminationReason: terminationReason.toString(),
880
+ });
881
+ try {
882
+ const response = await this.makePostRequestWithRetries(`${this.baseApiUrl}/journeyRun/${journeyRunId}/terminate?${terminateParams}`);
883
+ return response;
884
+ }
885
+ catch (error) {
886
+ throw toApiError(`Failed to terminate journey run ${journeyRunId}`, error);
887
+ }
888
+ }
889
+ async copyWorkspace(sourceWorkspaceId, destinationWorkspaceId, includeDefaults, includedTests, excludedTests) {
890
+ const copyParams = query_string_1.default.stringify({
891
+ source_workspace_id: sourceWorkspaceId,
892
+ destination_workspace_id: destinationWorkspaceId,
893
+ include_defaults: includeDefaults,
894
+ included_tests: includedTests,
895
+ excluded_tests: excludedTests,
896
+ });
897
+ return this.makePostRequest(`${this.baseApiUrl}/copy/organizations?${copyParams}`, {}, {
898
+ timeout: 3600000,
899
+ });
900
+ }
901
+ async getEnabledAccountFeaturesByWorkspaceId(workspaceId) {
902
+ var _a;
903
+ try {
904
+ const account = await this.getAccountByWorkspaceId(workspaceId);
905
+ return new featureSet_1.FeatureSet(new Set((_a = account.effective_features) !== null && _a !== void 0 ? _a : []));
906
+ }
907
+ catch (error) {
908
+ throw toApiError(`Failed to get effective account features for workspace ${workspaceId}`, error);
909
+ }
910
+ }
911
+ async getEnabledLabsFeaturesForWorkspace(workspaceId) {
912
+ var _a;
913
+ try {
914
+ const workspace = await this.getWorkspace(workspaceId);
915
+ return new featureSet_1.FeatureSet(new Set((_a = workspace.labs_features) !== null && _a !== void 0 ? _a : []));
916
+ }
917
+ catch (error) {
918
+ throw toApiError(`Failed to get labs features for workspace ${workspaceId}`, error);
919
+ }
920
+ }
921
+ async getUsers(workspaceId, limit) {
922
+ try {
923
+ const userQueryString = query_string_1.default.stringify({
924
+ organization_id: workspaceId,
925
+ limit,
926
+ });
927
+ const users = await this.makeGetRequest(`${this.baseApiUrl}/users/?${userQueryString}`).then((result) => { var _a; return (_a = result.users) !== null && _a !== void 0 ? _a : []; });
928
+ sortTemporallyAscending(users);
929
+ return users;
930
+ }
931
+ catch (error) {
932
+ throw toApiError(`Failed to get users`, error);
933
+ }
934
+ }
935
+ async getStepIdsInJourneyByFlow(journeyInvariantId, flowIds) {
936
+ try {
937
+ const stepIdsQueryString = query_string_1.default.stringify({
938
+ flow_variant_ids: [flowIds],
939
+ });
940
+ return await this.makeGetRequest(`${this.baseApiUrl}/test/journey/${journeyInvariantId}/stepIdsByFlow?${stepIdsQueryString}`).then((result) => result !== null && result !== void 0 ? result : []);
941
+ }
942
+ catch (error) {
943
+ throw toApiError(`Failed to get step ids in journey by flow`, error);
944
+ }
945
+ }
946
+ async recordTimeSeriesMetricMeasurement(type, value, options) {
947
+ try {
948
+ return this.makePostRequest(`${this.baseApiUrl}/metrics/timeSeries`, createTimeSeriesMetricMeasurement(type, value, options));
949
+ }
950
+ catch (error) {
951
+ throw toApiError('Failed to record time series metric measurement', error);
952
+ }
953
+ }
954
+ async recordWorkspaceTimeSeriesMetricMeasurement(type, value, workspaceId, options) {
955
+ const labels = { ...options === null || options === void 0 ? void 0 : options.labels, workspaceId };
956
+ return this.recordTimeSeriesMetricMeasurement(type, value, {
957
+ ...options,
958
+ labels,
959
+ });
960
+ }
961
+ async getMobileAppFile(id, sign = false) {
962
+ let url = `${this.baseApiUrl}/mobile/apps/files/${id}`;
963
+ if (sign) {
964
+ url += '?sign=true';
965
+ }
966
+ try {
967
+ return await this.makeGetRequest(url);
968
+ }
969
+ catch (error) {
970
+ throw toApiError(`Failed to get mobile app file ${id}`, error);
971
+ }
972
+ }
973
+ async getMobileAppFiles(workspaceId, limit) {
974
+ try {
975
+ const query = query_string_1.default.stringify({
976
+ workspace_id: workspaceId,
977
+ limit,
978
+ });
979
+ const mobileAppFiles = await this.makePostRequest(`${this.baseApiUrl}/mobile/apps/files/queryFiles?${query}`, {
980
+ filter_conditions: [],
981
+ sort_columns: [
982
+ {
983
+ column_name: 'created_time',
984
+ sort_direction: 'DESC',
985
+ },
986
+ ],
987
+ }).then((result) => { var _a; return (_a = result.mobile_app_files) !== null && _a !== void 0 ? _a : []; });
988
+ sortTemporallyDescending(mobileAppFiles);
989
+ return mobileAppFiles;
990
+ }
991
+ catch (error) {
992
+ throw toApiError(`Failed to get mobile app files`, error);
993
+ }
994
+ }
995
+ async deleteMobileAppFile(id) {
996
+ try {
997
+ const response = await this.makeDeleteRequest(`${this.baseApiUrl}/mobile/apps/files/${id}`);
998
+ return response;
999
+ }
1000
+ catch (error) {
1001
+ throw toApiError(`Failed to delete mobile app file ${id}`, error);
1002
+ }
1003
+ }
1004
+ async createMobileTrainingSession(prototype) {
1005
+ try {
1006
+ return await this.makePostRequest(`${this.baseApiUrl}/mobile/training/sessions`, prototype);
1007
+ }
1008
+ catch (error) {
1009
+ throw toApiError(`Failed to create mobile training session`, error);
1010
+ }
1011
+ }
1012
+ async getMobileTrainingSession(id) {
1013
+ try {
1014
+ return await this.makeGetRequest(`${this.baseApiUrl}/mobile/training/session/${id}`);
1015
+ }
1016
+ catch (error) {
1017
+ throw toApiError(`Failed to get mobile training session ${id}`, error);
1018
+ }
1019
+ }
1020
+ async runDatabaseQuery(queryExecution) {
1021
+ try {
1022
+ return await this.makePostRequest(`${this.baseApiUrl}/database/queryExecution`, queryExecution);
1023
+ }
1024
+ catch (error) {
1025
+ throw toApiError(`Failed to schedule database query execution`, error);
1026
+ }
1027
+ }
1028
+ async getDatabaseQueryExecution(executionId) {
1029
+ try {
1030
+ return await this.makeGetRequest(`${this.baseApiUrl}/database/queryExecution/${executionId}`);
1031
+ }
1032
+ catch (error) {
1033
+ throw toApiError(`Failed to schedule database query execution`, error);
1034
+ }
1035
+ }
1036
+ async terminateMobileTrainingSession(id, reason) {
1037
+ try {
1038
+ return await this.makePostRequest(`${this.baseApiUrl}/mobile/training/session/${id}/terminate`, { termination_reason: reason });
1039
+ }
1040
+ catch (error) {
1041
+ throw toApiError(`Failed to terminate mobile training session ${id}`, error);
1042
+ }
1043
+ }
1044
+ }
1045
+ exports.MablApiClient = MablApiClient;
1046
+ function sortTemporallyAscending(entities) {
1047
+ entities.sort((a, b) => a.created_time - b.created_time);
1048
+ }
1049
+ function sortTemporallyDescending(entities) {
1050
+ entities.sort((a, b) => b.created_time - a.created_time);
1051
+ }
1052
+ function toApiError(summary, cause) {
1053
+ const errorResponse = cause === null || cause === void 0 ? void 0 : cause.response;
1054
+ const code = errorResponse === null || errorResponse === void 0 ? void 0 : errorResponse.status;
1055
+ const mablError = errorResponse === null || errorResponse === void 0 ? void 0 : errorResponse.data;
1056
+ const message = `${summary}: ${mablError
1057
+ ? `${mablError.code}: ${mablError.message} (${mablError.id})`
1058
+ : cause.toString()}`;
1059
+ return new ApiError_1.ApiError(message, code, cause);
1060
+ }
1061
+ function createTimeSeriesMetricMeasurement(type, numberValue, options) {
1062
+ return {
1063
+ labels: options === null || options === void 0 ? void 0 : options.labels,
1064
+ event_time: options === null || options === void 0 ? void 0 : options.event_time,
1065
+ type,
1066
+ value: Number.isInteger(numberValue)
1067
+ ? { int64_value: numberValue }
1068
+ : { double_value: numberValue },
1069
+ };
1070
+ }