@stalfh233/omc-fake-platform 0.4.69 → 0.4.71
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/dist/rule-lifecycle.d.ts +0 -5
- package/dist/rule-lifecycle.js +59 -1
- package/package.json +2 -2
package/dist/rule-lifecycle.d.ts
CHANGED
|
@@ -1,7 +1,2 @@
|
|
|
1
1
|
import { type LaneRoute } from "./state.js";
|
|
2
|
-
/**
|
|
3
|
-
* S25-rule-lifecycle lane: enable/disable/delete mutations. Twin of
|
|
4
|
-
* src/lanes/rule-lifecycle.ts. The platform quirk stands: `enabled` is the
|
|
5
|
-
* truth; `status` may still read DISABLED.
|
|
6
|
-
*/
|
|
7
2
|
export declare const ruleLifecycleRoute: LaneRoute;
|
package/dist/rule-lifecycle.js
CHANGED
|
@@ -1,15 +1,73 @@
|
|
|
1
|
-
import { NOT_HANDLED } from "./state.js";
|
|
1
|
+
import { NOT_HANDLED, businessRefusal } from "./state.js";
|
|
2
2
|
/**
|
|
3
3
|
* S25-rule-lifecycle lane: enable/disable/delete mutations. Twin of
|
|
4
4
|
* src/lanes/rule-lifecycle.ts. The platform quirk stands: `enabled` is the
|
|
5
5
|
* truth; `status` may still read DISABLED.
|
|
6
6
|
*/
|
|
7
|
+
/**
|
|
8
|
+
* Live 1.1.25 fidelity: businessrule/publish answers 550018
|
|
9
|
+
* (BUSINESS_RULE_PARAM_ERROR 「保存规则失败,规则存在异常」) when the platform's
|
|
10
|
+
* self-check finds a referenced property that does not exist / is unpublished,
|
|
11
|
+
* a missing org object, or a dead cycle. `node_run_map` returns that detail per
|
|
12
|
+
* node (BusinessRuleController.getNodeRunMaps → checkBizRuleError).
|
|
13
|
+
*/
|
|
14
|
+
function selfCheckProblems(state, model) {
|
|
15
|
+
const schemaCode = String(model.schemaCode ?? "");
|
|
16
|
+
const raw = model.node;
|
|
17
|
+
let nodes = [];
|
|
18
|
+
try {
|
|
19
|
+
const parsed = typeof raw === "string" ? JSON.parse(raw) : raw;
|
|
20
|
+
if (Array.isArray(parsed))
|
|
21
|
+
nodes = parsed;
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return [];
|
|
25
|
+
}
|
|
26
|
+
const known = new Set();
|
|
27
|
+
for (const [key, field] of state.fields) {
|
|
28
|
+
const [schema, code] = key.split("#");
|
|
29
|
+
if (schema === schemaCode && field.published)
|
|
30
|
+
known.add(String(code));
|
|
31
|
+
}
|
|
32
|
+
const problems = [];
|
|
33
|
+
for (const node of nodes) {
|
|
34
|
+
const actions = Array.isArray(node.dataActions) ? node.dataActions : [];
|
|
35
|
+
const missing = actions
|
|
36
|
+
.map((action) => String(action.targetDataItem ?? ""))
|
|
37
|
+
.filter((code) => code !== "" && !known.has(code));
|
|
38
|
+
if (missing.length > 0) {
|
|
39
|
+
problems.push({
|
|
40
|
+
schemaCode,
|
|
41
|
+
nodeCode: node.nodeCode ?? "",
|
|
42
|
+
nodeName: node.nodeName ?? "",
|
|
43
|
+
notExistPropertyObjectList: [{
|
|
44
|
+
objectCode: schemaCode,
|
|
45
|
+
objectName: schemaCode,
|
|
46
|
+
objectType: 1,
|
|
47
|
+
modelExist: true,
|
|
48
|
+
quotePropertyList: missing.map((code) => ({ objectCode: schemaCode, objectName: schemaCode, propertyCode: code, propertyName: code, exist: false, propertyPublished: false })),
|
|
49
|
+
}],
|
|
50
|
+
notExistOrgObjectList: [],
|
|
51
|
+
deadCycleRunMapList: [],
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return problems;
|
|
56
|
+
}
|
|
7
57
|
export const ruleLifecycleRoute = (ctx, input) => {
|
|
8
58
|
const q = input.query ?? {};
|
|
9
59
|
const body = (input.body ?? {});
|
|
10
60
|
switch (input.path) {
|
|
61
|
+
case "/api/api/app/businessrule/node_run_map":
|
|
62
|
+
return selfCheckProblems(ctx.state, body);
|
|
11
63
|
case "/api/api/app/businessrule/publish": {
|
|
12
64
|
const targetId = q.id ?? body.id;
|
|
65
|
+
const stored = [...ctx.state.rules.values()].find((rule) => rule.id === targetId);
|
|
66
|
+
const model = { ...(stored ?? {}), ...body };
|
|
67
|
+
if (process.env.FAKE_DEBUG_SELFCHECK)
|
|
68
|
+
console.error("DEBUG body keys", Object.keys(body), "nodeType", typeof body.node, String(body.node ?? "").slice(0, 120), "known", [...ctx.state.fields.keys()].slice(0, 6));
|
|
69
|
+
if (selfCheckProblems(ctx.state, model).length > 0)
|
|
70
|
+
return businessRefusal(550018, "保存规则失败,规则存在异常,请点击检测并修正!");
|
|
13
71
|
for (const rule of ctx.state.rules.values())
|
|
14
72
|
if (rule.id === targetId)
|
|
15
73
|
rule.enabled = true;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stalfh233/omc-fake-platform",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.71",
|
|
4
4
|
"description": "OMC 的内存假 CloudPivot 平台(wire 接缝的第二个适配器)+ HTTP 假服务器——@stalfh233/omc-cli 的测试与 bench 基准基座",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"build": "tsc --project tsconfig.build.json"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"omc-core": "0.4.
|
|
21
|
+
"omc-core": "0.4.71"
|
|
22
22
|
},
|
|
23
23
|
"engines": {
|
|
24
24
|
"node": ">=22.13"
|