@webiny/api-page-builder-import-export-so-ddb 0.0.0-ee-vpcs.549378cf03

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,30 @@
1
+ # @webiny/api-page-builder-import-export-so-ddb
2
+
3
+ [![](https://img.shields.io/npm/dw/@webiny/api-page-builder-so-ddb.svg)](https://www.npmjs.com/package/@webiny/api-page-builder-so-ddb)
4
+ [![](https://img.shields.io/npm/v/@webiny/api-page-builder-so-ddb.svg)](https://www.npmjs.com/package/@webiny/api-page-builder-so-ddb)
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-page-builder-import-export-so-ddb
12
+ ```
13
+
14
+ Or if you prefer yarn:
15
+
16
+ ```
17
+ yarn add @webiny/api-page-builder-import-export-so-ddb
18
+ ```
19
+
20
+
21
+ ## Testing
22
+ To run the tests only for this package you must filter it with keywords.
23
+
24
+ ### Env variables
25
+
26
+
27
+ ### Command
28
+ ````
29
+ yarn test packages/api-page-builder-import-export --keyword=pbie:ddb --keyword=pbie:base
30
+ ````
@@ -0,0 +1,9 @@
1
+ import { Entity, Table } from "dynamodb-toolbox";
2
+ import { Attributes } from "../types";
3
+ interface Params {
4
+ entityName: string;
5
+ table: Table;
6
+ attributes?: Attributes;
7
+ }
8
+ export declare const createImportExportTaskEntity: ({ entityName, table, attributes }: Params) => Entity<{}>;
9
+ export {};
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.createImportExportTaskEntity = void 0;
9
+
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
+
12
+ var _dynamodbToolbox = require("dynamodb-toolbox");
13
+
14
+ const createImportExportTaskEntity = ({
15
+ entityName,
16
+ table,
17
+ attributes
18
+ }) => {
19
+ return new _dynamodbToolbox.Entity({
20
+ name: entityName,
21
+ table,
22
+ attributes: (0, _objectSpread2.default)({
23
+ PK: {
24
+ partitionKey: true
25
+ },
26
+ SK: {
27
+ sortKey: true
28
+ },
29
+ GSI1_PK: {
30
+ type: "string"
31
+ },
32
+ GSI1_SK: {
33
+ type: "string"
34
+ },
35
+ TYPE: {
36
+ type: "string"
37
+ },
38
+ id: {
39
+ type: "string"
40
+ },
41
+ parent: {
42
+ type: "string"
43
+ },
44
+ status: {
45
+ type: "string"
46
+ },
47
+ data: {
48
+ type: "map"
49
+ },
50
+ input: {
51
+ type: "map"
52
+ },
53
+ stats: {
54
+ type: "map"
55
+ },
56
+ error: {
57
+ type: "map"
58
+ },
59
+ createdOn: {
60
+ type: "string"
61
+ },
62
+ createdBy: {
63
+ type: "map"
64
+ },
65
+ tenant: {
66
+ type: "string"
67
+ },
68
+ locale: {
69
+ type: "string"
70
+ }
71
+ }, attributes)
72
+ });
73
+ };
74
+
75
+ exports.createImportExportTaskEntity = createImportExportTaskEntity;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createImportExportTaskEntity","entityName","table","attributes","Entity","name","PK","partitionKey","SK","sortKey","GSI1_PK","type","GSI1_SK","TYPE","id","parent","status","data","input","stats","error","createdOn","createdBy","tenant","locale"],"sources":["importExportTaskEntity.ts"],"sourcesContent":["import { Entity, Table } from \"dynamodb-toolbox\";\nimport { Attributes } from \"~/types\";\n\ninterface Params {\n entityName: string;\n table: Table;\n attributes?: Attributes;\n}\n\nexport const createImportExportTaskEntity = ({ entityName, table, attributes }: Params) => {\n return new Entity({\n name: entityName,\n table,\n attributes: {\n PK: {\n partitionKey: true\n },\n SK: {\n sortKey: true\n },\n GSI1_PK: {\n type: \"string\"\n },\n GSI1_SK: {\n type: \"string\"\n },\n TYPE: {\n type: \"string\"\n },\n id: {\n type: \"string\"\n },\n parent: {\n type: \"string\"\n },\n status: {\n type: \"string\"\n },\n data: {\n type: \"map\"\n },\n input: {\n type: \"map\"\n },\n stats: {\n type: \"map\"\n },\n error: {\n type: \"map\"\n },\n createdOn: {\n type: \"string\"\n },\n createdBy: {\n type: \"map\"\n },\n tenant: {\n type: \"string\"\n },\n locale: {\n type: \"string\"\n },\n ...attributes\n }\n });\n};\n"],"mappings":";;;;;;;;;;;AAAA;;AASO,MAAMA,4BAA4B,GAAG,CAAC;EAAEC,UAAF;EAAcC,KAAd;EAAqBC;AAArB,CAAD,KAA+C;EACvF,OAAO,IAAIC,uBAAJ,CAAW;IACdC,IAAI,EAAEJ,UADQ;IAEdC,KAFc;IAGdC,UAAU;MACNG,EAAE,EAAE;QACAC,YAAY,EAAE;MADd,CADE;MAINC,EAAE,EAAE;QACAC,OAAO,EAAE;MADT,CAJE;MAONC,OAAO,EAAE;QACLC,IAAI,EAAE;MADD,CAPH;MAUNC,OAAO,EAAE;QACLD,IAAI,EAAE;MADD,CAVH;MAaNE,IAAI,EAAE;QACFF,IAAI,EAAE;MADJ,CAbA;MAgBNG,EAAE,EAAE;QACAH,IAAI,EAAE;MADN,CAhBE;MAmBNI,MAAM,EAAE;QACJJ,IAAI,EAAE;MADF,CAnBF;MAsBNK,MAAM,EAAE;QACJL,IAAI,EAAE;MADF,CAtBF;MAyBNM,IAAI,EAAE;QACFN,IAAI,EAAE;MADJ,CAzBA;MA4BNO,KAAK,EAAE;QACHP,IAAI,EAAE;MADH,CA5BD;MA+BNQ,KAAK,EAAE;QACHR,IAAI,EAAE;MADH,CA/BD;MAkCNS,KAAK,EAAE;QACHT,IAAI,EAAE;MADH,CAlCD;MAqCNU,SAAS,EAAE;QACPV,IAAI,EAAE;MADC,CArCL;MAwCNW,SAAS,EAAE;QACPX,IAAI,EAAE;MADC,CAxCL;MA2CNY,MAAM,EAAE;QACJZ,IAAI,EAAE;MADF,CA3CF;MA8CNa,MAAM,EAAE;QACJb,IAAI,EAAE;MADF;IA9CF,GAiDHR,UAjDG;EAHI,CAAX,CAAP;AAuDH,CAxDM"}
@@ -0,0 +1,8 @@
1
+ import { Table } from "dynamodb-toolbox";
2
+ import { DocumentClient } from "aws-sdk/clients/dynamodb";
3
+ interface CreateTableParams {
4
+ table?: string;
5
+ documentClient: DocumentClient;
6
+ }
7
+ export declare const createTable: ({ table, documentClient }: CreateTableParams) => Table;
8
+ export {};
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createTable = void 0;
7
+
8
+ var _dynamodbToolbox = require("dynamodb-toolbox");
9
+
10
+ const createTable = ({
11
+ table,
12
+ documentClient
13
+ }) => {
14
+ return new _dynamodbToolbox.Table({
15
+ name: table || process.env.DB_TABLE_PAGE_BUILDER || process.env.DB_TABLE,
16
+ partitionKey: "PK",
17
+ sortKey: "SK",
18
+ DocumentClient: documentClient,
19
+ indexes: {
20
+ GSI1: {
21
+ partitionKey: "GSI1_PK",
22
+ sortKey: "GSI1_SK"
23
+ }
24
+ }
25
+ });
26
+ };
27
+
28
+ exports.createTable = createTable;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createTable","table","documentClient","Table","name","process","env","DB_TABLE_PAGE_BUILDER","DB_TABLE","partitionKey","sortKey","DocumentClient","indexes","GSI1"],"sources":["table.ts"],"sourcesContent":["import { Table } from \"dynamodb-toolbox\";\nimport { DocumentClient } from \"aws-sdk/clients/dynamodb\";\n\ninterface CreateTableParams {\n table?: string;\n documentClient: DocumentClient;\n}\n\nexport const createTable = ({ table, documentClient }: CreateTableParams) => {\n return new Table({\n name: table || process.env.DB_TABLE_PAGE_BUILDER || (process.env.DB_TABLE as string),\n partitionKey: \"PK\",\n sortKey: \"SK\",\n DocumentClient: documentClient,\n indexes: {\n GSI1: {\n partitionKey: \"GSI1_PK\",\n sortKey: \"GSI1_SK\"\n }\n }\n });\n};\n"],"mappings":";;;;;;;AAAA;;AAQO,MAAMA,WAAW,GAAG,CAAC;EAAEC,KAAF;EAASC;AAAT,CAAD,KAAkD;EACzE,OAAO,IAAIC,sBAAJ,CAAU;IACbC,IAAI,EAAEH,KAAK,IAAII,OAAO,CAACC,GAAR,CAAYC,qBAArB,IAA+CF,OAAO,CAACC,GAAR,CAAYE,QADpD;IAEbC,YAAY,EAAE,IAFD;IAGbC,OAAO,EAAE,IAHI;IAIbC,cAAc,EAAET,cAJH;IAKbU,OAAO,EAAE;MACLC,IAAI,EAAE;QACFJ,YAAY,EAAE,SADZ;QAEFC,OAAO,EAAE;MAFP;IADD;EALI,CAAV,CAAP;AAYH,CAbM"}
package/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import { CreateStorageOperations } from "./types";
2
+ export declare const createStorageOperations: CreateStorageOperations;
package/index.js ADDED
@@ -0,0 +1,396 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.createStorageOperations = void 0;
9
+
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
+
12
+ var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
13
+
14
+ var _error = _interopRequireDefault(require("@webiny/error"));
15
+
16
+ var _query = require("@webiny/db-dynamodb/utils/query");
17
+
18
+ var _listResponse = require("@webiny/db-dynamodb/utils/listResponse");
19
+
20
+ var _table = require("./definitions/table");
21
+
22
+ var _importExportTaskEntity = require("./definitions/importExportTaskEntity");
23
+
24
+ const PARENT_TASK_GSI1_PK = "PB#IE_TASKS";
25
+
26
+ const createPartitionKey = ({
27
+ tenant,
28
+ locale,
29
+ id
30
+ }) => {
31
+ return `T#${tenant}#L#${locale}#PB#IE_TASK#${id}`;
32
+ };
33
+
34
+ const createSortKey = input => {
35
+ return `SUB#${input}`;
36
+ };
37
+
38
+ const createGsiPartitionKey = ({
39
+ tenant,
40
+ locale,
41
+ id
42
+ }) => {
43
+ return `T#${tenant}#L#${locale}#PB#IE_TASK#${id}`;
44
+ };
45
+
46
+ const createGsiSortKey = (status, id) => {
47
+ return `S#${status}#${id}`;
48
+ };
49
+
50
+ const createType = () => {
51
+ return "pb.importExportTask";
52
+ };
53
+
54
+ const createStorageOperations = params => {
55
+ const {
56
+ table: tableName,
57
+ documentClient,
58
+ attributes = {}
59
+ } = params;
60
+ const table = (0, _table.createTable)({
61
+ table: tableName,
62
+ documentClient
63
+ });
64
+ const entity = (0, _importExportTaskEntity.createImportExportTaskEntity)({
65
+ entityName: "ImportExportTask",
66
+ table,
67
+ attributes
68
+ });
69
+ return {
70
+ getTable() {
71
+ return table;
72
+ },
73
+
74
+ getEntity() {
75
+ return entity;
76
+ },
77
+
78
+ async getTask(params) {
79
+ const {
80
+ where
81
+ } = params;
82
+ const keys = {
83
+ PK: createPartitionKey(where),
84
+ SK: "A"
85
+ };
86
+
87
+ try {
88
+ const result = await entity.get(keys);
89
+
90
+ if (!result || !result.Item) {
91
+ return null;
92
+ }
93
+
94
+ return (0, _cleanup.cleanupItem)(entity, result.Item);
95
+ } catch (ex) {
96
+ throw new _error.default(ex.message || "Could not load element by given parameters.", ex.code || "IMPORT_EXPORT_TASK_GET_ERROR", {
97
+ where
98
+ });
99
+ }
100
+ },
101
+
102
+ async listTasks(params) {
103
+ const {
104
+ limit = 100
105
+ } = params;
106
+ const queryAllParams = {
107
+ entity: entity,
108
+ partitionKey: PARENT_TASK_GSI1_PK,
109
+ options: {
110
+ beginsWith: "",
111
+ index: "GSI1",
112
+ limit: limit || undefined
113
+ }
114
+ };
115
+ let results = [];
116
+
117
+ try {
118
+ results = await (0, _query.queryAll)(queryAllParams);
119
+ } catch (ex) {
120
+ throw new _error.default(ex.message || "Could not list import export tasks by given parameters.", ex.code || "IMPORT_EXPORT_TASKS_LIST_ERROR", {
121
+ partitionKey: queryAllParams.partitionKey,
122
+ options: queryAllParams.options
123
+ });
124
+ }
125
+
126
+ const items = results.map(item => (0, _cleanup.cleanupItem)(entity, item)); // TODO: Implement sort and filter
127
+
128
+ return (0, _listResponse.createListResponse)({
129
+ items: items,
130
+ limit,
131
+ totalCount: items.length,
132
+ after: null
133
+ });
134
+ },
135
+
136
+ async createTask(params) {
137
+ const {
138
+ task
139
+ } = params;
140
+ const keys = {
141
+ PK: createPartitionKey({
142
+ tenant: task.tenant,
143
+ locale: task.locale,
144
+ id: task.id
145
+ }),
146
+ SK: "A",
147
+ GSI1_PK: PARENT_TASK_GSI1_PK,
148
+ GSI1_SK: task.createdOn
149
+ };
150
+
151
+ try {
152
+ await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, task), {}, {
153
+ TYPE: createType()
154
+ }, keys));
155
+ return task;
156
+ } catch (ex) {
157
+ throw new _error.default(ex.message || "Could not create importExportTask.", ex.code || "IMPORT_EXPORT_TASK_CREATE_ERROR", {
158
+ keys,
159
+ importExportTask: task
160
+ });
161
+ }
162
+ },
163
+
164
+ async updateTask(params) {
165
+ const {
166
+ task,
167
+ original
168
+ } = params;
169
+ const keys = {
170
+ PK: createPartitionKey({
171
+ tenant: task.tenant,
172
+ locale: task.locale,
173
+ id: task.id
174
+ }),
175
+ SK: "A",
176
+ GSI1_PK: PARENT_TASK_GSI1_PK,
177
+ GSI1_SK: task.createdOn
178
+ };
179
+
180
+ try {
181
+ await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, task), {}, {
182
+ TYPE: createType()
183
+ }, keys));
184
+ return task;
185
+ } catch (ex) {
186
+ throw new _error.default(ex.message || "Could not update importExportTask.", ex.code || "IMPORT_EXPORT_TASK_UPDATE_ERROR", {
187
+ keys,
188
+ original,
189
+ task: task
190
+ });
191
+ }
192
+ },
193
+
194
+ async deleteTask(params) {
195
+ const {
196
+ task
197
+ } = params;
198
+ const keys = {
199
+ PK: createPartitionKey({
200
+ tenant: task.tenant,
201
+ locale: task.locale,
202
+ id: task.id
203
+ }),
204
+ SK: "A"
205
+ };
206
+
207
+ try {
208
+ await entity.delete(keys);
209
+ return task;
210
+ } catch (ex) {
211
+ throw new _error.default(ex.message || "Could not delete importExportTask.", ex.code || "IMPORT_EXPORT_TASK_DELETE_ERROR", {
212
+ keys,
213
+ task: task
214
+ });
215
+ }
216
+ },
217
+
218
+ async updateTaskStats(params) {
219
+ const {
220
+ original,
221
+ input: {
222
+ prevStatus,
223
+ nextStatus
224
+ }
225
+ } = params;
226
+ const keys = {
227
+ PK: createPartitionKey({
228
+ tenant: original.tenant,
229
+ locale: original.locale,
230
+ id: original.id
231
+ }),
232
+ SK: "A",
233
+ GSI1_PK: PARENT_TASK_GSI1_PK,
234
+ GSI1_SK: original.createdOn
235
+ };
236
+
237
+ try {
238
+ await entity.update((0, _objectSpread2.default)((0, _objectSpread2.default)({
239
+ TYPE: createType()
240
+ }, keys), {}, {
241
+ stats: {
242
+ $set: {
243
+ [prevStatus]: {
244
+ $add: -1
245
+ },
246
+ [nextStatus]: {
247
+ $add: 1
248
+ }
249
+ }
250
+ }
251
+ }));
252
+ return original;
253
+ } catch (ex) {
254
+ throw new _error.default(ex.message || "Could not update importExportTask.", ex.code || "IMPORT_EXPORT_TASK_UPDATE_ERROR", {
255
+ keys,
256
+ original
257
+ });
258
+ }
259
+ },
260
+
261
+ async createSubTask(params) {
262
+ const {
263
+ subTask
264
+ } = params;
265
+ const pkParams = {
266
+ tenant: subTask.tenant,
267
+ locale: subTask.locale,
268
+ id: subTask.parent
269
+ };
270
+ const keys = {
271
+ PK: createPartitionKey(pkParams),
272
+ SK: createSortKey(subTask.id),
273
+ GSI1_PK: createGsiPartitionKey(pkParams),
274
+ GSI1_SK: createGsiSortKey(subTask.status, subTask.id)
275
+ };
276
+
277
+ try {
278
+ await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, subTask), {}, {
279
+ TYPE: createType()
280
+ }, keys));
281
+ return subTask;
282
+ } catch (ex) {
283
+ throw new _error.default(ex.message || "Could not create importExportSubTask.", ex.code || "CREATE_IMPORT_EXPORT_SUB_TASK_ERROR", {
284
+ keys,
285
+ subTask: subTask
286
+ });
287
+ }
288
+ },
289
+
290
+ async updateSubTask(params) {
291
+ const {
292
+ subTask,
293
+ original
294
+ } = params;
295
+ const pkParams = {
296
+ tenant: subTask.tenant,
297
+ locale: subTask.locale,
298
+ id: subTask.parent
299
+ };
300
+ const keys = {
301
+ PK: createPartitionKey(pkParams),
302
+ SK: createSortKey(subTask.id),
303
+ GSI1_PK: createGsiPartitionKey(pkParams),
304
+ GSI1_SK: createGsiSortKey(subTask.status, subTask.id)
305
+ };
306
+
307
+ try {
308
+ await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, subTask), {}, {
309
+ TYPE: createType()
310
+ }, keys));
311
+ return subTask;
312
+ } catch (ex) {
313
+ throw new _error.default(ex.message || "Could not update importExportSubTask.", ex.code || "UPDATE_IMPORT_EXPORT_SUB_TASK_ERROR", {
314
+ keys,
315
+ original,
316
+ subTask: subTask
317
+ });
318
+ }
319
+ },
320
+
321
+ async getSubTask(params) {
322
+ const {
323
+ where
324
+ } = params;
325
+ const keys = {
326
+ PK: createPartitionKey({
327
+ tenant: where.tenant,
328
+ locale: where.locale,
329
+ id: where.parent
330
+ }),
331
+ SK: createSortKey(where.id)
332
+ };
333
+
334
+ try {
335
+ const result = await entity.get(keys);
336
+
337
+ if (!result || !result.Item) {
338
+ return null;
339
+ }
340
+
341
+ return (0, _cleanup.cleanupItem)(entity, result.Item);
342
+ } catch (ex) {
343
+ throw new _error.default(ex.message || "Could not load import export subTask by given parameters.", ex.code || "IMPORT_EXPORT_TASK_GET_ERROR", {
344
+ where
345
+ });
346
+ }
347
+ },
348
+
349
+ async listSubTasks(params) {
350
+ const {
351
+ where,
352
+ limit = 100
353
+ } = params;
354
+ const {
355
+ tenant,
356
+ locale,
357
+ parent,
358
+ status
359
+ } = where;
360
+ const queryAllParams = {
361
+ entity: entity,
362
+ partitionKey: createGsiPartitionKey({
363
+ tenant,
364
+ locale,
365
+ id: parent
366
+ }),
367
+ options: {
368
+ beginsWith: `S#${status}`,
369
+ limit: limit || undefined,
370
+ index: "GSI1"
371
+ }
372
+ };
373
+ let results = [];
374
+
375
+ try {
376
+ results = await (0, _query.queryAll)(queryAllParams);
377
+ } catch (ex) {
378
+ throw new _error.default(ex.message || "Could not list import export tasks by given parameters.", ex.code || "LIST_IMPORT_EXPORT_SUB_TASKS_ERROR", {
379
+ partitionKey: queryAllParams.partitionKey,
380
+ options: queryAllParams.options
381
+ });
382
+ }
383
+
384
+ const items = results.map(item => (0, _cleanup.cleanupItem)(entity, item));
385
+ return (0, _listResponse.createListResponse)({
386
+ items: items,
387
+ limit,
388
+ totalCount: items.length,
389
+ after: null
390
+ });
391
+ }
392
+
393
+ };
394
+ };
395
+
396
+ exports.createStorageOperations = createStorageOperations;
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"names":["PARENT_TASK_GSI1_PK","createPartitionKey","tenant","locale","id","createSortKey","input","createGsiPartitionKey","createGsiSortKey","status","createType","createStorageOperations","params","table","tableName","documentClient","attributes","createTable","entity","createImportExportTaskEntity","entityName","getTable","getEntity","getTask","where","keys","PK","SK","result","get","Item","cleanupItem","ex","WebinyError","message","code","listTasks","limit","queryAllParams","partitionKey","options","beginsWith","index","undefined","results","queryAll","items","map","item","createListResponse","totalCount","length","after","createTask","task","GSI1_PK","GSI1_SK","createdOn","put","TYPE","importExportTask","updateTask","original","deleteTask","delete","updateTaskStats","prevStatus","nextStatus","update","stats","$set","$add","createSubTask","subTask","pkParams","parent","updateSubTask","getSubTask","listSubTasks"],"sources":["index.ts"],"sourcesContent":["import {\n ImportExportTask,\n ImportExportTaskStatus,\n ImportExportTaskStorageOperationsCreateParams,\n ImportExportTaskStorageOperationsCreateSubTaskParams,\n ImportExportTaskStorageOperationsDeleteParams,\n ImportExportTaskStorageOperationsGetParams,\n ImportExportTaskStorageOperationsGetSubTaskParams,\n ImportExportTaskStorageOperationsListParams,\n ImportExportTaskStorageOperationsListResponse,\n ImportExportTaskStorageOperationsListSubTaskParams,\n ImportExportTaskStorageOperationsListSubTaskResponse,\n ImportExportTaskStorageOperationsUpdateParams,\n ImportExportTaskStorageOperationsUpdateSubTaskParams,\n ImportExportTaskStorageOperationsUpdateTaskStatsParams\n} from \"@webiny/api-page-builder-import-export/types\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport WebinyError from \"@webiny/error\";\nimport { queryAll, QueryAllParams } from \"@webiny/db-dynamodb/utils/query\";\nimport { createListResponse } from \"@webiny/db-dynamodb/utils/listResponse\";\nimport { createTable } from \"~/definitions/table\";\nimport { createImportExportTaskEntity } from \"~/definitions/importExportTaskEntity\";\nimport { CreateStorageOperations } from \"./types\";\n\ninterface PartitionKeyOptions {\n tenant: string;\n locale: string;\n id?: string;\n}\n\nconst PARENT_TASK_GSI1_PK = \"PB#IE_TASKS\";\n\nconst createPartitionKey = ({ tenant, locale, id }: PartitionKeyOptions): string => {\n return `T#${tenant}#L#${locale}#PB#IE_TASK#${id}`;\n};\n\nconst createSortKey = (input: string): string => {\n return `SUB#${input}`;\n};\n\nconst createGsiPartitionKey = ({ tenant, locale, id }: PartitionKeyOptions): string => {\n return `T#${tenant}#L#${locale}#PB#IE_TASK#${id}`;\n};\n\nconst createGsiSortKey = (status: ImportExportTaskStatus, id: string): string => {\n return `S#${status}#${id}`;\n};\n\nconst createType = (): string => {\n return \"pb.importExportTask\";\n};\n\nexport const createStorageOperations: CreateStorageOperations = params => {\n const { table: tableName, documentClient, attributes = {} } = params;\n\n const table = createTable({ table: tableName, documentClient });\n\n const entity = createImportExportTaskEntity({\n entityName: \"ImportExportTask\",\n table,\n attributes\n });\n\n return {\n getTable() {\n return table;\n },\n getEntity() {\n return entity;\n },\n async getTask(\n params: ImportExportTaskStorageOperationsGetParams\n ): Promise<ImportExportTask | null> {\n const { where } = params;\n\n const keys = {\n PK: createPartitionKey(where),\n SK: \"A\"\n };\n\n try {\n const result = await entity.get(keys);\n if (!result || !result.Item) {\n return null;\n }\n return cleanupItem(entity, result.Item);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not load element by given parameters.\",\n ex.code || \"IMPORT_EXPORT_TASK_GET_ERROR\",\n {\n where\n }\n );\n }\n },\n\n async listTasks(\n params: ImportExportTaskStorageOperationsListParams\n ): Promise<ImportExportTaskStorageOperationsListResponse> {\n const { limit = 100 } = params;\n\n const queryAllParams: QueryAllParams = {\n entity: entity,\n partitionKey: PARENT_TASK_GSI1_PK,\n options: {\n beginsWith: \"\",\n index: \"GSI1\",\n limit: limit || undefined\n }\n };\n\n let results: ImportExportTask[] = [];\n\n try {\n results = await queryAll<ImportExportTask>(queryAllParams);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not list import export tasks by given parameters.\",\n ex.code || \"IMPORT_EXPORT_TASKS_LIST_ERROR\",\n {\n partitionKey: queryAllParams.partitionKey,\n options: queryAllParams.options\n }\n );\n }\n\n const items = results.map(item =>\n cleanupItem<ImportExportTask>(entity, item)\n ) as ImportExportTask[];\n\n // TODO: Implement sort and filter\n\n return createListResponse({\n items: items,\n limit,\n totalCount: items.length,\n after: null\n });\n },\n\n async createTask(\n params: ImportExportTaskStorageOperationsCreateParams\n ): Promise<ImportExportTask> {\n const { task } = params;\n\n const keys = {\n PK: createPartitionKey({\n tenant: task.tenant,\n locale: task.locale,\n id: task.id\n }),\n SK: \"A\",\n GSI1_PK: PARENT_TASK_GSI1_PK,\n GSI1_SK: task.createdOn\n };\n\n try {\n await entity.put({\n ...task,\n TYPE: createType(),\n ...keys\n });\n return task;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create importExportTask.\",\n ex.code || \"IMPORT_EXPORT_TASK_CREATE_ERROR\",\n {\n keys,\n importExportTask: task\n }\n );\n }\n },\n\n async updateTask(\n params: ImportExportTaskStorageOperationsUpdateParams\n ): Promise<ImportExportTask> {\n const { task, original } = params;\n const keys = {\n PK: createPartitionKey({\n tenant: task.tenant,\n locale: task.locale,\n id: task.id\n }),\n SK: \"A\",\n GSI1_PK: PARENT_TASK_GSI1_PK,\n GSI1_SK: task.createdOn\n };\n\n try {\n await entity.put({\n ...task,\n TYPE: createType(),\n ...keys\n });\n return task;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update importExportTask.\",\n ex.code || \"IMPORT_EXPORT_TASK_UPDATE_ERROR\",\n {\n keys,\n original,\n task: task\n }\n );\n }\n },\n\n async deleteTask(\n params: ImportExportTaskStorageOperationsDeleteParams\n ): Promise<ImportExportTask> {\n const { task } = params;\n const keys = {\n PK: createPartitionKey({\n tenant: task.tenant,\n locale: task.locale,\n id: task.id\n }),\n SK: \"A\"\n };\n\n try {\n await entity.delete(keys);\n return task;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete importExportTask.\",\n ex.code || \"IMPORT_EXPORT_TASK_DELETE_ERROR\",\n {\n keys,\n task: task\n }\n );\n }\n },\n\n async updateTaskStats(\n params: ImportExportTaskStorageOperationsUpdateTaskStatsParams\n ): Promise<ImportExportTask> {\n const {\n original,\n input: { prevStatus, nextStatus }\n } = params;\n\n const keys = {\n PK: createPartitionKey({\n tenant: original.tenant,\n locale: original.locale,\n id: original.id\n }),\n SK: \"A\",\n GSI1_PK: PARENT_TASK_GSI1_PK,\n GSI1_SK: original.createdOn\n };\n\n try {\n await entity.update({\n TYPE: createType(),\n ...keys,\n stats: {\n $set: {\n [prevStatus]: { $add: -1 },\n [nextStatus]: { $add: 1 }\n }\n }\n });\n return original;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update importExportTask.\",\n ex.code || \"IMPORT_EXPORT_TASK_UPDATE_ERROR\",\n {\n keys,\n original\n }\n );\n }\n },\n\n async createSubTask(\n params: ImportExportTaskStorageOperationsCreateSubTaskParams\n ): Promise<ImportExportTask> {\n const { subTask } = params;\n const pkParams = {\n tenant: subTask.tenant,\n locale: subTask.locale,\n id: subTask.parent\n };\n const keys = {\n PK: createPartitionKey(pkParams),\n SK: createSortKey(subTask.id),\n GSI1_PK: createGsiPartitionKey(pkParams),\n GSI1_SK: createGsiSortKey(subTask.status, subTask.id)\n };\n\n try {\n await entity.put({\n ...subTask,\n TYPE: createType(),\n ...keys\n });\n return subTask;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create importExportSubTask.\",\n ex.code || \"CREATE_IMPORT_EXPORT_SUB_TASK_ERROR\",\n {\n keys,\n subTask: subTask\n }\n );\n }\n },\n\n async updateSubTask(\n params: ImportExportTaskStorageOperationsUpdateSubTaskParams\n ): Promise<ImportExportTask> {\n const { subTask, original } = params;\n const pkParams = {\n tenant: subTask.tenant,\n locale: subTask.locale,\n id: subTask.parent\n };\n const keys = {\n PK: createPartitionKey(pkParams),\n SK: createSortKey(subTask.id),\n GSI1_PK: createGsiPartitionKey(pkParams),\n GSI1_SK: createGsiSortKey(subTask.status, subTask.id)\n };\n\n try {\n await entity.put({\n ...subTask,\n TYPE: createType(),\n ...keys\n });\n return subTask;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update importExportSubTask.\",\n ex.code || \"UPDATE_IMPORT_EXPORT_SUB_TASK_ERROR\",\n {\n keys,\n original,\n subTask: subTask\n }\n );\n }\n },\n\n async getSubTask(\n params: ImportExportTaskStorageOperationsGetSubTaskParams\n ): Promise<ImportExportTask | null> {\n const { where } = params;\n\n const keys = {\n PK: createPartitionKey({\n tenant: where.tenant,\n locale: where.locale,\n id: where.parent\n }),\n SK: createSortKey(where.id)\n };\n try {\n const result = await entity.get(keys);\n if (!result || !result.Item) {\n return null;\n }\n return cleanupItem(entity, result.Item);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not load import export subTask by given parameters.\",\n ex.code || \"IMPORT_EXPORT_TASK_GET_ERROR\",\n {\n where\n }\n );\n }\n },\n\n async listSubTasks(\n params: ImportExportTaskStorageOperationsListSubTaskParams\n ): Promise<ImportExportTaskStorageOperationsListSubTaskResponse> {\n const { where, limit = 100 } = params;\n\n const { tenant, locale, parent, status } = where;\n const queryAllParams: QueryAllParams = {\n entity: entity,\n partitionKey: createGsiPartitionKey({\n tenant,\n locale,\n id: parent\n }),\n options: {\n beginsWith: `S#${status}`,\n limit: limit || undefined,\n index: \"GSI1\"\n }\n };\n\n let results: ImportExportTask[] = [];\n\n try {\n results = await queryAll<ImportExportTask>(queryAllParams);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not list import export tasks by given parameters.\",\n ex.code || \"LIST_IMPORT_EXPORT_SUB_TASKS_ERROR\",\n {\n partitionKey: queryAllParams.partitionKey,\n options: queryAllParams.options\n }\n );\n }\n\n const items = results.map(item =>\n cleanupItem<ImportExportTask>(entity, item)\n ) as ImportExportTask[];\n\n return createListResponse({\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CL,MADgC;UAEhCC,MAFgC;UAGhCC,EAAE,EAAEuE;QAH4B,CAAD,CAFA;QAOnCnC,OAAO,EAAE;UACLC,UAAU,EAAG,KAAIhC,MAAO,EADnB;UAEL4B,KAAK,EAAEA,KAAK,IAAIM,SAFX;UAGLD,KAAK,EAAE;QAHF;MAP0B,CAAvC;MAcA,IAAIE,OAA2B,GAAG,EAAlC;;MAEA,IAAI;QACAA,OAAO,GAAG,MAAM,IAAAC,eAAA,EAA2BP,cAA3B,CAAhB;MACH,CAFD,CAEE,OAAON,EAAP,EAAW;QACT,MAAM,IAAIC,cAAJ,CACFD,EAAE,CAACE,OAAH,IAAc,yDADZ,EAEFF,EAAE,CAACG,IAAH,IAAW,oCAFT,EAGF;UACII,YAAY,EAAED,cAAc,CAACC,YADjC;UAEIC,OAAO,EAAEF,cAAc,CAACE;QAF5B,CAHE,CAAN;MAQH;;MAED,MAAMM,KAAK,GAAGF,OAAO,CAACG,GAAR,CAAYC,IAAI,IAC1B,IAAAjB,oBAAA,EAA8Bb,MAA9B,EAAsC8B,IAAtC,CADU,CAAd;MAIA,OAAO,IAAAC,gCAAA,EAAmB;QACtBH,KAAK,EAAEA,KADe;QAEtBT,KAFsB;QAGtBa,UAAU,EAAEJ,KAAK,CAACK,MAHI;QAItBC,KAAK,EAAE;MAJe,CAAnB,CAAP;IAMH;;EA7WE,CAAP;AA+WH,CA1XM"}
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@webiny/api-page-builder-import-export-so-ddb",
3
+ "version": "0.0.0-ee-vpcs.549378cf03",
4
+ "main": "index.js",
5
+ "keywords": [
6
+ "@webiny/api-page-builder-import-export",
7
+ "storage-operations",
8
+ "dynamodb",
9
+ "pbie:ddb"
10
+ ],
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "https://github.com/webiny/webiny-js.git",
14
+ "directory": "packages/api-page-builder-import-export-so-ddb"
15
+ },
16
+ "author": "Webiny Ltd",
17
+ "description": "The DynamoDB storage operations for import export feature in the Webiny Page Builder API.",
18
+ "license": "MIT",
19
+ "dependencies": {
20
+ "@babel/runtime": "7.19.0",
21
+ "@webiny/api-page-builder-import-export": "0.0.0-ee-vpcs.549378cf03",
22
+ "@webiny/db-dynamodb": "0.0.0-ee-vpcs.549378cf03",
23
+ "@webiny/error": "0.0.0-ee-vpcs.549378cf03",
24
+ "dynamodb-toolbox": "0.3.5"
25
+ },
26
+ "devDependencies": {
27
+ "@babel/cli": "^7.19.3",
28
+ "@babel/core": "^7.19.3",
29
+ "@babel/preset-env": "^7.19.4",
30
+ "@babel/preset-typescript": "^7.18.6",
31
+ "@webiny/api-security": "^0.0.0-ee-vpcs.549378cf03",
32
+ "@webiny/api-tenancy": "^0.0.0-ee-vpcs.549378cf03",
33
+ "@webiny/cli": "^0.0.0-ee-vpcs.549378cf03",
34
+ "@webiny/handler-aws": "^0.0.0-ee-vpcs.549378cf03",
35
+ "@webiny/handler-graphql": "^0.0.0-ee-vpcs.549378cf03",
36
+ "@webiny/project-utils": "^0.0.0-ee-vpcs.549378cf03",
37
+ "jest": "^28.1.0",
38
+ "jest-dynalite": "^3.2.0",
39
+ "jest-environment-node": "^27.0.6",
40
+ "rimraf": "^3.0.2",
41
+ "ttypescript": "^1.5.12",
42
+ "typescript": "4.7.4"
43
+ },
44
+ "publishConfig": {
45
+ "access": "public",
46
+ "directory": "dist"
47
+ },
48
+ "scripts": {
49
+ "build": "yarn webiny run build",
50
+ "watch": "yarn webiny run watch"
51
+ },
52
+ "gitHead": "549378cf03fcd27845fc3fa23d1dc6b32896f630"
53
+ }
package/types.d.ts ADDED
@@ -0,0 +1,13 @@
1
+ import { DynamoDBTypes } from "dynamodb-toolbox/dist/classes/Table";
2
+ import { EntityAttributeConfig, EntityCompositeAttributes } from "dynamodb-toolbox/dist/classes/Entity";
3
+ import { DocumentClient } from "aws-sdk/clients/dynamodb";
4
+ import { ImportExportTaskStorageOperations } from "@webiny/api-page-builder-import-export/types";
5
+ export declare type AttributeDefinition = DynamoDBTypes | EntityAttributeConfig | EntityCompositeAttributes;
6
+ export declare type Attributes = Record<string, AttributeDefinition>;
7
+ export interface CreateStorageOperations {
8
+ (params: {
9
+ documentClient: DocumentClient;
10
+ table?: string;
11
+ attributes?: Attributes;
12
+ }): ImportExportTaskStorageOperations;
13
+ }
package/types.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
package/types.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import { DynamoDBTypes } from \"dynamodb-toolbox/dist/classes/Table\";\nimport {\n EntityAttributeConfig,\n EntityCompositeAttributes\n} from \"dynamodb-toolbox/dist/classes/Entity\";\nimport { DocumentClient } from \"aws-sdk/clients/dynamodb\";\nimport { ImportExportTaskStorageOperations } from \"@webiny/api-page-builder-import-export/types\";\n\nexport type AttributeDefinition = DynamoDBTypes | EntityAttributeConfig | EntityCompositeAttributes;\n\nexport type Attributes = Record<string, AttributeDefinition>;\n\nexport interface CreateStorageOperations {\n (params: {\n documentClient: DocumentClient;\n table?: string;\n attributes?: Attributes;\n }): ImportExportTaskStorageOperations;\n}\n"],"mappings":""}