@webiny/shared-aco 0.0.0-unstable.e53eceafb5

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Webiny
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,18 @@
1
+ # @webiny/api-headless-cms-aco
2
+
3
+ [![](https://img.shields.io/npm/dw/@webiny/api-headless-cms-aco.svg)](https://www.npmjs.com/package/@webiny/api-headless-cms-aco)
4
+ [![](https://img.shields.io/npm/v/@webiny/api-headless-cms-aco.svg)](https://www.npmjs.com/package/@webiny/api-headless-cms-aco)
5
+ [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
6
+ [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
7
+
8
+ ## Install
9
+
10
+ ```
11
+ npm install --save @webiny/api-headless-cms-aco
12
+ ```
13
+
14
+ Or if you prefer yarn:
15
+
16
+ ```
17
+ yarn add @webiny/api-headless-cms-aco
18
+ ```
package/constants.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare const ROOT_FOLDER = "root";
package/constants.js ADDED
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ROOT_FOLDER = void 0;
7
+ const ROOT_FOLDER = exports.ROOT_FOLDER = "root";
8
+
9
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ROOT_FOLDER","exports"],"sources":["constants.ts"],"sourcesContent":["export const ROOT_FOLDER = \"root\";\n"],"mappings":";;;;;;AAAO,MAAMA,WAAW,GAAAC,OAAA,CAAAD,WAAA,GAAG,MAAM","ignoreList":[]}
package/flp/Path.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export declare class Path {
2
+ static create(slug: string, parentPath?: string): string;
3
+ }
package/flp/Path.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Path = void 0;
7
+ var _constants = require("../constants");
8
+ class Path {
9
+ static create(slug, parentPath) {
10
+ if (parentPath) {
11
+ return `${parentPath}/${slug}`;
12
+ }
13
+ return `${_constants.ROOT_FOLDER}/${slug}`;
14
+ }
15
+ }
16
+ exports.Path = Path;
17
+
18
+ //# sourceMappingURL=Path.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_constants","require","Path","create","slug","parentPath","ROOT_FOLDER","exports"],"sources":["Path.ts"],"sourcesContent":["import { ROOT_FOLDER } from \"~/constants\";\n\nexport class Path {\n static create(slug: string, parentPath?: string) {\n if (parentPath) {\n return `${parentPath}/${slug}`;\n }\n\n return `${ROOT_FOLDER}/${slug}`;\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAEO,MAAMC,IAAI,CAAC;EACd,OAAOC,MAAMA,CAACC,IAAY,EAAEC,UAAmB,EAAE;IAC7C,IAAIA,UAAU,EAAE;MACZ,OAAO,GAAGA,UAAU,IAAID,IAAI,EAAE;IAClC;IAEA,OAAO,GAAGE,sBAAW,IAAIF,IAAI,EAAE;EACnC;AACJ;AAACG,OAAA,CAAAL,IAAA,GAAAA,IAAA","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ import type { FolderLevelPermission, FolderPermission } from "./flp.types";
2
+ export declare class Permissions {
3
+ static create(permissions?: FolderPermission[], parentFlp?: Pick<FolderLevelPermission, "id" | "permissions"> | null): FolderPermission[];
4
+ }
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Permissions = void 0;
7
+ class Permissions {
8
+ static create(permissions, parentFlp) {
9
+ const parentFolderPermissions = parentFlp?.permissions || [];
10
+ const currentFolderPermissions = permissions?.filter(p => p.inheritedFrom !== `parent:${parentFlp?.id}`) || [];
11
+ if (!parentFolderPermissions.length) {
12
+ return currentFolderPermissions;
13
+ }
14
+
15
+ // Merge parent and current folder permissions:
16
+ // - current folder permissions take precedence over parent permissions
17
+ // - only if parent permission's level is set to `no-access`, then we ignore the current folder permission
18
+ const permissionsInheritedFromParentFolder = [];
19
+ for (const parentFolderPermission of parentFolderPermissions) {
20
+ if (parentFolderPermission.level === "no-access") {
21
+ permissionsInheritedFromParentFolder.push({
22
+ ...parentFolderPermission,
23
+ inheritedFrom: `parent:${parentFlp.id}`
24
+ });
25
+ continue;
26
+ }
27
+ const currentFolderHasOverridePermission = currentFolderPermissions.some(permission => permission.target === parentFolderPermission.target);
28
+ if (currentFolderHasOverridePermission) {
29
+ continue;
30
+ }
31
+ permissionsInheritedFromParentFolder.push({
32
+ ...parentFolderPermission,
33
+ inheritedFrom: `parent:${parentFlp.id}`
34
+ });
35
+ }
36
+
37
+ // Add current folder permissions that are not present in the parent folder permissions.
38
+ const applicableCurrentFolderPermissions = currentFolderPermissions.filter(permission => {
39
+ const alreadyInInheritedPermissions = permissionsInheritedFromParentFolder.some(p => p.target === permission.target);
40
+ return !alreadyInInheritedPermissions;
41
+ });
42
+ return [...applicableCurrentFolderPermissions, ...permissionsInheritedFromParentFolder];
43
+ }
44
+ }
45
+ exports.Permissions = Permissions;
46
+
47
+ //# sourceMappingURL=Permissions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Permissions","create","permissions","parentFlp","parentFolderPermissions","currentFolderPermissions","filter","p","inheritedFrom","id","length","permissionsInheritedFromParentFolder","parentFolderPermission","level","push","currentFolderHasOverridePermission","some","permission","target","applicableCurrentFolderPermissions","alreadyInInheritedPermissions","exports"],"sources":["Permissions.ts"],"sourcesContent":["import type { FolderLevelPermission, FolderPermission } from \"~/flp/flp.types\";\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 =\n permissions?.filter(p => p.inheritedFrom !== `parent:${parentFlp?.id}`) || [];\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: `parent:${parentFlp!.id}`\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: `parent:${parentFlp!.id}`\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"],"mappings":";;;;;;AAEO,MAAMA,WAAW,CAAC;EACrB,OAAcC,MAAMA,CAChBC,WAAgC,EAChCC,SAAoE,EAClD;IAClB,MAAMC,uBAAuB,GAAGD,SAAS,EAAED,WAAW,IAAI,EAAE;IAC5D,MAAMG,wBAAwB,GAC1BH,WAAW,EAAEI,MAAM,CAACC,CAAC,IAAIA,CAAC,CAACC,aAAa,KAAK,UAAUL,SAAS,EAAEM,EAAE,EAAE,CAAC,IAAI,EAAE;IAEjF,IAAI,CAACL,uBAAuB,CAACM,MAAM,EAAE;MACjC,OAAOL,wBAAwB;IACnC;;IAEA;IACA;IACA;IACA,MAAMM,oCAAwD,GAAG,EAAE;IAEnE,KAAK,MAAMC,sBAAsB,IAAIR,uBAAuB,EAAE;MAC1D,IAAIQ,sBAAsB,CAACC,KAAK,KAAK,WAAW,EAAE;QAC9CF,oCAAoC,CAACG,IAAI,CAAC;UACtC,GAAGF,sBAAsB;UACzBJ,aAAa,EAAE,UAAUL,SAAS,CAAEM,EAAE;QAC1C,CAAC,CAAC;QACF;MACJ;MAEA,MAAMM,kCAAkC,GAAGV,wBAAwB,CAACW,IAAI,CACpEC,UAAU,IAAIA,UAAU,CAACC,MAAM,KAAKN,sBAAsB,CAACM,MAC/D,CAAC;MAED,IAAIH,kCAAkC,EAAE;QACpC;MACJ;MAEAJ,oCAAoC,CAACG,IAAI,CAAC;QACtC,GAAGF,sBAAsB;QACzBJ,aAAa,EAAE,UAAUL,SAAS,CAAEM,EAAE;MAC1C,CAAC,CAAC;IACN;;IAEA;IACA,MAAMU,kCAAkC,GAAGd,wBAAwB,CAACC,MAAM,CAACW,UAAU,IAAI;MACrF,MAAMG,6BAA6B,GAAGT,oCAAoC,CAACK,IAAI,CAC3ET,CAAC,IAAIA,CAAC,CAACW,MAAM,KAAKD,UAAU,CAACC,MACjC,CAAC;MAED,OAAO,CAACE,6BAA6B;IACzC,CAAC,CAAC;IAEF,OAAO,CAAC,GAAGD,kCAAkC,EAAE,GAAGR,oCAAoC,CAAC;EAC3F;AACJ;AAACU,OAAA,CAAArB,WAAA,GAAAA,WAAA","ignoreList":[]}
@@ -0,0 +1,14 @@
1
+ export type FolderAccessLevel = "owner" | "viewer" | "editor" | "public" | "no-access";
2
+ export interface FolderPermission {
3
+ target: `admin:${string}` | `team:${string}`;
4
+ level: FolderAccessLevel;
5
+ inheritedFrom?: string;
6
+ }
7
+ export interface FolderLevelPermission {
8
+ id: string;
9
+ parentId: string;
10
+ slug: string;
11
+ path: string;
12
+ permissions: FolderPermission[];
13
+ type: string;
14
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ //# sourceMappingURL=flp.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["flp.types.ts"],"sourcesContent":["export type FolderAccessLevel = \"owner\" | \"viewer\" | \"editor\" | \"public\" | \"no-access\";\n\nexport interface FolderPermission {\n target: `admin:${string}` | `team:${string}`;\n level: FolderAccessLevel;\n inheritedFrom?: string;\n}\n\nexport interface FolderLevelPermission {\n id: string;\n parentId: string;\n slug: string;\n path: string;\n permissions: FolderPermission[];\n type: string;\n}\n"],"mappings":"","ignoreList":[]}
package/flp/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./Path";
2
+ export * from "./Permissions";
package/flp/index.js ADDED
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _Path = require("./Path");
7
+ Object.keys(_Path).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _Path[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _Path[key];
14
+ }
15
+ });
16
+ });
17
+ var _Permissions = require("./Permissions");
18
+ Object.keys(_Permissions).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _Permissions[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _Permissions[key];
25
+ }
26
+ });
27
+ });
28
+
29
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_Path","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_Permissions"],"sources":["index.ts"],"sourcesContent":["export * from \"./Path\";\nexport * from \"./Permissions\";\n"],"mappings":";;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,KAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,KAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,KAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,YAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,YAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,YAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,YAAA,CAAAL,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
package/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./flp";
2
+ export * from "./constants";
package/index.js ADDED
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _flp = require("./flp");
7
+ Object.keys(_flp).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _flp[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _flp[key];
14
+ }
15
+ });
16
+ });
17
+ var _constants = require("./constants");
18
+ Object.keys(_constants).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _constants[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _constants[key];
25
+ }
26
+ });
27
+ });
28
+
29
+ //# sourceMappingURL=index.js.map
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_flp","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_constants"],"sources":["index.ts"],"sourcesContent":["export * from \"./flp\";\nexport * from \"./constants\";\n"],"mappings":";;;;;AAAA,IAAAA,IAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,IAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,IAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,IAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,UAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,UAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,UAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,UAAA,CAAAL,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@webiny/shared-aco",
3
+ "version": "0.0.0-unstable.e53eceafb5",
4
+ "main": "index.js",
5
+ "keywords": [
6
+ "shared-aco:base"
7
+ ],
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/webiny/webiny-js.git",
11
+ "directory": "packages/shared-aco"
12
+ },
13
+ "description": "Shared utilities for the ACO api and admin packages.",
14
+ "author": "Webiny Ltd.",
15
+ "license": "MIT",
16
+ "scripts": {
17
+ "build": "node ../cli/bin.js run build",
18
+ "watch": "node ../cli/bin.js run watch"
19
+ },
20
+ "publishConfig": {
21
+ "access": "public",
22
+ "directory": "dist"
23
+ },
24
+ "devDependencies": {
25
+ "@webiny/project-utils": "0.0.0-unstable.e53eceafb5",
26
+ "typescript": "5.3.3"
27
+ },
28
+ "gitHead": "e53eceafb5ce1a3872c9b4548939bb2eae5b1aef"
29
+ }
package/types.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./flp/flp.types";
package/types.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _flp = require("./flp/flp.types");
7
+ Object.keys(_flp).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _flp[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _flp[key];
14
+ }
15
+ });
16
+ });
17
+
18
+ //# sourceMappingURL=types.js.map
package/types.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_flp","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sources":["types.ts"],"sourcesContent":["export * from \"./flp/flp.types\";\n"],"mappings":";;;;;AAAA,IAAAA,IAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,IAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,IAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,IAAA,CAAAK,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}