@yongdall/organization-rbac 0.7.0 → 0.7.1
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 +11 -18
- package/index.mjs +1 -1
- package/{organization-rbac--hDZMB8h.mjs → organization-rbac-Bbuq32zd.mjs} +36 -24
- package/organization-rbac-Bbuq32zd.mjs.map +1 -0
- package/package.json +1 -1
- package/yongdall/migration.mjs +1 -1
- package/yongdall/model.mjs +1 -1
- package/yongdall/user.mjs +1 -1
- package/organization-rbac--hDZMB8h.mjs.map +0 -1
package/index.d.mts
CHANGED
|
@@ -4,24 +4,17 @@ export declare const CompositeRole: import("@yongdall/model").ModelTable<{
|
|
|
4
4
|
label: import("imodel").FieldDefine<"string", false, false>;
|
|
5
5
|
organizationId: import("imodel").FieldDefine<"uuid", false, true>;
|
|
6
6
|
description: import("imodel").FieldDefine<"text", false, true>;
|
|
7
|
-
createdAt: import("imodel").FieldDefine<"
|
|
8
|
-
updatedAt: import("imodel").FieldDefine<"
|
|
7
|
+
createdAt: import("imodel").FieldDefine<"timestamp", false, false>;
|
|
8
|
+
updatedAt: import("imodel").FieldDefine<"timestamp", false, false>;
|
|
9
9
|
}, "compositeRole">;
|
|
10
10
|
//#endregion
|
|
11
11
|
//#region plugins/organization-rbac/models/OrganizationCompositeRole.d.mts
|
|
12
|
-
/**
|
|
13
|
-
* 组织用户角色模型
|
|
14
|
-
* @typedef {Object} OrganizationUserRole
|
|
15
|
-
* @property {string} userId - 用户ID,主键第一部分
|
|
16
|
-
* @property {string} organizationId - 组织ID,主键第二部分
|
|
17
|
-
* @property {string} roleId - 角色ID,主键第三部分
|
|
18
|
-
* @property {number} no - 编号
|
|
19
|
-
*/
|
|
20
12
|
export declare const OrganizationCompositeRole: import("@yongdall/model").ModelTable<{
|
|
21
13
|
compositeRoleId: import("imodel").FieldDefine<"uuid", false, false>;
|
|
22
14
|
organizationId: import("imodel").FieldDefine<"uuid", false, false>;
|
|
23
15
|
roleId: import("imodel").FieldDefine<"uuid", false, false>;
|
|
24
|
-
|
|
16
|
+
mainOrganizationId: import("imodel").FieldDefine<"uuid", false, false>;
|
|
17
|
+
createdAt: import("imodel").FieldDefine<"timestamp", false, false>;
|
|
25
18
|
}, "organizationCompositeRole">;
|
|
26
19
|
//#endregion
|
|
27
20
|
//#region plugins/organization-rbac/models/OrganizationUserCompositeRole.d.mts
|
|
@@ -37,8 +30,8 @@ export declare const OrganizationUserCompositeRole: import("@yongdall/model").Mo
|
|
|
37
30
|
userId: import("imodel").FieldDefine<"uuid", false, false>;
|
|
38
31
|
organizationId: import("imodel").FieldDefine<"uuid", false, false>;
|
|
39
32
|
compositeRoleId: import("imodel").FieldDefine<"uuid", false, false>;
|
|
40
|
-
createdAt: import("imodel").FieldDefine<"
|
|
41
|
-
updatedAt: import("imodel").FieldDefine<"
|
|
33
|
+
createdAt: import("imodel").FieldDefine<"timestamp", false, false>;
|
|
34
|
+
updatedAt: import("imodel").FieldDefine<"timestamp", false, false>;
|
|
42
35
|
}, "organizationUserCompositeRole">;
|
|
43
36
|
//#endregion
|
|
44
37
|
//#region plugins/organization-rbac/models/OrganizationAppointment.d.mts
|
|
@@ -46,8 +39,8 @@ export declare const OrganizationAppointment: import("@yongdall/model").ModelTab
|
|
|
46
39
|
id: import("imodel").FieldDefine<"uuid", false, false>;
|
|
47
40
|
label: import("imodel").FieldDefine<"string", false, false>;
|
|
48
41
|
description: import("imodel").FieldDefine<"string", false, true>;
|
|
49
|
-
createdAt: import("imodel").FieldDefine<"
|
|
50
|
-
updatedAt: import("imodel").FieldDefine<"
|
|
42
|
+
createdAt: import("imodel").FieldDefine<"timestamp", false, false>;
|
|
43
|
+
updatedAt: import("imodel").FieldDefine<"timestamp", false, false>;
|
|
51
44
|
}, "organizationAppointment">;
|
|
52
45
|
//#endregion
|
|
53
46
|
//#region plugins/organization-rbac/models/OrganizationMember.d.mts
|
|
@@ -57,8 +50,8 @@ export declare const OrganizationMember: import("@yongdall/model").ModelTable<{
|
|
|
57
50
|
organizationId: import("imodel").FieldDefine<"uuid", false, false>;
|
|
58
51
|
appointmentId: import("imodel").FieldDefine<"uuid", false, true>;
|
|
59
52
|
default: import("imodel").FieldDefine<"bool", false, false>;
|
|
60
|
-
createdAt: import("imodel").FieldDefine<"
|
|
61
|
-
updatedAt: import("imodel").FieldDefine<"
|
|
53
|
+
createdAt: import("imodel").FieldDefine<"timestamp", false, false>;
|
|
54
|
+
updatedAt: import("imodel").FieldDefine<"timestamp", false, false>;
|
|
62
55
|
}, "organizationMember">;
|
|
63
56
|
//#endregion
|
|
64
57
|
//#region plugins/organization-rbac/models/OrganizationUserRole.d.mts
|
|
@@ -66,7 +59,7 @@ export declare const OrganizationUserRole: import("@yongdall/model").ModelTable<
|
|
|
66
59
|
userId: import("imodel").FieldDefine<"uuid", false, false>;
|
|
67
60
|
organizationId: import("imodel").FieldDefine<"uuid", false, false>;
|
|
68
61
|
roleId: import("imodel").FieldDefine<"uuid", false, false>;
|
|
69
|
-
createdAt: import("imodel").FieldDefine<"
|
|
62
|
+
createdAt: import("imodel").FieldDefine<"timestamp", false, false>;
|
|
70
63
|
}, "organizationUserRole">;
|
|
71
64
|
//#endregion
|
|
72
65
|
//#region plugins/organization-rbac/index.d.mts
|
package/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
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
|
|
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-Bbuq32zd.mjs";
|
|
2
2
|
export { CompositeRole, OrganizationAppointment, OrganizationCompositeRole, OrganizationMember, OrganizationUserCompositeRole, OrganizationUserRole, getOrganizationAllPermissions, getOrganizationPermissions, getOrganizationRoleIds, getOrganizations };
|
|
@@ -8,14 +8,6 @@ import PluginMeta from "@yongdall/plugin-meta";
|
|
|
8
8
|
const { id: pluginId, database } = PluginMeta();
|
|
9
9
|
//#endregion
|
|
10
10
|
//#region plugins/organization-rbac/models/OrganizationCompositeRole.mts
|
|
11
|
-
/**
|
|
12
|
-
* 组织用户角色模型
|
|
13
|
-
* @typedef {Object} OrganizationUserRole
|
|
14
|
-
* @property {string} userId - 用户ID,主键第一部分
|
|
15
|
-
* @property {string} organizationId - 组织ID,主键第二部分
|
|
16
|
-
* @property {string} roleId - 角色ID,主键第三部分
|
|
17
|
-
* @property {number} no - 编号
|
|
18
|
-
*/
|
|
19
11
|
const OrganizationCompositeRole = createModel("organizationCompositeRole", {
|
|
20
12
|
compositeRoleId: createField("uuid", {
|
|
21
13
|
nullable: false,
|
|
@@ -24,7 +16,11 @@ const OrganizationCompositeRole = createModel("organizationCompositeRole", {
|
|
|
24
16
|
model: "compositeRole",
|
|
25
17
|
renderer: "document",
|
|
26
18
|
immutable: true,
|
|
27
|
-
primary: 1
|
|
19
|
+
primary: 1,
|
|
20
|
+
bind: { mainOrganizationId: {
|
|
21
|
+
source: "organizationId",
|
|
22
|
+
clear: true
|
|
23
|
+
} }
|
|
28
24
|
}),
|
|
29
25
|
organizationId: createField("uuid", {
|
|
30
26
|
nullable: false,
|
|
@@ -33,7 +29,8 @@ const OrganizationCompositeRole = createModel("organizationCompositeRole", {
|
|
|
33
29
|
model: "organization",
|
|
34
30
|
renderer: "document",
|
|
35
31
|
immutable: true,
|
|
36
|
-
primary: 2
|
|
32
|
+
primary: 2,
|
|
33
|
+
source: { search: "mainId=?mainOrganizationId" }
|
|
37
34
|
}),
|
|
38
35
|
roleId: createField("uuid", {
|
|
39
36
|
nullable: false,
|
|
@@ -44,7 +41,16 @@ const OrganizationCompositeRole = createModel("organizationCompositeRole", {
|
|
|
44
41
|
immutable: true,
|
|
45
42
|
primary: 3
|
|
46
43
|
}),
|
|
47
|
-
|
|
44
|
+
mainOrganizationId: createField("uuid", {
|
|
45
|
+
nullable: false,
|
|
46
|
+
index: true,
|
|
47
|
+
label: "主体组织",
|
|
48
|
+
model: "organization",
|
|
49
|
+
renderer: "document",
|
|
50
|
+
immutable: true,
|
|
51
|
+
layout: { hidden: true }
|
|
52
|
+
}),
|
|
53
|
+
createdAt: createField("timestamp", {
|
|
48
54
|
nullable: false,
|
|
49
55
|
default: now,
|
|
50
56
|
creating: now,
|
|
@@ -76,17 +82,19 @@ const OrganizationCompositeRole = createModel("organizationCompositeRole", {
|
|
|
76
82
|
}],
|
|
77
83
|
database,
|
|
78
84
|
label: "组织复合角色配置",
|
|
79
|
-
hooks: { async
|
|
85
|
+
hooks: { async beforeCreate(conn, model, record) {
|
|
80
86
|
if (!record.organizationId) throw new ServerError("组织不存在");
|
|
81
87
|
if (!record.roleId) throw new ServerError("角色不存在");
|
|
82
88
|
const [compositeRole] = await conn.call(new Query(CompositeRole).where({ id: record.compositeRoleId }).limit(1));
|
|
83
89
|
if (!compositeRole) throw new Error("复合角色不存在");
|
|
84
|
-
|
|
90
|
+
const mainOrganizationId = compositeRole.organizationId || null;
|
|
91
|
+
if (record.mainOrganizationId && record.mainOrganizationId !== mainOrganizationId) throw new ServerError("主体组织不匹配");
|
|
92
|
+
if (!mainOrganizationId) return;
|
|
85
93
|
const organizationModel = await getModel("organization");
|
|
86
94
|
if (organizationModel) {
|
|
87
95
|
const [organization] = await useDatabase(organizationModel.databaseId).call(new Query(organizationModel).where({
|
|
88
96
|
id: record.organizationId,
|
|
89
|
-
mainId:
|
|
97
|
+
mainId: mainOrganizationId
|
|
90
98
|
}).limit(1));
|
|
91
99
|
if (!organization) throw new ServerError("请选择关联组织");
|
|
92
100
|
}
|
|
@@ -98,6 +106,10 @@ const OrganizationCompositeRole = createModel("organizationCompositeRole", {
|
|
|
98
106
|
}).limit(1));
|
|
99
107
|
if (!role) throw new ServerError("请选择有效角色");
|
|
100
108
|
}
|
|
109
|
+
return {
|
|
110
|
+
...record,
|
|
111
|
+
mainOrganizationId
|
|
112
|
+
};
|
|
101
113
|
} }
|
|
102
114
|
});
|
|
103
115
|
//#endregion
|
|
@@ -137,13 +149,13 @@ const OrganizationUserCompositeRole = createModel("organizationUserCompositeRole
|
|
|
137
149
|
immutable: true,
|
|
138
150
|
primary: 2
|
|
139
151
|
}),
|
|
140
|
-
createdAt: createField("
|
|
152
|
+
createdAt: createField("timestamp", {
|
|
141
153
|
nullable: false,
|
|
142
154
|
default: now,
|
|
143
155
|
creating: now,
|
|
144
156
|
label: "创建日期"
|
|
145
157
|
}),
|
|
146
|
-
updatedAt: createField("
|
|
158
|
+
updatedAt: createField("timestamp", {
|
|
147
159
|
nullable: false,
|
|
148
160
|
default: now,
|
|
149
161
|
updating: now,
|
|
@@ -212,13 +224,13 @@ const CompositeRole = createModel("compositeRole", {
|
|
|
212
224
|
nullable: true,
|
|
213
225
|
label: "描述"
|
|
214
226
|
}),
|
|
215
|
-
createdAt: createField("
|
|
227
|
+
createdAt: createField("timestamp", {
|
|
216
228
|
nullable: false,
|
|
217
229
|
default: now,
|
|
218
230
|
creating: now,
|
|
219
231
|
label: "创建日期"
|
|
220
232
|
}),
|
|
221
|
-
updatedAt: createField("
|
|
233
|
+
updatedAt: createField("timestamp", {
|
|
222
234
|
nullable: false,
|
|
223
235
|
default: now,
|
|
224
236
|
updating: now,
|
|
@@ -293,13 +305,13 @@ const OrganizationAppointment = createModel("organizationAppointment", {
|
|
|
293
305
|
nullable: true,
|
|
294
306
|
label: "描述"
|
|
295
307
|
}),
|
|
296
|
-
createdAt: createField("
|
|
308
|
+
createdAt: createField("timestamp", {
|
|
297
309
|
nullable: false,
|
|
298
310
|
default: now,
|
|
299
311
|
creating: now,
|
|
300
312
|
label: "创建日期"
|
|
301
313
|
}),
|
|
302
|
-
updatedAt: createField("
|
|
314
|
+
updatedAt: createField("timestamp", {
|
|
303
315
|
nullable: false,
|
|
304
316
|
default: now,
|
|
305
317
|
updating: now,
|
|
@@ -363,13 +375,13 @@ const OrganizationMember = createModel("organizationMember", {
|
|
|
363
375
|
default: false,
|
|
364
376
|
label: "默认职务"
|
|
365
377
|
}),
|
|
366
|
-
createdAt: createField("
|
|
378
|
+
createdAt: createField("timestamp", {
|
|
367
379
|
nullable: false,
|
|
368
380
|
default: now,
|
|
369
381
|
creating: now,
|
|
370
382
|
label: "创建日期"
|
|
371
383
|
}),
|
|
372
|
-
updatedAt: createField("
|
|
384
|
+
updatedAt: createField("timestamp", {
|
|
373
385
|
nullable: false,
|
|
374
386
|
default: now,
|
|
375
387
|
updating: now,
|
|
@@ -440,7 +452,7 @@ const OrganizationUserRole = createModel("organizationUserRole", {
|
|
|
440
452
|
immutable: true,
|
|
441
453
|
primary: 3
|
|
442
454
|
}),
|
|
443
|
-
createdAt: createField("
|
|
455
|
+
createdAt: createField("timestamp", {
|
|
444
456
|
nullable: false,
|
|
445
457
|
default: now,
|
|
446
458
|
creating: now,
|
|
@@ -494,4 +506,4 @@ const getOrganizationAllPermissions = createKeyStore(async (userId) => {
|
|
|
494
506
|
//#endregion
|
|
495
507
|
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
508
|
|
|
497
|
-
//# sourceMappingURL=organization-rbac
|
|
509
|
+
//# sourceMappingURL=organization-rbac-Bbuq32zd.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"organization-rbac-Bbuq32zd.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 { createField, createModel, now, Query } 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\nexport const OrganizationCompositeRole = createModel('organizationCompositeRole', {\n\tcompositeRoleId: createField('uuid', { nullable: false, index: true, label: '复合角色', model: 'compositeRole', renderer: 'document', immutable: true, primary: 1, bind: {\n\t\tmainOrganizationId: { source: 'organizationId', clear: true },\n\t} }),\n\torganizationId: createField('uuid', { nullable: false, index: true, label: '组织', model: 'organization', renderer: 'document', immutable: true, primary: 2, source: {\n\t\tsearch: 'mainId=?mainOrganizationId'\n\t} }),\n\troleId: createField('uuid', { nullable: false, index: true, label: '角色', model: 'role', renderer: 'document', immutable: true, primary: 3 }),\n\tmainOrganizationId: createField('uuid', { nullable: false, index: true, label: '主体组织', model: 'organization', renderer: 'document', immutable: true, layout: {hidden: true} }),\n\n\tcreatedAt: createField('timestamp', { 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 beforeCreate(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\tconst mainOrganizationId = compositeRole.organizationId || null;\n\t\t\tif (record.mainOrganizationId && record.mainOrganizationId !== mainOrganizationId) {\n\t\t\t\tthrow new ServerError('主体组织不匹配');\n\t\t\t}\n\t\t\tif (!mainOrganizationId) { 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: mainOrganizationId }).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\t\t\t}\n\t\t\treturn {...record, mainOrganizationId};\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('timestamp', { nullable: false, default: now, creating: now, label: '创建日期' }),\n\tupdatedAt: createField('timestamp', { 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('timestamp', { nullable: false, default: now, creating: now, label: '创建日期' }),\n\tupdatedAt: createField('timestamp', { 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('timestamp', { nullable: false, default: now, creating: now, label: '创建日期' }),\n\tupdatedAt: createField('timestamp', { 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('timestamp', { nullable: false, default: now, creating: now, label: '创建日期' }),\n\tupdatedAt: createField('timestamp', { 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('timestamp', { 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 ||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AQ,MAAK,CAAC,GAAG,CAAC,CAAC,CAAC;AACrD,IAAG,SAAQ,QAAQ,EAAE"}
|
package/package.json
CHANGED
package/yongdall/migration.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as OrganizationUserRole, c as CompositeRole, l as OrganizationUserCompositeRole, o as OrganizationMember, s as OrganizationAppointment, u as OrganizationCompositeRole } from "../organization-rbac
|
|
1
|
+
import { a as OrganizationUserRole, c as CompositeRole, l as OrganizationUserCompositeRole, o as OrganizationMember, s as OrganizationAppointment, u as OrganizationCompositeRole } from "../organization-rbac-Bbuq32zd.mjs";
|
|
2
2
|
//#region plugins/organization-rbac/yongdall/migration.mts
|
|
3
3
|
const models = [
|
|
4
4
|
OrganizationAppointment,
|
package/yongdall/model.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as OrganizationUserRole, c as CompositeRole, l as OrganizationUserCompositeRole, o as OrganizationMember, s as OrganizationAppointment, u as OrganizationCompositeRole } from "../organization-rbac
|
|
1
|
+
import { a as OrganizationUserRole, c as CompositeRole, l as OrganizationUserCompositeRole, o as OrganizationMember, s as OrganizationAppointment, u as OrganizationCompositeRole } from "../organization-rbac-Bbuq32zd.mjs";
|
|
2
2
|
//#region plugins/organization-rbac/yongdall/model.mts
|
|
3
3
|
const models = {
|
|
4
4
|
organizationAppointment: OrganizationAppointment,
|
package/yongdall/user.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as getOrganizationPermissions, t as getOrganizationAllPermissions } from "../organization-rbac
|
|
1
|
+
import { n as getOrganizationPermissions, t as getOrganizationAllPermissions } from "../organization-rbac-Bbuq32zd.mjs";
|
|
2
2
|
export { getOrganizationAllPermissions, getOrganizationPermissions };
|
|
@@ -1 +0,0 @@
|
|
|
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,QA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