@webiny/api-page-builder-import-export-so-ddb 0.0.0-mt-2 → 0.0.0-unstable.1145e7667f
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/importExportTaskEntity.js +75 -0
- package/definitions/importExportTaskEntity.js.map +1 -0
- package/definitions/table.d.ts +4 -3
- package/definitions/table.js.map +1 -0
- package/index.js +72 -76
- package/index.js.map +1 -0
- package/package.json +19 -20
- package/types.d.ts +2 -7
- package/types.js.map +1 -0
- package/definitions/pageImportExportTaskEntity.js +0 -79
|
@@ -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 {};
|
|
@@ -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"}
|
package/definitions/table.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Table } from "dynamodb-toolbox";
|
|
2
2
|
import { DocumentClient } from "aws-sdk/clients/dynamodb";
|
|
3
|
-
|
|
4
|
-
table
|
|
3
|
+
interface CreateTableParams {
|
|
4
|
+
table?: string;
|
|
5
5
|
documentClient: DocumentClient;
|
|
6
6
|
}
|
|
7
|
-
export declare const createTable: ({ table, documentClient }:
|
|
7
|
+
export declare const createTable: ({ table, documentClient }: CreateTableParams) => Table;
|
|
8
|
+
export {};
|
|
@@ -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.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.createStorageOperations = void 0;
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
11
|
|
|
12
12
|
var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
|
|
13
13
|
|
|
@@ -19,13 +19,38 @@ var _listResponse = require("@webiny/db-dynamodb/utils/listResponse");
|
|
|
19
19
|
|
|
20
20
|
var _table = require("./definitions/table");
|
|
21
21
|
|
|
22
|
-
var
|
|
22
|
+
var _importExportTaskEntity = require("./definitions/importExportTaskEntity");
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
const PARENT_TASK_GSI1_PK = "PB#IE_TASKS";
|
|
25
25
|
|
|
26
|
-
|
|
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
|
+
};
|
|
27
53
|
|
|
28
|
-
// @ts-ignore
|
|
29
54
|
const createStorageOperations = params => {
|
|
30
55
|
const {
|
|
31
56
|
table: tableName,
|
|
@@ -36,12 +61,11 @@ const createStorageOperations = params => {
|
|
|
36
61
|
table: tableName,
|
|
37
62
|
documentClient
|
|
38
63
|
});
|
|
39
|
-
const entity = (0,
|
|
40
|
-
entityName: "
|
|
64
|
+
const entity = (0, _importExportTaskEntity.createImportExportTaskEntity)({
|
|
65
|
+
entityName: "ImportExportTask",
|
|
41
66
|
table,
|
|
42
67
|
attributes
|
|
43
68
|
});
|
|
44
|
-
const PARENT_TASK_GSI1_PK = "PB#IE_TASKS";
|
|
45
69
|
return {
|
|
46
70
|
getTable() {
|
|
47
71
|
return table;
|
|
@@ -51,40 +75,12 @@ const createStorageOperations = params => {
|
|
|
51
75
|
return entity;
|
|
52
76
|
},
|
|
53
77
|
|
|
54
|
-
createPartitionKey({
|
|
55
|
-
tenant,
|
|
56
|
-
locale,
|
|
57
|
-
id
|
|
58
|
-
}) {
|
|
59
|
-
return `T#${tenant}#L#${locale}#PB#IE_TASK#${id}`;
|
|
60
|
-
},
|
|
61
|
-
|
|
62
|
-
createSortKey(input) {
|
|
63
|
-
return `SUB#${input}`;
|
|
64
|
-
},
|
|
65
|
-
|
|
66
|
-
createGsiPartitionKey({
|
|
67
|
-
tenant,
|
|
68
|
-
locale,
|
|
69
|
-
id
|
|
70
|
-
}) {
|
|
71
|
-
return `T#${tenant}#L#${locale}#PB#IE_TASK#${id}`;
|
|
72
|
-
},
|
|
73
|
-
|
|
74
|
-
createGsiSortKey(status, id) {
|
|
75
|
-
return `S#${status}#${id}`;
|
|
76
|
-
},
|
|
77
|
-
|
|
78
|
-
createType() {
|
|
79
|
-
return "pb.pageImportExportTask";
|
|
80
|
-
},
|
|
81
|
-
|
|
82
78
|
async getTask(params) {
|
|
83
79
|
const {
|
|
84
80
|
where
|
|
85
81
|
} = params;
|
|
86
82
|
const keys = {
|
|
87
|
-
PK:
|
|
83
|
+
PK: createPartitionKey(where),
|
|
88
84
|
SK: "A"
|
|
89
85
|
};
|
|
90
86
|
|
|
@@ -97,7 +93,7 @@ const createStorageOperations = params => {
|
|
|
97
93
|
|
|
98
94
|
return (0, _cleanup.cleanupItem)(entity, result.Item);
|
|
99
95
|
} catch (ex) {
|
|
100
|
-
throw new _error.default(ex.message || "Could not load
|
|
96
|
+
throw new _error.default(ex.message || "Could not load element by given parameters.", ex.code || "IMPORT_EXPORT_TASK_GET_ERROR", {
|
|
101
97
|
where
|
|
102
98
|
});
|
|
103
99
|
}
|
|
@@ -105,7 +101,7 @@ const createStorageOperations = params => {
|
|
|
105
101
|
|
|
106
102
|
async listTasks(params) {
|
|
107
103
|
const {
|
|
108
|
-
limit
|
|
104
|
+
limit = 100
|
|
109
105
|
} = params;
|
|
110
106
|
const queryAllParams = {
|
|
111
107
|
entity: entity,
|
|
@@ -121,7 +117,7 @@ const createStorageOperations = params => {
|
|
|
121
117
|
try {
|
|
122
118
|
results = await (0, _query.queryAll)(queryAllParams);
|
|
123
119
|
} catch (ex) {
|
|
124
|
-
throw new _error.default(ex.message || "Could not list
|
|
120
|
+
throw new _error.default(ex.message || "Could not list import export tasks by given parameters.", ex.code || "IMPORT_EXPORT_TASKS_LIST_ERROR", {
|
|
125
121
|
partitionKey: queryAllParams.partitionKey,
|
|
126
122
|
options: queryAllParams.options
|
|
127
123
|
});
|
|
@@ -142,7 +138,7 @@ const createStorageOperations = params => {
|
|
|
142
138
|
task
|
|
143
139
|
} = params;
|
|
144
140
|
const keys = {
|
|
145
|
-
PK:
|
|
141
|
+
PK: createPartitionKey({
|
|
146
142
|
tenant: task.tenant,
|
|
147
143
|
locale: task.locale,
|
|
148
144
|
id: task.id
|
|
@@ -153,14 +149,14 @@ const createStorageOperations = params => {
|
|
|
153
149
|
};
|
|
154
150
|
|
|
155
151
|
try {
|
|
156
|
-
await entity.put(
|
|
157
|
-
TYPE:
|
|
152
|
+
await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, task), {}, {
|
|
153
|
+
TYPE: createType()
|
|
158
154
|
}, keys));
|
|
159
155
|
return task;
|
|
160
156
|
} catch (ex) {
|
|
161
|
-
throw new _error.default(ex.message || "Could not create
|
|
157
|
+
throw new _error.default(ex.message || "Could not create importExportTask.", ex.code || "IMPORT_EXPORT_TASK_CREATE_ERROR", {
|
|
162
158
|
keys,
|
|
163
|
-
|
|
159
|
+
importExportTask: task
|
|
164
160
|
});
|
|
165
161
|
}
|
|
166
162
|
},
|
|
@@ -171,7 +167,7 @@ const createStorageOperations = params => {
|
|
|
171
167
|
original
|
|
172
168
|
} = params;
|
|
173
169
|
const keys = {
|
|
174
|
-
PK:
|
|
170
|
+
PK: createPartitionKey({
|
|
175
171
|
tenant: task.tenant,
|
|
176
172
|
locale: task.locale,
|
|
177
173
|
id: task.id
|
|
@@ -182,12 +178,12 @@ const createStorageOperations = params => {
|
|
|
182
178
|
};
|
|
183
179
|
|
|
184
180
|
try {
|
|
185
|
-
await entity.put(
|
|
186
|
-
TYPE:
|
|
181
|
+
await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, task), {}, {
|
|
182
|
+
TYPE: createType()
|
|
187
183
|
}, keys));
|
|
188
184
|
return task;
|
|
189
185
|
} catch (ex) {
|
|
190
|
-
throw new _error.default(ex.message || "Could not update
|
|
186
|
+
throw new _error.default(ex.message || "Could not update importExportTask.", ex.code || "IMPORT_EXPORT_TASK_UPDATE_ERROR", {
|
|
191
187
|
keys,
|
|
192
188
|
original,
|
|
193
189
|
task: task
|
|
@@ -200,7 +196,7 @@ const createStorageOperations = params => {
|
|
|
200
196
|
task
|
|
201
197
|
} = params;
|
|
202
198
|
const keys = {
|
|
203
|
-
PK:
|
|
199
|
+
PK: createPartitionKey({
|
|
204
200
|
tenant: task.tenant,
|
|
205
201
|
locale: task.locale,
|
|
206
202
|
id: task.id
|
|
@@ -212,7 +208,7 @@ const createStorageOperations = params => {
|
|
|
212
208
|
await entity.delete(keys);
|
|
213
209
|
return task;
|
|
214
210
|
} catch (ex) {
|
|
215
|
-
throw new _error.default(ex.message || "Could not delete
|
|
211
|
+
throw new _error.default(ex.message || "Could not delete importExportTask.", ex.code || "IMPORT_EXPORT_TASK_DELETE_ERROR", {
|
|
216
212
|
keys,
|
|
217
213
|
task: task
|
|
218
214
|
});
|
|
@@ -228,7 +224,7 @@ const createStorageOperations = params => {
|
|
|
228
224
|
}
|
|
229
225
|
} = params;
|
|
230
226
|
const keys = {
|
|
231
|
-
PK:
|
|
227
|
+
PK: createPartitionKey({
|
|
232
228
|
tenant: original.tenant,
|
|
233
229
|
locale: original.locale,
|
|
234
230
|
id: original.id
|
|
@@ -239,8 +235,8 @@ const createStorageOperations = params => {
|
|
|
239
235
|
};
|
|
240
236
|
|
|
241
237
|
try {
|
|
242
|
-
await entity.update(
|
|
243
|
-
TYPE:
|
|
238
|
+
await entity.update((0, _objectSpread2.default)((0, _objectSpread2.default)({
|
|
239
|
+
TYPE: createType()
|
|
244
240
|
}, keys), {}, {
|
|
245
241
|
stats: {
|
|
246
242
|
$set: {
|
|
@@ -255,7 +251,7 @@ const createStorageOperations = params => {
|
|
|
255
251
|
}));
|
|
256
252
|
return original;
|
|
257
253
|
} catch (ex) {
|
|
258
|
-
throw new _error.default(ex.message || "Could not update
|
|
254
|
+
throw new _error.default(ex.message || "Could not update importExportTask.", ex.code || "IMPORT_EXPORT_TASK_UPDATE_ERROR", {
|
|
259
255
|
keys,
|
|
260
256
|
original
|
|
261
257
|
});
|
|
@@ -272,19 +268,19 @@ const createStorageOperations = params => {
|
|
|
272
268
|
id: subTask.parent
|
|
273
269
|
};
|
|
274
270
|
const keys = {
|
|
275
|
-
PK:
|
|
276
|
-
SK:
|
|
277
|
-
GSI1_PK:
|
|
278
|
-
GSI1_SK:
|
|
271
|
+
PK: createPartitionKey(pkParams),
|
|
272
|
+
SK: createSortKey(subTask.id),
|
|
273
|
+
GSI1_PK: createGsiPartitionKey(pkParams),
|
|
274
|
+
GSI1_SK: createGsiSortKey(subTask.status, subTask.id)
|
|
279
275
|
};
|
|
280
276
|
|
|
281
277
|
try {
|
|
282
|
-
await entity.put(
|
|
283
|
-
TYPE:
|
|
278
|
+
await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, subTask), {}, {
|
|
279
|
+
TYPE: createType()
|
|
284
280
|
}, keys));
|
|
285
281
|
return subTask;
|
|
286
282
|
} catch (ex) {
|
|
287
|
-
throw new _error.default(ex.message || "Could not create
|
|
283
|
+
throw new _error.default(ex.message || "Could not create importExportSubTask.", ex.code || "CREATE_IMPORT_EXPORT_SUB_TASK_ERROR", {
|
|
288
284
|
keys,
|
|
289
285
|
subTask: subTask
|
|
290
286
|
});
|
|
@@ -302,19 +298,19 @@ const createStorageOperations = params => {
|
|
|
302
298
|
id: subTask.parent
|
|
303
299
|
};
|
|
304
300
|
const keys = {
|
|
305
|
-
PK:
|
|
306
|
-
SK:
|
|
307
|
-
GSI1_PK:
|
|
308
|
-
GSI1_SK:
|
|
301
|
+
PK: createPartitionKey(pkParams),
|
|
302
|
+
SK: createSortKey(subTask.id),
|
|
303
|
+
GSI1_PK: createGsiPartitionKey(pkParams),
|
|
304
|
+
GSI1_SK: createGsiSortKey(subTask.status, subTask.id)
|
|
309
305
|
};
|
|
310
306
|
|
|
311
307
|
try {
|
|
312
|
-
await entity.put(
|
|
313
|
-
TYPE:
|
|
308
|
+
await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, subTask), {}, {
|
|
309
|
+
TYPE: createType()
|
|
314
310
|
}, keys));
|
|
315
311
|
return subTask;
|
|
316
312
|
} catch (ex) {
|
|
317
|
-
throw new _error.default(ex.message || "Could not update
|
|
313
|
+
throw new _error.default(ex.message || "Could not update importExportSubTask.", ex.code || "UPDATE_IMPORT_EXPORT_SUB_TASK_ERROR", {
|
|
318
314
|
keys,
|
|
319
315
|
original,
|
|
320
316
|
subTask: subTask
|
|
@@ -327,12 +323,12 @@ const createStorageOperations = params => {
|
|
|
327
323
|
where
|
|
328
324
|
} = params;
|
|
329
325
|
const keys = {
|
|
330
|
-
PK:
|
|
326
|
+
PK: createPartitionKey({
|
|
331
327
|
tenant: where.tenant,
|
|
332
328
|
locale: where.locale,
|
|
333
329
|
id: where.parent
|
|
334
330
|
}),
|
|
335
|
-
SK:
|
|
331
|
+
SK: createSortKey(where.id)
|
|
336
332
|
};
|
|
337
333
|
|
|
338
334
|
try {
|
|
@@ -344,7 +340,7 @@ const createStorageOperations = params => {
|
|
|
344
340
|
|
|
345
341
|
return (0, _cleanup.cleanupItem)(entity, result.Item);
|
|
346
342
|
} catch (ex) {
|
|
347
|
-
throw new _error.default(ex.message || "Could not load
|
|
343
|
+
throw new _error.default(ex.message || "Could not load import export subTask by given parameters.", ex.code || "IMPORT_EXPORT_TASK_GET_ERROR", {
|
|
348
344
|
where
|
|
349
345
|
});
|
|
350
346
|
}
|
|
@@ -353,7 +349,7 @@ const createStorageOperations = params => {
|
|
|
353
349
|
async listSubTasks(params) {
|
|
354
350
|
const {
|
|
355
351
|
where,
|
|
356
|
-
limit
|
|
352
|
+
limit = 100
|
|
357
353
|
} = params;
|
|
358
354
|
const {
|
|
359
355
|
tenant,
|
|
@@ -363,7 +359,7 @@ const createStorageOperations = params => {
|
|
|
363
359
|
} = where;
|
|
364
360
|
const queryAllParams = {
|
|
365
361
|
entity: entity,
|
|
366
|
-
partitionKey:
|
|
362
|
+
partitionKey: createGsiPartitionKey({
|
|
367
363
|
tenant,
|
|
368
364
|
locale,
|
|
369
365
|
id: parent
|
|
@@ -379,7 +375,7 @@ const createStorageOperations = params => {
|
|
|
379
375
|
try {
|
|
380
376
|
results = await (0, _query.queryAll)(queryAllParams);
|
|
381
377
|
} catch (ex) {
|
|
382
|
-
throw new _error.default(ex.message || "Could not list
|
|
378
|
+
throw new _error.default(ex.message || "Could not list import export tasks by given parameters.", ex.code || "LIST_IMPORT_EXPORT_SUB_TASKS_ERROR", {
|
|
383
379
|
partitionKey: queryAllParams.partitionKey,
|
|
384
380
|
options: queryAllParams.options
|
|
385
381
|
});
|
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({\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,EAAiCL,EAAjC,KAAwD;EAC7E,OAAQ,KAAIK,MAAO,IAAGL,EAAG,EAAzB;AACH,CAFD;;AAIA,MAAMM,UAAU,GAAG,MAAc;EAC7B,OAAO,qBAAP;AACH,CAFD;;AAIO,MAAMC,uBAAgD,GAAGC,MAAM,IAAI;EACtE,MAAM;IAAEC,KAAK,EAAEC,SAAT;IAAoBC,cAApB;IAAoCC,UAAU,GAAG;EAAjD,IAAwDJ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|
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-
|
|
3
|
+
"version": "0.0.0-unstable.1145e7667f",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"@webiny/api-page-builder-import-export",
|
|
@@ -17,30 +17,29 @@
|
|
|
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-
|
|
22
|
-
"@webiny/db-dynamodb": "0.0.0-
|
|
23
|
-
"@webiny/error": "0.0.0-
|
|
24
|
-
"dynamodb-toolbox": "0.3.
|
|
20
|
+
"@babel/runtime": "7.20.13",
|
|
21
|
+
"@webiny/api-page-builder-import-export": "0.0.0-unstable.1145e7667f",
|
|
22
|
+
"@webiny/db-dynamodb": "0.0.0-unstable.1145e7667f",
|
|
23
|
+
"@webiny/error": "0.0.0-unstable.1145e7667f",
|
|
24
|
+
"dynamodb-toolbox": "0.3.5"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@babel/cli": "^7.
|
|
28
|
-
"@babel/core": "^7.
|
|
29
|
-
"@babel/preset-env": "^7.
|
|
30
|
-
"@babel/preset-typescript": "^7.
|
|
31
|
-
"@webiny/api-security": "^0.0.0-
|
|
32
|
-
"@webiny/api-tenancy": "^0.0.0-
|
|
33
|
-
"@webiny/cli": "^0.0.0-
|
|
34
|
-
"@webiny/handler": "^0.0.0-
|
|
35
|
-
"@webiny/handler-
|
|
36
|
-
"@webiny/
|
|
37
|
-
"
|
|
38
|
-
"jest": "^26.6.3",
|
|
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-unstable.1145e7667f",
|
|
32
|
+
"@webiny/api-tenancy": "^0.0.0-unstable.1145e7667f",
|
|
33
|
+
"@webiny/cli": "^0.0.0-unstable.1145e7667f",
|
|
34
|
+
"@webiny/handler-aws": "^0.0.0-unstable.1145e7667f",
|
|
35
|
+
"@webiny/handler-graphql": "^0.0.0-unstable.1145e7667f",
|
|
36
|
+
"@webiny/project-utils": "^0.0.0-unstable.1145e7667f",
|
|
37
|
+
"jest": "^28.1.0",
|
|
39
38
|
"jest-dynalite": "^3.2.0",
|
|
40
39
|
"jest-environment-node": "^27.0.6",
|
|
41
40
|
"rimraf": "^3.0.2",
|
|
42
41
|
"ttypescript": "^1.5.12",
|
|
43
|
-
"typescript": "
|
|
42
|
+
"typescript": "4.7.4"
|
|
44
43
|
},
|
|
45
44
|
"publishConfig": {
|
|
46
45
|
"access": "public",
|
|
@@ -50,5 +49,5 @@
|
|
|
50
49
|
"build": "yarn webiny run build",
|
|
51
50
|
"watch": "yarn webiny run watch"
|
|
52
51
|
},
|
|
53
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "1145e7667ffd3d18bfea1e73d6078cd6a35c1038"
|
|
54
53
|
}
|
package/types.d.ts
CHANGED
|
@@ -1,18 +1,13 @@
|
|
|
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
|
-
export interface PartitionKeyOptions {
|
|
8
|
-
tenant: string;
|
|
9
|
-
locale: string;
|
|
10
|
-
id?: string;
|
|
11
|
-
}
|
|
12
7
|
export interface CreateStorageOperations {
|
|
13
8
|
(params: {
|
|
14
9
|
documentClient: DocumentClient;
|
|
15
10
|
table?: string;
|
|
16
11
|
attributes?: Attributes;
|
|
17
|
-
}):
|
|
12
|
+
}): ImportExportTaskStorageOperations;
|
|
18
13
|
}
|
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":""}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.createPageImportExportTaskEntity = void 0;
|
|
9
|
-
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
|
-
var _dynamodbToolbox = require("dynamodb-toolbox");
|
|
13
|
-
|
|
14
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
15
|
-
|
|
16
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
17
|
-
|
|
18
|
-
const createPageImportExportTaskEntity = ({
|
|
19
|
-
entityName,
|
|
20
|
-
table,
|
|
21
|
-
attributes
|
|
22
|
-
}) => {
|
|
23
|
-
return new _dynamodbToolbox.Entity({
|
|
24
|
-
name: entityName,
|
|
25
|
-
table,
|
|
26
|
-
attributes: _objectSpread({
|
|
27
|
-
PK: {
|
|
28
|
-
partitionKey: true
|
|
29
|
-
},
|
|
30
|
-
SK: {
|
|
31
|
-
sortKey: true
|
|
32
|
-
},
|
|
33
|
-
GSI1_PK: {
|
|
34
|
-
type: "string"
|
|
35
|
-
},
|
|
36
|
-
GSI1_SK: {
|
|
37
|
-
type: "string"
|
|
38
|
-
},
|
|
39
|
-
TYPE: {
|
|
40
|
-
type: "string"
|
|
41
|
-
},
|
|
42
|
-
id: {
|
|
43
|
-
type: "string"
|
|
44
|
-
},
|
|
45
|
-
parent: {
|
|
46
|
-
type: "string"
|
|
47
|
-
},
|
|
48
|
-
status: {
|
|
49
|
-
type: "string"
|
|
50
|
-
},
|
|
51
|
-
data: {
|
|
52
|
-
type: "map"
|
|
53
|
-
},
|
|
54
|
-
input: {
|
|
55
|
-
type: "map"
|
|
56
|
-
},
|
|
57
|
-
stats: {
|
|
58
|
-
type: "map"
|
|
59
|
-
},
|
|
60
|
-
error: {
|
|
61
|
-
type: "map"
|
|
62
|
-
},
|
|
63
|
-
createdOn: {
|
|
64
|
-
type: "string"
|
|
65
|
-
},
|
|
66
|
-
createdBy: {
|
|
67
|
-
type: "map"
|
|
68
|
-
},
|
|
69
|
-
tenant: {
|
|
70
|
-
type: "string"
|
|
71
|
-
},
|
|
72
|
-
locale: {
|
|
73
|
-
type: "string"
|
|
74
|
-
}
|
|
75
|
-
}, attributes)
|
|
76
|
-
});
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
exports.createPageImportExportTaskEntity = createPageImportExportTaskEntity;
|