merge(main): 合入 main (v0.8.22) 解决 catalog 灰度开通网关冲突
- 解决 src/domains/platform/workflow/transport/catalog/api.ts 中的冲突, 合并 innerData 解析与 interpretGatewayOutcome 判定逻辑; - 执行 bun install 补齐 qrcode-terminal 依赖; - 全部 1021 个单测通过,tsc --noEmit 校验通过。
This commit is contained in:
commit
c3e39fe77a
53 files changed
+20116
-640
No files matched your search
@@ -1,7 +1,15 @@
|
||||
import ky, { type KyInstance } from "ky";
|
||||
import qrcode from "qrcode-terminal";
|
||||
import { BusinessError, NotFoundError } from "../../core/errors.js";
|
||||
import { importFromLink, type ImportFromLinkOptions } from "../../core/auth/link-import.js";
|
||||
import { loadCorpConfigs, resolveWritableEnterprisesDir, saveCorpConfig } from "../../core/config/loader.js";
|
||||
import { saveAssistPlatformSession } from "../../core/auth/assist-platform-store.js";
|
||||
import {
|
||||
createSsoClient,
|
||||
getSsoQrCode,
|
||||
pollSsoQrCodeStatus,
|
||||
verifySsoTokenOnUnity,
|
||||
} from "../../core/http/sso-client.js";
|
||||
import type { CorpConfig } from "../../core/config/types.js";
|
||||
import {
|
||||
approveAssistTicketApi,
|
||||
@@ -351,8 +359,10 @@ export async function importAssistSessionToLocal(
|
||||
}> {
|
||||
const sessionResult = await generateAssistSession(client, params);
|
||||
|
||||
const importBaseUrl = sessionResult.baseUrl || "https://app.ekuaibao.com";
|
||||
const importOptions: ImportFromLinkOptions = {
|
||||
name: params.saveName,
|
||||
baseUrl: importBaseUrl,
|
||||
overwrite: params.overwrite ?? true,
|
||||
enterprisesDir: params.enterprisesDir,
|
||||
ttl: params.ttl,
|
||||
@@ -361,7 +371,7 @@ export async function importAssistSessionToLocal(
|
||||
|
||||
const linkToImport = sessionResult.loginUrl.includes("accessToken=")
|
||||
? sessionResult.loginUrl
|
||||
: `https://app.ekuaibao.com/web/thirdparty.html?accessToken=${encodeURIComponent(sessionResult.token)}&ekbCorpId=${encodeURIComponent(sessionResult.corporationId)}${sessionResult.staffId ? `&staffId=${encodeURIComponent(sessionResult.staffId)}` : ""}`;
|
||||
: `${importBaseUrl}/web/thirdparty.html?accessToken=${encodeURIComponent(sessionResult.token)}&ekbCorpId=${encodeURIComponent(sessionResult.corporationId)}${sessionResult.staffId ? `&staffId=${encodeURIComponent(sessionResult.staffId)}` : ""}`;
|
||||
|
||||
const previousCorp = loadCorpConfigs(params.enterprisesDir ? [params.enterprisesDir] : undefined)
|
||||
.find((corp) => corp.id === sessionResult.corporationId);
|
||||
@@ -520,3 +530,95 @@ export async function transferAssistTicket(
|
||||
remarks: params.remarks,
|
||||
};
|
||||
}
|
||||
|
||||
export interface AssistQrLoginOptions {
|
||||
timeoutMs?: number;
|
||||
onQrCode?: (qrText: string, dingUrl: string) => void;
|
||||
onProgress?: (elapsedMs: number, remainingMs: number) => void;
|
||||
signal?: AbortSignal;
|
||||
}
|
||||
|
||||
export function generateTerminalQrCode(text: string): Promise<string> {
|
||||
return new Promise((resolve) => {
|
||||
try {
|
||||
qrcode.generate(text, { small: true }, (qr) => {
|
||||
resolve(qr);
|
||||
});
|
||||
} catch {
|
||||
resolve("");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 完整固化的钉钉交互式扫码登录合思协助平台闭环
|
||||
*/
|
||||
export async function loginAssistPlatformByQrCode(
|
||||
options: AssistQrLoginOptions = {}
|
||||
): Promise<{ token: string; userName: string; baseUrl: string }> {
|
||||
const timeoutMs = options.timeoutMs ?? 60000;
|
||||
const ssoClient = createSsoClient();
|
||||
const qrRes = await getSsoQrCode(ssoClient);
|
||||
|
||||
const terminalQr = await generateTerminalQrCode(qrRes.dingUrl);
|
||||
|
||||
if (options.onQrCode) {
|
||||
options.onQrCode(terminalQr, qrRes.dingUrl);
|
||||
}
|
||||
|
||||
const startTime = Date.now();
|
||||
let pollData: any = null;
|
||||
|
||||
while (Date.now() - startTime < timeoutMs) {
|
||||
if (options.signal?.aborted) {
|
||||
throw new BusinessError("扫码登录已取消");
|
||||
}
|
||||
|
||||
await new Promise((resolve) => setTimeout(resolve, 1500));
|
||||
|
||||
const elapsed = Date.now() - startTime;
|
||||
const remaining = Math.max(0, timeoutMs - elapsed);
|
||||
if (options.onProgress) {
|
||||
options.onProgress(elapsed, remaining);
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await pollSsoQrCodeStatus(ssoClient, {
|
||||
cookie: `SSO_SESSION_ID=${qrRes.ssoSessionId}`,
|
||||
signal: options.signal,
|
||||
});
|
||||
|
||||
if (res.code === 0 && res.data && typeof res.data === "object") {
|
||||
pollData = res.data;
|
||||
break;
|
||||
}
|
||||
} catch (err) {
|
||||
if (err instanceof Error && err.name === "AbortError") throw err;
|
||||
// 容错继续轮询
|
||||
}
|
||||
}
|
||||
|
||||
if (!pollData) {
|
||||
throw new BusinessError("钉钉扫码登录超时(超过 60 秒时间窗口),请重新发起登录");
|
||||
}
|
||||
|
||||
const tokenCandidate = pollData.redirect || pollData.token;
|
||||
if (!tokenCandidate) {
|
||||
throw new BusinessError("SSO 认证响应中未包含有效 Token 或跳转链接");
|
||||
}
|
||||
|
||||
const { sessionToken, userName } = await verifySsoTokenOnUnity(tokenCandidate);
|
||||
|
||||
saveAssistPlatformSession({
|
||||
token: sessionToken,
|
||||
userName,
|
||||
baseUrl: "https://unity.ekuaibao.com/api",
|
||||
updatedAt: Date.now(),
|
||||
});
|
||||
|
||||
return {
|
||||
token: sessionToken,
|
||||
userName,
|
||||
baseUrl: "https://unity.ekuaibao.com/api",
|
||||
};
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import type {
|
||||
WorkflowFormSpecComponentLike,
|
||||
AnalyzeWorkflowOptions,
|
||||
} from "./types.js";
|
||||
import { isKnownGrayNodeType } from "../nodes/gray-nodes-catalog.js";
|
||||
|
||||
const KNOWN_TYPES = new Set([
|
||||
"webhook",
|
||||
@@ -473,7 +474,7 @@ export function analyzeWorkflow(
|
||||
message: `${task.type} 控制节点没有子节点`,
|
||||
});
|
||||
}
|
||||
if (!KNOWN_TYPES.has(task.type)) {
|
||||
if (!KNOWN_TYPES.has(task.type) && !isKnownGrayNodeType(task.type)) {
|
||||
addDiagnostic(diagnostics, {
|
||||
severity: "warning",
|
||||
code: "UNKNOWN_TASK_TYPE",
|
||||
|
||||
@@ -1,209 +1,5 @@
|
||||
import { z } from "zod";
|
||||
|
||||
// ── 工作流任务节点(递归、按类型区分)─────────────────────────────────────────
|
||||
|
||||
export const BaseTaskSchema = z.object({
|
||||
name: z.string(),
|
||||
type: z.string(),
|
||||
label: z.string(),
|
||||
desc: z.string().optional(),
|
||||
groupName: z.string(),
|
||||
orderIndex: z.number(),
|
||||
levelIndex: z.array(z.number()),
|
||||
status: z.string(),
|
||||
displayName: z.string().optional(),
|
||||
});
|
||||
|
||||
// 任务节点运行时类型(用于递归结构中的类型标注)
|
||||
export interface WorkflowTask {
|
||||
name: string;
|
||||
type: string;
|
||||
label?: string;
|
||||
desc?: string;
|
||||
groupName: string;
|
||||
orderIndex: number;
|
||||
levelIndex: number[];
|
||||
status: string;
|
||||
displayName?: string;
|
||||
tasks?: WorkflowTask[];
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
// 条件/过滤的递归结构:condition / combineFilters
|
||||
export const FilterConditionSchema = z.object({
|
||||
key: z.string(),
|
||||
value: z.any().optional(),
|
||||
compare: z.string(),
|
||||
});
|
||||
|
||||
export const FilterGroupSchema: z.ZodType<any> = z.lazy(() =>
|
||||
z.object({
|
||||
filters: z.array(z.union([FilterConditionSchema, FilterGroupSchema])),
|
||||
condition: z.string(),
|
||||
})
|
||||
);
|
||||
|
||||
// 字段映射条目的两种形态:只读 key 或 key-value 映射(保留 value 及其余配置项)
|
||||
export const FieldMappingSchema = z.object({
|
||||
key: z.string(),
|
||||
value: z.any().optional(),
|
||||
}).passthrough();
|
||||
|
||||
// 错误处理配置
|
||||
export const OnErrorSchema = z.object({
|
||||
defaultAction: z.string(),
|
||||
});
|
||||
|
||||
// ── 控制节点 ─────────────────────────────────────────────────────────────────
|
||||
|
||||
export const ConditionTaskSchema: z.ZodType<WorkflowTask> = BaseTaskSchema.extend({
|
||||
type: z.literal("condition"),
|
||||
tasksMaxLevel: z.number(),
|
||||
combineFilters: FilterGroupSchema,
|
||||
tasks: z.lazy(() => z.array(WorkflowTaskSchema)),
|
||||
});
|
||||
|
||||
export const EveryTaskSchema: z.ZodType<WorkflowTask> = BaseTaskSchema.extend({
|
||||
type: z.literal("every"),
|
||||
batch: z.boolean(),
|
||||
batchSize: z.number().optional(),
|
||||
mode: z.string(),
|
||||
list: z.string(),
|
||||
filters: z.array(z.any()),
|
||||
tasksMaxLevel: z.number(),
|
||||
tasks: z.lazy(() => z.array(WorkflowTaskSchema)),
|
||||
});
|
||||
|
||||
// ── 触发器节点 ─────────────────────────────────────────────────────────────────
|
||||
|
||||
export const WebhookTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("webhook"),
|
||||
sampleId: z.string(),
|
||||
params: z.array(z.object({ key: z.string(), value: z.string() })),
|
||||
urlPath: z.string(),
|
||||
});
|
||||
|
||||
// ── 动作节点 ─────────────────────────────────────────────────────────────────
|
||||
|
||||
export const StopTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("stop"),
|
||||
});
|
||||
|
||||
export const HttpTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("http"),
|
||||
method: z.string(),
|
||||
url: z.string(),
|
||||
bodyType: z.string().optional(),
|
||||
bodyRaw: z.record(z.string(), z.any()).optional(),
|
||||
header: z.array(z.any()),
|
||||
params: z.array(z.object({ key: z.string(), value: z.string() })),
|
||||
successCode: z.array(z.string()),
|
||||
sampleData: z.record(z.string(), z.any()).optional(),
|
||||
});
|
||||
|
||||
export const FlowDetailTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("flow-detail"),
|
||||
specificationId: z.string(),
|
||||
mapping: z.union([
|
||||
z.boolean(),
|
||||
z.array(z.object({ key: z.string(), value: z.string() })),
|
||||
]),
|
||||
flowCode: z.string(),
|
||||
});
|
||||
|
||||
export const CodeTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("code"),
|
||||
code: z.string(),
|
||||
});
|
||||
|
||||
export const CodeJs2TaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("code-js2"),
|
||||
code: z.string(),
|
||||
mapping: z.array(z.object({ key: z.string(), value: z.string() })).optional(),
|
||||
onError: OnErrorSchema.optional(),
|
||||
});
|
||||
|
||||
export const EkuaibaoDatalinkFilterTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("ekuaibao-datalink-filter"),
|
||||
mode: z.string(),
|
||||
entityId: z.string(),
|
||||
fields: z.array(FieldMappingSchema),
|
||||
filters: z.array(z.any()),
|
||||
selectFields: z.array(z.any()),
|
||||
combineFilters: FilterGroupSchema,
|
||||
orderKey: z.string(),
|
||||
orderMode: z.string(),
|
||||
limitCount: z.string(),
|
||||
onError: OnErrorSchema.optional(),
|
||||
});
|
||||
|
||||
export const EkuaibaoDatalinkCreateTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("ekuaibao-datalink-create"),
|
||||
mode: z.string(),
|
||||
entityId: z.string(),
|
||||
fields: z.array(FieldMappingSchema),
|
||||
filters: z.array(z.any()),
|
||||
combineFilters: FilterGroupSchema,
|
||||
});
|
||||
|
||||
export const DataConvertTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("data-convert"),
|
||||
mode: z.string(),
|
||||
path: z.array(z.string()),
|
||||
fields: z.array(z.object({ key: z.string(), value: z.string() })),
|
||||
onError: OnErrorSchema.optional(),
|
||||
subType: z.string(),
|
||||
itemType: z.string(),
|
||||
targetType: z.string(),
|
||||
feeFormType: z.string(),
|
||||
});
|
||||
|
||||
export const FlowCreateTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("flow-create-task"),
|
||||
specificationId: z.string(),
|
||||
formState: z.string(),
|
||||
form: z.record(z.string(), z.string()),
|
||||
details: z.record(z.string(), z.any()),
|
||||
onError: OnErrorSchema.optional(),
|
||||
});
|
||||
|
||||
export const DynamicDelayTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("task-dynamic-delay"),
|
||||
sleepTime: z.union([z.number(), z.string()]).optional(),
|
||||
});
|
||||
|
||||
// 兜底节点:遇到未收录类型时仍保留全部字段
|
||||
export const UnknownTaskSchema = z
|
||||
.object({
|
||||
name: z.string().default("task"),
|
||||
type: z.string(),
|
||||
label: z.string().optional(),
|
||||
desc: z.string().optional(),
|
||||
groupName: z.string().default("trigger"),
|
||||
orderIndex: z.number().default(0),
|
||||
levelIndex: z.array(z.number()).default([0]),
|
||||
status: z.string().default("active"),
|
||||
displayName: z.string().optional(),
|
||||
})
|
||||
.passthrough();
|
||||
|
||||
// 统一任务节点类型
|
||||
export const WorkflowTaskSchema: z.ZodType<WorkflowTask> = z.union([
|
||||
WebhookTaskSchema,
|
||||
ConditionTaskSchema,
|
||||
EveryTaskSchema,
|
||||
StopTaskSchema,
|
||||
HttpTaskSchema,
|
||||
FlowDetailTaskSchema,
|
||||
CodeTaskSchema,
|
||||
CodeJs2TaskSchema,
|
||||
EkuaibaoDatalinkFilterTaskSchema,
|
||||
EkuaibaoDatalinkCreateTaskSchema,
|
||||
DataConvertTaskSchema,
|
||||
FlowCreateTaskSchema,
|
||||
DynamicDelayTaskSchema,
|
||||
UnknownTaskSchema,
|
||||
]);
|
||||
|
||||
|
||||
export type FilterGroup = z.infer<typeof FilterGroupSchema>;
|
||||
/**
|
||||
* 工作流任务节点统一模型与子节点契约出口
|
||||
* 节点各类型 Schema 与字段已原子化拆分至 ./nodes/ 子目录
|
||||
*/
|
||||
export * from "./nodes/index.js";
|
||||
@@ -0,0 +1,61 @@
|
||||
# 工作流节点原子模型定义(models/nodes)
|
||||
|
||||
本目录将工作流各类型节点的数据模型与 Schema 从原本庞大的单文件按类型原子化拆分,确保各节点具备清晰的强类型边界和独立演进能力。
|
||||
|
||||
## 文件分工
|
||||
|
||||
| 文件 | 节点类型 / 职责 |
|
||||
|---|---|
|
||||
| [common.ts](./common.ts) | 基础任务契约(`BaseTaskSchema`、`WorkflowTask`)、过滤与映射通用 Schema |
|
||||
| [http.ts](./http.ts) | HTTP 请求动作节点(包含 `authId` / `appId` 授权凭证、URL、参数与报文) |
|
||||
| [delay.ts](./delay.ts) | 动态延迟等待节点(`task-dynamic-delay` / `sleepTime`) |
|
||||
| [code.ts](./code.ts) | 脚本代码节点(MVEL `code` / JavaScript `code-js2`) |
|
||||
| [webhook.ts](./webhook.ts) | Webhook 外部触发器节点(`sampleId` / `urlPath`) |
|
||||
| [trigger.ts](./trigger.ts) | 工作流官方触发器全家桶(`clock`、`start`、单据与台账变更触发器等 18 类) |
|
||||
| [stop.ts](./stop.ts) | 终止流程控制节点(`stop`) |
|
||||
| [flow.ts](./flow.ts) | 单据操作节点(`flow-detail` 查询详情 / `flow-create-task` 创建单据 / `flow-update-task` / `recalculate-the-approval-flow` 等) |
|
||||
| [datalink.ts](./datalink.ts) | 数据连接台账与转换节点(`ekuaibao-datalink-filter`、`create`、`edit` 与 `data-convert`) |
|
||||
| [condition.ts](./condition.ts) | 条件分支控制节点工厂(`createConditionTaskSchema`) |
|
||||
| [every.ts](./every.ts) | 依次执行循环控制节点工厂(`createEveryTaskSchema`) |
|
||||
| [control.ts](./control.ts) | 流程控制节点工厂(`if`、`loop`、`while`、`amortization`、`apportion`) |
|
||||
| [message.ts](./message.ts) | 消息与通知节点(`message-dingtalk`、`message-feishu`、`email`、`message`、`message-internet`、`message-outnet`、`oa`) |
|
||||
| [ai.ts](./ai.ts) | AI 智能匹配、提取与大模型节点(`ai-classification`、`ai-extraction`、`ai-attachment`、`ekb-ai`、`dify` 等) |
|
||||
| [org.ts](./org.ts) | 组织架构人员与部门节点(`ekuaibao-staff-filter`、`ekuaibao-staff-detail`、`staff-create`、`department-create` 等) |
|
||||
| [utility.ts](./utility.ts) | 基础通用工具节点(`excel` 导出表格、`aggregation` 分类汇总、`flow-format`、`task-log` 流程日志、`dmn` 等) |
|
||||
| [integration.ts](./integration.ts) | 第三方系统集成与定制数据节点(NetSuite、纷享销客、易桥、天润工单、招商银行等) |
|
||||
| [invoice-tmc.ts](./invoice-tmc.ts) | 发票验真巡检与差旅/TMC行程数据节点(`invoice-verification`、`invoice-inspector` 等) |
|
||||
| [requisition.ts](./requisition.ts) | 申请事项与易商卡/随手记节点(`ekuaibao-requision-detail`、`ekuaibao-ecard-fee-filter` 等) |
|
||||
| [unknown.ts](./unknown.ts) | 兜底节点模型(未知节点类型全透传) |
|
||||
| [index.ts](./index.ts) | 实例化递归容器节点、聚合统一 `WorkflowTaskSchema` 并集中导出 |
|
||||
|
||||
## 核心节点规范详情
|
||||
|
||||
### HTTP 请求节点 (`http.ts`)
|
||||
|
||||
HTTP 动作节点用于调用外部 API 或合思原生 OpenAPI。主要字段如下:
|
||||
|
||||
1. **请求方法 (`method`)**:
|
||||
- 严格枚举:`GET`、`POST`、`PUT`、`PATCH`、`DELETE`
|
||||
- 当为 `POST`、`PUT`、`PATCH` 时显示并支持请求体;为 `GET`、`DELETE` 时不传递请求体。
|
||||
|
||||
2. **连接器与授权联动 (`appId` 与 `authId`)**:
|
||||
- **连接器 (`appId`)**:决定 API 调用的预置鉴权通道与目标服务类型。
|
||||
- 获取接口:`POST /api/easo/dsl/task-openapi/select/appId`
|
||||
- 常见预置连接器代码:
|
||||
- `4`: **费控原生**(`ekuaibao_app`,合思开放平台鉴权,Piper 自动换取并注入 `?accessToken=...`)
|
||||
- `5`: **费控钉钉**
|
||||
- `9`: **纷享销客**
|
||||
- `11`: **ai应用**
|
||||
- `14`: **招商银行商务卡查询**
|
||||
- `15`: **费控企微**
|
||||
- `16`: **开放平台**
|
||||
- **授权实例 (`authId`)**:连接器具体的授权账户或凭据实例。
|
||||
- 获取接口:`POST /api/easo/corpApp/getAuthList`,参数 `{ appId, size: 100 }`
|
||||
- 需携带 Piper `Authorization: Bearer <jwtToken>`。
|
||||
- 必须与选定的 `appId` 配对。如未配置或传错,调用合思开放平台接口时将因缺少凭证报错 `400 缺少accessToken参数`。
|
||||
|
||||
3. **请求体与格式 (`bodyType` / `bodyRaw` / `contentType`)**:
|
||||
- `bodyType` 枚举:`none`、`raw`、`from-data`、`form-urlencoded`(默认 `raw`)
|
||||
- `contentType` 枚举(当 `raw` 时):`application/json`(默认)、`text/plain`、`application/javascript`、`text/html`、`application/xml`
|
||||
- `bodyRaw`:支持直接入参对象或字符串,兼容合思变量插值模板(`@{choose(...)}`)。
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
import { z } from "zod";
|
||||
import { BaseTaskSchema, OnErrorSchema } from "./common.js";
|
||||
|
||||
// ── AI 相关节点 (分类、提取、理解与大模型对接) ──────────────────────────────────
|
||||
|
||||
export const AiClassificationTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("ai-classification"),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const AiExtractionTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("ai-extraction"),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const AiAttachmentTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("ai-attachment"),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const EkbAiTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("ekb-ai"),
|
||||
model: z.string().optional(),
|
||||
prompt: z.string().optional(),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const EkbMinimaxTextTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("ekb-minimax-text"),
|
||||
prompt: z.string().optional(),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const EkbMinimaxPhotoTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("ekb-minimax-photo"),
|
||||
imageUrl: z.string().optional(),
|
||||
prompt: z.string().optional(),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const EkbAiPdfTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("ekb-ai-pdf"),
|
||||
attachmentUrl: z.string().optional(),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const EkbAiUrlTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("ekb-ai-url"),
|
||||
url: z.string().optional(),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const DifyTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("dify"),
|
||||
apiKey: z.string().optional(),
|
||||
inputs: z.record(z.string(), z.any()).optional(),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export type AiClassificationTask = z.infer<typeof AiClassificationTaskSchema>;
|
||||
export type AiExtractionTask = z.infer<typeof AiExtractionTaskSchema>;
|
||||
export type AiAttachmentTask = z.infer<typeof AiAttachmentTaskSchema>;
|
||||
export type EkbAiTask = z.infer<typeof EkbAiTaskSchema>;
|
||||
export type EkbMinimaxTextTask = z.infer<typeof EkbMinimaxTextTaskSchema>;
|
||||
export type EkbMinimaxPhotoTask = z.infer<typeof EkbMinimaxPhotoTaskSchema>;
|
||||
export type EkbAiPdfTask = z.infer<typeof EkbAiPdfTaskSchema>;
|
||||
export type EkbAiUrlTask = z.infer<typeof EkbAiUrlTaskSchema>;
|
||||
export type DifyTask = z.infer<typeof DifyTaskSchema>;
|
||||
@@ -0,0 +1,27 @@
|
||||
import { z } from "zod";
|
||||
import { BaseTaskSchema, OnErrorSchema } from "./common.js";
|
||||
|
||||
// ── 脚本代码节点 (MVEL / JavaScript) ──────────────────────────────────────────
|
||||
|
||||
export const CodeTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("code"),
|
||||
code: z.string(),
|
||||
}).passthrough();
|
||||
|
||||
export const CodeJs2TaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("code-js2"),
|
||||
code: z.string().optional(),
|
||||
mapping: z.array(z.object({ key: z.string(), value: z.string() })).optional(),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const CodeJsTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("code-js"),
|
||||
code: z.string().optional(),
|
||||
mapping: z.array(z.object({ key: z.string(), value: z.string() })).optional(),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export type CodeTask = z.infer<typeof CodeTaskSchema>;
|
||||
export type CodeJs2Task = z.infer<typeof CodeJs2TaskSchema>;
|
||||
export type CodeJsTask = z.infer<typeof CodeJsTaskSchema>;
|
||||
@@ -0,0 +1,57 @@
|
||||
import { z } from "zod";
|
||||
|
||||
// ── 工作流任务节点基础 Schema ─────────────────────────────────────────────────
|
||||
|
||||
export const BaseTaskSchema = z.object({
|
||||
name: z.string(),
|
||||
type: z.string(),
|
||||
label: z.string(),
|
||||
desc: z.string().optional(),
|
||||
groupName: z.string(),
|
||||
orderIndex: z.number(),
|
||||
levelIndex: z.array(z.number()),
|
||||
status: z.string(),
|
||||
displayName: z.string().optional(),
|
||||
}).passthrough();
|
||||
|
||||
// 任务节点运行时类型(用于递归结构中的类型标注)
|
||||
export interface WorkflowTask {
|
||||
name: string;
|
||||
type: string;
|
||||
label?: string;
|
||||
desc?: string;
|
||||
groupName: string;
|
||||
orderIndex: number;
|
||||
levelIndex: number[];
|
||||
status: string;
|
||||
displayName?: string;
|
||||
tasks?: WorkflowTask[];
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
// 条件/过滤的递归结构:condition / combineFilters
|
||||
export const FilterConditionSchema = z.object({
|
||||
key: z.string(),
|
||||
value: z.any().optional(),
|
||||
compare: z.string(),
|
||||
});
|
||||
|
||||
export const FilterGroupSchema: z.ZodType<any> = z.lazy(() =>
|
||||
z.object({
|
||||
filters: z.array(z.union([FilterConditionSchema, FilterGroupSchema])),
|
||||
condition: z.string(),
|
||||
})
|
||||
);
|
||||
|
||||
// 字段映射条目的两种形态:只读 key 或 key-value 映射(保留 value 及其余配置项)
|
||||
export const FieldMappingSchema = z.object({
|
||||
key: z.string(),
|
||||
value: z.any().optional(),
|
||||
}).passthrough();
|
||||
|
||||
// 错误处理配置
|
||||
export const OnErrorSchema = z.object({
|
||||
defaultAction: z.string(),
|
||||
});
|
||||
|
||||
export type FilterGroup = z.infer<typeof FilterGroupSchema>;
|
||||
@@ -0,0 +1,15 @@
|
||||
import { z } from "zod";
|
||||
import { BaseTaskSchema, FilterGroupSchema, type WorkflowTask } from "./common.js";
|
||||
|
||||
// ── 条件分支控制节点 ─────────────────────────────────────────────────────────
|
||||
|
||||
export function createConditionTaskSchema(
|
||||
getTaskSchema: () => z.ZodType<WorkflowTask>
|
||||
): z.ZodType<WorkflowTask> {
|
||||
return BaseTaskSchema.extend({
|
||||
type: z.literal("condition"),
|
||||
tasksMaxLevel: z.number(),
|
||||
combineFilters: FilterGroupSchema,
|
||||
tasks: z.lazy(() => z.array(getTaskSchema())),
|
||||
}).passthrough();
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
import { z } from "zod";
|
||||
import { BaseTaskSchema, type WorkflowTask } from "./common.js";
|
||||
|
||||
// ── 流程控制节点 (if, loop, while, amortization, apportion) ───────────────────
|
||||
|
||||
export function createIfTaskSchema(
|
||||
getTaskSchema: () => z.ZodType<WorkflowTask>
|
||||
): z.ZodType<WorkflowTask> {
|
||||
return BaseTaskSchema.extend({
|
||||
type: z.literal("if"),
|
||||
tasksMaxLevel: z.number().optional(),
|
||||
combineFilters: z.any().optional(),
|
||||
conditions: z.any().optional(),
|
||||
tasks: z.lazy(() => z.array(getTaskSchema())).optional(),
|
||||
}).passthrough();
|
||||
}
|
||||
|
||||
export function createLoopTaskSchema(
|
||||
getTaskSchema: () => z.ZodType<WorkflowTask>
|
||||
): z.ZodType<WorkflowTask> {
|
||||
return BaseTaskSchema.extend({
|
||||
type: z.literal("loop"),
|
||||
list: z.any().optional(),
|
||||
batchSize: z.number().optional(),
|
||||
tasksMaxLevel: z.number().optional(),
|
||||
tasks: z.lazy(() => z.array(getTaskSchema())).optional(),
|
||||
}).passthrough();
|
||||
}
|
||||
|
||||
export function createWhileTaskSchema(
|
||||
getTaskSchema: () => z.ZodType<WorkflowTask>
|
||||
): z.ZodType<WorkflowTask> {
|
||||
return BaseTaskSchema.extend({
|
||||
type: z.literal("while"),
|
||||
combineFilters: z.any().optional(),
|
||||
conditions: z.any().optional(),
|
||||
maxLoop: z.number().optional(),
|
||||
tasksMaxLevel: z.number().optional(),
|
||||
tasks: z.lazy(() => z.array(getTaskSchema())).optional(),
|
||||
}).passthrough();
|
||||
}
|
||||
|
||||
export function createAmortizationTaskSchema(
|
||||
getTaskSchema: () => z.ZodType<WorkflowTask>
|
||||
): z.ZodType<WorkflowTask> {
|
||||
return BaseTaskSchema.extend({
|
||||
type: z.literal("amortization"),
|
||||
tasksMaxLevel: z.number().optional(),
|
||||
tasks: z.lazy(() => z.array(getTaskSchema())).optional(),
|
||||
}).passthrough();
|
||||
}
|
||||
|
||||
export function createApportionTaskSchema(
|
||||
getTaskSchema: () => z.ZodType<WorkflowTask>
|
||||
): z.ZodType<WorkflowTask> {
|
||||
return BaseTaskSchema.extend({
|
||||
type: z.literal("apportion"),
|
||||
tasksMaxLevel: z.number().optional(),
|
||||
tasks: z.lazy(() => z.array(getTaskSchema())).optional(),
|
||||
}).passthrough();
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
import { z } from "zod";
|
||||
import { BaseTaskSchema, FieldMappingSchema, FilterGroupSchema, OnErrorSchema } from "./common.js";
|
||||
|
||||
// ── 数据连接 / 台账与转换节点 ────────────────────────────────────────────────
|
||||
|
||||
export const EkuaibaoDatalinkFilterTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("ekuaibao-datalink-filter"),
|
||||
mode: z.string(),
|
||||
entityId: z.string(),
|
||||
fields: z.array(FieldMappingSchema),
|
||||
filters: z.array(z.any()),
|
||||
selectFields: z.array(z.any()),
|
||||
combineFilters: FilterGroupSchema,
|
||||
orderKey: z.string(),
|
||||
orderMode: z.string(),
|
||||
limitCount: z.string(),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const EkuaibaoDatalinkCreateTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("ekuaibao-datalink-create"),
|
||||
mode: z.string(),
|
||||
entityId: z.string(),
|
||||
fields: z.array(FieldMappingSchema),
|
||||
filters: z.array(z.any()),
|
||||
combineFilters: FilterGroupSchema,
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const EkuaibaoDatalinkEditTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("ekuaibao-datalink-edit"),
|
||||
mode: z.string().optional(),
|
||||
entityId: z.string().optional(),
|
||||
fields: z.array(FieldMappingSchema).optional(),
|
||||
filters: z.array(z.any()).optional(),
|
||||
combineFilters: FilterGroupSchema.optional(),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const DataConvertTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("data-convert"),
|
||||
mode: z.string().optional(),
|
||||
path: z.array(z.string()).optional(),
|
||||
fields: z.array(z.object({ key: z.string(), value: z.string() })).optional(),
|
||||
onError: OnErrorSchema.optional(),
|
||||
subType: z.string().optional(),
|
||||
itemType: z.string().optional(),
|
||||
targetType: z.string().optional(),
|
||||
feeFormType: z.string().optional(),
|
||||
}).passthrough();
|
||||
|
||||
export type EkuaibaoDatalinkFilterTask = z.infer<typeof EkuaibaoDatalinkFilterTaskSchema>;
|
||||
export type EkuaibaoDatalinkCreateTask = z.infer<typeof EkuaibaoDatalinkCreateTaskSchema>;
|
||||
export type EkuaibaoDatalinkEditTask = z.infer<typeof EkuaibaoDatalinkEditTaskSchema>;
|
||||
export type DataConvertTask = z.infer<typeof DataConvertTaskSchema>;
|
||||
@@ -0,0 +1,11 @@
|
||||
import { z } from "zod";
|
||||
import { BaseTaskSchema } from "./common.js";
|
||||
|
||||
// ── 延迟等待节点 ─────────────────────────────────────────────────────────────
|
||||
|
||||
export const DynamicDelayTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("task-dynamic-delay"),
|
||||
sleepTime: z.union([z.number(), z.string()]).optional(),
|
||||
}).passthrough();
|
||||
|
||||
export type DynamicDelayTask = z.infer<typeof DynamicDelayTaskSchema>;
|
||||
@@ -0,0 +1,19 @@
|
||||
import { z } from "zod";
|
||||
import { BaseTaskSchema, type WorkflowTask } from "./common.js";
|
||||
|
||||
// ── 依次执行循环控制节点 ─────────────────────────────────────────────────────
|
||||
|
||||
export function createEveryTaskSchema(
|
||||
getTaskSchema: () => z.ZodType<WorkflowTask>
|
||||
): z.ZodType<WorkflowTask> {
|
||||
return BaseTaskSchema.extend({
|
||||
type: z.literal("every"),
|
||||
batch: z.boolean(),
|
||||
batchSize: z.number().optional(),
|
||||
mode: z.string(),
|
||||
list: z.string(),
|
||||
filters: z.array(z.any()),
|
||||
tasksMaxLevel: z.number(),
|
||||
tasks: z.lazy(() => z.array(getTaskSchema())),
|
||||
}).passthrough();
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
import { z } from "zod";
|
||||
import { BaseTaskSchema, OnErrorSchema } from "./common.js";
|
||||
|
||||
// ── 单据相关节点 (详情查询 / 创建单据) ─────────────────────────────────────────
|
||||
|
||||
export const FlowDetailTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("flow-detail"),
|
||||
specificationId: z.string(),
|
||||
mapping: z.union([
|
||||
z.boolean(),
|
||||
z.array(z.object({ key: z.string(), value: z.string() })),
|
||||
]),
|
||||
flowCode: z.string(),
|
||||
}).passthrough();
|
||||
|
||||
export const FlowCreateTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("flow-create-task"),
|
||||
specificationId: z.string().optional(),
|
||||
formState: z.string().optional(),
|
||||
form: z.record(z.string(), z.any()).optional(),
|
||||
details: z.record(z.string(), z.any()).optional(),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const FlowUpdateTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("flow-update-task"),
|
||||
specificationId: z.string().optional(),
|
||||
formState: z.string().optional(),
|
||||
form: z.record(z.string(), z.any()).optional(),
|
||||
details: z.record(z.string(), z.any()).optional(),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const RecalculateApprovalFlowTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("recalculate-the-approval-flow"),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const FlowListTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("flow-list"),
|
||||
specificationId: z.string().optional(),
|
||||
combineFilters: z.any().optional(),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const FlowDetailVersionedTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("flow-detail-versioned"),
|
||||
specificationId: z.string().optional(),
|
||||
flowCode: z.string().optional(),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const FlowSampleListTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("flow-sample-list"),
|
||||
specificationId: z.string().optional(),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const EbotApprovalFlowTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("ebot-approval-flow"),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const RiskTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("risk"),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export type FlowDetailTask = z.infer<typeof FlowDetailTaskSchema>;
|
||||
export type FlowCreateTask = z.infer<typeof FlowCreateTaskSchema>;
|
||||
export type FlowUpdateTask = z.infer<typeof FlowUpdateTaskSchema>;
|
||||
export type RecalculateApprovalFlowTask = z.infer<typeof RecalculateApprovalFlowTaskSchema>;
|
||||
export type FlowListTask = z.infer<typeof FlowListTaskSchema>;
|
||||
export type FlowDetailVersionedTask = z.infer<typeof FlowDetailVersionedTaskSchema>;
|
||||
export type FlowSampleListTask = z.infer<typeof FlowSampleListTaskSchema>;
|
||||
export type EbotApprovalFlowTask = z.infer<typeof EbotApprovalFlowTaskSchema>;
|
||||
export type RiskTask = z.infer<typeof RiskTaskSchema>;
|
||||
@@ -0,0 +1,38 @@
|
||||
import { z } from "zod";
|
||||
import { BaseTaskSchema } from "./common.js";
|
||||
|
||||
// ── HTTP 请求方法与请求体枚举 ──────────────────────────────────────────────────
|
||||
|
||||
export const HttpMethodSchema = z.enum(["GET", "POST", "PUT", "PATCH", "DELETE"]);
|
||||
export type HttpMethod = z.infer<typeof HttpMethodSchema>;
|
||||
|
||||
export const HttpBodyTypeSchema = z.enum(["none", "raw", "from-data", "form-urlencoded"]);
|
||||
export type HttpBodyType = z.infer<typeof HttpBodyTypeSchema>;
|
||||
|
||||
export const HttpContentTypeSchema = z.enum([
|
||||
"application/json",
|
||||
"text/plain",
|
||||
"application/javascript",
|
||||
"text/html",
|
||||
"application/xml",
|
||||
]);
|
||||
export type HttpContentType = z.infer<typeof HttpContentTypeSchema>;
|
||||
|
||||
// ── HTTP 请求动作节点 ─────────────────────────────────────────────────────────
|
||||
|
||||
export const HttpTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("http"),
|
||||
method: z.union([HttpMethodSchema, z.string()]),
|
||||
url: z.string(),
|
||||
bodyType: z.union([HttpBodyTypeSchema, z.string()]).optional(),
|
||||
bodyRaw: z.union([z.string(), z.record(z.string(), z.any())]).optional(),
|
||||
contentType: z.union([HttpContentTypeSchema, z.string()]).optional(),
|
||||
header: z.array(z.any()),
|
||||
params: z.array(z.object({ key: z.string(), value: z.string() })),
|
||||
successCode: z.array(z.string()),
|
||||
sampleData: z.record(z.string(), z.any()).optional(),
|
||||
authId: z.union([z.number(), z.string()]).optional(),
|
||||
appId: z.union([z.number(), z.string()]).optional(),
|
||||
}).passthrough();
|
||||
|
||||
export type HttpTask = z.infer<typeof HttpTaskSchema>;
|
||||
@@ -0,0 +1,275 @@
|
||||
import { z } from "zod";
|
||||
import type { WorkflowTask } from "./common.js";
|
||||
import { createConditionTaskSchema } from "./condition.js";
|
||||
import { createEveryTaskSchema } from "./every.js";
|
||||
import {
|
||||
createIfTaskSchema,
|
||||
createLoopTaskSchema,
|
||||
createWhileTaskSchema,
|
||||
createAmortizationTaskSchema,
|
||||
createApportionTaskSchema,
|
||||
} from "./control.js";
|
||||
import { WebhookTaskSchema } from "./webhook.js";
|
||||
import {
|
||||
ClockTriggerTaskSchema,
|
||||
StartTriggerTaskSchema,
|
||||
FlowChangeTriggerTaskSchema,
|
||||
EkuaibaoFlowformTriggerTaskSchema,
|
||||
EkuaibaoDatalinkCreateTriggerTaskSchema,
|
||||
EkuaibaoDatalinkChangeTriggerTaskSchema,
|
||||
EkuaibaoDatalinkTimeTriggerTaskSchema,
|
||||
DatalinkButtonTriggerTaskSchema,
|
||||
FxiaokeTriggerTaskSchema,
|
||||
XrxsTriggerTaskSchema,
|
||||
EkuaibaoTmcDatalinkCreateTriggerTaskSchema,
|
||||
EkuaibaoTmcDatalinkChangeTriggerTaskSchema,
|
||||
EkuaibaoTmcDatalinkTimeTriggerTaskSchema,
|
||||
EkuaibaoEbotTriggerTaskSchema,
|
||||
OtherEventTriggerTaskSchema,
|
||||
HabTriggerTaskSchema,
|
||||
EkuaibaoRequisitionTriggerTaskSchema,
|
||||
} from "./trigger.js";
|
||||
import { StopTaskSchema } from "./stop.js";
|
||||
import { HttpTaskSchema } from "./http.js";
|
||||
import {
|
||||
FlowDetailTaskSchema,
|
||||
FlowCreateTaskSchema,
|
||||
FlowUpdateTaskSchema,
|
||||
RecalculateApprovalFlowTaskSchema,
|
||||
FlowListTaskSchema,
|
||||
FlowDetailVersionedTaskSchema,
|
||||
FlowSampleListTaskSchema,
|
||||
EbotApprovalFlowTaskSchema,
|
||||
RiskTaskSchema,
|
||||
} from "./flow.js";
|
||||
import { CodeTaskSchema, CodeJs2TaskSchema, CodeJsTaskSchema } from "./code.js";
|
||||
import {
|
||||
EkuaibaoDatalinkFilterTaskSchema,
|
||||
EkuaibaoDatalinkCreateTaskSchema,
|
||||
EkuaibaoDatalinkEditTaskSchema,
|
||||
DataConvertTaskSchema,
|
||||
} from "./datalink.js";
|
||||
import { DynamicDelayTaskSchema } from "./delay.js";
|
||||
import {
|
||||
MessageDingtalkTaskSchema,
|
||||
MessageFeishuTaskSchema,
|
||||
FeishuSendMsgTaskSchema,
|
||||
MessageSmsTaskSchema,
|
||||
EmailTaskSchema,
|
||||
MessageInternetTaskSchema,
|
||||
MessageOutnetTaskSchema,
|
||||
OaReminderTaskSchema,
|
||||
} from "./message.js";
|
||||
import {
|
||||
AiClassificationTaskSchema,
|
||||
AiExtractionTaskSchema,
|
||||
AiAttachmentTaskSchema,
|
||||
EkbAiTaskSchema,
|
||||
EkbMinimaxTextTaskSchema,
|
||||
EkbMinimaxPhotoTaskSchema,
|
||||
EkbAiPdfTaskSchema,
|
||||
EkbAiUrlTaskSchema,
|
||||
DifyTaskSchema,
|
||||
} from "./ai.js";
|
||||
import {
|
||||
EkuaibaoStaffFilterTaskSchema,
|
||||
EkuaibaoStaffDetailTaskSchema,
|
||||
StaffCreateTaskSchema,
|
||||
DepartmentCreateTaskSchema,
|
||||
DepartmentFilterTaskSchema,
|
||||
EkuaibaoDepartmentDetailTaskSchema,
|
||||
EkuaibaoDepartmentUpdateTaskSchema,
|
||||
FeishuDepartmentFilterTaskSchema,
|
||||
WecomDepartmentTaskSchema,
|
||||
TaskDynamicDingAttendanceTaskSchema,
|
||||
SearchStaffByRoleTaskSchema,
|
||||
RoleUpdateTaskSchema,
|
||||
} from "./org.js";
|
||||
import {
|
||||
ExcelTaskSchema,
|
||||
AggregationTaskSchema,
|
||||
FlowFormatTaskSchema,
|
||||
TaskLogTaskSchema,
|
||||
TaskDynamicTestTaskSchema,
|
||||
TaskOpenapiTaskSchema,
|
||||
ContextTaskSchema,
|
||||
DmnTaskSchema,
|
||||
MappingTaskSchema,
|
||||
UiDialogTaskSchema,
|
||||
UiNotificationTaskSchema,
|
||||
OutputTaskSchema,
|
||||
} from "./utility.js";
|
||||
import {
|
||||
EBridgeMapDataTaskSchema,
|
||||
EBridgeAuthTaskSchema,
|
||||
FxiaokeAuthTaskSchema,
|
||||
FxiaokeListTaskSchema,
|
||||
NetsuiteSyncTaskSchema,
|
||||
NetsuiteCreateTaskSchema,
|
||||
NetsuiteDeleteTaskSchema,
|
||||
TrSelectTaskSchema,
|
||||
TrCommentTaskSchema,
|
||||
TrDetailTaskSchema,
|
||||
TaskZsTaskSchema,
|
||||
EscapeTaskSchema,
|
||||
HlDetailTaskSchema,
|
||||
HlTaskSchema,
|
||||
MappingDetailTaskSchema,
|
||||
} from "./integration.js";
|
||||
import {
|
||||
InvoiceVerificationTaskSchema,
|
||||
EkuaibaoInvoiceInspectorTaskSchema,
|
||||
EkuaibaoInvoiceDatalinkFilterTaskSchema,
|
||||
EkuaibaoTmcDatalinkFilterTaskSchema,
|
||||
} from "./invoice-tmc.js";
|
||||
import {
|
||||
EkuaibaoRequisitionDetailTaskSchema,
|
||||
EkuaibaoEcardFeeFilterTaskSchema,
|
||||
EkuaibaoEcardRequisitionFilterTaskSchema,
|
||||
EkuaibaoEcardFeeDetailFilterTaskSchema,
|
||||
} from "./requisition.js";
|
||||
import { UnknownTaskSchema } from "./unknown.js";
|
||||
|
||||
// 导出所有基础与分类模型
|
||||
export * from "./common.js";
|
||||
export * from "./http.js";
|
||||
export * from "./delay.js";
|
||||
export * from "./code.js";
|
||||
export * from "./webhook.js";
|
||||
export * from "./trigger.js";
|
||||
export * from "./stop.js";
|
||||
export * from "./flow.js";
|
||||
export * from "./datalink.js";
|
||||
export * from "./condition.js";
|
||||
export * from "./every.js";
|
||||
export * from "./control.js";
|
||||
export * from "./message.js";
|
||||
export * from "./ai.js";
|
||||
export * from "./org.js";
|
||||
export * from "./utility.js";
|
||||
export * from "./integration.js";
|
||||
export * from "./invoice-tmc.js";
|
||||
export * from "./requisition.js";
|
||||
export * from "./unknown.js";
|
||||
|
||||
// 递归容器节点 Schema 实例化
|
||||
export const ConditionTaskSchema: z.ZodType<WorkflowTask> = createConditionTaskSchema(() => WorkflowTaskSchema);
|
||||
export const EveryTaskSchema: z.ZodType<WorkflowTask> = createEveryTaskSchema(() => WorkflowTaskSchema);
|
||||
export const IfTaskSchema: z.ZodType<WorkflowTask> = createIfTaskSchema(() => WorkflowTaskSchema);
|
||||
export const LoopTaskSchema: z.ZodType<WorkflowTask> = createLoopTaskSchema(() => WorkflowTaskSchema);
|
||||
export const WhileTaskSchema: z.ZodType<WorkflowTask> = createWhileTaskSchema(() => WorkflowTaskSchema);
|
||||
export const AmortizationTaskSchema: z.ZodType<WorkflowTask> = createAmortizationTaskSchema(() => WorkflowTaskSchema);
|
||||
export const ApportionTaskSchema: z.ZodType<WorkflowTask> = createApportionTaskSchema(() => WorkflowTaskSchema);
|
||||
|
||||
// 统一任务节点联合 Schema
|
||||
export const WorkflowTaskSchema: z.ZodType<WorkflowTask> = z.union([
|
||||
WebhookTaskSchema,
|
||||
ClockTriggerTaskSchema,
|
||||
StartTriggerTaskSchema,
|
||||
FlowChangeTriggerTaskSchema,
|
||||
EkuaibaoFlowformTriggerTaskSchema,
|
||||
EkuaibaoDatalinkCreateTriggerTaskSchema,
|
||||
EkuaibaoDatalinkChangeTriggerTaskSchema,
|
||||
EkuaibaoDatalinkTimeTriggerTaskSchema,
|
||||
DatalinkButtonTriggerTaskSchema,
|
||||
FxiaokeTriggerTaskSchema,
|
||||
XrxsTriggerTaskSchema,
|
||||
EkuaibaoTmcDatalinkCreateTriggerTaskSchema,
|
||||
EkuaibaoTmcDatalinkChangeTriggerTaskSchema,
|
||||
EkuaibaoTmcDatalinkTimeTriggerTaskSchema,
|
||||
EkuaibaoEbotTriggerTaskSchema,
|
||||
OtherEventTriggerTaskSchema,
|
||||
HabTriggerTaskSchema,
|
||||
EkuaibaoRequisitionTriggerTaskSchema,
|
||||
ConditionTaskSchema,
|
||||
EveryTaskSchema,
|
||||
IfTaskSchema,
|
||||
LoopTaskSchema,
|
||||
WhileTaskSchema,
|
||||
AmortizationTaskSchema,
|
||||
ApportionTaskSchema,
|
||||
StopTaskSchema,
|
||||
HttpTaskSchema,
|
||||
FlowDetailTaskSchema,
|
||||
FlowCreateTaskSchema,
|
||||
FlowUpdateTaskSchema,
|
||||
RecalculateApprovalFlowTaskSchema,
|
||||
FlowListTaskSchema,
|
||||
FlowDetailVersionedTaskSchema,
|
||||
FlowSampleListTaskSchema,
|
||||
EbotApprovalFlowTaskSchema,
|
||||
RiskTaskSchema,
|
||||
CodeTaskSchema,
|
||||
CodeJs2TaskSchema,
|
||||
CodeJsTaskSchema,
|
||||
EkuaibaoDatalinkFilterTaskSchema,
|
||||
EkuaibaoDatalinkCreateTaskSchema,
|
||||
EkuaibaoDatalinkEditTaskSchema,
|
||||
DataConvertTaskSchema,
|
||||
DynamicDelayTaskSchema,
|
||||
MessageDingtalkTaskSchema,
|
||||
MessageFeishuTaskSchema,
|
||||
FeishuSendMsgTaskSchema,
|
||||
MessageSmsTaskSchema,
|
||||
EmailTaskSchema,
|
||||
MessageInternetTaskSchema,
|
||||
MessageOutnetTaskSchema,
|
||||
OaReminderTaskSchema,
|
||||
AiClassificationTaskSchema,
|
||||
AiExtractionTaskSchema,
|
||||
AiAttachmentTaskSchema,
|
||||
EkbAiTaskSchema,
|
||||
EkbMinimaxTextTaskSchema,
|
||||
EkbMinimaxPhotoTaskSchema,
|
||||
EkbAiPdfTaskSchema,
|
||||
EkbAiUrlTaskSchema,
|
||||
DifyTaskSchema,
|
||||
EkuaibaoStaffFilterTaskSchema,
|
||||
EkuaibaoStaffDetailTaskSchema,
|
||||
StaffCreateTaskSchema,
|
||||
DepartmentCreateTaskSchema,
|
||||
DepartmentFilterTaskSchema,
|
||||
EkuaibaoDepartmentDetailTaskSchema,
|
||||
EkuaibaoDepartmentUpdateTaskSchema,
|
||||
FeishuDepartmentFilterTaskSchema,
|
||||
WecomDepartmentTaskSchema,
|
||||
TaskDynamicDingAttendanceTaskSchema,
|
||||
SearchStaffByRoleTaskSchema,
|
||||
RoleUpdateTaskSchema,
|
||||
ExcelTaskSchema,
|
||||
AggregationTaskSchema,
|
||||
FlowFormatTaskSchema,
|
||||
TaskLogTaskSchema,
|
||||
TaskDynamicTestTaskSchema,
|
||||
TaskOpenapiTaskSchema,
|
||||
ContextTaskSchema,
|
||||
DmnTaskSchema,
|
||||
MappingTaskSchema,
|
||||
UiDialogTaskSchema,
|
||||
UiNotificationTaskSchema,
|
||||
OutputTaskSchema,
|
||||
EBridgeMapDataTaskSchema,
|
||||
EBridgeAuthTaskSchema,
|
||||
FxiaokeAuthTaskSchema,
|
||||
FxiaokeListTaskSchema,
|
||||
NetsuiteSyncTaskSchema,
|
||||
NetsuiteCreateTaskSchema,
|
||||
NetsuiteDeleteTaskSchema,
|
||||
TrSelectTaskSchema,
|
||||
TrCommentTaskSchema,
|
||||
TrDetailTaskSchema,
|
||||
TaskZsTaskSchema,
|
||||
EscapeTaskSchema,
|
||||
HlDetailTaskSchema,
|
||||
HlTaskSchema,
|
||||
MappingDetailTaskSchema,
|
||||
InvoiceVerificationTaskSchema,
|
||||
EkuaibaoInvoiceInspectorTaskSchema,
|
||||
EkuaibaoInvoiceDatalinkFilterTaskSchema,
|
||||
EkuaibaoTmcDatalinkFilterTaskSchema,
|
||||
EkuaibaoRequisitionDetailTaskSchema,
|
||||
EkuaibaoEcardFeeFilterTaskSchema,
|
||||
EkuaibaoEcardRequisitionFilterTaskSchema,
|
||||
EkuaibaoEcardFeeDetailFilterTaskSchema,
|
||||
UnknownTaskSchema,
|
||||
]);
|
||||
@@ -0,0 +1,95 @@
|
||||
import { z } from "zod";
|
||||
import { BaseTaskSchema, OnErrorSchema } from "./common.js";
|
||||
|
||||
// ── 第三方系统集成与定制数据节点 ─────────────────────────────────────────────
|
||||
|
||||
export const EBridgeMapDataTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("eBridge-mapData"),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const EBridgeAuthTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("ebridge-auth"),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const FxiaokeAuthTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("fxiaoke-auth"),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const FxiaokeListTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("fxiaoke-list"),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const NetsuiteSyncTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("netsuite-sync"),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const NetsuiteCreateTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("netsuite-create"),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const NetsuiteDeleteTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("netsuite-delete"),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const TrSelectTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("tr-select"),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const TrCommentTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("tr-comment"),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const TrDetailTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("tr-detail"),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const TaskZsTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("task-zs"),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const EscapeTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("escape"),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const HlDetailTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("hl-detail"),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const HlTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("hl"),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const MappingDetailTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("mapping-detail"),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export type EBridgeMapDataTask = z.infer<typeof EBridgeMapDataTaskSchema>;
|
||||
export type EBridgeAuthTask = z.infer<typeof EBridgeAuthTaskSchema>;
|
||||
export type FxiaokeAuthTask = z.infer<typeof FxiaokeAuthTaskSchema>;
|
||||
export type FxiaokeListTask = z.infer<typeof FxiaokeListTaskSchema>;
|
||||
export type NetsuiteSyncTask = z.infer<typeof NetsuiteSyncTaskSchema>;
|
||||
export type NetsuiteCreateTask = z.infer<typeof NetsuiteCreateTaskSchema>;
|
||||
export type NetsuiteDeleteTask = z.infer<typeof NetsuiteDeleteTaskSchema>;
|
||||
export type TrSelectTask = z.infer<typeof TrSelectTaskSchema>;
|
||||
export type TrCommentTask = z.infer<typeof TrCommentTaskSchema>;
|
||||
export type TrDetailTask = z.infer<typeof TrDetailTaskSchema>;
|
||||
export type TaskZsTask = z.infer<typeof TaskZsTaskSchema>;
|
||||
export type EscapeTask = z.infer<typeof EscapeTaskSchema>;
|
||||
export type HlDetailTask = z.infer<typeof HlDetailTaskSchema>;
|
||||
export type HlTask = z.infer<typeof HlTaskSchema>;
|
||||
export type MappingDetailTask = z.infer<typeof MappingDetailTaskSchema>;
|
||||
@@ -0,0 +1,31 @@
|
||||
import { z } from "zod";
|
||||
import { BaseTaskSchema, OnErrorSchema } from "./common.js";
|
||||
|
||||
// ── 发票验真巡检与差旅/TMC行程节点 ──────────────────────────────────────────
|
||||
|
||||
export const InvoiceVerificationTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("invoice-verification"),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const EkuaibaoInvoiceInspectorTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("ekuaibao-invoice-inspector"),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const EkuaibaoInvoiceDatalinkFilterTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("ekuaibao-invoice-datalink-filter"),
|
||||
combineFilters: z.any().optional(),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const EkuaibaoTmcDatalinkFilterTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("ekuaibao-tmc-datalink-filter"),
|
||||
combineFilters: z.any().optional(),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export type InvoiceVerificationTask = z.infer<typeof InvoiceVerificationTaskSchema>;
|
||||
export type EkuaibaoInvoiceInspectorTask = z.infer<typeof EkuaibaoInvoiceInspectorTaskSchema>;
|
||||
export type EkuaibaoInvoiceDatalinkFilterTask = z.infer<typeof EkuaibaoInvoiceDatalinkFilterTaskSchema>;
|
||||
export type EkuaibaoTmcDatalinkFilterTask = z.infer<typeof EkuaibaoTmcDatalinkFilterTaskSchema>;
|
||||
@@ -0,0 +1,75 @@
|
||||
import { z } from "zod";
|
||||
import { BaseTaskSchema, OnErrorSchema } from "./common.js";
|
||||
|
||||
// ── 消息通知相关节点 ──────────────────────────────────────────────────────────
|
||||
|
||||
export const MessageDingtalkTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("message-dingtalk"),
|
||||
receiverType: z.string().optional(),
|
||||
receivers: z.array(z.any()).optional(),
|
||||
content: z.string().optional(),
|
||||
title: z.string().optional(),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const MessageFeishuTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("message-feishu"),
|
||||
receiverType: z.string().optional(),
|
||||
receivers: z.array(z.any()).optional(),
|
||||
content: z.string().optional(),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const FeishuSendMsgTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("feishu-sendMsg"),
|
||||
receiverType: z.string().optional(),
|
||||
receivers: z.array(z.any()).optional(),
|
||||
content: z.string().optional(),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const MessageSmsTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("message"),
|
||||
receivers: z.array(z.any()).optional(),
|
||||
content: z.string().optional(),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const EmailTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("email"),
|
||||
receivers: z.array(z.any()).optional(),
|
||||
title: z.string().optional(),
|
||||
content: z.string().optional(),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const MessageInternetTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("message-internet"),
|
||||
receivers: z.array(z.any()).optional(),
|
||||
title: z.string().optional(),
|
||||
content: z.string().optional(),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const MessageOutnetTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("message-outnet"),
|
||||
receivers: z.array(z.any()).optional(),
|
||||
content: z.string().optional(),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const OaReminderTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("oa"),
|
||||
receivers: z.array(z.any()).optional(),
|
||||
content: z.string().optional(),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export type MessageDingtalkTask = z.infer<typeof MessageDingtalkTaskSchema>;
|
||||
export type MessageFeishuTask = z.infer<typeof MessageFeishuTaskSchema>;
|
||||
export type FeishuSendMsgTask = z.infer<typeof FeishuSendMsgTaskSchema>;
|
||||
export type MessageSmsTask = z.infer<typeof MessageSmsTaskSchema>;
|
||||
export type EmailTask = z.infer<typeof EmailTaskSchema>;
|
||||
export type MessageInternetTask = z.infer<typeof MessageInternetTaskSchema>;
|
||||
export type MessageOutnetTask = z.infer<typeof MessageOutnetTaskSchema>;
|
||||
export type OaReminderTask = z.infer<typeof OaReminderTaskSchema>;
|
||||
@@ -0,0 +1,88 @@
|
||||
import { z } from "zod";
|
||||
import { BaseTaskSchema, OnErrorSchema } from "./common.js";
|
||||
|
||||
// ── 组织架构与人员/部门节点 ───────────────────────────────────────────────────
|
||||
|
||||
export const EkuaibaoStaffFilterTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("ekuaibao-staff-filter"),
|
||||
combineFilters: z.any().optional(),
|
||||
filters: z.array(z.any()).optional(),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const EkuaibaoStaffDetailTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("ekuaibao-staff-detail"),
|
||||
staffId: z.string().optional(),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const StaffCreateTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("staff-create"),
|
||||
form: z.record(z.string(), z.any()).optional(),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const DepartmentCreateTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("department-create"),
|
||||
form: z.record(z.string(), z.any()).optional(),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const DepartmentFilterTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("department-filter"),
|
||||
combineFilters: z.any().optional(),
|
||||
filters: z.array(z.any()).optional(),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const EkuaibaoDepartmentDetailTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("ekuaibao-department-detail"),
|
||||
departmentId: z.string().optional(),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const EkuaibaoDepartmentUpdateTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("ekuaibao-department-update"),
|
||||
departmentId: z.string().optional(),
|
||||
form: z.record(z.string(), z.any()).optional(),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const FeishuDepartmentFilterTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("feishu-department-filter"),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const WecomDepartmentTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("wecom-department"),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const TaskDynamicDingAttendanceTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("task-dynamic-ding-attendance"),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const SearchStaffByRoleTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("search-staff-by-role"),
|
||||
roleId: z.string().optional(),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const RoleUpdateTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("role-update"),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export type EkuaibaoStaffFilterTask = z.infer<typeof EkuaibaoStaffFilterTaskSchema>;
|
||||
export type EkuaibaoStaffDetailTask = z.infer<typeof EkuaibaoStaffDetailTaskSchema>;
|
||||
export type StaffCreateTask = z.infer<typeof StaffCreateTaskSchema>;
|
||||
export type DepartmentCreateTask = z.infer<typeof DepartmentCreateTaskSchema>;
|
||||
export type DepartmentFilterTask = z.infer<typeof DepartmentFilterTaskSchema>;
|
||||
export type EkuaibaoDepartmentDetailTask = z.infer<typeof EkuaibaoDepartmentDetailTaskSchema>;
|
||||
export type EkuaibaoDepartmentUpdateTask = z.infer<typeof EkuaibaoDepartmentUpdateTaskSchema>;
|
||||
export type FeishuDepartmentFilterTask = z.infer<typeof FeishuDepartmentFilterTaskSchema>;
|
||||
export type WecomDepartmentTask = z.infer<typeof WecomDepartmentTaskSchema>;
|
||||
export type TaskDynamicDingAttendanceTask = z.infer<typeof TaskDynamicDingAttendanceTaskSchema>;
|
||||
export type SearchStaffByRoleTask = z.infer<typeof SearchStaffByRoleTaskSchema>;
|
||||
export type RoleUpdateTask = z.infer<typeof RoleUpdateTaskSchema>;
|
||||
@@ -0,0 +1,34 @@
|
||||
import { z } from "zod";
|
||||
import { BaseTaskSchema, OnErrorSchema } from "./common.js";
|
||||
|
||||
// ── 申请事项与易商卡/随手记节点 ──────────────────────────────────────────────
|
||||
|
||||
export const EkuaibaoRequisitionDetailTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("ekuaibao-requision-detail"),
|
||||
specificationId: z.string().optional(),
|
||||
requisitionId: z.string().optional(),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const EkuaibaoEcardFeeFilterTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("ekuaibao-ecard-fee-filter"),
|
||||
combineFilters: z.any().optional(),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const EkuaibaoEcardRequisitionFilterTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("ekuaibao-ecard-requisition-filter"),
|
||||
combineFilters: z.any().optional(),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const EkuaibaoEcardFeeDetailFilterTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("ekuaibao-ecard-fee-detail-filter"),
|
||||
combineFilters: z.any().optional(),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export type EkuaibaoRequisitionDetailTask = z.infer<typeof EkuaibaoRequisitionDetailTaskSchema>;
|
||||
export type EkuaibaoEcardFeeFilterTask = z.infer<typeof EkuaibaoEcardFeeFilterTaskSchema>;
|
||||
export type EkuaibaoEcardRequisitionFilterTask = z.infer<typeof EkuaibaoEcardRequisitionFilterTaskSchema>;
|
||||
export type EkuaibaoEcardFeeDetailFilterTask = z.infer<typeof EkuaibaoEcardFeeDetailFilterTaskSchema>;
|
||||
@@ -0,0 +1,10 @@
|
||||
import { z } from "zod";
|
||||
import { BaseTaskSchema } from "./common.js";
|
||||
|
||||
// ── 终止流程节点 ─────────────────────────────────────────────────────────────
|
||||
|
||||
export const StopTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("stop"),
|
||||
}).passthrough();
|
||||
|
||||
export type StopTask = z.infer<typeof StopTaskSchema>;
|
||||
@@ -0,0 +1,114 @@
|
||||
import { z } from "zod";
|
||||
import { BaseTaskSchema } from "./common.js";
|
||||
|
||||
// ── 工作流触发器节点 (全量官方 18 类触发器) ───────────────────────────────────
|
||||
|
||||
export const ClockTriggerTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("clock"),
|
||||
mode: z.string().optional(),
|
||||
triggerDateTime: z.string().optional(),
|
||||
cron: z.string().optional(),
|
||||
timezone: z.string().optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const StartTriggerTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("start"),
|
||||
cron: z.string().optional(),
|
||||
mode: z.string().optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const FlowChangeTriggerTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("flow-change-trigger"),
|
||||
specificationId: z.string().optional(),
|
||||
dateField: z.string().optional(),
|
||||
advanceDays: z.number().optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const EkuaibaoFlowformTriggerTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("ekuaibao-flowform-trigger"),
|
||||
specificationId: z.string().optional(),
|
||||
flowState: z.string().optional(),
|
||||
event: z.string().optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const EkuaibaoDatalinkCreateTriggerTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("ekuaibao-datalink-create-trigger"),
|
||||
datalinkModelId: z.string().optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const EkuaibaoDatalinkChangeTriggerTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("ekuaibao-datalink-change-trigger"),
|
||||
datalinkModelId: z.string().optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const EkuaibaoDatalinkTimeTriggerTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("ekuaibao-datalink-time-trigger"),
|
||||
datalinkModelId: z.string().optional(),
|
||||
dateField: z.string().optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const DatalinkButtonTriggerTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("datalink-button-trigger"),
|
||||
datalinkModelId: z.string().optional(),
|
||||
buttonCode: z.string().optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const FxiaokeTriggerTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("fxiaoke-trigger"),
|
||||
objectDescribeApiName: z.string().optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const XrxsTriggerTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("xrxs-trigger"),
|
||||
event: z.string().optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const EkuaibaoTmcDatalinkCreateTriggerTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("ekuaibao-tmc-datalink-create-trigger"),
|
||||
}).passthrough();
|
||||
|
||||
export const EkuaibaoTmcDatalinkChangeTriggerTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("ekuaibao-tmc-datalink-change-trigger"),
|
||||
}).passthrough();
|
||||
|
||||
export const EkuaibaoTmcDatalinkTimeTriggerTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("ekuaibao-tmc-datalink-time-trigger"),
|
||||
}).passthrough();
|
||||
|
||||
export const EkuaibaoEbotTriggerTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("ekuaibao-ebot-trigger"),
|
||||
botId: z.string().optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const OtherEventTriggerTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("other-event-trigger"),
|
||||
eventType: z.string().optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const HabTriggerTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("hab-trigger-task"),
|
||||
appCode: z.string().optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const EkuaibaoRequisitionTriggerTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("ekuaibao-requisition-trigger"),
|
||||
specificationId: z.string().optional(),
|
||||
}).passthrough();
|
||||
|
||||
export type ClockTriggerTask = z.infer<typeof ClockTriggerTaskSchema>;
|
||||
export type StartTriggerTask = z.infer<typeof StartTriggerTaskSchema>;
|
||||
export type FlowChangeTriggerTask = z.infer<typeof FlowChangeTriggerTaskSchema>;
|
||||
export type EkuaibaoFlowformTriggerTask = z.infer<typeof EkuaibaoFlowformTriggerTaskSchema>;
|
||||
export type EkuaibaoDatalinkCreateTriggerTask = z.infer<typeof EkuaibaoDatalinkCreateTriggerTaskSchema>;
|
||||
export type EkuaibaoDatalinkChangeTriggerTask = z.infer<typeof EkuaibaoDatalinkChangeTriggerTaskSchema>;
|
||||
export type EkuaibaoDatalinkTimeTriggerTask = z.infer<typeof EkuaibaoDatalinkTimeTriggerTaskSchema>;
|
||||
export type DatalinkButtonTriggerTask = z.infer<typeof DatalinkButtonTriggerTaskSchema>;
|
||||
export type FxiaokeTriggerTask = z.infer<typeof FxiaokeTriggerTaskSchema>;
|
||||
export type XrxsTriggerTask = z.infer<typeof XrxsTriggerTaskSchema>;
|
||||
export type EkuaibaoTmcDatalinkCreateTriggerTask = z.infer<typeof EkuaibaoTmcDatalinkCreateTriggerTaskSchema>;
|
||||
export type EkuaibaoTmcDatalinkChangeTriggerTask = z.infer<typeof EkuaibaoTmcDatalinkChangeTriggerTaskSchema>;
|
||||
export type EkuaibaoTmcDatalinkTimeTriggerTask = z.infer<typeof EkuaibaoTmcDatalinkTimeTriggerTaskSchema>;
|
||||
export type EkuaibaoEbotTriggerTask = z.infer<typeof EkuaibaoEbotTriggerTaskSchema>;
|
||||
export type OtherEventTriggerTask = z.infer<typeof OtherEventTriggerTaskSchema>;
|
||||
export type HabTriggerTask = z.infer<typeof HabTriggerTaskSchema>;
|
||||
export type EkuaibaoRequisitionTriggerTask = z.infer<typeof EkuaibaoRequisitionTriggerTaskSchema>;
|
||||
@@ -0,0 +1,19 @@
|
||||
import { z } from "zod";
|
||||
|
||||
// ── 兜底节点:遇到未收录类型时仍保留全部字段 ─────────────────────────────────────
|
||||
|
||||
export const UnknownTaskSchema = z
|
||||
.object({
|
||||
name: z.string().default("task"),
|
||||
type: z.string(),
|
||||
label: z.string().optional(),
|
||||
desc: z.string().optional(),
|
||||
groupName: z.string().default("trigger"),
|
||||
orderIndex: z.number().default(0),
|
||||
levelIndex: z.array(z.number()).default([0]),
|
||||
status: z.string().default("active"),
|
||||
displayName: z.string().optional(),
|
||||
})
|
||||
.passthrough();
|
||||
|
||||
export type UnknownTask = z.infer<typeof UnknownTaskSchema>;
|
||||
@@ -0,0 +1,80 @@
|
||||
import { z } from "zod";
|
||||
import { BaseTaskSchema, OnErrorSchema } from "./common.js";
|
||||
|
||||
// ── 基础通用/工具类节点 ────────────────────────────────────────────────────────
|
||||
|
||||
export const ExcelTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("excel"),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const AggregationTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("aggregation"),
|
||||
list: z.any().optional(),
|
||||
groupBy: z.any().optional(),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const FlowFormatTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("flow-format"),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const TaskLogTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("task-log"),
|
||||
message: z.string().optional(),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const TaskDynamicTestTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("task-dynamic-test"),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const TaskOpenapiTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("task-openapi"),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const ContextTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("context"),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const DmnTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("dmn"),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const MappingTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("mapping"),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const UiDialogTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("ui-dialog"),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const UiNotificationTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("ui-notification"),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export const OutputTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("output"),
|
||||
onError: OnErrorSchema.optional(),
|
||||
}).passthrough();
|
||||
|
||||
export type ExcelTask = z.infer<typeof ExcelTaskSchema>;
|
||||
export type AggregationTask = z.infer<typeof AggregationTaskSchema>;
|
||||
export type FlowFormatTask = z.infer<typeof FlowFormatTaskSchema>;
|
||||
export type TaskLogTask = z.infer<typeof TaskLogTaskSchema>;
|
||||
export type TaskDynamicTestTask = z.infer<typeof TaskDynamicTestTaskSchema>;
|
||||
export type TaskOpenapiTask = z.infer<typeof TaskOpenapiTaskSchema>;
|
||||
export type ContextTask = z.infer<typeof ContextTaskSchema>;
|
||||
export type DmnTask = z.infer<typeof DmnTaskSchema>;
|
||||
export type MappingTask = z.infer<typeof MappingTaskSchema>;
|
||||
export type UiDialogTask = z.infer<typeof UiDialogTaskSchema>;
|
||||
export type UiNotificationTask = z.infer<typeof UiNotificationTaskSchema>;
|
||||
export type OutputTask = z.infer<typeof OutputTaskSchema>;
|
||||
@@ -0,0 +1,13 @@
|
||||
import { z } from "zod";
|
||||
import { BaseTaskSchema } from "./common.js";
|
||||
|
||||
// ── Webhook 触发器节点 ────────────────────────────────────────────────────────
|
||||
|
||||
export const WebhookTaskSchema = BaseTaskSchema.extend({
|
||||
type: z.literal("webhook"),
|
||||
sampleId: z.string(),
|
||||
params: z.array(z.object({ key: z.string(), value: z.string() })),
|
||||
urlPath: z.string(),
|
||||
}).passthrough();
|
||||
|
||||
export type WebhookTask = z.infer<typeof WebhookTaskSchema>;
|
||||
@@ -125,12 +125,12 @@ export async function grantWorkflowNodesApi(options: {
|
||||
timeout: 30000,
|
||||
});
|
||||
const json = (await response.json()) as any;
|
||||
const data = json?.data ?? {};
|
||||
const innerData = json?.data?.data ?? json?.data ?? {};
|
||||
return {
|
||||
success: interpretGatewayOutcome(json),
|
||||
saved: Array.isArray(data.saved) ? data.saved : [],
|
||||
skipped: Array.isArray(data.skipped) ? data.skipped : [],
|
||||
rawMessage: json?.msg || json?.message || "",
|
||||
saved: Array.isArray(innerData.saved) ? innerData.saved : [],
|
||||
skipped: Array.isArray(innerData.skipped) ? innerData.skipped : [],
|
||||
rawMessage: json?.data?.msg || json?.msg || json?.message || "",
|
||||
};
|
||||
} catch (err: any) {
|
||||
const message = err?.message || String(err);
|
||||
|
||||
Reference in new issue
Block a user