@nocobase/acl 2.1.0-alpha.1 → 2.1.0-alpha.10
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/LICENSE +201 -661
- package/README.md +79 -10
- package/lib/acl.d.ts +25 -10
- package/lib/acl.js +102 -72
- package/lib/fixed-params-manager.d.ts +3 -0
- package/lib/fixed-params-manager.js +7 -0
- package/package.json +8 -5
package/README.md
CHANGED
|
@@ -1,17 +1,24 @@
|
|
|
1
1
|
# NocoBase
|
|
2
2
|
|
|
3
3
|
<video width="100%" controls>
|
|
4
|
-
|
|
4
|
+
<source src="https://github.com/user-attachments/assets/4d11a87b-00e2-48f3-9bf7-389d21072d13" type="video/mp4">
|
|
5
5
|
</video>
|
|
6
6
|
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="https://trendshift.io/repositories/4112" target="_blank"><img src="https://trendshift.io/api/badge/repositories/4112" alt="nocobase%2Fnocobase | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
|
|
9
|
+
<a href="https://www.producthunt.com/posts/nocobase?embed=true&utm_source=badge-top-post-topic-badge&utm_medium=badge&utm_souce=badge-nocobase" target="_blank"><img src="https://api.producthunt.com/widgets/embed-image/v1/top-post-topic-badge.svg?post_id=456520&theme=light&period=weekly&topic_id=267" alt="NocoBase - Scalability-first, open-source no-code platform | Product Hunt" style="width: 250px; height: 54px;" width="250" height="54" /></a>
|
|
10
|
+
</p>
|
|
7
11
|
|
|
8
12
|
## What is NocoBase
|
|
9
13
|
|
|
10
|
-
NocoBase is
|
|
11
|
-
|
|
14
|
+
NocoBase is the most extensible AI-powered no-code platform.
|
|
15
|
+
Total control. Infinite extensibility. AI collaboration.
|
|
16
|
+
Enable your team to adapt quickly and cut costs dramatically.
|
|
17
|
+
No years of development. No millions wasted.
|
|
18
|
+
Deploy NocoBase in minutes — and take control of everything.
|
|
12
19
|
|
|
13
20
|
Homepage:
|
|
14
|
-
https://www.nocobase.com/
|
|
21
|
+
https://www.nocobase.com/
|
|
15
22
|
|
|
16
23
|
Online Demo:
|
|
17
24
|
https://demo.nocobase.com/new
|
|
@@ -19,12 +26,74 @@ https://demo.nocobase.com/new
|
|
|
19
26
|
Documents:
|
|
20
27
|
https://docs.nocobase.com/
|
|
21
28
|
|
|
22
|
-
|
|
23
|
-
https://
|
|
29
|
+
Forum:
|
|
30
|
+
https://forum.nocobase.com/
|
|
24
31
|
|
|
25
|
-
|
|
26
|
-
https://www.nocobase.com/en/
|
|
32
|
+
Use Cases:
|
|
33
|
+
https://www.nocobase.com/en/blog/tags/customer-stories
|
|
27
34
|
|
|
35
|
+
## Release Notes
|
|
28
36
|
|
|
29
|
-
|
|
30
|
-
|
|
37
|
+
Our [blog](https://www.nocobase.com/en/blog/timeline) is regularly updated with release notes and provides a weekly summary.
|
|
38
|
+
|
|
39
|
+
## Distinctive features
|
|
40
|
+
|
|
41
|
+
### 1. Data model-driven, not form/table–driven
|
|
42
|
+
|
|
43
|
+
Instead of being constrained by forms or tables, NocoBase adopts a data model–driven approach, separating data structure from user interface to unlock unlimited possibilities.
|
|
44
|
+
|
|
45
|
+
- UI and data structure are fully decoupled
|
|
46
|
+
- Multiple blocks and actions can be created for the same table or record in any quantity or form
|
|
47
|
+
- Supports the main database, external databases, and third-party APIs as data sources
|
|
48
|
+
|
|
49
|
+

|
|
50
|
+
|
|
51
|
+
### 2. AI employees, integrated into your business systems
|
|
52
|
+
Unlike standalone AI demos, NocoBase allows you to embed AI capabilities seamlessly into your interfaces, workflows, and data context, making AI truly useful in real business scenarios.
|
|
53
|
+
|
|
54
|
+
- Define AI employees for roles such as translator, analyst, researcher, or assistant
|
|
55
|
+
- Seamless AI–human collaboration in interfaces and workflows
|
|
56
|
+
- Ensure AI usage is secure, transparent, and customizable for your business needs
|
|
57
|
+
|
|
58
|
+

|
|
59
|
+
|
|
60
|
+
### 3. What you see is what you get, incredibly easy to use
|
|
61
|
+
|
|
62
|
+
While enabling the development of complex business systems, NocoBase keeps the experience simple and intuitive.
|
|
63
|
+
|
|
64
|
+
- One-click switch between usage mode and configuration mode
|
|
65
|
+
- Pages serve as a canvas to arrange blocks and actions, similar to Notion
|
|
66
|
+
- Configuration mode is designed for ordinary users, not just programmers
|
|
67
|
+
|
|
68
|
+

|
|
69
|
+
|
|
70
|
+
### 4. Everything is a plugin, designed for extension
|
|
71
|
+
Adding more no-code features will never cover every business case. NocoBase is built for extension through its plugin-based microkernel architecture.
|
|
72
|
+
|
|
73
|
+
- All functionalities are plugins, similar to WordPress
|
|
74
|
+
- Plugins are ready to use upon installation
|
|
75
|
+
- Pages, blocks, actions, APIs, and data sources can all be extended through custom plugins
|
|
76
|
+
|
|
77
|
+

|
|
78
|
+
|
|
79
|
+
## Installation
|
|
80
|
+
|
|
81
|
+
NocoBase supports three installation methods:
|
|
82
|
+
|
|
83
|
+
- <a target="_blank" href="https://docs.nocobase.com/welcome/getting-started/installation/docker-compose">Installing With Docker (👍Recommended)</a>
|
|
84
|
+
|
|
85
|
+
Suitable for no-code scenarios, no code to write. When upgrading, just download the latest image and reboot.
|
|
86
|
+
|
|
87
|
+
- <a target="_blank" href="https://docs.nocobase.com/welcome/getting-started/installation/create-nocobase-app">Installing from create-nocobase-app CLI</a>
|
|
88
|
+
|
|
89
|
+
The business code of the project is completely independent and supports low-code development.
|
|
90
|
+
|
|
91
|
+
- <a target="_blank" href="https://docs.nocobase.com/welcome/getting-started/installation/git-clone">Installing from Git source code</a>
|
|
92
|
+
|
|
93
|
+
If you want to experience the latest unreleased version, or want to participate in the contribution, you need to make changes and debug on the source code, it is recommended to choose this installation method, which requires a high level of development skills, and if the code has been updated, you can git pull the latest code.
|
|
94
|
+
|
|
95
|
+
## How NocoBase works
|
|
96
|
+
|
|
97
|
+
<video width="100%" controls>
|
|
98
|
+
<source src="https://github.com/user-attachments/assets/8d183b44-9bb5-4792-b08f-bc08fe8dfaaf" type="video/mp4">
|
|
99
|
+
</video>
|
package/lib/acl.d.ts
CHANGED
|
@@ -13,9 +13,10 @@ import { ACLAvailableAction, AvailableActionOptions } from './acl-available-acti
|
|
|
13
13
|
import { ACLAvailableStrategy, AvailableStrategyOptions } from './acl-available-strategy';
|
|
14
14
|
import { ACLRole, ResourceActionsOptions, RoleActionParams } from './acl-role';
|
|
15
15
|
import { AllowManager, ConditionFunc } from './allow-manager';
|
|
16
|
-
import FixedParamsManager, { Merger } from './fixed-params-manager';
|
|
16
|
+
import FixedParamsManager, { Merger, GeneralMerger } from './fixed-params-manager';
|
|
17
17
|
import SnippetManager, { SnippetOptions } from './snippet-manager';
|
|
18
|
-
|
|
18
|
+
import Database from '@nocobase/database';
|
|
19
|
+
export interface CanResult {
|
|
19
20
|
role: string;
|
|
20
21
|
resource: string;
|
|
21
22
|
action: string;
|
|
@@ -44,6 +45,14 @@ export interface ListenerContext {
|
|
|
44
45
|
params: RoleActionParams;
|
|
45
46
|
}
|
|
46
47
|
type Listener = (ctx: ListenerContext) => void;
|
|
48
|
+
export type UserProvider = (args: {
|
|
49
|
+
fields: string[];
|
|
50
|
+
}) => Promise<any>;
|
|
51
|
+
export interface ParseJsonTemplateOptions {
|
|
52
|
+
timezone?: string;
|
|
53
|
+
state?: any;
|
|
54
|
+
userProvider?: UserProvider;
|
|
55
|
+
}
|
|
47
56
|
interface CanArgs {
|
|
48
57
|
role?: string;
|
|
49
58
|
resource: string;
|
|
@@ -104,22 +113,28 @@ export declare class ACL extends EventEmitter {
|
|
|
104
113
|
* @deprecated
|
|
105
114
|
*/
|
|
106
115
|
skip(resourceName: string, actionNames: string[] | string, condition?: string | ConditionFunc): void;
|
|
107
|
-
/**
|
|
108
|
-
* @internal
|
|
109
|
-
*/
|
|
110
|
-
parseJsonTemplate(json: any, ctx: any): Promise<any>;
|
|
111
116
|
middleware(): (ctx: any, next: any) => Promise<void>;
|
|
112
117
|
/**
|
|
113
118
|
* @internal
|
|
114
119
|
*/
|
|
115
120
|
getActionParams(ctx: any): Promise<void>;
|
|
121
|
+
addGeneralFixedParams(merger: GeneralMerger): void;
|
|
116
122
|
addFixedParams(resource: string, action: string, merger: Merger): void;
|
|
117
123
|
registerSnippet(snippet: SnippetOptions): void;
|
|
118
|
-
/**
|
|
119
|
-
* @internal
|
|
120
|
-
*/
|
|
121
|
-
filterParams(ctx: any, resourceName: any, params: any): any;
|
|
122
124
|
protected addCoreMiddleware(): void;
|
|
123
125
|
protected isAvailableAction(actionName: string): boolean;
|
|
124
126
|
}
|
|
127
|
+
export declare function createUserProvider(options: {
|
|
128
|
+
db?: Database;
|
|
129
|
+
dataSourceManager?: any;
|
|
130
|
+
currentUser?: any;
|
|
131
|
+
}): UserProvider;
|
|
132
|
+
/**
|
|
133
|
+
* @internal
|
|
134
|
+
*/
|
|
135
|
+
export declare function parseJsonTemplate(filter: any, options: ParseJsonTemplateOptions): Promise<any>;
|
|
136
|
+
/**
|
|
137
|
+
* @internal
|
|
138
|
+
*/
|
|
139
|
+
export declare function checkFilterParams(collection: any, filter: any): void;
|
|
125
140
|
export {};
|
package/lib/acl.js
CHANGED
|
@@ -37,7 +37,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
37
37
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
38
|
var acl_exports = {};
|
|
39
39
|
__export(acl_exports, {
|
|
40
|
-
ACL: () => ACL
|
|
40
|
+
ACL: () => ACL,
|
|
41
|
+
checkFilterParams: () => checkFilterParams,
|
|
42
|
+
createUserProvider: () => createUserProvider,
|
|
43
|
+
parseJsonTemplate: () => parseJsonTemplate
|
|
41
44
|
});
|
|
42
45
|
module.exports = __toCommonJS(acl_exports);
|
|
43
46
|
var import_utils = require("@nocobase/utils");
|
|
@@ -279,31 +282,6 @@ const _ACL = class _ACL extends import_events.default {
|
|
|
279
282
|
this.allowManager.allow(resourceName, actionName, condition);
|
|
280
283
|
}
|
|
281
284
|
}
|
|
282
|
-
/**
|
|
283
|
-
* @internal
|
|
284
|
-
*/
|
|
285
|
-
async parseJsonTemplate(json, ctx) {
|
|
286
|
-
var _a, _b, _c, _d, _e;
|
|
287
|
-
if (json.filter) {
|
|
288
|
-
(_b = (_a = ctx.logger) == null ? void 0 : _a.info) == null ? void 0 : _b.call(_a, "parseJsonTemplate.raw", JSON.parse(JSON.stringify(json.filter)));
|
|
289
|
-
const timezone = (_c = ctx == null ? void 0 : ctx.get) == null ? void 0 : _c.call(ctx, "x-timezone");
|
|
290
|
-
const state = JSON.parse(JSON.stringify(ctx.state));
|
|
291
|
-
const filter = await (0, import_utils.parseFilter)(json.filter, {
|
|
292
|
-
timezone,
|
|
293
|
-
now: (/* @__PURE__ */ new Date()).toISOString(),
|
|
294
|
-
vars: {
|
|
295
|
-
ctx: {
|
|
296
|
-
state
|
|
297
|
-
},
|
|
298
|
-
$user: getUser(ctx),
|
|
299
|
-
$nRole: /* @__PURE__ */ __name(() => state.currentRole, "$nRole")
|
|
300
|
-
}
|
|
301
|
-
});
|
|
302
|
-
json.filter = filter;
|
|
303
|
-
(_e = (_d = ctx.logger) == null ? void 0 : _d.info) == null ? void 0 : _e.call(_d, "parseJsonTemplate.parsed", filter);
|
|
304
|
-
}
|
|
305
|
-
return json;
|
|
306
|
-
}
|
|
307
285
|
middleware() {
|
|
308
286
|
const acl = this;
|
|
309
287
|
return /* @__PURE__ */ __name(async function ACLMiddleware(ctx, next) {
|
|
@@ -368,46 +346,20 @@ const _ACL = class _ACL extends import_events.default {
|
|
|
368
346
|
await (0, import_koa_compose.default)(this.middlewares.nodes)(ctx, async () => {
|
|
369
347
|
});
|
|
370
348
|
}
|
|
349
|
+
addGeneralFixedParams(merger) {
|
|
350
|
+
this.fixedParamsManager.addGeneralParams(merger);
|
|
351
|
+
}
|
|
371
352
|
addFixedParams(resource, action, merger) {
|
|
372
353
|
this.fixedParamsManager.addParams(resource, action, merger);
|
|
373
354
|
}
|
|
374
355
|
registerSnippet(snippet) {
|
|
375
356
|
this.snippetManager.register(snippet);
|
|
376
357
|
}
|
|
377
|
-
/**
|
|
378
|
-
* @internal
|
|
379
|
-
*/
|
|
380
|
-
filterParams(ctx, resourceName, params) {
|
|
381
|
-
var _a, _b, _c;
|
|
382
|
-
if ((_a = params == null ? void 0 : params.filter) == null ? void 0 : _a.createdById) {
|
|
383
|
-
const collection = ctx.db.getCollection(resourceName);
|
|
384
|
-
if (!collection || !collection.getField("createdById")) {
|
|
385
|
-
throw new import_no_permission_error.NoPermissionError("createdById field not found");
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
if ((_c = (_b = params == null ? void 0 : params.filter) == null ? void 0 : _b.$or) == null ? void 0 : _c.length) {
|
|
389
|
-
const checkCreatedById = /* @__PURE__ */ __name((items) => {
|
|
390
|
-
return items.some(
|
|
391
|
-
(x) => {
|
|
392
|
-
var _a2, _b2;
|
|
393
|
-
return "createdById" in x || ((_a2 = x.$or) == null ? void 0 : _a2.some((y) => "createdById" in y)) || ((_b2 = x.$and) == null ? void 0 : _b2.some((y) => "createdById" in y));
|
|
394
|
-
}
|
|
395
|
-
);
|
|
396
|
-
}, "checkCreatedById");
|
|
397
|
-
if (checkCreatedById(params.filter.$or)) {
|
|
398
|
-
const collection = ctx.db.getCollection(resourceName);
|
|
399
|
-
if (!collection || !collection.getField("createdById")) {
|
|
400
|
-
throw new import_no_permission_error.NoPermissionError("createdById field not found");
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
return params;
|
|
405
|
-
}
|
|
406
358
|
addCoreMiddleware() {
|
|
407
359
|
const acl = this;
|
|
408
360
|
this.middlewares.add(
|
|
409
361
|
async (ctx, next) => {
|
|
410
|
-
var _a, _b, _c, _d;
|
|
362
|
+
var _a, _b, _c, _d, _e, _f;
|
|
411
363
|
const resourcerAction = ctx.action;
|
|
412
364
|
const { resourceName, actionName } = ctx.permission;
|
|
413
365
|
const permission = ctx.permission;
|
|
@@ -420,10 +372,20 @@ const _ACL = class _ACL extends import_events.default {
|
|
|
420
372
|
((_c = ctx.log) == null ? void 0 : _c.debug) && ctx.log.debug("acl params", params);
|
|
421
373
|
try {
|
|
422
374
|
if (params && resourcerAction.mergeParams) {
|
|
423
|
-
const
|
|
424
|
-
const
|
|
375
|
+
const db = ctx.database ?? ctx.db;
|
|
376
|
+
const collection = (_d = db == null ? void 0 : db.getCollection) == null ? void 0 : _d.call(db, resourceName);
|
|
377
|
+
checkFilterParams(collection, params == null ? void 0 : params.filter);
|
|
378
|
+
const parsedFilter = await parseJsonTemplate(params.filter, {
|
|
379
|
+
state: ctx.state,
|
|
380
|
+
timezone: getTimezone(ctx),
|
|
381
|
+
userProvider: createUserProvider({
|
|
382
|
+
db: ctx.db,
|
|
383
|
+
currentUser: (_e = ctx.state) == null ? void 0 : _e.currentUser
|
|
384
|
+
})
|
|
385
|
+
});
|
|
386
|
+
const parsedParams = params.filter ? { ...params, filter: parsedFilter ?? params.filter } : params;
|
|
425
387
|
ctx.permission.parsedParams = parsedParams;
|
|
426
|
-
((
|
|
388
|
+
((_f = ctx.log) == null ? void 0 : _f.debug) && ctx.log.debug("acl parsedParams", parsedParams);
|
|
427
389
|
ctx.permission.rawParams = import_lodash.default.cloneDeep(resourcerAction.params);
|
|
428
390
|
if (parsedParams.appends && resourcerAction.params.fields) {
|
|
429
391
|
for (const queryField of resourcerAction.params.fields) {
|
|
@@ -474,31 +436,99 @@ const _ACL = class _ACL extends import_events.default {
|
|
|
474
436
|
};
|
|
475
437
|
__name(_ACL, "ACL");
|
|
476
438
|
let ACL = _ACL;
|
|
477
|
-
function
|
|
478
|
-
|
|
479
|
-
|
|
439
|
+
function getTimezone(ctx) {
|
|
440
|
+
var _a, _b, _c, _d, _e, _f;
|
|
441
|
+
return ((_b = (_a = ctx == null ? void 0 : ctx.request) == null ? void 0 : _a.get) == null ? void 0 : _b.call(_a, "x-timezone")) ?? ((_d = (_c = ctx == null ? void 0 : ctx.request) == null ? void 0 : _c.header) == null ? void 0 : _d["x-timezone"]) ?? ((_f = (_e = ctx == null ? void 0 : ctx.req) == null ? void 0 : _e.headers) == null ? void 0 : _f["x-timezone"]);
|
|
442
|
+
}
|
|
443
|
+
__name(getTimezone, "getTimezone");
|
|
444
|
+
function createUserProvider(options) {
|
|
445
|
+
var _a, _b, _c, _d, _e;
|
|
446
|
+
const db = options.db ?? ((_e = (_d = (_c = (_b = (_a = options.dataSourceManager) == null ? void 0 : _a.dataSources) == null ? void 0 : _b.get) == null ? void 0 : _c.call(_b, "main")) == null ? void 0 : _d.collectionManager) == null ? void 0 : _e.db);
|
|
447
|
+
const currentUser = options.currentUser;
|
|
480
448
|
return async ({ fields }) => {
|
|
481
|
-
|
|
482
|
-
const userFields = fields.filter((f) => f && db.getFieldByPath("users." + f));
|
|
483
|
-
(_a = ctx.logger) == null ? void 0 : _a.info("filter-parse: ", { userFields });
|
|
484
|
-
if (!ctx.state.currentUser) {
|
|
449
|
+
if (!db) {
|
|
485
450
|
return;
|
|
486
451
|
}
|
|
452
|
+
if (!currentUser) {
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
455
|
+
const userFields = fields.filter((f) => f && db.getFieldByPath("users." + f));
|
|
487
456
|
if (!userFields.length) {
|
|
488
457
|
return;
|
|
489
458
|
}
|
|
490
459
|
const user = await db.getRepository("users").findOne({
|
|
491
|
-
filterByTk:
|
|
460
|
+
filterByTk: currentUser.id,
|
|
492
461
|
fields: userFields
|
|
493
462
|
});
|
|
494
|
-
(_b = ctx.logger) == null ? void 0 : _b.info("filter-parse: ", {
|
|
495
|
-
$user: user == null ? void 0 : user.toJSON()
|
|
496
|
-
});
|
|
497
463
|
return user;
|
|
498
464
|
};
|
|
499
465
|
}
|
|
500
|
-
__name(
|
|
466
|
+
__name(createUserProvider, "createUserProvider");
|
|
467
|
+
function containsCreatedByIdFilter(input, seen = /* @__PURE__ */ new Set()) {
|
|
468
|
+
if (!input) {
|
|
469
|
+
return false;
|
|
470
|
+
}
|
|
471
|
+
if (Array.isArray(input)) {
|
|
472
|
+
return input.some((item) => containsCreatedByIdFilter(item, seen));
|
|
473
|
+
}
|
|
474
|
+
if (!import_lodash.default.isPlainObject(input)) {
|
|
475
|
+
return false;
|
|
476
|
+
}
|
|
477
|
+
if (seen.has(input)) {
|
|
478
|
+
return false;
|
|
479
|
+
}
|
|
480
|
+
seen.add(input);
|
|
481
|
+
for (const [key, value] of Object.entries(input)) {
|
|
482
|
+
if (isCreatedByIdKey(key)) {
|
|
483
|
+
return true;
|
|
484
|
+
}
|
|
485
|
+
if (containsCreatedByIdFilter(value, seen)) {
|
|
486
|
+
return true;
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
return false;
|
|
490
|
+
}
|
|
491
|
+
__name(containsCreatedByIdFilter, "containsCreatedByIdFilter");
|
|
492
|
+
function isCreatedByIdKey(key) {
|
|
493
|
+
return key === "createdById" || key.startsWith("createdById.") || key.startsWith("createdById$");
|
|
494
|
+
}
|
|
495
|
+
__name(isCreatedByIdKey, "isCreatedByIdKey");
|
|
496
|
+
async function parseJsonTemplate(filter, options) {
|
|
497
|
+
if (!filter) {
|
|
498
|
+
return filter;
|
|
499
|
+
}
|
|
500
|
+
const timezone = options == null ? void 0 : options.timezone;
|
|
501
|
+
const state = JSON.parse(JSON.stringify((options == null ? void 0 : options.state) || {}));
|
|
502
|
+
const parsedFilter = await (0, import_utils.parseFilter)(filter, {
|
|
503
|
+
timezone,
|
|
504
|
+
now: (/* @__PURE__ */ new Date()).toISOString(),
|
|
505
|
+
vars: {
|
|
506
|
+
ctx: {
|
|
507
|
+
state
|
|
508
|
+
},
|
|
509
|
+
$user: (options == null ? void 0 : options.userProvider) || (async () => void 0),
|
|
510
|
+
$nRole: /* @__PURE__ */ __name(() => state.currentRole, "$nRole")
|
|
511
|
+
}
|
|
512
|
+
});
|
|
513
|
+
return parsedFilter;
|
|
514
|
+
}
|
|
515
|
+
__name(parseJsonTemplate, "parseJsonTemplate");
|
|
516
|
+
function checkFilterParams(collection, filter) {
|
|
517
|
+
if (!filter) {
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
520
|
+
if (!containsCreatedByIdFilter(filter)) {
|
|
521
|
+
return;
|
|
522
|
+
}
|
|
523
|
+
if (!collection || !collection.getField("createdById")) {
|
|
524
|
+
throw new import_no_permission_error.NoPermissionError("createdById field not found");
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
__name(checkFilterParams, "checkFilterParams");
|
|
501
528
|
// Annotate the CommonJS export names for ESM import in node:
|
|
502
529
|
0 && (module.exports = {
|
|
503
|
-
ACL
|
|
530
|
+
ACL,
|
|
531
|
+
checkFilterParams,
|
|
532
|
+
createUserProvider,
|
|
533
|
+
parseJsonTemplate
|
|
504
534
|
});
|
|
@@ -7,10 +7,13 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
export type Merger = () => object;
|
|
10
|
+
export type GeneralMerger = (resource: string, action: string) => object;
|
|
10
11
|
export type ActionPath = string;
|
|
11
12
|
export default class FixedParamsManager {
|
|
12
13
|
merger: Map<string, Merger[]>;
|
|
14
|
+
generalMergers: Array<GeneralMerger>;
|
|
13
15
|
addParams(resource: string, action: string, merger: Merger): void;
|
|
16
|
+
addGeneralParams(merger: GeneralMerger): void;
|
|
14
17
|
getParamsMerger(resource: string, action: string): Merger[];
|
|
15
18
|
protected getActionPath(resource: string, action: string): string;
|
|
16
19
|
getParams(resource: string, action: string, extraParams?: any): {};
|
|
@@ -34,10 +34,14 @@ var import_utils = require("@nocobase/utils");
|
|
|
34
34
|
const SPLIT = ":";
|
|
35
35
|
const _FixedParamsManager = class _FixedParamsManager {
|
|
36
36
|
merger = /* @__PURE__ */ new Map();
|
|
37
|
+
generalMergers = [];
|
|
37
38
|
addParams(resource, action, merger) {
|
|
38
39
|
const path = this.getActionPath(resource, action);
|
|
39
40
|
this.merger.set(path, [...this.getParamsMerger(resource, action), merger]);
|
|
40
41
|
}
|
|
42
|
+
addGeneralParams(merger) {
|
|
43
|
+
this.generalMergers.push(merger);
|
|
44
|
+
}
|
|
41
45
|
getParamsMerger(resource, action) {
|
|
42
46
|
const path = this.getActionPath(resource, action);
|
|
43
47
|
return this.merger.get(path) || [];
|
|
@@ -47,6 +51,9 @@ const _FixedParamsManager = class _FixedParamsManager {
|
|
|
47
51
|
}
|
|
48
52
|
getParams(resource, action, extraParams = {}) {
|
|
49
53
|
const results = {};
|
|
54
|
+
for (const merger of this.generalMergers) {
|
|
55
|
+
_FixedParamsManager.mergeParams(results, merger(resource, action));
|
|
56
|
+
}
|
|
50
57
|
for (const merger of this.getParamsMerger(resource, action)) {
|
|
51
58
|
_FixedParamsManager.mergeParams(results, merger());
|
|
52
59
|
}
|
package/package.json
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/acl",
|
|
3
|
-
"version": "2.1.0-alpha.
|
|
3
|
+
"version": "2.1.0-alpha.10",
|
|
4
4
|
"description": "",
|
|
5
|
-
"license": "
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
6
|
"main": "./lib/index.js",
|
|
7
7
|
"types": "./lib/index.d.ts",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@nocobase/resourcer": "2.1.0-alpha.1",
|
|
10
|
-
"@nocobase/utils": "2.1.0-alpha.1",
|
|
11
9
|
"minimatch": "^5.1.1"
|
|
12
10
|
},
|
|
11
|
+
"peerDependencies": {
|
|
12
|
+
"@nocobase/database": "2.x",
|
|
13
|
+
"@nocobase/resourcer": "2.x",
|
|
14
|
+
"@nocobase/utils": "2.x"
|
|
15
|
+
},
|
|
13
16
|
"repository": {
|
|
14
17
|
"type": "git",
|
|
15
18
|
"url": "git+https://github.com/nocobase/nocobase.git",
|
|
16
19
|
"directory": "packages/acl"
|
|
17
20
|
},
|
|
18
|
-
"gitHead": "
|
|
21
|
+
"gitHead": "ce790d46c0a5768ca9618c7d0d77ab8300de75c8"
|
|
19
22
|
}
|