@nocobase/plugin-acl 1.2.13-alpha → 1.3.0-alpha.20240710084543

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.
Files changed (67) hide show
  1. package/package.json +2 -2
  2. package/dist/client/NewRole.d.ts +0 -10
  3. package/dist/client/RolesManagement.d.ts +0 -10
  4. package/dist/client/RolesManagerProvider.d.ts +0 -13
  5. package/dist/client/RolesMenu.d.ts +0 -15
  6. package/dist/client/hooks/load-more-observer.d.ts +0 -15
  7. package/dist/client/index.d.ts +0 -16
  8. package/dist/client/index.js +0 -18
  9. package/dist/client/locale.d.ts +0 -9
  10. package/dist/client/permissions/ActionPermissions.d.ts +0 -12
  11. package/dist/client/permissions/AvailableActions.d.ts +0 -11
  12. package/dist/client/permissions/GeneralPermissions.d.ts +0 -12
  13. package/dist/client/permissions/MenuItemsProvider.d.ts +0 -12
  14. package/dist/client/permissions/MenuPermissions.d.ts +0 -12
  15. package/dist/client/permissions/Permissions.d.ts +0 -12
  16. package/dist/client/permissions/PluginPermissions.d.ts +0 -12
  17. package/dist/client/permissions/RolesResourcesActions.d.ts +0 -11
  18. package/dist/client/permissions/ScopeSelect.d.ts +0 -11
  19. package/dist/client/permissions/StrategyActions.d.ts +0 -10
  20. package/dist/client/permissions/style.d.ts +0 -9
  21. package/dist/client/roles-manager.d.ts +0 -18
  22. package/dist/client/schemas/roles.d.ts +0 -63
  23. package/dist/client/schemas/scopes.d.ts +0 -75
  24. package/dist/externalVersion.js +0 -31
  25. package/dist/index.d.ts +0 -10
  26. package/dist/index.js +0 -48
  27. package/dist/locale/en-US.json +0 -6
  28. package/dist/locale/ko_KR.json +0 -4
  29. package/dist/locale/zh-CN.json +0 -11
  30. package/dist/server/actions/available-actions.d.ts +0 -15
  31. package/dist/server/actions/available-actions.js +0 -51
  32. package/dist/server/actions/role-check.d.ts +0 -9
  33. package/dist/server/actions/role-check.js +0 -76
  34. package/dist/server/actions/role-collections.d.ts +0 -15
  35. package/dist/server/actions/role-collections.js +0 -84
  36. package/dist/server/actions/user-setDefaultRole.d.ts +0 -10
  37. package/dist/server/actions/user-setDefaultRole.js +0 -74
  38. package/dist/server/collections/roles-users.d.ts +0 -10
  39. package/dist/server/collections/roles-users.js +0 -39
  40. package/dist/server/collections/roles.d.ts +0 -10
  41. package/dist/server/collections/roles.js +0 -128
  42. package/dist/server/collections/rolesResources.d.ts +0 -10
  43. package/dist/server/collections/rolesResources.js +0 -64
  44. package/dist/server/collections/rolesResourcesActions.d.ts +0 -10
  45. package/dist/server/collections/rolesResourcesActions.js +0 -60
  46. package/dist/server/collections/rolesResourcesScopes.d.ts +0 -10
  47. package/dist/server/collections/rolesResourcesScopes.js +0 -54
  48. package/dist/server/collections/users.d.ts +0 -14
  49. package/dist/server/collections/users.js +0 -61
  50. package/dist/server/index.d.ts +0 -13
  51. package/dist/server/index.js +0 -56
  52. package/dist/server/middlewares/setCurrentRole.d.ts +0 -10
  53. package/dist/server/middlewares/setCurrentRole.js +0 -86
  54. package/dist/server/middlewares/with-acl-meta.d.ts +0 -10
  55. package/dist/server/middlewares/with-acl-meta.js +0 -255
  56. package/dist/server/migrations/20221214072638-set-role-snippets.d.ts +0 -14
  57. package/dist/server/migrations/20221214072638-set-role-snippets.js +0 -53
  58. package/dist/server/model/RoleModel.d.ts +0 -16
  59. package/dist/server/model/RoleModel.js +0 -55
  60. package/dist/server/model/RoleResourceActionModel.d.ts +0 -17
  61. package/dist/server/model/RoleResourceActionModel.js +0 -53
  62. package/dist/server/model/RoleResourceModel.d.ts +0 -20
  63. package/dist/server/model/RoleResourceModel.js +0 -72
  64. package/dist/server/server.d.ts +0 -24
  65. package/dist/server/server.js +0 -552
  66. package/dist/swagger/index.d.ts +0 -374
  67. package/dist/swagger/index.js +0 -404
@@ -1,552 +0,0 @@
1
- /**
2
- * This file is part of the NocoBase (R) project.
3
- * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
- * Authors: NocoBase Team.
5
- *
6
- * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
- * For more information, please refer to: https://www.nocobase.com/agreement.
8
- */
9
-
10
- var __create = Object.create;
11
- var __defProp = Object.defineProperty;
12
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
13
- var __getOwnPropNames = Object.getOwnPropertyNames;
14
- var __getProtoOf = Object.getPrototypeOf;
15
- var __hasOwnProp = Object.prototype.hasOwnProperty;
16
- var __export = (target, all) => {
17
- for (var name in all)
18
- __defProp(target, name, { get: all[name], enumerable: true });
19
- };
20
- var __copyProps = (to, from, except, desc) => {
21
- if (from && typeof from === "object" || typeof from === "function") {
22
- for (let key of __getOwnPropNames(from))
23
- if (!__hasOwnProp.call(to, key) && key !== except)
24
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
25
- }
26
- return to;
27
- };
28
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
29
- // If the importer is in node compatibility mode or this is not an ESM
30
- // file that has been converted to a CommonJS file using a Babel-
31
- // compatible transform (i.e. "__esModule" has not been set), then set
32
- // "default" to the CommonJS "module.exports" for node compatibility.
33
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
34
- mod
35
- ));
36
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
37
- var server_exports = {};
38
- __export(server_exports, {
39
- PluginACLServer: () => PluginACLServer,
40
- default: () => server_default
41
- });
42
- module.exports = __toCommonJS(server_exports);
43
- var import_actions = require("@nocobase/actions");
44
- var import_database = require("@nocobase/database");
45
- var import_server = require("@nocobase/server");
46
- var import_async_mutex = require("async-mutex");
47
- var import_lodash = __toESM(require("lodash"));
48
- var import_path = require("path");
49
- var import_available_actions = require("./actions/available-actions");
50
- var import_role_check = require("./actions/role-check");
51
- var import_role_collections = require("./actions/role-collections");
52
- var import_user_setDefaultRole = require("./actions/user-setDefaultRole");
53
- var import_setCurrentRole = require("./middlewares/setCurrentRole");
54
- var import_with_acl_meta = require("./middlewares/with-acl-meta");
55
- var import_RoleModel = require("./model/RoleModel");
56
- var import_RoleResourceActionModel = require("./model/RoleResourceActionModel");
57
- var import_RoleResourceModel = require("./model/RoleResourceModel");
58
- class PluginACLServer extends import_server.Plugin {
59
- get acl() {
60
- return this.app.acl;
61
- }
62
- async writeResourceToACL(resourceModel, transaction) {
63
- await resourceModel.writeToACL({
64
- acl: this.acl,
65
- transaction
66
- });
67
- }
68
- async writeActionToACL(actionModel, transaction) {
69
- const resource = actionModel.get("resource");
70
- const role = this.acl.getRole(resource.get("roleName"));
71
- await actionModel.writeToACL({
72
- acl: this.acl,
73
- role,
74
- resourceName: resource.get("name")
75
- });
76
- }
77
- async writeRolesToACL(options) {
78
- const roles = await this.app.db.getRepository("roles").find({
79
- appends: ["resources", "resources.actions"]
80
- });
81
- for (const role of roles) {
82
- await this.writeRoleToACL(role, options);
83
- }
84
- }
85
- async writeRoleToACL(role, options = {}) {
86
- const transaction = options == null ? void 0 : options.transaction;
87
- role.writeToAcl({ acl: this.acl, withOutStrategy: true });
88
- if (options.withOutResources) {
89
- return;
90
- }
91
- let resources = role.get("resources");
92
- if (!resources) {
93
- resources = await role.getResources({ transaction });
94
- }
95
- for (const resource of resources) {
96
- await this.writeResourceToACL(resource, transaction);
97
- }
98
- }
99
- async beforeLoad() {
100
- this.db.addMigrations({
101
- namespace: this.name,
102
- directory: (0, import_path.resolve)(__dirname, "./migrations"),
103
- context: {
104
- plugin: this
105
- }
106
- });
107
- this.app.db.registerModels({
108
- RoleResourceActionModel: import_RoleResourceActionModel.RoleResourceActionModel,
109
- RoleResourceModel: import_RoleResourceModel.RoleResourceModel,
110
- RoleModel: import_RoleModel.RoleModel
111
- });
112
- this.app.acl.registerSnippet({
113
- name: `pm.${this.name}.roles`,
114
- actions: [
115
- "roles:*",
116
- "roles.snippets:*",
117
- "availableActions:list",
118
- "roles.collections:list",
119
- "roles.resources:*",
120
- "uiSchemas:getProperties",
121
- "roles.menuUiSchemas:*",
122
- "roles.users:*",
123
- "dataSources.roles:*",
124
- "dataSources:list",
125
- "roles.dataSourcesCollections:*",
126
- "roles.dataSourceResources:*",
127
- "dataSourcesRolesResourcesScopes:*",
128
- "rolesResourcesScopes:*"
129
- ]
130
- });
131
- this.app.acl.beforeGrantAction((ctx) => {
132
- const actionName = this.app.acl.resolveActionAlias(ctx.actionName);
133
- const collection = this.app.db.getCollection(ctx.resourceName);
134
- if (!collection) {
135
- return;
136
- }
137
- const fieldsParams = ctx.params.fields;
138
- if (!fieldsParams) {
139
- return;
140
- }
141
- if (actionName == "view" || actionName == "export") {
142
- const associationsFields = fieldsParams.filter((fieldName) => {
143
- const field = collection.getField(fieldName);
144
- return field instanceof import_database.RelationField;
145
- });
146
- ctx.params = {
147
- ...ctx.params,
148
- fields: import_lodash.default.difference(fieldsParams, associationsFields),
149
- appends: associationsFields
150
- };
151
- }
152
- });
153
- this.app.resourcer.define(import_available_actions.availableActionResource);
154
- this.app.resourcer.define(import_role_collections.roleCollectionsResource);
155
- this.app.resourcer.registerActionHandler("roles:check", import_role_check.checkAction);
156
- this.app.resourcer.registerActionHandler(`users:setDefaultRole`, import_user_setDefaultRole.setDefaultRole);
157
- this.db.on("users.afterCreateWithAssociations", async (model, options) => {
158
- const { transaction } = options;
159
- const repository = this.app.db.getRepository("roles");
160
- const defaultRole = await repository.findOne({
161
- filter: {
162
- default: true
163
- },
164
- transaction
165
- });
166
- if (defaultRole && await model.countRoles({ transaction }) == 0) {
167
- await model.addRoles(defaultRole, { transaction });
168
- }
169
- });
170
- this.app.on("acl:writeRoleToACL", async (roleModel) => {
171
- await this.writeRoleToACL(roleModel, {
172
- withOutResources: true
173
- });
174
- await this.app.db.getRepository("dataSourcesRoles").updateOrCreate({
175
- values: {
176
- roleName: roleModel.get("name"),
177
- dataSourceKey: "main",
178
- strategy: roleModel.get("strategy")
179
- },
180
- filterKeys: ["roleName", "dataSourceKey"]
181
- });
182
- });
183
- this.app.db.on("roles.afterSaveWithAssociations", async (model, options) => {
184
- const { transaction } = options;
185
- await this.writeRoleToACL(model, {
186
- withOutResources: true
187
- });
188
- await this.app.db.getRepository("dataSourcesRoles").updateOrCreate({
189
- values: {
190
- roleName: model.get("name"),
191
- dataSourceKey: "main",
192
- strategy: model.get("strategy")
193
- },
194
- filterKeys: ["roleName", "dataSourceKey"],
195
- transaction
196
- });
197
- await this.app.emitAsync("acl:writeResources", {
198
- roleName: model.get("name"),
199
- transaction
200
- });
201
- if (model.get("default")) {
202
- await this.app.db.getRepository("roles").update({
203
- values: {
204
- default: false
205
- },
206
- filter: {
207
- "name.$ne": model.get("name")
208
- },
209
- hooks: false,
210
- transaction
211
- });
212
- }
213
- });
214
- this.app.db.on("roles.afterDestroy", (model) => {
215
- const roleName = model.get("name");
216
- this.acl.removeRole(roleName);
217
- });
218
- this.app.db.on("rolesResources.afterSaveWithAssociations", async (model, options) => {
219
- await this.writeResourceToACL(model, options.transaction);
220
- });
221
- this.app.db.on("rolesResourcesActions.afterUpdateWithAssociations", async (model, options) => {
222
- const { transaction } = options;
223
- const resource = await model.getResource({
224
- transaction
225
- });
226
- await this.writeResourceToACL(resource, transaction);
227
- });
228
- this.app.db.on("collections.afterDestroy", async (model, options) => {
229
- const { transaction } = options;
230
- await this.app.db.getRepository("dataSourcesRolesResources").destroy({
231
- filter: {
232
- name: model.get("name"),
233
- dataSourceKey: "main"
234
- },
235
- transaction
236
- });
237
- });
238
- this.app.db.on("fields.afterCreate", async (model, options) => {
239
- const { transaction } = options;
240
- const collectionName = model.get("collectionName");
241
- const fieldName = model.get("name");
242
- const resourceActions = await this.app.db.getRepository("dataSourcesRolesResourcesActions").find({
243
- filter: {
244
- "resource.name": collectionName,
245
- "resource.dataSourceKey": "main"
246
- },
247
- transaction,
248
- appends: ["resource"]
249
- });
250
- for (const resourceAction of resourceActions) {
251
- const fields = resourceAction.get("fields");
252
- const newFields = [...fields, fieldName];
253
- await this.app.db.getRepository("dataSourcesRolesResourcesActions").update({
254
- filterByTk: resourceAction.get("id"),
255
- values: {
256
- fields: newFields
257
- },
258
- transaction
259
- });
260
- }
261
- });
262
- const mutex = new import_async_mutex.Mutex();
263
- this.app.db.on("fields.afterDestroy", async (model, options) => {
264
- await mutex.runExclusive(async () => {
265
- const collectionName = model.get("collectionName");
266
- const fieldName = model.get("name");
267
- const resourceActions = await this.app.db.getRepository("dataSourcesRolesResourcesActions").find({
268
- filter: {
269
- "resource.name": collectionName,
270
- "fields.$anyOf": [fieldName],
271
- "resource.dataSourceKey": "main"
272
- },
273
- transaction: options.transaction
274
- });
275
- for (const resourceAction of resourceActions) {
276
- const fields = resourceAction.get("fields");
277
- const newFields = fields.filter((field) => field != fieldName);
278
- await this.app.db.getRepository("dataSourcesRolesResourcesActions").update({
279
- filterByTk: resourceAction.get("id"),
280
- values: {
281
- fields: newFields
282
- },
283
- transaction: options.transaction
284
- });
285
- }
286
- });
287
- });
288
- this.app.db.on("rolesUsers.afterSave", async (model) => {
289
- const cache = this.app.cache;
290
- await cache.del(`roles:${model.get("userId")}`);
291
- });
292
- this.app.db.on("rolesUsers.afterDestroy", async (model) => {
293
- const cache = this.app.cache;
294
- await cache.del(`roles:${model.get("userId")}`);
295
- });
296
- const writeRolesToACL = async (app, options) => {
297
- const exists = await this.app.db.collectionExistsInDb("roles");
298
- if (exists) {
299
- this.log.info("write roles to ACL", { method: "writeRolesToACL" });
300
- await this.writeRolesToACL(options);
301
- }
302
- };
303
- this.app.on("afterStart", async () => {
304
- await writeRolesToACL(this.app, {
305
- withOutResources: true
306
- });
307
- });
308
- this.app.on("afterInstallPlugin", async (plugin) => {
309
- if (plugin.getName() !== "users") {
310
- return;
311
- }
312
- const User = this.db.getCollection("users");
313
- await User.repository.update({
314
- values: {
315
- roles: ["root", "admin", "member"]
316
- },
317
- forceUpdate: true
318
- });
319
- const RolesUsers = this.db.getCollection("rolesUsers");
320
- await RolesUsers.repository.update({
321
- filter: {
322
- userId: 1,
323
- roleName: "root"
324
- },
325
- values: {
326
- default: true
327
- }
328
- });
329
- });
330
- this.app.on("beforeInstallPlugin", async (plugin) => {
331
- if (plugin.getName() !== "users") {
332
- return;
333
- }
334
- const roles = this.app.db.getRepository("roles");
335
- await roles.createMany({
336
- records: [
337
- {
338
- name: "root",
339
- title: '{{t("Root")}}',
340
- hidden: true,
341
- snippets: ["ui.*", "pm", "pm.*"]
342
- },
343
- {
344
- name: "admin",
345
- title: '{{t("Admin")}}',
346
- allowConfigure: true,
347
- allowNewMenu: true,
348
- strategy: { actions: ["create", "view", "update", "destroy"] },
349
- snippets: ["ui.*", "pm", "pm.*"]
350
- },
351
- {
352
- name: "member",
353
- title: '{{t("Member")}}',
354
- allowNewMenu: true,
355
- strategy: { actions: ["view", "update:own", "destroy:own", "create"] },
356
- default: true,
357
- snippets: ["!ui.*", "!pm", "!pm.*"]
358
- }
359
- ]
360
- });
361
- const rolesResourcesScopes = this.app.db.getRepository("dataSourcesRolesResourcesScopes");
362
- await rolesResourcesScopes.createMany({
363
- records: [
364
- {
365
- key: "all",
366
- name: '{{t("All records")}}',
367
- scope: {}
368
- },
369
- {
370
- key: "own",
371
- name: '{{t("Own records")}}',
372
- scope: {
373
- createdById: "{{ ctx.state.currentUser.id }}"
374
- }
375
- }
376
- ]
377
- });
378
- });
379
- this.app.on("beforeSignOut", ({ userId }) => {
380
- this.app.cache.del(`roles:${userId}`);
381
- });
382
- this.app.resourcer.use(import_setCurrentRole.setCurrentRole, { tag: "setCurrentRole", before: "acl", after: "auth" });
383
- this.app.acl.allow("users", "setDefaultRole", "loggedIn");
384
- this.app.acl.allow("roles", "check", "loggedIn");
385
- this.app.acl.allow("*", "*", (ctx) => {
386
- return ctx.state.currentRole === "root";
387
- });
388
- this.app.acl.addFixedParams("collections", "destroy", () => {
389
- return {
390
- filter: {
391
- $and: [{ "name.$ne": "roles" }, { "name.$ne": "rolesUsers" }]
392
- }
393
- };
394
- });
395
- this.app.acl.addFixedParams("rolesResourcesScopes", "destroy", () => {
396
- return {
397
- filter: {
398
- $and: [{ "key.$ne": "all" }, { "key.$ne": "own" }]
399
- }
400
- };
401
- });
402
- this.app.acl.addFixedParams("rolesResourcesScopes", "update", () => {
403
- return {
404
- filter: {
405
- $and: [{ "key.$ne": "all" }, { "key.$ne": "own" }]
406
- }
407
- };
408
- });
409
- this.app.acl.addFixedParams("roles", "destroy", () => {
410
- return {
411
- filter: {
412
- $and: [{ "name.$ne": "root" }, { "name.$ne": "admin" }, { "name.$ne": "member" }]
413
- }
414
- };
415
- });
416
- this.app.resourcer.use(async (ctx, next) => {
417
- const { actionName, resourceName, params } = ctx.action;
418
- const { showAnonymous } = params || {};
419
- if (actionName === "list" && resourceName === "roles") {
420
- if (!showAnonymous) {
421
- ctx.action.mergeParams({
422
- filter: {
423
- "name.$ne": "anonymous"
424
- }
425
- });
426
- }
427
- }
428
- if (actionName === "update" && resourceName === "roles.resources") {
429
- ctx.action.mergeParams({
430
- updateAssociationValues: ["actions"]
431
- });
432
- }
433
- await next();
434
- });
435
- this.app.acl.use(async (ctx, next) => {
436
- var _a, _b, _c, _d, _e;
437
- const { actionName, resourceName } = ctx.action;
438
- if (actionName === "get" || actionName === "list") {
439
- if (!Array.isArray((_c = (_b = (_a = ctx == null ? void 0 : ctx.permission) == null ? void 0 : _a.can) == null ? void 0 : _b.params) == null ? void 0 : _c.fields)) {
440
- return next();
441
- }
442
- let collection;
443
- if (resourceName.includes(".")) {
444
- const [collectionName, associationName] = resourceName.split(".");
445
- const field = (_e = (_d = ctx.db.getCollection(collectionName)) == null ? void 0 : _d.getField) == null ? void 0 : _e.call(_d, associationName);
446
- if (field.target) {
447
- collection = ctx.db.getCollection(field.target);
448
- }
449
- } else {
450
- collection = ctx.db.getCollection(resourceName);
451
- }
452
- if (collection && collection.hasField("createdById")) {
453
- ctx.permission.can.params.fields.push("createdById");
454
- }
455
- }
456
- return next();
457
- });
458
- const parseJsonTemplate = this.app.acl.parseJsonTemplate;
459
- this.app.acl.beforeGrantAction(async (ctx) => {
460
- const actionName = this.app.acl.resolveActionAlias(ctx.actionName);
461
- if (import_lodash.default.isPlainObject(ctx.params)) {
462
- if (actionName === "view" && ctx.params.fields) {
463
- const appendFields = [];
464
- const collection = this.app.db.getCollection(ctx.resourceName);
465
- if (!collection) {
466
- return;
467
- }
468
- if (collection.model.primaryKeyAttribute) {
469
- appendFields.push(collection.model.primaryKeyAttribute);
470
- }
471
- if (collection.model.rawAttributes["createdAt"]) {
472
- appendFields.push("createdAt");
473
- }
474
- if (collection.model.rawAttributes["updatedAt"]) {
475
- appendFields.push("updatedAt");
476
- }
477
- ctx.params = {
478
- ...import_lodash.default.omit(ctx.params, "fields"),
479
- fields: [...ctx.params.fields, ...appendFields]
480
- };
481
- }
482
- }
483
- });
484
- this.app.acl.use(
485
- async (ctx, next) => {
486
- var _a, _b;
487
- const action = (_b = (_a = ctx.permission) == null ? void 0 : _a.can) == null ? void 0 : _b.action;
488
- if (action == "destroy" && !ctx.action.resourceName.includes(".")) {
489
- const repository = import_actions.utils.getRepositoryFromParams(ctx);
490
- if (!repository) {
491
- await next();
492
- return;
493
- }
494
- const filteredCount = await repository.count(ctx.permission.mergedParams);
495
- const queryCount = await repository.count(ctx.permission.rawParams);
496
- if (queryCount > filteredCount) {
497
- ctx.throw(403, "No permissions");
498
- return;
499
- }
500
- }
501
- await next();
502
- },
503
- {
504
- after: "core",
505
- group: "after"
506
- }
507
- );
508
- const withACLMeta = (0, import_with_acl_meta.createWithACLMetaMiddleware)();
509
- this.app.use(
510
- async (ctx, next) => {
511
- try {
512
- await withACLMeta(ctx, next);
513
- } catch (error) {
514
- ctx.logger.error(error);
515
- }
516
- },
517
- { after: "dataSource", group: "with-acl-meta" }
518
- );
519
- this.db.on("afterUpdateCollection", async (collection) => {
520
- if (collection.options.loadedFromCollectionManager || collection.options.asStrategyResource) {
521
- this.app.acl.appendStrategyResource(collection.name);
522
- }
523
- });
524
- this.db.on("afterDefineCollection", async (collection) => {
525
- if (collection.options.loadedFromCollectionManager || collection.options.asStrategyResource) {
526
- this.app.acl.appendStrategyResource(collection.name);
527
- }
528
- });
529
- this.db.on("afterRemoveCollection", (collection) => {
530
- this.app.acl.removeStrategyResource(collection.name);
531
- });
532
- }
533
- async install() {
534
- const repo = this.db.getRepository("collections");
535
- if (repo) {
536
- await repo.db2cm("roles");
537
- }
538
- }
539
- async load() {
540
- await this.importCollections((0, import_path.resolve)(__dirname, "collections"));
541
- this.db.extendCollection({
542
- name: "rolesUischemas",
543
- dumpRules: "required",
544
- origin: this.options.packageName
545
- });
546
- }
547
- }
548
- var server_default = PluginACLServer;
549
- // Annotate the CommonJS export names for ESM import in node:
550
- 0 && (module.exports = {
551
- PluginACLServer
552
- });