@5minds/processcube_engine
Version:
The ProcessCube Engine. Stores and executes BPMNs.
43 lines • 1.82 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ScriptTaskInstanceHandler = void 0;
const AbortablePromise_1 = require("../../../Tools/AbortablePromise");
const ActivityInstanceHandler_1 = require("./ActivityInstanceHandler");
class ScriptTaskInstanceHandler extends ActivityInstanceHandler_1.ActivityInstanceHandler {
loggerNamespace = 'script_task';
get scriptTask() {
return this.flowNode;
}
async runHandler() {
this.logger.debug(`Executing ScriptTask instance`);
const handlerPromise = new AbortablePromise_1.AbortablePromise(async (resolve, reject) => {
try {
this.currentToken = await this.runScript(this.currentToken);
return resolve();
}
catch (error) {
const errorLogPrefix = error.category ? `Failure in ${error.category}: ` : '';
this.logger.error(`${errorLogPrefix}Failed to run script`, {
err: error,
});
return reject(error);
}
}, { signal: this.activityHandler.abortSignal });
return handlerPromise;
}
async runScript(token) {
if (!this.scriptTask.script) {
return undefined;
}
const result = await this.executeRuntimeExpressionOnInstanceContext({
expression: this.scriptTask.script,
currentFlowNode: this.scriptTask,
currentToken: token,
previousFlowNode: this.processInstance.getProcessModelFacade().getPreviousFlowNodesFor(this.flowNode)?.pop(),
allowNonObjectResults: false,
});
return result ?? {};
}
}
exports.ScriptTaskInstanceHandler = ScriptTaskInstanceHandler;
//# sourceMappingURL=ScriptTaskInstanceHandler.js.map