@webiny/api-headless-cms-ddb-es 0.0.0-unstable.eb196ccd2f → 0.0.0-unstable.eb81deee7e

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