@webiny/api-headless-cms-ddb-es 0.0.0-unstable.e53eceafb5 → 0.0.0-unstable.e6f0dc8ca7

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 (431) hide show
  1. package/README.md +6 -30
  2. package/configurations.d.ts +7 -7
  3. package/configurations.js +16 -26
  4. package/configurations.js.map +1 -1
  5. package/definitions/entry.d.ts +4 -6
  6. package/definitions/entry.js +5 -174
  7. package/definitions/entry.js.map +1 -1
  8. package/definitions/group.d.ts +6 -7
  9. package/definitions/group.js +5 -58
  10. package/definitions/group.js.map +1 -1
  11. package/definitions/model.d.ts +6 -7
  12. package/definitions/model.js +5 -102
  13. package/definitions/model.js.map +1 -1
  14. package/definitions/types.d.ts +61 -0
  15. package/definitions/types.js +3 -0
  16. package/definitions/types.js.map +1 -0
  17. package/elasticsearch/createElasticsearchIndex.d.ts +4 -4
  18. package/elasticsearch/createElasticsearchIndex.js +61 -27
  19. package/elasticsearch/createElasticsearchIndex.js.map +1 -1
  20. package/elasticsearch/deleteElasticsearchIndex.d.ts +2 -2
  21. package/elasticsearch/deleteElasticsearchIndex.js +3 -10
  22. package/elasticsearch/deleteElasticsearchIndex.js.map +1 -1
  23. package/exports/api/cms/opensearch.d.ts +9 -0
  24. package/exports/api/cms/opensearch.js +11 -0
  25. package/exports/api/cms/opensearch.js.map +1 -0
  26. package/feature.d.ts +1 -0
  27. package/feature.js +188 -0
  28. package/feature.js.map +1 -0
  29. package/features/CmsEntryOpenSearchBodyModifier/abstractions.d.ts +16 -0
  30. package/features/CmsEntryOpenSearchBodyModifier/abstractions.js +4 -0
  31. package/features/CmsEntryOpenSearchBodyModifier/abstractions.js.map +1 -0
  32. package/features/CmsEntryOpenSearchBodyModifier/index.d.ts +1 -0
  33. package/features/CmsEntryOpenSearchBodyModifier/index.js +3 -0
  34. package/features/CmsEntryOpenSearchBodyModifier/index.js.map +1 -0
  35. package/features/CmsEntryOpenSearchFieldIndex/CmsEntryOpenSearchFieldIndexRegistry.d.ts +13 -0
  36. package/features/CmsEntryOpenSearchFieldIndex/CmsEntryOpenSearchFieldIndexRegistry.js +36 -0
  37. package/features/CmsEntryOpenSearchFieldIndex/CmsEntryOpenSearchFieldIndexRegistry.js.map +1 -0
  38. package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndex.d.ts +35 -0
  39. package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndex.js +4 -0
  40. package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndex.js.map +1 -0
  41. package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndexRegistry.d.ts +11 -0
  42. package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndexRegistry.js +4 -0
  43. package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndexRegistry.js.map +1 -0
  44. package/features/CmsEntryOpenSearchFieldIndex/constants.d.ts +1 -0
  45. package/features/CmsEntryOpenSearchFieldIndex/constants.js +3 -0
  46. package/features/CmsEntryOpenSearchFieldIndex/constants.js.map +1 -0
  47. package/features/CmsEntryOpenSearchFieldIndex/feature.d.ts +4 -0
  48. package/features/CmsEntryOpenSearchFieldIndex/feature.js +24 -0
  49. package/features/CmsEntryOpenSearchFieldIndex/feature.js.map +1 -0
  50. package/features/CmsEntryOpenSearchFieldIndex/fields/DateTimeFieldIndex.d.ts +11 -0
  51. package/{elasticsearch/indexing/dateTimeIndexing.js → features/CmsEntryOpenSearchFieldIndex/fields/DateTimeFieldIndex.js} +21 -32
  52. package/features/CmsEntryOpenSearchFieldIndex/fields/DateTimeFieldIndex.js.map +1 -0
  53. package/features/CmsEntryOpenSearchFieldIndex/fields/DefaultFieldIndex.d.ts +10 -0
  54. package/features/CmsEntryOpenSearchFieldIndex/fields/DefaultFieldIndex.js +39 -0
  55. package/features/CmsEntryOpenSearchFieldIndex/fields/DefaultFieldIndex.js.map +1 -0
  56. package/features/CmsEntryOpenSearchFieldIndex/fields/JsonFieldIndex.d.ts +10 -0
  57. package/features/CmsEntryOpenSearchFieldIndex/fields/JsonFieldIndex.js +22 -0
  58. package/features/CmsEntryOpenSearchFieldIndex/fields/JsonFieldIndex.js.map +1 -0
  59. package/features/CmsEntryOpenSearchFieldIndex/fields/LongTextFieldIndex.d.ts +10 -0
  60. package/features/CmsEntryOpenSearchFieldIndex/fields/LongTextFieldIndex.js +25 -0
  61. package/features/CmsEntryOpenSearchFieldIndex/fields/LongTextFieldIndex.js.map +1 -0
  62. package/features/CmsEntryOpenSearchFieldIndex/fields/NumberFieldIndex.d.ts +11 -0
  63. package/{elasticsearch/indexing/numberIndexing.js → features/CmsEntryOpenSearchFieldIndex/fields/NumberFieldIndex.js} +11 -15
  64. package/features/CmsEntryOpenSearchFieldIndex/fields/NumberFieldIndex.js.map +1 -0
  65. package/features/CmsEntryOpenSearchFieldIndex/fields/ObjectFieldIndex.d.ts +10 -0
  66. package/features/CmsEntryOpenSearchFieldIndex/fields/ObjectFieldIndex.js +158 -0
  67. package/features/CmsEntryOpenSearchFieldIndex/fields/ObjectFieldIndex.js.map +1 -0
  68. package/features/CmsEntryOpenSearchFieldIndex/fields/RichTextFieldIndex.d.ts +10 -0
  69. package/features/CmsEntryOpenSearchFieldIndex/fields/RichTextFieldIndex.js +22 -0
  70. package/features/CmsEntryOpenSearchFieldIndex/fields/RichTextFieldIndex.js.map +1 -0
  71. package/features/CmsEntryOpenSearchFieldIndex/index.d.ts +3 -0
  72. package/features/CmsEntryOpenSearchFieldIndex/index.js +5 -0
  73. package/features/CmsEntryOpenSearchFieldIndex/index.js.map +1 -0
  74. package/features/CmsEntryOpenSearchFilter/CmsEntryOpenSearchFilterRegistry.d.ts +11 -0
  75. package/features/CmsEntryOpenSearchFilter/CmsEntryOpenSearchFilterRegistry.js +38 -0
  76. package/features/CmsEntryOpenSearchFilter/CmsEntryOpenSearchFilterRegistry.js.map +1 -0
  77. package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilter.d.ts +37 -0
  78. package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilter.js +4 -0
  79. package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilter.js.map +1 -0
  80. package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilterRegistry.d.ts +9 -0
  81. package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilterRegistry.js +4 -0
  82. package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilterRegistry.js.map +1 -0
  83. package/features/CmsEntryOpenSearchFilter/constants.d.ts +1 -0
  84. package/features/CmsEntryOpenSearchFilter/constants.js +3 -0
  85. package/features/CmsEntryOpenSearchFilter/constants.js.map +1 -0
  86. package/features/CmsEntryOpenSearchFilter/feature.d.ts +4 -0
  87. package/features/CmsEntryOpenSearchFilter/feature.js +16 -0
  88. package/features/CmsEntryOpenSearchFilter/feature.js.map +1 -0
  89. package/features/CmsEntryOpenSearchFilter/fields/DefaultFilter.d.ts +9 -0
  90. package/features/CmsEntryOpenSearchFilter/fields/DefaultFilter.js +23 -0
  91. package/features/CmsEntryOpenSearchFilter/fields/DefaultFilter.js.map +1 -0
  92. package/features/CmsEntryOpenSearchFilter/fields/ObjectFilter.d.ts +9 -0
  93. package/features/CmsEntryOpenSearchFilter/fields/ObjectFilter.js +61 -0
  94. package/features/CmsEntryOpenSearchFilter/fields/ObjectFilter.js.map +1 -0
  95. package/features/CmsEntryOpenSearchFilter/fields/RefFilter.d.ts +9 -0
  96. package/features/CmsEntryOpenSearchFilter/fields/RefFilter.js +49 -0
  97. package/features/CmsEntryOpenSearchFilter/fields/RefFilter.js.map +1 -0
  98. package/features/CmsEntryOpenSearchFilter/index.d.ts +3 -0
  99. package/features/CmsEntryOpenSearchFilter/index.js +5 -0
  100. package/features/CmsEntryOpenSearchFilter/index.js.map +1 -0
  101. package/features/CmsEntryOpenSearchFullTextSearch/abstractions.d.ts +20 -0
  102. package/features/CmsEntryOpenSearchFullTextSearch/abstractions.js +4 -0
  103. package/features/CmsEntryOpenSearchFullTextSearch/abstractions.js.map +1 -0
  104. package/features/CmsEntryOpenSearchFullTextSearch/index.d.ts +1 -0
  105. package/features/CmsEntryOpenSearchFullTextSearch/index.js +3 -0
  106. package/features/CmsEntryOpenSearchFullTextSearch/index.js.map +1 -0
  107. package/features/CmsEntryOpenSearchIndex/BaseOpenSearchIndex.d.ts +11 -0
  108. package/features/CmsEntryOpenSearchIndex/BaseOpenSearchIndex.js +16 -0
  109. package/features/CmsEntryOpenSearchIndex/BaseOpenSearchIndex.js.map +1 -0
  110. package/features/CmsEntryOpenSearchIndex/abstractions.d.ts +14 -0
  111. package/features/CmsEntryOpenSearchIndex/abstractions.js +4 -0
  112. package/features/CmsEntryOpenSearchIndex/abstractions.js.map +1 -0
  113. package/features/CmsEntryOpenSearchIndex/feature.d.ts +4 -0
  114. package/features/CmsEntryOpenSearchIndex/feature.js +10 -0
  115. package/features/CmsEntryOpenSearchIndex/feature.js.map +1 -0
  116. package/features/CmsEntryOpenSearchIndex/index.d.ts +3 -0
  117. package/features/CmsEntryOpenSearchIndex/index.js +5 -0
  118. package/features/CmsEntryOpenSearchIndex/index.js.map +1 -0
  119. package/features/CmsEntryOpenSearchQueryModifier/abstractions.d.ts +16 -0
  120. package/features/CmsEntryOpenSearchQueryModifier/abstractions.js +4 -0
  121. package/features/CmsEntryOpenSearchQueryModifier/abstractions.js.map +1 -0
  122. package/features/CmsEntryOpenSearchQueryModifier/index.d.ts +1 -0
  123. package/features/CmsEntryOpenSearchQueryModifier/index.js +3 -0
  124. package/features/CmsEntryOpenSearchQueryModifier/index.js.map +1 -0
  125. package/features/CmsEntryOpenSearchSortModifier/abstractions.d.ts +15 -0
  126. package/features/CmsEntryOpenSearchSortModifier/abstractions.js +4 -0
  127. package/features/CmsEntryOpenSearchSortModifier/abstractions.js.map +1 -0
  128. package/features/CmsEntryOpenSearchSortModifier/index.d.ts +1 -0
  129. package/features/CmsEntryOpenSearchSortModifier/index.js +3 -0
  130. package/features/CmsEntryOpenSearchSortModifier/index.js.map +1 -0
  131. package/features/CmsEntryOpenSearchValueSearch/CmsEntryOpenSearchValueSearchRegistry.d.ts +12 -0
  132. package/features/CmsEntryOpenSearchValueSearch/CmsEntryOpenSearchValueSearchRegistry.js +27 -0
  133. package/features/CmsEntryOpenSearchValueSearch/CmsEntryOpenSearchValueSearchRegistry.js.map +1 -0
  134. package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearch.d.ts +22 -0
  135. package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearch.js +4 -0
  136. package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearch.js.map +1 -0
  137. package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearchRegistry.d.ts +10 -0
  138. package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearchRegistry.js +4 -0
  139. package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearchRegistry.js.map +1 -0
  140. package/features/CmsEntryOpenSearchValueSearch/feature.d.ts +4 -0
  141. package/features/CmsEntryOpenSearchValueSearch/feature.js +16 -0
  142. package/features/CmsEntryOpenSearchValueSearch/feature.js.map +1 -0
  143. package/features/CmsEntryOpenSearchValueSearch/fields/RefSearch.d.ts +10 -0
  144. package/features/CmsEntryOpenSearchValueSearch/fields/RefSearch.js +23 -0
  145. package/features/CmsEntryOpenSearchValueSearch/fields/RefSearch.js.map +1 -0
  146. package/features/CmsEntryOpenSearchValueSearch/fields/SearchableJsonSearch.d.ts +10 -0
  147. package/features/CmsEntryOpenSearchValueSearch/fields/SearchableJsonSearch.js +55 -0
  148. package/features/CmsEntryOpenSearchValueSearch/fields/SearchableJsonSearch.js.map +1 -0
  149. package/features/CmsEntryOpenSearchValueSearch/fields/TimeSearch.d.ts +10 -0
  150. package/features/CmsEntryOpenSearchValueSearch/fields/TimeSearch.js +24 -0
  151. package/features/CmsEntryOpenSearchValueSearch/fields/TimeSearch.js.map +1 -0
  152. package/features/CmsEntryOpenSearchValueSearch/index.d.ts +3 -0
  153. package/features/CmsEntryOpenSearchValueSearch/index.js +5 -0
  154. package/features/CmsEntryOpenSearchValueSearch/index.js.map +1 -0
  155. package/features/CmsEntryOpenSearchValuesModifier/abstractions.d.ts +23 -0
  156. package/features/CmsEntryOpenSearchValuesModifier/abstractions.js +4 -0
  157. package/features/CmsEntryOpenSearchValuesModifier/abstractions.js.map +1 -0
  158. package/features/CmsEntryOpenSearchValuesModifier/index.d.ts +1 -0
  159. package/features/CmsEntryOpenSearchValuesModifier/index.js +3 -0
  160. package/features/CmsEntryOpenSearchValuesModifier/index.js.map +1 -0
  161. package/helpers/entryIndexHelpers.d.ts +13 -11
  162. package/helpers/entryIndexHelpers.js +38 -94
  163. package/helpers/entryIndexHelpers.js.map +1 -1
  164. package/helpers/fieldIdentifier.d.ts +1 -1
  165. package/helpers/fieldIdentifier.js +2 -10
  166. package/helpers/fieldIdentifier.js.map +1 -1
  167. package/helpers/index.d.ts +2 -2
  168. package/helpers/index.js +2 -27
  169. package/helpers/index.js.map +1 -1
  170. package/index.d.ts +1 -3
  171. package/index.js +1 -223
  172. package/index.js.map +1 -1
  173. package/operations/entry/dataLoader/DataLoaderCache.d.ts +1 -2
  174. package/operations/entry/dataLoader/DataLoaderCache.js +3 -13
  175. package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -1
  176. package/operations/entry/dataLoader/constants.js +1 -7
  177. package/operations/entry/dataLoader/constants.js.map +1 -1
  178. package/operations/entry/dataLoader/createBatchScheduleFn.js +4 -10
  179. package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -1
  180. package/operations/entry/dataLoader/getAllEntryRevisions.d.ts +3 -3
  181. package/operations/entry/dataLoader/getAllEntryRevisions.js +16 -26
  182. package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -1
  183. package/operations/entry/dataLoader/getLatestRevisionByEntryId.d.ts +3 -3
  184. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +23 -31
  185. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -1
  186. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.d.ts +3 -3
  187. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +23 -31
  188. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -1
  189. package/operations/entry/dataLoader/getRevisionById.d.ts +3 -3
  190. package/operations/entry/dataLoader/getRevisionById.js +26 -34
  191. package/operations/entry/dataLoader/getRevisionById.js.map +1 -1
  192. package/operations/entry/dataLoader/index.d.ts +3 -3
  193. package/operations/entry/dataLoader/index.js +10 -31
  194. package/operations/entry/dataLoader/index.js.map +1 -1
  195. package/operations/entry/dataLoader/types.d.ts +4 -4
  196. package/operations/entry/dataLoader/types.js +1 -5
  197. package/operations/entry/dataLoader/types.js.map +1 -1
  198. package/operations/entry/dataLoaders.d.ts +13 -13
  199. package/operations/entry/dataLoaders.js +16 -24
  200. package/operations/entry/dataLoaders.js.map +1 -1
  201. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.d.ts +1 -1
  202. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js +1 -8
  203. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js.map +1 -1
  204. package/operations/entry/elasticsearch/body.d.ts +20 -4
  205. package/operations/entry/elasticsearch/body.js +49 -53
  206. package/operations/entry/elasticsearch/body.js.map +1 -1
  207. package/operations/entry/elasticsearch/fields/createSystemField.d.ts +4 -0
  208. package/operations/entry/elasticsearch/fields/createSystemField.js +10 -0
  209. package/operations/entry/elasticsearch/fields/createSystemField.js.map +1 -0
  210. package/operations/entry/elasticsearch/fields/live.d.ts +2 -0
  211. package/operations/entry/elasticsearch/fields/live.js +45 -0
  212. package/operations/entry/elasticsearch/fields/live.js.map +1 -0
  213. package/operations/entry/elasticsearch/fields/location.d.ts +2 -0
  214. package/operations/entry/elasticsearch/fields/location.js +45 -0
  215. package/operations/entry/elasticsearch/fields/location.js.map +1 -0
  216. package/operations/entry/elasticsearch/fields/state.d.ts +2 -0
  217. package/operations/entry/elasticsearch/fields/state.js +93 -0
  218. package/operations/entry/elasticsearch/fields/state.js.map +1 -0
  219. package/operations/entry/elasticsearch/fields.d.ts +8 -6
  220. package/operations/entry/elasticsearch/fields.js +38 -122
  221. package/operations/entry/elasticsearch/fields.js.map +1 -1
  222. package/operations/entry/elasticsearch/filtering/applyFiltering.d.ts +6 -5
  223. package/operations/entry/elasticsearch/filtering/applyFiltering.js +13 -20
  224. package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +1 -1
  225. package/operations/entry/elasticsearch/filtering/exec.d.ts +11 -6
  226. package/operations/entry/elasticsearch/filtering/exec.js +47 -97
  227. package/operations/entry/elasticsearch/filtering/exec.js.map +1 -1
  228. package/operations/entry/elasticsearch/filtering/index.d.ts +1 -1
  229. package/operations/entry/elasticsearch/filtering/index.js +1 -16
  230. package/operations/entry/elasticsearch/filtering/index.js.map +1 -1
  231. package/operations/entry/elasticsearch/filtering/path.d.ts +5 -3
  232. package/operations/entry/elasticsearch/filtering/path.js +10 -20
  233. package/operations/entry/elasticsearch/filtering/path.js.map +1 -1
  234. package/operations/entry/elasticsearch/filtering/populated.d.ts +2 -2
  235. package/operations/entry/elasticsearch/filtering/populated.js +1 -8
  236. package/operations/entry/elasticsearch/filtering/populated.js.map +1 -1
  237. package/operations/entry/elasticsearch/filtering/values.d.ts +1 -1
  238. package/operations/entry/elasticsearch/filtering/values.js +4 -12
  239. package/operations/entry/elasticsearch/filtering/values.js.map +1 -1
  240. package/operations/entry/elasticsearch/fullTextSearch.d.ts +7 -6
  241. package/operations/entry/elasticsearch/fullTextSearch.js +39 -42
  242. package/operations/entry/elasticsearch/fullTextSearch.js.map +1 -1
  243. package/operations/entry/elasticsearch/fullTextSearchFields.d.ts +4 -4
  244. package/operations/entry/elasticsearch/fullTextSearchFields.js +11 -18
  245. package/operations/entry/elasticsearch/fullTextSearchFields.js.map +1 -1
  246. package/operations/entry/elasticsearch/initialQuery.d.ts +4 -4
  247. package/operations/entry/elasticsearch/initialQuery.js +9 -27
  248. package/operations/entry/elasticsearch/initialQuery.js.map +1 -1
  249. package/operations/entry/elasticsearch/keyword.d.ts +1 -1
  250. package/operations/entry/elasticsearch/keyword.js +4 -9
  251. package/operations/entry/elasticsearch/keyword.js.map +1 -1
  252. package/operations/entry/elasticsearch/plugins/operator.d.ts +2 -3
  253. package/operations/entry/elasticsearch/plugins/operator.js +4 -19
  254. package/operations/entry/elasticsearch/plugins/operator.js.map +1 -1
  255. package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js +2 -9
  256. package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js.map +1 -1
  257. package/operations/entry/elasticsearch/sort.d.ts +6 -6
  258. package/operations/entry/elasticsearch/sort.js +52 -36
  259. package/operations/entry/elasticsearch/sort.js.map +1 -1
  260. package/operations/entry/elasticsearch/transformValueForSearch.d.ts +3 -10
  261. package/operations/entry/elasticsearch/transformValueForSearch.js +5 -20
  262. package/operations/entry/elasticsearch/transformValueForSearch.js.map +1 -1
  263. package/operations/entry/elasticsearch/types.d.ts +4 -11
  264. package/operations/entry/elasticsearch/types.js +1 -5
  265. package/operations/entry/elasticsearch/types.js.map +1 -1
  266. package/operations/entry/index.d.ts +26 -5
  267. package/operations/entry/index.js +421 -541
  268. package/operations/entry/index.js.map +1 -1
  269. package/operations/entry/keys.d.ts +31 -1
  270. package/operations/entry/keys.js +56 -19
  271. package/operations/entry/keys.js.map +1 -1
  272. package/operations/entry/recordType.js +3 -12
  273. package/operations/entry/recordType.js.map +1 -1
  274. package/operations/entry/transformations/convertEntryKeys.d.ts +6 -6
  275. package/operations/entry/transformations/convertEntryKeys.js +2 -10
  276. package/operations/entry/transformations/convertEntryKeys.js.map +1 -1
  277. package/operations/entry/transformations/index.d.ts +24 -18
  278. package/operations/entry/transformations/index.js +31 -37
  279. package/operations/entry/transformations/index.js.map +1 -1
  280. package/operations/entry/transformations/modifyEntryValues.d.ts +30 -35
  281. package/operations/entry/transformations/modifyEntryValues.js +4 -11
  282. package/operations/entry/transformations/modifyEntryValues.js.map +1 -1
  283. package/operations/entry/transformations/transformEntryKeys.d.ts +8 -8
  284. package/operations/entry/transformations/transformEntryKeys.js +4 -11
  285. package/operations/entry/transformations/transformEntryKeys.js.map +1 -1
  286. package/operations/entry/transformations/transformEntryToIndex.d.ts +10 -8
  287. package/operations/entry/transformations/transformEntryToIndex.js +9 -14
  288. package/operations/entry/transformations/transformEntryToIndex.js.map +1 -1
  289. package/operations/group/index.d.ts +7 -6
  290. package/operations/group/index.js +41 -78
  291. package/operations/group/index.js.map +1 -1
  292. package/operations/model/index.d.ts +4 -4
  293. package/operations/model/index.js +38 -58
  294. package/operations/model/index.js.map +1 -1
  295. package/package.json +32 -34
  296. package/tasks/createIndexTaskPlugin.d.ts +2 -2
  297. package/tasks/createIndexTaskPlugin.js +41 -60
  298. package/tasks/createIndexTaskPlugin.js.map +1 -1
  299. package/types.d.ts +26 -134
  300. package/types.js +2 -28
  301. package/types.js.map +1 -1
  302. package/values/NoValueContainer.d.ts +5 -0
  303. package/values/NoValueContainer.js +13 -0
  304. package/values/NoValueContainer.js.map +1 -0
  305. package/definitions/entryElasticsearch.d.ts +0 -9
  306. package/definitions/entryElasticsearch.js +0 -41
  307. package/definitions/entryElasticsearch.js.map +0 -1
  308. package/definitions/system.d.ts +0 -9
  309. package/definitions/system.js +0 -42
  310. package/definitions/system.js.map +0 -1
  311. package/definitions/table.d.ts +0 -8
  312. package/definitions/table.js +0 -25
  313. package/definitions/table.js.map +0 -1
  314. package/definitions/tableElasticsearch.d.ts +0 -8
  315. package/definitions/tableElasticsearch.js +0 -25
  316. package/definitions/tableElasticsearch.js.map +0 -1
  317. package/dynamoDb/index.d.ts +0 -3
  318. package/dynamoDb/index.js +0 -16
  319. package/dynamoDb/index.js.map +0 -1
  320. package/dynamoDb/storage/longText.d.ts +0 -10
  321. package/dynamoDb/storage/longText.js +0 -96
  322. package/dynamoDb/storage/longText.js.map +0 -1
  323. package/dynamoDb/storage/richText.d.ts +0 -2
  324. package/dynamoDb/storage/richText.js +0 -59
  325. package/dynamoDb/storage/richText.js.map +0 -1
  326. package/elasticsearch/index.d.ts +0 -2
  327. package/elasticsearch/index.js +0 -13
  328. package/elasticsearch/index.js.map +0 -1
  329. package/elasticsearch/indexing/dateTimeIndexing.d.ts +0 -3
  330. package/elasticsearch/indexing/dateTimeIndexing.js.map +0 -1
  331. package/elasticsearch/indexing/defaultFieldIndexing.d.ts +0 -3
  332. package/elasticsearch/indexing/defaultFieldIndexing.js +0 -54
  333. package/elasticsearch/indexing/defaultFieldIndexing.js.map +0 -1
  334. package/elasticsearch/indexing/index.d.ts +0 -2
  335. package/elasticsearch/indexing/index.js +0 -18
  336. package/elasticsearch/indexing/index.js.map +0 -1
  337. package/elasticsearch/indexing/jsonIndexing.d.ts +0 -2
  338. package/elasticsearch/indexing/jsonIndexing.js +0 -28
  339. package/elasticsearch/indexing/jsonIndexing.js.map +0 -1
  340. package/elasticsearch/indexing/longTextIndexing.d.ts +0 -7
  341. package/elasticsearch/indexing/longTextIndexing.js +0 -42
  342. package/elasticsearch/indexing/longTextIndexing.js.map +0 -1
  343. package/elasticsearch/indexing/numberIndexing.d.ts +0 -3
  344. package/elasticsearch/indexing/numberIndexing.js.map +0 -1
  345. package/elasticsearch/indexing/objectIndexing.d.ts +0 -12
  346. package/elasticsearch/indexing/objectIndexing.js +0 -201
  347. package/elasticsearch/indexing/objectIndexing.js.map +0 -1
  348. package/elasticsearch/indexing/richTextIndexing.d.ts +0 -3
  349. package/elasticsearch/indexing/richTextIndexing.js +0 -31
  350. package/elasticsearch/indexing/richTextIndexing.js.map +0 -1
  351. package/elasticsearch/indices/base.d.ts +0 -2
  352. package/elasticsearch/indices/base.js +0 -13
  353. package/elasticsearch/indices/base.js.map +0 -1
  354. package/elasticsearch/indices/index.d.ts +0 -1
  355. package/elasticsearch/indices/index.js +0 -14
  356. package/elasticsearch/indices/index.js.map +0 -1
  357. package/elasticsearch/indices/japanese.d.ts +0 -2
  358. package/elasticsearch/indices/japanese.js +0 -14
  359. package/elasticsearch/indices/japanese.js.map +0 -1
  360. package/elasticsearch/search/index.d.ts +0 -3
  361. package/elasticsearch/search/index.js +0 -12
  362. package/elasticsearch/search/index.js.map +0 -1
  363. package/elasticsearch/search/refSearch.d.ts +0 -2
  364. package/elasticsearch/search/refSearch.js +0 -31
  365. package/elasticsearch/search/refSearch.js.map +0 -1
  366. package/elasticsearch/search/timeSearch.d.ts +0 -2
  367. package/elasticsearch/search/timeSearch.js +0 -27
  368. package/elasticsearch/search/timeSearch.js.map +0 -1
  369. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.d.ts +0 -2
  370. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js +0 -30
  371. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js.map +0 -1
  372. package/operations/entry/elasticsearch/filtering/plugins/index.d.ts +0 -1
  373. package/operations/entry/elasticsearch/filtering/plugins/index.js +0 -15
  374. package/operations/entry/elasticsearch/filtering/plugins/index.js.map +0 -1
  375. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.d.ts +0 -2
  376. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js +0 -69
  377. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js.map +0 -1
  378. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.d.ts +0 -2
  379. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js +0 -57
  380. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js.map +0 -1
  381. package/operations/entry/elasticsearch/logIgnoredEsResponseError.d.ts +0 -9
  382. package/operations/entry/elasticsearch/logIgnoredEsResponseError.js +0 -26
  383. package/operations/entry/elasticsearch/logIgnoredEsResponseError.js.map +0 -1
  384. package/operations/entry/elasticsearch/plugins/bodyModifier.d.ts +0 -9
  385. package/operations/entry/elasticsearch/plugins/bodyModifier.js +0 -18
  386. package/operations/entry/elasticsearch/plugins/bodyModifier.js.map +0 -1
  387. package/operations/entry/elasticsearch/plugins/queryModifier.d.ts +0 -9
  388. package/operations/entry/elasticsearch/plugins/queryModifier.js +0 -18
  389. package/operations/entry/elasticsearch/plugins/queryModifier.js.map +0 -1
  390. package/operations/entry/elasticsearch/plugins/search.d.ts +0 -7
  391. package/operations/entry/elasticsearch/plugins/search.js +0 -26
  392. package/operations/entry/elasticsearch/plugins/search.js.map +0 -1
  393. package/operations/entry/elasticsearch/plugins/sortModifier.d.ts +0 -9
  394. package/operations/entry/elasticsearch/plugins/sortModifier.js +0 -18
  395. package/operations/entry/elasticsearch/plugins/sortModifier.js.map +0 -1
  396. package/operations/system/index.d.ts +0 -6
  397. package/operations/system/index.js +0 -94
  398. package/operations/system/index.js.map +0 -1
  399. package/operations/system/indexes.d.ts +0 -10
  400. package/operations/system/indexes.js +0 -41
  401. package/operations/system/indexes.js.map +0 -1
  402. package/plugins/CmsElasticsearchModelFieldPlugin.d.ts +0 -69
  403. package/plugins/CmsElasticsearchModelFieldPlugin.js +0 -52
  404. package/plugins/CmsElasticsearchModelFieldPlugin.js.map +0 -1
  405. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.d.ts +0 -22
  406. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js +0 -21
  407. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js.map +0 -1
  408. package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.d.ts +0 -23
  409. package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js +0 -27
  410. package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js.map +0 -1
  411. package/plugins/CmsEntryElasticsearchIndexPlugin.d.ts +0 -4
  412. package/plugins/CmsEntryElasticsearchIndexPlugin.js +0 -13
  413. package/plugins/CmsEntryElasticsearchIndexPlugin.js.map +0 -1
  414. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.d.ts +0 -31
  415. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js +0 -40
  416. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js.map +0 -1
  417. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.d.ts +0 -19
  418. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js +0 -21
  419. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js.map +0 -1
  420. package/plugins/CmsEntryElasticsearchSortModifierPlugin.d.ts +0 -19
  421. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js +0 -21
  422. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js.map +0 -1
  423. package/plugins/CmsEntryElasticsearchValuesModifier.d.ts +0 -33
  424. package/plugins/CmsEntryElasticsearchValuesModifier.js +0 -50
  425. package/plugins/CmsEntryElasticsearchValuesModifier.js.map +0 -1
  426. package/plugins/CmsEntryFilterPlugin.d.ts +0 -49
  427. package/plugins/CmsEntryFilterPlugin.js +0 -22
  428. package/plugins/CmsEntryFilterPlugin.js.map +0 -1
  429. package/plugins/index.d.ts +0 -8
  430. package/plugins/index.js +0 -95
  431. package/plugins/index.js.map +0 -1
@@ -1,27 +1,17 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.createEntriesStorageOperations = void 0;
8
- var _error = _interopRequireDefault(require("@webiny/error"));
9
- var _types = require("@webiny/api-headless-cms/types");
10
- var _helpers = require("../../helpers");
11
- var _configurations = require("../../configurations");
12
- var _dbDynamodb = require("@webiny/db-dynamodb");
13
- var _dataLoaders = require("./dataLoaders");
14
- var _keys = require("./keys");
15
- var _apiElasticsearch = require("@webiny/api-elasticsearch");
16
- var _utils = require("@webiny/utils");
17
- var _body = require("./elasticsearch/body");
18
- var _logIgnoredEsResponseError = require("./elasticsearch/logIgnoredEsResponseError");
19
- var _shouldIgnoreEsResponseError = require("./elasticsearch/shouldIgnoreEsResponseError");
20
- var _recordType = require("./recordType");
21
- var _apiHeadlessCms = require("@webiny/api-headless-cms");
22
- var _transformations = require("./transformations");
23
- var _convertEntryKeys = require("./transformations/convertEntryKeys");
24
- var _constants = require("@webiny/api-headless-cms/constants");
1
+ import { WebinyError } from "@webiny/error";
2
+ import { CONTENT_ENTRY_STATUS } from "@webiny/api-headless-cms/types/index.js";
3
+ import { extractEntriesFromIndex } from "../../helpers/index.js";
4
+ import { configurations } from "../../configurations.js";
5
+ import { createLimit, decodeCursor, encodeCursor } from "@webiny/api-opensearch";
6
+ import { DataLoadersHandler } from "./dataLoaders.js";
7
+ import { createEntryLatestKeys, createEntryPublishedKeys, createEntryRevisionKeys, createLatestSortKey, createPartitionKey, createPublishedSortKey, createRevisionSortKey } from "./keys.js";
8
+ import { getTotalCount } from "@webiny/api-opensearch/types.js";
9
+ import { createElasticsearchBody } from "./elasticsearch/body.js";
10
+ import { shouldIgnoreEsResponseError } from "./elasticsearch/shouldIgnoreEsResponseError.js";
11
+ import { StorageOperationsCmsModelPlugin } from "@webiny/api-headless-cms";
12
+ import { createTransformer } from "./transformations/index.js";
13
+ import { convertEntryKeysFromStorage } from "./transformations/convertEntryKeys.js";
14
+ import { isDeletedEntryMetaField, isEntryLevelEntryMetaField, isRestoredEntryMetaField, pickEntryMetaFields } from "@webiny/api-headless-cms/constants.js";
25
15
  const convertToStorageEntry = params => {
26
16
  const {
27
17
  model,
@@ -36,26 +26,36 @@ const convertToStorageEntry = params => {
36
26
  values
37
27
  };
38
28
  };
39
- const createEntriesStorageOperations = params => {
29
+ export const createEntriesStorageOperations = params => {
40
30
  const {
41
31
  entity,
42
32
  esEntity,
43
33
  elasticsearch,
44
- plugins
34
+ plugins,
35
+ fieldRegistry,
36
+ fieldIndexRegistry,
37
+ compressionHandler,
38
+ bodyModifiers,
39
+ sortModifiers,
40
+ queryModifiers,
41
+ valueSearchRegistry,
42
+ fullTextSearches,
43
+ valuesModifiers,
44
+ filterRegistry
45
45
  } = params;
46
46
  let storageOperationsCmsModelPlugin;
47
47
  const getStorageOperationsCmsModelPlugin = () => {
48
48
  if (storageOperationsCmsModelPlugin) {
49
49
  return storageOperationsCmsModelPlugin;
50
50
  }
51
- storageOperationsCmsModelPlugin = plugins.oneByType(_apiHeadlessCms.StorageOperationsCmsModelPlugin.type);
51
+ storageOperationsCmsModelPlugin = plugins.oneByType(StorageOperationsCmsModelPlugin.type);
52
52
  return storageOperationsCmsModelPlugin;
53
53
  };
54
54
  const getStorageOperationsModel = model => {
55
55
  const plugin = getStorageOperationsCmsModelPlugin();
56
56
  return plugin.getModel(model);
57
57
  };
58
- const dataLoaders = new _dataLoaders.DataLoadersHandler({
58
+ const dataLoaders = new DataLoadersHandler({
59
59
  entity
60
60
  });
61
61
  const create = async (initialModel, params) => {
@@ -68,11 +68,14 @@ const createEntriesStorageOperations = params => {
68
68
  const locked = isPublished ? true : initialEntry.locked;
69
69
  initialEntry.locked = locked;
70
70
  initialStorageEntry.locked = locked;
71
- const transformer = (0, _transformations.createTransformer)({
72
- plugins,
71
+ const transformer = createTransformer({
72
+ fieldRegistry,
73
+ fieldIndexRegistry,
73
74
  model,
74
75
  entry: initialEntry,
75
- storageEntry: initialStorageEntry
76
+ storageEntry: initialStorageEntry,
77
+ compressionHandler,
78
+ valuesModifiers
76
79
  });
77
80
  const {
78
81
  entry,
@@ -81,53 +84,34 @@ const createEntriesStorageOperations = params => {
81
84
  const esEntry = transformer.transformToIndex();
82
85
  const {
83
86
  index: esIndex
84
- } = _configurations.configurations.es({
87
+ } = configurations.es({
85
88
  model
86
89
  });
87
- const revisionKeys = {
88
- PK: (0, _keys.createPartitionKey)({
89
- id: entry.id,
90
- locale: model.locale,
91
- tenant: model.tenant
92
- }),
93
- SK: (0, _keys.createRevisionSortKey)(entry)
94
- };
95
- const latestKeys = {
96
- PK: (0, _keys.createPartitionKey)({
97
- id: entry.id,
98
- locale: model.locale,
99
- tenant: model.tenant
100
- }),
101
- SK: (0, _keys.createLatestSortKey)()
102
- };
103
- const publishedKeys = {
104
- PK: (0, _keys.createPartitionKey)({
105
- id: entry.id,
106
- locale: model.locale,
107
- tenant: model.tenant
108
- }),
109
- SK: (0, _keys.createPublishedSortKey)()
110
- };
111
- const entityBatch = (0, _dbDynamodb.createEntityWriteBatch)({
112
- entity,
90
+ const revisionKeys = createEntryRevisionKeys(entry);
91
+ const latestKeys = createEntryLatestKeys(entry);
92
+ const publishedKeys = createEntryPublishedKeys(entry);
93
+ const entityBatch = entity.createEntityWriter({
113
94
  put: [{
114
- ...storageEntry,
115
- locked,
116
95
  ...revisionKeys,
117
- TYPE: (0, _recordType.createRecordType)()
96
+ data: {
97
+ ...storageEntry,
98
+ locked
99
+ }
118
100
  }, {
119
- ...storageEntry,
120
- locked,
121
101
  ...latestKeys,
122
- TYPE: (0, _recordType.createLatestRecordType)()
102
+ data: {
103
+ ...storageEntry,
104
+ locked
105
+ }
123
106
  }]
124
107
  });
125
108
  if (isPublished) {
126
109
  entityBatch.put({
127
- ...storageEntry,
128
- locked,
129
110
  ...publishedKeys,
130
- TYPE: (0, _recordType.createPublishedRecordType)()
111
+ data: {
112
+ ...storageEntry,
113
+ locked
114
+ }
131
115
  });
132
116
  }
133
117
  try {
@@ -136,15 +120,14 @@ const createEntriesStorageOperations = params => {
136
120
  model
137
121
  });
138
122
  } catch (ex) {
139
- throw new _error.default(ex.message || "Could not insert entry data into the DynamoDB table.", ex.code || "CREATE_ENTRY_ERROR", {
123
+ throw new WebinyError(ex.message || "Could not insert entry data into the DynamoDB table.", ex.code || "CREATE_ENTRY_ERROR", {
140
124
  error: ex,
141
125
  entry,
142
126
  storageEntry
143
127
  });
144
128
  }
145
129
  const esLatestData = await transformer.getElasticsearchLatestEntryData();
146
- const elasticsearchEntityBatch = (0, _dbDynamodb.createEntityWriteBatch)({
147
- entity: esEntity,
130
+ const elasticsearchEntityBatch = esEntity.createEntityWriter({
148
131
  put: [{
149
132
  ...latestKeys,
150
133
  index: esIndex,
@@ -162,7 +145,7 @@ const createEntriesStorageOperations = params => {
162
145
  try {
163
146
  await elasticsearchEntityBatch.execute();
164
147
  } catch (ex) {
165
- throw new _error.default(ex.message || "Could not insert entry data into the Elasticsearch DynamoDB table.", ex.code || "CREATE_ES_ENTRY_ERROR", {
148
+ throw new WebinyError(ex.message || "Could not insert entry data into the Elasticsearch DynamoDB table.", ex.code || "CREATE_ES_ENTRY_ERROR", {
166
149
  error: ex,
167
150
  entry,
168
151
  esEntry
@@ -176,61 +159,39 @@ const createEntriesStorageOperations = params => {
176
159
  storageEntry: initialStorageEntry
177
160
  } = params;
178
161
  const model = getStorageOperationsModel(initialModel);
179
- const transformer = (0, _transformations.createTransformer)({
180
- plugins,
162
+ const transformer = createTransformer({
181
163
  model,
182
164
  entry: initialEntry,
183
- storageEntry: initialStorageEntry
165
+ storageEntry: initialStorageEntry,
166
+ fieldRegistry,
167
+ fieldIndexRegistry,
168
+ compressionHandler,
169
+ valuesModifiers
184
170
  });
185
171
  const {
186
172
  entry,
187
173
  storageEntry
188
174
  } = transformer.transformEntryKeys();
189
- const revisionKeys = {
190
- PK: (0, _keys.createPartitionKey)({
191
- id: entry.id,
192
- locale: model.locale,
193
- tenant: model.tenant
194
- }),
195
- SK: (0, _keys.createRevisionSortKey)(entry)
196
- };
197
- const latestKeys = {
198
- PK: (0, _keys.createPartitionKey)({
199
- id: entry.id,
200
- locale: model.locale,
201
- tenant: model.tenant
202
- }),
203
- SK: (0, _keys.createLatestSortKey)()
204
- };
205
- const publishedKeys = {
206
- PK: (0, _keys.createPartitionKey)({
207
- id: entry.id,
208
- locale: model.locale,
209
- tenant: model.tenant
210
- }),
211
- SK: (0, _keys.createPublishedSortKey)()
212
- };
175
+ const revisionKeys = createEntryRevisionKeys(entry);
176
+ const latestKeys = createEntryLatestKeys(entry);
177
+ const publishedKeys = createEntryPublishedKeys(entry);
213
178
 
214
179
  // We'll need this flag below.
215
180
  const isPublished = entry.status === "published";
216
181
  const esLatestData = await transformer.getElasticsearchLatestEntryData();
217
- const entityBatch = (0, _dbDynamodb.createEntityWriteBatch)({
218
- entity,
182
+ const entityBatch = entity.createEntityWriter({
219
183
  put: [{
220
- ...storageEntry,
221
- TYPE: (0, _recordType.createRecordType)(),
222
- ...revisionKeys
184
+ ...revisionKeys,
185
+ data: storageEntry
223
186
  }, {
224
- ...storageEntry,
225
- TYPE: (0, _recordType.createLatestRecordType)(),
226
- ...latestKeys
187
+ ...latestKeys,
188
+ data: storageEntry
227
189
  }]
228
190
  });
229
191
  if (isPublished) {
230
192
  entityBatch.put({
231
- ...storageEntry,
232
- TYPE: (0, _recordType.createPublishedRecordType)(),
233
- ...publishedKeys
193
+ ...publishedKeys,
194
+ data: storageEntry
234
195
  });
235
196
 
236
197
  // Unpublish previously published revision (if any).
@@ -239,16 +200,13 @@ const createEntriesStorageOperations = params => {
239
200
  ids: [entry.id]
240
201
  });
241
202
  if (publishedRevisionStorageEntry) {
203
+ const publishedRevisionKey = createEntryRevisionKeys(publishedRevisionStorageEntry);
242
204
  entityBatch.put({
243
- ...publishedRevisionStorageEntry,
244
- PK: (0, _keys.createPartitionKey)({
245
- id: publishedRevisionStorageEntry.id,
246
- locale: model.locale,
247
- tenant: model.tenant
248
- }),
249
- SK: (0, _keys.createRevisionSortKey)(publishedRevisionStorageEntry),
250
- TYPE: (0, _recordType.createRecordType)(),
251
- status: _types.CONTENT_ENTRY_STATUS.UNPUBLISHED
205
+ ...publishedRevisionKey,
206
+ data: {
207
+ ...publishedRevisionStorageEntry,
208
+ status: CONTENT_ENTRY_STATUS.UNPUBLISHED
209
+ }
252
210
  });
253
211
  }
254
212
  }
@@ -258,7 +216,7 @@ const createEntriesStorageOperations = params => {
258
216
  model
259
217
  });
260
218
  } catch (ex) {
261
- throw new _error.default(ex.message || "Could not create revision from given entry in the DynamoDB table.", ex.code || "CREATE_REVISION_ERROR", {
219
+ throw new WebinyError(ex.message || "Could not create revision from given entry in the DynamoDB table.", ex.code || "CREATE_REVISION_ERROR", {
262
220
  error: ex,
263
221
  entry,
264
222
  storageEntry
@@ -266,11 +224,10 @@ const createEntriesStorageOperations = params => {
266
224
  }
267
225
  const {
268
226
  index: esIndex
269
- } = _configurations.configurations.es({
227
+ } = configurations.es({
270
228
  model
271
229
  });
272
- const elasticsearchEntityBatch = (0, _dbDynamodb.createEntityWriteBatch)({
273
- entity: esEntity,
230
+ const elasticsearchEntityBatch = esEntity.createEntityWriter({
274
231
  put: [{
275
232
  ...latestKeys,
276
233
  index: esIndex,
@@ -288,7 +245,7 @@ const createEntriesStorageOperations = params => {
288
245
  try {
289
246
  await elasticsearchEntityBatch.execute();
290
247
  } catch (ex) {
291
- throw new _error.default(ex.message || "Could not update latest entry in the DynamoDB Elasticsearch table.", ex.code || "CREATE_REVISION_ERROR", {
248
+ throw new WebinyError(ex.message || "Could not update latest entry in the DynamoDB Elasticsearch table.", ex.code || "CREATE_REVISION_ERROR", {
292
249
  error: ex,
293
250
  entry
294
251
  });
@@ -304,11 +261,14 @@ const createEntriesStorageOperations = params => {
304
261
  storageEntry: initialStorageEntry
305
262
  } = params;
306
263
  const model = getStorageOperationsModel(initialModel);
307
- const transformer = (0, _transformations.createTransformer)({
308
- plugins,
264
+ const transformer = createTransformer({
265
+ valuesModifiers,
309
266
  model,
310
267
  entry: initialEntry,
311
- storageEntry: initialStorageEntry
268
+ storageEntry: initialStorageEntry,
269
+ fieldRegistry,
270
+ fieldIndexRegistry,
271
+ compressionHandler
312
272
  });
313
273
  const {
314
274
  entry,
@@ -316,30 +276,9 @@ const createEntriesStorageOperations = params => {
316
276
  } = transformer.transformEntryKeys();
317
277
  const isPublished = entry.status === "published";
318
278
  const locked = isPublished ? true : entry.locked;
319
- const revisionKeys = {
320
- PK: (0, _keys.createPartitionKey)({
321
- id: entry.id,
322
- locale: model.locale,
323
- tenant: model.tenant
324
- }),
325
- SK: (0, _keys.createRevisionSortKey)(entry)
326
- };
327
- const latestKeys = {
328
- PK: (0, _keys.createPartitionKey)({
329
- id: entry.id,
330
- locale: model.locale,
331
- tenant: model.tenant
332
- }),
333
- SK: (0, _keys.createLatestSortKey)()
334
- };
335
- const publishedKeys = {
336
- PK: (0, _keys.createPartitionKey)({
337
- id: entry.id,
338
- locale: model.locale,
339
- tenant: model.tenant
340
- }),
341
- SK: (0, _keys.createPublishedSortKey)()
342
- };
279
+ const revisionKeys = createEntryRevisionKeys(entry);
280
+ const latestKeys = createEntryLatestKeys(entry);
281
+ const publishedKeys = createEntryPublishedKeys(entry);
343
282
 
344
283
  /**
345
284
  * We need the latest entry to check if it needs to be updated.
@@ -352,29 +291,28 @@ const createEntriesStorageOperations = params => {
352
291
  model,
353
292
  ids: [entry.id]
354
293
  });
355
- const entityBatch = (0, _dbDynamodb.createEntityWriteBatch)({
356
- entity,
294
+ const entityBatch = entity.createEntityWriter({
357
295
  put: [{
358
- ...storageEntry,
359
- locked,
360
296
  ...revisionKeys,
361
- TYPE: (0, _recordType.createRecordType)()
297
+ data: {
298
+ ...storageEntry,
299
+ locked
300
+ }
362
301
  }]
363
302
  });
364
303
  if (isPublished) {
365
304
  entityBatch.put({
366
- ...storageEntry,
367
- locked,
368
305
  ...publishedKeys,
369
- TYPE: (0, _recordType.createPublishedRecordType)()
306
+ data: {
307
+ ...storageEntry,
308
+ locked
309
+ }
370
310
  });
371
311
  }
372
- const elasticsearchEntityBatch = (0, _dbDynamodb.createEntityWriteBatch)({
373
- entity: esEntity
374
- });
312
+ const elasticsearchEntityBatch = esEntity.createEntityWriter();
375
313
  const {
376
314
  index: esIndex
377
- } = _configurations.configurations.es({
315
+ } = configurations.es({
378
316
  model
379
317
  });
380
318
 
@@ -388,9 +326,8 @@ const createEntriesStorageOperations = params => {
388
326
  * First we update the regular DynamoDB table.
389
327
  */
390
328
  entityBatch.put({
391
- ...storageEntry,
392
329
  ...latestKeys,
393
- TYPE: (0, _recordType.createLatestRecordType)()
330
+ data: storageEntry
394
331
  });
395
332
 
396
333
  /**
@@ -407,11 +344,13 @@ const createEntriesStorageOperations = params => {
407
344
  * If not updating latest revision, we still want to update the latest revision's
408
345
  * entry-level meta fields to match the current revision's entry-level meta fields.
409
346
  */
410
- const updatedEntryLevelMetaFields = (0, _constants.pickEntryMetaFields)(entry, _constants.isEntryLevelEntryMetaField);
347
+ const updatedEntryLevelMetaFields = pickEntryMetaFields(entry, isEntryLevelEntryMetaField);
411
348
  const updatedLatestStorageEntry = {
412
- ...latestStorageEntry,
413
349
  ...latestKeys,
414
- ...updatedEntryLevelMetaFields
350
+ data: {
351
+ ...latestStorageEntry,
352
+ ...updatedEntryLevelMetaFields
353
+ }
415
354
  };
416
355
 
417
356
  /**
@@ -421,29 +360,23 @@ const createEntriesStorageOperations = params => {
421
360
  */
422
361
  entityBatch.put({
423
362
  ...updatedLatestStorageEntry,
424
- PK: (0, _keys.createPartitionKey)({
363
+ PK: createPartitionKey({
425
364
  id: latestStorageEntry.id,
426
- locale: model.locale,
427
365
  tenant: model.tenant
428
366
  }),
429
- SK: (0, _keys.createRevisionSortKey)(latestStorageEntry),
430
- TYPE: (0, _recordType.createRecordType)()
367
+ SK: createRevisionSortKey(latestStorageEntry)
431
368
  });
432
369
  entityBatch.put({
433
- ...updatedLatestStorageEntry,
434
- TYPE: (0, _recordType.createLatestRecordType)()
370
+ ...updatedLatestStorageEntry
435
371
  });
436
372
 
437
373
  /**
438
374
  * Update the Elasticsearch table to propagate changes to the Elasticsearch.
439
375
  */
440
- const latestEsEntry = await (0, _dbDynamodb.getClean)({
441
- entity: esEntity,
442
- keys: latestKeys
443
- });
376
+ const latestEsEntry = await esEntity.getClean(latestKeys);
444
377
  if (latestEsEntry) {
445
- const latestEsEntryDataDecompressed = await (0, _apiElasticsearch.decompress)(plugins, latestEsEntry.data);
446
- const updatedLatestEntry = await (0, _apiElasticsearch.compress)(plugins, {
378
+ const latestEsEntryDataDecompressed = await compressionHandler.decompress(latestEsEntry.data);
379
+ const updatedLatestEntry = await compressionHandler.compress({
447
380
  ...latestEsEntryDataDecompressed,
448
381
  ...updatedEntryLevelMetaFields
449
382
  });
@@ -469,7 +402,7 @@ const createEntriesStorageOperations = params => {
469
402
  model
470
403
  });
471
404
  } catch (ex) {
472
- throw new _error.default(ex.message || "Could not update entry DynamoDB records.", ex.code || "UPDATE_ENTRY_ERROR", {
405
+ throw new WebinyError(ex.message || "Could not update entry DynamoDB records.", ex.code || "UPDATE_ENTRY_ERROR", {
473
406
  error: ex,
474
407
  entry,
475
408
  storageEntry
@@ -478,7 +411,7 @@ const createEntriesStorageOperations = params => {
478
411
  try {
479
412
  await elasticsearchEntityBatch.execute();
480
413
  } catch (ex) {
481
- throw new _error.default(ex.message || "Could not update entry DynamoDB Elasticsearch records.", ex.code || "UPDATE_ES_ENTRY_ERROR", {
414
+ throw new WebinyError(ex.message || "Could not update entry DynamoDB Elasticsearch records.", ex.code || "UPDATE_ES_ENTRY_ERROR", {
482
415
  error: ex,
483
416
  entry
484
417
  });
@@ -487,38 +420,37 @@ const createEntriesStorageOperations = params => {
487
420
  };
488
421
  const move = async (initialModel, id, folderId) => {
489
422
  const model = getStorageOperationsModel(initialModel);
490
- const partitionKey = (0, _keys.createPartitionKey)({
423
+ const partitionKey = createPartitionKey({
491
424
  id,
492
- locale: model.locale,
493
425
  tenant: model.tenant
494
426
  });
495
427
  /**
496
428
  * First we need to fetch all the records in the regular DynamoDB table.
497
429
  */
498
430
  const queryAllParams = {
499
- entity,
500
431
  partitionKey,
501
432
  options: {
502
433
  gte: " "
503
434
  }
504
435
  };
505
- const latestSortKey = (0, _keys.createLatestSortKey)();
506
- const publishedSortKey = (0, _keys.createPublishedSortKey)();
507
- const records = await (0, _dbDynamodb.queryAll)(queryAllParams);
436
+ const latestSortKey = createLatestSortKey();
437
+ const publishedSortKey = createPublishedSortKey();
438
+ const records = await entity.queryAll(queryAllParams);
508
439
  /**
509
440
  * Then update the folderId in each record and prepare it to be stored.
510
441
  */
511
442
  let latestRecord = undefined;
512
443
  let publishedRecord = undefined;
513
- const entityBatch = (0, _dbDynamodb.createEntityWriteBatch)({
514
- entity
515
- });
444
+ const entityBatch = entity.createEntityWriter();
516
445
  for (const record of records) {
517
446
  entityBatch.put({
518
447
  ...record,
519
- location: {
520
- ...record?.location,
521
- folderId
448
+ data: {
449
+ ...record.data,
450
+ location: {
451
+ ...record.data.location,
452
+ folderId
453
+ }
522
454
  }
523
455
  });
524
456
 
@@ -526,9 +458,9 @@ const createEntriesStorageOperations = params => {
526
458
  * We need to get the published and latest records, so we can update the Elasticsearch.
527
459
  */
528
460
  if (record.SK === publishedSortKey) {
529
- publishedRecord = record;
461
+ publishedRecord = record.data;
530
462
  } else if (record.SK === latestSortKey) {
531
- latestRecord = record;
463
+ latestRecord = record.data;
532
464
  }
533
465
  }
534
466
  try {
@@ -537,62 +469,58 @@ const createEntriesStorageOperations = params => {
537
469
  model
538
470
  });
539
471
  } catch (ex) {
540
- throw new _error.default(ex.message || "Could not move all entry records from in the DynamoDB table.", ex.code || "MOVE_ENTRY_ERROR", {
472
+ throw new WebinyError(ex.message || "Could not move all entry records from in the DynamoDB table.", ex.code || "MOVE_ENTRY_ERROR", {
541
473
  error: ex,
542
474
  id
543
475
  });
544
476
  }
545
- const esGetItems = [];
477
+ const esEntityReader = esEntity.createEntityReader();
546
478
  if (publishedRecord) {
547
- esGetItems.push(esEntity.getBatch({
479
+ esEntityReader.get({
548
480
  PK: partitionKey,
549
481
  SK: publishedSortKey
550
- }));
482
+ });
551
483
  }
552
484
  if (latestRecord) {
553
- esGetItems.push(esEntity.getBatch({
485
+ esEntityReader.get({
554
486
  PK: partitionKey,
555
487
  SK: latestSortKey
556
- }));
488
+ });
557
489
  }
558
- if (esGetItems.length === 0) {
490
+ if (esEntityReader.total === 0) {
559
491
  return;
560
492
  }
561
- const esRecords = await (0, _dbDynamodb.batchReadAll)({
562
- table: esEntity.table,
563
- items: esGetItems
564
- });
493
+ const esRecords = await esEntityReader.execute();
565
494
  const esItems = (await Promise.all(esRecords.map(async record => {
566
495
  if (!record) {
567
496
  return null;
568
497
  }
569
498
  return {
570
499
  ...record,
571
- data: await (0, _apiElasticsearch.decompress)(plugins, record.data)
500
+ data: await compressionHandler.decompress(record.data)
572
501
  };
573
- }))).filter(Boolean);
502
+ }))).filter(item => !!item);
574
503
  if (esItems.length === 0) {
575
504
  return;
576
505
  }
577
- const elasticsearchEntityBatch = (0, _dbDynamodb.createEntityWriteBatch)({
578
- entity: esEntity,
579
- put: await Promise.all(esItems.map(async item => {
580
- return {
581
- ...item,
582
- data: await (0, _apiElasticsearch.compress)(plugins, {
583
- ...item.data,
584
- location: {
585
- ...item.data?.location,
586
- folderId
587
- }
588
- })
589
- };
590
- }))
591
- });
592
506
  try {
507
+ const elasticsearchEntityBatch = esEntity.createEntityWriter({
508
+ put: await Promise.all(esItems.map(async item => {
509
+ return {
510
+ ...item,
511
+ data: await compressionHandler.compress({
512
+ ...item.data,
513
+ location: {
514
+ ...item.data?.location,
515
+ folderId
516
+ }
517
+ })
518
+ };
519
+ }))
520
+ });
593
521
  await elasticsearchEntityBatch.execute();
594
522
  } catch (ex) {
595
- throw new _error.default(ex.message || "Could not move entry DynamoDB Elasticsearch records.", ex.code || "MOVE_ES_ENTRY_ERROR", {
523
+ throw new WebinyError(ex.message || "Could not move entry DynamoDB Elasticsearch records.", ex.code || "MOVE_ES_ENTRY_ERROR", {
596
524
  error: ex,
597
525
  partitionKey
598
526
  });
@@ -604,19 +532,21 @@ const createEntriesStorageOperations = params => {
604
532
  storageEntry: initialStorageEntry
605
533
  } = params;
606
534
  const model = getStorageOperationsModel(initialModel);
607
- const transformer = (0, _transformations.createTransformer)({
608
- plugins,
535
+ const transformer = createTransformer({
536
+ valuesModifiers,
609
537
  model,
610
538
  entry: initialEntry,
611
- storageEntry: initialStorageEntry
539
+ storageEntry: initialStorageEntry,
540
+ fieldRegistry,
541
+ fieldIndexRegistry,
542
+ compressionHandler
612
543
  });
613
544
  const {
614
545
  entry,
615
546
  storageEntry
616
547
  } = transformer.transformEntryKeys();
617
- const partitionKey = (0, _keys.createPartitionKey)({
548
+ const partitionKey = createPartitionKey({
618
549
  id: entry.id,
619
- locale: model.locale,
620
550
  tenant: model.tenant
621
551
  });
622
552
 
@@ -624,45 +554,45 @@ const createEntriesStorageOperations = params => {
624
554
  * First we need to fetch all the records in the regular DynamoDB table.
625
555
  */
626
556
  const queryAllParams = {
627
- entity,
628
557
  partitionKey,
629
558
  options: {
630
559
  gte: " "
631
560
  }
632
561
  };
633
- const latestSortKey = (0, _keys.createLatestSortKey)();
634
- const publishedSortKey = (0, _keys.createPublishedSortKey)();
635
- const records = await (0, _dbDynamodb.queryAll)(queryAllParams);
562
+ const latestSortKey = createLatestSortKey();
563
+ const publishedSortKey = createPublishedSortKey();
564
+ const records = await entity.queryAll(queryAllParams);
636
565
 
637
566
  /**
638
567
  * Let's pick the `deleted` meta fields from the entry.
639
568
  */
640
- const updatedEntryMetaFields = (0, _constants.pickEntryMetaFields)(entry, _constants.isDeletedEntryMetaField);
569
+ const updatedEntryMetaFields = pickEntryMetaFields(entry, isDeletedEntryMetaField);
641
570
 
642
571
  /**
643
572
  * Then update all the records with data received.
644
573
  */
645
574
  let latestRecord = undefined;
646
575
  let publishedRecord = undefined;
647
- const entityBatch = (0, _dbDynamodb.createEntityWriteBatch)({
648
- entity
649
- });
576
+ const entityBatch = entity.createEntityWriter();
650
577
  for (const record of records) {
651
578
  entityBatch.put({
652
579
  ...record,
653
- ...updatedEntryMetaFields,
654
- wbyDeleted: storageEntry.wbyDeleted,
655
- location: storageEntry.location,
656
- binOriginalFolderId: storageEntry.binOriginalFolderId
580
+ data: {
581
+ ...record.data,
582
+ ...updatedEntryMetaFields,
583
+ wbyDeleted: storageEntry.wbyDeleted,
584
+ location: storageEntry.location,
585
+ binOriginalFolderId: storageEntry.binOriginalFolderId
586
+ }
657
587
  });
658
588
 
659
589
  /**
660
590
  * We need to get the published and latest records, so we can update the Elasticsearch.
661
591
  */
662
592
  if (record.SK === publishedSortKey) {
663
- publishedRecord = record;
593
+ publishedRecord = record.data;
664
594
  } else if (record.SK === latestSortKey) {
665
- latestRecord = record;
595
+ latestRecord = record.data;
666
596
  }
667
597
  }
668
598
 
@@ -675,7 +605,7 @@ const createEntriesStorageOperations = params => {
675
605
  model
676
606
  });
677
607
  } catch (ex) {
678
- throw new _error.default(ex.message || "Could mark as deleted all entry records from in the DynamoDB table.", ex.code || "MOVE_ENTRY_TO_BIN_ERROR", {
608
+ throw new WebinyError(ex.message || "Could mark as deleted all entry records from in the DynamoDB table.", ex.code || "MOVE_ENTRY_TO_BIN_ERROR", {
679
609
  error: ex,
680
610
  entry,
681
611
  storageEntry
@@ -685,35 +615,32 @@ const createEntriesStorageOperations = params => {
685
615
  /**
686
616
  * We need to get the published and latest records from Elasticsearch.
687
617
  */
688
- const esGetItems = [];
618
+ const esEntityReader = esEntity.createEntityReader();
689
619
  if (publishedRecord) {
690
- esGetItems.push(esEntity.getBatch({
620
+ esEntityReader.get({
691
621
  PK: partitionKey,
692
622
  SK: publishedSortKey
693
- }));
623
+ });
694
624
  }
695
625
  if (latestRecord) {
696
- esGetItems.push(esEntity.getBatch({
626
+ esEntityReader.get({
697
627
  PK: partitionKey,
698
628
  SK: latestSortKey
699
- }));
629
+ });
700
630
  }
701
- if (esGetItems.length === 0) {
631
+ if (esEntityReader.total === 0) {
702
632
  return;
703
633
  }
704
- const esRecords = await (0, _dbDynamodb.batchReadAll)({
705
- table: esEntity.table,
706
- items: esGetItems
707
- });
634
+ const esRecords = await esEntityReader.execute();
708
635
  const esItems = (await Promise.all(esRecords.map(async record => {
709
636
  if (!record) {
710
637
  return null;
711
638
  }
712
639
  return {
713
640
  ...record,
714
- data: await (0, _apiElasticsearch.decompress)(plugins, record.data)
641
+ data: await compressionHandler.decompress(record.data)
715
642
  };
716
- }))).filter(Boolean);
643
+ }))).filter(item => !!item);
717
644
  if (esItems.length === 0) {
718
645
  return;
719
646
  }
@@ -721,13 +648,11 @@ const createEntriesStorageOperations = params => {
721
648
  /**
722
649
  * We update all ES records with data received.
723
650
  */
724
- const elasticsearchEntityBatch = (0, _dbDynamodb.createEntityWriteBatch)({
725
- entity: esEntity
726
- });
651
+ const elasticsearchEntityBatch = esEntity.createEntityWriter();
727
652
  for (const item of esItems) {
728
653
  elasticsearchEntityBatch.put({
729
654
  ...item,
730
- data: await (0, _apiElasticsearch.compress)(plugins, {
655
+ data: await compressionHandler.compress({
731
656
  ...item.data,
732
657
  ...updatedEntryMetaFields,
733
658
  wbyDeleted: entry.wbyDeleted,
@@ -743,7 +668,7 @@ const createEntriesStorageOperations = params => {
743
668
  try {
744
669
  await elasticsearchEntityBatch.execute();
745
670
  } catch (ex) {
746
- throw new _error.default(ex.message || "Could not mark as deleted entry records from DynamoDB Elasticsearch table.", ex.code || "MOVE_ENTRY_TO_BIN_ERROR", {
671
+ throw new WebinyError(ex.message || "Could not mark as deleted entry records from DynamoDB Elasticsearch table.", ex.code || "MOVE_ENTRY_TO_BIN_ERROR", {
747
672
  error: ex,
748
673
  entry,
749
674
  storageEntry
@@ -756,11 +681,14 @@ const createEntriesStorageOperations = params => {
756
681
  storageEntry: initialStorageEntry
757
682
  } = params;
758
683
  const model = getStorageOperationsModel(initialModel);
759
- const transformer = (0, _transformations.createTransformer)({
760
- plugins,
684
+ const transformer = createTransformer({
685
+ valuesModifiers,
761
686
  model,
762
687
  entry: initialEntry,
763
- storageEntry: initialStorageEntry
688
+ storageEntry: initialStorageEntry,
689
+ fieldRegistry,
690
+ fieldIndexRegistry,
691
+ compressionHandler
764
692
  });
765
693
  const {
766
694
  entry,
@@ -770,10 +698,9 @@ const createEntriesStorageOperations = params => {
770
698
  /**
771
699
  * Let's pick the `restored` meta fields from the storage entry.
772
700
  */
773
- const updatedEntryMetaFields = (0, _constants.pickEntryMetaFields)(entry, _constants.isRestoredEntryMetaField);
774
- const partitionKey = (0, _keys.createPartitionKey)({
701
+ const updatedEntryMetaFields = pickEntryMetaFields(entry, isRestoredEntryMetaField);
702
+ const partitionKey = createPartitionKey({
775
703
  id: entry.id,
776
- locale: model.locale,
777
704
  tenant: model.tenant
778
705
  });
779
706
 
@@ -781,40 +708,40 @@ const createEntriesStorageOperations = params => {
781
708
  * First we need to fetch all the records in the regular DynamoDB table.
782
709
  */
783
710
  const queryAllParams = {
784
- entity,
785
711
  partitionKey,
786
712
  options: {
787
713
  gte: " "
788
714
  }
789
715
  };
790
- const latestSortKey = (0, _keys.createLatestSortKey)();
791
- const publishedSortKey = (0, _keys.createPublishedSortKey)();
792
- const records = await (0, _dbDynamodb.queryAll)(queryAllParams);
716
+ const latestSortKey = createLatestSortKey();
717
+ const publishedSortKey = createPublishedSortKey();
718
+ const records = await entity.queryAll(queryAllParams);
793
719
 
794
720
  /**
795
721
  * Then update all the records with data received.
796
722
  */
797
723
  let latestRecord = undefined;
798
724
  let publishedRecord = undefined;
799
- const entityBatch = (0, _dbDynamodb.createEntityWriteBatch)({
800
- entity
801
- });
725
+ const entityBatch = entity.createEntityWriter();
802
726
  for (const record of records) {
803
727
  entityBatch.put({
804
728
  ...record,
805
- ...updatedEntryMetaFields,
806
- wbyDeleted: storageEntry.wbyDeleted,
807
- location: storageEntry.location,
808
- binOriginalFolderId: storageEntry.binOriginalFolderId
729
+ data: {
730
+ ...record.data,
731
+ ...updatedEntryMetaFields,
732
+ wbyDeleted: storageEntry.wbyDeleted,
733
+ location: storageEntry.location,
734
+ binOriginalFolderId: storageEntry.binOriginalFolderId
735
+ }
809
736
  });
810
737
 
811
738
  /**
812
739
  * We need to get the published and latest records, so we can update the Elasticsearch.
813
740
  */
814
741
  if (record.SK === publishedSortKey) {
815
- publishedRecord = record;
742
+ publishedRecord = record.data;
816
743
  } else if (record.SK === latestSortKey) {
817
- latestRecord = record;
744
+ latestRecord = record.data;
818
745
  }
819
746
  }
820
747
 
@@ -827,7 +754,7 @@ const createEntriesStorageOperations = params => {
827
754
  model
828
755
  });
829
756
  } catch (ex) {
830
- throw new _error.default(ex.message || "Could not restore all entry records from in the DynamoDB table.", ex.code || "RESTORE_ENTRY_ERROR", {
757
+ throw new WebinyError(ex.message || "Could not restore all entry records from in the DynamoDB table.", ex.code || "RESTORE_ENTRY_ERROR", {
831
758
  error: ex,
832
759
  entry,
833
760
  storageEntry
@@ -837,32 +764,29 @@ const createEntriesStorageOperations = params => {
837
764
  /**
838
765
  * We need to get the published and latest records from Elasticsearch.
839
766
  */
840
- const esGetItems = [];
767
+ const esEntityReader = esEntity.createEntityReader();
841
768
  if (publishedRecord) {
842
- esGetItems.push(esEntity.getBatch({
769
+ esEntityReader.get({
843
770
  PK: partitionKey,
844
771
  SK: publishedSortKey
845
- }));
772
+ });
846
773
  }
847
774
  if (latestRecord) {
848
- esGetItems.push(esEntity.getBatch({
775
+ esEntityReader.get({
849
776
  PK: partitionKey,
850
777
  SK: latestSortKey
851
- }));
778
+ });
852
779
  }
853
- const esRecords = await (0, _dbDynamodb.batchReadAll)({
854
- table: esEntity.table,
855
- items: esGetItems
856
- });
780
+ const esRecords = await esEntityReader.execute();
857
781
  const esItems = (await Promise.all(esRecords.map(async record => {
858
782
  if (!record) {
859
783
  return null;
860
784
  }
861
785
  return {
862
786
  ...record,
863
- data: await (0, _apiElasticsearch.decompress)(plugins, record.data)
787
+ data: await compressionHandler.decompress(record.data)
864
788
  };
865
- }))).filter(Boolean);
789
+ }))).filter(item => !!item);
866
790
  if (esItems.length === 0) {
867
791
  return initialStorageEntry;
868
792
  }
@@ -870,13 +794,11 @@ const createEntriesStorageOperations = params => {
870
794
  /**
871
795
  * We update all ES records with data received.
872
796
  */
873
- const elasticsearchEntityBatch = (0, _dbDynamodb.createEntityWriteBatch)({
874
- entity: esEntity
875
- });
797
+ const elasticsearchEntityBatch = esEntity.createEntityWriter();
876
798
  for (const item of esItems) {
877
799
  elasticsearchEntityBatch.put({
878
800
  ...item,
879
- data: await (0, _apiElasticsearch.compress)(plugins, {
801
+ data: await compressionHandler.compress({
880
802
  ...item.data,
881
803
  ...updatedEntryMetaFields,
882
804
  wbyDeleted: entry.wbyDeleted,
@@ -892,7 +814,7 @@ const createEntriesStorageOperations = params => {
892
814
  try {
893
815
  await elasticsearchEntityBatch.execute();
894
816
  } catch (ex) {
895
- throw new _error.default(ex.message || "Could not restore entry records from DynamoDB Elasticsearch table.", ex.code || "RESTORE_ENTRY_ERROR", {
817
+ throw new WebinyError(ex.message || "Could not restore entry records from DynamoDB Elasticsearch table.", ex.code || "RESTORE_ENTRY_ERROR", {
896
818
  error: ex,
897
819
  entry,
898
820
  storageEntry
@@ -906,27 +828,23 @@ const createEntriesStorageOperations = params => {
906
828
  } = params;
907
829
  const id = entry.id || entry.entryId;
908
830
  const model = getStorageOperationsModel(initialModel);
909
- const partitionKey = (0, _keys.createPartitionKey)({
831
+ const partitionKey = createPartitionKey({
910
832
  id,
911
- locale: model.locale,
912
833
  tenant: model.tenant
913
834
  });
914
- const items = await (0, _dbDynamodb.queryAll)({
915
- entity,
835
+ const items = await entity.queryAll({
916
836
  partitionKey,
917
837
  options: {
918
838
  gte: " "
919
839
  }
920
840
  });
921
- const esItems = await (0, _dbDynamodb.queryAll)({
922
- entity: esEntity,
841
+ const esItems = await esEntity.queryAll({
923
842
  partitionKey,
924
843
  options: {
925
844
  gte: " "
926
845
  }
927
846
  });
928
- const entityBatch = (0, _dbDynamodb.createEntityWriteBatch)({
929
- entity,
847
+ const entityBatch = entity.createEntityWriter({
930
848
  delete: items.map(item => {
931
849
  return {
932
850
  PK: item.PK,
@@ -934,8 +852,7 @@ const createEntriesStorageOperations = params => {
934
852
  };
935
853
  })
936
854
  });
937
- const elasticsearchEntityBatch = (0, _dbDynamodb.createEntityWriteBatch)({
938
- entity: esEntity,
855
+ const elasticsearchEntityBatch = esEntity.createEntityWriter({
939
856
  delete: esItems.map(item => {
940
857
  return {
941
858
  PK: item.PK,
@@ -949,7 +866,7 @@ const createEntriesStorageOperations = params => {
949
866
  model
950
867
  });
951
868
  } catch (ex) {
952
- throw new _error.default(ex.message || "Could not destroy entry records from DynamoDB table.", ex.code || "DELETE_ENTRY_ERROR", {
869
+ throw new WebinyError(ex.message || "Could not destroy entry records from DynamoDB table.", ex.code || "DELETE_ENTRY_ERROR", {
953
870
  error: ex,
954
871
  id
955
872
  });
@@ -957,7 +874,7 @@ const createEntriesStorageOperations = params => {
957
874
  try {
958
875
  await elasticsearchEntityBatch.execute();
959
876
  } catch (ex) {
960
- throw new _error.default(ex.message || "Could not destroy entry records from DynamoDB Elasticsearch table.", ex.code || "DELETE_ENTRY_ERROR", {
877
+ throw new WebinyError(ex.message || "Could not destroy entry records from DynamoDB Elasticsearch table.", ex.code || "DELETE_ENTRY_ERROR", {
961
878
  error: ex,
962
879
  id
963
880
  });
@@ -970,14 +887,13 @@ const createEntriesStorageOperations = params => {
970
887
  latestStorageEntry: initialLatestStorageEntry
971
888
  } = params;
972
889
  const model = getStorageOperationsModel(initialModel);
973
- const partitionKey = (0, _keys.createPartitionKey)({
890
+ const partitionKey = createPartitionKey({
974
891
  id: entry.id,
975
- locale: model.locale,
976
892
  tenant: model.tenant
977
893
  });
978
894
  const {
979
895
  index
980
- } = _configurations.configurations.es({
896
+ } = configurations.es({
981
897
  model
982
898
  });
983
899
  /**
@@ -990,16 +906,13 @@ const createEntriesStorageOperations = params => {
990
906
  /**
991
907
  * We need to delete all existing records of the given entry revision.
992
908
  */
993
- const entityBatch = (0, _dbDynamodb.createEntityWriteBatch)({
994
- entity,
909
+ const entityBatch = entity.createEntityWriter({
995
910
  delete: [{
996
911
  PK: partitionKey,
997
- SK: (0, _keys.createRevisionSortKey)(entry)
912
+ SK: createRevisionSortKey(entry)
998
913
  }]
999
914
  });
1000
- const elasticsearchEntityBatch = (0, _dbDynamodb.createEntityWriteBatch)({
1001
- entity: esEntity
1002
- });
915
+ const elasticsearchEntityBatch = esEntity.createEntityWriter();
1003
916
 
1004
917
  /**
1005
918
  * If revision we are deleting is the published one as well, we need to delete those records as well.
@@ -1007,11 +920,11 @@ const createEntriesStorageOperations = params => {
1007
920
  if (publishedStorageEntry?.id === entry.id) {
1008
921
  entityBatch.delete({
1009
922
  PK: partitionKey,
1010
- SK: (0, _keys.createPublishedSortKey)()
923
+ SK: createPublishedSortKey()
1011
924
  });
1012
925
  elasticsearchEntityBatch.delete({
1013
926
  PK: partitionKey,
1014
- SK: (0, _keys.createPublishedSortKey)()
927
+ SK: createPublishedSortKey()
1015
928
  });
1016
929
  }
1017
930
  if (latestEntry && initialLatestStorageEntry) {
@@ -1023,37 +936,34 @@ const createEntriesStorageOperations = params => {
1023
936
  /**
1024
937
  * In the end we need to set the new latest entry.
1025
938
  */
939
+ const latestStorageEntryLatestKey = createEntryLatestKeys(latestStorageEntry);
1026
940
  entityBatch.put({
1027
- ...latestStorageEntry,
1028
- PK: partitionKey,
1029
- SK: (0, _keys.createLatestSortKey)(),
1030
- TYPE: (0, _recordType.createLatestRecordType)()
941
+ ...latestStorageEntryLatestKey,
942
+ data: latestStorageEntry
1031
943
  });
1032
944
 
1033
945
  /**
1034
946
  * Also perform an update on the actual revision. This is needed
1035
947
  * because of updates on the entry-level meta fields.
1036
948
  */
949
+ const actualRevisionEntryKey = createEntryRevisionKeys(initialLatestStorageEntry);
1037
950
  entityBatch.put({
1038
- ...latestStorageEntry,
1039
- PK: (0, _keys.createPartitionKey)({
1040
- id: initialLatestStorageEntry.id,
1041
- locale: model.locale,
1042
- tenant: model.tenant
1043
- }),
1044
- SK: (0, _keys.createRevisionSortKey)(initialLatestStorageEntry),
1045
- TYPE: (0, _recordType.createRecordType)()
951
+ ...actualRevisionEntryKey,
952
+ data: latestStorageEntry
1046
953
  });
1047
- const latestTransformer = (0, _transformations.createTransformer)({
1048
- plugins,
954
+ const latestTransformer = createTransformer({
955
+ valuesModifiers,
1049
956
  model,
1050
957
  entry: latestEntry,
1051
- storageEntry: initialLatestStorageEntry
958
+ storageEntry: initialLatestStorageEntry,
959
+ fieldRegistry,
960
+ fieldIndexRegistry,
961
+ compressionHandler
1052
962
  });
1053
963
  const esLatestData = await latestTransformer.getElasticsearchLatestEntryData();
964
+ const esLatestKeys = createEntryLatestKeys(latestEntry);
1054
965
  elasticsearchEntityBatch.put({
1055
- PK: partitionKey,
1056
- SK: (0, _keys.createLatestSortKey)(),
966
+ ...esLatestKeys,
1057
967
  index,
1058
968
  data: esLatestData
1059
969
  });
@@ -1064,7 +974,7 @@ const createEntriesStorageOperations = params => {
1064
974
  model
1065
975
  });
1066
976
  } catch (ex) {
1067
- throw new _error.default(ex.message || "Could not batch write entry records to DynamoDB table.", ex.code || "DELETE_REVISION_ERROR", {
977
+ throw new WebinyError(ex.message || "Could not batch write entry records to DynamoDB table.", ex.code || "DELETE_REVISION_ERROR", {
1068
978
  error: ex,
1069
979
  entry,
1070
980
  latestEntry,
@@ -1074,7 +984,7 @@ const createEntriesStorageOperations = params => {
1074
984
  try {
1075
985
  await elasticsearchEntityBatch.execute();
1076
986
  } catch (ex) {
1077
- throw new _error.default(ex.message || "Could not batch write entry records to DynamoDB Elasticsearch table.", ex.code || "DELETE_REVISION_ERROR", {
987
+ throw new WebinyError(ex.message || "Could not batch write entry records to DynamoDB Elasticsearch table.", ex.code || "DELETE_REVISION_ERROR", {
1078
988
  error: ex,
1079
989
  entry,
1080
990
  latestEntry,
@@ -1098,28 +1008,22 @@ const createEntriesStorageOperations = params => {
1098
1008
  * Then we need to construct the queries for all the revisions and entries.
1099
1009
  */
1100
1010
 
1101
- const entityBatch = (0, _dbDynamodb.createEntityWriteBatch)({
1102
- entity
1103
- });
1104
- const elasticsearchEntityBatch = (0, _dbDynamodb.createEntityWriteBatch)({
1105
- entity: esEntity
1106
- });
1011
+ const entityBatch = entity.createEntityWriter();
1012
+ const elasticsearchEntityBatch = esEntity.createEntityWriter();
1107
1013
  for (const id of entries) {
1108
1014
  /**
1109
1015
  * Latest item.
1110
1016
  */
1111
1017
  entityBatch.delete({
1112
- PK: (0, _keys.createPartitionKey)({
1018
+ PK: createPartitionKey({
1113
1019
  id,
1114
- locale: model.locale,
1115
1020
  tenant: model.tenant
1116
1021
  }),
1117
1022
  SK: "L"
1118
1023
  });
1119
1024
  elasticsearchEntityBatch.delete({
1120
- PK: (0, _keys.createPartitionKey)({
1025
+ PK: createPartitionKey({
1121
1026
  id,
1122
- locale: model.locale,
1123
1027
  tenant: model.tenant
1124
1028
  }),
1125
1029
  SK: "L"
@@ -1129,17 +1033,15 @@ const createEntriesStorageOperations = params => {
1129
1033
  * Published item.
1130
1034
  */
1131
1035
  entityBatch.delete({
1132
- PK: (0, _keys.createPartitionKey)({
1036
+ PK: createPartitionKey({
1133
1037
  id,
1134
- locale: model.locale,
1135
1038
  tenant: model.tenant
1136
1039
  }),
1137
1040
  SK: "P"
1138
1041
  });
1139
1042
  elasticsearchEntityBatch.delete({
1140
- PK: (0, _keys.createPartitionKey)({
1043
+ PK: createPartitionKey({
1141
1044
  id,
1142
- locale: model.locale,
1143
1045
  tenant: model.tenant
1144
1046
  }),
1145
1047
  SK: "P"
@@ -1150,12 +1052,11 @@ const createEntriesStorageOperations = params => {
1150
1052
  */
1151
1053
  for (const revision of revisions) {
1152
1054
  entityBatch.delete({
1153
- PK: (0, _keys.createPartitionKey)({
1055
+ PK: createPartitionKey({
1154
1056
  id: revision.id,
1155
- locale: model.locale,
1156
1057
  tenant: model.tenant
1157
1058
  }),
1158
- SK: (0, _keys.createRevisionSortKey)({
1059
+ SK: createRevisionSortKey({
1159
1060
  version: revision.version
1160
1061
  })
1161
1062
  });
@@ -1165,18 +1066,26 @@ const createEntriesStorageOperations = params => {
1165
1066
  };
1166
1067
  const list = async (initialModel, params) => {
1167
1068
  const model = getStorageOperationsModel(initialModel);
1168
- const limit = (0, _apiElasticsearch.createLimit)(params.limit, 50);
1069
+ const limit = createLimit(params.limit, 50);
1169
1070
  const {
1170
1071
  index
1171
- } = _configurations.configurations.es({
1072
+ } = configurations.es({
1172
1073
  model
1173
1074
  });
1174
- const body = (0, _body.createElasticsearchBody)({
1075
+ const body = createElasticsearchBody({
1175
1076
  model,
1077
+ fieldRegistry,
1078
+ fieldIndexRegistry,
1079
+ bodyModifiers,
1080
+ sortModifiers,
1081
+ queryModifiers,
1082
+ valueSearchRegistry,
1083
+ fullTextSearches,
1084
+ filterRegistry,
1176
1085
  params: {
1177
1086
  ...params,
1178
1087
  limit,
1179
- after: (0, _apiElasticsearch.decodeCursor)(params.after)
1088
+ after: decodeCursor(params.after)
1180
1089
  },
1181
1090
  plugins
1182
1091
  });
@@ -1191,12 +1100,7 @@ const createEntriesStorageOperations = params => {
1191
1100
  * We will silently ignore the `index_not_found_exception` error and return an empty result set.
1192
1101
  * This is because the index might not exist yet, and we don't want to throw an error.
1193
1102
  */
1194
- if ((0, _shouldIgnoreEsResponseError.shouldIgnoreEsResponseError)(error)) {
1195
- (0, _logIgnoredEsResponseError.logIgnoredEsResponseError)({
1196
- error,
1197
- model,
1198
- indexName: index
1199
- });
1103
+ if (shouldIgnoreEsResponseError(error)) {
1200
1104
  return {
1201
1105
  hasMoreItems: false,
1202
1106
  totalCount: 0,
@@ -1204,7 +1108,7 @@ const createEntriesStorageOperations = params => {
1204
1108
  items: []
1205
1109
  };
1206
1110
  }
1207
- throw new _error.default(error.message, error.code || "ELASTICSEARCH_ERROR", {
1111
+ throw new WebinyError(error.message, error.code || "OPENSEARCH_ERROR", {
1208
1112
  error,
1209
1113
  index,
1210
1114
  body,
@@ -1214,13 +1118,16 @@ const createEntriesStorageOperations = params => {
1214
1118
  const {
1215
1119
  hits,
1216
1120
  total
1217
- } = response?.body?.hits || {};
1218
- const items = (0, _helpers.extractEntriesFromIndex)({
1219
- plugins,
1121
+ } = response.body.hits;
1122
+ const items = extractEntriesFromIndex({
1123
+ fieldRegistry,
1124
+ fieldIndexRegistry,
1220
1125
  model,
1221
- entries: hits.map(item => item._source)
1126
+ entries: hits.map(item => {
1127
+ return item._source;
1128
+ })
1222
1129
  }).map(item => {
1223
- return (0, _convertEntryKeys.convertEntryKeysFromStorage)({
1130
+ return convertEntryKeysFromStorage({
1224
1131
  model,
1225
1132
  entry: item
1226
1133
  });
@@ -1236,10 +1143,15 @@ const createEntriesStorageOperations = params => {
1236
1143
  * Cursor is the `sort` value of the last item in the array.
1237
1144
  * https://www.elastic.co/guide/en/elasticsearch/reference/current/paginate-search-results.html#search-after
1238
1145
  */
1239
- const cursor = items.length > 0 ? (0, _apiElasticsearch.encodeCursor)(hits[items.length - 1].sort) || null : null;
1146
+ /**
1147
+ * TODO expect errors over hit properties is required due to opensearch library narrowing types too much because of the _source: false. At least what Claude says, didnt go into it too much.
1148
+ * Properties are there, but types are not correct.
1149
+ */
1150
+ // @ts-expect-error
1151
+ const cursor = items.length > 0 ? encodeCursor(hits[items.length - 1].sort) || null : null;
1240
1152
  return {
1241
1153
  hasMoreItems,
1242
- totalCount: total.value,
1154
+ totalCount: getTotalCount(total),
1243
1155
  cursor,
1244
1156
  items
1245
1157
  };
@@ -1260,55 +1172,34 @@ const createEntriesStorageOperations = params => {
1260
1172
  storageEntry: initialStorageEntry
1261
1173
  } = params;
1262
1174
  const model = getStorageOperationsModel(initialModel);
1263
- const transformer = (0, _transformations.createTransformer)({
1264
- plugins,
1175
+ const transformer = createTransformer({
1176
+ valuesModifiers,
1265
1177
  model,
1266
1178
  entry: initialEntry,
1267
- storageEntry: initialStorageEntry
1179
+ storageEntry: initialStorageEntry,
1180
+ fieldRegistry,
1181
+ fieldIndexRegistry,
1182
+ compressionHandler
1268
1183
  });
1269
1184
  const {
1270
1185
  entry,
1271
1186
  storageEntry
1272
1187
  } = transformer.transformEntryKeys();
1273
- const revisionKeys = {
1274
- PK: (0, _keys.createPartitionKey)({
1275
- id: entry.id,
1276
- locale: model.locale,
1277
- tenant: model.tenant
1278
- }),
1279
- SK: (0, _keys.createRevisionSortKey)(entry)
1280
- };
1281
- const latestKeys = {
1282
- PK: (0, _keys.createPartitionKey)({
1283
- id: entry.id,
1284
- locale: model.locale,
1285
- tenant: model.tenant
1286
- }),
1287
- SK: (0, _keys.createLatestSortKey)()
1288
- };
1289
- const publishedKeys = {
1290
- PK: (0, _keys.createPartitionKey)({
1291
- id: entry.id,
1292
- locale: model.locale,
1293
- tenant: model.tenant
1294
- }),
1295
- SK: (0, _keys.createPublishedSortKey)()
1296
- };
1188
+ const revisionKeys = createEntryRevisionKeys(entry);
1189
+ const latestKeys = createEntryLatestKeys(entry);
1190
+ const publishedKeys = createEntryPublishedKeys(entry);
1297
1191
  let latestEsEntry = null;
1298
1192
  try {
1299
- latestEsEntry = await (0, _dbDynamodb.getClean)({
1300
- entity: esEntity,
1301
- keys: latestKeys
1302
- });
1193
+ latestEsEntry = await esEntity.getClean(latestKeys);
1303
1194
  } catch (ex) {
1304
- throw new _error.default(ex.message || "Could not read Elasticsearch latest data.", ex.code || "PUBLISH_LATEST_READ", {
1195
+ throw new WebinyError(ex.message || "Could not read Elasticsearch latest data.", ex.code || "PUBLISH_LATEST_READ", {
1305
1196
  error: ex,
1306
1197
  latestKeys: latestKeys,
1307
1198
  publishedKeys: publishedKeys
1308
1199
  });
1309
1200
  }
1310
1201
  if (!latestEsEntry) {
1311
- throw new _error.default(`Could not publish entry. Could not load latest ("L") record (ES table).`, "PUBLISH_ERROR", {
1202
+ throw new WebinyError(`Could not publish entry. Could not load latest ("L") record (ES table).`, "PUBLISH_ERROR", {
1312
1203
  entry
1313
1204
  });
1314
1205
  }
@@ -1321,7 +1212,7 @@ const createEntriesStorageOperations = params => {
1321
1212
  ids: [entry.id]
1322
1213
  });
1323
1214
  if (!latestStorageEntry) {
1324
- throw new _error.default(`Could not publish entry. Could not load latest ("L") record.`, "PUBLISH_ERROR", {
1215
+ throw new WebinyError(`Could not publish entry. Could not load latest ("L") record.`, "PUBLISH_ERROR", {
1325
1216
  entry
1326
1217
  });
1327
1218
  }
@@ -1335,24 +1226,19 @@ const createEntriesStorageOperations = params => {
1335
1226
  });
1336
1227
 
1337
1228
  // 1. Update REV# and P records with new data.
1338
- const entityBatch = (0, _dbDynamodb.createEntityWriteBatch)({
1339
- entity,
1229
+ const entityBatch = entity.createEntityWriter({
1340
1230
  put: [{
1341
- ...storageEntry,
1342
1231
  ...revisionKeys,
1343
- TYPE: (0, _recordType.createRecordType)()
1232
+ data: storageEntry
1344
1233
  }, {
1345
- ...storageEntry,
1346
1234
  ...publishedKeys,
1347
- TYPE: (0, _recordType.createPublishedRecordType)()
1235
+ data: storageEntry
1348
1236
  }]
1349
1237
  });
1350
- const elasticsearchEntityBatch = (0, _dbDynamodb.createEntityWriteBatch)({
1351
- entity: esEntity
1352
- });
1238
+ const elasticsearchEntityWriter = esEntity.createEntityWriter();
1353
1239
  const {
1354
1240
  index: esIndex
1355
- } = _configurations.configurations.es({
1241
+ } = configurations.es({
1356
1242
  model
1357
1243
  });
1358
1244
 
@@ -1363,8 +1249,8 @@ const createEntriesStorageOperations = params => {
1363
1249
  if (publishingLatestRevision) {
1364
1250
  // 2.1 If we're publishing the latest revision, we first need to update the L record.
1365
1251
  entityBatch.put({
1366
- ...storageEntry,
1367
- ...latestKeys
1252
+ ...latestKeys,
1253
+ data: storageEntry
1368
1254
  });
1369
1255
 
1370
1256
  // 2.2 Additionally, if we have a previously published entry, we need to mark it as unpublished.
@@ -1377,12 +1263,13 @@ const createEntriesStorageOperations = params => {
1377
1263
  /**
1378
1264
  * Update currently published entry (unpublish it)
1379
1265
  */
1266
+ const publishedStorageEntryKeys = createEntryRevisionKeys(publishedStorageEntry);
1380
1267
  entityBatch.put({
1381
- ...publishedStorageEntry,
1382
- status: _types.CONTENT_ENTRY_STATUS.UNPUBLISHED,
1383
- TYPE: (0, _recordType.createRecordType)(),
1384
- PK: (0, _keys.createPartitionKey)(publishedStorageEntry),
1385
- SK: (0, _keys.createRevisionSortKey)(publishedStorageEntry)
1268
+ ...publishedStorageEntryKeys,
1269
+ data: {
1270
+ ...publishedStorageEntry,
1271
+ status: CONTENT_ENTRY_STATUS.UNPUBLISHED
1272
+ }
1386
1273
  });
1387
1274
  }
1388
1275
  }
@@ -1390,32 +1277,30 @@ const createEntriesStorageOperations = params => {
1390
1277
  // 2.3 If the published revision is not the latest one, the situation is a bit
1391
1278
  // more complex. We first need to update the L and REV# records with the new
1392
1279
  // values of *only entry-level* meta fields.
1393
- const updatedEntryLevelMetaFields = (0, _constants.pickEntryMetaFields)(entry, _constants.isEntryLevelEntryMetaField);
1280
+ const updatedEntryLevelMetaFields = pickEntryMetaFields(entry, isEntryLevelEntryMetaField);
1394
1281
 
1395
1282
  // 2.4 Update L record. Apart from updating the entry-level meta fields, we also need
1396
1283
  // to change the status from "published" to "unpublished" (if the status is set to "published").
1397
1284
  let latestRevisionStatus = latestStorageEntry.status;
1398
- if (latestRevisionStatus === _types.CONTENT_ENTRY_STATUS.PUBLISHED) {
1399
- latestRevisionStatus = _types.CONTENT_ENTRY_STATUS.UNPUBLISHED;
1285
+ if (latestRevisionStatus === CONTENT_ENTRY_STATUS.PUBLISHED) {
1286
+ latestRevisionStatus = CONTENT_ENTRY_STATUS.UNPUBLISHED;
1400
1287
  }
1401
1288
  const latestStorageEntryFields = {
1402
1289
  ...latestStorageEntry,
1403
1290
  ...updatedEntryLevelMetaFields,
1404
1291
  status: latestRevisionStatus
1405
1292
  };
1293
+ const latestStorageEntryLatestKeys = createEntryLatestKeys(latestStorageEntry);
1406
1294
  entityBatch.put({
1407
- ...latestStorageEntryFields,
1408
- PK: (0, _keys.createPartitionKey)(latestStorageEntry),
1409
- SK: (0, _keys.createLatestSortKey)(),
1410
- TYPE: (0, _recordType.createLatestRecordType)()
1295
+ ...latestStorageEntryLatestKeys,
1296
+ data: latestStorageEntryFields
1411
1297
  });
1412
1298
 
1413
1299
  // 2.5 Update REV# record.
1300
+ const latestStorageEntryRevisionKeys = createEntryRevisionKeys(latestStorageEntry);
1414
1301
  entityBatch.put({
1415
- ...latestStorageEntryFields,
1416
- PK: (0, _keys.createPartitionKey)(latestStorageEntry),
1417
- SK: (0, _keys.createRevisionSortKey)(latestStorageEntry),
1418
- TYPE: (0, _recordType.createRecordType)()
1302
+ ...latestStorageEntryRevisionKeys,
1303
+ data: latestStorageEntryFields
1419
1304
  });
1420
1305
 
1421
1306
  // 2.6 Additionally, if we have a previously published entry, we need to mark it as unpublished.
@@ -1426,12 +1311,13 @@ const createEntriesStorageOperations = params => {
1426
1311
  const isRepublishing = publishedStorageEntry.id === entry.id;
1427
1312
  const publishedRevisionDifferentFromLatest = publishedRevisionId !== latestStorageEntry.id;
1428
1313
  if (!isRepublishing && publishedRevisionDifferentFromLatest) {
1314
+ const publishedStorageEntryRevisionKeys = createEntryRevisionKeys(publishedStorageEntry);
1429
1315
  entityBatch.put({
1430
- ...publishedStorageEntry,
1431
- PK: (0, _keys.createPartitionKey)(publishedStorageEntry),
1432
- SK: (0, _keys.createRevisionSortKey)(publishedStorageEntry),
1433
- TYPE: (0, _recordType.createRecordType)(),
1434
- status: _types.CONTENT_ENTRY_STATUS.UNPUBLISHED
1316
+ ...publishedStorageEntryRevisionKeys,
1317
+ data: {
1318
+ ...publishedStorageEntry,
1319
+ status: CONTENT_ENTRY_STATUS.UNPUBLISHED
1320
+ }
1435
1321
  });
1436
1322
  }
1437
1323
  }
@@ -1443,7 +1329,7 @@ const createEntriesStorageOperations = params => {
1443
1329
  * Update the published revision entry in ES.
1444
1330
  */
1445
1331
  const esPublishedData = await transformer.getElasticsearchPublishedEntryData();
1446
- elasticsearchEntityBatch.put({
1332
+ elasticsearchEntityWriter.put({
1447
1333
  ...publishedKeys,
1448
1334
  index: esIndex,
1449
1335
  data: esPublishedData
@@ -1455,47 +1341,47 @@ const createEntriesStorageOperations = params => {
1455
1341
  * No need to transform it for the storage because it was fetched
1456
1342
  * directly from the Elasticsearch table, where it sits transformed.
1457
1343
  */
1458
- const latestEsEntryDataDecompressed = await (0, _apiElasticsearch.decompress)(plugins, latestEsEntry.data);
1344
+ const latestEsEntryDataDecompressed = await compressionHandler.decompress(latestEsEntry.data);
1459
1345
  if (publishingLatestRevision) {
1460
- const updatedMetaFields = (0, _constants.pickEntryMetaFields)(entry);
1461
- const latestTransformer = (0, _transformations.createTransformer)({
1462
- plugins,
1346
+ const updatedMetaFields = pickEntryMetaFields(entry);
1347
+ const latestTransformer = createTransformer({
1348
+ valuesModifiers,
1463
1349
  model,
1464
1350
  transformedToIndex: {
1465
1351
  ...latestEsEntryDataDecompressed,
1466
- status: _types.CONTENT_ENTRY_STATUS.PUBLISHED,
1352
+ status: CONTENT_ENTRY_STATUS.PUBLISHED,
1467
1353
  locked: true,
1468
1354
  ...updatedMetaFields
1469
- }
1355
+ },
1356
+ fieldRegistry,
1357
+ fieldIndexRegistry,
1358
+ compressionHandler
1470
1359
  });
1471
- elasticsearchEntityBatch.put({
1360
+ const esEntryLatestKeys = createEntryLatestKeys(latestEsEntryDataDecompressed);
1361
+ elasticsearchEntityWriter.put({
1472
1362
  index: esIndex,
1473
- PK: (0, _keys.createPartitionKey)(latestEsEntryDataDecompressed),
1474
- SK: (0, _keys.createLatestSortKey)(),
1475
- data: await latestTransformer.getElasticsearchLatestEntryData()
1363
+ data: await latestTransformer.getElasticsearchLatestEntryData(),
1364
+ ...esEntryLatestKeys
1476
1365
  });
1477
1366
  } else {
1478
- const updatedEntryLevelMetaFields = (0, _constants.pickEntryMetaFields)(entry, _constants.isEntryLevelEntryMetaField);
1367
+ const updatedEntryLevelMetaFields = pickEntryMetaFields(entry, isEntryLevelEntryMetaField);
1479
1368
 
1480
1369
  /**
1481
1370
  * Update the Elasticsearch table to propagate changes to the Elasticsearch.
1482
1371
  */
1483
- const latestEsEntry = await (0, _dbDynamodb.getClean)({
1484
- entity: esEntity,
1485
- keys: latestKeys
1486
- });
1372
+ const latestEsEntry = await esEntity.getClean(latestKeys);
1487
1373
  if (latestEsEntry) {
1488
- const latestEsEntryDataDecompressed = await (0, _apiElasticsearch.decompress)(plugins, latestEsEntry.data);
1374
+ const latestEsEntryDataDecompressed = await compressionHandler.decompress(latestEsEntry.data);
1489
1375
  let latestRevisionStatus = latestEsEntryDataDecompressed.status;
1490
- if (latestRevisionStatus === _types.CONTENT_ENTRY_STATUS.PUBLISHED) {
1491
- latestRevisionStatus = _types.CONTENT_ENTRY_STATUS.UNPUBLISHED;
1376
+ if (latestRevisionStatus === CONTENT_ENTRY_STATUS.PUBLISHED) {
1377
+ latestRevisionStatus = CONTENT_ENTRY_STATUS.UNPUBLISHED;
1492
1378
  }
1493
- const updatedLatestEntry = await (0, _apiElasticsearch.compress)(plugins, {
1379
+ const updatedLatestEntry = await compressionHandler.compress({
1494
1380
  ...latestEsEntryDataDecompressed,
1495
1381
  ...updatedEntryLevelMetaFields,
1496
1382
  status: latestRevisionStatus
1497
1383
  });
1498
- elasticsearchEntityBatch.put({
1384
+ elasticsearchEntityWriter.put({
1499
1385
  ...latestKeys,
1500
1386
  index: esIndex,
1501
1387
  data: updatedLatestEntry
@@ -1512,7 +1398,7 @@ const createEntriesStorageOperations = params => {
1512
1398
  model
1513
1399
  });
1514
1400
  } catch (ex) {
1515
- throw new _error.default(ex.message || "Could not store publish entry records in DynamoDB table.", ex.code || "PUBLISH_ERROR", {
1401
+ throw new WebinyError(ex.message || "Could not store publish entry records in DynamoDB table.", ex.code || "PUBLISH_ERROR", {
1516
1402
  error: ex,
1517
1403
  entry,
1518
1404
  latestStorageEntry,
@@ -1523,9 +1409,9 @@ const createEntriesStorageOperations = params => {
1523
1409
  * And Elasticsearch table batch.
1524
1410
  */
1525
1411
  try {
1526
- await elasticsearchEntityBatch.execute();
1412
+ await elasticsearchEntityWriter.execute();
1527
1413
  } catch (ex) {
1528
- throw new _error.default(ex.message || "Could not store publish entry records in DynamoDB Elasticsearch table.", ex.code || "PUBLISH_ES_ERROR", {
1414
+ throw new WebinyError(ex.message || "Could not store publish entry records in DynamoDB Elasticsearch table.", ex.code || "PUBLISH_ES_ERROR", {
1529
1415
  error: ex,
1530
1416
  entry,
1531
1417
  latestStorageEntry,
@@ -1540,11 +1426,14 @@ const createEntriesStorageOperations = params => {
1540
1426
  storageEntry: initialStorageEntry
1541
1427
  } = params;
1542
1428
  const model = getStorageOperationsModel(initialModel);
1543
- const transformer = (0, _transformations.createTransformer)({
1544
- plugins,
1429
+ const transformer = createTransformer({
1430
+ valuesModifiers,
1545
1431
  model,
1546
1432
  entry: initialEntry,
1547
- storageEntry: initialStorageEntry
1433
+ storageEntry: initialStorageEntry,
1434
+ fieldRegistry,
1435
+ fieldIndexRegistry,
1436
+ compressionHandler
1548
1437
  });
1549
1438
  const {
1550
1439
  entry,
@@ -1558,29 +1447,25 @@ const createEntriesStorageOperations = params => {
1558
1447
  model,
1559
1448
  ids: [entry.id]
1560
1449
  });
1561
- const partitionKey = (0, _keys.createPartitionKey)({
1450
+ const partitionKey = createPartitionKey({
1562
1451
  id: entry.id,
1563
- locale: model.locale,
1564
1452
  tenant: model.tenant
1565
1453
  });
1566
- const entityBatch = (0, _dbDynamodb.createEntityWriteBatch)({
1567
- entity,
1454
+ const entryRevisionKeys = createEntryRevisionKeys(entry);
1455
+ const entityBatch = entity.createEntityWriter({
1568
1456
  put: [{
1569
- ...storageEntry,
1570
- PK: partitionKey,
1571
- SK: (0, _keys.createRevisionSortKey)(entry),
1572
- TYPE: (0, _recordType.createRecordType)()
1457
+ ...entryRevisionKeys,
1458
+ data: storageEntry
1573
1459
  }],
1574
1460
  delete: [{
1575
1461
  PK: partitionKey,
1576
- SK: (0, _keys.createPublishedSortKey)()
1462
+ SK: createPublishedSortKey()
1577
1463
  }]
1578
1464
  });
1579
- const elasticsearchEntityBatch = (0, _dbDynamodb.createEntityWriteBatch)({
1580
- entity: esEntity,
1465
+ const elasticsearchEntityBatch = esEntity.createEntityWriter({
1581
1466
  delete: [{
1582
1467
  PK: partitionKey,
1583
- SK: (0, _keys.createPublishedSortKey)()
1468
+ SK: createPublishedSortKey()
1584
1469
  }]
1585
1470
  });
1586
1471
 
@@ -1590,21 +1475,19 @@ const createEntriesStorageOperations = params => {
1590
1475
  if (latestStorageEntry?.id === entry.id) {
1591
1476
  const {
1592
1477
  index
1593
- } = _configurations.configurations.es({
1478
+ } = configurations.es({
1594
1479
  model
1595
1480
  });
1481
+ const entryLatestKeys = createEntryLatestKeys(storageEntry);
1596
1482
  entityBatch.put({
1597
- ...storageEntry,
1598
- PK: partitionKey,
1599
- SK: (0, _keys.createLatestSortKey)(),
1600
- TYPE: (0, _recordType.createLatestRecordType)()
1483
+ ...entryLatestKeys,
1484
+ data: storageEntry
1601
1485
  });
1602
1486
  const esLatestData = await transformer.getElasticsearchLatestEntryData();
1603
1487
  elasticsearchEntityBatch.put({
1604
- PK: partitionKey,
1605
- SK: (0, _keys.createLatestSortKey)(),
1606
1488
  index,
1607
- data: esLatestData
1489
+ data: esLatestData,
1490
+ ...entryLatestKeys
1608
1491
  });
1609
1492
  }
1610
1493
 
@@ -1617,7 +1500,7 @@ const createEntriesStorageOperations = params => {
1617
1500
  model
1618
1501
  });
1619
1502
  } catch (ex) {
1620
- throw new _error.default(ex.message || "Could not store unpublished entry records in DynamoDB table.", ex.code || "UNPUBLISH_ERROR", {
1503
+ throw new WebinyError(ex.message || "Could not store unpublished entry records in DynamoDB table.", ex.code || "UNPUBLISH_ERROR", {
1621
1504
  entry,
1622
1505
  storageEntry
1623
1506
  });
@@ -1628,7 +1511,7 @@ const createEntriesStorageOperations = params => {
1628
1511
  try {
1629
1512
  await elasticsearchEntityBatch.execute();
1630
1513
  } catch (ex) {
1631
- throw new _error.default(ex.message || "Could not store unpublished entry records in DynamoDB Elasticsearch table.", ex.code || "UNPUBLISH_ERROR", {
1514
+ throw new WebinyError(ex.message || "Could not store unpublished entry records in DynamoDB Elasticsearch table.", ex.code || "UNPUBLISH_ERROR", {
1632
1515
  entry,
1633
1516
  storageEntry
1634
1517
  });
@@ -1644,7 +1527,7 @@ const createEntriesStorageOperations = params => {
1644
1527
  if (!entry) {
1645
1528
  return null;
1646
1529
  }
1647
- return (0, _convertEntryKeys.convertEntryKeysFromStorage)({
1530
+ return convertEntryKeysFromStorage({
1648
1531
  model,
1649
1532
  entry
1650
1533
  });
@@ -1658,7 +1541,7 @@ const createEntriesStorageOperations = params => {
1658
1541
  if (!entry) {
1659
1542
  return null;
1660
1543
  }
1661
- return (0, _convertEntryKeys.convertEntryKeysFromStorage)({
1544
+ return convertEntryKeysFromStorage({
1662
1545
  model,
1663
1546
  entry
1664
1547
  });
@@ -1672,7 +1555,7 @@ const createEntriesStorageOperations = params => {
1672
1555
  if (!entry) {
1673
1556
  return null;
1674
1557
  }
1675
- return (0, _convertEntryKeys.convertEntryKeysFromStorage)({
1558
+ return convertEntryKeysFromStorage({
1676
1559
  model,
1677
1560
  entry
1678
1561
  });
@@ -1684,7 +1567,7 @@ const createEntriesStorageOperations = params => {
1684
1567
  ids: [params.id]
1685
1568
  });
1686
1569
  return entries.map(entry => {
1687
- return (0, _convertEntryKeys.convertEntryKeysFromStorage)({
1570
+ return convertEntryKeysFromStorage({
1688
1571
  model,
1689
1572
  entry
1690
1573
  });
@@ -1697,7 +1580,7 @@ const createEntriesStorageOperations = params => {
1697
1580
  ids: params.ids
1698
1581
  });
1699
1582
  return entries.map(entry => {
1700
- return (0, _convertEntryKeys.convertEntryKeysFromStorage)({
1583
+ return convertEntryKeysFromStorage({
1701
1584
  model,
1702
1585
  entry
1703
1586
  });
@@ -1710,7 +1593,7 @@ const createEntriesStorageOperations = params => {
1710
1593
  ids: params.ids
1711
1594
  });
1712
1595
  return entries.map(entry => {
1713
- return (0, _convertEntryKeys.convertEntryKeysFromStorage)({
1596
+ return convertEntryKeysFromStorage({
1714
1597
  model,
1715
1598
  entry
1716
1599
  });
@@ -1723,7 +1606,7 @@ const createEntriesStorageOperations = params => {
1723
1606
  ids: params.ids
1724
1607
  });
1725
1608
  return entries.map(entry => {
1726
- return (0, _convertEntryKeys.convertEntryKeysFromStorage)({
1609
+ return convertEntryKeysFromStorage({
1727
1610
  model,
1728
1611
  entry
1729
1612
  });
@@ -1732,51 +1615,44 @@ const createEntriesStorageOperations = params => {
1732
1615
  const getPreviousRevision = async (initialModel, params) => {
1733
1616
  const model = getStorageOperationsModel(initialModel);
1734
1617
  const {
1735
- tenant,
1736
- locale
1618
+ tenant
1737
1619
  } = model;
1738
1620
  const {
1739
1621
  entryId,
1740
1622
  version
1741
1623
  } = params;
1742
- const queryParams = {
1743
- entity,
1744
- partitionKey: (0, _keys.createPartitionKey)({
1745
- tenant,
1746
- locale,
1747
- id: entryId
1748
- }),
1749
- options: {
1750
- lt: `REV#${(0, _utils.zeroPad)(version)}`,
1751
- /**
1752
- * We need to have extra checks because DynamoDB will return published or latest record if there is no REV# record.
1753
- */
1754
- filters: [{
1755
- attr: "TYPE",
1756
- eq: (0, _recordType.createRecordType)()
1757
- }, {
1758
- attr: "version",
1759
- lt: version
1760
- }],
1761
- reverse: true
1762
- }
1624
+ const partitionKey = createPartitionKey({
1625
+ tenant,
1626
+ id: entryId
1627
+ });
1628
+ const options = {
1629
+ beginsWith: `REV#`,
1630
+ reverse: true
1763
1631
  };
1764
1632
  try {
1765
- const result = await (0, _dbDynamodb.queryOne)(queryParams);
1766
- const entry = (0, _dbDynamodb.cleanupItem)(entity, result);
1633
+ const unfilteredEntries = (await entity.queryAll({
1634
+ partitionKey,
1635
+ options
1636
+ })).map(item => {
1637
+ return item.data;
1638
+ });
1639
+ const entries = unfilteredEntries.filter(item => {
1640
+ return item.version < version;
1641
+ });
1642
+ const entry = entries[0];
1767
1643
  if (!entry) {
1768
1644
  return null;
1769
1645
  }
1770
- return (0, _convertEntryKeys.convertEntryKeysFromStorage)({
1646
+ return convertEntryKeysFromStorage({
1771
1647
  entry,
1772
1648
  model
1773
1649
  });
1774
1650
  } catch (ex) {
1775
- throw new _error.default(ex.message || "Could not get previous version of given entry.", ex.code || "GET_PREVIOUS_VERSION_ERROR", {
1651
+ throw new WebinyError(ex.message || "Could not get previous version of given entry.", ex.code || "GET_PREVIOUS_VERSION_ERROR", {
1776
1652
  ...params,
1777
1653
  error: ex,
1778
- partitionKey: queryParams.partitionKey,
1779
- options: queryParams.options,
1654
+ partitionKey,
1655
+ options,
1780
1656
  model
1781
1657
  });
1782
1658
  }
@@ -1788,11 +1664,19 @@ const createEntriesStorageOperations = params => {
1788
1664
  } = params;
1789
1665
  const {
1790
1666
  index
1791
- } = _configurations.configurations.es({
1667
+ } = configurations.es({
1792
1668
  model
1793
1669
  });
1794
- const initialBody = (0, _body.createElasticsearchBody)({
1670
+ const initialBody = createElasticsearchBody({
1795
1671
  model,
1672
+ fieldRegistry,
1673
+ fieldIndexRegistry,
1674
+ bodyModifiers,
1675
+ sortModifiers,
1676
+ queryModifiers,
1677
+ valueSearchRegistry,
1678
+ fullTextSearches,
1679
+ filterRegistry,
1796
1680
  params: {
1797
1681
  limit: 1,
1798
1682
  where
@@ -1801,7 +1685,7 @@ const createEntriesStorageOperations = params => {
1801
1685
  });
1802
1686
  const field = model.fields.find(f => f.fieldId === fieldId);
1803
1687
  if (!field) {
1804
- throw new _error.default(`Could not find field with given "fieldId" value.`, "FIELD_NOT_FOUND", {
1688
+ throw new WebinyError(`Could not find field with given "fieldId" value.`, "FIELD_NOT_FOUND", {
1805
1689
  fieldId
1806
1690
  });
1807
1691
  }
@@ -1827,26 +1711,23 @@ const createEntriesStorageOperations = params => {
1827
1711
  body
1828
1712
  });
1829
1713
  } catch (error) {
1830
- if ((0, _shouldIgnoreEsResponseError.shouldIgnoreEsResponseError)(error)) {
1831
- (0, _logIgnoredEsResponseError.logIgnoredEsResponseError)({
1832
- error,
1833
- model,
1834
- indexName: index
1835
- });
1714
+ if (shouldIgnoreEsResponseError(error)) {
1836
1715
  return [];
1837
1716
  }
1838
- throw new _error.default(error.message || "Error in the Elasticsearch query.", error.code || "ELASTICSEARCH_ERROR", {
1717
+ throw new WebinyError(error.message || "Error in the Elasticsearch query.", error.code || "OPENSEARCH_ERROR", {
1839
1718
  error,
1840
1719
  index,
1841
1720
  model,
1842
1721
  body
1843
1722
  });
1844
1723
  }
1845
- const buckets = response.body.aggregations["getUniqueFieldValues"]?.buckets || [];
1846
- return buckets.map(file => {
1724
+ const aggregations = response.body.aggregations || {};
1725
+ const agg = aggregations["getUniqueFieldValues"];
1726
+ const buckets = agg && "buckets" in agg && Array.isArray(agg.buckets) ? agg.buckets : [];
1727
+ return buckets.map(bucket => {
1847
1728
  return {
1848
- value: file.key,
1849
- count: file.doc_count
1729
+ value: bucket.key,
1730
+ count: bucket.doc_count
1850
1731
  };
1851
1732
  });
1852
1733
  };
@@ -1876,6 +1757,5 @@ const createEntriesStorageOperations = params => {
1876
1757
  dataLoaders
1877
1758
  };
1878
1759
  };
1879
- exports.createEntriesStorageOperations = createEntriesStorageOperations;
1880
1760
 
1881
1761
  //# sourceMappingURL=index.js.map