Files
certd/packages/core/pipeline/src/plugin/api.ts

61 lines
1.0 KiB
TypeScript
Raw Normal View History

2022-10-26 09:02:47 +08:00
import { Registrable } from "../registry";
2022-10-31 21:27:32 +08:00
import { FormItemProps } from "../d.ts";
2022-10-26 09:02:47 +08:00
export enum ContextScope {
global,
pipeline,
runtime,
}
export type Storage = {
scope: ContextScope;
path: string;
};
export type TaskOutputDefine = {
title: string;
value?: any;
storage?: Storage;
};
export type TaskInputDefine = FormItemProps;
export type PluginDefine = Registrable & {
2022-12-27 12:32:09 +08:00
default?: any;
2023-01-07 23:22:02 +08:00
input?: {
2022-10-26 09:02:47 +08:00
[key: string]: TaskInputDefine;
};
2023-01-07 23:22:02 +08:00
output?: {
2022-10-26 09:02:47 +08:00
[key: string]: TaskOutputDefine;
};
2022-12-27 12:32:09 +08:00
2023-01-07 23:22:02 +08:00
autowire?: {
[key: string]: any;
};
2022-10-26 09:02:47 +08:00
};
2023-05-24 15:41:35 +08:00
export type ITaskPlugin = {
2023-05-09 10:16:49 +08:00
onInstance(): Promise<void>;
2022-12-27 12:32:09 +08:00
execute(): Promise<void>;
2023-05-24 15:41:35 +08:00
[key: string]: any;
};
export type TaskResult = {
clearLastStatus?: boolean;
};
export abstract class AbstractTaskPlugin implements ITaskPlugin {
result: TaskResult = {};
clearLastStatus() {
this.result.clearLastStatus = true;
}
async onInstance(): Promise<void> {
return;
}
abstract execute(): Promise<void>;
2022-10-26 09:02:47 +08:00
}
export type OutputVO = {
key: string;
title: string;
value: any;
};