rez_core 3.1.56 → 3.1.58

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.
Files changed (38) hide show
  1. package/dist/module/mapper/controller/field-mapper.controller.d.ts +1 -0
  2. package/dist/module/mapper/controller/field-mapper.controller.js +10 -0
  3. package/dist/module/mapper/controller/field-mapper.controller.js.map +1 -1
  4. package/dist/module/mapper/dto/field-mapper.dto.d.ts +3 -4
  5. package/dist/module/mapper/dto/field-mapper.dto.js.map +1 -1
  6. package/dist/module/mapper/repository/field-lovs.repository.d.ts +1 -0
  7. package/dist/module/mapper/repository/field-lovs.repository.js +5 -0
  8. package/dist/module/mapper/repository/field-lovs.repository.js.map +1 -1
  9. package/dist/module/mapper/service/field-mapper.service.d.ts +2 -3
  10. package/dist/module/mapper/service/field-mapper.service.js +11 -14
  11. package/dist/module/mapper/service/field-mapper.service.js.map +1 -1
  12. package/dist/module/workflow/entity/action-category.entity.d.ts +1 -0
  13. package/dist/module/workflow/entity/action-category.entity.js +4 -0
  14. package/dist/module/workflow/entity/action-category.entity.js.map +1 -1
  15. package/dist/module/workflow-automation/entity/workflow-automation-action.entity.d.ts +1 -2
  16. package/dist/module/workflow-automation/entity/workflow-automation-action.entity.js +1 -5
  17. package/dist/module/workflow-automation/entity/workflow-automation-action.entity.js.map +1 -1
  18. package/dist/module/workflow-automation/entity/workflow-automation.entity.d.ts +1 -0
  19. package/dist/module/workflow-automation/entity/workflow-automation.entity.js +4 -0
  20. package/dist/module/workflow-automation/entity/workflow-automation.entity.js.map +1 -1
  21. package/dist/module/workflow-automation/service/workflow-automation-engine.service.d.ts +3 -1
  22. package/dist/module/workflow-automation/service/workflow-automation-engine.service.js +31 -8
  23. package/dist/module/workflow-automation/service/workflow-automation-engine.service.js.map +1 -1
  24. package/dist/module/workflow-automation/service/workflow-automation.service.d.ts +2 -1
  25. package/dist/module/workflow-automation/service/workflow-automation.service.js +3 -1
  26. package/dist/module/workflow-automation/service/workflow-automation.service.js.map +1 -1
  27. package/dist/tsconfig.build.tsbuildinfo +1 -1
  28. package/package.json +1 -1
  29. package/src/module/mapper/controller/field-mapper.controller.ts +5 -0
  30. package/src/module/mapper/dto/field-mapper.dto.ts +3 -4
  31. package/src/module/mapper/repository/field-lovs.repository.ts +6 -0
  32. package/src/module/mapper/service/field-mapper.service.ts +13 -13
  33. package/src/module/workflow/entity/action-category.entity.ts +3 -0
  34. package/src/module/workflow-automation/entity/workflow-automation-action.entity.ts +1 -4
  35. package/src/module/workflow-automation/entity/workflow-automation.entity.ts +3 -0
  36. package/src/module/workflow-automation/service/workflow-automation-engine.service.ts +46 -11
  37. package/src/module/workflow-automation/service/workflow-automation.service.ts +3 -0
  38. package/.vscode/extensions.json +0 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rez_core",
3
- "version": "3.1.56",
3
+ "version": "3.1.58",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -48,4 +48,9 @@ export class FieldMapperController {
48
48
  async getFieldsByMapper(@Param('mapperId') mapperId: number) {
49
49
  return this.fieldMapperService.getMapperFields(mapperId);
50
50
  }
51
+
52
+ @Get('getLovs/:mapperFieldId')
53
+ async getLovsByMapperField(@Param('mapperFieldId') mapperFieldId: number) {
54
+ return this.fieldMapperService.getFieldLovs(mapperFieldId);
55
+ }
51
56
  }
@@ -2,14 +2,13 @@ import { BaseEntity } from '../../meta/entity/base-entity.entity';
2
2
  import { FieldLovMapper } from '../entity/field-lovs.entity';
3
3
 
4
4
  export class FieldMapperDto extends BaseEntity {
5
- mapper_id: string;
6
5
  action: string;
6
+ mapper_id: number;
7
7
  source_attribute: string;
8
- destination_attribute: string;
9
- destination_entity_type: string;
8
+ attribute_key: string;
9
+ mapper_entity_type: string;
10
10
  mapped_entity_type: string;
11
11
  filter_code?: string;
12
- filter_json?: any;
13
12
  field_lovs?: FieldLovMapper[];
14
13
  }
15
14
 
@@ -23,4 +23,10 @@ export class FieldLovsRepository {
23
23
  where: { mapper_field_id, destination_attribute_value },
24
24
  })
25
25
  }
26
+
27
+ async findByMapperFieldId(mapper_field_id: number) {
28
+ return await this.fieldLovMapperRepository.find({
29
+ where: { mapper_field_id },
30
+ })
31
+ }
26
32
  }
@@ -1,9 +1,8 @@
1
- import { Inject, Injectable } from '@nestjs/common';
1
+ import { Injectable } from '@nestjs/common';
2
2
  import { FieldMapperRepository } from '../repository/field-mapper.repository';
3
3
  import { FieldMapperDto } from '../dto/field-mapper.dto';
4
4
  import { EntityServiceImpl } from '../../meta/service/entity-service-impl.service';
5
5
  import { UserData } from '../../user/entity/user.entity';
6
- import { SavedFilterService } from '../../filter/service/saved-filter.service';
7
6
  import { FieldLovsRepository } from '../repository/field-lovs.repository';
8
7
  import { DataSource } from 'typeorm';
9
8
  import { FilterService } from 'src/module/filter/service/filter.service';
@@ -13,8 +12,6 @@ import { BaseEntity } from '../../meta/entity/base-entity.entity';
13
12
  export class FieldMapperService extends EntityServiceImpl {
14
13
  constructor(
15
14
  private readonly fieldMapperRepository: FieldMapperRepository,
16
- @Inject('SavedFilterService')
17
- private readonly savedFilterService: SavedFilterService,
18
15
  private readonly fieldLovsRepository: FieldLovsRepository,
19
16
  private readonly datasource: DataSource,
20
17
  private readonly filterService: FilterService,
@@ -23,20 +20,19 @@ export class FieldMapperService extends EntityServiceImpl {
23
20
  }
24
21
 
25
22
  async createEntity(dto: FieldMapperDto, loggedInUser: UserData) {
23
+ let savedEntity = await super.createEntity(dto, loggedInUser);
24
+
26
25
  if (dto.field_lovs) {
26
+ for (const lov of dto.field_lovs) {
27
+ lov.mapper_field_id = savedEntity.id;
28
+ lov.entity_type = 'FLOV';
29
+ }
27
30
  await this.fieldLovsRepository.saveBulk(dto.field_lovs);
28
31
  }
29
- return super.createEntity(dto, loggedInUser);
32
+ return savedEntity;
30
33
  }
31
34
 
32
35
  async updateEntity(dto: FieldMapperDto, loggedInUser: UserData) {
33
- if (dto.filter_json) {
34
- const savedFilter = await this.savedFilterService.createEntity(
35
- dto.filter_json,
36
- loggedInUser,
37
- );
38
- dto.filter_code = savedFilter.code;
39
- }
40
36
  return super.updateEntity(dto, loggedInUser);
41
37
  }
42
38
 
@@ -62,6 +58,10 @@ export class FieldMapperService extends EntityServiceImpl {
62
58
  return await this.fieldMapperRepository.findByMapperId(mapperId);
63
59
  }
64
60
 
61
+ async getFieldLovs(mapperFieldId: number) {
62
+ return await this.fieldLovsRepository.findByMapperFieldId(mapperFieldId);
63
+ }
64
+
65
65
  async resolveData(
66
66
  mapper_id: number,
67
67
  parent_type: string,
@@ -88,7 +88,7 @@ export class FieldMapperService extends EntityServiceImpl {
88
88
 
89
89
  // Case 1️⃣ direct mapping (no mapped_entity_type or equal)
90
90
  if (
91
- !inMemory[entityType][filterCode] &&
91
+ !inMemory[entityType][filterCode] ||
92
92
  field.mapped_entity_type == field.mapper_entity_type
93
93
  ) {
94
94
  inMemory[entityType][filterCode] = await super.getResolvedEntityData(
@@ -32,4 +32,7 @@ export class ActionCategory extends BaseEntity {
32
32
 
33
33
  @Column({ type: 'varchar', nullable: true })
34
34
  mode: string;
35
+
36
+ @Column({ type: 'varchar', nullable: true })
37
+ action_decorator: string;
35
38
  }
@@ -16,10 +16,7 @@ export class WorkflowAutomationActionEntity extends BaseEntity {
16
16
  action_category_id: number;
17
17
 
18
18
  @Column({ type: 'json', nullable: true })
19
- payload: JSON;
20
-
21
- @Column({ type: 'varchar', nullable: true })
22
- action_decorator: string;
19
+ payload: string;
23
20
 
24
21
  @Column({ type: 'varchar', nullable: true })
25
22
  entity_method: string;
@@ -27,6 +27,9 @@ export class WorkflowAutomation extends BaseEntity {
27
27
  @Column({ type: 'varchar', nullable: true })
28
28
  trigger_type: string;
29
29
 
30
+ @Column({ type: 'varchar', nullable: true })
31
+ applicable_entity_type: string;
32
+
30
33
  @Column({ type: 'json', nullable: true })
31
34
  schedule: string;
32
35
  }
@@ -3,6 +3,7 @@ import { Injectable, Inject } from '@nestjs/common';
3
3
  import { WorkflowAutomationService } from './workflow-automation.service';
4
4
  import { FilterEvaluatorService } from '../../filter/service/filter-evaluator.service';
5
5
  import { Action } from '../interface/action.interface';
6
+ import { DataSource } from 'typeorm';
6
7
 
7
8
  @Injectable()
8
9
  export class WorkflowAutomationEngineService {
@@ -12,6 +13,7 @@ export class WorkflowAutomationEngineService {
12
13
  @Inject('WorkflowAutomationService')
13
14
  private readonly wfService: WorkflowAutomationService,
14
15
  private readonly filterEvaluator: FilterEvaluatorService,
16
+ private readonly dataSource: DataSource,
15
17
  ) {}
16
18
 
17
19
  registerAction(actionName: string, actionInstance: Action) {
@@ -90,24 +92,57 @@ export class WorkflowAutomationEngineService {
90
92
  entity: any,
91
93
  user: any,
92
94
  ) {
93
- // Load actions for this rule from DB
95
+ // 1️ Get actions from workflow automation
94
96
  const actions = await this.wfService.getActionsForRule(
95
97
  workflow_automation_id,
96
98
  );
97
99
 
100
+ if (!actions.length) {
101
+ console.log(`No actions found for workflow ${workflow_automation_id}`);
102
+ return;
103
+ }
104
+
98
105
  for (const action of actions) {
99
- const impl = this.actions.get(String(action.action_decorator)); // action_code = registered name
100
- if (!impl) {
101
- console.warn(
102
- `⚠️ No implementation found for action: ${action.action_decorator}`,
106
+ try {
107
+ // 2 Resolve action_decorator using action_category_id
108
+ const [category] = await this.dataSource.query(
109
+ `SELECT action_decorator FROM cr_wf_action_category WHERE id = ?`,
110
+ [action.action_category_id],
103
111
  );
104
- continue;
105
- }
106
112
 
107
- console.log(
108
- `🚀 Executing action ${action.action_decorator} for entity ${entity.id}`,
109
- );
110
- await impl.execute({ entity, user, config: action.payload });
113
+ if (!category?.action_decorator) {
114
+ console.warn(
115
+ `No action_decorator found for category_id=${action.action_category_id}`,
116
+ );
117
+ continue;
118
+ }
119
+
120
+ const decorator = String(category.action_decorator);
121
+
122
+ // 3️ Get implementation from the registered action map
123
+ const impl = this.actions.get(decorator);
124
+
125
+ if (!impl) {
126
+ console.warn(` No implementation found for action: ${decorator}`);
127
+ continue;
128
+ }
129
+
130
+ console.log(`Executing action ${decorator} for entity ${entity.id}`);
131
+
132
+ // 4️ Execute action with required context
133
+ await impl.execute({
134
+ entity,
135
+ user,
136
+ config: action.payload, // from cr_wf_action table
137
+ });
138
+
139
+ console.log(`Action ${decorator} executed successfully`);
140
+ } catch (err) {
141
+ console.error(
142
+ `Error executing action (category_id=${action.action_category_id}):`,
143
+ err,
144
+ );
145
+ }
111
146
  }
112
147
  }
113
148
  }
@@ -7,6 +7,7 @@ import { EntityServiceImpl } from 'src/module/meta/service/entity-service-impl.s
7
7
  import { UserData } from 'src/module/user/entity/user.entity';
8
8
  import { SavedFilterService } from 'src/module/filter/service/saved-filter.service';
9
9
  import { ENTITYTYPE_SAVEDFILTERMASTER } from 'src/constant/global.constant';
10
+ import { app } from 'firebase-admin';
10
11
 
11
12
  @Injectable()
12
13
  export class WorkflowAutomationService extends EntityServiceImpl {
@@ -90,6 +91,7 @@ export class WorkflowAutomationService extends EntityServiceImpl {
90
91
  filter_scope: 'RULE',
91
92
  organization_id: loggedInUser.organization_id,
92
93
  enterprise_id: loggedInUser.enterprise_id,
94
+ applicable_entity_type: workflow.applicable_entity_type,
93
95
  };
94
96
 
95
97
  if (workflow.condition_filter_code) {
@@ -128,6 +130,7 @@ export class WorkflowAutomationService extends EntityServiceImpl {
128
130
  if (event.triggerType === 'on_schedule') {
129
131
  // just store JSON directly into schedule column
130
132
  workflow.schedule = event?.scheduleJson ?? null;
133
+ workflow.applicable_entity_type= workflow.applicable_entity_type,
131
134
  this.logger.log(
132
135
  `Stored schedule JSON for workflow ${workflow.id}: ${JSON.stringify(
133
136
  workflow.schedule,
@@ -1,5 +0,0 @@
1
- {
2
- "recommendations": [
3
- "dbaeumer.vscode-eslint"
4
- ]
5
- }