@webiny/api-headless-cms-ddb-es 6.0.0-beta.0 → 6.0.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (285) hide show
  1. package/README.md +6 -30
  2. package/configurations.d.ts +4 -5
  3. package/configurations.js +12 -24
  4. package/configurations.js.map +1 -1
  5. package/definitions/entry.d.ts +4 -5
  6. package/definitions/entry.js +5 -174
  7. package/definitions/entry.js.map +1 -1
  8. package/definitions/group.d.ts +6 -6
  9. package/definitions/group.js +5 -58
  10. package/definitions/group.js.map +1 -1
  11. package/definitions/model.d.ts +6 -6
  12. package/definitions/model.js +5 -102
  13. package/definitions/model.js.map +1 -1
  14. package/definitions/types.d.ts +59 -0
  15. package/definitions/types.js +3 -0
  16. package/definitions/types.js.map +1 -0
  17. package/dynamoDb/index.d.ts +2 -2
  18. package/dynamoDb/index.js +5 -14
  19. package/dynamoDb/index.js.map +1 -1
  20. package/dynamoDb/storage/longText.js +11 -18
  21. package/dynamoDb/storage/longText.js.map +1 -1
  22. package/dynamoDb/storage/richText.d.ts +0 -5
  23. package/dynamoDb/storage/richText.js +25 -80
  24. package/dynamoDb/storage/richText.js.map +1 -1
  25. package/elasticsearch/createElasticsearchIndex.d.ts +3 -3
  26. package/elasticsearch/createElasticsearchIndex.js +7 -15
  27. package/elasticsearch/createElasticsearchIndex.js.map +1 -1
  28. package/elasticsearch/deleteElasticsearchIndex.d.ts +2 -2
  29. package/elasticsearch/deleteElasticsearchIndex.js +3 -10
  30. package/elasticsearch/deleteElasticsearchIndex.js.map +1 -1
  31. package/elasticsearch/index.d.ts +1 -1
  32. package/elasticsearch/index.js +3 -11
  33. package/elasticsearch/index.js.map +1 -1
  34. package/elasticsearch/indexing/dateTimeIndexing.d.ts +1 -1
  35. package/elasticsearch/indexing/dateTimeIndexing.js +1 -8
  36. package/elasticsearch/indexing/dateTimeIndexing.js.map +1 -1
  37. package/elasticsearch/indexing/defaultFieldIndexing.d.ts +1 -1
  38. package/elasticsearch/indexing/defaultFieldIndexing.js +1 -8
  39. package/elasticsearch/indexing/defaultFieldIndexing.js.map +1 -1
  40. package/elasticsearch/indexing/index.d.ts +1 -1
  41. package/elasticsearch/indexing/index.js +8 -16
  42. package/elasticsearch/indexing/index.js.map +1 -1
  43. package/elasticsearch/indexing/jsonIndexing.d.ts +1 -1
  44. package/elasticsearch/indexing/jsonIndexing.js +1 -8
  45. package/elasticsearch/indexing/jsonIndexing.js.map +1 -1
  46. package/elasticsearch/indexing/longTextIndexing.d.ts +1 -1
  47. package/elasticsearch/indexing/longTextIndexing.js +1 -8
  48. package/elasticsearch/indexing/longTextIndexing.js.map +1 -1
  49. package/elasticsearch/indexing/numberIndexing.d.ts +1 -1
  50. package/elasticsearch/indexing/numberIndexing.js +1 -8
  51. package/elasticsearch/indexing/numberIndexing.js.map +1 -1
  52. package/elasticsearch/indexing/objectIndexing.d.ts +1 -1
  53. package/elasticsearch/indexing/objectIndexing.js +6 -13
  54. package/elasticsearch/indexing/objectIndexing.js.map +1 -1
  55. package/elasticsearch/indexing/richTextIndexing.d.ts +1 -1
  56. package/elasticsearch/indexing/richTextIndexing.js +1 -8
  57. package/elasticsearch/indexing/richTextIndexing.js.map +1 -1
  58. package/elasticsearch/indices/base.d.ts +1 -1
  59. package/elasticsearch/indices/base.js +4 -10
  60. package/elasticsearch/indices/base.js.map +1 -1
  61. package/elasticsearch/indices/index.d.ts +1 -1
  62. package/elasticsearch/indices/index.js +3 -11
  63. package/elasticsearch/indices/index.js.map +1 -1
  64. package/elasticsearch/search/index.d.ts +1 -1
  65. package/elasticsearch/search/index.js +4 -10
  66. package/elasticsearch/search/index.js.map +1 -1
  67. package/elasticsearch/search/refSearch.d.ts +1 -1
  68. package/elasticsearch/search/refSearch.js +3 -10
  69. package/elasticsearch/search/refSearch.js.map +1 -1
  70. package/elasticsearch/search/searchableJson.d.ts +2 -0
  71. package/elasticsearch/search/searchableJson.js +53 -0
  72. package/elasticsearch/search/searchableJson.js.map +1 -0
  73. package/elasticsearch/search/timeSearch.d.ts +1 -1
  74. package/elasticsearch/search/timeSearch.js +3 -10
  75. package/elasticsearch/search/timeSearch.js.map +1 -1
  76. package/helpers/entryIndexHelpers.d.ts +10 -10
  77. package/helpers/entryIndexHelpers.js +32 -26
  78. package/helpers/entryIndexHelpers.js.map +1 -1
  79. package/helpers/fieldIdentifier.d.ts +1 -1
  80. package/helpers/fieldIdentifier.js +2 -10
  81. package/helpers/fieldIdentifier.js.map +1 -1
  82. package/helpers/index.d.ts +2 -2
  83. package/helpers/index.js +2 -27
  84. package/helpers/index.js.map +1 -1
  85. package/index.d.ts +2 -2
  86. package/index.js +108 -134
  87. package/index.js.map +1 -1
  88. package/operations/entry/dataLoader/DataLoaderCache.d.ts +1 -3
  89. package/operations/entry/dataLoader/DataLoaderCache.js +2 -9
  90. package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -1
  91. package/operations/entry/dataLoader/constants.js +1 -7
  92. package/operations/entry/dataLoader/constants.js.map +1 -1
  93. package/operations/entry/dataLoader/createBatchScheduleFn.js +4 -10
  94. package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -1
  95. package/operations/entry/dataLoader/getAllEntryRevisions.d.ts +3 -3
  96. package/operations/entry/dataLoader/getAllEntryRevisions.js +11 -24
  97. package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -1
  98. package/operations/entry/dataLoader/getLatestRevisionByEntryId.d.ts +3 -3
  99. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +18 -30
  100. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -1
  101. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.d.ts +3 -3
  102. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +18 -30
  103. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -1
  104. package/operations/entry/dataLoader/getRevisionById.d.ts +3 -3
  105. package/operations/entry/dataLoader/getRevisionById.js +23 -35
  106. package/operations/entry/dataLoader/getRevisionById.js.map +1 -1
  107. package/operations/entry/dataLoader/index.d.ts +5 -5
  108. package/operations/entry/dataLoader/index.js +10 -31
  109. package/operations/entry/dataLoader/index.js.map +1 -1
  110. package/operations/entry/dataLoader/types.d.ts +3 -4
  111. package/operations/entry/dataLoader/types.js +1 -5
  112. package/operations/entry/dataLoader/types.js.map +1 -1
  113. package/operations/entry/dataLoaders.d.ts +13 -13
  114. package/operations/entry/dataLoaders.js +15 -25
  115. package/operations/entry/dataLoaders.js.map +1 -1
  116. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.d.ts +1 -1
  117. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js +1 -8
  118. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js.map +1 -1
  119. package/operations/entry/elasticsearch/body.d.ts +3 -3
  120. package/operations/entry/elasticsearch/body.js +21 -28
  121. package/operations/entry/elasticsearch/body.js.map +1 -1
  122. package/operations/entry/elasticsearch/fields.d.ts +3 -3
  123. package/operations/entry/elasticsearch/fields.js +110 -24
  124. package/operations/entry/elasticsearch/fields.js.map +1 -1
  125. package/operations/entry/elasticsearch/filtering/applyFiltering.d.ts +2 -2
  126. package/operations/entry/elasticsearch/filtering/applyFiltering.js +10 -17
  127. package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +1 -1
  128. package/operations/entry/elasticsearch/filtering/exec.d.ts +7 -6
  129. package/operations/entry/elasticsearch/filtering/exec.js +48 -45
  130. package/operations/entry/elasticsearch/filtering/exec.js.map +1 -1
  131. package/operations/entry/elasticsearch/filtering/index.d.ts +1 -1
  132. package/operations/entry/elasticsearch/filtering/index.js +1 -16
  133. package/operations/entry/elasticsearch/filtering/index.js.map +1 -1
  134. package/operations/entry/elasticsearch/filtering/path.d.ts +2 -1
  135. package/operations/entry/elasticsearch/filtering/path.js +9 -17
  136. package/operations/entry/elasticsearch/filtering/path.js.map +1 -1
  137. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.d.ts +1 -1
  138. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js +6 -14
  139. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js.map +1 -1
  140. package/operations/entry/elasticsearch/filtering/plugins/index.d.ts +1 -1
  141. package/operations/entry/elasticsearch/filtering/plugins/index.js +5 -12
  142. package/operations/entry/elasticsearch/filtering/plugins/index.js.map +1 -1
  143. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.d.ts +1 -1
  144. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js +7 -15
  145. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js.map +1 -1
  146. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.d.ts +1 -1
  147. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js +15 -16
  148. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js.map +1 -1
  149. package/operations/entry/elasticsearch/filtering/populated.d.ts +1 -1
  150. package/operations/entry/elasticsearch/filtering/populated.js +1 -8
  151. package/operations/entry/elasticsearch/filtering/populated.js.map +1 -1
  152. package/operations/entry/elasticsearch/filtering/values.d.ts +1 -1
  153. package/operations/entry/elasticsearch/filtering/values.js +4 -12
  154. package/operations/entry/elasticsearch/filtering/values.js.map +1 -1
  155. package/operations/entry/elasticsearch/fullTextSearch.d.ts +3 -3
  156. package/operations/entry/elasticsearch/fullTextSearch.js +6 -12
  157. package/operations/entry/elasticsearch/fullTextSearch.js.map +1 -1
  158. package/operations/entry/elasticsearch/fullTextSearchFields.d.ts +1 -1
  159. package/operations/entry/elasticsearch/fullTextSearchFields.js +1 -8
  160. package/operations/entry/elasticsearch/fullTextSearchFields.js.map +1 -1
  161. package/operations/entry/elasticsearch/initialQuery.d.ts +2 -2
  162. package/operations/entry/elasticsearch/initialQuery.js +9 -26
  163. package/operations/entry/elasticsearch/initialQuery.js.map +1 -1
  164. package/operations/entry/elasticsearch/keyword.d.ts +1 -1
  165. package/operations/entry/elasticsearch/keyword.js +4 -9
  166. package/operations/entry/elasticsearch/keyword.js.map +1 -1
  167. package/operations/entry/elasticsearch/plugins/bodyModifier.d.ts +4 -4
  168. package/operations/entry/elasticsearch/plugins/bodyModifier.js +3 -10
  169. package/operations/entry/elasticsearch/plugins/bodyModifier.js.map +1 -1
  170. package/operations/entry/elasticsearch/plugins/operator.d.ts +2 -3
  171. package/operations/entry/elasticsearch/plugins/operator.js +4 -19
  172. package/operations/entry/elasticsearch/plugins/operator.js.map +1 -1
  173. package/operations/entry/elasticsearch/plugins/queryModifier.d.ts +4 -4
  174. package/operations/entry/elasticsearch/plugins/queryModifier.js +3 -10
  175. package/operations/entry/elasticsearch/plugins/queryModifier.js.map +1 -1
  176. package/operations/entry/elasticsearch/plugins/search.d.ts +2 -2
  177. package/operations/entry/elasticsearch/plugins/search.js +5 -13
  178. package/operations/entry/elasticsearch/plugins/search.js.map +1 -1
  179. package/operations/entry/elasticsearch/plugins/sortModifier.d.ts +4 -4
  180. package/operations/entry/elasticsearch/plugins/sortModifier.js +3 -10
  181. package/operations/entry/elasticsearch/plugins/sortModifier.js.map +1 -1
  182. package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.d.ts +2 -0
  183. package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js +6 -0
  184. package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js.map +1 -0
  185. package/operations/entry/elasticsearch/sort.d.ts +4 -4
  186. package/operations/entry/elasticsearch/sort.js +57 -33
  187. package/operations/entry/elasticsearch/sort.js.map +1 -1
  188. package/operations/entry/elasticsearch/transformValueForSearch.d.ts +2 -2
  189. package/operations/entry/elasticsearch/transformValueForSearch.js +4 -9
  190. package/operations/entry/elasticsearch/transformValueForSearch.js.map +1 -1
  191. package/operations/entry/elasticsearch/types.d.ts +5 -5
  192. package/operations/entry/elasticsearch/types.js +1 -5
  193. package/operations/entry/elasticsearch/types.js.map +1 -1
  194. package/operations/entry/index.d.ts +7 -6
  195. package/operations/entry/index.js +634 -735
  196. package/operations/entry/index.js.map +1 -1
  197. package/operations/entry/keys.d.ts +31 -1
  198. package/operations/entry/keys.js +56 -19
  199. package/operations/entry/keys.js.map +1 -1
  200. package/operations/entry/recordType.js +3 -12
  201. package/operations/entry/recordType.js.map +1 -1
  202. package/operations/entry/transformations/convertEntryKeys.d.ts +6 -6
  203. package/operations/entry/transformations/convertEntryKeys.js +2 -10
  204. package/operations/entry/transformations/convertEntryKeys.js.map +1 -1
  205. package/operations/entry/transformations/index.d.ts +17 -17
  206. package/operations/entry/transformations/index.js +22 -30
  207. package/operations/entry/transformations/index.js.map +1 -1
  208. package/operations/entry/transformations/modifyEntryValues.d.ts +27 -34
  209. package/operations/entry/transformations/modifyEntryValues.js +1 -8
  210. package/operations/entry/transformations/modifyEntryValues.js.map +1 -1
  211. package/operations/entry/transformations/transformEntryKeys.d.ts +8 -8
  212. package/operations/entry/transformations/transformEntryKeys.js +4 -11
  213. package/operations/entry/transformations/transformEntryKeys.js.map +1 -1
  214. package/operations/entry/transformations/transformEntryToIndex.d.ts +7 -7
  215. package/operations/entry/transformations/transformEntryToIndex.js +3 -10
  216. package/operations/entry/transformations/transformEntryToIndex.js.map +1 -1
  217. package/operations/group/index.d.ts +6 -5
  218. package/operations/group/index.js +39 -73
  219. package/operations/group/index.js.map +1 -1
  220. package/operations/model/index.d.ts +4 -4
  221. package/operations/model/index.js +38 -57
  222. package/operations/model/index.js.map +1 -1
  223. package/package.json +29 -41
  224. package/plugins/CmsElasticsearchModelFieldPlugin.d.ts +1 -1
  225. package/plugins/CmsElasticsearchModelFieldPlugin.js +2 -8
  226. package/plugins/CmsElasticsearchModelFieldPlugin.js.map +1 -1
  227. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.d.ts +3 -2
  228. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js +3 -11
  229. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js.map +1 -1
  230. package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.d.ts +2 -2
  231. package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js +3 -11
  232. package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js.map +1 -1
  233. package/plugins/CmsEntryElasticsearchIndexPlugin.js +2 -9
  234. package/plugins/CmsEntryElasticsearchIndexPlugin.js.map +1 -1
  235. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.d.ts +3 -2
  236. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js +3 -11
  237. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js.map +1 -1
  238. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.d.ts +3 -2
  239. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js +3 -11
  240. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js.map +1 -1
  241. package/plugins/CmsEntryElasticsearchSortModifierPlugin.d.ts +3 -2
  242. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js +3 -11
  243. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js.map +1 -1
  244. package/plugins/CmsEntryElasticsearchValuesModifier.d.ts +12 -12
  245. package/plugins/CmsEntryElasticsearchValuesModifier.js +4 -12
  246. package/plugins/CmsEntryElasticsearchValuesModifier.js.map +1 -1
  247. package/plugins/CmsEntryFilterPlugin.d.ts +3 -3
  248. package/plugins/CmsEntryFilterPlugin.js +2 -9
  249. package/plugins/CmsEntryFilterPlugin.js.map +1 -1
  250. package/plugins/index.d.ts +8 -8
  251. package/plugins/index.js +8 -93
  252. package/plugins/index.js.map +1 -1
  253. package/tasks/createIndexTaskPlugin.d.ts +2 -2
  254. package/tasks/createIndexTaskPlugin.js +36 -62
  255. package/tasks/createIndexTaskPlugin.js.map +1 -1
  256. package/types.d.ts +28 -33
  257. package/types.js +5 -8
  258. package/types.js.map +1 -1
  259. package/values/NoValueContainer.d.ts +5 -0
  260. package/values/NoValueContainer.js +13 -0
  261. package/values/NoValueContainer.js.map +1 -0
  262. package/definitions/entryElasticsearch.d.ts +0 -8
  263. package/definitions/entryElasticsearch.js +0 -38
  264. package/definitions/entryElasticsearch.js.map +0 -1
  265. package/definitions/system.d.ts +0 -8
  266. package/definitions/system.js +0 -42
  267. package/definitions/system.js.map +0 -1
  268. package/definitions/table.d.ts +0 -8
  269. package/definitions/table.js +0 -25
  270. package/definitions/table.js.map +0 -1
  271. package/definitions/tableElasticsearch.d.ts +0 -8
  272. package/definitions/tableElasticsearch.js +0 -25
  273. package/definitions/tableElasticsearch.js.map +0 -1
  274. package/dynamoDb/storage/date.d.ts +0 -3
  275. package/dynamoDb/storage/date.js +0 -84
  276. package/dynamoDb/storage/date.js.map +0 -1
  277. package/elasticsearch/indices/japanese.d.ts +0 -2
  278. package/elasticsearch/indices/japanese.js +0 -14
  279. package/elasticsearch/indices/japanese.js.map +0 -1
  280. package/operations/system/index.d.ts +0 -6
  281. package/operations/system/index.js +0 -94
  282. package/operations/system/index.js.map +0 -1
  283. package/operations/system/indexes.d.ts +0 -10
  284. package/operations/system/indexes.js +0 -41
  285. package/operations/system/indexes.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"names":["_CmsEntryFilterPlugin","require","_apiElasticsearch","_error","_interopRequireDefault","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","Object","keys","type","name","exports"],"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(\n `There is no field \"${identifier}\".`,\n \"OBJECT_FILTER_FIELD_ERROR\",\n {\n fields: Object.keys(fields)\n }\n );\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,IAAAA,qBAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEO,MAAMI,wBAAwB,GAAGA,CAAA,KAAM;EAC1C,MAAMC,MAAM,GAAG,IAAIC,0CAAoB,CAAC;IACpCC,SAAS,EAAE,QAAQ;IACnBC,IAAI,EAAEC,MAAM,IAAI;MACZ,MAAM;QACFC,cAAc;QACdC,KAAK,EAAEC,KAAK;QACZC,MAAM;QACNC,KAAK,EAAEC,WAAW;QAClBC,eAAe;QACfC;MACJ,CAAC,GAAGR,MAAM;MACV;AACZ;AACA;AACA;MACY,KAAK,MAAMS,GAAG,IAAIN,KAAK,EAAE;QACrB,MAAMD,KAAK,GAAGC,KAAK,CAACM,GAAG,CAAC;QACxB,IAAIP,KAAK,KAAKQ,SAAS,EAAE;UACrB;QACJ;QACA,MAAM;UAAEL,KAAK,EAAEM,YAAY;UAAEC;QAAS,CAAC,GAAG,IAAAC,+BAAa,EAACJ,GAAG,CAAC;QAE5D,MAAMK,UAAU,GAAG,CACf,GAAGR,WAAW,CAACS,OAAO,CAACC,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACC,OAAO,CAAC,EAC1CZ,WAAW,CAACD,KAAK,CAACa,OAAO,EACzBP,YAAY,CACf,CAACQ,IAAI,CAAC,GAAG,CAAC;QACX,MAAMd,KAAK,GAAGD,MAAM,CAACU,UAAU,CAAC;QAChC,IAAI,CAACT,KAAK,EAAE;UACR,MAAM,IAAIe,cAAW,CAChB,sBAAqBN,UAAW,IAAG,EACpC,2BAA2B,EAC3B;YACIV,MAAM,EAAEiB,MAAM,CAACC,IAAI,CAAClB,MAAM;UAC9B,CACJ,CAAC;QACL;QACA;AAChB;AACA;AACA;QACgB,MAAMR,MAAM,GAAGW,eAAe,CAACF,KAAK,CAACkB,IAAI,CAAC;QAC1C;AAChB;AACA;QACgB3B,MAAM,CAACG,IAAI,CAAC;UACRE,cAAc;UACdM,eAAe;UACfE,GAAG;UACHP,KAAK;UACLU,QAAQ;UACRP,KAAK;UACLD,MAAM;UACNI;QACJ,CAAC,CAAC;MACN;IACJ;EACJ,CAAC,CAAC;EAEFZ,MAAM,CAAC4B,IAAI,GAAI,GAAE5B,MAAM,CAAC2B,IAAK,iBAAgB;EAE7C,OAAO3B,MAAM;AACjB,CAAC;AAAC6B,OAAA,CAAA9B,wBAAA,GAAAA,wBAAA","ignoreList":[]}
1
+ {"version":3,"names":["CmsEntryFilterPlugin","parseWhereKey","WebinyError","createObjectFilterPlugin","plugin","fieldType","exec","params","applyFiltering","value","where","fields","field","parentField","getFilterPlugin","query","key","undefined","whereFieldId","operator","identifier","parents","map","p","fieldId","join","Object","keys","type","name"],"sources":["objectFilterPlugin.ts"],"sourcesContent":["import { CmsEntryFilterPlugin } from \"~/plugins/CmsEntryFilterPlugin.js\";\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(\n `There is no field \"${identifier}\".`,\n \"OBJECT_FILTER_FIELD_ERROR\",\n {\n fields: Object.keys(fields)\n }\n );\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,SAASA,oBAAoB;AAC7B,SAASC,aAAa,QAAQ,2BAA2B;AACzD,OAAOC,WAAW,MAAM,eAAe;AAEvC,OAAO,MAAMC,wBAAwB,GAAGA,CAAA,KAAM;EAC1C,MAAMC,MAAM,GAAG,IAAIJ,oBAAoB,CAAC;IACpCK,SAAS,EAAE,QAAQ;IACnBC,IAAI,EAAEC,MAAM,IAAI;MACZ,MAAM;QACFC,cAAc;QACdC,KAAK,EAAEC,KAAK;QACZC,MAAM;QACNC,KAAK,EAAEC,WAAW;QAClBC,eAAe;QACfC;MACJ,CAAC,GAAGR,MAAM;MACV;AACZ;AACA;AACA;MACY,KAAK,MAAMS,GAAG,IAAIN,KAAK,EAAE;QACrB,MAAMD,KAAK,GAAGC,KAAK,CAACM,GAAG,CAAC;QACxB,IAAIP,KAAK,KAAKQ,SAAS,EAAE;UACrB;QACJ;QACA,MAAM;UAAEL,KAAK,EAAEM,YAAY;UAAEC;QAAS,CAAC,GAAGlB,aAAa,CAACe,GAAG,CAAC;QAE5D,MAAMI,UAAU,GAAG,CACf,GAAGP,WAAW,CAACQ,OAAO,CAACC,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACC,OAAO,CAAC,EAC1CX,WAAW,CAACD,KAAK,CAACY,OAAO,EACzBN,YAAY,CACf,CAACO,IAAI,CAAC,GAAG,CAAC;QACX,MAAMb,KAAK,GAAGD,MAAM,CAACS,UAAU,CAAC;QAChC,IAAI,CAACR,KAAK,EAAE;UACR,MAAM,IAAIV,WAAW,CACjB,sBAAsBkB,UAAU,IAAI,EACpC,2BAA2B,EAC3B;YACIT,MAAM,EAAEe,MAAM,CAACC,IAAI,CAAChB,MAAM;UAC9B,CACJ,CAAC;QACL;QACA;AAChB;AACA;AACA;QACgB,MAAMP,MAAM,GAAGU,eAAe,CAACF,KAAK,CAACgB,IAAI,CAAC;QAC1C;AAChB;AACA;QACgBxB,MAAM,CAACE,IAAI,CAAC;UACRE,cAAc;UACdM,eAAe;UACfE,GAAG;UACHP,KAAK;UACLU,QAAQ;UACRP,KAAK;UACLD,MAAM;UACNI;QACJ,CAAC,CAAC;MACN;IACJ;EACJ,CAAC,CAAC;EAEFX,MAAM,CAACyB,IAAI,GAAG,GAAGzB,MAAM,CAACwB,IAAI,iBAAiB;EAE7C,OAAOxB,MAAM;AACjB,CAAC","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- import { CmsEntryFilterPlugin } from "../../../../../plugins/CmsEntryFilterPlugin";
1
+ import { CmsEntryFilterPlugin } from "../../../../../plugins/CmsEntryFilterPlugin.js";
2
2
  export declare const createRefFilterPlugin: () => CmsEntryFilterPlugin;
@@ -1,35 +1,33 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.createRefFilterPlugin = void 0;
8
- var _error = _interopRequireDefault(require("@webiny/error"));
9
- var _CmsEntryFilterPlugin = require("../../../../../plugins/CmsEntryFilterPlugin");
10
- var _apiElasticsearch = require("@webiny/api-elasticsearch");
11
- const createRefFilterPlugin = () => {
12
- return new _CmsEntryFilterPlugin.CmsEntryFilterPlugin({
1
+ import WebinyError from "@webiny/error";
2
+ import { CmsEntryFilterPlugin } from "../../../../../plugins/CmsEntryFilterPlugin.js";
3
+ import { parseWhereKey } from "@webiny/api-elasticsearch";
4
+ export const createRefFilterPlugin = () => {
5
+ const plugin = new CmsEntryFilterPlugin({
13
6
  fieldType: "ref",
14
7
  exec: params => {
15
8
  const {
16
9
  applyFiltering,
17
- value: values,
18
10
  query,
19
11
  field
20
12
  } = params;
13
+ let values = params.value;
21
14
  /**
22
15
  * We must have an object when querying in the ref field.
23
16
  */
24
17
  if (typeof values !== "object") {
25
- throw new _error.default(`When querying by ref field, value of the field must be an object.`, "OBJECT_REQUIRED", {
18
+ throw new WebinyError(`When querying by ref field, value of the field must be an object.`, "OBJECT_REQUIRED", {
26
19
  value: values
27
20
  });
28
21
  }
22
+ if (values === null || values === undefined) {
23
+ values = {
24
+ entryId: null
25
+ };
26
+ }
29
27
  for (const key in values) {
30
28
  const {
31
29
  operator
32
- } = (0, _apiElasticsearch.parseWhereKey)(key);
30
+ } = parseWhereKey(key);
33
31
  const value = values[key];
34
32
  if (value === undefined) {
35
33
  continue;
@@ -44,7 +42,8 @@ const createRefFilterPlugin = () => {
44
42
  }
45
43
  }
46
44
  });
45
+ plugin.name = `${plugin.type}.default.ref`;
46
+ return plugin;
47
47
  };
48
- exports.createRefFilterPlugin = createRefFilterPlugin;
49
48
 
50
49
  //# sourceMappingURL=refFilterPlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_error","_interopRequireDefault","require","_CmsEntryFilterPlugin","_apiElasticsearch","createRefFilterPlugin","CmsEntryFilterPlugin","fieldType","exec","params","applyFiltering","value","values","query","field","WebinyError","key","operator","parseWhereKey","undefined","exports"],"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,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,qBAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AAEO,MAAMG,qBAAqB,GAAGA,CAAA,KAAM;EACvC,OAAO,IAAIC,0CAAoB,CAAC;IAC5BC,SAAS,EAAE,KAAK;IAChBC,IAAI,EAAEC,MAAM,IAAI;MACZ,MAAM;QAAEC,cAAc;QAAEC,KAAK,EAAEC,MAAM;QAAEC,KAAK;QAAEC;MAAM,CAAC,GAAGL,MAAM;MAC9D;AACZ;AACA;MACY,IAAI,OAAOG,MAAM,KAAK,QAAQ,EAAE;QAC5B,MAAM,IAAIG,cAAW,CAChB,mEAAkE,EACnE,iBAAiB,EACjB;UACIJ,KAAK,EAAEC;QACX,CACJ,CAAC;MACL;MAEA,KAAK,MAAMI,GAAG,IAAIJ,MAAM,EAAE;QACtB,MAAM;UAAEK;QAAS,CAAC,GAAG,IAAAC,+BAAa,EAACF,GAAG,CAAC;QACvC,MAAML,KAAK,GAAGC,MAAM,CAACI,GAAG,CAAC;QACzB,IAAIL,KAAK,KAAKQ,SAAS,EAAE;UACrB;QACJ;QAEAT,cAAc,CAAC;UACXG,KAAK;UACLC,KAAK;UACLG,QAAQ;UACRD,GAAG;UACHL;QACJ,CAAC,CAAC;MACN;IACJ;EACJ,CAAC,CAAC;AACN,CAAC;AAACS,OAAA,CAAAf,qBAAA,GAAAA,qBAAA","ignoreList":[]}
1
+ {"version":3,"names":["WebinyError","CmsEntryFilterPlugin","parseWhereKey","createRefFilterPlugin","plugin","fieldType","exec","params","applyFiltering","query","field","values","value","undefined","entryId","key","operator","name","type"],"sources":["refFilterPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsEntryFilterPlugin } from \"~/plugins/CmsEntryFilterPlugin.js\";\nimport { parseWhereKey } from \"@webiny/api-elasticsearch\";\n\nexport const createRefFilterPlugin = () => {\n const plugin = new CmsEntryFilterPlugin({\n fieldType: \"ref\",\n exec: params => {\n const { applyFiltering, query, field } = params;\n\n let values = params.value;\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 if (values === null || values === undefined) {\n values = {\n entryId: null\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 plugin.name = `${plugin.type}.default.ref`;\n\n return plugin;\n};\n"],"mappings":"AAAA,OAAOA,WAAW,MAAM,eAAe;AACvC,SAASC,oBAAoB;AAC7B,SAASC,aAAa,QAAQ,2BAA2B;AAEzD,OAAO,MAAMC,qBAAqB,GAAGA,CAAA,KAAM;EACvC,MAAMC,MAAM,GAAG,IAAIH,oBAAoB,CAAC;IACpCI,SAAS,EAAE,KAAK;IAChBC,IAAI,EAAEC,MAAM,IAAI;MACZ,MAAM;QAAEC,cAAc;QAAEC,KAAK;QAAEC;MAAM,CAAC,GAAGH,MAAM;MAE/C,IAAII,MAAM,GAAGJ,MAAM,CAACK,KAAK;MACzB;AACZ;AACA;MACY,IAAI,OAAOD,MAAM,KAAK,QAAQ,EAAE;QAC5B,MAAM,IAAIX,WAAW,CACjB,mEAAmE,EACnE,iBAAiB,EACjB;UACIY,KAAK,EAAED;QACX,CACJ,CAAC;MACL;MAEA,IAAIA,MAAM,KAAK,IAAI,IAAIA,MAAM,KAAKE,SAAS,EAAE;QACzCF,MAAM,GAAG;UACLG,OAAO,EAAE;QACb,CAAC;MACL;MAEA,KAAK,MAAMC,GAAG,IAAIJ,MAAM,EAAE;QACtB,MAAM;UAAEK;QAAS,CAAC,GAAGd,aAAa,CAACa,GAAG,CAAC;QACvC,MAAMH,KAAK,GAAGD,MAAM,CAACI,GAAG,CAAC;QACzB,IAAIH,KAAK,KAAKC,SAAS,EAAE;UACrB;QACJ;QAEAL,cAAc,CAAC;UACXC,KAAK;UACLC,KAAK;UACLM,QAAQ;UACRD,GAAG;UACHH;QACJ,CAAC,CAAC;MACN;IACJ;EACJ,CAAC,CAAC;EAEFR,MAAM,CAACa,IAAI,GAAG,GAAGb,MAAM,CAACc,IAAI,cAAc;EAE1C,OAAOd,MAAM;AACjB,CAAC","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- import { ElasticsearchBoolQueryConfig } from "@webiny/api-elasticsearch/types";
1
+ import type { ElasticsearchBoolQueryConfig } from "@webiny/api-elasticsearch/types.js";
2
2
  export declare const getPopulated: (query: ElasticsearchBoolQueryConfig) => Partial<ElasticsearchBoolQueryConfig>;
@@ -1,10 +1,4 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getPopulated = void 0;
7
- const getPopulated = query => {
1
+ export const getPopulated = query => {
8
2
  const result = {};
9
3
  let key;
10
4
  for (key in query) {
@@ -20,6 +14,5 @@ const getPopulated = query => {
20
14
  }
21
15
  return result;
22
16
  };
23
- exports.getPopulated = getPopulated;
24
17
 
25
18
  //# sourceMappingURL=populated.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["getPopulated","query","result","key","value","undefined","Array","isArray","length","exports"],"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-expect-error\n result[key] = value;\n }\n return result;\n};\n"],"mappings":";;;;;;AAEO,MAAMA,YAAY,GACrBC,KAAmC,IACK;EACxC,MAAMC,MAA6C,GAAG,CAAC,CAAC;EACxD,IAAIC,GAAuC;EAC3C,KAAKA,GAAG,IAAIF,KAAK,EAAE;IACf,MAAMG,KAAK,GAAGH,KAAK,CAACE,GAAG,CAAC;IACxB,IAAIC,KAAK,KAAKC,SAAS,IAAKC,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,IAAIA,KAAK,CAACI,MAAM,KAAK,CAAE,EAAE;MACrE;IACJ;IACA;AACR;AACA;IACQ;IACAN,MAAM,CAACC,GAAG,CAAC,GAAGC,KAAK;EACvB;EACA,OAAOF,MAAM;AACjB,CAAC;AAACO,OAAA,CAAAT,YAAA,GAAAA,YAAA","ignoreList":[]}
1
+ {"version":3,"names":["getPopulated","query","result","key","value","undefined","Array","isArray","length"],"sources":["populated.ts"],"sourcesContent":["import type { ElasticsearchBoolQueryConfig } from \"@webiny/api-elasticsearch/types.js\";\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-expect-error\n result[key] = value;\n }\n return result;\n};\n"],"mappings":"AAEA,OAAO,MAAMA,YAAY,GACrBC,KAAmC,IACK;EACxC,MAAMC,MAA6C,GAAG,CAAC,CAAC;EACxD,IAAIC,GAAuC;EAC3C,KAAKA,GAAG,IAAIF,KAAK,EAAE;IACf,MAAMG,KAAK,GAAGH,KAAK,CAACE,GAAG,CAAC;IACxB,IAAIC,KAAK,KAAKC,SAAS,IAAKC,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,IAAIA,KAAK,CAACI,MAAM,KAAK,CAAE,EAAE;MACrE;IACJ;IACA;AACR;AACA;IACQ;IACAN,MAAM,CAACC,GAAG,CAAC,GAAGC,KAAK;EACvB;EACA,OAAOF,MAAM;AACjB,CAAC","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- import { CmsEntryListWhere } from "@webiny/api-headless-cms/types";
1
+ import type { CmsEntryListWhere } from "@webiny/api-headless-cms/types/index.js";
2
2
  export declare const getWhereValues: (value: unknown, condition: "AND" | "OR") => CmsEntryListWhere[];
@@ -1,24 +1,16 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.getWhereValues = void 0;
8
- var _error = _interopRequireDefault(require("@webiny/error"));
9
- const getWhereValues = (value, condition) => {
1
+ import WebinyError from "@webiny/error";
2
+ export const getWhereValues = (value, condition) => {
10
3
  const values = value;
11
4
  if (!Array.isArray(values)) {
12
- throw new _error.default(`Trying to run filtering with "${condition}", but the value sent is not an array.`, `MALFORMED_${condition}_CONDITION`, {
5
+ throw new WebinyError(`Trying to run filtering with "${condition}", but the value sent is not an array.`, `MALFORMED_${condition}_CONDITION`, {
13
6
  value
14
7
  });
15
8
  } else if (values.length === 0) {
16
- throw new _error.default(`Trying to run filtering with "${condition}", but the value sent is empty array.`, `MALFORMED_${condition}_CONDITION`, {
9
+ throw new WebinyError(`Trying to run filtering with "${condition}", but the value sent is empty array.`, `MALFORMED_${condition}_CONDITION`, {
17
10
  value
18
11
  });
19
12
  }
20
13
  return values;
21
14
  };
22
- exports.getWhereValues = getWhereValues;
23
15
 
24
16
  //# sourceMappingURL=values.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_error","_interopRequireDefault","require","getWhereValues","value","condition","values","Array","isArray","WebinyError","length","exports"],"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,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEO,MAAMC,cAAc,GAAGA,CAACC,KAAc,EAAEC,SAAuB,KAAK;EACvE,MAAMC,MAAM,GAAGF,KAAwC;EACvD,IAAI,CAACG,KAAK,CAACC,OAAO,CAACF,MAAM,CAAC,EAAE;IACxB,MAAM,IAAIG,cAAW,CAChB,iCAAgCJ,SAAU,wCAAuC,EACjF,aAAYA,SAAU,YAAW,EAClC;MACID;IACJ,CACJ,CAAC;EACL,CAAC,MAAM,IAAIE,MAAM,CAACI,MAAM,KAAK,CAAC,EAAE;IAC5B,MAAM,IAAID,cAAW,CAChB,iCAAgCJ,SAAU,uCAAsC,EAChF,aAAYA,SAAU,YAAW,EAClC;MACID;IACJ,CACJ,CAAC;EACL;EACA,OAAOE,MAAM;AACjB,CAAC;AAACK,OAAA,CAAAR,cAAA,GAAAA,cAAA","ignoreList":[]}
1
+ {"version":3,"names":["WebinyError","getWhereValues","value","condition","values","Array","isArray","length"],"sources":["values.ts"],"sourcesContent":["import type { CmsEntryListWhere } from \"@webiny/api-headless-cms/types/index.js\";\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,OAAOA,WAAW,MAAM,eAAe;AAEvC,OAAO,MAAMC,cAAc,GAAGA,CAACC,KAAc,EAAEC,SAAuB,KAAK;EACvE,MAAMC,MAAM,GAAGF,KAAwC;EACvD,IAAI,CAACG,KAAK,CAACC,OAAO,CAACF,MAAM,CAAC,EAAE;IACxB,MAAM,IAAIJ,WAAW,CACjB,iCAAiCG,SAAS,wCAAwC,EAClF,aAAaA,SAAS,YAAY,EAClC;MACID;IACJ,CACJ,CAAC;EACL,CAAC,MAAM,IAAIE,MAAM,CAACG,MAAM,KAAK,CAAC,EAAE;IAC5B,MAAM,IAAIP,WAAW,CACjB,iCAAiCG,SAAS,uCAAuC,EACjF,aAAaA,SAAS,YAAY,EAClC;MACID;IACJ,CACJ,CAAC;EACL;EACA,OAAOE,MAAM;AACjB,CAAC","ignoreList":[]}
@@ -1,6 +1,6 @@
1
- import { ElasticsearchBoolQueryConfig } from "@webiny/api-elasticsearch/types";
2
- import { CmsModel, CmsModelField } from "@webiny/api-headless-cms/types";
3
- import { PluginsContainer } from "@webiny/plugins";
1
+ import type { ElasticsearchBoolQueryConfig } from "@webiny/api-elasticsearch/types.js";
2
+ import type { CmsModel, CmsModelField } from "@webiny/api-headless-cms/types/index.js";
3
+ import type { PluginsContainer } from "@webiny/plugins";
4
4
  interface Params {
5
5
  plugins: PluginsContainer;
6
6
  model: CmsModel;
@@ -1,15 +1,10 @@
1
- "use strict";
1
+ import { normalizeValue } from "@webiny/api-elasticsearch";
2
+ import { CmsEntryElasticsearchFullTextSearchPlugin, createCmsEntryElasticsearchFullTextSearchPlugin } from "../../../plugins/index.js";
2
3
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.applyFullTextSearch = void 0;
7
- var _apiElasticsearch = require("@webiny/api-elasticsearch");
8
- var _plugins = require("../../../plugins");
9
4
  /**
10
5
  * Our default plugin is working with the AND operator for the multiple words query string.
11
6
  */
12
- const defaultPlugin = (0, _plugins.createCmsEntryElasticsearchFullTextSearchPlugin)({
7
+ const defaultPlugin = createCmsEntryElasticsearchFullTextSearchPlugin({
13
8
  apply: params => {
14
9
  const {
15
10
  query,
@@ -37,7 +32,7 @@ const getPlugin = params => {
37
32
  /**
38
33
  * We need to reverse the plugins, so we can take the last one first - possibility to override existing plugins.
39
34
  */
40
- const plugins = container.byType(_plugins.CmsEntryElasticsearchFullTextSearchPlugin.type).reverse();
35
+ const plugins = container.byType(CmsEntryElasticsearchFullTextSearchPlugin.type).reverse();
41
36
  /**
42
37
  * We need to find the most specific plugin for the given model.
43
38
  * Also, we need to use the first possible plugin if the specific one is not found.
@@ -62,7 +57,7 @@ const getPlugin = params => {
62
57
  }
63
58
  return plugin || defaultPlugin;
64
59
  };
65
- const applyFullTextSearch = params => {
60
+ export const applyFullTextSearch = params => {
66
61
  const {
67
62
  plugins,
68
63
  query,
@@ -83,9 +78,8 @@ const applyFullTextSearch = params => {
83
78
  fields,
84
79
  query,
85
80
  term,
86
- prepareTerm: _apiElasticsearch.normalizeValue
81
+ prepareTerm: normalizeValue
87
82
  });
88
83
  };
89
- exports.applyFullTextSearch = applyFullTextSearch;
90
84
 
91
85
  //# sourceMappingURL=fullTextSearch.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_apiElasticsearch","require","_plugins","defaultPlugin","createCmsEntryElasticsearchFullTextSearchPlugin","apply","params","query","term","fields","createFieldPath","prepareTerm","must","push","query_string","allow_leading_wildcard","map","default_operator","name","getPlugin","container","model","plugins","byType","CmsEntryElasticsearchFullTextSearchPlugin","type","reverse","plugin","pl","models","includes","modelId","length","applyFullTextSearch","field","storageId","normalizeValue","exports"],"sources":["fullTextSearch.ts"],"sourcesContent":["import { ElasticsearchBoolQueryConfig } from \"@webiny/api-elasticsearch/types\";\nimport { normalizeValue } from \"@webiny/api-elasticsearch\";\nimport { CmsModel, CmsModelField } from \"@webiny/api-headless-cms/types\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport {\n CmsEntryElasticsearchFullTextSearchPlugin,\n createCmsEntryElasticsearchFullTextSearchPlugin\n} from \"~/plugins\";\n\n/**\n * Our default plugin is working with the AND operator for the multiple words query string.\n */\nconst defaultPlugin = createCmsEntryElasticsearchFullTextSearchPlugin({\n apply: params => {\n const { query, term, fields, createFieldPath, prepareTerm } = params;\n\n query.must.push({\n query_string: {\n allow_leading_wildcard: true,\n fields: fields.map(createFieldPath),\n query: `*${prepareTerm(term)}*`,\n default_operator: \"and\"\n }\n });\n }\n});\ndefaultPlugin.name = \"headless-cms.elasticsearch.entry.fullTextSearch.default\";\n\ninterface GetPluginParams {\n container: PluginsContainer;\n model: CmsModel;\n}\nconst getPlugin = (params: GetPluginParams): CmsEntryElasticsearchFullTextSearchPlugin => {\n const { container, model } = params;\n /**\n * We need to reverse the plugins, so we can take the last one first - possibility to override existing plugins.\n */\n const plugins = container\n .byType<CmsEntryElasticsearchFullTextSearchPlugin>(\n CmsEntryElasticsearchFullTextSearchPlugin.type\n )\n .reverse();\n /**\n * We need to find the most specific plugin for the given model.\n * Also, we need to use the first possible plugin if the specific one is not found.\n */\n let plugin: CmsEntryElasticsearchFullTextSearchPlugin | null = null;\n for (const pl of plugins) {\n const models = pl.models || [];\n /**\n * We take the first available plugin for the given model.\n */\n if (models.includes(model.modelId)) {\n return pl;\n }\n /**\n * Then we set the first possible plugin, which has no models defined, as the default one.\n * It is important not to set the plugin which has models defined as they are specifically for the targeted model.\n */\n //\n else if (!plugin && models.length === 0) {\n plugin = pl;\n }\n }\n\n return plugin || defaultPlugin;\n};\n\ninterface Params {\n plugins: PluginsContainer;\n model: CmsModel;\n query: ElasticsearchBoolQueryConfig;\n term?: string;\n fields: CmsModelField[];\n}\nexport const applyFullTextSearch = (params: Params): void => {\n const { plugins, query, term, fields, model } = params;\n if (!term || term.length === 0 || fields.length === 0) {\n return;\n }\n\n const plugin = getPlugin({\n container: plugins,\n model\n });\n\n plugin.apply({\n model,\n createFieldPath: field => `values.${field.storageId}`,\n fields,\n query,\n term,\n prepareTerm: normalizeValue\n });\n};\n"],"mappings":";;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AAGA,IAAAC,QAAA,GAAAD,OAAA;AAKA;AACA;AACA;AACA,MAAME,aAAa,GAAG,IAAAC,wDAA+C,EAAC;EAClEC,KAAK,EAAEC,MAAM,IAAI;IACb,MAAM;MAAEC,KAAK;MAAEC,IAAI;MAAEC,MAAM;MAAEC,eAAe;MAAEC;IAAY,CAAC,GAAGL,MAAM;IAEpEC,KAAK,CAACK,IAAI,CAACC,IAAI,CAAC;MACZC,YAAY,EAAE;QACVC,sBAAsB,EAAE,IAAI;QAC5BN,MAAM,EAAEA,MAAM,CAACO,GAAG,CAACN,eAAe,CAAC;QACnCH,KAAK,EAAG,IAAGI,WAAW,CAACH,IAAI,CAAE,GAAE;QAC/BS,gBAAgB,EAAE;MACtB;IACJ,CAAC,CAAC;EACN;AACJ,CAAC,CAAC;AACFd,aAAa,CAACe,IAAI,GAAG,yDAAyD;AAM9E,MAAMC,SAAS,GAAIb,MAAuB,IAAgD;EACtF,MAAM;IAAEc,SAAS;IAAEC;EAAM,CAAC,GAAGf,MAAM;EACnC;AACJ;AACA;EACI,MAAMgB,OAAO,GAAGF,SAAS,CACpBG,MAAM,CACHC,kDAAyC,CAACC,IAC9C,CAAC,CACAC,OAAO,CAAC,CAAC;EACd;AACJ;AACA;AACA;EACI,IAAIC,MAAwD,GAAG,IAAI;EACnE,KAAK,MAAMC,EAAE,IAAIN,OAAO,EAAE;IACtB,MAAMO,MAAM,GAAGD,EAAE,CAACC,MAAM,IAAI,EAAE;IAC9B;AACR;AACA;IACQ,IAAIA,MAAM,CAACC,QAAQ,CAACT,KAAK,CAACU,OAAO,CAAC,EAAE;MAChC,OAAOH,EAAE;IACb;IACA;AACR;AACA;AACA;IACQ;IAAA,KACK,IAAI,CAACD,MAAM,IAAIE,MAAM,CAACG,MAAM,KAAK,CAAC,EAAE;MACrCL,MAAM,GAAGC,EAAE;IACf;EACJ;EAEA,OAAOD,MAAM,IAAIxB,aAAa;AAClC,CAAC;AASM,MAAM8B,mBAAmB,GAAI3B,MAAc,IAAW;EACzD,MAAM;IAAEgB,OAAO;IAAEf,KAAK;IAAEC,IAAI;IAAEC,MAAM;IAAEY;EAAM,CAAC,GAAGf,MAAM;EACtD,IAAI,CAACE,IAAI,IAAIA,IAAI,CAACwB,MAAM,KAAK,CAAC,IAAIvB,MAAM,CAACuB,MAAM,KAAK,CAAC,EAAE;IACnD;EACJ;EAEA,MAAML,MAAM,GAAGR,SAAS,CAAC;IACrBC,SAAS,EAAEE,OAAO;IAClBD;EACJ,CAAC,CAAC;EAEFM,MAAM,CAACtB,KAAK,CAAC;IACTgB,KAAK;IACLX,eAAe,EAAEwB,KAAK,IAAK,UAASA,KAAK,CAACC,SAAU,EAAC;IACrD1B,MAAM;IACNF,KAAK;IACLC,IAAI;IACJG,WAAW,EAAEyB;EACjB,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAAJ,mBAAA,GAAAA,mBAAA","ignoreList":[]}
1
+ {"version":3,"names":["normalizeValue","CmsEntryElasticsearchFullTextSearchPlugin","createCmsEntryElasticsearchFullTextSearchPlugin","defaultPlugin","apply","params","query","term","fields","createFieldPath","prepareTerm","must","push","query_string","allow_leading_wildcard","map","default_operator","name","getPlugin","container","model","plugins","byType","type","reverse","plugin","pl","models","includes","modelId","length","applyFullTextSearch","field","storageId"],"sources":["fullTextSearch.ts"],"sourcesContent":["import type { ElasticsearchBoolQueryConfig } from \"@webiny/api-elasticsearch/types.js\";\nimport { normalizeValue } from \"@webiny/api-elasticsearch\";\nimport type { CmsModel, CmsModelField } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport {\n CmsEntryElasticsearchFullTextSearchPlugin,\n createCmsEntryElasticsearchFullTextSearchPlugin\n} from \"~/plugins/index.js\";\n\n/**\n * Our default plugin is working with the AND operator for the multiple words query string.\n */\nconst defaultPlugin = createCmsEntryElasticsearchFullTextSearchPlugin({\n apply: params => {\n const { query, term, fields, createFieldPath, prepareTerm } = params;\n\n query.must.push({\n query_string: {\n allow_leading_wildcard: true,\n fields: fields.map(createFieldPath),\n query: `*${prepareTerm(term)}*`,\n default_operator: \"and\"\n }\n });\n }\n});\ndefaultPlugin.name = \"headless-cms.elasticsearch.entry.fullTextSearch.default\";\n\ninterface GetPluginParams {\n container: PluginsContainer;\n model: CmsModel;\n}\nconst getPlugin = (params: GetPluginParams): CmsEntryElasticsearchFullTextSearchPlugin => {\n const { container, model } = params;\n /**\n * We need to reverse the plugins, so we can take the last one first - possibility to override existing plugins.\n */\n const plugins = container\n .byType<CmsEntryElasticsearchFullTextSearchPlugin>(\n CmsEntryElasticsearchFullTextSearchPlugin.type\n )\n .reverse();\n /**\n * We need to find the most specific plugin for the given model.\n * Also, we need to use the first possible plugin if the specific one is not found.\n */\n let plugin: CmsEntryElasticsearchFullTextSearchPlugin | null = null;\n for (const pl of plugins) {\n const models = pl.models || [];\n /**\n * We take the first available plugin for the given model.\n */\n if (models.includes(model.modelId)) {\n return pl;\n }\n /**\n * Then we set the first possible plugin, which has no models defined, as the default one.\n * It is important not to set the plugin which has models defined as they are specifically for the targeted model.\n */\n //\n else if (!plugin && models.length === 0) {\n plugin = pl;\n }\n }\n\n return plugin || defaultPlugin;\n};\n\ninterface Params {\n plugins: PluginsContainer;\n model: CmsModel;\n query: ElasticsearchBoolQueryConfig;\n term?: string;\n fields: CmsModelField[];\n}\nexport const applyFullTextSearch = (params: Params): void => {\n const { plugins, query, term, fields, model } = params;\n if (!term || term.length === 0 || fields.length === 0) {\n return;\n }\n\n const plugin = getPlugin({\n container: plugins,\n model\n });\n\n plugin.apply({\n model,\n createFieldPath: field => `values.${field.storageId}`,\n fields,\n query,\n term,\n prepareTerm: normalizeValue\n });\n};\n"],"mappings":"AACA,SAASA,cAAc,QAAQ,2BAA2B;AAG1D,SACIC,yCAAyC,EACzCC,+CAA+C;;AAGnD;AACA;AACA;AACA,MAAMC,aAAa,GAAGD,+CAA+C,CAAC;EAClEE,KAAK,EAAEC,MAAM,IAAI;IACb,MAAM;MAAEC,KAAK;MAAEC,IAAI;MAAEC,MAAM;MAAEC,eAAe;MAAEC;IAAY,CAAC,GAAGL,MAAM;IAEpEC,KAAK,CAACK,IAAI,CAACC,IAAI,CAAC;MACZC,YAAY,EAAE;QACVC,sBAAsB,EAAE,IAAI;QAC5BN,MAAM,EAAEA,MAAM,CAACO,GAAG,CAACN,eAAe,CAAC;QACnCH,KAAK,EAAE,IAAII,WAAW,CAACH,IAAI,CAAC,GAAG;QAC/BS,gBAAgB,EAAE;MACtB;IACJ,CAAC,CAAC;EACN;AACJ,CAAC,CAAC;AACFb,aAAa,CAACc,IAAI,GAAG,yDAAyD;AAM9E,MAAMC,SAAS,GAAIb,MAAuB,IAAgD;EACtF,MAAM;IAAEc,SAAS;IAAEC;EAAM,CAAC,GAAGf,MAAM;EACnC;AACJ;AACA;EACI,MAAMgB,OAAO,GAAGF,SAAS,CACpBG,MAAM,CACHrB,yCAAyC,CAACsB,IAC9C,CAAC,CACAC,OAAO,CAAC,CAAC;EACd;AACJ;AACA;AACA;EACI,IAAIC,MAAwD,GAAG,IAAI;EACnE,KAAK,MAAMC,EAAE,IAAIL,OAAO,EAAE;IACtB,MAAMM,MAAM,GAAGD,EAAE,CAACC,MAAM,IAAI,EAAE;IAC9B;AACR;AACA;IACQ,IAAIA,MAAM,CAACC,QAAQ,CAACR,KAAK,CAACS,OAAO,CAAC,EAAE;MAChC,OAAOH,EAAE;IACb;IACA;AACR;AACA;AACA;IACQ;IAAA,KACK,IAAI,CAACD,MAAM,IAAIE,MAAM,CAACG,MAAM,KAAK,CAAC,EAAE;MACrCL,MAAM,GAAGC,EAAE;IACf;EACJ;EAEA,OAAOD,MAAM,IAAItB,aAAa;AAClC,CAAC;AASD,OAAO,MAAM4B,mBAAmB,GAAI1B,MAAc,IAAW;EACzD,MAAM;IAAEgB,OAAO;IAAEf,KAAK;IAAEC,IAAI;IAAEC,MAAM;IAAEY;EAAM,CAAC,GAAGf,MAAM;EACtD,IAAI,CAACE,IAAI,IAAIA,IAAI,CAACuB,MAAM,KAAK,CAAC,IAAItB,MAAM,CAACsB,MAAM,KAAK,CAAC,EAAE;IACnD;EACJ;EAEA,MAAML,MAAM,GAAGP,SAAS,CAAC;IACrBC,SAAS,EAAEE,OAAO;IAClBD;EACJ,CAAC,CAAC;EAEFK,MAAM,CAACrB,KAAK,CAAC;IACTgB,KAAK;IACLX,eAAe,EAAEuB,KAAK,IAAI,UAAUA,KAAK,CAACC,SAAS,EAAE;IACrDzB,MAAM;IACNF,KAAK;IACLC,IAAI;IACJG,WAAW,EAAEV;EACjB,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import { CmsModel, CmsModelField } from "@webiny/api-headless-cms/types";
1
+ import type { CmsModel, CmsModelField } from "@webiny/api-headless-cms/types/index.js";
2
2
  interface Params {
3
3
  model: CmsModel;
4
4
  term?: string;
@@ -1,10 +1,4 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createFullTextSearchFields = void 0;
7
- const createFullTextSearchFields = params => {
1
+ export const createFullTextSearchFields = params => {
8
2
  const {
9
3
  term,
10
4
  model,
@@ -22,6 +16,5 @@ const createFullTextSearchFields = params => {
22
16
  return collection;
23
17
  }, []);
24
18
  };
25
- exports.createFullTextSearchFields = createFullTextSearchFields;
26
19
 
27
20
  //# sourceMappingURL=fullTextSearchFields.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createFullTextSearchFields","params","term","model","fields","length","trim","reduce","collection","fieldId","field","find","f","push","exports"],"sources":["fullTextSearchFields.ts"],"sourcesContent":["import { CmsModel, CmsModelField } from \"@webiny/api-headless-cms/types\";\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.trim().length === 0) {\n return [];\n }\n return fields.reduce<CmsModelField[]>((collection, fieldId) => {\n const field = model.fields.find(f => f.fieldId === fieldId);\n if (!field) {\n return collection;\n }\n collection.push(field);\n return collection;\n }, []);\n};\n"],"mappings":";;;;;;AAOO,MAAMA,0BAA0B,GAAIC,MAAc,IAAsB;EAC3E,MAAM;IAAEC,IAAI;IAAEC,KAAK;IAAEC;EAAO,CAAC,GAAGH,MAAM;EACtC,IAAI,CAACG,MAAM,IAAIA,MAAM,CAACC,MAAM,KAAK,CAAC,IAAI,CAACH,IAAI,IAAIA,IAAI,CAACI,IAAI,CAAC,CAAC,CAACD,MAAM,KAAK,CAAC,EAAE;IACrE,OAAO,EAAE;EACb;EACA,OAAOD,MAAM,CAACG,MAAM,CAAkB,CAACC,UAAU,EAAEC,OAAO,KAAK;IAC3D,MAAMC,KAAK,GAAGP,KAAK,CAACC,MAAM,CAACO,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACH,OAAO,KAAKA,OAAO,CAAC;IAC3D,IAAI,CAACC,KAAK,EAAE;MACR,OAAOF,UAAU;IACrB;IACAA,UAAU,CAACK,IAAI,CAACH,KAAK,CAAC;IACtB,OAAOF,UAAU;EACrB,CAAC,EAAE,EAAE,CAAC;AACV,CAAC;AAACM,OAAA,CAAAd,0BAAA,GAAAA,0BAAA","ignoreList":[]}
1
+ {"version":3,"names":["createFullTextSearchFields","params","term","model","fields","length","trim","reduce","collection","fieldId","field","find","f","push"],"sources":["fullTextSearchFields.ts"],"sourcesContent":["import type { CmsModel, CmsModelField } from \"@webiny/api-headless-cms/types/index.js\";\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.trim().length === 0) {\n return [];\n }\n return fields.reduce<CmsModelField[]>((collection, fieldId) => {\n const field = model.fields.find(f => f.fieldId === fieldId);\n if (!field) {\n return collection;\n }\n collection.push(field);\n return collection;\n }, []);\n};\n"],"mappings":"AAOA,OAAO,MAAMA,0BAA0B,GAAIC,MAAc,IAAsB;EAC3E,MAAM;IAAEC,IAAI;IAAEC,KAAK;IAAEC;EAAO,CAAC,GAAGH,MAAM;EACtC,IAAI,CAACG,MAAM,IAAIA,MAAM,CAACC,MAAM,KAAK,CAAC,IAAI,CAACH,IAAI,IAAIA,IAAI,CAACI,IAAI,CAAC,CAAC,CAACD,MAAM,KAAK,CAAC,EAAE;IACrE,OAAO,EAAE;EACb;EACA,OAAOD,MAAM,CAACG,MAAM,CAAkB,CAACC,UAAU,EAAEC,OAAO,KAAK;IAC3D,MAAMC,KAAK,GAAGP,KAAK,CAACC,MAAM,CAACO,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACH,OAAO,KAAKA,OAAO,CAAC;IAC3D,IAAI,CAACC,KAAK,EAAE;MACR,OAAOF,UAAU;IACrB;IACAA,UAAU,CAACK,IAAI,CAACH,KAAK,CAAC;IACtB,OAAOF,UAAU;EACrB,CAAC,EAAE,EAAE,CAAC;AACV,CAAC","ignoreList":[]}
@@ -1,5 +1,5 @@
1
- import { ElasticsearchBoolQueryConfig } from "@webiny/api-elasticsearch/types";
2
- import { CmsEntryListWhere, CmsModel } from "@webiny/api-headless-cms/types";
1
+ import type { ElasticsearchBoolQueryConfig } from "@webiny/api-elasticsearch/types.js";
2
+ import type { CmsEntryListWhere, CmsModel } from "@webiny/api-headless-cms/types/index.js";
3
3
  export declare const createBaseQuery: () => ElasticsearchBoolQueryConfig;
4
4
  interface Params {
5
5
  model: CmsModel;
@@ -1,13 +1,7 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.createInitialQuery = exports.createBaseQuery = void 0;
8
- var _error = _interopRequireDefault(require("@webiny/error"));
9
- var _recordType = require("../recordType");
10
- const createBaseQuery = () => {
1
+ import WebinyError from "@webiny/error";
2
+ import { createLatestRecordType, createPublishedRecordType } from "../recordType.js";
3
+ import { isSharedElasticsearchIndex } from "@webiny/api-elasticsearch";
4
+ export const createBaseQuery = () => {
11
5
  return {
12
6
  must: [],
13
7
  must_not: [],
@@ -15,7 +9,6 @@ const createBaseQuery = () => {
15
9
  filter: []
16
10
  };
17
11
  };
18
- exports.createBaseQuery = createBaseQuery;
19
12
  /**
20
13
  * Latest and published are specific in Elasticsearch to that extend that they are tagged in the __type property.
21
14
  * We allow either published or either latest.
@@ -24,7 +17,7 @@ exports.createBaseQuery = createBaseQuery;
24
17
  *
25
18
  * We add the query.filter terms because we do not need scored search here and it is a bit faster.
26
19
  */
27
- const createInitialQuery = params => {
20
+ export const createInitialQuery = params => {
28
21
  const {
29
22
  model,
30
23
  where
@@ -36,7 +29,7 @@ const createInitialQuery = params => {
36
29
  *
37
30
  * TODO determine if we want to search across tenants in shared index?
38
31
  */
39
- const sharedIndex = process.env.ELASTICSEARCH_SHARED_INDEXES === "true";
32
+ const sharedIndex = isSharedElasticsearchIndex();
40
33
  if (sharedIndex) {
41
34
  /**
42
35
  * Tenant for the filtering is taken from the model.
@@ -56,15 +49,6 @@ const createInitialQuery = params => {
56
49
  "modelId.keyword": model.modelId
57
50
  }
58
51
  });
59
- /**
60
- * TODO determine if we want to search across locales?
61
- * This search would anyway work for a single model and when sharing index.
62
- */
63
- query.filter.push({
64
- term: {
65
- "locale.keyword": model.locale
66
- }
67
- });
68
52
  }
69
53
 
70
54
  /**
@@ -73,13 +57,13 @@ const createInitialQuery = params => {
73
57
  if (where.published === true) {
74
58
  query.filter.push({
75
59
  term: {
76
- "__type.keyword": (0, _recordType.createPublishedRecordType)()
60
+ "__type.keyword": createPublishedRecordType()
77
61
  }
78
62
  });
79
63
  } else if (where.latest === true) {
80
64
  query.filter.push({
81
65
  term: {
82
- "__type.keyword": (0, _recordType.createLatestRecordType)()
66
+ "__type.keyword": createLatestRecordType()
83
67
  }
84
68
  });
85
69
  }
@@ -88,7 +72,7 @@ const createInitialQuery = params => {
88
72
  * We do not allow filtering without the published or latest parameter.
89
73
  * Also, we do not want to set the default one, as there is a large possibility for user error when filtering.
90
74
  */else {
91
- throw new _error.default(`Cannot call Elasticsearch query when not setting "published" or "latest".`, "ELASTICSEARCH_UNSUPPORTED_QUERY", {
75
+ throw new WebinyError(`Cannot call Elasticsearch query when not setting "published" or "latest".`, "OPENSEARCH_UNSUPPORTED_QUERY", {
92
76
  where
93
77
  });
94
78
  }
@@ -100,6 +84,5 @@ const createInitialQuery = params => {
100
84
  delete where.latest;
101
85
  return query;
102
86
  };
103
- exports.createInitialQuery = createInitialQuery;
104
87
 
105
88
  //# sourceMappingURL=initialQuery.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_error","_interopRequireDefault","require","_recordType","createBaseQuery","must","must_not","should","filter","exports","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,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAAAC,WAAA,GAAAD,OAAA;AAEO,MAAME,eAAe,GAAGA,CAAA,KAAoC;EAC/D,OAAO;IACHC,IAAI,EAAE,EAAE;IACRC,QAAQ,EAAE,EAAE;IACZC,MAAM,EAAE,EAAE;IACVC,MAAM,EAAE;EACZ,CAAC;AACL,CAAC;AAACC,OAAA,CAAAL,eAAA,GAAAA,eAAA;AAMF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMM,kBAAkB,GAAIC,MAAc,IAAmC;EAChF,MAAM;IAAEC,KAAK;IAAEC;EAAM,CAAC,GAAGF,MAAM;EAE/B,MAAMG,KAAK,GAAGV,eAAe,CAAC,CAAC;;EAE/B;AACJ;AACA;AACA;AACA;EACI,MAAMW,WAAW,GAAGC,OAAO,CAACC,GAAG,CAACC,4BAA4B,KAAK,MAAM;EACvE,IAAIH,WAAW,EAAE;IACb;AACR;AACA;AACA;AACA;IACQD,KAAK,CAACN,MAAM,CAACW,IAAI,CAAC;MACdC,IAAI,EAAE;QACF,gBAAgB,EAAER,KAAK,CAACS;MAC5B;IACJ,CAAC,CAAC;IACF;AACR;AACA;IACQP,KAAK,CAACN,MAAM,CAACW,IAAI,CAAC;MACdC,IAAI,EAAE;QACF,iBAAiB,EAAER,KAAK,CAACU;MAC7B;IACJ,CAAC,CAAC;IACF;AACR;AACA;AACA;IACQR,KAAK,CAACN,MAAM,CAACW,IAAI,CAAC;MACdC,IAAI,EAAE;QACF,gBAAgB,EAAER,KAAK,CAACW;MAC5B;IACJ,CAAC,CAAC;EACN;;EAEA;AACJ;AACA;EACI,IAAIV,KAAK,CAACW,SAAS,KAAK,IAAI,EAAE;IAC1BV,KAAK,CAACN,MAAM,CAACW,IAAI,CAAC;MACdC,IAAI,EAAE;QACF,gBAAgB,EAAE,IAAAK,qCAAyB,EAAC;MAChD;IACJ,CAAC,CAAC;EACN,CAAC,MAAM,IAAIZ,KAAK,CAACa,MAAM,KAAK,IAAI,EAAE;IAC9BZ,KAAK,CAACN,MAAM,CAACW,IAAI,CAAC;MACdC,IAAI,EAAE;QACF,gBAAgB,EAAE,IAAAO,kCAAsB,EAAC;MAC7C;IACJ,CAAC,CAAC;EACN;EACA;EACA;AACJ;AACA;AACA,KAHI,KAIK;IACD,MAAM,IAAIC,cAAW,CAChB,2EAA0E,EAC3E,iCAAiC,EACjC;MACIf;IACJ,CACJ,CAAC;EACL;EACA;AACJ;AACA;AACA;EACI,OAAOA,KAAK,CAACW,SAAS;EACtB,OAAOX,KAAK,CAACa,MAAM;EAEnB,OAAOZ,KAAK;AAChB,CAAC;AAACL,OAAA,CAAAC,kBAAA,GAAAA,kBAAA","ignoreList":[]}
1
+ {"version":3,"names":["WebinyError","createLatestRecordType","createPublishedRecordType","isSharedElasticsearchIndex","createBaseQuery","must","must_not","should","filter","createInitialQuery","params","model","where","query","sharedIndex","push","term","tenant","modelId","published","latest"],"sources":["initialQuery.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { ElasticsearchBoolQueryConfig } from \"@webiny/api-elasticsearch/types.js\";\nimport type { CmsEntryListWhere, CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\nimport { createLatestRecordType, createPublishedRecordType } from \"../recordType.js\";\nimport { isSharedElasticsearchIndex } from \"@webiny/api-elasticsearch\";\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 = isSharedElasticsearchIndex();\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\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 \"OPENSEARCH_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,OAAOA,WAAW,MAAM,eAAe;AAGvC,SAASC,sBAAsB,EAAEC,yBAAyB;AAC1D,SAASC,0BAA0B,QAAQ,2BAA2B;AAEtE,OAAO,MAAMC,eAAe,GAAGA,CAAA,KAAoC;EAC/D,OAAO;IACHC,IAAI,EAAE,EAAE;IACRC,QAAQ,EAAE,EAAE;IACZC,MAAM,EAAE,EAAE;IACVC,MAAM,EAAE;EACZ,CAAC;AACL,CAAC;AAMD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,kBAAkB,GAAIC,MAAc,IAAmC;EAChF,MAAM;IAAEC,KAAK;IAAEC;EAAM,CAAC,GAAGF,MAAM;EAE/B,MAAMG,KAAK,GAAGT,eAAe,CAAC,CAAC;;EAE/B;AACJ;AACA;AACA;AACA;EACI,MAAMU,WAAW,GAAGX,0BAA0B,CAAC,CAAC;EAChD,IAAIW,WAAW,EAAE;IACb;AACR;AACA;AACA;AACA;IACQD,KAAK,CAACL,MAAM,CAACO,IAAI,CAAC;MACdC,IAAI,EAAE;QACF,gBAAgB,EAAEL,KAAK,CAACM;MAC5B;IACJ,CAAC,CAAC;IACF;AACR;AACA;IACQJ,KAAK,CAACL,MAAM,CAACO,IAAI,CAAC;MACdC,IAAI,EAAE;QACF,iBAAiB,EAAEL,KAAK,CAACO;MAC7B;IACJ,CAAC,CAAC;EACN;;EAEA;AACJ;AACA;EACI,IAAIN,KAAK,CAACO,SAAS,KAAK,IAAI,EAAE;IAC1BN,KAAK,CAACL,MAAM,CAACO,IAAI,CAAC;MACdC,IAAI,EAAE;QACF,gBAAgB,EAAEd,yBAAyB,CAAC;MAChD;IACJ,CAAC,CAAC;EACN,CAAC,MAAM,IAAIU,KAAK,CAACQ,MAAM,KAAK,IAAI,EAAE;IAC9BP,KAAK,CAACL,MAAM,CAACO,IAAI,CAAC;MACdC,IAAI,EAAE;QACF,gBAAgB,EAAEf,sBAAsB,CAAC;MAC7C;IACJ,CAAC,CAAC;EACN;EACA;EACA;AACJ;AACA;AACA,KAHI,KAIK;IACD,MAAM,IAAID,WAAW,CACjB,2EAA2E,EAC3E,8BAA8B,EAC9B;MACIY;IACJ,CACJ,CAAC;EACL;EACA;AACJ;AACA;AACA;EACI,OAAOA,KAAK,CAACO,SAAS;EACtB,OAAOP,KAAK,CAACQ,MAAM;EAEnB,OAAOP,KAAK;AAChB,CAAC","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- import { ModelField } from "./types";
1
+ import type { ModelField } from "./types.js";
2
2
  export declare const hasKeyword: (field: ModelField) => boolean;
@@ -1,15 +1,11 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.hasKeyword = void 0;
1
+ import { getBaseFieldType } from "@webiny/api-headless-cms/utils/getBaseFieldType.js";
7
2
  const noKeywordFields = ["date", "datetime", "number", "boolean"];
8
- const hasKeyword = field => {
3
+ export const hasKeyword = field => {
4
+ const fieldType = getBaseFieldType(field);
9
5
  /**
10
6
  * We defined some field types that MUST have no keyword added to the field path
11
7
  */
12
- if (noKeywordFields.includes(field.type)) {
8
+ if (noKeywordFields.includes(fieldType)) {
13
9
  return false;
14
10
  }
15
11
  /**
@@ -31,6 +27,5 @@ const hasKeyword = field => {
31
27
  */
32
28
  return true;
33
29
  };
34
- exports.hasKeyword = hasKeyword;
35
30
 
36
31
  //# sourceMappingURL=keyword.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["noKeywordFields","hasKeyword","field","includes","type","unmappedType","keyword","exports"],"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,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,CAAC;AACpE,MAAMC,UAAU,GAAIC,KAAiB,IAAc;EACtD;AACJ;AACA;EACI,IAAIF,eAAe,CAACG,QAAQ,CAACD,KAAK,CAACE,IAAI,CAAC,EAAE;IACtC,OAAO,KAAK;EAChB;EACA;AACJ;AACA;EACI;EAAA,KACK,IAAIF,KAAK,CAACG,YAAY,EAAE;IACzB,OAAO,KAAK;EAChB;EACA;AACJ;AACA;EACI;EAAA,KACK,IAAIH,KAAK,CAACI,OAAO,KAAK,KAAK,EAAE;IAC9B,OAAO,KAAK;EAChB;EACA;AACJ;AACA;EACI,OAAO,IAAI;AACf,CAAC;AAACC,OAAA,CAAAN,UAAA,GAAAA,UAAA","ignoreList":[]}
1
+ {"version":3,"names":["getBaseFieldType","noKeywordFields","hasKeyword","field","fieldType","includes","unmappedType","keyword"],"sources":["keyword.ts"],"sourcesContent":["import type { ModelField } from \"./types.js\";\nimport { getBaseFieldType } from \"@webiny/api-headless-cms/utils/getBaseFieldType.js\";\n\nconst noKeywordFields: string[] = [\"date\", \"datetime\", \"number\", \"boolean\"];\nexport const hasKeyword = (field: ModelField): boolean => {\n const fieldType = getBaseFieldType(field);\n /**\n * We defined some field types that MUST have no keyword added to the field path\n */\n if (noKeywordFields.includes(fieldType)) {\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":"AACA,SAASA,gBAAgB,QAAQ,oDAAoD;AAErF,MAAMC,eAAyB,GAAG,CAAC,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,CAAC;AAC3E,OAAO,MAAMC,UAAU,GAAIC,KAAiB,IAAc;EACtD,MAAMC,SAAS,GAAGJ,gBAAgB,CAACG,KAAK,CAAC;EACzC;AACJ;AACA;EACI,IAAIF,eAAe,CAACI,QAAQ,CAACD,SAAS,CAAC,EAAE;IACrC,OAAO,KAAK;EAChB;EACA;AACJ;AACA;EACI;EAAA,KACK,IAAID,KAAK,CAACG,YAAY,EAAE;IACzB,OAAO,KAAK;EAChB;EACA;AACJ;AACA;EACI;EAAA,KACK,IAAIH,KAAK,CAACI,OAAO,KAAK,KAAK,EAAE;IAC9B,OAAO,KAAK;EAChB;EACA;AACJ;AACA;EACI,OAAO,IAAI;AACf,CAAC","ignoreList":[]}
@@ -1,9 +1,9 @@
1
- import { CmsEntryElasticsearchBodyModifierPlugin } from "../../../../plugins";
2
- import { PluginsContainer } from "@webiny/plugins";
3
- import { CmsModel } from "@webiny/api-headless-cms/types";
1
+ import { CmsEntryElasticsearchBodyModifierPlugin } from "../../../../plugins/index.js";
2
+ import type { PluginsContainer } from "@webiny/plugins";
3
+ import type { CmsModel } from "@webiny/api-headless-cms/types/index.js";
4
4
  interface Params {
5
5
  plugins: PluginsContainer;
6
6
  model: CmsModel;
7
7
  }
8
- export declare const createBodyModifierPluginList: ({ plugins, model }: Params) => CmsEntryElasticsearchBodyModifierPlugin[];
8
+ export declare const createBodyModifierPluginList: ({ plugins, model }: Params) => import("@webiny/plugins/PluginsContainer").WithName<CmsEntryElasticsearchBodyModifierPlugin>[];
9
9
  export {};
@@ -1,18 +1,11 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createBodyModifierPluginList = void 0;
7
- var _plugins = require("../../../../plugins");
8
- const createBodyModifierPluginList = ({
1
+ import { CmsEntryElasticsearchBodyModifierPlugin } from "../../../../plugins/index.js";
2
+ export const createBodyModifierPluginList = ({
9
3
  plugins,
10
4
  model
11
5
  }) => {
12
- return plugins.byType(_plugins.CmsEntryElasticsearchBodyModifierPlugin.type).filter(pl => {
6
+ return plugins.byType(CmsEntryElasticsearchBodyModifierPlugin.type).filter(pl => {
13
7
  return !pl.modelId || pl.modelId === model.modelId;
14
8
  });
15
9
  };
16
- exports.createBodyModifierPluginList = createBodyModifierPluginList;
17
10
 
18
11
  //# sourceMappingURL=bodyModifier.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_plugins","require","createBodyModifierPluginList","plugins","model","byType","CmsEntryElasticsearchBodyModifierPlugin","type","filter","pl","modelId","exports"],"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,IAAAA,QAAA,GAAAC,OAAA;AAQO,MAAMC,4BAA4B,GAAGA,CAAC;EAAEC,OAAO;EAAEC;AAAc,CAAC,KAAK;EACxE,OAAOD,OAAO,CACTE,MAAM,CACHC,gDAAuC,CAACC,IAC5C,CAAC,CACAC,MAAM,CAACC,EAAE,IAAI;IACV,OAAO,CAACA,EAAE,CAACC,OAAO,IAAID,EAAE,CAACC,OAAO,KAAKN,KAAK,CAACM,OAAO;EACtD,CAAC,CAAC;AACV,CAAC;AAACC,OAAA,CAAAT,4BAAA,GAAAA,4BAAA","ignoreList":[]}
1
+ {"version":3,"names":["CmsEntryElasticsearchBodyModifierPlugin","createBodyModifierPluginList","plugins","model","byType","type","filter","pl","modelId"],"sources":["bodyModifier.ts"],"sourcesContent":["import { CmsEntryElasticsearchBodyModifierPlugin } from \"~/plugins/index.js\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\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,SAASA,uCAAuC;AAQhD,OAAO,MAAMC,4BAA4B,GAAGA,CAAC;EAAEC,OAAO;EAAEC;AAAc,CAAC,KAAK;EACxE,OAAOD,OAAO,CACTE,MAAM,CACHJ,uCAAuC,CAACK,IAC5C,CAAC,CACAC,MAAM,CAACC,EAAE,IAAI;IACV,OAAO,CAACA,EAAE,CAACC,OAAO,IAAID,EAAE,CAACC,OAAO,KAAKL,KAAK,CAACK,OAAO;EACtD,CAAC,CAAC;AACV,CAAC","ignoreList":[]}
@@ -1,8 +1,7 @@
1
- import { PluginsContainer } from "@webiny/plugins";
2
- import { ElasticsearchQueryBuilderOperatorPlugins } from "../types";
1
+ import type { PluginsContainer } from "@webiny/plugins";
2
+ import type { ElasticsearchQueryBuilderOperatorPlugins } from "../types.js";
3
3
  interface Params {
4
4
  plugins: PluginsContainer;
5
- locale: string;
6
5
  }
7
6
  export declare const createOperatorPluginList: (params: Params) => ElasticsearchQueryBuilderOperatorPlugins;
8
7
  export {};
@@ -1,28 +1,14 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createOperatorPluginList = void 0;
7
- var _apiElasticsearch = require("@webiny/api-elasticsearch");
8
- const createOperatorPluginList = params => {
1
+ import { ElasticsearchQueryBuilderOperatorPlugin } from "@webiny/api-elasticsearch";
2
+ export const createOperatorPluginList = params => {
9
3
  const {
10
- plugins,
11
- locale
4
+ plugins
12
5
  } = params;
13
6
  /**
14
7
  * We always set the last one operator plugin added.
15
8
  * This way user can override the plugins.
16
9
  */
17
- return plugins.byType(_apiElasticsearch.ElasticsearchQueryBuilderOperatorPlugin.type).reduce((acc, plugin) => {
10
+ return plugins.byType(ElasticsearchQueryBuilderOperatorPlugin.type).reduce((acc, plugin) => {
18
11
  const operator = plugin.getOperator();
19
- /**
20
- * We only allow the plugins which can pass the locale test.
21
- * The default plugins always return true.
22
- */
23
- if (plugin.isLocaleSupported(locale) === false) {
24
- return acc;
25
- }
26
12
  /**
27
13
  * We also only allow the override of the plugins if the new plugin is NOT a default one.
28
14
  * If a user sets the plugin name ending with .default, we cannot do anything about it.
@@ -34,6 +20,5 @@ const createOperatorPluginList = params => {
34
20
  return acc;
35
21
  }, {});
36
22
  };
37
- exports.createOperatorPluginList = createOperatorPluginList;
38
23
 
39
24
  //# sourceMappingURL=operator.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_apiElasticsearch","require","createOperatorPluginList","params","plugins","locale","byType","ElasticsearchQueryBuilderOperatorPlugin","type","reduce","acc","plugin","operator","getOperator","isLocaleSupported","name","match","exports"],"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,IAAAA,iBAAA,GAAAC,OAAA;AAOO,MAAMC,wBAAwB,GACjCC,MAAc,IAC6B;EAC3C,MAAM;IAAEC,OAAO;IAAEC;EAAO,CAAC,GAAGF,MAAM;EAClC;AACJ;AACA;AACA;EACI,OAAOC,OAAO,CACTE,MAAM,CACHC,yDAAuC,CAACC,IAC5C,CAAC,CACAC,MAAM,CAA2C,CAACC,GAAG,EAAEC,MAAM,KAAK;IAC/D,MAAMC,QAAQ,GAAGD,MAAM,CAACE,WAAW,CAAC,CAAC;IACrC;AACZ;AACA;AACA;IACY,IAAIF,MAAM,CAACG,iBAAiB,CAACT,MAAM,CAAC,KAAK,KAAK,EAAE;MAC5C,OAAOK,GAAG;IACd;IACA;AACZ;AACA;AACA;IACY,IAAI,CAAC,CAACA,GAAG,CAACE,QAAQ,CAAC,IAAI,CAACD,MAAM,CAACI,IAAI,IAAI,EAAE,EAAEC,KAAK,CAAC,YAAY,CAAC,EAAE;MAC5D,OAAON,GAAG;IACd;IACAA,GAAG,CAACE,QAAQ,CAAC,GAAGD,MAAM;IACtB,OAAOD,GAAG;EACd,CAAC,EAAE,CAAC,CAAC,CAAC;AACd,CAAC;AAACO,OAAA,CAAAf,wBAAA,GAAAA,wBAAA","ignoreList":[]}
1
+ {"version":3,"names":["ElasticsearchQueryBuilderOperatorPlugin","createOperatorPluginList","params","plugins","byType","type","reduce","acc","plugin","operator","getOperator","name","match"],"sources":["operator.ts"],"sourcesContent":["import type { PluginsContainer } from \"@webiny/plugins\";\nimport { ElasticsearchQueryBuilderOperatorPlugin } from \"@webiny/api-elasticsearch\";\nimport type { ElasticsearchQueryBuilderOperatorPlugins } from \"../types.js\";\n\ninterface Params {\n plugins: PluginsContainer;\n}\nexport const createOperatorPluginList = (\n params: Params\n): ElasticsearchQueryBuilderOperatorPlugins => {\n const { plugins } = 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 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,SAASA,uCAAuC,QAAQ,2BAA2B;AAMnF,OAAO,MAAMC,wBAAwB,GACjCC,MAAc,IAC6B;EAC3C,MAAM;IAAEC;EAAQ,CAAC,GAAGD,MAAM;EAC1B;AACJ;AACA;AACA;EACI,OAAOC,OAAO,CACTC,MAAM,CACHJ,uCAAuC,CAACK,IAC5C,CAAC,CACAC,MAAM,CAA2C,CAACC,GAAG,EAAEC,MAAM,KAAK;IAC/D,MAAMC,QAAQ,GAAGD,MAAM,CAACE,WAAW,CAAC,CAAC;IACrC;AACZ;AACA;AACA;IACY,IAAI,CAAC,CAACH,GAAG,CAACE,QAAQ,CAAC,IAAI,CAACD,MAAM,CAACG,IAAI,IAAI,EAAE,EAAEC,KAAK,CAAC,YAAY,CAAC,EAAE;MAC5D,OAAOL,GAAG;IACd;IACAA,GAAG,CAACE,QAAQ,CAAC,GAAGD,MAAM;IACtB,OAAOD,GAAG;EACd,CAAC,EAAE,CAAC,CAAC,CAAC;AACd,CAAC","ignoreList":[]}