@nocobase/plugin-acl 0.12.0-alpha.5 → 0.13.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.
@@ -278,21 +278,15 @@ class PluginACL extends server.Plugin {
278
278
  });
279
279
  }
280
280
  });
281
- this.app.on("afterLoad", async (app, options) => {
282
- if ((options == null ? void 0 : options.method) === "install" || (options == null ? void 0 : options.method) === "upgrade") {
283
- return;
284
- }
281
+ const writeRolesToACL = async (app, options) => {
285
282
  const exists = await this.app.db.collectionExistsInDb("roles");
286
283
  if (exists) {
284
+ this.log.info("write roles to ACL");
287
285
  await this.writeRolesToACL();
288
286
  }
289
- });
290
- this.app.on("afterInstall", async (app, options) => {
291
- const exists = await this.app.db.collectionExistsInDb("roles");
292
- if (exists) {
293
- await this.writeRolesToACL();
294
- }
295
- });
287
+ };
288
+ this.app.on("afterLoad", writeRolesToACL);
289
+ this.app.on("afterInstall", writeRolesToACL);
296
290
  this.app.on("afterInstallPlugin", async (plugin) => {
297
291
  if (plugin.getName() !== "users") {
298
292
  return;
@@ -0,0 +1,366 @@
1
+ declare const _default: {
2
+ openapi: string;
3
+ info: {
4
+ title: string;
5
+ };
6
+ paths: {
7
+ '/roles:list': {
8
+ get: {
9
+ tags: string[];
10
+ description: string;
11
+ parameters: any[];
12
+ responses: {
13
+ 200: {
14
+ description: string;
15
+ content: {
16
+ 'application/json': {
17
+ schema: {
18
+ type: string;
19
+ items: {
20
+ $ref: string;
21
+ };
22
+ };
23
+ };
24
+ };
25
+ };
26
+ };
27
+ };
28
+ };
29
+ '/roles:get': {
30
+ get: {
31
+ tags: string[];
32
+ description: string;
33
+ parameters: {
34
+ name: string;
35
+ in: string;
36
+ description: string;
37
+ required: boolean;
38
+ schema: {
39
+ type: string;
40
+ };
41
+ }[];
42
+ responses: {
43
+ 200: {
44
+ description: string;
45
+ content: {
46
+ 'application/json': {
47
+ schema: {
48
+ $ref: string;
49
+ };
50
+ };
51
+ };
52
+ };
53
+ };
54
+ };
55
+ };
56
+ '/roles:create': {
57
+ post: {
58
+ tags: string[];
59
+ description: string;
60
+ requestBody: {
61
+ content: {
62
+ 'application/json': {
63
+ schema: {
64
+ $ref: string;
65
+ };
66
+ };
67
+ };
68
+ };
69
+ responses: {
70
+ '200': {
71
+ description: string;
72
+ content: {
73
+ 'application/json': {
74
+ schema: {
75
+ $ref: string;
76
+ };
77
+ };
78
+ };
79
+ };
80
+ };
81
+ };
82
+ };
83
+ '/roles:update': {
84
+ post: {
85
+ tags: string[];
86
+ description: string;
87
+ parameters: {
88
+ name: string;
89
+ in: string;
90
+ description: string;
91
+ required: boolean;
92
+ schema: {
93
+ type: string;
94
+ };
95
+ }[];
96
+ requestBody: {
97
+ content: {
98
+ 'application/json': {
99
+ schema: {
100
+ $ref: string;
101
+ };
102
+ };
103
+ };
104
+ };
105
+ responses: {
106
+ 200: {
107
+ description: string;
108
+ content: {
109
+ 'application/json': {
110
+ schema: {
111
+ $ref: string;
112
+ };
113
+ };
114
+ };
115
+ };
116
+ };
117
+ };
118
+ };
119
+ '/roles:destroy': {
120
+ post: {
121
+ tags: string[];
122
+ description: string;
123
+ parameters: {
124
+ name: string;
125
+ in: string;
126
+ description: string;
127
+ required: boolean;
128
+ schema: {
129
+ type: string;
130
+ };
131
+ }[];
132
+ responses: {
133
+ '200': {
134
+ description: string;
135
+ };
136
+ };
137
+ };
138
+ };
139
+ '/roles:check': {
140
+ get: {
141
+ tags: string[];
142
+ description: string;
143
+ responses: {
144
+ 200: {
145
+ description: string;
146
+ content: {
147
+ 'application/json': {
148
+ schema: {
149
+ $ref: string;
150
+ };
151
+ };
152
+ };
153
+ };
154
+ };
155
+ };
156
+ };
157
+ '/roles:setDefaultRole': {
158
+ post: {
159
+ tags: string[];
160
+ description: string;
161
+ requestBody: {
162
+ content: {
163
+ 'application/json': {
164
+ schema: {
165
+ type: string;
166
+ properties: {
167
+ roleName: {
168
+ type: string;
169
+ };
170
+ };
171
+ };
172
+ };
173
+ };
174
+ };
175
+ responses: {
176
+ '200': {
177
+ description: string;
178
+ };
179
+ };
180
+ };
181
+ };
182
+ '/roles/{roleName}/collections:list': {
183
+ get: {
184
+ tags: string[];
185
+ description: string;
186
+ parameters: {
187
+ name: string;
188
+ in: string;
189
+ description: string;
190
+ required: boolean;
191
+ schema: {
192
+ type: string;
193
+ };
194
+ }[];
195
+ responses: {
196
+ '200': {
197
+ description: string;
198
+ content: {
199
+ 'application/json': {
200
+ schema: {
201
+ type: string;
202
+ items: {
203
+ type: string;
204
+ properties: {
205
+ type: {
206
+ type: string;
207
+ description: string;
208
+ };
209
+ name: {
210
+ type: string;
211
+ description: string;
212
+ };
213
+ collectionName: {
214
+ type: string;
215
+ description: string;
216
+ };
217
+ title: {
218
+ type: string;
219
+ description: string;
220
+ };
221
+ roleName: {
222
+ type: string;
223
+ description: string;
224
+ };
225
+ usingConfig: {
226
+ type: string;
227
+ enum: string[];
228
+ description: string;
229
+ };
230
+ exists: {
231
+ type: string;
232
+ description: string;
233
+ };
234
+ };
235
+ };
236
+ };
237
+ };
238
+ };
239
+ };
240
+ };
241
+ };
242
+ };
243
+ '/availableActions:list': {
244
+ get: {
245
+ tags: string[];
246
+ description: string;
247
+ parameters: any[];
248
+ responses: {
249
+ '200': {
250
+ description: string;
251
+ content: {
252
+ 'application/json': {
253
+ schema: {
254
+ type: string;
255
+ items: {
256
+ type: string;
257
+ properties: {
258
+ name: {
259
+ type: string;
260
+ description: string;
261
+ };
262
+ displayName: {
263
+ type: string;
264
+ description: string;
265
+ };
266
+ allowConfigureFields: {
267
+ type: string;
268
+ description: string;
269
+ };
270
+ onNewRecord: {
271
+ type: string;
272
+ description: string;
273
+ };
274
+ type: {
275
+ type: string;
276
+ description: string;
277
+ };
278
+ aliases: {
279
+ type: string;
280
+ items: {
281
+ type: string;
282
+ };
283
+ description: string;
284
+ };
285
+ };
286
+ };
287
+ };
288
+ };
289
+ };
290
+ };
291
+ };
292
+ };
293
+ };
294
+ };
295
+ components: {
296
+ schemas: {
297
+ role: {
298
+ type: string;
299
+ properties: {
300
+ title: {
301
+ type: string;
302
+ description: string;
303
+ };
304
+ name: {
305
+ type: string;
306
+ description: string;
307
+ };
308
+ description: {
309
+ type: string;
310
+ description: string;
311
+ };
312
+ hidden: {
313
+ type: string;
314
+ description: string;
315
+ };
316
+ default: {
317
+ type: string;
318
+ description: string;
319
+ };
320
+ allowConfigure: {
321
+ type: string;
322
+ description: string;
323
+ };
324
+ allowNewMenu: {
325
+ type: string;
326
+ description: string;
327
+ };
328
+ snippets: {
329
+ type: string;
330
+ items: {
331
+ type: string;
332
+ };
333
+ description: string;
334
+ };
335
+ strategy: {
336
+ type: string;
337
+ description: string;
338
+ items: {
339
+ type: string;
340
+ properties: {
341
+ actions: {
342
+ type: string;
343
+ items: {
344
+ type: string;
345
+ };
346
+ description: string;
347
+ };
348
+ };
349
+ };
350
+ };
351
+ createdAt: {
352
+ type: string;
353
+ format: string;
354
+ description: string;
355
+ };
356
+ updatedAt: {
357
+ type: string;
358
+ format: string;
359
+ description: string;
360
+ };
361
+ };
362
+ };
363
+ };
364
+ };
365
+ };
366
+ export default _default;
@@ -0,0 +1,377 @@
1
+ 'use strict';
2
+
3
+ var swagger_default = {
4
+ openapi: "3.0.2",
5
+ info: {
6
+ title: "NocoBase API - ACL plugin"
7
+ },
8
+ paths: {
9
+ "/roles:list": {
10
+ get: {
11
+ tags: ["roles"],
12
+ description: "",
13
+ parameters: [],
14
+ responses: {
15
+ 200: {
16
+ description: "ok",
17
+ content: {
18
+ "application/json": {
19
+ schema: {
20
+ type: "array",
21
+ items: {
22
+ $ref: "#/components/schemas/role"
23
+ }
24
+ }
25
+ }
26
+ }
27
+ }
28
+ }
29
+ }
30
+ },
31
+ "/roles:get": {
32
+ get: {
33
+ tags: ["roles"],
34
+ description: "",
35
+ parameters: [
36
+ {
37
+ name: "filterByTk",
38
+ in: "query",
39
+ description: "role name",
40
+ required: true,
41
+ schema: {
42
+ type: "string"
43
+ }
44
+ }
45
+ ],
46
+ responses: {
47
+ 200: {
48
+ description: "ok",
49
+ content: {
50
+ "application/json": {
51
+ schema: {
52
+ $ref: "#/components/schemas/role"
53
+ }
54
+ }
55
+ }
56
+ }
57
+ }
58
+ }
59
+ },
60
+ "/roles:create": {
61
+ post: {
62
+ tags: ["roles"],
63
+ description: "",
64
+ requestBody: {
65
+ content: {
66
+ "application/json": {
67
+ schema: {
68
+ $ref: "#/components/schemas/role"
69
+ }
70
+ }
71
+ }
72
+ },
73
+ responses: {
74
+ "200": {
75
+ description: "OK",
76
+ content: {
77
+ "application/json": {
78
+ schema: {
79
+ $ref: "#/components/schemas/role"
80
+ }
81
+ }
82
+ }
83
+ }
84
+ }
85
+ }
86
+ },
87
+ "/roles:update": {
88
+ post: {
89
+ tags: ["roles"],
90
+ description: "",
91
+ parameters: [
92
+ {
93
+ name: "filterByTk",
94
+ in: "query",
95
+ description: "role name",
96
+ required: true,
97
+ schema: {
98
+ type: "string"
99
+ }
100
+ }
101
+ ],
102
+ requestBody: {
103
+ content: {
104
+ "application/json": {
105
+ schema: {
106
+ $ref: "#/components/schemas/role"
107
+ }
108
+ }
109
+ }
110
+ },
111
+ responses: {
112
+ 200: {
113
+ description: "ok",
114
+ content: {
115
+ "application/json": {
116
+ schema: {
117
+ $ref: "#/components/schemas/role"
118
+ }
119
+ }
120
+ }
121
+ }
122
+ }
123
+ }
124
+ },
125
+ "/roles:destroy": {
126
+ post: {
127
+ tags: ["roles"],
128
+ description: "",
129
+ parameters: [
130
+ {
131
+ name: "filterByTk",
132
+ in: "query",
133
+ description: "role name",
134
+ required: true,
135
+ schema: {
136
+ type: "string"
137
+ }
138
+ }
139
+ ],
140
+ responses: {
141
+ "200": {
142
+ description: "OK"
143
+ }
144
+ }
145
+ }
146
+ },
147
+ "/roles:check": {
148
+ get: {
149
+ tags: ["roles"],
150
+ description: "return current user role",
151
+ responses: {
152
+ 200: {
153
+ description: "ok",
154
+ content: {
155
+ "application/json": {
156
+ schema: {
157
+ $ref: "#/components/schemas/role"
158
+ }
159
+ }
160
+ }
161
+ }
162
+ }
163
+ }
164
+ },
165
+ "/roles:setDefaultRole": {
166
+ post: {
167
+ tags: ["roles"],
168
+ description: "set default role for new user",
169
+ requestBody: {
170
+ content: {
171
+ "application/json": {
172
+ schema: {
173
+ type: "object",
174
+ properties: {
175
+ roleName: {
176
+ type: "string"
177
+ }
178
+ }
179
+ }
180
+ }
181
+ }
182
+ },
183
+ responses: {
184
+ "200": {
185
+ description: "OK"
186
+ }
187
+ }
188
+ }
189
+ },
190
+ "/roles/{roleName}/collections:list": {
191
+ get: {
192
+ tags: ["roles.collections"],
193
+ description: "list permissions of collections for role by roleName",
194
+ parameters: [
195
+ {
196
+ name: "filterByTk",
197
+ in: "query",
198
+ description: "role name",
199
+ required: true,
200
+ schema: {
201
+ type: "string"
202
+ }
203
+ }
204
+ ],
205
+ responses: {
206
+ "200": {
207
+ description: "OK",
208
+ content: {
209
+ "application/json": {
210
+ schema: {
211
+ type: "array",
212
+ items: {
213
+ type: "object",
214
+ properties: {
215
+ type: {
216
+ type: "string",
217
+ description: "collection"
218
+ },
219
+ name: {
220
+ type: "string",
221
+ description: "collection name"
222
+ },
223
+ collectionName: {
224
+ type: "string",
225
+ description: "collection name"
226
+ },
227
+ title: {
228
+ type: "string",
229
+ description: "collection title"
230
+ },
231
+ roleName: {
232
+ type: "string",
233
+ description: "role name"
234
+ },
235
+ usingConfig: {
236
+ type: "string",
237
+ enum: ["resourceAction", "strategy"],
238
+ description: "resourceAction: \u5355\u72EC\u914D\u7F6E, strategy: \u5168\u5C40\u7B56\u7565"
239
+ },
240
+ exists: {
241
+ type: "boolean",
242
+ description: "\u662F\u5426\u5B58\u5728\u5355\u72EC\u914D\u7F6E\u7684\u6743\u9650"
243
+ }
244
+ }
245
+ }
246
+ }
247
+ }
248
+ }
249
+ }
250
+ }
251
+ }
252
+ },
253
+ "/availableActions:list": {
254
+ get: {
255
+ tags: ["availableActions"],
256
+ description: "available actions of resource in current system",
257
+ parameters: [],
258
+ responses: {
259
+ "200": {
260
+ description: "OK",
261
+ content: {
262
+ "application/json": {
263
+ schema: {
264
+ type: "array",
265
+ items: {
266
+ type: "object",
267
+ properties: {
268
+ name: {
269
+ type: "string",
270
+ description: "Action\u540D\u79F0"
271
+ },
272
+ displayName: {
273
+ type: "string",
274
+ description: "Action\u663E\u793A\u540D\u79F0"
275
+ },
276
+ allowConfigureFields: {
277
+ type: "boolean",
278
+ description: "\u662F\u5426\u5141\u8BB8\u914D\u7F6E\u5B57\u6BB5"
279
+ },
280
+ onNewRecord: {
281
+ type: "string",
282
+ description: "\u662F\u5426\u662F\u65B0\u8BB0\u5F55\u7684Action"
283
+ },
284
+ type: {
285
+ type: "string",
286
+ description: "new-data \u6216\u8005 old-data"
287
+ },
288
+ aliases: {
289
+ type: "array",
290
+ items: {
291
+ type: "string"
292
+ },
293
+ description: "\u522B\u540D"
294
+ }
295
+ }
296
+ }
297
+ }
298
+ }
299
+ }
300
+ }
301
+ }
302
+ }
303
+ }
304
+ },
305
+ components: {
306
+ schemas: {
307
+ role: {
308
+ type: "object",
309
+ properties: {
310
+ title: {
311
+ type: "string",
312
+ description: "\u89D2\u8272\u540D\u79F0"
313
+ },
314
+ name: {
315
+ type: "string",
316
+ description: "\u89D2\u8272\u6807\u8BC6"
317
+ },
318
+ description: {
319
+ type: "string",
320
+ description: "\u89D2\u8272\u63CF\u8FF0"
321
+ },
322
+ hidden: {
323
+ type: "boolean",
324
+ description: "\u662F\u5426\u9690\u85CF"
325
+ },
326
+ default: {
327
+ type: "boolean",
328
+ description: "\u662F\u5426\u9ED8\u8BA4"
329
+ },
330
+ allowConfigure: {
331
+ type: "boolean",
332
+ description: "\u662F\u5426\u5141\u8BB8\u914D\u7F6E"
333
+ },
334
+ allowNewMenu: {
335
+ type: "boolean",
336
+ description: "\u662F\u5426\u5141\u8BB8\u65B0\u5EFA\u83DC\u5355"
337
+ },
338
+ snippets: {
339
+ type: "array",
340
+ items: {
341
+ type: "string"
342
+ },
343
+ description: "\u63A5\u53E3\u6743\u9650"
344
+ },
345
+ strategy: {
346
+ type: "array",
347
+ description: "\u6570\u636E\u8868\u6743\u9650\u7B56\u7565",
348
+ items: {
349
+ type: "object",
350
+ properties: {
351
+ actions: {
352
+ type: "array",
353
+ items: {
354
+ type: "string"
355
+ },
356
+ description: "\u64CD\u4F5C"
357
+ }
358
+ }
359
+ }
360
+ },
361
+ createdAt: {
362
+ type: "string",
363
+ format: "date-time",
364
+ description: "\u521B\u5EFA\u65F6\u95F4"
365
+ },
366
+ updatedAt: {
367
+ type: "string",
368
+ format: "date-time",
369
+ description: "\u66F4\u65B0\u65F6\u95F4"
370
+ }
371
+ }
372
+ }
373
+ }
374
+ }
375
+ };
376
+
377
+ module.exports = swagger_default;
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "displayName.zh-CN": "权限控制",
5
5
  "description": "A simple access control based on roles, resources and actions",
6
6
  "description.zh-CN": "基于角色、资源和操作的权限控制。",
7
- "version": "0.12.0-alpha.5",
7
+ "version": "0.13.0-alpha.1",
8
8
  "license": "AGPL-3.0",
9
9
  "main": "./dist/server/index.js",
10
10
  "devDependencies": {
@@ -27,5 +27,5 @@
27
27
  "url": "git+https://github.com/nocobase/nocobase.git",
28
28
  "directory": "packages/plugins/acl"
29
29
  },
30
- "gitHead": "689cc16e83361c4d0b91907e0deac30bdb907692"
30
+ "gitHead": "0ebd4e85a1b0b0d0943768ab6cb5c3d824562239"
31
31
  }