@webiny/api-page-builder-import-export-so-ddb 0.0.0-unstable.fcdad0bc61 → 0.0.0-unstable.fdd9228b5d

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.
@@ -0,0 +1,116 @@
1
+ import type { Table } from "@webiny/db-dynamodb/toolbox";
2
+ import { Entity } from "@webiny/db-dynamodb/toolbox";
3
+ import type { Attributes } from "../types";
4
+ interface Params {
5
+ entityName: string;
6
+ table: Table<string, string, string>;
7
+ attributes?: Attributes;
8
+ }
9
+ export declare const createImportExportTaskEntity: ({ entityName, table, attributes }: Params) => Entity<string, import("dynamodb-toolbox/dist/cjs/classes/Entity").Overlay, import("dynamodb-toolbox/dist/cjs/classes/Entity").Overlay, Table<string, string, string>, boolean, boolean, boolean, string, string, string, boolean, {
10
+ PK: {
11
+ partitionKey: true;
12
+ };
13
+ SK: {
14
+ sortKey: true;
15
+ };
16
+ GSI1_PK: {
17
+ type: "string";
18
+ };
19
+ GSI1_SK: {
20
+ type: "string";
21
+ };
22
+ TYPE: {
23
+ type: "string";
24
+ };
25
+ id: {
26
+ type: "string";
27
+ };
28
+ parent: {
29
+ type: "string";
30
+ };
31
+ status: {
32
+ type: "string";
33
+ };
34
+ data: {
35
+ type: "map";
36
+ };
37
+ input: {
38
+ type: "map";
39
+ };
40
+ stats: {
41
+ type: "map";
42
+ };
43
+ error: {
44
+ type: "map";
45
+ };
46
+ createdOn: {
47
+ type: "string";
48
+ };
49
+ createdBy: {
50
+ type: "map";
51
+ };
52
+ tenant: {
53
+ type: "string";
54
+ };
55
+ locale: {
56
+ type: "string";
57
+ };
58
+ }, {
59
+ PK: {
60
+ partitionKey: true;
61
+ };
62
+ SK: {
63
+ sortKey: true;
64
+ };
65
+ GSI1_PK: {
66
+ type: "string";
67
+ };
68
+ GSI1_SK: {
69
+ type: "string";
70
+ };
71
+ TYPE: {
72
+ type: "string";
73
+ };
74
+ id: {
75
+ type: "string";
76
+ };
77
+ parent: {
78
+ type: "string";
79
+ };
80
+ status: {
81
+ type: "string";
82
+ };
83
+ data: {
84
+ type: "map";
85
+ };
86
+ input: {
87
+ type: "map";
88
+ };
89
+ stats: {
90
+ type: "map";
91
+ };
92
+ error: {
93
+ type: "map";
94
+ };
95
+ createdOn: {
96
+ type: "string";
97
+ };
98
+ createdBy: {
99
+ type: "map";
100
+ };
101
+ tenant: {
102
+ type: "string";
103
+ };
104
+ locale: {
105
+ type: "string";
106
+ };
107
+ }, import("dynamodb-toolbox/dist/cjs/classes/Entity").ParsedAttributes<import("ts-toolbelt/out/Any/Key").Key>, any, {
108
+ [x: string]: any;
109
+ [x: number]: any;
110
+ [x: symbol]: any;
111
+ }, {
112
+ [x: string]: any;
113
+ [x: number]: any;
114
+ [x: symbol]: any;
115
+ }>;
116
+ export {};
@@ -1,25 +1,19 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
8
- exports.createPageImportExportTaskEntity = void 0;
9
-
10
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
-
12
- var _dynamodbToolbox = require("dynamodb-toolbox");
13
-
14
- const createPageImportExportTaskEntity = ({
6
+ exports.createImportExportTaskEntity = void 0;
7
+ var _toolbox = require("@webiny/db-dynamodb/toolbox");
8
+ const createImportExportTaskEntity = ({
15
9
  entityName,
16
10
  table,
17
11
  attributes
18
12
  }) => {
19
- return new _dynamodbToolbox.Entity({
13
+ return new _toolbox.Entity({
20
14
  name: entityName,
21
15
  table,
22
- attributes: (0, _objectSpread2.default)({
16
+ attributes: {
23
17
  PK: {
24
18
  partitionKey: true
25
19
  },
@@ -67,9 +61,11 @@ const createPageImportExportTaskEntity = ({
67
61
  },
68
62
  locale: {
69
63
  type: "string"
70
- }
71
- }, attributes)
64
+ },
65
+ ...attributes
66
+ }
72
67
  });
73
68
  };
69
+ exports.createImportExportTaskEntity = createImportExportTaskEntity;
74
70
 
75
- exports.createPageImportExportTaskEntity = createPageImportExportTaskEntity;
71
+ //# sourceMappingURL=importExportTaskEntity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_toolbox","require","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","exports"],"sources":["importExportTaskEntity.ts"],"sourcesContent":["import type { Table } from \"@webiny/db-dynamodb/toolbox\";\nimport { Entity } from \"@webiny/db-dynamodb/toolbox\";\nimport type { Attributes } from \"~/types\";\n\ninterface Params {\n entityName: string;\n table: Table<string, string, string>;\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":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AASO,MAAMC,4BAA4B,GAAGA,CAAC;EAAEC,UAAU;EAAEC,KAAK;EAAEC;AAAmB,CAAC,KAAK;EACvF,OAAO,IAAIC,eAAM,CAAC;IACdC,IAAI,EAAEJ,UAAU;IAChBC,KAAK;IACLC,UAAU,EAAE;MACRG,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,CAAC;MACD,GAAGR;IACP;EACJ,CAAC,CAAC;AACN,CAAC;AAACsB,OAAA,CAAAzB,4BAAA,GAAAA,4BAAA","ignoreList":[]}
@@ -1,8 +1,8 @@
1
- import { Table } from "dynamodb-toolbox";
2
- import { DocumentClient } from "aws-sdk/clients/dynamodb";
1
+ import { Table } from "@webiny/db-dynamodb/toolbox";
2
+ import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb";
3
3
  interface CreateTableParams {
4
4
  table?: string;
5
- documentClient: DocumentClient;
5
+ documentClient: DynamoDBDocument;
6
6
  }
7
- export declare const createTable: ({ table, documentClient }: CreateTableParams) => Table;
7
+ export declare const createTable: ({ table, documentClient }: CreateTableParams) => Table<string, "PK", "SK">;
8
8
  export {};
@@ -4,14 +4,12 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.createTable = void 0;
7
-
8
- var _dynamodbToolbox = require("dynamodb-toolbox");
9
-
7
+ var _toolbox = require("@webiny/db-dynamodb/toolbox");
10
8
  const createTable = ({
11
9
  table,
12
10
  documentClient
13
11
  }) => {
14
- return new _dynamodbToolbox.Table({
12
+ return new _toolbox.Table({
15
13
  name: table || process.env.DB_TABLE_PAGE_BUILDER || process.env.DB_TABLE,
16
14
  partitionKey: "PK",
17
15
  sortKey: "SK",
@@ -21,8 +19,11 @@ const createTable = ({
21
19
  partitionKey: "GSI1_PK",
22
20
  sortKey: "GSI1_SK"
23
21
  }
24
- }
22
+ },
23
+ autoExecute: true,
24
+ autoParse: true
25
25
  });
26
26
  };
27
+ exports.createTable = createTable;
27
28
 
28
- exports.createTable = createTable;
29
+ //# sourceMappingURL=table.js.map
@@ -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":";;;;;;;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"}
1
+ {"version":3,"names":["_toolbox","require","createTable","table","documentClient","Table","name","process","env","DB_TABLE_PAGE_BUILDER","DB_TABLE","partitionKey","sortKey","DocumentClient","indexes","GSI1","autoExecute","autoParse","exports"],"sources":["table.ts"],"sourcesContent":["import { Table } from \"@webiny/db-dynamodb/toolbox\";\nimport type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb\";\n\ninterface CreateTableParams {\n table?: string;\n documentClient: DynamoDBDocument;\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 autoExecute: true,\n autoParse: true\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAQO,MAAMC,WAAW,GAAGA,CAAC;EAAEC,KAAK;EAAEC;AAAkC,CAAC,KAAK;EACzE,OAAO,IAAIC,cAAK,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,CAAC;IACDI,WAAW,EAAE,IAAI;IACjBC,SAAS,EAAE;EACf,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAAhB,WAAA,GAAAA,WAAA","ignoreList":[]}
package/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { CreateStorageOperations } from "./types";
1
+ import type { CreateStorageOperations } from "./types";
2
2
  export declare const createStorageOperations: CreateStorageOperations;
package/index.js CHANGED
@@ -1,28 +1,17 @@
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
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
-
12
- var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
13
-
14
8
  var _error = _interopRequireDefault(require("@webiny/error"));
15
-
16
9
  var _query = require("@webiny/db-dynamodb/utils/query");
17
-
18
10
  var _listResponse = require("@webiny/db-dynamodb/utils/listResponse");
19
-
20
11
  var _table = require("./definitions/table");
21
-
22
- var _pageImportExportTaskEntity = require("./definitions/pageImportExportTaskEntity");
23
-
12
+ var _importExportTaskEntity = require("./definitions/importExportTaskEntity");
13
+ var _dbDynamodb = require("@webiny/db-dynamodb");
24
14
  const PARENT_TASK_GSI1_PK = "PB#IE_TASKS";
25
-
26
15
  const createPartitionKey = ({
27
16
  tenant,
28
17
  locale,
@@ -30,11 +19,9 @@ const createPartitionKey = ({
30
19
  }) => {
31
20
  return `T#${tenant}#L#${locale}#PB#IE_TASK#${id}`;
32
21
  };
33
-
34
22
  const createSortKey = input => {
35
23
  return `SUB#${input}`;
36
24
  };
37
-
38
25
  const createGsiPartitionKey = ({
39
26
  tenant,
40
27
  locale,
@@ -42,15 +29,12 @@ const createGsiPartitionKey = ({
42
29
  }) => {
43
30
  return `T#${tenant}#L#${locale}#PB#IE_TASK#${id}`;
44
31
  };
45
-
46
32
  const createGsiSortKey = (status, id) => {
47
33
  return `S#${status}#${id}`;
48
34
  };
49
-
50
35
  const createType = () => {
51
- return "pb.pageImportExportTask";
36
+ return "pb.importExportTask";
52
37
  };
53
-
54
38
  const createStorageOperations = params => {
55
39
  const {
56
40
  table: tableName,
@@ -61,8 +45,8 @@ const createStorageOperations = params => {
61
45
  table: tableName,
62
46
  documentClient
63
47
  });
64
- const entity = (0, _pageImportExportTaskEntity.createPageImportExportTaskEntity)({
65
- entityName: "PageImportExportTask",
48
+ const entity = (0, _importExportTaskEntity.createImportExportTaskEntity)({
49
+ entityName: "ImportExportTask",
66
50
  table,
67
51
  attributes
68
52
  });
@@ -70,11 +54,9 @@ const createStorageOperations = params => {
70
54
  getTable() {
71
55
  return table;
72
56
  },
73
-
74
57
  getEntity() {
75
58
  return entity;
76
59
  },
77
-
78
60
  async getTask(params) {
79
61
  const {
80
62
  where
@@ -83,22 +65,17 @@ const createStorageOperations = params => {
83
65
  PK: createPartitionKey(where),
84
66
  SK: "A"
85
67
  };
86
-
87
68
  try {
88
- const result = await entity.get(keys);
89
-
90
- if (!result || !result.Item) {
91
- return null;
92
- }
93
-
94
- return (0, _cleanup.cleanupItem)(entity, result.Item);
69
+ return await (0, _dbDynamodb.getClean)({
70
+ entity,
71
+ keys
72
+ });
95
73
  } catch (ex) {
96
- throw new _error.default(ex.message || "Could not load page element by given parameters.", ex.code || "PAGE_IMPORT_EXPORT_TASK_GET_ERROR", {
74
+ throw new _error.default(ex.message || "Could not load element by given parameters.", ex.code || "IMPORT_EXPORT_TASK_GET_ERROR", {
97
75
  where
98
76
  });
99
77
  }
100
78
  },
101
-
102
79
  async listTasks(params) {
103
80
  const {
104
81
  limit = 100
@@ -107,32 +84,29 @@ const createStorageOperations = params => {
107
84
  entity: entity,
108
85
  partitionKey: PARENT_TASK_GSI1_PK,
109
86
  options: {
110
- beginsWith: "",
111
87
  index: "GSI1",
112
88
  limit: limit || undefined
113
89
  }
114
90
  };
115
91
  let results = [];
116
-
117
92
  try {
118
- results = await (0, _query.queryAll)(queryAllParams);
93
+ results = await (0, _query.queryAllClean)(queryAllParams);
119
94
  } catch (ex) {
120
- throw new _error.default(ex.message || "Could not list page import export tasks by given parameters.", ex.code || "PAGE_IMPORT_EXPORT_TASKS_LIST_ERROR", {
95
+ throw new _error.default(ex.message || "Could not list import export tasks by given parameters.", ex.code || "IMPORT_EXPORT_TASKS_LIST_ERROR", {
121
96
  partitionKey: queryAllParams.partitionKey,
122
97
  options: queryAllParams.options
123
98
  });
124
99
  }
125
100
 
126
- const items = results.map(item => (0, _cleanup.cleanupItem)(entity, item)); // TODO: Implement sort and filter
101
+ // TODO: Implement sort and filter
127
102
 
128
103
  return (0, _listResponse.createListResponse)({
129
- items: items,
104
+ items: results,
130
105
  limit,
131
- totalCount: items.length,
106
+ totalCount: results.length,
132
107
  after: null
133
108
  });
134
109
  },
135
-
136
110
  async createTask(params) {
137
111
  const {
138
112
  task
@@ -147,20 +121,23 @@ const createStorageOperations = params => {
147
121
  GSI1_PK: PARENT_TASK_GSI1_PK,
148
122
  GSI1_SK: task.createdOn
149
123
  };
150
-
151
124
  try {
152
- await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, task), {}, {
153
- TYPE: createType()
154
- }, keys));
125
+ await (0, _dbDynamodb.put)({
126
+ entity,
127
+ item: {
128
+ ...task,
129
+ TYPE: createType(),
130
+ ...keys
131
+ }
132
+ });
155
133
  return task;
156
134
  } catch (ex) {
157
- throw new _error.default(ex.message || "Could not create pageImportExportTask.", ex.code || "PAGE_IMPORT_EXPORT_TASK_CREATE_ERROR", {
135
+ throw new _error.default(ex.message || "Could not create importExportTask.", ex.code || "IMPORT_EXPORT_TASK_CREATE_ERROR", {
158
136
  keys,
159
- pageImportExportTask: task
137
+ importExportTask: task
160
138
  });
161
139
  }
162
140
  },
163
-
164
141
  async updateTask(params) {
165
142
  const {
166
143
  task,
@@ -176,21 +153,24 @@ const createStorageOperations = params => {
176
153
  GSI1_PK: PARENT_TASK_GSI1_PK,
177
154
  GSI1_SK: task.createdOn
178
155
  };
179
-
180
156
  try {
181
- await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, task), {}, {
182
- TYPE: createType()
183
- }, keys));
157
+ await (0, _dbDynamodb.put)({
158
+ entity,
159
+ item: {
160
+ ...task,
161
+ TYPE: createType(),
162
+ ...keys
163
+ }
164
+ });
184
165
  return task;
185
166
  } catch (ex) {
186
- throw new _error.default(ex.message || "Could not update pageImportExportTask.", ex.code || "PAGE_IMPORT_EXPORT_TASK_UPDATE_ERROR", {
167
+ throw new _error.default(ex.message || "Could not update importExportTask.", ex.code || "IMPORT_EXPORT_TASK_UPDATE_ERROR", {
187
168
  keys,
188
169
  original,
189
170
  task: task
190
171
  });
191
172
  }
192
173
  },
193
-
194
174
  async deleteTask(params) {
195
175
  const {
196
176
  task
@@ -203,18 +183,19 @@ const createStorageOperations = params => {
203
183
  }),
204
184
  SK: "A"
205
185
  };
206
-
207
186
  try {
208
- await entity.delete(keys);
187
+ await (0, _dbDynamodb.deleteItem)({
188
+ entity,
189
+ keys
190
+ });
209
191
  return task;
210
192
  } catch (ex) {
211
- throw new _error.default(ex.message || "Could not delete pageImportExportTask.", ex.code || "PAGE_IMPORT_EXPORT_TASK_DELETE_ERROR", {
193
+ throw new _error.default(ex.message || "Could not delete importExportTask.", ex.code || "IMPORT_EXPORT_TASK_DELETE_ERROR", {
212
194
  keys,
213
195
  task: task
214
196
  });
215
197
  }
216
198
  },
217
-
218
199
  async updateTaskStats(params) {
219
200
  const {
220
201
  original,
@@ -233,31 +214,32 @@ const createStorageOperations = params => {
233
214
  GSI1_PK: PARENT_TASK_GSI1_PK,
234
215
  GSI1_SK: original.createdOn
235
216
  };
236
-
237
217
  try {
238
- await entity.update((0, _objectSpread2.default)((0, _objectSpread2.default)({
239
- TYPE: createType()
240
- }, keys), {}, {
241
- stats: {
242
- $set: {
243
- [prevStatus]: {
244
- $add: -1
245
- },
246
- [nextStatus]: {
247
- $add: 1
218
+ await (0, _dbDynamodb.update)({
219
+ entity,
220
+ item: {
221
+ TYPE: createType(),
222
+ ...keys,
223
+ stats: {
224
+ $set: {
225
+ [prevStatus]: {
226
+ $add: -1
227
+ },
228
+ [nextStatus]: {
229
+ $add: 1
230
+ }
248
231
  }
249
232
  }
250
233
  }
251
- }));
234
+ });
252
235
  return original;
253
236
  } catch (ex) {
254
- throw new _error.default(ex.message || "Could not update pageImportExportTask.", ex.code || "PAGE_IMPORT_EXPORT_TASK_UPDATE_ERROR", {
237
+ throw new _error.default(ex.message || "Could not update importExportTask.", ex.code || "IMPORT_EXPORT_TASK_UPDATE_ERROR", {
255
238
  keys,
256
239
  original
257
240
  });
258
241
  }
259
242
  },
260
-
261
243
  async createSubTask(params) {
262
244
  const {
263
245
  subTask
@@ -273,20 +255,23 @@ const createStorageOperations = params => {
273
255
  GSI1_PK: createGsiPartitionKey(pkParams),
274
256
  GSI1_SK: createGsiSortKey(subTask.status, subTask.id)
275
257
  };
276
-
277
258
  try {
278
- await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, subTask), {}, {
279
- TYPE: createType()
280
- }, keys));
259
+ await (0, _dbDynamodb.put)({
260
+ entity,
261
+ item: {
262
+ ...subTask,
263
+ TYPE: createType(),
264
+ ...keys
265
+ }
266
+ });
281
267
  return subTask;
282
268
  } catch (ex) {
283
- throw new _error.default(ex.message || "Could not create pageImportExportSubTask.", ex.code || "CREATE_PAGE_IMPORT_EXPORT_SUB_TASK_ERROR", {
269
+ throw new _error.default(ex.message || "Could not create importExportSubTask.", ex.code || "CREATE_IMPORT_EXPORT_SUB_TASK_ERROR", {
284
270
  keys,
285
271
  subTask: subTask
286
272
  });
287
273
  }
288
274
  },
289
-
290
275
  async updateSubTask(params) {
291
276
  const {
292
277
  subTask,
@@ -303,21 +288,24 @@ const createStorageOperations = params => {
303
288
  GSI1_PK: createGsiPartitionKey(pkParams),
304
289
  GSI1_SK: createGsiSortKey(subTask.status, subTask.id)
305
290
  };
306
-
307
291
  try {
308
- await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, subTask), {}, {
309
- TYPE: createType()
310
- }, keys));
292
+ await (0, _dbDynamodb.put)({
293
+ entity,
294
+ item: {
295
+ ...subTask,
296
+ TYPE: createType(),
297
+ ...keys
298
+ }
299
+ });
311
300
  return subTask;
312
301
  } catch (ex) {
313
- throw new _error.default(ex.message || "Could not update pageImportExportSubTask.", ex.code || "UPDATE_PAGE_IMPORT_EXPORT_SUB_TASK_ERROR", {
302
+ throw new _error.default(ex.message || "Could not update importExportSubTask.", ex.code || "UPDATE_IMPORT_EXPORT_SUB_TASK_ERROR", {
314
303
  keys,
315
304
  original,
316
305
  subTask: subTask
317
306
  });
318
307
  }
319
308
  },
320
-
321
309
  async getSubTask(params) {
322
310
  const {
323
311
  where
@@ -330,22 +318,17 @@ const createStorageOperations = params => {
330
318
  }),
331
319
  SK: createSortKey(where.id)
332
320
  };
333
-
334
321
  try {
335
- const result = await entity.get(keys);
336
-
337
- if (!result || !result.Item) {
338
- return null;
339
- }
340
-
341
- return (0, _cleanup.cleanupItem)(entity, result.Item);
322
+ return await (0, _dbDynamodb.getClean)({
323
+ entity,
324
+ keys
325
+ });
342
326
  } catch (ex) {
343
- throw new _error.default(ex.message || "Could not load page import export subTask by given parameters.", ex.code || "PAGE_IMPORT_EXPORT_TASK_GET_ERROR", {
327
+ throw new _error.default(ex.message || "Could not load import export subTask by given parameters.", ex.code || "IMPORT_EXPORT_TASK_GET_ERROR", {
344
328
  where
345
329
  });
346
330
  }
347
331
  },
348
-
349
332
  async listSubTasks(params) {
350
333
  const {
351
334
  where,
@@ -371,26 +354,23 @@ const createStorageOperations = params => {
371
354
  }
372
355
  };
373
356
  let results = [];
374
-
375
357
  try {
376
- results = await (0, _query.queryAll)(queryAllParams);
358
+ results = await (0, _query.queryAllClean)(queryAllParams);
377
359
  } catch (ex) {
378
- throw new _error.default(ex.message || "Could not list page import export tasks by given parameters.", ex.code || "LIST_PAGE_IMPORT_EXPORT_SUB_TASKS_ERROR", {
360
+ throw new _error.default(ex.message || "Could not list import export tasks by given parameters.", ex.code || "LIST_IMPORT_EXPORT_SUB_TASKS_ERROR", {
379
361
  partitionKey: queryAllParams.partitionKey,
380
362
  options: queryAllParams.options
381
363
  });
382
364
  }
383
-
384
- const items = results.map(item => (0, _cleanup.cleanupItem)(entity, item));
385
365
  return (0, _listResponse.createListResponse)({
386
- items: items,
366
+ items: results,
387
367
  limit,
388
- totalCount: items.length,
368
+ totalCount: results.length,
389
369
  after: null
390
370
  });
391
371
  }
392
-
393
372
  };
394
373
  };
374
+ exports.createStorageOperations = createStorageOperations;
395
375
 
396
- exports.createStorageOperations = createStorageOperations;
376
+ //# sourceMappingURL=index.js.map
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,EAAqCL,EAArC,KAA4D;EACjF,OAAQ,KAAIK,MAAO,IAAGL,EAAG,EAAzB;AACH,CAFD;;AAIA,MAAMM,UAAU,GAAG,MAAc;EAC7B,OAAO,yBAAP;AACH,CAFD;;AAIO,MAAMC,uBAAgD,GAAGC,MAAM,IAAI;EACtE,MAAM;IAAE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;QAItBC,KAAK,EAAE;MAJe,CAAnB,CAAP;IAMH;;EA7WE,CAAP;AA+WH,CA1XM"}
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_query","_listResponse","_table","_importExportTaskEntity","_dbDynamodb","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","getClean","ex","WebinyError","message","code","listTasks","limit","queryAllParams","partitionKey","options","index","undefined","results","queryAllClean","createListResponse","items","totalCount","length","after","createTask","task","GSI1_PK","GSI1_SK","createdOn","put","item","TYPE","importExportTask","updateTask","original","deleteTask","deleteItem","updateTaskStats","prevStatus","nextStatus","update","stats","$set","$add","createSubTask","subTask","pkParams","parent","updateSubTask","getSubTask","listSubTasks","beginsWith","exports"],"sources":["index.ts"],"sourcesContent":["import type {\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 WebinyError from \"@webiny/error\";\nimport type { QueryAllParams } from \"@webiny/db-dynamodb/utils/query\";\nimport { queryAllClean } 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 type { CreateStorageOperations } from \"./types\";\nimport { deleteItem, getClean, put, update } from \"@webiny/db-dynamodb\";\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(params: ImportExportTaskStorageOperationsGetParams) {\n const { where } = params;\n\n const keys = {\n PK: createPartitionKey(where),\n SK: \"A\"\n };\n\n try {\n return await getClean<ImportExportTask>({\n entity,\n keys\n });\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 index: \"GSI1\",\n limit: limit || undefined\n }\n };\n\n let results: ImportExportTask[] = [];\n\n try {\n results = await queryAllClean<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 // TODO: Implement sort and filter\n\n return createListResponse({\n items: results,\n limit,\n totalCount: results.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 put({\n entity,\n item: {\n ...task,\n TYPE: createType(),\n ...keys\n }\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 put({\n entity,\n item: {\n ...task,\n TYPE: createType(),\n ...keys\n }\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 deleteItem({\n entity,\n keys\n });\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 update({\n entity,\n item: {\n TYPE: createType(),\n ...keys,\n stats: {\n $set: {\n [prevStatus]: { $add: -1 },\n [nextStatus]: { $add: 1 }\n }\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 put({\n entity,\n item: {\n ...subTask,\n TYPE: createType(),\n ...keys\n }\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 put({\n entity,\n item: {\n ...subTask,\n TYPE: createType(),\n ...keys\n }\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(params: ImportExportTaskStorageOperationsGetSubTaskParams) {\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 return await getClean<ImportExportTask>({\n entity,\n keys\n });\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 queryAllClean<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 return createListResponse({\n items: results,\n limit,\n totalCount: results.length,\n after: null\n });\n }\n };\n};\n"],"mappings":";;;;;;;AAgBA,IAAAA,MAAA,GAAAC,sBAAA,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AC,CAAC;QACFjC,OAAO,EAAE;UACLqC,UAAU,EAAE,KAAKjE,MAAM,EAAE;UACzByB,KAAK,EAAEA,KAAK,IAAIK,SAAS;UACzBD,KAAK,EAAE;QACX;MACJ,CAAC;MAED,IAAIE,OAA2B,GAAG,EAAE;MAEpC,IAAI;QACAA,OAAO,GAAG,MAAM,IAAAC,oBAAa,EAAmBN,cAAc,CAAC;MACnE,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,CACJ,CAAC;MACL;MAEA,OAAO,IAAAK,gCAAkB,EAAC;QACtBC,KAAK,EAAEH,OAAO;QACdN,KAAK;QACLU,UAAU,EAAEJ,OAAO,CAACK,MAAM;QAC1BC,KAAK,EAAE;MACX,CAAC,CAAC;IACN;EACJ,CAAC;AACL,CAAC;AAAC6B,OAAA,CAAAhE,uBAAA,GAAAA,uBAAA","ignoreList":[]}
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-unstable.fcdad0bc61",
3
+ "version": "0.0.0-unstable.fdd9228b5d",
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,37 +18,29 @@
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.19.0",
21
- "@webiny/api-page-builder-import-export": "0.0.0-unstable.fcdad0bc61",
22
- "@webiny/db-dynamodb": "0.0.0-unstable.fcdad0bc61",
23
- "@webiny/error": "0.0.0-unstable.fcdad0bc61",
24
- "dynamodb-toolbox": "0.3.5"
21
+ "@webiny/api-page-builder-import-export": "0.0.0-unstable.fdd9228b5d",
22
+ "@webiny/aws-sdk": "0.0.0-unstable.fdd9228b5d",
23
+ "@webiny/db-dynamodb": "0.0.0-unstable.fdd9228b5d",
24
+ "@webiny/error": "0.0.0-unstable.fdd9228b5d"
25
25
  },
26
26
  "devDependencies": {
27
- "@babel/cli": "^7.19.3",
28
- "@babel/core": "^7.19.3",
29
- "@babel/preset-env": "^7.19.4",
30
- "@babel/preset-typescript": "^7.18.6",
31
- "@webiny/api-security": "^0.0.0-unstable.fcdad0bc61",
32
- "@webiny/api-tenancy": "^0.0.0-unstable.fcdad0bc61",
33
- "@webiny/cli": "^0.0.0-unstable.fcdad0bc61",
34
- "@webiny/handler-aws": "^0.0.0-unstable.fcdad0bc61",
35
- "@webiny/handler-graphql": "^0.0.0-unstable.fcdad0bc61",
36
- "@webiny/project-utils": "^0.0.0-unstable.fcdad0bc61",
37
- "jest": "^28.1.0",
38
- "jest-dynalite": "^3.2.0",
39
- "jest-environment-node": "^27.0.6",
40
- "rimraf": "^3.0.2",
41
- "ttypescript": "^1.5.12",
42
- "typescript": "4.7.4"
27
+ "@webiny/api-security": "0.0.0-unstable.fdd9228b5d",
28
+ "@webiny/api-tenancy": "0.0.0-unstable.fdd9228b5d",
29
+ "@webiny/handler-aws": "0.0.0-unstable.fdd9228b5d",
30
+ "@webiny/handler-graphql": "0.0.0-unstable.fdd9228b5d",
31
+ "@webiny/project-utils": "0.0.0-unstable.fdd9228b5d",
32
+ "jest": "29.7.0",
33
+ "jest-dynalite": "3.6.1",
34
+ "rimraf": "6.0.1",
35
+ "typescript": "5.3.3"
43
36
  },
44
37
  "publishConfig": {
45
38
  "access": "public",
46
39
  "directory": "dist"
47
40
  },
48
41
  "scripts": {
49
- "build": "yarn webiny run build",
50
- "watch": "yarn webiny run watch"
42
+ "build": "node ../cli/bin.js run build",
43
+ "watch": "node ../cli/bin.js run watch"
51
44
  },
52
- "gitHead": "40d639c3665e384a5e2d26674d43ce26f3295e8c"
45
+ "gitHead": "fdd9228b5d2636463e8a34b6e0d26eea1e29c01d"
53
46
  }
package/types.d.ts CHANGED
@@ -1,13 +1,11 @@
1
- import { DynamoDBTypes } from "dynamodb-toolbox/dist/classes/Table";
2
- import { EntityAttributeConfig, EntityCompositeAttributes } from "dynamodb-toolbox/dist/classes/Entity";
3
- import { DocumentClient } from "aws-sdk/clients/dynamodb";
4
- import { PageImportExportTaskStorageOperations } from "@webiny/api-page-builder-import-export/types";
5
- export declare type AttributeDefinition = DynamoDBTypes | EntityAttributeConfig | EntityCompositeAttributes;
6
- export declare type Attributes = Record<string, AttributeDefinition>;
1
+ import type { AttributeDefinition } from "@webiny/db-dynamodb/toolbox";
2
+ import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb";
3
+ import type { ImportExportTaskStorageOperations } from "@webiny/api-page-builder-import-export/types";
4
+ export type Attributes = Record<string, AttributeDefinition>;
7
5
  export interface CreateStorageOperations {
8
6
  (params: {
9
- documentClient: DocumentClient;
7
+ documentClient: DynamoDBDocument;
10
8
  table?: string;
11
9
  attributes?: Attributes;
12
- }): PageImportExportTaskStorageOperations;
10
+ }): ImportExportTaskStorageOperations;
13
11
  }
package/types.js CHANGED
@@ -2,4 +2,6 @@
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
- });
5
+ });
6
+
7
+ //# sourceMappingURL=types.js.map
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 { PageImportExportTaskStorageOperations } 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 }): PageImportExportTaskStorageOperations;\n}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { AttributeDefinition } from \"@webiny/db-dynamodb/toolbox\";\nimport type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb\";\nimport type { ImportExportTaskStorageOperations } from \"@webiny/api-page-builder-import-export/types\";\n\nexport type Attributes = Record<string, AttributeDefinition>;\n\nexport interface CreateStorageOperations {\n (params: {\n documentClient: DynamoDBDocument;\n table?: string;\n attributes?: Attributes;\n }): ImportExportTaskStorageOperations;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1,9 +0,0 @@
1
- import { Entity, Table } from "dynamodb-toolbox";
2
- import { Attributes } from "../types";
3
- interface Params {
4
- entityName: string;
5
- table: Table;
6
- attributes?: Attributes;
7
- }
8
- export declare const createPageImportExportTaskEntity: ({ entityName, table, attributes }: Params) => Entity<{}>;
9
- export {};
@@ -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"}