@webiny/api-headless-cms-ddb-es 6.4.5 → 6.6.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (384) hide show
  1. package/abstractions/CmsDdbEsDataLoaders.d.ts +5 -0
  2. package/abstractions/CmsDdbEsDataLoaders.js +5 -0
  3. package/abstractions/CmsDdbEsDataLoaders.js.map +1 -0
  4. package/abstractions/CmsDdbEsEntriesEsEntity.d.ts +5 -0
  5. package/abstractions/CmsDdbEsEntriesEsEntity.js +5 -0
  6. package/abstractions/CmsDdbEsEntriesEsEntity.js.map +1 -0
  7. package/abstractions/CmsDdbEsEntryEntity.d.ts +5 -0
  8. package/abstractions/CmsDdbEsEntryEntity.js +5 -0
  9. package/abstractions/CmsDdbEsEntryEntity.js.map +1 -0
  10. package/abstractions/CmsDdbEsGroupEntity.d.ts +5 -0
  11. package/abstractions/CmsDdbEsGroupEntity.js +5 -0
  12. package/abstractions/CmsDdbEsGroupEntity.js.map +1 -0
  13. package/abstractions/CmsDdbEsModelEntity.d.ts +5 -0
  14. package/abstractions/CmsDdbEsModelEntity.js +5 -0
  15. package/abstractions/CmsDdbEsModelEntity.js.map +1 -0
  16. package/abstractions/CmsDdbEsOsTable.d.ts +5 -0
  17. package/abstractions/CmsDdbEsOsTable.js +5 -0
  18. package/abstractions/CmsDdbEsOsTable.js.map +1 -0
  19. package/abstractions/CmsDdbEsTable.d.ts +5 -0
  20. package/abstractions/CmsDdbEsTable.js +5 -0
  21. package/abstractions/CmsDdbEsTable.js.map +1 -0
  22. package/feature.d.ts +4 -1
  23. package/feature.js +59 -157
  24. package/feature.js.map +1 -1
  25. package/index.d.ts +1 -1
  26. package/index.js +1 -1
  27. package/operations/entry/DdbEsCreateEntry.d.ts +23 -0
  28. package/operations/entry/DdbEsCreateEntry.js +131 -0
  29. package/operations/entry/DdbEsCreateEntry.js.map +1 -0
  30. package/operations/entry/DdbEsCreateEntryRevisionFrom.d.ts +23 -0
  31. package/operations/entry/DdbEsCreateEntryRevisionFrom.js +136 -0
  32. package/operations/entry/DdbEsCreateEntryRevisionFrom.js.map +1 -0
  33. package/operations/entry/DdbEsDeleteEntry.d.ts +18 -0
  34. package/operations/entry/DdbEsDeleteEntry.js +79 -0
  35. package/operations/entry/DdbEsDeleteEntry.js.map +1 -0
  36. package/operations/entry/DdbEsDeleteEntryRevision.d.ts +23 -0
  37. package/operations/entry/DdbEsDeleteEntryRevision.js +133 -0
  38. package/operations/entry/DdbEsDeleteEntryRevision.js.map +1 -0
  39. package/operations/entry/DdbEsDeleteMultipleEntries.d.ts +18 -0
  40. package/operations/entry/DdbEsDeleteMultipleEntries.js +77 -0
  41. package/operations/entry/DdbEsDeleteMultipleEntries.js.map +1 -0
  42. package/operations/entry/DdbEsGetEntriesByIds.d.ts +14 -0
  43. package/operations/entry/DdbEsGetEntriesByIds.js +31 -0
  44. package/operations/entry/DdbEsGetEntriesByIds.js.map +1 -0
  45. package/operations/entry/DdbEsGetEntry.d.ts +14 -0
  46. package/operations/entry/DdbEsGetEntry.js +27 -0
  47. package/operations/entry/DdbEsGetEntry.js.map +1 -0
  48. package/operations/entry/DdbEsGetLatestEntriesByIds.d.ts +14 -0
  49. package/operations/entry/DdbEsGetLatestEntriesByIds.js +31 -0
  50. package/operations/entry/DdbEsGetLatestEntriesByIds.js.map +1 -0
  51. package/operations/entry/DdbEsGetLatestRevisionByEntryId.d.ts +14 -0
  52. package/operations/entry/DdbEsGetLatestRevisionByEntryId.js +34 -0
  53. package/operations/entry/DdbEsGetLatestRevisionByEntryId.js.map +1 -0
  54. package/operations/entry/DdbEsGetPreviousRevision.d.ts +14 -0
  55. package/operations/entry/DdbEsGetPreviousRevision.js +56 -0
  56. package/operations/entry/DdbEsGetPreviousRevision.js.map +1 -0
  57. package/operations/entry/DdbEsGetPublishedEntriesByIds.d.ts +14 -0
  58. package/operations/entry/DdbEsGetPublishedEntriesByIds.js +31 -0
  59. package/operations/entry/DdbEsGetPublishedEntriesByIds.js.map +1 -0
  60. package/operations/entry/DdbEsGetPublishedRevisionByEntryId.d.ts +14 -0
  61. package/operations/entry/DdbEsGetPublishedRevisionByEntryId.js +34 -0
  62. package/operations/entry/DdbEsGetPublishedRevisionByEntryId.js.map +1 -0
  63. package/operations/entry/DdbEsGetRevisionById.d.ts +14 -0
  64. package/operations/entry/DdbEsGetRevisionById.js +34 -0
  65. package/operations/entry/DdbEsGetRevisionById.js.map +1 -0
  66. package/operations/entry/DdbEsGetRevisions.d.ts +14 -0
  67. package/operations/entry/DdbEsGetRevisions.js +33 -0
  68. package/operations/entry/DdbEsGetRevisions.js.map +1 -0
  69. package/operations/entry/DdbEsGetUniqueFieldValues.d.ts +17 -0
  70. package/operations/entry/DdbEsGetUniqueFieldValues.js +73 -0
  71. package/operations/entry/DdbEsGetUniqueFieldValues.js.map +1 -0
  72. package/operations/entry/DdbEsListEntries.d.ts +24 -0
  73. package/operations/entry/DdbEsListEntries.js +88 -0
  74. package/operations/entry/DdbEsListEntries.js.map +1 -0
  75. package/operations/entry/DdbEsMoveEntry.d.ts +20 -0
  76. package/operations/entry/DdbEsMoveEntry.js +113 -0
  77. package/operations/entry/DdbEsMoveEntry.js.map +1 -0
  78. package/operations/entry/DdbEsMoveToBin.d.ts +23 -0
  79. package/operations/entry/DdbEsMoveToBin.js +137 -0
  80. package/operations/entry/DdbEsMoveToBin.js.map +1 -0
  81. package/operations/entry/DdbEsPublishEntry.d.ts +23 -0
  82. package/operations/entry/DdbEsPublishEntry.js +228 -0
  83. package/operations/entry/DdbEsPublishEntry.js.map +1 -0
  84. package/operations/entry/DdbEsRestoreFromBin.d.ts +23 -0
  85. package/operations/entry/DdbEsRestoreFromBin.js +137 -0
  86. package/operations/entry/DdbEsRestoreFromBin.js.map +1 -0
  87. package/operations/entry/DdbEsUnpublishEntry.d.ts +23 -0
  88. package/operations/entry/DdbEsUnpublishEntry.js +124 -0
  89. package/operations/entry/DdbEsUnpublishEntry.js.map +1 -0
  90. package/operations/entry/DdbEsUpdateEntry.d.ts +23 -0
  91. package/operations/entry/DdbEsUpdateEntry.js +172 -0
  92. package/operations/entry/DdbEsUpdateEntry.js.map +1 -0
  93. package/operations/entry/dataLoaders.d.ts +5 -5
  94. package/operations/entry/dataLoaders.js +11 -3
  95. package/operations/entry/dataLoaders.js.map +1 -1
  96. package/{features/CmsModelOpenSearchIndex → operations/entry}/feature.d.ts +1 -1
  97. package/operations/entry/feature.js +55 -0
  98. package/operations/entry/feature.js.map +1 -0
  99. package/operations/entry/storageEntryUtils.d.ts +7 -0
  100. package/operations/entry/storageEntryUtils.js +14 -0
  101. package/operations/entry/storageEntryUtils.js.map +1 -0
  102. package/operations/entry/transformations/index.d.ts +2 -3
  103. package/operations/entry/transformations/index.js +1 -1
  104. package/operations/entry/transformations/index.js.map +1 -1
  105. package/operations/entry/transformations/modifyEntryValues.d.ts +2 -2
  106. package/operations/entry/transformations/modifyEntryValues.js.map +1 -1
  107. package/operations/group/DdbEsCreateGroup.d.ts +12 -0
  108. package/operations/group/DdbEsCreateGroup.js +35 -0
  109. package/operations/group/DdbEsCreateGroup.js.map +1 -0
  110. package/operations/group/DdbEsDeleteGroup.d.ts +12 -0
  111. package/operations/group/DdbEsDeleteGroup.js +31 -0
  112. package/operations/group/DdbEsDeleteGroup.js.map +1 -0
  113. package/operations/group/DdbEsGetGroup.d.ts +12 -0
  114. package/operations/group/DdbEsGetGroup.js +31 -0
  115. package/operations/group/DdbEsGetGroup.js.map +1 -0
  116. package/operations/group/DdbEsListGroups.d.ts +14 -0
  117. package/operations/group/DdbEsListGroups.js +52 -0
  118. package/operations/group/DdbEsListGroups.js.map +1 -0
  119. package/operations/group/DdbEsUpdateGroup.d.ts +12 -0
  120. package/operations/group/DdbEsUpdateGroup.js +35 -0
  121. package/operations/group/DdbEsUpdateGroup.js.map +1 -0
  122. package/{features/CmsEntryOpenSearchFilter → operations/group}/feature.d.ts +1 -1
  123. package/operations/group/feature.js +19 -0
  124. package/operations/group/feature.js.map +1 -0
  125. package/operations/group/keys.d.ts +15 -0
  126. package/operations/group/keys.js +17 -0
  127. package/operations/group/keys.js.map +1 -0
  128. package/operations/model/DdbEsCreateModel.d.ts +14 -0
  129. package/operations/model/DdbEsCreateModel.js +52 -0
  130. package/operations/model/DdbEsCreateModel.js.map +1 -0
  131. package/operations/model/DdbEsDeleteModel.d.ts +14 -0
  132. package/operations/model/DdbEsDeleteModel.js +50 -0
  133. package/operations/model/DdbEsDeleteModel.js.map +1 -0
  134. package/operations/model/DdbEsGetModel.d.ts +12 -0
  135. package/operations/model/DdbEsGetModel.js +30 -0
  136. package/operations/model/DdbEsGetModel.js.map +1 -0
  137. package/operations/model/DdbEsListModels.d.ts +12 -0
  138. package/operations/model/DdbEsListModels.js +36 -0
  139. package/operations/model/DdbEsListModels.js.map +1 -0
  140. package/operations/model/DdbEsUpdateModel.d.ts +12 -0
  141. package/operations/model/DdbEsUpdateModel.js +36 -0
  142. package/operations/model/DdbEsUpdateModel.js.map +1 -0
  143. package/{features/CmsEntryOpenSearchFieldIndex → operations/model}/feature.d.ts +1 -1
  144. package/operations/model/feature.js +19 -0
  145. package/operations/model/feature.js.map +1 -0
  146. package/operations/model/keys.d.ts +15 -0
  147. package/operations/model/keys.js +17 -0
  148. package/operations/model/keys.js.map +1 -0
  149. package/package.json +26 -22
  150. package/tasks/CreateElasticsearchIndexTask.d.ts +13 -0
  151. package/tasks/CreateElasticsearchIndexTask.js +49 -0
  152. package/tasks/CreateElasticsearchIndexTask.js.map +1 -0
  153. package/types.d.ts +10 -49
  154. package/types.js.map +1 -1
  155. package/configurations.d.ts +0 -22
  156. package/configurations.js +0 -37
  157. package/configurations.js.map +0 -1
  158. package/elasticsearch/createElasticsearchIndex.d.ts +0 -9
  159. package/elasticsearch/createElasticsearchIndex.js +0 -45
  160. package/elasticsearch/createElasticsearchIndex.js.map +0 -1
  161. package/elasticsearch/deleteElasticsearchIndex.d.ts +0 -10
  162. package/elasticsearch/deleteElasticsearchIndex.js +0 -23
  163. package/elasticsearch/deleteElasticsearchIndex.js.map +0 -1
  164. package/exports/api/cms/opensearch.d.ts +0 -9
  165. package/exports/api/cms/opensearch.js +0 -9
  166. package/features/CmsEntryOpenSearchBodyModifier/abstractions.d.ts +0 -16
  167. package/features/CmsEntryOpenSearchBodyModifier/abstractions.js +0 -5
  168. package/features/CmsEntryOpenSearchBodyModifier/abstractions.js.map +0 -1
  169. package/features/CmsEntryOpenSearchBodyModifier/index.d.ts +0 -1
  170. package/features/CmsEntryOpenSearchBodyModifier/index.js +0 -1
  171. package/features/CmsEntryOpenSearchFieldIndex/CmsEntryOpenSearchFieldIndexRegistry.d.ts +0 -14
  172. package/features/CmsEntryOpenSearchFieldIndex/CmsEntryOpenSearchFieldIndexRegistry.js +0 -42
  173. package/features/CmsEntryOpenSearchFieldIndex/CmsEntryOpenSearchFieldIndexRegistry.js.map +0 -1
  174. package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndex.d.ts +0 -32
  175. package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndex.js +0 -5
  176. package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndex.js.map +0 -1
  177. package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndexRegistry.d.ts +0 -11
  178. package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndexRegistry.js +0 -5
  179. package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndexRegistry.js.map +0 -1
  180. package/features/CmsEntryOpenSearchFieldIndex/constants.d.ts +0 -1
  181. package/features/CmsEntryOpenSearchFieldIndex/constants.js +0 -4
  182. package/features/CmsEntryOpenSearchFieldIndex/constants.js.map +0 -1
  183. package/features/CmsEntryOpenSearchFieldIndex/feature.js +0 -29
  184. package/features/CmsEntryOpenSearchFieldIndex/feature.js.map +0 -1
  185. package/features/CmsEntryOpenSearchFieldIndex/fields/DateTimeFieldIndex.d.ts +0 -11
  186. package/features/CmsEntryOpenSearchFieldIndex/fields/DateTimeFieldIndex.js +0 -60
  187. package/features/CmsEntryOpenSearchFieldIndex/fields/DateTimeFieldIndex.js.map +0 -1
  188. package/features/CmsEntryOpenSearchFieldIndex/fields/DefaultFieldIndex.d.ts +0 -13
  189. package/features/CmsEntryOpenSearchFieldIndex/fields/DefaultFieldIndex.js +0 -33
  190. package/features/CmsEntryOpenSearchFieldIndex/fields/DefaultFieldIndex.js.map +0 -1
  191. package/features/CmsEntryOpenSearchFieldIndex/fields/JsonFieldIndex.d.ts +0 -10
  192. package/features/CmsEntryOpenSearchFieldIndex/fields/JsonFieldIndex.js +0 -21
  193. package/features/CmsEntryOpenSearchFieldIndex/fields/JsonFieldIndex.js.map +0 -1
  194. package/features/CmsEntryOpenSearchFieldIndex/fields/LongTextFieldIndex.d.ts +0 -10
  195. package/features/CmsEntryOpenSearchFieldIndex/fields/LongTextFieldIndex.js +0 -22
  196. package/features/CmsEntryOpenSearchFieldIndex/fields/LongTextFieldIndex.js.map +0 -1
  197. package/features/CmsEntryOpenSearchFieldIndex/fields/NumberFieldIndex.d.ts +0 -11
  198. package/features/CmsEntryOpenSearchFieldIndex/fields/NumberFieldIndex.js +0 -32
  199. package/features/CmsEntryOpenSearchFieldIndex/fields/NumberFieldIndex.js.map +0 -1
  200. package/features/CmsEntryOpenSearchFieldIndex/fields/ObjectFieldIndex.d.ts +0 -12
  201. package/features/CmsEntryOpenSearchFieldIndex/fields/ObjectFieldIndex.js +0 -107
  202. package/features/CmsEntryOpenSearchFieldIndex/fields/ObjectFieldIndex.js.map +0 -1
  203. package/features/CmsEntryOpenSearchFieldIndex/fields/RichTextFieldIndex.d.ts +0 -10
  204. package/features/CmsEntryOpenSearchFieldIndex/fields/RichTextFieldIndex.js +0 -21
  205. package/features/CmsEntryOpenSearchFieldIndex/fields/RichTextFieldIndex.js.map +0 -1
  206. package/features/CmsEntryOpenSearchFieldIndex/fields/TextCompressedFieldIndex.d.ts +0 -15
  207. package/features/CmsEntryOpenSearchFieldIndex/fields/TextCompressedFieldIndex.js +0 -40
  208. package/features/CmsEntryOpenSearchFieldIndex/fields/TextCompressedFieldIndex.js.map +0 -1
  209. package/features/CmsEntryOpenSearchFieldIndex/fields/TextEncryptedFieldIndex.d.ts +0 -15
  210. package/features/CmsEntryOpenSearchFieldIndex/fields/TextEncryptedFieldIndex.js +0 -40
  211. package/features/CmsEntryOpenSearchFieldIndex/fields/TextEncryptedFieldIndex.js.map +0 -1
  212. package/features/CmsEntryOpenSearchFieldIndex/index.d.ts +0 -3
  213. package/features/CmsEntryOpenSearchFieldIndex/index.js +0 -3
  214. package/features/CmsEntryOpenSearchFilter/CmsEntryOpenSearchFilterRegistry.d.ts +0 -11
  215. package/features/CmsEntryOpenSearchFilter/CmsEntryOpenSearchFilterRegistry.js +0 -36
  216. package/features/CmsEntryOpenSearchFilter/CmsEntryOpenSearchFilterRegistry.js.map +0 -1
  217. package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilter.d.ts +0 -37
  218. package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilter.js +0 -5
  219. package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilter.js.map +0 -1
  220. package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilterRegistry.d.ts +0 -9
  221. package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilterRegistry.js +0 -5
  222. package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilterRegistry.js.map +0 -1
  223. package/features/CmsEntryOpenSearchFilter/constants.d.ts +0 -1
  224. package/features/CmsEntryOpenSearchFilter/constants.js +0 -4
  225. package/features/CmsEntryOpenSearchFilter/constants.js.map +0 -1
  226. package/features/CmsEntryOpenSearchFilter/feature.js +0 -17
  227. package/features/CmsEntryOpenSearchFilter/feature.js.map +0 -1
  228. package/features/CmsEntryOpenSearchFilter/fields/DefaultFilter.d.ts +0 -9
  229. package/features/CmsEntryOpenSearchFilter/fields/DefaultFilter.js +0 -26
  230. package/features/CmsEntryOpenSearchFilter/fields/DefaultFilter.js.map +0 -1
  231. package/features/CmsEntryOpenSearchFilter/fields/ObjectFilter.d.ts +0 -9
  232. package/features/CmsEntryOpenSearchFilter/fields/ObjectFilter.js +0 -43
  233. package/features/CmsEntryOpenSearchFilter/fields/ObjectFilter.js.map +0 -1
  234. package/features/CmsEntryOpenSearchFilter/fields/RefFilter.d.ts +0 -9
  235. package/features/CmsEntryOpenSearchFilter/fields/RefFilter.js +0 -36
  236. package/features/CmsEntryOpenSearchFilter/fields/RefFilter.js.map +0 -1
  237. package/features/CmsEntryOpenSearchFilter/index.d.ts +0 -3
  238. package/features/CmsEntryOpenSearchFilter/index.js +0 -3
  239. package/features/CmsEntryOpenSearchFullTextSearch/abstractions.d.ts +0 -20
  240. package/features/CmsEntryOpenSearchFullTextSearch/abstractions.js +0 -5
  241. package/features/CmsEntryOpenSearchFullTextSearch/abstractions.js.map +0 -1
  242. package/features/CmsEntryOpenSearchFullTextSearch/index.d.ts +0 -1
  243. package/features/CmsEntryOpenSearchFullTextSearch/index.js +0 -1
  244. package/features/CmsEntryOpenSearchQueryModifier/abstractions.d.ts +0 -16
  245. package/features/CmsEntryOpenSearchQueryModifier/abstractions.js +0 -5
  246. package/features/CmsEntryOpenSearchQueryModifier/abstractions.js.map +0 -1
  247. package/features/CmsEntryOpenSearchQueryModifier/index.d.ts +0 -1
  248. package/features/CmsEntryOpenSearchQueryModifier/index.js +0 -1
  249. package/features/CmsEntryOpenSearchSortModifier/abstractions.d.ts +0 -15
  250. package/features/CmsEntryOpenSearchSortModifier/abstractions.js +0 -5
  251. package/features/CmsEntryOpenSearchSortModifier/abstractions.js.map +0 -1
  252. package/features/CmsEntryOpenSearchSortModifier/index.d.ts +0 -1
  253. package/features/CmsEntryOpenSearchSortModifier/index.js +0 -1
  254. package/features/CmsEntryOpenSearchValueSearch/CmsEntryOpenSearchValueSearchRegistry.d.ts +0 -12
  255. package/features/CmsEntryOpenSearchValueSearch/CmsEntryOpenSearchValueSearchRegistry.js +0 -31
  256. package/features/CmsEntryOpenSearchValueSearch/CmsEntryOpenSearchValueSearchRegistry.js.map +0 -1
  257. package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearch.d.ts +0 -22
  258. package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearch.js +0 -5
  259. package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearch.js.map +0 -1
  260. package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearchRegistry.d.ts +0 -10
  261. package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearchRegistry.js +0 -5
  262. package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearchRegistry.js.map +0 -1
  263. package/features/CmsEntryOpenSearchValueSearch/feature.d.ts +0 -4
  264. package/features/CmsEntryOpenSearchValueSearch/feature.js +0 -17
  265. package/features/CmsEntryOpenSearchValueSearch/feature.js.map +0 -1
  266. package/features/CmsEntryOpenSearchValueSearch/fields/RefSearch.d.ts +0 -10
  267. package/features/CmsEntryOpenSearchValueSearch/fields/RefSearch.js +0 -21
  268. package/features/CmsEntryOpenSearchValueSearch/fields/RefSearch.js.map +0 -1
  269. package/features/CmsEntryOpenSearchValueSearch/fields/SearchableJsonSearch.d.ts +0 -10
  270. package/features/CmsEntryOpenSearchValueSearch/fields/SearchableJsonSearch.js +0 -44
  271. package/features/CmsEntryOpenSearchValueSearch/fields/SearchableJsonSearch.js.map +0 -1
  272. package/features/CmsEntryOpenSearchValueSearch/fields/TimeSearch.d.ts +0 -10
  273. package/features/CmsEntryOpenSearchValueSearch/fields/TimeSearch.js +0 -22
  274. package/features/CmsEntryOpenSearchValueSearch/fields/TimeSearch.js.map +0 -1
  275. package/features/CmsEntryOpenSearchValueSearch/index.d.ts +0 -3
  276. package/features/CmsEntryOpenSearchValueSearch/index.js +0 -3
  277. package/features/CmsEntryOpenSearchValuesModifier/abstractions.d.ts +0 -23
  278. package/features/CmsEntryOpenSearchValuesModifier/abstractions.js +0 -5
  279. package/features/CmsEntryOpenSearchValuesModifier/abstractions.js.map +0 -1
  280. package/features/CmsEntryOpenSearchValuesModifier/index.d.ts +0 -1
  281. package/features/CmsEntryOpenSearchValuesModifier/index.js +0 -1
  282. package/features/CmsModelOpenSearchIndex/CmsModelOpenSearchIndexProvider.d.ts +0 -25
  283. package/features/CmsModelOpenSearchIndex/CmsModelOpenSearchIndexProvider.js +0 -36
  284. package/features/CmsModelOpenSearchIndex/CmsModelOpenSearchIndexProvider.js.map +0 -1
  285. package/features/CmsModelOpenSearchIndex/DefaultCmsModelOpenSearchIndex.d.ts +0 -8
  286. package/features/CmsModelOpenSearchIndex/DefaultCmsModelOpenSearchIndex.js +0 -17
  287. package/features/CmsModelOpenSearchIndex/DefaultCmsModelOpenSearchIndex.js.map +0 -1
  288. package/features/CmsModelOpenSearchIndex/abstractions.d.ts +0 -20
  289. package/features/CmsModelOpenSearchIndex/abstractions.js +0 -5
  290. package/features/CmsModelOpenSearchIndex/abstractions.js.map +0 -1
  291. package/features/CmsModelOpenSearchIndex/feature.js +0 -13
  292. package/features/CmsModelOpenSearchIndex/feature.js.map +0 -1
  293. package/features/CmsModelOpenSearchIndex/index.d.ts +0 -3
  294. package/features/CmsModelOpenSearchIndex/index.js +0 -3
  295. package/helpers/entryIndexHelpers.d.ts +0 -20
  296. package/helpers/entryIndexHelpers.js +0 -80
  297. package/helpers/entryIndexHelpers.js.map +0 -1
  298. package/helpers/fieldIdentifier.d.ts +0 -6
  299. package/helpers/fieldIdentifier.js +0 -23
  300. package/helpers/fieldIdentifier.js.map +0 -1
  301. package/helpers/index.d.ts +0 -2
  302. package/helpers/index.js +0 -2
  303. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.d.ts +0 -18
  304. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js +0 -9
  305. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js.map +0 -1
  306. package/operations/entry/elasticsearch/body.d.ts +0 -30
  307. package/operations/entry/elasticsearch/body.js +0 -88
  308. package/operations/entry/elasticsearch/body.js.map +0 -1
  309. package/operations/entry/elasticsearch/fields/createSystemField.d.ts +0 -4
  310. package/operations/entry/elasticsearch/fields/createSystemField.js +0 -9
  311. package/operations/entry/elasticsearch/fields/createSystemField.js.map +0 -1
  312. package/operations/entry/elasticsearch/fields/live.d.ts +0 -2
  313. package/operations/entry/elasticsearch/fields/live.js +0 -50
  314. package/operations/entry/elasticsearch/fields/live.js.map +0 -1
  315. package/operations/entry/elasticsearch/fields/location.d.ts +0 -2
  316. package/operations/entry/elasticsearch/fields/location.js +0 -50
  317. package/operations/entry/elasticsearch/fields/location.js.map +0 -1
  318. package/operations/entry/elasticsearch/fields/state.d.ts +0 -2
  319. package/operations/entry/elasticsearch/fields/state.js +0 -104
  320. package/operations/entry/elasticsearch/fields/state.js.map +0 -1
  321. package/operations/entry/elasticsearch/fields.d.ts +0 -12
  322. package/operations/entry/elasticsearch/fields.js +0 -207
  323. package/operations/entry/elasticsearch/fields.js.map +0 -1
  324. package/operations/entry/elasticsearch/filtering/applyFiltering.d.ts +0 -9
  325. package/operations/entry/elasticsearch/filtering/applyFiltering.js +0 -39
  326. package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +0 -1
  327. package/operations/entry/elasticsearch/filtering/exec.d.ts +0 -22
  328. package/operations/entry/elasticsearch/filtering/exec.js +0 -96
  329. package/operations/entry/elasticsearch/filtering/exec.js.map +0 -1
  330. package/operations/entry/elasticsearch/filtering/index.d.ts +0 -1
  331. package/operations/entry/elasticsearch/filtering/index.js +0 -1
  332. package/operations/entry/elasticsearch/filtering/path.d.ts +0 -17
  333. package/operations/entry/elasticsearch/filtering/path.js +0 -27
  334. package/operations/entry/elasticsearch/filtering/path.js.map +0 -1
  335. package/operations/entry/elasticsearch/filtering/populated.d.ts +0 -2
  336. package/operations/entry/elasticsearch/filtering/populated.js +0 -12
  337. package/operations/entry/elasticsearch/filtering/populated.js.map +0 -1
  338. package/operations/entry/elasticsearch/filtering/values.d.ts +0 -2
  339. package/operations/entry/elasticsearch/filtering/values.js +0 -15
  340. package/operations/entry/elasticsearch/filtering/values.js.map +0 -1
  341. package/operations/entry/elasticsearch/fullTextSearch.d.ts +0 -13
  342. package/operations/entry/elasticsearch/fullTextSearch.js +0 -51
  343. package/operations/entry/elasticsearch/fullTextSearch.js.map +0 -1
  344. package/operations/entry/elasticsearch/fullTextSearchFields.d.ts +0 -8
  345. package/operations/entry/elasticsearch/fullTextSearchFields.js +0 -10
  346. package/operations/entry/elasticsearch/fullTextSearchFields.js.map +0 -1
  347. package/operations/entry/elasticsearch/initialQuery.d.ts +0 -18
  348. package/operations/entry/elasticsearch/initialQuery.js +0 -43
  349. package/operations/entry/elasticsearch/initialQuery.js.map +0 -1
  350. package/operations/entry/elasticsearch/keyword.d.ts +0 -2
  351. package/operations/entry/elasticsearch/keyword.js +0 -17
  352. package/operations/entry/elasticsearch/keyword.js.map +0 -1
  353. package/operations/entry/elasticsearch/plugins/operator.d.ts +0 -7
  354. package/operations/entry/elasticsearch/plugins/operator.js +0 -13
  355. package/operations/entry/elasticsearch/plugins/operator.js.map +0 -1
  356. package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.d.ts +0 -2
  357. package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js +0 -8
  358. package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js.map +0 -1
  359. package/operations/entry/elasticsearch/sort.d.ts +0 -12
  360. package/operations/entry/elasticsearch/sort.js +0 -80
  361. package/operations/entry/elasticsearch/sort.js.map +0 -1
  362. package/operations/entry/elasticsearch/transformValueForSearch.d.ts +0 -9
  363. package/operations/entry/elasticsearch/transformValueForSearch.js +0 -12
  364. package/operations/entry/elasticsearch/transformValueForSearch.js.map +0 -1
  365. package/operations/entry/elasticsearch/types.d.ts +0 -34
  366. package/operations/entry/elasticsearch/types.js +0 -0
  367. package/operations/entry/index.d.ts +0 -34
  368. package/operations/entry/index.js +0 -1366
  369. package/operations/entry/index.js.map +0 -1
  370. package/operations/entry/transformations/transformEntryToIndex.d.ts +0 -10
  371. package/operations/entry/transformations/transformEntryToIndex.js +0 -20
  372. package/operations/entry/transformations/transformEntryToIndex.js.map +0 -1
  373. package/operations/group/index.d.ts +0 -9
  374. package/operations/group/index.js +0 -121
  375. package/operations/group/index.js.map +0 -1
  376. package/operations/model/index.d.ts +0 -10
  377. package/operations/model/index.js +0 -119
  378. package/operations/model/index.js.map +0 -1
  379. package/tasks/createIndexTaskPlugin.d.ts +0 -2
  380. package/tasks/createIndexTaskPlugin.js +0 -36
  381. package/tasks/createIndexTaskPlugin.js.map +0 -1
  382. package/values/NoValueContainer.d.ts +0 -5
  383. package/values/NoValueContainer.js +0 -11
  384. package/values/NoValueContainer.js.map +0 -1
@@ -1,1366 +0,0 @@
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 { createLimit, decodeCursor, encodeCursor } from "@webiny/api-opensearch";
5
- import { DataLoadersHandler } from "./dataLoaders.js";
6
- import { createEntryLatestKeys, createEntryPublishedKeys, createEntryRevisionKeys, createLatestSortKey, createPartitionKey, createPublishedSortKey, createRevisionSortKey } from "./keys.js";
7
- import { getTotalCount } from "@webiny/api-opensearch/types.js";
8
- import { createElasticsearchBody } from "./elasticsearch/body.js";
9
- import { shouldIgnoreEsResponseError } from "./elasticsearch/shouldIgnoreEsResponseError.js";
10
- import { StorageOperationsCmsModelPlugin } from "@webiny/api-headless-cms";
11
- import { createTransformer } from "./transformations/index.js";
12
- import { convertEntryKeysFromStorage } from "./transformations/convertEntryKeys.js";
13
- import { isDeletedEntryMetaField, isEntryLevelEntryMetaField, isRestoredEntryMetaField, pickEntryMetaFields } from "@webiny/api-headless-cms/constants.js";
14
- const convertToStorageEntry = (params)=>{
15
- const { model, storageEntry } = params;
16
- const values = model.convertValueKeyToStorage({
17
- fields: model.fields,
18
- values: storageEntry.values
19
- });
20
- return {
21
- ...storageEntry,
22
- values
23
- };
24
- };
25
- const createEntriesStorageOperations = (params)=>{
26
- const { entity, esEntity, elasticsearch, plugins, configurations, fieldRegistry, fieldIndexRegistry, compressionHandler, bodyModifiers, sortModifiers, queryModifiers, valueSearchRegistry, fullTextSearches, valuesModifiers, filterRegistry } = params;
27
- let storageOperationsCmsModelPlugin;
28
- const getStorageOperationsCmsModelPlugin = ()=>{
29
- if (storageOperationsCmsModelPlugin) return storageOperationsCmsModelPlugin;
30
- storageOperationsCmsModelPlugin = plugins.oneByType(StorageOperationsCmsModelPlugin.type);
31
- return storageOperationsCmsModelPlugin;
32
- };
33
- const getStorageOperationsModel = (model)=>{
34
- const plugin = getStorageOperationsCmsModelPlugin();
35
- return plugin.getModel(model);
36
- };
37
- const dataLoaders = new DataLoadersHandler({
38
- entity
39
- });
40
- const create = async (initialModel, params)=>{
41
- const { entry: initialEntry, storageEntry: initialStorageEntry } = params;
42
- const model = getStorageOperationsModel(initialModel);
43
- const isPublished = "published" === initialEntry.status;
44
- const locked = isPublished ? true : initialEntry.locked;
45
- initialEntry.locked = locked;
46
- initialStorageEntry.locked = locked;
47
- const transformer = createTransformer({
48
- fieldIndexRegistry,
49
- model,
50
- entry: initialEntry,
51
- storageEntry: initialStorageEntry,
52
- compressionHandler,
53
- valuesModifiers
54
- });
55
- const { entry, storageEntry } = transformer.transformEntryKeys();
56
- const esEntry = transformer.transformToIndex();
57
- const { index: esIndex } = await configurations.es({
58
- model
59
- });
60
- const revisionKeys = createEntryRevisionKeys(entry);
61
- const latestKeys = createEntryLatestKeys(entry);
62
- const publishedKeys = createEntryPublishedKeys(entry);
63
- const entityBatch = entity.createEntityWriter({
64
- put: [
65
- {
66
- ...revisionKeys,
67
- data: {
68
- ...storageEntry,
69
- locked
70
- }
71
- },
72
- {
73
- ...latestKeys,
74
- data: {
75
- ...storageEntry,
76
- locked
77
- }
78
- }
79
- ]
80
- });
81
- if (isPublished) entityBatch.put({
82
- ...publishedKeys,
83
- data: {
84
- ...storageEntry,
85
- locked
86
- }
87
- });
88
- try {
89
- await entityBatch.execute();
90
- dataLoaders.clearAll({
91
- tenant: entry.tenant
92
- });
93
- } catch (ex) {
94
- throw new WebinyError(ex.message || "Could not insert entry data into the DynamoDB table.", ex.code || "CREATE_ENTRY_ERROR", {
95
- error: ex,
96
- entry,
97
- storageEntry
98
- });
99
- }
100
- const esLatestData = await transformer.getElasticsearchLatestEntryData();
101
- const elasticsearchEntityBatch = esEntity.createEntityWriter({
102
- put: [
103
- {
104
- ...latestKeys,
105
- index: esIndex,
106
- data: esLatestData
107
- }
108
- ]
109
- });
110
- if (isPublished) {
111
- const esPublishedData = await transformer.getElasticsearchPublishedEntryData();
112
- elasticsearchEntityBatch.put({
113
- ...publishedKeys,
114
- index: esIndex,
115
- data: esPublishedData
116
- });
117
- }
118
- try {
119
- await elasticsearchEntityBatch.execute();
120
- } catch (ex) {
121
- throw new WebinyError(ex.message || "Could not insert entry data into the Elasticsearch DynamoDB table.", ex.code || "CREATE_ES_ENTRY_ERROR", {
122
- error: ex,
123
- entry,
124
- esEntry
125
- });
126
- }
127
- return initialStorageEntry;
128
- };
129
- const createRevisionFrom = async (initialModel, params)=>{
130
- const { entry: initialEntry, storageEntry: initialStorageEntry } = params;
131
- const model = getStorageOperationsModel(initialModel);
132
- const transformer = createTransformer({
133
- model,
134
- entry: initialEntry,
135
- storageEntry: initialStorageEntry,
136
- fieldIndexRegistry,
137
- compressionHandler,
138
- valuesModifiers
139
- });
140
- const { entry, storageEntry } = transformer.transformEntryKeys();
141
- const revisionKeys = createEntryRevisionKeys(entry);
142
- const latestKeys = createEntryLatestKeys(entry);
143
- const publishedKeys = createEntryPublishedKeys(entry);
144
- const isPublished = "published" === entry.status;
145
- const esLatestData = await transformer.getElasticsearchLatestEntryData();
146
- const entityBatch = entity.createEntityWriter({
147
- put: [
148
- {
149
- ...revisionKeys,
150
- data: storageEntry
151
- },
152
- {
153
- ...latestKeys,
154
- data: storageEntry
155
- }
156
- ]
157
- });
158
- if (isPublished) {
159
- entityBatch.put({
160
- ...publishedKeys,
161
- data: storageEntry
162
- });
163
- const [publishedRevisionStorageEntry] = await dataLoaders.getPublishedRevisionByEntryId({
164
- model,
165
- ids: [
166
- entry.id
167
- ]
168
- });
169
- if (publishedRevisionStorageEntry) {
170
- const publishedRevisionKey = createEntryRevisionKeys(publishedRevisionStorageEntry);
171
- entityBatch.put({
172
- ...publishedRevisionKey,
173
- data: {
174
- ...publishedRevisionStorageEntry,
175
- status: CONTENT_ENTRY_STATUS.UNPUBLISHED
176
- }
177
- });
178
- }
179
- }
180
- try {
181
- await entityBatch.execute();
182
- dataLoaders.clearAll({
183
- tenant: entry.tenant
184
- });
185
- } catch (ex) {
186
- throw new WebinyError(ex.message || "Could not create revision from given entry in the DynamoDB table.", ex.code || "CREATE_REVISION_ERROR", {
187
- error: ex,
188
- entry,
189
- storageEntry
190
- });
191
- }
192
- const { index: esIndex } = await configurations.es({
193
- model
194
- });
195
- const elasticsearchEntityBatch = esEntity.createEntityWriter({
196
- put: [
197
- {
198
- ...latestKeys,
199
- index: esIndex,
200
- data: esLatestData
201
- }
202
- ]
203
- });
204
- if (isPublished) {
205
- const esPublishedData = await transformer.getElasticsearchPublishedEntryData();
206
- elasticsearchEntityBatch.put({
207
- ...publishedKeys,
208
- index: esIndex,
209
- data: esPublishedData
210
- });
211
- }
212
- try {
213
- await elasticsearchEntityBatch.execute();
214
- } catch (ex) {
215
- throw new WebinyError(ex.message || "Could not update latest entry in the DynamoDB Elasticsearch table.", ex.code || "CREATE_REVISION_ERROR", {
216
- error: ex,
217
- entry
218
- });
219
- }
220
- return initialStorageEntry;
221
- };
222
- const update = async (initialModel, params)=>{
223
- const { entry: initialEntry, storageEntry: initialStorageEntry } = params;
224
- const model = getStorageOperationsModel(initialModel);
225
- const transformer = createTransformer({
226
- valuesModifiers,
227
- model,
228
- entry: initialEntry,
229
- storageEntry: initialStorageEntry,
230
- fieldIndexRegistry,
231
- compressionHandler
232
- });
233
- const { entry, storageEntry } = transformer.transformEntryKeys();
234
- const isPublished = "published" === entry.status;
235
- const locked = isPublished ? true : entry.locked;
236
- const revisionKeys = createEntryRevisionKeys(entry);
237
- const latestKeys = createEntryLatestKeys(entry);
238
- const publishedKeys = createEntryPublishedKeys(entry);
239
- const [latestStorageEntry] = await dataLoaders.getLatestRevisionByEntryId({
240
- model,
241
- ids: [
242
- entry.id
243
- ]
244
- });
245
- const [publishedStorageEntry] = await dataLoaders.getPublishedRevisionByEntryId({
246
- model,
247
- ids: [
248
- entry.id
249
- ]
250
- });
251
- const entityBatch = entity.createEntityWriter({
252
- put: [
253
- {
254
- ...revisionKeys,
255
- data: {
256
- ...storageEntry,
257
- locked
258
- }
259
- }
260
- ]
261
- });
262
- if (isPublished) entityBatch.put({
263
- ...publishedKeys,
264
- data: {
265
- ...storageEntry,
266
- locked
267
- }
268
- });
269
- const elasticsearchEntityBatch = esEntity.createEntityWriter();
270
- const { index: esIndex } = await configurations.es({
271
- model
272
- });
273
- if (latestStorageEntry) {
274
- const updatingLatestRevision = latestStorageEntry.id === entry.id;
275
- if (updatingLatestRevision) {
276
- entityBatch.put({
277
- ...latestKeys,
278
- data: storageEntry
279
- });
280
- const elasticsearchLatestData = await transformer.getElasticsearchLatestEntryData();
281
- elasticsearchEntityBatch.put({
282
- ...latestKeys,
283
- index: esIndex,
284
- data: elasticsearchLatestData
285
- });
286
- } else {
287
- const updatedEntryLevelMetaFields = pickEntryMetaFields(entry, isEntryLevelEntryMetaField);
288
- const updatedLatestStorageEntry = {
289
- ...latestKeys,
290
- data: {
291
- ...latestStorageEntry,
292
- ...updatedEntryLevelMetaFields
293
- }
294
- };
295
- entityBatch.put({
296
- ...updatedLatestStorageEntry,
297
- PK: createPartitionKey({
298
- id: latestStorageEntry.id,
299
- tenant: model.tenant
300
- }),
301
- SK: createRevisionSortKey(latestStorageEntry)
302
- });
303
- entityBatch.put({
304
- ...updatedLatestStorageEntry
305
- });
306
- const latestEsEntry = await esEntity.getClean(latestKeys);
307
- if (latestEsEntry) {
308
- const latestEsEntryDataDecompressed = await compressionHandler.decompress(latestEsEntry.data);
309
- const updatedLatestEntry = await compressionHandler.compress({
310
- ...latestEsEntryDataDecompressed,
311
- ...updatedEntryLevelMetaFields
312
- });
313
- elasticsearchEntityBatch.put({
314
- ...latestKeys,
315
- index: esIndex,
316
- data: updatedLatestEntry
317
- });
318
- }
319
- }
320
- }
321
- if (isPublished && publishedStorageEntry?.id === entry.id) {
322
- const elasticsearchPublishedData = await transformer.getElasticsearchPublishedEntryData();
323
- elasticsearchEntityBatch.put({
324
- ...publishedKeys,
325
- index: esIndex,
326
- data: elasticsearchPublishedData
327
- });
328
- }
329
- try {
330
- await entityBatch.execute();
331
- dataLoaders.clearAll({
332
- tenant: entry.tenant
333
- });
334
- } catch (ex) {
335
- throw new WebinyError(ex.message || "Could not update entry DynamoDB records.", ex.code || "UPDATE_ENTRY_ERROR", {
336
- error: ex,
337
- entry,
338
- storageEntry
339
- });
340
- }
341
- try {
342
- await elasticsearchEntityBatch.execute();
343
- } catch (ex) {
344
- throw new WebinyError(ex.message || "Could not update entry DynamoDB Elasticsearch records.", ex.code || "UPDATE_ES_ENTRY_ERROR", {
345
- error: ex,
346
- entry
347
- });
348
- }
349
- return initialStorageEntry;
350
- };
351
- const move = async (initialModel, id, folderId)=>{
352
- const model = getStorageOperationsModel(initialModel);
353
- const partitionKey = createPartitionKey({
354
- id,
355
- tenant: model.tenant
356
- });
357
- const queryAllParams = {
358
- partitionKey,
359
- options: {
360
- gte: " "
361
- }
362
- };
363
- const latestSortKey = createLatestSortKey();
364
- const publishedSortKey = createPublishedSortKey();
365
- const records = await entity.queryAll(queryAllParams);
366
- let latestRecord;
367
- let publishedRecord;
368
- const entityBatch = entity.createEntityWriter();
369
- for (const record of records){
370
- entityBatch.put({
371
- ...record,
372
- data: {
373
- ...record.data,
374
- location: {
375
- ...record.data.location,
376
- folderId
377
- }
378
- }
379
- });
380
- if (record.SK === publishedSortKey) publishedRecord = record.data;
381
- else if (record.SK === latestSortKey) latestRecord = record.data;
382
- }
383
- try {
384
- await entityBatch.execute();
385
- dataLoaders.clearAll({
386
- tenant: initialModel.tenant
387
- });
388
- } catch (ex) {
389
- throw new WebinyError(ex.message || "Could not move all entry records from in the DynamoDB table.", ex.code || "MOVE_ENTRY_ERROR", {
390
- error: ex,
391
- id
392
- });
393
- }
394
- const esEntityReader = esEntity.createEntityReader();
395
- if (publishedRecord) esEntityReader.get({
396
- PK: partitionKey,
397
- SK: publishedSortKey
398
- });
399
- if (latestRecord) esEntityReader.get({
400
- PK: partitionKey,
401
- SK: latestSortKey
402
- });
403
- if (0 === esEntityReader.total) return;
404
- const esRecords = await esEntityReader.execute();
405
- const esItems = (await Promise.all(esRecords.map(async (record)=>{
406
- if (!record) return null;
407
- return {
408
- ...record,
409
- data: await compressionHandler.decompress(record.data)
410
- };
411
- }))).filter((item)=>!!item);
412
- if (0 === esItems.length) return;
413
- try {
414
- const elasticsearchEntityBatch = esEntity.createEntityWriter({
415
- put: await Promise.all(esItems.map(async (item)=>({
416
- ...item,
417
- data: await compressionHandler.compress({
418
- ...item.data,
419
- location: {
420
- ...item.data?.location,
421
- folderId
422
- }
423
- })
424
- })))
425
- });
426
- await elasticsearchEntityBatch.execute();
427
- } catch (ex) {
428
- throw new WebinyError(ex.message || "Could not move entry DynamoDB Elasticsearch records.", ex.code || "MOVE_ES_ENTRY_ERROR", {
429
- error: ex,
430
- partitionKey
431
- });
432
- }
433
- };
434
- const moveToBin = async (initialModel, params)=>{
435
- const { entry: initialEntry, storageEntry: initialStorageEntry } = params;
436
- const model = getStorageOperationsModel(initialModel);
437
- const transformer = createTransformer({
438
- valuesModifiers,
439
- model,
440
- entry: initialEntry,
441
- storageEntry: initialStorageEntry,
442
- fieldIndexRegistry,
443
- compressionHandler
444
- });
445
- const { entry, storageEntry } = transformer.transformEntryKeys();
446
- const partitionKey = createPartitionKey({
447
- id: entry.id,
448
- tenant: model.tenant
449
- });
450
- const queryAllParams = {
451
- partitionKey,
452
- options: {
453
- gte: " "
454
- }
455
- };
456
- const latestSortKey = createLatestSortKey();
457
- const publishedSortKey = createPublishedSortKey();
458
- const records = await entity.queryAll(queryAllParams);
459
- const updatedEntryMetaFields = pickEntryMetaFields(entry, isDeletedEntryMetaField);
460
- let latestRecord;
461
- let publishedRecord;
462
- const entityBatch = entity.createEntityWriter();
463
- for (const record of records){
464
- entityBatch.put({
465
- ...record,
466
- data: {
467
- ...record.data,
468
- ...updatedEntryMetaFields,
469
- wbyDeleted: storageEntry.wbyDeleted,
470
- location: storageEntry.location,
471
- binOriginalFolderId: storageEntry.binOriginalFolderId
472
- }
473
- });
474
- if (record.SK === publishedSortKey) publishedRecord = record.data;
475
- else if (record.SK === latestSortKey) latestRecord = record.data;
476
- }
477
- try {
478
- await entityBatch.execute();
479
- dataLoaders.clearAll({
480
- tenant: entry.tenant
481
- });
482
- } catch (ex) {
483
- throw new WebinyError(ex.message || "Could mark as deleted all entry records from in the DynamoDB table.", ex.code || "MOVE_ENTRY_TO_BIN_ERROR", {
484
- error: ex,
485
- entry,
486
- storageEntry
487
- });
488
- }
489
- const esEntityReader = esEntity.createEntityReader();
490
- if (publishedRecord) esEntityReader.get({
491
- PK: partitionKey,
492
- SK: publishedSortKey
493
- });
494
- if (latestRecord) esEntityReader.get({
495
- PK: partitionKey,
496
- SK: latestSortKey
497
- });
498
- if (0 === esEntityReader.total) return;
499
- const esRecords = await esEntityReader.execute();
500
- const esItems = (await Promise.all(esRecords.map(async (record)=>{
501
- if (!record) return null;
502
- return {
503
- ...record,
504
- data: await compressionHandler.decompress(record.data)
505
- };
506
- }))).filter((item)=>!!item);
507
- if (0 === esItems.length) return;
508
- const elasticsearchEntityBatch = esEntity.createEntityWriter();
509
- for (const item of esItems)elasticsearchEntityBatch.put({
510
- ...item,
511
- data: await compressionHandler.compress({
512
- ...item.data,
513
- ...updatedEntryMetaFields,
514
- wbyDeleted: entry.wbyDeleted,
515
- location: entry.location,
516
- binOriginalFolderId: entry.binOriginalFolderId
517
- })
518
- });
519
- try {
520
- await elasticsearchEntityBatch.execute();
521
- } catch (ex) {
522
- throw new WebinyError(ex.message || "Could not mark as deleted entry records from DynamoDB Elasticsearch table.", ex.code || "MOVE_ENTRY_TO_BIN_ERROR", {
523
- error: ex,
524
- entry,
525
- storageEntry
526
- });
527
- }
528
- };
529
- const restoreFromBin = async (initialModel, params)=>{
530
- const { entry: initialEntry, storageEntry: initialStorageEntry } = params;
531
- const model = getStorageOperationsModel(initialModel);
532
- const transformer = createTransformer({
533
- valuesModifiers,
534
- model,
535
- entry: initialEntry,
536
- storageEntry: initialStorageEntry,
537
- fieldIndexRegistry,
538
- compressionHandler
539
- });
540
- const { entry, storageEntry } = transformer.transformEntryKeys();
541
- const updatedEntryMetaFields = pickEntryMetaFields(entry, isRestoredEntryMetaField);
542
- const partitionKey = createPartitionKey({
543
- id: entry.id,
544
- tenant: model.tenant
545
- });
546
- const queryAllParams = {
547
- partitionKey,
548
- options: {
549
- gte: " "
550
- }
551
- };
552
- const latestSortKey = createLatestSortKey();
553
- const publishedSortKey = createPublishedSortKey();
554
- const records = await entity.queryAll(queryAllParams);
555
- let latestRecord;
556
- let publishedRecord;
557
- const entityBatch = entity.createEntityWriter();
558
- for (const record of records){
559
- entityBatch.put({
560
- ...record,
561
- data: {
562
- ...record.data,
563
- ...updatedEntryMetaFields,
564
- wbyDeleted: storageEntry.wbyDeleted,
565
- location: storageEntry.location,
566
- binOriginalFolderId: storageEntry.binOriginalFolderId
567
- }
568
- });
569
- if (record.SK === publishedSortKey) publishedRecord = record.data;
570
- else if (record.SK === latestSortKey) latestRecord = record.data;
571
- }
572
- try {
573
- await entityBatch.execute();
574
- dataLoaders.clearAll({
575
- tenant: entry.tenant
576
- });
577
- } catch (ex) {
578
- throw new WebinyError(ex.message || "Could not restore all entry records from in the DynamoDB table.", ex.code || "RESTORE_ENTRY_ERROR", {
579
- error: ex,
580
- entry,
581
- storageEntry
582
- });
583
- }
584
- const esEntityReader = esEntity.createEntityReader();
585
- if (publishedRecord) esEntityReader.get({
586
- PK: partitionKey,
587
- SK: publishedSortKey
588
- });
589
- if (latestRecord) esEntityReader.get({
590
- PK: partitionKey,
591
- SK: latestSortKey
592
- });
593
- const esRecords = await esEntityReader.execute();
594
- const esItems = (await Promise.all(esRecords.map(async (record)=>{
595
- if (!record) return null;
596
- return {
597
- ...record,
598
- data: await compressionHandler.decompress(record.data)
599
- };
600
- }))).filter((item)=>!!item);
601
- if (0 === esItems.length) return initialStorageEntry;
602
- const elasticsearchEntityBatch = esEntity.createEntityWriter();
603
- for (const item of esItems)elasticsearchEntityBatch.put({
604
- ...item,
605
- data: await compressionHandler.compress({
606
- ...item.data,
607
- ...updatedEntryMetaFields,
608
- wbyDeleted: entry.wbyDeleted,
609
- location: entry.location,
610
- binOriginalFolderId: entry.binOriginalFolderId
611
- })
612
- });
613
- try {
614
- await elasticsearchEntityBatch.execute();
615
- } catch (ex) {
616
- throw new WebinyError(ex.message || "Could not restore entry records from DynamoDB Elasticsearch table.", ex.code || "RESTORE_ENTRY_ERROR", {
617
- error: ex,
618
- entry,
619
- storageEntry
620
- });
621
- }
622
- return initialStorageEntry;
623
- };
624
- const deleteEntry = async (initialModel, params)=>{
625
- const { entry } = params;
626
- const id = entry.id || entry.entryId;
627
- const model = getStorageOperationsModel(initialModel);
628
- const partitionKey = createPartitionKey({
629
- id,
630
- tenant: model.tenant
631
- });
632
- const items = await entity.queryAll({
633
- partitionKey,
634
- options: {
635
- gte: " "
636
- }
637
- });
638
- const esItems = await esEntity.queryAll({
639
- partitionKey,
640
- options: {
641
- gte: " "
642
- }
643
- });
644
- const entityBatch = entity.createEntityWriter({
645
- delete: items.map((item)=>({
646
- PK: item.PK,
647
- SK: item.SK
648
- }))
649
- });
650
- const elasticsearchEntityBatch = esEntity.createEntityWriter({
651
- delete: esItems.map((item)=>({
652
- PK: item.PK,
653
- SK: item.SK
654
- }))
655
- });
656
- try {
657
- await entityBatch.execute();
658
- dataLoaders.clearAll({
659
- tenant: entry.tenant
660
- });
661
- } catch (ex) {
662
- throw new WebinyError(ex.message || "Could not destroy entry records from DynamoDB table.", ex.code || "DELETE_ENTRY_ERROR", {
663
- error: ex,
664
- id
665
- });
666
- }
667
- try {
668
- await elasticsearchEntityBatch.execute();
669
- } catch (ex) {
670
- throw new WebinyError(ex.message || "Could not destroy entry records from DynamoDB Elasticsearch table.", ex.code || "DELETE_ENTRY_ERROR", {
671
- error: ex,
672
- id
673
- });
674
- }
675
- };
676
- const deleteRevision = async (initialModel, params)=>{
677
- const { entry, latestEntry, latestStorageEntry: initialLatestStorageEntry } = params;
678
- const model = getStorageOperationsModel(initialModel);
679
- const partitionKey = createPartitionKey({
680
- id: entry.id,
681
- tenant: model.tenant
682
- });
683
- const { index } = await configurations.es({
684
- model
685
- });
686
- const [publishedStorageEntry] = await dataLoaders.getPublishedRevisionByEntryId({
687
- model,
688
- ids: [
689
- entry.id
690
- ]
691
- });
692
- const entityBatch = entity.createEntityWriter({
693
- delete: [
694
- {
695
- PK: partitionKey,
696
- SK: createRevisionSortKey(entry)
697
- }
698
- ]
699
- });
700
- const elasticsearchEntityBatch = esEntity.createEntityWriter();
701
- if (publishedStorageEntry?.id === entry.id) {
702
- entityBatch.delete({
703
- PK: partitionKey,
704
- SK: createPublishedSortKey()
705
- });
706
- elasticsearchEntityBatch.delete({
707
- PK: partitionKey,
708
- SK: createPublishedSortKey()
709
- });
710
- }
711
- if (latestEntry && initialLatestStorageEntry) {
712
- const latestStorageEntry = convertToStorageEntry({
713
- storageEntry: initialLatestStorageEntry,
714
- model
715
- });
716
- const latestStorageEntryLatestKey = createEntryLatestKeys(latestStorageEntry);
717
- entityBatch.put({
718
- ...latestStorageEntryLatestKey,
719
- data: latestStorageEntry
720
- });
721
- const actualRevisionEntryKey = createEntryRevisionKeys(initialLatestStorageEntry);
722
- entityBatch.put({
723
- ...actualRevisionEntryKey,
724
- data: latestStorageEntry
725
- });
726
- const latestTransformer = createTransformer({
727
- valuesModifiers,
728
- model,
729
- entry: latestEntry,
730
- storageEntry: initialLatestStorageEntry,
731
- fieldIndexRegistry,
732
- compressionHandler
733
- });
734
- const esLatestData = await latestTransformer.getElasticsearchLatestEntryData();
735
- const esLatestKeys = createEntryLatestKeys(latestEntry);
736
- elasticsearchEntityBatch.put({
737
- ...esLatestKeys,
738
- index,
739
- data: esLatestData
740
- });
741
- }
742
- try {
743
- await entityBatch.execute();
744
- dataLoaders.clearAll({
745
- tenant: entry.tenant
746
- });
747
- } catch (ex) {
748
- throw new WebinyError(ex.message || "Could not batch write entry records to DynamoDB table.", ex.code || "DELETE_REVISION_ERROR", {
749
- error: ex,
750
- entry,
751
- latestEntry,
752
- initialLatestStorageEntry
753
- });
754
- }
755
- try {
756
- await elasticsearchEntityBatch.execute();
757
- } catch (ex) {
758
- throw new WebinyError(ex.message || "Could not batch write entry records to DynamoDB Elasticsearch table.", ex.code || "DELETE_REVISION_ERROR", {
759
- error: ex,
760
- entry,
761
- latestEntry,
762
- initialLatestStorageEntry
763
- });
764
- }
765
- };
766
- const deleteMultipleEntries = async (initialModel, params)=>{
767
- const { entries } = params;
768
- const model = getStorageOperationsModel(initialModel);
769
- const revisions = await dataLoaders.getAllEntryRevisions({
770
- model,
771
- ids: entries
772
- });
773
- const entityBatch = entity.createEntityWriter();
774
- const elasticsearchEntityBatch = esEntity.createEntityWriter();
775
- for (const id of entries){
776
- entityBatch.delete({
777
- PK: createPartitionKey({
778
- id,
779
- tenant: model.tenant
780
- }),
781
- SK: "L"
782
- });
783
- elasticsearchEntityBatch.delete({
784
- PK: createPartitionKey({
785
- id,
786
- tenant: model.tenant
787
- }),
788
- SK: "L"
789
- });
790
- entityBatch.delete({
791
- PK: createPartitionKey({
792
- id,
793
- tenant: model.tenant
794
- }),
795
- SK: "P"
796
- });
797
- elasticsearchEntityBatch.delete({
798
- PK: createPartitionKey({
799
- id,
800
- tenant: model.tenant
801
- }),
802
- SK: "P"
803
- });
804
- }
805
- for (const revision of revisions)entityBatch.delete({
806
- PK: createPartitionKey({
807
- id: revision.id,
808
- tenant: model.tenant
809
- }),
810
- SK: createRevisionSortKey({
811
- version: revision.version
812
- })
813
- });
814
- await entityBatch.execute();
815
- await elasticsearchEntityBatch.execute();
816
- };
817
- const list = async (initialModel, params)=>{
818
- const model = getStorageOperationsModel(initialModel);
819
- const limit = createLimit(params.limit, 50);
820
- const { index, shared } = await configurations.es({
821
- model
822
- });
823
- const body = createElasticsearchBody({
824
- model,
825
- shared,
826
- fieldRegistry,
827
- fieldIndexRegistry,
828
- bodyModifiers,
829
- sortModifiers,
830
- queryModifiers,
831
- valueSearchRegistry,
832
- fullTextSearches,
833
- filterRegistry,
834
- params: {
835
- ...params,
836
- limit,
837
- after: decodeCursor(params.after)
838
- },
839
- plugins
840
- });
841
- let response;
842
- try {
843
- response = await elasticsearch.search({
844
- index,
845
- body
846
- });
847
- } catch (error) {
848
- if (shouldIgnoreEsResponseError(error)) return {
849
- hasMoreItems: false,
850
- totalCount: 0,
851
- cursor: null,
852
- items: []
853
- };
854
- throw new WebinyError(error.message, error.code || "OPENSEARCH_ERROR", {
855
- error,
856
- index,
857
- body,
858
- model
859
- });
860
- }
861
- const { hits, total } = response.body.hits;
862
- const items = extractEntriesFromIndex({
863
- fieldRegistry,
864
- fieldIndexRegistry,
865
- model,
866
- entries: hits.map((item)=>item._source)
867
- }).map((item)=>convertEntryKeysFromStorage({
868
- model,
869
- entry: item
870
- }));
871
- const hasMoreItems = items.length > limit;
872
- if (hasMoreItems) items.pop();
873
- const cursor = items.length > 0 ? encodeCursor(hits[items.length - 1].sort) || null : null;
874
- return {
875
- hasMoreItems,
876
- totalCount: getTotalCount(total),
877
- cursor,
878
- items
879
- };
880
- };
881
- const get = async (initialModel, params)=>{
882
- const model = getStorageOperationsModel(initialModel);
883
- const { items } = await list(model, {
884
- ...params,
885
- limit: 1
886
- });
887
- return items.shift() || null;
888
- };
889
- const publish = async (initialModel, params)=>{
890
- const { entry: initialEntry, storageEntry: initialStorageEntry } = params;
891
- const model = getStorageOperationsModel(initialModel);
892
- const transformer = createTransformer({
893
- valuesModifiers,
894
- model,
895
- entry: initialEntry,
896
- storageEntry: initialStorageEntry,
897
- fieldIndexRegistry,
898
- compressionHandler
899
- });
900
- const { entry, storageEntry } = transformer.transformEntryKeys();
901
- const revisionKeys = createEntryRevisionKeys(entry);
902
- const latestKeys = createEntryLatestKeys(entry);
903
- const publishedKeys = createEntryPublishedKeys(entry);
904
- let latestEsEntry = null;
905
- try {
906
- latestEsEntry = await esEntity.getClean(latestKeys);
907
- } catch (ex) {
908
- throw new WebinyError(ex.message || "Could not read Elasticsearch latest data.", ex.code || "PUBLISH_LATEST_READ", {
909
- error: ex,
910
- latestKeys: latestKeys,
911
- publishedKeys: publishedKeys
912
- });
913
- }
914
- if (!latestEsEntry) throw new WebinyError('Could not publish entry. Could not load latest ("L") record (ES table).', "PUBLISH_ERROR", {
915
- entry
916
- });
917
- const [latestStorageEntry] = await dataLoaders.getLatestRevisionByEntryId({
918
- model,
919
- ids: [
920
- entry.id
921
- ]
922
- });
923
- if (!latestStorageEntry) throw new WebinyError('Could not publish entry. Could not load latest ("L") record.', "PUBLISH_ERROR", {
924
- entry
925
- });
926
- const [publishedStorageEntry] = await dataLoaders.getPublishedRevisionByEntryId({
927
- model,
928
- ids: [
929
- entry.id
930
- ]
931
- });
932
- const entityBatch = entity.createEntityWriter({
933
- put: [
934
- {
935
- ...revisionKeys,
936
- data: storageEntry
937
- },
938
- {
939
- ...publishedKeys,
940
- data: storageEntry
941
- }
942
- ]
943
- });
944
- const elasticsearchEntityWriter = esEntity.createEntityWriter();
945
- const { index: esIndex } = await configurations.es({
946
- model
947
- });
948
- const publishedRevisionId = publishedStorageEntry?.id;
949
- const publishingLatestRevision = latestStorageEntry?.id === entry.id;
950
- if (publishingLatestRevision) {
951
- entityBatch.put({
952
- ...latestKeys,
953
- data: storageEntry
954
- });
955
- if (publishedStorageEntry) {
956
- const isRepublishing = publishedStorageEntry.id === entry.id;
957
- if (!isRepublishing) {
958
- const publishedStorageEntryKeys = createEntryRevisionKeys(publishedStorageEntry);
959
- entityBatch.put({
960
- ...publishedStorageEntryKeys,
961
- data: {
962
- ...publishedStorageEntry,
963
- status: CONTENT_ENTRY_STATUS.UNPUBLISHED
964
- }
965
- });
966
- }
967
- }
968
- } else {
969
- const updatedEntryLevelMetaFields = pickEntryMetaFields(entry, isEntryLevelEntryMetaField);
970
- let latestRevisionStatus = latestStorageEntry.status;
971
- if (latestRevisionStatus === CONTENT_ENTRY_STATUS.PUBLISHED) latestRevisionStatus = CONTENT_ENTRY_STATUS.UNPUBLISHED;
972
- const latestStorageEntryFields = {
973
- ...latestStorageEntry,
974
- ...updatedEntryLevelMetaFields,
975
- status: latestRevisionStatus
976
- };
977
- const latestStorageEntryLatestKeys = createEntryLatestKeys(latestStorageEntry);
978
- entityBatch.put({
979
- ...latestStorageEntryLatestKeys,
980
- data: latestStorageEntryFields
981
- });
982
- const latestStorageEntryRevisionKeys = createEntryRevisionKeys(latestStorageEntry);
983
- entityBatch.put({
984
- ...latestStorageEntryRevisionKeys,
985
- data: latestStorageEntryFields
986
- });
987
- if (publishedStorageEntry) {
988
- const isRepublishing = publishedStorageEntry.id === entry.id;
989
- const publishedRevisionDifferentFromLatest = publishedRevisionId !== latestStorageEntry.id;
990
- if (!isRepublishing && publishedRevisionDifferentFromLatest) {
991
- const publishedStorageEntryRevisionKeys = createEntryRevisionKeys(publishedStorageEntry);
992
- entityBatch.put({
993
- ...publishedStorageEntryRevisionKeys,
994
- data: {
995
- ...publishedStorageEntry,
996
- status: CONTENT_ENTRY_STATUS.UNPUBLISHED
997
- }
998
- });
999
- }
1000
- }
1001
- }
1002
- const esPublishedData = await transformer.getElasticsearchPublishedEntryData();
1003
- elasticsearchEntityWriter.put({
1004
- ...publishedKeys,
1005
- index: esIndex,
1006
- data: esPublishedData
1007
- });
1008
- const latestEsEntryDataDecompressed = await compressionHandler.decompress(latestEsEntry.data);
1009
- if (publishingLatestRevision) {
1010
- const updatedMetaFields = pickEntryMetaFields(entry);
1011
- const latestTransformer = createTransformer({
1012
- valuesModifiers,
1013
- model,
1014
- transformedToIndex: {
1015
- ...latestEsEntryDataDecompressed,
1016
- status: CONTENT_ENTRY_STATUS.PUBLISHED,
1017
- locked: true,
1018
- ...updatedMetaFields
1019
- },
1020
- fieldIndexRegistry,
1021
- compressionHandler
1022
- });
1023
- const esEntryLatestKeys = createEntryLatestKeys(latestEsEntryDataDecompressed);
1024
- elasticsearchEntityWriter.put({
1025
- index: esIndex,
1026
- data: await latestTransformer.getElasticsearchLatestEntryData(),
1027
- ...esEntryLatestKeys
1028
- });
1029
- } else {
1030
- const updatedEntryLevelMetaFields = pickEntryMetaFields(entry, isEntryLevelEntryMetaField);
1031
- const latestEsEntry = await esEntity.getClean(latestKeys);
1032
- if (latestEsEntry) {
1033
- const latestEsEntryDataDecompressed = await compressionHandler.decompress(latestEsEntry.data);
1034
- let latestRevisionStatus = latestEsEntryDataDecompressed.status;
1035
- if (latestRevisionStatus === CONTENT_ENTRY_STATUS.PUBLISHED) latestRevisionStatus = CONTENT_ENTRY_STATUS.UNPUBLISHED;
1036
- const updatedLatestEntry = await compressionHandler.compress({
1037
- ...latestEsEntryDataDecompressed,
1038
- ...updatedEntryLevelMetaFields,
1039
- status: latestRevisionStatus
1040
- });
1041
- elasticsearchEntityWriter.put({
1042
- ...latestKeys,
1043
- index: esIndex,
1044
- data: updatedLatestEntry
1045
- });
1046
- }
1047
- }
1048
- try {
1049
- await entityBatch.execute();
1050
- dataLoaders.clearAll({
1051
- tenant: entry.tenant
1052
- });
1053
- } catch (ex) {
1054
- throw new WebinyError(ex.message || "Could not store publish entry records in DynamoDB table.", ex.code || "PUBLISH_ERROR", {
1055
- error: ex,
1056
- entry,
1057
- latestStorageEntry,
1058
- publishedStorageEntry
1059
- });
1060
- }
1061
- try {
1062
- await elasticsearchEntityWriter.execute();
1063
- } catch (ex) {
1064
- throw new WebinyError(ex.message || "Could not store publish entry records in DynamoDB Elasticsearch table.", ex.code || "PUBLISH_ES_ERROR", {
1065
- error: ex,
1066
- entry,
1067
- latestStorageEntry,
1068
- publishedStorageEntry
1069
- });
1070
- }
1071
- return initialStorageEntry;
1072
- };
1073
- const unpublish = async (initialModel, params)=>{
1074
- const { entry: initialEntry, storageEntry: initialStorageEntry } = params;
1075
- const model = getStorageOperationsModel(initialModel);
1076
- const transformer = createTransformer({
1077
- valuesModifiers,
1078
- model,
1079
- entry: initialEntry,
1080
- storageEntry: initialStorageEntry,
1081
- fieldIndexRegistry,
1082
- compressionHandler
1083
- });
1084
- const { entry, storageEntry } = await transformer.transformEntryKeys();
1085
- const [latestStorageEntry] = await dataLoaders.getLatestRevisionByEntryId({
1086
- model,
1087
- ids: [
1088
- entry.id
1089
- ]
1090
- });
1091
- const partitionKey = createPartitionKey({
1092
- id: entry.id,
1093
- tenant: model.tenant
1094
- });
1095
- const entryRevisionKeys = createEntryRevisionKeys(entry);
1096
- const entityBatch = entity.createEntityWriter({
1097
- put: [
1098
- {
1099
- ...entryRevisionKeys,
1100
- data: storageEntry
1101
- }
1102
- ],
1103
- delete: [
1104
- {
1105
- PK: partitionKey,
1106
- SK: createPublishedSortKey()
1107
- }
1108
- ]
1109
- });
1110
- const elasticsearchEntityBatch = esEntity.createEntityWriter({
1111
- delete: [
1112
- {
1113
- PK: partitionKey,
1114
- SK: createPublishedSortKey()
1115
- }
1116
- ]
1117
- });
1118
- if (latestStorageEntry?.id === entry.id) {
1119
- const { index } = await configurations.es({
1120
- model
1121
- });
1122
- const entryLatestKeys = createEntryLatestKeys(storageEntry);
1123
- entityBatch.put({
1124
- ...entryLatestKeys,
1125
- data: storageEntry
1126
- });
1127
- const esLatestData = await transformer.getElasticsearchLatestEntryData();
1128
- elasticsearchEntityBatch.put({
1129
- index,
1130
- data: esLatestData,
1131
- ...entryLatestKeys
1132
- });
1133
- }
1134
- try {
1135
- await entityBatch.execute();
1136
- dataLoaders.clearAll({
1137
- tenant: entry.tenant
1138
- });
1139
- } catch (ex) {
1140
- throw new WebinyError(ex.message || "Could not store unpublished entry records in DynamoDB table.", ex.code || "UNPUBLISH_ERROR", {
1141
- entry,
1142
- storageEntry
1143
- });
1144
- }
1145
- try {
1146
- await elasticsearchEntityBatch.execute();
1147
- } catch (ex) {
1148
- throw new WebinyError(ex.message || "Could not store unpublished entry records in DynamoDB Elasticsearch table.", ex.code || "UNPUBLISH_ERROR", {
1149
- entry,
1150
- storageEntry
1151
- });
1152
- }
1153
- return initialStorageEntry;
1154
- };
1155
- const getLatestRevisionByEntryId = async (initialModel, params)=>{
1156
- const model = getStorageOperationsModel(initialModel);
1157
- const [entry] = await dataLoaders.getLatestRevisionByEntryId({
1158
- model,
1159
- ids: [
1160
- params.id
1161
- ]
1162
- });
1163
- if (!entry) return null;
1164
- return convertEntryKeysFromStorage({
1165
- model,
1166
- entry
1167
- });
1168
- };
1169
- const getPublishedRevisionByEntryId = async (initialModel, params)=>{
1170
- const model = getStorageOperationsModel(initialModel);
1171
- const [entry] = await dataLoaders.getPublishedRevisionByEntryId({
1172
- model,
1173
- ids: [
1174
- params.id
1175
- ]
1176
- });
1177
- if (!entry) return null;
1178
- return convertEntryKeysFromStorage({
1179
- model,
1180
- entry
1181
- });
1182
- };
1183
- const getRevisionById = async (initialModel, params)=>{
1184
- const model = getStorageOperationsModel(initialModel);
1185
- const [entry] = await dataLoaders.getRevisionById({
1186
- model,
1187
- ids: [
1188
- params.id
1189
- ]
1190
- });
1191
- if (!entry) return null;
1192
- return convertEntryKeysFromStorage({
1193
- model,
1194
- entry
1195
- });
1196
- };
1197
- const getRevisions = async (initialModel, params)=>{
1198
- const model = getStorageOperationsModel(initialModel);
1199
- const entries = await dataLoaders.getAllEntryRevisions({
1200
- model,
1201
- ids: [
1202
- params.id
1203
- ]
1204
- });
1205
- return entries.map((entry)=>convertEntryKeysFromStorage({
1206
- model,
1207
- entry
1208
- }));
1209
- };
1210
- const getByIds = async (initialModel, params)=>{
1211
- const model = getStorageOperationsModel(initialModel);
1212
- const entries = await dataLoaders.getRevisionById({
1213
- model,
1214
- ids: params.ids
1215
- });
1216
- return entries.map((entry)=>convertEntryKeysFromStorage({
1217
- model,
1218
- entry
1219
- }));
1220
- };
1221
- const getLatestByIds = async (initialModel, params)=>{
1222
- const model = getStorageOperationsModel(initialModel);
1223
- const entries = await dataLoaders.getLatestRevisionByEntryId({
1224
- model,
1225
- ids: params.ids
1226
- });
1227
- return entries.map((entry)=>convertEntryKeysFromStorage({
1228
- model,
1229
- entry
1230
- }));
1231
- };
1232
- const getPublishedByIds = async (initialModel, params)=>{
1233
- const model = getStorageOperationsModel(initialModel);
1234
- const entries = await dataLoaders.getPublishedRevisionByEntryId({
1235
- model,
1236
- ids: params.ids
1237
- });
1238
- return entries.map((entry)=>convertEntryKeysFromStorage({
1239
- model,
1240
- entry
1241
- }));
1242
- };
1243
- const getPreviousRevision = async (initialModel, params)=>{
1244
- const model = getStorageOperationsModel(initialModel);
1245
- const { tenant } = model;
1246
- const { entryId, version } = params;
1247
- const partitionKey = createPartitionKey({
1248
- tenant,
1249
- id: entryId
1250
- });
1251
- const options = {
1252
- beginsWith: "REV#",
1253
- reverse: true
1254
- };
1255
- try {
1256
- const unfilteredEntries = (await entity.queryAll({
1257
- partitionKey,
1258
- options
1259
- })).map((item)=>item.data);
1260
- const entries = unfilteredEntries.filter((item)=>item.version < version);
1261
- const entry = entries[0];
1262
- if (!entry) return null;
1263
- return convertEntryKeysFromStorage({
1264
- entry,
1265
- model
1266
- });
1267
- } catch (ex) {
1268
- throw new WebinyError(ex.message || "Could not get previous version of given entry.", ex.code || "GET_PREVIOUS_VERSION_ERROR", {
1269
- ...params,
1270
- error: ex,
1271
- partitionKey,
1272
- options,
1273
- model
1274
- });
1275
- }
1276
- };
1277
- const getUniqueFieldValues = async (model, params)=>{
1278
- const { where, fieldId } = params;
1279
- const { index, shared } = await configurations.es({
1280
- model
1281
- });
1282
- const initialBody = createElasticsearchBody({
1283
- model,
1284
- shared,
1285
- fieldRegistry,
1286
- fieldIndexRegistry,
1287
- bodyModifiers,
1288
- sortModifiers,
1289
- queryModifiers,
1290
- valueSearchRegistry,
1291
- fullTextSearches,
1292
- filterRegistry,
1293
- params: {
1294
- limit: 1,
1295
- where
1296
- },
1297
- plugins
1298
- });
1299
- const field = model.fields.find((f)=>f.fieldId === fieldId);
1300
- if (!field) throw new WebinyError('Could not find field with given "fieldId" value.', "FIELD_NOT_FOUND", {
1301
- fieldId
1302
- });
1303
- const body = {
1304
- ...initialBody,
1305
- size: 0,
1306
- aggregations: {
1307
- getUniqueFieldValues: {
1308
- terms: {
1309
- field: `values.${field.storageId}.keyword`,
1310
- size: 1000000
1311
- }
1312
- }
1313
- }
1314
- };
1315
- let response;
1316
- try {
1317
- response = await elasticsearch.search({
1318
- index,
1319
- body
1320
- });
1321
- } catch (error) {
1322
- if (shouldIgnoreEsResponseError(error)) return [];
1323
- throw new WebinyError(error.message || "Error in the Elasticsearch query.", error.code || "OPENSEARCH_ERROR", {
1324
- error,
1325
- index,
1326
- model,
1327
- body
1328
- });
1329
- }
1330
- const aggregations = response.body.aggregations || {};
1331
- const agg = aggregations["getUniqueFieldValues"];
1332
- const buckets = agg && "buckets" in agg && Array.isArray(agg.buckets) ? agg.buckets : [];
1333
- return buckets.map((bucket)=>({
1334
- value: bucket.key,
1335
- count: bucket.doc_count
1336
- }));
1337
- };
1338
- return {
1339
- create,
1340
- createRevisionFrom,
1341
- update,
1342
- move,
1343
- delete: deleteEntry,
1344
- moveToBin,
1345
- restoreFromBin,
1346
- deleteRevision,
1347
- deleteMultipleEntries,
1348
- get,
1349
- publish,
1350
- unpublish,
1351
- list,
1352
- getLatestRevisionByEntryId,
1353
- getPublishedRevisionByEntryId,
1354
- getRevisionById,
1355
- getRevisions,
1356
- getByIds,
1357
- getLatestByIds,
1358
- getPublishedByIds,
1359
- getPreviousRevision,
1360
- getUniqueFieldValues,
1361
- dataLoaders
1362
- };
1363
- };
1364
- export { createEntriesStorageOperations };
1365
-
1366
- //# sourceMappingURL=index.js.map