@webiny/api-headless-cms-ddb-es 0.0.0-unstable.496cf268ac → 0.0.0-unstable.5387e5f7c8

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 (410) hide show
  1. package/README.md +6 -30
  2. package/abstractions/CmsDdbEsDataLoaders.d.ts +5 -0
  3. package/abstractions/CmsDdbEsDataLoaders.js +5 -0
  4. package/abstractions/CmsDdbEsDataLoaders.js.map +1 -0
  5. package/abstractions/CmsDdbEsEntriesEsEntity.d.ts +5 -0
  6. package/abstractions/CmsDdbEsEntriesEsEntity.js +5 -0
  7. package/abstractions/CmsDdbEsEntriesEsEntity.js.map +1 -0
  8. package/abstractions/CmsDdbEsEntryEntity.d.ts +5 -0
  9. package/abstractions/CmsDdbEsEntryEntity.js +5 -0
  10. package/abstractions/CmsDdbEsEntryEntity.js.map +1 -0
  11. package/abstractions/CmsDdbEsGroupEntity.d.ts +5 -0
  12. package/abstractions/CmsDdbEsGroupEntity.js +5 -0
  13. package/abstractions/CmsDdbEsGroupEntity.js.map +1 -0
  14. package/abstractions/CmsDdbEsModelEntity.d.ts +5 -0
  15. package/abstractions/CmsDdbEsModelEntity.js +5 -0
  16. package/abstractions/CmsDdbEsModelEntity.js.map +1 -0
  17. package/abstractions/CmsDdbEsOsTable.d.ts +5 -0
  18. package/abstractions/CmsDdbEsOsTable.js +5 -0
  19. package/abstractions/CmsDdbEsOsTable.js.map +1 -0
  20. package/abstractions/CmsDdbEsTable.d.ts +5 -0
  21. package/abstractions/CmsDdbEsTable.js +5 -0
  22. package/abstractions/CmsDdbEsTable.js.map +1 -0
  23. package/definitions/entry.d.ts +4 -5
  24. package/definitions/entry.js +10 -87
  25. package/definitions/entry.js.map +1 -1
  26. package/definitions/group.d.ts +6 -6
  27. package/definitions/group.js +10 -64
  28. package/definitions/group.js.map +1 -1
  29. package/definitions/model.d.ts +6 -6
  30. package/definitions/model.js +10 -108
  31. package/definitions/model.js.map +1 -1
  32. package/definitions/types.d.ts +65 -0
  33. package/definitions/types.js +0 -0
  34. package/feature.d.ts +10 -0
  35. package/feature.js +69 -0
  36. package/feature.js.map +1 -0
  37. package/index.d.ts +1 -3
  38. package/index.js +1 -214
  39. package/operations/entry/DdbEsCreateEntry.d.ts +24 -0
  40. package/operations/entry/DdbEsCreateEntry.js +134 -0
  41. package/operations/entry/DdbEsCreateEntry.js.map +1 -0
  42. package/operations/entry/DdbEsCreateEntryRevisionFrom.d.ts +24 -0
  43. package/operations/entry/DdbEsCreateEntryRevisionFrom.js +139 -0
  44. package/operations/entry/DdbEsCreateEntryRevisionFrom.js.map +1 -0
  45. package/operations/entry/DdbEsDeleteEntry.d.ts +18 -0
  46. package/operations/entry/DdbEsDeleteEntry.js +79 -0
  47. package/operations/entry/DdbEsDeleteEntry.js.map +1 -0
  48. package/operations/entry/DdbEsDeleteEntryRevision.d.ts +24 -0
  49. package/operations/entry/DdbEsDeleteEntryRevision.js +136 -0
  50. package/operations/entry/DdbEsDeleteEntryRevision.js.map +1 -0
  51. package/operations/entry/DdbEsDeleteMultipleEntries.d.ts +18 -0
  52. package/operations/entry/DdbEsDeleteMultipleEntries.js +80 -0
  53. package/operations/entry/DdbEsDeleteMultipleEntries.js.map +1 -0
  54. package/operations/entry/DdbEsGetEntriesByIds.d.ts +14 -0
  55. package/operations/entry/DdbEsGetEntriesByIds.js +31 -0
  56. package/operations/entry/DdbEsGetEntriesByIds.js.map +1 -0
  57. package/operations/entry/DdbEsGetEntry.d.ts +14 -0
  58. package/operations/entry/DdbEsGetEntry.js +27 -0
  59. package/operations/entry/DdbEsGetEntry.js.map +1 -0
  60. package/operations/entry/DdbEsGetLatestEntriesByIds.d.ts +14 -0
  61. package/operations/entry/DdbEsGetLatestEntriesByIds.js +31 -0
  62. package/operations/entry/DdbEsGetLatestEntriesByIds.js.map +1 -0
  63. package/operations/entry/DdbEsGetLatestRevisionByEntryId.d.ts +14 -0
  64. package/operations/entry/DdbEsGetLatestRevisionByEntryId.js +34 -0
  65. package/operations/entry/DdbEsGetLatestRevisionByEntryId.js.map +1 -0
  66. package/operations/entry/DdbEsGetPreviousRevision.d.ts +14 -0
  67. package/operations/entry/DdbEsGetPreviousRevision.js +56 -0
  68. package/operations/entry/DdbEsGetPreviousRevision.js.map +1 -0
  69. package/operations/entry/DdbEsGetPublishedEntriesByIds.d.ts +14 -0
  70. package/operations/entry/DdbEsGetPublishedEntriesByIds.js +31 -0
  71. package/operations/entry/DdbEsGetPublishedEntriesByIds.js.map +1 -0
  72. package/operations/entry/DdbEsGetPublishedRevisionByEntryId.d.ts +14 -0
  73. package/operations/entry/DdbEsGetPublishedRevisionByEntryId.js +34 -0
  74. package/operations/entry/DdbEsGetPublishedRevisionByEntryId.js.map +1 -0
  75. package/operations/entry/DdbEsGetRevisionById.d.ts +14 -0
  76. package/operations/entry/DdbEsGetRevisionById.js +34 -0
  77. package/operations/entry/DdbEsGetRevisionById.js.map +1 -0
  78. package/operations/entry/DdbEsGetRevisions.d.ts +14 -0
  79. package/operations/entry/DdbEsGetRevisions.js +33 -0
  80. package/operations/entry/DdbEsGetRevisions.js.map +1 -0
  81. package/operations/entry/DdbEsGetUniqueFieldValues.d.ts +18 -0
  82. package/operations/entry/DdbEsGetUniqueFieldValues.js +76 -0
  83. package/operations/entry/DdbEsGetUniqueFieldValues.js.map +1 -0
  84. package/operations/entry/DdbEsListEntries.d.ts +25 -0
  85. package/operations/entry/DdbEsListEntries.js +91 -0
  86. package/operations/entry/DdbEsListEntries.js.map +1 -0
  87. package/operations/entry/DdbEsMoveEntry.d.ts +20 -0
  88. package/operations/entry/DdbEsMoveEntry.js +113 -0
  89. package/operations/entry/DdbEsMoveEntry.js.map +1 -0
  90. package/operations/entry/DdbEsMoveToBin.d.ts +23 -0
  91. package/operations/entry/DdbEsMoveToBin.js +137 -0
  92. package/operations/entry/DdbEsMoveToBin.js.map +1 -0
  93. package/operations/entry/DdbEsPublishEntry.d.ts +24 -0
  94. package/operations/entry/DdbEsPublishEntry.js +231 -0
  95. package/operations/entry/DdbEsPublishEntry.js.map +1 -0
  96. package/operations/entry/DdbEsRestoreFromBin.d.ts +23 -0
  97. package/operations/entry/DdbEsRestoreFromBin.js +137 -0
  98. package/operations/entry/DdbEsRestoreFromBin.js.map +1 -0
  99. package/operations/entry/DdbEsUnpublishEntry.d.ts +24 -0
  100. package/operations/entry/DdbEsUnpublishEntry.js +127 -0
  101. package/operations/entry/DdbEsUnpublishEntry.js.map +1 -0
  102. package/operations/entry/DdbEsUpdateEntry.d.ts +24 -0
  103. package/operations/entry/DdbEsUpdateEntry.js +175 -0
  104. package/operations/entry/DdbEsUpdateEntry.js.map +1 -0
  105. package/operations/entry/dataLoader/DataLoaderCache.d.ts +16 -0
  106. package/operations/entry/dataLoader/DataLoaderCache.js +27 -0
  107. package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -0
  108. package/operations/entry/dataLoader/constants.d.ts +1 -0
  109. package/operations/entry/dataLoader/constants.js +5 -0
  110. package/operations/entry/dataLoader/constants.js.map +1 -0
  111. package/operations/entry/dataLoader/createBatchScheduleFn.d.ts +8 -0
  112. package/operations/entry/dataLoader/createBatchScheduleFn.js +10 -0
  113. package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -0
  114. package/operations/entry/dataLoader/getAllEntryRevisions.d.ts +4 -0
  115. package/operations/entry/dataLoader/getAllEntryRevisions.js +24 -0
  116. package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -0
  117. package/operations/entry/dataLoader/getLatestRevisionByEntryId.d.ts +4 -0
  118. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +34 -0
  119. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -0
  120. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.d.ts +4 -0
  121. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +34 -0
  122. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -0
  123. package/operations/entry/dataLoader/getRevisionById.d.ts +4 -0
  124. package/operations/entry/dataLoader/getRevisionById.js +40 -0
  125. package/operations/entry/dataLoader/getRevisionById.js.map +1 -0
  126. package/operations/entry/dataLoader/index.d.ts +8 -0
  127. package/operations/entry/dataLoader/index.js +18 -0
  128. package/operations/entry/dataLoader/index.js.map +1 -0
  129. package/operations/entry/dataLoader/types.d.ts +6 -0
  130. package/operations/entry/dataLoader/types.js +0 -0
  131. package/operations/entry/dataLoaders.d.ts +18 -39
  132. package/operations/entry/dataLoaders.js +91 -306
  133. package/operations/entry/dataLoaders.js.map +1 -1
  134. package/operations/entry/feature.d.ts +4 -0
  135. package/operations/entry/feature.js +55 -0
  136. package/operations/entry/feature.js.map +1 -0
  137. package/operations/entry/keys.d.ts +31 -1
  138. package/operations/entry/keys.js +46 -27
  139. package/operations/entry/keys.js.map +1 -1
  140. package/operations/entry/recordType.js +5 -17
  141. package/operations/entry/recordType.js.map +1 -1
  142. package/operations/entry/storageEntryUtils.d.ts +7 -0
  143. package/operations/entry/storageEntryUtils.js +14 -0
  144. package/operations/entry/storageEntryUtils.js.map +1 -0
  145. package/operations/entry/transformations/convertEntryKeys.d.ts +8 -0
  146. package/operations/entry/transformations/convertEntryKeys.js +25 -0
  147. package/operations/entry/transformations/convertEntryKeys.js.map +1 -0
  148. package/operations/entry/transformations/index.d.ts +32 -0
  149. package/operations/entry/transformations/index.js +91 -0
  150. package/operations/entry/transformations/index.js.map +1 -0
  151. package/operations/entry/transformations/modifyEntryValues.d.ts +53 -0
  152. package/operations/entry/transformations/modifyEntryValues.js +16 -0
  153. package/operations/entry/transformations/modifyEntryValues.js.map +1 -0
  154. package/operations/entry/transformations/transformEntryKeys.d.ts +11 -0
  155. package/operations/entry/transformations/transformEntryKeys.js +17 -0
  156. package/operations/entry/transformations/transformEntryKeys.js.map +1 -0
  157. package/operations/group/DdbEsCreateGroup.d.ts +12 -0
  158. package/operations/group/DdbEsCreateGroup.js +35 -0
  159. package/operations/group/DdbEsCreateGroup.js.map +1 -0
  160. package/operations/group/DdbEsDeleteGroup.d.ts +12 -0
  161. package/operations/group/DdbEsDeleteGroup.js +31 -0
  162. package/operations/group/DdbEsDeleteGroup.js.map +1 -0
  163. package/operations/group/DdbEsGetGroup.d.ts +12 -0
  164. package/operations/group/DdbEsGetGroup.js +31 -0
  165. package/operations/group/DdbEsGetGroup.js.map +1 -0
  166. package/operations/group/DdbEsListGroups.d.ts +14 -0
  167. package/operations/group/DdbEsListGroups.js +52 -0
  168. package/operations/group/DdbEsListGroups.js.map +1 -0
  169. package/operations/group/DdbEsUpdateGroup.d.ts +12 -0
  170. package/operations/group/DdbEsUpdateGroup.js +35 -0
  171. package/operations/group/DdbEsUpdateGroup.js.map +1 -0
  172. package/operations/group/feature.d.ts +4 -0
  173. package/operations/group/feature.js +19 -0
  174. package/operations/group/feature.js.map +1 -0
  175. package/operations/group/keys.d.ts +15 -0
  176. package/operations/group/keys.js +17 -0
  177. package/operations/group/keys.js.map +1 -0
  178. package/operations/model/DdbEsCreateModel.d.ts +16 -0
  179. package/operations/model/DdbEsCreateModel.js +56 -0
  180. package/operations/model/DdbEsCreateModel.js.map +1 -0
  181. package/operations/model/DdbEsDeleteModel.d.ts +12 -0
  182. package/operations/model/DdbEsDeleteModel.js +31 -0
  183. package/operations/model/DdbEsDeleteModel.js.map +1 -0
  184. package/operations/model/DdbEsGetModel.d.ts +12 -0
  185. package/operations/model/DdbEsGetModel.js +30 -0
  186. package/operations/model/DdbEsGetModel.js.map +1 -0
  187. package/operations/model/DdbEsListModels.d.ts +12 -0
  188. package/operations/model/DdbEsListModels.js +36 -0
  189. package/operations/model/DdbEsListModels.js.map +1 -0
  190. package/operations/model/DdbEsUpdateModel.d.ts +12 -0
  191. package/operations/model/DdbEsUpdateModel.js +36 -0
  192. package/operations/model/DdbEsUpdateModel.js.map +1 -0
  193. package/operations/model/feature.d.ts +4 -0
  194. package/operations/model/feature.js +19 -0
  195. package/operations/model/feature.js.map +1 -0
  196. package/operations/model/keys.d.ts +15 -0
  197. package/operations/model/keys.js +17 -0
  198. package/operations/model/keys.js.map +1 -0
  199. package/package.json +48 -41
  200. package/registry/CmsEntitiesDbRegistryDecorator.d.ts +27 -0
  201. package/registry/CmsEntitiesDbRegistryDecorator.js +46 -0
  202. package/registry/CmsEntitiesDbRegistryDecorator.js.map +1 -0
  203. package/tasks/CreateElasticsearchIndexTask.d.ts +13 -0
  204. package/tasks/CreateElasticsearchIndexTask.js +40 -0
  205. package/tasks/CreateElasticsearchIndexTask.js.map +1 -0
  206. package/types.d.ts +13 -155
  207. package/types.js +9 -41
  208. package/types.js.map +1 -1
  209. package/configurations.d.ts +0 -12
  210. package/configurations.js +0 -35
  211. package/configurations.js.map +0 -1
  212. package/definitions/entryElasticsearch.d.ts +0 -8
  213. package/definitions/entryElasticsearch.js +0 -37
  214. package/definitions/entryElasticsearch.js.map +0 -1
  215. package/definitions/settings.d.ts +0 -8
  216. package/definitions/settings.js +0 -53
  217. package/definitions/settings.js.map +0 -1
  218. package/definitions/system.d.ts +0 -8
  219. package/definitions/system.js +0 -41
  220. package/definitions/system.js.map +0 -1
  221. package/definitions/table.d.ts +0 -8
  222. package/definitions/table.js +0 -21
  223. package/definitions/table.js.map +0 -1
  224. package/definitions/tableElasticsearch.d.ts +0 -8
  225. package/definitions/tableElasticsearch.js +0 -21
  226. package/definitions/tableElasticsearch.js.map +0 -1
  227. package/dynamoDb/index.d.ts +0 -2
  228. package/dynamoDb/index.js +0 -11
  229. package/dynamoDb/index.js.map +0 -1
  230. package/dynamoDb/storage/date.d.ts +0 -3
  231. package/dynamoDb/storage/date.js +0 -86
  232. package/dynamoDb/storage/date.js.map +0 -1
  233. package/dynamoDb/storage/longText.d.ts +0 -10
  234. package/dynamoDb/storage/longText.js +0 -93
  235. package/dynamoDb/storage/longText.js.map +0 -1
  236. package/dynamoDb/storage/richText.d.ts +0 -7
  237. package/dynamoDb/storage/richText.js +0 -110
  238. package/dynamoDb/storage/richText.js.map +0 -1
  239. package/elasticsearch/createElasticsearchIndex.d.ts +0 -9
  240. package/elasticsearch/createElasticsearchIndex.js +0 -49
  241. package/elasticsearch/createElasticsearchIndex.js.map +0 -1
  242. package/elasticsearch/deleteElasticsearchIndex.d.ts +0 -8
  243. package/elasticsearch/deleteElasticsearchIndex.js +0 -36
  244. package/elasticsearch/deleteElasticsearchIndex.js.map +0 -1
  245. package/elasticsearch/index.d.ts +0 -2
  246. package/elasticsearch/index.js +0 -11
  247. package/elasticsearch/index.js.map +0 -1
  248. package/elasticsearch/indexing/dateTimeIndexing.d.ts +0 -3
  249. package/elasticsearch/indexing/dateTimeIndexing.js +0 -86
  250. package/elasticsearch/indexing/dateTimeIndexing.js.map +0 -1
  251. package/elasticsearch/indexing/defaultFieldIndexing.d.ts +0 -3
  252. package/elasticsearch/indexing/defaultFieldIndexing.js +0 -52
  253. package/elasticsearch/indexing/defaultFieldIndexing.js.map +0 -1
  254. package/elasticsearch/indexing/index.d.ts +0 -2
  255. package/elasticsearch/indexing/index.js +0 -15
  256. package/elasticsearch/indexing/index.js.map +0 -1
  257. package/elasticsearch/indexing/longTextIndexing.d.ts +0 -7
  258. package/elasticsearch/indexing/longTextIndexing.js +0 -46
  259. package/elasticsearch/indexing/longTextIndexing.js.map +0 -1
  260. package/elasticsearch/indexing/numberIndexing.d.ts +0 -3
  261. package/elasticsearch/indexing/numberIndexing.js +0 -39
  262. package/elasticsearch/indexing/numberIndexing.js.map +0 -1
  263. package/elasticsearch/indexing/objectIndexing.d.ts +0 -12
  264. package/elasticsearch/indexing/objectIndexing.js +0 -196
  265. package/elasticsearch/indexing/objectIndexing.js.map +0 -1
  266. package/elasticsearch/indexing/richTextIndexing.d.ts +0 -3
  267. package/elasticsearch/indexing/richTextIndexing.js +0 -29
  268. package/elasticsearch/indexing/richTextIndexing.js.map +0 -1
  269. package/elasticsearch/indices/base.d.ts +0 -2
  270. package/elasticsearch/indices/base.js +0 -12
  271. package/elasticsearch/indices/base.js.map +0 -1
  272. package/elasticsearch/indices/index.d.ts +0 -1
  273. package/elasticsearch/indices/index.js +0 -12
  274. package/elasticsearch/indices/index.js.map +0 -1
  275. package/elasticsearch/indices/japanese.d.ts +0 -2
  276. package/elasticsearch/indices/japanese.js +0 -13
  277. package/elasticsearch/indices/japanese.js.map +0 -1
  278. package/elasticsearch/search/index.d.ts +0 -3
  279. package/elasticsearch/search/index.js +0 -10
  280. package/elasticsearch/search/index.js.map +0 -1
  281. package/elasticsearch/search/refSearch.d.ts +0 -2
  282. package/elasticsearch/search/refSearch.js +0 -29
  283. package/elasticsearch/search/refSearch.js.map +0 -1
  284. package/elasticsearch/search/timeSearch.d.ts +0 -2
  285. package/elasticsearch/search/timeSearch.js +0 -26
  286. package/elasticsearch/search/timeSearch.js.map +0 -1
  287. package/helpers/entryIndexHelpers.d.ts +0 -18
  288. package/helpers/entryIndexHelpers.js +0 -175
  289. package/helpers/entryIndexHelpers.js.map +0 -1
  290. package/helpers/index.d.ts +0 -1
  291. package/helpers/index.js +0 -16
  292. package/helpers/index.js.map +0 -1
  293. package/index.js.map +0 -1
  294. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.d.ts +0 -18
  295. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js +0 -32
  296. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js.map +0 -1
  297. package/operations/entry/elasticsearch/body.d.ts +0 -13
  298. package/operations/entry/elasticsearch/body.js +0 -140
  299. package/operations/entry/elasticsearch/body.js.map +0 -1
  300. package/operations/entry/elasticsearch/fields.d.ts +0 -9
  301. package/operations/entry/elasticsearch/fields.js +0 -229
  302. package/operations/entry/elasticsearch/fields.js.map +0 -1
  303. package/operations/entry/elasticsearch/filtering/applyFiltering.d.ts +0 -8
  304. package/operations/entry/elasticsearch/filtering/applyFiltering.js +0 -57
  305. package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +0 -1
  306. package/operations/entry/elasticsearch/filtering/exec.d.ts +0 -17
  307. package/operations/entry/elasticsearch/filtering/exec.js +0 -172
  308. package/operations/entry/elasticsearch/filtering/exec.js.map +0 -1
  309. package/operations/entry/elasticsearch/filtering/index.d.ts +0 -1
  310. package/operations/entry/elasticsearch/filtering/index.js +0 -16
  311. package/operations/entry/elasticsearch/filtering/index.js.map +0 -1
  312. package/operations/entry/elasticsearch/filtering/path.d.ts +0 -15
  313. package/operations/entry/elasticsearch/filtering/path.js +0 -44
  314. package/operations/entry/elasticsearch/filtering/path.js.map +0 -1
  315. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.d.ts +0 -2
  316. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js +0 -28
  317. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js.map +0 -1
  318. package/operations/entry/elasticsearch/filtering/plugins/index.d.ts +0 -1
  319. package/operations/entry/elasticsearch/filtering/plugins/index.js +0 -13
  320. package/operations/entry/elasticsearch/filtering/plugins/index.js.map +0 -1
  321. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.d.ts +0 -2
  322. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js +0 -65
  323. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js.map +0 -1
  324. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.d.ts +0 -2
  325. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js +0 -48
  326. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js.map +0 -1
  327. package/operations/entry/elasticsearch/filtering/populated.d.ts +0 -2
  328. package/operations/entry/elasticsearch/filtering/populated.js +0 -23
  329. package/operations/entry/elasticsearch/filtering/populated.js.map +0 -1
  330. package/operations/entry/elasticsearch/filtering/values.d.ts +0 -2
  331. package/operations/entry/elasticsearch/filtering/values.js +0 -22
  332. package/operations/entry/elasticsearch/filtering/values.js.map +0 -1
  333. package/operations/entry/elasticsearch/fullTextSearch.d.ts +0 -12
  334. package/operations/entry/elasticsearch/fullTextSearch.js +0 -89
  335. package/operations/entry/elasticsearch/fullTextSearch.js.map +0 -1
  336. package/operations/entry/elasticsearch/fullTextSearchFields.d.ts +0 -8
  337. package/operations/entry/elasticsearch/fullTextSearchFields.js +0 -25
  338. package/operations/entry/elasticsearch/fullTextSearchFields.js.map +0 -1
  339. package/operations/entry/elasticsearch/initialQuery.d.ts +0 -17
  340. package/operations/entry/elasticsearch/initialQuery.js +0 -103
  341. package/operations/entry/elasticsearch/initialQuery.js.map +0 -1
  342. package/operations/entry/elasticsearch/keyword.d.ts +0 -2
  343. package/operations/entry/elasticsearch/keyword.js +0 -34
  344. package/operations/entry/elasticsearch/keyword.js.map +0 -1
  345. package/operations/entry/elasticsearch/plugins/bodyModifier.d.ts +0 -9
  346. package/operations/entry/elasticsearch/plugins/bodyModifier.js +0 -16
  347. package/operations/entry/elasticsearch/plugins/bodyModifier.js.map +0 -1
  348. package/operations/entry/elasticsearch/plugins/operator.d.ts +0 -8
  349. package/operations/entry/elasticsearch/plugins/operator.js +0 -37
  350. package/operations/entry/elasticsearch/plugins/operator.js.map +0 -1
  351. package/operations/entry/elasticsearch/plugins/queryModifier.d.ts +0 -9
  352. package/operations/entry/elasticsearch/plugins/queryModifier.js +0 -16
  353. package/operations/entry/elasticsearch/plugins/queryModifier.js.map +0 -1
  354. package/operations/entry/elasticsearch/plugins/search.d.ts +0 -7
  355. package/operations/entry/elasticsearch/plugins/search.js +0 -24
  356. package/operations/entry/elasticsearch/plugins/search.js.map +0 -1
  357. package/operations/entry/elasticsearch/plugins/sortModifier.d.ts +0 -9
  358. package/operations/entry/elasticsearch/plugins/sortModifier.js +0 -16
  359. package/operations/entry/elasticsearch/plugins/sortModifier.js.map +0 -1
  360. package/operations/entry/elasticsearch/sort.d.ts +0 -12
  361. package/operations/entry/elasticsearch/sort.js +0 -82
  362. package/operations/entry/elasticsearch/sort.js.map +0 -1
  363. package/operations/entry/elasticsearch/transformValueForSearch.d.ts +0 -16
  364. package/operations/entry/elasticsearch/transformValueForSearch.js +0 -30
  365. package/operations/entry/elasticsearch/transformValueForSearch.js.map +0 -1
  366. package/operations/entry/elasticsearch/types.d.ts +0 -41
  367. package/operations/entry/elasticsearch/types.js +0 -5
  368. package/operations/entry/elasticsearch/types.js.map +0 -1
  369. package/operations/entry/index.d.ts +0 -11
  370. package/operations/entry/index.js +0 -1128
  371. package/operations/entry/index.js.map +0 -1
  372. package/operations/group/index.d.ts +0 -8
  373. package/operations/group/index.js +0 -165
  374. package/operations/group/index.js.map +0 -1
  375. package/operations/model/index.d.ts +0 -8
  376. package/operations/model/index.js +0 -171
  377. package/operations/model/index.js.map +0 -1
  378. package/operations/settings/index.d.ts +0 -6
  379. package/operations/settings/index.js +0 -111
  380. package/operations/settings/index.js.map +0 -1
  381. package/operations/system/index.d.ts +0 -6
  382. package/operations/system/index.js +0 -82
  383. package/operations/system/index.js.map +0 -1
  384. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.d.ts +0 -21
  385. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js +0 -22
  386. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js.map +0 -1
  387. package/plugins/CmsEntryElasticsearchFieldPlugin.d.ts +0 -12
  388. package/plugins/CmsEntryElasticsearchFieldPlugin.js +0 -18
  389. package/plugins/CmsEntryElasticsearchFieldPlugin.js.map +0 -1
  390. package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.d.ts +0 -23
  391. package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js +0 -28
  392. package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js.map +0 -1
  393. package/plugins/CmsEntryElasticsearchIndexPlugin.d.ts +0 -4
  394. package/plugins/CmsEntryElasticsearchIndexPlugin.js +0 -12
  395. package/plugins/CmsEntryElasticsearchIndexPlugin.js.map +0 -1
  396. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.d.ts +0 -31
  397. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js +0 -37
  398. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js.map +0 -1
  399. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.d.ts +0 -18
  400. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js +0 -22
  401. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js.map +0 -1
  402. package/plugins/CmsEntryElasticsearchSortModifierPlugin.d.ts +0 -18
  403. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js +0 -22
  404. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js.map +0 -1
  405. package/plugins/CmsEntryFilterPlugin.d.ts +0 -49
  406. package/plugins/CmsEntryFilterPlugin.js +0 -24
  407. package/plugins/CmsEntryFilterPlugin.js.map +0 -1
  408. package/plugins/index.d.ts +0 -7
  409. package/plugins/index.js +0 -82
  410. package/plugins/index.js.map +0 -1
@@ -1,1128 +0,0 @@
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 _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
- var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
10
- var _error = _interopRequireDefault(require("@webiny/error"));
11
- var _types = require("@webiny/api-headless-cms/types");
12
- var _helpers = require("../../helpers");
13
- var _configurations = require("../../configurations");
14
- var _batchWrite = require("@webiny/db-dynamodb/utils/batchWrite");
15
- var _dataLoaders = require("./dataLoaders");
16
- var _keys = require("./keys");
17
- var _query = require("@webiny/db-dynamodb/utils/query");
18
- var _apiElasticsearch = require("@webiny/api-elasticsearch");
19
- var _get = require("@webiny/db-dynamodb/utils/get");
20
- var _utils = require("@webiny/utils");
21
- var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
22
- var _body = require("./elasticsearch/body");
23
- var _recordType = require("./recordType");
24
- const getEntryData = input => {
25
- const output = (0, _objectSpread2.default)({}, input);
26
- delete output["PK"];
27
- delete output["SK"];
28
- delete output["published"];
29
- delete output["latest"];
30
- return output;
31
- };
32
- const getESLatestEntryData = async (plugins, entry) => {
33
- return (0, _apiElasticsearch.compress)(plugins, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, getEntryData(entry)), {}, {
34
- latest: true,
35
- TYPE: (0, _recordType.createLatestRecordType)(),
36
- __type: (0, _recordType.createLatestRecordType)()
37
- }));
38
- };
39
- const getESPublishedEntryData = async (plugins, entry) => {
40
- return (0, _apiElasticsearch.compress)(plugins, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, getEntryData(entry)), {}, {
41
- published: true,
42
- TYPE: (0, _recordType.createPublishedRecordType)(),
43
- __type: (0, _recordType.createPublishedRecordType)()
44
- }));
45
- };
46
- const convertEntryKeysToStorage = params => {
47
- const {
48
- model,
49
- entry
50
- } = params;
51
- const values = model.convertValueKeyToStorage({
52
- fields: model.fields,
53
- values: entry.values
54
- });
55
- return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, entry), {}, {
56
- values
57
- });
58
- };
59
- const convertEntryKeysFromStorage = params => {
60
- const {
61
- model,
62
- entry
63
- } = params;
64
- const values = model.convertValueKeyFromStorage({
65
- fields: model.fields,
66
- values: entry.values
67
- });
68
- return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, entry), {}, {
69
- values
70
- });
71
- };
72
- const createEntriesStorageOperations = params => {
73
- const {
74
- entity,
75
- esEntity,
76
- elasticsearch,
77
- plugins
78
- } = params;
79
- const dataLoaders = new _dataLoaders.DataLoadersHandler({
80
- entity
81
- });
82
- const create = async (model, params) => {
83
- const {
84
- entry: initialEntry,
85
- storageEntry: initialStorageEntry
86
- } = params;
87
- const isPublished = initialEntry.status === "published";
88
- const locked = isPublished ? true : initialEntry.locked;
89
- const entry = convertEntryKeysToStorage({
90
- model,
91
- entry: initialEntry
92
- });
93
- const storageEntry = convertEntryKeysToStorage({
94
- model,
95
- entry: initialStorageEntry
96
- });
97
- const esEntry = (0, _helpers.prepareEntryToIndex)({
98
- plugins,
99
- model,
100
- entry: (0, _cloneDeep.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, entry), {}, {
101
- locked
102
- })),
103
- storageEntry: (0, _cloneDeep.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
104
- locked
105
- }))
106
- });
107
- const {
108
- index: esIndex
109
- } = _configurations.configurations.es({
110
- model
111
- });
112
- const esLatestData = await getESLatestEntryData(plugins, esEntry);
113
- const esPublishedData = await getESPublishedEntryData(plugins, esEntry);
114
- const revisionKeys = {
115
- PK: (0, _keys.createPartitionKey)({
116
- id: entry.id,
117
- locale: model.locale,
118
- tenant: model.tenant
119
- }),
120
- SK: (0, _keys.createRevisionSortKey)(entry)
121
- };
122
- const latestKeys = {
123
- PK: (0, _keys.createPartitionKey)({
124
- id: entry.id,
125
- locale: model.locale,
126
- tenant: model.tenant
127
- }),
128
- SK: (0, _keys.createLatestSortKey)()
129
- };
130
- const publishedKeys = {
131
- PK: (0, _keys.createPartitionKey)({
132
- id: entry.id,
133
- locale: model.locale,
134
- tenant: model.tenant
135
- }),
136
- SK: (0, _keys.createPublishedSortKey)()
137
- };
138
- const items = [entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
139
- locked
140
- }, revisionKeys), {}, {
141
- TYPE: (0, _recordType.createRecordType)()
142
- })), entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
143
- locked
144
- }, latestKeys), {}, {
145
- TYPE: (0, _recordType.createLatestRecordType)()
146
- }))];
147
- if (isPublished) {
148
- items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
149
- locked
150
- }, publishedKeys), {}, {
151
- TYPE: (0, _recordType.createPublishedRecordType)()
152
- })));
153
- }
154
- try {
155
- await (0, _batchWrite.batchWriteAll)({
156
- table: entity.table,
157
- items
158
- });
159
- dataLoaders.clearAll({
160
- model
161
- });
162
- } catch (ex) {
163
- throw new _error.default(ex.message || "Could not insert entry data into the DynamoDB table.", ex.code || "CREATE_ENTRY_ERROR", {
164
- error: ex,
165
- entry,
166
- storageEntry
167
- });
168
- }
169
- const esItems = [esEntity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, latestKeys), {}, {
170
- index: esIndex,
171
- data: esLatestData
172
- }))];
173
- if (isPublished) {
174
- esItems.push(esEntity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, publishedKeys), {}, {
175
- index: esIndex,
176
- data: esPublishedData
177
- })));
178
- }
179
- try {
180
- await (0, _batchWrite.batchWriteAll)({
181
- table: esEntity.table,
182
- items: esItems
183
- });
184
- } catch (ex) {
185
- throw new _error.default(ex.message || "Could not insert entry data into the Elasticsearch DynamoDB table.", ex.code || "CREATE_ES_ENTRY_ERROR", {
186
- error: ex,
187
- entry,
188
- esEntry
189
- });
190
- }
191
- return initialStorageEntry;
192
- };
193
- const createRevisionFrom = async (model, params) => {
194
- const {
195
- entry: initialEntry,
196
- storageEntry: initialStorageEntry
197
- } = params;
198
- const entry = convertEntryKeysToStorage({
199
- model,
200
- entry: initialEntry
201
- });
202
- const storageEntry = convertEntryKeysToStorage({
203
- model,
204
- entry: initialStorageEntry
205
- });
206
- const revisionKeys = {
207
- PK: (0, _keys.createPartitionKey)({
208
- id: entry.id,
209
- locale: model.locale,
210
- tenant: model.tenant
211
- }),
212
- SK: (0, _keys.createRevisionSortKey)(entry)
213
- };
214
- const latestKeys = {
215
- PK: (0, _keys.createPartitionKey)({
216
- id: entry.id,
217
- locale: model.locale,
218
- tenant: model.tenant
219
- }),
220
- SK: (0, _keys.createLatestSortKey)()
221
- };
222
- const esEntry = (0, _helpers.prepareEntryToIndex)({
223
- plugins,
224
- model,
225
- entry: (0, _cloneDeep.default)(entry),
226
- storageEntry: (0, _cloneDeep.default)(storageEntry)
227
- });
228
- const esLatestData = await getESLatestEntryData(plugins, esEntry);
229
- const items = [entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
230
- TYPE: (0, _recordType.createRecordType)()
231
- }, revisionKeys)), entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
232
- TYPE: (0, _recordType.createLatestRecordType)()
233
- }, latestKeys))];
234
- const {
235
- index
236
- } = _configurations.configurations.es({
237
- model
238
- });
239
- try {
240
- await (0, _batchWrite.batchWriteAll)({
241
- table: entity.table,
242
- items
243
- });
244
- dataLoaders.clearAll({
245
- model
246
- });
247
- } catch (ex) {
248
- throw new _error.default(ex.message || "Could not create revision from given entry in the DynamoDB table.", ex.code || "CREATE_REVISION_ERROR", {
249
- error: ex,
250
- entry,
251
- storageEntry
252
- });
253
- }
254
- /**
255
- * Update the "latest" entry item in the Elasticsearch
256
- */
257
- try {
258
- await esEntity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, latestKeys), {}, {
259
- index,
260
- data: esLatestData
261
- }));
262
- } catch (ex) {
263
- throw new _error.default(ex.message || "Could not update latest entry in the DynamoDB Elasticsearch table.", ex.code || "CREATE_REVISION_ERROR", {
264
- error: ex,
265
- entry
266
- });
267
- }
268
- /**
269
- * There are no modifications on the entry created so just return the data.
270
- */
271
- return initialStorageEntry;
272
- };
273
- const update = async (model, params) => {
274
- const {
275
- entry: initialEntry,
276
- storageEntry: initialStorageEntry
277
- } = params;
278
- const entry = convertEntryKeysToStorage({
279
- model,
280
- entry: initialEntry
281
- });
282
- const storageEntry = convertEntryKeysToStorage({
283
- model,
284
- entry: initialStorageEntry
285
- });
286
- const isPublished = entry.status === "published";
287
- const locked = isPublished ? true : entry.locked;
288
- const revisionKeys = {
289
- PK: (0, _keys.createPartitionKey)({
290
- id: entry.id,
291
- locale: model.locale,
292
- tenant: model.tenant
293
- }),
294
- SK: (0, _keys.createRevisionSortKey)(entry)
295
- };
296
- const latestKeys = {
297
- PK: (0, _keys.createPartitionKey)({
298
- id: entry.id,
299
- locale: model.locale,
300
- tenant: model.tenant
301
- }),
302
- SK: (0, _keys.createLatestSortKey)()
303
- };
304
- const publishedKeys = {
305
- PK: (0, _keys.createPartitionKey)({
306
- id: entry.id,
307
- locale: model.locale,
308
- tenant: model.tenant
309
- }),
310
- SK: (0, _keys.createPublishedSortKey)()
311
- };
312
-
313
- /**
314
- * We need the latest entry to check if it needs to be updated.
315
- */
316
- const [latestStorageEntry] = await dataLoaders.getLatestRevisionByEntryId({
317
- model,
318
- ids: [entry.id]
319
- });
320
- const [publishedStorageEntry] = await dataLoaders.getPublishedRevisionByEntryId({
321
- model,
322
- ids: [entry.id]
323
- });
324
- const items = [entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
325
- locked
326
- }, revisionKeys), {}, {
327
- TYPE: (0, _recordType.createRecordType)()
328
- }))];
329
- if (isPublished) {
330
- items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
331
- locked
332
- }, publishedKeys), {}, {
333
- TYPE: (0, _recordType.createPublishedRecordType)()
334
- })));
335
- }
336
- const esItems = [];
337
- const {
338
- index: esIndex
339
- } = _configurations.configurations.es({
340
- model
341
- });
342
- /**
343
- * Variable for the elasticsearch entry so we do not convert it more than once
344
- */
345
- let esEntry = undefined;
346
- /**
347
- * If the latest entry is the one being updated, we need to create a new latest entry records.
348
- */
349
- let elasticsearchLatestData = null;
350
- if ((latestStorageEntry === null || latestStorageEntry === void 0 ? void 0 : latestStorageEntry.id) === entry.id) {
351
- /**
352
- * First we update the regular DynamoDB table
353
- */
354
- items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), latestKeys), {}, {
355
- TYPE: (0, _keys.createLatestSortKey)()
356
- })));
357
- /**
358
- * And then update the Elasticsearch table to propagate changes to the Elasticsearch
359
- */
360
- esEntry = (0, _helpers.prepareEntryToIndex)({
361
- plugins,
362
- model,
363
- entry: (0, _cloneDeep.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, entry), {}, {
364
- locked
365
- })),
366
- storageEntry: (0, _cloneDeep.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
367
- locked
368
- }))
369
- });
370
- elasticsearchLatestData = await getESLatestEntryData(plugins, esEntry);
371
- esItems.push(esEntity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, latestKeys), {}, {
372
- index: esIndex,
373
- data: elasticsearchLatestData
374
- })));
375
- }
376
- let elasticsearchPublishedData = null;
377
- if (isPublished && (publishedStorageEntry === null || publishedStorageEntry === void 0 ? void 0 : publishedStorageEntry.id) === entry.id) {
378
- if (!elasticsearchLatestData) {
379
- /**
380
- * And then update the Elasticsearch table to propagate changes to the Elasticsearch
381
- */
382
- if (!esEntry) {
383
- esEntry = (0, _helpers.prepareEntryToIndex)({
384
- plugins,
385
- model,
386
- entry: (0, _cloneDeep.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, entry), {}, {
387
- locked
388
- })),
389
- storageEntry: (0, _cloneDeep.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
390
- locked
391
- }))
392
- });
393
- }
394
- elasticsearchPublishedData = await getESPublishedEntryData(plugins, esEntry);
395
- } else {
396
- elasticsearchPublishedData = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, elasticsearchLatestData), {}, {
397
- published: true,
398
- TYPE: (0, _recordType.createPublishedRecordType)(),
399
- __type: (0, _recordType.createPublishedRecordType)()
400
- });
401
- delete elasticsearchPublishedData.latest;
402
- }
403
- esItems.push(esEntity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, publishedKeys), {}, {
404
- index: esIndex,
405
- data: elasticsearchPublishedData
406
- })));
407
- }
408
- try {
409
- await (0, _batchWrite.batchWriteAll)({
410
- table: entity.table,
411
- items
412
- });
413
- dataLoaders.clearAll({
414
- model
415
- });
416
- } catch (ex) {
417
- throw new _error.default(ex.message || "Could not update entry DynamoDB records.", ex.code || "UPDATE_ENTRY_ERROR", {
418
- error: ex,
419
- entry,
420
- storageEntry
421
- });
422
- }
423
- if (esItems.length === 0) {
424
- return initialStorageEntry;
425
- }
426
- try {
427
- await (0, _batchWrite.batchWriteAll)({
428
- table: esEntity.table,
429
- items: esItems
430
- });
431
- } catch (ex) {
432
- throw new _error.default(ex.message || "Could not update entry DynamoDB Elasticsearch records.", ex.code || "UPDATE_ES_ENTRY_ERROR", {
433
- error: ex,
434
- entry
435
- });
436
- }
437
- return initialStorageEntry;
438
- };
439
- const deleteEntry = async (model, params) => {
440
- const {
441
- entry
442
- } = params;
443
- const partitionKey = (0, _keys.createPartitionKey)({
444
- id: entry.id,
445
- locale: model.locale,
446
- tenant: model.tenant
447
- });
448
- const items = await (0, _query.queryAll)({
449
- entity,
450
- partitionKey,
451
- options: {
452
- gte: " "
453
- }
454
- });
455
- const esItems = await (0, _query.queryAll)({
456
- entity: esEntity,
457
- partitionKey,
458
- options: {
459
- gte: " "
460
- }
461
- });
462
- const deleteItems = items.map(item => {
463
- return entity.deleteBatch({
464
- PK: item.PK,
465
- SK: item.SK
466
- });
467
- });
468
- const deleteEsItems = esItems.map(item => {
469
- return esEntity.deleteBatch({
470
- PK: item.PK,
471
- SK: item.SK
472
- });
473
- });
474
- try {
475
- await (0, _batchWrite.batchWriteAll)({
476
- table: entity.table,
477
- items: deleteItems
478
- });
479
- dataLoaders.clearAll({
480
- model
481
- });
482
- } catch (ex) {
483
- throw new _error.default(ex.message || "Could not delete entry records from DynamoDB table.", ex.code || "DELETE_ENTRY_ERROR", {
484
- error: ex,
485
- entry
486
- });
487
- }
488
- try {
489
- await (0, _batchWrite.batchWriteAll)({
490
- table: esEntity.table,
491
- items: deleteEsItems
492
- });
493
- } catch (ex) {
494
- throw new _error.default(ex.message || "Could not delete entry records from DynamoDB Elasticsearch table.", ex.code || "DELETE_ENTRY_ERROR", {
495
- error: ex,
496
- entry
497
- });
498
- }
499
- };
500
- const deleteRevision = async (model, params) => {
501
- const {
502
- entry,
503
- latestEntry,
504
- latestStorageEntry
505
- } = params;
506
- const partitionKey = (0, _keys.createPartitionKey)({
507
- id: entry.id,
508
- locale: model.locale,
509
- tenant: model.tenant
510
- });
511
- const {
512
- index
513
- } = _configurations.configurations.es({
514
- model
515
- });
516
- /**
517
- * We need published entry to delete it if necessary.
518
- */
519
- const [publishedStorageEntry] = await dataLoaders.getPublishedRevisionByEntryId({
520
- model,
521
- ids: [entry.id]
522
- });
523
- /**
524
- * We need to delete all existing records of the given entry revision.
525
- */
526
- const items = [
527
- /**
528
- * Delete records of given entry revision.
529
- */
530
- entity.deleteBatch({
531
- PK: partitionKey,
532
- SK: (0, _keys.createRevisionSortKey)(entry)
533
- })];
534
- const esItems = [];
535
-
536
- /**
537
- * If revision we are deleting is the published one as well, we need to delete those records as well.
538
- */
539
- if ((publishedStorageEntry === null || publishedStorageEntry === void 0 ? void 0 : publishedStorageEntry.id) === entry.id) {
540
- items.push(entity.deleteBatch({
541
- PK: partitionKey,
542
- SK: (0, _keys.createPublishedSortKey)()
543
- }));
544
- esItems.push(entity.deleteBatch({
545
- PK: partitionKey,
546
- SK: (0, _keys.createPublishedSortKey)()
547
- }));
548
- }
549
- if (latestEntry && latestStorageEntry) {
550
- const esEntry = (0, _helpers.prepareEntryToIndex)({
551
- plugins,
552
- model,
553
- entry: (0, _cloneDeep.default)(latestEntry),
554
- storageEntry: (0, _cloneDeep.default)(latestStorageEntry)
555
- });
556
- const esLatestData = await getESLatestEntryData(plugins, esEntry);
557
- /**
558
- * In the end we need to set the new latest entry
559
- */
560
- items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, latestStorageEntry), {}, {
561
- PK: partitionKey,
562
- SK: (0, _keys.createLatestSortKey)(),
563
- TYPE: (0, _recordType.createLatestRecordType)()
564
- })));
565
- esItems.push(esEntity.putBatch({
566
- PK: partitionKey,
567
- SK: (0, _keys.createLatestSortKey)(),
568
- index,
569
- data: esLatestData
570
- }));
571
- }
572
- try {
573
- await (0, _batchWrite.batchWriteAll)({
574
- table: entity.table,
575
- items
576
- });
577
- dataLoaders.clearAll({
578
- model
579
- });
580
- } catch (ex) {
581
- throw new _error.default(ex.message || "Could not batch write entry records to DynamoDB table.", ex.code || "DELETE_REVISION_ERROR", {
582
- error: ex,
583
- entry,
584
- latestEntry,
585
- latestStorageEntry
586
- });
587
- }
588
- if (esItems.length === 0) {
589
- return;
590
- }
591
- try {
592
- await (0, _batchWrite.batchWriteAll)({
593
- table: esEntity.table,
594
- items: esItems
595
- });
596
- } catch (ex) {
597
- throw new _error.default(ex.message || "Could not batch write entry records to DynamoDB Elasticsearch table.", ex.code || "DELETE_REVISION_ERROR", {
598
- error: ex,
599
- entry,
600
- latestEntry,
601
- latestStorageEntry
602
- });
603
- }
604
- };
605
- const list = async (model, params) => {
606
- var _response, _response$body;
607
- const limit = (0, _apiElasticsearch.createLimit)(params.limit, 50);
608
- const {
609
- index
610
- } = _configurations.configurations.es({
611
- model
612
- });
613
- try {
614
- const result = await elasticsearch.indices.exists({
615
- index
616
- });
617
- if (!(result !== null && result !== void 0 && result.body)) {
618
- return {
619
- hasMoreItems: false,
620
- totalCount: 0,
621
- cursor: null,
622
- items: []
623
- };
624
- }
625
- } catch (ex) {
626
- throw new _error.default("Could not determine if Elasticsearch index exists.", "ELASTICSEARCH_INDEX_CHECK_ERROR", {
627
- error: ex,
628
- index
629
- });
630
- }
631
- const body = (0, _body.createElasticsearchBody)({
632
- model,
633
- params: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
634
- limit,
635
- after: (0, _apiElasticsearch.decodeCursor)(params.after)
636
- }),
637
- plugins
638
- });
639
- let response;
640
- try {
641
- response = await elasticsearch.search({
642
- index,
643
- body
644
- });
645
- } catch (ex) {
646
- throw new _error.default(ex.message, ex.code || "ELASTICSEARCH_ERROR", {
647
- error: ex,
648
- index,
649
- body,
650
- model
651
- });
652
- }
653
- const {
654
- hits,
655
- total
656
- } = ((_response = response) === null || _response === void 0 ? void 0 : (_response$body = _response.body) === null || _response$body === void 0 ? void 0 : _response$body.hits) || {};
657
- const items = (0, _helpers.extractEntriesFromIndex)({
658
- plugins,
659
- model,
660
- entries: hits.map(item => item._source)
661
- }).map(item => {
662
- return convertEntryKeysFromStorage({
663
- model,
664
- entry: item
665
- });
666
- });
667
- const hasMoreItems = items.length > limit;
668
- if (hasMoreItems) {
669
- /**
670
- * Remove the last item from results, we don't want to include it.
671
- */
672
- items.pop();
673
- }
674
- /**
675
- * Cursor is the `sort` value of the last item in the array.
676
- * https://www.elastic.co/guide/en/elasticsearch/reference/current/paginate-search-results.html#search-after
677
- */
678
- const cursor = items.length > 0 ? (0, _apiElasticsearch.encodeCursor)(hits[items.length - 1].sort) || null : null;
679
- return {
680
- hasMoreItems,
681
- totalCount: total.value,
682
- cursor,
683
- items
684
- };
685
- };
686
- const get = async (model, params) => {
687
- const {
688
- items
689
- } = await list(model, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
690
- limit: 1
691
- }));
692
- return items.shift() || null;
693
- };
694
- const publish = async (model, params) => {
695
- const {
696
- entry: initialEntry,
697
- storageEntry: initialStorageEntry
698
- } = params;
699
- const entry = convertEntryKeysToStorage({
700
- model,
701
- entry: initialEntry
702
- });
703
- const storageEntry = convertEntryKeysToStorage({
704
- model,
705
- entry: initialStorageEntry
706
- });
707
-
708
- /**
709
- * We need currently published entry to check if need to remove it.
710
- */
711
- const [publishedStorageEntry] = await dataLoaders.getPublishedRevisionByEntryId({
712
- model,
713
- ids: [entry.id]
714
- });
715
- const revisionKeys = {
716
- PK: (0, _keys.createPartitionKey)({
717
- id: entry.id,
718
- locale: model.locale,
719
- tenant: model.tenant
720
- }),
721
- SK: (0, _keys.createRevisionSortKey)(entry)
722
- };
723
- const latestKeys = {
724
- PK: (0, _keys.createPartitionKey)({
725
- id: entry.id,
726
- locale: model.locale,
727
- tenant: model.tenant
728
- }),
729
- SK: (0, _keys.createLatestSortKey)()
730
- };
731
- const publishedKeys = {
732
- PK: (0, _keys.createPartitionKey)({
733
- id: entry.id,
734
- locale: model.locale,
735
- tenant: model.tenant
736
- }),
737
- SK: (0, _keys.createPublishedSortKey)()
738
- };
739
- let latestEsEntry = null;
740
- try {
741
- latestEsEntry = await (0, _get.get)({
742
- entity: esEntity,
743
- keys: latestKeys
744
- });
745
- } catch (ex) {
746
- throw new _error.default(ex.message || "Could not read Elasticsearch latest or published data.", ex.code || "PUBLISH_BATCH_READ", {
747
- error: ex,
748
- latestKeys: latestKeys,
749
- publishedKeys: publishedKeys
750
- });
751
- }
752
- const items = [entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), revisionKeys), {}, {
753
- TYPE: (0, _recordType.createRecordType)()
754
- }))];
755
- const esItems = [];
756
- const {
757
- index
758
- } = _configurations.configurations.es({
759
- model
760
- });
761
- if (publishedStorageEntry && publishedStorageEntry.id !== entry.id) {
762
- /**
763
- * If there is a `published` entry already, we need to set it to `unpublished`. We need to
764
- * execute two updates: update the previously published entry's status and the published entry record.
765
- * DynamoDB does not support `batchUpdate` - so here we load the previously published
766
- * entry's data to update its status within a batch operation. If, hopefully,
767
- * they introduce a true update batch operation, remove this `read` call.
768
- */
769
- const [previouslyPublishedEntry] = await dataLoaders.getRevisionById({
770
- model,
771
- ids: [publishedStorageEntry.id]
772
- });
773
- items.push(
774
- /**
775
- * Update currently published entry (unpublish it)
776
- */
777
- entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, previouslyPublishedEntry), {}, {
778
- status: _types.CONTENT_ENTRY_STATUS.UNPUBLISHED,
779
- savedOn: entry.savedOn,
780
- TYPE: (0, _recordType.createRecordType)(),
781
- PK: (0, _keys.createPartitionKey)(publishedStorageEntry),
782
- SK: (0, _keys.createRevisionSortKey)(publishedStorageEntry)
783
- })));
784
- }
785
- /**
786
- * Update the helper item in DB with the new published entry
787
- */
788
- items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), publishedKeys), {}, {
789
- TYPE: (0, _recordType.createPublishedRecordType)()
790
- })));
791
-
792
- /**
793
- * We need the latest entry to check if it needs to be updated as well in the Elasticsearch.
794
- */
795
- const [latestStorageEntry] = await dataLoaders.getLatestRevisionByEntryId({
796
- model,
797
- ids: [entry.id]
798
- });
799
- if ((latestStorageEntry === null || latestStorageEntry === void 0 ? void 0 : latestStorageEntry.id) === entry.id) {
800
- items.push(entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), latestKeys)));
801
- }
802
- /**
803
- * If we are publishing the latest revision, let's also update the latest revision's status in ES.
804
- */
805
- if (latestEsEntry && (latestStorageEntry === null || latestStorageEntry === void 0 ? void 0 : latestStorageEntry.id) === entry.id) {
806
- /**
807
- * Need to decompress the data from Elasticsearch DynamoDB table.
808
- *
809
- * No need to transform it for the storage because it was fetched directly from the Elasticsearch table, where it sits transformed.
810
- */
811
- const latestEsEntryDataDecompressed = await (0, _apiElasticsearch.decompress)(plugins, latestEsEntry.data);
812
- esItems.push(esEntity.putBatch({
813
- index,
814
- PK: (0, _keys.createPartitionKey)(latestEsEntryDataDecompressed),
815
- SK: (0, _keys.createLatestSortKey)(),
816
- data: await getESLatestEntryData(plugins, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, latestEsEntryDataDecompressed), {}, {
817
- status: _types.CONTENT_ENTRY_STATUS.PUBLISHED,
818
- locked: true,
819
- savedOn: entry.savedOn,
820
- publishedOn: entry.publishedOn
821
- }))
822
- }));
823
- }
824
- const preparedEntryData = (0, _helpers.prepareEntryToIndex)({
825
- plugins,
826
- model,
827
- entry: (0, _cloneDeep.default)(entry),
828
- storageEntry: (0, _cloneDeep.default)(storageEntry)
829
- });
830
- /**
831
- * Update the published revision entry in ES.
832
- */
833
- const esPublishedData = await getESPublishedEntryData(plugins, preparedEntryData);
834
- esItems.push(esEntity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, publishedKeys), {}, {
835
- index,
836
- data: esPublishedData
837
- })));
838
-
839
- /**
840
- * Finally, execute regular table batch.
841
- */
842
- try {
843
- await (0, _batchWrite.batchWriteAll)({
844
- table: entity.table,
845
- items
846
- });
847
- dataLoaders.clearAll({
848
- model
849
- });
850
- } catch (ex) {
851
- throw new _error.default(ex.message || "Could not store publish entry records in DynamoDB table.", ex.code || "PUBLISH_ERROR", {
852
- error: ex,
853
- entry,
854
- latestStorageEntry,
855
- publishedStorageEntry
856
- });
857
- }
858
- /**
859
- * And Elasticsearch table batch.
860
- */
861
- try {
862
- await (0, _batchWrite.batchWriteAll)({
863
- table: esEntity.table,
864
- items: esItems
865
- });
866
- } catch (ex) {
867
- throw new _error.default(ex.message || "Could not store publish entry records in DynamoDB Elasticsearch table.", ex.code || "PUBLISH_ES_ERROR", {
868
- error: ex,
869
- entry,
870
- latestStorageEntry,
871
- publishedStorageEntry
872
- });
873
- }
874
- return initialStorageEntry;
875
- };
876
- const unpublish = async (model, params) => {
877
- const {
878
- entry: initialEntry,
879
- storageEntry: initialStorageEntry
880
- } = params;
881
- const entry = convertEntryKeysToStorage({
882
- model,
883
- entry: initialEntry
884
- });
885
- const storageEntry = convertEntryKeysToStorage({
886
- model,
887
- entry: initialStorageEntry
888
- });
889
-
890
- /**
891
- * We need the latest entry to check if it needs to be updated.
892
- */
893
- const [latestStorageEntry] = await dataLoaders.getLatestRevisionByEntryId({
894
- model,
895
- ids: [entry.id]
896
- });
897
- const partitionKey = (0, _keys.createPartitionKey)({
898
- id: entry.id,
899
- locale: model.locale,
900
- tenant: model.tenant
901
- });
902
- const items = [entity.deleteBatch({
903
- PK: partitionKey,
904
- SK: (0, _keys.createPublishedSortKey)()
905
- }), entity.putBatch((0, _objectSpread2.default)((0, _objectSpread2.default)({}, storageEntry), {}, {
906
- PK: partitionKey,
907
- SK: (0, _keys.createRevisionSortKey)(entry),
908
- TYPE: (0, _recordType.createRecordType)()
909
- }))];
910
- const esItems = [esEntity.deleteBatch({
911
- PK: partitionKey,
912
- SK: (0, _keys.createPublishedSortKey)()
913
- })];
914
- /**
915
- * If we are unpublishing the latest revision, let's also update the latest revision entry's status in ES.
916
- */
917
- if ((latestStorageEntry === null || latestStorageEntry === void 0 ? void 0 : latestStorageEntry.id) === entry.id) {
918
- const {
919
- index
920
- } = _configurations.configurations.es({
921
- model
922
- });
923
- const preparedEntryData = (0, _helpers.prepareEntryToIndex)({
924
- plugins,
925
- model,
926
- entry: (0, _cloneDeep.default)(entry),
927
- storageEntry: (0, _cloneDeep.default)(storageEntry)
928
- });
929
- const esLatestData = await getESLatestEntryData(plugins, preparedEntryData);
930
- esItems.push(esEntity.putBatch({
931
- PK: partitionKey,
932
- SK: (0, _keys.createLatestSortKey)(),
933
- index,
934
- data: esLatestData
935
- }));
936
- }
937
-
938
- /**
939
- * Finally, execute regular table batch.
940
- */
941
- try {
942
- await (0, _batchWrite.batchWriteAll)({
943
- table: entity.table,
944
- items
945
- });
946
- dataLoaders.clearAll({
947
- model
948
- });
949
- } catch (ex) {
950
- throw new _error.default(ex.message || "Could not store unpublished entry records in DynamoDB table.", ex.code || "UNPUBLISH_ERROR", {
951
- entry,
952
- storageEntry
953
- });
954
- }
955
- /**
956
- * And Elasticsearch table batch.
957
- */
958
- try {
959
- await (0, _batchWrite.batchWriteAll)({
960
- table: esEntity.table,
961
- items: esItems
962
- });
963
- } catch (ex) {
964
- throw new _error.default(ex.message || "Could not store unpublished entry records in DynamoDB Elasticsearch table.", ex.code || "UNPUBLISH_ERROR", {
965
- entry,
966
- storageEntry
967
- });
968
- }
969
- return initialStorageEntry;
970
- };
971
- const getLatestRevisionByEntryId = async (model, params) => {
972
- const [entry] = await dataLoaders.getLatestRevisionByEntryId({
973
- model,
974
- ids: [params.id]
975
- });
976
- if (!entry) {
977
- return null;
978
- }
979
- return convertEntryKeysFromStorage({
980
- model,
981
- entry
982
- });
983
- };
984
- const getPublishedRevisionByEntryId = async (model, params) => {
985
- const [entry] = await dataLoaders.getPublishedRevisionByEntryId({
986
- model,
987
- ids: [params.id]
988
- });
989
- if (!entry) {
990
- return null;
991
- }
992
- return convertEntryKeysFromStorage({
993
- model,
994
- entry
995
- });
996
- };
997
- const getRevisionById = async (model, params) => {
998
- const [entry] = await dataLoaders.getRevisionById({
999
- model,
1000
- ids: [params.id]
1001
- });
1002
- if (!entry) {
1003
- return null;
1004
- }
1005
- return convertEntryKeysFromStorage({
1006
- model,
1007
- entry
1008
- });
1009
- };
1010
- const getRevisions = async (model, params) => {
1011
- const entries = await dataLoaders.getAllEntryRevisions({
1012
- model,
1013
- ids: [params.id]
1014
- });
1015
- return entries.map(entry => {
1016
- return convertEntryKeysFromStorage({
1017
- model,
1018
- entry
1019
- });
1020
- });
1021
- };
1022
- const getByIds = async (model, params) => {
1023
- const entries = await dataLoaders.getRevisionById({
1024
- model,
1025
- ids: params.ids
1026
- });
1027
- return entries.map(entry => {
1028
- return convertEntryKeysFromStorage({
1029
- model,
1030
- entry
1031
- });
1032
- });
1033
- };
1034
- const getLatestByIds = async (model, params) => {
1035
- const entries = await dataLoaders.getLatestRevisionByEntryId({
1036
- model,
1037
- ids: params.ids
1038
- });
1039
- return entries.map(entry => {
1040
- return convertEntryKeysFromStorage({
1041
- model,
1042
- entry
1043
- });
1044
- });
1045
- };
1046
- const getPublishedByIds = async (model, params) => {
1047
- const entries = await dataLoaders.getPublishedRevisionByEntryId({
1048
- model,
1049
- ids: params.ids
1050
- });
1051
- return entries.map(entry => {
1052
- return convertEntryKeysFromStorage({
1053
- model,
1054
- entry
1055
- });
1056
- });
1057
- };
1058
- const getPreviousRevision = async (model, params) => {
1059
- const {
1060
- tenant,
1061
- locale
1062
- } = model;
1063
- const {
1064
- entryId,
1065
- version
1066
- } = params;
1067
- const queryParams = {
1068
- entity,
1069
- partitionKey: (0, _keys.createPartitionKey)({
1070
- tenant,
1071
- locale,
1072
- id: entryId
1073
- }),
1074
- options: {
1075
- lt: `REV#${(0, _utils.zeroPad)(version)}`,
1076
- /**
1077
- * We need to have extra checks because DynamoDB will return published or latest record if there is no REV# record.
1078
- */
1079
- filters: [{
1080
- attr: "TYPE",
1081
- eq: (0, _recordType.createRecordType)()
1082
- }, {
1083
- attr: "version",
1084
- lt: version
1085
- }],
1086
- reverse: true
1087
- }
1088
- };
1089
- try {
1090
- const result = await (0, _query.queryOne)(queryParams);
1091
- const entry = (0, _cleanup.cleanupItem)(entity, result);
1092
- if (!entry) {
1093
- return null;
1094
- }
1095
- return convertEntryKeysFromStorage({
1096
- entry,
1097
- model
1098
- });
1099
- } catch (ex) {
1100
- throw new _error.default(ex.message || "Could not get previous version of given entry.", ex.code || "GET_PREVIOUS_VERSION_ERROR", (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
1101
- error: ex,
1102
- partitionKey: queryParams.partitionKey,
1103
- options: queryParams.options,
1104
- model
1105
- }));
1106
- }
1107
- };
1108
- return {
1109
- create,
1110
- createRevisionFrom,
1111
- update,
1112
- delete: deleteEntry,
1113
- deleteRevision,
1114
- get,
1115
- publish,
1116
- unpublish,
1117
- list,
1118
- getLatestRevisionByEntryId,
1119
- getPublishedRevisionByEntryId,
1120
- getRevisionById,
1121
- getRevisions,
1122
- getByIds,
1123
- getLatestByIds,
1124
- getPublishedByIds,
1125
- getPreviousRevision
1126
- };
1127
- };
1128
- exports.createEntriesStorageOperations = createEntriesStorageOperations;