@nocobase/plugin-acl 0.7.0-alpha.7 → 0.7.0-alpha.72
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/lib/actions/available-actions.js +35 -25
- package/lib/actions/role-check.js +85 -38
- package/lib/actions/role-collections.js +78 -53
- package/lib/collections/roles.js +70 -78
- package/lib/collections/rolesResources.js +27 -30
- package/lib/collections/rolesResourcesActions.js +26 -27
- package/lib/collections/rolesResourcesScopes.js +21 -22
- package/lib/index.js +14 -8
- package/lib/model/RoleModel.js +39 -15
- package/lib/model/RoleResourceActionModel.js +103 -66
- package/lib/model/RoleResourceModel.js +125 -56
- package/lib/server.js +609 -351
- package/package.json +5 -10
- package/src/__tests__/acl.test.ts +50 -0
- package/src/__tests__/own.test.ts +5 -6
- package/src/actions/role-collections.ts +15 -5
- package/src/model/RoleResourceActionModel.ts +4 -2
- package/src/model/RoleResourceModel.ts +12 -4
- package/src/server.ts +5 -0
- package/esm/actions/available-actions.d.ts +0 -7
- package/esm/actions/available-actions.js +0 -26
- package/esm/actions/available-actions.js.map +0 -1
- package/esm/actions/role-check.d.ts +0 -1
- package/esm/actions/role-check.js +0 -38
- package/esm/actions/role-check.js.map +0 -1
- package/esm/actions/role-collections.d.ts +0 -7
- package/esm/actions/role-collections.js +0 -54
- package/esm/actions/role-collections.js.map +0 -1
- package/esm/collections/roles.d.ts +0 -3
- package/esm/collections/roles.js +0 -78
- package/esm/collections/roles.js.map +0 -1
- package/esm/collections/rolesResources.d.ts +0 -3
- package/esm/collections/rolesResources.js +0 -30
- package/esm/collections/rolesResources.js.map +0 -1
- package/esm/collections/rolesResourcesActions.d.ts +0 -3
- package/esm/collections/rolesResourcesActions.js +0 -27
- package/esm/collections/rolesResourcesActions.js.map +0 -1
- package/esm/collections/rolesResourcesScopes.d.ts +0 -3
- package/esm/collections/rolesResourcesScopes.js +0 -22
- package/esm/collections/rolesResourcesScopes.js.map +0 -1
- package/esm/index.d.ts +0 -1
- package/esm/index.js +0 -2
- package/esm/index.js.map +0 -1
- package/esm/model/RoleModel.d.ts +0 -7
- package/esm/model/RoleModel.js +0 -15
- package/esm/model/RoleModel.js.map +0 -1
- package/esm/model/RoleResourceActionModel.d.ts +0 -12
- package/esm/model/RoleResourceActionModel.js +0 -65
- package/esm/model/RoleResourceActionModel.js.map +0 -1
- package/esm/model/RoleResourceModel.d.ts +0 -16
- package/esm/model/RoleResourceModel.js +0 -55
- package/esm/model/RoleResourceModel.js.map +0 -1
- package/esm/server.d.ts +0 -33
- package/esm/server.js +0 -366
- package/esm/server.js.map +0 -1
- package/lib/actions/available-actions.js.map +0 -1
- package/lib/actions/role-check.js.map +0 -1
- package/lib/actions/role-collections.js.map +0 -1
- package/lib/collections/roles.js.map +0 -1
- package/lib/collections/rolesResources.js.map +0 -1
- package/lib/collections/rolesResourcesActions.js.map +0 -1
- package/lib/collections/rolesResourcesScopes.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/model/RoleModel.js.map +0 -1
- package/lib/model/RoleResourceActionModel.js.map +0 -1
- package/lib/model/RoleResourceModel.js.map +0 -1
- package/lib/server.js.map +0 -1
- package/tsconfig.build.json +0 -9
- package/tsconfig.json +0 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-acl",
|
|
3
|
-
"version": "0.7.0-alpha.
|
|
3
|
+
"version": "0.7.0-alpha.72",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"licenses": [
|
|
@@ -11,20 +11,15 @@
|
|
|
11
11
|
],
|
|
12
12
|
"main": "./lib/index.js",
|
|
13
13
|
"types": "./lib/index.d.ts",
|
|
14
|
-
"scripts": {
|
|
15
|
-
"build": "rimraf -rf lib esm dist && npm run build:cjs && npm run build:esm",
|
|
16
|
-
"build:cjs": "tsc --project tsconfig.build.json",
|
|
17
|
-
"build:esm": "tsc --project tsconfig.build.json --module es2015 --outDir esm"
|
|
18
|
-
},
|
|
19
14
|
"dependencies": {
|
|
20
|
-
"@nocobase/acl": "0.7.0-alpha.
|
|
21
|
-
"@nocobase/database": "0.7.0-alpha.
|
|
22
|
-
"@nocobase/server": "0.7.0-alpha.
|
|
15
|
+
"@nocobase/acl": "0.7.0-alpha.72",
|
|
16
|
+
"@nocobase/database": "0.7.0-alpha.72",
|
|
17
|
+
"@nocobase/server": "0.7.0-alpha.72"
|
|
23
18
|
},
|
|
24
19
|
"repository": {
|
|
25
20
|
"type": "git",
|
|
26
21
|
"url": "git+https://github.com/nocobase/nocobase.git",
|
|
27
22
|
"directory": "packages/plugins/acl"
|
|
28
23
|
},
|
|
29
|
-
"gitHead": "
|
|
24
|
+
"gitHead": "db24b85879b0f911458914b49ea9644fd7eb7562"
|
|
30
25
|
}
|
|
@@ -72,6 +72,56 @@ describe('acl', () => {
|
|
|
72
72
|
});
|
|
73
73
|
});
|
|
74
74
|
|
|
75
|
+
it('should deny when resource action has no resource', async () => {
|
|
76
|
+
const role = await db.getRepository('roles').create({
|
|
77
|
+
values: {
|
|
78
|
+
name: 'admin',
|
|
79
|
+
title: 'Admin User',
|
|
80
|
+
allowConfigure: true,
|
|
81
|
+
strategy: {
|
|
82
|
+
actions: ['update:own', 'destroy:own', 'create', 'view'],
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
changeMockRole('admin');
|
|
88
|
+
|
|
89
|
+
// create c1 collection
|
|
90
|
+
await db.getRepository('collections').create({
|
|
91
|
+
values: {
|
|
92
|
+
name: 'c1',
|
|
93
|
+
title: 'table1',
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
// create c2 collection
|
|
98
|
+
await db.getRepository('collections').create({
|
|
99
|
+
values: {
|
|
100
|
+
name: 'c2',
|
|
101
|
+
title: 'table2',
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
await app
|
|
106
|
+
.agent()
|
|
107
|
+
.resource('roles.resources', 'admin')
|
|
108
|
+
.create({
|
|
109
|
+
values: {
|
|
110
|
+
name: 'c1',
|
|
111
|
+
usingActionsConfig: true,
|
|
112
|
+
actions: [],
|
|
113
|
+
},
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
expect(
|
|
117
|
+
acl.can({
|
|
118
|
+
role: 'admin',
|
|
119
|
+
resource: 'c1',
|
|
120
|
+
action: 'list',
|
|
121
|
+
}),
|
|
122
|
+
).toBeNull();
|
|
123
|
+
});
|
|
124
|
+
|
|
75
125
|
it('should works with resources actions', async () => {
|
|
76
126
|
const role = await db.getRepository('roles').create({
|
|
77
127
|
values: {
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { mockServer, MockServer } from '@nocobase/test';
|
|
2
|
-
import { Database } from '@nocobase/database';
|
|
3
1
|
import { ACL } from '@nocobase/acl';
|
|
4
|
-
import {
|
|
5
|
-
import PluginUiSchema from '@nocobase/plugin-ui-schema-storage';
|
|
6
|
-
import PluginCollectionManager from '@nocobase/plugin-collection-manager';
|
|
2
|
+
import { Database } from '@nocobase/database';
|
|
7
3
|
import PluginACL from '@nocobase/plugin-acl';
|
|
4
|
+
import PluginCollectionManager from '@nocobase/plugin-collection-manager';
|
|
5
|
+
import PluginUiSchema from '@nocobase/plugin-ui-schema-storage';
|
|
8
6
|
import PluginUser from '@nocobase/plugin-users';
|
|
7
|
+
import { mockServer, MockServer } from '@nocobase/test';
|
|
9
8
|
import supertest from 'supertest';
|
|
10
9
|
|
|
11
10
|
describe('own test', () => {
|
|
@@ -38,7 +37,7 @@ describe('own test', () => {
|
|
|
38
37
|
app.plugin(PluginCollectionManager);
|
|
39
38
|
app.plugin(PluginUser, {
|
|
40
39
|
jwt: {
|
|
41
|
-
secret: process.env.
|
|
40
|
+
secret: process.env.APP_KEY || 'test-key',
|
|
42
41
|
},
|
|
43
42
|
});
|
|
44
43
|
|
|
@@ -2,18 +2,24 @@ import { Database } from '@nocobase/database';
|
|
|
2
2
|
|
|
3
3
|
type UsingConfigType = 'strategy' | 'resourceAction';
|
|
4
4
|
|
|
5
|
+
function totalPage(total, pageSize): number {
|
|
6
|
+
return Math.ceil(total / pageSize);
|
|
7
|
+
}
|
|
8
|
+
|
|
5
9
|
const roleCollectionsResource = {
|
|
6
10
|
name: 'roles.collections',
|
|
7
11
|
actions: {
|
|
8
12
|
async list(ctx, next) {
|
|
9
13
|
const role = ctx.action.params.associatedIndex;
|
|
14
|
+
const { page = 1, pageSize = 20 } = ctx.action.params;
|
|
10
15
|
|
|
11
16
|
const db: Database = ctx.db;
|
|
12
17
|
const collectionRepository = db.getRepository('collections');
|
|
13
18
|
|
|
14
19
|
// all collections
|
|
15
|
-
const collections = await collectionRepository.
|
|
20
|
+
const [collections, count] = await collectionRepository.findAndCount({
|
|
16
21
|
filter: ctx.action.params.filter,
|
|
22
|
+
sort: 'sort',
|
|
17
23
|
});
|
|
18
24
|
|
|
19
25
|
// role collections
|
|
@@ -29,8 +35,9 @@ const roleCollectionsResource = {
|
|
|
29
35
|
.filter((roleResources) => roleResources.get('usingActionsConfig'))
|
|
30
36
|
.map((roleResources) => roleResources.get('name'));
|
|
31
37
|
|
|
32
|
-
ctx.body =
|
|
33
|
-
|
|
38
|
+
ctx.body = {
|
|
39
|
+
count,
|
|
40
|
+
rows: collections.map((collection) => {
|
|
34
41
|
const exists = roleResourcesNames.includes(collection.get('name'));
|
|
35
42
|
|
|
36
43
|
const usingConfig: UsingConfigType = roleResourceActionResourceNames.includes(collection.get('name'))
|
|
@@ -44,8 +51,11 @@ const roleCollectionsResource = {
|
|
|
44
51
|
usingConfig,
|
|
45
52
|
exists,
|
|
46
53
|
};
|
|
47
|
-
})
|
|
48
|
-
|
|
54
|
+
}),
|
|
55
|
+
page: Number(page),
|
|
56
|
+
pageSize: Number(pageSize),
|
|
57
|
+
totalPage: totalPage(count, pageSize),
|
|
58
|
+
};
|
|
49
59
|
|
|
50
60
|
await next();
|
|
51
61
|
},
|
|
@@ -51,6 +51,7 @@ export class RoleResourceActionModel extends Model {
|
|
|
51
51
|
const fieldTarget = collectionField.get('target');
|
|
52
52
|
|
|
53
53
|
if (fieldActions) {
|
|
54
|
+
// grant association actions to role
|
|
54
55
|
const associationActions = fieldActions.associationActions || [];
|
|
55
56
|
associationActions.forEach((associationAction) => {
|
|
56
57
|
const actionName = `${resourceName}.${fieldTarget}:${associationAction}`;
|
|
@@ -62,14 +63,15 @@ export class RoleResourceActionModel extends Model {
|
|
|
62
63
|
targetActions.forEach((targetAction) => {
|
|
63
64
|
const targetActionPath = `${fieldTarget}:${targetAction}`;
|
|
64
65
|
|
|
65
|
-
|
|
66
|
+
// set resource target action with current resourceName
|
|
67
|
+
grantHelper.resourceTargetActionMap.set(`${role.name}.${resourceName}`, [
|
|
66
68
|
...(grantHelper.resourceTargetActionMap.get(resourceName) || []),
|
|
67
69
|
targetActionPath,
|
|
68
70
|
]);
|
|
69
71
|
|
|
70
72
|
grantHelper.targetActionResourceMap.set(targetActionPath, [
|
|
71
73
|
...(grantHelper.targetActionResourceMap.get(targetActionPath) || []),
|
|
72
|
-
resourceName
|
|
74
|
+
`${role.name}.${resourceName}`,
|
|
73
75
|
]);
|
|
74
76
|
|
|
75
77
|
role.grantAction(targetActionPath);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Database, Model } from '@nocobase/database';
|
|
2
|
-
import { ACL, ACLRole } from '@nocobase/acl';
|
|
2
|
+
import { ACL, ACLResource, ACLRole } from '@nocobase/acl';
|
|
3
3
|
import { RoleResourceActionModel } from './RoleResourceActionModel';
|
|
4
4
|
import { AssociationFieldsActions, GrantHelper } from '../server';
|
|
5
5
|
|
|
@@ -8,20 +8,21 @@ export class RoleResourceModel extends Model {
|
|
|
8
8
|
const { role, resourceName, grantHelper } = options;
|
|
9
9
|
role.revokeResource(resourceName);
|
|
10
10
|
|
|
11
|
-
const targetActions = grantHelper.resourceTargetActionMap.get(resourceName) || [];
|
|
11
|
+
const targetActions = grantHelper.resourceTargetActionMap.get(`${role.name}.${resourceName}`) || [];
|
|
12
12
|
|
|
13
13
|
for (const targetAction of targetActions) {
|
|
14
14
|
const targetActionResource = (grantHelper.targetActionResourceMap.get(targetAction) || []).filter(
|
|
15
|
-
(item) => resourceName !== item,
|
|
15
|
+
(item) => `${role.name}.${resourceName}` !== item,
|
|
16
16
|
);
|
|
17
17
|
|
|
18
18
|
grantHelper.targetActionResourceMap.set(targetAction, targetActionResource);
|
|
19
|
+
|
|
19
20
|
if (targetActionResource.length == 0) {
|
|
20
21
|
role.revokeAction(targetAction);
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
grantHelper.resourceTargetActionMap.set(resourceName
|
|
25
|
+
grantHelper.resourceTargetActionMap.set(`${role.name}.${resourceName}`, []);
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
async writeToACL(options: {
|
|
@@ -43,6 +44,13 @@ export class RoleResourceModel extends Model {
|
|
|
43
44
|
return;
|
|
44
45
|
}
|
|
45
46
|
|
|
47
|
+
const resource = new ACLResource({
|
|
48
|
+
role,
|
|
49
|
+
name: resourceName,
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
role.resources.set(resourceName, resource);
|
|
53
|
+
|
|
46
54
|
// @ts-ignore
|
|
47
55
|
const actions: RoleResourceActionModel[] = await this.getActions({
|
|
48
56
|
transaction: options.transaction,
|
package/src/server.ts
CHANGED
|
@@ -30,6 +30,8 @@ export class GrantHelper {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
export class PluginACL extends Plugin {
|
|
33
|
+
// association field actions config
|
|
34
|
+
|
|
33
35
|
associationFieldsActions: AssociationFieldsActions = {};
|
|
34
36
|
|
|
35
37
|
grantHelper = new GrantHelper();
|
|
@@ -43,6 +45,8 @@ export class PluginACL extends Plugin {
|
|
|
43
45
|
}
|
|
44
46
|
|
|
45
47
|
registerAssociationFieldsActions() {
|
|
48
|
+
// if grant create action to role, it should
|
|
49
|
+
// also grant add action and association target's view action
|
|
46
50
|
this.registerAssociationFieldAction('linkTo', {
|
|
47
51
|
view: {
|
|
48
52
|
associationActions: ['list', 'get'],
|
|
@@ -107,6 +111,7 @@ export class PluginACL extends Plugin {
|
|
|
107
111
|
const roles = (await this.app.db.getRepository('roles').find({
|
|
108
112
|
appends: ['resources', 'resources.actions'],
|
|
109
113
|
})) as RoleModel[];
|
|
114
|
+
|
|
110
115
|
for (const role of roles) {
|
|
111
116
|
role.writeToAcl({ acl: this.acl });
|
|
112
117
|
for (const resource of role.get('resources') as RoleResourceModel[]) {
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
const availableActionResource = {
|
|
11
|
-
name: 'availableActions',
|
|
12
|
-
actions: {
|
|
13
|
-
list(ctx, next) {
|
|
14
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
-
const acl = ctx.app.acl;
|
|
16
|
-
const availableActions = acl.getAvailableActions();
|
|
17
|
-
ctx.body = Array.from(availableActions.entries()).map(([, { name, options }]) => {
|
|
18
|
-
return Object.assign(Object.assign({}, options), { name });
|
|
19
|
-
});
|
|
20
|
-
yield next();
|
|
21
|
-
});
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
};
|
|
25
|
-
export { availableActionResource };
|
|
26
|
-
//# sourceMappingURL=available-actions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"available-actions.js","sourceRoot":"","sources":["../../src/actions/available-actions.ts"],"names":[],"mappings":";;;;;;;;;AAAA,MAAM,uBAAuB,GAAG;IAC9B,IAAI,EAAE,kBAAkB;IACxB,OAAO,EAAE;QACD,IAAI,CAAC,GAAG,EAAE,IAAI;;gBAClB,MAAM,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC;gBACxB,MAAM,gBAAgB,GAAG,GAAG,CAAC,mBAAmB,EAAE,CAAC;gBACnD,GAAG,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE;oBAC9E,uCACK,OAAO,KACV,IAAI,IACJ;gBACJ,CAAC,CAAC,CAAC;gBACH,MAAM,IAAI,EAAE,CAAC;YACf,CAAC;SAAA;KACF;CACF,CAAC;AAEF,OAAO,EAAE,uBAAuB,EAAE,CAAC","sourcesContent":["const availableActionResource = {\n name: 'availableActions',\n actions: {\n async list(ctx, next) {\n const acl = ctx.app.acl;\n const availableActions = acl.getAvailableActions();\n ctx.body = Array.from(availableActions.entries()).map(([, { name, options }]) => {\n return {\n ...options,\n name,\n };\n });\n await next();\n },\n },\n};\n\nexport { availableActionResource };\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function checkAction(ctx: any, next: any): Promise<void>;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
const map2obj = (map) => {
|
|
11
|
-
const obj = {};
|
|
12
|
-
for (let [key, value] of map) {
|
|
13
|
-
obj[key] = value;
|
|
14
|
-
}
|
|
15
|
-
return obj;
|
|
16
|
-
};
|
|
17
|
-
export function checkAction(ctx, next) {
|
|
18
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
-
const currentRole = ctx.state.currentRole;
|
|
20
|
-
if (currentRole) {
|
|
21
|
-
const roleInstance = yield ctx.db.getRepository('roles').findOne({
|
|
22
|
-
filter: {
|
|
23
|
-
name: currentRole,
|
|
24
|
-
},
|
|
25
|
-
appends: ['menuUiSchemas'],
|
|
26
|
-
});
|
|
27
|
-
const anonymous = yield ctx.db.getRepository('roles').findOne({
|
|
28
|
-
filter: {
|
|
29
|
-
name: 'anonymous',
|
|
30
|
-
},
|
|
31
|
-
});
|
|
32
|
-
const role = ctx.app.acl.getRole(currentRole);
|
|
33
|
-
ctx.body = Object.assign(Object.assign({}, role.toJSON()), { resources: [...role.resources.keys()], actionAlias: map2obj(ctx.app.acl.actionAlias), allowAll: currentRole === 'root', allowConfigure: roleInstance.get('allowConfigure'), allowMenuItemIds: roleInstance.get('menuUiSchemas').map((uiSchema) => uiSchema.get('x-uid')), allowAnonymous: !!anonymous });
|
|
34
|
-
}
|
|
35
|
-
yield next();
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
//# sourceMappingURL=role-check.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"role-check.js","sourceRoot":"","sources":["../../src/actions/role-check.ts"],"names":[],"mappings":";;;;;;;;;AAAA,MAAM,OAAO,GAAG,CAAC,GAAwB,EAAE,EAAE;IAC3C,MAAM,GAAG,GAAG,EAAE,CAAC;IACf,KAAI,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,GAAG,EAAC;QAC1B,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;KAClB;IACF,OAAO,GAAG,CAAC;AACZ,CAAC,CAAA;AAED,MAAM,UAAgB,WAAW,CAAC,GAAG,EAAE,IAAI;;QACzC,MAAM,WAAW,GAAG,GAAG,CAAC,KAAK,CAAC,WAAW,CAAC;QAC1C,IAAI,WAAW,EAAE;YACf,MAAM,YAAY,GAAG,MAAM,GAAG,CAAC,EAAE,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC;gBAC/D,MAAM,EAAE;oBACN,IAAI,EAAE,WAAW;iBAClB;gBACD,OAAO,EAAE,CAAC,eAAe,CAAC;aAC3B,CAAC,CAAC;YAEH,MAAM,SAAS,GAAG,MAAM,GAAG,CAAC,EAAE,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC;gBAC5D,MAAM,EAAE;oBACN,IAAI,EAAE,WAAW;iBAClB;aACF,CAAC,CAAC;YAEH,MAAM,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;YAE9C,GAAG,CAAC,IAAI,mCACH,IAAI,CAAC,MAAM,EAAE,KAChB,SAAS,EAAE,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,EACrC,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC,EAC7C,QAAQ,EAAE,WAAW,KAAK,MAAM,EAChC,cAAc,EAAE,YAAY,CAAC,GAAG,CAAC,gBAAgB,CAAC,EAClD,gBAAgB,EAAE,YAAY,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,EAC5F,cAAc,EAAE,CAAC,CAAC,SAAS,GAC5B,CAAC;SACH;QAED,MAAM,IAAI,EAAE,CAAC;IACf,CAAC;CAAA","sourcesContent":["const map2obj = (map: Map<string, string>) => {\n const obj = {};\n for(let [key, value] of map){\n obj[key] = value;\n }\n return obj;\n}\n\nexport async function checkAction(ctx, next) {\n const currentRole = ctx.state.currentRole;\n if (currentRole) {\n const roleInstance = await ctx.db.getRepository('roles').findOne({\n filter: {\n name: currentRole,\n },\n appends: ['menuUiSchemas'],\n });\n\n const anonymous = await ctx.db.getRepository('roles').findOne({\n filter: {\n name: 'anonymous',\n },\n });\n\n const role = ctx.app.acl.getRole(currentRole);\n\n ctx.body = {\n ...role.toJSON(),\n resources: [...role.resources.keys()],\n actionAlias: map2obj(ctx.app.acl.actionAlias),\n allowAll: currentRole === 'root',\n allowConfigure: roleInstance.get('allowConfigure'),\n allowMenuItemIds: roleInstance.get('menuUiSchemas').map((uiSchema) => uiSchema.get('x-uid')),\n allowAnonymous: !!anonymous,\n };\n }\n\n await next();\n}\n"]}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
const roleCollectionsResource = {
|
|
11
|
-
name: 'roles.collections',
|
|
12
|
-
actions: {
|
|
13
|
-
list(ctx, next) {
|
|
14
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
-
const role = ctx.action.params.associatedIndex;
|
|
16
|
-
const db = ctx.db;
|
|
17
|
-
const collectionRepository = db.getRepository('collections');
|
|
18
|
-
// all collections
|
|
19
|
-
const collections = yield collectionRepository.find({
|
|
20
|
-
filter: ctx.action.params.filter,
|
|
21
|
-
});
|
|
22
|
-
// role collections
|
|
23
|
-
const roleResources = yield db.getRepository('rolesResources').find({
|
|
24
|
-
filter: {
|
|
25
|
-
roleName: role,
|
|
26
|
-
},
|
|
27
|
-
});
|
|
28
|
-
// role collections
|
|
29
|
-
const roleResourcesNames = roleResources.map((roleResource) => roleResource.get('name'));
|
|
30
|
-
const roleResourceActionResourceNames = roleResources
|
|
31
|
-
.filter((roleResources) => roleResources.get('usingActionsConfig'))
|
|
32
|
-
.map((roleResources) => roleResources.get('name'));
|
|
33
|
-
ctx.body = collections
|
|
34
|
-
.map((collection) => {
|
|
35
|
-
const exists = roleResourcesNames.includes(collection.get('name'));
|
|
36
|
-
const usingConfig = roleResourceActionResourceNames.includes(collection.get('name'))
|
|
37
|
-
? 'resourceAction'
|
|
38
|
-
: 'strategy';
|
|
39
|
-
return {
|
|
40
|
-
name: collection.get('name'),
|
|
41
|
-
title: collection.get('title'),
|
|
42
|
-
roleName: role,
|
|
43
|
-
usingConfig,
|
|
44
|
-
exists,
|
|
45
|
-
};
|
|
46
|
-
})
|
|
47
|
-
.sort((a, b) => (a.name > b.name ? 1 : -1));
|
|
48
|
-
yield next();
|
|
49
|
-
});
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
};
|
|
53
|
-
export { roleCollectionsResource };
|
|
54
|
-
//# sourceMappingURL=role-collections.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"role-collections.js","sourceRoot":"","sources":["../../src/actions/role-collections.ts"],"names":[],"mappings":";;;;;;;;;AAIA,MAAM,uBAAuB,GAAG;IAC9B,IAAI,EAAE,mBAAmB;IACzB,OAAO,EAAE;QACD,IAAI,CAAC,GAAG,EAAE,IAAI;;gBAClB,MAAM,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC;gBAE/C,MAAM,EAAE,GAAa,GAAG,CAAC,EAAE,CAAC;gBAC5B,MAAM,oBAAoB,GAAG,EAAE,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;gBAE7D,kBAAkB;gBAClB,MAAM,WAAW,GAAG,MAAM,oBAAoB,CAAC,IAAI,CAAC;oBAClD,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM;iBACjC,CAAC,CAAC;gBAEH,mBAAmB;gBACnB,MAAM,aAAa,GAAG,MAAM,EAAE,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC,IAAI,CAAC;oBAClE,MAAM,EAAE;wBACN,QAAQ,EAAE,IAAI;qBACf;iBACF,CAAC,CAAC;gBAEH,mBAAmB;gBACnB,MAAM,kBAAkB,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,YAAY,EAAE,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;gBACzF,MAAM,+BAA+B,GAAG,aAAa;qBAClD,MAAM,CAAC,CAAC,aAAa,EAAE,EAAE,CAAC,aAAa,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;qBAClE,GAAG,CAAC,CAAC,aAAa,EAAE,EAAE,CAAC,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;gBAErD,GAAG,CAAC,IAAI,GAAG,WAAW;qBACnB,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE;oBAClB,MAAM,MAAM,GAAG,kBAAkB,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;oBAEnE,MAAM,WAAW,GAAoB,+BAA+B,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;wBACnG,CAAC,CAAC,gBAAgB;wBAClB,CAAC,CAAC,UAAU,CAAC;oBAEf,OAAO;wBACL,IAAI,EAAE,UAAU,CAAC,GAAG,CAAC,MAAM,CAAW;wBACtC,KAAK,EAAE,UAAU,CAAC,GAAG,CAAC,OAAO,CAAW;wBACxC,QAAQ,EAAE,IAAI;wBACd,WAAW;wBACX,MAAM;qBACP,CAAC;gBACJ,CAAC,CAAC;qBACD,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBAE9C,MAAM,IAAI,EAAE,CAAC;YACf,CAAC;SAAA;KACF;CACF,CAAC;AAEF,OAAO,EAAE,uBAAuB,EAAE,CAAC","sourcesContent":["import { Database } from '@nocobase/database';\n\ntype UsingConfigType = 'strategy' | 'resourceAction';\n\nconst roleCollectionsResource = {\n name: 'roles.collections',\n actions: {\n async list(ctx, next) {\n const role = ctx.action.params.associatedIndex;\n\n const db: Database = ctx.db;\n const collectionRepository = db.getRepository('collections');\n\n // all collections\n const collections = await collectionRepository.find({\n filter: ctx.action.params.filter,\n });\n\n // role collections\n const roleResources = await db.getRepository('rolesResources').find({\n filter: {\n roleName: role,\n },\n });\n\n // role collections\n const roleResourcesNames = roleResources.map((roleResource) => roleResource.get('name'));\n const roleResourceActionResourceNames = roleResources\n .filter((roleResources) => roleResources.get('usingActionsConfig'))\n .map((roleResources) => roleResources.get('name'));\n\n ctx.body = collections\n .map((collection) => {\n const exists = roleResourcesNames.includes(collection.get('name'));\n\n const usingConfig: UsingConfigType = roleResourceActionResourceNames.includes(collection.get('name'))\n ? 'resourceAction'\n : 'strategy';\n\n return {\n name: collection.get('name') as string,\n title: collection.get('title') as string,\n roleName: role,\n usingConfig,\n exists,\n };\n })\n .sort((a, b) => (a.name > b.name ? 1 : -1));\n\n await next();\n },\n },\n};\n\nexport { roleCollectionsResource };\n"]}
|
package/esm/collections/roles.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
name: 'roles',
|
|
3
|
-
title: '{{t("Roles")}}',
|
|
4
|
-
autoGenId: false,
|
|
5
|
-
model: 'RoleModel',
|
|
6
|
-
filterTargetKey: 'name',
|
|
7
|
-
// targetKey: 'name',
|
|
8
|
-
sortable: true,
|
|
9
|
-
fields: [
|
|
10
|
-
{
|
|
11
|
-
type: 'uid',
|
|
12
|
-
name: 'name',
|
|
13
|
-
prefix: 'r_',
|
|
14
|
-
primaryKey: true,
|
|
15
|
-
interface: 'input',
|
|
16
|
-
uiSchema: {
|
|
17
|
-
type: 'string',
|
|
18
|
-
title: '{{t("Role UID")}}',
|
|
19
|
-
'x-component': 'Input',
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
type: 'string',
|
|
24
|
-
name: 'title',
|
|
25
|
-
unique: true,
|
|
26
|
-
interface: 'input',
|
|
27
|
-
uiSchema: {
|
|
28
|
-
type: 'string',
|
|
29
|
-
title: '{{t("Role name")}}',
|
|
30
|
-
'x-component': 'Input',
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
type: 'boolean',
|
|
35
|
-
name: 'default',
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
type: 'string',
|
|
39
|
-
name: 'description',
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
type: 'json',
|
|
43
|
-
name: 'strategy',
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
type: 'boolean',
|
|
47
|
-
name: 'default',
|
|
48
|
-
defaultValue: false,
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
type: 'boolean',
|
|
52
|
-
name: 'hidden',
|
|
53
|
-
defaultValue: false,
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
type: 'boolean',
|
|
57
|
-
name: 'allowConfigure',
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
type: 'boolean',
|
|
61
|
-
name: 'allowNewMenu',
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
type: 'belongsToMany',
|
|
65
|
-
name: 'menuUiSchemas',
|
|
66
|
-
target: 'uiSchemas',
|
|
67
|
-
targetKey: 'x-uid',
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
type: 'hasMany',
|
|
71
|
-
name: 'resources',
|
|
72
|
-
target: 'rolesResources',
|
|
73
|
-
sourceKey: 'name',
|
|
74
|
-
targetKey: 'name',
|
|
75
|
-
},
|
|
76
|
-
],
|
|
77
|
-
};
|
|
78
|
-
//# sourceMappingURL=roles.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"roles.js","sourceRoot":"","sources":["../../src/collections/roles.ts"],"names":[],"mappings":"AAEA,eAAe;IACb,IAAI,EAAE,OAAO;IACb,KAAK,EAAE,gBAAgB;IACvB,SAAS,EAAE,KAAK;IAChB,KAAK,EAAE,WAAW;IAClB,eAAe,EAAE,MAAM;IACvB,qBAAqB;IACrB,QAAQ,EAAE,IAAI;IACd,MAAM,EAAE;QACN;YACE,IAAI,EAAE,KAAK;YACX,IAAI,EAAE,MAAM;YACZ,MAAM,EAAE,IAAI;YACZ,UAAU,EAAE,IAAI;YAChB,SAAS,EAAE,OAAO;YAClB,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,mBAAmB;gBAC1B,aAAa,EAAE,OAAO;aACvB;SACF;QACD;YACE,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,OAAO;YACb,MAAM,EAAE,IAAI;YACZ,SAAS,EAAE,OAAO;YAClB,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,oBAAoB;gBAC3B,aAAa,EAAE,OAAO;aACvB;SACF;QACD;YACE,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,SAAS;SAChB;QACD;YACE,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,aAAa;SACpB;QACD;YACE,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,UAAU;SACjB;QACD;YACE,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,SAAS;YACf,YAAY,EAAE,KAAK;SACpB;QACD;YACE,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,QAAQ;YACd,YAAY,EAAE,KAAK;SACpB;QACD;YACE,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,gBAAgB;SACvB;QACD;YACE,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,cAAc;SACrB;QACD;YACE,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE,eAAe;YACrB,MAAM,EAAE,WAAW;YACnB,SAAS,EAAE,OAAO;SACnB;QACD;YACE,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,WAAW;YACjB,MAAM,EAAE,gBAAgB;YACxB,SAAS,EAAE,MAAM;YACjB,SAAS,EAAE,MAAM;SAClB;KACF;CACmB,CAAC","sourcesContent":["import { CollectionOptions } from '@nocobase/database';\n\nexport default {\n name: 'roles',\n title: '{{t(\"Roles\")}}',\n autoGenId: false,\n model: 'RoleModel',\n filterTargetKey: 'name',\n // targetKey: 'name',\n sortable: true,\n fields: [\n {\n type: 'uid',\n name: 'name',\n prefix: 'r_',\n primaryKey: true,\n interface: 'input',\n uiSchema: {\n type: 'string',\n title: '{{t(\"Role UID\")}}',\n 'x-component': 'Input',\n },\n },\n {\n type: 'string',\n name: 'title',\n unique: true,\n interface: 'input',\n uiSchema: {\n type: 'string',\n title: '{{t(\"Role name\")}}',\n 'x-component': 'Input',\n },\n },\n {\n type: 'boolean',\n name: 'default',\n },\n {\n type: 'string',\n name: 'description',\n },\n {\n type: 'json',\n name: 'strategy',\n },\n {\n type: 'boolean',\n name: 'default',\n defaultValue: false,\n },\n {\n type: 'boolean',\n name: 'hidden',\n defaultValue: false,\n },\n {\n type: 'boolean',\n name: 'allowConfigure',\n },\n {\n type: 'boolean',\n name: 'allowNewMenu',\n },\n {\n type: 'belongsToMany',\n name: 'menuUiSchemas',\n target: 'uiSchemas',\n targetKey: 'x-uid',\n },\n {\n type: 'hasMany',\n name: 'resources',\n target: 'rolesResources',\n sourceKey: 'name',\n targetKey: 'name',\n },\n ],\n} as CollectionOptions;\n"]}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
name: 'rolesResources',
|
|
3
|
-
model: 'RoleResourceModel',
|
|
4
|
-
indexes: [
|
|
5
|
-
{
|
|
6
|
-
unique: true,
|
|
7
|
-
fields: ['roleName', 'name'],
|
|
8
|
-
},
|
|
9
|
-
],
|
|
10
|
-
fields: [
|
|
11
|
-
{
|
|
12
|
-
type: 'belongsTo',
|
|
13
|
-
name: 'role',
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
type: 'string',
|
|
17
|
-
name: 'name',
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
type: 'boolean',
|
|
21
|
-
name: 'usingActionsConfig',
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
type: 'hasMany',
|
|
25
|
-
name: 'actions',
|
|
26
|
-
target: 'rolesResourcesActions',
|
|
27
|
-
},
|
|
28
|
-
],
|
|
29
|
-
};
|
|
30
|
-
//# sourceMappingURL=rolesResources.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rolesResources.js","sourceRoot":"","sources":["../../src/collections/rolesResources.ts"],"names":[],"mappings":"AAEA,eAAe;IACb,IAAI,EAAE,gBAAgB;IACtB,KAAK,EAAE,mBAAmB;IAC1B,OAAO,EAAE;QACP;YACE,MAAM,EAAE,IAAI;YACZ,MAAM,EAAE,CAAC,UAAU,EAAE,MAAM,CAAC;SAC7B;KACF;IACD,MAAM,EAAE;QACN;YACE,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,MAAM;SACb;QACD;YACE,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,MAAM;SACb;QACD;YACE,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,oBAAoB;SAC3B;QACD;YACE,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,SAAS;YACf,MAAM,EAAE,uBAAuB;SAChC;KACF;CACmB,CAAC","sourcesContent":["import { CollectionOptions } from '@nocobase/database';\n\nexport default {\n name: 'rolesResources',\n model: 'RoleResourceModel',\n indexes: [\n {\n unique: true,\n fields: ['roleName', 'name'],\n },\n ],\n fields: [\n {\n type: 'belongsTo',\n name: 'role',\n },\n {\n type: 'string',\n name: 'name',\n },\n {\n type: 'boolean',\n name: 'usingActionsConfig',\n },\n {\n type: 'hasMany',\n name: 'actions',\n target: 'rolesResourcesActions',\n },\n ],\n} as CollectionOptions;\n"]}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
name: 'rolesResourcesActions',
|
|
3
|
-
model: 'RoleResourceActionModel',
|
|
4
|
-
fields: [
|
|
5
|
-
{
|
|
6
|
-
type: 'belongsTo',
|
|
7
|
-
name: 'resource',
|
|
8
|
-
foreignKey: 'rolesResourceId',
|
|
9
|
-
target: 'rolesResources',
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
type: 'string',
|
|
13
|
-
name: 'name',
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
type: 'array',
|
|
17
|
-
name: 'fields',
|
|
18
|
-
defaultValue: [],
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
type: 'belongsTo',
|
|
22
|
-
name: 'scope',
|
|
23
|
-
target: 'rolesResourcesScopes',
|
|
24
|
-
},
|
|
25
|
-
],
|
|
26
|
-
};
|
|
27
|
-
//# sourceMappingURL=rolesResourcesActions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rolesResourcesActions.js","sourceRoot":"","sources":["../../src/collections/rolesResourcesActions.ts"],"names":[],"mappings":"AAEA,eAAe;IACb,IAAI,EAAE,uBAAuB;IAC7B,KAAK,EAAE,yBAAyB;IAChC,MAAM,EAAE;QACN;YACE,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,UAAU;YAChB,UAAU,EAAE,iBAAiB;YAC7B,MAAM,EAAE,gBAAgB;SACzB;QACD;YACE,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,MAAM;SACb;QACD;YACE,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,QAAQ;YACd,YAAY,EAAE,EAAE;SACjB;QACD;YACE,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,OAAO;YACb,MAAM,EAAE,sBAAsB;SAC/B;KACF;CACmB,CAAC","sourcesContent":["import { CollectionOptions } from '@nocobase/database';\n\nexport default {\n name: 'rolesResourcesActions',\n model: 'RoleResourceActionModel',\n fields: [\n {\n type: 'belongsTo',\n name: 'resource',\n foreignKey: 'rolesResourceId',\n target: 'rolesResources',\n },\n {\n type: 'string',\n name: 'name',\n },\n {\n type: 'array',\n name: 'fields',\n defaultValue: [],\n },\n {\n type: 'belongsTo',\n name: 'scope',\n target: 'rolesResourcesScopes',\n },\n ],\n} as CollectionOptions;\n"]}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
name: 'rolesResourcesScopes',
|
|
3
|
-
fields: [
|
|
4
|
-
{
|
|
5
|
-
type: 'uid',
|
|
6
|
-
name: 'key',
|
|
7
|
-
},
|
|
8
|
-
{
|
|
9
|
-
type: 'string',
|
|
10
|
-
name: 'name',
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
type: 'string',
|
|
14
|
-
name: 'resourceName',
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
type: 'json',
|
|
18
|
-
name: 'scope',
|
|
19
|
-
},
|
|
20
|
-
],
|
|
21
|
-
};
|
|
22
|
-
//# sourceMappingURL=rolesResourcesScopes.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rolesResourcesScopes.js","sourceRoot":"","sources":["../../src/collections/rolesResourcesScopes.ts"],"names":[],"mappings":"AAEA,eAAe;IACb,IAAI,EAAE,sBAAsB;IAC5B,MAAM,EAAE;QACN;YACE,IAAI,EAAE,KAAK;YACX,IAAI,EAAE,KAAK;SACZ;QACD;YACE,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,MAAM;SACb;QACD;YACE,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,cAAc;SACrB;QACD;YACE,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,OAAO;SACd;KACF;CACmB,CAAC","sourcesContent":["import { CollectionOptions } from '@nocobase/database';\n\nexport default {\n name: 'rolesResourcesScopes',\n fields: [\n {\n type: 'uid',\n name: 'key',\n },\n {\n type: 'string',\n name: 'name',\n },\n {\n type: 'string',\n name: 'resourceName',\n },\n {\n type: 'json',\n name: 'scope',\n },\n ],\n} as CollectionOptions;\n"]}
|
package/esm/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from './server';
|
package/esm/index.js
DELETED
package/esm/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC","sourcesContent":["export { default } from './server';\n\n"]}
|