@nocobase/acl 0.20.0-alpha.8 → 0.21.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.
- package/lib/acl.d.ts +42 -0
- package/lib/acl.js +42 -3
- package/package.json +4 -4
package/lib/acl.d.ts
CHANGED
|
@@ -37,11 +37,29 @@ interface CanArgs {
|
|
|
37
37
|
ctx?: any;
|
|
38
38
|
}
|
|
39
39
|
export declare class ACL extends EventEmitter {
|
|
40
|
+
/**
|
|
41
|
+
* @internal
|
|
42
|
+
*/
|
|
40
43
|
availableStrategy: Map<string, ACLAvailableStrategy>;
|
|
44
|
+
/**
|
|
45
|
+
* @internal
|
|
46
|
+
*/
|
|
41
47
|
allowManager: AllowManager;
|
|
48
|
+
/**
|
|
49
|
+
* @internal
|
|
50
|
+
*/
|
|
42
51
|
snippetManager: SnippetManager;
|
|
52
|
+
/**
|
|
53
|
+
* @internal
|
|
54
|
+
*/
|
|
43
55
|
roles: Map<string, ACLRole>;
|
|
56
|
+
/**
|
|
57
|
+
* @internal
|
|
58
|
+
*/
|
|
44
59
|
actionAlias: Map<string, string>;
|
|
60
|
+
/**
|
|
61
|
+
* @internal
|
|
62
|
+
*/
|
|
45
63
|
configResources: string[];
|
|
46
64
|
protected availableActions: Map<string, ACLAvailableAction>;
|
|
47
65
|
protected fixedParamsManager: FixedParamsManager;
|
|
@@ -50,8 +68,17 @@ export declare class ACL extends EventEmitter {
|
|
|
50
68
|
define(options: DefineOptions): ACLRole;
|
|
51
69
|
getRole(name: string): ACLRole;
|
|
52
70
|
removeRole(name: string): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* @internal
|
|
73
|
+
*/
|
|
53
74
|
registerConfigResources(names: string[]): void;
|
|
75
|
+
/**
|
|
76
|
+
* @internal
|
|
77
|
+
*/
|
|
54
78
|
registerConfigResource(name: string): void;
|
|
79
|
+
/**
|
|
80
|
+
* @internal
|
|
81
|
+
*/
|
|
55
82
|
isConfigResource(name: string): boolean;
|
|
56
83
|
setAvailableAction(name: string, options?: AvailableActionOptions): void;
|
|
57
84
|
getAvailableAction(name: string): ACLAvailableAction;
|
|
@@ -59,15 +86,30 @@ export declare class ACL extends EventEmitter {
|
|
|
59
86
|
setAvailableStrategy(name: string, options: AvailableStrategyOptions): void;
|
|
60
87
|
beforeGrantAction(listener?: Listener): void;
|
|
61
88
|
can(options: CanArgs): CanResult | null;
|
|
89
|
+
/**
|
|
90
|
+
* @internal
|
|
91
|
+
*/
|
|
62
92
|
resolveActionAlias(action: string): string;
|
|
63
93
|
use(fn: any, options?: ToposortOptions): void;
|
|
64
94
|
allow(resourceName: string, actionNames: string[] | string, condition?: string | ConditionFunc): void;
|
|
95
|
+
/**
|
|
96
|
+
* @deprecated
|
|
97
|
+
*/
|
|
65
98
|
skip(resourceName: string, actionNames: string[] | string, condition?: string | ConditionFunc): void;
|
|
99
|
+
/**
|
|
100
|
+
* @internal
|
|
101
|
+
*/
|
|
66
102
|
parseJsonTemplate(json: any, ctx: any): Promise<any>;
|
|
67
103
|
middleware(): (ctx: any, next: any) => Promise<void>;
|
|
104
|
+
/**
|
|
105
|
+
* @internal
|
|
106
|
+
*/
|
|
68
107
|
getActionParams(ctx: any): Promise<void>;
|
|
69
108
|
addFixedParams(resource: string, action: string, merger: Merger): void;
|
|
70
109
|
registerSnippet(snippet: SnippetOptions): void;
|
|
110
|
+
/**
|
|
111
|
+
* @internal
|
|
112
|
+
*/
|
|
71
113
|
filterParams(ctx: any, resourceName: any, params: any): any;
|
|
72
114
|
protected addCoreMiddleware(): void;
|
|
73
115
|
protected isAvailableAction(actionName: string): boolean;
|
package/lib/acl.js
CHANGED
|
@@ -42,11 +42,29 @@ var import_allow_manager = require("./allow-manager");
|
|
|
42
42
|
var import_fixed_params_manager = __toESM(require("./fixed-params-manager"));
|
|
43
43
|
var import_snippet_manager = __toESM(require("./snippet-manager"));
|
|
44
44
|
const _ACL = class _ACL extends import_events.default {
|
|
45
|
+
/**
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
45
48
|
availableStrategy = /* @__PURE__ */ new Map();
|
|
49
|
+
/**
|
|
50
|
+
* @internal
|
|
51
|
+
*/
|
|
46
52
|
allowManager = new import_allow_manager.AllowManager(this);
|
|
53
|
+
/**
|
|
54
|
+
* @internal
|
|
55
|
+
*/
|
|
47
56
|
snippetManager = new import_snippet_manager.default();
|
|
57
|
+
/**
|
|
58
|
+
* @internal
|
|
59
|
+
*/
|
|
48
60
|
roles = /* @__PURE__ */ new Map();
|
|
61
|
+
/**
|
|
62
|
+
* @internal
|
|
63
|
+
*/
|
|
49
64
|
actionAlias = /* @__PURE__ */ new Map();
|
|
65
|
+
/**
|
|
66
|
+
* @internal
|
|
67
|
+
*/
|
|
50
68
|
configResources = [];
|
|
51
69
|
availableActions = /* @__PURE__ */ new Map();
|
|
52
70
|
fixedParamsManager = new import_fixed_params_manager.default();
|
|
@@ -95,12 +113,21 @@ const _ACL = class _ACL extends import_events.default {
|
|
|
95
113
|
removeRole(name) {
|
|
96
114
|
return this.roles.delete(name);
|
|
97
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* @internal
|
|
118
|
+
*/
|
|
98
119
|
registerConfigResources(names) {
|
|
99
120
|
names.forEach((name) => this.registerConfigResource(name));
|
|
100
121
|
}
|
|
122
|
+
/**
|
|
123
|
+
* @internal
|
|
124
|
+
*/
|
|
101
125
|
registerConfigResource(name) {
|
|
102
126
|
this.configResources.push(name);
|
|
103
127
|
}
|
|
128
|
+
/**
|
|
129
|
+
* @internal
|
|
130
|
+
*/
|
|
104
131
|
isConfigResource(name) {
|
|
105
132
|
return this.configResources.includes(name);
|
|
106
133
|
}
|
|
@@ -133,9 +160,6 @@ const _ACL = class _ACL extends import_events.default {
|
|
|
133
160
|
return null;
|
|
134
161
|
}
|
|
135
162
|
const snippetAllowed = aclRole.snippetAllowed(`${resource}:${action}`);
|
|
136
|
-
if (snippetAllowed === false) {
|
|
137
|
-
return null;
|
|
138
|
-
}
|
|
139
163
|
const fixedParams = this.fixedParamsManager.getParams(resource, action);
|
|
140
164
|
const mergeParams = /* @__PURE__ */ __name((result) => {
|
|
141
165
|
const params = result["params"] || {};
|
|
@@ -178,6 +202,9 @@ const _ACL = class _ACL extends import_events.default {
|
|
|
178
202
|
}
|
|
179
203
|
return null;
|
|
180
204
|
}
|
|
205
|
+
/**
|
|
206
|
+
* @internal
|
|
207
|
+
*/
|
|
181
208
|
resolveActionAlias(action) {
|
|
182
209
|
return this.actionAlias.get(action) ? this.actionAlias.get(action) : action;
|
|
183
210
|
}
|
|
@@ -190,6 +217,9 @@ const _ACL = class _ACL extends import_events.default {
|
|
|
190
217
|
allow(resourceName, actionNames, condition) {
|
|
191
218
|
return this.skip(resourceName, actionNames, condition);
|
|
192
219
|
}
|
|
220
|
+
/**
|
|
221
|
+
* @deprecated
|
|
222
|
+
*/
|
|
193
223
|
skip(resourceName, actionNames, condition) {
|
|
194
224
|
if (!Array.isArray(actionNames)) {
|
|
195
225
|
actionNames = [actionNames];
|
|
@@ -198,6 +228,9 @@ const _ACL = class _ACL extends import_events.default {
|
|
|
198
228
|
this.allowManager.allow(resourceName, actionName, condition);
|
|
199
229
|
}
|
|
200
230
|
}
|
|
231
|
+
/**
|
|
232
|
+
* @internal
|
|
233
|
+
*/
|
|
201
234
|
async parseJsonTemplate(json, ctx) {
|
|
202
235
|
var _a, _b, _c, _d, _e;
|
|
203
236
|
if (json.filter) {
|
|
@@ -235,6 +268,9 @@ const _ACL = class _ACL extends import_events.default {
|
|
|
235
268
|
return (0, import_koa_compose.default)(acl.middlewares.nodes)(ctx, next);
|
|
236
269
|
}, "ACLMiddleware");
|
|
237
270
|
}
|
|
271
|
+
/**
|
|
272
|
+
* @internal
|
|
273
|
+
*/
|
|
238
274
|
async getActionParams(ctx) {
|
|
239
275
|
const roleName = ctx.state.currentRole || "anonymous";
|
|
240
276
|
const { resourceName, actionName } = ctx.action;
|
|
@@ -257,6 +293,9 @@ const _ACL = class _ACL extends import_events.default {
|
|
|
257
293
|
registerSnippet(snippet) {
|
|
258
294
|
this.snippetManager.register(snippet);
|
|
259
295
|
}
|
|
296
|
+
/**
|
|
297
|
+
* @internal
|
|
298
|
+
*/
|
|
260
299
|
filterParams(ctx, resourceName, params) {
|
|
261
300
|
var _a;
|
|
262
301
|
if ((_a = params == null ? void 0 : params.filter) == null ? void 0 : _a.createdById) {
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/acl",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0-alpha.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "./lib/index.js",
|
|
7
7
|
"types": "./lib/index.d.ts",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@nocobase/resourcer": "0.
|
|
10
|
-
"@nocobase/utils": "0.
|
|
9
|
+
"@nocobase/resourcer": "0.21.0-alpha.1",
|
|
10
|
+
"@nocobase/utils": "0.21.0-alpha.1",
|
|
11
11
|
"minimatch": "^5.1.1"
|
|
12
12
|
},
|
|
13
13
|
"repository": {
|
|
@@ -15,5 +15,5 @@
|
|
|
15
15
|
"url": "git+https://github.com/nocobase/nocobase.git",
|
|
16
16
|
"directory": "packages/acl"
|
|
17
17
|
},
|
|
18
|
-
"gitHead": "
|
|
18
|
+
"gitHead": "afd2f3d1341b85ea9daa7b2667dd4ace1fafb7ff"
|
|
19
19
|
}
|