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.
- package/README.md +271 -0
- package/RUNTIME_SECURITY_NOTICE.txt +41 -0
- package/SECURITY.md +24 -0
- package/dist/cli/args.js +34 -0
- package/dist/cli/help.js +214 -0
- package/dist/cli/output.js +39 -0
- package/dist/commands/auth.js +283 -0
- package/dist/commands/capabilities.js +118 -0
- package/dist/commands/cloud.js +241 -0
- package/dist/commands/data.js +220 -0
- package/dist/commands/doctor.js +73 -0
- package/dist/commands/env.js +63 -0
- package/dist/commands/local.js +251 -0
- package/dist/commands/run.js +622 -0
- package/dist/commands/runs.js +171 -0
- package/dist/commands/task.js +101 -0
- package/dist/index.js +133 -0
- package/dist/runtime/account-capabilities.js +71 -0
- package/dist/runtime/api-client.js +290 -0
- package/dist/runtime/artifacts.js +33 -0
- package/dist/runtime/auth.js +94 -0
- package/dist/runtime/bridge-hub.js +173 -0
- package/dist/runtime/client-headers.js +23 -0
- package/dist/runtime/cloud-data.js +75 -0
- package/dist/runtime/config.js +48 -0
- package/dist/runtime/data-exporter.js +267 -0
- package/dist/runtime/engine-host.js +449 -0
- package/dist/runtime/local-runs.js +92 -0
- package/dist/runtime/naming.js +13 -0
- package/dist/runtime/run-control.js +363 -0
- package/dist/runtime/run-services.js +380 -0
- package/dist/runtime/security-notice.js +78 -0
- package/dist/runtime/task-definition-provider.js +282 -0
- package/dist/types.js +4 -0
- package/examples/minimal-task.json +6 -0
- package/examples/navigate-example-task.json +6 -0
- package/node_modules/@octopus/bpmn/index.js +3 -0
- package/node_modules/@octopus/bpmn/lib/Context.js +245 -0
- package/node_modules/@octopus/bpmn/lib/Definition.js +258 -0
- package/node_modules/@octopus/bpmn/lib/Engine.js +275 -0
- package/node_modules/@octopus/bpmn/lib/PrematureStopError.js +7 -0
- package/node_modules/@octopus/bpmn/lib/activities/Activity.js +202 -0
- package/node_modules/@octopus/bpmn/lib/activities/BaseProcess.js +308 -0
- package/node_modules/@octopus/bpmn/lib/activities/BaseTask.js +145 -0
- package/node_modules/@octopus/bpmn/lib/activities/BoundaryEvent.js +12 -0
- package/node_modules/@octopus/bpmn/lib/activities/Dummy.js +10 -0
- package/node_modules/@octopus/bpmn/lib/activities/EventDefinition.js +99 -0
- package/node_modules/@octopus/bpmn/lib/activities/Flow.js +52 -0
- package/node_modules/@octopus/bpmn/lib/activities/Form.js +67 -0
- package/node_modules/@octopus/bpmn/lib/activities/InputOutput.js +53 -0
- package/node_modules/@octopus/bpmn/lib/activities/IntermediateCatchEvent.js +12 -0
- package/node_modules/@octopus/bpmn/lib/activities/MessageFlow.js +19 -0
- package/node_modules/@octopus/bpmn/lib/activities/MultiInstanceLoopCharacteristics.js +160 -0
- package/node_modules/@octopus/bpmn/lib/activities/Properties.js +27 -0
- package/node_modules/@octopus/bpmn/lib/activities/SequenceFlow.js +56 -0
- package/node_modules/@octopus/bpmn/lib/activities/ServiceConnector.js +71 -0
- package/node_modules/@octopus/bpmn/lib/context-helper.js +198 -0
- package/node_modules/@octopus/bpmn/lib/events/EndEvent.js +22 -0
- package/node_modules/@octopus/bpmn/lib/events/ErrorEvent.js +41 -0
- package/node_modules/@octopus/bpmn/lib/events/MessageEvent.js +19 -0
- package/node_modules/@octopus/bpmn/lib/events/StartEvent.js +55 -0
- package/node_modules/@octopus/bpmn/lib/events/TimerEvent.js +75 -0
- package/node_modules/@octopus/bpmn/lib/expressions.js +41 -0
- package/node_modules/@octopus/bpmn/lib/gateways/ExclusiveGateway.js +86 -0
- package/node_modules/@octopus/bpmn/lib/gateways/InclusiveGateway.js +56 -0
- package/node_modules/@octopus/bpmn/lib/gateways/ParallelGateway.js +195 -0
- package/node_modules/@octopus/bpmn/lib/getPropertyValue.js +83 -0
- package/node_modules/@octopus/bpmn/lib/index.js +6 -0
- package/node_modules/@octopus/bpmn/lib/mapper.js +55 -0
- package/node_modules/@octopus/bpmn/lib/parameter.js +119 -0
- package/node_modules/@octopus/bpmn/lib/script-helper.js +45 -0
- package/node_modules/@octopus/bpmn/lib/tasks/ManualTask.js +31 -0
- package/node_modules/@octopus/bpmn/lib/tasks/ReceiveTask.js +31 -0
- package/node_modules/@octopus/bpmn/lib/tasks/ScriptTask.js +35 -0
- package/node_modules/@octopus/bpmn/lib/tasks/SendTask.js +16 -0
- package/node_modules/@octopus/bpmn/lib/tasks/ServiceTask.js +68 -0
- package/node_modules/@octopus/bpmn/lib/tasks/SubProcess.js +17 -0
- package/node_modules/@octopus/bpmn/lib/tasks/Task.js +16 -0
- package/node_modules/@octopus/bpmn/lib/tasks/UserTask.js +47 -0
- package/node_modules/@octopus/bpmn/lib/transformer.js +13 -0
- package/node_modules/@octopus/bpmn/lib/validation.js +111 -0
- package/node_modules/@octopus/bpmn/package.json +17 -0
- package/node_modules/@octopus/bpmn/types/bpmn.d.ts +85 -0
- package/node_modules/@octopus/engine/README.md +370 -0
- package/node_modules/@octopus/engine/dist/actions/BackPreWebPageAction.d.ts +4 -0
- package/node_modules/@octopus/engine/dist/actions/BackPreWebPageAction.js +1 -0
- package/node_modules/@octopus/engine/dist/actions/BaseAction.d.ts +339 -0
- package/node_modules/@octopus/engine/dist/actions/BaseAction.js +1559 -0
- package/node_modules/@octopus/engine/dist/actions/BranchAction.d.ts +9 -0
- package/node_modules/@octopus/engine/dist/actions/BranchAction.js +1 -0
- package/node_modules/@octopus/engine/dist/actions/ClickAction.d.ts +22 -0
- package/node_modules/@octopus/engine/dist/actions/ClickAction.js +1 -0
- package/node_modules/@octopus/engine/dist/actions/ConditionAction.d.ts +4 -0
- package/node_modules/@octopus/engine/dist/actions/ConditionAction.js +1 -0
- package/node_modules/@octopus/engine/dist/actions/EmptyAction.d.ts +4 -0
- package/node_modules/@octopus/engine/dist/actions/EmptyAction.js +12 -0
- package/node_modules/@octopus/engine/dist/actions/EnterCaptchaAction.d.ts +28 -0
- package/node_modules/@octopus/engine/dist/actions/EnterCaptchaAction.js +1 -0
- package/node_modules/@octopus/engine/dist/actions/EnterTextAction.d.ts +20 -0
- package/node_modules/@octopus/engine/dist/actions/EnterTextAction.js +1 -0
- package/node_modules/@octopus/engine/dist/actions/ExtractDataAction.d.ts +40 -0
- package/node_modules/@octopus/engine/dist/actions/ExtractDataAction.js +1 -0
- package/node_modules/@octopus/engine/dist/actions/LoopAction.d.ts +41 -0
- package/node_modules/@octopus/engine/dist/actions/LoopAction.js +526 -0
- package/node_modules/@octopus/engine/dist/actions/LoopStartAction.d.ts +47 -0
- package/node_modules/@octopus/engine/dist/actions/LoopStartAction.js +607 -0
- package/node_modules/@octopus/engine/dist/actions/MouseOverAction.d.ts +8 -0
- package/node_modules/@octopus/engine/dist/actions/MouseOverAction.js +34 -0
- package/node_modules/@octopus/engine/dist/actions/NavigateAction.d.ts +38 -0
- package/node_modules/@octopus/engine/dist/actions/NavigateAction.js +535 -0
- package/node_modules/@octopus/engine/dist/actions/SwitchComboAction.d.ts +13 -0
- package/node_modules/@octopus/engine/dist/actions/SwitchComboAction.js +69 -0
- package/node_modules/@octopus/engine/dist/browser.d.ts +17 -0
- package/node_modules/@octopus/engine/dist/browser.js +157 -0
- package/node_modules/@octopus/engine/dist/browserProxy.d.ts +90 -0
- package/node_modules/@octopus/engine/dist/browserProxy.js +1 -0
- package/node_modules/@octopus/engine/dist/configs/BaseConfig.d.ts +20 -0
- package/node_modules/@octopus/engine/dist/configs/BaseConfig.js +88 -0
- package/node_modules/@octopus/engine/dist/configs/BranchConfig.d.ts +7 -0
- package/node_modules/@octopus/engine/dist/configs/BranchConfig.js +1 -0
- package/node_modules/@octopus/engine/dist/configs/ClickConfig.d.ts +36 -0
- package/node_modules/@octopus/engine/dist/configs/ClickConfig.js +65 -0
- package/node_modules/@octopus/engine/dist/configs/EnterCaptchaConfig.d.ts +19 -0
- package/node_modules/@octopus/engine/dist/configs/EnterCaptchaConfig.js +25 -0
- package/node_modules/@octopus/engine/dist/configs/EnterTextConfig.d.ts +24 -0
- package/node_modules/@octopus/engine/dist/configs/EnterTextConfig.js +36 -0
- package/node_modules/@octopus/engine/dist/configs/ExtractDataConfig.d.ts +12 -0
- package/node_modules/@octopus/engine/dist/configs/ExtractDataConfig.js +1 -0
- package/node_modules/@octopus/engine/dist/configs/LoopConfig.d.ts +25 -0
- package/node_modules/@octopus/engine/dist/configs/LoopConfig.js +40 -0
- package/node_modules/@octopus/engine/dist/configs/LoopStartConfig.d.ts +4 -0
- package/node_modules/@octopus/engine/dist/configs/LoopStartConfig.js +12 -0
- package/node_modules/@octopus/engine/dist/configs/MouseOverConfig.d.ts +8 -0
- package/node_modules/@octopus/engine/dist/configs/MouseOverConfig.js +15 -0
- package/node_modules/@octopus/engine/dist/configs/NavigateConfig.d.ts +41 -0
- package/node_modules/@octopus/engine/dist/configs/NavigateConfig.js +121 -0
- package/node_modules/@octopus/engine/dist/configs/SwitchComboConfig.d.ts +8 -0
- package/node_modules/@octopus/engine/dist/configs/SwitchComboConfig.js +15 -0
- package/node_modules/@octopus/engine/dist/enums/index.d.ts +419 -0
- package/node_modules/@octopus/engine/dist/enums/index.js +314 -0
- package/node_modules/@octopus/engine/dist/extension/BrowserWebSocketTransport-D_zAGZMQ.js +1 -0
- package/node_modules/@octopus/engine/dist/extension/LaunchOptions-DxvePrV4.js +6 -0
- package/node_modules/@octopus/engine/dist/extension/NodeWebSocketTransport-BTgRVB7Z.js +6 -0
- package/node_modules/@octopus/engine/dist/extension/background.js +396 -0
- package/node_modules/@octopus/engine/dist/extension/bidi-C_GIZ8Uz.js +131 -0
- package/node_modules/@octopus/engine/dist/extension/manifest.json +27 -0
- package/node_modules/@octopus/engine/dist/extension/src/content/anti-detection.js +1 -0
- package/node_modules/@octopus/engine/dist/extension-bridge/BaseExtensionBridge.d.ts +21 -0
- package/node_modules/@octopus/engine/dist/extension-bridge/BaseExtensionBridge.js +117 -0
- package/node_modules/@octopus/engine/dist/extension-bridge/SessionExtensionBridge.d.ts +17 -0
- package/node_modules/@octopus/engine/dist/extension-bridge/SessionExtensionBridge.js +29 -0
- package/node_modules/@octopus/engine/dist/extension-bridge/index.d.ts +2 -0
- package/node_modules/@octopus/engine/dist/extension-bridge/index.js +5 -0
- package/node_modules/@octopus/engine/dist/extension-bridge/types.d.ts +159 -0
- package/node_modules/@octopus/engine/dist/extension-bridge/types.js +5 -0
- package/node_modules/@octopus/engine/dist/extensions/ublock-origin/uBlock0.chromium.tar.xz +0 -0
- package/node_modules/@octopus/engine/dist/extensions/ublock-origin-lite/uBOLite.chromium.tar.xz +0 -0
- package/node_modules/@octopus/engine/dist/index.d.ts +169 -0
- package/node_modules/@octopus/engine/dist/index.js +1 -0
- package/node_modules/@octopus/engine/dist/models/actionItem.d.ts +16 -0
- package/node_modules/@octopus/engine/dist/models/actionItem.js +15 -0
- package/node_modules/@octopus/engine/dist/models/conditionCheckArgs.d.ts +11 -0
- package/node_modules/@octopus/engine/dist/models/conditionCheckArgs.js +11 -0
- package/node_modules/@octopus/engine/dist/models/customizeCookie.d.ts +14 -0
- package/node_modules/@octopus/engine/dist/models/customizeCookie.js +6 -0
- package/node_modules/@octopus/engine/dist/models/downloadFileConfig.d.ts +17 -0
- package/node_modules/@octopus/engine/dist/models/downloadFileConfig.js +26 -0
- package/node_modules/@octopus/engine/dist/models/elementNotFoundArgs.d.ts +8 -0
- package/node_modules/@octopus/engine/dist/models/elementNotFoundArgs.js +12 -0
- package/node_modules/@octopus/engine/dist/models/elementNotFoundError.d.ts +2 -0
- package/node_modules/@octopus/engine/dist/models/elementNotFoundError.js +6 -0
- package/node_modules/@octopus/engine/dist/models/extractItem.d.ts +37 -0
- package/node_modules/@octopus/engine/dist/models/extractItem.js +35 -0
- package/node_modules/@octopus/engine/dist/models/extractTemplate.d.ts +11 -0
- package/node_modules/@octopus/engine/dist/models/extractTemplate.js +48 -0
- package/node_modules/@octopus/engine/dist/models/extractTextItem.d.ts +10 -0
- package/node_modules/@octopus/engine/dist/models/extractTextItem.js +17 -0
- package/node_modules/@octopus/engine/dist/models/globalConfig.d.ts +5 -0
- package/node_modules/@octopus/engine/dist/models/globalConfig.js +1 -0
- package/node_modules/@octopus/engine/dist/models/httpHeader.d.ts +4 -0
- package/node_modules/@octopus/engine/dist/models/httpHeader.js +10 -0
- package/node_modules/@octopus/engine/dist/models/operation.d.ts +27 -0
- package/node_modules/@octopus/engine/dist/models/operation.js +242 -0
- package/node_modules/@octopus/engine/dist/models/retryCondition.d.ts +7 -0
- package/node_modules/@octopus/engine/dist/models/retryCondition.js +10 -0
- package/node_modules/@octopus/engine/dist/models/task.d.ts +89 -0
- package/node_modules/@octopus/engine/dist/models/task.js +120 -0
- package/node_modules/@octopus/engine/dist/models/trigger.d.ts +66 -0
- package/node_modules/@octopus/engine/dist/models/trigger.js +117 -0
- package/node_modules/@octopus/engine/dist/package.json +26 -0
- package/node_modules/@octopus/engine/dist/public-types.d.ts +13 -0
- package/node_modules/@octopus/engine/dist/public-types.js +2 -0
- package/node_modules/@octopus/engine/dist/settings.d.ts +41 -0
- package/node_modules/@octopus/engine/dist/settings.js +20 -0
- package/node_modules/@octopus/engine/dist/solvers/captcha/ClickCaptchaSolver.d.ts +6 -0
- package/node_modules/@octopus/engine/dist/solvers/captcha/ClickCaptchaSolver.js +1 -0
- package/node_modules/@octopus/engine/dist/solvers/captcha/HCaptchaSolver.d.ts +4 -0
- package/node_modules/@octopus/engine/dist/solvers/captcha/HCaptchaSolver.js +73 -0
- package/node_modules/@octopus/engine/dist/solvers/captcha/ImageCaptchaSolver.d.ts +2 -0
- package/node_modules/@octopus/engine/dist/solvers/captcha/ImageCaptchaSolver.js +74 -0
- package/node_modules/@octopus/engine/dist/solvers/captcha/RecaptchaSolver.d.ts +9 -0
- package/node_modules/@octopus/engine/dist/solvers/captcha/RecaptchaSolver.js +371 -0
- package/node_modules/@octopus/engine/dist/solvers/captcha/SliderCaptchaSolver.d.ts +6 -0
- package/node_modules/@octopus/engine/dist/solvers/captcha/SliderCaptchaSolver.js +184 -0
- package/node_modules/@octopus/engine/dist/solvers/captcha/SlidingTrajectory.d.ts +50 -0
- package/node_modules/@octopus/engine/dist/solvers/captcha/SlidingTrajectory.js +125 -0
- package/node_modules/@octopus/engine/dist/solvers/captcha/types.d.ts +68 -0
- package/node_modules/@octopus/engine/dist/solvers/captcha/types.js +34 -0
- package/node_modules/@octopus/engine/dist/solvers/captcha/utils.d.ts +2 -0
- package/node_modules/@octopus/engine/dist/solvers/captcha/utils.js +15 -0
- package/node_modules/@octopus/engine/dist/translator/actionFactory.d.ts +6 -0
- package/node_modules/@octopus/engine/dist/translator/actionFactory.js +1 -0
- package/node_modules/@octopus/engine/dist/translator/activityTypeEnum.d.ts +22 -0
- package/node_modules/@octopus/engine/dist/translator/activityTypeEnum.js +1 -0
- package/node_modules/@octopus/engine/dist/translator/backPreWebPageAction.d.ts +5 -0
- package/node_modules/@octopus/engine/dist/translator/backPreWebPageAction.js +1 -0
- package/node_modules/@octopus/engine/dist/translator/baseAction.d.ts +31 -0
- package/node_modules/@octopus/engine/dist/translator/baseAction.js +1 -0
- package/node_modules/@octopus/engine/dist/translator/breakActivity.d.ts +5 -0
- package/node_modules/@octopus/engine/dist/translator/breakActivity.js +1 -0
- package/node_modules/@octopus/engine/dist/translator/clickAction.d.ts +5 -0
- package/node_modules/@octopus/engine/dist/translator/clickAction.js +1 -0
- package/node_modules/@octopus/engine/dist/translator/completeWF.d.ts +5 -0
- package/node_modules/@octopus/engine/dist/translator/completeWF.js +1 -0
- package/node_modules/@octopus/engine/dist/translator/conditionAction.d.ts +6 -0
- package/node_modules/@octopus/engine/dist/translator/conditionAction.js +1 -0
- package/node_modules/@octopus/engine/dist/translator/emptyAction.d.ts +5 -0
- package/node_modules/@octopus/engine/dist/translator/emptyAction.js +1 -0
- package/node_modules/@octopus/engine/dist/translator/enterCapachaAction.d.ts +5 -0
- package/node_modules/@octopus/engine/dist/translator/enterCapachaAction.js +1 -0
- package/node_modules/@octopus/engine/dist/translator/enterTextAction.d.ts +5 -0
- package/node_modules/@octopus/engine/dist/translator/enterTextAction.js +1 -0
- package/node_modules/@octopus/engine/dist/translator/extractDataAction.d.ts +13 -0
- package/node_modules/@octopus/engine/dist/translator/extractDataAction.js +1 -0
- package/node_modules/@octopus/engine/dist/translator/loopAction.d.ts +5 -0
- package/node_modules/@octopus/engine/dist/translator/loopAction.js +1 -0
- package/node_modules/@octopus/engine/dist/translator/mouseOverAction.d.ts +5 -0
- package/node_modules/@octopus/engine/dist/translator/mouseOverAction.js +19 -0
- package/node_modules/@octopus/engine/dist/translator/navigateAction.d.ts +5 -0
- package/node_modules/@octopus/engine/dist/translator/navigateAction.js +117 -0
- package/node_modules/@octopus/engine/dist/translator/rootAction.d.ts +6 -0
- package/node_modules/@octopus/engine/dist/translator/rootAction.js +80 -0
- package/node_modules/@octopus/engine/dist/translator/switchCombo2Action.d.ts +5 -0
- package/node_modules/@octopus/engine/dist/translator/switchCombo2Action.js +19 -0
- package/node_modules/@octopus/engine/dist/translator/translator.d.ts +1 -0
- package/node_modules/@octopus/engine/dist/translator/translator.js +36 -0
- package/node_modules/@octopus/engine/dist/type.d.ts +25 -0
- package/node_modules/@octopus/engine/dist/type.js +2 -0
- package/node_modules/@octopus/engine/dist/types/browser.d.ts +191 -0
- package/node_modules/@octopus/engine/dist/types/browser.js +1 -0
- package/node_modules/@octopus/engine/dist/types/browserManager.d.ts +41 -0
- package/node_modules/@octopus/engine/dist/types/browserManager.js +1 -0
- package/node_modules/@octopus/engine/dist/types/index.d.ts +40 -0
- package/node_modules/@octopus/engine/dist/types/index.js +2 -0
- package/node_modules/@octopus/engine/dist/types/plugin.d.ts +29 -0
- package/node_modules/@octopus/engine/dist/types/plugin.js +2 -0
- package/node_modules/@octopus/engine/dist/utils/AsyncEmitter.d.ts +15 -0
- package/node_modules/@octopus/engine/dist/utils/AsyncEmitter.js +1 -0
- package/node_modules/@octopus/engine/dist/utils/DataStore.d.ts +58 -0
- package/node_modules/@octopus/engine/dist/utils/DataStore.js +1 -0
- package/node_modules/@octopus/engine/dist/utils/DateTimeFormatHelper.d.ts +22 -0
- package/node_modules/@octopus/engine/dist/utils/DateTimeFormatHelper.js +173 -0
- package/node_modules/@octopus/engine/dist/utils/FileDownloader.d.ts +108 -0
- package/node_modules/@octopus/engine/dist/utils/FileDownloader.js +1 -0
- package/node_modules/@octopus/engine/dist/utils/HttpRequester.d.ts +43 -0
- package/node_modules/@octopus/engine/dist/utils/HttpRequester.js +174 -0
- package/node_modules/@octopus/engine/dist/utils/JsonParser.d.ts +95 -0
- package/node_modules/@octopus/engine/dist/utils/JsonParser.js +439 -0
- package/node_modules/@octopus/engine/dist/utils/Operations.d.ts +27 -0
- package/node_modules/@octopus/engine/dist/utils/Operations.js +115 -0
- package/node_modules/@octopus/engine/dist/utils/index.d.ts +28 -0
- package/node_modules/@octopus/engine/dist/utils/index.js +356 -0
- package/node_modules/@octopus/engine/package.json +58 -0
- package/package.json +79 -0
- package/schemas/capabilities-v1.schema.json +234 -0
- package/schemas/detached-bootstrap-v1.schema.json +42 -0
- package/schemas/json-envelope-v1.schema.json +39 -0
- 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,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;
|