rez_core 4.0.19 → 4.0.21

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.19",
3
+ "version": "4.0.21",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -65,6 +65,14 @@ export class PopulateMetaService {
65
65
  );
66
66
  const status = getStatus[0]?.id ? getStatus[0].id : 'ACTIVE';
67
67
 
68
+ let oneToManyId = await this.dataSource.query(
69
+ `SELECT id FROM frm_list_master_items WHERE value = 'ONE_TO_MANY' AND organization_id = ${organization_id}`,
70
+ )
71
+
72
+ let oneToOneId = await this.dataSource.query(
73
+ `SELECT id FROM frm_list_master_items WHERE value = 'ONE_TO_MANY' AND organization_id = ${organization_id}`,
74
+ )
75
+
68
76
  // Step 1: Insert basic metadata tables
69
77
  for (const table of metadataTables) {
70
78
  const factoryData = await this.dataSource.query(
@@ -99,7 +107,19 @@ export class PopulateMetaService {
99
107
  status: status,
100
108
  }),
101
109
  );
102
- } else {
110
+ }
111
+ else if (table === 'frm_entity_relation') {
112
+ transformedData = factoryData.map(
113
+ ({ id, created_date, modified_date, ...rest }) => ({
114
+ ...rest,
115
+ organization_id,
116
+ level_type: 'ORG',
117
+ level_id: organization_id,
118
+ status: status,
119
+ relation_id:rest.relation_type=="ONE_TO_ONE"?oneToOneId[0].id:oneToManyId[0].id
120
+ }),
121
+ );
122
+ }else {
103
123
  transformedData = factoryData.map(
104
124
  ({ id, created_date, modified_date, ...rest }) => ({
105
125
  ...rest,
@@ -17,7 +17,7 @@ export class ActionTemplateMappingController {
17
17
  private readonly actionTemplateMappingService: ActionTemplateMappingService,
18
18
  ) {}
19
19
 
20
- @Post('/get-template')
20
+ @Post('/get-template-by-mode')
21
21
  @HttpCode(HttpStatus.OK)
22
22
  async getTemplate(
23
23
  @Body() body: { stage_id: number; action_id: number; mode: number },
@@ -27,8 +27,8 @@ export class ActionTemplateMappingController {
27
27
  const result = this.actionTemplateMappingService.getTemplateByMode(
28
28
  body.stage_id,
29
29
  body.action_id,
30
- body.mode,
31
30
  loggedInUser,
31
+ body.mode,
32
32
  );
33
33
  return result;
34
34
  }
@@ -269,7 +269,7 @@ export class ActionDataRepository extends EntityServiceImpl {
269
269
 
270
270
  const { level_id } = loggedInUser;
271
271
 
272
- const url = `${baseUrl}/entity/public/getById/${level_id}?entity_type=ORG&${queryParams}`;
272
+ const url = `${baseUrl}/organization/public/${level_id}?entity_type=ORGP&${queryParams}`;
273
273
 
274
274
  const response = await axios.get(url);
275
275
  console.log('Internal Entity API response:', response.data);
@@ -281,7 +281,7 @@ export class ActionDataRepository extends EntityServiceImpl {
281
281
  console.error('Internal Entity API call failed:', error.message);
282
282
  }
283
283
 
284
- const org_slug = organizationData?.slug;
284
+ const org_slug = organizationData[0]?.slug;
285
285
 
286
286
  // fetch required var from config or env
287
287
  const profile = this.configService.get('PROFILE');
@@ -1,3 +1,4 @@
1
+ import { level } from 'winston';
1
2
  import { Injectable } from '@nestjs/common';
2
3
  import { EntityServiceImpl } from 'src/module/meta/service/entity-service-impl.service';
3
4
  import { DataSource } from 'typeorm';
@@ -10,8 +11,8 @@ export class ActionTemplateMappingService extends EntityServiceImpl {
10
11
  async getTemplateByMode(
11
12
  stage_id: number,
12
13
  action_id: number,
13
- mode: number,
14
14
  loggedInUser,
15
+ mode?: number,
15
16
  ) {
16
17
  const stageAction = await this.dataSource.query(
17
18
  `
@@ -24,6 +25,17 @@ export class ActionTemplateMappingService extends EntityServiceImpl {
24
25
 
25
26
  const stgActMappingId = stageAction[0].id;
26
27
 
28
+ if (!mode) {
29
+ const getModeFromAction = await this.dataSource.query(
30
+ `
31
+ SELECT mode FROM frm_wf_action
32
+ WHERE id = ?
33
+ `,
34
+ [action_id],
35
+ );
36
+ mode = getModeFromAction[0]?.mode;
37
+ }
38
+
27
39
  const templates = await this.dataSource.query(
28
40
  `
29
41
  SELECT template_code FROM frm_wf_action_resources_mapping
@@ -31,12 +43,6 @@ export class ActionTemplateMappingService extends EntityServiceImpl {
31
43
  `,
32
44
  [stgActMappingId],
33
45
  );
34
- const listMasterItemData = await this.dataSource.query(
35
- `SELECT code FROM frm_list_master_items WHERE id = ?`,
36
- [mode],
37
- );
38
-
39
- if (!listMasterItemData?.length) return [];
40
46
 
41
47
  const templateCodes = templates.map((t) => t.template_code);
42
48
  if (!templateCodes.length) return [];
@@ -45,9 +51,15 @@ export class ActionTemplateMappingService extends EntityServiceImpl {
45
51
  `
46
52
  SELECT id, name
47
53
  FROM frm_wf_comm_template
48
- WHERE code IN (?) AND mode = ? AND organization_id = ?
54
+ WHERE code IN (?) AND mode = ? AND organization_id = ? AND level_type = ? AND level_id = ?
49
55
  `,
50
- [templateCodes, listMasterItemData[0].code, loggedInUser.organization_id],
56
+ [
57
+ templateCodes,
58
+ mode,
59
+ loggedInUser.organization_id,
60
+ loggedInUser.level_type,
61
+ loggedInUser.level_id,
62
+ ],
51
63
  );
52
64
 
53
65
  return commTemplates;
@@ -191,7 +191,8 @@ export class ActionService extends EntityServiceImpl {
191
191
  entity_type: 'WFAR',
192
192
  } as any;
193
193
 
194
- await super.createEntity(resourceMapping, loggedInUser);
194
+ const res = await super.createEntity(resourceMapping, loggedInUser);
195
+ console.log(res);
195
196
  }
196
197
  }
197
198