@webiny/api-aco-ddb 6.6.0-alpha.12 → 6.6.0-alpha.14
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/AcoDdbFeature.js +2 -9
- package/AcoDdbFeature.js.map +1 -1
- package/DdbFlpStorageOperations.d.ts +12 -0
- package/DdbFlpStorageOperations.js +22 -0
- package/DdbFlpStorageOperations.js.map +1 -0
- package/FolderLevelPermissionsStorageOperations.d.ts +11 -5
- package/FolderLevelPermissionsStorageOperations.js +62 -26
- package/FolderLevelPermissionsStorageOperations.js.map +1 -1
- package/index.js +5 -10
- package/index.js.map +1 -1
- package/package.json +11 -11
package/AcoDdbFeature.js
CHANGED
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
import { createFeature } from "@webiny/feature/api";
|
|
2
|
-
import { DynamoDBClient } from "@webiny/db-dynamodb";
|
|
3
|
-
import { FlpStorageOperations } from "@webiny/api-aco/features/folder/shared/abstractions.js";
|
|
4
2
|
import { TaskCatalogFlpFeature } from "@webiny/api-aco/flpTaskCatalog/index.js";
|
|
5
|
-
import {
|
|
3
|
+
import { DdbFlpStorageOperations } from "./DdbFlpStorageOperations.js";
|
|
6
4
|
const AcoDdbFeature = createFeature({
|
|
7
5
|
name: "AcoDdb",
|
|
8
6
|
register (container) {
|
|
9
|
-
container.
|
|
10
|
-
const db = container.resolve(DynamoDBClient);
|
|
11
|
-
return new FolderLevelPermissionsStorageOperations({
|
|
12
|
-
documentClient: db.client
|
|
13
|
-
});
|
|
14
|
-
});
|
|
7
|
+
container.register(DdbFlpStorageOperations).inContainerScope();
|
|
15
8
|
TaskCatalogFlpFeature.register(container);
|
|
16
9
|
}
|
|
17
10
|
});
|
package/AcoDdbFeature.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AcoDdbFeature.js","sources":["../src/AcoDdbFeature.ts"],"sourcesContent":["import { type Container, createFeature } from \"@webiny/feature/api\";\nimport {
|
|
1
|
+
{"version":3,"file":"AcoDdbFeature.js","sources":["../src/AcoDdbFeature.ts"],"sourcesContent":["import { type Container, createFeature } from \"@webiny/feature/api\";\nimport { TaskCatalogFlpFeature } from \"@webiny/api-aco/flpTaskCatalog/index.js\";\nimport { DdbFlpStorageOperations } from \"./DdbFlpStorageOperations.js\";\n\nexport const AcoDdbFeature = createFeature({\n name: \"AcoDdb\",\n register(container: Container) {\n // Registered once, in the root, and built in each tenant scope with the scope's tenant.\n container.register(DdbFlpStorageOperations).inContainerScope();\n\n // Folder-level permissions on this storage use the task-maintained FLP catalog.\n TaskCatalogFlpFeature.register(container);\n }\n});\n"],"names":["AcoDdbFeature","createFeature","container","DdbFlpStorageOperations","TaskCatalogFlpFeature"],"mappings":";;;AAIO,MAAMA,gBAAgBC,cAAc;IACvC,MAAM;IACN,UAASC,SAAoB;QAEzBA,UAAU,QAAQ,CAACC,yBAAyB,gBAAgB;QAG5DC,sBAAsB,QAAQ,CAACF;IACnC;AACJ"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DynamoDBClient } from "@webiny/db-dynamodb";
|
|
2
|
+
import { FlpStorageOperations } from "@webiny/api-aco/features/folder/shared/abstractions.js";
|
|
3
|
+
import { ScopeTenant } from "@webiny/api-core/features/tenancy/ScopeTenant/index.js";
|
|
4
|
+
import { FolderLevelPermissionsStorageOperations } from "./FolderLevelPermissionsStorageOperations.js";
|
|
5
|
+
/** Folder-level permissions on DynamoDB, for the tenant of the scope that builds them. */
|
|
6
|
+
declare class DdbFlpStorageOperationsImpl extends FolderLevelPermissionsStorageOperations implements FlpStorageOperations.Interface {
|
|
7
|
+
constructor(db: DynamoDBClient.Interface, scopeTenant: ScopeTenant.Interface);
|
|
8
|
+
}
|
|
9
|
+
export declare const DdbFlpStorageOperations: typeof DdbFlpStorageOperationsImpl & {
|
|
10
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-aco/types.js").AcoFolderLevelPermissionsStorageOperations>;
|
|
11
|
+
};
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { DynamoDBClient } from "@webiny/db-dynamodb";
|
|
2
|
+
import { FlpStorageOperations } from "@webiny/api-aco/features/folder/shared/abstractions.js";
|
|
3
|
+
import { ScopeTenant } from "@webiny/api-core/features/tenancy/ScopeTenant/index.js";
|
|
4
|
+
import { FolderLevelPermissionsStorageOperations } from "./FolderLevelPermissionsStorageOperations.js";
|
|
5
|
+
class DdbFlpStorageOperationsImpl extends FolderLevelPermissionsStorageOperations {
|
|
6
|
+
constructor(db, scopeTenant){
|
|
7
|
+
super({
|
|
8
|
+
documentClient: db.client,
|
|
9
|
+
scopeTenant
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
const DdbFlpStorageOperations = FlpStorageOperations.createImplementation({
|
|
14
|
+
implementation: DdbFlpStorageOperationsImpl,
|
|
15
|
+
dependencies: [
|
|
16
|
+
DynamoDBClient,
|
|
17
|
+
ScopeTenant
|
|
18
|
+
]
|
|
19
|
+
});
|
|
20
|
+
export { DdbFlpStorageOperations };
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=DdbFlpStorageOperations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DdbFlpStorageOperations.js","sources":["../src/DdbFlpStorageOperations.ts"],"sourcesContent":["import { DynamoDBClient } from \"@webiny/db-dynamodb\";\nimport { FlpStorageOperations } from \"@webiny/api-aco/features/folder/shared/abstractions.js\";\nimport { ScopeTenant } from \"@webiny/api-core/features/tenancy/ScopeTenant/index.js\";\nimport { FolderLevelPermissionsStorageOperations } from \"./FolderLevelPermissionsStorageOperations.js\";\n\n/** Folder-level permissions on DynamoDB, for the tenant of the scope that builds them. */\nclass DdbFlpStorageOperationsImpl\n extends FolderLevelPermissionsStorageOperations\n implements FlpStorageOperations.Interface\n{\n public constructor(db: DynamoDBClient.Interface, scopeTenant: ScopeTenant.Interface) {\n super({ documentClient: db.client, scopeTenant });\n }\n}\n\nexport const DdbFlpStorageOperations = FlpStorageOperations.createImplementation({\n implementation: DdbFlpStorageOperationsImpl,\n dependencies: [DynamoDBClient, ScopeTenant]\n});\n"],"names":["DdbFlpStorageOperationsImpl","FolderLevelPermissionsStorageOperations","db","scopeTenant","DdbFlpStorageOperations","FlpStorageOperations","DynamoDBClient","ScopeTenant"],"mappings":";;;;AAMA,MAAMA,oCACMC;IAGR,YAAmBC,EAA4B,EAAEC,WAAkC,CAAE;QACjF,KAAK,CAAC;YAAE,gBAAgBD,GAAG,MAAM;YAAEC;QAAY;IACnD;AACJ;AAEO,MAAMC,0BAA0BC,qBAAqB,oBAAoB,CAAC;IAC7E,gBAAgBL;IAChB,cAAc;QAACM;QAAgBC;KAAY;AAC/C"}
|
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb/index.js";
|
|
2
2
|
import type { AcoFolderLevelPermissionsStorageOperations, FolderLevelPermission, StorageOperationsBatchUpdateFlpParams, StorageOperationsCreateFlpParams, StorageOperationsDeleteFlpParams, StorageOperationsGetFlpParams, StorageOperationsListFlpsParams, StorageOperationsUpdateFlpParams } from "@webiny/api-aco/types.js";
|
|
3
|
+
import type { ScopeTenant } from "@webiny/api-core/features/tenancy/ScopeTenant/index.js";
|
|
3
4
|
export interface StorageOperationsConfig {
|
|
4
5
|
documentClient: DynamoDBDocument;
|
|
6
|
+
/** The tenant the storage acts on: its tenant scope's. */
|
|
7
|
+
scopeTenant: ScopeTenant.Interface;
|
|
5
8
|
}
|
|
6
9
|
export declare class FolderLevelPermissionsStorageOperations implements AcoFolderLevelPermissionsStorageOperations {
|
|
7
10
|
private readonly entity;
|
|
8
11
|
private readonly table;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
private readonly scopeTenant;
|
|
13
|
+
constructor({ documentClient, scopeTenant }: StorageOperationsConfig);
|
|
14
|
+
/** The permission with its scope's tenant, whatever tenant it carries. */
|
|
15
|
+
private inScope;
|
|
16
|
+
list({ where }: StorageOperationsListFlpsParams): Promise<FolderLevelPermission[]>;
|
|
17
|
+
get(params: StorageOperationsGetFlpParams): Promise<FolderLevelPermission | null>;
|
|
18
|
+
create(params: StorageOperationsCreateFlpParams): Promise<FolderLevelPermission>;
|
|
13
19
|
update({ data: inputData, original }: StorageOperationsUpdateFlpParams): Promise<FolderLevelPermission>;
|
|
14
|
-
delete(
|
|
20
|
+
delete(params: StorageOperationsDeleteFlpParams): Promise<void>;
|
|
15
21
|
batchUpdate({ items }: StorageOperationsBatchUpdateFlpParams): Promise<FolderLevelPermission[]>;
|
|
16
22
|
private createKeys;
|
|
17
23
|
private createGsiKeys;
|
|
@@ -1,18 +1,41 @@
|
|
|
1
1
|
import { createStandardEntity, createTable } from "@webiny/db-dynamodb";
|
|
2
2
|
import { WebinyError } from "@webiny/error";
|
|
3
3
|
import { executeWithRetry } from "@webiny/utils";
|
|
4
|
+
const createTableAndEntity = (documentClient)=>{
|
|
5
|
+
const table = createTable({
|
|
6
|
+
name: String(process.env.DB_TABLE),
|
|
7
|
+
documentClient
|
|
8
|
+
});
|
|
9
|
+
const entity = createStandardEntity({
|
|
10
|
+
table: table.table,
|
|
11
|
+
name: "ACO.flp"
|
|
12
|
+
});
|
|
13
|
+
return {
|
|
14
|
+
table,
|
|
15
|
+
entity
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
const tablesByClient = new WeakMap();
|
|
4
19
|
class FolderLevelPermissionsStorageOperations {
|
|
5
|
-
constructor({ documentClient }){
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
documentClient
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
20
|
+
constructor({ documentClient, scopeTenant }){
|
|
21
|
+
let tableAndEntity = tablesByClient.get(documentClient);
|
|
22
|
+
if (!tableAndEntity) {
|
|
23
|
+
tableAndEntity = createTableAndEntity(documentClient);
|
|
24
|
+
tablesByClient.set(documentClient, tableAndEntity);
|
|
25
|
+
}
|
|
26
|
+
this.table = tableAndEntity.table;
|
|
27
|
+
this.entity = tableAndEntity.entity;
|
|
28
|
+
this.scopeTenant = scopeTenant;
|
|
29
|
+
}
|
|
30
|
+
inScope(record) {
|
|
31
|
+
return {
|
|
32
|
+
...record,
|
|
33
|
+
tenant: this.scopeTenant.getId()
|
|
34
|
+
};
|
|
14
35
|
}
|
|
15
|
-
async list({ where
|
|
36
|
+
async list({ where }) {
|
|
37
|
+
const { type, path_startsWith, parentId } = where;
|
|
38
|
+
const tenant = this.scopeTenant.getId();
|
|
16
39
|
try {
|
|
17
40
|
if (parentId) {
|
|
18
41
|
const entries = await this.entity.queryAll({
|
|
@@ -34,6 +57,15 @@ class FolderLevelPermissionsStorageOperations {
|
|
|
34
57
|
});
|
|
35
58
|
return entries.map((entry)=>entry.data);
|
|
36
59
|
}
|
|
60
|
+
if (type) {
|
|
61
|
+
const entries = await this.entity.queryAll({
|
|
62
|
+
partitionKey: `T#${tenant}#AT#${type}#FLP`,
|
|
63
|
+
options: {
|
|
64
|
+
index: "GSI1"
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
return entries.map((entry)=>entry.data);
|
|
68
|
+
}
|
|
37
69
|
throw new WebinyError("Missing required parameters.", "LIST_FLP_MISSING_PARAMETERS", {
|
|
38
70
|
tenant,
|
|
39
71
|
type,
|
|
@@ -47,7 +79,9 @@ class FolderLevelPermissionsStorageOperations {
|
|
|
47
79
|
});
|
|
48
80
|
}
|
|
49
81
|
}
|
|
50
|
-
async get(
|
|
82
|
+
async get(params) {
|
|
83
|
+
const { id } = params;
|
|
84
|
+
const tenant = this.scopeTenant.getId();
|
|
51
85
|
try {
|
|
52
86
|
const entry = await this.entity.get(this.createKeys({
|
|
53
87
|
tenant,
|
|
@@ -66,7 +100,8 @@ class FolderLevelPermissionsStorageOperations {
|
|
|
66
100
|
});
|
|
67
101
|
}
|
|
68
102
|
}
|
|
69
|
-
async create(
|
|
103
|
+
async create(params) {
|
|
104
|
+
const data = this.inScope(params.data);
|
|
70
105
|
const keys = {
|
|
71
106
|
...this.createKeys(data),
|
|
72
107
|
...this.createGsiKeys(data)
|
|
@@ -89,15 +124,15 @@ class FolderLevelPermissionsStorageOperations {
|
|
|
89
124
|
}
|
|
90
125
|
}
|
|
91
126
|
async update({ data: inputData, original }) {
|
|
127
|
+
const data = this.inScope({
|
|
128
|
+
...original,
|
|
129
|
+
...inputData
|
|
130
|
+
});
|
|
131
|
+
const keys = {
|
|
132
|
+
...this.createKeys(data),
|
|
133
|
+
...this.createGsiKeys(data)
|
|
134
|
+
};
|
|
92
135
|
try {
|
|
93
|
-
const data = {
|
|
94
|
-
...original,
|
|
95
|
-
...inputData
|
|
96
|
-
};
|
|
97
|
-
const keys = {
|
|
98
|
-
...this.createKeys(data),
|
|
99
|
-
...this.createGsiKeys(data)
|
|
100
|
-
};
|
|
101
136
|
await this.entity.put({
|
|
102
137
|
...keys,
|
|
103
138
|
data
|
|
@@ -114,7 +149,8 @@ class FolderLevelPermissionsStorageOperations {
|
|
|
114
149
|
});
|
|
115
150
|
}
|
|
116
151
|
}
|
|
117
|
-
async delete(
|
|
152
|
+
async delete(params) {
|
|
153
|
+
const flp = this.inScope(params.flp);
|
|
118
154
|
const keys = this.createKeys(flp);
|
|
119
155
|
try {
|
|
120
156
|
await this.entity.delete(keys);
|
|
@@ -130,14 +166,14 @@ class FolderLevelPermissionsStorageOperations {
|
|
|
130
166
|
}
|
|
131
167
|
}
|
|
132
168
|
async batchUpdate({ items }) {
|
|
169
|
+
const scopedItems = items.map(({ original, data: inputData })=>this.inScope({
|
|
170
|
+
...original,
|
|
171
|
+
...inputData
|
|
172
|
+
}));
|
|
133
173
|
try {
|
|
134
174
|
const batch = this.entity.createEntityWriter();
|
|
135
175
|
const updatedItems = [];
|
|
136
|
-
for (const
|
|
137
|
-
const data = {
|
|
138
|
-
...original,
|
|
139
|
-
...inputData
|
|
140
|
-
};
|
|
176
|
+
for (const data of scopedItems){
|
|
141
177
|
const keys = {
|
|
142
178
|
...this.createKeys(data),
|
|
143
179
|
...this.createGsiKeys(data)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FolderLevelPermissionsStorageOperations.js","sources":["../src/FolderLevelPermissionsStorageOperations.ts"],"sourcesContent":["import type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport { createStandardEntity, createTable } from \"@webiny/db-dynamodb\";\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\";\nimport { executeWithRetry } from \"@webiny/utils\";\n\nexport interface StorageOperationsConfig {\n documentClient: DynamoDBDocument;\n}\n\ninterface CreateKeysParams {\n tenant: string;\n id: string;\n}\n\ninterface CreateGsiKeysParams {\n tenant: string;\n id: string;\n type: string;\n path: string;\n parentId: string;\n}\n\nexport class FolderLevelPermissionsStorageOperations implements AcoFolderLevelPermissionsStorageOperations {\n private readonly entity;\n private readonly table;\n\n constructor({ documentClient }: StorageOperationsConfig) {\n this.table = createTable({\n name: String(process.env.DB_TABLE),\n documentClient\n });\n\n this.entity = createStandardEntity<FolderLevelPermission>({\n table: this.table.table,\n name: \"ACO.flp\"\n });\n }\n\n public async list({\n where: { tenant, type, path_startsWith, parentId }\n }: StorageOperationsListFlpsParams): Promise<FolderLevelPermission[]> {\n try {\n if (parentId) {\n const entries = await this.entity.queryAll({\n partitionKey: `T#${tenant}#FLP`,\n options: {\n index: \"GSI2\",\n eq: parentId\n }\n });\n return entries.map(entry => entry.data);\n }\n\n if (path_startsWith) {\n const entries = await this.entity.queryAll({\n partitionKey: `T#${tenant}#AT#${type}#FLP`,\n options: {\n index: \"GSI1\",\n beginsWith: path_startsWith\n }\n });\n return entries.map(entry => entry.data);\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 const entry = await this.entity.get(this.createKeys({ tenant, id }));\n\n if (!entry) {\n return null;\n }\n\n return entry.data;\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 const keys = {\n ...this.createKeys(data),\n ...this.createGsiKeys(data)\n };\n\n try {\n await this.entity.put({\n ...keys,\n data\n });\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: { keys, data }\n });\n }\n }\n\n public async update({\n data: inputData,\n original\n }: StorageOperationsUpdateFlpParams): Promise<FolderLevelPermission> {\n try {\n const data = {\n ...original,\n ...inputData\n };\n\n const keys = {\n ...this.createKeys(data),\n ...this.createGsiKeys(data)\n };\n\n await this.entity.put({\n ...keys,\n data\n });\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 const keys = this.createKeys(flp);\n\n try {\n await this.entity.delete(keys);\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not delete folder level permission.\",\n code: \"DELETE_FLP_ERROR\",\n data: {\n keys,\n flp\n }\n });\n }\n }\n\n public async batchUpdate({\n items\n }: StorageOperationsBatchUpdateFlpParams): Promise<FolderLevelPermission[]> {\n try {\n const batch = this.entity.createEntityWriter();\n\n const updatedItems: FolderLevelPermission[] = [];\n\n for (const { original, data: inputData } of items) {\n const data = {\n ...original,\n ...inputData\n };\n\n const keys = {\n ...this.createKeys(data),\n ...this.createGsiKeys(data)\n };\n\n batch.put({\n ...keys,\n data\n });\n\n updatedItems.push(data);\n }\n\n await executeWithRetry(async () => {\n return await batch.execute();\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 createKeys({ id, tenant }: CreateKeysParams) {\n return {\n PK: `T#${tenant}#FLP#${id}`,\n SK: `A`,\n TYPE: \"aco.flp\"\n };\n }\n\n private createGsiKeys({ tenant, type, path, parentId }: CreateGsiKeysParams) {\n return {\n GSI1_PK: `T#${tenant}#AT#${type}#FLP`,\n GSI1_SK: path,\n GSI2_PK: `T#${tenant}#FLP`,\n GSI2_SK: parentId,\n GSI_TENANT: tenant\n };\n }\n}\n"],"names":["FolderLevelPermissionsStorageOperations","documentClient","createTable","String","process","createStandardEntity","tenant","type","path_startsWith","parentId","entries","entry","WebinyError","err","id","data","keys","inputData","original","flp","items","batch","updatedItems","executeWithRetry","path"],"mappings":";;;AAgCO,MAAMA;IAIT,YAAY,EAAEC,cAAc,EAA2B,CAAE;QACrD,IAAI,CAAC,KAAK,GAAGC,YAAY;YACrB,MAAMC,OAAOC,QAAQ,GAAG,CAAC,QAAQ;YACjCH;QACJ;QAEA,IAAI,CAAC,MAAM,GAAGI,qBAA4C;YACtD,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK;YACvB,MAAM;QACV;IACJ;IAEA,MAAa,KAAK,EACd,OAAO,EAAEC,MAAM,EAAEC,IAAI,EAAEC,eAAe,EAAEC,QAAQ,EAAE,EACpB,EAAoC;QAClE,IAAI;YACA,IAAIA,UAAU;gBACV,MAAMC,UAAU,MAA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AQ;oBACX,GAAGD,SAAS;gBAChB;gBAEA,MAAMD,OAAO;oBACT,GAAG,IAAI,CAAC,UAAU,CAACD,KAAK;oBACxB,GAAG,IAAI,CAAC,aAAa,CAACA,KAAK;gBAC/B;gBAEAM,MAAM,GAAG,CAAC;oBACN,GAAGL,IAAI;oBACPD;gBACJ;gBAEAO,aAAa,IAAI,CAACP;YACtB;YAEA,MAAMQ,iBAAiB,UACZ,MAAMF,MAAM,OAAO;YAG9B,OAAOC;QACX,EAAE,OAAOT,KAAK;YACV,MAAMD,YAAY,IAAI,CAACC,KAAK;gBACxB,SAAS;gBACT,MAAM;gBACN,MAAM;oBAAEO;gBAAM;YAClB;QACJ;IACJ;IAEQ,WAAW,EAAEN,EAAE,EAAER,MAAM,EAAoB,EAAE;QACjD,OAAO;YACH,IAAI,CAAC,EAAE,EAAEA,OAAO,KAAK,EAAEQ,IAAI;YAC3B,IAAI;YACJ,MAAM;QACV;IACJ;IAEQ,cAAc,EAAER,MAAM,EAAEC,IAAI,EAAEiB,IAAI,EAAEf,QAAQ,EAAuB,EAAE;QACzE,OAAO;YACH,SAAS,CAAC,EAAE,EAAEH,OAAO,IAAI,EAAEC,KAAK,IAAI,CAAC;YACrC,SAASiB;YACT,SAAS,CAAC,EAAE,EAAElB,OAAO,IAAI,CAAC;YAC1B,SAASG;YACT,YAAYH;QAChB;IACJ;AACJ"}
|
|
1
|
+
{"version":3,"file":"FolderLevelPermissionsStorageOperations.js","sources":["../src/FolderLevelPermissionsStorageOperations.ts"],"sourcesContent":["import type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport { createStandardEntity, createTable } from \"@webiny/db-dynamodb\";\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\";\nimport { executeWithRetry } from \"@webiny/utils\";\nimport type { ScopeTenant } from \"@webiny/api-core/features/tenancy/ScopeTenant/index.js\";\n\nexport interface StorageOperationsConfig {\n documentClient: DynamoDBDocument;\n /** The tenant the storage acts on: its tenant scope's. */\n scopeTenant: ScopeTenant.Interface;\n}\n\nconst createTableAndEntity = (documentClient: DynamoDBDocument) => {\n const table = createTable({\n name: String(process.env.DB_TABLE),\n documentClient\n });\n const entity = createStandardEntity<FolderLevelPermission>({\n table: table.table,\n name: \"ACO.flp\"\n });\n return { table, entity };\n};\n\n/** The table and entity, built once per client: the storage itself is built per tenant scope. */\nconst tablesByClient = new WeakMap<DynamoDBDocument, ReturnType<typeof createTableAndEntity>>();\n\ninterface CreateKeysParams {\n tenant: string;\n id: string;\n}\n\ninterface CreateGsiKeysParams {\n tenant: string;\n id: string;\n type: string;\n path: string;\n parentId: string;\n}\n\nexport class FolderLevelPermissionsStorageOperations implements AcoFolderLevelPermissionsStorageOperations {\n private readonly entity;\n private readonly table;\n private readonly scopeTenant: ScopeTenant.Interface;\n\n constructor({ documentClient, scopeTenant }: StorageOperationsConfig) {\n let tableAndEntity = tablesByClient.get(documentClient);\n if (!tableAndEntity) {\n tableAndEntity = createTableAndEntity(documentClient);\n tablesByClient.set(documentClient, tableAndEntity);\n }\n this.table = tableAndEntity.table;\n this.entity = tableAndEntity.entity;\n this.scopeTenant = scopeTenant;\n }\n\n /** The permission with its scope's tenant, whatever tenant it carries. */\n private inScope<T extends { tenant?: string | null }>(record: T): T & { tenant: string } {\n return { ...record, tenant: this.scopeTenant.getId() };\n }\n\n public async list({\n where\n }: StorageOperationsListFlpsParams): Promise<FolderLevelPermission[]> {\n const { type, path_startsWith, parentId } = where;\n const tenant = this.scopeTenant.getId();\n try {\n if (parentId) {\n const entries = await this.entity.queryAll({\n partitionKey: `T#${tenant}#FLP`,\n options: {\n index: \"GSI2\",\n eq: parentId\n }\n });\n return entries.map(entry => entry.data);\n }\n\n if (path_startsWith) {\n const entries = await this.entity.queryAll({\n partitionKey: `T#${tenant}#AT#${type}#FLP`,\n options: {\n index: \"GSI1\",\n beginsWith: path_startsWith\n }\n });\n return entries.map(entry => entry.data);\n }\n\n // All folder level permissions of a folder type.\n if (type) {\n const entries = await this.entity.queryAll({\n partitionKey: `T#${tenant}#AT#${type}#FLP`,\n options: {\n index: \"GSI1\"\n }\n });\n return entries.map(entry => entry.data);\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(params: StorageOperationsGetFlpParams): Promise<FolderLevelPermission | null> {\n const { id } = params;\n const tenant = this.scopeTenant.getId();\n try {\n const entry = await this.entity.get(this.createKeys({ tenant, id }));\n\n if (!entry) {\n return null;\n }\n\n return entry.data;\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(params: StorageOperationsCreateFlpParams): Promise<FolderLevelPermission> {\n const data = this.inScope(params.data);\n const keys = {\n ...this.createKeys(data),\n ...this.createGsiKeys(data)\n };\n\n try {\n await this.entity.put({\n ...keys,\n data\n });\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: { keys, data }\n });\n }\n }\n\n public async update({\n data: inputData,\n original\n }: StorageOperationsUpdateFlpParams): Promise<FolderLevelPermission> {\n const data = this.inScope({\n ...original,\n ...inputData\n });\n\n const keys = {\n ...this.createKeys(data),\n ...this.createGsiKeys(data)\n };\n\n try {\n await this.entity.put({\n ...keys,\n data\n });\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(params: StorageOperationsDeleteFlpParams): Promise<void> {\n const flp = this.inScope(params.flp);\n const keys = this.createKeys(flp);\n\n try {\n await this.entity.delete(keys);\n } catch (err) {\n throw WebinyError.from(err, {\n message: \"Could not delete folder level permission.\",\n code: \"DELETE_FLP_ERROR\",\n data: {\n keys,\n flp\n }\n });\n }\n }\n\n public async batchUpdate({\n items\n }: StorageOperationsBatchUpdateFlpParams): Promise<FolderLevelPermission[]> {\n const scopedItems = items.map(({ original, data: inputData }) => {\n return this.inScope({\n ...original,\n ...inputData\n });\n });\n\n try {\n const batch = this.entity.createEntityWriter();\n\n const updatedItems: FolderLevelPermission[] = [];\n\n for (const data of scopedItems) {\n const keys = {\n ...this.createKeys(data),\n ...this.createGsiKeys(data)\n };\n\n batch.put({\n ...keys,\n data\n });\n\n updatedItems.push(data);\n }\n\n await executeWithRetry(async () => {\n return await batch.execute();\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 createKeys({ id, tenant }: CreateKeysParams) {\n return {\n PK: `T#${tenant}#FLP#${id}`,\n SK: `A`,\n TYPE: \"aco.flp\"\n };\n }\n\n private createGsiKeys({ tenant, type, path, parentId }: CreateGsiKeysParams) {\n return {\n GSI1_PK: `T#${tenant}#AT#${type}#FLP`,\n GSI1_SK: path,\n GSI2_PK: `T#${tenant}#FLP`,\n GSI2_SK: parentId,\n GSI_TENANT: tenant\n };\n }\n}\n"],"names":["createTableAndEntity","documentClient","table","createTable","String","process","entity","createStandardEntity","tablesByClient","WeakMap","FolderLevelPermissionsStorageOperations","scopeTenant","tableAndEntity","record","where","type","path_startsWith","parentId","tenant","entries","entry","WebinyError","err","params","id","data","keys","inputData","original","flp","items","scopedItems","batch","updatedItems","executeWithRetry","path"],"mappings":";;;AAsBA,MAAMA,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GC,QAAQ;gBACX,GAAGD,SAAS;YAChB;QAGJ,IAAI;YACA,MAAMK,QAAQ,IAAI,CAAC,MAAM,CAAC,kBAAkB;YAE5C,MAAMC,eAAwC,EAAE;YAEhD,KAAK,MAAMR,QAAQM,YAAa;gBAC5B,MAAML,OAAO;oBACT,GAAG,IAAI,CAAC,UAAU,CAACD,KAAK;oBACxB,GAAG,IAAI,CAAC,aAAa,CAACA,KAAK;gBAC/B;gBAEAO,MAAM,GAAG,CAAC;oBACN,GAAGN,IAAI;oBACPD;gBACJ;gBAEAQ,aAAa,IAAI,CAACR;YACtB;YAEA,MAAMS,iBAAiB,UACZ,MAAMF,MAAM,OAAO;YAG9B,OAAOC;QACX,EAAE,OAAOX,KAAK;YACV,MAAMD,YAAY,IAAI,CAACC,KAAK;gBACxB,SAAS;gBACT,MAAM;gBACN,MAAM;oBAAEQ;gBAAM;YAClB;QACJ;IACJ;IAEQ,WAAW,EAAEN,EAAE,EAAEN,MAAM,EAAoB,EAAE;QACjD,OAAO;YACH,IAAI,CAAC,EAAE,EAAEA,OAAO,KAAK,EAAEM,IAAI;YAC3B,IAAI;YACJ,MAAM;QACV;IACJ;IAEQ,cAAc,EAAEN,MAAM,EAAEH,IAAI,EAAEoB,IAAI,EAAElB,QAAQ,EAAuB,EAAE;QACzE,OAAO;YACH,SAAS,CAAC,EAAE,EAAEC,OAAO,IAAI,EAAEH,KAAK,IAAI,CAAC;YACrC,SAASoB;YACT,SAAS,CAAC,EAAE,EAAEjB,OAAO,IAAI,CAAC;YAC1B,SAASD;YACT,YAAYC;QAChB;IACJ;AACJ"}
|
package/index.js
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
import { createRegisterExtensionPlugin } from "@webiny/handler";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { TaskCatalogFlpFeature } from "@webiny/api-aco/flpTaskCatalog/index.js";
|
|
2
|
+
import { DynamoDBClientFeature } from "@webiny/db-dynamodb";
|
|
3
|
+
import { AcoDdbFeature } from "./AcoDdbFeature.js";
|
|
5
4
|
const registerAcoDdbStorageOperations = (params)=>createRegisterExtensionPlugin((context)=>{
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
});
|
|
9
|
-
context.container.registerInstance(FlpStorageOperations, flpStorageOperations);
|
|
10
|
-
TaskCatalogFlpFeature.register(context.container);
|
|
5
|
+
DynamoDBClientFeature.register(context.container, params.documentClient);
|
|
6
|
+
AcoDdbFeature.register(context.container);
|
|
11
7
|
});
|
|
12
|
-
export { AcoDdbFeature }
|
|
13
|
-
export { registerAcoDdbStorageOperations };
|
|
8
|
+
export { AcoDdbFeature, registerAcoDdbStorageOperations };
|
|
14
9
|
|
|
15
10
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport { createRegisterExtensionPlugin } from \"@webiny/handler\";\nimport {
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport { createRegisterExtensionPlugin } from \"@webiny/handler\";\nimport { DynamoDBClientFeature } from \"@webiny/db-dynamodb\";\nimport { AcoDdbFeature } from \"./AcoDdbFeature.js\";\n\ninterface RegisterAcoDdbStorageOperationsParams {\n documentClient: DynamoDBDocument;\n}\n\nexport const registerAcoDdbStorageOperations = (params: RegisterAcoDdbStorageOperationsParams) => {\n return createRegisterExtensionPlugin(context => {\n // The storage injects `DynamoDBClient`; this one wraps the given document client.\n DynamoDBClientFeature.register(context.container, params.documentClient);\n AcoDdbFeature.register(context.container);\n });\n};\nexport { AcoDdbFeature } from \"./AcoDdbFeature.js\";\n"],"names":["registerAcoDdbStorageOperations","params","createRegisterExtensionPlugin","context","DynamoDBClientFeature","AcoDdbFeature"],"mappings":";;;AASO,MAAMA,kCAAkC,CAACC,SACrCC,8BAA8BC,CAAAA;QAEjCC,sBAAsB,QAAQ,CAACD,QAAQ,SAAS,EAAEF,OAAO,cAAc;QACvEI,cAAc,QAAQ,CAACF,QAAQ,SAAS;IAC5C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-aco-ddb",
|
|
3
|
-
"version": "6.6.0-alpha.
|
|
3
|
+
"version": "6.6.0-alpha.14",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"@webiny/api-aco",
|
|
@@ -21,18 +21,18 @@
|
|
|
21
21
|
"./*": "./*"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@webiny/api-aco": "6.6.0-alpha.
|
|
25
|
-
"@webiny/
|
|
26
|
-
"@webiny/
|
|
27
|
-
"@webiny/
|
|
28
|
-
"@webiny/
|
|
29
|
-
"@webiny/
|
|
30
|
-
"@webiny/
|
|
24
|
+
"@webiny/api-aco": "6.6.0-alpha.14",
|
|
25
|
+
"@webiny/api-core": "6.6.0-alpha.14",
|
|
26
|
+
"@webiny/aws-sdk": "6.6.0-alpha.14",
|
|
27
|
+
"@webiny/db-dynamodb": "6.6.0-alpha.14",
|
|
28
|
+
"@webiny/error": "6.6.0-alpha.14",
|
|
29
|
+
"@webiny/feature": "6.6.0-alpha.14",
|
|
30
|
+
"@webiny/handler": "6.6.0-alpha.14",
|
|
31
|
+
"@webiny/utils": "6.6.0-alpha.14"
|
|
31
32
|
},
|
|
32
33
|
"devDependencies": {
|
|
33
|
-
"@webiny/
|
|
34
|
-
"
|
|
35
|
-
"rimraf": "6.1.3",
|
|
34
|
+
"@webiny/build-tools": "6.6.0-alpha.14",
|
|
35
|
+
"rimraf": "6.1.4",
|
|
36
36
|
"typescript": "7.0.2"
|
|
37
37
|
},
|
|
38
38
|
"publishConfig": {
|