-
Notifications
You must be signed in to change notification settings - Fork 70
/
types.ts
74 lines (63 loc) · 2.04 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// Copyright (c) 2023 Sourcefuse Technologies
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
import {AnyObject} from '@loopback/repository';
import {IServiceConfig} from '@sourceloop/core';
import {BPMTask} from './bpm-task';
import {Workflow, WorkflowVersion, WorkflowDto} from '../models';
/* eslint-disable @typescript-eslint/no-explicit-any */
export interface ICommand {
parameters?: any; //NOSONAR
execute(): Promise<any>; //NOSONAR
}
export interface IBPMTask<T, R> {
operation(data?: T, done?: (data: R) => void): void;
command: ICommand;
}
export interface IWorkflowServiceConfig extends IServiceConfig {
useCustomSequence: boolean;
workflowEngineBaseUrl?: string;
}
export interface WorflowManager<T = AnyObject, S = AnyObject> {
getWorkflowById(workflow: Workflow): Promise<Workflow>;
startWorkflow(
input: T,
workflow: Workflow,
version?: WorkflowVersion,
): Promise<S>;
createWorkflow(workflowDto: WorkflowDto): Promise<SuccessResponse>;
updateWorkflow(workflowDto: WorkflowDto): Promise<SuccessResponse>;
deleteWorkflowById(workflow: Workflow): Promise<Workflow>;
deleteWorkflowVersionById?(
version: WorkflowVersion,
): Promise<WorkflowVersion>;
}
export type ExecutionInputValidator<T = AnyObject> = (
schema: AnyObject,
input: T,
) => Promise<boolean>;
export type WorkerRegisterFn<T = AnyObject, R = AnyObject> = (
bpmnName: string,
topicName: string,
commandCtor: BPMTask<T, R>,
) => Promise<void>;
export type WorkerMap<T = AnyObject, R = AnyObject> = {
[workflowName: string]: WorkerNameCmdPair<T, R>[];
};
export type WorkerNameCmdPair<T = AnyObject, R = AnyObject> = {
topic: string;
command: BPMTask<T, R>;
running: boolean;
};
export type WorkerImplementationFn<T = AnyObject, R = AnyObject> = (
worker: WorkerNameCmdPair<T, R>,
) => Promise<void>;
export type SuccessResponse = {
version: number;
provider: string;
processId: string;
externalId: string;
fileRef?: string;
};
export const WorkflowCacheSourceName = 'WorkflowCache';