@nocobase/plugin-acl 0.7.0-alpha.8 → 0.7.0-alpha.80
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
|
@@ -1,29 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
12
6
|
exports.availableActionResource = void 0;
|
|
7
|
+
|
|
8
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
9
|
+
|
|
10
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
11
|
+
|
|
12
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
13
|
+
|
|
14
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
15
|
+
|
|
16
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
17
|
+
|
|
13
18
|
const availableActionResource = {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
name: 'availableActions',
|
|
20
|
+
actions: {
|
|
21
|
+
list(ctx, next) {
|
|
22
|
+
return _asyncToGenerator(function* () {
|
|
23
|
+
const acl = ctx.app.acl;
|
|
24
|
+
const availableActions = acl.getAvailableActions();
|
|
25
|
+
ctx.body = Array.from(availableActions.entries()).map(([, {
|
|
26
|
+
name,
|
|
27
|
+
options
|
|
28
|
+
}]) => {
|
|
29
|
+
return _objectSpread(_objectSpread({}, options), {}, {
|
|
30
|
+
name
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
yield next();
|
|
34
|
+
})();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
}
|
|
27
38
|
};
|
|
28
|
-
exports.availableActionResource = availableActionResource;
|
|
29
|
-
//# sourceMappingURL=available-actions.js.map
|
|
39
|
+
exports.availableActionResource = availableActionResource;
|
|
@@ -1,42 +1,89 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.checkAction = checkAction;
|
|
7
|
+
|
|
8
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
9
|
+
|
|
10
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
11
|
+
|
|
12
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
13
|
+
|
|
14
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
15
|
+
|
|
16
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
17
|
+
|
|
18
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
19
|
+
|
|
20
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
21
|
+
|
|
22
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
23
|
+
|
|
24
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
25
|
+
|
|
26
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
27
|
+
|
|
28
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
29
|
+
|
|
30
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
31
|
+
|
|
32
|
+
const map2obj = map => {
|
|
33
|
+
const obj = {};
|
|
34
|
+
|
|
35
|
+
var _iterator = _createForOfIteratorHelper(map),
|
|
36
|
+
_step;
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
40
|
+
let _step$value = _slicedToArray(_step.value, 2),
|
|
41
|
+
key = _step$value[0],
|
|
42
|
+
value = _step$value[1];
|
|
43
|
+
|
|
44
|
+
obj[key] = value;
|
|
17
45
|
}
|
|
18
|
-
|
|
46
|
+
} catch (err) {
|
|
47
|
+
_iterator.e(err);
|
|
48
|
+
} finally {
|
|
49
|
+
_iterator.f();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return obj;
|
|
19
53
|
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (currentRole) {
|
|
24
|
-
const roleInstance = yield ctx.db.getRepository('roles').findOne({
|
|
25
|
-
filter: {
|
|
26
|
-
name: currentRole,
|
|
27
|
-
},
|
|
28
|
-
appends: ['menuUiSchemas'],
|
|
29
|
-
});
|
|
30
|
-
const anonymous = yield ctx.db.getRepository('roles').findOne({
|
|
31
|
-
filter: {
|
|
32
|
-
name: 'anonymous',
|
|
33
|
-
},
|
|
34
|
-
});
|
|
35
|
-
const role = ctx.app.acl.getRole(currentRole);
|
|
36
|
-
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 });
|
|
37
|
-
}
|
|
38
|
-
yield next();
|
|
39
|
-
});
|
|
54
|
+
|
|
55
|
+
function checkAction(_x, _x2) {
|
|
56
|
+
return _checkAction.apply(this, arguments);
|
|
40
57
|
}
|
|
41
|
-
|
|
42
|
-
|
|
58
|
+
|
|
59
|
+
function _checkAction() {
|
|
60
|
+
_checkAction = _asyncToGenerator(function* (ctx, next) {
|
|
61
|
+
const currentRole = ctx.state.currentRole;
|
|
62
|
+
|
|
63
|
+
if (currentRole) {
|
|
64
|
+
const roleInstance = yield ctx.db.getRepository('roles').findOne({
|
|
65
|
+
filter: {
|
|
66
|
+
name: currentRole
|
|
67
|
+
},
|
|
68
|
+
appends: ['menuUiSchemas']
|
|
69
|
+
});
|
|
70
|
+
const anonymous = yield ctx.db.getRepository('roles').findOne({
|
|
71
|
+
filter: {
|
|
72
|
+
name: 'anonymous'
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
const role = ctx.app.acl.getRole(currentRole);
|
|
76
|
+
ctx.body = _objectSpread(_objectSpread({}, role.toJSON()), {}, {
|
|
77
|
+
resources: [...role.resources.keys()],
|
|
78
|
+
actionAlias: map2obj(ctx.app.acl.actionAlias),
|
|
79
|
+
allowAll: currentRole === 'root',
|
|
80
|
+
allowConfigure: roleInstance.get('allowConfigure'),
|
|
81
|
+
allowMenuItemIds: roleInstance.get('menuUiSchemas').map(uiSchema => uiSchema.get('x-uid')),
|
|
82
|
+
allowAnonymous: !!anonymous
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
yield next();
|
|
87
|
+
});
|
|
88
|
+
return _checkAction.apply(this, arguments);
|
|
89
|
+
}
|
|
@@ -1,57 +1,82 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
12
6
|
exports.roleCollectionsResource = void 0;
|
|
7
|
+
|
|
8
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
9
|
+
|
|
10
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
11
|
+
|
|
12
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
13
|
+
|
|
14
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
15
|
+
|
|
16
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
17
|
+
|
|
18
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
19
|
+
|
|
20
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
21
|
+
|
|
22
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
23
|
+
|
|
24
|
+
function totalPage(total, pageSize) {
|
|
25
|
+
return Math.ceil(total / pageSize);
|
|
26
|
+
}
|
|
27
|
+
|
|
13
28
|
const roleCollectionsResource = {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
29
|
+
name: 'roles.collections',
|
|
30
|
+
actions: {
|
|
31
|
+
list(ctx, next) {
|
|
32
|
+
return _asyncToGenerator(function* () {
|
|
33
|
+
const role = ctx.action.params.associatedIndex;
|
|
34
|
+
const _ctx$action$params = ctx.action.params,
|
|
35
|
+
_ctx$action$params$pa = _ctx$action$params.page,
|
|
36
|
+
page = _ctx$action$params$pa === void 0 ? 1 : _ctx$action$params$pa,
|
|
37
|
+
_ctx$action$params$pa2 = _ctx$action$params.pageSize,
|
|
38
|
+
pageSize = _ctx$action$params$pa2 === void 0 ? 20 : _ctx$action$params$pa2;
|
|
39
|
+
const db = ctx.db;
|
|
40
|
+
const collectionRepository = db.getRepository('collections'); // all collections
|
|
41
|
+
|
|
42
|
+
const _yield$collectionRepo = yield collectionRepository.findAndCount({
|
|
43
|
+
filter: ctx.action.params.filter,
|
|
44
|
+
sort: 'sort'
|
|
45
|
+
}),
|
|
46
|
+
_yield$collectionRepo2 = _slicedToArray(_yield$collectionRepo, 2),
|
|
47
|
+
collections = _yield$collectionRepo2[0],
|
|
48
|
+
count = _yield$collectionRepo2[1]; // role collections
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
const roleResources = yield db.getRepository('rolesResources').find({
|
|
52
|
+
filter: {
|
|
53
|
+
roleName: role
|
|
54
|
+
}
|
|
55
|
+
}); // role collections
|
|
56
|
+
|
|
57
|
+
const roleResourcesNames = roleResources.map(roleResource => roleResource.get('name'));
|
|
58
|
+
const roleResourceActionResourceNames = roleResources.filter(roleResources => roleResources.get('usingActionsConfig')).map(roleResources => roleResources.get('name'));
|
|
59
|
+
ctx.body = {
|
|
60
|
+
count,
|
|
61
|
+
rows: collections.map(collection => {
|
|
62
|
+
const exists = roleResourcesNames.includes(collection.get('name'));
|
|
63
|
+
const usingConfig = roleResourceActionResourceNames.includes(collection.get('name')) ? 'resourceAction' : 'strategy';
|
|
64
|
+
return {
|
|
65
|
+
name: collection.get('name'),
|
|
66
|
+
title: collection.get('title'),
|
|
67
|
+
roleName: role,
|
|
68
|
+
usingConfig,
|
|
69
|
+
exists
|
|
70
|
+
};
|
|
71
|
+
}),
|
|
72
|
+
page: Number(page),
|
|
73
|
+
pageSize: Number(pageSize),
|
|
74
|
+
totalPage: totalPage(count, pageSize)
|
|
75
|
+
};
|
|
76
|
+
yield next();
|
|
77
|
+
})();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
}
|
|
55
81
|
};
|
|
56
|
-
exports.roleCollectionsResource = roleCollectionsResource;
|
|
57
|
-
//# sourceMappingURL=role-collections.js.map
|
|
82
|
+
exports.roleCollectionsResource = roleCollectionsResource;
|
package/lib/collections/roles.js
CHANGED
|
@@ -1,80 +1,72 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
exports
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
{
|
|
72
|
-
type: 'hasMany',
|
|
73
|
-
name: 'resources',
|
|
74
|
-
target: 'rolesResources',
|
|
75
|
-
sourceKey: 'name',
|
|
76
|
-
targetKey: 'name',
|
|
77
|
-
},
|
|
78
|
-
],
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _default = {
|
|
8
|
+
name: 'roles',
|
|
9
|
+
title: '{{t("Roles")}}',
|
|
10
|
+
autoGenId: false,
|
|
11
|
+
model: 'RoleModel',
|
|
12
|
+
filterTargetKey: 'name',
|
|
13
|
+
// targetKey: 'name',
|
|
14
|
+
sortable: true,
|
|
15
|
+
fields: [{
|
|
16
|
+
type: 'uid',
|
|
17
|
+
name: 'name',
|
|
18
|
+
prefix: 'r_',
|
|
19
|
+
primaryKey: true,
|
|
20
|
+
interface: 'input',
|
|
21
|
+
uiSchema: {
|
|
22
|
+
type: 'string',
|
|
23
|
+
title: '{{t("Role UID")}}',
|
|
24
|
+
'x-component': 'Input'
|
|
25
|
+
}
|
|
26
|
+
}, {
|
|
27
|
+
type: 'string',
|
|
28
|
+
name: 'title',
|
|
29
|
+
unique: true,
|
|
30
|
+
interface: 'input',
|
|
31
|
+
uiSchema: {
|
|
32
|
+
type: 'string',
|
|
33
|
+
title: '{{t("Role name")}}',
|
|
34
|
+
'x-component': 'Input'
|
|
35
|
+
}
|
|
36
|
+
}, {
|
|
37
|
+
type: 'boolean',
|
|
38
|
+
name: 'default'
|
|
39
|
+
}, {
|
|
40
|
+
type: 'string',
|
|
41
|
+
name: 'description'
|
|
42
|
+
}, {
|
|
43
|
+
type: 'json',
|
|
44
|
+
name: 'strategy'
|
|
45
|
+
}, {
|
|
46
|
+
type: 'boolean',
|
|
47
|
+
name: 'default',
|
|
48
|
+
defaultValue: false
|
|
49
|
+
}, {
|
|
50
|
+
type: 'boolean',
|
|
51
|
+
name: 'hidden',
|
|
52
|
+
defaultValue: false
|
|
53
|
+
}, {
|
|
54
|
+
type: 'boolean',
|
|
55
|
+
name: 'allowConfigure'
|
|
56
|
+
}, {
|
|
57
|
+
type: 'boolean',
|
|
58
|
+
name: 'allowNewMenu'
|
|
59
|
+
}, {
|
|
60
|
+
type: 'belongsToMany',
|
|
61
|
+
name: 'menuUiSchemas',
|
|
62
|
+
target: 'uiSchemas',
|
|
63
|
+
targetKey: 'x-uid'
|
|
64
|
+
}, {
|
|
65
|
+
type: 'hasMany',
|
|
66
|
+
name: 'resources',
|
|
67
|
+
target: 'rolesResources',
|
|
68
|
+
sourceKey: 'name',
|
|
69
|
+
targetKey: 'name'
|
|
70
|
+
}]
|
|
79
71
|
};
|
|
80
|
-
|
|
72
|
+
exports.default = _default;
|
|
@@ -1,32 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
exports
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
fields: [
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
target: 'rolesResourcesActions',
|
|
29
|
-
},
|
|
30
|
-
],
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _default = {
|
|
8
|
+
name: 'rolesResources',
|
|
9
|
+
model: 'RoleResourceModel',
|
|
10
|
+
indexes: [{
|
|
11
|
+
unique: true,
|
|
12
|
+
fields: ['roleName', 'name']
|
|
13
|
+
}],
|
|
14
|
+
fields: [{
|
|
15
|
+
type: 'belongsTo',
|
|
16
|
+
name: 'role'
|
|
17
|
+
}, {
|
|
18
|
+
type: 'string',
|
|
19
|
+
name: 'name'
|
|
20
|
+
}, {
|
|
21
|
+
type: 'boolean',
|
|
22
|
+
name: 'usingActionsConfig'
|
|
23
|
+
}, {
|
|
24
|
+
type: 'hasMany',
|
|
25
|
+
name: 'actions',
|
|
26
|
+
target: 'rolesResourcesActions'
|
|
27
|
+
}]
|
|
31
28
|
};
|
|
32
|
-
|
|
29
|
+
exports.default = _default;
|
|
@@ -1,29 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
exports
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
],
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _default = {
|
|
8
|
+
name: 'rolesResourcesActions',
|
|
9
|
+
model: 'RoleResourceActionModel',
|
|
10
|
+
fields: [{
|
|
11
|
+
type: 'belongsTo',
|
|
12
|
+
name: 'resource',
|
|
13
|
+
foreignKey: 'rolesResourceId',
|
|
14
|
+
target: 'rolesResources'
|
|
15
|
+
}, {
|
|
16
|
+
type: 'string',
|
|
17
|
+
name: 'name'
|
|
18
|
+
}, {
|
|
19
|
+
type: 'array',
|
|
20
|
+
name: 'fields',
|
|
21
|
+
defaultValue: []
|
|
22
|
+
}, {
|
|
23
|
+
type: 'belongsTo',
|
|
24
|
+
name: 'scope',
|
|
25
|
+
target: 'rolesResourcesScopes'
|
|
26
|
+
}]
|
|
28
27
|
};
|
|
29
|
-
|
|
28
|
+
exports.default = _default;
|