@webiny/api-headless-cms-ddb-es 0.0.0-unstable.a4637c5ce6 → 0.0.0-unstable.a4f3e4ea8b

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 (436) hide show
  1. package/README.md +6 -30
  2. package/configurations.d.ts +18 -15
  3. package/configurations.js +33 -45
  4. package/configurations.js.map +1 -1
  5. package/definitions/entry.d.ts +4 -6
  6. package/definitions/entry.js +8 -179
  7. package/definitions/entry.js.map +1 -1
  8. package/definitions/group.d.ts +6 -7
  9. package/definitions/group.js +8 -63
  10. package/definitions/group.js.map +1 -1
  11. package/definitions/model.d.ts +6 -7
  12. package/definitions/model.js +8 -107
  13. package/definitions/model.js.map +1 -1
  14. package/definitions/types.d.ts +65 -0
  15. package/definitions/types.js +0 -0
  16. package/elasticsearch/createElasticsearchIndex.d.ts +5 -5
  17. package/elasticsearch/createElasticsearchIndex.js +41 -36
  18. package/elasticsearch/createElasticsearchIndex.js.map +1 -1
  19. package/elasticsearch/deleteElasticsearchIndex.d.ts +5 -3
  20. package/elasticsearch/deleteElasticsearchIndex.js +19 -34
  21. package/elasticsearch/deleteElasticsearchIndex.js.map +1 -1
  22. package/exports/api/cms/opensearch.d.ts +9 -0
  23. package/exports/api/cms/opensearch.js +9 -0
  24. package/feature.d.ts +1 -0
  25. package/feature.js +201 -0
  26. package/feature.js.map +1 -0
  27. package/features/CmsEntryOpenSearchBodyModifier/abstractions.d.ts +16 -0
  28. package/features/CmsEntryOpenSearchBodyModifier/abstractions.js +5 -0
  29. package/features/CmsEntryOpenSearchBodyModifier/abstractions.js.map +1 -0
  30. package/features/CmsEntryOpenSearchBodyModifier/index.d.ts +1 -0
  31. package/features/CmsEntryOpenSearchBodyModifier/index.js +1 -0
  32. package/features/CmsEntryOpenSearchFieldIndex/CmsEntryOpenSearchFieldIndexRegistry.d.ts +14 -0
  33. package/features/CmsEntryOpenSearchFieldIndex/CmsEntryOpenSearchFieldIndexRegistry.js +42 -0
  34. package/features/CmsEntryOpenSearchFieldIndex/CmsEntryOpenSearchFieldIndexRegistry.js.map +1 -0
  35. package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndex.d.ts +32 -0
  36. package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndex.js +5 -0
  37. package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndex.js.map +1 -0
  38. package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndexRegistry.d.ts +11 -0
  39. package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndexRegistry.js +5 -0
  40. package/features/CmsEntryOpenSearchFieldIndex/abstractions/CmsEntryOpenSearchFieldIndexRegistry.js.map +1 -0
  41. package/features/CmsEntryOpenSearchFieldIndex/constants.d.ts +1 -0
  42. package/features/CmsEntryOpenSearchFieldIndex/constants.js +4 -0
  43. package/features/CmsEntryOpenSearchFieldIndex/constants.js.map +1 -0
  44. package/features/CmsEntryOpenSearchFieldIndex/feature.d.ts +4 -0
  45. package/features/CmsEntryOpenSearchFieldIndex/feature.js +29 -0
  46. package/features/CmsEntryOpenSearchFieldIndex/feature.js.map +1 -0
  47. package/features/CmsEntryOpenSearchFieldIndex/fields/DateTimeFieldIndex.d.ts +11 -0
  48. package/features/CmsEntryOpenSearchFieldIndex/fields/DateTimeFieldIndex.js +60 -0
  49. package/features/CmsEntryOpenSearchFieldIndex/fields/DateTimeFieldIndex.js.map +1 -0
  50. package/features/CmsEntryOpenSearchFieldIndex/fields/DefaultFieldIndex.d.ts +13 -0
  51. package/features/CmsEntryOpenSearchFieldIndex/fields/DefaultFieldIndex.js +33 -0
  52. package/features/CmsEntryOpenSearchFieldIndex/fields/DefaultFieldIndex.js.map +1 -0
  53. package/features/CmsEntryOpenSearchFieldIndex/fields/JsonFieldIndex.d.ts +10 -0
  54. package/features/CmsEntryOpenSearchFieldIndex/fields/JsonFieldIndex.js +21 -0
  55. package/features/CmsEntryOpenSearchFieldIndex/fields/JsonFieldIndex.js.map +1 -0
  56. package/features/CmsEntryOpenSearchFieldIndex/fields/LongTextFieldIndex.d.ts +10 -0
  57. package/features/CmsEntryOpenSearchFieldIndex/fields/LongTextFieldIndex.js +22 -0
  58. package/features/CmsEntryOpenSearchFieldIndex/fields/LongTextFieldIndex.js.map +1 -0
  59. package/features/CmsEntryOpenSearchFieldIndex/fields/NumberFieldIndex.d.ts +11 -0
  60. package/features/CmsEntryOpenSearchFieldIndex/fields/NumberFieldIndex.js +32 -0
  61. package/features/CmsEntryOpenSearchFieldIndex/fields/NumberFieldIndex.js.map +1 -0
  62. package/features/CmsEntryOpenSearchFieldIndex/fields/ObjectFieldIndex.d.ts +12 -0
  63. package/features/CmsEntryOpenSearchFieldIndex/fields/ObjectFieldIndex.js +116 -0
  64. package/features/CmsEntryOpenSearchFieldIndex/fields/ObjectFieldIndex.js.map +1 -0
  65. package/features/CmsEntryOpenSearchFieldIndex/fields/RichTextFieldIndex.d.ts +10 -0
  66. package/features/CmsEntryOpenSearchFieldIndex/fields/RichTextFieldIndex.js +21 -0
  67. package/features/CmsEntryOpenSearchFieldIndex/fields/RichTextFieldIndex.js.map +1 -0
  68. package/features/CmsEntryOpenSearchFieldIndex/fields/TextCompressedFieldIndex.d.ts +15 -0
  69. package/features/CmsEntryOpenSearchFieldIndex/fields/TextCompressedFieldIndex.js +40 -0
  70. package/features/CmsEntryOpenSearchFieldIndex/fields/TextCompressedFieldIndex.js.map +1 -0
  71. package/features/CmsEntryOpenSearchFieldIndex/fields/TextEncryptedFieldIndex.d.ts +15 -0
  72. package/features/CmsEntryOpenSearchFieldIndex/fields/TextEncryptedFieldIndex.js +40 -0
  73. package/features/CmsEntryOpenSearchFieldIndex/fields/TextEncryptedFieldIndex.js.map +1 -0
  74. package/features/CmsEntryOpenSearchFieldIndex/index.d.ts +3 -0
  75. package/features/CmsEntryOpenSearchFieldIndex/index.js +3 -0
  76. package/features/CmsEntryOpenSearchFilter/CmsEntryOpenSearchFilterRegistry.d.ts +11 -0
  77. package/features/CmsEntryOpenSearchFilter/CmsEntryOpenSearchFilterRegistry.js +36 -0
  78. package/features/CmsEntryOpenSearchFilter/CmsEntryOpenSearchFilterRegistry.js.map +1 -0
  79. package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilter.d.ts +37 -0
  80. package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilter.js +5 -0
  81. package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilter.js.map +1 -0
  82. package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilterRegistry.d.ts +9 -0
  83. package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilterRegistry.js +5 -0
  84. package/features/CmsEntryOpenSearchFilter/abstractions/CmsEntryOpenSearchFilterRegistry.js.map +1 -0
  85. package/features/CmsEntryOpenSearchFilter/constants.d.ts +1 -0
  86. package/features/CmsEntryOpenSearchFilter/constants.js +4 -0
  87. package/features/CmsEntryOpenSearchFilter/constants.js.map +1 -0
  88. package/features/CmsEntryOpenSearchFilter/feature.d.ts +4 -0
  89. package/features/CmsEntryOpenSearchFilter/feature.js +17 -0
  90. package/features/CmsEntryOpenSearchFilter/feature.js.map +1 -0
  91. package/features/CmsEntryOpenSearchFilter/fields/DefaultFilter.d.ts +9 -0
  92. package/features/CmsEntryOpenSearchFilter/fields/DefaultFilter.js +26 -0
  93. package/features/CmsEntryOpenSearchFilter/fields/DefaultFilter.js.map +1 -0
  94. package/features/CmsEntryOpenSearchFilter/fields/ObjectFilter.d.ts +9 -0
  95. package/features/CmsEntryOpenSearchFilter/fields/ObjectFilter.js +43 -0
  96. package/features/CmsEntryOpenSearchFilter/fields/ObjectFilter.js.map +1 -0
  97. package/features/CmsEntryOpenSearchFilter/fields/RefFilter.d.ts +9 -0
  98. package/features/CmsEntryOpenSearchFilter/fields/RefFilter.js +36 -0
  99. package/features/CmsEntryOpenSearchFilter/fields/RefFilter.js.map +1 -0
  100. package/features/CmsEntryOpenSearchFilter/index.d.ts +3 -0
  101. package/features/CmsEntryOpenSearchFilter/index.js +3 -0
  102. package/features/CmsEntryOpenSearchFullTextSearch/abstractions.d.ts +20 -0
  103. package/features/CmsEntryOpenSearchFullTextSearch/abstractions.js +5 -0
  104. package/features/CmsEntryOpenSearchFullTextSearch/abstractions.js.map +1 -0
  105. package/features/CmsEntryOpenSearchFullTextSearch/index.d.ts +1 -0
  106. package/features/CmsEntryOpenSearchFullTextSearch/index.js +1 -0
  107. package/features/CmsEntryOpenSearchQueryModifier/abstractions.d.ts +16 -0
  108. package/features/CmsEntryOpenSearchQueryModifier/abstractions.js +5 -0
  109. package/features/CmsEntryOpenSearchQueryModifier/abstractions.js.map +1 -0
  110. package/features/CmsEntryOpenSearchQueryModifier/index.d.ts +1 -0
  111. package/features/CmsEntryOpenSearchQueryModifier/index.js +1 -0
  112. package/features/CmsEntryOpenSearchSortModifier/abstractions.d.ts +15 -0
  113. package/features/CmsEntryOpenSearchSortModifier/abstractions.js +5 -0
  114. package/features/CmsEntryOpenSearchSortModifier/abstractions.js.map +1 -0
  115. package/features/CmsEntryOpenSearchSortModifier/index.d.ts +1 -0
  116. package/features/CmsEntryOpenSearchSortModifier/index.js +1 -0
  117. package/features/CmsEntryOpenSearchValueSearch/CmsEntryOpenSearchValueSearchRegistry.d.ts +12 -0
  118. package/features/CmsEntryOpenSearchValueSearch/CmsEntryOpenSearchValueSearchRegistry.js +31 -0
  119. package/features/CmsEntryOpenSearchValueSearch/CmsEntryOpenSearchValueSearchRegistry.js.map +1 -0
  120. package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearch.d.ts +22 -0
  121. package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearch.js +5 -0
  122. package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearch.js.map +1 -0
  123. package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearchRegistry.d.ts +10 -0
  124. package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearchRegistry.js +5 -0
  125. package/features/CmsEntryOpenSearchValueSearch/abstractions/CmsEntryOpenSearchValueSearchRegistry.js.map +1 -0
  126. package/features/CmsEntryOpenSearchValueSearch/feature.d.ts +4 -0
  127. package/features/CmsEntryOpenSearchValueSearch/feature.js +17 -0
  128. package/features/CmsEntryOpenSearchValueSearch/feature.js.map +1 -0
  129. package/features/CmsEntryOpenSearchValueSearch/fields/RefSearch.d.ts +10 -0
  130. package/features/CmsEntryOpenSearchValueSearch/fields/RefSearch.js +21 -0
  131. package/features/CmsEntryOpenSearchValueSearch/fields/RefSearch.js.map +1 -0
  132. package/features/CmsEntryOpenSearchValueSearch/fields/SearchableJsonSearch.d.ts +10 -0
  133. package/features/CmsEntryOpenSearchValueSearch/fields/SearchableJsonSearch.js +44 -0
  134. package/features/CmsEntryOpenSearchValueSearch/fields/SearchableJsonSearch.js.map +1 -0
  135. package/features/CmsEntryOpenSearchValueSearch/fields/TimeSearch.d.ts +10 -0
  136. package/features/CmsEntryOpenSearchValueSearch/fields/TimeSearch.js +22 -0
  137. package/features/CmsEntryOpenSearchValueSearch/fields/TimeSearch.js.map +1 -0
  138. package/features/CmsEntryOpenSearchValueSearch/index.d.ts +3 -0
  139. package/features/CmsEntryOpenSearchValueSearch/index.js +3 -0
  140. package/features/CmsEntryOpenSearchValuesModifier/abstractions.d.ts +23 -0
  141. package/features/CmsEntryOpenSearchValuesModifier/abstractions.js +5 -0
  142. package/features/CmsEntryOpenSearchValuesModifier/abstractions.js.map +1 -0
  143. package/features/CmsEntryOpenSearchValuesModifier/index.d.ts +1 -0
  144. package/features/CmsEntryOpenSearchValuesModifier/index.js +1 -0
  145. package/features/CmsModelOpenSearchIndex/CmsModelOpenSearchIndexProvider.d.ts +25 -0
  146. package/features/CmsModelOpenSearchIndex/CmsModelOpenSearchIndexProvider.js +36 -0
  147. package/features/CmsModelOpenSearchIndex/CmsModelOpenSearchIndexProvider.js.map +1 -0
  148. package/features/CmsModelOpenSearchIndex/DefaultCmsModelOpenSearchIndex.d.ts +8 -0
  149. package/features/CmsModelOpenSearchIndex/DefaultCmsModelOpenSearchIndex.js +17 -0
  150. package/features/CmsModelOpenSearchIndex/DefaultCmsModelOpenSearchIndex.js.map +1 -0
  151. package/features/CmsModelOpenSearchIndex/abstractions.d.ts +20 -0
  152. package/features/CmsModelOpenSearchIndex/abstractions.js +5 -0
  153. package/features/CmsModelOpenSearchIndex/abstractions.js.map +1 -0
  154. package/features/CmsModelOpenSearchIndex/feature.d.ts +4 -0
  155. package/features/CmsModelOpenSearchIndex/feature.js +13 -0
  156. package/features/CmsModelOpenSearchIndex/feature.js.map +1 -0
  157. package/features/CmsModelOpenSearchIndex/index.d.ts +3 -0
  158. package/features/CmsModelOpenSearchIndex/index.js +3 -0
  159. package/helpers/entryIndexHelpers.d.ts +13 -11
  160. package/helpers/entryIndexHelpers.js +71 -181
  161. package/helpers/entryIndexHelpers.js.map +1 -1
  162. package/helpers/fieldIdentifier.d.ts +1 -1
  163. package/helpers/fieldIdentifier.js +18 -38
  164. package/helpers/fieldIdentifier.js.map +1 -1
  165. package/helpers/index.d.ts +2 -2
  166. package/helpers/index.js +2 -29
  167. package/index.d.ts +1 -3
  168. package/index.js +1 -225
  169. package/operations/entry/dataLoader/DataLoaderCache.d.ts +1 -2
  170. package/operations/entry/dataLoader/DataLoaderCache.js +21 -35
  171. package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -1
  172. package/operations/entry/dataLoader/constants.js +2 -7
  173. package/operations/entry/dataLoader/constants.js.map +1 -1
  174. package/operations/entry/dataLoader/createBatchScheduleFn.js +7 -22
  175. package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -1
  176. package/operations/entry/dataLoader/getAllEntryRevisions.d.ts +3 -3
  177. package/operations/entry/dataLoader/getAllEntryRevisions.js +20 -41
  178. package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -1
  179. package/operations/entry/dataLoader/getLatestRevisionByEntryId.d.ts +3 -3
  180. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +30 -48
  181. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -1
  182. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.d.ts +3 -3
  183. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +30 -48
  184. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -1
  185. package/operations/entry/dataLoader/getRevisionById.d.ts +3 -3
  186. package/operations/entry/dataLoader/getRevisionById.js +36 -58
  187. package/operations/entry/dataLoader/getRevisionById.js.map +1 -1
  188. package/operations/entry/dataLoader/index.d.ts +3 -3
  189. package/operations/entry/dataLoader/index.js +13 -35
  190. package/operations/entry/dataLoader/index.js.map +1 -1
  191. package/operations/entry/dataLoader/types.d.ts +4 -4
  192. package/operations/entry/dataLoader/types.js +0 -7
  193. package/operations/entry/dataLoaders.d.ts +13 -13
  194. package/operations/entry/dataLoaders.js +83 -109
  195. package/operations/entry/dataLoaders.js.map +1 -1
  196. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.d.ts +1 -1
  197. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js +6 -31
  198. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js.map +1 -1
  199. package/operations/entry/elasticsearch/body.d.ts +25 -6
  200. package/operations/entry/elasticsearch/body.js +83 -136
  201. package/operations/entry/elasticsearch/body.js.map +1 -1
  202. package/operations/entry/elasticsearch/fields/createSystemField.d.ts +4 -0
  203. package/operations/entry/elasticsearch/fields/createSystemField.js +9 -0
  204. package/operations/entry/elasticsearch/fields/createSystemField.js.map +1 -0
  205. package/operations/entry/elasticsearch/fields/live.d.ts +2 -0
  206. package/operations/entry/elasticsearch/fields/live.js +50 -0
  207. package/operations/entry/elasticsearch/fields/live.js.map +1 -0
  208. package/operations/entry/elasticsearch/fields/location.d.ts +2 -0
  209. package/operations/entry/elasticsearch/fields/location.js +50 -0
  210. package/operations/entry/elasticsearch/fields/location.js.map +1 -0
  211. package/operations/entry/elasticsearch/fields/state.d.ts +2 -0
  212. package/operations/entry/elasticsearch/fields/state.js +104 -0
  213. package/operations/entry/elasticsearch/fields/state.js.map +1 -0
  214. package/operations/entry/elasticsearch/fields.d.ts +8 -6
  215. package/operations/entry/elasticsearch/fields.js +198 -306
  216. package/operations/entry/elasticsearch/fields.js.map +1 -1
  217. package/operations/entry/elasticsearch/filtering/applyFiltering.d.ts +6 -5
  218. package/operations/entry/elasticsearch/filtering/applyFiltering.js +35 -56
  219. package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +1 -1
  220. package/operations/entry/elasticsearch/filtering/exec.d.ts +13 -8
  221. package/operations/entry/elasticsearch/filtering/exec.js +91 -170
  222. package/operations/entry/elasticsearch/filtering/exec.js.map +1 -1
  223. package/operations/entry/elasticsearch/filtering/index.d.ts +1 -1
  224. package/operations/entry/elasticsearch/filtering/index.js +1 -18
  225. package/operations/entry/elasticsearch/filtering/path.d.ts +4 -3
  226. package/operations/entry/elasticsearch/filtering/path.js +24 -45
  227. package/operations/entry/elasticsearch/filtering/path.js.map +1 -1
  228. package/operations/entry/elasticsearch/filtering/populated.d.ts +2 -2
  229. package/operations/entry/elasticsearch/filtering/populated.js +8 -21
  230. package/operations/entry/elasticsearch/filtering/populated.js.map +1 -1
  231. package/operations/entry/elasticsearch/filtering/values.d.ts +1 -1
  232. package/operations/entry/elasticsearch/filtering/values.js +11 -20
  233. package/operations/entry/elasticsearch/filtering/values.js.map +1 -1
  234. package/operations/entry/elasticsearch/fullTextSearch.d.ts +7 -6
  235. package/operations/entry/elasticsearch/fullTextSearch.js +47 -85
  236. package/operations/entry/elasticsearch/fullTextSearch.js.map +1 -1
  237. package/operations/entry/elasticsearch/fullTextSearchFields.d.ts +4 -4
  238. package/operations/entry/elasticsearch/fullTextSearchFields.js +7 -24
  239. package/operations/entry/elasticsearch/fullTextSearchFields.js.map +1 -1
  240. package/operations/entry/elasticsearch/initialQuery.d.ts +5 -4
  241. package/operations/entry/elasticsearch/initialQuery.js +36 -99
  242. package/operations/entry/elasticsearch/initialQuery.js.map +1 -1
  243. package/operations/entry/elasticsearch/keyword.d.ts +1 -1
  244. package/operations/entry/elasticsearch/keyword.js +14 -33
  245. package/operations/entry/elasticsearch/keyword.js.map +1 -1
  246. package/operations/entry/elasticsearch/plugins/operator.d.ts +4 -5
  247. package/operations/entry/elasticsearch/plugins/operator.js +7 -36
  248. package/operations/entry/elasticsearch/plugins/operator.js.map +1 -1
  249. package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js +6 -11
  250. package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js.map +1 -1
  251. package/operations/entry/elasticsearch/sort.d.ts +9 -6
  252. package/operations/entry/elasticsearch/sort.js +74 -83
  253. package/operations/entry/elasticsearch/sort.js.map +1 -1
  254. package/operations/entry/elasticsearch/transformValueForSearch.d.ts +3 -10
  255. package/operations/entry/elasticsearch/transformValueForSearch.js +9 -29
  256. package/operations/entry/elasticsearch/transformValueForSearch.js.map +1 -1
  257. package/operations/entry/elasticsearch/types.d.ts +4 -14
  258. package/operations/entry/elasticsearch/types.js +0 -7
  259. package/operations/entry/index.d.ts +32 -5
  260. package/operations/entry/index.js +1367 -1845
  261. package/operations/entry/index.js.map +1 -1
  262. package/operations/entry/keys.d.ts +31 -1
  263. package/operations/entry/keys.js +44 -27
  264. package/operations/entry/keys.js.map +1 -1
  265. package/operations/entry/recordType.js +4 -18
  266. package/operations/entry/recordType.js.map +1 -1
  267. package/operations/entry/transformations/convertEntryKeys.d.ts +6 -6
  268. package/operations/entry/transformations/convertEntryKeys.js +21 -34
  269. package/operations/entry/transformations/convertEntryKeys.js.map +1 -1
  270. package/operations/entry/transformations/index.d.ts +22 -18
  271. package/operations/entry/transformations/index.js +87 -123
  272. package/operations/entry/transformations/index.js.map +1 -1
  273. package/operations/entry/transformations/modifyEntryValues.d.ts +30 -35
  274. package/operations/entry/transformations/modifyEntryValues.js +12 -24
  275. package/operations/entry/transformations/modifyEntryValues.js.map +1 -1
  276. package/operations/entry/transformations/transformEntryKeys.d.ts +8 -8
  277. package/operations/entry/transformations/transformEntryKeys.js +14 -24
  278. package/operations/entry/transformations/transformEntryKeys.js.map +1 -1
  279. package/operations/entry/transformations/transformEntryToIndex.d.ts +8 -8
  280. package/operations/entry/transformations/transformEntryToIndex.js +17 -28
  281. package/operations/entry/transformations/transformEntryToIndex.js.map +1 -1
  282. package/operations/group/index.d.ts +7 -6
  283. package/operations/group/index.js +112 -170
  284. package/operations/group/index.js.map +1 -1
  285. package/operations/model/index.d.ts +6 -4
  286. package/operations/model/index.js +111 -175
  287. package/operations/model/index.js.map +1 -1
  288. package/package.json +36 -36
  289. package/tasks/CreateElasticsearchIndexTask.d.ts +16 -0
  290. package/tasks/CreateElasticsearchIndexTask.js +47 -0
  291. package/tasks/CreateElasticsearchIndexTask.js.map +1 -0
  292. package/types.d.ts +24 -135
  293. package/types.js +7 -39
  294. package/types.js.map +1 -1
  295. package/values/NoValueContainer.js +7 -16
  296. package/values/NoValueContainer.js.map +1 -1
  297. package/definitions/entryElasticsearch.d.ts +0 -9
  298. package/definitions/entryElasticsearch.js +0 -41
  299. package/definitions/entryElasticsearch.js.map +0 -1
  300. package/definitions/system.d.ts +0 -9
  301. package/definitions/system.js +0 -42
  302. package/definitions/system.js.map +0 -1
  303. package/definitions/table.d.ts +0 -8
  304. package/definitions/table.js +0 -25
  305. package/definitions/table.js.map +0 -1
  306. package/definitions/tableElasticsearch.d.ts +0 -8
  307. package/definitions/tableElasticsearch.js +0 -25
  308. package/definitions/tableElasticsearch.js.map +0 -1
  309. package/dynamoDb/index.d.ts +0 -3
  310. package/dynamoDb/index.js +0 -16
  311. package/dynamoDb/index.js.map +0 -1
  312. package/dynamoDb/storage/longText.d.ts +0 -10
  313. package/dynamoDb/storage/longText.js +0 -96
  314. package/dynamoDb/storage/longText.js.map +0 -1
  315. package/dynamoDb/storage/richText.d.ts +0 -2
  316. package/dynamoDb/storage/richText.js +0 -59
  317. package/dynamoDb/storage/richText.js.map +0 -1
  318. package/elasticsearch/index.d.ts +0 -2
  319. package/elasticsearch/index.js +0 -13
  320. package/elasticsearch/index.js.map +0 -1
  321. package/elasticsearch/indexing/dateTimeIndexing.d.ts +0 -3
  322. package/elasticsearch/indexing/dateTimeIndexing.js +0 -88
  323. package/elasticsearch/indexing/dateTimeIndexing.js.map +0 -1
  324. package/elasticsearch/indexing/defaultFieldIndexing.d.ts +0 -3
  325. package/elasticsearch/indexing/defaultFieldIndexing.js +0 -54
  326. package/elasticsearch/indexing/defaultFieldIndexing.js.map +0 -1
  327. package/elasticsearch/indexing/index.d.ts +0 -2
  328. package/elasticsearch/indexing/index.js +0 -18
  329. package/elasticsearch/indexing/index.js.map +0 -1
  330. package/elasticsearch/indexing/jsonIndexing.d.ts +0 -2
  331. package/elasticsearch/indexing/jsonIndexing.js +0 -28
  332. package/elasticsearch/indexing/jsonIndexing.js.map +0 -1
  333. package/elasticsearch/indexing/longTextIndexing.d.ts +0 -7
  334. package/elasticsearch/indexing/longTextIndexing.js +0 -42
  335. package/elasticsearch/indexing/longTextIndexing.js.map +0 -1
  336. package/elasticsearch/indexing/numberIndexing.d.ts +0 -3
  337. package/elasticsearch/indexing/numberIndexing.js +0 -41
  338. package/elasticsearch/indexing/numberIndexing.js.map +0 -1
  339. package/elasticsearch/indexing/objectIndexing.d.ts +0 -12
  340. package/elasticsearch/indexing/objectIndexing.js +0 -201
  341. package/elasticsearch/indexing/objectIndexing.js.map +0 -1
  342. package/elasticsearch/indexing/richTextIndexing.d.ts +0 -3
  343. package/elasticsearch/indexing/richTextIndexing.js +0 -31
  344. package/elasticsearch/indexing/richTextIndexing.js.map +0 -1
  345. package/elasticsearch/indices/base.d.ts +0 -2
  346. package/elasticsearch/indices/base.js +0 -13
  347. package/elasticsearch/indices/base.js.map +0 -1
  348. package/elasticsearch/indices/index.d.ts +0 -1
  349. package/elasticsearch/indices/index.js +0 -14
  350. package/elasticsearch/indices/index.js.map +0 -1
  351. package/elasticsearch/indices/japanese.d.ts +0 -2
  352. package/elasticsearch/indices/japanese.js +0 -14
  353. package/elasticsearch/indices/japanese.js.map +0 -1
  354. package/elasticsearch/search/index.d.ts +0 -3
  355. package/elasticsearch/search/index.js +0 -13
  356. package/elasticsearch/search/index.js.map +0 -1
  357. package/elasticsearch/search/refSearch.d.ts +0 -2
  358. package/elasticsearch/search/refSearch.js +0 -31
  359. package/elasticsearch/search/refSearch.js.map +0 -1
  360. package/elasticsearch/search/searchableJson.d.ts +0 -2
  361. package/elasticsearch/search/searchableJson.js +0 -60
  362. package/elasticsearch/search/searchableJson.js.map +0 -1
  363. package/elasticsearch/search/timeSearch.d.ts +0 -2
  364. package/elasticsearch/search/timeSearch.js +0 -27
  365. package/elasticsearch/search/timeSearch.js.map +0 -1
  366. package/helpers/index.js.map +0 -1
  367. package/index.js.map +0 -1
  368. package/operations/entry/dataLoader/types.js.map +0 -1
  369. package/operations/entry/elasticsearch/filtering/index.js.map +0 -1
  370. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.d.ts +0 -2
  371. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js +0 -30
  372. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js.map +0 -1
  373. package/operations/entry/elasticsearch/filtering/plugins/index.d.ts +0 -1
  374. package/operations/entry/elasticsearch/filtering/plugins/index.js +0 -15
  375. package/operations/entry/elasticsearch/filtering/plugins/index.js.map +0 -1
  376. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.d.ts +0 -2
  377. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js +0 -69
  378. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js.map +0 -1
  379. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.d.ts +0 -2
  380. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js +0 -57
  381. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js.map +0 -1
  382. package/operations/entry/elasticsearch/logIgnoredEsResponseError.d.ts +0 -9
  383. package/operations/entry/elasticsearch/logIgnoredEsResponseError.js +0 -26
  384. package/operations/entry/elasticsearch/logIgnoredEsResponseError.js.map +0 -1
  385. package/operations/entry/elasticsearch/plugins/bodyModifier.d.ts +0 -9
  386. package/operations/entry/elasticsearch/plugins/bodyModifier.js +0 -18
  387. package/operations/entry/elasticsearch/plugins/bodyModifier.js.map +0 -1
  388. package/operations/entry/elasticsearch/plugins/queryModifier.d.ts +0 -9
  389. package/operations/entry/elasticsearch/plugins/queryModifier.js +0 -18
  390. package/operations/entry/elasticsearch/plugins/queryModifier.js.map +0 -1
  391. package/operations/entry/elasticsearch/plugins/search.d.ts +0 -7
  392. package/operations/entry/elasticsearch/plugins/search.js +0 -26
  393. package/operations/entry/elasticsearch/plugins/search.js.map +0 -1
  394. package/operations/entry/elasticsearch/plugins/sortModifier.d.ts +0 -9
  395. package/operations/entry/elasticsearch/plugins/sortModifier.js +0 -18
  396. package/operations/entry/elasticsearch/plugins/sortModifier.js.map +0 -1
  397. package/operations/entry/elasticsearch/types.js.map +0 -1
  398. package/operations/system/index.d.ts +0 -6
  399. package/operations/system/index.js +0 -94
  400. package/operations/system/index.js.map +0 -1
  401. package/operations/system/indexes.d.ts +0 -10
  402. package/operations/system/indexes.js +0 -41
  403. package/operations/system/indexes.js.map +0 -1
  404. package/plugins/CmsElasticsearchModelFieldPlugin.d.ts +0 -69
  405. package/plugins/CmsElasticsearchModelFieldPlugin.js +0 -52
  406. package/plugins/CmsElasticsearchModelFieldPlugin.js.map +0 -1
  407. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.d.ts +0 -22
  408. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js +0 -21
  409. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js.map +0 -1
  410. package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.d.ts +0 -23
  411. package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js +0 -27
  412. package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js.map +0 -1
  413. package/plugins/CmsEntryElasticsearchIndexPlugin.d.ts +0 -4
  414. package/plugins/CmsEntryElasticsearchIndexPlugin.js +0 -13
  415. package/plugins/CmsEntryElasticsearchIndexPlugin.js.map +0 -1
  416. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.d.ts +0 -32
  417. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js +0 -40
  418. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js.map +0 -1
  419. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.d.ts +0 -19
  420. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js +0 -21
  421. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js.map +0 -1
  422. package/plugins/CmsEntryElasticsearchSortModifierPlugin.d.ts +0 -19
  423. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js +0 -21
  424. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js.map +0 -1
  425. package/plugins/CmsEntryElasticsearchValuesModifier.d.ts +0 -33
  426. package/plugins/CmsEntryElasticsearchValuesModifier.js +0 -50
  427. package/plugins/CmsEntryElasticsearchValuesModifier.js.map +0 -1
  428. package/plugins/CmsEntryFilterPlugin.d.ts +0 -49
  429. package/plugins/CmsEntryFilterPlugin.js +0 -22
  430. package/plugins/CmsEntryFilterPlugin.js.map +0 -1
  431. package/plugins/index.d.ts +0 -8
  432. package/plugins/index.js +0 -95
  433. package/plugins/index.js.map +0 -1
  434. package/tasks/createIndexTaskPlugin.d.ts +0 -2
  435. package/tasks/createIndexTaskPlugin.js +0 -67
  436. package/tasks/createIndexTaskPlugin.js.map +0 -1
package/index.js CHANGED
@@ -1,225 +1 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- var _exportNames = {
8
- createStorageOperations: true
9
- };
10
- exports.createStorageOperations = void 0;
11
- var _filters = _interopRequireDefault(require("@webiny/db-dynamodb/plugins/filters"));
12
- var _elasticsearch = _interopRequireDefault(require("./elasticsearch"));
13
- var _dynamoDb = _interopRequireDefault(require("./dynamoDb"));
14
- var _system = require("./operations/system");
15
- var _model = require("./operations/model");
16
- var _entry = require("./operations/entry");
17
- var _types = require("./types");
18
- var _table = require("./definitions/table");
19
- var _tableElasticsearch = require("./definitions/tableElasticsearch");
20
- var _group = require("./definitions/group");
21
- var _model2 = require("./definitions/model");
22
- var _entry2 = require("./definitions/entry");
23
- var _entryElasticsearch = require("./definitions/entryElasticsearch");
24
- var _system2 = require("./definitions/system");
25
- var _createElasticsearchIndex = require("./elasticsearch/createElasticsearchIndex");
26
- var _plugins = require("@webiny/plugins");
27
- var _group2 = require("./operations/group");
28
- var _apiElasticsearch = require("@webiny/api-elasticsearch");
29
- var _indices = require("./elasticsearch/indices");
30
- var _deleteElasticsearchIndex = require("./elasticsearch/deleteElasticsearchIndex");
31
- var _plugins2 = require("./plugins");
32
- Object.keys(_plugins2).forEach(function (key) {
33
- if (key === "default" || key === "__esModule") return;
34
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
35
- if (key in exports && exports[key] === _plugins2[key]) return;
36
- Object.defineProperty(exports, key, {
37
- enumerable: true,
38
- get: function () {
39
- return _plugins2[key];
40
- }
41
- });
42
- });
43
- var _plugins3 = require("./operations/entry/elasticsearch/filtering/plugins");
44
- var _CmsEntryFilterPlugin = require("./plugins/CmsEntryFilterPlugin");
45
- var _apiHeadlessCms = require("@webiny/api-headless-cms");
46
- var _indexes = require("./operations/system/indexes");
47
- var _createIndexTaskPlugin = require("./tasks/createIndexTaskPlugin");
48
- var _api = require("@webiny/api");
49
- const createStorageOperations = params => {
50
- const {
51
- attributes,
52
- table,
53
- esTable,
54
- documentClient,
55
- elasticsearch,
56
- plugins: userPlugins
57
- } = params;
58
- const tableInstance = (0, _table.createTable)({
59
- table,
60
- documentClient
61
- });
62
- const tableElasticsearchInstance = (0, _tableElasticsearch.createElasticsearchTable)({
63
- table: esTable,
64
- documentClient
65
- });
66
- const entities = {
67
- system: (0, _system2.createSystemEntity)({
68
- entityName: _types.ENTITIES.SYSTEM,
69
- table: tableInstance,
70
- attributes: attributes ? attributes[_types.ENTITIES.SYSTEM] : {}
71
- }),
72
- groups: (0, _group.createGroupEntity)({
73
- entityName: _types.ENTITIES.GROUPS,
74
- table: tableInstance,
75
- attributes: attributes ? attributes[_types.ENTITIES.GROUPS] : {}
76
- }),
77
- models: (0, _model2.createModelEntity)({
78
- entityName: _types.ENTITIES.MODELS,
79
- table: tableInstance,
80
- attributes: attributes ? attributes[_types.ENTITIES.MODELS] : {}
81
- }),
82
- entries: (0, _entry2.createEntryEntity)({
83
- entityName: _types.ENTITIES.ENTRIES,
84
- table: tableInstance,
85
- attributes: attributes ? attributes[_types.ENTITIES.ENTRIES] : {}
86
- }),
87
- entriesEs: (0, _entryElasticsearch.createEntryElasticsearchEntity)({
88
- entityName: _types.ENTITIES.ENTRIES_ES,
89
- table: tableElasticsearchInstance,
90
- attributes: attributes ? attributes[_types.ENTITIES.ENTRIES_ES] : {}
91
- })
92
- };
93
- const plugins = new _plugins.PluginsContainer([
94
- /**
95
- * DynamoDB filter plugins for the where conditions.
96
- */
97
- (0, _filters.default)(),
98
- /**
99
- * Field plugins for DynamoDB.
100
- */
101
- (0, _dynamoDb.default)(),
102
- /**
103
- * Field plugins for Elasticsearch.
104
- */
105
- (0, _elasticsearch.default)(),
106
- /**
107
- * Built-in Elasticsearch index templates.
108
- */
109
- (0, _indices.elasticsearchIndexPlugins)(),
110
- /**
111
- * Filter plugins used to apply filtering from where conditions to Elasticsearch query.
112
- */
113
- (0, _plugins3.createFilterPlugins)(),
114
- /**
115
- * User defined custom plugins.
116
- * They are at the end because we can then override existing plugins.
117
- */
118
- ...(userPlugins || [])]);
119
- const entries = (0, _entry.createEntriesStorageOperations)({
120
- entity: entities.entries,
121
- esEntity: entities.entriesEs,
122
- plugins,
123
- elasticsearch
124
- });
125
- return {
126
- name: "dynamodb:elasticsearch",
127
- beforeInit: async context => {
128
- context.db.registry.register({
129
- item: entities.entries,
130
- app: "cms",
131
- tags: ["regular", entities.entries.name]
132
- });
133
- context.db.registry.register({
134
- item: entities.entriesEs,
135
- app: "cms",
136
- tags: ["es", entities.entriesEs.name]
137
- });
138
- /**
139
- * Attach the elasticsearch into context if it is not already attached.
140
- */
141
- if (!context.elasticsearch) {
142
- context.elasticsearch = elasticsearch;
143
- }
144
- /**
145
- * Pass the plugins to the parent context.
146
- */
147
- context.plugins.register([(0, _dynamoDb.default)(), (0, _createIndexTaskPlugin.createIndexTaskPluginTest)(), (0, _indices.elasticsearchIndexPlugins)()]);
148
- /**
149
- * We need to fetch all the plugin types in the list from the main container.
150
- * This way we do not need to register plugins in the storage plugins contains.
151
- */
152
- const types = [_apiElasticsearch.ElasticsearchQueryBuilderOperatorPlugin.type,
153
- // Headless CMS
154
- "cms-model-field-to-graphql", _CmsEntryFilterPlugin.CmsEntryFilterPlugin.type, _plugins2.CmsEntryElasticsearchBodyModifierPlugin.type, _plugins2.CmsEntryElasticsearchFullTextSearchPlugin.type, _plugins2.CmsEntryElasticsearchIndexPlugin.type, _plugins2.CmsEntryElasticsearchQueryBuilderValueSearchPlugin.type, _plugins2.CmsEntryElasticsearchQueryModifierPlugin.type, _plugins2.CmsEntryElasticsearchSortModifierPlugin.type, _plugins2.CmsElasticsearchModelFieldPlugin.type, _apiHeadlessCms.StorageOperationsCmsModelPlugin.type, _apiHeadlessCms.StorageTransformPlugin.type, _plugins2.CmsEntryElasticsearchValuesModifier.type, _api.CompressorPlugin.type];
155
- for (const type of types) {
156
- plugins.mergeByType(context.plugins, type);
157
- }
158
- entries.dataLoaders.clearAll();
159
- },
160
- init: async context => {
161
- /**
162
- * We need to create indexes on before model create and on clone (create from).
163
- * Other apps create indexes on locale creation.
164
- */
165
- await (0, _indexes.createElasticsearchIndexesOnLocaleAfterCreate)({
166
- context,
167
- client: elasticsearch,
168
- plugins
169
- });
170
- context.cms.onModelBeforeCreate.subscribe(async ({
171
- model
172
- }) => {
173
- await (0, _createElasticsearchIndex.createElasticsearchIndex)({
174
- client: elasticsearch,
175
- model,
176
- plugins
177
- });
178
- });
179
- context.cms.onModelBeforeCreateFrom.subscribe(async ({
180
- model
181
- }) => {
182
- await (0, _createElasticsearchIndex.createElasticsearchIndex)({
183
- client: elasticsearch,
184
- model,
185
- plugins
186
- });
187
- });
188
- context.cms.onModelAfterDelete.subscribe(async ({
189
- model
190
- }) => {
191
- await (0, _deleteElasticsearchIndex.deleteElasticsearchIndex)({
192
- client: elasticsearch,
193
- model
194
- });
195
- });
196
- context.cms.onModelInitialize.subscribe(async ({
197
- model
198
- }) => {
199
- await (0, _createElasticsearchIndex.createElasticsearchIndex)({
200
- client: elasticsearch,
201
- model,
202
- plugins
203
- });
204
- });
205
- },
206
- getEntities: () => entities,
207
- getTable: () => tableInstance,
208
- getEsTable: () => tableElasticsearchInstance,
209
- system: (0, _system.createSystemStorageOperations)({
210
- entity: entities.system
211
- }),
212
- groups: (0, _group2.createGroupsStorageOperations)({
213
- entity: entities.groups,
214
- plugins
215
- }),
216
- models: (0, _model.createModelsStorageOperations)({
217
- entity: entities.models,
218
- elasticsearch
219
- }),
220
- entries
221
- };
222
- };
223
- exports.createStorageOperations = createStorageOperations;
224
-
225
- //# sourceMappingURL=index.js.map
1
+ export { registerCmsOpenSearchStorageOperations } from "./feature.js";
@@ -2,11 +2,10 @@ import type DataLoader from "dataloader";
2
2
  export interface CacheKeyParams {
3
3
  name: string;
4
4
  tenant: string;
5
- locale: string;
5
+ modelId: string;
6
6
  }
7
7
  export interface ClearAllParams {
8
8
  tenant: string;
9
- locale: string;
10
9
  }
11
10
  export declare class DataLoaderCache {
12
11
  private readonly cache;
@@ -1,41 +1,27 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.DataLoaderCache = void 0;
7
1
  class DataLoaderCache {
8
- cache = {};
9
- getDataLoader(params) {
10
- const key = this.createKey(params);
11
- return this.cache[key] || null;
12
- }
13
- setDataLoader(params, dataLoader) {
14
- const key = this.createKey(params);
15
- this.cache[key] = dataLoader;
16
- }
17
- clearAll(params) {
18
- if (!params) {
19
- for (const current in this.cache) {
20
- this.cache[current].clearAll();
21
- }
22
- return;
2
+ getDataLoader(params) {
3
+ const key = this.createKey(params);
4
+ return this.cache[key] || null;
5
+ }
6
+ setDataLoader(params, dataLoader) {
7
+ const key = this.createKey(params);
8
+ this.cache[key] = dataLoader;
9
+ }
10
+ clearAll(params) {
11
+ if (!params) {
12
+ for(const current in this.cache)this.cache[current].clearAll();
13
+ return;
14
+ }
15
+ const key = `${params.tenant}_`;
16
+ for(const current in this.cache)if (false !== current.startsWith(key)) this.cache[current].clearAll();
17
+ }
18
+ createKey(params) {
19
+ return `${params.tenant}_${params.modelId}_${params.name}`;
23
20
  }
24
- const key = this.createKey({
25
- ...params,
26
- name: ""
27
- });
28
- for (const current in this.cache) {
29
- if (current.startsWith(key) === false) {
30
- continue;
31
- }
32
- this.cache[current].clearAll();
21
+ constructor(){
22
+ this.cache = {};
33
23
  }
34
- }
35
- createKey(params) {
36
- return `${params.tenant}_${params.locale}_${params.name}`;
37
- }
38
24
  }
39
- exports.DataLoaderCache = DataLoaderCache;
25
+ export { DataLoaderCache };
40
26
 
41
27
  //# sourceMappingURL=DataLoaderCache.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["DataLoaderCache","cache","getDataLoader","params","key","createKey","setDataLoader","dataLoader","clearAll","current","name","startsWith","tenant","locale","exports"],"sources":["DataLoaderCache.ts"],"sourcesContent":["import type DataLoader from \"dataloader\";\n\nexport interface CacheKeyParams {\n name: string;\n tenant: string;\n locale: string;\n}\n\nexport interface ClearAllParams {\n tenant: string;\n locale: string;\n}\n\nexport class DataLoaderCache {\n private readonly cache: Record<string, DataLoader<any, any>> = {};\n\n public getDataLoader<I = any, R = any>(params: CacheKeyParams): DataLoader<I, R> | null {\n const key = this.createKey(params);\n\n return this.cache[key] || null;\n }\n\n public setDataLoader(params: CacheKeyParams, dataLoader: DataLoader<any, any>): void {\n const key = this.createKey(params);\n this.cache[key] = dataLoader;\n }\n\n public clearAll(params?: ClearAllParams): void {\n if (!params) {\n for (const current in this.cache) {\n this.cache[current].clearAll();\n }\n return;\n }\n const key = this.createKey({\n ...params,\n name: \"\"\n });\n for (const current in this.cache) {\n if (current.startsWith(key) === false) {\n continue;\n }\n this.cache[current].clearAll();\n }\n }\n\n private createKey(params: CacheKeyParams): string {\n return `${params.tenant}_${params.locale}_${params.name}`;\n }\n}\n"],"mappings":";;;;;;AAaO,MAAMA,eAAe,CAAC;EACRC,KAAK,GAAyC,CAAC,CAAC;EAE1DC,aAAaA,CAAmBC,MAAsB,EAA2B;IACpF,MAAMC,GAAG,GAAG,IAAI,CAACC,SAAS,CAACF,MAAM,CAAC;IAElC,OAAO,IAAI,CAACF,KAAK,CAACG,GAAG,CAAC,IAAI,IAAI;EAClC;EAEOE,aAAaA,CAACH,MAAsB,EAAEI,UAAgC,EAAQ;IACjF,MAAMH,GAAG,GAAG,IAAI,CAACC,SAAS,CAACF,MAAM,CAAC;IAClC,IAAI,CAACF,KAAK,CAACG,GAAG,CAAC,GAAGG,UAAU;EAChC;EAEOC,QAAQA,CAACL,MAAuB,EAAQ;IAC3C,IAAI,CAACA,MAAM,EAAE;MACT,KAAK,MAAMM,OAAO,IAAI,IAAI,CAACR,KAAK,EAAE;QAC9B,IAAI,CAACA,KAAK,CAACQ,OAAO,CAAC,CAACD,QAAQ,CAAC,CAAC;MAClC;MACA;IACJ;IACA,MAAMJ,GAAG,GAAG,IAAI,CAACC,SAAS,CAAC;MACvB,GAAGF,MAAM;MACTO,IAAI,EAAE;IACV,CAAC,CAAC;IACF,KAAK,MAAMD,OAAO,IAAI,IAAI,CAACR,KAAK,EAAE;MAC9B,IAAIQ,OAAO,CAACE,UAAU,CAACP,GAAG,CAAC,KAAK,KAAK,EAAE;QACnC;MACJ;MACA,IAAI,CAACH,KAAK,CAACQ,OAAO,CAAC,CAACD,QAAQ,CAAC,CAAC;IAClC;EACJ;EAEQH,SAASA,CAACF,MAAsB,EAAU;IAC9C,OAAO,GAAGA,MAAM,CAACS,MAAM,IAAIT,MAAM,CAACU,MAAM,IAAIV,MAAM,CAACO,IAAI,EAAE;EAC7D;AACJ;AAACI,OAAA,CAAAd,eAAA,GAAAA,eAAA","ignoreList":[]}
1
+ {"version":3,"file":"operations/entry/dataLoader/DataLoaderCache.js","sources":["../../../../src/operations/entry/dataLoader/DataLoaderCache.ts"],"sourcesContent":["import type DataLoader from \"dataloader\";\n\nexport interface CacheKeyParams {\n name: string;\n tenant: string;\n modelId: string;\n}\n\nexport interface ClearAllParams {\n tenant: string;\n}\n\nexport class DataLoaderCache {\n private readonly cache: Record<string, DataLoader<any, any>> = {};\n\n public getDataLoader<I = any, R = any>(params: CacheKeyParams): DataLoader<I, R> | null {\n const key = this.createKey(params);\n\n return this.cache[key] || null;\n }\n\n public setDataLoader(params: CacheKeyParams, dataLoader: DataLoader<any, any>): void {\n const key = this.createKey(params);\n this.cache[key] = dataLoader;\n }\n\n public clearAll(params?: ClearAllParams): void {\n if (!params) {\n for (const current in this.cache) {\n this.cache[current].clearAll();\n }\n return;\n }\n const key = `${params.tenant}_`;\n for (const current in this.cache) {\n if (current.startsWith(key) === false) {\n continue;\n }\n this.cache[current].clearAll();\n }\n }\n\n private createKey(params: CacheKeyParams): string {\n return `${params.tenant}_${params.modelId}_${params.name}`;\n }\n}\n"],"names":["DataLoaderCache","params","key","dataLoader","current"],"mappings":"AAYO,MAAMA;IAGF,cAAgCC,MAAsB,EAA2B;QACpF,MAAMC,MAAM,IAAI,CAAC,SAAS,CAACD;QAE3B,OAAO,IAAI,CAAC,KAAK,CAACC,IAAI,IAAI;IAC9B;IAEO,cAAcD,MAAsB,EAAEE,UAAgC,EAAQ;QACjF,MAAMD,MAAM,IAAI,CAAC,SAAS,CAACD;QAC3B,IAAI,CAAC,KAAK,CAACC,IAAI,GAAGC;IACtB;IAEO,SAASF,MAAuB,EAAQ;QAC3C,IAAI,CAACA,QAAQ;YACT,IAAK,MAAMG,WAAW,IAAI,CAAC,KAAK,CAC5B,IAAI,CAAC,KAAK,CAACA,QAAQ,CAAC,QAAQ;YAEhC;QACJ;QACA,MAAMF,MAAM,GAAGD,OAAO,MAAM,CAAC,CAAC,CAAC;QAC/B,IAAK,MAAMG,WAAW,IAAI,CAAC,KAAK,CAC5B,IAAIA,AAA4B,UAA5BA,QAAQ,UAAU,CAACF,MAGvB,IAAI,CAAC,KAAK,CAACE,QAAQ,CAAC,QAAQ;IAEpC;IAEQ,UAAUH,MAAsB,EAAU;QAC9C,OAAO,GAAGA,OAAO,MAAM,CAAC,CAAC,EAAEA,OAAO,OAAO,CAAC,CAAC,EAAEA,OAAO,IAAI,EAAE;IAC9D;;aA/BiB,KAAK,GAAyC,CAAC;;AAgCpE"}
@@ -1,10 +1,5 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.CMS_ENTRY_BATCH_SCHEDULE_WAIT = void 0;
7
1
  const batchScheduleWaitEnv = Number(process.env.WEBINY_API_CMS_ENTRY_BATCH_SCHEDULE_WAIT || "0");
8
- const CMS_ENTRY_BATCH_SCHEDULE_WAIT = exports.CMS_ENTRY_BATCH_SCHEDULE_WAIT = isNaN(batchScheduleWaitEnv) ? 0 : batchScheduleWaitEnv;
2
+ const CMS_ENTRY_BATCH_SCHEDULE_WAIT = isNaN(batchScheduleWaitEnv) ? 0 : batchScheduleWaitEnv;
3
+ export { CMS_ENTRY_BATCH_SCHEDULE_WAIT };
9
4
 
10
5
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["batchScheduleWaitEnv","Number","process","env","WEBINY_API_CMS_ENTRY_BATCH_SCHEDULE_WAIT","CMS_ENTRY_BATCH_SCHEDULE_WAIT","exports","isNaN"],"sources":["constants.ts"],"sourcesContent":["const batchScheduleWaitEnv = Number(process.env.WEBINY_API_CMS_ENTRY_BATCH_SCHEDULE_WAIT || \"0\");\nexport const CMS_ENTRY_BATCH_SCHEDULE_WAIT = isNaN(batchScheduleWaitEnv) ? 0 : batchScheduleWaitEnv;\n"],"mappings":";;;;;;AAAA,MAAMA,oBAAoB,GAAGC,MAAM,CAACC,OAAO,CAACC,GAAG,CAACC,wCAAwC,IAAI,GAAG,CAAC;AACzF,MAAMC,6BAA6B,GAAAC,OAAA,CAAAD,6BAAA,GAAGE,KAAK,CAACP,oBAAoB,CAAC,GAAG,CAAC,GAAGA,oBAAoB","ignoreList":[]}
1
+ {"version":3,"file":"operations/entry/dataLoader/constants.js","sources":["../../../../src/operations/entry/dataLoader/constants.ts"],"sourcesContent":["const batchScheduleWaitEnv = Number(process.env.WEBINY_API_CMS_ENTRY_BATCH_SCHEDULE_WAIT || \"0\");\nexport const CMS_ENTRY_BATCH_SCHEDULE_WAIT = isNaN(batchScheduleWaitEnv) ? 0 : batchScheduleWaitEnv;\n"],"names":["batchScheduleWaitEnv","Number","process","CMS_ENTRY_BATCH_SCHEDULE_WAIT","isNaN"],"mappings":"AAAA,MAAMA,uBAAuBC,OAAOC,QAAQ,GAAG,CAAC,wCAAwC,IAAI;AACrF,MAAMC,gCAAgCC,MAAMJ,wBAAwB,IAAIA"}
@@ -1,25 +1,10 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createBatchScheduleFn = void 0;
7
- var _constants = require("./constants");
8
- /**
9
- * This is to be used when user wants to wait for a number of milliseconds before the batch is executed.
10
- * Intended to be used internally or for a specific user case.
11
- * Not to be documented and exposed to publish as it can slow the data loading a lot.
12
- *
13
- * https://github.com/graphql/dataloader#batch-scheduling
14
- */
15
- const createBatchScheduleFn = () => {
16
- if (_constants.CMS_ENTRY_BATCH_SCHEDULE_WAIT <= 0) {
17
- return undefined;
18
- }
19
- return callback => {
20
- setTimeout(callback, _constants.CMS_ENTRY_BATCH_SCHEDULE_WAIT);
21
- };
1
+ import { CMS_ENTRY_BATCH_SCHEDULE_WAIT } from "./constants.js";
2
+ const createBatchScheduleFn = ()=>{
3
+ if (CMS_ENTRY_BATCH_SCHEDULE_WAIT <= 0) return;
4
+ return (callback)=>{
5
+ setTimeout(callback, CMS_ENTRY_BATCH_SCHEDULE_WAIT);
6
+ };
22
7
  };
23
- exports.createBatchScheduleFn = createBatchScheduleFn;
8
+ export { createBatchScheduleFn };
24
9
 
25
10
  //# sourceMappingURL=createBatchScheduleFn.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_constants","require","createBatchScheduleFn","CMS_ENTRY_BATCH_SCHEDULE_WAIT","undefined","callback","setTimeout","exports"],"sources":["createBatchScheduleFn.ts"],"sourcesContent":["import { CMS_ENTRY_BATCH_SCHEDULE_WAIT } from \"./constants\";\n\n/**\n * This is to be used when user wants to wait for a number of milliseconds before the batch is executed.\n * Intended to be used internally or for a specific user case.\n * Not to be documented and exposed to publish as it can slow the data loading a lot.\n *\n * https://github.com/graphql/dataloader#batch-scheduling\n */\nexport const createBatchScheduleFn = () => {\n if (CMS_ENTRY_BATCH_SCHEDULE_WAIT <= 0) {\n return undefined;\n }\n return (callback: () => void) => {\n setTimeout(callback, CMS_ENTRY_BATCH_SCHEDULE_WAIT);\n };\n};\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,qBAAqB,GAAGA,CAAA,KAAM;EACvC,IAAIC,wCAA6B,IAAI,CAAC,EAAE;IACpC,OAAOC,SAAS;EACpB;EACA,OAAQC,QAAoB,IAAK;IAC7BC,UAAU,CAACD,QAAQ,EAAEF,wCAA6B,CAAC;EACvD,CAAC;AACL,CAAC;AAACI,OAAA,CAAAL,qBAAA,GAAAA,qBAAA","ignoreList":[]}
1
+ {"version":3,"file":"operations/entry/dataLoader/createBatchScheduleFn.js","sources":["../../../../src/operations/entry/dataLoader/createBatchScheduleFn.ts"],"sourcesContent":["import { CMS_ENTRY_BATCH_SCHEDULE_WAIT } from \"./constants.js\";\n\n/**\n * This is to be used when user wants to wait for a number of milliseconds before the batch is executed.\n * Intended to be used internally or for a specific user case.\n * Not to be documented and exposed to publish as it can slow the data loading a lot.\n *\n * https://github.com/graphql/dataloader#batch-scheduling\n */\nexport const createBatchScheduleFn = () => {\n if (CMS_ENTRY_BATCH_SCHEDULE_WAIT <= 0) {\n return undefined;\n }\n return (callback: () => void) => {\n setTimeout(callback, CMS_ENTRY_BATCH_SCHEDULE_WAIT);\n };\n};\n"],"names":["createBatchScheduleFn","CMS_ENTRY_BATCH_SCHEDULE_WAIT","callback","setTimeout"],"mappings":";AASO,MAAMA,wBAAwB;IACjC,IAAIC,iCAAiC,GACjC;IAEJ,OAAO,CAACC;QACJC,WAAWD,UAAUD;IACzB;AACJ"}
@@ -1,4 +1,4 @@
1
1
  import DataLoader from "dataloader";
2
- import type { CmsStorageEntry } from "@webiny/api-headless-cms/types";
3
- import type { DataLoaderParams } from "./types";
4
- export declare const createGetAllEntryRevisions: (params: DataLoaderParams) => DataLoader<string, CmsStorageEntry[], string>;
2
+ import type { CmsStorageEntry } from "@webiny/api-headless-cms/types/index.js";
3
+ import type { IDataLoaderParams } from "./types.js";
4
+ export declare const createGetAllEntryRevisions: (params: IDataLoaderParams) => DataLoader<string, CmsStorageEntry<import("@webiny/api-headless-cms/types/types.js").CmsEntryValues>[], string>;
@@ -1,45 +1,24 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.createGetAllEntryRevisions = void 0;
8
- var _dataloader = _interopRequireDefault(require("dataloader"));
9
- var _query = require("@webiny/db-dynamodb/utils/query");
10
- var _keys = require("../keys");
11
- var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
12
- var _createBatchScheduleFn = require("./createBatchScheduleFn");
13
- const createGetAllEntryRevisions = params => {
14
- const {
15
- entity,
16
- locale,
17
- tenant
18
- } = params;
19
- return new _dataloader.default(async ids => {
20
- const results = {};
21
- for (const id of ids) {
22
- const queryAllParams = {
23
- entity,
24
- partitionKey: (0, _keys.createPartitionKey)({
25
- tenant,
26
- locale,
27
- id
28
- }),
29
- options: {
30
- beginsWith: "REV#"
31
- }
32
- };
33
- const items = await (0, _query.queryAll)(queryAllParams);
34
- results[id] = (0, _cleanup.cleanupItems)(entity, items);
35
- }
36
- return ids.map(entryId => {
37
- return results[entryId] || [];
1
+ import dataloader from "dataloader";
2
+ import { createPartitionKey } from "../keys.js";
3
+ import { createBatchScheduleFn } from "./createBatchScheduleFn.js";
4
+ const createGetAllEntryRevisions = (params)=>{
5
+ const { entity, tenant, modelId } = params;
6
+ return new dataloader(async (ids)=>{
7
+ const results = {};
8
+ for (const id of ids)results[id] = (await entity.queryAllClean({
9
+ partitionKey: createPartitionKey({
10
+ tenant,
11
+ id
12
+ }),
13
+ options: {
14
+ beginsWith: "REV#"
15
+ }
16
+ })).map((item)=>item.data);
17
+ return ids.map((entryId)=>(results[entryId] || []).filter((item)=>item.modelId === modelId));
18
+ }, {
19
+ batchScheduleFn: createBatchScheduleFn()
38
20
  });
39
- }, {
40
- batchScheduleFn: (0, _createBatchScheduleFn.createBatchScheduleFn)()
41
- });
42
21
  };
43
- exports.createGetAllEntryRevisions = createGetAllEntryRevisions;
22
+ export { createGetAllEntryRevisions };
44
23
 
45
24
  //# sourceMappingURL=getAllEntryRevisions.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_dataloader","_interopRequireDefault","require","_query","_keys","_cleanup","_createBatchScheduleFn","createGetAllEntryRevisions","params","entity","locale","tenant","DataLoader","ids","results","id","queryAllParams","partitionKey","createPartitionKey","options","beginsWith","items","queryAll","cleanupItems","map","entryId","batchScheduleFn","createBatchScheduleFn","exports"],"sources":["getAllEntryRevisions.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport type { CmsStorageEntry } from \"@webiny/api-headless-cms/types\";\nimport type { QueryAllParams } from \"@webiny/db-dynamodb/utils/query\";\nimport { queryAll } from \"@webiny/db-dynamodb/utils/query\";\nimport { createPartitionKey } from \"~/operations/entry/keys\";\nimport { cleanupItems } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport type { DataLoaderParams } from \"./types\";\nimport { createBatchScheduleFn } from \"./createBatchScheduleFn\";\n\nexport const createGetAllEntryRevisions = (params: DataLoaderParams) => {\n const { entity, locale, tenant } = params;\n return new DataLoader<string, CmsStorageEntry[]>(\n async (ids: readonly string[]) => {\n const results: Record<string, CmsStorageEntry[]> = {};\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<CmsStorageEntry>(queryAllParams);\n results[id] = cleanupItems(entity, items);\n }\n\n return ids.map(entryId => {\n return results[entryId] || [];\n });\n },\n {\n batchScheduleFn: createBatchScheduleFn()\n }\n );\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAEA,IAAAI,sBAAA,GAAAJ,OAAA;AAEO,MAAMK,0BAA0B,GAAIC,MAAwB,IAAK;EACpE,MAAM;IAAEC,MAAM;IAAEC,MAAM;IAAEC;EAAO,CAAC,GAAGH,MAAM;EACzC,OAAO,IAAII,mBAAU,CACjB,MAAOC,GAAsB,IAAK;IAC9B,MAAMC,OAA0C,GAAG,CAAC,CAAC;IACrD,KAAK,MAAMC,EAAE,IAAIF,GAAG,EAAE;MAClB,MAAMG,cAA8B,GAAG;QACnCP,MAAM;QACNQ,YAAY,EAAE,IAAAC,wBAAkB,EAAC;UAC7BP,MAAM;UACND,MAAM;UACNK;QACJ,CAAC,CAAC;QACFI,OAAO,EAAE;UACLC,UAAU,EAAE;QAChB;MACJ,CAAC;MACD,MAAMC,KAAK,GAAG,MAAM,IAAAC,eAAQ,EAAkBN,cAAc,CAAC;MAC7DF,OAAO,CAACC,EAAE,CAAC,GAAG,IAAAQ,qBAAY,EAACd,MAAM,EAAEY,KAAK,CAAC;IAC7C;IAEA,OAAOR,GAAG,CAACW,GAAG,CAACC,OAAO,IAAI;MACtB,OAAOX,OAAO,CAACW,OAAO,CAAC,IAAI,EAAE;IACjC,CAAC,CAAC;EACN,CAAC,EACD;IACIC,eAAe,EAAE,IAAAC,4CAAqB,EAAC;EAC3C,CACJ,CAAC;AACL,CAAC;AAACC,OAAA,CAAArB,0BAAA,GAAAA,0BAAA","ignoreList":[]}
1
+ {"version":3,"file":"operations/entry/dataLoader/getAllEntryRevisions.js","sources":["../../../../src/operations/entry/dataLoader/getAllEntryRevisions.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport type { CmsStorageEntry } from \"@webiny/api-headless-cms/types/index.js\";\nimport { createPartitionKey } from \"~/operations/entry/keys.js\";\nimport type { IDataLoaderParams } from \"./types.js\";\nimport { createBatchScheduleFn } from \"./createBatchScheduleFn.js\";\n\nexport const createGetAllEntryRevisions = (params: IDataLoaderParams) => {\n const { entity, tenant, modelId } = params;\n return new DataLoader<string, CmsStorageEntry[]>(\n async ids => {\n const results: Record<string, CmsStorageEntry[]> = {};\n\n for (const id of ids) {\n results[id] = (\n await entity.queryAllClean({\n partitionKey: createPartitionKey({\n tenant,\n id\n }),\n options: {\n beginsWith: \"REV#\"\n }\n })\n ).map(item => {\n return item.data;\n });\n }\n\n return ids.map(entryId => {\n return (results[entryId] || []).filter(item => {\n return item.modelId === modelId;\n });\n });\n },\n {\n batchScheduleFn: createBatchScheduleFn()\n }\n );\n};\n"],"names":["createGetAllEntryRevisions","params","entity","tenant","modelId","DataLoader","ids","results","id","createPartitionKey","item","entryId","createBatchScheduleFn"],"mappings":";;;AAMO,MAAMA,6BAA6B,CAACC;IACvC,MAAM,EAAEC,MAAM,EAAEC,MAAM,EAAEC,OAAO,EAAE,GAAGH;IACpC,OAAO,IAAII,WACP,OAAMC;QACF,MAAMC,UAA6C,CAAC;QAEpD,KAAK,MAAMC,MAAMF,IACbC,OAAO,CAACC,GAAG,GACP,OAAMN,OAAO,aAAa,CAAC;YACvB,cAAcO,mBAAmB;gBAC7BN;gBACAK;YACJ;YACA,SAAS;gBACL,YAAY;YAChB;QACJ,EAAC,EACH,GAAG,CAACE,CAAAA,OACKA,KAAK,IAAI;QAIxB,OAAOJ,IAAI,GAAG,CAACK,CAAAA,UACHJ,AAAAA,CAAAA,OAAO,CAACI,QAAQ,IAAI,EAAC,EAAG,MAAM,CAACD,CAAAA,OAC5BA,KAAK,OAAO,KAAKN;IAGpC,GACA;QACI,iBAAiBQ;IACrB;AAER"}
@@ -1,4 +1,4 @@
1
1
  import DataLoader from "dataloader";
2
- import type { CmsStorageEntry } from "@webiny/api-headless-cms/types";
3
- import type { DataLoaderParams } from "./types";
4
- export declare const createGetLatestRevisionByEntryId: (params: DataLoaderParams) => DataLoader<string, CmsStorageEntry[], string>;
2
+ import type { CmsStorageEntry } from "@webiny/api-headless-cms/types/index.js";
3
+ import type { IDataLoaderParams } from "./types.js";
4
+ export declare const createGetLatestRevisionByEntryId: (params: IDataLoaderParams) => DataLoader<string, CmsStorageEntry<import("@webiny/api-headless-cms/types/types.js").CmsEntryValues>[], string>;
@@ -1,52 +1,34 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.createGetLatestRevisionByEntryId = void 0;
8
- var _dataloader = _interopRequireDefault(require("dataloader"));
9
- var _dbDynamodb = require("@webiny/db-dynamodb");
10
- var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
11
- var _createBatchScheduleFn = require("./createBatchScheduleFn");
12
- var _keys = require("../keys");
13
- const createGetLatestRevisionByEntryId = params => {
14
- const {
15
- entity,
16
- locale,
17
- tenant
18
- } = params;
19
- const latestKey = (0, _keys.createLatestSortKey)();
20
- return new _dataloader.default(async ids => {
21
- const queries = ids.reduce((collection, id) => {
22
- const partitionKey = (0, _keys.createPartitionKey)({
23
- tenant,
24
- locale,
25
- id
26
- });
27
- if (collection[partitionKey]) {
28
- return collection;
29
- }
30
- collection[partitionKey] = entity.getBatch({
31
- PK: partitionKey,
32
- SK: latestKey
33
- });
34
- return collection;
35
- }, {});
36
- const records = await (0, _dbDynamodb.batchReadAll)({
37
- table: entity.table,
38
- items: Object.values(queries)
39
- });
40
- const items = (0, _cleanup.cleanupItems)(entity, records);
41
- return ids.map(entryId => {
42
- return items.filter(item => {
43
- return entryId === item.entryId;
44
- });
1
+ import dataloader from "dataloader";
2
+ import { createBatchScheduleFn } from "./createBatchScheduleFn.js";
3
+ import { createLatestSortKey, createPartitionKey } from "../keys.js";
4
+ const createGetLatestRevisionByEntryId = (params)=>{
5
+ const { entity, tenant, modelId } = params;
6
+ const latestKey = createLatestSortKey();
7
+ return new dataloader(async (ids)=>{
8
+ const reader = entity.createEntityReader();
9
+ const keys = new Set();
10
+ for (const id of ids){
11
+ const partitionKey = createPartitionKey({
12
+ tenant,
13
+ id
14
+ });
15
+ if (!keys.has(partitionKey)) {
16
+ keys.add(partitionKey);
17
+ reader.get({
18
+ PK: partitionKey,
19
+ SK: latestKey
20
+ });
21
+ }
22
+ }
23
+ const items = (await reader.execute()).map((item)=>item.data);
24
+ return ids.map((entryId)=>items.filter((item)=>{
25
+ if (item.modelId !== modelId) return false;
26
+ return entryId === item.entryId;
27
+ }));
28
+ }, {
29
+ batchScheduleFn: createBatchScheduleFn()
45
30
  });
46
- }, {
47
- batchScheduleFn: (0, _createBatchScheduleFn.createBatchScheduleFn)()
48
- });
49
31
  };
50
- exports.createGetLatestRevisionByEntryId = createGetLatestRevisionByEntryId;
32
+ export { createGetLatestRevisionByEntryId };
51
33
 
52
34
  //# sourceMappingURL=getLatestRevisionByEntryId.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_dataloader","_interopRequireDefault","require","_dbDynamodb","_cleanup","_createBatchScheduleFn","_keys","createGetLatestRevisionByEntryId","params","entity","locale","tenant","latestKey","createLatestSortKey","DataLoader","ids","queries","reduce","collection","id","partitionKey","createPartitionKey","getBatch","PK","SK","records","batchReadAll","table","items","Object","values","cleanupItems","map","entryId","filter","item","batchScheduleFn","createBatchScheduleFn","exports"],"sources":["getLatestRevisionByEntryId.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport { batchReadAll } from \"@webiny/db-dynamodb\";\nimport { cleanupItems } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport type { CmsStorageEntry } from \"@webiny/api-headless-cms/types\";\nimport { createBatchScheduleFn } from \"./createBatchScheduleFn\";\nimport { createLatestSortKey, createPartitionKey } from \"~/operations/entry/keys\";\nimport type { DataLoaderParams } from \"./types\";\n\nexport const createGetLatestRevisionByEntryId = (params: DataLoaderParams) => {\n const { entity, locale, tenant } = params;\n\n const latestKey = createLatestSortKey();\n\n return new DataLoader<string, CmsStorageEntry[]>(\n async (ids: readonly string[]) => {\n const queries = ids.reduce<Record<string, ReturnType<typeof entity.getBatch>>>(\n (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 {}\n );\n\n const records = await batchReadAll<CmsStorageEntry>({\n table: entity.table,\n items: Object.values(queries)\n });\n const items = cleanupItems(entity, records);\n\n return ids.map(entryId => {\n return items.filter(item => {\n return entryId === item.entryId;\n });\n });\n },\n {\n batchScheduleFn: createBatchScheduleFn()\n }\n );\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAEA,IAAAG,sBAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AAGO,MAAMK,gCAAgC,GAAIC,MAAwB,IAAK;EAC1E,MAAM;IAAEC,MAAM;IAAEC,MAAM;IAAEC;EAAO,CAAC,GAAGH,MAAM;EAEzC,MAAMI,SAAS,GAAG,IAAAC,yBAAmB,EAAC,CAAC;EAEvC,OAAO,IAAIC,mBAAU,CACjB,MAAOC,GAAsB,IAAK;IAC9B,MAAMC,OAAO,GAAGD,GAAG,CAACE,MAAM,CACtB,CAACC,UAAU,EAAEC,EAAE,KAAK;MAChB,MAAMC,YAAY,GAAG,IAAAC,wBAAkB,EAAC;QACpCV,MAAM;QACND,MAAM;QACNS;MACJ,CAAC,CAAC;MACF,IAAID,UAAU,CAACE,YAAY,CAAC,EAAE;QAC1B,OAAOF,UAAU;MACrB;MACAA,UAAU,CAACE,YAAY,CAAC,GAAGX,MAAM,CAACa,QAAQ,CAAC;QACvCC,EAAE,EAAEH,YAAY;QAChBI,EAAE,EAAEZ;MACR,CAAC,CAAC;MACF,OAAOM,UAAU;IACrB,CAAC,EACD,CAAC,CACL,CAAC;IAED,MAAMO,OAAO,GAAG,MAAM,IAAAC,wBAAY,EAAkB;MAChDC,KAAK,EAAElB,MAAM,CAACkB,KAAK;MACnBC,KAAK,EAAEC,MAAM,CAACC,MAAM,CAACd,OAAO;IAChC,CAAC,CAAC;IACF,MAAMY,KAAK,GAAG,IAAAG,qBAAY,EAACtB,MAAM,EAAEgB,OAAO,CAAC;IAE3C,OAAOV,GAAG,CAACiB,GAAG,CAACC,OAAO,IAAI;MACtB,OAAOL,KAAK,CAACM,MAAM,CAACC,IAAI,IAAI;QACxB,OAAOF,OAAO,KAAKE,IAAI,CAACF,OAAO;MACnC,CAAC,CAAC;IACN,CAAC,CAAC;EACN,CAAC,EACD;IACIG,eAAe,EAAE,IAAAC,4CAAqB,EAAC;EAC3C,CACJ,CAAC;AACL,CAAC;AAACC,OAAA,CAAA/B,gCAAA,GAAAA,gCAAA","ignoreList":[]}
1
+ {"version":3,"file":"operations/entry/dataLoader/getLatestRevisionByEntryId.js","sources":["../../../../src/operations/entry/dataLoader/getLatestRevisionByEntryId.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport type { CmsStorageEntry } from \"@webiny/api-headless-cms/types/index.js\";\nimport { createBatchScheduleFn } from \"./createBatchScheduleFn.js\";\nimport { createLatestSortKey, createPartitionKey } from \"~/operations/entry/keys.js\";\nimport type { IDataLoaderParams } from \"./types.js\";\n\nexport const createGetLatestRevisionByEntryId = (params: IDataLoaderParams) => {\n const { entity, tenant, modelId } = params;\n\n const latestKey = createLatestSortKey();\n\n return new DataLoader<string, CmsStorageEntry[]>(\n async ids => {\n const reader = entity.createEntityReader();\n\n const keys = new Set<string>();\n\n for (const id of ids) {\n const partitionKey = createPartitionKey({\n tenant,\n id\n });\n if (keys.has(partitionKey)) {\n continue;\n }\n keys.add(partitionKey);\n reader.get({\n PK: partitionKey,\n SK: latestKey\n });\n }\n\n const items = (await reader.execute()).map(item => {\n return item.data;\n });\n\n return ids.map(entryId => {\n return items.filter(item => {\n if (item.modelId !== modelId) {\n return false;\n }\n return entryId === item.entryId;\n });\n });\n },\n {\n batchScheduleFn: createBatchScheduleFn()\n }\n );\n};\n"],"names":["createGetLatestRevisionByEntryId","params","entity","tenant","modelId","latestKey","createLatestSortKey","DataLoader","ids","reader","keys","Set","id","partitionKey","createPartitionKey","items","item","entryId","createBatchScheduleFn"],"mappings":";;;AAMO,MAAMA,mCAAmC,CAACC;IAC7C,MAAM,EAAEC,MAAM,EAAEC,MAAM,EAAEC,OAAO,EAAE,GAAGH;IAEpC,MAAMI,YAAYC;IAElB,OAAO,IAAIC,WACP,OAAMC;QACF,MAAMC,SAASP,OAAO,kBAAkB;QAExC,MAAMQ,OAAO,IAAIC;QAEjB,KAAK,MAAMC,MAAMJ,IAAK;YAClB,MAAMK,eAAeC,mBAAmB;gBACpCX;gBACAS;YACJ;YACA,KAAIF,KAAK,GAAG,CAACG;gBAGbH,KAAK,GAAG,CAACG;gBACTJ,OAAO,GAAG,CAAC;oBACP,IAAII;oBACJ,IAAIR;gBACR;;QACJ;QAEA,MAAMU,QAAS,OAAMN,OAAO,OAAO,EAAC,EAAG,GAAG,CAACO,CAAAA,OAChCA,KAAK,IAAI;QAGpB,OAAOR,IAAI,GAAG,CAACS,CAAAA,UACJF,MAAM,MAAM,CAACC,CAAAA;gBAChB,IAAIA,KAAK,OAAO,KAAKZ,SACjB,OAAO;gBAEX,OAAOa,YAAYD,KAAK,OAAO;YACnC;IAER,GACA;QACI,iBAAiBE;IACrB;AAER"}
@@ -1,4 +1,4 @@
1
1
  import DataLoader from "dataloader";
2
- import type { CmsStorageEntry } from "@webiny/api-headless-cms/types";
3
- import type { DataLoaderParams } from "./types";
4
- export declare const createGetPublishedRevisionByEntryId: (params: DataLoaderParams) => DataLoader<string, CmsStorageEntry[], string>;
2
+ import type { CmsStorageEntry } from "@webiny/api-headless-cms/types/index.js";
3
+ import type { IDataLoaderParams } from "./types.js";
4
+ export declare const createGetPublishedRevisionByEntryId: (params: IDataLoaderParams) => DataLoader<string, CmsStorageEntry<import("@webiny/api-headless-cms/types/types.js").CmsEntryValues>[], string>;