@webiny/api-headless-cms-ddb-es 0.0.0-ee-vpcs.549378cf03

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 (228) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +35 -0
  3. package/configurations.d.ts +12 -0
  4. package/configurations.js +43 -0
  5. package/configurations.js.map +1 -0
  6. package/definitions/entry.d.ts +8 -0
  7. package/definitions/entry.js +90 -0
  8. package/definitions/entry.js.map +1 -0
  9. package/definitions/entryElasticsearch.d.ts +8 -0
  10. package/definitions/entryElasticsearch.js +42 -0
  11. package/definitions/entryElasticsearch.js.map +1 -0
  12. package/definitions/group.d.ts +8 -0
  13. package/definitions/group.js +70 -0
  14. package/definitions/group.js.map +1 -0
  15. package/definitions/model.d.ts +8 -0
  16. package/definitions/model.js +97 -0
  17. package/definitions/model.js.map +1 -0
  18. package/definitions/settings.d.ts +8 -0
  19. package/definitions/settings.js +58 -0
  20. package/definitions/settings.js.map +1 -0
  21. package/definitions/system.d.ts +8 -0
  22. package/definitions/system.js +46 -0
  23. package/definitions/system.js.map +1 -0
  24. package/definitions/table.d.ts +8 -0
  25. package/definitions/table.js +24 -0
  26. package/definitions/table.js.map +1 -0
  27. package/definitions/tableElasticsearch.d.ts +8 -0
  28. package/definitions/tableElasticsearch.js +24 -0
  29. package/definitions/tableElasticsearch.js.map +1 -0
  30. package/dynamoDb/index.d.ts +2 -0
  31. package/dynamoDb/index.js +16 -0
  32. package/dynamoDb/index.js.map +1 -0
  33. package/dynamoDb/storage/date.d.ts +3 -0
  34. package/dynamoDb/storage/date.js +99 -0
  35. package/dynamoDb/storage/date.js.map +1 -0
  36. package/dynamoDb/storage/longText.d.ts +10 -0
  37. package/dynamoDb/storage/longText.js +108 -0
  38. package/dynamoDb/storage/longText.js.map +1 -0
  39. package/dynamoDb/storage/richText.d.ts +7 -0
  40. package/dynamoDb/storage/richText.js +128 -0
  41. package/dynamoDb/storage/richText.js.map +1 -0
  42. package/elasticsearch/createElasticsearchIndex.d.ts +9 -0
  43. package/elasticsearch/createElasticsearchIndex.js +60 -0
  44. package/elasticsearch/createElasticsearchIndex.js.map +1 -0
  45. package/elasticsearch/deleteElasticsearchIndex.d.ts +8 -0
  46. package/elasticsearch/deleteElasticsearchIndex.js +43 -0
  47. package/elasticsearch/deleteElasticsearchIndex.js.map +1 -0
  48. package/elasticsearch/index.d.ts +2 -0
  49. package/elasticsearch/index.js +16 -0
  50. package/elasticsearch/index.js.map +1 -0
  51. package/elasticsearch/indexing/dateTimeIndexing.d.ts +3 -0
  52. package/elasticsearch/indexing/dateTimeIndexing.js +103 -0
  53. package/elasticsearch/indexing/dateTimeIndexing.js.map +1 -0
  54. package/elasticsearch/indexing/defaultFieldIndexing.d.ts +3 -0
  55. package/elasticsearch/indexing/defaultFieldIndexing.js +47 -0
  56. package/elasticsearch/indexing/defaultFieldIndexing.js.map +1 -0
  57. package/elasticsearch/indexing/index.d.ts +2 -0
  58. package/elasticsearch/indexing/index.js +24 -0
  59. package/elasticsearch/indexing/index.js.map +1 -0
  60. package/elasticsearch/indexing/longTextIndexing.d.ts +7 -0
  61. package/elasticsearch/indexing/longTextIndexing.js +52 -0
  62. package/elasticsearch/indexing/longTextIndexing.js.map +1 -0
  63. package/elasticsearch/indexing/numberIndexing.d.ts +3 -0
  64. package/elasticsearch/indexing/numberIndexing.js +48 -0
  65. package/elasticsearch/indexing/numberIndexing.js.map +1 -0
  66. package/elasticsearch/indexing/objectIndexing.d.ts +12 -0
  67. package/elasticsearch/indexing/objectIndexing.js +223 -0
  68. package/elasticsearch/indexing/objectIndexing.js.map +1 -0
  69. package/elasticsearch/indexing/richTextIndexing.d.ts +3 -0
  70. package/elasticsearch/indexing/richTextIndexing.js +34 -0
  71. package/elasticsearch/indexing/richTextIndexing.js.map +1 -0
  72. package/elasticsearch/indices/base.d.ts +2 -0
  73. package/elasticsearch/indices/base.js +15 -0
  74. package/elasticsearch/indices/base.js.map +1 -0
  75. package/elasticsearch/indices/index.d.ts +1 -0
  76. package/elasticsearch/indices/index.js +16 -0
  77. package/elasticsearch/indices/index.js.map +1 -0
  78. package/elasticsearch/indices/japanese.d.ts +2 -0
  79. package/elasticsearch/indices/japanese.js +16 -0
  80. package/elasticsearch/indices/japanese.js.map +1 -0
  81. package/elasticsearch/search/index.d.ts +3 -0
  82. package/elasticsearch/search/index.js +14 -0
  83. package/elasticsearch/search/index.js.map +1 -0
  84. package/elasticsearch/search/refSearch.d.ts +2 -0
  85. package/elasticsearch/search/refSearch.js +35 -0
  86. package/elasticsearch/search/refSearch.js.map +1 -0
  87. package/elasticsearch/search/timeSearch.d.ts +2 -0
  88. package/elasticsearch/search/timeSearch.js +33 -0
  89. package/elasticsearch/search/timeSearch.js.map +1 -0
  90. package/helpers/entryIndexHelpers.d.ts +18 -0
  91. package/helpers/entryIndexHelpers.js +204 -0
  92. package/helpers/entryIndexHelpers.js.map +1 -0
  93. package/helpers/index.d.ts +1 -0
  94. package/helpers/index.js +18 -0
  95. package/helpers/index.js.map +1 -0
  96. package/index.d.ts +3 -0
  97. package/index.js +275 -0
  98. package/index.js.map +1 -0
  99. package/operations/entry/dataLoaders.d.ts +51 -0
  100. package/operations/entry/dataLoaders.js +365 -0
  101. package/operations/entry/dataLoaders.js.map +1 -0
  102. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.d.ts +18 -0
  103. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js +34 -0
  104. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js.map +1 -0
  105. package/operations/entry/elasticsearch/body.d.ts +13 -0
  106. package/operations/entry/elasticsearch/body.js +162 -0
  107. package/operations/entry/elasticsearch/body.js.map +1 -0
  108. package/operations/entry/elasticsearch/fields.d.ts +9 -0
  109. package/operations/entry/elasticsearch/fields.js +248 -0
  110. package/operations/entry/elasticsearch/fields.js.map +1 -0
  111. package/operations/entry/elasticsearch/filtering/applyFiltering.d.ts +8 -0
  112. package/operations/entry/elasticsearch/filtering/applyFiltering.js +66 -0
  113. package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +1 -0
  114. package/operations/entry/elasticsearch/filtering/exec.d.ts +17 -0
  115. package/operations/entry/elasticsearch/filtering/exec.js +215 -0
  116. package/operations/entry/elasticsearch/filtering/exec.js.map +1 -0
  117. package/operations/entry/elasticsearch/filtering/index.d.ts +1 -0
  118. package/operations/entry/elasticsearch/filtering/index.js +18 -0
  119. package/operations/entry/elasticsearch/filtering/index.js.map +1 -0
  120. package/operations/entry/elasticsearch/filtering/path.d.ts +15 -0
  121. package/operations/entry/elasticsearch/filtering/path.js +52 -0
  122. package/operations/entry/elasticsearch/filtering/path.js.map +1 -0
  123. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.d.ts +2 -0
  124. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js +35 -0
  125. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js.map +1 -0
  126. package/operations/entry/elasticsearch/filtering/plugins/index.d.ts +1 -0
  127. package/operations/entry/elasticsearch/filtering/plugins/index.js +18 -0
  128. package/operations/entry/elasticsearch/filtering/plugins/index.js.map +1 -0
  129. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.d.ts +2 -0
  130. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js +78 -0
  131. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js.map +1 -0
  132. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.d.ts +2 -0
  133. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js +58 -0
  134. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js.map +1 -0
  135. package/operations/entry/elasticsearch/filtering/populated.d.ts +2 -0
  136. package/operations/entry/elasticsearch/filtering/populated.js +30 -0
  137. package/operations/entry/elasticsearch/filtering/populated.js.map +1 -0
  138. package/operations/entry/elasticsearch/filtering/values.d.ts +2 -0
  139. package/operations/entry/elasticsearch/filtering/values.js +28 -0
  140. package/operations/entry/elasticsearch/filtering/values.js.map +1 -0
  141. package/operations/entry/elasticsearch/fullTextSearch.d.ts +9 -0
  142. package/operations/entry/elasticsearch/fullTextSearch.js +34 -0
  143. package/operations/entry/elasticsearch/fullTextSearch.js.map +1 -0
  144. package/operations/entry/elasticsearch/fullTextSearchFields.d.ts +8 -0
  145. package/operations/entry/elasticsearch/fullTextSearchFields.js +52 -0
  146. package/operations/entry/elasticsearch/fullTextSearchFields.js.map +1 -0
  147. package/operations/entry/elasticsearch/initialQuery.d.ts +17 -0
  148. package/operations/entry/elasticsearch/initialQuery.js +117 -0
  149. package/operations/entry/elasticsearch/initialQuery.js.map +1 -0
  150. package/operations/entry/elasticsearch/keyword.d.ts +2 -0
  151. package/operations/entry/elasticsearch/keyword.js +38 -0
  152. package/operations/entry/elasticsearch/keyword.js.map +1 -0
  153. package/operations/entry/elasticsearch/plugins/bodyModifier.d.ts +9 -0
  154. package/operations/entry/elasticsearch/plugins/bodyModifier.js +19 -0
  155. package/operations/entry/elasticsearch/plugins/bodyModifier.js.map +1 -0
  156. package/operations/entry/elasticsearch/plugins/operator.d.ts +8 -0
  157. package/operations/entry/elasticsearch/plugins/operator.js +45 -0
  158. package/operations/entry/elasticsearch/plugins/operator.js.map +1 -0
  159. package/operations/entry/elasticsearch/plugins/queryModifier.d.ts +9 -0
  160. package/operations/entry/elasticsearch/plugins/queryModifier.js +19 -0
  161. package/operations/entry/elasticsearch/plugins/queryModifier.js.map +1 -0
  162. package/operations/entry/elasticsearch/plugins/search.d.ts +7 -0
  163. package/operations/entry/elasticsearch/plugins/search.js +30 -0
  164. package/operations/entry/elasticsearch/plugins/search.js.map +1 -0
  165. package/operations/entry/elasticsearch/plugins/sortModifier.d.ts +9 -0
  166. package/operations/entry/elasticsearch/plugins/sortModifier.js +19 -0
  167. package/operations/entry/elasticsearch/plugins/sortModifier.js.map +1 -0
  168. package/operations/entry/elasticsearch/sort.d.ts +12 -0
  169. package/operations/entry/elasticsearch/sort.js +92 -0
  170. package/operations/entry/elasticsearch/sort.js.map +1 -0
  171. package/operations/entry/elasticsearch/transformValueForSearch.d.ts +16 -0
  172. package/operations/entry/elasticsearch/transformValueForSearch.js +34 -0
  173. package/operations/entry/elasticsearch/transformValueForSearch.js.map +1 -0
  174. package/operations/entry/elasticsearch/types.d.ts +41 -0
  175. package/operations/entry/elasticsearch/types.js +5 -0
  176. package/operations/entry/elasticsearch/types.js.map +1 -0
  177. package/operations/entry/elasticsearchFields.d.ts +2 -0
  178. package/operations/entry/elasticsearchFields.js +38 -0
  179. package/operations/entry/elasticsearchFields.js.map +1 -0
  180. package/operations/entry/index.d.ts +11 -0
  181. package/operations/entry/index.js +1251 -0
  182. package/operations/entry/index.js.map +1 -0
  183. package/operations/entry/keys.d.ts +12 -0
  184. package/operations/entry/keys.js +40 -0
  185. package/operations/entry/keys.js.map +1 -0
  186. package/operations/entry/recordType.d.ts +3 -0
  187. package/operations/entry/recordType.js +24 -0
  188. package/operations/entry/recordType.js.map +1 -0
  189. package/operations/group/index.d.ts +8 -0
  190. package/operations/group/index.js +195 -0
  191. package/operations/group/index.js.map +1 -0
  192. package/operations/model/index.d.ts +8 -0
  193. package/operations/model/index.js +204 -0
  194. package/operations/model/index.js.map +1 -0
  195. package/operations/settings/index.d.ts +6 -0
  196. package/operations/settings/index.js +135 -0
  197. package/operations/settings/index.js.map +1 -0
  198. package/operations/system/index.d.ts +6 -0
  199. package/operations/system/index.js +99 -0
  200. package/operations/system/index.js.map +1 -0
  201. package/package.json +68 -0
  202. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.d.ts +20 -0
  203. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js +24 -0
  204. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js.map +1 -0
  205. package/plugins/CmsEntryElasticsearchFieldPlugin.d.ts +12 -0
  206. package/plugins/CmsEntryElasticsearchFieldPlugin.js +24 -0
  207. package/plugins/CmsEntryElasticsearchFieldPlugin.js.map +1 -0
  208. package/plugins/CmsEntryElasticsearchIndexPlugin.d.ts +4 -0
  209. package/plugins/CmsEntryElasticsearchIndexPlugin.js +17 -0
  210. package/plugins/CmsEntryElasticsearchIndexPlugin.js.map +1 -0
  211. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.d.ts +30 -0
  212. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js +43 -0
  213. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js.map +1 -0
  214. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.d.ts +17 -0
  215. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js +24 -0
  216. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js.map +1 -0
  217. package/plugins/CmsEntryElasticsearchSortModifierPlugin.d.ts +17 -0
  218. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js +24 -0
  219. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js.map +1 -0
  220. package/plugins/CmsEntryFilterPlugin.d.ts +49 -0
  221. package/plugins/CmsEntryFilterPlugin.js +31 -0
  222. package/plugins/CmsEntryFilterPlugin.js.map +1 -0
  223. package/plugins/index.d.ts +6 -0
  224. package/plugins/index.js +83 -0
  225. package/plugins/index.js.map +1 -0
  226. package/types.d.ts +164 -0
  227. package/types.js +47 -0
  228. package/types.js.map +1 -0
@@ -0,0 +1,365 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.DataLoadersHandler = void 0;
9
+
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
+
12
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
+
14
+ var _dataloader = _interopRequireDefault(require("dataloader"));
15
+
16
+ var _error = _interopRequireDefault(require("@webiny/error"));
17
+
18
+ var _query = require("@webiny/db-dynamodb/utils/query");
19
+
20
+ var _keys = require("./keys");
21
+
22
+ var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
23
+
24
+ var _utils = require("@webiny/utils");
25
+
26
+ var _batchRead = require("@webiny/db-dynamodb/utils/batchRead");
27
+
28
+ const getAllEntryRevisions = params => {
29
+ const {
30
+ entity,
31
+ model
32
+ } = params;
33
+ const {
34
+ tenant,
35
+ locale
36
+ } = model;
37
+ return new _dataloader.default(async ids => {
38
+ const results = {};
39
+
40
+ for (const id of ids) {
41
+ const queryAllParams = {
42
+ entity,
43
+ partitionKey: (0, _keys.createPartitionKey)({
44
+ tenant,
45
+ locale,
46
+ id
47
+ }),
48
+ options: {
49
+ beginsWith: "REV#"
50
+ }
51
+ };
52
+ const items = await (0, _query.queryAll)(queryAllParams);
53
+ results[id] = (0, _cleanup.cleanupItems)(entity, items);
54
+ }
55
+
56
+ return ids.map(id => {
57
+ return results[id] || [];
58
+ });
59
+ });
60
+ };
61
+
62
+ const getRevisionById = params => {
63
+ const {
64
+ entity,
65
+ model
66
+ } = params;
67
+ const {
68
+ locale,
69
+ tenant
70
+ } = model;
71
+ return new _dataloader.default(async ids => {
72
+ const queries = ids.reduce((collection, id) => {
73
+ const partitionKey = (0, _keys.createPartitionKey)({
74
+ tenant,
75
+ locale,
76
+ id
77
+ });
78
+ const {
79
+ version
80
+ } = (0, _utils.parseIdentifier)(id);
81
+
82
+ if (!version) {
83
+ return collection;
84
+ }
85
+
86
+ const sortKey = (0, _keys.createRevisionSortKey)({
87
+ version
88
+ });
89
+ const keys = `${partitionKey}__${sortKey}`;
90
+
91
+ if (collection[keys]) {
92
+ return collection;
93
+ }
94
+
95
+ collection[keys] = entity.getBatch({
96
+ PK: partitionKey,
97
+ SK: sortKey
98
+ });
99
+ return collection;
100
+ /**
101
+ * We use any because there is no type for the return type.
102
+ */
103
+ }, {});
104
+ const records = await (0, _batchRead.batchReadAll)({
105
+ table: entity.table,
106
+ items: Object.values(queries)
107
+ });
108
+ const items = (0, _cleanup.cleanupItems)(entity, records);
109
+ return ids.map(id => {
110
+ return items.filter(item => {
111
+ return id === item.id;
112
+ });
113
+ });
114
+ });
115
+ };
116
+
117
+ const getPublishedRevisionByEntryId = params => {
118
+ const {
119
+ entity,
120
+ model
121
+ } = params;
122
+ const {
123
+ locale,
124
+ tenant
125
+ } = model;
126
+ const publishedKey = (0, _keys.createPublishedSortKey)();
127
+ return new _dataloader.default(async ids => {
128
+ const queries = ids.reduce((collection, id) => {
129
+ const partitionKey = (0, _keys.createPartitionKey)({
130
+ tenant,
131
+ locale,
132
+ id
133
+ });
134
+
135
+ if (collection[partitionKey]) {
136
+ return collection;
137
+ }
138
+
139
+ collection[partitionKey] = entity.getBatch({
140
+ PK: partitionKey,
141
+ SK: publishedKey
142
+ });
143
+ return collection;
144
+ /**
145
+ * We use any because there is no type for the return type.
146
+ */
147
+ }, {});
148
+ const records = await (0, _batchRead.batchReadAll)({
149
+ table: entity.table,
150
+ items: Object.values(queries)
151
+ });
152
+ const items = (0, _cleanup.cleanupItems)(entity, records);
153
+ return ids.map(id => {
154
+ const {
155
+ id: entryId
156
+ } = (0, _utils.parseIdentifier)(id);
157
+ return items.filter(item => {
158
+ return entryId === item.entryId;
159
+ });
160
+ });
161
+ });
162
+ };
163
+
164
+ const getLatestRevisionByEntryId = params => {
165
+ const {
166
+ entity,
167
+ model
168
+ } = params;
169
+ const {
170
+ locale,
171
+ tenant
172
+ } = model;
173
+ const latestKey = (0, _keys.createLatestSortKey)();
174
+ return new _dataloader.default(async ids => {
175
+ const queries = ids.reduce((collection, id) => {
176
+ const partitionKey = (0, _keys.createPartitionKey)({
177
+ tenant,
178
+ locale,
179
+ id
180
+ });
181
+
182
+ if (collection[partitionKey]) {
183
+ return collection;
184
+ }
185
+
186
+ collection[partitionKey] = entity.getBatch({
187
+ PK: partitionKey,
188
+ SK: latestKey
189
+ });
190
+ return collection;
191
+ /**
192
+ * We use any because there is no type for the return type.
193
+ */
194
+ }, {});
195
+ const records = await (0, _batchRead.batchReadAll)({
196
+ table: entity.table,
197
+ items: Object.values(queries)
198
+ });
199
+ const items = (0, _cleanup.cleanupItems)(entity, records);
200
+ return ids.map(id => {
201
+ const {
202
+ id: entryId
203
+ } = (0, _utils.parseIdentifier)(id);
204
+ return items.filter(item => {
205
+ return entryId === item.entryId;
206
+ });
207
+ });
208
+ });
209
+ };
210
+
211
+ const dataLoaders = {
212
+ getAllEntryRevisions,
213
+ getRevisionById,
214
+ getPublishedRevisionByEntryId,
215
+ getLatestRevisionByEntryId
216
+ };
217
+ const loaderNames = Object.keys(dataLoaders);
218
+
219
+ class DataLoadersHandler {
220
+ constructor(params) {
221
+ (0, _defineProperty2.default)(this, "loaders", new Map());
222
+ (0, _defineProperty2.default)(this, "entity", void 0);
223
+ this.entity = params.entity;
224
+ }
225
+
226
+ async getAllEntryRevisions(params) {
227
+ return await this.loadMany("getAllEntryRevisions", params, params.ids);
228
+ }
229
+
230
+ clearAllEntryRevisions(params) {
231
+ this.clear("getAllEntryRevisions", params);
232
+ }
233
+
234
+ async getRevisionById(params) {
235
+ return await this.loadMany("getRevisionById", params, params.ids);
236
+ }
237
+
238
+ clearRevisionById(params) {
239
+ this.clear("getRevisionById", params);
240
+ }
241
+
242
+ async getPublishedRevisionByEntryId(params) {
243
+ return await this.loadMany("getPublishedRevisionByEntryId", params, params.ids);
244
+ }
245
+
246
+ clearPublishedRevisionByEntryId(params) {
247
+ this.clear("getPublishedRevisionByEntryId", params);
248
+ }
249
+
250
+ async getLatestRevisionByEntryId(params) {
251
+ return await this.loadMany("getLatestRevisionByEntryId", params, params.ids);
252
+ }
253
+
254
+ clearLatestRevisionByEntryId(params) {
255
+ this.clear("getLatestRevisionByEntryId", params);
256
+ }
257
+ /**
258
+ * TODO @ts-refactor
259
+ * Maybe pass on the generics to DataLoader definition?
260
+ */
261
+
262
+
263
+ getLoader(name, params) {
264
+ if (!dataLoaders[name]) {
265
+ throw new _error.default("Unknown data loader.", "UNKNOWN_DATA_LOADER", {
266
+ name
267
+ });
268
+ }
269
+
270
+ const {
271
+ model
272
+ } = params;
273
+ const {
274
+ tenant,
275
+ locale
276
+ } = model;
277
+ const loaderKey = `${name}-${tenant}-${locale}-${model.modelId}`;
278
+
279
+ if (!this.loaders.has(loaderKey)) {
280
+ this.loaders.set(loaderKey, dataLoaders[name]((0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
281
+ entity: this.entity
282
+ })));
283
+ }
284
+
285
+ return this.loaders.get(loaderKey);
286
+ }
287
+
288
+ async loadMany(loader, params, ids) {
289
+ let results;
290
+
291
+ try {
292
+ results = await this.getLoader(loader, params).loadMany(ids);
293
+
294
+ if (Array.isArray(results) === true) {
295
+ return results.reduce((acc, res) => {
296
+ if (Array.isArray(res) === false) {
297
+ if (res && res.message) {
298
+ throw new _error.default(res.message, res.code, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, res), {}, {
299
+ data: JSON.stringify(res.data || {})
300
+ }));
301
+ }
302
+
303
+ 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), {}, {
304
+ loader
305
+ }));
306
+ }
307
+
308
+ acc.push(...res);
309
+ return acc;
310
+ }, []);
311
+ }
312
+ } catch (ex) {
313
+ throw new _error.default(ex.message || "Data loader error.", ex.code || "DATA_LOADER_ERROR", (0, _objectSpread2.default)((0, _objectSpread2.default)({
314
+ error: ex
315
+ }, params), {}, {
316
+ loader,
317
+ ids
318
+ }));
319
+ }
320
+
321
+ throw new _error.default(`Data loader did not return array of items or empty array.`, "INVALID_DATA_LOADER_RESULT", {
322
+ loader,
323
+ ids,
324
+ results
325
+ });
326
+ }
327
+
328
+ clearAll(params) {
329
+ for (const name of loaderNames) {
330
+ const loader = this.getLoader(name, params);
331
+ loader.clearAll();
332
+ }
333
+ }
334
+ /**
335
+ * Helper to clear the cache for certain data loader.
336
+ * If entry is passed then clear target key only.
337
+ */
338
+
339
+
340
+ clear(name, params) {
341
+ const {
342
+ entry
343
+ } = params;
344
+ const loader = this.getLoader(name, params);
345
+
346
+ if (!entry) {
347
+ loader.clearAll();
348
+ return;
349
+ }
350
+
351
+ loader.clear(entry.id);
352
+ const {
353
+ tenant,
354
+ locale
355
+ } = params.model;
356
+ loader.clear((0, _keys.createPartitionKey)({
357
+ tenant,
358
+ locale,
359
+ id: entry.id
360
+ }));
361
+ }
362
+
363
+ }
364
+
365
+ 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,MAAD,IAA0B;EACnD,MAAM;IAAEC,MAAF;IAAUC;EAAV,IAAoBF,MAA1B;EACA,MAAM;IAAEG,MAAF;IAAUC;EAAV,IAAqBF,KAA3B;EACA,OAAO,IAAIG,mBAAJ,CAAmC,MAAOC,GAAP,IAAkC;IACxE,MAAMC,OA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AAOQ,EAAP,EAAW;MACT,MAAM,IAAIlB,cAAJ,CACFkB,EAAE,CAACN,OAAH,IAAc,oBADZ,EAEFM,EAAE,CAACL,IAAH,IAAW,mBAFT;QAIEM,KAAK,EAAED;MAJT,GAKK3E,MALL;QAMEgE,MANF;QAOE1D;MAPF,GAAN;IAUH;;IACD,MAAM,IAAImD,cAAJ,CACD,2DADC,EAEF,4BAFE,EAGF;MACIO,MADJ;MAEI1D,GAFJ;MAGIC;IAHJ,CAHE,CAAN;EASH;;EAEMsE,QAAQ,CAAC7E,MAAD,EAAiD;IAC5D,KAAK,MAAMwD,IAAX,IAAmBX,WAAnB,EAAgC;MAC5B,MAAMmB,MAAM,GAAG,KAAKT,SAAL,CAAeC,IAAf,EAAqBxD,MAArB,CAAf;MACAgE,MAAM,CAACa,QAAP;IACH;EACJ;EACD;AACJ;AACA;AACA;;;EACY1B,KAAK,CAACK,IAAD,EAAgBxD,MAAhB,EAAiD;IAC1D,MAAM;MAAE8E;IAAF,IAAY9E,MAAlB;IACA,MAAMgE,MAAM,GAAG,KAAKT,SAAL,CAAeC,IAAf,EAAqBxD,MAArB,CAAf;;IACA,IAAI,CAAC8E,KAAL,EAAY;MACRd,MAAM,CAACa,QAAP;MACA;IACH;;IACDb,MAAM,CAACb,KAAP,CAAa2B,KAAK,CAACtE,EAAnB;IACA,MAAM;MAAEL,MAAF;MAAUC;IAAV,IAAqBJ,MAAM,CAACE,KAAlC;IACA8D,MAAM,CAACb,KAAP,CACI,IAAAxC,wBAAA,EAAmB;MACfR,MADe;MAEfC,MAFe;MAGfI,EAAE,EAAEsE,KAAK,CAACtE;IAHK,CAAnB,CADJ;EAOH;;AAlJ2B"}
@@ -0,0 +1,18 @@
1
+ import { BoolQueryConfig } from "@webiny/api-elasticsearch/types";
2
+ /**
3
+ * This function will assign a minimum_should_match for the query if conditions are met:
4
+ * * should is an array
5
+ * * it is not empty
6
+ * * minimum_should_match is not already set
7
+ *
8
+ *
9
+ * By the default we set it to 1 as we want at least one OR condition to produce results.
10
+ *
11
+ * Users can modify minimum_should_match value via the body or query modification plugins.
12
+ */
13
+ interface Params {
14
+ query: BoolQueryConfig;
15
+ value?: number;
16
+ }
17
+ export declare const assignMinimumShouldMatchToQuery: ({ query, value }: Params) => void;
18
+ export {};
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.assignMinimumShouldMatchToQuery = void 0;
7
+
8
+ /**
9
+ * This function will assign a minimum_should_match for the query if conditions are met:
10
+ * * should is an array
11
+ * * it is not empty
12
+ * * minimum_should_match is not already set
13
+ *
14
+ *
15
+ * By the default we set it to 1 as we want at least one OR condition to produce results.
16
+ *
17
+ * Users can modify minimum_should_match value via the body or query modification plugins.
18
+ */
19
+ const assignMinimumShouldMatchToQuery = ({
20
+ query,
21
+ value = 1
22
+ }) => {
23
+ if (!Array.isArray(query.should)) {
24
+ return;
25
+ } else if (query.should.length === 0) {
26
+ return;
27
+ } else if (query.minimum_should_match) {
28
+ return;
29
+ }
30
+
31
+ query.minimum_should_match = value > 0 ? value : 1;
32
+ };
33
+
34
+ exports.assignMinimumShouldMatchToQuery = assignMinimumShouldMatchToQuery;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["assignMinimumShouldMatchToQuery","query","value","Array","isArray","should","length","minimum_should_match"],"sources":["assignMinimumShouldMatchToQuery.ts"],"sourcesContent":["import { BoolQueryConfig } from \"@webiny/api-elasticsearch/types\";\n\n/**\n * This function will assign a minimum_should_match for the query if conditions are met:\n * * should is an array\n * * it is not empty\n * * minimum_should_match is not already set\n *\n *\n * By the default we set it to 1 as we want at least one OR condition to produce results.\n *\n * Users can modify minimum_should_match value via the body or query modification plugins.\n */\ninterface Params {\n query: BoolQueryConfig;\n value?: number;\n}\nexport const assignMinimumShouldMatchToQuery = ({ query, value = 1 }: Params): void => {\n if (!Array.isArray(query.should)) {\n return;\n } else if (query.should.length === 0) {\n return;\n } else if (query.minimum_should_match) {\n return;\n }\n query.minimum_should_match = value > 0 ? value : 1;\n};\n"],"mappings":";;;;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAKO,MAAMA,+BAA+B,GAAG,CAAC;EAAEC,KAAF;EAASC,KAAK,GAAG;AAAjB,CAAD,KAAwC;EACnF,IAAI,CAACC,KAAK,CAACC,OAAN,CAAcH,KAAK,CAACI,MAApB,CAAL,EAAkC;IAC9B;EACH,CAFD,MAEO,IAAIJ,KAAK,CAACI,MAAN,CAAaC,MAAb,KAAwB,CAA5B,EAA+B;IAClC;EACH,CAFM,MAEA,IAAIL,KAAK,CAACM,oBAAV,EAAgC;IACnC;EACH;;EACDN,KAAK,CAACM,oBAAN,GAA6BL,KAAK,GAAG,CAAR,GAAYA,KAAZ,GAAoB,CAAjD;AACH,CATM"}
@@ -0,0 +1,13 @@
1
+ import { PluginsContainer } from "@webiny/plugins";
2
+ import { CmsEntryListParams, CmsEntryListWhere, CmsModel } from "@webiny/api-headless-cms/types";
3
+ import { PrimitiveValue, SearchBody } from "@webiny/api-elasticsearch/types";
4
+ interface Params {
5
+ plugins: PluginsContainer;
6
+ model: CmsModel;
7
+ params: Omit<CmsEntryListParams, "where" | "after"> & {
8
+ where: CmsEntryListWhere;
9
+ after?: PrimitiveValue[];
10
+ };
11
+ }
12
+ export declare const createElasticsearchBody: ({ plugins, model, params }: Params) => SearchBody;
13
+ export {};
@@ -0,0 +1,162 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createElasticsearchBody = void 0;
7
+
8
+ var _fields = require("./fields");
9
+
10
+ var _fullTextSearchFields = require("./fullTextSearchFields");
11
+
12
+ var _initialQuery = require("./initialQuery");
13
+
14
+ var _fullTextSearch = require("./fullTextSearch");
15
+
16
+ var _queryModifier = require("./plugins/queryModifier");
17
+
18
+ var _sortModifier = require("./plugins/sortModifier");
19
+
20
+ var _bodyModifier = require("./plugins/bodyModifier");
21
+
22
+ var _sort = require("./sort");
23
+
24
+ var _filtering = require("./filtering");
25
+
26
+ var _assignMinimumShouldMatchToQuery = require("./assignMinimumShouldMatchToQuery");
27
+
28
+ const createElasticsearchBody = ({
29
+ plugins,
30
+ model,
31
+ params
32
+ }) => {
33
+ const {
34
+ fields,
35
+ search: term,
36
+ where,
37
+ sort: initialSort,
38
+ after,
39
+ limit
40
+ } = params;
41
+ /**
42
+ * We need the model fields constructed as a key -> field value, so we do not need to iterate through array when we require some field.
43
+ */
44
+
45
+ const modelFields = (0, _fields.createModelFields)({
46
+ plugins,
47
+ fields: model.fields
48
+ });
49
+ /**
50
+ * We need the query modifier plugins.
51
+ */
52
+
53
+ const queryModifierPlugins = (0, _queryModifier.createQueryModifierPluginList)({
54
+ plugins,
55
+ model
56
+ });
57
+ /**
58
+ * We need the sort modifier plugins.
59
+ */
60
+
61
+ const sortModifierPlugins = (0, _sortModifier.createSortModifierPluginList)({
62
+ plugins,
63
+ model
64
+ });
65
+ /**
66
+ * We need the body modifier plugins.
67
+ */
68
+
69
+ const bodyModifierPlugins = (0, _bodyModifier.createBodyModifierPluginList)({
70
+ plugins,
71
+ model
72
+ });
73
+ /**
74
+ * We need the fields which we can search through via the full text search.
75
+ *
76
+ */
77
+
78
+ const fullTextSearchFields = (0, _fullTextSearchFields.createFullTextSearchFields)({
79
+ model,
80
+ term,
81
+ fields
82
+ });
83
+ /**
84
+ * The initial elasticsearch query where we attach some default conditions we always need.
85
+ */
86
+
87
+ const query = (0, _initialQuery.createInitialQuery)({
88
+ where,
89
+ model
90
+ });
91
+ /**
92
+ * Apply the full text search, if term is set.
93
+ */
94
+
95
+ (0, _fullTextSearch.applyFullTextSearch)({
96
+ query,
97
+ term,
98
+ fields: fullTextSearchFields
99
+ });
100
+ const execFiltering = (0, _filtering.createExecFiltering)({
101
+ model,
102
+ fields: modelFields,
103
+ plugins
104
+ });
105
+ execFiltering({
106
+ where,
107
+ query
108
+ });
109
+
110
+ for (const pl of queryModifierPlugins) {
111
+ pl.modifyQuery({
112
+ query,
113
+ model,
114
+ where
115
+ });
116
+ }
117
+
118
+ const sort = (0, _sort.createElasticsearchSort)({
119
+ plugins,
120
+ sort: initialSort,
121
+ modelFields,
122
+ model
123
+ });
124
+
125
+ for (const pl of sortModifierPlugins) {
126
+ pl.modifySort({
127
+ sort,
128
+ model
129
+ });
130
+ }
131
+
132
+ const boolQuery = {
133
+ must: query.must.length > 0 ? query.must : undefined,
134
+ must_not: query.must_not.length > 0 ? query.must_not : undefined,
135
+ should: query.should.length > 0 ? query.should : undefined,
136
+ filter: query.filter.length > 0 ? query.filter : undefined
137
+ };
138
+ (0, _assignMinimumShouldMatchToQuery.assignMinimumShouldMatchToQuery)({
139
+ query: boolQuery
140
+ });
141
+ const body = {
142
+ query: {
143
+ bool: boolQuery
144
+ },
145
+ sort,
146
+ size: (limit || 0) + 1,
147
+ search_after: after,
148
+ track_total_hits: true
149
+ };
150
+
151
+ for (const pl of bodyModifierPlugins) {
152
+ pl.modifyBody({
153
+ body,
154
+ model,
155
+ where
156
+ });
157
+ }
158
+
159
+ return body;
160
+ };
161
+
162
+ exports.createElasticsearchBody = createElasticsearchBody;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createElasticsearchBody","plugins","model","params","fields","search","term","where","sort","initialSort","after","limit","modelFields","createModelFields","queryModifierPlugins","createQueryModifierPluginList","sortModifierPlugins","createSortModifierPluginList","bodyModifierPlugins","createBodyModifierPluginList","fullTextSearchFields","createFullTextSearchFields","query","createInitialQuery","applyFullTextSearch","execFiltering","createExecFiltering","pl","modifyQuery","createElasticsearchSort","modifySort","boolQuery","must","length","undefined","must_not","should","filter","assignMinimumShouldMatchToQuery","body","bool","size","search_after","track_total_hits","modifyBody"],"sources":["body.ts"],"sourcesContent":["import { PluginsContainer } from \"@webiny/plugins\";\nimport { CmsEntryListParams, CmsEntryListWhere, CmsModel } from \"@webiny/api-headless-cms/types\";\nimport { createModelFields } from \"./fields\";\nimport { createFullTextSearchFields } from \"./fullTextSearchFields\";\nimport { createInitialQuery } from \"./initialQuery\";\nimport { applyFullTextSearch } from \"./fullTextSearch\";\nimport { createQueryModifierPluginList } from \"./plugins/queryModifier\";\nimport { createSortModifierPluginList } from \"./plugins/sortModifier\";\nimport { createBodyModifierPluginList } from \"./plugins/bodyModifier\";\nimport { createElasticsearchSort } from \"./sort\";\nimport { PrimitiveValue, SearchBody, BoolQueryConfig } from \"@webiny/api-elasticsearch/types\";\nimport { createExecFiltering } from \"./filtering\";\nimport { assignMinimumShouldMatchToQuery } from \"./assignMinimumShouldMatchToQuery\";\n\ninterface Params {\n plugins: PluginsContainer;\n model: CmsModel;\n params: Omit<CmsEntryListParams, \"where\" | \"after\"> & {\n where: CmsEntryListWhere;\n after?: PrimitiveValue[];\n };\n}\nexport const createElasticsearchBody = ({ plugins, model, params }: Params): SearchBody => {\n const { fields, search: term, where, sort: initialSort, after, limit } = params;\n /**\n * We need the model fields constructed as a key -> field value, so we do not need to iterate through array when we require some field.\n */\n const modelFields = createModelFields({\n plugins,\n fields: model.fields\n });\n\n /**\n * We need the query modifier plugins.\n */\n const queryModifierPlugins = createQueryModifierPluginList({\n plugins,\n model\n });\n /**\n * We need the sort modifier plugins.\n */\n const sortModifierPlugins = createSortModifierPluginList({\n plugins,\n model\n });\n /**\n * We need the body modifier plugins.\n */\n const bodyModifierPlugins = createBodyModifierPluginList({\n plugins,\n model\n });\n /**\n * We need the fields which we can search through via the full text search.\n *\n */\n const fullTextSearchFields = createFullTextSearchFields({\n model,\n term,\n fields\n });\n /**\n * The initial elasticsearch query where we attach some default conditions we always need.\n */\n const query = createInitialQuery({\n where,\n model\n });\n /**\n * Apply the full text search, if term is set.\n */\n applyFullTextSearch({\n query,\n term,\n fields: fullTextSearchFields\n });\n\n const execFiltering = createExecFiltering({\n model,\n fields: modelFields,\n plugins\n });\n\n execFiltering({\n where,\n query\n });\n\n for (const pl of queryModifierPlugins) {\n pl.modifyQuery({ query, model, where });\n }\n\n const sort = createElasticsearchSort({\n plugins,\n sort: initialSort,\n modelFields,\n model\n });\n\n for (const pl of sortModifierPlugins) {\n pl.modifySort({\n sort,\n model\n });\n }\n\n const boolQuery: BoolQueryConfig = {\n must: query.must.length > 0 ? query.must : undefined,\n must_not: query.must_not.length > 0 ? query.must_not : undefined,\n should: query.should.length > 0 ? query.should : undefined,\n filter: query.filter.length > 0 ? query.filter : undefined\n };\n\n assignMinimumShouldMatchToQuery({\n query: boolQuery\n });\n\n const body: SearchBody = {\n query: {\n bool: boolQuery\n },\n sort,\n size: (limit || 0) + 1,\n search_after: after,\n track_total_hits: true\n };\n\n for (const pl of bodyModifierPlugins) {\n pl.modifyBody({\n body,\n model,\n where\n });\n }\n\n return body;\n};\n"],"mappings":";;;;;;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AAUO,MAAMA,uBAAuB,GAAG,CAAC;EAAEC,OAAF;EAAWC,KAAX;EAAkBC;AAAlB,CAAD,KAAoD;EACvF,MAAM;IAAEC,MAAF;IAAUC,MAAM,EAAEC,IAAlB;IAAwBC,KAAxB;IAA+BC,IAAI,EAAEC,WAArC;IAAkDC,KAAlD;IAAyDC;EAAzD,IAAmER,MAAzE;EACA;AACJ;AACA;;EACI,MAAMS,WAAW,GAAG,IAAAC,yBAAA,EAAkB;IAClCZ,OADkC;IAElCG,MAAM,EAAEF,KAAK,CAACE;EAFoB,CAAlB,CAApB;EAKA;AACJ;AACA;;EACI,MAAMU,oBAAoB,GAAG,IAAAC,4CAAA,EAA8B;IACvDd,OADuD;IAEvDC;EAFuD,CAA9B,CAA7B;EAIA;AACJ;AACA;;EACI,MAAMc,mBAAmB,GAAG,IAAAC,0CAAA,EAA6B;IACrDhB,OADqD;IAErDC;EAFqD,CAA7B,CAA5B;EAIA;AACJ;AACA;;EACI,MAAMgB,mBAAmB,GAAG,IAAAC,0CAAA,EAA6B;IACrDlB,OADqD;IAErDC;EAFqD,CAA7B,CAA5B;EAIA;AAC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AA0BX,KAAK,CAACc,MAAhC,GAAyCF,SAHlB;IAI/BG,MAAM,EAAEf,KAAK,CAACe,MAAN,CAAaJ,MAAb,GAAsB,CAAtB,GAA0BX,KAAK,CAACe,MAAhC,GAAyCH;EAJlB,CAAnC;EAOA,IAAAI,gEAAA,EAAgC;IAC5BhB,KAAK,EAAES;EADqB,CAAhC;EAIA,MAAMQ,IAAgB,GAAG;IACrBjB,KAAK,EAAE;MACHkB,IAAI,EAAET;IADH,CADc;IAIrBvB,IAJqB;IAKrBiC,IAAI,EAAE,CAAC9B,KAAK,IAAI,CAAV,IAAe,CALA;IAMrB+B,YAAY,EAAEhC,KANO;IAOrBiC,gBAAgB,EAAE;EAPG,CAAzB;;EAUA,KAAK,MAAMhB,EAAX,IAAiBT,mBAAjB,EAAsC;IAClCS,EAAE,CAACiB,UAAH,CAAc;MACVL,IADU;MAEVrC,KAFU;MAGVK;IAHU,CAAd;EAKH;;EAED,OAAOgC,IAAP;AACH,CAnHM"}
@@ -0,0 +1,9 @@
1
+ import { PluginsContainer } from "@webiny/plugins";
2
+ import { CmsModelField } from "@webiny/api-headless-cms/types";
3
+ import { ModelFields } from "./types";
4
+ interface Params {
5
+ plugins: PluginsContainer;
6
+ fields?: CmsModelField[];
7
+ }
8
+ export declare const createModelFields: ({ plugins, fields }: Params) => ModelFields;
9
+ export {};