Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

elastic-dsl-typescript

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

elastic-dsl-typescript - npm Package Compare versions

Comparing version 1.2.4-0 to 1.2.4

13

dist/Builders/EshopFacets/index.d.ts

@@ -1,13 +0,14 @@

import { AggregationSchema } from 'Builders/Aggregation/types';
import { Bool } from 'Builders/Bool';
import { AggregationSchema } from '../Aggregation/types';
import { Bool } from '../Bool';
import { AbstractBulder } from '../../Abstract/AbstractBuilder';
interface IFacet {
active: any;
[key: string]: any;
inactive: InactiveFacet;
}
declare type FacetType = keyof IFacet;
declare type InactiveFacet = Record<'filter' | 'aggs', object>;
export declare class EshopFacets {
declare type InactiveFacet = Record<'filter' | 'aggs', any>;
export declare class EshopFacets extends AbstractBulder {
private _facets;
setupInactiveFacets(filter: Bool): void;
addInactiveFacet<Type extends keyof AggregationSchema>(facetType: FacetType, aggType: Type, name: string, d: AggregationSchema[Type]): this;
add<Type extends keyof AggregationSchema>(facetType: FacetType, aggType: Type, name: string, d: AggregationSchema[Type]): this;
addCustom(facetType: FacetType, name: string, cutsomAgg: object): void;

@@ -14,0 +15,0 @@ build(): object;

@@ -14,6 +14,7 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
class EshopFacets {
const AbstractBuilder_1 = require("../../Abstract/AbstractBuilder");
class EshopFacets extends AbstractBuilder_1.AbstractBulder {
constructor() {
super(...arguments);
this._facets = {
active: {},
inactive: {

@@ -26,7 +27,8 @@ aggs: {},

setupInactiveFacets(filter) {
this._facets.inactive.filter = filter;
this._facets.inactive.filter = filter.build();
}
addInactiveFacet(facetType, aggType, name, d) {
add(facetType, aggType, name, d) {
const _a = d.params, { filter, subAgg } = _a, all = __rest(_a, ["filter", "subAgg"]);
let sub = {};
let data = {};
if (subAgg) {

@@ -38,3 +40,3 @@ sub = {

if (filter) {
this._facets[facetType][name] = {
data = {
filter,

@@ -45,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);
}

@@ -61,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.2.4-0",
"version": "1.2.4",
"description": "Node.js ElasticSearch search query builder",

@@ -8,7 +8,5 @@ "main": "dist/index.js",

"scripts": {
"prepublish": " npm run build && npm version prerelease -m \"Upgrade to %s \"",
"prepublish": " npm run build && npm version patch -m \"Upgrade to %s \"",
"test": "./node_modules/.bin/jest -i --coverage --forceExit",
"copyData": "cp package.json ./dist/package.json && cp ./README.md ./dist/README.md && cp ./LICENSE ./dist/LICENSE && cp -r ./img ./dist/img && cp -r ./src ./dist/ ",
"build": "rm -rf ./dist && ./node_modules/.bin/tsc",
"pub": "npm run build && npm run copyData && cd ./dist && npm publish"
"build": "rm -rf ./dist && ./node_modules/.bin/tsc"
},

@@ -15,0 +13,0 @@ "repository": {

@@ -1,7 +0,9 @@

import { AggregationSchema } from 'Builders/Aggregation/types';
import { Bool } from 'Builders/Bool';
import {AggregationSchema} from '../Aggregation/types';
import {Bool} from '../Bool';
import {AbstractBulder} from '../../Abstract/AbstractBuilder';
interface IFacet {
active: any;
inactive: InactiveFacet;
[key: string]: any;
inactive: InactiveFacet;
}

@@ -11,66 +13,67 @@

type InactiveFacet = Record<'filter' | 'aggs', object>;
type InactiveFacet = Record<'filter' | 'aggs', any>;
export class EshopFacets {
private _facets: IFacet = {
active: {},
inactive: {
aggs: {},
filter: {},
export class EshopFacets extends AbstractBulder {
private _facets: IFacet = {
inactive: {
aggs: {},
filter: {},
},
};
public setupInactiveFacets(filter: Bool): void {
this._facets.inactive!.filter = filter.build();
}
public add<Type extends keyof AggregationSchema>(
facetType: FacetType,
aggType: Type,
name: string,
d: AggregationSchema[Type],
) {
const {filter, subAgg, ...all} = d.params as { filter?: object; subAgg?: object };
let sub = {};
let data = {};
if (subAgg) {
sub = {
aggs: {
...subAgg,
},
};
public setupInactiveFacets(filter: Bool): void {
this._facets.inactive!.filter = filter;
};
}
public addInactiveFacet<Type extends keyof AggregationSchema>(
facetType: FacetType,
aggType: Type,
name: string,
d: AggregationSchema[Type],
) {
const {filter, subAgg, ...all} = d.params as { filter?: any; subAgg?: any };
let sub = {};
if (subAgg) {
sub = {
aggs: {
...subAgg,
},
};
}
if (filter) {
this._facets[facetType][name] = {
filter,
aggs: {
[`${name}_filtered`]: {
[aggType]: {...all, ...((d.opts as object) || {})},
...sub,
},
},
};
return this;
}
this._facets[facetType][name] = {
if (filter) {
data = {
filter,
aggs: {
[`${name}_filtered`]: {
[aggType]: {...all, ...((d.opts as object) || {})},
...sub,
};
return this;
},
},
};
} else {
data = {
[aggType]: {...all, ...((d.opts as object) || {})},
...sub,
};
}
public addCustom(facetType: FacetType, name: string, cutsomAgg: object) {
this._facets[facetType][name] = cutsomAgg;
}
facetType === 'inactive' ? (this._facets['inactive']['aggs'][name] = data) : (this._facets[name] = data);
return this;
}
public build(): object {
if (Object.keys(this._facets.inactive.aggs).length > 0 && Object.keys(this._facets.inactive.filter).length < 1) {
throw new Error('Please setup inactive facets');
}
return this._facets;
public addCustom(facetType: FacetType, name: string, cutsomAgg: object) {
facetType === 'inactive' ? (this._facets['inactive']['aggs'][name] = cutsomAgg) : (this._facets[name] = cutsomAgg);
}
public build(): object {
if (Object.keys(this._facets.inactive.aggs).length > 0 && Object.keys(this._facets.inactive.filter).length < 1) {
throw new Error('Please setup inactive facets');
}
return this._facets;
}
public isNotEmty(): boolean {
return Object.keys({...this._facets.active, ...this._facets.inactive.aggs}).length > 0;
}
public isNotEmty(): boolean {
return Object.keys({...this._facets, ...this._facets.inactive.aggs}).length > 1;
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc