@webiny/api-page-builder-import-export-so-ddb 0.0.0-mt-3 → 0.0.0-unstable.085ff6572f
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 +70 -0
- package/definitions/importExportTaskEntity.js.map +1 -0
- package/definitions/table.d.ts +4 -3
- package/definitions/table.js +0 -3
- package/definitions/table.js.map +1 -0
- package/index.js +70 -116
- package/index.js.map +1 -0
- package/package.json +23 -24
- 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,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.createImportExportTaskEntity = void 0;
|
|
8
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
+
var _dynamodbToolbox = require("dynamodb-toolbox");
|
|
10
|
+
const createImportExportTaskEntity = ({
|
|
11
|
+
entityName,
|
|
12
|
+
table,
|
|
13
|
+
attributes
|
|
14
|
+
}) => {
|
|
15
|
+
return new _dynamodbToolbox.Entity({
|
|
16
|
+
name: entityName,
|
|
17
|
+
table,
|
|
18
|
+
attributes: (0, _objectSpread2.default)({
|
|
19
|
+
PK: {
|
|
20
|
+
partitionKey: true
|
|
21
|
+
},
|
|
22
|
+
SK: {
|
|
23
|
+
sortKey: true
|
|
24
|
+
},
|
|
25
|
+
GSI1_PK: {
|
|
26
|
+
type: "string"
|
|
27
|
+
},
|
|
28
|
+
GSI1_SK: {
|
|
29
|
+
type: "string"
|
|
30
|
+
},
|
|
31
|
+
TYPE: {
|
|
32
|
+
type: "string"
|
|
33
|
+
},
|
|
34
|
+
id: {
|
|
35
|
+
type: "string"
|
|
36
|
+
},
|
|
37
|
+
parent: {
|
|
38
|
+
type: "string"
|
|
39
|
+
},
|
|
40
|
+
status: {
|
|
41
|
+
type: "string"
|
|
42
|
+
},
|
|
43
|
+
data: {
|
|
44
|
+
type: "map"
|
|
45
|
+
},
|
|
46
|
+
input: {
|
|
47
|
+
type: "map"
|
|
48
|
+
},
|
|
49
|
+
stats: {
|
|
50
|
+
type: "map"
|
|
51
|
+
},
|
|
52
|
+
error: {
|
|
53
|
+
type: "map"
|
|
54
|
+
},
|
|
55
|
+
createdOn: {
|
|
56
|
+
type: "string"
|
|
57
|
+
},
|
|
58
|
+
createdBy: {
|
|
59
|
+
type: "map"
|
|
60
|
+
},
|
|
61
|
+
tenant: {
|
|
62
|
+
type: "string"
|
|
63
|
+
},
|
|
64
|
+
locale: {
|
|
65
|
+
type: "string"
|
|
66
|
+
}
|
|
67
|
+
}, attributes)
|
|
68
|
+
});
|
|
69
|
+
};
|
|
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.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 {};
|
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;
|
|
@@ -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,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,31 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.createStorageOperations = void 0;
|
|
9
|
-
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
8
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
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
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
14
|
+
var _importExportTaskEntity = require("./definitions/importExportTaskEntity");
|
|
15
|
+
const PARENT_TASK_GSI1_PK = "PB#IE_TASKS";
|
|
16
|
+
const createPartitionKey = ({
|
|
17
|
+
tenant,
|
|
18
|
+
locale,
|
|
19
|
+
id
|
|
20
|
+
}) => {
|
|
21
|
+
return `T#${tenant}#L#${locale}#PB#IE_TASK#${id}`;
|
|
22
|
+
};
|
|
23
|
+
const createSortKey = input => {
|
|
24
|
+
return `SUB#${input}`;
|
|
25
|
+
};
|
|
26
|
+
const createGsiPartitionKey = ({
|
|
27
|
+
tenant,
|
|
28
|
+
locale,
|
|
29
|
+
id
|
|
30
|
+
}) => {
|
|
31
|
+
return `T#${tenant}#L#${locale}#PB#IE_TASK#${id}`;
|
|
32
|
+
};
|
|
33
|
+
const createGsiSortKey = (status, id) => {
|
|
34
|
+
return `S#${status}#${id}`;
|
|
35
|
+
};
|
|
36
|
+
const createType = () => {
|
|
37
|
+
return "pb.importExportTask";
|
|
38
|
+
};
|
|
29
39
|
const createStorageOperations = params => {
|
|
30
40
|
const {
|
|
31
41
|
table: tableName,
|
|
@@ -36,76 +46,41 @@ const createStorageOperations = params => {
|
|
|
36
46
|
table: tableName,
|
|
37
47
|
documentClient
|
|
38
48
|
});
|
|
39
|
-
const entity = (0,
|
|
40
|
-
entityName: "
|
|
49
|
+
const entity = (0, _importExportTaskEntity.createImportExportTaskEntity)({
|
|
50
|
+
entityName: "ImportExportTask",
|
|
41
51
|
table,
|
|
42
52
|
attributes
|
|
43
53
|
});
|
|
44
|
-
const PARENT_TASK_GSI1_PK = "PB#IE_TASKS";
|
|
45
54
|
return {
|
|
46
55
|
getTable() {
|
|
47
56
|
return table;
|
|
48
57
|
},
|
|
49
|
-
|
|
50
58
|
getEntity() {
|
|
51
59
|
return entity;
|
|
52
60
|
},
|
|
53
|
-
|
|
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
61
|
async getTask(params) {
|
|
83
62
|
const {
|
|
84
63
|
where
|
|
85
64
|
} = params;
|
|
86
65
|
const keys = {
|
|
87
|
-
PK:
|
|
66
|
+
PK: createPartitionKey(where),
|
|
88
67
|
SK: "A"
|
|
89
68
|
};
|
|
90
|
-
|
|
91
69
|
try {
|
|
92
70
|
const result = await entity.get(keys);
|
|
93
|
-
|
|
94
71
|
if (!result || !result.Item) {
|
|
95
72
|
return null;
|
|
96
73
|
}
|
|
97
|
-
|
|
98
74
|
return (0, _cleanup.cleanupItem)(entity, result.Item);
|
|
99
75
|
} catch (ex) {
|
|
100
|
-
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", {
|
|
101
77
|
where
|
|
102
78
|
});
|
|
103
79
|
}
|
|
104
80
|
},
|
|
105
|
-
|
|
106
81
|
async listTasks(params) {
|
|
107
82
|
const {
|
|
108
|
-
limit
|
|
83
|
+
limit = 100
|
|
109
84
|
} = params;
|
|
110
85
|
const queryAllParams = {
|
|
111
86
|
entity: entity,
|
|
@@ -117,17 +92,17 @@ const createStorageOperations = params => {
|
|
|
117
92
|
}
|
|
118
93
|
};
|
|
119
94
|
let results = [];
|
|
120
|
-
|
|
121
95
|
try {
|
|
122
96
|
results = await (0, _query.queryAll)(queryAllParams);
|
|
123
97
|
} catch (ex) {
|
|
124
|
-
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", {
|
|
125
99
|
partitionKey: queryAllParams.partitionKey,
|
|
126
100
|
options: queryAllParams.options
|
|
127
101
|
});
|
|
128
102
|
}
|
|
103
|
+
const items = results.map(item => (0, _cleanup.cleanupItem)(entity, item));
|
|
129
104
|
|
|
130
|
-
|
|
105
|
+
// TODO: Implement sort and filter
|
|
131
106
|
|
|
132
107
|
return (0, _listResponse.createListResponse)({
|
|
133
108
|
items: items,
|
|
@@ -136,13 +111,12 @@ const createStorageOperations = params => {
|
|
|
136
111
|
after: null
|
|
137
112
|
});
|
|
138
113
|
},
|
|
139
|
-
|
|
140
114
|
async createTask(params) {
|
|
141
115
|
const {
|
|
142
116
|
task
|
|
143
117
|
} = params;
|
|
144
118
|
const keys = {
|
|
145
|
-
PK:
|
|
119
|
+
PK: createPartitionKey({
|
|
146
120
|
tenant: task.tenant,
|
|
147
121
|
locale: task.locale,
|
|
148
122
|
id: task.id
|
|
@@ -151,27 +125,25 @@ const createStorageOperations = params => {
|
|
|
151
125
|
GSI1_PK: PARENT_TASK_GSI1_PK,
|
|
152
126
|
GSI1_SK: task.createdOn
|
|
153
127
|
};
|
|
154
|
-
|
|
155
128
|
try {
|
|
156
|
-
await entity.put(
|
|
157
|
-
TYPE:
|
|
129
|
+
await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, task), {}, {
|
|
130
|
+
TYPE: createType()
|
|
158
131
|
}, keys));
|
|
159
132
|
return task;
|
|
160
133
|
} catch (ex) {
|
|
161
|
-
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", {
|
|
162
135
|
keys,
|
|
163
|
-
|
|
136
|
+
importExportTask: task
|
|
164
137
|
});
|
|
165
138
|
}
|
|
166
139
|
},
|
|
167
|
-
|
|
168
140
|
async updateTask(params) {
|
|
169
141
|
const {
|
|
170
142
|
task,
|
|
171
143
|
original
|
|
172
144
|
} = params;
|
|
173
145
|
const keys = {
|
|
174
|
-
PK:
|
|
146
|
+
PK: createPartitionKey({
|
|
175
147
|
tenant: task.tenant,
|
|
176
148
|
locale: task.locale,
|
|
177
149
|
id: task.id
|
|
@@ -180,45 +152,41 @@ const createStorageOperations = params => {
|
|
|
180
152
|
GSI1_PK: PARENT_TASK_GSI1_PK,
|
|
181
153
|
GSI1_SK: task.createdOn
|
|
182
154
|
};
|
|
183
|
-
|
|
184
155
|
try {
|
|
185
|
-
await entity.put(
|
|
186
|
-
TYPE:
|
|
156
|
+
await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, task), {}, {
|
|
157
|
+
TYPE: createType()
|
|
187
158
|
}, keys));
|
|
188
159
|
return task;
|
|
189
160
|
} catch (ex) {
|
|
190
|
-
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", {
|
|
191
162
|
keys,
|
|
192
163
|
original,
|
|
193
164
|
task: task
|
|
194
165
|
});
|
|
195
166
|
}
|
|
196
167
|
},
|
|
197
|
-
|
|
198
168
|
async deleteTask(params) {
|
|
199
169
|
const {
|
|
200
170
|
task
|
|
201
171
|
} = params;
|
|
202
172
|
const keys = {
|
|
203
|
-
PK:
|
|
173
|
+
PK: createPartitionKey({
|
|
204
174
|
tenant: task.tenant,
|
|
205
175
|
locale: task.locale,
|
|
206
176
|
id: task.id
|
|
207
177
|
}),
|
|
208
178
|
SK: "A"
|
|
209
179
|
};
|
|
210
|
-
|
|
211
180
|
try {
|
|
212
181
|
await entity.delete(keys);
|
|
213
182
|
return task;
|
|
214
183
|
} catch (ex) {
|
|
215
|
-
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", {
|
|
216
185
|
keys,
|
|
217
186
|
task: task
|
|
218
187
|
});
|
|
219
188
|
}
|
|
220
189
|
},
|
|
221
|
-
|
|
222
190
|
async updateTaskStats(params) {
|
|
223
191
|
const {
|
|
224
192
|
original,
|
|
@@ -228,7 +196,7 @@ const createStorageOperations = params => {
|
|
|
228
196
|
}
|
|
229
197
|
} = params;
|
|
230
198
|
const keys = {
|
|
231
|
-
PK:
|
|
199
|
+
PK: createPartitionKey({
|
|
232
200
|
tenant: original.tenant,
|
|
233
201
|
locale: original.locale,
|
|
234
202
|
id: original.id
|
|
@@ -237,10 +205,9 @@ const createStorageOperations = params => {
|
|
|
237
205
|
GSI1_PK: PARENT_TASK_GSI1_PK,
|
|
238
206
|
GSI1_SK: original.createdOn
|
|
239
207
|
};
|
|
240
|
-
|
|
241
208
|
try {
|
|
242
|
-
await entity.update(
|
|
243
|
-
TYPE:
|
|
209
|
+
await entity.update((0, _objectSpread2.default)((0, _objectSpread2.default)({
|
|
210
|
+
TYPE: createType()
|
|
244
211
|
}, keys), {}, {
|
|
245
212
|
stats: {
|
|
246
213
|
$set: {
|
|
@@ -255,13 +222,12 @@ const createStorageOperations = params => {
|
|
|
255
222
|
}));
|
|
256
223
|
return original;
|
|
257
224
|
} catch (ex) {
|
|
258
|
-
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", {
|
|
259
226
|
keys,
|
|
260
227
|
original
|
|
261
228
|
});
|
|
262
229
|
}
|
|
263
230
|
},
|
|
264
|
-
|
|
265
231
|
async createSubTask(params) {
|
|
266
232
|
const {
|
|
267
233
|
subTask
|
|
@@ -272,25 +238,23 @@ const createStorageOperations = params => {
|
|
|
272
238
|
id: subTask.parent
|
|
273
239
|
};
|
|
274
240
|
const keys = {
|
|
275
|
-
PK:
|
|
276
|
-
SK:
|
|
277
|
-
GSI1_PK:
|
|
278
|
-
GSI1_SK:
|
|
241
|
+
PK: createPartitionKey(pkParams),
|
|
242
|
+
SK: createSortKey(subTask.id),
|
|
243
|
+
GSI1_PK: createGsiPartitionKey(pkParams),
|
|
244
|
+
GSI1_SK: createGsiSortKey(subTask.status, subTask.id)
|
|
279
245
|
};
|
|
280
|
-
|
|
281
246
|
try {
|
|
282
|
-
await entity.put(
|
|
283
|
-
TYPE:
|
|
247
|
+
await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, subTask), {}, {
|
|
248
|
+
TYPE: createType()
|
|
284
249
|
}, keys));
|
|
285
250
|
return subTask;
|
|
286
251
|
} catch (ex) {
|
|
287
|
-
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", {
|
|
288
253
|
keys,
|
|
289
254
|
subTask: subTask
|
|
290
255
|
});
|
|
291
256
|
}
|
|
292
257
|
},
|
|
293
|
-
|
|
294
258
|
async updateSubTask(params) {
|
|
295
259
|
const {
|
|
296
260
|
subTask,
|
|
@@ -302,58 +266,52 @@ const createStorageOperations = params => {
|
|
|
302
266
|
id: subTask.parent
|
|
303
267
|
};
|
|
304
268
|
const keys = {
|
|
305
|
-
PK:
|
|
306
|
-
SK:
|
|
307
|
-
GSI1_PK:
|
|
308
|
-
GSI1_SK:
|
|
269
|
+
PK: createPartitionKey(pkParams),
|
|
270
|
+
SK: createSortKey(subTask.id),
|
|
271
|
+
GSI1_PK: createGsiPartitionKey(pkParams),
|
|
272
|
+
GSI1_SK: createGsiSortKey(subTask.status, subTask.id)
|
|
309
273
|
};
|
|
310
|
-
|
|
311
274
|
try {
|
|
312
|
-
await entity.put(
|
|
313
|
-
TYPE:
|
|
275
|
+
await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, subTask), {}, {
|
|
276
|
+
TYPE: createType()
|
|
314
277
|
}, keys));
|
|
315
278
|
return subTask;
|
|
316
279
|
} catch (ex) {
|
|
317
|
-
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", {
|
|
318
281
|
keys,
|
|
319
282
|
original,
|
|
320
283
|
subTask: subTask
|
|
321
284
|
});
|
|
322
285
|
}
|
|
323
286
|
},
|
|
324
|
-
|
|
325
287
|
async getSubTask(params) {
|
|
326
288
|
const {
|
|
327
289
|
where
|
|
328
290
|
} = params;
|
|
329
291
|
const keys = {
|
|
330
|
-
PK:
|
|
292
|
+
PK: createPartitionKey({
|
|
331
293
|
tenant: where.tenant,
|
|
332
294
|
locale: where.locale,
|
|
333
295
|
id: where.parent
|
|
334
296
|
}),
|
|
335
|
-
SK:
|
|
297
|
+
SK: createSortKey(where.id)
|
|
336
298
|
};
|
|
337
|
-
|
|
338
299
|
try {
|
|
339
300
|
const result = await entity.get(keys);
|
|
340
|
-
|
|
341
301
|
if (!result || !result.Item) {
|
|
342
302
|
return null;
|
|
343
303
|
}
|
|
344
|
-
|
|
345
304
|
return (0, _cleanup.cleanupItem)(entity, result.Item);
|
|
346
305
|
} catch (ex) {
|
|
347
|
-
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", {
|
|
348
307
|
where
|
|
349
308
|
});
|
|
350
309
|
}
|
|
351
310
|
},
|
|
352
|
-
|
|
353
311
|
async listSubTasks(params) {
|
|
354
312
|
const {
|
|
355
313
|
where,
|
|
356
|
-
limit
|
|
314
|
+
limit = 100
|
|
357
315
|
} = params;
|
|
358
316
|
const {
|
|
359
317
|
tenant,
|
|
@@ -363,7 +321,7 @@ const createStorageOperations = params => {
|
|
|
363
321
|
} = where;
|
|
364
322
|
const queryAllParams = {
|
|
365
323
|
entity: entity,
|
|
366
|
-
partitionKey:
|
|
324
|
+
partitionKey: createGsiPartitionKey({
|
|
367
325
|
tenant,
|
|
368
326
|
locale,
|
|
369
327
|
id: parent
|
|
@@ -375,16 +333,14 @@ const createStorageOperations = params => {
|
|
|
375
333
|
}
|
|
376
334
|
};
|
|
377
335
|
let results = [];
|
|
378
|
-
|
|
379
336
|
try {
|
|
380
337
|
results = await (0, _query.queryAll)(queryAllParams);
|
|
381
338
|
} catch (ex) {
|
|
382
|
-
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", {
|
|
383
340
|
partitionKey: queryAllParams.partitionKey,
|
|
384
341
|
options: queryAllParams.options
|
|
385
342
|
});
|
|
386
343
|
}
|
|
387
|
-
|
|
388
344
|
const items = results.map(item => (0, _cleanup.cleanupItem)(entity, item));
|
|
389
345
|
return (0, _listResponse.createListResponse)({
|
|
390
346
|
items: items,
|
|
@@ -393,8 +349,6 @@ const createStorageOperations = params => {
|
|
|
393
349
|
after: null
|
|
394
350
|
});
|
|
395
351
|
}
|
|
396
|
-
|
|
397
352
|
};
|
|
398
353
|
};
|
|
399
|
-
|
|
400
354
|
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({\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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E,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,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-page-builder-import-export-so-ddb",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-unstable.085ff6572f",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"@webiny/api-page-builder-import-export",
|
|
7
7
|
"storage-operations",
|
|
8
8
|
"dynamodb",
|
|
9
|
+
"ddb",
|
|
9
10
|
"pbie:ddb"
|
|
10
11
|
],
|
|
11
12
|
"repository": {
|
|
@@ -17,30 +18,28 @@
|
|
|
17
18
|
"description": "The DynamoDB storage operations for import export feature in the Webiny Page Builder API.",
|
|
18
19
|
"license": "MIT",
|
|
19
20
|
"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.
|
|
21
|
+
"@babel/runtime": "7.20.13",
|
|
22
|
+
"@webiny/api-page-builder-import-export": "0.0.0-unstable.085ff6572f",
|
|
23
|
+
"@webiny/db-dynamodb": "0.0.0-unstable.085ff6572f",
|
|
24
|
+
"@webiny/error": "0.0.0-unstable.085ff6572f",
|
|
25
|
+
"dynamodb-toolbox": "0.3.5"
|
|
25
26
|
},
|
|
26
27
|
"devDependencies": {
|
|
27
|
-
"@babel/cli": "
|
|
28
|
-
"@babel/core": "
|
|
29
|
-
"@babel/preset-env": "
|
|
30
|
-
"@babel/preset-typescript": "
|
|
31
|
-
"@webiny/api-security": "
|
|
32
|
-
"@webiny/api-tenancy": "
|
|
33
|
-
"@webiny/cli": "
|
|
34
|
-
"@webiny/handler": "
|
|
35
|
-
"@webiny/handler-
|
|
36
|
-
"@webiny/
|
|
37
|
-
"
|
|
38
|
-
"jest": "
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"ttypescript": "^1.5.12",
|
|
43
|
-
"typescript": "^4.1.3"
|
|
28
|
+
"@babel/cli": "7.20.7",
|
|
29
|
+
"@babel/core": "7.20.12",
|
|
30
|
+
"@babel/preset-env": "7.20.2",
|
|
31
|
+
"@babel/preset-typescript": "7.18.6",
|
|
32
|
+
"@webiny/api-security": "0.0.0-unstable.085ff6572f",
|
|
33
|
+
"@webiny/api-tenancy": "0.0.0-unstable.085ff6572f",
|
|
34
|
+
"@webiny/cli": "0.0.0-unstable.085ff6572f",
|
|
35
|
+
"@webiny/handler-aws": "0.0.0-unstable.085ff6572f",
|
|
36
|
+
"@webiny/handler-graphql": "0.0.0-unstable.085ff6572f",
|
|
37
|
+
"@webiny/project-utils": "0.0.0-unstable.085ff6572f",
|
|
38
|
+
"jest": "29.5.0",
|
|
39
|
+
"jest-dynalite": "3.6.1",
|
|
40
|
+
"rimraf": "3.0.2",
|
|
41
|
+
"ttypescript": "1.5.15",
|
|
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": "085ff6572f6bb6a76d218088b06d9f4ef92bbea7"
|
|
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;
|