rez_core 5.0.189 → 5.0.191

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": "5.0.189",
3
+ "version": "5.0.191",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -4,7 +4,8 @@ import { ReflectionHelper } from '../../../utils/service/reflection-helper.servi
4
4
 
5
5
  @Injectable()
6
6
  export class SchoolRepository {
7
- constructor(private readonly reflectionHelper: ReflectionHelper) {}
7
+ constructor(private readonly reflectionHelper: ReflectionHelper) {
8
+ }
8
9
 
9
10
  async findAllByOrgId(orgId: number): Promise<any[]> {
10
11
  const schoolRepo = this.reflectionHelper.getRepoService('SSOSchool');
@@ -25,12 +26,11 @@ export class SchoolRepository {
25
26
  }
26
27
 
27
28
  async getUserContextDropdown(userId: number, appCode: string, org_id) {
28
- const userRoleRepo =
29
- this.reflectionHelper.getRepoService('UserRoleMapping');
29
+ const userRoleRepo = this.reflectionHelper.getRepoService('UserRoleMapping');
30
30
 
31
31
  const hasOrgAccess = await userRoleRepo
32
32
  .createQueryBuilder('urm')
33
- .where('urm.user_id::text = :userId', { userId: String(userId) })
33
+ .where('urm.user_id = :userId', { userId })
34
34
  .andWhere('urm.appcode = :appCode', { appCode })
35
35
  .andWhere('urm.level_type = :levelType', { levelType: 'ORG' })
36
36
  .getRawMany();
@@ -40,8 +40,7 @@ export class SchoolRepository {
40
40
  currentORGLevel_id = org_id;
41
41
  }
42
42
 
43
- const listMasterItemsRepo =
44
- this.reflectionHelper.getRepoService('ListMasterItems');
43
+ const listMasterItemsRepo = this.reflectionHelper.getRepoService('ListMasterItems');
45
44
  const resolvedInactiveStatus = await listMasterItemsRepo.findOne({
46
45
  where: {
47
46
  code: STATUS_INACTIVE,
@@ -50,8 +49,7 @@ export class SchoolRepository {
50
49
  });
51
50
 
52
51
  if (hasOrgAccess.length > 0) {
53
- const organizationRepo =
54
- this.reflectionHelper.getRepoService('OrganizationData');
52
+ const organizationRepo = this.reflectionHelper.getRepoService('OrganizationData');
55
53
 
56
54
  const schools = await organizationRepo
57
55
  .createQueryBuilder('org')
@@ -74,7 +72,7 @@ export class SchoolRepository {
74
72
  .innerJoin(
75
73
  'sso_organization',
76
74
  'brn',
77
- "brn.type = 'BRN' AND brn.parent_id::varchar = org.id::varchar",
75
+ 'brn.type = \'BRN\' AND brn.parent_id::varchar = org.id::varchar',
78
76
  )
79
77
  // JOIN school table
80
78
  .innerJoin(
@@ -163,6 +161,7 @@ export class SchoolRepository {
163
161
  brands: Object.values(org.brands),
164
162
  }));
165
163
  } else {
164
+
166
165
  const orgResult = await organizationRepo.findOne({
167
166
  where: {
168
167
  id: currentORGLevel_id,
@@ -181,8 +180,8 @@ export class SchoolRepository {
181
180
  ];
182
181
  }
183
182
  } else {
184
- const userRoleMappingRepo =
185
- this.reflectionHelper.getRepoService('UserRoleMapping');
183
+
184
+ const userRoleMappingRepo = this.reflectionHelper.getRepoService('UserRoleMapping');
186
185
 
187
186
  const brnMappings = await userRoleMappingRepo
188
187
  .createQueryBuilder('urm')
@@ -196,17 +195,9 @@ export class SchoolRepository {
196
195
  'school.location AS school_location',
197
196
  'school.status AS school_status',
198
197
  ])
199
- .innerJoin(
200
- 'sso_organization',
201
- 'brand',
202
- 'brand.id::text = urm.level_id::text',
203
- )
204
- .innerJoin(
205
- 'sso_school',
206
- 'school',
207
- 'school.brand_id::text = brand.id::text',
208
- )
209
- .where('urm.user_id::text = :userId', { userId: String(userId) })
198
+ .innerJoin('sso_organization', 'brand', 'brand.id = urm.level_id')
199
+ .innerJoin('sso_school', 'school', 'school.brand_id = brand.id')
200
+ .where('urm.user_id = :userId', { userId })
210
201
  .andWhere('urm.appcode = :appCode', { appCode })
211
202
  .andWhere('urm.level_type = :levelType', { levelType: 'BRN' })
212
203
  .distinct(true)
@@ -224,17 +215,9 @@ export class SchoolRepository {
224
215
  'school.location AS school_location',
225
216
  'school.status AS school_status',
226
217
  ])
227
- .innerJoin(
228
- 'sso_school',
229
- 'school',
230
- 'school.id::text = urm.level_id::text',
231
- )
232
- .innerJoin(
233
- 'sso_organization',
234
- 'brand',
235
- 'brand.id::text = school.brand_id::text',
236
- )
237
- .where('urm.user_id::text = :userId', { userId: String(userId) })
218
+ .innerJoin('sso_school', 'school', 'school.id = urm.level_id')
219
+ .innerJoin('sso_organization', 'brand', 'brand.id = school.brand_id')
220
+ .where('urm.user_id = :userId', { userId })
238
221
  .andWhere('urm.appcode = :appCode', { appCode })
239
222
  .andWhere('urm.level_type = :levelType', { levelType: 'SCH' })
240
223
  .distinct(true)
@@ -26,7 +26,8 @@ export class FilterService {
26
26
  @Inject() protected readonly loggingService: LoggingService,
27
27
  private readonly configService: ConfigService,
28
28
  private readonly reflectionHelper: ReflectionHelper,
29
- ) {}
29
+ ) {
30
+ }
30
31
 
31
32
  schema = this.configService.get('DB_SCHEMA');
32
33
 
@@ -81,6 +82,7 @@ export class FilterService {
81
82
  GROUP BY ${column}
82
83
  `;
83
84
 
85
+
84
86
  const rows = await this.entityManager.query(rawSQL, values);
85
87
 
86
88
  const total = rows.reduce(
@@ -282,6 +284,7 @@ export class FilterService {
282
284
 
283
285
  // Handle TEMPLATE entity special condition
284
286
  if (entity_type === 'TEMP' || entity_type === 'TEM') {
287
+
285
288
  if (level_type === 'ORG') {
286
289
  baseWhere.push({
287
290
  query: ` ((e.level_type = 'ORG' AND e.level_id = '${loggedInUser.enterprise_id}'))`,
@@ -322,7 +325,8 @@ export class FilterService {
322
325
  !customLevelId
323
326
  ) {
324
327
  baseWhere.push({
325
- query: 'e.level_type = :level_type AND e.level_id = :level_id',
328
+ query:
329
+ 'e.level_type = :level_type AND e.level_id = :level_id',
326
330
  params: {
327
331
  level_type,
328
332
  level_id,
@@ -899,26 +903,28 @@ export class FilterService {
899
903
  // convert to number when needed
900
904
  const numVal = Number(val);
901
905
 
902
- // const subtractBusinessDays = (days: number): string => {
903
- // let d = new Date();
904
- // let count = 0;
906
+ // INSIDE buildDateCondition
907
+ const subtractBusinessDays = (days: number): string => {
908
+ let d = new Date();
909
+ let count = 0;
905
910
 
906
- // while (count < days) {
907
- // d.setDate(d.getDate() - 1);
911
+ while (count < days) {
912
+ d.setDate(d.getDate() - 1);
908
913
 
909
- // const day = d.getDay(); // 0 = Sunday, 6 = Saturday
914
+ const day = d.getDay(); // 0 = Sunday, 6 = Saturday
910
915
 
911
- // if (day !== 0 && day !== 6) {
912
- // count++;
913
- // }
914
- // }
916
+ if (day !== 0 && day !== 6) {
917
+ count++;
918
+ }
919
+ }
915
920
 
916
- // return d.toISOString().split('T')[0];
917
- // };
921
+ return d.toISOString().split('T')[0];
922
+ };
918
923
 
919
924
  switch (op) {
925
+ // ============================================
920
926
  // BASIC COMPARISONS
921
-
927
+ // ============================================
922
928
  case 'equal':
923
929
  case 'is':
924
930
  return {
@@ -952,7 +958,9 @@ export class FilterService {
952
958
  params: { [key]: val },
953
959
  };
954
960
 
961
+ // ============================================
955
962
  // EMPTY / NOT EMPTY
963
+ // ============================================
956
964
  case 'empty':
957
965
  return {
958
966
  query: `e.${attr} IS NULL`,
@@ -965,12 +973,10 @@ export class FilterService {
965
973
  params: {},
966
974
  };
967
975
 
976
+ // ============================================
968
977
  // DAY OFFSET LOGIC (ALWAYS ADJUST -1 DAY)
969
- // DAY OFFSET LOGIC – NEW RULE:
970
- // +N → future date (today + N)
971
- // -N → past date (today - |N|)
972
-
973
- case 'is_day_before': {
978
+ // ============================================
979
+ case 'is_day_before':
974
980
  if (isNaN(numVal)) {
975
981
  throw new BadRequestException(
976
982
  'Value must be a number for is_day_before',
@@ -979,25 +985,18 @@ export class FilterService {
979
985
 
980
986
  const dayBefore = (() => {
981
987
  const d = new Date();
988
+ d.setDate(d.getDate() - numVal);
982
989
 
983
- if (numVal >= 0) {
984
- // positive go forward
985
- d.setDate(d.getDate() + numVal);
986
- } else {
987
- // negative → go backward
988
- d.setDate(d.getDate() - Math.abs(numVal));
989
- }
990
-
991
- return d.toISOString().split('T')[0];
990
+ // Format as YYYY-MM-DD in IST
991
+ return d.toLocaleDateString('en-CA', { timeZone: 'Asia/Kolkata' });
992
992
  })();
993
993
 
994
994
  return {
995
- query: `${dateColumn} < :${key}`,
995
+ query: `${dateColumn} <= :${key}`,
996
996
  params: { [key]: dayBefore },
997
997
  };
998
- }
999
998
 
1000
- case 'is_day_after': {
999
+ case 'is_day_after':
1001
1000
  if (isNaN(numVal)) {
1002
1001
  throw new BadRequestException(
1003
1002
  'Value must be a number for is_day_after',
@@ -1006,15 +1005,7 @@ export class FilterService {
1006
1005
 
1007
1006
  const dayAfter = (() => {
1008
1007
  const d = new Date();
1009
-
1010
- if (numVal >= 0) {
1011
- // positive → go forward
1012
- d.setDate(d.getDate() + numVal);
1013
- } else {
1014
- // negative → go backward
1015
- d.setDate(d.getDate() - Math.abs(numVal));
1016
- }
1017
-
1008
+ d.setDate(d.getDate() - 1 + numVal); // -1 because DB stores previous day
1018
1009
  return d.toISOString().split('T')[0];
1019
1010
  })();
1020
1011
 
@@ -1022,9 +1013,10 @@ export class FilterService {
1022
1013
  query: `${dateColumn} > :${key}`,
1023
1014
  params: { [key]: dayAfter },
1024
1015
  };
1025
- }
1026
1016
 
1017
+ // ============================================
1027
1018
  // MONTH OFFSET LOGIC
1019
+ // ============================================
1028
1020
  case 'is_month_before':
1029
1021
  if (isNaN(numVal)) {
1030
1022
  throw new BadRequestException(
@@ -1065,7 +1057,7 @@ export class FilterService {
1065
1057
  params: { [key]: monthAfter },
1066
1058
  };
1067
1059
 
1068
- // BETWEEN
1060
+ // ===== BETWEEN =====
1069
1061
  case 'between': {
1070
1062
  if (typeof val === 'string') {
1071
1063
  val = val.split(',').map((v) => v.trim());
@@ -1090,7 +1082,7 @@ export class FilterService {
1090
1082
  };
1091
1083
  }
1092
1084
 
1093
- // TODAY
1085
+ // ===== TODAY =====
1094
1086
  case 'today': {
1095
1087
  const today = moment().format('YYYY-MM-DD');
1096
1088
  return {
@@ -1099,83 +1091,42 @@ export class FilterService {
1099
1091
  };
1100
1092
  }
1101
1093
 
1094
+ // ============================================
1102
1095
  // BUSINESS DAY OFFSET LOGIC (SKIPS WEEKENDS)
1103
1096
  // ALWAYS ADJUST -1 DAY FOR DB SHIFT
1097
+ // ============================================
1098
+
1104
1099
  case 'is_before_business_days': {
1105
1100
  if (isNaN(numVal)) {
1106
1101
  throw new BadRequestException('Value must be a number');
1107
1102
  }
1108
1103
 
1109
- // if (numVal === 0) {
1110
- // throw new BadRequestException(
1111
- // 'Zero business days offset is not valid',
1112
- // );
1113
- // }
1114
-
1115
- const abs = Math.abs(numVal);
1116
-
1117
- const calcDate = (() => {
1118
- let d = new Date();
1119
- let count = 0;
1120
-
1121
- if (numVal > 0) {
1122
- // POSITIVE → move backward
1123
- while (count < abs) {
1124
- d.setDate(d.getDate() - 1);
1125
- if (![0, 6].includes(d.getDay())) count++;
1126
- }
1127
- } else {
1128
- // NEGATIVE → move forward
1129
- while (count < abs) {
1130
- d.setDate(d.getDate() + 1);
1131
- if (![0, 6].includes(d.getDay())) count++;
1132
- }
1133
- }
1134
-
1135
- // DB SHIFT (as per your existing logic)
1136
- d.setDate(d.getDate() - 1);
1137
-
1138
- return d.toISOString().split('T')[0];
1139
- })();
1104
+ const targetDate = subtractBusinessDays(numVal);
1140
1105
 
1141
1106
  return {
1142
1107
  query: `${dateColumn} <= :${key} AND EXTRACT(DOW FROM ${dateColumn}) NOT IN (0, 6)`,
1143
- params: { [key]: calcDate },
1108
+ params: { [key]: targetDate },
1144
1109
  };
1145
1110
  }
1146
1111
 
1147
1112
  case 'is_after_business_days': {
1148
1113
  if (isNaN(numVal)) {
1149
- throw new BadRequestException('Value must be a number');
1114
+ throw new BadRequestException(
1115
+ 'Value must be a number for is_after_business_days',
1116
+ );
1150
1117
  }
1151
1118
 
1152
- // if (numVal === 0) {
1153
- // throw new BadRequestException(
1154
- // 'Zero business days offset is not valid',
1155
- // );
1156
- // }
1157
-
1158
- const abs = Math.abs(numVal);
1159
-
1160
- const calcDate = (() => {
1119
+ const businessAfter = (() => {
1161
1120
  let d = new Date();
1162
1121
  let count = 0;
1163
1122
 
1164
- if (numVal > 0) {
1165
- // POSITIVE → move forward
1166
- while (count < abs) {
1167
- d.setDate(d.getDate() + 1);
1168
- if (![0, 6].includes(d.getDay())) count++;
1169
- }
1170
- } else {
1171
- // NEGATIVE → move backward
1172
- while (count < abs) {
1173
- d.setDate(d.getDate() - 1);
1174
- if (![0, 6].includes(d.getDay())) count++;
1175
- }
1123
+ while (count < numVal) {
1124
+ d.setDate(d.getDate() + 1);
1125
+ const day = d.getDay(); // 0=Sun, 6=Sat
1126
+ if (day !== 0 && day !== 6) count++;
1176
1127
  }
1177
1128
 
1178
- // DB SHIFT -1 day (KEEPING EXACT)
1129
+ // DB shift -1 day
1179
1130
  d.setDate(d.getDate() - 1);
1180
1131
 
1181
1132
  return d.toISOString().split('T')[0];
@@ -1183,53 +1134,13 @@ export class FilterService {
1183
1134
 
1184
1135
  return {
1185
1136
  query: `${dateColumn} > :${key}`,
1186
- params: { [key]: calcDate },
1137
+ params: { [key]: businessAfter },
1187
1138
  };
1188
1139
  }
1189
1140
 
1190
- // case 'is_before_business_days': {
1191
- // if (isNaN(numVal)) {
1192
- // throw new BadRequestException('Value must be a number');
1193
- // }
1194
-
1195
- // const targetDate = subtractBusinessDays(numVal);
1196
-
1197
- // return {
1198
- // query: `${dateColumn} <= :${key} AND EXTRACT(DOW FROM ${dateColumn}) NOT IN (0, 6)`,
1199
- // params: { [key]: targetDate },
1200
- // };
1201
- // }
1202
-
1203
- // case 'is_after_business_days': {
1204
- // if (isNaN(numVal)) {
1205
- // throw new BadRequestException(
1206
- // 'Value must be a number for is_after_business_days',
1207
- // );
1208
- // }
1209
-
1210
- // const businessAfter = (() => {
1211
- // let d = new Date();
1212
- // let count = 0;
1213
-
1214
- // while (count < numVal) {
1215
- // d.setDate(d.getDate() + 1);
1216
- // const day = d.getDay(); // 0=Sun, 6=Sat
1217
- // if (day !== 0 && day !== 6) count++;
1218
- // }
1219
-
1220
- // // DB shift -1 day
1221
- // d.setDate(d.getDate() - 1);
1222
-
1223
- // return d.toISOString().split('T')[0];
1224
- // })();
1225
-
1226
- // return {
1227
- // query: `${dateColumn} > :${key}`,
1228
- // params: { [key]: businessAfter },
1229
- // };
1230
- // }
1231
-
1141
+ // ============================================
1232
1142
  // IN LAST DAY (range: today to N days before)
1143
+ // ============================================
1233
1144
  case 'in_last_day': {
1234
1145
  if (isNaN(numVal)) {
1235
1146
  throw new BadRequestException(
@@ -1257,7 +1168,9 @@ export class FilterService {
1257
1168
  };
1258
1169
  }
1259
1170
 
1171
+ // ============================================
1260
1172
  // IN NEXT DAY (range: today to N days after)
1173
+ // ============================================
1261
1174
  case 'in_next_day': {
1262
1175
  if (isNaN(numVal)) {
1263
1176
  throw new BadRequestException(
@@ -1095,6 +1095,7 @@ export class IntegrationService {
1095
1095
  templateId: externalTemplateId,
1096
1096
  variables,
1097
1097
  richText,
1098
+ subject,
1098
1099
  };
1099
1100
 
1100
1101
  // Handle user integration if user_id provided
@@ -1,12 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <module type="WEB_MODULE" version="4">
3
- <component name="NewModuleRootManager">
4
- <content url="file://$MODULE_DIR$">
5
- <excludeFolder url="file://$MODULE_DIR$/.tmp" />
6
- <excludeFolder url="file://$MODULE_DIR$/temp" />
7
- <excludeFolder url="file://$MODULE_DIR$/tmp" />
8
- </content>
9
- <orderEntry type="inheritedJdk" />
10
- <orderEntry type="sourceFolder" forTests="false" />
11
- </component>
12
- </module>
@@ -1,59 +0,0 @@
1
- <component name="ProjectCodeStyleConfiguration">
2
- <code_scheme name="Project" version="173">
3
- <HTMLCodeStyleSettings>
4
- <option name="HTML_SPACE_INSIDE_EMPTY_TAG" value="true" />
5
- </HTMLCodeStyleSettings>
6
- <JSCodeStyleSettings version="0">
7
- <option name="FORCE_SEMICOLON_STYLE" value="true" />
8
- <option name="SPACE_BEFORE_FUNCTION_LEFT_PARENTH" value="false" />
9
- <option name="USE_DOUBLE_QUOTES" value="false" />
10
- <option name="FORCE_QUOTE_STYlE" value="true" />
11
- <option name="ENFORCE_TRAILING_COMMA" value="WhenMultiline" />
12
- <option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
13
- <option name="SPACES_WITHIN_IMPORTS" value="true" />
14
- </JSCodeStyleSettings>
15
- <TypeScriptCodeStyleSettings version="0">
16
- <option name="FORCE_SEMICOLON_STYLE" value="true" />
17
- <option name="SPACE_BEFORE_FUNCTION_LEFT_PARENTH" value="false" />
18
- <option name="USE_DOUBLE_QUOTES" value="false" />
19
- <option name="FORCE_QUOTE_STYlE" value="true" />
20
- <option name="ENFORCE_TRAILING_COMMA" value="WhenMultiline" />
21
- <option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
22
- <option name="SPACES_WITHIN_IMPORTS" value="true" />
23
- </TypeScriptCodeStyleSettings>
24
- <VueCodeStyleSettings>
25
- <option name="INTERPOLATION_NEW_LINE_AFTER_START_DELIMITER" value="false" />
26
- <option name="INTERPOLATION_NEW_LINE_BEFORE_END_DELIMITER" value="false" />
27
- </VueCodeStyleSettings>
28
- <codeStyleSettings language="HTML">
29
- <option name="SOFT_MARGINS" value="80" />
30
- <indentOptions>
31
- <option name="INDENT_SIZE" value="2" />
32
- <option name="CONTINUATION_INDENT_SIZE" value="2" />
33
- <option name="TAB_SIZE" value="2" />
34
- </indentOptions>
35
- </codeStyleSettings>
36
- <codeStyleSettings language="JavaScript">
37
- <option name="SOFT_MARGINS" value="80" />
38
- <indentOptions>
39
- <option name="INDENT_SIZE" value="2" />
40
- <option name="CONTINUATION_INDENT_SIZE" value="2" />
41
- <option name="TAB_SIZE" value="2" />
42
- </indentOptions>
43
- </codeStyleSettings>
44
- <codeStyleSettings language="TypeScript">
45
- <option name="SOFT_MARGINS" value="80" />
46
- <indentOptions>
47
- <option name="INDENT_SIZE" value="2" />
48
- <option name="CONTINUATION_INDENT_SIZE" value="2" />
49
- <option name="TAB_SIZE" value="2" />
50
- </indentOptions>
51
- </codeStyleSettings>
52
- <codeStyleSettings language="Vue">
53
- <option name="SOFT_MARGINS" value="80" />
54
- <indentOptions>
55
- <option name="CONTINUATION_INDENT_SIZE" value="2" />
56
- </indentOptions>
57
- </codeStyleSettings>
58
- </code_scheme>
59
- </component>
@@ -1,5 +0,0 @@
1
- <component name="ProjectCodeStyleConfiguration">
2
- <state>
3
- <option name="USE_PER_PROJECT_SETTINGS" value="true" />
4
- </state>
5
- </component>
@@ -1,6 +0,0 @@
1
- <component name="InspectionProjectProfileManager">
2
- <profile version="1.0">
3
- <option name="myName" value="Project Default" />
4
- <inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
5
- </profile>
6
- </component>
package/.idea/modules.xml DELETED
@@ -1,8 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectModuleManager">
4
- <modules>
5
- <module fileurl="file://$PROJECT_DIR$/.idea/250218_nodejs_core.iml" filepath="$PROJECT_DIR$/.idea/250218_nodejs_core.iml" />
6
- </modules>
7
- </component>
8
- </project>
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="PrettierConfiguration">
4
- <option name="myConfigurationMode" value="AUTOMATIC" />
5
- </component>
6
- </project>
package/.idea/vcs.xml DELETED
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="VcsDirectoryMappings">
4
- <mapping directory="" vcs="Git" />
5
- </component>
6
- </project>