refactor: 将应用数据与工作流统一归入应用平台子模块
建立 applications 的应用模型和查询出口,保留基础及详情投影差异。 下沉 DataLink,将工作流模型、API、编排及执行上下文归回 workflow。 同步 CLI、SDK、生成脚本、测试和活跃文档引用,公开命令与 SDK 名称保持兼容。 验证:943 项测试、类型和版本检查通过;三份生成规范字节一致,README 审计通过。
This commit is contained in:
1 parent
edf300b808
commit
4e03c9bcd7
107 files changed
+423
-496
No files matched your search
@@ -0,0 +1,27 @@
|
||||
import { ValidationError } from "../../../core/errors.js";
|
||||
import type { DatalinkField } from "./types.js";
|
||||
|
||||
/** 物理键优先;标签和模糊匹配必须指向唯一物理字段。未知字段由调用方决定是否透传。 */
|
||||
export function resolveDatalinkField(
|
||||
fields: DatalinkField[],
|
||||
entityId: string,
|
||||
query: string
|
||||
): DatalinkField | undefined {
|
||||
const key = query.trim().toLowerCase();
|
||||
if (!key) return undefined;
|
||||
const prefix = `e_${entityId.replace(/^\$/, "").toLowerCase()}_`;
|
||||
const unique = (matches: DatalinkField[]): DatalinkField | undefined => {
|
||||
const byName = new Map(matches.map((field) => [field.name, field]));
|
||||
if (byName.size > 1) {
|
||||
throw new ValidationError(`字段存在歧义: ${query},请使用完整字段名`);
|
||||
}
|
||||
return byName.values().next().value;
|
||||
};
|
||||
const exact = unique(fields.filter((field) => field.name.toLowerCase() === key))
|
||||
?? unique(fields.filter((field) => field.name.toLowerCase() === prefix + key))
|
||||
?? unique(fields.filter((field) => field.label?.toLowerCase() === key));
|
||||
if (exact) return exact;
|
||||
// 未在元数据声明的系统键由调用方读取/透传,不能误匹配到 inactive 等业务标签。
|
||||
if (["id", "recordid", "active", "name", "code", "createtime", "updatetime", "entityid"].includes(key)) return undefined;
|
||||
return unique(fields.filter((field) => field.label?.toLowerCase().includes(key)));
|
||||
}
|
||||
Reference in new issue
Block a user