@opra/elastic 1.5.2 → 1.5.3
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.
|
@@ -3,14 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.default = prepareProjection;
|
|
4
4
|
exports.prepare = prepare;
|
|
5
5
|
const common_1 = require("@opra/common");
|
|
6
|
-
function prepareProjection(dataType, projection) {
|
|
6
|
+
function prepareProjection(dataType, projection, scope) {
|
|
7
7
|
const out = {};
|
|
8
8
|
const includes = [];
|
|
9
9
|
const excludes = [];
|
|
10
10
|
const projection_ = typeof projection === 'string' || Array.isArray(projection)
|
|
11
11
|
? (0, common_1.parseFieldsProjection)(projection)
|
|
12
12
|
: projection;
|
|
13
|
-
prepare(dataType, includes, excludes, '', projection_);
|
|
13
|
+
prepare(dataType, includes, excludes, '', projection_, scope);
|
|
14
14
|
if (includes.length)
|
|
15
15
|
out.includes = includes;
|
|
16
16
|
if (excludes.length)
|
|
@@ -20,7 +20,7 @@ function prepareProjection(dataType, projection) {
|
|
|
20
20
|
function getNeedIncludes(projection) {
|
|
21
21
|
return !!(projection && Object.values(projection).find(p => !p.sign));
|
|
22
22
|
}
|
|
23
|
-
function prepare(dataType, includes, excludes, curPath, projection) {
|
|
23
|
+
function prepare(dataType, includes, excludes, curPath, projection, scope) {
|
|
24
24
|
const needIncludes = getNeedIncludes(projection);
|
|
25
25
|
const projectionKeys = projection && Object.keys(projection);
|
|
26
26
|
const projectionKeysSet = new Set(projectionKeys);
|
|
@@ -29,7 +29,7 @@ function prepare(dataType, includes, excludes, curPath, projection) {
|
|
|
29
29
|
let field;
|
|
30
30
|
let k;
|
|
31
31
|
/** Add fields from data type */
|
|
32
|
-
for (field of dataType.fields
|
|
32
|
+
for (field of dataType.fields(scope)) {
|
|
33
33
|
fieldName = field.name;
|
|
34
34
|
fieldPath = curPath + (curPath ? '.' : '') + fieldName;
|
|
35
35
|
k = fieldName.toLowerCase();
|
|
@@ -215,7 +215,7 @@ class ElasticEntityService extends elastic_service_js_1.ElasticService {
|
|
|
215
215
|
sort: options?.sort
|
|
216
216
|
? elastic_adapter_js_1.ElasticAdapter.prepareSort(options?.sort)
|
|
217
217
|
: undefined,
|
|
218
|
-
_source: elastic_adapter_js_1.ElasticAdapter.prepareProjection(this.dataType, options?.projection),
|
|
218
|
+
_source: elastic_adapter_js_1.ElasticAdapter.prepareProjection(this.dataType, options?.projection, this.scope),
|
|
219
219
|
index: this.getIndexName(),
|
|
220
220
|
...options?.request,
|
|
221
221
|
query,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { ComplexType, parseFieldsProjection, } from '@opra/common';
|
|
2
|
-
export default function prepareProjection(dataType, projection) {
|
|
2
|
+
export default function prepareProjection(dataType, projection, scope) {
|
|
3
3
|
const out = {};
|
|
4
4
|
const includes = [];
|
|
5
5
|
const excludes = [];
|
|
6
6
|
const projection_ = typeof projection === 'string' || Array.isArray(projection)
|
|
7
7
|
? parseFieldsProjection(projection)
|
|
8
8
|
: projection;
|
|
9
|
-
prepare(dataType, includes, excludes, '', projection_);
|
|
9
|
+
prepare(dataType, includes, excludes, '', projection_, scope);
|
|
10
10
|
if (includes.length)
|
|
11
11
|
out.includes = includes;
|
|
12
12
|
if (excludes.length)
|
|
@@ -16,7 +16,7 @@ export default function prepareProjection(dataType, projection) {
|
|
|
16
16
|
function getNeedIncludes(projection) {
|
|
17
17
|
return !!(projection && Object.values(projection).find(p => !p.sign));
|
|
18
18
|
}
|
|
19
|
-
export function prepare(dataType, includes, excludes, curPath, projection) {
|
|
19
|
+
export function prepare(dataType, includes, excludes, curPath, projection, scope) {
|
|
20
20
|
const needIncludes = getNeedIncludes(projection);
|
|
21
21
|
const projectionKeys = projection && Object.keys(projection);
|
|
22
22
|
const projectionKeysSet = new Set(projectionKeys);
|
|
@@ -25,7 +25,7 @@ export function prepare(dataType, includes, excludes, curPath, projection) {
|
|
|
25
25
|
let field;
|
|
26
26
|
let k;
|
|
27
27
|
/** Add fields from data type */
|
|
28
|
-
for (field of dataType.fields
|
|
28
|
+
for (field of dataType.fields(scope)) {
|
|
29
29
|
fieldName = field.name;
|
|
30
30
|
fieldPath = curPath + (curPath ? '.' : '') + fieldName;
|
|
31
31
|
k = fieldName.toLowerCase();
|
|
@@ -212,7 +212,7 @@ export class ElasticEntityService extends ElasticService {
|
|
|
212
212
|
sort: options?.sort
|
|
213
213
|
? ElasticAdapter.prepareSort(options?.sort)
|
|
214
214
|
: undefined,
|
|
215
|
-
_source: ElasticAdapter.prepareProjection(this.dataType, options?.projection),
|
|
215
|
+
_source: ElasticAdapter.prepareProjection(this.dataType, options?.projection, this.scope),
|
|
216
216
|
index: this.getIndexName(),
|
|
217
217
|
...options?.request,
|
|
218
218
|
query,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opra/elastic",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.3",
|
|
4
4
|
"description": "Opra Elastic Search adapter package",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
},
|
|
12
12
|
"peerDependencies": {
|
|
13
13
|
"@elastic/elasticsearch": ">=8.7.0",
|
|
14
|
-
"@opra/common": "^1.5.
|
|
15
|
-
"@opra/core": "^1.5.
|
|
14
|
+
"@opra/common": "^1.5.3",
|
|
15
|
+
"@opra/core": "^1.5.3"
|
|
16
16
|
},
|
|
17
17
|
"type": "module",
|
|
18
18
|
"exports": {
|
|
@@ -3,5 +3,5 @@ export interface ElasticProjection {
|
|
|
3
3
|
includes?: string[];
|
|
4
4
|
excludes?: string[];
|
|
5
5
|
}
|
|
6
|
-
export default function prepareProjection(dataType: ComplexType, projection?: string | string[]): ElasticProjection | undefined;
|
|
7
|
-
export declare function prepare(dataType: ComplexType, includes: string[], excludes: string[], curPath: string, projection?: FieldsProjection): void;
|
|
6
|
+
export default function prepareProjection(dataType: ComplexType, projection?: string | string[], scope?: string): ElasticProjection | undefined;
|
|
7
|
+
export declare function prepare(dataType: ComplexType, includes: string[], excludes: string[], curPath: string, projection?: FieldsProjection, scope?: string): void;
|