@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,27 @@
1
+ /*!
2
+ * mime-db
3
+ * Copyright(c) 2014 Jonathan Ong
4
+ * MIT Licensed
5
+ */
6
+
7
+ /*!
8
+ * mime-types
9
+ * Copyright(c) 2014 Jonathan Ong
10
+ * Copyright(c) 2015 Douglas Christopher Wilson
11
+ * MIT Licensed
12
+ */
13
+
14
+ /*! *****************************************************************************
15
+ Copyright (c) Microsoft Corporation.
16
+
17
+ Permission to use, copy, modify, and/or distribute this software for any
18
+ purpose with or without fee is hereby granted.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
21
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
22
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
23
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
24
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
25
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
26
+ PERFORMANCE OF THIS SOFTWARE.
27
+ ***************************************************************************** */
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const storage_1 = require("@google-cloud/storage");
4
+ const IdentifierUtil_1 = require("./IdentifierUtil");
5
+ const loggingProvider_1 = require("../providers/logging/loggingProvider");
6
+ const MAX_PUT_ATTEMPTS = 3;
7
+ const AUTO_COMPRESS_MIME_TYPES = new Set([
8
+ 'application/json',
9
+ 'text/plain',
10
+ ]);
11
+ class CloudStorageWriter {
12
+ constructor(projectId, workspaceId) {
13
+ this.bucket = new storage_1.Storage().bucket(`${projectId}-workspace-${(0, IdentifierUtil_1.toCloudSafeId)(workspaceId)}`);
14
+ }
15
+ bucketName() {
16
+ return this.bucket.name;
17
+ }
18
+ async write(path, contentType, data) {
19
+ let attempt = 0;
20
+ while (attempt++ < MAX_PUT_ATTEMPTS) {
21
+ try {
22
+ return await this.writeOnce(path, contentType, data);
23
+ }
24
+ catch (error) {
25
+ loggingProvider_1.logger.info(`Error writing file to GCS at ${path} (attempt ${attempt} of ${MAX_PUT_ATTEMPTS})`, error);
26
+ if (attempt === MAX_PUT_ATTEMPTS) {
27
+ throw error;
28
+ }
29
+ }
30
+ }
31
+ }
32
+ writeOnce(path, contentType, data) {
33
+ return this.bucket.file(path).save(data, {
34
+ contentType,
35
+ metadata: {
36
+ 'Content-Type': getNowIsoTimestamp(),
37
+ },
38
+ gzip: AUTO_COMPRESS_MIME_TYPES.has(contentType.toLowerCase()),
39
+ });
40
+ }
41
+ }
42
+ exports.default = CloudStorageWriter;
43
+ function getNowIsoTimestamp() {
44
+ return new Date().toISOString();
45
+ }
@@ -0,0 +1,180 @@
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.FileCache = void 0;
7
+ const fs_1 = require("fs");
8
+ const promises_1 = require("fs/promises");
9
+ const node_path_1 = require("node:path");
10
+ const cachedir_1 = __importDefault(require("cachedir"));
11
+ const upload_1 = require("../upload");
12
+ const env_1 = require("../env/env");
13
+ const loggingProvider_1 = require("../providers/logging/loggingProvider");
14
+ const DEFAULT_READ_BUFFER_SIZE_BYTES = 8 * 1024 * 1024;
15
+ class File {
16
+ constructor(directory, name) {
17
+ this.path = (0, node_path_1.resolve)((0, node_path_1.join)(directory, name));
18
+ this.stats = (0, fs_1.statSync)(this.path);
19
+ }
20
+ get createdTimeMillis() {
21
+ return this.stats.ctimeMs;
22
+ }
23
+ delete() {
24
+ (0, fs_1.rmSync)(this.path, { force: true, recursive: this.isDirectory });
25
+ }
26
+ get isDirectory() {
27
+ return this.stats.isDirectory();
28
+ }
29
+ }
30
+ class FileCache {
31
+ constructor({ cacheName, maximumCachedFiles, maximumCachedFileAgeMinutes, readBufferSizeBytes, }) {
32
+ this.cacheName = cacheName;
33
+ this.cacheDirectoryPath = (0, node_path_1.resolve)((0, node_path_1.join)((0, cachedir_1.default)(env_1.CONF_FILE_PROJECT_NAME), cacheName));
34
+ this.maximumCachedFiles = maximumCachedFiles;
35
+ this.maximumCachedFileAgeMinutes = maximumCachedFileAgeMinutes;
36
+ this.readBufferSizeBytes =
37
+ readBufferSizeBytes !== null && readBufferSizeBytes !== void 0 ? readBufferSizeBytes : DEFAULT_READ_BUFFER_SIZE_BYTES;
38
+ }
39
+ async performCacheCleanup() {
40
+ if (!(await this.directoryExists(this.cacheDirectoryPath))) {
41
+ return;
42
+ }
43
+ const nowMillis = Date.now();
44
+ try {
45
+ const files = (await (0, promises_1.readdir)(this.cacheDirectoryPath))
46
+ .map((name) => new File(this.cacheDirectoryPath, name))
47
+ .filter((file) => {
48
+ if (this.maximumCachedFileAgeMinutes &&
49
+ (nowMillis - file.createdTimeMillis) / 1000 / 60 >
50
+ this.maximumCachedFileAgeMinutes) {
51
+ loggingProvider_1.logger.info(`Deleting expired cache ${file.isDirectory ? 'directory' : 'file'} ${file.path}`);
52
+ file.delete();
53
+ return false;
54
+ }
55
+ return true;
56
+ })
57
+ .sort((left, right) => right.createdTimeMillis - left.createdTimeMillis);
58
+ if (this.maximumCachedFiles && files.length > this.maximumCachedFiles) {
59
+ loggingProvider_1.logger.info(`Deleting the oldest ${files.length - this.maximumCachedFiles} file(s) in ${this.cacheName} cache`);
60
+ files.slice(this.maximumCachedFiles).forEach((file) => {
61
+ loggingProvider_1.logger.info(`Deleting cache ${file.isDirectory ? 'directory' : 'file'} ${file.path}`);
62
+ file.delete();
63
+ });
64
+ }
65
+ }
66
+ catch (error) {
67
+ loggingProvider_1.logger.error(`Error performing cache cleanup on ${this.cacheDirectoryPath}`, error);
68
+ }
69
+ }
70
+ async getOrCreateFile(name, getReader, metadata) {
71
+ const path = this.getCacheFilePath(name);
72
+ await this.performCacheCleanup();
73
+ if (await this.cachedFileIsValid(path, metadata)) {
74
+ return path;
75
+ }
76
+ const { crc32cHex: writtenCrc32cHex, sizeBytes: writtenSizeBytes } = await this.write(await getReader(), path, metadata === null || metadata === void 0 ? void 0 : metadata.sizeBytes);
77
+ if (metadata) {
78
+ if (writtenSizeBytes !== metadata.sizeBytes) {
79
+ throw new Error(`Expected ${metadata.sizeBytes}b but received ${writtenSizeBytes}b`);
80
+ }
81
+ if (writtenCrc32cHex !== metadata.crc32cHex) {
82
+ throw new Error(`Expected checksum ${metadata.crc32cHex} but computed ${writtenCrc32cHex}`);
83
+ }
84
+ }
85
+ if (!(await this.cachedFileIsValid(path, metadata))) {
86
+ throw new Error(`Downloaded cache file ${path} failed verification`);
87
+ }
88
+ return path;
89
+ }
90
+ async directoryExists(path) {
91
+ try {
92
+ return (await (0, promises_1.stat)(path)).isDirectory();
93
+ }
94
+ catch (error) {
95
+ return false;
96
+ }
97
+ }
98
+ async fileExists(path) {
99
+ try {
100
+ return (await (0, promises_1.stat)(path)).isFile();
101
+ }
102
+ catch (error) {
103
+ return false;
104
+ }
105
+ }
106
+ async cachedFileIsValid(path, metadata) {
107
+ if (!(await this.fileExists(path))) {
108
+ return false;
109
+ }
110
+ if (metadata) {
111
+ loggingProvider_1.logger.info(`Verifying integrity of cache file ${path}`);
112
+ const actualSizeBytes = (await (0, promises_1.stat)(path)).size;
113
+ if (actualSizeBytes !== metadata.sizeBytes) {
114
+ loggingProvider_1.logger.warn(`Expected cache file at ${path} to have size [${metadata.sizeBytes}b] but was [${actualSizeBytes}b]`);
115
+ return false;
116
+ }
117
+ const actualCrc32cHex = await this.computeCrc32cHex(path);
118
+ if (actualCrc32cHex !== metadata.crc32cHex) {
119
+ loggingProvider_1.logger.warn(`Expected cache file at ${path} to have checksum [${metadata.crc32cHex}] but was [${actualCrc32cHex}]}`);
120
+ return false;
121
+ }
122
+ }
123
+ return true;
124
+ }
125
+ getCacheFilePath(relativePath) {
126
+ return (0, node_path_1.resolve)((0, node_path_1.join)(this.cacheDirectoryPath, relativePath));
127
+ }
128
+ async write(reader, destination, expectedSizeBytes) {
129
+ const destinationDirectory = (0, node_path_1.dirname)(destination);
130
+ if (!(await this.directoryExists(destinationDirectory))) {
131
+ await (0, promises_1.mkdir)(destinationDirectory, { recursive: true });
132
+ }
133
+ const fd = await (0, promises_1.open)(destination, 'w');
134
+ const writeStream = fd.createWriteStream({ autoClose: true });
135
+ const metadata = await new Promise((resolve, reject) => {
136
+ const crc32c = new upload_1.Crc32cChecksum();
137
+ let sizeBytes = 0;
138
+ let percentageComplete = 0;
139
+ writeStream.on('error', (error) => reject(error));
140
+ writeStream.on('close', () => resolve({ crc32cHex: crc32c.digestHex(), sizeBytes }));
141
+ reader.on('error', (error) => reject(error));
142
+ reader.on('end', () => writeStream.close());
143
+ reader.on('data', (chunk) => {
144
+ crc32c.update(chunk);
145
+ sizeBytes += chunk.byteLength;
146
+ if (expectedSizeBytes) {
147
+ const newPercentageComplete = Math.round((sizeBytes / expectedSizeBytes) * 100);
148
+ if (newPercentageComplete % 10 === 0 &&
149
+ newPercentageComplete > percentageComplete) {
150
+ percentageComplete = newPercentageComplete;
151
+ loggingProvider_1.logger.info(`Downloaded ${sizeBytes} of ${expectedSizeBytes} bytes (${percentageComplete}% complete)`);
152
+ }
153
+ }
154
+ });
155
+ reader.pipe(writeStream);
156
+ });
157
+ await this.performCacheCleanup();
158
+ return metadata;
159
+ }
160
+ async computeCrc32cHex(path) {
161
+ const fd = await (0, promises_1.open)(path, 'r');
162
+ const crc32c = new upload_1.Crc32cChecksum();
163
+ let totalBytesRead = 0;
164
+ while (true) {
165
+ const { buffer, bytesRead: chunkSizeBytes } = await fd.read({
166
+ buffer: Buffer.alloc(this.readBufferSizeBytes),
167
+ length: this.readBufferSizeBytes,
168
+ position: totalBytesRead,
169
+ });
170
+ if (chunkSizeBytes === 0) {
171
+ break;
172
+ }
173
+ totalBytesRead += chunkSizeBytes;
174
+ const chunk = buffer.subarray(0, chunkSizeBytes);
175
+ crc32c.update(chunk);
176
+ }
177
+ return crc32c.digestHex();
178
+ }
179
+ }
180
+ exports.FileCache = FileCache;
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toCloudSafeId = void 0;
4
+ const legacyUuidPattern = /^[a-fA-F0-9-]{36}$/;
5
+ const untypedUidPattern = /^[a-zA-Z0-9_-]+$/;
6
+ const typedUidPattern = /^(?<id>[a-zA-Z0-9_-]{22})-(?<type>[a-z]+)$/;
7
+ const idTypes = {
8
+ uuid: 1,
9
+ untypedUid: 2,
10
+ typedUid: 3,
11
+ };
12
+ function isLegacyUuid(id) {
13
+ return !!id.match(legacyUuidPattern);
14
+ }
15
+ function isUntypedUid(id) {
16
+ return !!id.match(untypedUidPattern);
17
+ }
18
+ function isTypedUid(id) {
19
+ return !!id.match(typedUidPattern);
20
+ }
21
+ function legacyUuidToHex(id) {
22
+ const idTypeBuffer = Buffer.alloc(1, idTypes.uuid);
23
+ const idBuffer = Buffer.from(id.toLowerCase().replace(/-/g, ''), 'hex');
24
+ return Buffer.concat([idTypeBuffer, idBuffer]).toString('hex');
25
+ }
26
+ function untypedUidToHex(id) {
27
+ const idTypeBuffer = Buffer.alloc(1, idTypes.untypedUid);
28
+ const idBuffer = Buffer.from(id.replace(/-/g, '+').replace(/_/g, '/'), 'base64');
29
+ return Buffer.concat([idTypeBuffer, idBuffer]).toString('hex');
30
+ }
31
+ function typedUidToHex(typedUid) {
32
+ const { id, type } = typedUid.match(typedUidPattern)
33
+ .groups;
34
+ const idTypeBuffer = Buffer.alloc(1, idTypes.typedUid);
35
+ const idBuffer = Buffer.from(id.replace(/-/g, '+').replace(/_/g, '/'), 'base64');
36
+ const typeBuffer = Buffer.from(type, 'utf8');
37
+ return Buffer.concat([idTypeBuffer, idBuffer, typeBuffer]).toString('hex');
38
+ }
39
+ function hexToBase36(hex) {
40
+ return BigInt(`0x${hex}`).toString(36);
41
+ }
42
+ function toCloudSafeId(id) {
43
+ if (!id) {
44
+ throw new Error('id is required');
45
+ }
46
+ if (isLegacyUuid(id)) {
47
+ return hexToBase36(legacyUuidToHex(id));
48
+ }
49
+ if (isTypedUid(id)) {
50
+ return hexToBase36(typedUidToHex(id));
51
+ }
52
+ if (isUntypedUid(id)) {
53
+ return hexToBase36(untypedUidToHex(id));
54
+ }
55
+ throw new Error(`Not a valid ID: [${id}]`);
56
+ }
57
+ exports.toCloudSafeId = toCloudSafeId;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InternalMetricsTrackingSingleton = void 0;
4
+ const logUtils_1 = require("./logUtils");
5
+ class InternalMetricsTrackingSingleton {
6
+ constructor() {
7
+ this.metadata = {};
8
+ }
9
+ static getInstance() {
10
+ if (!InternalMetricsTrackingSingleton.instance) {
11
+ InternalMetricsTrackingSingleton.instance =
12
+ new InternalMetricsTrackingSingleton();
13
+ }
14
+ return InternalMetricsTrackingSingleton.instance;
15
+ }
16
+ addMetric(name, value) {
17
+ this.metadata[name] = value;
18
+ }
19
+ addMetrics(metrics) {
20
+ this.metadata = { ...this.metadata, ...metrics };
21
+ }
22
+ testType(testType) {
23
+ this.metadata.testType = testType;
24
+ }
25
+ testStatus(testStatus) {
26
+ this.metadata.testStatus = testStatus;
27
+ }
28
+ reportMetrics() {
29
+ if (Object.keys(this.metadata).length === 0) {
30
+ return;
31
+ }
32
+ (0, logUtils_1.logInternal)('Internal metrics:', this.metadata);
33
+ this.metadata = {};
34
+ }
35
+ }
36
+ exports.InternalMetricsTrackingSingleton = InternalMetricsTrackingSingleton;
package/util/Lazy.js ADDED
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Lazy = void 0;
4
+ class Lazy {
5
+ constructor(initializer) {
6
+ this.initializer = initializer;
7
+ }
8
+ apply(action) {
9
+ return action(this.instance);
10
+ }
11
+ get instance() {
12
+ if (!this.value) {
13
+ this.value = this.initializer();
14
+ }
15
+ return this.value;
16
+ }
17
+ get isInitialized() {
18
+ return !!this.value;
19
+ }
20
+ map(mapper) {
21
+ return new Lazy(() => this.apply(mapper));
22
+ }
23
+ get maybe() {
24
+ return this.value;
25
+ }
26
+ reset() {
27
+ this.value = undefined;
28
+ }
29
+ withValue(consumer) {
30
+ consumer(this.instance);
31
+ }
32
+ withValueAsync(consumer) {
33
+ return this.apply(consumer);
34
+ }
35
+ static from(instance) {
36
+ return new Lazy(() => instance);
37
+ }
38
+ static of(initializer) {
39
+ return new Lazy(initializer);
40
+ }
41
+ static proxy(initializer) {
42
+ const lazy = Lazy.of(initializer);
43
+ return new Proxy(lazy, new LazyProxy(lazy));
44
+ }
45
+ }
46
+ exports.Lazy = Lazy;
47
+ class LazyProxy {
48
+ constructor(lazy) {
49
+ this.lazy = lazy;
50
+ }
51
+ apply(target, _thisArg, args) {
52
+ return Reflect.apply(target, this.lazy.instance, args);
53
+ }
54
+ construct(target, argArray, _newTarget) {
55
+ return Reflect.construct(target, argArray, this.lazy.instance.constructor);
56
+ }
57
+ defineProperty(_target, property, attributes) {
58
+ return Reflect.defineProperty(this.lazy.instance, property, attributes);
59
+ }
60
+ deleteProperty(_target, p) {
61
+ return Reflect.deleteProperty(this.lazy.instance, p);
62
+ }
63
+ get(_target, p, receiver) {
64
+ return Reflect.get(this.lazy.instance, p, receiver);
65
+ }
66
+ getOwnPropertyDescriptor(_target, p) {
67
+ return Reflect.getOwnPropertyDescriptor(this.lazy.instance, p);
68
+ }
69
+ getPrototypeOf(_target) {
70
+ return Reflect.getPrototypeOf(this.lazy.instance);
71
+ }
72
+ has(_target, p) {
73
+ return Reflect.has(this.lazy.instance, p);
74
+ }
75
+ isExtensible(_target) {
76
+ return Reflect.isExtensible(this.lazy.instance);
77
+ }
78
+ ownKeys(_target) {
79
+ return Reflect.ownKeys(this.lazy.instance);
80
+ }
81
+ preventExtensions(_target) {
82
+ return Reflect.preventExtensions(this.lazy.instance);
83
+ }
84
+ set(_target, p, newValue, receiver) {
85
+ return Reflect.set(this.lazy.instance, p, newValue, receiver);
86
+ }
87
+ setPrototypeOf(_target, v) {
88
+ return Reflect.setPrototypeOf(this.lazy.instance, v);
89
+ }
90
+ }
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MobileAppFileCache = void 0;
4
+ const path_1 = require("path");
5
+ const stream_1 = require("stream");
6
+ const promises_1 = require("fs/promises");
7
+ const mablApi_1 = require("../mablApi");
8
+ const util_1 = require("../core/util");
9
+ const FileCache_1 = require("./FileCache");
10
+ const loggingProvider_1 = require("../providers/logging/loggingProvider");
11
+ const MOBILE_APP_FILE_CACHE_DIRECTORY = 'mobile-app-files';
12
+ const DEFAULT_MAX_MOBILE_APP_FILES = 10;
13
+ const DEFAULT_MAX_MOBILE_APP_FILE_AGE_MINUTES = 60 * 24;
14
+ const MOBILE_APP_FILE_IMMUTABLE_FIELDS = [
15
+ 'content_type',
16
+ 'crc32c_hex',
17
+ 'created_by_id',
18
+ 'created_time',
19
+ 'extension',
20
+ 'id',
21
+ 'name',
22
+ 'platform',
23
+ 'size',
24
+ 'version',
25
+ 'workspace_id',
26
+ ];
27
+ const MOBILE_APP_FILE_IMMUTABLE_FIELD_SET = new Set(MOBILE_APP_FILE_IMMUTABLE_FIELDS);
28
+ class MobileAppFileCache extends FileCache_1.FileCache {
29
+ constructor(options) {
30
+ var _a, _b;
31
+ super({
32
+ ...options,
33
+ cacheName: MOBILE_APP_FILE_CACHE_DIRECTORY,
34
+ maximumCachedFiles: (_a = options === null || options === void 0 ? void 0 : options.maximumCachedFiles) !== null && _a !== void 0 ? _a : DEFAULT_MAX_MOBILE_APP_FILES,
35
+ maximumCachedFileAgeMinutes: (_b = options === null || options === void 0 ? void 0 : options.maximumCachedFileAgeMinutes) !== null && _b !== void 0 ? _b : DEFAULT_MAX_MOBILE_APP_FILE_AGE_MINUTES,
36
+ });
37
+ this.mablApiClientPromise = (options === null || options === void 0 ? void 0 : options.mablApiClient)
38
+ ? Promise.resolve(options.mablApiClient)
39
+ : (0, util_1.getApiClient)();
40
+ }
41
+ async getMobileAppFileImmutableFields(id) {
42
+ const getReader = async () => {
43
+ const apiClient = await this.mablApiClientPromise;
44
+ const mobileAppFile = this.retainImmutableFields(await apiClient.getMobileAppFile(id));
45
+ return stream_1.Readable.from(Buffer.from(JSON.stringify(mobileAppFile, undefined, 0), 'utf-8'));
46
+ };
47
+ const path = await this.getOrCreateFile((0, path_1.join)(id, 'MobileAppFile.json'), getReader);
48
+ return JSON.parse((await (0, promises_1.readFile)(path)).toString());
49
+ }
50
+ async getMobileAppFile(id) {
51
+ const mobileAppFile = await this.getMobileAppFileImmutableFields(id);
52
+ const { crc32c_hex: crc32cHex, size: sizeBytes } = mobileAppFile;
53
+ const getReader = async () => {
54
+ loggingProvider_1.logger.info(`Downloading mobile app file ${id}`);
55
+ const apiClient = await this.mablApiClientPromise;
56
+ const { download_url: downloadUrl } = await apiClient.getMobileAppFile(id, true);
57
+ return (await apiClient.httpClient.get(downloadUrl, {
58
+ responseType: 'stream',
59
+ })).data;
60
+ };
61
+ const extension = this.getMobileAppFileExtension(mobileAppFile);
62
+ if (!extension) {
63
+ throw new Error(`Unable to determine file extension for mobile app file ${id}`);
64
+ }
65
+ const path = await this.getOrCreateFile((0, path_1.join)(id, `MobileAppFile.${extension}`), getReader, {
66
+ crc32cHex: crc32cHex,
67
+ sizeBytes: sizeBytes,
68
+ });
69
+ return { ...mobileAppFile, path };
70
+ }
71
+ retainImmutableFields(mobileAppFile) {
72
+ const immutableFields = { ...mobileAppFile };
73
+ Object.keys(immutableFields).forEach((field) => {
74
+ if (!MOBILE_APP_FILE_IMMUTABLE_FIELD_SET.has(field)) {
75
+ delete immutableFields[field];
76
+ }
77
+ });
78
+ return immutableFields;
79
+ }
80
+ getMobileAppFileExtension({ extension, id, name, platform, }) {
81
+ let resolvedExtension = extension;
82
+ if (!resolvedExtension && name) {
83
+ resolvedExtension = (0, path_1.extname)(name);
84
+ }
85
+ if (!resolvedExtension && platform) {
86
+ switch (platform) {
87
+ case mablApi_1.MobilePlatformEnum.Android:
88
+ resolvedExtension = 'apk';
89
+ break;
90
+ case mablApi_1.MobilePlatformEnum.Ios:
91
+ resolvedExtension = 'app.zip';
92
+ break;
93
+ default:
94
+ throw new Error(`Mobile app file ${id} has unknown platform ${platform}`);
95
+ }
96
+ }
97
+ if (resolvedExtension === null || resolvedExtension === void 0 ? void 0 : resolvedExtension.startsWith('.')) {
98
+ resolvedExtension = resolvedExtension.substring(1);
99
+ }
100
+ return resolvedExtension;
101
+ }
102
+ }
103
+ exports.MobileAppFileCache = MobileAppFileCache;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ var _a;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ class RichPromise {
5
+ constructor(chained) {
6
+ this.resolver = () => { };
7
+ this.resolved = false;
8
+ this.rejecter = () => { };
9
+ this.rejected = false;
10
+ this[_a] = 'promise';
11
+ this.promise = new Promise((resolve, reject) => {
12
+ this.resolver = resolve;
13
+ this.rejecter = reject;
14
+ });
15
+ if (chained) {
16
+ chained
17
+ .then((result) => this.resolve(result))
18
+ .catch((reason) => this.reject(reason));
19
+ }
20
+ }
21
+ isPending() {
22
+ return !(this.isResolved() || this.isRejected());
23
+ }
24
+ resolve(value) {
25
+ if (this.isPending()) {
26
+ this.resolver(value);
27
+ this.resolved = true;
28
+ }
29
+ }
30
+ isResolved() {
31
+ return this.resolved;
32
+ }
33
+ reject(reason) {
34
+ if (this.isPending()) {
35
+ this.rejecter(reason);
36
+ this.rejected = true;
37
+ }
38
+ }
39
+ isRejected() {
40
+ return this.rejected;
41
+ }
42
+ then(onfulfilled, onrejected) {
43
+ return this.promise.then(onfulfilled, onrejected);
44
+ }
45
+ catch(onrejected) {
46
+ return this.promise.catch(onrejected);
47
+ }
48
+ finally(onfinally) {
49
+ return this.promise.finally(onfinally);
50
+ }
51
+ }
52
+ _a = Symbol.toStringTag;
53
+ exports.default = RichPromise;