@stalfh233/omc-fake-platform 0.6.86 → 0.6.87

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.
@@ -418,6 +418,35 @@ export const b2Route = (ctx, input) => {
418
418
  outputParameterModels: parseParamArray(method.outputParametersJson),
419
419
  referenced: method.referenced === true,
420
420
  }));
421
+ case "/api/api/bizservice/method/viewReference": {
422
+ // BizServiceMethodController.java:452-487: the referencing MODELS/apps
423
+ // (no ruleCode on this face). Derived from the current rule set, like the
424
+ // real h_biz_method_mapping rows.
425
+ const hits = [];
426
+ for (const rule of ctx.state.rules.values()) {
427
+ const mapped = parseParamArray(rule.node).some((entry) => {
428
+ if (!entry || typeof entry !== "object" || Array.isArray(entry))
429
+ return false;
430
+ const mapping = entry.methodMapping;
431
+ if (!mapping || typeof mapping !== "object" || Array.isArray(mapping))
432
+ return false;
433
+ const m = mapping;
434
+ return String(m.serviceCode ?? "") === String(q.serviceCode ?? "") && String(m.serviceMethodCode ?? "") === String(q.serviceMethodCode ?? "");
435
+ });
436
+ if (mapped && !hits.some((hit) => hit.schemaCode === rule.schemaCode))
437
+ hits.push({ schemaCode: rule.schemaCode, appCode: "test", schemaName: rule.schemaCode, appName: "test" });
438
+ }
439
+ return hits;
440
+ }
441
+ case "/api/api/app/bizmethod/count_mapping": {
442
+ // F12: GET /app/bizmethod/count_mapping?serviceCode=[&serviceMethodCode=]
443
+ // → Integer (BizMethodController.java:287-307). The real query counts
444
+ // mapping ROWS; the fake models one referenced flag per method, so the
445
+ // count is the number of referenced methods (0 for an unknown service —
446
+ // live-proven: no_such_service answers data:0, not an errcode).
447
+ const methods = ctx.state.services.get(String(q.serviceCode ?? ""))?.methods ?? [];
448
+ return methods.filter((method) => method.referenced === true && (q.serviceMethodCode === undefined || method.code === q.serviceMethodCode)).length;
449
+ }
421
450
  case "/api/api/bizservice/service/delete": {
422
451
  for (const [code, service] of ctx.state.services) {
423
452
  if (service.id === q.id || code === q.id)
@@ -11,7 +11,19 @@ import { NOT_HANDLED } from "./state.js";
11
11
  * the bound biz-service methods referenced (the platform derives the same
12
12
  * flag from its mapping tables; a referenced method refuses method/delete
13
13
  * with 500108).
14
+ *
15
+ * r89 T3 fidelity (A3): the platform DELETES the rule's mapping rows and
16
+ * re-inserts them on every rule save (BusinessRuleFacadeImpl.java:278-334;
17
+ * h_biz_method_mapping). A pure "mark true" fake therefore kept a stale mark
18
+ * forever — after unbinding the node and saving, the method still answered
19
+ * 500108 in the fake while the real platform allows the delete. Recompute from
20
+ * the CURRENT rule set on every save instead (clear all, then mark).
14
21
  */
22
+ function clearReferencedMethods(ctx) {
23
+ for (const service of ctx.state.services.values())
24
+ for (const method of service.methods)
25
+ method.referenced = false;
26
+ }
15
27
  function markReferencedMethods(ctx, nodeJson) {
16
28
  if (typeof nodeJson !== "string")
17
29
  return;
@@ -40,6 +52,12 @@ function markReferencedMethods(ctx, nodeJson) {
40
52
  method.referenced = true;
41
53
  }
42
54
  }
55
+ /** Delete-then-recreate the mapping marks across every current rule (platform parity). */
56
+ function recomputeReferencedMethods(ctx) {
57
+ clearReferencedMethods(ctx);
58
+ for (const rule of ctx.state.rules.values())
59
+ markReferencedMethods(ctx, rule.node);
60
+ }
43
61
  export const businessRuleRoute = (ctx, input) => {
44
62
  const q = input.query ?? {};
45
63
  const body = (input.body ?? {});
@@ -133,8 +151,10 @@ export const businessRuleRoute = (ctx, input) => {
133
151
  // Ticket 97 fidelity: a saved methodMapping (serviceCode+serviceMethodCode
134
152
  // inside the node graph) marks the bound method referenced — the
135
153
  // platform derives the same flag from the mapping tables, and a
136
- // referenced method refuses method/delete with 500108.
137
- markReferencedMethods(ctx, typeof body.node === "string" ? body.node : existing?.node);
154
+ // referenced method refuses method/delete with 500108. Save = delete +
155
+ // re-insert of this rule's mapping rows, so the whole mark set is
156
+ // recomputed (an unbound node releases its method).
157
+ recomputeReferencedMethods(ctx);
138
158
  return null;
139
159
  }
140
160
  default:
@@ -94,6 +94,44 @@ export const runtimeDataRoute = (ctx, input) => {
94
94
  })),
95
95
  };
96
96
  }
97
+ case "/api/api/runtime/query/sum": {
98
+ // QueryRuntimeController.sum fidelity (D5): POST /runtime/query/sum with
99
+ // sumItemList[{propertyCode,sumDataType}]; ALL_DATA is an independent
100
+ // scalar aggregate over the same queryCondition (NOT the GET_LIST rule
101
+ // path — DomainServiceImpl.query is bypassed), response
102
+ // {<fieldCode>:{COUNT,SUM,MAX,MIN,AVG}} (BigDecimal → JSON number).
103
+ const schemaCode = String(body.schemaCode ?? "");
104
+ const rows = [...ctx.state.dataRows.values()].filter((row) => row.schemaCode === schemaCode);
105
+ const groups = Array.isArray(body.queryCondition) ? body.queryCondition : [];
106
+ const filtered = groups.length > 0
107
+ ? rows.filter((row) => groups.every((group) => (Array.isArray(group) ? group : [group]).some((andGroup) => (Array.isArray(andGroup) ? andGroup : [andGroup]).every((leaf) => matchesCondition(leaf, row)))))
108
+ : rows;
109
+ const page = typeof body.page === "number" ? body.page : 0;
110
+ const size = typeof body.size === "number" ? body.size : 20;
111
+ const currentPage = filtered.slice(page * size, page * size + size);
112
+ const items = Array.isArray(body.sumItemList) ? body.sumItemList : [];
113
+ const result = {};
114
+ for (const item of items) {
115
+ const code = String(item?.propertyCode ?? "");
116
+ if (!code)
117
+ continue;
118
+ const source = item.sumDataType === "CURRENT_PAGE" ? currentPage : filtered;
119
+ const values = source
120
+ .map((row) => row[code])
121
+ .map((value) => (typeof value === "number" ? value : typeof value === "string" && value.trim() !== "" ? Number(value) : Number.NaN))
122
+ .filter((value) => Number.isFinite(value));
123
+ const count = values.length;
124
+ const total = values.reduce((sum, value) => sum + value, 0);
125
+ result[code] = {
126
+ COUNT: count,
127
+ SUM: count > 0 ? total : 0,
128
+ MAX: count > 0 ? Math.max(...values) : 0,
129
+ MIN: count > 0 ? Math.min(...values) : 0,
130
+ AVG: count > 0 ? total / count : 0,
131
+ };
132
+ }
133
+ return result;
134
+ }
97
135
  case "/api/api/runtime/form/save": {
98
136
  const bizObject = (body.bizObject ?? {});
99
137
  const data = bizObject.data ?? {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stalfh233/omc-fake-platform",
3
- "version": "0.6.86",
3
+ "version": "0.6.87",
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.6.86"
21
+ "omc-core": "0.6.87"
22
22
  },
23
23
  "engines": {
24
24
  "node": ">=22.13"