@webiny/shared-aco 6.6.0-alpha.5 → 6.6.0-alpha.7
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/flp/Permissions.js +5 -4
- package/flp/Permissions.js.map +1 -1
- package/flp/flp.types.d.ts +5 -0
- package/package.json +2 -2
package/flp/Permissions.js
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
class Permissions {
|
|
2
2
|
static create(permissions, parentFlp) {
|
|
3
|
-
const
|
|
4
|
-
const
|
|
3
|
+
const inheritedFromParent = `parent:${parentFlp?.id}`;
|
|
4
|
+
const parentFolderPermissions = (parentFlp?.permissions || []).filter((p)=>!p.plugin);
|
|
5
|
+
const currentFolderPermissions = (permissions || []).filter((p)=>!p.plugin && p.inheritedFrom !== inheritedFromParent);
|
|
5
6
|
if (!parentFolderPermissions.length) return currentFolderPermissions;
|
|
6
7
|
const permissionsInheritedFromParentFolder = [];
|
|
7
8
|
for (const parentFolderPermission of parentFolderPermissions){
|
|
8
9
|
if ("no-access" === parentFolderPermission.level) {
|
|
9
10
|
permissionsInheritedFromParentFolder.push({
|
|
10
11
|
...parentFolderPermission,
|
|
11
|
-
inheritedFrom:
|
|
12
|
+
inheritedFrom: inheritedFromParent
|
|
12
13
|
});
|
|
13
14
|
continue;
|
|
14
15
|
}
|
|
15
16
|
const currentFolderHasOverridePermission = currentFolderPermissions.some((permission)=>permission.target === parentFolderPermission.target);
|
|
16
17
|
if (!currentFolderHasOverridePermission) permissionsInheritedFromParentFolder.push({
|
|
17
18
|
...parentFolderPermission,
|
|
18
|
-
inheritedFrom:
|
|
19
|
+
inheritedFrom: inheritedFromParent
|
|
19
20
|
});
|
|
20
21
|
}
|
|
21
22
|
const applicableCurrentFolderPermissions = currentFolderPermissions.filter((permission)=>{
|
package/flp/Permissions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flp/Permissions.js","sources":["../../src/flp/Permissions.ts"],"sourcesContent":["import type { FolderLevelPermission, FolderPermission } from \"~/flp/flp.types.js\";\n\nexport class Permissions {\n public static create(\n permissions?: FolderPermission[],\n parentFlp?: Pick<FolderLevelPermission, \"id\" | \"permissions\"> | null\n ): FolderPermission[] {\n const parentFolderPermissions = parentFlp?.permissions || [];\n const currentFolderPermissions
|
|
1
|
+
{"version":3,"file":"flp/Permissions.js","sources":["../../src/flp/Permissions.ts"],"sourcesContent":["import type { FolderLevelPermission, FolderPermission } from \"~/flp/flp.types.js\";\n\nexport class Permissions {\n public static create(\n permissions?: FolderPermission[],\n parentFlp?: Pick<FolderLevelPermission, \"id\" | \"permissions\"> | null\n ): FolderPermission[] {\n // Code-defined permissions (contributed via an `FlpFactory`) are merged into FLP records on\n // read only. Every write to the FLP catalog funnels through here, so this is where we make\n // sure they can never be persisted — otherwise a client echoing back what it read would turn\n // a code permission into a stored one that nobody can remove from the UI.\n const inheritedFromParent = `parent:${parentFlp?.id}`;\n\n const parentFolderPermissions = (parentFlp?.permissions || []).filter(p => !p.plugin);\n const currentFolderPermissions = (permissions || []).filter(\n p => !p.plugin && p.inheritedFrom !== inheritedFromParent\n );\n\n if (!parentFolderPermissions.length) {\n return currentFolderPermissions;\n }\n\n // Merge parent and current folder permissions:\n // - current folder permissions take precedence over parent permissions\n // - only if parent permission's level is set to `no-access`, then we ignore the current folder permission\n const permissionsInheritedFromParentFolder: FolderPermission[] = [];\n\n for (const parentFolderPermission of parentFolderPermissions) {\n if (parentFolderPermission.level === \"no-access\") {\n permissionsInheritedFromParentFolder.push({\n ...parentFolderPermission,\n inheritedFrom: inheritedFromParent\n });\n continue;\n }\n\n const currentFolderHasOverridePermission = currentFolderPermissions.some(\n permission => permission.target === parentFolderPermission.target\n );\n\n if (currentFolderHasOverridePermission) {\n continue;\n }\n\n permissionsInheritedFromParentFolder.push({\n ...parentFolderPermission,\n inheritedFrom: inheritedFromParent\n });\n }\n\n // Add current folder permissions that are not present in the parent folder permissions.\n const applicableCurrentFolderPermissions = currentFolderPermissions.filter(permission => {\n const alreadyInInheritedPermissions = permissionsInheritedFromParentFolder.some(\n p => p.target === permission.target\n );\n\n return !alreadyInInheritedPermissions;\n });\n\n return [...applicableCurrentFolderPermissions, ...permissionsInheritedFromParentFolder];\n }\n}\n"],"names":["Permissions","permissions","parentFlp","inheritedFromParent","parentFolderPermissions","p","currentFolderPermissions","permissionsInheritedFromParentFolder","parentFolderPermission","currentFolderHasOverridePermission","permission","applicableCurrentFolderPermissions","alreadyInInheritedPermissions"],"mappings":"AAEO,MAAMA;IACT,OAAc,OACVC,WAAgC,EAChCC,SAAoE,EAClD;QAKlB,MAAMC,sBAAsB,CAAC,OAAO,EAAED,WAAW,IAAI;QAErD,MAAME,0BAA2BF,AAAAA,CAAAA,WAAW,eAAe,EAAC,EAAG,MAAM,CAACG,CAAAA,IAAK,CAACA,EAAE,MAAM;QACpF,MAAMC,2BAA4BL,AAAAA,CAAAA,eAAe,EAAC,EAAG,MAAM,CACvDI,CAAAA,IAAK,CAACA,EAAE,MAAM,IAAIA,EAAE,aAAa,KAAKF;QAG1C,IAAI,CAACC,wBAAwB,MAAM,EAC/B,OAAOE;QAMX,MAAMC,uCAA2D,EAAE;QAEnE,KAAK,MAAMC,0BAA0BJ,wBAAyB;YAC1D,IAAII,AAAiC,gBAAjCA,uBAAuB,KAAK,EAAkB;gBAC9CD,qCAAqC,IAAI,CAAC;oBACtC,GAAGC,sBAAsB;oBACzB,eAAeL;gBACnB;gBACA;YACJ;YAEA,MAAMM,qCAAqCH,yBAAyB,IAAI,CACpEI,CAAAA,aAAcA,WAAW,MAAM,KAAKF,uBAAuB,MAAM;YAGrE,KAAIC,oCAIJF,qCAAqC,IAAI,CAAC;gBACtC,GAAGC,sBAAsB;gBACzB,eAAeL;YACnB;QACJ;QAGA,MAAMQ,qCAAqCL,yBAAyB,MAAM,CAACI,CAAAA;YACvE,MAAME,gCAAgCL,qCAAqC,IAAI,CAC3EF,CAAAA,IAAKA,EAAE,MAAM,KAAKK,WAAW,MAAM;YAGvC,OAAO,CAACE;QACZ;QAEA,OAAO;eAAID;eAAuCJ;SAAqC;IAC3F;AACJ"}
|
package/flp/flp.types.d.ts
CHANGED
|
@@ -3,6 +3,11 @@ export interface FolderPermission {
|
|
|
3
3
|
target: `admin:${string}` | `team:${string}`;
|
|
4
4
|
level: FolderAccessLevel;
|
|
5
5
|
inheritedFrom?: string;
|
|
6
|
+
/**
|
|
7
|
+
* Set on permissions contributed from code, via an `FlpFactory`. These are merged into the FLP
|
|
8
|
+
* record on read, never persisted, and cannot be modified via the API or the Admin UI.
|
|
9
|
+
*/
|
|
10
|
+
plugin?: boolean;
|
|
6
11
|
}
|
|
7
12
|
export interface FolderLevelPermission {
|
|
8
13
|
id: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/shared-aco",
|
|
3
|
-
"version": "6.6.0-alpha.
|
|
3
|
+
"version": "6.6.0-alpha.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"access": "public"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@webiny/build-tools": "6.6.0-alpha.
|
|
24
|
+
"@webiny/build-tools": "6.6.0-alpha.7",
|
|
25
25
|
"typescript": "7.0.2"
|
|
26
26
|
},
|
|
27
27
|
"webiny": {
|