@nocobase/plugin-acl 2.1.0-beta.8 → 2.2.0-alpha.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.
Files changed (50) hide show
  1. package/client-v2.d.ts +2 -0
  2. package/client-v2.js +1 -0
  3. package/dist/client/949.7ad4ad3b554e5452.js +10 -0
  4. package/dist/client/971.50ecf7b6ac572080.js +10 -0
  5. package/dist/client/index.js +1 -1
  6. package/dist/client-v2/336.c27dbbf4b362f3c2.js +10 -0
  7. package/dist/client-v2/532.be9165ee6b4d34c1.js +10 -0
  8. package/dist/client-v2/800.020212b7d7b3875d.js +10 -0
  9. package/dist/client-v2/870.1d9bac44ccd1f650.js +10 -0
  10. package/dist/client-v2/components/ResourceFormDrawer.d.ts +33 -0
  11. package/dist/client-v2/index.d.ts +12 -0
  12. package/dist/client-v2/index.js +10 -0
  13. package/dist/client-v2/locale.d.ts +11 -0
  14. package/dist/client-v2/models/user-center/SwitchRoleItemModel.d.ts +18 -0
  15. package/dist/client-v2/pages/RolesManagementPage.d.ts +10 -0
  16. package/dist/client-v2/pages/permissions/DesktopRoutesPermissionsTab.d.ts +11 -0
  17. package/dist/client-v2/pages/permissions/PluginPermissionsTable.d.ts +16 -0
  18. package/dist/client-v2/pages/permissions/SystemPermissionsTab.d.ts +11 -0
  19. package/dist/client-v2/pages/permissions/utils.d.ts +18 -0
  20. package/dist/client-v2/plugin.d.ts +16 -0
  21. package/dist/client-v2/registries.d.ts +60 -0
  22. package/dist/externalVersion.js +13 -10
  23. package/dist/locale/en-US.json +17 -2
  24. package/dist/locale/zh-CN.json +17 -2
  25. package/dist/server/actions/apply-data-permissions.d.ts +10 -0
  26. package/dist/server/actions/apply-data-permissions.js +208 -0
  27. package/dist/server/actions/data-source-compat.d.ts +13 -0
  28. package/dist/server/actions/data-source-compat.js +189 -0
  29. package/dist/server/collections/roles-users.js +1 -0
  30. package/dist/server/collections/roles.js +1 -0
  31. package/dist/server/collections/rolesResources.js +1 -0
  32. package/dist/server/collections/rolesResourcesActions.js +1 -0
  33. package/dist/server/collections/rolesResourcesScopes.js +1 -0
  34. package/dist/server/index.d.ts +3 -0
  35. package/dist/server/index.js +6 -0
  36. package/dist/server/middlewares/check-association-operate.js +9 -6
  37. package/dist/server/middlewares/check-change-with-association.d.ts +1 -0
  38. package/dist/server/middlewares/check-change-with-association.js +3 -1
  39. package/dist/server/middlewares/check-query-permission.d.ts +10 -0
  40. package/dist/server/middlewares/check-query-permission.js +64 -0
  41. package/dist/server/middlewares/setCurrentRole.js +2 -2
  42. package/dist/server/middlewares/with-acl-meta.js +1 -1
  43. package/dist/server/query/apply-query-permission.d.ts +27 -0
  44. package/dist/server/query/apply-query-permission.js +242 -0
  45. package/dist/server/server.js +18 -0
  46. package/dist/swagger/index.d.ts +1113 -145
  47. package/dist/swagger/index.js +986 -180
  48. package/package.json +4 -2
  49. package/dist/client/0655d5ded9f45bb1.js +0 -10
  50. package/dist/client/50204a14518b3a0d.js +0 -10
@@ -0,0 +1,10 @@
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 React from 'react';
10
+ export default function RolesManagementPage(): React.JSX.Element;
@@ -0,0 +1,11 @@
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 React from 'react';
10
+ import type { PermissionTabProps } from '../../registries';
11
+ export default function DesktopRoutesPermissionsTab(props: PermissionTabProps): React.JSX.Element;
@@ -0,0 +1,16 @@
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 React from 'react';
10
+ import type { Role } from '../../registries';
11
+ interface PluginPermissionsTableProps {
12
+ active: boolean;
13
+ role: Role;
14
+ }
15
+ export default function PluginPermissionsTable(props: PluginPermissionsTableProps): React.JSX.Element;
16
+ export {};
@@ -0,0 +1,11 @@
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 React from 'react';
10
+ import type { PermissionTabProps } from '../../registries';
11
+ export default function SystemPermissionsTab(props: PermissionTabProps): React.JSX.Element;
@@ -0,0 +1,18 @@
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 type { PluginSettingsPageType } from '@nocobase/client-v2';
10
+ import type { Role } from '../../registries';
11
+ export type TFunction = (key: string, options?: Record<string, unknown>) => string;
12
+ export interface RoleSnippetsPayload {
13
+ data?: string[];
14
+ }
15
+ export declare function toRoleSnippetsPayload(responseData: unknown): RoleSnippetsPayload;
16
+ export declare function translateTitle(title: unknown, t: TFunction): unknown;
17
+ export declare function mergeRoleSnippets(role: Role, snippets: string[]): Role;
18
+ export declare function getSettingsChildren(item: PluginSettingsPageType): PluginSettingsPageType[];
@@ -0,0 +1,16 @@
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 { Application, Plugin } from '@nocobase/client-v2';
10
+ import { ACLSettingsUI, RolesManager } from './registries';
11
+ export declare class PluginAclClientV2 extends Plugin<any, Application> {
12
+ rolesManager: RolesManager;
13
+ settingsUI: ACLSettingsUI;
14
+ load(): Promise<void>;
15
+ }
16
+ export default PluginAclClientV2;
@@ -0,0 +1,60 @@
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 type { ComponentType, ReactNode } from 'react';
10
+ export interface Role {
11
+ createdAt?: string;
12
+ updatedAt?: string;
13
+ name: string;
14
+ title: string;
15
+ description?: string;
16
+ strategy?: {
17
+ actions?: string[];
18
+ };
19
+ default?: boolean;
20
+ hidden?: boolean;
21
+ allowConfigure?: boolean;
22
+ allowNewMenu?: boolean;
23
+ snippets?: string[];
24
+ }
25
+ export interface RoleTabProps {
26
+ active: boolean;
27
+ role: Role | null;
28
+ onRoleChange: (role: Role | null) => void;
29
+ }
30
+ export interface PermissionTabProps {
31
+ activeKey: string;
32
+ activeRole: Role | null;
33
+ currentUserRole: Role | null;
34
+ onRoleChange: (role: Role | null) => void;
35
+ }
36
+ export type ComponentLoader<Props> = () => Promise<{
37
+ default: ComponentType<Props>;
38
+ }>;
39
+ export interface RoleTabOptions {
40
+ title: ReactNode;
41
+ componentLoader: ComponentLoader<RoleTabProps>;
42
+ sort?: number;
43
+ }
44
+ export interface PermissionTabOptions {
45
+ key: string;
46
+ label: ReactNode;
47
+ componentLoader: ComponentLoader<PermissionTabProps>;
48
+ sort?: number;
49
+ }
50
+ export type PermissionTabOptionResolver = PermissionTabOptions | ((props: PermissionTabProps) => PermissionTabOptions | null | undefined);
51
+ export declare class RolesManager {
52
+ private readonly items;
53
+ add(name: string, options: RoleTabOptions): void;
54
+ list(): [string, RoleTabOptions][];
55
+ }
56
+ export declare class ACLSettingsUI {
57
+ private readonly permissionTabs;
58
+ addPermissionsTab(options: PermissionTabOptionResolver): void;
59
+ getPermissionsTabs(props: PermissionTabProps): PermissionTabOptions[];
60
+ }
@@ -8,7 +8,7 @@
8
8
  */
9
9
 
10
10
  module.exports = {
11
- "@nocobase/client": "2.1.0-beta.8",
11
+ "@nocobase/client": "2.2.0-alpha.1",
12
12
  "antd": "5.24.2",
13
13
  "react": "18.2.0",
14
14
  "react-i18next": "11.18.6",
@@ -16,15 +16,18 @@ module.exports = {
16
16
  "ahooks": "3.7.8",
17
17
  "@formily/react": "2.3.7",
18
18
  "@ant-design/icons": "5.6.1",
19
- "lodash": "4.17.21",
20
- "@nocobase/utils": "2.1.0-beta.8",
21
- "@nocobase/actions": "2.1.0-beta.8",
22
- "@nocobase/cache": "2.1.0-beta.8",
23
- "@nocobase/database": "2.1.0-beta.8",
24
- "@nocobase/server": "2.1.0-beta.8",
25
- "@nocobase/acl": "2.1.0-beta.8",
26
- "@nocobase/test": "2.1.0-beta.8",
19
+ "lodash": "4.18.1",
20
+ "@nocobase/utils": "2.2.0-alpha.1",
21
+ "@nocobase/flow-engine": "2.2.0-alpha.1",
22
+ "@nocobase/client-v2": "2.2.0-alpha.1",
23
+ "@nocobase/actions": "2.2.0-alpha.1",
24
+ "@nocobase/cache": "2.2.0-alpha.1",
25
+ "@nocobase/database": "2.2.0-alpha.1",
26
+ "@nocobase/server": "2.2.0-alpha.1",
27
+ "@nocobase/acl": "2.2.0-alpha.1",
28
+ "@nocobase/test": "2.2.0-alpha.1",
27
29
  "@formily/core": "2.3.7",
28
30
  "@formily/antd-v5": "1.2.3",
29
- "antd-style": "3.7.1"
31
+ "antd-style": "3.7.1",
32
+ "@emotion/css": "11.13.0"
30
33
  };
@@ -1,6 +1,14 @@
1
1
  {
2
+ "Accessible": "Accessible",
3
+ "Allow access": "Allow access",
2
4
  "Allow roles union": "Allow roles union",
5
+ "Allows to clear cache, reboot application": "Allows to clear cache, reboot application",
6
+ "Allows to configure interface": "Allows to configure interface",
7
+ "Allows to configure plugins": "Allows to configure plugins",
8
+ "Allows to install, activate, disable plugins": "Allows to install, activate, disable plugins",
3
9
  "Allow users to use role union, which means they can use permissions from all their roles simultaneously, or switch between individual roles.": "Allow users to use role union, which means they can use permissions from all their roles simultaneously, or switch between individual roles.",
10
+ "Desktop routes": "Desktop routes",
11
+ "Configure permissions": "Configure permissions",
4
12
  "Data sources": "Data sources",
5
13
  "Desktop menu": "Desktop menu",
6
14
  "Do not use role union. Users need to switch between their roles individually.": "Do not use role union. Users need to switch between their roles individually.",
@@ -9,14 +17,21 @@
9
17
  "General": "General",
10
18
  "Independent roles": "Independent roles",
11
19
  "New role": "New role",
20
+ "New routes are allowed to be accessed by default": "New routes are allowed to be accessed by default",
12
21
  "Permissions": "Permissions",
13
22
  "Please select role mode": "Please select role mode",
14
23
  "Plugin settings": "Plugin settings",
24
+ "Plugin name": "Plugin name",
25
+ "Route name": "Route name",
26
+ "Route permissions": "Route permissions",
15
27
  "Role mode": "Role mode",
16
28
  "Role mode doc": "https://docs.nocobase.com/handbook/acl/manual",
17
29
  "Roles & Permissions": "Roles & Permissions",
18
30
  "Roles union only": "Roles union only",
19
31
  "Saved successfully": "Saved successfully",
32
+ "Select a role to configure permissions": "Select a role to configure permissions",
33
+ "System": "System",
20
34
  "The current user has no roles. Please try another account.": "The current user has no roles. Please try another account.",
21
- "The user role does not exist. Please try signing in again": "The user role does not exist. Please try signing in again"
22
- }
35
+ "The user role does not exist. Please try signing in again": "The user role does not exist. Please try signing in again",
36
+ "Users & Permissions": "Users & Permissions"
37
+ }
@@ -1,6 +1,14 @@
1
1
  {
2
+ "Accessible": "可访问",
3
+ "Allow access": "允许访问",
2
4
  "Allow roles union": "允许角色并集",
5
+ "Allows to clear cache, reboot application": "允许清除缓存、重启应用",
6
+ "Allows to configure interface": "允许配置界面",
7
+ "Allows to configure plugins": "允许配置插件",
8
+ "Allows to install, activate, disable plugins": "允许安装、激活、禁用插件",
3
9
  "Allow users to use role union, which means they can use permissions from all their roles simultaneously, or switch between individual roles.": "允许用户使用角色并集,即可以同时使用自己拥有的所有角色的权限,也允许用户逐个切换自己的角色。",
10
+ "Desktop routes": "桌面端路由",
11
+ "Configure permissions": "配置权限",
4
12
  "Data sources": "数据源",
5
13
  "Desktop menu": "桌面端菜单",
6
14
  "Do not use role union. Users need to switch between their roles individually.": "不使用角色并集,用户需要逐个切换自己拥有的角色。",
@@ -9,14 +17,21 @@
9
17
  "General": "通用",
10
18
  "Independent roles": "独立角色",
11
19
  "New role": "新建角色",
20
+ "New routes are allowed to be accessed by default": "默认允许访问新路由",
12
21
  "Permissions": "权限",
13
22
  "Please select role mode": "请选择角色模式",
14
23
  "Plugin settings": "插件设置",
24
+ "Plugin name": "插件名称",
25
+ "Route name": "路由名称",
26
+ "Route permissions": "路由权限",
15
27
  "Role mode": "角色模式",
16
28
  "Role mode doc": "https://docs-cn.nocobase.com/handbook/acl/manual",
17
29
  "Roles & Permissions": "角色和权限",
18
30
  "Roles union only": "仅角色并集",
19
31
  "Saved successfully": "保存成功",
32
+ "Select a role to configure permissions": "选择一个角色以配置权限",
33
+ "System": "系统",
20
34
  "The current user has no roles. Please try another account.": "当前用户没有角色,请使用其他账号。",
21
- "The user role does not exist. Please try signing in again": "用户角色不存在,请尝试重新登录。"
22
- }
35
+ "The user role does not exist. Please try signing in again": "用户角色不存在,请尝试重新登录。",
36
+ "Users & Permissions": "用户和权限"
37
+ }
@@ -0,0 +1,10 @@
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 type { Context, Next } from '@nocobase/actions';
10
+ export declare function applyDataPermissions(ctx: Context, next: Next): Promise<void>;
@@ -0,0 +1,208 @@
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 apply_data_permissions_exports = {};
28
+ __export(apply_data_permissions_exports, {
29
+ applyDataPermissions: () => applyDataPermissions
30
+ });
31
+ module.exports = __toCommonJS(apply_data_permissions_exports);
32
+ function ensureString(value, fieldName) {
33
+ if (typeof value !== "string" || !value.trim()) {
34
+ throw new Error(`Invalid ${fieldName}`);
35
+ }
36
+ return value.trim();
37
+ }
38
+ function normalizeFields(fields) {
39
+ if (!Array.isArray(fields)) {
40
+ return void 0;
41
+ }
42
+ const normalized = [
43
+ ...new Set(fields.filter((field) => typeof field === "string" && !!field.trim()))
44
+ ];
45
+ return normalized.length ? normalized : [];
46
+ }
47
+ function normalizeScopeId(scopeId) {
48
+ if (scopeId === null) {
49
+ return null;
50
+ }
51
+ if (scopeId === void 0) {
52
+ return void 0;
53
+ }
54
+ const parsed = Number(scopeId);
55
+ if (!Number.isInteger(parsed) || parsed <= 0) {
56
+ throw new Error(`Invalid scopeId: ${scopeId}`);
57
+ }
58
+ return parsed;
59
+ }
60
+ async function resolveScopeIdByKey(options) {
61
+ const scope = await options.ctx.db.getRepository("dataSourcesRolesResourcesScopes").findOne({
62
+ filter: {
63
+ dataSourceKey: options.dataSourceKey,
64
+ key: options.scopeKey
65
+ },
66
+ transaction: options.transaction
67
+ });
68
+ if (!scope) {
69
+ throw new Error(`Scope key "${options.scopeKey}" not found in data source "${options.dataSourceKey}"`);
70
+ }
71
+ return scope.get("id");
72
+ }
73
+ async function normalizeAction(options) {
74
+ const name = ensureString(options.action.name, "action.name");
75
+ let scopeId = normalizeScopeId(options.action.scopeId);
76
+ if (scopeId === void 0 && options.action.scope && typeof options.action.scope.id === "number") {
77
+ scopeId = normalizeScopeId(options.action.scope.id);
78
+ }
79
+ let scopeKey;
80
+ if (typeof options.action.scopeKey === "string" && options.action.scopeKey.trim()) {
81
+ scopeKey = options.action.scopeKey.trim();
82
+ } else if (options.action.scope && typeof options.action.scope.key === "string" && options.action.scope.key.trim()) {
83
+ scopeKey = options.action.scope.key.trim();
84
+ }
85
+ if (scopeId === void 0 && scopeKey) {
86
+ scopeId = await resolveScopeIdByKey({
87
+ ctx: options.ctx,
88
+ dataSourceKey: options.dataSourceKey,
89
+ scopeKey,
90
+ transaction: options.transaction
91
+ });
92
+ }
93
+ if (scopeId === void 0) {
94
+ scopeId = null;
95
+ }
96
+ const normalized = {
97
+ name,
98
+ fields: normalizeFields(options.action.fields),
99
+ scopeId
100
+ };
101
+ const output = {
102
+ name: normalized.name
103
+ };
104
+ if (normalized.fields !== void 0) {
105
+ output.fields = normalized.fields;
106
+ }
107
+ if (normalized.scopeId !== void 0) {
108
+ output.scopeId = normalized.scopeId;
109
+ }
110
+ return output;
111
+ }
112
+ async function applyDataPermissions(ctx, next) {
113
+ const roleName = ensureString(ctx.action.params.filterByTk, "filterByTk");
114
+ const values = ctx.action.params.values || {};
115
+ const dataSourceKey = ensureString(values.dataSourceKey || "main", "dataSourceKey");
116
+ const resources = values.resources;
117
+ if (!Array.isArray(resources) || resources.length === 0) {
118
+ throw new Error("`resources` must be a non-empty array");
119
+ }
120
+ const role = await ctx.db.getRepository("roles").findOne({
121
+ filterByTk: roleName
122
+ });
123
+ if (!role) {
124
+ throw new Error(`Role "${roleName}" not found`);
125
+ }
126
+ const roleResourceRepository = ctx.db.getRepository("roles.resources", roleName);
127
+ const appliedResources = [];
128
+ await ctx.db.sequelize.transaction(async (transaction) => {
129
+ for (const resourceInput of resources) {
130
+ const resourceName = ensureString(resourceInput == null ? void 0 : resourceInput.name, "resource.name");
131
+ const usingActionsConfig = (resourceInput == null ? void 0 : resourceInput.usingActionsConfig) ?? true;
132
+ const actionsInput = Array.isArray(resourceInput == null ? void 0 : resourceInput.actions) ? resourceInput.actions : [];
133
+ const normalizedActions = [];
134
+ for (const action of actionsInput) {
135
+ normalizedActions.push(
136
+ await normalizeAction({
137
+ ctx,
138
+ dataSourceKey,
139
+ action,
140
+ transaction
141
+ })
142
+ );
143
+ }
144
+ const existingResource = await roleResourceRepository.findOne({
145
+ filter: {
146
+ name: resourceName,
147
+ dataSourceKey
148
+ },
149
+ appends: ["actions"],
150
+ transaction
151
+ });
152
+ const writeValues = {
153
+ name: resourceName,
154
+ dataSourceKey,
155
+ usingActionsConfig,
156
+ actions: normalizedActions
157
+ };
158
+ let savedResource;
159
+ if (existingResource) {
160
+ await roleResourceRepository.update({
161
+ filterByTk: existingResource.get("id"),
162
+ values: writeValues,
163
+ updateAssociationValues: ["actions"],
164
+ transaction
165
+ });
166
+ savedResource = await roleResourceRepository.findOne({
167
+ filterByTk: existingResource.get("id"),
168
+ appends: ["actions"],
169
+ transaction
170
+ });
171
+ } else {
172
+ const created = await roleResourceRepository.create({
173
+ values: writeValues,
174
+ transaction
175
+ });
176
+ savedResource = await roleResourceRepository.findOne({
177
+ filterByTk: created.get("id"),
178
+ appends: ["actions"],
179
+ transaction
180
+ });
181
+ }
182
+ const actionModels = savedResource.get("actions") || [];
183
+ appliedResources.push({
184
+ id: savedResource.get("id"),
185
+ name: savedResource.get("name"),
186
+ dataSourceKey: savedResource.get("dataSourceKey"),
187
+ usingActionsConfig: !!savedResource.get("usingActionsConfig"),
188
+ actions: actionModels.map((actionModel) => ({
189
+ id: actionModel.get("id"),
190
+ name: actionModel.get("name"),
191
+ fields: actionModel.get("fields") || [],
192
+ scopeId: actionModel.get("scopeId") ?? null
193
+ }))
194
+ });
195
+ }
196
+ });
197
+ ctx.body = {
198
+ roleName,
199
+ dataSourceKey,
200
+ resources: appliedResources,
201
+ count: appliedResources.length
202
+ };
203
+ await next();
204
+ }
205
+ // Annotate the CommonJS export names for ESM import in node:
206
+ 0 && (module.exports = {
207
+ applyDataPermissions
208
+ });
@@ -0,0 +1,13 @@
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 type { Context, Next } from '@nocobase/actions';
10
+ export declare function guardRolesDataSourcesCollectionsList(ctx: Context, next: Next): Promise<void>;
11
+ export declare function guardRolesDataSourceResourcesCreate(ctx: Context, next: Next): Promise<void>;
12
+ export declare function guardRolesDataSourceResourcesGet(ctx: Context, next: Next): Promise<void>;
13
+ export declare function guardRolesDataSourceResourcesUpdate(ctx: Context, next: Next): Promise<void>;