@webiny/api-headless-cms-ddb-es 5.34.8 → 5.35.0-beta.1
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.
- package/configurations.d.ts +1 -1
- package/configurations.js +0 -8
- package/configurations.js.map +1 -1
- package/definitions/entry.js +3 -5
- package/definitions/entry.js.map +1 -1
- package/definitions/entryElasticsearch.js +0 -5
- package/definitions/entryElasticsearch.js.map +1 -1
- package/definitions/group.js +0 -5
- package/definitions/group.js.map +1 -1
- package/definitions/model.js +17 -5
- package/definitions/model.js.map +1 -1
- package/definitions/settings.js +0 -5
- package/definitions/settings.js.map +1 -1
- package/definitions/system.js +0 -5
- package/definitions/system.js.map +1 -1
- package/definitions/table.js +0 -3
- package/definitions/table.js.map +1 -1
- package/definitions/tableElasticsearch.js +0 -3
- package/definitions/tableElasticsearch.js.map +1 -1
- package/dynamoDb/index.js +0 -5
- package/dynamoDb/index.js.map +1 -1
- package/dynamoDb/storage/date.js +1 -16
- package/dynamoDb/storage/date.js.map +1 -1
- package/dynamoDb/storage/longText.js +1 -18
- package/dynamoDb/storage/longText.js.map +1 -1
- package/dynamoDb/storage/richText.js +0 -24
- package/dynamoDb/storage/richText.js.map +1 -1
- package/elasticsearch/createElasticsearchIndex.js +0 -11
- package/elasticsearch/createElasticsearchIndex.js.map +1 -1
- package/elasticsearch/deleteElasticsearchIndex.js +0 -7
- package/elasticsearch/deleteElasticsearchIndex.js.map +1 -1
- package/elasticsearch/index.js +0 -5
- package/elasticsearch/index.js.map +1 -1
- package/elasticsearch/indexing/dateTimeIndexing.js +4 -21
- package/elasticsearch/indexing/dateTimeIndexing.js.map +1 -1
- package/elasticsearch/indexing/defaultFieldIndexing.js +5 -11
- package/elasticsearch/indexing/defaultFieldIndexing.js.map +1 -1
- package/elasticsearch/indexing/index.js +0 -9
- package/elasticsearch/indexing/index.js.map +1 -1
- package/elasticsearch/indexing/longTextIndexing.js +2 -14
- package/elasticsearch/indexing/longTextIndexing.js.map +1 -1
- package/elasticsearch/indexing/numberIndexing.js +0 -9
- package/elasticsearch/indexing/numberIndexing.js.map +1 -1
- package/elasticsearch/indexing/objectIndexing.js +3 -30
- package/elasticsearch/indexing/objectIndexing.js.map +1 -1
- package/elasticsearch/indexing/richTextIndexing.js +0 -5
- package/elasticsearch/indexing/richTextIndexing.js.map +1 -1
- package/elasticsearch/indices/base.js +0 -3
- package/elasticsearch/indices/base.js.map +1 -1
- package/elasticsearch/indices/index.js +0 -4
- package/elasticsearch/indices/index.js.map +1 -1
- package/elasticsearch/indices/japanese.js +0 -3
- package/elasticsearch/indices/japanese.js.map +1 -1
- package/elasticsearch/search/index.js +0 -4
- package/elasticsearch/search/index.js.map +1 -1
- package/elasticsearch/search/refSearch.js +0 -6
- package/elasticsearch/search/refSearch.js.map +1 -1
- package/elasticsearch/search/timeSearch.js +0 -7
- package/elasticsearch/search/timeSearch.js.map +1 -1
- package/helpers/entryIndexHelpers.js +20 -49
- package/helpers/entryIndexHelpers.js.map +1 -1
- package/helpers/index.js +0 -2
- package/helpers/index.js.map +1 -1
- package/index.js +7 -44
- package/index.js.map +1 -1
- package/operations/entry/dataLoaders.js +0 -52
- package/operations/entry/dataLoaders.js.map +1 -1
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js +1 -3
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js.map +1 -1
- package/operations/entry/elasticsearch/body.js +2 -26
- package/operations/entry/elasticsearch/body.js.map +1 -1
- package/operations/entry/elasticsearch/fields.d.ts +5 -4
- package/operations/entry/elasticsearch/fields.js +73 -60
- package/operations/entry/elasticsearch/fields.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/applyFiltering.js +1 -10
- package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/exec.js +9 -52
- package/operations/entry/elasticsearch/filtering/exec.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/index.js +0 -2
- package/operations/entry/elasticsearch/filtering/index.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/path.js +1 -9
- package/operations/entry/elasticsearch/filtering/path.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js +1 -8
- package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/plugins/index.js +0 -5
- package/operations/entry/elasticsearch/filtering/plugins/index.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js +0 -13
- package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js +0 -10
- package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/populated.js +0 -7
- package/operations/entry/elasticsearch/filtering/populated.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/values.js +0 -6
- package/operations/entry/elasticsearch/filtering/values.js.map +1 -1
- package/operations/entry/elasticsearch/fullTextSearch.js +0 -13
- package/operations/entry/elasticsearch/fullTextSearch.js.map +1 -1
- package/operations/entry/elasticsearch/fullTextSearchFields.js +0 -6
- package/operations/entry/elasticsearch/fullTextSearchFields.js.map +1 -1
- package/operations/entry/elasticsearch/initialQuery.js +5 -19
- package/operations/entry/elasticsearch/initialQuery.js.map +1 -1
- package/operations/entry/elasticsearch/keyword.js +0 -4
- package/operations/entry/elasticsearch/keyword.js.map +1 -1
- package/operations/entry/elasticsearch/plugins/bodyModifier.js +0 -3
- package/operations/entry/elasticsearch/plugins/bodyModifier.js.map +1 -1
- package/operations/entry/elasticsearch/plugins/operator.js +0 -8
- package/operations/entry/elasticsearch/plugins/operator.js.map +1 -1
- package/operations/entry/elasticsearch/plugins/queryModifier.js +0 -3
- package/operations/entry/elasticsearch/plugins/queryModifier.js.map +1 -1
- package/operations/entry/elasticsearch/plugins/search.js +0 -6
- package/operations/entry/elasticsearch/plugins/search.js.map +1 -1
- package/operations/entry/elasticsearch/plugins/sortModifier.js +0 -3
- package/operations/entry/elasticsearch/plugins/sortModifier.js.map +1 -1
- package/operations/entry/elasticsearch/sort.js +5 -21
- package/operations/entry/elasticsearch/sort.js.map +1 -1
- package/operations/entry/elasticsearch/transformValueForSearch.js +0 -4
- package/operations/entry/elasticsearch/transformValueForSearch.js.map +1 -1
- package/operations/entry/elasticsearch/types.d.ts +3 -3
- package/operations/entry/elasticsearch/types.js.map +1 -1
- package/operations/entry/index.js +54 -147
- package/operations/entry/index.js.map +1 -1
- package/operations/entry/keys.js +0 -9
- package/operations/entry/keys.js.map +1 -1
- package/operations/entry/recordType.js +0 -6
- package/operations/entry/recordType.js.map +1 -1
- package/operations/group/index.js +2 -32
- package/operations/group/index.js.map +1 -1
- package/operations/model/index.js +1 -34
- package/operations/model/index.js.map +1 -1
- package/operations/settings/index.js +0 -24
- package/operations/settings/index.js.map +1 -1
- package/operations/system/index.js +0 -17
- package/operations/system/index.js.map +1 -1
- package/package.json +23 -16
- package/plugins/CmsElasticsearchModelFieldPlugin.d.ts +69 -0
- package/plugins/CmsElasticsearchModelFieldPlugin.js +48 -0
- package/plugins/CmsElasticsearchModelFieldPlugin.js.map +1 -0
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js +0 -8
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js +0 -10
- package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchIndexPlugin.js +0 -5
- package/plugins/CmsEntryElasticsearchIndexPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js +0 -12
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js +0 -8
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.js +0 -8
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.js.map +1 -1
- package/plugins/CmsEntryFilterPlugin.js +0 -7
- package/plugins/CmsEntryFilterPlugin.js.map +1 -1
- package/plugins/index.d.ts +1 -1
- package/plugins/index.js +11 -25
- package/plugins/index.js.map +1 -1
- package/types.d.ts +1 -1
- package/types.js +0 -5
- package/types.js.map +1 -1
|
@@ -1,30 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.DataLoadersHandler = void 0;
|
|
9
|
-
|
|
10
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
-
|
|
12
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
-
|
|
14
10
|
var _dataloader = _interopRequireDefault(require("dataloader"));
|
|
15
|
-
|
|
16
11
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
17
|
-
|
|
18
12
|
var _query = require("@webiny/db-dynamodb/utils/query");
|
|
19
|
-
|
|
20
13
|
var _keys = require("./keys");
|
|
21
|
-
|
|
22
14
|
var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
|
|
23
|
-
|
|
24
15
|
var _utils = require("@webiny/utils");
|
|
25
|
-
|
|
26
16
|
var _batchRead = require("@webiny/db-dynamodb/utils/batchRead");
|
|
27
|
-
|
|
28
17
|
const getAllEntryRevisions = params => {
|
|
29
18
|
const {
|
|
30
19
|
entity,
|
|
@@ -36,7 +25,6 @@ const getAllEntryRevisions = params => {
|
|
|
36
25
|
} = model;
|
|
37
26
|
return new _dataloader.default(async ids => {
|
|
38
27
|
const results = {};
|
|
39
|
-
|
|
40
28
|
for (const id of ids) {
|
|
41
29
|
const queryAllParams = {
|
|
42
30
|
entity,
|
|
@@ -52,13 +40,11 @@ const getAllEntryRevisions = params => {
|
|
|
52
40
|
const items = await (0, _query.queryAll)(queryAllParams);
|
|
53
41
|
results[id] = (0, _cleanup.cleanupItems)(entity, items);
|
|
54
42
|
}
|
|
55
|
-
|
|
56
43
|
return ids.map(id => {
|
|
57
44
|
return results[id] || [];
|
|
58
45
|
});
|
|
59
46
|
});
|
|
60
47
|
};
|
|
61
|
-
|
|
62
48
|
const getRevisionById = params => {
|
|
63
49
|
const {
|
|
64
50
|
entity,
|
|
@@ -78,20 +64,16 @@ const getRevisionById = params => {
|
|
|
78
64
|
const {
|
|
79
65
|
version
|
|
80
66
|
} = (0, _utils.parseIdentifier)(id);
|
|
81
|
-
|
|
82
67
|
if (!version) {
|
|
83
68
|
return collection;
|
|
84
69
|
}
|
|
85
|
-
|
|
86
70
|
const sortKey = (0, _keys.createRevisionSortKey)({
|
|
87
71
|
version
|
|
88
72
|
});
|
|
89
73
|
const keys = `${partitionKey}__${sortKey}`;
|
|
90
|
-
|
|
91
74
|
if (collection[keys]) {
|
|
92
75
|
return collection;
|
|
93
76
|
}
|
|
94
|
-
|
|
95
77
|
collection[keys] = entity.getBatch({
|
|
96
78
|
PK: partitionKey,
|
|
97
79
|
SK: sortKey
|
|
@@ -113,7 +95,6 @@ const getRevisionById = params => {
|
|
|
113
95
|
});
|
|
114
96
|
});
|
|
115
97
|
};
|
|
116
|
-
|
|
117
98
|
const getPublishedRevisionByEntryId = params => {
|
|
118
99
|
const {
|
|
119
100
|
entity,
|
|
@@ -131,11 +112,9 @@ const getPublishedRevisionByEntryId = params => {
|
|
|
131
112
|
locale,
|
|
132
113
|
id
|
|
133
114
|
});
|
|
134
|
-
|
|
135
115
|
if (collection[partitionKey]) {
|
|
136
116
|
return collection;
|
|
137
117
|
}
|
|
138
|
-
|
|
139
118
|
collection[partitionKey] = entity.getBatch({
|
|
140
119
|
PK: partitionKey,
|
|
141
120
|
SK: publishedKey
|
|
@@ -160,7 +139,6 @@ const getPublishedRevisionByEntryId = params => {
|
|
|
160
139
|
});
|
|
161
140
|
});
|
|
162
141
|
};
|
|
163
|
-
|
|
164
142
|
const getLatestRevisionByEntryId = params => {
|
|
165
143
|
const {
|
|
166
144
|
entity,
|
|
@@ -178,11 +156,9 @@ const getLatestRevisionByEntryId = params => {
|
|
|
178
156
|
locale,
|
|
179
157
|
id
|
|
180
158
|
});
|
|
181
|
-
|
|
182
159
|
if (collection[partitionKey]) {
|
|
183
160
|
return collection;
|
|
184
161
|
}
|
|
185
|
-
|
|
186
162
|
collection[partitionKey] = entity.getBatch({
|
|
187
163
|
PK: partitionKey,
|
|
188
164
|
SK: latestKey
|
|
@@ -207,7 +183,6 @@ const getLatestRevisionByEntryId = params => {
|
|
|
207
183
|
});
|
|
208
184
|
});
|
|
209
185
|
};
|
|
210
|
-
|
|
211
186
|
const dataLoaders = {
|
|
212
187
|
getAllEntryRevisions,
|
|
213
188
|
getRevisionById,
|
|
@@ -215,42 +190,33 @@ const dataLoaders = {
|
|
|
215
190
|
getLatestRevisionByEntryId
|
|
216
191
|
};
|
|
217
192
|
const loaderNames = Object.keys(dataLoaders);
|
|
218
|
-
|
|
219
193
|
class DataLoadersHandler {
|
|
220
194
|
constructor(params) {
|
|
221
195
|
(0, _defineProperty2.default)(this, "loaders", new Map());
|
|
222
196
|
(0, _defineProperty2.default)(this, "entity", void 0);
|
|
223
197
|
this.entity = params.entity;
|
|
224
198
|
}
|
|
225
|
-
|
|
226
199
|
async getAllEntryRevisions(params) {
|
|
227
200
|
return await this.loadMany("getAllEntryRevisions", params, params.ids);
|
|
228
201
|
}
|
|
229
|
-
|
|
230
202
|
clearAllEntryRevisions(params) {
|
|
231
203
|
this.clear("getAllEntryRevisions", params);
|
|
232
204
|
}
|
|
233
|
-
|
|
234
205
|
async getRevisionById(params) {
|
|
235
206
|
return await this.loadMany("getRevisionById", params, params.ids);
|
|
236
207
|
}
|
|
237
|
-
|
|
238
208
|
clearRevisionById(params) {
|
|
239
209
|
this.clear("getRevisionById", params);
|
|
240
210
|
}
|
|
241
|
-
|
|
242
211
|
async getPublishedRevisionByEntryId(params) {
|
|
243
212
|
return await this.loadMany("getPublishedRevisionByEntryId", params, params.ids);
|
|
244
213
|
}
|
|
245
|
-
|
|
246
214
|
clearPublishedRevisionByEntryId(params) {
|
|
247
215
|
this.clear("getPublishedRevisionByEntryId", params);
|
|
248
216
|
}
|
|
249
|
-
|
|
250
217
|
async getLatestRevisionByEntryId(params) {
|
|
251
218
|
return await this.loadMany("getLatestRevisionByEntryId", params, params.ids);
|
|
252
219
|
}
|
|
253
|
-
|
|
254
220
|
clearLatestRevisionByEntryId(params) {
|
|
255
221
|
this.clear("getLatestRevisionByEntryId", params);
|
|
256
222
|
}
|
|
@@ -258,15 +224,12 @@ class DataLoadersHandler {
|
|
|
258
224
|
* TODO @ts-refactor
|
|
259
225
|
* Maybe pass on the generics to DataLoader definition?
|
|
260
226
|
*/
|
|
261
|
-
|
|
262
|
-
|
|
263
227
|
getLoader(name, params) {
|
|
264
228
|
if (!dataLoaders[name]) {
|
|
265
229
|
throw new _error.default("Unknown data loader.", "UNKNOWN_DATA_LOADER", {
|
|
266
230
|
name
|
|
267
231
|
});
|
|
268
232
|
}
|
|
269
|
-
|
|
270
233
|
const {
|
|
271
234
|
model
|
|
272
235
|
} = params;
|
|
@@ -275,22 +238,17 @@ class DataLoadersHandler {
|
|
|
275
238
|
locale
|
|
276
239
|
} = model;
|
|
277
240
|
const loaderKey = `${name}-${tenant}-${locale}-${model.modelId}`;
|
|
278
|
-
|
|
279
241
|
if (!this.loaders.has(loaderKey)) {
|
|
280
242
|
this.loaders.set(loaderKey, dataLoaders[name]((0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
|
|
281
243
|
entity: this.entity
|
|
282
244
|
})));
|
|
283
245
|
}
|
|
284
|
-
|
|
285
246
|
return this.loaders.get(loaderKey);
|
|
286
247
|
}
|
|
287
|
-
|
|
288
248
|
async loadMany(loader, params, ids) {
|
|
289
249
|
let results;
|
|
290
|
-
|
|
291
250
|
try {
|
|
292
251
|
results = await this.getLoader(loader, params).loadMany(ids);
|
|
293
|
-
|
|
294
252
|
if (Array.isArray(results) === true) {
|
|
295
253
|
return results.reduce((acc, res) => {
|
|
296
254
|
if (Array.isArray(res) === false) {
|
|
@@ -299,12 +257,10 @@ class DataLoadersHandler {
|
|
|
299
257
|
data: JSON.stringify(res.data || {})
|
|
300
258
|
}));
|
|
301
259
|
}
|
|
302
|
-
|
|
303
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), {}, {
|
|
304
261
|
loader
|
|
305
262
|
}));
|
|
306
263
|
}
|
|
307
|
-
|
|
308
264
|
acc.push(...res);
|
|
309
265
|
return acc;
|
|
310
266
|
}, []);
|
|
@@ -317,14 +273,12 @@ class DataLoadersHandler {
|
|
|
317
273
|
ids
|
|
318
274
|
}));
|
|
319
275
|
}
|
|
320
|
-
|
|
321
276
|
throw new _error.default(`Data loader did not return array of items or empty array.`, "INVALID_DATA_LOADER_RESULT", {
|
|
322
277
|
loader,
|
|
323
278
|
ids,
|
|
324
279
|
results
|
|
325
280
|
});
|
|
326
281
|
}
|
|
327
|
-
|
|
328
282
|
clearAll(params) {
|
|
329
283
|
for (const name of loaderNames) {
|
|
330
284
|
const loader = this.getLoader(name, params);
|
|
@@ -335,19 +289,15 @@ class DataLoadersHandler {
|
|
|
335
289
|
* Helper to clear the cache for certain data loader.
|
|
336
290
|
* If entry is passed then clear target key only.
|
|
337
291
|
*/
|
|
338
|
-
|
|
339
|
-
|
|
340
292
|
clear(name, params) {
|
|
341
293
|
const {
|
|
342
294
|
entry
|
|
343
295
|
} = params;
|
|
344
296
|
const loader = this.getLoader(name, params);
|
|
345
|
-
|
|
346
297
|
if (!entry) {
|
|
347
298
|
loader.clearAll();
|
|
348
299
|
return;
|
|
349
300
|
}
|
|
350
|
-
|
|
351
301
|
loader.clear(entry.id);
|
|
352
302
|
const {
|
|
353
303
|
tenant,
|
|
@@ -359,7 +309,5 @@ class DataLoadersHandler {
|
|
|
359
309
|
id: entry.id
|
|
360
310
|
}));
|
|
361
311
|
}
|
|
362
|
-
|
|
363
312
|
}
|
|
364
|
-
|
|
365
313
|
exports.DataLoadersHandler = DataLoadersHandler;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getAllEntryRevisions","params","entity","model","tenant","locale","DataLoader","ids","results","id","queryAllParams","partitionKey","createPartitionKey","options","beginsWith","items","queryAll","cleanupItems","map","getRevisionById","queries","reduce","collection","version","parseIdentifier","sortKey","createRevisionSortKey","keys","getBatch","PK","SK","records","batchReadAll","table","Object","values","filter","item","getPublishedRevisionByEntryId","publishedKey","createPublishedSortKey","entryId","getLatestRevisionByEntryId","latestKey","createLatestSortKey","dataLoaders","loaderNames","DataLoadersHandler","constructor","Map","loadMany","clearAllEntryRevisions","clear","clearRevisionById","clearPublishedRevisionByEntryId","clearLatestRevisionByEntryId","getLoader","name","WebinyError","loaderKey","modelId","loaders","has","set","get","loader","Array","isArray","acc","res","message","code","data","JSON","stringify","push","ex","error","clearAll","entry"],"sources":["dataLoaders.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport WebinyError from \"@webiny/error\";\nimport { CmsEntry, CmsModel } from \"@webiny/api-headless-cms/types\";\nimport { Entity } from \"dynamodb-toolbox\";\nimport { queryAll, QueryAllParams } from \"@webiny/db-dynamodb/utils/query\";\nimport {\n createLatestSortKey,\n createPartitionKey,\n createPublishedSortKey,\n createRevisionSortKey\n} from \"./keys\";\nimport { cleanupItems } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { batchReadAll } from \"@webiny/db-dynamodb/utils/batchRead\";\n\nconst getAllEntryRevisions = (params: LoaderParams) => {\n const { entity, model } = params;\n const { tenant, locale } = model;\n return new DataLoader<string, CmsEntry[]>(async (ids: readonly string[]) => {\n const results: Record<string, CmsEntry[]> = {};\n for (const id of ids) {\n const queryAllParams: QueryAllParams = {\n entity,\n partitionKey: createPartitionKey({\n tenant,\n locale,\n id\n }),\n options: {\n beginsWith: \"REV#\"\n }\n };\n const items = await queryAll<CmsEntry>(queryAllParams);\n\n results[id] = cleanupItems(entity, items);\n }\n\n return ids.map(id => {\n return results[id] || [];\n });\n });\n};\n\nconst getRevisionById = (params: LoaderParams) => {\n const { entity, model } = params;\n const { locale, tenant } = model;\n\n return new DataLoader<string, CmsEntry[]>(async (ids: readonly string[]) => {\n const queries = ids.reduce((collection, id) => {\n const partitionKey = createPartitionKey({\n tenant,\n locale,\n id\n });\n const { version } = parseIdentifier(id);\n if (!version) {\n return collection;\n }\n const sortKey = createRevisionSortKey({\n version\n });\n const keys = `${partitionKey}__${sortKey}`;\n if (collection[keys]) {\n return collection;\n }\n\n collection[keys] = entity.getBatch({\n PK: partitionKey,\n SK: sortKey\n });\n\n return collection;\n /**\n * We use any because there is no type for the return type.\n */\n }, {} as Record<string, any>);\n\n const records = await batchReadAll<CmsEntry>({\n table: entity.table,\n items: Object.values(queries)\n });\n const items = cleanupItems(entity, records);\n\n return ids.map(id => {\n return items.filter(item => {\n return id === item.id;\n });\n });\n });\n};\n\nconst getPublishedRevisionByEntryId = (params: LoaderParams) => {\n const { entity, model } = params;\n const { locale, tenant } = model;\n\n const publishedKey = createPublishedSortKey();\n\n return new DataLoader<string, CmsEntry[]>(async (ids: readonly string[]) => {\n const queries = ids.reduce((collection, id) => {\n const partitionKey = createPartitionKey({\n tenant,\n locale,\n id\n });\n if (collection[partitionKey]) {\n return collection;\n }\n collection[partitionKey] = entity.getBatch({\n PK: partitionKey,\n SK: publishedKey\n });\n return collection;\n /**\n * We use any because there is no type for the return type.\n */\n }, {} as Record<string, any>);\n\n const records = await batchReadAll<CmsEntry>({\n table: entity.table,\n items: Object.values(queries)\n });\n const items = cleanupItems(entity, records);\n\n return ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return items.filter(item => {\n return entryId === item.entryId;\n });\n });\n });\n};\n\nconst getLatestRevisionByEntryId = (params: LoaderParams) => {\n const { entity, model } = params;\n const { locale, tenant } = model;\n\n const latestKey = createLatestSortKey();\n\n return new DataLoader<string, CmsEntry[]>(async (ids: readonly string[]) => {\n const queries = ids.reduce((collection, id) => {\n const partitionKey = createPartitionKey({\n tenant,\n locale,\n id\n });\n if (collection[partitionKey]) {\n return collection;\n }\n collection[partitionKey] = entity.getBatch({\n PK: partitionKey,\n SK: latestKey\n });\n return collection;\n /**\n * We use any because there is no type for the return type.\n */\n }, {} as Record<string, any>);\n\n const records = await batchReadAll<CmsEntry>({\n table: entity.table,\n items: Object.values(queries)\n });\n const items = cleanupItems(entity, records);\n\n return ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return items.filter(item => {\n return entryId === item.entryId;\n });\n });\n });\n};\n\nconst dataLoaders: Record<Loaders, any> = {\n getAllEntryRevisions,\n getRevisionById,\n getPublishedRevisionByEntryId,\n getLatestRevisionByEntryId\n};\n\nexport interface GetAllEntryRevisionsParams {\n ids: readonly string[];\n model: CmsModel;\n}\n\nexport interface GetRevisionByIdParams {\n ids: readonly string[];\n model: CmsModel;\n}\n\nexport interface GetPublishedRevisionByEntryIdParams {\n ids: readonly string[];\n model: CmsModel;\n}\n\nexport interface GetLatestRevisionByEntryIdParams {\n ids: readonly string[];\n model: CmsModel;\n}\n\ninterface LoaderParams {\n entity: Entity<any>;\n model: CmsModel;\n}\n\ninterface GetLoaderParams {\n model: CmsModel;\n}\n\ninterface ClearLoaderParams {\n model: CmsModel;\n entry?: CmsEntry;\n}\n\ntype Loaders =\n | \"getAllEntryRevisions\"\n | \"getRevisionById\"\n | \"getPublishedRevisionByEntryId\"\n | \"getLatestRevisionByEntryId\";\n\nconst loaderNames = Object.keys(dataLoaders) as Loaders[];\n\nexport interface DataLoadersHandlerParams {\n entity: Entity<any>;\n}\nexport class DataLoadersHandler {\n private readonly loaders: Map<string, DataLoader<any, any>> = new Map();\n private readonly entity: Entity<any>;\n\n public constructor(params: DataLoadersHandlerParams) {\n this.entity = params.entity;\n }\n\n public async getAllEntryRevisions(params: GetAllEntryRevisionsParams): Promise<CmsEntry[]> {\n return await this.loadMany(\"getAllEntryRevisions\", params, params.ids);\n }\n\n public clearAllEntryRevisions(params: ClearLoaderParams): void {\n this.clear(\"getAllEntryRevisions\", params);\n }\n\n public async getRevisionById(params: GetRevisionByIdParams): Promise<CmsEntry[]> {\n return await this.loadMany(\"getRevisionById\", params, params.ids);\n }\n\n public clearRevisionById(params: ClearLoaderParams): void {\n this.clear(\"getRevisionById\", params);\n }\n\n public async getPublishedRevisionByEntryId(\n params: GetPublishedRevisionByEntryIdParams\n ): Promise<CmsEntry[]> {\n return await this.loadMany(\"getPublishedRevisionByEntryId\", params, params.ids);\n }\n public clearPublishedRevisionByEntryId(params: ClearLoaderParams): void {\n this.clear(\"getPublishedRevisionByEntryId\", params);\n }\n\n public async getLatestRevisionByEntryId(\n params: GetLatestRevisionByEntryIdParams\n ): Promise<CmsEntry[]> {\n return await this.loadMany(\"getLatestRevisionByEntryId\", params, params.ids);\n }\n\n public clearLatestRevisionByEntryId(params: ClearLoaderParams): void {\n this.clear(\"getLatestRevisionByEntryId\", params);\n }\n /**\n * TODO @ts-refactor\n * Maybe pass on the generics to DataLoader definition?\n */\n private getLoader(name: Loaders, params: GetLoaderParams): DataLoader<any, any> {\n if (!dataLoaders[name]) {\n throw new WebinyError(\"Unknown data loader.\", \"UNKNOWN_DATA_LOADER\", {\n name\n });\n }\n const { model } = params;\n const { tenant, locale } = model;\n const loaderKey = `${name}-${tenant}-${locale}-${model.modelId}`;\n if (!this.loaders.has(loaderKey)) {\n this.loaders.set(\n loaderKey,\n dataLoaders[name]({\n ...params,\n entity: this.entity\n })\n );\n }\n return this.loaders.get(loaderKey) as DataLoader<any, any>;\n }\n\n private async loadMany(\n loader: Loaders,\n params: GetLoaderParams,\n ids: readonly string[]\n ): Promise<CmsEntry[]> {\n let results;\n try {\n results = await this.getLoader(loader, params).loadMany(ids);\n if (Array.isArray(results) === true) {\n return results.reduce((acc, res) => {\n if (Array.isArray(res) === false) {\n if (res && res.message) {\n throw new WebinyError(res.message, res.code, {\n ...res,\n data: JSON.stringify(res.data || {})\n });\n }\n throw new WebinyError(\n \"Result from the data loader must be an array of arrays which contain requested items.\",\n \"DATA_LOADER_RESULTS_ERROR\",\n {\n ...params,\n loader\n }\n );\n }\n acc.push(...res);\n return acc;\n }, []);\n }\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Data loader error.\",\n ex.code || \"DATA_LOADER_ERROR\",\n {\n error: ex,\n ...params,\n loader,\n ids\n }\n );\n }\n throw new WebinyError(\n `Data loader did not return array of items or empty array.`,\n \"INVALID_DATA_LOADER_RESULT\",\n {\n loader,\n ids,\n results\n }\n );\n }\n\n public clearAll(params: Omit<ClearLoaderParams, \"entry\">): void {\n for (const name of loaderNames) {\n const loader = this.getLoader(name, params);\n loader.clearAll();\n }\n }\n /**\n * Helper to clear the cache for certain data loader.\n * If entry is passed then clear target key only.\n */\n private clear(name: Loaders, params: ClearLoaderParams): void {\n const { entry } = params;\n const loader = this.getLoader(name, params);\n if (!entry) {\n loader.clearAll();\n return;\n }\n loader.clear(entry.id);\n const { tenant, locale } = params.model;\n loader.clear(\n createPartitionKey({\n tenant,\n locale,\n id: entry.id\n })\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;AAGA;;AACA;;AAMA;;AACA;;AACA;;AAEA,MAAMA,oBAAoB,GAAIC,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,OAAmC,GAAG,EAA5C;;IACA,KAAK,MAAMC,EAAX,IAA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ACFkB,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"}
|
|
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,EAAEa,KAAK,CAAC;IAC7C;IAEA,OAAOR,GAAG,CAACW,GAAG,CAACT,EAAE,IAAI;MACjB,OAAOD,OAAO,CAACC,EAAE,CAAC,IAAI,EAAE;IAC5B,CAAC,CAAC;EACN,CAAC,CAAC;AACN,CAAC;AAED,MAAMU,eAA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ACxB,MAAMgE,MAAM,GAAG,IAAI,CAACT,SAAS,CAACC,IAAI,EAAExD,MAAM,CAAC;IAC3C,IAAI,CAAC8E,KAAK,EAAE;MACRd,MAAM,CAACa,QAAQ,EAAE;MACjB;IACJ;IACAb,MAAM,CAACb,KAAK,CAAC2B,KAAK,CAACtE,EAAE,CAAC;IACtB,MAAM;MAAEL,MAAM;MAAEC;IAAO,CAAC,GAAGJ,MAAM,CAACE,KAAK;IACvC8D,MAAM,CAACb,KAAK,CACR,IAAAxC,wBAAkB,EAAC;MACfR,MAAM;MACNC,MAAM;MACNI,EAAE,EAAEsE,KAAK,CAACtE;IACd,CAAC,CAAC,CACL;EACL;AACJ;AAAC"}
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.assignMinimumShouldMatchToQuery = void 0;
|
|
7
|
-
|
|
8
7
|
/**
|
|
9
8
|
* This function will assign a minimum_should_match for the query if conditions are met:
|
|
10
9
|
* * should is an array
|
|
@@ -16,6 +15,7 @@ exports.assignMinimumShouldMatchToQuery = void 0;
|
|
|
16
15
|
*
|
|
17
16
|
* Users can modify minimum_should_match value via the body or query modification plugins.
|
|
18
17
|
*/
|
|
18
|
+
|
|
19
19
|
const assignMinimumShouldMatchToQuery = ({
|
|
20
20
|
query,
|
|
21
21
|
value = 1
|
|
@@ -27,8 +27,6 @@ const assignMinimumShouldMatchToQuery = ({
|
|
|
27
27
|
} else if (query.minimum_should_match) {
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
|
-
|
|
31
30
|
query.minimum_should_match = value > 0 ? value : 1;
|
|
32
31
|
};
|
|
33
|
-
|
|
34
32
|
exports.assignMinimumShouldMatchToQuery = assignMinimumShouldMatchToQuery;
|
|
@@ -1 +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":"
|
|
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,KAAK;EAAEC,KAAK,GAAG;AAAU,CAAC,KAAW;EACnF,IAAI,CAACC,KAAK,CAACC,OAAO,CAACH,KAAK,CAACI,MAAM,CAAC,EAAE;IAC9B;EACJ,CAAC,MAAM,IAAIJ,KAAK,CAACI,MAAM,CAACC,MAAM,KAAK,CAAC,EAAE;IAClC;EACJ,CAAC,MAAM,IAAIL,KAAK,CAACM,oBAAoB,EAAE;IACnC;EACJ;EACAN,KAAK,CAACM,oBAAoB,GAAGL,KAAK,GAAG,CAAC,GAAGA,KAAK,GAAG,CAAC;AACtD,CAAC;AAAC"}
|
|
@@ -4,27 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.createElasticsearchBody = void 0;
|
|
7
|
-
|
|
8
7
|
var _fields = require("./fields");
|
|
9
|
-
|
|
10
8
|
var _fullTextSearchFields = require("./fullTextSearchFields");
|
|
11
|
-
|
|
12
9
|
var _initialQuery = require("./initialQuery");
|
|
13
|
-
|
|
14
10
|
var _fullTextSearch = require("./fullTextSearch");
|
|
15
|
-
|
|
16
11
|
var _queryModifier = require("./plugins/queryModifier");
|
|
17
|
-
|
|
18
12
|
var _sortModifier = require("./plugins/sortModifier");
|
|
19
|
-
|
|
20
13
|
var _bodyModifier = require("./plugins/bodyModifier");
|
|
21
|
-
|
|
22
14
|
var _sort = require("./sort");
|
|
23
|
-
|
|
24
15
|
var _filtering = require("./filtering");
|
|
25
|
-
|
|
26
16
|
var _assignMinimumShouldMatchToQuery = require("./assignMinimumShouldMatchToQuery");
|
|
27
|
-
|
|
28
17
|
const createElasticsearchBody = ({
|
|
29
18
|
plugins,
|
|
30
19
|
model,
|
|
@@ -41,15 +30,14 @@ const createElasticsearchBody = ({
|
|
|
41
30
|
/**
|
|
42
31
|
* 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
32
|
*/
|
|
44
|
-
|
|
45
33
|
const modelFields = (0, _fields.createModelFields)({
|
|
46
34
|
plugins,
|
|
47
|
-
|
|
35
|
+
model
|
|
48
36
|
});
|
|
37
|
+
|
|
49
38
|
/**
|
|
50
39
|
* We need the query modifier plugins.
|
|
51
40
|
*/
|
|
52
|
-
|
|
53
41
|
const queryModifierPlugins = (0, _queryModifier.createQueryModifierPluginList)({
|
|
54
42
|
plugins,
|
|
55
43
|
model
|
|
@@ -57,7 +45,6 @@ const createElasticsearchBody = ({
|
|
|
57
45
|
/**
|
|
58
46
|
* We need the sort modifier plugins.
|
|
59
47
|
*/
|
|
60
|
-
|
|
61
48
|
const sortModifierPlugins = (0, _sortModifier.createSortModifierPluginList)({
|
|
62
49
|
plugins,
|
|
63
50
|
model
|
|
@@ -65,7 +52,6 @@ const createElasticsearchBody = ({
|
|
|
65
52
|
/**
|
|
66
53
|
* We need the body modifier plugins.
|
|
67
54
|
*/
|
|
68
|
-
|
|
69
55
|
const bodyModifierPlugins = (0, _bodyModifier.createBodyModifierPluginList)({
|
|
70
56
|
plugins,
|
|
71
57
|
model
|
|
@@ -74,7 +60,6 @@ const createElasticsearchBody = ({
|
|
|
74
60
|
* We need the fields which we can search through via the full text search.
|
|
75
61
|
*
|
|
76
62
|
*/
|
|
77
|
-
|
|
78
63
|
const fullTextSearchFields = (0, _fullTextSearchFields.createFullTextSearchFields)({
|
|
79
64
|
model,
|
|
80
65
|
term,
|
|
@@ -83,7 +68,6 @@ const createElasticsearchBody = ({
|
|
|
83
68
|
/**
|
|
84
69
|
* The initial elasticsearch query where we attach some default conditions we always need.
|
|
85
70
|
*/
|
|
86
|
-
|
|
87
71
|
const query = (0, _initialQuery.createInitialQuery)({
|
|
88
72
|
where,
|
|
89
73
|
model
|
|
@@ -91,7 +75,6 @@ const createElasticsearchBody = ({
|
|
|
91
75
|
/**
|
|
92
76
|
* Apply the full text search, if term is set.
|
|
93
77
|
*/
|
|
94
|
-
|
|
95
78
|
(0, _fullTextSearch.applyFullTextSearch)({
|
|
96
79
|
model,
|
|
97
80
|
plugins,
|
|
@@ -108,7 +91,6 @@ const createElasticsearchBody = ({
|
|
|
108
91
|
where,
|
|
109
92
|
query
|
|
110
93
|
});
|
|
111
|
-
|
|
112
94
|
for (const pl of queryModifierPlugins) {
|
|
113
95
|
pl.modifyQuery({
|
|
114
96
|
query,
|
|
@@ -116,21 +98,18 @@ const createElasticsearchBody = ({
|
|
|
116
98
|
where
|
|
117
99
|
});
|
|
118
100
|
}
|
|
119
|
-
|
|
120
101
|
const sort = (0, _sort.createElasticsearchSort)({
|
|
121
102
|
plugins,
|
|
122
103
|
sort: initialSort,
|
|
123
104
|
modelFields,
|
|
124
105
|
model
|
|
125
106
|
});
|
|
126
|
-
|
|
127
107
|
for (const pl of sortModifierPlugins) {
|
|
128
108
|
pl.modifySort({
|
|
129
109
|
sort,
|
|
130
110
|
model
|
|
131
111
|
});
|
|
132
112
|
}
|
|
133
|
-
|
|
134
113
|
const boolQuery = {
|
|
135
114
|
must: query.must.length > 0 ? query.must : undefined,
|
|
136
115
|
must_not: query.must_not.length > 0 ? query.must_not : undefined,
|
|
@@ -149,7 +128,6 @@ const createElasticsearchBody = ({
|
|
|
149
128
|
search_after: after,
|
|
150
129
|
track_total_hits: true
|
|
151
130
|
};
|
|
152
|
-
|
|
153
131
|
for (const pl of bodyModifierPlugins) {
|
|
154
132
|
pl.modifyBody({
|
|
155
133
|
body,
|
|
@@ -157,8 +135,6 @@ const createElasticsearchBody = ({
|
|
|
157
135
|
where
|
|
158
136
|
});
|
|
159
137
|
}
|
|
160
|
-
|
|
161
138
|
return body;
|
|
162
139
|
};
|
|
163
|
-
|
|
164
140
|
exports.createElasticsearchBody = createElasticsearchBody;
|
|
@@ -1 +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
|
|
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 model\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 model,\n plugins,\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,OAAO;EAAEC,KAAK;EAAEC;AAAe,CAAC,KAAiB;EACvF,MAAM;IAAEC,MAAM;IAAEC,MAAM,EAAEC,IAAI;IAAEC,KAAK;IAAEC,IAAI,EAAEC,WAAW;IAAEC,KAAK;IAAEC;EAAM,CAAC,GAAGR,MAAM;EAC/E;AACJ;AACA;EACI,MAAMS,WAAW,GAAG,IAAAC,yBAAiB,EAAC;IAClCZ,OAAO;IACPC;EACJ,CAAC,CAAC;;EAEF;AACJ;AACA;EACI,MAAMY,oBAAoB,GAAG,IAAAC,4CAA6B,EAAC;IACvDd,OAAO;IACPC;EACJ,CAAC,CAAC;EACF;AACJ;AACA;EACI,MAAMc,mBAAmB,GAAG,IAAAC,0CAA4B,EAAC;IACrDhB,OAAO;IACPC;EACJ,CAAC,CAAC;EACF;AACJ;AACA;EACI,MAAMgB,mBAAmB,GAAG,IAAAC,0CAA4B,EAAC;IACrDlB,OAAO;IACPC;EACJ,CAAC,CAAC;EACF;AACJ;AACA;AACA;EACI,MAAMkB,oBAAoB,GAAG,IAAAC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M,CAACJ,MAAM,GAAG,CAAC,GAAGX,KAAK,CAACe,MAAM,GAAGH;EACrD,CAAC;EAED,IAAAI,gEAA+B,EAAC;IAC5BhB,KAAK,EAAES;EACX,CAAC,CAAC;EAEF,MAAMQ,IAAgB,GAAG;IACrBjB,KAAK,EAAE;MACHkB,IAAI,EAAET;IACV,CAAC;IACDvB,IAAI;IACJiC,IAAI,EAAE,CAAC9B,KAAK,IAAI,CAAC,IAAI,CAAC;IACtB+B,YAAY,EAAEhC,KAAK;IACnBiC,gBAAgB,EAAE;EACtB,CAAC;EAED,KAAK,MAAMhB,EAAE,IAAIT,mBAAmB,EAAE;IAClCS,EAAE,CAACiB,UAAU,CAAC;MACVL,IAAI;MACJrC,KAAK;MACLK;IACJ,CAAC,CAAC;EACN;EAEA,OAAOgC,IAAI;AACf,CAAC;AAAC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { PluginsContainer } from "@webiny/plugins";
|
|
2
|
-
import {
|
|
3
|
-
import { ModelFields } from "./types";
|
|
2
|
+
import { CmsModel } from "@webiny/api-headless-cms/types";
|
|
4
3
|
interface Params {
|
|
5
4
|
plugins: PluginsContainer;
|
|
6
|
-
|
|
5
|
+
model: CmsModel;
|
|
7
6
|
}
|
|
8
|
-
export declare const createModelFields: ({ plugins,
|
|
7
|
+
export declare const createModelFields: ({ plugins, model }: Params) => {
|
|
8
|
+
[x: string]: import("./types").ModelField;
|
|
9
|
+
};
|
|
9
10
|
export {};
|