@stalfh233/omc-fake-platform 0.6.27 → 0.6.28
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/perm.d.ts +3 -0
- package/dist/perm.js +26 -0
- package/dist/routes.js +2 -0
- package/dist/state.d.ts +12 -0
- package/dist/state.js +1 -0
- package/package.json +2 -2
package/dist/perm.d.ts
ADDED
package/dist/perm.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { businessRefusal, NOT_HANDLED } from "./state.js";
|
|
2
|
+
/** r48a permission wire face used by perm.* CLI adapters. */
|
|
3
|
+
export const permRoute = (ctx, input) => {
|
|
4
|
+
const q = input.query ?? {};
|
|
5
|
+
const body = (input.body ?? {});
|
|
6
|
+
const groups = [...ctx.state.permissionGroups.values()].filter((g) => !q.appCode || g.appCode === q.appCode);
|
|
7
|
+
if (input.path === "/api/api/organization/authorization/listPermissionGroups" && input.method === "POST") {
|
|
8
|
+
if (!body.unitId)
|
|
9
|
+
return businessRefusal(10005, "部门/角色/用户Id不能为空");
|
|
10
|
+
const assigned = groups.filter((g) => g.members.some((m) => String(m.unitId) === String(body.unitId) && Number(m.unitType) === Number(body.unitType)));
|
|
11
|
+
if (assigned.length === 0)
|
|
12
|
+
return businessRefusal(-1, "没有找到该用户的权限组");
|
|
13
|
+
return assigned.map((g) => ({ appCode: g.appCode, permissionGroups: [{ permissionGroupId: g.id, permissionGroupName: g.name, modelPermissions: [] }] }));
|
|
14
|
+
}
|
|
15
|
+
if (input.path === "/api/api/organization/authorization/mergePermissionsGroup" && input.method === "POST")
|
|
16
|
+
return { adminBypass: String(body.unitId) === "admin", visible: true, administrator: String(body.unitId) === "admin", allVisible: String(body.unitId) === "admin", models: [], fields: [], dataPermissionType: 1 };
|
|
17
|
+
if ((input.path === "/api/api/organization/authorization/savePermissionGroupUtils" || input.path === "/api/api/organization/authorization/deletePermissionGroupUtils") && input.method === "POST") {
|
|
18
|
+
const units = Array.isArray(body.permissionGroupUnits) ? body.permissionGroupUnits : [];
|
|
19
|
+
const groupId = String((Array.isArray(body.permGroupInfos) ? body.permGroupInfos[0]?.permGroupId : body.permGroupId) ?? "");
|
|
20
|
+
const g = ctx.state.permissionGroups.get(groupId);
|
|
21
|
+
if (g)
|
|
22
|
+
g.members = input.path.endsWith("savePermissionGroupUtils") ? units : g.members.filter((m) => !units.some((u) => String(u.unitId) === String(m.unitId)));
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
return NOT_HANDLED;
|
|
26
|
+
};
|
package/dist/routes.js
CHANGED
|
@@ -17,6 +17,7 @@ import { ruleLogRoute } from "./rulelog.js";
|
|
|
17
17
|
import { runtimeDataRoute } from "./runtime-data.js";
|
|
18
18
|
import { NOT_HANDLED } from "./state.js";
|
|
19
19
|
import { workflowRoute } from "./workflow.js";
|
|
20
|
+
import { permRoute } from "./perm.js";
|
|
20
21
|
/**
|
|
21
22
|
* Composition root for the fake wire surface: one route module per lane,
|
|
22
23
|
* mirroring src/tools.ts. Every lane is tried in turn; the first that does
|
|
@@ -35,6 +36,7 @@ const LANE_ROUTES = [
|
|
|
35
36
|
ruleLifecycleRoute,
|
|
36
37
|
runtimeDataRoute,
|
|
37
38
|
workflowRoute,
|
|
39
|
+
permRoute,
|
|
38
40
|
onlineJsRoute,
|
|
39
41
|
programmingRoute,
|
|
40
42
|
b2Route,
|
package/dist/state.d.ts
CHANGED
|
@@ -421,6 +421,18 @@ export interface FakeState {
|
|
|
421
421
|
unitType: string;
|
|
422
422
|
ouScope: Record<string, unknown>[];
|
|
423
423
|
}>;
|
|
424
|
+
/** r48a permission groups and their opaque platform auth scopes. */
|
|
425
|
+
permissionGroups: Map<string, {
|
|
426
|
+
id: string;
|
|
427
|
+
appCode: string;
|
|
428
|
+
name: string;
|
|
429
|
+
code: string;
|
|
430
|
+
internalUser: boolean;
|
|
431
|
+
externalUser: boolean;
|
|
432
|
+
remarks: string | null;
|
|
433
|
+
members: Record<string, unknown>[];
|
|
434
|
+
scopes: unknown[];
|
|
435
|
+
}>;
|
|
424
436
|
/** Organization departments/users (writes added 2026-10-22). */
|
|
425
437
|
orgDepartments: Map<string, {
|
|
426
438
|
id: string;
|
package/dist/state.js
CHANGED
|
@@ -72,6 +72,7 @@ export function createFakeState(options = {}) {
|
|
|
72
72
|
orgUsers: new Map(),
|
|
73
73
|
orgRoles: new Map(),
|
|
74
74
|
orgMembers: new Map(),
|
|
75
|
+
permissionGroups: new Map([["perm-1", { id: "perm-1", appCode: defaultAppCode, name: "默认权限组", code: "DEFAULT", internalUser: true, externalUser: false, remarks: null, members: [], scopes: [] }]]),
|
|
75
76
|
workflowInstances: new Map(),
|
|
76
77
|
workflowPermissions: new Map(),
|
|
77
78
|
enforceWorkflowStartPermission: false,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stalfh233/omc-fake-platform",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.28",
|
|
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.
|
|
21
|
+
"omc-core": "0.6.28"
|
|
22
22
|
},
|
|
23
23
|
"engines": {
|
|
24
24
|
"node": ">=22.13"
|