rez_core 5.0.55 → 5.0.57

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.55",
3
+ "version": "5.0.57",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -18,7 +18,8 @@ export class ResolverService {
18
18
  private readonly moduleRef: ModuleRef,
19
19
  private readonly attributeMasterRepo: AttributeMasterRepository,
20
20
  private readonly reflectionHelper: ReflectionHelper,
21
- ) {}
21
+ ) {
22
+ }
22
23
 
23
24
  private async getMediaDataService() {
24
25
  if (!this.mediaDataService) {
@@ -139,7 +140,11 @@ export class ResolverService {
139
140
 
140
141
  // fetch attribute meta only for the given attributeKey
141
142
  const [attr] = await this.dataSource.query(
142
- `SELECT * FROM frm_entity_attribute WHERE mapped_entity_type = $1 AND organization_id = $2 AND attribute_key = $3`,
143
+ `SELECT *
144
+ FROM frm_entity_attribute
145
+ WHERE mapped_entity_type = $1
146
+ AND organization_id = $2
147
+ AND attribute_key = $3`,
143
148
  [entityType, loggedInUser.organization_id, attrKey],
144
149
  );
145
150
 
@@ -148,7 +153,10 @@ export class ResolverService {
148
153
  // -------- ENTITY data_source_type --------
149
154
  if (attr.data_source_type === 'entity') {
150
155
  const [entityDef] = await this.dataSource.query(
151
- `SELECT * FROM frm_entity_master WHERE mapped_entity_type = $1 AND organization_id = $2`,
156
+ `SELECT *
157
+ FROM frm_entity_master
158
+ WHERE mapped_entity_type = $1
159
+ AND organization_id = $2`,
152
160
  [attr.datasource_list, loggedInUser.organization_id],
153
161
  );
154
162
 
@@ -161,8 +169,13 @@ export class ResolverService {
161
169
  for (const code of rawValue) {
162
170
  const query =
163
171
  tableName === 'sso_organization'
164
- ? `SELECT * FROM ${tableName} WHERE code = $1`
165
- : `SELECT * FROM ${tableName} WHERE id = $1 AND organization_id = $2`;
172
+ ? `SELECT *
173
+ FROM ${tableName}
174
+ WHERE code = $1`
175
+ : `SELECT *
176
+ FROM ${tableName}
177
+ WHERE id = $1
178
+ AND organization_id = $2`;
166
179
 
167
180
  const params =
168
181
  tableName === 'sso_organization'
@@ -176,8 +189,13 @@ export class ResolverService {
176
189
  } else {
177
190
  const query =
178
191
  tableName === 'sso_organization'
179
- ? `SELECT * FROM ${tableName} WHERE id = $1`
180
- : `SELECT * FROM ${tableName} WHERE id = $1 AND organization_id = $2`;
192
+ ? `SELECT *
193
+ FROM ${tableName}
194
+ WHERE id = $1`
195
+ : `SELECT *
196
+ FROM ${tableName}
197
+ WHERE id = $1
198
+ AND organization_id = $2`;
181
199
 
182
200
  const params =
183
201
  tableName === 'sso_organization'
@@ -197,7 +215,7 @@ export class ResolverService {
197
215
  const repo =
198
216
  await this.reflectionHelper.getRepoService('ListMasterItems');
199
217
 
200
- let item = await repo.findOne({
218
+ let item = repo.findOne({
201
219
  where: {
202
220
  id: code,
203
221
  organization_id: loggedInUser.organization_id,
@@ -207,16 +225,11 @@ export class ResolverService {
207
225
  }
208
226
  return resolvedValues;
209
227
  } else {
210
- // const [item] = await this.dataSource.query(
211
- // `SELECT * FROM frm_list_master_items WHERE id = $1 AND organization_id = $2`,
212
- // [rawValue, loggedInUser.organization_id],
213
- // );
214
-
215
228
  const repo =
216
229
  await this.reflectionHelper.getRepoService('ListMasterItems');
217
- let item = await repo.findOne({
230
+ let item = repo.findOne({
218
231
  where: {
219
- id: rawValue,
232
+ id: Number(rawValue),
220
233
  organization_id: loggedInUser.organization_id,
221
234
  },
222
235
  });
@@ -243,8 +256,11 @@ export class ResolverService {
243
256
 
244
257
  // fetch attribute meta
245
258
  const [attr] = await this.dataSource.query(
246
- `SELECT * FROM frm_entity_attribute
247
- WHERE mapped_entity_type = $1 AND organization_id = $2 AND attribute_key = $3`,
259
+ `SELECT *
260
+ FROM frm_entity_attribute
261
+ WHERE mapped_entity_type = $1
262
+ AND organization_id = $2
263
+ AND attribute_key = $3`,
248
264
  [entityType, loggedInUser.organization_id, attrKey],
249
265
  );
250
266
 
@@ -253,8 +269,10 @@ export class ResolverService {
253
269
  // -------- ENTITY data_source_type --------
254
270
  if (attr.data_source_type === 'entity') {
255
271
  const [entityDef] = await this.dataSource.query(
256
- `SELECT * FROM frm_entity_master
257
- WHERE mapped_entity_type = $1 AND organization_id = $2`,
272
+ `SELECT *
273
+ FROM frm_entity_master
274
+ WHERE mapped_entity_type = $1
275
+ AND organization_id = $2`,
258
276
  [attr.datasource_list, loggedInUser.organization_id],
259
277
  );
260
278
 
@@ -264,8 +282,13 @@ export class ResolverService {
264
282
 
265
283
  const query =
266
284
  tableName === 'sso_organization'
267
- ? `SELECT id FROM ${tableName} WHERE ${attr.data_source_attribute} = $1`
268
- : `SELECT id FROM ${tableName} WHERE ${attr.data_source_attribute} = $1 AND organization_id = $2`;
285
+ ? `SELECT id
286
+ FROM ${tableName}
287
+ WHERE ${attr.data_source_attribute} = $1`
288
+ : `SELECT id
289
+ FROM ${tableName}
290
+ WHERE ${attr.data_source_attribute} = $1
291
+ AND organization_id = $2`;
269
292
 
270
293
  const params =
271
294
  tableName === 'sso_organization'
@@ -279,8 +302,11 @@ export class ResolverService {
279
302
  // -------- MASTER data_source_type --------
280
303
  else if (attr.data_source_type === 'master') {
281
304
  const [item] = await this.dataSource.query(
282
- `SELECT id FROM frm_list_master_items
283
- WHERE ${attr.data_source_attribute} = $1 AND organization_id = $2 AND listtype = $3`,
305
+ `SELECT id
306
+ FROM frm_list_master_items
307
+ WHERE ${attr.data_source_attribute} = $1
308
+ AND organization_id = $2
309
+ AND listtype = $3`,
284
310
  [displayValue, loggedInUser.organization_id, attr.datasource_list],
285
311
  );
286
312
  return item?.id ?? displayValue;
@@ -12,6 +12,7 @@ import * as moment from 'moment';
12
12
  import { ConfigService } from '@nestjs/config';
13
13
  import axios from 'axios';
14
14
  import { ChecksumAlgorithm } from '@aws-sdk/client-s3';
15
+ import { ReflectionHelper } from '../../../utils/service/reflection-helper.service';
15
16
 
16
17
  @Injectable()
17
18
  @ActionHandler('add_task')
@@ -23,7 +24,7 @@ export class TaskService extends EntityServiceImpl {
23
24
  @Inject('ActivityLogService')
24
25
  private readonly activityLogService: ActivityLogService,
25
26
  private readonly mediaDataService: MediaDataService,
26
- private readonly configService: ConfigService,
27
+ private readonly configService: ConfigService
27
28
  ) {
28
29
  super();
29
30
  }
@@ -278,70 +279,57 @@ export class TaskService extends EntityServiceImpl {
278
279
  ): Promise<any[]> {
279
280
  const { mapped_entity_type, mapped_entity_id, status, mandatory, overdue } =
280
281
  data;
282
+ const taskRepo = this.reflectionHelper.getRepoService('TaskDataEntity');
283
+ const qb = taskRepo
284
+ .createQueryBuilder("t")
285
+ .select("t.*")
286
+ .leftJoinAndSelect("frm_wf_stage", "s", "t.stage_id::text = s.id::text")
287
+ .leftJoinAndSelect("frm_wf_stage_group", "sg", "s.stage_group_id = sg.id")
288
+ .leftJoinAndSelect("frm_wf_action", "a", "t.action_id::text = a.id::text")
289
+ .where("t.mapped_entity_type = :mapped_entity_type", {
290
+ mapped_entity_type,
291
+ })
292
+ .andWhere("t.mapped_entity_id::text = :mapped_entity_id", {
293
+ mapped_entity_id: String(mapped_entity_id),
294
+ });
295
+
296
+ // ---------------------------
297
+ // OPTIONAL FILTERS
298
+ // ---------------------------
281
299
 
282
- const whereClauses: string[] = [];
283
- const params: any[] = [];
284
- let idx = 1;
285
-
286
- // Required filters
287
- whereClauses.push(`t.mapped_entity_type = $${idx++}`);
288
- params.push(mapped_entity_type);
289
-
290
- whereClauses.push(`t.mapped_entity_id::text = $${idx++}`);
291
- params.push(String(mapped_entity_id));
292
-
293
- // Optional: status (stored as varchar)
294
300
  if (status) {
295
- whereClauses.push(`t.status::text = $${idx++}`);
296
- params.push(String(status));
301
+ qb.andWhere("t.status::text = :status", { status: String(status) });
297
302
  }
298
303
 
299
- // Optional: mandatory (stored as varchar '0' / '1')
300
304
  if (mandatory !== undefined) {
301
- whereClauses.push(`t.is_mandatory::text = $${idx++}`);
302
- params.push(mandatory ? "1" : "0");
305
+ qb.andWhere("t.is_mandatory = :mandatory", {
306
+ mandatory: mandatory ? "1" : "0",
307
+ });
303
308
  }
304
309
 
305
- // Optional: overdue
306
310
  if (overdue) {
307
- whereClauses.push(`
308
- (
309
- t.due_date < CURRENT_DATE
310
- OR (t.due_date = CURRENT_DATE AND t.due_time < CURRENT_TIME)
311
- )
312
- `);
313
-
314
- // Only include tasks NOT done
315
- whereClauses.push(`t.is_done::text = $${idx++}`);
316
- params.push("0"); // varchar field
311
+ qb.andWhere(
312
+ `
313
+ (
314
+ t.due_date < CURRENT_DATE
315
+ OR (t.due_date = CURRENT_DATE AND t.due_time < CURRENT_TIME)
316
+ )
317
+ `,
318
+ ).andWhere("t.is_done::text = :is_done", { is_done: "0" });
317
319
  }
318
320
 
319
- // Final SQL
320
- const sql = `
321
- SELECT
322
- t.*,
323
- sg.name AS stage_group_name,
324
- s.name AS stage_name,
325
- a.name AS action_name
326
- FROM frm_wf_task_data t
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
330
- WHERE ${whereClauses.join(" AND ")}
331
- ORDER BY t.created_date DESC
332
- `;
333
-
334
- const taskData = await this.dataSource.query(sql, params);
335
-
336
- // -------------------------------
337
- // PROFILE IMAGE MAPPING
338
- // -------------------------------
321
+ qb.orderBy("t.created_date", "DESC");
322
+
323
+ const taskData = await qb.getRawMany();
324
+
325
+ // ------------------------------------------------
326
+ // PROFILE IMAGE LOGIC (same as your code)
327
+ // ------------------------------------------------
328
+
339
329
  if (taskData?.length) {
340
330
  for (const task of taskData) {
341
331
  try {
342
- const baseUrl =
343
- this.configService.get<string>("REDIRECT_BE_URL");
344
-
332
+ const baseUrl = this.configService.get<string>("REDIRECT_BE_URL");
345
333
  const queryParams = new URLSearchParams({
346
334
  loggedInUser: JSON.stringify(loggedInUser),
347
335
  }).toString();
@@ -362,27 +350,21 @@ export class TaskService extends EntityServiceImpl {
362
350
 
363
351
  if (!taskData.length) return [];
364
352
 
365
- // -------------------------------
366
- // FETCH TKST STATUS LABELS
367
- // -------------------------------
368
- const statusSql = `
369
- SELECT id, name
370
- FROM frm_list_master_items
371
- WHERE organization_id = $1
372
- AND listtype = 'TKST'
373
- `;
374
-
375
- const allStatuses = await this.dataSource.query(statusSql, [
376
- loggedInUser.organization_id,
377
- ]);
353
+ // ------------------------------------------------
354
+ // STATUS LOOKUP
355
+ // ------------------------------------------------
356
+ const listMasterRepo = this.reflectionHelper.getRepoService('ListMasterItem');
378
357
 
379
- const statusMap = new Map(
380
- allStatuses.map((row) => [String(row.id), row.name]),
381
- );
358
+ const statuses = await listMasterRepo.find({
359
+ where: {
360
+ organization_id: loggedInUser.organization_id,
361
+ listtype: "TKST",
362
+ },
363
+ select: ["id", "name"],
364
+ });
365
+
366
+ const statusMap = new Map(statuses.map((row) => [String(row.id), row.name]));
382
367
 
383
- // -------------------------------
384
- // FINAL MAPPING
385
- // -------------------------------
386
368
  return taskData.map((task) => ({
387
369
  ...task,
388
370
  task_status: statusMap.get(String(task.status)) || null,
@@ -105,13 +105,17 @@ export class WorkflowService extends EntityServiceImpl {
105
105
  )
106
106
  .execute();
107
107
 
108
- // Update frm_wf_level_mapping to point to the new workflow
109
- await this.dataSource.query(
110
- `UPDATE frm_wf_level_mapping
111
- SET workflow_id = $1
112
- WHERE mapped_level_id = $2 AND mapped_level_type = $3`,
113
- [workflowId, level_id, level_type],
114
- );
108
+ await this.reflectionHelper
109
+ .getRepoService('WorkflowLevelMappingEntity')
110
+ .update(
111
+ {
112
+ mapped_level_id: level_id,
113
+ mapped_level_type: level_type,
114
+ },
115
+ {
116
+ workflow_id: workflowId,
117
+ },
118
+ );
115
119
  }
116
120
 
117
121
  // Final update
@@ -5,7 +5,7 @@ DB_PORT: '5432'
5
5
  DB_USER: 'root'
6
6
  DB_PASS: 'Rezolut123'
7
7
  DB_NAME: 'universal'
8
- DB_SCHEMA: 'preprod_ether_sso'
8
+ DB_SCHEMA: 'preprod_ether_crm'
9
9
  MASTER_KEY: '0QZ2eRJv5oVILYnyBlC+FbSGVQiWKReh'
10
10
  MASTER_IV: 'heuUQf5uPVtkotrFAOKUVw=='
11
11
  SECRET_KEY: '1hard_to_guess_secret7890a'