@webiny/api-headless-cms-ddb-es 5.34.8-beta.1 → 5.35.0-beta.0
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.d.ts +1 -1
- package/configurations.js +0 -8
- package/configurations.js.map +1 -1
- package/definitions/entry.js +3 -5
- package/definitions/entry.js.map +1 -1
- package/definitions/entryElasticsearch.js +0 -5
- package/definitions/entryElasticsearch.js.map +1 -1
- package/definitions/group.js +0 -5
- package/definitions/group.js.map +1 -1
- package/definitions/model.js +17 -5
- package/definitions/model.js.map +1 -1
- package/definitions/settings.js +0 -5
- package/definitions/settings.js.map +1 -1
- package/definitions/system.js +0 -5
- package/definitions/system.js.map +1 -1
- package/definitions/table.js +0 -3
- package/definitions/table.js.map +1 -1
- package/definitions/tableElasticsearch.js +0 -3
- package/definitions/tableElasticsearch.js.map +1 -1
- package/dynamoDb/index.js +0 -5
- package/dynamoDb/index.js.map +1 -1
- package/dynamoDb/storage/date.js +1 -16
- package/dynamoDb/storage/date.js.map +1 -1
- package/dynamoDb/storage/longText.js +1 -18
- package/dynamoDb/storage/longText.js.map +1 -1
- package/dynamoDb/storage/richText.js +0 -24
- package/dynamoDb/storage/richText.js.map +1 -1
- package/elasticsearch/createElasticsearchIndex.js +0 -11
- package/elasticsearch/createElasticsearchIndex.js.map +1 -1
- package/elasticsearch/deleteElasticsearchIndex.js +0 -7
- package/elasticsearch/deleteElasticsearchIndex.js.map +1 -1
- package/elasticsearch/index.js +0 -5
- package/elasticsearch/index.js.map +1 -1
- package/elasticsearch/indexing/dateTimeIndexing.js +4 -21
- package/elasticsearch/indexing/dateTimeIndexing.js.map +1 -1
- package/elasticsearch/indexing/defaultFieldIndexing.js +5 -11
- package/elasticsearch/indexing/defaultFieldIndexing.js.map +1 -1
- package/elasticsearch/indexing/index.js +0 -9
- package/elasticsearch/indexing/index.js.map +1 -1
- package/elasticsearch/indexing/longTextIndexing.js +2 -14
- package/elasticsearch/indexing/longTextIndexing.js.map +1 -1
- package/elasticsearch/indexing/numberIndexing.js +0 -9
- package/elasticsearch/indexing/numberIndexing.js.map +1 -1
- package/elasticsearch/indexing/objectIndexing.js +3 -30
- package/elasticsearch/indexing/objectIndexing.js.map +1 -1
- package/elasticsearch/indexing/richTextIndexing.js +0 -5
- package/elasticsearch/indexing/richTextIndexing.js.map +1 -1
- package/elasticsearch/indices/base.js +0 -3
- package/elasticsearch/indices/base.js.map +1 -1
- package/elasticsearch/indices/index.js +0 -4
- package/elasticsearch/indices/index.js.map +1 -1
- package/elasticsearch/indices/japanese.js +0 -3
- package/elasticsearch/indices/japanese.js.map +1 -1
- package/elasticsearch/search/index.js +0 -4
- package/elasticsearch/search/index.js.map +1 -1
- package/elasticsearch/search/refSearch.js +0 -6
- package/elasticsearch/search/refSearch.js.map +1 -1
- package/elasticsearch/search/timeSearch.js +0 -7
- package/elasticsearch/search/timeSearch.js.map +1 -1
- package/helpers/entryIndexHelpers.js +20 -49
- package/helpers/entryIndexHelpers.js.map +1 -1
- package/helpers/index.js +0 -2
- package/helpers/index.js.map +1 -1
- package/index.js +7 -44
- package/index.js.map +1 -1
- package/operations/entry/dataLoaders.js +0 -52
- package/operations/entry/dataLoaders.js.map +1 -1
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js +1 -3
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js.map +1 -1
- package/operations/entry/elasticsearch/body.js +2 -26
- package/operations/entry/elasticsearch/body.js.map +1 -1
- package/operations/entry/elasticsearch/fields.d.ts +5 -4
- package/operations/entry/elasticsearch/fields.js +73 -60
- package/operations/entry/elasticsearch/fields.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/applyFiltering.js +1 -10
- package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/exec.js +9 -52
- package/operations/entry/elasticsearch/filtering/exec.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/index.js +0 -2
- package/operations/entry/elasticsearch/filtering/index.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/path.js +1 -9
- package/operations/entry/elasticsearch/filtering/path.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js +1 -8
- package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/plugins/index.js +0 -5
- package/operations/entry/elasticsearch/filtering/plugins/index.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js +0 -13
- package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js +0 -10
- package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/populated.js +0 -7
- package/operations/entry/elasticsearch/filtering/populated.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/values.js +0 -6
- package/operations/entry/elasticsearch/filtering/values.js.map +1 -1
- package/operations/entry/elasticsearch/fullTextSearch.js +0 -13
- package/operations/entry/elasticsearch/fullTextSearch.js.map +1 -1
- package/operations/entry/elasticsearch/fullTextSearchFields.js +0 -6
- package/operations/entry/elasticsearch/fullTextSearchFields.js.map +1 -1
- package/operations/entry/elasticsearch/initialQuery.js +5 -19
- package/operations/entry/elasticsearch/initialQuery.js.map +1 -1
- package/operations/entry/elasticsearch/keyword.js +0 -4
- package/operations/entry/elasticsearch/keyword.js.map +1 -1
- package/operations/entry/elasticsearch/plugins/bodyModifier.js +0 -3
- package/operations/entry/elasticsearch/plugins/bodyModifier.js.map +1 -1
- package/operations/entry/elasticsearch/plugins/operator.js +0 -8
- package/operations/entry/elasticsearch/plugins/operator.js.map +1 -1
- package/operations/entry/elasticsearch/plugins/queryModifier.js +0 -3
- package/operations/entry/elasticsearch/plugins/queryModifier.js.map +1 -1
- package/operations/entry/elasticsearch/plugins/search.js +0 -6
- package/operations/entry/elasticsearch/plugins/search.js.map +1 -1
- package/operations/entry/elasticsearch/plugins/sortModifier.js +0 -3
- package/operations/entry/elasticsearch/plugins/sortModifier.js.map +1 -1
- package/operations/entry/elasticsearch/sort.js +5 -21
- package/operations/entry/elasticsearch/sort.js.map +1 -1
- package/operations/entry/elasticsearch/transformValueForSearch.js +0 -4
- package/operations/entry/elasticsearch/transformValueForSearch.js.map +1 -1
- package/operations/entry/elasticsearch/types.d.ts +3 -3
- package/operations/entry/elasticsearch/types.js.map +1 -1
- package/operations/entry/index.js +54 -147
- package/operations/entry/index.js.map +1 -1
- package/operations/entry/keys.js +0 -9
- package/operations/entry/keys.js.map +1 -1
- package/operations/entry/recordType.js +0 -6
- package/operations/entry/recordType.js.map +1 -1
- package/operations/group/index.js +2 -32
- package/operations/group/index.js.map +1 -1
- package/operations/model/index.js +1 -34
- package/operations/model/index.js.map +1 -1
- package/operations/settings/index.js +0 -24
- package/operations/settings/index.js.map +1 -1
- package/operations/system/index.js +0 -17
- package/operations/system/index.js.map +1 -1
- package/package.json +23 -16
- package/plugins/CmsElasticsearchModelFieldPlugin.d.ts +69 -0
- package/plugins/CmsElasticsearchModelFieldPlugin.js +48 -0
- package/plugins/CmsElasticsearchModelFieldPlugin.js.map +1 -0
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js +0 -8
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js +0 -10
- package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchIndexPlugin.js +0 -5
- package/plugins/CmsEntryElasticsearchIndexPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js +0 -12
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js +0 -8
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.js +0 -8
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.js.map +1 -1
- package/plugins/CmsEntryFilterPlugin.js +0 -7
- package/plugins/CmsEntryFilterPlugin.js.map +1 -1
- package/plugins/index.d.ts +1 -1
- package/plugins/index.js +11 -25
- package/plugins/index.js.map +1 -1
- package/types.d.ts +1 -1
- package/types.js +0 -5
- package/types.js.map +1 -1
|
@@ -1,44 +1,27 @@
|
|
|
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.createEntriesStorageOperations = void 0;
|
|
9
|
-
|
|
10
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
-
|
|
12
9
|
var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
|
|
13
|
-
|
|
14
10
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
15
|
-
|
|
16
11
|
var _types = require("@webiny/api-headless-cms/types");
|
|
17
|
-
|
|
18
12
|
var _helpers = require("../../helpers");
|
|
19
|
-
|
|
20
13
|
var _configurations = require("../../configurations");
|
|
21
|
-
|
|
22
14
|
var _batchWrite = require("@webiny/db-dynamodb/utils/batchWrite");
|
|
23
|
-
|
|
24
15
|
var _dataLoaders = require("./dataLoaders");
|
|
25
|
-
|
|
26
16
|
var _keys = require("./keys");
|
|
27
|
-
|
|
28
17
|
var _query = require("@webiny/db-dynamodb/utils/query");
|
|
29
|
-
|
|
30
18
|
var _apiElasticsearch = require("@webiny/api-elasticsearch");
|
|
31
|
-
|
|
32
19
|
var _get = require("@webiny/db-dynamodb/utils/get");
|
|
33
|
-
|
|
34
20
|
var _utils = require("@webiny/utils");
|
|
35
|
-
|
|
36
21
|
var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
|
|
37
|
-
|
|
38
22
|
var _body = require("./elasticsearch/body");
|
|
39
|
-
|
|
40
23
|
var _recordType = require("./recordType");
|
|
41
|
-
|
|
24
|
+
var _apiHeadlessCms = require("@webiny/api-headless-cms");
|
|
42
25
|
const getEntryData = input => {
|
|
43
26
|
const output = (0, _objectSpread2.default)({}, input);
|
|
44
27
|
delete output["PK"];
|
|
@@ -47,7 +30,6 @@ const getEntryData = input => {
|
|
|
47
30
|
delete output["latest"];
|
|
48
31
|
return output;
|
|
49
32
|
};
|
|
50
|
-
|
|
51
33
|
const getESLatestEntryData = async (plugins, entry) => {
|
|
52
34
|
return (0, _apiElasticsearch.compress)(plugins, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, getEntryData(entry)), {}, {
|
|
53
35
|
latest: true,
|
|
@@ -55,7 +37,6 @@ const getESLatestEntryData = async (plugins, entry) => {
|
|
|
55
37
|
__type: (0, _recordType.createLatestRecordType)()
|
|
56
38
|
}));
|
|
57
39
|
};
|
|
58
|
-
|
|
59
40
|
const getESPublishedEntryData = async (plugins, entry) => {
|
|
60
41
|
return (0, _apiElasticsearch.compress)(plugins, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, getEntryData(entry)), {}, {
|
|
61
42
|
published: true,
|
|
@@ -63,7 +44,6 @@ const getESPublishedEntryData = async (plugins, entry) => {
|
|
|
63
44
|
__type: (0, _recordType.createPublishedRecordType)()
|
|
64
45
|
}));
|
|
65
46
|
};
|
|
66
|
-
|
|
67
47
|
const convertEntryKeysToStorage = params => {
|
|
68
48
|
const {
|
|
69
49
|
model,
|
|
@@ -77,7 +57,6 @@ const convertEntryKeysToStorage = params => {
|
|
|
77
57
|
values
|
|
78
58
|
});
|
|
79
59
|
};
|
|
80
|
-
|
|
81
60
|
const convertEntryKeysFromStorage = params => {
|
|
82
61
|
const {
|
|
83
62
|
model,
|
|
@@ -91,7 +70,6 @@ const convertEntryKeysFromStorage = params => {
|
|
|
91
70
|
values
|
|
92
71
|
});
|
|
93
72
|
};
|
|
94
|
-
|
|
95
73
|
const createEntriesStorageOperations = params => {
|
|
96
74
|
const {
|
|
97
75
|
entity,
|
|
@@ -99,15 +77,27 @@ const createEntriesStorageOperations = params => {
|
|
|
99
77
|
elasticsearch,
|
|
100
78
|
plugins
|
|
101
79
|
} = params;
|
|
80
|
+
let storageOperationsCmsModelPlugin;
|
|
81
|
+
const getStorageOperationsCmsModelPlugin = () => {
|
|
82
|
+
if (storageOperationsCmsModelPlugin) {
|
|
83
|
+
return storageOperationsCmsModelPlugin;
|
|
84
|
+
}
|
|
85
|
+
storageOperationsCmsModelPlugin = plugins.oneByType(_apiHeadlessCms.StorageOperationsCmsModelPlugin.type);
|
|
86
|
+
return storageOperationsCmsModelPlugin;
|
|
87
|
+
};
|
|
88
|
+
const getStorageOperationsModel = model => {
|
|
89
|
+
const plugin = getStorageOperationsCmsModelPlugin();
|
|
90
|
+
return plugin.getModel(model);
|
|
91
|
+
};
|
|
102
92
|
const dataLoaders = new _dataLoaders.DataLoadersHandler({
|
|
103
93
|
entity
|
|
104
94
|
});
|
|
105
|
-
|
|
106
|
-
const create = async (model, params) => {
|
|
95
|
+
const create = async (initialModel, params) => {
|
|
107
96
|
const {
|
|
108
97
|
entry: initialEntry,
|
|
109
98
|
storageEntry: initialStorageEntry
|
|
110
99
|
} = params;
|
|
100
|
+
const model = getStorageOperationsModel(initialModel);
|
|
111
101
|
const isPublished = initialEntry.status === "published";
|
|
112
102
|
const locked = isPublished ? true : initialEntry.locked;
|
|
113
103
|
const entry = convertEntryKeysToStorage({
|
|
@@ -128,13 +118,11 @@ const createEntriesStorageOperations = params => {
|
|
|
128
118
|
locked
|
|
129
119
|
}))
|
|
130
120
|
});
|
|
131
|
-
|
|
132
121
|
const {
|
|
133
122
|
index: esIndex
|
|
134
123
|
} = _configurations.configurations.es({
|
|
135
124
|
model
|
|
136
125
|
});
|
|
137
|
-
|
|
138
126
|
const esLatestData = await getESLatestEntryData(plugins, esEntry);
|
|
139
127
|
const esPublishedData = await getESPublishedEntryData(plugins, esEntry);
|
|
140
128
|
const revisionKeys = {
|
|
@@ -170,7 +158,6 @@ const createEntriesStorageOperations = params => {
|
|
|
170
158
|
}, latestKeys), {}, {
|
|
171
159
|
TYPE: (0, _recordType.createLatestRecordType)()
|
|
172
160
|
}))];
|
|
173
|
-
|
|
174
161
|
if (isPublished) {
|
|
175
162
|
items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
176
163
|
locked
|
|
@@ -178,7 +165,6 @@ const createEntriesStorageOperations = params => {
|
|
|
178
165
|
TYPE: (0, _recordType.createPublishedRecordType)()
|
|
179
166
|
})));
|
|
180
167
|
}
|
|
181
|
-
|
|
182
168
|
try {
|
|
183
169
|
await (0, _batchWrite.batchWriteAll)({
|
|
184
170
|
table: entity.table,
|
|
@@ -194,19 +180,16 @@ const createEntriesStorageOperations = params => {
|
|
|
194
180
|
storageEntry
|
|
195
181
|
});
|
|
196
182
|
}
|
|
197
|
-
|
|
198
183
|
const esItems = [esEntity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, latestKeys), {}, {
|
|
199
184
|
index: esIndex,
|
|
200
185
|
data: esLatestData
|
|
201
186
|
}))];
|
|
202
|
-
|
|
203
187
|
if (isPublished) {
|
|
204
188
|
esItems.push(esEntity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, publishedKeys), {}, {
|
|
205
189
|
index: esIndex,
|
|
206
190
|
data: esPublishedData
|
|
207
191
|
})));
|
|
208
192
|
}
|
|
209
|
-
|
|
210
193
|
try {
|
|
211
194
|
await (0, _batchWrite.batchWriteAll)({
|
|
212
195
|
table: esEntity.table,
|
|
@@ -219,15 +202,14 @@ const createEntriesStorageOperations = params => {
|
|
|
219
202
|
esEntry
|
|
220
203
|
});
|
|
221
204
|
}
|
|
222
|
-
|
|
223
205
|
return initialStorageEntry;
|
|
224
206
|
};
|
|
225
|
-
|
|
226
|
-
const createRevisionFrom = async (model, params) => {
|
|
207
|
+
const createRevisionFrom = async (initialModel, params) => {
|
|
227
208
|
const {
|
|
228
209
|
entry: initialEntry,
|
|
229
210
|
storageEntry: initialStorageEntry
|
|
230
211
|
} = params;
|
|
212
|
+
const model = getStorageOperationsModel(initialModel);
|
|
231
213
|
const entry = convertEntryKeysToStorage({
|
|
232
214
|
model,
|
|
233
215
|
entry: initialEntry
|
|
@@ -264,13 +246,11 @@ const createEntriesStorageOperations = params => {
|
|
|
264
246
|
}, revisionKeys)), entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
265
247
|
TYPE: (0, _recordType.createLatestRecordType)()
|
|
266
248
|
}, latestKeys))];
|
|
267
|
-
|
|
268
249
|
const {
|
|
269
250
|
index
|
|
270
251
|
} = _configurations.configurations.es({
|
|
271
252
|
model
|
|
272
253
|
});
|
|
273
|
-
|
|
274
254
|
try {
|
|
275
255
|
await (0, _batchWrite.batchWriteAll)({
|
|
276
256
|
table: entity.table,
|
|
@@ -289,8 +269,6 @@ const createEntriesStorageOperations = params => {
|
|
|
289
269
|
/**
|
|
290
270
|
* Update the "latest" entry item in the Elasticsearch
|
|
291
271
|
*/
|
|
292
|
-
|
|
293
|
-
|
|
294
272
|
try {
|
|
295
273
|
await esEntity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, latestKeys), {}, {
|
|
296
274
|
index,
|
|
@@ -305,16 +283,14 @@ const createEntriesStorageOperations = params => {
|
|
|
305
283
|
/**
|
|
306
284
|
* There are no modifications on the entry created so just return the data.
|
|
307
285
|
*/
|
|
308
|
-
|
|
309
|
-
|
|
310
286
|
return initialStorageEntry;
|
|
311
287
|
};
|
|
312
|
-
|
|
313
|
-
const update = async (model, params) => {
|
|
288
|
+
const update = async (initialModel, params) => {
|
|
314
289
|
const {
|
|
315
290
|
entry: initialEntry,
|
|
316
291
|
storageEntry: initialStorageEntry
|
|
317
292
|
} = params;
|
|
293
|
+
const model = getStorageOperationsModel(initialModel);
|
|
318
294
|
const entry = convertEntryKeysToStorage({
|
|
319
295
|
model,
|
|
320
296
|
entry: initialEntry
|
|
@@ -349,10 +325,10 @@ const createEntriesStorageOperations = params => {
|
|
|
349
325
|
}),
|
|
350
326
|
SK: (0, _keys.createPublishedSortKey)()
|
|
351
327
|
};
|
|
328
|
+
|
|
352
329
|
/**
|
|
353
330
|
* We need the latest entry to check if it needs to be updated.
|
|
354
331
|
*/
|
|
355
|
-
|
|
356
332
|
const [latestStorageEntry] = await dataLoaders.getLatestRevisionByEntryId({
|
|
357
333
|
model,
|
|
358
334
|
ids: [entry.id]
|
|
@@ -366,7 +342,6 @@ const createEntriesStorageOperations = params => {
|
|
|
366
342
|
}, revisionKeys), {}, {
|
|
367
343
|
TYPE: (0, _recordType.createRecordType)()
|
|
368
344
|
}))];
|
|
369
|
-
|
|
370
345
|
if (isPublished) {
|
|
371
346
|
items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
372
347
|
locked
|
|
@@ -374,9 +349,7 @@ const createEntriesStorageOperations = params => {
|
|
|
374
349
|
TYPE: (0, _recordType.createPublishedRecordType)()
|
|
375
350
|
})));
|
|
376
351
|
}
|
|
377
|
-
|
|
378
352
|
const esItems = [];
|
|
379
|
-
|
|
380
353
|
const {
|
|
381
354
|
index: esIndex
|
|
382
355
|
} = _configurations.configurations.es({
|
|
@@ -385,15 +358,11 @@ const createEntriesStorageOperations = params => {
|
|
|
385
358
|
/**
|
|
386
359
|
* Variable for the elasticsearch entry so we do not convert it more than once
|
|
387
360
|
*/
|
|
388
|
-
|
|
389
|
-
|
|
390
361
|
let esEntry = undefined;
|
|
391
362
|
/**
|
|
392
363
|
* If the latest entry is the one being updated, we need to create a new latest entry records.
|
|
393
364
|
*/
|
|
394
|
-
|
|
395
365
|
let elasticsearchLatestData = null;
|
|
396
|
-
|
|
397
366
|
if ((latestStorageEntry === null || latestStorageEntry === void 0 ? void 0 : latestStorageEntry.id) === entry.id) {
|
|
398
367
|
/**
|
|
399
368
|
* First we update the regular DynamoDB table
|
|
@@ -404,7 +373,6 @@ const createEntriesStorageOperations = params => {
|
|
|
404
373
|
/**
|
|
405
374
|
* And then update the Elasticsearch table to propagate changes to the Elasticsearch
|
|
406
375
|
*/
|
|
407
|
-
|
|
408
376
|
esEntry = (0, _helpers.prepareEntryToIndex)({
|
|
409
377
|
plugins,
|
|
410
378
|
model,
|
|
@@ -421,9 +389,7 @@ const createEntriesStorageOperations = params => {
|
|
|
421
389
|
data: elasticsearchLatestData
|
|
422
390
|
})));
|
|
423
391
|
}
|
|
424
|
-
|
|
425
392
|
let elasticsearchPublishedData = null;
|
|
426
|
-
|
|
427
393
|
if (isPublished && (publishedStorageEntry === null || publishedStorageEntry === void 0 ? void 0 : publishedStorageEntry.id) === entry.id) {
|
|
428
394
|
if (!elasticsearchLatestData) {
|
|
429
395
|
/**
|
|
@@ -441,7 +407,6 @@ const createEntriesStorageOperations = params => {
|
|
|
441
407
|
}))
|
|
442
408
|
});
|
|
443
409
|
}
|
|
444
|
-
|
|
445
410
|
elasticsearchPublishedData = await getESPublishedEntryData(plugins, esEntry);
|
|
446
411
|
} else {
|
|
447
412
|
elasticsearchPublishedData = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, elasticsearchLatestData), {}, {
|
|
@@ -451,13 +416,11 @@ const createEntriesStorageOperations = params => {
|
|
|
451
416
|
});
|
|
452
417
|
delete elasticsearchPublishedData.latest;
|
|
453
418
|
}
|
|
454
|
-
|
|
455
419
|
esItems.push(esEntity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, publishedKeys), {}, {
|
|
456
420
|
index: esIndex,
|
|
457
421
|
data: elasticsearchPublishedData
|
|
458
422
|
})));
|
|
459
423
|
}
|
|
460
|
-
|
|
461
424
|
try {
|
|
462
425
|
await (0, _batchWrite.batchWriteAll)({
|
|
463
426
|
table: entity.table,
|
|
@@ -473,11 +436,9 @@ const createEntriesStorageOperations = params => {
|
|
|
473
436
|
storageEntry
|
|
474
437
|
});
|
|
475
438
|
}
|
|
476
|
-
|
|
477
439
|
if (esItems.length === 0) {
|
|
478
440
|
return initialStorageEntry;
|
|
479
441
|
}
|
|
480
|
-
|
|
481
442
|
try {
|
|
482
443
|
await (0, _batchWrite.batchWriteAll)({
|
|
483
444
|
table: esEntity.table,
|
|
@@ -489,14 +450,13 @@ const createEntriesStorageOperations = params => {
|
|
|
489
450
|
entry
|
|
490
451
|
});
|
|
491
452
|
}
|
|
492
|
-
|
|
493
453
|
return initialStorageEntry;
|
|
494
454
|
};
|
|
495
|
-
|
|
496
|
-
const deleteEntry = async (model, params) => {
|
|
455
|
+
const deleteEntry = async (initialModel, params) => {
|
|
497
456
|
const {
|
|
498
457
|
entry
|
|
499
458
|
} = params;
|
|
459
|
+
const model = getStorageOperationsModel(initialModel);
|
|
500
460
|
const partitionKey = (0, _keys.createPartitionKey)({
|
|
501
461
|
id: entry.id,
|
|
502
462
|
locale: model.locale,
|
|
@@ -528,7 +488,6 @@ const createEntriesStorageOperations = params => {
|
|
|
528
488
|
SK: item.SK
|
|
529
489
|
});
|
|
530
490
|
});
|
|
531
|
-
|
|
532
491
|
try {
|
|
533
492
|
await (0, _batchWrite.batchWriteAll)({
|
|
534
493
|
table: entity.table,
|
|
@@ -543,7 +502,6 @@ const createEntriesStorageOperations = params => {
|
|
|
543
502
|
entry
|
|
544
503
|
});
|
|
545
504
|
}
|
|
546
|
-
|
|
547
505
|
try {
|
|
548
506
|
await (0, _batchWrite.batchWriteAll)({
|
|
549
507
|
table: esEntity.table,
|
|
@@ -556,19 +514,18 @@ const createEntriesStorageOperations = params => {
|
|
|
556
514
|
});
|
|
557
515
|
}
|
|
558
516
|
};
|
|
559
|
-
|
|
560
|
-
const deleteRevision = async (model, params) => {
|
|
517
|
+
const deleteRevision = async (initialModel, params) => {
|
|
561
518
|
const {
|
|
562
519
|
entry,
|
|
563
520
|
latestEntry,
|
|
564
521
|
latestStorageEntry
|
|
565
522
|
} = params;
|
|
523
|
+
const model = getStorageOperationsModel(initialModel);
|
|
566
524
|
const partitionKey = (0, _keys.createPartitionKey)({
|
|
567
525
|
id: entry.id,
|
|
568
526
|
locale: model.locale,
|
|
569
527
|
tenant: model.tenant
|
|
570
528
|
});
|
|
571
|
-
|
|
572
529
|
const {
|
|
573
530
|
index
|
|
574
531
|
} = _configurations.configurations.es({
|
|
@@ -577,8 +534,6 @@ const createEntriesStorageOperations = params => {
|
|
|
577
534
|
/**
|
|
578
535
|
* We need published entry to delete it if necessary.
|
|
579
536
|
*/
|
|
580
|
-
|
|
581
|
-
|
|
582
537
|
const [publishedStorageEntry] = await dataLoaders.getPublishedRevisionByEntryId({
|
|
583
538
|
model,
|
|
584
539
|
ids: [entry.id]
|
|
@@ -586,7 +541,6 @@ const createEntriesStorageOperations = params => {
|
|
|
586
541
|
/**
|
|
587
542
|
* We need to delete all existing records of the given entry revision.
|
|
588
543
|
*/
|
|
589
|
-
|
|
590
544
|
const items = [
|
|
591
545
|
/**
|
|
592
546
|
* Delete records of given entry revision.
|
|
@@ -596,10 +550,10 @@ const createEntriesStorageOperations = params => {
|
|
|
596
550
|
SK: (0, _keys.createRevisionSortKey)(entry)
|
|
597
551
|
})];
|
|
598
552
|
const esItems = [];
|
|
553
|
+
|
|
599
554
|
/**
|
|
600
555
|
* If revision we are deleting is the published one as well, we need to delete those records as well.
|
|
601
556
|
*/
|
|
602
|
-
|
|
603
557
|
if ((publishedStorageEntry === null || publishedStorageEntry === void 0 ? void 0 : publishedStorageEntry.id) === entry.id) {
|
|
604
558
|
items.push(entity.deleteBatch({
|
|
605
559
|
PK: partitionKey,
|
|
@@ -610,7 +564,6 @@ const createEntriesStorageOperations = params => {
|
|
|
610
564
|
SK: (0, _keys.createPublishedSortKey)()
|
|
611
565
|
}));
|
|
612
566
|
}
|
|
613
|
-
|
|
614
567
|
if (latestEntry && latestStorageEntry) {
|
|
615
568
|
const esEntry = (0, _helpers.prepareEntryToIndex)({
|
|
616
569
|
plugins,
|
|
@@ -622,7 +575,6 @@ const createEntriesStorageOperations = params => {
|
|
|
622
575
|
/**
|
|
623
576
|
* In the end we need to set the new latest entry
|
|
624
577
|
*/
|
|
625
|
-
|
|
626
578
|
items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, latestStorageEntry), {}, {
|
|
627
579
|
PK: partitionKey,
|
|
628
580
|
SK: (0, _keys.createLatestSortKey)(),
|
|
@@ -635,7 +587,6 @@ const createEntriesStorageOperations = params => {
|
|
|
635
587
|
data: esLatestData
|
|
636
588
|
}));
|
|
637
589
|
}
|
|
638
|
-
|
|
639
590
|
try {
|
|
640
591
|
await (0, _batchWrite.batchWriteAll)({
|
|
641
592
|
table: entity.table,
|
|
@@ -652,11 +603,9 @@ const createEntriesStorageOperations = params => {
|
|
|
652
603
|
latestStorageEntry
|
|
653
604
|
});
|
|
654
605
|
}
|
|
655
|
-
|
|
656
606
|
if (esItems.length === 0) {
|
|
657
607
|
return;
|
|
658
608
|
}
|
|
659
|
-
|
|
660
609
|
try {
|
|
661
610
|
await (0, _batchWrite.batchWriteAll)({
|
|
662
611
|
table: esEntity.table,
|
|
@@ -671,23 +620,19 @@ const createEntriesStorageOperations = params => {
|
|
|
671
620
|
});
|
|
672
621
|
}
|
|
673
622
|
};
|
|
674
|
-
|
|
675
|
-
const list = async (model, params) => {
|
|
623
|
+
const list = async (initialModel, params) => {
|
|
676
624
|
var _response, _response$body;
|
|
677
|
-
|
|
625
|
+
const model = getStorageOperationsModel(initialModel);
|
|
678
626
|
const limit = (0, _apiElasticsearch.createLimit)(params.limit, 50);
|
|
679
|
-
|
|
680
627
|
const {
|
|
681
628
|
index
|
|
682
629
|
} = _configurations.configurations.es({
|
|
683
630
|
model
|
|
684
631
|
});
|
|
685
|
-
|
|
686
632
|
try {
|
|
687
633
|
const result = await elasticsearch.indices.exists({
|
|
688
634
|
index
|
|
689
635
|
});
|
|
690
|
-
|
|
691
636
|
if (!(result !== null && result !== void 0 && result.body)) {
|
|
692
637
|
return {
|
|
693
638
|
hasMoreItems: false,
|
|
@@ -702,7 +647,6 @@ const createEntriesStorageOperations = params => {
|
|
|
702
647
|
index
|
|
703
648
|
});
|
|
704
649
|
}
|
|
705
|
-
|
|
706
650
|
const body = (0, _body.createElasticsearchBody)({
|
|
707
651
|
model,
|
|
708
652
|
params: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
|
|
@@ -712,7 +656,6 @@ const createEntriesStorageOperations = params => {
|
|
|
712
656
|
plugins
|
|
713
657
|
});
|
|
714
658
|
let response;
|
|
715
|
-
|
|
716
659
|
try {
|
|
717
660
|
response = await elasticsearch.search({
|
|
718
661
|
index,
|
|
@@ -726,7 +669,6 @@ const createEntriesStorageOperations = params => {
|
|
|
726
669
|
model
|
|
727
670
|
});
|
|
728
671
|
}
|
|
729
|
-
|
|
730
672
|
const {
|
|
731
673
|
hits,
|
|
732
674
|
total
|
|
@@ -742,7 +684,6 @@ const createEntriesStorageOperations = params => {
|
|
|
742
684
|
});
|
|
743
685
|
});
|
|
744
686
|
const hasMoreItems = items.length > limit;
|
|
745
|
-
|
|
746
687
|
if (hasMoreItems) {
|
|
747
688
|
/**
|
|
748
689
|
* Remove the last item from results, we don't want to include it.
|
|
@@ -753,8 +694,6 @@ const createEntriesStorageOperations = params => {
|
|
|
753
694
|
* Cursor is the `sort` value of the last item in the array.
|
|
754
695
|
* https://www.elastic.co/guide/en/elasticsearch/reference/current/paginate-search-results.html#search-after
|
|
755
696
|
*/
|
|
756
|
-
|
|
757
|
-
|
|
758
697
|
const cursor = items.length > 0 ? (0, _apiElasticsearch.encodeCursor)(hits[items.length - 1].sort) || null : null;
|
|
759
698
|
return {
|
|
760
699
|
hasMoreItems,
|
|
@@ -763,8 +702,8 @@ const createEntriesStorageOperations = params => {
|
|
|
763
702
|
items
|
|
764
703
|
};
|
|
765
704
|
};
|
|
766
|
-
|
|
767
|
-
|
|
705
|
+
const get = async (initialModel, params) => {
|
|
706
|
+
const model = getStorageOperationsModel(initialModel);
|
|
768
707
|
const {
|
|
769
708
|
items
|
|
770
709
|
} = await list(model, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
|
|
@@ -772,12 +711,12 @@ const createEntriesStorageOperations = params => {
|
|
|
772
711
|
}));
|
|
773
712
|
return items.shift() || null;
|
|
774
713
|
};
|
|
775
|
-
|
|
776
|
-
const publish = async (model, params) => {
|
|
714
|
+
const publish = async (initialModel, params) => {
|
|
777
715
|
const {
|
|
778
716
|
entry: initialEntry,
|
|
779
717
|
storageEntry: initialStorageEntry
|
|
780
718
|
} = params;
|
|
719
|
+
const model = getStorageOperationsModel(initialModel);
|
|
781
720
|
const entry = convertEntryKeysToStorage({
|
|
782
721
|
model,
|
|
783
722
|
entry: initialEntry
|
|
@@ -786,10 +725,10 @@ const createEntriesStorageOperations = params => {
|
|
|
786
725
|
model,
|
|
787
726
|
entry: initialStorageEntry
|
|
788
727
|
});
|
|
728
|
+
|
|
789
729
|
/**
|
|
790
730
|
* We need currently published entry to check if need to remove it.
|
|
791
731
|
*/
|
|
792
|
-
|
|
793
732
|
const [publishedStorageEntry] = await dataLoaders.getPublishedRevisionByEntryId({
|
|
794
733
|
model,
|
|
795
734
|
ids: [entry.id]
|
|
@@ -819,7 +758,6 @@ const createEntriesStorageOperations = params => {
|
|
|
819
758
|
SK: (0, _keys.createPublishedSortKey)()
|
|
820
759
|
};
|
|
821
760
|
let latestEsEntry = null;
|
|
822
|
-
|
|
823
761
|
try {
|
|
824
762
|
latestEsEntry = await (0, _get.get)({
|
|
825
763
|
entity: esEntity,
|
|
@@ -832,18 +770,15 @@ const createEntriesStorageOperations = params => {
|
|
|
832
770
|
publishedKeys: publishedKeys
|
|
833
771
|
});
|
|
834
772
|
}
|
|
835
|
-
|
|
836
773
|
const items = [entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), revisionKeys), {}, {
|
|
837
774
|
TYPE: (0, _recordType.createRecordType)()
|
|
838
775
|
}))];
|
|
839
776
|
const esItems = [];
|
|
840
|
-
|
|
841
777
|
const {
|
|
842
778
|
index
|
|
843
779
|
} = _configurations.configurations.es({
|
|
844
780
|
model
|
|
845
781
|
});
|
|
846
|
-
|
|
847
782
|
if (publishedStorageEntry && publishedStorageEntry.id !== entry.id) {
|
|
848
783
|
/**
|
|
849
784
|
* If there is a `published` entry already, we need to set it to `unpublished`. We need to
|
|
@@ -871,28 +806,23 @@ const createEntriesStorageOperations = params => {
|
|
|
871
806
|
/**
|
|
872
807
|
* Update the helper item in DB with the new published entry
|
|
873
808
|
*/
|
|
874
|
-
|
|
875
|
-
|
|
876
809
|
items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), publishedKeys), {}, {
|
|
877
810
|
TYPE: (0, _recordType.createPublishedRecordType)()
|
|
878
811
|
})));
|
|
812
|
+
|
|
879
813
|
/**
|
|
880
814
|
* We need the latest entry to check if it needs to be updated as well in the Elasticsearch.
|
|
881
815
|
*/
|
|
882
|
-
|
|
883
816
|
const [latestStorageEntry] = await dataLoaders.getLatestRevisionByEntryId({
|
|
884
817
|
model,
|
|
885
818
|
ids: [entry.id]
|
|
886
819
|
});
|
|
887
|
-
|
|
888
820
|
if ((latestStorageEntry === null || latestStorageEntry === void 0 ? void 0 : latestStorageEntry.id) === entry.id) {
|
|
889
821
|
items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), latestKeys)));
|
|
890
822
|
}
|
|
891
823
|
/**
|
|
892
824
|
* If we are publishing the latest revision, let's also update the latest revision's status in ES.
|
|
893
825
|
*/
|
|
894
|
-
|
|
895
|
-
|
|
896
826
|
if (latestEsEntry && (latestStorageEntry === null || latestStorageEntry === void 0 ? void 0 : latestStorageEntry.id) === entry.id) {
|
|
897
827
|
/**
|
|
898
828
|
* Need to decompress the data from Elasticsearch DynamoDB table.
|
|
@@ -912,7 +842,6 @@ const createEntriesStorageOperations = params => {
|
|
|
912
842
|
}))
|
|
913
843
|
}));
|
|
914
844
|
}
|
|
915
|
-
|
|
916
845
|
const preparedEntryData = (0, _helpers.prepareEntryToIndex)({
|
|
917
846
|
plugins,
|
|
918
847
|
model,
|
|
@@ -922,16 +851,15 @@ const createEntriesStorageOperations = params => {
|
|
|
922
851
|
/**
|
|
923
852
|
* Update the published revision entry in ES.
|
|
924
853
|
*/
|
|
925
|
-
|
|
926
854
|
const esPublishedData = await getESPublishedEntryData(plugins, preparedEntryData);
|
|
927
855
|
esItems.push(esEntity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, publishedKeys), {}, {
|
|
928
856
|
index,
|
|
929
857
|
data: esPublishedData
|
|
930
858
|
})));
|
|
859
|
+
|
|
931
860
|
/**
|
|
932
861
|
* Finally, execute regular table batch.
|
|
933
862
|
*/
|
|
934
|
-
|
|
935
863
|
try {
|
|
936
864
|
await (0, _batchWrite.batchWriteAll)({
|
|
937
865
|
table: entity.table,
|
|
@@ -951,8 +879,6 @@ const createEntriesStorageOperations = params => {
|
|
|
951
879
|
/**
|
|
952
880
|
* And Elasticsearch table batch.
|
|
953
881
|
*/
|
|
954
|
-
|
|
955
|
-
|
|
956
882
|
try {
|
|
957
883
|
await (0, _batchWrite.batchWriteAll)({
|
|
958
884
|
table: esEntity.table,
|
|
@@ -966,15 +892,14 @@ const createEntriesStorageOperations = params => {
|
|
|
966
892
|
publishedStorageEntry
|
|
967
893
|
});
|
|
968
894
|
}
|
|
969
|
-
|
|
970
895
|
return initialStorageEntry;
|
|
971
896
|
};
|
|
972
|
-
|
|
973
|
-
const unpublish = async (model, params) => {
|
|
897
|
+
const unpublish = async (initialModel, params) => {
|
|
974
898
|
const {
|
|
975
899
|
entry: initialEntry,
|
|
976
900
|
storageEntry: initialStorageEntry
|
|
977
901
|
} = params;
|
|
902
|
+
const model = getStorageOperationsModel(initialModel);
|
|
978
903
|
const entry = convertEntryKeysToStorage({
|
|
979
904
|
model,
|
|
980
905
|
entry: initialEntry
|
|
@@ -983,10 +908,10 @@ const createEntriesStorageOperations = params => {
|
|
|
983
908
|
model,
|
|
984
909
|
entry: initialStorageEntry
|
|
985
910
|
});
|
|
911
|
+
|
|
986
912
|
/**
|
|
987
913
|
* We need the latest entry to check if it needs to be updated.
|
|
988
914
|
*/
|
|
989
|
-
|
|
990
915
|
const [latestStorageEntry] = await dataLoaders.getLatestRevisionByEntryId({
|
|
991
916
|
model,
|
|
992
917
|
ids: [entry.id]
|
|
@@ -1011,14 +936,12 @@ const createEntriesStorageOperations = params => {
|
|
|
1011
936
|
/**
|
|
1012
937
|
* If we are unpublishing the latest revision, let's also update the latest revision entry's status in ES.
|
|
1013
938
|
*/
|
|
1014
|
-
|
|
1015
939
|
if ((latestStorageEntry === null || latestStorageEntry === void 0 ? void 0 : latestStorageEntry.id) === entry.id) {
|
|
1016
940
|
const {
|
|
1017
941
|
index
|
|
1018
942
|
} = _configurations.configurations.es({
|
|
1019
943
|
model
|
|
1020
944
|
});
|
|
1021
|
-
|
|
1022
945
|
const preparedEntryData = (0, _helpers.prepareEntryToIndex)({
|
|
1023
946
|
plugins,
|
|
1024
947
|
model,
|
|
@@ -1033,11 +956,10 @@ const createEntriesStorageOperations = params => {
|
|
|
1033
956
|
data: esLatestData
|
|
1034
957
|
}));
|
|
1035
958
|
}
|
|
959
|
+
|
|
1036
960
|
/**
|
|
1037
961
|
* Finally, execute regular table batch.
|
|
1038
962
|
*/
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
963
|
try {
|
|
1042
964
|
await (0, _batchWrite.batchWriteAll)({
|
|
1043
965
|
table: entity.table,
|
|
@@ -1055,8 +977,6 @@ const createEntriesStorageOperations = params => {
|
|
|
1055
977
|
/**
|
|
1056
978
|
* And Elasticsearch table batch.
|
|
1057
979
|
*/
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
980
|
try {
|
|
1061
981
|
await (0, _batchWrite.batchWriteAll)({
|
|
1062
982
|
table: esEntity.table,
|
|
@@ -1068,59 +988,52 @@ const createEntriesStorageOperations = params => {
|
|
|
1068
988
|
storageEntry
|
|
1069
989
|
});
|
|
1070
990
|
}
|
|
1071
|
-
|
|
1072
991
|
return initialStorageEntry;
|
|
1073
992
|
};
|
|
1074
|
-
|
|
1075
|
-
|
|
993
|
+
const getLatestRevisionByEntryId = async (initialModel, params) => {
|
|
994
|
+
const model = getStorageOperationsModel(initialModel);
|
|
1076
995
|
const [entry] = await dataLoaders.getLatestRevisionByEntryId({
|
|
1077
996
|
model,
|
|
1078
997
|
ids: [params.id]
|
|
1079
998
|
});
|
|
1080
|
-
|
|
1081
999
|
if (!entry) {
|
|
1082
1000
|
return null;
|
|
1083
1001
|
}
|
|
1084
|
-
|
|
1085
1002
|
return convertEntryKeysFromStorage({
|
|
1086
1003
|
model,
|
|
1087
1004
|
entry
|
|
1088
1005
|
});
|
|
1089
1006
|
};
|
|
1090
|
-
|
|
1091
|
-
|
|
1007
|
+
const getPublishedRevisionByEntryId = async (initialModel, params) => {
|
|
1008
|
+
const model = getStorageOperationsModel(initialModel);
|
|
1092
1009
|
const [entry] = await dataLoaders.getPublishedRevisionByEntryId({
|
|
1093
1010
|
model,
|
|
1094
1011
|
ids: [params.id]
|
|
1095
1012
|
});
|
|
1096
|
-
|
|
1097
1013
|
if (!entry) {
|
|
1098
1014
|
return null;
|
|
1099
1015
|
}
|
|
1100
|
-
|
|
1101
1016
|
return convertEntryKeysFromStorage({
|
|
1102
1017
|
model,
|
|
1103
1018
|
entry
|
|
1104
1019
|
});
|
|
1105
1020
|
};
|
|
1106
|
-
|
|
1107
|
-
|
|
1021
|
+
const getRevisionById = async (initialModel, params) => {
|
|
1022
|
+
const model = getStorageOperationsModel(initialModel);
|
|
1108
1023
|
const [entry] = await dataLoaders.getRevisionById({
|
|
1109
1024
|
model,
|
|
1110
1025
|
ids: [params.id]
|
|
1111
1026
|
});
|
|
1112
|
-
|
|
1113
1027
|
if (!entry) {
|
|
1114
1028
|
return null;
|
|
1115
1029
|
}
|
|
1116
|
-
|
|
1117
1030
|
return convertEntryKeysFromStorage({
|
|
1118
1031
|
model,
|
|
1119
1032
|
entry
|
|
1120
1033
|
});
|
|
1121
1034
|
};
|
|
1122
|
-
|
|
1123
|
-
|
|
1035
|
+
const getRevisions = async (initialModel, params) => {
|
|
1036
|
+
const model = getStorageOperationsModel(initialModel);
|
|
1124
1037
|
const entries = await dataLoaders.getAllEntryRevisions({
|
|
1125
1038
|
model,
|
|
1126
1039
|
ids: [params.id]
|
|
@@ -1132,8 +1045,8 @@ const createEntriesStorageOperations = params => {
|
|
|
1132
1045
|
});
|
|
1133
1046
|
});
|
|
1134
1047
|
};
|
|
1135
|
-
|
|
1136
|
-
|
|
1048
|
+
const getByIds = async (initialModel, params) => {
|
|
1049
|
+
const model = getStorageOperationsModel(initialModel);
|
|
1137
1050
|
const entries = await dataLoaders.getRevisionById({
|
|
1138
1051
|
model,
|
|
1139
1052
|
ids: params.ids
|
|
@@ -1145,8 +1058,8 @@ const createEntriesStorageOperations = params => {
|
|
|
1145
1058
|
});
|
|
1146
1059
|
});
|
|
1147
1060
|
};
|
|
1148
|
-
|
|
1149
|
-
|
|
1061
|
+
const getLatestByIds = async (initialModel, params) => {
|
|
1062
|
+
const model = getStorageOperationsModel(initialModel);
|
|
1150
1063
|
const entries = await dataLoaders.getLatestRevisionByEntryId({
|
|
1151
1064
|
model,
|
|
1152
1065
|
ids: params.ids
|
|
@@ -1158,8 +1071,8 @@ const createEntriesStorageOperations = params => {
|
|
|
1158
1071
|
});
|
|
1159
1072
|
});
|
|
1160
1073
|
};
|
|
1161
|
-
|
|
1162
|
-
|
|
1074
|
+
const getPublishedByIds = async (initialModel, params) => {
|
|
1075
|
+
const model = getStorageOperationsModel(initialModel);
|
|
1163
1076
|
const entries = await dataLoaders.getPublishedRevisionByEntryId({
|
|
1164
1077
|
model,
|
|
1165
1078
|
ids: params.ids
|
|
@@ -1171,8 +1084,8 @@ const createEntriesStorageOperations = params => {
|
|
|
1171
1084
|
});
|
|
1172
1085
|
});
|
|
1173
1086
|
};
|
|
1174
|
-
|
|
1175
|
-
|
|
1087
|
+
const getPreviousRevision = async (initialModel, params) => {
|
|
1088
|
+
const model = getStorageOperationsModel(initialModel);
|
|
1176
1089
|
const {
|
|
1177
1090
|
tenant,
|
|
1178
1091
|
locale
|
|
@@ -1190,7 +1103,6 @@ const createEntriesStorageOperations = params => {
|
|
|
1190
1103
|
}),
|
|
1191
1104
|
options: {
|
|
1192
1105
|
lt: `REV#${(0, _utils.zeroPad)(version)}`,
|
|
1193
|
-
|
|
1194
1106
|
/**
|
|
1195
1107
|
* We need to have extra checks because DynamoDB will return published or latest record if there is no REV# record.
|
|
1196
1108
|
*/
|
|
@@ -1204,15 +1116,12 @@ const createEntriesStorageOperations = params => {
|
|
|
1204
1116
|
reverse: true
|
|
1205
1117
|
}
|
|
1206
1118
|
};
|
|
1207
|
-
|
|
1208
1119
|
try {
|
|
1209
1120
|
const result = await (0, _query.queryOne)(queryParams);
|
|
1210
1121
|
const entry = (0, _cleanup.cleanupItem)(entity, result);
|
|
1211
|
-
|
|
1212
1122
|
if (!entry) {
|
|
1213
1123
|
return null;
|
|
1214
1124
|
}
|
|
1215
|
-
|
|
1216
1125
|
return convertEntryKeysFromStorage({
|
|
1217
1126
|
entry,
|
|
1218
1127
|
model
|
|
@@ -1226,7 +1135,6 @@ const createEntriesStorageOperations = params => {
|
|
|
1226
1135
|
}));
|
|
1227
1136
|
}
|
|
1228
1137
|
};
|
|
1229
|
-
|
|
1230
1138
|
return {
|
|
1231
1139
|
create,
|
|
1232
1140
|
createRevisionFrom,
|
|
@@ -1247,5 +1155,4 @@ const createEntriesStorageOperations = params => {
|
|
|
1247
1155
|
getPreviousRevision
|
|
1248
1156
|
};
|
|
1249
1157
|
};
|
|
1250
|
-
|
|
1251
1158
|
exports.createEntriesStorageOperations = createEntriesStorageOperations;
|