@nocobase/acl 0.20.0-alpha.15 → 0.20.0-alpha.17

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 (3) hide show
  1. package/lib/acl.d.ts +42 -0
  2. package/lib/acl.js +42 -0
  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
  }
@@ -175,6 +202,9 @@ const _ACL = class _ACL extends import_events.default {
175
202
  }
176
203
  return null;
177
204
  }
205
+ /**
206
+ * @internal
207
+ */
178
208
  resolveActionAlias(action) {
179
209
  return this.actionAlias.get(action) ? this.actionAlias.get(action) : action;
180
210
  }
@@ -187,6 +217,9 @@ const _ACL = class _ACL extends import_events.default {
187
217
  allow(resourceName, actionNames, condition) {
188
218
  return this.skip(resourceName, actionNames, condition);
189
219
  }
220
+ /**
221
+ * @deprecated
222
+ */
190
223
  skip(resourceName, actionNames, condition) {
191
224
  if (!Array.isArray(actionNames)) {
192
225
  actionNames = [actionNames];
@@ -195,6 +228,9 @@ const _ACL = class _ACL extends import_events.default {
195
228
  this.allowManager.allow(resourceName, actionName, condition);
196
229
  }
197
230
  }
231
+ /**
232
+ * @internal
233
+ */
198
234
  async parseJsonTemplate(json, ctx) {
199
235
  var _a, _b, _c, _d, _e;
200
236
  if (json.filter) {
@@ -232,6 +268,9 @@ const _ACL = class _ACL extends import_events.default {
232
268
  return (0, import_koa_compose.default)(acl.middlewares.nodes)(ctx, next);
233
269
  }, "ACLMiddleware");
234
270
  }
271
+ /**
272
+ * @internal
273
+ */
235
274
  async getActionParams(ctx) {
236
275
  const roleName = ctx.state.currentRole || "anonymous";
237
276
  const { resourceName, actionName } = ctx.action;
@@ -254,6 +293,9 @@ const _ACL = class _ACL extends import_events.default {
254
293
  registerSnippet(snippet) {
255
294
  this.snippetManager.register(snippet);
256
295
  }
296
+ /**
297
+ * @internal
298
+ */
257
299
  filterParams(ctx, resourceName, params) {
258
300
  var _a;
259
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.20.0-alpha.15",
3
+ "version": "0.20.0-alpha.17",
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.20.0-alpha.15",
10
- "@nocobase/utils": "0.20.0-alpha.15",
9
+ "@nocobase/resourcer": "0.20.0-alpha.17",
10
+ "@nocobase/utils": "0.20.0-alpha.17",
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": "ec192dcfe2dadda913e2d4c67b3706d78d5d3b9c"
18
+ "gitHead": "a2460c222bc0b8a3bcb783b5c856499d756efa82"
19
19
  }