更改处理器上下文类型为TS接口,多项优化:
- 修复Typescript库依赖错误 - 完善注释,格式化代码 - 更新pnpm lock文件版本为9.0
This commit is contained in:
27
src/base.ts
27
src/base.ts
@@ -4,26 +4,39 @@ import { ConfigBase } from "./models/config";
|
||||
/**
|
||||
* 加工处理器上下文
|
||||
*/
|
||||
export abstract class ProcessorContext<TInput,TOutput,TConfig extends ConfigBase>{
|
||||
export interface ProcessorContext<TInput, TOutput, TConfig extends ConfigBase> {
|
||||
/**
|
||||
* 输入数据
|
||||
*/
|
||||
public input?:TInput;
|
||||
input?: TInput;
|
||||
/**
|
||||
* 合并配置文件与临时输入参
|
||||
*/
|
||||
public params?:TConfig;
|
||||
params?: TConfig;
|
||||
/**
|
||||
* 输出数据
|
||||
*/
|
||||
public output?:TOutput;
|
||||
output?: TOutput;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理器基类
|
||||
*/
|
||||
export abstract class ProcessorBase<TInput,TOutput,TConfig extends ConfigBase> {
|
||||
public abstract get name():string;
|
||||
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;
|
||||
public abstract exec(context:ProcessorContext<TInput,TOutput,TConfig>):Promise<void>|void
|
||||
/**
|
||||
* 处理器执行方法
|
||||
* @param context 处理器上下文
|
||||
*/
|
||||
public abstract exec(context: ProcessorContext<TInput, TOutput, TConfig>): Promise<void> | void;
|
||||
}
|
Reference in New Issue
Block a user