Files
cut-abstractions/src/base.ts
2817212736@qq.com 03229b5f48 更改处理器上下文类型为TS接口,多项优化:
- 修复Typescript库依赖错误
- 完善注释,格式化代码
- 更新pnpm lock文件版本为9.0
2025-07-15 16:13:59 +08:00

42 lines
990 B
TypeScript

import { ConfigBase } from "./models/config";
/**
* 加工处理器上下文
*/
export interface ProcessorContext<TInput, TOutput, TConfig extends 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;
}