@punks/backend-entity-manager 0.0.484 → 0.0.486

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.
@@ -37,6 +37,10 @@ export type EnumFilter<T> = {
37
37
  notIn?: T[];
38
38
  isNull?: boolean;
39
39
  };
40
+ export type ArrayFilter<T> = {
41
+ eq?: T[];
42
+ isNull?: boolean;
43
+ };
40
44
  export type BooleanFilter = {
41
45
  eq?: boolean;
42
46
  ne?: boolean;
@@ -1,6 +1,7 @@
1
1
  import { FindOperator } from "typeorm";
2
- import { BooleanFilter, DateFilter, EnumFilter, IdFilter, NumericFilter, StringFilter, StringListFilter } from "./clause";
2
+ import { ArrayFilter, BooleanFilter, DateFilter, EnumFilter, IdFilter, NumericFilter, StringFilter, StringListFilter } from "./clause";
3
3
  export declare class QueryClauseBuilder {
4
+ arrayFilter<T>(filter: ArrayFilter<T>): FindOperator<T>;
4
5
  enumFilter<T>(filter: EnumFilter<T>): FindOperator<T>;
5
6
  idFilter(filter: IdFilter): FindOperator<string>;
6
7
  stringFilter(filter: StringFilter): FindOperator<string>;
package/dist/esm/index.js CHANGED
@@ -2,7 +2,7 @@ import { Log, csvParse, excelParse, ExcelKeyTransform, excelBuild, csvBuild, map
2
2
  import { QueryCommand, ScanCommand, GetItemCommand, PutItemCommand, DeleteItemCommand, DynamoDBClient } from '@aws-sdk/client-dynamodb';
3
3
  import { unmarshall, marshall } from '@aws-sdk/util-dynamodb';
4
4
  import { Module, applyDecorators, Injectable, SetMetadata, createParamDecorator, Global, Scope, Inject, Logger, StreamableFile, HttpException, HttpStatus } from '@nestjs/common';
5
- import { MoreThanOrEqual, Equal, Not, IsNull, And, MoreThan, LessThanOrEqual, LessThan, ILike, Like, In, Or, Repository } from 'typeorm';
5
+ import { MoreThanOrEqual, IsNull, And, Equal, Not, MoreThan, LessThanOrEqual, LessThan, ILike, Like, Between, In, Or, Repository } from 'typeorm';
6
6
  import { Reflector } from '@nestjs/core';
7
7
  import { AsyncLocalStorage } from 'async_hooks';
8
8
  import { hash } from 'bcrypt';
@@ -3596,6 +3596,17 @@ class QueryBuilderBase {
3596
3596
  }
3597
3597
 
3598
3598
  class QueryClauseBuilder {
3599
+ arrayFilter(filter) {
3600
+ if (filter.eq) {
3601
+ return `{${filter.eq
3602
+ .map((v) => `"${v}"`)
3603
+ .join(",")}}`;
3604
+ }
3605
+ if (filter?.isNull) {
3606
+ return IsNull();
3607
+ }
3608
+ return And();
3609
+ }
3599
3610
  enumFilter(filter) {
3600
3611
  const clauses = [];
3601
3612
  if (!isNullOrUndefined(filter?.in)) {
@@ -3729,6 +3740,13 @@ class QueryClauseBuilder {
3729
3740
  }
3730
3741
  dateFilter(filter) {
3731
3742
  const clauses = [];
3743
+ if (!isNullOrUndefined(filter?.eq)) {
3744
+ const startOfDay = new Date(filter.eq);
3745
+ startOfDay.setHours(0, 0, 0, 0);
3746
+ const endOfDay = new Date(filter.eq);
3747
+ endOfDay.setHours(23, 59, 59, 999);
3748
+ clauses.push(Between(startOfDay, endOfDay));
3749
+ }
3732
3750
  if (!isNullOrUndefined(filter?.gte)) {
3733
3751
  clauses.push(MoreThanOrEqual(filter.gte));
3734
3752
  }