@webiny/api-headless-cms-ddb-es 5.19.0 → 5.20.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.
|
@@ -7,10 +7,15 @@ exports.createRefSearchPlugin = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _CmsEntryElasticsearchQueryBuilderValueSearchPlugin = require("../../plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin");
|
|
9
9
|
|
|
10
|
-
const createPath =
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
const createPath = ({
|
|
11
|
+
field,
|
|
12
|
+
key
|
|
13
|
+
}) => {
|
|
14
|
+
if (key && key.match("entryId") === null) {
|
|
15
|
+
return `${field.fieldId}.id`;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return `${field.fieldId}.entryId`;
|
|
14
19
|
};
|
|
15
20
|
|
|
16
21
|
const transform = params => {
|
|
@@ -63,6 +63,7 @@ const createElasticsearchSortParams = args => {
|
|
|
63
63
|
searchable: modelField.isSearchable,
|
|
64
64
|
field: modelField.field.fieldId,
|
|
65
65
|
path: createFieldPath({
|
|
66
|
+
key: modelField.field.fieldId,
|
|
66
67
|
parentPath,
|
|
67
68
|
modelField,
|
|
68
69
|
searchPlugin
|
|
@@ -144,14 +145,16 @@ const createInitialQueryValue = args => {
|
|
|
144
145
|
const createFieldPath = ({
|
|
145
146
|
modelField,
|
|
146
147
|
searchPlugin,
|
|
147
|
-
parentPath
|
|
148
|
+
parentPath,
|
|
149
|
+
key
|
|
148
150
|
}) => {
|
|
149
151
|
let path;
|
|
150
152
|
|
|
151
153
|
if (searchPlugin && typeof searchPlugin.createPath === "function") {
|
|
152
154
|
path = searchPlugin.createPath({
|
|
153
155
|
field: modelField.field,
|
|
154
|
-
value: null
|
|
156
|
+
value: null,
|
|
157
|
+
key
|
|
155
158
|
});
|
|
156
159
|
} else if (typeof modelField.path === "function") {
|
|
157
160
|
path = modelField.path(modelField.field.fieldId);
|
|
@@ -222,7 +225,8 @@ const fieldPathFactory = params => {
|
|
|
222
225
|
modelField,
|
|
223
226
|
value,
|
|
224
227
|
parentPath,
|
|
225
|
-
keyword
|
|
228
|
+
keyword,
|
|
229
|
+
key
|
|
226
230
|
} = params;
|
|
227
231
|
const field = modelField.field;
|
|
228
232
|
let fieldPath;
|
|
@@ -230,7 +234,8 @@ const fieldPathFactory = params => {
|
|
|
230
234
|
if (plugin) {
|
|
231
235
|
fieldPath = plugin.createPath({
|
|
232
236
|
field,
|
|
233
|
-
value
|
|
237
|
+
value,
|
|
238
|
+
key
|
|
234
239
|
});
|
|
235
240
|
}
|
|
236
241
|
|
|
@@ -256,6 +261,7 @@ const applyFiltering = params => {
|
|
|
256
261
|
query,
|
|
257
262
|
modelField,
|
|
258
263
|
operator,
|
|
264
|
+
key,
|
|
259
265
|
value: initialValue,
|
|
260
266
|
operatorPlugins,
|
|
261
267
|
searchPlugins,
|
|
@@ -281,14 +287,16 @@ const applyFiltering = params => {
|
|
|
281
287
|
plugin: fieldSearchPlugin,
|
|
282
288
|
modelField,
|
|
283
289
|
parentPath: modelField.isSystemField ? null : parentPath,
|
|
284
|
-
value
|
|
290
|
+
value,
|
|
291
|
+
key
|
|
285
292
|
}),
|
|
286
293
|
path: fieldPathFactory({
|
|
287
294
|
plugin: fieldSearchPlugin,
|
|
288
295
|
modelField,
|
|
289
296
|
value,
|
|
290
297
|
parentPath: modelField.isSystemField ? null : parentPath,
|
|
291
|
-
keyword
|
|
298
|
+
keyword,
|
|
299
|
+
key
|
|
292
300
|
}),
|
|
293
301
|
value,
|
|
294
302
|
keyword
|
|
@@ -381,6 +389,7 @@ const execElasticsearchBuildQueryPlugins = params => {
|
|
|
381
389
|
query,
|
|
382
390
|
modelField,
|
|
383
391
|
operator,
|
|
392
|
+
key: whereKey,
|
|
384
393
|
value: where[key][whereKey],
|
|
385
394
|
searchPlugins,
|
|
386
395
|
operatorPlugins,
|
|
@@ -395,6 +404,7 @@ const execElasticsearchBuildQueryPlugins = params => {
|
|
|
395
404
|
query,
|
|
396
405
|
modelField,
|
|
397
406
|
operator,
|
|
407
|
+
key,
|
|
398
408
|
value: where[key],
|
|
399
409
|
searchPlugins,
|
|
400
410
|
operatorPlugins,
|
|
@@ -501,6 +501,33 @@ const createEntriesStorageOperations = params => {
|
|
|
501
501
|
|
|
502
502
|
const list = async (model, params) => {
|
|
503
503
|
const limit = (0, _limit.createLimit)(params.limit, 50);
|
|
504
|
+
|
|
505
|
+
const {
|
|
506
|
+
index
|
|
507
|
+
} = _configurations.default.es({
|
|
508
|
+
model
|
|
509
|
+
});
|
|
510
|
+
|
|
511
|
+
try {
|
|
512
|
+
const result = await elasticsearch.indices.exists({
|
|
513
|
+
index
|
|
514
|
+
});
|
|
515
|
+
|
|
516
|
+
if (!result || !result.body) {
|
|
517
|
+
return {
|
|
518
|
+
hasMoreItems: false,
|
|
519
|
+
totalCount: 0,
|
|
520
|
+
cursor: null,
|
|
521
|
+
items: []
|
|
522
|
+
};
|
|
523
|
+
}
|
|
524
|
+
} catch (ex) {
|
|
525
|
+
throw new _error.default("Could not determine if Elasticsearch index exists.", "ELASTICSEARCH_INDEX_CHECK_ERROR", {
|
|
526
|
+
error: ex,
|
|
527
|
+
index
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
|
|
504
531
|
const body = (0, _helpers.createElasticsearchQueryBody)({
|
|
505
532
|
model,
|
|
506
533
|
args: _objectSpread(_objectSpread({}, params), {}, {
|
|
@@ -511,12 +538,6 @@ const createEntriesStorageOperations = params => {
|
|
|
511
538
|
});
|
|
512
539
|
let response;
|
|
513
540
|
|
|
514
|
-
const {
|
|
515
|
-
index
|
|
516
|
-
} = _configurations.default.es({
|
|
517
|
-
model
|
|
518
|
-
});
|
|
519
|
-
|
|
520
541
|
try {
|
|
521
542
|
response = await elasticsearch.search({
|
|
522
543
|
index,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-headless-cms-ddb-es",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.20.0-beta.1",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"@webiny/api-headless-cms",
|
|
@@ -23,15 +23,15 @@
|
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@babel/runtime": "7.16.3",
|
|
26
|
-
"@webiny/api-headless-cms": "5.
|
|
27
|
-
"@webiny/api-upgrade": "5.
|
|
28
|
-
"@webiny/db-dynamodb": "5.
|
|
29
|
-
"@webiny/error": "5.
|
|
30
|
-
"@webiny/handler": "5.
|
|
31
|
-
"@webiny/handler-aws": "5.
|
|
32
|
-
"@webiny/handler-db": "5.
|
|
33
|
-
"@webiny/plugins": "5.
|
|
34
|
-
"@webiny/utils": "5.
|
|
26
|
+
"@webiny/api-headless-cms": "5.20.0-beta.1",
|
|
27
|
+
"@webiny/api-upgrade": "5.20.0-beta.1",
|
|
28
|
+
"@webiny/db-dynamodb": "5.20.0-beta.1",
|
|
29
|
+
"@webiny/error": "5.20.0-beta.1",
|
|
30
|
+
"@webiny/handler": "5.20.0-beta.1",
|
|
31
|
+
"@webiny/handler-aws": "5.20.0-beta.1",
|
|
32
|
+
"@webiny/handler-db": "5.20.0-beta.1",
|
|
33
|
+
"@webiny/plugins": "5.20.0-beta.1",
|
|
34
|
+
"@webiny/utils": "5.20.0-beta.1",
|
|
35
35
|
"dataloader": "2.0.0",
|
|
36
36
|
"dynamodb-toolbox": "0.3.5",
|
|
37
37
|
"jsonpack": "1.1.5",
|
|
@@ -47,10 +47,10 @@
|
|
|
47
47
|
"@elastic/elasticsearch": "7.12.0",
|
|
48
48
|
"@shelf/jest-elasticsearch": "^1.0.0",
|
|
49
49
|
"@types/jsonpack": "^1.1.0",
|
|
50
|
-
"@webiny/api-dynamodb-to-elasticsearch": "^5.
|
|
51
|
-
"@webiny/api-elasticsearch": "^5.
|
|
52
|
-
"@webiny/cli": "^5.
|
|
53
|
-
"@webiny/project-utils": "^5.
|
|
50
|
+
"@webiny/api-dynamodb-to-elasticsearch": "^5.20.0-beta.1",
|
|
51
|
+
"@webiny/api-elasticsearch": "^5.20.0-beta.1",
|
|
52
|
+
"@webiny/cli": "^5.20.0-beta.1",
|
|
53
|
+
"@webiny/project-utils": "^5.20.0-beta.1",
|
|
54
54
|
"jest": "^26.6.3",
|
|
55
55
|
"jest-dynalite": "^3.2.0",
|
|
56
56
|
"jest-environment-node": "^26.6.2",
|
|
@@ -69,5 +69,5 @@
|
|
|
69
69
|
"build": "yarn webiny run build",
|
|
70
70
|
"watch": "yarn webiny run watch"
|
|
71
71
|
},
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "40e30fb4c778d0bcc773b3b8231ce8e0861b6d52"
|
|
73
73
|
}
|
|
@@ -2,6 +2,7 @@ import { Plugin } from "@webiny/plugins/Plugin";
|
|
|
2
2
|
import { CmsModelField } from "@webiny/api-headless-cms/types";
|
|
3
3
|
export interface CreatePathCallableParams<T = any> {
|
|
4
4
|
field: CmsModelField;
|
|
5
|
+
key: string;
|
|
5
6
|
value: T;
|
|
6
7
|
}
|
|
7
8
|
export interface CreatePathCallable<T = any> {
|