@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,175 +1,80 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.prepareEntryToIndex = exports.extractEntriesFromIndex = void 0;
8
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
- var _error = _interopRequireDefault(require("@webiny/error"));
10
- const prepareEntryToIndex = params => {
11
- const {
12
- plugins,
13
- storageEntry,
14
- entry,
15
- model
16
- } = params;
17
- const {
18
- fieldIndexPlugins,
19
- defaultIndexFieldPlugin,
20
- fieldTypePlugins
21
- } = setupEntriesIndexHelpers({
22
- plugins
23
- });
24
- function getFieldIndexPlugin(fieldType) {
25
- return fieldIndexPlugins[fieldType] || defaultIndexFieldPlugin;
26
- }
27
- function getFieldTypePlugin(fieldType) {
28
- const pl = fieldTypePlugins[fieldType];
29
- if (pl) {
30
- return pl;
31
- }
32
- throw new _error.default(`Missing field type plugin "${fieldType}". Prepare entry for index.`);
33
- }
34
-
35
- // These objects will contain values processed by field index plugins
36
- const values = {};
37
- const rawValues = {};
38
-
39
- // We're only interested in current model fields.
40
- for (const field of model.fields) {
41
- if (storageEntry.values.hasOwnProperty(field.storageId) === false) {
42
- continue;
43
- }
44
- const targetFieldPlugin = getFieldIndexPlugin(field.type);
45
-
46
- // TODO: remove this `if` once we convert this plugin to proper plugin class
47
- if (!targetFieldPlugin || !targetFieldPlugin.toIndex) {
48
- continue;
49
- }
50
- const {
51
- value,
52
- rawValue
53
- } = targetFieldPlugin.toIndex({
54
- plugins,
55
- model,
56
- field,
57
- rawValue: entry.values[field.storageId],
58
- value: storageEntry.values[field.storageId],
59
- getFieldIndexPlugin,
60
- getFieldTypePlugin
61
- });
62
- if (typeof value !== "undefined") {
63
- values[field.storageId] = value;
1
+ import { WebinyError } from "@webiny/error";
2
+ import { getFieldIdentifier, getFieldIdentifiers } from "./fieldIdentifier.js";
3
+ const prepareEntryToIndex = (params)=>{
4
+ const { fieldIndexRegistry, storageEntry, entry, model } = params;
5
+ function getFieldIndex(type) {
6
+ const fieldIndexing = fieldIndexRegistry.get(type);
7
+ if (fieldIndexing) return fieldIndexing;
8
+ return fieldIndexRegistry.getDefault();
64
9
  }
65
- if (typeof rawValue !== "undefined") {
66
- rawValues[field.storageId] = rawValue;
10
+ const values = {};
11
+ const rawValues = {};
12
+ for (const field of model.fields){
13
+ const identifier = getFieldIdentifier(storageEntry.values, field);
14
+ if (!identifier) continue;
15
+ const fieldIndex = getFieldIndex(field.type);
16
+ const { value, rawValue } = fieldIndex.toIndex({
17
+ model,
18
+ field,
19
+ rawValue: entry.values[identifier],
20
+ value: storageEntry.values[identifier],
21
+ getFieldIndex
22
+ });
23
+ if (void 0 !== value) values[identifier] = value;
24
+ if (void 0 !== rawValue) rawValues[identifier] = rawValue;
67
25
  }
68
- }
69
- return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
70
- values,
71
- rawValues
72
- });
26
+ return {
27
+ ...storageEntry,
28
+ values,
29
+ rawValues
30
+ };
73
31
  };
74
- exports.prepareEntryToIndex = prepareEntryToIndex;
75
- const setupEntriesIndexHelpers = ({
76
- plugins: pluginsContainer
77
- }) => {
78
- const plugins = pluginsContainer.byType("cms-model-field-to-elastic-search");
79
- const fieldIndexPlugins = {};
80
- for (const plugin of plugins.reverse()) {
81
- if (fieldIndexPlugins[plugin.fieldType]) {
82
- continue;
32
+ const extractEntriesFromIndex = ({ fieldRegistry, fieldIndexRegistry, entries, model })=>{
33
+ function getFieldIndex(type) {
34
+ const fieldIndex = fieldIndexRegistry.get(type);
35
+ if (fieldIndex) return fieldIndex;
36
+ return fieldIndexRegistry.getDefault();
83
37
  }
84
- fieldIndexPlugins[plugin.fieldType] = plugin;
85
- }
86
- // we will use this plugin if no targeted plugin found
87
- const defaultIndexFieldPlugin = plugins.find(plugin => plugin.fieldType === "*");
88
-
89
- // CmsModelFieldToGraphQLPlugin plugins
90
- const fieldTypePlugins = pluginsContainer.byType("cms-model-field-to-graphql").reduce((plugins, plugin) => (0, _objectSpread2.default)((0, _objectSpread2.default)({}, plugins), {}, {
91
- [plugin.fieldType]: plugin
92
- }), {});
93
- return {
94
- fieldIndexPlugins,
95
- defaultIndexFieldPlugin,
96
- fieldTypePlugins
97
- };
98
- };
99
- const extractEntriesFromIndex = ({
100
- plugins,
101
- entries,
102
- model
103
- }) => {
104
- const {
105
- fieldIndexPlugins,
106
- defaultIndexFieldPlugin,
107
- fieldTypePlugins
108
- } = setupEntriesIndexHelpers({
109
- plugins
110
- });
111
- function getFieldIndexPlugin(fieldType) {
112
- return fieldIndexPlugins[fieldType] || defaultIndexFieldPlugin;
113
- }
114
- function getFieldTypePlugin(fieldType) {
115
- return fieldTypePlugins[fieldType];
116
- }
117
- const list = [];
118
- for (const entry of entries) {
119
- // This object will contain values processed by field index plugins
120
- const indexValues = {};
121
-
122
- // We only consider fields that are present in the model
123
- for (const field of model.fields) {
124
- const fieldTypePlugin = fieldTypePlugins[field.type];
125
- if (!fieldTypePlugin) {
126
- throw new _error.default(`Missing field type plugin "${field.type}". Extract entries from index.`);
127
- }
128
- const targetFieldPlugin = getFieldIndexPlugin(field.type);
129
- if (!targetFieldPlugin || !targetFieldPlugin.fromIndex) {
130
- continue;
131
- }
132
- try {
133
- indexValues[field.storageId] = targetFieldPlugin.fromIndex({
134
- plugins,
135
- model,
136
- field,
137
- getFieldIndexPlugin,
138
- getFieldTypePlugin,
139
- value: entry.values[field.storageId],
140
- /**
141
- * Possibly no rawValues so we must check for the existence of the field.
142
- */
143
- rawValue: entry.rawValues ? entry.rawValues[field.storageId] : null
144
- });
145
- } catch (ex) {
146
- throw new _error.default(ex.message || "Could not transform entry field from index.", ex.code || "FIELD_FROM_INDEX_ERROR", {
147
- field,
148
- entry
38
+ const list = [];
39
+ for (const entry of entries){
40
+ const indexValues = {};
41
+ for (const field of model.fields){
42
+ const fieldType = fieldRegistry.get(field.type);
43
+ if (!fieldType) throw new WebinyError(`Missing field type "${field.type}". Extract entries from index.`);
44
+ const fieldIndex = getFieldIndex(field.type);
45
+ const identifiers = getFieldIdentifiers(entry.values, entry.rawValues, field);
46
+ if (identifiers) try {
47
+ const key = identifiers.valueIdentifier;
48
+ const rawKey = identifiers.rawValueIdentifier;
49
+ indexValues[key] = fieldIndex.fromIndex({
50
+ model,
51
+ field,
52
+ getFieldIndex,
53
+ value: entry.values[key || rawKey],
54
+ rawValue: entry.rawValues ? entry.rawValues[rawKey || key] : null
55
+ });
56
+ } catch (ex) {
57
+ throw new WebinyError(ex.message || "Could not transform entry field from index.", ex.code || "FIELD_FROM_INDEX_ERROR", {
58
+ field,
59
+ entry
60
+ });
61
+ }
62
+ }
63
+ const newEntry = {
64
+ ...entry,
65
+ values: indexValues
66
+ };
67
+ delete newEntry["rawValues"];
68
+ delete newEntry["TYPE"];
69
+ delete newEntry["__type"];
70
+ delete newEntry["latest"];
71
+ delete newEntry["published"];
72
+ list.push({
73
+ ...newEntry
149
74
  });
150
- }
151
75
  }
152
- /**
153
- * Let's have a new entry so we do not modify the original one.
154
- */
155
- const newEntry = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, entry), {}, {
156
- values: indexValues
157
- });
158
- /**
159
- * If we want to remove the rawValues, TYPE, latest, published and __type, we must make them optional or ignore them.
160
- */
161
- // @ts-ignore
162
- delete newEntry["rawValues"];
163
- // @ts-ignore
164
- delete newEntry["TYPE"];
165
- // @ts-ignore
166
- delete newEntry["__type"];
167
- // @ts-ignore
168
- delete newEntry["latest"];
169
- // @ts-ignore
170
- delete newEntry["published"];
171
- list.push((0, _objectSpread2.default)({}, newEntry));
172
- }
173
- return list;
76
+ return list;
174
77
  };
175
- exports.extractEntriesFromIndex = extractEntriesFromIndex;
78
+ export { extractEntriesFromIndex, prepareEntryToIndex };
79
+
80
+ //# sourceMappingURL=entryIndexHelpers.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["prepareEntryToIndex","params","plugins","storageEntry","entry","model","fieldIndexPlugins","defaultIndexFieldPlugin","fieldTypePlugins","setupEntriesIndexHelpers","getFieldIndexPlugin","fieldType","getFieldTypePlugin","pl","WebinyError","values","rawValues","field","fields","hasOwnProperty","storageId","targetFieldPlugin","type","toIndex","value","rawValue","pluginsContainer","byType","plugin","reverse","find","reduce","extractEntriesFromIndex","entries","list","indexValues","fieldTypePlugin","fromIndex","ex","message","code","newEntry","push"],"sources":["entryIndexHelpers.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsEntry, CmsModel, CmsModelFieldToGraphQLPlugin } from \"@webiny/api-headless-cms/types\";\nimport { CmsIndexEntry, CmsModelFieldToElasticsearchPlugin } from \"~/types\";\nimport { PluginsContainer } from \"@webiny/plugins\";\n\ninterface SetupEntriesIndexHelpersParams {\n plugins: PluginsContainer;\n}\n\ninterface ExtractEntriesFromIndexParams extends SetupEntriesIndexHelpersParams {\n model: CmsModel;\n entries: CmsIndexEntry[];\n}\n\ninterface PrepareElasticsearchDataParams extends SetupEntriesIndexHelpersParams {\n model: CmsModel;\n entry: CmsEntry;\n storageEntry: CmsEntry;\n}\n\nexport const prepareEntryToIndex = (params: PrepareElasticsearchDataParams): CmsIndexEntry => {\n const { plugins, storageEntry, entry, model } = params;\n const { fieldIndexPlugins, defaultIndexFieldPlugin, fieldTypePlugins } =\n setupEntriesIndexHelpers({ plugins });\n\n function getFieldIndexPlugin(fieldType: string) {\n return fieldIndexPlugins[fieldType] || defaultIndexFieldPlugin;\n }\n\n function getFieldTypePlugin(fieldType: string) {\n const pl = fieldTypePlugins[fieldType];\n if (pl) {\n return pl;\n }\n throw new WebinyError(`Missing field type plugin \"${fieldType}\". Prepare entry for index.`);\n }\n\n // These objects will contain values processed by field index plugins\n const values: Record<string, string> = {};\n const rawValues: Record<string, string> = {};\n\n // We're only interested in current model fields.\n for (const field of model.fields) {\n if (storageEntry.values.hasOwnProperty(field.storageId) === false) {\n continue;\n }\n\n const targetFieldPlugin = getFieldIndexPlugin(field.type);\n\n // TODO: remove this `if` once we convert this plugin to proper plugin class\n if (!targetFieldPlugin || !targetFieldPlugin.toIndex) {\n continue;\n }\n\n const { value, rawValue } = targetFieldPlugin.toIndex({\n plugins,\n model,\n field,\n rawValue: entry.values[field.storageId],\n value: storageEntry.values[field.storageId],\n getFieldIndexPlugin,\n getFieldTypePlugin\n });\n\n if (typeof value !== \"undefined\") {\n values[field.storageId] = value;\n }\n\n if (typeof rawValue !== \"undefined\") {\n rawValues[field.storageId] = rawValue;\n }\n }\n return {\n ...storageEntry,\n values,\n rawValues\n } as CmsIndexEntry;\n};\n\nconst setupEntriesIndexHelpers = ({\n plugins: pluginsContainer\n}: SetupEntriesIndexHelpersParams) => {\n const plugins = pluginsContainer.byType<CmsModelFieldToElasticsearchPlugin>(\n \"cms-model-field-to-elastic-search\"\n );\n\n const fieldIndexPlugins: Record<string, CmsModelFieldToElasticsearchPlugin> = {};\n for (const plugin of plugins.reverse()) {\n if (fieldIndexPlugins[plugin.fieldType]) {\n continue;\n }\n fieldIndexPlugins[plugin.fieldType] = plugin;\n }\n // we will use this plugin if no targeted plugin found\n const defaultIndexFieldPlugin = plugins.find(plugin => plugin.fieldType === \"*\");\n\n // CmsModelFieldToGraphQLPlugin plugins\n const fieldTypePlugins: Record<string, CmsModelFieldToGraphQLPlugin> = pluginsContainer\n .byType<CmsModelFieldToGraphQLPlugin>(\"cms-model-field-to-graphql\")\n .reduce((plugins, plugin) => ({ ...plugins, [plugin.fieldType]: plugin }), {});\n\n return {\n fieldIndexPlugins,\n defaultIndexFieldPlugin,\n fieldTypePlugins\n };\n};\n\nexport const extractEntriesFromIndex = ({\n plugins,\n entries,\n model\n}: ExtractEntriesFromIndexParams): CmsEntry[] => {\n const { fieldIndexPlugins, defaultIndexFieldPlugin, fieldTypePlugins } =\n setupEntriesIndexHelpers({ plugins });\n\n function getFieldIndexPlugin(fieldType: string) {\n return fieldIndexPlugins[fieldType] || defaultIndexFieldPlugin;\n }\n\n function getFieldTypePlugin(fieldType: string) {\n return fieldTypePlugins[fieldType];\n }\n\n const list: CmsEntry[] = [];\n\n for (const entry of entries) {\n // This object will contain values processed by field index plugins\n const indexValues: Record<string, string> = {};\n\n // We only consider fields that are present in the model\n for (const field of model.fields) {\n const fieldTypePlugin = fieldTypePlugins[field.type];\n if (!fieldTypePlugin) {\n throw new WebinyError(\n `Missing field type plugin \"${field.type}\". Extract entries from index.`\n );\n }\n\n const targetFieldPlugin = getFieldIndexPlugin(field.type);\n if (!targetFieldPlugin || !targetFieldPlugin.fromIndex) {\n continue;\n }\n try {\n indexValues[field.storageId] = targetFieldPlugin.fromIndex({\n plugins,\n model,\n field,\n getFieldIndexPlugin,\n getFieldTypePlugin,\n value: entry.values[field.storageId],\n /**\n * Possibly no rawValues so we must check for the existence of the field.\n */\n rawValue: entry.rawValues ? entry.rawValues[field.storageId] : null\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not transform entry field from index.\",\n ex.code || \"FIELD_FROM_INDEX_ERROR\",\n {\n field,\n entry\n }\n );\n }\n }\n /**\n * Let's have a new entry so we do not modify the original one.\n */\n const newEntry: CmsEntry = {\n ...entry,\n values: indexValues\n };\n /**\n * If we want to remove the rawValues, TYPE, latest, published and __type, we must make them optional or ignore them.\n */\n // @ts-ignore\n delete newEntry[\"rawValues\"];\n // @ts-ignore\n delete newEntry[\"TYPE\"];\n // @ts-ignore\n delete newEntry[\"__type\"];\n // @ts-ignore\n delete newEntry[\"latest\"];\n // @ts-ignore\n delete newEntry[\"published\"];\n list.push({ ...newEntry });\n }\n\n return list;\n};\n"],"mappings":";;;;;;;;AAAA;AAoBO,MAAMA,mBAAmB,GAAIC,MAAsC,IAAoB;EAC1F,MAAM;IAAEC,OAAO;IAAEC,YAAY;IAAEC,KAAK;IAAEC;EAAM,CAAC,GAAGJ,MAAM;EACtD,MAAM;IAAEK,iBAAiB;IAAEC,uBAAuB;IAAEC;EAAiB,CAAC,GAClEC,wBAAwB,CAAC;IAAEP;EAAQ,CAAC,CAAC;EAEzC,SAASQ,mBAAmB,CAACC,SAAiB,EAAE;IAC5C,OAAOL,iBAAiB,CAACK,SAAS,CAAC,IAAIJ,uBAAuB;EAClE;EAEA,SAASK,kBAAkB,CAACD,SAAiB,EAAE;IAC3C,MAAME,EAAE,GAAGL,gBAAgB,CAACG,SAAS,CAAC;IACtC,IAAIE,EAAE,EAAE;MACJ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AAMD,QAAQ,EAAG;EAC9B;EAEA,OAAOP,IAAI;AACf,CAAC;AAAC"}
1
+ {"version":3,"file":"helpers/entryIndexHelpers.js","sources":["../../src/helpers/entryIndexHelpers.ts"],"sourcesContent":["import { WebinyError } from \"@webiny/error\";\nimport type { CmsEntry, CmsEntryValues, CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { CmsIndexEntry } from \"~/types.js\";\nimport { getFieldIdentifier, getFieldIdentifiers } from \"~/helpers/fieldIdentifier.js\";\nimport type { CmsModelFieldToGraphQLRegistry } from \"@webiny/api-headless-cms/exports/api/cms/graphql.js\";\nimport type {\n CmsEntryOpenSearchFieldIndex,\n CmsEntryOpenSearchFieldIndexRegistry\n} from \"~/features/CmsEntryOpenSearchFieldIndex/index.js\";\n\ninterface SetupEntriesIndexHelpersParams {\n fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface;\n fieldIndexRegistry: CmsEntryOpenSearchFieldIndexRegistry.Interface;\n}\n\ninterface ExtractEntriesFromIndexParams<\n T extends CmsEntryValues = CmsEntryValues\n> extends SetupEntriesIndexHelpersParams {\n model: CmsModel;\n entries: CmsIndexEntry<T>[];\n}\n\ninterface PrepareElasticsearchDataParams<T extends CmsEntryValues = CmsEntryValues> extends Omit<\n SetupEntriesIndexHelpersParams,\n \"fieldRegistry\"\n> {\n model: CmsModel;\n entry: CmsEntry<T>;\n storageEntry: CmsEntry<T>;\n}\n\nexport const prepareEntryToIndex = <T extends CmsEntryValues = CmsEntryValues>(\n params: PrepareElasticsearchDataParams<T>\n): CmsIndexEntry<T> => {\n const { fieldIndexRegistry, storageEntry, entry, model } = params;\n\n function getFieldIndex(type: string): CmsEntryOpenSearchFieldIndex.Interface {\n const fieldIndexing = fieldIndexRegistry.get(type);\n if (fieldIndexing) {\n return fieldIndexing;\n }\n return fieldIndexRegistry.getDefault();\n }\n\n // These objects will contain values processed by field index implementations\n const values: T = {} as T;\n const rawValues: T = {} as T;\n\n // We're only interested in current model fields.\n for (const field of model.fields) {\n const identifier = getFieldIdentifier(storageEntry.values, field) as keyof T;\n if (!identifier) {\n continue;\n }\n\n const fieldIndex = getFieldIndex(field.type);\n\n const { value, rawValue } = fieldIndex.toIndex({\n model,\n field,\n rawValue: entry.values[identifier],\n value: storageEntry.values[identifier],\n getFieldIndex\n });\n\n if (typeof value !== \"undefined\") {\n values[identifier] = value;\n }\n\n if (typeof rawValue !== \"undefined\") {\n rawValues[identifier] = rawValue;\n }\n }\n return {\n ...storageEntry,\n values,\n rawValues\n };\n};\n\nexport const extractEntriesFromIndex = <T extends CmsEntryValues = CmsEntryValues>({\n fieldRegistry,\n fieldIndexRegistry,\n entries,\n model\n}: ExtractEntriesFromIndexParams<T>): CmsEntry<T>[] => {\n function getFieldIndex(type: string): CmsEntryOpenSearchFieldIndex.Interface {\n const fieldIndex = fieldIndexRegistry.get(type);\n if (fieldIndex) {\n return fieldIndex;\n }\n return fieldIndexRegistry.getDefault();\n }\n\n const list: CmsEntry<T>[] = [];\n\n for (const entry of entries) {\n // This object will contain values processed by field index plugins\n const indexValues: T = {} as T;\n\n // We only consider fields that are present in the model\n for (const field of model.fields) {\n const fieldType = fieldRegistry.get(field.type);\n if (!fieldType) {\n throw new WebinyError(\n `Missing field type \"${field.type}\". Extract entries from index.`\n );\n }\n\n const fieldIndex = getFieldIndex(field.type);\n /**\n * We can safely cast as the code will not continue in case of no identifiers.\n */\n const identifiers = getFieldIdentifiers(entry.values, entry.rawValues, field);\n if (!identifiers) {\n continue;\n }\n try {\n const key = identifiers.valueIdentifier as keyof T;\n const rawKey = identifiers.rawValueIdentifier as keyof T;\n indexValues[key] = fieldIndex.fromIndex({\n model,\n field,\n getFieldIndex,\n value: entry.values[key || rawKey],\n /**\n * Possibly no rawValues so we must check for the existence of the field.\n */\n rawValue: entry.rawValues ? entry.rawValues[rawKey || key] : null\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not transform entry field from index.\",\n ex.code || \"FIELD_FROM_INDEX_ERROR\",\n {\n field,\n entry\n }\n );\n }\n }\n /**\n * Let's have a new entry so we do not modify the original one.\n */\n const newEntry: CmsEntry<T> = {\n ...entry,\n values: indexValues\n };\n /**\n * If we want to remove the rawValues, TYPE, latest, published and __type, we must make them optional or ignore them.\n */\n // @ts-expect-error\n delete newEntry[\"rawValues\"];\n // @ts-expect-error\n delete newEntry[\"TYPE\"];\n // @ts-expect-error\n delete newEntry[\"__type\"];\n // @ts-expect-error\n delete newEntry[\"latest\"];\n // @ts-expect-error\n delete newEntry[\"published\"];\n list.push({\n ...newEntry\n });\n }\n\n return list;\n};\n"],"names":["prepareEntryToIndex","params","fieldIndexRegistry","storageEntry","entry","model","getFieldIndex","type","fieldIndexing","values","rawValues","field","identifier","getFieldIdentifier","fieldIndex","value","rawValue","extractEntriesFromIndex","fieldRegistry","entries","list","indexValues","fieldType","WebinyError","identifiers","getFieldIdentifiers","key","rawKey","ex","newEntry"],"mappings":";;AA+BO,MAAMA,sBAAsB,CAC/BC;IAEA,MAAM,EAAEC,kBAAkB,EAAEC,YAAY,EAAEC,KAAK,EAAEC,KAAK,EAAE,GAAGJ;IAE3D,SAASK,cAAcC,IAAY;QAC/B,MAAMC,gBAAgBN,mBAAmB,GAAG,CAACK;QAC7C,IAAIC,eACA,OAAOA;QAEX,OAAON,mBAAmB,UAAU;IACxC;IAGA,MAAMO,SAAY,CAAC;IACnB,MAAMC,YAAe,CAAC;IAGtB,KAAK,MAAMC,SAASN,MAAM,MAAM,CAAE;QAC9B,MAAMO,aAAaC,mBAAmBV,aAAa,MAAM,EAAEQ;QAC3D,IAAI,CAACC,YACD;QAGJ,MAAME,aAAaR,cAAcK,MAAM,IAAI;QAE3C,MAAM,EAAEI,KAAK,EAAEC,QAAQ,EAAE,GAAGF,WAAW,OAAO,CAAC;YAC3CT;YACAM;YACA,UAAUP,MAAM,MAAM,CAACQ,WAAW;YAClC,OAAOT,aAAa,MAAM,CAACS,WAAW;YACtCN;QACJ;QAEA,IAAI,AAAiB,WAAVS,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GzB,KAAK;YACR,QAAQiB;QACZ;QAKA,OAAOQ,QAAQ,CAAC,YAAY;QAE5B,OAAOA,QAAQ,CAAC,OAAO;QAEvB,OAAOA,QAAQ,CAAC,SAAS;QAEzB,OAAOA,QAAQ,CAAC,SAAS;QAEzB,OAAOA,QAAQ,CAAC,YAAY;QAC5BT,KAAK,IAAI,CAAC;YACN,GAAGS,QAAQ;QACf;IACJ;IAEA,OAAOT;AACX"}
@@ -0,0 +1,6 @@
1
+ import type { CmsEntryValues, CmsModelField } from "@webiny/api-headless-cms/types/index.js";
2
+ export declare const getFieldIdentifier: (values: CmsEntryValues | null | undefined, field: CmsModelField) => string | undefined;
3
+ export declare const getFieldIdentifiers: (values: CmsEntryValues, rawValues: CmsEntryValues | null | undefined, field: CmsModelField) => {
4
+ valueIdentifier: string;
5
+ rawValueIdentifier: string;
6
+ } | null;
@@ -0,0 +1,23 @@
1
+ const fieldIdentifier_hasOwnProperty = (values = {}, property)=>{
2
+ if (!values) return false;
3
+ if (values.hasOwnProperty) return values.hasOwnProperty(property);
4
+ return void 0 !== values[property];
5
+ };
6
+ const getFieldIdentifier = (values, field)=>{
7
+ if (field.storageId && fieldIdentifier_hasOwnProperty(values, field.storageId)) return field.storageId;
8
+ if (fieldIdentifier_hasOwnProperty(values, field.fieldId)) return field.fieldId;
9
+ };
10
+ const getFieldIdentifiers = (values, rawValues, field)=>{
11
+ let valueIdentifier = getFieldIdentifier(values, field);
12
+ let rawValueIdentifier = getFieldIdentifier(rawValues, field);
13
+ if (!valueIdentifier && !rawValueIdentifier) return null;
14
+ if (!valueIdentifier) valueIdentifier = rawValueIdentifier;
15
+ if (!rawValueIdentifier) rawValueIdentifier = valueIdentifier;
16
+ return {
17
+ valueIdentifier,
18
+ rawValueIdentifier
19
+ };
20
+ };
21
+ export { getFieldIdentifier, getFieldIdentifiers };
22
+
23
+ //# sourceMappingURL=fieldIdentifier.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers/fieldIdentifier.js","sources":["../../src/helpers/fieldIdentifier.ts"],"sourcesContent":["import type { CmsEntryValues, CmsModelField } from \"@webiny/api-headless-cms/types/index.js\";\n\nconst hasOwnProperty = (\n values: CmsEntryValues | null | undefined = {},\n property: string\n): boolean => {\n if (!values) {\n return false;\n } else if (values.hasOwnProperty) {\n return values.hasOwnProperty(property);\n }\n return values[property] !== undefined;\n};\n\nexport const getFieldIdentifier = (\n values: CmsEntryValues | null | undefined,\n field: CmsModelField\n): string | undefined => {\n if (field.storageId && hasOwnProperty(values, field.storageId)) {\n return field.storageId;\n } else if (hasOwnProperty(values, field.fieldId)) {\n return field.fieldId;\n }\n return undefined;\n};\n\nexport const getFieldIdentifiers = (\n values: CmsEntryValues,\n rawValues: CmsEntryValues | null | undefined,\n field: CmsModelField\n) => {\n let valueIdentifier = getFieldIdentifier(values, field);\n let rawValueIdentifier = getFieldIdentifier(rawValues, field);\n if (!valueIdentifier && !rawValueIdentifier) {\n return null;\n }\n if (!valueIdentifier) {\n valueIdentifier = rawValueIdentifier as string;\n }\n if (!rawValueIdentifier) {\n rawValueIdentifier = valueIdentifier as string;\n }\n return {\n valueIdentifier,\n rawValueIdentifier\n };\n};\n"],"names":["hasOwnProperty","values","property","undefined","getFieldIdentifier","field","getFieldIdentifiers","rawValues","valueIdentifier","rawValueIdentifier"],"mappings":"AAEA,MAAMA,iCAAiB,CACnBC,SAA4C,CAAC,CAAC,EAC9CC;IAEA,IAAI,CAACD,QACD,OAAO;IACJ,IAAIA,OAAO,cAAc,EAC5B,OAAOA,OAAO,cAAc,CAACC;IAEjC,OAAOD,AAAqBE,WAArBF,MAAM,CAACC,SAAS;AAC3B;AAEO,MAAME,qBAAqB,CAC9BH,QACAI;IAEA,IAAIA,MAAM,SAAS,IAAIL,+BAAeC,QAAQI,MAAM,SAAS,GACzD,OAAOA,MAAM,SAAS;IACnB,IAAIL,+BAAeC,QAAQI,MAAM,OAAO,GAC3C,OAAOA,MAAM,OAAO;AAG5B;AAEO,MAAMC,sBAAsB,CAC/BL,QACAM,WACAF;IAEA,IAAIG,kBAAkBJ,mBAAmBH,QAAQI;IACjD,IAAII,qBAAqBL,mBAAmBG,WAAWF;IACvD,IAAI,CAACG,mBAAmB,CAACC,oBACrB,OAAO;IAEX,IAAI,CAACD,iBACDA,kBAAkBC;IAEtB,IAAI,CAACA,oBACDA,qBAAqBD;IAEzB,OAAO;QACHA;QACAC;IACJ;AACJ"}
@@ -1 +1,2 @@
1
- export * from "./entryIndexHelpers";
1
+ export * from "./entryIndexHelpers.js";
2
+ export * from "./fieldIdentifier.js";
package/helpers/index.js CHANGED
@@ -1,16 +1,2 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _entryIndexHelpers = require("./entryIndexHelpers");
7
- Object.keys(_entryIndexHelpers).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _entryIndexHelpers[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function () {
13
- return _entryIndexHelpers[key];
14
- }
15
- });
16
- });
1
+ export * from "./entryIndexHelpers.js";
2
+ export * from "./fieldIdentifier.js";
package/index.d.ts CHANGED
@@ -1,3 +1 @@
1
- import { StorageOperationsFactory } from "./types";
2
- export * from "./plugins";
3
- export declare const createStorageOperations: StorageOperationsFactory;
1
+ export { registerCmsOpenSearchStorageOperations } from "./feature.js";
package/index.js CHANGED
@@ -1,215 +1 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- var _exportNames = {
8
- createStorageOperations: true
9
- };
10
- exports.createStorageOperations = void 0;
11
- var _filters = _interopRequireDefault(require("@webiny/db-dynamodb/plugins/filters"));
12
- var _elasticsearch = _interopRequireDefault(require("./elasticsearch"));
13
- var _dynamoDb = _interopRequireDefault(require("./dynamoDb"));
14
- var _settings = require("./operations/settings");
15
- var _system = require("./operations/system");
16
- var _model = require("./operations/model");
17
- var _entry = require("./operations/entry");
18
- var _types = require("./types");
19
- var _table = require("./definitions/table");
20
- var _tableElasticsearch = require("./definitions/tableElasticsearch");
21
- var _group = require("./definitions/group");
22
- var _model2 = require("./definitions/model");
23
- var _entry2 = require("./definitions/entry");
24
- var _entryElasticsearch = require("./definitions/entryElasticsearch");
25
- var _system2 = require("./definitions/system");
26
- var _settings2 = require("./definitions/settings");
27
- var _createElasticsearchIndex = require("./elasticsearch/createElasticsearchIndex");
28
- var _plugins = require("@webiny/plugins");
29
- var _group2 = require("./operations/group");
30
- var _apiElasticsearch = require("@webiny/api-elasticsearch");
31
- var _indices = require("./elasticsearch/indices");
32
- var _deleteElasticsearchIndex = require("./elasticsearch/deleteElasticsearchIndex");
33
- var _plugins2 = require("./plugins");
34
- Object.keys(_plugins2).forEach(function (key) {
35
- if (key === "default" || key === "__esModule") return;
36
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
37
- if (key in exports && exports[key] === _plugins2[key]) return;
38
- Object.defineProperty(exports, key, {
39
- enumerable: true,
40
- get: function () {
41
- return _plugins2[key];
42
- }
43
- });
44
- });
45
- var _plugins3 = require("./operations/entry/elasticsearch/filtering/plugins");
46
- var _CmsEntryFilterPlugin = require("./plugins/CmsEntryFilterPlugin");
47
- var _apiHeadlessCms = require("@webiny/api-headless-cms");
48
- const createStorageOperations = params => {
49
- const {
50
- attributes,
51
- table,
52
- esTable,
53
- documentClient,
54
- elasticsearch,
55
- plugins: userPlugins
56
- } = params;
57
- const tableInstance = (0, _table.createTable)({
58
- table,
59
- documentClient
60
- });
61
- const tableElasticsearchInstance = (0, _tableElasticsearch.createElasticsearchTable)({
62
- table: esTable,
63
- documentClient
64
- });
65
- const entities = {
66
- settings: (0, _settings2.createSettingsEntity)({
67
- entityName: _types.ENTITIES.SETTINGS,
68
- table: tableInstance,
69
- attributes: attributes ? attributes[_types.ENTITIES.SETTINGS] : {}
70
- }),
71
- system: (0, _system2.createSystemEntity)({
72
- entityName: _types.ENTITIES.SYSTEM,
73
- table: tableInstance,
74
- attributes: attributes ? attributes[_types.ENTITIES.SYSTEM] : {}
75
- }),
76
- groups: (0, _group.createGroupEntity)({
77
- entityName: _types.ENTITIES.GROUPS,
78
- table: tableInstance,
79
- attributes: attributes ? attributes[_types.ENTITIES.GROUPS] : {}
80
- }),
81
- models: (0, _model2.createModelEntity)({
82
- entityName: _types.ENTITIES.MODELS,
83
- table: tableInstance,
84
- attributes: attributes ? attributes[_types.ENTITIES.MODELS] : {}
85
- }),
86
- entries: (0, _entry2.createEntryEntity)({
87
- entityName: _types.ENTITIES.ENTRIES,
88
- table: tableInstance,
89
- attributes: attributes ? attributes[_types.ENTITIES.ENTRIES] : {}
90
- }),
91
- entriesEs: (0, _entryElasticsearch.createEntryElasticsearchEntity)({
92
- entityName: _types.ENTITIES.ENTRIES_ES,
93
- table: tableElasticsearchInstance,
94
- attributes: attributes ? attributes[_types.ENTITIES.ENTRIES_ES] : {}
95
- })
96
- };
97
- const plugins = new _plugins.PluginsContainer([
98
- /**
99
- * DynamoDB filter plugins for the where conditions.
100
- */
101
- (0, _filters.default)(),
102
- /**
103
- * Field plugins for DynamoDB.
104
- */
105
- (0, _dynamoDb.default)(),
106
- /**
107
- * Field plugins for Elasticsearch.
108
- */
109
- (0, _elasticsearch.default)(),
110
- /**
111
- * Built-in Elasticsearch index templates.
112
- */
113
- (0, _indices.elasticsearchIndexPlugins)(),
114
- /**
115
- * Filter plugins used to apply filtering from where conditions to Elasticsearch query.
116
- */
117
- (0, _plugins3.createFilterPlugins)(),
118
- /**
119
- * User defined custom plugins.
120
- * They are at the end because we can then override existing plugins.
121
- */
122
- ...(userPlugins || [])]);
123
- return {
124
- name: "dynamodb:elasticsearch",
125
- beforeInit: async context => {
126
- /**
127
- * Attach the elasticsearch into context if it is not already attached.
128
- */
129
- if (!context.elasticsearch) {
130
- context.elasticsearch = elasticsearch;
131
- }
132
- /**
133
- * Pass the plugins to the parent context.
134
- */
135
- context.plugins.register([(0, _dynamoDb.default)()]);
136
- /**
137
- * We need to fetch all the plugin types in the list from the main container.
138
- * This way we do not need to register plugins in the storage plugins contains.
139
- */
140
- const types = [
141
- // Elasticsearch
142
- _apiElasticsearch.CompressionPlugin.type, _apiElasticsearch.ElasticsearchQueryBuilderOperatorPlugin.type,
143
- // Headless CMS
144
- "cms-model-field-to-graphql", _CmsEntryFilterPlugin.CmsEntryFilterPlugin.type, _plugins2.CmsEntryElasticsearchBodyModifierPlugin.type, _plugins2.CmsEntryElasticsearchFullTextSearchPlugin.type, _plugins2.CmsEntryElasticsearchIndexPlugin.type, _plugins2.CmsEntryElasticsearchQueryBuilderValueSearchPlugin.type, _plugins2.CmsEntryElasticsearchQueryModifierPlugin.type, _plugins2.CmsEntryElasticsearchSortModifierPlugin.type, _plugins2.CmsElasticsearchModelFieldPlugin.type, _apiHeadlessCms.StorageOperationsCmsModelPlugin.type];
145
- for (const type of types) {
146
- plugins.mergeByType(context.plugins, type);
147
- }
148
- },
149
- init: async context => {
150
- /**
151
- * We need to create indexes on before model create and on clone (create from).
152
- * Other apps create indexes on locale creation.
153
- */
154
- context.cms.onModelBeforeCreate.subscribe(async ({
155
- model
156
- }) => {
157
- await (0, _createElasticsearchIndex.createElasticsearchIndex)({
158
- elasticsearch,
159
- model,
160
- plugins
161
- });
162
- });
163
- context.cms.onModelBeforeCreateFrom.subscribe(async ({
164
- model
165
- }) => {
166
- await (0, _createElasticsearchIndex.createElasticsearchIndex)({
167
- elasticsearch,
168
- model,
169
- plugins
170
- });
171
- });
172
- context.cms.onModelAfterDelete.subscribe(async ({
173
- model
174
- }) => {
175
- await (0, _deleteElasticsearchIndex.deleteElasticsearchIndex)({
176
- elasticsearch,
177
- model
178
- });
179
- });
180
- context.cms.onModelInitialize.subscribe(async ({
181
- model
182
- }) => {
183
- await (0, _createElasticsearchIndex.createElasticsearchIndex)({
184
- elasticsearch,
185
- model,
186
- plugins
187
- });
188
- });
189
- },
190
- getEntities: () => entities,
191
- getTable: () => tableInstance,
192
- getEsTable: () => tableElasticsearchInstance,
193
- system: (0, _system.createSystemStorageOperations)({
194
- entity: entities.system
195
- }),
196
- settings: (0, _settings.createSettingsStorageOperations)({
197
- entity: entities.settings
198
- }),
199
- groups: (0, _group2.createGroupsStorageOperations)({
200
- entity: entities.groups,
201
- plugins
202
- }),
203
- models: (0, _model.createModelsStorageOperations)({
204
- entity: entities.models,
205
- elasticsearch
206
- }),
207
- entries: (0, _entry.createEntriesStorageOperations)({
208
- entity: entities.entries,
209
- esEntity: entities.entriesEs,
210
- plugins,
211
- elasticsearch
212
- })
213
- };
214
- };
215
- exports.createStorageOperations = createStorageOperations;
1
+ export { registerCmsOpenSearchStorageOperations } from "./feature.js";
@@ -0,0 +1,16 @@
1
+ import type DataLoader from "dataloader";
2
+ export interface CacheKeyParams {
3
+ name: string;
4
+ tenant: string;
5
+ modelId: string;
6
+ }
7
+ export interface ClearAllParams {
8
+ tenant: string;
9
+ }
10
+ export declare class DataLoaderCache {
11
+ private readonly cache;
12
+ getDataLoader<I = any, R = any>(params: CacheKeyParams): DataLoader<I, R> | null;
13
+ setDataLoader(params: CacheKeyParams, dataLoader: DataLoader<any, any>): void;
14
+ clearAll(params?: ClearAllParams): void;
15
+ private createKey;
16
+ }
@@ -0,0 +1,27 @@
1
+ class DataLoaderCache {
2
+ getDataLoader(params) {
3
+ const key = this.createKey(params);
4
+ return this.cache[key] || null;
5
+ }
6
+ setDataLoader(params, dataLoader) {
7
+ const key = this.createKey(params);
8
+ this.cache[key] = dataLoader;
9
+ }
10
+ clearAll(params) {
11
+ if (!params) {
12
+ for(const current in this.cache)this.cache[current].clearAll();
13
+ return;
14
+ }
15
+ const key = `${params.tenant}_`;
16
+ for(const current in this.cache)if (false !== current.startsWith(key)) this.cache[current].clearAll();
17
+ }
18
+ createKey(params) {
19
+ return `${params.tenant}_${params.modelId}_${params.name}`;
20
+ }
21
+ constructor(){
22
+ this.cache = {};
23
+ }
24
+ }
25
+ export { DataLoaderCache };
26
+
27
+ //# sourceMappingURL=DataLoaderCache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations/entry/dataLoader/DataLoaderCache.js","sources":["../../../../src/operations/entry/dataLoader/DataLoaderCache.ts"],"sourcesContent":["import type DataLoader from \"dataloader\";\n\nexport interface CacheKeyParams {\n name: string;\n tenant: string;\n modelId: string;\n}\n\nexport interface ClearAllParams {\n tenant: string;\n}\n\nexport class DataLoaderCache {\n private readonly cache: Record<string, DataLoader<any, any>> = {};\n\n public getDataLoader<I = any, R = any>(params: CacheKeyParams): DataLoader<I, R> | null {\n const key = this.createKey(params);\n\n return this.cache[key] || null;\n }\n\n public setDataLoader(params: CacheKeyParams, dataLoader: DataLoader<any, any>): void {\n const key = this.createKey(params);\n this.cache[key] = dataLoader;\n }\n\n public clearAll(params?: ClearAllParams): void {\n if (!params) {\n for (const current in this.cache) {\n this.cache[current].clearAll();\n }\n return;\n }\n const key = `${params.tenant}_`;\n for (const current in this.cache) {\n if (current.startsWith(key) === false) {\n continue;\n }\n this.cache[current].clearAll();\n }\n }\n\n private createKey(params: CacheKeyParams): string {\n return `${params.tenant}_${params.modelId}_${params.name}`;\n }\n}\n"],"names":["DataLoaderCache","params","key","dataLoader","current"],"mappings":"AAYO,MAAMA;IAGF,cAAgCC,MAAsB,EAA2B;QACpF,MAAMC,MAAM,IAAI,CAAC,SAAS,CAACD;QAE3B,OAAO,IAAI,CAAC,KAAK,CAACC,IAAI,IAAI;IAC9B;IAEO,cAAcD,MAAsB,EAAEE,UAAgC,EAAQ;QACjF,MAAMD,MAAM,IAAI,CAAC,SAAS,CAACD;QAC3B,IAAI,CAAC,KAAK,CAACC,IAAI,GAAGC;IACtB;IAEO,SAASF,MAAuB,EAAQ;QAC3C,IAAI,CAACA,QAAQ;YACT,IAAK,MAAMG,WAAW,IAAI,CAAC,KAAK,CAC5B,IAAI,CAAC,KAAK,CAACA,QAAQ,CAAC,QAAQ;YAEhC;QACJ;QACA,MAAMF,MAAM,GAAGD,OAAO,MAAM,CAAC,CAAC,CAAC;QAC/B,IAAK,MAAMG,WAAW,IAAI,CAAC,KAAK,CAC5B,IAAIA,AAA4B,UAA5BA,QAAQ,UAAU,CAACF,MAGvB,IAAI,CAAC,KAAK,CAACE,QAAQ,CAAC,QAAQ;IAEpC;IAEQ,UAAUH,MAAsB,EAAU;QAC9C,OAAO,GAAGA,OAAO,MAAM,CAAC,CAAC,EAAEA,OAAO,OAAO,CAAC,CAAC,EAAEA,OAAO,IAAI,EAAE;IAC9D;;aA/BiB,KAAK,GAAyC,CAAC;;AAgCpE"}
@@ -0,0 +1 @@
1
+ export declare const CMS_ENTRY_BATCH_SCHEDULE_WAIT: number;
@@ -0,0 +1,5 @@
1
+ const batchScheduleWaitEnv = Number(process.env.WEBINY_API_CMS_ENTRY_BATCH_SCHEDULE_WAIT || "0");
2
+ const CMS_ENTRY_BATCH_SCHEDULE_WAIT = isNaN(batchScheduleWaitEnv) ? 0 : batchScheduleWaitEnv;
3
+ export { CMS_ENTRY_BATCH_SCHEDULE_WAIT };
4
+
5
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations/entry/dataLoader/constants.js","sources":["../../../../src/operations/entry/dataLoader/constants.ts"],"sourcesContent":["const batchScheduleWaitEnv = Number(process.env.WEBINY_API_CMS_ENTRY_BATCH_SCHEDULE_WAIT || \"0\");\nexport const CMS_ENTRY_BATCH_SCHEDULE_WAIT = isNaN(batchScheduleWaitEnv) ? 0 : batchScheduleWaitEnv;\n"],"names":["batchScheduleWaitEnv","Number","process","CMS_ENTRY_BATCH_SCHEDULE_WAIT","isNaN"],"mappings":"AAAA,MAAMA,uBAAuBC,OAAOC,QAAQ,GAAG,CAAC,wCAAwC,IAAI;AACrF,MAAMC,gCAAgCC,MAAMJ,wBAAwB,IAAIA"}