Files
certd/packages/core/pipeline/src/d.ts/pipeline.ts
T

141 lines
2.3 KiB
TypeScript
Raw Normal View History

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
};
2023-06-25 23:25:56 +08:00
export type FileItem = {
2023-06-27 22:45:27 +08:00
id: string;
2023-06-25 23:25:56 +08:00
filename: string;
path: 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;
2023-07-03 11:16:46 +08:00
timeout?: number;
2022-10-31 15:01:50 +08:00
default?: {
[key: string]: any;
};
2024-07-15 00:30:33 +08:00
context?: Context;
2022-10-26 09:02:47 +08:00
};
2023-06-07 23:10:33 +08:00
export type EmailOptions = {
receivers: string[];
};
2023-06-27 22:45:27 +08:00
export type NotificationWhen = "error" | "success" | "turnToSuccess" | "start";
2023-06-07 23:10:33 +08:00
export type NotificationType = "email" | "url";
export type Notification = {
type: NotificationType;
when: NotificationWhen[];
options: EmailOptions;
};
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[];
notifications?: Notification[];
2022-10-26 09:02:47 +08:00
};
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 {
2023-05-24 15:41:35 +08:00
start = "start",
success = "success",
error = "error",
2023-07-03 11:45:32 +08:00
canceled = "canceled",
2023-05-24 15:41:35 +08:00
skip = "skip",
none = "none",
2022-10-28 16:08:12 +08:00
}
export type HistoryResultGroup = {
[key: string]: {
runnable: Runnable;
res: HistoryResult;
};
};
2022-10-26 09:02:47 +08:00
export type HistoryResult = {
2023-05-24 15:41:35 +08:00
input: any;
output: any;
2023-06-25 23:25:56 +08:00
files?: FileItem[];
2022-10-26 09:02:47 +08:00
/**
* 任务状态
*/
2023-05-24 15:41:35 +08:00
status: ResultType;
2022-10-26 09:02:47 +08:00
startTime: number;
endTime?: number;
/**
* 处理结果
*/
2023-05-24 15:41:35 +08:00
result?: ResultType; //success, error,skip
2022-10-29 01:10:55 +08:00
message?: string;
2022-10-26 09:02:47 +08:00
};
2023-05-24 15:41:35 +08:00
export type RunnableMap = {
[id: string]: Runnable;
};