@webiny/api-page-builder-import-export-so-ddb 5.22.0 → 5.23.0-beta.1

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.
Files changed (3) hide show
  1. package/index.js +51 -51
  2. package/package.json +12 -12
  3. package/types.d.ts +0 -5
package/index.js CHANGED
@@ -25,7 +25,36 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
25
25
 
26
26
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
27
27
 
28
- // @ts-ignore
28
+ const PARENT_TASK_GSI1_PK = "PB#IE_TASKS";
29
+
30
+ const createPartitionKey = ({
31
+ tenant,
32
+ locale,
33
+ id
34
+ }) => {
35
+ return `T#${tenant}#L#${locale}#PB#IE_TASK#${id}`;
36
+ };
37
+
38
+ const createSortKey = input => {
39
+ return `SUB#${input}`;
40
+ };
41
+
42
+ const createGsiPartitionKey = ({
43
+ tenant,
44
+ locale,
45
+ id
46
+ }) => {
47
+ return `T#${tenant}#L#${locale}#PB#IE_TASK#${id}`;
48
+ };
49
+
50
+ const createGsiSortKey = (status, id) => {
51
+ return `S#${status}#${id}`;
52
+ };
53
+
54
+ const createType = () => {
55
+ return "pb.pageImportExportTask";
56
+ };
57
+
29
58
  const createStorageOperations = params => {
30
59
  const {
31
60
  table: tableName,
@@ -41,7 +70,6 @@ const createStorageOperations = params => {
41
70
  table,
42
71
  attributes
43
72
  });
44
- const PARENT_TASK_GSI1_PK = "PB#IE_TASKS";
45
73
  return {
46
74
  getTable() {
47
75
  return table;
@@ -51,40 +79,12 @@ const createStorageOperations = params => {
51
79
  return entity;
52
80
  },
53
81
 
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
82
  async getTask(params) {
83
83
  const {
84
84
  where
85
85
  } = params;
86
86
  const keys = {
87
- PK: this.createPartitionKey(where),
87
+ PK: createPartitionKey(where),
88
88
  SK: "A"
89
89
  };
90
90
 
@@ -142,7 +142,7 @@ const createStorageOperations = params => {
142
142
  task
143
143
  } = params;
144
144
  const keys = {
145
- PK: this.createPartitionKey({
145
+ PK: createPartitionKey({
146
146
  tenant: task.tenant,
147
147
  locale: task.locale,
148
148
  id: task.id
@@ -154,7 +154,7 @@ const createStorageOperations = params => {
154
154
 
155
155
  try {
156
156
  await entity.put(_objectSpread(_objectSpread({}, task), {}, {
157
- TYPE: this.createType()
157
+ TYPE: createType()
158
158
  }, keys));
159
159
  return task;
160
160
  } catch (ex) {
@@ -171,7 +171,7 @@ const createStorageOperations = params => {
171
171
  original
172
172
  } = params;
173
173
  const keys = {
174
- PK: this.createPartitionKey({
174
+ PK: createPartitionKey({
175
175
  tenant: task.tenant,
176
176
  locale: task.locale,
177
177
  id: task.id
@@ -183,7 +183,7 @@ const createStorageOperations = params => {
183
183
 
184
184
  try {
185
185
  await entity.put(_objectSpread(_objectSpread({}, task), {}, {
186
- TYPE: this.createType()
186
+ TYPE: createType()
187
187
  }, keys));
188
188
  return task;
189
189
  } catch (ex) {
@@ -200,7 +200,7 @@ const createStorageOperations = params => {
200
200
  task
201
201
  } = params;
202
202
  const keys = {
203
- PK: this.createPartitionKey({
203
+ PK: createPartitionKey({
204
204
  tenant: task.tenant,
205
205
  locale: task.locale,
206
206
  id: task.id
@@ -228,7 +228,7 @@ const createStorageOperations = params => {
228
228
  }
229
229
  } = params;
230
230
  const keys = {
231
- PK: this.createPartitionKey({
231
+ PK: createPartitionKey({
232
232
  tenant: original.tenant,
233
233
  locale: original.locale,
234
234
  id: original.id
@@ -240,7 +240,7 @@ const createStorageOperations = params => {
240
240
 
241
241
  try {
242
242
  await entity.update(_objectSpread(_objectSpread({
243
- TYPE: this.createType()
243
+ TYPE: createType()
244
244
  }, keys), {}, {
245
245
  stats: {
246
246
  $set: {
@@ -272,15 +272,15 @@ const createStorageOperations = params => {
272
272
  id: subTask.parent
273
273
  };
274
274
  const keys = {
275
- PK: this.createPartitionKey(pkParams),
276
- SK: this.createSortKey(subTask.id),
277
- GSI1_PK: this.createGsiPartitionKey(pkParams),
278
- GSI1_SK: this.createGsiSortKey(subTask.status, subTask.id)
275
+ PK: createPartitionKey(pkParams),
276
+ SK: createSortKey(subTask.id),
277
+ GSI1_PK: createGsiPartitionKey(pkParams),
278
+ GSI1_SK: createGsiSortKey(subTask.status, subTask.id)
279
279
  };
280
280
 
281
281
  try {
282
282
  await entity.put(_objectSpread(_objectSpread({}, subTask), {}, {
283
- TYPE: this.createType()
283
+ TYPE: createType()
284
284
  }, keys));
285
285
  return subTask;
286
286
  } catch (ex) {
@@ -302,15 +302,15 @@ const createStorageOperations = params => {
302
302
  id: subTask.parent
303
303
  };
304
304
  const keys = {
305
- PK: this.createPartitionKey(pkParams),
306
- SK: this.createSortKey(subTask.id),
307
- GSI1_PK: this.createGsiPartitionKey(pkParams),
308
- GSI1_SK: this.createGsiSortKey(subTask.status, subTask.id)
305
+ PK: createPartitionKey(pkParams),
306
+ SK: createSortKey(subTask.id),
307
+ GSI1_PK: createGsiPartitionKey(pkParams),
308
+ GSI1_SK: createGsiSortKey(subTask.status, subTask.id)
309
309
  };
310
310
 
311
311
  try {
312
312
  await entity.put(_objectSpread(_objectSpread({}, subTask), {}, {
313
- TYPE: this.createType()
313
+ TYPE: createType()
314
314
  }, keys));
315
315
  return subTask;
316
316
  } catch (ex) {
@@ -327,12 +327,12 @@ const createStorageOperations = params => {
327
327
  where
328
328
  } = params;
329
329
  const keys = {
330
- PK: this.createPartitionKey({
330
+ PK: createPartitionKey({
331
331
  tenant: where.tenant,
332
332
  locale: where.locale,
333
333
  id: where.parent
334
334
  }),
335
- SK: this.createSortKey(where.id)
335
+ SK: createSortKey(where.id)
336
336
  };
337
337
 
338
338
  try {
@@ -363,7 +363,7 @@ const createStorageOperations = params => {
363
363
  } = where;
364
364
  const queryAllParams = {
365
365
  entity: entity,
366
- partitionKey: this.createGsiPartitionKey({
366
+ partitionKey: createGsiPartitionKey({
367
367
  tenant,
368
368
  locale,
369
369
  id: parent
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-page-builder-import-export-so-ddb",
3
- "version": "5.22.0",
3
+ "version": "5.23.0-beta.1",
4
4
  "main": "index.js",
5
5
  "keywords": [
6
6
  "@webiny/api-page-builder-import-export",
@@ -18,9 +18,9 @@
18
18
  "license": "MIT",
19
19
  "dependencies": {
20
20
  "@babel/runtime": "7.16.7",
21
- "@webiny/api-page-builder-import-export": "5.22.0",
22
- "@webiny/db-dynamodb": "5.22.0",
23
- "@webiny/error": "5.22.0",
21
+ "@webiny/api-page-builder-import-export": "5.23.0-beta.1",
22
+ "@webiny/db-dynamodb": "5.23.0-beta.1",
23
+ "@webiny/error": "5.23.0-beta.1",
24
24
  "dynamodb-toolbox": "0.3.5"
25
25
  },
26
26
  "devDependencies": {
@@ -28,13 +28,13 @@
28
28
  "@babel/core": "^7.16.0",
29
29
  "@babel/preset-env": "^7.16.4",
30
30
  "@babel/preset-typescript": "^7.16.0",
31
- "@webiny/api-security": "^5.22.0",
32
- "@webiny/api-tenancy": "^5.22.0",
33
- "@webiny/cli": "^5.22.0",
34
- "@webiny/handler": "^5.22.0",
35
- "@webiny/handler-aws": "^5.22.0",
36
- "@webiny/handler-graphql": "^5.22.0",
37
- "@webiny/project-utils": "^5.22.0",
31
+ "@webiny/api-security": "^5.23.0-beta.1",
32
+ "@webiny/api-tenancy": "^5.23.0-beta.1",
33
+ "@webiny/cli": "^5.23.0-beta.1",
34
+ "@webiny/handler": "^5.23.0-beta.1",
35
+ "@webiny/handler-aws": "^5.23.0-beta.1",
36
+ "@webiny/handler-graphql": "^5.23.0-beta.1",
37
+ "@webiny/project-utils": "^5.23.0-beta.1",
38
38
  "jest": "^26.6.3",
39
39
  "jest-dynalite": "^3.2.0",
40
40
  "jest-environment-node": "^27.0.6",
@@ -50,5 +50,5 @@
50
50
  "build": "yarn webiny run build",
51
51
  "watch": "yarn webiny run watch"
52
52
  },
53
- "gitHead": "ab2ca1af058fdec3aa1bed3f30afd51f4592dbb6"
53
+ "gitHead": "04f2d5e43684b9086251e2a6370b3c085e6d51cb"
54
54
  }
package/types.d.ts CHANGED
@@ -4,11 +4,6 @@ import { DocumentClient } from "aws-sdk/clients/dynamodb";
4
4
  import { PageImportExportTaskStorageOperations } 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;