octoparse-cli 0.1.14

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 (278) hide show
  1. package/README.md +271 -0
  2. package/RUNTIME_SECURITY_NOTICE.txt +41 -0
  3. package/SECURITY.md +24 -0
  4. package/dist/cli/args.js +34 -0
  5. package/dist/cli/help.js +214 -0
  6. package/dist/cli/output.js +39 -0
  7. package/dist/commands/auth.js +283 -0
  8. package/dist/commands/capabilities.js +118 -0
  9. package/dist/commands/cloud.js +241 -0
  10. package/dist/commands/data.js +220 -0
  11. package/dist/commands/doctor.js +73 -0
  12. package/dist/commands/env.js +63 -0
  13. package/dist/commands/local.js +251 -0
  14. package/dist/commands/run.js +622 -0
  15. package/dist/commands/runs.js +171 -0
  16. package/dist/commands/task.js +101 -0
  17. package/dist/index.js +133 -0
  18. package/dist/runtime/account-capabilities.js +71 -0
  19. package/dist/runtime/api-client.js +290 -0
  20. package/dist/runtime/artifacts.js +33 -0
  21. package/dist/runtime/auth.js +94 -0
  22. package/dist/runtime/bridge-hub.js +173 -0
  23. package/dist/runtime/client-headers.js +23 -0
  24. package/dist/runtime/cloud-data.js +75 -0
  25. package/dist/runtime/config.js +48 -0
  26. package/dist/runtime/data-exporter.js +267 -0
  27. package/dist/runtime/engine-host.js +449 -0
  28. package/dist/runtime/local-runs.js +92 -0
  29. package/dist/runtime/naming.js +13 -0
  30. package/dist/runtime/run-control.js +363 -0
  31. package/dist/runtime/run-services.js +380 -0
  32. package/dist/runtime/security-notice.js +78 -0
  33. package/dist/runtime/task-definition-provider.js +282 -0
  34. package/dist/types.js +4 -0
  35. package/examples/minimal-task.json +6 -0
  36. package/examples/navigate-example-task.json +6 -0
  37. package/node_modules/@octopus/bpmn/index.js +3 -0
  38. package/node_modules/@octopus/bpmn/lib/Context.js +245 -0
  39. package/node_modules/@octopus/bpmn/lib/Definition.js +258 -0
  40. package/node_modules/@octopus/bpmn/lib/Engine.js +275 -0
  41. package/node_modules/@octopus/bpmn/lib/PrematureStopError.js +7 -0
  42. package/node_modules/@octopus/bpmn/lib/activities/Activity.js +202 -0
  43. package/node_modules/@octopus/bpmn/lib/activities/BaseProcess.js +308 -0
  44. package/node_modules/@octopus/bpmn/lib/activities/BaseTask.js +145 -0
  45. package/node_modules/@octopus/bpmn/lib/activities/BoundaryEvent.js +12 -0
  46. package/node_modules/@octopus/bpmn/lib/activities/Dummy.js +10 -0
  47. package/node_modules/@octopus/bpmn/lib/activities/EventDefinition.js +99 -0
  48. package/node_modules/@octopus/bpmn/lib/activities/Flow.js +52 -0
  49. package/node_modules/@octopus/bpmn/lib/activities/Form.js +67 -0
  50. package/node_modules/@octopus/bpmn/lib/activities/InputOutput.js +53 -0
  51. package/node_modules/@octopus/bpmn/lib/activities/IntermediateCatchEvent.js +12 -0
  52. package/node_modules/@octopus/bpmn/lib/activities/MessageFlow.js +19 -0
  53. package/node_modules/@octopus/bpmn/lib/activities/MultiInstanceLoopCharacteristics.js +160 -0
  54. package/node_modules/@octopus/bpmn/lib/activities/Properties.js +27 -0
  55. package/node_modules/@octopus/bpmn/lib/activities/SequenceFlow.js +56 -0
  56. package/node_modules/@octopus/bpmn/lib/activities/ServiceConnector.js +71 -0
  57. package/node_modules/@octopus/bpmn/lib/context-helper.js +198 -0
  58. package/node_modules/@octopus/bpmn/lib/events/EndEvent.js +22 -0
  59. package/node_modules/@octopus/bpmn/lib/events/ErrorEvent.js +41 -0
  60. package/node_modules/@octopus/bpmn/lib/events/MessageEvent.js +19 -0
  61. package/node_modules/@octopus/bpmn/lib/events/StartEvent.js +55 -0
  62. package/node_modules/@octopus/bpmn/lib/events/TimerEvent.js +75 -0
  63. package/node_modules/@octopus/bpmn/lib/expressions.js +41 -0
  64. package/node_modules/@octopus/bpmn/lib/gateways/ExclusiveGateway.js +86 -0
  65. package/node_modules/@octopus/bpmn/lib/gateways/InclusiveGateway.js +56 -0
  66. package/node_modules/@octopus/bpmn/lib/gateways/ParallelGateway.js +195 -0
  67. package/node_modules/@octopus/bpmn/lib/getPropertyValue.js +83 -0
  68. package/node_modules/@octopus/bpmn/lib/index.js +6 -0
  69. package/node_modules/@octopus/bpmn/lib/mapper.js +55 -0
  70. package/node_modules/@octopus/bpmn/lib/parameter.js +119 -0
  71. package/node_modules/@octopus/bpmn/lib/script-helper.js +45 -0
  72. package/node_modules/@octopus/bpmn/lib/tasks/ManualTask.js +31 -0
  73. package/node_modules/@octopus/bpmn/lib/tasks/ReceiveTask.js +31 -0
  74. package/node_modules/@octopus/bpmn/lib/tasks/ScriptTask.js +35 -0
  75. package/node_modules/@octopus/bpmn/lib/tasks/SendTask.js +16 -0
  76. package/node_modules/@octopus/bpmn/lib/tasks/ServiceTask.js +68 -0
  77. package/node_modules/@octopus/bpmn/lib/tasks/SubProcess.js +17 -0
  78. package/node_modules/@octopus/bpmn/lib/tasks/Task.js +16 -0
  79. package/node_modules/@octopus/bpmn/lib/tasks/UserTask.js +47 -0
  80. package/node_modules/@octopus/bpmn/lib/transformer.js +13 -0
  81. package/node_modules/@octopus/bpmn/lib/validation.js +111 -0
  82. package/node_modules/@octopus/bpmn/package.json +17 -0
  83. package/node_modules/@octopus/bpmn/types/bpmn.d.ts +85 -0
  84. package/node_modules/@octopus/engine/README.md +370 -0
  85. package/node_modules/@octopus/engine/dist/actions/BackPreWebPageAction.d.ts +4 -0
  86. package/node_modules/@octopus/engine/dist/actions/BackPreWebPageAction.js +1 -0
  87. package/node_modules/@octopus/engine/dist/actions/BaseAction.d.ts +339 -0
  88. package/node_modules/@octopus/engine/dist/actions/BaseAction.js +1559 -0
  89. package/node_modules/@octopus/engine/dist/actions/BranchAction.d.ts +9 -0
  90. package/node_modules/@octopus/engine/dist/actions/BranchAction.js +1 -0
  91. package/node_modules/@octopus/engine/dist/actions/ClickAction.d.ts +22 -0
  92. package/node_modules/@octopus/engine/dist/actions/ClickAction.js +1 -0
  93. package/node_modules/@octopus/engine/dist/actions/ConditionAction.d.ts +4 -0
  94. package/node_modules/@octopus/engine/dist/actions/ConditionAction.js +1 -0
  95. package/node_modules/@octopus/engine/dist/actions/EmptyAction.d.ts +4 -0
  96. package/node_modules/@octopus/engine/dist/actions/EmptyAction.js +12 -0
  97. package/node_modules/@octopus/engine/dist/actions/EnterCaptchaAction.d.ts +28 -0
  98. package/node_modules/@octopus/engine/dist/actions/EnterCaptchaAction.js +1 -0
  99. package/node_modules/@octopus/engine/dist/actions/EnterTextAction.d.ts +20 -0
  100. package/node_modules/@octopus/engine/dist/actions/EnterTextAction.js +1 -0
  101. package/node_modules/@octopus/engine/dist/actions/ExtractDataAction.d.ts +40 -0
  102. package/node_modules/@octopus/engine/dist/actions/ExtractDataAction.js +1 -0
  103. package/node_modules/@octopus/engine/dist/actions/LoopAction.d.ts +41 -0
  104. package/node_modules/@octopus/engine/dist/actions/LoopAction.js +526 -0
  105. package/node_modules/@octopus/engine/dist/actions/LoopStartAction.d.ts +47 -0
  106. package/node_modules/@octopus/engine/dist/actions/LoopStartAction.js +607 -0
  107. package/node_modules/@octopus/engine/dist/actions/MouseOverAction.d.ts +8 -0
  108. package/node_modules/@octopus/engine/dist/actions/MouseOverAction.js +34 -0
  109. package/node_modules/@octopus/engine/dist/actions/NavigateAction.d.ts +38 -0
  110. package/node_modules/@octopus/engine/dist/actions/NavigateAction.js +535 -0
  111. package/node_modules/@octopus/engine/dist/actions/SwitchComboAction.d.ts +13 -0
  112. package/node_modules/@octopus/engine/dist/actions/SwitchComboAction.js +69 -0
  113. package/node_modules/@octopus/engine/dist/browser.d.ts +17 -0
  114. package/node_modules/@octopus/engine/dist/browser.js +157 -0
  115. package/node_modules/@octopus/engine/dist/browserProxy.d.ts +90 -0
  116. package/node_modules/@octopus/engine/dist/browserProxy.js +1 -0
  117. package/node_modules/@octopus/engine/dist/configs/BaseConfig.d.ts +20 -0
  118. package/node_modules/@octopus/engine/dist/configs/BaseConfig.js +88 -0
  119. package/node_modules/@octopus/engine/dist/configs/BranchConfig.d.ts +7 -0
  120. package/node_modules/@octopus/engine/dist/configs/BranchConfig.js +1 -0
  121. package/node_modules/@octopus/engine/dist/configs/ClickConfig.d.ts +36 -0
  122. package/node_modules/@octopus/engine/dist/configs/ClickConfig.js +65 -0
  123. package/node_modules/@octopus/engine/dist/configs/EnterCaptchaConfig.d.ts +19 -0
  124. package/node_modules/@octopus/engine/dist/configs/EnterCaptchaConfig.js +25 -0
  125. package/node_modules/@octopus/engine/dist/configs/EnterTextConfig.d.ts +24 -0
  126. package/node_modules/@octopus/engine/dist/configs/EnterTextConfig.js +36 -0
  127. package/node_modules/@octopus/engine/dist/configs/ExtractDataConfig.d.ts +12 -0
  128. package/node_modules/@octopus/engine/dist/configs/ExtractDataConfig.js +1 -0
  129. package/node_modules/@octopus/engine/dist/configs/LoopConfig.d.ts +25 -0
  130. package/node_modules/@octopus/engine/dist/configs/LoopConfig.js +40 -0
  131. package/node_modules/@octopus/engine/dist/configs/LoopStartConfig.d.ts +4 -0
  132. package/node_modules/@octopus/engine/dist/configs/LoopStartConfig.js +12 -0
  133. package/node_modules/@octopus/engine/dist/configs/MouseOverConfig.d.ts +8 -0
  134. package/node_modules/@octopus/engine/dist/configs/MouseOverConfig.js +15 -0
  135. package/node_modules/@octopus/engine/dist/configs/NavigateConfig.d.ts +41 -0
  136. package/node_modules/@octopus/engine/dist/configs/NavigateConfig.js +121 -0
  137. package/node_modules/@octopus/engine/dist/configs/SwitchComboConfig.d.ts +8 -0
  138. package/node_modules/@octopus/engine/dist/configs/SwitchComboConfig.js +15 -0
  139. package/node_modules/@octopus/engine/dist/enums/index.d.ts +419 -0
  140. package/node_modules/@octopus/engine/dist/enums/index.js +314 -0
  141. package/node_modules/@octopus/engine/dist/extension/BrowserWebSocketTransport-D_zAGZMQ.js +1 -0
  142. package/node_modules/@octopus/engine/dist/extension/LaunchOptions-DxvePrV4.js +6 -0
  143. package/node_modules/@octopus/engine/dist/extension/NodeWebSocketTransport-BTgRVB7Z.js +6 -0
  144. package/node_modules/@octopus/engine/dist/extension/background.js +396 -0
  145. package/node_modules/@octopus/engine/dist/extension/bidi-C_GIZ8Uz.js +131 -0
  146. package/node_modules/@octopus/engine/dist/extension/manifest.json +27 -0
  147. package/node_modules/@octopus/engine/dist/extension/src/content/anti-detection.js +1 -0
  148. package/node_modules/@octopus/engine/dist/extension-bridge/BaseExtensionBridge.d.ts +21 -0
  149. package/node_modules/@octopus/engine/dist/extension-bridge/BaseExtensionBridge.js +117 -0
  150. package/node_modules/@octopus/engine/dist/extension-bridge/SessionExtensionBridge.d.ts +17 -0
  151. package/node_modules/@octopus/engine/dist/extension-bridge/SessionExtensionBridge.js +29 -0
  152. package/node_modules/@octopus/engine/dist/extension-bridge/index.d.ts +2 -0
  153. package/node_modules/@octopus/engine/dist/extension-bridge/index.js +5 -0
  154. package/node_modules/@octopus/engine/dist/extension-bridge/types.d.ts +159 -0
  155. package/node_modules/@octopus/engine/dist/extension-bridge/types.js +5 -0
  156. package/node_modules/@octopus/engine/dist/extensions/ublock-origin/uBlock0.chromium.tar.xz +0 -0
  157. package/node_modules/@octopus/engine/dist/extensions/ublock-origin-lite/uBOLite.chromium.tar.xz +0 -0
  158. package/node_modules/@octopus/engine/dist/index.d.ts +169 -0
  159. package/node_modules/@octopus/engine/dist/index.js +1 -0
  160. package/node_modules/@octopus/engine/dist/models/actionItem.d.ts +16 -0
  161. package/node_modules/@octopus/engine/dist/models/actionItem.js +15 -0
  162. package/node_modules/@octopus/engine/dist/models/conditionCheckArgs.d.ts +11 -0
  163. package/node_modules/@octopus/engine/dist/models/conditionCheckArgs.js +11 -0
  164. package/node_modules/@octopus/engine/dist/models/customizeCookie.d.ts +14 -0
  165. package/node_modules/@octopus/engine/dist/models/customizeCookie.js +6 -0
  166. package/node_modules/@octopus/engine/dist/models/downloadFileConfig.d.ts +17 -0
  167. package/node_modules/@octopus/engine/dist/models/downloadFileConfig.js +26 -0
  168. package/node_modules/@octopus/engine/dist/models/elementNotFoundArgs.d.ts +8 -0
  169. package/node_modules/@octopus/engine/dist/models/elementNotFoundArgs.js +12 -0
  170. package/node_modules/@octopus/engine/dist/models/elementNotFoundError.d.ts +2 -0
  171. package/node_modules/@octopus/engine/dist/models/elementNotFoundError.js +6 -0
  172. package/node_modules/@octopus/engine/dist/models/extractItem.d.ts +37 -0
  173. package/node_modules/@octopus/engine/dist/models/extractItem.js +35 -0
  174. package/node_modules/@octopus/engine/dist/models/extractTemplate.d.ts +11 -0
  175. package/node_modules/@octopus/engine/dist/models/extractTemplate.js +48 -0
  176. package/node_modules/@octopus/engine/dist/models/extractTextItem.d.ts +10 -0
  177. package/node_modules/@octopus/engine/dist/models/extractTextItem.js +17 -0
  178. package/node_modules/@octopus/engine/dist/models/globalConfig.d.ts +5 -0
  179. package/node_modules/@octopus/engine/dist/models/globalConfig.js +1 -0
  180. package/node_modules/@octopus/engine/dist/models/httpHeader.d.ts +4 -0
  181. package/node_modules/@octopus/engine/dist/models/httpHeader.js +10 -0
  182. package/node_modules/@octopus/engine/dist/models/operation.d.ts +27 -0
  183. package/node_modules/@octopus/engine/dist/models/operation.js +242 -0
  184. package/node_modules/@octopus/engine/dist/models/retryCondition.d.ts +7 -0
  185. package/node_modules/@octopus/engine/dist/models/retryCondition.js +10 -0
  186. package/node_modules/@octopus/engine/dist/models/task.d.ts +89 -0
  187. package/node_modules/@octopus/engine/dist/models/task.js +120 -0
  188. package/node_modules/@octopus/engine/dist/models/trigger.d.ts +66 -0
  189. package/node_modules/@octopus/engine/dist/models/trigger.js +117 -0
  190. package/node_modules/@octopus/engine/dist/package.json +26 -0
  191. package/node_modules/@octopus/engine/dist/public-types.d.ts +13 -0
  192. package/node_modules/@octopus/engine/dist/public-types.js +2 -0
  193. package/node_modules/@octopus/engine/dist/settings.d.ts +41 -0
  194. package/node_modules/@octopus/engine/dist/settings.js +20 -0
  195. package/node_modules/@octopus/engine/dist/solvers/captcha/ClickCaptchaSolver.d.ts +6 -0
  196. package/node_modules/@octopus/engine/dist/solvers/captcha/ClickCaptchaSolver.js +1 -0
  197. package/node_modules/@octopus/engine/dist/solvers/captcha/HCaptchaSolver.d.ts +4 -0
  198. package/node_modules/@octopus/engine/dist/solvers/captcha/HCaptchaSolver.js +73 -0
  199. package/node_modules/@octopus/engine/dist/solvers/captcha/ImageCaptchaSolver.d.ts +2 -0
  200. package/node_modules/@octopus/engine/dist/solvers/captcha/ImageCaptchaSolver.js +74 -0
  201. package/node_modules/@octopus/engine/dist/solvers/captcha/RecaptchaSolver.d.ts +9 -0
  202. package/node_modules/@octopus/engine/dist/solvers/captcha/RecaptchaSolver.js +371 -0
  203. package/node_modules/@octopus/engine/dist/solvers/captcha/SliderCaptchaSolver.d.ts +6 -0
  204. package/node_modules/@octopus/engine/dist/solvers/captcha/SliderCaptchaSolver.js +184 -0
  205. package/node_modules/@octopus/engine/dist/solvers/captcha/SlidingTrajectory.d.ts +50 -0
  206. package/node_modules/@octopus/engine/dist/solvers/captcha/SlidingTrajectory.js +125 -0
  207. package/node_modules/@octopus/engine/dist/solvers/captcha/types.d.ts +68 -0
  208. package/node_modules/@octopus/engine/dist/solvers/captcha/types.js +34 -0
  209. package/node_modules/@octopus/engine/dist/solvers/captcha/utils.d.ts +2 -0
  210. package/node_modules/@octopus/engine/dist/solvers/captcha/utils.js +15 -0
  211. package/node_modules/@octopus/engine/dist/translator/actionFactory.d.ts +6 -0
  212. package/node_modules/@octopus/engine/dist/translator/actionFactory.js +1 -0
  213. package/node_modules/@octopus/engine/dist/translator/activityTypeEnum.d.ts +22 -0
  214. package/node_modules/@octopus/engine/dist/translator/activityTypeEnum.js +1 -0
  215. package/node_modules/@octopus/engine/dist/translator/backPreWebPageAction.d.ts +5 -0
  216. package/node_modules/@octopus/engine/dist/translator/backPreWebPageAction.js +1 -0
  217. package/node_modules/@octopus/engine/dist/translator/baseAction.d.ts +31 -0
  218. package/node_modules/@octopus/engine/dist/translator/baseAction.js +1 -0
  219. package/node_modules/@octopus/engine/dist/translator/breakActivity.d.ts +5 -0
  220. package/node_modules/@octopus/engine/dist/translator/breakActivity.js +1 -0
  221. package/node_modules/@octopus/engine/dist/translator/clickAction.d.ts +5 -0
  222. package/node_modules/@octopus/engine/dist/translator/clickAction.js +1 -0
  223. package/node_modules/@octopus/engine/dist/translator/completeWF.d.ts +5 -0
  224. package/node_modules/@octopus/engine/dist/translator/completeWF.js +1 -0
  225. package/node_modules/@octopus/engine/dist/translator/conditionAction.d.ts +6 -0
  226. package/node_modules/@octopus/engine/dist/translator/conditionAction.js +1 -0
  227. package/node_modules/@octopus/engine/dist/translator/emptyAction.d.ts +5 -0
  228. package/node_modules/@octopus/engine/dist/translator/emptyAction.js +1 -0
  229. package/node_modules/@octopus/engine/dist/translator/enterCapachaAction.d.ts +5 -0
  230. package/node_modules/@octopus/engine/dist/translator/enterCapachaAction.js +1 -0
  231. package/node_modules/@octopus/engine/dist/translator/enterTextAction.d.ts +5 -0
  232. package/node_modules/@octopus/engine/dist/translator/enterTextAction.js +1 -0
  233. package/node_modules/@octopus/engine/dist/translator/extractDataAction.d.ts +13 -0
  234. package/node_modules/@octopus/engine/dist/translator/extractDataAction.js +1 -0
  235. package/node_modules/@octopus/engine/dist/translator/loopAction.d.ts +5 -0
  236. package/node_modules/@octopus/engine/dist/translator/loopAction.js +1 -0
  237. package/node_modules/@octopus/engine/dist/translator/mouseOverAction.d.ts +5 -0
  238. package/node_modules/@octopus/engine/dist/translator/mouseOverAction.js +19 -0
  239. package/node_modules/@octopus/engine/dist/translator/navigateAction.d.ts +5 -0
  240. package/node_modules/@octopus/engine/dist/translator/navigateAction.js +117 -0
  241. package/node_modules/@octopus/engine/dist/translator/rootAction.d.ts +6 -0
  242. package/node_modules/@octopus/engine/dist/translator/rootAction.js +80 -0
  243. package/node_modules/@octopus/engine/dist/translator/switchCombo2Action.d.ts +5 -0
  244. package/node_modules/@octopus/engine/dist/translator/switchCombo2Action.js +19 -0
  245. package/node_modules/@octopus/engine/dist/translator/translator.d.ts +1 -0
  246. package/node_modules/@octopus/engine/dist/translator/translator.js +36 -0
  247. package/node_modules/@octopus/engine/dist/type.d.ts +25 -0
  248. package/node_modules/@octopus/engine/dist/type.js +2 -0
  249. package/node_modules/@octopus/engine/dist/types/browser.d.ts +191 -0
  250. package/node_modules/@octopus/engine/dist/types/browser.js +1 -0
  251. package/node_modules/@octopus/engine/dist/types/browserManager.d.ts +41 -0
  252. package/node_modules/@octopus/engine/dist/types/browserManager.js +1 -0
  253. package/node_modules/@octopus/engine/dist/types/index.d.ts +40 -0
  254. package/node_modules/@octopus/engine/dist/types/index.js +2 -0
  255. package/node_modules/@octopus/engine/dist/types/plugin.d.ts +29 -0
  256. package/node_modules/@octopus/engine/dist/types/plugin.js +2 -0
  257. package/node_modules/@octopus/engine/dist/utils/AsyncEmitter.d.ts +15 -0
  258. package/node_modules/@octopus/engine/dist/utils/AsyncEmitter.js +1 -0
  259. package/node_modules/@octopus/engine/dist/utils/DataStore.d.ts +58 -0
  260. package/node_modules/@octopus/engine/dist/utils/DataStore.js +1 -0
  261. package/node_modules/@octopus/engine/dist/utils/DateTimeFormatHelper.d.ts +22 -0
  262. package/node_modules/@octopus/engine/dist/utils/DateTimeFormatHelper.js +173 -0
  263. package/node_modules/@octopus/engine/dist/utils/FileDownloader.d.ts +108 -0
  264. package/node_modules/@octopus/engine/dist/utils/FileDownloader.js +1 -0
  265. package/node_modules/@octopus/engine/dist/utils/HttpRequester.d.ts +43 -0
  266. package/node_modules/@octopus/engine/dist/utils/HttpRequester.js +174 -0
  267. package/node_modules/@octopus/engine/dist/utils/JsonParser.d.ts +95 -0
  268. package/node_modules/@octopus/engine/dist/utils/JsonParser.js +439 -0
  269. package/node_modules/@octopus/engine/dist/utils/Operations.d.ts +27 -0
  270. package/node_modules/@octopus/engine/dist/utils/Operations.js +115 -0
  271. package/node_modules/@octopus/engine/dist/utils/index.d.ts +28 -0
  272. package/node_modules/@octopus/engine/dist/utils/index.js +356 -0
  273. package/node_modules/@octopus/engine/package.json +58 -0
  274. package/package.json +79 -0
  275. package/schemas/capabilities-v1.schema.json +234 -0
  276. package/schemas/detached-bootstrap-v1.schema.json +42 -0
  277. package/schemas/json-envelope-v1.schema.json +39 -0
  278. package/schemas/run-event-v1.schema.json +47 -0
@@ -0,0 +1,439 @@
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.JsonParsedArgs = exports.JsonNodeType = exports.JsonNode = exports.HttpMethod = exports.JsonRequest = void 0;
7
+ const events_1 = require("events");
8
+ const jsonpath_plus_1 = require("jsonpath-plus");
9
+ const moment_1 = __importDefault(require("moment"));
10
+ const xmlbuilder_1 = __importDefault(require("xmlbuilder"));
11
+ const enums_1 = require("../enums");
12
+ const elementNotFoundArgs_1 = require("../models/elementNotFoundArgs");
13
+ const elementNotFoundError_1 = require("../models/elementNotFoundError");
14
+ const _1 = require(".");
15
+ const HttpRequester_1 = require("./HttpRequester");
16
+ const lodash_1 = require("lodash");
17
+ const xmlValueRegex = /[\0-\x08\x0B\f\x0E-\x1F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/g;
18
+ class JsonParser extends events_1.EventEmitter {
19
+ constructor() {
20
+ super();
21
+ this.originText = '';
22
+ this.currentUrl = '';
23
+ this.UNICODE_REGEX = /[\u4e00-\u9fa5]/;
24
+ this.jsonpath = jsonpath_plus_1.JSONPath;
25
+ this.httpRequester = new HttpRequester_1.HttpRequester();
26
+ this.httpRequester.on('onRequested', (args) => {
27
+ this.httpJsonParser_OnRequested(args);
28
+ });
29
+ this.httpRequester.on('onRequestError', (args) => {
30
+ this.json = '';
31
+ });
32
+ }
33
+ onRequested(func) {
34
+ this.httpRequester.on('onRequested', (args) => {
35
+ func(args);
36
+ });
37
+ }
38
+ onRequestError(func) {
39
+ this.httpRequester.on('onRequestError', (args) => {
40
+ func(args);
41
+ });
42
+ }
43
+ onRequesting(func) {
44
+ this.httpRequester.on('onRequesting', (args) => {
45
+ func(args);
46
+ });
47
+ }
48
+ onRequestStopped(func) {
49
+ this.httpRequester.on('onRequestStopped', () => {
50
+ func();
51
+ });
52
+ }
53
+ onJsonParsed(func) {
54
+ this.on('onJsonParsed', (args) => {
55
+ func(args);
56
+ });
57
+ }
58
+ get json() {
59
+ return JSON.stringify(this.jsonObject);
60
+ }
61
+ set json(str) {
62
+ try {
63
+ this.jsonObject = JSON.parse(str);
64
+ }
65
+ catch (error) {
66
+ this.jsonObject = {};
67
+ }
68
+ }
69
+ get isRequesting() {
70
+ return this.httpRequester.isRequesting;
71
+ }
72
+ async startRequest(url, method, headers, bodyContent, timeout, requestCallback) {
73
+ await this.httpRequester.startRequest(url, method, headers, bodyContent, timeout, requestCallback);
74
+ }
75
+ getRoot() {
76
+ return this.jsonObject;
77
+ }
78
+ /**
79
+ * 获取路径末尾的[.*]
80
+ * @param path
81
+ */
82
+ getLastBracketString(path) {
83
+ if (path.endsWith(']')) {
84
+ return path.substring(path.lastIndexOf('['));
85
+ }
86
+ return '';
87
+ }
88
+ /**
89
+ * 将jsonpath转为8可用的格式
90
+ */
91
+ fixPathToV8(path, relativePath) {
92
+ if (this.UNICODE_REGEX.test(path)) {
93
+ const end = this.getLastBracketString(path);
94
+ path = path.substr(0, path.length - end.length);
95
+ if (!path.includes('.')) {
96
+ if (!path.includes('["')) {
97
+ path = '$["' + path + '"]';
98
+ }
99
+ }
100
+ else {
101
+ const arrs = path.split('.');
102
+ arrs.forEach((a) => {
103
+ if (!a.includes('["') && a.match(this.UNICODE_REGEX)) {
104
+ path = path.replace('.' + a, `["${a}"]`);
105
+ }
106
+ });
107
+ }
108
+ if (path.startsWith('[')) {
109
+ path = '$' + path;
110
+ }
111
+ path += end;
112
+ }
113
+ if (relativePath) {
114
+ if (this.UNICODE_REGEX.test(relativePath)) {
115
+ if (relativePath.startsWith('[') && relativePath.endsWith(']')) {
116
+ path = path + relativePath;
117
+ }
118
+ else {
119
+ path = `${path}["${relativePath}"]`;
120
+ }
121
+ }
122
+ else {
123
+ if (relativePath.startsWith('["')) {
124
+ path = path + relativePath;
125
+ }
126
+ else {
127
+ const absPathItems = jsonpath_plus_1.JSONPath.toPathArray(path);
128
+ const relativePathItems = jsonpath_plus_1.JSONPath.toPathArray(relativePath);
129
+ path = jsonpath_plus_1.JSONPath.toPathString(absPathItems.concat(relativePathItems));
130
+ }
131
+ }
132
+ }
133
+ return path;
134
+ }
135
+ getNode(absPath, relativePath) {
136
+ const root = this.getRoot();
137
+ if (root) {
138
+ const path = this.fixPathToV8(absPath, relativePath);
139
+ if (!path)
140
+ return undefined;
141
+ const results = (0, jsonpath_plus_1.JSONPath)({
142
+ path,
143
+ json: root,
144
+ resultType: 'all'
145
+ });
146
+ for (const result of results) {
147
+ const pathArray = jsonpath_plus_1.JSONPath.toPathArray(result.path);
148
+ const nodeName = pathArray[pathArray.length - 1].toString();
149
+ const n = new JsonNode(this.jsonpath, nodeName, result.value, pathArray);
150
+ return n;
151
+ }
152
+ return undefined;
153
+ }
154
+ }
155
+ loadFromJson(json) {
156
+ this.originText = json;
157
+ try {
158
+ if (!this.isNormalJson(json)) {
159
+ this.json = this.stripJsonpToJson(json);
160
+ }
161
+ else {
162
+ this.json = json;
163
+ }
164
+ }
165
+ catch (error) {
166
+ this.json = json;
167
+ }
168
+ }
169
+ httpJsonParser_OnRequested(args) {
170
+ let parseArgs;
171
+ try {
172
+ this.currentUrl = args.url;
173
+ this.loadFromJson(args.responseString);
174
+ parseArgs = new JsonParsedArgs(args.url, args.responseString, args.responseString, true);
175
+ }
176
+ catch (error) {
177
+ parseArgs = new JsonParsedArgs(args.url, '', '', false, error);
178
+ }
179
+ finally {
180
+ this.emit('onJsonParsed', parseArgs);
181
+ }
182
+ }
183
+ async extractText(textItem, baseJPath) {
184
+ let resultText = '';
185
+ let node;
186
+ switch (textItem.ExtractType) {
187
+ case "ExtractPageSource" /* ExtractTextType.ExtractPageSource */:
188
+ resultText = this.json;
189
+ break;
190
+ case "ExtractPageURL" /* ExtractTextType.ExtractPageURL */:
191
+ resultText = this.currentUrl;
192
+ break;
193
+ case "ExtractPageTitle" /* ExtractTextType.ExtractPageTitle */:
194
+ resultText = '';
195
+ break;
196
+ case "GenerateFixedValue" /* ExtractTextType.GenerateFixedValue */:
197
+ resultText = textItem.FixedValue;
198
+ break;
199
+ case "GenerateCurrentDateTime" /* ExtractTextType.GenerateCurrentDateTime */:
200
+ resultText = (0, moment_1.default)(new Date()).format('YYYY-MM-DD HH:mm:ss.SSSS');
201
+ break;
202
+ case "ExtractAddTaskSourceUrl" /* ExtractTextType.ExtractAddTaskSourceUrl */:
203
+ resultText = this.taskSourceUrl;
204
+ break;
205
+ default:
206
+ if (textItem.useRelativeXPath) {
207
+ node = this.getNode(baseJPath, textItem.relativeXpath);
208
+ }
209
+ else {
210
+ node = this.getNode(textItem.absXpath);
211
+ }
212
+ if (!node && textItem.backUpAbsXPath) {
213
+ node = this.getNode(textItem.backUpAbsXPath);
214
+ }
215
+ if (node) {
216
+ resultText = node.getValueText();
217
+ }
218
+ else {
219
+ throw new elementNotFoundError_1.ElementNotFoundError('element not found, extraction failed');
220
+ }
221
+ break;
222
+ }
223
+ if (!(0, _1.isNullOrEmpty)(resultText)) {
224
+ if (textItem.operations != null && textItem.operations.length > 0) {
225
+ for (const operation of textItem.operations) {
226
+ resultText = await operation.caculate(resultText);
227
+ }
228
+ }
229
+ }
230
+ return resultText;
231
+ }
232
+ async extractItem(extractItem, writer, baseJPath, data) {
233
+ if (extractItem == undefined) {
234
+ return false;
235
+ }
236
+ let resultText = '';
237
+ try {
238
+ resultText = await this.extractText(extractItem, baseJPath);
239
+ }
240
+ catch (error) {
241
+ if (error instanceof elementNotFoundError_1.ElementNotFoundError) {
242
+ const e = new elementNotFoundArgs_1.ElementNotFoundArgs(baseJPath, extractItem);
243
+ // TODO
244
+ // RaiseElementNotFoundEvent(e)
245
+ switch (e.HandleType) {
246
+ case enums_1.ElementNotFoundHandleType.AllowSkip:
247
+ return false;
248
+ break;
249
+ case enums_1.ElementNotFoundHandleType.SetBackup:
250
+ case enums_1.ElementNotFoundHandleType.ModifyXPath:
251
+ break;
252
+ case enums_1.ElementNotFoundHandleType.NotHandle:
253
+ if (extractItem.allowSkip) {
254
+ return false;
255
+ }
256
+ else if (extractItem.allowDefaultValue) {
257
+ resultText = extractItem.NullValue;
258
+ }
259
+ break;
260
+ case enums_1.ElementNotFoundHandleType.AllowEmpty:
261
+ default:
262
+ break;
263
+ }
264
+ }
265
+ console.error(error);
266
+ }
267
+ finally {
268
+ data[extractItem.header] = resultText;
269
+ /** 去除字段内容中的 XML 的非法字符 */
270
+ resultText = resultText.replace(xmlValueRegex, '');
271
+ writer.ele(extractItem.header, { IsAppend: extractItem.IsAppend }, resultText);
272
+ }
273
+ return true;
274
+ }
275
+ async extractGroupItem(extractTemplate, extractItem, writer, baseJPath, data) {
276
+ if ((0, lodash_1.isNil)(extractItem)) {
277
+ return false;
278
+ }
279
+ if (extractItem.header != 'Root') {
280
+ writer.ele(extractItem.header);
281
+ }
282
+ const childs = extractTemplate.getChildren(extractItem.id);
283
+ if (childs.length > 0) {
284
+ for (const item of childs) {
285
+ if (item.type == 'ExtractGroupItem') {
286
+ return await this.extractGroupItem(extractTemplate, extractItem, writer, baseJPath, data);
287
+ }
288
+ else {
289
+ if (!(await this.extractItem(item, writer, baseJPath, data))) {
290
+ return true;
291
+ }
292
+ }
293
+ }
294
+ }
295
+ return false;
296
+ }
297
+ /** 当前任务源网址 */
298
+ async extractFromTemplate(extractTemplate, baseJPath, data, taskSourceUrl) {
299
+ // let resultXmlFile: string = path.join(foldername, uuid.v1() + '.xml');
300
+ this.taskSourceUrl = taskSourceUrl;
301
+ let skipExtractAction = false;
302
+ const writer = xmlbuilder_1.default.create('Root');
303
+ const root = extractTemplate.getRoot();
304
+ skipExtractAction = await this.extractGroupItem(extractTemplate, root, writer, baseJPath, data);
305
+ if (skipExtractAction) {
306
+ for (const item of extractTemplate.items) {
307
+ writer.ele(item.name);
308
+ }
309
+ }
310
+ const xmlStr = writer.end({ pretty: true });
311
+ return xmlStr;
312
+ }
313
+ isNormalJson(text) {
314
+ if ((0, _1.isNullOrEmpty)(text)) {
315
+ return false;
316
+ }
317
+ const trimText = text.trim();
318
+ if ((0, _1.isNullOrEmpty)(trimText)) {
319
+ return false;
320
+ }
321
+ return trimText[0] == '[' || trimText[0] == '{';
322
+ }
323
+ stripJsonpToJson(text) {
324
+ const start = text.indexOf('(');
325
+ const end = text.lastIndexOf(')');
326
+ const length = text.length;
327
+ const newLen = end - start - 1;
328
+ if (newLen > 1) {
329
+ const str = text.substring(start + 1, end);
330
+ return str;
331
+ }
332
+ return text;
333
+ }
334
+ }
335
+ exports.default = JsonParser;
336
+ class JsonRequest {
337
+ constructor() {
338
+ this.method = HttpMethod.Get;
339
+ this.url = '';
340
+ this.headers = new Map();
341
+ this.body = '';
342
+ }
343
+ addHeader(name, value) {
344
+ if (!(0, _1.isNullOrEmpty)(name)) {
345
+ this.headers.set(name, value === undefined ? '' : value);
346
+ }
347
+ }
348
+ removeHeader(name) {
349
+ if (!(0, _1.isNullOrEmpty)(name) && this.headers.has(name)) {
350
+ this.headers.delete(name);
351
+ }
352
+ }
353
+ getHeaders() {
354
+ return this.headers;
355
+ }
356
+ setBody(body) {
357
+ this.body = body;
358
+ }
359
+ getBody() {
360
+ return this.body;
361
+ }
362
+ }
363
+ exports.JsonRequest = JsonRequest;
364
+ var HttpMethod;
365
+ (function (HttpMethod) {
366
+ HttpMethod["Get"] = "GET";
367
+ HttpMethod["Post"] = "POST";
368
+ })(HttpMethod || (exports.HttpMethod = HttpMethod = {}));
369
+ class JsonNode {
370
+ constructor(jsonpath, name, value, pathItems) {
371
+ this.selected = false;
372
+ this.childs = [];
373
+ this._jsonpath = jsonpath;
374
+ this._name = name;
375
+ this._value = value;
376
+ this._pathItems = pathItems;
377
+ }
378
+ /** 获取json节点的value文本 */
379
+ getValueText() {
380
+ if (typeof this._value == 'object')
381
+ return JSON.stringify(this._value);
382
+ else
383
+ return this._value.toString();
384
+ }
385
+ /** 在json browser上展示的文本 */
386
+ get text() {
387
+ const type = this.type;
388
+ let val = this._value;
389
+ switch (type) {
390
+ case JsonNodeType.Value:
391
+ if (val == null)
392
+ val = '<null>';
393
+ else if (val)
394
+ val = `"${val}"`;
395
+ return `${this._name} : ${val}`;
396
+ case JsonNodeType.Array:
397
+ return `${this._name} [${val.length}]`;
398
+ case JsonNodeType.Object:
399
+ return `${this._name} {${Object.keys(val).length}}`;
400
+ }
401
+ return '';
402
+ }
403
+ get path() {
404
+ return jsonpath_plus_1.JSONPath.toPathString(this._pathItems.map(String));
405
+ }
406
+ get pathItems() {
407
+ return this._pathItems;
408
+ }
409
+ get type() {
410
+ if (Array.isArray(this._value))
411
+ return JsonNodeType.Array;
412
+ if (typeof this._value === 'boolean' ||
413
+ typeof this._value === 'string' ||
414
+ typeof this._value === 'number' ||
415
+ this._value === null)
416
+ return JsonNodeType.Value;
417
+ return JsonNodeType.Object;
418
+ }
419
+ get value() {
420
+ return this._value;
421
+ }
422
+ }
423
+ exports.JsonNode = JsonNode;
424
+ var JsonNodeType;
425
+ (function (JsonNodeType) {
426
+ JsonNodeType["Object"] = "Object";
427
+ JsonNodeType["Array"] = "Array";
428
+ JsonNodeType["Value"] = "Value";
429
+ })(JsonNodeType || (exports.JsonNodeType = JsonNodeType = {}));
430
+ class JsonParsedArgs {
431
+ constructor(url, originText, json, parseSuccess, parseException) {
432
+ this.url = url;
433
+ this.originText = originText;
434
+ this.json = json;
435
+ this.parseSuccess = parseSuccess;
436
+ this.parseException = parseException;
437
+ }
438
+ }
439
+ exports.JsonParsedArgs = JsonParsedArgs;
@@ -0,0 +1,27 @@
1
+ import { Page } from 'puppeteer-core';
2
+ import { ActionItem } from '../models/actionItem';
3
+ /**
4
+ * 判定是否属于“页面上下文暂时不可用”的瞬时错误。
5
+ * 这类错误通常不是 XPath 本身有问题,而是查询发生在 context 重建窗口期。
6
+ */
7
+ export declare function isTransientContextError(error: unknown): boolean;
8
+ /**
9
+ * 根据 ActionItem 获取元素句柄。
10
+ * 这个方法只负责“找元素”,不执行页面内脚本。
11
+ * 如果目标在 iframe 中,会先定位 iframe,再进入 frame 内查找真实元素。
12
+ */
13
+ export declare const getElement: (actionItem: ActionItem, page: Page) => Promise<import("puppeteer-core").ElementHandle<Element>>;
14
+ /**
15
+ * 在目标元素上执行 Puppeteer 的 `$eval` / 其他同类调用。
16
+ * 这里把主文档和 iframe 的分支统一收口,同时把 context 重试放在公共层,
17
+ * 让提取文本、读取属性、页面内局部滚动等调用都复用同一套容错逻辑。
18
+ */
19
+ export declare const processElement: <TFnEle, TFnParam, TFnReturn>(actionItem: ActionItem, page: Page, $type: string, Fn: (ele: TFnEle, value?: TFnParam) => TFnReturn, FnParam?: TFnParam) => Promise<TFnReturn>;
20
+ /**
21
+ * 查询元素,并在需要时先做一次显式等待。
22
+ *
23
+ * 和 getElement 的区别:
24
+ * - getElement:立即查找,偏向“当前时刻有没有”
25
+ * - queryElement:可附带 timeout,偏向“在一小段时间内等它出现”
26
+ */
27
+ export declare const queryElement: (actionItem: ActionItem, page: Page, timeout?: number) => Promise<import("puppeteer-core").ElementHandle<Element>>;
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.queryElement = exports.processElement = exports.getElement = void 0;
4
+ exports.isTransientContextError = isTransientContextError;
5
+ // rebrowser / Puppeteer 在页面跳转、局部刷新、iframe 重建时,
6
+ // 偶发会出现 execution context 短暂失效的问题。
7
+ // 这里统一做一次轻量重试,避免上层把这种瞬时抖动误判成“元素不存在”。
8
+ const CONTEXT_RETRY_COUNT = 3;
9
+ const CONTEXT_RETRY_DELAY_MS = 120;
10
+ /**
11
+ * 判定是否属于“页面上下文暂时不可用”的瞬时错误。
12
+ * 这类错误通常不是 XPath 本身有问题,而是查询发生在 context 重建窗口期。
13
+ */
14
+ function isTransientContextError(error) {
15
+ const message = error instanceof Error
16
+ ? `${error.message}\n${error.stack || ''}`
17
+ : String(error);
18
+ return (message.includes('acquireContextId failed') ||
19
+ message.includes('Execution context was destroyed') ||
20
+ message.includes('Cannot find context with specified id') ||
21
+ message.includes('Inspected target navigated or closed'));
22
+ }
23
+ async function sleep(delay) {
24
+ await new Promise((resolve) => setTimeout(resolve, delay));
25
+ }
26
+ /**
27
+ * 对底层 DOM 访问做短重试。
28
+ * 只重试瞬时 context 错误;真正的业务错误、XPath 错误仍然直接抛出。
29
+ *
30
+ */
31
+ async function withContextRetry(task) {
32
+ let lastError;
33
+ for (let tryCount = 0; tryCount < CONTEXT_RETRY_COUNT; tryCount++) {
34
+ try {
35
+ return await task();
36
+ }
37
+ catch (error) {
38
+ lastError = error;
39
+ if (!isTransientContextError(error) || tryCount === CONTEXT_RETRY_COUNT - 1) {
40
+ throw error;
41
+ }
42
+ await sleep(CONTEXT_RETRY_DELAY_MS * (tryCount + 1));
43
+ }
44
+ }
45
+ throw lastError;
46
+ }
47
+ /**
48
+ * 根据 ActionItem 获取元素句柄。
49
+ * 这个方法只负责“找元素”,不执行页面内脚本。
50
+ * 如果目标在 iframe 中,会先定位 iframe,再进入 frame 内查找真实元素。
51
+ */
52
+ const getElement = async (actionItem, page) => {
53
+ let element = await withContextRetry(() => page.$(`::-p-xpath(${actionItem.AbsXpath})`));
54
+ if (actionItem.IsIFrame) {
55
+ const iframeElement = await withContextRetry(() => page.$(`::-p-xpath(${actionItem.IFrameAbsXPath})`));
56
+ if (iframeElement) {
57
+ const iframe = await iframeElement.contentFrame();
58
+ element = await withContextRetry(() => iframe.$(`::-p-xpath(${actionItem.AbsXpath})`));
59
+ }
60
+ }
61
+ return element;
62
+ };
63
+ exports.getElement = getElement;
64
+ /**
65
+ * 在目标元素上执行 Puppeteer 的 `$eval` / 其他同类调用。
66
+ * 这里把主文档和 iframe 的分支统一收口,同时把 context 重试放在公共层,
67
+ * 让提取文本、读取属性、页面内局部滚动等调用都复用同一套容错逻辑。
68
+ */
69
+ const processElement = async (actionItem, page, $type, Fn, FnParam) => {
70
+ let attributeValue;
71
+ if (actionItem.IsIFrame) {
72
+ const iframeElement = await withContextRetry(() => page.$(`::-p-xpath(${actionItem.IFrameAbsXPath})`));
73
+ if (iframeElement) {
74
+ const iframe = await iframeElement.contentFrame();
75
+ attributeValue = await withContextRetry(() => iframe[$type](`::-p-xpath(${actionItem.AbsXpath})`, Fn, FnParam));
76
+ }
77
+ }
78
+ else {
79
+ attributeValue = await withContextRetry(() => page[$type](`::-p-xpath(${actionItem.AbsXpath})`, Fn, FnParam));
80
+ }
81
+ return attributeValue;
82
+ };
83
+ exports.processElement = processElement;
84
+ /**
85
+ * 查询元素,并在需要时先做一次显式等待。
86
+ *
87
+ * 和 getElement 的区别:
88
+ * - getElement:立即查找,偏向“当前时刻有没有”
89
+ * - queryElement:可附带 timeout,偏向“在一小段时间内等它出现”
90
+ */
91
+ const queryElement = async (actionItem, page, timeout = 0) => {
92
+ const { IsIFrame, AbsXpath, IFrameAbsXPath } = actionItem;
93
+ if (timeout) {
94
+ // 等待阶段仍然只等最外层目标:
95
+ // iframe 场景先确保 iframe 本身可用,后面的 frame.$ 再去定位内部元素。
96
+ await page
97
+ .locator(`::-p-xpath(${IsIFrame ? IFrameAbsXPath : AbsXpath})`)
98
+ .setTimeout(timeout)
99
+ .wait()
100
+ .catch((er) => {
101
+ console.error('等待元素超时', er.message);
102
+ });
103
+ }
104
+ if (IsIFrame) {
105
+ const iframe = await withContextRetry(() => page.$(`::-p-xpath(${IFrameAbsXPath})`));
106
+ const frame = await (iframe === null || iframe === void 0 ? void 0 : iframe.contentFrame());
107
+ const element = frame
108
+ ? await withContextRetry(() => frame.$(`::-p-xpath(${AbsXpath})`))
109
+ : undefined;
110
+ return element;
111
+ }
112
+ const element = await withContextRetry(() => page.$(`::-p-xpath(${AbsXpath})`));
113
+ return element;
114
+ };
115
+ exports.queryElement = queryElement;
@@ -0,0 +1,28 @@
1
+ export declare const parseXML: (xml: string, cb: (er: any, data: any) => void) => void;
2
+ /** 解析 XML 转为对象 */
3
+ export declare const parseXMLToObj: (xml: string) => {
4
+ data: {};
5
+ isAppend: boolean;
6
+ };
7
+ export declare const sleep: (delay?: number) => Promise<void>;
8
+ /** 生成任务流程的全部【提取步骤】的序号映射表 */
9
+ export declare const generateExtractIndexMap: (xml: string) => Map<string, number>;
10
+ export declare const getGlobalCookie: (xml: string) => {
11
+ globalCookie: string;
12
+ isSetGlobalCookie: boolean;
13
+ };
14
+ export declare const isNullOrEmpty: (value?: string) => boolean;
15
+ export declare const correctUrl: (url: string) => string;
16
+ /**
17
+ * 在 Worker 线程中执行耗时的 JavaScript 代码,可以设置超时时间自动结束
18
+ * PS:这个功能目前主要给执行正则表达式时使用,因为 string.replace() 等方法是同步执行,当执行一些用户输入的不可预期的正则表达式时会卡死的当前 UI 线程
19
+ * @see https://skieer.feishu.cn/docs/doccncVezuTFcky9wboyAkCPLuc?sidebarOpen=1
20
+ * @param code 需要执行的代码
21
+ * @param timeout 超时时间,默认为 10s
22
+ */
23
+ export declare const executeJavaScriptInWorker: (code: string, timeout?: number) => Promise<any>;
24
+ export declare const hashCode: (str: string) => number;
25
+ export declare const random: (min: number, max: number) => number;
26
+ /** 转换时间描述文本为标准时间对象 */
27
+ export declare const transformDate: (input: string) => Date | undefined;
28
+ export declare const repairURL: (url: string) => string;