rez_core 4.0.225 → 4.0.227

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 (26) hide show
  1. package/dist/module/workflow-automation/service/schedule-handler.service.d.ts +11 -5
  2. package/dist/module/workflow-automation/service/schedule-handler.service.js +50 -18
  3. package/dist/module/workflow-automation/service/schedule-handler.service.js.map +1 -1
  4. package/dist/module/workflow-automation/service/workflow-automation-engine.service.d.ts +4 -3
  5. package/dist/module/workflow-automation/service/workflow-automation-engine.service.js +12 -4
  6. package/dist/module/workflow-automation/service/workflow-automation-engine.service.js.map +1 -1
  7. package/dist/module/workflow-automation/service/workflow-automation.service.js +4 -2
  8. package/dist/module/workflow-automation/service/workflow-automation.service.js.map +1 -1
  9. package/dist/module/workflow-automation/workflow-automation.module.js +6 -0
  10. package/dist/module/workflow-automation/workflow-automation.module.js.map +1 -1
  11. package/dist/module/workflow-schedule/service/workflow-schedule.service.js +1 -1
  12. package/dist/module/workflow-schedule/service/workflow-schedule.service.js.map +1 -1
  13. package/dist/tsconfig.build.tsbuildinfo +1 -1
  14. package/package.json +1 -1
  15. package/src/module/workflow-automation/service/schedule-handler.service.ts +45 -26
  16. package/src/module/workflow-automation/service/workflow-automation-engine.service.ts +16 -6
  17. package/src/module/workflow-automation/service/workflow-automation.service.ts +10 -3
  18. package/src/module/workflow-automation/workflow-automation.module.ts +6 -0
  19. package/src/module/workflow-schedule/service/workflow-schedule.service.ts +1 -1
  20. package/.idea/250218_nodejs_core.iml +0 -12
  21. package/.idea/codeStyles/Project.xml +0 -59
  22. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  23. package/.idea/inspectionProfiles/Project_Default.xml +0 -6
  24. package/.idea/modules.xml +0 -8
  25. package/.idea/prettier.xml +0 -6
  26. package/.idea/vcs.xml +0 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rez_core",
3
- "version": "4.0.225",
3
+ "version": "4.0.227",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -1,7 +1,11 @@
1
1
  import { Inject, Injectable, Logger } from '@nestjs/common';
2
2
  import { FilterEvaluatorService } from 'src/module/filter/service/filter-evaluator.service';
3
- import { DataSource } from 'typeorm';
3
+ import { DataSource, Repository } from 'typeorm';
4
4
  import { WorkflowAutomationEngineService } from './workflow-automation-engine.service';
5
+ import { WorkflowAutomation } from '../entity/workflow-automation.entity';
6
+ import { InjectRepository } from '@nestjs/typeorm';
7
+ import { EntityMaster } from 'src/module/meta/entity/entity-master.entity';
8
+ import { ListMasterData } from 'src/module/listmaster/entity/list-master.entity';
5
9
 
6
10
  @Injectable()
7
11
  export class ScheduleHandlerService {
@@ -10,36 +14,52 @@ export class ScheduleHandlerService {
10
14
  constructor(
11
15
  private readonly dataSource: DataSource,
12
16
  private readonly filterEvaluator: FilterEvaluatorService,
13
- // @Inject('WorkflowAutomationEngineService')
14
17
  private readonly workflowAutomationEngineService: WorkflowAutomationEngineService,
18
+ @InjectRepository(WorkflowAutomation)
19
+ private readonly workflowAutomation: Repository<WorkflowAutomation>,
20
+ @InjectRepository(EntityMaster)
21
+ private readonly entityMasterRepository: Repository<EntityMaster>,
22
+ @InjectRepository(ListMasterData)
23
+ private readonly listMasterRepo: Repository<ListMasterData>,
15
24
  ) {}
16
25
 
17
26
  async scheduleQueryBuilder(workflowId: number, jobData: any) {
18
27
  // 1️⃣ Fetch workflow automation config
19
- const [workflow] = await this.dataSource.query(
20
- `SELECT * FROM frm_wf_automation WHERE id = ? AND organization_id = ?`,
21
- [workflowId, jobData.organizationId],
22
- );
28
+ const workflow = await this.workflowAutomation.findOne({
29
+ where: {
30
+ id: workflowId,
31
+ organization_id: jobData.organizationId,
32
+ },
33
+ });
23
34
 
24
35
  if (!workflow) throw new Error(`Workflow with ID ${workflowId} not found`);
25
36
 
26
- const event = JSON.parse(workflow.event_json || '{}');
27
- const scheduleJson = workflow.schedule;
37
+ const scheduleJson =
38
+ typeof workflow.schedule === 'string'
39
+ ? JSON.parse(workflow.schedule)
40
+ : workflow.schedule;
41
+
28
42
  const entityType = workflow.applicable_entity_type;
29
43
 
30
44
  // 2️⃣ Get table name from frm_entity_master
31
- const [entity] = await this.dataSource.query(
32
- `SELECT data_source FROM frm_entity_master WHERE mapped_entity_type = ? AND organization_id = ?`,
33
- [entityType, jobData.organizationId],
34
- );
45
+ const entity = await this.entityMasterRepository.findOne({
46
+ where: {
47
+ mapped_entity_type: entityType,
48
+ organization_id: jobData.organizationId,
49
+ },
50
+ select: ['data_source'],
51
+ });
35
52
  if (!entity?.data_source) throw new Error(`Entity ${entityType} not found`);
36
53
 
37
54
  const tableName = entity.data_source;
38
55
 
39
56
  // 3️⃣ Resolve executionDate (list master item name)
40
- const [executionDateItem] = await this.dataSource.query(
41
- `SELECT name FROM frm_list_master_items WHERE id = ${scheduleJson.executionDate}`
42
- );
57
+ const executionDateItem = await this.listMasterRepo.findOne({
58
+ where: {
59
+ id: scheduleJson.executionDate,
60
+ },
61
+ select: ['name'],
62
+ });
43
63
  const executionDateName = executionDateItem?.name?.toLowerCase() || '';
44
64
  const executionDataOrTime = scheduleJson.executionDateOrTime;
45
65
 
@@ -66,18 +86,18 @@ export class ScheduleHandlerService {
66
86
  `;
67
87
  }
68
88
 
69
- const query = `
70
- SELECT *
71
- FROM ${tableName}
72
- WHERE ${comparisonDateCondition}
73
- AND organization_id = ?
74
- `;
89
+ const qb = this.dataSource
90
+ .createQueryBuilder()
91
+ .from(tableName, tableName)
92
+ .select('*')
93
+ .where(comparisonDateCondition)
94
+ .andWhere(`${tableName}.organization_id = :orgId`, {
95
+ orgId: jobData.organizationId,
96
+ });
75
97
 
76
- this.logger.debug(`Executing Scheduler Query: ${query}`);
98
+ this.logger.debug(`Executing Scheduler Query: ${qb.getSql()}`);
77
99
 
78
- const results = await this.dataSource.query(query, [
79
- jobData.organizationId,
80
- ]);
100
+ const results = await qb.getRawMany();
81
101
 
82
102
  this.logger.log(
83
103
  `Found ${results.length} scheduled records for ${tableName}`,
@@ -103,7 +123,6 @@ export class ScheduleHandlerService {
103
123
  );
104
124
 
105
125
  // Parse the workflow event JSON again to get filter/action info
106
- const event = JSON.parse(workflow.event_json || '{}');
107
126
  const filter = workflow.condition_filter_code;
108
127
  const mappedEntityType = workflow.applicable_entity_type;
109
128
 
@@ -3,7 +3,9 @@ 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
+ import { ActionCategory } from 'src/module/workflow/entity/action-category.entity';
7
+ import { Repository } from 'typeorm';
8
+ import { InjectRepository } from '@nestjs/typeorm';
7
9
 
8
10
  @Injectable()
9
11
  export class WorkflowAutomationEngineService {
@@ -13,7 +15,8 @@ export class WorkflowAutomationEngineService {
13
15
  @Inject('WorkflowAutomationService')
14
16
  private readonly wfService: WorkflowAutomationService,
15
17
  private readonly filterEvaluator: FilterEvaluatorService,
16
- private readonly dataSource: DataSource,
18
+ @InjectRepository(ActionCategory)
19
+ private readonly actionCateRepo: Repository<ActionCategory>,
17
20
  ) {}
18
21
 
19
22
  registerAction(actionName: string, actionInstance: Action) {
@@ -165,10 +168,17 @@ export class WorkflowAutomationEngineService {
165
168
  for (const action of actions) {
166
169
  try {
167
170
  // 2 Resolve action_decorator using action_category_id
168
- const [category] = await this.dataSource.query(
169
- `SELECT action_decorator FROM frm_wf_action_category WHERE id = ?`,
170
- [action.action_category_id],
171
- );
171
+ // const category = await this.dataSource.query(
172
+ // `SELECT action_decorator FROM frm_wf_action_category WHERE id = ?`,
173
+ // [action.action_category_id],
174
+ // );
175
+
176
+ const category = await this.actionCateRepo.findOne({
177
+ where: {
178
+ id: action.action_category_id,
179
+ },
180
+ select: ['action_decorator'],
181
+ });
172
182
 
173
183
  if (!category?.action_decorator) {
174
184
  console.warn(
@@ -16,6 +16,8 @@ import { ENTITYTYPE_SAVEDFILTERMASTER } from 'src/constant/global.constant';
16
16
  import { ScheduledWorkflow } from 'src/module/workflow-schedule/entities/scheduled-workflow.entity';
17
17
  import { WorkflowScheduleService } from 'src/module/workflow-schedule/service/workflow-schedule.service';
18
18
  import * as moment from 'moment';
19
+ import { Update } from 'aws-sdk/clients/dynamodb';
20
+ import { UpdateScheduleDto } from 'src/module/workflow-schedule/dto/update-schedule.dto';
19
21
 
20
22
  @Injectable()
21
23
  export class WorkflowAutomationService extends EntityServiceImpl {
@@ -232,6 +234,7 @@ export class WorkflowAutomationService extends EntityServiceImpl {
232
234
  existing.payload = a.actionPayload ?? {};
233
235
  existing.actionCategoryName =
234
236
  a.actionCategoryName ?? existing.actionCategoryName;
237
+ existing.status = a.status ?? existing.status;
235
238
  await this.dataSource
236
239
  .getRepository(WorkflowAutomationActionEntity)
237
240
  .save(existing);
@@ -377,6 +380,7 @@ export class WorkflowAutomationService extends EntityServiceImpl {
377
380
  const cronExpression = await this.generateDailyCron(scheduleJson.fixedTime);
378
381
 
379
382
  const payload = {
383
+ id: Number(existingSchedule?.id ?? null),
380
384
  workflow_id: workflow.id,
381
385
  workflow_name: workflow.name,
382
386
  name: scheduleJson.name ?? `Schedule_${workflow.id}`,
@@ -401,8 +405,11 @@ export class WorkflowAutomationService extends EntityServiceImpl {
401
405
  this.logger.log(
402
406
  `Existing schedule found (id=${existingSchedule.id}), updating...`,
403
407
  );
404
- payload['id'] = existingSchedule.id;
405
- // return await this.workflowScheduleService.updateSchedule(payload, loggedInUser);
408
+ // payload['id'] = existingSchedule.id;
409
+ return await this.workflowScheduleService.updateSchedule(
410
+ payload,
411
+ loggedInUser,
412
+ );
406
413
  } else {
407
414
  this.logger.log(`No existing schedule found, creating new one...`);
408
415
  return await this.workflowScheduleService.createSchedule(
@@ -436,7 +443,7 @@ export class WorkflowAutomationService extends EntityServiceImpl {
436
443
  );
437
444
  }
438
445
 
439
- return '*/1 * * * *';
446
+ return cron;
440
447
  }
441
448
  /**
442
449
  * Updates the sequence of multiple workflow automations.
@@ -12,6 +12,9 @@ import { ActionRegistryService } from './service/action-registery.service';
12
12
  import { ScheduleHandlerService } from './service/schedule-handler.service';
13
13
  import { ScheduledWorkflow } from '../workflow-schedule/entities/scheduled-workflow.entity';
14
14
  import { WorkflowExecutionLog } from '../workflow-schedule/entities/workflow-execution-log.entity';
15
+ import {EntityMaster} from "../meta/entity/entity-master.entity";
16
+ import { ListMasterData } from '../listmaster/entity/list-master.entity';
17
+ import { ActionCategory } from '../workflow/entity/action-category.entity';
15
18
 
16
19
  @Module({
17
20
  imports: [
@@ -20,6 +23,9 @@ import { WorkflowExecutionLog } from '../workflow-schedule/entities/workflow-exe
20
23
  WorkflowAutomationActionEntity,
21
24
  ScheduledWorkflow, // 👈 Required by WorkflowAutomationService
22
25
  WorkflowExecutionLog, // 👈 May be used by services
26
+ EntityMaster,
27
+ ListMasterData,
28
+ ActionCategory
23
29
  ]),
24
30
  FilterModule,
25
31
  forwardRef(() => EntityModule),
@@ -539,7 +539,7 @@ export class WorkflowScheduleService {
539
539
 
540
540
  const job = await this.scheduleQueue.add(EXECUTE_SCHEDULED_WORKFLOW_JOB, jobData, {
541
541
  repeat: {
542
- cron: '*/1 * * * *',
542
+ cron: schedule.cron_expression,
543
543
  tz: schedule.timezone,
544
544
  startDate: schedule.start_date || undefined,
545
545
  endDate: schedule.end_date || undefined,
@@ -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>