rez_core 4.0.65 → 4.0.70

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.65",
3
+ "version": "4.0.70",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -36,28 +36,28 @@ export class FilterService {
36
36
  ) {
37
37
  if (!column) return [];
38
38
 
39
- if (!/^[a-zA-Z0-9_]+$/.test(tableName) || !/^[a-zA-Z0-9_]+$/.test(column)) {
40
- throw new Error('Invalid table or column name');
41
- }
42
-
43
39
  let whereSQL = '';
44
40
  const values: any[] = [];
45
41
 
46
42
  if (whereClauses.length > 0) {
47
43
  const clauseParts = whereClauses.map((clause) => {
48
- let parsedQuery = clause.query.replace(/\be\./g, '');
44
+ let parsedQuery = clause.query.replace(/\be\./g, ''); // remove e.
45
+
49
46
  Object.entries(clause.params).forEach(([key, val]) => {
50
47
  if (Array.isArray(val)) {
48
+ // if it's an array → expand placeholders (?, ?, ?)
51
49
  const placeholders = val.map(() => '?').join(', ');
52
- parsedQuery = parsedQuery.replace(new RegExp(`:${key}\\b`, 'g'), placeholders);
53
- values.push(...val);
50
+ parsedQuery = parsedQuery.replace(new RegExp(`:${key}`, 'g'), `(${placeholders})`);
51
+ values.push(...val); // flatten values
54
52
  } else {
55
- parsedQuery = parsedQuery.replace(new RegExp(`:${key}\\b`, 'g'), '?');
53
+ parsedQuery = parsedQuery.replace(new RegExp(`:${key}`, 'g'), '?');
56
54
  values.push(val);
57
55
  }
58
56
  });
59
- return `(${parsedQuery})`;
57
+
58
+ return parsedQuery;
60
59
  });
60
+
61
61
  whereSQL = `WHERE ${clauseParts.join(' AND ')}`;
62
62
  }
63
63
 
@@ -68,9 +68,21 @@ export class FilterService {
68
68
  GROUP BY ${column}
69
69
  `;
70
70
 
71
- return await this.dataSource.query(rawSQL, values);
72
- }
71
+ const rows = await this.dataSource.query(rawSQL, values);
72
+
73
+ const total = rows.reduce(
74
+ (sum, r) => sum + parseInt(r.tab_value_count, 10),
75
+ 0,
76
+ );
73
77
 
78
+ return [
79
+ { tab_value: 'All', tab_value_count: total },
80
+ ...rows.map((r) => ({
81
+ tab_value: r.tab_value ?? 'UNKNOWN',
82
+ tab_value_count: parseInt(r.tab_value_count, 10),
83
+ })),
84
+ ];
85
+ }
74
86
 
75
87
 
76
88
  async applyFilterWrapper(dto: FilterRequestDto) {
@@ -850,22 +862,22 @@ if (
850
862
  if (Array.isArray(val) && val.length === 0) {
851
863
  return { query: '1=1', params: {} };
852
864
  }
853
-
865
+
854
866
  if ((op === 'equal' || op === 'not_equal') && !Array.isArray(val)) {
855
867
  throw new BadRequestException(
856
868
  `Value for multi-select must be an array for operator: ${op}`,
857
869
  );
858
870
  }
859
-
871
+
860
872
  switch (op) {
861
873
  case 'equal':
862
874
  return {
863
- query: `e.${attr} IN (:...${key})`, // <-- use :... for arrays
875
+ query: `e.${attr} IN (:${key})`,
864
876
  params: { [key]: val },
865
877
  };
866
878
  case 'not_equal':
867
879
  return {
868
- query: `e.${attr} NOT IN (:...${key})`,
880
+ query: `e.${attr} NOT IN (:${key})`,
869
881
  params: { [key]: val },
870
882
  };
871
883
  case 'contains':
@@ -888,7 +900,7 @@ if (
888
900
  );
889
901
  }
890
902
  }
891
-
903
+
892
904
  private buildYearCondition(attr: string, op: string, val: any, key: string) {
893
905
  switch (op) {
894
906
  case 'equal':
@@ -58,8 +58,11 @@ export class ActionService extends EntityServiceImpl {
58
58
  ): Promise<any> {
59
59
  const actionData = entityData as any;
60
60
 
61
- // Step 1: Create main action entity
62
- const action = await super.createEntity(entityData, loggedInUser);
61
+ // 🔧 Remove 'template' array before inserting main action
62
+ const { template, ...actionWithoutTemplates } = actionData;
63
+
64
+ // Step 1: Create main action entity
65
+ const action = await super.createEntity(actionWithoutTemplates, loggedInUser);
63
66
 
64
67
  // Step 2: Create stage mapping
65
68
  const stageActionMapping = {