@opra/elastic 0.21.0 → 0.23.0
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/cjs/elastic-adapter.js +18 -18
- package/esm/elastic-adapter.js +18 -18
- package/package.json +3 -3
package/cjs/elastic-adapter.js
CHANGED
|
@@ -19,36 +19,36 @@ var ElasticAdapter;
|
|
|
19
19
|
function transformRequest(request) {
|
|
20
20
|
const { resource } = request;
|
|
21
21
|
if (resource instanceof common_1.Collection || resource instanceof common_1.Singleton) {
|
|
22
|
-
const {
|
|
22
|
+
const { params, operation } = request;
|
|
23
23
|
let options = {};
|
|
24
24
|
switch (operation) {
|
|
25
25
|
case 'findMany': {
|
|
26
|
-
let
|
|
27
|
-
const filter = ElasticAdapter.transformFilter(
|
|
26
|
+
let searchRequest = {};
|
|
27
|
+
const filter = ElasticAdapter.transformFilter(params?.filter);
|
|
28
28
|
if (filter)
|
|
29
|
-
|
|
30
|
-
if (
|
|
31
|
-
|
|
32
|
-
if (
|
|
33
|
-
|
|
34
|
-
if (
|
|
35
|
-
|
|
36
|
-
if (
|
|
37
|
-
|
|
38
|
-
if (
|
|
39
|
-
|
|
40
|
-
|
|
29
|
+
searchRequest.query = filter;
|
|
30
|
+
if (params?.limit != null)
|
|
31
|
+
searchRequest.size = params.limit;
|
|
32
|
+
if (params?.skip != null)
|
|
33
|
+
searchRequest.from = params.skip;
|
|
34
|
+
if (params?.count)
|
|
35
|
+
searchRequest.track_total_hits = true;
|
|
36
|
+
if (params?.pick || params?.include || params?.omit)
|
|
37
|
+
searchRequest._source = (0, transform_projection_js_1.default)(resource.type, params);
|
|
38
|
+
if (params?.sort)
|
|
39
|
+
searchRequest.sort = (0, transform_sort_js_1.default)(params.sort);
|
|
40
|
+
searchRequest = (0, lodash_omitby_1.default)(searchRequest, lodash_isnil_1.default);
|
|
41
41
|
options = (0, lodash_omitby_1.default)(options, lodash_isnil_1.default);
|
|
42
42
|
return {
|
|
43
43
|
method: 'search',
|
|
44
|
-
params,
|
|
44
|
+
params: searchRequest,
|
|
45
45
|
options,
|
|
46
|
-
args: [
|
|
46
|
+
args: [searchRequest, options]
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
throw new TypeError(`Unimplemented request (${request.
|
|
51
|
+
throw new TypeError(`Unimplemented request (${request.resource.kind}.${request.operation})`);
|
|
52
52
|
}
|
|
53
53
|
ElasticAdapter.transformRequest = transformRequest;
|
|
54
54
|
})(ElasticAdapter || (exports.ElasticAdapter = ElasticAdapter = {}));
|
package/esm/elastic-adapter.js
CHANGED
|
@@ -15,36 +15,36 @@ export var ElasticAdapter;
|
|
|
15
15
|
function transformRequest(request) {
|
|
16
16
|
const { resource } = request;
|
|
17
17
|
if (resource instanceof Collection || resource instanceof Singleton) {
|
|
18
|
-
const {
|
|
18
|
+
const { params, operation } = request;
|
|
19
19
|
let options = {};
|
|
20
20
|
switch (operation) {
|
|
21
21
|
case 'findMany': {
|
|
22
|
-
let
|
|
23
|
-
const filter = ElasticAdapter.transformFilter(
|
|
22
|
+
let searchRequest = {};
|
|
23
|
+
const filter = ElasticAdapter.transformFilter(params?.filter);
|
|
24
24
|
if (filter)
|
|
25
|
-
|
|
26
|
-
if (
|
|
27
|
-
|
|
28
|
-
if (
|
|
29
|
-
|
|
30
|
-
if (
|
|
31
|
-
|
|
32
|
-
if (
|
|
33
|
-
|
|
34
|
-
if (
|
|
35
|
-
|
|
36
|
-
|
|
25
|
+
searchRequest.query = filter;
|
|
26
|
+
if (params?.limit != null)
|
|
27
|
+
searchRequest.size = params.limit;
|
|
28
|
+
if (params?.skip != null)
|
|
29
|
+
searchRequest.from = params.skip;
|
|
30
|
+
if (params?.count)
|
|
31
|
+
searchRequest.track_total_hits = true;
|
|
32
|
+
if (params?.pick || params?.include || params?.omit)
|
|
33
|
+
searchRequest._source = _transformProjection(resource.type, params);
|
|
34
|
+
if (params?.sort)
|
|
35
|
+
searchRequest.sort = _transformSort(params.sort);
|
|
36
|
+
searchRequest = omitBy(searchRequest, isNil);
|
|
37
37
|
options = omitBy(options, isNil);
|
|
38
38
|
return {
|
|
39
39
|
method: 'search',
|
|
40
|
-
params,
|
|
40
|
+
params: searchRequest,
|
|
41
41
|
options,
|
|
42
|
-
args: [
|
|
42
|
+
args: [searchRequest, options]
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
throw new TypeError(`Unimplemented request (${request.
|
|
47
|
+
throw new TypeError(`Unimplemented request (${request.resource.kind}.${request.operation})`);
|
|
48
48
|
}
|
|
49
49
|
ElasticAdapter.transformRequest = transformRequest;
|
|
50
50
|
})(ElasticAdapter || (ElasticAdapter = {}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opra/elastic",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.0",
|
|
4
4
|
"description": "Opra Elastic Search adapter package",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"@elastic/elasticsearch": ">=8.7.0",
|
|
37
|
-
"@opra/common": "^0.
|
|
38
|
-
"@opra/core": "^0.
|
|
37
|
+
"@opra/common": "^0.23.0",
|
|
38
|
+
"@opra/core": "^0.23.0"
|
|
39
39
|
},
|
|
40
40
|
"type": "module",
|
|
41
41
|
"types": "types/index.d.ts",
|