rez_core 4.0.290 → 4.0.291

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rez_core",
3
- "version": "4.0.290",
3
+ "version": "4.0.291",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -851,6 +851,8 @@ export class FilterService {
851
851
  const dateColumn = `DATE(e.${attr})`;
852
852
  const monthColumn = `DATE_TRUNC('month', e.${attr})`;
853
853
 
854
+ const numVal = Number(val);
855
+
854
856
  switch (op) {
855
857
  // ===== BASIC COMPARISONS =====
856
858
  case 'equal':
@@ -886,19 +888,66 @@ export class FilterService {
886
888
  params: { [key]: val },
887
889
  };
888
890
 
889
- // ===== MONTH COMPARISONS =====
891
+ // ===== MONTH COMPARISONS (NUMERIC OR DATE) =====
890
892
  case 'is_month_before':
893
+ if (!isNaN(numVal)) {
894
+ const target = moment()
895
+ .subtract(numVal, 'months')
896
+ .startOf('month')
897
+ .format('YYYY-MM-DD');
898
+ return {
899
+ query: `${monthColumn} < DATE_TRUNC('month', :${key})`,
900
+ params: { [key]: target },
901
+ };
902
+ }
891
903
  return {
892
904
  query: `${monthColumn} < DATE_TRUNC('month', :${key})`,
893
905
  params: { [key]: val },
894
906
  };
895
907
 
896
908
  case 'is_month_after':
909
+ if (!isNaN(numVal)) {
910
+ const target = moment()
911
+ .add(numVal, 'months')
912
+ .startOf('month')
913
+ .format('YYYY-MM-DD');
914
+ return {
915
+ query: `${monthColumn} > DATE_TRUNC('month', :${key})`,
916
+ params: { [key]: target },
917
+ };
918
+ }
897
919
  return {
898
920
  query: `${monthColumn} > DATE_TRUNC('month', :${key})`,
899
921
  params: { [key]: val },
900
922
  };
901
923
 
924
+ // ===== DAY BEFORE / AFTER WITH MOMENT =====
925
+ case 'is_day_before':
926
+ if (isNaN(numVal))
927
+ throw new BadRequestException(
928
+ 'Value must be a number for is_day_before',
929
+ );
930
+
931
+ return {
932
+ query: `${dateColumn} < :${key}`,
933
+ params: {
934
+ [key]: moment().subtract(numVal, 'days').format('YYYY-MM-DD'),
935
+ },
936
+ };
937
+
938
+ case 'is_day_after':
939
+ if (isNaN(numVal))
940
+ throw new BadRequestException(
941
+ 'Value must be a number for is_day_after',
942
+ );
943
+
944
+ return {
945
+ query: `${dateColumn} > :${key}`,
946
+ params: {
947
+ [key]: moment().add(numVal, 'days').format('YYYY-MM-DD'),
948
+ },
949
+ };
950
+
902
951
  // ===== BETWEEN =====
903
952
  case 'between': {
904
953
  if (typeof val === 'string') {
@@ -924,17 +973,18 @@ export class FilterService {
924
973
  };
925
974
  }
926
975
 
927
- // ===== TODAY KEYWORD =====
976
+ // ===== TODAY =====
928
977
  case 'today': {
929
- const today = new Date().toISOString().split('T')[0];
978
+ const today = moment().format('YYYY-MM-DD');
930
979
  return {
931
980
  query: `${dateColumn} = :today`,
932
981
  params: { today },
933
982
  };
934
983
  }
935
984
 
936
- // ===== EMPTY / NOT EMPTY =====
985
+ // ===== EMPTY =====
937
986
  case 'empty':
987
+ case 'is_empty':
938
988
  return {
939
989
  query: `e.${attr} IS NULL`,
940
990
  params: {},
@@ -946,7 +996,6 @@ export class FilterService {
946
996
  params: {},
947
997
  };
948
998
 
949
- // ===== UNSUPPORTED =====
950
999
  default:
951
1000
  throw new BadRequestException(`Unsupported operator for date: ${op}`);
952
1001
  }