elastic-dsl-typescript
Advanced tools
Comparing version 1.1.9 to 1.2.0
@@ -5,3 +5,3 @@ import { AggregationSchema } from '../Aggregation/types'; | ||
interface IFacet { | ||
active: object; | ||
[key: string]: object; | ||
inactive: InactiveFacet; | ||
@@ -8,0 +8,0 @@ } |
@@ -19,3 +19,2 @@ "use strict"; | ||
this._facets = { | ||
active: {}, | ||
inactive: { | ||
@@ -33,2 +32,3 @@ aggs: {}, | ||
let sub = {}; | ||
let data = {}; | ||
if (subAgg) { | ||
@@ -40,3 +40,3 @@ sub = { | ||
if (filter) { | ||
this._facets[facetType][name] = { | ||
data = { | ||
filter, | ||
@@ -47,9 +47,11 @@ aggs: { | ||
}; | ||
return this; | ||
} | ||
this._facets[facetType][name] = Object.assign({ [aggType]: Object.assign(Object.assign({}, all), (d.opts || {})) }, sub); | ||
else { | ||
data = Object.assign({ [aggType]: Object.assign(Object.assign({}, all), (d.opts || {})) }, sub); | ||
} | ||
facetType === 'inactive' ? (this._facets['inactive']['aggs'][name] = data) : (this._facets[name] = data); | ||
return this; | ||
} | ||
addCustom(facetType, name, cutsomAgg) { | ||
this._facets[facetType][name] = cutsomAgg; | ||
facetType === 'inactive' ? (this._facets['inactive']['aggs'][name] = cutsomAgg) : (this._facets[name] = cutsomAgg); | ||
} | ||
@@ -63,5 +65,5 @@ build() { | ||
isNotEmty() { | ||
return Object.keys(Object.assign(Object.assign({}, this._facets.active), this._facets.inactive.aggs)).length > 0; | ||
return Object.keys(Object.assign(Object.assign({}, this._facets), this._facets.inactive.aggs)).length > 1; | ||
} | ||
} | ||
exports.EshopFacets = EshopFacets; |
{ | ||
"name": "elastic-dsl-typescript", | ||
"version": "1.1.9", | ||
"version": "1.2.0", | ||
"description": "Node.js ElasticSearch search query builder", | ||
@@ -5,0 +5,0 @@ "main": "./", |
@@ -1,7 +0,8 @@ | ||
import { AggregationSchema } from '../Aggregation/types'; | ||
import { Bool } from '../Bool'; | ||
import { AbstractBulder } from '../../Abstract/AbstractBuilder'; | ||
import {AggregationSchema} from '../Aggregation/types'; | ||
import {Bool} from '../Bool'; | ||
import {AbstractBulder} from '../../Abstract/AbstractBuilder'; | ||
interface IFacet { | ||
active: object; | ||
[key: string]: object; | ||
inactive: InactiveFacet; | ||
@@ -16,3 +17,2 @@ } | ||
private _facets: IFacet = { | ||
active: {}, | ||
inactive: { | ||
@@ -29,9 +29,10 @@ aggs: {}, | ||
public add<Type extends keyof AggregationSchema>( | ||
facetType: FacetType, | ||
aggType: Type, | ||
name: string, | ||
d: AggregationSchema[Type], | ||
facetType: FacetType, | ||
aggType: Type, | ||
name: string, | ||
d: AggregationSchema[Type], | ||
) { | ||
const { filter, subAgg, ...all } = d.params as { filter?: any; subAgg?: any }; | ||
const {filter, subAgg, ...all} = d.params as { filter?: object; subAgg?: object }; | ||
let sub = {}; | ||
let data = {}; | ||
if (subAgg) { | ||
@@ -45,7 +46,7 @@ sub = { | ||
if (filter) { | ||
this._facets[facetType][name] = { | ||
data = { | ||
filter, | ||
aggs: { | ||
[`${name}_filtered`]: { | ||
[aggType]: { ...all, ...((d.opts as object) || {}) }, | ||
[aggType]: {...all, ...((d.opts as object) || {})}, | ||
...sub, | ||
@@ -55,9 +56,10 @@ }, | ||
}; | ||
return this; | ||
} else { | ||
data = { | ||
[aggType]: {...all, ...((d.opts as object) || {})}, | ||
...sub, | ||
}; | ||
} | ||
this._facets[facetType][name] = { | ||
[aggType]: { ...all, ...((d.opts as object) || {}) }, | ||
...sub, | ||
}; | ||
facetType === 'inactive' ? (this._facets['inactive']['aggs'][name] = data) : (this._facets[name] = data); | ||
return this; | ||
@@ -67,3 +69,3 @@ } | ||
public addCustom(facetType: FacetType, name: string, cutsomAgg: object) { | ||
this._facets[facetType][name] = cutsomAgg; | ||
facetType === 'inactive' ? (this._facets['inactive']['aggs'][name] = cutsomAgg) : (this._facets[name] = cutsomAgg); | ||
} | ||
@@ -79,4 +81,4 @@ | ||
public isNotEmty(): boolean { | ||
return Object.keys({ ...this._facets.active, ...this._facets.inactive.aggs }).length > 0; | ||
return Object.keys({...this._facets, ...this._facets.inactive.aggs}).length > 1; | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
314407
2897