fix: 修复首次创建任务运行时不自动设置当前运行情况的bug

This commit is contained in:
xiaojunnuo
2024-09-11 18:01:46 +08:00
parent 8ed16b3ea2
commit ecd83ee136
9 changed files with 106 additions and 9 deletions
+2 -1
View File
@@ -12,7 +12,7 @@ import { RegistryItem } from "../registry/index.js";
import { Decorator } from "../decorator/index.js";
import { IEmailService } from "../service/index.js";
import { FileStore } from "./file-store.js";
import { hashUtils } from "../utils/index.js";
import { hashUtils, utils } from "../utils/index.js";
// import { TimeoutPromise } from "../utils/util.promise.js";
export type ExecutorOptions = {
@@ -276,6 +276,7 @@ export class Executor {
rootDir: this.options.fileRootDir,
}),
signal: this.abort.signal,
utils,
};
instance.setCtx(taskCtx);
+15 -1
View File
@@ -7,7 +7,7 @@ import { IEmailService } from "../service/index.js";
import { IContext } from "../core/index.js";
import { ILogger, logger } from "../utils/index.js";
import { HttpClient } from "../utils/util.request";
import { utils } from "../utils/index.js";
export enum ContextScope {
global,
pipeline,
@@ -57,18 +57,32 @@ export type TaskResult = {
pipelineVars: Record<string, any>;
};
export type TaskInstanceContext = {
//流水线定义
pipeline: Pipeline;
//步骤定义
step: Step;
//日志
logger: Logger;
//当前步骤输入参数跟上一次执行比较是否有变化
inputChanged: boolean;
//授权获取服务
accessService: IAccessService;
//邮件服务
emailService: IEmailService;
//流水线上下文
pipelineContext: IContext;
//用户上下文
userContext: IContext;
//http请求客户端
http: HttpClient;
//文件存储
fileStore: FileStore;
//上一次执行结果状态
lastStatus?: Runnable;
//用户取消信号
signal: AbortSignal;
//工具类
utils: typeof utils;
};
export abstract class AbstractTaskPlugin implements ITaskPlugin {
+11 -1
View File
@@ -4,9 +4,19 @@ export * from "./util.request.js";
export * from "./util.log.js";
export * from "./util.file.js";
export * from "./util.sp.js";
export * as promises from "./util.promise.js";
export * from "./util.promise.js";
export * from "./util.hash.js";
import { sp } from "./util.sp.js";
import { hashUtils } from "./util.hash.js";
import { promises } from "./util.promise.js";
import { fileUtils } from "./util.file.js";
import _ from "lodash-es";
export const utils = {
sleep,
http,
sp,
hash: hashUtils,
promises,
file: fileUtils,
_,
};
@@ -24,3 +24,8 @@ export function safePromise<T>(callback: (resolve: (ret: T) => void, reject: (re
}
});
}
export const promises = {
TimeoutPromise,
safePromise,
};