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