rez_core 2.2.254 → 2.2.255
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/dist/module/workflow-automation/service/workflow-automation.service.d.ts +30 -0
- package/dist/module/workflow-automation/service/workflow-automation.service.js +50 -0
- package/dist/module/workflow-automation/service/workflow-automation.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/workflow-automation/service/workflow-automation.service.ts +87 -1
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Inject, Injectable, Logger } from '@nestjs/common';
|
|
1
|
+
import { Inject, Injectable, Logger, NotFoundException } from '@nestjs/common';
|
|
2
2
|
import { InjectRepository } from '@nestjs/typeorm';
|
|
3
3
|
import { DataSource, Repository } from 'typeorm';
|
|
4
4
|
import { WorkflowAutomation } from '../entity/workflow-automation.entity';
|
|
@@ -238,4 +238,90 @@ export class WorkflowAutomationService extends EntityServiceImpl {
|
|
|
238
238
|
|
|
239
239
|
return workflow;
|
|
240
240
|
}
|
|
241
|
+
|
|
242
|
+
async getEntityData(entity_type: string, id: number, loggedInUser: UserData) {
|
|
243
|
+
this.logger.log(`Fetching WorkflowAutomation by id=${id}`);
|
|
244
|
+
|
|
245
|
+
// 1. Get workflow automation entity
|
|
246
|
+
const workflowAutomation = await this.dataSource
|
|
247
|
+
.getRepository(WorkflowAutomation)
|
|
248
|
+
.findOne({
|
|
249
|
+
where: { id },
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
if (!workflowAutomation) {
|
|
253
|
+
throw new NotFoundException(`WorkflowAutomation not found with id=${id}`);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// 2. EVENT FILTER
|
|
257
|
+
let event: any = null;
|
|
258
|
+
if (workflowAutomation.condition_filter_code) {
|
|
259
|
+
const eventFilterMaster: any =
|
|
260
|
+
await this.savedFilterService.getEntityDataByCode(
|
|
261
|
+
ENTITYTYPE_SAVEDFILTERMASTER,
|
|
262
|
+
workflowAutomation.condition_filter_code,
|
|
263
|
+
loggedInUser,
|
|
264
|
+
);
|
|
265
|
+
|
|
266
|
+
if (eventFilterMaster) {
|
|
267
|
+
// 🔑 fetch filter details using mapped_filter_code
|
|
268
|
+
const eventFilterDetails =
|
|
269
|
+
await this.savedFilterService.getDetailsByCode(
|
|
270
|
+
eventFilterMaster.code,
|
|
271
|
+
);
|
|
272
|
+
|
|
273
|
+
event = {
|
|
274
|
+
eventFilterJson: eventFilterDetails ?? [],
|
|
275
|
+
triggerType: workflowAutomation.trigger_type,
|
|
276
|
+
event: workflowAutomation.trigger_event,
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// 3. CRITERIA FILTER
|
|
282
|
+
let criteria: any = null;
|
|
283
|
+
if (workflowAutomation.criteria_filter_code) {
|
|
284
|
+
const criteriaFilterMaster: any =
|
|
285
|
+
await this.savedFilterService.getEntityDataByCode(
|
|
286
|
+
ENTITYTYPE_SAVEDFILTERMASTER,
|
|
287
|
+
workflowAutomation.criteria_filter_code,
|
|
288
|
+
loggedInUser,
|
|
289
|
+
);
|
|
290
|
+
|
|
291
|
+
if (criteriaFilterMaster) {
|
|
292
|
+
// 🔑 fetch filter details using mapped_filter_code
|
|
293
|
+
const criteriaFilterDetails =
|
|
294
|
+
await this.savedFilterService.getDetailsByCode(
|
|
295
|
+
criteriaFilterMaster.code,
|
|
296
|
+
);
|
|
297
|
+
|
|
298
|
+
criteria = {
|
|
299
|
+
criteriaFilterJson: criteriaFilterDetails ?? [],
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// 4. ACTIONS
|
|
305
|
+
const actions = await this.dataSource
|
|
306
|
+
.getRepository(WorkflowAutomationActionEntity)
|
|
307
|
+
.find({
|
|
308
|
+
where: { workflow_automation_id: workflowAutomation.id },
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
const action = actions.map((a) => ({
|
|
312
|
+
actionCategory: a.entity_method,
|
|
313
|
+
actionPayload: a.payload,
|
|
314
|
+
}));
|
|
315
|
+
|
|
316
|
+
// 5. Final response
|
|
317
|
+
const response = {
|
|
318
|
+
...workflowAutomation,
|
|
319
|
+
event,
|
|
320
|
+
criteria,
|
|
321
|
+
action,
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
this.logger.debug(`Fetched WorkflowAutomation (id=${id}) with relations`);
|
|
325
|
+
return response;
|
|
326
|
+
}
|
|
241
327
|
}
|