feat(workflow): 企业可用节点探针、灰度开通收敛与DataLink公式硬规则校验

This commit is contained in:
gitea committed 2026-10-20 13:08:36 +08:00
1 parent 4f0eea5725
commit 0768b94d65
14 files changed
+974 -22

No files matched your search

+66 -3
View File
@@ -1,6 +1,6 @@
import { z } from "zod";
import { KyInstance } from "ky";
import { AuthenticationError, EkbApiError } from "../../core/errors.js";
import ky, { KyInstance } from "ky";
import { AuthenticationError, BusinessError, EkbApiError } from "../../core/errors.js";
import {
PlatformSchema,
WorkflowPageSchema,
@@ -16,6 +16,7 @@ import {
WorkflowExecutionPageSchema,
WorkflowExecutionLogSchema,
WorkflowDslSchema,
WorkflowDslCatalogSchema,
StaffSchema,
WebhookInfoSchema,
WorkflowSampleDataSchema,
@@ -325,7 +326,34 @@ export async function listDsl(
client: KyInstance
): Promise<import("./types.js").WorkflowDsl[]> {
const response = await client.get("api/easo/dsl/all");
return unwrap(response, z.array(WorkflowDslSchema));
const raw = await response.json<any>();
const payload = raw?.data ?? raw;
if (Array.isArray(payload)) {
return payload.map((item) => WorkflowDslSchema.parse(item));
}
// 若是对象结构,将各分类下的 items 拍平返回
const allItems: any[] = [
...(payload?.action || []),
...(payload?.control || []),
...(payload?.trigger || []),
];
return allItems.map((item) => WorkflowDslSchema.parse(item));
}
export async function listDslCatalog(
client: KyInstance
): Promise<import("./types.js").WorkflowDslCatalog> {
const response = await client.get("api/easo/dsl/all");
const raw = await response.json<any>();
const payload = raw?.data ?? raw;
if (Array.isArray(payload)) {
return {
action: payload,
control: [],
trigger: [],
};
}
return WorkflowDslCatalogSchema.parse(payload || {});
}
// ── 员工列表(Piper)──────────────────────────────────────────────────────────
@@ -429,4 +457,39 @@ export async function getWorkflowEnumOptions(
return unwrap(response, z.array(WorkflowEnumItemSchema));
}
// ── 灰度节点开通网关 ──────────────────────────────────────────────────────────
export async function grantWorkflowNodesApi(options: {
token: string;
corpId: string;
nodes: string[];
baseUrl?: string;
}): Promise<import("./types.js").GrantWorkflowNodesResult> {
const payload = {
token: options.token,
corpId: options.corpId,
nodes: options.nodes.join(","),
...(options.baseUrl ? { baseUrl: options.baseUrl } : {}),
};
try {
const response = await ky.post("https://d9jxeccs5j.sealosgzg.site/hose-workflow-node", {
json: payload,
timeout: 30000,
});
const json = (await response.json()) as any;
const data = json?.data ?? {};
return {
success: Boolean(json?.success ?? true),
saved: Array.isArray(data.saved) ? data.saved : [],
skipped: Array.isArray(data.skipped) ? data.skipped : [],
rawMessage: json?.msg || json?.message || "",
};
} catch (err: any) {
const message = err?.message || String(err);
throw new EkbApiError(`灰度节点开通网关调用失败: ${message}`, "GATEWAY_ERROR", 502);
}
}
+77 -2
View File
@@ -1,7 +1,7 @@
import { KyInstance } from "ky";
import { CorpConfig } from "../../core/config/types.js";
import * as api from "./api.js";
import { ValidationError } from "../../core/errors.js";
import { PermissionError, ValidationError } from "../../core/errors.js";
import { explainConditionBranches } from "./workflow/branch/index.js";
import { indexExecutionContexts } from "./execution-context.js";
import {
@@ -70,7 +70,12 @@ export async function copyWorkflow(
(cloned.tasks[0] as any).urlPath = crypto.randomUUID();
delete (cloned.tasks[0] as any).sampleId;
}
return api.copyWorkflow(client, pipelineId, cloned);
const result = await api.copyWorkflow(client, pipelineId, cloned);
if (options.label && result.label !== options.label) {
result.label = options.label;
return api.updateWorkflow(client, result);
}
return result;
}
export interface CreateWorkflowOptions {
@@ -977,4 +982,74 @@ export async function resolveWorkflowEnumOptions(
return [];
}
// ── 工作流企业可用节点探针与灰度开通 ──────────────────────────────────────────
export async function getWorkflowAvailableNodes(
client: KyInstance
): Promise<import("./types.js").AvailableWorkflowNodes> {
const catalog = await api.listDslCatalog(client);
const allTypes = new Set<string>();
for (const item of catalog.action) {
if (item.type) allTypes.add(item.type);
}
for (const item of catalog.control) {
if (item.type) allTypes.add(item.type);
}
for (const item of catalog.trigger) {
if (item.type) allTypes.add(item.type);
}
return {
allTypes,
actionNodes: catalog.action,
controlNodes: catalog.control,
triggerNodes: catalog.trigger,
};
}
export async function grantWorkflowNodes(
corp: CorpConfig,
options: import("./types.js").GrantWorkflowNodesOptions
): Promise<import("./types.js").GrantWorkflowNodesResult> {
if (!options.nodes || options.nodes.length === 0) {
throw new ValidationError("必须指定至少一个需要开通的节点名称或类型");
}
// 1. 管理员密码保护预留设计
const adminPassword = process.env.HOSE_ADMIN_PASSWORD;
if (adminPassword) {
if (!options.password || options.password !== adminPassword) {
throw new PermissionError(
"灰度节点开通功能已启用管理员保护,请通过 --password 或配置输入正确的管理员密码"
);
}
}
// 2. 节点清洗与归一化(将可能传入的中文名映射为标准的 node type)
const { findGrayNode } = await import("./workflow/nodes/gray-nodes-catalog.js");
const normalizedNodes = options.nodes.map((node) => {
const matched = findGrayNode(node);
return matched ? matched.type : node.trim();
});
const token = corp.credentials?.accessToken;
const corpId = corp.corpId || corp.credentials?.corpId || corp.id;
const baseUrl = corp.baseUrl;
if (!token) {
throw new ValidationError("当前企业缺少 accessToken,无法发起节点开通申请");
}
// 3. 调用开通 API
const result = await api.grantWorkflowNodesApi({
token,
corpId,
nodes: normalizedNodes,
baseUrl,
});
return result;
}
export * from "./workflow/index.js";
+66 -9
View File
@@ -269,20 +269,31 @@ export const WorkflowDetailSchema = z.object({
label: z.string().default(""),
desc: z.string().nullable().optional(),
customDesc: z.string().nullable().optional(),
state: z.number().default(0),
debugState: z.number().default(0),
runTimes: z.number().default(0),
errorTimes: z.number().default(0),
state: z.coerce.number().default(0),
debugState: z.coerce.number().default(0),
runTimes: z.coerce.number().default(0),
errorTimes: z.coerce.number().default(0),
updateTime: z.string().default(""),
updateUser: z.string().nullable().optional(),
staffName: z.string().nullable().optional(),
version: z.string().default(""),
dataLimit: z.number().default(20),
source: z.number().default(0),
dataLimit: z.coerce.number().default(20),
source: z.coerce.number().default(0),
queueJobs: z.boolean().default(false),
tasksVersion: z.number().default(0),
tasksVersion: z.coerce.number().default(0),
tasks: z.array(WorkflowTaskSchema).default([]),
alarm: WorkflowAlarmSchema.optional(),
alarm: z.union([
WorkflowAlarmSchema,
z.string().transform((val) => {
try {
const parsed = JSON.parse(val);
return WorkflowAlarmSchema.safeParse(parsed).data ?? undefined;
} catch {
return undefined;
}
}),
z.null(),
]).optional(),
inputs: z.array(z.object({ key: z.string(), value: z.any() })).optional(),
"$snapshot": z.array(z.object({ key: z.string(), value: z.string() })).optional(),
}).passthrough();
@@ -422,12 +433,58 @@ export const WorkflowExecutionPageSchema = z
// ── DSL 配置 ─────────────────────────────────────────────────────────────────
export const WorkflowDslSchema = z.object({
id: z.string(),
id: z.string().optional(),
name: z.string().default(""),
type: z.string().default(""),
config: z.record(z.string(), z.any()).default({}),
});
export const WorkflowNodeDefinitionSchema = z
.object({
id: z.string().nullable().optional(),
name: z.string().default(""),
type: z.string().default(""),
groupName: z.string().nullable().optional(),
icon: z.string().nullable().optional(),
iconColor: z.string().nullable().optional(),
remark: z.string().nullable().optional(),
platform: z.string().nullable().optional(),
version: z.number().nullable().optional(),
$json: z.string().nullable().optional(),
})
.passthrough();
export type WorkflowNodeDefinition = z.infer<typeof WorkflowNodeDefinitionSchema>;
export const WorkflowDslCatalogSchema = z
.object({
action: z.array(WorkflowNodeDefinitionSchema).default([]),
control: z.array(WorkflowNodeDefinitionSchema).default([]),
trigger: z.array(WorkflowNodeDefinitionSchema).default([]),
})
.passthrough();
export type WorkflowDslCatalog = z.infer<typeof WorkflowDslCatalogSchema>;
export interface AvailableWorkflowNodes {
allTypes: Set<string>;
actionNodes: WorkflowNodeDefinition[];
controlNodes: WorkflowNodeDefinition[];
triggerNodes: WorkflowNodeDefinition[];
}
export interface GrantWorkflowNodesOptions {
nodes: string[];
password?: string;
}
export interface GrantWorkflowNodesResult {
success: boolean;
saved: string[];
skipped: string[];
rawMessage: string;
}
// ── 员工 ─────────────────────────────────────────────────────────────────────
export const StaffSchema = z.object({
@@ -18,6 +18,8 @@ hose-use workflow debug <pipelineId> --flow=<单号> --yes
hose-use workflow create [--name=<名称>] [--trigger=webhook|clock|datalink|flowform] [--file=<JSON模板>] [--dry-run|--yes]
hose-use workflow copy <pipelineId> [--name=<名称>] [--platform-id=<应用ID>] [--dry-run|--yes]
hose-use workflow delete <pipelineId> [--dry-run|--yes]
hose-use workflow nodes [list] [--all]
hose-use workflow nodes grant <type...> [--password=<pwd>]
hose-use workflow node list <pipelineId>
hose-use workflow node get <pipelineId> <节点name或#序号>
hose-use workflow node add <pipelineId> --type=code-js2 --label="清洗" --code="..." [--after=<节点>] [--parent=<容器>] [--dry-run|--yes]
@@ -72,3 +74,20 @@ hose-use workflow eval-script --code="return a + b;" --input='{"a":1,"b":2}'
- 条件解释支持已声明的比较操作符、嵌套 AND/OR 和循环上下文;缺少证据、不支持的值类型或执行尚未结束时,`evaluation` / `matched` 为 `null`,不据此声称分支判定为 False。
- `diff-job` 按父任务路径、循环路径及重复次数配对实例;JSON 节点包含 `instanceKey` / `currentLoopPath`,输出变化也计入差异。
- `execution-context.ts` 是条件解释和 Job diff 共用的纯执行实例索引,不负责请求或 CLI 输出。
## 企业可用节点探针与灰度开通(Nodes Probe & Grant)
合思微前端(Piper)在进入流程设计器与渲染节点级联选择器时,调用 `GET /api/easo/dsl/all` 获取当前租户真实已开通的节点字典(Action、Control、Trigger):
- 前端级联选择器仅会渲染当前企业已开通的节点,未开通节点在界面中完全隐身;
- 若工作流在后端配置了当前租户未开通的节点类型,执行 `hose-use workflow analyze` 会触发 `PERMISSION_MISSING_NODE` 阻止性诊断并提示开通命令;
- 执行 `hose-use workflow nodes` 查看当前租户已开通的节点字典;
- 执行 `hose-use workflow nodes --all` 查看当前企业与官方全量 108 个灰度节点清单的开通状态对照;
- 执行 `hose-use workflow nodes grant <type...>` 申请开通灰度节点(内置管理员密码预留设计:未配置环境变量 `HOSE_ADMIN_PASSWORD` 时为免密便捷模式;配置后强制要求 `--password` 授权)。
## 静态分析器硬规则:DataLink 公式误填拦截
在 `ekuaibao-datalink-create` / `ekuaibao-datalink-edit` 等业务对象数据写入节点中:
- 合思 DataLink 属于底层数据写入节点,**不具备前端表单公式求值引擎**;
- 若在字段映射中误填表单公式(如 `AddMonths(...)`、`dateDIF(...)`),公式字符串将被直接传给后端,在强类型转换时触发 `ParseException` 导致流程崩溃;
- 静态分析器通过 `MISPLACED_FORMULA_IN_DATALINK_MAPPING` 规则在离线期直接拦截并报出致命错误,引导前置增加代码节点(MVEL/JS)预先求值。
@@ -19,6 +19,13 @@ const KNOWN_TYPES = new Set([
"flow-detail",
"code",
"code-js2",
"apportion",
"flow-change-trigger",
"datalink-button-trigger",
"email",
"message",
"message-dingtalk",
"dmn",
"ekuaibao-datalink-filter",
"ekuaibao-datalink-create",
"ekuaibao-datalink-edit",
@@ -212,6 +219,81 @@ function findUnguardedDatalinkEdits(
return found;
}
const FORMULA_REGEX =
/\b(AddMonths|dateDIF|DATEADD|DATEDIF|IF|SUM|ROUND|INT|TEXT|YEAR|MONTH|DAY)\s*\(/i;
function checkMisplacedFormulasInDatalink(
task: WorkflowTask,
path: string,
diagnostics: WorkflowDiagnostic[]
): void {
if (!task.type.includes("datalink")) return;
const raw = task as Record<string, unknown>;
const inspectTargets: Array<{ key: string; value: unknown }> = [];
// 1. inspect task.inputs
if (Array.isArray(task.inputs)) {
for (const inp of task.inputs) {
if (inp && typeof inp === "object") {
inspectTargets.push({ key: inp.key || (inp as any).name || "input", value: inp.value });
}
}
} else if (raw.inputs && typeof raw.inputs === "object") {
for (const [k, v] of Object.entries(raw.inputs as Record<string, unknown>)) {
inspectTargets.push({ key: k, value: v });
}
}
// 2. inspect task.form / formValues / mapping
const formEntries = getTaskFormEntries(task);
for (const entry of formEntries) {
if (entry.key) {
inspectTargets.push({ key: entry.key, value: entry.value });
}
}
// 3. inspect raw.mapping / raw.data / raw.jsonMapping
if (Array.isArray(raw.mapping)) {
for (const m of raw.mapping) {
if (m && typeof m === "object") {
const item = m as Record<string, unknown>;
inspectTargets.push({
key: String(item.key || item.target || "field"),
value: item.value ?? item.source,
});
}
}
}
// 4. inspect task.fields / raw.fields (合思业务对象新增/修改字段映射)
const fields = (task as any).fields ?? raw.fields;
if (Array.isArray(fields)) {
for (const f of fields) {
if (f && typeof f === "object") {
const item = f as Record<string, unknown>;
inspectTargets.push({
key: String(item.key || item.label || "field"),
value: item.value,
});
}
}
}
for (const target of inspectTargets) {
if (typeof target.value === "string") {
const match = target.value.match(FORMULA_REGEX);
if (match) {
diagnostics.push({
severity: "error",
code: "MISPLACED_FORMULA_IN_DATALINK_MAPPING",
path,
message: `DataLink 任务 '${task.label || task.name}' 的字段 '${target.key}' 配置了表单公式 '${match[0]}...'。合思 DataLink 属于底层数据写入节点,不支持前端表单公式求值,传入公式字符串会导致后端强类型解析崩溃 (如 ParseException)。请前置添加【代码节点】计算该值并在此处引用。`,
});
}
}
}
}
export function analyzeWorkflow(
detail: WorkflowDetail,
options: AnalyzeWorkflowOptions = {}
@@ -220,6 +302,15 @@ export function analyzeWorkflow(
const dependencies: WorkflowDependency[] = [];
const diagnostics: WorkflowDiagnostic[] = [];
const availableSet: Set<string> | undefined = options.availableNodeTypes
? new Set(
(Array.isArray(options.availableNodeTypes)
? options.availableNodeTypes
: Array.from(options.availableNodeTypes)
).map((t) => t.trim().toLowerCase())
)
: undefined;
if (detail.state === 0) {
diagnostics.push({
severity: "warning",
@@ -262,6 +353,19 @@ export function analyzeWorkflow(
});
}
// 诊断:租户节点开通权限校验
if (availableSet && availableSet.size > 0 && !availableSet.has(task.type.toLowerCase())) {
diagnostics.push({
severity: "error",
code: "PERMISSION_MISSING_NODE",
path,
message: `当前企业尚未开通节点类型 '${task.type}',工作流运行时将被合思引擎直接阻断。请先使用 'hose-use workflow nodes grant ${task.type}' 开通灰度权限,或替换为已开通的等价节点。`,
});
}
// 诊断:DataLink 字段误填表单公式硬校验
checkMisplacedFormulasInDatalink(task, path, diagnostics);
// 诊断 2: every 循环内 flow-create-task (SKIP) 后跟无状态守卫的 ekuaibao-datalink-edit
if (insideEvery && task.type === "flow-create-task") {
const onError = (task as Record<string, unknown>).onError as
@@ -164,5 +164,62 @@ describe("Workflow static analysis", () => {
expect(codes).toContain("MISSING_BACKLOG_DATA_BRACKETS");
expect(result.diagnostics.find((d) => d.code === "MISSING_BACKLOG_DATA_BRACKETS")?.severity).toBe("warning");
});
it("detects PERMISSION_MISSING_NODE when workflow uses nodes not granted to the enterprise", () => {
const wf = {
id: "wf-missing-perm",
label: "新代码节点测试",
state: 1,
version: "1",
tasks: [
{
name: "action_1",
type: "code-js2",
label: "新版JS节点",
code: "return 1;",
},
],
};
// 假设企业只开通了 code 和 http,没有开通 code-js2
const result = analyzeWorkflow(wf as any, {
availableNodeTypes: ["code", "http"],
});
const missingNodeDiag = result.diagnostics.find(
(d) => d.code === "PERMISSION_MISSING_NODE"
);
expect(missingNodeDiag).toBeDefined();
expect(missingNodeDiag?.severity).toBe("error");
expect(missingNodeDiag?.message).toContain("code-js2");
});
it("detects MISPLACED_FORMULA_IN_DATALINK_MAPPING when formulas are placed in DataLink fields", () => {
const wf = {
id: "wf-datalink-formula",
label: "台账摊销工作流",
state: 1,
version: "1",
tasks: [
{
name: "action_create",
type: "ekuaibao-datalink-create",
label: "新增摊销台账",
mapping: [
{
key: "amortizationMonth",
value: "AddMonths(date, 1)",
},
],
},
],
};
const result = analyzeWorkflow(wf as any);
const formulaDiag = result.diagnostics.find(
(d) => d.code === "MISPLACED_FORMULA_IN_DATALINK_MAPPING"
);
expect(formulaDiag).toBeDefined();
expect(formulaDiag?.severity).toBe("error");
expect(formulaDiag?.message).toContain("AddMonths");
expect(formulaDiag?.message).toContain("代码节点");
});
});
@@ -47,4 +47,5 @@ export interface WorkflowFormSpecLike {
export interface AnalyzeWorkflowOptions {
specifications?: Record<string, WorkflowFormSpecLike | undefined>;
availableNodeTypes?: Set<string> | string[];
}
@@ -0,0 +1,138 @@
export interface GrayNodeItem {
displayName: string;
name: string;
type: string;
category?: "action" | "control" | "trigger" | "unknown";
}
/**
* 合思官方工作流灰度节点清单(共 108 个有效去重条目)
* 来源于官方灰度开通对照表
*/
export const GRAY_NODES_CATALOG: readonly GrayNodeItem[] = [
{ displayName: "JS节点(新)", name: "JS节点(新)", type: "code-js2", category: "action" },
{ displayName: "重算审批流", name: "重算审批流", type: "recalculate-the-approval-flow", category: "action" },
{ displayName: "提示框", name: "提示框", type: "ui-notification", category: "action" },
{ displayName: "定时任务节点", name: "定时任务节点", type: "start", category: "trigger" },
{ displayName: "推送飞书消息", name: "推送飞书消息", type: "feishu-sendMsg", category: "action" },
{ displayName: "飞书消息", name: "飞书消息", type: "message-feishu", category: "action" },
{ displayName: "if节点", name: "if节点", type: "if", category: "control" },
{ displayName: "http节点", name: "http节点", type: "http", category: "action" },
{ displayName: "遍历数组", name: "遍历数组", type: "loop", category: "control" },
{ displayName: "循环节点", name: "循环节点", type: "while", category: "control" },
{ displayName: "企业微信开放平台获取子部门ID列表", name: "企业微信开放平台获取子部门ID列表", type: "wecom-department", category: "action" },
{ displayName: "易桥参数转化", name: "易桥参数转化", type: "eBridge-mapData", category: "action" },
{ displayName: "代码节点", name: "代码节点", type: "code", category: "action" },
{ displayName: "数据映射", name: "数据映射", type: "mapping", category: "action" },
{ displayName: "纷享销客鉴权", name: "纷享销客鉴权", type: "fxiaoke-auth", category: "action" },
{ displayName: "纷享销客数据列表", name: "纷享销客数据列表", type: "fxiaoke-list", category: "action" },
{ displayName: "NetSuite数据列表", name: "NetSuite数据列表", type: "netsuite-sync", category: "action" },
{ displayName: "NetSuite数据创建", name: "NetSuite数据创建", type: "netsuite-create", category: "action" },
{ displayName: "易桥鉴权", name: "易桥鉴权", type: "ebridge-auth", category: "action" },
{ displayName: "新增业务对象数据", name: "新增业务对象数据", type: "ekuaibao-datalink-create", category: "action" },
{ displayName: "定时触发", name: "定时触发", type: "clock", category: "trigger" },
{ displayName: "纷享销客触发器", name: "纷享销客触发器", type: "fxiaoke-trigger", category: "trigger" },
{ displayName: "到达业务对象数据中的日期时触发", name: "到达业务对象数据中的日期时触发", type: "ekuaibao-datalink-time-trigger", category: "trigger" },
{ displayName: "发送邮件", name: "发送邮件", type: "email", category: "action" },
{ displayName: "查找业务对象数据", name: "查找业务对象数据", type: "ekuaibao-datalink-filter", category: "action" },
{ displayName: "修改业务对象数据", name: "修改业务对象数据", type: "ekuaibao-datalink-edit", category: "action" },
{ displayName: "NetSuite数据删除", name: "NetSuite数据删除", type: "netsuite-delete", category: "action" },
{ displayName: "薪人薪事触发器", name: "薪人薪事触发器", type: "xrxs-trigger", category: "trigger" },
{ displayName: "新增业务对象数据时触发", name: "新增业务对象数据时触发", type: "ekuaibao-datalink-create-trigger", category: "trigger" },
{ displayName: "变更业务对象数据时触发", name: "变更业务对象数据时触发", type: "ekuaibao-datalink-change-trigger", category: "trigger" },
{ displayName: "单据审批事件触发器", name: "单据审批事件触发器", type: "ekuaibao-flowform-trigger", category: "trigger" },
{ displayName: "发送短信", name: "发送短信", type: "message", category: "action" },
{ displayName: "webhook触发器", name: "webhook触发器", type: "webhook", category: "trigger" },
{ displayName: "对话框", name: "对话框", type: "ui-dialog", category: "action" },
{ displayName: "流程日志", name: "流程日志", type: "task-log", category: "action" },
{ displayName: "动态节点测试", name: "动态节点测试", type: "task-dynamic-test", category: "action" },
{ displayName: "条件节点", name: "条件节点", type: "condition", category: "control" },
{ displayName: "OpenAPI", name: "OpenAPI", type: "task-openapi", category: "action" },
{ displayName: "终止节点", name: "终止节点", type: "stop", category: "action" },
{ displayName: "收集节点", name: "收集节点", type: "context", category: "action" },
{ displayName: "到达单据日期时触发", name: "到达单据日期时触发", type: "flow-change-trigger", category: "trigger" },
{ displayName: "获取钉钉考勤", name: "获取钉钉考勤", type: "task-dynamic-ding-attendance", category: "action" },
{ displayName: "摊销节点", name: "摊销节点", type: "apportion", category: "control" },
{ displayName: "创建单据", name: "创建单据", type: "flow-create-task", category: "action" },
{ displayName: "站内信", name: "站内信", type: "message-internet", category: "action" },
{ displayName: "钉钉消息", name: "钉钉消息", type: "message-dingtalk", category: "action" },
{ displayName: "修改角色", name: "修改角色", type: "role-update", category: "action" },
{ displayName: "依次执行", name: "依次执行", type: "every", category: "control" },
{ displayName: "查询申请事项详情", name: "查询申请事项详情", type: "ekuaibao-requision-detail", category: "action" },
{ displayName: "查询单据详情", name: "查询单据详情", type: "flow-detail", category: "action" },
{ displayName: "查询单据历史详情", name: "查询单据历史详情", type: "flow-detail-versioned", category: "action" },
{ displayName: "业务对象数据按钮触发", name: "业务对象数据按钮触发", type: "datalink-button-trigger", category: "trigger" },
{ displayName: "查找行程数据", name: "查找行程数据", type: "ekuaibao-tmc-datalink-filter", category: "action" },
{ displayName: "新增行程数据时触发", name: "新增行程数据时触发", type: "ekuaibao-tmc-datalink-create-trigger", category: "trigger" },
{ displayName: "变更行程数据时触发", name: "变更行程数据时触发", type: "ekuaibao-tmc-datalink-change-trigger", category: "trigger" },
{ displayName: "到达行程日期时触发", name: "到达行程日期时触发", type: "ekuaibao-tmc-datalink-time-trigger", category: "trigger" },
{ displayName: "查询发票", name: "查询发票", type: "ekuaibao-invoice-datalink-filter", category: "action" },
{ displayName: "结果输出", name: "结果输出", type: "output", category: "action" },
{ displayName: "EBOT触发", name: "EBOT触发", type: "ekuaibao-ebot-trigger", category: "trigger" },
{ displayName: "补充发票触发", name: "补充发票触发", type: "other-event-trigger", category: "trigger" },
{ displayName: "发票验真", name: "发票验真", type: "invoice-verification", category: "action" },
{ displayName: "JS节点", name: "JS节点", type: "code-js", category: "action" },
{ displayName: "数据转化", name: "数据转化", type: "data-convert", category: "action" },
{ displayName: "新摊销", name: "新摊销", type: "amortization", category: "control" },
{ displayName: "数据映射", name: "数据映射", type: "dmn", category: "action" },
{ displayName: "查询人员", name: "查询人员", type: "ekuaibao-staff-filter", category: "action" },
{ displayName: "查询单据列表", name: "查询单据列表", type: "flow-list", category: "action" },
{ displayName: "HAB触发器", name: "HAB触发器", type: "hab-trigger-task", category: "trigger" },
{ displayName: "申请事项触发器", name: "申请事项触发器", type: "ekuaibao-requisition-trigger", category: "trigger" },
{ displayName: "创建部门", name: "创建部门", type: "department-create", category: "action" },
{ displayName: "部门查询", name: "部门查询", type: "department-filter", category: "action" },
{ displayName: "新增人员", name: "新增人员", type: "staff-create", category: "action" },
{ displayName: "查询随手记列表", name: "查询随手记列表", type: "ekuaibao-ecard-fee-filter", category: "action" },
{ displayName: "查询人员详情", name: "查询人员详情", type: "ekuaibao-staff-detail", category: "action" },
{ displayName: "查询部门详情", name: "查询部门详情", type: "ekuaibao-department-detail", category: "action" },
{ displayName: "查询易商卡申请事项列表", name: "查询易商卡申请事项列表", type: "ekuaibao-ecard-requisition-filter", category: "action" },
{ displayName: "查询飞书部门", name: "查询飞书部门", type: "feishu-department-filter", category: "action" },
{ displayName: "修改部门", name: "修改部门", type: "ekuaibao-department-update", category: "action" },
{ displayName: "站外信", name: "站外信", type: "message-outnet", category: "action" },
{ displayName: "AI节点", name: "AI节点", type: "ekb-ai", category: "action" },
{ displayName: "修改单据", name: "修改单据", type: "flow-update-task", category: "action" },
{ displayName: "提取文本(word,PDF)", name: "提取文本(word,PDF)", type: "ekb-ai-pdf", category: "action" },
{ displayName: "单据风险写入", name: "单据风险写入", type: "risk", category: "action" },
{ displayName: "天润工单查询", name: "天润工单查询", type: "tr-select", category: "action" },
{ displayName: "天润工单评论", name: "天润工单评论", type: "tr-comment", category: "action" },
{ displayName: "天润工单查询详情", name: "天润工单查询详情", type: "tr-detail", category: "action" },
{ displayName: "Dify接入", name: "Dify接入", type: "dify", category: "action" },
{ displayName: "图片URL识别", name: "图片URL识别", type: "ekb-ai-url", category: "action" },
{ displayName: "AI文本理解", name: "AI文本理解", type: "ekb-minimax-text", category: "action" },
{ displayName: "AI图像理解", name: "AI图像理解", type: "ekb-minimax-photo", category: "action" },
{ displayName: "查询角色下的人员", name: "查询角色下的人员", type: "search-staff-by-role", category: "action" },
{ displayName: "发票巡检", name: "发票巡检", type: "ekuaibao-invoice-inspector", category: "action" },
{ displayName: "招商银行商务卡查询", name: "招商银行商务卡查询", type: "task-zs", category: "action" },
{ displayName: "单据查询详情(跨租户)", name: "单据查询详情(跨租户)", type: "escape", category: "action" },
{ displayName: "海亮单据查询详情", name: "海亮单据查询详情", type: "hl-detail", category: "action" },
{ displayName: "单据查询详情AI审批专用", name: "单据查询详情AI审批专用", type: "mapping-detail", category: "action" },
{ displayName: "海亮数据集列表", name: "海亮数据集列表", type: "hl", category: "action" },
{ displayName: "查询易商卡流水的费用信息", name: "查询易商卡流水的费用信息", type: "ekuaibao-ecard-fee-detail-filter", category: "action" },
{ displayName: "Ebot审批", name: "Ebot审批", type: "ebot-approval-flow", category: "action" },
{ displayName: "给OA账号发送提醒", name: "给OA账号发送提醒", type: "oa", category: "action" },
{ displayName: "查询历史单据测试集", name: "查询历史单据测试集", type: "flow-sample-list", category: "action" },
{ displayName: "分类汇总", name: "分类汇总", type: "aggregation", category: "action" },
{ displayName: "单据转译节点", name: "单据转译节点", type: "flow-format", category: "action" },
{ displayName: "导出表格", name: "导出表格", type: "excel", category: "action" },
{ displayName: "AI附件理解", name: "AI附件理解", type: "ai-attachment", category: "action" },
{ displayName: "AI智能匹配", name: "AI智能匹配", type: "ai-classification", category: "action" },
{ displayName: "AI智能提取", name: "AI智能提取", type: "ai-extraction", category: "action" },
{ displayName: "延迟执行节点", name: "延迟执行节点", type: "task-dynamic-delay", category: "action" },
];
const typeMap = new Map<string, GrayNodeItem>();
const nameMap = new Map<string, GrayNodeItem>();
for (const item of GRAY_NODES_CATALOG) {
typeMap.set(item.type.toLowerCase(), item);
nameMap.set(item.displayName.toLowerCase(), item);
}
export function findGrayNode(query: string): GrayNodeItem | undefined {
const q = query.trim().toLowerCase();
return typeMap.get(q) || nameMap.get(q);
}
export function isKnownGrayNodeType(type: string): boolean {
return typeMap.has(type.trim().toLowerCase());
}
@@ -2,3 +2,4 @@ export * from "./types.js";
export * from "./tree.js";
export * from "./locator.js";
export * from "./mutations.js";
export * from "./gray-nodes-catalog.js";