@punks/backend-entity-manager 0.0.236 → 0.0.238

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.
@@ -17,6 +17,7 @@ export interface ITraverseFilters {
17
17
  export interface ISearchOptions {
18
18
  includeFacets?: boolean;
19
19
  includeChildrenMap?: boolean;
20
+ facetsFilters?: ISearchFilters;
20
21
  }
21
22
  export interface ISearchRequestPaging<TCursor> {
22
23
  cursor?: TCursor;
@@ -6,6 +6,7 @@ export type NumericFilter = {
6
6
  lt?: number;
7
7
  lte?: number;
8
8
  isNull?: boolean;
9
+ notIn?: number[];
9
10
  };
10
11
  export type StringFilter = {
11
12
  gt?: string;
@@ -40,6 +41,8 @@ export type BooleanFilter = {
40
41
  eq?: boolean;
41
42
  ne?: boolean;
42
43
  isNull?: boolean;
44
+ in?: boolean[];
45
+ notIn?: boolean[];
43
46
  };
44
47
  export type DateFilter = {
45
48
  in?: Date[];
@@ -16,6 +16,7 @@ export declare class FooQueryPaging implements ISearchRequestPaging<FooCursor> {
16
16
  }
17
17
  export declare class FooSearchOptions implements ISearchOptions {
18
18
  includeFacets?: boolean;
19
+ facetsFilters?: FooSearchFilters;
19
20
  }
20
21
  export declare class FooSearchParameters implements IEntitySearchParameters<FooEntity, FooSorting, FooCursor> {
21
22
  filters?: FooSearchFilters;
package/dist/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Log, csvParse, excelParse, excelBuild, csvBuild, isNullOrUndefined, addTime, newUuid as newUuid$1, buildObject, sort, byField, toDict, ensureTailingSlash, ensureStartSlash, removeUndefinedProps } from '@punks/backend-core';
2
- import { MoreThanOrEqual, In, Equal, Not, IsNull, And, MoreThan, LessThanOrEqual, LessThan, ILike, Like } from 'typeorm';
2
+ import { MoreThanOrEqual, In, Equal, Not, IsNull, And, MoreThan, LessThanOrEqual, LessThan, ILike } from 'typeorm';
3
3
  import { applyDecorators, Injectable, SetMetadata, createParamDecorator, Global, Module, Scope, Logger, StreamableFile, HttpException, HttpStatus } from '@nestjs/common';
4
4
  import { Reflector } from '@nestjs/core';
5
5
  import { AsyncLocalStorage } from 'async_hooks';
@@ -2918,7 +2918,7 @@ class QueryClauseBuilder {
2918
2918
  clauses.push(ILike(filter.eq));
2919
2919
  }
2920
2920
  if (!isNullOrUndefined(filter?.like)) {
2921
- clauses.push(Like(filter.like.replaceAll("*", "%")));
2921
+ clauses.push(ILike(filter.like.replaceAll("*", "%")));
2922
2922
  }
2923
2923
  if (!isNullOrUndefined(filter?.ne)) {
2924
2924
  clauses.push(Not(Equal(filter.ne)));
@@ -2930,7 +2930,7 @@ class QueryClauseBuilder {
2930
2930
  clauses.push(Not(In(filter.notIn)));
2931
2931
  }
2932
2932
  if (!isNullOrUndefined(filter?.notLike)) {
2933
- clauses.push(Not(Like(filter.notLike.replaceAll("*", "%"))));
2933
+ clauses.push(Not(ILike(filter.notLike.replaceAll("*", "%"))));
2934
2934
  }
2935
2935
  if (filter?.isNull === true) {
2936
2936
  clauses.push(IsNull());
@@ -2954,6 +2954,15 @@ class QueryClauseBuilder {
2954
2954
  if (!isNullOrUndefined(filter?.lt)) {
2955
2955
  clauses.push(LessThan(filter.lt));
2956
2956
  }
2957
+ if (!isNullOrUndefined(filter?.in)) {
2958
+ clauses.push(In(filter.in ?? []));
2959
+ }
2960
+ if (!isNullOrUndefined(filter?.notIn)) {
2961
+ clauses.push(Not(In(filter.notIn)));
2962
+ }
2963
+ if (!isNullOrUndefined(filter?.eq)) {
2964
+ clauses.push(Equal(filter.eq));
2965
+ }
2957
2966
  if (filter?.isNull === true) {
2958
2967
  clauses.push(IsNull());
2959
2968
  }
@@ -2998,6 +3007,12 @@ class QueryClauseBuilder {
2998
3007
  if (filter?.isNull === false) {
2999
3008
  clauses.push(Not(IsNull()));
3000
3009
  }
3010
+ if (!isNullOrUndefined(filter?.in)) {
3011
+ clauses.push(In(filter.in ?? []));
3012
+ }
3013
+ if (!isNullOrUndefined(filter?.notIn)) {
3014
+ clauses.push(Not(In(filter.notIn)));
3015
+ }
3001
3016
  return And(...clauses);
3002
3017
  }
3003
3018
  }
@@ -3083,7 +3098,11 @@ class TypeOrmQueryBuilder extends QueryBuilderBase {
3083
3098
  const queryResults = await this.countQueryResults(request, context);
3084
3099
  const results = await this.findPagedQueryResults(request, context);
3085
3100
  const facets = request.options?.includeFacets
3086
- ? await this.calculateFacets(request, context)
3101
+ ? // todo: refactor avoiding to manipulate the request object
3102
+ await this.calculateFacets({
3103
+ ...request,
3104
+ filters: request.options.facetsFilters,
3105
+ }, context)
3087
3106
  : undefined;
3088
3107
  const childrenMap = request.options?.includeChildrenMap
3089
3108
  ? await this.calculateChildrenMap(results)