@webiny/api-headless-cms-ddb-es 0.0.0-unstable.b14eaecf38 → 0.0.0-unstable.b6d7105cee

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 (433) hide show
  1. package/README.md +6 -30
  2. package/configurations.d.ts +20 -10
  3. package/configurations.js +34 -32
  4. package/configurations.js.map +1 -1
  5. package/definitions/entry.d.ts +4 -5
  6. package/definitions/entry.js +10 -87
  7. package/definitions/entry.js.map +1 -1
  8. package/definitions/group.d.ts +6 -6
  9. package/definitions/group.js +10 -64
  10. package/definitions/group.js.map +1 -1
  11. package/definitions/model.d.ts +6 -6
  12. package/definitions/model.js +10 -108
  13. package/definitions/model.js.map +1 -1
  14. package/definitions/types.d.ts +65 -0
  15. package/definitions/types.js +0 -0
  16. package/elasticsearch/createElasticsearchIndex.d.ts +6 -6
  17. package/elasticsearch/createElasticsearchIndex.js +42 -46
  18. package/elasticsearch/createElasticsearchIndex.js.map +1 -1
  19. package/elasticsearch/deleteElasticsearchIndex.d.ts +6 -4
  20. package/elasticsearch/deleteElasticsearchIndex.js +21 -34
  21. package/elasticsearch/deleteElasticsearchIndex.js.map +1 -1
  22. package/exports/api/cms/opensearch.d.ts +9 -0
  23. package/exports/api/cms/opensearch.js +9 -0
  24. package/feature.d.ts +1 -0
  25. package/feature.js +201 -0
  26. package/feature.js.map +1 -0
  27. package/features/CmsEntryOpenSearchBodyModifier/abstractions.d.ts +16 -0
  28. package/features/CmsEntryOpenSearchBodyModifier/abstractions.js +5 -0
  29. package/features/CmsEntryOpenSearchBodyModifier/abstractions.js.map +1 -0
  30. package/features/CmsEntryOpenSearchBodyModifier/index.d.ts +1 -0
  31. package/features/CmsEntryOpenSearchBodyModifier/index.js +1 -0
  32. package/features/CmsEntryOpenSearchFieldIndex/CmsEntryOpenSearchFieldIndexRegistry.d.ts +14 -0
  33. package/features/CmsEntryOpenSearchFieldIndex/CmsEntryOpenSearchFieldIndexRegistry.js +42 -0
  34. package/features/CmsEntryOpenSearchFieldIndex/CmsEntryOpenSearchFieldIndexRegistry.js.map +1 -0
  35. package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndex.d.ts +32 -0
  36. package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndex.js +5 -0
  37. package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndex.js.map +1 -0
  38. package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndexRegistry.d.ts +11 -0
  39. package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndexRegistry.js +5 -0
  40. package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndexRegistry.js.map +1 -0
  41. package/features/CmsEntryOpenSearchFieldIndex/constants.d.ts +1 -0
  42. package/features/CmsEntryOpenSearchFieldIndex/constants.js +4 -0
  43. package/features/CmsEntryOpenSearchFieldIndex/constants.js.map +1 -0
  44. package/features/CmsEntryOpenSearchFieldIndex/feature.d.ts +4 -0
  45. package/features/CmsEntryOpenSearchFieldIndex/feature.js +29 -0
  46. package/features/CmsEntryOpenSearchFieldIndex/feature.js.map +1 -0
  47. package/features/CmsEntryOpenSearchFieldIndex/fields/DateTimeFieldIndex.d.ts +11 -0
  48. package/features/CmsEntryOpenSearchFieldIndex/fields/DateTimeFieldIndex.js +60 -0
  49. package/features/CmsEntryOpenSearchFieldIndex/fields/DateTimeFieldIndex.js.map +1 -0
  50. package/features/CmsEntryOpenSearchFieldIndex/fields/DefaultFieldIndex.d.ts +13 -0
  51. package/features/CmsEntryOpenSearchFieldIndex/fields/DefaultFieldIndex.js +33 -0
  52. package/features/CmsEntryOpenSearchFieldIndex/fields/DefaultFieldIndex.js.map +1 -0
  53. package/features/CmsEntryOpenSearchFieldIndex/fields/JsonFieldIndex.d.ts +10 -0
  54. package/features/CmsEntryOpenSearchFieldIndex/fields/JsonFieldIndex.js +21 -0
  55. package/features/CmsEntryOpenSearchFieldIndex/fields/JsonFieldIndex.js.map +1 -0
  56. package/features/CmsEntryOpenSearchFieldIndex/fields/LongTextFieldIndex.d.ts +10 -0
  57. package/features/CmsEntryOpenSearchFieldIndex/fields/LongTextFieldIndex.js +22 -0
  58. package/features/CmsEntryOpenSearchFieldIndex/fields/LongTextFieldIndex.js.map +1 -0
  59. package/features/CmsEntryOpenSearchFieldIndex/fields/NumberFieldIndex.d.ts +11 -0
  60. package/features/CmsEntryOpenSearchFieldIndex/fields/NumberFieldIndex.js +32 -0
  61. package/features/CmsEntryOpenSearchFieldIndex/fields/NumberFieldIndex.js.map +1 -0
  62. package/features/CmsEntryOpenSearchFieldIndex/fields/ObjectFieldIndex.d.ts +12 -0
  63. package/features/CmsEntryOpenSearchFieldIndex/fields/ObjectFieldIndex.js +107 -0
  64. package/features/CmsEntryOpenSearchFieldIndex/fields/ObjectFieldIndex.js.map +1 -0
  65. package/features/CmsEntryOpenSearchFieldIndex/fields/RichTextFieldIndex.d.ts +10 -0
  66. package/features/CmsEntryOpenSearchFieldIndex/fields/RichTextFieldIndex.js +21 -0
  67. package/features/CmsEntryOpenSearchFieldIndex/fields/RichTextFieldIndex.js.map +1 -0
  68. package/features/CmsEntryOpenSearchFieldIndex/fields/TextCompressedFieldIndex.d.ts +15 -0
  69. package/features/CmsEntryOpenSearchFieldIndex/fields/TextCompressedFieldIndex.js +40 -0
  70. package/features/CmsEntryOpenSearchFieldIndex/fields/TextCompressedFieldIndex.js.map +1 -0
  71. package/features/CmsEntryOpenSearchFieldIndex/fields/TextEncryptedFieldIndex.d.ts +15 -0
  72. package/features/CmsEntryOpenSearchFieldIndex/fields/TextEncryptedFieldIndex.js +40 -0
  73. package/features/CmsEntryOpenSearchFieldIndex/fields/TextEncryptedFieldIndex.js.map +1 -0
  74. package/features/CmsEntryOpenSearchFieldIndex/index.d.ts +3 -0
  75. package/features/CmsEntryOpenSearchFieldIndex/index.js +3 -0
  76. package/features/CmsEntryOpenSearchFilter/CmsEntryOpenSearchFilterRegistry.d.ts +11 -0
  77. package/features/CmsEntryOpenSearchFilter/CmsEntryOpenSearchFilterRegistry.js +36 -0
  78. package/features/CmsEntryOpenSearchFilter/CmsEntryOpenSearchFilterRegistry.js.map +1 -0
  79. package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilter.d.ts +37 -0
  80. package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilter.js +5 -0
  81. package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilter.js.map +1 -0
  82. package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilterRegistry.d.ts +9 -0
  83. package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilterRegistry.js +5 -0
  84. package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilterRegistry.js.map +1 -0
  85. package/features/CmsEntryOpenSearchFilter/constants.d.ts +1 -0
  86. package/features/CmsEntryOpenSearchFilter/constants.js +4 -0
  87. package/features/CmsEntryOpenSearchFilter/constants.js.map +1 -0
  88. package/features/CmsEntryOpenSearchFilter/feature.d.ts +4 -0
  89. package/features/CmsEntryOpenSearchFilter/feature.js +17 -0
  90. package/features/CmsEntryOpenSearchFilter/feature.js.map +1 -0
  91. package/features/CmsEntryOpenSearchFilter/fields/DefaultFilter.d.ts +9 -0
  92. package/features/CmsEntryOpenSearchFilter/fields/DefaultFilter.js +26 -0
  93. package/features/CmsEntryOpenSearchFilter/fields/DefaultFilter.js.map +1 -0
  94. package/features/CmsEntryOpenSearchFilter/fields/ObjectFilter.d.ts +9 -0
  95. package/features/CmsEntryOpenSearchFilter/fields/ObjectFilter.js +43 -0
  96. package/features/CmsEntryOpenSearchFilter/fields/ObjectFilter.js.map +1 -0
  97. package/features/CmsEntryOpenSearchFilter/fields/RefFilter.d.ts +9 -0
  98. package/features/CmsEntryOpenSearchFilter/fields/RefFilter.js +36 -0
  99. package/features/CmsEntryOpenSearchFilter/fields/RefFilter.js.map +1 -0
  100. package/features/CmsEntryOpenSearchFilter/index.d.ts +3 -0
  101. package/features/CmsEntryOpenSearchFilter/index.js +3 -0
  102. package/features/CmsEntryOpenSearchFullTextSearch/abstractions.d.ts +20 -0
  103. package/features/CmsEntryOpenSearchFullTextSearch/abstractions.js +5 -0
  104. package/features/CmsEntryOpenSearchFullTextSearch/abstractions.js.map +1 -0
  105. package/features/CmsEntryOpenSearchFullTextSearch/index.d.ts +1 -0
  106. package/features/CmsEntryOpenSearchFullTextSearch/index.js +1 -0
  107. package/features/CmsEntryOpenSearchQueryModifier/abstractions.d.ts +16 -0
  108. package/features/CmsEntryOpenSearchQueryModifier/abstractions.js +5 -0
  109. package/features/CmsEntryOpenSearchQueryModifier/abstractions.js.map +1 -0
  110. package/features/CmsEntryOpenSearchQueryModifier/index.d.ts +1 -0
  111. package/features/CmsEntryOpenSearchQueryModifier/index.js +1 -0
  112. package/features/CmsEntryOpenSearchSortModifier/abstractions.d.ts +15 -0
  113. package/features/CmsEntryOpenSearchSortModifier/abstractions.js +5 -0
  114. package/features/CmsEntryOpenSearchSortModifier/abstractions.js.map +1 -0
  115. package/features/CmsEntryOpenSearchSortModifier/index.d.ts +1 -0
  116. package/features/CmsEntryOpenSearchSortModifier/index.js +1 -0
  117. package/features/CmsEntryOpenSearchValueSearch/CmsEntryOpenSearchValueSearchRegistry.d.ts +12 -0
  118. package/features/CmsEntryOpenSearchValueSearch/CmsEntryOpenSearchValueSearchRegistry.js +31 -0
  119. package/features/CmsEntryOpenSearchValueSearch/CmsEntryOpenSearchValueSearchRegistry.js.map +1 -0
  120. package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearch.d.ts +22 -0
  121. package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearch.js +5 -0
  122. package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearch.js.map +1 -0
  123. package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearchRegistry.d.ts +10 -0
  124. package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearchRegistry.js +5 -0
  125. package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearchRegistry.js.map +1 -0
  126. package/features/CmsEntryOpenSearchValueSearch/feature.d.ts +4 -0
  127. package/features/CmsEntryOpenSearchValueSearch/feature.js +17 -0
  128. package/features/CmsEntryOpenSearchValueSearch/feature.js.map +1 -0
  129. package/features/CmsEntryOpenSearchValueSearch/fields/RefSearch.d.ts +10 -0
  130. package/features/CmsEntryOpenSearchValueSearch/fields/RefSearch.js +21 -0
  131. package/features/CmsEntryOpenSearchValueSearch/fields/RefSearch.js.map +1 -0
  132. package/features/CmsEntryOpenSearchValueSearch/fields/SearchableJsonSearch.d.ts +10 -0
  133. package/features/CmsEntryOpenSearchValueSearch/fields/SearchableJsonSearch.js +44 -0
  134. package/features/CmsEntryOpenSearchValueSearch/fields/SearchableJsonSearch.js.map +1 -0
  135. package/features/CmsEntryOpenSearchValueSearch/fields/TimeSearch.d.ts +10 -0
  136. package/features/CmsEntryOpenSearchValueSearch/fields/TimeSearch.js +22 -0
  137. package/features/CmsEntryOpenSearchValueSearch/fields/TimeSearch.js.map +1 -0
  138. package/features/CmsEntryOpenSearchValueSearch/index.d.ts +3 -0
  139. package/features/CmsEntryOpenSearchValueSearch/index.js +3 -0
  140. package/features/CmsEntryOpenSearchValuesModifier/abstractions.d.ts +23 -0
  141. package/features/CmsEntryOpenSearchValuesModifier/abstractions.js +5 -0
  142. package/features/CmsEntryOpenSearchValuesModifier/abstractions.js.map +1 -0
  143. package/features/CmsEntryOpenSearchValuesModifier/index.d.ts +1 -0
  144. package/features/CmsEntryOpenSearchValuesModifier/index.js +1 -0
  145. package/features/CmsModelOpenSearchIndex/CmsModelOpenSearchIndexProvider.d.ts +25 -0
  146. package/features/CmsModelOpenSearchIndex/CmsModelOpenSearchIndexProvider.js +36 -0
  147. package/features/CmsModelOpenSearchIndex/CmsModelOpenSearchIndexProvider.js.map +1 -0
  148. package/features/CmsModelOpenSearchIndex/DefaultCmsModelOpenSearchIndex.d.ts +8 -0
  149. package/features/CmsModelOpenSearchIndex/DefaultCmsModelOpenSearchIndex.js +17 -0
  150. package/features/CmsModelOpenSearchIndex/DefaultCmsModelOpenSearchIndex.js.map +1 -0
  151. package/features/CmsModelOpenSearchIndex/abstractions.d.ts +20 -0
  152. package/features/CmsModelOpenSearchIndex/abstractions.js +5 -0
  153. package/features/CmsModelOpenSearchIndex/abstractions.js.map +1 -0
  154. package/features/CmsModelOpenSearchIndex/feature.d.ts +4 -0
  155. package/features/CmsModelOpenSearchIndex/feature.js +13 -0
  156. package/features/CmsModelOpenSearchIndex/feature.js.map +1 -0
  157. package/features/CmsModelOpenSearchIndex/index.d.ts +3 -0
  158. package/features/CmsModelOpenSearchIndex/index.js +3 -0
  159. package/helpers/entryIndexHelpers.d.ts +13 -11
  160. package/helpers/entryIndexHelpers.js +73 -168
  161. package/helpers/entryIndexHelpers.js.map +1 -1
  162. package/helpers/fieldIdentifier.d.ts +6 -0
  163. package/helpers/fieldIdentifier.js +23 -0
  164. package/helpers/fieldIdentifier.js.map +1 -0
  165. package/helpers/index.d.ts +2 -1
  166. package/helpers/index.js +2 -16
  167. package/index.d.ts +1 -3
  168. package/index.js +1 -215
  169. package/operations/entry/dataLoader/DataLoaderCache.d.ts +16 -0
  170. package/operations/entry/dataLoader/DataLoaderCache.js +27 -0
  171. package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -0
  172. package/operations/entry/dataLoader/constants.d.ts +1 -0
  173. package/operations/entry/dataLoader/constants.js +5 -0
  174. package/operations/entry/dataLoader/constants.js.map +1 -0
  175. package/operations/entry/dataLoader/createBatchScheduleFn.d.ts +8 -0
  176. package/operations/entry/dataLoader/createBatchScheduleFn.js +10 -0
  177. package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -0
  178. package/operations/entry/dataLoader/getAllEntryRevisions.d.ts +4 -0
  179. package/operations/entry/dataLoader/getAllEntryRevisions.js +24 -0
  180. package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -0
  181. package/operations/entry/dataLoader/getLatestRevisionByEntryId.d.ts +4 -0
  182. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +34 -0
  183. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -0
  184. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.d.ts +4 -0
  185. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +34 -0
  186. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -0
  187. package/operations/entry/dataLoader/getRevisionById.d.ts +4 -0
  188. package/operations/entry/dataLoader/getRevisionById.js +40 -0
  189. package/operations/entry/dataLoader/getRevisionById.js.map +1 -0
  190. package/operations/entry/dataLoader/index.d.ts +8 -0
  191. package/operations/entry/dataLoader/index.js +18 -0
  192. package/operations/entry/dataLoader/index.js.map +1 -0
  193. package/operations/entry/dataLoader/types.d.ts +6 -0
  194. package/operations/entry/dataLoader/types.js +0 -0
  195. package/operations/entry/dataLoaders.d.ts +17 -38
  196. package/operations/entry/dataLoaders.js +83 -306
  197. package/operations/entry/dataLoaders.js.map +1 -1
  198. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.d.ts +1 -1
  199. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js +8 -31
  200. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js.map +1 -1
  201. package/operations/entry/elasticsearch/body.d.ts +25 -6
  202. package/operations/entry/elasticsearch/body.js +85 -136
  203. package/operations/entry/elasticsearch/body.js.map +1 -1
  204. package/operations/entry/elasticsearch/fields/createSystemField.d.ts +4 -0
  205. package/operations/entry/elasticsearch/fields/createSystemField.js +9 -0
  206. package/operations/entry/elasticsearch/fields/createSystemField.js.map +1 -0
  207. package/operations/entry/elasticsearch/fields/live.d.ts +2 -0
  208. package/operations/entry/elasticsearch/fields/live.js +50 -0
  209. package/operations/entry/elasticsearch/fields/live.js.map +1 -0
  210. package/operations/entry/elasticsearch/fields/location.d.ts +2 -0
  211. package/operations/entry/elasticsearch/fields/location.js +50 -0
  212. package/operations/entry/elasticsearch/fields/location.js.map +1 -0
  213. package/operations/entry/elasticsearch/fields/state.d.ts +2 -0
  214. package/operations/entry/elasticsearch/fields/state.js +104 -0
  215. package/operations/entry/elasticsearch/fields/state.js.map +1 -0
  216. package/operations/entry/elasticsearch/fields.d.ts +8 -6
  217. package/operations/entry/elasticsearch/fields.js +202 -256
  218. package/operations/entry/elasticsearch/fields.js.map +1 -1
  219. package/operations/entry/elasticsearch/filtering/applyFiltering.d.ts +6 -5
  220. package/operations/entry/elasticsearch/filtering/applyFiltering.js +37 -55
  221. package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +1 -1
  222. package/operations/entry/elasticsearch/filtering/exec.d.ts +13 -8
  223. package/operations/entry/elasticsearch/filtering/exec.js +93 -169
  224. package/operations/entry/elasticsearch/filtering/exec.js.map +1 -1
  225. package/operations/entry/elasticsearch/filtering/index.d.ts +1 -1
  226. package/operations/entry/elasticsearch/filtering/index.js +1 -16
  227. package/operations/entry/elasticsearch/filtering/path.d.ts +5 -3
  228. package/operations/entry/elasticsearch/filtering/path.js +26 -43
  229. package/operations/entry/elasticsearch/filtering/path.js.map +1 -1
  230. package/operations/entry/elasticsearch/filtering/populated.d.ts +2 -2
  231. package/operations/entry/elasticsearch/filtering/populated.js +10 -21
  232. package/operations/entry/elasticsearch/filtering/populated.js.map +1 -1
  233. package/operations/entry/elasticsearch/filtering/values.d.ts +1 -1
  234. package/operations/entry/elasticsearch/filtering/values.js +13 -20
  235. package/operations/entry/elasticsearch/filtering/values.js.map +1 -1
  236. package/operations/entry/elasticsearch/fullTextSearch.d.ts +7 -6
  237. package/operations/entry/elasticsearch/fullTextSearch.js +47 -85
  238. package/operations/entry/elasticsearch/fullTextSearch.js.map +1 -1
  239. package/operations/entry/elasticsearch/fullTextSearchFields.d.ts +4 -4
  240. package/operations/entry/elasticsearch/fullTextSearchFields.js +9 -24
  241. package/operations/entry/elasticsearch/fullTextSearchFields.js.map +1 -1
  242. package/operations/entry/elasticsearch/initialQuery.d.ts +5 -4
  243. package/operations/entry/elasticsearch/initialQuery.js +38 -98
  244. package/operations/entry/elasticsearch/initialQuery.js.map +1 -1
  245. package/operations/entry/elasticsearch/keyword.d.ts +1 -1
  246. package/operations/entry/elasticsearch/keyword.js +16 -33
  247. package/operations/entry/elasticsearch/keyword.js.map +1 -1
  248. package/operations/entry/elasticsearch/plugins/operator.d.ts +4 -5
  249. package/operations/entry/elasticsearch/plugins/operator.js +9 -36
  250. package/operations/entry/elasticsearch/plugins/operator.js.map +1 -1
  251. package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.d.ts +2 -0
  252. package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js +8 -0
  253. package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js.map +1 -0
  254. package/operations/entry/elasticsearch/sort.d.ts +9 -6
  255. package/operations/entry/elasticsearch/sort.js +76 -77
  256. package/operations/entry/elasticsearch/sort.js.map +1 -1
  257. package/operations/entry/elasticsearch/transformValueForSearch.d.ts +3 -10
  258. package/operations/entry/elasticsearch/transformValueForSearch.js +11 -29
  259. package/operations/entry/elasticsearch/transformValueForSearch.js.map +1 -1
  260. package/operations/entry/elasticsearch/types.d.ts +6 -16
  261. package/operations/entry/elasticsearch/types.js +0 -5
  262. package/operations/entry/index.d.ts +33 -6
  263. package/operations/entry/index.js +1348 -1138
  264. package/operations/entry/index.js.map +1 -1
  265. package/operations/entry/keys.d.ts +31 -1
  266. package/operations/entry/keys.js +46 -27
  267. package/operations/entry/keys.js.map +1 -1
  268. package/operations/entry/recordType.js +5 -17
  269. package/operations/entry/recordType.js.map +1 -1
  270. package/operations/entry/transformations/convertEntryKeys.d.ts +8 -0
  271. package/operations/entry/transformations/convertEntryKeys.js +25 -0
  272. package/operations/entry/transformations/convertEntryKeys.js.map +1 -0
  273. package/operations/entry/transformations/index.d.ts +33 -0
  274. package/operations/entry/transformations/index.js +91 -0
  275. package/operations/entry/transformations/index.js.map +1 -0
  276. package/operations/entry/transformations/modifyEntryValues.d.ts +53 -0
  277. package/operations/entry/transformations/modifyEntryValues.js +16 -0
  278. package/operations/entry/transformations/modifyEntryValues.js.map +1 -0
  279. package/operations/entry/transformations/transformEntryKeys.d.ts +11 -0
  280. package/operations/entry/transformations/transformEntryKeys.js +17 -0
  281. package/operations/entry/transformations/transformEntryKeys.js.map +1 -0
  282. package/operations/entry/transformations/transformEntryToIndex.d.ts +10 -0
  283. package/operations/entry/transformations/transformEntryToIndex.js +20 -0
  284. package/operations/entry/transformations/transformEntryToIndex.js.map +1 -0
  285. package/operations/group/index.d.ts +7 -6
  286. package/operations/group/index.js +117 -161
  287. package/operations/group/index.js.map +1 -1
  288. package/operations/model/index.d.ts +6 -4
  289. package/operations/model/index.js +115 -167
  290. package/operations/model/index.js.map +1 -1
  291. package/package.json +44 -48
  292. package/tasks/CreateElasticsearchIndexTask.d.ts +14 -0
  293. package/tasks/CreateElasticsearchIndexTask.js +40 -0
  294. package/tasks/CreateElasticsearchIndexTask.js.map +1 -0
  295. package/types.d.ts +31 -137
  296. package/types.js +9 -41
  297. package/types.js.map +1 -1
  298. package/values/NoValueContainer.d.ts +5 -0
  299. package/values/NoValueContainer.js +11 -0
  300. package/values/NoValueContainer.js.map +1 -0
  301. package/definitions/entryElasticsearch.d.ts +0 -8
  302. package/definitions/entryElasticsearch.js +0 -37
  303. package/definitions/entryElasticsearch.js.map +0 -1
  304. package/definitions/settings.d.ts +0 -8
  305. package/definitions/settings.js +0 -53
  306. package/definitions/settings.js.map +0 -1
  307. package/definitions/system.d.ts +0 -8
  308. package/definitions/system.js +0 -41
  309. package/definitions/system.js.map +0 -1
  310. package/definitions/table.d.ts +0 -8
  311. package/definitions/table.js +0 -21
  312. package/definitions/table.js.map +0 -1
  313. package/definitions/tableElasticsearch.d.ts +0 -8
  314. package/definitions/tableElasticsearch.js +0 -21
  315. package/definitions/tableElasticsearch.js.map +0 -1
  316. package/dynamoDb/index.d.ts +0 -2
  317. package/dynamoDb/index.js +0 -11
  318. package/dynamoDb/index.js.map +0 -1
  319. package/dynamoDb/storage/date.d.ts +0 -3
  320. package/dynamoDb/storage/date.js +0 -86
  321. package/dynamoDb/storage/date.js.map +0 -1
  322. package/dynamoDb/storage/longText.d.ts +0 -10
  323. package/dynamoDb/storage/longText.js +0 -93
  324. package/dynamoDb/storage/longText.js.map +0 -1
  325. package/dynamoDb/storage/richText.d.ts +0 -7
  326. package/dynamoDb/storage/richText.js +0 -110
  327. package/dynamoDb/storage/richText.js.map +0 -1
  328. package/elasticsearch/index.d.ts +0 -2
  329. package/elasticsearch/index.js +0 -11
  330. package/elasticsearch/index.js.map +0 -1
  331. package/elasticsearch/indexing/dateTimeIndexing.d.ts +0 -3
  332. package/elasticsearch/indexing/dateTimeIndexing.js +0 -86
  333. package/elasticsearch/indexing/dateTimeIndexing.js.map +0 -1
  334. package/elasticsearch/indexing/defaultFieldIndexing.d.ts +0 -3
  335. package/elasticsearch/indexing/defaultFieldIndexing.js +0 -52
  336. package/elasticsearch/indexing/defaultFieldIndexing.js.map +0 -1
  337. package/elasticsearch/indexing/index.d.ts +0 -2
  338. package/elasticsearch/indexing/index.js +0 -15
  339. package/elasticsearch/indexing/index.js.map +0 -1
  340. package/elasticsearch/indexing/longTextIndexing.d.ts +0 -7
  341. package/elasticsearch/indexing/longTextIndexing.js +0 -40
  342. package/elasticsearch/indexing/longTextIndexing.js.map +0 -1
  343. package/elasticsearch/indexing/numberIndexing.d.ts +0 -3
  344. package/elasticsearch/indexing/numberIndexing.js +0 -39
  345. package/elasticsearch/indexing/numberIndexing.js.map +0 -1
  346. package/elasticsearch/indexing/objectIndexing.d.ts +0 -12
  347. package/elasticsearch/indexing/objectIndexing.js +0 -196
  348. package/elasticsearch/indexing/objectIndexing.js.map +0 -1
  349. package/elasticsearch/indexing/richTextIndexing.d.ts +0 -3
  350. package/elasticsearch/indexing/richTextIndexing.js +0 -29
  351. package/elasticsearch/indexing/richTextIndexing.js.map +0 -1
  352. package/elasticsearch/indices/base.d.ts +0 -2
  353. package/elasticsearch/indices/base.js +0 -12
  354. package/elasticsearch/indices/base.js.map +0 -1
  355. package/elasticsearch/indices/index.d.ts +0 -1
  356. package/elasticsearch/indices/index.js +0 -12
  357. package/elasticsearch/indices/index.js.map +0 -1
  358. package/elasticsearch/indices/japanese.d.ts +0 -2
  359. package/elasticsearch/indices/japanese.js +0 -13
  360. package/elasticsearch/indices/japanese.js.map +0 -1
  361. package/elasticsearch/search/index.d.ts +0 -3
  362. package/elasticsearch/search/index.js +0 -10
  363. package/elasticsearch/search/index.js.map +0 -1
  364. package/elasticsearch/search/refSearch.d.ts +0 -2
  365. package/elasticsearch/search/refSearch.js +0 -29
  366. package/elasticsearch/search/refSearch.js.map +0 -1
  367. package/elasticsearch/search/timeSearch.d.ts +0 -2
  368. package/elasticsearch/search/timeSearch.js +0 -26
  369. package/elasticsearch/search/timeSearch.js.map +0 -1
  370. package/helpers/index.js.map +0 -1
  371. package/index.js.map +0 -1
  372. package/operations/entry/elasticsearch/filtering/index.js.map +0 -1
  373. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.d.ts +0 -2
  374. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js +0 -28
  375. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js.map +0 -1
  376. package/operations/entry/elasticsearch/filtering/plugins/index.d.ts +0 -1
  377. package/operations/entry/elasticsearch/filtering/plugins/index.js +0 -13
  378. package/operations/entry/elasticsearch/filtering/plugins/index.js.map +0 -1
  379. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.d.ts +0 -2
  380. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js +0 -65
  381. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js.map +0 -1
  382. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.d.ts +0 -2
  383. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js +0 -48
  384. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js.map +0 -1
  385. package/operations/entry/elasticsearch/plugins/bodyModifier.d.ts +0 -9
  386. package/operations/entry/elasticsearch/plugins/bodyModifier.js +0 -16
  387. package/operations/entry/elasticsearch/plugins/bodyModifier.js.map +0 -1
  388. package/operations/entry/elasticsearch/plugins/queryModifier.d.ts +0 -9
  389. package/operations/entry/elasticsearch/plugins/queryModifier.js +0 -16
  390. package/operations/entry/elasticsearch/plugins/queryModifier.js.map +0 -1
  391. package/operations/entry/elasticsearch/plugins/search.d.ts +0 -7
  392. package/operations/entry/elasticsearch/plugins/search.js +0 -24
  393. package/operations/entry/elasticsearch/plugins/search.js.map +0 -1
  394. package/operations/entry/elasticsearch/plugins/sortModifier.d.ts +0 -9
  395. package/operations/entry/elasticsearch/plugins/sortModifier.js +0 -16
  396. package/operations/entry/elasticsearch/plugins/sortModifier.js.map +0 -1
  397. package/operations/entry/elasticsearch/types.js.map +0 -1
  398. package/operations/settings/index.d.ts +0 -6
  399. package/operations/settings/index.js +0 -111
  400. package/operations/settings/index.js.map +0 -1
  401. package/operations/system/index.d.ts +0 -6
  402. package/operations/system/index.js +0 -82
  403. package/operations/system/index.js.map +0 -1
  404. package/plugins/CmsElasticsearchModelFieldPlugin.d.ts +0 -69
  405. package/plugins/CmsElasticsearchModelFieldPlugin.js +0 -48
  406. package/plugins/CmsElasticsearchModelFieldPlugin.js.map +0 -1
  407. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.d.ts +0 -21
  408. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js +0 -22
  409. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js.map +0 -1
  410. package/plugins/CmsEntryElasticsearchFieldPlugin.d.ts +0 -12
  411. package/plugins/CmsEntryElasticsearchFieldPlugin.js +0 -24
  412. package/plugins/CmsEntryElasticsearchFieldPlugin.js.map +0 -1
  413. package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.d.ts +0 -23
  414. package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js +0 -28
  415. package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js.map +0 -1
  416. package/plugins/CmsEntryElasticsearchIndexPlugin.d.ts +0 -4
  417. package/plugins/CmsEntryElasticsearchIndexPlugin.js +0 -12
  418. package/plugins/CmsEntryElasticsearchIndexPlugin.js.map +0 -1
  419. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.d.ts +0 -31
  420. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js +0 -37
  421. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js.map +0 -1
  422. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.d.ts +0 -18
  423. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js +0 -22
  424. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js.map +0 -1
  425. package/plugins/CmsEntryElasticsearchSortModifierPlugin.d.ts +0 -18
  426. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js +0 -22
  427. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js.map +0 -1
  428. package/plugins/CmsEntryFilterPlugin.d.ts +0 -49
  429. package/plugins/CmsEntryFilterPlugin.js +0 -24
  430. package/plugins/CmsEntryFilterPlugin.js.map +0 -1
  431. package/plugins/index.d.ts +0 -7
  432. package/plugins/index.js +0 -82
  433. package/plugins/index.js.map +0 -1
@@ -1,313 +1,90 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.DataLoadersHandler = void 0;
8
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
- var _dataloader = _interopRequireDefault(require("dataloader"));
11
- var _error = _interopRequireDefault(require("@webiny/error"));
12
- var _query = require("@webiny/db-dynamodb/utils/query");
13
- var _keys = require("./keys");
14
- var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
15
- var _utils = require("@webiny/utils");
16
- var _batchRead = require("@webiny/db-dynamodb/utils/batchRead");
17
- const getAllEntryRevisions = params => {
18
- const {
19
- entity,
20
- model
21
- } = params;
22
- const {
23
- tenant,
24
- locale
25
- } = model;
26
- return new _dataloader.default(async ids => {
27
- const results = {};
28
- for (const id of ids) {
29
- const queryAllParams = {
30
- entity,
31
- partitionKey: (0, _keys.createPartitionKey)({
32
- tenant,
33
- locale,
34
- id
35
- }),
36
- options: {
37
- beginsWith: "REV#"
38
- }
39
- };
40
- const items = await (0, _query.queryAll)(queryAllParams);
41
- results[id] = (0, _cleanup.cleanupItems)(entity, items);
42
- }
43
- return ids.map(id => {
44
- return results[id] || [];
45
- });
46
- });
47
- };
48
- const getRevisionById = params => {
49
- const {
50
- entity,
51
- model
52
- } = params;
53
- const {
54
- locale,
55
- tenant
56
- } = model;
57
- return new _dataloader.default(async ids => {
58
- const queries = ids.reduce((collection, id) => {
59
- const partitionKey = (0, _keys.createPartitionKey)({
60
- tenant,
61
- locale,
62
- id
63
- });
64
- const {
65
- version
66
- } = (0, _utils.parseIdentifier)(id);
67
- if (!version) {
68
- return collection;
69
- }
70
- const sortKey = (0, _keys.createRevisionSortKey)({
71
- version
72
- });
73
- const keys = `${partitionKey}__${sortKey}`;
74
- if (collection[keys]) {
75
- return collection;
76
- }
77
- collection[keys] = entity.getBatch({
78
- PK: partitionKey,
79
- SK: sortKey
80
- });
81
- return collection;
82
- /**
83
- * We use any because there is no type for the return type.
84
- */
85
- }, {});
86
- const records = await (0, _batchRead.batchReadAll)({
87
- table: entity.table,
88
- items: Object.values(queries)
89
- });
90
- const items = (0, _cleanup.cleanupItems)(entity, records);
91
- return ids.map(id => {
92
- return items.filter(item => {
93
- return id === item.id;
94
- });
95
- });
96
- });
97
- };
98
- const getPublishedRevisionByEntryId = params => {
99
- const {
100
- entity,
101
- model
102
- } = params;
103
- const {
104
- locale,
105
- tenant
106
- } = model;
107
- const publishedKey = (0, _keys.createPublishedSortKey)();
108
- return new _dataloader.default(async ids => {
109
- const queries = ids.reduce((collection, id) => {
110
- const partitionKey = (0, _keys.createPartitionKey)({
111
- tenant,
112
- locale,
113
- id
114
- });
115
- if (collection[partitionKey]) {
116
- return collection;
117
- }
118
- collection[partitionKey] = entity.getBatch({
119
- PK: partitionKey,
120
- SK: publishedKey
121
- });
122
- return collection;
123
- /**
124
- * We use any because there is no type for the return type.
125
- */
126
- }, {});
127
- const records = await (0, _batchRead.batchReadAll)({
128
- table: entity.table,
129
- items: Object.values(queries)
130
- });
131
- const items = (0, _cleanup.cleanupItems)(entity, records);
132
- return ids.map(id => {
133
- const {
134
- id: entryId
135
- } = (0, _utils.parseIdentifier)(id);
136
- return items.filter(item => {
137
- return entryId === item.entryId;
138
- });
139
- });
140
- });
141
- };
142
- const getLatestRevisionByEntryId = params => {
143
- const {
144
- entity,
145
- model
146
- } = params;
147
- const {
148
- locale,
149
- tenant
150
- } = model;
151
- const latestKey = (0, _keys.createLatestSortKey)();
152
- return new _dataloader.default(async ids => {
153
- const queries = ids.reduce((collection, id) => {
154
- const partitionKey = (0, _keys.createPartitionKey)({
155
- tenant,
156
- locale,
157
- id
158
- });
159
- if (collection[partitionKey]) {
160
- return collection;
161
- }
162
- collection[partitionKey] = entity.getBatch({
163
- PK: partitionKey,
164
- SK: latestKey
165
- });
166
- return collection;
167
- /**
168
- * We use any because there is no type for the return type.
169
- */
170
- }, {});
171
- const records = await (0, _batchRead.batchReadAll)({
172
- table: entity.table,
173
- items: Object.values(queries)
174
- });
175
- const items = (0, _cleanup.cleanupItems)(entity, records);
176
- return ids.map(id => {
177
- const {
178
- id: entryId
179
- } = (0, _utils.parseIdentifier)(id);
180
- return items.filter(item => {
181
- return entryId === item.entryId;
182
- });
183
- });
184
- });
185
- };
186
- const dataLoaders = {
187
- getAllEntryRevisions,
188
- getRevisionById,
189
- getPublishedRevisionByEntryId,
190
- getLatestRevisionByEntryId
191
- };
192
- const loaderNames = Object.keys(dataLoaders);
1
+ import error from "@webiny/error";
2
+ import { DataLoaderCache } from "./dataLoader/DataLoaderCache.js";
3
+ import { getDataLoaderFactory } from "./dataLoader/index.js";
4
+ import { parseIdentifier } from "@webiny/utils";
193
5
  class DataLoadersHandler {
194
- constructor(params) {
195
- (0, _defineProperty2.default)(this, "loaders", new Map());
196
- (0, _defineProperty2.default)(this, "entity", void 0);
197
- this.entity = params.entity;
198
- }
199
- async getAllEntryRevisions(params) {
200
- return await this.loadMany("getAllEntryRevisions", params, params.ids);
201
- }
202
- clearAllEntryRevisions(params) {
203
- this.clear("getAllEntryRevisions", params);
204
- }
205
- async getRevisionById(params) {
206
- return await this.loadMany("getRevisionById", params, params.ids);
207
- }
208
- clearRevisionById(params) {
209
- this.clear("getRevisionById", params);
210
- }
211
- async getPublishedRevisionByEntryId(params) {
212
- return await this.loadMany("getPublishedRevisionByEntryId", params, params.ids);
213
- }
214
- clearPublishedRevisionByEntryId(params) {
215
- this.clear("getPublishedRevisionByEntryId", params);
216
- }
217
- async getLatestRevisionByEntryId(params) {
218
- return await this.loadMany("getLatestRevisionByEntryId", params, params.ids);
219
- }
220
- clearLatestRevisionByEntryId(params) {
221
- this.clear("getLatestRevisionByEntryId", params);
222
- }
223
- /**
224
- * TODO @ts-refactor
225
- * Maybe pass on the generics to DataLoader definition?
226
- */
227
- getLoader(name, params) {
228
- if (!dataLoaders[name]) {
229
- throw new _error.default("Unknown data loader.", "UNKNOWN_DATA_LOADER", {
230
- name
231
- });
6
+ constructor(params){
7
+ this.cache = new DataLoaderCache();
8
+ this.entity = params.entity;
9
+ }
10
+ async getAllEntryRevisions(params) {
11
+ const ids = params.ids.map((id)=>{
12
+ const { id: entryId } = parseIdentifier(id);
13
+ return entryId;
14
+ });
15
+ return await this.loadMany("getAllEntryRevisions", params, ids);
232
16
  }
233
- const {
234
- model
235
- } = params;
236
- const {
237
- tenant,
238
- locale
239
- } = model;
240
- const loaderKey = `${name}-${tenant}-${locale}-${model.modelId}`;
241
- if (!this.loaders.has(loaderKey)) {
242
- this.loaders.set(loaderKey, dataLoaders[name]((0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
243
- entity: this.entity
244
- })));
17
+ async getRevisionById(params) {
18
+ return await this.loadMany("getRevisionById", params, params.ids);
245
19
  }
246
- return this.loaders.get(loaderKey);
247
- }
248
- async loadMany(loader, params, ids) {
249
- let results;
250
- try {
251
- results = await this.getLoader(loader, params).loadMany(ids);
252
- if (Array.isArray(results) === true) {
253
- return results.reduce((acc, res) => {
254
- if (Array.isArray(res) === false) {
255
- if (res && res.message) {
256
- throw new _error.default(res.message, res.code, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, res), {}, {
257
- data: JSON.stringify(res.data || {})
258
- }));
259
- }
260
- throw new _error.default("Result from the data loader must be an array of arrays which contain requested items.", "DATA_LOADER_RESULTS_ERROR", (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
261
- loader
262
- }));
263
- }
264
- acc.push(...res);
265
- return acc;
266
- }, []);
267
- }
268
- } catch (ex) {
269
- throw new _error.default(ex.message || "Data loader error.", ex.code || "DATA_LOADER_ERROR", (0, _objectSpread2.default)((0, _objectSpread2.default)({
270
- error: ex
271
- }, params), {}, {
272
- loader,
273
- ids
274
- }));
20
+ async getPublishedRevisionByEntryId(params) {
21
+ const ids = params.ids.map((id)=>{
22
+ const { id: entryId } = parseIdentifier(id);
23
+ return entryId;
24
+ });
25
+ return await this.loadMany("getPublishedRevisionByEntryId", params, ids);
275
26
  }
276
- throw new _error.default(`Data loader did not return array of items or empty array.`, "INVALID_DATA_LOADER_RESULT", {
277
- loader,
278
- ids,
279
- results
280
- });
281
- }
282
- clearAll(params) {
283
- for (const name of loaderNames) {
284
- const loader = this.getLoader(name, params);
285
- loader.clearAll();
27
+ async getLatestRevisionByEntryId(params) {
28
+ const ids = params.ids.map((id)=>{
29
+ const { id: entryId } = parseIdentifier(id);
30
+ return entryId;
31
+ });
32
+ return await this.loadMany("getLatestRevisionByEntryId", params, ids);
286
33
  }
287
- }
288
- /**
289
- * Helper to clear the cache for certain data loader.
290
- * If entry is passed then clear target key only.
291
- */
292
- clear(name, params) {
293
- const {
294
- entry
295
- } = params;
296
- const loader = this.getLoader(name, params);
297
- if (!entry) {
298
- loader.clearAll();
299
- return;
34
+ getLoader(name, params) {
35
+ const { model } = params;
36
+ const cacheParams = {
37
+ tenant: model.tenant,
38
+ modelId: model.modelId,
39
+ name
40
+ };
41
+ let loader = this.cache.getDataLoader(cacheParams);
42
+ if (loader) return loader;
43
+ const factory = getDataLoaderFactory(name);
44
+ loader = factory({
45
+ entity: this.entity,
46
+ tenant: model.tenant,
47
+ modelId: model.modelId
48
+ });
49
+ this.cache.setDataLoader(cacheParams, loader);
50
+ return loader;
51
+ }
52
+ async loadMany(loader, params, ids) {
53
+ let results = [];
54
+ try {
55
+ results = await this.getLoader(loader, params).loadMany(ids);
56
+ if (true === Array.isArray(results)) return results.reduce((acc, res)=>{
57
+ if (false === Array.isArray(res)) {
58
+ if (res && res.message) throw new error(res.message, res.code, {
59
+ ...res,
60
+ data: JSON.stringify(res.data || {})
61
+ });
62
+ throw new error("Result from the data loader must be an array of arrays which contain requested items.", "DATA_LOADER_RESULTS_ERROR", {
63
+ ...params,
64
+ loader
65
+ });
66
+ }
67
+ acc.push(...res);
68
+ return acc;
69
+ }, []);
70
+ } catch (ex) {
71
+ throw new error(ex.message || "Data loader error.", ex.code || "DATA_LOADER_ERROR", {
72
+ error: ex,
73
+ ...params,
74
+ loader,
75
+ ids
76
+ });
77
+ }
78
+ throw new error("Data loader did not return array of items or empty array.", "INVALID_DATA_LOADER_RESULT", {
79
+ loader,
80
+ ids,
81
+ results
82
+ });
83
+ }
84
+ clearAll(params) {
85
+ this.cache.clearAll(params);
300
86
  }
301
- loader.clear(entry.id);
302
- const {
303
- tenant,
304
- locale
305
- } = params.model;
306
- loader.clear((0, _keys.createPartitionKey)({
307
- tenant,
308
- locale,
309
- id: entry.id
310
- }));
311
- }
312
87
  }
313
- exports.DataLoadersHandler = DataLoadersHandler;
88
+ export { DataLoadersHandler };
89
+
90
+ //# sourceMappingURL=dataLoaders.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["getAllEntryRevisions","params","entity","model","tenant","locale","DataLoader","ids","results","id","queryAllParams","partitionKey","createPartitionKey","options","beginsWith","items","queryAll","cleanupItems","map","getRevisionById","queries","reduce","collection","version","parseIdentifier","sortKey","createRevisionSortKey","keys","getBatch","PK","SK","records","batchReadAll","table","Object","values","filter","item","getPublishedRevisionByEntryId","publishedKey","createPublishedSortKey","entryId","getLatestRevisionByEntryId","latestKey","createLatestSortKey","dataLoaders","loaderNames","DataLoadersHandler","constructor","Map","loadMany","clearAllEntryRevisions","clear","clearRevisionById","clearPublishedRevisionByEntryId","clearLatestRevisionByEntryId","getLoader","name","WebinyError","loaderKey","modelId","loaders","has","set","get","loader","Array","isArray","acc","res","message","code","data","JSON","stringify","push","ex","error","clearAll","entry"],"sources":["dataLoaders.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport WebinyError from \"@webiny/error\";\nimport { CmsEntry, CmsModel } from \"@webiny/api-headless-cms/types\";\nimport { Entity } from \"dynamodb-toolbox\";\nimport { queryAll, QueryAllParams } from \"@webiny/db-dynamodb/utils/query\";\nimport {\n createLatestSortKey,\n createPartitionKey,\n createPublishedSortKey,\n createRevisionSortKey\n} from \"./keys\";\nimport { cleanupItems } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { batchReadAll } from \"@webiny/db-dynamodb/utils/batchRead\";\n\nconst getAllEntryRevisions = (params: LoaderParams) => {\n const { entity, model } = params;\n const { tenant, locale } = model;\n return new DataLoader<string, CmsEntry[]>(async (ids: readonly string[]) => {\n const results: Record<string, CmsEntry[]> = {};\n for (const id of ids) {\n const queryAllParams: QueryAllParams = {\n entity,\n partitionKey: createPartitionKey({\n tenant,\n locale,\n id\n }),\n options: {\n beginsWith: \"REV#\"\n }\n };\n const items = await queryAll<CmsEntry>(queryAllParams);\n\n results[id] = cleanupItems(entity, items);\n }\n\n return ids.map(id => {\n return results[id] || [];\n });\n });\n};\n\nconst getRevisionById = (params: LoaderParams) => {\n const { entity, model } = params;\n const { locale, tenant } = model;\n\n return new DataLoader<string, CmsEntry[]>(async (ids: readonly string[]) => {\n const queries = ids.reduce((collection, id) => {\n const partitionKey = createPartitionKey({\n tenant,\n locale,\n id\n });\n const { version } = parseIdentifier(id);\n if (!version) {\n return collection;\n }\n const sortKey = createRevisionSortKey({\n version\n });\n const keys = `${partitionKey}__${sortKey}`;\n if (collection[keys]) {\n return collection;\n }\n\n collection[keys] = entity.getBatch({\n PK: partitionKey,\n SK: sortKey\n });\n\n return collection;\n /**\n * We use any because there is no type for the return type.\n */\n }, {} as Record<string, any>);\n\n const records = await batchReadAll<CmsEntry>({\n table: entity.table,\n items: Object.values(queries)\n });\n const items = cleanupItems(entity, records);\n\n return ids.map(id => {\n return items.filter(item => {\n return id === item.id;\n });\n });\n });\n};\n\nconst getPublishedRevisionByEntryId = (params: LoaderParams) => {\n const { entity, model } = params;\n const { locale, tenant } = model;\n\n const publishedKey = createPublishedSortKey();\n\n return new DataLoader<string, CmsEntry[]>(async (ids: readonly string[]) => {\n const queries = ids.reduce((collection, id) => {\n const partitionKey = createPartitionKey({\n tenant,\n locale,\n id\n });\n if (collection[partitionKey]) {\n return collection;\n }\n collection[partitionKey] = entity.getBatch({\n PK: partitionKey,\n SK: publishedKey\n });\n return collection;\n /**\n * We use any because there is no type for the return type.\n */\n }, {} as Record<string, any>);\n\n const records = await batchReadAll<CmsEntry>({\n table: entity.table,\n items: Object.values(queries)\n });\n const items = cleanupItems(entity, records);\n\n return ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return items.filter(item => {\n return entryId === item.entryId;\n });\n });\n });\n};\n\nconst getLatestRevisionByEntryId = (params: LoaderParams) => {\n const { entity, model } = params;\n const { locale, tenant } = model;\n\n const latestKey = createLatestSortKey();\n\n return new DataLoader<string, CmsEntry[]>(async (ids: readonly string[]) => {\n const queries = ids.reduce((collection, id) => {\n const partitionKey = createPartitionKey({\n tenant,\n locale,\n id\n });\n if (collection[partitionKey]) {\n return collection;\n }\n collection[partitionKey] = entity.getBatch({\n PK: partitionKey,\n SK: latestKey\n });\n return collection;\n /**\n * We use any because there is no type for the return type.\n */\n }, {} as Record<string, any>);\n\n const records = await batchReadAll<CmsEntry>({\n table: entity.table,\n items: Object.values(queries)\n });\n const items = cleanupItems(entity, records);\n\n return ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return items.filter(item => {\n return entryId === item.entryId;\n });\n });\n });\n};\n\nconst dataLoaders: Record<Loaders, any> = {\n getAllEntryRevisions,\n getRevisionById,\n getPublishedRevisionByEntryId,\n getLatestRevisionByEntryId\n};\n\nexport interface GetAllEntryRevisionsParams {\n ids: readonly string[];\n model: CmsModel;\n}\n\nexport interface GetRevisionByIdParams {\n ids: readonly string[];\n model: CmsModel;\n}\n\nexport interface GetPublishedRevisionByEntryIdParams {\n ids: readonly string[];\n model: CmsModel;\n}\n\nexport interface GetLatestRevisionByEntryIdParams {\n ids: readonly string[];\n model: CmsModel;\n}\n\ninterface LoaderParams {\n entity: Entity<any>;\n model: CmsModel;\n}\n\ninterface GetLoaderParams {\n model: CmsModel;\n}\n\ninterface ClearLoaderParams {\n model: CmsModel;\n entry?: CmsEntry;\n}\n\ntype Loaders =\n | \"getAllEntryRevisions\"\n | \"getRevisionById\"\n | \"getPublishedRevisionByEntryId\"\n | \"getLatestRevisionByEntryId\";\n\nconst loaderNames = Object.keys(dataLoaders) as Loaders[];\n\nexport interface DataLoadersHandlerParams {\n entity: Entity<any>;\n}\nexport class DataLoadersHandler {\n private readonly loaders: Map<string, DataLoader<any, any>> = new Map();\n private readonly entity: Entity<any>;\n\n public constructor(params: DataLoadersHandlerParams) {\n this.entity = params.entity;\n }\n\n public async getAllEntryRevisions(params: GetAllEntryRevisionsParams): Promise<CmsEntry[]> {\n return await this.loadMany(\"getAllEntryRevisions\", params, params.ids);\n }\n\n public clearAllEntryRevisions(params: ClearLoaderParams): void {\n this.clear(\"getAllEntryRevisions\", params);\n }\n\n public async getRevisionById(params: GetRevisionByIdParams): Promise<CmsEntry[]> {\n return await this.loadMany(\"getRevisionById\", params, params.ids);\n }\n\n public clearRevisionById(params: ClearLoaderParams): void {\n this.clear(\"getRevisionById\", params);\n }\n\n public async getPublishedRevisionByEntryId(\n params: GetPublishedRevisionByEntryIdParams\n ): Promise<CmsEntry[]> {\n return await this.loadMany(\"getPublishedRevisionByEntryId\", params, params.ids);\n }\n public clearPublishedRevisionByEntryId(params: ClearLoaderParams): void {\n this.clear(\"getPublishedRevisionByEntryId\", params);\n }\n\n public async getLatestRevisionByEntryId(\n params: GetLatestRevisionByEntryIdParams\n ): Promise<CmsEntry[]> {\n return await this.loadMany(\"getLatestRevisionByEntryId\", params, params.ids);\n }\n\n public clearLatestRevisionByEntryId(params: ClearLoaderParams): void {\n this.clear(\"getLatestRevisionByEntryId\", params);\n }\n /**\n * TODO @ts-refactor\n * Maybe pass on the generics to DataLoader definition?\n */\n private getLoader(name: Loaders, params: GetLoaderParams): DataLoader<any, any> {\n if (!dataLoaders[name]) {\n throw new WebinyError(\"Unknown data loader.\", \"UNKNOWN_DATA_LOADER\", {\n name\n });\n }\n const { model } = params;\n const { tenant, locale } = model;\n const loaderKey = `${name}-${tenant}-${locale}-${model.modelId}`;\n if (!this.loaders.has(loaderKey)) {\n this.loaders.set(\n loaderKey,\n dataLoaders[name]({\n ...params,\n entity: this.entity\n })\n );\n }\n return this.loaders.get(loaderKey) as DataLoader<any, any>;\n }\n\n private async loadMany(\n loader: Loaders,\n params: GetLoaderParams,\n ids: readonly string[]\n ): Promise<CmsEntry[]> {\n let results;\n try {\n results = await this.getLoader(loader, params).loadMany(ids);\n if (Array.isArray(results) === true) {\n return results.reduce((acc, res) => {\n if (Array.isArray(res) === false) {\n if (res && res.message) {\n throw new WebinyError(res.message, res.code, {\n ...res,\n data: JSON.stringify(res.data || {})\n });\n }\n throw new WebinyError(\n \"Result from the data loader must be an array of arrays which contain requested items.\",\n \"DATA_LOADER_RESULTS_ERROR\",\n {\n ...params,\n loader\n }\n );\n }\n acc.push(...res);\n return acc;\n }, []);\n }\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Data loader error.\",\n ex.code || \"DATA_LOADER_ERROR\",\n {\n error: ex,\n ...params,\n loader,\n ids\n }\n );\n }\n throw new WebinyError(\n `Data loader did not return array of items or empty array.`,\n \"INVALID_DATA_LOADER_RESULT\",\n {\n loader,\n ids,\n results\n }\n );\n }\n\n public clearAll(params: Omit<ClearLoaderParams, \"entry\">): void {\n for (const name of loaderNames) {\n const loader = this.getLoader(name, params);\n loader.clearAll();\n }\n }\n /**\n * Helper to clear the cache for certain data loader.\n * If entry is passed then clear target key only.\n */\n private clear(name: Loaders, params: ClearLoaderParams): void {\n const { entry } = params;\n const loader = this.getLoader(name, params);\n if (!entry) {\n loader.clearAll();\n return;\n }\n loader.clear(entry.id);\n const { tenant, locale } = params.model;\n loader.clear(\n createPartitionKey({\n tenant,\n locale,\n id: entry.id\n })\n );\n }\n}\n"],"mappings":";;;;;;;;;AAAA;AACA;AAGA;AACA;AAMA;AACA;AACA;AAEA,MAAMA,oBAAoB,GAAIC,MAAoB,IAAK;EACnD,MAAM;IAAEC,MAAM;IAAEC;EAAM,CAAC,GAAGF,MAAM;EAChC,MAAM;IAAEG,MAAM;IAAEC;EAAO,CAAC,GAAGF,KAAK;EAChC,OAAO,IAAIG,mBAAU,CAAqB,MAAOC,GAAsB,IAAK;IACxE,MAAMC,OAAmC,GAAG,CAAC,CAAC;IAC9C,KAAK,MAAMC,EAAE,IAAIF,GAAG,EA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,EAAED;MAAE,GACN3E,MAAM;QACTgE,MAAM;QACN1D;MAAG,GAEV;IACL;IACA,MAAM,IAAImD,cAAW,CAChB,2DAA0D,EAC3D,4BAA4B,EAC5B;MACIO,MAAM;MACN1D,GAAG;MACHC;IACJ,CAAC,CACJ;EACL;EAEOsE,QAAQ,CAAC7E,MAAwC,EAAQ;IAC5D,KAAK,MAAMwD,IAAI,IAAIX,WAAW,EAAE;MAC5B,MAAMmB,MAAM,GAAG,IAAI,CAACT,SAAS,CAACC,IAAI,EAAExD,MAAM,CAAC;MAC3CgE,MAAM,CAACa,QAAQ,EAAE;IACrB;EACJ;EACA;AACJ;AACA;AACA;EACY1B,KAAK,CAACK,IAAa,EAAExD,MAAyB,EAAQ;IAC1D,MAAM;MAAE8E;IAAM,CAAC,GAAG9E,MAAM;IACxB,MAAMgE,MAAM,GAAG,IAAI,CAACT,SAAS,CAACC,IAAI,EAAExD,MAAM,CAAC;IAC3C,IAAI,CAAC8E,KAAK,EAAE;MACRd,MAAM,CAACa,QAAQ,EAAE;MACjB;IACJ;IACAb,MAAM,CAACb,KAAK,CAAC2B,KAAK,CAACtE,EAAE,CAAC;IACtB,MAAM;MAAEL,MAAM;MAAEC;IAAO,CAAC,GAAGJ,MAAM,CAACE,KAAK;IACvC8D,MAAM,CAACb,KAAK,CACR,IAAAxC,wBAAkB,EAAC;MACfR,MAAM;MACNC,MAAM;MACNI,EAAE,EAAEsE,KAAK,CAACtE;IACd,CAAC,CAAC,CACL;EACL;AACJ;AAAC"}
1
+ {"version":3,"file":"operations/entry/dataLoaders.js","sources":["../../../src/operations/entry/dataLoaders.ts"],"sourcesContent":["import type DataLoader from \"dataloader\";\nimport WebinyError from \"@webiny/error\";\nimport type {\n CmsEntryValues,\n CmsModel,\n CmsStorageEntry\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport type { CacheKeyParams } from \"~/operations/entry/dataLoader/DataLoaderCache.js\";\nimport { DataLoaderCache } from \"~/operations/entry/dataLoader/DataLoaderCache.js\";\nimport type { DataLoaders } from \"~/operations/entry/dataLoader/index.js\";\nimport { getDataLoaderFactory } from \"~/operations/entry/dataLoader/index.js\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport type { DataLoadersHandlerInterfaceClearAllParams, IDataLoadersHandler } from \"~/types.js\";\nimport type { IEntryEntity } from \"~/definitions/types.js\";\n\ninterface DataLoaderParams {\n model: Pick<CmsModel, \"tenant\" | \"modelId\">;\n ids: readonly string[];\n}\n\ninterface GetLoaderParams {\n model: Pick<CmsModel, \"tenant\" | \"modelId\">;\n}\n\ninterface IDataLoadersHandlerParams {\n entity: IEntryEntity;\n}\n\nexport interface ClearAllParams {\n model: Pick<CmsModel, \"tenant\" | \"modelId\">;\n}\n\nexport class DataLoadersHandler implements IDataLoadersHandler {\n private readonly entity;\n private readonly cache = new DataLoaderCache();\n\n public constructor(params: IDataLoadersHandlerParams) {\n this.entity = params.entity;\n }\n\n public async getAllEntryRevisions<T extends CmsEntryValues = CmsEntryValues>(\n params: DataLoaderParams\n ): Promise<CmsStorageEntry<T>[]> {\n const ids = params.ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return entryId;\n });\n return await this.loadMany<T>(\"getAllEntryRevisions\", params, ids);\n }\n\n public async getRevisionById<T extends CmsEntryValues = CmsEntryValues>(\n params: DataLoaderParams\n ): Promise<CmsStorageEntry<T>[]> {\n return await this.loadMany<T>(\"getRevisionById\", params, params.ids);\n }\n\n public async getPublishedRevisionByEntryId<T extends CmsEntryValues = CmsEntryValues>(\n params: DataLoaderParams\n ): Promise<CmsStorageEntry<T>[]> {\n const ids = params.ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return entryId;\n });\n return await this.loadMany<T>(\"getPublishedRevisionByEntryId\", params, ids);\n }\n\n public async getLatestRevisionByEntryId<T extends CmsEntryValues = CmsEntryValues>(\n params: DataLoaderParams\n ): Promise<CmsStorageEntry<T>[]> {\n const ids = params.ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return entryId;\n });\n return await this.loadMany<T>(\"getLatestRevisionByEntryId\", params, ids);\n }\n\n /**\n * TODO @ts-refactor\n * Maybe pass on the generics to DataLoader definition?\n */\n private getLoader(name: DataLoaders, params: GetLoaderParams): DataLoader<any, any> {\n const { model } = params;\n const cacheParams: CacheKeyParams = {\n tenant: model.tenant,\n modelId: model.modelId,\n name\n };\n let loader = this.cache.getDataLoader(cacheParams);\n if (loader) {\n return loader;\n }\n const factory = getDataLoaderFactory(name);\n loader = factory({\n entity: this.entity,\n tenant: model.tenant,\n modelId: model.modelId\n });\n this.cache.setDataLoader(cacheParams, loader);\n return loader;\n }\n\n private async loadMany<T extends CmsEntryValues = CmsEntryValues>(\n loader: DataLoaders,\n params: GetLoaderParams,\n ids: readonly string[]\n ): Promise<CmsStorageEntry<T>[]> {\n let results: CmsStorageEntry<T>[] = [];\n try {\n results = await this.getLoader(loader, params).loadMany(ids);\n if (Array.isArray(results) === true) {\n return results.reduce<CmsStorageEntry<T>[]>((acc, res) => {\n if (Array.isArray(res) === false) {\n if (res && res.message) {\n throw new WebinyError(res.message, res.code, {\n ...res,\n data: JSON.stringify(res.data || {})\n });\n }\n throw new WebinyError(\n \"Result from the data loader must be an array of arrays which contain requested items.\",\n \"DATA_LOADER_RESULTS_ERROR\",\n {\n ...params,\n loader\n }\n );\n }\n acc.push(...res);\n return acc;\n }, []);\n }\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Data loader error.\",\n ex.code || \"DATA_LOADER_ERROR\",\n {\n error: ex,\n ...params,\n loader,\n ids\n }\n );\n }\n throw new WebinyError(\n `Data loader did not return array of items or empty array.`,\n \"INVALID_DATA_LOADER_RESULT\",\n {\n loader,\n ids,\n results\n }\n );\n }\n\n public clearAll(params?: DataLoadersHandlerInterfaceClearAllParams): void {\n this.cache.clearAll(params);\n }\n}\n"],"names":["DataLoadersHandler","params","DataLoaderCache","ids","id","entryId","parseIdentifier","name","model","cacheParams","loader","factory","getDataLoaderFactory","results","Array","acc","res","WebinyError","J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b,QAAQ,IAAI,CAAC,MAAM;YACnB,QAAQH,MAAM,MAAM;YACpB,SAASA,MAAM,OAAO;QAC1B;QACA,IAAI,CAAC,KAAK,CAAC,aAAa,CAACC,aAAaC;QACtC,OAAOA;IACX;IAEA,MAAc,SACVA,MAAmB,EACnBT,MAAuB,EACvBE,GAAsB,EACO;QAC7B,IAAIU,UAAgC,EAAE;QACtC,IAAI;YACAA,UAAU,MAAM,IAAI,CAAC,SAAS,CAACH,QAAQT,QAAQ,QAAQ,CAACE;YACxD,IAAIW,AAA2B,SAA3BA,MAAM,OAAO,CAACD,UACd,OAAOA,QAAQ,MAAM,CAAuB,CAACE,KAAKC;gBAC9C,IAAIF,AAAuB,UAAvBA,MAAM,OAAO,CAACE,MAAgB;oBAC9B,IAAIA,OAAOA,IAAI,OAAO,EAClB,MAAM,IAAIC,MAAYD,IAAI,OAAO,EAAEA,IAAI,IAAI,EAAE;wBACzC,GAAGA,GAAG;wBACN,MAAME,KAAK,SAAS,CAACF,IAAI,IAAI,IAAI,CAAC;oBACtC;oBAEJ,MAAM,IAAIC,MACN,yFACA,6BACA;wBACI,GAAGhB,MAAM;wBACTS;oBACJ;gBAER;gBACAK,IAAI,IAAI,IAAIC;gBACZ,OAAOD;YACX,GAAG,EAAE;QAEb,EAAE,OAAOI,IAAI;YACT,MAAM,IAAIF,MACNE,GAAG,OAAO,IAAI,sBACdA,GAAG,IAAI,IAAI,qBACX;gBACI,OAAOA;gBACP,GAAGlB,MAAM;gBACTS;gBACAP;YACJ;QAER;QACA,MAAM,IAAIc,MACN,6DACA,8BACA;YACIP;YACAP;YACAU;QACJ;IAER;IAEO,SAASZ,MAAkD,EAAQ;QACtE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAACA;IACxB;AACJ"}
@@ -1,4 +1,4 @@
1
- import { BoolQueryConfig } from "@webiny/api-elasticsearch/types";
1
+ import type { QueryDslBoolQuery as BoolQueryConfig } from "@webiny/api-opensearch/types.js";
2
2
  /**
3
3
  * This function will assign a minimum_should_match for the query if conditions are met:
4
4
  * * should is an array
@@ -1,32 +1,9 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.assignMinimumShouldMatchToQuery = void 0;
7
- /**
8
- * This function will assign a minimum_should_match for the query if conditions are met:
9
- * * should is an array
10
- * * it is not empty
11
- * * minimum_should_match is not already set
12
- *
13
- *
14
- * By the default we set it to 1 as we want at least one OR condition to produce results.
15
- *
16
- * Users can modify minimum_should_match value via the body or query modification plugins.
17
- */
18
-
19
- const assignMinimumShouldMatchToQuery = ({
20
- query,
21
- value = 1
22
- }) => {
23
- if (!Array.isArray(query.should)) {
24
- return;
25
- } else if (query.should.length === 0) {
26
- return;
27
- } else if (query.minimum_should_match) {
28
- return;
29
- }
30
- query.minimum_should_match = value > 0 ? value : 1;
1
+ const assignMinimumShouldMatchToQuery = ({ query, value = 1 })=>{
2
+ if (!Array.isArray(query.should)) return;
3
+ if (0 === query.should.length) return;
4
+ if (query.minimum_should_match) return;
5
+ query.minimum_should_match = value > 0 ? value : 1;
31
6
  };
32
- exports.assignMinimumShouldMatchToQuery = assignMinimumShouldMatchToQuery;
7
+ export { assignMinimumShouldMatchToQuery };
8
+
9
+ //# sourceMappingURL=assignMinimumShouldMatchToQuery.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["assignMinimumShouldMatchToQuery","query","value","Array","isArray","should","length","minimum_should_match"],"sources":["assignMinimumShouldMatchToQuery.ts"],"sourcesContent":["import { BoolQueryConfig } from \"@webiny/api-elasticsearch/types\";\n\n/**\n * This function will assign a minimum_should_match for the query if conditions are met:\n * * should is an array\n * * it is not empty\n * * minimum_should_match is not already set\n *\n *\n * By the default we set it to 1 as we want at least one OR condition to produce results.\n *\n * Users can modify minimum_should_match value via the body or query modification plugins.\n */\ninterface Params {\n query: BoolQueryConfig;\n value?: number;\n}\nexport const assignMinimumShouldMatchToQuery = ({ query, value = 1 }: Params): void => {\n if (!Array.isArray(query.should)) {\n return;\n } else if (query.should.length === 0) {\n return;\n } else if (query.minimum_should_match) {\n return;\n }\n query.minimum_should_match = value > 0 ? value : 1;\n};\n"],"mappings":";;;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKO,MAAMA,+BAA+B,GAAG,CAAC;EAAEC,KAAK;EAAEC,KAAK,GAAG;AAAU,CAAC,KAAW;EACnF,IAAI,CAACC,KAAK,CAACC,OAAO,CAACH,KAAK,CAACI,MAAM,CAAC,EAAE;IAC9B;EACJ,CAAC,MAAM,IAAIJ,KAAK,CAACI,MAAM,CAACC,MAAM,KAAK,CAAC,EAAE;IAClC;EACJ,CAAC,MAAM,IAAIL,KAAK,CAACM,oBAAoB,EAAE;IACnC;EACJ;EACAN,KAAK,CAACM,oBAAoB,GAAGL,KAAK,GAAG,CAAC,GAAGA,KAAK,GAAG,CAAC;AACtD,CAAC;AAAC"}
1
+ {"version":3,"file":"operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js","sources":["../../../../src/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.ts"],"sourcesContent":["import type { QueryDslBoolQuery as BoolQueryConfig } from \"@webiny/api-opensearch/types.js\";\n\n/**\n * This function will assign a minimum_should_match for the query if conditions are met:\n * * should is an array\n * * it is not empty\n * * minimum_should_match is not already set\n *\n *\n * By the default we set it to 1 as we want at least one OR condition to produce results.\n *\n * Users can modify minimum_should_match value via the body or query modification plugins.\n */\ninterface Params {\n query: BoolQueryConfig;\n value?: number;\n}\nexport const assignMinimumShouldMatchToQuery = ({ query, value = 1 }: Params): void => {\n if (!Array.isArray(query.should)) {\n return;\n } else if (query.should.length === 0) {\n return;\n } else if (query.minimum_should_match) {\n return;\n }\n query.minimum_should_match = value > 0 ? value : 1;\n};\n"],"names":["assignMinimumShouldMatchToQuery","query","value","Array"],"mappings":"AAiBO,MAAMA,kCAAkC,CAAC,EAAEC,KAAK,EAAEC,QAAQ,CAAC,EAAU;IACxE,IAAI,CAACC,MAAM,OAAO,CAACF,MAAM,MAAM,GAC3B;IACG,IAAIA,AAAwB,MAAxBA,MAAM,MAAM,CAAC,MAAM,EAC1B;IACG,IAAIA,MAAM,oBAAoB,EACjC;IAEJA,MAAM,oBAAoB,GAAGC,QAAQ,IAAIA,QAAQ;AACrD"}
@@ -1,13 +1,32 @@
1
- import { PluginsContainer } from "@webiny/plugins";
2
- import { CmsEntryListParams, CmsEntryListWhere, CmsModel } from "@webiny/api-headless-cms/types";
3
- import { PrimitiveValue, SearchBody } from "@webiny/api-elasticsearch/types";
4
- interface Params {
5
- plugins: PluginsContainer;
1
+ import type { OpenSearchQueryBuilderOperatorRegistry } from "@webiny/api-opensearch/exports/api/opensearch.js";
2
+ import type { OpenSearchFieldFactory } from "@webiny/api-opensearch/exports/api/opensearch.js";
3
+ import type { CmsEntryListParams, CmsEntryListWhere, CmsModel } from "@webiny/api-headless-cms/types/index.js";
4
+ import type { CmsEntryOpenSearchBodyModifier } from "../../../features/CmsEntryOpenSearchBodyModifier/index.js";
5
+ import type { CmsEntryOpenSearchSortModifier } from "../../../features/CmsEntryOpenSearchSortModifier/index.js";
6
+ import type { CmsEntryOpenSearchQueryModifier } from "../../../features/CmsEntryOpenSearchQueryModifier/index.js";
7
+ import type { CmsEntryOpenSearchValueSearchRegistry } from "../../../features/CmsEntryOpenSearchValueSearch/index.js";
8
+ import type { CmsEntryOpenSearchFullTextSearch } from "../../../features/CmsEntryOpenSearchFullTextSearch/index.js";
9
+ import type { PrimitiveValue, SearchBody } from "@webiny/api-opensearch/types.js";
10
+ import { CmsModelFieldToGraphQLRegistry } from "@webiny/api-headless-cms/features/graphql/index.js";
11
+ import { CmsEntryOpenSearchFieldIndexRegistry } from "../../../features/CmsEntryOpenSearchFieldIndex/index.js";
12
+ import type { CmsEntryOpenSearchFilterRegistry } from "../../../features/CmsEntryOpenSearchFilter/index.js";
13
+ interface ICreateElasticsearchBodyParams {
14
+ operatorRegistry: OpenSearchQueryBuilderOperatorRegistry.Interface;
6
15
  model: CmsModel;
16
+ shared: boolean;
17
+ fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface;
18
+ fieldIndexRegistry: CmsEntryOpenSearchFieldIndexRegistry.Interface;
19
+ bodyModifiers: CmsEntryOpenSearchBodyModifier.Interface[];
20
+ sortModifiers: CmsEntryOpenSearchSortModifier.Interface[];
21
+ queryModifiers: CmsEntryOpenSearchQueryModifier.Interface[];
22
+ valueSearchRegistry: CmsEntryOpenSearchValueSearchRegistry.Interface;
23
+ fullTextSearches: CmsEntryOpenSearchFullTextSearch.Interface[];
24
+ filterRegistry: CmsEntryOpenSearchFilterRegistry.Interface;
25
+ fieldFactory: OpenSearchFieldFactory.Interface;
7
26
  params: Omit<CmsEntryListParams, "where" | "after"> & {
8
27
  where: CmsEntryListWhere;
9
28
  after?: PrimitiveValue[];
10
29
  };
11
30
  }
12
- export declare const createElasticsearchBody: ({ plugins, model, params }: Params) => SearchBody;
31
+ export declare const createElasticsearchBody: ({ operatorRegistry, model, shared, params, fieldRegistry, fieldIndexRegistry, bodyModifiers, sortModifiers, queryModifiers, valueSearchRegistry, fullTextSearches, filterRegistry, fieldFactory }: ICreateElasticsearchBodyParams) => SearchBody;
13
32
  export {};