@yongdall/organization-rbac 0.7.1 → 0.7.4

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
@@ -5,7 +5,9 @@ export declare const CompositeRole: import("@yongdall/model").ModelTable<{
5
5
  organizationId: import("imodel").FieldDefine<"uuid", false, true>;
6
6
  description: import("imodel").FieldDefine<"text", false, true>;
7
7
  createdAt: import("imodel").FieldDefine<"timestamp", false, false>;
8
+ createdBy: import("imodel").FieldDefine<"uuid", false, true>;
8
9
  updatedAt: import("imodel").FieldDefine<"timestamp", false, false>;
10
+ updatedBy: import("imodel").FieldDefine<"uuid", false, true>;
9
11
  }, "compositeRole">;
10
12
  //#endregion
11
13
  //#region plugins/organization-rbac/models/OrganizationCompositeRole.d.mts
@@ -15,6 +17,7 @@ export declare const OrganizationCompositeRole: import("@yongdall/model").ModelT
15
17
  roleId: import("imodel").FieldDefine<"uuid", false, false>;
16
18
  mainOrganizationId: import("imodel").FieldDefine<"uuid", false, false>;
17
19
  createdAt: import("imodel").FieldDefine<"timestamp", false, false>;
20
+ createdBy: import("imodel").FieldDefine<"uuid", false, true>;
18
21
  }, "organizationCompositeRole">;
19
22
  //#endregion
20
23
  //#region plugins/organization-rbac/models/OrganizationUserCompositeRole.d.mts
@@ -31,7 +34,9 @@ export declare const OrganizationUserCompositeRole: import("@yongdall/model").Mo
31
34
  organizationId: import("imodel").FieldDefine<"uuid", false, false>;
32
35
  compositeRoleId: import("imodel").FieldDefine<"uuid", false, false>;
33
36
  createdAt: import("imodel").FieldDefine<"timestamp", false, false>;
37
+ createdBy: import("imodel").FieldDefine<"uuid", false, true>;
34
38
  updatedAt: import("imodel").FieldDefine<"timestamp", false, false>;
39
+ updatedBy: import("imodel").FieldDefine<"uuid", false, true>;
35
40
  }, "organizationUserCompositeRole">;
36
41
  //#endregion
37
42
  //#region plugins/organization-rbac/models/OrganizationAppointment.d.mts
@@ -40,7 +45,9 @@ export declare const OrganizationAppointment: import("@yongdall/model").ModelTab
40
45
  label: import("imodel").FieldDefine<"string", false, false>;
41
46
  description: import("imodel").FieldDefine<"string", false, true>;
42
47
  createdAt: import("imodel").FieldDefine<"timestamp", false, false>;
48
+ createdBy: import("imodel").FieldDefine<"uuid", false, true>;
43
49
  updatedAt: import("imodel").FieldDefine<"timestamp", false, false>;
50
+ updatedBy: import("imodel").FieldDefine<"uuid", false, true>;
44
51
  }, "organizationAppointment">;
45
52
  //#endregion
46
53
  //#region plugins/organization-rbac/models/OrganizationMember.d.mts
@@ -51,7 +58,9 @@ export declare const OrganizationMember: import("@yongdall/model").ModelTable<{
51
58
  appointmentId: import("imodel").FieldDefine<"uuid", false, true>;
52
59
  default: import("imodel").FieldDefine<"bool", false, false>;
53
60
  createdAt: import("imodel").FieldDefine<"timestamp", false, false>;
61
+ createdBy: import("imodel").FieldDefine<"uuid", false, true>;
54
62
  updatedAt: import("imodel").FieldDefine<"timestamp", false, false>;
63
+ updatedBy: import("imodel").FieldDefine<"uuid", false, true>;
55
64
  }, "organizationMember">;
56
65
  //#endregion
57
66
  //#region plugins/organization-rbac/models/OrganizationUserRole.d.mts
@@ -60,6 +69,7 @@ export declare const OrganizationUserRole: import("@yongdall/model").ModelTable<
60
69
  organizationId: import("imodel").FieldDefine<"uuid", false, false>;
61
70
  roleId: import("imodel").FieldDefine<"uuid", false, false>;
62
71
  createdAt: import("imodel").FieldDefine<"timestamp", false, false>;
72
+ createdBy: import("imodel").FieldDefine<"uuid", false, true>;
63
73
  }, "organizationUserRole">;
64
74
  //#endregion
65
75
  //#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-Bbuq32zd.mjs";
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-BDkqPng0.mjs";
2
2
  export { CompositeRole, OrganizationAppointment, OrganizationCompositeRole, OrganizationMember, OrganizationUserCompositeRole, OrganizationUserRole, getOrganizationAllPermissions, getOrganizationPermissions, getOrganizationRoleIds, getOrganizations };
@@ -1,6 +1,6 @@
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 } from "@yongdall/core";
3
+ import { ServerError, getModel, getUser } 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";
@@ -14,7 +14,7 @@ const OrganizationCompositeRole = createModel("organizationCompositeRole", {
14
14
  index: true,
15
15
  label: "复合角色",
16
16
  model: "compositeRole",
17
- renderer: "document",
17
+ renderer: ["compositeRole", "document"],
18
18
  immutable: true,
19
19
  primary: 1,
20
20
  bind: { mainOrganizationId: {
@@ -27,7 +27,7 @@ const OrganizationCompositeRole = createModel("organizationCompositeRole", {
27
27
  index: true,
28
28
  label: "组织",
29
29
  model: "organization",
30
- renderer: "document",
30
+ renderer: ["organization", "document"],
31
31
  immutable: true,
32
32
  primary: 2,
33
33
  source: { search: "mainId=?mainOrganizationId" }
@@ -37,7 +37,7 @@ const OrganizationCompositeRole = createModel("organizationCompositeRole", {
37
37
  index: true,
38
38
  label: "角色",
39
39
  model: "role",
40
- renderer: "document",
40
+ renderer: ["role", "document"],
41
41
  immutable: true,
42
42
  primary: 3
43
43
  }),
@@ -46,7 +46,7 @@ const OrganizationCompositeRole = createModel("organizationCompositeRole", {
46
46
  index: true,
47
47
  label: "主体组织",
48
48
  model: "organization",
49
- renderer: "document",
49
+ renderer: ["organization", "document"],
50
50
  immutable: true,
51
51
  layout: { hidden: true }
52
52
  }),
@@ -55,6 +55,13 @@ const OrganizationCompositeRole = createModel("organizationCompositeRole", {
55
55
  default: now,
56
56
  creating: now,
57
57
  label: "创建日期"
58
+ }),
59
+ createdBy: createField("uuid", {
60
+ nullable: true,
61
+ creating: { computed: () => getUser() },
62
+ label: "创建人",
63
+ model: "user",
64
+ renderer: ["user", "document"]
58
65
  })
59
66
  }, {
60
67
  permissions: [{
@@ -92,11 +99,9 @@ const OrganizationCompositeRole = createModel("organizationCompositeRole", {
92
99
  if (!mainOrganizationId) return;
93
100
  const organizationModel = await getModel("organization");
94
101
  if (organizationModel) {
95
- const [organization] = await useDatabase(organizationModel.databaseId).call(new Query(organizationModel).where({
96
- id: record.organizationId,
97
- mainId: mainOrganizationId
98
- }).limit(1));
102
+ const [organization] = await useDatabase(organizationModel.databaseId).call(new Query(organizationModel).where({ id: record.organizationId }).limit(1));
99
103
  if (!organization) throw new ServerError("请选择关联组织");
104
+ if (organization.mainId !== mainOrganizationId && organization.parentId !== mainOrganizationId) throw new ServerError("请选择关联组织");
100
105
  }
101
106
  const roleModel = await getModel("role");
102
107
  if (roleModel?.fields.open) {
@@ -128,7 +133,7 @@ const OrganizationUserCompositeRole = createModel("organizationUserCompositeRole
128
133
  index: true,
129
134
  label: "用户",
130
135
  model: "user",
131
- renderer: "document",
136
+ renderer: ["user", "document"],
132
137
  immutable: true,
133
138
  primary: 1
134
139
  }),
@@ -137,7 +142,7 @@ const OrganizationUserCompositeRole = createModel("organizationUserCompositeRole
137
142
  index: true,
138
143
  label: "组织",
139
144
  model: "organization",
140
- renderer: "document",
145
+ renderer: ["organization", "document"],
141
146
  immutable: true
142
147
  }),
143
148
  compositeRoleId: createField("uuid", {
@@ -145,7 +150,7 @@ const OrganizationUserCompositeRole = createModel("organizationUserCompositeRole
145
150
  index: true,
146
151
  label: "角色",
147
152
  model: "compositeRole",
148
- renderer: "document",
153
+ renderer: ["compositeRole", "document"],
149
154
  immutable: true,
150
155
  primary: 2
151
156
  }),
@@ -155,11 +160,25 @@ const OrganizationUserCompositeRole = createModel("organizationUserCompositeRole
155
160
  creating: now,
156
161
  label: "创建日期"
157
162
  }),
163
+ createdBy: createField("uuid", {
164
+ nullable: true,
165
+ creating: { computed: () => getUser() },
166
+ label: "创建人",
167
+ model: "user",
168
+ renderer: ["user", "document"]
169
+ }),
158
170
  updatedAt: createField("timestamp", {
159
171
  nullable: false,
160
172
  default: now,
161
173
  updating: now,
162
- label: "最后更新日期"
174
+ label: "更新日期"
175
+ }),
176
+ updatedBy: createField("uuid", {
177
+ nullable: true,
178
+ updating: { computed: () => getUser() },
179
+ label: "更新人",
180
+ model: "user",
181
+ renderer: ["user", "document"]
163
182
  })
164
183
  }, {
165
184
  database,
@@ -216,7 +235,7 @@ const CompositeRole = createModel("compositeRole", {
216
235
  index: true,
217
236
  label: "组织",
218
237
  model: "organization",
219
- renderer: "document",
238
+ renderer: ["organization", "document"],
220
239
  immutable: true,
221
240
  source: { search: "internal=0" }
222
241
  }),
@@ -230,11 +249,25 @@ const CompositeRole = createModel("compositeRole", {
230
249
  creating: now,
231
250
  label: "创建日期"
232
251
  }),
252
+ createdBy: createField("uuid", {
253
+ nullable: true,
254
+ creating: { computed: () => getUser() },
255
+ label: "创建人",
256
+ model: "user",
257
+ renderer: ["user", "document"]
258
+ }),
233
259
  updatedAt: createField("timestamp", {
234
260
  nullable: false,
235
261
  default: now,
236
262
  updating: now,
237
- label: "最后更新日期"
263
+ label: "更新日期"
264
+ }),
265
+ updatedBy: createField("uuid", {
266
+ nullable: true,
267
+ updating: { computed: () => getUser() },
268
+ label: "更新人",
269
+ model: "user",
270
+ renderer: ["user", "document"]
238
271
  })
239
272
  }, {
240
273
  database,
@@ -311,11 +344,25 @@ const OrganizationAppointment = createModel("organizationAppointment", {
311
344
  creating: now,
312
345
  label: "创建日期"
313
346
  }),
347
+ createdBy: createField("uuid", {
348
+ nullable: true,
349
+ creating: { computed: () => getUser() },
350
+ label: "创建人",
351
+ model: "user",
352
+ renderer: ["user", "document"]
353
+ }),
314
354
  updatedAt: createField("timestamp", {
315
355
  nullable: false,
316
356
  default: now,
317
357
  updating: now,
318
- label: "最后更新日期"
358
+ label: "更新日期"
359
+ }),
360
+ updatedBy: createField("uuid", {
361
+ nullable: true,
362
+ updating: { computed: () => getUser() },
363
+ label: "更新人",
364
+ model: "user",
365
+ renderer: ["user", "document"]
319
366
  })
320
367
  }, {
321
368
  database,
@@ -349,7 +396,7 @@ const OrganizationMember = createModel("organizationMember", {
349
396
  index: true,
350
397
  label: "用户",
351
398
  model: "user",
352
- renderer: "document",
399
+ renderer: ["user", "document"],
353
400
  immutable: true,
354
401
  layout: { rowSpan: 6 }
355
402
  }),
@@ -358,7 +405,7 @@ const OrganizationMember = createModel("organizationMember", {
358
405
  index: true,
359
406
  label: "组织",
360
407
  model: "organization",
361
- renderer: "document",
408
+ renderer: ["organization", "document"],
362
409
  immutable: true,
363
410
  layout: { rowSpan: 6 }
364
411
  }),
@@ -381,11 +428,25 @@ const OrganizationMember = createModel("organizationMember", {
381
428
  creating: now,
382
429
  label: "创建日期"
383
430
  }),
431
+ createdBy: createField("uuid", {
432
+ nullable: true,
433
+ creating: { computed: () => getUser() },
434
+ label: "创建人",
435
+ model: "user",
436
+ renderer: ["user", "document"]
437
+ }),
384
438
  updatedAt: createField("timestamp", {
385
439
  nullable: false,
386
440
  default: now,
387
441
  updating: now,
388
- label: "最后更新日期"
442
+ label: "更新日期"
443
+ }),
444
+ updatedBy: createField("uuid", {
445
+ nullable: true,
446
+ updating: { computed: () => getUser() },
447
+ label: "更新人",
448
+ model: "user",
449
+ renderer: ["user", "document"]
389
450
  })
390
451
  }, {
391
452
  database,
@@ -430,7 +491,7 @@ const OrganizationUserRole = createModel("organizationUserRole", {
430
491
  index: true,
431
492
  label: "用户",
432
493
  model: "user",
433
- renderer: "document",
494
+ renderer: ["user", "document"],
434
495
  immutable: true,
435
496
  primary: 1
436
497
  }),
@@ -439,7 +500,7 @@ const OrganizationUserRole = createModel("organizationUserRole", {
439
500
  index: true,
440
501
  label: "组织",
441
502
  model: "organization",
442
- renderer: "document",
503
+ renderer: ["organization", "document"],
443
504
  immutable: true,
444
505
  primary: 2
445
506
  }),
@@ -448,7 +509,7 @@ const OrganizationUserRole = createModel("organizationUserRole", {
448
509
  index: true,
449
510
  label: "角色",
450
511
  model: "role",
451
- renderer: "document",
512
+ renderer: ["role", "document"],
452
513
  immutable: true,
453
514
  primary: 3
454
515
  }),
@@ -457,6 +518,13 @@ const OrganizationUserRole = createModel("organizationUserRole", {
457
518
  default: now,
458
519
  creating: now,
459
520
  label: "创建日期"
521
+ }),
522
+ createdBy: createField("uuid", {
523
+ nullable: true,
524
+ creating: { computed: () => getUser() },
525
+ label: "创建人",
526
+ model: "user",
527
+ renderer: ["user", "document"]
460
528
  })
461
529
  }, {
462
530
  database,
@@ -506,4 +574,4 @@ const getOrganizationAllPermissions = createKeyStore(async (userId) => {
506
574
  //#endregion
507
575
  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
576
 
509
- //# sourceMappingURL=organization-rbac-Bbuq32zd.mjs.map
577
+ //# sourceMappingURL=organization-rbac-BDkqPng0.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organization-rbac-BDkqPng0.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, getUser, 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: ['compositeRole', '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: ['organization', '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: ['role', 'document'], immutable: true, primary: 3 }),\n\tmainOrganizationId: createField('uuid', { nullable: false, index: true, label: '主体组织', model: 'organization', renderer: ['organization', 'document'], immutable: true, layout: {hidden: true} }),\n\n\tcreatedAt: createField('timestamp', { nullable: false, default: now, creating: now, label: '创建日期' }),\n\tcreatedBy: createField('uuid', { nullable: true, creating: { computed: () => getUser() }, label: '创建人', model: 'user', renderer: ['user', 'document'] }),\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 }).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\t\t\t\tif (organization.mainId !== mainOrganizationId && organization.parentId !== mainOrganizationId) {\n\t\t\t\t\tthrow new ServerError('请选择关联组织');\n\t\t\t\t}\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 { getUser, 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: ['user', 'document'], immutable: true, primary: 1 }),\n\torganizationId: createField('uuid', { nullable: false, index: true, label: '组织', model: 'organization', renderer: ['organization', 'document'], immutable: true }),\n\tcompositeRoleId: createField('uuid', { nullable: false, index: true, label: '角色', model: 'compositeRole', renderer: ['compositeRole', 'document'], immutable: true, primary: 2 }),\n\n\tcreatedAt: createField('timestamp', { nullable: false, default: now, creating: now, label: '创建日期' }),\n\tcreatedBy: createField('uuid', { nullable: true, creating: { computed: () => getUser() }, label: '创建人', model: 'user', renderer: ['user', 'document'] }),\n\tupdatedAt: createField('timestamp', { nullable: false, default: now, updating: now, label: '更新日期' }),\n\tupdatedBy: createField('uuid', { nullable: true, updating: { computed: () => getUser() }, label: '更新人', model: 'user', renderer: ['user', 'document'] }),\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, getUser, 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: ['organization', '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\tcreatedBy: createField('uuid', { nullable: true, creating: { computed: () => getUser() }, label: '创建人', model: 'user', renderer: ['user', 'document'] }),\n\tupdatedAt: createField('timestamp', { nullable: false, default: now, updating: now, label: '更新日期' }),\n\tupdatedBy: createField('uuid', { nullable: true, updating: { computed: () => getUser() }, label: '更新人', model: 'user', renderer: ['user', 'document'] }),\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';\nimport { getUser } from '@yongdall/core';\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: ['role', '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\tcreatedBy: createField('uuid', { nullable: true, creating: { computed: () => getUser() }, label: '创建人', model: 'user', renderer: ['user', 'document'] }),\n\tupdatedAt: createField('timestamp', { nullable: false, default: now, updating: now, label: '更新日期' }),\n\tupdatedBy: createField('uuid', { nullable: true, updating: { computed: () => getUser() }, label: '更新人', model: 'user', renderer: ['user', 'document'] }),\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';\nimport { getUser } from '@yongdall/core';\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: ['user', 'document'], immutable: true, layout: { rowSpan: 6 } }),\n\torganizationId: createField('uuid', { nullable: false, index: true, label: '组织', model: 'organization', renderer: ['organization', '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\tcreatedBy: createField('uuid', { nullable: true, creating: { computed: () => getUser() }, label: '创建人', model: 'user', renderer: ['user', 'document'] }),\n\tupdatedAt: createField('timestamp', { nullable: false, default: now, updating: now, label: '更新日期' }),\n\tupdatedBy: createField('uuid', { nullable: true, updating: { computed: () => getUser() }, label: '更新人', model: 'user', renderer: ['user', 'document'] }),\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';\nimport { getUser } from '@yongdall/core';\n\nexport const OrganizationUserRole = createModel('organizationUserRole', {\n\tuserId: createField('uuid', { nullable: false, index: true, label: '用户', model: 'user', renderer: ['user', 'document'], immutable: true, primary: 1 }),\n\torganizationId: createField('uuid', { nullable: false, index: true, label: '组织', model: 'organization', renderer: ['organization', 'document'], immutable: true, primary: 2 }),\n\troleId: createField('uuid', { nullable: false, index: true, label: '角色', model: 'role', renderer: ['role', 'document'], immutable: true, primary: 3 }),\n\n\n\tcreatedAt: createField('timestamp', { nullable: false, default: now, creating: now, label: '创建日期' }),\n\tcreatedBy: createField('uuid', { nullable: true, creating: { computed: () => getUser() }, label: '创建人', model: 'user', renderer: ['user', 'document'] }),\n\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;CACjF,iBAAiB,YAAY,QAAQ;EAAE,UAAU;EAAO,OAAO;EAAM,OAAO;EAAQ,OAAO;EAAiB,UAAU,CAAC,iBAAiB,UAAU;EAAG,WAAW;EAAM,SAAS;EAAG,MAAM,EACvL,oBAAoB;GAAE,QAAQ;GAAkB,OAAO;EA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K,KAAK,MAAM,CAAC,CAAC,CAAC;EAC1D,IAAI,CAAC,EAAE,MAAQ;EACf,YAAY,gBAAgB;CAC7B;CACA,OAAO;AACR,IAAG,SAAQ,QAAQ,EAAE;AAIrB,MAAa,gCAAgC,eAAe,OAAO,WAA0B;CAC5F,MAAM,IAAI,MAAM,2BAA2B,MAAM;CACjD,OAAO,IAAI,IAAI,OAAO,OAAO,CAAC,CAAC,CAAC,SAAQ,MAAK,CAAC,GAAG,CAAC,CAAC,CAAC;AACrD,IAAG,SAAQ,QAAQ,EAAE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yongdall/organization-rbac",
3
- "version": "0.7.1",
3
+ "version": "0.7.4",
4
4
  "type": "module",
5
5
  "main": "./index.mjs",
6
6
  "exports": {
@@ -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-Bbuq32zd.mjs";
1
+ import { a as OrganizationUserRole, c as CompositeRole, l as OrganizationUserCompositeRole, o as OrganizationMember, s as OrganizationAppointment, u as OrganizationCompositeRole } from "../organization-rbac-BDkqPng0.mjs";
2
2
  //#region plugins/organization-rbac/yongdall/migration.mts
3
3
  const models = [
4
4
  OrganizationAppointment,
@@ -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-Bbuq32zd.mjs";
1
+ import { a as OrganizationUserRole, c as CompositeRole, l as OrganizationUserCompositeRole, o as OrganizationMember, s as OrganizationAppointment, u as OrganizationCompositeRole } from "../organization-rbac-BDkqPng0.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-Bbuq32zd.mjs";
1
+ import { n as getOrganizationPermissions, t as getOrganizationAllPermissions } from "../organization-rbac-BDkqPng0.mjs";
2
2
  export { getOrganizationAllPermissions, getOrganizationPermissions };
@@ -1 +0,0 @@
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;CACjF,iBAAiB,YAAY,QAAQ;EAAE,UAAU;EAAO,OAAO;EAAM,OAAO;EAAQ,OAAO;EAAiB,UAAU;EAAY,WAAW;EAAM,SAAS;EAAG,MAAM,EACpK,oBAAoB;GAAE,QAAQ;GAAkB,OAAO;EAAK,EAC7D;CAAE,CAAC;CACH,gBAAgB,YAAY,QAAQ;EAAE,UAAU;EAAO,OAAO;EAAM,OAAO;EAAM,OAAO;EAAgB,UAAU;EAAY,WAAW;EAAM,SAAS;EAAG,QAAQ,EAClK,QAAQ,6BACT;CAAE,CAAC;CACH,QAAQ,YAAY,QAAQ;EAAE,UAAU;EAAO,OAAO;EAAM,OAAO;EAAM,OAAO;EAAQ,UAAU;EAAY,WAAW;EAAM,SAAS;CAAE,CAAC;CAC3I,oBAAoB,YAAY,QAAQ;EAAE,UAAU;EAAO,OAAO;EAAM,OAAO;EAAQ,OAAO;EAAgB,UAAU;EAAY,WAAW;EAAM,QAAQ,EAAC,QAAQ,KAAI;CAAE,CAAC;CAE7K,WAAW,YAAY,aAAa;EAAE,UAAU;EAAO,SAAS;EAAK,UAAU;EAAK,OAAO;CAAO,CAAC;AACpG,GAAG;CAEF,aAAa,CACZ;EAAE,YAAY;EAAwB,QAAQ,CAAC,GAAG;EAA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