@yongdall/organization-rbac 0.6.6 → 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 CHANGED
@@ -1,30 +1,20 @@
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: _yongdall_model3.ModelTable<{
6
- id: imodel20.FieldDefine<"uuid", false, false>;
7
- label: imodel20.FieldDefine<"string", false, false>;
8
- organizationId: imodel20.FieldDefine<"uuid", false, true>;
9
- description: imodel20.FieldDefine<"text", false, true>;
10
- createdAt: imodel20.FieldDefine<"date", false, false>;
11
- updatedAt: imodel20.FieldDefine<"date", false, false>;
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<"timestamp", false, false>;
8
+ updatedAt: import("imodel").FieldDefine<"timestamp", false, false>;
12
9
  }, "compositeRole">;
13
10
  //#endregion
14
11
  //#region plugins/organization-rbac/models/OrganizationCompositeRole.d.mts
15
- /**
16
- * 组织用户角色模型
17
- * @typedef {Object} OrganizationUserRole
18
- * @property {string} userId - 用户ID,主键第一部分
19
- * @property {string} organizationId - 组织ID,主键第二部分
20
- * @property {string} roleId - 角色ID,主键第三部分
21
- * @property {number} no - 编号
22
- */
23
- declare const OrganizationCompositeRole: _yongdall_model3.ModelTable<{
24
- compositeRoleId: imodel20.FieldDefine<"uuid", false, false>;
25
- organizationId: imodel20.FieldDefine<"uuid", false, false>;
26
- roleId: imodel20.FieldDefine<"uuid", false, false>;
27
- createdAt: imodel20.FieldDefine<"date", false, false>;
12
+ export declare const OrganizationCompositeRole: import("@yongdall/model").ModelTable<{
13
+ compositeRoleId: import("imodel").FieldDefine<"uuid", false, false>;
14
+ organizationId: import("imodel").FieldDefine<"uuid", false, false>;
15
+ roleId: import("imodel").FieldDefine<"uuid", false, false>;
16
+ mainOrganizationId: import("imodel").FieldDefine<"uuid", false, false>;
17
+ createdAt: import("imodel").FieldDefine<"timestamp", false, false>;
28
18
  }, "organizationCompositeRole">;
29
19
  //#endregion
30
20
  //#region plugins/organization-rbac/models/OrganizationUserCompositeRole.d.mts
@@ -36,60 +26,49 @@ declare const OrganizationCompositeRole: _yongdall_model3.ModelTable<{
36
26
  * @property {string} roleId - 角色ID,主键第三部分
37
27
  * @property {number} no - 编号
38
28
  */
39
- declare const OrganizationUserCompositeRole: _yongdall_model3.ModelTable<{
40
- userId: imodel20.FieldDefine<"uuid", false, false>;
41
- organizationId: imodel20.FieldDefine<"uuid", false, false>;
42
- compositeRoleId: imodel20.FieldDefine<"uuid", false, false>;
43
- createdAt: imodel20.FieldDefine<"date", false, false>;
44
- updatedAt: imodel20.FieldDefine<"date", false, false>;
29
+ export declare const OrganizationUserCompositeRole: import("@yongdall/model").ModelTable<{
30
+ userId: import("imodel").FieldDefine<"uuid", false, false>;
31
+ organizationId: import("imodel").FieldDefine<"uuid", false, false>;
32
+ compositeRoleId: import("imodel").FieldDefine<"uuid", false, false>;
33
+ createdAt: import("imodel").FieldDefine<"timestamp", false, false>;
34
+ updatedAt: import("imodel").FieldDefine<"timestamp", false, false>;
45
35
  }, "organizationUserCompositeRole">;
46
36
  //#endregion
47
37
  //#region plugins/organization-rbac/models/OrganizationAppointment.d.mts
48
- declare const OrganizationAppointment: _yongdall_model3.ModelTable<{
49
- id: imodel20.FieldDefine<"uuid", false, false>;
50
- label: imodel20.FieldDefine<"string", false, false>;
51
- description: imodel20.FieldDefine<"string", false, true>;
52
- createdAt: imodel20.FieldDefine<"date", false, false>;
53
- updatedAt: imodel20.FieldDefine<"date", false, false>;
38
+ export declare const OrganizationAppointment: import("@yongdall/model").ModelTable<{
39
+ id: import("imodel").FieldDefine<"uuid", false, false>;
40
+ label: import("imodel").FieldDefine<"string", false, false>;
41
+ description: import("imodel").FieldDefine<"string", false, true>;
42
+ createdAt: import("imodel").FieldDefine<"timestamp", false, false>;
43
+ updatedAt: import("imodel").FieldDefine<"timestamp", false, false>;
54
44
  }, "organizationAppointment">;
55
45
  //#endregion
56
46
  //#region plugins/organization-rbac/models/OrganizationMember.d.mts
57
- declare const OrganizationMember: _yongdall_model3.ModelTable<{
58
- id: imodel20.FieldDefine<"uuid", false, false>;
59
- userId: imodel20.FieldDefine<"uuid", false, false>;
60
- organizationId: imodel20.FieldDefine<"uuid", false, false>;
61
- appointmentId: imodel20.FieldDefine<"uuid", false, true>;
62
- default: imodel20.FieldDefine<"bool", false, false>;
63
- createdAt: imodel20.FieldDefine<"date", false, false>;
64
- updatedAt: imodel20.FieldDefine<"date", false, false>;
47
+ export declare const OrganizationMember: import("@yongdall/model").ModelTable<{
48
+ id: import("imodel").FieldDefine<"uuid", false, false>;
49
+ userId: import("imodel").FieldDefine<"uuid", false, false>;
50
+ organizationId: import("imodel").FieldDefine<"uuid", false, false>;
51
+ appointmentId: import("imodel").FieldDefine<"uuid", false, true>;
52
+ default: import("imodel").FieldDefine<"bool", false, false>;
53
+ createdAt: import("imodel").FieldDefine<"timestamp", false, false>;
54
+ updatedAt: import("imodel").FieldDefine<"timestamp", false, false>;
65
55
  }, "organizationMember">;
66
56
  //#endregion
67
57
  //#region plugins/organization-rbac/models/OrganizationUserRole.d.mts
68
- declare const OrganizationUserRole: _yongdall_model3.ModelTable<{
69
- userId: imodel20.FieldDefine<"uuid", false, false>;
70
- organizationId: imodel20.FieldDefine<"uuid", false, false>;
71
- roleId: imodel20.FieldDefine<"uuid", false, false>;
72
- createdAt: imodel20.FieldDefine<"date", false, false>;
58
+ export declare const OrganizationUserRole: import("@yongdall/model").ModelTable<{
59
+ userId: import("imodel").FieldDefine<"uuid", false, false>;
60
+ organizationId: import("imodel").FieldDefine<"uuid", false, false>;
61
+ roleId: import("imodel").FieldDefine<"uuid", false, false>;
62
+ createdAt: import("imodel").FieldDefine<"timestamp", false, false>;
73
63
  }, "organizationUserRole">;
74
64
  //#endregion
75
65
  //#region plugins/organization-rbac/index.d.mts
76
66
  /** 所在组织 */
77
- declare const getOrganizations: (userId: string | null) => Promise<Set<unknown>>;
67
+ export declare const getOrganizations: (userId: string | null) => Promise<Set<unknown>>;
78
68
  /** 角色 */
79
- declare const getOrganizationRoleIds: (userId: string | null) => Promise<{
69
+ export declare const getOrganizationRoleIds: (userId: string | null) => Promise<{
80
70
  [k: string]: Set<string>;
81
71
  }>;
82
- declare const getOrganizationPermissions: (userId: string | null) => Promise<Record<string, Set<string>>>;
83
- declare const getOrganizationAllPermissions: (userId: string | null) => Promise<Set<string>>;
84
- /** @deprecated */
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 };
72
+ export declare const getOrganizationPermissions: (userId: string | null) => Promise<Record<string, Set<string>>>;
73
+ export declare const getOrganizationAllPermissions: (userId: string | null) => Promise<Set<string>>;
74
+ //#endregion
package/index.mjs CHANGED
@@ -1,3 +1,2 @@
1
- import { a as useOrganizationAllPermissions, c as useOrganizations, d as OrganizationAppointment, f as CompositeRole, i as getOrganizations, l as OrganizationUserRole, m as OrganizationCompositeRole, n as getOrganizationPermissions, o as useOrganizationPermissions, p as OrganizationUserCompositeRole, r as getOrganizationRoleIds, s as useOrganizationRoleIds, t as getOrganizationAllPermissions, u as OrganizationMember } from "./organization-rbac-CVRP1FKi.mjs";
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-Bbuq32zd.mjs";
2
+ export { CompositeRole, OrganizationAppointment, OrganizationCompositeRole, OrganizationMember, OrganizationUserCompositeRole, OrganizationUserRole, getOrganizationAllPermissions, getOrganizationPermissions, getOrganizationRoleIds, getOrganizations };
@@ -1,23 +1,13 @@
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, getUser } from "@yongdall/core";
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
- /**
14
- * 组织用户角色模型
15
- * @typedef {Object} OrganizationUserRole
16
- * @property {string} userId - 用户ID,主键第一部分
17
- * @property {string} organizationId - 组织ID,主键第二部分
18
- * @property {string} roleId - 角色ID,主键第三部分
19
- * @property {number} no - 编号
20
- */
21
11
  const OrganizationCompositeRole = createModel("organizationCompositeRole", {
22
12
  compositeRoleId: createField("uuid", {
23
13
  nullable: false,
@@ -26,7 +16,11 @@ const OrganizationCompositeRole = createModel("organizationCompositeRole", {
26
16
  model: "compositeRole",
27
17
  renderer: "document",
28
18
  immutable: true,
29
- primary: 1
19
+ primary: 1,
20
+ bind: { mainOrganizationId: {
21
+ source: "organizationId",
22
+ clear: true
23
+ } }
30
24
  }),
31
25
  organizationId: createField("uuid", {
32
26
  nullable: false,
@@ -35,7 +29,8 @@ const OrganizationCompositeRole = createModel("organizationCompositeRole", {
35
29
  model: "organization",
36
30
  renderer: "document",
37
31
  immutable: true,
38
- primary: 2
32
+ primary: 2,
33
+ source: { search: "mainId=?mainOrganizationId" }
39
34
  }),
40
35
  roleId: createField("uuid", {
41
36
  nullable: false,
@@ -46,7 +41,16 @@ const OrganizationCompositeRole = createModel("organizationCompositeRole", {
46
41
  immutable: true,
47
42
  primary: 3
48
43
  }),
49
- createdAt: createField("date", {
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", {
50
54
  nullable: false,
51
55
  default: now,
52
56
  creating: now,
@@ -78,17 +82,19 @@ const OrganizationCompositeRole = createModel("organizationCompositeRole", {
78
82
  }],
79
83
  database,
80
84
  label: "组织复合角色配置",
81
- hooks: { async afterCreate(conn, model, record) {
85
+ hooks: { async beforeCreate(conn, model, record) {
82
86
  if (!record.organizationId) throw new ServerError("组织不存在");
83
87
  if (!record.roleId) throw new ServerError("角色不存在");
84
88
  const [compositeRole] = await conn.call(new Query(CompositeRole).where({ id: record.compositeRoleId }).limit(1));
85
89
  if (!compositeRole) throw new Error("复合角色不存在");
86
- if (!compositeRole.organizationId) return;
90
+ const mainOrganizationId = compositeRole.organizationId || null;
91
+ if (record.mainOrganizationId && record.mainOrganizationId !== mainOrganizationId) throw new ServerError("主体组织不匹配");
92
+ if (!mainOrganizationId) return;
87
93
  const organizationModel = await getModel("organization");
88
94
  if (organizationModel) {
89
95
  const [organization] = await useDatabase(organizationModel.databaseId).call(new Query(organizationModel).where({
90
96
  id: record.organizationId,
91
- mainId: compositeRole.organizationId
97
+ mainId: mainOrganizationId
92
98
  }).limit(1));
93
99
  if (!organization) throw new ServerError("请选择关联组织");
94
100
  }
@@ -100,9 +106,12 @@ const OrganizationCompositeRole = createModel("organizationCompositeRole", {
100
106
  }).limit(1));
101
107
  if (!role) throw new ServerError("请选择有效角色");
102
108
  }
109
+ return {
110
+ ...record,
111
+ mainOrganizationId
112
+ };
103
113
  } }
104
114
  });
105
-
106
115
  //#endregion
107
116
  //#region plugins/organization-rbac/models/OrganizationUserCompositeRole.mts
108
117
  /**
@@ -140,13 +149,13 @@ const OrganizationUserCompositeRole = createModel("organizationUserCompositeRole
140
149
  immutable: true,
141
150
  primary: 2
142
151
  }),
143
- createdAt: createField("date", {
152
+ createdAt: createField("timestamp", {
144
153
  nullable: false,
145
154
  default: now,
146
155
  creating: now,
147
156
  label: "创建日期"
148
157
  }),
149
- updatedAt: createField("date", {
158
+ updatedAt: createField("timestamp", {
150
159
  nullable: false,
151
160
  default: now,
152
161
  updating: now,
@@ -185,7 +194,6 @@ const OrganizationUserCompositeRole = createModel("organizationUserCompositeRole
185
194
  throw new ServerError("复合角色与组织不匹配");
186
195
  } }
187
196
  });
188
-
189
197
  //#endregion
190
198
  //#region plugins/organization-rbac/models/CompositeRole.mts
191
199
  const CompositeRole = createModel("compositeRole", {
@@ -216,13 +224,13 @@ const CompositeRole = createModel("compositeRole", {
216
224
  nullable: true,
217
225
  label: "描述"
218
226
  }),
219
- createdAt: createField("date", {
227
+ createdAt: createField("timestamp", {
220
228
  nullable: false,
221
229
  default: now,
222
230
  creating: now,
223
231
  label: "创建日期"
224
232
  }),
225
- updatedAt: createField("date", {
233
+ updatedAt: createField("timestamp", {
226
234
  nullable: false,
227
235
  default: now,
228
236
  updating: now,
@@ -279,7 +287,6 @@ const CompositeRole = createModel("compositeRole", {
279
287
  }
280
288
  }
281
289
  });
282
-
283
290
  //#endregion
284
291
  //#region plugins/organization-rbac/models/OrganizationAppointment.mts
285
292
  const OrganizationAppointment = createModel("organizationAppointment", {
@@ -298,13 +305,13 @@ const OrganizationAppointment = createModel("organizationAppointment", {
298
305
  nullable: true,
299
306
  label: "描述"
300
307
  }),
301
- createdAt: createField("date", {
308
+ createdAt: createField("timestamp", {
302
309
  nullable: false,
303
310
  default: now,
304
311
  creating: now,
305
312
  label: "创建日期"
306
313
  }),
307
- updatedAt: createField("date", {
314
+ updatedAt: createField("timestamp", {
308
315
  nullable: false,
309
316
  default: now,
310
317
  updating: now,
@@ -326,7 +333,6 @@ const OrganizationAppointment = createModel("organizationAppointment", {
326
333
  ]
327
334
  }]
328
335
  });
329
-
330
336
  //#endregion
331
337
  //#region plugins/organization-rbac/models/OrganizationMember.mts
332
338
  const OrganizationMember = createModel("organizationMember", {
@@ -369,13 +375,13 @@ const OrganizationMember = createModel("organizationMember", {
369
375
  default: false,
370
376
  label: "默认职务"
371
377
  }),
372
- createdAt: createField("date", {
378
+ createdAt: createField("timestamp", {
373
379
  nullable: false,
374
380
  default: now,
375
381
  creating: now,
376
382
  label: "创建日期"
377
383
  }),
378
- updatedAt: createField("date", {
384
+ updatedAt: createField("timestamp", {
379
385
  nullable: false,
380
386
  default: now,
381
387
  updating: now,
@@ -416,7 +422,6 @@ const OrganizationMember = createModel("organizationMember", {
416
422
  }
417
423
  }
418
424
  });
419
-
420
425
  //#endregion
421
426
  //#region plugins/organization-rbac/models/OrganizationUserRole.mts
422
427
  const OrganizationUserRole = createModel("organizationUserRole", {
@@ -447,7 +452,7 @@ const OrganizationUserRole = createModel("organizationUserRole", {
447
452
  immutable: true,
448
453
  primary: 3
449
454
  }),
450
- createdAt: createField("date", {
455
+ createdAt: createField("timestamp", {
451
456
  nullable: false,
452
457
  default: now,
453
458
  creating: now,
@@ -466,7 +471,6 @@ const OrganizationUserRole = createModel("organizationUserRole", {
466
471
  ]
467
472
  }]
468
473
  });
469
-
470
474
  //#endregion
471
475
  //#region plugins/organization-rbac/index.mts
472
476
  /** 所在组织 */
@@ -499,15 +503,7 @@ const getOrganizationAllPermissions = createKeyStore(async (userId) => {
499
503
  const v = await getOrganizationPermissions(userId);
500
504
  return new Set(Object.values(v).flatMap((v) => [...v]));
501
505
  }, (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
506
  //#endregion
512
- export { useOrganizationAllPermissions as a, useOrganizations as c, OrganizationAppointment as d, CompositeRole as f, getOrganizations as i, OrganizationUserRole as l, OrganizationCompositeRole as m, getOrganizationPermissions as n, useOrganizationPermissions as o, OrganizationUserCompositeRole as p, getOrganizationRoleIds as r, useOrganizationRoleIds as s, getOrganizationAllPermissions as t, OrganizationMember as u };
513
- //# sourceMappingURL=organization-rbac-CVRP1FKi.mjs.map
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 };
508
+
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 || '');\n"],"mappings":";;;;;;;AACA,MAAa,EACZ,IAAI,UACM,aACP,WAAW;;;ACEf,MAAa,4BAA4B,YAAY,6BAA6B;CAC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1,6 @@
1
1
  {
2
2
  "name": "@yongdall/organization-rbac",
3
- "version": "0.6.6",
3
+ "version": "0.7.1",
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.6.6",
15
- "@yongdall/context": "^0.6.6",
16
- "@yongdall/core": "^0.6.6",
17
- "@yongdall/model": "^0.6.6",
18
- "@yongdall/plugin-meta": "^0.6.6",
19
- "@yongdall/role-permission": "^0.6.6"
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.6.6",
23
- "@yongdall/types": "^0.6.6"
22
+ "@yongdall/migrate": "^0.7.0",
23
+ "@yongdall/types": "^0.7.0"
24
24
  }
25
25
  }
@@ -1,16 +1,14 @@
1
- import { d as OrganizationAppointment, f as CompositeRole, m as OrganizationCompositeRole, p as OrganizationUserCompositeRole, u as OrganizationMember } from "../organization-rbac-CVRP1FKi.mjs";
2
-
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";
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":["/** @import { Profile } from '@yongdall/migrate' */\nimport { CompositeRole, OrganizationAppointment, OrganizationCompositeRole, OrganizationMember, OrganizationUserCompositeRole } from '../index.mts';\n\n\n/** @type {Profile['models']} */\nexport const models = [\n\tOrganizationAppointment,\n\tOrganizationMember,\n\tCompositeRole,\n\tOrganizationCompositeRole,\n\tOrganizationUserCompositeRole,\n];\n"],"mappings":";;;;;AAKA,MAAa,SAAS;CACrB;CACA;CACA;CACA;CACA;CACA"}
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"}
@@ -1,16 +1,14 @@
1
- import { d as OrganizationAppointment, f as CompositeRole, m as OrganizationCompositeRole, p as OrganizationUserCompositeRole, u as OrganizationMember } from "../organization-rbac-CVRP1FKi.mjs";
2
-
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";
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
@@ -1 +1 @@
1
- {"version":3,"file":"model.mjs","names":[],"sources":["../../../plugins/organization-rbac/yongdall/model.mts"],"sourcesContent":["/** @import { ModelProfile } from '@yongdall/core' */\nimport { CompositeRole, OrganizationAppointment, OrganizationCompositeRole, OrganizationMember, OrganizationUserCompositeRole } from '../index.mts';\n\n/** @type {ModelProfile['models']} */\nexport const models = {\n\torganizationAppointment: OrganizationAppointment,\n\torganizationMember: OrganizationMember,\n\t\tcompositeRole: CompositeRole,\n\t\torganizationCompositeRole: OrganizationCompositeRole,\n\t\torganizationUserCompositeRole: OrganizationUserCompositeRole,\n};\n"],"mappings":";;;;;AAIA,MAAa,SAAS;CACrB,yBAAyB;CACzB,oBAAoB;CACnB,eAAe;CACf,2BAA2B;CAC3B,+BAA+B;CAChC"}
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-CVRP1FKi.mjs";
2
-
3
- export { getOrganizationAllPermissions, getOrganizationPermissions };
1
+ import { n as getOrganizationPermissions, t as getOrganizationAllPermissions } from "../organization-rbac-Bbuq32zd.mjs";
2
+ export { getOrganizationAllPermissions, getOrganizationPermissions };
@@ -1 +0,0 @@
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;EAAM,SAAS;EAAG,CAAC;CAC5J,QAAQ,YAAY,QAAQ;EAAE,UAAU;EAAO,OAAO;EAAM,OAAO;EAAM,OAAO;EAAQ,UAAU;EAAY,WAAW;EAAM,SAAS;EAAG,CAAC;CAE5I,WAAW,YAAY,QAAQ;EAAE,UAAU;EAAO,SAAS;EAAK,UAAU;EAAK,OAAO;EAAQ,CAAC;CAC/F,EAAE;CAEF,aAAa,CACZ;EAAE,YAAY;EAAwB,QAAQ,CAAC,IAAI;EAAE,gBAAgB;GAAC;GAAW;GAAS;GAAQ;GAAU;GAAU;EAAE,EACxH;EAAE,YAAY;EAAwB,mBAAmB;EAAkB,QAAQ,CAAC,IAAI;EAAE,gBAAgB;GAAC;GAAW;GAAS;G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