@yongdall/organization-rbac 0.6.6 → 0.7.0
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/index.d.mts +42 -56
- package/index.mjs +2 -3
- package/{organization-rbac-CVRP1FKi.mjs → organization-rbac--hDZMB8h.mjs} +4 -20
- package/{organization-rbac-CVRP1FKi.mjs.map → organization-rbac--hDZMB8h.mjs.map} +1 -1
- package/package.json +9 -9
- package/yongdall/migration.mjs +3 -5
- package/yongdall/migration.mjs.map +1 -1
- package/yongdall/model.mjs +3 -5
- package/yongdall/model.mjs.map +1 -1
- package/yongdall/user.mjs +2 -3
package/index.d.mts
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import * as imodel20 from "imodel";
|
|
2
|
-
import * as _yongdall_model3 from "@yongdall/model";
|
|
3
|
-
|
|
4
1
|
//#region plugins/organization-rbac/models/CompositeRole.d.mts
|
|
5
|
-
declare const CompositeRole:
|
|
6
|
-
id:
|
|
7
|
-
label:
|
|
8
|
-
organizationId:
|
|
9
|
-
description:
|
|
10
|
-
createdAt:
|
|
11
|
-
updatedAt:
|
|
2
|
+
export declare const CompositeRole: import("@yongdall/model").ModelTable<{
|
|
3
|
+
id: import("imodel").FieldDefine<"uuid", false, false>;
|
|
4
|
+
label: import("imodel").FieldDefine<"string", false, false>;
|
|
5
|
+
organizationId: import("imodel").FieldDefine<"uuid", false, true>;
|
|
6
|
+
description: import("imodel").FieldDefine<"text", false, true>;
|
|
7
|
+
createdAt: import("imodel").FieldDefine<"date", false, false>;
|
|
8
|
+
updatedAt: import("imodel").FieldDefine<"date", false, false>;
|
|
12
9
|
}, "compositeRole">;
|
|
13
10
|
//#endregion
|
|
14
11
|
//#region plugins/organization-rbac/models/OrganizationCompositeRole.d.mts
|
|
@@ -20,11 +17,11 @@ declare const CompositeRole: _yongdall_model3.ModelTable<{
|
|
|
20
17
|
* @property {string} roleId - 角色ID,主键第三部分
|
|
21
18
|
* @property {number} no - 编号
|
|
22
19
|
*/
|
|
23
|
-
declare const OrganizationCompositeRole:
|
|
24
|
-
compositeRoleId:
|
|
25
|
-
organizationId:
|
|
26
|
-
roleId:
|
|
27
|
-
createdAt:
|
|
20
|
+
export declare const OrganizationCompositeRole: import("@yongdall/model").ModelTable<{
|
|
21
|
+
compositeRoleId: import("imodel").FieldDefine<"uuid", false, false>;
|
|
22
|
+
organizationId: import("imodel").FieldDefine<"uuid", false, false>;
|
|
23
|
+
roleId: import("imodel").FieldDefine<"uuid", false, false>;
|
|
24
|
+
createdAt: import("imodel").FieldDefine<"date", false, false>;
|
|
28
25
|
}, "organizationCompositeRole">;
|
|
29
26
|
//#endregion
|
|
30
27
|
//#region plugins/organization-rbac/models/OrganizationUserCompositeRole.d.mts
|
|
@@ -36,60 +33,49 @@ declare const OrganizationCompositeRole: _yongdall_model3.ModelTable<{
|
|
|
36
33
|
* @property {string} roleId - 角色ID,主键第三部分
|
|
37
34
|
* @property {number} no - 编号
|
|
38
35
|
*/
|
|
39
|
-
declare const OrganizationUserCompositeRole:
|
|
40
|
-
userId:
|
|
41
|
-
organizationId:
|
|
42
|
-
compositeRoleId:
|
|
43
|
-
createdAt:
|
|
44
|
-
updatedAt:
|
|
36
|
+
export declare const OrganizationUserCompositeRole: import("@yongdall/model").ModelTable<{
|
|
37
|
+
userId: import("imodel").FieldDefine<"uuid", false, false>;
|
|
38
|
+
organizationId: import("imodel").FieldDefine<"uuid", false, false>;
|
|
39
|
+
compositeRoleId: import("imodel").FieldDefine<"uuid", false, false>;
|
|
40
|
+
createdAt: import("imodel").FieldDefine<"date", false, false>;
|
|
41
|
+
updatedAt: import("imodel").FieldDefine<"date", false, false>;
|
|
45
42
|
}, "organizationUserCompositeRole">;
|
|
46
43
|
//#endregion
|
|
47
44
|
//#region plugins/organization-rbac/models/OrganizationAppointment.d.mts
|
|
48
|
-
declare const OrganizationAppointment:
|
|
49
|
-
id:
|
|
50
|
-
label:
|
|
51
|
-
description:
|
|
52
|
-
createdAt:
|
|
53
|
-
updatedAt:
|
|
45
|
+
export declare const OrganizationAppointment: import("@yongdall/model").ModelTable<{
|
|
46
|
+
id: import("imodel").FieldDefine<"uuid", false, false>;
|
|
47
|
+
label: import("imodel").FieldDefine<"string", false, false>;
|
|
48
|
+
description: import("imodel").FieldDefine<"string", false, true>;
|
|
49
|
+
createdAt: import("imodel").FieldDefine<"date", false, false>;
|
|
50
|
+
updatedAt: import("imodel").FieldDefine<"date", false, false>;
|
|
54
51
|
}, "organizationAppointment">;
|
|
55
52
|
//#endregion
|
|
56
53
|
//#region plugins/organization-rbac/models/OrganizationMember.d.mts
|
|
57
|
-
declare const OrganizationMember:
|
|
58
|
-
id:
|
|
59
|
-
userId:
|
|
60
|
-
organizationId:
|
|
61
|
-
appointmentId:
|
|
62
|
-
default:
|
|
63
|
-
createdAt:
|
|
64
|
-
updatedAt:
|
|
54
|
+
export declare const OrganizationMember: import("@yongdall/model").ModelTable<{
|
|
55
|
+
id: import("imodel").FieldDefine<"uuid", false, false>;
|
|
56
|
+
userId: import("imodel").FieldDefine<"uuid", false, false>;
|
|
57
|
+
organizationId: import("imodel").FieldDefine<"uuid", false, false>;
|
|
58
|
+
appointmentId: import("imodel").FieldDefine<"uuid", false, true>;
|
|
59
|
+
default: import("imodel").FieldDefine<"bool", false, false>;
|
|
60
|
+
createdAt: import("imodel").FieldDefine<"date", false, false>;
|
|
61
|
+
updatedAt: import("imodel").FieldDefine<"date", false, false>;
|
|
65
62
|
}, "organizationMember">;
|
|
66
63
|
//#endregion
|
|
67
64
|
//#region plugins/organization-rbac/models/OrganizationUserRole.d.mts
|
|
68
|
-
declare const OrganizationUserRole:
|
|
69
|
-
userId:
|
|
70
|
-
organizationId:
|
|
71
|
-
roleId:
|
|
72
|
-
createdAt:
|
|
65
|
+
export declare const OrganizationUserRole: import("@yongdall/model").ModelTable<{
|
|
66
|
+
userId: import("imodel").FieldDefine<"uuid", false, false>;
|
|
67
|
+
organizationId: import("imodel").FieldDefine<"uuid", false, false>;
|
|
68
|
+
roleId: import("imodel").FieldDefine<"uuid", false, false>;
|
|
69
|
+
createdAt: import("imodel").FieldDefine<"date", false, false>;
|
|
73
70
|
}, "organizationUserRole">;
|
|
74
71
|
//#endregion
|
|
75
72
|
//#region plugins/organization-rbac/index.d.mts
|
|
76
73
|
/** 所在组织 */
|
|
77
|
-
declare const getOrganizations: (userId: string | null) => Promise<Set<unknown>>;
|
|
74
|
+
export declare const getOrganizations: (userId: string | null) => Promise<Set<unknown>>;
|
|
78
75
|
/** 角色 */
|
|
79
|
-
declare const getOrganizationRoleIds: (userId: string | null) => Promise<{
|
|
76
|
+
export declare const getOrganizationRoleIds: (userId: string | null) => Promise<{
|
|
80
77
|
[k: string]: Set<string>;
|
|
81
78
|
}>;
|
|
82
|
-
declare const getOrganizationPermissions: (userId: string | null) => Promise<Record<string, Set<string>>>;
|
|
83
|
-
declare const getOrganizationAllPermissions: (userId: string | null) => Promise<Set<string>>;
|
|
84
|
-
|
|
85
|
-
declare const useOrganizations: () => Promise<Set<unknown>>;
|
|
86
|
-
/** @deprecated */
|
|
87
|
-
declare const useOrganizationRoleIds: () => Promise<{
|
|
88
|
-
[k: string]: Set<string>;
|
|
89
|
-
}>;
|
|
90
|
-
/** @deprecated */
|
|
91
|
-
declare const useOrganizationPermissions: () => Promise<Record<string, Set<string>>>;
|
|
92
|
-
/** @deprecated */
|
|
93
|
-
declare const useOrganizationAllPermissions: () => Promise<Set<string>>;
|
|
94
|
-
//#endregion
|
|
95
|
-
export { CompositeRole, OrganizationAppointment, OrganizationCompositeRole, OrganizationMember, OrganizationUserCompositeRole, OrganizationUserRole, getOrganizationAllPermissions, getOrganizationPermissions, getOrganizationRoleIds, getOrganizations, useOrganizationAllPermissions, useOrganizationPermissions, useOrganizationRoleIds, useOrganizations };
|
|
79
|
+
export declare const getOrganizationPermissions: (userId: string | null) => Promise<Record<string, Set<string>>>;
|
|
80
|
+
export declare const getOrganizationAllPermissions: (userId: string | null) => Promise<Set<string>>;
|
|
81
|
+
//#endregion
|
package/index.mjs
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
|
|
3
|
-
export { CompositeRole, OrganizationAppointment, OrganizationCompositeRole, OrganizationMember, OrganizationUserCompositeRole, OrganizationUserRole, getOrganizationAllPermissions, getOrganizationPermissions, getOrganizationRoleIds, getOrganizations, useOrganizationAllPermissions, useOrganizationPermissions, useOrganizationRoleIds, useOrganizations };
|
|
1
|
+
import { a as OrganizationUserRole, c as CompositeRole, i as getOrganizations, l as OrganizationUserCompositeRole, n as getOrganizationPermissions, o as OrganizationMember, r as getOrganizationRoleIds, s as OrganizationAppointment, t as getOrganizationAllPermissions, u as OrganizationCompositeRole } from "./organization-rbac--hDZMB8h.mjs";
|
|
2
|
+
export { CompositeRole, OrganizationAppointment, OrganizationCompositeRole, OrganizationMember, OrganizationUserCompositeRole, OrganizationUserRole, getOrganizationAllPermissions, getOrganizationPermissions, getOrganizationRoleIds, getOrganizations };
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { createKeyStore } from "@yongdall/context";
|
|
2
2
|
import { Action, Query, Where, actions, createField, createModel, now, uuid } from "@yongdall/model";
|
|
3
|
-
import { ServerError, getModel
|
|
3
|
+
import { ServerError, getModel } from "@yongdall/core";
|
|
4
4
|
import { useDatabase } from "@yongdall/connection";
|
|
5
5
|
import { findRolePermissions } from "@yongdall/role-permission";
|
|
6
6
|
import PluginMeta from "@yongdall/plugin-meta";
|
|
7
|
-
|
|
8
7
|
//#region plugins/organization-rbac/constants.mts
|
|
9
8
|
const { id: pluginId, database } = PluginMeta();
|
|
10
|
-
|
|
11
9
|
//#endregion
|
|
12
10
|
//#region plugins/organization-rbac/models/OrganizationCompositeRole.mts
|
|
13
11
|
/**
|
|
@@ -102,7 +100,6 @@ const OrganizationCompositeRole = createModel("organizationCompositeRole", {
|
|
|
102
100
|
}
|
|
103
101
|
} }
|
|
104
102
|
});
|
|
105
|
-
|
|
106
103
|
//#endregion
|
|
107
104
|
//#region plugins/organization-rbac/models/OrganizationUserCompositeRole.mts
|
|
108
105
|
/**
|
|
@@ -185,7 +182,6 @@ const OrganizationUserCompositeRole = createModel("organizationUserCompositeRole
|
|
|
185
182
|
throw new ServerError("复合角色与组织不匹配");
|
|
186
183
|
} }
|
|
187
184
|
});
|
|
188
|
-
|
|
189
185
|
//#endregion
|
|
190
186
|
//#region plugins/organization-rbac/models/CompositeRole.mts
|
|
191
187
|
const CompositeRole = createModel("compositeRole", {
|
|
@@ -279,7 +275,6 @@ const CompositeRole = createModel("compositeRole", {
|
|
|
279
275
|
}
|
|
280
276
|
}
|
|
281
277
|
});
|
|
282
|
-
|
|
283
278
|
//#endregion
|
|
284
279
|
//#region plugins/organization-rbac/models/OrganizationAppointment.mts
|
|
285
280
|
const OrganizationAppointment = createModel("organizationAppointment", {
|
|
@@ -326,7 +321,6 @@ const OrganizationAppointment = createModel("organizationAppointment", {
|
|
|
326
321
|
]
|
|
327
322
|
}]
|
|
328
323
|
});
|
|
329
|
-
|
|
330
324
|
//#endregion
|
|
331
325
|
//#region plugins/organization-rbac/models/OrganizationMember.mts
|
|
332
326
|
const OrganizationMember = createModel("organizationMember", {
|
|
@@ -416,7 +410,6 @@ const OrganizationMember = createModel("organizationMember", {
|
|
|
416
410
|
}
|
|
417
411
|
}
|
|
418
412
|
});
|
|
419
|
-
|
|
420
413
|
//#endregion
|
|
421
414
|
//#region plugins/organization-rbac/models/OrganizationUserRole.mts
|
|
422
415
|
const OrganizationUserRole = createModel("organizationUserRole", {
|
|
@@ -466,7 +459,6 @@ const OrganizationUserRole = createModel("organizationUserRole", {
|
|
|
466
459
|
]
|
|
467
460
|
}]
|
|
468
461
|
});
|
|
469
|
-
|
|
470
462
|
//#endregion
|
|
471
463
|
//#region plugins/organization-rbac/index.mts
|
|
472
464
|
/** 所在组织 */
|
|
@@ -499,15 +491,7 @@ const getOrganizationAllPermissions = createKeyStore(async (userId) => {
|
|
|
499
491
|
const v = await getOrganizationPermissions(userId);
|
|
500
492
|
return new Set(Object.values(v).flatMap((v) => [...v]));
|
|
501
493
|
}, (user) => user || "");
|
|
502
|
-
/** @deprecated */
|
|
503
|
-
const useOrganizations = () => getUser().then(getOrganizations);
|
|
504
|
-
/** @deprecated */
|
|
505
|
-
const useOrganizationRoleIds = () => getUser().then(getOrganizationRoleIds);
|
|
506
|
-
/** @deprecated */
|
|
507
|
-
const useOrganizationPermissions = () => getUser().then(getOrganizationPermissions);
|
|
508
|
-
/** @deprecated */
|
|
509
|
-
const useOrganizationAllPermissions = () => getUser().then(getOrganizationAllPermissions);
|
|
510
|
-
|
|
511
494
|
//#endregion
|
|
512
|
-
export {
|
|
513
|
-
|
|
495
|
+
export { OrganizationUserRole as a, CompositeRole as c, getOrganizations as i, OrganizationUserCompositeRole as l, getOrganizationPermissions as n, OrganizationMember as o, getOrganizationRoleIds as r, OrganizationAppointment as s, getOrganizationAllPermissions as t, OrganizationCompositeRole as u };
|
|
496
|
+
|
|
497
|
+
//# sourceMappingURL=organization-rbac--hDZMB8h.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"organization-rbac-CVRP1FKi.mjs","names":[],"sources":["../../plugins/organization-rbac/constants.mts","../../plugins/organization-rbac/models/OrganizationCompositeRole.mts","../../plugins/organization-rbac/models/OrganizationUserCompositeRole.mts","../../plugins/organization-rbac/models/CompositeRole.mts","../../plugins/organization-rbac/models/OrganizationAppointment.mts","../../plugins/organization-rbac/models/OrganizationMember.mts","../../plugins/organization-rbac/models/OrganizationUserRole.mts","../../plugins/organization-rbac/index.mts"],"sourcesContent":["import PluginMeta from '@yongdall/plugin-meta';\nexport const {\n\tid: pluginId,\n\tdatabase: database,\n} = PluginMeta();\n","import { actions, createField, createModel, now, Query, uuid, Where } from '@yongdall/model';\nimport { database } from '../constants.mts';\nimport { CompositeRole } from './CompositeRole.mts';\nimport { getModel, ServerError } from '@yongdall/core';\nimport { useDatabase } from '@yongdall/connection';\n\n/**\n * 组织用户角色模型\n * @typedef {Object} OrganizationUserRole\n * @property {string} userId - 用户ID,主键第一部分\n * @property {string} organizationId - 组织ID,主键第二部分\n * @property {string} roleId - 角色ID,主键第三部分\n * @property {number} no - 编号\n */\nexport const OrganizationCompositeRole = createModel('organizationCompositeRole', {\n\tcompositeRoleId: createField('uuid', { nullable: false, index: true, label: '复合角色', model: 'compositeRole', renderer: 'document', immutable: true, primary: 1 }),\n\torganizationId: createField('uuid', { nullable: false, index: true, label: '组织', model: 'organization', renderer: 'document', immutable: true, primary: 2 }),\n\troleId: createField('uuid', { nullable: false, index: true, label: '角色', model: 'role', renderer: 'document', immutable: true, primary: 3 }),\n\n\tcreatedAt: createField('date', { nullable: false, default: now, creating: now, label: '创建日期' }),\n}, {\n\n\tpermissions: [\n\t\t{ permission: 'system:compositeRole', fields: ['*'], authorizations: ['options', 'query', 'read', 'create', 'destroy'] },\n\t\t{ permission: 'system:compositeRole', organizationField: 'organizationId', fields: ['*'], authorizations: ['options', 'query', 'read', 'create', 'update', 'destroy'] },\n\t],\n\tdatabase,\n\tlabel: '组织复合角色配置',\n\thooks: {\n\t\tasync afterCreate(conn, model, record) {\n\t\t\tif (!record.organizationId) { throw new ServerError('组织不存在') }\n\t\t\tif (!record.roleId) { throw new ServerError('角色不存在') }\n\t\t\tconst [compositeRole] = await conn.call(\n\t\t\t\tnew Query(CompositeRole).where({ id: record.compositeRoleId }).limit(1)\n\t\t\t)\n\t\t\tif (!compositeRole) {\n\t\t\t\tthrow new Error('复合角色不存在')\n\t\t\t}\n\t\t\tif (!compositeRole.organizationId) { return }\n\t\t\tconst organizationModel = await getModel('organization')\n\t\t\tif (organizationModel) {\n\t\t\t\tconst [organization] = await useDatabase(organizationModel.databaseId).call(\n\t\t\t\t\tnew Query(organizationModel).where({ id: record.organizationId, mainId: compositeRole.organizationId }).limit(1)\n\t\t\t\t)\n\t\t\t\tif (!organization) {\n\t\t\t\t\tthrow new ServerError('请选择关联组织');\n\t\t\t\t}\n\n\t\t\t}\n\t\t\tconst roleModel = await getModel('role')\n\t\t\tif (roleModel?.fields.open) {\n\t\t\t\tconst [role] = await useDatabase(roleModel.databaseId).call(\n\t\t\t\t\tnew Query(roleModel).where({ id: record.organizationId, open: true }).limit(1)\n\t\t\t\t)\n\t\t\t\tif (!role) {\n\t\t\t\t\tthrow new ServerError('请选择有效角色');\n\t\t\t\t}\n\n\t\t\t}\n\t\t},\n\t}\n});\n","import { actions, createField, createModel, now, Query, uuid, Where} from '@yongdall/model';\nimport { database } from '../constants.mts';\nimport { CompositeRole } from './CompositeRole.mts';\nimport { ServerError } from '@yongdall/core';\n\n/**\n * 组织用户角色模型\n * @typedef {Object} OrganizationUserRole\n * @property {string} userId - 用户ID,主键第一部分\n * @property {string} organizationId - 组织ID,主键第二部分\n * @property {string} roleId - 角色ID,主键第三部分\n * @property {number} no - 编号\n */\nexport const OrganizationUserCompositeRole = createModel('organizationUserCompositeRole', {\n\tuserId: createField('uuid', { nullable: false, index: true, label: '用户', model: 'user', renderer: 'document', immutable: true, primary: 1 }),\n\torganizationId: createField('uuid', { nullable: false, index: true, label: '组织', model: 'organization', renderer: 'document', immutable: true }),\n\tcompositeRoleId: createField('uuid', { nullable: false, index: true, label: '角色', model: 'compositeRole', renderer: 'document', immutable: true, primary: 2 }),\n\n\tcreatedAt: createField('date', { nullable: false, default: now, creating: now, label: '创建日期' }),\n\tupdatedAt: createField('date', { nullable: false, default: now, updating: now, label: '最后更新日期' }),\n},{\n\tdatabase,\n\tlabel: '用户复合角色',\n\n\tpermissions: [\n\t\t{ permission: 'system:compositeRole', fields: ['*'], authorizations: ['options', 'query', 'read', 'create', 'destroy'] },\n\t\t{ permission: 'system:compositeRole', organizationField: 'organizationId', fields: ['*'], authorizations: ['options', 'query', 'read', 'create', 'update', 'destroy'] },\n\t],\n\thooks: {\n\t\tasync afterCreate(conn, model, record) {\n\t\t\tconst [compositeRole] = await conn.call(\n\t\t\t\tnew Query(CompositeRole).where({ id: record.compositeRoleId }).limit(1)\n\t\t\t)\n\t\t\tif (!compositeRole) {\n\t\t\t\tthrow new ServerError('复合角色不存在')\n\t\t\t}\n\t\t\tif ((compositeRole.organizationId || null) === (record.organizationId || null)) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthrow new ServerError('复合角色与组织不匹配');\n\t\t},\n\t}\n});\n","import { Action, actions, createField, createModel, now, Query, uuid, Where } from '@yongdall/model';\nimport { database } from '../constants.mts';\nimport { getModel, ServerError } from '@yongdall/core';\nimport { useDatabase } from '@yongdall/connection';\nimport { OrganizationCompositeRole } from './OrganizationCompositeRole.mts';\nimport { OrganizationUserCompositeRole } from './OrganizationUserCompositeRole.mts';\n\n\nexport const CompositeRole = createModel('compositeRole', {\n\tid: createField('uuid', { nullable: false, default: uuid, primary: 1, uncreatable: true, layout: { hidden: true } }),\n\tlabel: createField('string', { size: 255, nullable: false, default: '', label: '名称', layout: { colSpan: 6 } }),\n\torganizationId: createField('uuid', { nullable: true, index: true, label: '组织', model: 'organization', renderer: 'document', immutable: true, source: { search: 'internal=0' } }),\n\tdescription: createField('text', { nullable: true, label: '描述' }),\n\n\tcreatedAt: createField('date', { nullable: false, default: now, creating: now, label: '创建日期' }),\n\tupdatedAt: createField('date', { nullable: false, default: now, updating: now, label: '最后更新日期' }),\n}, {\n\tdatabase,\n\tlabelField: 'label',\n\tlabel: '复合角色',\n\n\tpermissions: [\n\t\t{ permission: 'system:compositeRole', fields: ['*'], authorizations: ['options', 'query', 'read', 'create', 'update', 'destroy', 'add', 'remove'] },\n\t\t{ permission: 'system:compositeRole', organizationField: 'organizationId', fields: ['*'], authorizations: ['options', 'query', 'read', 'create', 'update', 'destroy', 'add', 'remove'] },\n\t],\n\thooks: {\n\t\tasync afterCreate(conn, model, { organizationId }) {\n\t\t\tif (!organizationId) { return; }\n\t\t\tconst organizationModel = await getModel('organization')\n\t\t\tif (!organizationModel) { return; }\n\t\t\tconst [organization] = await useDatabase(organizationModel.databaseId).call(\n\t\t\t\tnew Query(organizationModel).where({ id: organizationId, internal: false }).limit(1)\n\t\t\t)\n\t\t\tif (organization) { return; }\n\t\t\tthrow new ServerError('请选择外部组织');\n\t\t},\n\t\tasync afterDelete(conn, model, record, update) {\n\t\t\tconst list = [\n\t\t\t\tconn.call(Action.delete(OrganizationUserCompositeRole, Where.and({ compositeRoleId: record.id })))\n\t\t\t]\n\n\t\t\tif (!update) {\n\t\t\t\tlist.push(\n\t\t\t\t\tconn.call(Action.delete(OrganizationCompositeRole, Where.and({ compositeRoleId: record.id })))\n\t\t\t\t)\n\t\t\t}\n\t\t\tawait Promise.all(list)\n\t\t},\n\t}\n});\n","import { createField, createModel, now, uuid } from '@yongdall/model';\nimport { database } from '../constants.mts';\n\n\n\n// export const OrganizationAppointmentRole = createModel('organizationAppointmentRole', {\n// \tappointmentId: createField('uuid', { nullable: false, index: true, label: '职务', model: 'appointment', renderer: 'document', immutable: true, primary: 1 }),\n// \troleId: createField('uuid', { nullable: false, index: true, label: '角色', model: 'role', renderer: 'document', immutable: true, primary: 2 }),\n// \tno: createField('i32', { nullable: false, default: 0 }),\n// });\n\nexport const OrganizationAppointment = createModel('organizationAppointment', {\n\tid: createField('uuid', { nullable: false, primary: 1, default: uuid, uncreatable: true, immutable: true }),\n\n\tlabel: createField('string', { nullable: false, label: '职务名称' }),\n\tdescription: createField('string', { nullable: true, label: '描述' }),\n\n\tcreatedAt: createField('date', { nullable: false, default: now, creating: now, label: '创建日期' }),\n\tupdatedAt: createField('date', { nullable: false, default: now, updating: now, label: '最后更新日期' }),\n\n\t// roles: createField(OrganizationAppointmentRole, { \n\t// \tarray: true, \n\t// \tconstraints: { appointmentId: { field: 'id' }, no: { noField: true } }, \n\t// \tlabel: '角色列表' \n\t// }),\n}, {\n\tdatabase,\n\n\tpermissions: [\n\t\t{ permission: 'system:organization', fields: '*', authorizations: ['query', 'read', 'create', 'update', 'destroy', 'add', 'remove'] },\n\t],\n});\n","import { actions, createField, createModel, now, uuid, Where} from '@yongdall/model';\nimport { database } from '../constants.mts';\n\n\nexport const OrganizationMember = createModel('organizationMember', {\n\tid: createField('uuid', { nullable: false, index: true, primary: 1, default: uuid, uncreatable: true, immutable: true }),\n\n\tuserId: createField('uuid', { nullable: false, index: true, label: '用户', model: 'user', renderer: 'document', immutable: true, layout: { rowSpan: 6 } }),\n\torganizationId: createField('uuid', { nullable: false, index: true, label: '组织', model: 'organization', renderer: 'document', immutable: true, layout: { rowSpan: 6 } }),\n\tappointmentId: createField('uuid', { nullable: true, index: true, label: '职务', model: 'appointment', renderer: 'document', layout: { rowSpan: 6 } }),\n\n\tdefault: createField('bool', { nullable: false, default: false, label: '默认职务' }),\n\n\tcreatedAt: createField('date', { nullable: false, default: now, creating: now, label: '创建日期' }),\n\tupdatedAt: createField('date', { nullable: false, default: now, updating: now, label: '最后更新日期' }),\n\n}, {\n\tdatabase,\n\tindexes: [\n\t\t{ fields: ['userId', 'organizationId', 'appointmentId'], unique: true }\n\t],\n\tpermissions: [\n\t\t{ permission: 'system:user', fields: '*', authorizations: ['query', 'read', 'create', 'update', 'destroy', 'add', 'remove'] },\n\t],\n\thooks: {\n\t\tasync afterCreate(conn, Model, record) {\n\t\t\tif (!record.default) { return }\n\t\t\tawait conn.call(actions.update(\n\t\t\t\tModel,\n\t\t\t\t{ default: false },\n\t\t\t\tWhere.and('organizationId', '=', record.organizationId, true)\n\t\t\t\t\t.and('userId', record.userId),\n\t\t\t));\n\t\t},\n\n\t\tasync afterUpdate(conn, Model, record, oldRecord) {\n\t\t\tif (!record.default) { return }\n\t\t\tif (oldRecord.default) { return }\n\t\t\tawait conn.call(actions.update(\n\t\t\t\tModel,\n\t\t\t\t{ default: false },\n\t\t\t\tWhere.and('organizationId', '=', record.organizationId, true)\n\t\t\t\t\t.and('userId', record.userId),\n\t\t\t));\n\t\t},\n\t}\n});\n","import { actions, createField, createModel, now, uuid, Where} from '@yongdall/model';\nimport { database } from '../constants.mts';\n\nexport const OrganizationUserRole = createModel('organizationUserRole', {\n\tuserId: createField('uuid', { nullable: false, index: true, label: '用户', model: 'user', renderer: 'document', immutable: true, primary: 1 }),\n\torganizationId: createField('uuid', { nullable: false, index: true, label: '组织', model: 'organization', renderer: 'document', immutable: true, primary: 2 }),\n\troleId: createField('uuid', { nullable: false, index: true, label: '角色', model: 'role', renderer: 'document', immutable: true, primary: 3 }),\n\n\n\tcreatedAt: createField('date', { nullable: false, default: now, creating: now, label: '创建日期' }),\n\n},{\n\tdatabase,\n\tpermissions: [\n\t\t{ permission: 'system:user', fields: '*', authorizations: ['query', 'read', 'create', 'destroy'] },\n\t],\n});\n","import { createKeyStore } from '@yongdall/context';\nimport { Query } from '@yongdall/model';\nimport { getUser } from '@yongdall/core';\nimport { useDatabase } from '@yongdall/connection';\nimport { findRolePermissions } from '@yongdall/role-permission';\nimport { OrganizationCompositeRole, OrganizationMember, OrganizationUserCompositeRole, OrganizationUserRole } from './models/index.mts';\n\nexport * from './models/index.mts';\n\n\n/** 所在组织 */\nexport const getOrganizations = createKeyStore(async (userId: string | null) => {\n\tif (!userId) { return new Set(); }\n\tconst relations: { organizationId: string }[] = await useDatabase(OrganizationMember.databaseId).call(\n\t\tnew Query(OrganizationMember).select(['organizationId']).where('userId', userId)\n\t);\n\treturn new Set(relations.map(v => v.organizationId));\n}, user => user || '');\n\n\n/** 角色 */\nexport const getOrganizationRoleIds = createKeyStore(async (userId: string | null) => {\n\tconst compositeRoleIds = new Query(OrganizationUserCompositeRole).select('compositeRoleId').where('userId', '=', userId)\n\tconst list: { organizationId: number; roleId: string; }[][] = await Promise.all([\n\t\tuseDatabase(OrganizationUserRole.databaseId).call(\n\t\t\tnew Query(OrganizationUserRole).select(['organizationId', 'roleId'])\n\t\t\t\t.where('userId', userId)\n\t\t),\n\t\tuseDatabase(OrganizationCompositeRole.databaseId).call(\n\t\t\tnew Query(OrganizationCompositeRole).select(['organizationId', 'roleId'])\n\t\t\t\t.where('compositeRoleId', 'in', compositeRoleIds)\n\t\t)\n\t]);\n\n\treturn Object.fromEntries((Object.entries(Object.groupBy(list.flat(), v => v.organizationId))\n\t\t.map(([organizationId, list]) => [organizationId, new Set(list?.map(v => v.roleId))])))\n}, user => user || '');\n\n\nexport const getOrganizationPermissions = createKeyStore(async (userId: string | null) => {\n\tconst roleIds = await getOrganizationRoleIds(userId)\n\tconst allRoleIds = [...new Set(Object.values(roleIds).flatMap(v => [...v]))];\n\tconst permissions: Record<string, Set<string>> = Object.create(null);\n\tif (!allRoleIds.length) { return permissions; }\n\tconst values = await findRolePermissions(allRoleIds);\n\tconst list = Object.fromEntries(Object.entries(Object.groupBy(values, l => l.roleId)).map(([k, v]) => [k, v?.map(v => v.permission)]));\n\tfor (const [organization, roleSet] of Object.entries(roleIds)) {\n\t\tconst s = new Set([...roleSet].flatMap(v => list[v] || []));\n\t\tif (!s.size) { continue; }\n\t\tpermissions[organization] = s;\n\t}\n\treturn permissions;\n}, user => user || '');\n\n\n\nexport const getOrganizationAllPermissions = createKeyStore(async (userId: string | null) => {\n\tconst v = await getOrganizationPermissions(userId)\n\treturn new Set(Object.values(v).flatMap(v => [...v]));\n}, user => user || '');\n\n/** @deprecated */\nexport const useOrganizations = () => getUser().then(getOrganizations);\n/** @deprecated */\nexport const useOrganizationRoleIds = () => getUser().then(getOrganizationRoleIds);\n/** @deprecated */\nexport const useOrganizationPermissions = () => getUser().then(getOrganizationPermissions);\n/** @deprecated */\nexport const useOrganizationAllPermissions = () => getUser().then(getOrganizationAllPermissions);\n"],"mappings":";;;;;;;;AACA,MAAa,EACZ,IAAI,UACM,aACP,YAAY;;;;;;;;;;;;ACUhB,MAAa,4BAA4B,YAAY,6BAA6B;CACjF,iBAAiB,YAAY,QAAQ;EAAE,UAAU;EAAO,OAAO;EAAM,OAAO;EAAQ,OAAO;EAAiB,UAAU;EAAY,WAAW;EAAM,SAAS;EAAG,CAAC;CAChK,gBAAgB,YAAY,QAAQ;EAAE,UAAU;EAAO,OAAO;EAAM,OAAO;EAAM,OAAO;EAAgB,UAAU;EAAY,WAAW;EA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,MAAM,IAAI,IAAI,IAAI,CAAC,GAAG,QAAQ,CAAC,SAAQ,MAAK,KAAK,MAAM,EAAE,CAAC,CAAC;AAC3D,MAAI,CAAC,EAAE,KAAQ;AACf,cAAY,gBAAgB;;AAE7B,QAAO;IACL,SAAQ,QAAQ,GAAG;AAItB,MAAa,gCAAgC,eAAe,OAAO,WAA0B;CAC5F,MAAM,IAAI,MAAM,2BAA2B,OAAO;AAClD,QAAO,IAAI,IAAI,OAAO,OAAO,EAAE,CAAC,SAAQ,MAAK,CAAC,GAAG,EAAE,CAAC,CAAC;IACnD,SAAQ,QAAQ,GAAG;;AAGtB,MAAa,yBAAyB,SAAS,CAAC,KAAK,iBAAiB;;AAEtE,MAAa,+BAA+B,SAAS,CAAC,KAAK,uBAAuB;;AAElF,MAAa,mCAAmC,SAAS,CAAC,KAAK,2BAA2B;;AAE1F,MAAa,sCAAsC,SAAS,CAAC,KAAK,8BAA8B"}
|
|
1
|
+
{"version":3,"file":"organization-rbac--hDZMB8h.mjs","names":[],"sources":["../../plugins/organization-rbac/constants.mts","../../plugins/organization-rbac/models/OrganizationCompositeRole.mts","../../plugins/organization-rbac/models/OrganizationUserCompositeRole.mts","../../plugins/organization-rbac/models/CompositeRole.mts","../../plugins/organization-rbac/models/OrganizationAppointment.mts","../../plugins/organization-rbac/models/OrganizationMember.mts","../../plugins/organization-rbac/models/OrganizationUserRole.mts","../../plugins/organization-rbac/index.mts"],"sourcesContent":["import PluginMeta from '@yongdall/plugin-meta';\nexport const {\n\tid: pluginId,\n\tdatabase: database,\n} = PluginMeta();\n","import { actions, createField, createModel, now, Query, uuid, Where } from '@yongdall/model';\nimport { database } from '../constants.mts';\nimport { CompositeRole } from './CompositeRole.mts';\nimport { getModel, ServerError } from '@yongdall/core';\nimport { useDatabase } from '@yongdall/connection';\n\n/**\n * 组织用户角色模型\n * @typedef {Object} OrganizationUserRole\n * @property {string} userId - 用户ID,主键第一部分\n * @property {string} organizationId - 组织ID,主键第二部分\n * @property {string} roleId - 角色ID,主键第三部分\n * @property {number} no - 编号\n */\nexport const OrganizationCompositeRole = createModel('organizationCompositeRole', {\n\tcompositeRoleId: createField('uuid', { nullable: false, index: true, label: '复合角色', model: 'compositeRole', renderer: 'document', immutable: true, primary: 1 }),\n\torganizationId: createField('uuid', { nullable: false, index: true, label: '组织', model: 'organization', renderer: 'document', immutable: true, primary: 2 }),\n\troleId: createField('uuid', { nullable: false, index: true, label: '角色', model: 'role', renderer: 'document', immutable: true, primary: 3 }),\n\n\tcreatedAt: createField('date', { nullable: false, default: now, creating: now, label: '创建日期' }),\n}, {\n\n\tpermissions: [\n\t\t{ permission: 'system:compositeRole', fields: ['*'], authorizations: ['options', 'query', 'read', 'create', 'destroy'] },\n\t\t{ permission: 'system:compositeRole', organizationField: 'organizationId', fields: ['*'], authorizations: ['options', 'query', 'read', 'create', 'update', 'destroy'] },\n\t],\n\tdatabase,\n\tlabel: '组织复合角色配置',\n\thooks: {\n\t\tasync afterCreate(conn, model, record) {\n\t\t\tif (!record.organizationId) { throw new ServerError('组织不存在') }\n\t\t\tif (!record.roleId) { throw new ServerError('角色不存在') }\n\t\t\tconst [compositeRole] = await conn.call(\n\t\t\t\tnew Query(CompositeRole).where({ id: record.compositeRoleId }).limit(1)\n\t\t\t)\n\t\t\tif (!compositeRole) {\n\t\t\t\tthrow new Error('复合角色不存在')\n\t\t\t}\n\t\t\tif (!compositeRole.organizationId) { return }\n\t\t\tconst organizationModel = await getModel('organization')\n\t\t\tif (organizationModel) {\n\t\t\t\tconst [organization] = await useDatabase(organizationModel.databaseId).call(\n\t\t\t\t\tnew Query(organizationModel).where({ id: record.organizationId, mainId: compositeRole.organizationId }).limit(1)\n\t\t\t\t)\n\t\t\t\tif (!organization) {\n\t\t\t\t\tthrow new ServerError('请选择关联组织');\n\t\t\t\t}\n\n\t\t\t}\n\t\t\tconst roleModel = await getModel('role')\n\t\t\tif (roleModel?.fields.open) {\n\t\t\t\tconst [role] = await useDatabase(roleModel.databaseId).call(\n\t\t\t\t\tnew Query(roleModel).where({ id: record.organizationId, open: true }).limit(1)\n\t\t\t\t)\n\t\t\t\tif (!role) {\n\t\t\t\t\tthrow new ServerError('请选择有效角色');\n\t\t\t\t}\n\n\t\t\t}\n\t\t},\n\t}\n});\n","import { actions, createField, createModel, now, Query, uuid, Where} from '@yongdall/model';\nimport { database } from '../constants.mts';\nimport { CompositeRole } from './CompositeRole.mts';\nimport { ServerError } from '@yongdall/core';\n\n/**\n * 组织用户角色模型\n * @typedef {Object} OrganizationUserRole\n * @property {string} userId - 用户ID,主键第一部分\n * @property {string} organizationId - 组织ID,主键第二部分\n * @property {string} roleId - 角色ID,主键第三部分\n * @property {number} no - 编号\n */\nexport const OrganizationUserCompositeRole = createModel('organizationUserCompositeRole', {\n\tuserId: createField('uuid', { nullable: false, index: true, label: '用户', model: 'user', renderer: 'document', immutable: true, primary: 1 }),\n\torganizationId: createField('uuid', { nullable: false, index: true, label: '组织', model: 'organization', renderer: 'document', immutable: true }),\n\tcompositeRoleId: createField('uuid', { nullable: false, index: true, label: '角色', model: 'compositeRole', renderer: 'document', immutable: true, primary: 2 }),\n\n\tcreatedAt: createField('date', { nullable: false, default: now, creating: now, label: '创建日期' }),\n\tupdatedAt: createField('date', { nullable: false, default: now, updating: now, label: '最后更新日期' }),\n},{\n\tdatabase,\n\tlabel: '用户复合角色',\n\n\tpermissions: [\n\t\t{ permission: 'system:compositeRole', fields: ['*'], authorizations: ['options', 'query', 'read', 'create', 'destroy'] },\n\t\t{ permission: 'system:compositeRole', organizationField: 'organizationId', fields: ['*'], authorizations: ['options', 'query', 'read', 'create', 'update', 'destroy'] },\n\t],\n\thooks: {\n\t\tasync afterCreate(conn, model, record) {\n\t\t\tconst [compositeRole] = await conn.call(\n\t\t\t\tnew Query(CompositeRole).where({ id: record.compositeRoleId }).limit(1)\n\t\t\t)\n\t\t\tif (!compositeRole) {\n\t\t\t\tthrow new ServerError('复合角色不存在')\n\t\t\t}\n\t\t\tif ((compositeRole.organizationId || null) === (record.organizationId || null)) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthrow new ServerError('复合角色与组织不匹配');\n\t\t},\n\t}\n});\n","import { Action, actions, createField, createModel, now, Query, uuid, Where } from '@yongdall/model';\nimport { database } from '../constants.mts';\nimport { getModel, ServerError } from '@yongdall/core';\nimport { useDatabase } from '@yongdall/connection';\nimport { OrganizationCompositeRole } from './OrganizationCompositeRole.mts';\nimport { OrganizationUserCompositeRole } from './OrganizationUserCompositeRole.mts';\n\n\nexport const CompositeRole = createModel('compositeRole', {\n\tid: createField('uuid', { nullable: false, default: uuid, primary: 1, uncreatable: true, layout: { hidden: true } }),\n\tlabel: createField('string', { size: 255, nullable: false, default: '', label: '名称', layout: { colSpan: 6 } }),\n\torganizationId: createField('uuid', { nullable: true, index: true, label: '组织', model: 'organization', renderer: 'document', immutable: true, source: { search: 'internal=0' } }),\n\tdescription: createField('text', { nullable: true, label: '描述' }),\n\n\tcreatedAt: createField('date', { nullable: false, default: now, creating: now, label: '创建日期' }),\n\tupdatedAt: createField('date', { nullable: false, default: now, updating: now, label: '最后更新日期' }),\n}, {\n\tdatabase,\n\tlabelField: 'label',\n\tlabel: '复合角色',\n\n\tpermissions: [\n\t\t{ permission: 'system:compositeRole', fields: ['*'], authorizations: ['options', 'query', 'read', 'create', 'update', 'destroy', 'add', 'remove'] },\n\t\t{ permission: 'system:compositeRole', organizationField: 'organizationId', fields: ['*'], authorizations: ['options', 'query', 'read', 'create', 'update', 'destroy', 'add', 'remove'] },\n\t],\n\thooks: {\n\t\tasync afterCreate(conn, model, { organizationId }) {\n\t\t\tif (!organizationId) { return; }\n\t\t\tconst organizationModel = await getModel('organization')\n\t\t\tif (!organizationModel) { return; }\n\t\t\tconst [organization] = await useDatabase(organizationModel.databaseId).call(\n\t\t\t\tnew Query(organizationModel).where({ id: organizationId, internal: false }).limit(1)\n\t\t\t)\n\t\t\tif (organization) { return; }\n\t\t\tthrow new ServerError('请选择外部组织');\n\t\t},\n\t\tasync afterDelete(conn, model, record, update) {\n\t\t\tconst list = [\n\t\t\t\tconn.call(Action.delete(OrganizationUserCompositeRole, Where.and({ compositeRoleId: record.id })))\n\t\t\t]\n\n\t\t\tif (!update) {\n\t\t\t\tlist.push(\n\t\t\t\t\tconn.call(Action.delete(OrganizationCompositeRole, Where.and({ compositeRoleId: record.id })))\n\t\t\t\t)\n\t\t\t}\n\t\t\tawait Promise.all(list)\n\t\t},\n\t}\n});\n","import { createField, createModel, now, uuid } from '@yongdall/model';\nimport { database } from '../constants.mts';\n\n\n\n// export const OrganizationAppointmentRole = createModel('organizationAppointmentRole', {\n// \tappointmentId: createField('uuid', { nullable: false, index: true, label: '职务', model: 'appointment', renderer: 'document', immutable: true, primary: 1 }),\n// \troleId: createField('uuid', { nullable: false, index: true, label: '角色', model: 'role', renderer: 'document', immutable: true, primary: 2 }),\n// \tno: createField('i32', { nullable: false, default: 0 }),\n// });\n\nexport const OrganizationAppointment = createModel('organizationAppointment', {\n\tid: createField('uuid', { nullable: false, primary: 1, default: uuid, uncreatable: true, immutable: true }),\n\n\tlabel: createField('string', { nullable: false, label: '职务名称' }),\n\tdescription: createField('string', { nullable: true, label: '描述' }),\n\n\tcreatedAt: createField('date', { nullable: false, default: now, creating: now, label: '创建日期' }),\n\tupdatedAt: createField('date', { nullable: false, default: now, updating: now, label: '最后更新日期' }),\n\n\t// roles: createField(OrganizationAppointmentRole, { \n\t// \tarray: true, \n\t// \tconstraints: { appointmentId: { field: 'id' }, no: { noField: true } }, \n\t// \tlabel: '角色列表' \n\t// }),\n}, {\n\tdatabase,\n\n\tpermissions: [\n\t\t{ permission: 'system:organization', fields: '*', authorizations: ['query', 'read', 'create', 'update', 'destroy', 'add', 'remove'] },\n\t],\n});\n","import { actions, createField, createModel, now, uuid, Where} from '@yongdall/model';\nimport { database } from '../constants.mts';\n\n\nexport const OrganizationMember = createModel('organizationMember', {\n\tid: createField('uuid', { nullable: false, index: true, primary: 1, default: uuid, uncreatable: true, immutable: true }),\n\n\tuserId: createField('uuid', { nullable: false, index: true, label: '用户', model: 'user', renderer: 'document', immutable: true, layout: { rowSpan: 6 } }),\n\torganizationId: createField('uuid', { nullable: false, index: true, label: '组织', model: 'organization', renderer: 'document', immutable: true, layout: { rowSpan: 6 } }),\n\tappointmentId: createField('uuid', { nullable: true, index: true, label: '职务', model: 'appointment', renderer: 'document', layout: { rowSpan: 6 } }),\n\n\tdefault: createField('bool', { nullable: false, default: false, label: '默认职务' }),\n\n\tcreatedAt: createField('date', { nullable: false, default: now, creating: now, label: '创建日期' }),\n\tupdatedAt: createField('date', { nullable: false, default: now, updating: now, label: '最后更新日期' }),\n\n}, {\n\tdatabase,\n\tindexes: [\n\t\t{ fields: ['userId', 'organizationId', 'appointmentId'], unique: true }\n\t],\n\tpermissions: [\n\t\t{ permission: 'system:user', fields: '*', authorizations: ['query', 'read', 'create', 'update', 'destroy', 'add', 'remove'] },\n\t],\n\thooks: {\n\t\tasync afterCreate(conn, Model, record) {\n\t\t\tif (!record.default) { return }\n\t\t\tawait conn.call(actions.update(\n\t\t\t\tModel,\n\t\t\t\t{ default: false },\n\t\t\t\tWhere.and('organizationId', '=', record.organizationId, true)\n\t\t\t\t\t.and('userId', record.userId),\n\t\t\t));\n\t\t},\n\n\t\tasync afterUpdate(conn, Model, record, oldRecord) {\n\t\t\tif (!record.default) { return }\n\t\t\tif (oldRecord.default) { return }\n\t\t\tawait conn.call(actions.update(\n\t\t\t\tModel,\n\t\t\t\t{ default: false },\n\t\t\t\tWhere.and('organizationId', '=', record.organizationId, true)\n\t\t\t\t\t.and('userId', record.userId),\n\t\t\t));\n\t\t},\n\t}\n});\n","import { actions, createField, createModel, now, uuid, Where} from '@yongdall/model';\nimport { database } from '../constants.mts';\n\nexport const OrganizationUserRole = createModel('organizationUserRole', {\n\tuserId: createField('uuid', { nullable: false, index: true, label: '用户', model: 'user', renderer: 'document', immutable: true, primary: 1 }),\n\torganizationId: createField('uuid', { nullable: false, index: true, label: '组织', model: 'organization', renderer: 'document', immutable: true, primary: 2 }),\n\troleId: createField('uuid', { nullable: false, index: true, label: '角色', model: 'role', renderer: 'document', immutable: true, primary: 3 }),\n\n\n\tcreatedAt: createField('date', { nullable: false, default: now, creating: now, label: '创建日期' }),\n\n},{\n\tdatabase,\n\tpermissions: [\n\t\t{ permission: 'system:user', fields: '*', authorizations: ['query', 'read', 'create', 'destroy'] },\n\t],\n});\n","import { createKeyStore } from '@yongdall/context';\nimport { Query } from '@yongdall/model';\nimport { getUser } from '@yongdall/core';\nimport { useDatabase } from '@yongdall/connection';\nimport { findRolePermissions } from '@yongdall/role-permission';\nimport { OrganizationCompositeRole, OrganizationMember, OrganizationUserCompositeRole, OrganizationUserRole } from './models/index.mts';\n\nexport * from './models/index.mts';\n\n\n/** 所在组织 */\nexport const getOrganizations = createKeyStore(async (userId: string | null) => {\n\tif (!userId) { return new Set(); }\n\tconst relations: { organizationId: string }[] = await useDatabase(OrganizationMember.databaseId).call(\n\t\tnew Query(OrganizationMember).select(['organizationId']).where('userId', userId)\n\t);\n\treturn new Set(relations.map(v => v.organizationId));\n}, user => user || '');\n\n\n/** 角色 */\nexport const getOrganizationRoleIds = createKeyStore(async (userId: string | null) => {\n\tconst compositeRoleIds = new Query(OrganizationUserCompositeRole).select('compositeRoleId').where('userId', '=', userId)\n\tconst list: { organizationId: number; roleId: string; }[][] = await Promise.all([\n\t\tuseDatabase(OrganizationUserRole.databaseId).call(\n\t\t\tnew Query(OrganizationUserRole).select(['organizationId', 'roleId'])\n\t\t\t\t.where('userId', userId)\n\t\t),\n\t\tuseDatabase(OrganizationCompositeRole.databaseId).call(\n\t\t\tnew Query(OrganizationCompositeRole).select(['organizationId', 'roleId'])\n\t\t\t\t.where('compositeRoleId', 'in', compositeRoleIds)\n\t\t)\n\t]);\n\n\treturn Object.fromEntries((Object.entries(Object.groupBy(list.flat(), v => v.organizationId))\n\t\t.map(([organizationId, list]) => [organizationId, new Set(list?.map(v => v.roleId))])))\n}, user => user || '');\n\n\nexport const getOrganizationPermissions = createKeyStore(async (userId: string | null) => {\n\tconst roleIds = await getOrganizationRoleIds(userId)\n\tconst allRoleIds = [...new Set(Object.values(roleIds).flatMap(v => [...v]))];\n\tconst permissions: Record<string, Set<string>> = Object.create(null);\n\tif (!allRoleIds.length) { return permissions; }\n\tconst values = await findRolePermissions(allRoleIds);\n\tconst list = Object.fromEntries(Object.entries(Object.groupBy(values, l => l.roleId)).map(([k, v]) => [k, v?.map(v => v.permission)]));\n\tfor (const [organization, roleSet] of Object.entries(roleIds)) {\n\t\tconst s = new Set([...roleSet].flatMap(v => list[v] || []));\n\t\tif (!s.size) { continue; }\n\t\tpermissions[organization] = s;\n\t}\n\treturn permissions;\n}, user => user || '');\n\n\n\nexport const getOrganizationAllPermissions = createKeyStore(async (userId: string | null) => {\n\tconst v = await getOrganizationPermissions(userId)\n\treturn new Set(Object.values(v).flatMap(v => [...v]));\n}, user => user || '');\n"],"mappings":";;;;;;;AACA,MAAa,EACZ,IAAI,UACM,aACP,WAAW;;;;;;;;;;;ACUf,MAAa,4BAA4B,YAAY,6BAA6B;CACjF,iBAAiB,YAAY,QAAQ;EAAE,UAAU;EAAO,OAAO;EAAM,OAAO;EAAQ,OAAO;EAAiB,UAAU;EAAY,WAAW;EAAM,SAAS;CAAE,CAAC;CAC/J,gBAAgB,YAAY,QAAQ;EAAE,UAAU;EAAO,OAAO;EAAM,OAAO;EAAM,OAAO;EAAgB,UAAU;EAAY,WAAW;EAAM,SAAS;CAAE,CAAC;CAC3J,QAAQ,YAAY,QAAQ;EAAE,UAAU;EAAO,OAAO;EAAM,OAAO;EAAM,OAAO;EAAQ,UAAU;EAAY,WAAW;EAAM,SAAS;CAAE,CAAC;CAE3I,WAAW,YAAY,QAAQ;EAAE,UAAU;EAAO,SAAS;EAAK,UAAU;EAAK,OAAO;CAAO,CAAC;AAC/F,GAAG;CAEF,aAAa,CACZ;EAAE,YAAY;EAAwB,QAAQ,CAAC,GAAG;EAAG,gBAAgB;GAAC;GA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MAAQ;EACf,YAAY,gBAAgB;CAC7B;CACA,OAAO;AACR,IAAG,SAAQ,QAAQ,EAAE;AAIrB,MAAa,gCAAgC,eAAe,OAAO,WAA0B;CAC5F,MAAM,IAAI,MAAM,2BAA2B,MAAM;CACjD,OAAO,IAAI,IAAI,OAAO,OAAO,CAAC,CAAC,CAAC,SAAQ,MAAK,CAAC,GAAG,CAAC,CAAC,CAAC;AACrD,IAAG,SAAQ,QAAQ,EAAE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yongdall/organization-rbac",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./index.mjs",
|
|
6
6
|
"exports": {
|
|
@@ -11,15 +11,15 @@
|
|
|
11
11
|
"author": "",
|
|
12
12
|
"license": "ISC",
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@yongdall/connection": "^0.
|
|
15
|
-
"@yongdall/context": "^0.
|
|
16
|
-
"@yongdall/core": "^0.
|
|
17
|
-
"@yongdall/model": "^0.
|
|
18
|
-
"@yongdall/plugin-meta": "^0.
|
|
19
|
-
"@yongdall/role-permission": "^0.
|
|
14
|
+
"@yongdall/connection": "^0.7.0",
|
|
15
|
+
"@yongdall/context": "^0.7.0",
|
|
16
|
+
"@yongdall/core": "^0.7.0",
|
|
17
|
+
"@yongdall/model": "^0.7.0",
|
|
18
|
+
"@yongdall/plugin-meta": "^0.7.0",
|
|
19
|
+
"@yongdall/role-permission": "^0.7.0"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@yongdall/migrate": "^0.
|
|
23
|
-
"@yongdall/types": "^0.
|
|
22
|
+
"@yongdall/migrate": "^0.7.0",
|
|
23
|
+
"@yongdall/types": "^0.7.0"
|
|
24
24
|
}
|
|
25
25
|
}
|
package/yongdall/migration.mjs
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { a as OrganizationUserRole, c as CompositeRole, l as OrganizationUserCompositeRole, o as OrganizationMember, s as OrganizationAppointment, u as OrganizationCompositeRole } from "../organization-rbac--hDZMB8h.mjs";
|
|
3
2
|
//#region plugins/organization-rbac/yongdall/migration.mts
|
|
4
|
-
/** @import { Profile } from '@yongdall/migrate' */
|
|
5
|
-
/** @type {Profile['models']} */
|
|
6
3
|
const models = [
|
|
7
4
|
OrganizationAppointment,
|
|
8
5
|
OrganizationMember,
|
|
6
|
+
OrganizationUserRole,
|
|
9
7
|
CompositeRole,
|
|
10
8
|
OrganizationCompositeRole,
|
|
11
9
|
OrganizationUserCompositeRole
|
|
12
10
|
];
|
|
13
|
-
|
|
14
11
|
//#endregion
|
|
15
12
|
export { models };
|
|
13
|
+
|
|
16
14
|
//# sourceMappingURL=migration.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration.mjs","names":[],"sources":["../../../plugins/organization-rbac/yongdall/migration.mts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"migration.mjs","names":[],"sources":["../../../plugins/organization-rbac/yongdall/migration.mts"],"sourcesContent":["import type { Profile } from '@yongdall/migrate';\nimport {\n\tCompositeRole,\n\tOrganizationAppointment,\n\tOrganizationCompositeRole,\n\tOrganizationMember,\n\tOrganizationUserCompositeRole,\n\tOrganizationUserRole,\n} from '../index.mts';\n\n\nexport const models: Profile['models'] = [\n\tOrganizationAppointment,\n\tOrganizationMember,\n\tOrganizationUserRole,\n\tCompositeRole,\n\tOrganizationCompositeRole,\n\tOrganizationUserCompositeRole,\n];\n"],"mappings":";;AAWA,MAAa,SAA4B;CACxC;CACA;CACA;CACA;CACA;CACA;AACD"}
|
package/yongdall/model.mjs
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { a as OrganizationUserRole, c as CompositeRole, l as OrganizationUserCompositeRole, o as OrganizationMember, s as OrganizationAppointment, u as OrganizationCompositeRole } from "../organization-rbac--hDZMB8h.mjs";
|
|
3
2
|
//#region plugins/organization-rbac/yongdall/model.mts
|
|
4
|
-
/** @import { ModelProfile } from '@yongdall/core' */
|
|
5
|
-
/** @type {ModelProfile['models']} */
|
|
6
3
|
const models = {
|
|
7
4
|
organizationAppointment: OrganizationAppointment,
|
|
8
5
|
organizationMember: OrganizationMember,
|
|
6
|
+
organizationUserRole: OrganizationUserRole,
|
|
9
7
|
compositeRole: CompositeRole,
|
|
10
8
|
organizationCompositeRole: OrganizationCompositeRole,
|
|
11
9
|
organizationUserCompositeRole: OrganizationUserCompositeRole
|
|
12
10
|
};
|
|
13
|
-
|
|
14
11
|
//#endregion
|
|
15
12
|
export { models };
|
|
13
|
+
|
|
16
14
|
//# sourceMappingURL=model.mjs.map
|
package/yongdall/model.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.mjs","names":[],"sources":["../../../plugins/organization-rbac/yongdall/model.mts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"model.mjs","names":[],"sources":["../../../plugins/organization-rbac/yongdall/model.mts"],"sourcesContent":["import type { ModelProfile } from '@yongdall/core';\nimport {\n\tCompositeRole,\n\tOrganizationAppointment,\n\tOrganizationCompositeRole,\n\tOrganizationMember,\n\tOrganizationUserCompositeRole,\n\tOrganizationUserRole,\n} from '../index.mts';\n\nexport const models: ModelProfile['models'] = {\n\torganizationAppointment: OrganizationAppointment,\n\torganizationMember: OrganizationMember,\n\torganizationUserRole: OrganizationUserRole,\n\tcompositeRole: CompositeRole,\n\torganizationCompositeRole: OrganizationCompositeRole,\n\torganizationUserCompositeRole: OrganizationUserCompositeRole,\n};\n"],"mappings":";;AAUA,MAAa,SAAiC;CAC7C,yBAAyB;CACzB,oBAAoB;CACpB,sBAAsB;CACtB,eAAe;CACf,2BAA2B;CAC3B,+BAA+B;AAChC"}
|
package/yongdall/user.mjs
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { n as getOrganizationPermissions, t as getOrganizationAllPermissions } from "../organization-rbac
|
|
2
|
-
|
|
3
|
-
export { getOrganizationAllPermissions, getOrganizationPermissions };
|
|
1
|
+
import { n as getOrganizationPermissions, t as getOrganizationAllPermissions } from "../organization-rbac--hDZMB8h.mjs";
|
|
2
|
+
export { getOrganizationAllPermissions, getOrganizationPermissions };
|