@webiny/api-headless-cms-ddb-es 0.0.0-mt-3 → 0.0.0-unstable.3386f66516

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 (243) hide show
  1. package/configurations.d.ts +2 -2
  2. package/configurations.js +18 -7
  3. package/configurations.js.map +1 -0
  4. package/definitions/entry.d.ts +2 -2
  5. package/definitions/entry.js +6 -7
  6. package/definitions/entry.js.map +1 -0
  7. package/definitions/entryElasticsearch.d.ts +2 -2
  8. package/definitions/entryElasticsearch.js +3 -7
  9. package/definitions/entryElasticsearch.js.map +1 -0
  10. package/definitions/group.d.ts +2 -2
  11. package/definitions/group.js +3 -7
  12. package/definitions/group.js.map +1 -0
  13. package/definitions/model.d.ts +2 -2
  14. package/definitions/model.js +8 -7
  15. package/definitions/model.js.map +1 -0
  16. package/definitions/settings.d.ts +2 -2
  17. package/definitions/settings.js +3 -7
  18. package/definitions/settings.js.map +1 -0
  19. package/definitions/system.d.ts +2 -2
  20. package/definitions/system.js +3 -7
  21. package/definitions/system.js.map +1 -0
  22. package/definitions/table.d.ts +2 -2
  23. package/definitions/table.js.map +1 -0
  24. package/definitions/tableElasticsearch.d.ts +2 -2
  25. package/definitions/tableElasticsearch.js.map +1 -0
  26. package/dynamoDb/index.d.ts +1 -1
  27. package/dynamoDb/index.js +4 -6
  28. package/dynamoDb/index.js.map +1 -0
  29. package/dynamoDb/storage/date.d.ts +3 -3
  30. package/dynamoDb/storage/date.js +80 -46
  31. package/dynamoDb/storage/date.js.map +1 -0
  32. package/dynamoDb/storage/longText.d.ts +7 -4
  33. package/dynamoDb/storage/longText.js +79 -54
  34. package/dynamoDb/storage/longText.js.map +1 -0
  35. package/dynamoDb/storage/richText.d.ts +2 -3
  36. package/dynamoDb/storage/richText.js +85 -67
  37. package/dynamoDb/storage/richText.js.map +1 -0
  38. package/elasticsearch/createElasticsearchIndex.d.ts +9 -0
  39. package/elasticsearch/createElasticsearchIndex.js +60 -0
  40. package/elasticsearch/createElasticsearchIndex.js.map +1 -0
  41. package/elasticsearch/deleteElasticsearchIndex.d.ts +8 -0
  42. package/elasticsearch/deleteElasticsearchIndex.js +43 -0
  43. package/elasticsearch/deleteElasticsearchIndex.js.map +1 -0
  44. package/elasticsearch/index.d.ts +1 -1
  45. package/elasticsearch/index.js +1 -1
  46. package/elasticsearch/index.js.map +1 -0
  47. package/elasticsearch/indexing/dateTimeIndexing.js +15 -1
  48. package/elasticsearch/indexing/dateTimeIndexing.js.map +1 -0
  49. package/elasticsearch/indexing/defaultFieldIndexing.js.map +1 -0
  50. package/elasticsearch/indexing/index.js +1 -1
  51. package/elasticsearch/indexing/index.js.map +1 -0
  52. package/elasticsearch/indexing/longTextIndexing.d.ts +4 -0
  53. package/elasticsearch/indexing/longTextIndexing.js +20 -4
  54. package/elasticsearch/indexing/longTextIndexing.js.map +1 -0
  55. package/elasticsearch/indexing/numberIndexing.js.map +1 -0
  56. package/elasticsearch/indexing/objectIndexing.d.ts +9 -0
  57. package/elasticsearch/indexing/objectIndexing.js +32 -9
  58. package/elasticsearch/indexing/objectIndexing.js.map +1 -0
  59. package/elasticsearch/indexing/richTextIndexing.js.map +1 -0
  60. package/elasticsearch/indices/base.d.ts +2 -0
  61. package/elasticsearch/indices/base.js +15 -0
  62. package/elasticsearch/indices/base.js.map +1 -0
  63. package/elasticsearch/indices/index.d.ts +1 -0
  64. package/elasticsearch/indices/index.js +16 -0
  65. package/elasticsearch/indices/index.js.map +1 -0
  66. package/elasticsearch/indices/japanese.d.ts +2 -0
  67. package/elasticsearch/indices/japanese.js +16 -0
  68. package/elasticsearch/indices/japanese.js.map +1 -0
  69. package/elasticsearch/search/index.d.ts +2 -2
  70. package/elasticsearch/search/index.js +3 -5
  71. package/elasticsearch/search/index.js.map +1 -0
  72. package/elasticsearch/search/refSearch.d.ts +2 -3
  73. package/elasticsearch/search/refSearch.js +27 -16
  74. package/elasticsearch/search/refSearch.js.map +1 -0
  75. package/elasticsearch/search/timeSearch.d.ts +2 -3
  76. package/elasticsearch/search/timeSearch.js +22 -14
  77. package/elasticsearch/search/timeSearch.js.map +1 -0
  78. package/helpers/entryIndexHelpers.js +33 -18
  79. package/helpers/entryIndexHelpers.js.map +1 -0
  80. package/helpers/index.d.ts +0 -1
  81. package/helpers/index.js +0 -13
  82. package/helpers/index.js.map +1 -0
  83. package/index.d.ts +1 -0
  84. package/index.js +132 -34
  85. package/index.js.map +1 -0
  86. package/operations/entry/dataLoaders.d.ts +6 -2
  87. package/operations/entry/dataLoaders.js +31 -13
  88. package/operations/entry/dataLoaders.js.map +1 -0
  89. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.d.ts +18 -0
  90. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js +34 -0
  91. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js.map +1 -0
  92. package/operations/entry/elasticsearch/body.d.ts +13 -0
  93. package/operations/entry/elasticsearch/body.js +162 -0
  94. package/operations/entry/elasticsearch/body.js.map +1 -0
  95. package/operations/entry/elasticsearch/fields.d.ts +9 -0
  96. package/operations/entry/elasticsearch/fields.js +248 -0
  97. package/operations/entry/elasticsearch/fields.js.map +1 -0
  98. package/operations/entry/elasticsearch/filtering/applyFiltering.d.ts +8 -0
  99. package/operations/entry/elasticsearch/filtering/applyFiltering.js +66 -0
  100. package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +1 -0
  101. package/operations/entry/elasticsearch/filtering/exec.d.ts +17 -0
  102. package/operations/entry/elasticsearch/filtering/exec.js +215 -0
  103. package/operations/entry/elasticsearch/filtering/exec.js.map +1 -0
  104. package/operations/entry/elasticsearch/filtering/index.d.ts +1 -0
  105. package/operations/entry/elasticsearch/filtering/index.js +18 -0
  106. package/operations/entry/elasticsearch/filtering/index.js.map +1 -0
  107. package/operations/entry/elasticsearch/filtering/path.d.ts +15 -0
  108. package/operations/entry/elasticsearch/filtering/path.js +52 -0
  109. package/operations/entry/elasticsearch/filtering/path.js.map +1 -0
  110. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.d.ts +2 -0
  111. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js +35 -0
  112. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js.map +1 -0
  113. package/operations/entry/elasticsearch/filtering/plugins/index.d.ts +1 -0
  114. package/operations/entry/elasticsearch/filtering/plugins/index.js +18 -0
  115. package/operations/entry/elasticsearch/filtering/plugins/index.js.map +1 -0
  116. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.d.ts +2 -0
  117. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js +78 -0
  118. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js.map +1 -0
  119. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.d.ts +2 -0
  120. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js +58 -0
  121. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js.map +1 -0
  122. package/operations/entry/elasticsearch/filtering/populated.d.ts +2 -0
  123. package/operations/entry/elasticsearch/filtering/populated.js +30 -0
  124. package/operations/entry/elasticsearch/filtering/populated.js.map +1 -0
  125. package/operations/entry/elasticsearch/filtering/values.d.ts +2 -0
  126. package/operations/entry/elasticsearch/filtering/values.js +28 -0
  127. package/operations/entry/elasticsearch/filtering/values.js.map +1 -0
  128. package/operations/entry/elasticsearch/fullTextSearch.d.ts +9 -0
  129. package/operations/entry/elasticsearch/fullTextSearch.js +34 -0
  130. package/operations/entry/elasticsearch/fullTextSearch.js.map +1 -0
  131. package/operations/entry/elasticsearch/fullTextSearchFields.d.ts +8 -0
  132. package/operations/entry/elasticsearch/fullTextSearchFields.js +52 -0
  133. package/operations/entry/elasticsearch/fullTextSearchFields.js.map +1 -0
  134. package/operations/entry/elasticsearch/initialQuery.d.ts +17 -0
  135. package/operations/entry/elasticsearch/initialQuery.js +117 -0
  136. package/operations/entry/elasticsearch/initialQuery.js.map +1 -0
  137. package/operations/entry/elasticsearch/keyword.d.ts +2 -0
  138. package/operations/entry/elasticsearch/keyword.js +38 -0
  139. package/operations/entry/elasticsearch/keyword.js.map +1 -0
  140. package/operations/entry/elasticsearch/plugins/bodyModifier.d.ts +9 -0
  141. package/operations/entry/elasticsearch/plugins/bodyModifier.js +19 -0
  142. package/operations/entry/elasticsearch/plugins/bodyModifier.js.map +1 -0
  143. package/operations/entry/elasticsearch/plugins/operator.d.ts +8 -0
  144. package/operations/entry/elasticsearch/plugins/operator.js +45 -0
  145. package/operations/entry/elasticsearch/plugins/operator.js.map +1 -0
  146. package/operations/entry/elasticsearch/plugins/queryModifier.d.ts +9 -0
  147. package/operations/entry/elasticsearch/plugins/queryModifier.js +19 -0
  148. package/operations/entry/elasticsearch/plugins/queryModifier.js.map +1 -0
  149. package/operations/entry/elasticsearch/plugins/search.d.ts +7 -0
  150. package/{helpers/searchPluginsList.js → operations/entry/elasticsearch/plugins/search.js} +9 -5
  151. package/operations/entry/elasticsearch/plugins/search.js.map +1 -0
  152. package/operations/entry/elasticsearch/plugins/sortModifier.d.ts +9 -0
  153. package/operations/entry/elasticsearch/plugins/sortModifier.js +19 -0
  154. package/operations/entry/elasticsearch/plugins/sortModifier.js.map +1 -0
  155. package/operations/entry/elasticsearch/sort.d.ts +12 -0
  156. package/operations/entry/elasticsearch/sort.js +97 -0
  157. package/operations/entry/elasticsearch/sort.js.map +1 -0
  158. package/operations/entry/elasticsearch/transformValueForSearch.d.ts +16 -0
  159. package/operations/entry/elasticsearch/transformValueForSearch.js +34 -0
  160. package/operations/entry/elasticsearch/transformValueForSearch.js.map +1 -0
  161. package/operations/entry/elasticsearch/types.d.ts +41 -0
  162. package/operations/entry/elasticsearch/types.js +5 -0
  163. package/operations/entry/elasticsearch/types.js.map +1 -0
  164. package/operations/entry/index.d.ts +2 -4
  165. package/operations/entry/index.js +473 -374
  166. package/operations/entry/index.js.map +1 -0
  167. package/operations/entry/keys.js.map +1 -0
  168. package/operations/entry/recordType.d.ts +3 -0
  169. package/operations/entry/recordType.js +24 -0
  170. package/operations/entry/recordType.js.map +1 -0
  171. package/operations/group/index.d.ts +2 -2
  172. package/operations/group/index.js +8 -15
  173. package/operations/group/index.js.map +1 -0
  174. package/operations/model/index.d.ts +2 -2
  175. package/operations/model/index.js +38 -39
  176. package/operations/model/index.js.map +1 -0
  177. package/operations/settings/index.d.ts +2 -2
  178. package/operations/settings/index.js +7 -13
  179. package/operations/settings/index.js.map +1 -0
  180. package/operations/system/index.d.ts +2 -2
  181. package/operations/system/index.js +5 -11
  182. package/operations/system/index.js.map +1 -0
  183. package/package.json +24 -29
  184. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.d.ts +7 -3
  185. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js +11 -5
  186. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js.map +1 -0
  187. package/plugins/CmsEntryElasticsearchFieldPlugin.d.ts +3 -3
  188. package/plugins/CmsEntryElasticsearchFieldPlugin.js +3 -3
  189. package/plugins/CmsEntryElasticsearchFieldPlugin.js.map +1 -0
  190. package/plugins/CmsEntryElasticsearchIndexPlugin.d.ts +4 -0
  191. package/plugins/CmsEntryElasticsearchIndexPlugin.js +17 -0
  192. package/plugins/CmsEntryElasticsearchIndexPlugin.js.map +1 -0
  193. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.d.ts +30 -0
  194. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js +43 -0
  195. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js.map +1 -0
  196. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.d.ts +4 -3
  197. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js +11 -5
  198. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js.map +1 -0
  199. package/plugins/CmsEntryElasticsearchSortModifierPlugin.d.ts +4 -3
  200. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js +11 -5
  201. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js.map +1 -0
  202. package/plugins/CmsEntryFilterPlugin.d.ts +49 -0
  203. package/plugins/CmsEntryFilterPlugin.js +31 -0
  204. package/plugins/CmsEntryFilterPlugin.js.map +1 -0
  205. package/plugins/index.d.ts +6 -0
  206. package/plugins/index.js +83 -0
  207. package/plugins/index.js.map +1 -0
  208. package/types.d.ts +7 -34
  209. package/types.js +0 -13
  210. package/types.js.map +1 -0
  211. package/helpers/createElasticsearchQueryBody.d.ts +0 -11
  212. package/helpers/createElasticsearchQueryBody.js +0 -375
  213. package/helpers/fields.d.ts +0 -77
  214. package/helpers/fields.js +0 -174
  215. package/helpers/operatorPluginsList.d.ts +0 -7
  216. package/helpers/operatorPluginsList.js +0 -30
  217. package/helpers/searchPluginsList.d.ts +0 -6
  218. package/helpers/transformValueForSearch.d.ts +0 -9
  219. package/helpers/transformValueForSearch.js +0 -26
  220. package/operations/entry/elasticsearchFields.d.ts +0 -2
  221. package/operations/entry/elasticsearchFields.js +0 -32
  222. package/operations/entry/fields.d.ts +0 -3
  223. package/operations/entry/fields.js +0 -60
  224. package/operations/system/createElasticsearchTemplate.d.ts +0 -5
  225. package/operations/system/createElasticsearchTemplate.js +0 -62
  226. package/upgrades/index.d.ts +0 -2
  227. package/upgrades/index.js +0 -16
  228. package/upgrades/utils.d.ts +0 -1
  229. package/upgrades/utils.js +0 -16
  230. package/upgrades/v5.0.0/cleanDatabaseRecord.d.ts +0 -6
  231. package/upgrades/v5.0.0/cleanDatabaseRecord.js +0 -16
  232. package/upgrades/v5.0.0/createOldVersionIndiceName.d.ts +0 -2
  233. package/upgrades/v5.0.0/createOldVersionIndiceName.js +0 -12
  234. package/upgrades/v5.0.0/entryValueFixer.d.ts +0 -4
  235. package/upgrades/v5.0.0/entryValueFixer.js +0 -124
  236. package/upgrades/v5.0.0/fieldFinder.d.ts +0 -6
  237. package/upgrades/v5.0.0/fieldFinder.js +0 -42
  238. package/upgrades/v5.0.0/helpers.d.ts +0 -4
  239. package/upgrades/v5.0.0/helpers.js +0 -57
  240. package/upgrades/v5.0.0/index.d.ts +0 -4
  241. package/upgrades/v5.0.0/index.js +0 -232
  242. package/upgrades/v5.8.0/index.d.ts +0 -4
  243. package/upgrades/v5.8.0/index.js +0 -426
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.getWhereValues = void 0;
9
+
10
+ var _error = _interopRequireDefault(require("@webiny/error"));
11
+
12
+ const getWhereValues = (value, condition) => {
13
+ const values = value;
14
+
15
+ if (!Array.isArray(values)) {
16
+ throw new _error.default(`Trying to run filtering with "${condition}", but the value sent is not an array.`, `MALFORMED_${condition}_CONDITION`, {
17
+ value
18
+ });
19
+ } else if (values.length === 0) {
20
+ throw new _error.default(`Trying to run filtering with "${condition}", but the value sent is empty array.`, `MALFORMED_${condition}_CONDITION`, {
21
+ value
22
+ });
23
+ }
24
+
25
+ return values;
26
+ };
27
+
28
+ exports.getWhereValues = getWhereValues;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getWhereValues","value","condition","values","Array","isArray","WebinyError","length"],"sources":["values.ts"],"sourcesContent":["import { CmsEntryListWhere } from \"@webiny/api-headless-cms/types\";\nimport WebinyError from \"@webiny/error\";\n\nexport const getWhereValues = (value: unknown, condition: \"AND\" | \"OR\") => {\n const values = value as CmsEntryListWhere[] | undefined;\n if (!Array.isArray(values)) {\n throw new WebinyError(\n `Trying to run filtering with \"${condition}\", but the value sent is not an array.`,\n `MALFORMED_${condition}_CONDITION`,\n {\n value\n }\n );\n } else if (values.length === 0) {\n throw new WebinyError(\n `Trying to run filtering with \"${condition}\", but the value sent is empty array.`,\n `MALFORMED_${condition}_CONDITION`,\n {\n value\n }\n );\n }\n return values;\n};\n"],"mappings":";;;;;;;;;AACA;;AAEO,MAAMA,cAAc,GAAG,CAACC,KAAD,EAAiBC,SAAjB,KAA6C;EACvE,MAAMC,MAAM,GAAGF,KAAf;;EACA,IAAI,CAACG,KAAK,CAACC,OAAN,CAAcF,MAAd,CAAL,EAA4B;IACxB,MAAM,IAAIG,cAAJ,CACD,iCAAgCJ,SAAU,wCADzC,EAED,aAAYA,SAAU,YAFrB,EAGF;MACID;IADJ,CAHE,CAAN;EAOH,CARD,MAQO,IAAIE,MAAM,CAACI,MAAP,KAAkB,CAAtB,EAAyB;IAC5B,MAAM,IAAID,cAAJ,CACD,iCAAgCJ,SAAU,uCADzC,EAED,aAAYA,SAAU,YAFrB,EAGF;MACID;IADJ,CAHE,CAAN;EAOH;;EACD,OAAOE,MAAP;AACH,CApBM"}
@@ -0,0 +1,9 @@
1
+ import { ElasticsearchBoolQueryConfig } from "@webiny/api-elasticsearch/types";
2
+ import { CmsModelField } from "@webiny/api-headless-cms/types";
3
+ interface Params {
4
+ query: ElasticsearchBoolQueryConfig;
5
+ term?: string;
6
+ fields: CmsModelField[];
7
+ }
8
+ export declare const applyFullTextSearch: (params: Params) => void;
9
+ export {};
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.applyFullTextSearch = void 0;
7
+
8
+ var _apiElasticsearch = require("@webiny/api-elasticsearch");
9
+
10
+ const applyFullTextSearch = params => {
11
+ const {
12
+ query,
13
+ term,
14
+ fields
15
+ } = params;
16
+
17
+ if (!term || term.length === 0 || fields.length === 0) {
18
+ return;
19
+ }
20
+
21
+ const fieldPaths = fields.map(field => {
22
+ return `values.${field.storageId}`;
23
+ });
24
+ query.must.push({
25
+ query_string: {
26
+ allow_leading_wildcard: true,
27
+ fields: fieldPaths,
28
+ query: (0, _apiElasticsearch.normalizeValue)(term),
29
+ default_operator: "or"
30
+ }
31
+ });
32
+ };
33
+
34
+ exports.applyFullTextSearch = applyFullTextSearch;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["applyFullTextSearch","params","query","term","fields","length","fieldPaths","map","field","storageId","must","push","query_string","allow_leading_wildcard","normalizeValue","default_operator"],"sources":["fullTextSearch.ts"],"sourcesContent":["import { ElasticsearchBoolQueryConfig } from \"@webiny/api-elasticsearch/types\";\nimport { normalizeValue } from \"@webiny/api-elasticsearch\";\nimport { CmsModelField } from \"@webiny/api-headless-cms/types\";\n\ninterface Params {\n query: ElasticsearchBoolQueryConfig;\n term?: string;\n fields: CmsModelField[];\n}\nexport const applyFullTextSearch = (params: Params): void => {\n const { query, term, fields } = params;\n if (!term || term.length === 0 || fields.length === 0) {\n return;\n }\n\n const fieldPaths = fields.map(field => {\n return `values.${field.storageId}`;\n });\n\n query.must.push({\n query_string: {\n allow_leading_wildcard: true,\n fields: fieldPaths,\n query: normalizeValue(term),\n default_operator: \"or\"\n }\n });\n};\n"],"mappings":";;;;;;;AACA;;AAQO,MAAMA,mBAAmB,GAAIC,MAAD,IAA0B;EACzD,MAAM;IAAEC,KAAF;IAASC,IAAT;IAAeC;EAAf,IAA0BH,MAAhC;;EACA,IAAI,CAACE,IAAD,IAASA,IAAI,CAACE,MAAL,KAAgB,CAAzB,IAA8BD,MAAM,CAACC,MAAP,KAAkB,CAApD,EAAuD;IACnD;EACH;;EAED,MAAMC,UAAU,GAAGF,MAAM,CAACG,GAAP,CAAWC,KAAK,IAAI;IACnC,OAAQ,UAASA,KAAK,CAACC,SAAU,EAAjC;EACH,CAFkB,CAAnB;EAIAP,KAAK,CAACQ,IAAN,CAAWC,IAAX,CAAgB;IACZC,YAAY,EAAE;MACVC,sBAAsB,EAAE,IADd;MAEVT,MAAM,EAAEE,UAFE;MAGVJ,KAAK,EAAE,IAAAY,gCAAA,EAAeX,IAAf,CAHG;MAIVY,gBAAgB,EAAE;IAJR;EADF,CAAhB;AAQH,CAlBM"}
@@ -0,0 +1,8 @@
1
+ import { CmsModel, CmsModelField } from "@webiny/api-headless-cms/types";
2
+ interface Params {
3
+ model: CmsModel;
4
+ term?: string;
5
+ fields?: string[];
6
+ }
7
+ export declare const createFullTextSearchFields: (params: Params) => CmsModelField[];
8
+ export {};
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createFullTextSearchFields = void 0;
7
+
8
+ /* eslint-disable */
9
+ const extractFields = fields => {
10
+ return fields.reduce((collection, field) => {
11
+ var _field$settings;
12
+
13
+ if ((_field$settings = field.settings) !== null && _field$settings !== void 0 && _field$settings.fields) {
14
+ collection.push(...extractFields(field.settings.fields));
15
+ } else if (field) {}
16
+
17
+ return collection;
18
+ }, []);
19
+ };
20
+
21
+ const createFullTextSearchFields = params => {
22
+ const {
23
+ term,
24
+ model,
25
+ fields
26
+ } = params;
27
+
28
+ if (!fields || fields.length === 0 || !term || term.length === 0) {
29
+ return [];
30
+ }
31
+
32
+ const fullTextSearchFields = [];
33
+ /**
34
+ * No point in going through fields if there is no search performed - no search term.
35
+ */
36
+
37
+ if (!!term) {
38
+ for (const fieldId of fields) {
39
+ const field = model.fields.find(f => f.fieldId === fieldId);
40
+
41
+ if (!field) {
42
+ continue;
43
+ }
44
+
45
+ fullTextSearchFields.push(field);
46
+ }
47
+ }
48
+
49
+ return fullTextSearchFields;
50
+ };
51
+
52
+ exports.createFullTextSearchFields = createFullTextSearchFields;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["extractFields","fields","reduce","collection","field","settings","push","createFullTextSearchFields","params","term","model","length","fullTextSearchFields","fieldId","find","f"],"sources":["fullTextSearchFields.ts"],"sourcesContent":["/* eslint-disable */\nimport { CmsModel, CmsModelField } from \"@webiny/api-headless-cms/types\";\n\nconst extractFields = (fields: CmsModelField[]): string[] => {\n return fields.reduce<string[]>((collection, field) => {\n if (field.settings?.fields) {\n collection.push(...extractFields(field.settings.fields));\n } else if (field) {\n }\n\n return collection;\n }, []);\n};\n\ninterface Params {\n model: CmsModel;\n term?: string;\n fields?: string[];\n}\nexport const createFullTextSearchFields = (params: Params): CmsModelField[] => {\n const { term, model, fields } = params;\n if (!fields || fields.length === 0 || !term || term.length === 0) {\n return [];\n }\n const fullTextSearchFields: CmsModelField[] = [];\n /**\n * No point in going through fields if there is no search performed - no search term.\n */\n if (!!term) {\n for (const fieldId of fields) {\n const field = model.fields.find(f => f.fieldId === fieldId);\n if (!field) {\n continue;\n }\n fullTextSearchFields.push(field);\n }\n }\n return fullTextSearchFields;\n};\n"],"mappings":";;;;;;;AAAA;AAGA,MAAMA,aAAa,GAAIC,MAAD,IAAuC;EACzD,OAAOA,MAAM,CAACC,MAAP,CAAwB,CAACC,UAAD,EAAaC,KAAb,KAAuB;IAAA;;IAClD,uBAAIA,KAAK,CAACC,QAAV,4CAAI,gBAAgBJ,MAApB,EAA4B;MACxBE,UAAU,CAACG,IAAX,CAAgB,GAAGN,aAAa,CAACI,KAAK,CAACC,QAAN,CAAeJ,MAAhB,CAAhC;IACH,CAFD,MAEO,IAAIG,KAAJ,EAAW,CACjB;;IAED,OAAOD,UAAP;EACH,CAPM,EAOJ,EAPI,CAAP;AAQH,CATD;;AAgBO,MAAMI,0BAA0B,GAAIC,MAAD,IAAqC;EAC3E,MAAM;IAAEC,IAAF;IAAQC,KAAR;IAAeT;EAAf,IAA0BO,MAAhC;;EACA,IAAI,CAACP,MAAD,IAAWA,MAAM,CAACU,MAAP,KAAkB,CAA7B,IAAkC,CAACF,IAAnC,IAA2CA,IAAI,CAACE,MAAL,KAAgB,CAA/D,EAAkE;IAC9D,OAAO,EAAP;EACH;;EACD,MAAMC,oBAAqC,GAAG,EAA9C;EACA;AACJ;AACA;;EACI,IAAI,CAAC,CAACH,IAAN,EAAY;IACR,KAAK,MAAMI,OAAX,IAAsBZ,MAAtB,EAA8B;MAC1B,MAAMG,KAAK,GAAGM,KAAK,CAACT,MAAN,CAAaa,IAAb,CAAkBC,CAAC,IAAIA,CAAC,CAACF,OAAF,KAAcA,OAArC,CAAd;;MACA,IAAI,CAACT,KAAL,EAAY;QACR;MACH;;MACDQ,oBAAoB,CAACN,IAArB,CAA0BF,KAA1B;IACH;EACJ;;EACD,OAAOQ,oBAAP;AACH,CAnBM"}
@@ -0,0 +1,17 @@
1
+ import { ElasticsearchBoolQueryConfig } from "@webiny/api-elasticsearch/types";
2
+ import { CmsEntryListWhere, CmsModel } from "@webiny/api-headless-cms/types";
3
+ export declare const createBaseQuery: () => ElasticsearchBoolQueryConfig;
4
+ interface Params {
5
+ model: CmsModel;
6
+ where: CmsEntryListWhere;
7
+ }
8
+ /**
9
+ * Latest and published are specific in Elasticsearch to that extend that they are tagged in the __type property.
10
+ * We allow either published or either latest.
11
+ * Latest is used in the manage API and published in the read API.
12
+ *
13
+ *
14
+ * We add the query.filter terms because we do not need scored search here and it is a bit faster.
15
+ */
16
+ export declare const createInitialQuery: (params: Params) => ElasticsearchBoolQueryConfig;
17
+ export {};
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.createInitialQuery = exports.createBaseQuery = void 0;
9
+
10
+ var _error = _interopRequireDefault(require("@webiny/error"));
11
+
12
+ var _recordType = require("../recordType");
13
+
14
+ const createBaseQuery = () => {
15
+ return {
16
+ must: [],
17
+ must_not: [],
18
+ should: [],
19
+ filter: []
20
+ };
21
+ };
22
+
23
+ exports.createBaseQuery = createBaseQuery;
24
+
25
+ /**
26
+ * Latest and published are specific in Elasticsearch to that extend that they are tagged in the __type property.
27
+ * We allow either published or either latest.
28
+ * Latest is used in the manage API and published in the read API.
29
+ *
30
+ *
31
+ * We add the query.filter terms because we do not need scored search here and it is a bit faster.
32
+ */
33
+ const createInitialQuery = params => {
34
+ const {
35
+ model,
36
+ where
37
+ } = params;
38
+ const query = createBaseQuery();
39
+ /**
40
+ * When ES index is shared between tenants, we need to filter records by tenant ID
41
+ *
42
+ * TODO determine if we want to search across tenants in shared index?
43
+ */
44
+
45
+ const sharedIndex = process.env.ELASTICSEARCH_SHARED_INDEXES === "true";
46
+
47
+ if (sharedIndex) {
48
+ /**
49
+ * Tenant for the filtering is taken from the model.
50
+ *
51
+ * TODO determine if we want to send it in the "where" parameter?
52
+ */
53
+ query.filter.push({
54
+ term: {
55
+ "tenant.keyword": model.tenant
56
+ }
57
+ });
58
+ /**
59
+ * Also, we must search only in selected model.
60
+ */
61
+
62
+ query.filter.push({
63
+ term: {
64
+ "modelId.keyword": model.modelId
65
+ }
66
+ });
67
+ /**
68
+ * TODO determine if we want to search across locales?
69
+ * This search would anyway work for a single model and when sharing index.
70
+ */
71
+
72
+ query.filter.push({
73
+ term: {
74
+ "locale.keyword": model.locale
75
+ }
76
+ });
77
+ }
78
+ /**
79
+ * We must transform published and latest where args into something that is understandable by our Elasticsearch
80
+ */
81
+
82
+
83
+ if (where.published === true) {
84
+ query.filter.push({
85
+ term: {
86
+ "__type.keyword": (0, _recordType.createPublishedRecordType)()
87
+ }
88
+ });
89
+ } else if (where.latest === true) {
90
+ query.filter.push({
91
+ term: {
92
+ "__type.keyword": (0, _recordType.createLatestRecordType)()
93
+ }
94
+ });
95
+ } //
96
+
97
+ /**
98
+ * We do not allow filtering without the published or latest parameter.
99
+ * Also, we do not want to set the default one, as there is a large possibility for user error when filtering.
100
+ */
101
+ else {
102
+ throw new _error.default(`Cannot call Elasticsearch query when not setting "published" or "latest".`, "ELASTICSEARCH_UNSUPPORTED_QUERY", {
103
+ where
104
+ });
105
+ }
106
+ /**
107
+ * We need to remove fields that actually do not exist on the record - it will break otherwise.
108
+ * This will modify the original object, which is what we want.
109
+ */
110
+
111
+
112
+ delete where.published;
113
+ delete where.latest;
114
+ return query;
115
+ };
116
+
117
+ exports.createInitialQuery = createInitialQuery;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createBaseQuery","must","must_not","should","filter","createInitialQuery","params","model","where","query","sharedIndex","process","env","ELASTICSEARCH_SHARED_INDEXES","push","term","tenant","modelId","locale","published","createPublishedRecordType","latest","createLatestRecordType","WebinyError"],"sources":["initialQuery.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { ElasticsearchBoolQueryConfig } from \"@webiny/api-elasticsearch/types\";\nimport { CmsEntryListWhere, CmsModel } from \"@webiny/api-headless-cms/types\";\nimport { createLatestRecordType, createPublishedRecordType } from \"../recordType\";\n\nexport const createBaseQuery = (): ElasticsearchBoolQueryConfig => {\n return {\n must: [],\n must_not: [],\n should: [],\n filter: []\n };\n};\n\ninterface Params {\n model: CmsModel;\n where: CmsEntryListWhere;\n}\n/**\n * Latest and published are specific in Elasticsearch to that extend that they are tagged in the __type property.\n * We allow either published or either latest.\n * Latest is used in the manage API and published in the read API.\n *\n *\n * We add the query.filter terms because we do not need scored search here and it is a bit faster.\n */\nexport const createInitialQuery = (params: Params): ElasticsearchBoolQueryConfig => {\n const { model, where } = params;\n\n const query = createBaseQuery();\n\n /**\n * When ES index is shared between tenants, we need to filter records by tenant ID\n *\n * TODO determine if we want to search across tenants in shared index?\n */\n const sharedIndex = process.env.ELASTICSEARCH_SHARED_INDEXES === \"true\";\n if (sharedIndex) {\n /**\n * Tenant for the filtering is taken from the model.\n *\n * TODO determine if we want to send it in the \"where\" parameter?\n */\n query.filter.push({\n term: {\n \"tenant.keyword\": model.tenant\n }\n });\n /**\n * Also, we must search only in selected model.\n */\n query.filter.push({\n term: {\n \"modelId.keyword\": model.modelId\n }\n });\n /**\n * TODO determine if we want to search across locales?\n * This search would anyway work for a single model and when sharing index.\n */\n query.filter.push({\n term: {\n \"locale.keyword\": model.locale\n }\n });\n }\n\n /**\n * We must transform published and latest where args into something that is understandable by our Elasticsearch\n */\n if (where.published === true) {\n query.filter.push({\n term: {\n \"__type.keyword\": createPublishedRecordType()\n }\n });\n } else if (where.latest === true) {\n query.filter.push({\n term: {\n \"__type.keyword\": createLatestRecordType()\n }\n });\n }\n //\n /**\n * We do not allow filtering without the published or latest parameter.\n * Also, we do not want to set the default one, as there is a large possibility for user error when filtering.\n */\n else {\n throw new WebinyError(\n `Cannot call Elasticsearch query when not setting \"published\" or \"latest\".`,\n \"ELASTICSEARCH_UNSUPPORTED_QUERY\",\n {\n where\n }\n );\n }\n /**\n * We need to remove fields that actually do not exist on the record - it will break otherwise.\n * This will modify the original object, which is what we want.\n */\n delete where.published;\n delete where.latest;\n\n return query;\n};\n"],"mappings":";;;;;;;;;AAAA;;AAGA;;AAEO,MAAMA,eAAe,GAAG,MAAoC;EAC/D,OAAO;IACHC,IAAI,EAAE,EADH;IAEHC,QAAQ,EAAE,EAFP;IAGHC,MAAM,EAAE,EAHL;IAIHC,MAAM,EAAE;EAJL,CAAP;AAMH,CAPM;;;;AAaP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,kBAAkB,GAAIC,MAAD,IAAkD;EAChF,MAAM;IAAEC,KAAF;IAASC;EAAT,IAAmBF,MAAzB;EAEA,MAAMG,KAAK,GAAGT,eAAe,EAA7B;EAEA;AACJ;AACA;AACA;AACA;;EACI,MAAMU,WAAW,GAAGC,OAAO,CAACC,GAAR,CAAYC,4BAAZ,KAA6C,MAAjE;;EACA,IAAIH,WAAJ,EAAiB;IACb;AACR;AACA;AACA;AACA;IACQD,KAAK,CAACL,MAAN,CAAaU,IAAb,CAAkB;MACdC,IAAI,EAAE;QACF,kBAAkBR,KAAK,CAACS;MADtB;IADQ,CAAlB;IAKA;AACR;AACA;;IACQP,KAAK,CAACL,MAAN,CAAaU,IAAb,CAAkB;MACdC,IAAI,EAAE;QACF,mBAAmBR,KAAK,CAACU;MADvB;IADQ,CAAlB;IAKA;AACR;AACA;AACA;;IACQR,KAAK,CAACL,MAAN,CAAaU,IAAb,CAAkB;MACdC,IAAI,EAAE;QACF,kBAAkBR,KAAK,CAACW;MADtB;IADQ,CAAlB;EAKH;EAED;AACJ;AACA;;;EACI,IAAIV,KAAK,CAACW,SAAN,KAAoB,IAAxB,EAA8B;IAC1BV,KAAK,CAACL,MAAN,CAAaU,IAAb,CAAkB;MACdC,IAAI,EAAE;QACF,kBAAkB,IAAAK,qCAAA;MADhB;IADQ,CAAlB;EAKH,CAND,MAMO,IAAIZ,KAAK,CAACa,MAAN,KAAiB,IAArB,EAA2B;IAC9BZ,KAAK,CAACL,MAAN,CAAaU,IAAb,CAAkB;MACdC,IAAI,EAAE;QACF,kBAAkB,IAAAO,kCAAA;MADhB;IADQ,CAAlB;EAKH,CANM,CAOP;;EACA;AACJ;AACA;AACA;EAXW,KAYF;IACD,MAAM,IAAIC,cAAJ,CACD,2EADC,EAEF,iCAFE,EAGF;MACIf;IADJ,CAHE,CAAN;EAOH;EACD;AACJ;AACA;AACA;;;EACI,OAAOA,KAAK,CAACW,SAAb;EACA,OAAOX,KAAK,CAACa,MAAb;EAEA,OAAOZ,KAAP;AACH,CA/EM"}
@@ -0,0 +1,2 @@
1
+ import { ModelField } from "./types";
2
+ export declare const hasKeyword: (field: ModelField) => boolean;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.hasKeyword = void 0;
7
+ const noKeywordFields = ["date", "datetime", "number", "boolean"];
8
+
9
+ const hasKeyword = field => {
10
+ /**
11
+ * We defined some field types that MUST have no keyword added to the field path
12
+ */
13
+ if (noKeywordFields.includes(field.type)) {
14
+ return false;
15
+ }
16
+ /**
17
+ * If field has unmapped type defined, do not add keyword.
18
+ */
19
+ //
20
+ else if (field.unmappedType) {
21
+ return false;
22
+ }
23
+ /**
24
+ * And if specifically defined that field has no keyword, do not add it.
25
+ */
26
+ //
27
+ else if (field.keyword === false) {
28
+ return false;
29
+ }
30
+ /**
31
+ * All other fields have keyword added.
32
+ */
33
+
34
+
35
+ return true;
36
+ };
37
+
38
+ exports.hasKeyword = hasKeyword;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["noKeywordFields","hasKeyword","field","includes","type","unmappedType","keyword"],"sources":["keyword.ts"],"sourcesContent":["import { ModelField } from \"./types\";\n\nconst noKeywordFields: string[] = [\"date\", \"datetime\", \"number\", \"boolean\"];\nexport const hasKeyword = (field: ModelField): boolean => {\n /**\n * We defined some field types that MUST have no keyword added to the field path\n */\n if (noKeywordFields.includes(field.type)) {\n return false;\n }\n /**\n * If field has unmapped type defined, do not add keyword.\n */\n //\n else if (field.unmappedType) {\n return false;\n }\n /**\n * And if specifically defined that field has no keyword, do not add it.\n */\n //\n else if (field.keyword === false) {\n return false;\n }\n /**\n * All other fields have keyword added.\n */\n return true;\n};\n"],"mappings":";;;;;;AAEA,MAAMA,eAAyB,GAAG,CAAC,MAAD,EAAS,UAAT,EAAqB,QAArB,EAA+B,SAA/B,CAAlC;;AACO,MAAMC,UAAU,GAAIC,KAAD,IAAgC;EACtD;AACJ;AACA;EACI,IAAIF,eAAe,CAACG,QAAhB,CAAyBD,KAAK,CAACE,IAA/B,CAAJ,EAA0C;IACtC,OAAO,KAAP;EACH;EACD;AACJ;AACA;EACI;EANA,KAOK,IAAIF,KAAK,CAACG,YAAV,EAAwB;IACzB,OAAO,KAAP;EACH;EACD;AACJ;AACA;EACI;EANK,KAOA,IAAIH,KAAK,CAACI,OAAN,KAAkB,KAAtB,EAA6B;IAC9B,OAAO,KAAP;EACH;EACD;AACJ;AACA;;;EACI,OAAO,IAAP;AACH,CAzBM"}
@@ -0,0 +1,9 @@
1
+ import { CmsEntryElasticsearchBodyModifierPlugin } from "../../../../plugins";
2
+ import { PluginsContainer } from "@webiny/plugins";
3
+ import { CmsModel } from "@webiny/api-headless-cms/types";
4
+ interface Params {
5
+ plugins: PluginsContainer;
6
+ model: CmsModel;
7
+ }
8
+ export declare const createBodyModifierPluginList: ({ plugins, model }: Params) => CmsEntryElasticsearchBodyModifierPlugin[];
9
+ export {};
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createBodyModifierPluginList = void 0;
7
+
8
+ var _plugins = require("../../../../plugins");
9
+
10
+ const createBodyModifierPluginList = ({
11
+ plugins,
12
+ model
13
+ }) => {
14
+ return plugins.byType(_plugins.CmsEntryElasticsearchBodyModifierPlugin.type).filter(pl => {
15
+ return !pl.modelId || pl.modelId === model.modelId;
16
+ });
17
+ };
18
+
19
+ exports.createBodyModifierPluginList = createBodyModifierPluginList;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createBodyModifierPluginList","plugins","model","byType","CmsEntryElasticsearchBodyModifierPlugin","type","filter","pl","modelId"],"sources":["bodyModifier.ts"],"sourcesContent":["import { CmsEntryElasticsearchBodyModifierPlugin } from \"~/plugins\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { CmsModel } from \"@webiny/api-headless-cms/types\";\n\ninterface Params {\n plugins: PluginsContainer;\n model: CmsModel;\n}\nexport const createBodyModifierPluginList = ({ plugins, model }: Params) => {\n return plugins\n .byType<CmsEntryElasticsearchBodyModifierPlugin>(\n CmsEntryElasticsearchBodyModifierPlugin.type\n )\n .filter(pl => {\n return !pl.modelId || pl.modelId === model.modelId;\n });\n};\n"],"mappings":";;;;;;;AAAA;;AAQO,MAAMA,4BAA4B,GAAG,CAAC;EAAEC,OAAF;EAAWC;AAAX,CAAD,KAAgC;EACxE,OAAOD,OAAO,CACTE,MADE,CAECC,gDAAA,CAAwCC,IAFzC,EAIFC,MAJE,CAIKC,EAAE,IAAI;IACV,OAAO,CAACA,EAAE,CAACC,OAAJ,IAAeD,EAAE,CAACC,OAAH,KAAeN,KAAK,CAACM,OAA3C;EACH,CANE,CAAP;AAOH,CARM"}
@@ -0,0 +1,8 @@
1
+ import { PluginsContainer } from "@webiny/plugins";
2
+ import { ElasticsearchQueryBuilderOperatorPlugins } from "../types";
3
+ interface Params {
4
+ plugins: PluginsContainer;
5
+ locale: string;
6
+ }
7
+ export declare const createOperatorPluginList: (params: Params) => ElasticsearchQueryBuilderOperatorPlugins;
8
+ export {};
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createOperatorPluginList = void 0;
7
+
8
+ var _apiElasticsearch = require("@webiny/api-elasticsearch");
9
+
10
+ const createOperatorPluginList = params => {
11
+ const {
12
+ plugins,
13
+ locale
14
+ } = params;
15
+ /**
16
+ * We always set the last one operator plugin added.
17
+ * This way user can override the plugins.
18
+ */
19
+
20
+ return plugins.byType(_apiElasticsearch.ElasticsearchQueryBuilderOperatorPlugin.type).reduce((acc, plugin) => {
21
+ const operator = plugin.getOperator();
22
+ /**
23
+ * We only allow the plugins which can pass the locale test.
24
+ * The default plugins always return true.
25
+ */
26
+
27
+ if (plugin.isLocaleSupported(locale) === false) {
28
+ return acc;
29
+ }
30
+ /**
31
+ * We also only allow the override of the plugins if the new plugin is NOT a default one.
32
+ * If a user sets the plugin name ending with .default, we cannot do anything about it.
33
+ */
34
+
35
+
36
+ if (!!acc[operator] && (plugin.name || "").match(/\.default$/)) {
37
+ return acc;
38
+ }
39
+
40
+ acc[operator] = plugin;
41
+ return acc;
42
+ }, {});
43
+ };
44
+
45
+ exports.createOperatorPluginList = createOperatorPluginList;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createOperatorPluginList","params","plugins","locale","byType","ElasticsearchQueryBuilderOperatorPlugin","type","reduce","acc","plugin","operator","getOperator","isLocaleSupported","name","match"],"sources":["operator.ts"],"sourcesContent":["import { PluginsContainer } from \"@webiny/plugins\";\nimport { ElasticsearchQueryBuilderOperatorPlugin } from \"@webiny/api-elasticsearch\";\nimport { ElasticsearchQueryBuilderOperatorPlugins } from \"../types\";\n\ninterface Params {\n plugins: PluginsContainer;\n locale: string;\n}\nexport const createOperatorPluginList = (\n params: Params\n): ElasticsearchQueryBuilderOperatorPlugins => {\n const { plugins, locale } = params;\n /**\n * We always set the last one operator plugin added.\n * This way user can override the plugins.\n */\n return plugins\n .byType<ElasticsearchQueryBuilderOperatorPlugin>(\n ElasticsearchQueryBuilderOperatorPlugin.type\n )\n .reduce<ElasticsearchQueryBuilderOperatorPlugins>((acc, plugin) => {\n const operator = plugin.getOperator();\n /**\n * We only allow the plugins which can pass the locale test.\n * The default plugins always return true.\n */\n if (plugin.isLocaleSupported(locale) === false) {\n return acc;\n }\n /**\n * We also only allow the override of the plugins if the new plugin is NOT a default one.\n * If a user sets the plugin name ending with .default, we cannot do anything about it.\n */\n if (!!acc[operator] && (plugin.name || \"\").match(/\\.default$/)) {\n return acc;\n }\n acc[operator] = plugin;\n return acc;\n }, {});\n};\n"],"mappings":";;;;;;;AACA;;AAOO,MAAMA,wBAAwB,GACjCC,MADoC,IAEO;EAC3C,MAAM;IAAEC,OAAF;IAAWC;EAAX,IAAsBF,MAA5B;EACA;AACJ;AACA;AACA;;EACI,OAAOC,OAAO,CACTE,MADE,CAECC,yDAAA,CAAwCC,IAFzC,EAIFC,MAJE,CAI+C,CAACC,GAAD,EAAMC,MAAN,KAAiB;IAC/D,MAAMC,QAAQ,GAAGD,MAAM,CAACE,WAAP,EAAjB;IACA;AACZ;AACA;AACA;;IACY,IAAIF,MAAM,CAACG,iBAAP,CAAyBT,MAAzB,MAAqC,KAAzC,EAAgD;MAC5C,OAAOK,GAAP;IACH;IACD;AACZ;AACA;AACA;;;IACY,IAAI,CAAC,CAACA,GAAG,CAACE,QAAD,CAAL,IAAmB,CAACD,MAAM,CAACI,IAAP,IAAe,EAAhB,EAAoBC,KAApB,CAA0B,YAA1B,CAAvB,EAAgE;MAC5D,OAAON,GAAP;IACH;;IACDA,GAAG,CAACE,QAAD,CAAH,GAAgBD,MAAhB;IACA,OAAOD,GAAP;EACH,CAtBE,EAsBA,EAtBA,CAAP;AAuBH,CA/BM"}
@@ -0,0 +1,9 @@
1
+ import { CmsEntryElasticsearchQueryModifierPlugin } from "../../../../plugins";
2
+ import { PluginsContainer } from "@webiny/plugins";
3
+ import { CmsModel } from "@webiny/api-headless-cms/types";
4
+ interface Params {
5
+ plugins: PluginsContainer;
6
+ model: CmsModel;
7
+ }
8
+ export declare const createQueryModifierPluginList: ({ plugins, model }: Params) => CmsEntryElasticsearchQueryModifierPlugin[];
9
+ export {};
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createQueryModifierPluginList = void 0;
7
+
8
+ var _plugins = require("../../../../plugins");
9
+
10
+ const createQueryModifierPluginList = ({
11
+ plugins,
12
+ model
13
+ }) => {
14
+ return plugins.byType(_plugins.CmsEntryElasticsearchQueryModifierPlugin.type).filter(pl => {
15
+ return !pl.modelId || pl.modelId === model.modelId;
16
+ });
17
+ };
18
+
19
+ exports.createQueryModifierPluginList = createQueryModifierPluginList;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createQueryModifierPluginList","plugins","model","byType","CmsEntryElasticsearchQueryModifierPlugin","type","filter","pl","modelId"],"sources":["queryModifier.ts"],"sourcesContent":["import { CmsEntryElasticsearchQueryModifierPlugin } from \"~/plugins\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { CmsModel } from \"@webiny/api-headless-cms/types\";\n\ninterface Params {\n plugins: PluginsContainer;\n model: CmsModel;\n}\nexport const createQueryModifierPluginList = ({ plugins, model }: Params) => {\n return plugins\n .byType<CmsEntryElasticsearchQueryModifierPlugin>(\n CmsEntryElasticsearchQueryModifierPlugin.type\n )\n .filter(pl => {\n return !pl.modelId || pl.modelId === model.modelId;\n });\n};\n"],"mappings":";;;;;;;AAAA;;AAQO,MAAMA,6BAA6B,GAAG,CAAC;EAAEC,OAAF;EAAWC;AAAX,CAAD,KAAgC;EACzE,OAAOD,OAAO,CACTE,MADE,CAECC,iDAAA,CAAyCC,IAF1C,EAIFC,MAJE,CAIKC,EAAE,IAAI;IACV,OAAO,CAACA,EAAE,CAACC,OAAJ,IAAeD,EAAE,CAACC,OAAH,KAAeN,KAAK,CAACM,OAA3C;EACH,CANE,CAAP;AAOH,CARM"}
@@ -0,0 +1,7 @@
1
+ import { PluginsContainer } from "@webiny/plugins";
2
+ import { ElasticsearchQuerySearchValuePlugins } from "../types";
3
+ interface Params {
4
+ plugins: PluginsContainer;
5
+ }
6
+ export declare const createSearchPluginList: ({ plugins }: Params) => ElasticsearchQuerySearchValuePlugins;
7
+ export {};
@@ -1,16 +1,20 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.searchPluginsList = void 0;
8
+ exports.createSearchPluginList = void 0;
9
9
 
10
10
  var _error = _interopRequireDefault(require("@webiny/error"));
11
11
 
12
- const searchPluginsList = plugins => {
13
- return plugins.byType("cms-elastic-search-query-builder-value-search").reduce((plugins, plugin) => {
12
+ var _plugins = require("../../../../plugins");
13
+
14
+ const createSearchPluginList = ({
15
+ plugins
16
+ }) => {
17
+ return plugins.byType(_plugins.CmsEntryElasticsearchQueryBuilderValueSearchPlugin.type).reduce((plugins, plugin) => {
14
18
  if (plugins[plugin.fieldType]) {
15
19
  throw new _error.default("There is a ElasticsearchQueryBuilderValueSearchPlugin defined for the field type.", "PLUGIN_ALREADY_EXISTS", {
16
20
  fieldType: plugin.fieldType,
@@ -23,4 +27,4 @@ const searchPluginsList = plugins => {
23
27
  }, {});
24
28
  };
25
29
 
26
- exports.searchPluginsList = searchPluginsList;
30
+ exports.createSearchPluginList = createSearchPluginList;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createSearchPluginList","plugins","byType","CmsEntryElasticsearchQueryBuilderValueSearchPlugin","type","reduce","plugin","fieldType","WebinyError","name"],"sources":["search.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsEntryElasticsearchQueryBuilderValueSearchPlugin } from \"~/plugins\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { ElasticsearchQuerySearchValuePlugins } from \"../types\";\n\ninterface Params {\n plugins: PluginsContainer;\n}\nexport const createSearchPluginList = ({\n plugins\n}: Params): ElasticsearchQuerySearchValuePlugins => {\n return plugins\n .byType<CmsEntryElasticsearchQueryBuilderValueSearchPlugin>(\n CmsEntryElasticsearchQueryBuilderValueSearchPlugin.type\n )\n .reduce<ElasticsearchQuerySearchValuePlugins>((plugins, plugin) => {\n if (plugins[plugin.fieldType]) {\n throw new WebinyError(\n \"There is a ElasticsearchQueryBuilderValueSearchPlugin defined for the field type.\",\n \"PLUGIN_ALREADY_EXISTS\",\n {\n fieldType: plugin.fieldType,\n name: plugin.name || \"unknown\"\n }\n );\n }\n plugins[plugin.fieldType] = plugin;\n\n return plugins;\n }, {});\n};\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AAOO,MAAMA,sBAAsB,GAAG,CAAC;EACnCC;AADmC,CAAD,KAEc;EAChD,OAAOA,OAAO,CACTC,MADE,CAECC,2DAAA,CAAmDC,IAFpD,EAIFC,MAJE,CAI2C,CAACJ,OAAD,EAAUK,MAAV,KAAqB;IAC/D,IAAIL,OAAO,CAACK,MAAM,CAACC,SAAR,CAAX,EAA+B;MAC3B,MAAM,IAAIC,cAAJ,CACF,mFADE,EAEF,uBAFE,EAGF;QACID,SAAS,EAAED,MAAM,CAACC,SADtB;QAEIE,IAAI,EAAEH,MAAM,CAACG,IAAP,IAAe;MAFzB,CAHE,CAAN;IAQH;;IACDR,OAAO,CAACK,MAAM,CAACC,SAAR,CAAP,GAA4BD,MAA5B;IAEA,OAAOL,OAAP;EACH,CAlBE,EAkBA,EAlBA,CAAP;AAmBH,CAtBM"}
@@ -0,0 +1,9 @@
1
+ import { CmsEntryElasticsearchSortModifierPlugin } from "../../../../plugins";
2
+ import { PluginsContainer } from "@webiny/plugins";
3
+ import { CmsModel } from "@webiny/api-headless-cms/types";
4
+ interface Params {
5
+ plugins: PluginsContainer;
6
+ model: CmsModel;
7
+ }
8
+ export declare const createSortModifierPluginList: ({ plugins, model }: Params) => CmsEntryElasticsearchSortModifierPlugin[];
9
+ export {};
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createSortModifierPluginList = void 0;
7
+
8
+ var _plugins = require("../../../../plugins");
9
+
10
+ const createSortModifierPluginList = ({
11
+ plugins,
12
+ model
13
+ }) => {
14
+ return plugins.byType(_plugins.CmsEntryElasticsearchSortModifierPlugin.type).filter(pl => {
15
+ return !pl.modelId || pl.modelId === model.modelId;
16
+ });
17
+ };
18
+
19
+ exports.createSortModifierPluginList = createSortModifierPluginList;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createSortModifierPluginList","plugins","model","byType","CmsEntryElasticsearchSortModifierPlugin","type","filter","pl","modelId"],"sources":["sortModifier.ts"],"sourcesContent":["import { CmsEntryElasticsearchSortModifierPlugin } from \"~/plugins\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { CmsModel } from \"@webiny/api-headless-cms/types\";\n\ninterface Params {\n plugins: PluginsContainer;\n model: CmsModel;\n}\nexport const createSortModifierPluginList = ({ plugins, model }: Params) => {\n return plugins\n .byType<CmsEntryElasticsearchSortModifierPlugin>(\n CmsEntryElasticsearchSortModifierPlugin.type\n )\n .filter(pl => {\n return !pl.modelId || pl.modelId === model.modelId;\n });\n};\n"],"mappings":";;;;;;;AAAA;;AAQO,MAAMA,4BAA4B,GAAG,CAAC;EAAEC,OAAF;EAAWC;AAAX,CAAD,KAAgC;EACxE,OAAOD,OAAO,CACTE,MADE,CAECC,gDAAA,CAAwCC,IAFzC,EAIFC,MAJE,CAIKC,EAAE,IAAI;IACV,OAAO,CAACA,EAAE,CAACC,OAAJ,IAAeD,EAAE,CAACC,OAAH,KAAeN,KAAK,CAACM,OAA3C;EACH,CANE,CAAP;AAOH,CARM"}
@@ -0,0 +1,12 @@
1
+ import { Sort as esSort } from "@webiny/api-elasticsearch/types";
2
+ import { PluginsContainer } from "@webiny/plugins";
3
+ import { CmsEntryListSort, CmsModel } from "@webiny/api-headless-cms/types";
4
+ import { ModelFields } from "./types";
5
+ interface Params {
6
+ plugins: PluginsContainer;
7
+ sort?: CmsEntryListSort;
8
+ modelFields: ModelFields;
9
+ model: CmsModel;
10
+ }
11
+ export declare const createElasticsearchSort: (params: Params) => esSort;
12
+ export {};