@stalfh233/omc-cli 0.6.81 → 0.6.82
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/coverage/m1-coverage-manifest-v1.json +5 -2
- package/dist/artifacts.js +28 -5
- package/dist/capability-overview.js +4 -4
- package/dist/cli.js +72 -36
- package/dist/endpoints.js +12 -0
- package/dist/env-export.js +4 -0
- package/dist/human-summary.js +8 -0
- package/dist/lanes/b2-registration-contract.js +11 -0
- package/dist/lanes/b2-registration-coverage.js +1 -0
- package/dist/lanes/businessrule-contract.js +5 -3
- package/dist/lanes/businessrule.js +82 -0
- package/dist/lanes/rule-graph.js +21 -5
- package/dist/lanes/servicelog.js +376 -0
- package/dist/lanes/workflow-contract.js +12 -2
- package/dist/lanes/workflow-coverage.js +1 -0
- package/dist/lanes/workflow.js +357 -27
- package/dist/model-purge.js +12 -3
- package/dist/read-shapes.js +12 -8
- package/dist/recipes/businessrule.js +1 -1
- package/dist/refusal-guidance.js +4 -3
- package/dist/rule-support.js +309 -28
- package/dist/session-account.js +66 -0
- package/dist/tool-search.js +5 -1
- package/dist/tools.js +2 -0
- package/package.json +3 -3
- package/skills/omc-capabilities.md +5 -5
package/dist/read-shapes.js
CHANGED
|
@@ -107,8 +107,8 @@ const READ_SHAPES = {
|
|
|
107
107
|
// 待办(待办在别人名下;同环境不带过滤回 8 条的实例,按实例过滤回 0,探针据此
|
|
108
108
|
// 误判过「没生成待办」)。看实例全活动链用 workflow.instanceActivity(查别人
|
|
109
109
|
// 名下待办用 participant 参数)。returnsFace 只显示 notes 首条——教学并进首条。
|
|
110
|
-
keys: ["items:array<{workItemId,workflowInstanceId,workflowCode,activityCode,activityName,state,sequenceNo,originator,originatorName,participant,participantName,bizObjectId,schemaCode}>", "total", "count"],
|
|
111
|
-
notes: ["本面=当前登录人待办:按实例过滤回 0 ≠ 没待办(在别人名下,用 participant
|
|
110
|
+
keys: ["items:array<{workItemId,workflowInstanceId,workflowCode,activityCode,activityName,state,sequenceNo,originator,originatorName,participant,participantName,bizObjectId,schemaCode}>", "total", "count", "stateFilter?:{requested,applied,via}"],
|
|
111
|
+
notes: ["本面=当前登录人待办:按实例过滤回 0 ≠ 没待办(在别人名下,用 participant 查别人);全活动链 workflow.instanceActivity", "state 过滤走 list_workitems(含 DRAFT;search_workitems 静默丢 state,看 stateFilter.applied)", "待办 id 键是 workItemId(平铺,不套 fields)"],
|
|
112
112
|
},
|
|
113
113
|
// r68 链2-D5(真机实证 2026-11-15):同一个「活动」概念两个面键名不同——
|
|
114
114
|
// workflow.get_published 的 activities[] 用 code/name/type,本面与 workitem 回执用
|
|
@@ -124,15 +124,15 @@ const READ_SHAPES = {
|
|
|
124
124
|
// 与 published 键不同。
|
|
125
125
|
"workflow.list": {
|
|
126
126
|
keys: ["applicationResolution", "modelsCount", "scannedModels", "withWorkflow", "publishedCount", "absentCount", "workflows:array<{modelCode,workflowCode,exists,published,ruleBindingCount,readFailed?}>", "wire", "partial?", "omittedModels?", "nextCommand?", "indexNote", "environmentFingerprint"],
|
|
127
|
-
notes: ["无流程的模型 workflowCode:null + exists:false(不是错误);平台无流程清单端点,本面按模型索引(流程-模型一对一惯例,workflowCode 常为 <模型code>_flow)", "ruleBindingCount = flow 级 handler
|
|
127
|
+
notes: ["无流程的模型 workflowCode:null + exists:false(不是错误);平台无流程清单端点,本面按模型索引(流程-模型一对一惯例,workflowCode 常为 <模型code>_flow)", "ruleBindingCount = flow 级 handler + 节点级事件 + SYSTEM_ACTIVITY 顶层绑定的规则码总数(比 get_published 摘要里的同名键多算节点级)"],
|
|
128
128
|
},
|
|
129
129
|
"workflow.get_published": {
|
|
130
|
-
keys: ["status", "workflowCode", "exists", "published", "workflowSummary:{workflowCode,templateType,activities:array<{index,code,type,name,bizActions?:{<nodeEvent>:[ruleCode]}}>,edges:array<{from,to}>,ruleBindings:array<{...}>,ruleBindingCount,originateActivity:{code,type,name,participant}}", "activities:array<{code,name,type,bizActions?}>(投影)", "propertyPermissionsCount", "version", "summaryHint", "truncatedKeys?", "omittedKeys?", "truncated?", "data?(外置时 null,完整模板在 detailArtifactId)", "omittedShape?", "omittedNote?", "environmentFingerprint", "detailArtifactId?", "detailSha256?", "fetch?"],
|
|
131
|
-
notes: ["
|
|
130
|
+
keys: ["status", "workflowCode", "exists", "published", "workflowSummary:{workflowCode,templateType,activities:array<{index,code,type,name,bizActions?:{<nodeEvent>:[ruleCode]},systemBizActions?:{bizActionType,ruleCodes:[code]}}>,edges:array<{from,to}>,ruleBindings:array<{...}>,nodeRuleBindings?,systemRuleBindings?,ruleBindingCount,originateActivity:{code,type,name,participant}}", "activities:array<{code,name,type,bizActions?,systemBizActions?}>(投影)", "propertyPermissionsCount", "version", "summaryHint", "truncatedKeys?", "omittedKeys?", "truncated?", "data?(外置时 null,完整模板在 detailArtifactId)", "omittedShape?", "omittedNote?", "environmentFingerprint", "detailArtifactId?", "detailSha256?", "fetch?"],
|
|
131
|
+
notes: ["规则绑定三个面:流程级 ruleBindings、节点事件 activities[].bizActions、SYSTEM_ACTIVITY 顶层 activities[].systemBizActions(规则绑在系统活动节点本身、激活时执行)——三个面看完再下「没绑」结论;完整模板在 data(外置 detailArtifactId),要深层字段时投影写到叶子(如 --jq 'data.activities[].bizActions')——写整棵父节点会因总量超限再次被外置"],
|
|
132
132
|
},
|
|
133
133
|
"workflow.get_draft": {
|
|
134
|
-
keys: ["status", "workflowCode", "exists", "workflowSummary:{workflowCode,templateType,activities:array<{index,code,type,name,bizActions?:{<nodeEvent>:[ruleCode]}}>,edges:array<{from,to}>,ruleBindings:array<{...}>,ruleBindingCount,originateActivity:{code,type,name,participant}}", "activities:array<{code,name,type,bizActions?}>(投影)", "propertyPermissionsCount", "version", "summaryHint", "truncatedKeys?", "omittedKeys?", "truncated?", "data?(外置时 null,完整模板在 detailArtifactId)", "omittedShape?", "omittedNote?", "environmentFingerprint", "detailArtifactId?", "detailSha256?", "fetch?"],
|
|
135
|
-
notes: ["与 workflow.get_published 同形(少了 published 键);节点绑定看 activities[].bizActions;templateType=DRAFT;深层字段投影写到叶子,完整模板在 data/detailArtifactId"],
|
|
134
|
+
keys: ["status", "workflowCode", "exists", "workflowSummary:{workflowCode,templateType,activities:array<{index,code,type,name,bizActions?:{<nodeEvent>:[ruleCode]},systemBizActions?:{bizActionType,ruleCodes:[code]}}>,edges:array<{from,to}>,ruleBindings:array<{...}>,nodeRuleBindings?,systemRuleBindings?,ruleBindingCount,originateActivity:{code,type,name,participant}}", "activities:array<{code,name,type,bizActions?,systemBizActions?}>(投影)", "propertyPermissionsCount", "version", "summaryHint", "truncatedKeys?", "omittedKeys?", "truncated?", "data?(外置时 null,完整模板在 detailArtifactId)", "omittedShape?", "omittedNote?", "environmentFingerprint", "detailArtifactId?", "detailSha256?", "fetch?"],
|
|
135
|
+
notes: ["与 workflow.get_published 同形(少了 published 键);节点绑定看 activities[].bizActions、系统活动顶层看 systemBizActions;templateType=DRAFT;深层字段投影写到叶子,完整模板在 data/detailArtifactId"],
|
|
136
136
|
},
|
|
137
137
|
"rule.list": {
|
|
138
138
|
keys: ["rules:array<{code,name,enabled,status,ruleVersion,defaultRule,preset,mappings?,mappingsUnavailable?}>", "rulesCount", "modelPresent", "source", "executableHint", "mappingsWireNote?", "schemaCodes?/modelsCount?/models?:array<每模型同单模型回执>/partial?/failed?:array<{schemaCode,code,message}>/absentModels?"],
|
|
@@ -161,7 +161,7 @@ const READ_SHAPES = {
|
|
|
161
161
|
// service.get,分插各自族附近);键集全部来自真机回执采样(非手写发明),
|
|
162
162
|
// returnsFace 只显 notes[0],高频陷阱并进首条。
|
|
163
163
|
"rule.get": {
|
|
164
|
-
keys: ["status", "id", "absent", "code", "name", "schemaCode", "bizRuleType", "enabled", "executable", "executableBasis", "ruleStatus", "defaultRule", "developmentMode", "ruleVersion", "templateType", "nodes:array<{nodeCode,nodeName,nodeType,nodeCategory?,inputParam?,methodMapping:{schemaCode,serviceCode,serviceMethodCode,inputMappings[],outputMappings[],serviceName,serviceMethodName},serviceType?}>", "routes:array<{preNode,postNode,routeCondition,matchType}>", "schedulerSetting?", "renderCompat", "semanticFindings?", "roundTrip", "nodeDigests?:array<{nodeCode,nodeType,methodMapping:{serviceCode,serviceMethodCode}}>(summary)", "methodMappingCount?(summary)", "bytesOmitted?(summary)", "rules?:array<摘要体>(ruleCodes 批量)", "rulesCount?/requestedCount?/partial?/failed?:array<{code,reason}>(批量;跨模型 failed 每条带 schemaCode)", "models?:array<{schemaCode,modelPresent,rulesCount,failedCount}>(跨模型)", "environmentFingerprint", "detailArtifactId?", "detailSha256?", "fetch?"],
|
|
164
|
+
keys: ["status", "id", "absent", "code", "name", "schemaCode", "bizRuleType", "enabled", "executable", "executableBasis", "ruleStatus", "defaultRule", "developmentMode", "ruleVersion", "templateType", "nodes:array<{nodeCode,nodeName,nodeType,nodeCategory?,inputParam?,methodMapping:{schemaCode,serviceCode,serviceMethodCode,inputMappings[],outputMappings[],serviceName,serviceMethodName},serviceType?}>", "routes:array<{preNode,postNode,routeCondition,matchType}>", "schedulerSetting?", "formulaNotes?(codeType:7 公式口径)", "renderCompat", "semanticFindings?", "roundTrip", "nodeDigests?:array<{nodeCode,nodeType,methodMapping:{serviceCode,serviceMethodCode}}>(summary)", "methodMappingCount?(summary)", "bytesOmitted?(summary)", "rules?:array<摘要体>(ruleCodes 批量)", "rulesCount?/requestedCount?/partial?/failed?:array<{code,reason}>(批量;跨模型 failed 每条带 schemaCode)", "models?:array<{schemaCode,modelPresent,rulesCount,failedCount}>(跨模型)", "environmentFingerprint", "detailArtifactId?", "detailSha256?", "fetch?"],
|
|
165
165
|
notes: [
|
|
166
166
|
"绑定方法:默认面看 nodes[].methodMapping.serviceCode/serviceMethodCode(三层深);扫多规则用 summary:true + ruleCodes[](同 schemaCode,1 次 list),扫多模型再配 schemaCodes[](≤20,逐模型 1 探针 + 1 list)——摘要键是 nodeDigests,不是 nodes(nodes 只在默认面)",
|
|
167
167
|
"入参 ruleCode 对应本面返回的 code;enabled 是开关推断,可执行性看 executable/executableBasis;批量面的 failed 是**数组**,所以信封仍是 status:ok + partial:true(不是 partial 状态);跨模型 failed[] 每条带 schemaCode(模型不存在 → modelPresent:false,不发规则面请求)",
|
|
@@ -302,6 +302,10 @@ const READ_SHAPES = {
|
|
|
302
302
|
keys: ["status", "index:{page,size,totalElements,totalPages}", "logs:array<{ruleCode,name,triggerType,status,triggerTime,finishTime,ruleVersion,traceId,triggerRows[]}>", "emptyLogHint?", "notes", "environmentFingerprint"],
|
|
303
303
|
notes: ["查日志拿 0 条先想:流程绑定模型的 REST 写入不派发数据事件规则(平台行为,r68 对照实验实证——验证用无流程模型对照);CODING 模式不记日志;行内 status:false=失败(布尔);includeNodes:true 拿节点链(BIZ_ACTION errMsg=根因),traceId 对全链路", "includeNodes:true 时 logs[].nodes=节点级执行链(type/name/status/errMsg——仅前 3 条,BIZ_ACTION 的 errMsg 直接给根因);traceId 对平台全链路日志"],
|
|
304
304
|
},
|
|
305
|
+
"servicelog.search": {
|
|
306
|
+
keys: ["status", "window:{startTime,endTime,minutes,source}", "filters", "paging:{page,size,totalElements,totalPages,returned,hasMore,nextPage?,nextCommand?}", "rowFilter?:{schemaCode?,bizObjectId?,matched,returned,scannedPages,scannedElements,exhausted,moreLikely?,truncatedMatches?}", "logs:array<{startTime,endTime?,usedTime,code,methodName,status,statusName?,dataTitle,schemaCode,bizObjectId,rule?,params,paramsBytes,paramsTruncated?,result,resultBytes,resultTruncated?,detail?}>", "emptyHint?", "notes", "wire:{path,calls,rowsFetched}", "payloadFile?,payloadSha256?,payloadBytes?,payloadHint?", "environmentFingerprint"],
|
|
307
|
+
notes: ["默认窗口=最近 60 分钟;无任何过滤条件直接拒绝(servicelog-filter-required)——日志表无过滤查询会全表扫描超时", "code/methodName/dataTitle/时间/status 是服务端过滤(code/methodName 为 LIKE 包含,逗号=精确 IN);schemaCode/bizObjectId 是客户端匹配(平台列表端点没有这两个参数),rowFilter.exhausted:false 表示扫描被页数上限截断,未命中不代表没有", "params 平台入库上限 2000 字符(更长的已截断);params/result 单行摘要超过 240 字符或完整量 >4096B 时,完整内容在 payloadFile(jq 定向取回)", "日志异步落库,刚触发的调用可能晚数秒可见;>10 行时 logs 会被读面外置到 detailFile(truncatedKeys/omittedKeys 标注),形状不变"],
|
|
308
|
+
},
|
|
305
309
|
};
|
|
306
310
|
/** Lookup the authored return shape for a tool, if any. */
|
|
307
311
|
export function readShapeFor(toolName) {
|
|
@@ -496,7 +496,7 @@ const ruleBizactionInvokeService = Object.freeze({
|
|
|
496
496
|
expectedReadback: { readback: { published: true, enabled: false, next: "rule.enable → data.submit 触发 → data.load 读回目标字段" } },
|
|
497
497
|
refusalRecovery: [
|
|
498
498
|
{ code: "rule-graph-bizmethod-unresolved", action: "serviceCode/serviceMethodCode 必须是已注册服务(service.list);方法级详情 service.get" },
|
|
499
|
-
{ code: "rule-
|
|
499
|
+
{ code: "rule-mapping-field-absent", action: "inputMappings 的 bizCode 必须是来源模型(本模型或 QUERY 上游)已发布字段 code(field.list 核对;错误里带 did-you-mean);确知不存在仍要保存传 allowAbsentMappingFields:true" },
|
|
500
500
|
{ code: "rule-graph-bizaction-expression-missing", action: "codeType:7(EXPRESSION) 入参的计算规则放 bizCode(JSON 字符串,如 '{\"formula\":\"{amount}*0.13\"}'),不是 expressionValue" },
|
|
501
501
|
...commonRecovery,
|
|
502
502
|
],
|
package/dist/refusal-guidance.js
CHANGED
|
@@ -80,13 +80,14 @@ const SHAPE_GATES = Object.freeze({
|
|
|
80
80
|
correctShape: "每条 route {preNode, postNode, routeCondition:true};Start→首节点→…→End 必须连通",
|
|
81
81
|
recipeCommand: { tool: "rule.save", recipe: "business-rule-branch-conditional" },
|
|
82
82
|
},
|
|
83
|
-
"rule-
|
|
84
|
-
whatWentWrong: "
|
|
85
|
-
correctShape: "inputMappings 每条:serviceMethodParameterCode(服务方法参数)↔ bizCode
|
|
83
|
+
"rule-mapping-field-absent": {
|
|
84
|
+
whatWentWrong: "codeType:1 映射的 bizCode 不在来源模型(本模型或 QUERY 上游模型)的已发布字段清单(错误带该模型字段摘要 + didYouMean)",
|
|
85
|
+
correctShape: "inputMappings 每条:serviceMethodParameterCode(服务方法参数)↔ bizCode(已发布字段 code),codeType:1;平台侧不保证拦截(运行时静默 null→10005)",
|
|
86
86
|
recipeCommand: { tool: "rule.save", recipe: "rule-cross-model-create" },
|
|
87
87
|
missingInputs: [
|
|
88
88
|
{ name: "serviceCode/serviceMethodCode", source: "omc call bizservice.list --args '{}'(已注册的二开服务)" },
|
|
89
89
|
{ name: "bizCode(模型字段)", source: "omc call field.list --args '{\"schemaCode\":\"<模型>\",\"all\":true}'" },
|
|
90
|
+
{ name: "确知字段不存在仍要保存", source: "rule.save 传 allowAbsentMappingFields:true(逃生阀,回执 absentMappingFieldsAllowed 点名放行项)" },
|
|
90
91
|
],
|
|
91
92
|
},
|
|
92
93
|
"rule-graph-bizmethod-unresolved": {
|
package/dist/rule-support.js
CHANGED
|
@@ -8,6 +8,7 @@ import { RULE_BIZ_RULE_TYPE_DESCRIPTION, RULE_CREATE_BODY, RULE_ROUTES_DESCRIPTI
|
|
|
8
8
|
import { validateRuleNodeGraph, prepareRuleGraph, PLATFORM_TRIGGER_RULE_CODES, DEFAULT_SYSTEM_NODE_BY_RULE_CODE } from "./lanes/rule-graph.js";
|
|
9
9
|
import { FORMULA_LINT_CODES } from "./formula-lint.js";
|
|
10
10
|
import { compileMethodConfigPlain } from "./bizservice-config.js";
|
|
11
|
+
import { closestMatches } from "./closest-match.js";
|
|
11
12
|
import { RESERVED_CODES } from "./code-rules.js";
|
|
12
13
|
import { SYSTEM_FIELD_CODES } from "./field-families.js";
|
|
13
14
|
import { FIELD_PROPERTY_TYPES } from "./field-families.js";
|
|
@@ -448,8 +449,24 @@ async function assertRuleGraphFieldOwnership(session, schemaCode, nodes, allowAd
|
|
|
448
449
|
return [{ code: "rule-graph-field-not-in-model", nodeCode: first.nodeCode, key: first.where, severity: "warning", message: `${message}(allowAdvisory:true,仅调查放行)` }];
|
|
449
450
|
throw new ToolRefusalError({ status: "refused", blocker: "rule-graph-field-not-in-model", nodeCode: first.nodeCode, side: first.side, model: first.model, field: first.code, where: first.where, missing, candidates, message });
|
|
450
451
|
}
|
|
451
|
-
|
|
452
|
+
/** BIZ_ACTION/GET_LIST(BIZ_SERVICE) 节点映射的来源模型解析(与条件叶归属同款:QUERY 上游优先)。 */
|
|
453
|
+
function mappingSourceModelResolver(schemaCode, nodes) {
|
|
454
|
+
const queryModels = new Map();
|
|
455
|
+
for (const entry of nodes) {
|
|
456
|
+
if (!entry || typeof entry !== "object")
|
|
457
|
+
continue;
|
|
458
|
+
const node = entry;
|
|
459
|
+
if (String(node.nodeType ?? "") === "QUERY" && typeof node.nodeCode === "string" && typeof node.targetSchemaCode === "string")
|
|
460
|
+
queryModels.set(node.nodeCode, node.targetSchemaCode.trim());
|
|
461
|
+
}
|
|
462
|
+
return (node) => {
|
|
463
|
+
const input = typeof node.inputParam === "string" ? /^_(.+)_output$/u.exec(node.inputParam) : undefined;
|
|
464
|
+
return input?.[1] && queryModels.get(input[1]) ? queryModels.get(input[1]) : schemaCode;
|
|
465
|
+
};
|
|
466
|
+
}
|
|
467
|
+
async function assertRuleMappingFieldsPublished(session, schemaCode, nodes, options = {}) {
|
|
452
468
|
const rows = [];
|
|
469
|
+
const modelOf = mappingSourceModelResolver(schemaCode, nodes);
|
|
453
470
|
for (const entry of nodes) {
|
|
454
471
|
if (!entry || typeof entry !== "object")
|
|
455
472
|
continue;
|
|
@@ -474,28 +491,61 @@ async function assertBizActionMappingFieldsExist(session, schemaCode, nodes) {
|
|
|
474
491
|
continue; // only PROPERTY mappings resolve to a schema field
|
|
475
492
|
const bizCode = typeof row.bizCode === "string" ? row.bizCode.trim() : "";
|
|
476
493
|
if (!bizCode)
|
|
477
|
-
continue; //
|
|
478
|
-
rows.push({ nodeCode: String(node.nodeCode ?? ""), listKey, serviceMethodParameterCode: typeof row.serviceMethodParameterCode === "string" ? row.serviceMethodParameterCode : "", bizCode });
|
|
494
|
+
continue; // r85 issue 04:显式空映射(bizCode:"")不指向字段,运行时参数不传
|
|
495
|
+
rows.push({ nodeCode: String(node.nodeCode ?? ""), listKey, serviceMethodParameterCode: typeof row.serviceMethodParameterCode === "string" ? row.serviceMethodParameterCode : "", bizCode, model: modelOf(node) });
|
|
479
496
|
}
|
|
480
497
|
}
|
|
481
498
|
}
|
|
482
499
|
if (rows.length === 0)
|
|
483
|
-
return;
|
|
484
|
-
const
|
|
485
|
-
const
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
status: "refused",
|
|
492
|
-
blocker: "rule-graph-bizaction-mapping-field-missing",
|
|
493
|
-
schemaCode,
|
|
494
|
-
missing,
|
|
495
|
-
message: "methodMapping 的 PROPERTY(codeType:1) 映射 bizCode 指向该模型上不存在(或未发布)的字段——平台 publish 会只回一个无明细的 550018「规则存在异常」。先 field.create 建字段并 field.publish 发布,或把映射改到已发布的真实字段 code",
|
|
496
|
-
recovery: [{ code: "create-and-publish-mapped-field", action: "field.create 建该字段 → field.publish 发布 → 重试 rule.save;或先 field.list(published:true) 核对字段 code" }],
|
|
497
|
-
});
|
|
500
|
+
return { checkedModels: 0 };
|
|
501
|
+
const fieldLists = new Map();
|
|
502
|
+
for (const model of [...new Set(rows.map((row) => row.model))]) {
|
|
503
|
+
const fields = wireRows((await wireCall(session, { path: ENDPOINTS.fieldList, query: { schemaCode: model, isPublish: "true" } })).data);
|
|
504
|
+
const codes = fields.map((field) => String(field.code ?? field.propertyCode ?? "").trim()).filter((code) => code.length > 0);
|
|
505
|
+
for (const code of RULE_RESERVED_MAPPING_CODES)
|
|
506
|
+
codes.push(code);
|
|
507
|
+
fieldLists.set(model, codes);
|
|
498
508
|
}
|
|
509
|
+
const missing = rows.filter((row) => {
|
|
510
|
+
const known = fieldLists.get(row.model);
|
|
511
|
+
if (known === undefined)
|
|
512
|
+
return false;
|
|
513
|
+
// 子表路径 `sheetCode.field`:父字段清单只含 sheet 列本身——前缀在册即视为
|
|
514
|
+
// 子列引用(子列清单不在本面,不猜)。整串命中同样放行(与 r21 门同口径)。
|
|
515
|
+
if (row.bizCode.includes(".")) {
|
|
516
|
+
const prefix = row.bizCode.slice(0, row.bizCode.indexOf("."));
|
|
517
|
+
return !known.includes(prefix) && !known.includes(row.bizCode);
|
|
518
|
+
}
|
|
519
|
+
return !known.includes(row.bizCode);
|
|
520
|
+
});
|
|
521
|
+
if (missing.length === 0)
|
|
522
|
+
return { checkedModels: fieldLists.size };
|
|
523
|
+
const detail = missing.map((row) => {
|
|
524
|
+
const known = fieldLists.get(row.model) ?? [];
|
|
525
|
+
return {
|
|
526
|
+
nodeCode: row.nodeCode,
|
|
527
|
+
listKey: row.listKey,
|
|
528
|
+
serviceMethodParameterCode: row.serviceMethodParameterCode,
|
|
529
|
+
bizCode: row.bizCode,
|
|
530
|
+
model: row.model,
|
|
531
|
+
modelFieldCount: known.length,
|
|
532
|
+
modelFieldSample: [...new Set(known)].sort().slice(0, 20),
|
|
533
|
+
didYouMean: closestMatches(row.bizCode, known, 3).map((match) => match.name),
|
|
534
|
+
};
|
|
535
|
+
});
|
|
536
|
+
if (options.allowAbsent === true)
|
|
537
|
+
return { checkedModels: fieldLists.size, absent: detail.map(({ nodeCode, serviceMethodParameterCode, bizCode, model }) => ({ nodeCode, serviceMethodParameterCode, bizCode, model })) };
|
|
538
|
+
throw new ToolRefusalError({
|
|
539
|
+
status: "refused",
|
|
540
|
+
blocker: "rule-mapping-field-absent",
|
|
541
|
+
schemaCode,
|
|
542
|
+
missing: detail,
|
|
543
|
+
message: "methodMapping 的 PROPERTY(codeType:1) 映射 bizCode 不在来源模型(本模型或 QUERY 上游模型)的已发布字段清单——平台侧不保证拦截(2026-11-19 联调实证:保存/发布通过、运行时参数静默 null → 10005)。先 field.create+field.publish 建字段,或改映射到 didYouMean 给出的已发布字段;确知不存在仍要保存:显式 allowAbsentMappingFields:true",
|
|
544
|
+
recovery: [
|
|
545
|
+
{ code: "create-and-publish-mapped-field", action: "field.create 建该字段 → field.publish 发布 → 重试 rule.save;或先 field.list(published:true) 核对字段 code" },
|
|
546
|
+
{ code: "allow-absent-mapping-fields", action: "确知字段不存在仍要保存:rule.save 传 allowAbsentMappingFields:true(回执 absentMappingFieldsAllowed 点名放行项)" },
|
|
547
|
+
],
|
|
548
|
+
});
|
|
499
549
|
}
|
|
500
550
|
/**
|
|
501
551
|
* Ticket 96 live incident fix — fail-closed schema-existence gate for every
|
|
@@ -867,7 +917,7 @@ export async function lintRuleGraphForWrite(session, args, options = {}) {
|
|
|
867
917
|
throw new ToolRefusalError({
|
|
868
918
|
status: "refused",
|
|
869
919
|
blocker: "rule-graph-routes-empty",
|
|
870
|
-
message: `图有 ${nodes.length} 个节点但 0 条 routes——平台发布会判「孤立节点」(550014)。边用 routes:[{preNode:"Start",postNode:"UPDATE_1"},...](不是 edges/from/to
|
|
920
|
+
message: `图有 ${nodes.length} 个节点但 0 条 routes——平台发布会判「孤立节点」(550014)。边用 routes:[{preNode:"Start",postNode:"UPDATE_1"},...](不是 edges/from/to,那会被静默剥掉);更新既有规则可整个省略 routes,工具会读现行连线沿用(回执 routesSource:"existing")`,
|
|
871
921
|
});
|
|
872
922
|
return { preparedGraph, blockers, lintWarnings, lintHazards, nodes, routes };
|
|
873
923
|
}
|
|
@@ -970,20 +1020,228 @@ function normalizeRuleJsonColumn(value, fallback) {
|
|
|
970
1020
|
return JSON.stringify(value);
|
|
971
1021
|
return fallback;
|
|
972
1022
|
}
|
|
1023
|
+
/** r85(retro 2026-11-19 issue 11):`<field-xxx>` 是设计器富文本标记;运行时只读 formula。 */
|
|
1024
|
+
export const DESIGNER_FIELD_TAG = "<field-";
|
|
1025
|
+
/** 图里是否存在 codeType:7 表达式映射(决定是否需要读现存映射做设计器文本保读)。 */
|
|
1026
|
+
function nodeGraphHasExpressionMappings(graph) {
|
|
1027
|
+
const nodes = graph.nodes;
|
|
1028
|
+
if (typeof nodes === "string") {
|
|
1029
|
+
try {
|
|
1030
|
+
return nodeGraphHasExpressionMappings({ nodes: JSON.parse(nodes) });
|
|
1031
|
+
}
|
|
1032
|
+
catch {
|
|
1033
|
+
return false;
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
if (!Array.isArray(nodes))
|
|
1037
|
+
return false;
|
|
1038
|
+
for (const entry of nodes) {
|
|
1039
|
+
if (!entry || typeof entry !== "object")
|
|
1040
|
+
continue;
|
|
1041
|
+
const mapping = entry.methodMapping;
|
|
1042
|
+
if (!mapping || typeof mapping !== "object" || Array.isArray(mapping))
|
|
1043
|
+
continue;
|
|
1044
|
+
const m = mapping;
|
|
1045
|
+
for (const listKey of ["inputMappings", "outputMappings"])
|
|
1046
|
+
if (Array.isArray(m[listKey]) && m[listKey].some((element) => element && typeof element === "object" && Number(element.codeType) === 7))
|
|
1047
|
+
return true;
|
|
1048
|
+
}
|
|
1049
|
+
return false;
|
|
1050
|
+
}
|
|
1051
|
+
/** 解析 codeType:7 的 bizCode JSON;非对象/坏串返回 null。 */
|
|
1052
|
+
function parseExpressionBizCode(bizCode) {
|
|
1053
|
+
if (typeof bizCode !== "string" || !bizCode.trim())
|
|
1054
|
+
return null;
|
|
1055
|
+
try {
|
|
1056
|
+
const parsed = JSON.parse(bizCode);
|
|
1057
|
+
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
|
|
1058
|
+
}
|
|
1059
|
+
catch {
|
|
1060
|
+
return null;
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
/** 现存映射值带设计器痕迹:editorText 含 `<field-` 或 editorMark 非空。 */
|
|
1064
|
+
function hasDesignerText(expression) {
|
|
1065
|
+
const editorText = typeof expression.editorText === "string" ? expression.editorText : "";
|
|
1066
|
+
const editorMark = typeof expression.editorMark === "string" ? expression.editorMark : "";
|
|
1067
|
+
return editorText.includes(DESIGNER_FIELD_TAG) || editorMark !== "";
|
|
1068
|
+
}
|
|
1069
|
+
/**
|
|
1070
|
+
* r85(retro 2026-11-19 issue 11):codeType:7 的保守 partial 合并。
|
|
1071
|
+
*
|
|
1072
|
+
* 设计器把公式存成两份文本:`formula`(`{code}` 形,运行时唯一求值源)与
|
|
1073
|
+
* `editorText`(`<field-xxx>code</field-xxx>` 富文本 + editorMark=标记名;xxx 是
|
|
1074
|
+
* 设计器端 Math.random 生成的 8 位 nonce——admin/js/12404.1675d362.js
|
|
1075
|
+
* setEditorMark:"field-"+random(8),**不是字段/控件 id,不可从字段读回面推导**)。
|
|
1076
|
+
* CLI 生成的 editorText 设计器标红,覆盖会丢用户在设计器里改好的渲染。
|
|
1077
|
+
*
|
|
1078
|
+
* 语义:目标映射的**现存值**带设计器痕迹、调用方**未显式传 editorText** 时,默认
|
|
1079
|
+
* 保留现存 editorText/editorMark 只更新 formula(preservedDesignerText 点名);
|
|
1080
|
+
* 调用方显式传了 editorText、或逃生阀 allowDesignerTextOverwrite:true,才覆盖
|
|
1081
|
+
* (designerTextOverwritten 警示)。无设计器痕迹时零注记(不加噪音)。
|
|
1082
|
+
*/
|
|
1083
|
+
async function preserveDesignerFormulaText(nodes, loadCurrentRow, allowOverwrite) {
|
|
1084
|
+
const preserved = [];
|
|
1085
|
+
const overwritten = [];
|
|
1086
|
+
if (!nodes.some((node) => {
|
|
1087
|
+
const type = String(node.nodeType ?? "");
|
|
1088
|
+
return type === "BIZ_ACTION" || (type === "GET_LIST" && String(node.dataSourceType ?? "") === "BIZ_SERVICE");
|
|
1089
|
+
}))
|
|
1090
|
+
return { preserved, overwritten };
|
|
1091
|
+
const row = await loadCurrentRow();
|
|
1092
|
+
if (!row || typeof row.node !== "string")
|
|
1093
|
+
return { preserved, overwritten };
|
|
1094
|
+
const existingNodes = parseJsonColumn(row.node);
|
|
1095
|
+
if (!Array.isArray(existingNodes))
|
|
1096
|
+
return { preserved, overwritten };
|
|
1097
|
+
const designerByText = new Map();
|
|
1098
|
+
for (const entry of existingNodes) {
|
|
1099
|
+
if (!entry || typeof entry !== "object")
|
|
1100
|
+
continue;
|
|
1101
|
+
const node = entry;
|
|
1102
|
+
const mapping = node.methodMapping;
|
|
1103
|
+
if (!mapping || typeof mapping !== "object" || Array.isArray(mapping))
|
|
1104
|
+
continue;
|
|
1105
|
+
const m = mapping;
|
|
1106
|
+
for (const listKey of ["inputMappings", "outputMappings"]) {
|
|
1107
|
+
if (!Array.isArray(m[listKey]))
|
|
1108
|
+
continue;
|
|
1109
|
+
for (const element of m[listKey]) {
|
|
1110
|
+
if (!element || typeof element !== "object")
|
|
1111
|
+
continue;
|
|
1112
|
+
const elementRow = element;
|
|
1113
|
+
if (Number(elementRow.codeType) !== 7)
|
|
1114
|
+
continue;
|
|
1115
|
+
const expression = parseExpressionBizCode(elementRow.bizCode);
|
|
1116
|
+
if (!expression || !hasDesignerText(expression))
|
|
1117
|
+
continue;
|
|
1118
|
+
designerByText.set(`${String(node.nodeCode ?? "")}#${listKey}#${String(elementRow.serviceMethodParameterCode ?? "")}`, {
|
|
1119
|
+
editorText: typeof expression.editorText === "string" ? expression.editorText : "",
|
|
1120
|
+
editorMark: typeof expression.editorMark === "string" ? expression.editorMark : "",
|
|
1121
|
+
});
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
if (designerByText.size === 0)
|
|
1126
|
+
return { preserved, overwritten };
|
|
1127
|
+
for (const node of nodes) {
|
|
1128
|
+
const type = String(node.nodeType ?? "");
|
|
1129
|
+
if (type !== "BIZ_ACTION" && !(type === "GET_LIST" && String(node.dataSourceType ?? "") === "BIZ_SERVICE"))
|
|
1130
|
+
continue;
|
|
1131
|
+
const mapping = node.methodMapping;
|
|
1132
|
+
if (!mapping || typeof mapping !== "object" || Array.isArray(mapping))
|
|
1133
|
+
continue;
|
|
1134
|
+
const m = mapping;
|
|
1135
|
+
for (const listKey of ["inputMappings", "outputMappings"]) {
|
|
1136
|
+
if (!Array.isArray(m[listKey]))
|
|
1137
|
+
continue;
|
|
1138
|
+
for (const element of m[listKey]) {
|
|
1139
|
+
if (!element || typeof element !== "object")
|
|
1140
|
+
continue;
|
|
1141
|
+
const elementRow = element;
|
|
1142
|
+
if (Number(elementRow.codeType) !== 7)
|
|
1143
|
+
continue;
|
|
1144
|
+
const expression = parseExpressionBizCode(elementRow.bizCode);
|
|
1145
|
+
if (!expression)
|
|
1146
|
+
continue;
|
|
1147
|
+
const key = `${String(node.nodeCode ?? "")}#${listKey}#${String(elementRow.serviceMethodParameterCode ?? "")}`;
|
|
1148
|
+
const existing = designerByText.get(key);
|
|
1149
|
+
if (!existing)
|
|
1150
|
+
continue;
|
|
1151
|
+
const where = `${String(node.nodeCode ?? "")}/${String(elementRow.serviceMethodParameterCode ?? "")}`;
|
|
1152
|
+
const callerHasText = typeof expression.editorText === "string" && expression.editorText.trim() !== "";
|
|
1153
|
+
if (callerHasText || allowOverwrite) {
|
|
1154
|
+
overwritten.push(where);
|
|
1155
|
+
continue;
|
|
1156
|
+
}
|
|
1157
|
+
expression.editorText = existing.editorText;
|
|
1158
|
+
expression.editorMark = existing.editorMark;
|
|
1159
|
+
elementRow.bizCode = JSON.stringify(expression);
|
|
1160
|
+
preserved.push(where);
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
return { preserved, overwritten };
|
|
1165
|
+
}
|
|
1166
|
+
/** r85(retro 2026-11-19 issue 04):显式空映射(bizCode:"",PROPERTY/CONST 归一后同形)点名。 */
|
|
1167
|
+
function collectEmptyMappings(nodes) {
|
|
1168
|
+
const empty = [];
|
|
1169
|
+
for (const node of nodes) {
|
|
1170
|
+
const mapping = node.methodMapping;
|
|
1171
|
+
if (!mapping || typeof mapping !== "object" || Array.isArray(mapping))
|
|
1172
|
+
continue;
|
|
1173
|
+
const m = mapping;
|
|
1174
|
+
for (const listKey of ["inputMappings", "outputMappings"]) {
|
|
1175
|
+
if (!Array.isArray(m[listKey]))
|
|
1176
|
+
continue;
|
|
1177
|
+
for (const element of m[listKey]) {
|
|
1178
|
+
if (!element || typeof element !== "object")
|
|
1179
|
+
continue;
|
|
1180
|
+
const row = element;
|
|
1181
|
+
if (row.bizCode !== "")
|
|
1182
|
+
continue;
|
|
1183
|
+
if (Number(row.codeType) !== 1 && Number(row.codeType) !== 0)
|
|
1184
|
+
continue;
|
|
1185
|
+
empty.push(`${String(node.nodeCode ?? "")}/${String(row.serviceMethodParameterCode ?? "")}`);
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
return empty;
|
|
1190
|
+
}
|
|
973
1191
|
export async function lintRuleSaveWrite(session, args) {
|
|
1192
|
+
// r85(issue 03/08):幻影 schema 门提前到一切规则面 wire 之前(原在图 lint 后,
|
|
1193
|
+
// 而 computeCarriedNodeCodes 已会 list——提前只收紧不放松;后续 routes 沿用
|
|
1194
|
+
// 读取/设计器保读都以 schema 已证存在为前提)。
|
|
1195
|
+
await assertRuleSchemaExists(session, args.schemaCode);
|
|
1196
|
+
// r85(issue 03):省略 routes 的沿用读取需要现存行;issue 11 的设计器文本
|
|
1197
|
+
// 保读需要现存映射。list 一趟同时服务 existing 定位与原有 upsert 语义。
|
|
1198
|
+
const list = await wireCall(session, { path: ENDPOINTS.businessRuleListBySchemaCode, query: { schemaCode: args.schemaCode } });
|
|
1199
|
+
const existing = wireRows(list.data).find((row) => row.code === args.ruleCode);
|
|
1200
|
+
let cachedCurrentRow = undefined;
|
|
1201
|
+
const loadCurrentRow = async () => {
|
|
1202
|
+
if (cachedCurrentRow !== undefined)
|
|
1203
|
+
return cachedCurrentRow;
|
|
1204
|
+
if (!existing?.id) {
|
|
1205
|
+
cachedCurrentRow = null;
|
|
1206
|
+
return null;
|
|
1207
|
+
}
|
|
1208
|
+
try {
|
|
1209
|
+
cachedCurrentRow = (await wireCall(session, { path: ENDPOINTS.businessRuleGet, query: { id: String(existing.id) } })).data;
|
|
1210
|
+
}
|
|
1211
|
+
catch {
|
|
1212
|
+
cachedCurrentRow = null;
|
|
1213
|
+
}
|
|
1214
|
+
return cachedCurrentRow;
|
|
1215
|
+
};
|
|
1216
|
+
// r85(issue 03):nodeGraph.routes 省略 + 规则已存在 → 读现行连线沿用
|
|
1217
|
+
// (businessrule/get +1 wire,回执 routesSource:"existing")。读不到 route 列
|
|
1218
|
+
// 不猜连线:落回 routes-empty/缺边 lint(新建路径本就必须显式给 routes)。
|
|
1219
|
+
let routesSource;
|
|
1220
|
+
let graph = args.nodeGraph;
|
|
1221
|
+
const routesOmitted = graph.routes === undefined;
|
|
1222
|
+
if (existing?.id && (routesOmitted || nodeGraphHasExpressionMappings(graph))) {
|
|
1223
|
+
const currentRow = await loadCurrentRow();
|
|
1224
|
+
if (routesOmitted && currentRow && typeof currentRow.route === "string") {
|
|
1225
|
+
const routes = parseJsonColumn(currentRow.route);
|
|
1226
|
+
if (Array.isArray(routes)) {
|
|
1227
|
+
graph = { ...graph, routes: routes };
|
|
1228
|
+
routesSource = "existing";
|
|
1229
|
+
}
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
974
1232
|
// Pre-flight dry lint (ticket 14) lives in lintRuleGraphForWrite (r73 #1):
|
|
975
1233
|
// the SAME lint now serves the real write AND `rule.node.update`'s
|
|
976
1234
|
// dryRunPayload, so a dry-run answers the same 能写/不能写 question.
|
|
977
|
-
const { preparedGraph, blockers, lintWarnings, lintHazards, nodes, routes } = await lintRuleGraphForWrite(session, args);
|
|
1235
|
+
const { preparedGraph, blockers, lintWarnings, lintHazards, nodes, routes } = await lintRuleGraphForWrite(session, { ...args, nodeGraph: graph });
|
|
978
1236
|
await assertCreateSelectionCompatibility(session, args.schemaCode, Array.isArray(nodes) ? nodes : []);
|
|
979
|
-
|
|
1237
|
+
// r85(issue 08):codeType:1 映射字段预检(QUERY 上游模型解析 + did-you-mean
|
|
1238
|
+
// + allowAbsentMappingFields 逃生阀)。r21 的同模型门已并入本门。
|
|
1239
|
+
const mappingPreflight = await assertRuleMappingFieldsPublished(session, args.schemaCode, Array.isArray(nodes) ? nodes : [], { allowAbsent: args.allowAbsentMappingFields === true });
|
|
980
1240
|
// r47a: ordinary UPDATE/CREATE/EXPRESSION references use two distinct
|
|
981
1241
|
// ownership sides. Read each involved published field set once (at most the
|
|
982
1242
|
// rule model plus two target/query models) and refuse before rule.save.
|
|
983
1243
|
blockers.push(...(await assertRuleGraphFieldOwnership(session, args.schemaCode, Array.isArray(nodes) ? nodes : [], args.allowAdvisory === true)));
|
|
984
|
-
// Ticket 96: phantom-schema gate —
|
|
985
|
-
// (the rule list itself auto-creates preset rows for unknown schemas).
|
|
986
|
-
await assertRuleSchemaExists(session, args.schemaCode);
|
|
1244
|
+
// Ticket 96: phantom-schema gate — r85 起已提前到函数首(一切规则面 wire 之前)。
|
|
987
1245
|
// ASSIGN shape is version-dependent (see isModernAssignVersion).
|
|
988
1246
|
const assignCodes = assignNodes(nodes);
|
|
989
1247
|
if (assignCodes.length > 0) {
|
|
@@ -1072,8 +1330,7 @@ export async function lintRuleSaveWrite(session, args) {
|
|
|
1072
1330
|
: typeof schedulerInput === "string"
|
|
1073
1331
|
? schedulerInput
|
|
1074
1332
|
: JSON.stringify(schedulerInput);
|
|
1075
|
-
|
|
1076
|
-
const existing = wireRows(list.data).find((row) => row.code === args.ruleCode);
|
|
1333
|
+
// r85:existing 定位已提前到函数首(与 routes 沿用读取共用一趟 list)。
|
|
1077
1334
|
// Persistence nodes belong to the PLATFORM, not to us and not to the caller.
|
|
1078
1335
|
// The preset row already carries its own (Start → Create(SYSTEM_CREATE) →
|
|
1079
1336
|
// End). Copy that node verbatim instead of fabricating our own: nodeCode,
|
|
@@ -1084,7 +1341,7 @@ export async function lintRuleSaveWrite(session, args) {
|
|
|
1084
1341
|
const systemSpec = DEFAULT_SYSTEM_NODE_BY_RULE_CODE[args.ruleCode];
|
|
1085
1342
|
if (existing?.id && systemSpec) {
|
|
1086
1343
|
try {
|
|
1087
|
-
const baselineRow =
|
|
1344
|
+
const baselineRow = await loadCurrentRow();
|
|
1088
1345
|
const baselineNodes = parseJsonColumn(baselineRow?.node);
|
|
1089
1346
|
const platformNode = Array.isArray(baselineNodes)
|
|
1090
1347
|
? baselineNodes.find((node) => String(node.nodeType ?? "") === systemSpec.nodeType)
|
|
@@ -1104,6 +1361,11 @@ export async function lintRuleSaveWrite(session, args) {
|
|
|
1104
1361
|
// synthesized the platform CUSTOM_NODE (rule.run then 550001s). Echo the
|
|
1105
1362
|
// observed trigger shape instead of the request.
|
|
1106
1363
|
const customTriggerApplied = nodes.some((node) => String(node.nodeType ?? "") === "CUSTOM_NODE");
|
|
1364
|
+
// r85(issue 11):设计器公式文本保守合并(保留现存 editorText/editorMark,
|
|
1365
|
+
// 只更新 formula;在 nodeJson 序列化前就地改写映射元素)。
|
|
1366
|
+
const designerText = await preserveDesignerFormulaText(nodes, loadCurrentRow, args.allowDesignerTextOverwrite === true);
|
|
1367
|
+
// r85(issue 04):显式空映射点名(归一后 bizCode:"" 的 PROPERTY/CONST 映射)。
|
|
1368
|
+
const emptyMappings = collectEmptyMappings(nodes);
|
|
1107
1369
|
const nodeJson = typeof nodes === "string" ? nodes : JSON.stringify(nodes);
|
|
1108
1370
|
const routeJson = typeof routes === "string" ? routes : JSON.stringify(routes);
|
|
1109
1371
|
const schedulerField = schedulerSetting === undefined ? {} : { schedulerSetting };
|
|
@@ -1137,11 +1399,28 @@ export async function lintRuleSaveWrite(session, args) {
|
|
|
1137
1399
|
nodeJson,
|
|
1138
1400
|
routeJson,
|
|
1139
1401
|
schedulerField,
|
|
1402
|
+
// r85(retro 2026-11-19)
|
|
1403
|
+
...(routesSource !== undefined ? { routesSource } : {}),
|
|
1404
|
+
emptyMappings,
|
|
1405
|
+
preservedDesignerText: designerText.preserved,
|
|
1406
|
+
designerTextOverwritten: designerText.overwritten,
|
|
1407
|
+
mappingFieldChecks: mappingPreflight.checkedModels,
|
|
1408
|
+
...(mappingPreflight.absent !== undefined ? { absentMappingFields: mappingPreflight.absent } : {}),
|
|
1140
1409
|
};
|
|
1141
1410
|
}
|
|
1142
1411
|
export async function executeRuleSaveWrite(session, args) {
|
|
1143
1412
|
// 与 dry-run 同源:同一套只读门先跑,然后才写。
|
|
1144
|
-
const { lintWarnings, lintHazards, bizMethodChecks, existing, customTriggerApplied, isPresetRule, bizRuleType, nodeJson, routeJson, schedulerField, schedulerSetting, nodes, } = await lintRuleSaveWrite(session, args);
|
|
1413
|
+
const { lintWarnings, lintHazards, bizMethodChecks, existing, customTriggerApplied, isPresetRule, bizRuleType, nodeJson, routeJson, schedulerField, schedulerSetting, nodes, routesSource, emptyMappings, preservedDesignerText, designerTextOverwritten, mappingFieldChecks, absentMappingFields, } = await lintRuleSaveWrite(session, args);
|
|
1414
|
+
// r85(retro 2026-11-19):dry-run 与真写共用的回执增量(routes 沿用 / 空映射 /
|
|
1415
|
+
// 设计器文本保读 / 映射字段预检)。
|
|
1416
|
+
const r85Readback = {
|
|
1417
|
+
...(routesSource !== undefined ? { routesSource, routesNote: "本次未传 routes:已读现行连线沿用(businessrule/get +1 wire)" } : {}),
|
|
1418
|
+
...(emptyMappings.length > 0 ? { emptyMappings, emptyMappingNote: "显式空映射(bizCode:\"\"):平台运行时跳过该参数、不传值(MapOps.java:490-496),服务侧按 null/缺省收到" } : {}),
|
|
1419
|
+
...(preservedDesignerText.length > 0 ? { preservedDesignerText, designerTextNote: "这些映射现存设计器公式文本(editorText/editorMark)已保留,只更新了 formula——不传 editorText 时工具不覆盖设计器渲染;要覆盖显式传 editorText 或 allowDesignerTextOverwrite:true" } : {}),
|
|
1420
|
+
...(designerTextOverwritten.length > 0 ? { designerTextOverwritten, designerTextOverwriteNote: "这些映射的设计器公式文本被本次写入覆盖(调用方显式传了 editorText 或 allowDesignerTextOverwrite:true);设计器打开若标红,用 rule.get formulaNotes 核对两份文本" } : {}),
|
|
1421
|
+
...(mappingFieldChecks > 0 ? { mappingFieldChecks } : {}),
|
|
1422
|
+
...(absentMappingFields !== undefined ? { absentMappingFieldsAllowed: absentMappingFields } : {}),
|
|
1423
|
+
};
|
|
1145
1424
|
const performed = existing?.id
|
|
1146
1425
|
? await wireCall(session, { path: ENDPOINTS.businessRuleUpdate, method: "POST", body: {
|
|
1147
1426
|
...existing,
|
|
@@ -1243,6 +1522,7 @@ export async function executeRuleSaveWrite(session, args) {
|
|
|
1243
1522
|
effectiveNow,
|
|
1244
1523
|
effectiveBasis,
|
|
1245
1524
|
latestPublished: effective?.latestPublished,
|
|
1525
|
+
...r85Readback,
|
|
1246
1526
|
...(await modelWorkflowDispatchWarning(session, args.schemaCode)),
|
|
1247
1527
|
...(existing?.id ? { versionNote } : {}),
|
|
1248
1528
|
...(enabled ? {} : { nextAction: "rule.enable(businessrule/publish + businessrule/enable 两步)后规则才会分发并对流程/按钮可见;publish:true 只写入版本" }),
|
|
@@ -1271,6 +1551,7 @@ export async function executeRuleSaveWrite(session, args) {
|
|
|
1271
1551
|
previousRuleVersion,
|
|
1272
1552
|
effectiveNow: false,
|
|
1273
1553
|
effectiveBasis: "本次只写 DRAFT,未发布;rule.enable(或 publish:true 后再 enable)才会让本次图成为当前运行图",
|
|
1554
|
+
...r85Readback,
|
|
1274
1555
|
...(await modelWorkflowDispatchWarning(session, args.schemaCode)),
|
|
1275
1556
|
latestPublished: effective?.latestPublished,
|
|
1276
1557
|
...(existing?.id ? { versionNote } : {}),
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { TokenCache, loginFingerprint } from "./token-cache.js";
|
|
2
|
+
/** JWT payload(claims)——只解不验签:目的是「回执自述」,不是鉴权。 */
|
|
3
|
+
export function decodeJwtPayload(token) {
|
|
4
|
+
const parts = token.split(".");
|
|
5
|
+
if (parts.length < 2)
|
|
6
|
+
return undefined;
|
|
7
|
+
try {
|
|
8
|
+
const decoded = Buffer.from(parts[1], "base64url").toString("utf8");
|
|
9
|
+
const parsed = JSON.parse(decoded);
|
|
10
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed))
|
|
11
|
+
return undefined;
|
|
12
|
+
return parsed;
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Decode the session account out of a bearer token. The display name comes from
|
|
20
|
+
* the login face (info_login, cached beside the token) because the JWT itself
|
|
21
|
+
* carries no displayName. Never throws: an undecodable token answers
|
|
22
|
+
* `{unavailableReason}` instead of inventing an identity.
|
|
23
|
+
*/
|
|
24
|
+
export function decodeSessionAccount(token, displayName) {
|
|
25
|
+
const claims = decodeJwtPayload(token);
|
|
26
|
+
if (claims === undefined)
|
|
27
|
+
return { unavailableReason: "token-not-jwt" };
|
|
28
|
+
const id = typeof claims.user_id === "string" ? claims.user_id : undefined;
|
|
29
|
+
if (id === undefined || id.length === 0)
|
|
30
|
+
return { unavailableReason: "token-payload-has-no-user-id" };
|
|
31
|
+
const username = typeof claims.user_name === "string" && claims.user_name.length > 0 ? claims.user_name : undefined;
|
|
32
|
+
return {
|
|
33
|
+
id,
|
|
34
|
+
...(username !== undefined ? { username } : {}),
|
|
35
|
+
...(displayName !== undefined && displayName.length > 0 ? { name: displayName } : {}),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* The session account a `call` on `environment` would use, read from the local
|
|
40
|
+
* token cache (written by the in-process login of THIS call when it went to the
|
|
41
|
+
* wire; otherwise the credential's last cached token). Zero network. Every
|
|
42
|
+
* failure mode maps to a short `unavailableReason` — the receipt must never
|
|
43
|
+
* lie about who is calling, and must never fail the call itself.
|
|
44
|
+
*/
|
|
45
|
+
export function sessionAccountForEnvironment(store, environment) {
|
|
46
|
+
try {
|
|
47
|
+
const resolved = store.resolveEnvironment(environment);
|
|
48
|
+
try {
|
|
49
|
+
const credential = store.readCredential(resolved.name);
|
|
50
|
+
const cache = new TokenCache(store.configPaths.configPath);
|
|
51
|
+
const cached = cache.load(resolved.name, loginFingerprint(resolved.profile, credential));
|
|
52
|
+
if (cached === undefined)
|
|
53
|
+
return { unavailableReason: "no-cached-token" };
|
|
54
|
+
return decodeSessionAccount(cached.token, cached.accountIdentity);
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
// credentials unreadable / store absent: not a session yet
|
|
58
|
+
return { unavailableReason: "credential-unavailable" };
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
// unknown env / cross-environment policy refusal / no default bound
|
|
63
|
+
return { unavailableReason: "environment-unresolved" };
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=session-account.js.map
|
package/dist/tool-search.js
CHANGED
|
@@ -5,7 +5,7 @@ const ACTION_VERBS = Object.freeze({
|
|
|
5
5
|
references: "read", inspect: "read", export: "read", check: "read", validate: "read",
|
|
6
6
|
update: "update", publish: "update", enable: "update", disable: "update",
|
|
7
7
|
move: "update", draft: "update", compose: "update", run: "update", link: "update",
|
|
8
|
-
assign: "update", test: "update", bindRule: "update", setButtons: "update",
|
|
8
|
+
assign: "update", test: "update", bindRule: "update", unbindRule: "update", setButtons: "update",
|
|
9
9
|
addPermission: "update", setUserScope: "update", transferDepartment: "update",
|
|
10
10
|
setSummary: "update", runButton: "update", commit: "update", start: "update", addUsers: "update",
|
|
11
11
|
delete: "delete", deleteMany: "delete", disableMany: "delete",
|
|
@@ -147,6 +147,7 @@ const OBJECT_LEXICON = Object.freeze({
|
|
|
147
147
|
datarule: ["字段级规则", "数据规则", "校验规则", "控件规则", "字段校验", "字段级校验"],
|
|
148
148
|
rule: ["业务规则", "规则"],
|
|
149
149
|
rulelog: ["规则执行日志", "规则日志", "执行日志", "触发日志"],
|
|
150
|
+
servicelog: ["业务服务日志", "服务调用日志", "接口调用日志", "调用记录", "集成日志"],
|
|
150
151
|
workflow: ["审批流程", "审批流", "工作流", "流程模板", "流程"],
|
|
151
152
|
workitem: ["待办", "工单"],
|
|
152
153
|
role: ["角色"],
|
|
@@ -225,6 +226,9 @@ const TOOL_PARENTS = Object.freeze({
|
|
|
225
226
|
// 点模型时给 workflow.list 父对象信号(与 listview/form 同族)。
|
|
226
227
|
"workflow.list": ["model"],
|
|
227
228
|
"method.create": ["service"], "method.update": ["service"], "method.get": ["service"], "method.delete": ["service"], "method.test": ["service"], "method.list": ["service"],
|
|
229
|
+
// 业务服务调用日志:对象段是 servicelog,句子里同时点「服务」或「模型/单据」
|
|
230
|
+
// (schemaCode/bizObjectId 是核心过滤面)都该给父对象信号。
|
|
231
|
+
"servicelog.search": ["service", "model"],
|
|
228
232
|
// r83(R79 二期):data.aggregate 是「模型数据的聚合」——句子里点模型时
|
|
229
233
|
// 与 data.list/data.load 同族给出父对象信号(此前只有 data 段命中)。
|
|
230
234
|
"data.aggregate": ["model"],
|