@webiny/api-headless-cms-ddb-es 6.3.0 → 6.4.0-beta.1

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.
Files changed (217) hide show
  1. package/configurations.js +27 -35
  2. package/configurations.js.map +1 -1
  3. package/definitions/entry.js +7 -9
  4. package/definitions/entry.js.map +1 -1
  5. package/definitions/group.js +7 -9
  6. package/definitions/group.js.map +1 -1
  7. package/definitions/model.js +7 -9
  8. package/definitions/model.js.map +1 -1
  9. package/definitions/types.d.ts +1 -0
  10. package/definitions/types.js +0 -3
  11. package/elasticsearch/createElasticsearchIndex.js +50 -67
  12. package/elasticsearch/createElasticsearchIndex.js.map +1 -1
  13. package/elasticsearch/deleteElasticsearchIndex.js +18 -26
  14. package/elasticsearch/deleteElasticsearchIndex.js.map +1 -1
  15. package/exports/api/cms/opensearch.js +2 -4
  16. package/feature.js +144 -153
  17. package/feature.js.map +1 -1
  18. package/features/CmsEntryOpenSearchBodyModifier/abstractions.js +2 -1
  19. package/features/CmsEntryOpenSearchBodyModifier/abstractions.js.map +1 -1
  20. package/features/CmsEntryOpenSearchBodyModifier/index.js +0 -2
  21. package/features/CmsEntryOpenSearchFieldIndex/CmsEntryOpenSearchFieldIndexRegistry.d.ts +2 -1
  22. package/features/CmsEntryOpenSearchFieldIndex/CmsEntryOpenSearchFieldIndexRegistry.js +33 -27
  23. package/features/CmsEntryOpenSearchFieldIndex/CmsEntryOpenSearchFieldIndexRegistry.js.map +1 -1
  24. package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndex.d.ts +0 -3
  25. package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndex.js +2 -1
  26. package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndex.js.map +1 -1
  27. package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndexRegistry.js +2 -1
  28. package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndexRegistry.js.map +1 -1
  29. package/features/CmsEntryOpenSearchFieldIndex/constants.js +2 -1
  30. package/features/CmsEntryOpenSearchFieldIndex/constants.js.map +1 -1
  31. package/features/CmsEntryOpenSearchFieldIndex/feature.js +15 -12
  32. package/features/CmsEntryOpenSearchFieldIndex/feature.js.map +1 -1
  33. package/features/CmsEntryOpenSearchFieldIndex/fields/DateTimeFieldIndex.js +48 -65
  34. package/features/CmsEntryOpenSearchFieldIndex/fields/DateTimeFieldIndex.js.map +1 -1
  35. package/features/CmsEntryOpenSearchFieldIndex/fields/DefaultFieldIndex.d.ts +5 -2
  36. package/features/CmsEntryOpenSearchFieldIndex/fields/DefaultFieldIndex.js +24 -30
  37. package/features/CmsEntryOpenSearchFieldIndex/fields/DefaultFieldIndex.js.map +1 -1
  38. package/features/CmsEntryOpenSearchFieldIndex/fields/JsonFieldIndex.js +15 -16
  39. package/features/CmsEntryOpenSearchFieldIndex/fields/JsonFieldIndex.js.map +1 -1
  40. package/features/CmsEntryOpenSearchFieldIndex/fields/LongTextFieldIndex.js +15 -18
  41. package/features/CmsEntryOpenSearchFieldIndex/fields/LongTextFieldIndex.js.map +1 -1
  42. package/features/CmsEntryOpenSearchFieldIndex/fields/NumberFieldIndex.js +24 -29
  43. package/features/CmsEntryOpenSearchFieldIndex/fields/NumberFieldIndex.js.map +1 -1
  44. package/features/CmsEntryOpenSearchFieldIndex/fields/ObjectFieldIndex.d.ts +4 -2
  45. package/features/CmsEntryOpenSearchFieldIndex/fields/ObjectFieldIndex.js +95 -146
  46. package/features/CmsEntryOpenSearchFieldIndex/fields/ObjectFieldIndex.js.map +1 -1
  47. package/features/CmsEntryOpenSearchFieldIndex/fields/RichTextFieldIndex.js +15 -16
  48. package/features/CmsEntryOpenSearchFieldIndex/fields/RichTextFieldIndex.js.map +1 -1
  49. package/features/CmsEntryOpenSearchFieldIndex/fields/TextCompressedFieldIndex.d.ts +14 -0
  50. package/features/CmsEntryOpenSearchFieldIndex/fields/TextCompressedFieldIndex.js +39 -0
  51. package/features/CmsEntryOpenSearchFieldIndex/fields/TextCompressedFieldIndex.js.map +1 -0
  52. package/features/CmsEntryOpenSearchFieldIndex/index.js +0 -2
  53. package/features/CmsEntryOpenSearchFilter/CmsEntryOpenSearchFilterRegistry.js +26 -28
  54. package/features/CmsEntryOpenSearchFilter/CmsEntryOpenSearchFilterRegistry.js.map +1 -1
  55. package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilter.js +2 -1
  56. package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilter.js.map +1 -1
  57. package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilterRegistry.js +2 -1
  58. package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilterRegistry.js.map +1 -1
  59. package/features/CmsEntryOpenSearchFilter/constants.js +2 -1
  60. package/features/CmsEntryOpenSearchFilter/constants.js.map +1 -1
  61. package/features/CmsEntryOpenSearchFilter/feature.js +9 -8
  62. package/features/CmsEntryOpenSearchFilter/feature.js.map +1 -1
  63. package/features/CmsEntryOpenSearchFilter/fields/DefaultFilter.js +18 -15
  64. package/features/CmsEntryOpenSearchFilter/fields/DefaultFilter.js.map +1 -1
  65. package/features/CmsEntryOpenSearchFilter/fields/ObjectFilter.js +35 -53
  66. package/features/CmsEntryOpenSearchFilter/fields/ObjectFilter.js.map +1 -1
  67. package/features/CmsEntryOpenSearchFilter/fields/RefFilter.js +27 -40
  68. package/features/CmsEntryOpenSearchFilter/fields/RefFilter.js.map +1 -1
  69. package/features/CmsEntryOpenSearchFilter/index.js +0 -2
  70. package/features/CmsEntryOpenSearchFullTextSearch/abstractions.js +2 -1
  71. package/features/CmsEntryOpenSearchFullTextSearch/abstractions.js.map +1 -1
  72. package/features/CmsEntryOpenSearchFullTextSearch/index.js +0 -2
  73. package/features/CmsEntryOpenSearchIndex/BaseOpenSearchIndex.js +10 -9
  74. package/features/CmsEntryOpenSearchIndex/BaseOpenSearchIndex.js.map +1 -1
  75. package/features/CmsEntryOpenSearchIndex/abstractions.js +2 -1
  76. package/features/CmsEntryOpenSearchIndex/abstractions.js.map +1 -1
  77. package/features/CmsEntryOpenSearchIndex/feature.js +6 -5
  78. package/features/CmsEntryOpenSearchIndex/feature.js.map +1 -1
  79. package/features/CmsEntryOpenSearchIndex/index.js +0 -2
  80. package/features/CmsEntryOpenSearchQueryModifier/abstractions.js +2 -1
  81. package/features/CmsEntryOpenSearchQueryModifier/abstractions.js.map +1 -1
  82. package/features/CmsEntryOpenSearchQueryModifier/index.js +0 -2
  83. package/features/CmsEntryOpenSearchSortModifier/abstractions.js +2 -1
  84. package/features/CmsEntryOpenSearchSortModifier/abstractions.js.map +1 -1
  85. package/features/CmsEntryOpenSearchSortModifier/index.js +0 -2
  86. package/features/CmsEntryOpenSearchValueSearch/CmsEntryOpenSearchValueSearchRegistry.js +24 -20
  87. package/features/CmsEntryOpenSearchValueSearch/CmsEntryOpenSearchValueSearchRegistry.js.map +1 -1
  88. package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearch.js +2 -1
  89. package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearch.js.map +1 -1
  90. package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearchRegistry.js +2 -1
  91. package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearchRegistry.js.map +1 -1
  92. package/features/CmsEntryOpenSearchValueSearch/feature.js +9 -8
  93. package/features/CmsEntryOpenSearchValueSearch/feature.js.map +1 -1
  94. package/features/CmsEntryOpenSearchValueSearch/fields/RefSearch.js +14 -16
  95. package/features/CmsEntryOpenSearchValueSearch/fields/RefSearch.js.map +1 -1
  96. package/features/CmsEntryOpenSearchValueSearch/fields/SearchableJsonSearch.js +31 -42
  97. package/features/CmsEntryOpenSearchValueSearch/fields/SearchableJsonSearch.js.map +1 -1
  98. package/features/CmsEntryOpenSearchValueSearch/fields/TimeSearch.js +15 -17
  99. package/features/CmsEntryOpenSearchValueSearch/fields/TimeSearch.js.map +1 -1
  100. package/features/CmsEntryOpenSearchValueSearch/index.js +0 -2
  101. package/features/CmsEntryOpenSearchValuesModifier/abstractions.js +2 -1
  102. package/features/CmsEntryOpenSearchValuesModifier/abstractions.js.map +1 -1
  103. package/features/CmsEntryOpenSearchValuesModifier/index.js +0 -2
  104. package/helpers/entryIndexHelpers.d.ts +1 -1
  105. package/helpers/entryIndexHelpers.js +69 -123
  106. package/helpers/entryIndexHelpers.js.map +1 -1
  107. package/helpers/fieldIdentifier.js +18 -30
  108. package/helpers/fieldIdentifier.js.map +1 -1
  109. package/helpers/index.js +0 -2
  110. package/index.js +0 -2
  111. package/operations/entry/dataLoader/DataLoaderCache.js +22 -26
  112. package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -1
  113. package/operations/entry/dataLoader/constants.js +2 -1
  114. package/operations/entry/dataLoader/constants.js.map +1 -1
  115. package/operations/entry/dataLoader/createBatchScheduleFn.js +6 -15
  116. package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -1
  117. package/operations/entry/dataLoader/getAllEntryRevisions.js +18 -29
  118. package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -1
  119. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +27 -37
  120. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -1
  121. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +27 -37
  122. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -1
  123. package/operations/entry/dataLoader/getRevisionById.js +32 -46
  124. package/operations/entry/dataLoader/getRevisionById.js.map +1 -1
  125. package/operations/entry/dataLoader/index.js +8 -9
  126. package/operations/entry/dataLoader/index.js.map +1 -1
  127. package/operations/entry/dataLoader/types.js +0 -3
  128. package/operations/entry/dataLoaders.js +81 -99
  129. package/operations/entry/dataLoaders.js.map +1 -1
  130. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js +6 -24
  131. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js.map +1 -1
  132. package/operations/entry/elasticsearch/body.js +74 -125
  133. package/operations/entry/elasticsearch/body.js.map +1 -1
  134. package/operations/entry/elasticsearch/fields/createSystemField.js +6 -7
  135. package/operations/entry/elasticsearch/fields/createSystemField.js.map +1 -1
  136. package/operations/entry/elasticsearch/fields/live.js +45 -40
  137. package/operations/entry/elasticsearch/fields/live.js.map +1 -1
  138. package/operations/entry/elasticsearch/fields/location.js +45 -40
  139. package/operations/entry/elasticsearch/fields/location.js.map +1 -1
  140. package/operations/entry/elasticsearch/fields/state.js +99 -88
  141. package/operations/entry/elasticsearch/fields/state.js.map +1 -1
  142. package/operations/entry/elasticsearch/fields.js +193 -217
  143. package/operations/entry/elasticsearch/fields.js.map +1 -1
  144. package/operations/entry/elasticsearch/filtering/applyFiltering.js +32 -45
  145. package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +1 -1
  146. package/operations/entry/elasticsearch/filtering/exec.js +85 -114
  147. package/operations/entry/elasticsearch/filtering/exec.js.map +1 -1
  148. package/operations/entry/elasticsearch/filtering/index.js +0 -2
  149. package/operations/entry/elasticsearch/filtering/path.js +24 -33
  150. package/operations/entry/elasticsearch/filtering/path.js.map +1 -1
  151. package/operations/entry/elasticsearch/filtering/populated.js +8 -14
  152. package/operations/entry/elasticsearch/filtering/populated.js.map +1 -1
  153. package/operations/entry/elasticsearch/filtering/values.js +11 -12
  154. package/operations/entry/elasticsearch/filtering/values.js.map +1 -1
  155. package/operations/entry/elasticsearch/fullTextSearch.js +43 -80
  156. package/operations/entry/elasticsearch/fullTextSearch.js.map +1 -1
  157. package/operations/entry/elasticsearch/fullTextSearchFields.js +7 -17
  158. package/operations/entry/elasticsearch/fullTextSearchFields.js.map +1 -1
  159. package/operations/entry/elasticsearch/initialQuery.js +37 -80
  160. package/operations/entry/elasticsearch/initialQuery.js.map +1 -1
  161. package/operations/entry/elasticsearch/keyword.js +13 -27
  162. package/operations/entry/elasticsearch/keyword.js.map +1 -1
  163. package/operations/entry/elasticsearch/plugins/operator.js +9 -20
  164. package/operations/entry/elasticsearch/plugins/operator.js.map +1 -1
  165. package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js +6 -4
  166. package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js.map +1 -1
  167. package/operations/entry/elasticsearch/sort.js +69 -92
  168. package/operations/entry/elasticsearch/sort.js.map +1 -1
  169. package/operations/entry/elasticsearch/transformValueForSearch.js +9 -14
  170. package/operations/entry/elasticsearch/transformValueForSearch.js.map +1 -1
  171. package/operations/entry/elasticsearch/types.js +0 -3
  172. package/operations/entry/index.js +1313 -1709
  173. package/operations/entry/index.js.map +1 -1
  174. package/operations/entry/keys.js +43 -63
  175. package/operations/entry/keys.js.map +1 -1
  176. package/operations/entry/recordType.js +4 -9
  177. package/operations/entry/recordType.js.map +1 -1
  178. package/operations/entry/transformations/convertEntryKeys.js +21 -26
  179. package/operations/entry/transformations/convertEntryKeys.js.map +1 -1
  180. package/operations/entry/transformations/index.d.ts +0 -2
  181. package/operations/entry/transformations/index.js +84 -114
  182. package/operations/entry/transformations/index.js.map +1 -1
  183. package/operations/entry/transformations/modifyEntryValues.d.ts +1 -1
  184. package/operations/entry/transformations/modifyEntryValues.js +12 -17
  185. package/operations/entry/transformations/modifyEntryValues.js.map +1 -1
  186. package/operations/entry/transformations/transformEntryKeys.js +13 -16
  187. package/operations/entry/transformations/transformEntryKeys.js.map +1 -1
  188. package/operations/entry/transformations/transformEntryToIndex.d.ts +0 -2
  189. package/operations/entry/transformations/transformEntryToIndex.js +16 -22
  190. package/operations/entry/transformations/transformEntryToIndex.js.map +1 -1
  191. package/operations/group/index.js +113 -134
  192. package/operations/group/index.js.map +1 -1
  193. package/operations/model/index.js +128 -156
  194. package/operations/model/index.js.map +1 -1
  195. package/package.json +24 -24
  196. package/tasks/createIndexTaskPlugin.js +35 -38
  197. package/tasks/createIndexTaskPlugin.js.map +1 -1
  198. package/types.js +7 -13
  199. package/types.js.map +1 -1
  200. package/values/NoValueContainer.js +8 -10
  201. package/values/NoValueContainer.js.map +1 -1
  202. package/definitions/types.js.map +0 -1
  203. package/exports/api/cms/opensearch.js.map +0 -1
  204. package/features/CmsEntryOpenSearchBodyModifier/index.js.map +0 -1
  205. package/features/CmsEntryOpenSearchFieldIndex/index.js.map +0 -1
  206. package/features/CmsEntryOpenSearchFilter/index.js.map +0 -1
  207. package/features/CmsEntryOpenSearchFullTextSearch/index.js.map +0 -1
  208. package/features/CmsEntryOpenSearchIndex/index.js.map +0 -1
  209. package/features/CmsEntryOpenSearchQueryModifier/index.js.map +0 -1
  210. package/features/CmsEntryOpenSearchSortModifier/index.js.map +0 -1
  211. package/features/CmsEntryOpenSearchValueSearch/index.js.map +0 -1
  212. package/features/CmsEntryOpenSearchValuesModifier/index.js.map +0 -1
  213. package/helpers/index.js.map +0 -1
  214. package/index.js.map +0 -1
  215. package/operations/entry/dataLoader/types.js.map +0 -1
  216. package/operations/entry/elasticsearch/filtering/index.js.map +0 -1
  217. package/operations/entry/elasticsearch/types.js.map +0 -1
@@ -1,158 +1,107 @@
1
1
  import { getFieldIdentifiers } from "../../../helpers/index.js";
2
2
  import { CmsEntryOpenSearchFieldIndex } from "../abstractions/CmsEntryOpenSearchFieldIndex.js";
3
- const processToIndex = params => {
4
- const {
5
- fields,
6
- value: sourceValue,
7
- rawValue: sourceRawValue,
8
- getFieldIndex,
9
- fieldRegistry,
10
- model
11
- } = params;
12
- return fields.reduce((values, field) => {
13
- const plugin = getFieldIndex(field.type);
14
- const identifiers = getFieldIdentifiers(sourceValue, sourceRawValue, field);
15
- if (!identifiers) {
16
- return values;
17
- }
18
- const {
19
- value,
20
- rawValue
21
- } = plugin.toIndex({
22
- model,
23
- field,
24
- value: sourceValue[identifiers.valueIdentifier || identifiers.rawValueIdentifier],
25
- rawValue: sourceRawValue[identifiers.rawValueIdentifier || identifiers.valueIdentifier],
26
- getFieldIndex,
27
- fieldRegistry
28
- });
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
- };
41
- const processFromIndex = params => {
42
- const {
43
- fields,
44
- value: sourceValue,
45
- rawValue: sourceRawValue,
46
- getFieldIndex,
47
- fieldRegistry,
48
- model
49
- } = params;
50
- return fields.reduce((values, field) => {
51
- const plugin = getFieldIndex(field.type);
52
- const identifiers = getFieldIdentifiers(sourceValue, sourceRawValue, field);
53
- if (!identifiers) {
54
- return values;
55
- }
56
- const value = plugin.fromIndex({
57
- fieldRegistry,
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
- }, {});
69
- };
70
3
  class ObjectFieldIndexImpl {
71
- fieldType = "object";
72
- toIndex({
73
- fieldRegistry,
74
- model,
75
- field,
76
- value: initialValue,
77
- rawValue: initialRawValue,
78
- getFieldIndex
79
- }) {
80
- if (!initialValue) {
81
- return {
82
- value: null
83
- };
4
+ toIndex({ model, field, value: initialValue, rawValue: initialRawValue, getFieldIndex }) {
5
+ if (!initialValue) return {
6
+ value: null
7
+ };
8
+ const fields = field.settings?.fields || [];
9
+ if (field.list) {
10
+ const result = {
11
+ value: [],
12
+ rawValue: []
13
+ };
14
+ for(const key in initialValue){
15
+ const { value, rawValue } = this.processToIndex({
16
+ value: initialValue[key],
17
+ rawValue: initialRawValue[key],
18
+ getFieldIndex,
19
+ model,
20
+ fields
21
+ });
22
+ result.value.push(value);
23
+ result.rawValue.push(rawValue);
24
+ }
25
+ return {
26
+ value: result.value.length > 0 ? result.value : void 0,
27
+ rawValue: result.rawValue.length > 0 ? result.rawValue : void 0
28
+ };
29
+ }
30
+ return this.processToIndex({
31
+ value: initialValue,
32
+ rawValue: initialRawValue,
33
+ getFieldIndex,
34
+ model,
35
+ fields
36
+ });
84
37
  }
85
- const fields = field.settings?.fields || [];
86
- if (field.list) {
87
- const result = {
88
- value: [],
89
- rawValue: []
90
- };
91
- for (const key in initialValue) {
92
- const {
93
- value,
94
- rawValue
95
- } = processToIndex({
96
- value: initialValue[key],
97
- rawValue: initialRawValue[key],
98
- getFieldIndex,
99
- model,
100
- fieldRegistry,
101
- fields
38
+ fromIndex({ field, value, rawValue, model, getFieldIndex }) {
39
+ if (!value) return null;
40
+ const fields = field.settings?.fields || [];
41
+ if (field.list) {
42
+ const source = value || rawValue || [];
43
+ return source.map((_, index)=>this.processFromIndex({
44
+ value: value ? value[index] || {} : {},
45
+ rawValue: rawValue ? rawValue[index] || {} : {},
46
+ getFieldIndex,
47
+ model,
48
+ fields
49
+ }));
50
+ }
51
+ return this.processFromIndex({
52
+ value,
53
+ rawValue,
54
+ getFieldIndex,
55
+ model,
56
+ fields
102
57
  });
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
58
  }
111
- return processToIndex({
112
- value: initialValue,
113
- rawValue: initialRawValue,
114
- getFieldIndex,
115
- model,
116
- fieldRegistry,
117
- fields
118
- });
119
- }
120
- fromIndex({
121
- field,
122
- value,
123
- rawValue,
124
- model,
125
- getFieldIndex,
126
- fieldRegistry
127
- }) {
128
- if (!value) {
129
- return null;
59
+ processToIndex(params) {
60
+ const { fields, value: sourceValue, rawValue: sourceRawValue, getFieldIndex, model } = params;
61
+ return fields.reduce((values, field)=>{
62
+ const plugin = getFieldIndex(field.type);
63
+ const identifiers = getFieldIdentifiers(sourceValue, sourceRawValue, field);
64
+ if (!identifiers) return values;
65
+ const { value, rawValue } = plugin.toIndex({
66
+ model,
67
+ field,
68
+ value: sourceValue[identifiers.valueIdentifier || identifiers.rawValueIdentifier],
69
+ rawValue: sourceRawValue[identifiers.rawValueIdentifier || identifiers.valueIdentifier],
70
+ getFieldIndex
71
+ });
72
+ if (void 0 !== value) values.value[identifiers.valueIdentifier || identifiers.rawValueIdentifier] = value;
73
+ if (void 0 !== rawValue) values.rawValue[identifiers.rawValueIdentifier || identifiers.valueIdentifier] = rawValue;
74
+ return values;
75
+ }, {
76
+ value: {},
77
+ rawValue: {}
78
+ });
130
79
  }
131
- const fields = field.settings?.fields || [];
132
- if (field.list) {
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
- }));
80
+ constructor(){
81
+ this.fieldType = "object";
82
+ this.processFromIndex = (params)=>{
83
+ const { fields, value: sourceValue, rawValue: sourceRawValue, getFieldIndex, model } = params;
84
+ return fields.reduce((values, field)=>{
85
+ const plugin = getFieldIndex(field.type);
86
+ const identifiers = getFieldIdentifiers(sourceValue, sourceRawValue, field);
87
+ if (!identifiers) return values;
88
+ const value = plugin.fromIndex({
89
+ model,
90
+ field,
91
+ value: sourceValue[identifiers.valueIdentifier || identifiers.rawValueIdentifier],
92
+ rawValue: sourceRawValue ? sourceRawValue[identifiers.rawValueIdentifier || identifiers.valueIdentifier] : null,
93
+ getFieldIndex
94
+ });
95
+ if (void 0 !== value) values[identifiers.valueIdentifier || identifiers.rawValueIdentifier] = value;
96
+ return values;
97
+ }, {});
98
+ };
142
99
  }
143
- return processFromIndex({
144
- value,
145
- rawValue,
146
- getFieldIndex,
147
- model,
148
- fieldRegistry,
149
- fields
150
- });
151
- }
152
100
  }
153
- export const ObjectFieldIndex = CmsEntryOpenSearchFieldIndex.createImplementation({
154
- implementation: ObjectFieldIndexImpl,
155
- dependencies: []
101
+ const ObjectFieldIndex = CmsEntryOpenSearchFieldIndex.createImplementation({
102
+ implementation: ObjectFieldIndexImpl,
103
+ dependencies: []
156
104
  });
105
+ export { ObjectFieldIndex };
157
106
 
158
107
  //# 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;EACnE,MAAM;IACFC,MAAM;IACNC,KAAK,EAAEC,WAAW;IAClBC,QAAQ,EAAEC,cAAc;IACxBC,aAAa;IACbC,aAAa;IACbC;EACJ,CAAC,GAAGR,MAAM;EAEV,OAAOC,MAAM,CAACQ,MAAM,CAChB,CAACC,MAAM,EAAEC,KAAK,KAAK;IACf,MA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,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 { 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 model: CmsModel;\n}\n\ninterface ReducerValue {\n value: Record<string, any>;\n rawValue: Record<string, any>;\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 model: CmsModel;\n}\n\nclass ObjectFieldIndexImpl implements CmsEntryOpenSearchFieldIndex.Interface {\n public readonly fieldType = \"object\";\n\n public toIndex({\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 } = this.processToIndex({\n value: initialValue[key],\n rawValue: initialRawValue[key],\n getFieldIndex,\n model,\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 this.processToIndex({\n value: initialValue,\n rawValue: initialRawValue,\n getFieldIndex,\n model,\n fields\n });\n }\n\n public fromIndex({\n field,\n value,\n rawValue,\n model,\n getFieldIndex\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 this.processFromIndex({\n value: value ? value[index] || {} : {},\n rawValue: rawValue ? rawValue[index] || {} : {},\n getFieldIndex,\n model,\n fields\n })\n );\n }\n\n return this.processFromIndex({\n value,\n rawValue,\n getFieldIndex,\n model,\n fields\n });\n }\n\n private processToIndex(params: ProcessToIndexParams): ReducerValue {\n const {\n fields,\n value: sourceValue,\n rawValue: sourceRawValue,\n getFieldIndex,\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[\n identifiers.valueIdentifier || identifiers.rawValueIdentifier\n ],\n rawValue:\n sourceRawValue[\n identifiers.rawValueIdentifier || identifiers.valueIdentifier\n ],\n getFieldIndex\n });\n\n if (value !== undefined) {\n values.value[identifiers.valueIdentifier || identifiers.rawValueIdentifier] =\n 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\n private processFromIndex = (params: ProcessFromIndexParams): Record<string, any> => {\n const {\n fields,\n value: sourceValue,\n rawValue: sourceRawValue,\n getFieldIndex,\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 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}\n\nexport const ObjectFieldIndex = CmsEntryOpenSearchFieldIndex.createImplementation({\n implementation: ObjectFieldIndexImpl,\n dependencies: []\n});\n"],"names":["ObjectFieldIndexImpl","model","field","initialValue","initialRawValue","getFieldIndex","fields","result","key","value","rawValue","undefined","source","_","index","params","sourceValue","sourceRawValue","values","plugin","identifiers","getFieldIdentifiers","ObjectFieldIndex","CmsEntryOpenSearchFieldIndex"],"mappings":";;AAyBA,MAAMA;IAGK,QAAQ,EACXC,KAAK,EACLC,KAAK,EACL,OAAOC,YAAY,EACnB,UAAUC,eAAe,EACzBC,aAAa,EACsB,EAAwC;QAC3E,IAAI,CAACF,cACD,OAAO;YAAE,OAAO;QAAK;QAGzB,MAAMG,SAAUJ,MAAM,QAAQ,EAAE,UAAU,EAAE;QAE5C,IAAIA,MAAM,IAAI,EAAE;YACZ,MAAMK,SAA4E;gBAC9E,OAAO,EAAE;gBACT,UAAU,EAAE;YAChB;YACA,IAAK,MAAMC,OAAOL,aAAc;gBAC5B,MAAM,EAAEM,KAAK,EAAEC,QAAQ,EAAE,GAAG,IAAI,CAAC,cAAc,CAAC;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GAAG,CAAC;QACR;;AACJ;AAEO,MAAMI,mBAAmBC,6BAA6B,oBAAoB,CAAC;IAC9E,gBAAgBvB;IAChB,cAAc,EAAE;AACpB"}
@@ -1,22 +1,21 @@
1
1
  import { CmsEntryOpenSearchFieldIndex } from "../abstractions/CmsEntryOpenSearchFieldIndex.js";
2
2
  class RichTextFieldIndexImpl {
3
- fieldType = "rich-text";
4
- toIndex({
5
- value
6
- }) {
7
- return {
8
- rawValue: value
9
- };
10
- }
11
- fromIndex({
12
- rawValue
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
- export const RichTextFieldIndex = CmsEntryOpenSearchFieldIndex.createImplementation({
18
- implementation: RichTextFieldIndexImpl,
19
- dependencies: []
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,"names":["CmsEntryOpenSearchFieldIndex","RichTextFieldIndexImpl","fieldType","toIndex","value","rawValue","fromIndex","RichTextFieldIndex","createImplementation","implementation","dependencies"],"sources":["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"],"mappings":"AAAA,SAASA,4BAA4B;AAErC,MAAMC,sBAAsB,CAAmD;EAC3DC,SAAS,GAAG,WAAW;EAEhCC,OAAOA,CAAC;IACXC;EACkC,CAAC,EAAwC;IAC3E,OAAO;MACHC,QAAQ,EAAED;IACd,CAAC;EACL;EAEOE,SAASA,CAAC;IAAED;EAAiD,CAAC,EAAO;IACxE,OAAOA,QAAQ;EACnB;AACJ;AAEA,OAAO,MAAME,kBAAkB,GAAGP,4BAA4B,CAACQ,oBAAoB,CAAC;EAChFC,cAAc,EAAER,sBAAsB;EACtCS,YAAY,EAAE;AAClB,CAAC,CAAC","ignoreList":[]}
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"}
@@ -0,0 +1,14 @@
1
+ import { CmsEntryOpenSearchFieldIndex } from "../abstractions/CmsEntryOpenSearchFieldIndex.js";
2
+ import { CmsModelFieldToGraphQLRegistry } from "@webiny/api-headless-cms/exports/api/cms/graphql.js";
3
+ declare class TextCompressedFieldIndexImpl implements CmsEntryOpenSearchFieldIndex.Interface {
4
+ private readonly fieldRegistry;
5
+ readonly fieldType = "text:compressed";
6
+ constructor(fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface);
7
+ toIndex(params: CmsEntryOpenSearchFieldIndex.ToIndex): CmsEntryOpenSearchFieldIndex.ToValue;
8
+ fromIndex(params: CmsEntryOpenSearchFieldIndex.FromIndex): any;
9
+ private isSearchable;
10
+ }
11
+ export declare const TextCompressedFieldIndex: typeof TextCompressedFieldIndexImpl & {
12
+ __abstraction: import("@webiny/di").Abstraction<import("../abstractions/CmsEntryOpenSearchFieldIndex.js").ICmsEntryOpenSearchFieldIndex>;
13
+ };
14
+ export {};
@@ -0,0 +1,39 @@
1
+ import { CmsEntryOpenSearchFieldIndex } from "../abstractions/CmsEntryOpenSearchFieldIndex.js";
2
+ import { CmsModelFieldToGraphQLRegistry } from "@webiny/api-headless-cms/exports/api/cms/graphql.js";
3
+ class TextCompressedFieldIndexImpl {
4
+ constructor(fieldRegistry){
5
+ this.fieldRegistry = fieldRegistry;
6
+ this.fieldType = "text:compressed";
7
+ }
8
+ toIndex(params) {
9
+ const { field, value } = params;
10
+ const isSearchable = this.isSearchable(field);
11
+ if (isSearchable) return {
12
+ value
13
+ };
14
+ return {
15
+ rawValue: value
16
+ };
17
+ }
18
+ fromIndex(params) {
19
+ const { field, value, rawValue } = params;
20
+ const isSearchable = this.isSearchable(field);
21
+ if (isSearchable) return void 0 === value ? rawValue : value;
22
+ return void 0 === rawValue ? value : rawValue;
23
+ }
24
+ isSearchable(field) {
25
+ const fieldType = this.fieldRegistry.get(field.type);
26
+ if (!fieldType?.isSearchable) return false;
27
+ if (field.settings?.disableFullTextSearch === true) return false;
28
+ return true;
29
+ }
30
+ }
31
+ const TextCompressedFieldIndex = CmsEntryOpenSearchFieldIndex.createImplementation({
32
+ implementation: TextCompressedFieldIndexImpl,
33
+ dependencies: [
34
+ CmsModelFieldToGraphQLRegistry
35
+ ]
36
+ });
37
+ export { TextCompressedFieldIndex };
38
+
39
+ //# sourceMappingURL=TextCompressedFieldIndex.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/CmsEntryOpenSearchFieldIndex/fields/TextCompressedFieldIndex.js","sources":["../../../../src/features/CmsEntryOpenSearchFieldIndex/fields/TextCompressedFieldIndex.ts"],"sourcesContent":["import { CmsEntryOpenSearchFieldIndex } from \"../abstractions/CmsEntryOpenSearchFieldIndex.js\";\nimport type { CmsModelField } from \"@webiny/api-headless-cms/types/index.js\";\nimport { CmsModelFieldToGraphQLRegistry } from \"@webiny/api-headless-cms/exports/api/cms/graphql.js\";\n\nclass TextCompressedFieldIndexImpl implements CmsEntryOpenSearchFieldIndex.Interface {\n public readonly fieldType = \"text:compressed\";\n\n public constructor(private readonly fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface) {}\n\n public toIndex(\n params: CmsEntryOpenSearchFieldIndex.ToIndex\n ): CmsEntryOpenSearchFieldIndex.ToValue {\n const { field, value } = params;\n const isSearchable = this.isSearchable(field);\n\n if (isSearchable) {\n return { value };\n }\n\n return {\n rawValue: value\n };\n }\n\n public fromIndex(params: CmsEntryOpenSearchFieldIndex.FromIndex): any {\n const { field, value, rawValue } = params;\n const isSearchable = this.isSearchable(field);\n\n if (isSearchable) {\n return value === undefined ? rawValue : value;\n }\n return rawValue === undefined ? value : rawValue;\n }\n\n private isSearchable(field: CmsModelField): boolean {\n const fieldType = this.fieldRegistry.get(field.type);\n if (!fieldType?.isSearchable) {\n return false;\n } else if (field.settings?.disableFullTextSearch === true) {\n return false;\n }\n return true;\n }\n}\n\nexport const TextCompressedFieldIndex = CmsEntryOpenSearchFieldIndex.createImplementation({\n implementation: TextCompressedFieldIndexImpl,\n dependencies: [CmsModelFieldToGraphQLRegistry]\n});\n"],"names":["TextCompressedFieldIndexImpl","fieldRegistry","params","field","value","isSearchable","rawValue","undefined","fieldType","TextCompressedFieldIndex","CmsEntryOpenSearchFieldIndex","CmsModelFieldToGraphQLRegistry"],"mappings":";;AAIA,MAAMA;IAGF,YAAoCC,aAAuD,CAAE;aAAzDA,aAAa,GAAbA;aAFpB,SAAS,GAAG;IAEkE;IAEvF,QACHC,MAA4C,EACR;QACpC,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAE,GAAGF;QACzB,MAAMG,eAAe,IAAI,CAAC,YAAY,CAACF;QAEvC,IAAIE,cACA,OAAO;YAAED;QAAM;QAGnB,OAAO;YACH,UAAUA;QACd;IACJ;IAEO,UAAUF,MAA8C,EAAO;QAClE,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAEE,QAAQ,EAAE,GAAGJ;QACnC,MAAMG,eAAe,IAAI,CAAC,YAAY,CAACF;QAEvC,IAAIE,cACA,OAAOD,AAAUG,WAAVH,QAAsBE,WAAWF;QAE5C,OAAOE,AAAaC,WAAbD,WAAyBF,QAAQE;IAC5C;IAEQ,aAAaH,KAAoB,EAAW;QAChD,MAAMK,YAAY,IAAI,CAAC,aAAa,CAAC,GAAG,CAACL,MAAM,IAAI;QACnD,IAAI,CAACK,WAAW,cACZ,OAAO;QACJ,IAAIL,MAAM,QAAQ,EAAE,0BAA0B,MACjD,OAAO;QAEX,OAAO;IACX;AACJ;AAEO,MAAMM,2BAA2BC,6BAA6B,oBAAoB,CAAC;IACtF,gBAAgBV;IAChB,cAAc;QAACW;KAA+B;AAClD"}
@@ -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 WebinyError from "@webiny/error";
2
- import { CmsEntryOpenSearchFilterRegistry as Abstraction } from "./abstractions/CmsEntryOpenSearchFilterRegistry.js";
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
- constructor(filters) {
8
- this.filters = filters;
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
- const fallback = this.filters.find(f => {
21
- return f.fieldType === FILTER_DEFAULT;
22
- });
23
- if (fallback) {
24
- return fallback;
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
- export const CmsEntryOpenSearchFilterRegistry = Abstraction.createImplementation({
32
- implementation: CmsEntryOpenSearchFilterRegistryImpl,
33
- dependencies: [[CmsEntryOpenSearchFilter, {
34
- multiple: true
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,"names":["WebinyError","CmsEntryOpenSearchFilterRegistry","Abstraction","CmsEntryOpenSearchFilter","getBaseFieldType","FILTER_DEFAULT","CmsEntryOpenSearchFilterRegistryImpl","constructor","filters","get","type","fieldType","filter","find","f","fallback","createImplementation","implementation","dependencies","multiple"],"sources":["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"],"mappings":"AAAA,OAAOA,WAAW,MAAM,eAAe;AACvC,SAASC,gCAAgC,IAAIC,WAAW;AACxD,SAASC,wBAAwB;AACjC,SAASC,gBAAgB,QAAQ,oDAAoD;AACrF,SAASC,cAAc;AAEvB,MAAMC,oCAAoC,CAAkC;EACjEC,WAAWA,CAAkBC,OAA6C,EAAE;IAAA,KAA/CA,OAA6C,GAA7CA,OAA6C;EAAG;EAE7EC,GAAGA,CAACC,IAAY,EAAsC;IACzD,MAAMC,SAAS,GAAGP,gBAAgB,CAAC;MAAEM;IAAK,CAAC,CAAC;IAC5C,MAAME,MAAM,GAAG,IAAI,CAACJ,OAAO,CAACK,IAAI,CAACC,CAAC,IAAI;MAClC,OAAOA,CAAC,CAACH,SAAS,KAAKA,SAAS;IACpC,CAAC,CAAC;IACF,IAAIC,MAAM,EAAE;MACR,OAAOA,MAAM;IACjB;IACA,MAAMG,QAAQ,GAAG,IAAI,CAACP,OAAO,CAACK,IAAI,CAACC,CAAC,IAAI;MACpC,OAAOA,CAAC,CAACH,SAAS,KAAKN,cAAc;IACzC,CAAC,CAAC;IACF,IAAIU,QAAQ,EAAE;MACV,OAAOA,QAAQ;IACnB;IACA,MAAM,IAAIf,WAAW,CACjB,gDAAgDW,SAAS,IAAI,EAC7D,uBAAuB,EACvB;MACIA;IACJ,CACJ,CAAC;EACL;AACJ;AAEA,OAAO,MAAMV,gCAAgC,GAAGC,WAAW,CAACc,oBAAoB,CAAC;EAC7EC,cAAc,EAAEX,oCAAoC;EACpDY,YAAY,EAAE,CAAC,CAACf,wBAAwB,EAAE;IAAEgB,QAAQ,EAAE;EAAK,CAAC,CAAC;AACjE,CAAC,CAAC","ignoreList":[]}
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
- export const CmsEntryOpenSearchFilter = createAbstraction("Cms/Entry/OpenSearch/Filter");
2
+ const CmsEntryOpenSearchFilter = createAbstraction("Cms/Entry/OpenSearch/Filter");
3
+ export { CmsEntryOpenSearchFilter };
3
4
 
4
5
  //# sourceMappingURL=CmsEntryOpenSearchFilter.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createAbstraction","CmsEntryOpenSearchFilter"],"sources":["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"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;AAoCvD,OAAO,MAAMC,wBAAwB,GAAGD,iBAAiB,CACrD,6BACJ,CAAC","ignoreList":[]}
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
- export const CmsEntryOpenSearchFilterRegistry = createAbstraction("Cms/Entry/OpenSearch/FilterRegistry");
2
+ const CmsEntryOpenSearchFilterRegistry = createAbstraction("Cms/Entry/OpenSearch/FilterRegistry");
3
+ export { CmsEntryOpenSearchFilterRegistry };
3
4
 
4
5
  //# sourceMappingURL=CmsEntryOpenSearchFilterRegistry.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createAbstraction","CmsEntryOpenSearchFilterRegistry"],"sources":["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"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;AAOvD,OAAO,MAAMC,gCAAgC,GACzCD,iBAAiB,CAAoC,qCAAqC,CAAC","ignoreList":[]}
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,3 +1,4 @@
1
- export const FILTER_DEFAULT = "*";
1
+ const FILTER_DEFAULT = "*";
2
+ export { FILTER_DEFAULT };
2
3
 
3
4
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["FILTER_DEFAULT"],"sources":["constants.ts"],"sourcesContent":["export const FILTER_DEFAULT = \"*\" as const;\n"],"mappings":"AAAA,OAAO,MAAMA,cAAc,GAAG,GAAY","ignoreList":[]}
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
- export 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
- }
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,"names":["createFeature","DefaultFilter","RefFilter","ObjectFilter","CmsEntryOpenSearchFilterRegistry","CmsEntryOpenSearchFilterFeature","name","register","container"],"sources":["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"],"mappings":"AAAA,SAASA,aAAa,QAAQ,qBAAqB;AACnD,SAASC,aAAa;AACtB,SAASC,SAAS;AAClB,SAASC,YAAY;AACrB,SAASC,gCAAgC;AAEzC,OAAO,MAAMC,+BAA+B,GAAGL,aAAa,CAAC;EACzDM,IAAI,EAAE,oCAAoC;EAC1CC,QAAQ,EAAEC,SAAS,IAAI;IACnBA,SAAS,CAACD,QAAQ,CAACN,aAAa,CAAC;IACjCO,SAAS,CAACD,QAAQ,CAACL,SAAS,CAAC;IAC7BM,SAAS,CAACD,QAAQ,CAACJ,YAAY,CAAC;IAChCK,SAAS,CAACD,QAAQ,CAACH,gCAAgC,CAAC;EACxD;AACJ,CAAC,CAAC","ignoreList":[]}
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"}