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,195 @@
1
+ 'use strict';
2
+
3
+ const Activity = require('../activities/Activity');
4
+
5
+ function ParallelGateway() {
6
+ Activity.apply(this, arguments);
7
+ this.join = this.inbound.length > 1;
8
+ this.fork = this.outbound.length > 1;
9
+ }
10
+
11
+ ParallelGateway.prototype = Object.create(Activity.prototype);
12
+
13
+ ParallelGateway.prototype.run = function() {
14
+ init.call(this);
15
+ continueRun.call(this);
16
+ };
17
+
18
+ function init() {
19
+ if (this.join) {
20
+ if (!this.pendingInbound) {
21
+ this.pendingInbound = this.inbound.slice();
22
+ }
23
+ this.pendingJoin = true;
24
+ }
25
+
26
+ if (this.fork) {
27
+ if (!this.pendingOutbound) {
28
+ this.pendingOutbound = this.outbound.slice();
29
+ }
30
+ this.pendingFork = true;
31
+ }
32
+
33
+ if (!this.discardedInbound) {
34
+ this.discardedInbound = [];
35
+ }
36
+
37
+ this.taken = false;
38
+ Activity.prototype.run.call(this);
39
+ }
40
+
41
+ ParallelGateway.prototype.activate = function() {
42
+ Activity.prototype.activate.apply(this, arguments);
43
+
44
+ this._onOutbound = this.onOutbound.bind(this);
45
+ this.outbound.forEach((flow) => {
46
+ flow.on('taken', this._onOutbound);
47
+ flow.on('discarded', this._onOutbound);
48
+ });
49
+ };
50
+
51
+ ParallelGateway.prototype.deactivate = function() {
52
+ Activity.prototype.deactivate.apply(this, arguments);
53
+ this.outbound.forEach((flow) => {
54
+ flow.removeListener('taken', this._onOutbound);
55
+ flow.removeListener('discarded', this._onOutbound);
56
+ });
57
+ };
58
+
59
+ ParallelGateway.prototype.onInbound = function(flow, rootFlow) {
60
+ if (!this.discardedInbound) {
61
+ init.call(this);
62
+ }
63
+
64
+ if (this.join) {
65
+ return runOnJoinInbound.call(this, flow, rootFlow);
66
+ }
67
+
68
+ return runOnInbound.call(this, flow, rootFlow);
69
+ };
70
+
71
+ function runOnJoinInbound(flow, rootFlow) {
72
+ if (flow.discarded) {
73
+ this.discardedInbound.push(flow);
74
+ }
75
+
76
+ const pendingIndex = this.pendingInbound.indexOf(flow);
77
+ this.pendingInbound.splice(pendingIndex, 1);
78
+
79
+ this._debug(`<${this.id}> join from ${flow.discarded ? 'discarded' : 'taken'} <${flow.id}> - pending ${this.pendingInbound.length}`);
80
+
81
+ if (this.pendingInbound.length === 0) {
82
+ this.pendingJoin = false;
83
+ return continueRun.call(this, rootFlow);
84
+ }
85
+
86
+ if (this.inbound.length - this.pendingInbound.length === 1) {
87
+ this.taken = true;
88
+ this.emit('start', this);
89
+ }
90
+ }
91
+
92
+ function runOnInbound(flow, rootFlow) {
93
+ if (flow.discarded) {
94
+ this.discardedInbound.push(flow);
95
+ }
96
+ return continueRun.call(this, rootFlow);
97
+ }
98
+
99
+
100
+ function continueRun(rootFlow) {
101
+ if (this.pendingJoin) return;
102
+
103
+ if (allInboundDiscarded.call(this)) {
104
+ return this.outbound.forEach((f) => f.discard(rootFlow));
105
+ }
106
+
107
+ if (this.pendingFork) {
108
+ return this.pendingOutbound.forEach((f) => f.take(rootFlow));
109
+ } else if (!this.isEnd) {
110
+ return this.outbound.forEach((f) => f.take(rootFlow));
111
+ }
112
+
113
+ this.complete();
114
+ }
115
+
116
+ ParallelGateway.prototype.onOutbound = function(flow) {
117
+ if (!this.pendingOutbound) return this.complete();
118
+
119
+ const idx = this.pendingOutbound.indexOf(flow);
120
+ this.pendingOutbound.splice(idx, 1);
121
+ this._debug(`<${this.id}> outbound flow <${flow.id}> ${flow.discarded ? 'discarded' : 'taken'} (${this.pendingOutbound.length})`);
122
+
123
+ if (!this.taken) {
124
+ this.taken = true;
125
+ this.emit('start', this);
126
+ }
127
+
128
+ if (this.pendingOutbound.length === 0) {
129
+ this._debug(`<${this.id}> all pending outbound completed`);
130
+ this.complete();
131
+ }
132
+ };
133
+
134
+ ParallelGateway.prototype.complete = function() {
135
+ const discard = allInboundDiscarded.call(this);
136
+
137
+ delete this.pendingInbound;
138
+ delete this.pendingOutbound;
139
+ delete this.discardedInbound;
140
+ this.pendingJoin = false;
141
+ this.pendingFork = false;
142
+
143
+ if (discard) {
144
+ this._debug(`<${this.id}>`, 'was discarded');
145
+ } else {
146
+ this.emit('end', this);
147
+ }
148
+
149
+ this.leave();
150
+ };
151
+
152
+ ParallelGateway.prototype.resume = function(state) {
153
+ if (state.hasOwnProperty('pendingJoin')) {
154
+ this.pendingJoin = state.pendingJoin;
155
+ }
156
+
157
+ if (state.pendingInbound) {
158
+ this.pendingInbound = state.pendingInbound.map((flowId) => this.inbound.find((flow) => flow.id === flowId));
159
+ }
160
+ if (state.discardedInbound) {
161
+ this.discardedInbound = state.discardedInbound.map((flowId) => this.inbound.find((flow) => flow.id === flowId));
162
+ }
163
+ if (state.pendingOutbound) {
164
+ this.pendingOutbound = state.pendingOutbound.map((flowId) => this.outbound.find((flow) => flow.id === flowId));
165
+ }
166
+
167
+ Activity.prototype.resume.apply(this, arguments);
168
+ };
169
+
170
+ ParallelGateway.prototype.getState = function() {
171
+ const state = Activity.prototype.getState.apply(this, arguments);
172
+
173
+ if (this.pendingJoin) {
174
+ state.pendingJoin = this.pendingJoin;
175
+ }
176
+ if (this.pendingInbound) {
177
+ state.pendingInbound = this.pendingInbound.map((flow) => flow.id);
178
+ }
179
+ if (this.discardedInbound) {
180
+ state.discardedInbound = this.discardedInbound.map((flow) => flow.id);
181
+ }
182
+
183
+ if (this.pendingOutbound) {
184
+ state.pendingOutbound = this.pendingOutbound.map((flow) => flow.id);
185
+ }
186
+
187
+ return state;
188
+ };
189
+
190
+ function allInboundDiscarded() {
191
+ if (this.isStart) return false;
192
+ return this.inbound.length === this.discardedInbound.length;
193
+ }
194
+
195
+ module.exports = ParallelGateway;
@@ -0,0 +1,83 @@
1
+ 'use strict';
2
+
3
+ const propertyPattern = /(\w+)\((.*?)(?:\))|(\.|\[|^)(.+?)(?:\]|\[|\.|$)/;
4
+ const stringConstantPattern = /^['"](.*)['"]$/;
5
+ const negativeIndexPattern = /^-\d+$/;
6
+
7
+ function getPropertyValue(obj, propertyPath, defaultValue) {
8
+ if (!obj) return defaultValue;
9
+
10
+ let resultValue;
11
+ let next = iterateProps(obj, obj, propertyPath);
12
+ while (next) {
13
+ resultValue = next.getResult();
14
+ next = next();
15
+ }
16
+ return resultValue !== undefined ? resultValue : defaultValue;
17
+ }
18
+
19
+ function iterateProps(base, obj, propertyPath) {
20
+ let result;
21
+
22
+ const rest = propertyPath.replace(propertyPattern, (match, fnName, args, p, prop) => {
23
+ if (fnName) {
24
+ result = executeFn(getNamedValue(obj, fnName), args, base);
25
+ } else {
26
+ result = getNamedValue(obj, prop);
27
+ }
28
+ return '';
29
+ });
30
+
31
+ if (rest === propertyPath) return;
32
+ if (result === undefined) return;
33
+
34
+ const next = iterateProps.bind(null, base, result, rest);
35
+ next.getResult = () => {
36
+ if (rest !== '') return;
37
+ return result;
38
+ };
39
+
40
+ return next;
41
+ }
42
+
43
+ function executeFn(fn, args, base) {
44
+ if (!fn) return;
45
+
46
+ let callArguments = [];
47
+ if (args) {
48
+ callArguments = callArguments.concat(args.split(','));
49
+ callArguments = callArguments.map((argument) => {
50
+ return getFunctionArgument(base, argument, argument);
51
+ });
52
+ } else {
53
+ callArguments.push(base);
54
+ }
55
+
56
+ return fn.apply(null, callArguments);
57
+ }
58
+
59
+ function getFunctionArgument(obj, argument, defaultValue) {
60
+ const stringMatch = argument.match(stringConstantPattern);
61
+ if (stringMatch) {
62
+ return stringMatch[1];
63
+ }
64
+ return getPropertyValue(obj, argument, defaultValue);
65
+ }
66
+
67
+ function getNamedValue(obj, property) {
68
+ if (Array.isArray(obj)) {
69
+ return getArrayItem(obj, property);
70
+ }
71
+ return obj[property];
72
+ }
73
+
74
+ function getArrayItem(list, idx) {
75
+ if (negativeIndexPattern.test(idx)) {
76
+ const nidx = Number(idx);
77
+ const aidx = nidx === 0 ? 0 : list.length + nidx;
78
+ return list[aidx];
79
+ }
80
+ return list[idx];
81
+ }
82
+
83
+ module.exports = getPropertyValue;
@@ -0,0 +1,6 @@
1
+ 'use strict';
2
+
3
+ exports.Engine = require('./Engine');
4
+ exports.Definition = require('./Definition');
5
+ exports.transformer = require('./transformer');
6
+ exports.validation = require('./validation');
@@ -0,0 +1,55 @@
1
+ 'use strict';
2
+
3
+ const activityTypes = {};
4
+
5
+ module.exports = function fromType(type) {
6
+ const activityType = activityTypes[type];
7
+
8
+ if (!activityType) {
9
+ throw new Error(`Unknown activity type ${type}`);
10
+ }
11
+
12
+ return activityType;
13
+ };
14
+
15
+ module.exports.isTask = function(type) {
16
+ if (!type) return false;
17
+ return /task$/i.test(type);
18
+ };
19
+
20
+ module.exports.Definition = activityTypes['bpmn:Definition'] = require('./Definition');
21
+ module.exports.Process = activityTypes['bpmn:Process'] = require('./activities/BaseProcess');
22
+
23
+ activityTypes['bpmn:SequenceFlow'] = require('./activities/SequenceFlow');
24
+ activityTypes['bpmn:MessageFlow'] = require('./activities/MessageFlow');
25
+
26
+ activityTypes['bpmn:IntermediateCatchEvent'] = require('./activities/IntermediateCatchEvent');
27
+ activityTypes['bpmn:BoundaryEvent'] = require('./activities/BoundaryEvent');
28
+
29
+ activityTypes['bpmn:ExclusiveGateway'] = require('./gateways/ExclusiveGateway');
30
+ activityTypes['bpmn:ParallelGateway'] = require('./gateways/ParallelGateway');
31
+ activityTypes['bpmn:InclusiveGateway'] = require('./gateways/InclusiveGateway');
32
+
33
+ activityTypes['bpmn:ManualTask'] = require('./tasks/ManualTask');
34
+ activityTypes['bpmn:ReceiveTask'] = require('./tasks/ReceiveTask');
35
+ activityTypes['bpmn:SubProcess'] = require('./tasks/SubProcess');
36
+ activityTypes['bpmn:ScriptTask'] = require('./tasks/ScriptTask');
37
+ activityTypes['bpmn:ServiceTask'] = require('./tasks/ServiceTask');
38
+ activityTypes['bpmn:SendTask'] = require('./tasks/SendTask');
39
+ activityTypes['bpmn:Task'] = require('./tasks/Task');
40
+ activityTypes['bpmn:UserTask'] = require('./tasks/UserTask');
41
+
42
+ activityTypes['bpmn:StartEvent'] = require('./events/StartEvent');
43
+ activityTypes['bpmn:EndEvent'] = require('./events/EndEvent');
44
+ activityTypes['bpmn:TimerEventDefinition'] = require('./events/TimerEvent');
45
+ activityTypes['bpmn:ErrorEventDefinition'] = require('./events/ErrorEvent');
46
+ activityTypes['bpmn:MessageEventDefinition'] = require('./events/MessageEvent');
47
+
48
+ activityTypes['bpmn:MultiInstanceLoopCharacteristics'] = require('./activities/MultiInstanceLoopCharacteristics');
49
+ activityTypes['bpmn:DataObjectReference'] = require('./activities/Dummy');
50
+ activityTypes['bpmn:DataObject'] = require('./activities/Dummy');
51
+
52
+ module.exports.ActivityIO = activityTypes ['camunda:inputOutput'] = require('./activities/InputOutput');
53
+ module.exports.ActivityProperties = activityTypes ['camunda:properties'] = require('./activities/Properties');
54
+ module.exports.Form = activityTypes['camunda:formData'] = require('./activities/Form');
55
+ module.exports.ServiceConnector = activityTypes['camunda:Connector'] = require('./activities/ServiceConnector');
@@ -0,0 +1,119 @@
1
+ 'use strict';
2
+
3
+ const debug = require('debug')('bpmn-engine:io:parameter');
4
+ const expressions = require('./expressions');
5
+ const scriptHelper = require('./script-helper');
6
+
7
+ function Parameter(ioParm) {
8
+ const parm = ioParm;
9
+ const name = parm.name;
10
+ const type = parm.$type;
11
+ const valueType = getValueType();
12
+
13
+ debug('init', type, `<${name}>`, `as type ${valueType}`);
14
+
15
+ let script;
16
+ if (valueType === 'script') {
17
+ if (!scriptHelper.isJavascript(parm.definition.scriptFormat)) throw new Error(`Script format ${parm.definition.scriptFormat} is unsupported (${name})`);
18
+ script = scriptHelper.parse(`${name}.io`, parm.definition.value);
19
+ }
20
+
21
+ const entries = getEntries(parm);
22
+
23
+ function getValueType() {
24
+ if (parm.value) {
25
+ return expressions.hasExpression(parm.value) ? 'expression' : 'constant';
26
+ }
27
+ if (parm.definition && parm.definition.$type) {
28
+ return parm.definition.$type.replace('camunda:', '').toLowerCase();
29
+ }
30
+ return 'named';
31
+ }
32
+
33
+ function getMap(message, variablesAndServices) {
34
+ if (!entries) return getNamedValue(message, variablesAndServices);
35
+
36
+ return entries.reduce((result, entry) => {
37
+ result[entry.name] = entry.getInputValue(message, variablesAndServices);
38
+ return result;
39
+ }, {});
40
+ }
41
+
42
+ function getList(message, variablesAndServices) {
43
+ if (!entries) return getNamedValue(message, variablesAndServices);
44
+
45
+ return parm.definition.items.map((entry) => {
46
+ return expressions.hasExpression(entry.value) ? expressions(entry.value, Object.assign({}, message, variablesAndServices)) : entry.value;
47
+ }, {});
48
+ }
49
+
50
+ function getValue(message, variablesAndServices) {
51
+ debug('get', type, `<${name}>`, valueType, 'value');
52
+
53
+ switch (valueType) {
54
+ case 'constant':
55
+ return parm.value;
56
+ case 'expression':
57
+ return expressions(parm.value, Object.assign({}, variablesAndServices, message));
58
+ case 'script':
59
+ debug('execute', `<${name}>`, 'script');
60
+ return scriptHelper.execute(script, variablesAndServices, message);
61
+ case 'map':
62
+ return getMap(message, variablesAndServices);
63
+ case 'list':
64
+ return getList(message, variablesAndServices);
65
+ default:
66
+ return getNamedValue(message, variablesAndServices);
67
+ }
68
+ }
69
+
70
+ function getNamedValue(message, variablesAndServices) {
71
+ if (message && message[parm.name]) {
72
+ return message[parm.name];
73
+ }
74
+ if (variablesAndServices) {
75
+ return variablesAndServices.variables[parm.name];
76
+ }
77
+ }
78
+
79
+ function getOutputValue(resultValue, variablesAndServices) {
80
+ const resultType = Array.isArray(resultValue) ? 'array' : typeof resultValue;
81
+
82
+ switch (resultType) {
83
+ case 'object':
84
+ case 'function':
85
+ return getValue(resultValue, variablesAndServices);
86
+ default:
87
+ return getValue({
88
+ result: resultValue
89
+ }, variablesAndServices);
90
+ }
91
+ }
92
+
93
+ return {
94
+ name: name,
95
+ type: type,
96
+ valueType: valueType,
97
+ getInputValue: getValue,
98
+ getOutputValue: getOutputValue
99
+ };
100
+ }
101
+
102
+ function getEntries(parm) {
103
+ if (!parm.definition) return;
104
+
105
+ let entries;
106
+ if (parm.definition.entries) {
107
+ entries = parm.definition.entries.map((entry) => {
108
+ return Parameter(Object.assign({name: entry.key}, entry));
109
+ });
110
+ } else if (parm.definition.items) {
111
+ entries = parm.definition.items.map((entry, idx) => {
112
+ return Parameter(Object.assign({name: idx}, entry));
113
+ });
114
+ }
115
+
116
+ return entries;
117
+ }
118
+
119
+ module.exports = Parameter;
@@ -0,0 +1,45 @@
1
+ 'use strict';
2
+
3
+ const vm = require('vm');
4
+
5
+ const pub = {};
6
+
7
+ pub.isJavascript = function(scriptType) {
8
+ if (!scriptType) return false;
9
+ return /^javascript$/i.test(scriptType);
10
+ };
11
+
12
+ pub.parse = function(filename, scriptBody) {
13
+ return new vm.Script(scriptBody, {
14
+ filename: filename,
15
+ displayErrors: true
16
+ });
17
+ };
18
+
19
+ pub.execute = function(script, context, messageOrCallback, callback) {
20
+ let message;
21
+ if (typeof messageOrCallback === 'function') {
22
+ callback = messageOrCallback;
23
+ message = {};
24
+ } else {
25
+ message = messageOrCallback;
26
+ }
27
+
28
+ const executionContext = Object.assign({}, message);
29
+ if (context) {
30
+ executionContext.variables = context.variables;
31
+ executionContext.services = context.services;
32
+ }
33
+
34
+ if (callback) {
35
+ executionContext.next = function(err, output) {
36
+ if (err) return callback(new Error(err.message), output);
37
+ callback(null, output);
38
+ };
39
+ }
40
+
41
+ const vmContext = new vm.createContext(executionContext);
42
+ return script.runInContext(vmContext);
43
+ };
44
+
45
+ module.exports = pub;
@@ -0,0 +1,31 @@
1
+ 'use strict';
2
+
3
+ const BaseTask = require('../activities/BaseTask');
4
+
5
+ function ManualTask() {
6
+ BaseTask.apply(this, arguments);
7
+ }
8
+
9
+ ManualTask.prototype = Object.create(BaseTask.prototype);
10
+
11
+ ManualTask.prototype.execute = function() {
12
+ this._debug(`<${this.id}>`, 'execute');
13
+ this.emit('start', this);
14
+ this.waiting = true;
15
+ this.emit('wait', this);
16
+ };
17
+
18
+ ManualTask.prototype.signal = function(input) {
19
+ if (!this.waiting) {
20
+ return this.emit('error', new Error(`<${this.id}> is not waiting`), this);
21
+ }
22
+
23
+ this.waiting = false;
24
+ this.dataOutput = input;
25
+ this.taken = true;
26
+
27
+ this._debug(`<${this.id}>`, 'signaled', input);
28
+ this.complete(input);
29
+ };
30
+
31
+ module.exports = ManualTask;
@@ -0,0 +1,31 @@
1
+ 'use strict';
2
+
3
+ const BaseTask = require('../activities/BaseTask');
4
+
5
+ function ReceiveTask() {
6
+ BaseTask.apply(this, arguments);
7
+ }
8
+
9
+ ReceiveTask.prototype = Object.create(BaseTask.prototype);
10
+
11
+ ReceiveTask.prototype.execute = function() {
12
+ this._debug(`<${this.id}>`, 'execute');
13
+ this.emit('start', this);
14
+ this.waiting = true;
15
+ this.emit('wait', this);
16
+ };
17
+
18
+ ReceiveTask.prototype.signal = function(input) {
19
+ if (!this.waiting) {
20
+ return this.emit('error', new Error(`<${this.id}> is not waiting`), this);
21
+ }
22
+
23
+ this.waiting = false;
24
+ this.dataOutput = input;
25
+ this.taken = true;
26
+
27
+ this._debug(`<${this.id}>`, 'signaled', input);
28
+ this.complete(input);
29
+ };
30
+
31
+ module.exports = ReceiveTask;
@@ -0,0 +1,35 @@
1
+ 'use strict';
2
+
3
+ const BaseTask = require('../activities/BaseTask');
4
+ const scriptHelper = require('../script-helper');
5
+
6
+ function ScriptTask(activity) {
7
+ if (!scriptHelper.isJavascript(activity.scriptFormat)) throw new Error(`Script format ${activity.scriptFormat} is unsupported (<${activity.id}>)`);
8
+
9
+ BaseTask.apply(this, arguments);
10
+ this.script = scriptHelper.parse(`${this.id}.script`, this.activity.script);
11
+ }
12
+
13
+ ScriptTask.prototype = Object.create(BaseTask.prototype);
14
+
15
+ ScriptTask.prototype.execute = function(message) {
16
+ this._debug(`<${this.id}>`, 'execute', message);
17
+ this.taken = true;
18
+ this.inboundMessage = message;
19
+
20
+ this.emit('start', this);
21
+
22
+ const input = this.getInput(message);
23
+
24
+ const executionContext = this.parentContext.getVariablesAndServices();
25
+ this.executeScript(executionContext, input, (err, output) => {
26
+ if (err) this.emit('error', err, this);
27
+ else this.complete(output);
28
+ });
29
+ };
30
+
31
+ ScriptTask.prototype.executeScript = function(variablesAndServices, messageOrCallback, callback) {
32
+ scriptHelper.execute(this.script, variablesAndServices, messageOrCallback, callback);
33
+ };
34
+
35
+ module.exports = ScriptTask;
@@ -0,0 +1,16 @@
1
+ 'use strict';
2
+
3
+ const BaseTask = require('../activities/BaseTask');
4
+
5
+ function SendTask() {
6
+ BaseTask.apply(this, arguments);
7
+ }
8
+
9
+ SendTask.prototype = Object.create(BaseTask.prototype);
10
+
11
+ SendTask.prototype.execute = function(message) {
12
+ this.emit('start', this);
13
+ this.complete(message);
14
+ };
15
+
16
+ module.exports = SendTask;
@@ -0,0 +1,68 @@
1
+ 'use strict';
2
+
3
+ const BaseTask = require('../activities/BaseTask');
4
+ const expressions = require('../expressions');
5
+
6
+ function ServiceTask() {
7
+ BaseTask.apply(this, arguments);
8
+ this.service = getService.call(this, this.activity, this.parentContext);
9
+
10
+ if (!this.service) throw new Error(`No service defined for <${this.id}>`);
11
+
12
+ this.resultVariable = this.activity.resultVariable;
13
+ }
14
+
15
+ ServiceTask.prototype = Object.create(BaseTask.prototype);
16
+
17
+ ServiceTask.prototype.execute = function(message) {
18
+ this._debug(`<${this.id}>`, `execute ${this.service.name}`);
19
+ this.taken = true;
20
+ this.emit('start', this);
21
+
22
+ const scope = this;
23
+
24
+ function serviceCallback(err, serviceResult) {
25
+ if (err) return scope.emit('error', err, scope);
26
+ if (scope.resultVariable) {
27
+ const result = {};
28
+ result[scope.resultVariable] = serviceResult;
29
+ return scope.complete(result);
30
+ }
31
+
32
+ return scope.complete(serviceResult);
33
+ }
34
+
35
+ const input = scope.getInput(message);
36
+ return this.service.execute(this, input, serviceCallback);
37
+ };
38
+
39
+ ServiceTask.prototype.getInput = function(message) {
40
+ if (!this.io) return this.parentContext.getVariablesAndServices(message);
41
+ return this.io.getInput(message, true);
42
+ };
43
+
44
+ function getService(activity, parentContext) {
45
+ if (activity.expression) {
46
+ this._debug(`<${this.id}>`, `use expression ${activity.expression}`);
47
+ return getServiceByExpression.call(this, activity.expression);
48
+ }
49
+
50
+ return parentContext.getElementService(activity);
51
+ }
52
+
53
+ function getServiceByExpression(expression) {
54
+ return {
55
+ name: expression,
56
+ execute: (executeOnBehalfOf, message, callback) => {
57
+ const serviceFn = expressions(expression, executeOnBehalfOf.parentContext.getVariablesAndServices());
58
+ if (typeof serviceFn !== 'function') return this.emit('error', new Error(`Expression ${expression} did not resolve to a function`), this);
59
+
60
+ serviceFn(message, function(err) {
61
+ const args = Array.prototype.slice.call(arguments, 1);
62
+ callback(err, args);
63
+ });
64
+ }
65
+ };
66
+ }
67
+
68
+ module.exports = ServiceTask;