@webiny/api-headless-cms-ddb-es 5.40.5 → 5.40.6-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js +9 -2
- package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js.map +1 -1
- package/operations/entry/elasticsearch/sort.js +5 -1
- package/operations/entry/elasticsearch/sort.js.map +1 -1
- package/operations/entry/index.js +204 -127
- package/operations/entry/index.js.map +1 -1
- package/package.json +23 -23
|
@@ -9,15 +9,15 @@ var _error = _interopRequireDefault(require("@webiny/error"));
|
|
|
9
9
|
var _CmsEntryFilterPlugin = require("../../../../../plugins/CmsEntryFilterPlugin");
|
|
10
10
|
var _apiElasticsearch = require("@webiny/api-elasticsearch");
|
|
11
11
|
const createRefFilterPlugin = () => {
|
|
12
|
-
|
|
12
|
+
const plugin = new _CmsEntryFilterPlugin.CmsEntryFilterPlugin({
|
|
13
13
|
fieldType: "ref",
|
|
14
14
|
exec: params => {
|
|
15
15
|
const {
|
|
16
16
|
applyFiltering,
|
|
17
|
-
value: values,
|
|
18
17
|
query,
|
|
19
18
|
field
|
|
20
19
|
} = params;
|
|
20
|
+
let values = params.value;
|
|
21
21
|
/**
|
|
22
22
|
* We must have an object when querying in the ref field.
|
|
23
23
|
*/
|
|
@@ -26,6 +26,11 @@ const createRefFilterPlugin = () => {
|
|
|
26
26
|
value: values
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
|
+
if (values === null || values === undefined) {
|
|
30
|
+
values = {
|
|
31
|
+
entryId: null
|
|
32
|
+
};
|
|
33
|
+
}
|
|
29
34
|
for (const key in values) {
|
|
30
35
|
const {
|
|
31
36
|
operator
|
|
@@ -44,6 +49,8 @@ const createRefFilterPlugin = () => {
|
|
|
44
49
|
}
|
|
45
50
|
}
|
|
46
51
|
});
|
|
52
|
+
plugin.name = `${plugin.type}.default.ref`;
|
|
53
|
+
return plugin;
|
|
47
54
|
};
|
|
48
55
|
exports.createRefFilterPlugin = createRefFilterPlugin;
|
|
49
56
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_error","_interopRequireDefault","require","_CmsEntryFilterPlugin","_apiElasticsearch","createRefFilterPlugin","CmsEntryFilterPlugin","fieldType","exec","params","applyFiltering","
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_CmsEntryFilterPlugin","_apiElasticsearch","createRefFilterPlugin","plugin","CmsEntryFilterPlugin","fieldType","exec","params","applyFiltering","query","field","values","value","WebinyError","undefined","entryId","key","operator","parseWhereKey","name","type","exports"],"sources":["refFilterPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsEntryFilterPlugin } from \"~/plugins/CmsEntryFilterPlugin\";\nimport { parseWhereKey } from \"@webiny/api-elasticsearch\";\n\nexport const createRefFilterPlugin = () => {\n const plugin = new CmsEntryFilterPlugin({\n fieldType: \"ref\",\n exec: params => {\n const { applyFiltering, query, field } = params;\n\n let values = params.value;\n /**\n * We must have an object when querying in the ref field.\n */\n if (typeof values !== \"object\") {\n throw new WebinyError(\n `When querying by ref field, value of the field must be an object.`,\n \"OBJECT_REQUIRED\",\n {\n value: values\n }\n );\n }\n\n if (values === null || values === undefined) {\n values = {\n entryId: null\n };\n }\n\n for (const key in values) {\n const { operator } = parseWhereKey(key);\n const value = values[key];\n if (value === undefined) {\n continue;\n }\n\n applyFiltering({\n query,\n field,\n operator,\n key,\n value\n });\n }\n }\n });\n\n plugin.name = `${plugin.type}.default.ref`;\n\n return plugin;\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,qBAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AAEO,MAAMG,qBAAqB,GAAGA,CAAA,KAAM;EACvC,MAAMC,MAAM,GAAG,IAAIC,0CAAoB,CAAC;IACpCC,SAAS,EAAE,KAAK;IAChBC,IAAI,EAAEC,MAAM,IAAI;MACZ,MAAM;QAAEC,cAAc;QAAEC,KAAK;QAAEC;MAAM,CAAC,GAAGH,MAAM;MAE/C,IAAII,MAAM,GAAGJ,MAAM,CAACK,KAAK;MACzB;AACZ;AACA;MACY,IAAI,OAAOD,MAAM,KAAK,QAAQ,EAAE;QAC5B,MAAM,IAAIE,cAAW,CAChB,mEAAkE,EACnE,iBAAiB,EACjB;UACID,KAAK,EAAED;QACX,CACJ,CAAC;MACL;MAEA,IAAIA,MAAM,KAAK,IAAI,IAAIA,MAAM,KAAKG,SAAS,EAAE;QACzCH,MAAM,GAAG;UACLI,OAAO,EAAE;QACb,CAAC;MACL;MAEA,KAAK,MAAMC,GAAG,IAAIL,MAAM,EAAE;QACtB,MAAM;UAAEM;QAAS,CAAC,GAAG,IAAAC,+BAAa,EAACF,GAAG,CAAC;QACvC,MAAMJ,KAAK,GAAGD,MAAM,CAACK,GAAG,CAAC;QACzB,IAAIJ,KAAK,KAAKE,SAAS,EAAE;UACrB;QACJ;QAEAN,cAAc,CAAC;UACXC,KAAK;UACLC,KAAK;UACLO,QAAQ;UACRD,GAAG;UACHJ;QACJ,CAAC,CAAC;MACN;IACJ;EACJ,CAAC,CAAC;EAEFT,MAAM,CAACgB,IAAI,GAAI,GAAEhB,MAAM,CAACiB,IAAK,cAAa;EAE1C,OAAOjB,MAAM;AACjB,CAAC;AAACkB,OAAA,CAAAnB,qBAAA,GAAAA,qBAAA","ignoreList":[]}
|
|
@@ -15,7 +15,11 @@ const createElasticsearchSort = params => {
|
|
|
15
15
|
plugins
|
|
16
16
|
} = params;
|
|
17
17
|
if (!sort || sort.length === 0) {
|
|
18
|
-
return [
|
|
18
|
+
return [{
|
|
19
|
+
["id.keyword"]: {
|
|
20
|
+
order: "asc"
|
|
21
|
+
}
|
|
22
|
+
}];
|
|
19
23
|
}
|
|
20
24
|
const searchPlugins = (0, _search.createSearchPluginList)({
|
|
21
25
|
plugins
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_apiElasticsearch","require","_keyword","_search","_path","createElasticsearchSort","params","sort","modelFields","plugins","length","searchPlugins","createSearchPluginList","createFieldPath","createFieldPathFactory","fieldIdToStorageIdIdMap","sortPlugins","Object","values","reduce","field","parents","fieldId","storageId","path","key","value","keyword","ElasticsearchFieldPlugin","unmappedType","hasKeyword","sortable","searchable","ALL","transformedSort","map","matched","match","
|
|
1
|
+
{"version":3,"names":["_apiElasticsearch","require","_keyword","_search","_path","createElasticsearchSort","params","sort","modelFields","plugins","length","order","searchPlugins","createSearchPluginList","createFieldPath","createFieldPathFactory","fieldIdToStorageIdIdMap","sortPlugins","Object","values","reduce","field","parents","fieldId","storageId","path","key","value","keyword","ElasticsearchFieldPlugin","unmappedType","hasKeyword","sortable","searchable","ALL","transformedSort","map","matched","match","filter","Boolean","createSort","fieldPlugins","exports"],"sources":["sort.ts"],"sourcesContent":["import { Sort as esSort } from \"@webiny/api-elasticsearch/types\";\nimport { createSort, ElasticsearchFieldPlugin } from \"@webiny/api-elasticsearch\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { CmsEntryListSort, CmsModel } from \"@webiny/api-headless-cms/types\";\nimport { ModelFields } from \"./types\";\nimport { hasKeyword } from \"~/operations/entry/elasticsearch/keyword\";\nimport { createSearchPluginList } from \"~/operations/entry/elasticsearch/plugins/search\";\nimport { createFieldPathFactory } from \"~/operations/entry/elasticsearch/filtering/path\";\n\ninterface Params {\n plugins: PluginsContainer;\n sort?: CmsEntryListSort;\n modelFields: ModelFields;\n model: CmsModel;\n}\nexport const createElasticsearchSort = (params: Params): esSort => {\n const { sort, modelFields, plugins } = params;\n\n if (!sort || sort.length === 0) {\n return [\n {\n [\"id.keyword\"]: {\n order: \"asc\"\n }\n }\n ];\n }\n\n const searchPlugins = createSearchPluginList({\n plugins\n });\n\n const createFieldPath = createFieldPathFactory({\n plugins: searchPlugins\n });\n\n const fieldIdToStorageIdIdMap: Record<string, string> = {};\n\n const sortPlugins = Object.values(modelFields).reduce<Record<string, ElasticsearchFieldPlugin>>(\n (plugins, field) => {\n /**\n * We do not support sorting by nested fields.\n */\n if (field.parents.length > 0) {\n return plugins;\n }\n const { fieldId, storageId } = field.field;\n\n fieldIdToStorageIdIdMap[fieldId] = fieldId;\n\n const { path } = createFieldPath({\n key: storageId,\n field,\n value: \"\",\n keyword: false\n });\n /**\n * Plugins must be stored with fieldId as key because it is later used to find the sorting plugin.\n */\n plugins[fieldId] = new ElasticsearchFieldPlugin({\n unmappedType: field.unmappedType,\n keyword: hasKeyword(field),\n sortable: field.sortable,\n searchable: field.searchable,\n field: fieldId,\n path\n });\n return plugins;\n },\n {\n [\"*\"]: new ElasticsearchFieldPlugin({\n field: ElasticsearchFieldPlugin.ALL,\n keyword: false\n })\n }\n );\n\n const transformedSort = sort\n .map(value => {\n const matched = value.match(/^([a-zA-Z-0-9_]+)_(ASC|DESC)$/);\n if (!matched) {\n return null;\n }\n const [, fieldId, order] = matched;\n if (fieldIdToStorageIdIdMap[fieldId]) {\n return `${fieldIdToStorageIdIdMap[fieldId]}_${order}`;\n }\n\n return value;\n })\n .filter(Boolean) as string[];\n return createSort({\n fieldPlugins: sortPlugins,\n sort: transformedSort\n });\n};\n"],"mappings":";;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AAIA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AAQO,MAAMI,uBAAuB,GAAIC,MAAc,IAAa;EAC/D,MAAM;IAAEC,IAAI;IAAEC,WAAW;IAAEC;EAAQ,CAAC,GAAGH,MAAM;EAE7C,IAAI,CAACC,IAAI,IAAIA,IAAI,CAACG,MAAM,KAAK,CAAC,EAAE;IAC5B,OAAO,CACH;MACI,CAAC,YAAY,GAAG;QACZC,KAAK,EAAE;MACX;IACJ,CAAC,CACJ;EACL;EAEA,MAAMC,aAAa,GAAG,IAAAC,8BAAsB,EAAC;IACzCJ;EAC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IAAI,CAACD,OAAO,EAAE;MACV,OAAO,IAAI;IACf;IACA,MAAM,GAAGd,OAAO,EAAEZ,KAAK,CAAC,GAAG0B,OAAO;IAClC,IAAIrB,uBAAuB,CAACO,OAAO,CAAC,EAAE;MAClC,OAAQ,GAAEP,uBAAuB,CAACO,OAAO,CAAE,IAAGZ,KAAM,EAAC;IACzD;IAEA,OAAOgB,KAAK;EAChB,CAAC,CAAC,CACDY,MAAM,CAACC,OAAO,CAAa;EAChC,OAAO,IAAAC,4BAAU,EAAC;IACdC,YAAY,EAAEzB,WAAW;IACzBV,IAAI,EAAE4B;EACV,CAAC,CAAC;AACN,CAAC;AAACQ,OAAA,CAAAtC,uBAAA,GAAAA,uBAAA","ignoreList":[]}
|
|
@@ -26,6 +26,20 @@ var _dbDynamodb = require("@webiny/db-dynamodb");
|
|
|
26
26
|
var _transformations = require("./transformations");
|
|
27
27
|
var _convertEntryKeys = require("./transformations/convertEntryKeys");
|
|
28
28
|
var _constants = require("@webiny/api-headless-cms/constants");
|
|
29
|
+
const convertToStorageEntry = params => {
|
|
30
|
+
const {
|
|
31
|
+
model,
|
|
32
|
+
storageEntry
|
|
33
|
+
} = params;
|
|
34
|
+
const values = model.convertValueKeyToStorage({
|
|
35
|
+
fields: model.fields,
|
|
36
|
+
values: storageEntry.values
|
|
37
|
+
});
|
|
38
|
+
return {
|
|
39
|
+
...storageEntry,
|
|
40
|
+
values
|
|
41
|
+
};
|
|
42
|
+
};
|
|
29
43
|
const createEntriesStorageOperations = params => {
|
|
30
44
|
const {
|
|
31
45
|
entity,
|
|
@@ -219,6 +233,25 @@ const createEntriesStorageOperations = params => {
|
|
|
219
233
|
TYPE: (0, _recordType.createPublishedRecordType)(),
|
|
220
234
|
...publishedKeys
|
|
221
235
|
}));
|
|
236
|
+
|
|
237
|
+
// Unpublish previously published revision (if any).
|
|
238
|
+
const [publishedRevisionStorageEntry] = await dataLoaders.getPublishedRevisionByEntryId({
|
|
239
|
+
model,
|
|
240
|
+
ids: [entry.id]
|
|
241
|
+
});
|
|
242
|
+
if (publishedRevisionStorageEntry) {
|
|
243
|
+
items.push(entity.putBatch({
|
|
244
|
+
...publishedRevisionStorageEntry,
|
|
245
|
+
PK: (0, _keys.createPartitionKey)({
|
|
246
|
+
id: publishedRevisionStorageEntry.id,
|
|
247
|
+
locale: model.locale,
|
|
248
|
+
tenant: model.tenant
|
|
249
|
+
}),
|
|
250
|
+
SK: (0, _keys.createRevisionSortKey)(publishedRevisionStorageEntry),
|
|
251
|
+
TYPE: (0, _recordType.createRecordType)(),
|
|
252
|
+
status: _types.CONTENT_ENTRY_STATUS.UNPUBLISHED
|
|
253
|
+
}));
|
|
254
|
+
}
|
|
222
255
|
}
|
|
223
256
|
try {
|
|
224
257
|
await (0, _batchWrite.batchWriteAll)({
|
|
@@ -945,7 +978,7 @@ const createEntriesStorageOperations = params => {
|
|
|
945
978
|
const {
|
|
946
979
|
entry,
|
|
947
980
|
latestEntry,
|
|
948
|
-
latestStorageEntry
|
|
981
|
+
latestStorageEntry: initialLatestStorageEntry
|
|
949
982
|
} = params;
|
|
950
983
|
const model = getStorageOperationsModel(initialModel);
|
|
951
984
|
const partitionKey = (0, _keys.createPartitionKey)({
|
|
@@ -986,12 +1019,17 @@ const createEntriesStorageOperations = params => {
|
|
|
986
1019
|
PK: partitionKey,
|
|
987
1020
|
SK: (0, _keys.createPublishedSortKey)()
|
|
988
1021
|
}));
|
|
989
|
-
esItems.push(
|
|
1022
|
+
esItems.push(esEntity.deleteBatch({
|
|
990
1023
|
PK: partitionKey,
|
|
991
1024
|
SK: (0, _keys.createPublishedSortKey)()
|
|
992
1025
|
}));
|
|
993
1026
|
}
|
|
994
|
-
if (latestEntry &&
|
|
1027
|
+
if (latestEntry && initialLatestStorageEntry) {
|
|
1028
|
+
const latestStorageEntry = convertToStorageEntry({
|
|
1029
|
+
storageEntry: initialLatestStorageEntry,
|
|
1030
|
+
model
|
|
1031
|
+
});
|
|
1032
|
+
|
|
995
1033
|
/**
|
|
996
1034
|
* In the end we need to set the new latest entry.
|
|
997
1035
|
*/
|
|
@@ -1009,18 +1047,18 @@ const createEntriesStorageOperations = params => {
|
|
|
1009
1047
|
items.push(entity.putBatch({
|
|
1010
1048
|
...latestStorageEntry,
|
|
1011
1049
|
PK: (0, _keys.createPartitionKey)({
|
|
1012
|
-
id:
|
|
1050
|
+
id: initialLatestStorageEntry.id,
|
|
1013
1051
|
locale: model.locale,
|
|
1014
1052
|
tenant: model.tenant
|
|
1015
1053
|
}),
|
|
1016
|
-
SK: (0, _keys.createRevisionSortKey)(
|
|
1054
|
+
SK: (0, _keys.createRevisionSortKey)(initialLatestStorageEntry),
|
|
1017
1055
|
TYPE: (0, _recordType.createRecordType)()
|
|
1018
1056
|
}));
|
|
1019
1057
|
const latestTransformer = (0, _transformations.createTransformer)({
|
|
1020
1058
|
plugins,
|
|
1021
1059
|
model,
|
|
1022
1060
|
entry: latestEntry,
|
|
1023
|
-
storageEntry:
|
|
1061
|
+
storageEntry: initialLatestStorageEntry
|
|
1024
1062
|
});
|
|
1025
1063
|
const esLatestData = await latestTransformer.getElasticsearchLatestEntryData();
|
|
1026
1064
|
esItems.push(esEntity.putBatch({
|
|
@@ -1043,7 +1081,7 @@ const createEntriesStorageOperations = params => {
|
|
|
1043
1081
|
error: ex,
|
|
1044
1082
|
entry,
|
|
1045
1083
|
latestEntry,
|
|
1046
|
-
|
|
1084
|
+
initialLatestStorageEntry
|
|
1047
1085
|
});
|
|
1048
1086
|
}
|
|
1049
1087
|
if (esItems.length === 0) {
|
|
@@ -1059,7 +1097,7 @@ const createEntriesStorageOperations = params => {
|
|
|
1059
1097
|
error: ex,
|
|
1060
1098
|
entry,
|
|
1061
1099
|
latestEntry,
|
|
1062
|
-
|
|
1100
|
+
initialLatestStorageEntry
|
|
1063
1101
|
});
|
|
1064
1102
|
}
|
|
1065
1103
|
};
|
|
@@ -1251,14 +1289,6 @@ const createEntriesStorageOperations = params => {
|
|
|
1251
1289
|
entry,
|
|
1252
1290
|
storageEntry
|
|
1253
1291
|
} = transformer.transformEntryKeys();
|
|
1254
|
-
|
|
1255
|
-
/**
|
|
1256
|
-
* We need currently published entry to check if need to remove it.
|
|
1257
|
-
*/
|
|
1258
|
-
const [publishedStorageEntry] = await dataLoaders.getPublishedRevisionByEntryId({
|
|
1259
|
-
model,
|
|
1260
|
-
ids: [entry.id]
|
|
1261
|
-
});
|
|
1262
1292
|
const revisionKeys = {
|
|
1263
1293
|
PK: (0, _keys.createPartitionKey)({
|
|
1264
1294
|
id: entry.id,
|
|
@@ -1296,10 +1326,42 @@ const createEntriesStorageOperations = params => {
|
|
|
1296
1326
|
publishedKeys: publishedKeys
|
|
1297
1327
|
});
|
|
1298
1328
|
}
|
|
1329
|
+
if (!latestEsEntry) {
|
|
1330
|
+
throw new _error.default(`Could not publish entry. Could not load latest ("L") record (ES table).`, "PUBLISH_ERROR", {
|
|
1331
|
+
entry
|
|
1332
|
+
});
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1335
|
+
/**
|
|
1336
|
+
* We need the latest entry to check if it needs to be updated as well in the Elasticsearch.
|
|
1337
|
+
*/
|
|
1338
|
+
const [latestStorageEntry] = await dataLoaders.getLatestRevisionByEntryId({
|
|
1339
|
+
model,
|
|
1340
|
+
ids: [entry.id]
|
|
1341
|
+
});
|
|
1342
|
+
if (!latestStorageEntry) {
|
|
1343
|
+
throw new _error.default(`Could not publish entry. Could not load latest ("L") record.`, "PUBLISH_ERROR", {
|
|
1344
|
+
entry
|
|
1345
|
+
});
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1348
|
+
/**
|
|
1349
|
+
* We need currently published entry to check if need to remove it.
|
|
1350
|
+
*/
|
|
1351
|
+
const [publishedStorageEntry] = await dataLoaders.getPublishedRevisionByEntryId({
|
|
1352
|
+
model,
|
|
1353
|
+
ids: [entry.id]
|
|
1354
|
+
});
|
|
1355
|
+
|
|
1356
|
+
// 1. Update REV# and P records with new data.
|
|
1299
1357
|
const items = [entity.putBatch({
|
|
1300
1358
|
...storageEntry,
|
|
1301
1359
|
...revisionKeys,
|
|
1302
1360
|
TYPE: (0, _recordType.createRecordType)()
|
|
1361
|
+
}), entity.putBatch({
|
|
1362
|
+
...storageEntry,
|
|
1363
|
+
...publishedKeys,
|
|
1364
|
+
TYPE: (0, _recordType.createPublishedRecordType)()
|
|
1303
1365
|
})];
|
|
1304
1366
|
const esItems = [];
|
|
1305
1367
|
const {
|
|
@@ -1307,130 +1369,91 @@ const createEntriesStorageOperations = params => {
|
|
|
1307
1369
|
} = _configurations.configurations.es({
|
|
1308
1370
|
model
|
|
1309
1371
|
});
|
|
1310
|
-
if (publishedStorageEntry && publishedStorageEntry.id !== entry.id) {
|
|
1311
|
-
/**
|
|
1312
|
-
* If there is a `published` entry already, we need to set it to `unpublished`. We need to
|
|
1313
|
-
* execute two updates: update the previously published entry's status and the published entry record.
|
|
1314
|
-
* DynamoDB does not support `batchUpdate` - so here we load the previously published
|
|
1315
|
-
* entry's data to update its status within a batch operation. If, hopefully,
|
|
1316
|
-
* they introduce a true update batch operation, remove this `read` call.
|
|
1317
|
-
*/
|
|
1318
|
-
const [previouslyPublishedEntry] = await dataLoaders.getRevisionById({
|
|
1319
|
-
model,
|
|
1320
|
-
ids: [publishedStorageEntry.id]
|
|
1321
|
-
});
|
|
1322
|
-
items.push(
|
|
1323
|
-
/**
|
|
1324
|
-
* Update currently published entry (unpublish it)
|
|
1325
|
-
*/
|
|
1326
|
-
entity.putBatch({
|
|
1327
|
-
...previouslyPublishedEntry,
|
|
1328
|
-
status: _types.CONTENT_ENTRY_STATUS.UNPUBLISHED,
|
|
1329
|
-
TYPE: (0, _recordType.createRecordType)(),
|
|
1330
|
-
PK: (0, _keys.createPartitionKey)(publishedStorageEntry),
|
|
1331
|
-
SK: (0, _keys.createRevisionSortKey)(publishedStorageEntry)
|
|
1332
|
-
}));
|
|
1333
|
-
}
|
|
1334
|
-
/**
|
|
1335
|
-
* Update the helper item in DB with the new published entry
|
|
1336
|
-
*/
|
|
1337
|
-
items.push(entity.putBatch({
|
|
1338
|
-
...storageEntry,
|
|
1339
|
-
...publishedKeys,
|
|
1340
|
-
TYPE: (0, _recordType.createPublishedRecordType)()
|
|
1341
|
-
}));
|
|
1342
1372
|
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
const
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
});
|
|
1350
|
-
if (latestStorageEntry?.id === entry.id) {
|
|
1373
|
+
// 2. When it comes to the latest record, we need to perform a couple of different
|
|
1374
|
+
// updates, based on whether the entry being published is the latest revision or not.
|
|
1375
|
+
const publishedRevisionId = publishedStorageEntry?.id;
|
|
1376
|
+
const publishingLatestRevision = latestStorageEntry?.id === entry.id;
|
|
1377
|
+
if (publishingLatestRevision) {
|
|
1378
|
+
// 2.1 If we're publishing the latest revision, we first need to update the L record.
|
|
1351
1379
|
items.push(entity.putBatch({
|
|
1352
1380
|
...storageEntry,
|
|
1353
1381
|
...latestKeys
|
|
1354
1382
|
}));
|
|
1355
|
-
}
|
|
1356
|
-
if (latestEsEntry) {
|
|
1357
|
-
const publishingLatestRevision = latestStorageEntry?.id === entry.id;
|
|
1358
1383
|
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
}
|
|
1377
|
-
}
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
} else {
|
|
1385
|
-
const updatedEntryLevelMetaFields = (0, _constants.pickEntryMetaFields)(entry, _constants.isEntryLevelEntryMetaField);
|
|
1386
|
-
const updatedLatestStorageEntry = {
|
|
1387
|
-
...latestStorageEntry,
|
|
1388
|
-
...latestKeys,
|
|
1389
|
-
...updatedEntryLevelMetaFields
|
|
1390
|
-
};
|
|
1384
|
+
// 2.2 Additionally, if we have a previously published entry, we need to mark it as unpublished.
|
|
1385
|
+
// Note that we need to take re-publishing into account (same published revision being
|
|
1386
|
+
// published again), in which case the below code does not apply. This is because the
|
|
1387
|
+
// required updates were already applied above.
|
|
1388
|
+
if (publishedStorageEntry) {
|
|
1389
|
+
const isRepublishing = publishedStorageEntry.id === entry.id;
|
|
1390
|
+
if (!isRepublishing) {
|
|
1391
|
+
items.push(
|
|
1392
|
+
/**
|
|
1393
|
+
* Update currently published entry (unpublish it)
|
|
1394
|
+
*/
|
|
1395
|
+
entity.putBatch({
|
|
1396
|
+
...publishedStorageEntry,
|
|
1397
|
+
status: _types.CONTENT_ENTRY_STATUS.UNPUBLISHED,
|
|
1398
|
+
TYPE: (0, _recordType.createRecordType)(),
|
|
1399
|
+
PK: (0, _keys.createPartitionKey)(publishedStorageEntry),
|
|
1400
|
+
SK: (0, _keys.createRevisionSortKey)(publishedStorageEntry)
|
|
1401
|
+
}));
|
|
1402
|
+
}
|
|
1403
|
+
}
|
|
1404
|
+
} else {
|
|
1405
|
+
// 2.3 If the published revision is not the latest one, the situation is a bit
|
|
1406
|
+
// more complex. We first need to update the L and REV# records with the new
|
|
1407
|
+
// values of *only entry-level* meta fields.
|
|
1408
|
+
const updatedEntryLevelMetaFields = (0, _constants.pickEntryMetaFields)(entry, _constants.isEntryLevelEntryMetaField);
|
|
1391
1409
|
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
TYPE: (0, _recordType.createLatestRecordType)()
|
|
1410
|
-
}));
|
|
1410
|
+
// 2.4 Update L record. Apart from updating the entry-level meta fields, we also need
|
|
1411
|
+
// to change the status from "published" to "unpublished" (if the status is set to "published").
|
|
1412
|
+
let latestRevisionStatus = latestStorageEntry.status;
|
|
1413
|
+
if (latestRevisionStatus === _types.CONTENT_ENTRY_STATUS.PUBLISHED) {
|
|
1414
|
+
latestRevisionStatus = _types.CONTENT_ENTRY_STATUS.UNPUBLISHED;
|
|
1415
|
+
}
|
|
1416
|
+
const latestStorageEntryFields = {
|
|
1417
|
+
...latestStorageEntry,
|
|
1418
|
+
...updatedEntryLevelMetaFields,
|
|
1419
|
+
status: latestRevisionStatus
|
|
1420
|
+
};
|
|
1421
|
+
items.push(entity.putBatch({
|
|
1422
|
+
...latestStorageEntryFields,
|
|
1423
|
+
PK: (0, _keys.createPartitionKey)(latestStorageEntry),
|
|
1424
|
+
SK: (0, _keys.createLatestSortKey)(),
|
|
1425
|
+
TYPE: (0, _recordType.createLatestRecordType)()
|
|
1426
|
+
}));
|
|
1411
1427
|
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1428
|
+
// 2.5 Update REV# record.
|
|
1429
|
+
items.push(entity.putBatch({
|
|
1430
|
+
...latestStorageEntryFields,
|
|
1431
|
+
PK: (0, _keys.createPartitionKey)(latestStorageEntry),
|
|
1432
|
+
SK: (0, _keys.createRevisionSortKey)(latestStorageEntry),
|
|
1433
|
+
TYPE: (0, _recordType.createRecordType)()
|
|
1434
|
+
}));
|
|
1435
|
+
|
|
1436
|
+
// 2.6 Additionally, if we have a previously published entry, we need to mark it as unpublished.
|
|
1437
|
+
// Note that we need to take re-publishing into account (same published revision being
|
|
1438
|
+
// published again), in which case the below code does not apply. This is because the
|
|
1439
|
+
// required updates were already applied above.
|
|
1440
|
+
if (publishedStorageEntry) {
|
|
1441
|
+
const isRepublishing = publishedStorageEntry.id === entry.id;
|
|
1442
|
+
const publishedRevisionDifferentFromLatest = publishedRevisionId !== latestStorageEntry.id;
|
|
1443
|
+
if (!isRepublishing && publishedRevisionDifferentFromLatest) {
|
|
1444
|
+
items.push(entity.putBatch({
|
|
1445
|
+
...publishedStorageEntry,
|
|
1446
|
+
PK: (0, _keys.createPartitionKey)(publishedStorageEntry),
|
|
1447
|
+
SK: (0, _keys.createRevisionSortKey)(publishedStorageEntry),
|
|
1448
|
+
TYPE: (0, _recordType.createRecordType)(),
|
|
1449
|
+
status: _types.CONTENT_ENTRY_STATUS.UNPUBLISHED
|
|
1429
1450
|
}));
|
|
1430
1451
|
}
|
|
1431
1452
|
}
|
|
1432
1453
|
}
|
|
1433
1454
|
|
|
1455
|
+
// 3. Update records in ES -> DDB table.
|
|
1456
|
+
|
|
1434
1457
|
/**
|
|
1435
1458
|
* Update the published revision entry in ES.
|
|
1436
1459
|
*/
|
|
@@ -1441,6 +1464,60 @@ const createEntriesStorageOperations = params => {
|
|
|
1441
1464
|
data: esPublishedData
|
|
1442
1465
|
}));
|
|
1443
1466
|
|
|
1467
|
+
/**
|
|
1468
|
+
* Need to decompress the data from Elasticsearch DynamoDB table.
|
|
1469
|
+
*
|
|
1470
|
+
* No need to transform it for the storage because it was fetched
|
|
1471
|
+
* directly from the Elasticsearch table, where it sits transformed.
|
|
1472
|
+
*/
|
|
1473
|
+
const latestEsEntryDataDecompressed = await (0, _apiElasticsearch.decompress)(plugins, latestEsEntry.data);
|
|
1474
|
+
if (publishingLatestRevision) {
|
|
1475
|
+
const updatedMetaFields = (0, _constants.pickEntryMetaFields)(entry);
|
|
1476
|
+
const latestTransformer = (0, _transformations.createTransformer)({
|
|
1477
|
+
plugins,
|
|
1478
|
+
model,
|
|
1479
|
+
transformedToIndex: {
|
|
1480
|
+
...latestEsEntryDataDecompressed,
|
|
1481
|
+
status: _types.CONTENT_ENTRY_STATUS.PUBLISHED,
|
|
1482
|
+
locked: true,
|
|
1483
|
+
...updatedMetaFields
|
|
1484
|
+
}
|
|
1485
|
+
});
|
|
1486
|
+
esItems.push(esEntity.putBatch({
|
|
1487
|
+
index: esIndex,
|
|
1488
|
+
PK: (0, _keys.createPartitionKey)(latestEsEntryDataDecompressed),
|
|
1489
|
+
SK: (0, _keys.createLatestSortKey)(),
|
|
1490
|
+
data: await latestTransformer.getElasticsearchLatestEntryData()
|
|
1491
|
+
}));
|
|
1492
|
+
} else {
|
|
1493
|
+
const updatedEntryLevelMetaFields = (0, _constants.pickEntryMetaFields)(entry, _constants.isEntryLevelEntryMetaField);
|
|
1494
|
+
|
|
1495
|
+
/**
|
|
1496
|
+
* Update the Elasticsearch table to propagate changes to the Elasticsearch.
|
|
1497
|
+
*/
|
|
1498
|
+
const latestEsEntry = await (0, _get.getClean)({
|
|
1499
|
+
entity: esEntity,
|
|
1500
|
+
keys: latestKeys
|
|
1501
|
+
});
|
|
1502
|
+
if (latestEsEntry) {
|
|
1503
|
+
const latestEsEntryDataDecompressed = await (0, _apiElasticsearch.decompress)(plugins, latestEsEntry.data);
|
|
1504
|
+
let latestRevisionStatus = latestEsEntryDataDecompressed.status;
|
|
1505
|
+
if (latestRevisionStatus === _types.CONTENT_ENTRY_STATUS.PUBLISHED) {
|
|
1506
|
+
latestRevisionStatus = _types.CONTENT_ENTRY_STATUS.UNPUBLISHED;
|
|
1507
|
+
}
|
|
1508
|
+
const updatedLatestEntry = await (0, _apiElasticsearch.compress)(plugins, {
|
|
1509
|
+
...latestEsEntryDataDecompressed,
|
|
1510
|
+
...updatedEntryLevelMetaFields,
|
|
1511
|
+
status: latestRevisionStatus
|
|
1512
|
+
});
|
|
1513
|
+
esItems.push(esEntity.putBatch({
|
|
1514
|
+
...latestKeys,
|
|
1515
|
+
index: esIndex,
|
|
1516
|
+
data: updatedLatestEntry
|
|
1517
|
+
}));
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1520
|
+
|
|
1444
1521
|
/**
|
|
1445
1522
|
* Finally, execute regular table batch.
|
|
1446
1523
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_error","_interopRequireDefault","require","_types","_helpers","_configurations","_batchWrite","_dataLoaders","_keys","_query","_apiElasticsearch","_get","_utils","_cleanup","_body","_logIgnoredEsResponseError","_shouldIgnoreEsResponseError","_recordType","_apiHeadlessCms","_dbDynamodb","_transformations","_convertEntryKeys","_constants","createEntriesStorageOperations","params","entity","esEntity","elasticsearch","plugins","storageOperationsCmsModelPlugin","getStorageOperationsCmsModelPlugin","oneByType","StorageOperationsCmsModelPlugin","type","getStorageOperationsModel","model","plugin","getModel","dataLoaders","DataLoadersHandler","create","initialModel","entry","initialEntry","storageEntry","initialStorageEntry","isPublished","status","locked","transformer","createTransformer","transformEntryKeys","esEntry","transformToIndex","index","esIndex","configurations","es","revisionKeys","PK","createPartitionKey","id","locale","tenant","SK","createRevisionSortKey","latestKeys","createLatestSortKey","publishedKeys","createPublishedSortKey","items","putBatch","TYPE","createRecordType","createLatestRecordType","push","createPublishedRecordType","batchWriteAll","table","clearAll","ex","WebinyError","message","code","error","esLatestData","getElasticsearchLatestEntryData","esItems","data","esPublishedData","getElasticsearchPublishedEntryData","createRevisionFrom","update","latestStorageEntry","getLatestRevisionByEntryId","ids","publishedStorageEntry","getPublishedRevisionByEntryId","updatingLatestRevision","elasticsearchLatestData","updatedEntryLevelMetaFields","pickEntryMetaFields","isEntryLevelEntryMetaField","updatedLatestStorageEntry","latestEsEntry","getClean","keys","latestEsEntryDataDecompressed","decompress","updatedLatestEntry","compress","elasticsearchPublishedData","length","move","folderId","partitionKey","queryAllParams","options","gte","latestSortKey","publishedSortKey","records","queryAll","latestRecord","undefined","publishedRecord","record","location","esGetItems","getBatch","esRecords","batchReadAll","Promise","all","map","filter","Boolean","esUpdateItems","item","moveToBin","updatedEntryMetaFields","isDeletedEntryMetaField","wbyDeleted","binOriginalFolderId","restoreFromBin","isRestoredEntryMetaField","deleteEntry","entryId","deleteItems","deleteBatch","deleteEsItems","deleteRevision","latestEntry","latestTransformer","deleteMultipleEntries","entries","revisions","getAllEntryRevisions","revision","version","list","limit","createLimit","body","createElasticsearchBody","after","decodeCursor","response","search","shouldIgnoreEsResponseError","logIgnoredEsResponseError","indexName","hasMoreItems","totalCount","cursor","hits","total","extractEntriesFromIndex","_source","convertEntryKeysFromStorage","pop","encodeCursor","sort","value","get","shift","publish","previouslyPublishedEntry","getRevisionById","CONTENT_ENTRY_STATUS","UNPUBLISHED","publishingLatestRevision","updatedMetaFields","transformedToIndex","PUBLISHED","unpublish","getRevisions","getByIds","getLatestByIds","getPublishedByIds","getPreviousRevision","queryParams","lt","zeroPad","filters","attr","eq","reverse","result","queryOne","cleanupItem","getUniqueFieldValues","where","fieldId","initialBody","field","fields","find","f","size","aggregations","terms","storageId","buckets","file","key","count","doc_count","delete","exports"],"sources":["index.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport {\n CmsEntry,\n CmsModel,\n CONTENT_ENTRY_STATUS,\n StorageOperationsCmsModel\n} from \"@webiny/api-headless-cms/types\";\nimport { extractEntriesFromIndex } from \"~/helpers\";\nimport { configurations } from \"~/configurations\";\nimport { Entity } from \"@webiny/db-dynamodb/toolbox\";\nimport { Client } from \"@elastic/elasticsearch\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { batchWriteAll, BatchWriteItem } from \"@webiny/db-dynamodb/utils/batchWrite\";\nimport { DataLoadersHandler } from \"./dataLoaders\";\nimport {\n createLatestSortKey,\n createPartitionKey,\n createPublishedSortKey,\n createRevisionSortKey\n} from \"./keys\";\nimport {\n queryAll,\n QueryAllParams,\n queryOne,\n QueryOneParams\n} from \"@webiny/db-dynamodb/utils/query\";\nimport {\n compress,\n createLimit,\n decodeCursor,\n decompress,\n encodeCursor\n} from \"@webiny/api-elasticsearch\";\nimport { getClean } from \"@webiny/db-dynamodb/utils/get\";\nimport { zeroPad } from \"@webiny/utils\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport {\n ElasticsearchSearchResponse,\n SearchBody as ElasticsearchSearchBody\n} from \"@webiny/api-elasticsearch/types\";\nimport { CmsEntryStorageOperations, CmsIndexEntry } from \"~/types\";\nimport { createElasticsearchBody } from \"./elasticsearch/body\";\nimport { logIgnoredEsResponseError } from \"./elasticsearch/logIgnoredEsResponseError\";\nimport { shouldIgnoreEsResponseError } from \"./elasticsearch/shouldIgnoreEsResponseError\";\nimport { createLatestRecordType, createPublishedRecordType, createRecordType } from \"./recordType\";\nimport { StorageOperationsCmsModelPlugin } from \"@webiny/api-headless-cms\";\nimport { WriteRequest } from \"@webiny/aws-sdk/client-dynamodb\";\nimport { batchReadAll, BatchReadItem } from \"@webiny/db-dynamodb\";\nimport { createTransformer } from \"./transformations\";\nimport { convertEntryKeysFromStorage } from \"./transformations/convertEntryKeys\";\nimport {\n isDeletedEntryMetaField,\n isEntryLevelEntryMetaField,\n isRestoredEntryMetaField,\n pickEntryMetaFields\n} from \"@webiny/api-headless-cms/constants\";\n\ninterface ElasticsearchDbRecord {\n index: string;\n data: Record<string, any>;\n}\n\nexport interface CreateEntriesStorageOperationsParams {\n entity: Entity<any>;\n esEntity: Entity<any>;\n elasticsearch: Client;\n plugins: PluginsContainer;\n}\n\nexport const createEntriesStorageOperations = (\n params: CreateEntriesStorageOperationsParams\n): CmsEntryStorageOperations => {\n const { entity, esEntity, elasticsearch, plugins } = params;\n\n let storageOperationsCmsModelPlugin: StorageOperationsCmsModelPlugin | undefined;\n const getStorageOperationsCmsModelPlugin = () => {\n if (storageOperationsCmsModelPlugin) {\n return storageOperationsCmsModelPlugin;\n }\n storageOperationsCmsModelPlugin = plugins.oneByType<StorageOperationsCmsModelPlugin>(\n StorageOperationsCmsModelPlugin.type\n );\n return storageOperationsCmsModelPlugin;\n };\n\n const getStorageOperationsModel = (model: CmsModel): StorageOperationsCmsModel => {\n const plugin = getStorageOperationsCmsModelPlugin();\n return plugin.getModel(model);\n };\n\n const dataLoaders = new DataLoadersHandler({\n entity\n });\n\n const create: CmsEntryStorageOperations[\"create\"] = async (initialModel, params) => {\n const { entry: initialEntry, storageEntry: initialStorageEntry } = params;\n\n const model = getStorageOperationsModel(initialModel);\n\n const isPublished = initialEntry.status === \"published\";\n const locked = isPublished ? true : initialEntry.locked;\n\n initialEntry.locked = locked;\n initialStorageEntry.locked = locked;\n\n const transformer = createTransformer({\n plugins,\n model,\n entry: initialEntry,\n storageEntry: initialStorageEntry\n });\n\n const { entry, storageEntry } = transformer.transformEntryKeys();\n\n const esEntry = transformer.transformToIndex();\n\n const { index: esIndex } = configurations.es({\n model\n });\n\n const revisionKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createRevisionSortKey(entry)\n };\n\n const latestKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createLatestSortKey()\n };\n\n const publishedKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createPublishedSortKey()\n };\n\n const items = [\n entity.putBatch({\n ...storageEntry,\n locked,\n ...revisionKeys,\n TYPE: createRecordType()\n }),\n entity.putBatch({\n ...storageEntry,\n locked,\n ...latestKeys,\n TYPE: createLatestRecordType()\n })\n ];\n\n if (isPublished) {\n items.push(\n entity.putBatch({\n ...storageEntry,\n locked,\n ...publishedKeys,\n TYPE: createPublishedRecordType()\n })\n );\n }\n\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not insert entry data into the DynamoDB table.\",\n ex.code || \"CREATE_ENTRY_ERROR\",\n {\n error: ex,\n entry,\n storageEntry\n }\n );\n }\n\n const esLatestData = await transformer.getElasticsearchLatestEntryData();\n const esItems: BatchWriteItem[] = [\n esEntity.putBatch({\n ...latestKeys,\n index: esIndex,\n data: esLatestData\n })\n ];\n if (isPublished) {\n const esPublishedData = await transformer.getElasticsearchPublishedEntryData();\n esItems.push(\n esEntity.putBatch({\n ...publishedKeys,\n index: esIndex,\n data: esPublishedData\n })\n );\n }\n\n try {\n await batchWriteAll({\n table: esEntity.table,\n items: esItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not insert entry data into the Elasticsearch DynamoDB table.\",\n ex.code || \"CREATE_ES_ENTRY_ERROR\",\n {\n error: ex,\n entry,\n esEntry\n }\n );\n }\n\n return initialStorageEntry;\n };\n\n const createRevisionFrom: CmsEntryStorageOperations[\"createRevisionFrom\"] = async (\n initialModel,\n params\n ) => {\n const { entry: initialEntry, storageEntry: initialStorageEntry } = params;\n const model = getStorageOperationsModel(initialModel);\n\n const transformer = createTransformer({\n plugins,\n model,\n entry: initialEntry,\n storageEntry: initialStorageEntry\n });\n const { entry, storageEntry } = transformer.transformEntryKeys();\n\n const revisionKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createRevisionSortKey(entry)\n };\n const latestKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createLatestSortKey()\n };\n\n const publishedKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createPublishedSortKey()\n };\n\n // We'll need this flag below.\n const isPublished = entry.status === \"published\";\n\n const esLatestData = await transformer.getElasticsearchLatestEntryData();\n\n const items = [\n entity.putBatch({\n ...storageEntry,\n TYPE: createRecordType(),\n ...revisionKeys\n }),\n entity.putBatch({\n ...storageEntry,\n TYPE: createLatestRecordType(),\n ...latestKeys\n })\n ];\n\n if (isPublished) {\n items.push(\n entity.putBatch({\n ...storageEntry,\n TYPE: createPublishedRecordType(),\n ...publishedKeys\n })\n );\n }\n\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create revision from given entry in the DynamoDB table.\",\n ex.code || \"CREATE_REVISION_ERROR\",\n {\n error: ex,\n entry,\n storageEntry\n }\n );\n }\n\n const { index: esIndex } = configurations.es({\n model\n });\n\n const esItems: BatchWriteItem[] = [\n esEntity.putBatch({\n ...latestKeys,\n index: esIndex,\n data: esLatestData\n })\n ];\n\n if (isPublished) {\n const esPublishedData = await transformer.getElasticsearchPublishedEntryData();\n esItems.push(\n esEntity.putBatch({\n ...publishedKeys,\n index: esIndex,\n data: esPublishedData\n })\n );\n }\n\n try {\n await batchWriteAll({\n table: esEntity.table,\n items: esItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update latest entry in the DynamoDB Elasticsearch table.\",\n ex.code || \"CREATE_REVISION_ERROR\",\n {\n error: ex,\n entry\n }\n );\n }\n /**\n * There are no modifications on the entry created so just return the data.\n */\n return initialStorageEntry;\n };\n\n const update: CmsEntryStorageOperations[\"update\"] = async (initialModel, params) => {\n const { entry: initialEntry, storageEntry: initialStorageEntry } = params;\n const model = getStorageOperationsModel(initialModel);\n\n const transformer = createTransformer({\n plugins,\n model,\n entry: initialEntry,\n storageEntry: initialStorageEntry\n });\n\n const { entry, storageEntry } = transformer.transformEntryKeys();\n\n const isPublished = entry.status === \"published\";\n const locked = isPublished ? true : entry.locked;\n\n const revisionKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createRevisionSortKey(entry)\n };\n const latestKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createLatestSortKey()\n };\n\n const publishedKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createPublishedSortKey()\n };\n\n /**\n * We need the latest entry to check if it needs to be updated.\n */\n const [latestStorageEntry] = await dataLoaders.getLatestRevisionByEntryId({\n model,\n ids: [entry.id]\n });\n\n const [publishedStorageEntry] = await dataLoaders.getPublishedRevisionByEntryId({\n model,\n ids: [entry.id]\n });\n\n const items = [\n entity.putBatch({\n ...storageEntry,\n locked,\n ...revisionKeys,\n TYPE: createRecordType()\n })\n ];\n if (isPublished) {\n items.push(\n entity.putBatch({\n ...storageEntry,\n locked,\n ...publishedKeys,\n TYPE: createPublishedRecordType()\n })\n );\n }\n\n const esItems: BatchWriteItem[] = [];\n\n const { index: esIndex } = configurations.es({\n model\n });\n\n /**\n * If the latest entry is the one being updated, we need to create a new latest entry records.\n */\n if (latestStorageEntry) {\n const updatingLatestRevision = latestStorageEntry.id === entry.id;\n if (updatingLatestRevision) {\n /**\n * First we update the regular DynamoDB table.\n */\n items.push(\n entity.putBatch({\n ...storageEntry,\n ...latestKeys,\n TYPE: createLatestRecordType()\n })\n );\n\n /**\n * And then update the Elasticsearch table to propagate changes to the Elasticsearch\n */\n const elasticsearchLatestData = await transformer.getElasticsearchLatestEntryData();\n\n esItems.push(\n esEntity.putBatch({\n ...latestKeys,\n index: esIndex,\n data: elasticsearchLatestData\n })\n );\n } else {\n /**\n * If not updating latest revision, we still want to update the latest revision's\n * entry-level meta fields to match the current revision's entry-level meta fields.\n */\n const updatedEntryLevelMetaFields = pickEntryMetaFields(\n entry,\n isEntryLevelEntryMetaField\n );\n\n const updatedLatestStorageEntry = {\n ...latestStorageEntry,\n ...latestKeys,\n ...updatedEntryLevelMetaFields\n };\n\n /**\n * First we update the regular DynamoDB table. Two updates are needed:\n * - one for the actual revision record\n * - one for the latest record\n */\n items.push(\n entity.putBatch({\n ...updatedLatestStorageEntry,\n PK: createPartitionKey({\n id: latestStorageEntry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createRevisionSortKey(latestStorageEntry),\n TYPE: createRecordType()\n })\n );\n\n items.push(\n entity.putBatch({\n ...updatedLatestStorageEntry,\n TYPE: createLatestRecordType()\n })\n );\n\n /**\n * Update the Elasticsearch table to propagate changes to the Elasticsearch.\n */\n const latestEsEntry = await getClean<ElasticsearchDbRecord>({\n entity: esEntity,\n keys: latestKeys\n });\n\n if (latestEsEntry) {\n const latestEsEntryDataDecompressed = (await decompress(\n plugins,\n latestEsEntry.data\n )) as CmsIndexEntry;\n\n const updatedLatestEntry = await compress(plugins, {\n ...latestEsEntryDataDecompressed,\n ...updatedEntryLevelMetaFields\n });\n\n esItems.push(\n esEntity.putBatch({\n ...latestKeys,\n index: esIndex,\n data: updatedLatestEntry\n })\n );\n }\n }\n }\n\n if (isPublished && publishedStorageEntry?.id === entry.id) {\n const elasticsearchPublishedData =\n await transformer.getElasticsearchPublishedEntryData();\n esItems.push(\n esEntity.putBatch({\n ...publishedKeys,\n index: esIndex,\n data: elasticsearchPublishedData\n })\n );\n }\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update entry DynamoDB records.\",\n ex.code || \"UPDATE_ENTRY_ERROR\",\n {\n error: ex,\n entry,\n storageEntry\n }\n );\n }\n if (esItems.length === 0) {\n return initialStorageEntry;\n }\n\n try {\n await batchWriteAll({\n table: esEntity.table,\n items: esItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update entry DynamoDB Elasticsearch records.\",\n ex.code || \"UPDATE_ES_ENTRY_ERROR\",\n {\n error: ex,\n entry\n }\n );\n }\n return initialStorageEntry;\n };\n\n const move: CmsEntryStorageOperations[\"move\"] = async (initialModel, id, folderId) => {\n const model = getStorageOperationsModel(initialModel);\n\n const partitionKey = createPartitionKey({\n id,\n locale: model.locale,\n tenant: model.tenant\n });\n /**\n * First we need to fetch all the records in the regular DynamoDB table.\n */\n const queryAllParams: QueryAllParams = {\n entity,\n partitionKey,\n options: {\n gte: \" \"\n }\n };\n const latestSortKey = createLatestSortKey();\n const publishedSortKey = createPublishedSortKey();\n const records = await queryAll<CmsEntry>(queryAllParams);\n /**\n * Then update the folderId in each record and prepare it to be stored.\n */\n let latestRecord: CmsEntry | undefined = undefined;\n let publishedRecord: CmsEntry | undefined = undefined;\n const items: BatchWriteItem[] = [];\n for (const record of records) {\n items.push(\n entity.putBatch({\n ...record,\n location: {\n ...record?.location,\n folderId\n }\n })\n );\n /**\n * We need to get the published and latest records, so we can update the Elasticsearch.\n */\n if (record.SK === publishedSortKey) {\n publishedRecord = record;\n } else if (record.SK === latestSortKey) {\n latestRecord = record;\n }\n }\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not move all entry records from in the DynamoDB table.\",\n ex.code || \"MOVE_ENTRY_ERROR\",\n {\n error: ex,\n id\n }\n );\n }\n const esGetItems: BatchReadItem[] = [];\n if (publishedRecord) {\n esGetItems.push(\n esEntity.getBatch({\n PK: partitionKey,\n SK: publishedSortKey\n })\n );\n }\n if (latestRecord) {\n esGetItems.push(\n esEntity.getBatch({\n PK: partitionKey,\n SK: latestSortKey\n })\n );\n }\n if (esGetItems.length === 0) {\n return;\n }\n const esRecords = await batchReadAll<ElasticsearchDbRecord>({\n table: esEntity.table,\n items: esGetItems\n });\n const esItems = (\n await Promise.all(\n esRecords.map(async record => {\n if (!record) {\n return null;\n }\n return {\n ...record,\n data: await decompress(plugins, record.data)\n };\n })\n )\n ).filter(Boolean) as ElasticsearchDbRecord[];\n\n if (esItems.length === 0) {\n return;\n }\n const esUpdateItems: BatchWriteItem[] = [];\n for (const item of esItems) {\n esUpdateItems.push(\n esEntity.putBatch({\n ...item,\n data: await compress(plugins, {\n ...item.data,\n location: {\n ...item.data?.location,\n folderId\n }\n })\n })\n );\n }\n\n try {\n await batchWriteAll({\n table: esEntity.table,\n items: esUpdateItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not move entry DynamoDB Elasticsearch records.\",\n ex.code || \"MOVE_ES_ENTRY_ERROR\",\n {\n error: ex,\n partitionKey\n }\n );\n }\n };\n\n const moveToBin: CmsEntryStorageOperations[\"moveToBin\"] = async (initialModel, params) => {\n const { entry: initialEntry, storageEntry: initialStorageEntry } = params;\n const model = getStorageOperationsModel(initialModel);\n\n const transformer = createTransformer({\n plugins,\n model,\n entry: initialEntry,\n storageEntry: initialStorageEntry\n });\n\n const { entry, storageEntry } = transformer.transformEntryKeys();\n\n const partitionKey = createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n });\n\n /**\n * First we need to fetch all the records in the regular DynamoDB table.\n */\n const queryAllParams: QueryAllParams = {\n entity,\n partitionKey,\n options: {\n gte: \" \"\n }\n };\n\n const latestSortKey = createLatestSortKey();\n const publishedSortKey = createPublishedSortKey();\n const records = await queryAll<CmsEntry>(queryAllParams);\n\n /**\n * Let's pick the `deleted` meta fields from the entry.\n */\n const updatedEntryMetaFields = pickEntryMetaFields(entry, isDeletedEntryMetaField);\n\n /**\n * Then update all the records with data received.\n */\n let latestRecord: CmsEntry | undefined = undefined;\n let publishedRecord: CmsEntry | undefined = undefined;\n const items: BatchWriteItem[] = [];\n\n for (const record of records) {\n items.push(\n entity.putBatch({\n ...record,\n ...updatedEntryMetaFields,\n wbyDeleted: storageEntry.wbyDeleted,\n location: storageEntry.location,\n binOriginalFolderId: storageEntry.binOriginalFolderId\n })\n );\n /**\n * We need to get the published and latest records, so we can update the Elasticsearch.\n */\n if (record.SK === publishedSortKey) {\n publishedRecord = record;\n } else if (record.SK === latestSortKey) {\n latestRecord = record;\n }\n }\n\n /**\n * We write the records back to the primary DynamoDB table.\n */\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could mark as deleted all entry records from in the DynamoDB table.\",\n ex.code || \"MOVE_ENTRY_TO_BIN_ERROR\",\n {\n error: ex,\n entry,\n storageEntry\n }\n );\n }\n\n /**\n * We need to get the published and latest records from Elasticsearch.\n */\n const esGetItems: BatchReadItem[] = [];\n if (publishedRecord) {\n esGetItems.push(\n esEntity.getBatch({\n PK: partitionKey,\n SK: publishedSortKey\n })\n );\n }\n if (latestRecord) {\n esGetItems.push(\n esEntity.getBatch({\n PK: partitionKey,\n SK: latestSortKey\n })\n );\n }\n if (esGetItems.length === 0) {\n return;\n }\n\n const esRecords = await batchReadAll<ElasticsearchDbRecord>({\n table: esEntity.table,\n items: esGetItems\n });\n\n const esItems = (\n await Promise.all(\n esRecords.map(async record => {\n if (!record) {\n return null;\n }\n return {\n ...record,\n data: await decompress(plugins, record.data)\n };\n })\n )\n ).filter(Boolean) as ElasticsearchDbRecord[];\n\n if (esItems.length === 0) {\n return;\n }\n\n /**\n * We update all ES records with data received.\n */\n const esUpdateItems: BatchWriteItem[] = [];\n for (const item of esItems) {\n esUpdateItems.push(\n esEntity.putBatch({\n ...item,\n data: await compress(plugins, {\n ...item.data,\n ...updatedEntryMetaFields,\n wbyDeleted: entry.wbyDeleted,\n location: entry.location,\n binOriginalFolderId: entry.binOriginalFolderId\n })\n })\n );\n }\n\n /**\n * We write the records back to the primary DynamoDB Elasticsearch table.\n */\n try {\n await batchWriteAll({\n table: esEntity.table,\n items: esUpdateItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message ||\n \"Could not mark as deleted entry records from DynamoDB Elasticsearch table.\",\n ex.code || \"MOVE_ENTRY_TO_BIN_ERROR\",\n {\n error: ex,\n entry,\n storageEntry\n }\n );\n }\n };\n\n const restoreFromBin: CmsEntryStorageOperations[\"restoreFromBin\"] = async (\n initialModel,\n params\n ) => {\n const { entry: initialEntry, storageEntry: initialStorageEntry } = params;\n const model = getStorageOperationsModel(initialModel);\n\n const transformer = createTransformer({\n plugins,\n model,\n entry: initialEntry,\n storageEntry: initialStorageEntry\n });\n\n const { entry, storageEntry } = transformer.transformEntryKeys();\n\n /**\n * Let's pick the `restored` meta fields from the storage entry.\n */\n const updatedEntryMetaFields = pickEntryMetaFields(entry, isRestoredEntryMetaField);\n\n const partitionKey = createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n });\n\n /**\n * First we need to fetch all the records in the regular DynamoDB table.\n */\n const queryAllParams: QueryAllParams = {\n entity,\n partitionKey,\n options: {\n gte: \" \"\n }\n };\n\n const latestSortKey = createLatestSortKey();\n const publishedSortKey = createPublishedSortKey();\n const records = await queryAll<CmsEntry>(queryAllParams);\n\n /**\n * Then update all the records with data received.\n */\n let latestRecord: CmsEntry | undefined = undefined;\n let publishedRecord: CmsEntry | undefined = undefined;\n const items: BatchWriteItem[] = [];\n\n for (const record of records) {\n items.push(\n entity.putBatch({\n ...record,\n ...updatedEntryMetaFields,\n wbyDeleted: storageEntry.wbyDeleted,\n location: storageEntry.location,\n binOriginalFolderId: storageEntry.binOriginalFolderId\n })\n );\n /**\n * We need to get the published and latest records, so we can update the Elasticsearch.\n */\n if (record.SK === publishedSortKey) {\n publishedRecord = record;\n } else if (record.SK === latestSortKey) {\n latestRecord = record;\n }\n }\n\n /**\n * We write the records back to the primary DynamoDB table.\n */\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not restore all entry records from in the DynamoDB table.\",\n ex.code || \"RESTORE_ENTRY_ERROR\",\n {\n error: ex,\n entry,\n storageEntry\n }\n );\n }\n\n /**\n * We need to get the published and latest records from Elasticsearch.\n */\n const esGetItems: BatchReadItem[] = [];\n if (publishedRecord) {\n esGetItems.push(\n esEntity.getBatch({\n PK: partitionKey,\n SK: publishedSortKey\n })\n );\n }\n if (latestRecord) {\n esGetItems.push(\n esEntity.getBatch({\n PK: partitionKey,\n SK: latestSortKey\n })\n );\n }\n\n const esRecords = await batchReadAll<ElasticsearchDbRecord>({\n table: esEntity.table,\n items: esGetItems\n });\n\n const esItems = (\n await Promise.all(\n esRecords.map(async record => {\n if (!record) {\n return null;\n }\n return {\n ...record,\n data: await decompress(plugins, record.data)\n };\n })\n )\n ).filter(Boolean) as ElasticsearchDbRecord[];\n\n if (esItems.length === 0) {\n return initialStorageEntry;\n }\n\n /**\n * We update all ES records with data received.\n */\n const esUpdateItems: BatchWriteItem[] = [];\n for (const item of esItems) {\n esUpdateItems.push(\n esEntity.putBatch({\n ...item,\n data: await compress(plugins, {\n ...item.data,\n ...updatedEntryMetaFields,\n wbyDeleted: entry.wbyDeleted,\n location: entry.location,\n binOriginalFolderId: entry.binOriginalFolderId\n })\n })\n );\n }\n\n /**\n * We write the records back to the primary DynamoDB Elasticsearch table.\n */\n try {\n await batchWriteAll({\n table: esEntity.table,\n items: esUpdateItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not restore entry records from DynamoDB Elasticsearch table.\",\n ex.code || \"RESTORE_ENTRY_ERROR\",\n {\n error: ex,\n entry,\n storageEntry\n }\n );\n }\n\n return initialStorageEntry;\n };\n\n const deleteEntry: CmsEntryStorageOperations[\"delete\"] = async (initialModel, params) => {\n const { entry } = params;\n const id = entry.id || entry.entryId;\n const model = getStorageOperationsModel(initialModel);\n\n const partitionKey = createPartitionKey({\n id,\n locale: model.locale,\n tenant: model.tenant\n });\n\n const items = await queryAll<CmsEntry>({\n entity,\n partitionKey,\n options: {\n gte: \" \"\n }\n });\n\n const esItems = await queryAll<CmsEntry>({\n entity: esEntity,\n partitionKey,\n options: {\n gte: \" \"\n }\n });\n\n const deleteItems = items.map(item => {\n return entity.deleteBatch({\n PK: item.PK,\n SK: item.SK\n });\n });\n\n const deleteEsItems = esItems.map(item => {\n return esEntity.deleteBatch({\n PK: item.PK,\n SK: item.SK\n });\n });\n\n try {\n await batchWriteAll({\n table: entity.table,\n items: deleteItems\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not destroy entry records from DynamoDB table.\",\n ex.code || \"DELETE_ENTRY_ERROR\",\n {\n error: ex,\n id\n }\n );\n }\n\n try {\n await batchWriteAll({\n table: esEntity.table,\n items: deleteEsItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not destroy entry records from DynamoDB Elasticsearch table.\",\n ex.code || \"DELETE_ENTRY_ERROR\",\n {\n error: ex,\n id\n }\n );\n }\n };\n\n const deleteRevision: CmsEntryStorageOperations[\"deleteRevision\"] = async (\n initialModel,\n params\n ) => {\n const { entry, latestEntry, latestStorageEntry } = params;\n const model = getStorageOperationsModel(initialModel);\n\n const partitionKey = createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n });\n\n const { index } = configurations.es({\n model\n });\n /**\n * We need published entry to delete it if necessary.\n */\n const [publishedStorageEntry] = await dataLoaders.getPublishedRevisionByEntryId({\n model,\n ids: [entry.id]\n });\n /**\n * We need to delete all existing records of the given entry revision.\n */\n const items = [\n /**\n * Delete records of given entry revision.\n */\n entity.deleteBatch({\n PK: partitionKey,\n SK: createRevisionSortKey(entry)\n })\n ];\n\n const esItems: BatchWriteItem[] = [];\n\n /**\n * If revision we are deleting is the published one as well, we need to delete those records as well.\n */\n if (publishedStorageEntry?.id === entry.id) {\n items.push(\n entity.deleteBatch({\n PK: partitionKey,\n SK: createPublishedSortKey()\n })\n );\n esItems.push(\n entity.deleteBatch({\n PK: partitionKey,\n SK: createPublishedSortKey()\n })\n );\n }\n\n if (latestEntry && latestStorageEntry) {\n /**\n * In the end we need to set the new latest entry.\n */\n items.push(\n entity.putBatch({\n ...latestStorageEntry,\n PK: partitionKey,\n SK: createLatestSortKey(),\n TYPE: createLatestRecordType()\n })\n );\n\n /**\n * Also perform an update on the actual revision. This is needed\n * because of updates on the entry-level meta fields.\n */\n items.push(\n entity.putBatch({\n ...latestStorageEntry,\n PK: createPartitionKey({\n id: latestStorageEntry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createRevisionSortKey(latestStorageEntry),\n TYPE: createRecordType()\n })\n );\n\n const latestTransformer = createTransformer({\n plugins,\n model,\n entry: latestEntry,\n storageEntry: latestStorageEntry\n });\n\n const esLatestData = await latestTransformer.getElasticsearchLatestEntryData();\n esItems.push(\n esEntity.putBatch({\n PK: partitionKey,\n SK: createLatestSortKey(),\n index,\n data: esLatestData\n })\n );\n }\n\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not batch write entry records to DynamoDB table.\",\n ex.code || \"DELETE_REVISION_ERROR\",\n {\n error: ex,\n entry,\n latestEntry,\n latestStorageEntry\n }\n );\n }\n\n if (esItems.length === 0) {\n return;\n }\n\n try {\n await batchWriteAll({\n table: esEntity.table,\n items: esItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message ||\n \"Could not batch write entry records to DynamoDB Elasticsearch table.\",\n ex.code || \"DELETE_REVISION_ERROR\",\n {\n error: ex,\n entry,\n latestEntry,\n latestStorageEntry\n }\n );\n }\n };\n\n const deleteMultipleEntries: CmsEntryStorageOperations[\"deleteMultipleEntries\"] = async (\n initialModel,\n params\n ) => {\n const { entries } = params;\n const model = getStorageOperationsModel(initialModel);\n /**\n * First we need all the revisions of the entries we want to delete.\n */\n const revisions = await dataLoaders.getAllEntryRevisions({\n model,\n ids: entries\n });\n /**\n * Then we need to construct the queries for all the revisions and entries.\n */\n const items: Record<string, WriteRequest>[] = [];\n const esItems: Record<string, WriteRequest>[] = [];\n for (const id of entries) {\n /**\n * Latest item.\n */\n items.push(\n entity.deleteBatch({\n PK: createPartitionKey({\n id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: \"L\"\n })\n );\n esItems.push(\n esEntity.deleteBatch({\n PK: createPartitionKey({\n id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: \"L\"\n })\n );\n /**\n * Published item.\n */\n items.push(\n entity.deleteBatch({\n PK: createPartitionKey({\n id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: \"P\"\n })\n );\n esItems.push(\n esEntity.deleteBatch({\n PK: createPartitionKey({\n id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: \"P\"\n })\n );\n }\n /**\n * Exact revisions of all the entries\n */\n for (const revision of revisions) {\n items.push(\n entity.deleteBatch({\n PK: createPartitionKey({\n id: revision.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createRevisionSortKey({\n version: revision.version\n })\n })\n );\n }\n\n await batchWriteAll({\n table: entity.table,\n items\n });\n await batchWriteAll({\n table: esEntity.table,\n items: esItems\n });\n };\n\n const list: CmsEntryStorageOperations[\"list\"] = async (initialModel, params) => {\n const model = getStorageOperationsModel(initialModel);\n\n const limit = createLimit(params.limit, 50);\n const { index } = configurations.es({\n model\n });\n\n const body = createElasticsearchBody({\n model,\n params: {\n ...params,\n limit,\n after: decodeCursor(params.after)\n },\n plugins\n });\n\n let response: ElasticsearchSearchResponse<CmsIndexEntry>;\n try {\n response = await elasticsearch.search({\n index,\n body\n });\n } catch (error) {\n /**\n * We will silently ignore the `index_not_found_exception` error and return an empty result set.\n * This is because the index might not exist yet, and we don't want to throw an error.\n */\n if (shouldIgnoreEsResponseError(error)) {\n logIgnoredEsResponseError({\n error,\n model,\n indexName: index\n });\n\n return {\n hasMoreItems: false,\n totalCount: 0,\n cursor: null,\n items: []\n };\n }\n\n throw new WebinyError(error.message, error.code || \"ELASTICSEARCH_ERROR\", {\n error,\n index,\n body,\n model\n });\n }\n\n const { hits, total } = response?.body?.hits || {};\n\n const items = extractEntriesFromIndex({\n plugins,\n model,\n entries: hits.map(item => item._source)\n }).map(item => {\n return convertEntryKeysFromStorage({\n model,\n entry: item\n });\n });\n\n const hasMoreItems = items.length > limit;\n if (hasMoreItems) {\n /**\n * Remove the last item from results, we don't want to include it.\n */\n items.pop();\n }\n /**\n * Cursor is the `sort` value of the last item in the array.\n * https://www.elastic.co/guide/en/elasticsearch/reference/current/paginate-search-results.html#search-after\n */\n const cursor = items.length > 0 ? encodeCursor(hits[items.length - 1].sort) || null : null;\n return {\n hasMoreItems,\n totalCount: total.value,\n cursor,\n items\n };\n };\n\n const get: CmsEntryStorageOperations[\"get\"] = async (initialModel, params) => {\n const model = getStorageOperationsModel(initialModel);\n\n const { items } = await list(model, {\n ...params,\n limit: 1\n });\n return items.shift() || null;\n };\n\n const publish: CmsEntryStorageOperations[\"publish\"] = async (initialModel, params) => {\n const { entry: initialEntry, storageEntry: initialStorageEntry } = params;\n const model = getStorageOperationsModel(initialModel);\n\n const transformer = createTransformer({\n plugins,\n model,\n entry: initialEntry,\n storageEntry: initialStorageEntry\n });\n\n const { entry, storageEntry } = transformer.transformEntryKeys();\n\n /**\n * We need currently published entry to check if need to remove it.\n */\n const [publishedStorageEntry] = await dataLoaders.getPublishedRevisionByEntryId({\n model,\n ids: [entry.id]\n });\n\n const revisionKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createRevisionSortKey(entry)\n };\n const latestKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createLatestSortKey()\n };\n const publishedKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createPublishedSortKey()\n };\n\n let latestEsEntry: ElasticsearchDbRecord | null = null;\n try {\n latestEsEntry = await getClean<ElasticsearchDbRecord>({\n entity: esEntity,\n keys: latestKeys\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not read Elasticsearch latest data.\",\n ex.code || \"PUBLISH_LATEST_READ\",\n {\n error: ex,\n latestKeys: latestKeys,\n publishedKeys: publishedKeys\n }\n );\n }\n\n const items = [\n entity.putBatch({\n ...storageEntry,\n ...revisionKeys,\n TYPE: createRecordType()\n })\n ];\n const esItems: BatchWriteItem[] = [];\n\n const { index: esIndex } = configurations.es({\n model\n });\n\n if (publishedStorageEntry && publishedStorageEntry.id !== entry.id) {\n /**\n * If there is a `published` entry already, we need to set it to `unpublished`. We need to\n * execute two updates: update the previously published entry's status and the published entry record.\n * DynamoDB does not support `batchUpdate` - so here we load the previously published\n * entry's data to update its status within a batch operation. If, hopefully,\n * they introduce a true update batch operation, remove this `read` call.\n */\n const [previouslyPublishedEntry] = await dataLoaders.getRevisionById({\n model,\n ids: [publishedStorageEntry.id]\n });\n items.push(\n /**\n * Update currently published entry (unpublish it)\n */\n entity.putBatch({\n ...previouslyPublishedEntry,\n status: CONTENT_ENTRY_STATUS.UNPUBLISHED,\n TYPE: createRecordType(),\n PK: createPartitionKey(publishedStorageEntry),\n SK: createRevisionSortKey(publishedStorageEntry)\n })\n );\n }\n /**\n * Update the helper item in DB with the new published entry\n */\n items.push(\n entity.putBatch({\n ...storageEntry,\n ...publishedKeys,\n TYPE: createPublishedRecordType()\n })\n );\n\n /**\n * We need the latest entry to check if it needs to be updated as well in the Elasticsearch.\n */\n const [latestStorageEntry] = await dataLoaders.getLatestRevisionByEntryId({\n model,\n ids: [entry.id]\n });\n\n if (latestStorageEntry?.id === entry.id) {\n items.push(\n entity.putBatch({\n ...storageEntry,\n ...latestKeys\n })\n );\n }\n\n if (latestEsEntry) {\n const publishingLatestRevision = latestStorageEntry?.id === entry.id;\n\n /**\n * Need to decompress the data from Elasticsearch DynamoDB table.\n *\n * No need to transform it for the storage because it was fetched\n * directly from the Elasticsearch table, where it sits transformed.\n */\n const latestEsEntryDataDecompressed = (await decompress(\n plugins,\n latestEsEntry.data\n )) as CmsIndexEntry;\n\n if (publishingLatestRevision) {\n const updatedMetaFields = pickEntryMetaFields(entry);\n\n const latestTransformer = createTransformer({\n plugins,\n model,\n transformedToIndex: {\n ...latestEsEntryDataDecompressed,\n status: CONTENT_ENTRY_STATUS.PUBLISHED,\n locked: true,\n ...updatedMetaFields\n }\n });\n\n esItems.push(\n esEntity.putBatch({\n index: esIndex,\n PK: createPartitionKey(latestEsEntryDataDecompressed),\n SK: createLatestSortKey(),\n data: await latestTransformer.getElasticsearchLatestEntryData()\n })\n );\n } else {\n const updatedEntryLevelMetaFields = pickEntryMetaFields(\n entry,\n isEntryLevelEntryMetaField\n );\n\n const updatedLatestStorageEntry = {\n ...latestStorageEntry,\n ...latestKeys,\n ...updatedEntryLevelMetaFields\n };\n\n /**\n * First we update the regular DynamoDB table. Two updates are needed:\n * - one for the actual revision record\n * - one for the latest record\n */\n items.push(\n entity.putBatch({\n ...updatedLatestStorageEntry,\n PK: createPartitionKey({\n id: latestStorageEntry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createRevisionSortKey(latestStorageEntry),\n TYPE: createRecordType()\n })\n );\n\n items.push(\n entity.putBatch({\n ...updatedLatestStorageEntry,\n TYPE: createLatestRecordType()\n })\n );\n\n /**\n * Update the Elasticsearch table to propagate changes to the Elasticsearch.\n */\n const latestEsEntry = await getClean<ElasticsearchDbRecord>({\n entity: esEntity,\n keys: latestKeys\n });\n\n if (latestEsEntry) {\n const latestEsEntryDataDecompressed = (await decompress(\n plugins,\n latestEsEntry.data\n )) as CmsIndexEntry;\n\n const updatedLatestEntry = await compress(plugins, {\n ...latestEsEntryDataDecompressed,\n ...updatedEntryLevelMetaFields\n });\n\n esItems.push(\n esEntity.putBatch({\n ...latestKeys,\n index: esIndex,\n data: updatedLatestEntry\n })\n );\n }\n }\n }\n\n /**\n * Update the published revision entry in ES.\n */\n const esPublishedData = await transformer.getElasticsearchPublishedEntryData();\n esItems.push(\n esEntity.putBatch({\n ...publishedKeys,\n index: esIndex,\n data: esPublishedData\n })\n );\n\n /**\n * Finally, execute regular table batch.\n */\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not store publish entry records in DynamoDB table.\",\n ex.code || \"PUBLISH_ERROR\",\n {\n error: ex,\n entry,\n latestStorageEntry,\n publishedStorageEntry\n }\n );\n }\n /**\n * And Elasticsearch table batch.\n */\n try {\n await batchWriteAll({\n table: esEntity.table,\n items: esItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message ||\n \"Could not store publish entry records in DynamoDB Elasticsearch table.\",\n ex.code || \"PUBLISH_ES_ERROR\",\n {\n error: ex,\n entry,\n latestStorageEntry,\n publishedStorageEntry\n }\n );\n }\n return initialStorageEntry;\n };\n\n const unpublish: CmsEntryStorageOperations[\"unpublish\"] = async (initialModel, params) => {\n const { entry: initialEntry, storageEntry: initialStorageEntry } = params;\n const model = getStorageOperationsModel(initialModel);\n\n const transformer = createTransformer({\n plugins,\n model,\n entry: initialEntry,\n storageEntry: initialStorageEntry\n });\n const { entry, storageEntry } = await transformer.transformEntryKeys();\n\n /**\n * We need the latest entry to check if it needs to be updated.\n */\n const [latestStorageEntry] = await dataLoaders.getLatestRevisionByEntryId({\n model,\n ids: [entry.id]\n });\n\n const partitionKey = createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n });\n\n const items = [\n entity.deleteBatch({\n PK: partitionKey,\n SK: createPublishedSortKey()\n }),\n entity.putBatch({\n ...storageEntry,\n PK: partitionKey,\n SK: createRevisionSortKey(entry),\n TYPE: createRecordType()\n })\n ];\n\n const esItems: BatchWriteItem[] = [\n esEntity.deleteBatch({\n PK: partitionKey,\n SK: createPublishedSortKey()\n })\n ];\n /**\n * If we are unpublishing the latest revision, let's also update the latest revision entry's status in both DynamoDB tables.\n */\n if (latestStorageEntry?.id === entry.id) {\n const { index } = configurations.es({\n model\n });\n\n items.push(\n entity.putBatch({\n ...storageEntry,\n PK: partitionKey,\n SK: createLatestSortKey(),\n TYPE: createLatestRecordType()\n })\n );\n\n const esLatestData = await transformer.getElasticsearchLatestEntryData();\n esItems.push(\n esEntity.putBatch({\n PK: partitionKey,\n SK: createLatestSortKey(),\n index,\n data: esLatestData\n })\n );\n }\n\n /**\n * Finally, execute regular table batch.\n */\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not store unpublished entry records in DynamoDB table.\",\n ex.code || \"UNPUBLISH_ERROR\",\n {\n entry,\n storageEntry\n }\n );\n }\n /**\n * And Elasticsearch table batch.\n */\n try {\n await batchWriteAll({\n table: esEntity.table,\n items: esItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message ||\n \"Could not store unpublished entry records in DynamoDB Elasticsearch table.\",\n ex.code || \"UNPUBLISH_ERROR\",\n {\n entry,\n storageEntry\n }\n );\n }\n return initialStorageEntry;\n };\n\n const getLatestRevisionByEntryId: CmsEntryStorageOperations[\"getLatestRevisionByEntryId\"] =\n async (initialModel, params) => {\n const model = getStorageOperationsModel(initialModel);\n\n const [entry] = await dataLoaders.getLatestRevisionByEntryId({\n model,\n ids: [params.id]\n });\n if (!entry) {\n return null;\n }\n return convertEntryKeysFromStorage({\n model,\n entry\n });\n };\n\n const getPublishedRevisionByEntryId: CmsEntryStorageOperations[\"getPublishedRevisionByEntryId\"] =\n async (initialModel, params) => {\n const model = getStorageOperationsModel(initialModel);\n\n const [entry] = await dataLoaders.getPublishedRevisionByEntryId({\n model,\n ids: [params.id]\n });\n if (!entry) {\n return null;\n }\n return convertEntryKeysFromStorage({\n model,\n entry\n });\n };\n\n const getRevisionById: CmsEntryStorageOperations[\"getRevisionById\"] = async (\n initialModel,\n params\n ) => {\n const model = getStorageOperationsModel(initialModel);\n\n const [entry] = await dataLoaders.getRevisionById({\n model,\n ids: [params.id]\n });\n if (!entry) {\n return null;\n }\n return convertEntryKeysFromStorage({\n model,\n entry\n });\n };\n\n const getRevisions: CmsEntryStorageOperations[\"getRevisions\"] = async (\n initialModel,\n params\n ) => {\n const model = getStorageOperationsModel(initialModel);\n\n const entries = await dataLoaders.getAllEntryRevisions({\n model,\n ids: [params.id]\n });\n\n return entries.map(entry => {\n return convertEntryKeysFromStorage({\n model,\n entry\n });\n });\n };\n\n const getByIds: CmsEntryStorageOperations[\"getByIds\"] = async (initialModel, params) => {\n const model = getStorageOperationsModel(initialModel);\n\n const entries = await dataLoaders.getRevisionById({\n model,\n ids: params.ids\n });\n\n return entries.map(entry => {\n return convertEntryKeysFromStorage({\n model,\n entry\n });\n });\n };\n\n const getLatestByIds: CmsEntryStorageOperations[\"getLatestByIds\"] = async (\n initialModel,\n params\n ) => {\n const model = getStorageOperationsModel(initialModel);\n\n const entries = await dataLoaders.getLatestRevisionByEntryId({\n model,\n ids: params.ids\n });\n return entries.map(entry => {\n return convertEntryKeysFromStorage({\n model,\n entry\n });\n });\n };\n\n const getPublishedByIds: CmsEntryStorageOperations[\"getPublishedByIds\"] = async (\n initialModel,\n params\n ) => {\n const model = getStorageOperationsModel(initialModel);\n\n const entries = await dataLoaders.getPublishedRevisionByEntryId({\n model,\n ids: params.ids\n });\n\n return entries.map(entry => {\n return convertEntryKeysFromStorage({\n model,\n entry\n });\n });\n };\n\n const getPreviousRevision: CmsEntryStorageOperations[\"getPreviousRevision\"] = async (\n initialModel,\n params\n ) => {\n const model = getStorageOperationsModel(initialModel);\n\n const { tenant, locale } = model;\n const { entryId, version } = params;\n const queryParams: QueryOneParams = {\n entity,\n partitionKey: createPartitionKey({\n tenant,\n locale,\n id: entryId\n }),\n options: {\n lt: `REV#${zeroPad(version)}`,\n /**\n * We need to have extra checks because DynamoDB will return published or latest record if there is no REV# record.\n */\n filters: [\n {\n attr: \"TYPE\",\n eq: createRecordType()\n },\n {\n attr: \"version\",\n lt: version\n }\n ],\n reverse: true\n }\n };\n\n try {\n const result = await queryOne<CmsEntry>(queryParams);\n\n const entry = cleanupItem(entity, result);\n\n if (!entry) {\n return null;\n }\n return convertEntryKeysFromStorage({\n entry,\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get previous version of given entry.\",\n ex.code || \"GET_PREVIOUS_VERSION_ERROR\",\n {\n ...params,\n error: ex,\n partitionKey: queryParams.partitionKey,\n options: queryParams.options,\n model\n }\n );\n }\n };\n\n const getUniqueFieldValues: CmsEntryStorageOperations[\"getUniqueFieldValues\"] = async (\n model,\n params\n ) => {\n const { where, fieldId } = params;\n\n const { index } = configurations.es({\n model\n });\n\n const initialBody = createElasticsearchBody({\n model,\n params: {\n limit: 1,\n where\n },\n plugins\n });\n\n const field = model.fields.find(f => f.fieldId === fieldId);\n if (!field) {\n throw new WebinyError(\n `Could not find field with given \"fieldId\" value.`,\n \"FIELD_NOT_FOUND\",\n {\n fieldId\n }\n );\n }\n\n const body: ElasticsearchSearchBody = {\n ...initialBody,\n /**\n * We do not need any hits returned, we only need the aggregations.\n */\n size: 0,\n aggregations: {\n getUniqueFieldValues: {\n terms: {\n field: `values.${field.storageId}.keyword`,\n size: 1000000\n }\n }\n }\n };\n\n let response: ElasticsearchSearchResponse<string> | undefined = undefined;\n\n try {\n response = await elasticsearch.search({\n index,\n body\n });\n } catch (error) {\n if (shouldIgnoreEsResponseError(error)) {\n logIgnoredEsResponseError({\n error,\n model,\n indexName: index\n });\n return [];\n }\n\n throw new WebinyError(\n error.message || \"Error in the Elasticsearch query.\",\n error.code || \"ELASTICSEARCH_ERROR\",\n {\n error,\n index,\n model,\n body\n }\n );\n }\n\n const buckets = response.body.aggregations[\"getUniqueFieldValues\"]?.buckets || [];\n return buckets.map(file => {\n return {\n value: file.key,\n count: file.doc_count\n };\n });\n };\n\n return {\n create,\n createRevisionFrom,\n update,\n move,\n delete: deleteEntry,\n moveToBin,\n restoreFromBin,\n deleteRevision,\n deleteMultipleEntries,\n get,\n publish,\n unpublish,\n list,\n getLatestRevisionByEntryId,\n getPublishedRevisionByEntryId,\n getRevisionById,\n getRevisions,\n getByIds,\n getLatestByIds,\n getPublishedByIds,\n getPreviousRevision,\n getUniqueFieldValues,\n dataLoaders\n };\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAMA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AAIA,IAAAI,WAAA,GAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AAMA,IAAAO,MAAA,GAAAP,OAAA;AAMA,IAAAQ,iBAAA,GAAAR,OAAA;AAOA,IAAAS,IAAA,GAAAT,OAAA;AACA,IAAA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IACPS,SAAS;IACTnC,IAAI;IACJlE,0BAA0B;IAC1BG,6BAA6B;IAC7B2F,eAAe;IACfQ,YAAY;IACZC,QAAQ;IACRC,cAAc;IACdC,iBAAiB;IACjBC,mBAAmB;IACnBW,oBAAoB;IACpB7K;EACJ,CAAC;AACL,CAAC;AAAC+L,OAAA,CAAA9M,8BAAA,GAAAA,8BAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_types","_helpers","_configurations","_batchWrite","_dataLoaders","_keys","_query","_apiElasticsearch","_get","_utils","_cleanup","_body","_logIgnoredEsResponseError","_shouldIgnoreEsResponseError","_recordType","_apiHeadlessCms","_dbDynamodb","_transformations","_convertEntryKeys","_constants","convertToStorageEntry","params","model","storageEntry","values","convertValueKeyToStorage","fields","createEntriesStorageOperations","entity","esEntity","elasticsearch","plugins","storageOperationsCmsModelPlugin","getStorageOperationsCmsModelPlugin","oneByType","StorageOperationsCmsModelPlugin","type","getStorageOperationsModel","plugin","getModel","dataLoaders","DataLoadersHandler","create","initialModel","entry","initialEntry","initialStorageEntry","isPublished","status","locked","transformer","createTransformer","transformEntryKeys","esEntry","transformToIndex","index","esIndex","configurations","es","revisionKeys","PK","createPartitionKey","id","locale","tenant","SK","createRevisionSortKey","latestKeys","createLatestSortKey","publishedKeys","createPublishedSortKey","items","putBatch","TYPE","createRecordType","createLatestRecordType","push","createPublishedRecordType","batchWriteAll","table","clearAll","ex","WebinyError","message","code","error","esLatestData","getElasticsearchLatestEntryData","esItems","data","esPublishedData","getElasticsearchPublishedEntryData","createRevisionFrom","publishedRevisionStorageEntry","getPublishedRevisionByEntryId","ids","CONTENT_ENTRY_STATUS","UNPUBLISHED","update","latestStorageEntry","getLatestRevisionByEntryId","publishedStorageEntry","updatingLatestRevision","elasticsearchLatestData","updatedEntryLevelMetaFields","pickEntryMetaFields","isEntryLevelEntryMetaField","updatedLatestStorageEntry","latestEsEntry","getClean","keys","latestEsEntryDataDecompressed","decompress","updatedLatestEntry","compress","elasticsearchPublishedData","length","move","folderId","partitionKey","queryAllParams","options","gte","latestSortKey","publishedSortKey","records","queryAll","latestRecord","undefined","publishedRecord","record","location","esGetItems","getBatch","esRecords","batchReadAll","Promise","all","map","filter","Boolean","esUpdateItems","item","moveToBin","updatedEntryMetaFields","isDeletedEntryMetaField","wbyDeleted","binOriginalFolderId","restoreFromBin","isRestoredEntryMetaField","deleteEntry","entryId","deleteItems","deleteBatch","deleteEsItems","deleteRevision","latestEntry","initialLatestStorageEntry","latestTransformer","deleteMultipleEntries","entries","revisions","getAllEntryRevisions","revision","version","list","limit","createLimit","body","createElasticsearchBody","after","decodeCursor","response","search","shouldIgnoreEsResponseError","logIgnoredEsResponseError","indexName","hasMoreItems","totalCount","cursor","hits","total","extractEntriesFromIndex","_source","convertEntryKeysFromStorage","pop","encodeCursor","sort","value","get","shift","publish","publishedRevisionId","publishingLatestRevision","isRepublishing","latestRevisionStatus","PUBLISHED","latestStorageEntryFields","publishedRevisionDifferentFromLatest","updatedMetaFields","transformedToIndex","unpublish","getRevisionById","getRevisions","getByIds","getLatestByIds","getPublishedByIds","getPreviousRevision","queryParams","lt","zeroPad","filters","attr","eq","reverse","result","queryOne","cleanupItem","getUniqueFieldValues","where","fieldId","initialBody","field","find","f","size","aggregations","terms","storageId","buckets","file","key","count","doc_count","delete","exports"],"sources":["index.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport {\n CmsEntry,\n CmsModel,\n CmsStorageEntry,\n CONTENT_ENTRY_STATUS,\n StorageOperationsCmsModel\n} from \"@webiny/api-headless-cms/types\";\nimport { extractEntriesFromIndex } from \"~/helpers\";\nimport { configurations } from \"~/configurations\";\nimport { Entity } from \"@webiny/db-dynamodb/toolbox\";\nimport { Client } from \"@elastic/elasticsearch\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { batchWriteAll, BatchWriteItem } from \"@webiny/db-dynamodb/utils/batchWrite\";\nimport { DataLoadersHandler } from \"./dataLoaders\";\nimport {\n createLatestSortKey,\n createPartitionKey,\n createPublishedSortKey,\n createRevisionSortKey\n} from \"./keys\";\nimport {\n queryAll,\n QueryAllParams,\n queryOne,\n QueryOneParams\n} from \"@webiny/db-dynamodb/utils/query\";\nimport {\n compress,\n createLimit,\n decodeCursor,\n decompress,\n encodeCursor\n} from \"@webiny/api-elasticsearch\";\nimport { getClean } from \"@webiny/db-dynamodb/utils/get\";\nimport { zeroPad } from \"@webiny/utils\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport {\n ElasticsearchSearchResponse,\n SearchBody as ElasticsearchSearchBody\n} from \"@webiny/api-elasticsearch/types\";\nimport { CmsEntryStorageOperations, CmsIndexEntry } from \"~/types\";\nimport { createElasticsearchBody } from \"./elasticsearch/body\";\nimport { logIgnoredEsResponseError } from \"./elasticsearch/logIgnoredEsResponseError\";\nimport { shouldIgnoreEsResponseError } from \"./elasticsearch/shouldIgnoreEsResponseError\";\nimport { createLatestRecordType, createPublishedRecordType, createRecordType } from \"./recordType\";\nimport { StorageOperationsCmsModelPlugin } from \"@webiny/api-headless-cms\";\nimport { WriteRequest } from \"@webiny/aws-sdk/client-dynamodb\";\nimport { batchReadAll, BatchReadItem } from \"@webiny/db-dynamodb\";\nimport { createTransformer } from \"./transformations\";\nimport { convertEntryKeysFromStorage } from \"./transformations/convertEntryKeys\";\nimport {\n isDeletedEntryMetaField,\n isEntryLevelEntryMetaField,\n isRestoredEntryMetaField,\n pickEntryMetaFields\n} from \"@webiny/api-headless-cms/constants\";\n\ninterface ElasticsearchDbRecord {\n index: string;\n data: Record<string, any>;\n}\n\nexport interface CreateEntriesStorageOperationsParams {\n entity: Entity<any>;\n esEntity: Entity<any>;\n elasticsearch: Client;\n plugins: PluginsContainer;\n}\n\ninterface ConvertStorageEntryParams {\n storageEntry: CmsStorageEntry;\n model: StorageOperationsCmsModel;\n}\n\nconst convertToStorageEntry = (params: ConvertStorageEntryParams): CmsStorageEntry => {\n const { model, storageEntry } = params;\n\n const values = model.convertValueKeyToStorage({\n fields: model.fields,\n values: storageEntry.values\n });\n return {\n ...storageEntry,\n values\n };\n};\n\nexport const createEntriesStorageOperations = (\n params: CreateEntriesStorageOperationsParams\n): CmsEntryStorageOperations => {\n const { entity, esEntity, elasticsearch, plugins } = params;\n\n let storageOperationsCmsModelPlugin: StorageOperationsCmsModelPlugin | undefined;\n const getStorageOperationsCmsModelPlugin = () => {\n if (storageOperationsCmsModelPlugin) {\n return storageOperationsCmsModelPlugin;\n }\n storageOperationsCmsModelPlugin = plugins.oneByType<StorageOperationsCmsModelPlugin>(\n StorageOperationsCmsModelPlugin.type\n );\n return storageOperationsCmsModelPlugin;\n };\n\n const getStorageOperationsModel = (model: CmsModel): StorageOperationsCmsModel => {\n const plugin = getStorageOperationsCmsModelPlugin();\n return plugin.getModel(model);\n };\n\n const dataLoaders = new DataLoadersHandler({\n entity\n });\n\n const create: CmsEntryStorageOperations[\"create\"] = async (initialModel, params) => {\n const { entry: initialEntry, storageEntry: initialStorageEntry } = params;\n\n const model = getStorageOperationsModel(initialModel);\n\n const isPublished = initialEntry.status === \"published\";\n const locked = isPublished ? true : initialEntry.locked;\n\n initialEntry.locked = locked;\n initialStorageEntry.locked = locked;\n\n const transformer = createTransformer({\n plugins,\n model,\n entry: initialEntry,\n storageEntry: initialStorageEntry\n });\n\n const { entry, storageEntry } = transformer.transformEntryKeys();\n\n const esEntry = transformer.transformToIndex();\n\n const { index: esIndex } = configurations.es({\n model\n });\n\n const revisionKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createRevisionSortKey(entry)\n };\n\n const latestKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createLatestSortKey()\n };\n\n const publishedKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createPublishedSortKey()\n };\n\n const items = [\n entity.putBatch({\n ...storageEntry,\n locked,\n ...revisionKeys,\n TYPE: createRecordType()\n }),\n entity.putBatch({\n ...storageEntry,\n locked,\n ...latestKeys,\n TYPE: createLatestRecordType()\n })\n ];\n\n if (isPublished) {\n items.push(\n entity.putBatch({\n ...storageEntry,\n locked,\n ...publishedKeys,\n TYPE: createPublishedRecordType()\n })\n );\n }\n\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not insert entry data into the DynamoDB table.\",\n ex.code || \"CREATE_ENTRY_ERROR\",\n {\n error: ex,\n entry,\n storageEntry\n }\n );\n }\n\n const esLatestData = await transformer.getElasticsearchLatestEntryData();\n const esItems: BatchWriteItem[] = [\n esEntity.putBatch({\n ...latestKeys,\n index: esIndex,\n data: esLatestData\n })\n ];\n if (isPublished) {\n const esPublishedData = await transformer.getElasticsearchPublishedEntryData();\n esItems.push(\n esEntity.putBatch({\n ...publishedKeys,\n index: esIndex,\n data: esPublishedData\n })\n );\n }\n\n try {\n await batchWriteAll({\n table: esEntity.table,\n items: esItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not insert entry data into the Elasticsearch DynamoDB table.\",\n ex.code || \"CREATE_ES_ENTRY_ERROR\",\n {\n error: ex,\n entry,\n esEntry\n }\n );\n }\n\n return initialStorageEntry;\n };\n\n const createRevisionFrom: CmsEntryStorageOperations[\"createRevisionFrom\"] = async (\n initialModel,\n params\n ) => {\n const { entry: initialEntry, storageEntry: initialStorageEntry } = params;\n const model = getStorageOperationsModel(initialModel);\n\n const transformer = createTransformer({\n plugins,\n model,\n entry: initialEntry,\n storageEntry: initialStorageEntry\n });\n const { entry, storageEntry } = transformer.transformEntryKeys();\n\n const revisionKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createRevisionSortKey(entry)\n };\n const latestKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createLatestSortKey()\n };\n\n const publishedKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createPublishedSortKey()\n };\n\n // We'll need this flag below.\n const isPublished = entry.status === \"published\";\n\n const esLatestData = await transformer.getElasticsearchLatestEntryData();\n\n const items = [\n entity.putBatch({\n ...storageEntry,\n TYPE: createRecordType(),\n ...revisionKeys\n }),\n entity.putBatch({\n ...storageEntry,\n TYPE: createLatestRecordType(),\n ...latestKeys\n })\n ];\n\n if (isPublished) {\n items.push(\n entity.putBatch({\n ...storageEntry,\n TYPE: createPublishedRecordType(),\n ...publishedKeys\n })\n );\n\n // Unpublish previously published revision (if any).\n const [publishedRevisionStorageEntry] = await dataLoaders.getPublishedRevisionByEntryId(\n {\n model,\n ids: [entry.id]\n }\n );\n\n if (publishedRevisionStorageEntry) {\n items.push(\n entity.putBatch({\n ...publishedRevisionStorageEntry,\n PK: createPartitionKey({\n id: publishedRevisionStorageEntry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createRevisionSortKey(publishedRevisionStorageEntry),\n TYPE: createRecordType(),\n status: CONTENT_ENTRY_STATUS.UNPUBLISHED\n })\n );\n }\n }\n\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create revision from given entry in the DynamoDB table.\",\n ex.code || \"CREATE_REVISION_ERROR\",\n {\n error: ex,\n entry,\n storageEntry\n }\n );\n }\n\n const { index: esIndex } = configurations.es({\n model\n });\n\n const esItems: BatchWriteItem[] = [\n esEntity.putBatch({\n ...latestKeys,\n index: esIndex,\n data: esLatestData\n })\n ];\n\n if (isPublished) {\n const esPublishedData = await transformer.getElasticsearchPublishedEntryData();\n esItems.push(\n esEntity.putBatch({\n ...publishedKeys,\n index: esIndex,\n data: esPublishedData\n })\n );\n }\n\n try {\n await batchWriteAll({\n table: esEntity.table,\n items: esItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update latest entry in the DynamoDB Elasticsearch table.\",\n ex.code || \"CREATE_REVISION_ERROR\",\n {\n error: ex,\n entry\n }\n );\n }\n /**\n * There are no modifications on the entry created so just return the data.\n */\n return initialStorageEntry;\n };\n\n const update: CmsEntryStorageOperations[\"update\"] = async (initialModel, params) => {\n const { entry: initialEntry, storageEntry: initialStorageEntry } = params;\n const model = getStorageOperationsModel(initialModel);\n\n const transformer = createTransformer({\n plugins,\n model,\n entry: initialEntry,\n storageEntry: initialStorageEntry\n });\n\n const { entry, storageEntry } = transformer.transformEntryKeys();\n\n const isPublished = entry.status === \"published\";\n const locked = isPublished ? true : entry.locked;\n\n const revisionKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createRevisionSortKey(entry)\n };\n const latestKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createLatestSortKey()\n };\n\n const publishedKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createPublishedSortKey()\n };\n\n /**\n * We need the latest entry to check if it needs to be updated.\n */\n const [latestStorageEntry] = await dataLoaders.getLatestRevisionByEntryId({\n model,\n ids: [entry.id]\n });\n\n const [publishedStorageEntry] = await dataLoaders.getPublishedRevisionByEntryId({\n model,\n ids: [entry.id]\n });\n\n const items = [\n entity.putBatch({\n ...storageEntry,\n locked,\n ...revisionKeys,\n TYPE: createRecordType()\n })\n ];\n if (isPublished) {\n items.push(\n entity.putBatch({\n ...storageEntry,\n locked,\n ...publishedKeys,\n TYPE: createPublishedRecordType()\n })\n );\n }\n\n const esItems: BatchWriteItem[] = [];\n\n const { index: esIndex } = configurations.es({\n model\n });\n\n /**\n * If the latest entry is the one being updated, we need to create a new latest entry records.\n */\n if (latestStorageEntry) {\n const updatingLatestRevision = latestStorageEntry.id === entry.id;\n if (updatingLatestRevision) {\n /**\n * First we update the regular DynamoDB table.\n */\n items.push(\n entity.putBatch({\n ...storageEntry,\n ...latestKeys,\n TYPE: createLatestRecordType()\n })\n );\n\n /**\n * And then update the Elasticsearch table to propagate changes to the Elasticsearch\n */\n const elasticsearchLatestData = await transformer.getElasticsearchLatestEntryData();\n\n esItems.push(\n esEntity.putBatch({\n ...latestKeys,\n index: esIndex,\n data: elasticsearchLatestData\n })\n );\n } else {\n /**\n * If not updating latest revision, we still want to update the latest revision's\n * entry-level meta fields to match the current revision's entry-level meta fields.\n */\n const updatedEntryLevelMetaFields = pickEntryMetaFields(\n entry,\n isEntryLevelEntryMetaField\n );\n\n const updatedLatestStorageEntry = {\n ...latestStorageEntry,\n ...latestKeys,\n ...updatedEntryLevelMetaFields\n };\n\n /**\n * First we update the regular DynamoDB table. Two updates are needed:\n * - one for the actual revision record\n * - one for the latest record\n */\n items.push(\n entity.putBatch({\n ...updatedLatestStorageEntry,\n PK: createPartitionKey({\n id: latestStorageEntry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createRevisionSortKey(latestStorageEntry),\n TYPE: createRecordType()\n })\n );\n\n items.push(\n entity.putBatch({\n ...updatedLatestStorageEntry,\n TYPE: createLatestRecordType()\n })\n );\n\n /**\n * Update the Elasticsearch table to propagate changes to the Elasticsearch.\n */\n const latestEsEntry = await getClean<ElasticsearchDbRecord>({\n entity: esEntity,\n keys: latestKeys\n });\n\n if (latestEsEntry) {\n const latestEsEntryDataDecompressed = (await decompress(\n plugins,\n latestEsEntry.data\n )) as CmsIndexEntry;\n\n const updatedLatestEntry = await compress(plugins, {\n ...latestEsEntryDataDecompressed,\n ...updatedEntryLevelMetaFields\n });\n\n esItems.push(\n esEntity.putBatch({\n ...latestKeys,\n index: esIndex,\n data: updatedLatestEntry\n })\n );\n }\n }\n }\n\n if (isPublished && publishedStorageEntry?.id === entry.id) {\n const elasticsearchPublishedData =\n await transformer.getElasticsearchPublishedEntryData();\n esItems.push(\n esEntity.putBatch({\n ...publishedKeys,\n index: esIndex,\n data: elasticsearchPublishedData\n })\n );\n }\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update entry DynamoDB records.\",\n ex.code || \"UPDATE_ENTRY_ERROR\",\n {\n error: ex,\n entry,\n storageEntry\n }\n );\n }\n if (esItems.length === 0) {\n return initialStorageEntry;\n }\n\n try {\n await batchWriteAll({\n table: esEntity.table,\n items: esItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update entry DynamoDB Elasticsearch records.\",\n ex.code || \"UPDATE_ES_ENTRY_ERROR\",\n {\n error: ex,\n entry\n }\n );\n }\n return initialStorageEntry;\n };\n\n const move: CmsEntryStorageOperations[\"move\"] = async (initialModel, id, folderId) => {\n const model = getStorageOperationsModel(initialModel);\n\n const partitionKey = createPartitionKey({\n id,\n locale: model.locale,\n tenant: model.tenant\n });\n /**\n * First we need to fetch all the records in the regular DynamoDB table.\n */\n const queryAllParams: QueryAllParams = {\n entity,\n partitionKey,\n options: {\n gte: \" \"\n }\n };\n const latestSortKey = createLatestSortKey();\n const publishedSortKey = createPublishedSortKey();\n const records = await queryAll<CmsEntry>(queryAllParams);\n /**\n * Then update the folderId in each record and prepare it to be stored.\n */\n let latestRecord: CmsEntry | undefined = undefined;\n let publishedRecord: CmsEntry | undefined = undefined;\n const items: BatchWriteItem[] = [];\n for (const record of records) {\n items.push(\n entity.putBatch({\n ...record,\n location: {\n ...record?.location,\n folderId\n }\n })\n );\n /**\n * We need to get the published and latest records, so we can update the Elasticsearch.\n */\n if (record.SK === publishedSortKey) {\n publishedRecord = record;\n } else if (record.SK === latestSortKey) {\n latestRecord = record;\n }\n }\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not move all entry records from in the DynamoDB table.\",\n ex.code || \"MOVE_ENTRY_ERROR\",\n {\n error: ex,\n id\n }\n );\n }\n const esGetItems: BatchReadItem[] = [];\n if (publishedRecord) {\n esGetItems.push(\n esEntity.getBatch({\n PK: partitionKey,\n SK: publishedSortKey\n })\n );\n }\n if (latestRecord) {\n esGetItems.push(\n esEntity.getBatch({\n PK: partitionKey,\n SK: latestSortKey\n })\n );\n }\n if (esGetItems.length === 0) {\n return;\n }\n const esRecords = await batchReadAll<ElasticsearchDbRecord>({\n table: esEntity.table,\n items: esGetItems\n });\n const esItems = (\n await Promise.all(\n esRecords.map(async record => {\n if (!record) {\n return null;\n }\n return {\n ...record,\n data: await decompress(plugins, record.data)\n };\n })\n )\n ).filter(Boolean) as ElasticsearchDbRecord[];\n\n if (esItems.length === 0) {\n return;\n }\n const esUpdateItems: BatchWriteItem[] = [];\n for (const item of esItems) {\n esUpdateItems.push(\n esEntity.putBatch({\n ...item,\n data: await compress(plugins, {\n ...item.data,\n location: {\n ...item.data?.location,\n folderId\n }\n })\n })\n );\n }\n\n try {\n await batchWriteAll({\n table: esEntity.table,\n items: esUpdateItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not move entry DynamoDB Elasticsearch records.\",\n ex.code || \"MOVE_ES_ENTRY_ERROR\",\n {\n error: ex,\n partitionKey\n }\n );\n }\n };\n\n const moveToBin: CmsEntryStorageOperations[\"moveToBin\"] = async (initialModel, params) => {\n const { entry: initialEntry, storageEntry: initialStorageEntry } = params;\n const model = getStorageOperationsModel(initialModel);\n\n const transformer = createTransformer({\n plugins,\n model,\n entry: initialEntry,\n storageEntry: initialStorageEntry\n });\n\n const { entry, storageEntry } = transformer.transformEntryKeys();\n\n const partitionKey = createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n });\n\n /**\n * First we need to fetch all the records in the regular DynamoDB table.\n */\n const queryAllParams: QueryAllParams = {\n entity,\n partitionKey,\n options: {\n gte: \" \"\n }\n };\n\n const latestSortKey = createLatestSortKey();\n const publishedSortKey = createPublishedSortKey();\n const records = await queryAll<CmsEntry>(queryAllParams);\n\n /**\n * Let's pick the `deleted` meta fields from the entry.\n */\n const updatedEntryMetaFields = pickEntryMetaFields(entry, isDeletedEntryMetaField);\n\n /**\n * Then update all the records with data received.\n */\n let latestRecord: CmsEntry | undefined = undefined;\n let publishedRecord: CmsEntry | undefined = undefined;\n const items: BatchWriteItem[] = [];\n\n for (const record of records) {\n items.push(\n entity.putBatch({\n ...record,\n ...updatedEntryMetaFields,\n wbyDeleted: storageEntry.wbyDeleted,\n location: storageEntry.location,\n binOriginalFolderId: storageEntry.binOriginalFolderId\n })\n );\n /**\n * We need to get the published and latest records, so we can update the Elasticsearch.\n */\n if (record.SK === publishedSortKey) {\n publishedRecord = record;\n } else if (record.SK === latestSortKey) {\n latestRecord = record;\n }\n }\n\n /**\n * We write the records back to the primary DynamoDB table.\n */\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could mark as deleted all entry records from in the DynamoDB table.\",\n ex.code || \"MOVE_ENTRY_TO_BIN_ERROR\",\n {\n error: ex,\n entry,\n storageEntry\n }\n );\n }\n\n /**\n * We need to get the published and latest records from Elasticsearch.\n */\n const esGetItems: BatchReadItem[] = [];\n if (publishedRecord) {\n esGetItems.push(\n esEntity.getBatch({\n PK: partitionKey,\n SK: publishedSortKey\n })\n );\n }\n if (latestRecord) {\n esGetItems.push(\n esEntity.getBatch({\n PK: partitionKey,\n SK: latestSortKey\n })\n );\n }\n if (esGetItems.length === 0) {\n return;\n }\n\n const esRecords = await batchReadAll<ElasticsearchDbRecord>({\n table: esEntity.table,\n items: esGetItems\n });\n\n const esItems = (\n await Promise.all(\n esRecords.map(async record => {\n if (!record) {\n return null;\n }\n return {\n ...record,\n data: await decompress(plugins, record.data)\n };\n })\n )\n ).filter(Boolean) as ElasticsearchDbRecord[];\n\n if (esItems.length === 0) {\n return;\n }\n\n /**\n * We update all ES records with data received.\n */\n const esUpdateItems: BatchWriteItem[] = [];\n for (const item of esItems) {\n esUpdateItems.push(\n esEntity.putBatch({\n ...item,\n data: await compress(plugins, {\n ...item.data,\n ...updatedEntryMetaFields,\n wbyDeleted: entry.wbyDeleted,\n location: entry.location,\n binOriginalFolderId: entry.binOriginalFolderId\n })\n })\n );\n }\n\n /**\n * We write the records back to the primary DynamoDB Elasticsearch table.\n */\n try {\n await batchWriteAll({\n table: esEntity.table,\n items: esUpdateItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message ||\n \"Could not mark as deleted entry records from DynamoDB Elasticsearch table.\",\n ex.code || \"MOVE_ENTRY_TO_BIN_ERROR\",\n {\n error: ex,\n entry,\n storageEntry\n }\n );\n }\n };\n\n const restoreFromBin: CmsEntryStorageOperations[\"restoreFromBin\"] = async (\n initialModel,\n params\n ) => {\n const { entry: initialEntry, storageEntry: initialStorageEntry } = params;\n const model = getStorageOperationsModel(initialModel);\n\n const transformer = createTransformer({\n plugins,\n model,\n entry: initialEntry,\n storageEntry: initialStorageEntry\n });\n\n const { entry, storageEntry } = transformer.transformEntryKeys();\n\n /**\n * Let's pick the `restored` meta fields from the storage entry.\n */\n const updatedEntryMetaFields = pickEntryMetaFields(entry, isRestoredEntryMetaField);\n\n const partitionKey = createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n });\n\n /**\n * First we need to fetch all the records in the regular DynamoDB table.\n */\n const queryAllParams: QueryAllParams = {\n entity,\n partitionKey,\n options: {\n gte: \" \"\n }\n };\n\n const latestSortKey = createLatestSortKey();\n const publishedSortKey = createPublishedSortKey();\n const records = await queryAll<CmsEntry>(queryAllParams);\n\n /**\n * Then update all the records with data received.\n */\n let latestRecord: CmsEntry | undefined = undefined;\n let publishedRecord: CmsEntry | undefined = undefined;\n const items: BatchWriteItem[] = [];\n\n for (const record of records) {\n items.push(\n entity.putBatch({\n ...record,\n ...updatedEntryMetaFields,\n wbyDeleted: storageEntry.wbyDeleted,\n location: storageEntry.location,\n binOriginalFolderId: storageEntry.binOriginalFolderId\n })\n );\n /**\n * We need to get the published and latest records, so we can update the Elasticsearch.\n */\n if (record.SK === publishedSortKey) {\n publishedRecord = record;\n } else if (record.SK === latestSortKey) {\n latestRecord = record;\n }\n }\n\n /**\n * We write the records back to the primary DynamoDB table.\n */\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not restore all entry records from in the DynamoDB table.\",\n ex.code || \"RESTORE_ENTRY_ERROR\",\n {\n error: ex,\n entry,\n storageEntry\n }\n );\n }\n\n /**\n * We need to get the published and latest records from Elasticsearch.\n */\n const esGetItems: BatchReadItem[] = [];\n if (publishedRecord) {\n esGetItems.push(\n esEntity.getBatch({\n PK: partitionKey,\n SK: publishedSortKey\n })\n );\n }\n if (latestRecord) {\n esGetItems.push(\n esEntity.getBatch({\n PK: partitionKey,\n SK: latestSortKey\n })\n );\n }\n\n const esRecords = await batchReadAll<ElasticsearchDbRecord>({\n table: esEntity.table,\n items: esGetItems\n });\n\n const esItems = (\n await Promise.all(\n esRecords.map(async record => {\n if (!record) {\n return null;\n }\n return {\n ...record,\n data: await decompress(plugins, record.data)\n };\n })\n )\n ).filter(Boolean) as ElasticsearchDbRecord[];\n\n if (esItems.length === 0) {\n return initialStorageEntry;\n }\n\n /**\n * We update all ES records with data received.\n */\n const esUpdateItems: BatchWriteItem[] = [];\n for (const item of esItems) {\n esUpdateItems.push(\n esEntity.putBatch({\n ...item,\n data: await compress(plugins, {\n ...item.data,\n ...updatedEntryMetaFields,\n wbyDeleted: entry.wbyDeleted,\n location: entry.location,\n binOriginalFolderId: entry.binOriginalFolderId\n })\n })\n );\n }\n\n /**\n * We write the records back to the primary DynamoDB Elasticsearch table.\n */\n try {\n await batchWriteAll({\n table: esEntity.table,\n items: esUpdateItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not restore entry records from DynamoDB Elasticsearch table.\",\n ex.code || \"RESTORE_ENTRY_ERROR\",\n {\n error: ex,\n entry,\n storageEntry\n }\n );\n }\n\n return initialStorageEntry;\n };\n\n const deleteEntry: CmsEntryStorageOperations[\"delete\"] = async (initialModel, params) => {\n const { entry } = params;\n const id = entry.id || entry.entryId;\n const model = getStorageOperationsModel(initialModel);\n\n const partitionKey = createPartitionKey({\n id,\n locale: model.locale,\n tenant: model.tenant\n });\n\n const items = await queryAll<CmsEntry>({\n entity,\n partitionKey,\n options: {\n gte: \" \"\n }\n });\n\n const esItems = await queryAll<CmsEntry>({\n entity: esEntity,\n partitionKey,\n options: {\n gte: \" \"\n }\n });\n\n const deleteItems = items.map(item => {\n return entity.deleteBatch({\n PK: item.PK,\n SK: item.SK\n });\n });\n\n const deleteEsItems = esItems.map(item => {\n return esEntity.deleteBatch({\n PK: item.PK,\n SK: item.SK\n });\n });\n\n try {\n await batchWriteAll({\n table: entity.table,\n items: deleteItems\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not destroy entry records from DynamoDB table.\",\n ex.code || \"DELETE_ENTRY_ERROR\",\n {\n error: ex,\n id\n }\n );\n }\n\n try {\n await batchWriteAll({\n table: esEntity.table,\n items: deleteEsItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not destroy entry records from DynamoDB Elasticsearch table.\",\n ex.code || \"DELETE_ENTRY_ERROR\",\n {\n error: ex,\n id\n }\n );\n }\n };\n\n const deleteRevision: CmsEntryStorageOperations[\"deleteRevision\"] = async (\n initialModel,\n params\n ) => {\n const { entry, latestEntry, latestStorageEntry: initialLatestStorageEntry } = params;\n const model = getStorageOperationsModel(initialModel);\n\n const partitionKey = createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n });\n\n const { index } = configurations.es({\n model\n });\n /**\n * We need published entry to delete it if necessary.\n */\n const [publishedStorageEntry] = await dataLoaders.getPublishedRevisionByEntryId({\n model,\n ids: [entry.id]\n });\n /**\n * We need to delete all existing records of the given entry revision.\n */\n const items = [\n /**\n * Delete records of given entry revision.\n */\n entity.deleteBatch({\n PK: partitionKey,\n SK: createRevisionSortKey(entry)\n })\n ];\n\n const esItems: BatchWriteItem[] = [];\n\n /**\n * If revision we are deleting is the published one as well, we need to delete those records as well.\n */\n if (publishedStorageEntry?.id === entry.id) {\n items.push(\n entity.deleteBatch({\n PK: partitionKey,\n SK: createPublishedSortKey()\n })\n );\n esItems.push(\n esEntity.deleteBatch({\n PK: partitionKey,\n SK: createPublishedSortKey()\n })\n );\n }\n\n if (latestEntry && initialLatestStorageEntry) {\n const latestStorageEntry = convertToStorageEntry({\n storageEntry: initialLatestStorageEntry,\n model\n });\n\n /**\n * In the end we need to set the new latest entry.\n */\n items.push(\n entity.putBatch({\n ...latestStorageEntry,\n PK: partitionKey,\n SK: createLatestSortKey(),\n TYPE: createLatestRecordType()\n })\n );\n\n /**\n * Also perform an update on the actual revision. This is needed\n * because of updates on the entry-level meta fields.\n */\n items.push(\n entity.putBatch({\n ...latestStorageEntry,\n PK: createPartitionKey({\n id: initialLatestStorageEntry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createRevisionSortKey(initialLatestStorageEntry),\n TYPE: createRecordType()\n })\n );\n\n const latestTransformer = createTransformer({\n plugins,\n model,\n entry: latestEntry,\n storageEntry: initialLatestStorageEntry\n });\n\n const esLatestData = await latestTransformer.getElasticsearchLatestEntryData();\n esItems.push(\n esEntity.putBatch({\n PK: partitionKey,\n SK: createLatestSortKey(),\n index,\n data: esLatestData\n })\n );\n }\n\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not batch write entry records to DynamoDB table.\",\n ex.code || \"DELETE_REVISION_ERROR\",\n {\n error: ex,\n entry,\n latestEntry,\n initialLatestStorageEntry\n }\n );\n }\n\n if (esItems.length === 0) {\n return;\n }\n\n try {\n await batchWriteAll({\n table: esEntity.table,\n items: esItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message ||\n \"Could not batch write entry records to DynamoDB Elasticsearch table.\",\n ex.code || \"DELETE_REVISION_ERROR\",\n {\n error: ex,\n entry,\n latestEntry,\n initialLatestStorageEntry\n }\n );\n }\n };\n\n const deleteMultipleEntries: CmsEntryStorageOperations[\"deleteMultipleEntries\"] = async (\n initialModel,\n params\n ) => {\n const { entries } = params;\n const model = getStorageOperationsModel(initialModel);\n /**\n * First we need all the revisions of the entries we want to delete.\n */\n const revisions = await dataLoaders.getAllEntryRevisions({\n model,\n ids: entries\n });\n /**\n * Then we need to construct the queries for all the revisions and entries.\n */\n const items: Record<string, WriteRequest>[] = [];\n const esItems: Record<string, WriteRequest>[] = [];\n for (const id of entries) {\n /**\n * Latest item.\n */\n items.push(\n entity.deleteBatch({\n PK: createPartitionKey({\n id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: \"L\"\n })\n );\n esItems.push(\n esEntity.deleteBatch({\n PK: createPartitionKey({\n id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: \"L\"\n })\n );\n /**\n * Published item.\n */\n items.push(\n entity.deleteBatch({\n PK: createPartitionKey({\n id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: \"P\"\n })\n );\n esItems.push(\n esEntity.deleteBatch({\n PK: createPartitionKey({\n id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: \"P\"\n })\n );\n }\n /**\n * Exact revisions of all the entries\n */\n for (const revision of revisions) {\n items.push(\n entity.deleteBatch({\n PK: createPartitionKey({\n id: revision.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createRevisionSortKey({\n version: revision.version\n })\n })\n );\n }\n\n await batchWriteAll({\n table: entity.table,\n items\n });\n await batchWriteAll({\n table: esEntity.table,\n items: esItems\n });\n };\n\n const list: CmsEntryStorageOperations[\"list\"] = async (initialModel, params) => {\n const model = getStorageOperationsModel(initialModel);\n\n const limit = createLimit(params.limit, 50);\n const { index } = configurations.es({\n model\n });\n\n const body = createElasticsearchBody({\n model,\n params: {\n ...params,\n limit,\n after: decodeCursor(params.after)\n },\n plugins\n });\n\n let response: ElasticsearchSearchResponse<CmsIndexEntry>;\n try {\n response = await elasticsearch.search({\n index,\n body\n });\n } catch (error) {\n /**\n * We will silently ignore the `index_not_found_exception` error and return an empty result set.\n * This is because the index might not exist yet, and we don't want to throw an error.\n */\n if (shouldIgnoreEsResponseError(error)) {\n logIgnoredEsResponseError({\n error,\n model,\n indexName: index\n });\n\n return {\n hasMoreItems: false,\n totalCount: 0,\n cursor: null,\n items: []\n };\n }\n\n throw new WebinyError(error.message, error.code || \"ELASTICSEARCH_ERROR\", {\n error,\n index,\n body,\n model\n });\n }\n\n const { hits, total } = response?.body?.hits || {};\n\n const items = extractEntriesFromIndex({\n plugins,\n model,\n entries: hits.map(item => item._source)\n }).map(item => {\n return convertEntryKeysFromStorage({\n model,\n entry: item\n });\n });\n\n const hasMoreItems = items.length > limit;\n if (hasMoreItems) {\n /**\n * Remove the last item from results, we don't want to include it.\n */\n items.pop();\n }\n /**\n * Cursor is the `sort` value of the last item in the array.\n * https://www.elastic.co/guide/en/elasticsearch/reference/current/paginate-search-results.html#search-after\n */\n const cursor = items.length > 0 ? encodeCursor(hits[items.length - 1].sort) || null : null;\n return {\n hasMoreItems,\n totalCount: total.value,\n cursor,\n items\n };\n };\n\n const get: CmsEntryStorageOperations[\"get\"] = async (initialModel, params) => {\n const model = getStorageOperationsModel(initialModel);\n\n const { items } = await list(model, {\n ...params,\n limit: 1\n });\n return items.shift() || null;\n };\n\n const publish: CmsEntryStorageOperations[\"publish\"] = async (initialModel, params) => {\n const { entry: initialEntry, storageEntry: initialStorageEntry } = params;\n const model = getStorageOperationsModel(initialModel);\n\n const transformer = createTransformer({\n plugins,\n model,\n entry: initialEntry,\n storageEntry: initialStorageEntry\n });\n\n const { entry, storageEntry } = transformer.transformEntryKeys();\n\n const revisionKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createRevisionSortKey(entry)\n };\n const latestKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createLatestSortKey()\n };\n const publishedKeys = {\n PK: createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n }),\n SK: createPublishedSortKey()\n };\n\n let latestEsEntry: ElasticsearchDbRecord | null = null;\n try {\n latestEsEntry = await getClean<ElasticsearchDbRecord>({\n entity: esEntity,\n keys: latestKeys\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not read Elasticsearch latest data.\",\n ex.code || \"PUBLISH_LATEST_READ\",\n {\n error: ex,\n latestKeys: latestKeys,\n publishedKeys: publishedKeys\n }\n );\n }\n\n if (!latestEsEntry) {\n throw new WebinyError(\n `Could not publish entry. Could not load latest (\"L\") record (ES table).`,\n \"PUBLISH_ERROR\",\n { entry }\n );\n }\n\n /**\n * We need the latest entry to check if it needs to be updated as well in the Elasticsearch.\n */\n const [latestStorageEntry] = await dataLoaders.getLatestRevisionByEntryId({\n model,\n ids: [entry.id]\n });\n\n if (!latestStorageEntry) {\n throw new WebinyError(\n `Could not publish entry. Could not load latest (\"L\") record.`,\n \"PUBLISH_ERROR\",\n { entry }\n );\n }\n\n /**\n * We need currently published entry to check if need to remove it.\n */\n const [publishedStorageEntry] = await dataLoaders.getPublishedRevisionByEntryId({\n model,\n ids: [entry.id]\n });\n\n // 1. Update REV# and P records with new data.\n const items = [\n entity.putBatch({\n ...storageEntry,\n ...revisionKeys,\n TYPE: createRecordType()\n }),\n entity.putBatch({\n ...storageEntry,\n ...publishedKeys,\n TYPE: createPublishedRecordType()\n })\n ];\n const esItems: BatchWriteItem[] = [];\n\n const { index: esIndex } = configurations.es({\n model\n });\n\n // 2. When it comes to the latest record, we need to perform a couple of different\n // updates, based on whether the entry being published is the latest revision or not.\n const publishedRevisionId = publishedStorageEntry?.id;\n const publishingLatestRevision = latestStorageEntry?.id === entry.id;\n\n if (publishingLatestRevision) {\n // 2.1 If we're publishing the latest revision, we first need to update the L record.\n items.push(\n entity.putBatch({\n ...storageEntry,\n ...latestKeys\n })\n );\n\n // 2.2 Additionally, if we have a previously published entry, we need to mark it as unpublished.\n // Note that we need to take re-publishing into account (same published revision being\n // published again), in which case the below code does not apply. This is because the\n // required updates were already applied above.\n if (publishedStorageEntry) {\n const isRepublishing = publishedStorageEntry.id === entry.id;\n if (!isRepublishing) {\n items.push(\n /**\n * Update currently published entry (unpublish it)\n */\n entity.putBatch({\n ...publishedStorageEntry,\n status: CONTENT_ENTRY_STATUS.UNPUBLISHED,\n TYPE: createRecordType(),\n PK: createPartitionKey(publishedStorageEntry),\n SK: createRevisionSortKey(publishedStorageEntry)\n })\n );\n }\n }\n } else {\n // 2.3 If the published revision is not the latest one, the situation is a bit\n // more complex. We first need to update the L and REV# records with the new\n // values of *only entry-level* meta fields.\n const updatedEntryLevelMetaFields = pickEntryMetaFields(\n entry,\n isEntryLevelEntryMetaField\n );\n\n // 2.4 Update L record. Apart from updating the entry-level meta fields, we also need\n // to change the status from \"published\" to \"unpublished\" (if the status is set to \"published\").\n let latestRevisionStatus = latestStorageEntry.status;\n if (latestRevisionStatus === CONTENT_ENTRY_STATUS.PUBLISHED) {\n latestRevisionStatus = CONTENT_ENTRY_STATUS.UNPUBLISHED;\n }\n\n const latestStorageEntryFields = {\n ...latestStorageEntry,\n ...updatedEntryLevelMetaFields,\n status: latestRevisionStatus\n };\n\n items.push(\n entity.putBatch({\n ...latestStorageEntryFields,\n PK: createPartitionKey(latestStorageEntry),\n SK: createLatestSortKey(),\n TYPE: createLatestRecordType()\n })\n );\n\n // 2.5 Update REV# record.\n items.push(\n entity.putBatch({\n ...latestStorageEntryFields,\n PK: createPartitionKey(latestStorageEntry),\n SK: createRevisionSortKey(latestStorageEntry),\n TYPE: createRecordType()\n })\n );\n\n // 2.6 Additionally, if we have a previously published entry, we need to mark it as unpublished.\n // Note that we need to take re-publishing into account (same published revision being\n // published again), in which case the below code does not apply. This is because the\n // required updates were already applied above.\n if (publishedStorageEntry) {\n const isRepublishing = publishedStorageEntry.id === entry.id;\n const publishedRevisionDifferentFromLatest =\n publishedRevisionId !== latestStorageEntry.id;\n\n if (!isRepublishing && publishedRevisionDifferentFromLatest) {\n items.push(\n entity.putBatch({\n ...publishedStorageEntry,\n PK: createPartitionKey(publishedStorageEntry),\n SK: createRevisionSortKey(publishedStorageEntry),\n TYPE: createRecordType(),\n status: CONTENT_ENTRY_STATUS.UNPUBLISHED\n })\n );\n }\n }\n }\n\n // 3. Update records in ES -> DDB table.\n\n /**\n * Update the published revision entry in ES.\n */\n const esPublishedData = await transformer.getElasticsearchPublishedEntryData();\n esItems.push(\n esEntity.putBatch({\n ...publishedKeys,\n index: esIndex,\n data: esPublishedData\n })\n );\n\n /**\n * Need to decompress the data from Elasticsearch DynamoDB table.\n *\n * No need to transform it for the storage because it was fetched\n * directly from the Elasticsearch table, where it sits transformed.\n */\n const latestEsEntryDataDecompressed = (await decompress(\n plugins,\n latestEsEntry.data\n )) as CmsIndexEntry;\n\n if (publishingLatestRevision) {\n const updatedMetaFields = pickEntryMetaFields(entry);\n\n const latestTransformer = createTransformer({\n plugins,\n model,\n transformedToIndex: {\n ...latestEsEntryDataDecompressed,\n status: CONTENT_ENTRY_STATUS.PUBLISHED,\n locked: true,\n ...updatedMetaFields\n }\n });\n\n esItems.push(\n esEntity.putBatch({\n index: esIndex,\n PK: createPartitionKey(latestEsEntryDataDecompressed),\n SK: createLatestSortKey(),\n data: await latestTransformer.getElasticsearchLatestEntryData()\n })\n );\n } else {\n const updatedEntryLevelMetaFields = pickEntryMetaFields(\n entry,\n isEntryLevelEntryMetaField\n );\n\n /**\n * Update the Elasticsearch table to propagate changes to the Elasticsearch.\n */\n const latestEsEntry = await getClean<ElasticsearchDbRecord>({\n entity: esEntity,\n keys: latestKeys\n });\n\n if (latestEsEntry) {\n const latestEsEntryDataDecompressed = (await decompress(\n plugins,\n latestEsEntry.data\n )) as CmsIndexEntry;\n\n let latestRevisionStatus = latestEsEntryDataDecompressed.status;\n if (latestRevisionStatus === CONTENT_ENTRY_STATUS.PUBLISHED) {\n latestRevisionStatus = CONTENT_ENTRY_STATUS.UNPUBLISHED;\n }\n\n const updatedLatestEntry = await compress(plugins, {\n ...latestEsEntryDataDecompressed,\n ...updatedEntryLevelMetaFields,\n status: latestRevisionStatus\n });\n\n esItems.push(\n esEntity.putBatch({\n ...latestKeys,\n index: esIndex,\n data: updatedLatestEntry\n })\n );\n }\n }\n\n /**\n * Finally, execute regular table batch.\n */\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not store publish entry records in DynamoDB table.\",\n ex.code || \"PUBLISH_ERROR\",\n {\n error: ex,\n entry,\n latestStorageEntry,\n publishedStorageEntry\n }\n );\n }\n /**\n * And Elasticsearch table batch.\n */\n try {\n await batchWriteAll({\n table: esEntity.table,\n items: esItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message ||\n \"Could not store publish entry records in DynamoDB Elasticsearch table.\",\n ex.code || \"PUBLISH_ES_ERROR\",\n {\n error: ex,\n entry,\n latestStorageEntry,\n publishedStorageEntry\n }\n );\n }\n return initialStorageEntry;\n };\n\n const unpublish: CmsEntryStorageOperations[\"unpublish\"] = async (initialModel, params) => {\n const { entry: initialEntry, storageEntry: initialStorageEntry } = params;\n const model = getStorageOperationsModel(initialModel);\n\n const transformer = createTransformer({\n plugins,\n model,\n entry: initialEntry,\n storageEntry: initialStorageEntry\n });\n const { entry, storageEntry } = await transformer.transformEntryKeys();\n\n /**\n * We need the latest entry to check if it needs to be updated.\n */\n const [latestStorageEntry] = await dataLoaders.getLatestRevisionByEntryId({\n model,\n ids: [entry.id]\n });\n\n const partitionKey = createPartitionKey({\n id: entry.id,\n locale: model.locale,\n tenant: model.tenant\n });\n\n const items = [\n entity.deleteBatch({\n PK: partitionKey,\n SK: createPublishedSortKey()\n }),\n entity.putBatch({\n ...storageEntry,\n PK: partitionKey,\n SK: createRevisionSortKey(entry),\n TYPE: createRecordType()\n })\n ];\n\n const esItems: BatchWriteItem[] = [\n esEntity.deleteBatch({\n PK: partitionKey,\n SK: createPublishedSortKey()\n })\n ];\n /**\n * If we are unpublishing the latest revision, let's also update the latest revision entry's status in both DynamoDB tables.\n */\n if (latestStorageEntry?.id === entry.id) {\n const { index } = configurations.es({\n model\n });\n\n items.push(\n entity.putBatch({\n ...storageEntry,\n PK: partitionKey,\n SK: createLatestSortKey(),\n TYPE: createLatestRecordType()\n })\n );\n\n const esLatestData = await transformer.getElasticsearchLatestEntryData();\n esItems.push(\n esEntity.putBatch({\n PK: partitionKey,\n SK: createLatestSortKey(),\n index,\n data: esLatestData\n })\n );\n }\n\n /**\n * Finally, execute regular table batch.\n */\n try {\n await batchWriteAll({\n table: entity.table,\n items\n });\n dataLoaders.clearAll({\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not store unpublished entry records in DynamoDB table.\",\n ex.code || \"UNPUBLISH_ERROR\",\n {\n entry,\n storageEntry\n }\n );\n }\n /**\n * And Elasticsearch table batch.\n */\n try {\n await batchWriteAll({\n table: esEntity.table,\n items: esItems\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message ||\n \"Could not store unpublished entry records in DynamoDB Elasticsearch table.\",\n ex.code || \"UNPUBLISH_ERROR\",\n {\n entry,\n storageEntry\n }\n );\n }\n return initialStorageEntry;\n };\n\n const getLatestRevisionByEntryId: CmsEntryStorageOperations[\"getLatestRevisionByEntryId\"] =\n async (initialModel, params) => {\n const model = getStorageOperationsModel(initialModel);\n\n const [entry] = await dataLoaders.getLatestRevisionByEntryId({\n model,\n ids: [params.id]\n });\n if (!entry) {\n return null;\n }\n return convertEntryKeysFromStorage({\n model,\n entry\n });\n };\n\n const getPublishedRevisionByEntryId: CmsEntryStorageOperations[\"getPublishedRevisionByEntryId\"] =\n async (initialModel, params) => {\n const model = getStorageOperationsModel(initialModel);\n\n const [entry] = await dataLoaders.getPublishedRevisionByEntryId({\n model,\n ids: [params.id]\n });\n if (!entry) {\n return null;\n }\n return convertEntryKeysFromStorage({\n model,\n entry\n });\n };\n\n const getRevisionById: CmsEntryStorageOperations[\"getRevisionById\"] = async (\n initialModel,\n params\n ) => {\n const model = getStorageOperationsModel(initialModel);\n\n const [entry] = await dataLoaders.getRevisionById({\n model,\n ids: [params.id]\n });\n if (!entry) {\n return null;\n }\n return convertEntryKeysFromStorage({\n model,\n entry\n });\n };\n\n const getRevisions: CmsEntryStorageOperations[\"getRevisions\"] = async (\n initialModel,\n params\n ) => {\n const model = getStorageOperationsModel(initialModel);\n\n const entries = await dataLoaders.getAllEntryRevisions({\n model,\n ids: [params.id]\n });\n\n return entries.map(entry => {\n return convertEntryKeysFromStorage({\n model,\n entry\n });\n });\n };\n\n const getByIds: CmsEntryStorageOperations[\"getByIds\"] = async (initialModel, params) => {\n const model = getStorageOperationsModel(initialModel);\n\n const entries = await dataLoaders.getRevisionById({\n model,\n ids: params.ids\n });\n\n return entries.map(entry => {\n return convertEntryKeysFromStorage({\n model,\n entry\n });\n });\n };\n\n const getLatestByIds: CmsEntryStorageOperations[\"getLatestByIds\"] = async (\n initialModel,\n params\n ) => {\n const model = getStorageOperationsModel(initialModel);\n\n const entries = await dataLoaders.getLatestRevisionByEntryId({\n model,\n ids: params.ids\n });\n return entries.map(entry => {\n return convertEntryKeysFromStorage({\n model,\n entry\n });\n });\n };\n\n const getPublishedByIds: CmsEntryStorageOperations[\"getPublishedByIds\"] = async (\n initialModel,\n params\n ) => {\n const model = getStorageOperationsModel(initialModel);\n\n const entries = await dataLoaders.getPublishedRevisionByEntryId({\n model,\n ids: params.ids\n });\n\n return entries.map(entry => {\n return convertEntryKeysFromStorage({\n model,\n entry\n });\n });\n };\n\n const getPreviousRevision: CmsEntryStorageOperations[\"getPreviousRevision\"] = async (\n initialModel,\n params\n ) => {\n const model = getStorageOperationsModel(initialModel);\n\n const { tenant, locale } = model;\n const { entryId, version } = params;\n const queryParams: QueryOneParams = {\n entity,\n partitionKey: createPartitionKey({\n tenant,\n locale,\n id: entryId\n }),\n options: {\n lt: `REV#${zeroPad(version)}`,\n /**\n * We need to have extra checks because DynamoDB will return published or latest record if there is no REV# record.\n */\n filters: [\n {\n attr: \"TYPE\",\n eq: createRecordType()\n },\n {\n attr: \"version\",\n lt: version\n }\n ],\n reverse: true\n }\n };\n\n try {\n const result = await queryOne<CmsEntry>(queryParams);\n\n const entry = cleanupItem(entity, result);\n\n if (!entry) {\n return null;\n }\n return convertEntryKeysFromStorage({\n entry,\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get previous version of given entry.\",\n ex.code || \"GET_PREVIOUS_VERSION_ERROR\",\n {\n ...params,\n error: ex,\n partitionKey: queryParams.partitionKey,\n options: queryParams.options,\n model\n }\n );\n }\n };\n\n const getUniqueFieldValues: CmsEntryStorageOperations[\"getUniqueFieldValues\"] = async (\n model,\n params\n ) => {\n const { where, fieldId } = params;\n\n const { index } = configurations.es({\n model\n });\n\n const initialBody = createElasticsearchBody({\n model,\n params: {\n limit: 1,\n where\n },\n plugins\n });\n\n const field = model.fields.find(f => f.fieldId === fieldId);\n if (!field) {\n throw new WebinyError(\n `Could not find field with given \"fieldId\" value.`,\n \"FIELD_NOT_FOUND\",\n {\n fieldId\n }\n );\n }\n\n const body: ElasticsearchSearchBody = {\n ...initialBody,\n /**\n * We do not need any hits returned, we only need the aggregations.\n */\n size: 0,\n aggregations: {\n getUniqueFieldValues: {\n terms: {\n field: `values.${field.storageId}.keyword`,\n size: 1000000\n }\n }\n }\n };\n\n let response: ElasticsearchSearchResponse<string> | undefined = undefined;\n\n try {\n response = await elasticsearch.search({\n index,\n body\n });\n } catch (error) {\n if (shouldIgnoreEsResponseError(error)) {\n logIgnoredEsResponseError({\n error,\n model,\n indexName: index\n });\n return [];\n }\n\n throw new WebinyError(\n error.message || \"Error in the Elasticsearch query.\",\n error.code || \"ELASTICSEARCH_ERROR\",\n {\n error,\n index,\n model,\n body\n }\n );\n }\n\n const buckets = response.body.aggregations[\"getUniqueFieldValues\"]?.buckets || [];\n return buckets.map(file => {\n return {\n value: file.key,\n count: file.doc_count\n };\n });\n };\n\n return {\n create,\n createRevisionFrom,\n update,\n move,\n delete: deleteEntry,\n moveToBin,\n restoreFromBin,\n deleteRevision,\n deleteMultipleEntries,\n get,\n publish,\n unpublish,\n list,\n getLatestRevisionByEntryId,\n getPublishedRevisionByEntryId,\n getRevisionById,\n getRevisions,\n getByIds,\n getLatestByIds,\n getPublishedByIds,\n getPreviousRevision,\n getUniqueFieldValues,\n dataLoaders\n };\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAOA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AAIA,IAAAI,WAAA,GAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AAMA,IAAAO,MAAA,GAAAP,OAAA;AAMA,IAAAQ,iBAAA,GAAAR,OAAA;AAOA,IAAAS,IAAA,GAAAT,OAAA;AACA,IAAAU,MAAA,GAAAV,OAAA;AACA,IAAAW,QAAA,GAAAX,OAAA;AAMA,IAAAY,KAAA,GAAAZ,OAAA;AACA,IAAAa,0BAAA,GAAAb,OAAA;AACA,IAAAc,4BAAA,GAAAd,OAAA;AACA,IAAAe,WAAA,GAAAf,OAAA;AACA,IAAAgB,eAAA,GAAAhB,OAAA;AAEA,IAAAiB,WAAA,GAAAjB,OAAA;AACA,IAAAkB,gBAAA,GAAAlB,OAAA;AACA,IAAAmB,iBAAA,GAAAnB,OAAA;AACA,IAAAoB,UAAA,GAAApB,OAAA;AAwBA,MAAMqB,qBAAqB,GAAIC,MAAiC,IAAsB;EAClF,MAAM;IAAEC,KAAK;IAAEC;EAAa,CAAC,GAAGF,MAAM;EAEtC,MA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EACnC;QACIC,KAAK;QACL9B,KAAK;QACLjC,KAAK;QACLkJ;MACJ,CACJ,CAAC;IACL;IAEA,MAAM6D,OAAO,GAAGzD,QAAQ,CAACJ,IAAI,CAAC0D,YAAY,CAAC,sBAAsB,CAAC,EAAEG,OAAO,IAAI,EAAE;IACjF,OAAOA,OAAO,CAAC3F,GAAG,CAAC4F,IAAI,IAAI;MACvB,OAAO;QACH1C,KAAK,EAAE0C,IAAI,CAACC,GAAG;QACfC,KAAK,EAAEF,IAAI,CAACG;MAChB,CAAC;IACL,CAAC,CAAC;EACN,CAAC;EAED,OAAO;IACH/L,MAAM;IACNkD,kBAAkB;IAClBM,MAAM;IACNmB,IAAI;IACJqH,MAAM,EAAEpF,WAAW;IACnBP,SAAS;IACTK,cAAc;IACdO,cAAc;IACdI,qBAAqB;IACrB8B,GAAG;IACHE,OAAO;IACPU,SAAS;IACTpC,IAAI;IACJjE,0BAA0B;IAC1BN,6BAA6B;IAC7B4G,eAAe;IACfC,YAAY;IACZC,QAAQ;IACRC,cAAc;IACdC,iBAAiB;IACjBC,mBAAmB;IACnBW,oBAAoB;IACpBlL;EACJ,CAAC;AACL,CAAC;AAACmM,OAAA,CAAAhN,8BAAA,GAAAA,8BAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-headless-cms-ddb-es",
|
|
3
|
-
"version": "5.40.
|
|
3
|
+
"version": "5.40.6-beta.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"@webiny/api-headless-cms",
|
|
@@ -27,16 +27,16 @@
|
|
|
27
27
|
"license": "MIT",
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@babel/runtime": "7.24.1",
|
|
30
|
-
"@webiny/api": "5.40.
|
|
31
|
-
"@webiny/api-elasticsearch": "5.40.
|
|
32
|
-
"@webiny/api-elasticsearch-tasks": "5.40.
|
|
33
|
-
"@webiny/api-headless-cms": "5.40.
|
|
34
|
-
"@webiny/aws-sdk": "5.40.
|
|
35
|
-
"@webiny/db-dynamodb": "5.40.
|
|
36
|
-
"@webiny/error": "5.40.
|
|
37
|
-
"@webiny/handler-db": "5.40.
|
|
38
|
-
"@webiny/plugins": "5.40.
|
|
39
|
-
"@webiny/utils": "5.40.
|
|
30
|
+
"@webiny/api": "5.40.6-beta.0",
|
|
31
|
+
"@webiny/api-elasticsearch": "5.40.6-beta.0",
|
|
32
|
+
"@webiny/api-elasticsearch-tasks": "5.40.6-beta.0",
|
|
33
|
+
"@webiny/api-headless-cms": "5.40.6-beta.0",
|
|
34
|
+
"@webiny/aws-sdk": "5.40.6-beta.0",
|
|
35
|
+
"@webiny/db-dynamodb": "5.40.6-beta.0",
|
|
36
|
+
"@webiny/error": "5.40.6-beta.0",
|
|
37
|
+
"@webiny/handler-db": "5.40.6-beta.0",
|
|
38
|
+
"@webiny/plugins": "5.40.6-beta.0",
|
|
39
|
+
"@webiny/utils": "5.40.6-beta.0",
|
|
40
40
|
"dataloader": "2.2.1",
|
|
41
41
|
"jsonpack": "1.1.5",
|
|
42
42
|
"lodash": "4.17.21"
|
|
@@ -47,17 +47,17 @@
|
|
|
47
47
|
"@babel/preset-env": "7.24.3",
|
|
48
48
|
"@elastic/elasticsearch": "7.12.0",
|
|
49
49
|
"@types/jsonpack": "1.1.2",
|
|
50
|
-
"@webiny/api-dynamodb-to-elasticsearch": "5.40.
|
|
51
|
-
"@webiny/api-i18n": "5.40.
|
|
52
|
-
"@webiny/api-security": "5.40.
|
|
53
|
-
"@webiny/api-tenancy": "5.40.
|
|
54
|
-
"@webiny/api-wcp": "5.40.
|
|
55
|
-
"@webiny/cli": "5.40.
|
|
56
|
-
"@webiny/handler": "5.40.
|
|
57
|
-
"@webiny/handler-aws": "5.40.
|
|
58
|
-
"@webiny/handler-graphql": "5.40.
|
|
59
|
-
"@webiny/project-utils": "5.40.
|
|
60
|
-
"@webiny/tasks": "5.40.
|
|
50
|
+
"@webiny/api-dynamodb-to-elasticsearch": "5.40.6-beta.0",
|
|
51
|
+
"@webiny/api-i18n": "5.40.6-beta.0",
|
|
52
|
+
"@webiny/api-security": "5.40.6-beta.0",
|
|
53
|
+
"@webiny/api-tenancy": "5.40.6-beta.0",
|
|
54
|
+
"@webiny/api-wcp": "5.40.6-beta.0",
|
|
55
|
+
"@webiny/cli": "5.40.6-beta.0",
|
|
56
|
+
"@webiny/handler": "5.40.6-beta.0",
|
|
57
|
+
"@webiny/handler-aws": "5.40.6-beta.0",
|
|
58
|
+
"@webiny/handler-graphql": "5.40.6-beta.0",
|
|
59
|
+
"@webiny/project-utils": "5.40.6-beta.0",
|
|
60
|
+
"@webiny/tasks": "5.40.6-beta.0",
|
|
61
61
|
"jest": "29.7.0",
|
|
62
62
|
"jest-dynalite": "3.6.1",
|
|
63
63
|
"prettier": "2.8.8",
|
|
@@ -74,5 +74,5 @@
|
|
|
74
74
|
"build": "yarn webiny run build",
|
|
75
75
|
"watch": "yarn webiny run watch"
|
|
76
76
|
},
|
|
77
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "c0bf7d9bfe72b0689b29c84506f3168515a78517"
|
|
78
78
|
}
|