新增NCBuilder接口; 优化部分类型定义,格式化代码; Reviewed-on: #11 Reviewed-by: 谢凡 <xief@163.com> Co-authored-by: 2817212736@qq.com <2817212736@qq.com> Co-committed-by: 2817212736@qq.com <2817212736@qq.com>
42 lines
1015 B
TypeScript
42 lines
1015 B
TypeScript
import { ConfigBase } from "./models/config";
|
|
|
|
|
|
/**
|
|
* 加工处理器上下文
|
|
*/
|
|
export interface ProcessorContext<TInput = any, TOutput = any, TConfig extends ConfigBase = ConfigBase> {
|
|
/**
|
|
* 输入数据
|
|
*/
|
|
input?: TInput;
|
|
/**
|
|
* 合并配置文件与临时输入参
|
|
*/
|
|
params?: TConfig;
|
|
/**
|
|
* 输出数据
|
|
*/
|
|
output?: TOutput;
|
|
}
|
|
|
|
/**
|
|
* 处理器基类
|
|
*/
|
|
export abstract class ProcessorBase<TInput, TOutput, TConfig extends ConfigBase> {
|
|
/**
|
|
* 处理器名,推荐使用 kebab-case 命名规则
|
|
* @example handle-ability
|
|
*/
|
|
public abstract get name(): string;
|
|
/**
|
|
* 处理器版本,对处理器进行更新后记得修改版本号
|
|
* 格式使用 semver
|
|
* @default 1.0.0
|
|
*/
|
|
public abstract get version(): string;
|
|
/**
|
|
* 处理器执行方法
|
|
* @param context 处理器上下文
|
|
*/
|
|
public abstract exec(context: ProcessorContext<TInput, TOutput, TConfig>): Promise<void> | void;
|
|
} |