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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (410) hide show
  1. package/README.md +6 -30
  2. package/abstractions/CmsDdbEsDataLoaders.d.ts +5 -0
  3. package/abstractions/CmsDdbEsDataLoaders.js +5 -0
  4. package/abstractions/CmsDdbEsDataLoaders.js.map +1 -0
  5. package/abstractions/CmsDdbEsEntriesEsEntity.d.ts +5 -0
  6. package/abstractions/CmsDdbEsEntriesEsEntity.js +5 -0
  7. package/abstractions/CmsDdbEsEntriesEsEntity.js.map +1 -0
  8. package/abstractions/CmsDdbEsEntryEntity.d.ts +5 -0
  9. package/abstractions/CmsDdbEsEntryEntity.js +5 -0
  10. package/abstractions/CmsDdbEsEntryEntity.js.map +1 -0
  11. package/abstractions/CmsDdbEsGroupEntity.d.ts +5 -0
  12. package/abstractions/CmsDdbEsGroupEntity.js +5 -0
  13. package/abstractions/CmsDdbEsGroupEntity.js.map +1 -0
  14. package/abstractions/CmsDdbEsModelEntity.d.ts +5 -0
  15. package/abstractions/CmsDdbEsModelEntity.js +5 -0
  16. package/abstractions/CmsDdbEsModelEntity.js.map +1 -0
  17. package/abstractions/CmsDdbEsOsTable.d.ts +5 -0
  18. package/abstractions/CmsDdbEsOsTable.js +5 -0
  19. package/abstractions/CmsDdbEsOsTable.js.map +1 -0
  20. package/abstractions/CmsDdbEsTable.d.ts +5 -0
  21. package/abstractions/CmsDdbEsTable.js +5 -0
  22. package/abstractions/CmsDdbEsTable.js.map +1 -0
  23. package/definitions/entry.d.ts +4 -5
  24. package/definitions/entry.js +10 -87
  25. package/definitions/entry.js.map +1 -1
  26. package/definitions/group.d.ts +6 -6
  27. package/definitions/group.js +10 -64
  28. package/definitions/group.js.map +1 -1
  29. package/definitions/model.d.ts +6 -6
  30. package/definitions/model.js +10 -108
  31. package/definitions/model.js.map +1 -1
  32. package/definitions/types.d.ts +65 -0
  33. package/definitions/types.js +0 -0
  34. package/feature.d.ts +10 -0
  35. package/feature.js +69 -0
  36. package/feature.js.map +1 -0
  37. package/index.d.ts +1 -3
  38. package/index.js +1 -214
  39. package/operations/entry/DdbEsCreateEntry.d.ts +24 -0
  40. package/operations/entry/DdbEsCreateEntry.js +134 -0
  41. package/operations/entry/DdbEsCreateEntry.js.map +1 -0
  42. package/operations/entry/DdbEsCreateEntryRevisionFrom.d.ts +24 -0
  43. package/operations/entry/DdbEsCreateEntryRevisionFrom.js +139 -0
  44. package/operations/entry/DdbEsCreateEntryRevisionFrom.js.map +1 -0
  45. package/operations/entry/DdbEsDeleteEntry.d.ts +18 -0
  46. package/operations/entry/DdbEsDeleteEntry.js +79 -0
  47. package/operations/entry/DdbEsDeleteEntry.js.map +1 -0
  48. package/operations/entry/DdbEsDeleteEntryRevision.d.ts +24 -0
  49. package/operations/entry/DdbEsDeleteEntryRevision.js +136 -0
  50. package/operations/entry/DdbEsDeleteEntryRevision.js.map +1 -0
  51. package/operations/entry/DdbEsDeleteMultipleEntries.d.ts +18 -0
  52. package/operations/entry/DdbEsDeleteMultipleEntries.js +80 -0
  53. package/operations/entry/DdbEsDeleteMultipleEntries.js.map +1 -0
  54. package/operations/entry/DdbEsGetEntriesByIds.d.ts +14 -0
  55. package/operations/entry/DdbEsGetEntriesByIds.js +31 -0
  56. package/operations/entry/DdbEsGetEntriesByIds.js.map +1 -0
  57. package/operations/entry/DdbEsGetEntry.d.ts +14 -0
  58. package/operations/entry/DdbEsGetEntry.js +27 -0
  59. package/operations/entry/DdbEsGetEntry.js.map +1 -0
  60. package/operations/entry/DdbEsGetLatestEntriesByIds.d.ts +14 -0
  61. package/operations/entry/DdbEsGetLatestEntriesByIds.js +31 -0
  62. package/operations/entry/DdbEsGetLatestEntriesByIds.js.map +1 -0
  63. package/operations/entry/DdbEsGetLatestRevisionByEntryId.d.ts +14 -0
  64. package/operations/entry/DdbEsGetLatestRevisionByEntryId.js +34 -0
  65. package/operations/entry/DdbEsGetLatestRevisionByEntryId.js.map +1 -0
  66. package/operations/entry/DdbEsGetPreviousRevision.d.ts +14 -0
  67. package/operations/entry/DdbEsGetPreviousRevision.js +56 -0
  68. package/operations/entry/DdbEsGetPreviousRevision.js.map +1 -0
  69. package/operations/entry/DdbEsGetPublishedEntriesByIds.d.ts +14 -0
  70. package/operations/entry/DdbEsGetPublishedEntriesByIds.js +31 -0
  71. package/operations/entry/DdbEsGetPublishedEntriesByIds.js.map +1 -0
  72. package/operations/entry/DdbEsGetPublishedRevisionByEntryId.d.ts +14 -0
  73. package/operations/entry/DdbEsGetPublishedRevisionByEntryId.js +34 -0
  74. package/operations/entry/DdbEsGetPublishedRevisionByEntryId.js.map +1 -0
  75. package/operations/entry/DdbEsGetRevisionById.d.ts +14 -0
  76. package/operations/entry/DdbEsGetRevisionById.js +34 -0
  77. package/operations/entry/DdbEsGetRevisionById.js.map +1 -0
  78. package/operations/entry/DdbEsGetRevisions.d.ts +14 -0
  79. package/operations/entry/DdbEsGetRevisions.js +33 -0
  80. package/operations/entry/DdbEsGetRevisions.js.map +1 -0
  81. package/operations/entry/DdbEsGetUniqueFieldValues.d.ts +18 -0
  82. package/operations/entry/DdbEsGetUniqueFieldValues.js +76 -0
  83. package/operations/entry/DdbEsGetUniqueFieldValues.js.map +1 -0
  84. package/operations/entry/DdbEsListEntries.d.ts +25 -0
  85. package/operations/entry/DdbEsListEntries.js +91 -0
  86. package/operations/entry/DdbEsListEntries.js.map +1 -0
  87. package/operations/entry/DdbEsMoveEntry.d.ts +20 -0
  88. package/operations/entry/DdbEsMoveEntry.js +113 -0
  89. package/operations/entry/DdbEsMoveEntry.js.map +1 -0
  90. package/operations/entry/DdbEsMoveToBin.d.ts +23 -0
  91. package/operations/entry/DdbEsMoveToBin.js +137 -0
  92. package/operations/entry/DdbEsMoveToBin.js.map +1 -0
  93. package/operations/entry/DdbEsPublishEntry.d.ts +24 -0
  94. package/operations/entry/DdbEsPublishEntry.js +231 -0
  95. package/operations/entry/DdbEsPublishEntry.js.map +1 -0
  96. package/operations/entry/DdbEsRestoreFromBin.d.ts +23 -0
  97. package/operations/entry/DdbEsRestoreFromBin.js +137 -0
  98. package/operations/entry/DdbEsRestoreFromBin.js.map +1 -0
  99. package/operations/entry/DdbEsUnpublishEntry.d.ts +24 -0
  100. package/operations/entry/DdbEsUnpublishEntry.js +127 -0
  101. package/operations/entry/DdbEsUnpublishEntry.js.map +1 -0
  102. package/operations/entry/DdbEsUpdateEntry.d.ts +24 -0
  103. package/operations/entry/DdbEsUpdateEntry.js +175 -0
  104. package/operations/entry/DdbEsUpdateEntry.js.map +1 -0
  105. package/operations/entry/dataLoader/DataLoaderCache.d.ts +16 -0
  106. package/operations/entry/dataLoader/DataLoaderCache.js +27 -0
  107. package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -0
  108. package/operations/entry/dataLoader/constants.d.ts +1 -0
  109. package/operations/entry/dataLoader/constants.js +5 -0
  110. package/operations/entry/dataLoader/constants.js.map +1 -0
  111. package/operations/entry/dataLoader/createBatchScheduleFn.d.ts +8 -0
  112. package/operations/entry/dataLoader/createBatchScheduleFn.js +10 -0
  113. package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -0
  114. package/operations/entry/dataLoader/getAllEntryRevisions.d.ts +4 -0
  115. package/operations/entry/dataLoader/getAllEntryRevisions.js +24 -0
  116. package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -0
  117. package/operations/entry/dataLoader/getLatestRevisionByEntryId.d.ts +4 -0
  118. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +34 -0
  119. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -0
  120. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.d.ts +4 -0
  121. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +34 -0
  122. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -0
  123. package/operations/entry/dataLoader/getRevisionById.d.ts +4 -0
  124. package/operations/entry/dataLoader/getRevisionById.js +40 -0
  125. package/operations/entry/dataLoader/getRevisionById.js.map +1 -0
  126. package/operations/entry/dataLoader/index.d.ts +8 -0
  127. package/operations/entry/dataLoader/index.js +18 -0
  128. package/operations/entry/dataLoader/index.js.map +1 -0
  129. package/operations/entry/dataLoader/types.d.ts +6 -0
  130. package/operations/entry/dataLoader/types.js +0 -0
  131. package/operations/entry/dataLoaders.d.ts +18 -39
  132. package/operations/entry/dataLoaders.js +91 -306
  133. package/operations/entry/dataLoaders.js.map +1 -1
  134. package/operations/entry/feature.d.ts +4 -0
  135. package/operations/entry/feature.js +55 -0
  136. package/operations/entry/feature.js.map +1 -0
  137. package/operations/entry/keys.d.ts +31 -1
  138. package/operations/entry/keys.js +46 -27
  139. package/operations/entry/keys.js.map +1 -1
  140. package/operations/entry/recordType.js +5 -17
  141. package/operations/entry/recordType.js.map +1 -1
  142. package/operations/entry/storageEntryUtils.d.ts +7 -0
  143. package/operations/entry/storageEntryUtils.js +14 -0
  144. package/operations/entry/storageEntryUtils.js.map +1 -0
  145. package/operations/entry/transformations/convertEntryKeys.d.ts +8 -0
  146. package/operations/entry/transformations/convertEntryKeys.js +25 -0
  147. package/operations/entry/transformations/convertEntryKeys.js.map +1 -0
  148. package/operations/entry/transformations/index.d.ts +32 -0
  149. package/operations/entry/transformations/index.js +91 -0
  150. package/operations/entry/transformations/index.js.map +1 -0
  151. package/operations/entry/transformations/modifyEntryValues.d.ts +53 -0
  152. package/operations/entry/transformations/modifyEntryValues.js +16 -0
  153. package/operations/entry/transformations/modifyEntryValues.js.map +1 -0
  154. package/operations/entry/transformations/transformEntryKeys.d.ts +11 -0
  155. package/operations/entry/transformations/transformEntryKeys.js +17 -0
  156. package/operations/entry/transformations/transformEntryKeys.js.map +1 -0
  157. package/operations/group/DdbEsCreateGroup.d.ts +12 -0
  158. package/operations/group/DdbEsCreateGroup.js +35 -0
  159. package/operations/group/DdbEsCreateGroup.js.map +1 -0
  160. package/operations/group/DdbEsDeleteGroup.d.ts +12 -0
  161. package/operations/group/DdbEsDeleteGroup.js +31 -0
  162. package/operations/group/DdbEsDeleteGroup.js.map +1 -0
  163. package/operations/group/DdbEsGetGroup.d.ts +12 -0
  164. package/operations/group/DdbEsGetGroup.js +31 -0
  165. package/operations/group/DdbEsGetGroup.js.map +1 -0
  166. package/operations/group/DdbEsListGroups.d.ts +14 -0
  167. package/operations/group/DdbEsListGroups.js +52 -0
  168. package/operations/group/DdbEsListGroups.js.map +1 -0
  169. package/operations/group/DdbEsUpdateGroup.d.ts +12 -0
  170. package/operations/group/DdbEsUpdateGroup.js +35 -0
  171. package/operations/group/DdbEsUpdateGroup.js.map +1 -0
  172. package/operations/group/feature.d.ts +4 -0
  173. package/operations/group/feature.js +19 -0
  174. package/operations/group/feature.js.map +1 -0
  175. package/operations/group/keys.d.ts +15 -0
  176. package/operations/group/keys.js +17 -0
  177. package/operations/group/keys.js.map +1 -0
  178. package/operations/model/DdbEsCreateModel.d.ts +16 -0
  179. package/operations/model/DdbEsCreateModel.js +56 -0
  180. package/operations/model/DdbEsCreateModel.js.map +1 -0
  181. package/operations/model/DdbEsDeleteModel.d.ts +12 -0
  182. package/operations/model/DdbEsDeleteModel.js +31 -0
  183. package/operations/model/DdbEsDeleteModel.js.map +1 -0
  184. package/operations/model/DdbEsGetModel.d.ts +12 -0
  185. package/operations/model/DdbEsGetModel.js +30 -0
  186. package/operations/model/DdbEsGetModel.js.map +1 -0
  187. package/operations/model/DdbEsListModels.d.ts +12 -0
  188. package/operations/model/DdbEsListModels.js +36 -0
  189. package/operations/model/DdbEsListModels.js.map +1 -0
  190. package/operations/model/DdbEsUpdateModel.d.ts +12 -0
  191. package/operations/model/DdbEsUpdateModel.js +36 -0
  192. package/operations/model/DdbEsUpdateModel.js.map +1 -0
  193. package/operations/model/feature.d.ts +4 -0
  194. package/operations/model/feature.js +19 -0
  195. package/operations/model/feature.js.map +1 -0
  196. package/operations/model/keys.d.ts +15 -0
  197. package/operations/model/keys.js +17 -0
  198. package/operations/model/keys.js.map +1 -0
  199. package/package.json +48 -41
  200. package/registry/CmsEntitiesDbRegistryDecorator.d.ts +27 -0
  201. package/registry/CmsEntitiesDbRegistryDecorator.js +46 -0
  202. package/registry/CmsEntitiesDbRegistryDecorator.js.map +1 -0
  203. package/tasks/CreateElasticsearchIndexTask.d.ts +13 -0
  204. package/tasks/CreateElasticsearchIndexTask.js +40 -0
  205. package/tasks/CreateElasticsearchIndexTask.js.map +1 -0
  206. package/types.d.ts +13 -155
  207. package/types.js +9 -41
  208. package/types.js.map +1 -1
  209. package/configurations.d.ts +0 -12
  210. package/configurations.js +0 -35
  211. package/configurations.js.map +0 -1
  212. package/definitions/entryElasticsearch.d.ts +0 -8
  213. package/definitions/entryElasticsearch.js +0 -37
  214. package/definitions/entryElasticsearch.js.map +0 -1
  215. package/definitions/settings.d.ts +0 -8
  216. package/definitions/settings.js +0 -53
  217. package/definitions/settings.js.map +0 -1
  218. package/definitions/system.d.ts +0 -8
  219. package/definitions/system.js +0 -41
  220. package/definitions/system.js.map +0 -1
  221. package/definitions/table.d.ts +0 -8
  222. package/definitions/table.js +0 -21
  223. package/definitions/table.js.map +0 -1
  224. package/definitions/tableElasticsearch.d.ts +0 -8
  225. package/definitions/tableElasticsearch.js +0 -21
  226. package/definitions/tableElasticsearch.js.map +0 -1
  227. package/dynamoDb/index.d.ts +0 -2
  228. package/dynamoDb/index.js +0 -11
  229. package/dynamoDb/index.js.map +0 -1
  230. package/dynamoDb/storage/date.d.ts +0 -3
  231. package/dynamoDb/storage/date.js +0 -86
  232. package/dynamoDb/storage/date.js.map +0 -1
  233. package/dynamoDb/storage/longText.d.ts +0 -10
  234. package/dynamoDb/storage/longText.js +0 -93
  235. package/dynamoDb/storage/longText.js.map +0 -1
  236. package/dynamoDb/storage/richText.d.ts +0 -7
  237. package/dynamoDb/storage/richText.js +0 -110
  238. package/dynamoDb/storage/richText.js.map +0 -1
  239. package/elasticsearch/createElasticsearchIndex.d.ts +0 -9
  240. package/elasticsearch/createElasticsearchIndex.js +0 -49
  241. package/elasticsearch/createElasticsearchIndex.js.map +0 -1
  242. package/elasticsearch/deleteElasticsearchIndex.d.ts +0 -8
  243. package/elasticsearch/deleteElasticsearchIndex.js +0 -36
  244. package/elasticsearch/deleteElasticsearchIndex.js.map +0 -1
  245. package/elasticsearch/index.d.ts +0 -2
  246. package/elasticsearch/index.js +0 -11
  247. package/elasticsearch/index.js.map +0 -1
  248. package/elasticsearch/indexing/dateTimeIndexing.d.ts +0 -3
  249. package/elasticsearch/indexing/dateTimeIndexing.js +0 -86
  250. package/elasticsearch/indexing/dateTimeIndexing.js.map +0 -1
  251. package/elasticsearch/indexing/defaultFieldIndexing.d.ts +0 -3
  252. package/elasticsearch/indexing/defaultFieldIndexing.js +0 -52
  253. package/elasticsearch/indexing/defaultFieldIndexing.js.map +0 -1
  254. package/elasticsearch/indexing/index.d.ts +0 -2
  255. package/elasticsearch/indexing/index.js +0 -15
  256. package/elasticsearch/indexing/index.js.map +0 -1
  257. package/elasticsearch/indexing/longTextIndexing.d.ts +0 -7
  258. package/elasticsearch/indexing/longTextIndexing.js +0 -46
  259. package/elasticsearch/indexing/longTextIndexing.js.map +0 -1
  260. package/elasticsearch/indexing/numberIndexing.d.ts +0 -3
  261. package/elasticsearch/indexing/numberIndexing.js +0 -39
  262. package/elasticsearch/indexing/numberIndexing.js.map +0 -1
  263. package/elasticsearch/indexing/objectIndexing.d.ts +0 -12
  264. package/elasticsearch/indexing/objectIndexing.js +0 -196
  265. package/elasticsearch/indexing/objectIndexing.js.map +0 -1
  266. package/elasticsearch/indexing/richTextIndexing.d.ts +0 -3
  267. package/elasticsearch/indexing/richTextIndexing.js +0 -29
  268. package/elasticsearch/indexing/richTextIndexing.js.map +0 -1
  269. package/elasticsearch/indices/base.d.ts +0 -2
  270. package/elasticsearch/indices/base.js +0 -12
  271. package/elasticsearch/indices/base.js.map +0 -1
  272. package/elasticsearch/indices/index.d.ts +0 -1
  273. package/elasticsearch/indices/index.js +0 -12
  274. package/elasticsearch/indices/index.js.map +0 -1
  275. package/elasticsearch/indices/japanese.d.ts +0 -2
  276. package/elasticsearch/indices/japanese.js +0 -13
  277. package/elasticsearch/indices/japanese.js.map +0 -1
  278. package/elasticsearch/search/index.d.ts +0 -3
  279. package/elasticsearch/search/index.js +0 -10
  280. package/elasticsearch/search/index.js.map +0 -1
  281. package/elasticsearch/search/refSearch.d.ts +0 -2
  282. package/elasticsearch/search/refSearch.js +0 -29
  283. package/elasticsearch/search/refSearch.js.map +0 -1
  284. package/elasticsearch/search/timeSearch.d.ts +0 -2
  285. package/elasticsearch/search/timeSearch.js +0 -26
  286. package/elasticsearch/search/timeSearch.js.map +0 -1
  287. package/helpers/entryIndexHelpers.d.ts +0 -18
  288. package/helpers/entryIndexHelpers.js +0 -175
  289. package/helpers/entryIndexHelpers.js.map +0 -1
  290. package/helpers/index.d.ts +0 -1
  291. package/helpers/index.js +0 -16
  292. package/helpers/index.js.map +0 -1
  293. package/index.js.map +0 -1
  294. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.d.ts +0 -18
  295. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js +0 -32
  296. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js.map +0 -1
  297. package/operations/entry/elasticsearch/body.d.ts +0 -13
  298. package/operations/entry/elasticsearch/body.js +0 -140
  299. package/operations/entry/elasticsearch/body.js.map +0 -1
  300. package/operations/entry/elasticsearch/fields.d.ts +0 -9
  301. package/operations/entry/elasticsearch/fields.js +0 -229
  302. package/operations/entry/elasticsearch/fields.js.map +0 -1
  303. package/operations/entry/elasticsearch/filtering/applyFiltering.d.ts +0 -8
  304. package/operations/entry/elasticsearch/filtering/applyFiltering.js +0 -57
  305. package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +0 -1
  306. package/operations/entry/elasticsearch/filtering/exec.d.ts +0 -17
  307. package/operations/entry/elasticsearch/filtering/exec.js +0 -172
  308. package/operations/entry/elasticsearch/filtering/exec.js.map +0 -1
  309. package/operations/entry/elasticsearch/filtering/index.d.ts +0 -1
  310. package/operations/entry/elasticsearch/filtering/index.js +0 -16
  311. package/operations/entry/elasticsearch/filtering/index.js.map +0 -1
  312. package/operations/entry/elasticsearch/filtering/path.d.ts +0 -15
  313. package/operations/entry/elasticsearch/filtering/path.js +0 -44
  314. package/operations/entry/elasticsearch/filtering/path.js.map +0 -1
  315. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.d.ts +0 -2
  316. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js +0 -28
  317. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js.map +0 -1
  318. package/operations/entry/elasticsearch/filtering/plugins/index.d.ts +0 -1
  319. package/operations/entry/elasticsearch/filtering/plugins/index.js +0 -13
  320. package/operations/entry/elasticsearch/filtering/plugins/index.js.map +0 -1
  321. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.d.ts +0 -2
  322. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js +0 -65
  323. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js.map +0 -1
  324. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.d.ts +0 -2
  325. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js +0 -48
  326. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js.map +0 -1
  327. package/operations/entry/elasticsearch/filtering/populated.d.ts +0 -2
  328. package/operations/entry/elasticsearch/filtering/populated.js +0 -23
  329. package/operations/entry/elasticsearch/filtering/populated.js.map +0 -1
  330. package/operations/entry/elasticsearch/filtering/values.d.ts +0 -2
  331. package/operations/entry/elasticsearch/filtering/values.js +0 -22
  332. package/operations/entry/elasticsearch/filtering/values.js.map +0 -1
  333. package/operations/entry/elasticsearch/fullTextSearch.d.ts +0 -12
  334. package/operations/entry/elasticsearch/fullTextSearch.js +0 -89
  335. package/operations/entry/elasticsearch/fullTextSearch.js.map +0 -1
  336. package/operations/entry/elasticsearch/fullTextSearchFields.d.ts +0 -8
  337. package/operations/entry/elasticsearch/fullTextSearchFields.js +0 -25
  338. package/operations/entry/elasticsearch/fullTextSearchFields.js.map +0 -1
  339. package/operations/entry/elasticsearch/initialQuery.d.ts +0 -17
  340. package/operations/entry/elasticsearch/initialQuery.js +0 -103
  341. package/operations/entry/elasticsearch/initialQuery.js.map +0 -1
  342. package/operations/entry/elasticsearch/keyword.d.ts +0 -2
  343. package/operations/entry/elasticsearch/keyword.js +0 -34
  344. package/operations/entry/elasticsearch/keyword.js.map +0 -1
  345. package/operations/entry/elasticsearch/plugins/bodyModifier.d.ts +0 -9
  346. package/operations/entry/elasticsearch/plugins/bodyModifier.js +0 -16
  347. package/operations/entry/elasticsearch/plugins/bodyModifier.js.map +0 -1
  348. package/operations/entry/elasticsearch/plugins/operator.d.ts +0 -8
  349. package/operations/entry/elasticsearch/plugins/operator.js +0 -37
  350. package/operations/entry/elasticsearch/plugins/operator.js.map +0 -1
  351. package/operations/entry/elasticsearch/plugins/queryModifier.d.ts +0 -9
  352. package/operations/entry/elasticsearch/plugins/queryModifier.js +0 -16
  353. package/operations/entry/elasticsearch/plugins/queryModifier.js.map +0 -1
  354. package/operations/entry/elasticsearch/plugins/search.d.ts +0 -7
  355. package/operations/entry/elasticsearch/plugins/search.js +0 -24
  356. package/operations/entry/elasticsearch/plugins/search.js.map +0 -1
  357. package/operations/entry/elasticsearch/plugins/sortModifier.d.ts +0 -9
  358. package/operations/entry/elasticsearch/plugins/sortModifier.js +0 -16
  359. package/operations/entry/elasticsearch/plugins/sortModifier.js.map +0 -1
  360. package/operations/entry/elasticsearch/sort.d.ts +0 -12
  361. package/operations/entry/elasticsearch/sort.js +0 -82
  362. package/operations/entry/elasticsearch/sort.js.map +0 -1
  363. package/operations/entry/elasticsearch/transformValueForSearch.d.ts +0 -16
  364. package/operations/entry/elasticsearch/transformValueForSearch.js +0 -30
  365. package/operations/entry/elasticsearch/transformValueForSearch.js.map +0 -1
  366. package/operations/entry/elasticsearch/types.d.ts +0 -41
  367. package/operations/entry/elasticsearch/types.js +0 -5
  368. package/operations/entry/elasticsearch/types.js.map +0 -1
  369. package/operations/entry/index.d.ts +0 -11
  370. package/operations/entry/index.js +0 -1128
  371. package/operations/entry/index.js.map +0 -1
  372. package/operations/group/index.d.ts +0 -8
  373. package/operations/group/index.js +0 -165
  374. package/operations/group/index.js.map +0 -1
  375. package/operations/model/index.d.ts +0 -8
  376. package/operations/model/index.js +0 -171
  377. package/operations/model/index.js.map +0 -1
  378. package/operations/settings/index.d.ts +0 -6
  379. package/operations/settings/index.js +0 -111
  380. package/operations/settings/index.js.map +0 -1
  381. package/operations/system/index.d.ts +0 -6
  382. package/operations/system/index.js +0 -82
  383. package/operations/system/index.js.map +0 -1
  384. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.d.ts +0 -21
  385. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js +0 -22
  386. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js.map +0 -1
  387. package/plugins/CmsEntryElasticsearchFieldPlugin.d.ts +0 -12
  388. package/plugins/CmsEntryElasticsearchFieldPlugin.js +0 -18
  389. package/plugins/CmsEntryElasticsearchFieldPlugin.js.map +0 -1
  390. package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.d.ts +0 -23
  391. package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js +0 -28
  392. package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js.map +0 -1
  393. package/plugins/CmsEntryElasticsearchIndexPlugin.d.ts +0 -4
  394. package/plugins/CmsEntryElasticsearchIndexPlugin.js +0 -12
  395. package/plugins/CmsEntryElasticsearchIndexPlugin.js.map +0 -1
  396. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.d.ts +0 -31
  397. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js +0 -37
  398. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js.map +0 -1
  399. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.d.ts +0 -18
  400. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js +0 -22
  401. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js.map +0 -1
  402. package/plugins/CmsEntryElasticsearchSortModifierPlugin.d.ts +0 -18
  403. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js +0 -22
  404. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js.map +0 -1
  405. package/plugins/CmsEntryFilterPlugin.d.ts +0 -49
  406. package/plugins/CmsEntryFilterPlugin.js +0 -24
  407. package/plugins/CmsEntryFilterPlugin.js.map +0 -1
  408. package/plugins/index.d.ts +0 -7
  409. package/plugins/index.js +0 -82
  410. package/plugins/index.js.map +0 -1
@@ -1,313 +1,98 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.DataLoadersHandler = void 0;
8
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
- var _dataloader = _interopRequireDefault(require("dataloader"));
11
- var _error = _interopRequireDefault(require("@webiny/error"));
12
- var _query = require("@webiny/db-dynamodb/utils/query");
13
- var _keys = require("./keys");
14
- var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
15
- var _utils = require("@webiny/utils");
16
- var _batchRead = require("@webiny/db-dynamodb/utils/batchRead");
17
- const getAllEntryRevisions = params => {
18
- const {
19
- entity,
20
- model
21
- } = params;
22
- const {
23
- tenant,
24
- locale
25
- } = model;
26
- return new _dataloader.default(async ids => {
27
- const results = {};
28
- for (const id of ids) {
29
- const queryAllParams = {
30
- entity,
31
- partitionKey: (0, _keys.createPartitionKey)({
32
- tenant,
33
- locale,
34
- id
35
- }),
36
- options: {
37
- beginsWith: "REV#"
38
- }
39
- };
40
- const items = await (0, _query.queryAll)(queryAllParams);
41
- results[id] = (0, _cleanup.cleanupItems)(entity, items);
1
+ import error from "@webiny/error";
2
+ import { DataLoaderCache } from "./dataLoader/DataLoaderCache.js";
3
+ import { getDataLoaderFactory } from "./dataLoader/index.js";
4
+ import { parseIdentifier } from "@webiny/utils";
5
+ import { CmsDdbEsDataLoaders } from "../../abstractions/CmsDdbEsDataLoaders.js";
6
+ import { CmsDdbEsEntryEntity } from "../../abstractions/CmsDdbEsEntryEntity.js";
7
+ class DataLoadersHandlerImpl {
8
+ constructor(entity){
9
+ this.entity = entity;
10
+ this.cache = new DataLoaderCache();
11
+ }
12
+ async getAllEntryRevisions(params) {
13
+ const ids = params.ids.map((id)=>{
14
+ const { id: entryId } = parseIdentifier(id);
15
+ return entryId;
16
+ });
17
+ return await this.loadMany("getAllEntryRevisions", params, ids);
42
18
  }
43
- return ids.map(id => {
44
- return results[id] || [];
45
- });
46
- });
47
- };
48
- const getRevisionById = params => {
49
- const {
50
- entity,
51
- model
52
- } = params;
53
- const {
54
- locale,
55
- tenant
56
- } = model;
57
- return new _dataloader.default(async ids => {
58
- const queries = ids.reduce((collection, id) => {
59
- const partitionKey = (0, _keys.createPartitionKey)({
60
- tenant,
61
- locale,
62
- id
63
- });
64
- const {
65
- version
66
- } = (0, _utils.parseIdentifier)(id);
67
- if (!version) {
68
- return collection;
69
- }
70
- const sortKey = (0, _keys.createRevisionSortKey)({
71
- version
72
- });
73
- const keys = `${partitionKey}__${sortKey}`;
74
- if (collection[keys]) {
75
- return collection;
76
- }
77
- collection[keys] = entity.getBatch({
78
- PK: partitionKey,
79
- SK: sortKey
80
- });
81
- return collection;
82
- /**
83
- * We use any because there is no type for the return type.
84
- */
85
- }, {});
86
- const records = await (0, _batchRead.batchReadAll)({
87
- table: entity.table,
88
- items: Object.values(queries)
89
- });
90
- const items = (0, _cleanup.cleanupItems)(entity, records);
91
- return ids.map(id => {
92
- return items.filter(item => {
93
- return id === item.id;
94
- });
95
- });
96
- });
97
- };
98
- const getPublishedRevisionByEntryId = params => {
99
- const {
100
- entity,
101
- model
102
- } = params;
103
- const {
104
- locale,
105
- tenant
106
- } = model;
107
- const publishedKey = (0, _keys.createPublishedSortKey)();
108
- return new _dataloader.default(async ids => {
109
- const queries = ids.reduce((collection, id) => {
110
- const partitionKey = (0, _keys.createPartitionKey)({
111
- tenant,
112
- locale,
113
- id
114
- });
115
- if (collection[partitionKey]) {
116
- return collection;
117
- }
118
- collection[partitionKey] = entity.getBatch({
119
- PK: partitionKey,
120
- SK: publishedKey
121
- });
122
- return collection;
123
- /**
124
- * We use any because there is no type for the return type.
125
- */
126
- }, {});
127
- const records = await (0, _batchRead.batchReadAll)({
128
- table: entity.table,
129
- items: Object.values(queries)
130
- });
131
- const items = (0, _cleanup.cleanupItems)(entity, records);
132
- return ids.map(id => {
133
- const {
134
- id: entryId
135
- } = (0, _utils.parseIdentifier)(id);
136
- return items.filter(item => {
137
- return entryId === item.entryId;
138
- });
139
- });
140
- });
141
- };
142
- const getLatestRevisionByEntryId = params => {
143
- const {
144
- entity,
145
- model
146
- } = params;
147
- const {
148
- locale,
149
- tenant
150
- } = model;
151
- const latestKey = (0, _keys.createLatestSortKey)();
152
- return new _dataloader.default(async ids => {
153
- const queries = ids.reduce((collection, id) => {
154
- const partitionKey = (0, _keys.createPartitionKey)({
155
- tenant,
156
- locale,
157
- id
158
- });
159
- if (collection[partitionKey]) {
160
- return collection;
161
- }
162
- collection[partitionKey] = entity.getBatch({
163
- PK: partitionKey,
164
- SK: latestKey
165
- });
166
- return collection;
167
- /**
168
- * We use any because there is no type for the return type.
169
- */
170
- }, {});
171
- const records = await (0, _batchRead.batchReadAll)({
172
- table: entity.table,
173
- items: Object.values(queries)
174
- });
175
- const items = (0, _cleanup.cleanupItems)(entity, records);
176
- return ids.map(id => {
177
- const {
178
- id: entryId
179
- } = (0, _utils.parseIdentifier)(id);
180
- return items.filter(item => {
181
- return entryId === item.entryId;
182
- });
183
- });
184
- });
185
- };
186
- const dataLoaders = {
187
- getAllEntryRevisions,
188
- getRevisionById,
189
- getPublishedRevisionByEntryId,
190
- getLatestRevisionByEntryId
191
- };
192
- const loaderNames = Object.keys(dataLoaders);
193
- class DataLoadersHandler {
194
- constructor(params) {
195
- (0, _defineProperty2.default)(this, "loaders", new Map());
196
- (0, _defineProperty2.default)(this, "entity", void 0);
197
- this.entity = params.entity;
198
- }
199
- async getAllEntryRevisions(params) {
200
- return await this.loadMany("getAllEntryRevisions", params, params.ids);
201
- }
202
- clearAllEntryRevisions(params) {
203
- this.clear("getAllEntryRevisions", params);
204
- }
205
- async getRevisionById(params) {
206
- return await this.loadMany("getRevisionById", params, params.ids);
207
- }
208
- clearRevisionById(params) {
209
- this.clear("getRevisionById", params);
210
- }
211
- async getPublishedRevisionByEntryId(params) {
212
- return await this.loadMany("getPublishedRevisionByEntryId", params, params.ids);
213
- }
214
- clearPublishedRevisionByEntryId(params) {
215
- this.clear("getPublishedRevisionByEntryId", params);
216
- }
217
- async getLatestRevisionByEntryId(params) {
218
- return await this.loadMany("getLatestRevisionByEntryId", params, params.ids);
219
- }
220
- clearLatestRevisionByEntryId(params) {
221
- this.clear("getLatestRevisionByEntryId", params);
222
- }
223
- /**
224
- * TODO @ts-refactor
225
- * Maybe pass on the generics to DataLoader definition?
226
- */
227
- getLoader(name, params) {
228
- if (!dataLoaders[name]) {
229
- throw new _error.default("Unknown data loader.", "UNKNOWN_DATA_LOADER", {
230
- name
231
- });
19
+ async getRevisionById(params) {
20
+ return await this.loadMany("getRevisionById", params, params.ids);
232
21
  }
233
- const {
234
- model
235
- } = params;
236
- const {
237
- tenant,
238
- locale
239
- } = model;
240
- const loaderKey = `${name}-${tenant}-${locale}-${model.modelId}`;
241
- if (!this.loaders.has(loaderKey)) {
242
- this.loaders.set(loaderKey, dataLoaders[name]((0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
243
- entity: this.entity
244
- })));
22
+ async getPublishedRevisionByEntryId(params) {
23
+ const ids = params.ids.map((id)=>{
24
+ const { id: entryId } = parseIdentifier(id);
25
+ return entryId;
26
+ });
27
+ return await this.loadMany("getPublishedRevisionByEntryId", params, ids);
245
28
  }
246
- return this.loaders.get(loaderKey);
247
- }
248
- async loadMany(loader, params, ids) {
249
- let results;
250
- try {
251
- results = await this.getLoader(loader, params).loadMany(ids);
252
- if (Array.isArray(results) === true) {
253
- return results.reduce((acc, res) => {
254
- if (Array.isArray(res) === false) {
255
- if (res && res.message) {
256
- throw new _error.default(res.message, res.code, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, res), {}, {
257
- data: JSON.stringify(res.data || {})
258
- }));
259
- }
260
- throw new _error.default("Result from the data loader must be an array of arrays which contain requested items.", "DATA_LOADER_RESULTS_ERROR", (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
261
- loader
262
- }));
263
- }
264
- acc.push(...res);
265
- return acc;
266
- }, []);
267
- }
268
- } catch (ex) {
269
- throw new _error.default(ex.message || "Data loader error.", ex.code || "DATA_LOADER_ERROR", (0, _objectSpread2.default)((0, _objectSpread2.default)({
270
- error: ex
271
- }, params), {}, {
272
- loader,
273
- ids
274
- }));
29
+ async getLatestRevisionByEntryId(params) {
30
+ const ids = params.ids.map((id)=>{
31
+ const { id: entryId } = parseIdentifier(id);
32
+ return entryId;
33
+ });
34
+ return await this.loadMany("getLatestRevisionByEntryId", params, ids);
275
35
  }
276
- throw new _error.default(`Data loader did not return array of items or empty array.`, "INVALID_DATA_LOADER_RESULT", {
277
- loader,
278
- ids,
279
- results
280
- });
281
- }
282
- clearAll(params) {
283
- for (const name of loaderNames) {
284
- const loader = this.getLoader(name, params);
285
- loader.clearAll();
36
+ getLoader(name, params) {
37
+ const { model } = params;
38
+ const cacheParams = {
39
+ tenant: model.tenant,
40
+ modelId: model.modelId,
41
+ name
42
+ };
43
+ let loader = this.cache.getDataLoader(cacheParams);
44
+ if (loader) return loader;
45
+ const factory = getDataLoaderFactory(name);
46
+ loader = factory({
47
+ entity: this.entity,
48
+ tenant: model.tenant,
49
+ modelId: model.modelId
50
+ });
51
+ this.cache.setDataLoader(cacheParams, loader);
52
+ return loader;
286
53
  }
287
- }
288
- /**
289
- * Helper to clear the cache for certain data loader.
290
- * If entry is passed then clear target key only.
291
- */
292
- clear(name, params) {
293
- const {
294
- entry
295
- } = params;
296
- const loader = this.getLoader(name, params);
297
- if (!entry) {
298
- loader.clearAll();
299
- return;
54
+ async loadMany(loader, params, ids) {
55
+ let results = [];
56
+ try {
57
+ results = await this.getLoader(loader, params).loadMany(ids);
58
+ if (true === Array.isArray(results)) return results.reduce((acc, res)=>{
59
+ if (false === Array.isArray(res)) {
60
+ if (res && res.message) throw new error(res.message, res.code, {
61
+ ...res,
62
+ data: JSON.stringify(res.data || {})
63
+ });
64
+ throw new error("Result from the data loader must be an array of arrays which contain requested items.", "DATA_LOADER_RESULTS_ERROR", {
65
+ ...params,
66
+ loader
67
+ });
68
+ }
69
+ acc.push(...res);
70
+ return acc;
71
+ }, []);
72
+ } catch (ex) {
73
+ throw new error(ex.message || "Data loader error.", ex.code || "DATA_LOADER_ERROR", {
74
+ error: ex,
75
+ ...params,
76
+ loader,
77
+ ids
78
+ });
79
+ }
80
+ throw new error("Data loader did not return array of items or empty array.", "INVALID_DATA_LOADER_RESULT", {
81
+ loader,
82
+ ids,
83
+ results
84
+ });
85
+ }
86
+ clearAll(params) {
87
+ this.cache.clearAll(params);
300
88
  }
301
- loader.clear(entry.id);
302
- const {
303
- tenant,
304
- locale
305
- } = params.model;
306
- loader.clear((0, _keys.createPartitionKey)({
307
- tenant,
308
- locale,
309
- id: entry.id
310
- }));
311
- }
312
89
  }
313
- exports.DataLoadersHandler = DataLoadersHandler;
90
+ const DataLoadersHandler = CmsDdbEsDataLoaders.createImplementation({
91
+ implementation: DataLoadersHandlerImpl,
92
+ dependencies: [
93
+ CmsDdbEsEntryEntity
94
+ ]
95
+ });
96
+ export { DataLoadersHandler };
97
+
98
+ //# sourceMappingURL=dataLoaders.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["getAllEntryRevisions","params","entity","model","tenant","locale","DataLoader","ids","results","id","queryAllParams","partitionKey","createPartitionKey","options","beginsWith","items","queryAll","cleanupItems","map","getRevisionById","queries","reduce","collection","version","parseIdentifier","sortKey","createRevisionSortKey","keys","getBatch","PK","SK","records","batchReadAll","table","Object","values","filter","item","getPublishedRevisionByEntryId","publishedKey","createPublishedSortKey","entryId","getLatestRevisionByEntryId","latestKey","createLatestSortKey","dataLoaders","loaderNames","DataLoadersHandler","constructor","Map","loadMany","clearAllEntryRevisions","clear","clearRevisionById","clearPublishedRevisionByEntryId","clearLatestRevisionByEntryId","getLoader","name","WebinyError","loaderKey","modelId","loaders","has","set","get","loader","Array","isArray","acc","res","message","code","data","JSON","stringify","push","ex","error","clearAll","entry"],"sources":["dataLoaders.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport WebinyError from \"@webiny/error\";\nimport { CmsEntry, CmsModel } from \"@webiny/api-headless-cms/types\";\nimport { Entity } from \"dynamodb-toolbox\";\nimport { queryAll, QueryAllParams } from \"@webiny/db-dynamodb/utils/query\";\nimport {\n createLatestSortKey,\n createPartitionKey,\n createPublishedSortKey,\n createRevisionSortKey\n} from \"./keys\";\nimport { cleanupItems } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { batchReadAll } from \"@webiny/db-dynamodb/utils/batchRead\";\n\nconst getAllEntryRevisions = (params: LoaderParams) => {\n const { entity, model } = params;\n const { tenant, locale } = model;\n return new DataLoader<string, CmsEntry[]>(async (ids: readonly string[]) => {\n const results: Record<string, CmsEntry[]> = {};\n for (const id of ids) {\n const queryAllParams: QueryAllParams = {\n entity,\n partitionKey: createPartitionKey({\n tenant,\n locale,\n id\n }),\n options: {\n beginsWith: \"REV#\"\n }\n };\n const items = await queryAll<CmsEntry>(queryAllParams);\n\n results[id] = cleanupItems(entity, items);\n }\n\n return ids.map(id => {\n return results[id] || [];\n });\n });\n};\n\nconst getRevisionById = (params: LoaderParams) => {\n const { entity, model } = params;\n const { locale, tenant } = model;\n\n return new DataLoader<string, CmsEntry[]>(async (ids: readonly string[]) => {\n const queries = ids.reduce((collection, id) => {\n const partitionKey = createPartitionKey({\n tenant,\n locale,\n id\n });\n const { version } = parseIdentifier(id);\n if (!version) {\n return collection;\n }\n const sortKey = createRevisionSortKey({\n version\n });\n const keys = `${partitionKey}__${sortKey}`;\n if (collection[keys]) {\n return collection;\n }\n\n collection[keys] = entity.getBatch({\n PK: partitionKey,\n SK: sortKey\n });\n\n return collection;\n /**\n * We use any because there is no type for the return type.\n */\n }, {} as Record<string, any>);\n\n const records = await batchReadAll<CmsEntry>({\n table: entity.table,\n items: Object.values(queries)\n });\n const items = cleanupItems(entity, records);\n\n return ids.map(id => {\n return items.filter(item => {\n return id === item.id;\n });\n });\n });\n};\n\nconst getPublishedRevisionByEntryId = (params: LoaderParams) => {\n const { entity, model } = params;\n const { locale, tenant } = model;\n\n const publishedKey = createPublishedSortKey();\n\n return new DataLoader<string, CmsEntry[]>(async (ids: readonly string[]) => {\n const queries = ids.reduce((collection, id) => {\n const partitionKey = createPartitionKey({\n tenant,\n locale,\n id\n });\n if (collection[partitionKey]) {\n return collection;\n }\n collection[partitionKey] = entity.getBatch({\n PK: partitionKey,\n SK: publishedKey\n });\n return collection;\n /**\n * We use any because there is no type for the return type.\n */\n }, {} as Record<string, any>);\n\n const records = await batchReadAll<CmsEntry>({\n table: entity.table,\n items: Object.values(queries)\n });\n const items = cleanupItems(entity, records);\n\n return ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return items.filter(item => {\n return entryId === item.entryId;\n });\n });\n });\n};\n\nconst getLatestRevisionByEntryId = (params: LoaderParams) => {\n const { entity, model } = params;\n const { locale, tenant } = model;\n\n const latestKey = createLatestSortKey();\n\n return new DataLoader<string, CmsEntry[]>(async (ids: readonly string[]) => {\n const queries = ids.reduce((collection, id) => {\n const partitionKey = createPartitionKey({\n tenant,\n locale,\n id\n });\n if (collection[partitionKey]) {\n return collection;\n }\n collection[partitionKey] = entity.getBatch({\n PK: partitionKey,\n SK: latestKey\n });\n return collection;\n /**\n * We use any because there is no type for the return type.\n */\n }, {} as Record<string, any>);\n\n const records = await batchReadAll<CmsEntry>({\n table: entity.table,\n items: Object.values(queries)\n });\n const items = cleanupItems(entity, records);\n\n return ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return items.filter(item => {\n return entryId === item.entryId;\n });\n });\n });\n};\n\nconst dataLoaders: Record<Loaders, any> = {\n getAllEntryRevisions,\n getRevisionById,\n getPublishedRevisionByEntryId,\n getLatestRevisionByEntryId\n};\n\nexport interface GetAllEntryRevisionsParams {\n ids: readonly string[];\n model: CmsModel;\n}\n\nexport interface GetRevisionByIdParams {\n ids: readonly string[];\n model: CmsModel;\n}\n\nexport interface GetPublishedRevisionByEntryIdParams {\n ids: readonly string[];\n model: CmsModel;\n}\n\nexport interface GetLatestRevisionByEntryIdParams {\n ids: readonly string[];\n model: CmsModel;\n}\n\ninterface LoaderParams {\n entity: Entity<any>;\n model: CmsModel;\n}\n\ninterface GetLoaderParams {\n model: CmsModel;\n}\n\ninterface ClearLoaderParams {\n model: CmsModel;\n entry?: CmsEntry;\n}\n\ntype Loaders =\n | \"getAllEntryRevisions\"\n | \"getRevisionById\"\n | \"getPublishedRevisionByEntryId\"\n | \"getLatestRevisionByEntryId\";\n\nconst loaderNames = Object.keys(dataLoaders) as Loaders[];\n\nexport interface DataLoadersHandlerParams {\n entity: Entity<any>;\n}\nexport class DataLoadersHandler {\n private readonly loaders: Map<string, DataLoader<any, any>> = new Map();\n private readonly entity: Entity<any>;\n\n public constructor(params: DataLoadersHandlerParams) {\n this.entity = params.entity;\n }\n\n public async getAllEntryRevisions(params: GetAllEntryRevisionsParams): Promise<CmsEntry[]> {\n return await this.loadMany(\"getAllEntryRevisions\", params, params.ids);\n }\n\n public clearAllEntryRevisions(params: ClearLoaderParams): void {\n this.clear(\"getAllEntryRevisions\", params);\n }\n\n public async getRevisionById(params: GetRevisionByIdParams): Promise<CmsEntry[]> {\n return await this.loadMany(\"getRevisionById\", params, params.ids);\n }\n\n public clearRevisionById(params: ClearLoaderParams): void {\n this.clear(\"getRevisionById\", params);\n }\n\n public async getPublishedRevisionByEntryId(\n params: GetPublishedRevisionByEntryIdParams\n ): Promise<CmsEntry[]> {\n return await this.loadMany(\"getPublishedRevisionByEntryId\", params, params.ids);\n }\n public clearPublishedRevisionByEntryId(params: ClearLoaderParams): void {\n this.clear(\"getPublishedRevisionByEntryId\", params);\n }\n\n public async getLatestRevisionByEntryId(\n params: GetLatestRevisionByEntryIdParams\n ): Promise<CmsEntry[]> {\n return await this.loadMany(\"getLatestRevisionByEntryId\", params, params.ids);\n }\n\n public clearLatestRevisionByEntryId(params: ClearLoaderParams): void {\n this.clear(\"getLatestRevisionByEntryId\", params);\n }\n /**\n * TODO @ts-refactor\n * Maybe pass on the generics to DataLoader definition?\n */\n private getLoader(name: Loaders, params: GetLoaderParams): DataLoader<any, any> {\n if (!dataLoaders[name]) {\n throw new WebinyError(\"Unknown data loader.\", \"UNKNOWN_DATA_LOADER\", {\n name\n });\n }\n const { model } = params;\n const { tenant, locale } = model;\n const loaderKey = `${name}-${tenant}-${locale}-${model.modelId}`;\n if (!this.loaders.has(loaderKey)) {\n this.loaders.set(\n loaderKey,\n dataLoaders[name]({\n ...params,\n entity: this.entity\n })\n );\n }\n return this.loaders.get(loaderKey) as DataLoader<any, any>;\n }\n\n private async loadMany(\n loader: Loaders,\n params: GetLoaderParams,\n ids: readonly string[]\n ): Promise<CmsEntry[]> {\n let results;\n try {\n results = await this.getLoader(loader, params).loadMany(ids);\n if (Array.isArray(results) === true) {\n return results.reduce((acc, res) => {\n if (Array.isArray(res) === false) {\n if (res && res.message) {\n throw new WebinyError(res.message, res.code, {\n ...res,\n data: JSON.stringify(res.data || {})\n });\n }\n throw new WebinyError(\n \"Result from the data loader must be an array of arrays which contain requested items.\",\n \"DATA_LOADER_RESULTS_ERROR\",\n {\n ...params,\n loader\n }\n );\n }\n acc.push(...res);\n return acc;\n }, []);\n }\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Data loader error.\",\n ex.code || \"DATA_LOADER_ERROR\",\n {\n error: ex,\n ...params,\n loader,\n ids\n }\n );\n }\n throw new WebinyError(\n `Data loader did not return array of items or empty array.`,\n \"INVALID_DATA_LOADER_RESULT\",\n {\n loader,\n ids,\n results\n }\n );\n }\n\n public clearAll(params: Omit<ClearLoaderParams, \"entry\">): void {\n for (const name of loaderNames) {\n const loader = this.getLoader(name, params);\n loader.clearAll();\n }\n }\n /**\n * Helper to clear the cache for certain data loader.\n * If entry is passed then clear target key only.\n */\n private clear(name: Loaders, params: ClearLoaderParams): void {\n const { entry } = params;\n const loader = this.getLoader(name, params);\n if (!entry) {\n loader.clearAll();\n return;\n }\n loader.clear(entry.id);\n const { tenant, locale } = params.model;\n loader.clear(\n createPartitionKey({\n tenant,\n locale,\n id: entry.id\n })\n );\n }\n}\n"],"mappings":";;;;;;;;;AAAA;AACA;AAGA;AACA;AAMA;AACA;AACA;AAEA,MAAMA,oBAAoB,GAAIC,MAAoB,IAAK;EACnD,MAAM;IAAEC,MAAM;IAAEC;EAAM,CAAC,GAAGF,MAAM;EAChC,MAAM;IAAEG,MAAM;IAAEC;EAAO,CAAC,GAAGF,KAAK;EAChC,OAAO,IAAIG,mBAAU,CAAqB,MAAOC,GAAsB,IAAK;IACxE,MAAMC,OAAmC,GAAG,CAAC,CAAC;IAC9C,KAAK,MAAMC,EAAE,IAAIF,GAAG,EAAE;MAClB,MAAMG,cAA8B,GAAG;QACnCR,MAAM;QACNS,YAAY,EAAE,IAAAC,wBAAkB,EAAC;UAC7BR,MAAM;UACNC,MAAM;UACNI;QACJ,CAAC,CAAC;QACFI,OAAO,EAAE;UACLC,UAAU,EAAE;QAChB;MACJ,CAAC;MACD,MAAMC,KAAK,GAAG,MAAM,IAAAC,eAAQ,EAAWN,cAAc,CAAC;MAEtD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,EAAE;MAC5B,MAAMmB,MAAM,GAAG,IAAI,CAACT,SAAS,CAACC,IAAI,EAAExD,MAAM,CAAC;MAC3CgE,MAAM,CAACa,QAAQ,EAAE;IACrB;EACJ;EACA;AACJ;AACA;AACA;EACY1B,KAAK,CAACK,IAAa,EAAExD,MAAyB,EAAQ;IAC1D,MAAM;MAAE8E;IAAM,CAAC,GAAG9E,MAAM;IACxB,MAAMgE,MAAM,GAAG,IAAI,CAACT,SAAS,CAACC,IAAI,EAAExD,MAAM,CAAC;IAC3C,IAAI,CAAC8E,KAAK,EAAE;MACRd,MAAM,CAACa,QAAQ,EAAE;MACjB;IACJ;IACAb,MAAM,CAACb,KAAK,CAAC2B,KAAK,CAACtE,EAAE,CAAC;IACtB,MAAM;MAAEL,MAAM;MAAEC;IAAO,CAAC,GAAGJ,MAAM,CAACE,KAAK;IACvC8D,MAAM,CAACb,KAAK,CACR,IAAAxC,wBAAkB,EAAC;MACfR,MAAM;MACNC,MAAM;MACNI,EAAE,EAAEsE,KAAK,CAACtE;IACd,CAAC,CAAC,CACL;EACL;AACJ;AAAC"}
1
+ {"version":3,"file":"operations/entry/dataLoaders.js","sources":["../../../src/operations/entry/dataLoaders.ts"],"sourcesContent":["import type DataLoader from \"dataloader\";\nimport WebinyError from \"@webiny/error\";\nimport type {\n CmsEntryValues,\n CmsModel,\n CmsStorageEntry\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport type { CacheKeyParams } from \"~/operations/entry/dataLoader/DataLoaderCache.js\";\nimport { DataLoaderCache } from \"~/operations/entry/dataLoader/DataLoaderCache.js\";\nimport type { DataLoaders } from \"~/operations/entry/dataLoader/index.js\";\nimport { getDataLoaderFactory } from \"~/operations/entry/dataLoader/index.js\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport type { DataLoadersHandlerInterfaceClearAllParams, IDataLoadersHandler } from \"~/types.js\";\nimport type { IEntryEntity } from \"~/definitions/types.js\";\nimport { CmsDdbEsDataLoaders } from \"~/abstractions/CmsDdbEsDataLoaders.js\";\nimport { CmsDdbEsEntryEntity } from \"~/abstractions/CmsDdbEsEntryEntity.js\";\n\ninterface DataLoaderParams {\n model: Pick<CmsModel, \"tenant\" | \"modelId\">;\n ids: readonly string[];\n}\n\ninterface GetLoaderParams {\n model: Pick<CmsModel, \"tenant\" | \"modelId\">;\n}\n\nexport interface ClearAllParams {\n model: Pick<CmsModel, \"tenant\" | \"modelId\">;\n}\n\nclass DataLoadersHandlerImpl implements IDataLoadersHandler {\n private readonly cache = new DataLoaderCache();\n\n public constructor(private readonly entity: IEntryEntity) {}\n\n public async getAllEntryRevisions<T extends CmsEntryValues = CmsEntryValues>(\n params: DataLoaderParams\n ): Promise<CmsStorageEntry<T>[]> {\n const ids = params.ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return entryId;\n });\n return await this.loadMany<T>(\"getAllEntryRevisions\", params, ids);\n }\n\n public async getRevisionById<T extends CmsEntryValues = CmsEntryValues>(\n params: DataLoaderParams\n ): Promise<CmsStorageEntry<T>[]> {\n return await this.loadMany<T>(\"getRevisionById\", params, params.ids);\n }\n\n public async getPublishedRevisionByEntryId<T extends CmsEntryValues = CmsEntryValues>(\n params: DataLoaderParams\n ): Promise<CmsStorageEntry<T>[]> {\n const ids = params.ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return entryId;\n });\n return await this.loadMany<T>(\"getPublishedRevisionByEntryId\", params, ids);\n }\n\n public async getLatestRevisionByEntryId<T extends CmsEntryValues = CmsEntryValues>(\n params: DataLoaderParams\n ): Promise<CmsStorageEntry<T>[]> {\n const ids = params.ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return entryId;\n });\n return await this.loadMany<T>(\"getLatestRevisionByEntryId\", params, ids);\n }\n\n /**\n * TODO @ts-refactor\n * Maybe pass on the generics to DataLoader definition?\n */\n private getLoader(name: DataLoaders, params: GetLoaderParams): DataLoader<any, any> {\n const { model } = params;\n const cacheParams: CacheKeyParams = {\n tenant: model.tenant,\n modelId: model.modelId,\n name\n };\n let loader = this.cache.getDataLoader(cacheParams);\n if (loader) {\n return loader;\n }\n const factory = getDataLoaderFactory(name);\n loader = factory({\n entity: this.entity,\n tenant: model.tenant,\n modelId: model.modelId\n });\n this.cache.setDataLoader(cacheParams, loader);\n return loader;\n }\n\n private async loadMany<T extends CmsEntryValues = CmsEntryValues>(\n loader: DataLoaders,\n params: GetLoaderParams,\n ids: readonly string[]\n ): Promise<CmsStorageEntry<T>[]> {\n let results: CmsStorageEntry<T>[] = [];\n try {\n results = await this.getLoader(loader, params).loadMany(ids);\n if (Array.isArray(results) === true) {\n return results.reduce<CmsStorageEntry<T>[]>((acc, res) => {\n if (Array.isArray(res) === false) {\n if (res && res.message) {\n throw new WebinyError(res.message, res.code, {\n ...res,\n data: JSON.stringify(res.data || {})\n });\n }\n throw new WebinyError(\n \"Result from the data loader must be an array of arrays which contain requested items.\",\n \"DATA_LOADER_RESULTS_ERROR\",\n {\n ...params,\n loader\n }\n );\n }\n acc.push(...res);\n return acc;\n }, []);\n }\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Data loader error.\",\n ex.code || \"DATA_LOADER_ERROR\",\n {\n error: ex,\n ...params,\n loader,\n ids\n }\n );\n }\n throw new WebinyError(\n `Data loader did not return array of items or empty array.`,\n \"INVALID_DATA_LOADER_RESULT\",\n {\n loader,\n ids,\n results\n }\n );\n }\n\n public clearAll(params?: DataLoadersHandlerInterfaceClearAllParams): void {\n this.cache.clearAll(params);\n }\n}\n\nexport const DataLoadersHandler = CmsDdbEsDataLoaders.createImplementation({\n implementation: DataLoadersHandlerImpl,\n dependencies: [CmsDdbEsEntryEntity]\n});\n"],"names":["DataLoadersHandlerImpl","entity","DataLoaderCache","params","ids","id","entryId","parseIdentifier","name","model","cacheParams","loader","factory","getDataLoaderFactory","results","Array","acc","res","WebinyError","JSON","ex","DataLoadersHandler","CmsDdbEsDataLoaders","CmsDdbEsEntryEntity"],"mappings":";;;;;;AA8BA,MAAMA;IAGF,YAAoCC,MAA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;QAC1B;QACA,IAAI,CAAC,KAAK,CAAC,aAAa,CAACC,aAAaC;QACtC,OAAOA;IACX;IAEA,MAAc,SACVA,MAAmB,EACnBR,MAAuB,EACvBC,GAAsB,EACO;QAC7B,IAAIU,UAAgC,EAAE;QACtC,IAAI;YACAA,UAAU,MAAM,IAAI,CAAC,SAAS,CAACH,QAAQR,QAAQ,QAAQ,CAACC;YACxD,IAAIW,AAA2B,SAA3BA,MAAM,OAAO,CAACD,UACd,OAAOA,QAAQ,MAAM,CAAuB,CAACE,KAAKC;gBAC9C,IAAIF,AAAuB,UAAvBA,MAAM,OAAO,CAACE,MAAgB;oBAC9B,IAAIA,OAAOA,IAAI,OAAO,EAClB,MAAM,IAAIC,MAAYD,IAAI,OAAO,EAAEA,IAAI,IAAI,EAAE;wBACzC,GAAGA,GAAG;wBACN,MAAME,KAAK,SAAS,CAACF,IAAI,IAAI,IAAI,CAAC;oBACtC;oBAEJ,MAAM,IAAIC,MACN,yFACA,6BACA;wBACI,GAAGf,MAAM;wBACTQ;oBACJ;gBAER;gBACAK,IAAI,IAAI,IAAIC;gBACZ,OAAOD;YACX,GAAG,EAAE;QAEb,EAAE,OAAOI,IAAI;YACT,MAAM,IAAIF,MACNE,GAAG,OAAO,IAAI,sBACdA,GAAG,IAAI,IAAI,qBACX;gBACI,OAAOA;gBACP,GAAGjB,MAAM;gBACTQ;gBACAP;YACJ;QAER;QACA,MAAM,IAAIc,MACN,6DACA,8BACA;YACIP;YACAP;YACAU;QACJ;IAER;IAEO,SAASX,MAAkD,EAAQ;QACtE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAACA;IACxB;AACJ;AAEO,MAAMkB,qBAAqBC,oBAAoB,oBAAoB,CAAC;IACvE,gBAAgBtB;IAChB,cAAc;QAACuB;KAAoB;AACvC"}
@@ -0,0 +1,4 @@
1
+ export declare const DdbEsEntryStorageOpsFeature: {
2
+ name: string;
3
+ register(container: import("@webiny/di").Container): void;
4
+ };
@@ -0,0 +1,55 @@
1
+ import { createFeature } from "@webiny/feature/api/index.js";
2
+ import { DataLoadersHandler } from "./dataLoaders.js";
3
+ import { DdbEsCreateEntry } from "./DdbEsCreateEntry.js";
4
+ import { DdbEsCreateEntryRevisionFrom } from "./DdbEsCreateEntryRevisionFrom.js";
5
+ import { DdbEsUpdateEntry } from "./DdbEsUpdateEntry.js";
6
+ import { DdbEsMoveEntry } from "./DdbEsMoveEntry.js";
7
+ import { DdbEsMoveToBin } from "./DdbEsMoveToBin.js";
8
+ import { DdbEsDeleteEntry } from "./DdbEsDeleteEntry.js";
9
+ import { DdbEsRestoreFromBin } from "./DdbEsRestoreFromBin.js";
10
+ import { DdbEsDeleteEntryRevision } from "./DdbEsDeleteEntryRevision.js";
11
+ import { DdbEsDeleteMultipleEntries } from "./DdbEsDeleteMultipleEntries.js";
12
+ import { DdbEsGetEntry } from "./DdbEsGetEntry.js";
13
+ import { DdbEsListEntries } from "./DdbEsListEntries.js";
14
+ import { DdbEsPublishEntry } from "./DdbEsPublishEntry.js";
15
+ import { DdbEsUnpublishEntry } from "./DdbEsUnpublishEntry.js";
16
+ import { DdbEsGetEntriesByIds } from "./DdbEsGetEntriesByIds.js";
17
+ import { DdbEsGetLatestEntriesByIds } from "./DdbEsGetLatestEntriesByIds.js";
18
+ import { DdbEsGetPublishedEntriesByIds } from "./DdbEsGetPublishedEntriesByIds.js";
19
+ import { DdbEsGetRevisions } from "./DdbEsGetRevisions.js";
20
+ import { DdbEsGetRevisionById } from "./DdbEsGetRevisionById.js";
21
+ import { DdbEsGetLatestRevisionByEntryId } from "./DdbEsGetLatestRevisionByEntryId.js";
22
+ import { DdbEsGetPublishedRevisionByEntryId } from "./DdbEsGetPublishedRevisionByEntryId.js";
23
+ import { DdbEsGetPreviousRevision } from "./DdbEsGetPreviousRevision.js";
24
+ import { DdbEsGetUniqueFieldValues } from "./DdbEsGetUniqueFieldValues.js";
25
+ const DdbEsEntryStorageOpsFeature = createFeature({
26
+ name: "cms.ddbEs.entryStorageOps",
27
+ register: (container)=>{
28
+ container.register(DataLoadersHandler).inContainerScope();
29
+ container.register(DdbEsCreateEntry);
30
+ container.register(DdbEsCreateEntryRevisionFrom);
31
+ container.register(DdbEsUpdateEntry);
32
+ container.register(DdbEsMoveEntry);
33
+ container.register(DdbEsMoveToBin);
34
+ container.register(DdbEsDeleteEntry);
35
+ container.register(DdbEsRestoreFromBin);
36
+ container.register(DdbEsDeleteEntryRevision);
37
+ container.register(DdbEsDeleteMultipleEntries);
38
+ container.register(DdbEsGetEntry);
39
+ container.register(DdbEsListEntries);
40
+ container.register(DdbEsPublishEntry);
41
+ container.register(DdbEsUnpublishEntry);
42
+ container.register(DdbEsGetEntriesByIds);
43
+ container.register(DdbEsGetLatestEntriesByIds);
44
+ container.register(DdbEsGetPublishedEntriesByIds);
45
+ container.register(DdbEsGetRevisions);
46
+ container.register(DdbEsGetRevisionById);
47
+ container.register(DdbEsGetLatestRevisionByEntryId);
48
+ container.register(DdbEsGetPublishedRevisionByEntryId);
49
+ container.register(DdbEsGetPreviousRevision);
50
+ container.register(DdbEsGetUniqueFieldValues);
51
+ }
52
+ });
53
+ export { DdbEsEntryStorageOpsFeature };
54
+
55
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations/entry/feature.js","sources":["../../../src/operations/entry/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api/index.js\";\nimport { DataLoadersHandler } from \"./dataLoaders.js\";\nimport { DdbEsCreateEntry } from \"./DdbEsCreateEntry.js\";\nimport { DdbEsCreateEntryRevisionFrom } from \"./DdbEsCreateEntryRevisionFrom.js\";\nimport { DdbEsUpdateEntry } from \"./DdbEsUpdateEntry.js\";\nimport { DdbEsMoveEntry } from \"./DdbEsMoveEntry.js\";\nimport { DdbEsMoveToBin } from \"./DdbEsMoveToBin.js\";\nimport { DdbEsDeleteEntry } from \"./DdbEsDeleteEntry.js\";\nimport { DdbEsRestoreFromBin } from \"./DdbEsRestoreFromBin.js\";\nimport { DdbEsDeleteEntryRevision } from \"./DdbEsDeleteEntryRevision.js\";\nimport { DdbEsDeleteMultipleEntries } from \"./DdbEsDeleteMultipleEntries.js\";\nimport { DdbEsGetEntry } from \"./DdbEsGetEntry.js\";\nimport { DdbEsListEntries } from \"./DdbEsListEntries.js\";\nimport { DdbEsPublishEntry } from \"./DdbEsPublishEntry.js\";\nimport { DdbEsUnpublishEntry } from \"./DdbEsUnpublishEntry.js\";\nimport { DdbEsGetEntriesByIds } from \"./DdbEsGetEntriesByIds.js\";\nimport { DdbEsGetLatestEntriesByIds } from \"./DdbEsGetLatestEntriesByIds.js\";\nimport { DdbEsGetPublishedEntriesByIds } from \"./DdbEsGetPublishedEntriesByIds.js\";\nimport { DdbEsGetRevisions } from \"./DdbEsGetRevisions.js\";\nimport { DdbEsGetRevisionById } from \"./DdbEsGetRevisionById.js\";\nimport { DdbEsGetLatestRevisionByEntryId } from \"./DdbEsGetLatestRevisionByEntryId.js\";\nimport { DdbEsGetPublishedRevisionByEntryId } from \"./DdbEsGetPublishedRevisionByEntryId.js\";\nimport { DdbEsGetPreviousRevision } from \"./DdbEsGetPreviousRevision.js\";\nimport { DdbEsGetUniqueFieldValues } from \"./DdbEsGetUniqueFieldValues.js\";\n\nexport const DdbEsEntryStorageOpsFeature = createFeature({\n name: \"cms.ddbEs.entryStorageOps\",\n register: container => {\n // The DataLoader caches reads, so it must live for one request: container scoped, it is built\n // per request (child) container even though the feature is registered once in the root.\n container.register(DataLoadersHandler).inContainerScope();\n container.register(DdbEsCreateEntry);\n container.register(DdbEsCreateEntryRevisionFrom);\n container.register(DdbEsUpdateEntry);\n container.register(DdbEsMoveEntry);\n container.register(DdbEsMoveToBin);\n container.register(DdbEsDeleteEntry);\n container.register(DdbEsRestoreFromBin);\n container.register(DdbEsDeleteEntryRevision);\n container.register(DdbEsDeleteMultipleEntries);\n container.register(DdbEsGetEntry);\n container.register(DdbEsListEntries);\n container.register(DdbEsPublishEntry);\n container.register(DdbEsUnpublishEntry);\n container.register(DdbEsGetEntriesByIds);\n container.register(DdbEsGetLatestEntriesByIds);\n container.register(DdbEsGetPublishedEntriesByIds);\n container.register(DdbEsGetRevisions);\n container.register(DdbEsGetRevisionById);\n container.register(DdbEsGetLatestRevisionByEntryId);\n container.register(DdbEsGetPublishedRevisionByEntryId);\n container.register(DdbEsGetPreviousRevision);\n container.register(DdbEsGetUniqueFieldValues);\n }\n});\n"],"names":["DdbEsEntryStorageOpsFeature","createFeature","container","DataLoadersHandler","DdbEsCreateEntry","DdbEsCreateEntryRevisionFrom","DdbEsUpdateEntry","DdbEsMoveEntry","DdbEsMoveToBin","DdbEsDeleteEntry","DdbEsRestoreFromBin","DdbEsDeleteEntryRevision","DdbEsDeleteMultipleEntries","DdbEsGetEntry","DdbEsListEntries","DdbEsPublishEntry","DdbEsUnpublishEntry","DdbEsGetEntriesByIds","DdbEsGetLatestEntriesByIds","DdbEsGetPublishedEntriesByIds","DdbEsGetRevisions","DdbEsGetRevisionById","DdbEsGetLatestRevisionByEntryId","DdbEsGetPublishedRevisionByEntryId","DdbEsGetPreviousRevision","DdbEsGetUniqueFieldValues"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAyBO,MAAMA,8BAA8BC,cAAc;IACrD,MAAM;IACN,UAAUC,CAAAA;QAGNA,UAAU,QAAQ,CAACC,oBAAoB,gBAAgB;QACvDD,UAAU,QAAQ,CAACE;QACnBF,UAAU,QAAQ,CAACG;QACnBH,UAAU,QAAQ,CAACI;QACnBJ,UAAU,QAAQ,CAACK;QACnBL,UAAU,QAAQ,CAACM;QACnBN,UAAU,QAAQ,CAACO;QACnBP,UAAU,QAAQ,CAACQ;QACnBR,UAAU,QAAQ,CAACS;QACnBT,UAAU,QAAQ,CAACU;QACnBV,UAAU,QAAQ,CAACW;QACnBX,UAAU,QAAQ,CAACY;QACnBZ,UAAU,QAAQ,CAACa;QACnBb,UAAU,QAAQ,CAACc;QACnBd,UAAU,QAAQ,CAACe;QACnBf,UAAU,QAAQ,CAACgB;QACnBhB,UAAU,QAAQ,CAACiB;QACnBjB,UAAU,QAAQ,CAACkB;QACnBlB,UAAU,QAAQ,CAACmB;QACnBnB,UAAU,QAAQ,CAACoB;QACnBpB,UAAU,QAAQ,CAACqB;QACnBrB,UAAU,QAAQ,CAACsB;QACnBtB,UAAU,QAAQ,CAACuB;IACvB;AACJ"}
@@ -1,7 +1,6 @@
1
1
  export interface PartitionKeyParams {
2
2
  id: string;
3
3
  tenant: string;
4
- locale: string;
5
4
  }
6
5
  export declare const createPartitionKey: (params: PartitionKeyParams) => string;
7
6
  export interface SortKeyParams {
@@ -10,3 +9,34 @@ export interface SortKeyParams {
10
9
  export declare const createRevisionSortKey: (params: SortKeyParams) => string;
11
10
  export declare const createLatestSortKey: () => string;
12
11
  export declare const createPublishedSortKey: () => string;
12
+ export interface ICreateEntryPublishedKeysParams {
13
+ id: string;
14
+ tenant: string;
15
+ }
16
+ export declare const createEntryPublishedKeys: (params: ICreateEntryPublishedKeysParams) => {
17
+ PK: string;
18
+ SK: string;
19
+ TYPE: string;
20
+ GSI_TENANT: string;
21
+ };
22
+ export interface ICreateEntryLatestKeysParams {
23
+ id: string;
24
+ tenant: string;
25
+ }
26
+ export declare const createEntryLatestKeys: (params: ICreateEntryLatestKeysParams) => {
27
+ PK: string;
28
+ SK: string;
29
+ TYPE: string;
30
+ GSI_TENANT: string;
31
+ };
32
+ export interface ICreateRevisionKeysParams {
33
+ id: string;
34
+ tenant: string;
35
+ version: number;
36
+ }
37
+ export declare const createEntryRevisionKeys: (params: ICreateRevisionKeysParams) => {
38
+ PK: string;
39
+ SK: string;
40
+ TYPE: string;
41
+ GSI_TENANT: string;
42
+ };