@stalfh233/omc-fake-platform 0.6.82 → 0.6.83

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.
@@ -46,28 +46,35 @@ export const businessRuleRoute = (ctx, input) => {
46
46
  switch (input.path) {
47
47
  case "/api/api/app/businessrule/list_by_schemacode":
48
48
  case "/api/api/runtime/business_rule/list_by_schemacode":
49
- return [...ctx.state.rules.values()].filter((rule) => rule.schemaCode === q.schemaCode).map((rule) => ({
50
- id: rule.id,
51
- schemaCode: rule.schemaCode,
52
- code: rule.code,
53
- ruleCode: rule.code,
54
- name: rule.name,
55
- enabled: rule.enabled,
56
- status: rule.status ?? (rule.enabled ? RULE_STATUS.enabled : RULE_STATUS.disabled),
57
- // Live fidelity: the list face carries defaultRule (platform preset
58
- // trigger rows answer true); consumers derive `preset` from it.
59
- defaultRule: rule.defaultRule ?? false,
60
- priority: rule.priority ?? 0,
61
- createdTime: rule.createdTime ?? 1730000000000,
62
- creator: rule.creator ?? "fake-user",
63
- // latestPublished must read the COMPUTED status, not the raw optional
64
- // field: a rule enabled by businessrule/publish has no explicit
65
- // publishStatus and previously reported latestPublished:false here.
66
- publishStatus: rule.publishStatus ?? (rule.enabled ? "PUBLISHED" : "DRAFT"),
67
- developmentMode: rule.developmentMode ?? "CODING",
68
- ruleVersion: rule.ruleVersion ?? 1,
69
- latestPublished: (rule.publishStatus ?? (rule.enabled ? "PUBLISHED" : "DRAFT")) === "PUBLISHED",
70
- }));
49
+ return [...ctx.state.rules.values()].filter((rule) => rule.schemaCode === q.schemaCode).map((rule) => {
50
+ // r86 issue 14 fidelity: hidePublishedFace keeps the list projections
51
+ // from ever showing latestPublished (DRAFT-only app face / runtime face
52
+ // draft-enabled filter) even after a successful publish.
53
+ const computedPublishStatus = rule.publishStatus ?? (rule.enabled ? "PUBLISHED" : "DRAFT");
54
+ const facePublishStatus = rule.hidePublishedFace === true ? "DRAFT" : computedPublishStatus;
55
+ return {
56
+ id: rule.id,
57
+ schemaCode: rule.schemaCode,
58
+ code: rule.code,
59
+ ruleCode: rule.code,
60
+ name: rule.name,
61
+ enabled: rule.enabled,
62
+ status: rule.status ?? (rule.enabled ? RULE_STATUS.enabled : RULE_STATUS.disabled),
63
+ // Live fidelity: the list face carries defaultRule (platform preset
64
+ // trigger rows answer true); consumers derive `preset` from it.
65
+ defaultRule: rule.defaultRule ?? false,
66
+ priority: rule.priority ?? 0,
67
+ createdTime: rule.createdTime ?? 1730000000000,
68
+ creator: rule.creator ?? "fake-user",
69
+ // latestPublished must read the COMPUTED status, not the raw optional
70
+ // field: a rule enabled by businessrule/publish has no explicit
71
+ // publishStatus and previously reported latestPublished:false here.
72
+ publishStatus: facePublishStatus,
73
+ developmentMode: rule.developmentMode ?? "CODING",
74
+ ruleVersion: rule.ruleVersion ?? 1,
75
+ latestPublished: facePublishStatus === "PUBLISHED",
76
+ };
77
+ });
71
78
  case "/api/api/app/businessrule/get": {
72
79
  // Ticket 109 fidelity: superseded rows stay readable by their OLD id
73
80
  // (historical versions) — the current rows map only holds the newest.
@@ -17,6 +17,20 @@ export const environmentRoute = (ctx, input) => {
17
17
  };
18
18
  case "/user/public/getKey":
19
19
  return { key: FAKE_RSA_PUBLIC_KEY, index: "1" };
20
+ case "/api/license/info":
21
+ // r86(retro issue 17):LicenseController.info(8.6 族)→ LicenseInfo
22
+ // {systemVersion(系统版本号), licenseType, expiration, ...}。
23
+ // 默认挂载(fake 基线是 8.6.26);1.1.x 产品线不挂载——测试用
24
+ // fake.absentPaths.add("/api/license/info") 模拟(真机 1.1.25 实测 404)。
25
+ // buildTime 是 LicenseInfo 的**声明字段**,但 8.6.26 的 info() 从不 setBuildTime
26
+ // (反编译 LicenseController.java:92-119)——默认不伪造;要测「有 buildTime
27
+ // 的产品线」用 options.licenseBuildTime 显式注入。
28
+ return {
29
+ systemVersion: ctx.options.systemVersion ?? ctx.options.version ?? "8.6.26",
30
+ ...(ctx.options.licenseBuildTime !== undefined ? { buildTime: ctx.options.licenseBuildTime } : {}),
31
+ licenseType: 2,
32
+ expiration: "2030-01-01",
33
+ };
20
34
  case "/user/login/Authentication/get_code":
21
35
  return { code: "fake-auth-code" };
22
36
  case "/user/login/Authentication/get_token":
package/dist/index.d.ts CHANGED
@@ -66,6 +66,13 @@ export declare class FakeCloudPivot implements CloudPivotHttp {
66
66
  markListViewUnconfigured(schemaCode: string): void;
67
67
  seedApp(app: Partial<FakeApp> & Pick<FakeApp, "code">): void;
68
68
  seedField(schemaCode: string, code: string, propertyType: number, published?: boolean, options?: Record<string, unknown>): void;
69
+ /**
70
+ * r86(retro issue 15):种一个子表 schema(bizmodels/get_all 的 parentCode 面)。
71
+ * 真平台里子表 schema 由父模型的 CHILD_TABLE 字段隐式创建;fake 不模拟该隐式链,
72
+ * 测试显式声明 child→parent 关系即可驱动 get_all parentCode 与 query/list 的
73
+ * 子表面行为(裸过滤字段按父模型解析 → 50000)。
74
+ */
75
+ seedChildSchema(childCode: string, parentCode: string, name?: string): void;
69
76
  request(input: FakeRequestInput): Promise<{
70
77
  status: number;
71
78
  body: unknown;
package/dist/index.js CHANGED
@@ -124,6 +124,18 @@ export class FakeCloudPivot {
124
124
  this.ensureSeedModel(schemaCode);
125
125
  this.state.fields.set(`${schemaCode}#${code}`, { code, name: code, type: String(propertyType), published, ...(options !== undefined ? { options: JSON.stringify(options) } : {}) });
126
126
  }
127
+ /**
128
+ * r86(retro issue 15):种一个子表 schema(bizmodels/get_all 的 parentCode 面)。
129
+ * 真平台里子表 schema 由父模型的 CHILD_TABLE 字段隐式创建;fake 不模拟该隐式链,
130
+ * 测试显式声明 child→parent 关系即可驱动 get_all parentCode 与 query/list 的
131
+ * 子表面行为(裸过滤字段按父模型解析 → 50000)。
132
+ */
133
+ seedChildSchema(childCode, parentCode, name = childCode) {
134
+ this.ensureSeedModel(childCode);
135
+ this.ensureSeedModel(parentCode);
136
+ this.state.models.get(childCode).parentCode = parentCode;
137
+ this.state.models.get(childCode).name = name;
138
+ }
127
139
  async request(input) {
128
140
  this.state.callLog.push({
129
141
  path: input.path,
package/dist/model.js CHANGED
@@ -163,7 +163,9 @@ export const modelRoute = (ctx, input) => {
163
163
  if (ctx.options.modelGetAllAbsent === true)
164
164
  return httpErrorResponse(404, JSON.stringify({ timestamp: "fake", status: 404, error: "Not Found", path: input.path }));
165
165
  const model = ctx.state.models.get(q.schemaCode);
166
- return model ? { id: model.recordId, name: model.name, modelType: "LIST" } : null;
166
+ // r86(retro issue 15):BizSchemaModel.parentCode 是子表判别面(真机 1.1.25
167
+ // 实证:get_all?schemaCode=w9a_items → parentCode=w9a_parent)。
168
+ return model ? { id: model.recordId, name: model.name, modelType: "LIST", ...(model.parentCode ? { parentCode: model.parentCode } : {}) } : null;
167
169
  }
168
170
  case "/api/api/app/folders/create": {
169
171
  const appCode = String(body.appCode ?? "");
@@ -142,10 +142,27 @@ export const ruleLifecycleRoute = (ctx, input) => {
142
142
  const model = { ...(stored ?? {}), ...body };
143
143
  if (selfCheckProblems(ctx.state, model).length > 0)
144
144
  return businessRefusal(550018, "保存规则失败,规则存在异常,请点击检测并修正!");
145
- for (const rule of ctx.state.rules.values())
146
- if (rule.id === targetId)
147
- rule.enabled = true;
148
- return null;
145
+ // r86 issue 14 fidelity: the platform publish is synchronous — the facade
146
+ // mints the PUBLISH row in-lock (ruleVersion = max+1, latestPublished=TRUE,
147
+ // status ENABLED; BusinessRuleServiceImpl.publish:483-536) and RETURNS the
148
+ // model with the minted ruleVersion (BusinessRuleFacadeImpl.
149
+ // publishBusinessRule:337-352). The response body is the verification
150
+ // evidence rule.save falls back to when the list faces cannot show the row.
151
+ for (const rule of ctx.state.rules.values()) {
152
+ if (rule.id !== targetId)
153
+ continue;
154
+ rule.enabled = true;
155
+ rule.ruleVersion = (rule.ruleVersion ?? 0) + 1;
156
+ if (rule.hidePublishedFace !== true)
157
+ rule.publishStatus = "PUBLISHED";
158
+ }
159
+ const storedNow = [...ctx.state.rules.values()].find((rule) => rule.id === targetId);
160
+ const responseModel = { ...(storedNow ?? model), ruleVersion: storedNow?.ruleVersion ?? 1, latestPublished: storedNow?.hidePublishedFace === true ? false : true };
161
+ if (storedNow?.publishResponseBare === true) {
162
+ delete responseModel.ruleVersion;
163
+ return responseModel;
164
+ }
165
+ return responseModel;
149
166
  }
150
167
  case "/api/api/app/businessrule/enable": {
151
168
  // BusinessRuleKeyRequest {schemaCode, ruleCode} flips the DRAFT row's
@@ -41,6 +41,23 @@ export const runtimeDataRoute = (ctx, input) => {
41
41
  // and>or>and>leaf array (level1 AND across groups, level2 OR across
42
42
  // and-groups, level3 AND across leaves), PageVO response.
43
43
  const schemaCode = String(body.schemaCode ?? "");
44
+ // r86(retro issue 15,8.6.26 ChildBizObjectAssembler + 真机 1.1.25):子表
45
+ // schema(get_all parentCode 非空)的 queryCondition 叶子按**父模型**解析——
46
+ // 裸字段不在父属性表 → 50000 服务异常;带点号的 `<子表code>.<字段>` 合法
47
+ // (真机:productCode eq → 50000、parentId eq → 50000、
48
+ // w9a_items.productCode eq → errcode 0)。
49
+ const parentCode = ctx.state.models.get(schemaCode)?.parentCode;
50
+ if (parentCode && Array.isArray(body.queryCondition)) {
51
+ const bareFields = collectConditionFields(body.queryCondition)
52
+ .filter((code) => !code.includes("."))
53
+ // 默认属性列(DefaultPropertyType.codes)两表都有物理列,按父模型解析也成立
54
+ // (平台子表分支自己就用 parent-scope sequenceStatus 排草稿);只有父表
55
+ // **没有**的裸字段(子表业务列、parentId 之外的子表专有列)才 50000。
56
+ .filter((code) => !ORDERABLE_SYSTEM_FIELDS.has(code))
57
+ .filter((code) => !ctx.state.fields.has(`${parentCode}#${code}`));
58
+ if (bareFields.length > 0)
59
+ return businessRefusal(50000, "服务异常");
60
+ }
44
61
  const rows = [...ctx.state.dataRows.values()].filter((row) => row.schemaCode === schemaCode);
45
62
  const groups = Array.isArray(body.queryCondition) ? body.queryCondition : [];
46
63
  const filtered = groups.length > 0
@@ -49,6 +66,15 @@ export const runtimeDataRoute = (ctx, input) => {
49
66
  const page = typeof body.page === "number" ? body.page : 0;
50
67
  const size = typeof body.size === "number" ? body.size : 20;
51
68
  const start = page * size;
69
+ // r86(retro issue 16,8.6.26 QueryDataVO.orders + 真机 1.1.25):服务端排序
70
+ // orders:[{propertyCode,dir:ASC|DESC}]——dir 大小写敏感(Order$Dir 枚举,小写
71
+ // 10009);未知列 → 40000 调用数据库发生异常(真机);多键数组序优先、
72
+ // ASC 时 null 在前(真机 contract_no ASC 的 None 首位)。子表 schema 分支
73
+ // 不消费 orders(ChildBizObjectAssembler 不设排序)——如实忽略。
74
+ const ordered = parentCode ? filtered : applyOrders(ctx, schemaCode, filtered, body.orders);
75
+ if (ordered === null)
76
+ return businessRefusal(40000, "调用数据库发生异常");
77
+ const content = ordered.slice(start, start + size);
52
78
  // An unconfigured default list view omits business columns from the
53
79
  // projection: the stored value exists but the wire row does not carry
54
80
  // it, so explicit display columns read back null (ticket 07).
@@ -61,7 +87,7 @@ export const runtimeDataRoute = (ctx, input) => {
61
87
  totalPages: size > 0 ? Math.ceil(filtered.length / size) : 0,
62
88
  page,
63
89
  size,
64
- content: filtered.slice(start, start + size).map((row) => ({
90
+ content: content.map((row) => ({
65
91
  bizObjectId: row.bizObjectId,
66
92
  schemaCode,
67
93
  data: project(row),
@@ -427,3 +453,75 @@ function matchesCondition(condition, row) {
427
453
  return true;
428
454
  return operator.matches(row[String(value.propertyCode ?? "")], String(value.propertyValue ?? ""));
429
455
  }
456
+ /** Walk a 3-level queryCondition array and collect leaf propertyCode values. */
457
+ function collectConditionFields(condition) {
458
+ const codes = [];
459
+ const walk = (node) => {
460
+ if (Array.isArray(node)) {
461
+ node.forEach(walk);
462
+ return;
463
+ }
464
+ if (node === null || typeof node !== "object")
465
+ return;
466
+ const leaf = node;
467
+ if (typeof leaf.propertyCode === "string" && leaf.propertyCode)
468
+ codes.push(leaf.propertyCode);
469
+ };
470
+ walk(condition);
471
+ return [...new Set(codes)];
472
+ }
473
+ /**
474
+ * r86(retro issue 16):QueryDataVO.orders 服务端排序。可排面 = 已发布业务字段 +
475
+ * 系统列(DefaultPropertyType;平台默认排序本身就是 createdTime)。不在可排面的
476
+ * 列 → 40000 调用数据库发生异常(真机 1.1.25 实证:no_such_col DESC → 40000)。
477
+ * 排序语义:多键数组序优先、ASC 时 null 在前(真机 contract_no ASC 的 None 首
478
+ * 位)、并列保持插入序(JS sort 稳定)。
479
+ */
480
+ const ORDERABLE_SYSTEM_FIELDS = new Set([
481
+ "id", "name", "creater", "createdDeptId", "owner", "ownerDeptId", "createdTime",
482
+ "modifier", "modifiedTime", "workflowInstanceId", "sequenceNo", "sequenceStatus",
483
+ "ownerDeptQueryCode", "version",
484
+ ]);
485
+ function orderableFieldOf(ctx, schemaCode, code) {
486
+ if (ORDERABLE_SYSTEM_FIELDS.has(code))
487
+ return true;
488
+ return ctx.state.fields.has(`${schemaCode}#${code}`);
489
+ }
490
+ function applyOrders(ctx, schemaCode, rows, orders) {
491
+ if (!Array.isArray(orders) || orders.length === 0)
492
+ return rows;
493
+ const keys = [];
494
+ for (const entry of orders) {
495
+ if (!entry || typeof entry !== "object")
496
+ return null;
497
+ const code = String(entry.propertyCode ?? "");
498
+ const dir = String(entry.dir ?? "");
499
+ if (!code || (dir !== "ASC" && dir !== "DESC"))
500
+ return null;
501
+ if (!orderableFieldOf(ctx, schemaCode, code))
502
+ return null;
503
+ keys.push({ code, dir });
504
+ }
505
+ return [...rows].sort((left, right) => {
506
+ for (const key of keys) {
507
+ const compared = compareOrderValues(left[key.code], right[key.code]);
508
+ if (compared !== 0)
509
+ return key.dir === "DESC" ? -compared : compared;
510
+ }
511
+ return 0;
512
+ });
513
+ }
514
+ /** null/undefined first under ASC (observed live: contract_no ASC put None first). */
515
+ function compareOrderValues(left, right) {
516
+ const leftMissing = left === null || left === undefined || left === "";
517
+ const rightMissing = right === null || right === undefined || right === "";
518
+ if (leftMissing && rightMissing)
519
+ return 0;
520
+ if (leftMissing)
521
+ return -1;
522
+ if (rightMissing)
523
+ return 1;
524
+ if (typeof left === "number" && typeof right === "number")
525
+ return left - right;
526
+ return String(left).localeCompare(String(right));
527
+ }
package/dist/state.d.ts CHANGED
@@ -42,6 +42,12 @@ export interface FakeCloudPivotOptions {
42
42
  readonly systemClientSecretField?: boolean;
43
43
  readonly systemClient?: string;
44
44
  readonly systemVersion?: string;
45
+ /**
46
+ * r86(retro issue 17):LicenseInfo.buildTime 是声明字段但 8.6.26 的
47
+ * `GET /api/license/info` 从不赋值(反编译 LicenseController.info)。
48
+ * 默认不返回;测试「有 buildTime 的产品线」时显式注入。
49
+ */
50
+ readonly licenseBuildTime?: string;
45
51
  /**
46
52
  * 8.0/8.1 deployments do not serve `/api/api/app/bizmodels/get_all` at all —
47
53
  * the path answers HTTP 404 and the same rows come from
@@ -150,6 +156,20 @@ export interface FakeRule {
150
156
  ruleVersion?: number;
151
157
  /** Platform preset trigger rule (Create/Update/Load/…); the list face exposes it. */
152
158
  defaultRule?: boolean;
159
+ /**
160
+ * r86 issue 14 fidelity: publish succeeds and the response carries the minted
161
+ * ruleVersion, but the list faces keep reporting latestPublished:false /
162
+ * publishStatus:"DRAFT" — modeling the real platform's DRAFT-only app face
163
+ * and the runtime face's draft-enabled filter (a disabled draft hides the
164
+ * PUBLISH row). Verification must fall back to the publish response.
165
+ */
166
+ hidePublishedFace?: boolean;
167
+ /**
168
+ * r86 issue 14 fidelity: the publish answer carries NO ruleVersion (product
169
+ * lines whose publish response is a bare ok) — combined with
170
+ * hidePublishedFace, neither evidence face can verify the publish.
171
+ */
172
+ publishResponseBare?: boolean;
153
173
  }
154
174
  export interface FakeDataRule {
155
175
  id: string;
@@ -527,6 +547,7 @@ export interface FakeState {
527
547
  treeHidden?: boolean;
528
548
  nodeName?: string;
529
549
  parentId?: string;
550
+ parentCode?: string;
530
551
  }>;
531
552
  apps: Map<string, FakeApp>;
532
553
  appGroups: Map<string, FakeAppGroup>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stalfh233/omc-fake-platform",
3
- "version": "0.6.82",
3
+ "version": "0.6.83",
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.82"
21
+ "omc-core": "0.6.83"
22
22
  },
23
23
  "engines": {
24
24
  "node": ">=22.13"