@webiny/api-headless-cms-ddb-es 0.0.0-mt-3 → 0.0.0-unstable.2af142b57e

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 (252) hide show
  1. package/configurations.d.ts +2 -2
  2. package/configurations.js +13 -10
  3. package/configurations.js.map +1 -0
  4. package/definitions/entry.d.ts +2 -2
  5. package/definitions/entry.js +6 -12
  6. package/definitions/entry.js.map +1 -0
  7. package/definitions/entryElasticsearch.d.ts +2 -2
  8. package/definitions/entryElasticsearch.js +3 -12
  9. package/definitions/entryElasticsearch.js.map +1 -0
  10. package/definitions/group.d.ts +2 -2
  11. package/definitions/group.js +3 -12
  12. package/definitions/group.js.map +1 -0
  13. package/definitions/model.d.ts +2 -2
  14. package/definitions/model.js +8 -12
  15. package/definitions/model.js.map +1 -0
  16. package/definitions/settings.d.ts +2 -2
  17. package/definitions/settings.js +3 -12
  18. package/definitions/settings.js.map +1 -0
  19. package/definitions/system.d.ts +2 -2
  20. package/definitions/system.js +3 -12
  21. package/definitions/system.js.map +1 -0
  22. package/definitions/table.d.ts +2 -2
  23. package/definitions/table.js +0 -3
  24. package/definitions/table.js.map +1 -0
  25. package/definitions/tableElasticsearch.d.ts +2 -2
  26. package/definitions/tableElasticsearch.js +0 -3
  27. package/definitions/tableElasticsearch.js.map +1 -0
  28. package/dynamoDb/index.d.ts +1 -1
  29. package/dynamoDb/index.js +4 -11
  30. package/dynamoDb/index.js.map +1 -0
  31. package/dynamoDb/storage/date.d.ts +3 -3
  32. package/dynamoDb/storage/date.js +73 -54
  33. package/dynamoDb/storage/date.js.map +1 -0
  34. package/dynamoDb/storage/longText.d.ts +7 -4
  35. package/dynamoDb/storage/longText.js +72 -64
  36. package/dynamoDb/storage/longText.js.map +1 -0
  37. package/dynamoDb/storage/richText.d.ts +2 -3
  38. package/dynamoDb/storage/richText.js +74 -78
  39. package/dynamoDb/storage/richText.js.map +1 -0
  40. package/elasticsearch/createElasticsearchIndex.d.ts +9 -0
  41. package/elasticsearch/createElasticsearchIndex.js +49 -0
  42. package/elasticsearch/createElasticsearchIndex.js.map +1 -0
  43. package/elasticsearch/deleteElasticsearchIndex.d.ts +8 -0
  44. package/elasticsearch/deleteElasticsearchIndex.js +36 -0
  45. package/elasticsearch/deleteElasticsearchIndex.js.map +1 -0
  46. package/elasticsearch/index.d.ts +1 -1
  47. package/elasticsearch/index.js +1 -6
  48. package/elasticsearch/index.js.map +1 -0
  49. package/elasticsearch/indexing/dateTimeIndexing.js +17 -20
  50. package/elasticsearch/indexing/dateTimeIndexing.js.map +1 -0
  51. package/elasticsearch/indexing/defaultFieldIndexing.js +5 -9
  52. package/elasticsearch/indexing/defaultFieldIndexing.js.map +1 -0
  53. package/elasticsearch/indexing/index.js +1 -10
  54. package/elasticsearch/indexing/index.js.map +1 -0
  55. package/elasticsearch/indexing/longTextIndexing.d.ts +4 -0
  56. package/elasticsearch/indexing/longTextIndexing.js +19 -9
  57. package/elasticsearch/indexing/longTextIndexing.js.map +1 -0
  58. package/elasticsearch/indexing/numberIndexing.js +0 -9
  59. package/elasticsearch/indexing/numberIndexing.js.map +1 -0
  60. package/elasticsearch/indexing/objectIndexing.d.ts +9 -0
  61. package/elasticsearch/indexing/objectIndexing.js +26 -30
  62. package/elasticsearch/indexing/objectIndexing.js.map +1 -0
  63. package/elasticsearch/indexing/richTextIndexing.js +0 -5
  64. package/elasticsearch/indexing/richTextIndexing.js.map +1 -0
  65. package/elasticsearch/indices/base.d.ts +2 -0
  66. package/elasticsearch/indices/base.js +12 -0
  67. package/elasticsearch/indices/base.js.map +1 -0
  68. package/elasticsearch/indices/index.d.ts +1 -0
  69. package/elasticsearch/indices/index.js +12 -0
  70. package/elasticsearch/indices/index.js.map +1 -0
  71. package/elasticsearch/indices/japanese.d.ts +2 -0
  72. package/elasticsearch/indices/japanese.js +13 -0
  73. package/elasticsearch/indices/japanese.js.map +1 -0
  74. package/elasticsearch/search/index.d.ts +2 -2
  75. package/elasticsearch/search/index.js +3 -9
  76. package/elasticsearch/search/index.js.map +1 -0
  77. package/elasticsearch/search/refSearch.d.ts +2 -3
  78. package/elasticsearch/search/refSearch.js +23 -18
  79. package/elasticsearch/search/refSearch.js.map +1 -0
  80. package/elasticsearch/search/timeSearch.d.ts +2 -3
  81. package/elasticsearch/search/timeSearch.js +18 -17
  82. package/elasticsearch/search/timeSearch.js.map +1 -0
  83. package/helpers/entryIndexHelpers.js +43 -57
  84. package/helpers/entryIndexHelpers.js.map +1 -0
  85. package/helpers/index.d.ts +0 -1
  86. package/helpers/index.js +0 -15
  87. package/helpers/index.js.map +1 -0
  88. package/index.d.ts +1 -0
  89. package/index.js +120 -58
  90. package/index.js.map +1 -0
  91. package/operations/entry/dataLoaders.d.ts +6 -2
  92. package/operations/entry/dataLoaders.js +27 -61
  93. package/operations/entry/dataLoaders.js.map +1 -0
  94. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.d.ts +18 -0
  95. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js +32 -0
  96. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js.map +1 -0
  97. package/operations/entry/elasticsearch/body.d.ts +13 -0
  98. package/operations/entry/elasticsearch/body.js +140 -0
  99. package/operations/entry/elasticsearch/body.js.map +1 -0
  100. package/operations/entry/elasticsearch/fields.d.ts +9 -0
  101. package/operations/entry/elasticsearch/fields.js +229 -0
  102. package/operations/entry/elasticsearch/fields.js.map +1 -0
  103. package/operations/entry/elasticsearch/filtering/applyFiltering.d.ts +8 -0
  104. package/operations/entry/elasticsearch/filtering/applyFiltering.js +57 -0
  105. package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +1 -0
  106. package/operations/entry/elasticsearch/filtering/exec.d.ts +17 -0
  107. package/operations/entry/elasticsearch/filtering/exec.js +172 -0
  108. package/operations/entry/elasticsearch/filtering/exec.js.map +1 -0
  109. package/operations/entry/elasticsearch/filtering/index.d.ts +1 -0
  110. package/operations/entry/elasticsearch/filtering/index.js +16 -0
  111. package/operations/entry/elasticsearch/filtering/index.js.map +1 -0
  112. package/operations/entry/elasticsearch/filtering/path.d.ts +15 -0
  113. package/operations/entry/elasticsearch/filtering/path.js +44 -0
  114. package/operations/entry/elasticsearch/filtering/path.js.map +1 -0
  115. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.d.ts +2 -0
  116. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js +28 -0
  117. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js.map +1 -0
  118. package/operations/entry/elasticsearch/filtering/plugins/index.d.ts +1 -0
  119. package/operations/entry/elasticsearch/filtering/plugins/index.js +13 -0
  120. package/operations/entry/elasticsearch/filtering/plugins/index.js.map +1 -0
  121. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.d.ts +2 -0
  122. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js +65 -0
  123. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js.map +1 -0
  124. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.d.ts +2 -0
  125. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js +48 -0
  126. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js.map +1 -0
  127. package/operations/entry/elasticsearch/filtering/populated.d.ts +2 -0
  128. package/operations/entry/elasticsearch/filtering/populated.js +23 -0
  129. package/operations/entry/elasticsearch/filtering/populated.js.map +1 -0
  130. package/operations/entry/elasticsearch/filtering/values.d.ts +2 -0
  131. package/operations/entry/elasticsearch/filtering/values.js +22 -0
  132. package/operations/entry/elasticsearch/filtering/values.js.map +1 -0
  133. package/operations/entry/elasticsearch/fullTextSearch.d.ts +12 -0
  134. package/operations/entry/elasticsearch/fullTextSearch.js +89 -0
  135. package/operations/entry/elasticsearch/fullTextSearch.js.map +1 -0
  136. package/operations/entry/elasticsearch/fullTextSearchFields.d.ts +8 -0
  137. package/operations/entry/elasticsearch/fullTextSearchFields.js +25 -0
  138. package/operations/entry/elasticsearch/fullTextSearchFields.js.map +1 -0
  139. package/operations/entry/elasticsearch/initialQuery.d.ts +17 -0
  140. package/operations/entry/elasticsearch/initialQuery.js +103 -0
  141. package/operations/entry/elasticsearch/initialQuery.js.map +1 -0
  142. package/operations/entry/elasticsearch/keyword.d.ts +2 -0
  143. package/operations/entry/elasticsearch/keyword.js +34 -0
  144. package/operations/entry/elasticsearch/keyword.js.map +1 -0
  145. package/operations/entry/elasticsearch/plugins/bodyModifier.d.ts +9 -0
  146. package/operations/entry/elasticsearch/plugins/bodyModifier.js +16 -0
  147. package/operations/entry/elasticsearch/plugins/bodyModifier.js.map +1 -0
  148. package/operations/entry/elasticsearch/plugins/operator.d.ts +8 -0
  149. package/operations/entry/elasticsearch/plugins/operator.js +37 -0
  150. package/operations/entry/elasticsearch/plugins/operator.js.map +1 -0
  151. package/operations/entry/elasticsearch/plugins/queryModifier.d.ts +9 -0
  152. package/operations/entry/elasticsearch/plugins/queryModifier.js +16 -0
  153. package/operations/entry/elasticsearch/plugins/queryModifier.js.map +1 -0
  154. package/operations/entry/elasticsearch/plugins/search.d.ts +7 -0
  155. package/{helpers/searchPluginsList.js → operations/entry/elasticsearch/plugins/search.js} +8 -10
  156. package/operations/entry/elasticsearch/plugins/search.js.map +1 -0
  157. package/operations/entry/elasticsearch/plugins/sortModifier.d.ts +9 -0
  158. package/operations/entry/elasticsearch/plugins/sortModifier.js +16 -0
  159. package/operations/entry/elasticsearch/plugins/sortModifier.js.map +1 -0
  160. package/operations/entry/elasticsearch/sort.d.ts +12 -0
  161. package/operations/entry/elasticsearch/sort.js +82 -0
  162. package/operations/entry/elasticsearch/sort.js.map +1 -0
  163. package/operations/entry/elasticsearch/transformValueForSearch.d.ts +16 -0
  164. package/operations/entry/elasticsearch/transformValueForSearch.js +30 -0
  165. package/operations/entry/elasticsearch/transformValueForSearch.js.map +1 -0
  166. package/operations/entry/elasticsearch/types.d.ts +41 -0
  167. package/operations/entry/elasticsearch/types.js +5 -0
  168. package/operations/entry/elasticsearch/types.js.map +1 -0
  169. package/operations/entry/index.d.ts +2 -4
  170. package/operations/entry/index.js +457 -481
  171. package/operations/entry/index.js.map +1 -0
  172. package/operations/entry/keys.js +0 -9
  173. package/operations/entry/keys.js.map +1 -0
  174. package/operations/entry/recordType.d.ts +3 -0
  175. package/operations/entry/recordType.js +18 -0
  176. package/operations/entry/recordType.js.map +1 -0
  177. package/operations/group/index.d.ts +2 -2
  178. package/operations/group/index.js +10 -47
  179. package/operations/group/index.js.map +1 -0
  180. package/operations/model/index.d.ts +2 -2
  181. package/operations/model/index.js +34 -68
  182. package/operations/model/index.js.map +1 -0
  183. package/operations/settings/index.d.ts +2 -2
  184. package/operations/settings/index.js +7 -37
  185. package/operations/settings/index.js.map +1 -0
  186. package/operations/system/index.d.ts +2 -2
  187. package/operations/system/index.js +5 -28
  188. package/operations/system/index.js.map +1 -0
  189. package/package.json +24 -29
  190. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.d.ts +7 -3
  191. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js +9 -11
  192. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js.map +1 -0
  193. package/plugins/CmsEntryElasticsearchFieldPlugin.d.ts +3 -3
  194. package/plugins/CmsEntryElasticsearchFieldPlugin.js +3 -9
  195. package/plugins/CmsEntryElasticsearchFieldPlugin.js.map +1 -0
  196. package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.d.ts +23 -0
  197. package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js +28 -0
  198. package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js.map +1 -0
  199. package/plugins/CmsEntryElasticsearchIndexPlugin.d.ts +4 -0
  200. package/plugins/CmsEntryElasticsearchIndexPlugin.js +12 -0
  201. package/plugins/CmsEntryElasticsearchIndexPlugin.js.map +1 -0
  202. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.d.ts +30 -0
  203. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js +33 -0
  204. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js.map +1 -0
  205. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.d.ts +4 -3
  206. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js +9 -11
  207. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js.map +1 -0
  208. package/plugins/CmsEntryElasticsearchSortModifierPlugin.d.ts +4 -3
  209. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js +9 -11
  210. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js.map +1 -0
  211. package/plugins/CmsEntryFilterPlugin.d.ts +49 -0
  212. package/plugins/CmsEntryFilterPlugin.js +24 -0
  213. package/plugins/CmsEntryFilterPlugin.js.map +1 -0
  214. package/plugins/index.d.ts +7 -0
  215. package/plugins/index.js +82 -0
  216. package/plugins/index.js.map +1 -0
  217. package/types.d.ts +7 -34
  218. package/types.js +0 -18
  219. package/types.js.map +1 -0
  220. package/helpers/createElasticsearchQueryBody.d.ts +0 -11
  221. package/helpers/createElasticsearchQueryBody.js +0 -375
  222. package/helpers/fields.d.ts +0 -77
  223. package/helpers/fields.js +0 -174
  224. package/helpers/operatorPluginsList.d.ts +0 -7
  225. package/helpers/operatorPluginsList.js +0 -30
  226. package/helpers/searchPluginsList.d.ts +0 -6
  227. package/helpers/transformValueForSearch.d.ts +0 -9
  228. package/helpers/transformValueForSearch.js +0 -26
  229. package/operations/entry/elasticsearchFields.d.ts +0 -2
  230. package/operations/entry/elasticsearchFields.js +0 -32
  231. package/operations/entry/fields.d.ts +0 -3
  232. package/operations/entry/fields.js +0 -60
  233. package/operations/system/createElasticsearchTemplate.d.ts +0 -5
  234. package/operations/system/createElasticsearchTemplate.js +0 -62
  235. package/upgrades/index.d.ts +0 -2
  236. package/upgrades/index.js +0 -16
  237. package/upgrades/utils.d.ts +0 -1
  238. package/upgrades/utils.js +0 -16
  239. package/upgrades/v5.0.0/cleanDatabaseRecord.d.ts +0 -6
  240. package/upgrades/v5.0.0/cleanDatabaseRecord.js +0 -16
  241. package/upgrades/v5.0.0/createOldVersionIndiceName.d.ts +0 -2
  242. package/upgrades/v5.0.0/createOldVersionIndiceName.js +0 -12
  243. package/upgrades/v5.0.0/entryValueFixer.d.ts +0 -4
  244. package/upgrades/v5.0.0/entryValueFixer.js +0 -124
  245. package/upgrades/v5.0.0/fieldFinder.d.ts +0 -6
  246. package/upgrades/v5.0.0/fieldFinder.js +0 -42
  247. package/upgrades/v5.0.0/helpers.d.ts +0 -4
  248. package/upgrades/v5.0.0/helpers.js +0 -57
  249. package/upgrades/v5.0.0/index.d.ts +0 -4
  250. package/upgrades/v5.0.0/index.js +0 -232
  251. package/upgrades/v5.8.0/index.d.ts +0 -4
  252. package/upgrades/v5.8.0/index.js +0 -426
package/index.js CHANGED
@@ -1,63 +1,56 @@
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
14
  var _settings = require("./operations/settings");
17
-
18
15
  var _system = require("./operations/system");
19
-
20
16
  var _model = require("./operations/model");
21
-
22
17
  var _entry = require("./operations/entry");
23
-
24
18
  var _types = require("./types");
25
-
26
19
  var _table = require("./definitions/table");
27
-
28
20
  var _tableElasticsearch = require("./definitions/tableElasticsearch");
29
-
30
21
  var _group = require("./definitions/group");
31
-
32
22
  var _model2 = require("./definitions/model");
33
-
34
23
  var _entry2 = require("./definitions/entry");
35
-
36
24
  var _entryElasticsearch = require("./definitions/entryElasticsearch");
37
-
38
25
  var _system2 = require("./definitions/system");
39
-
40
26
  var _settings2 = require("./definitions/settings");
41
-
42
- var _createElasticsearchTemplate = require("./operations/system/createElasticsearchTemplate");
43
-
27
+ var _createElasticsearchIndex = require("./elasticsearch/createElasticsearchIndex");
44
28
  var _plugins = require("@webiny/plugins");
45
-
46
29
  var _group2 = require("./operations/group");
47
-
48
- var _operators = require("@webiny/api-elasticsearch/operators");
49
-
50
- var _elasticsearchFields = require("./operations/entry/elasticsearchFields");
51
-
30
+ var _apiElasticsearch = require("@webiny/api-elasticsearch");
31
+ var _indices = require("./elasticsearch/indices");
32
+ var _deleteElasticsearchIndex = require("./elasticsearch/deleteElasticsearchIndex");
33
+ var _plugins2 = require("./plugins");
34
+ Object.keys(_plugins2).forEach(function (key) {
35
+ if (key === "default" || key === "__esModule") return;
36
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
37
+ if (key in exports && exports[key] === _plugins2[key]) return;
38
+ Object.defineProperty(exports, key, {
39
+ enumerable: true,
40
+ get: function () {
41
+ return _plugins2[key];
42
+ }
43
+ });
44
+ });
45
+ var _plugins3 = require("./operations/entry/elasticsearch/filtering/plugins");
52
46
  const createStorageOperations = params => {
53
47
  const {
54
- attributes = {},
48
+ attributes,
55
49
  table,
56
50
  esTable,
57
51
  documentClient,
58
52
  elasticsearch,
59
- plugins: customPlugins,
60
- modelFieldToGraphQLPlugins
53
+ plugins: userPlugins
61
54
  } = params;
62
55
  const tableInstance = (0, _table.createTable)({
63
56
  table,
@@ -71,47 +64,38 @@ const createStorageOperations = params => {
71
64
  settings: (0, _settings2.createSettingsEntity)({
72
65
  entityName: _types.ENTITIES.SETTINGS,
73
66
  table: tableInstance,
74
- attributes: attributes[_types.ENTITIES.SETTINGS]
67
+ attributes: attributes ? attributes[_types.ENTITIES.SETTINGS] : {}
75
68
  }),
76
69
  system: (0, _system2.createSystemEntity)({
77
70
  entityName: _types.ENTITIES.SYSTEM,
78
71
  table: tableInstance,
79
- attributes: attributes[_types.ENTITIES.SYSTEM]
72
+ attributes: attributes ? attributes[_types.ENTITIES.SYSTEM] : {}
80
73
  }),
81
74
  groups: (0, _group.createGroupEntity)({
82
75
  entityName: _types.ENTITIES.GROUPS,
83
76
  table: tableInstance,
84
- attributes: attributes[_types.ENTITIES.GROUPS]
77
+ attributes: attributes ? attributes[_types.ENTITIES.GROUPS] : {}
85
78
  }),
86
79
  models: (0, _model2.createModelEntity)({
87
80
  entityName: _types.ENTITIES.MODELS,
88
81
  table: tableInstance,
89
- attributes: attributes[_types.ENTITIES.MODELS]
82
+ attributes: attributes ? attributes[_types.ENTITIES.MODELS] : {}
90
83
  }),
91
84
  entries: (0, _entry2.createEntryEntity)({
92
85
  entityName: _types.ENTITIES.ENTRIES,
93
86
  table: tableInstance,
94
- attributes: attributes[_types.ENTITIES.ENTRIES]
87
+ attributes: attributes ? attributes[_types.ENTITIES.ENTRIES] : {}
95
88
  }),
96
89
  entriesEs: (0, _entryElasticsearch.createEntryElasticsearchEntity)({
97
90
  entityName: _types.ENTITIES.ENTRIES_ES,
98
91
  table: tableElasticsearchInstance,
99
- attributes: attributes[_types.ENTITIES.ENTRIES_ES]
92
+ attributes: attributes ? attributes[_types.ENTITIES.ENTRIES_ES] : {}
100
93
  })
101
94
  };
102
95
  const plugins = new _plugins.PluginsContainer([
103
- /**
104
- * User defined custom plugins.
105
- */
106
- ...(customPlugins || []),
107
96
  /**
108
97
  * Plugins of type CmsModelFieldToGraphQLPlugin.
109
98
  */
110
- modelFieldToGraphQLPlugins,
111
- /**
112
- * Elasticsearch field definitions for the entry record.
113
- */
114
- _elasticsearchFields.elasticsearchFields,
115
99
  /**
116
100
  * DynamoDB filter plugins for the where conditions.
117
101
  */
@@ -119,7 +103,7 @@ const createStorageOperations = params => {
119
103
  /**
120
104
  * Elasticsearch operators.
121
105
  */
122
- (0, _operators.getElasticsearchOperators)(),
106
+ (0, _apiElasticsearch.getElasticsearchOperators)(),
123
107
  /**
124
108
  * Field plugins for DynamoDB.
125
109
  */
@@ -127,21 +111,100 @@ const createStorageOperations = params => {
127
111
  /**
128
112
  * Field plugins for Elasticsearch.
129
113
  */
130
- (0, _elasticsearch.default)()]);
114
+ (0, _elasticsearch.default)(),
115
+ /**
116
+ * Built-in Elasticsearch index templates.
117
+ */
118
+ (0, _indices.elasticsearchIndexPlugins)(),
119
+ /**
120
+ * Filter plugins used to apply filtering from where conditions to Elasticsearch query.
121
+ */
122
+ (0, _plugins3.createFilterPlugins)(),
123
+ /**
124
+ * User defined custom plugins.
125
+ * They are at the end because we can then override existing plugins.
126
+ */
127
+ ...(userPlugins || [])]);
131
128
  return {
132
- init: async cms => {
133
- cms.onBeforeSystemInstall.subscribe(async () => {
134
- await (0, _createElasticsearchTemplate.createElasticsearchTemplate)({
135
- elasticsearch
129
+ name: "dynamodb:elasticsearch",
130
+ beforeInit: async context => {
131
+ /**
132
+ * Attach the elasticsearch into context if it is not already attached.
133
+ */
134
+ if (!context.elasticsearch) {
135
+ context.elasticsearch = elasticsearch;
136
+ }
137
+ /**
138
+ * Pass the plugins to the parent context.
139
+ */
140
+ context.plugins.register([(0, _dynamoDb.default)()]);
141
+ /**
142
+ * Collect all required plugins from parent context.
143
+ */
144
+ const fieldPlugins = context.plugins.byType("cms-model-field-to-graphql");
145
+ plugins.register(fieldPlugins);
146
+ /**
147
+ * We need to get all the operator plugins from the main plugin container.
148
+ */
149
+ const elasticsearchOperatorPlugins = context.plugins.byType(_apiElasticsearch.ElasticsearchQueryBuilderOperatorPlugin.type);
150
+ plugins.register(elasticsearchOperatorPlugins);
151
+ /**
152
+ * We need to get all the query modifier plugins
153
+ */
154
+ const queryModifierPlugins = context.plugins.byType(_plugins2.CmsEntryElasticsearchQueryModifierPlugin.type);
155
+ plugins.register(queryModifierPlugins);
156
+ /**
157
+ * We need to get all the sort modifier plugins
158
+ */
159
+ const sortModifierPlugins = context.plugins.byType(_plugins2.CmsEntryElasticsearchSortModifierPlugin.type);
160
+ plugins.register(sortModifierPlugins);
161
+ /**
162
+ * We need to get all the body modifier plugins
163
+ */
164
+ const bodyModifierPlugins = context.plugins.byType(_plugins2.CmsEntryElasticsearchBodyModifierPlugin.type);
165
+ plugins.register(bodyModifierPlugins);
166
+ },
167
+ init: async context => {
168
+ /**
169
+ * We need to create indexes on before model create and on clone (create from).
170
+ * Other apps create indexes on locale creation.
171
+ */
172
+ context.cms.onModelBeforeCreate.subscribe(async ({
173
+ model
174
+ }) => {
175
+ await (0, _createElasticsearchIndex.createElasticsearchIndex)({
176
+ elasticsearch,
177
+ model,
178
+ plugins
179
+ });
180
+ });
181
+ context.cms.onModelBeforeCreateFrom.subscribe(async ({
182
+ model
183
+ }) => {
184
+ await (0, _createElasticsearchIndex.createElasticsearchIndex)({
185
+ elasticsearch,
186
+ model,
187
+ plugins
188
+ });
189
+ });
190
+ context.cms.onModelAfterDelete.subscribe(async ({
191
+ model
192
+ }) => {
193
+ await (0, _deleteElasticsearchIndex.deleteElasticsearchIndex)({
194
+ elasticsearch,
195
+ model
196
+ });
197
+ });
198
+ context.cms.onModelInitialize.subscribe(async ({
199
+ model
200
+ }) => {
201
+ await (0, _createElasticsearchIndex.createElasticsearchIndex)({
202
+ elasticsearch,
203
+ model,
204
+ plugins
136
205
  });
137
206
  });
138
207
  },
139
- plugins: [
140
- /**
141
- * Field plugins for DynamoDB.
142
- * We must pass them to the base application.
143
- */
144
- (0, _dynamoDb.default)()],
145
208
  getEntities: () => entities,
146
209
  getTable: () => tableInstance,
147
210
  getEsTable: () => tableElasticsearchInstance,
@@ -167,5 +230,4 @@ const createStorageOperations = params => {
167
230
  })
168
231
  };
169
232
  };
170
-
171
233
  exports.createStorageOperations = createStorageOperations;
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createStorageOperations","params","attributes","table","esTable","documentClient","elasticsearch","plugins","userPlugins","tableInstance","createTable","tableElasticsearchInstance","createElasticsearchTable","entities","settings","createSettingsEntity","entityName","ENTITIES","SETTINGS","system","createSystemEntity","SYSTEM","groups","createGroupEntity","GROUPS","models","createModelEntity","MODELS","entries","createEntryEntity","ENTRIES","entriesEs","createEntryElasticsearchEntity","ENTRIES_ES","PluginsContainer","dynamoDbValueFilters","getElasticsearchOperators","dynamoDbPlugins","elasticsearchPlugins","elasticsearchIndexPlugins","createFilterPlugins","name","beforeInit","context","register","fieldPlugins","byType","elasticsearchOperatorPlugins","ElasticsearchQueryBuilderOperatorPlugin","type","queryModifierPlugins","CmsEntryElasticsearchQueryModifierPlugin","sortModifierPlugins","CmsEntryElasticsearchSortModifierPlugin","bodyModifierPlugins","CmsEntryElasticsearchBodyModifierPlugin","init","cms","onModelBeforeCreate","subscribe","model","createElasticsearchIndex","onModelBeforeCreateFrom","onModelAfterDelete","deleteElasticsearchIndex","onModelInitialize","getEntities","getTable","getEsTable","createSystemStorageOperations","entity","createSettingsStorageOperations","createGroupsStorageOperations","createModelsStorageOperations","createEntriesStorageOperations","esEntity"],"sources":["index.ts"],"sourcesContent":["import dynamoDbValueFilters from \"@webiny/db-dynamodb/plugins/filters\";\nimport elasticsearchPlugins from \"./elasticsearch\";\nimport dynamoDbPlugins from \"./dynamoDb\";\nimport { createSettingsStorageOperations } from \"./operations/settings\";\nimport { createSystemStorageOperations } from \"./operations/system\";\nimport { createModelsStorageOperations } from \"./operations/model\";\nimport { createEntriesStorageOperations } from \"./operations/entry\";\nimport { ENTITIES, StorageOperationsFactory } 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 { createSettingsEntity } from \"~/definitions/settings\";\nimport { createElasticsearchIndex } from \"~/elasticsearch/createElasticsearchIndex\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { createGroupsStorageOperations } from \"~/operations/group\";\nimport {\n ElasticsearchQueryBuilderOperatorPlugin,\n getElasticsearchOperators\n} from \"@webiny/api-elasticsearch\";\nimport { elasticsearchIndexPlugins } from \"./elasticsearch/indices\";\nimport { deleteElasticsearchIndex } from \"./elasticsearch/deleteElasticsearchIndex\";\nimport { CmsModelFieldToGraphQLPlugin } from \"@webiny/api-headless-cms/types\";\nimport {\n CmsEntryElasticsearchBodyModifierPlugin,\n CmsEntryElasticsearchQueryModifierPlugin,\n CmsEntryElasticsearchSortModifierPlugin\n} from \"~/plugins\";\nimport { createFilterPlugins } from \"~/operations/entry/elasticsearch/filtering/plugins\";\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 settings: createSettingsEntity({\n entityName: ENTITIES.SETTINGS,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.SETTINGS] : {}\n }),\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 * Plugins of type CmsModelFieldToGraphQLPlugin.\n */\n /**\n * DynamoDB filter plugins for the where conditions.\n */\n dynamoDbValueFilters(),\n /**\n * Elasticsearch operators.\n */\n getElasticsearchOperators(),\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 return {\n name: \"dynamodb:elasticsearch\",\n beforeInit: async context => {\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([dynamoDbPlugins()]);\n /**\n * Collect all required plugins from parent context.\n */\n const fieldPlugins = context.plugins.byType<CmsModelFieldToGraphQLPlugin>(\n \"cms-model-field-to-graphql\"\n );\n plugins.register(fieldPlugins);\n /**\n * We need to get all the operator plugins from the main plugin container.\n */\n const elasticsearchOperatorPlugins =\n context.plugins.byType<ElasticsearchQueryBuilderOperatorPlugin>(\n ElasticsearchQueryBuilderOperatorPlugin.type\n );\n plugins.register(elasticsearchOperatorPlugins);\n /**\n * We need to get all the query modifier plugins\n */\n const queryModifierPlugins =\n context.plugins.byType<CmsEntryElasticsearchQueryModifierPlugin>(\n CmsEntryElasticsearchQueryModifierPlugin.type\n );\n plugins.register(queryModifierPlugins);\n /**\n * We need to get all the sort modifier plugins\n */\n const sortModifierPlugins =\n context.plugins.byType<CmsEntryElasticsearchSortModifierPlugin>(\n CmsEntryElasticsearchSortModifierPlugin.type\n );\n plugins.register(sortModifierPlugins);\n /**\n * We need to get all the body modifier plugins\n */\n const bodyModifierPlugins =\n context.plugins.byType<CmsEntryElasticsearchBodyModifierPlugin>(\n CmsEntryElasticsearchBodyModifierPlugin.type\n );\n plugins.register(bodyModifierPlugins);\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 context.cms.onModelBeforeCreate.subscribe(async ({ model }) => {\n await createElasticsearchIndex({\n elasticsearch,\n model,\n plugins\n });\n });\n context.cms.onModelBeforeCreateFrom.subscribe(async ({ model }) => {\n await createElasticsearchIndex({\n elasticsearch,\n model,\n plugins\n });\n });\n context.cms.onModelAfterDelete.subscribe(async ({ model }) => {\n await deleteElasticsearchIndex({\n elasticsearch,\n model\n });\n });\n\n context.cms.onModelInitialize.subscribe(async ({ model }) => {\n await createElasticsearchIndex({\n 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 settings: createSettingsStorageOperations({\n entity: entities.settings\n }),\n groups: createGroupsStorageOperations({\n entity: entities.groups,\n plugins\n }),\n models: createModelsStorageOperations({\n entity: entities.models,\n elasticsearch\n }),\n entries: createEntriesStorageOperations({\n entity: entities.entries,\n esEntity: entities.entriesEs,\n plugins,\n elasticsearch\n })\n };\n};\n"],"mappings":";;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAIA;AACA;AAEA;AAOA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AAFA;AAIO,MAAMA,uBAAiD,GAAGC,MAAM,IAAI;EACvE,MAAM;IACFC,UAAU;IACVC,KAAK;IACLC,OAAO;IACPC,cAAc;IACdC,aAAa;IACbC,OAAO,EAAEC;EACb,CAAC,GAAGP,MAAM;EAEV,MAAMQ,aAAa,GAAG,IAAAC,kBAAW,EAAC;IAC9BP,KAAK;IACLE;EACJ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,CAAC,CAAC;MACN,CAAC,CAAC;IACN,CAAC;IACD2D,WAAW,EAAE,MAAMrD,QAAQ;IAC3BsD,QAAQ,EAAE,MAAM1D,aAAa;IAC7B2D,UAAU,EAAE,MAAMzD,0BAA0B;IAC5CQ,MAAM,EAAE,IAAAkD,qCAA6B,EAAC;MAClCC,MAAM,EAAEzD,QAAQ,CAACM;IACrB,CAAC,CAAC;IACFL,QAAQ,EAAE,IAAAyD,yCAA+B,EAAC;MACtCD,MAAM,EAAEzD,QAAQ,CAACC;IACrB,CAAC,CAAC;IACFQ,MAAM,EAAE,IAAAkD,qCAA6B,EAAC;MAClCF,MAAM,EAAEzD,QAAQ,CAACS,MAAM;MACvBf;IACJ,CAAC,CAAC;IACFkB,MAAM,EAAE,IAAAgD,oCAA6B,EAAC;MAClCH,MAAM,EAAEzD,QAAQ,CAACY,MAAM;MACvBnB;IACJ,CAAC,CAAC;IACFsB,OAAO,EAAE,IAAA8C,qCAA8B,EAAC;MACpCJ,MAAM,EAAEzD,QAAQ,CAACe,OAAO;MACxB+C,QAAQ,EAAE9D,QAAQ,CAACkB,SAAS;MAC5BxB,OAAO;MACPD;IACJ,CAAC;EACL,CAAC;AACL,CAAC;AAAC"}
@@ -20,13 +20,13 @@ interface ClearLoaderParams {
20
20
  model: CmsModel;
21
21
  entry?: CmsEntry;
22
22
  }
23
- export interface Params {
23
+ export interface DataLoadersHandlerParams {
24
24
  entity: Entity<any>;
25
25
  }
26
26
  export declare class DataLoadersHandler {
27
27
  private readonly loaders;
28
28
  private readonly entity;
29
- constructor(params: any);
29
+ constructor(params: DataLoadersHandlerParams);
30
30
  getAllEntryRevisions(params: GetAllEntryRevisionsParams): Promise<CmsEntry[]>;
31
31
  clearAllEntryRevisions(params: ClearLoaderParams): void;
32
32
  getRevisionById(params: GetRevisionByIdParams): Promise<CmsEntry[]>;
@@ -35,6 +35,10 @@ export declare class DataLoadersHandler {
35
35
  clearPublishedRevisionByEntryId(params: ClearLoaderParams): void;
36
36
  getLatestRevisionByEntryId(params: GetLatestRevisionByEntryIdParams): Promise<CmsEntry[]>;
37
37
  clearLatestRevisionByEntryId(params: ClearLoaderParams): void;
38
+ /**
39
+ * TODO @ts-refactor
40
+ * Maybe pass on the generics to DataLoader definition?
41
+ */
38
42
  private getLoader;
39
43
  private loadMany;
40
44
  clearAll(params: Omit<ClearLoaderParams, "entry">): void;
@@ -1,32 +1,19 @@
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
  });
8
7
  exports.DataLoadersHandler = void 0;
9
-
8
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
10
9
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
10
  var _dataloader = _interopRequireDefault(require("dataloader"));
13
-
14
11
  var _error = _interopRequireDefault(require("@webiny/error"));
15
-
16
12
  var _query = require("@webiny/db-dynamodb/utils/query");
17
-
18
13
  var _keys = require("./keys");
19
-
20
14
  var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
21
-
22
15
  var _utils = require("@webiny/utils");
23
-
24
16
  var _batchRead = require("@webiny/db-dynamodb/utils/batchRead");
25
-
26
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
27
-
28
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
29
-
30
17
  const getAllEntryRevisions = params => {
31
18
  const {
32
19
  entity,
@@ -37,8 +24,7 @@ const getAllEntryRevisions = params => {
37
24
  locale
38
25
  } = model;
39
26
  return new _dataloader.default(async ids => {
40
- const results = [];
41
-
27
+ const results = {};
42
28
  for (const id of ids) {
43
29
  const queryAllParams = {
44
30
  entity,
@@ -52,14 +38,13 @@ const getAllEntryRevisions = params => {
52
38
  }
53
39
  };
54
40
  const items = await (0, _query.queryAll)(queryAllParams);
55
- const entries = (0, _cleanup.cleanupItems)(entity, items);
56
- results.push(entries);
41
+ results[id] = (0, _cleanup.cleanupItems)(entity, items);
57
42
  }
58
-
59
- return results;
43
+ return ids.map(id => {
44
+ return results[id] || [];
45
+ });
60
46
  });
61
47
  };
62
-
63
48
  const getRevisionById = params => {
64
49
  const {
65
50
  entity,
@@ -79,20 +64,24 @@ const getRevisionById = params => {
79
64
  const {
80
65
  version
81
66
  } = (0, _utils.parseIdentifier)(id);
67
+ if (!version) {
68
+ return collection;
69
+ }
82
70
  const sortKey = (0, _keys.createRevisionSortKey)({
83
71
  version
84
72
  });
85
73
  const keys = `${partitionKey}__${sortKey}`;
86
-
87
74
  if (collection[keys]) {
88
75
  return collection;
89
76
  }
90
-
91
77
  collection[keys] = entity.getBatch({
92
78
  PK: partitionKey,
93
79
  SK: sortKey
94
80
  });
95
81
  return collection;
82
+ /**
83
+ * We use any because there is no type for the return type.
84
+ */
96
85
  }, {});
97
86
  const records = await (0, _batchRead.batchReadAll)({
98
87
  table: entity.table,
@@ -106,7 +95,6 @@ const getRevisionById = params => {
106
95
  });
107
96
  });
108
97
  };
109
-
110
98
  const getPublishedRevisionByEntryId = params => {
111
99
  const {
112
100
  entity,
@@ -124,16 +112,17 @@ const getPublishedRevisionByEntryId = params => {
124
112
  locale,
125
113
  id
126
114
  });
127
-
128
115
  if (collection[partitionKey]) {
129
116
  return collection;
130
117
  }
131
-
132
118
  collection[partitionKey] = entity.getBatch({
133
119
  PK: partitionKey,
134
120
  SK: publishedKey
135
121
  });
136
122
  return collection;
123
+ /**
124
+ * We use any because there is no type for the return type.
125
+ */
137
126
  }, {});
138
127
  const records = await (0, _batchRead.batchReadAll)({
139
128
  table: entity.table,
@@ -150,7 +139,6 @@ const getPublishedRevisionByEntryId = params => {
150
139
  });
151
140
  });
152
141
  };
153
-
154
142
  const getLatestRevisionByEntryId = params => {
155
143
  const {
156
144
  entity,
@@ -168,16 +156,17 @@ const getLatestRevisionByEntryId = params => {
168
156
  locale,
169
157
  id
170
158
  });
171
-
172
159
  if (collection[partitionKey]) {
173
160
  return collection;
174
161
  }
175
-
176
162
  collection[partitionKey] = entity.getBatch({
177
163
  PK: partitionKey,
178
164
  SK: latestKey
179
165
  });
180
166
  return collection;
167
+ /**
168
+ * We use any because there is no type for the return type.
169
+ */
181
170
  }, {});
182
171
  const records = await (0, _batchRead.batchReadAll)({
183
172
  table: entity.table,
@@ -194,7 +183,6 @@ const getLatestRevisionByEntryId = params => {
194
183
  });
195
184
  });
196
185
  };
197
-
198
186
  const dataLoaders = {
199
187
  getAllEntryRevisions,
200
188
  getRevisionById,
@@ -202,53 +190,46 @@ const dataLoaders = {
202
190
  getLatestRevisionByEntryId
203
191
  };
204
192
  const loaderNames = Object.keys(dataLoaders);
205
-
206
193
  class DataLoadersHandler {
207
194
  constructor(params) {
208
195
  (0, _defineProperty2.default)(this, "loaders", new Map());
209
196
  (0, _defineProperty2.default)(this, "entity", void 0);
210
197
  this.entity = params.entity;
211
198
  }
212
-
213
199
  async getAllEntryRevisions(params) {
214
200
  return await this.loadMany("getAllEntryRevisions", params, params.ids);
215
201
  }
216
-
217
202
  clearAllEntryRevisions(params) {
218
203
  this.clear("getAllEntryRevisions", params);
219
204
  }
220
-
221
205
  async getRevisionById(params) {
222
206
  return await this.loadMany("getRevisionById", params, params.ids);
223
207
  }
224
-
225
208
  clearRevisionById(params) {
226
209
  this.clear("getRevisionById", params);
227
210
  }
228
-
229
211
  async getPublishedRevisionByEntryId(params) {
230
212
  return await this.loadMany("getPublishedRevisionByEntryId", params, params.ids);
231
213
  }
232
-
233
214
  clearPublishedRevisionByEntryId(params) {
234
215
  this.clear("getPublishedRevisionByEntryId", params);
235
216
  }
236
-
237
217
  async getLatestRevisionByEntryId(params) {
238
218
  return await this.loadMany("getLatestRevisionByEntryId", params, params.ids);
239
219
  }
240
-
241
220
  clearLatestRevisionByEntryId(params) {
242
221
  this.clear("getLatestRevisionByEntryId", params);
243
222
  }
244
-
223
+ /**
224
+ * TODO @ts-refactor
225
+ * Maybe pass on the generics to DataLoader definition?
226
+ */
245
227
  getLoader(name, params) {
246
228
  if (!dataLoaders[name]) {
247
229
  throw new _error.default("Unknown data loader.", "UNKNOWN_DATA_LOADER", {
248
230
  name
249
231
  });
250
232
  }
251
-
252
233
  const {
253
234
  model
254
235
  } = params;
@@ -257,56 +238,47 @@ class DataLoadersHandler {
257
238
  locale
258
239
  } = model;
259
240
  const loaderKey = `${name}-${tenant}-${locale}-${model.modelId}`;
260
-
261
241
  if (!this.loaders.has(loaderKey)) {
262
- this.loaders.set(loaderKey, dataLoaders[name](_objectSpread(_objectSpread({}, params), {}, {
242
+ this.loaders.set(loaderKey, dataLoaders[name]((0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
263
243
  entity: this.entity
264
244
  })));
265
245
  }
266
-
267
246
  return this.loaders.get(loaderKey);
268
247
  }
269
-
270
248
  async loadMany(loader, params, ids) {
271
249
  let results;
272
-
273
250
  try {
274
251
  results = await this.getLoader(loader, params).loadMany(ids);
275
-
276
252
  if (Array.isArray(results) === true) {
277
253
  return results.reduce((acc, res) => {
278
254
  if (Array.isArray(res) === false) {
279
255
  if (res && res.message) {
280
- throw new _error.default(res.message, res.code, _objectSpread(_objectSpread({}, res), {}, {
256
+ throw new _error.default(res.message, res.code, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, res), {}, {
281
257
  data: JSON.stringify(res.data || {})
282
258
  }));
283
259
  }
284
-
285
- throw new _error.default("Result from the data loader must be an array of arrays which contain requested items.", "DATA_LOADER_RESULTS_ERROR", _objectSpread(_objectSpread({}, params), {}, {
260
+ throw new _error.default("Result from the data loader must be an array of arrays which contain requested items.", "DATA_LOADER_RESULTS_ERROR", (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
286
261
  loader
287
262
  }));
288
263
  }
289
-
290
264
  acc.push(...res);
291
265
  return acc;
292
266
  }, []);
293
267
  }
294
268
  } catch (ex) {
295
- throw new _error.default(ex.message || "Data loader error.", ex.code || "DATA_LOADER_ERROR", _objectSpread(_objectSpread({
269
+ throw new _error.default(ex.message || "Data loader error.", ex.code || "DATA_LOADER_ERROR", (0, _objectSpread2.default)((0, _objectSpread2.default)({
296
270
  error: ex
297
271
  }, params), {}, {
298
272
  loader,
299
273
  ids
300
274
  }));
301
275
  }
302
-
303
276
  throw new _error.default(`Data loader did not return array of items or empty array.`, "INVALID_DATA_LOADER_RESULT", {
304
277
  loader,
305
278
  ids,
306
279
  results
307
280
  });
308
281
  }
309
-
310
282
  clearAll(params) {
311
283
  for (const name of loaderNames) {
312
284
  const loader = this.getLoader(name, params);
@@ -317,19 +289,15 @@ class DataLoadersHandler {
317
289
  * Helper to clear the cache for certain data loader.
318
290
  * If entry is passed then clear target key only.
319
291
  */
320
-
321
-
322
292
  clear(name, params) {
323
293
  const {
324
294
  entry
325
295
  } = params;
326
296
  const loader = this.getLoader(name, params);
327
-
328
297
  if (!entry) {
329
298
  loader.clearAll();
330
299
  return;
331
300
  }
332
-
333
301
  loader.clear(entry.id);
334
302
  const {
335
303
  tenant,
@@ -341,7 +309,5 @@ class DataLoadersHandler {
341
309
  id: entry.id
342
310
  }));
343
311
  }
344
-
345
312
  }
346
-
347
313
  exports.DataLoadersHandler = DataLoadersHandler;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getAllEntryRevisions","params","entity","model","tenant","locale","DataLoader","ids","results","id","queryAllParams","partitionKey","createPartitionKey","options","beginsWith","items","queryAll","cleanupItems","map","getRevisionById","queries","reduce","collection","version","parseIdentifier","sortKey","createRevisionSortKey","keys","getBatch","PK","SK","records","batchReadAll","table","Object","values","filter","item","getPublishedRevisionByEntryId","publishedKey","createPublishedSortKey","entryId","getLatestRevisionByEntryId","latestKey","createLatestSortKey","dataLoaders","loaderNames","DataLoadersHandler","constructor","Map","loadMany","clearAllEntryRevisions","clear","clearRevisionById","clearPublishedRevisionByEntryId","clearLatestRevisionByEntryId","getLoader","name","WebinyError","loaderKey","modelId","loaders","has","set","get","loader","Array","isArray","acc","res","message","code","data","JSON","stringify","push","ex","error","clearAll","entry"],"sources":["dataLoaders.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport WebinyError from \"@webiny/error\";\nimport { CmsEntry, CmsModel } from \"@webiny/api-headless-cms/types\";\nimport { Entity } from \"dynamodb-toolbox\";\nimport { queryAll, QueryAllParams } from \"@webiny/db-dynamodb/utils/query\";\nimport {\n createLatestSortKey,\n createPartitionKey,\n createPublishedSortKey,\n createRevisionSortKey\n} from \"./keys\";\nimport { cleanupItems } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { batchReadAll } from \"@webiny/db-dynamodb/utils/batchRead\";\n\nconst getAllEntryRevisions = (params: LoaderParams) => {\n const { entity, model } = params;\n const { tenant, locale } = model;\n return new DataLoader<string, CmsEntry[]>(async (ids: readonly string[]) => {\n const results: Record<string, CmsEntry[]> = {};\n for (const id of ids) {\n const queryAllParams: QueryAllParams = {\n entity,\n partitionKey: createPartitionKey({\n tenant,\n locale,\n id\n }),\n options: {\n beginsWith: \"REV#\"\n }\n };\n const items = await queryAll<CmsEntry>(queryAllParams);\n\n results[id] = cleanupItems(entity, items);\n }\n\n return ids.map(id => {\n return results[id] || [];\n });\n });\n};\n\nconst getRevisionById = (params: LoaderParams) => {\n const { entity, model } = params;\n const { locale, tenant } = model;\n\n return new DataLoader<string, CmsEntry[]>(async (ids: readonly string[]) => {\n const queries = ids.reduce((collection, id) => {\n const partitionKey = createPartitionKey({\n tenant,\n locale,\n id\n });\n const { version } = parseIdentifier(id);\n if (!version) {\n return collection;\n }\n const sortKey = createRevisionSortKey({\n version\n });\n const keys = `${partitionKey}__${sortKey}`;\n if (collection[keys]) {\n return collection;\n }\n\n collection[keys] = entity.getBatch({\n PK: partitionKey,\n SK: sortKey\n });\n\n return collection;\n /**\n * We use any because there is no type for the return type.\n */\n }, {} as Record<string, any>);\n\n const records = await batchReadAll<CmsEntry>({\n table: entity.table,\n items: Object.values(queries)\n });\n const items = cleanupItems(entity, records);\n\n return ids.map(id => {\n return items.filter(item => {\n return id === item.id;\n });\n });\n });\n};\n\nconst getPublishedRevisionByEntryId = (params: LoaderParams) => {\n const { entity, model } = params;\n const { locale, tenant } = model;\n\n const publishedKey = createPublishedSortKey();\n\n return new DataLoader<string, CmsEntry[]>(async (ids: readonly string[]) => {\n const queries = ids.reduce((collection, id) => {\n const partitionKey = createPartitionKey({\n tenant,\n locale,\n id\n });\n if (collection[partitionKey]) {\n return collection;\n }\n collection[partitionKey] = entity.getBatch({\n PK: partitionKey,\n SK: publishedKey\n });\n return collection;\n /**\n * We use any because there is no type for the return type.\n */\n }, {} as Record<string, any>);\n\n const records = await batchReadAll<CmsEntry>({\n table: entity.table,\n items: Object.values(queries)\n });\n const items = cleanupItems(entity, records);\n\n return ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return items.filter(item => {\n return entryId === item.entryId;\n });\n });\n });\n};\n\nconst getLatestRevisionByEntryId = (params: LoaderParams) => {\n const { entity, model } = params;\n const { locale, tenant } = model;\n\n const latestKey = createLatestSortKey();\n\n return new DataLoader<string, CmsEntry[]>(async (ids: readonly string[]) => {\n const queries = ids.reduce((collection, id) => {\n const partitionKey = createPartitionKey({\n tenant,\n locale,\n id\n });\n if (collection[partitionKey]) {\n return collection;\n }\n collection[partitionKey] = entity.getBatch({\n PK: partitionKey,\n SK: latestKey\n });\n return collection;\n /**\n * We use any because there is no type for the return type.\n */\n }, {} as Record<string, any>);\n\n const records = await batchReadAll<CmsEntry>({\n table: entity.table,\n items: Object.values(queries)\n });\n const items = cleanupItems(entity, records);\n\n return ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return items.filter(item => {\n return entryId === item.entryId;\n });\n });\n });\n};\n\nconst dataLoaders: Record<Loaders, any> = {\n getAllEntryRevisions,\n getRevisionById,\n getPublishedRevisionByEntryId,\n getLatestRevisionByEntryId\n};\n\nexport interface GetAllEntryRevisionsParams {\n ids: readonly string[];\n model: CmsModel;\n}\n\nexport interface GetRevisionByIdParams {\n ids: readonly string[];\n model: CmsModel;\n}\n\nexport interface GetPublishedRevisionByEntryIdParams {\n ids: readonly string[];\n model: CmsModel;\n}\n\nexport interface GetLatestRevisionByEntryIdParams {\n ids: readonly string[];\n model: CmsModel;\n}\n\ninterface LoaderParams {\n entity: Entity<any>;\n model: CmsModel;\n}\n\ninterface GetLoaderParams {\n model: CmsModel;\n}\n\ninterface ClearLoaderParams {\n model: CmsModel;\n entry?: CmsEntry;\n}\n\ntype Loaders =\n | \"getAllEntryRevisions\"\n | \"getRevisionById\"\n | \"getPublishedRevisionByEntryId\"\n | \"getLatestRevisionByEntryId\";\n\nconst loaderNames = Object.keys(dataLoaders) as Loaders[];\n\nexport interface DataLoadersHandlerParams {\n entity: Entity<any>;\n}\nexport class DataLoadersHandler {\n private readonly loaders: Map<string, DataLoader<any, any>> = new Map();\n private readonly entity: Entity<any>;\n\n public constructor(params: DataLoadersHandlerParams) {\n this.entity = params.entity;\n }\n\n public async getAllEntryRevisions(params: GetAllEntryRevisionsParams): Promise<CmsEntry[]> {\n return await this.loadMany(\"getAllEntryRevisions\", params, params.ids);\n }\n\n public clearAllEntryRevisions(params: ClearLoaderParams): void {\n this.clear(\"getAllEntryRevisions\", params);\n }\n\n public async getRevisionById(params: GetRevisionByIdParams): Promise<CmsEntry[]> {\n return await this.loadMany(\"getRevisionById\", params, params.ids);\n }\n\n public clearRevisionById(params: ClearLoaderParams): void {\n this.clear(\"getRevisionById\", params);\n }\n\n public async getPublishedRevisionByEntryId(\n params: GetPublishedRevisionByEntryIdParams\n ): Promise<CmsEntry[]> {\n return await this.loadMany(\"getPublishedRevisionByEntryId\", params, params.ids);\n }\n public clearPublishedRevisionByEntryId(params: ClearLoaderParams): void {\n this.clear(\"getPublishedRevisionByEntryId\", params);\n }\n\n public async getLatestRevisionByEntryId(\n params: GetLatestRevisionByEntryIdParams\n ): Promise<CmsEntry[]> {\n return await this.loadMany(\"getLatestRevisionByEntryId\", params, params.ids);\n }\n\n public clearLatestRevisionByEntryId(params: ClearLoaderParams): void {\n this.clear(\"getLatestRevisionByEntryId\", params);\n }\n /**\n * TODO @ts-refactor\n * Maybe pass on the generics to DataLoader definition?\n */\n private getLoader(name: Loaders, params: GetLoaderParams): DataLoader<any, any> {\n if (!dataLoaders[name]) {\n throw new WebinyError(\"Unknown data loader.\", \"UNKNOWN_DATA_LOADER\", {\n name\n });\n }\n const { model } = params;\n const { tenant, locale } = model;\n const loaderKey = `${name}-${tenant}-${locale}-${model.modelId}`;\n if (!this.loaders.has(loaderKey)) {\n this.loaders.set(\n loaderKey,\n dataLoaders[name]({\n ...params,\n entity: this.entity\n })\n );\n }\n return this.loaders.get(loaderKey) as DataLoader<any, any>;\n }\n\n private async loadMany(\n loader: Loaders,\n params: GetLoaderParams,\n ids: readonly string[]\n ): Promise<CmsEntry[]> {\n let results;\n try {\n results = await this.getLoader(loader, params).loadMany(ids);\n if (Array.isArray(results) === true) {\n return results.reduce((acc, res) => {\n if (Array.isArray(res) === false) {\n if (res && res.message) {\n throw new WebinyError(res.message, res.code, {\n ...res,\n data: JSON.stringify(res.data || {})\n });\n }\n throw new WebinyError(\n \"Result from the data loader must be an array of arrays which contain requested items.\",\n \"DATA_LOADER_RESULTS_ERROR\",\n {\n ...params,\n loader\n }\n );\n }\n acc.push(...res);\n return acc;\n }, []);\n }\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Data loader error.\",\n ex.code || \"DATA_LOADER_ERROR\",\n {\n error: ex,\n ...params,\n loader,\n ids\n }\n );\n }\n throw new WebinyError(\n `Data loader did not return array of items or empty array.`,\n \"INVALID_DATA_LOADER_RESULT\",\n {\n loader,\n ids,\n results\n }\n );\n }\n\n public clearAll(params: Omit<ClearLoaderParams, \"entry\">): void {\n for (const name of loaderNames) {\n const loader = this.getLoader(name, params);\n loader.clearAll();\n }\n }\n /**\n * Helper to clear the cache for certain data loader.\n * If entry is passed then clear target key only.\n */\n private clear(name: Loaders, params: ClearLoaderParams): void {\n const { entry } = params;\n const loader = this.getLoader(name, params);\n if (!entry) {\n loader.clearAll();\n return;\n }\n loader.clear(entry.id);\n const { tenant, locale } = params.model;\n loader.clear(\n createPartitionKey({\n tenant,\n locale,\n id: entry.id\n })\n );\n }\n}\n"],"mappings":";;;;;;;;;AAAA;AACA;AAGA;AACA;AAMA;AACA;AACA;AAEA,MAAMA,oBAAoB,GAAIC,MAAoB,IAAK;EACnD,MAAM;IAAEC,MAAM;IAAEC;EAAM,CAAC,GAAGF,MAAM;EAChC,MAAM;IAAEG,MAAM;IAAEC;EAAO,CAAC,GAAGF,KAAK;EAChC,OAAO,IAAIG,mBAAU,CAAqB,MAAOC,GAAsB,IAAK;IACxE,MAAMC,OAAmC,GAAG,CAAC,CAAC;IAC9C,KAAK,MAAMC,EAAE,IAAIF,GAAG,EAAE;MAClB,MAAMG,cAA8B,GAAG;QACnCR,MAAM;QACNS,YAAY,EAAE,IAAAC,wBAAkB,EAAC;UAC7BR,MAAM;UACNC,MAAM;UACNI;QACJ,CAAC,CAAC;QACFI,OAAO,EAAE;UACLC,UAAU,EAAE;QAChB;MACJ,CAAC;MACD,MAAMC,KAAK,GAAG,MAAM,IAAAC,eAAQ,EAAWN,cAAc,CAAC;MAEtDF,OAAO,CAACC,EAAE,CAAC,GAAG,IAAAQ,qBAAY,EAACf,MAAM,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