@node-ts/bus-workflow
Version:
A workflow engine for orchestrating logic flows in distributed applications.
38 lines • 1.61 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Workflow = exports.WORKFLOW_STEP_DISCARDED = void 0;
const tslib_1 = require("tslib");
const workflow_data_1 = require("./workflow-data");
const inversify_1 = require("inversify");
exports.WORKFLOW_STEP_DISCARDED = 'discarded';
let Workflow = class Workflow {
/**
* Flags that the workflow is complete, thereby preventing it from reacting to any
* subsequent messages. This should be called as part of the return value of
* a handling function
* @param data Any final modifications to the workflow data that will be persisted
* @example
* \@Handles<TaskRan, TestWorkflowData, 'handleTaskRan'>(TaskRan, event => event.value, 'property1')
* async handleTaskRan (event: TaskRan): Promise<Partial<TestWorkflowData>> {
* return this.complete({ taskRunDuration: event.duration })
* }
*/
complete(data = {}) {
return Object.assign(Object.assign({}, data), { $status: workflow_data_1.WorkflowStatus.Complete });
}
/**
* Tells the workflow engine to avoid persisting state for this workflow step. If this is
* returned in a StartedBy handler, then the handler state will not be created and stored.
* If this is run in a Handles handler, then changes to the state will not be run.
*/
discard() {
return {
$status: workflow_data_1.WorkflowStatus.Discard
};
}
};
Workflow = tslib_1.__decorate([
inversify_1.injectable()
], Workflow);
exports.Workflow = Workflow;
//# sourceMappingURL=workflow.js.map