@webiny/api-headless-cms-ddb-es 0.0.0-ee-vpcs.549378cf03

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 (228) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +35 -0
  3. package/configurations.d.ts +12 -0
  4. package/configurations.js +43 -0
  5. package/configurations.js.map +1 -0
  6. package/definitions/entry.d.ts +8 -0
  7. package/definitions/entry.js +90 -0
  8. package/definitions/entry.js.map +1 -0
  9. package/definitions/entryElasticsearch.d.ts +8 -0
  10. package/definitions/entryElasticsearch.js +42 -0
  11. package/definitions/entryElasticsearch.js.map +1 -0
  12. package/definitions/group.d.ts +8 -0
  13. package/definitions/group.js +70 -0
  14. package/definitions/group.js.map +1 -0
  15. package/definitions/model.d.ts +8 -0
  16. package/definitions/model.js +97 -0
  17. package/definitions/model.js.map +1 -0
  18. package/definitions/settings.d.ts +8 -0
  19. package/definitions/settings.js +58 -0
  20. package/definitions/settings.js.map +1 -0
  21. package/definitions/system.d.ts +8 -0
  22. package/definitions/system.js +46 -0
  23. package/definitions/system.js.map +1 -0
  24. package/definitions/table.d.ts +8 -0
  25. package/definitions/table.js +24 -0
  26. package/definitions/table.js.map +1 -0
  27. package/definitions/tableElasticsearch.d.ts +8 -0
  28. package/definitions/tableElasticsearch.js +24 -0
  29. package/definitions/tableElasticsearch.js.map +1 -0
  30. package/dynamoDb/index.d.ts +2 -0
  31. package/dynamoDb/index.js +16 -0
  32. package/dynamoDb/index.js.map +1 -0
  33. package/dynamoDb/storage/date.d.ts +3 -0
  34. package/dynamoDb/storage/date.js +99 -0
  35. package/dynamoDb/storage/date.js.map +1 -0
  36. package/dynamoDb/storage/longText.d.ts +10 -0
  37. package/dynamoDb/storage/longText.js +108 -0
  38. package/dynamoDb/storage/longText.js.map +1 -0
  39. package/dynamoDb/storage/richText.d.ts +7 -0
  40. package/dynamoDb/storage/richText.js +128 -0
  41. package/dynamoDb/storage/richText.js.map +1 -0
  42. package/elasticsearch/createElasticsearchIndex.d.ts +9 -0
  43. package/elasticsearch/createElasticsearchIndex.js +60 -0
  44. package/elasticsearch/createElasticsearchIndex.js.map +1 -0
  45. package/elasticsearch/deleteElasticsearchIndex.d.ts +8 -0
  46. package/elasticsearch/deleteElasticsearchIndex.js +43 -0
  47. package/elasticsearch/deleteElasticsearchIndex.js.map +1 -0
  48. package/elasticsearch/index.d.ts +2 -0
  49. package/elasticsearch/index.js +16 -0
  50. package/elasticsearch/index.js.map +1 -0
  51. package/elasticsearch/indexing/dateTimeIndexing.d.ts +3 -0
  52. package/elasticsearch/indexing/dateTimeIndexing.js +103 -0
  53. package/elasticsearch/indexing/dateTimeIndexing.js.map +1 -0
  54. package/elasticsearch/indexing/defaultFieldIndexing.d.ts +3 -0
  55. package/elasticsearch/indexing/defaultFieldIndexing.js +47 -0
  56. package/elasticsearch/indexing/defaultFieldIndexing.js.map +1 -0
  57. package/elasticsearch/indexing/index.d.ts +2 -0
  58. package/elasticsearch/indexing/index.js +24 -0
  59. package/elasticsearch/indexing/index.js.map +1 -0
  60. package/elasticsearch/indexing/longTextIndexing.d.ts +7 -0
  61. package/elasticsearch/indexing/longTextIndexing.js +52 -0
  62. package/elasticsearch/indexing/longTextIndexing.js.map +1 -0
  63. package/elasticsearch/indexing/numberIndexing.d.ts +3 -0
  64. package/elasticsearch/indexing/numberIndexing.js +48 -0
  65. package/elasticsearch/indexing/numberIndexing.js.map +1 -0
  66. package/elasticsearch/indexing/objectIndexing.d.ts +12 -0
  67. package/elasticsearch/indexing/objectIndexing.js +223 -0
  68. package/elasticsearch/indexing/objectIndexing.js.map +1 -0
  69. package/elasticsearch/indexing/richTextIndexing.d.ts +3 -0
  70. package/elasticsearch/indexing/richTextIndexing.js +34 -0
  71. package/elasticsearch/indexing/richTextIndexing.js.map +1 -0
  72. package/elasticsearch/indices/base.d.ts +2 -0
  73. package/elasticsearch/indices/base.js +15 -0
  74. package/elasticsearch/indices/base.js.map +1 -0
  75. package/elasticsearch/indices/index.d.ts +1 -0
  76. package/elasticsearch/indices/index.js +16 -0
  77. package/elasticsearch/indices/index.js.map +1 -0
  78. package/elasticsearch/indices/japanese.d.ts +2 -0
  79. package/elasticsearch/indices/japanese.js +16 -0
  80. package/elasticsearch/indices/japanese.js.map +1 -0
  81. package/elasticsearch/search/index.d.ts +3 -0
  82. package/elasticsearch/search/index.js +14 -0
  83. package/elasticsearch/search/index.js.map +1 -0
  84. package/elasticsearch/search/refSearch.d.ts +2 -0
  85. package/elasticsearch/search/refSearch.js +35 -0
  86. package/elasticsearch/search/refSearch.js.map +1 -0
  87. package/elasticsearch/search/timeSearch.d.ts +2 -0
  88. package/elasticsearch/search/timeSearch.js +33 -0
  89. package/elasticsearch/search/timeSearch.js.map +1 -0
  90. package/helpers/entryIndexHelpers.d.ts +18 -0
  91. package/helpers/entryIndexHelpers.js +204 -0
  92. package/helpers/entryIndexHelpers.js.map +1 -0
  93. package/helpers/index.d.ts +1 -0
  94. package/helpers/index.js +18 -0
  95. package/helpers/index.js.map +1 -0
  96. package/index.d.ts +3 -0
  97. package/index.js +275 -0
  98. package/index.js.map +1 -0
  99. package/operations/entry/dataLoaders.d.ts +51 -0
  100. package/operations/entry/dataLoaders.js +365 -0
  101. package/operations/entry/dataLoaders.js.map +1 -0
  102. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.d.ts +18 -0
  103. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js +34 -0
  104. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js.map +1 -0
  105. package/operations/entry/elasticsearch/body.d.ts +13 -0
  106. package/operations/entry/elasticsearch/body.js +162 -0
  107. package/operations/entry/elasticsearch/body.js.map +1 -0
  108. package/operations/entry/elasticsearch/fields.d.ts +9 -0
  109. package/operations/entry/elasticsearch/fields.js +248 -0
  110. package/operations/entry/elasticsearch/fields.js.map +1 -0
  111. package/operations/entry/elasticsearch/filtering/applyFiltering.d.ts +8 -0
  112. package/operations/entry/elasticsearch/filtering/applyFiltering.js +66 -0
  113. package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +1 -0
  114. package/operations/entry/elasticsearch/filtering/exec.d.ts +17 -0
  115. package/operations/entry/elasticsearch/filtering/exec.js +215 -0
  116. package/operations/entry/elasticsearch/filtering/exec.js.map +1 -0
  117. package/operations/entry/elasticsearch/filtering/index.d.ts +1 -0
  118. package/operations/entry/elasticsearch/filtering/index.js +18 -0
  119. package/operations/entry/elasticsearch/filtering/index.js.map +1 -0
  120. package/operations/entry/elasticsearch/filtering/path.d.ts +15 -0
  121. package/operations/entry/elasticsearch/filtering/path.js +52 -0
  122. package/operations/entry/elasticsearch/filtering/path.js.map +1 -0
  123. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.d.ts +2 -0
  124. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js +35 -0
  125. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js.map +1 -0
  126. package/operations/entry/elasticsearch/filtering/plugins/index.d.ts +1 -0
  127. package/operations/entry/elasticsearch/filtering/plugins/index.js +18 -0
  128. package/operations/entry/elasticsearch/filtering/plugins/index.js.map +1 -0
  129. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.d.ts +2 -0
  130. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js +78 -0
  131. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js.map +1 -0
  132. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.d.ts +2 -0
  133. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js +58 -0
  134. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js.map +1 -0
  135. package/operations/entry/elasticsearch/filtering/populated.d.ts +2 -0
  136. package/operations/entry/elasticsearch/filtering/populated.js +30 -0
  137. package/operations/entry/elasticsearch/filtering/populated.js.map +1 -0
  138. package/operations/entry/elasticsearch/filtering/values.d.ts +2 -0
  139. package/operations/entry/elasticsearch/filtering/values.js +28 -0
  140. package/operations/entry/elasticsearch/filtering/values.js.map +1 -0
  141. package/operations/entry/elasticsearch/fullTextSearch.d.ts +9 -0
  142. package/operations/entry/elasticsearch/fullTextSearch.js +34 -0
  143. package/operations/entry/elasticsearch/fullTextSearch.js.map +1 -0
  144. package/operations/entry/elasticsearch/fullTextSearchFields.d.ts +8 -0
  145. package/operations/entry/elasticsearch/fullTextSearchFields.js +52 -0
  146. package/operations/entry/elasticsearch/fullTextSearchFields.js.map +1 -0
  147. package/operations/entry/elasticsearch/initialQuery.d.ts +17 -0
  148. package/operations/entry/elasticsearch/initialQuery.js +117 -0
  149. package/operations/entry/elasticsearch/initialQuery.js.map +1 -0
  150. package/operations/entry/elasticsearch/keyword.d.ts +2 -0
  151. package/operations/entry/elasticsearch/keyword.js +38 -0
  152. package/operations/entry/elasticsearch/keyword.js.map +1 -0
  153. package/operations/entry/elasticsearch/plugins/bodyModifier.d.ts +9 -0
  154. package/operations/entry/elasticsearch/plugins/bodyModifier.js +19 -0
  155. package/operations/entry/elasticsearch/plugins/bodyModifier.js.map +1 -0
  156. package/operations/entry/elasticsearch/plugins/operator.d.ts +8 -0
  157. package/operations/entry/elasticsearch/plugins/operator.js +45 -0
  158. package/operations/entry/elasticsearch/plugins/operator.js.map +1 -0
  159. package/operations/entry/elasticsearch/plugins/queryModifier.d.ts +9 -0
  160. package/operations/entry/elasticsearch/plugins/queryModifier.js +19 -0
  161. package/operations/entry/elasticsearch/plugins/queryModifier.js.map +1 -0
  162. package/operations/entry/elasticsearch/plugins/search.d.ts +7 -0
  163. package/operations/entry/elasticsearch/plugins/search.js +30 -0
  164. package/operations/entry/elasticsearch/plugins/search.js.map +1 -0
  165. package/operations/entry/elasticsearch/plugins/sortModifier.d.ts +9 -0
  166. package/operations/entry/elasticsearch/plugins/sortModifier.js +19 -0
  167. package/operations/entry/elasticsearch/plugins/sortModifier.js.map +1 -0
  168. package/operations/entry/elasticsearch/sort.d.ts +12 -0
  169. package/operations/entry/elasticsearch/sort.js +92 -0
  170. package/operations/entry/elasticsearch/sort.js.map +1 -0
  171. package/operations/entry/elasticsearch/transformValueForSearch.d.ts +16 -0
  172. package/operations/entry/elasticsearch/transformValueForSearch.js +34 -0
  173. package/operations/entry/elasticsearch/transformValueForSearch.js.map +1 -0
  174. package/operations/entry/elasticsearch/types.d.ts +41 -0
  175. package/operations/entry/elasticsearch/types.js +5 -0
  176. package/operations/entry/elasticsearch/types.js.map +1 -0
  177. package/operations/entry/elasticsearchFields.d.ts +2 -0
  178. package/operations/entry/elasticsearchFields.js +38 -0
  179. package/operations/entry/elasticsearchFields.js.map +1 -0
  180. package/operations/entry/index.d.ts +11 -0
  181. package/operations/entry/index.js +1251 -0
  182. package/operations/entry/index.js.map +1 -0
  183. package/operations/entry/keys.d.ts +12 -0
  184. package/operations/entry/keys.js +40 -0
  185. package/operations/entry/keys.js.map +1 -0
  186. package/operations/entry/recordType.d.ts +3 -0
  187. package/operations/entry/recordType.js +24 -0
  188. package/operations/entry/recordType.js.map +1 -0
  189. package/operations/group/index.d.ts +8 -0
  190. package/operations/group/index.js +195 -0
  191. package/operations/group/index.js.map +1 -0
  192. package/operations/model/index.d.ts +8 -0
  193. package/operations/model/index.js +204 -0
  194. package/operations/model/index.js.map +1 -0
  195. package/operations/settings/index.d.ts +6 -0
  196. package/operations/settings/index.js +135 -0
  197. package/operations/settings/index.js.map +1 -0
  198. package/operations/system/index.d.ts +6 -0
  199. package/operations/system/index.js +99 -0
  200. package/operations/system/index.js.map +1 -0
  201. package/package.json +68 -0
  202. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.d.ts +20 -0
  203. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js +24 -0
  204. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js.map +1 -0
  205. package/plugins/CmsEntryElasticsearchFieldPlugin.d.ts +12 -0
  206. package/plugins/CmsEntryElasticsearchFieldPlugin.js +24 -0
  207. package/plugins/CmsEntryElasticsearchFieldPlugin.js.map +1 -0
  208. package/plugins/CmsEntryElasticsearchIndexPlugin.d.ts +4 -0
  209. package/plugins/CmsEntryElasticsearchIndexPlugin.js +17 -0
  210. package/plugins/CmsEntryElasticsearchIndexPlugin.js.map +1 -0
  211. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.d.ts +30 -0
  212. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js +43 -0
  213. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js.map +1 -0
  214. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.d.ts +17 -0
  215. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js +24 -0
  216. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js.map +1 -0
  217. package/plugins/CmsEntryElasticsearchSortModifierPlugin.d.ts +17 -0
  218. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js +24 -0
  219. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js.map +1 -0
  220. package/plugins/CmsEntryFilterPlugin.d.ts +49 -0
  221. package/plugins/CmsEntryFilterPlugin.js +31 -0
  222. package/plugins/CmsEntryFilterPlugin.js.map +1 -0
  223. package/plugins/index.d.ts +6 -0
  224. package/plugins/index.js +83 -0
  225. package/plugins/index.js.map +1 -0
  226. package/types.d.ts +164 -0
  227. package/types.js +47 -0
  228. package/types.js.map +1 -0
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createFieldPathFactory = void 0;
7
+
8
+ const createFieldPathFactory = ({
9
+ plugins
10
+ }) => {
11
+ return params => {
12
+ const {
13
+ field,
14
+ key,
15
+ value,
16
+ keyword
17
+ } = params;
18
+ const plugin = plugins[field.type];
19
+ let fieldPath = null;
20
+
21
+ if (plugin) {
22
+ fieldPath = plugin.createPath({
23
+ field: field.field,
24
+ value,
25
+ key
26
+ });
27
+ }
28
+
29
+ if (!fieldPath) {
30
+ fieldPath = field.field.storageId;
31
+
32
+ if (field.path) {
33
+ fieldPath = typeof field.path === "function" ? field.path(value) : field.path;
34
+ }
35
+ }
36
+
37
+ const result = [];
38
+
39
+ if (!field.isSystemField) {
40
+ result.push("values");
41
+ }
42
+
43
+ result.push(...field.parents.map(p => p.storageId));
44
+ result.push(fieldPath);
45
+ return {
46
+ basePath: result.join("."),
47
+ path: result.concat(keyword ? ["keyword"] : []).join(".")
48
+ };
49
+ };
50
+ };
51
+
52
+ exports.createFieldPathFactory = createFieldPathFactory;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createFieldPathFactory","plugins","params","field","key","value","keyword","plugin","type","fieldPath","createPath","storageId","path","result","isSystemField","push","parents","map","p","basePath","join","concat"],"sources":["path.ts"],"sourcesContent":["import {\n ElasticsearchQuerySearchValuePlugins,\n ModelField\n} from \"~/operations/entry/elasticsearch/types\";\n\ninterface FieldPathFactoryParams {\n plugins: ElasticsearchQuerySearchValuePlugins;\n}\ninterface FieldPathParams {\n field: ModelField;\n key: string;\n value: any;\n keyword: boolean;\n}\n\nexport const createFieldPathFactory = ({ plugins }: FieldPathFactoryParams) => {\n return (params: FieldPathParams) => {\n const { field, key, value, keyword } = params;\n const plugin = plugins[field.type];\n\n let fieldPath: string | null = null;\n if (plugin) {\n fieldPath = plugin.createPath({ field: field.field, value, key });\n }\n if (!fieldPath) {\n fieldPath = field.field.storageId;\n if (field.path) {\n fieldPath = typeof field.path === \"function\" ? field.path(value) : field.path;\n }\n }\n\n const result: string[] = [];\n if (!field.isSystemField) {\n result.push(\"values\");\n }\n result.push(...field.parents.map(p => p.storageId));\n result.push(fieldPath);\n\n return {\n basePath: result.join(\".\"),\n path: result.concat(keyword ? [\"keyword\"] : []).join(\".\")\n };\n };\n};\n"],"mappings":";;;;;;;AAeO,MAAMA,sBAAsB,GAAG,CAAC;EAAEC;AAAF,CAAD,KAAyC;EAC3E,OAAQC,MAAD,IAA6B;IAChC,MAAM;MAAEC,KAAF;MAASC,GAAT;MAAcC,KAAd;MAAqBC;IAArB,IAAiCJ,MAAvC;IACA,MAAMK,MAAM,GAAGN,OAAO,CAACE,KAAK,CAACK,IAAP,CAAtB;IAEA,IAAIC,SAAwB,GAAG,IAA/B;;IACA,IAAIF,MAAJ,EAAY;MACRE,SAAS,GAAGF,MAAM,CAACG,UAAP,CAAkB;QAAEP,KAAK,EAAEA,KAAK,CAACA,KAAf;QAAsBE,KAAtB;QAA6BD;MAA7B,CAAlB,CAAZ;IACH;;IACD,IAAI,CAACK,SAAL,EAAgB;MACZA,SAAS,GAAGN,KAAK,CAACA,KAAN,CAAYQ,SAAxB;;MACA,IAAIR,KAAK,CAACS,IAAV,EAAgB;QACZH,SAAS,GAAG,OAAON,KAAK,CAACS,IAAb,KAAsB,UAAtB,GAAmCT,KAAK,CAACS,IAAN,CAAWP,KAAX,CAAnC,GAAuDF,KAAK,CAACS,IAAzE;MACH;IACJ;;IAED,MAAMC,MAAgB,GAAG,EAAzB;;IACA,IAAI,CAACV,KAAK,CAACW,aAAX,EAA0B;MACtBD,MAAM,CAACE,IAAP,CAAY,QAAZ;IACH;;IACDF,MAAM,CAACE,IAAP,CAAY,GAAGZ,KAAK,CAACa,OAAN,CAAcC,GAAd,CAAkBC,CAAC,IAAIA,CAAC,CAACP,SAAzB,CAAf;IACAE,MAAM,CAACE,IAAP,CAAYN,SAAZ;IAEA,OAAO;MACHU,QAAQ,EAAEN,MAAM,CAACO,IAAP,CAAY,GAAZ,CADP;MAEHR,IAAI,EAAEC,MAAM,CAACQ,MAAP,CAAcf,OAAO,GAAG,CAAC,SAAD,CAAH,GAAiB,EAAtC,EAA0Cc,IAA1C,CAA+C,GAA/C;IAFH,CAAP;EAIH,CA1BD;AA2BH,CA5BM"}
@@ -0,0 +1,2 @@
1
+ import { CmsEntryFilterPlugin } from "../../../../../plugins/CmsEntryFilterPlugin";
2
+ export declare const createDefaultFilterPlugin: () => CmsEntryFilterPlugin;
@@ -0,0 +1,35 @@
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.createDefaultFilterPlugin = void 0;
9
+
10
+ var _error = _interopRequireDefault(require("@webiny/error"));
11
+
12
+ var _CmsEntryFilterPlugin = require("../../../../../plugins/CmsEntryFilterPlugin");
13
+
14
+ const createDefaultFilterPlugin = () => {
15
+ const plugin = new _CmsEntryFilterPlugin.CmsEntryFilterPlugin({
16
+ fieldType: _CmsEntryFilterPlugin.CmsEntryFilterPlugin.ALL,
17
+ exec: params => {
18
+ const {
19
+ applyFiltering,
20
+ field
21
+ } = params;
22
+
23
+ if (!params.field.isSearchable) {
24
+ const identifier = [...field.parents.map(p => p.fieldId), field.field.fieldId].join(".");
25
+ throw new _error.default(`Field "${identifier}" is not searchable.`);
26
+ }
27
+
28
+ applyFiltering(params);
29
+ }
30
+ });
31
+ plugin.name = `${plugin.type}.default.all`;
32
+ return plugin;
33
+ };
34
+
35
+ exports.createDefaultFilterPlugin = createDefaultFilterPlugin;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createDefaultFilterPlugin","plugin","CmsEntryFilterPlugin","fieldType","ALL","exec","params","applyFiltering","field","isSearchable","identifier","parents","map","p","fieldId","join","WebinyError","name","type"],"sources":["defaultFilterPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsEntryFilterPlugin } from \"~/plugins/CmsEntryFilterPlugin\";\n\nexport const createDefaultFilterPlugin = () => {\n const plugin = new CmsEntryFilterPlugin({\n fieldType: CmsEntryFilterPlugin.ALL,\n exec: params => {\n const { applyFiltering, field } = params;\n if (!params.field.isSearchable) {\n const identifier = [...field.parents.map(p => p.fieldId), field.field.fieldId].join(\n \".\"\n );\n throw new WebinyError(`Field \"${identifier}\" is not searchable.`);\n }\n applyFiltering(params);\n }\n });\n\n plugin.name = `${plugin.type}.default.all`;\n\n return plugin;\n};\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AAEO,MAAMA,yBAAyB,GAAG,MAAM;EAC3C,MAAMC,MAAM,GAAG,IAAIC,0CAAJ,CAAyB;IACpCC,SAAS,EAAED,0CAAA,CAAqBE,GADI;IAEpCC,IAAI,EAAEC,MAAM,IAAI;MACZ,MAAM;QAAEC,cAAF;QAAkBC;MAAlB,IAA4BF,MAAlC;;MACA,IAAI,CAACA,MAAM,CAACE,KAAP,CAAaC,YAAlB,EAAgC;QAC5B,MAAMC,UAAU,GAAG,CAAC,GAAGF,KAAK,CAACG,OAAN,CAAcC,GAAd,CAAkBC,CAAC,IAAIA,CAAC,CAACC,OAAzB,CAAJ,EAAuCN,KAAK,CAACA,KAAN,CAAYM,OAAnD,EAA4DC,IAA5D,CACf,GADe,CAAnB;QAGA,MAAM,IAAIC,cAAJ,CAAiB,UAASN,UAAW,sBAArC,CAAN;MACH;;MACDH,cAAc,CAACD,MAAD,CAAd;IACH;EAXmC,CAAzB,CAAf;EAcAL,MAAM,CAACgB,IAAP,GAAe,GAAEhB,MAAM,CAACiB,IAAK,cAA7B;EAEA,OAAOjB,MAAP;AACH,CAlBM"}
@@ -0,0 +1 @@
1
+ export declare const createFilterPlugins: () => import("../../../../../plugins/CmsEntryFilterPlugin").CmsEntryFilterPlugin[];
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createFilterPlugins = void 0;
7
+
8
+ var _defaultFilterPlugin = require("./defaultFilterPlugin");
9
+
10
+ var _objectFilterPlugin = require("./objectFilterPlugin");
11
+
12
+ var _refFilterPlugin = require("./refFilterPlugin");
13
+
14
+ const createFilterPlugins = () => {
15
+ return [(0, _defaultFilterPlugin.createDefaultFilterPlugin)(), (0, _objectFilterPlugin.createObjectFilterPlugin)(), (0, _refFilterPlugin.createRefFilterPlugin)()];
16
+ };
17
+
18
+ exports.createFilterPlugins = createFilterPlugins;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createFilterPlugins","createDefaultFilterPlugin","createObjectFilterPlugin","createRefFilterPlugin"],"sources":["index.ts"],"sourcesContent":["import { createDefaultFilterPlugin } from \"./defaultFilterPlugin\";\nimport { createObjectFilterPlugin } from \"./objectFilterPlugin\";\nimport { createRefFilterPlugin } from \"./refFilterPlugin\";\n\nexport const createFilterPlugins = () => {\n return [createDefaultFilterPlugin(), createObjectFilterPlugin(), createRefFilterPlugin()];\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAEO,MAAMA,mBAAmB,GAAG,MAAM;EACrC,OAAO,CAAC,IAAAC,8CAAA,GAAD,EAA8B,IAAAC,4CAAA,GAA9B,EAA0D,IAAAC,sCAAA,GAA1D,CAAP;AACH,CAFM"}
@@ -0,0 +1,2 @@
1
+ import { CmsEntryFilterPlugin } from "../../../../../plugins/CmsEntryFilterPlugin";
2
+ export declare const createObjectFilterPlugin: () => CmsEntryFilterPlugin;
@@ -0,0 +1,78 @@
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.createObjectFilterPlugin = void 0;
9
+
10
+ var _CmsEntryFilterPlugin = require("../../../../../plugins/CmsEntryFilterPlugin");
11
+
12
+ var _apiElasticsearch = require("@webiny/api-elasticsearch");
13
+
14
+ var _error = _interopRequireDefault(require("@webiny/error"));
15
+
16
+ const createObjectFilterPlugin = () => {
17
+ const plugin = new _CmsEntryFilterPlugin.CmsEntryFilterPlugin({
18
+ fieldType: "object",
19
+ exec: params => {
20
+ const {
21
+ applyFiltering,
22
+ value: where,
23
+ fields,
24
+ field: parentField,
25
+ getFilterPlugin,
26
+ query
27
+ } = params;
28
+ /**
29
+ * Because this is an object field, we must construct filters based on the value property.
30
+ * Value property is actually a where condition.
31
+ */
32
+
33
+ for (const key in where) {
34
+ const value = where[key];
35
+
36
+ if (value === undefined) {
37
+ continue;
38
+ }
39
+
40
+ const {
41
+ field: whereFieldId,
42
+ operator
43
+ } = (0, _apiElasticsearch.parseWhereKey)(key);
44
+ const identifier = [...parentField.parents.map(p => p.fieldId), parentField.field.fieldId, whereFieldId].join(".");
45
+ const field = fields[identifier];
46
+
47
+ if (!field) {
48
+ throw new _error.default(`There is no field "${identifier}".`);
49
+ }
50
+ /**
51
+ * We need to find the filter plugin for the child field.
52
+ * This will throw error if no plugin can be found.
53
+ */
54
+
55
+
56
+ const plugin = getFilterPlugin(field.type);
57
+ /**
58
+ * Basically this allows us to go into depth as much as we want with the object fields.
59
+ */
60
+
61
+ plugin.exec({
62
+ applyFiltering,
63
+ getFilterPlugin,
64
+ key,
65
+ value,
66
+ operator,
67
+ field,
68
+ fields,
69
+ query
70
+ });
71
+ }
72
+ }
73
+ });
74
+ plugin.name = `${plugin.type}.default.object`;
75
+ return plugin;
76
+ };
77
+
78
+ exports.createObjectFilterPlugin = createObjectFilterPlugin;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createObjectFilterPlugin","plugin","CmsEntryFilterPlugin","fieldType","exec","params","applyFiltering","value","where","fields","field","parentField","getFilterPlugin","query","key","undefined","whereFieldId","operator","parseWhereKey","identifier","parents","map","p","fieldId","join","WebinyError","type","name"],"sources":["objectFilterPlugin.ts"],"sourcesContent":["import { CmsEntryFilterPlugin } from \"~/plugins/CmsEntryFilterPlugin\";\nimport { parseWhereKey } from \"@webiny/api-elasticsearch\";\nimport WebinyError from \"@webiny/error\";\n\nexport const createObjectFilterPlugin = () => {\n const plugin = new CmsEntryFilterPlugin({\n fieldType: \"object\",\n exec: params => {\n const {\n applyFiltering,\n value: where,\n fields,\n field: parentField,\n getFilterPlugin,\n query\n } = params;\n /**\n * Because this is an object field, we must construct filters based on the value property.\n * Value property is actually a where condition.\n */\n for (const key in where) {\n const value = where[key];\n if (value === undefined) {\n continue;\n }\n const { field: whereFieldId, operator } = parseWhereKey(key);\n\n const identifier = [\n ...parentField.parents.map(p => p.fieldId),\n parentField.field.fieldId,\n whereFieldId\n ].join(\".\");\n const field = fields[identifier];\n if (!field) {\n throw new WebinyError(`There is no field \"${identifier}\".`);\n }\n /**\n * We need to find the filter plugin for the child field.\n * This will throw error if no plugin can be found.\n */\n const plugin = getFilterPlugin(field.type);\n /**\n * Basically this allows us to go into depth as much as we want with the object fields.\n */\n plugin.exec({\n applyFiltering,\n getFilterPlugin,\n key,\n value,\n operator,\n field,\n fields,\n query\n });\n }\n }\n });\n\n plugin.name = `${plugin.type}.default.object`;\n\n return plugin;\n};\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AAEO,MAAMA,wBAAwB,GAAG,MAAM;EAC1C,MAAMC,MAAM,GAAG,IAAIC,0CAAJ,CAAyB;IACpCC,SAAS,EAAE,QADyB;IAEpCC,IAAI,EAAEC,MAAM,IAAI;MACZ,MAAM;QACFC,cADE;QAEFC,KAAK,EAAEC,KAFL;QAGFC,MAHE;QAIFC,KAAK,EAAEC,WAJL;QAKFC,eALE;QAMFC;MANE,IAOFR,MAPJ;MAQA;AACZ;AACA;AACA;;MACY,KAAK,MAAMS,GAAX,IAAkBN,KAAlB,EAAyB;QACrB,MAAMD,KAAK,GAAGC,KAAK,CAACM,GAAD,CAAnB;;QACA,IAAIP,KAAK,KAAKQ,SAAd,EAAyB;UACrB;QACH;;QACD,MAAM;UAAEL,KAAK,EAAEM,YAAT;UAAuBC;QAAvB,IAAoC,IAAAC,+BAAA,EAAcJ,GAAd,CAA1C;QAEA,MAAMK,UAAU,GAAG,CACf,GAAGR,WAAW,CAACS,OAAZ,CAAoBC,GAApB,CAAwBC,CAAC,IAAIA,CAAC,CAACC,OAA/B,CADY,EAEfZ,WAAW,CAACD,KAAZ,CAAkBa,OAFH,EAGfP,YAHe,EAIjBQ,IAJiB,CAIZ,GAJY,CAAnB;QAKA,MAAMd,KAAK,GAAGD,MAAM,CAACU,UAAD,CAApB;;QACA,IAAI,CAACT,KAAL,EAAY;UACR,MAAM,IAAIe,cAAJ,CAAiB,sBAAqBN,UAAW,IAAjD,CAAN;QACH;QACD;AAChB;AACA;AACA;;;QACgB,MAAMlB,MAAM,GAAGW,eAAe,CAACF,KAAK,CAACgB,IAAP,CAA9B;QACA;AAChB;AACA;;QACgBzB,MAAM,CAACG,IAAP,CAAY;UACRE,cADQ;UAERM,eAFQ;UAGRE,GAHQ;UAIRP,KAJQ;UAKRU,QALQ;UAMRP,KANQ;UAORD,MAPQ;UAQRI;QARQ,CAAZ;MAUH;IACJ;EAlDmC,CAAzB,CAAf;EAqDAZ,MAAM,CAAC0B,IAAP,GAAe,GAAE1B,MAAM,CAACyB,IAAK,iBAA7B;EAEA,OAAOzB,MAAP;AACH,CAzDM"}
@@ -0,0 +1,2 @@
1
+ import { CmsEntryFilterPlugin } from "../../../../../plugins/CmsEntryFilterPlugin";
2
+ export declare const createRefFilterPlugin: () => CmsEntryFilterPlugin;
@@ -0,0 +1,58 @@
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.createRefFilterPlugin = void 0;
9
+
10
+ var _error = _interopRequireDefault(require("@webiny/error"));
11
+
12
+ var _CmsEntryFilterPlugin = require("../../../../../plugins/CmsEntryFilterPlugin");
13
+
14
+ var _apiElasticsearch = require("@webiny/api-elasticsearch");
15
+
16
+ const createRefFilterPlugin = () => {
17
+ return new _CmsEntryFilterPlugin.CmsEntryFilterPlugin({
18
+ fieldType: "ref",
19
+ exec: params => {
20
+ const {
21
+ applyFiltering,
22
+ value: values,
23
+ query,
24
+ field
25
+ } = params;
26
+ /**
27
+ * We must have an object when querying in the ref field.
28
+ */
29
+
30
+ if (typeof values !== "object") {
31
+ throw new _error.default(`When querying by ref field, value of the field must be an object.`, "OBJECT_REQUIRED", {
32
+ value: values
33
+ });
34
+ }
35
+
36
+ for (const key in values) {
37
+ const {
38
+ operator
39
+ } = (0, _apiElasticsearch.parseWhereKey)(key);
40
+ const value = values[key];
41
+
42
+ if (value === undefined) {
43
+ continue;
44
+ }
45
+
46
+ applyFiltering({
47
+ query,
48
+ field,
49
+ operator,
50
+ key,
51
+ value
52
+ });
53
+ }
54
+ }
55
+ });
56
+ };
57
+
58
+ exports.createRefFilterPlugin = createRefFilterPlugin;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createRefFilterPlugin","CmsEntryFilterPlugin","fieldType","exec","params","applyFiltering","value","values","query","field","WebinyError","key","operator","parseWhereKey","undefined"],"sources":["refFilterPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsEntryFilterPlugin } from \"~/plugins/CmsEntryFilterPlugin\";\nimport { parseWhereKey } from \"@webiny/api-elasticsearch\";\n\nexport const createRefFilterPlugin = () => {\n return new CmsEntryFilterPlugin({\n fieldType: \"ref\",\n exec: params => {\n const { applyFiltering, value: values, query, field } = params;\n /**\n * We must have an object when querying in the ref field.\n */\n if (typeof values !== \"object\") {\n throw new WebinyError(\n `When querying by ref field, value of the field must be an object.`,\n \"OBJECT_REQUIRED\",\n {\n value: values\n }\n );\n }\n\n for (const key in values) {\n const { operator } = parseWhereKey(key);\n const value = values[key];\n if (value === undefined) {\n continue;\n }\n\n applyFiltering({\n query,\n field,\n operator,\n key,\n value\n });\n }\n }\n });\n};\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AAEO,MAAMA,qBAAqB,GAAG,MAAM;EACvC,OAAO,IAAIC,0CAAJ,CAAyB;IAC5BC,SAAS,EAAE,KADiB;IAE5BC,IAAI,EAAEC,MAAM,IAAI;MACZ,MAAM;QAAEC,cAAF;QAAkBC,KAAK,EAAEC,MAAzB;QAAiCC,KAAjC;QAAwCC;MAAxC,IAAkDL,MAAxD;MACA;AACZ;AACA;;MACY,IAAI,OAAOG,MAAP,KAAkB,QAAtB,EAAgC;QAC5B,MAAM,IAAIG,cAAJ,CACD,mEADC,EAEF,iBAFE,EAGF;UACIJ,KAAK,EAAEC;QADX,CAHE,CAAN;MAOH;;MAED,KAAK,MAAMI,GAAX,IAAkBJ,MAAlB,EAA0B;QACtB,MAAM;UAAEK;QAAF,IAAe,IAAAC,+BAAA,EAAcF,GAAd,CAArB;QACA,MAAML,KAAK,GAAGC,MAAM,CAACI,GAAD,CAApB;;QACA,IAAIL,KAAK,KAAKQ,SAAd,EAAyB;UACrB;QACH;;QAEDT,cAAc,CAAC;UACXG,KADW;UAEXC,KAFW;UAGXG,QAHW;UAIXD,GAJW;UAKXL;QALW,CAAD,CAAd;MAOH;IACJ;EAhC2B,CAAzB,CAAP;AAkCH,CAnCM"}
@@ -0,0 +1,2 @@
1
+ import { ElasticsearchBoolQueryConfig } from "@webiny/api-elasticsearch/types";
2
+ export declare const getPopulated: (query: ElasticsearchBoolQueryConfig) => Partial<ElasticsearchBoolQueryConfig>;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getPopulated = void 0;
7
+
8
+ const getPopulated = query => {
9
+ const result = {};
10
+ let key;
11
+
12
+ for (key in query) {
13
+ const value = query[key];
14
+
15
+ if (value === undefined || Array.isArray(value) && value.length === 0) {
16
+ continue;
17
+ }
18
+ /**
19
+ * TODO figure out better types.
20
+ */
21
+ // @ts-ignore
22
+
23
+
24
+ result[key] = value;
25
+ }
26
+
27
+ return result;
28
+ };
29
+
30
+ exports.getPopulated = getPopulated;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getPopulated","query","result","key","value","undefined","Array","isArray","length"],"sources":["populated.ts"],"sourcesContent":["import { ElasticsearchBoolQueryConfig } from \"@webiny/api-elasticsearch/types\";\n\nexport const getPopulated = (\n query: ElasticsearchBoolQueryConfig\n): Partial<ElasticsearchBoolQueryConfig> => {\n const result: Partial<ElasticsearchBoolQueryConfig> = {};\n let key: keyof ElasticsearchBoolQueryConfig;\n for (key in query) {\n const value = query[key];\n if (value === undefined || (Array.isArray(value) && value.length === 0)) {\n continue;\n }\n /**\n * TODO figure out better types.\n */\n // @ts-ignore\n result[key] = value;\n }\n return result;\n};\n"],"mappings":";;;;;;;AAEO,MAAMA,YAAY,GACrBC,KADwB,IAEgB;EACxC,MAAMC,MAA6C,GAAG,EAAtD;EACA,IAAIC,GAAJ;;EACA,KAAKA,GAAL,IAAYF,KAAZ,EAAmB;IACf,MAAMG,KAAK,GAAGH,KAAK,CAACE,GAAD,CAAnB;;IACA,IAAIC,KAAK,KAAKC,SAAV,IAAwBC,KAAK,CAACC,OAAN,CAAcH,KAAd,KAAwBA,KAAK,CAACI,MAAN,KAAiB,CAArE,EAAyE;MACrE;IACH;IACD;AACR;AACA;IACQ;;;IACAN,MAAM,CAACC,GAAD,CAAN,GAAcC,KAAd;EACH;;EACD,OAAOF,MAAP;AACH,CAjBM"}
@@ -0,0 +1,2 @@
1
+ import { CmsEntryListWhere } from "@webiny/api-headless-cms/types";
2
+ export declare const getWhereValues: (value: unknown, condition: "AND" | "OR") => CmsEntryListWhere[];
@@ -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;