Merge pull request #163 from yunyingk/feat/workflow-cli-ergonomics
CI / validate (push) Has been cancelled
CI / validate (push) Has been cancelled
feat(workflow): 原子化重构108个官方节点模型与新增设计器免密直达命令
This commit is contained in:
39 files changed
+19552
-603
No files matched your search
@@ -0,0 +1,64 @@
|
||||
# 2026-11-01
|
||||
|
||||
## 仓库状态收口与双远端对齐
|
||||
|
||||
- 起始状态:本地在 `chore/codex-local-environment`(ac6437b),工作区干净,无 stash;版本 v0.8.21。
|
||||
- 健康度基线:`bun test` 951 pass / 0 fail(126 文件,4580 断言,~34s);`bun run check`(`tsc --noEmit`)零错误;CI `validate` job 通过。
|
||||
- 合并 PR #160(chore: 添加 Codex 本地开发与示例环境,`--merge --delete-branch`),合入后 main = `eb9b979`。
|
||||
- 修复 `home`(Gitea git.ying-qing.cn)main 落后问题:原停在 c6d7184(PR #158),缺少 PR #159 工作流传 CLI 拆分的 10 个 commit,违反 AGENTS.md「先推 home 再推 origin」顺序。已 `git push home main` 对齐。
|
||||
- 现三个头指针完全一致:`main` = `origin/main` = `home/main` = eb9b979;tag v0.8.12~v0.8.21 两远端均齐备(diff 差异仅为 `^{}` 解引用项)。
|
||||
- 已 `git fetch origin --prune` 清理 PR #160 删除分支后的陈旧 remote-tracking ref。
|
||||
|
||||
## 待处理
|
||||
|
||||
- `home` 上枯分支 `feat/openapi-provisional-auth-and-workflow-ux`(39a5a7e)已确认合入 main,本地无对应分支,是否删除远端需用户确认后再动。
|
||||
- 远端残留若干旧分支(origin/archive/*、fix/restore-local-bill-fixes、feat/bill-draft-ops 等),未做任何删除。
|
||||
|
||||
## 经验
|
||||
|
||||
- `gh pr merge` 会自动 checkout 到 base 分支并 fast-forward,合并后需确认当前所处分支。
|
||||
- 检查远端是否有本地缺的新提交,`git fetch --dry-run`(不带 refspec)覆盖默认全部分支 ref,比逐分支对比更快。
|
||||
|
||||
## workflow 领域代码审查结论(PR #159 拆分重构之后)
|
||||
|
||||
以下为实地读码确认的问题,按修复优先级排列:
|
||||
|
||||
1. **生产启停的成功判定是假的(P0)**:`transport/pipeline/api.ts:177` 用 `ok()`(`transport/response.ts:59`,`success = status===200`)判结果,不读 body 不查业务码;而同一文件其他写操作都用会校验业务码的 `readEasoWriteResponse`。`cli/commands/workflow/lifecycle.ts:31-41` 的 `handleToggle` 连 `result.success` 都不看,无条件 `[SUCCESS]` + exitCode 0。反向也错:HTTP 204 成功会被判失败。与 README「HTTP 200 不等于业务成功」正面冲突。
|
||||
2. **灰度开通网关硬编码第三方域(P0)**:`transport/catalog/api.ts:88` 硬编码 `https://d9jxeccs5j.sealosgzg.site/hose-workflow-node`,无环境变量逃生口;`options.baseUrl` 只塞进请求 body、不改实际请求目标(疑似可配化没做完)。`success: Boolean(json?.success ?? true)` 缺字段即默认成功。同类 Sealos 资产(sealosgzg.site)已被回收过一次。
|
||||
3. **version/tasksVersion 检查只在 CLI 层**:`cli/commands/workflow/node.ts:21-27` 有正查;`draft.ts:130-134` 另有一份实现且抛裸 Error 而非 ValidationError;SDK 出口 `management/configuration.ts:27` 的 `updateWorkflow` 完全没有,任何绕过 CLI 的调用方(HTTP daemon / SDK 直连)都跳过该保障,README 描述得像全局保证。
|
||||
4. **`analysis/analyzer.ts` 没被拆分受益**:819 行全域最大,其中 `visit` 闭包一段 373 行塞了 12 类规则(590-611 触发器、614-660 条件、663-733 HTTP、735-791 choose)。PR #159 只拆了 transport/models/management,最该拆的 analyzer 反而没动。
|
||||
5. **`UNSAFE_SKIP_WITHOUT_STATUS_GUARD` 判定形同虚设**:`analyzer.ts:252-269` 把过滤条件 `JSON.stringify` 后用 `includes(节点名) && includes("$status")` 判断"是否已守卫",误命中方向是"认为已守卫"= 不告警 = 静默漏报。
|
||||
6. **`script/lint-js.ts:6-18` 注释剥离是假的**:只跳过整行注释,`// return` 行尾注释、块注释内部行、字符串里的 return 全部命中 → `missing-return` 告警永不触发。
|
||||
7. **重复实现(拆分未收敛)**:节点树遍历 6 份(`execution/tree.ts`、`execution/context.ts`、`management/queries.ts`、`nodes/tree.ts`、`nodes/locator.ts`、`comparison/snapshot.ts`),children 键集合/顺序不一致;`@{choose()}` 解析两份;`@{value()}` 解析三份;终态集合两份;`failedOnly` 过滤两份逐字重复。
|
||||
8. **测试盲区**:`branch/explain` 只覆盖 eq/gt,其余比较符无用例;`UNKNOWN_TASK_TYPE` 硬门禁无测试;`alert/` 零测试(DB 与 JSON 双写,`writeFileSync` 在事务提交后无 try/catch);`execution/tree.ts` 的用例写在 `state/index.test.ts:406` 里,模块归属错位。
|
||||
|
||||
注:`analysis/every.ts:57` 只校验"batchSize 存在但非法"、不管"缺失",这是 README 记录的有意设计(不补默认值),不是缺陷。
|
||||
|
||||
## 修复落地(工作树 /Users/yingqing/Code/hose-use-workbuddy,分支 workbuddy/workflow-hardening)
|
||||
|
||||
基于 main(eb9b979) 拉起独立工作树施工,5 个 commit(cedc424 / 71aa9b5 / a0058c1 / 1ee46fd / 6dc96a5),
|
||||
32 文件 +1042/-147,测试 951 → 1004 全绿,`tsc --noEmit` 无错。尚未 push、未开 PR。
|
||||
|
||||
| commit | 内容 |
|
||||
|---|---|
|
||||
| 6dc96a5 | 删除 `transport/response.ts` 的 `ok()`;toggle 改用 `readEasoWriteResponse`,management 层写后回读详情,不一致抛 `BusinessError(WORKFLOW_STATE_NOT_APPLIED)`,回读失败返回 `verified:false`;lifecycle 按结果给退出码。新增 `WorkflowToggleResult` |
|
||||
| 1ee46fd | 网关地址改为 `resolveGrayGatewayUrl()`(显式参数 > `HOSE_GRAY_GATEWAY_URL` > 内置默认),统一拼接 `/hose-workflow-node`;`interpretGatewayOutcome` 缺 success/code 标记时判为失败;失败信息带网关地址 |
|
||||
| a0058c1 | `updateWorkflow` 第三参数支持 `{platformId, expectedVersion}`(字符串写法向后兼容),提交前重读比对;node.ts 删除重复实现;`taskGuardsStatusOf` 改为结构化引用比对;`stripCommentsAndStrings` 真正剥离注释与字符串 |
|
||||
| 71aa9b5 | Job 状态语义收敛到 `execution/job-status.ts`(原先 watch 把 state:0 当完成、debug 当未知继续轮询,同一 Job 结论相反);`--failed-only` 过滤抽为 `shouldEmitWatchEvent` |
|
||||
| cedc424 | 补齐 evaluateRule 全 11 个比较符、UNKNOWN_TASK_TYPE、权限证据边界测试;alert 的 JSON 副本导出失败改为返回 `exportError`(原先落盘失败会让整轮巡检失败但指纹已入库);告警测试从 state/index.test.ts 迁回 alert/ |
|
||||
|
||||
### 施工踩坑
|
||||
|
||||
- `mock.module("ky")` 会污染同进程其他测试文件的 ky 引用(write-result.test.ts 的 `ky.create` 直接变 undefined)。
|
||||
改用具名导出的 `spyOn(ky, "post")` + 可恢复语义。
|
||||
- bun 的 `spyOn` 是顶层具名导出,`mock.spyOn` 不存在。
|
||||
- 本地 `enterprises/` 只有 example.json,无真实企业配置,因此本次改动无法真实联调,全部依赖单测。
|
||||
- 涉及真实企业时只能用「沈玥妍测试企业」(见 MEMORY.md 红线)。
|
||||
|
||||
### 未做、建议单独排期
|
||||
|
||||
- `analysis/analyzer.ts` 819 行拆分:`visit` 闭包一段 373 行塞了 12 类规则(590-611/614-660/663-733/735-791),
|
||||
应按规则族拆 `rules/*.ts` 注册表。改动面大,需要专门一轮 + 全量回归。
|
||||
- 节点树遍历仍重复 6 份(`execution/tree`、`execution/context`、`management/queries`、`nodes/tree`、
|
||||
`nodes/locator`、`comparison/snapshot`),children 键集合与顺序不一致会导致执行树与配置树遍历结果漂移。
|
||||
- `@{choose()}` 两份、`@{value()}` 三份解析实现待收敛。
|
||||
@@ -0,0 +1,107 @@
|
||||
# 2026-11-02 工作记录
|
||||
|
||||
## 1. 任务背景与目标
|
||||
- **目标企业**: CSM (`Cxa3oOtQi2eS$g`)
|
||||
- **操作员工身份约束**: 严格绑定「**李志财**」(`2HQbkGx2DgnM00`),严禁使用其他账号(如缪梦婷)。
|
||||
- **目标工作流**: `881196955148578838`(商机台账单据事件流)
|
||||
- **核心问题定位**:
|
||||
- `action_agree_normal` 在未超标单据执行时报错:`HTTP 400 缺少accessToken参数`。
|
||||
- 根因:HTTP 节点原本漏填了 `appId`(连接器)与 `authId`(授权),合思开放平台需要由 Piper 自动根据连接器授权换取 accessToken 并注入 URL。
|
||||
- 本地模型与校验问题:原本 `BaseTaskSchema` 和 `HttpTaskSchema` 缺少 `.passthrough()` 与 `appId`/`authId` 显式字段定义,导致 `hose-use workflow node edit` 序列化时自动吞掉这些关键属性。
|
||||
|
||||
## 2. 节点原子化重构成果
|
||||
- 创建 `src/domains/platform/workflow/models/nodes/` 子目录,将原庞大的单文件节点拆为 13 个独立模块:
|
||||
- `common.ts`: `BaseTaskSchema.passthrough()`, `WorkflowTask`
|
||||
- `http.ts`: `HttpTaskSchema`(支持 `authId`, `appId`, `HttpMethodSchema`, `HttpBodyTypeSchema`, `HttpContentTypeSchema`)
|
||||
- `delay.ts`, `code.ts`, `webhook.ts`, `stop.ts`, `flow.ts`, `datalink.ts`, `condition.ts`, `every.ts`, `unknown.ts`, `index.ts`
|
||||
- `README.nodes.md`: 完整架构与节点规范文档
|
||||
- 同步生成 `specs/workflow-schema.json`。
|
||||
|
||||
## 3. Piper 连接器、授权与 HTTP 请求方法深度调研结论
|
||||
通过 Kimi WebBridge 挂载 CDP 探针并逆向 Piper 生产前端 bundle 与 Sourcemap,明确了以下底层契约:
|
||||
|
||||
### 3.1 连接器 (`appId`)
|
||||
- **查询接口**: `POST /api/easo/dsl/task-openapi/select/appId`,Body: `{ $platformId: platformId }`
|
||||
- **平台预置全量清单(共 7 个)**:
|
||||
1. `4`: `费控原生`(`ekuaibao_app`,通过 openapi key/secret 自动向 `https://app.ekuaibao.com/api/openapi/v1/auth/getAccessToken` 换票并自动注入 `?accessToken=...`)
|
||||
2. `5`: `费控钉钉`
|
||||
3. `9`: `纷享销客`
|
||||
4. `11`: `ai应用`
|
||||
5. `14`: `招商银行商务卡查询`
|
||||
6. `15`: `费控企微`
|
||||
7. `16`: `开放平台`
|
||||
|
||||
### 3.2 授权 (`authId`)
|
||||
- **查询接口**: `POST /api/easo/corpApp/getAuthList`,Body: `{ appId: "<appId>", size: 100 }`,Header: `Authorization: Bearer <jwtToken>`
|
||||
- **配置详情/元数据接口**: `GET /api/easo/app/getInfo?id=<appId>`(含 `authConfig.dslConfig` 表单结构与 `tokenSendParam`)
|
||||
- **保存新授权接口**: `POST /api/easo/corpApp/saveAuthInfo`
|
||||
- **CSM 企业实测现状**:
|
||||
- `appId: 4`(费控原生):拥有 1 个可用授权实例:`id: 157`,名称 `费控原生#202512150`。
|
||||
- 其他连接器(5、9、11、14、15、16):在当前 CSM 企业下 `totalItems: 0`,未配置授权实例。
|
||||
|
||||
### 3.3 HTTP 节点请求方法 (`method`)
|
||||
- **严格枚举(5 种)**:
|
||||
- `GET`
|
||||
- `POST`
|
||||
- `PUT`
|
||||
- `PATCH`
|
||||
- `DELETE`
|
||||
- **联动行为(Reactions)**:
|
||||
- 选定 `POST`、`PUT`、`PATCH` 时,表单显示 `bodyType` 及其输入区;
|
||||
- 选定 `GET`、`DELETE` 时,表单隐藏请求体区域(`x-display: none`)。
|
||||
|
||||
### 3.4 配套请求体类型 (`bodyType`) 与 Content-Type
|
||||
- **`bodyType` 枚举**:
|
||||
- `none`: 无请求体
|
||||
- `raw`: 原生字符串/JSON(默认,支持 `@{choose(...)}` 变量插值)
|
||||
- `from-data`: multipart/form-data 键值对(前端枚举值为 `from-data`)
|
||||
- `form-urlencoded`: x-www-form-urlencoded 键值对
|
||||
- **`contentType`(raw 模式下)**:
|
||||
- `application/json`(默认)
|
||||
- `text/plain`
|
||||
- `application/javascript`
|
||||
- `text/html`
|
||||
- `application/xml`
|
||||
|
||||
## 4. 沈玥妍测试企业自主补充工作流全量可用节点
|
||||
|
||||
### 4.1 背景与边界
|
||||
- **测试企业**: 沈玥妍测试企业 (`ID01ofWoOC1wiX` [🧪 测试])
|
||||
- **操作员工**: 谢子豪 (`ID01ofWoOC1wiX:ID01KsDgHaH5nN`)
|
||||
- **目标流程**: `857320807633186842` (`未命名流程OMcjrw`)
|
||||
|
||||
### 4.2 灰度全量解锁 (107/108 个节点)
|
||||
- 探查官方灰度网关,发现当前企业共有 53 个灰度节点处于未开通状态;
|
||||
- 执行 `hose-use workflow nodes grant` 批量免密开通全量 53 个灰度节点;
|
||||
- 开通后,租户拥有 83 个 action 节点、6 个 control 节点、18 个 trigger 节点,全量可用节点达到 107 个。
|
||||
|
||||
### 4.3 浏览器端 Piper 逆向鉴权与工作流设计器加载
|
||||
- 发现 `https://unity.ekuaibao.com/api/realms/EASO` 返回的是 1 段式 Bearer token,而 Piper 后端要求标准 3 段式 JWT。
|
||||
- 逆向得出正确的 EASO JWT 生成接口:
|
||||
`GET https://app.ekuaibao.com/api/engine/realm/$EASO/actions/jwt?corpId=<corpId>`(携带 accesstoken, corpid, staffid 请求头)。
|
||||
- 将取得的 JWT 存入 localStorage `jwtToken`,成功在 Kimi WebBridge 浏览器中完整加载 `https://piper.ekuaibao.com/#/workflow/857320807633186842`。
|
||||
|
||||
### 4.4 参考工作流多类别节点完整编排
|
||||
在沈玥妍测试企业的工作流 `857320807633186842` 中,依次补充并成功保存了覆盖全部分类的 16 个节点全链路:
|
||||
1. `trigger_1`: 定时触发 (`clock`) [触发器]
|
||||
2. `action_6hfh88`: 查询单据详情 (`flow-detail`) [业务单据]
|
||||
3. `action_mhjko9`: 代码节点 (`code` MVEL 脚本) [通用代码]
|
||||
4. `action_23lsze`: 创建单据 (`flow-create-task`) [业务单据]
|
||||
5. `action_4fcd9s`: JS节点(新) (`code-js2`) [通用代码]
|
||||
6. `action_iz22vg`: http节点 (`http` 带凭证调用) [通用网络]
|
||||
7. `action_k7b0xb`: 延迟执行节点 (`task-dynamic-delay`) [通用流控]
|
||||
8. `action_0mhuwa`: 重算审批流 (`recalculate-the-approval-flow`) [业务审批]
|
||||
9. `action_e5mzyn`: 修改单据 (`flow-update-task`) [业务单据]
|
||||
10. `action_uc6ph8`: 钉钉消息 (`message-dingtalk`) [消息通知]
|
||||
11. `action_tt1b29`: 查询人员 (`ekuaibao-staff-filter`) [组织架构]
|
||||
12. `action_uut5b0`: 导出表格 (`excel`) [通用报表]
|
||||
13. `action_3ivkgn`: AI智能匹配 (`ai-classification`) [AI能力]
|
||||
14. `control_cond1`: 条件节点 (`condition`) [流程控制容器]
|
||||
- 14.1 `action_sub_log`: 流程日志 (`task-log`) [容器子节点]
|
||||
15. `action_iqhn3b`: 终止节点 (`stop`) [流程控制]
|
||||
|
||||
### 4.5 代码库静态分析与 Schema 全面对齐
|
||||
1. 在 `src/domains/platform/workflow/models/nodes/` 补齐了 `ai.ts`, `control.ts`, `message.ts`, `org.ts`, `utility.ts`,导出并重现 `specs/workflow-schema.json`;
|
||||
2. 修复分析器 `KNOWN_TYPES`,接入 `isKnownGrayNodeType`,使得分析器静态识别 108 个官方已知节点类型;
|
||||
3. 执行 `hose-use workflow analyze 857320807633186842`:0 项硬门禁阻断,完美通过。
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
# 2026-11-03 工作记录
|
||||
|
||||
## 1. CSM 工作流 881196955148578838(方案一)正式发布上线
|
||||
- **目标企业**: CSM (`Cxa3oOtQi2eS$g`)
|
||||
- **操作员工**: 李志财 (`2HQbkGx2DgnM00`)
|
||||
- **目标工作流**: `881196955148578838` (方案一)
|
||||
- **执行命令**:
|
||||
```bash
|
||||
hose-use workflow publish 881196955148578838 --corp='Cxa3oOtQi2eS$g' --yes
|
||||
```
|
||||
- **验证结果**:
|
||||
- 远端发布成功:`state=1`,`updateUser: "李志财"`,`updateTime: "2026-11-03 10:20:22"`。
|
||||
- 静态门禁静态分析(`workflow analyze`):
|
||||
- 状态:🟢 启用 (state=1)
|
||||
- 门禁裁决:✅ 已执行的静态检查未发现阻断项
|
||||
- 硬门禁数:0 项
|
||||
- 软建议数:0 项
|
||||
- 诊断列表:未发现明显配置问题
|
||||
@@ -0,0 +1,35 @@
|
||||
# hose-use 项目长期约束
|
||||
|
||||
## 企业租户操作红线(强制)
|
||||
|
||||
- **唯一允许操作的测试企业是「沈玥妍测试企业」**,任何需要真实联调/验证的场景只能在它上面做。
|
||||
- **绝对禁止对任何生产企业执行操作**,尤其是不可逆的写操作:工作流保存/发布/启停/删除、调试 Job 派发、单据审批、台账写入、灰度节点开通、Webhook 样本注入。
|
||||
- 合思后端没有调试沙箱,调试 Job 以真实操作员身份在生产环境运行,并会隐式自增 Pipeline 快照版本 —— 在生产企业上一次「调试」就等于一次真实变更。
|
||||
- 代码改动优先用单元测试 + Mock 验证;确需真实接口验证时,先确认当前选中的是测试企业再动手。
|
||||
|
||||
## 仓库协作
|
||||
|
||||
- 双远端:`origin` = GitHub(主),`home` = Gitea(git.ying-qing.cn)。发布顺序先 `home` 再 `origin`。
|
||||
- 分支名必须全小写,禁止在 main 直接提交,详见 AGENTS.md。
|
||||
|
||||
## 已知基础设施
|
||||
|
||||
- New API 端点已从 Sealos 的 `sealosgzg.site` 迁移至 `api.ying-qing.cn`;代码里残留的 `*.sealosgzg.site` 硬编码属于待清理项(workflow 灰度开通网关)。
|
||||
|
||||
## 工作流与 Piper 核心契约(2026-11-02 固化)
|
||||
|
||||
- **工作流节点原子模型**: 位于 `src/domains/platform/workflow/models/nodes/`,包含 13 个独立模块与 `README.nodes.md`。
|
||||
- **连接器 (`appId`)**:
|
||||
- 查询接口: `POST /api/easo/dsl/task-openapi/select/appId`,Body: `{ $platformId: platformId }`
|
||||
- 完整 7 种枚举: `4` (费控原生), `5` (费控钉钉), `9` (纷享销客), `11` (ai应用), `14` (招商银行商务卡查询), `15` (费控企微), `16` (开放平台)。
|
||||
- **授权 (`authId`)**:
|
||||
- 查询接口: `POST /api/easo/corpApp/getAuthList`,Body: `{ appId, size: 100 }`,Header: `Authorization: Bearer <jwtToken>`。
|
||||
- 元数据接口: `GET /api/easo/app/getInfo?id=<appId>`(含 `tokenSendParam`,`appId: 4` 时自动注入 `?accessToken=...`)。
|
||||
- **HTTP 节点请求方法 (`method`)**:
|
||||
- 严格 5 种枚举: `GET`, `POST`, `PUT`, `PATCH`, `DELETE`。
|
||||
- `POST`, `PUT`, `PATCH` 时显示请求体;`GET`, `DELETE` 时收起隐藏。
|
||||
- **请求体类型 (`bodyType`)**:
|
||||
- 4 种枚举: `none`, `raw` (默认), `from-data`, `form-urlencoded`。
|
||||
- **Content-Type**:
|
||||
- 5 种枚举: `application/json` (默认), `text/plain`, `application/javascript`, `text/html`, `application/xml`。
|
||||
|
||||
+17412
-339
File diff suppressed because it is too large.
Load diff
@@ -220,7 +220,9 @@ export const COMMAND_METADATA: Record<string, CliCommandMetadata> = {
|
||||
"check": "检查错误管道",
|
||||
"enum": "查询在线枚举字典(不可用时使用内置字典)",
|
||||
"lint-script": "静态检查 JavaScript / MVEL 脚本",
|
||||
"eval-script": "在本地沙箱中模拟执行脚本"
|
||||
"eval-script": "在本地沙箱中模拟执行脚本",
|
||||
"webhook": "向工作流 Webhook 触发器发送测试数据 (别名: webhook-send)",
|
||||
"link": "生成工作流设计器 (Piper) 免密直达链接 (包含特权警告)"
|
||||
},
|
||||
"options": [
|
||||
"--flow=<单号> 指定测试单据",
|
||||
@@ -271,9 +273,13 @@ export const COMMAND_METADATA: Record<string, CliCommandMetadata> = {
|
||||
"run-script": "eval-script",
|
||||
"enums": "enum",
|
||||
"dictionary": "enum",
|
||||
"dict": "enum"
|
||||
"dict": "enum",
|
||||
"webhook-send": "webhook",
|
||||
"webhooks": "webhook",
|
||||
"url": "link",
|
||||
"web": "link"
|
||||
},
|
||||
flags: { ...flagList("all allow-prod allow-production auto-publish autoPublish compare detail diff empty errors f fail fail-on-alert failOnAlert failed failed-only failedOnly follow force force-write forceWrite full has-error hasError in-place inPlace includeDetail json none once publish snapshot v value-json valueJson verbose with-tasks withTasks timeline progress steps", "boolean"), ...flagList("a admin-key adminKey after app app-id appId b bill body c code code-file container count d data desc description display display-name displayName end-time endTime entity execution-logs field file filter flow flow-code flowCode from i id input input-file insert-after interval job job-id job1 job2 jobA jobB jobId json-file keyword l label limit log logs mapping mapping-file max-jobs maxJobs n name node node-id nodeId nodes output output-file outputFile p page page-size pageSize parent parent-id parentId password path payload pipeline pipeline-id pipelineId platform platform-id platformId pwd q query record s sample sample-id sampleId set size snapshot1 snapshot2 snapshotA snapshotB source start-time startTime state state-file stateFile t target targetName targetPlatformId task taskType third-id thirdId timeout timeout-ms timeoutMs to trigger type types value workflowId", "value") }
|
||||
flags: { ...flagList("all allow-prod allow-production auto-publish autoPublish compare detail diff empty errors f fail fail-on-alert failOnAlert failed failed-only failedOnly follow force force-write forceWrite full has-error hasError in-place inPlace includeDetail json none once publish snapshot v value-json valueJson verbose with-tasks withTasks timeline progress steps", "boolean"), ...flagList("a admin-key adminKey after app app-id appId b bill body c code code-file container count d data desc description display display-name displayName end-time endTime entity execution-logs field file filter flow flow-code flowCode from i id input input-file insert-after interval job job-id job1 job2 jobA jobB jobId json-file keyword l label limit log logs mapping mapping-file max-jobs maxJobs n name node node-id nodeId nodes output output-file outputFile p page page-size pageSize parent parent-id parentId password path payload pipeline pipeline-id pipelineId platform platform-id platformId pwd q query record s sample sample-id sampleId seconds set size sleep-time sleepTime snapshot1 snapshot2 snapshotA snapshotB source start-time startTime state state-file stateFile t target targetName targetPlatformId task taskType third-id thirdId timeout timeout-ms timeoutMs to trigger type types value workflowId", "value") }
|
||||
},
|
||||
"bill": {
|
||||
"summary": "单据检索、表单规格诊断与审批动作",
|
||||
|
||||
@@ -2331,5 +2331,90 @@ describe("CLI - workflow list 轻量化与名称搜索", () => {
|
||||
expect(data.workflows[0].pipelineName).toBe("待摊台账拆分计划");
|
||||
expect(data.totalWorkflows).toBe(1);
|
||||
});
|
||||
|
||||
it("workflow link 生成高特权免密直达链接并输出安全警告与自建应用信息", async () => {
|
||||
const mockSessionClient = {
|
||||
get: () => ({
|
||||
json: async () => ({ id: "mock.jwt.token" }),
|
||||
}),
|
||||
};
|
||||
spies.push(
|
||||
spyOn(helpers, "createClientsForCorp").mockResolvedValue({
|
||||
sessionClient: mockSessionClient,
|
||||
} as any),
|
||||
spyOn(platformServices, "listAllWorkflows").mockResolvedValue({
|
||||
workflows: [
|
||||
{
|
||||
id: "wf_001",
|
||||
pipelineName: "待摊台账拆分计划",
|
||||
platformId: "app_platform_1",
|
||||
platformName: "商机台账",
|
||||
state: 1,
|
||||
},
|
||||
] as any,
|
||||
errors: [],
|
||||
})
|
||||
);
|
||||
|
||||
const res = await handleWorkflowCommand(
|
||||
{
|
||||
area: "workflow",
|
||||
action: "link",
|
||||
args: ["wf_001"],
|
||||
options: {},
|
||||
raw: ["workflow", "link", "wf_001"],
|
||||
},
|
||||
mockRuntime
|
||||
);
|
||||
|
||||
expect(res.exitCode).toBe(0);
|
||||
expect(res.stdout).toContain("【高特权免密直达警告】");
|
||||
expect(res.stdout).toContain("所属自建应用 : 商机台账 (app_platform_1)");
|
||||
expect(res.stdout).toContain("目标工作流 : 待摊台账拆分计划 (wf_001)");
|
||||
expect(res.stdout).toContain("https://piper.ekuaibao.com/#/workflow/wf_001?jwtToken=mock.jwt.token&$platformId=app_platform_1");
|
||||
});
|
||||
|
||||
it("workflow link --json 返回结构化授权链接与警告信息", async () => {
|
||||
const mockSessionClient = {
|
||||
get: () => ({
|
||||
json: async () => ({ id: "mock.jwt.token" }),
|
||||
}),
|
||||
};
|
||||
spies.push(
|
||||
spyOn(helpers, "createClientsForCorp").mockResolvedValue({
|
||||
sessionClient: mockSessionClient,
|
||||
} as any),
|
||||
spyOn(platformServices, "listAllWorkflows").mockResolvedValue({
|
||||
workflows: [
|
||||
{
|
||||
id: "wf_001",
|
||||
pipelineName: "待摊台账拆分计划",
|
||||
platformId: "app_platform_1",
|
||||
platformName: "商机台账",
|
||||
state: 1,
|
||||
},
|
||||
] as any,
|
||||
errors: [],
|
||||
})
|
||||
);
|
||||
|
||||
const res = await handleWorkflowCommand(
|
||||
{
|
||||
area: "workflow",
|
||||
action: "link",
|
||||
args: ["wf_001"],
|
||||
options: { json: true },
|
||||
raw: ["workflow", "link", "wf_001", "--json"],
|
||||
},
|
||||
{ ...mockRuntime, jsonMode: true }
|
||||
);
|
||||
|
||||
expect(res.exitCode).toBe(0);
|
||||
const data = JSON.parse(res.stdout);
|
||||
expect(data.pipelineId).toBe("wf_001");
|
||||
expect(data.platformName).toBe("商机台账");
|
||||
expect(data.jwtToken).toBe("mock.jwt.token");
|
||||
expect(data.warning).toContain("特权");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
| [analyze.ts](./analyze.ts)、[check.ts](./check.ts)、[diff.ts](./diff.ts) | 静态分析、健康检查与配置/执行差异 |
|
||||
| [script.ts](./script.ts)、[test.ts](./test.ts) | 脚本校验、求值与工作流测试 |
|
||||
| [tail.ts](./tail.ts)、[webhook.ts](./webhook.ts)、[enum.ts](./enum.ts) | 执行监听、Webhook 与业务枚举 |
|
||||
| [link.ts](./link.ts) | 工作流设计器 (Piper) 免密直达链接签发与高特权安全警告 |
|
||||
|
||||
## 保存和执行契约
|
||||
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
import { afterEach, beforeEach, describe, expect, it } from "bun:test";
|
||||
import { mkdtempSync, mkdirSync, writeFileSync, rmSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { tmpdir } from "node:os";
|
||||
import { runCli } from "../../runner.js";
|
||||
import { renderScopedHelp } from "../../help.js";
|
||||
|
||||
const keys = ["HOSE_ENTERPRISES_DIR", "HOSE_CONFIG_FILE"] as const;
|
||||
const original = keys.map((key) => process.env[key]);
|
||||
let tempDir = "";
|
||||
|
||||
describe("workflow CLI ergonomics & layered help", () => {
|
||||
beforeEach(() => {
|
||||
tempDir = mkdtempSync(join(tmpdir(), "hose-ergonomics-"));
|
||||
const corps = join(tempDir, "corps");
|
||||
mkdirSync(corps, { recursive: true });
|
||||
writeFileSync(
|
||||
join(corps, "corp.json"),
|
||||
JSON.stringify({
|
||||
id: "corp",
|
||||
name: "Fixture",
|
||||
source: "manual",
|
||||
credentials: { accessToken: "fake", corpId: "corp", staffId: "staff" },
|
||||
})
|
||||
);
|
||||
writeFileSync(
|
||||
join(tempDir, "config.json"),
|
||||
JSON.stringify({ defaultCorpId: "corp", stateful: true })
|
||||
);
|
||||
process.env.HOSE_ENTERPRISES_DIR = corps;
|
||||
process.env.HOSE_CONFIG_FILE = join(tempDir, "config.json");
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
keys.forEach((key, i) => {
|
||||
if (original[i] === undefined) delete process.env[key];
|
||||
else process.env[key] = original[i];
|
||||
});
|
||||
if (tempDir) {
|
||||
rmSync(tempDir, { recursive: true, force: true });
|
||||
tempDir = "";
|
||||
}
|
||||
});
|
||||
it("renders specialized layered help for workflow node add", () => {
|
||||
const help = renderScopedHelp(["workflow", "node", "add"]);
|
||||
expect(help).toContain("workflow node add -");
|
||||
expect(help).toContain("--type=<type>");
|
||||
expect(help).toContain("--sleep-time=<秒数>");
|
||||
expect(help).toContain("--set='key=value'");
|
||||
expect(help).toContain("--after=<节点name>");
|
||||
expect(help).toContain("支持选项:");
|
||||
});
|
||||
|
||||
it("renders specialized layered help for workflow node edit", () => {
|
||||
const help = renderScopedHelp(["workflow", "node", "edit"]);
|
||||
expect(help).toContain("workflow node edit -");
|
||||
expect(help).toContain("--sleep-time=<秒数>");
|
||||
expect(help).toContain("--set='key=value'");
|
||||
expect(help).toContain("支持选项:");
|
||||
});
|
||||
|
||||
it("renders specialized layered help for workflow test", () => {
|
||||
const help = renderScopedHelp(["workflow", "test"]);
|
||||
expect(help).toContain("workflow test -");
|
||||
expect(help).toContain("--flow=<单号>");
|
||||
expect(help).toContain("--body='{...}'");
|
||||
expect(help).toContain("--sample=<1|2|3>");
|
||||
expect(help).toContain("支持选项:");
|
||||
});
|
||||
|
||||
it("renders specialized layered help for workflow webhook send", () => {
|
||||
const help = renderScopedHelp(["workflow", "webhook", "send"]);
|
||||
expect(help).toContain("workflow webhook send -");
|
||||
expect(help).toContain("--bill=<单号|单据ID>");
|
||||
expect(help).toContain("--body='{...}'");
|
||||
expect(help).toContain("支持选项:");
|
||||
});
|
||||
|
||||
it("runCli correctly resolves sub-subcommand help via --help flag", async () => {
|
||||
const result = await runCli(["workflow", "node", "add", "--help"]);
|
||||
expect(result.exitCode).toBe(0);
|
||||
expect(result.stdout).toContain("workflow node add -");
|
||||
expect(result.stdout).toContain("--sleep-time=<秒数>");
|
||||
});
|
||||
|
||||
it("workflow test automatically swaps reversed arguments (billCode and 18-digit pipelineId)", async () => {
|
||||
const result = await runCli(["workflow", "test", "B26000148", "881196955148578838", "--dry-run"]);
|
||||
expect(result.exitCode).toBe(0);
|
||||
expect(result.stdout).toContain("881196955148578838");
|
||||
expect(result.stdout).toContain("B26000148");
|
||||
});
|
||||
|
||||
it("workflow node add dry-run accepts --sleep-time directly", async () => {
|
||||
const result = await runCli([
|
||||
"workflow",
|
||||
"node",
|
||||
"add",
|
||||
"881196955148578838",
|
||||
"--type=task-dynamic-delay",
|
||||
"--sleep-time=5",
|
||||
"--dry-run",
|
||||
]);
|
||||
expect(result.exitCode).toBe(0);
|
||||
expect(result.stdout).toContain("追加工作流节点");
|
||||
expect(result.stdout).toContain("task-dynamic-delay");
|
||||
});
|
||||
|
||||
it("workflow node edit dry-run parses JSON payload in --set", async () => {
|
||||
const result = await runCli([
|
||||
"workflow",
|
||||
"node",
|
||||
"edit",
|
||||
"881196955148578838",
|
||||
"action_agree_normal",
|
||||
'--set={"authId":157,"appId":"4"}',
|
||||
"--dry-run",
|
||||
]);
|
||||
expect(result.exitCode).toBe(0);
|
||||
expect(result.stdout).toContain("修改工作流节点");
|
||||
expect(result.stdout).toContain('"authId":157');
|
||||
expect(result.stdout).toContain('"appId":"4"');
|
||||
});
|
||||
|
||||
it("WorkflowTaskSchema preserves authId and appId on http tasks without stripping", async () => {
|
||||
const { WorkflowTaskSchema } = await import("../../../domains/platform/workflow/models/nodes.js");
|
||||
const sample = {
|
||||
name: "action_test",
|
||||
type: "http",
|
||||
label: "http节点",
|
||||
groupName: "action",
|
||||
orderIndex: 0,
|
||||
levelIndex: [0],
|
||||
status: "active",
|
||||
method: "POST",
|
||||
url: "https://example.com",
|
||||
header: [],
|
||||
params: [],
|
||||
successCode: ["200"],
|
||||
authId: 157,
|
||||
appId: "4",
|
||||
};
|
||||
const parsed = WorkflowTaskSchema.parse(sample);
|
||||
expect((parsed as any).authId).toBe(157);
|
||||
expect((parsed as any).appId).toBe("4");
|
||||
});
|
||||
});
|
||||
@@ -16,6 +16,7 @@ import { handleWorkflowTailCommand } from "./tail.js";
|
||||
import { handleWorkflowLintScript, handleWorkflowEvalScript } from "./script.js";
|
||||
import { handleWorkflowEnum } from "./enum.js";
|
||||
import { handleWebhookCommand } from "./webhook.js";
|
||||
import { handleWorkflowLink } from "./link.js";
|
||||
|
||||
export async function handleWorkflowCommand(
|
||||
parsed: CliParsedArgs,
|
||||
@@ -121,10 +122,14 @@ export async function handleWorkflowCommand(
|
||||
case "webhook-send":
|
||||
case "webhooks":
|
||||
return handleWebhookCommand(parsed, runtime);
|
||||
case "link":
|
||||
case "url":
|
||||
case "web":
|
||||
return handleWorkflowLink(parsed, runtime);
|
||||
default:
|
||||
return {
|
||||
stdout: "",
|
||||
stderr: `未知 workflow 子命令: ${action}。支持: list, get, find, analyze, toggle, publish, patch, save, refresh-chooses, history, logs, job, diff, diff-job, check, test, copy, create, delete, node, tail, lint-script, eval-script, enum, webhook\n`,
|
||||
stderr: `未知 workflow 子命令: ${action}。支持: list, get, find, analyze, toggle, publish, patch, save, refresh-chooses, history, logs, job, diff, diff-job, check, test, copy, create, delete, node, tail, lint-script, eval-script, enum, webhook, link\n`,
|
||||
exitCode: 1,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
import { stringOption } from "../../parser.js";
|
||||
import { printJson } from "../../printer.js";
|
||||
import type { CliParsedArgs, CliResult, CliRuntime } from "../../types.js";
|
||||
import { createClientsForCorp } from "../../helpers.js";
|
||||
import { listAllWorkflows } from "../../../domains/platform/workflow/services.js";
|
||||
|
||||
// ── 工作流设计器 (Piper) 免密直达链接签发 ────────────────────────────────────
|
||||
|
||||
export async function handleWorkflowLink(
|
||||
parsed: CliParsedArgs,
|
||||
runtime: CliRuntime
|
||||
): Promise<CliResult> {
|
||||
const corp = runtime.selectedCorp!;
|
||||
const pipelineId =
|
||||
parsed.args[0] ||
|
||||
stringOption(parsed.options, ["id", "pipelineId", "workflowId", "pipeline"]);
|
||||
|
||||
if (!pipelineId) {
|
||||
return {
|
||||
stdout: "",
|
||||
stderr: [
|
||||
"请提供工作流 ID: hose-use workflow link <pipelineId> [选项]",
|
||||
"",
|
||||
"常用选项:",
|
||||
" --corp=<corpId> 指定企业 (默认当前企业)",
|
||||
" --platform-id=<platformId> 指定所属自建应用 ID (可选,默认自动识别)",
|
||||
" --json 输出结构化 JSON 格式",
|
||||
"",
|
||||
"示例:",
|
||||
" hose-use workflow link 881196955148578838",
|
||||
].join("\n") + "\n",
|
||||
exitCode: 1,
|
||||
};
|
||||
}
|
||||
|
||||
const clients = await createClientsForCorp(corp);
|
||||
|
||||
// 1. 查询工作流元数据及所属自建应用平台信息
|
||||
let platformId = stringOption(parsed.options, ["platform-id", "platformId", "app-id", "appId"]);
|
||||
let platformName = "";
|
||||
let pipelineName = "";
|
||||
let workflowState: number | undefined;
|
||||
|
||||
try {
|
||||
const all = await listAllWorkflows(clients, { page: 1, pageSize: 100 });
|
||||
const match = all.workflows.find((w) => w.id === pipelineId);
|
||||
if (match) {
|
||||
pipelineName = match.pipelineName || "";
|
||||
platformId = platformId || match.platformId || "";
|
||||
platformName = match.platformName || "";
|
||||
workflowState = match.state;
|
||||
}
|
||||
} catch {
|
||||
// 容错降级
|
||||
}
|
||||
|
||||
platformId = platformId || corp.corpId || corp.id;
|
||||
|
||||
// 2. 向 EASO Realm 申请专属 3 段式 JWT 授权凭据
|
||||
let jwt = "";
|
||||
try {
|
||||
const jwtRes = await clients.sessionClient.get("api/engine/realm/$EASO/actions/jwt", {
|
||||
searchParams: { corpId: corp.corpId || corp.id },
|
||||
}).json<{ id: string }>();
|
||||
jwt = jwtRes.id;
|
||||
} catch (err) {
|
||||
const errMsg = err instanceof Error ? err.message : String(err);
|
||||
return {
|
||||
stdout: "",
|
||||
stderr: `获取 EASO JWT 授权凭据失败: ${errMsg}\n请确认当前会话是否有效或重新登录。\n`,
|
||||
exitCode: 1,
|
||||
};
|
||||
}
|
||||
|
||||
const directUrl = `https://piper.ekuaibao.com/#/workflow/${pipelineId}?jwtToken=${jwt}&$platformId=${encodeURIComponent(platformId)}`;
|
||||
|
||||
if (runtime.jsonMode) {
|
||||
const output = {
|
||||
pipelineId,
|
||||
pipelineName: pipelineName || pipelineId,
|
||||
corpId: corp.corpId || corp.id,
|
||||
corpName: corp.name,
|
||||
env: corp.env || (corp.isTest ? "test" : "prod"),
|
||||
staffId: corp.staffId,
|
||||
staffName: corp.staffName || corp.staffId,
|
||||
platformId,
|
||||
platformName: platformName || "自建应用",
|
||||
state: workflowState,
|
||||
jwtToken: jwt,
|
||||
url: directUrl,
|
||||
warning: "⚠️ 该直达链接具备以当前员工身份免密直接访问和修改工作流的最高特权,严禁外泄!",
|
||||
};
|
||||
return {
|
||||
stdout: printJson(output, runtime.outputOptions),
|
||||
stderr: "",
|
||||
exitCode: 0,
|
||||
};
|
||||
}
|
||||
|
||||
const envTag = corp.isTest ? "🧪 测试环境" : "🚨 生产环境";
|
||||
const stateText =
|
||||
workflowState === 1
|
||||
? "🟢 启用中 (state=1)"
|
||||
: workflowState === 0
|
||||
? "⚪ 停用/草稿 (state=0)"
|
||||
: "未知";
|
||||
|
||||
const lines = [
|
||||
"⚠️ 【高特权免密直达警告】(HIGH PRIVILEGE DIRECT ACCESS WARNING)",
|
||||
" ----------------------------------------------------------------------",
|
||||
" • 该链接包含有效 3 段式 EASO JWT 授权凭证,在浏览器中打开即直接以当前员工身份进入!",
|
||||
" • 具有对该工作流的所有节点配置、代码脚本、版本发布及运行实例的完全编辑/删除/调试权限!",
|
||||
" • 严禁将该链接发送到群聊、公开工单或不受信渠道;使用完毕后请及时关闭会话标签页。",
|
||||
" ----------------------------------------------------------------------",
|
||||
"",
|
||||
"====== 合思工作流设计器 (Piper) 免密直达链接 ======",
|
||||
` 企业名称 : ${corp.name} (${corp.corpId || corp.id}) [${envTag}]`,
|
||||
` 操作人身份 : ${corp.staffName || "未指定姓名"} (${corp.staffId})`,
|
||||
` 所属自建应用 : ${platformName ? `${platformName} (${platformId})` : platformId}`,
|
||||
` 目标工作流 : ${pipelineName ? `${pipelineName} (${pipelineId})` : pipelineId}`,
|
||||
` 当前流程状态 : ${stateText}`,
|
||||
" 凭证有效时长 : 约 2 小时 (由合思 EASO Realm 动态颁发)",
|
||||
"",
|
||||
" 直达链接:",
|
||||
` ${directUrl}`,
|
||||
"",
|
||||
`Markdown 直达: [打开「${platformName || "工作流"}」设计器 (${pipelineName || pipelineId} - ${corp.staffName || "免密"})](${directUrl})`,
|
||||
];
|
||||
|
||||
return {
|
||||
stdout: `${lines.join("\n")}\n`,
|
||||
stderr: "",
|
||||
exitCode: 0,
|
||||
};
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
import { isServerManagedDescType } from "../../../domains/platform/workflow/nodes/mutations.js";
|
||||
import { ValidationError } from "../../../core/errors.js";
|
||||
import type { WorkflowDetail } from "../../../domains/platform/workflow/types.js";
|
||||
import { stringOption } from "../../parser.js";
|
||||
import { stringOption, numberOption } from "../../parser.js";
|
||||
import { printJson, printTable, printKeyValue } from "../../printer.js";
|
||||
import { isDryRun, mutationPreview, requireMutationConfirmation } from "../../mutation.js";
|
||||
import type { CliParsedArgs, CliResult, CliRuntime } from "../../types.js";
|
||||
@@ -257,10 +257,12 @@ async function handleAddNode(
|
||||
stdout: "",
|
||||
stderr: [
|
||||
"请指定新增节点类型: --type=<类型>",
|
||||
"常见类型: code-js2 (JS脚本), code (MVEL代码), http (HTTP请求), stop (终止流程), every (循环遍历), condition (分支条件)",
|
||||
"常见类型: task-dynamic-delay (延迟等待), code-js2 (JS脚本), code (MVEL代码), http (HTTP请求), stop (终止流程), every (循环遍历), condition (分支条件)",
|
||||
"",
|
||||
"常用选项:",
|
||||
" --type=<type> 节点类型 (如 code-js2 / code)",
|
||||
" --type=<type> 节点类型 (如 task-dynamic-delay / code-js2 / http)",
|
||||
" --sleep-time=<秒数> 延迟等待秒数 (针对 task-dynamic-delay,如 5)",
|
||||
" --set='key=value' 自定义节点属性注入",
|
||||
" --label=<标题> 节点类型标题",
|
||||
" --display-name=<名称> 设计器节点标题(displayName,最多 20 字符)",
|
||||
" --code-file=<脚本路径> (推荐) 从本地文件导入代码,避免终端转义与 Token 浪费",
|
||||
@@ -269,7 +271,9 @@ async function handleAddNode(
|
||||
" --after=<前置节点name> 插入指定节点之后",
|
||||
" --yes 确认追加",
|
||||
"",
|
||||
"示例: hose-use workflow node add 896398895352487950 --type=code-js2 --label='数据清洗' --code-file=./clean.js --yes",
|
||||
"示例:",
|
||||
" hose-use workflow node add 881196955148578838 --type=task-dynamic-delay --sleep-time=5 --after=action_123 --yes",
|
||||
" hose-use workflow node add 896398895352487950 --type=code-js2 --label='数据清洗' --code-file=./clean.js --yes",
|
||||
].join("\n") + "\n",
|
||||
exitCode: 1,
|
||||
};
|
||||
@@ -288,6 +292,33 @@ async function handleAddNode(
|
||||
code = await fs.readFile(codeFile, "utf-8");
|
||||
}
|
||||
|
||||
const rawSleepTime = numberOption(parsed.options, ["sleep-time", "sleepTime", "seconds"]);
|
||||
const rawSet = stringOption(parsed.options, ["set", "value"]);
|
||||
const extra: Record<string, any> = {};
|
||||
if (rawSleepTime !== undefined) {
|
||||
extra.sleepTime = rawSleepTime;
|
||||
}
|
||||
if (rawSet) {
|
||||
if (rawSet.startsWith("{") && rawSet.endsWith("}")) {
|
||||
try {
|
||||
Object.assign(extra, JSON.parse(rawSet));
|
||||
} catch {
|
||||
// fallback
|
||||
}
|
||||
} else {
|
||||
const eqIdx = rawSet.indexOf("=");
|
||||
if (eqIdx !== -1) {
|
||||
const k = rawSet.slice(0, eqIdx).trim();
|
||||
const v = rawSet.slice(eqIdx + 1).trim();
|
||||
try {
|
||||
extra[k] = JSON.parse(v);
|
||||
} catch {
|
||||
extra[k] = v;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
requireMutationConfirmation(
|
||||
parsed,
|
||||
runtime,
|
||||
@@ -295,6 +326,17 @@ async function handleAddNode(
|
||||
`hose-use workflow node add ${pipelineId} --type=${type}${label ? ` --label="${label}"` : ""}${displayName ? ` --display-name="${displayName}"` : ""}${parent ? ` --parent="${parent}"` : ""}${after ? ` --after="${after}"` : ""} --yes`
|
||||
);
|
||||
|
||||
if (isDryRun(parsed, runtime)) {
|
||||
return mutationPreview(parsed, runtime, "追加工作流节点", pipelineId, {
|
||||
pipelineId,
|
||||
type,
|
||||
label: label || "-",
|
||||
displayName: displayName || "-",
|
||||
targetLocation: parent ? `容器 [${parent}] 内部` : after ? `节点 [${after}] 之后` : "工作流末尾",
|
||||
extra: Object.keys(extra).length ? extra : undefined,
|
||||
});
|
||||
}
|
||||
|
||||
const { client, platformId } = await createWorkflowDetailClient(parsed, runtime, pipelineId);
|
||||
const detail = await getWorkflowDetail(client, pipelineId);
|
||||
|
||||
@@ -306,20 +348,9 @@ async function handleAddNode(
|
||||
code,
|
||||
parent,
|
||||
after,
|
||||
extra: Object.keys(extra).length ? extra : undefined,
|
||||
});
|
||||
|
||||
if (isDryRun(parsed, runtime)) {
|
||||
return mutationPreview(parsed, runtime, "追加工作流节点", pipelineId, {
|
||||
pipelineId,
|
||||
newNodeName: newTask.name,
|
||||
type: newTask.type,
|
||||
label: newTask.label,
|
||||
displayName: newTask.displayName,
|
||||
targetLocation: parent ? `容器 [${parent}] 内部` : after ? `节点 [${after}] 之后` : "工作流末尾",
|
||||
totalTasksCount: updatedWorkflow.tasks?.length || 0,
|
||||
});
|
||||
}
|
||||
|
||||
const saveResult = await saveNodeChanges(client, detail, updatedWorkflow, platformId);
|
||||
|
||||
if (runtime.jsonMode) {
|
||||
@@ -359,12 +390,13 @@ async function handleEditNode(
|
||||
"请提供节点标识 (name 或层级序号): hose-use workflow node edit <pipelineId> <nodeNameOrIndex> [选项]",
|
||||
"",
|
||||
"常用选项:",
|
||||
" --sleep-time=<秒数> 更新延迟等待秒数 (针对 task-dynamic-delay,如 5)",
|
||||
" --set='key=value' 定向修改节点自定义属性 (如 --set='sleepTime=5')",
|
||||
" --label=<类型标题> 更新节点类型标题(服务端保存时可能重新生成)",
|
||||
" --display-name=<新名称> 更新设计器节点标题(displayName,最多 20 字符)",
|
||||
" --code-file=<脚本路径> (推荐) 从本地文件导入最新脚本,避免终端转义与 Token 浪费",
|
||||
" --code=<行内代码> 直接传入代码片段(短脚本)",
|
||||
" --desc=<描述> 更新节点描述",
|
||||
" --set='key=value' 定向修改节点自定义属性",
|
||||
" --dry-run 只预览变更",
|
||||
" --yes 确认保存修改",
|
||||
"",
|
||||
@@ -388,15 +420,27 @@ async function handleEditNode(
|
||||
|
||||
const rawSet = stringOption(parsed.options, ["set", "value"]);
|
||||
const customSet: Record<string, any> = {};
|
||||
const rawSleepTime = numberOption(parsed.options, ["sleep-time", "sleepTime", "seconds"]);
|
||||
if (rawSleepTime !== undefined) {
|
||||
customSet.sleepTime = rawSleepTime;
|
||||
}
|
||||
if (rawSet) {
|
||||
const eqIdx = rawSet.indexOf("=");
|
||||
if (eqIdx !== -1) {
|
||||
const k = rawSet.slice(0, eqIdx).trim();
|
||||
const v = rawSet.slice(eqIdx + 1).trim();
|
||||
if (rawSet.startsWith("{") && rawSet.endsWith("}")) {
|
||||
try {
|
||||
customSet[k] = JSON.parse(v);
|
||||
Object.assign(customSet, JSON.parse(rawSet));
|
||||
} catch {
|
||||
customSet[k] = v;
|
||||
// fallback to key=value if json parse fails
|
||||
}
|
||||
} else {
|
||||
const eqIdx = rawSet.indexOf("=");
|
||||
if (eqIdx !== -1) {
|
||||
const k = rawSet.slice(0, eqIdx).trim();
|
||||
const v = rawSet.slice(eqIdx + 1).trim();
|
||||
try {
|
||||
customSet[k] = JSON.parse(v);
|
||||
} catch {
|
||||
customSet[k] = v;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -416,6 +460,22 @@ async function handleEditNode(
|
||||
`hose-use workflow node edit ${pipelineId} ${nodeTarget}${label ? ` --label="${label}"` : ""}${displayName ? ` --display-name="${displayName}"` : ""} --yes`
|
||||
);
|
||||
|
||||
if (isDryRun(parsed, runtime)) {
|
||||
return mutationPreview(parsed, runtime, "修改工作流节点", `${pipelineId}:${nodeTarget}`, {
|
||||
pipelineId,
|
||||
nodeName: nodeTarget,
|
||||
label: label || "-",
|
||||
displayName: displayName || "-",
|
||||
updatedFields: {
|
||||
...(label ? { label } : {}),
|
||||
...(displayName !== undefined ? { displayName } : {}),
|
||||
...(desc ? { desc } : {}),
|
||||
...(code !== undefined ? { code: `${code.length} 字符${!codeFile && code.length > 300 ? " [TIP: 建议使用 --code-file=<path> 从本地文件载入以规避转义错误并节省 Token]" : ""}` } : {}),
|
||||
...customSet,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
const { client, platformId } = await createWorkflowDetailClient(parsed, runtime, pipelineId);
|
||||
const detail = await getWorkflowDetail(client, pipelineId);
|
||||
|
||||
@@ -428,22 +488,6 @@ async function handleEditNode(
|
||||
});
|
||||
const descManaged = desc !== undefined && isServerManagedDescType(editedTask.type);
|
||||
|
||||
if (isDryRun(parsed, runtime)) {
|
||||
return mutationPreview(parsed, runtime, "修改工作流节点", `${pipelineId}:${editedTask.name}`, {
|
||||
pipelineId,
|
||||
nodeName: editedTask.name,
|
||||
label: editedTask.label,
|
||||
updatedFields: {
|
||||
...(label ? { label } : {}),
|
||||
...(displayName !== undefined ? { displayName } : {}),
|
||||
...(desc && !descManaged ? { desc } : {}),
|
||||
...(descManaged ? { desc: "服务端托管,已跳过" } : {}),
|
||||
...(code !== undefined ? { code: `${code.length} 字符${!codeFile && code.length > 300 ? " [TIP: 建议使用 --code-file=<path> 从本地文件载入以规避转义错误并节省 Token]" : ""}` } : {}),
|
||||
...customSet,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
const saveResult = await saveNodeChanges(client, detail, updatedWorkflow, platformId);
|
||||
|
||||
if (runtime.jsonMode) {
|
||||
|
||||
@@ -18,7 +18,20 @@ export async function handleWorkflowTest(
|
||||
parsed: CliParsedArgs,
|
||||
runtime: CliRuntime
|
||||
): Promise<CliResult> {
|
||||
const pipelineId = parsed.args[0] || stringOption(parsed.options, ["id", "pipeline-id", "pipelineId"]);
|
||||
let pipelineId = parsed.args[0] || stringOption(parsed.options, ["id", "pipeline-id", "pipelineId"]);
|
||||
let flowCodeOrId = stringOption(parsed.options, ["flow", "record", "code", "flow-code", "flowCode", "bill", "entity", "id"]);
|
||||
|
||||
// 智能参数纠错:如果首参数疑似单号/台账记录(非纯数字长ID),且第二个位置参数为工作流ID(16~20位纯数字)
|
||||
if (
|
||||
parsed.args[0] &&
|
||||
parsed.args[1] &&
|
||||
/^\d{16,20}$/.test(parsed.args[1]) &&
|
||||
!/^\d{16,20}$/.test(parsed.args[0])
|
||||
) {
|
||||
flowCodeOrId = parsed.args[0];
|
||||
pipelineId = parsed.args[1];
|
||||
}
|
||||
|
||||
if (!pipelineId) {
|
||||
return {
|
||||
stdout: "",
|
||||
@@ -44,7 +57,6 @@ export async function handleWorkflowTest(
|
||||
};
|
||||
}
|
||||
|
||||
const flowCodeOrId = stringOption(parsed.options, ["flow", "record", "code", "flow-code", "flowCode", "bill", "entity", "id"]);
|
||||
const autoPublish = booleanOption(parsed.options, ["auto-publish", "autoPublish", "publish"]);
|
||||
const timeoutMs = numberOption(parsed.options, ["timeout", "timeout-ms", "timeoutMs"]) ?? 15000;
|
||||
const rawBody = stringOption(parsed.options, ["body", "data", "payload"]);
|
||||
@@ -245,13 +257,16 @@ export async function handleWorkflowTest(
|
||||
...(sampleLines.length > 0
|
||||
? [` --sample=<1|2|3> 直接选用上述服务器最近接收的数据样本发起测试`]
|
||||
: []),
|
||||
` --flow=<单号> 提取指定单据的编码与数据作为 Webhook Payload 发起测试`,
|
||||
` --body='{"key": "value"}' 直接传入自定义 JSON 请求体`,
|
||||
` --file=<payload.json> 从本地 JSON 文件读取请求体`,
|
||||
` --empty 使用空对象 {} 直接发起测试`,
|
||||
"",
|
||||
`示例: hose-use workflow test ${pipelineId} ${
|
||||
sampleLines.length > 0 ? "--sample=1" : `--body='{"code": "TEST-001"}'`
|
||||
`示例:`,
|
||||
` hose-use workflow test ${pipelineId} ${
|
||||
sampleLines.length > 0 ? "--sample=1" : `--flow=B26000148`
|
||||
}`,
|
||||
` hose-use workflow webhook send ${pipelineId} --bill=B26000148 --yes`,
|
||||
].join("\n") + "\n",
|
||||
stderr: "",
|
||||
exitCode: 1,
|
||||
@@ -357,9 +372,13 @@ export async function handleWorkflowTest(
|
||||
].join("\n");
|
||||
return { stdout: `${out}\n`, stderr: "", exitCode: 1 };
|
||||
} catch (err: any) {
|
||||
const errMsg = err.message || String(err);
|
||||
const notFoundHint = errMsg.includes("expected 1 result. got 0")
|
||||
? `\n💡 提示: 云端未查询到工作流 [${pipelineId}] 的调试数据源,请检查工作流 ID 是否有效,或工作流类型是否需要 --flow / --body 等参数。`
|
||||
: "";
|
||||
return {
|
||||
stdout: "",
|
||||
stderr: `未指定测试单号 (--flow=<单号>),且拉取候选单据失败: ${err.message || String(err)}\n`,
|
||||
stderr: `未指定测试单号 (--flow=<单号>),且拉取候选单据失败: ${errMsg}${notFoundHint}\n`,
|
||||
exitCode: 1,
|
||||
};
|
||||
}
|
||||
@@ -489,6 +508,13 @@ export async function handleWorkflowTest(
|
||||
outLines.push(...formatCodeNodeSummariesCard(codeSummaries, report.jobId));
|
||||
}
|
||||
|
||||
if (category === "WEBHOOK" && report.outcome !== "completed") {
|
||||
outLines.push("");
|
||||
outLines.push("💡 [Webhook 流程调试提示]");
|
||||
outLines.push(" 工作流首节点为 Webhook 触发器。若需向合思云端发起真实的 Webhook 事件调度流转,可直接运行:");
|
||||
outLines.push(` hose-use workflow webhook send ${pipelineId}${flowCodeOrId ? ` --bill=${flowCodeOrId}` : ""} --yes`);
|
||||
}
|
||||
|
||||
return {
|
||||
stdout: `${outLines.join("\n")}\n`,
|
||||
stderr: "",
|
||||
|
||||
+86
-4
@@ -3,6 +3,72 @@ import { usageError } from "./errors.js";
|
||||
export type { HelpTopic } from "./command-metadata.js";
|
||||
export const HELP_REGISTRY = COMMAND_METADATA;
|
||||
|
||||
interface SubActionHelp {
|
||||
summary: string;
|
||||
usage: string;
|
||||
options: string[];
|
||||
}
|
||||
|
||||
const SUB_ACTION_HELP: Record<string, SubActionHelp> = {
|
||||
"workflow:node:add": {
|
||||
summary: "向工作流声明式追加任务节点",
|
||||
usage: "hose-use workflow node add <pipelineId> --type=<类型> [选项]",
|
||||
options: [
|
||||
"--type=<type> 节点类型 (如 task-dynamic-delay / code-js2 / http / stop / every)",
|
||||
"--sleep-time=<秒数> 延迟等待秒数 (针对 task-dynamic-delay,如 5)",
|
||||
"--set='key=value' 自定义节点属性注入 (如 --set='sleepTime=5')",
|
||||
"--after=<节点name> 插入在指定节点之后",
|
||||
"--parent=<容器节点name> 插入指定容器节点内部 (如 every 循环)",
|
||||
"--label=<标题> 节点类型标题",
|
||||
"--display-name=<名称> 设计器节点标题(最多 20 字符)",
|
||||
"--code-file=<脚本路径> 从本地文件导入代码 (推荐)",
|
||||
"--code=<代码片段> 传入代码字符串 (仅限简短代码)",
|
||||
"--dry-run 只预览追加变更,不实际写入",
|
||||
"--yes 确认追加新节点",
|
||||
],
|
||||
},
|
||||
"workflow:node:edit": {
|
||||
summary: "定向修改工作流任务节点配置",
|
||||
usage: "hose-use workflow node edit <pipelineId> <nodeNameOrIndex> [选项]",
|
||||
options: [
|
||||
"--sleep-time=<秒数> 更新延迟等待秒数 (针对 task-dynamic-delay,如 5)",
|
||||
"--set='key=value' 定向修改节点自定义属性 (如 --set='sleepTime=5')",
|
||||
"--display-name=<新名称> 更新设计器节点标题(displayName,最多 20 字符)",
|
||||
"--code-file=<脚本路径> 从本地文件导入最新脚本 (推荐)",
|
||||
"--code=<行内代码> 直接传入代码片段",
|
||||
"--desc=<描述> 更新节点描述",
|
||||
"--label=<类型标题> 更新节点类型标题",
|
||||
"--dry-run 只预览变更",
|
||||
"--yes 确认保存修改",
|
||||
],
|
||||
},
|
||||
"workflow:test": {
|
||||
summary: "端到端一键调试工作流(替代前端手工调测)",
|
||||
usage: "hose-use workflow test <pipelineId> [选项]",
|
||||
options: [
|
||||
"--flow=<单号> 测试单据编号 (flowCode 或 flowId)",
|
||||
"--body='{...}' 自定义测试请求体 (针对 Webhook 触发器)",
|
||||
"--sample=<1|2|3> 直接选用服务器最近接收的数据样本发起测试",
|
||||
"--timeout=<ms> 轮询超时时间 (毫秒,默认 15000)",
|
||||
"--auto-publish 调试通过后是否自动发布测试快照 (默认 false)",
|
||||
"--force, -f 生产环境安全放行 (正式企业 env: prod 调试必须加)",
|
||||
"--dry-run 只预览测试配置,不发起调用",
|
||||
"--yes/--confirm 确认执行真实调试",
|
||||
],
|
||||
},
|
||||
"workflow:webhook": {
|
||||
summary: "向工作流 Webhook 触发器发送测试数据 (别名: webhook-send)",
|
||||
usage: "hose-use workflow webhook [send] <pipelineId> [选项]",
|
||||
options: [
|
||||
"--bill=<单号|单据ID> 抓取真实单据数据作为测试载荷发送",
|
||||
"--body='{...}' 指定自定义 JSON 请求体",
|
||||
"--file=<path.json> 从 JSON 文件读取请求体",
|
||||
"--dry-run 仅预览目标 Webhook 地址与载荷,不实际发送",
|
||||
"--yes 确认发送网络请求",
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
export function renderScopedHelp(target: string[]): string {
|
||||
const resolved = resolveCommandMetadata(target[0]);
|
||||
if (!resolved) throw usageError(`未找到命令域帮助: ${target.join(" ") || "<empty>"}。运行 hose-use --help 查看全部命令域。`);
|
||||
@@ -10,10 +76,26 @@ export function renderScopedHelp(target: string[]): string {
|
||||
|
||||
const action = resolveCommandAction(area, target[1]);
|
||||
if (action && !Object.hasOwn(topic.commands, action)) throw usageError(`未找到子命令帮助: ${area} ${target[1]}`);
|
||||
const lines = [`${area} - ${topic.summary}`, "", `用法: ${topic.usage}`, "", "子命令:"];
|
||||
if (action && topic.commands[action]) lines.push(` ${action.padEnd(14)} ${topic.commands[action]}`);
|
||||
else for (const [name, description] of Object.entries(topic.commands)) lines.push(` ${name.padEnd(14)} ${description}`);
|
||||
if (topic.options?.length) lines.push("", "常用选项:", ...topic.options.map((option) => ` ${option}`));
|
||||
|
||||
const subTarget = target[2]?.toLowerCase();
|
||||
const subKey = subTarget ? `${area}:${action}:${subTarget}` : `${area}:${action}`;
|
||||
const subHelp = SUB_ACTION_HELP[subKey] || SUB_ACTION_HELP[`${area}:${action}`];
|
||||
|
||||
const titlePrefix = subHelp ? `${area} ${action}${subTarget ? ` ${subTarget}` : ""}` : area;
|
||||
const summaryText = subHelp?.summary || topic.summary;
|
||||
const usageText = subHelp?.usage || topic.usage;
|
||||
const commonOpts = subHelp?.options || topic.options;
|
||||
|
||||
const lines = [`${titlePrefix} - ${summaryText}`, "", `用法: ${usageText}`, "", "子命令:"];
|
||||
if (subHelp) {
|
||||
lines.push(` ${action}${subTarget ? ` ${subTarget}` : ""}`.padEnd(16) + ` ${subHelp.summary}`);
|
||||
} else if (action && topic.commands[action]) {
|
||||
lines.push(` ${action.padEnd(14)} ${topic.commands[action]}`);
|
||||
} else {
|
||||
for (const [name, description] of Object.entries(topic.commands)) lines.push(` ${name.padEnd(14)} ${description}`);
|
||||
}
|
||||
|
||||
if (commonOpts?.length) lines.push("", "常用选项:", ...commonOpts.map((option) => ` ${option}`));
|
||||
lines.push("", "支持选项:", ...Object.entries(commandFlags(area, action)).map(([key, kind]) => ` --${key}${kind === "value" ? "=<值>" : kind === "boolean-or-value" ? "[=<值>]" : ""}`));
|
||||
lines.push("", "提示: 追加 --json 获取机器可解析结果;写操作先用 --dry-run,再用 --yes 或 --confirm 执行。", "更多: hose-use --help");
|
||||
return lines.join("\n");
|
||||
|
||||
+4
-2
@@ -93,9 +93,11 @@ function isVersionRequested(parsed: CliParsedArgs): boolean {
|
||||
|
||||
function resolveHelpTarget(parsed: CliParsedArgs): string[] {
|
||||
if (["help", "h", "?"].includes((parsed.area || "").toLowerCase())) {
|
||||
return [parsed.action, parsed.args[0]].filter((value): value is string => Boolean(value));
|
||||
return [parsed.action, parsed.args[0], parsed.args[1]].filter((value): value is string => Boolean(value));
|
||||
}
|
||||
return [parsed.area, parsed.action === "help" ? parsed.args[0] : parsed.action].filter((value): value is string => Boolean(value));
|
||||
const primaryAction = parsed.action === "help" ? parsed.args[0] : parsed.action;
|
||||
const subAction = parsed.action === "help" ? parsed.args[1] : parsed.args[0];
|
||||
return [parsed.area, primaryAction, subAction].filter((value): value is string => Boolean(value));
|
||||
}
|
||||
|
||||
async function dispatchCli(rawArgs: string[], options: CliRunOptions = {}): Promise<CliResult> {
|
||||
|
||||
@@ -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",
|
||||
@@ -442,7 +443,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>;
|
||||
Reference in new issue
Block a user