@webiny/api-headless-cms-ddb-es 0.0.0-unstable.5e7233243f → 0.0.0-unstable.fcdad0bc61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/configurations.js +1 -1
- package/definitions/entry.js +3 -7
- package/definitions/entry.js.map +1 -1
- package/definitions/entryElasticsearch.js +3 -7
- package/definitions/entryElasticsearch.js.map +1 -1
- package/definitions/group.js +3 -7
- package/definitions/group.js.map +1 -1
- package/definitions/model.js +3 -7
- package/definitions/model.js.map +1 -1
- package/definitions/settings.js +3 -7
- package/definitions/settings.js.map +1 -1
- package/definitions/system.js +3 -7
- package/definitions/system.js.map +1 -1
- package/dynamoDb/storage/date.js +1 -1
- package/dynamoDb/storage/longText.js +1 -1
- package/dynamoDb/storage/richText.js +1 -1
- package/elasticsearch/createElasticsearchIndex.js +3 -3
- package/elasticsearch/createElasticsearchIndex.js.map +1 -1
- package/elasticsearch/index.d.ts +1 -1
- package/elasticsearch/index.js +1 -1
- package/elasticsearch/indexing/index.js +1 -1
- package/elasticsearch/indices/base.js +2 -10
- package/elasticsearch/indices/base.js.map +1 -1
- package/elasticsearch/indices/index.d.ts +1 -1
- package/elasticsearch/indices/japanese.js +2 -10
- package/elasticsearch/indices/japanese.js.map +1 -1
- package/helpers/createElasticsearchQueryBody.js +25 -34
- package/helpers/createElasticsearchQueryBody.js.map +1 -1
- package/helpers/entryIndexHelpers.js +6 -11
- package/helpers/entryIndexHelpers.js.map +1 -1
- package/helpers/fields.js +18 -9
- package/helpers/fields.js.map +1 -1
- package/helpers/searchPluginsList.js +1 -1
- package/index.d.ts +1 -0
- package/index.js +70 -11
- package/index.js.map +1 -1
- package/operations/entry/dataLoaders.js +7 -9
- package/operations/entry/dataLoaders.js.map +1 -1
- package/operations/entry/elasticsearchFields.js +3 -0
- package/operations/entry/elasticsearchFields.js.map +1 -1
- package/operations/entry/index.js +42 -241
- package/operations/entry/index.js.map +1 -1
- package/operations/group/index.js +7 -12
- package/operations/group/index.js.map +1 -1
- package/operations/model/index.js +4 -8
- package/operations/model/index.js.map +1 -1
- package/operations/settings/index.js +6 -10
- package/operations/settings/index.js.map +1 -1
- package/operations/system/index.js +4 -8
- package/operations/system/index.js.map +1 -1
- package/package.json +18 -19
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.d.ts +4 -1
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js +3 -3
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchFieldPlugin.d.ts +1 -1
- package/plugins/CmsEntryElasticsearchFieldPlugin.js +3 -3
- package/plugins/CmsEntryElasticsearchFieldPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchIndexPlugin.d.ts +1 -1
- package/plugins/CmsEntryElasticsearchIndexPlugin.js +3 -3
- package/plugins/CmsEntryElasticsearchIndexPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js +1 -1
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.d.ts +1 -1
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js +3 -3
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.d.ts +1 -1
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.js +3 -3
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.js.map +1 -1
- package/plugins/index.d.ts +6 -0
- package/plugins/index.js +83 -0
- package/plugins/index.js.map +1 -0
- package/types.d.ts +5 -2
- package/types.js.map +1 -1
- package/upgrades/index.d.ts +0 -2
- package/upgrades/index.js +0 -10
- package/upgrades/index.js.map +0 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.createPublishedType = exports.createLatestType = exports.createEntriesStorageOperations = void 0;
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
11
|
|
|
12
12
|
var _types = require("@webiny/api-headless-cms/types");
|
|
13
13
|
|
|
@@ -21,8 +21,6 @@ var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
|
|
|
21
21
|
|
|
22
22
|
var _omit = _interopRequireDefault(require("lodash/omit"));
|
|
23
23
|
|
|
24
|
-
var _compression = require("@webiny/api-elasticsearch/compression");
|
|
25
|
-
|
|
26
24
|
var _batchWrite = require("@webiny/db-dynamodb/utils/batchWrite");
|
|
27
25
|
|
|
28
26
|
var _dataLoaders = require("./dataLoaders");
|
|
@@ -31,9 +29,7 @@ var _keys = require("./keys");
|
|
|
31
29
|
|
|
32
30
|
var _query = require("@webiny/db-dynamodb/utils/query");
|
|
33
31
|
|
|
34
|
-
var
|
|
35
|
-
|
|
36
|
-
var _cursors = require("@webiny/api-elasticsearch/cursors");
|
|
32
|
+
var _apiElasticsearch = require("@webiny/api-elasticsearch");
|
|
37
33
|
|
|
38
34
|
var _get = require("@webiny/db-dynamodb/utils/get");
|
|
39
35
|
|
|
@@ -41,10 +37,6 @@ var _utils = require("@webiny/utils");
|
|
|
41
37
|
|
|
42
38
|
var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
|
|
43
39
|
|
|
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; }
|
|
47
|
-
|
|
48
40
|
const createType = () => {
|
|
49
41
|
return "cms.entry";
|
|
50
42
|
};
|
|
@@ -62,14 +54,14 @@ const createPublishedType = () => {
|
|
|
62
54
|
exports.createPublishedType = createPublishedType;
|
|
63
55
|
|
|
64
56
|
const getEntryData = entry => {
|
|
65
|
-
return
|
|
57
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _omit.default)(entry, ["PK", "SK", "published", "latest"])), {}, {
|
|
66
58
|
TYPE: createType(),
|
|
67
59
|
__type: createType()
|
|
68
60
|
});
|
|
69
61
|
};
|
|
70
62
|
|
|
71
63
|
const getESLatestEntryData = async (plugins, entry) => {
|
|
72
|
-
return (0,
|
|
64
|
+
return (0, _apiElasticsearch.compress)(plugins, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, getEntryData(entry)), {}, {
|
|
73
65
|
latest: true,
|
|
74
66
|
TYPE: createLatestType(),
|
|
75
67
|
__type: createLatestType()
|
|
@@ -77,7 +69,7 @@ const getESLatestEntryData = async (plugins, entry) => {
|
|
|
77
69
|
};
|
|
78
70
|
|
|
79
71
|
const getESPublishedEntryData = async (plugins, entry) => {
|
|
80
|
-
return (0,
|
|
72
|
+
return (0, _apiElasticsearch.compress)(plugins, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, getEntryData(entry)), {}, {
|
|
81
73
|
published: true,
|
|
82
74
|
TYPE: createPublishedType(),
|
|
83
75
|
__type: createPublishedType()
|
|
@@ -93,7 +85,7 @@ const convertToStorageEntry = params => {
|
|
|
93
85
|
fields: model.fields,
|
|
94
86
|
values: entry.values
|
|
95
87
|
});
|
|
96
|
-
return
|
|
88
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, entry), {}, {
|
|
97
89
|
values
|
|
98
90
|
});
|
|
99
91
|
};
|
|
@@ -107,7 +99,7 @@ const convertFromStorageEntry = params => {
|
|
|
107
99
|
fields: model.fields,
|
|
108
100
|
values: entry.values
|
|
109
101
|
});
|
|
110
|
-
return
|
|
102
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, entry), {}, {
|
|
111
103
|
values
|
|
112
104
|
});
|
|
113
105
|
};
|
|
@@ -141,10 +133,10 @@ const createEntriesStorageOperations = params => {
|
|
|
141
133
|
const esEntry = (0, _helpers.prepareEntryToIndex)({
|
|
142
134
|
plugins,
|
|
143
135
|
model,
|
|
144
|
-
entry: (0, _cloneDeep.default)(
|
|
136
|
+
entry: (0, _cloneDeep.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, entry), {}, {
|
|
145
137
|
locked
|
|
146
138
|
})),
|
|
147
|
-
storageEntry: (0, _cloneDeep.default)(
|
|
139
|
+
storageEntry: (0, _cloneDeep.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
148
140
|
locked
|
|
149
141
|
}))
|
|
150
142
|
});
|
|
@@ -181,18 +173,18 @@ const createEntriesStorageOperations = params => {
|
|
|
181
173
|
}),
|
|
182
174
|
SK: (0, _keys.createPublishedSortKey)()
|
|
183
175
|
};
|
|
184
|
-
const items = [entity.putBatch(
|
|
176
|
+
const items = [entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
185
177
|
locked
|
|
186
178
|
}, revisionKeys), {}, {
|
|
187
179
|
TYPE: createType()
|
|
188
|
-
})), entity.putBatch(
|
|
180
|
+
})), entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
189
181
|
locked
|
|
190
182
|
}, latestKeys), {}, {
|
|
191
183
|
TYPE: createLatestType()
|
|
192
184
|
}))];
|
|
193
185
|
|
|
194
186
|
if (isPublished) {
|
|
195
|
-
items.push(entity.putBatch(
|
|
187
|
+
items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
196
188
|
locked
|
|
197
189
|
}, publishedKeys), {}, {
|
|
198
190
|
TYPE: createPublishedType()
|
|
@@ -215,13 +207,13 @@ const createEntriesStorageOperations = params => {
|
|
|
215
207
|
});
|
|
216
208
|
}
|
|
217
209
|
|
|
218
|
-
const esItems = [esEntity.putBatch(
|
|
210
|
+
const esItems = [esEntity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, latestKeys), {}, {
|
|
219
211
|
index: esIndex,
|
|
220
212
|
data: esLatestData
|
|
221
213
|
}))];
|
|
222
214
|
|
|
223
215
|
if (isPublished) {
|
|
224
|
-
esItems.push(esEntity.putBatch(
|
|
216
|
+
esItems.push(esEntity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, publishedKeys), {}, {
|
|
225
217
|
index: esIndex,
|
|
226
218
|
data: esPublishedData
|
|
227
219
|
})));
|
|
@@ -279,9 +271,9 @@ const createEntriesStorageOperations = params => {
|
|
|
279
271
|
storageEntry: (0, _cloneDeep.default)(storageEntry)
|
|
280
272
|
});
|
|
281
273
|
const esLatestData = await getESLatestEntryData(plugins, esEntry);
|
|
282
|
-
const items = [entity.putBatch(
|
|
274
|
+
const items = [entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
283
275
|
TYPE: createType()
|
|
284
|
-
}, revisionKeys)), entity.putBatch(
|
|
276
|
+
}, revisionKeys)), entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
285
277
|
TYPE: createLatestType()
|
|
286
278
|
}, latestKeys))];
|
|
287
279
|
|
|
@@ -312,7 +304,7 @@ const createEntriesStorageOperations = params => {
|
|
|
312
304
|
|
|
313
305
|
|
|
314
306
|
try {
|
|
315
|
-
await esEntity.put(
|
|
307
|
+
await esEntity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, latestKeys), {}, {
|
|
316
308
|
index,
|
|
317
309
|
data: esLatestData
|
|
318
310
|
}));
|
|
@@ -381,14 +373,14 @@ const createEntriesStorageOperations = params => {
|
|
|
381
373
|
model,
|
|
382
374
|
ids: [entry.id]
|
|
383
375
|
});
|
|
384
|
-
const items = [entity.putBatch(
|
|
376
|
+
const items = [entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
385
377
|
locked
|
|
386
378
|
}, revisionKeys), {}, {
|
|
387
379
|
TYPE: createType()
|
|
388
380
|
}))];
|
|
389
381
|
|
|
390
382
|
if (isPublished) {
|
|
391
|
-
items.push(entity.putBatch(
|
|
383
|
+
items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
392
384
|
locked
|
|
393
385
|
}, publishedKeys), {}, {
|
|
394
386
|
TYPE: createPublishedType()
|
|
@@ -418,7 +410,7 @@ const createEntriesStorageOperations = params => {
|
|
|
418
410
|
/**
|
|
419
411
|
* First we update the regular DynamoDB table
|
|
420
412
|
*/
|
|
421
|
-
items.push(entity.putBatch(
|
|
413
|
+
items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), latestKeys), {}, {
|
|
422
414
|
TYPE: (0, _keys.createLatestSortKey)()
|
|
423
415
|
})));
|
|
424
416
|
/**
|
|
@@ -428,15 +420,15 @@ const createEntriesStorageOperations = params => {
|
|
|
428
420
|
esEntry = (0, _helpers.prepareEntryToIndex)({
|
|
429
421
|
plugins,
|
|
430
422
|
model,
|
|
431
|
-
entry: (0, _cloneDeep.default)(
|
|
423
|
+
entry: (0, _cloneDeep.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, entry), {}, {
|
|
432
424
|
locked
|
|
433
425
|
})),
|
|
434
|
-
storageEntry: (0, _cloneDeep.default)(
|
|
426
|
+
storageEntry: (0, _cloneDeep.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
435
427
|
locked
|
|
436
428
|
}))
|
|
437
429
|
});
|
|
438
430
|
elasticsearchLatestData = await getESLatestEntryData(plugins, esEntry);
|
|
439
|
-
esItems.push(esEntity.putBatch(
|
|
431
|
+
esItems.push(esEntity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, latestKeys), {}, {
|
|
440
432
|
index: esIndex,
|
|
441
433
|
data: elasticsearchLatestData
|
|
442
434
|
})));
|
|
@@ -453,10 +445,10 @@ const createEntriesStorageOperations = params => {
|
|
|
453
445
|
esEntry = (0, _helpers.prepareEntryToIndex)({
|
|
454
446
|
plugins,
|
|
455
447
|
model,
|
|
456
|
-
entry: (0, _cloneDeep.default)(
|
|
448
|
+
entry: (0, _cloneDeep.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, entry), {}, {
|
|
457
449
|
locked
|
|
458
450
|
})),
|
|
459
|
-
storageEntry: (0, _cloneDeep.default)(
|
|
451
|
+
storageEntry: (0, _cloneDeep.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
460
452
|
locked
|
|
461
453
|
}))
|
|
462
454
|
});
|
|
@@ -464,7 +456,7 @@ const createEntriesStorageOperations = params => {
|
|
|
464
456
|
|
|
465
457
|
elasticsearchPublishedData = await getESPublishedEntryData(plugins, esEntry);
|
|
466
458
|
} else {
|
|
467
|
-
elasticsearchPublishedData =
|
|
459
|
+
elasticsearchPublishedData = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, elasticsearchLatestData), {}, {
|
|
468
460
|
published: true,
|
|
469
461
|
TYPE: createPublishedType(),
|
|
470
462
|
__type: createPublishedType()
|
|
@@ -472,7 +464,7 @@ const createEntriesStorageOperations = params => {
|
|
|
472
464
|
delete elasticsearchPublishedData.latest;
|
|
473
465
|
}
|
|
474
466
|
|
|
475
|
-
esItems.push(esEntity.putBatch(
|
|
467
|
+
esItems.push(esEntity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, publishedKeys), {}, {
|
|
476
468
|
index: esIndex,
|
|
477
469
|
data: elasticsearchPublishedData
|
|
478
470
|
})));
|
|
@@ -643,7 +635,7 @@ const createEntriesStorageOperations = params => {
|
|
|
643
635
|
* In the end we need to set the new latest entry
|
|
644
636
|
*/
|
|
645
637
|
|
|
646
|
-
items.push(entity.putBatch(
|
|
638
|
+
items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, latestStorageEntry), {}, {
|
|
647
639
|
PK: partitionKey,
|
|
648
640
|
SK: (0, _keys.createLatestSortKey)(),
|
|
649
641
|
TYPE: createLatestType()
|
|
@@ -693,7 +685,7 @@ const createEntriesStorageOperations = params => {
|
|
|
693
685
|
};
|
|
694
686
|
|
|
695
687
|
const list = async (model, params) => {
|
|
696
|
-
const limit = (0,
|
|
688
|
+
const limit = (0, _apiElasticsearch.createLimit)(params.limit, 50);
|
|
697
689
|
|
|
698
690
|
const {
|
|
699
691
|
index
|
|
@@ -723,7 +715,7 @@ const createEntriesStorageOperations = params => {
|
|
|
723
715
|
|
|
724
716
|
const body = (0, _helpers.createElasticsearchQueryBody)({
|
|
725
717
|
model,
|
|
726
|
-
args:
|
|
718
|
+
args: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
|
|
727
719
|
limit
|
|
728
720
|
}),
|
|
729
721
|
plugins,
|
|
@@ -773,7 +765,7 @@ const createEntriesStorageOperations = params => {
|
|
|
773
765
|
*/
|
|
774
766
|
|
|
775
767
|
|
|
776
|
-
const cursor = items.length > 0 ? (0,
|
|
768
|
+
const cursor = items.length > 0 ? (0, _apiElasticsearch.encodeCursor)(hits[items.length - 1].sort) || null : null;
|
|
777
769
|
return {
|
|
778
770
|
hasMoreItems,
|
|
779
771
|
totalCount: total.value,
|
|
@@ -785,7 +777,7 @@ const createEntriesStorageOperations = params => {
|
|
|
785
777
|
const get = async (model, params) => {
|
|
786
778
|
const {
|
|
787
779
|
items
|
|
788
|
-
} = await list(model,
|
|
780
|
+
} = await list(model, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
|
|
789
781
|
limit: 1
|
|
790
782
|
}));
|
|
791
783
|
return items.shift() || null;
|
|
@@ -851,7 +843,7 @@ const createEntriesStorageOperations = params => {
|
|
|
851
843
|
});
|
|
852
844
|
}
|
|
853
845
|
|
|
854
|
-
const items = [entity.putBatch(
|
|
846
|
+
const items = [entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), revisionKeys), {}, {
|
|
855
847
|
TYPE: createType()
|
|
856
848
|
}))];
|
|
857
849
|
const esItems = [];
|
|
@@ -883,7 +875,7 @@ const createEntriesStorageOperations = params => {
|
|
|
883
875
|
/**
|
|
884
876
|
* Update currently published entry (unpublish it)
|
|
885
877
|
*/
|
|
886
|
-
entity.putBatch(
|
|
878
|
+
entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, previouslyPublishedEntry), {}, {
|
|
887
879
|
status: _types.CONTENT_ENTRY_STATUS.UNPUBLISHED,
|
|
888
880
|
savedOn: entry.savedOn,
|
|
889
881
|
TYPE: createType(),
|
|
@@ -896,7 +888,7 @@ const createEntriesStorageOperations = params => {
|
|
|
896
888
|
*/
|
|
897
889
|
|
|
898
890
|
|
|
899
|
-
items.push(entity.putBatch(
|
|
891
|
+
items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), publishedKeys), {}, {
|
|
900
892
|
TYPE: createPublishedType()
|
|
901
893
|
})));
|
|
902
894
|
/**
|
|
@@ -909,7 +901,7 @@ const createEntriesStorageOperations = params => {
|
|
|
909
901
|
});
|
|
910
902
|
|
|
911
903
|
if ((latestStorageEntry === null || latestStorageEntry === void 0 ? void 0 : latestStorageEntry.id) === entry.id) {
|
|
912
|
-
items.push(entity.putBatch(
|
|
904
|
+
items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), latestKeys)));
|
|
913
905
|
}
|
|
914
906
|
/**
|
|
915
907
|
* If we are publishing the latest revision, let's also update the latest revision's status in ES.
|
|
@@ -922,12 +914,12 @@ const createEntriesStorageOperations = params => {
|
|
|
922
914
|
*
|
|
923
915
|
* No need to transform it for the storage because it was fetched directly from the Elasticsearch table, where it sits transformed.
|
|
924
916
|
*/
|
|
925
|
-
const latestEsEntryDataDecompressed = await (0,
|
|
917
|
+
const latestEsEntryDataDecompressed = await (0, _apiElasticsearch.decompress)(plugins, latestEsEntry.data);
|
|
926
918
|
esItems.push(esEntity.putBatch({
|
|
927
919
|
index,
|
|
928
920
|
PK: (0, _keys.createPartitionKey)(latestEsEntryDataDecompressed),
|
|
929
921
|
SK: (0, _keys.createLatestSortKey)(),
|
|
930
|
-
data:
|
|
922
|
+
data: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, latestEsEntryDataDecompressed), {}, {
|
|
931
923
|
status: _types.CONTENT_ENTRY_STATUS.PUBLISHED,
|
|
932
924
|
locked: true,
|
|
933
925
|
savedOn: entry.savedOn,
|
|
@@ -947,7 +939,7 @@ const createEntriesStorageOperations = params => {
|
|
|
947
939
|
*/
|
|
948
940
|
|
|
949
941
|
const esLatestData = await getESPublishedEntryData(plugins, preparedEntryData);
|
|
950
|
-
esItems.push(esEntity.putBatch(
|
|
942
|
+
esItems.push(esEntity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, publishedKeys), {}, {
|
|
951
943
|
index,
|
|
952
944
|
data: esLatestData
|
|
953
945
|
})));
|
|
@@ -1022,7 +1014,7 @@ const createEntriesStorageOperations = params => {
|
|
|
1022
1014
|
const items = [entity.deleteBatch({
|
|
1023
1015
|
PK: partitionKey,
|
|
1024
1016
|
SK: (0, _keys.createPublishedSortKey)()
|
|
1025
|
-
}), entity.putBatch(
|
|
1017
|
+
}), entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
1026
1018
|
PK: partitionKey,
|
|
1027
1019
|
SK: (0, _keys.createRevisionSortKey)(entry),
|
|
1028
1020
|
TYPE: createType()
|
|
@@ -1095,195 +1087,6 @@ const createEntriesStorageOperations = params => {
|
|
|
1095
1087
|
return initialStorageEntry;
|
|
1096
1088
|
};
|
|
1097
1089
|
|
|
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
1090
|
const getLatestRevisionByEntryId = async (model, params) => {
|
|
1288
1091
|
const [entry] = await dataLoaders.getLatestRevisionByEntryId({
|
|
1289
1092
|
model,
|
|
@@ -1430,7 +1233,7 @@ const createEntriesStorageOperations = params => {
|
|
|
1430
1233
|
model
|
|
1431
1234
|
});
|
|
1432
1235
|
} catch (ex) {
|
|
1433
|
-
throw new _error.default(ex.message || "Could not get previous version of given entry.", ex.code || "GET_PREVIOUS_VERSION_ERROR",
|
|
1236
|
+
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
1237
|
error: ex,
|
|
1435
1238
|
partitionKey: queryParams.partitionKey,
|
|
1436
1239
|
options: queryParams.options,
|
|
@@ -1448,8 +1251,6 @@ const createEntriesStorageOperations = params => {
|
|
|
1448
1251
|
get,
|
|
1449
1252
|
publish,
|
|
1450
1253
|
unpublish,
|
|
1451
|
-
requestReview,
|
|
1452
|
-
requestChanges,
|
|
1453
1254
|
list,
|
|
1454
1255
|
getLatestRevisionByEntryId,
|
|
1455
1256
|
getPublishedRevisionByEntryId,
|