@webiny/api-headless-cms-ddb-es 0.0.0-unstable.d4f203fa97 → 0.0.0-unstable.d65ec29d44
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 +0 -8
- package/configurations.js.map +1 -1
- package/definitions/entry.js +0 -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 +5 -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.d.ts +1 -1
- package/dynamoDb/index.js +0 -5
- package/dynamoDb/index.js.map +1 -1
- package/dynamoDb/storage/date.d.ts +2 -1
- package/dynamoDb/storage/date.js +1 -16
- package/dynamoDb/storage/date.js.map +1 -1
- package/dynamoDb/storage/longText.d.ts +1 -1
- package/dynamoDb/storage/longText.js +7 -17
- package/dynamoDb/storage/longText.js.map +1 -1
- package/dynamoDb/storage/richText.d.ts +1 -1
- package/dynamoDb/storage/richText.js +9 -29
- 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 +15 -10
- 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.d.ts +4 -0
- package/elasticsearch/indexing/longTextIndexing.js +19 -9
- 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 +13 -64
- 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.d.ts +18 -0
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js +32 -0
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js.map +1 -0
- package/operations/entry/elasticsearch/body.js +7 -29
- package/operations/entry/elasticsearch/body.js.map +1 -1
- package/operations/entry/elasticsearch/fields.js +79 -46
- package/operations/entry/elasticsearch/fields.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/applyFiltering.d.ts +3 -10
- package/operations/entry/elasticsearch/filtering/applyFiltering.js +0 -9
- package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/exec.js +36 -91
- 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 -8
- package/operations/entry/elasticsearch/filtering/path.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.d.ts +2 -0
- package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js +28 -0
- package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/plugins/index.d.ts +1 -0
- package/operations/entry/elasticsearch/filtering/plugins/index.js +13 -0
- package/operations/entry/elasticsearch/filtering/plugins/index.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.d.ts +2 -0
- package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js +65 -0
- package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.d.ts +2 -0
- package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js +48 -0
- package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js.map +1 -0
- 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.d.ts +1 -1
- package/operations/entry/elasticsearch/filtering/values.js +3 -9
- package/operations/entry/elasticsearch/filtering/values.js.map +1 -1
- package/operations/entry/elasticsearch/fullTextSearch.d.ts +4 -1
- package/operations/entry/elasticsearch/fullTextSearch.js +70 -15
- package/operations/entry/elasticsearch/fullTextSearch.js.map +1 -1
- package/operations/entry/elasticsearch/fullTextSearchFields.js +8 -35
- 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 +12 -15
- 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 +9 -1
- package/operations/entry/elasticsearch/types.js.map +1 -1
- package/operations/entry/index.js +32 -155
- 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 +0 -33
- 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 +16 -16
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.d.ts +1 -0
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js +6 -8
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchFieldPlugin.js +0 -6
- package/plugins/CmsEntryElasticsearchFieldPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.d.ts +23 -0
- package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js +28 -0
- package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js.map +1 -0
- package/plugins/CmsEntryElasticsearchIndexPlugin.js +0 -5
- package/plugins/CmsEntryElasticsearchIndexPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.d.ts +1 -0
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js +6 -12
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.d.ts +1 -0
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js +6 -8
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.d.ts +1 -0
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.js +6 -8
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.js.map +1 -1
- package/plugins/CmsEntryFilterPlugin.d.ts +49 -0
- package/plugins/CmsEntryFilterPlugin.js +24 -0
- package/plugins/CmsEntryFilterPlugin.js.map +1 -0
- package/plugins/index.d.ts +1 -0
- package/plugins/index.js +11 -12
- package/plugins/index.js.map +1 -1
- package/types.js +0 -5
- package/types.js.map +1 -1
- package/helpers/createElasticsearchQueryBody.d.ts +0 -11
- package/helpers/createElasticsearchQueryBody.js +0 -618
- package/helpers/createElasticsearchQueryBody.js.map +0 -1
- package/helpers/fields.d.ts +0 -19
- package/helpers/fields.js +0 -196
- package/helpers/fields.js.map +0 -1
- package/helpers/searchPluginsList.d.ts +0 -6
- package/helpers/searchPluginsList.js +0 -26
- package/helpers/searchPluginsList.js.map +0 -1
- package/helpers/transformValueForSearch.d.ts +0 -12
- package/helpers/transformValueForSearch.js +0 -29
- package/helpers/transformValueForSearch.js.map +0 -1
- package/operations/entry/elasticsearch/filtering/isRefFieldFiltering.d.ts +0 -8
- package/operations/entry/elasticsearch/filtering/isRefFieldFiltering.js +0 -39
- package/operations/entry/elasticsearch/filtering/isRefFieldFiltering.js.map +0 -1
- package/operations/entry/elasticsearchFields.d.ts +0 -2
- package/operations/entry/elasticsearchFields.js +0 -38
- package/operations/entry/elasticsearchFields.js.map +0 -1
|
@@ -1,44 +1,26 @@
|
|
|
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
|
-
|
|
42
24
|
const getEntryData = input => {
|
|
43
25
|
const output = (0, _objectSpread2.default)({}, input);
|
|
44
26
|
delete output["PK"];
|
|
@@ -47,7 +29,6 @@ const getEntryData = input => {
|
|
|
47
29
|
delete output["latest"];
|
|
48
30
|
return output;
|
|
49
31
|
};
|
|
50
|
-
|
|
51
32
|
const getESLatestEntryData = async (plugins, entry) => {
|
|
52
33
|
return (0, _apiElasticsearch.compress)(plugins, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, getEntryData(entry)), {}, {
|
|
53
34
|
latest: true,
|
|
@@ -55,7 +36,6 @@ const getESLatestEntryData = async (plugins, entry) => {
|
|
|
55
36
|
__type: (0, _recordType.createLatestRecordType)()
|
|
56
37
|
}));
|
|
57
38
|
};
|
|
58
|
-
|
|
59
39
|
const getESPublishedEntryData = async (plugins, entry) => {
|
|
60
40
|
return (0, _apiElasticsearch.compress)(plugins, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, getEntryData(entry)), {}, {
|
|
61
41
|
published: true,
|
|
@@ -63,8 +43,7 @@ const getESPublishedEntryData = async (plugins, entry) => {
|
|
|
63
43
|
__type: (0, _recordType.createPublishedRecordType)()
|
|
64
44
|
}));
|
|
65
45
|
};
|
|
66
|
-
|
|
67
|
-
const convertToStorageEntry = params => {
|
|
46
|
+
const convertEntryKeysToStorage = params => {
|
|
68
47
|
const {
|
|
69
48
|
model,
|
|
70
49
|
entry
|
|
@@ -77,8 +56,7 @@ const convertToStorageEntry = params => {
|
|
|
77
56
|
values
|
|
78
57
|
});
|
|
79
58
|
};
|
|
80
|
-
|
|
81
|
-
const convertFromStorageEntry = params => {
|
|
59
|
+
const convertEntryKeysFromStorage = params => {
|
|
82
60
|
const {
|
|
83
61
|
model,
|
|
84
62
|
entry
|
|
@@ -91,7 +69,6 @@ const convertFromStorageEntry = params => {
|
|
|
91
69
|
values
|
|
92
70
|
});
|
|
93
71
|
};
|
|
94
|
-
|
|
95
72
|
const createEntriesStorageOperations = params => {
|
|
96
73
|
const {
|
|
97
74
|
entity,
|
|
@@ -102,7 +79,6 @@ const createEntriesStorageOperations = params => {
|
|
|
102
79
|
const dataLoaders = new _dataLoaders.DataLoadersHandler({
|
|
103
80
|
entity
|
|
104
81
|
});
|
|
105
|
-
|
|
106
82
|
const create = async (model, params) => {
|
|
107
83
|
const {
|
|
108
84
|
entry: initialEntry,
|
|
@@ -110,11 +86,11 @@ const createEntriesStorageOperations = params => {
|
|
|
110
86
|
} = params;
|
|
111
87
|
const isPublished = initialEntry.status === "published";
|
|
112
88
|
const locked = isPublished ? true : initialEntry.locked;
|
|
113
|
-
const entry =
|
|
89
|
+
const entry = convertEntryKeysToStorage({
|
|
114
90
|
model,
|
|
115
91
|
entry: initialEntry
|
|
116
92
|
});
|
|
117
|
-
const storageEntry =
|
|
93
|
+
const storageEntry = convertEntryKeysToStorage({
|
|
118
94
|
model,
|
|
119
95
|
entry: initialStorageEntry
|
|
120
96
|
});
|
|
@@ -128,13 +104,11 @@ const createEntriesStorageOperations = params => {
|
|
|
128
104
|
locked
|
|
129
105
|
}))
|
|
130
106
|
});
|
|
131
|
-
|
|
132
107
|
const {
|
|
133
108
|
index: esIndex
|
|
134
109
|
} = _configurations.configurations.es({
|
|
135
110
|
model
|
|
136
111
|
});
|
|
137
|
-
|
|
138
112
|
const esLatestData = await getESLatestEntryData(plugins, esEntry);
|
|
139
113
|
const esPublishedData = await getESPublishedEntryData(plugins, esEntry);
|
|
140
114
|
const revisionKeys = {
|
|
@@ -170,7 +144,6 @@ const createEntriesStorageOperations = params => {
|
|
|
170
144
|
}, latestKeys), {}, {
|
|
171
145
|
TYPE: (0, _recordType.createLatestRecordType)()
|
|
172
146
|
}))];
|
|
173
|
-
|
|
174
147
|
if (isPublished) {
|
|
175
148
|
items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
176
149
|
locked
|
|
@@ -178,7 +151,6 @@ const createEntriesStorageOperations = params => {
|
|
|
178
151
|
TYPE: (0, _recordType.createPublishedRecordType)()
|
|
179
152
|
})));
|
|
180
153
|
}
|
|
181
|
-
|
|
182
154
|
try {
|
|
183
155
|
await (0, _batchWrite.batchWriteAll)({
|
|
184
156
|
table: entity.table,
|
|
@@ -194,19 +166,16 @@ const createEntriesStorageOperations = params => {
|
|
|
194
166
|
storageEntry
|
|
195
167
|
});
|
|
196
168
|
}
|
|
197
|
-
|
|
198
169
|
const esItems = [esEntity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, latestKeys), {}, {
|
|
199
170
|
index: esIndex,
|
|
200
171
|
data: esLatestData
|
|
201
172
|
}))];
|
|
202
|
-
|
|
203
173
|
if (isPublished) {
|
|
204
174
|
esItems.push(esEntity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, publishedKeys), {}, {
|
|
205
175
|
index: esIndex,
|
|
206
176
|
data: esPublishedData
|
|
207
177
|
})));
|
|
208
178
|
}
|
|
209
|
-
|
|
210
179
|
try {
|
|
211
180
|
await (0, _batchWrite.batchWriteAll)({
|
|
212
181
|
table: esEntity.table,
|
|
@@ -219,20 +188,18 @@ const createEntriesStorageOperations = params => {
|
|
|
219
188
|
esEntry
|
|
220
189
|
});
|
|
221
190
|
}
|
|
222
|
-
|
|
223
191
|
return initialStorageEntry;
|
|
224
192
|
};
|
|
225
|
-
|
|
226
193
|
const createRevisionFrom = async (model, params) => {
|
|
227
194
|
const {
|
|
228
195
|
entry: initialEntry,
|
|
229
196
|
storageEntry: initialStorageEntry
|
|
230
197
|
} = params;
|
|
231
|
-
const entry =
|
|
198
|
+
const entry = convertEntryKeysToStorage({
|
|
232
199
|
model,
|
|
233
200
|
entry: initialEntry
|
|
234
201
|
});
|
|
235
|
-
const storageEntry =
|
|
202
|
+
const storageEntry = convertEntryKeysToStorage({
|
|
236
203
|
model,
|
|
237
204
|
entry: initialStorageEntry
|
|
238
205
|
});
|
|
@@ -264,13 +231,11 @@ const createEntriesStorageOperations = params => {
|
|
|
264
231
|
}, revisionKeys)), entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
265
232
|
TYPE: (0, _recordType.createLatestRecordType)()
|
|
266
233
|
}, latestKeys))];
|
|
267
|
-
|
|
268
234
|
const {
|
|
269
235
|
index
|
|
270
236
|
} = _configurations.configurations.es({
|
|
271
237
|
model
|
|
272
238
|
});
|
|
273
|
-
|
|
274
239
|
try {
|
|
275
240
|
await (0, _batchWrite.batchWriteAll)({
|
|
276
241
|
table: entity.table,
|
|
@@ -289,8 +254,6 @@ const createEntriesStorageOperations = params => {
|
|
|
289
254
|
/**
|
|
290
255
|
* Update the "latest" entry item in the Elasticsearch
|
|
291
256
|
*/
|
|
292
|
-
|
|
293
|
-
|
|
294
257
|
try {
|
|
295
258
|
await esEntity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, latestKeys), {}, {
|
|
296
259
|
index,
|
|
@@ -305,21 +268,18 @@ const createEntriesStorageOperations = params => {
|
|
|
305
268
|
/**
|
|
306
269
|
* There are no modifications on the entry created so just return the data.
|
|
307
270
|
*/
|
|
308
|
-
|
|
309
|
-
|
|
310
271
|
return initialStorageEntry;
|
|
311
272
|
};
|
|
312
|
-
|
|
313
273
|
const update = async (model, params) => {
|
|
314
274
|
const {
|
|
315
275
|
entry: initialEntry,
|
|
316
276
|
storageEntry: initialStorageEntry
|
|
317
277
|
} = params;
|
|
318
|
-
const entry =
|
|
278
|
+
const entry = convertEntryKeysToStorage({
|
|
319
279
|
model,
|
|
320
280
|
entry: initialEntry
|
|
321
281
|
});
|
|
322
|
-
const storageEntry =
|
|
282
|
+
const storageEntry = convertEntryKeysToStorage({
|
|
323
283
|
model,
|
|
324
284
|
entry: initialStorageEntry
|
|
325
285
|
});
|
|
@@ -349,10 +309,10 @@ const createEntriesStorageOperations = params => {
|
|
|
349
309
|
}),
|
|
350
310
|
SK: (0, _keys.createPublishedSortKey)()
|
|
351
311
|
};
|
|
312
|
+
|
|
352
313
|
/**
|
|
353
314
|
* We need the latest entry to check if it needs to be updated.
|
|
354
315
|
*/
|
|
355
|
-
|
|
356
316
|
const [latestStorageEntry] = await dataLoaders.getLatestRevisionByEntryId({
|
|
357
317
|
model,
|
|
358
318
|
ids: [entry.id]
|
|
@@ -366,7 +326,6 @@ const createEntriesStorageOperations = params => {
|
|
|
366
326
|
}, revisionKeys), {}, {
|
|
367
327
|
TYPE: (0, _recordType.createRecordType)()
|
|
368
328
|
}))];
|
|
369
|
-
|
|
370
329
|
if (isPublished) {
|
|
371
330
|
items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
372
331
|
locked
|
|
@@ -374,9 +333,7 @@ const createEntriesStorageOperations = params => {
|
|
|
374
333
|
TYPE: (0, _recordType.createPublishedRecordType)()
|
|
375
334
|
})));
|
|
376
335
|
}
|
|
377
|
-
|
|
378
336
|
const esItems = [];
|
|
379
|
-
|
|
380
337
|
const {
|
|
381
338
|
index: esIndex
|
|
382
339
|
} = _configurations.configurations.es({
|
|
@@ -385,15 +342,11 @@ const createEntriesStorageOperations = params => {
|
|
|
385
342
|
/**
|
|
386
343
|
* Variable for the elasticsearch entry so we do not convert it more than once
|
|
387
344
|
*/
|
|
388
|
-
|
|
389
|
-
|
|
390
345
|
let esEntry = undefined;
|
|
391
346
|
/**
|
|
392
347
|
* If the latest entry is the one being updated, we need to create a new latest entry records.
|
|
393
348
|
*/
|
|
394
|
-
|
|
395
349
|
let elasticsearchLatestData = null;
|
|
396
|
-
|
|
397
350
|
if ((latestStorageEntry === null || latestStorageEntry === void 0 ? void 0 : latestStorageEntry.id) === entry.id) {
|
|
398
351
|
/**
|
|
399
352
|
* First we update the regular DynamoDB table
|
|
@@ -404,7 +357,6 @@ const createEntriesStorageOperations = params => {
|
|
|
404
357
|
/**
|
|
405
358
|
* And then update the Elasticsearch table to propagate changes to the Elasticsearch
|
|
406
359
|
*/
|
|
407
|
-
|
|
408
360
|
esEntry = (0, _helpers.prepareEntryToIndex)({
|
|
409
361
|
plugins,
|
|
410
362
|
model,
|
|
@@ -421,9 +373,7 @@ const createEntriesStorageOperations = params => {
|
|
|
421
373
|
data: elasticsearchLatestData
|
|
422
374
|
})));
|
|
423
375
|
}
|
|
424
|
-
|
|
425
376
|
let elasticsearchPublishedData = null;
|
|
426
|
-
|
|
427
377
|
if (isPublished && (publishedStorageEntry === null || publishedStorageEntry === void 0 ? void 0 : publishedStorageEntry.id) === entry.id) {
|
|
428
378
|
if (!elasticsearchLatestData) {
|
|
429
379
|
/**
|
|
@@ -441,7 +391,6 @@ const createEntriesStorageOperations = params => {
|
|
|
441
391
|
}))
|
|
442
392
|
});
|
|
443
393
|
}
|
|
444
|
-
|
|
445
394
|
elasticsearchPublishedData = await getESPublishedEntryData(plugins, esEntry);
|
|
446
395
|
} else {
|
|
447
396
|
elasticsearchPublishedData = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, elasticsearchLatestData), {}, {
|
|
@@ -451,13 +400,11 @@ const createEntriesStorageOperations = params => {
|
|
|
451
400
|
});
|
|
452
401
|
delete elasticsearchPublishedData.latest;
|
|
453
402
|
}
|
|
454
|
-
|
|
455
403
|
esItems.push(esEntity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, publishedKeys), {}, {
|
|
456
404
|
index: esIndex,
|
|
457
405
|
data: elasticsearchPublishedData
|
|
458
406
|
})));
|
|
459
407
|
}
|
|
460
|
-
|
|
461
408
|
try {
|
|
462
409
|
await (0, _batchWrite.batchWriteAll)({
|
|
463
410
|
table: entity.table,
|
|
@@ -473,11 +420,9 @@ const createEntriesStorageOperations = params => {
|
|
|
473
420
|
storageEntry
|
|
474
421
|
});
|
|
475
422
|
}
|
|
476
|
-
|
|
477
423
|
if (esItems.length === 0) {
|
|
478
424
|
return initialStorageEntry;
|
|
479
425
|
}
|
|
480
|
-
|
|
481
426
|
try {
|
|
482
427
|
await (0, _batchWrite.batchWriteAll)({
|
|
483
428
|
table: esEntity.table,
|
|
@@ -489,10 +434,8 @@ const createEntriesStorageOperations = params => {
|
|
|
489
434
|
entry
|
|
490
435
|
});
|
|
491
436
|
}
|
|
492
|
-
|
|
493
437
|
return initialStorageEntry;
|
|
494
438
|
};
|
|
495
|
-
|
|
496
439
|
const deleteEntry = async (model, params) => {
|
|
497
440
|
const {
|
|
498
441
|
entry
|
|
@@ -528,7 +471,6 @@ const createEntriesStorageOperations = params => {
|
|
|
528
471
|
SK: item.SK
|
|
529
472
|
});
|
|
530
473
|
});
|
|
531
|
-
|
|
532
474
|
try {
|
|
533
475
|
await (0, _batchWrite.batchWriteAll)({
|
|
534
476
|
table: entity.table,
|
|
@@ -543,7 +485,6 @@ const createEntriesStorageOperations = params => {
|
|
|
543
485
|
entry
|
|
544
486
|
});
|
|
545
487
|
}
|
|
546
|
-
|
|
547
488
|
try {
|
|
548
489
|
await (0, _batchWrite.batchWriteAll)({
|
|
549
490
|
table: esEntity.table,
|
|
@@ -556,7 +497,6 @@ const createEntriesStorageOperations = params => {
|
|
|
556
497
|
});
|
|
557
498
|
}
|
|
558
499
|
};
|
|
559
|
-
|
|
560
500
|
const deleteRevision = async (model, params) => {
|
|
561
501
|
const {
|
|
562
502
|
entry,
|
|
@@ -568,7 +508,6 @@ const createEntriesStorageOperations = params => {
|
|
|
568
508
|
locale: model.locale,
|
|
569
509
|
tenant: model.tenant
|
|
570
510
|
});
|
|
571
|
-
|
|
572
511
|
const {
|
|
573
512
|
index
|
|
574
513
|
} = _configurations.configurations.es({
|
|
@@ -577,8 +516,6 @@ const createEntriesStorageOperations = params => {
|
|
|
577
516
|
/**
|
|
578
517
|
* We need published entry to delete it if necessary.
|
|
579
518
|
*/
|
|
580
|
-
|
|
581
|
-
|
|
582
519
|
const [publishedStorageEntry] = await dataLoaders.getPublishedRevisionByEntryId({
|
|
583
520
|
model,
|
|
584
521
|
ids: [entry.id]
|
|
@@ -586,7 +523,6 @@ const createEntriesStorageOperations = params => {
|
|
|
586
523
|
/**
|
|
587
524
|
* We need to delete all existing records of the given entry revision.
|
|
588
525
|
*/
|
|
589
|
-
|
|
590
526
|
const items = [
|
|
591
527
|
/**
|
|
592
528
|
* Delete records of given entry revision.
|
|
@@ -596,10 +532,10 @@ const createEntriesStorageOperations = params => {
|
|
|
596
532
|
SK: (0, _keys.createRevisionSortKey)(entry)
|
|
597
533
|
})];
|
|
598
534
|
const esItems = [];
|
|
535
|
+
|
|
599
536
|
/**
|
|
600
537
|
* If revision we are deleting is the published one as well, we need to delete those records as well.
|
|
601
538
|
*/
|
|
602
|
-
|
|
603
539
|
if ((publishedStorageEntry === null || publishedStorageEntry === void 0 ? void 0 : publishedStorageEntry.id) === entry.id) {
|
|
604
540
|
items.push(entity.deleteBatch({
|
|
605
541
|
PK: partitionKey,
|
|
@@ -610,7 +546,6 @@ const createEntriesStorageOperations = params => {
|
|
|
610
546
|
SK: (0, _keys.createPublishedSortKey)()
|
|
611
547
|
}));
|
|
612
548
|
}
|
|
613
|
-
|
|
614
549
|
if (latestEntry && latestStorageEntry) {
|
|
615
550
|
const esEntry = (0, _helpers.prepareEntryToIndex)({
|
|
616
551
|
plugins,
|
|
@@ -622,7 +557,6 @@ const createEntriesStorageOperations = params => {
|
|
|
622
557
|
/**
|
|
623
558
|
* In the end we need to set the new latest entry
|
|
624
559
|
*/
|
|
625
|
-
|
|
626
560
|
items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, latestStorageEntry), {}, {
|
|
627
561
|
PK: partitionKey,
|
|
628
562
|
SK: (0, _keys.createLatestSortKey)(),
|
|
@@ -635,7 +569,6 @@ const createEntriesStorageOperations = params => {
|
|
|
635
569
|
data: esLatestData
|
|
636
570
|
}));
|
|
637
571
|
}
|
|
638
|
-
|
|
639
572
|
try {
|
|
640
573
|
await (0, _batchWrite.batchWriteAll)({
|
|
641
574
|
table: entity.table,
|
|
@@ -652,11 +585,9 @@ const createEntriesStorageOperations = params => {
|
|
|
652
585
|
latestStorageEntry
|
|
653
586
|
});
|
|
654
587
|
}
|
|
655
|
-
|
|
656
588
|
if (esItems.length === 0) {
|
|
657
589
|
return;
|
|
658
590
|
}
|
|
659
|
-
|
|
660
591
|
try {
|
|
661
592
|
await (0, _batchWrite.batchWriteAll)({
|
|
662
593
|
table: esEntity.table,
|
|
@@ -671,23 +602,18 @@ const createEntriesStorageOperations = params => {
|
|
|
671
602
|
});
|
|
672
603
|
}
|
|
673
604
|
};
|
|
674
|
-
|
|
675
605
|
const list = async (model, params) => {
|
|
676
606
|
var _response, _response$body;
|
|
677
|
-
|
|
678
607
|
const limit = (0, _apiElasticsearch.createLimit)(params.limit, 50);
|
|
679
|
-
|
|
680
608
|
const {
|
|
681
609
|
index
|
|
682
610
|
} = _configurations.configurations.es({
|
|
683
611
|
model
|
|
684
612
|
});
|
|
685
|
-
|
|
686
613
|
try {
|
|
687
614
|
const result = await elasticsearch.indices.exists({
|
|
688
615
|
index
|
|
689
616
|
});
|
|
690
|
-
|
|
691
617
|
if (!(result !== null && result !== void 0 && result.body)) {
|
|
692
618
|
return {
|
|
693
619
|
hasMoreItems: false,
|
|
@@ -702,7 +628,6 @@ const createEntriesStorageOperations = params => {
|
|
|
702
628
|
index
|
|
703
629
|
});
|
|
704
630
|
}
|
|
705
|
-
|
|
706
631
|
const body = (0, _body.createElasticsearchBody)({
|
|
707
632
|
model,
|
|
708
633
|
params: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
|
|
@@ -712,7 +637,6 @@ const createEntriesStorageOperations = params => {
|
|
|
712
637
|
plugins
|
|
713
638
|
});
|
|
714
639
|
let response;
|
|
715
|
-
|
|
716
640
|
try {
|
|
717
641
|
response = await elasticsearch.search({
|
|
718
642
|
index,
|
|
@@ -726,7 +650,6 @@ const createEntriesStorageOperations = params => {
|
|
|
726
650
|
model
|
|
727
651
|
});
|
|
728
652
|
}
|
|
729
|
-
|
|
730
653
|
const {
|
|
731
654
|
hits,
|
|
732
655
|
total
|
|
@@ -736,13 +659,12 @@ const createEntriesStorageOperations = params => {
|
|
|
736
659
|
model,
|
|
737
660
|
entries: hits.map(item => item._source)
|
|
738
661
|
}).map(item => {
|
|
739
|
-
return
|
|
662
|
+
return convertEntryKeysFromStorage({
|
|
740
663
|
model,
|
|
741
664
|
entry: item
|
|
742
665
|
});
|
|
743
666
|
});
|
|
744
667
|
const hasMoreItems = items.length > limit;
|
|
745
|
-
|
|
746
668
|
if (hasMoreItems) {
|
|
747
669
|
/**
|
|
748
670
|
* Remove the last item from results, we don't want to include it.
|
|
@@ -753,8 +675,6 @@ const createEntriesStorageOperations = params => {
|
|
|
753
675
|
* Cursor is the `sort` value of the last item in the array.
|
|
754
676
|
* https://www.elastic.co/guide/en/elasticsearch/reference/current/paginate-search-results.html#search-after
|
|
755
677
|
*/
|
|
756
|
-
|
|
757
|
-
|
|
758
678
|
const cursor = items.length > 0 ? (0, _apiElasticsearch.encodeCursor)(hits[items.length - 1].sort) || null : null;
|
|
759
679
|
return {
|
|
760
680
|
hasMoreItems,
|
|
@@ -763,7 +683,6 @@ const createEntriesStorageOperations = params => {
|
|
|
763
683
|
items
|
|
764
684
|
};
|
|
765
685
|
};
|
|
766
|
-
|
|
767
686
|
const get = async (model, params) => {
|
|
768
687
|
const {
|
|
769
688
|
items
|
|
@@ -772,24 +691,23 @@ const createEntriesStorageOperations = params => {
|
|
|
772
691
|
}));
|
|
773
692
|
return items.shift() || null;
|
|
774
693
|
};
|
|
775
|
-
|
|
776
694
|
const publish = async (model, params) => {
|
|
777
695
|
const {
|
|
778
696
|
entry: initialEntry,
|
|
779
697
|
storageEntry: initialStorageEntry
|
|
780
698
|
} = params;
|
|
781
|
-
const entry =
|
|
699
|
+
const entry = convertEntryKeysToStorage({
|
|
782
700
|
model,
|
|
783
701
|
entry: initialEntry
|
|
784
702
|
});
|
|
785
|
-
const storageEntry =
|
|
703
|
+
const storageEntry = convertEntryKeysToStorage({
|
|
786
704
|
model,
|
|
787
705
|
entry: initialStorageEntry
|
|
788
706
|
});
|
|
707
|
+
|
|
789
708
|
/**
|
|
790
709
|
* We need currently published entry to check if need to remove it.
|
|
791
710
|
*/
|
|
792
|
-
|
|
793
711
|
const [publishedStorageEntry] = await dataLoaders.getPublishedRevisionByEntryId({
|
|
794
712
|
model,
|
|
795
713
|
ids: [entry.id]
|
|
@@ -819,7 +737,6 @@ const createEntriesStorageOperations = params => {
|
|
|
819
737
|
SK: (0, _keys.createPublishedSortKey)()
|
|
820
738
|
};
|
|
821
739
|
let latestEsEntry = null;
|
|
822
|
-
|
|
823
740
|
try {
|
|
824
741
|
latestEsEntry = await (0, _get.get)({
|
|
825
742
|
entity: esEntity,
|
|
@@ -832,18 +749,15 @@ const createEntriesStorageOperations = params => {
|
|
|
832
749
|
publishedKeys: publishedKeys
|
|
833
750
|
});
|
|
834
751
|
}
|
|
835
|
-
|
|
836
752
|
const items = [entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), revisionKeys), {}, {
|
|
837
753
|
TYPE: (0, _recordType.createRecordType)()
|
|
838
754
|
}))];
|
|
839
755
|
const esItems = [];
|
|
840
|
-
|
|
841
756
|
const {
|
|
842
757
|
index
|
|
843
758
|
} = _configurations.configurations.es({
|
|
844
759
|
model
|
|
845
760
|
});
|
|
846
|
-
|
|
847
761
|
if (publishedStorageEntry && publishedStorageEntry.id !== entry.id) {
|
|
848
762
|
/**
|
|
849
763
|
* If there is a `published` entry already, we need to set it to `unpublished`. We need to
|
|
@@ -871,28 +785,23 @@ const createEntriesStorageOperations = params => {
|
|
|
871
785
|
/**
|
|
872
786
|
* Update the helper item in DB with the new published entry
|
|
873
787
|
*/
|
|
874
|
-
|
|
875
|
-
|
|
876
788
|
items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), publishedKeys), {}, {
|
|
877
789
|
TYPE: (0, _recordType.createPublishedRecordType)()
|
|
878
790
|
})));
|
|
791
|
+
|
|
879
792
|
/**
|
|
880
793
|
* We need the latest entry to check if it needs to be updated as well in the Elasticsearch.
|
|
881
794
|
*/
|
|
882
|
-
|
|
883
795
|
const [latestStorageEntry] = await dataLoaders.getLatestRevisionByEntryId({
|
|
884
796
|
model,
|
|
885
797
|
ids: [entry.id]
|
|
886
798
|
});
|
|
887
|
-
|
|
888
799
|
if ((latestStorageEntry === null || latestStorageEntry === void 0 ? void 0 : latestStorageEntry.id) === entry.id) {
|
|
889
800
|
items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), latestKeys)));
|
|
890
801
|
}
|
|
891
802
|
/**
|
|
892
803
|
* If we are publishing the latest revision, let's also update the latest revision's status in ES.
|
|
893
804
|
*/
|
|
894
|
-
|
|
895
|
-
|
|
896
805
|
if (latestEsEntry && (latestStorageEntry === null || latestStorageEntry === void 0 ? void 0 : latestStorageEntry.id) === entry.id) {
|
|
897
806
|
/**
|
|
898
807
|
* Need to decompress the data from Elasticsearch DynamoDB table.
|
|
@@ -904,15 +813,14 @@ const createEntriesStorageOperations = params => {
|
|
|
904
813
|
index,
|
|
905
814
|
PK: (0, _keys.createPartitionKey)(latestEsEntryDataDecompressed),
|
|
906
815
|
SK: (0, _keys.createLatestSortKey)(),
|
|
907
|
-
data: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, latestEsEntryDataDecompressed), {}, {
|
|
816
|
+
data: await getESLatestEntryData(plugins, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, latestEsEntryDataDecompressed), {}, {
|
|
908
817
|
status: _types.CONTENT_ENTRY_STATUS.PUBLISHED,
|
|
909
818
|
locked: true,
|
|
910
819
|
savedOn: entry.savedOn,
|
|
911
820
|
publishedOn: entry.publishedOn
|
|
912
|
-
})
|
|
821
|
+
}))
|
|
913
822
|
}));
|
|
914
823
|
}
|
|
915
|
-
|
|
916
824
|
const preparedEntryData = (0, _helpers.prepareEntryToIndex)({
|
|
917
825
|
plugins,
|
|
918
826
|
model,
|
|
@@ -922,16 +830,15 @@ const createEntriesStorageOperations = params => {
|
|
|
922
830
|
/**
|
|
923
831
|
* Update the published revision entry in ES.
|
|
924
832
|
*/
|
|
925
|
-
|
|
926
|
-
const esLatestData = await getESPublishedEntryData(plugins, preparedEntryData);
|
|
833
|
+
const esPublishedData = await getESPublishedEntryData(plugins, preparedEntryData);
|
|
927
834
|
esItems.push(esEntity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, publishedKeys), {}, {
|
|
928
835
|
index,
|
|
929
|
-
data:
|
|
836
|
+
data: esPublishedData
|
|
930
837
|
})));
|
|
838
|
+
|
|
931
839
|
/**
|
|
932
840
|
* Finally, execute regular table batch.
|
|
933
841
|
*/
|
|
934
|
-
|
|
935
842
|
try {
|
|
936
843
|
await (0, _batchWrite.batchWriteAll)({
|
|
937
844
|
table: entity.table,
|
|
@@ -951,8 +858,6 @@ const createEntriesStorageOperations = params => {
|
|
|
951
858
|
/**
|
|
952
859
|
* And Elasticsearch table batch.
|
|
953
860
|
*/
|
|
954
|
-
|
|
955
|
-
|
|
956
861
|
try {
|
|
957
862
|
await (0, _batchWrite.batchWriteAll)({
|
|
958
863
|
table: esEntity.table,
|
|
@@ -966,27 +871,25 @@ const createEntriesStorageOperations = params => {
|
|
|
966
871
|
publishedStorageEntry
|
|
967
872
|
});
|
|
968
873
|
}
|
|
969
|
-
|
|
970
874
|
return initialStorageEntry;
|
|
971
875
|
};
|
|
972
|
-
|
|
973
876
|
const unpublish = async (model, params) => {
|
|
974
877
|
const {
|
|
975
878
|
entry: initialEntry,
|
|
976
879
|
storageEntry: initialStorageEntry
|
|
977
880
|
} = params;
|
|
978
|
-
const entry =
|
|
881
|
+
const entry = convertEntryKeysToStorage({
|
|
979
882
|
model,
|
|
980
883
|
entry: initialEntry
|
|
981
884
|
});
|
|
982
|
-
const storageEntry =
|
|
885
|
+
const storageEntry = convertEntryKeysToStorage({
|
|
983
886
|
model,
|
|
984
887
|
entry: initialStorageEntry
|
|
985
888
|
});
|
|
889
|
+
|
|
986
890
|
/**
|
|
987
891
|
* We need the latest entry to check if it needs to be updated.
|
|
988
892
|
*/
|
|
989
|
-
|
|
990
893
|
const [latestStorageEntry] = await dataLoaders.getLatestRevisionByEntryId({
|
|
991
894
|
model,
|
|
992
895
|
ids: [entry.id]
|
|
@@ -1011,14 +914,12 @@ const createEntriesStorageOperations = params => {
|
|
|
1011
914
|
/**
|
|
1012
915
|
* If we are unpublishing the latest revision, let's also update the latest revision entry's status in ES.
|
|
1013
916
|
*/
|
|
1014
|
-
|
|
1015
917
|
if ((latestStorageEntry === null || latestStorageEntry === void 0 ? void 0 : latestStorageEntry.id) === entry.id) {
|
|
1016
918
|
const {
|
|
1017
919
|
index
|
|
1018
920
|
} = _configurations.configurations.es({
|
|
1019
921
|
model
|
|
1020
922
|
});
|
|
1021
|
-
|
|
1022
923
|
const preparedEntryData = (0, _helpers.prepareEntryToIndex)({
|
|
1023
924
|
plugins,
|
|
1024
925
|
model,
|
|
@@ -1033,11 +934,10 @@ const createEntriesStorageOperations = params => {
|
|
|
1033
934
|
data: esLatestData
|
|
1034
935
|
}));
|
|
1035
936
|
}
|
|
937
|
+
|
|
1036
938
|
/**
|
|
1037
939
|
* Finally, execute regular table batch.
|
|
1038
940
|
*/
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
941
|
try {
|
|
1042
942
|
await (0, _batchWrite.batchWriteAll)({
|
|
1043
943
|
table: entity.table,
|
|
@@ -1055,8 +955,6 @@ const createEntriesStorageOperations = params => {
|
|
|
1055
955
|
/**
|
|
1056
956
|
* And Elasticsearch table batch.
|
|
1057
957
|
*/
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
958
|
try {
|
|
1061
959
|
await (0, _batchWrite.batchWriteAll)({
|
|
1062
960
|
table: esEntity.table,
|
|
@@ -1068,110 +966,95 @@ const createEntriesStorageOperations = params => {
|
|
|
1068
966
|
storageEntry
|
|
1069
967
|
});
|
|
1070
968
|
}
|
|
1071
|
-
|
|
1072
969
|
return initialStorageEntry;
|
|
1073
970
|
};
|
|
1074
|
-
|
|
1075
971
|
const getLatestRevisionByEntryId = async (model, params) => {
|
|
1076
972
|
const [entry] = await dataLoaders.getLatestRevisionByEntryId({
|
|
1077
973
|
model,
|
|
1078
974
|
ids: [params.id]
|
|
1079
975
|
});
|
|
1080
|
-
|
|
1081
976
|
if (!entry) {
|
|
1082
977
|
return null;
|
|
1083
978
|
}
|
|
1084
|
-
|
|
1085
|
-
return convertFromStorageEntry({
|
|
979
|
+
return convertEntryKeysFromStorage({
|
|
1086
980
|
model,
|
|
1087
981
|
entry
|
|
1088
982
|
});
|
|
1089
983
|
};
|
|
1090
|
-
|
|
1091
984
|
const getPublishedRevisionByEntryId = async (model, params) => {
|
|
1092
985
|
const [entry] = await dataLoaders.getPublishedRevisionByEntryId({
|
|
1093
986
|
model,
|
|
1094
987
|
ids: [params.id]
|
|
1095
988
|
});
|
|
1096
|
-
|
|
1097
989
|
if (!entry) {
|
|
1098
990
|
return null;
|
|
1099
991
|
}
|
|
1100
|
-
|
|
1101
|
-
return convertFromStorageEntry({
|
|
992
|
+
return convertEntryKeysFromStorage({
|
|
1102
993
|
model,
|
|
1103
994
|
entry
|
|
1104
995
|
});
|
|
1105
996
|
};
|
|
1106
|
-
|
|
1107
997
|
const getRevisionById = async (model, params) => {
|
|
1108
998
|
const [entry] = await dataLoaders.getRevisionById({
|
|
1109
999
|
model,
|
|
1110
1000
|
ids: [params.id]
|
|
1111
1001
|
});
|
|
1112
|
-
|
|
1113
1002
|
if (!entry) {
|
|
1114
1003
|
return null;
|
|
1115
1004
|
}
|
|
1116
|
-
|
|
1117
|
-
return convertFromStorageEntry({
|
|
1005
|
+
return convertEntryKeysFromStorage({
|
|
1118
1006
|
model,
|
|
1119
1007
|
entry
|
|
1120
1008
|
});
|
|
1121
1009
|
};
|
|
1122
|
-
|
|
1123
1010
|
const getRevisions = async (model, params) => {
|
|
1124
1011
|
const entries = await dataLoaders.getAllEntryRevisions({
|
|
1125
1012
|
model,
|
|
1126
1013
|
ids: [params.id]
|
|
1127
1014
|
});
|
|
1128
1015
|
return entries.map(entry => {
|
|
1129
|
-
return
|
|
1016
|
+
return convertEntryKeysFromStorage({
|
|
1130
1017
|
model,
|
|
1131
1018
|
entry
|
|
1132
1019
|
});
|
|
1133
1020
|
});
|
|
1134
1021
|
};
|
|
1135
|
-
|
|
1136
1022
|
const getByIds = async (model, params) => {
|
|
1137
1023
|
const entries = await dataLoaders.getRevisionById({
|
|
1138
1024
|
model,
|
|
1139
1025
|
ids: params.ids
|
|
1140
1026
|
});
|
|
1141
1027
|
return entries.map(entry => {
|
|
1142
|
-
return
|
|
1028
|
+
return convertEntryKeysFromStorage({
|
|
1143
1029
|
model,
|
|
1144
1030
|
entry
|
|
1145
1031
|
});
|
|
1146
1032
|
});
|
|
1147
1033
|
};
|
|
1148
|
-
|
|
1149
1034
|
const getLatestByIds = async (model, params) => {
|
|
1150
1035
|
const entries = await dataLoaders.getLatestRevisionByEntryId({
|
|
1151
1036
|
model,
|
|
1152
1037
|
ids: params.ids
|
|
1153
1038
|
});
|
|
1154
1039
|
return entries.map(entry => {
|
|
1155
|
-
return
|
|
1040
|
+
return convertEntryKeysFromStorage({
|
|
1156
1041
|
model,
|
|
1157
1042
|
entry
|
|
1158
1043
|
});
|
|
1159
1044
|
});
|
|
1160
1045
|
};
|
|
1161
|
-
|
|
1162
1046
|
const getPublishedByIds = async (model, params) => {
|
|
1163
1047
|
const entries = await dataLoaders.getPublishedRevisionByEntryId({
|
|
1164
1048
|
model,
|
|
1165
1049
|
ids: params.ids
|
|
1166
1050
|
});
|
|
1167
1051
|
return entries.map(entry => {
|
|
1168
|
-
return
|
|
1052
|
+
return convertEntryKeysFromStorage({
|
|
1169
1053
|
model,
|
|
1170
1054
|
entry
|
|
1171
1055
|
});
|
|
1172
1056
|
});
|
|
1173
1057
|
};
|
|
1174
|
-
|
|
1175
1058
|
const getPreviousRevision = async (model, params) => {
|
|
1176
1059
|
const {
|
|
1177
1060
|
tenant,
|
|
@@ -1190,7 +1073,6 @@ const createEntriesStorageOperations = params => {
|
|
|
1190
1073
|
}),
|
|
1191
1074
|
options: {
|
|
1192
1075
|
lt: `REV#${(0, _utils.zeroPad)(version)}`,
|
|
1193
|
-
|
|
1194
1076
|
/**
|
|
1195
1077
|
* We need to have extra checks because DynamoDB will return published or latest record if there is no REV# record.
|
|
1196
1078
|
*/
|
|
@@ -1204,16 +1086,13 @@ const createEntriesStorageOperations = params => {
|
|
|
1204
1086
|
reverse: true
|
|
1205
1087
|
}
|
|
1206
1088
|
};
|
|
1207
|
-
|
|
1208
1089
|
try {
|
|
1209
1090
|
const result = await (0, _query.queryOne)(queryParams);
|
|
1210
1091
|
const entry = (0, _cleanup.cleanupItem)(entity, result);
|
|
1211
|
-
|
|
1212
1092
|
if (!entry) {
|
|
1213
1093
|
return null;
|
|
1214
1094
|
}
|
|
1215
|
-
|
|
1216
|
-
return convertFromStorageEntry({
|
|
1095
|
+
return convertEntryKeysFromStorage({
|
|
1217
1096
|
entry,
|
|
1218
1097
|
model
|
|
1219
1098
|
});
|
|
@@ -1226,7 +1105,6 @@ const createEntriesStorageOperations = params => {
|
|
|
1226
1105
|
}));
|
|
1227
1106
|
}
|
|
1228
1107
|
};
|
|
1229
|
-
|
|
1230
1108
|
return {
|
|
1231
1109
|
create,
|
|
1232
1110
|
createRevisionFrom,
|
|
@@ -1247,5 +1125,4 @@ const createEntriesStorageOperations = params => {
|
|
|
1247
1125
|
getPreviousRevision
|
|
1248
1126
|
};
|
|
1249
1127
|
};
|
|
1250
|
-
|
|
1251
1128
|
exports.createEntriesStorageOperations = createEntriesStorageOperations;
|