@nocobase/plugin-acl 1.2.12-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,55 +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 __defProp = Object.defineProperty;
11
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
- var __getOwnPropNames = Object.getOwnPropertyNames;
13
- var __hasOwnProp = Object.prototype.hasOwnProperty;
14
- var __export = (target, all) => {
15
- for (var name in all)
16
- __defProp(target, name, { get: all[name], enumerable: true });
17
- };
18
- var __copyProps = (to, from, except, desc) => {
19
- if (from && typeof from === "object" || typeof from === "function") {
20
- for (let key of __getOwnPropNames(from))
21
- if (!__hasOwnProp.call(to, key) && key !== except)
22
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
- }
24
- return to;
25
- };
26
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
- var RoleModel_exports = {};
28
- __export(RoleModel_exports, {
29
- RoleModel: () => RoleModel
30
- });
31
- module.exports = __toCommonJS(RoleModel_exports);
32
- var import_database = require("@nocobase/database");
33
- class RoleModel extends import_database.Model {
34
- writeToAcl(options) {
35
- const { acl } = options;
36
- const roleName = this.get("name");
37
- let role = acl.getRole(roleName);
38
- if (!role) {
39
- role = acl.define({
40
- role: roleName
41
- });
42
- }
43
- if (options.withOutStrategy !== true) {
44
- role.setStrategy({
45
- ...this.get("strategy") || {},
46
- allowConfigure: this.get("allowConfigure")
47
- });
48
- }
49
- role.snippets = new Set(this.get("snippets"));
50
- }
51
- }
52
- // Annotate the CommonJS export names for ESM import in node:
53
- 0 && (module.exports = {
54
- RoleModel
55
- });
@@ -1,17 +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
- import { ACL, ACLRole } from '@nocobase/acl';
10
- import { Model } from '@nocobase/database';
11
- export declare class RoleResourceActionModel extends Model {
12
- writeToACL(options: {
13
- acl: ACL;
14
- role: ACLRole;
15
- resourceName: string;
16
- }): Promise<void>;
17
- }
@@ -1,53 +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 __defProp = Object.defineProperty;
11
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
- var __getOwnPropNames = Object.getOwnPropertyNames;
13
- var __hasOwnProp = Object.prototype.hasOwnProperty;
14
- var __export = (target, all) => {
15
- for (var name in all)
16
- __defProp(target, name, { get: all[name], enumerable: true });
17
- };
18
- var __copyProps = (to, from, except, desc) => {
19
- if (from && typeof from === "object" || typeof from === "function") {
20
- for (let key of __getOwnPropNames(from))
21
- if (!__hasOwnProp.call(to, key) && key !== except)
22
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
- }
24
- return to;
25
- };
26
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
- var RoleResourceActionModel_exports = {};
28
- __export(RoleResourceActionModel_exports, {
29
- RoleResourceActionModel: () => RoleResourceActionModel
30
- });
31
- module.exports = __toCommonJS(RoleResourceActionModel_exports);
32
- var import_database = require("@nocobase/database");
33
- class RoleResourceActionModel extends import_database.Model {
34
- async writeToACL(options) {
35
- const { resourceName, role } = options;
36
- const actionName = this.get("name");
37
- const fields = this.get("fields");
38
- const actionPath = `${resourceName}:${actionName}`;
39
- const actionParams = {
40
- fields
41
- };
42
- const scope = await this.getScope();
43
- if (scope) {
44
- actionParams["own"] = scope.get("key") === "own";
45
- actionParams["filter"] = scope.get("scope");
46
- }
47
- role.grantAction(actionPath, actionParams);
48
- }
49
- }
50
- // Annotate the CommonJS export names for ESM import in node:
51
- 0 && (module.exports = {
52
- RoleResourceActionModel
53
- });
@@ -1,20 +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
- import { ACL, ACLRole } from '@nocobase/acl';
10
- import { Model } from '@nocobase/database';
11
- export declare class RoleResourceModel extends Model {
12
- revoke(options: {
13
- role: ACLRole;
14
- resourceName: string;
15
- }): Promise<void>;
16
- writeToACL(options: {
17
- acl: ACL;
18
- transaction: any;
19
- }): Promise<void>;
20
- }
@@ -1,72 +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 __defProp = Object.defineProperty;
11
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
- var __getOwnPropNames = Object.getOwnPropertyNames;
13
- var __hasOwnProp = Object.prototype.hasOwnProperty;
14
- var __export = (target, all) => {
15
- for (var name in all)
16
- __defProp(target, name, { get: all[name], enumerable: true });
17
- };
18
- var __copyProps = (to, from, except, desc) => {
19
- if (from && typeof from === "object" || typeof from === "function") {
20
- for (let key of __getOwnPropNames(from))
21
- if (!__hasOwnProp.call(to, key) && key !== except)
22
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
- }
24
- return to;
25
- };
26
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
- var RoleResourceModel_exports = {};
28
- __export(RoleResourceModel_exports, {
29
- RoleResourceModel: () => RoleResourceModel
30
- });
31
- module.exports = __toCommonJS(RoleResourceModel_exports);
32
- var import_acl = require("@nocobase/acl");
33
- var import_database = require("@nocobase/database");
34
- class RoleResourceModel extends import_database.Model {
35
- async revoke(options) {
36
- const { role, resourceName } = options;
37
- role.revokeResource(resourceName);
38
- }
39
- async writeToACL(options) {
40
- const { acl } = options;
41
- const resourceName = this.get("name");
42
- const roleName = this.get("roleName");
43
- const role = acl.getRole(roleName);
44
- if (!role) {
45
- console.log(`${roleName} role does not exist`);
46
- return;
47
- }
48
- await this.revoke({ role, resourceName });
49
- if (this.usingActionsConfig === false) {
50
- return;
51
- }
52
- const resource = new import_acl.ACLResource({
53
- role,
54
- name: resourceName
55
- });
56
- role.resources.set(resourceName, resource);
57
- const actions = await this.getActions({
58
- transaction: options.transaction
59
- });
60
- for (const action of actions) {
61
- await action.writeToACL({
62
- acl,
63
- role,
64
- resourceName
65
- });
66
- }
67
- }
68
- }
69
- // Annotate the CommonJS export names for ESM import in node:
70
- 0 && (module.exports = {
71
- RoleResourceModel
72
- });
@@ -1,24 +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
- import { Transaction } from '@nocobase/database';
10
- import { Plugin } from '@nocobase/server';
11
- import { RoleModel } from './model/RoleModel';
12
- import { RoleResourceActionModel } from './model/RoleResourceActionModel';
13
- import { RoleResourceModel } from './model/RoleResourceModel';
14
- export declare class PluginACLServer extends Plugin {
15
- get acl(): import("@nocobase/acl").ACL;
16
- writeResourceToACL(resourceModel: RoleResourceModel, transaction: Transaction): Promise<void>;
17
- writeActionToACL(actionModel: RoleResourceActionModel, transaction: Transaction): Promise<void>;
18
- writeRolesToACL(options: any): Promise<void>;
19
- writeRoleToACL(role: RoleModel, options?: any): Promise<void>;
20
- beforeLoad(): Promise<void>;
21
- install(): Promise<void>;
22
- load(): Promise<void>;
23
- }
24
- export default PluginACLServer;