@webiny/api-headless-cms-ddb-es 5.18.3-beta.0 → 5.19.0-beta.2
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/elasticsearch/index.d.ts +1 -1
- package/elasticsearch/search/index.d.ts +2 -2
- package/elasticsearch/search/index.js +3 -5
- package/elasticsearch/search/refSearch.d.ts +2 -3
- package/elasticsearch/search/refSearch.js +21 -17
- package/elasticsearch/search/timeSearch.d.ts +2 -3
- package/elasticsearch/search/timeSearch.js +20 -14
- package/helpers/createElasticsearchQueryBody.js +144 -23
- package/helpers/operatorPluginsList.d.ts +1 -2
- package/helpers/searchPluginsList.d.ts +2 -2
- package/operations/entry/dataLoaders.js +5 -4
- package/operations/entry/elasticsearchFields.js +3 -0
- package/operations/entry/fields.js +8 -0
- package/operations/entry/index.js +14 -29
- package/package.json +15 -15
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.d.ts +29 -0
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js +43 -0
- package/types.d.ts +0 -29
- package/types.js +0 -13
package/elasticsearch/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: () => (import("../types").CmsModelFieldToElasticsearchPlugin[] | import("../
|
|
1
|
+
declare const _default: () => (import("../types").CmsModelFieldToElasticsearchPlugin[] | import("../plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin").CmsEntryElasticsearchQueryBuilderValueSearchPlugin[])[];
|
|
2
2
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
declare const _default: () =>
|
|
1
|
+
import { CmsEntryElasticsearchQueryBuilderValueSearchPlugin } from "../../plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin";
|
|
2
|
+
declare const _default: () => CmsEntryElasticsearchQueryBuilderValueSearchPlugin[];
|
|
3
3
|
export default _default;
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
6
|
exports.default = void 0;
|
|
9
7
|
|
|
10
|
-
var _timeSearch =
|
|
8
|
+
var _timeSearch = require("./timeSearch");
|
|
11
9
|
|
|
12
|
-
var _refSearch =
|
|
10
|
+
var _refSearch = require("./refSearch");
|
|
13
11
|
|
|
14
|
-
var _default = () => [(0, _timeSearch.
|
|
12
|
+
var _default = () => [(0, _timeSearch.createTimeSearchPlugin)(), (0, _refSearch.createRefSearchPlugin)()];
|
|
15
13
|
|
|
16
14
|
exports.default = _default;
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
declare const
|
|
3
|
-
export default _default;
|
|
1
|
+
import { CmsEntryElasticsearchQueryBuilderValueSearchPlugin } from "../../plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin";
|
|
2
|
+
export declare const createRefSearchPlugin: () => CmsEntryElasticsearchQueryBuilderValueSearchPlugin;
|
|
@@ -3,22 +3,26 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.createRefSearchPlugin = void 0;
|
|
7
7
|
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
8
|
+
var _CmsEntryElasticsearchQueryBuilderValueSearchPlugin = require("../../plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin");
|
|
9
|
+
|
|
10
|
+
const createPath = params => {
|
|
11
|
+
const value = `${params.value || ""}`;
|
|
12
|
+
const target = value && value.includes("#") ? "id" : "entryId";
|
|
13
|
+
return `${params.field.fieldId}.${target}`;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const transform = params => {
|
|
17
|
+
return params.value;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const createRefSearchPlugin = () => {
|
|
21
|
+
return new _CmsEntryElasticsearchQueryBuilderValueSearchPlugin.CmsEntryElasticsearchQueryBuilderValueSearchPlugin({
|
|
22
|
+
fieldType: "ref",
|
|
23
|
+
path: createPath,
|
|
24
|
+
transform
|
|
25
|
+
});
|
|
26
|
+
};
|
|
23
27
|
|
|
24
|
-
exports.
|
|
28
|
+
exports.createRefSearchPlugin = createRefSearchPlugin;
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
declare const
|
|
3
|
-
export default _default;
|
|
1
|
+
import { CmsEntryElasticsearchQueryBuilderValueSearchPlugin } from "../../plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin";
|
|
2
|
+
export declare const createTimeSearchPlugin: () => CmsEntryElasticsearchQueryBuilderValueSearchPlugin;
|
|
@@ -3,23 +3,29 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.createTimeSearchPlugin = void 0;
|
|
7
7
|
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
transform: ({
|
|
8
|
+
var _CmsEntryElasticsearchQueryBuilderValueSearchPlugin = require("../../plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin");
|
|
9
|
+
|
|
10
|
+
const transform = params => {
|
|
11
|
+
const {
|
|
13
12
|
field,
|
|
14
13
|
value
|
|
15
|
-
}
|
|
16
|
-
if (field.settings.type !== "time") {
|
|
17
|
-
return value;
|
|
18
|
-
}
|
|
14
|
+
} = params;
|
|
19
15
|
|
|
20
|
-
|
|
21
|
-
return
|
|
16
|
+
if (!value || field.settings.type !== "time") {
|
|
17
|
+
return value;
|
|
22
18
|
}
|
|
23
|
-
});
|
|
24
19
|
|
|
25
|
-
|
|
20
|
+
const [hours, minutes, seconds = 0] = value.split(":").map(Number);
|
|
21
|
+
return hours * 60 * 60 + minutes * 60 + seconds;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const createTimeSearchPlugin = () => {
|
|
25
|
+
return new _CmsEntryElasticsearchQueryBuilderValueSearchPlugin.CmsEntryElasticsearchQueryBuilderValueSearchPlugin({
|
|
26
|
+
fieldType: "datetime",
|
|
27
|
+
transform
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
exports.createTimeSearchPlugin = createTimeSearchPlugin;
|
|
@@ -64,7 +64,7 @@ const createElasticsearchSortParams = args => {
|
|
|
64
64
|
field: modelField.field.fieldId,
|
|
65
65
|
path: createFieldPath({
|
|
66
66
|
parentPath,
|
|
67
|
-
modelField
|
|
67
|
+
modelField,
|
|
68
68
|
searchPlugin
|
|
69
69
|
})
|
|
70
70
|
});
|
|
@@ -154,7 +154,8 @@ const createFieldPath = ({
|
|
|
154
154
|
|
|
155
155
|
if (searchPlugin && typeof searchPlugin.createPath === "function") {
|
|
156
156
|
path = searchPlugin.createPath({
|
|
157
|
-
field: modelField.field
|
|
157
|
+
field: modelField.field,
|
|
158
|
+
value: null
|
|
158
159
|
});
|
|
159
160
|
} else if (typeof modelField.path === "function") {
|
|
160
161
|
path = modelField.path(modelField.field.fieldId);
|
|
@@ -191,6 +192,112 @@ const hasKeyword = modelField => {
|
|
|
191
192
|
|
|
192
193
|
return true;
|
|
193
194
|
};
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* A list of typeof strings that are 100% not ref field filtering.
|
|
198
|
+
* We also need to check for array and date.
|
|
199
|
+
*/
|
|
200
|
+
const nonRefFieldTypes = ["string", "number", "undefined", "symbol", "bigint", "function", "boolean"];
|
|
201
|
+
|
|
202
|
+
const isRefFieldFiltering = params => {
|
|
203
|
+
const {
|
|
204
|
+
key,
|
|
205
|
+
value,
|
|
206
|
+
field
|
|
207
|
+
} = params;
|
|
208
|
+
const typeOf = typeof value;
|
|
209
|
+
|
|
210
|
+
if (!value || nonRefFieldTypes.includes(typeOf) || Array.isArray(value) || value instanceof Date || !!value.toISOString) {
|
|
211
|
+
return false;
|
|
212
|
+
} else if (typeOf === "object" && field.type === "ref") {
|
|
213
|
+
return true;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
throw new _error.default("Could not determine if the search value is ref field search.", "REF_FIELD_SEARCH_ERROR", {
|
|
217
|
+
value,
|
|
218
|
+
field,
|
|
219
|
+
key
|
|
220
|
+
});
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
const fieldPathFactory = params => {
|
|
224
|
+
const {
|
|
225
|
+
plugin,
|
|
226
|
+
modelField,
|
|
227
|
+
value,
|
|
228
|
+
parentPath,
|
|
229
|
+
keyword
|
|
230
|
+
} = params;
|
|
231
|
+
const field = modelField.field;
|
|
232
|
+
let fieldPath;
|
|
233
|
+
|
|
234
|
+
if (plugin) {
|
|
235
|
+
fieldPath = plugin.createPath({
|
|
236
|
+
field,
|
|
237
|
+
value
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
if (!fieldPath) {
|
|
242
|
+
fieldPath = field.fieldId;
|
|
243
|
+
|
|
244
|
+
if (modelField.path) {
|
|
245
|
+
fieldPath = typeof modelField.path === "function" ? modelField.path(value) : modelField.path;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
const keywordValue = keyword ? ".keyword" : "";
|
|
250
|
+
|
|
251
|
+
if (!parentPath) {
|
|
252
|
+
return `${fieldPath}${keywordValue}`;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
return `${parentPath}.${fieldPath}${keywordValue}`;
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
const applyFiltering = params => {
|
|
259
|
+
const {
|
|
260
|
+
query,
|
|
261
|
+
modelField,
|
|
262
|
+
operator,
|
|
263
|
+
value: initialValue,
|
|
264
|
+
operatorPlugins,
|
|
265
|
+
searchPlugins,
|
|
266
|
+
parentPath
|
|
267
|
+
} = params;
|
|
268
|
+
const plugin = operatorPlugins[operator];
|
|
269
|
+
|
|
270
|
+
if (!plugin) {
|
|
271
|
+
throw new _error.default("Operator plugin missing.", "PLUGIN_MISSING", {
|
|
272
|
+
operator
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
const fieldSearchPlugin = searchPlugins[modelField.type];
|
|
277
|
+
const value = (0, _transformValueForSearch.transformValueForSearch)({
|
|
278
|
+
plugins: searchPlugins,
|
|
279
|
+
field: modelField.field,
|
|
280
|
+
value: initialValue
|
|
281
|
+
});
|
|
282
|
+
const keyword = hasKeyword(modelField);
|
|
283
|
+
plugin.apply(query, {
|
|
284
|
+
basePath: fieldPathFactory({
|
|
285
|
+
plugin: fieldSearchPlugin,
|
|
286
|
+
modelField,
|
|
287
|
+
parentPath: modelField.isSystemField ? null : parentPath,
|
|
288
|
+
value
|
|
289
|
+
}),
|
|
290
|
+
path: fieldPathFactory({
|
|
291
|
+
plugin: fieldSearchPlugin,
|
|
292
|
+
modelField,
|
|
293
|
+
value,
|
|
294
|
+
parentPath: modelField.isSystemField ? null : parentPath,
|
|
295
|
+
keyword
|
|
296
|
+
}),
|
|
297
|
+
value,
|
|
298
|
+
keyword
|
|
299
|
+
});
|
|
300
|
+
};
|
|
194
301
|
/*
|
|
195
302
|
* Iterate through where keys and apply plugins where necessary
|
|
196
303
|
*/
|
|
@@ -256,32 +363,46 @@ const execElasticsearchBuildQueryPlugins = params => {
|
|
|
256
363
|
if (!isSearchable) {
|
|
257
364
|
throw new _error.default(`Field "${field}" is not searchable.`);
|
|
258
365
|
}
|
|
366
|
+
/**
|
|
367
|
+
* There is a possibility that value is an object.
|
|
368
|
+
* In that case, check if field is ref field and continue a bit differently.
|
|
369
|
+
*/
|
|
259
370
|
|
|
260
|
-
const plugin = operatorPlugins[operator];
|
|
261
371
|
|
|
262
|
-
if (
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
372
|
+
if (isRefFieldFiltering({
|
|
373
|
+
key,
|
|
374
|
+
value: where[key],
|
|
375
|
+
field: cmsField
|
|
376
|
+
})) {
|
|
377
|
+
/**
|
|
378
|
+
* We we need to go through each key in where[key] to determine the filters.
|
|
379
|
+
*/
|
|
380
|
+
for (const whereKey in where[key]) {
|
|
381
|
+
const {
|
|
382
|
+
operator
|
|
383
|
+
} = (0, _where.parseWhereKey)(whereKey);
|
|
384
|
+
applyFiltering({
|
|
385
|
+
query,
|
|
386
|
+
modelField,
|
|
387
|
+
operator,
|
|
388
|
+
value: where[key][whereKey],
|
|
389
|
+
searchPlugins,
|
|
390
|
+
operatorPlugins,
|
|
391
|
+
parentPath
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
continue;
|
|
266
396
|
}
|
|
267
397
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
plugins: searchPlugins,
|
|
271
|
-
field: cmsField,
|
|
272
|
-
value: where[key]
|
|
273
|
-
});
|
|
274
|
-
const fieldPath = createFieldPath({
|
|
275
|
-
searchPlugin: fieldSearchPlugin,
|
|
398
|
+
applyFiltering({
|
|
399
|
+
query,
|
|
276
400
|
modelField,
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
path: keyword ? `${fieldPath}.keyword` : fieldPath,
|
|
283
|
-
value,
|
|
284
|
-
keyword
|
|
401
|
+
operator,
|
|
402
|
+
value: where[key],
|
|
403
|
+
searchPlugins,
|
|
404
|
+
operatorPlugins,
|
|
405
|
+
parentPath
|
|
285
406
|
});
|
|
286
407
|
}
|
|
287
408
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ElasticsearchQueryBuilderOperatorPlugin } from "@webiny/api-elasticsearch/plugins/definition/ElasticsearchQueryBuilderOperatorPlugin";
|
|
2
2
|
import { PluginsContainer } from "@webiny/plugins";
|
|
3
|
-
interface OperatorPlugins {
|
|
3
|
+
export interface OperatorPlugins {
|
|
4
4
|
[operator: string]: ElasticsearchQueryBuilderOperatorPlugin;
|
|
5
5
|
}
|
|
6
6
|
export declare const operatorPluginsList: (plugins: PluginsContainer) => OperatorPlugins;
|
|
7
|
-
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ElasticsearchQueryBuilderValueSearchPlugin } from "../types";
|
|
2
1
|
import { PluginsContainer } from "@webiny/plugins";
|
|
2
|
+
import { CmsEntryElasticsearchQueryBuilderValueSearchPlugin } from "../plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin";
|
|
3
3
|
export interface ElasticsearchQuerySearchValuePlugins {
|
|
4
|
-
[fieldType: string]:
|
|
4
|
+
[fieldType: string]: CmsEntryElasticsearchQueryBuilderValueSearchPlugin;
|
|
5
5
|
}
|
|
6
6
|
export declare const searchPluginsList: (plugins: PluginsContainer) => ElasticsearchQuerySearchValuePlugins;
|
|
@@ -37,7 +37,7 @@ const getAllEntryRevisions = params => {
|
|
|
37
37
|
locale
|
|
38
38
|
} = model;
|
|
39
39
|
return new _dataloader.default(async ids => {
|
|
40
|
-
const results =
|
|
40
|
+
const results = {};
|
|
41
41
|
|
|
42
42
|
for (const id of ids) {
|
|
43
43
|
const queryAllParams = {
|
|
@@ -52,11 +52,12 @@ const getAllEntryRevisions = params => {
|
|
|
52
52
|
}
|
|
53
53
|
};
|
|
54
54
|
const items = await (0, _query.queryAll)(queryAllParams);
|
|
55
|
-
|
|
56
|
-
results.push(entries);
|
|
55
|
+
results[id] = (0, _cleanup.cleanupItems)(entity, items);
|
|
57
56
|
}
|
|
58
57
|
|
|
59
|
-
return
|
|
58
|
+
return ids.map(id => {
|
|
59
|
+
return results[id] || [];
|
|
60
|
+
});
|
|
60
61
|
});
|
|
61
62
|
};
|
|
62
63
|
|
|
@@ -22,6 +22,9 @@ const elasticsearchFields = [new _CmsEntryElasticsearchFieldPlugin.CmsEntryElast
|
|
|
22
22
|
}), new _CmsEntryElasticsearchFieldPlugin.CmsEntryElasticsearchFieldPlugin({
|
|
23
23
|
field: "createdBy",
|
|
24
24
|
path: "createdBy.id"
|
|
25
|
+
}), new _CmsEntryElasticsearchFieldPlugin.CmsEntryElasticsearchFieldPlugin({
|
|
26
|
+
field: "version",
|
|
27
|
+
path: "version"
|
|
25
28
|
}),
|
|
26
29
|
/**
|
|
27
30
|
* Always add the ALL fields plugin because of the keyword/path build.
|
|
@@ -42,6 +42,14 @@ const systemFields = {
|
|
|
42
42
|
keyword: false,
|
|
43
43
|
sortable: false,
|
|
44
44
|
unmappedType: "date"
|
|
45
|
+
}),
|
|
46
|
+
version: new _CmsEntryElasticsearchFieldPlugin.CmsEntryElasticsearchFieldPlugin({
|
|
47
|
+
field: "version",
|
|
48
|
+
path: "version",
|
|
49
|
+
sortable: true,
|
|
50
|
+
searchable: true,
|
|
51
|
+
keyword: false,
|
|
52
|
+
unmappedType: "number"
|
|
45
53
|
})
|
|
46
54
|
};
|
|
47
55
|
|
|
@@ -639,37 +639,30 @@ const createEntriesStorageOperations = params => {
|
|
|
639
639
|
model,
|
|
640
640
|
ids: [publishedStorageEntry.id]
|
|
641
641
|
});
|
|
642
|
-
previouslyPublishedEntry.status = _types.CONTENT_ENTRY_STATUS.UNPUBLISHED;
|
|
643
642
|
items.push(
|
|
644
643
|
/**
|
|
645
644
|
* Update currently published entry (unpublish it)
|
|
646
645
|
*/
|
|
647
646
|
entity.putBatch(_objectSpread(_objectSpread({}, previouslyPublishedEntry), {}, {
|
|
647
|
+
status: _types.CONTENT_ENTRY_STATUS.UNPUBLISHED,
|
|
648
648
|
savedOn: entry.savedOn,
|
|
649
649
|
TYPE: createType(),
|
|
650
650
|
PK: (0, _keys.createPartitionKey)(publishedStorageEntry),
|
|
651
651
|
SK: (0, _keys.createRevisionSortKey)(publishedStorageEntry)
|
|
652
|
-
})),
|
|
653
|
-
/**
|
|
654
|
-
* Update the helper item in DB with the new published entry ID
|
|
655
|
-
*/
|
|
656
|
-
entity.putBatch(_objectSpread(_objectSpread({}, storageEntry), {}, {
|
|
657
|
-
TYPE: createType(),
|
|
658
|
-
PK: (0, _keys.createPartitionKey)(storageEntry),
|
|
659
|
-
SK: (0, _keys.createPublishedSortKey)()
|
|
660
|
-
})));
|
|
661
|
-
} else {
|
|
662
|
-
items.push(entity.putBatch(_objectSpread(_objectSpread({}, storageEntry), {}, {
|
|
663
|
-
PK: (0, _keys.createPartitionKey)(storageEntry),
|
|
664
|
-
SK: (0, _keys.createPublishedSortKey)(),
|
|
665
|
-
TYPE: createPublishedType()
|
|
666
652
|
})));
|
|
667
653
|
}
|
|
668
654
|
/**
|
|
669
|
-
*
|
|
655
|
+
* Update the helper item in DB with the new published entry
|
|
670
656
|
*/
|
|
671
657
|
|
|
672
658
|
|
|
659
|
+
items.push(entity.putBatch(_objectSpread(_objectSpread(_objectSpread({}, storageEntry), publishedKeys), {}, {
|
|
660
|
+
TYPE: createPublishedType()
|
|
661
|
+
})));
|
|
662
|
+
/**
|
|
663
|
+
* We need the latest entry to check if it neds to be updated as well in the Elasticsearch.
|
|
664
|
+
*/
|
|
665
|
+
|
|
673
666
|
const [latestStorageEntry] = await dataLoaders.getLatestRevisionByEntryId({
|
|
674
667
|
model,
|
|
675
668
|
ids: [entry.id]
|
|
@@ -707,12 +700,10 @@ const createEntriesStorageOperations = params => {
|
|
|
707
700
|
*/
|
|
708
701
|
|
|
709
702
|
const esLatestData = await getESPublishedEntryData(plugins, preparedEntryData);
|
|
710
|
-
esItems.push(esEntity.putBatch({
|
|
711
|
-
PK: (0, _keys.createPartitionKey)(entry),
|
|
712
|
-
SK: (0, _keys.createPublishedSortKey)(),
|
|
703
|
+
esItems.push(esEntity.putBatch(_objectSpread(_objectSpread({}, publishedKeys), {}, {
|
|
713
704
|
index,
|
|
714
705
|
data: esLatestData
|
|
715
|
-
}));
|
|
706
|
+
})));
|
|
716
707
|
/**
|
|
717
708
|
* Finally, execute regular table batch.
|
|
718
709
|
*/
|
|
@@ -1014,13 +1005,6 @@ const createEntriesStorageOperations = params => {
|
|
|
1014
1005
|
return storageEntry;
|
|
1015
1006
|
};
|
|
1016
1007
|
|
|
1017
|
-
const getAllRevisionsByIds = async (model, params) => {
|
|
1018
|
-
return await dataLoaders.getAllEntryRevisions({
|
|
1019
|
-
model,
|
|
1020
|
-
ids: params.ids
|
|
1021
|
-
});
|
|
1022
|
-
};
|
|
1023
|
-
|
|
1024
1008
|
const getLatestRevisionByEntryId = async (model, params) => {
|
|
1025
1009
|
const result = await dataLoaders.getLatestRevisionByEntryId({
|
|
1026
1010
|
model,
|
|
@@ -1091,7 +1075,9 @@ const createEntriesStorageOperations = params => {
|
|
|
1091
1075
|
const getPreviousRevision = async (model, params) => {
|
|
1092
1076
|
const {
|
|
1093
1077
|
tenant,
|
|
1094
|
-
locale
|
|
1078
|
+
locale
|
|
1079
|
+
} = model;
|
|
1080
|
+
const {
|
|
1095
1081
|
entryId,
|
|
1096
1082
|
version
|
|
1097
1083
|
} = params;
|
|
@@ -1144,7 +1130,6 @@ const createEntriesStorageOperations = params => {
|
|
|
1144
1130
|
requestReview,
|
|
1145
1131
|
requestChanges,
|
|
1146
1132
|
list,
|
|
1147
|
-
getAllRevisionsByIds,
|
|
1148
1133
|
getLatestRevisionByEntryId,
|
|
1149
1134
|
getPublishedRevisionByEntryId,
|
|
1150
1135
|
getRevisionById,
|
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.19.0-beta.2",
|
|
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.19.0-beta.2",
|
|
27
|
+
"@webiny/api-upgrade": "5.19.0-beta.2",
|
|
28
|
+
"@webiny/db-dynamodb": "5.19.0-beta.2",
|
|
29
|
+
"@webiny/error": "5.19.0-beta.2",
|
|
30
|
+
"@webiny/handler": "5.19.0-beta.2",
|
|
31
|
+
"@webiny/handler-aws": "5.19.0-beta.2",
|
|
32
|
+
"@webiny/handler-db": "5.19.0-beta.2",
|
|
33
|
+
"@webiny/plugins": "5.19.0-beta.2",
|
|
34
|
+
"@webiny/utils": "5.19.0-beta.2",
|
|
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.19.0-beta.2",
|
|
51
|
+
"@webiny/api-elasticsearch": "^5.19.0-beta.2",
|
|
52
|
+
"@webiny/cli": "^5.19.0-beta.2",
|
|
53
|
+
"@webiny/project-utils": "^5.19.0-beta.2",
|
|
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": "6817702cc537405b7288c1fc63ee5d40531b4122"
|
|
73
73
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Plugin } from "@webiny/plugins/Plugin";
|
|
2
|
+
import { CmsModelField } from "@webiny/api-headless-cms/types";
|
|
3
|
+
export interface CreatePathCallableParams<T = any> {
|
|
4
|
+
field: CmsModelField;
|
|
5
|
+
value: T;
|
|
6
|
+
}
|
|
7
|
+
export interface CreatePathCallable<T = any> {
|
|
8
|
+
(params: CreatePathCallableParams<T>): string;
|
|
9
|
+
}
|
|
10
|
+
export interface TransformCallableParams<T = any> {
|
|
11
|
+
field: CmsModelField;
|
|
12
|
+
value: T;
|
|
13
|
+
}
|
|
14
|
+
export interface TransformCallable<T = any> {
|
|
15
|
+
(params: TransformCallableParams<T>): string;
|
|
16
|
+
}
|
|
17
|
+
export interface Params {
|
|
18
|
+
fieldType: string;
|
|
19
|
+
path?: string | CreatePathCallable;
|
|
20
|
+
transform: TransformCallable;
|
|
21
|
+
}
|
|
22
|
+
export declare class CmsEntryElasticsearchQueryBuilderValueSearchPlugin extends Plugin {
|
|
23
|
+
static readonly type: string;
|
|
24
|
+
private readonly config;
|
|
25
|
+
get fieldType(): string;
|
|
26
|
+
constructor(params: Params);
|
|
27
|
+
transform(params: TransformCallableParams): any;
|
|
28
|
+
createPath(params: CreatePathCallableParams): string;
|
|
29
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.CmsEntryElasticsearchQueryBuilderValueSearchPlugin = void 0;
|
|
9
|
+
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
var _Plugin = require("@webiny/plugins/Plugin");
|
|
13
|
+
|
|
14
|
+
class CmsEntryElasticsearchQueryBuilderValueSearchPlugin extends _Plugin.Plugin {
|
|
15
|
+
get fieldType() {
|
|
16
|
+
return this.config.fieldType;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
constructor(params) {
|
|
20
|
+
super();
|
|
21
|
+
(0, _defineProperty2.default)(this, "config", void 0);
|
|
22
|
+
this.config = params;
|
|
23
|
+
this.name = `${this.constructor.type}-${this.config.fieldType}`;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
transform(params) {
|
|
27
|
+
return this.config.transform(params);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
createPath(params) {
|
|
31
|
+
if (typeof this.config.path === "function") {
|
|
32
|
+
return this.config.path(params);
|
|
33
|
+
} else if (typeof this.config.path === "string") {
|
|
34
|
+
return this.config.path;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
exports.CmsEntryElasticsearchQueryBuilderValueSearchPlugin = CmsEntryElasticsearchQueryBuilderValueSearchPlugin;
|
|
43
|
+
(0, _defineProperty2.default)(CmsEntryElasticsearchQueryBuilderValueSearchPlugin, "type", "cms-elastic-search-query-builder-value-search");
|
package/types.d.ts
CHANGED
|
@@ -6,35 +6,6 @@ import { EntityAttributeConfig, EntityCompositeAttributes } from "dynamodb-toolb
|
|
|
6
6
|
import { Client } from "@elastic/elasticsearch";
|
|
7
7
|
import { Entity, Table } from "dynamodb-toolbox";
|
|
8
8
|
import { PluginsContainer } from "@webiny/plugins";
|
|
9
|
-
/**
|
|
10
|
-
* Arguments for ElasticsearchQueryBuilderValueSearchPlugin.
|
|
11
|
-
*
|
|
12
|
-
* @see ElasticsearchQueryBuilderValueSearchPlugin.transform
|
|
13
|
-
*/
|
|
14
|
-
interface ElasticsearchQueryBuilderValueSearchPluginArgs {
|
|
15
|
-
field: CmsModelField;
|
|
16
|
-
value: any;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* A plugin definition for transforming the search value for Elasticsearch.
|
|
20
|
-
*
|
|
21
|
-
* @category Plugin
|
|
22
|
-
* @category Elasticsearch
|
|
23
|
-
*/
|
|
24
|
-
export interface ElasticsearchQueryBuilderValueSearchPlugin extends Plugin {
|
|
25
|
-
/**
|
|
26
|
-
* A plugin type.
|
|
27
|
-
*/
|
|
28
|
-
type: "cms-elastic-search-query-builder-value-search";
|
|
29
|
-
/**
|
|
30
|
-
* A field type for plugin to target.
|
|
31
|
-
*/
|
|
32
|
-
fieldType: string;
|
|
33
|
-
/**
|
|
34
|
-
* Transform value that is going to be searched for in the Elasticsearch.
|
|
35
|
-
*/
|
|
36
|
-
transform: (args: ElasticsearchQueryBuilderValueSearchPluginArgs) => any;
|
|
37
|
-
}
|
|
38
9
|
/**
|
|
39
10
|
* A definition of the entry that is being prepared for the Elasticsearch.
|
|
40
11
|
*
|
package/types.js
CHANGED
|
@@ -5,19 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.ENTITIES = void 0;
|
|
7
7
|
|
|
8
|
-
/**
|
|
9
|
-
* Arguments for ElasticsearchQueryBuilderValueSearchPlugin.
|
|
10
|
-
*
|
|
11
|
-
* @see ElasticsearchQueryBuilderValueSearchPlugin.transform
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* A plugin definition for transforming the search value for Elasticsearch.
|
|
16
|
-
*
|
|
17
|
-
* @category Plugin
|
|
18
|
-
* @category Elasticsearch
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
8
|
/**
|
|
22
9
|
* A definition of the entry that is being prepared for the Elasticsearch.
|
|
23
10
|
*
|