@webiny/api-headless-cms-ddb-es 0.0.0-mt-3 → 0.0.0-unstable.40876133bb
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/configurations.d.ts +2 -2
- package/configurations.js +18 -7
- package/configurations.js.map +1 -0
- package/definitions/entry.d.ts +2 -2
- package/definitions/entry.js +6 -7
- package/definitions/entry.js.map +1 -0
- package/definitions/entryElasticsearch.d.ts +2 -2
- package/definitions/entryElasticsearch.js +3 -7
- package/definitions/entryElasticsearch.js.map +1 -0
- package/definitions/group.d.ts +2 -2
- package/definitions/group.js +3 -7
- package/definitions/group.js.map +1 -0
- package/definitions/model.d.ts +2 -2
- package/definitions/model.js +3 -7
- package/definitions/model.js.map +1 -0
- package/definitions/settings.d.ts +2 -2
- package/definitions/settings.js +3 -7
- package/definitions/settings.js.map +1 -0
- package/definitions/system.d.ts +2 -2
- package/definitions/system.js +3 -7
- package/definitions/system.js.map +1 -0
- package/definitions/table.d.ts +2 -2
- package/definitions/table.js.map +1 -0
- package/definitions/tableElasticsearch.d.ts +2 -2
- package/definitions/tableElasticsearch.js.map +1 -0
- package/dynamoDb/index.d.ts +1 -1
- package/dynamoDb/index.js +4 -6
- package/dynamoDb/index.js.map +1 -0
- package/dynamoDb/storage/date.d.ts +2 -3
- package/dynamoDb/storage/date.js +80 -46
- package/dynamoDb/storage/date.js.map +1 -0
- package/dynamoDb/storage/longText.d.ts +7 -4
- package/dynamoDb/storage/longText.js +72 -54
- package/dynamoDb/storage/longText.js.map +1 -0
- package/dynamoDb/storage/richText.d.ts +2 -3
- package/dynamoDb/storage/richText.js +85 -67
- package/dynamoDb/storage/richText.js.map +1 -0
- package/elasticsearch/createElasticsearchIndex.d.ts +9 -0
- package/elasticsearch/createElasticsearchIndex.js +60 -0
- package/elasticsearch/createElasticsearchIndex.js.map +1 -0
- package/elasticsearch/deleteElasticsearchIndex.d.ts +8 -0
- package/elasticsearch/deleteElasticsearchIndex.js +43 -0
- package/elasticsearch/deleteElasticsearchIndex.js.map +1 -0
- package/elasticsearch/index.d.ts +1 -1
- package/elasticsearch/index.js +1 -1
- package/elasticsearch/index.js.map +1 -0
- package/elasticsearch/indexing/dateTimeIndexing.js +15 -1
- package/elasticsearch/indexing/dateTimeIndexing.js.map +1 -0
- package/elasticsearch/indexing/defaultFieldIndexing.js.map +1 -0
- package/elasticsearch/indexing/index.js +1 -1
- package/elasticsearch/indexing/index.js.map +1 -0
- package/elasticsearch/indexing/longTextIndexing.js.map +1 -0
- package/elasticsearch/indexing/numberIndexing.js.map +1 -0
- package/elasticsearch/indexing/objectIndexing.d.ts +9 -0
- package/elasticsearch/indexing/objectIndexing.js +32 -9
- package/elasticsearch/indexing/objectIndexing.js.map +1 -0
- package/elasticsearch/indexing/richTextIndexing.js.map +1 -0
- package/elasticsearch/indices/base.d.ts +2 -0
- package/elasticsearch/indices/base.js +15 -0
- package/elasticsearch/indices/base.js.map +1 -0
- package/elasticsearch/indices/index.d.ts +1 -0
- package/elasticsearch/indices/index.js +16 -0
- package/elasticsearch/indices/index.js.map +1 -0
- package/elasticsearch/indices/japanese.d.ts +2 -0
- package/elasticsearch/indices/japanese.js +16 -0
- package/elasticsearch/indices/japanese.js.map +1 -0
- package/elasticsearch/search/index.d.ts +2 -2
- package/elasticsearch/search/index.js +3 -5
- package/elasticsearch/search/index.js.map +1 -0
- package/elasticsearch/search/refSearch.d.ts +2 -3
- package/elasticsearch/search/refSearch.js +25 -16
- package/elasticsearch/search/refSearch.js.map +1 -0
- package/elasticsearch/search/timeSearch.d.ts +2 -3
- package/elasticsearch/search/timeSearch.js +22 -14
- package/elasticsearch/search/timeSearch.js.map +1 -0
- package/helpers/createElasticsearchQueryBody.js +320 -84
- package/helpers/createElasticsearchQueryBody.js.map +1 -0
- package/helpers/entryIndexHelpers.js +33 -18
- package/helpers/entryIndexHelpers.js.map +1 -0
- package/helpers/fields.d.ts +4 -62
- package/helpers/fields.js +39 -8
- package/helpers/fields.js.map +1 -0
- package/helpers/index.js.map +1 -0
- package/helpers/searchPluginsList.d.ts +2 -2
- package/helpers/searchPluginsList.js +1 -1
- package/helpers/searchPluginsList.js.map +1 -0
- package/helpers/transformValueForSearch.d.ts +5 -2
- package/helpers/transformValueForSearch.js +3 -0
- package/helpers/transformValueForSearch.js.map +1 -0
- package/index.d.ts +1 -0
- package/index.js +126 -29
- package/index.js.map +1 -0
- package/operations/entry/dataLoaders.d.ts +6 -2
- package/operations/entry/dataLoaders.js +31 -13
- package/operations/entry/dataLoaders.js.map +1 -0
- package/operations/entry/elasticsearchFields.js +6 -0
- package/operations/entry/elasticsearchFields.js.map +1 -0
- package/operations/entry/index.d.ts +2 -2
- package/operations/entry/index.js +445 -331
- package/operations/entry/index.js.map +1 -0
- package/operations/entry/keys.js.map +1 -0
- package/operations/group/index.d.ts +2 -2
- package/operations/group/index.js +8 -15
- package/operations/group/index.js.map +1 -0
- package/operations/model/index.d.ts +2 -2
- package/operations/model/index.js +38 -39
- package/operations/model/index.js.map +1 -0
- package/operations/settings/index.d.ts +2 -2
- package/operations/settings/index.js +7 -13
- package/operations/settings/index.js.map +1 -0
- package/operations/system/index.d.ts +2 -2
- package/operations/system/index.js +5 -11
- package/operations/system/index.js.map +1 -0
- package/package.json +24 -29
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.d.ts +6 -3
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js +3 -3
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js.map +1 -0
- package/plugins/CmsEntryElasticsearchFieldPlugin.d.ts +3 -3
- package/plugins/CmsEntryElasticsearchFieldPlugin.js +3 -3
- package/plugins/CmsEntryElasticsearchFieldPlugin.js.map +1 -0
- package/plugins/CmsEntryElasticsearchIndexPlugin.d.ts +4 -0
- package/plugins/CmsEntryElasticsearchIndexPlugin.js +17 -0
- package/plugins/CmsEntryElasticsearchIndexPlugin.js.map +1 -0
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.d.ts +30 -0
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js +43 -0
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js.map +1 -0
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.d.ts +3 -3
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js +3 -3
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js.map +1 -0
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.d.ts +3 -3
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.js +3 -3
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.js.map +1 -0
- package/plugins/index.d.ts +6 -0
- package/plugins/index.js +83 -0
- package/plugins/index.js.map +1 -0
- package/types.d.ts +7 -34
- package/types.js +0 -13
- package/types.js.map +1 -0
- package/helpers/operatorPluginsList.d.ts +0 -7
- package/helpers/operatorPluginsList.js +0 -30
- package/operations/entry/fields.d.ts +0 -3
- package/operations/entry/fields.js +0 -60
- package/operations/system/createElasticsearchTemplate.d.ts +0 -5
- package/operations/system/createElasticsearchTemplate.js +0 -62
- package/upgrades/index.d.ts +0 -2
- package/upgrades/index.js +0 -16
- package/upgrades/utils.d.ts +0 -1
- package/upgrades/utils.js +0 -16
- package/upgrades/v5.0.0/cleanDatabaseRecord.d.ts +0 -6
- package/upgrades/v5.0.0/cleanDatabaseRecord.js +0 -16
- package/upgrades/v5.0.0/createOldVersionIndiceName.d.ts +0 -2
- package/upgrades/v5.0.0/createOldVersionIndiceName.js +0 -12
- package/upgrades/v5.0.0/entryValueFixer.d.ts +0 -4
- package/upgrades/v5.0.0/entryValueFixer.js +0 -124
- package/upgrades/v5.0.0/fieldFinder.d.ts +0 -6
- package/upgrades/v5.0.0/fieldFinder.js +0 -42
- package/upgrades/v5.0.0/helpers.d.ts +0 -4
- package/upgrades/v5.0.0/helpers.js +0 -57
- package/upgrades/v5.0.0/index.d.ts +0 -4
- package/upgrades/v5.0.0/index.js +0 -232
- package/upgrades/v5.8.0/index.d.ts +0 -4
- package/upgrades/v5.8.0/index.js +0 -426
|
@@ -1,27 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.createPublishedType = exports.createLatestType = exports.createEntriesStorageOperations = void 0;
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
11
|
|
|
12
12
|
var _types = require("@webiny/api-headless-cms/types");
|
|
13
13
|
|
|
14
14
|
var _helpers = require("../../helpers");
|
|
15
15
|
|
|
16
|
-
var _configurations =
|
|
16
|
+
var _configurations = require("../../configurations");
|
|
17
17
|
|
|
18
18
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
19
19
|
|
|
20
|
-
var
|
|
20
|
+
var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
|
|
21
21
|
|
|
22
|
-
var
|
|
23
|
-
|
|
24
|
-
var _compression = require("@webiny/api-elasticsearch/compression");
|
|
22
|
+
var _omit = _interopRequireDefault(require("lodash/omit"));
|
|
25
23
|
|
|
26
24
|
var _batchWrite = require("@webiny/db-dynamodb/utils/batchWrite");
|
|
27
25
|
|
|
@@ -31,9 +29,7 @@ var _keys = require("./keys");
|
|
|
31
29
|
|
|
32
30
|
var _query = require("@webiny/db-dynamodb/utils/query");
|
|
33
31
|
|
|
34
|
-
var
|
|
35
|
-
|
|
36
|
-
var _cursors = require("@webiny/api-elasticsearch/cursors");
|
|
32
|
+
var _apiElasticsearch = require("@webiny/api-elasticsearch");
|
|
37
33
|
|
|
38
34
|
var _get = require("@webiny/db-dynamodb/utils/get");
|
|
39
35
|
|
|
@@ -41,10 +37,6 @@ var _utils = require("@webiny/utils");
|
|
|
41
37
|
|
|
42
38
|
var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
|
|
43
39
|
|
|
44
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
45
|
-
|
|
46
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
47
|
-
|
|
48
40
|
const createType = () => {
|
|
49
41
|
return "cms.entry";
|
|
50
42
|
};
|
|
@@ -62,14 +54,14 @@ const createPublishedType = () => {
|
|
|
62
54
|
exports.createPublishedType = createPublishedType;
|
|
63
55
|
|
|
64
56
|
const getEntryData = entry => {
|
|
65
|
-
return
|
|
57
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _omit.default)(entry, ["PK", "SK", "published", "latest"])), {}, {
|
|
66
58
|
TYPE: createType(),
|
|
67
59
|
__type: createType()
|
|
68
60
|
});
|
|
69
61
|
};
|
|
70
62
|
|
|
71
63
|
const getESLatestEntryData = async (plugins, entry) => {
|
|
72
|
-
return (0,
|
|
64
|
+
return (0, _apiElasticsearch.compress)(plugins, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, getEntryData(entry)), {}, {
|
|
73
65
|
latest: true,
|
|
74
66
|
TYPE: createLatestType(),
|
|
75
67
|
__type: createLatestType()
|
|
@@ -77,13 +69,41 @@ const getESLatestEntryData = async (plugins, entry) => {
|
|
|
77
69
|
};
|
|
78
70
|
|
|
79
71
|
const getESPublishedEntryData = async (plugins, entry) => {
|
|
80
|
-
return (0,
|
|
72
|
+
return (0, _apiElasticsearch.compress)(plugins, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, getEntryData(entry)), {}, {
|
|
81
73
|
published: true,
|
|
82
74
|
TYPE: createPublishedType(),
|
|
83
75
|
__type: createPublishedType()
|
|
84
76
|
}));
|
|
85
77
|
};
|
|
86
78
|
|
|
79
|
+
const convertToStorageEntry = params => {
|
|
80
|
+
const {
|
|
81
|
+
model,
|
|
82
|
+
entry
|
|
83
|
+
} = params;
|
|
84
|
+
const values = model.convertValueKeyToStorage({
|
|
85
|
+
fields: model.fields,
|
|
86
|
+
values: entry.values
|
|
87
|
+
});
|
|
88
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, entry), {}, {
|
|
89
|
+
values
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const convertFromStorageEntry = params => {
|
|
94
|
+
const {
|
|
95
|
+
model,
|
|
96
|
+
entry
|
|
97
|
+
} = params;
|
|
98
|
+
const values = model.convertValueKeyFromStorage({
|
|
99
|
+
fields: model.fields,
|
|
100
|
+
values: entry.values
|
|
101
|
+
});
|
|
102
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, entry), {}, {
|
|
103
|
+
values
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
|
|
87
107
|
const createEntriesStorageOperations = params => {
|
|
88
108
|
const {
|
|
89
109
|
entity,
|
|
@@ -97,37 +117,80 @@ const createEntriesStorageOperations = params => {
|
|
|
97
117
|
|
|
98
118
|
const create = async (model, params) => {
|
|
99
119
|
const {
|
|
100
|
-
entry,
|
|
101
|
-
storageEntry
|
|
120
|
+
entry: initialEntry,
|
|
121
|
+
storageEntry: initialStorageEntry
|
|
102
122
|
} = params;
|
|
123
|
+
const isPublished = initialEntry.status === "published";
|
|
124
|
+
const locked = isPublished ? true : initialEntry.locked;
|
|
125
|
+
const entry = convertToStorageEntry({
|
|
126
|
+
model,
|
|
127
|
+
entry: initialEntry
|
|
128
|
+
});
|
|
129
|
+
const storageEntry = convertToStorageEntry({
|
|
130
|
+
model,
|
|
131
|
+
entry: initialStorageEntry
|
|
132
|
+
});
|
|
103
133
|
const esEntry = (0, _helpers.prepareEntryToIndex)({
|
|
104
134
|
plugins,
|
|
105
135
|
model,
|
|
106
|
-
entry: (0,
|
|
107
|
-
|
|
136
|
+
entry: (0, _cloneDeep.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, entry), {}, {
|
|
137
|
+
locked
|
|
138
|
+
})),
|
|
139
|
+
storageEntry: (0, _cloneDeep.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
140
|
+
locked
|
|
141
|
+
}))
|
|
108
142
|
});
|
|
109
143
|
|
|
110
144
|
const {
|
|
111
145
|
index: esIndex
|
|
112
|
-
} = _configurations.
|
|
146
|
+
} = _configurations.configurations.es({
|
|
113
147
|
model
|
|
114
148
|
});
|
|
115
149
|
|
|
116
150
|
const esLatestData = await getESLatestEntryData(plugins, esEntry);
|
|
151
|
+
const esPublishedData = await getESPublishedEntryData(plugins, esEntry);
|
|
117
152
|
const revisionKeys = {
|
|
118
|
-
PK: (0, _keys.createPartitionKey)(
|
|
153
|
+
PK: (0, _keys.createPartitionKey)({
|
|
154
|
+
id: entry.id,
|
|
155
|
+
locale: model.locale,
|
|
156
|
+
tenant: model.tenant
|
|
157
|
+
}),
|
|
119
158
|
SK: (0, _keys.createRevisionSortKey)(entry)
|
|
120
159
|
};
|
|
121
160
|
const latestKeys = {
|
|
122
|
-
PK: (0, _keys.createPartitionKey)(
|
|
161
|
+
PK: (0, _keys.createPartitionKey)({
|
|
162
|
+
id: entry.id,
|
|
163
|
+
locale: model.locale,
|
|
164
|
+
tenant: model.tenant
|
|
165
|
+
}),
|
|
123
166
|
SK: (0, _keys.createLatestSortKey)()
|
|
124
167
|
};
|
|
125
|
-
const
|
|
168
|
+
const publishedKeys = {
|
|
169
|
+
PK: (0, _keys.createPartitionKey)({
|
|
170
|
+
id: entry.id,
|
|
171
|
+
locale: model.locale,
|
|
172
|
+
tenant: model.tenant
|
|
173
|
+
}),
|
|
174
|
+
SK: (0, _keys.createPublishedSortKey)()
|
|
175
|
+
};
|
|
176
|
+
const items = [entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
177
|
+
locked
|
|
178
|
+
}, revisionKeys), {}, {
|
|
126
179
|
TYPE: createType()
|
|
127
|
-
})), entity.putBatch(
|
|
180
|
+
})), entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
181
|
+
locked
|
|
182
|
+
}, latestKeys), {}, {
|
|
128
183
|
TYPE: createLatestType()
|
|
129
184
|
}))];
|
|
130
185
|
|
|
186
|
+
if (isPublished) {
|
|
187
|
+
items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
188
|
+
locked
|
|
189
|
+
}, publishedKeys), {}, {
|
|
190
|
+
TYPE: createPublishedType()
|
|
191
|
+
})));
|
|
192
|
+
}
|
|
193
|
+
|
|
131
194
|
try {
|
|
132
195
|
await (0, _batchWrite.batchWriteAll)({
|
|
133
196
|
table: entity.table,
|
|
@@ -144,11 +207,23 @@ const createEntriesStorageOperations = params => {
|
|
|
144
207
|
});
|
|
145
208
|
}
|
|
146
209
|
|
|
147
|
-
|
|
148
|
-
|
|
210
|
+
const esItems = [esEntity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, latestKeys), {}, {
|
|
211
|
+
index: esIndex,
|
|
212
|
+
data: esLatestData
|
|
213
|
+
}))];
|
|
214
|
+
|
|
215
|
+
if (isPublished) {
|
|
216
|
+
esItems.push(esEntity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, publishedKeys), {}, {
|
|
149
217
|
index: esIndex,
|
|
150
|
-
data:
|
|
151
|
-
}));
|
|
218
|
+
data: esPublishedData
|
|
219
|
+
})));
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
try {
|
|
223
|
+
await (0, _batchWrite.batchWriteAll)({
|
|
224
|
+
table: esEntity.table,
|
|
225
|
+
items: esItems
|
|
226
|
+
});
|
|
152
227
|
} catch (ex) {
|
|
153
228
|
throw new _error.default(ex.message || "Could not insert entry data into the Elasticsearch DynamoDB table.", ex.code || "CREATE_ES_ENTRY_ERROR", {
|
|
154
229
|
error: ex,
|
|
@@ -157,39 +232,54 @@ const createEntriesStorageOperations = params => {
|
|
|
157
232
|
});
|
|
158
233
|
}
|
|
159
234
|
|
|
160
|
-
return
|
|
235
|
+
return initialStorageEntry;
|
|
161
236
|
};
|
|
162
237
|
|
|
163
238
|
const createRevisionFrom = async (model, params) => {
|
|
164
239
|
const {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
storageEntry
|
|
240
|
+
entry: initialEntry,
|
|
241
|
+
storageEntry: initialStorageEntry
|
|
168
242
|
} = params;
|
|
243
|
+
const entry = convertToStorageEntry({
|
|
244
|
+
model,
|
|
245
|
+
entry: initialEntry
|
|
246
|
+
});
|
|
247
|
+
const storageEntry = convertToStorageEntry({
|
|
248
|
+
model,
|
|
249
|
+
entry: initialStorageEntry
|
|
250
|
+
});
|
|
169
251
|
const revisionKeys = {
|
|
170
|
-
PK: (0, _keys.createPartitionKey)(
|
|
252
|
+
PK: (0, _keys.createPartitionKey)({
|
|
253
|
+
id: entry.id,
|
|
254
|
+
locale: model.locale,
|
|
255
|
+
tenant: model.tenant
|
|
256
|
+
}),
|
|
171
257
|
SK: (0, _keys.createRevisionSortKey)(entry)
|
|
172
258
|
};
|
|
173
259
|
const latestKeys = {
|
|
174
|
-
PK: (0, _keys.createPartitionKey)(
|
|
260
|
+
PK: (0, _keys.createPartitionKey)({
|
|
261
|
+
id: entry.id,
|
|
262
|
+
locale: model.locale,
|
|
263
|
+
tenant: model.tenant
|
|
264
|
+
}),
|
|
175
265
|
SK: (0, _keys.createLatestSortKey)()
|
|
176
266
|
};
|
|
177
267
|
const esEntry = (0, _helpers.prepareEntryToIndex)({
|
|
178
268
|
plugins,
|
|
179
269
|
model,
|
|
180
|
-
entry: (0,
|
|
181
|
-
storageEntry: (0,
|
|
270
|
+
entry: (0, _cloneDeep.default)(entry),
|
|
271
|
+
storageEntry: (0, _cloneDeep.default)(storageEntry)
|
|
182
272
|
});
|
|
183
273
|
const esLatestData = await getESLatestEntryData(plugins, esEntry);
|
|
184
|
-
const items = [entity.putBatch(
|
|
274
|
+
const items = [entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
185
275
|
TYPE: createType()
|
|
186
|
-
}, revisionKeys)), entity.putBatch(
|
|
276
|
+
}, revisionKeys)), entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
187
277
|
TYPE: createLatestType()
|
|
188
278
|
}, latestKeys))];
|
|
189
279
|
|
|
190
280
|
const {
|
|
191
281
|
index
|
|
192
|
-
} = _configurations.
|
|
282
|
+
} = _configurations.configurations.es({
|
|
193
283
|
model
|
|
194
284
|
});
|
|
195
285
|
|
|
@@ -204,7 +294,6 @@ const createEntriesStorageOperations = params => {
|
|
|
204
294
|
} catch (ex) {
|
|
205
295
|
throw new _error.default(ex.message || "Could not create revision from given entry in the DynamoDB table.", ex.code || "CREATE_REVISION_ERROR", {
|
|
206
296
|
error: ex,
|
|
207
|
-
originalEntry,
|
|
208
297
|
entry,
|
|
209
298
|
storageEntry
|
|
210
299
|
});
|
|
@@ -215,14 +304,13 @@ const createEntriesStorageOperations = params => {
|
|
|
215
304
|
|
|
216
305
|
|
|
217
306
|
try {
|
|
218
|
-
await esEntity.put(
|
|
307
|
+
await esEntity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, latestKeys), {}, {
|
|
219
308
|
index,
|
|
220
309
|
data: esLatestData
|
|
221
310
|
}));
|
|
222
311
|
} catch (ex) {
|
|
223
312
|
throw new _error.default(ex.message || "Could not update latest entry in the DynamoDB Elasticsearch table.", ex.code || "CREATE_REVISION_ERROR", {
|
|
224
313
|
error: ex,
|
|
225
|
-
originalEntry,
|
|
226
314
|
entry
|
|
227
315
|
});
|
|
228
316
|
}
|
|
@@ -231,58 +319,155 @@ const createEntriesStorageOperations = params => {
|
|
|
231
319
|
*/
|
|
232
320
|
|
|
233
321
|
|
|
234
|
-
return
|
|
322
|
+
return initialStorageEntry;
|
|
235
323
|
};
|
|
236
324
|
|
|
237
325
|
const update = async (model, params) => {
|
|
238
326
|
const {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
storageEntry
|
|
327
|
+
entry: initialEntry,
|
|
328
|
+
storageEntry: initialStorageEntry
|
|
242
329
|
} = params;
|
|
330
|
+
const entry = convertToStorageEntry({
|
|
331
|
+
model,
|
|
332
|
+
entry: initialEntry
|
|
333
|
+
});
|
|
334
|
+
const storageEntry = convertToStorageEntry({
|
|
335
|
+
model,
|
|
336
|
+
entry: initialStorageEntry
|
|
337
|
+
});
|
|
338
|
+
const isPublished = entry.status === "published";
|
|
339
|
+
const locked = isPublished ? true : entry.locked;
|
|
243
340
|
const revisionKeys = {
|
|
244
|
-
PK: (0, _keys.createPartitionKey)(
|
|
341
|
+
PK: (0, _keys.createPartitionKey)({
|
|
342
|
+
id: entry.id,
|
|
343
|
+
locale: model.locale,
|
|
344
|
+
tenant: model.tenant
|
|
345
|
+
}),
|
|
245
346
|
SK: (0, _keys.createRevisionSortKey)(entry)
|
|
246
347
|
};
|
|
247
348
|
const latestKeys = {
|
|
248
|
-
PK: (0, _keys.createPartitionKey)(
|
|
349
|
+
PK: (0, _keys.createPartitionKey)({
|
|
350
|
+
id: entry.id,
|
|
351
|
+
locale: model.locale,
|
|
352
|
+
tenant: model.tenant
|
|
353
|
+
}),
|
|
249
354
|
SK: (0, _keys.createLatestSortKey)()
|
|
250
355
|
};
|
|
356
|
+
const publishedKeys = {
|
|
357
|
+
PK: (0, _keys.createPartitionKey)({
|
|
358
|
+
id: entry.id,
|
|
359
|
+
locale: model.locale,
|
|
360
|
+
tenant: model.tenant
|
|
361
|
+
}),
|
|
362
|
+
SK: (0, _keys.createPublishedSortKey)()
|
|
363
|
+
};
|
|
251
364
|
/**
|
|
252
365
|
* We need the latest entry to check if it needs to be updated.
|
|
253
366
|
*/
|
|
254
367
|
|
|
255
368
|
const [latestStorageEntry] = await dataLoaders.getLatestRevisionByEntryId({
|
|
256
369
|
model,
|
|
257
|
-
ids: [
|
|
370
|
+
ids: [entry.id]
|
|
371
|
+
});
|
|
372
|
+
const [publishedStorageEntry] = await dataLoaders.getPublishedRevisionByEntryId({
|
|
373
|
+
model,
|
|
374
|
+
ids: [entry.id]
|
|
258
375
|
});
|
|
259
|
-
const items = [entity.putBatch(
|
|
376
|
+
const items = [entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
377
|
+
locked
|
|
378
|
+
}, revisionKeys), {}, {
|
|
260
379
|
TYPE: createType()
|
|
261
380
|
}))];
|
|
381
|
+
|
|
382
|
+
if (isPublished) {
|
|
383
|
+
items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
384
|
+
locked
|
|
385
|
+
}, publishedKeys), {}, {
|
|
386
|
+
TYPE: createPublishedType()
|
|
387
|
+
})));
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
const esItems = [];
|
|
391
|
+
|
|
392
|
+
const {
|
|
393
|
+
index: esIndex
|
|
394
|
+
} = _configurations.configurations.es({
|
|
395
|
+
model
|
|
396
|
+
});
|
|
397
|
+
/**
|
|
398
|
+
* Variable for the elasticsearch entry so we do not convert it more than once
|
|
399
|
+
*/
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
let esEntry = undefined;
|
|
262
403
|
/**
|
|
263
404
|
* If the latest entry is the one being updated, we need to create a new latest entry records.
|
|
264
405
|
*/
|
|
265
406
|
|
|
266
407
|
let elasticsearchLatestData = null;
|
|
267
408
|
|
|
268
|
-
if (latestStorageEntry.id ===
|
|
409
|
+
if ((latestStorageEntry === null || latestStorageEntry === void 0 ? void 0 : latestStorageEntry.id) === entry.id) {
|
|
269
410
|
/**
|
|
270
411
|
* First we update the regular DynamoDB table
|
|
271
412
|
*/
|
|
272
|
-
items.push(entity.putBatch(
|
|
413
|
+
items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), latestKeys), {}, {
|
|
273
414
|
TYPE: (0, _keys.createLatestSortKey)()
|
|
274
415
|
})));
|
|
275
416
|
/**
|
|
276
417
|
* And then update the Elasticsearch table to propagate changes to the Elasticsearch
|
|
277
418
|
*/
|
|
278
419
|
|
|
279
|
-
|
|
420
|
+
esEntry = (0, _helpers.prepareEntryToIndex)({
|
|
280
421
|
plugins,
|
|
281
422
|
model,
|
|
282
|
-
entry: (0,
|
|
283
|
-
|
|
423
|
+
entry: (0, _cloneDeep.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, entry), {}, {
|
|
424
|
+
locked
|
|
425
|
+
})),
|
|
426
|
+
storageEntry: (0, _cloneDeep.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
427
|
+
locked
|
|
428
|
+
}))
|
|
284
429
|
});
|
|
285
430
|
elasticsearchLatestData = await getESLatestEntryData(plugins, esEntry);
|
|
431
|
+
esItems.push(esEntity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, latestKeys), {}, {
|
|
432
|
+
index: esIndex,
|
|
433
|
+
data: elasticsearchLatestData
|
|
434
|
+
})));
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
let elasticsearchPublishedData = null;
|
|
438
|
+
|
|
439
|
+
if (isPublished && (publishedStorageEntry === null || publishedStorageEntry === void 0 ? void 0 : publishedStorageEntry.id) === entry.id) {
|
|
440
|
+
if (!elasticsearchLatestData) {
|
|
441
|
+
/**
|
|
442
|
+
* And then update the Elasticsearch table to propagate changes to the Elasticsearch
|
|
443
|
+
*/
|
|
444
|
+
if (!esEntry) {
|
|
445
|
+
esEntry = (0, _helpers.prepareEntryToIndex)({
|
|
446
|
+
plugins,
|
|
447
|
+
model,
|
|
448
|
+
entry: (0, _cloneDeep.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, entry), {}, {
|
|
449
|
+
locked
|
|
450
|
+
})),
|
|
451
|
+
storageEntry: (0, _cloneDeep.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
452
|
+
locked
|
|
453
|
+
}))
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
elasticsearchPublishedData = await getESPublishedEntryData(plugins, esEntry);
|
|
458
|
+
} else {
|
|
459
|
+
elasticsearchPublishedData = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, elasticsearchLatestData), {}, {
|
|
460
|
+
published: true,
|
|
461
|
+
TYPE: createPublishedType(),
|
|
462
|
+
__type: createPublishedType()
|
|
463
|
+
});
|
|
464
|
+
delete elasticsearchPublishedData.latest;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
esItems.push(esEntity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, publishedKeys), {}, {
|
|
468
|
+
index: esIndex,
|
|
469
|
+
data: elasticsearchPublishedData
|
|
470
|
+
})));
|
|
286
471
|
}
|
|
287
472
|
|
|
288
473
|
try {
|
|
@@ -296,43 +481,39 @@ const createEntriesStorageOperations = params => {
|
|
|
296
481
|
} catch (ex) {
|
|
297
482
|
throw new _error.default(ex.message || "Could not update entry DynamoDB records.", ex.code || "UPDATE_ENTRY_ERROR", {
|
|
298
483
|
error: ex,
|
|
299
|
-
originalEntry,
|
|
300
484
|
entry,
|
|
301
485
|
storageEntry
|
|
302
486
|
});
|
|
303
487
|
}
|
|
304
488
|
|
|
305
|
-
if (
|
|
306
|
-
return
|
|
489
|
+
if (esItems.length === 0) {
|
|
490
|
+
return initialStorageEntry;
|
|
307
491
|
}
|
|
308
492
|
|
|
309
|
-
const {
|
|
310
|
-
index: esIndex
|
|
311
|
-
} = _configurations.default.es({
|
|
312
|
-
model
|
|
313
|
-
});
|
|
314
|
-
|
|
315
493
|
try {
|
|
316
|
-
await
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
})
|
|
494
|
+
await (0, _batchWrite.batchWriteAll)({
|
|
495
|
+
table: esEntity.table,
|
|
496
|
+
items: esItems
|
|
497
|
+
});
|
|
320
498
|
} catch (ex) {
|
|
321
|
-
throw new _error.default(ex.message || "Could not update entry DynamoDB Elasticsearch
|
|
499
|
+
throw new _error.default(ex.message || "Could not update entry DynamoDB Elasticsearch records.", ex.code || "UPDATE_ES_ENTRY_ERROR", {
|
|
322
500
|
error: ex,
|
|
323
|
-
originalEntry,
|
|
324
501
|
entry
|
|
325
502
|
});
|
|
326
503
|
}
|
|
327
504
|
|
|
328
|
-
return
|
|
505
|
+
return initialStorageEntry;
|
|
329
506
|
};
|
|
330
507
|
|
|
331
508
|
const deleteEntry = async (model, params) => {
|
|
332
509
|
const {
|
|
333
510
|
entry
|
|
334
511
|
} = params;
|
|
335
|
-
const partitionKey = (0, _keys.createPartitionKey)(
|
|
512
|
+
const partitionKey = (0, _keys.createPartitionKey)({
|
|
513
|
+
id: entry.id,
|
|
514
|
+
locale: model.locale,
|
|
515
|
+
tenant: model.tenant
|
|
516
|
+
});
|
|
336
517
|
const items = await (0, _query.queryAll)({
|
|
337
518
|
entity,
|
|
338
519
|
partitionKey,
|
|
@@ -390,15 +571,19 @@ const createEntriesStorageOperations = params => {
|
|
|
390
571
|
|
|
391
572
|
const deleteRevision = async (model, params) => {
|
|
392
573
|
const {
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
574
|
+
entry,
|
|
575
|
+
latestEntry,
|
|
576
|
+
latestStorageEntry
|
|
396
577
|
} = params;
|
|
397
|
-
const partitionKey = (0, _keys.createPartitionKey)(
|
|
578
|
+
const partitionKey = (0, _keys.createPartitionKey)({
|
|
579
|
+
id: entry.id,
|
|
580
|
+
locale: model.locale,
|
|
581
|
+
tenant: model.tenant
|
|
582
|
+
});
|
|
398
583
|
|
|
399
584
|
const {
|
|
400
585
|
index
|
|
401
|
-
} = _configurations.
|
|
586
|
+
} = _configurations.configurations.es({
|
|
402
587
|
model
|
|
403
588
|
});
|
|
404
589
|
/**
|
|
@@ -408,7 +593,7 @@ const createEntriesStorageOperations = params => {
|
|
|
408
593
|
|
|
409
594
|
const [publishedStorageEntry] = await dataLoaders.getPublishedRevisionByEntryId({
|
|
410
595
|
model,
|
|
411
|
-
ids: [
|
|
596
|
+
ids: [entry.id]
|
|
412
597
|
});
|
|
413
598
|
/**
|
|
414
599
|
* We need to delete all existing records of the given entry revision.
|
|
@@ -420,14 +605,14 @@ const createEntriesStorageOperations = params => {
|
|
|
420
605
|
*/
|
|
421
606
|
entity.deleteBatch({
|
|
422
607
|
PK: partitionKey,
|
|
423
|
-
SK: (0, _keys.createRevisionSortKey)(
|
|
608
|
+
SK: (0, _keys.createRevisionSortKey)(entry)
|
|
424
609
|
})];
|
|
425
610
|
const esItems = [];
|
|
426
611
|
/**
|
|
427
612
|
* If revision we are deleting is the published one as well, we need to delete those records as well.
|
|
428
613
|
*/
|
|
429
614
|
|
|
430
|
-
if (publishedStorageEntry
|
|
615
|
+
if ((publishedStorageEntry === null || publishedStorageEntry === void 0 ? void 0 : publishedStorageEntry.id) === entry.id) {
|
|
431
616
|
items.push(entity.deleteBatch({
|
|
432
617
|
PK: partitionKey,
|
|
433
618
|
SK: (0, _keys.createPublishedSortKey)()
|
|
@@ -438,19 +623,19 @@ const createEntriesStorageOperations = params => {
|
|
|
438
623
|
}));
|
|
439
624
|
}
|
|
440
625
|
|
|
441
|
-
if (
|
|
626
|
+
if (latestEntry && latestStorageEntry) {
|
|
442
627
|
const esEntry = (0, _helpers.prepareEntryToIndex)({
|
|
443
628
|
plugins,
|
|
444
629
|
model,
|
|
445
|
-
entry: (0,
|
|
446
|
-
storageEntry: (0,
|
|
630
|
+
entry: (0, _cloneDeep.default)(latestEntry),
|
|
631
|
+
storageEntry: (0, _cloneDeep.default)(latestStorageEntry)
|
|
447
632
|
});
|
|
448
633
|
const esLatestData = await getESLatestEntryData(plugins, esEntry);
|
|
449
634
|
/**
|
|
450
635
|
* In the end we need to set the new latest entry
|
|
451
636
|
*/
|
|
452
637
|
|
|
453
|
-
items.push(entity.putBatch(
|
|
638
|
+
items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, latestStorageEntry), {}, {
|
|
454
639
|
PK: partitionKey,
|
|
455
640
|
SK: (0, _keys.createLatestSortKey)(),
|
|
456
641
|
TYPE: createLatestType()
|
|
@@ -474,9 +659,9 @@ const createEntriesStorageOperations = params => {
|
|
|
474
659
|
} catch (ex) {
|
|
475
660
|
throw new _error.default(ex.message || "Could not batch write entry records to DynamoDB table.", ex.code || "DELETE_REVISION_ERROR", {
|
|
476
661
|
error: ex,
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
662
|
+
entry,
|
|
663
|
+
latestEntry,
|
|
664
|
+
latestStorageEntry
|
|
480
665
|
});
|
|
481
666
|
}
|
|
482
667
|
|
|
@@ -492,18 +677,45 @@ const createEntriesStorageOperations = params => {
|
|
|
492
677
|
} catch (ex) {
|
|
493
678
|
throw new _error.default(ex.message || "Could not batch write entry records to DynamoDB Elasticsearch table.", ex.code || "DELETE_REVISION_ERROR", {
|
|
494
679
|
error: ex,
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
680
|
+
entry,
|
|
681
|
+
latestEntry,
|
|
682
|
+
latestStorageEntry
|
|
498
683
|
});
|
|
499
684
|
}
|
|
500
685
|
};
|
|
501
686
|
|
|
502
687
|
const list = async (model, params) => {
|
|
503
|
-
const limit = (0,
|
|
688
|
+
const limit = (0, _apiElasticsearch.createLimit)(params.limit, 50);
|
|
689
|
+
|
|
690
|
+
const {
|
|
691
|
+
index
|
|
692
|
+
} = _configurations.configurations.es({
|
|
693
|
+
model
|
|
694
|
+
});
|
|
695
|
+
|
|
696
|
+
try {
|
|
697
|
+
const result = await elasticsearch.indices.exists({
|
|
698
|
+
index
|
|
699
|
+
});
|
|
700
|
+
|
|
701
|
+
if (!result || !result.body) {
|
|
702
|
+
return {
|
|
703
|
+
hasMoreItems: false,
|
|
704
|
+
totalCount: 0,
|
|
705
|
+
cursor: null,
|
|
706
|
+
items: []
|
|
707
|
+
};
|
|
708
|
+
}
|
|
709
|
+
} catch (ex) {
|
|
710
|
+
throw new _error.default("Could not determine if Elasticsearch index exists.", "ELASTICSEARCH_INDEX_CHECK_ERROR", {
|
|
711
|
+
error: ex,
|
|
712
|
+
index
|
|
713
|
+
});
|
|
714
|
+
}
|
|
715
|
+
|
|
504
716
|
const body = (0, _helpers.createElasticsearchQueryBody)({
|
|
505
717
|
model,
|
|
506
|
-
args:
|
|
718
|
+
args: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
|
|
507
719
|
limit
|
|
508
720
|
}),
|
|
509
721
|
plugins,
|
|
@@ -511,12 +723,6 @@ const createEntriesStorageOperations = params => {
|
|
|
511
723
|
});
|
|
512
724
|
let response;
|
|
513
725
|
|
|
514
|
-
const {
|
|
515
|
-
index
|
|
516
|
-
} = _configurations.default.es({
|
|
517
|
-
model
|
|
518
|
-
});
|
|
519
|
-
|
|
520
726
|
try {
|
|
521
727
|
response = await elasticsearch.search({
|
|
522
728
|
index,
|
|
@@ -526,7 +732,8 @@ const createEntriesStorageOperations = params => {
|
|
|
526
732
|
throw new _error.default(ex.message, ex.code || "ELASTICSEARCH_ERROR", {
|
|
527
733
|
error: ex,
|
|
528
734
|
index,
|
|
529
|
-
body
|
|
735
|
+
body,
|
|
736
|
+
model
|
|
530
737
|
});
|
|
531
738
|
}
|
|
532
739
|
|
|
@@ -538,6 +745,11 @@ const createEntriesStorageOperations = params => {
|
|
|
538
745
|
plugins,
|
|
539
746
|
model,
|
|
540
747
|
entries: hits.map(item => item._source)
|
|
748
|
+
}).map(item => {
|
|
749
|
+
return convertFromStorageEntry({
|
|
750
|
+
model,
|
|
751
|
+
entry: item
|
|
752
|
+
});
|
|
541
753
|
});
|
|
542
754
|
const hasMoreItems = items.length > limit;
|
|
543
755
|
|
|
@@ -553,7 +765,7 @@ const createEntriesStorageOperations = params => {
|
|
|
553
765
|
*/
|
|
554
766
|
|
|
555
767
|
|
|
556
|
-
const cursor = items.length > 0 ? (0,
|
|
768
|
+
const cursor = items.length > 0 ? (0, _apiElasticsearch.encodeCursor)(hits[items.length - 1].sort) || null : null;
|
|
557
769
|
return {
|
|
558
770
|
hasMoreItems,
|
|
559
771
|
totalCount: total.value,
|
|
@@ -565,22 +777,25 @@ const createEntriesStorageOperations = params => {
|
|
|
565
777
|
const get = async (model, params) => {
|
|
566
778
|
const {
|
|
567
779
|
items
|
|
568
|
-
} = await list(model,
|
|
780
|
+
} = await list(model, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
|
|
569
781
|
limit: 1
|
|
570
782
|
}));
|
|
571
|
-
|
|
572
|
-
if (items.length === 0) {
|
|
573
|
-
return null;
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
return items.shift();
|
|
783
|
+
return items.shift() || null;
|
|
577
784
|
};
|
|
578
785
|
|
|
579
786
|
const publish = async (model, params) => {
|
|
580
787
|
const {
|
|
581
|
-
entry,
|
|
582
|
-
storageEntry
|
|
788
|
+
entry: initialEntry,
|
|
789
|
+
storageEntry: initialStorageEntry
|
|
583
790
|
} = params;
|
|
791
|
+
const entry = convertToStorageEntry({
|
|
792
|
+
model,
|
|
793
|
+
entry: initialEntry
|
|
794
|
+
});
|
|
795
|
+
const storageEntry = convertToStorageEntry({
|
|
796
|
+
model,
|
|
797
|
+
entry: initialStorageEntry
|
|
798
|
+
});
|
|
584
799
|
/**
|
|
585
800
|
* We need currently published entry to check if need to remove it.
|
|
586
801
|
*/
|
|
@@ -590,15 +805,27 @@ const createEntriesStorageOperations = params => {
|
|
|
590
805
|
ids: [entry.id]
|
|
591
806
|
});
|
|
592
807
|
const revisionKeys = {
|
|
593
|
-
PK: (0, _keys.createPartitionKey)(
|
|
808
|
+
PK: (0, _keys.createPartitionKey)({
|
|
809
|
+
id: entry.id,
|
|
810
|
+
locale: model.locale,
|
|
811
|
+
tenant: model.tenant
|
|
812
|
+
}),
|
|
594
813
|
SK: (0, _keys.createRevisionSortKey)(entry)
|
|
595
814
|
};
|
|
596
815
|
const latestKeys = {
|
|
597
|
-
PK: (0, _keys.createPartitionKey)(
|
|
816
|
+
PK: (0, _keys.createPartitionKey)({
|
|
817
|
+
id: entry.id,
|
|
818
|
+
locale: model.locale,
|
|
819
|
+
tenant: model.tenant
|
|
820
|
+
}),
|
|
598
821
|
SK: (0, _keys.createLatestSortKey)()
|
|
599
822
|
};
|
|
600
823
|
const publishedKeys = {
|
|
601
|
-
PK: (0, _keys.createPartitionKey)(
|
|
824
|
+
PK: (0, _keys.createPartitionKey)({
|
|
825
|
+
id: entry.id,
|
|
826
|
+
locale: model.locale,
|
|
827
|
+
tenant: model.tenant
|
|
828
|
+
}),
|
|
602
829
|
SK: (0, _keys.createPublishedSortKey)()
|
|
603
830
|
};
|
|
604
831
|
let latestEsEntry = null;
|
|
@@ -616,18 +843,18 @@ const createEntriesStorageOperations = params => {
|
|
|
616
843
|
});
|
|
617
844
|
}
|
|
618
845
|
|
|
619
|
-
const items = [entity.putBatch(
|
|
846
|
+
const items = [entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), revisionKeys), {}, {
|
|
620
847
|
TYPE: createType()
|
|
621
848
|
}))];
|
|
622
849
|
const esItems = [];
|
|
623
850
|
|
|
624
851
|
const {
|
|
625
852
|
index
|
|
626
|
-
} = _configurations.
|
|
853
|
+
} = _configurations.configurations.es({
|
|
627
854
|
model
|
|
628
855
|
});
|
|
629
856
|
|
|
630
|
-
if (publishedStorageEntry) {
|
|
857
|
+
if (publishedStorageEntry && publishedStorageEntry.id !== entry.id) {
|
|
631
858
|
/**
|
|
632
859
|
* If there is a `published` entry already, we need to set it to `unpublished`. We need to
|
|
633
860
|
* execute two updates: update the previously published entry's status and the published entry record.
|
|
@@ -638,12 +865,17 @@ const createEntriesStorageOperations = params => {
|
|
|
638
865
|
const [previouslyPublishedEntry] = await dataLoaders.getRevisionById({
|
|
639
866
|
model,
|
|
640
867
|
ids: [publishedStorageEntry.id]
|
|
641
|
-
});
|
|
868
|
+
}); //
|
|
869
|
+
// const previouslyPublishedEntry = convertToStorageEntry({
|
|
870
|
+
// model,
|
|
871
|
+
// entry: initialPreviouslyPublishedEntry
|
|
872
|
+
// });
|
|
873
|
+
|
|
642
874
|
items.push(
|
|
643
875
|
/**
|
|
644
876
|
* Update currently published entry (unpublish it)
|
|
645
877
|
*/
|
|
646
|
-
entity.putBatch(
|
|
878
|
+
entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, previouslyPublishedEntry), {}, {
|
|
647
879
|
status: _types.CONTENT_ENTRY_STATUS.UNPUBLISHED,
|
|
648
880
|
savedOn: entry.savedOn,
|
|
649
881
|
TYPE: createType(),
|
|
@@ -656,31 +888,38 @@ const createEntriesStorageOperations = params => {
|
|
|
656
888
|
*/
|
|
657
889
|
|
|
658
890
|
|
|
659
|
-
items.push(entity.putBatch(
|
|
891
|
+
items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), publishedKeys), {}, {
|
|
660
892
|
TYPE: createPublishedType()
|
|
661
893
|
})));
|
|
662
894
|
/**
|
|
663
|
-
* We need the latest entry to check if it
|
|
895
|
+
* We need the latest entry to check if it needs to be updated as well in the Elasticsearch.
|
|
664
896
|
*/
|
|
665
897
|
|
|
666
898
|
const [latestStorageEntry] = await dataLoaders.getLatestRevisionByEntryId({
|
|
667
899
|
model,
|
|
668
900
|
ids: [entry.id]
|
|
669
901
|
});
|
|
902
|
+
|
|
903
|
+
if ((latestStorageEntry === null || latestStorageEntry === void 0 ? void 0 : latestStorageEntry.id) === entry.id) {
|
|
904
|
+
items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), latestKeys)));
|
|
905
|
+
}
|
|
670
906
|
/**
|
|
671
907
|
* If we are publishing the latest revision, let's also update the latest revision's status in ES.
|
|
672
908
|
*/
|
|
673
909
|
|
|
674
|
-
|
|
910
|
+
|
|
911
|
+
if (latestEsEntry && (latestStorageEntry === null || latestStorageEntry === void 0 ? void 0 : latestStorageEntry.id) === entry.id) {
|
|
675
912
|
/**
|
|
676
913
|
* Need to decompress the data from Elasticsearch DynamoDB table.
|
|
914
|
+
*
|
|
915
|
+
* No need to transform it for the storage because it was fetched directly from the Elasticsearch table, where it sits transformed.
|
|
677
916
|
*/
|
|
678
|
-
const latestEsEntryDataDecompressed = await (0,
|
|
917
|
+
const latestEsEntryDataDecompressed = await (0, _apiElasticsearch.decompress)(plugins, latestEsEntry.data);
|
|
679
918
|
esItems.push(esEntity.putBatch({
|
|
680
919
|
index,
|
|
681
920
|
PK: (0, _keys.createPartitionKey)(latestEsEntryDataDecompressed),
|
|
682
921
|
SK: (0, _keys.createLatestSortKey)(),
|
|
683
|
-
data:
|
|
922
|
+
data: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, latestEsEntryDataDecompressed), {}, {
|
|
684
923
|
status: _types.CONTENT_ENTRY_STATUS.PUBLISHED,
|
|
685
924
|
locked: true,
|
|
686
925
|
savedOn: entry.savedOn,
|
|
@@ -692,15 +931,15 @@ const createEntriesStorageOperations = params => {
|
|
|
692
931
|
const preparedEntryData = (0, _helpers.prepareEntryToIndex)({
|
|
693
932
|
plugins,
|
|
694
933
|
model,
|
|
695
|
-
entry: (0,
|
|
696
|
-
storageEntry: (0,
|
|
934
|
+
entry: (0, _cloneDeep.default)(entry),
|
|
935
|
+
storageEntry: (0, _cloneDeep.default)(storageEntry)
|
|
697
936
|
});
|
|
698
937
|
/**
|
|
699
938
|
* Update the published revision entry in ES.
|
|
700
939
|
*/
|
|
701
940
|
|
|
702
941
|
const esLatestData = await getESPublishedEntryData(plugins, preparedEntryData);
|
|
703
|
-
esItems.push(esEntity.putBatch(
|
|
942
|
+
esItems.push(esEntity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, publishedKeys), {}, {
|
|
704
943
|
index,
|
|
705
944
|
data: esLatestData
|
|
706
945
|
})));
|
|
@@ -743,14 +982,22 @@ const createEntriesStorageOperations = params => {
|
|
|
743
982
|
});
|
|
744
983
|
}
|
|
745
984
|
|
|
746
|
-
return
|
|
985
|
+
return initialStorageEntry;
|
|
747
986
|
};
|
|
748
987
|
|
|
749
988
|
const unpublish = async (model, params) => {
|
|
750
989
|
const {
|
|
751
|
-
entry,
|
|
752
|
-
storageEntry
|
|
990
|
+
entry: initialEntry,
|
|
991
|
+
storageEntry: initialStorageEntry
|
|
753
992
|
} = params;
|
|
993
|
+
const entry = convertToStorageEntry({
|
|
994
|
+
model,
|
|
995
|
+
entry: initialEntry
|
|
996
|
+
});
|
|
997
|
+
const storageEntry = convertToStorageEntry({
|
|
998
|
+
model,
|
|
999
|
+
entry: initialStorageEntry
|
|
1000
|
+
});
|
|
754
1001
|
/**
|
|
755
1002
|
* We need the latest entry to check if it needs to be updated.
|
|
756
1003
|
*/
|
|
@@ -759,11 +1006,15 @@ const createEntriesStorageOperations = params => {
|
|
|
759
1006
|
model,
|
|
760
1007
|
ids: [entry.id]
|
|
761
1008
|
});
|
|
762
|
-
const partitionKey = (0, _keys.createPartitionKey)(
|
|
1009
|
+
const partitionKey = (0, _keys.createPartitionKey)({
|
|
1010
|
+
id: entry.id,
|
|
1011
|
+
locale: model.locale,
|
|
1012
|
+
tenant: model.tenant
|
|
1013
|
+
});
|
|
763
1014
|
const items = [entity.deleteBatch({
|
|
764
1015
|
PK: partitionKey,
|
|
765
1016
|
SK: (0, _keys.createPublishedSortKey)()
|
|
766
|
-
}), entity.putBatch(
|
|
1017
|
+
}), entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
|
|
767
1018
|
PK: partitionKey,
|
|
768
1019
|
SK: (0, _keys.createRevisionSortKey)(entry),
|
|
769
1020
|
TYPE: createType()
|
|
@@ -776,18 +1027,18 @@ const createEntriesStorageOperations = params => {
|
|
|
776
1027
|
* If we are unpublishing the latest revision, let's also update the latest revision entry's status in ES.
|
|
777
1028
|
*/
|
|
778
1029
|
|
|
779
|
-
if (latestStorageEntry.id === entry.id) {
|
|
1030
|
+
if ((latestStorageEntry === null || latestStorageEntry === void 0 ? void 0 : latestStorageEntry.id) === entry.id) {
|
|
780
1031
|
const {
|
|
781
1032
|
index
|
|
782
|
-
} = _configurations.
|
|
1033
|
+
} = _configurations.configurations.es({
|
|
783
1034
|
model
|
|
784
1035
|
});
|
|
785
1036
|
|
|
786
1037
|
const preparedEntryData = (0, _helpers.prepareEntryToIndex)({
|
|
787
1038
|
plugins,
|
|
788
1039
|
model,
|
|
789
|
-
entry: (0,
|
|
790
|
-
storageEntry: (0,
|
|
1040
|
+
entry: (0, _cloneDeep.default)(entry),
|
|
1041
|
+
storageEntry: (0, _cloneDeep.default)(storageEntry)
|
|
791
1042
|
});
|
|
792
1043
|
const esLatestData = await getESLatestEntryData(plugins, preparedEntryData);
|
|
793
1044
|
esItems.push(esEntity.putBatch({
|
|
@@ -833,250 +1084,107 @@ const createEntriesStorageOperations = params => {
|
|
|
833
1084
|
});
|
|
834
1085
|
}
|
|
835
1086
|
|
|
836
|
-
return
|
|
837
|
-
};
|
|
838
|
-
|
|
839
|
-
const requestReview = async (model, params) => {
|
|
840
|
-
const {
|
|
841
|
-
entry,
|
|
842
|
-
storageEntry,
|
|
843
|
-
originalEntry
|
|
844
|
-
} = params;
|
|
845
|
-
/**
|
|
846
|
-
* We need the latest entry to check if it needs to be updated.
|
|
847
|
-
*/
|
|
848
|
-
|
|
849
|
-
const [latestStorageEntry] = await dataLoaders.getLatestRevisionByEntryId({
|
|
850
|
-
model,
|
|
851
|
-
ids: [entry.id]
|
|
852
|
-
});
|
|
853
|
-
const partitionKey = (0, _keys.createPartitionKey)(entry);
|
|
854
|
-
/**
|
|
855
|
-
* If we updated the latest version, then make sure the changes are propagated to ES too.
|
|
856
|
-
*/
|
|
857
|
-
|
|
858
|
-
let esLatestData = null;
|
|
859
|
-
|
|
860
|
-
const {
|
|
861
|
-
index
|
|
862
|
-
} = _configurations.default.es({
|
|
863
|
-
model
|
|
864
|
-
});
|
|
865
|
-
|
|
866
|
-
if (latestStorageEntry && latestStorageEntry.id === entry.id) {
|
|
867
|
-
const preparedEntryData = (0, _helpers.prepareEntryToIndex)({
|
|
868
|
-
plugins,
|
|
869
|
-
model,
|
|
870
|
-
entry: (0, _lodash.default)(entry),
|
|
871
|
-
storageEntry: (0, _lodash.default)(storageEntry)
|
|
872
|
-
});
|
|
873
|
-
esLatestData = await getESLatestEntryData(plugins, preparedEntryData);
|
|
874
|
-
}
|
|
875
|
-
|
|
876
|
-
try {
|
|
877
|
-
await entity.put(_objectSpread(_objectSpread({}, storageEntry), {}, {
|
|
878
|
-
PK: partitionKey,
|
|
879
|
-
SK: (0, _keys.createRevisionSortKey)(entry),
|
|
880
|
-
TYPE: createType()
|
|
881
|
-
}));
|
|
882
|
-
dataLoaders.clearAll({
|
|
883
|
-
model
|
|
884
|
-
});
|
|
885
|
-
} catch (ex) {
|
|
886
|
-
throw new _error.default(ex.message || "Could not store request review entry record into DynamoDB table.", ex.code || "REQUEST_REVIEW_ERROR", {
|
|
887
|
-
entry,
|
|
888
|
-
latestStorageEntry,
|
|
889
|
-
originalEntry
|
|
890
|
-
});
|
|
891
|
-
}
|
|
892
|
-
/**
|
|
893
|
-
* No need to proceed further if nothing to put into Elasticsearch.
|
|
894
|
-
*/
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
if (!esLatestData) {
|
|
898
|
-
return storageEntry;
|
|
899
|
-
}
|
|
900
|
-
|
|
901
|
-
try {
|
|
902
|
-
await esEntity.put({
|
|
903
|
-
PK: partitionKey,
|
|
904
|
-
SK: (0, _keys.createLatestSortKey)(),
|
|
905
|
-
index,
|
|
906
|
-
data: esLatestData
|
|
907
|
-
});
|
|
908
|
-
} catch (ex) {
|
|
909
|
-
throw new _error.default(ex.message || "Could not store request review entry record into DynamoDB Elasticsearch table.", ex.code || "REQUEST_REVIEW_ERROR", {
|
|
910
|
-
entry,
|
|
911
|
-
latestStorageEntry,
|
|
912
|
-
originalEntry
|
|
913
|
-
});
|
|
914
|
-
}
|
|
915
|
-
|
|
916
|
-
return storageEntry;
|
|
917
|
-
};
|
|
918
|
-
|
|
919
|
-
const requestChanges = async (model, params) => {
|
|
920
|
-
const {
|
|
921
|
-
entry,
|
|
922
|
-
storageEntry,
|
|
923
|
-
originalEntry
|
|
924
|
-
} = params;
|
|
925
|
-
/**
|
|
926
|
-
* We need the latest entry to check if it needs to be updated.
|
|
927
|
-
*/
|
|
928
|
-
|
|
929
|
-
const [latestStorageEntry] = await dataLoaders.getLatestRevisionByEntryId({
|
|
930
|
-
model,
|
|
931
|
-
ids: [entry.id]
|
|
932
|
-
});
|
|
933
|
-
const partitionKey = (0, _keys.createPartitionKey)(entry);
|
|
934
|
-
const items = [entity.putBatch(_objectSpread(_objectSpread({}, storageEntry), {}, {
|
|
935
|
-
PK: partitionKey,
|
|
936
|
-
SK: (0, _keys.createRevisionSortKey)(entry),
|
|
937
|
-
TYPE: createType()
|
|
938
|
-
}))];
|
|
939
|
-
/**
|
|
940
|
-
* If we updated the latest version, then make sure the changes are propagated to ES too.
|
|
941
|
-
*/
|
|
942
|
-
|
|
943
|
-
const {
|
|
944
|
-
index
|
|
945
|
-
} = _configurations.default.es({
|
|
946
|
-
model
|
|
947
|
-
});
|
|
948
|
-
|
|
949
|
-
let esLatestData = null;
|
|
950
|
-
|
|
951
|
-
if (latestStorageEntry && latestStorageEntry.id === entry.id) {
|
|
952
|
-
items.push(entity.putBatch(_objectSpread(_objectSpread({}, storageEntry), {}, {
|
|
953
|
-
PK: partitionKey,
|
|
954
|
-
SK: (0, _keys.createLatestSortKey)(),
|
|
955
|
-
TYPE: createLatestType()
|
|
956
|
-
})));
|
|
957
|
-
const preparedEntryData = (0, _helpers.prepareEntryToIndex)({
|
|
958
|
-
plugins,
|
|
959
|
-
model,
|
|
960
|
-
entry: (0, _lodash.default)(entry),
|
|
961
|
-
storageEntry: (0, _lodash.default)(storageEntry)
|
|
962
|
-
});
|
|
963
|
-
esLatestData = await getESLatestEntryData(plugins, preparedEntryData);
|
|
964
|
-
}
|
|
965
|
-
|
|
966
|
-
try {
|
|
967
|
-
await (0, _batchWrite.batchWriteAll)({
|
|
968
|
-
table: entity.table,
|
|
969
|
-
items
|
|
970
|
-
});
|
|
971
|
-
dataLoaders.clearAll({
|
|
972
|
-
model
|
|
973
|
-
});
|
|
974
|
-
} catch (ex) {
|
|
975
|
-
throw new _error.default(ex.message || "Could not store request changes entry record into DynamoDB table.", ex.code || "REQUEST_CHANGES_ERROR", {
|
|
976
|
-
entry,
|
|
977
|
-
latestStorageEntry,
|
|
978
|
-
originalEntry
|
|
979
|
-
});
|
|
980
|
-
}
|
|
981
|
-
/**
|
|
982
|
-
* No need to proceed further if nothing to put into Elasticsearch.
|
|
983
|
-
*/
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
if (!esLatestData) {
|
|
987
|
-
return storageEntry;
|
|
988
|
-
}
|
|
989
|
-
|
|
990
|
-
try {
|
|
991
|
-
await esEntity.put({
|
|
992
|
-
PK: partitionKey,
|
|
993
|
-
SK: (0, _keys.createLatestSortKey)(),
|
|
994
|
-
index,
|
|
995
|
-
data: esLatestData
|
|
996
|
-
});
|
|
997
|
-
} catch (ex) {
|
|
998
|
-
throw new _error.default(ex.message || "Could not store request changes entry record into DynamoDB Elasticsearch table.", ex.code || "REQUEST_CHANGES_ERROR", {
|
|
999
|
-
entry,
|
|
1000
|
-
latestStorageEntry,
|
|
1001
|
-
originalEntry
|
|
1002
|
-
});
|
|
1003
|
-
}
|
|
1004
|
-
|
|
1005
|
-
return storageEntry;
|
|
1006
|
-
};
|
|
1007
|
-
|
|
1008
|
-
const getAllRevisionsByIds = async (model, params) => {
|
|
1009
|
-
return await dataLoaders.getAllEntryRevisions({
|
|
1010
|
-
model,
|
|
1011
|
-
ids: params.ids
|
|
1012
|
-
});
|
|
1087
|
+
return initialStorageEntry;
|
|
1013
1088
|
};
|
|
1014
1089
|
|
|
1015
1090
|
const getLatestRevisionByEntryId = async (model, params) => {
|
|
1016
|
-
const
|
|
1091
|
+
const [entry] = await dataLoaders.getLatestRevisionByEntryId({
|
|
1017
1092
|
model,
|
|
1018
1093
|
ids: [params.id]
|
|
1019
1094
|
});
|
|
1020
1095
|
|
|
1021
|
-
if (
|
|
1096
|
+
if (!entry) {
|
|
1022
1097
|
return null;
|
|
1023
1098
|
}
|
|
1024
1099
|
|
|
1025
|
-
return
|
|
1100
|
+
return convertFromStorageEntry({
|
|
1101
|
+
model,
|
|
1102
|
+
entry
|
|
1103
|
+
});
|
|
1026
1104
|
};
|
|
1027
1105
|
|
|
1028
1106
|
const getPublishedRevisionByEntryId = async (model, params) => {
|
|
1029
|
-
const
|
|
1107
|
+
const [entry] = await dataLoaders.getPublishedRevisionByEntryId({
|
|
1030
1108
|
model,
|
|
1031
1109
|
ids: [params.id]
|
|
1032
1110
|
});
|
|
1033
1111
|
|
|
1034
|
-
if (
|
|
1112
|
+
if (!entry) {
|
|
1035
1113
|
return null;
|
|
1036
1114
|
}
|
|
1037
1115
|
|
|
1038
|
-
return
|
|
1116
|
+
return convertFromStorageEntry({
|
|
1117
|
+
model,
|
|
1118
|
+
entry
|
|
1119
|
+
});
|
|
1039
1120
|
};
|
|
1040
1121
|
|
|
1041
1122
|
const getRevisionById = async (model, params) => {
|
|
1042
|
-
const
|
|
1123
|
+
const [entry] = await dataLoaders.getRevisionById({
|
|
1043
1124
|
model,
|
|
1044
1125
|
ids: [params.id]
|
|
1045
1126
|
});
|
|
1046
1127
|
|
|
1047
|
-
if (
|
|
1128
|
+
if (!entry) {
|
|
1048
1129
|
return null;
|
|
1049
1130
|
}
|
|
1050
1131
|
|
|
1051
|
-
return
|
|
1132
|
+
return convertFromStorageEntry({
|
|
1133
|
+
model,
|
|
1134
|
+
entry
|
|
1135
|
+
});
|
|
1052
1136
|
};
|
|
1053
1137
|
|
|
1054
1138
|
const getRevisions = async (model, params) => {
|
|
1055
|
-
|
|
1139
|
+
const entries = await dataLoaders.getAllEntryRevisions({
|
|
1056
1140
|
model,
|
|
1057
1141
|
ids: [params.id]
|
|
1058
1142
|
});
|
|
1143
|
+
return entries.map(entry => {
|
|
1144
|
+
return convertFromStorageEntry({
|
|
1145
|
+
model,
|
|
1146
|
+
entry
|
|
1147
|
+
});
|
|
1148
|
+
});
|
|
1059
1149
|
};
|
|
1060
1150
|
|
|
1061
1151
|
const getByIds = async (model, params) => {
|
|
1062
|
-
|
|
1152
|
+
const entries = await dataLoaders.getRevisionById({
|
|
1063
1153
|
model,
|
|
1064
1154
|
ids: params.ids
|
|
1065
1155
|
});
|
|
1156
|
+
return entries.map(entry => {
|
|
1157
|
+
return convertFromStorageEntry({
|
|
1158
|
+
model,
|
|
1159
|
+
entry
|
|
1160
|
+
});
|
|
1161
|
+
});
|
|
1066
1162
|
};
|
|
1067
1163
|
|
|
1068
1164
|
const getLatestByIds = async (model, params) => {
|
|
1069
|
-
|
|
1165
|
+
const entries = await dataLoaders.getLatestRevisionByEntryId({
|
|
1070
1166
|
model,
|
|
1071
1167
|
ids: params.ids
|
|
1072
1168
|
});
|
|
1169
|
+
return entries.map(entry => {
|
|
1170
|
+
return convertFromStorageEntry({
|
|
1171
|
+
model,
|
|
1172
|
+
entry
|
|
1173
|
+
});
|
|
1174
|
+
});
|
|
1073
1175
|
};
|
|
1074
1176
|
|
|
1075
1177
|
const getPublishedByIds = async (model, params) => {
|
|
1076
|
-
|
|
1178
|
+
const entries = await dataLoaders.getPublishedRevisionByEntryId({
|
|
1077
1179
|
model,
|
|
1078
1180
|
ids: params.ids
|
|
1079
1181
|
});
|
|
1182
|
+
return entries.map(entry => {
|
|
1183
|
+
return convertFromStorageEntry({
|
|
1184
|
+
model,
|
|
1185
|
+
entry
|
|
1186
|
+
});
|
|
1187
|
+
});
|
|
1080
1188
|
};
|
|
1081
1189
|
|
|
1082
1190
|
const getPreviousRevision = async (model, params) => {
|
|
@@ -1114,9 +1222,18 @@ const createEntriesStorageOperations = params => {
|
|
|
1114
1222
|
|
|
1115
1223
|
try {
|
|
1116
1224
|
const result = await (0, _query.queryOne)(queryParams);
|
|
1117
|
-
|
|
1225
|
+
const entry = (0, _cleanup.cleanupItem)(entity, result);
|
|
1226
|
+
|
|
1227
|
+
if (!entry) {
|
|
1228
|
+
return null;
|
|
1229
|
+
}
|
|
1230
|
+
|
|
1231
|
+
return convertFromStorageEntry({
|
|
1232
|
+
entry,
|
|
1233
|
+
model
|
|
1234
|
+
});
|
|
1118
1235
|
} catch (ex) {
|
|
1119
|
-
throw new _error.default(ex.message || "Could not get previous version of given entry.", ex.code || "GET_PREVIOUS_VERSION_ERROR",
|
|
1236
|
+
throw new _error.default(ex.message || "Could not get previous version of given entry.", ex.code || "GET_PREVIOUS_VERSION_ERROR", (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
|
|
1120
1237
|
error: ex,
|
|
1121
1238
|
partitionKey: queryParams.partitionKey,
|
|
1122
1239
|
options: queryParams.options,
|
|
@@ -1134,10 +1251,7 @@ const createEntriesStorageOperations = params => {
|
|
|
1134
1251
|
get,
|
|
1135
1252
|
publish,
|
|
1136
1253
|
unpublish,
|
|
1137
|
-
requestReview,
|
|
1138
|
-
requestChanges,
|
|
1139
1254
|
list,
|
|
1140
|
-
getAllRevisionsByIds,
|
|
1141
1255
|
getLatestRevisionByEntryId,
|
|
1142
1256
|
getPublishedRevisionByEntryId,
|
|
1143
1257
|
getRevisionById,
|