@webiny/api-aco-sql 0.0.0-unstable.0d717d18dd

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.
@@ -0,0 +1,20 @@
1
+ import type { Knex } from "knex";
2
+ import type { AcoFolderLevelPermissionsStorageOperations, FolderLevelPermission, StorageOperationsBatchUpdateFlpParams, StorageOperationsCreateFlpParams, StorageOperationsDeleteFlpParams, StorageOperationsGetFlpParams, StorageOperationsListFlpsParams, StorageOperationsUpdateFlpParams } from "@webiny/api-aco/types.js";
3
+ export interface StorageOperationsConfig {
4
+ knex: Knex;
5
+ tableNamePrefix?: string;
6
+ }
7
+ export declare class FolderLevelPermissionsStorageOperations implements AcoFolderLevelPermissionsStorageOperations {
8
+ private readonly knex;
9
+ private readonly tableName;
10
+ constructor({ knex, tableNamePrefix }: StorageOperationsConfig);
11
+ list({ where: { tenant, type, path_startsWith, parentId } }: StorageOperationsListFlpsParams): Promise<FolderLevelPermission[]>;
12
+ get({ tenant, id }: StorageOperationsGetFlpParams): Promise<FolderLevelPermission | null>;
13
+ create({ data }: StorageOperationsCreateFlpParams): Promise<FolderLevelPermission>;
14
+ update({ data: inputData, original }: StorageOperationsUpdateFlpParams): Promise<FolderLevelPermission>;
15
+ delete({ flp }: StorageOperationsDeleteFlpParams): Promise<void>;
16
+ batchUpdate({ items }: StorageOperationsBatchUpdateFlpParams): Promise<FolderLevelPermission[]>;
17
+ private ensureTable;
18
+ private toRow;
19
+ private fromRow;
20
+ }
@@ -0,0 +1,164 @@
1
+ import { WebinyError } from "@webiny/error";
2
+ const BASE_TABLE_NAME = "webiny_aco_flp";
3
+ class FolderLevelPermissionsStorageOperations {
4
+ constructor({ knex, tableNamePrefix }){
5
+ this.knex = knex;
6
+ this.tableName = tableNamePrefix ? `${tableNamePrefix}_${BASE_TABLE_NAME}` : BASE_TABLE_NAME;
7
+ }
8
+ async list({ where: { tenant, type, path_startsWith, parentId } }) {
9
+ try {
10
+ await this.ensureTable();
11
+ if (parentId) {
12
+ const rows = await this.knex(this.tableName).where("tenant", tenant).andWhere("parentId", parentId);
13
+ return rows.map((row)=>this.fromRow(row));
14
+ }
15
+ if (path_startsWith) {
16
+ const rows = await this.knex(this.tableName).where("tenant", tenant).andWhere("type", type).andWhere("path", "like", path_startsWith + "%");
17
+ return rows.map((row)=>this.fromRow(row));
18
+ }
19
+ throw new WebinyError("Missing required parameters.", "LIST_FLP_MISSING_PARAMETERS", {
20
+ tenant,
21
+ type,
22
+ path_startsWith,
23
+ parentId
24
+ });
25
+ } catch (err) {
26
+ throw WebinyError.from(err, {
27
+ message: "Could not list folder level permissions.",
28
+ code: "LIST_FLP_ERROR"
29
+ });
30
+ }
31
+ }
32
+ async get({ tenant, id }) {
33
+ try {
34
+ await this.ensureTable();
35
+ const row = await this.knex(this.tableName).where("tenant", tenant).andWhere("id", id).first();
36
+ if (!row) return null;
37
+ return this.fromRow(row);
38
+ } catch (err) {
39
+ throw WebinyError.from(err, {
40
+ message: "Could not load folder level permission.",
41
+ code: "GET_FLP_ERROR",
42
+ data: {
43
+ tenant,
44
+ id
45
+ }
46
+ });
47
+ }
48
+ }
49
+ async create({ data }) {
50
+ try {
51
+ await this.ensureTable();
52
+ await this.knex(this.tableName).insert(this.toRow(data));
53
+ return data;
54
+ } catch (err) {
55
+ throw WebinyError.from(err, {
56
+ message: "Could not create folder level permission.",
57
+ code: "CREATE_FLP_ERROR",
58
+ data: {
59
+ data
60
+ }
61
+ });
62
+ }
63
+ }
64
+ async update({ data: inputData, original }) {
65
+ try {
66
+ await this.ensureTable();
67
+ const data = {
68
+ ...original,
69
+ ...inputData
70
+ };
71
+ await this.knex(this.tableName).where("tenant", data.tenant).andWhere("id", data.id).update(this.toRow(data));
72
+ return data;
73
+ } catch (err) {
74
+ throw WebinyError.from(err, {
75
+ message: "Could not update folder level permission.",
76
+ code: "UPDATE_FLP_ERROR",
77
+ data: {
78
+ inputData,
79
+ original
80
+ }
81
+ });
82
+ }
83
+ }
84
+ async delete({ flp }) {
85
+ try {
86
+ await this.ensureTable();
87
+ await this.knex(this.tableName).where("tenant", flp.tenant).andWhere("id", flp.id).delete();
88
+ } catch (err) {
89
+ throw WebinyError.from(err, {
90
+ message: "Could not delete folder level permission.",
91
+ code: "DELETE_FLP_ERROR",
92
+ data: {
93
+ flp
94
+ }
95
+ });
96
+ }
97
+ }
98
+ async batchUpdate({ items }) {
99
+ try {
100
+ await this.ensureTable();
101
+ const updatedItems = [];
102
+ await this.knex.transaction(async (trx)=>{
103
+ for (const { original, data: inputData } of items){
104
+ const data = {
105
+ ...original,
106
+ ...inputData
107
+ };
108
+ await trx(this.tableName).where("tenant", data.tenant).andWhere("id", data.id).update(this.toRow(data));
109
+ updatedItems.push(data);
110
+ }
111
+ });
112
+ return updatedItems;
113
+ } catch (err) {
114
+ throw WebinyError.from(err, {
115
+ message: "Could not batch update folder level permissions.",
116
+ code: "BATCH_UPDATE_FLP_ERROR",
117
+ data: {
118
+ items
119
+ }
120
+ });
121
+ }
122
+ }
123
+ async ensureTable() {
124
+ const exists = await this.knex.schema.hasTable(this.tableName);
125
+ if (exists) return;
126
+ await this.knex.schema.createTable(this.tableName, (table)=>{
127
+ table.text("id").notNullable();
128
+ table.text("tenant").notNullable();
129
+ table.text("type").notNullable();
130
+ table.text("slug").notNullable();
131
+ table.text("path").notNullable();
132
+ table.text("parentId").notNullable();
133
+ table.text("permissions").notNullable();
134
+ table.primary([
135
+ "tenant",
136
+ "id"
137
+ ]);
138
+ });
139
+ }
140
+ toRow(data) {
141
+ return {
142
+ id: data.id,
143
+ tenant: data.tenant,
144
+ type: data.type,
145
+ slug: data.slug,
146
+ path: data.path,
147
+ parentId: data.parentId,
148
+ permissions: JSON.stringify(data.permissions)
149
+ };
150
+ }
151
+ fromRow(row) {
152
+ return {
153
+ id: row.id,
154
+ parentId: row.parentId,
155
+ slug: row.slug,
156
+ path: row.path,
157
+ permissions: JSON.parse(row.permissions),
158
+ type: row.type
159
+ };
160
+ }
161
+ }
162
+ export { FolderLevelPermissionsStorageOperations };
163
+
164
+ //# sourceMappingURL=FolderLevelPermissionsStorageOperations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FolderLevelPermissionsStorageOperations.js","sources":["../src/FolderLevelPermissionsStorageOperations.ts"],"sourcesContent":["import type { Knex } from \"knex\";\nimport { WebinyError } from \"@webiny/error\";\nimport type {\n AcoFolderLevelPermissionsStorageOperations,\n FolderLevelPermission,\n StorageOperationsBatchUpdateFlpParams,\n StorageOperationsCreateFlpParams,\n StorageOperationsDeleteFlpParams,\n StorageOperationsGetFlpParams,\n StorageOperationsListFlpsParams,\n StorageOperationsUpdateFlpParams\n} from \"@webiny/api-aco/types.js\";\n\ninterface FlpRow {\n id: string;\n tenant: string;\n type: string;\n slug: string;\n path: string;\n parentId: string;\n permissions: string;\n}\n\nconst BASE_TABLE_NAME = \"webiny_aco_flp\";\n\nexport interface StorageOperationsConfig {\n knex: Knex;\n tableNamePrefix?: string;\n}\n\nexport class FolderLevelPermissionsStorageOperations implements AcoFolderLevelPermissionsStorageOperations {\n private readonly knex: Knex;\n private readonly tableName: string;\n\n constructor({ knex, tableNamePrefix }: StorageOperationsConfig) {\n this.knex = knex;\n this.tableName = tableNamePrefix\n ? `${tableNamePrefix}_${BASE_TABLE_NAME}`\n : BASE_TABLE_NAME;\n }\n\n public async list({\n where: { tenant, type, path_startsWith, parentId }\n }: StorageOperationsListFlpsParams): Promise<FolderLevelPermission[]> {\n try {\n await this.ensureTable();\n\n if (parentId) {\n const rows = await this.knex<FlpRow>(this.tableName)\n .where(\"tenant\", tenant)\n .andWhere(\"parentId\", parentId);\n\n return rows.map(row => this.fromRow(row));\n }\n\n if (path_startsWith) {\n const rows = await this.knex<FlpRow>(this.tableName)\n .where(\"tenant\", tenant)\n .andWhere(\"type\", type)\n .andWhere(\"path\", \"like\", path_startsWith + \"%\");\n\n return rows.map(row => this.fromRow(row));\n }\n\n throw new WebinyError(\"Missing required parameters.\", \"LIST_FLP_MISSING_PARAMETERS\", {\n tenant,\n type,\n path_startsWith,\n parentId\n });\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not list folder level permissions.\",\n code: \"LIST_FLP_ERROR\"\n });\n }\n }\n\n public async get({\n tenant,\n id\n }: StorageOperationsGetFlpParams): Promise<FolderLevelPermission | null> {\n try {\n await this.ensureTable();\n\n const row = await this.knex<FlpRow>(this.tableName)\n .where(\"tenant\", tenant)\n .andWhere(\"id\", id)\n .first();\n\n if (!row) {\n return null;\n }\n\n return this.fromRow(row);\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not load folder level permission.\",\n code: \"GET_FLP_ERROR\",\n data: { tenant, id }\n });\n }\n }\n\n public async create({\n data\n }: StorageOperationsCreateFlpParams): Promise<FolderLevelPermission> {\n try {\n await this.ensureTable();\n\n await this.knex<FlpRow>(this.tableName).insert(this.toRow(data));\n\n return data;\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not create folder level permission.\",\n code: \"CREATE_FLP_ERROR\",\n data: { data }\n });\n }\n }\n\n public async update({\n data: inputData,\n original\n }: StorageOperationsUpdateFlpParams): Promise<FolderLevelPermission> {\n try {\n await this.ensureTable();\n\n const data = {\n ...original,\n ...inputData\n };\n\n await this.knex<FlpRow>(this.tableName)\n .where(\"tenant\", data.tenant)\n .andWhere(\"id\", data.id)\n .update(this.toRow(data));\n\n return data;\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not update folder level permission.\",\n code: \"UPDATE_FLP_ERROR\",\n data: { inputData, original }\n });\n }\n }\n\n public async delete({ flp }: StorageOperationsDeleteFlpParams): Promise<void> {\n try {\n await this.ensureTable();\n\n await this.knex<FlpRow>(this.tableName)\n .where(\"tenant\", flp.tenant)\n .andWhere(\"id\", flp.id)\n .delete();\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not delete folder level permission.\",\n code: \"DELETE_FLP_ERROR\",\n data: { flp }\n });\n }\n }\n\n public async batchUpdate({\n items\n }: StorageOperationsBatchUpdateFlpParams): Promise<FolderLevelPermission[]> {\n try {\n await this.ensureTable();\n\n const updatedItems: FolderLevelPermission[] = [];\n\n await this.knex.transaction(async trx => {\n for (const { original, data: inputData } of items) {\n const data = {\n ...original,\n ...inputData\n };\n\n await trx<FlpRow>(this.tableName)\n .where(\"tenant\", data.tenant)\n .andWhere(\"id\", data.id)\n .update(this.toRow(data));\n\n updatedItems.push(data);\n }\n });\n\n return updatedItems;\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not batch update folder level permissions.\",\n code: \"BATCH_UPDATE_FLP_ERROR\",\n data: { items }\n });\n }\n }\n\n private async ensureTable(): Promise<void> {\n const exists = await this.knex.schema.hasTable(this.tableName);\n if (exists) {\n return;\n }\n\n await this.knex.schema.createTable(this.tableName, table => {\n table.text(\"id\").notNullable();\n table.text(\"tenant\").notNullable();\n table.text(\"type\").notNullable();\n table.text(\"slug\").notNullable();\n table.text(\"path\").notNullable();\n table.text(\"parentId\").notNullable();\n table.text(\"permissions\").notNullable();\n table.primary([\"tenant\", \"id\"]);\n });\n }\n\n private toRow(data: FolderLevelPermission & { tenant: string }): FlpRow {\n return {\n id: data.id,\n tenant: data.tenant,\n type: data.type,\n slug: data.slug,\n path: data.path,\n parentId: data.parentId,\n permissions: JSON.stringify(data.permissions)\n };\n }\n\n private fromRow(row: FlpRow): FolderLevelPermission {\n return {\n id: row.id,\n parentId: row.parentId,\n slug: row.slug,\n path: row.path,\n permissions: JSON.parse(row.permissions),\n type: row.type\n };\n }\n}\n"],"names":["BASE_TABLE_NAME","FolderLevelPermissionsStorageOperations","knex","tableNamePrefix","tenant","type","path_startsWith","parentId","rows","row","WebinyError","err","id","data","inputData","original","flp","items","updatedItems","trx","exists","table","JSON"],"mappings":";AAuBA,MAAMA,kBAAkB;AAOjB,MAAMC;IAIT,YAAY,EAAEC,IAAI,EAAEC,eAAe,EAA2B,CAAE;QAC5D,IAAI,CAAC,IAAI,GAAGD;QACZ,IAAI,CAAC,SAAS,GAAGC,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C;IACJ;IAEQ,MAAMR,IAAgD,EAAU;QACpE,OAAO;YACH,IAAIA,KAAK,EAAE;YACX,QAAQA,KAAK,MAAM;YACnB,MAAMA,KAAK,IAAI;YACf,MAAMA,KAAK,IAAI;YACf,MAAMA,KAAK,IAAI;YACf,UAAUA,KAAK,QAAQ;YACvB,aAAaS,KAAK,SAAS,CAACT,KAAK,WAAW;QAChD;IACJ;IAEQ,QAAQJ,GAAW,EAAyB;QAChD,OAAO;YACH,IAAIA,IAAI,EAAE;YACV,UAAUA,IAAI,QAAQ;YACtB,MAAMA,IAAI,IAAI;YACd,MAAMA,IAAI,IAAI;YACd,aAAaa,KAAK,KAAK,CAACb,IAAI,WAAW;YACvC,MAAMA,IAAI,IAAI;QAClB;IACJ;AACJ"}
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,11 @@
1
+ # @webiny/api-aco-sql
2
+
3
+ > [!NOTE]
4
+ > This package is part of the [Webiny](https://www.webiny.com) monorepo.
5
+ > It’s **included in every Webiny project by default** and is not meant to be used as a standalone package.
6
+
7
+ 📘 **Documentation:** [https://www.webiny.com/docs](https://www.webiny.com/docs)
8
+
9
+ ---
10
+
11
+ _This README file is automatically generated during the publish process._
package/index.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ import type { Knex } from "knex";
2
+ interface RegisterAcoSqlStorageOperationsParams {
3
+ knex: Knex;
4
+ tableNamePrefix?: string;
5
+ }
6
+ export declare const registerAcoSqlStorageOperations: (params: RegisterAcoSqlStorageOperationsParams) => import("@webiny/handler").RegisterExtensionPlugin<import("@webiny/handler/types.js").Context>;
7
+ export {};
package/index.js ADDED
@@ -0,0 +1,13 @@
1
+ import { createRegisterExtensionPlugin } from "@webiny/handler";
2
+ import { FolderLevelPermissionsStorageOperations } from "./FolderLevelPermissionsStorageOperations.js";
3
+ import { FlpStorageOperations } from "@webiny/api-aco/features/folder/shared/abstractions.js";
4
+ const registerAcoSqlStorageOperations = (params)=>createRegisterExtensionPlugin((context)=>{
5
+ const flpStorageOperations = new FolderLevelPermissionsStorageOperations({
6
+ knex: params.knex,
7
+ tableNamePrefix: params.tableNamePrefix
8
+ });
9
+ context.container.registerInstance(FlpStorageOperations, flpStorageOperations);
10
+ });
11
+ export { registerAcoSqlStorageOperations };
12
+
13
+ //# sourceMappingURL=index.js.map
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import type { Knex } from \"knex\";\nimport { createRegisterExtensionPlugin } from \"@webiny/handler\";\nimport { FolderLevelPermissionsStorageOperations } from \"./FolderLevelPermissionsStorageOperations.js\";\nimport { FlpStorageOperations } from \"@webiny/api-aco/features/folder/shared/abstractions.js\";\n\ninterface RegisterAcoSqlStorageOperationsParams {\n knex: Knex;\n tableNamePrefix?: string;\n}\n\nexport const registerAcoSqlStorageOperations = (params: RegisterAcoSqlStorageOperationsParams) => {\n return createRegisterExtensionPlugin(context => {\n const flpStorageOperations = new FolderLevelPermissionsStorageOperations({\n knex: params.knex,\n tableNamePrefix: params.tableNamePrefix\n });\n\n context.container.registerInstance(FlpStorageOperations, flpStorageOperations);\n });\n};\n"],"names":["registerAcoSqlStorageOperations","params","createRegisterExtensionPlugin","context","flpStorageOperations","FolderLevelPermissionsStorageOperations","FlpStorageOperations"],"mappings":";;;AAUO,MAAMA,kCAAkC,CAACC,SACrCC,8BAA8BC,CAAAA;QACjC,MAAMC,uBAAuB,IAAIC,wCAAwC;YACrE,MAAMJ,OAAO,IAAI;YACjB,iBAAiBA,OAAO,eAAe;QAC3C;QAEAE,QAAQ,SAAS,CAAC,gBAAgB,CAACG,sBAAsBF;IAC7D"}
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@webiny/api-aco-sql",
3
+ "version": "0.0.0-unstable.0d717d18dd",
4
+ "type": "module",
5
+ "keywords": [
6
+ "@webiny/api-aco",
7
+ "storage-operations",
8
+ "sql",
9
+ "sau:sql"
10
+ ],
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "https://github.com/webiny/webiny-js.git"
14
+ },
15
+ "description": "SQL storage operations for @webiny/api-aco.",
16
+ "author": "Webiny Ltd.",
17
+ "license": "MIT",
18
+ "exports": {
19
+ ".": "./index.js",
20
+ "./*": "./*"
21
+ },
22
+ "dependencies": {
23
+ "@webiny/api-aco": "0.0.0-unstable.0d717d18dd",
24
+ "@webiny/error": "0.0.0-unstable.0d717d18dd",
25
+ "@webiny/handler": "0.0.0-unstable.0d717d18dd",
26
+ "knex": "3.3.0"
27
+ },
28
+ "devDependencies": {
29
+ "@webiny/build-tools": "0.0.0-unstable.0d717d18dd",
30
+ "@webiny/project-utils": "0.0.0-unstable.0d717d18dd",
31
+ "better-sqlite3": "13.0.2",
32
+ "rimraf": "6.1.3",
33
+ "typescript": "7.0.2",
34
+ "vitest": "4.1.10"
35
+ },
36
+ "publishConfig": {
37
+ "access": "public"
38
+ },
39
+ "webiny": {
40
+ "publishFrom": "dist"
41
+ }
42
+ }