@stalfh233/omc-fake-platform 0.6.0 → 0.6.2

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.
Files changed (2) hide show
  1. package/dist/workflow.js +30 -2
  2. package/package.json +1 -1
package/dist/workflow.js CHANGED
@@ -451,12 +451,40 @@ export const workflowRoute = (ctx, input) => {
451
451
  return null;
452
452
  return { id: item.bizObjectId, schemaCode: item.schemaCode };
453
453
  }
454
- case "/api/api/organization/role/list":
454
+ case "/api/api/organization/role/list": {
455
455
  // Real shape: groups with `children` roles (see real-env observation).
456
+ // r70: previously a static fixture — a group/role created in the same
457
+ // session never showed up, so any readback-based guard (and any agent
458
+ // checking its own write) got a wrong "not created" answer. Reflect the
459
+ // live state: seeded group first, then created groups, each with its
460
+ // roles. Roles whose roleGroupId is not a known group are omitted, which
461
+ // mirrors the real orphan behaviour (row exists, tree never returns it).
462
+ const roleOf = (role) => ({
463
+ id: role.id,
464
+ name: role.name,
465
+ code: role.code,
466
+ roleType: role.roleType ?? "SYS",
467
+ corpId: role.corpId ?? "corp-1",
468
+ });
469
+ const rolesByGroup = new Map();
470
+ for (const role of [...ctx.state.orgRoles.values()]) {
471
+ const bucket = rolesByGroup.get(role.roleGroupId) ?? [];
472
+ bucket.push(roleOf(role));
473
+ rolesByGroup.set(role.roleGroupId, bucket);
474
+ }
475
+ const seededRoles = [{ id: "role-lead", name: "部门负责人", code: "SYS260630023816197", roleType: "SYS", corpId: "corp-1" }];
476
+ const groups = [
477
+ { id: "grp-1", name: "默认", code: "SYS_1000000", group: true, children: [...seededRoles, ...(rolesByGroup.get("grp-1") ?? [])] },
478
+ ...[...ctx.state.orgGroups.values()]
479
+ .filter((group) => group.id !== "grp-1")
480
+ .map((group) => ({ id: group.id, name: group.name, code: group.code, group: true, children: rolesByGroup.get(group.id) ?? [] })),
481
+ ];
456
482
  return [
457
- { id: "grp-1", name: "默认", code: "SYS_1000000", children: [{ id: "role-lead", name: "部门负责人", code: "SYS260630023816197", roleType: "SYS", corpId: "corp-1" }] },
483
+ ...groups,
484
+ // Leaf role with no group container (legacy fixture shape).
458
485
  { id: "role-finance", name: "财务负责人", code: "SYS260515031207258", roleType: "SYS", corpId: "corp-1" },
459
486
  ];
487
+ }
460
488
  case "/api/api/organization/department/tree": {
461
489
  // Platform semantics (re-verified r15, 1.1.25): no deptIds → roots ONLY;
462
490
  // deptIds=<id> → DIRECT CHILDREN only. The old "whole subtree" fake made
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stalfh233/omc-fake-platform",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
4
4
  "description": "OMC 的内存假 CloudPivot 平台(wire 接缝的第二个适配器)+ HTTP 假服务器——@stalfh233/omc-cli 的测试与 bench 基准基座",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",