rez_core 5.0.17 → 5.0.19

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.17",
3
+ "version": "5.0.19",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -15,6 +15,7 @@ import axios from 'axios';
15
15
  import { ConfigService } from '@nestjs/config';
16
16
  import { ListMasterData } from 'src/module/listmaster/entity/list-master.entity';
17
17
  import { StageGroup } from '../entity/stage-group.entity';
18
+ import { EntityMasterService } from 'src/module/meta/service/entity-master.service';
18
19
 
19
20
  @Injectable()
20
21
  export class StageGroupService extends EntityServiceImpl {
@@ -110,7 +111,11 @@ export class StageGroupService extends EntityServiceImpl {
110
111
  // 3) Lead status (parameterized)
111
112
  let leadStatus: string | null = null;
112
113
 
113
- const leadData = await this.getEntityData('LEAD', lead_id, loggedInUser);
114
+ const leadData = await super.getEntityData(
115
+ 'LEAD',
116
+ lead_id,
117
+ loggedInUser,
118
+ );
114
119
  console.log('leadData', leadData);
115
120
  const leadRecord = Array.isArray(leadData) ? leadData[0] : null;
116
121
 
@@ -130,7 +135,7 @@ export class StageGroupService extends EntityServiceImpl {
130
135
  // 4. Fetch stage groups & hierarchy
131
136
  const stageGroupAndStageHierarchy =
132
137
  (await this.stageGroupRepository.getAllStageGroupAndStageHierarchy(
133
- stageGroupData[0].workflow_id,
138
+ stageGroupData.workflow_id,
134
139
  loggedInUser,
135
140
  lead_id,
136
141
  )) as Array<{
@@ -283,26 +283,27 @@ export class TaskService extends EntityServiceImpl {
283
283
  const params: any[] = [];
284
284
  let idx = 1;
285
285
 
286
- // Required conditions
286
+ // Required filters
287
287
  whereClauses.push(`t.mapped_entity_type = $${idx++}`);
288
288
  params.push(mapped_entity_type);
289
289
 
290
- whereClauses.push(`t.mapped_entity_id = $${idx++}`);
290
+ whereClauses.push(`t.mapped_entity_id::text = $${idx++}`);
291
291
  params.push(String(mapped_entity_id));
292
292
 
293
- // Optional filters
293
+ // Optional: status (stored as varchar)
294
294
  if (status) {
295
- whereClauses.push(`t.status = $${idx++}`);
296
- params.push(Number(status));
295
+ whereClauses.push(`t.status::text = $${idx++}`);
296
+ params.push(String(status));
297
297
  }
298
298
 
299
+ // Optional: mandatory (stored as varchar '0' / '1')
299
300
  if (mandatory !== undefined) {
300
- whereClauses.push(`t.is_mandatory = $${idx++}`);
301
- params.push(mandatory ? true : false);
301
+ whereClauses.push(`t.is_mandatory::text = $${idx++}`);
302
+ params.push(mandatory ? "1" : "0");
302
303
  }
303
304
 
305
+ // Optional: overdue
304
306
  if (overdue) {
305
- // Use PostgreSQL CURRENT_DATE + CURRENT_TIME
306
307
  whereClauses.push(`
307
308
  (
308
309
  t.due_date < CURRENT_DATE
@@ -310,11 +311,12 @@ export class TaskService extends EntityServiceImpl {
310
311
  )
311
312
  `);
312
313
 
313
- // Only if not done
314
- whereClauses.push(`t.is_done = $${idx++}`);
315
- params.push(false);
314
+ // Only include tasks NOT done
315
+ whereClauses.push(`t.is_done::text = $${idx++}`);
316
+ params.push("0"); // varchar field
316
317
  }
317
318
 
319
+ // Final SQL
318
320
  const sql = `
319
321
  SELECT
320
322
  t.*,
@@ -322,29 +324,30 @@ export class TaskService extends EntityServiceImpl {
322
324
  s.name AS stage_name,
323
325
  a.name AS action_name
324
326
  FROM frm_wf_task_data t
325
- LEFT JOIN frm_wf_stage s ON t.stage_id = s.id
326
- LEFT JOIN frm_wf_stage_group sg ON s.stage_group_id = sg.id
327
- LEFT JOIN frm_wf_action a ON t.action_id = a.id
327
+ LEFT JOIN frm_wf_stage s ON t.stage_id::text = s.id::text
328
+ LEFT JOIN frm_wf_stage_group sg ON s.stage_group_id = sg.id
329
+ LEFT JOIN frm_wf_action a ON t.action_id::text = a.id::text
328
330
  WHERE ${whereClauses.join(" AND ")}
329
331
  ORDER BY t.created_date DESC
330
332
  `;
331
333
 
332
334
  const taskData = await this.dataSource.query(sql, params);
333
335
 
334
- // ------------------------------------------------------
335
- // Resolve user profile
336
- // ------------------------------------------------------
336
+ // -------------------------------
337
+ // PROFILE IMAGE MAPPING
338
+ // -------------------------------
337
339
  if (taskData?.length) {
338
340
  for (const task of taskData) {
339
341
  try {
340
- const baseUrl = this.configService.get<string>("REDIRECT_BE_URL");
342
+ const baseUrl =
343
+ this.configService.get<string>("REDIRECT_BE_URL");
341
344
 
342
345
  const queryParams = new URLSearchParams({
343
346
  loggedInUser: JSON.stringify(loggedInUser),
344
347
  }).toString();
345
348
 
346
349
  const response = await axios.get(
347
- `${baseUrl}/users/profile-image-url/${task?.task_owner}?entity_type=USR&${queryParams}`,
350
+ `${baseUrl}/users/profile-image-url/${task.task_owner}?entity_type=USR&${queryParams}`,
348
351
  { headers: { "Content-Type": "application/json" } },
349
352
  );
350
353
 
@@ -359,15 +362,15 @@ export class TaskService extends EntityServiceImpl {
359
362
 
360
363
  if (!taskData.length) return [];
361
364
 
362
- // ------------------------------------------------------
363
- // Load All TKST Statuses
364
- // ------------------------------------------------------
365
+ // -------------------------------
366
+ // FETCH TKST STATUS LABELS
367
+ // -------------------------------
365
368
  const statusSql = `
366
- SELECT id, name
367
- FROM frm_list_master_items
368
- WHERE organization_id = $1
369
- AND listtype = 'TKST'
370
- `;
369
+ SELECT id, name
370
+ FROM frm_list_master_items
371
+ WHERE organization_id = $1
372
+ AND listtype = 'TKST'
373
+ `;
371
374
 
372
375
  const allStatuses = await this.dataSource.query(statusSql, [
373
376
  loggedInUser.organization_id,
@@ -377,17 +380,17 @@ export class TaskService extends EntityServiceImpl {
377
380
  allStatuses.map((row) => [String(row.id), row.name]),
378
381
  );
379
382
 
380
- // ------------------------------------------------------
381
- // Normalize & decorate tasks
382
- // ------------------------------------------------------
383
+ // -------------------------------
384
+ // FINAL MAPPING
385
+ // -------------------------------
383
386
  return taskData.map((task) => ({
384
387
  ...task,
385
388
  task_status: statusMap.get(String(task.status)) || null,
386
389
  action_name:
387
- task.action_id === 0 || task.action_id === "0"
390
+ task.action_id === "0" || task.action_id === 0
388
391
  ? "Generic"
389
392
  : task.action_name,
390
- is_mandatory: task.is_mandatory ? "1" : "0",
393
+ is_mandatory: task.is_mandatory === "1" ? "1" : "0",
391
394
  }));
392
395
  }
393
396