@webiny/api-page-builder-import-export-so-ddb 0.0.0-unstable.78f581c1d2 → 0.0.0-unstable.7f63ea0744
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/definitions/{pageImportExportTaskEntity.d.ts → importExportTaskEntity.d.ts} +1 -1
- package/definitions/{pageImportExportTaskEntity.js → importExportTaskEntity.js} +3 -8
- package/definitions/importExportTaskEntity.js.map +1 -0
- package/definitions/table.js +0 -3
- package/definitions/table.js.map +1 -1
- package/index.js +17 -59
- package/index.js.map +1 -1
- package/package.json +12 -12
- package/types.d.ts +2 -2
- package/types.js.map +1 -1
- package/definitions/pageImportExportTaskEntity.js.map +0 -1
|
@@ -5,5 +5,5 @@ interface Params {
|
|
|
5
5
|
table: Table;
|
|
6
6
|
attributes?: Attributes;
|
|
7
7
|
}
|
|
8
|
-
export declare const
|
|
8
|
+
export declare const createImportExportTaskEntity: ({ entityName, table, attributes }: Params) => Entity<{}>;
|
|
9
9
|
export {};
|
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
|
-
exports.
|
|
9
|
-
|
|
7
|
+
exports.createImportExportTaskEntity = void 0;
|
|
10
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
-
|
|
12
9
|
var _dynamodbToolbox = require("dynamodb-toolbox");
|
|
13
|
-
|
|
14
|
-
const createPageImportExportTaskEntity = ({
|
|
10
|
+
const createImportExportTaskEntity = ({
|
|
15
11
|
entityName,
|
|
16
12
|
table,
|
|
17
13
|
attributes
|
|
@@ -71,5 +67,4 @@ const createPageImportExportTaskEntity = ({
|
|
|
71
67
|
}, attributes)
|
|
72
68
|
});
|
|
73
69
|
};
|
|
74
|
-
|
|
75
|
-
exports.createPageImportExportTaskEntity = createPageImportExportTaskEntity;
|
|
70
|
+
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,UAAU;EAAEC,KAAK;EAAEC;AAAmB,CAAC,KAAK;EACvF,OAAO,IAAIC,uBAAM,CAAC;IACdC,IAAI,EAAEJ,UAAU;IAChBC,KAAK;IACLC,UAAU;MACNG,EAAE,EAAE;QACAC,YAAY,EAAE;MAClB,CAAC;MACDC,EAAE,EAAE;QACAC,OAAO,EAAE;MACb,CAAC;MACDC,OAAO,EAAE;QACLC,IAAI,EAAE;MACV,CAAC;MACDC,OAAO,EAAE;QACLD,IAAI,EAAE;MACV,CAAC;MACDE,IAAI,EAAE;QACFF,IAAI,EAAE;MACV,CAAC;MACDG,EAAE,EAAE;QACAH,IAAI,EAAE;MACV,CAAC;MACDI,MAAM,EAAE;QACJJ,IAAI,EAAE;MACV,CAAC;MACDK,MAAM,EAAE;QACJL,IAAI,EAAE;MACV,CAAC;MACDM,IAAI,EAAE;QACFN,IAAI,EAAE;MACV,CAAC;MACDO,KAAK,EAAE;QACHP,IAAI,EAAE;MACV,CAAC;MACDQ,KAAK,EAAE;QACHR,IAAI,EAAE;MACV,CAAC;MACDS,KAAK,EAAE;QACHT,IAAI,EAAE;MACV,CAAC;MACDU,SAAS,EAAE;QACPV,IAAI,EAAE;MACV,CAAC;MACDW,SAAS,EAAE;QACPX,IAAI,EAAE;MACV,CAAC;MACDY,MAAM,EAAE;QACJZ,IAAI,EAAE;MACV,CAAC;MACDa,MAAM,EAAE;QACJb,IAAI,EAAE;MACV;IAAC,GACER,UAAU;EAErB,CAAC,CAAC;AACN,CAAC;AAAC"}
|
package/definitions/table.js
CHANGED
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.createTable = void 0;
|
|
7
|
-
|
|
8
7
|
var _dynamodbToolbox = require("dynamodb-toolbox");
|
|
9
|
-
|
|
10
8
|
const createTable = ({
|
|
11
9
|
table,
|
|
12
10
|
documentClient
|
|
@@ -24,5 +22,4 @@ const createTable = ({
|
|
|
24
22
|
}
|
|
25
23
|
});
|
|
26
24
|
};
|
|
27
|
-
|
|
28
25
|
exports.createTable = createTable;
|
package/definitions/table.js.map
CHANGED
|
@@ -1 +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":"
|
|
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,KAAK;EAAEC;AAAkC,CAAC,KAAK;EACzE,OAAO,IAAIC,sBAAK,CAAC;IACbC,IAAI,EAAEH,KAAK,IAAII,OAAO,CAACC,GAAG,CAACC,qBAAqB,IAAKF,OAAO,CAACC,GAAG,CAACE,QAAmB;IACpFC,YAAY,EAAE,IAAI;IAClBC,OAAO,EAAE,IAAI;IACbC,cAAc,EAAET,cAAc;IAC9BU,OAAO,EAAE;MACLC,IAAI,EAAE;QACFJ,YAAY,EAAE,SAAS;QACvBC,OAAO,EAAE;MACb;IACJ;EACJ,CAAC,CAAC;AACN,CAAC;AAAC"}
|
package/index.js
CHANGED
|
@@ -1,28 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.createStorageOperations = void 0;
|
|
9
|
-
|
|
10
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
-
|
|
12
9
|
var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
|
|
13
|
-
|
|
14
10
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
15
|
-
|
|
16
11
|
var _query = require("@webiny/db-dynamodb/utils/query");
|
|
17
|
-
|
|
18
12
|
var _listResponse = require("@webiny/db-dynamodb/utils/listResponse");
|
|
19
|
-
|
|
20
13
|
var _table = require("./definitions/table");
|
|
21
|
-
|
|
22
|
-
var _pageImportExportTaskEntity = require("./definitions/pageImportExportTaskEntity");
|
|
23
|
-
|
|
14
|
+
var _importExportTaskEntity = require("./definitions/importExportTaskEntity");
|
|
24
15
|
const PARENT_TASK_GSI1_PK = "PB#IE_TASKS";
|
|
25
|
-
|
|
26
16
|
const createPartitionKey = ({
|
|
27
17
|
tenant,
|
|
28
18
|
locale,
|
|
@@ -30,11 +20,9 @@ const createPartitionKey = ({
|
|
|
30
20
|
}) => {
|
|
31
21
|
return `T#${tenant}#L#${locale}#PB#IE_TASK#${id}`;
|
|
32
22
|
};
|
|
33
|
-
|
|
34
23
|
const createSortKey = input => {
|
|
35
24
|
return `SUB#${input}`;
|
|
36
25
|
};
|
|
37
|
-
|
|
38
26
|
const createGsiPartitionKey = ({
|
|
39
27
|
tenant,
|
|
40
28
|
locale,
|
|
@@ -42,15 +30,12 @@ const createGsiPartitionKey = ({
|
|
|
42
30
|
}) => {
|
|
43
31
|
return `T#${tenant}#L#${locale}#PB#IE_TASK#${id}`;
|
|
44
32
|
};
|
|
45
|
-
|
|
46
33
|
const createGsiSortKey = (status, id) => {
|
|
47
34
|
return `S#${status}#${id}`;
|
|
48
35
|
};
|
|
49
|
-
|
|
50
36
|
const createType = () => {
|
|
51
|
-
return "pb.
|
|
37
|
+
return "pb.importExportTask";
|
|
52
38
|
};
|
|
53
|
-
|
|
54
39
|
const createStorageOperations = params => {
|
|
55
40
|
const {
|
|
56
41
|
table: tableName,
|
|
@@ -61,8 +46,8 @@ const createStorageOperations = params => {
|
|
|
61
46
|
table: tableName,
|
|
62
47
|
documentClient
|
|
63
48
|
});
|
|
64
|
-
const entity = (0,
|
|
65
|
-
entityName: "
|
|
49
|
+
const entity = (0, _importExportTaskEntity.createImportExportTaskEntity)({
|
|
50
|
+
entityName: "ImportExportTask",
|
|
66
51
|
table,
|
|
67
52
|
attributes
|
|
68
53
|
});
|
|
@@ -70,11 +55,9 @@ const createStorageOperations = params => {
|
|
|
70
55
|
getTable() {
|
|
71
56
|
return table;
|
|
72
57
|
},
|
|
73
|
-
|
|
74
58
|
getEntity() {
|
|
75
59
|
return entity;
|
|
76
60
|
},
|
|
77
|
-
|
|
78
61
|
async getTask(params) {
|
|
79
62
|
const {
|
|
80
63
|
where
|
|
@@ -83,22 +66,18 @@ const createStorageOperations = params => {
|
|
|
83
66
|
PK: createPartitionKey(where),
|
|
84
67
|
SK: "A"
|
|
85
68
|
};
|
|
86
|
-
|
|
87
69
|
try {
|
|
88
70
|
const result = await entity.get(keys);
|
|
89
|
-
|
|
90
71
|
if (!result || !result.Item) {
|
|
91
72
|
return null;
|
|
92
73
|
}
|
|
93
|
-
|
|
94
74
|
return (0, _cleanup.cleanupItem)(entity, result.Item);
|
|
95
75
|
} catch (ex) {
|
|
96
|
-
throw new _error.default(ex.message || "Could not load
|
|
76
|
+
throw new _error.default(ex.message || "Could not load element by given parameters.", ex.code || "IMPORT_EXPORT_TASK_GET_ERROR", {
|
|
97
77
|
where
|
|
98
78
|
});
|
|
99
79
|
}
|
|
100
80
|
},
|
|
101
|
-
|
|
102
81
|
async listTasks(params) {
|
|
103
82
|
const {
|
|
104
83
|
limit = 100
|
|
@@ -113,17 +92,17 @@ const createStorageOperations = params => {
|
|
|
113
92
|
}
|
|
114
93
|
};
|
|
115
94
|
let results = [];
|
|
116
|
-
|
|
117
95
|
try {
|
|
118
96
|
results = await (0, _query.queryAll)(queryAllParams);
|
|
119
97
|
} catch (ex) {
|
|
120
|
-
throw new _error.default(ex.message || "Could not list
|
|
98
|
+
throw new _error.default(ex.message || "Could not list import export tasks by given parameters.", ex.code || "IMPORT_EXPORT_TASKS_LIST_ERROR", {
|
|
121
99
|
partitionKey: queryAllParams.partitionKey,
|
|
122
100
|
options: queryAllParams.options
|
|
123
101
|
});
|
|
124
102
|
}
|
|
103
|
+
const items = results.map(item => (0, _cleanup.cleanupItem)(entity, item));
|
|
125
104
|
|
|
126
|
-
|
|
105
|
+
// TODO: Implement sort and filter
|
|
127
106
|
|
|
128
107
|
return (0, _listResponse.createListResponse)({
|
|
129
108
|
items: items,
|
|
@@ -132,7 +111,6 @@ const createStorageOperations = params => {
|
|
|
132
111
|
after: null
|
|
133
112
|
});
|
|
134
113
|
},
|
|
135
|
-
|
|
136
114
|
async createTask(params) {
|
|
137
115
|
const {
|
|
138
116
|
task
|
|
@@ -147,20 +125,18 @@ const createStorageOperations = params => {
|
|
|
147
125
|
GSI1_PK: PARENT_TASK_GSI1_PK,
|
|
148
126
|
GSI1_SK: task.createdOn
|
|
149
127
|
};
|
|
150
|
-
|
|
151
128
|
try {
|
|
152
129
|
await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, task), {}, {
|
|
153
130
|
TYPE: createType()
|
|
154
131
|
}, keys));
|
|
155
132
|
return task;
|
|
156
133
|
} catch (ex) {
|
|
157
|
-
throw new _error.default(ex.message || "Could not create
|
|
134
|
+
throw new _error.default(ex.message || "Could not create importExportTask.", ex.code || "IMPORT_EXPORT_TASK_CREATE_ERROR", {
|
|
158
135
|
keys,
|
|
159
|
-
|
|
136
|
+
importExportTask: task
|
|
160
137
|
});
|
|
161
138
|
}
|
|
162
139
|
},
|
|
163
|
-
|
|
164
140
|
async updateTask(params) {
|
|
165
141
|
const {
|
|
166
142
|
task,
|
|
@@ -176,21 +152,19 @@ const createStorageOperations = params => {
|
|
|
176
152
|
GSI1_PK: PARENT_TASK_GSI1_PK,
|
|
177
153
|
GSI1_SK: task.createdOn
|
|
178
154
|
};
|
|
179
|
-
|
|
180
155
|
try {
|
|
181
156
|
await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, task), {}, {
|
|
182
157
|
TYPE: createType()
|
|
183
158
|
}, keys));
|
|
184
159
|
return task;
|
|
185
160
|
} catch (ex) {
|
|
186
|
-
throw new _error.default(ex.message || "Could not update
|
|
161
|
+
throw new _error.default(ex.message || "Could not update importExportTask.", ex.code || "IMPORT_EXPORT_TASK_UPDATE_ERROR", {
|
|
187
162
|
keys,
|
|
188
163
|
original,
|
|
189
164
|
task: task
|
|
190
165
|
});
|
|
191
166
|
}
|
|
192
167
|
},
|
|
193
|
-
|
|
194
168
|
async deleteTask(params) {
|
|
195
169
|
const {
|
|
196
170
|
task
|
|
@@ -203,18 +177,16 @@ const createStorageOperations = params => {
|
|
|
203
177
|
}),
|
|
204
178
|
SK: "A"
|
|
205
179
|
};
|
|
206
|
-
|
|
207
180
|
try {
|
|
208
181
|
await entity.delete(keys);
|
|
209
182
|
return task;
|
|
210
183
|
} catch (ex) {
|
|
211
|
-
throw new _error.default(ex.message || "Could not delete
|
|
184
|
+
throw new _error.default(ex.message || "Could not delete importExportTask.", ex.code || "IMPORT_EXPORT_TASK_DELETE_ERROR", {
|
|
212
185
|
keys,
|
|
213
186
|
task: task
|
|
214
187
|
});
|
|
215
188
|
}
|
|
216
189
|
},
|
|
217
|
-
|
|
218
190
|
async updateTaskStats(params) {
|
|
219
191
|
const {
|
|
220
192
|
original,
|
|
@@ -233,7 +205,6 @@ const createStorageOperations = params => {
|
|
|
233
205
|
GSI1_PK: PARENT_TASK_GSI1_PK,
|
|
234
206
|
GSI1_SK: original.createdOn
|
|
235
207
|
};
|
|
236
|
-
|
|
237
208
|
try {
|
|
238
209
|
await entity.update((0, _objectSpread2.default)((0, _objectSpread2.default)({
|
|
239
210
|
TYPE: createType()
|
|
@@ -251,13 +222,12 @@ const createStorageOperations = params => {
|
|
|
251
222
|
}));
|
|
252
223
|
return original;
|
|
253
224
|
} catch (ex) {
|
|
254
|
-
throw new _error.default(ex.message || "Could not update
|
|
225
|
+
throw new _error.default(ex.message || "Could not update importExportTask.", ex.code || "IMPORT_EXPORT_TASK_UPDATE_ERROR", {
|
|
255
226
|
keys,
|
|
256
227
|
original
|
|
257
228
|
});
|
|
258
229
|
}
|
|
259
230
|
},
|
|
260
|
-
|
|
261
231
|
async createSubTask(params) {
|
|
262
232
|
const {
|
|
263
233
|
subTask
|
|
@@ -273,20 +243,18 @@ const createStorageOperations = params => {
|
|
|
273
243
|
GSI1_PK: createGsiPartitionKey(pkParams),
|
|
274
244
|
GSI1_SK: createGsiSortKey(subTask.status, subTask.id)
|
|
275
245
|
};
|
|
276
|
-
|
|
277
246
|
try {
|
|
278
247
|
await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, subTask), {}, {
|
|
279
248
|
TYPE: createType()
|
|
280
249
|
}, keys));
|
|
281
250
|
return subTask;
|
|
282
251
|
} catch (ex) {
|
|
283
|
-
throw new _error.default(ex.message || "Could not create
|
|
252
|
+
throw new _error.default(ex.message || "Could not create importExportSubTask.", ex.code || "CREATE_IMPORT_EXPORT_SUB_TASK_ERROR", {
|
|
284
253
|
keys,
|
|
285
254
|
subTask: subTask
|
|
286
255
|
});
|
|
287
256
|
}
|
|
288
257
|
},
|
|
289
|
-
|
|
290
258
|
async updateSubTask(params) {
|
|
291
259
|
const {
|
|
292
260
|
subTask,
|
|
@@ -303,21 +271,19 @@ const createStorageOperations = params => {
|
|
|
303
271
|
GSI1_PK: createGsiPartitionKey(pkParams),
|
|
304
272
|
GSI1_SK: createGsiSortKey(subTask.status, subTask.id)
|
|
305
273
|
};
|
|
306
|
-
|
|
307
274
|
try {
|
|
308
275
|
await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, subTask), {}, {
|
|
309
276
|
TYPE: createType()
|
|
310
277
|
}, keys));
|
|
311
278
|
return subTask;
|
|
312
279
|
} catch (ex) {
|
|
313
|
-
throw new _error.default(ex.message || "Could not update
|
|
280
|
+
throw new _error.default(ex.message || "Could not update importExportSubTask.", ex.code || "UPDATE_IMPORT_EXPORT_SUB_TASK_ERROR", {
|
|
314
281
|
keys,
|
|
315
282
|
original,
|
|
316
283
|
subTask: subTask
|
|
317
284
|
});
|
|
318
285
|
}
|
|
319
286
|
},
|
|
320
|
-
|
|
321
287
|
async getSubTask(params) {
|
|
322
288
|
const {
|
|
323
289
|
where
|
|
@@ -330,22 +296,18 @@ const createStorageOperations = params => {
|
|
|
330
296
|
}),
|
|
331
297
|
SK: createSortKey(where.id)
|
|
332
298
|
};
|
|
333
|
-
|
|
334
299
|
try {
|
|
335
300
|
const result = await entity.get(keys);
|
|
336
|
-
|
|
337
301
|
if (!result || !result.Item) {
|
|
338
302
|
return null;
|
|
339
303
|
}
|
|
340
|
-
|
|
341
304
|
return (0, _cleanup.cleanupItem)(entity, result.Item);
|
|
342
305
|
} catch (ex) {
|
|
343
|
-
throw new _error.default(ex.message || "Could not load
|
|
306
|
+
throw new _error.default(ex.message || "Could not load import export subTask by given parameters.", ex.code || "IMPORT_EXPORT_TASK_GET_ERROR", {
|
|
344
307
|
where
|
|
345
308
|
});
|
|
346
309
|
}
|
|
347
310
|
},
|
|
348
|
-
|
|
349
311
|
async listSubTasks(params) {
|
|
350
312
|
const {
|
|
351
313
|
where,
|
|
@@ -371,16 +333,14 @@ const createStorageOperations = params => {
|
|
|
371
333
|
}
|
|
372
334
|
};
|
|
373
335
|
let results = [];
|
|
374
|
-
|
|
375
336
|
try {
|
|
376
337
|
results = await (0, _query.queryAll)(queryAllParams);
|
|
377
338
|
} catch (ex) {
|
|
378
|
-
throw new _error.default(ex.message || "Could not list
|
|
339
|
+
throw new _error.default(ex.message || "Could not list import export tasks by given parameters.", ex.code || "LIST_IMPORT_EXPORT_SUB_TASKS_ERROR", {
|
|
379
340
|
partitionKey: queryAllParams.partitionKey,
|
|
380
341
|
options: queryAllParams.options
|
|
381
342
|
});
|
|
382
343
|
}
|
|
383
|
-
|
|
384
344
|
const items = results.map(item => (0, _cleanup.cleanupItem)(entity, item));
|
|
385
345
|
return (0, _listResponse.createListResponse)({
|
|
386
346
|
items: items,
|
|
@@ -389,8 +349,6 @@ const createStorageOperations = params => {
|
|
|
389
349
|
after: null
|
|
390
350
|
});
|
|
391
351
|
}
|
|
392
|
-
|
|
393
352
|
};
|
|
394
353
|
};
|
|
395
|
-
|
|
396
354
|
exports.createStorageOperations = createStorageOperations;
|
package/index.js.map
CHANGED
|
@@ -1 +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","createPageImportExportTaskEntity","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","pageImportExportTask","updateTask","original","deleteTask","delete","updateTaskStats","prevStatus","nextStatus","update","stats","$set","$add","createSubTask","subTask","pkParams","parent","updateSubTask","getSubTask","listSubTasks"],"sources":["index.ts"],"sourcesContent":["import {\n PageImportExportTask,\n PageImportExportTaskStatus,\n PageImportExportTaskStorageOperationsCreateParams,\n PageImportExportTaskStorageOperationsCreateSubTaskParams,\n PageImportExportTaskStorageOperationsDeleteParams,\n PageImportExportTaskStorageOperationsGetParams,\n PageImportExportTaskStorageOperationsGetSubTaskParams,\n PageImportExportTaskStorageOperationsListParams,\n PageImportExportTaskStorageOperationsListResponse,\n PageImportExportTaskStorageOperationsListSubTaskParams,\n PageImportExportTaskStorageOperationsListSubTaskResponse,\n PageImportExportTaskStorageOperationsUpdateParams,\n PageImportExportTaskStorageOperationsUpdateSubTaskParams,\n PageImportExportTaskStorageOperationsUpdateTaskStatsParams\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 { createPageImportExportTaskEntity } from \"~/definitions/pageImportExportTaskEntity\";\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: PageImportExportTaskStatus, id: string): string => {\n return `S#${status}#${id}`;\n};\n\nconst createType = (): string => {\n return \"pb.pageImportExportTask\";\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 = createPageImportExportTaskEntity({\n entityName: \"PageImportExportTask\",\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: PageImportExportTaskStorageOperationsGetParams\n ): Promise<PageImportExportTask | 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 page element by given parameters.\",\n ex.code || \"PAGE_IMPORT_EXPORT_TASK_GET_ERROR\",\n {\n where\n }\n );\n }\n },\n\n async listTasks(\n params: PageImportExportTaskStorageOperationsListParams\n ): Promise<PageImportExportTaskStorageOperationsListResponse> {\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: PageImportExportTask[] = [];\n\n try {\n results = await queryAll<PageImportExportTask>(queryAllParams);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not list page import export tasks by given parameters.\",\n ex.code || \"PAGE_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<PageImportExportTask>(entity, item)\n ) as PageImportExportTask[];\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: PageImportExportTaskStorageOperationsCreateParams\n ): Promise<PageImportExportTask> {\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 pageImportExportTask.\",\n ex.code || \"PAGE_IMPORT_EXPORT_TASK_CREATE_ERROR\",\n {\n keys,\n pageImportExportTask: task\n }\n );\n }\n },\n\n async updateTask(\n params: PageImportExportTaskStorageOperationsUpdateParams\n ): Promise<PageImportExportTask> {\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 pageImportExportTask.\",\n ex.code || \"PAGE_IMPORT_EXPORT_TASK_UPDATE_ERROR\",\n {\n keys,\n original,\n task: task\n }\n );\n }\n },\n\n async deleteTask(\n params: PageImportExportTaskStorageOperationsDeleteParams\n ): Promise<PageImportExportTask> {\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 pageImportExportTask.\",\n ex.code || \"PAGE_IMPORT_EXPORT_TASK_DELETE_ERROR\",\n {\n keys,\n task: task\n }\n );\n }\n },\n\n async updateTaskStats(\n params: PageImportExportTaskStorageOperationsUpdateTaskStatsParams\n ): Promise<PageImportExportTask> {\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 pageImportExportTask.\",\n ex.code || \"PAGE_IMPORT_EXPORT_TASK_UPDATE_ERROR\",\n {\n keys,\n original\n }\n );\n }\n },\n\n async createSubTask(\n params: PageImportExportTaskStorageOperationsCreateSubTaskParams\n ): Promise<PageImportExportTask> {\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 pageImportExportSubTask.\",\n ex.code || \"CREATE_PAGE_IMPORT_EXPORT_SUB_TASK_ERROR\",\n {\n keys,\n subTask: subTask\n }\n );\n }\n },\n\n async updateSubTask(\n params: PageImportExportTaskStorageOperationsUpdateSubTaskParams\n ): Promise<PageImportExportTask> {\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 pageImportExportSubTask.\",\n ex.code || \"UPDATE_PAGE_IMPORT_EXPORT_SUB_TASK_ERROR\",\n {\n keys,\n original,\n subTask: subTask\n }\n );\n }\n },\n\n async getSubTask(\n params: PageImportExportTaskStorageOperationsGetSubTaskParams\n ): Promise<PageImportExportTask | 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 page import export subTask by given parameters.\",\n ex.code || \"PAGE_IMPORT_EXPORT_TASK_GET_ERROR\",\n {\n where\n }\n );\n }\n },\n\n async listSubTasks(\n params: PageImportExportTaskStorageOperationsListSubTaskParams\n ): Promise<PageImportExportTaskStorageOperationsListSubTaskResponse> {\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: PageImportExportTask[] = [];\n\n try {\n results = await queryAll<PageImportExportTask>(queryAllParams);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not list page import export tasks by given parameters.\",\n ex.code || \"LIST_PAGE_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<PageImportExportTask>(entity, item)\n ) as PageImportExportTask[];\n\n return createListResponse({\n items: items,\n limit,\n totalCount: items.length,\n after: null\n });\n }\n };\n};\n"],"mappings":";;;;;;;;;;;AAgBA;;AACA;;AACA;;AACA;;AACA;;AACA;;AASA,MAAMA,mBAAmB,GAAG,aAA5B;;AAEA,MAAMC,kBAAkB,GAAG,CAAC;EAAEC,MAAF;EAAUC,MAAV;EAAkBC;AAAlB,CAAD,KAAyD;EAChF,OAAQ,KAAIF,MAAO,MAAKC,MAAO,eAAcC,EAAG,EAAhD;AACH,CAFD;;AAIA,MAAMC,aAAa,GAAIC,KAAD,IAA2B;EAC7C,OAAQ,OAAMA,KAAM,EAApB;AACH,CAFD;;AAIA,MAAMC,qBAAqB,GAAG,CAAC;EAAEL,MAAF;EAAUC,MAAV;EAAkBC;AAAlB,CAAD,KAAyD;EACnF,OAAQ,KAAIF,MAAO,MAAKC,MAAO,eAAcC,EAAG,EAAhD;AACH,CAFD;;AAIA,MAAMI,gBAAgB,GAAG,CAACC,MAAD,EAAqC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R,CAAYC,IAAI,IAC1B,IAAAjB,oBAAA,EAAkCb,MAAlC,EAA0C8B,IAA1C,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"}
|
|
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({\n items: items,\n limit,\n totalCount: items.length,\n after: null\n });\n }\n };\n};\n"],"mappings":";;;;;;;;AAgBA;AACA;AACA;AACA;AACA;AACA;AASA,MAAMA,mBAAmB,GAAG,aAAa;AAEzC,MAAMC,kBAAkB,GAAG,CAAC;EAAEC,MAAM;EAAEC,MAAM;EAAEC;AAAwB,CAAC,KAAa;EAChF,OAAQ,KAAIF,MAAO,MAAKC,MAAO,eAAcC,EAAG,EAAC;AACrD,CAAC;AAED,MAAMC,aAAa,GAAIC,KAAa,IAAa;EAC7C,OAAQ,OAAMA,KAAM,EAAC;AACzB,CAAC;AAED,MAAMC,qBAAqB,GAAG,CAAC;EAAEL,MAAM;EAAEC,MAAM;EAAEC;AAAwB,CAAC,KAAa;EACnF,OAAQ,KAAIF,MAAO,MAAKC,MAAO,eAAcC,EAAG,EAAC;AACrD,CAAC;AAED,MAAMI,gBAAgB,GAAG,CAACC,MAA8B,EAAEL,EAAU,KAAa;EAC7E,OAAQ,KAAIK,MAAO,IAAGL,EAAG,EAAC;AAC9B,CAAC;AAED,MAAMM,UAAU,GAAG,MAAc;EAC7B,OAAO,qBAAqB;AAChC,CAAC;AAEM,MAAMC,uBAAgD,GAAGC,MAAM,IAAI;EACtE,MAAM;IAAEC,KAAK,EAAEC,SAAS;IAAEC,cAAc;IAAEC,UAAU,GAAG,CAAC;EAAE,CAAC,GAAGJ,MAAM;EAEpE,MAAMC,KAAK,GAAG,IAAAI,kBAAW,EAAC;IAAEJ,KAAK,EAAEC,SAAS;IAAEC;EAAe,CAAC,CAAC;EAE/D,MAAMG,MAAM,GAAG,IAAAC,oDAA4B,EAAC;IACxCC,UAAU,EAAE,kBAAkB;IAC9BP,KAAK;IACLG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AAC,GAAGe,KAAK;MAChD,MAAMc,cAA8B,GAAG;QACnCpB,MAAM,EAAEA,MAAM;QACdqB,YAAY,EAAEhC,qBAAqB,CAAC;UAChCL,MAAM;UACNC,MAAM;UACNC,EAAE,EAAEuE;QACR,CAAC,CAAC;QACFnC,OAAO,EAAE;UACLC,UAAU,EAAG,KAAIhC,MAAO,EAAC;UACzB4B,KAAK,EAAEA,KAAK,IAAIM,SAAS;UACzBD,KAAK,EAAE;QACX;MACJ,CAAC;MAED,IAAIE,OAA2B,GAAG,EAAE;MAEpC,IAAI;QACAA,OAAO,GAAG,MAAM,IAAAC,eAAQ,EAAmBP,cAAc,CAAC;MAC9D,CAAC,CAAC,OAAON,EAAE,EAAE;QACT,MAAM,IAAIC,cAAW,CACjBD,EAAE,CAACE,OAAO,IAAI,yDAAyD,EACvEF,EAAE,CAACG,IAAI,IAAI,oCAAoC,EAC/C;UACII,YAAY,EAAED,cAAc,CAACC,YAAY;UACzCC,OAAO,EAAEF,cAAc,CAACE;QAC5B,CAAC,CACJ;MACL;MAEA,MAAMM,KAAK,GAAGF,OAAO,CAACG,GAAG,CAACC,IAAI,IAC1B,IAAAjB,oBAAW,EAAmBb,MAAM,EAAE8B,IAAI,CAAC,CACxB;MAEvB,OAAO,IAAAC,gCAAkB,EAAC;QACtBH,KAAK,EAAEA,KAAK;QACZT,KAAK;QACLa,UAAU,EAAEJ,KAAK,CAACK,MAAM;QACxBC,KAAK,EAAE;MACX,CAAC,CAAC;IACN;EACJ,CAAC;AACL,CAAC;AAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-page-builder-import-export-so-ddb",
|
|
3
|
-
"version": "0.0.0-unstable.
|
|
3
|
+
"version": "0.0.0-unstable.7f63ea0744",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"@webiny/api-page-builder-import-export",
|
|
@@ -17,10 +17,10 @@
|
|
|
17
17
|
"description": "The DynamoDB storage operations for import export feature in the Webiny Page Builder API.",
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@babel/runtime": "7.
|
|
21
|
-
"@webiny/api-page-builder-import-export": "0.0.0-unstable.
|
|
22
|
-
"@webiny/db-dynamodb": "0.0.0-unstable.
|
|
23
|
-
"@webiny/error": "0.0.0-unstable.
|
|
20
|
+
"@babel/runtime": "7.20.13",
|
|
21
|
+
"@webiny/api-page-builder-import-export": "0.0.0-unstable.7f63ea0744",
|
|
22
|
+
"@webiny/db-dynamodb": "0.0.0-unstable.7f63ea0744",
|
|
23
|
+
"@webiny/error": "0.0.0-unstable.7f63ea0744",
|
|
24
24
|
"dynamodb-toolbox": "0.3.5"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
@@ -28,12 +28,12 @@
|
|
|
28
28
|
"@babel/core": "^7.19.3",
|
|
29
29
|
"@babel/preset-env": "^7.19.4",
|
|
30
30
|
"@babel/preset-typescript": "^7.18.6",
|
|
31
|
-
"@webiny/api-security": "^0.0.0-unstable.
|
|
32
|
-
"@webiny/api-tenancy": "^0.0.0-unstable.
|
|
33
|
-
"@webiny/cli": "^0.0.0-unstable.
|
|
34
|
-
"@webiny/handler-aws": "^0.0.0-unstable.
|
|
35
|
-
"@webiny/handler-graphql": "^0.0.0-unstable.
|
|
36
|
-
"@webiny/project-utils": "^0.0.0-unstable.
|
|
31
|
+
"@webiny/api-security": "^0.0.0-unstable.7f63ea0744",
|
|
32
|
+
"@webiny/api-tenancy": "^0.0.0-unstable.7f63ea0744",
|
|
33
|
+
"@webiny/cli": "^0.0.0-unstable.7f63ea0744",
|
|
34
|
+
"@webiny/handler-aws": "^0.0.0-unstable.7f63ea0744",
|
|
35
|
+
"@webiny/handler-graphql": "^0.0.0-unstable.7f63ea0744",
|
|
36
|
+
"@webiny/project-utils": "^0.0.0-unstable.7f63ea0744",
|
|
37
37
|
"jest": "^28.1.0",
|
|
38
38
|
"jest-dynalite": "^3.2.0",
|
|
39
39
|
"jest-environment-node": "^27.0.6",
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"build": "yarn webiny run build",
|
|
50
50
|
"watch": "yarn webiny run watch"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "7f63ea0744c9e31977e5dabb95538d22b4db585c"
|
|
53
53
|
}
|
package/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DynamoDBTypes } from "dynamodb-toolbox/dist/classes/Table";
|
|
2
2
|
import { EntityAttributeConfig, EntityCompositeAttributes } from "dynamodb-toolbox/dist/classes/Entity";
|
|
3
3
|
import { DocumentClient } from "aws-sdk/clients/dynamodb";
|
|
4
|
-
import {
|
|
4
|
+
import { ImportExportTaskStorageOperations } from "@webiny/api-page-builder-import-export/types";
|
|
5
5
|
export declare type AttributeDefinition = DynamoDBTypes | EntityAttributeConfig | EntityCompositeAttributes;
|
|
6
6
|
export declare type Attributes = Record<string, AttributeDefinition>;
|
|
7
7
|
export interface CreateStorageOperations {
|
|
@@ -9,5 +9,5 @@ export interface CreateStorageOperations {
|
|
|
9
9
|
documentClient: DocumentClient;
|
|
10
10
|
table?: string;
|
|
11
11
|
attributes?: Attributes;
|
|
12
|
-
}):
|
|
12
|
+
}): ImportExportTaskStorageOperations;
|
|
13
13
|
}
|
package/types.js.map
CHANGED
|
@@ -1 +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 {
|
|
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":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["createPageImportExportTaskEntity","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":["pageImportExportTaskEntity.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 createPageImportExportTaskEntity = ({ 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,gCAAgC,GAAG,CAAC;EAAEC,UAAF;EAAcC,KAAd;EAAqBC;AAArB,CAAD,KAA+C;EAC3F,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"}
|