rez_core 4.0.184 → 4.0.187

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 (197) hide show
  1. package/dist/app.module.js +11 -0
  2. package/dist/app.module.js.map +1 -1
  3. package/dist/config/bull.config.d.ts +10 -0
  4. package/dist/config/bull.config.js +66 -0
  5. package/dist/config/bull.config.js.map +1 -0
  6. package/dist/config/database.config.js +1 -1
  7. package/dist/config/database.config.js.map +1 -1
  8. package/dist/module/entity_json/controller/entity_json.controller.d.ts +8 -0
  9. package/dist/module/entity_json/controller/entity_json.controller.js +43 -0
  10. package/dist/module/entity_json/controller/entity_json.controller.js.map +1 -0
  11. package/dist/module/entity_json/entity_json.module.d.ts +2 -0
  12. package/dist/module/entity_json/entity_json.module.js +26 -0
  13. package/dist/module/entity_json/entity_json.module.js.map +1 -0
  14. package/dist/module/entity_json/service/entity_json.service.d.ts +7 -0
  15. package/dist/module/entity_json/service/entity_json.service.js +116 -0
  16. package/dist/module/entity_json/service/entity_json.service.js.map +1 -0
  17. package/dist/module/filter/service/filter.service.js.map +1 -1
  18. package/dist/module/integration/service/wrapper.service.d.ts +3 -1
  19. package/dist/module/integration/service/wrapper.service.js +39 -36
  20. package/dist/module/integration/service/wrapper.service.js.map +1 -1
  21. package/dist/module/linked_attributes/controller/linked_attributes.controller.d.ts +5 -0
  22. package/dist/module/linked_attributes/controller/linked_attributes.controller.js +29 -0
  23. package/dist/module/linked_attributes/controller/linked_attributes.controller.js.map +1 -0
  24. package/dist/module/linked_attributes/entity/linked_attribute.entity.d.ts +9 -0
  25. package/dist/module/linked_attributes/entity/linked_attribute.entity.js +70 -0
  26. package/dist/module/linked_attributes/entity/linked_attribute.entity.js.map +1 -0
  27. package/dist/module/linked_attributes/linked_attributes.module.d.ts +2 -0
  28. package/dist/module/linked_attributes/linked_attributes.module.js +29 -0
  29. package/dist/module/linked_attributes/linked_attributes.module.js.map +1 -0
  30. package/dist/module/linked_attributes/repository/linked_attribute.repository.d.ts +6 -0
  31. package/dist/module/linked_attributes/repository/linked_attribute.repository.js +31 -0
  32. package/dist/module/linked_attributes/repository/linked_attribute.repository.js.map +1 -0
  33. package/dist/module/linked_attributes/service/linked_attributes.service.d.ts +5 -0
  34. package/dist/module/linked_attributes/service/linked_attributes.service.js +34 -0
  35. package/dist/module/linked_attributes/service/linked_attributes.service.js.map +1 -0
  36. package/dist/module/mapper/service/field-mapper.service.js +2 -2
  37. package/dist/module/mapper/service/field-mapper.service.js.map +1 -1
  38. package/dist/module/meta/controller/attribute-master.controller.d.ts +10 -1
  39. package/dist/module/meta/controller/attribute-master.controller.js +27 -2
  40. package/dist/module/meta/controller/attribute-master.controller.js.map +1 -1
  41. package/dist/module/meta/controller/entity-master.controller.d.ts +6 -0
  42. package/dist/module/meta/controller/entity-master.controller.js +13 -0
  43. package/dist/module/meta/controller/entity-master.controller.js.map +1 -1
  44. package/dist/module/meta/entity.module.js +7 -0
  45. package/dist/module/meta/entity.module.js.map +1 -1
  46. package/dist/module/meta/repository/attribute-master.repository.d.ts +4 -0
  47. package/dist/module/meta/repository/attribute-master.repository.js +19 -0
  48. package/dist/module/meta/repository/attribute-master.repository.js.map +1 -1
  49. package/dist/module/meta/repository/entity-attribute-update.repository.d.ts +6 -0
  50. package/dist/module/meta/repository/entity-attribute-update.repository.js +44 -0
  51. package/dist/module/meta/repository/entity-attribute-update.repository.js.map +1 -0
  52. package/dist/module/meta/repository/entity-master.repository.d.ts +7 -1
  53. package/dist/module/meta/repository/entity-master.repository.js +24 -2
  54. package/dist/module/meta/repository/entity-master.repository.js.map +1 -1
  55. package/dist/module/meta/service/attribute-master.service.d.ts +4 -0
  56. package/dist/module/meta/service/attribute-master.service.js +3 -0
  57. package/dist/module/meta/service/attribute-master.service.js.map +1 -1
  58. package/dist/module/meta/service/entity-attribute-update.service.d.ts +7 -0
  59. package/dist/module/meta/service/entity-attribute-update.service.js +35 -0
  60. package/dist/module/meta/service/entity-attribute-update.service.js.map +1 -0
  61. package/dist/module/meta/service/entity-master.service.d.ts +4 -0
  62. package/dist/module/meta/service/entity-master.service.js +3 -0
  63. package/dist/module/meta/service/entity-master.service.js.map +1 -1
  64. package/dist/module/meta/service/resolver.service.js +2 -2
  65. package/dist/module/meta/service/resolver.service.js.map +1 -1
  66. package/dist/module/module/service/module-access.service.js +1 -7
  67. package/dist/module/module/service/module-access.service.js.map +1 -1
  68. package/dist/module/workflow/entity/action.entity.d.ts +1 -0
  69. package/dist/module/workflow/entity/action.entity.js +4 -0
  70. package/dist/module/workflow/entity/action.entity.js.map +1 -1
  71. package/dist/module/workflow/repository/action-data.repository.js +1 -0
  72. package/dist/module/workflow/repository/action-data.repository.js.map +1 -1
  73. package/dist/module/workflow/repository/task.repository.d.ts +3 -1
  74. package/dist/module/workflow/repository/task.repository.js +6 -1
  75. package/dist/module/workflow/repository/task.repository.js.map +1 -1
  76. package/dist/module/workflow/service/task.service.js +41 -27
  77. package/dist/module/workflow/service/task.service.js.map +1 -1
  78. package/dist/module/workflow/service/workflow-meta.service.js +23 -21
  79. package/dist/module/workflow/service/workflow-meta.service.js.map +1 -1
  80. package/dist/module/workflow-automation/controller/workflow-automation.controller.d.ts +6 -0
  81. package/dist/module/workflow-automation/controller/workflow-automation.controller.js +16 -0
  82. package/dist/module/workflow-automation/controller/workflow-automation.controller.js.map +1 -1
  83. package/dist/module/workflow-automation/entity/workflow-automation.entity.d.ts +2 -0
  84. package/dist/module/workflow-automation/entity/workflow-automation.entity.js +8 -0
  85. package/dist/module/workflow-automation/entity/workflow-automation.entity.js.map +1 -1
  86. package/dist/module/workflow-automation/service/schedule-handler.service.d.ts +16 -0
  87. package/dist/module/workflow-automation/service/schedule-handler.service.js +109 -0
  88. package/dist/module/workflow-automation/service/schedule-handler.service.js.map +1 -0
  89. package/dist/module/workflow-automation/service/workflow-automation-engine.service.d.ts +1 -1
  90. package/dist/module/workflow-automation/service/workflow-automation-engine.service.js.map +1 -1
  91. package/dist/module/workflow-automation/service/workflow-automation.service.d.ts +13 -1
  92. package/dist/module/workflow-automation/service/workflow-automation.service.js +111 -2
  93. package/dist/module/workflow-automation/service/workflow-automation.service.js.map +1 -1
  94. package/dist/module/workflow-automation/workflow-automation.module.js +14 -1
  95. package/dist/module/workflow-automation/workflow-automation.module.js.map +1 -1
  96. package/dist/module/workflow-schedule/constants/schedule.constants.d.ts +27 -0
  97. package/dist/module/workflow-schedule/constants/schedule.constants.js +31 -0
  98. package/dist/module/workflow-schedule/constants/schedule.constants.js.map +1 -0
  99. package/dist/module/workflow-schedule/controller/workflow-schedule.controller.d.ts +83 -0
  100. package/dist/module/workflow-schedule/controller/workflow-schedule.controller.js +220 -0
  101. package/dist/module/workflow-schedule/controller/workflow-schedule.controller.js.map +1 -0
  102. package/dist/module/workflow-schedule/dto/create-schedule.dto.d.ts +32 -0
  103. package/dist/module/workflow-schedule/dto/create-schedule.dto.js +163 -0
  104. package/dist/module/workflow-schedule/dto/create-schedule.dto.js.map +1 -0
  105. package/dist/module/workflow-schedule/dto/get-execution-logs.dto.d.ts +35 -0
  106. package/dist/module/workflow-schedule/dto/get-execution-logs.dto.js +124 -0
  107. package/dist/module/workflow-schedule/dto/get-execution-logs.dto.js.map +1 -0
  108. package/dist/module/workflow-schedule/dto/update-schedule.dto.d.ts +19 -0
  109. package/dist/module/workflow-schedule/dto/update-schedule.dto.js +106 -0
  110. package/dist/module/workflow-schedule/dto/update-schedule.dto.js.map +1 -0
  111. package/dist/module/workflow-schedule/entities/scheduled-workflow.entity.d.ts +30 -0
  112. package/dist/module/workflow-schedule/entities/scheduled-workflow.entity.js +113 -0
  113. package/dist/module/workflow-schedule/entities/scheduled-workflow.entity.js.map +1 -0
  114. package/dist/module/workflow-schedule/entities/workflow-execution-log.entity.d.ts +34 -0
  115. package/dist/module/workflow-schedule/entities/workflow-execution-log.entity.js +118 -0
  116. package/dist/module/workflow-schedule/entities/workflow-execution-log.entity.js.map +1 -0
  117. package/dist/module/workflow-schedule/interfaces/schedule-job-data.interface.d.ts +44 -0
  118. package/dist/module/workflow-schedule/interfaces/schedule-job-data.interface.js +3 -0
  119. package/dist/module/workflow-schedule/interfaces/schedule-job-data.interface.js.map +1 -0
  120. package/dist/module/workflow-schedule/interfaces/workflow-schedule-options.interface.d.ts +3 -0
  121. package/dist/module/workflow-schedule/interfaces/workflow-schedule-options.interface.js +3 -0
  122. package/dist/module/workflow-schedule/interfaces/workflow-schedule-options.interface.js.map +1 -0
  123. package/dist/module/workflow-schedule/processors/schedule.processor.d.ts +31 -0
  124. package/dist/module/workflow-schedule/processors/schedule.processor.js +409 -0
  125. package/dist/module/workflow-schedule/processors/schedule.processor.js.map +1 -0
  126. package/dist/module/workflow-schedule/service/workflow-schedule.service.d.ts +44 -0
  127. package/dist/module/workflow-schedule/service/workflow-schedule.service.js +434 -0
  128. package/dist/module/workflow-schedule/service/workflow-schedule.service.js.map +1 -0
  129. package/dist/module/workflow-schedule/workflow-schedule.module.d.ts +5 -0
  130. package/dist/module/workflow-schedule/workflow-schedule.module.js +52 -0
  131. package/dist/module/workflow-schedule/workflow-schedule.module.js.map +1 -0
  132. package/dist/table.config.d.ts +1 -1
  133. package/dist/tsconfig.build.tsbuildinfo +1 -1
  134. package/dist/utils/service/loggingUtil.service.d.ts +9 -2
  135. package/dist/utils/service/loggingUtil.service.js +65 -14
  136. package/dist/utils/service/loggingUtil.service.js.map +1 -1
  137. package/dist/utils/utils.module.js +2 -0
  138. package/dist/utils/utils.module.js.map +1 -1
  139. package/package.json +9 -4
  140. package/src/app.module.ts +16 -2
  141. package/src/config/bull.config.ts +69 -0
  142. package/src/config/database.config.ts +1 -1
  143. package/src/module/entity_json/controller/entity_json.controller.ts +47 -0
  144. package/src/module/entity_json/entity_json.module.ts +13 -0
  145. package/src/module/entity_json/service/entity_json.service.ts +162 -0
  146. package/src/module/filter/service/filter.service.ts +0 -2
  147. package/src/module/integration/service/wrapper.service.ts +248 -41
  148. package/src/module/linked_attributes/controller/linked_attributes.controller.ts +10 -0
  149. package/src/module/linked_attributes/entity/linked_attribute.entity.ts +48 -0
  150. package/src/module/linked_attributes/linked_attributes.module.ts +16 -0
  151. package/src/module/linked_attributes/repository/linked_attribute.repository.ts +12 -0
  152. package/src/module/linked_attributes/service/linked_attributes.service.ts +22 -0
  153. package/src/module/mapper/service/field-mapper.service.ts +12 -7
  154. package/src/module/meta/controller/attribute-master.controller.ts +20 -0
  155. package/src/module/meta/controller/entity-master.controller.ts +13 -0
  156. package/src/module/meta/entity.module.ts +8 -0
  157. package/src/module/meta/repository/attribute-master.repository.ts +20 -0
  158. package/src/module/meta/repository/entity-attribute-update.repository.ts +44 -0
  159. package/src/module/meta/repository/entity-master.repository.ts +30 -0
  160. package/src/module/meta/service/attribute-master.service.ts +4 -0
  161. package/src/module/meta/service/entity-attribute-update.service.ts +29 -0
  162. package/src/module/meta/service/entity-master.service.ts +6 -0
  163. package/src/module/meta/service/resolver.service.ts +2 -2
  164. package/src/module/module/service/module-access.service.ts +3 -16
  165. package/src/module/workflow/entity/action.entity.ts +3 -0
  166. package/src/module/workflow/repository/action-data.repository.ts +1 -0
  167. package/src/module/workflow/repository/task.repository.ts +8 -0
  168. package/src/module/workflow/service/task.service.ts +47 -38
  169. package/src/module/workflow/service/workflow-meta.service.ts +47 -33
  170. package/src/module/workflow-automation/SCHEDULING_GUIDE.md +145 -0
  171. package/src/module/workflow-automation/controller/workflow-automation.controller.ts +22 -0
  172. package/src/module/workflow-automation/entity/workflow-automation.entity.ts +5 -0
  173. package/src/module/workflow-automation/service/schedule-handler.service.ts +149 -0
  174. package/src/module/workflow-automation/service/workflow-automation-engine.service.ts +1 -1
  175. package/src/module/workflow-automation/service/workflow-automation.service.ts +163 -2
  176. package/src/module/workflow-automation/workflow-automation.module.ts +14 -1
  177. package/src/module/workflow-schedule/INSTALLATION.md +244 -0
  178. package/src/module/workflow-schedule/MULTI_PROJECT_GUIDE.md +196 -0
  179. package/src/module/workflow-schedule/README.md +422 -0
  180. package/src/module/workflow-schedule/constants/schedule.constants.ts +48 -0
  181. package/src/module/workflow-schedule/controller/workflow-schedule.controller.ts +255 -0
  182. package/src/module/workflow-schedule/docs/CLAUDE_CODE_GUIDE.md +510 -0
  183. package/src/module/workflow-schedule/docs/CLAUDE_CODE_PROMPT.md +362 -0
  184. package/src/module/workflow-schedule/docs/RUN_CLAUDE_CODE.sh +68 -0
  185. package/src/module/workflow-schedule/dto/create-schedule.dto.ts +147 -0
  186. package/src/module/workflow-schedule/dto/get-execution-logs.dto.ts +119 -0
  187. package/src/module/workflow-schedule/dto/update-schedule.dto.ts +96 -0
  188. package/src/module/workflow-schedule/entities/scheduled-workflow.entity.ts +148 -0
  189. package/src/module/workflow-schedule/entities/workflow-execution-log.entity.ts +154 -0
  190. package/src/module/workflow-schedule/interfaces/schedule-job-data.interface.ts +53 -0
  191. package/src/module/workflow-schedule/interfaces/workflow-schedule-options.interface.ts +12 -0
  192. package/src/module/workflow-schedule/processors/schedule.processor.ts +584 -0
  193. package/src/module/workflow-schedule/service/workflow-schedule.service.ts +600 -0
  194. package/src/module/workflow-schedule/workflow-schedule.module.ts +67 -0
  195. package/src/resources/dev.properties.yaml +1 -1
  196. package/src/utils/service/loggingUtil.service.ts +70 -16
  197. package/src/utils/utils.module.ts +2 -0
@@ -0,0 +1,409 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ var ScheduleProcessor_1;
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.ScheduleProcessor = void 0;
17
+ const bull_1 = require("@nestjs/bull");
18
+ const common_1 = require("@nestjs/common");
19
+ const typeorm_1 = require("@nestjs/typeorm");
20
+ const typeorm_2 = require("typeorm");
21
+ const scheduled_workflow_entity_1 = require("../entities/scheduled-workflow.entity");
22
+ const workflow_execution_log_entity_1 = require("../entities/workflow-execution-log.entity");
23
+ const schedule_constants_1 = require("../constants/schedule.constants");
24
+ const schedule_handler_service_1 = require("../../workflow-automation/service/schedule-handler.service");
25
+ let ScheduleProcessor = ScheduleProcessor_1 = class ScheduleProcessor {
26
+ constructor(scheduledWorkflowRepository, executionLogRepository, dataSource, scheduleHandlerService) {
27
+ this.scheduledWorkflowRepository = scheduledWorkflowRepository;
28
+ this.executionLogRepository = executionLogRepository;
29
+ this.dataSource = dataSource;
30
+ this.scheduleHandlerService = scheduleHandlerService;
31
+ this.logger = new common_1.Logger(ScheduleProcessor_1.name);
32
+ }
33
+ async handleScheduledWorkflowExecution(job) {
34
+ const { scheduleId, workflowId, organizationId, triggeredBy, createdBy } = job.data;
35
+ this.logger.log(`🚀 [handleScheduledWorkflowExecution] Invoked for scheduleId=${scheduleId}, workflowId=${workflowId}`);
36
+ const executionLog = this.executionLogRepository.create({
37
+ schedule_id: scheduleId,
38
+ workflow_id: workflowId,
39
+ job_id: job.id.toString(),
40
+ execution_status: schedule_constants_1.EXECUTION_STATUS_PENDING,
41
+ triggered_by: triggeredBy,
42
+ triggered_by_user_id: triggeredBy === 'MANUAL' ? createdBy : null,
43
+ organization_id: organizationId,
44
+ enterprise_id: job.data.enterpriseId,
45
+ created_by: createdBy,
46
+ entity_type: 'WFEL',
47
+ });
48
+ this.logger.debug(`🧾 Creating execution log for jobId=${job.id}`);
49
+ await this.executionLogRepository.save(executionLog);
50
+ try {
51
+ executionLog.execution_status = schedule_constants_1.EXECUTION_STATUS_RUNNING;
52
+ executionLog.started_at = new Date();
53
+ await this.executionLogRepository.save(executionLog);
54
+ this.logger.log(`🏃 Workflow execution started for scheduleId=${scheduleId}`);
55
+ const schedule = await this.scheduledWorkflowRepository.findOne({
56
+ where: { id: scheduleId },
57
+ });
58
+ if (!schedule) {
59
+ throw new Error(`Scheduled workflow not found: ${scheduleId}`);
60
+ }
61
+ this.logger.debug(`📋 Loaded schedule from DB: ${JSON.stringify(schedule)}`);
62
+ this.logger.log(`⚙️ Executing workflow actions...`);
63
+ const result = await this.executeWorkflowActions(schedule, job.data);
64
+ this.logger.debug(`🧮 Execution result: ${JSON.stringify(result)}`);
65
+ const completedAt = new Date();
66
+ executionLog.execution_status =
67
+ result.failedRecords > 0 && result.successfulRecords > 0
68
+ ? schedule_constants_1.EXECUTION_STATUS_PARTIAL
69
+ : result.failedRecords > 0
70
+ ? schedule_constants_1.EXECUTION_STATUS_FAILED
71
+ : schedule_constants_1.EXECUTION_STATUS_COMPLETED;
72
+ executionLog.completed_at = completedAt;
73
+ executionLog.duration_ms = completedAt.getTime() - executionLog.started_at.getTime();
74
+ executionLog.total_records = result.totalRecords;
75
+ executionLog.successful_records = result.successfulRecords;
76
+ executionLog.failed_records = result.failedRecords;
77
+ executionLog.execution_details = {
78
+ batchesProcessed: Math.ceil(result.totalRecords / schedule_constants_1.DEFAULT_BATCH_SIZE),
79
+ errors: result.errors,
80
+ };
81
+ await this.executionLogRepository.save(executionLog);
82
+ schedule.execution_count += 1;
83
+ schedule.last_execution_at = completedAt;
84
+ await this.scheduledWorkflowRepository.save(schedule);
85
+ this.logger.log(`✅ Workflow execution completed: scheduleId=${scheduleId}, status=${executionLog.execution_status}, processed=${result.totalRecords}`);
86
+ return {
87
+ success: true,
88
+ executionLogId: executionLog.id,
89
+ result,
90
+ };
91
+ }
92
+ catch (error) {
93
+ this.logger.error(`🔥 Workflow execution failed: scheduleId=${scheduleId}, error=${error.message}`, error.stack);
94
+ executionLog.execution_status = schedule_constants_1.EXECUTION_STATUS_FAILED;
95
+ executionLog.completed_at = new Date();
96
+ executionLog.duration_ms = executionLog.started_at
97
+ ? executionLog.completed_at.getTime() - executionLog.started_at.getTime()
98
+ : 0;
99
+ executionLog.error_message = error.message;
100
+ executionLog.error_stack = error.stack;
101
+ await this.executionLogRepository.save(executionLog);
102
+ throw error;
103
+ }
104
+ }
105
+ async executeWorkflowActions(schedule, jobData) {
106
+ const result = {
107
+ totalRecords: 0,
108
+ processedRecords: 0,
109
+ successfulRecords: 0,
110
+ failedRecords: 0,
111
+ errors: [],
112
+ };
113
+ const resultData = await this.scheduleHandlerService.handleScheduledWorkflow(jobData.workflowId, jobData);
114
+ if (!schedule.actions || schedule.actions.length === 0) {
115
+ this.logger.warn(`No actions defined for schedule: ${schedule.id}`);
116
+ return result;
117
+ }
118
+ for (const action of schedule.actions) {
119
+ try {
120
+ const actionResult = await this.executeAction(action, jobData);
121
+ result.totalRecords += actionResult.totalRecords;
122
+ result.processedRecords += actionResult.processedRecords;
123
+ result.successfulRecords += actionResult.successfulRecords;
124
+ result.failedRecords += actionResult.failedRecords;
125
+ result.errors.push(...actionResult.errors);
126
+ }
127
+ catch (error) {
128
+ this.logger.error(`Action execution failed: actionType=${action.actionType}, error=${error.message}`);
129
+ result.failedRecords += 1;
130
+ result.errors.push({
131
+ error: `Action ${action.actionType} failed: ${error.message}`,
132
+ });
133
+ }
134
+ }
135
+ return resultData;
136
+ }
137
+ async executeAction(action, jobData) {
138
+ this.logger.log(`🚀 Executing scheduled action: ${action.actionType}`);
139
+ try {
140
+ const { workflowId, loggedInUser } = jobData;
141
+ const result = await this.scheduleHandlerService.handleScheduledWorkflow(workflowId, loggedInUser);
142
+ this.logger.log(`✅ Scheduled workflow ${workflowId} executed successfully`);
143
+ return {
144
+ totalRecords: result?.length || 0,
145
+ processedRecords: result?.length || 0,
146
+ successfulRecords: result?.length || 0,
147
+ failedRecords: 0,
148
+ errors: [],
149
+ };
150
+ }
151
+ catch (error) {
152
+ this.logger.error(`🔥 Error executing scheduled workflow action: ${error.message}`, error.stack);
153
+ return {
154
+ totalRecords: 0,
155
+ processedRecords: 0,
156
+ successfulRecords: 0,
157
+ failedRecords: 1,
158
+ errors: [{ error: error.message }],
159
+ };
160
+ }
161
+ }
162
+ async executeSendEmailAction(action, jobData) {
163
+ const result = {
164
+ totalRecords: 0,
165
+ processedRecords: 0,
166
+ successfulRecords: 0,
167
+ failedRecords: 0,
168
+ errors: [],
169
+ };
170
+ try {
171
+ const records = await this.getTargetRecords(action.targetEntityType, action.filterCriteria, jobData);
172
+ result.totalRecords = records.length;
173
+ const batches = this.chunkArray(records, schedule_constants_1.DEFAULT_BATCH_SIZE);
174
+ for (const batch of batches) {
175
+ for (const record of batch) {
176
+ try {
177
+ result.processedRecords += 1;
178
+ result.successfulRecords += 1;
179
+ }
180
+ catch (error) {
181
+ result.processedRecords += 1;
182
+ result.failedRecords += 1;
183
+ result.errors.push({
184
+ recordId: record.id,
185
+ error: error.message,
186
+ });
187
+ }
188
+ }
189
+ }
190
+ }
191
+ catch (error) {
192
+ throw new Error(`Send email action failed: ${error.message}`);
193
+ }
194
+ return result;
195
+ }
196
+ async executeUpdateRecordsAction(action, jobData) {
197
+ const result = {
198
+ totalRecords: 0,
199
+ processedRecords: 0,
200
+ successfulRecords: 0,
201
+ failedRecords: 0,
202
+ errors: [],
203
+ };
204
+ try {
205
+ const records = await this.getTargetRecords(action.targetEntityType, action.filterCriteria, jobData);
206
+ result.totalRecords = records.length;
207
+ const batches = this.chunkArray(records, schedule_constants_1.DEFAULT_BATCH_SIZE);
208
+ for (const batch of batches) {
209
+ const queryRunner = this.dataSource.createQueryRunner();
210
+ await queryRunner.connect();
211
+ await queryRunner.startTransaction();
212
+ try {
213
+ for (const record of batch) {
214
+ const updateFields = action.actionConfig.updateFields || {};
215
+ const updateValues = Object.keys(updateFields).map((key) => {
216
+ return `${key} = ?`;
217
+ });
218
+ const values = Object.values(updateFields);
219
+ if (updateValues.length > 0) {
220
+ const tableName = this.getTableNameForEntityType(action.targetEntityType);
221
+ await queryRunner.query(`UPDATE ${tableName} SET ${updateValues.join(', ')} WHERE id = ?`, [...values, record.id]);
222
+ }
223
+ result.processedRecords += 1;
224
+ result.successfulRecords += 1;
225
+ }
226
+ await queryRunner.commitTransaction();
227
+ }
228
+ catch (error) {
229
+ await queryRunner.rollbackTransaction();
230
+ result.failedRecords += batch.length;
231
+ result.errors.push({
232
+ error: `Batch update failed: ${error.message}`,
233
+ });
234
+ }
235
+ finally {
236
+ await queryRunner.release();
237
+ }
238
+ }
239
+ }
240
+ catch (error) {
241
+ throw new Error(`Update records action failed: ${error.message}`);
242
+ }
243
+ return result;
244
+ }
245
+ async executeCreateTaskAction(action, jobData) {
246
+ const result = {
247
+ totalRecords: 0,
248
+ processedRecords: 0,
249
+ successfulRecords: 0,
250
+ failedRecords: 0,
251
+ errors: [],
252
+ };
253
+ try {
254
+ const records = await this.getTargetRecords(action.targetEntityType, action.filterCriteria, jobData);
255
+ result.totalRecords = records.length;
256
+ const batches = this.chunkArray(records, schedule_constants_1.DEFAULT_BATCH_SIZE);
257
+ for (const batch of batches) {
258
+ for (const record of batch) {
259
+ try {
260
+ await this.dataSource.query(`INSERT INTO cr_wf_task (name, description, status, mapped_entity_id, mapped_entity_type,
261
+ organization_id, enterprise_id, created_by, created_date, entity_type)
262
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, NOW(), 'WFTK')`, [
263
+ action.actionConfig.taskName || 'Scheduled Task',
264
+ action.actionConfig.taskDescription || '',
265
+ 'PENDING',
266
+ record.id,
267
+ action.targetEntityType,
268
+ jobData.organizationId,
269
+ jobData.enterpriseId,
270
+ jobData.createdBy,
271
+ ]);
272
+ result.processedRecords += 1;
273
+ result.successfulRecords += 1;
274
+ }
275
+ catch (error) {
276
+ result.processedRecords += 1;
277
+ result.failedRecords += 1;
278
+ result.errors.push({
279
+ recordId: record.id,
280
+ error: error.message,
281
+ });
282
+ }
283
+ }
284
+ }
285
+ }
286
+ catch (error) {
287
+ throw new Error(`Create task action failed: ${error.message}`);
288
+ }
289
+ return result;
290
+ }
291
+ async executeSendNotificationAction(action, jobData) {
292
+ const result = {
293
+ totalRecords: 0,
294
+ processedRecords: 0,
295
+ successfulRecords: 0,
296
+ failedRecords: 0,
297
+ errors: [],
298
+ };
299
+ try {
300
+ const records = await this.getTargetRecords(action.targetEntityType, action.filterCriteria, jobData);
301
+ result.totalRecords = records.length;
302
+ const batches = this.chunkArray(records, schedule_constants_1.DEFAULT_BATCH_SIZE);
303
+ for (const batch of batches) {
304
+ for (const record of batch) {
305
+ try {
306
+ await this.dataSource.query(`INSERT INTO cr_notification (user_id, event_type, message, mapped_entity_id,
307
+ mapped_entity_type, is_read, organization_id, created_date, entity_type, status)
308
+ VALUES (?, ?, ?, ?, ?, 0, ?, NOW(), 'NOTF', 'ACTIVE')`, [
309
+ record.user_id || jobData.createdBy,
310
+ action.actionConfig.eventType || 'WORKFLOW_SCHEDULED',
311
+ action.actionConfig.message || 'Scheduled workflow executed',
312
+ record.id,
313
+ action.targetEntityType,
314
+ jobData.organizationId,
315
+ ]);
316
+ result.processedRecords += 1;
317
+ result.successfulRecords += 1;
318
+ }
319
+ catch (error) {
320
+ result.processedRecords += 1;
321
+ result.failedRecords += 1;
322
+ result.errors.push({
323
+ recordId: record.id,
324
+ error: error.message,
325
+ });
326
+ }
327
+ }
328
+ }
329
+ }
330
+ catch (error) {
331
+ throw new Error(`Send notification action failed: ${error.message}`);
332
+ }
333
+ return result;
334
+ }
335
+ async getTargetRecords(entityType, filterCriteria, jobData) {
336
+ const tableName = this.getTableNameForEntityType(entityType);
337
+ let whereClause = `organization_id = ${jobData.organizationId}`;
338
+ const params = [];
339
+ if (filterCriteria && Object.keys(filterCriteria).length > 0) {
340
+ Object.keys(filterCriteria).forEach((key) => {
341
+ whereClause += ` AND ${key} = ?`;
342
+ params.push(filterCriteria[key]);
343
+ });
344
+ }
345
+ const query = `SELECT * FROM ${tableName} WHERE ${whereClause}`;
346
+ const records = await this.dataSource.query(query, params);
347
+ return records;
348
+ }
349
+ getTableNameForEntityType(entityType) {
350
+ const entityTypeMap = {
351
+ USR: 'sso_user',
352
+ LEAD: 'cr_lead',
353
+ TASK: 'cr_wf_task',
354
+ };
355
+ return entityTypeMap[entityType] || 'unknown_table';
356
+ }
357
+ chunkArray(array, chunkSize) {
358
+ const chunks = [];
359
+ for (let i = 0; i < array.length; i += chunkSize) {
360
+ chunks.push(array.slice(i, i + chunkSize));
361
+ }
362
+ return chunks;
363
+ }
364
+ onActive(job) {
365
+ this.logger.log(`Processing job ${job.id} of type ${job.name} for schedule ${job.data.scheduleId}`);
366
+ }
367
+ onCompleted(job, result) {
368
+ this.logger.log(`Job ${job.id} completed for schedule ${job.data.scheduleId} with result: ${JSON.stringify(result)}`);
369
+ }
370
+ onFailed(job, error) {
371
+ this.logger.error(`Job ${job.id} failed for schedule ${job.data.scheduleId} with error: ${error.message}`, error.stack);
372
+ }
373
+ };
374
+ exports.ScheduleProcessor = ScheduleProcessor;
375
+ __decorate([
376
+ (0, bull_1.Process)(schedule_constants_1.EXECUTE_SCHEDULED_WORKFLOW_JOB),
377
+ __metadata("design:type", Function),
378
+ __metadata("design:paramtypes", [Object]),
379
+ __metadata("design:returntype", Promise)
380
+ ], ScheduleProcessor.prototype, "handleScheduledWorkflowExecution", null);
381
+ __decorate([
382
+ (0, bull_1.OnQueueActive)(),
383
+ __metadata("design:type", Function),
384
+ __metadata("design:paramtypes", [Object]),
385
+ __metadata("design:returntype", void 0)
386
+ ], ScheduleProcessor.prototype, "onActive", null);
387
+ __decorate([
388
+ (0, bull_1.OnQueueCompleted)(),
389
+ __metadata("design:type", Function),
390
+ __metadata("design:paramtypes", [Object, Object]),
391
+ __metadata("design:returntype", void 0)
392
+ ], ScheduleProcessor.prototype, "onCompleted", null);
393
+ __decorate([
394
+ (0, bull_1.OnQueueFailed)(),
395
+ __metadata("design:type", Function),
396
+ __metadata("design:paramtypes", [Object, Error]),
397
+ __metadata("design:returntype", void 0)
398
+ ], ScheduleProcessor.prototype, "onFailed", null);
399
+ exports.ScheduleProcessor = ScheduleProcessor = ScheduleProcessor_1 = __decorate([
400
+ (0, bull_1.Processor)(schedule_constants_1.WORKFLOW_SCHEDULE_QUEUE),
401
+ __param(0, (0, typeorm_1.InjectRepository)(scheduled_workflow_entity_1.ScheduledWorkflow)),
402
+ __param(1, (0, typeorm_1.InjectRepository)(workflow_execution_log_entity_1.WorkflowExecutionLog)),
403
+ __param(3, (0, common_1.Inject)('ScheduleHandlerService')),
404
+ __metadata("design:paramtypes", [typeorm_2.Repository,
405
+ typeorm_2.Repository,
406
+ typeorm_2.DataSource,
407
+ schedule_handler_service_1.ScheduleHandlerService])
408
+ ], ScheduleProcessor);
409
+ //# sourceMappingURL=schedule.processor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schedule.processor.js","sourceRoot":"","sources":["../../../../src/module/workflow-schedule/processors/schedule.processor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uCAAkG;AAClG,2CAA4D;AAE5D,6CAAmD;AACnD,qCAAiD;AACjD,qFAA0E;AAC1E,6FAAiF;AACjF,wEAayC;AAEzC,yGAAyG;AAOlG,IAAM,iBAAiB,yBAAvB,MAAM,iBAAiB;IAG5B,YAEE,2BAA2E,EAE3E,sBAAyE,EACxD,UAAsB,EAEzC,sBAA+D;QAL5C,gCAA2B,GAA3B,2BAA2B,CAA+B;QAE1D,2BAAsB,GAAtB,sBAAsB,CAAkC;QACxD,eAAU,GAAV,UAAU,CAAY;QAExB,2BAAsB,GAAtB,sBAAsB,CAAwB;QAT9C,WAAM,GAAG,IAAI,eAAM,CAAC,mBAAiB,CAAC,IAAI,CAAC,CAAC;IAU1D,CAAC;IAMC,AAAN,KAAK,CAAC,gCAAgC,CAAC,GAAyB;QAC7D,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,cAAc,EAAE,WAAW,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BAAiB,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE,CACnF,CAAC;IACJ,CAAC;IAMD,WAAW,CAAC,GAAyB,EAAE,MAAW;QAChD,IAAI,CAAC,MAAM,CAAC,GAAG,CACb,OAAO,GAAG,CAAC,EAAE,2BAA2B,GAAG,CAAC,IAAI,CAAC,UAAU,iBAAiB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CACrG,CAAC;IACJ,CAAC;IAMD,QAAQ,CAAC,GAAyB,EAAE,KAAY;QAC9C,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,OAAO,GAAG,CAAC,EAAE,wBAAwB,GAAG,CAAC,IAAI,CAAC,UAAU,gBAAgB,KAAK,CAAC,OAAO,EAAE,EACvF,KAAK,CAAC,KAAK,CACZ,CAAC;IACJ,CAAC;CACF,CAAA;AA1iBY,8CAAiB;AAiBvB;IADJ,IAAA,cAAO,EAAC,mDAA8B,CAAC;;;;yEAsGvC;AA0ZD;IADC,IAAA,oBAAa,GAAE;;;;iDAKf;AAMD;IADC,IAAA,uBAAgB,GAAE;;;;oDAKlB;AAMD;IADC,IAAA,oBAAa,GAAE;;6CAC2B,KAAK;;iDAK/C;4BAziBU,iBAAiB;IAD7B,IAAA,gBAAS,EAAC,4CAAuB,CAAC;IAK9B,WAAA,IAAA,0BAAgB,EAAC,6CAAiB,CAAC,CAAA;IAEnC,WAAA,IAAA,0BAAgB,EAAC,oDAAoB,CAAC,CAAA;IAG1C,WAAA,IAAA,eAAM,EAAC,wBAAwB,CAAC,CAAA;qCAJiB,oBAAU;QAEf,oBAAU;QACtB,oBAAU;QAEA,iDAAsB;GAVpD,iBAAiB,CA0iB7B"}
@@ -0,0 +1,44 @@
1
+ import { Repository, DataSource } from 'typeorm';
2
+ import { Queue } from 'bull';
3
+ import { ScheduledWorkflow } from '../entities/scheduled-workflow.entity';
4
+ import { WorkflowExecutionLog } from '../entities/workflow-execution-log.entity';
5
+ import { CreateScheduleDto } from '../dto/create-schedule.dto';
6
+ import { UpdateScheduleDto } from '../dto/update-schedule.dto';
7
+ import { GetExecutionLogsDto } from '../dto/get-execution-logs.dto';
8
+ import { UserData } from '../../user/entity/user.entity';
9
+ import { ScheduleJobData } from '../interfaces/schedule-job-data.interface';
10
+ export declare class WorkflowScheduleService {
11
+ private readonly scheduledWorkflowRepository;
12
+ private readonly executionLogRepository;
13
+ private readonly scheduleQueue;
14
+ private readonly dataSource;
15
+ private readonly logger;
16
+ constructor(scheduledWorkflowRepository: Repository<ScheduledWorkflow>, executionLogRepository: Repository<WorkflowExecutionLog>, scheduleQueue: Queue<ScheduleJobData>, dataSource: DataSource);
17
+ createSchedule(createScheduleDto: CreateScheduleDto, loggedInUser: UserData): Promise<ScheduledWorkflow>;
18
+ updateSchedule(updateScheduleDto: UpdateScheduleDto, loggedInUser: UserData): Promise<ScheduledWorkflow>;
19
+ getScheduleById(scheduleId: number, loggedInUser: UserData): Promise<ScheduledWorkflow>;
20
+ getAllSchedules(page: number | undefined, size: number | undefined, filters: any | undefined, loggedInUser: UserData): Promise<{
21
+ data: ScheduledWorkflow[];
22
+ total: number;
23
+ page: number;
24
+ size: number;
25
+ }>;
26
+ pauseSchedule(scheduleId: number, loggedInUser: UserData): Promise<ScheduledWorkflow>;
27
+ resumeSchedule(scheduleId: number, loggedInUser: UserData): Promise<ScheduledWorkflow>;
28
+ deleteSchedule(scheduleId: number, loggedInUser: UserData): Promise<void>;
29
+ triggerManualExecution(scheduleId: number, loggedInUser: UserData, metadata?: Record<string, any>): Promise<{
30
+ executionLogId: number;
31
+ jobId: string;
32
+ }>;
33
+ getExecutionLogs(getExecutionLogsDto: GetExecutionLogsDto, loggedInUser: UserData): Promise<{
34
+ data: WorkflowExecutionLog[];
35
+ total: number;
36
+ page: number;
37
+ size: number;
38
+ }>;
39
+ getExecutionStats(scheduleId: number, loggedInUser: UserData): Promise<any>;
40
+ private scheduleJob;
41
+ private removeJob;
42
+ private validateCronExpression;
43
+ private calculateNextExecution;
44
+ }