@webiny/api-headless-cms-ddb-es 0.0.0-mt-2 → 0.0.0-unstable.06b2ede40f

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 (325) hide show
  1. package/configurations.d.ts +15 -8
  2. package/configurations.js +29 -12
  3. package/configurations.js.map +1 -0
  4. package/definitions/entry.d.ts +6 -5
  5. package/definitions/entry.js +111 -20
  6. package/definitions/entry.js.map +1 -0
  7. package/definitions/entryElasticsearch.d.ts +6 -5
  8. package/definitions/entryElasticsearch.js +11 -16
  9. package/definitions/entryElasticsearch.js.map +1 -0
  10. package/definitions/group.d.ts +6 -5
  11. package/definitions/group.js +8 -16
  12. package/definitions/group.js.map +1 -0
  13. package/definitions/model.d.ts +6 -5
  14. package/definitions/model.js +30 -16
  15. package/definitions/model.js.map +1 -0
  16. package/definitions/system.d.ts +6 -5
  17. package/definitions/system.js +8 -16
  18. package/definitions/system.js.map +1 -0
  19. package/definitions/table.d.ts +6 -6
  20. package/definitions/table.js +7 -6
  21. package/definitions/table.js.map +1 -0
  22. package/definitions/tableElasticsearch.d.ts +6 -6
  23. package/definitions/tableElasticsearch.js +7 -6
  24. package/definitions/tableElasticsearch.js.map +1 -0
  25. package/dynamoDb/index.d.ts +2 -1
  26. package/dynamoDb/index.js +10 -12
  27. package/dynamoDb/index.js.map +1 -0
  28. package/dynamoDb/storage/longText.d.ts +7 -4
  29. package/dynamoDb/storage/longText.js +75 -62
  30. package/dynamoDb/storage/longText.js.map +1 -0
  31. package/dynamoDb/storage/richText.d.ts +2 -8
  32. package/dynamoDb/storage/richText.js +49 -100
  33. package/dynamoDb/storage/richText.js.map +1 -0
  34. package/elasticsearch/createElasticsearchIndex.d.ts +9 -0
  35. package/elasticsearch/createElasticsearchIndex.js +40 -0
  36. package/elasticsearch/createElasticsearchIndex.js.map +1 -0
  37. package/elasticsearch/deleteElasticsearchIndex.d.ts +8 -0
  38. package/elasticsearch/deleteElasticsearchIndex.js +38 -0
  39. package/elasticsearch/deleteElasticsearchIndex.js.map +1 -0
  40. package/elasticsearch/index.d.ts +1 -1
  41. package/elasticsearch/index.js +3 -6
  42. package/elasticsearch/index.js.map +1 -0
  43. package/elasticsearch/indexing/dateTimeIndexing.d.ts +1 -1
  44. package/elasticsearch/indexing/dateTimeIndexing.js +21 -22
  45. package/elasticsearch/indexing/dateTimeIndexing.js.map +1 -0
  46. package/elasticsearch/indexing/defaultFieldIndexing.d.ts +1 -1
  47. package/elasticsearch/indexing/defaultFieldIndexing.js +17 -10
  48. package/elasticsearch/indexing/defaultFieldIndexing.js.map +1 -0
  49. package/elasticsearch/indexing/index.js +5 -11
  50. package/elasticsearch/indexing/index.js.map +1 -0
  51. package/elasticsearch/indexing/jsonIndexing.d.ts +2 -0
  52. package/elasticsearch/indexing/jsonIndexing.js +28 -0
  53. package/elasticsearch/indexing/jsonIndexing.js.map +1 -0
  54. package/elasticsearch/indexing/longTextIndexing.d.ts +5 -1
  55. package/elasticsearch/indexing/longTextIndexing.js +16 -10
  56. package/elasticsearch/indexing/longTextIndexing.js.map +1 -0
  57. package/elasticsearch/indexing/numberIndexing.d.ts +1 -1
  58. package/elasticsearch/indexing/numberIndexing.js +2 -9
  59. package/elasticsearch/indexing/numberIndexing.js.map +1 -0
  60. package/elasticsearch/indexing/objectIndexing.d.ts +10 -1
  61. package/elasticsearch/indexing/objectIndexing.js +37 -36
  62. package/elasticsearch/indexing/objectIndexing.js.map +1 -0
  63. package/elasticsearch/indexing/richTextIndexing.d.ts +1 -1
  64. package/elasticsearch/indexing/richTextIndexing.js +2 -5
  65. package/elasticsearch/indexing/richTextIndexing.js.map +1 -0
  66. package/elasticsearch/indices/base.d.ts +2 -0
  67. package/elasticsearch/indices/base.js +13 -0
  68. package/elasticsearch/indices/base.js.map +1 -0
  69. package/elasticsearch/indices/index.d.ts +1 -0
  70. package/elasticsearch/indices/index.js +14 -0
  71. package/elasticsearch/indices/index.js.map +1 -0
  72. package/elasticsearch/indices/japanese.d.ts +2 -0
  73. package/elasticsearch/indices/japanese.js +14 -0
  74. package/elasticsearch/indices/japanese.js.map +1 -0
  75. package/elasticsearch/search/index.d.ts +2 -2
  76. package/elasticsearch/search/index.js +6 -9
  77. package/elasticsearch/search/index.js.map +1 -0
  78. package/elasticsearch/search/refSearch.d.ts +2 -3
  79. package/elasticsearch/search/refSearch.js +24 -17
  80. package/elasticsearch/search/refSearch.js.map +1 -0
  81. package/elasticsearch/search/searchableJson.d.ts +2 -0
  82. package/elasticsearch/search/searchableJson.js +60 -0
  83. package/elasticsearch/search/searchableJson.js.map +1 -0
  84. package/elasticsearch/search/timeSearch.d.ts +2 -3
  85. package/elasticsearch/search/timeSearch.js +18 -16
  86. package/elasticsearch/search/timeSearch.js.map +1 -0
  87. package/helpers/entryIndexHelpers.d.ts +3 -3
  88. package/helpers/entryIndexHelpers.js +59 -58
  89. package/helpers/entryIndexHelpers.js.map +1 -0
  90. package/helpers/fieldIdentifier.d.ts +6 -0
  91. package/helpers/fieldIdentifier.js +43 -0
  92. package/helpers/fieldIdentifier.js.map +1 -0
  93. package/helpers/index.d.ts +1 -1
  94. package/helpers/index.js +11 -13
  95. package/helpers/index.js.map +1 -0
  96. package/index.d.ts +2 -1
  97. package/index.js +132 -78
  98. package/index.js.map +1 -0
  99. package/operations/entry/dataLoader/DataLoaderCache.d.ts +17 -0
  100. package/operations/entry/dataLoader/DataLoaderCache.js +41 -0
  101. package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -0
  102. package/operations/entry/dataLoader/constants.d.ts +1 -0
  103. package/operations/entry/dataLoader/constants.js +10 -0
  104. package/operations/entry/dataLoader/constants.js.map +1 -0
  105. package/operations/entry/dataLoader/createBatchScheduleFn.d.ts +8 -0
  106. package/operations/entry/dataLoader/createBatchScheduleFn.js +25 -0
  107. package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -0
  108. package/operations/entry/dataLoader/getAllEntryRevisions.d.ts +4 -0
  109. package/operations/entry/dataLoader/getAllEntryRevisions.js +45 -0
  110. package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -0
  111. package/operations/entry/dataLoader/getLatestRevisionByEntryId.d.ts +4 -0
  112. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +52 -0
  113. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -0
  114. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.d.ts +4 -0
  115. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +52 -0
  116. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -0
  117. package/operations/entry/dataLoader/getRevisionById.d.ts +4 -0
  118. package/operations/entry/dataLoader/getRevisionById.js +62 -0
  119. package/operations/entry/dataLoader/getRevisionById.js.map +1 -0
  120. package/operations/entry/dataLoader/index.d.ts +8 -0
  121. package/operations/entry/dataLoader/index.js +40 -0
  122. package/operations/entry/dataLoader/index.js.map +1 -0
  123. package/operations/entry/dataLoader/types.d.ts +6 -0
  124. package/operations/entry/dataLoader/types.js +7 -0
  125. package/operations/entry/dataLoader/types.js.map +1 -0
  126. package/operations/entry/dataLoaders.d.ts +21 -38
  127. package/operations/entry/dataLoaders.js +59 -290
  128. package/operations/entry/dataLoaders.js.map +1 -0
  129. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.d.ts +18 -0
  130. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js +34 -0
  131. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js.map +1 -0
  132. package/operations/entry/elasticsearch/body.d.ts +13 -0
  133. package/operations/entry/elasticsearch/body.js +142 -0
  134. package/operations/entry/elasticsearch/body.js.map +1 -0
  135. package/operations/entry/elasticsearch/fields.d.ts +10 -0
  136. package/operations/entry/elasticsearch/fields.js +315 -0
  137. package/operations/entry/elasticsearch/fields.js.map +1 -0
  138. package/operations/entry/elasticsearch/filtering/applyFiltering.d.ts +8 -0
  139. package/operations/entry/elasticsearch/filtering/applyFiltering.js +60 -0
  140. package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +1 -0
  141. package/operations/entry/elasticsearch/filtering/exec.d.ts +17 -0
  142. package/operations/entry/elasticsearch/filtering/exec.js +175 -0
  143. package/operations/entry/elasticsearch/filtering/exec.js.map +1 -0
  144. package/operations/entry/elasticsearch/filtering/index.d.ts +1 -0
  145. package/operations/entry/elasticsearch/filtering/index.js +18 -0
  146. package/operations/entry/elasticsearch/filtering/index.js.map +1 -0
  147. package/operations/entry/elasticsearch/filtering/path.d.ts +16 -0
  148. package/operations/entry/elasticsearch/filtering/path.js +48 -0
  149. package/operations/entry/elasticsearch/filtering/path.js.map +1 -0
  150. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.d.ts +2 -0
  151. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js +30 -0
  152. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js.map +1 -0
  153. package/operations/entry/elasticsearch/filtering/plugins/index.d.ts +1 -0
  154. package/operations/entry/elasticsearch/filtering/plugins/index.js +15 -0
  155. package/operations/entry/elasticsearch/filtering/plugins/index.js.map +1 -0
  156. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.d.ts +2 -0
  157. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js +69 -0
  158. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js.map +1 -0
  159. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.d.ts +2 -0
  160. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js +57 -0
  161. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js.map +1 -0
  162. package/operations/entry/elasticsearch/filtering/populated.d.ts +2 -0
  163. package/operations/entry/elasticsearch/filtering/populated.js +25 -0
  164. package/operations/entry/elasticsearch/filtering/populated.js.map +1 -0
  165. package/operations/entry/elasticsearch/filtering/values.d.ts +2 -0
  166. package/operations/entry/elasticsearch/filtering/values.js +24 -0
  167. package/operations/entry/elasticsearch/filtering/values.js.map +1 -0
  168. package/operations/entry/elasticsearch/fullTextSearch.d.ts +12 -0
  169. package/operations/entry/elasticsearch/fullTextSearch.js +91 -0
  170. package/operations/entry/elasticsearch/fullTextSearch.js.map +1 -0
  171. package/operations/entry/elasticsearch/fullTextSearchFields.d.ts +8 -0
  172. package/operations/entry/elasticsearch/fullTextSearchFields.js +27 -0
  173. package/operations/entry/elasticsearch/fullTextSearchFields.js.map +1 -0
  174. package/operations/entry/elasticsearch/initialQuery.d.ts +17 -0
  175. package/operations/entry/elasticsearch/initialQuery.js +106 -0
  176. package/operations/entry/elasticsearch/initialQuery.js.map +1 -0
  177. package/operations/entry/elasticsearch/keyword.d.ts +2 -0
  178. package/operations/entry/elasticsearch/keyword.js +36 -0
  179. package/operations/entry/elasticsearch/keyword.js.map +1 -0
  180. package/operations/entry/elasticsearch/logIgnoredEsResponseError.d.ts +9 -0
  181. package/operations/entry/elasticsearch/logIgnoredEsResponseError.js +26 -0
  182. package/operations/entry/elasticsearch/logIgnoredEsResponseError.js.map +1 -0
  183. package/operations/entry/elasticsearch/plugins/bodyModifier.d.ts +9 -0
  184. package/operations/entry/elasticsearch/plugins/bodyModifier.js +18 -0
  185. package/operations/entry/elasticsearch/plugins/bodyModifier.js.map +1 -0
  186. package/operations/entry/elasticsearch/plugins/operator.d.ts +8 -0
  187. package/operations/entry/elasticsearch/plugins/operator.js +39 -0
  188. package/operations/entry/elasticsearch/plugins/operator.js.map +1 -0
  189. package/operations/entry/elasticsearch/plugins/queryModifier.d.ts +9 -0
  190. package/operations/entry/elasticsearch/plugins/queryModifier.js +18 -0
  191. package/operations/entry/elasticsearch/plugins/queryModifier.js.map +1 -0
  192. package/operations/entry/elasticsearch/plugins/search.d.ts +7 -0
  193. package/{helpers/searchPluginsList.js → operations/entry/elasticsearch/plugins/search.js} +9 -9
  194. package/operations/entry/elasticsearch/plugins/search.js.map +1 -0
  195. package/operations/entry/elasticsearch/plugins/sortModifier.d.ts +9 -0
  196. package/operations/entry/elasticsearch/plugins/sortModifier.js +18 -0
  197. package/operations/entry/elasticsearch/plugins/sortModifier.js.map +1 -0
  198. package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.d.ts +2 -0
  199. package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js +13 -0
  200. package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js.map +1 -0
  201. package/operations/entry/elasticsearch/sort.d.ts +12 -0
  202. package/operations/entry/elasticsearch/sort.js +89 -0
  203. package/operations/entry/elasticsearch/sort.js.map +1 -0
  204. package/operations/entry/elasticsearch/transformValueForSearch.d.ts +16 -0
  205. package/operations/entry/elasticsearch/transformValueForSearch.js +32 -0
  206. package/operations/entry/elasticsearch/transformValueForSearch.js.map +1 -0
  207. package/operations/entry/elasticsearch/types.d.ts +41 -0
  208. package/operations/entry/elasticsearch/types.js +7 -0
  209. package/operations/entry/elasticsearch/types.js.map +1 -0
  210. package/operations/entry/index.d.ts +6 -8
  211. package/operations/entry/index.js +1422 -693
  212. package/operations/entry/index.js.map +1 -0
  213. package/operations/entry/keys.js +2 -9
  214. package/operations/entry/keys.js.map +1 -0
  215. package/operations/entry/recordType.d.ts +3 -0
  216. package/operations/entry/recordType.js +20 -0
  217. package/operations/entry/recordType.js.map +1 -0
  218. package/operations/entry/transformations/convertEntryKeys.d.ts +8 -0
  219. package/operations/entry/transformations/convertEntryKeys.js +38 -0
  220. package/operations/entry/transformations/convertEntryKeys.js.map +1 -0
  221. package/operations/entry/transformations/index.d.ts +29 -0
  222. package/operations/entry/transformations/index.js +127 -0
  223. package/operations/entry/transformations/index.js.map +1 -0
  224. package/operations/entry/transformations/modifyEntryValues.d.ts +58 -0
  225. package/operations/entry/transformations/modifyEntryValues.js +28 -0
  226. package/operations/entry/transformations/modifyEntryValues.js.map +1 -0
  227. package/operations/entry/transformations/transformEntryKeys.d.ts +11 -0
  228. package/operations/entry/transformations/transformEntryKeys.js +27 -0
  229. package/operations/entry/transformations/transformEntryKeys.js.map +1 -0
  230. package/operations/entry/transformations/transformEntryToIndex.d.ts +10 -0
  231. package/operations/entry/transformations/transformEntryToIndex.js +31 -0
  232. package/operations/entry/transformations/transformEntryToIndex.js.map +1 -0
  233. package/operations/group/index.d.ts +5 -5
  234. package/operations/group/index.js +40 -63
  235. package/operations/group/index.js.map +1 -0
  236. package/operations/model/index.d.ts +5 -5
  237. package/operations/model/index.js +56 -78
  238. package/operations/model/index.js.map +1 -0
  239. package/operations/system/index.d.ts +4 -4
  240. package/operations/system/index.js +20 -31
  241. package/operations/system/index.js.map +1 -0
  242. package/operations/system/indexes.d.ts +10 -0
  243. package/operations/system/indexes.js +41 -0
  244. package/operations/system/indexes.js.map +1 -0
  245. package/package.json +38 -40
  246. package/plugins/CmsElasticsearchModelFieldPlugin.d.ts +69 -0
  247. package/plugins/CmsElasticsearchModelFieldPlugin.js +52 -0
  248. package/plugins/CmsElasticsearchModelFieldPlugin.js.map +1 -0
  249. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.d.ts +9 -4
  250. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js +10 -13
  251. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js.map +1 -0
  252. package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.d.ts +23 -0
  253. package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js +27 -0
  254. package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js.map +1 -0
  255. package/plugins/CmsEntryElasticsearchIndexPlugin.d.ts +4 -0
  256. package/plugins/CmsEntryElasticsearchIndexPlugin.js +13 -0
  257. package/plugins/CmsEntryElasticsearchIndexPlugin.js.map +1 -0
  258. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.d.ts +32 -0
  259. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js +40 -0
  260. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js.map +1 -0
  261. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.d.ts +6 -4
  262. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js +10 -13
  263. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js.map +1 -0
  264. package/plugins/CmsEntryElasticsearchSortModifierPlugin.d.ts +6 -4
  265. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js +10 -13
  266. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js.map +1 -0
  267. package/plugins/CmsEntryElasticsearchValuesModifier.d.ts +33 -0
  268. package/plugins/CmsEntryElasticsearchValuesModifier.js +50 -0
  269. package/plugins/CmsEntryElasticsearchValuesModifier.js.map +1 -0
  270. package/plugins/CmsEntryFilterPlugin.d.ts +49 -0
  271. package/plugins/CmsEntryFilterPlugin.js +22 -0
  272. package/plugins/CmsEntryFilterPlugin.js.map +1 -0
  273. package/plugins/index.d.ts +8 -0
  274. package/plugins/index.js +95 -0
  275. package/plugins/index.js.map +1 -0
  276. package/tasks/createIndexTaskPlugin.d.ts +2 -0
  277. package/tasks/createIndexTaskPlugin.js +67 -0
  278. package/tasks/createIndexTaskPlugin.js.map +1 -0
  279. package/types.d.ts +30 -52
  280. package/types.js +5 -23
  281. package/types.js.map +1 -0
  282. package/values/NoValueContainer.d.ts +5 -0
  283. package/values/NoValueContainer.js +20 -0
  284. package/values/NoValueContainer.js.map +1 -0
  285. package/definitions/settings.d.ts +0 -8
  286. package/definitions/settings.js +0 -62
  287. package/dynamoDb/storage/date.d.ts +0 -3
  288. package/dynamoDb/storage/date.js +0 -65
  289. package/helpers/createElasticsearchQueryBody.d.ts +0 -11
  290. package/helpers/createElasticsearchQueryBody.js +0 -375
  291. package/helpers/fields.d.ts +0 -77
  292. package/helpers/fields.js +0 -174
  293. package/helpers/operatorPluginsList.d.ts +0 -7
  294. package/helpers/operatorPluginsList.js +0 -30
  295. package/helpers/searchPluginsList.d.ts +0 -6
  296. package/helpers/transformValueForSearch.d.ts +0 -9
  297. package/helpers/transformValueForSearch.js +0 -26
  298. package/operations/entry/elasticsearchFields.d.ts +0 -2
  299. package/operations/entry/elasticsearchFields.js +0 -32
  300. package/operations/entry/fields.d.ts +0 -3
  301. package/operations/entry/fields.js +0 -60
  302. package/operations/settings/index.d.ts +0 -6
  303. package/operations/settings/index.js +0 -141
  304. package/operations/system/createElasticsearchTemplate.d.ts +0 -5
  305. package/operations/system/createElasticsearchTemplate.js +0 -62
  306. package/plugins/CmsEntryElasticsearchFieldPlugin.d.ts +0 -12
  307. package/plugins/CmsEntryElasticsearchFieldPlugin.js +0 -24
  308. package/upgrades/index.d.ts +0 -2
  309. package/upgrades/index.js +0 -16
  310. package/upgrades/utils.d.ts +0 -1
  311. package/upgrades/utils.js +0 -16
  312. package/upgrades/v5.0.0/cleanDatabaseRecord.d.ts +0 -6
  313. package/upgrades/v5.0.0/cleanDatabaseRecord.js +0 -16
  314. package/upgrades/v5.0.0/createOldVersionIndiceName.d.ts +0 -2
  315. package/upgrades/v5.0.0/createOldVersionIndiceName.js +0 -12
  316. package/upgrades/v5.0.0/entryValueFixer.d.ts +0 -4
  317. package/upgrades/v5.0.0/entryValueFixer.js +0 -124
  318. package/upgrades/v5.0.0/fieldFinder.d.ts +0 -6
  319. package/upgrades/v5.0.0/fieldFinder.js +0 -42
  320. package/upgrades/v5.0.0/helpers.d.ts +0 -4
  321. package/upgrades/v5.0.0/helpers.js +0 -57
  322. package/upgrades/v5.0.0/index.d.ts +0 -4
  323. package/upgrades/v5.0.0/index.js +0 -232
  324. package/upgrades/v5.8.0/index.d.ts +0 -4
  325. package/upgrades/v5.8.0/index.js +0 -426
package/index.js CHANGED
@@ -1,63 +1,59 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
7
+ var _exportNames = {
8
+ createStorageOperations: true
9
+ };
8
10
  exports.createStorageOperations = void 0;
9
-
10
11
  var _filters = _interopRequireDefault(require("@webiny/db-dynamodb/plugins/filters"));
11
-
12
12
  var _elasticsearch = _interopRequireDefault(require("./elasticsearch"));
13
-
14
13
  var _dynamoDb = _interopRequireDefault(require("./dynamoDb"));
15
-
16
- var _settings = require("./operations/settings");
17
-
18
14
  var _system = require("./operations/system");
19
-
20
15
  var _model = require("./operations/model");
21
-
22
16
  var _entry = require("./operations/entry");
23
-
24
17
  var _types = require("./types");
25
-
26
18
  var _table = require("./definitions/table");
27
-
28
19
  var _tableElasticsearch = require("./definitions/tableElasticsearch");
29
-
30
20
  var _group = require("./definitions/group");
31
-
32
21
  var _model2 = require("./definitions/model");
33
-
34
22
  var _entry2 = require("./definitions/entry");
35
-
36
23
  var _entryElasticsearch = require("./definitions/entryElasticsearch");
37
-
38
24
  var _system2 = require("./definitions/system");
39
-
40
- var _settings2 = require("./definitions/settings");
41
-
42
- var _createElasticsearchTemplate = require("./operations/system/createElasticsearchTemplate");
43
-
25
+ var _createElasticsearchIndex = require("./elasticsearch/createElasticsearchIndex");
44
26
  var _plugins = require("@webiny/plugins");
45
-
46
27
  var _group2 = require("./operations/group");
47
-
48
- var _operators = require("@webiny/api-elasticsearch/operators");
49
-
50
- var _elasticsearchFields = require("./operations/entry/elasticsearchFields");
51
-
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");
52
49
  const createStorageOperations = params => {
53
50
  const {
54
- attributes = {},
51
+ attributes,
55
52
  table,
56
53
  esTable,
57
54
  documentClient,
58
55
  elasticsearch,
59
- plugins: customPlugins,
60
- modelFieldToGraphQLPlugins
56
+ plugins: userPlugins
61
57
  } = params;
62
58
  const tableInstance = (0, _table.createTable)({
63
59
  table,
@@ -68,89 +64,151 @@ const createStorageOperations = params => {
68
64
  documentClient
69
65
  });
70
66
  const entities = {
71
- settings: (0, _settings2.createSettingsEntity)({
72
- entityName: _types.ENTITIES.SETTINGS,
73
- table: tableInstance,
74
- attributes: attributes[_types.ENTITIES.SETTINGS]
75
- }),
76
67
  system: (0, _system2.createSystemEntity)({
77
68
  entityName: _types.ENTITIES.SYSTEM,
78
69
  table: tableInstance,
79
- attributes: attributes[_types.ENTITIES.SYSTEM]
70
+ attributes: attributes ? attributes[_types.ENTITIES.SYSTEM] : {}
80
71
  }),
81
72
  groups: (0, _group.createGroupEntity)({
82
73
  entityName: _types.ENTITIES.GROUPS,
83
74
  table: tableInstance,
84
- attributes: attributes[_types.ENTITIES.GROUPS]
75
+ attributes: attributes ? attributes[_types.ENTITIES.GROUPS] : {}
85
76
  }),
86
77
  models: (0, _model2.createModelEntity)({
87
78
  entityName: _types.ENTITIES.MODELS,
88
79
  table: tableInstance,
89
- attributes: attributes[_types.ENTITIES.MODELS]
80
+ attributes: attributes ? attributes[_types.ENTITIES.MODELS] : {}
90
81
  }),
91
82
  entries: (0, _entry2.createEntryEntity)({
92
83
  entityName: _types.ENTITIES.ENTRIES,
93
84
  table: tableInstance,
94
- attributes: attributes[_types.ENTITIES.ENTRIES]
85
+ attributes: attributes ? attributes[_types.ENTITIES.ENTRIES] : {}
95
86
  }),
96
87
  entriesEs: (0, _entryElasticsearch.createEntryElasticsearchEntity)({
97
88
  entityName: _types.ENTITIES.ENTRIES_ES,
98
89
  table: tableElasticsearchInstance,
99
- attributes: attributes[_types.ENTITIES.ENTRIES_ES]
90
+ attributes: attributes ? attributes[_types.ENTITIES.ENTRIES_ES] : {}
100
91
  })
101
92
  };
102
93
  const plugins = new _plugins.PluginsContainer([
103
94
  /**
104
- * User defined custom plugins.
105
- */
106
- ...(customPlugins || []),
107
- /**
108
- * Plugins of type CmsModelFieldToGraphQLPlugin.
95
+ * DynamoDB filter plugins for the where conditions.
109
96
  */
110
- modelFieldToGraphQLPlugins,
97
+ (0, _filters.default)(),
111
98
  /**
112
- * Elasticsearch field definitions for the entry record.
99
+ * Field plugins for DynamoDB.
113
100
  */
114
- _elasticsearchFields.elasticsearchFields,
101
+ (0, _dynamoDb.default)(),
115
102
  /**
116
- * DynamoDB filter plugins for the where conditions.
103
+ * Field plugins for Elasticsearch.
117
104
  */
118
- (0, _filters.default)(),
105
+ (0, _elasticsearch.default)(),
119
106
  /**
120
- * Elasticsearch operators.
107
+ * Built-in Elasticsearch index templates.
121
108
  */
122
- (0, _operators.getElasticsearchOperators)(),
109
+ (0, _indices.elasticsearchIndexPlugins)(),
123
110
  /**
124
- * Field plugins for DynamoDB.
111
+ * Filter plugins used to apply filtering from where conditions to Elasticsearch query.
125
112
  */
126
- (0, _dynamoDb.default)(),
113
+ (0, _plugins3.createFilterPlugins)(),
127
114
  /**
128
- * Field plugins for Elasticsearch.
115
+ * User defined custom plugins.
116
+ * They are at the end because we can then override existing plugins.
129
117
  */
130
- (0, _elasticsearch.default)()]);
118
+ ...(userPlugins || [])]);
119
+ const entries = (0, _entry.createEntriesStorageOperations)({
120
+ entity: entities.entries,
121
+ esEntity: entities.entriesEs,
122
+ plugins,
123
+ elasticsearch
124
+ });
131
125
  return {
132
- init: async cms => {
133
- cms.onBeforeSystemInstall.subscribe(async () => {
134
- await (0, _createElasticsearchTemplate.createElasticsearchTemplate)({
135
- elasticsearch
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
136
203
  });
137
204
  });
138
205
  },
139
- plugins: [
140
- /**
141
- * Field plugins for DynamoDB.
142
- * We must pass them to the base application.
143
- */
144
- (0, _dynamoDb.default)()],
145
206
  getEntities: () => entities,
146
207
  getTable: () => tableInstance,
147
208
  getEsTable: () => tableElasticsearchInstance,
148
209
  system: (0, _system.createSystemStorageOperations)({
149
210
  entity: entities.system
150
211
  }),
151
- settings: (0, _settings.createSettingsStorageOperations)({
152
- entity: entities.settings
153
- }),
154
212
  groups: (0, _group2.createGroupsStorageOperations)({
155
213
  entity: entities.groups,
156
214
  plugins
@@ -159,13 +217,9 @@ const createStorageOperations = params => {
159
217
  entity: entities.models,
160
218
  elasticsearch
161
219
  }),
162
- entries: (0, _entry.createEntriesStorageOperations)({
163
- entity: entities.entries,
164
- esEntity: entities.entriesEs,
165
- plugins,
166
- elasticsearch
167
- })
220
+ entries
168
221
  };
169
222
  };
223
+ exports.createStorageOperations = createStorageOperations;
170
224
 
171
- exports.createStorageOperations = createStorageOperations;
225
+ //# sourceMappingURL=index.js.map
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_filters","_interopRequireDefault","require","_elasticsearch","_dynamoDb","_system","_model","_entry","_types","_table","_tableElasticsearch","_group","_model2","_entry2","_entryElasticsearch","_system2","_createElasticsearchIndex","_plugins","_group2","_apiElasticsearch","_indices","_deleteElasticsearchIndex","_plugins2","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_plugins3","_CmsEntryFilterPlugin","_apiHeadlessCms","_indexes","_createIndexTaskPlugin","_api","createStorageOperations","params","attributes","table","esTable","documentClient","elasticsearch","plugins","userPlugins","tableInstance","createTable","tableElasticsearchInstance","createElasticsearchTable","entities","system","createSystemEntity","entityName","ENTITIES","SYSTEM","groups","createGroupEntity","GROUPS","models","createModelEntity","MODELS","entries","createEntryEntity","ENTRIES","entriesEs","createEntryElasticsearchEntity","ENTRIES_ES","PluginsContainer","dynamoDbValueFilters","dynamoDbPlugins","elasticsearchPlugins","elasticsearchIndexPlugins","createFilterPlugins","createEntriesStorageOperations","entity","esEntity","name","beforeInit","context","db","registry","register","item","app","tags","createIndexTaskPluginTest","types","ElasticsearchQueryBuilderOperatorPlugin","type","CmsEntryFilterPlugin","CmsEntryElasticsearchBodyModifierPlugin","CmsEntryElasticsearchFullTextSearchPlugin","CmsEntryElasticsearchIndexPlugin","CmsEntryElasticsearchQueryBuilderValueSearchPlugin","CmsEntryElasticsearchQueryModifierPlugin","CmsEntryElasticsearchSortModifierPlugin","CmsElasticsearchModelFieldPlugin","StorageOperationsCmsModelPlugin","StorageTransformPlugin","CmsEntryElasticsearchValuesModifier","CompressorPlugin","mergeByType","dataLoaders","clearAll","init","createElasticsearchIndexesOnLocaleAfterCreate","client","cms","onModelBeforeCreate","subscribe","model","createElasticsearchIndex","onModelBeforeCreateFrom","onModelAfterDelete","deleteElasticsearchIndex","onModelInitialize","getEntities","getTable","getEsTable","createSystemStorageOperations","createGroupsStorageOperations","createModelsStorageOperations"],"sources":["index.ts"],"sourcesContent":["import dynamoDbValueFilters from \"@webiny/db-dynamodb/plugins/filters\";\nimport elasticsearchPlugins from \"./elasticsearch\";\nimport dynamoDbPlugins from \"./dynamoDb\";\nimport { createSystemStorageOperations } from \"./operations/system\";\nimport { createModelsStorageOperations } from \"./operations/model\";\nimport { createEntriesStorageOperations } from \"./operations/entry\";\nimport type { StorageOperationsFactory } from \"~/types\";\nimport { ENTITIES } from \"~/types\";\nimport { createTable } from \"~/definitions/table\";\nimport { createElasticsearchTable } from \"~/definitions/tableElasticsearch\";\nimport { createGroupEntity } from \"~/definitions/group\";\nimport { createModelEntity } from \"~/definitions/model\";\nimport { createEntryEntity } from \"~/definitions/entry\";\nimport { createEntryElasticsearchEntity } from \"~/definitions/entryElasticsearch\";\nimport { createSystemEntity } from \"~/definitions/system\";\nimport { createElasticsearchIndex } from \"~/elasticsearch/createElasticsearchIndex\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { createGroupsStorageOperations } from \"~/operations/group\";\nimport { ElasticsearchQueryBuilderOperatorPlugin } from \"@webiny/api-elasticsearch\";\nimport { elasticsearchIndexPlugins } from \"./elasticsearch/indices\";\nimport { deleteElasticsearchIndex } from \"./elasticsearch/deleteElasticsearchIndex\";\nimport {\n CmsElasticsearchModelFieldPlugin,\n CmsEntryElasticsearchBodyModifierPlugin,\n CmsEntryElasticsearchFullTextSearchPlugin,\n CmsEntryElasticsearchIndexPlugin,\n CmsEntryElasticsearchQueryBuilderValueSearchPlugin,\n CmsEntryElasticsearchQueryModifierPlugin,\n CmsEntryElasticsearchSortModifierPlugin,\n CmsEntryElasticsearchValuesModifier\n} from \"~/plugins\";\nimport { createFilterPlugins } from \"~/operations/entry/elasticsearch/filtering/plugins\";\nimport { CmsEntryFilterPlugin } from \"~/plugins/CmsEntryFilterPlugin\";\nimport { StorageOperationsCmsModelPlugin, StorageTransformPlugin } from \"@webiny/api-headless-cms\";\nimport { createElasticsearchIndexesOnLocaleAfterCreate } from \"~/operations/system/indexes\";\nimport { createIndexTaskPluginTest } from \"~/tasks/createIndexTaskPlugin\";\nimport { CompressorPlugin } from \"@webiny/api\";\n\nexport * from \"./plugins\";\n\nexport const createStorageOperations: StorageOperationsFactory = params => {\n const {\n attributes,\n table,\n esTable,\n documentClient,\n elasticsearch,\n plugins: userPlugins\n } = params;\n\n const tableInstance = createTable({\n table,\n documentClient\n });\n const tableElasticsearchInstance = createElasticsearchTable({\n table: esTable,\n documentClient\n });\n\n const entities = {\n system: createSystemEntity({\n entityName: ENTITIES.SYSTEM,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.SYSTEM] : {}\n }),\n groups: createGroupEntity({\n entityName: ENTITIES.GROUPS,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.GROUPS] : {}\n }),\n models: createModelEntity({\n entityName: ENTITIES.MODELS,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.MODELS] : {}\n }),\n entries: createEntryEntity({\n entityName: ENTITIES.ENTRIES,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.ENTRIES] : {}\n }),\n entriesEs: createEntryElasticsearchEntity({\n entityName: ENTITIES.ENTRIES_ES,\n table: tableElasticsearchInstance,\n attributes: attributes ? attributes[ENTITIES.ENTRIES_ES] : {}\n })\n };\n\n const plugins = new PluginsContainer([\n /**\n * DynamoDB filter plugins for the where conditions.\n */\n dynamoDbValueFilters(),\n /**\n * Field plugins for DynamoDB.\n */\n dynamoDbPlugins(),\n /**\n * Field plugins for Elasticsearch.\n */\n elasticsearchPlugins(),\n /**\n * Built-in Elasticsearch index templates.\n */\n elasticsearchIndexPlugins(),\n /**\n * Filter plugins used to apply filtering from where conditions to Elasticsearch query.\n */\n createFilterPlugins(),\n /**\n * User defined custom plugins.\n * They are at the end because we can then override existing plugins.\n */\n ...(userPlugins || [])\n ]);\n\n const entries = createEntriesStorageOperations({\n entity: entities.entries,\n esEntity: entities.entriesEs,\n plugins,\n elasticsearch\n });\n\n return {\n name: \"dynamodb:elasticsearch\",\n beforeInit: async context => {\n context.db.registry.register({\n item: entities.entries,\n app: \"cms\",\n tags: [\"regular\", entities.entries.name]\n });\n context.db.registry.register({\n item: entities.entriesEs,\n app: \"cms\",\n tags: [\"es\", entities.entriesEs.name]\n });\n /**\n * Attach the elasticsearch into context if it is not already attached.\n */\n if (!context.elasticsearch) {\n context.elasticsearch = elasticsearch;\n }\n /**\n * Pass the plugins to the parent context.\n */\n context.plugins.register([\n dynamoDbPlugins(),\n createIndexTaskPluginTest(),\n elasticsearchIndexPlugins()\n ]);\n /**\n * We need to fetch all the plugin types in the list from the main container.\n * This way we do not need to register plugins in the storage plugins contains.\n */\n const types: string[] = [\n ElasticsearchQueryBuilderOperatorPlugin.type,\n // Headless CMS\n \"cms-model-field-to-graphql\",\n CmsEntryFilterPlugin.type,\n CmsEntryElasticsearchBodyModifierPlugin.type,\n CmsEntryElasticsearchFullTextSearchPlugin.type,\n CmsEntryElasticsearchIndexPlugin.type,\n CmsEntryElasticsearchQueryBuilderValueSearchPlugin.type,\n CmsEntryElasticsearchQueryModifierPlugin.type,\n CmsEntryElasticsearchSortModifierPlugin.type,\n CmsElasticsearchModelFieldPlugin.type,\n StorageOperationsCmsModelPlugin.type,\n StorageTransformPlugin.type,\n CmsEntryElasticsearchValuesModifier.type,\n CompressorPlugin.type\n ];\n for (const type of types) {\n plugins.mergeByType(context.plugins, type);\n }\n entries.dataLoaders.clearAll();\n },\n init: async context => {\n /**\n * We need to create indexes on before model create and on clone (create from).\n * Other apps create indexes on locale creation.\n */\n await createElasticsearchIndexesOnLocaleAfterCreate({\n context,\n client: elasticsearch,\n plugins\n });\n\n context.cms.onModelBeforeCreate.subscribe(async ({ model }) => {\n await createElasticsearchIndex({\n client: elasticsearch,\n model,\n plugins\n });\n });\n context.cms.onModelBeforeCreateFrom.subscribe(async ({ model }) => {\n await createElasticsearchIndex({\n client: elasticsearch,\n model,\n plugins\n });\n });\n context.cms.onModelAfterDelete.subscribe(async ({ model }) => {\n await deleteElasticsearchIndex({\n client: elasticsearch,\n model\n });\n });\n\n context.cms.onModelInitialize.subscribe(async ({ model }) => {\n await createElasticsearchIndex({\n client: elasticsearch,\n model,\n plugins\n });\n });\n },\n getEntities: () => entities,\n getTable: () => tableInstance,\n getEsTable: () => tableElasticsearchInstance,\n system: createSystemStorageOperations({\n entity: entities.system\n }),\n groups: createGroupsStorageOperations({\n entity: entities.groups,\n plugins\n }),\n models: createModelsStorageOperations({\n entity: entities.models,\n elasticsearch\n }),\n entries\n };\n};\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,cAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,SAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAEA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AACA,IAAAQ,mBAAA,GAAAR,OAAA;AACA,IAAAS,MAAA,GAAAT,OAAA;AACA,IAAAU,OAAA,GAAAV,OAAA;AACA,IAAAW,OAAA,GAAAX,OAAA;AACA,IAAAY,mBAAA,GAAAZ,OAAA;AACA,IAAAa,QAAA,GAAAb,OAAA;AACA,IAAAc,yBAAA,GAAAd,OAAA;AACA,IAAAe,QAAA,GAAAf,OAAA;AACA,IAAAgB,OAAA,GAAAhB,OAAA;AACA,IAAAiB,iBAAA,GAAAjB,OAAA;AACA,IAAAkB,QAAA,GAAAlB,OAAA;AACA,IAAAmB,yBAAA,GAAAnB,OAAA;AACA,IAAAoB,SAAA,GAAApB,OAAA;AAiBAqB,MAAA,CAAAC,IAAA,CAAAF,SAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAA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,aAAa;IAC7ByE,UAAU,EAAEA,CAAA,KAAMvE,0BAA0B;IAC5CG,MAAM,EAAE,IAAAqE,qCAA6B,EAAC;MAClC7C,MAAM,EAAEzB,QAAQ,CAACC;IACrB,CAAC,CAAC;IACFK,MAAM,EAAE,IAAAiE,qCAA6B,EAAC;MAClC9C,MAAM,EAAEzB,QAAQ,CAACM,MAAM;MACvBZ;IACJ,CAAC,CAAC;IACFe,MAAM,EAAE,IAAA+D,oCAA6B,EAAC;MAClC/C,MAAM,EAAEzB,QAAQ,CAACS,MAAM;MACvBhB;IACJ,CAAC,CAAC;IACFmB;EACJ,CAAC;AACL,CAAC;AAACnC,OAAA,CAAAU,uBAAA,GAAAA,uBAAA","ignoreList":[]}
@@ -0,0 +1,17 @@
1
+ import type DataLoader from "dataloader";
2
+ export interface CacheKeyParams {
3
+ name: string;
4
+ tenant: string;
5
+ locale: string;
6
+ }
7
+ export interface ClearAllParams {
8
+ tenant: string;
9
+ locale: string;
10
+ }
11
+ export declare class DataLoaderCache {
12
+ private readonly cache;
13
+ getDataLoader<I = any, R = any>(params: CacheKeyParams): DataLoader<I, R> | null;
14
+ setDataLoader(params: CacheKeyParams, dataLoader: DataLoader<any, any>): void;
15
+ clearAll(params?: ClearAllParams): void;
16
+ private createKey;
17
+ }
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.DataLoaderCache = void 0;
7
+ 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;
23
+ }
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();
33
+ }
34
+ }
35
+ createKey(params) {
36
+ return `${params.tenant}_${params.locale}_${params.name}`;
37
+ }
38
+ }
39
+ exports.DataLoaderCache = DataLoaderCache;
40
+
41
+ //# sourceMappingURL=DataLoaderCache.js.map
@@ -0,0 +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":[]}
@@ -0,0 +1 @@
1
+ export declare const CMS_ENTRY_BATCH_SCHEDULE_WAIT: number;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.CMS_ENTRY_BATCH_SCHEDULE_WAIT = void 0;
7
+ 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;
9
+
10
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +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":[]}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * This is to be used when user wants to wait for a number of milliseconds before the batch is executed.
3
+ * Intended to be used internally or for a specific user case.
4
+ * Not to be documented and exposed to publish as it can slow the data loading a lot.
5
+ *
6
+ * https://github.com/graphql/dataloader#batch-scheduling
7
+ */
8
+ export declare const createBatchScheduleFn: () => ((callback: () => void) => void) | undefined;
@@ -0,0 +1,25 @@
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
+ };
22
+ };
23
+ exports.createBatchScheduleFn = createBatchScheduleFn;
24
+
25
+ //# sourceMappingURL=createBatchScheduleFn.js.map
@@ -0,0 +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":[]}
@@ -0,0 +1,4 @@
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>;
@@ -0,0 +1,45 @@
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] || [];
38
+ });
39
+ }, {
40
+ batchScheduleFn: (0, _createBatchScheduleFn.createBatchScheduleFn)()
41
+ });
42
+ };
43
+ exports.createGetAllEntryRevisions = createGetAllEntryRevisions;
44
+
45
+ //# sourceMappingURL=getAllEntryRevisions.js.map
@@ -0,0 +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":[]}
@@ -0,0 +1,4 @@
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>;
@@ -0,0 +1,52 @@
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
+ });
45
+ });
46
+ }, {
47
+ batchScheduleFn: (0, _createBatchScheduleFn.createBatchScheduleFn)()
48
+ });
49
+ };
50
+ exports.createGetLatestRevisionByEntryId = createGetLatestRevisionByEntryId;
51
+
52
+ //# sourceMappingURL=getLatestRevisionByEntryId.js.map
@@ -0,0 +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":[]}
@@ -0,0 +1,4 @@
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>;