@webiny/api-headless-cms-ddb-es 6.3.0-beta.4 → 6.4.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/configurations.js +27 -35
- package/configurations.js.map +1 -1
- package/definitions/entry.js +7 -9
- package/definitions/entry.js.map +1 -1
- package/definitions/group.js +7 -9
- package/definitions/group.js.map +1 -1
- package/definitions/model.js +7 -9
- package/definitions/model.js.map +1 -1
- package/definitions/types.d.ts +1 -0
- package/definitions/types.js +0 -3
- package/elasticsearch/createElasticsearchIndex.js +50 -67
- package/elasticsearch/createElasticsearchIndex.js.map +1 -1
- package/elasticsearch/deleteElasticsearchIndex.js +18 -26
- package/elasticsearch/deleteElasticsearchIndex.js.map +1 -1
- package/exports/api/cms/opensearch.js +2 -4
- package/feature.js +144 -153
- package/feature.js.map +1 -1
- package/features/CmsEntryOpenSearchBodyModifier/abstractions.js +2 -1
- package/features/CmsEntryOpenSearchBodyModifier/abstractions.js.map +1 -1
- package/features/CmsEntryOpenSearchBodyModifier/index.js +0 -2
- package/features/CmsEntryOpenSearchFieldIndex/CmsEntryOpenSearchFieldIndexRegistry.js +28 -27
- package/features/CmsEntryOpenSearchFieldIndex/CmsEntryOpenSearchFieldIndexRegistry.js.map +1 -1
- package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndex.js +2 -1
- package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndex.js.map +1 -1
- package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndexRegistry.js +2 -1
- package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndexRegistry.js.map +1 -1
- package/features/CmsEntryOpenSearchFieldIndex/constants.js +2 -1
- package/features/CmsEntryOpenSearchFieldIndex/constants.js.map +1 -1
- package/features/CmsEntryOpenSearchFieldIndex/feature.js +13 -12
- package/features/CmsEntryOpenSearchFieldIndex/feature.js.map +1 -1
- package/features/CmsEntryOpenSearchFieldIndex/fields/DateTimeFieldIndex.js +48 -65
- package/features/CmsEntryOpenSearchFieldIndex/fields/DateTimeFieldIndex.js.map +1 -1
- package/features/CmsEntryOpenSearchFieldIndex/fields/DefaultFieldIndex.js +20 -30
- package/features/CmsEntryOpenSearchFieldIndex/fields/DefaultFieldIndex.js.map +1 -1
- package/features/CmsEntryOpenSearchFieldIndex/fields/JsonFieldIndex.js +15 -16
- package/features/CmsEntryOpenSearchFieldIndex/fields/JsonFieldIndex.js.map +1 -1
- package/features/CmsEntryOpenSearchFieldIndex/fields/LongTextFieldIndex.js +15 -18
- package/features/CmsEntryOpenSearchFieldIndex/fields/LongTextFieldIndex.js.map +1 -1
- package/features/CmsEntryOpenSearchFieldIndex/fields/NumberFieldIndex.js +24 -29
- package/features/CmsEntryOpenSearchFieldIndex/fields/NumberFieldIndex.js.map +1 -1
- package/features/CmsEntryOpenSearchFieldIndex/fields/ObjectFieldIndex.js +99 -144
- package/features/CmsEntryOpenSearchFieldIndex/fields/ObjectFieldIndex.js.map +1 -1
- package/features/CmsEntryOpenSearchFieldIndex/fields/RichTextFieldIndex.js +15 -16
- package/features/CmsEntryOpenSearchFieldIndex/fields/RichTextFieldIndex.js.map +1 -1
- package/features/CmsEntryOpenSearchFieldIndex/index.js +0 -2
- package/features/CmsEntryOpenSearchFilter/CmsEntryOpenSearchFilterRegistry.js +26 -28
- package/features/CmsEntryOpenSearchFilter/CmsEntryOpenSearchFilterRegistry.js.map +1 -1
- package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilter.js +2 -1
- package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilter.js.map +1 -1
- package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilterRegistry.js +2 -1
- package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilterRegistry.js.map +1 -1
- package/features/CmsEntryOpenSearchFilter/constants.js +2 -1
- package/features/CmsEntryOpenSearchFilter/constants.js.map +1 -1
- package/features/CmsEntryOpenSearchFilter/feature.js +9 -8
- package/features/CmsEntryOpenSearchFilter/feature.js.map +1 -1
- package/features/CmsEntryOpenSearchFilter/fields/DefaultFilter.js +18 -15
- package/features/CmsEntryOpenSearchFilter/fields/DefaultFilter.js.map +1 -1
- package/features/CmsEntryOpenSearchFilter/fields/ObjectFilter.js +35 -53
- package/features/CmsEntryOpenSearchFilter/fields/ObjectFilter.js.map +1 -1
- package/features/CmsEntryOpenSearchFilter/fields/RefFilter.js +27 -40
- package/features/CmsEntryOpenSearchFilter/fields/RefFilter.js.map +1 -1
- package/features/CmsEntryOpenSearchFilter/index.js +0 -2
- package/features/CmsEntryOpenSearchFullTextSearch/abstractions.js +2 -1
- package/features/CmsEntryOpenSearchFullTextSearch/abstractions.js.map +1 -1
- package/features/CmsEntryOpenSearchFullTextSearch/index.js +0 -2
- package/features/CmsEntryOpenSearchIndex/BaseOpenSearchIndex.js +10 -9
- package/features/CmsEntryOpenSearchIndex/BaseOpenSearchIndex.js.map +1 -1
- package/features/CmsEntryOpenSearchIndex/abstractions.js +2 -1
- package/features/CmsEntryOpenSearchIndex/abstractions.js.map +1 -1
- package/features/CmsEntryOpenSearchIndex/feature.js +6 -5
- package/features/CmsEntryOpenSearchIndex/feature.js.map +1 -1
- package/features/CmsEntryOpenSearchIndex/index.js +0 -2
- package/features/CmsEntryOpenSearchQueryModifier/abstractions.js +2 -1
- package/features/CmsEntryOpenSearchQueryModifier/abstractions.js.map +1 -1
- package/features/CmsEntryOpenSearchQueryModifier/index.js +0 -2
- package/features/CmsEntryOpenSearchSortModifier/abstractions.js +2 -1
- package/features/CmsEntryOpenSearchSortModifier/abstractions.js.map +1 -1
- package/features/CmsEntryOpenSearchSortModifier/index.js +0 -2
- package/features/CmsEntryOpenSearchValueSearch/CmsEntryOpenSearchValueSearchRegistry.js +24 -20
- package/features/CmsEntryOpenSearchValueSearch/CmsEntryOpenSearchValueSearchRegistry.js.map +1 -1
- package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearch.js +2 -1
- package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearch.js.map +1 -1
- package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearchRegistry.js +2 -1
- package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearchRegistry.js.map +1 -1
- package/features/CmsEntryOpenSearchValueSearch/feature.js +9 -8
- package/features/CmsEntryOpenSearchValueSearch/feature.js.map +1 -1
- package/features/CmsEntryOpenSearchValueSearch/fields/RefSearch.js +14 -16
- package/features/CmsEntryOpenSearchValueSearch/fields/RefSearch.js.map +1 -1
- package/features/CmsEntryOpenSearchValueSearch/fields/SearchableJsonSearch.js +31 -42
- package/features/CmsEntryOpenSearchValueSearch/fields/SearchableJsonSearch.js.map +1 -1
- package/features/CmsEntryOpenSearchValueSearch/fields/TimeSearch.js +15 -17
- package/features/CmsEntryOpenSearchValueSearch/fields/TimeSearch.js.map +1 -1
- package/features/CmsEntryOpenSearchValueSearch/index.js +0 -2
- package/features/CmsEntryOpenSearchValuesModifier/abstractions.js +2 -1
- package/features/CmsEntryOpenSearchValuesModifier/abstractions.js.map +1 -1
- package/features/CmsEntryOpenSearchValuesModifier/index.js +0 -2
- package/helpers/entryIndexHelpers.js +71 -123
- package/helpers/entryIndexHelpers.js.map +1 -1
- package/helpers/fieldIdentifier.js +18 -30
- package/helpers/fieldIdentifier.js.map +1 -1
- package/helpers/index.js +0 -2
- package/index.js +0 -2
- package/operations/entry/dataLoader/DataLoaderCache.js +22 -26
- package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -1
- package/operations/entry/dataLoader/constants.js +2 -1
- package/operations/entry/dataLoader/constants.js.map +1 -1
- package/operations/entry/dataLoader/createBatchScheduleFn.js +6 -15
- package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -1
- package/operations/entry/dataLoader/getAllEntryRevisions.js +18 -29
- package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -1
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +27 -37
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -1
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +27 -37
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -1
- package/operations/entry/dataLoader/getRevisionById.js +32 -46
- package/operations/entry/dataLoader/getRevisionById.js.map +1 -1
- package/operations/entry/dataLoader/index.js +8 -9
- package/operations/entry/dataLoader/index.js.map +1 -1
- package/operations/entry/dataLoader/types.js +0 -3
- package/operations/entry/dataLoaders.js +81 -99
- package/operations/entry/dataLoaders.js.map +1 -1
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js +6 -24
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js.map +1 -1
- package/operations/entry/elasticsearch/body.js +74 -125
- package/operations/entry/elasticsearch/body.js.map +1 -1
- package/operations/entry/elasticsearch/fields/createSystemField.js +6 -7
- package/operations/entry/elasticsearch/fields/createSystemField.js.map +1 -1
- package/operations/entry/elasticsearch/fields/live.js +45 -40
- package/operations/entry/elasticsearch/fields/live.js.map +1 -1
- package/operations/entry/elasticsearch/fields/location.js +45 -40
- package/operations/entry/elasticsearch/fields/location.js.map +1 -1
- package/operations/entry/elasticsearch/fields/state.js +99 -88
- package/operations/entry/elasticsearch/fields/state.js.map +1 -1
- package/operations/entry/elasticsearch/fields.js +193 -217
- package/operations/entry/elasticsearch/fields.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/applyFiltering.js +32 -45
- package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/exec.js +85 -114
- package/operations/entry/elasticsearch/filtering/exec.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/index.js +0 -2
- package/operations/entry/elasticsearch/filtering/path.js +24 -33
- package/operations/entry/elasticsearch/filtering/path.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/populated.js +8 -14
- package/operations/entry/elasticsearch/filtering/populated.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/values.js +11 -12
- package/operations/entry/elasticsearch/filtering/values.js.map +1 -1
- package/operations/entry/elasticsearch/fullTextSearch.js +43 -80
- package/operations/entry/elasticsearch/fullTextSearch.js.map +1 -1
- package/operations/entry/elasticsearch/fullTextSearchFields.js +7 -17
- package/operations/entry/elasticsearch/fullTextSearchFields.js.map +1 -1
- package/operations/entry/elasticsearch/initialQuery.js +37 -80
- package/operations/entry/elasticsearch/initialQuery.js.map +1 -1
- package/operations/entry/elasticsearch/keyword.js +13 -27
- package/operations/entry/elasticsearch/keyword.js.map +1 -1
- package/operations/entry/elasticsearch/plugins/operator.js +9 -20
- package/operations/entry/elasticsearch/plugins/operator.js.map +1 -1
- package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js +6 -4
- package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js.map +1 -1
- package/operations/entry/elasticsearch/sort.js +69 -92
- package/operations/entry/elasticsearch/sort.js.map +1 -1
- package/operations/entry/elasticsearch/transformValueForSearch.js +9 -14
- package/operations/entry/elasticsearch/transformValueForSearch.js.map +1 -1
- package/operations/entry/elasticsearch/types.js +0 -3
- package/operations/entry/index.js +1322 -1709
- package/operations/entry/index.js.map +1 -1
- package/operations/entry/keys.js +43 -63
- package/operations/entry/keys.js.map +1 -1
- package/operations/entry/recordType.js +4 -9
- package/operations/entry/recordType.js.map +1 -1
- package/operations/entry/transformations/convertEntryKeys.js +21 -26
- package/operations/entry/transformations/convertEntryKeys.js.map +1 -1
- package/operations/entry/transformations/index.js +85 -114
- package/operations/entry/transformations/index.js.map +1 -1
- package/operations/entry/transformations/modifyEntryValues.d.ts +1 -1
- package/operations/entry/transformations/modifyEntryValues.js +12 -17
- package/operations/entry/transformations/modifyEntryValues.js.map +1 -1
- package/operations/entry/transformations/transformEntryKeys.js +13 -16
- package/operations/entry/transformations/transformEntryKeys.js.map +1 -1
- package/operations/entry/transformations/transformEntryToIndex.js +17 -22
- package/operations/entry/transformations/transformEntryToIndex.js.map +1 -1
- package/operations/group/index.js +113 -134
- package/operations/group/index.js.map +1 -1
- package/operations/model/index.js +128 -156
- package/operations/model/index.js.map +1 -1
- package/package.json +23 -23
- package/tasks/createIndexTaskPlugin.js +35 -38
- package/tasks/createIndexTaskPlugin.js.map +1 -1
- package/types.js +7 -13
- package/types.js.map +1 -1
- package/values/NoValueContainer.js +8 -10
- package/values/NoValueContainer.js.map +1 -1
- package/definitions/types.js.map +0 -1
- package/exports/api/cms/opensearch.js.map +0 -1
- package/features/CmsEntryOpenSearchBodyModifier/index.js.map +0 -1
- package/features/CmsEntryOpenSearchFieldIndex/index.js.map +0 -1
- package/features/CmsEntryOpenSearchFilter/index.js.map +0 -1
- package/features/CmsEntryOpenSearchFullTextSearch/index.js.map +0 -1
- package/features/CmsEntryOpenSearchIndex/index.js.map +0 -1
- package/features/CmsEntryOpenSearchQueryModifier/index.js.map +0 -1
- package/features/CmsEntryOpenSearchSortModifier/index.js.map +0 -1
- package/features/CmsEntryOpenSearchValueSearch/index.js.map +0 -1
- package/features/CmsEntryOpenSearchValuesModifier/index.js.map +0 -1
- package/helpers/index.js.map +0 -1
- package/index.js.map +0 -1
- package/operations/entry/dataLoader/types.js.map +0 -1
- package/operations/entry/elasticsearch/filtering/index.js.map +0 -1
- package/operations/entry/elasticsearch/types.js.map +0 -1
|
@@ -1,158 +1,113 @@
|
|
|
1
1
|
import { getFieldIdentifiers } from "../../../helpers/index.js";
|
|
2
2
|
import { CmsEntryOpenSearchFieldIndex } from "../abstractions/CmsEntryOpenSearchFieldIndex.js";
|
|
3
|
-
const processToIndex = params
|
|
4
|
-
|
|
5
|
-
fields,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
field,
|
|
24
|
-
value: sourceValue[identifiers.valueIdentifier || identifiers.rawValueIdentifier],
|
|
25
|
-
rawValue: sourceRawValue[identifiers.rawValueIdentifier || identifiers.valueIdentifier],
|
|
26
|
-
getFieldIndex,
|
|
27
|
-
fieldRegistry
|
|
3
|
+
const processToIndex = (params)=>{
|
|
4
|
+
const { fields, value: sourceValue, rawValue: sourceRawValue, getFieldIndex, fieldRegistry, model } = params;
|
|
5
|
+
return fields.reduce((values, field)=>{
|
|
6
|
+
const plugin = getFieldIndex(field.type);
|
|
7
|
+
const identifiers = getFieldIdentifiers(sourceValue, sourceRawValue, field);
|
|
8
|
+
if (!identifiers) return values;
|
|
9
|
+
const { value, rawValue } = plugin.toIndex({
|
|
10
|
+
model,
|
|
11
|
+
field,
|
|
12
|
+
value: sourceValue[identifiers.valueIdentifier || identifiers.rawValueIdentifier],
|
|
13
|
+
rawValue: sourceRawValue[identifiers.rawValueIdentifier || identifiers.valueIdentifier],
|
|
14
|
+
getFieldIndex,
|
|
15
|
+
fieldRegistry
|
|
16
|
+
});
|
|
17
|
+
if (void 0 !== value) values.value[identifiers.valueIdentifier || identifiers.rawValueIdentifier] = value;
|
|
18
|
+
if (void 0 !== rawValue) values.rawValue[identifiers.rawValueIdentifier || identifiers.valueIdentifier] = rawValue;
|
|
19
|
+
return values;
|
|
20
|
+
}, {
|
|
21
|
+
value: {},
|
|
22
|
+
rawValue: {}
|
|
28
23
|
});
|
|
29
|
-
if (value !== undefined) {
|
|
30
|
-
values.value[identifiers.valueIdentifier || identifiers.rawValueIdentifier] = value;
|
|
31
|
-
}
|
|
32
|
-
if (rawValue !== undefined) {
|
|
33
|
-
values.rawValue[identifiers.rawValueIdentifier || identifiers.valueIdentifier] = rawValue;
|
|
34
|
-
}
|
|
35
|
-
return values;
|
|
36
|
-
}, {
|
|
37
|
-
value: {},
|
|
38
|
-
rawValue: {}
|
|
39
|
-
});
|
|
40
24
|
};
|
|
41
|
-
const processFromIndex = params
|
|
42
|
-
|
|
43
|
-
fields,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
model,
|
|
59
|
-
field,
|
|
60
|
-
value: sourceValue[identifiers.valueIdentifier || identifiers.rawValueIdentifier],
|
|
61
|
-
rawValue: sourceRawValue ? sourceRawValue[identifiers.rawValueIdentifier || identifiers.valueIdentifier] : null,
|
|
62
|
-
getFieldIndex
|
|
63
|
-
});
|
|
64
|
-
if (value !== undefined) {
|
|
65
|
-
values[identifiers.valueIdentifier || identifiers.rawValueIdentifier] = value;
|
|
66
|
-
}
|
|
67
|
-
return values;
|
|
68
|
-
}, {});
|
|
25
|
+
const processFromIndex = (params)=>{
|
|
26
|
+
const { fields, value: sourceValue, rawValue: sourceRawValue, getFieldIndex, fieldRegistry, model } = params;
|
|
27
|
+
return fields.reduce((values, field)=>{
|
|
28
|
+
const plugin = getFieldIndex(field.type);
|
|
29
|
+
const identifiers = getFieldIdentifiers(sourceValue, sourceRawValue, field);
|
|
30
|
+
if (!identifiers) return values;
|
|
31
|
+
const value = plugin.fromIndex({
|
|
32
|
+
fieldRegistry,
|
|
33
|
+
model,
|
|
34
|
+
field,
|
|
35
|
+
value: sourceValue[identifiers.valueIdentifier || identifiers.rawValueIdentifier],
|
|
36
|
+
rawValue: sourceRawValue ? sourceRawValue[identifiers.rawValueIdentifier || identifiers.valueIdentifier] : null,
|
|
37
|
+
getFieldIndex
|
|
38
|
+
});
|
|
39
|
+
if (void 0 !== value) values[identifiers.valueIdentifier || identifiers.rawValueIdentifier] = value;
|
|
40
|
+
return values;
|
|
41
|
+
}, {});
|
|
69
42
|
};
|
|
70
43
|
class ObjectFieldIndexImpl {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
44
|
+
toIndex({ fieldRegistry, model, field, value: initialValue, rawValue: initialRawValue, getFieldIndex }) {
|
|
45
|
+
if (!initialValue) return {
|
|
46
|
+
value: null
|
|
47
|
+
};
|
|
48
|
+
const fields = field.settings?.fields || [];
|
|
49
|
+
if (field.list) {
|
|
50
|
+
const result = {
|
|
51
|
+
value: [],
|
|
52
|
+
rawValue: []
|
|
53
|
+
};
|
|
54
|
+
for(const key in initialValue){
|
|
55
|
+
const { value, rawValue } = processToIndex({
|
|
56
|
+
value: initialValue[key],
|
|
57
|
+
rawValue: initialRawValue[key],
|
|
58
|
+
getFieldIndex,
|
|
59
|
+
model,
|
|
60
|
+
fieldRegistry,
|
|
61
|
+
fields
|
|
62
|
+
});
|
|
63
|
+
result.value.push(value);
|
|
64
|
+
result.rawValue.push(rawValue);
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
value: result.value.length > 0 ? result.value : void 0,
|
|
68
|
+
rawValue: result.rawValue.length > 0 ? result.rawValue : void 0
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
return processToIndex({
|
|
72
|
+
value: initialValue,
|
|
73
|
+
rawValue: initialRawValue,
|
|
74
|
+
getFieldIndex,
|
|
75
|
+
model,
|
|
76
|
+
fieldRegistry,
|
|
77
|
+
fields
|
|
102
78
|
});
|
|
103
|
-
result.value.push(value);
|
|
104
|
-
result.rawValue.push(rawValue);
|
|
105
|
-
}
|
|
106
|
-
return {
|
|
107
|
-
value: result.value.length > 0 ? result.value : undefined,
|
|
108
|
-
rawValue: result.rawValue.length > 0 ? result.rawValue : undefined
|
|
109
|
-
};
|
|
110
79
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
80
|
+
fromIndex({ field, value, rawValue, model, getFieldIndex, fieldRegistry }) {
|
|
81
|
+
if (!value) return null;
|
|
82
|
+
const fields = field.settings?.fields || [];
|
|
83
|
+
if (field.list) {
|
|
84
|
+
const source = value || rawValue || [];
|
|
85
|
+
return source.map((_, index)=>processFromIndex({
|
|
86
|
+
value: value ? value[index] || {} : {},
|
|
87
|
+
rawValue: rawValue ? rawValue[index] || {} : {},
|
|
88
|
+
getFieldIndex,
|
|
89
|
+
model,
|
|
90
|
+
fieldRegistry,
|
|
91
|
+
fields
|
|
92
|
+
}));
|
|
93
|
+
}
|
|
94
|
+
return processFromIndex({
|
|
95
|
+
value,
|
|
96
|
+
rawValue,
|
|
97
|
+
getFieldIndex,
|
|
98
|
+
model,
|
|
99
|
+
fieldRegistry,
|
|
100
|
+
fields
|
|
101
|
+
});
|
|
130
102
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
const source = value || rawValue || [];
|
|
134
|
-
return source.map((_, index) => processFromIndex({
|
|
135
|
-
value: value ? value[index] || {} : {},
|
|
136
|
-
rawValue: rawValue ? rawValue[index] || {} : {},
|
|
137
|
-
getFieldIndex,
|
|
138
|
-
model,
|
|
139
|
-
fieldRegistry,
|
|
140
|
-
fields
|
|
141
|
-
}));
|
|
103
|
+
constructor(){
|
|
104
|
+
this.fieldType = "object";
|
|
142
105
|
}
|
|
143
|
-
return processFromIndex({
|
|
144
|
-
value,
|
|
145
|
-
rawValue,
|
|
146
|
-
getFieldIndex,
|
|
147
|
-
model,
|
|
148
|
-
fieldRegistry,
|
|
149
|
-
fields
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
106
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
107
|
+
const ObjectFieldIndex = CmsEntryOpenSearchFieldIndex.createImplementation({
|
|
108
|
+
implementation: ObjectFieldIndexImpl,
|
|
109
|
+
dependencies: []
|
|
156
110
|
});
|
|
111
|
+
export { ObjectFieldIndex };
|
|
157
112
|
|
|
158
113
|
//# sourceMappingURL=ObjectFieldIndex.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getFieldIdentifiers","CmsEntryOpenSearchFieldIndex","processToIndex","params","fields","value","sourceValue","rawValue","sourceRawValue","getFieldIndex","fieldRegistry","model","reduce","values","field","plugin","type","identifiers","toIndex","valueIdentifier","rawValueIdentifier","undefined","processFromIndex","fromIndex","ObjectFieldIndexImpl","fieldType","initialValue","initialRawValue","settings","list","result","key","push","length","source","map","_","index","ObjectFieldIndex","createImplementation","implementation","dependencies"],"sources":["ObjectFieldIndex.ts"],"sourcesContent":["import type { CmsModel, CmsModelField } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { CmsModelFieldToGraphQLRegistry } from \"@webiny/api-headless-cms/exports/api/cms/graphql.js\";\nimport { getFieldIdentifiers } from \"~/helpers/index.js\";\nimport { CmsEntryOpenSearchFieldIndex } from \"../abstractions/CmsEntryOpenSearchFieldIndex.js\";\n\ninterface ProcessToIndexParams {\n fields: CmsModelField[];\n value: Record<string, any>;\n rawValue: Record<string, any>;\n getFieldIndex: (fieldType: string) => CmsEntryOpenSearchFieldIndex.Interface;\n fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface;\n model: CmsModel;\n}\n\ninterface ReducerValue {\n value: Record<string, any>;\n rawValue: Record<string, any>;\n}\n\nconst processToIndex = (params: ProcessToIndexParams): ReducerValue => {\n const {\n fields,\n value: sourceValue,\n rawValue: sourceRawValue,\n getFieldIndex,\n fieldRegistry,\n model\n } = params;\n\n return fields.reduce<ReducerValue>(\n (values, field) => {\n const plugin = getFieldIndex(field.type);\n\n const identifiers = getFieldIdentifiers(sourceValue, sourceRawValue, field);\n if (!identifiers) {\n return values;\n }\n\n const { value, rawValue } = plugin.toIndex({\n model,\n field,\n value: sourceValue[identifiers.valueIdentifier || identifiers.rawValueIdentifier],\n rawValue:\n sourceRawValue[identifiers.rawValueIdentifier || identifiers.valueIdentifier],\n getFieldIndex,\n fieldRegistry\n });\n\n if (value !== undefined) {\n values.value[identifiers.valueIdentifier || identifiers.rawValueIdentifier] = value;\n }\n if (rawValue !== undefined) {\n values.rawValue[identifiers.rawValueIdentifier || identifiers.valueIdentifier] =\n rawValue;\n }\n\n return values;\n },\n { value: {}, rawValue: {} }\n );\n};\n\ninterface ProcessFromIndexParams {\n fields: CmsModelField[];\n value: Record<string, any>;\n rawValue?: Record<string, any> | null;\n getFieldIndex: (fieldType: string) => CmsEntryOpenSearchFieldIndex.Interface;\n fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface;\n model: CmsModel;\n}\n\nconst processFromIndex = (params: ProcessFromIndexParams): Record<string, any> => {\n const {\n fields,\n value: sourceValue,\n rawValue: sourceRawValue,\n getFieldIndex,\n fieldRegistry,\n model\n } = params;\n\n return fields.reduce<Record<string, any>>((values, field) => {\n const plugin = getFieldIndex(field.type);\n\n const identifiers = getFieldIdentifiers(sourceValue, sourceRawValue, field);\n if (!identifiers) {\n return values;\n }\n\n const value = plugin.fromIndex({\n fieldRegistry,\n model,\n field,\n value: sourceValue[identifiers.valueIdentifier || identifiers.rawValueIdentifier],\n rawValue: sourceRawValue\n ? sourceRawValue[identifiers.rawValueIdentifier || identifiers.valueIdentifier]\n : null,\n getFieldIndex\n });\n\n if (value !== undefined) {\n values[identifiers.valueIdentifier || identifiers.rawValueIdentifier] = value;\n }\n\n return values;\n }, {});\n};\n\nclass ObjectFieldIndexImpl implements CmsEntryOpenSearchFieldIndex.Interface {\n public readonly fieldType = \"object\";\n\n public toIndex({\n fieldRegistry,\n model,\n field,\n value: initialValue,\n rawValue: initialRawValue,\n getFieldIndex\n }: CmsEntryOpenSearchFieldIndex.ToIndex): CmsEntryOpenSearchFieldIndex.ToValue {\n if (!initialValue) {\n return { value: null };\n }\n\n const fields = (field.settings?.fields || []) as CmsModelField[];\n\n if (field.list) {\n const result: { value: Record<string, any>[]; rawValue: Record<string, any>[] } = {\n value: [],\n rawValue: []\n };\n for (const key in initialValue) {\n const { value, rawValue } = processToIndex({\n value: initialValue[key],\n rawValue: initialRawValue[key],\n getFieldIndex,\n model,\n fieldRegistry,\n fields\n });\n\n result.value.push(value);\n result.rawValue.push(rawValue);\n }\n\n return {\n value: result.value.length > 0 ? result.value : undefined,\n rawValue: result.rawValue.length > 0 ? result.rawValue : undefined\n };\n }\n\n return processToIndex({\n value: initialValue,\n rawValue: initialRawValue,\n getFieldIndex,\n model,\n fieldRegistry,\n fields\n });\n }\n\n public fromIndex({\n field,\n value,\n rawValue,\n model,\n getFieldIndex,\n fieldRegistry\n }: CmsEntryOpenSearchFieldIndex.FromIndex): any {\n if (!value) {\n return null;\n }\n\n const fields = field.settings?.fields || [];\n\n if (field.list) {\n const source = value || rawValue || [];\n\n return source.map((_: any, index: number) =>\n processFromIndex({\n value: value ? value[index] || {} : {},\n rawValue: rawValue ? rawValue[index] || {} : {},\n getFieldIndex,\n model,\n fieldRegistry,\n fields\n })\n );\n }\n\n return processFromIndex({\n value,\n rawValue,\n getFieldIndex,\n model,\n fieldRegistry,\n fields\n });\n }\n}\n\nexport const ObjectFieldIndex = CmsEntryOpenSearchFieldIndex.createImplementation({\n implementation: ObjectFieldIndexImpl,\n dependencies: []\n});\n"],"mappings":"AAEA,SAASA,mBAAmB;AAC5B,SAASC,4BAA4B;AAgBrC,MAAMC,cAAc,GAAIC,MAA4B,IAAmB;E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AG,CAAC,CAACC,CAAM,EAAEC,KAAa,KACpCf,gBAAgB,CAAC;QACbjB,KAAK,EAAEA,KAAK,GAAGA,KAAK,CAACgC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QACtC9B,QAAQ,EAAEA,QAAQ,GAAGA,QAAQ,CAAC8B,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QAC/C5B,aAAa;QACbE,KAAK;QACLD,aAAa;QACbN;MACJ,CAAC,CACL,CAAC;IACL;IAEA,OAAOkB,gBAAgB,CAAC;MACpBjB,KAAK;MACLE,QAAQ;MACRE,aAAa;MACbE,KAAK;MACLD,aAAa;MACbN;IACJ,CAAC,CAAC;EACN;AACJ;AAEA,OAAO,MAAMkC,gBAAgB,GAAGrC,4BAA4B,CAACsC,oBAAoB,CAAC;EAC9EC,cAAc,EAAEhB,oBAAoB;EACpCiB,YAAY,EAAE;AAClB,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"features/CmsEntryOpenSearchFieldIndex/fields/ObjectFieldIndex.js","sources":["../../../../src/features/CmsEntryOpenSearchFieldIndex/fields/ObjectFieldIndex.ts"],"sourcesContent":["import type { CmsModel, CmsModelField } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { CmsModelFieldToGraphQLRegistry } from \"@webiny/api-headless-cms/exports/api/cms/graphql.js\";\nimport { getFieldIdentifiers } from \"~/helpers/index.js\";\nimport { CmsEntryOpenSearchFieldIndex } from \"../abstractions/CmsEntryOpenSearchFieldIndex.js\";\n\ninterface ProcessToIndexParams {\n fields: CmsModelField[];\n value: Record<string, any>;\n rawValue: Record<string, any>;\n getFieldIndex: (fieldType: string) => CmsEntryOpenSearchFieldIndex.Interface;\n fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface;\n model: CmsModel;\n}\n\ninterface ReducerValue {\n value: Record<string, any>;\n rawValue: Record<string, any>;\n}\n\nconst processToIndex = (params: ProcessToIndexParams): ReducerValue => {\n const {\n fields,\n value: sourceValue,\n rawValue: sourceRawValue,\n getFieldIndex,\n fieldRegistry,\n model\n } = params;\n\n return fields.reduce<ReducerValue>(\n (values, field) => {\n const plugin = getFieldIndex(field.type);\n\n const identifiers = getFieldIdentifiers(sourceValue, sourceRawValue, field);\n if (!identifiers) {\n return values;\n }\n\n const { value, rawValue } = plugin.toIndex({\n model,\n field,\n value: sourceValue[identifiers.valueIdentifier || identifiers.rawValueIdentifier],\n rawValue:\n sourceRawValue[identifiers.rawValueIdentifier || identifiers.valueIdentifier],\n getFieldIndex,\n fieldRegistry\n });\n\n if (value !== undefined) {\n values.value[identifiers.valueIdentifier || identifiers.rawValueIdentifier] = value;\n }\n if (rawValue !== undefined) {\n values.rawValue[identifiers.rawValueIdentifier || identifiers.valueIdentifier] =\n rawValue;\n }\n\n return values;\n },\n { value: {}, rawValue: {} }\n );\n};\n\ninterface ProcessFromIndexParams {\n fields: CmsModelField[];\n value: Record<string, any>;\n rawValue?: Record<string, any> | null;\n getFieldIndex: (fieldType: string) => CmsEntryOpenSearchFieldIndex.Interface;\n fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface;\n model: CmsModel;\n}\n\nconst processFromIndex = (params: ProcessFromIndexParams): Record<string, any> => {\n const {\n fields,\n value: sourceValue,\n rawValue: sourceRawValue,\n getFieldIndex,\n fieldRegistry,\n model\n } = params;\n\n return fields.reduce<Record<string, any>>((values, field) => {\n const plugin = getFieldIndex(field.type);\n\n const identifiers = getFieldIdentifiers(sourceValue, sourceRawValue, field);\n if (!identifiers) {\n return values;\n }\n\n const value = plugin.fromIndex({\n fieldRegistry,\n model,\n field,\n value: sourceValue[identifiers.valueIdentifier || identifiers.rawValueIdentifier],\n rawValue: sourceRawValue\n ? sourceRawValue[identifiers.rawValueIdentifier || identifiers.valueIdentifier]\n : null,\n getFieldIndex\n });\n\n if (value !== undefined) {\n values[identifiers.valueIdentifier || identifiers.rawValueIdentifier] = value;\n }\n\n return values;\n }, {});\n};\n\nclass ObjectFieldIndexImpl implements CmsEntryOpenSearchFieldIndex.Interface {\n public readonly fieldType = \"object\";\n\n public toIndex({\n fieldRegistry,\n model,\n field,\n value: initialValue,\n rawValue: initialRawValue,\n getFieldIndex\n }: CmsEntryOpenSearchFieldIndex.ToIndex): CmsEntryOpenSearchFieldIndex.ToValue {\n if (!initialValue) {\n return { value: null };\n }\n\n const fields = (field.settings?.fields || []) as CmsModelField[];\n\n if (field.list) {\n const result: { value: Record<string, any>[]; rawValue: Record<string, any>[] } = {\n value: [],\n rawValue: []\n };\n for (const key in initialValue) {\n const { value, rawValue } = processToIndex({\n value: initialValue[key],\n rawValue: initialRawValue[key],\n getFieldIndex,\n model,\n fieldRegistry,\n fields\n });\n\n result.value.push(value);\n result.rawValue.push(rawValue);\n }\n\n return {\n value: result.value.length > 0 ? result.value : undefined,\n rawValue: result.rawValue.length > 0 ? result.rawValue : undefined\n };\n }\n\n return processToIndex({\n value: initialValue,\n rawValue: initialRawValue,\n getFieldIndex,\n model,\n fieldRegistry,\n fields\n });\n }\n\n public fromIndex({\n field,\n value,\n rawValue,\n model,\n getFieldIndex,\n fieldRegistry\n }: CmsEntryOpenSearchFieldIndex.FromIndex): any {\n if (!value) {\n return null;\n }\n\n const fields = field.settings?.fields || [];\n\n if (field.list) {\n const source = value || rawValue || [];\n\n return source.map((_: any, index: number) =>\n processFromIndex({\n value: value ? value[index] || {} : {},\n rawValue: rawValue ? rawValue[index] || {} : {},\n getFieldIndex,\n model,\n fieldRegistry,\n fields\n })\n );\n }\n\n return processFromIndex({\n value,\n rawValue,\n getFieldIndex,\n model,\n fieldRegistry,\n fields\n });\n }\n}\n\nexport const ObjectFieldIndex = CmsEntryOpenSearchFieldIndex.createImplementation({\n implementation: ObjectFieldIndexImpl,\n dependencies: []\n});\n"],"names":["processToIndex","params","fields","sourceValue","sourceRawValue","getFieldIndex","fieldRegistry","model","values","field","plugin","identifiers","getFieldIdentifiers","value","rawValue","undefined","processFromIndex","ObjectFieldIndexImpl","initialValue","initialRawValue","result","key","source","_","index","ObjectFieldIndex","CmsEntryOpenSearchFieldIndex"],"mappings":";;AAmBA,MAAMA,iBAAiB,CAACC;IACpB,MAAM,EACFC,MAAM,EACN,OAAOC,WAAW,EAClB,UAAUC,cAAc,EACxBC,aAAa,EACbC,aAAa,EACbC,KAAK,EACR,GAAGN;IAEJ,OAAOC,OAAO,MAAM,CAChB,CAACM,QAAQC;QACL,MAAMC,SAASL,cAAcI,MAAM,IAAI;QAEvC,MAAME,cAAcC,oBAAoBT,aAAaC,gBAAgBK;QACrE,IAAI,CAACE,aACD,OAAOH;QAGX,MAAM,EAAEK,KAAK,EAAEC,QAAQ,EAAE,GAAGJ,OAAO,OAAO,CAAC;YACvCH;YACAE;YACA,OAAON,WAAW,CAACQ,YAAY,eAAe,IAAIA,YAAY,kBAAkB,CAAC;YACjF,UACIP,cAAc,CAACO,YAAY,kBAAkB,IAAIA,YAAY,eAAe,CAAC;YACjFN;YACAC;QACJ;QAEA,IAAIO,AAAUE,WAAVF,OACAL,OAAO,KAAK,CAACG,YAAY,eAAe,IAAIA,YAAY,kBAAkB,CAAC,GAAGE;QAElF,IAAIC,AAAaC,WAAbD,UACAN,OAAO,QAAQ,CAACG,YAAY,kBAAkB,IAAIA,YAAY,eAAe,CAAC,GAC1EG;QAGR,OAAON;IACX,GACA;QAAE,OAAO,CAAC;QAAG,UAAU,CAAC;IAAE;AAElC;AAWA,MAAMQ,mBAAmB,CAACf;IACtB,MAAM,EACFC,MAAM,EACN,OAAOC,WAAW,EAClB,UAAUC,cAAc,EACxBC,aAAa,EACbC,aAAa,EACbC,KAAK,EACR,GAAGN;IAEJ,OAAOC,OAAO,MAAM,CAAsB,CAACM,QAAQC;QAC/C,MAAMC,SAASL,cAAcI,MAAM,IAAI;QAEvC,MAAME,cAAcC,oBAAoBT,aAAaC,gBAAgBK;QACrE,IAAI,CAACE,aACD,OAAOH;QAGX,MAAMK,QAAQH,OAAO,SAAS,CAAC;YAC3BJ;YACAC;YACAE;YAC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ACwB,EAAO;QAC5C,IAAI,CAACO,OACD,OAAO;QAGX,MAAMX,SAASO,MAAM,QAAQ,EAAE,UAAU,EAAE;QAE3C,IAAIA,MAAM,IAAI,EAAE;YACZ,MAAMa,SAAST,SAASC,YAAY,EAAE;YAEtC,OAAOQ,OAAO,GAAG,CAAC,CAACC,GAAQC,QACvBR,iBAAiB;oBACb,OAAOH,QAAQA,KAAK,CAACW,MAAM,IAAI,CAAC,IAAI,CAAC;oBACrC,UAAUV,WAAWA,QAAQ,CAACU,MAAM,IAAI,CAAC,IAAI,CAAC;oBAC9CnB;oBACAE;oBACAD;oBACAJ;gBACJ;QAER;QAEA,OAAOc,iBAAiB;YACpBH;YACAC;YACAT;YACAE;YACAD;YACAJ;QACJ;IACJ;;aAxFgB,SAAS,GAAG;;AAyFhC;AAEO,MAAMuB,mBAAmBC,6BAA6B,oBAAoB,CAAC;IAC9E,gBAAgBT;IAChB,cAAc,EAAE;AACpB"}
|
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
import { CmsEntryOpenSearchFieldIndex } from "../abstractions/CmsEntryOpenSearchFieldIndex.js";
|
|
2
2
|
class RichTextFieldIndexImpl {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return rawValue;
|
|
15
|
-
}
|
|
3
|
+
toIndex({ value }) {
|
|
4
|
+
return {
|
|
5
|
+
rawValue: value
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
fromIndex({ rawValue }) {
|
|
9
|
+
return rawValue;
|
|
10
|
+
}
|
|
11
|
+
constructor(){
|
|
12
|
+
this.fieldType = "rich-text";
|
|
13
|
+
}
|
|
16
14
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
const RichTextFieldIndex = CmsEntryOpenSearchFieldIndex.createImplementation({
|
|
16
|
+
implementation: RichTextFieldIndexImpl,
|
|
17
|
+
dependencies: []
|
|
20
18
|
});
|
|
19
|
+
export { RichTextFieldIndex };
|
|
21
20
|
|
|
22
21
|
//# sourceMappingURL=RichTextFieldIndex.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/CmsEntryOpenSearchFieldIndex/fields/RichTextFieldIndex.js","sources":["../../../../src/features/CmsEntryOpenSearchFieldIndex/fields/RichTextFieldIndex.ts"],"sourcesContent":["import { CmsEntryOpenSearchFieldIndex } from \"../abstractions/CmsEntryOpenSearchFieldIndex.js\";\n\nclass RichTextFieldIndexImpl implements CmsEntryOpenSearchFieldIndex.Interface {\n public readonly fieldType = \"rich-text\";\n\n public toIndex({\n value\n }: CmsEntryOpenSearchFieldIndex.ToIndex): CmsEntryOpenSearchFieldIndex.ToValue {\n return {\n rawValue: value\n };\n }\n\n public fromIndex({ rawValue }: CmsEntryOpenSearchFieldIndex.FromIndex): any {\n return rawValue;\n }\n}\n\nexport const RichTextFieldIndex = CmsEntryOpenSearchFieldIndex.createImplementation({\n implementation: RichTextFieldIndexImpl,\n dependencies: []\n});\n"],"names":["RichTextFieldIndexImpl","value","rawValue","RichTextFieldIndex","CmsEntryOpenSearchFieldIndex"],"mappings":";AAEA,MAAMA;IAGK,QAAQ,EACXC,KAAK,EAC8B,EAAwC;QAC3E,OAAO;YACH,UAAUA;QACd;IACJ;IAEO,UAAU,EAAEC,QAAQ,EAA0C,EAAO;QACxE,OAAOA;IACX;;aAZgB,SAAS,GAAG;;AAahC;AAEO,MAAMC,qBAAqBC,6BAA6B,oBAAoB,CAAC;IAChF,gBAAgBJ;IAChB,cAAc,EAAE;AACpB"}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
export { CmsEntryOpenSearchFieldIndexFeature } from "./feature.js";
|
|
2
2
|
export { CmsEntryOpenSearchFieldIndex } from "./abstractions/CmsEntryOpenSearchFieldIndex.js";
|
|
3
3
|
export { CmsEntryOpenSearchFieldIndexRegistry } from "./abstractions/CmsEntryOpenSearchFieldIndexRegistry.js";
|
|
4
|
-
|
|
5
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,38 +1,36 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { CmsEntryOpenSearchFilterRegistry
|
|
1
|
+
import error from "@webiny/error";
|
|
2
|
+
import { CmsEntryOpenSearchFilterRegistry } from "./abstractions/CmsEntryOpenSearchFilterRegistry.js";
|
|
3
3
|
import { CmsEntryOpenSearchFilter } from "./abstractions/CmsEntryOpenSearchFilter.js";
|
|
4
4
|
import { getBaseFieldType } from "@webiny/api-headless-cms/utils/getBaseFieldType.js";
|
|
5
5
|
import { FILTER_DEFAULT } from "./constants.js";
|
|
6
6
|
class CmsEntryOpenSearchFilterRegistryImpl {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
get(type) {
|
|
11
|
-
const fieldType = getBaseFieldType({
|
|
12
|
-
type
|
|
13
|
-
});
|
|
14
|
-
const filter = this.filters.find(f => {
|
|
15
|
-
return f.fieldType === fieldType;
|
|
16
|
-
});
|
|
17
|
-
if (filter) {
|
|
18
|
-
return filter;
|
|
7
|
+
constructor(filters){
|
|
8
|
+
this.filters = filters;
|
|
19
9
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
10
|
+
get(type) {
|
|
11
|
+
const fieldType = getBaseFieldType({
|
|
12
|
+
type
|
|
13
|
+
});
|
|
14
|
+
const filter = this.filters.find((f)=>f.fieldType === fieldType);
|
|
15
|
+
if (filter) return filter;
|
|
16
|
+
const fallback = this.filters.find((f)=>f.fieldType === FILTER_DEFAULT);
|
|
17
|
+
if (fallback) return fallback;
|
|
18
|
+
throw new error(`There is no filter for the given field type "${fieldType}".`, "FILTER_REGISTRY_ERROR", {
|
|
19
|
+
fieldType
|
|
20
|
+
});
|
|
25
21
|
}
|
|
26
|
-
throw new WebinyError(`There is no filter for the given field type "${fieldType}".`, "FILTER_REGISTRY_ERROR", {
|
|
27
|
-
fieldType
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
22
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
23
|
+
const CmsEntryOpenSearchFilterRegistry_CmsEntryOpenSearchFilterRegistry = CmsEntryOpenSearchFilterRegistry.createImplementation({
|
|
24
|
+
implementation: CmsEntryOpenSearchFilterRegistryImpl,
|
|
25
|
+
dependencies: [
|
|
26
|
+
[
|
|
27
|
+
CmsEntryOpenSearchFilter,
|
|
28
|
+
{
|
|
29
|
+
multiple: true
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
]
|
|
36
33
|
});
|
|
34
|
+
export { CmsEntryOpenSearchFilterRegistry_CmsEntryOpenSearchFilterRegistry as CmsEntryOpenSearchFilterRegistry };
|
|
37
35
|
|
|
38
36
|
//# sourceMappingURL=CmsEntryOpenSearchFilterRegistry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/CmsEntryOpenSearchFilter/CmsEntryOpenSearchFilterRegistry.js","sources":["../../../src/features/CmsEntryOpenSearchFilter/CmsEntryOpenSearchFilterRegistry.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsEntryOpenSearchFilterRegistry as Abstraction } from \"./abstractions/CmsEntryOpenSearchFilterRegistry.js\";\nimport { CmsEntryOpenSearchFilter } from \"./abstractions/CmsEntryOpenSearchFilter.js\";\nimport { getBaseFieldType } from \"@webiny/api-headless-cms/utils/getBaseFieldType.js\";\nimport { FILTER_DEFAULT } from \"./constants.js\";\n\nclass CmsEntryOpenSearchFilterRegistryImpl implements Abstraction.Interface {\n public constructor(private readonly filters: CmsEntryOpenSearchFilter.Interface[]) {}\n\n public get(type: string): CmsEntryOpenSearchFilter.Interface {\n const fieldType = getBaseFieldType({ type });\n const filter = this.filters.find(f => {\n return f.fieldType === fieldType;\n });\n if (filter) {\n return filter;\n }\n const fallback = this.filters.find(f => {\n return f.fieldType === FILTER_DEFAULT;\n });\n if (fallback) {\n return fallback;\n }\n throw new WebinyError(\n `There is no filter for the given field type \"${fieldType}\".`,\n \"FILTER_REGISTRY_ERROR\",\n {\n fieldType\n }\n );\n }\n}\n\nexport const CmsEntryOpenSearchFilterRegistry = Abstraction.createImplementation({\n implementation: CmsEntryOpenSearchFilterRegistryImpl,\n dependencies: [[CmsEntryOpenSearchFilter, { multiple: true }]]\n});\n"],"names":["CmsEntryOpenSearchFilterRegistryImpl","filters","type","fieldType","getBaseFieldType","filter","f","fallback","FILTER_DEFAULT","WebinyError","CmsEntryOpenSearchFilterRegistry","Abstraction","CmsEntryOpenSearchFilter"],"mappings":";;;;;AAMA,MAAMA;IACF,YAAoCC,OAA6C,CAAE;aAA/CA,OAAO,GAAPA;IAAgD;IAE7E,IAAIC,IAAY,EAAsC;QACzD,MAAMC,YAAYC,iBAAiB;YAAEF;QAAK;QAC1C,MAAMG,SAAS,IAAI,CAAC,OAAO,CAAC,IAAI,CAACC,CAAAA,IACtBA,EAAE,SAAS,KAAKH;QAE3B,IAAIE,QACA,OAAOA;QAEX,MAAME,WAAW,IAAI,CAAC,OAAO,CAAC,IAAI,CAACD,CAAAA,IACxBA,EAAE,SAAS,KAAKE;QAE3B,IAAID,UACA,OAAOA;QAEX,MAAM,IAAIE,MACN,CAAC,6CAA6C,EAAEN,UAAU,EAAE,CAAC,EAC7D,yBACA;YACIA;QACJ;IAER;AACJ;AAEO,MAAMO,oEAAmCC,iCAAAA,oBAAgC,CAAC;IAC7E,gBAAgBX;IAChB,cAAc;QAAC;YAACY;YAA0B;gBAAE,UAAU;YAAK;SAAE;KAAC;AAClE"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createAbstraction } from "@webiny/feature/api";
|
|
2
|
-
|
|
2
|
+
const CmsEntryOpenSearchFilter = createAbstraction("Cms/Entry/OpenSearch/Filter");
|
|
3
|
+
export { CmsEntryOpenSearchFilter };
|
|
3
4
|
|
|
4
5
|
//# sourceMappingURL=CmsEntryOpenSearchFilter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilter.js","sources":["../../../../src/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilter.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { ModelField, ModelFields } from \"~/operations/entry/elasticsearch/types.js\";\nimport type { OpenSearchBoolQueryConfig } from \"@webiny/api-opensearch/types.js\";\n\ninterface ApplyParams {\n key: string;\n value: any;\n query: OpenSearchBoolQueryConfig;\n operator: string;\n field: ModelField;\n}\n\nexport interface ApplyFilteringCb {\n (params: ApplyParams): void;\n}\n\nexport interface GetFilterCb {\n (type: string): CmsEntryOpenSearchFilter.Interface;\n}\n\nexport interface IExecParams {\n applyFiltering: ApplyFilteringCb;\n getFilter: GetFilterCb;\n key: string;\n value: any;\n operator: string;\n field: ModelField;\n fields: ModelFields;\n query: OpenSearchBoolQueryConfig;\n}\n\nexport interface ICmsEntryOpenSearchFilter {\n readonly fieldType: string;\n exec(params: IExecParams): void;\n}\n\nexport const CmsEntryOpenSearchFilter = createAbstraction<ICmsEntryOpenSearchFilter>(\n \"Cms/Entry/OpenSearch/Filter\"\n);\n\nexport namespace CmsEntryOpenSearchFilter {\n export type Interface = ICmsEntryOpenSearchFilter;\n export type ExecParams = IExecParams;\n export type ApplyFiltering = ApplyFilteringCb;\n export type GetFilter = GetFilterCb;\n}\n"],"names":["CmsEntryOpenSearchFilter","createAbstraction"],"mappings":";AAoCO,MAAMA,2BAA2BC,kBACpC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createAbstraction } from "@webiny/feature/api";
|
|
2
|
-
|
|
2
|
+
const CmsEntryOpenSearchFilterRegistry = createAbstraction("Cms/Entry/OpenSearch/FilterRegistry");
|
|
3
|
+
export { CmsEntryOpenSearchFilterRegistry };
|
|
3
4
|
|
|
4
5
|
//# sourceMappingURL=CmsEntryOpenSearchFilterRegistry.js.map
|
package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilterRegistry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilterRegistry.js","sources":["../../../../src/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilterRegistry.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { CmsEntryOpenSearchFilter } from \"./CmsEntryOpenSearchFilter.js\";\n\nexport interface ICmsEntryOpenSearchFilterRegistry {\n get(fieldType: string): CmsEntryOpenSearchFilter.Interface;\n}\n\nexport const CmsEntryOpenSearchFilterRegistry =\n createAbstraction<ICmsEntryOpenSearchFilterRegistry>(\"Cms/Entry/OpenSearch/FilterRegistry\");\n\nexport namespace CmsEntryOpenSearchFilterRegistry {\n export type Interface = ICmsEntryOpenSearchFilterRegistry;\n export type Filter = CmsEntryOpenSearchFilter.Interface;\n}\n"],"names":["CmsEntryOpenSearchFilterRegistry","createAbstraction"],"mappings":";AAOO,MAAMA,mCACTC,kBAAqD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/CmsEntryOpenSearchFilter/constants.js","sources":["../../../src/features/CmsEntryOpenSearchFilter/constants.ts"],"sourcesContent":["export const FILTER_DEFAULT = \"*\" as const;\n"],"names":["FILTER_DEFAULT"],"mappings":"AAAO,MAAMA,iBAAiB"}
|
|
@@ -3,14 +3,15 @@ import { DefaultFilter } from "./fields/DefaultFilter.js";
|
|
|
3
3
|
import { RefFilter } from "./fields/RefFilter.js";
|
|
4
4
|
import { ObjectFilter } from "./fields/ObjectFilter.js";
|
|
5
5
|
import { CmsEntryOpenSearchFilterRegistry } from "./CmsEntryOpenSearchFilterRegistry.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
const CmsEntryOpenSearchFilterFeature = createFeature({
|
|
7
|
+
name: "Cms/Entry/OpenSearch/FilterFeature",
|
|
8
|
+
register: (container)=>{
|
|
9
|
+
container.register(DefaultFilter);
|
|
10
|
+
container.register(RefFilter);
|
|
11
|
+
container.register(ObjectFilter);
|
|
12
|
+
container.register(CmsEntryOpenSearchFilterRegistry);
|
|
13
|
+
}
|
|
14
14
|
});
|
|
15
|
+
export { CmsEntryOpenSearchFilterFeature };
|
|
15
16
|
|
|
16
17
|
//# sourceMappingURL=feature.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/CmsEntryOpenSearchFilter/feature.js","sources":["../../../src/features/CmsEntryOpenSearchFilter/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { DefaultFilter } from \"./fields/DefaultFilter.js\";\nimport { RefFilter } from \"./fields/RefFilter.js\";\nimport { ObjectFilter } from \"./fields/ObjectFilter.js\";\nimport { CmsEntryOpenSearchFilterRegistry } from \"./CmsEntryOpenSearchFilterRegistry.js\";\n\nexport const CmsEntryOpenSearchFilterFeature = createFeature({\n name: \"Cms/Entry/OpenSearch/FilterFeature\",\n register: container => {\n container.register(DefaultFilter);\n container.register(RefFilter);\n container.register(ObjectFilter);\n container.register(CmsEntryOpenSearchFilterRegistry);\n }\n});\n"],"names":["CmsEntryOpenSearchFilterFeature","createFeature","container","DefaultFilter","RefFilter","ObjectFilter","CmsEntryOpenSearchFilterRegistry"],"mappings":";;;;;AAMO,MAAMA,kCAAkCC,cAAc;IACzD,MAAM;IACN,UAAUC,CAAAA;QACNA,UAAU,QAAQ,CAACC;QACnBD,UAAU,QAAQ,CAACE;QACnBF,UAAU,QAAQ,CAACG;QACnBH,UAAU,QAAQ,CAACI;IACvB;AACJ"}
|
|
@@ -1,23 +1,26 @@
|
|
|
1
|
-
import
|
|
1
|
+
import error from "@webiny/error";
|
|
2
2
|
import { CmsEntryOpenSearchFilter } from "../abstractions/CmsEntryOpenSearchFilter.js";
|
|
3
3
|
import { FILTER_DEFAULT } from "../constants.js";
|
|
4
4
|
class DefaultFilterImpl {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
exec(params) {
|
|
6
|
+
const { applyFiltering, field } = params;
|
|
7
|
+
if (!field.searchable) {
|
|
8
|
+
const identifier = [
|
|
9
|
+
...field.parents.map((p)=>p.fieldId),
|
|
10
|
+
field.field.fieldId
|
|
11
|
+
].join(".");
|
|
12
|
+
throw new error(`Field "${identifier}" is not searchable.`);
|
|
13
|
+
}
|
|
14
|
+
applyFiltering(params);
|
|
15
|
+
}
|
|
16
|
+
constructor(){
|
|
17
|
+
this.fieldType = FILTER_DEFAULT;
|
|
14
18
|
}
|
|
15
|
-
applyFiltering(params);
|
|
16
|
-
}
|
|
17
19
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
const DefaultFilter = CmsEntryOpenSearchFilter.createImplementation({
|
|
21
|
+
implementation: DefaultFilterImpl,
|
|
22
|
+
dependencies: []
|
|
21
23
|
});
|
|
24
|
+
export { DefaultFilter };
|
|
22
25
|
|
|
23
26
|
//# sourceMappingURL=DefaultFilter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/CmsEntryOpenSearchFilter/fields/DefaultFilter.js","sources":["../../../../src/features/CmsEntryOpenSearchFilter/fields/DefaultFilter.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsEntryOpenSearchFilter } from \"../abstractions/CmsEntryOpenSearchFilter.js\";\nimport { FILTER_DEFAULT } from \"../constants.js\";\n\nclass DefaultFilterImpl implements CmsEntryOpenSearchFilter.Interface {\n public readonly fieldType = FILTER_DEFAULT;\n\n public exec(params: CmsEntryOpenSearchFilter.ExecParams): void {\n const { applyFiltering, field } = params;\n if (!field.searchable) {\n const identifier = [...field.parents.map(p => p.fieldId), field.field.fieldId].join(\n \".\"\n );\n throw new WebinyError(`Field \"${identifier}\" is not searchable.`);\n }\n applyFiltering(params);\n }\n}\n\nexport const DefaultFilter = CmsEntryOpenSearchFilter.createImplementation({\n implementation: DefaultFilterImpl,\n dependencies: []\n});\n"],"names":["DefaultFilterImpl","params","applyFiltering","field","identifier","p","WebinyError","FILTER_DEFAULT","DefaultFilter","CmsEntryOpenSearchFilter"],"mappings":";;;AAIA,MAAMA;IAGK,KAAKC,MAA2C,EAAQ;QAC3D,MAAM,EAAEC,cAAc,EAAEC,KAAK,EAAE,GAAGF;QAClC,IAAI,CAACE,MAAM,UAAU,EAAE;YACnB,MAAMC,aAAa;mBAAID,MAAM,OAAO,CAAC,GAAG,CAACE,CAAAA,IAAKA,EAAE,OAAO;gBAAGF,MAAM,KAAK,CAAC,OAAO;aAAC,CAAC,IAAI,CAC/E;YAEJ,MAAM,IAAIG,MAAY,CAAC,OAAO,EAAEF,WAAW,oBAAoB,CAAC;QACpE;QACAF,eAAeD;IACnB;;aAXgB,SAAS,GAAGM;;AAYhC;AAEO,MAAMC,gBAAgBC,yBAAyB,oBAAoB,CAAC;IACvE,gBAAgBT;IAChB,cAAc,EAAE;AACpB"}
|