更改处理器上下文类型为TS接口,多项优化:
- 修复Typescript库依赖错误 - 完善注释,格式化代码 - 更新pnpm lock文件版本为9.0
This commit is contained in:
parent
e8ae91bb2a
commit
03229b5f48
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "cut-abstractions",
|
||||
"version": "0.1.5",
|
||||
"version": "0.1.6",
|
||||
"description": "",
|
||||
"files": [
|
||||
"dist/**/*"
|
||||
|
3404
pnpm-lock.yaml
3404
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
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;
|
||||
}
|
@ -11,6 +11,7 @@
|
||||
"module": "commonjs", /* Specify what module code is generated. */
|
||||
// "rootDir": "./", /* Specify the root folder within your source files. */
|
||||
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
||||
"lib": ["DOM", "ES6", "ES2021"],
|
||||
|
||||
/* Emit */
|
||||
"declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
|
||||
|
Loading…
Reference in New Issue
Block a user