@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
@@ -0,0 +1,20 @@
1
+ import type { CmsModel } from "@webiny/api-headless-cms/types/index.js";
2
+ import { MoveEntryStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/MoveEntryStorageOperation.js";
3
+ import { CmsDdbEsEntryEntity } from "../../abstractions/CmsDdbEsEntryEntity.js";
4
+ import { CmsDdbEsEntriesEsEntity } from "../../abstractions/CmsDdbEsEntriesEsEntity.js";
5
+ import { CmsDdbEsDataLoaders } from "../../abstractions/CmsDdbEsDataLoaders.js";
6
+ import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
7
+ import { CompressionHandler } from "@webiny/utils/exports/api.js";
8
+ declare class DdbEsMoveEntryImpl implements MoveEntryStorageOperation.Interface {
9
+ private entity;
10
+ private esEntity;
11
+ private dataLoaders;
12
+ private storageModelProvider;
13
+ private compressionHandler;
14
+ constructor(entity: CmsDdbEsEntryEntity.Interface, esEntity: CmsDdbEsEntriesEsEntity.Interface, dataLoaders: CmsDdbEsDataLoaders.Interface, storageModelProvider: CmsStorageModelProvider.Interface, compressionHandler: CompressionHandler.Interface);
15
+ execute(initialModel: CmsModel, id: string, folderId: string): Promise<void>;
16
+ }
17
+ export declare const DdbEsMoveEntry: typeof DdbEsMoveEntryImpl & {
18
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/shared/storageOperations/entry/MoveEntryStorageOperation.js").IMoveEntryStorageOperation>;
19
+ };
20
+ export {};
@@ -0,0 +1,113 @@
1
+ import error from "@webiny/error";
2
+ import { MoveEntryStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/MoveEntryStorageOperation.js";
3
+ import { CmsDdbEsEntryEntity } from "../../abstractions/CmsDdbEsEntryEntity.js";
4
+ import { CmsDdbEsEntriesEsEntity } from "../../abstractions/CmsDdbEsEntriesEsEntity.js";
5
+ import { CmsDdbEsDataLoaders } from "../../abstractions/CmsDdbEsDataLoaders.js";
6
+ import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
7
+ import { CompressionHandler } from "@webiny/utils/exports/api.js";
8
+ import { createLatestSortKey, createPartitionKey, createPublishedSortKey } from "./keys.js";
9
+ class DdbEsMoveEntryImpl {
10
+ constructor(entity, esEntity, dataLoaders, storageModelProvider, compressionHandler){
11
+ this.entity = entity;
12
+ this.esEntity = esEntity;
13
+ this.dataLoaders = dataLoaders;
14
+ this.storageModelProvider = storageModelProvider;
15
+ this.compressionHandler = compressionHandler;
16
+ }
17
+ async execute(initialModel, id, folderId) {
18
+ const model = this.storageModelProvider.getModel(initialModel);
19
+ const partitionKey = createPartitionKey({
20
+ id,
21
+ tenant: model.tenant
22
+ });
23
+ const queryAllParams = {
24
+ partitionKey,
25
+ options: {
26
+ gte: " "
27
+ }
28
+ };
29
+ const latestSortKey = createLatestSortKey();
30
+ const publishedSortKey = createPublishedSortKey();
31
+ const records = await this.entity.queryAll(queryAllParams);
32
+ let latestRecord;
33
+ let publishedRecord;
34
+ const entityBatch = this.entity.createEntityWriter();
35
+ for (const record of records){
36
+ entityBatch.put({
37
+ ...record,
38
+ data: {
39
+ ...record.data,
40
+ location: {
41
+ ...record.data.location,
42
+ folderId
43
+ }
44
+ }
45
+ });
46
+ if (record.SK === publishedSortKey) publishedRecord = record.data;
47
+ else if (record.SK === latestSortKey) latestRecord = record.data;
48
+ }
49
+ try {
50
+ await entityBatch.execute();
51
+ this.dataLoaders.clearAll({
52
+ tenant: initialModel.tenant
53
+ });
54
+ } catch (ex) {
55
+ throw new error(ex.message || "Could not move all entry records from in the DynamoDB table.", ex.code || "MOVE_ENTRY_ERROR", {
56
+ error: ex,
57
+ id
58
+ });
59
+ }
60
+ const esEntityReader = this.esEntity.createEntityReader();
61
+ if (publishedRecord) esEntityReader.get({
62
+ PK: partitionKey,
63
+ SK: publishedSortKey
64
+ });
65
+ if (latestRecord) esEntityReader.get({
66
+ PK: partitionKey,
67
+ SK: latestSortKey
68
+ });
69
+ if (0 === esEntityReader.total) return;
70
+ const esRecords = await esEntityReader.execute();
71
+ const esItems = (await Promise.all(esRecords.map(async (record)=>{
72
+ if (!record) return null;
73
+ return {
74
+ ...record,
75
+ data: await this.compressionHandler.decompress(record.data)
76
+ };
77
+ }))).filter((item)=>!!item);
78
+ if (0 === esItems.length) return;
79
+ try {
80
+ const elasticsearchEntityBatch = this.esEntity.createEntityWriter({
81
+ put: await Promise.all(esItems.map(async (item)=>({
82
+ ...item,
83
+ data: await this.compressionHandler.compress({
84
+ ...item.data,
85
+ location: {
86
+ ...item.data?.location,
87
+ folderId
88
+ }
89
+ })
90
+ })))
91
+ });
92
+ await elasticsearchEntityBatch.execute();
93
+ } catch (ex) {
94
+ throw new error(ex.message || "Could not move entry DynamoDB Elasticsearch records.", ex.code || "MOVE_ES_ENTRY_ERROR", {
95
+ error: ex,
96
+ partitionKey
97
+ });
98
+ }
99
+ }
100
+ }
101
+ const DdbEsMoveEntry = MoveEntryStorageOperation.createImplementation({
102
+ implementation: DdbEsMoveEntryImpl,
103
+ dependencies: [
104
+ CmsDdbEsEntryEntity,
105
+ CmsDdbEsEntriesEsEntity,
106
+ CmsDdbEsDataLoaders,
107
+ CmsStorageModelProvider,
108
+ CompressionHandler
109
+ ]
110
+ });
111
+ export { DdbEsMoveEntry };
112
+
113
+ //# sourceMappingURL=DdbEsMoveEntry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations/entry/DdbEsMoveEntry.js","sources":["../../../src/operations/entry/DdbEsMoveEntry.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { CmsEntry, CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\nimport { MoveEntryStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/MoveEntryStorageOperation.js\";\nimport { CmsDdbEsEntryEntity } from \"~/abstractions/CmsDdbEsEntryEntity.js\";\nimport { CmsDdbEsEntriesEsEntity } from \"~/abstractions/CmsDdbEsEntriesEsEntity.js\";\nimport { CmsDdbEsDataLoaders } from \"~/abstractions/CmsDdbEsDataLoaders.js\";\nimport { CmsStorageModelProvider } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport { CompressionHandler } from \"@webiny/utils/exports/api.js\";\nimport type { IOpenSearchEntityAttributes as IElasticsearchEntityAttributes } from \"@webiny/api-opensearch-aws\";\nimport type { IEntityQueryAllParams } from \"@webiny/db-dynamodb\";\nimport { createLatestSortKey, createPartitionKey, createPublishedSortKey } from \"./keys.js\";\n\nclass DdbEsMoveEntryImpl implements MoveEntryStorageOperation.Interface {\n constructor(\n private entity: CmsDdbEsEntryEntity.Interface,\n private esEntity: CmsDdbEsEntriesEsEntity.Interface,\n private dataLoaders: CmsDdbEsDataLoaders.Interface,\n private storageModelProvider: CmsStorageModelProvider.Interface,\n private compressionHandler: CompressionHandler.Interface\n ) {}\n\n async execute(initialModel: CmsModel, id: string, folderId: string) {\n const model = this.storageModelProvider.getModel(initialModel);\n\n const partitionKey = createPartitionKey({\n id,\n tenant: model.tenant\n });\n /**\n * First we need to fetch all the records in the regular DynamoDB table.\n */\n const queryAllParams: IEntityQueryAllParams = {\n partitionKey,\n options: {\n gte: \" \"\n }\n };\n const latestSortKey = createLatestSortKey();\n const publishedSortKey = createPublishedSortKey();\n const records = await this.entity.queryAll(queryAllParams);\n /**\n * Then update the folderId in each record and prepare it to be stored.\n */\n let latestRecord: CmsEntry | undefined = undefined;\n let publishedRecord: CmsEntry | undefined = undefined;\n const entityBatch = this.entity.createEntityWriter();\n\n for (const record of records) {\n entityBatch.put({\n ...record,\n data: {\n ...record.data,\n location: {\n ...record.data.location,\n folderId\n }\n }\n });\n\n /**\n * We need to get the published and latest records, so we can update the Elasticsearch.\n */\n if (record.SK === publishedSortKey) {\n publishedRecord = record.data;\n } else if (record.SK === latestSortKey) {\n latestRecord = record.data;\n }\n }\n try {\n await entityBatch.execute();\n this.dataLoaders.clearAll({\n tenant: initialModel.tenant\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not move all entry records from in the DynamoDB table.\",\n ex.code || \"MOVE_ENTRY_ERROR\",\n {\n error: ex,\n id\n }\n );\n }\n\n const esEntityReader = this.esEntity.createEntityReader();\n\n if (publishedRecord) {\n esEntityReader.get({\n PK: partitionKey,\n SK: publishedSortKey\n });\n }\n if (latestRecord) {\n esEntityReader.get({\n PK: partitionKey,\n SK: latestSortKey\n });\n }\n if (esEntityReader.total === 0) {\n return;\n }\n const esRecords = await esEntityReader.execute();\n\n const esItems = (\n await Promise.all(\n esRecords.map(async record => {\n if (!record) {\n return null;\n }\n return {\n ...record,\n data: await this.compressionHandler.decompress(record.data)\n };\n })\n )\n ).filter((item): item is IElasticsearchEntityAttributes => !!item);\n\n if (esItems.length === 0) {\n return;\n }\n\n try {\n const elasticsearchEntityBatch = this.esEntity.createEntityWriter({\n put: await Promise.all(\n esItems.map(async item => {\n return {\n ...item,\n data: await this.compressionHandler.compress({\n ...item.data,\n location: {\n ...item.data?.location,\n folderId\n }\n })\n };\n })\n )\n });\n await elasticsearchEntityBatch.execute();\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not move entry DynamoDB Elasticsearch records.\",\n ex.code || \"MOVE_ES_ENTRY_ERROR\",\n {\n error: ex,\n partitionKey\n }\n );\n }\n }\n}\n\nexport const DdbEsMoveEntry = MoveEntryStorageOperation.createImplementation({\n implementation: DdbEsMoveEntryImpl,\n dependencies: [\n CmsDdbEsEntryEntity,\n CmsDdbEsEntriesEsEntity,\n CmsDdbEsDataLoaders,\n CmsStorageModelProvider,\n CompressionHandler\n ]\n});\n"],"names":["DdbEsMoveEntryImpl","entity","esEntity","dataLoaders","storageModelProvider","compressionHandler","initialModel","id","folderId","model","partitionKey","createPartitionKey","queryAllParams","latestSortKey","createLatestSortKey","publishedSortKey","createPublishedSortKey","records","latestRecord","publishedRecord","entityBatch","record","ex","WebinyError","esEntityReader","esRecords","esItems","Promise","item","elasticsearchEntityBatch","DdbEsMoveEntry","MoveEntryStorageOperation","CmsDdbEsEntryEntity","CmsDdbEsEntriesEsEntity","CmsDdbEsDataLoaders","CmsStorageModelProvider","CompressionHandler"],"mappings":"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"}
@@ -0,0 +1,23 @@
1
+ import type { CmsModel, CmsEntryStorageOperationsMoveToBinParams } from "@webiny/api-headless-cms/types/index.js";
2
+ import { MoveToBinStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/MoveToBinStorageOperation.js";
3
+ import { CmsDdbEsEntryEntity } from "../../abstractions/CmsDdbEsEntryEntity.js";
4
+ import { CmsDdbEsEntriesEsEntity } from "../../abstractions/CmsDdbEsEntriesEsEntity.js";
5
+ import { CmsDdbEsDataLoaders } from "../../abstractions/CmsDdbEsDataLoaders.js";
6
+ import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
7
+ import { CmsEntryOpenSearchFieldIndexRegistry, CmsEntryOpenSearchValuesModifier } from "@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js";
8
+ import { CompressionHandler } from "@webiny/utils/exports/api.js";
9
+ declare class DdbEsMoveToBinImpl implements MoveToBinStorageOperation.Interface {
10
+ private entity;
11
+ private esEntity;
12
+ private dataLoaders;
13
+ private storageModelProvider;
14
+ private fieldIndexRegistry;
15
+ private compressionHandler;
16
+ private valuesModifiers;
17
+ constructor(entity: CmsDdbEsEntryEntity.Interface, esEntity: CmsDdbEsEntriesEsEntity.Interface, dataLoaders: CmsDdbEsDataLoaders.Interface, storageModelProvider: CmsStorageModelProvider.Interface, fieldIndexRegistry: CmsEntryOpenSearchFieldIndexRegistry.Interface, compressionHandler: CompressionHandler.Interface, valuesModifiers: CmsEntryOpenSearchValuesModifier.Interface[]);
18
+ execute(initialModel: CmsModel, params: CmsEntryStorageOperationsMoveToBinParams): Promise<void>;
19
+ }
20
+ export declare const DdbEsMoveToBin: typeof DdbEsMoveToBinImpl & {
21
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/shared/storageOperations/entry/MoveToBinStorageOperation.js").IMoveToBinStorageOperation>;
22
+ };
23
+ export {};
@@ -0,0 +1,137 @@
1
+ import error from "@webiny/error";
2
+ import { MoveToBinStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/MoveToBinStorageOperation.js";
3
+ import { CmsDdbEsEntryEntity } from "../../abstractions/CmsDdbEsEntryEntity.js";
4
+ import { CmsDdbEsEntriesEsEntity } from "../../abstractions/CmsDdbEsEntriesEsEntity.js";
5
+ import { CmsDdbEsDataLoaders } from "../../abstractions/CmsDdbEsDataLoaders.js";
6
+ import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
7
+ import { CmsEntryOpenSearchFieldIndexRegistry, CmsEntryOpenSearchValuesModifier } from "@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js";
8
+ import { CompressionHandler } from "@webiny/utils/exports/api.js";
9
+ import { createTransformer } from "./transformations/index.js";
10
+ import { createLatestSortKey, createPartitionKey, createPublishedSortKey } from "./keys.js";
11
+ import { isDeletedEntryMetaField, pickEntryMetaFields } from "@webiny/api-headless-cms/constants.js";
12
+ class DdbEsMoveToBinImpl {
13
+ constructor(entity, esEntity, dataLoaders, storageModelProvider, fieldIndexRegistry, compressionHandler, valuesModifiers){
14
+ this.entity = entity;
15
+ this.esEntity = esEntity;
16
+ this.dataLoaders = dataLoaders;
17
+ this.storageModelProvider = storageModelProvider;
18
+ this.fieldIndexRegistry = fieldIndexRegistry;
19
+ this.compressionHandler = compressionHandler;
20
+ this.valuesModifiers = valuesModifiers;
21
+ }
22
+ async execute(initialModel, params) {
23
+ const { entry: initialEntry, storageEntry: initialStorageEntry } = params;
24
+ const model = this.storageModelProvider.getModel(initialModel);
25
+ const transformer = createTransformer({
26
+ valuesModifiers: this.valuesModifiers,
27
+ model,
28
+ entry: initialEntry,
29
+ storageEntry: initialStorageEntry,
30
+ fieldIndexRegistry: this.fieldIndexRegistry,
31
+ compressionHandler: this.compressionHandler
32
+ });
33
+ const { entry, storageEntry } = transformer.transformEntryKeys();
34
+ const partitionKey = createPartitionKey({
35
+ id: entry.id,
36
+ tenant: model.tenant
37
+ });
38
+ const queryAllParams = {
39
+ partitionKey,
40
+ options: {
41
+ gte: " "
42
+ }
43
+ };
44
+ const latestSortKey = createLatestSortKey();
45
+ const publishedSortKey = createPublishedSortKey();
46
+ const records = await this.entity.queryAll(queryAllParams);
47
+ const updatedEntryMetaFields = pickEntryMetaFields(entry, isDeletedEntryMetaField);
48
+ let latestRecord;
49
+ let publishedRecord;
50
+ const entityBatch = this.entity.createEntityWriter();
51
+ for (const record of records){
52
+ entityBatch.put({
53
+ ...record,
54
+ data: {
55
+ ...record.data,
56
+ ...updatedEntryMetaFields,
57
+ wbyDeleted: storageEntry.wbyDeleted,
58
+ location: storageEntry.location,
59
+ binOriginalFolderId: storageEntry.binOriginalFolderId
60
+ }
61
+ });
62
+ if (record.SK === publishedSortKey) publishedRecord = record.data;
63
+ else if (record.SK === latestSortKey) latestRecord = record.data;
64
+ }
65
+ try {
66
+ await entityBatch.execute();
67
+ this.dataLoaders.clearAll({
68
+ tenant: entry.tenant
69
+ });
70
+ } catch (ex) {
71
+ throw new error(ex.message || "Could mark as deleted all entry records from in the DynamoDB table.", ex.code || "MOVE_ENTRY_TO_BIN_ERROR", {
72
+ error: ex,
73
+ entry,
74
+ storageEntry
75
+ });
76
+ }
77
+ const esEntityReader = this.esEntity.createEntityReader();
78
+ if (publishedRecord) esEntityReader.get({
79
+ PK: partitionKey,
80
+ SK: publishedSortKey
81
+ });
82
+ if (latestRecord) esEntityReader.get({
83
+ PK: partitionKey,
84
+ SK: latestSortKey
85
+ });
86
+ if (0 === esEntityReader.total) return;
87
+ const esRecords = await esEntityReader.execute();
88
+ const esItems = (await Promise.all(esRecords.map(async (record)=>{
89
+ if (!record) return null;
90
+ return {
91
+ ...record,
92
+ data: await this.compressionHandler.decompress(record.data)
93
+ };
94
+ }))).filter((item)=>!!item);
95
+ if (0 === esItems.length) return;
96
+ const elasticsearchEntityBatch = this.esEntity.createEntityWriter();
97
+ for (const item of esItems)elasticsearchEntityBatch.put({
98
+ ...item,
99
+ data: await this.compressionHandler.compress({
100
+ ...item.data,
101
+ ...updatedEntryMetaFields,
102
+ wbyDeleted: entry.wbyDeleted,
103
+ location: entry.location,
104
+ binOriginalFolderId: entry.binOriginalFolderId
105
+ })
106
+ });
107
+ try {
108
+ await elasticsearchEntityBatch.execute();
109
+ } catch (ex) {
110
+ throw new error(ex.message || "Could not mark as deleted entry records from DynamoDB Elasticsearch table.", ex.code || "MOVE_ENTRY_TO_BIN_ERROR", {
111
+ error: ex,
112
+ entry,
113
+ storageEntry
114
+ });
115
+ }
116
+ }
117
+ }
118
+ const DdbEsMoveToBin = MoveToBinStorageOperation.createImplementation({
119
+ implementation: DdbEsMoveToBinImpl,
120
+ dependencies: [
121
+ CmsDdbEsEntryEntity,
122
+ CmsDdbEsEntriesEsEntity,
123
+ CmsDdbEsDataLoaders,
124
+ CmsStorageModelProvider,
125
+ CmsEntryOpenSearchFieldIndexRegistry,
126
+ CompressionHandler,
127
+ [
128
+ CmsEntryOpenSearchValuesModifier,
129
+ {
130
+ multiple: true
131
+ }
132
+ ]
133
+ ]
134
+ });
135
+ export { DdbEsMoveToBin };
136
+
137
+ //# sourceMappingURL=DdbEsMoveToBin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations/entry/DdbEsMoveToBin.js","sources":["../../../src/operations/entry/DdbEsMoveToBin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type {\n CmsEntry,\n CmsModel,\n CmsEntryStorageOperationsMoveToBinParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { MoveToBinStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/MoveToBinStorageOperation.js\";\nimport { CmsDdbEsEntryEntity } from \"~/abstractions/CmsDdbEsEntryEntity.js\";\nimport { CmsDdbEsEntriesEsEntity } from \"~/abstractions/CmsDdbEsEntriesEsEntity.js\";\nimport { CmsDdbEsDataLoaders } from \"~/abstractions/CmsDdbEsDataLoaders.js\";\nimport { CmsStorageModelProvider } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport {\n CmsEntryOpenSearchFieldIndexRegistry,\n CmsEntryOpenSearchValuesModifier\n} from \"@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js\";\nimport { CompressionHandler } from \"@webiny/utils/exports/api.js\";\nimport { createTransformer } from \"./transformations/index.js\";\nimport { createLatestSortKey, createPartitionKey, createPublishedSortKey } from \"./keys.js\";\nimport {\n isDeletedEntryMetaField,\n pickEntryMetaFields\n} from \"@webiny/api-headless-cms/constants.js\";\nimport type { IOpenSearchEntityAttributes as IElasticsearchEntityAttributes } from \"@webiny/api-opensearch-aws\";\nimport type { IEntityQueryAllParams } from \"@webiny/db-dynamodb\";\n\nclass DdbEsMoveToBinImpl implements MoveToBinStorageOperation.Interface {\n constructor(\n private entity: CmsDdbEsEntryEntity.Interface,\n private esEntity: CmsDdbEsEntriesEsEntity.Interface,\n private dataLoaders: CmsDdbEsDataLoaders.Interface,\n private storageModelProvider: CmsStorageModelProvider.Interface,\n private fieldIndexRegistry: CmsEntryOpenSearchFieldIndexRegistry.Interface,\n private compressionHandler: CompressionHandler.Interface,\n private valuesModifiers: CmsEntryOpenSearchValuesModifier.Interface[]\n ) {}\n\n async execute(\n initialModel: CmsModel,\n params: CmsEntryStorageOperationsMoveToBinParams\n ): Promise<void> {\n const { entry: initialEntry, storageEntry: initialStorageEntry } = params;\n const model = this.storageModelProvider.getModel(initialModel);\n\n const transformer = createTransformer({\n valuesModifiers: this.valuesModifiers,\n model,\n entry: initialEntry,\n storageEntry: initialStorageEntry,\n fieldIndexRegistry: this.fieldIndexRegistry,\n compressionHandler: this.compressionHandler\n });\n\n const { entry, storageEntry } = transformer.transformEntryKeys();\n\n const partitionKey = createPartitionKey({\n id: entry.id,\n tenant: model.tenant\n });\n\n /**\n * First we need to fetch all the records in the regular DynamoDB table.\n */\n const queryAllParams: IEntityQueryAllParams = {\n partitionKey,\n options: {\n gte: \" \"\n }\n };\n\n const latestSortKey = createLatestSortKey();\n const publishedSortKey = createPublishedSortKey();\n const records = await this.entity.queryAll(queryAllParams);\n\n /**\n * Let's pick the `deleted` meta fields from the entry.\n */\n const updatedEntryMetaFields = pickEntryMetaFields(entry, isDeletedEntryMetaField);\n\n /**\n * Then update all the records with data received.\n */\n let latestRecord: CmsEntry | undefined = undefined;\n let publishedRecord: CmsEntry | undefined = undefined;\n\n const entityBatch = this.entity.createEntityWriter();\n\n for (const record of records) {\n entityBatch.put({\n ...record,\n data: {\n ...record.data,\n ...updatedEntryMetaFields,\n wbyDeleted: storageEntry.wbyDeleted,\n location: storageEntry.location,\n binOriginalFolderId: storageEntry.binOriginalFolderId\n }\n });\n\n /**\n * We need to get the published and latest records, so we can update the Elasticsearch.\n */\n if (record.SK === publishedSortKey) {\n publishedRecord = record.data;\n } else if (record.SK === latestSortKey) {\n latestRecord = record.data;\n }\n }\n\n /**\n * We write the records back to the primary DynamoDB table.\n */\n try {\n await entityBatch.execute();\n\n this.dataLoaders.clearAll({\n tenant: entry.tenant\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could mark as deleted all entry records from in the DynamoDB table.\",\n ex.code || \"MOVE_ENTRY_TO_BIN_ERROR\",\n {\n error: ex,\n entry,\n storageEntry\n }\n );\n }\n\n /**\n * We need to get the published and latest records from Elasticsearch.\n */\n const esEntityReader = this.esEntity.createEntityReader();\n if (publishedRecord) {\n esEntityReader.get({\n PK: partitionKey,\n SK: publishedSortKey\n });\n }\n if (latestRecord) {\n esEntityReader.get({\n PK: partitionKey,\n SK: latestSortKey\n });\n }\n if (esEntityReader.total === 0) {\n return;\n }\n\n const esRecords = await esEntityReader.execute();\n\n const esItems = (\n await Promise.all(\n esRecords.map(async record => {\n if (!record) {\n return null;\n }\n return {\n ...record,\n data: await this.compressionHandler.decompress(record.data)\n };\n })\n )\n ).filter((item): item is IElasticsearchEntityAttributes => !!item);\n\n if (esItems.length === 0) {\n return;\n }\n\n /**\n * We update all ES records with data received.\n */\n const elasticsearchEntityBatch = this.esEntity.createEntityWriter();\n\n for (const item of esItems) {\n elasticsearchEntityBatch.put({\n ...item,\n data: await this.compressionHandler.compress({\n ...item.data,\n ...updatedEntryMetaFields,\n wbyDeleted: entry.wbyDeleted,\n location: entry.location,\n binOriginalFolderId: entry.binOriginalFolderId\n })\n });\n }\n\n /**\n * We write the records back to the primary DynamoDB Elasticsearch table.\n */\n try {\n await elasticsearchEntityBatch.execute();\n } catch (ex) {\n throw new WebinyError(\n ex.message ||\n \"Could not mark as deleted entry records from DynamoDB Elasticsearch table.\",\n ex.code || \"MOVE_ENTRY_TO_BIN_ERROR\",\n {\n error: ex,\n entry,\n storageEntry\n }\n );\n }\n }\n}\n\nexport const DdbEsMoveToBin = MoveToBinStorageOperation.createImplementation({\n implementation: DdbEsMoveToBinImpl,\n dependencies: [\n CmsDdbEsEntryEntity,\n CmsDdbEsEntriesEsEntity,\n CmsDdbEsDataLoaders,\n CmsStorageModelProvider,\n CmsEntryOpenSearchFieldIndexRegistry,\n CompressionHandler,\n [CmsEntryOpenSearchValuesModifier, { multiple: true }]\n ]\n});\n"],"names":["DdbEsMoveToBinImpl","entity","esEntity","dataLoaders","storageModelProvider","fieldIndexRegistry","compressionHandler","valuesModifiers","initialModel","params","initialEntry","initialStorageEntry","model","transformer","createTransformer","entry","storageEntry","partitionKey","createPartitionKey","queryAllParams","latestSortKey","createLatestSortKey","publishedSortKey","createPublishedSortKey","records","updatedEntryMetaFields","pickEntryMetaFields","isDeletedEntryMetaField","latestRecord","publishedRecord","entityBatch","record","ex","WebinyError","esEntityReader","esRecords","esItems","Promise","item","elasticsearchEntityBatch","DdbEsMoveToBin","MoveToBinStorageOperation","CmsDdbEsEntryEntity","CmsDdbEsEntriesEsEntity","CmsDdbEsDataLoaders","CmsStorageModelProvider","CmsEntryOpenSearchFieldIndexRegistry","CompressionHandler","CmsEntryOpenSearchValuesModifier"],"mappings":"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"}
@@ -0,0 +1,24 @@
1
+ import type { CmsModel, CmsEntryValues, CmsEntryStorageOperationsPublishParams } from "@webiny/api-headless-cms/types/index.js";
2
+ import { PublishEntryStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/PublishEntryStorageOperation.js";
3
+ import { CmsDdbEsEntryEntity } from "../../abstractions/CmsDdbEsEntryEntity.js";
4
+ import { CmsDdbEsEntriesEsEntity } from "../../abstractions/CmsDdbEsEntriesEsEntity.js";
5
+ import { CmsDdbEsDataLoaders } from "../../abstractions/CmsDdbEsDataLoaders.js";
6
+ import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
7
+ import { CmsEntryOpenSearchFieldIndexRegistry, CmsEntryOpenSearchValuesModifier, CmsModelOpenSearchIndexProvider } from "@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js";
8
+ import { CompressionHandler } from "@webiny/utils/exports/api.js";
9
+ declare class DdbEsPublishEntryImpl implements PublishEntryStorageOperation.Interface {
10
+ private entity;
11
+ private esEntity;
12
+ private dataLoaders;
13
+ private storageModelProvider;
14
+ private fieldIndexRegistry;
15
+ private compressionHandler;
16
+ private indexProvider;
17
+ private valuesModifiers;
18
+ constructor(entity: CmsDdbEsEntryEntity.Interface, esEntity: CmsDdbEsEntriesEsEntity.Interface, dataLoaders: CmsDdbEsDataLoaders.Interface, storageModelProvider: CmsStorageModelProvider.Interface, fieldIndexRegistry: CmsEntryOpenSearchFieldIndexRegistry.Interface, compressionHandler: CompressionHandler.Interface, indexProvider: CmsModelOpenSearchIndexProvider.Interface, valuesModifiers: CmsEntryOpenSearchValuesModifier.Interface[]);
19
+ execute<T extends CmsEntryValues = CmsEntryValues>(initialModel: CmsModel, params: CmsEntryStorageOperationsPublishParams<T>): Promise<import("@webiny/api-headless-cms/types/types.js").CmsStorageEntry<T>>;
20
+ }
21
+ export declare const DdbEsPublishEntry: typeof DdbEsPublishEntryImpl & {
22
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/shared/storageOperations/entry/PublishEntryStorageOperation.js").IPublishEntryStorageOperation>;
23
+ };
24
+ export {};
@@ -0,0 +1,231 @@
1
+ import error from "@webiny/error";
2
+ import { CONTENT_ENTRY_STATUS } from "@webiny/api-headless-cms/types/index.js";
3
+ import { PublishEntryStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/PublishEntryStorageOperation.js";
4
+ import { CmsDdbEsEntryEntity } from "../../abstractions/CmsDdbEsEntryEntity.js";
5
+ import { CmsDdbEsEntriesEsEntity } from "../../abstractions/CmsDdbEsEntriesEsEntity.js";
6
+ import { CmsDdbEsDataLoaders } from "../../abstractions/CmsDdbEsDataLoaders.js";
7
+ import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
8
+ import { CmsEntryOpenSearchFieldIndexRegistry, CmsEntryOpenSearchValuesModifier, CmsModelOpenSearchIndexProvider } from "@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js";
9
+ import { CompressionHandler } from "@webiny/utils/exports/api.js";
10
+ import { createConfigurations } from "@webiny/api-headless-cms-utils-os/configurations.js";
11
+ import { createTransformer } from "./transformations/index.js";
12
+ import { createEntryLatestKeys, createEntryPublishedKeys, createEntryRevisionKeys } from "./keys.js";
13
+ import { isEntryLevelEntryMetaField, pickEntryMetaFields } from "@webiny/api-headless-cms/constants.js";
14
+ class DdbEsPublishEntryImpl {
15
+ constructor(entity, esEntity, dataLoaders, storageModelProvider, fieldIndexRegistry, compressionHandler, indexProvider, valuesModifiers){
16
+ this.entity = entity;
17
+ this.esEntity = esEntity;
18
+ this.dataLoaders = dataLoaders;
19
+ this.storageModelProvider = storageModelProvider;
20
+ this.fieldIndexRegistry = fieldIndexRegistry;
21
+ this.compressionHandler = compressionHandler;
22
+ this.indexProvider = indexProvider;
23
+ this.valuesModifiers = valuesModifiers;
24
+ }
25
+ async execute(initialModel, params) {
26
+ const { entry: initialEntry, storageEntry: initialStorageEntry } = params;
27
+ const model = this.storageModelProvider.getModel(initialModel);
28
+ const transformer = createTransformer({
29
+ valuesModifiers: this.valuesModifiers,
30
+ model,
31
+ entry: initialEntry,
32
+ storageEntry: initialStorageEntry,
33
+ fieldIndexRegistry: this.fieldIndexRegistry,
34
+ compressionHandler: this.compressionHandler
35
+ });
36
+ const { entry, storageEntry } = transformer.transformEntryKeys();
37
+ const revisionKeys = createEntryRevisionKeys(entry);
38
+ const latestKeys = createEntryLatestKeys(entry);
39
+ const publishedKeys = createEntryPublishedKeys(entry);
40
+ let latestEsEntry = null;
41
+ try {
42
+ latestEsEntry = await this.esEntity.getClean(latestKeys);
43
+ } catch (ex) {
44
+ throw new error(ex.message || "Could not read Elasticsearch latest data.", ex.code || "PUBLISH_LATEST_READ", {
45
+ error: ex,
46
+ latestKeys: latestKeys,
47
+ publishedKeys: publishedKeys
48
+ });
49
+ }
50
+ if (!latestEsEntry) throw new error('Could not publish entry. Could not load latest ("L") record (ES table).', "PUBLISH_ERROR", {
51
+ entry
52
+ });
53
+ const [latestStorageEntry] = await this.dataLoaders.getLatestRevisionByEntryId({
54
+ model,
55
+ ids: [
56
+ entry.id
57
+ ]
58
+ });
59
+ if (!latestStorageEntry) throw new error('Could not publish entry. Could not load latest ("L") record.', "PUBLISH_ERROR", {
60
+ entry
61
+ });
62
+ const [publishedStorageEntry] = await this.dataLoaders.getPublishedRevisionByEntryId({
63
+ model,
64
+ ids: [
65
+ entry.id
66
+ ]
67
+ });
68
+ const entityBatch = this.entity.createEntityWriter({
69
+ put: [
70
+ {
71
+ ...revisionKeys,
72
+ data: storageEntry
73
+ },
74
+ {
75
+ ...publishedKeys,
76
+ data: storageEntry
77
+ }
78
+ ]
79
+ });
80
+ const elasticsearchEntityWriter = this.esEntity.createEntityWriter();
81
+ const configurations = createConfigurations(this.indexProvider);
82
+ const { index: esIndex } = await configurations.es({
83
+ model
84
+ });
85
+ const publishedRevisionId = publishedStorageEntry?.id;
86
+ const publishingLatestRevision = latestStorageEntry?.id === entry.id;
87
+ if (publishingLatestRevision) {
88
+ entityBatch.put({
89
+ ...latestKeys,
90
+ data: storageEntry
91
+ });
92
+ if (publishedStorageEntry) {
93
+ const isRepublishing = publishedStorageEntry.id === entry.id;
94
+ if (!isRepublishing) {
95
+ const publishedStorageEntryKeys = createEntryRevisionKeys(publishedStorageEntry);
96
+ entityBatch.put({
97
+ ...publishedStorageEntryKeys,
98
+ data: {
99
+ ...publishedStorageEntry,
100
+ status: CONTENT_ENTRY_STATUS.UNPUBLISHED
101
+ }
102
+ });
103
+ }
104
+ }
105
+ } else {
106
+ const updatedEntryLevelMetaFields = pickEntryMetaFields(entry, isEntryLevelEntryMetaField);
107
+ let latestRevisionStatus = latestStorageEntry.status;
108
+ if (latestRevisionStatus === CONTENT_ENTRY_STATUS.PUBLISHED) latestRevisionStatus = CONTENT_ENTRY_STATUS.UNPUBLISHED;
109
+ const latestStorageEntryFields = {
110
+ ...latestStorageEntry,
111
+ ...updatedEntryLevelMetaFields,
112
+ status: latestRevisionStatus
113
+ };
114
+ const latestStorageEntryLatestKeys = createEntryLatestKeys(latestStorageEntry);
115
+ entityBatch.put({
116
+ ...latestStorageEntryLatestKeys,
117
+ data: latestStorageEntryFields
118
+ });
119
+ const latestStorageEntryRevisionKeys = createEntryRevisionKeys(latestStorageEntry);
120
+ entityBatch.put({
121
+ ...latestStorageEntryRevisionKeys,
122
+ data: latestStorageEntryFields
123
+ });
124
+ if (publishedStorageEntry) {
125
+ const isRepublishing = publishedStorageEntry.id === entry.id;
126
+ const publishedRevisionDifferentFromLatest = publishedRevisionId !== latestStorageEntry.id;
127
+ if (!isRepublishing && publishedRevisionDifferentFromLatest) {
128
+ const publishedStorageEntryRevisionKeys = createEntryRevisionKeys(publishedStorageEntry);
129
+ entityBatch.put({
130
+ ...publishedStorageEntryRevisionKeys,
131
+ data: {
132
+ ...publishedStorageEntry,
133
+ status: CONTENT_ENTRY_STATUS.UNPUBLISHED
134
+ }
135
+ });
136
+ }
137
+ }
138
+ }
139
+ const esPublishedData = await transformer.getElasticsearchPublishedEntryData();
140
+ elasticsearchEntityWriter.put({
141
+ ...publishedKeys,
142
+ index: esIndex,
143
+ data: esPublishedData
144
+ });
145
+ const latestEsEntryDataDecompressed = await this.compressionHandler.decompress(latestEsEntry.data);
146
+ if (publishingLatestRevision) {
147
+ const updatedMetaFields = pickEntryMetaFields(entry);
148
+ const latestTransformer = createTransformer({
149
+ valuesModifiers: this.valuesModifiers,
150
+ model,
151
+ transformedToIndex: {
152
+ ...latestEsEntryDataDecompressed,
153
+ status: CONTENT_ENTRY_STATUS.PUBLISHED,
154
+ locked: true,
155
+ ...updatedMetaFields
156
+ },
157
+ fieldIndexRegistry: this.fieldIndexRegistry,
158
+ compressionHandler: this.compressionHandler
159
+ });
160
+ const esEntryLatestKeys = createEntryLatestKeys(latestEsEntryDataDecompressed);
161
+ elasticsearchEntityWriter.put({
162
+ index: esIndex,
163
+ data: await latestTransformer.getElasticsearchLatestEntryData(),
164
+ ...esEntryLatestKeys
165
+ });
166
+ } else {
167
+ const updatedEntryLevelMetaFields = pickEntryMetaFields(entry, isEntryLevelEntryMetaField);
168
+ const latestEsEntry = await this.esEntity.getClean(latestKeys);
169
+ if (latestEsEntry) {
170
+ const latestEsEntryDataDecompressed = await this.compressionHandler.decompress(latestEsEntry.data);
171
+ let latestRevisionStatus = latestEsEntryDataDecompressed.status;
172
+ if (latestRevisionStatus === CONTENT_ENTRY_STATUS.PUBLISHED) latestRevisionStatus = CONTENT_ENTRY_STATUS.UNPUBLISHED;
173
+ const updatedLatestEntry = await this.compressionHandler.compress({
174
+ ...latestEsEntryDataDecompressed,
175
+ ...updatedEntryLevelMetaFields,
176
+ status: latestRevisionStatus
177
+ });
178
+ elasticsearchEntityWriter.put({
179
+ ...latestKeys,
180
+ index: esIndex,
181
+ data: updatedLatestEntry
182
+ });
183
+ }
184
+ }
185
+ try {
186
+ await entityBatch.execute();
187
+ this.dataLoaders.clearAll({
188
+ tenant: entry.tenant
189
+ });
190
+ } catch (ex) {
191
+ throw new error(ex.message || "Could not store publish entry records in DynamoDB table.", ex.code || "PUBLISH_ERROR", {
192
+ error: ex,
193
+ entry,
194
+ latestStorageEntry,
195
+ publishedStorageEntry
196
+ });
197
+ }
198
+ try {
199
+ await elasticsearchEntityWriter.execute();
200
+ } catch (ex) {
201
+ throw new error(ex.message || "Could not store publish entry records in DynamoDB Elasticsearch table.", ex.code || "PUBLISH_ES_ERROR", {
202
+ error: ex,
203
+ entry,
204
+ latestStorageEntry,
205
+ publishedStorageEntry
206
+ });
207
+ }
208
+ return initialStorageEntry;
209
+ }
210
+ }
211
+ const DdbEsPublishEntry = PublishEntryStorageOperation.createImplementation({
212
+ implementation: DdbEsPublishEntryImpl,
213
+ dependencies: [
214
+ CmsDdbEsEntryEntity,
215
+ CmsDdbEsEntriesEsEntity,
216
+ CmsDdbEsDataLoaders,
217
+ CmsStorageModelProvider,
218
+ CmsEntryOpenSearchFieldIndexRegistry,
219
+ CompressionHandler,
220
+ CmsModelOpenSearchIndexProvider,
221
+ [
222
+ CmsEntryOpenSearchValuesModifier,
223
+ {
224
+ multiple: true
225
+ }
226
+ ]
227
+ ]
228
+ });
229
+ export { DdbEsPublishEntry };
230
+
231
+ //# sourceMappingURL=DdbEsPublishEntry.js.map