@webiny/api-headless-cms-ddb-es 0.0.0-unstable.5e7233243f → 0.0.0-unstable.615a930a68

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 (160) hide show
  1. package/configurations.js +1 -1
  2. package/definitions/entry.js +3 -7
  3. package/definitions/entry.js.map +1 -1
  4. package/definitions/entryElasticsearch.js +3 -7
  5. package/definitions/entryElasticsearch.js.map +1 -1
  6. package/definitions/group.js +3 -7
  7. package/definitions/group.js.map +1 -1
  8. package/definitions/model.js +3 -7
  9. package/definitions/model.js.map +1 -1
  10. package/definitions/settings.js +3 -7
  11. package/definitions/settings.js.map +1 -1
  12. package/definitions/system.js +3 -7
  13. package/definitions/system.js.map +1 -1
  14. package/dynamoDb/storage/date.js +1 -1
  15. package/dynamoDb/storage/date.js.map +1 -1
  16. package/dynamoDb/storage/longText.js +1 -1
  17. package/dynamoDb/storage/richText.js +1 -1
  18. package/elasticsearch/createElasticsearchIndex.js +3 -3
  19. package/elasticsearch/createElasticsearchIndex.js.map +1 -1
  20. package/elasticsearch/index.d.ts +1 -1
  21. package/elasticsearch/index.js +1 -1
  22. package/elasticsearch/indexing/index.js +1 -1
  23. package/elasticsearch/indexing/longTextIndexing.d.ts +4 -0
  24. package/elasticsearch/indexing/longTextIndexing.js +20 -4
  25. package/elasticsearch/indexing/longTextIndexing.js.map +1 -1
  26. package/elasticsearch/indices/base.js +2 -10
  27. package/elasticsearch/indices/base.js.map +1 -1
  28. package/elasticsearch/indices/index.d.ts +1 -1
  29. package/elasticsearch/indices/japanese.js +2 -10
  30. package/elasticsearch/indices/japanese.js.map +1 -1
  31. package/elasticsearch/search/refSearch.js +4 -2
  32. package/elasticsearch/search/refSearch.js.map +1 -1
  33. package/helpers/createElasticsearchQueryBody.js +20 -22
  34. package/helpers/createElasticsearchQueryBody.js.map +1 -1
  35. package/helpers/entryIndexHelpers.js +6 -11
  36. package/helpers/entryIndexHelpers.js.map +1 -1
  37. package/helpers/index.d.ts +0 -1
  38. package/helpers/index.js +0 -13
  39. package/helpers/index.js.map +1 -1
  40. package/index.d.ts +1 -0
  41. package/index.js +79 -13
  42. package/index.js.map +1 -1
  43. package/operations/entry/dataLoaders.js +7 -9
  44. package/operations/entry/dataLoaders.js.map +1 -1
  45. package/operations/entry/elasticsearch/body.d.ts +13 -0
  46. package/operations/entry/elasticsearch/body.js +162 -0
  47. package/operations/entry/elasticsearch/body.js.map +1 -0
  48. package/operations/entry/elasticsearch/fields.d.ts +9 -0
  49. package/operations/entry/elasticsearch/fields.js +248 -0
  50. package/operations/entry/elasticsearch/fields.js.map +1 -0
  51. package/operations/entry/elasticsearch/filtering/applyFiltering.d.ts +8 -0
  52. package/operations/entry/elasticsearch/filtering/applyFiltering.js +66 -0
  53. package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +1 -0
  54. package/operations/entry/elasticsearch/filtering/exec.d.ts +17 -0
  55. package/operations/entry/elasticsearch/filtering/exec.js +214 -0
  56. package/operations/entry/elasticsearch/filtering/exec.js.map +1 -0
  57. package/operations/entry/elasticsearch/filtering/index.d.ts +1 -0
  58. package/operations/entry/elasticsearch/filtering/index.js +18 -0
  59. package/operations/entry/elasticsearch/filtering/index.js.map +1 -0
  60. package/operations/entry/elasticsearch/filtering/path.d.ts +15 -0
  61. package/operations/entry/elasticsearch/filtering/path.js +52 -0
  62. package/operations/entry/elasticsearch/filtering/path.js.map +1 -0
  63. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.d.ts +2 -0
  64. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js +35 -0
  65. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js.map +1 -0
  66. package/operations/entry/elasticsearch/filtering/plugins/index.d.ts +1 -0
  67. package/operations/entry/elasticsearch/filtering/plugins/index.js +18 -0
  68. package/operations/entry/elasticsearch/filtering/plugins/index.js.map +1 -0
  69. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.d.ts +2 -0
  70. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js +78 -0
  71. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js.map +1 -0
  72. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.d.ts +2 -0
  73. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js +58 -0
  74. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js.map +1 -0
  75. package/operations/entry/elasticsearch/filtering/populated.d.ts +2 -0
  76. package/operations/entry/elasticsearch/filtering/populated.js +30 -0
  77. package/operations/entry/elasticsearch/filtering/populated.js.map +1 -0
  78. package/operations/entry/elasticsearch/filtering/values.d.ts +2 -0
  79. package/operations/entry/elasticsearch/filtering/values.js +28 -0
  80. package/operations/entry/elasticsearch/filtering/values.js.map +1 -0
  81. package/operations/entry/elasticsearch/fullTextSearch.d.ts +9 -0
  82. package/operations/entry/elasticsearch/fullTextSearch.js +34 -0
  83. package/operations/entry/elasticsearch/fullTextSearch.js.map +1 -0
  84. package/operations/entry/elasticsearch/fullTextSearchFields.d.ts +8 -0
  85. package/operations/entry/elasticsearch/fullTextSearchFields.js +52 -0
  86. package/operations/entry/elasticsearch/fullTextSearchFields.js.map +1 -0
  87. package/operations/entry/elasticsearch/initialQuery.d.ts +17 -0
  88. package/operations/entry/elasticsearch/initialQuery.js +117 -0
  89. package/operations/entry/elasticsearch/initialQuery.js.map +1 -0
  90. package/operations/entry/elasticsearch/keyword.d.ts +2 -0
  91. package/operations/entry/elasticsearch/keyword.js +38 -0
  92. package/operations/entry/elasticsearch/keyword.js.map +1 -0
  93. package/operations/entry/elasticsearch/plugins/bodyModifier.d.ts +9 -0
  94. package/operations/entry/elasticsearch/plugins/bodyModifier.js +19 -0
  95. package/operations/entry/elasticsearch/plugins/bodyModifier.js.map +1 -0
  96. package/operations/entry/elasticsearch/plugins/operator.d.ts +8 -0
  97. package/operations/entry/elasticsearch/plugins/operator.js +45 -0
  98. package/operations/entry/elasticsearch/plugins/operator.js.map +1 -0
  99. package/operations/entry/elasticsearch/plugins/queryModifier.d.ts +9 -0
  100. package/operations/entry/elasticsearch/plugins/queryModifier.js +19 -0
  101. package/operations/entry/elasticsearch/plugins/queryModifier.js.map +1 -0
  102. package/operations/entry/elasticsearch/plugins/search.d.ts +7 -0
  103. package/operations/entry/elasticsearch/plugins/search.js +30 -0
  104. package/operations/entry/elasticsearch/plugins/search.js.map +1 -0
  105. package/operations/entry/elasticsearch/plugins/sortModifier.d.ts +9 -0
  106. package/operations/entry/elasticsearch/plugins/sortModifier.js +19 -0
  107. package/operations/entry/elasticsearch/plugins/sortModifier.js.map +1 -0
  108. package/operations/entry/elasticsearch/sort.d.ts +12 -0
  109. package/operations/entry/elasticsearch/sort.js +92 -0
  110. package/operations/entry/elasticsearch/sort.js.map +1 -0
  111. package/operations/entry/elasticsearch/transformValueForSearch.d.ts +16 -0
  112. package/operations/entry/elasticsearch/transformValueForSearch.js +34 -0
  113. package/operations/entry/elasticsearch/transformValueForSearch.js.map +1 -0
  114. package/operations/entry/elasticsearch/types.d.ts +41 -0
  115. package/operations/entry/elasticsearch/types.js +5 -0
  116. package/operations/entry/elasticsearch/types.js.map +1 -0
  117. package/operations/entry/elasticsearchFields.js +3 -0
  118. package/operations/entry/elasticsearchFields.js.map +1 -1
  119. package/operations/entry/index.d.ts +0 -2
  120. package/operations/entry/index.js +86 -300
  121. package/operations/entry/index.js.map +1 -1
  122. package/operations/entry/recordType.d.ts +3 -0
  123. package/operations/entry/recordType.js +24 -0
  124. package/operations/entry/recordType.js.map +1 -0
  125. package/operations/group/index.js +7 -12
  126. package/operations/group/index.js.map +1 -1
  127. package/operations/model/index.js +4 -8
  128. package/operations/model/index.js.map +1 -1
  129. package/operations/settings/index.js +6 -10
  130. package/operations/settings/index.js.map +1 -1
  131. package/operations/system/index.js +4 -8
  132. package/operations/system/index.js.map +1 -1
  133. package/package.json +18 -19
  134. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.d.ts +4 -1
  135. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js +3 -3
  136. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js.map +1 -1
  137. package/plugins/CmsEntryElasticsearchFieldPlugin.d.ts +1 -1
  138. package/plugins/CmsEntryElasticsearchFieldPlugin.js +3 -3
  139. package/plugins/CmsEntryElasticsearchFieldPlugin.js.map +1 -1
  140. package/plugins/CmsEntryElasticsearchIndexPlugin.d.ts +1 -1
  141. package/plugins/CmsEntryElasticsearchIndexPlugin.js +3 -3
  142. package/plugins/CmsEntryElasticsearchIndexPlugin.js.map +1 -1
  143. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js +1 -1
  144. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.d.ts +1 -1
  145. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js +3 -3
  146. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js.map +1 -1
  147. package/plugins/CmsEntryElasticsearchSortModifierPlugin.d.ts +1 -1
  148. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js +3 -3
  149. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js.map +1 -1
  150. package/plugins/CmsEntryFilterPlugin.d.ts +49 -0
  151. package/plugins/CmsEntryFilterPlugin.js +31 -0
  152. package/plugins/CmsEntryFilterPlugin.js.map +1 -0
  153. package/plugins/index.d.ts +6 -0
  154. package/plugins/index.js +83 -0
  155. package/plugins/index.js.map +1 -0
  156. package/types.d.ts +5 -2
  157. package/types.js.map +1 -1
  158. package/upgrades/index.d.ts +0 -2
  159. package/upgrades/index.js +0 -10
  160. package/upgrades/index.js.map +0 -1
@@ -1,27 +1,23 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.createPublishedType = exports.createLatestType = exports.createEntriesStorageOperations = void 0;
8
+ exports.createEntriesStorageOperations = void 0;
9
9
 
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
11
 
12
- var _types = require("@webiny/api-headless-cms/types");
13
-
14
- var _helpers = require("../../helpers");
15
-
16
- var _configurations = require("../../configurations");
12
+ var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
17
13
 
18
14
  var _error = _interopRequireDefault(require("@webiny/error"));
19
15
 
20
- var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
16
+ var _types = require("@webiny/api-headless-cms/types");
21
17
 
22
- var _omit = _interopRequireDefault(require("lodash/omit"));
18
+ var _helpers = require("../../helpers");
23
19
 
24
- var _compression = require("@webiny/api-elasticsearch/compression");
20
+ var _configurations = require("../../configurations");
25
21
 
26
22
  var _batchWrite = require("@webiny/db-dynamodb/utils/batchWrite");
27
23
 
@@ -31,9 +27,7 @@ var _keys = require("./keys");
31
27
 
32
28
  var _query = require("@webiny/db-dynamodb/utils/query");
33
29
 
34
- var _limit = require("@webiny/api-elasticsearch/limit");
35
-
36
- var _cursors = require("@webiny/api-elasticsearch/cursors");
30
+ var _apiElasticsearch = require("@webiny/api-elasticsearch");
37
31
 
38
32
  var _get = require("@webiny/db-dynamodb/utils/get");
39
33
 
@@ -41,46 +35,32 @@ var _utils = require("@webiny/utils");
41
35
 
42
36
  var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
43
37
 
44
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
45
-
46
- 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; }
38
+ var _body = require("./elasticsearch/body");
47
39
 
48
- const createType = () => {
49
- return "cms.entry";
50
- };
51
-
52
- const createLatestType = () => {
53
- return `${createType()}.l`;
54
- };
55
-
56
- exports.createLatestType = createLatestType;
57
-
58
- const createPublishedType = () => {
59
- return `${createType()}.p`;
60
- };
40
+ var _recordType = require("./recordType");
61
41
 
62
- exports.createPublishedType = createPublishedType;
63
-
64
- const getEntryData = entry => {
65
- return _objectSpread(_objectSpread({}, (0, _omit.default)(entry, ["PK", "SK", "published", "latest"])), {}, {
66
- TYPE: createType(),
67
- __type: createType()
68
- });
42
+ const getEntryData = input => {
43
+ const output = (0, _objectSpread2.default)({}, input);
44
+ delete output["PK"];
45
+ delete output["SK"];
46
+ delete output["published"];
47
+ delete output["latest"];
48
+ return output;
69
49
  };
70
50
 
71
51
  const getESLatestEntryData = async (plugins, entry) => {
72
- return (0, _compression.compress)(plugins, _objectSpread(_objectSpread({}, getEntryData(entry)), {}, {
52
+ return (0, _apiElasticsearch.compress)(plugins, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, getEntryData(entry)), {}, {
73
53
  latest: true,
74
- TYPE: createLatestType(),
75
- __type: createLatestType()
54
+ TYPE: (0, _recordType.createLatestRecordType)(),
55
+ __type: (0, _recordType.createLatestRecordType)()
76
56
  }));
77
57
  };
78
58
 
79
59
  const getESPublishedEntryData = async (plugins, entry) => {
80
- return (0, _compression.compress)(plugins, _objectSpread(_objectSpread({}, getEntryData(entry)), {}, {
60
+ return (0, _apiElasticsearch.compress)(plugins, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, getEntryData(entry)), {}, {
81
61
  published: true,
82
- TYPE: createPublishedType(),
83
- __type: createPublishedType()
62
+ TYPE: (0, _recordType.createPublishedRecordType)(),
63
+ __type: (0, _recordType.createPublishedRecordType)()
84
64
  }));
85
65
  };
86
66
 
@@ -93,7 +73,7 @@ const convertToStorageEntry = params => {
93
73
  fields: model.fields,
94
74
  values: entry.values
95
75
  });
96
- return _objectSpread(_objectSpread({}, entry), {}, {
76
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, entry), {}, {
97
77
  values
98
78
  });
99
79
  };
@@ -107,7 +87,7 @@ const convertFromStorageEntry = params => {
107
87
  fields: model.fields,
108
88
  values: entry.values
109
89
  });
110
- return _objectSpread(_objectSpread({}, entry), {}, {
90
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, entry), {}, {
111
91
  values
112
92
  });
113
93
  };
@@ -141,10 +121,10 @@ const createEntriesStorageOperations = params => {
141
121
  const esEntry = (0, _helpers.prepareEntryToIndex)({
142
122
  plugins,
143
123
  model,
144
- entry: (0, _cloneDeep.default)(_objectSpread(_objectSpread({}, entry), {}, {
124
+ entry: (0, _cloneDeep.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, entry), {}, {
145
125
  locked
146
126
  })),
147
- storageEntry: (0, _cloneDeep.default)(_objectSpread(_objectSpread({}, storageEntry), {}, {
127
+ storageEntry: (0, _cloneDeep.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
148
128
  locked
149
129
  }))
150
130
  });
@@ -181,21 +161,21 @@ const createEntriesStorageOperations = params => {
181
161
  }),
182
162
  SK: (0, _keys.createPublishedSortKey)()
183
163
  };
184
- const items = [entity.putBatch(_objectSpread(_objectSpread(_objectSpread({}, storageEntry), {}, {
164
+ const items = [entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
185
165
  locked
186
166
  }, revisionKeys), {}, {
187
- TYPE: createType()
188
- })), entity.putBatch(_objectSpread(_objectSpread(_objectSpread({}, storageEntry), {}, {
167
+ TYPE: (0, _recordType.createRecordType)()
168
+ })), entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
189
169
  locked
190
170
  }, latestKeys), {}, {
191
- TYPE: createLatestType()
171
+ TYPE: (0, _recordType.createLatestRecordType)()
192
172
  }))];
193
173
 
194
174
  if (isPublished) {
195
- items.push(entity.putBatch(_objectSpread(_objectSpread(_objectSpread({}, storageEntry), {}, {
175
+ items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
196
176
  locked
197
177
  }, publishedKeys), {}, {
198
- TYPE: createPublishedType()
178
+ TYPE: (0, _recordType.createPublishedRecordType)()
199
179
  })));
200
180
  }
201
181
 
@@ -215,13 +195,13 @@ const createEntriesStorageOperations = params => {
215
195
  });
216
196
  }
217
197
 
218
- const esItems = [esEntity.putBatch(_objectSpread(_objectSpread({}, latestKeys), {}, {
198
+ const esItems = [esEntity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, latestKeys), {}, {
219
199
  index: esIndex,
220
200
  data: esLatestData
221
201
  }))];
222
202
 
223
203
  if (isPublished) {
224
- esItems.push(esEntity.putBatch(_objectSpread(_objectSpread({}, publishedKeys), {}, {
204
+ esItems.push(esEntity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, publishedKeys), {}, {
225
205
  index: esIndex,
226
206
  data: esPublishedData
227
207
  })));
@@ -279,10 +259,10 @@ const createEntriesStorageOperations = params => {
279
259
  storageEntry: (0, _cloneDeep.default)(storageEntry)
280
260
  });
281
261
  const esLatestData = await getESLatestEntryData(plugins, esEntry);
282
- const items = [entity.putBatch(_objectSpread(_objectSpread({}, storageEntry), {}, {
283
- TYPE: createType()
284
- }, revisionKeys)), entity.putBatch(_objectSpread(_objectSpread({}, storageEntry), {}, {
285
- TYPE: createLatestType()
262
+ const items = [entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
263
+ TYPE: (0, _recordType.createRecordType)()
264
+ }, revisionKeys)), entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
265
+ TYPE: (0, _recordType.createLatestRecordType)()
286
266
  }, latestKeys))];
287
267
 
288
268
  const {
@@ -312,7 +292,7 @@ const createEntriesStorageOperations = params => {
312
292
 
313
293
 
314
294
  try {
315
- await esEntity.put(_objectSpread(_objectSpread({}, latestKeys), {}, {
295
+ await esEntity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, latestKeys), {}, {
316
296
  index,
317
297
  data: esLatestData
318
298
  }));
@@ -381,17 +361,17 @@ const createEntriesStorageOperations = params => {
381
361
  model,
382
362
  ids: [entry.id]
383
363
  });
384
- const items = [entity.putBatch(_objectSpread(_objectSpread(_objectSpread({}, storageEntry), {}, {
364
+ const items = [entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
385
365
  locked
386
366
  }, revisionKeys), {}, {
387
- TYPE: createType()
367
+ TYPE: (0, _recordType.createRecordType)()
388
368
  }))];
389
369
 
390
370
  if (isPublished) {
391
- items.push(entity.putBatch(_objectSpread(_objectSpread(_objectSpread({}, storageEntry), {}, {
371
+ items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
392
372
  locked
393
373
  }, publishedKeys), {}, {
394
- TYPE: createPublishedType()
374
+ TYPE: (0, _recordType.createPublishedRecordType)()
395
375
  })));
396
376
  }
397
377
 
@@ -418,7 +398,7 @@ const createEntriesStorageOperations = params => {
418
398
  /**
419
399
  * First we update the regular DynamoDB table
420
400
  */
421
- items.push(entity.putBatch(_objectSpread(_objectSpread(_objectSpread({}, storageEntry), latestKeys), {}, {
401
+ items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), latestKeys), {}, {
422
402
  TYPE: (0, _keys.createLatestSortKey)()
423
403
  })));
424
404
  /**
@@ -428,15 +408,15 @@ const createEntriesStorageOperations = params => {
428
408
  esEntry = (0, _helpers.prepareEntryToIndex)({
429
409
  plugins,
430
410
  model,
431
- entry: (0, _cloneDeep.default)(_objectSpread(_objectSpread({}, entry), {}, {
411
+ entry: (0, _cloneDeep.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, entry), {}, {
432
412
  locked
433
413
  })),
434
- storageEntry: (0, _cloneDeep.default)(_objectSpread(_objectSpread({}, storageEntry), {}, {
414
+ storageEntry: (0, _cloneDeep.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
435
415
  locked
436
416
  }))
437
417
  });
438
418
  elasticsearchLatestData = await getESLatestEntryData(plugins, esEntry);
439
- esItems.push(esEntity.putBatch(_objectSpread(_objectSpread({}, latestKeys), {}, {
419
+ esItems.push(esEntity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, latestKeys), {}, {
440
420
  index: esIndex,
441
421
  data: elasticsearchLatestData
442
422
  })));
@@ -453,10 +433,10 @@ const createEntriesStorageOperations = params => {
453
433
  esEntry = (0, _helpers.prepareEntryToIndex)({
454
434
  plugins,
455
435
  model,
456
- entry: (0, _cloneDeep.default)(_objectSpread(_objectSpread({}, entry), {}, {
436
+ entry: (0, _cloneDeep.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, entry), {}, {
457
437
  locked
458
438
  })),
459
- storageEntry: (0, _cloneDeep.default)(_objectSpread(_objectSpread({}, storageEntry), {}, {
439
+ storageEntry: (0, _cloneDeep.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
460
440
  locked
461
441
  }))
462
442
  });
@@ -464,15 +444,15 @@ const createEntriesStorageOperations = params => {
464
444
 
465
445
  elasticsearchPublishedData = await getESPublishedEntryData(plugins, esEntry);
466
446
  } else {
467
- elasticsearchPublishedData = _objectSpread(_objectSpread({}, elasticsearchLatestData), {}, {
447
+ elasticsearchPublishedData = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, elasticsearchLatestData), {}, {
468
448
  published: true,
469
- TYPE: createPublishedType(),
470
- __type: createPublishedType()
449
+ TYPE: (0, _recordType.createPublishedRecordType)(),
450
+ __type: (0, _recordType.createPublishedRecordType)()
471
451
  });
472
452
  delete elasticsearchPublishedData.latest;
473
453
  }
474
454
 
475
- esItems.push(esEntity.putBatch(_objectSpread(_objectSpread({}, publishedKeys), {}, {
455
+ esItems.push(esEntity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, publishedKeys), {}, {
476
456
  index: esIndex,
477
457
  data: elasticsearchPublishedData
478
458
  })));
@@ -643,10 +623,10 @@ const createEntriesStorageOperations = params => {
643
623
  * In the end we need to set the new latest entry
644
624
  */
645
625
 
646
- items.push(entity.putBatch(_objectSpread(_objectSpread({}, latestStorageEntry), {}, {
626
+ items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, latestStorageEntry), {}, {
647
627
  PK: partitionKey,
648
628
  SK: (0, _keys.createLatestSortKey)(),
649
- TYPE: createLatestType()
629
+ TYPE: (0, _recordType.createLatestRecordType)()
650
630
  })));
651
631
  esItems.push(esEntity.putBatch({
652
632
  PK: partitionKey,
@@ -693,7 +673,9 @@ const createEntriesStorageOperations = params => {
693
673
  };
694
674
 
695
675
  const list = async (model, params) => {
696
- const limit = (0, _limit.createLimit)(params.limit, 50);
676
+ var _response, _response$body;
677
+
678
+ const limit = (0, _apiElasticsearch.createLimit)(params.limit, 50);
697
679
 
698
680
  const {
699
681
  index
@@ -706,7 +688,7 @@ const createEntriesStorageOperations = params => {
706
688
  index
707
689
  });
708
690
 
709
- if (!result || !result.body) {
691
+ if (!(result !== null && result !== void 0 && result.body)) {
710
692
  return {
711
693
  hasMoreItems: false,
712
694
  totalCount: 0,
@@ -721,13 +703,13 @@ const createEntriesStorageOperations = params => {
721
703
  });
722
704
  }
723
705
 
724
- const body = (0, _helpers.createElasticsearchQueryBody)({
706
+ const body = (0, _body.createElasticsearchBody)({
725
707
  model,
726
- args: _objectSpread(_objectSpread({}, params), {}, {
727
- limit
708
+ params: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
709
+ limit,
710
+ after: (0, _apiElasticsearch.decodeCursor)(params.after)
728
711
  }),
729
- plugins,
730
- parentPath: "values"
712
+ plugins
731
713
  });
732
714
  let response;
733
715
 
@@ -748,7 +730,7 @@ const createEntriesStorageOperations = params => {
748
730
  const {
749
731
  hits,
750
732
  total
751
- } = response.body.hits;
733
+ } = ((_response = response) === null || _response === void 0 ? void 0 : (_response$body = _response.body) === null || _response$body === void 0 ? void 0 : _response$body.hits) || {};
752
734
  const items = (0, _helpers.extractEntriesFromIndex)({
753
735
  plugins,
754
736
  model,
@@ -773,7 +755,7 @@ const createEntriesStorageOperations = params => {
773
755
  */
774
756
 
775
757
 
776
- const cursor = items.length > 0 ? (0, _cursors.encodeCursor)(hits[items.length - 1].sort) || null : null;
758
+ const cursor = items.length > 0 ? (0, _apiElasticsearch.encodeCursor)(hits[items.length - 1].sort) || null : null;
777
759
  return {
778
760
  hasMoreItems,
779
761
  totalCount: total.value,
@@ -785,7 +767,7 @@ const createEntriesStorageOperations = params => {
785
767
  const get = async (model, params) => {
786
768
  const {
787
769
  items
788
- } = await list(model, _objectSpread(_objectSpread({}, params), {}, {
770
+ } = await list(model, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
789
771
  limit: 1
790
772
  }));
791
773
  return items.shift() || null;
@@ -851,8 +833,8 @@ const createEntriesStorageOperations = params => {
851
833
  });
852
834
  }
853
835
 
854
- const items = [entity.putBatch(_objectSpread(_objectSpread(_objectSpread({}, storageEntry), revisionKeys), {}, {
855
- TYPE: createType()
836
+ const items = [entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), revisionKeys), {}, {
837
+ TYPE: (0, _recordType.createRecordType)()
856
838
  }))];
857
839
  const esItems = [];
858
840
 
@@ -873,20 +855,15 @@ const createEntriesStorageOperations = params => {
873
855
  const [previouslyPublishedEntry] = await dataLoaders.getRevisionById({
874
856
  model,
875
857
  ids: [publishedStorageEntry.id]
876
- }); //
877
- // const previouslyPublishedEntry = convertToStorageEntry({
878
- // model,
879
- // entry: initialPreviouslyPublishedEntry
880
- // });
881
-
858
+ });
882
859
  items.push(
883
860
  /**
884
861
  * Update currently published entry (unpublish it)
885
862
  */
886
- entity.putBatch(_objectSpread(_objectSpread({}, previouslyPublishedEntry), {}, {
863
+ entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, previouslyPublishedEntry), {}, {
887
864
  status: _types.CONTENT_ENTRY_STATUS.UNPUBLISHED,
888
865
  savedOn: entry.savedOn,
889
- TYPE: createType(),
866
+ TYPE: (0, _recordType.createRecordType)(),
890
867
  PK: (0, _keys.createPartitionKey)(publishedStorageEntry),
891
868
  SK: (0, _keys.createRevisionSortKey)(publishedStorageEntry)
892
869
  })));
@@ -896,8 +873,8 @@ const createEntriesStorageOperations = params => {
896
873
  */
897
874
 
898
875
 
899
- items.push(entity.putBatch(_objectSpread(_objectSpread(_objectSpread({}, storageEntry), publishedKeys), {}, {
900
- TYPE: createPublishedType()
876
+ items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), publishedKeys), {}, {
877
+ TYPE: (0, _recordType.createPublishedRecordType)()
901
878
  })));
902
879
  /**
903
880
  * We need the latest entry to check if it needs to be updated as well in the Elasticsearch.
@@ -909,7 +886,7 @@ const createEntriesStorageOperations = params => {
909
886
  });
910
887
 
911
888
  if ((latestStorageEntry === null || latestStorageEntry === void 0 ? void 0 : latestStorageEntry.id) === entry.id) {
912
- items.push(entity.putBatch(_objectSpread(_objectSpread({}, storageEntry), latestKeys)));
889
+ items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), latestKeys)));
913
890
  }
914
891
  /**
915
892
  * If we are publishing the latest revision, let's also update the latest revision's status in ES.
@@ -922,17 +899,17 @@ const createEntriesStorageOperations = params => {
922
899
  *
923
900
  * No need to transform it for the storage because it was fetched directly from the Elasticsearch table, where it sits transformed.
924
901
  */
925
- const latestEsEntryDataDecompressed = await (0, _compression.decompress)(plugins, latestEsEntry.data);
902
+ const latestEsEntryDataDecompressed = await (0, _apiElasticsearch.decompress)(plugins, latestEsEntry.data);
926
903
  esItems.push(esEntity.putBatch({
927
904
  index,
928
905
  PK: (0, _keys.createPartitionKey)(latestEsEntryDataDecompressed),
929
906
  SK: (0, _keys.createLatestSortKey)(),
930
- data: _objectSpread(_objectSpread({}, latestEsEntryDataDecompressed), {}, {
907
+ data: await getESLatestEntryData(plugins, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, latestEsEntryDataDecompressed), {}, {
931
908
  status: _types.CONTENT_ENTRY_STATUS.PUBLISHED,
932
909
  locked: true,
933
910
  savedOn: entry.savedOn,
934
911
  publishedOn: entry.publishedOn
935
- })
912
+ }))
936
913
  }));
937
914
  }
938
915
 
@@ -946,10 +923,10 @@ const createEntriesStorageOperations = params => {
946
923
  * Update the published revision entry in ES.
947
924
  */
948
925
 
949
- const esLatestData = await getESPublishedEntryData(plugins, preparedEntryData);
950
- esItems.push(esEntity.putBatch(_objectSpread(_objectSpread({}, publishedKeys), {}, {
926
+ const esPublishedData = await getESPublishedEntryData(plugins, preparedEntryData);
927
+ esItems.push(esEntity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, publishedKeys), {}, {
951
928
  index,
952
- data: esLatestData
929
+ data: esPublishedData
953
930
  })));
954
931
  /**
955
932
  * Finally, execute regular table batch.
@@ -1022,10 +999,10 @@ const createEntriesStorageOperations = params => {
1022
999
  const items = [entity.deleteBatch({
1023
1000
  PK: partitionKey,
1024
1001
  SK: (0, _keys.createPublishedSortKey)()
1025
- }), entity.putBatch(_objectSpread(_objectSpread({}, storageEntry), {}, {
1002
+ }), entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
1026
1003
  PK: partitionKey,
1027
1004
  SK: (0, _keys.createRevisionSortKey)(entry),
1028
- TYPE: createType()
1005
+ TYPE: (0, _recordType.createRecordType)()
1029
1006
  }))];
1030
1007
  const esItems = [esEntity.deleteBatch({
1031
1008
  PK: partitionKey,
@@ -1095,195 +1072,6 @@ const createEntriesStorageOperations = params => {
1095
1072
  return initialStorageEntry;
1096
1073
  };
1097
1074
 
1098
- const requestReview = async (model, params) => {
1099
- const {
1100
- entry: initialEntry,
1101
- storageEntry: initialStorageEntry
1102
- } = params;
1103
- const entry = convertToStorageEntry({
1104
- model,
1105
- entry: initialEntry
1106
- });
1107
- const storageEntry = convertToStorageEntry({
1108
- model,
1109
- entry: initialStorageEntry
1110
- });
1111
- /**
1112
- * We need the latest entry to check if it needs to be updated.
1113
- */
1114
-
1115
- const [latestStorageEntry] = await dataLoaders.getLatestRevisionByEntryId({
1116
- model,
1117
- ids: [entry.id]
1118
- });
1119
- const partitionKey = (0, _keys.createPartitionKey)({
1120
- id: entry.id,
1121
- locale: model.locale,
1122
- tenant: model.tenant
1123
- });
1124
- /**
1125
- * If we updated the latest version, then make sure the changes are propagated to ES too.
1126
- */
1127
-
1128
- let esLatestData = null;
1129
-
1130
- const {
1131
- index
1132
- } = _configurations.configurations.es({
1133
- model
1134
- });
1135
-
1136
- if ((latestStorageEntry === null || latestStorageEntry === void 0 ? void 0 : latestStorageEntry.id) === entry.id) {
1137
- const preparedEntryData = (0, _helpers.prepareEntryToIndex)({
1138
- plugins,
1139
- model,
1140
- entry: (0, _cloneDeep.default)(entry),
1141
- storageEntry: (0, _cloneDeep.default)(storageEntry)
1142
- });
1143
- esLatestData = await getESLatestEntryData(plugins, preparedEntryData);
1144
- }
1145
-
1146
- try {
1147
- await entity.put(_objectSpread(_objectSpread({}, storageEntry), {}, {
1148
- PK: partitionKey,
1149
- SK: (0, _keys.createRevisionSortKey)(entry),
1150
- TYPE: createType()
1151
- }));
1152
- dataLoaders.clearAll({
1153
- model
1154
- });
1155
- } catch (ex) {
1156
- throw new _error.default(ex.message || "Could not store request review entry record into DynamoDB table.", ex.code || "REQUEST_REVIEW_ERROR", {
1157
- entry,
1158
- storageEntry,
1159
- latestStorageEntry
1160
- });
1161
- }
1162
- /**
1163
- * No need to proceed further if nothing to put into Elasticsearch.
1164
- */
1165
-
1166
-
1167
- if (!esLatestData) {
1168
- return initialStorageEntry;
1169
- }
1170
-
1171
- try {
1172
- await esEntity.put({
1173
- PK: partitionKey,
1174
- SK: (0, _keys.createLatestSortKey)(),
1175
- index,
1176
- data: esLatestData
1177
- });
1178
- } catch (ex) {
1179
- throw new _error.default(ex.message || "Could not store request review entry record into DynamoDB Elasticsearch table.", ex.code || "REQUEST_REVIEW_ERROR", {
1180
- entry,
1181
- storageEntry,
1182
- latestStorageEntry
1183
- });
1184
- }
1185
-
1186
- return initialStorageEntry;
1187
- };
1188
-
1189
- const requestChanges = async (model, params) => {
1190
- const {
1191
- entry: initialEntry,
1192
- storageEntry: initialStorageEntry
1193
- } = params;
1194
- const entry = convertToStorageEntry({
1195
- model,
1196
- entry: initialEntry
1197
- });
1198
- const storageEntry = convertToStorageEntry({
1199
- model,
1200
- entry: initialStorageEntry
1201
- });
1202
- /**
1203
- * We need the latest entry to check if it needs to be updated.
1204
- */
1205
-
1206
- const [latestStorageEntry] = await dataLoaders.getLatestRevisionByEntryId({
1207
- model,
1208
- ids: [entry.id]
1209
- });
1210
- const partitionKey = (0, _keys.createPartitionKey)({
1211
- id: entry.id,
1212
- locale: model.locale,
1213
- tenant: model.tenant
1214
- });
1215
- const items = [entity.putBatch(_objectSpread(_objectSpread({}, storageEntry), {}, {
1216
- PK: partitionKey,
1217
- SK: (0, _keys.createRevisionSortKey)(entry),
1218
- TYPE: createType()
1219
- }))];
1220
- /**
1221
- * If we updated the latest version, then make sure the changes are propagated to ES too.
1222
- */
1223
-
1224
- const {
1225
- index
1226
- } = _configurations.configurations.es({
1227
- model
1228
- });
1229
-
1230
- let esLatestData = null;
1231
-
1232
- if ((latestStorageEntry === null || latestStorageEntry === void 0 ? void 0 : latestStorageEntry.id) === entry.id) {
1233
- items.push(entity.putBatch(_objectSpread(_objectSpread({}, storageEntry), {}, {
1234
- PK: partitionKey,
1235
- SK: (0, _keys.createLatestSortKey)(),
1236
- TYPE: createLatestType()
1237
- })));
1238
- const preparedEntryData = (0, _helpers.prepareEntryToIndex)({
1239
- plugins,
1240
- model,
1241
- entry: (0, _cloneDeep.default)(entry),
1242
- storageEntry: (0, _cloneDeep.default)(storageEntry)
1243
- });
1244
- esLatestData = await getESLatestEntryData(plugins, preparedEntryData);
1245
- }
1246
-
1247
- try {
1248
- await (0, _batchWrite.batchWriteAll)({
1249
- table: entity.table,
1250
- items
1251
- });
1252
- dataLoaders.clearAll({
1253
- model
1254
- });
1255
- } catch (ex) {
1256
- throw new _error.default(ex.message || "Could not store request changes entry record into DynamoDB table.", ex.code || "REQUEST_CHANGES_ERROR", {
1257
- entry,
1258
- latestStorageEntry
1259
- });
1260
- }
1261
- /**
1262
- * No need to proceed further if nothing to put into Elasticsearch.
1263
- */
1264
-
1265
-
1266
- if (!esLatestData) {
1267
- return initialStorageEntry;
1268
- }
1269
-
1270
- try {
1271
- await esEntity.put({
1272
- PK: partitionKey,
1273
- SK: (0, _keys.createLatestSortKey)(),
1274
- index,
1275
- data: esLatestData
1276
- });
1277
- } catch (ex) {
1278
- throw new _error.default(ex.message || "Could not store request changes entry record into DynamoDB Elasticsearch table.", ex.code || "REQUEST_CHANGES_ERROR", {
1279
- entry,
1280
- latestStorageEntry
1281
- });
1282
- }
1283
-
1284
- return initialStorageEntry;
1285
- };
1286
-
1287
1075
  const getLatestRevisionByEntryId = async (model, params) => {
1288
1076
  const [entry] = await dataLoaders.getLatestRevisionByEntryId({
1289
1077
  model,
@@ -1408,7 +1196,7 @@ const createEntriesStorageOperations = params => {
1408
1196
  */
1409
1197
  filters: [{
1410
1198
  attr: "TYPE",
1411
- eq: createType()
1199
+ eq: (0, _recordType.createRecordType)()
1412
1200
  }, {
1413
1201
  attr: "version",
1414
1202
  lt: version
@@ -1430,7 +1218,7 @@ const createEntriesStorageOperations = params => {
1430
1218
  model
1431
1219
  });
1432
1220
  } catch (ex) {
1433
- throw new _error.default(ex.message || "Could not get previous version of given entry.", ex.code || "GET_PREVIOUS_VERSION_ERROR", _objectSpread(_objectSpread({}, params), {}, {
1221
+ throw new _error.default(ex.message || "Could not get previous version of given entry.", ex.code || "GET_PREVIOUS_VERSION_ERROR", (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
1434
1222
  error: ex,
1435
1223
  partitionKey: queryParams.partitionKey,
1436
1224
  options: queryParams.options,
@@ -1448,8 +1236,6 @@ const createEntriesStorageOperations = params => {
1448
1236
  get,
1449
1237
  publish,
1450
1238
  unpublish,
1451
- requestReview,
1452
- requestChanges,
1453
1239
  list,
1454
1240
  getLatestRevisionByEntryId,
1455
1241
  getPublishedRevisionByEntryId,