rez_core 4.0.55 → 4.0.56
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/.vscode/extensions.json +5 -0
- package/dist/module/meta/controller/entity.controller.js.map +1 -1
- package/dist/module/workflow/service/action-template-mapping.service.js +30 -4
- package/dist/module/workflow/service/action-template-mapping.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/meta/controller/entity.controller.ts +40 -33
- package/src/module/workflow/service/action-template-mapping.service.ts +43 -6
package/package.json
CHANGED
|
@@ -143,26 +143,29 @@ export class EntityController {
|
|
|
143
143
|
) {
|
|
144
144
|
const loggedInUser = req.user.userData;
|
|
145
145
|
const appcode = loggedInUser.appcode;
|
|
146
|
-
|
|
146
|
+
|
|
147
147
|
if (!entityType) {
|
|
148
|
-
throw new BadRequestException(
|
|
148
|
+
throw new BadRequestException(
|
|
149
|
+
`Query parameter "entity_type" is required`,
|
|
150
|
+
);
|
|
149
151
|
}
|
|
150
|
-
|
|
152
|
+
|
|
151
153
|
const entityMaster = await this.entityMasterService.getEntityData(
|
|
152
154
|
entityType,
|
|
153
155
|
loggedInUser,
|
|
154
156
|
);
|
|
155
|
-
|
|
156
|
-
const entityService =
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
157
|
+
|
|
158
|
+
const entityService =
|
|
159
|
+
await this.reflectionHelper.getBean<EntityServiceImpl>(
|
|
160
|
+
entityMaster.entity_service,
|
|
161
|
+
);
|
|
162
|
+
|
|
160
163
|
if (!entityService) {
|
|
161
164
|
throw new InternalServerErrorException(
|
|
162
165
|
`No service found for entity_type "${entityType}"`,
|
|
163
166
|
);
|
|
164
167
|
}
|
|
165
|
-
|
|
168
|
+
|
|
166
169
|
// ✅ Create
|
|
167
170
|
const savedData = await entityService.createEntity(
|
|
168
171
|
entityData,
|
|
@@ -170,7 +173,7 @@ export class EntityController {
|
|
|
170
173
|
null,
|
|
171
174
|
appcode,
|
|
172
175
|
);
|
|
173
|
-
|
|
176
|
+
|
|
174
177
|
// ✅ Run workflow automation (no preUpdateStates for CREATE)
|
|
175
178
|
await this.workflowAutomationEngineService.handleEntityEvent(
|
|
176
179
|
entityType,
|
|
@@ -179,10 +182,10 @@ export class EntityController {
|
|
|
179
182
|
loggedInUser,
|
|
180
183
|
null,
|
|
181
184
|
);
|
|
182
|
-
|
|
185
|
+
|
|
183
186
|
return savedData;
|
|
184
187
|
}
|
|
185
|
-
|
|
188
|
+
|
|
186
189
|
@Post('update/:id')
|
|
187
190
|
@HttpCode(200)
|
|
188
191
|
async update(
|
|
@@ -192,26 +195,29 @@ export class EntityController {
|
|
|
192
195
|
@Req() req: Request & { user: any },
|
|
193
196
|
) {
|
|
194
197
|
const loggedInUser = req.user.userData;
|
|
195
|
-
|
|
198
|
+
|
|
196
199
|
if (!entityType) {
|
|
197
|
-
throw new BadRequestException(
|
|
200
|
+
throw new BadRequestException(
|
|
201
|
+
'Query parameter "entity_type" is required',
|
|
202
|
+
);
|
|
198
203
|
}
|
|
199
|
-
|
|
204
|
+
|
|
200
205
|
const entityMaster = await this.entityMasterService.getEntityData(
|
|
201
206
|
entityType,
|
|
202
207
|
loggedInUser,
|
|
203
208
|
);
|
|
204
|
-
|
|
205
|
-
const entityService =
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
+
|
|
210
|
+
const entityService =
|
|
211
|
+
await this.reflectionHelper.getBean<EntityServiceImpl>(
|
|
212
|
+
entityMaster.entity_service,
|
|
213
|
+
);
|
|
214
|
+
|
|
209
215
|
if (!entityService) {
|
|
210
216
|
throw new InternalServerErrorException(
|
|
211
217
|
`No service found for entity_type "${entityType}"`,
|
|
212
218
|
);
|
|
213
219
|
}
|
|
214
|
-
|
|
220
|
+
|
|
215
221
|
// 1️⃣ Get old state
|
|
216
222
|
const existingEntity = await entityService.getEntityData(
|
|
217
223
|
entityType,
|
|
@@ -221,26 +227,29 @@ export class EntityController {
|
|
|
221
227
|
if (!existingEntity) {
|
|
222
228
|
throw new NotFoundException(`No entity found for id "${id}"`);
|
|
223
229
|
}
|
|
224
|
-
|
|
230
|
+
|
|
225
231
|
// 2️⃣ Pre-evaluate criteria
|
|
226
|
-
const workflows = await this.workflowAutomationEngineService[
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
loggedInUser
|
|
230
|
-
);
|
|
232
|
+
const workflows = await this.workflowAutomationEngineService[
|
|
233
|
+
'wfService'
|
|
234
|
+
].getActiveRules(entityType, 'UPDATE', loggedInUser);
|
|
231
235
|
const preUpdateStates: Record<number, boolean> = {};
|
|
232
236
|
for (const wf of workflows) {
|
|
233
237
|
preUpdateStates[wf.id] = await this.workflowAutomationEngineService[
|
|
234
238
|
'filterEvaluator'
|
|
235
|
-
].evaluateCriteria(
|
|
239
|
+
].evaluateCriteria(
|
|
240
|
+
entityType,
|
|
241
|
+
wf.condition_filter_code,
|
|
242
|
+
existingEntity.id,
|
|
243
|
+
loggedInUser,
|
|
244
|
+
);
|
|
236
245
|
}
|
|
237
|
-
|
|
246
|
+
|
|
238
247
|
// 3️⃣ Update
|
|
239
248
|
const updatedData = await entityService.updateEntity(
|
|
240
249
|
entityData,
|
|
241
250
|
loggedInUser as UserData,
|
|
242
251
|
);
|
|
243
|
-
|
|
252
|
+
|
|
244
253
|
// 4️⃣ Run workflow automation (pass preUpdateStates)
|
|
245
254
|
await this.workflowAutomationEngineService.handleEntityEvent(
|
|
246
255
|
entityType,
|
|
@@ -249,11 +258,9 @@ export class EntityController {
|
|
|
249
258
|
loggedInUser,
|
|
250
259
|
preUpdateStates,
|
|
251
260
|
);
|
|
252
|
-
|
|
261
|
+
|
|
253
262
|
return updatedData;
|
|
254
263
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
264
|
|
|
258
265
|
@Post('delete/:id')
|
|
259
266
|
@HttpCode(200)
|
|
@@ -14,13 +14,50 @@ export class ActionTemplateMappingService extends EntityServiceImpl {
|
|
|
14
14
|
loggedInUser,
|
|
15
15
|
mode?: number,
|
|
16
16
|
) {
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
let stageAction = [] as any;
|
|
18
|
+
|
|
19
|
+
if (action_id != 0) {
|
|
20
|
+
stageAction = await this.dataSource.query(
|
|
21
|
+
`
|
|
19
22
|
SELECT id FROM frm_wf_stage_action_mapping
|
|
20
|
-
WHERE
|
|
23
|
+
WHERE action_id = ?
|
|
21
24
|
`,
|
|
22
|
-
|
|
23
|
-
|
|
25
|
+
[action_id],
|
|
26
|
+
);
|
|
27
|
+
} else {
|
|
28
|
+
// generic action
|
|
29
|
+
// get template by mode
|
|
30
|
+
|
|
31
|
+
let modeId = mode;
|
|
32
|
+
if (!modeId) {
|
|
33
|
+
const rows = await this.dataSource.query(
|
|
34
|
+
`
|
|
35
|
+
SELECT id
|
|
36
|
+
FROM frm_list_master_items
|
|
37
|
+
WHERE organization_id = ?
|
|
38
|
+
AND listtype = "MOD" AND code = ?
|
|
39
|
+
`,
|
|
40
|
+
[loggedInUser.organization_id, 'email'],
|
|
41
|
+
);
|
|
42
|
+
modeId = rows?.[0]?.id ?? 0;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const commTemplates = await this.dataSource.query(
|
|
46
|
+
`
|
|
47
|
+
SELECT code as value, name as label , id
|
|
48
|
+
FROM frm_wf_comm_template
|
|
49
|
+
WHERE mode = ? AND organization_id = ? AND level_type = ? AND level_id = ?
|
|
50
|
+
`,
|
|
51
|
+
[
|
|
52
|
+
modeId,
|
|
53
|
+
loggedInUser.organization_id,
|
|
54
|
+
loggedInUser.level_type,
|
|
55
|
+
loggedInUser.level_id,
|
|
56
|
+
],
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
return commTemplates;
|
|
60
|
+
}
|
|
24
61
|
if (!stageAction?.length) return [];
|
|
25
62
|
|
|
26
63
|
const stgActMappingId = stageAction[0].id;
|
|
@@ -49,7 +86,7 @@ export class ActionTemplateMappingService extends EntityServiceImpl {
|
|
|
49
86
|
|
|
50
87
|
const commTemplates = await this.dataSource.query(
|
|
51
88
|
`
|
|
52
|
-
SELECT
|
|
89
|
+
SELECT code as value, name as label , id
|
|
53
90
|
FROM frm_wf_comm_template
|
|
54
91
|
WHERE code IN (?) AND mode = ? AND organization_id = ? AND level_type = ? AND level_id = ?
|
|
55
92
|
`,
|