@5minds/processcube_engine
Version:
The ProcessCube Engine. Stores and executes BPMNs.
30 lines • 2.1 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.DefaultActivityExecutionStrategy = void 0;
const processcube_engine_sdk_1 = require("@5minds/processcube_engine_sdk");
const ActivityExecutionStrategy_1 = require("./ActivityExecutionStrategy");
class DefaultActivityExecutionStrategy extends ActivityExecutionStrategy_1.ActivityExecutionStrategy {
async execute(startToken, executionCanceledCallback) {
this.activityHandler.abortSignal.throwIfAborted();
const newActivityInstanceHandler = this.createNewActivityInstanceHandler(this.activityHandler.previousFlowNodeInstanceId);
this.activityInstanceHandlers.push(newActivityInstanceHandler);
return newActivityInstanceHandler.execute(startToken, executionCanceledCallback);
}
async resume(flowNodeInstancesToResume, startToken, resumptionCanceledCallback) {
this.activityHandler.abortSignal.throwIfAborted();
const hasNoFlowNodeInstance = !flowNodeInstancesToResume || flowNodeInstancesToResume.length <= 0;
if (hasNoFlowNodeInstance) {
throw new processcube_engine_sdk_1.InternalServerError('No flowNodeInstances for resuming were supplied.', 'process');
}
const hasTooManyFlowNodeInstances = flowNodeInstancesToResume.length > 1;
if (hasTooManyFlowNodeInstances) {
throw new processcube_engine_sdk_1.InternalServerError(`Too many flowNodeInstances for resuming were supplied. Expected 1, but got ${flowNodeInstancesToResume.length} instead.`, 'process');
}
const flowNodeInstanceForHandler = flowNodeInstancesToResume[0];
const newActivityInstanceHandler = this.createNewActivityInstanceHandler(flowNodeInstanceForHandler.previousFlowNodeInstanceId);
this.activityInstanceHandlers.push(newActivityInstanceHandler);
return newActivityInstanceHandler.resume(flowNodeInstanceForHandler, resumptionCanceledCallback);
}
}
exports.DefaultActivityExecutionStrategy = DefaultActivityExecutionStrategy;
//# sourceMappingURL=DefaultActivityExecutionStrategy.js.map