2022-10-26 09:02:47 +08:00
|
|
|
export enum RunStrategy {
|
|
|
|
|
AlwaysRun,
|
|
|
|
|
SkipWhenSucceed,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export enum ConcurrencyStrategy {
|
|
|
|
|
Serial,
|
|
|
|
|
Parallel,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export enum NextStrategy {
|
|
|
|
|
AllSuccess,
|
|
|
|
|
OneSuccess,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export enum HandlerType {
|
|
|
|
|
//清空后续任务的状态
|
|
|
|
|
ClearFollowStatus,
|
|
|
|
|
SendEmail,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export type EventHandler = {
|
|
|
|
|
type: HandlerType;
|
|
|
|
|
params: {
|
|
|
|
|
[key: string]: any;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export type RunnableStrategy = {
|
2022-10-28 16:08:12 +08:00
|
|
|
runStrategy?: RunStrategy;
|
|
|
|
|
onSuccess?: EventHandler[];
|
|
|
|
|
onError?: EventHandler[];
|
2022-10-26 09:02:47 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export type Step = Runnable & {
|
|
|
|
|
type: string; //插件类型
|
|
|
|
|
input: {
|
|
|
|
|
[key: string]: any;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
export type Task = Runnable & {
|
|
|
|
|
steps: Step[];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export type Stage = Runnable & {
|
|
|
|
|
tasks: Task[];
|
|
|
|
|
concurrency: ConcurrencyStrategy;
|
|
|
|
|
next: NextStrategy;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export type Trigger = {
|
|
|
|
|
id: string;
|
|
|
|
|
title: string;
|
|
|
|
|
cron: string;
|
2022-10-31 15:01:50 +08:00
|
|
|
type: string;
|
2022-10-26 09:02:47 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export type Runnable = {
|
|
|
|
|
id: string;
|
|
|
|
|
title: string;
|
|
|
|
|
strategy?: RunnableStrategy;
|
2022-10-29 01:10:55 +08:00
|
|
|
runnableType?: string; // pipeline, stage, task , step
|
2022-10-30 01:13:08 +08:00
|
|
|
status?: HistoryResult;
|
2022-10-31 15:01:50 +08:00
|
|
|
default?: {
|
|
|
|
|
[key: string]: any;
|
|
|
|
|
};
|
2022-10-26 09:02:47 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export type Pipeline = Runnable & {
|
2022-10-30 01:13:08 +08:00
|
|
|
version?: number;
|
2022-10-30 01:42:10 +08:00
|
|
|
userId: any;
|
2022-10-26 09:02:47 +08:00
|
|
|
stages: Stage[];
|
|
|
|
|
triggers: Trigger[];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export type Context = {
|
|
|
|
|
[key: string]: any;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export type Log = {
|
|
|
|
|
title: string;
|
|
|
|
|
time: number;
|
|
|
|
|
level: string;
|
|
|
|
|
text: string;
|
|
|
|
|
};
|
|
|
|
|
|
2022-10-28 16:08:12 +08:00
|
|
|
export enum ResultType {
|
|
|
|
|
success,
|
|
|
|
|
error,
|
|
|
|
|
skip,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export type HistoryResultGroup = {
|
|
|
|
|
[key: string]: {
|
|
|
|
|
runnable: Runnable;
|
|
|
|
|
res: HistoryResult;
|
|
|
|
|
};
|
|
|
|
|
};
|
2022-10-26 09:02:47 +08:00
|
|
|
export type HistoryResult = {
|
|
|
|
|
/**
|
|
|
|
|
* 任务状态
|
|
|
|
|
*/
|
|
|
|
|
status: string;
|
|
|
|
|
startTime: number;
|
|
|
|
|
endTime?: number;
|
|
|
|
|
/**
|
|
|
|
|
* 处理结果
|
|
|
|
|
*/
|
2022-10-29 01:10:55 +08:00
|
|
|
result?: string; //success, error,skip
|
|
|
|
|
message?: string;
|
2022-10-26 09:02:47 +08:00
|
|
|
};
|