@webiny/api-headless-cms-ddb-es 6.0.0-beta.0 → 6.0.0-rc.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/README.md +6 -30
- package/configurations.d.ts +4 -5
- package/configurations.js +12 -24
- package/configurations.js.map +1 -1
- package/definitions/entry.d.ts +4 -5
- package/definitions/entry.js +5 -174
- package/definitions/entry.js.map +1 -1
- package/definitions/group.d.ts +6 -6
- package/definitions/group.js +5 -58
- package/definitions/group.js.map +1 -1
- package/definitions/model.d.ts +6 -6
- package/definitions/model.js +5 -102
- package/definitions/model.js.map +1 -1
- package/definitions/types.d.ts +59 -0
- package/definitions/types.js +3 -0
- package/definitions/types.js.map +1 -0
- package/dynamoDb/index.d.ts +2 -2
- package/dynamoDb/index.js +5 -14
- package/dynamoDb/index.js.map +1 -1
- package/dynamoDb/storage/longText.js +11 -18
- package/dynamoDb/storage/longText.js.map +1 -1
- package/dynamoDb/storage/richText.d.ts +0 -5
- package/dynamoDb/storage/richText.js +25 -80
- package/dynamoDb/storage/richText.js.map +1 -1
- package/elasticsearch/createElasticsearchIndex.d.ts +3 -3
- package/elasticsearch/createElasticsearchIndex.js +7 -15
- package/elasticsearch/createElasticsearchIndex.js.map +1 -1
- package/elasticsearch/deleteElasticsearchIndex.d.ts +2 -2
- package/elasticsearch/deleteElasticsearchIndex.js +3 -10
- package/elasticsearch/deleteElasticsearchIndex.js.map +1 -1
- package/elasticsearch/index.d.ts +1 -1
- package/elasticsearch/index.js +3 -11
- package/elasticsearch/index.js.map +1 -1
- package/elasticsearch/indexing/dateTimeIndexing.d.ts +1 -1
- package/elasticsearch/indexing/dateTimeIndexing.js +1 -8
- package/elasticsearch/indexing/dateTimeIndexing.js.map +1 -1
- package/elasticsearch/indexing/defaultFieldIndexing.d.ts +1 -1
- package/elasticsearch/indexing/defaultFieldIndexing.js +1 -8
- package/elasticsearch/indexing/defaultFieldIndexing.js.map +1 -1
- package/elasticsearch/indexing/index.d.ts +1 -1
- package/elasticsearch/indexing/index.js +8 -16
- package/elasticsearch/indexing/index.js.map +1 -1
- package/elasticsearch/indexing/jsonIndexing.d.ts +1 -1
- package/elasticsearch/indexing/jsonIndexing.js +1 -8
- package/elasticsearch/indexing/jsonIndexing.js.map +1 -1
- package/elasticsearch/indexing/longTextIndexing.d.ts +1 -1
- package/elasticsearch/indexing/longTextIndexing.js +1 -8
- package/elasticsearch/indexing/longTextIndexing.js.map +1 -1
- package/elasticsearch/indexing/numberIndexing.d.ts +1 -1
- package/elasticsearch/indexing/numberIndexing.js +1 -8
- package/elasticsearch/indexing/numberIndexing.js.map +1 -1
- package/elasticsearch/indexing/objectIndexing.d.ts +1 -1
- package/elasticsearch/indexing/objectIndexing.js +6 -13
- package/elasticsearch/indexing/objectIndexing.js.map +1 -1
- package/elasticsearch/indexing/richTextIndexing.d.ts +1 -1
- package/elasticsearch/indexing/richTextIndexing.js +1 -8
- package/elasticsearch/indexing/richTextIndexing.js.map +1 -1
- package/elasticsearch/indices/base.d.ts +1 -1
- package/elasticsearch/indices/base.js +4 -10
- package/elasticsearch/indices/base.js.map +1 -1
- package/elasticsearch/indices/index.d.ts +1 -1
- package/elasticsearch/indices/index.js +3 -11
- package/elasticsearch/indices/index.js.map +1 -1
- package/elasticsearch/search/index.d.ts +1 -1
- package/elasticsearch/search/index.js +4 -10
- package/elasticsearch/search/index.js.map +1 -1
- package/elasticsearch/search/refSearch.d.ts +1 -1
- package/elasticsearch/search/refSearch.js +3 -10
- package/elasticsearch/search/refSearch.js.map +1 -1
- package/elasticsearch/search/searchableJson.d.ts +2 -0
- package/elasticsearch/search/searchableJson.js +53 -0
- package/elasticsearch/search/searchableJson.js.map +1 -0
- package/elasticsearch/search/timeSearch.d.ts +1 -1
- package/elasticsearch/search/timeSearch.js +3 -10
- package/elasticsearch/search/timeSearch.js.map +1 -1
- package/helpers/entryIndexHelpers.d.ts +10 -10
- package/helpers/entryIndexHelpers.js +32 -26
- package/helpers/entryIndexHelpers.js.map +1 -1
- package/helpers/fieldIdentifier.d.ts +1 -1
- package/helpers/fieldIdentifier.js +2 -10
- package/helpers/fieldIdentifier.js.map +1 -1
- package/helpers/index.d.ts +2 -2
- package/helpers/index.js +2 -27
- package/helpers/index.js.map +1 -1
- package/index.d.ts +2 -2
- package/index.js +108 -134
- package/index.js.map +1 -1
- package/operations/entry/dataLoader/DataLoaderCache.d.ts +1 -3
- package/operations/entry/dataLoader/DataLoaderCache.js +2 -9
- package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -1
- package/operations/entry/dataLoader/constants.js +1 -7
- package/operations/entry/dataLoader/constants.js.map +1 -1
- package/operations/entry/dataLoader/createBatchScheduleFn.js +4 -10
- package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -1
- package/operations/entry/dataLoader/getAllEntryRevisions.d.ts +3 -3
- package/operations/entry/dataLoader/getAllEntryRevisions.js +11 -24
- package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -1
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.d.ts +3 -3
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +18 -30
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -1
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.d.ts +3 -3
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +18 -30
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -1
- package/operations/entry/dataLoader/getRevisionById.d.ts +3 -3
- package/operations/entry/dataLoader/getRevisionById.js +23 -35
- package/operations/entry/dataLoader/getRevisionById.js.map +1 -1
- package/operations/entry/dataLoader/index.d.ts +5 -5
- package/operations/entry/dataLoader/index.js +10 -31
- package/operations/entry/dataLoader/index.js.map +1 -1
- package/operations/entry/dataLoader/types.d.ts +3 -4
- package/operations/entry/dataLoader/types.js +1 -5
- package/operations/entry/dataLoader/types.js.map +1 -1
- package/operations/entry/dataLoaders.d.ts +13 -13
- package/operations/entry/dataLoaders.js +15 -25
- package/operations/entry/dataLoaders.js.map +1 -1
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.d.ts +1 -1
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js +1 -8
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js.map +1 -1
- package/operations/entry/elasticsearch/body.d.ts +3 -3
- package/operations/entry/elasticsearch/body.js +21 -28
- package/operations/entry/elasticsearch/body.js.map +1 -1
- package/operations/entry/elasticsearch/fields.d.ts +3 -3
- package/operations/entry/elasticsearch/fields.js +110 -24
- package/operations/entry/elasticsearch/fields.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/applyFiltering.d.ts +2 -2
- package/operations/entry/elasticsearch/filtering/applyFiltering.js +10 -17
- package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/exec.d.ts +7 -6
- package/operations/entry/elasticsearch/filtering/exec.js +48 -45
- package/operations/entry/elasticsearch/filtering/exec.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/index.d.ts +1 -1
- package/operations/entry/elasticsearch/filtering/index.js +1 -16
- package/operations/entry/elasticsearch/filtering/index.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/path.d.ts +2 -1
- package/operations/entry/elasticsearch/filtering/path.js +9 -17
- package/operations/entry/elasticsearch/filtering/path.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.d.ts +1 -1
- package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js +6 -14
- package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/plugins/index.d.ts +1 -1
- package/operations/entry/elasticsearch/filtering/plugins/index.js +5 -12
- package/operations/entry/elasticsearch/filtering/plugins/index.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.d.ts +1 -1
- package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js +7 -15
- package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.d.ts +1 -1
- package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js +15 -16
- package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/populated.d.ts +1 -1
- package/operations/entry/elasticsearch/filtering/populated.js +1 -8
- package/operations/entry/elasticsearch/filtering/populated.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/values.d.ts +1 -1
- package/operations/entry/elasticsearch/filtering/values.js +4 -12
- package/operations/entry/elasticsearch/filtering/values.js.map +1 -1
- package/operations/entry/elasticsearch/fullTextSearch.d.ts +3 -3
- package/operations/entry/elasticsearch/fullTextSearch.js +6 -12
- package/operations/entry/elasticsearch/fullTextSearch.js.map +1 -1
- package/operations/entry/elasticsearch/fullTextSearchFields.d.ts +1 -1
- package/operations/entry/elasticsearch/fullTextSearchFields.js +1 -8
- package/operations/entry/elasticsearch/fullTextSearchFields.js.map +1 -1
- package/operations/entry/elasticsearch/initialQuery.d.ts +2 -2
- package/operations/entry/elasticsearch/initialQuery.js +9 -26
- package/operations/entry/elasticsearch/initialQuery.js.map +1 -1
- package/operations/entry/elasticsearch/keyword.d.ts +1 -1
- package/operations/entry/elasticsearch/keyword.js +4 -9
- package/operations/entry/elasticsearch/keyword.js.map +1 -1
- package/operations/entry/elasticsearch/plugins/bodyModifier.d.ts +4 -4
- package/operations/entry/elasticsearch/plugins/bodyModifier.js +3 -10
- package/operations/entry/elasticsearch/plugins/bodyModifier.js.map +1 -1
- package/operations/entry/elasticsearch/plugins/operator.d.ts +2 -3
- package/operations/entry/elasticsearch/plugins/operator.js +4 -19
- package/operations/entry/elasticsearch/plugins/operator.js.map +1 -1
- package/operations/entry/elasticsearch/plugins/queryModifier.d.ts +4 -4
- package/operations/entry/elasticsearch/plugins/queryModifier.js +3 -10
- package/operations/entry/elasticsearch/plugins/queryModifier.js.map +1 -1
- package/operations/entry/elasticsearch/plugins/search.d.ts +2 -2
- package/operations/entry/elasticsearch/plugins/search.js +5 -13
- package/operations/entry/elasticsearch/plugins/search.js.map +1 -1
- package/operations/entry/elasticsearch/plugins/sortModifier.d.ts +4 -4
- package/operations/entry/elasticsearch/plugins/sortModifier.js +3 -10
- package/operations/entry/elasticsearch/plugins/sortModifier.js.map +1 -1
- package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.d.ts +2 -0
- package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js +6 -0
- package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js.map +1 -0
- package/operations/entry/elasticsearch/sort.d.ts +4 -4
- package/operations/entry/elasticsearch/sort.js +57 -33
- package/operations/entry/elasticsearch/sort.js.map +1 -1
- package/operations/entry/elasticsearch/transformValueForSearch.d.ts +2 -2
- package/operations/entry/elasticsearch/transformValueForSearch.js +4 -9
- package/operations/entry/elasticsearch/transformValueForSearch.js.map +1 -1
- package/operations/entry/elasticsearch/types.d.ts +5 -5
- package/operations/entry/elasticsearch/types.js +1 -5
- package/operations/entry/elasticsearch/types.js.map +1 -1
- package/operations/entry/index.d.ts +7 -6
- package/operations/entry/index.js +634 -735
- package/operations/entry/index.js.map +1 -1
- package/operations/entry/keys.d.ts +31 -1
- package/operations/entry/keys.js +56 -19
- package/operations/entry/keys.js.map +1 -1
- package/operations/entry/recordType.js +3 -12
- package/operations/entry/recordType.js.map +1 -1
- package/operations/entry/transformations/convertEntryKeys.d.ts +6 -6
- package/operations/entry/transformations/convertEntryKeys.js +2 -10
- package/operations/entry/transformations/convertEntryKeys.js.map +1 -1
- package/operations/entry/transformations/index.d.ts +17 -17
- package/operations/entry/transformations/index.js +22 -30
- package/operations/entry/transformations/index.js.map +1 -1
- package/operations/entry/transformations/modifyEntryValues.d.ts +27 -34
- package/operations/entry/transformations/modifyEntryValues.js +1 -8
- package/operations/entry/transformations/modifyEntryValues.js.map +1 -1
- package/operations/entry/transformations/transformEntryKeys.d.ts +8 -8
- package/operations/entry/transformations/transformEntryKeys.js +4 -11
- package/operations/entry/transformations/transformEntryKeys.js.map +1 -1
- package/operations/entry/transformations/transformEntryToIndex.d.ts +7 -7
- package/operations/entry/transformations/transformEntryToIndex.js +3 -10
- package/operations/entry/transformations/transformEntryToIndex.js.map +1 -1
- package/operations/group/index.d.ts +6 -5
- package/operations/group/index.js +39 -73
- package/operations/group/index.js.map +1 -1
- package/operations/model/index.d.ts +4 -4
- package/operations/model/index.js +38 -57
- package/operations/model/index.js.map +1 -1
- package/package.json +29 -41
- package/plugins/CmsElasticsearchModelFieldPlugin.d.ts +1 -1
- package/plugins/CmsElasticsearchModelFieldPlugin.js +2 -8
- package/plugins/CmsElasticsearchModelFieldPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.d.ts +3 -2
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js +3 -11
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.d.ts +2 -2
- package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js +3 -11
- package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchIndexPlugin.js +2 -9
- package/plugins/CmsEntryElasticsearchIndexPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.d.ts +3 -2
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js +3 -11
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.d.ts +3 -2
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js +3 -11
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.d.ts +3 -2
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.js +3 -11
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchValuesModifier.d.ts +12 -12
- package/plugins/CmsEntryElasticsearchValuesModifier.js +4 -12
- package/plugins/CmsEntryElasticsearchValuesModifier.js.map +1 -1
- package/plugins/CmsEntryFilterPlugin.d.ts +3 -3
- package/plugins/CmsEntryFilterPlugin.js +2 -9
- package/plugins/CmsEntryFilterPlugin.js.map +1 -1
- package/plugins/index.d.ts +8 -8
- package/plugins/index.js +8 -93
- package/plugins/index.js.map +1 -1
- package/tasks/createIndexTaskPlugin.d.ts +2 -2
- package/tasks/createIndexTaskPlugin.js +36 -62
- package/tasks/createIndexTaskPlugin.js.map +1 -1
- package/types.d.ts +28 -33
- package/types.js +5 -8
- package/types.js.map +1 -1
- package/values/NoValueContainer.d.ts +5 -0
- package/values/NoValueContainer.js +13 -0
- package/values/NoValueContainer.js.map +1 -0
- package/definitions/entryElasticsearch.d.ts +0 -8
- package/definitions/entryElasticsearch.js +0 -38
- package/definitions/entryElasticsearch.js.map +0 -1
- package/definitions/system.d.ts +0 -8
- package/definitions/system.js +0 -42
- package/definitions/system.js.map +0 -1
- package/definitions/table.d.ts +0 -8
- package/definitions/table.js +0 -25
- package/definitions/table.js.map +0 -1
- package/definitions/tableElasticsearch.d.ts +0 -8
- package/definitions/tableElasticsearch.js +0 -25
- package/definitions/tableElasticsearch.js.map +0 -1
- package/dynamoDb/storage/date.d.ts +0 -3
- package/dynamoDb/storage/date.js +0 -84
- package/dynamoDb/storage/date.js.map +0 -1
- package/elasticsearch/indices/japanese.d.ts +0 -2
- package/elasticsearch/indices/japanese.js +0 -14
- package/elasticsearch/indices/japanese.js.map +0 -1
- package/operations/system/index.d.ts +0 -6
- package/operations/system/index.js +0 -94
- package/operations/system/index.js.map +0 -1
- package/operations/system/indexes.d.ts +0 -10
- package/operations/system/indexes.js +0 -41
- package/operations/system/indexes.js.map +0 -1
|
@@ -1,43 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const IGNORED_ES_SEARCH_EXCEPTIONS = ["index_not_found_exception", "search_phase_execution_exception"];
|
|
28
|
-
const shouldIgnoreElasticsearchException = ex => {
|
|
29
|
-
if (IGNORED_ES_SEARCH_EXCEPTIONS.includes(ex.message)) {
|
|
30
|
-
console.log(`Ignoring Elasticsearch exception: ${ex.message}`);
|
|
31
|
-
console.log({
|
|
32
|
-
code: ex.code,
|
|
33
|
-
data: ex.data,
|
|
34
|
-
stack: ex.stack
|
|
35
|
-
});
|
|
36
|
-
return true;
|
|
37
|
-
}
|
|
38
|
-
return false;
|
|
1
|
+
import WebinyError from "@webiny/error";
|
|
2
|
+
import { CONTENT_ENTRY_STATUS } from "@webiny/api-headless-cms/types/index.js";
|
|
3
|
+
import { extractEntriesFromIndex } from "../../helpers/index.js";
|
|
4
|
+
import { configurations } from "../../configurations.js";
|
|
5
|
+
import { DataLoadersHandler } from "./dataLoaders.js";
|
|
6
|
+
import { createEntryLatestKeys, createEntryPublishedKeys, createEntryRevisionKeys, createLatestSortKey, createPartitionKey, createPublishedSortKey, createRevisionSortKey } from "./keys.js";
|
|
7
|
+
import { compress, createLimit, decodeCursor, decompress, encodeCursor } from "@webiny/api-elasticsearch";
|
|
8
|
+
import { createElasticsearchBody } from "./elasticsearch/body.js";
|
|
9
|
+
import { shouldIgnoreEsResponseError } from "./elasticsearch/shouldIgnoreEsResponseError.js";
|
|
10
|
+
import { StorageOperationsCmsModelPlugin } from "@webiny/api-headless-cms";
|
|
11
|
+
import { createTransformer } from "./transformations/index.js";
|
|
12
|
+
import { convertEntryKeysFromStorage } from "./transformations/convertEntryKeys.js";
|
|
13
|
+
import { isDeletedEntryMetaField, isEntryLevelEntryMetaField, isRestoredEntryMetaField, pickEntryMetaFields } from "@webiny/api-headless-cms/constants.js";
|
|
14
|
+
const convertToStorageEntry = params => {
|
|
15
|
+
const {
|
|
16
|
+
model,
|
|
17
|
+
storageEntry
|
|
18
|
+
} = params;
|
|
19
|
+
const values = model.convertValueKeyToStorage({
|
|
20
|
+
fields: model.fields,
|
|
21
|
+
values: storageEntry.values
|
|
22
|
+
});
|
|
23
|
+
return {
|
|
24
|
+
...storageEntry,
|
|
25
|
+
values
|
|
26
|
+
};
|
|
39
27
|
};
|
|
40
|
-
const createEntriesStorageOperations = params => {
|
|
28
|
+
export const createEntriesStorageOperations = params => {
|
|
41
29
|
const {
|
|
42
30
|
entity,
|
|
43
31
|
esEntity,
|
|
@@ -49,14 +37,14 @@ const createEntriesStorageOperations = params => {
|
|
|
49
37
|
if (storageOperationsCmsModelPlugin) {
|
|
50
38
|
return storageOperationsCmsModelPlugin;
|
|
51
39
|
}
|
|
52
|
-
storageOperationsCmsModelPlugin = plugins.oneByType(
|
|
40
|
+
storageOperationsCmsModelPlugin = plugins.oneByType(StorageOperationsCmsModelPlugin.type);
|
|
53
41
|
return storageOperationsCmsModelPlugin;
|
|
54
42
|
};
|
|
55
43
|
const getStorageOperationsModel = model => {
|
|
56
44
|
const plugin = getStorageOperationsCmsModelPlugin();
|
|
57
45
|
return plugin.getModel(model);
|
|
58
46
|
};
|
|
59
|
-
const dataLoaders = new
|
|
47
|
+
const dataLoaders = new DataLoadersHandler({
|
|
60
48
|
entity
|
|
61
49
|
});
|
|
62
50
|
const create = async (initialModel, params) => {
|
|
@@ -69,7 +57,7 @@ const createEntriesStorageOperations = params => {
|
|
|
69
57
|
const locked = isPublished ? true : initialEntry.locked;
|
|
70
58
|
initialEntry.locked = locked;
|
|
71
59
|
initialStorageEntry.locked = locked;
|
|
72
|
-
const transformer =
|
|
60
|
+
const transformer = createTransformer({
|
|
73
61
|
plugins,
|
|
74
62
|
model,
|
|
75
63
|
entry: initialEntry,
|
|
@@ -82,88 +70,68 @@ const createEntriesStorageOperations = params => {
|
|
|
82
70
|
const esEntry = transformer.transformToIndex();
|
|
83
71
|
const {
|
|
84
72
|
index: esIndex
|
|
85
|
-
} =
|
|
73
|
+
} = configurations.es({
|
|
86
74
|
model
|
|
87
75
|
});
|
|
88
|
-
const revisionKeys =
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
id: entry.id,
|
|
107
|
-
locale: model.locale,
|
|
108
|
-
tenant: model.tenant
|
|
109
|
-
}),
|
|
110
|
-
SK: (0, _keys.createPublishedSortKey)()
|
|
111
|
-
};
|
|
112
|
-
const items = [entity.putBatch({
|
|
113
|
-
...storageEntry,
|
|
114
|
-
locked,
|
|
115
|
-
...revisionKeys,
|
|
116
|
-
TYPE: (0, _recordType.createRecordType)()
|
|
117
|
-
}), entity.putBatch({
|
|
118
|
-
...storageEntry,
|
|
119
|
-
locked,
|
|
120
|
-
...latestKeys,
|
|
121
|
-
TYPE: (0, _recordType.createLatestRecordType)()
|
|
122
|
-
})];
|
|
76
|
+
const revisionKeys = createEntryRevisionKeys(entry);
|
|
77
|
+
const latestKeys = createEntryLatestKeys(entry);
|
|
78
|
+
const publishedKeys = createEntryPublishedKeys(entry);
|
|
79
|
+
const entityBatch = entity.createEntityWriter({
|
|
80
|
+
put: [{
|
|
81
|
+
...revisionKeys,
|
|
82
|
+
data: {
|
|
83
|
+
...storageEntry,
|
|
84
|
+
locked
|
|
85
|
+
}
|
|
86
|
+
}, {
|
|
87
|
+
...latestKeys,
|
|
88
|
+
data: {
|
|
89
|
+
...storageEntry,
|
|
90
|
+
locked
|
|
91
|
+
}
|
|
92
|
+
}]
|
|
93
|
+
});
|
|
123
94
|
if (isPublished) {
|
|
124
|
-
|
|
125
|
-
...storageEntry,
|
|
126
|
-
locked,
|
|
95
|
+
entityBatch.put({
|
|
127
96
|
...publishedKeys,
|
|
128
|
-
|
|
129
|
-
|
|
97
|
+
data: {
|
|
98
|
+
...storageEntry,
|
|
99
|
+
locked
|
|
100
|
+
}
|
|
101
|
+
});
|
|
130
102
|
}
|
|
131
103
|
try {
|
|
132
|
-
await (
|
|
133
|
-
table: entity.table,
|
|
134
|
-
items
|
|
135
|
-
});
|
|
104
|
+
await entityBatch.execute();
|
|
136
105
|
dataLoaders.clearAll({
|
|
137
106
|
model
|
|
138
107
|
});
|
|
139
108
|
} catch (ex) {
|
|
140
|
-
throw new
|
|
109
|
+
throw new WebinyError(ex.message || "Could not insert entry data into the DynamoDB table.", ex.code || "CREATE_ENTRY_ERROR", {
|
|
141
110
|
error: ex,
|
|
142
111
|
entry,
|
|
143
112
|
storageEntry
|
|
144
113
|
});
|
|
145
114
|
}
|
|
146
115
|
const esLatestData = await transformer.getElasticsearchLatestEntryData();
|
|
147
|
-
const
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
116
|
+
const elasticsearchEntityBatch = esEntity.createEntityWriter({
|
|
117
|
+
put: [{
|
|
118
|
+
...latestKeys,
|
|
119
|
+
index: esIndex,
|
|
120
|
+
data: esLatestData
|
|
121
|
+
}]
|
|
122
|
+
});
|
|
152
123
|
if (isPublished) {
|
|
153
124
|
const esPublishedData = await transformer.getElasticsearchPublishedEntryData();
|
|
154
|
-
|
|
125
|
+
elasticsearchEntityBatch.put({
|
|
155
126
|
...publishedKeys,
|
|
156
127
|
index: esIndex,
|
|
157
128
|
data: esPublishedData
|
|
158
|
-
})
|
|
129
|
+
});
|
|
159
130
|
}
|
|
160
131
|
try {
|
|
161
|
-
await (
|
|
162
|
-
table: esEntity.table,
|
|
163
|
-
items: esItems
|
|
164
|
-
});
|
|
132
|
+
await elasticsearchEntityBatch.execute();
|
|
165
133
|
} catch (ex) {
|
|
166
|
-
throw new
|
|
134
|
+
throw new WebinyError(ex.message || "Could not insert entry data into the Elasticsearch DynamoDB table.", ex.code || "CREATE_ES_ENTRY_ERROR", {
|
|
167
135
|
error: ex,
|
|
168
136
|
entry,
|
|
169
137
|
esEntry
|
|
@@ -177,7 +145,7 @@ const createEntriesStorageOperations = params => {
|
|
|
177
145
|
storageEntry: initialStorageEntry
|
|
178
146
|
} = params;
|
|
179
147
|
const model = getStorageOperationsModel(initialModel);
|
|
180
|
-
const transformer =
|
|
148
|
+
const transformer = createTransformer({
|
|
181
149
|
plugins,
|
|
182
150
|
model,
|
|
183
151
|
entry: initialEntry,
|
|
@@ -187,66 +155,80 @@ const createEntriesStorageOperations = params => {
|
|
|
187
155
|
entry,
|
|
188
156
|
storageEntry
|
|
189
157
|
} = transformer.transformEntryKeys();
|
|
190
|
-
const revisionKeys =
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
SK: (0, _keys.createRevisionSortKey)(entry)
|
|
197
|
-
};
|
|
198
|
-
const latestKeys = {
|
|
199
|
-
PK: (0, _keys.createPartitionKey)({
|
|
200
|
-
id: entry.id,
|
|
201
|
-
locale: model.locale,
|
|
202
|
-
tenant: model.tenant
|
|
203
|
-
}),
|
|
204
|
-
SK: (0, _keys.createLatestSortKey)()
|
|
205
|
-
};
|
|
158
|
+
const revisionKeys = createEntryRevisionKeys(entry);
|
|
159
|
+
const latestKeys = createEntryLatestKeys(entry);
|
|
160
|
+
const publishedKeys = createEntryPublishedKeys(entry);
|
|
161
|
+
|
|
162
|
+
// We'll need this flag below.
|
|
163
|
+
const isPublished = entry.status === "published";
|
|
206
164
|
const esLatestData = await transformer.getElasticsearchLatestEntryData();
|
|
207
|
-
const
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
})];
|
|
216
|
-
const {
|
|
217
|
-
index
|
|
218
|
-
} = _configurations.configurations.es({
|
|
219
|
-
model
|
|
165
|
+
const entityBatch = entity.createEntityWriter({
|
|
166
|
+
put: [{
|
|
167
|
+
...revisionKeys,
|
|
168
|
+
data: storageEntry
|
|
169
|
+
}, {
|
|
170
|
+
...latestKeys,
|
|
171
|
+
data: storageEntry
|
|
172
|
+
}]
|
|
220
173
|
});
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
174
|
+
if (isPublished) {
|
|
175
|
+
entityBatch.put({
|
|
176
|
+
...publishedKeys,
|
|
177
|
+
data: storageEntry
|
|
225
178
|
});
|
|
179
|
+
|
|
180
|
+
// Unpublish previously published revision (if any).
|
|
181
|
+
const [publishedRevisionStorageEntry] = await dataLoaders.getPublishedRevisionByEntryId({
|
|
182
|
+
model,
|
|
183
|
+
ids: [entry.id]
|
|
184
|
+
});
|
|
185
|
+
if (publishedRevisionStorageEntry) {
|
|
186
|
+
const publishedRevisionKey = createEntryRevisionKeys(publishedRevisionStorageEntry);
|
|
187
|
+
entityBatch.put({
|
|
188
|
+
...publishedRevisionKey,
|
|
189
|
+
data: {
|
|
190
|
+
...publishedRevisionStorageEntry,
|
|
191
|
+
status: CONTENT_ENTRY_STATUS.UNPUBLISHED
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
try {
|
|
197
|
+
await entityBatch.execute();
|
|
226
198
|
dataLoaders.clearAll({
|
|
227
199
|
model
|
|
228
200
|
});
|
|
229
201
|
} catch (ex) {
|
|
230
|
-
throw new
|
|
202
|
+
throw new WebinyError(ex.message || "Could not create revision from given entry in the DynamoDB table.", ex.code || "CREATE_REVISION_ERROR", {
|
|
231
203
|
error: ex,
|
|
232
204
|
entry,
|
|
233
205
|
storageEntry
|
|
234
206
|
});
|
|
235
207
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
208
|
+
const {
|
|
209
|
+
index: esIndex
|
|
210
|
+
} = configurations.es({
|
|
211
|
+
model
|
|
212
|
+
});
|
|
213
|
+
const elasticsearchEntityBatch = esEntity.createEntityWriter({
|
|
214
|
+
put: [{
|
|
215
|
+
...latestKeys,
|
|
216
|
+
index: esIndex,
|
|
217
|
+
data: esLatestData
|
|
218
|
+
}]
|
|
219
|
+
});
|
|
220
|
+
if (isPublished) {
|
|
221
|
+
const esPublishedData = await transformer.getElasticsearchPublishedEntryData();
|
|
222
|
+
elasticsearchEntityBatch.put({
|
|
223
|
+
...publishedKeys,
|
|
224
|
+
index: esIndex,
|
|
225
|
+
data: esPublishedData
|
|
247
226
|
});
|
|
227
|
+
}
|
|
228
|
+
try {
|
|
229
|
+
await elasticsearchEntityBatch.execute();
|
|
248
230
|
} catch (ex) {
|
|
249
|
-
throw new
|
|
231
|
+
throw new WebinyError(ex.message || "Could not update latest entry in the DynamoDB Elasticsearch table.", ex.code || "CREATE_REVISION_ERROR", {
|
|
250
232
|
error: ex,
|
|
251
233
|
entry
|
|
252
234
|
});
|
|
@@ -262,7 +244,7 @@ const createEntriesStorageOperations = params => {
|
|
|
262
244
|
storageEntry: initialStorageEntry
|
|
263
245
|
} = params;
|
|
264
246
|
const model = getStorageOperationsModel(initialModel);
|
|
265
|
-
const transformer =
|
|
247
|
+
const transformer = createTransformer({
|
|
266
248
|
plugins,
|
|
267
249
|
model,
|
|
268
250
|
entry: initialEntry,
|
|
@@ -274,30 +256,9 @@ const createEntriesStorageOperations = params => {
|
|
|
274
256
|
} = transformer.transformEntryKeys();
|
|
275
257
|
const isPublished = entry.status === "published";
|
|
276
258
|
const locked = isPublished ? true : entry.locked;
|
|
277
|
-
const revisionKeys =
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
locale: model.locale,
|
|
281
|
-
tenant: model.tenant
|
|
282
|
-
}),
|
|
283
|
-
SK: (0, _keys.createRevisionSortKey)(entry)
|
|
284
|
-
};
|
|
285
|
-
const latestKeys = {
|
|
286
|
-
PK: (0, _keys.createPartitionKey)({
|
|
287
|
-
id: entry.id,
|
|
288
|
-
locale: model.locale,
|
|
289
|
-
tenant: model.tenant
|
|
290
|
-
}),
|
|
291
|
-
SK: (0, _keys.createLatestSortKey)()
|
|
292
|
-
};
|
|
293
|
-
const publishedKeys = {
|
|
294
|
-
PK: (0, _keys.createPartitionKey)({
|
|
295
|
-
id: entry.id,
|
|
296
|
-
locale: model.locale,
|
|
297
|
-
tenant: model.tenant
|
|
298
|
-
}),
|
|
299
|
-
SK: (0, _keys.createPublishedSortKey)()
|
|
300
|
-
};
|
|
259
|
+
const revisionKeys = createEntryRevisionKeys(entry);
|
|
260
|
+
const latestKeys = createEntryLatestKeys(entry);
|
|
261
|
+
const publishedKeys = createEntryPublishedKeys(entry);
|
|
301
262
|
|
|
302
263
|
/**
|
|
303
264
|
* We need the latest entry to check if it needs to be updated.
|
|
@@ -310,24 +271,28 @@ const createEntriesStorageOperations = params => {
|
|
|
310
271
|
model,
|
|
311
272
|
ids: [entry.id]
|
|
312
273
|
});
|
|
313
|
-
const
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
274
|
+
const entityBatch = entity.createEntityWriter({
|
|
275
|
+
put: [{
|
|
276
|
+
...revisionKeys,
|
|
277
|
+
data: {
|
|
278
|
+
...storageEntry,
|
|
279
|
+
locked
|
|
280
|
+
}
|
|
281
|
+
}]
|
|
282
|
+
});
|
|
319
283
|
if (isPublished) {
|
|
320
|
-
|
|
321
|
-
...storageEntry,
|
|
322
|
-
locked,
|
|
284
|
+
entityBatch.put({
|
|
323
285
|
...publishedKeys,
|
|
324
|
-
|
|
325
|
-
|
|
286
|
+
data: {
|
|
287
|
+
...storageEntry,
|
|
288
|
+
locked
|
|
289
|
+
}
|
|
290
|
+
});
|
|
326
291
|
}
|
|
327
|
-
const
|
|
292
|
+
const elasticsearchEntityBatch = esEntity.createEntityWriter();
|
|
328
293
|
const {
|
|
329
294
|
index: esIndex
|
|
330
|
-
} =
|
|
295
|
+
} = configurations.es({
|
|
331
296
|
model
|
|
332
297
|
});
|
|
333
298
|
|
|
@@ -340,31 +305,32 @@ const createEntriesStorageOperations = params => {
|
|
|
340
305
|
/**
|
|
341
306
|
* First we update the regular DynamoDB table.
|
|
342
307
|
*/
|
|
343
|
-
|
|
344
|
-
...storageEntry,
|
|
308
|
+
entityBatch.put({
|
|
345
309
|
...latestKeys,
|
|
346
|
-
|
|
347
|
-
})
|
|
310
|
+
data: storageEntry
|
|
311
|
+
});
|
|
348
312
|
|
|
349
313
|
/**
|
|
350
314
|
* And then update the Elasticsearch table to propagate changes to the Elasticsearch
|
|
351
315
|
*/
|
|
352
316
|
const elasticsearchLatestData = await transformer.getElasticsearchLatestEntryData();
|
|
353
|
-
|
|
317
|
+
elasticsearchEntityBatch.put({
|
|
354
318
|
...latestKeys,
|
|
355
319
|
index: esIndex,
|
|
356
320
|
data: elasticsearchLatestData
|
|
357
|
-
})
|
|
321
|
+
});
|
|
358
322
|
} else {
|
|
359
323
|
/**
|
|
360
324
|
* If not updating latest revision, we still want to update the latest revision's
|
|
361
325
|
* entry-level meta fields to match the current revision's entry-level meta fields.
|
|
362
326
|
*/
|
|
363
|
-
const updatedEntryLevelMetaFields =
|
|
327
|
+
const updatedEntryLevelMetaFields = pickEntryMetaFields(entry, isEntryLevelEntryMetaField);
|
|
364
328
|
const updatedLatestStorageEntry = {
|
|
365
|
-
...latestStorageEntry,
|
|
366
329
|
...latestKeys,
|
|
367
|
-
|
|
330
|
+
data: {
|
|
331
|
+
...latestStorageEntry,
|
|
332
|
+
...updatedEntryLevelMetaFields
|
|
333
|
+
}
|
|
368
334
|
};
|
|
369
335
|
|
|
370
336
|
/**
|
|
@@ -372,75 +338,60 @@ const createEntriesStorageOperations = params => {
|
|
|
372
338
|
* - one for the actual revision record
|
|
373
339
|
* - one for the latest record
|
|
374
340
|
*/
|
|
375
|
-
|
|
341
|
+
entityBatch.put({
|
|
376
342
|
...updatedLatestStorageEntry,
|
|
377
|
-
PK:
|
|
343
|
+
PK: createPartitionKey({
|
|
378
344
|
id: latestStorageEntry.id,
|
|
379
|
-
locale: model.locale,
|
|
380
345
|
tenant: model.tenant
|
|
381
346
|
}),
|
|
382
|
-
SK:
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
TYPE: (0, _recordType.createLatestRecordType)()
|
|
388
|
-
}));
|
|
347
|
+
SK: createRevisionSortKey(latestStorageEntry)
|
|
348
|
+
});
|
|
349
|
+
entityBatch.put({
|
|
350
|
+
...updatedLatestStorageEntry
|
|
351
|
+
});
|
|
389
352
|
|
|
390
353
|
/**
|
|
391
354
|
* Update the Elasticsearch table to propagate changes to the Elasticsearch.
|
|
392
355
|
*/
|
|
393
|
-
const latestEsEntry = await
|
|
394
|
-
entity: esEntity,
|
|
395
|
-
keys: latestKeys
|
|
396
|
-
});
|
|
356
|
+
const latestEsEntry = await esEntity.getClean(latestKeys);
|
|
397
357
|
if (latestEsEntry) {
|
|
398
|
-
const latestEsEntryDataDecompressed = await
|
|
399
|
-
const updatedLatestEntry = await
|
|
358
|
+
const latestEsEntryDataDecompressed = await decompress(plugins, latestEsEntry.data);
|
|
359
|
+
const updatedLatestEntry = await compress(plugins, {
|
|
400
360
|
...latestEsEntryDataDecompressed,
|
|
401
361
|
...updatedEntryLevelMetaFields
|
|
402
362
|
});
|
|
403
|
-
|
|
363
|
+
elasticsearchEntityBatch.put({
|
|
404
364
|
...latestKeys,
|
|
405
365
|
index: esIndex,
|
|
406
366
|
data: updatedLatestEntry
|
|
407
|
-
})
|
|
367
|
+
});
|
|
408
368
|
}
|
|
409
369
|
}
|
|
410
370
|
}
|
|
411
371
|
if (isPublished && publishedStorageEntry?.id === entry.id) {
|
|
412
372
|
const elasticsearchPublishedData = await transformer.getElasticsearchPublishedEntryData();
|
|
413
|
-
|
|
373
|
+
elasticsearchEntityBatch.put({
|
|
414
374
|
...publishedKeys,
|
|
415
375
|
index: esIndex,
|
|
416
376
|
data: elasticsearchPublishedData
|
|
417
|
-
})
|
|
377
|
+
});
|
|
418
378
|
}
|
|
419
379
|
try {
|
|
420
|
-
await (
|
|
421
|
-
table: entity.table,
|
|
422
|
-
items
|
|
423
|
-
});
|
|
380
|
+
await entityBatch.execute();
|
|
424
381
|
dataLoaders.clearAll({
|
|
425
382
|
model
|
|
426
383
|
});
|
|
427
384
|
} catch (ex) {
|
|
428
|
-
throw new
|
|
385
|
+
throw new WebinyError(ex.message || "Could not update entry DynamoDB records.", ex.code || "UPDATE_ENTRY_ERROR", {
|
|
429
386
|
error: ex,
|
|
430
387
|
entry,
|
|
431
388
|
storageEntry
|
|
432
389
|
});
|
|
433
390
|
}
|
|
434
|
-
if (esItems.length === 0) {
|
|
435
|
-
return initialStorageEntry;
|
|
436
|
-
}
|
|
437
391
|
try {
|
|
438
|
-
await (
|
|
439
|
-
table: esEntity.table,
|
|
440
|
-
items: esItems
|
|
441
|
-
});
|
|
392
|
+
await elasticsearchEntityBatch.execute();
|
|
442
393
|
} catch (ex) {
|
|
443
|
-
throw new
|
|
394
|
+
throw new WebinyError(ex.message || "Could not update entry DynamoDB Elasticsearch records.", ex.code || "UPDATE_ES_ENTRY_ERROR", {
|
|
444
395
|
error: ex,
|
|
445
396
|
entry
|
|
446
397
|
});
|
|
@@ -449,113 +400,107 @@ const createEntriesStorageOperations = params => {
|
|
|
449
400
|
};
|
|
450
401
|
const move = async (initialModel, id, folderId) => {
|
|
451
402
|
const model = getStorageOperationsModel(initialModel);
|
|
452
|
-
const partitionKey =
|
|
403
|
+
const partitionKey = createPartitionKey({
|
|
453
404
|
id,
|
|
454
|
-
locale: model.locale,
|
|
455
405
|
tenant: model.tenant
|
|
456
406
|
});
|
|
457
407
|
/**
|
|
458
408
|
* First we need to fetch all the records in the regular DynamoDB table.
|
|
459
409
|
*/
|
|
460
410
|
const queryAllParams = {
|
|
461
|
-
entity,
|
|
462
411
|
partitionKey,
|
|
463
412
|
options: {
|
|
464
413
|
gte: " "
|
|
465
414
|
}
|
|
466
415
|
};
|
|
467
|
-
const latestSortKey =
|
|
468
|
-
const publishedSortKey =
|
|
469
|
-
const records = await
|
|
416
|
+
const latestSortKey = createLatestSortKey();
|
|
417
|
+
const publishedSortKey = createPublishedSortKey();
|
|
418
|
+
const records = await entity.queryAll(queryAllParams);
|
|
470
419
|
/**
|
|
471
420
|
* Then update the folderId in each record and prepare it to be stored.
|
|
472
421
|
*/
|
|
473
422
|
let latestRecord = undefined;
|
|
474
423
|
let publishedRecord = undefined;
|
|
475
|
-
const
|
|
424
|
+
const entityBatch = entity.createEntityWriter();
|
|
476
425
|
for (const record of records) {
|
|
477
|
-
|
|
426
|
+
entityBatch.put({
|
|
478
427
|
...record,
|
|
479
|
-
|
|
480
|
-
...record
|
|
481
|
-
|
|
428
|
+
data: {
|
|
429
|
+
...record.data,
|
|
430
|
+
location: {
|
|
431
|
+
...record.data.location,
|
|
432
|
+
folderId
|
|
433
|
+
}
|
|
482
434
|
}
|
|
483
|
-
})
|
|
435
|
+
});
|
|
436
|
+
|
|
484
437
|
/**
|
|
485
438
|
* We need to get the published and latest records, so we can update the Elasticsearch.
|
|
486
439
|
*/
|
|
487
440
|
if (record.SK === publishedSortKey) {
|
|
488
|
-
publishedRecord = record;
|
|
441
|
+
publishedRecord = record.data;
|
|
489
442
|
} else if (record.SK === latestSortKey) {
|
|
490
|
-
latestRecord = record;
|
|
443
|
+
latestRecord = record.data;
|
|
491
444
|
}
|
|
492
445
|
}
|
|
493
446
|
try {
|
|
494
|
-
await (
|
|
495
|
-
table: entity.table,
|
|
496
|
-
items
|
|
497
|
-
});
|
|
447
|
+
await entityBatch.execute();
|
|
498
448
|
dataLoaders.clearAll({
|
|
499
449
|
model
|
|
500
450
|
});
|
|
501
451
|
} catch (ex) {
|
|
502
|
-
throw new
|
|
452
|
+
throw new WebinyError(ex.message || "Could not move all entry records from in the DynamoDB table.", ex.code || "MOVE_ENTRY_ERROR", {
|
|
503
453
|
error: ex,
|
|
504
454
|
id
|
|
505
455
|
});
|
|
506
456
|
}
|
|
507
|
-
const
|
|
457
|
+
const esEntityReader = esEntity.createEntityReader();
|
|
508
458
|
if (publishedRecord) {
|
|
509
|
-
|
|
459
|
+
esEntityReader.get({
|
|
510
460
|
PK: partitionKey,
|
|
511
461
|
SK: publishedSortKey
|
|
512
|
-
})
|
|
462
|
+
});
|
|
513
463
|
}
|
|
514
464
|
if (latestRecord) {
|
|
515
|
-
|
|
465
|
+
esEntityReader.get({
|
|
516
466
|
PK: partitionKey,
|
|
517
467
|
SK: latestSortKey
|
|
518
|
-
})
|
|
468
|
+
});
|
|
519
469
|
}
|
|
520
|
-
if (
|
|
470
|
+
if (esEntityReader.total === 0) {
|
|
521
471
|
return;
|
|
522
472
|
}
|
|
523
|
-
const esRecords = await (
|
|
524
|
-
table: esEntity.table,
|
|
525
|
-
items: esGetItems
|
|
526
|
-
});
|
|
473
|
+
const esRecords = await esEntityReader.execute();
|
|
527
474
|
const esItems = (await Promise.all(esRecords.map(async record => {
|
|
528
475
|
if (!record) {
|
|
529
476
|
return null;
|
|
530
477
|
}
|
|
531
478
|
return {
|
|
532
479
|
...record,
|
|
533
|
-
data: await
|
|
480
|
+
data: await decompress(plugins, record.data)
|
|
534
481
|
};
|
|
535
|
-
}))).filter(
|
|
482
|
+
}))).filter(item => !!item);
|
|
536
483
|
if (esItems.length === 0) {
|
|
537
484
|
return;
|
|
538
485
|
}
|
|
539
|
-
const esUpdateItems = [];
|
|
540
|
-
for (const item of esItems) {
|
|
541
|
-
esUpdateItems.push(esEntity.putBatch({
|
|
542
|
-
...item,
|
|
543
|
-
data: await (0, _apiElasticsearch.compress)(plugins, {
|
|
544
|
-
...item.data,
|
|
545
|
-
location: {
|
|
546
|
-
...item.data?.location,
|
|
547
|
-
folderId
|
|
548
|
-
}
|
|
549
|
-
})
|
|
550
|
-
}));
|
|
551
|
-
}
|
|
552
486
|
try {
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
487
|
+
const elasticsearchEntityBatch = esEntity.createEntityWriter({
|
|
488
|
+
put: await Promise.all(esItems.map(async item => {
|
|
489
|
+
return {
|
|
490
|
+
...item,
|
|
491
|
+
data: await compress(plugins, {
|
|
492
|
+
...item.data,
|
|
493
|
+
location: {
|
|
494
|
+
...item.data?.location,
|
|
495
|
+
folderId
|
|
496
|
+
}
|
|
497
|
+
})
|
|
498
|
+
};
|
|
499
|
+
}))
|
|
500
|
+
});
|
|
501
|
+
await elasticsearchEntityBatch.execute();
|
|
557
502
|
} catch (ex) {
|
|
558
|
-
throw new
|
|
503
|
+
throw new WebinyError(ex.message || "Could not move entry DynamoDB Elasticsearch records.", ex.code || "MOVE_ES_ENTRY_ERROR", {
|
|
559
504
|
error: ex,
|
|
560
505
|
partitionKey
|
|
561
506
|
});
|
|
@@ -567,7 +512,7 @@ const createEntriesStorageOperations = params => {
|
|
|
567
512
|
storageEntry: initialStorageEntry
|
|
568
513
|
} = params;
|
|
569
514
|
const model = getStorageOperationsModel(initialModel);
|
|
570
|
-
const transformer =
|
|
515
|
+
const transformer = createTransformer({
|
|
571
516
|
plugins,
|
|
572
517
|
model,
|
|
573
518
|
entry: initialEntry,
|
|
@@ -577,9 +522,8 @@ const createEntriesStorageOperations = params => {
|
|
|
577
522
|
entry,
|
|
578
523
|
storageEntry
|
|
579
524
|
} = transformer.transformEntryKeys();
|
|
580
|
-
const partitionKey =
|
|
525
|
+
const partitionKey = createPartitionKey({
|
|
581
526
|
id: entry.id,
|
|
582
|
-
locale: model.locale,
|
|
583
527
|
tenant: model.tenant
|
|
584
528
|
});
|
|
585
529
|
|
|
@@ -587,42 +531,45 @@ const createEntriesStorageOperations = params => {
|
|
|
587
531
|
* First we need to fetch all the records in the regular DynamoDB table.
|
|
588
532
|
*/
|
|
589
533
|
const queryAllParams = {
|
|
590
|
-
entity,
|
|
591
534
|
partitionKey,
|
|
592
535
|
options: {
|
|
593
536
|
gte: " "
|
|
594
537
|
}
|
|
595
538
|
};
|
|
596
|
-
const latestSortKey =
|
|
597
|
-
const publishedSortKey =
|
|
598
|
-
const records = await
|
|
539
|
+
const latestSortKey = createLatestSortKey();
|
|
540
|
+
const publishedSortKey = createPublishedSortKey();
|
|
541
|
+
const records = await entity.queryAll(queryAllParams);
|
|
599
542
|
|
|
600
543
|
/**
|
|
601
544
|
* Let's pick the `deleted` meta fields from the entry.
|
|
602
545
|
*/
|
|
603
|
-
const updatedEntryMetaFields =
|
|
546
|
+
const updatedEntryMetaFields = pickEntryMetaFields(entry, isDeletedEntryMetaField);
|
|
604
547
|
|
|
605
548
|
/**
|
|
606
549
|
* Then update all the records with data received.
|
|
607
550
|
*/
|
|
608
551
|
let latestRecord = undefined;
|
|
609
552
|
let publishedRecord = undefined;
|
|
610
|
-
const
|
|
553
|
+
const entityBatch = entity.createEntityWriter();
|
|
611
554
|
for (const record of records) {
|
|
612
|
-
|
|
555
|
+
entityBatch.put({
|
|
613
556
|
...record,
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
557
|
+
data: {
|
|
558
|
+
...record.data,
|
|
559
|
+
...updatedEntryMetaFields,
|
|
560
|
+
wbyDeleted: storageEntry.wbyDeleted,
|
|
561
|
+
location: storageEntry.location,
|
|
562
|
+
binOriginalFolderId: storageEntry.binOriginalFolderId
|
|
563
|
+
}
|
|
564
|
+
});
|
|
565
|
+
|
|
619
566
|
/**
|
|
620
567
|
* We need to get the published and latest records, so we can update the Elasticsearch.
|
|
621
568
|
*/
|
|
622
569
|
if (record.SK === publishedSortKey) {
|
|
623
|
-
publishedRecord = record;
|
|
570
|
+
publishedRecord = record.data;
|
|
624
571
|
} else if (record.SK === latestSortKey) {
|
|
625
|
-
latestRecord = record;
|
|
572
|
+
latestRecord = record.data;
|
|
626
573
|
}
|
|
627
574
|
}
|
|
628
575
|
|
|
@@ -630,15 +577,12 @@ const createEntriesStorageOperations = params => {
|
|
|
630
577
|
* We write the records back to the primary DynamoDB table.
|
|
631
578
|
*/
|
|
632
579
|
try {
|
|
633
|
-
await (
|
|
634
|
-
table: entity.table,
|
|
635
|
-
items
|
|
636
|
-
});
|
|
580
|
+
await entityBatch.execute();
|
|
637
581
|
dataLoaders.clearAll({
|
|
638
582
|
model
|
|
639
583
|
});
|
|
640
584
|
} catch (ex) {
|
|
641
|
-
throw new
|
|
585
|
+
throw new WebinyError(ex.message || "Could mark as deleted all entry records from in the DynamoDB table.", ex.code || "MOVE_ENTRY_TO_BIN_ERROR", {
|
|
642
586
|
error: ex,
|
|
643
587
|
entry,
|
|
644
588
|
storageEntry
|
|
@@ -648,35 +592,32 @@ const createEntriesStorageOperations = params => {
|
|
|
648
592
|
/**
|
|
649
593
|
* We need to get the published and latest records from Elasticsearch.
|
|
650
594
|
*/
|
|
651
|
-
const
|
|
595
|
+
const esEntityReader = esEntity.createEntityReader();
|
|
652
596
|
if (publishedRecord) {
|
|
653
|
-
|
|
597
|
+
esEntityReader.get({
|
|
654
598
|
PK: partitionKey,
|
|
655
599
|
SK: publishedSortKey
|
|
656
|
-
})
|
|
600
|
+
});
|
|
657
601
|
}
|
|
658
602
|
if (latestRecord) {
|
|
659
|
-
|
|
603
|
+
esEntityReader.get({
|
|
660
604
|
PK: partitionKey,
|
|
661
605
|
SK: latestSortKey
|
|
662
|
-
})
|
|
606
|
+
});
|
|
663
607
|
}
|
|
664
|
-
if (
|
|
608
|
+
if (esEntityReader.total === 0) {
|
|
665
609
|
return;
|
|
666
610
|
}
|
|
667
|
-
const esRecords = await (
|
|
668
|
-
table: esEntity.table,
|
|
669
|
-
items: esGetItems
|
|
670
|
-
});
|
|
611
|
+
const esRecords = await esEntityReader.execute();
|
|
671
612
|
const esItems = (await Promise.all(esRecords.map(async record => {
|
|
672
613
|
if (!record) {
|
|
673
614
|
return null;
|
|
674
615
|
}
|
|
675
616
|
return {
|
|
676
617
|
...record,
|
|
677
|
-
data: await
|
|
618
|
+
data: await decompress(plugins, record.data)
|
|
678
619
|
};
|
|
679
|
-
}))).filter(
|
|
620
|
+
}))).filter(item => !!item);
|
|
680
621
|
if (esItems.length === 0) {
|
|
681
622
|
return;
|
|
682
623
|
}
|
|
@@ -684,30 +625,27 @@ const createEntriesStorageOperations = params => {
|
|
|
684
625
|
/**
|
|
685
626
|
* We update all ES records with data received.
|
|
686
627
|
*/
|
|
687
|
-
const
|
|
628
|
+
const elasticsearchEntityBatch = esEntity.createEntityWriter();
|
|
688
629
|
for (const item of esItems) {
|
|
689
|
-
|
|
630
|
+
elasticsearchEntityBatch.put({
|
|
690
631
|
...item,
|
|
691
|
-
data: await
|
|
632
|
+
data: await compress(plugins, {
|
|
692
633
|
...item.data,
|
|
693
634
|
...updatedEntryMetaFields,
|
|
694
635
|
wbyDeleted: entry.wbyDeleted,
|
|
695
636
|
location: entry.location,
|
|
696
637
|
binOriginalFolderId: entry.binOriginalFolderId
|
|
697
638
|
})
|
|
698
|
-
})
|
|
639
|
+
});
|
|
699
640
|
}
|
|
700
641
|
|
|
701
642
|
/**
|
|
702
643
|
* We write the records back to the primary DynamoDB Elasticsearch table.
|
|
703
644
|
*/
|
|
704
645
|
try {
|
|
705
|
-
await (
|
|
706
|
-
table: esEntity.table,
|
|
707
|
-
items: esUpdateItems
|
|
708
|
-
});
|
|
646
|
+
await elasticsearchEntityBatch.execute();
|
|
709
647
|
} catch (ex) {
|
|
710
|
-
throw new
|
|
648
|
+
throw new WebinyError(ex.message || "Could not mark as deleted entry records from DynamoDB Elasticsearch table.", ex.code || "MOVE_ENTRY_TO_BIN_ERROR", {
|
|
711
649
|
error: ex,
|
|
712
650
|
entry,
|
|
713
651
|
storageEntry
|
|
@@ -720,7 +658,7 @@ const createEntriesStorageOperations = params => {
|
|
|
720
658
|
storageEntry: initialStorageEntry
|
|
721
659
|
} = params;
|
|
722
660
|
const model = getStorageOperationsModel(initialModel);
|
|
723
|
-
const transformer =
|
|
661
|
+
const transformer = createTransformer({
|
|
724
662
|
plugins,
|
|
725
663
|
model,
|
|
726
664
|
entry: initialEntry,
|
|
@@ -734,10 +672,9 @@ const createEntriesStorageOperations = params => {
|
|
|
734
672
|
/**
|
|
735
673
|
* Let's pick the `restored` meta fields from the storage entry.
|
|
736
674
|
*/
|
|
737
|
-
const updatedEntryMetaFields =
|
|
738
|
-
const partitionKey =
|
|
675
|
+
const updatedEntryMetaFields = pickEntryMetaFields(entry, isRestoredEntryMetaField);
|
|
676
|
+
const partitionKey = createPartitionKey({
|
|
739
677
|
id: entry.id,
|
|
740
|
-
locale: model.locale,
|
|
741
678
|
tenant: model.tenant
|
|
742
679
|
});
|
|
743
680
|
|
|
@@ -745,37 +682,40 @@ const createEntriesStorageOperations = params => {
|
|
|
745
682
|
* First we need to fetch all the records in the regular DynamoDB table.
|
|
746
683
|
*/
|
|
747
684
|
const queryAllParams = {
|
|
748
|
-
entity,
|
|
749
685
|
partitionKey,
|
|
750
686
|
options: {
|
|
751
687
|
gte: " "
|
|
752
688
|
}
|
|
753
689
|
};
|
|
754
|
-
const latestSortKey =
|
|
755
|
-
const publishedSortKey =
|
|
756
|
-
const records = await
|
|
690
|
+
const latestSortKey = createLatestSortKey();
|
|
691
|
+
const publishedSortKey = createPublishedSortKey();
|
|
692
|
+
const records = await entity.queryAll(queryAllParams);
|
|
757
693
|
|
|
758
694
|
/**
|
|
759
695
|
* Then update all the records with data received.
|
|
760
696
|
*/
|
|
761
697
|
let latestRecord = undefined;
|
|
762
698
|
let publishedRecord = undefined;
|
|
763
|
-
const
|
|
699
|
+
const entityBatch = entity.createEntityWriter();
|
|
764
700
|
for (const record of records) {
|
|
765
|
-
|
|
701
|
+
entityBatch.put({
|
|
766
702
|
...record,
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
703
|
+
data: {
|
|
704
|
+
...record.data,
|
|
705
|
+
...updatedEntryMetaFields,
|
|
706
|
+
wbyDeleted: storageEntry.wbyDeleted,
|
|
707
|
+
location: storageEntry.location,
|
|
708
|
+
binOriginalFolderId: storageEntry.binOriginalFolderId
|
|
709
|
+
}
|
|
710
|
+
});
|
|
711
|
+
|
|
772
712
|
/**
|
|
773
713
|
* We need to get the published and latest records, so we can update the Elasticsearch.
|
|
774
714
|
*/
|
|
775
715
|
if (record.SK === publishedSortKey) {
|
|
776
|
-
publishedRecord = record;
|
|
716
|
+
publishedRecord = record.data;
|
|
777
717
|
} else if (record.SK === latestSortKey) {
|
|
778
|
-
latestRecord = record;
|
|
718
|
+
latestRecord = record.data;
|
|
779
719
|
}
|
|
780
720
|
}
|
|
781
721
|
|
|
@@ -783,15 +723,12 @@ const createEntriesStorageOperations = params => {
|
|
|
783
723
|
* We write the records back to the primary DynamoDB table.
|
|
784
724
|
*/
|
|
785
725
|
try {
|
|
786
|
-
await (
|
|
787
|
-
table: entity.table,
|
|
788
|
-
items
|
|
789
|
-
});
|
|
726
|
+
await entityBatch.execute();
|
|
790
727
|
dataLoaders.clearAll({
|
|
791
728
|
model
|
|
792
729
|
});
|
|
793
730
|
} catch (ex) {
|
|
794
|
-
throw new
|
|
731
|
+
throw new WebinyError(ex.message || "Could not restore all entry records from in the DynamoDB table.", ex.code || "RESTORE_ENTRY_ERROR", {
|
|
795
732
|
error: ex,
|
|
796
733
|
entry,
|
|
797
734
|
storageEntry
|
|
@@ -801,32 +738,29 @@ const createEntriesStorageOperations = params => {
|
|
|
801
738
|
/**
|
|
802
739
|
* We need to get the published and latest records from Elasticsearch.
|
|
803
740
|
*/
|
|
804
|
-
const
|
|
741
|
+
const esEntityReader = esEntity.createEntityReader();
|
|
805
742
|
if (publishedRecord) {
|
|
806
|
-
|
|
743
|
+
esEntityReader.get({
|
|
807
744
|
PK: partitionKey,
|
|
808
745
|
SK: publishedSortKey
|
|
809
|
-
})
|
|
746
|
+
});
|
|
810
747
|
}
|
|
811
748
|
if (latestRecord) {
|
|
812
|
-
|
|
749
|
+
esEntityReader.get({
|
|
813
750
|
PK: partitionKey,
|
|
814
751
|
SK: latestSortKey
|
|
815
|
-
})
|
|
752
|
+
});
|
|
816
753
|
}
|
|
817
|
-
const esRecords = await (
|
|
818
|
-
table: esEntity.table,
|
|
819
|
-
items: esGetItems
|
|
820
|
-
});
|
|
754
|
+
const esRecords = await esEntityReader.execute();
|
|
821
755
|
const esItems = (await Promise.all(esRecords.map(async record => {
|
|
822
756
|
if (!record) {
|
|
823
757
|
return null;
|
|
824
758
|
}
|
|
825
759
|
return {
|
|
826
760
|
...record,
|
|
827
|
-
data: await
|
|
761
|
+
data: await decompress(plugins, record.data)
|
|
828
762
|
};
|
|
829
|
-
}))).filter(
|
|
763
|
+
}))).filter(item => !!item);
|
|
830
764
|
if (esItems.length === 0) {
|
|
831
765
|
return initialStorageEntry;
|
|
832
766
|
}
|
|
@@ -834,30 +768,27 @@ const createEntriesStorageOperations = params => {
|
|
|
834
768
|
/**
|
|
835
769
|
* We update all ES records with data received.
|
|
836
770
|
*/
|
|
837
|
-
const
|
|
771
|
+
const elasticsearchEntityBatch = esEntity.createEntityWriter();
|
|
838
772
|
for (const item of esItems) {
|
|
839
|
-
|
|
773
|
+
elasticsearchEntityBatch.put({
|
|
840
774
|
...item,
|
|
841
|
-
data: await
|
|
775
|
+
data: await compress(plugins, {
|
|
842
776
|
...item.data,
|
|
843
777
|
...updatedEntryMetaFields,
|
|
844
778
|
wbyDeleted: entry.wbyDeleted,
|
|
845
779
|
location: entry.location,
|
|
846
780
|
binOriginalFolderId: entry.binOriginalFolderId
|
|
847
781
|
})
|
|
848
|
-
})
|
|
782
|
+
});
|
|
849
783
|
}
|
|
850
784
|
|
|
851
785
|
/**
|
|
852
786
|
* We write the records back to the primary DynamoDB Elasticsearch table.
|
|
853
787
|
*/
|
|
854
788
|
try {
|
|
855
|
-
await (
|
|
856
|
-
table: esEntity.table,
|
|
857
|
-
items: esUpdateItems
|
|
858
|
-
});
|
|
789
|
+
await elasticsearchEntityBatch.execute();
|
|
859
790
|
} catch (ex) {
|
|
860
|
-
throw new
|
|
791
|
+
throw new WebinyError(ex.message || "Could not restore entry records from DynamoDB Elasticsearch table.", ex.code || "RESTORE_ENTRY_ERROR", {
|
|
861
792
|
error: ex,
|
|
862
793
|
entry,
|
|
863
794
|
storageEntry
|
|
@@ -871,58 +802,53 @@ const createEntriesStorageOperations = params => {
|
|
|
871
802
|
} = params;
|
|
872
803
|
const id = entry.id || entry.entryId;
|
|
873
804
|
const model = getStorageOperationsModel(initialModel);
|
|
874
|
-
const partitionKey =
|
|
805
|
+
const partitionKey = createPartitionKey({
|
|
875
806
|
id,
|
|
876
|
-
locale: model.locale,
|
|
877
807
|
tenant: model.tenant
|
|
878
808
|
});
|
|
879
|
-
const items = await
|
|
880
|
-
entity,
|
|
809
|
+
const items = await entity.queryAll({
|
|
881
810
|
partitionKey,
|
|
882
811
|
options: {
|
|
883
812
|
gte: " "
|
|
884
813
|
}
|
|
885
814
|
});
|
|
886
|
-
const esItems = await
|
|
887
|
-
entity: esEntity,
|
|
815
|
+
const esItems = await esEntity.queryAll({
|
|
888
816
|
partitionKey,
|
|
889
817
|
options: {
|
|
890
818
|
gte: " "
|
|
891
819
|
}
|
|
892
820
|
});
|
|
893
|
-
const
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
821
|
+
const entityBatch = entity.createEntityWriter({
|
|
822
|
+
delete: items.map(item => {
|
|
823
|
+
return {
|
|
824
|
+
PK: item.PK,
|
|
825
|
+
SK: item.SK
|
|
826
|
+
};
|
|
827
|
+
})
|
|
898
828
|
});
|
|
899
|
-
const
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
829
|
+
const elasticsearchEntityBatch = esEntity.createEntityWriter({
|
|
830
|
+
delete: esItems.map(item => {
|
|
831
|
+
return {
|
|
832
|
+
PK: item.PK,
|
|
833
|
+
SK: item.SK
|
|
834
|
+
};
|
|
835
|
+
})
|
|
904
836
|
});
|
|
905
837
|
try {
|
|
906
|
-
await (
|
|
907
|
-
table: entity.table,
|
|
908
|
-
items: deleteItems
|
|
909
|
-
});
|
|
838
|
+
await entityBatch.execute();
|
|
910
839
|
dataLoaders.clearAll({
|
|
911
840
|
model
|
|
912
841
|
});
|
|
913
842
|
} catch (ex) {
|
|
914
|
-
throw new
|
|
843
|
+
throw new WebinyError(ex.message || "Could not destroy entry records from DynamoDB table.", ex.code || "DELETE_ENTRY_ERROR", {
|
|
915
844
|
error: ex,
|
|
916
845
|
id
|
|
917
846
|
});
|
|
918
847
|
}
|
|
919
848
|
try {
|
|
920
|
-
await (
|
|
921
|
-
table: esEntity.table,
|
|
922
|
-
items: deleteEsItems
|
|
923
|
-
});
|
|
849
|
+
await elasticsearchEntityBatch.execute();
|
|
924
850
|
} catch (ex) {
|
|
925
|
-
throw new
|
|
851
|
+
throw new WebinyError(ex.message || "Could not destroy entry records from DynamoDB Elasticsearch table.", ex.code || "DELETE_ENTRY_ERROR", {
|
|
926
852
|
error: ex,
|
|
927
853
|
id
|
|
928
854
|
});
|
|
@@ -932,17 +858,16 @@ const createEntriesStorageOperations = params => {
|
|
|
932
858
|
const {
|
|
933
859
|
entry,
|
|
934
860
|
latestEntry,
|
|
935
|
-
latestStorageEntry
|
|
861
|
+
latestStorageEntry: initialLatestStorageEntry
|
|
936
862
|
} = params;
|
|
937
863
|
const model = getStorageOperationsModel(initialModel);
|
|
938
|
-
const partitionKey =
|
|
864
|
+
const partitionKey = createPartitionKey({
|
|
939
865
|
id: entry.id,
|
|
940
|
-
locale: model.locale,
|
|
941
866
|
tenant: model.tenant
|
|
942
867
|
});
|
|
943
868
|
const {
|
|
944
869
|
index
|
|
945
|
-
} =
|
|
870
|
+
} = configurations.es({
|
|
946
871
|
model
|
|
947
872
|
});
|
|
948
873
|
/**
|
|
@@ -955,98 +880,86 @@ const createEntriesStorageOperations = params => {
|
|
|
955
880
|
/**
|
|
956
881
|
* We need to delete all existing records of the given entry revision.
|
|
957
882
|
*/
|
|
958
|
-
const
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
})];
|
|
966
|
-
const esItems = [];
|
|
883
|
+
const entityBatch = entity.createEntityWriter({
|
|
884
|
+
delete: [{
|
|
885
|
+
PK: partitionKey,
|
|
886
|
+
SK: createRevisionSortKey(entry)
|
|
887
|
+
}]
|
|
888
|
+
});
|
|
889
|
+
const elasticsearchEntityBatch = esEntity.createEntityWriter();
|
|
967
890
|
|
|
968
891
|
/**
|
|
969
892
|
* If revision we are deleting is the published one as well, we need to delete those records as well.
|
|
970
893
|
*/
|
|
971
894
|
if (publishedStorageEntry?.id === entry.id) {
|
|
972
|
-
|
|
895
|
+
entityBatch.delete({
|
|
973
896
|
PK: partitionKey,
|
|
974
|
-
SK:
|
|
975
|
-
})
|
|
976
|
-
|
|
897
|
+
SK: createPublishedSortKey()
|
|
898
|
+
});
|
|
899
|
+
elasticsearchEntityBatch.delete({
|
|
977
900
|
PK: partitionKey,
|
|
978
|
-
SK:
|
|
979
|
-
})
|
|
901
|
+
SK: createPublishedSortKey()
|
|
902
|
+
});
|
|
980
903
|
}
|
|
981
|
-
if (latestEntry &&
|
|
904
|
+
if (latestEntry && initialLatestStorageEntry) {
|
|
905
|
+
const latestStorageEntry = convertToStorageEntry({
|
|
906
|
+
storageEntry: initialLatestStorageEntry,
|
|
907
|
+
model
|
|
908
|
+
});
|
|
909
|
+
|
|
982
910
|
/**
|
|
983
911
|
* In the end we need to set the new latest entry.
|
|
984
912
|
*/
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
}));
|
|
913
|
+
const latestStorageEntryLatestKey = createEntryLatestKeys(latestStorageEntry);
|
|
914
|
+
entityBatch.put({
|
|
915
|
+
...latestStorageEntryLatestKey,
|
|
916
|
+
data: latestStorageEntry
|
|
917
|
+
});
|
|
991
918
|
|
|
992
919
|
/**
|
|
993
920
|
* Also perform an update on the actual revision. This is needed
|
|
994
921
|
* because of updates on the entry-level meta fields.
|
|
995
922
|
*/
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
}),
|
|
1003
|
-
SK: (0, _keys.createRevisionSortKey)(latestStorageEntry),
|
|
1004
|
-
TYPE: (0, _recordType.createRecordType)()
|
|
1005
|
-
}));
|
|
1006
|
-
const latestTransformer = (0, _transformations.createTransformer)({
|
|
923
|
+
const actualRevisionEntryKey = createEntryRevisionKeys(initialLatestStorageEntry);
|
|
924
|
+
entityBatch.put({
|
|
925
|
+
...actualRevisionEntryKey,
|
|
926
|
+
data: latestStorageEntry
|
|
927
|
+
});
|
|
928
|
+
const latestTransformer = createTransformer({
|
|
1007
929
|
plugins,
|
|
1008
930
|
model,
|
|
1009
931
|
entry: latestEntry,
|
|
1010
|
-
storageEntry:
|
|
932
|
+
storageEntry: initialLatestStorageEntry
|
|
1011
933
|
});
|
|
1012
934
|
const esLatestData = await latestTransformer.getElasticsearchLatestEntryData();
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
935
|
+
const esLatestKeys = createEntryLatestKeys(latestEntry);
|
|
936
|
+
elasticsearchEntityBatch.put({
|
|
937
|
+
...esLatestKeys,
|
|
1016
938
|
index,
|
|
1017
939
|
data: esLatestData
|
|
1018
|
-
})
|
|
940
|
+
});
|
|
1019
941
|
}
|
|
1020
942
|
try {
|
|
1021
|
-
await (
|
|
1022
|
-
table: entity.table,
|
|
1023
|
-
items
|
|
1024
|
-
});
|
|
943
|
+
await entityBatch.execute();
|
|
1025
944
|
dataLoaders.clearAll({
|
|
1026
945
|
model
|
|
1027
946
|
});
|
|
1028
947
|
} catch (ex) {
|
|
1029
|
-
throw new
|
|
948
|
+
throw new WebinyError(ex.message || "Could not batch write entry records to DynamoDB table.", ex.code || "DELETE_REVISION_ERROR", {
|
|
1030
949
|
error: ex,
|
|
1031
950
|
entry,
|
|
1032
951
|
latestEntry,
|
|
1033
|
-
|
|
952
|
+
initialLatestStorageEntry
|
|
1034
953
|
});
|
|
1035
954
|
}
|
|
1036
|
-
if (esItems.length === 0) {
|
|
1037
|
-
return;
|
|
1038
|
-
}
|
|
1039
955
|
try {
|
|
1040
|
-
await (
|
|
1041
|
-
table: esEntity.table,
|
|
1042
|
-
items: esItems
|
|
1043
|
-
});
|
|
956
|
+
await elasticsearchEntityBatch.execute();
|
|
1044
957
|
} catch (ex) {
|
|
1045
|
-
throw new
|
|
958
|
+
throw new WebinyError(ex.message || "Could not batch write entry records to DynamoDB Elasticsearch table.", ex.code || "DELETE_REVISION_ERROR", {
|
|
1046
959
|
error: ex,
|
|
1047
960
|
entry,
|
|
1048
961
|
latestEntry,
|
|
1049
|
-
|
|
962
|
+
initialLatestStorageEntry
|
|
1050
963
|
});
|
|
1051
964
|
}
|
|
1052
965
|
};
|
|
@@ -1065,86 +978,77 @@ const createEntriesStorageOperations = params => {
|
|
|
1065
978
|
/**
|
|
1066
979
|
* Then we need to construct the queries for all the revisions and entries.
|
|
1067
980
|
*/
|
|
1068
|
-
|
|
1069
|
-
const
|
|
981
|
+
|
|
982
|
+
const entityBatch = entity.createEntityWriter();
|
|
983
|
+
const elasticsearchEntityBatch = esEntity.createEntityWriter();
|
|
1070
984
|
for (const id of entries) {
|
|
1071
985
|
/**
|
|
1072
986
|
* Latest item.
|
|
1073
987
|
*/
|
|
1074
|
-
|
|
1075
|
-
PK:
|
|
988
|
+
entityBatch.delete({
|
|
989
|
+
PK: createPartitionKey({
|
|
1076
990
|
id,
|
|
1077
|
-
locale: model.locale,
|
|
1078
991
|
tenant: model.tenant
|
|
1079
992
|
}),
|
|
1080
993
|
SK: "L"
|
|
1081
|
-
})
|
|
1082
|
-
|
|
1083
|
-
PK:
|
|
994
|
+
});
|
|
995
|
+
elasticsearchEntityBatch.delete({
|
|
996
|
+
PK: createPartitionKey({
|
|
1084
997
|
id,
|
|
1085
|
-
locale: model.locale,
|
|
1086
998
|
tenant: model.tenant
|
|
1087
999
|
}),
|
|
1088
1000
|
SK: "L"
|
|
1089
|
-
})
|
|
1001
|
+
});
|
|
1002
|
+
|
|
1090
1003
|
/**
|
|
1091
1004
|
* Published item.
|
|
1092
1005
|
*/
|
|
1093
|
-
|
|
1094
|
-
PK:
|
|
1006
|
+
entityBatch.delete({
|
|
1007
|
+
PK: createPartitionKey({
|
|
1095
1008
|
id,
|
|
1096
|
-
locale: model.locale,
|
|
1097
1009
|
tenant: model.tenant
|
|
1098
1010
|
}),
|
|
1099
1011
|
SK: "P"
|
|
1100
|
-
})
|
|
1101
|
-
|
|
1102
|
-
PK:
|
|
1012
|
+
});
|
|
1013
|
+
elasticsearchEntityBatch.delete({
|
|
1014
|
+
PK: createPartitionKey({
|
|
1103
1015
|
id,
|
|
1104
|
-
locale: model.locale,
|
|
1105
1016
|
tenant: model.tenant
|
|
1106
1017
|
}),
|
|
1107
1018
|
SK: "P"
|
|
1108
|
-
})
|
|
1019
|
+
});
|
|
1109
1020
|
}
|
|
1110
1021
|
/**
|
|
1111
1022
|
* Exact revisions of all the entries
|
|
1112
1023
|
*/
|
|
1113
1024
|
for (const revision of revisions) {
|
|
1114
|
-
|
|
1115
|
-
PK:
|
|
1025
|
+
entityBatch.delete({
|
|
1026
|
+
PK: createPartitionKey({
|
|
1116
1027
|
id: revision.id,
|
|
1117
|
-
locale: model.locale,
|
|
1118
1028
|
tenant: model.tenant
|
|
1119
1029
|
}),
|
|
1120
|
-
SK:
|
|
1030
|
+
SK: createRevisionSortKey({
|
|
1121
1031
|
version: revision.version
|
|
1122
1032
|
})
|
|
1123
|
-
})
|
|
1033
|
+
});
|
|
1124
1034
|
}
|
|
1125
|
-
await (
|
|
1126
|
-
|
|
1127
|
-
items
|
|
1128
|
-
});
|
|
1129
|
-
await (0, _batchWrite.batchWriteAll)({
|
|
1130
|
-
table: esEntity.table,
|
|
1131
|
-
items: esItems
|
|
1132
|
-
});
|
|
1035
|
+
await entityBatch.execute();
|
|
1036
|
+
await elasticsearchEntityBatch.execute();
|
|
1133
1037
|
};
|
|
1134
1038
|
const list = async (initialModel, params) => {
|
|
1135
1039
|
const model = getStorageOperationsModel(initialModel);
|
|
1136
|
-
const limit =
|
|
1040
|
+
const limit = createLimit(params.limit, 50);
|
|
1137
1041
|
const {
|
|
1138
1042
|
index
|
|
1139
|
-
} =
|
|
1043
|
+
} = configurations.es({
|
|
1140
1044
|
model
|
|
1141
1045
|
});
|
|
1142
|
-
const body =
|
|
1046
|
+
const body = createElasticsearchBody({
|
|
1143
1047
|
model,
|
|
1144
1048
|
params: {
|
|
1145
1049
|
...params,
|
|
1146
1050
|
limit,
|
|
1147
|
-
after:
|
|
1051
|
+
after: decodeCursor(params.after)
|
|
1148
1052
|
},
|
|
1149
1053
|
plugins
|
|
1150
1054
|
});
|
|
@@ -1154,12 +1058,12 @@ const createEntriesStorageOperations = params => {
|
|
|
1154
1058
|
index,
|
|
1155
1059
|
body
|
|
1156
1060
|
});
|
|
1157
|
-
} catch (
|
|
1061
|
+
} catch (error) {
|
|
1158
1062
|
/**
|
|
1159
1063
|
* We will silently ignore the `index_not_found_exception` error and return an empty result set.
|
|
1160
1064
|
* This is because the index might not exist yet, and we don't want to throw an error.
|
|
1161
1065
|
*/
|
|
1162
|
-
if (
|
|
1066
|
+
if (shouldIgnoreEsResponseError(error)) {
|
|
1163
1067
|
return {
|
|
1164
1068
|
hasMoreItems: false,
|
|
1165
1069
|
totalCount: 0,
|
|
@@ -1167,8 +1071,8 @@ const createEntriesStorageOperations = params => {
|
|
|
1167
1071
|
items: []
|
|
1168
1072
|
};
|
|
1169
1073
|
}
|
|
1170
|
-
throw new
|
|
1171
|
-
error
|
|
1074
|
+
throw new WebinyError(error.message, error.code || "OPENSEARCH_ERROR", {
|
|
1075
|
+
error,
|
|
1172
1076
|
index,
|
|
1173
1077
|
body,
|
|
1174
1078
|
model
|
|
@@ -1178,12 +1082,14 @@ const createEntriesStorageOperations = params => {
|
|
|
1178
1082
|
hits,
|
|
1179
1083
|
total
|
|
1180
1084
|
} = response?.body?.hits || {};
|
|
1181
|
-
const items =
|
|
1085
|
+
const items = extractEntriesFromIndex({
|
|
1182
1086
|
plugins,
|
|
1183
1087
|
model,
|
|
1184
|
-
entries: hits.map(item =>
|
|
1088
|
+
entries: hits.map(item => {
|
|
1089
|
+
return item._source;
|
|
1090
|
+
})
|
|
1185
1091
|
}).map(item => {
|
|
1186
|
-
return
|
|
1092
|
+
return convertEntryKeysFromStorage({
|
|
1187
1093
|
model,
|
|
1188
1094
|
entry: item
|
|
1189
1095
|
});
|
|
@@ -1199,7 +1105,7 @@ const createEntriesStorageOperations = params => {
|
|
|
1199
1105
|
* Cursor is the `sort` value of the last item in the array.
|
|
1200
1106
|
* https://www.elastic.co/guide/en/elasticsearch/reference/current/paginate-search-results.html#search-after
|
|
1201
1107
|
*/
|
|
1202
|
-
const cursor = items.length > 0 ?
|
|
1108
|
+
const cursor = items.length > 0 ? encodeCursor(hits[items.length - 1].sort) || null : null;
|
|
1203
1109
|
return {
|
|
1204
1110
|
hasMoreItems,
|
|
1205
1111
|
totalCount: total.value,
|
|
@@ -1223,7 +1129,7 @@ const createEntriesStorageOperations = params => {
|
|
|
1223
1129
|
storageEntry: initialStorageEntry
|
|
1224
1130
|
} = params;
|
|
1225
1131
|
const model = getStorageOperationsModel(initialModel);
|
|
1226
|
-
const transformer =
|
|
1132
|
+
const transformer = createTransformer({
|
|
1227
1133
|
plugins,
|
|
1228
1134
|
model,
|
|
1229
1135
|
entry: initialEntry,
|
|
@@ -1233,94 +1139,24 @@ const createEntriesStorageOperations = params => {
|
|
|
1233
1139
|
entry,
|
|
1234
1140
|
storageEntry
|
|
1235
1141
|
} = transformer.transformEntryKeys();
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
*/
|
|
1240
|
-
const [publishedStorageEntry] = await dataLoaders.getPublishedRevisionByEntryId({
|
|
1241
|
-
model,
|
|
1242
|
-
ids: [entry.id]
|
|
1243
|
-
});
|
|
1244
|
-
const revisionKeys = {
|
|
1245
|
-
PK: (0, _keys.createPartitionKey)({
|
|
1246
|
-
id: entry.id,
|
|
1247
|
-
locale: model.locale,
|
|
1248
|
-
tenant: model.tenant
|
|
1249
|
-
}),
|
|
1250
|
-
SK: (0, _keys.createRevisionSortKey)(entry)
|
|
1251
|
-
};
|
|
1252
|
-
const latestKeys = {
|
|
1253
|
-
PK: (0, _keys.createPartitionKey)({
|
|
1254
|
-
id: entry.id,
|
|
1255
|
-
locale: model.locale,
|
|
1256
|
-
tenant: model.tenant
|
|
1257
|
-
}),
|
|
1258
|
-
SK: (0, _keys.createLatestSortKey)()
|
|
1259
|
-
};
|
|
1260
|
-
const publishedKeys = {
|
|
1261
|
-
PK: (0, _keys.createPartitionKey)({
|
|
1262
|
-
id: entry.id,
|
|
1263
|
-
locale: model.locale,
|
|
1264
|
-
tenant: model.tenant
|
|
1265
|
-
}),
|
|
1266
|
-
SK: (0, _keys.createPublishedSortKey)()
|
|
1267
|
-
};
|
|
1142
|
+
const revisionKeys = createEntryRevisionKeys(entry);
|
|
1143
|
+
const latestKeys = createEntryLatestKeys(entry);
|
|
1144
|
+
const publishedKeys = createEntryPublishedKeys(entry);
|
|
1268
1145
|
let latestEsEntry = null;
|
|
1269
1146
|
try {
|
|
1270
|
-
latestEsEntry = await
|
|
1271
|
-
entity: esEntity,
|
|
1272
|
-
keys: latestKeys
|
|
1273
|
-
});
|
|
1147
|
+
latestEsEntry = await esEntity.getClean(latestKeys);
|
|
1274
1148
|
} catch (ex) {
|
|
1275
|
-
throw new
|
|
1149
|
+
throw new WebinyError(ex.message || "Could not read Elasticsearch latest data.", ex.code || "PUBLISH_LATEST_READ", {
|
|
1276
1150
|
error: ex,
|
|
1277
1151
|
latestKeys: latestKeys,
|
|
1278
1152
|
publishedKeys: publishedKeys
|
|
1279
1153
|
});
|
|
1280
1154
|
}
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
TYPE: (0, _recordType.createRecordType)()
|
|
1285
|
-
})];
|
|
1286
|
-
const esItems = [];
|
|
1287
|
-
const {
|
|
1288
|
-
index: esIndex
|
|
1289
|
-
} = _configurations.configurations.es({
|
|
1290
|
-
model
|
|
1291
|
-
});
|
|
1292
|
-
if (publishedStorageEntry && publishedStorageEntry.id !== entry.id) {
|
|
1293
|
-
/**
|
|
1294
|
-
* If there is a `published` entry already, we need to set it to `unpublished`. We need to
|
|
1295
|
-
* execute two updates: update the previously published entry's status and the published entry record.
|
|
1296
|
-
* DynamoDB does not support `batchUpdate` - so here we load the previously published
|
|
1297
|
-
* entry's data to update its status within a batch operation. If, hopefully,
|
|
1298
|
-
* they introduce a true update batch operation, remove this `read` call.
|
|
1299
|
-
*/
|
|
1300
|
-
const [previouslyPublishedEntry] = await dataLoaders.getRevisionById({
|
|
1301
|
-
model,
|
|
1302
|
-
ids: [publishedStorageEntry.id]
|
|
1155
|
+
if (!latestEsEntry) {
|
|
1156
|
+
throw new WebinyError(`Could not publish entry. Could not load latest ("L") record (ES table).`, "PUBLISH_ERROR", {
|
|
1157
|
+
entry
|
|
1303
1158
|
});
|
|
1304
|
-
items.push(
|
|
1305
|
-
/**
|
|
1306
|
-
* Update currently published entry (unpublish it)
|
|
1307
|
-
*/
|
|
1308
|
-
entity.putBatch({
|
|
1309
|
-
...previouslyPublishedEntry,
|
|
1310
|
-
status: _types.CONTENT_ENTRY_STATUS.UNPUBLISHED,
|
|
1311
|
-
TYPE: (0, _recordType.createRecordType)(),
|
|
1312
|
-
PK: (0, _keys.createPartitionKey)(publishedStorageEntry),
|
|
1313
|
-
SK: (0, _keys.createRevisionSortKey)(publishedStorageEntry)
|
|
1314
|
-
}));
|
|
1315
1159
|
}
|
|
1316
|
-
/**
|
|
1317
|
-
* Update the helper item in DB with the new published entry
|
|
1318
|
-
*/
|
|
1319
|
-
items.push(entity.putBatch({
|
|
1320
|
-
...storageEntry,
|
|
1321
|
-
...publishedKeys,
|
|
1322
|
-
TYPE: (0, _recordType.createPublishedRecordType)()
|
|
1323
|
-
}));
|
|
1324
1160
|
|
|
1325
1161
|
/**
|
|
1326
1162
|
* We need the latest entry to check if it needs to be updated as well in the Elasticsearch.
|
|
@@ -1329,113 +1165,191 @@ const createEntriesStorageOperations = params => {
|
|
|
1329
1165
|
model,
|
|
1330
1166
|
ids: [entry.id]
|
|
1331
1167
|
});
|
|
1332
|
-
if (latestStorageEntry
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
}));
|
|
1168
|
+
if (!latestStorageEntry) {
|
|
1169
|
+
throw new WebinyError(`Could not publish entry. Could not load latest ("L") record.`, "PUBLISH_ERROR", {
|
|
1170
|
+
entry
|
|
1171
|
+
});
|
|
1337
1172
|
}
|
|
1338
|
-
if (latestEsEntry) {
|
|
1339
|
-
const publishingLatestRevision = latestStorageEntry?.id === entry.id;
|
|
1340
1173
|
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
if (publishingLatestRevision) {
|
|
1349
|
-
const updatedMetaFields = (0, _constants.pickEntryMetaFields)(entry);
|
|
1350
|
-
const latestTransformer = (0, _transformations.createTransformer)({
|
|
1351
|
-
plugins,
|
|
1352
|
-
model,
|
|
1353
|
-
transformedToIndex: {
|
|
1354
|
-
...latestEsEntryDataDecompressed,
|
|
1355
|
-
status: _types.CONTENT_ENTRY_STATUS.PUBLISHED,
|
|
1356
|
-
locked: true,
|
|
1357
|
-
...updatedMetaFields
|
|
1358
|
-
}
|
|
1359
|
-
});
|
|
1360
|
-
esItems.push(esEntity.putBatch({
|
|
1361
|
-
index: esIndex,
|
|
1362
|
-
PK: (0, _keys.createPartitionKey)(latestEsEntryDataDecompressed),
|
|
1363
|
-
SK: (0, _keys.createLatestSortKey)(),
|
|
1364
|
-
data: await latestTransformer.getElasticsearchLatestEntryData()
|
|
1365
|
-
}));
|
|
1366
|
-
} else {
|
|
1367
|
-
const updatedEntryLevelMetaFields = (0, _constants.pickEntryMetaFields)(entry, _constants.isEntryLevelEntryMetaField);
|
|
1368
|
-
const updatedLatestStorageEntry = {
|
|
1369
|
-
...latestStorageEntry,
|
|
1370
|
-
...latestKeys,
|
|
1371
|
-
...updatedEntryLevelMetaFields
|
|
1372
|
-
};
|
|
1174
|
+
/**
|
|
1175
|
+
* We need currently published entry to check if need to remove it.
|
|
1176
|
+
*/
|
|
1177
|
+
const [publishedStorageEntry] = await dataLoaders.getPublishedRevisionByEntryId({
|
|
1178
|
+
model,
|
|
1179
|
+
ids: [entry.id]
|
|
1180
|
+
});
|
|
1373
1181
|
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
...updatedLatestStorageEntry,
|
|
1391
|
-
TYPE: (0, _recordType.createLatestRecordType)()
|
|
1392
|
-
}));
|
|
1182
|
+
// 1. Update REV# and P records with new data.
|
|
1183
|
+
const entityBatch = entity.createEntityWriter({
|
|
1184
|
+
put: [{
|
|
1185
|
+
...revisionKeys,
|
|
1186
|
+
data: storageEntry
|
|
1187
|
+
}, {
|
|
1188
|
+
...publishedKeys,
|
|
1189
|
+
data: storageEntry
|
|
1190
|
+
}]
|
|
1191
|
+
});
|
|
1192
|
+
const elasticsearchEntityWriter = esEntity.createEntityWriter();
|
|
1193
|
+
const {
|
|
1194
|
+
index: esIndex
|
|
1195
|
+
} = configurations.es({
|
|
1196
|
+
model
|
|
1197
|
+
});
|
|
1393
1198
|
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1199
|
+
// 2. When it comes to the latest record, we need to perform a couple of different
|
|
1200
|
+
// updates, based on whether the entry being published is the latest revision or not.
|
|
1201
|
+
const publishedRevisionId = publishedStorageEntry?.id;
|
|
1202
|
+
const publishingLatestRevision = latestStorageEntry?.id === entry.id;
|
|
1203
|
+
if (publishingLatestRevision) {
|
|
1204
|
+
// 2.1 If we're publishing the latest revision, we first need to update the L record.
|
|
1205
|
+
entityBatch.put({
|
|
1206
|
+
...latestKeys,
|
|
1207
|
+
data: storageEntry
|
|
1208
|
+
});
|
|
1209
|
+
|
|
1210
|
+
// 2.2 Additionally, if we have a previously published entry, we need to mark it as unpublished.
|
|
1211
|
+
// Note that we need to take re-publishing into account (same published revision being
|
|
1212
|
+
// published again), in which case the below code does not apply. This is because the
|
|
1213
|
+
// required updates were already applied above.
|
|
1214
|
+
if (publishedStorageEntry) {
|
|
1215
|
+
const isRepublishing = publishedStorageEntry.id === entry.id;
|
|
1216
|
+
if (!isRepublishing) {
|
|
1217
|
+
/**
|
|
1218
|
+
* Update currently published entry (unpublish it)
|
|
1219
|
+
*/
|
|
1220
|
+
const publishedStorageEntryKeys = createEntryRevisionKeys(publishedStorageEntry);
|
|
1221
|
+
entityBatch.put({
|
|
1222
|
+
...publishedStorageEntryKeys,
|
|
1223
|
+
data: {
|
|
1224
|
+
...publishedStorageEntry,
|
|
1225
|
+
status: CONTENT_ENTRY_STATUS.UNPUBLISHED
|
|
1226
|
+
}
|
|
1227
|
+
});
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
1230
|
+
} else {
|
|
1231
|
+
// 2.3 If the published revision is not the latest one, the situation is a bit
|
|
1232
|
+
// more complex. We first need to update the L and REV# records with the new
|
|
1233
|
+
// values of *only entry-level* meta fields.
|
|
1234
|
+
const updatedEntryLevelMetaFields = pickEntryMetaFields(entry, isEntryLevelEntryMetaField);
|
|
1235
|
+
|
|
1236
|
+
// 2.4 Update L record. Apart from updating the entry-level meta fields, we also need
|
|
1237
|
+
// to change the status from "published" to "unpublished" (if the status is set to "published").
|
|
1238
|
+
let latestRevisionStatus = latestStorageEntry.status;
|
|
1239
|
+
if (latestRevisionStatus === CONTENT_ENTRY_STATUS.PUBLISHED) {
|
|
1240
|
+
latestRevisionStatus = CONTENT_ENTRY_STATUS.UNPUBLISHED;
|
|
1241
|
+
}
|
|
1242
|
+
const latestStorageEntryFields = {
|
|
1243
|
+
...latestStorageEntry,
|
|
1244
|
+
...updatedEntryLevelMetaFields,
|
|
1245
|
+
status: latestRevisionStatus
|
|
1246
|
+
};
|
|
1247
|
+
const latestStorageEntryLatestKeys = createEntryLatestKeys(latestStorageEntry);
|
|
1248
|
+
entityBatch.put({
|
|
1249
|
+
...latestStorageEntryLatestKeys,
|
|
1250
|
+
data: latestStorageEntryFields
|
|
1251
|
+
});
|
|
1252
|
+
|
|
1253
|
+
// 2.5 Update REV# record.
|
|
1254
|
+
const latestStorageEntryRevisionKeys = createEntryRevisionKeys(latestStorageEntry);
|
|
1255
|
+
entityBatch.put({
|
|
1256
|
+
...latestStorageEntryRevisionKeys,
|
|
1257
|
+
data: latestStorageEntryFields
|
|
1258
|
+
});
|
|
1259
|
+
|
|
1260
|
+
// 2.6 Additionally, if we have a previously published entry, we need to mark it as unpublished.
|
|
1261
|
+
// Note that we need to take re-publishing into account (same published revision being
|
|
1262
|
+
// published again), in which case the below code does not apply. This is because the
|
|
1263
|
+
// required updates were already applied above.
|
|
1264
|
+
if (publishedStorageEntry) {
|
|
1265
|
+
const isRepublishing = publishedStorageEntry.id === entry.id;
|
|
1266
|
+
const publishedRevisionDifferentFromLatest = publishedRevisionId !== latestStorageEntry.id;
|
|
1267
|
+
if (!isRepublishing && publishedRevisionDifferentFromLatest) {
|
|
1268
|
+
const publishedStorageEntryRevisionKeys = createEntryRevisionKeys(publishedStorageEntry);
|
|
1269
|
+
entityBatch.put({
|
|
1270
|
+
...publishedStorageEntryRevisionKeys,
|
|
1271
|
+
data: {
|
|
1272
|
+
...publishedStorageEntry,
|
|
1273
|
+
status: CONTENT_ENTRY_STATUS.UNPUBLISHED
|
|
1274
|
+
}
|
|
1406
1275
|
});
|
|
1407
|
-
esItems.push(esEntity.putBatch({
|
|
1408
|
-
...latestKeys,
|
|
1409
|
-
index: esIndex,
|
|
1410
|
-
data: updatedLatestEntry
|
|
1411
|
-
}));
|
|
1412
1276
|
}
|
|
1413
1277
|
}
|
|
1414
1278
|
}
|
|
1415
1279
|
|
|
1280
|
+
// 3. Update records in ES -> DDB table.
|
|
1281
|
+
|
|
1416
1282
|
/**
|
|
1417
1283
|
* Update the published revision entry in ES.
|
|
1418
1284
|
*/
|
|
1419
1285
|
const esPublishedData = await transformer.getElasticsearchPublishedEntryData();
|
|
1420
|
-
|
|
1286
|
+
elasticsearchEntityWriter.put({
|
|
1421
1287
|
...publishedKeys,
|
|
1422
1288
|
index: esIndex,
|
|
1423
1289
|
data: esPublishedData
|
|
1424
|
-
})
|
|
1290
|
+
});
|
|
1291
|
+
|
|
1292
|
+
/**
|
|
1293
|
+
* Need to decompress the data from Elasticsearch DynamoDB table.
|
|
1294
|
+
*
|
|
1295
|
+
* No need to transform it for the storage because it was fetched
|
|
1296
|
+
* directly from the Elasticsearch table, where it sits transformed.
|
|
1297
|
+
*/
|
|
1298
|
+
const latestEsEntryDataDecompressed = await decompress(plugins, latestEsEntry.data);
|
|
1299
|
+
if (publishingLatestRevision) {
|
|
1300
|
+
const updatedMetaFields = pickEntryMetaFields(entry);
|
|
1301
|
+
const latestTransformer = createTransformer({
|
|
1302
|
+
plugins,
|
|
1303
|
+
model,
|
|
1304
|
+
transformedToIndex: {
|
|
1305
|
+
...latestEsEntryDataDecompressed,
|
|
1306
|
+
status: CONTENT_ENTRY_STATUS.PUBLISHED,
|
|
1307
|
+
locked: true,
|
|
1308
|
+
...updatedMetaFields
|
|
1309
|
+
}
|
|
1310
|
+
});
|
|
1311
|
+
const esEntryLatestKeys = createEntryLatestKeys(latestEsEntryDataDecompressed);
|
|
1312
|
+
elasticsearchEntityWriter.put({
|
|
1313
|
+
index: esIndex,
|
|
1314
|
+
data: await latestTransformer.getElasticsearchLatestEntryData(),
|
|
1315
|
+
...esEntryLatestKeys
|
|
1316
|
+
});
|
|
1317
|
+
} else {
|
|
1318
|
+
const updatedEntryLevelMetaFields = pickEntryMetaFields(entry, isEntryLevelEntryMetaField);
|
|
1319
|
+
|
|
1320
|
+
/**
|
|
1321
|
+
* Update the Elasticsearch table to propagate changes to the Elasticsearch.
|
|
1322
|
+
*/
|
|
1323
|
+
const latestEsEntry = await esEntity.getClean(latestKeys);
|
|
1324
|
+
if (latestEsEntry) {
|
|
1325
|
+
const latestEsEntryDataDecompressed = await decompress(plugins, latestEsEntry.data);
|
|
1326
|
+
let latestRevisionStatus = latestEsEntryDataDecompressed.status;
|
|
1327
|
+
if (latestRevisionStatus === CONTENT_ENTRY_STATUS.PUBLISHED) {
|
|
1328
|
+
latestRevisionStatus = CONTENT_ENTRY_STATUS.UNPUBLISHED;
|
|
1329
|
+
}
|
|
1330
|
+
const updatedLatestEntry = await compress(plugins, {
|
|
1331
|
+
...latestEsEntryDataDecompressed,
|
|
1332
|
+
...updatedEntryLevelMetaFields,
|
|
1333
|
+
status: latestRevisionStatus
|
|
1334
|
+
});
|
|
1335
|
+
elasticsearchEntityWriter.put({
|
|
1336
|
+
...latestKeys,
|
|
1337
|
+
index: esIndex,
|
|
1338
|
+
data: updatedLatestEntry
|
|
1339
|
+
});
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1425
1342
|
|
|
1426
1343
|
/**
|
|
1427
1344
|
* Finally, execute regular table batch.
|
|
1428
1345
|
*/
|
|
1429
1346
|
try {
|
|
1430
|
-
await (
|
|
1431
|
-
table: entity.table,
|
|
1432
|
-
items
|
|
1433
|
-
});
|
|
1347
|
+
await entityBatch.execute();
|
|
1434
1348
|
dataLoaders.clearAll({
|
|
1435
1349
|
model
|
|
1436
1350
|
});
|
|
1437
1351
|
} catch (ex) {
|
|
1438
|
-
throw new
|
|
1352
|
+
throw new WebinyError(ex.message || "Could not store publish entry records in DynamoDB table.", ex.code || "PUBLISH_ERROR", {
|
|
1439
1353
|
error: ex,
|
|
1440
1354
|
entry,
|
|
1441
1355
|
latestStorageEntry,
|
|
@@ -1446,12 +1360,9 @@ const createEntriesStorageOperations = params => {
|
|
|
1446
1360
|
* And Elasticsearch table batch.
|
|
1447
1361
|
*/
|
|
1448
1362
|
try {
|
|
1449
|
-
await (
|
|
1450
|
-
table: esEntity.table,
|
|
1451
|
-
items: esItems
|
|
1452
|
-
});
|
|
1363
|
+
await elasticsearchEntityWriter.execute();
|
|
1453
1364
|
} catch (ex) {
|
|
1454
|
-
throw new
|
|
1365
|
+
throw new WebinyError(ex.message || "Could not store publish entry records in DynamoDB Elasticsearch table.", ex.code || "PUBLISH_ES_ERROR", {
|
|
1455
1366
|
error: ex,
|
|
1456
1367
|
entry,
|
|
1457
1368
|
latestStorageEntry,
|
|
@@ -1466,7 +1377,7 @@ const createEntriesStorageOperations = params => {
|
|
|
1466
1377
|
storageEntry: initialStorageEntry
|
|
1467
1378
|
} = params;
|
|
1468
1379
|
const model = getStorageOperationsModel(initialModel);
|
|
1469
|
-
const transformer =
|
|
1380
|
+
const transformer = createTransformer({
|
|
1470
1381
|
plugins,
|
|
1471
1382
|
model,
|
|
1472
1383
|
entry: initialEntry,
|
|
@@ -1484,61 +1395,60 @@ const createEntriesStorageOperations = params => {
|
|
|
1484
1395
|
model,
|
|
1485
1396
|
ids: [entry.id]
|
|
1486
1397
|
});
|
|
1487
|
-
const partitionKey =
|
|
1398
|
+
const partitionKey = createPartitionKey({
|
|
1488
1399
|
id: entry.id,
|
|
1489
|
-
locale: model.locale,
|
|
1490
1400
|
tenant: model.tenant
|
|
1491
1401
|
});
|
|
1492
|
-
const
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1402
|
+
const entryRevisionKeys = createEntryRevisionKeys(entry);
|
|
1403
|
+
const entityBatch = entity.createEntityWriter({
|
|
1404
|
+
put: [{
|
|
1405
|
+
...entryRevisionKeys,
|
|
1406
|
+
data: storageEntry
|
|
1407
|
+
}],
|
|
1408
|
+
delete: [{
|
|
1409
|
+
PK: partitionKey,
|
|
1410
|
+
SK: createPublishedSortKey()
|
|
1411
|
+
}]
|
|
1412
|
+
});
|
|
1413
|
+
const elasticsearchEntityBatch = esEntity.createEntityWriter({
|
|
1414
|
+
delete: [{
|
|
1415
|
+
PK: partitionKey,
|
|
1416
|
+
SK: createPublishedSortKey()
|
|
1417
|
+
}]
|
|
1418
|
+
});
|
|
1419
|
+
|
|
1505
1420
|
/**
|
|
1506
1421
|
* If we are unpublishing the latest revision, let's also update the latest revision entry's status in both DynamoDB tables.
|
|
1507
1422
|
*/
|
|
1508
1423
|
if (latestStorageEntry?.id === entry.id) {
|
|
1509
1424
|
const {
|
|
1510
1425
|
index
|
|
1511
|
-
} =
|
|
1426
|
+
} = configurations.es({
|
|
1512
1427
|
model
|
|
1513
1428
|
});
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
}));
|
|
1429
|
+
const entryLatestKeys = createEntryLatestKeys(storageEntry);
|
|
1430
|
+
entityBatch.put({
|
|
1431
|
+
...entryLatestKeys,
|
|
1432
|
+
data: storageEntry
|
|
1433
|
+
});
|
|
1520
1434
|
const esLatestData = await transformer.getElasticsearchLatestEntryData();
|
|
1521
|
-
|
|
1522
|
-
PK: partitionKey,
|
|
1523
|
-
SK: (0, _keys.createLatestSortKey)(),
|
|
1435
|
+
elasticsearchEntityBatch.put({
|
|
1524
1436
|
index,
|
|
1525
|
-
data: esLatestData
|
|
1526
|
-
|
|
1437
|
+
data: esLatestData,
|
|
1438
|
+
...entryLatestKeys
|
|
1439
|
+
});
|
|
1527
1440
|
}
|
|
1528
1441
|
|
|
1529
1442
|
/**
|
|
1530
1443
|
* Finally, execute regular table batch.
|
|
1531
1444
|
*/
|
|
1532
1445
|
try {
|
|
1533
|
-
await (
|
|
1534
|
-
table: entity.table,
|
|
1535
|
-
items
|
|
1536
|
-
});
|
|
1446
|
+
await entityBatch.execute();
|
|
1537
1447
|
dataLoaders.clearAll({
|
|
1538
1448
|
model
|
|
1539
1449
|
});
|
|
1540
1450
|
} catch (ex) {
|
|
1541
|
-
throw new
|
|
1451
|
+
throw new WebinyError(ex.message || "Could not store unpublished entry records in DynamoDB table.", ex.code || "UNPUBLISH_ERROR", {
|
|
1542
1452
|
entry,
|
|
1543
1453
|
storageEntry
|
|
1544
1454
|
});
|
|
@@ -1547,12 +1457,9 @@ const createEntriesStorageOperations = params => {
|
|
|
1547
1457
|
* And Elasticsearch table batch.
|
|
1548
1458
|
*/
|
|
1549
1459
|
try {
|
|
1550
|
-
await (
|
|
1551
|
-
table: esEntity.table,
|
|
1552
|
-
items: esItems
|
|
1553
|
-
});
|
|
1460
|
+
await elasticsearchEntityBatch.execute();
|
|
1554
1461
|
} catch (ex) {
|
|
1555
|
-
throw new
|
|
1462
|
+
throw new WebinyError(ex.message || "Could not store unpublished entry records in DynamoDB Elasticsearch table.", ex.code || "UNPUBLISH_ERROR", {
|
|
1556
1463
|
entry,
|
|
1557
1464
|
storageEntry
|
|
1558
1465
|
});
|
|
@@ -1568,7 +1475,7 @@ const createEntriesStorageOperations = params => {
|
|
|
1568
1475
|
if (!entry) {
|
|
1569
1476
|
return null;
|
|
1570
1477
|
}
|
|
1571
|
-
return
|
|
1478
|
+
return convertEntryKeysFromStorage({
|
|
1572
1479
|
model,
|
|
1573
1480
|
entry
|
|
1574
1481
|
});
|
|
@@ -1582,7 +1489,7 @@ const createEntriesStorageOperations = params => {
|
|
|
1582
1489
|
if (!entry) {
|
|
1583
1490
|
return null;
|
|
1584
1491
|
}
|
|
1585
|
-
return
|
|
1492
|
+
return convertEntryKeysFromStorage({
|
|
1586
1493
|
model,
|
|
1587
1494
|
entry
|
|
1588
1495
|
});
|
|
@@ -1596,7 +1503,7 @@ const createEntriesStorageOperations = params => {
|
|
|
1596
1503
|
if (!entry) {
|
|
1597
1504
|
return null;
|
|
1598
1505
|
}
|
|
1599
|
-
return
|
|
1506
|
+
return convertEntryKeysFromStorage({
|
|
1600
1507
|
model,
|
|
1601
1508
|
entry
|
|
1602
1509
|
});
|
|
@@ -1608,7 +1515,7 @@ const createEntriesStorageOperations = params => {
|
|
|
1608
1515
|
ids: [params.id]
|
|
1609
1516
|
});
|
|
1610
1517
|
return entries.map(entry => {
|
|
1611
|
-
return
|
|
1518
|
+
return convertEntryKeysFromStorage({
|
|
1612
1519
|
model,
|
|
1613
1520
|
entry
|
|
1614
1521
|
});
|
|
@@ -1621,7 +1528,7 @@ const createEntriesStorageOperations = params => {
|
|
|
1621
1528
|
ids: params.ids
|
|
1622
1529
|
});
|
|
1623
1530
|
return entries.map(entry => {
|
|
1624
|
-
return
|
|
1531
|
+
return convertEntryKeysFromStorage({
|
|
1625
1532
|
model,
|
|
1626
1533
|
entry
|
|
1627
1534
|
});
|
|
@@ -1634,7 +1541,7 @@ const createEntriesStorageOperations = params => {
|
|
|
1634
1541
|
ids: params.ids
|
|
1635
1542
|
});
|
|
1636
1543
|
return entries.map(entry => {
|
|
1637
|
-
return
|
|
1544
|
+
return convertEntryKeysFromStorage({
|
|
1638
1545
|
model,
|
|
1639
1546
|
entry
|
|
1640
1547
|
});
|
|
@@ -1647,7 +1554,7 @@ const createEntriesStorageOperations = params => {
|
|
|
1647
1554
|
ids: params.ids
|
|
1648
1555
|
});
|
|
1649
1556
|
return entries.map(entry => {
|
|
1650
|
-
return
|
|
1557
|
+
return convertEntryKeysFromStorage({
|
|
1651
1558
|
model,
|
|
1652
1559
|
entry
|
|
1653
1560
|
});
|
|
@@ -1656,51 +1563,44 @@ const createEntriesStorageOperations = params => {
|
|
|
1656
1563
|
const getPreviousRevision = async (initialModel, params) => {
|
|
1657
1564
|
const model = getStorageOperationsModel(initialModel);
|
|
1658
1565
|
const {
|
|
1659
|
-
tenant
|
|
1660
|
-
locale
|
|
1566
|
+
tenant
|
|
1661
1567
|
} = model;
|
|
1662
1568
|
const {
|
|
1663
1569
|
entryId,
|
|
1664
1570
|
version
|
|
1665
1571
|
} = params;
|
|
1666
|
-
const
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
options: {
|
|
1674
|
-
lt: `REV#${(0, _utils.zeroPad)(version)}`,
|
|
1675
|
-
/**
|
|
1676
|
-
* We need to have extra checks because DynamoDB will return published or latest record if there is no REV# record.
|
|
1677
|
-
*/
|
|
1678
|
-
filters: [{
|
|
1679
|
-
attr: "TYPE",
|
|
1680
|
-
eq: (0, _recordType.createRecordType)()
|
|
1681
|
-
}, {
|
|
1682
|
-
attr: "version",
|
|
1683
|
-
lt: version
|
|
1684
|
-
}],
|
|
1685
|
-
reverse: true
|
|
1686
|
-
}
|
|
1572
|
+
const partitionKey = createPartitionKey({
|
|
1573
|
+
tenant,
|
|
1574
|
+
id: entryId
|
|
1575
|
+
});
|
|
1576
|
+
const options = {
|
|
1577
|
+
beginsWith: `REV#`,
|
|
1578
|
+
reverse: true
|
|
1687
1579
|
};
|
|
1688
1580
|
try {
|
|
1689
|
-
const
|
|
1690
|
-
|
|
1581
|
+
const unfilteredEntries = (await entity.queryAll({
|
|
1582
|
+
partitionKey,
|
|
1583
|
+
options
|
|
1584
|
+
})).map(item => {
|
|
1585
|
+
return item.data;
|
|
1586
|
+
});
|
|
1587
|
+
const entries = unfilteredEntries.filter(item => {
|
|
1588
|
+
return item.version < version;
|
|
1589
|
+
});
|
|
1590
|
+
const entry = entries[0];
|
|
1691
1591
|
if (!entry) {
|
|
1692
1592
|
return null;
|
|
1693
1593
|
}
|
|
1694
|
-
return
|
|
1594
|
+
return convertEntryKeysFromStorage({
|
|
1695
1595
|
entry,
|
|
1696
1596
|
model
|
|
1697
1597
|
});
|
|
1698
1598
|
} catch (ex) {
|
|
1699
|
-
throw new
|
|
1599
|
+
throw new WebinyError(ex.message || "Could not get previous version of given entry.", ex.code || "GET_PREVIOUS_VERSION_ERROR", {
|
|
1700
1600
|
...params,
|
|
1701
1601
|
error: ex,
|
|
1702
|
-
partitionKey
|
|
1703
|
-
options
|
|
1602
|
+
partitionKey,
|
|
1603
|
+
options,
|
|
1704
1604
|
model
|
|
1705
1605
|
});
|
|
1706
1606
|
}
|
|
@@ -1712,10 +1612,10 @@ const createEntriesStorageOperations = params => {
|
|
|
1712
1612
|
} = params;
|
|
1713
1613
|
const {
|
|
1714
1614
|
index
|
|
1715
|
-
} =
|
|
1615
|
+
} = configurations.es({
|
|
1716
1616
|
model
|
|
1717
1617
|
});
|
|
1718
|
-
const initialBody =
|
|
1618
|
+
const initialBody = createElasticsearchBody({
|
|
1719
1619
|
model,
|
|
1720
1620
|
params: {
|
|
1721
1621
|
limit: 1,
|
|
@@ -1725,7 +1625,7 @@ const createEntriesStorageOperations = params => {
|
|
|
1725
1625
|
});
|
|
1726
1626
|
const field = model.fields.find(f => f.fieldId === fieldId);
|
|
1727
1627
|
if (!field) {
|
|
1728
|
-
throw new
|
|
1628
|
+
throw new WebinyError(`Could not find field with given "fieldId" value.`, "FIELD_NOT_FOUND", {
|
|
1729
1629
|
fieldId
|
|
1730
1630
|
});
|
|
1731
1631
|
}
|
|
@@ -1750,12 +1650,12 @@ const createEntriesStorageOperations = params => {
|
|
|
1750
1650
|
index,
|
|
1751
1651
|
body
|
|
1752
1652
|
});
|
|
1753
|
-
} catch (
|
|
1754
|
-
if (
|
|
1653
|
+
} catch (error) {
|
|
1654
|
+
if (shouldIgnoreEsResponseError(error)) {
|
|
1755
1655
|
return [];
|
|
1756
1656
|
}
|
|
1757
|
-
throw new
|
|
1758
|
-
error
|
|
1657
|
+
throw new WebinyError(error.message || "Error in the Elasticsearch query.", error.code || "OPENSEARCH_ERROR", {
|
|
1658
|
+
error,
|
|
1759
1659
|
index,
|
|
1760
1660
|
model,
|
|
1761
1661
|
body
|
|
@@ -1795,6 +1695,5 @@ const createEntriesStorageOperations = params => {
|
|
|
1795
1695
|
dataLoaders
|
|
1796
1696
|
};
|
|
1797
1697
|
};
|
|
1798
|
-
exports.createEntriesStorageOperations = createEntriesStorageOperations;
|
|
1799
1698
|
|
|
1800
1699
|
//# sourceMappingURL=index.js.map
|