@webiny/api-headless-cms-ddb-es 0.0.0-unstable.615a930a68 → 0.0.0-unstable.61c048f412
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 +12 -6
- package/configurations.js +20 -26
- package/configurations.js.map +1 -1
- package/definitions/entry.d.ts +4 -5
- package/definitions/entry.js +6 -83
- package/definitions/entry.js.map +1 -1
- package/definitions/group.d.ts +6 -6
- package/definitions/group.js +6 -63
- package/definitions/group.js.map +1 -1
- package/definitions/model.d.ts +6 -6
- package/definitions/model.js +6 -85
- 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 -1
- package/dynamoDb/index.js +8 -16
- package/dynamoDb/index.js.map +1 -1
- package/dynamoDb/storage/longText.d.ts +1 -1
- package/dynamoDb/storage/longText.js +21 -34
- package/dynamoDb/storage/longText.js.map +1 -1
- package/dynamoDb/storage/richText.d.ts +1 -6
- package/dynamoDb/storage/richText.js +28 -105
- package/dynamoDb/storage/richText.js.map +1 -1
- package/elasticsearch/createElasticsearchIndex.d.ts +4 -4
- package/elasticsearch/createElasticsearchIndex.js +22 -50
- package/elasticsearch/createElasticsearchIndex.js.map +1 -1
- package/elasticsearch/deleteElasticsearchIndex.d.ts +3 -3
- package/elasticsearch/deleteElasticsearchIndex.js +7 -19
- package/elasticsearch/deleteElasticsearchIndex.js.map +1 -1
- package/elasticsearch/index.d.ts +1 -1
- package/elasticsearch/index.js +4 -15
- package/elasticsearch/index.js.map +1 -1
- package/elasticsearch/indexing/dateTimeIndexing.d.ts +1 -1
- package/elasticsearch/indexing/dateTimeIndexing.js +8 -30
- package/elasticsearch/indexing/dateTimeIndexing.js.map +1 -1
- package/elasticsearch/indexing/defaultFieldIndexing.d.ts +1 -1
- package/elasticsearch/indexing/defaultFieldIndexing.js +17 -17
- package/elasticsearch/indexing/defaultFieldIndexing.js.map +1 -1
- package/elasticsearch/indexing/index.d.ts +1 -1
- package/elasticsearch/indexing/index.js +10 -24
- package/elasticsearch/indexing/index.js.map +1 -1
- package/elasticsearch/indexing/jsonIndexing.d.ts +2 -0
- package/elasticsearch/indexing/jsonIndexing.js +21 -0
- package/elasticsearch/indexing/jsonIndexing.js.map +1 -0
- package/elasticsearch/indexing/longTextIndexing.d.ts +1 -1
- package/elasticsearch/indexing/longTextIndexing.js +4 -21
- package/elasticsearch/indexing/longTextIndexing.js.map +1 -1
- package/elasticsearch/indexing/numberIndexing.d.ts +1 -1
- package/elasticsearch/indexing/numberIndexing.js +2 -16
- package/elasticsearch/indexing/numberIndexing.js.map +1 -1
- package/elasticsearch/indexing/objectIndexing.d.ts +1 -1
- package/elasticsearch/indexing/objectIndexing.js +23 -52
- package/elasticsearch/indexing/objectIndexing.js.map +1 -1
- package/elasticsearch/indexing/richTextIndexing.d.ts +1 -1
- package/elasticsearch/indexing/richTextIndexing.js +2 -12
- package/elasticsearch/indexing/richTextIndexing.js.map +1 -1
- package/elasticsearch/indices/base.d.ts +1 -1
- package/elasticsearch/indices/base.js +5 -13
- package/elasticsearch/indices/base.js.map +1 -1
- package/elasticsearch/indices/index.d.ts +1 -1
- package/elasticsearch/indices/index.js +4 -14
- package/elasticsearch/indices/index.js.map +1 -1
- package/elasticsearch/search/index.d.ts +1 -1
- package/elasticsearch/search/index.js +5 -13
- package/elasticsearch/search/index.js.map +1 -1
- package/elasticsearch/search/refSearch.d.ts +1 -1
- package/elasticsearch/search/refSearch.js +4 -15
- 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 +5 -18
- package/elasticsearch/search/timeSearch.js.map +1 -1
- package/helpers/entryIndexHelpers.d.ts +10 -10
- package/helpers/entryIndexHelpers.js +76 -84
- package/helpers/entryIndexHelpers.js.map +1 -1
- package/helpers/fieldIdentifier.d.ts +6 -0
- package/helpers/fieldIdentifier.js +35 -0
- package/helpers/fieldIdentifier.js.map +1 -0
- package/helpers/index.d.ts +2 -1
- package/helpers/index.js +3 -17
- package/helpers/index.js.map +1 -1
- package/index.d.ts +2 -2
- package/index.js +119 -204
- package/index.js.map +1 -1
- package/operations/entry/dataLoader/DataLoaderCache.d.ts +15 -0
- package/operations/entry/dataLoader/DataLoaderCache.js +34 -0
- package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -0
- package/operations/entry/dataLoader/constants.d.ts +1 -0
- package/operations/entry/dataLoader/constants.js +4 -0
- package/operations/entry/dataLoader/constants.js.map +1 -0
- package/operations/entry/dataLoader/createBatchScheduleFn.d.ts +8 -0
- package/operations/entry/dataLoader/createBatchScheduleFn.js +19 -0
- package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -0
- package/operations/entry/dataLoader/getAllEntryRevisions.d.ts +4 -0
- package/operations/entry/dataLoader/getAllEntryRevisions.js +32 -0
- package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -0
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.d.ts +4 -0
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +40 -0
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -0
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.d.ts +4 -0
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +40 -0
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -0
- package/operations/entry/dataLoader/getRevisionById.d.ts +4 -0
- package/operations/entry/dataLoader/getRevisionById.js +50 -0
- package/operations/entry/dataLoader/getRevisionById.js.map +1 -0
- package/operations/entry/dataLoader/index.d.ts +8 -0
- package/operations/entry/dataLoader/index.js +19 -0
- package/operations/entry/dataLoader/index.js.map +1 -0
- package/operations/entry/dataLoader/types.d.ts +5 -0
- package/operations/entry/dataLoader/types.js +3 -0
- package/operations/entry/dataLoader/types.js.map +1 -0
- package/operations/entry/dataLoaders.d.ts +17 -38
- package/operations/entry/dataLoaders.js +55 -314
- package/operations/entry/dataLoaders.js.map +1 -1
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.d.ts +18 -0
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js +27 -0
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js.map +1 -0
- package/operations/entry/elasticsearch/body.d.ts +3 -3
- package/operations/entry/elasticsearch/body.js +28 -55
- package/operations/entry/elasticsearch/body.js.map +1 -1
- package/operations/entry/elasticsearch/fields.d.ts +6 -5
- package/operations/entry/elasticsearch/fields.js +274 -121
- 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 +11 -25
- 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 +60 -96
- 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 +2 -17
- 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 +10 -24
- 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 +8 -21
- 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 +6 -16
- 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 +10 -27
- 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 +16 -25
- 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 +3 -15
- 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 +5 -17
- package/operations/entry/elasticsearch/filtering/values.js.map +1 -1
- package/operations/entry/elasticsearch/fullTextSearch.d.ts +5 -2
- package/operations/entry/elasticsearch/fullTextSearch.js +72 -21
- package/operations/entry/elasticsearch/fullTextSearch.js.map +1 -1
- package/operations/entry/elasticsearch/fullTextSearchFields.d.ts +1 -1
- package/operations/entry/elasticsearch/fullTextSearchFields.js +10 -42
- package/operations/entry/elasticsearch/fullTextSearchFields.js.map +1 -1
- package/operations/entry/elasticsearch/initialQuery.d.ts +2 -2
- package/operations/entry/elasticsearch/initialQuery.js +15 -44
- package/operations/entry/elasticsearch/initialQuery.js.map +1 -1
- package/operations/entry/elasticsearch/keyword.d.ts +1 -1
- package/operations/entry/elasticsearch/keyword.js +5 -12
- 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 +4 -12
- 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 +5 -26
- 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 +4 -12
- 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 +6 -18
- 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 +4 -12
- 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 +64 -49
- package/operations/entry/elasticsearch/sort.js.map +1 -1
- package/operations/entry/elasticsearch/transformValueForSearch.d.ts +2 -2
- package/operations/entry/elasticsearch/transformValueForSearch.js +5 -12
- package/operations/entry/elasticsearch/transformValueForSearch.js.map +1 -1
- package/operations/entry/elasticsearch/types.d.ts +8 -8
- package/operations/entry/elasticsearch/types.js +2 -4
- package/operations/entry/elasticsearch/types.js.map +1 -1
- package/operations/entry/index.d.ts +7 -6
- package/operations/entry/index.js +1184 -736
- package/operations/entry/index.js.map +1 -1
- package/operations/entry/keys.d.ts +31 -1
- package/operations/entry/keys.js +57 -27
- package/operations/entry/keys.js.map +1 -1
- package/operations/entry/recordType.js +4 -17
- package/operations/entry/recordType.js.map +1 -1
- package/operations/entry/transformations/convertEntryKeys.d.ts +8 -0
- package/operations/entry/transformations/convertEntryKeys.js +30 -0
- package/operations/entry/transformations/convertEntryKeys.js.map +1 -0
- package/operations/entry/transformations/index.d.ts +29 -0
- package/operations/entry/transformations/index.js +119 -0
- package/operations/entry/transformations/index.js.map +1 -0
- package/operations/entry/transformations/modifyEntryValues.d.ts +51 -0
- package/operations/entry/transformations/modifyEntryValues.js +21 -0
- package/operations/entry/transformations/modifyEntryValues.js.map +1 -0
- package/operations/entry/transformations/transformEntryKeys.d.ts +11 -0
- package/operations/entry/transformations/transformEntryKeys.js +20 -0
- package/operations/entry/transformations/transformEntryKeys.js.map +1 -0
- package/operations/entry/transformations/transformEntryToIndex.d.ts +10 -0
- package/operations/entry/transformations/transformEntryToIndex.js +24 -0
- package/operations/entry/transformations/transformEntryToIndex.js.map +1 -0
- package/operations/group/index.d.ts +6 -5
- package/operations/group/index.js +47 -97
- package/operations/group/index.js.map +1 -1
- package/operations/model/index.d.ts +4 -4
- package/operations/model/index.js +38 -78
- package/operations/model/index.js.map +1 -1
- package/package.json +35 -37
- package/plugins/CmsElasticsearchModelFieldPlugin.d.ts +69 -0
- package/plugins/CmsElasticsearchModelFieldPlugin.js +46 -0
- package/plugins/CmsElasticsearchModelFieldPlugin.js.map +1 -0
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.d.ts +4 -2
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js +7 -18
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.d.ts +23 -0
- package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js +19 -0
- package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js.map +1 -0
- package/plugins/CmsEntryElasticsearchIndexPlugin.js +5 -16
- package/plugins/CmsEntryElasticsearchIndexPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.d.ts +4 -2
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js +11 -22
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.d.ts +4 -2
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js +7 -18
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.d.ts +4 -2
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.js +7 -18
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchValuesModifier.d.ts +33 -0
- package/plugins/CmsEntryElasticsearchValuesModifier.js +42 -0
- package/plugins/CmsEntryElasticsearchValuesModifier.js.map +1 -0
- package/plugins/CmsEntryFilterPlugin.d.ts +3 -3
- package/plugins/CmsEntryFilterPlugin.js +5 -21
- package/plugins/CmsEntryFilterPlugin.js.map +1 -1
- package/plugins/index.d.ts +8 -6
- package/plugins/index.js +10 -83
- package/plugins/index.js.map +1 -1
- package/tasks/createIndexTaskPlugin.d.ts +2 -0
- package/tasks/createIndexTaskPlugin.js +41 -0
- package/tasks/createIndexTaskPlugin.js.map +1 -0
- package/types.d.ts +38 -36
- package/types.js +5 -13
- 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 -42
- package/definitions/entryElasticsearch.js.map +0 -1
- package/definitions/settings.d.ts +0 -8
- package/definitions/settings.js +0 -58
- package/definitions/settings.js.map +0 -1
- package/definitions/system.d.ts +0 -8
- package/definitions/system.js +0 -46
- package/definitions/system.js.map +0 -1
- package/definitions/table.d.ts +0 -8
- package/definitions/table.js +0 -24
- package/definitions/table.js.map +0 -1
- package/definitions/tableElasticsearch.d.ts +0 -8
- package/definitions/tableElasticsearch.js +0 -24
- package/definitions/tableElasticsearch.js.map +0 -1
- package/dynamoDb/storage/date.d.ts +0 -2
- package/dynamoDb/storage/date.js +0 -99
- package/dynamoDb/storage/date.js.map +0 -1
- package/elasticsearch/indices/japanese.d.ts +0 -2
- package/elasticsearch/indices/japanese.js +0 -16
- package/elasticsearch/indices/japanese.js.map +0 -1
- package/helpers/createElasticsearchQueryBody.d.ts +0 -11
- package/helpers/createElasticsearchQueryBody.js +0 -618
- package/helpers/createElasticsearchQueryBody.js.map +0 -1
- package/helpers/fields.d.ts +0 -19
- package/helpers/fields.js +0 -196
- package/helpers/fields.js.map +0 -1
- package/helpers/searchPluginsList.d.ts +0 -6
- package/helpers/searchPluginsList.js +0 -26
- package/helpers/searchPluginsList.js.map +0 -1
- package/helpers/transformValueForSearch.d.ts +0 -12
- package/helpers/transformValueForSearch.js +0 -29
- package/helpers/transformValueForSearch.js.map +0 -1
- package/operations/entry/elasticsearchFields.d.ts +0 -2
- package/operations/entry/elasticsearchFields.js +0 -38
- package/operations/entry/elasticsearchFields.js.map +0 -1
- package/operations/settings/index.d.ts +0 -6
- package/operations/settings/index.js +0 -135
- package/operations/settings/index.js.map +0 -1
- package/operations/system/index.d.ts +0 -6
- package/operations/system/index.js +0 -99
- package/operations/system/index.js.map +0 -1
- package/plugins/CmsEntryElasticsearchFieldPlugin.d.ts +0 -12
- package/plugins/CmsEntryElasticsearchFieldPlugin.js +0 -24
- package/plugins/CmsEntryElasticsearchFieldPlugin.js.map +0 -1
|
@@ -1,48 +1,33 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.createLongTextStorageTransformPlugin = void 0;
|
|
9
|
-
|
|
10
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
11
|
-
|
|
12
|
-
var _gzip = require("@webiny/utils/compression/gzip");
|
|
13
|
-
|
|
14
|
-
var _apiHeadlessCms = require("@webiny/api-headless-cms");
|
|
15
|
-
|
|
16
1
|
/**
|
|
17
2
|
* File is @internal
|
|
18
3
|
*/
|
|
4
|
+
|
|
5
|
+
import WebinyError from "@webiny/error";
|
|
6
|
+
import { compress as gzip, decompress as ungzip } from "@webiny/utils/compression/gzip.js";
|
|
7
|
+
import { StorageTransformPlugin } from "@webiny/api-headless-cms";
|
|
19
8
|
const GZIP = "gzip";
|
|
20
9
|
const TO_STORAGE_ENCODING = "base64";
|
|
21
10
|
const FROM_STORAGE_ENCODING = "utf8";
|
|
22
|
-
|
|
23
11
|
const convertToBuffer = value => {
|
|
24
12
|
if (typeof value === "string") {
|
|
25
13
|
return Buffer.from(value, TO_STORAGE_ENCODING);
|
|
26
14
|
}
|
|
27
|
-
|
|
28
15
|
return value;
|
|
29
16
|
};
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
|
|
17
|
+
export const createLongTextStorageTransformPlugin = () => {
|
|
18
|
+
const plugin = new StorageTransformPlugin({
|
|
19
|
+
name: "headless-cms.storage-transform.long-text.default",
|
|
33
20
|
fieldType: "long-text",
|
|
34
21
|
fromStorage: async ({
|
|
35
22
|
field,
|
|
36
23
|
value: storageValue
|
|
37
24
|
}) => {
|
|
38
25
|
const typeOf = typeof storageValue;
|
|
39
|
-
|
|
40
26
|
if (!storageValue || typeOf === "string" || typeOf === "number" || Array.isArray(storageValue) === true) {
|
|
41
27
|
return storageValue;
|
|
42
28
|
} else if (typeOf !== "object") {
|
|
43
|
-
throw new
|
|
29
|
+
throw new WebinyError(`LongText value received in "fromStorage" function is not an object in field "${field.storageId}" - ${field.fieldId}.`);
|
|
44
30
|
}
|
|
45
|
-
|
|
46
31
|
const {
|
|
47
32
|
compression,
|
|
48
33
|
value,
|
|
@@ -51,25 +36,21 @@ const createLongTextStorageTransformPlugin = () => {
|
|
|
51
36
|
/**
|
|
52
37
|
* Check if possibly undefined, null, empty...
|
|
53
38
|
*/
|
|
54
|
-
|
|
55
39
|
if (!compression) {
|
|
56
|
-
throw new
|
|
40
|
+
throw new WebinyError(`Missing compression in "fromStorage" function in field "${field.storageId}" - ${field.fieldId}.": ${JSON.stringify(storageValue)}.`, "MISSING_COMPRESSION", {
|
|
57
41
|
value: storageValue
|
|
58
42
|
});
|
|
59
43
|
} else if (compression !== GZIP) {
|
|
60
|
-
throw new
|
|
44
|
+
throw new WebinyError(`This plugin cannot transform something not compressed with "GZIP".`, "WRONG_COMPRESSION", {
|
|
61
45
|
compression
|
|
62
46
|
});
|
|
63
47
|
}
|
|
64
|
-
|
|
65
48
|
try {
|
|
66
|
-
const buf = await (
|
|
49
|
+
const buf = await ungzip(convertToBuffer(value));
|
|
67
50
|
const result = buf.toString(FROM_STORAGE_ENCODING);
|
|
68
|
-
|
|
69
51
|
if (!isArray) {
|
|
70
52
|
return result;
|
|
71
53
|
}
|
|
72
|
-
|
|
73
54
|
return JSON.parse(result);
|
|
74
55
|
} catch (ex) {
|
|
75
56
|
console.log("Error while transforming long-text.");
|
|
@@ -80,22 +61,28 @@ const createLongTextStorageTransformPlugin = () => {
|
|
|
80
61
|
toStorage: async ({
|
|
81
62
|
value: initialValue
|
|
82
63
|
}) => {
|
|
64
|
+
/**
|
|
65
|
+
* There is a possibility that we are trying to compress already compressed value.
|
|
66
|
+
*/
|
|
67
|
+
if (initialValue && initialValue.hasOwnProperty("compression") === true) {
|
|
68
|
+
return initialValue;
|
|
69
|
+
}
|
|
83
70
|
const isArray = Array.isArray(initialValue);
|
|
84
71
|
const value = isArray ? JSON.stringify(initialValue) : initialValue;
|
|
85
|
-
const compressedValue = await (
|
|
72
|
+
const compressedValue = await gzip(value);
|
|
86
73
|
const result = {
|
|
87
74
|
compression: GZIP,
|
|
88
75
|
value: compressedValue.toString(TO_STORAGE_ENCODING)
|
|
89
76
|
};
|
|
90
|
-
|
|
91
77
|
if (!isArray) {
|
|
92
78
|
return result;
|
|
93
79
|
}
|
|
94
|
-
|
|
95
80
|
result.isArray = isArray;
|
|
96
81
|
return result;
|
|
97
82
|
}
|
|
98
83
|
});
|
|
84
|
+
plugin.name = plugin.name = `headless-cms.dynamodb.storageTransform.long-text`;
|
|
85
|
+
return plugin;
|
|
99
86
|
};
|
|
100
87
|
|
|
101
|
-
|
|
88
|
+
//# sourceMappingURL=longText.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["GZIP","TO_STORAGE_ENCODING","FROM_STORAGE_ENCODING","convertToBuffer","value","Buffer","from","createLongTextStorageTransformPlugin","
|
|
1
|
+
{"version":3,"names":["WebinyError","compress","gzip","decompress","ungzip","StorageTransformPlugin","GZIP","TO_STORAGE_ENCODING","FROM_STORAGE_ENCODING","convertToBuffer","value","Buffer","from","createLongTextStorageTransformPlugin","plugin","name","fieldType","fromStorage","field","storageValue","typeOf","Array","isArray","storageId","fieldId","compression","JSON","stringify","buf","result","toString","parse","ex","console","log","message","toStorage","initialValue","hasOwnProperty","compressedValue"],"sources":["longText.ts"],"sourcesContent":["/**\n * File is @internal\n */\n\nimport WebinyError from \"@webiny/error\";\nimport { compress as gzip, decompress as ungzip } from \"@webiny/utils/compression/gzip.js\";\nimport { StorageTransformPlugin } from \"@webiny/api-headless-cms\";\n\nconst GZIP = \"gzip\";\nconst TO_STORAGE_ENCODING = \"base64\";\nconst FROM_STORAGE_ENCODING = \"utf8\";\n\nconst convertToBuffer = (value: string | Buffer): Buffer => {\n if (typeof value === \"string\") {\n return Buffer.from(value, TO_STORAGE_ENCODING);\n }\n return value;\n};\n\nexport interface StorageValue {\n compression: string;\n value: string;\n isArray?: boolean;\n}\n\nexport const createLongTextStorageTransformPlugin = () => {\n const plugin = new StorageTransformPlugin<string | string[], StorageValue>({\n name: \"headless-cms.storage-transform.long-text.default\",\n fieldType: \"long-text\",\n fromStorage: async ({ field, value: storageValue }) => {\n const typeOf = typeof storageValue;\n if (\n !storageValue ||\n typeOf === \"string\" ||\n typeOf === \"number\" ||\n Array.isArray(storageValue) === true\n ) {\n return storageValue as unknown as string | string[];\n } else if (typeOf !== \"object\") {\n throw new WebinyError(\n `LongText value received in \"fromStorage\" function is not an object in field \"${field.storageId}\" - ${field.fieldId}.`\n );\n }\n const { compression, value, isArray } = storageValue;\n /**\n * Check if possibly undefined, null, empty...\n */\n if (!compression) {\n throw new WebinyError(\n `Missing compression in \"fromStorage\" function in field \"${\n field.storageId\n }\" - ${field.fieldId}.\": ${JSON.stringify(storageValue)}.`,\n \"MISSING_COMPRESSION\",\n {\n value: storageValue\n }\n );\n } else if (compression !== GZIP) {\n throw new WebinyError(\n `This plugin cannot transform something not compressed with \"GZIP\".`,\n \"WRONG_COMPRESSION\",\n {\n compression\n }\n );\n }\n try {\n const buf = await ungzip(convertToBuffer(value));\n const result = buf.toString(FROM_STORAGE_ENCODING);\n if (!isArray) {\n return result;\n }\n return JSON.parse(result);\n } catch (ex) {\n console.log(\"Error while transforming long-text.\");\n console.log(ex.message);\n return \"\";\n }\n },\n toStorage: async ({ value: initialValue }) => {\n /**\n * There is a possibility that we are trying to compress already compressed value.\n */\n if (initialValue && initialValue.hasOwnProperty(\"compression\") === true) {\n return initialValue as unknown as StorageValue;\n }\n const isArray = Array.isArray(initialValue);\n const value = isArray ? JSON.stringify(initialValue) : initialValue;\n const compressedValue = await gzip(value);\n\n const result: StorageValue = {\n compression: GZIP,\n value: compressedValue.toString(TO_STORAGE_ENCODING)\n };\n if (!isArray) {\n return result;\n }\n result.isArray = isArray;\n return result;\n }\n });\n plugin.name = plugin.name = `headless-cms.dynamodb.storageTransform.long-text`;\n\n return plugin;\n};\n"],"mappings":"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","ignoreList":[]}
|
|
@@ -1,7 +1,2 @@
|
|
|
1
1
|
import { StorageTransformPlugin } from "@webiny/api-headless-cms";
|
|
2
|
-
export declare
|
|
3
|
-
export interface StorageValue {
|
|
4
|
-
compression: string;
|
|
5
|
-
value: any;
|
|
6
|
-
}
|
|
7
|
-
export declare const createRichTextStorageTransformPlugin: () => StorageTransformPlugin<any, any>;
|
|
2
|
+
export declare const createRichTextStorageTransformPlugin: () => StorageTransformPlugin<any, any, import("@webiny/api-headless-cms/types").CmsModelField>;
|
|
@@ -1,128 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
});
|
|
8
|
-
exports.createRichTextStorageTransformPlugin = void 0;
|
|
9
|
-
|
|
10
|
-
var _jsonpack = _interopRequireDefault(require("jsonpack"));
|
|
11
|
-
|
|
12
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
13
|
-
|
|
14
|
-
var _apiHeadlessCms = require("@webiny/api-headless-cms");
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Remove when jsonpack gets PR with a fix merged
|
|
18
|
-
* https://github.com/rgcl/jsonpack/pull/25/files
|
|
19
|
-
* NOTE 2021-07-28: it seems PR is not going to be merged so keep this.
|
|
20
|
-
*/
|
|
21
|
-
// TODO @ts-refactor figure better type
|
|
22
|
-
const transformArray = value => {
|
|
23
|
-
if (!value) {
|
|
24
|
-
return value;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
let isArray = Array.isArray(value);
|
|
28
|
-
const shouldBeArray = value instanceof Array === false && isArray;
|
|
29
|
-
|
|
30
|
-
if (shouldBeArray) {
|
|
31
|
-
value = Array.from(value);
|
|
32
|
-
isArray = true;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (typeof value === "object" || isArray) {
|
|
36
|
-
for (const k in value) {
|
|
37
|
-
value[k] = transformArray(value[k]);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return value;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const createRichTextStorageTransformPlugin = () => {
|
|
45
|
-
return new _apiHeadlessCms.StorageTransformPlugin({
|
|
1
|
+
import WebinyError from "@webiny/error";
|
|
2
|
+
import { StorageTransformPlugin } from "@webiny/api-headless-cms";
|
|
3
|
+
import { CompressorPlugin } from "@webiny/api";
|
|
4
|
+
export const createRichTextStorageTransformPlugin = () => {
|
|
5
|
+
const plugin = new StorageTransformPlugin({
|
|
6
|
+
name: "headless-cms.storage-transform.rich-text.default",
|
|
46
7
|
fieldType: "rich-text",
|
|
47
8
|
fromStorage: async ({
|
|
48
9
|
field,
|
|
49
|
-
value: storageValue
|
|
10
|
+
value: storageValue,
|
|
11
|
+
plugins
|
|
50
12
|
}) => {
|
|
51
13
|
if (!storageValue) {
|
|
52
14
|
return storageValue;
|
|
53
15
|
} else if (typeof storageValue !== "object") {
|
|
54
|
-
throw new
|
|
16
|
+
throw new WebinyError(`RichText value received in "fromStorage" function is not an object in field "${field.storageId}" - ${field.fieldId}.`);
|
|
55
17
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
if (storageValue.hasOwnProperty("compression") === false) {
|
|
18
|
+
let compressor;
|
|
19
|
+
try {
|
|
20
|
+
compressor = plugins.oneByType(CompressorPlugin.type);
|
|
21
|
+
} catch {
|
|
63
22
|
return storageValue;
|
|
64
23
|
}
|
|
65
|
-
|
|
66
|
-
const {
|
|
67
|
-
compression,
|
|
68
|
-
value
|
|
69
|
-
} = storageValue;
|
|
70
|
-
|
|
71
|
-
if (!compression) {
|
|
72
|
-
throw new _error.default(`Missing compression in "fromStorage" function in field "${field.storageId}": ${JSON.stringify(storageValue)}.`, "MISSING_COMPRESSION", {
|
|
73
|
-
value: storageValue
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if (compression !== "jsonpack") {
|
|
78
|
-
throw new _error.default(`This plugin cannot transform something not packed with "jsonpack".`, "WRONG_COMPRESSION", {
|
|
79
|
-
compression
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
|
|
83
24
|
try {
|
|
84
|
-
return
|
|
85
|
-
} catch
|
|
86
|
-
|
|
87
|
-
return null;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
console.log("Error while decompressing rich-text.");
|
|
91
|
-
console.log(ex.message);
|
|
92
|
-
return null;
|
|
25
|
+
return await compressor.getCompressor().decompress(storageValue);
|
|
26
|
+
} catch {
|
|
27
|
+
return storageValue;
|
|
93
28
|
}
|
|
94
29
|
},
|
|
95
30
|
toStorage: async ({
|
|
96
|
-
value
|
|
31
|
+
value,
|
|
32
|
+
plugins
|
|
97
33
|
}) => {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
if (value && value.hasOwnProperty("compression") === true) {
|
|
34
|
+
let compressor;
|
|
35
|
+
try {
|
|
36
|
+
compressor = plugins.oneByType(CompressorPlugin.type);
|
|
37
|
+
} catch {
|
|
103
38
|
return value;
|
|
104
39
|
}
|
|
105
|
-
|
|
106
|
-
value = transformArray(value);
|
|
107
|
-
let jsonValue = null;
|
|
108
|
-
|
|
109
40
|
try {
|
|
110
|
-
|
|
111
|
-
} catch
|
|
112
|
-
|
|
113
|
-
return null;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
console.log("Error while compressing rich-text.");
|
|
117
|
-
console.log(ex.message);
|
|
41
|
+
return await compressor.getCompressor().compress(value);
|
|
42
|
+
} catch {
|
|
43
|
+
return value;
|
|
118
44
|
}
|
|
119
|
-
|
|
120
|
-
return {
|
|
121
|
-
compression: "jsonpack",
|
|
122
|
-
value: jsonValue
|
|
123
|
-
};
|
|
124
45
|
}
|
|
125
46
|
});
|
|
47
|
+
plugin.name = `headless-cms.dynamodb.storageTransform.rich-text`;
|
|
48
|
+
return plugin;
|
|
126
49
|
};
|
|
127
50
|
|
|
128
|
-
|
|
51
|
+
//# sourceMappingURL=richText.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["WebinyError","StorageTransformPlugin","CompressorPlugin","createRichTextStorageTransformPlugin","plugin","name","fieldType","fromStorage","field","value","storageValue","plugins","storageId","fieldId","compressor","oneByType","type","getCompressor","decompress","toStorage","compress"],"sources":["richText.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { StorageTransformPlugin } from \"@webiny/api-headless-cms\";\nimport { CompressorPlugin } from \"@webiny/api\";\n\nexport const createRichTextStorageTransformPlugin = () => {\n const plugin = new StorageTransformPlugin({\n name: \"headless-cms.storage-transform.rich-text.default\",\n fieldType: \"rich-text\",\n fromStorage: async ({ field, value: storageValue, plugins }) => {\n if (!storageValue) {\n return storageValue;\n } else if (typeof storageValue !== \"object\") {\n throw new WebinyError(\n `RichText value received in \"fromStorage\" function is not an object in field \"${field.storageId}\" - ${field.fieldId}.`\n );\n }\n\n let compressor: CompressorPlugin;\n\n try {\n compressor = plugins.oneByType<CompressorPlugin>(CompressorPlugin.type);\n } catch {\n return storageValue;\n }\n\n try {\n return await compressor.getCompressor().decompress(storageValue);\n } catch {\n return storageValue;\n }\n },\n toStorage: async ({ value, plugins }) => {\n let compressor: CompressorPlugin;\n\n try {\n compressor = plugins.oneByType<CompressorPlugin>(CompressorPlugin.type);\n } catch {\n return value;\n }\n try {\n return await compressor.getCompressor().compress(value);\n } catch {\n return value;\n }\n }\n });\n plugin.name = `headless-cms.dynamodb.storageTransform.rich-text`;\n\n return plugin;\n};\n"],"mappings":"AAAA,OAAOA,WAAW,MAAM,eAAe;AACvC,SAASC,sBAAsB,QAAQ,0BAA0B;AACjE,SAASC,gBAAgB,QAAQ,aAAa;AAE9C,OAAO,MAAMC,oCAAoC,GAAGA,CAAA,KAAM;EACtD,MAAMC,MAAM,GAAG,IAAIH,sBAAsB,CAAC;IACtCI,IAAI,EAAE,kDAAkD;IACxDC,SAAS,EAAE,WAAW;IACtBC,WAAW,EAAE,MAAAA,CAAO;MAAEC,KAAK;MAAEC,KAAK,EAAEC,YAAY;MAAEC;IAAQ,CAAC,KAAK;MAC5D,IAAI,CAACD,YAAY,EAAE;QACf,OAAOA,YAAY;MACvB,CAAC,MAAM,IAAI,OAAOA,YAAY,KAAK,QAAQ,EAAE;QACzC,MAAM,IAAIV,WAAW,CACjB,gFAAgFQ,KAAK,CAACI,SAAS,OAAOJ,KAAK,CAACK,OAAO,GACvH,CAAC;MACL;MAEA,IAAIC,UAA4B;MAEhC,IAAI;QACAA,UAAU,GAAGH,OAAO,CAACI,SAAS,CAAmBb,gBAAgB,CAACc,IAAI,CAAC;MAC3E,CAAC,CAAC,MAAM;QACJ,OAAON,YAAY;MACvB;MAEA,IAAI;QACA,OAAO,MAAMI,UAAU,CAACG,aAAa,CAAC,CAAC,CAACC,UAAU,CAACR,YAAY,CAAC;MACpE,CAAC,CAAC,MAAM;QACJ,OAAOA,YAAY;MACvB;IACJ,CAAC;IACDS,SAAS,EAAE,MAAAA,CAAO;MAAEV,KAAK;MAAEE;IAAQ,CAAC,KAAK;MACrC,IAAIG,UAA4B;MAEhC,IAAI;QACAA,UAAU,GAAGH,OAAO,CAACI,SAAS,CAAmBb,gBAAgB,CAACc,IAAI,CAAC;MAC3E,CAAC,CAAC,MAAM;QACJ,OAAOP,KAAK;MAChB;MACA,IAAI;QACA,OAAO,MAAMK,UAAU,CAACG,aAAa,CAAC,CAAC,CAACG,QAAQ,CAACX,KAAK,CAAC;MAC3D,CAAC,CAAC,MAAM;QACJ,OAAOA,KAAK;MAChB;IACJ;EACJ,CAAC,CAAC;EACFL,MAAM,CAACC,IAAI,GAAG,kDAAkD;EAEhE,OAAOD,MAAM;AACjB,CAAC","ignoreList":[]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Client } from "@elastic/elasticsearch";
|
|
2
|
-
import { PluginsContainer } from "@webiny/plugins";
|
|
3
|
-
import { CmsModel } from "@webiny/api-headless-cms/types";
|
|
1
|
+
import type { Client } from "@elastic/elasticsearch";
|
|
2
|
+
import type { PluginsContainer } from "@webiny/plugins";
|
|
3
|
+
import type { CmsModel } from "@webiny/api-headless-cms/types/index.js";
|
|
4
4
|
export interface CreateElasticsearchIndexParams {
|
|
5
|
-
|
|
5
|
+
client: Client;
|
|
6
6
|
plugins: PluginsContainer;
|
|
7
7
|
model: CmsModel;
|
|
8
8
|
}
|
|
@@ -1,60 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.createElasticsearchIndex = void 0;
|
|
9
|
-
|
|
10
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
11
|
-
|
|
12
|
-
var _CmsEntryElasticsearchIndexPlugin = require("../plugins/CmsEntryElasticsearchIndexPlugin");
|
|
13
|
-
|
|
14
|
-
var _apiElasticsearch = require("@webiny/api-elasticsearch");
|
|
15
|
-
|
|
16
|
-
var _configurations = require("../configurations");
|
|
17
|
-
|
|
18
|
-
const createElasticsearchIndex = async params => {
|
|
1
|
+
import { CmsEntryElasticsearchIndexPlugin } from "../plugins/CmsEntryElasticsearchIndexPlugin.js";
|
|
2
|
+
import { createIndex } from "@webiny/api-elasticsearch";
|
|
3
|
+
import { configurations } from "../configurations.js";
|
|
4
|
+
export const createElasticsearchIndex = async params => {
|
|
19
5
|
const {
|
|
20
|
-
|
|
21
|
-
plugins
|
|
6
|
+
client,
|
|
7
|
+
plugins,
|
|
22
8
|
model
|
|
23
9
|
} = params;
|
|
24
|
-
const plugin = (0, _apiElasticsearch.getLastAddedIndexPlugin)({
|
|
25
|
-
container,
|
|
26
|
-
type: _CmsEntryElasticsearchIndexPlugin.CmsEntryElasticsearchIndexPlugin.type,
|
|
27
|
-
locale: model.locale
|
|
28
|
-
});
|
|
29
|
-
|
|
30
10
|
const {
|
|
31
11
|
index
|
|
32
|
-
} =
|
|
12
|
+
} = configurations.es({
|
|
33
13
|
model
|
|
34
14
|
});
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
15
|
+
await createIndex({
|
|
16
|
+
client,
|
|
17
|
+
index,
|
|
18
|
+
type: CmsEntryElasticsearchIndexPlugin.type,
|
|
19
|
+
tenant: model.tenant,
|
|
20
|
+
plugins,
|
|
21
|
+
onExists: () => {
|
|
22
|
+
console.log(`Elasticsearch index "${index}" for the CMS model "${model.name}" already exists.`);
|
|
23
|
+
},
|
|
24
|
+
onError: ex => {
|
|
25
|
+
console.error(`Could not create Elasticsearch index "${index}" for the CMS model "${model.name}".`);
|
|
26
|
+
console.error(ex);
|
|
27
|
+
return ex;
|
|
43
28
|
}
|
|
44
|
-
|
|
45
|
-
await elasticsearch.indices.create({
|
|
46
|
-
index,
|
|
47
|
-
body: plugin.body
|
|
48
|
-
});
|
|
49
|
-
} catch (ex) {
|
|
50
|
-
throw new _error.default(ex.message || "Could not create Elasticsearch index for the Headless CMS model.", ex.code || "CMS_ELASTICSEARCH_INDEX_ERROR", {
|
|
51
|
-
error: ex,
|
|
52
|
-
type: _CmsEntryElasticsearchIndexPlugin.CmsEntryElasticsearchIndexPlugin.type,
|
|
53
|
-
locale: model.locale,
|
|
54
|
-
tenant: model.tenant,
|
|
55
|
-
body: plugin.body
|
|
56
|
-
});
|
|
57
|
-
}
|
|
29
|
+
});
|
|
58
30
|
};
|
|
59
31
|
|
|
60
|
-
|
|
32
|
+
//# sourceMappingURL=createElasticsearchIndex.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["CmsEntryElasticsearchIndexPlugin","createIndex","configurations","createElasticsearchIndex","params","client","plugins","model","index","es","type","tenant","onExists","console","log","name","onError","ex","error"],"sources":["createElasticsearchIndex.ts"],"sourcesContent":["import type { Client } from \"@elastic/elasticsearch\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport { CmsEntryElasticsearchIndexPlugin } from \"~/plugins/CmsEntryElasticsearchIndexPlugin.js\";\nimport { createIndex } from \"@webiny/api-elasticsearch\";\nimport { configurations } from \"~/configurations.js\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\n\nexport interface CreateElasticsearchIndexParams {\n client: Client;\n plugins: PluginsContainer;\n model: CmsModel;\n}\n\nexport const createElasticsearchIndex = async (params: CreateElasticsearchIndexParams) => {\n const { client, plugins, model } = params;\n\n const { index } = configurations.es({\n model\n });\n\n await createIndex({\n client,\n index,\n type: CmsEntryElasticsearchIndexPlugin.type,\n tenant: model.tenant,\n plugins,\n onExists: () => {\n console.log(\n `Elasticsearch index \"${index}\" for the CMS model \"${model.name}\" already exists.`\n );\n },\n onError: ex => {\n console.error(\n `Could not create Elasticsearch index \"${index}\" for the CMS model \"${model.name}\".`\n );\n console.error(ex);\n return ex;\n }\n });\n};\n"],"mappings":"AAEA,SAASA,gCAAgC;AACzC,SAASC,WAAW,QAAQ,2BAA2B;AACvD,SAASC,cAAc;AASvB,OAAO,MAAMC,wBAAwB,GAAG,MAAOC,MAAsC,IAAK;EACtF,MAAM;IAAEC,MAAM;IAAEC,OAAO;IAAEC;EAAM,CAAC,GAAGH,MAAM;EAEzC,MAAM;IAAEI;EAAM,CAAC,GAAGN,cAAc,CAACO,EAAE,CAAC;IAChCF;EACJ,CAAC,CAAC;EAEF,MAAMN,WAAW,CAAC;IACdI,MAAM;IACNG,KAAK;IACLE,IAAI,EAAEV,gCAAgC,CAACU,IAAI;IAC3CC,MAAM,EAAEJ,KAAK,CAACI,MAAM;IACpBL,OAAO;IACPM,QAAQ,EAAEA,CAAA,KAAM;MACZC,OAAO,CAACC,GAAG,CACP,wBAAwBN,KAAK,wBAAwBD,KAAK,CAACQ,IAAI,mBACnE,CAAC;IACL,CAAC;IACDC,OAAO,EAAEC,EAAE,IAAI;MACXJ,OAAO,CAACK,KAAK,CACT,yCAAyCV,KAAK,wBAAwBD,KAAK,CAACQ,IAAI,IACpF,CAAC;MACDF,OAAO,CAACK,KAAK,CAACD,EAAE,CAAC;MACjB,OAAOA,EAAE;IACb;EACJ,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Client } from "@elastic/elasticsearch";
|
|
2
|
-
import { CmsModel } from "@webiny/api-headless-cms/types";
|
|
1
|
+
import type { Client } from "@elastic/elasticsearch";
|
|
2
|
+
import type { CmsModel } from "@webiny/api-headless-cms/types/index.js";
|
|
3
3
|
interface DeleteElasticsearchIndexParams {
|
|
4
|
-
|
|
4
|
+
client: Client;
|
|
5
5
|
model: CmsModel;
|
|
6
6
|
}
|
|
7
7
|
export declare const deleteElasticsearchIndex: (params: DeleteElasticsearchIndexParams) => Promise<void>;
|
|
@@ -1,36 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.deleteElasticsearchIndex = void 0;
|
|
7
|
-
|
|
8
|
-
var _configurations = require("../configurations");
|
|
9
|
-
|
|
10
|
-
const deleteElasticsearchIndex = async params => {
|
|
1
|
+
import { configurations } from "../configurations.js";
|
|
2
|
+
export const deleteElasticsearchIndex = async params => {
|
|
11
3
|
const {
|
|
12
|
-
|
|
4
|
+
client,
|
|
13
5
|
model
|
|
14
6
|
} = params;
|
|
15
|
-
|
|
16
7
|
const {
|
|
17
8
|
index
|
|
18
|
-
} =
|
|
9
|
+
} = configurations.es({
|
|
19
10
|
model
|
|
20
11
|
});
|
|
21
|
-
|
|
22
12
|
const {
|
|
23
13
|
body: exists
|
|
24
|
-
} = await
|
|
14
|
+
} = await client.indices.exists({
|
|
25
15
|
index
|
|
26
16
|
});
|
|
27
|
-
|
|
28
17
|
if (!exists) {
|
|
29
18
|
return;
|
|
30
19
|
}
|
|
31
|
-
|
|
32
20
|
try {
|
|
33
|
-
await
|
|
21
|
+
await client.indices.delete({
|
|
34
22
|
index,
|
|
35
23
|
ignore_unavailable: true
|
|
36
24
|
});
|
|
@@ -40,4 +28,4 @@ const deleteElasticsearchIndex = async params => {
|
|
|
40
28
|
}
|
|
41
29
|
};
|
|
42
30
|
|
|
43
|
-
|
|
31
|
+
//# sourceMappingURL=deleteElasticsearchIndex.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["deleteElasticsearchIndex","params","
|
|
1
|
+
{"version":3,"names":["configurations","deleteElasticsearchIndex","params","client","model","index","es","body","exists","indices","delete","ignore_unavailable","ex","console","log","message"],"sources":["deleteElasticsearchIndex.ts"],"sourcesContent":["import type { Client } from \"@elastic/elasticsearch\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\nimport { configurations } from \"~/configurations.js\";\n\ninterface DeleteElasticsearchIndexParams {\n client: Client;\n model: CmsModel;\n}\n\nexport const deleteElasticsearchIndex = async (\n params: DeleteElasticsearchIndexParams\n): Promise<void> => {\n const { client, model } = params;\n\n const { index } = configurations.es({\n model\n });\n const { body: exists } = await client.indices.exists({\n index\n });\n if (!exists) {\n return;\n }\n\n try {\n await client.indices.delete({\n index,\n ignore_unavailable: true\n });\n } catch (ex) {\n console.log(`Could not delete Elasticsearch index \"${index}\". Please do it manually.`);\n console.log(ex.message);\n }\n};\n"],"mappings":"AAEA,SAASA,cAAc;AAOvB,OAAO,MAAMC,wBAAwB,GAAG,MACpCC,MAAsC,IACtB;EAChB,MAAM;IAAEC,MAAM;IAAEC;EAAM,CAAC,GAAGF,MAAM;EAEhC,MAAM;IAAEG;EAAM,CAAC,GAAGL,cAAc,CAACM,EAAE,CAAC;IAChCF;EACJ,CAAC,CAAC;EACF,MAAM;IAAEG,IAAI,EAAEC;EAAO,CAAC,GAAG,MAAML,MAAM,CAACM,OAAO,CAACD,MAAM,CAAC;IACjDH;EACJ,CAAC,CAAC;EACF,IAAI,CAACG,MAAM,EAAE;IACT;EACJ;EAEA,IAAI;IACA,MAAML,MAAM,CAACM,OAAO,CAACC,MAAM,CAAC;MACxBL,KAAK;MACLM,kBAAkB,EAAE;IACxB,CAAC,CAAC;EACN,CAAC,CAAC,OAAOC,EAAE,EAAE;IACTC,OAAO,CAACC,GAAG,CAAC,yCAAyCT,KAAK,2BAA2B,CAAC;IACtFQ,OAAO,CAACC,GAAG,CAACF,EAAE,CAACG,OAAO,CAAC;EAC3B;AACJ,CAAC","ignoreList":[]}
|
package/elasticsearch/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: () => (import("../types").CmsModelFieldToElasticsearchPlugin[] | import("
|
|
1
|
+
declare const _default: () => (import("../types.js").CmsModelFieldToElasticsearchPlugin[] | import("../index.js").CmsEntryElasticsearchQueryBuilderValueSearchPlugin[])[];
|
|
2
2
|
export default _default;
|
package/elasticsearch/index.js
CHANGED
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import elasticsearchIndexingPlugins from "./indexing/index.js";
|
|
2
|
+
import elasticsearchSearchPlugins from "./search/index.js";
|
|
3
|
+
export default () => [elasticsearchIndexingPlugins(), elasticsearchSearchPlugins()];
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = void 0;
|
|
9
|
-
|
|
10
|
-
var _indexing = _interopRequireDefault(require("./indexing"));
|
|
11
|
-
|
|
12
|
-
var _search = _interopRequireDefault(require("./search"));
|
|
13
|
-
|
|
14
|
-
var _default = () => [(0, _indexing.default)(), (0, _search.default)()];
|
|
15
|
-
|
|
16
|
-
exports.default = _default;
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["elasticsearchIndexingPlugins","elasticsearchSearchPlugins"],"sources":["index.ts"],"sourcesContent":["import elasticsearchIndexingPlugins from \"./indexing\";\nimport elasticsearchSearchPlugins from \"./search\";\n\nexport default () => [elasticsearchIndexingPlugins(), elasticsearchSearchPlugins()];\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["elasticsearchIndexingPlugins","elasticsearchSearchPlugins"],"sources":["index.ts"],"sourcesContent":["import elasticsearchIndexingPlugins from \"./indexing/index.js\";\nimport elasticsearchSearchPlugins from \"./search/index.js\";\n\nexport default () => [elasticsearchIndexingPlugins(), elasticsearchSearchPlugins()];\n"],"mappings":"AAAA,OAAOA,4BAA4B;AACnC,OAAOC,0BAA0B;AAEjC,eAAe,MAAM,CAACD,4BAA4B,CAAC,CAAC,EAAEC,0BAA0B,CAAC,CAAC,CAAC","ignoreList":[]}
|