@platform-modules/civil-aviation-authority 2.3.295 → 2.3.296
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.
|
@@ -77,7 +77,6 @@ export type RequestApprovedAssignedWorkflowParams = {
|
|
|
77
77
|
employeeId: string | number;
|
|
78
78
|
assigneeLabel?: 'user' | 'technician';
|
|
79
79
|
};
|
|
80
|
-
/** Parse legacy English-only assignment comments used as workflow log suffixes. */
|
|
81
80
|
export declare function tryParseRequestAssignedComment(comment?: string | null): Omit<RequestApprovedAssignedWorkflowParams, 'roleArabicName'> | null;
|
|
82
81
|
/** Bilingual workflow content for approved assignment steps (HR, IT, Tender, etc.). */
|
|
83
82
|
export declare function buildRequestApprovedAssignedWorkflowFields(params: RequestApprovedAssignedWorkflowParams): BilingualText;
|
|
@@ -178,10 +178,19 @@ function buildSynchronizedWorkflowMessage(ctx) {
|
|
|
178
178
|
return actorEn
|
|
179
179
|
? renderSynchronizedWorkflowMessage('request_approval_pending_from', { name: actorEn }, { name: actorAr })
|
|
180
180
|
: workflowTemplate('request_approval_pending');
|
|
181
|
-
case 'approved':
|
|
181
|
+
case 'approved': {
|
|
182
|
+
const assignment = tryParseRequestAssignedComment(ctx.comment);
|
|
183
|
+
if (assignment) {
|
|
184
|
+
return buildRequestApprovedAssignedWorkflowFields({
|
|
185
|
+
...assignment,
|
|
186
|
+
roleName: ctx.roleName?.trim() || assignment.roleName,
|
|
187
|
+
roleArabicName: ctx.roleArabicName,
|
|
188
|
+
});
|
|
189
|
+
}
|
|
182
190
|
return actorEn
|
|
183
191
|
? renderSynchronizedWorkflowMessage('request_approved_by', { name: actorEn, comment: commentWf }, { name: actorAr, comment: commentWf })
|
|
184
192
|
: renderSynchronizedWorkflowMessage('request_approved', { comment: commentWf }, { comment: commentWf });
|
|
193
|
+
}
|
|
185
194
|
case 'rejected':
|
|
186
195
|
return actorEn
|
|
187
196
|
? renderSynchronizedWorkflowMessage('request_rejected_by', { name: actorEn, comment: commentWf }, { name: actorAr, comment: commentWf })
|
|
@@ -236,11 +245,11 @@ function buildSynchronizedChatMessage(ctx) {
|
|
|
236
245
|
}
|
|
237
246
|
}
|
|
238
247
|
/** Parse legacy English-only assignment comments used as workflow log suffixes. */
|
|
239
|
-
function
|
|
240
|
-
const
|
|
241
|
-
if (!
|
|
248
|
+
function parseRequestAssignedCommentText(text) {
|
|
249
|
+
const normalized = text.trim();
|
|
250
|
+
if (!normalized)
|
|
242
251
|
return null;
|
|
243
|
-
const technicianMatch =
|
|
252
|
+
const technicianMatch = normalized.match(/^request assigned to technician (.+?) by (.+?) \((.+?) - (.+?)\)$/i);
|
|
244
253
|
if (technicianMatch) {
|
|
245
254
|
return {
|
|
246
255
|
assignedUserName: technicianMatch[1].trim(),
|
|
@@ -250,7 +259,7 @@ function tryParseRequestAssignedComment(comment) {
|
|
|
250
259
|
assigneeLabel: 'technician',
|
|
251
260
|
};
|
|
252
261
|
}
|
|
253
|
-
const userMatch =
|
|
262
|
+
const userMatch = normalized.match(/^request assigned to (.+?) by (.+?) \((.+?) - (.+?)\)$/i);
|
|
254
263
|
if (userMatch) {
|
|
255
264
|
return {
|
|
256
265
|
assignedUserName: userMatch[1].trim(),
|
|
@@ -262,6 +271,36 @@ function tryParseRequestAssignedComment(comment) {
|
|
|
262
271
|
}
|
|
263
272
|
return null;
|
|
264
273
|
}
|
|
274
|
+
function tryParseRequestAssignedComment(comment) {
|
|
275
|
+
let text = comment?.trim();
|
|
276
|
+
if (!text)
|
|
277
|
+
return null;
|
|
278
|
+
if (text.startsWith(':')) {
|
|
279
|
+
text = text.replace(/^:\s*/, '').trim();
|
|
280
|
+
}
|
|
281
|
+
const direct = parseRequestAssignedCommentText(text);
|
|
282
|
+
if (direct)
|
|
283
|
+
return direct;
|
|
284
|
+
const colonIdx = text.indexOf(': ');
|
|
285
|
+
if (colonIdx >= 0) {
|
|
286
|
+
const afterColon = text.slice(colonIdx + 2).trim();
|
|
287
|
+
const parsedAfterColon = parseRequestAssignedCommentText(afterColon);
|
|
288
|
+
if (parsedAfterColon)
|
|
289
|
+
return parsedAfterColon;
|
|
290
|
+
}
|
|
291
|
+
const assignMatch = text.match(/request assigned to/i);
|
|
292
|
+
if (assignMatch && assignMatch.index != null && assignMatch.index >= 0) {
|
|
293
|
+
return parseRequestAssignedCommentText(text.slice(assignMatch.index).trim());
|
|
294
|
+
}
|
|
295
|
+
return null;
|
|
296
|
+
}
|
|
297
|
+
function buildAssignmentWorkflowFieldsFromActors(assignment, actors) {
|
|
298
|
+
return buildRequestApprovedAssignedWorkflowFields({
|
|
299
|
+
...assignment,
|
|
300
|
+
roleName: actors?.roleName?.trim() || assignment.roleName,
|
|
301
|
+
roleArabicName: actors?.roleArabicName ?? null,
|
|
302
|
+
});
|
|
303
|
+
}
|
|
265
304
|
/** Bilingual workflow content for approved assignment steps (HR, IT, Tender, etc.). */
|
|
266
305
|
function buildRequestApprovedAssignedWorkflowFields(params) {
|
|
267
306
|
const assignedUserEn = params.assignedUserName?.trim() || 'User';
|
|
@@ -286,7 +325,8 @@ function buildRequestApprovedAssignedWorkflowFields(params) {
|
|
|
286
325
|
}
|
|
287
326
|
/** Standard workflow log UPDATE fields for all CAA module repositories. */
|
|
288
327
|
function buildWorkflowLogUpdateFields(params) {
|
|
289
|
-
|
|
328
|
+
const isApprovedLike = params.approvalStatus === 'Approved' || params.approvalStatus === 'Assigned';
|
|
329
|
+
if (isApprovedLike) {
|
|
290
330
|
const assignment = tryParseRequestAssignedComment(params.comment);
|
|
291
331
|
if (assignment) {
|
|
292
332
|
const bilingual = buildRequestApprovedAssignedWorkflowFields({
|
|
@@ -303,7 +343,7 @@ function buildWorkflowLogUpdateFields(params) {
|
|
|
303
343
|
}
|
|
304
344
|
}
|
|
305
345
|
let action;
|
|
306
|
-
if (params.approvalStatus === 'Approved')
|
|
346
|
+
if (params.approvalStatus === 'Approved' || params.approvalStatus === 'Assigned')
|
|
307
347
|
action = 'approved';
|
|
308
348
|
else if (params.approvalStatus === 'Rejected')
|
|
309
349
|
action = 'rejected';
|
|
@@ -880,6 +920,10 @@ function resolveWorkflowContentAr(content, actors) {
|
|
|
880
920
|
if (content == null || content.trim() === '')
|
|
881
921
|
return null;
|
|
882
922
|
const normalized = content.trim();
|
|
923
|
+
const embeddedAssignment = tryParseRequestAssignedComment(normalized);
|
|
924
|
+
if (embeddedAssignment) {
|
|
925
|
+
return buildAssignmentWorkflowFieldsFromActors(embeddedAssignment, actors).ar;
|
|
926
|
+
}
|
|
883
927
|
for (const tpl of Object.values(WORKFLOW_TEMPLATES)) {
|
|
884
928
|
if (tpl.en === normalized || tpl.en.toLowerCase() === normalized.toLowerCase())
|
|
885
929
|
return tpl.ar;
|
|
@@ -896,6 +940,10 @@ function resolveWorkflowContentAr(content, actors) {
|
|
|
896
940
|
if (commentIdx > 0) {
|
|
897
941
|
const baseEn = normalized.slice(0, commentIdx).trim();
|
|
898
942
|
const commentText = normalized.slice(commentIdx + 2).trim();
|
|
943
|
+
const assignment = tryParseRequestAssignedComment(commentText);
|
|
944
|
+
if (assignment) {
|
|
945
|
+
return buildAssignmentWorkflowFieldsFromActors(assignment, actors).ar;
|
|
946
|
+
}
|
|
899
947
|
const commentSuffix = formatWorkflowCommentSuffix(commentText);
|
|
900
948
|
for (const tpl of Object.values(WORKFLOW_TEMPLATES)) {
|
|
901
949
|
if (!tpl.en.includes('{{comment}}'))
|
|
@@ -999,7 +1047,7 @@ function enrichWorkflowLog(log) {
|
|
|
999
1047
|
existingAr &&
|
|
1000
1048
|
resolvedAr &&
|
|
1001
1049
|
existingAr !== resolvedAr &&
|
|
1002
|
-
/
|
|
1050
|
+
(/request assigned to/i.test(content) || /request assigned to/i.test(existingAr))) {
|
|
1003
1051
|
content_ar = resolvedAr;
|
|
1004
1052
|
}
|
|
1005
1053
|
if (content &&
|
package/package.json
CHANGED
|
@@ -237,7 +237,15 @@ export function buildSynchronizedWorkflowMessage(ctx: WorkflowMessageContext): B
|
|
|
237
237
|
{ name: actorAr },
|
|
238
238
|
)
|
|
239
239
|
: workflowTemplate('request_approval_pending');
|
|
240
|
-
case 'approved':
|
|
240
|
+
case 'approved': {
|
|
241
|
+
const assignment = tryParseRequestAssignedComment(ctx.comment);
|
|
242
|
+
if (assignment) {
|
|
243
|
+
return buildRequestApprovedAssignedWorkflowFields({
|
|
244
|
+
...assignment,
|
|
245
|
+
roleName: ctx.roleName?.trim() || assignment.roleName,
|
|
246
|
+
roleArabicName: ctx.roleArabicName,
|
|
247
|
+
});
|
|
248
|
+
}
|
|
241
249
|
return actorEn
|
|
242
250
|
? renderSynchronizedWorkflowMessage(
|
|
243
251
|
'request_approved_by',
|
|
@@ -249,6 +257,7 @@ export function buildSynchronizedWorkflowMessage(ctx: WorkflowMessageContext): B
|
|
|
249
257
|
{ comment: commentWf },
|
|
250
258
|
{ comment: commentWf },
|
|
251
259
|
);
|
|
260
|
+
}
|
|
252
261
|
case 'rejected':
|
|
253
262
|
return actorEn
|
|
254
263
|
? renderSynchronizedWorkflowMessage(
|
|
@@ -354,14 +363,14 @@ export type RequestApprovedAssignedWorkflowParams = {
|
|
|
354
363
|
};
|
|
355
364
|
|
|
356
365
|
/** Parse legacy English-only assignment comments used as workflow log suffixes. */
|
|
357
|
-
|
|
358
|
-
|
|
366
|
+
function parseRequestAssignedCommentText(
|
|
367
|
+
text: string,
|
|
359
368
|
): Omit<RequestApprovedAssignedWorkflowParams, 'roleArabicName'> | null {
|
|
360
|
-
const
|
|
361
|
-
if (!
|
|
369
|
+
const normalized = text.trim();
|
|
370
|
+
if (!normalized) return null;
|
|
362
371
|
|
|
363
|
-
const technicianMatch =
|
|
364
|
-
/^
|
|
372
|
+
const technicianMatch = normalized.match(
|
|
373
|
+
/^request assigned to technician (.+?) by (.+?) \((.+?) - (.+?)\)$/i,
|
|
365
374
|
);
|
|
366
375
|
if (technicianMatch) {
|
|
367
376
|
return {
|
|
@@ -373,7 +382,7 @@ export function tryParseRequestAssignedComment(
|
|
|
373
382
|
};
|
|
374
383
|
}
|
|
375
384
|
|
|
376
|
-
const userMatch =
|
|
385
|
+
const userMatch = normalized.match(/^request assigned to (.+?) by (.+?) \((.+?) - (.+?)\)$/i);
|
|
377
386
|
if (userMatch) {
|
|
378
387
|
return {
|
|
379
388
|
assignedUserName: userMatch[1].trim(),
|
|
@@ -387,6 +396,45 @@ export function tryParseRequestAssignedComment(
|
|
|
387
396
|
return null;
|
|
388
397
|
}
|
|
389
398
|
|
|
399
|
+
export function tryParseRequestAssignedComment(
|
|
400
|
+
comment?: string | null,
|
|
401
|
+
): Omit<RequestApprovedAssignedWorkflowParams, 'roleArabicName'> | null {
|
|
402
|
+
let text = comment?.trim();
|
|
403
|
+
if (!text) return null;
|
|
404
|
+
|
|
405
|
+
if (text.startsWith(':')) {
|
|
406
|
+
text = text.replace(/^:\s*/, '').trim();
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
const direct = parseRequestAssignedCommentText(text);
|
|
410
|
+
if (direct) return direct;
|
|
411
|
+
|
|
412
|
+
const colonIdx = text.indexOf(': ');
|
|
413
|
+
if (colonIdx >= 0) {
|
|
414
|
+
const afterColon = text.slice(colonIdx + 2).trim();
|
|
415
|
+
const parsedAfterColon = parseRequestAssignedCommentText(afterColon);
|
|
416
|
+
if (parsedAfterColon) return parsedAfterColon;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
const assignMatch = text.match(/request assigned to/i);
|
|
420
|
+
if (assignMatch && assignMatch.index != null && assignMatch.index >= 0) {
|
|
421
|
+
return parseRequestAssignedCommentText(text.slice(assignMatch.index).trim());
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
return null;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
function buildAssignmentWorkflowFieldsFromActors(
|
|
428
|
+
assignment: Omit<RequestApprovedAssignedWorkflowParams, 'roleArabicName'>,
|
|
429
|
+
actors?: BilingualActorNames,
|
|
430
|
+
): BilingualText {
|
|
431
|
+
return buildRequestApprovedAssignedWorkflowFields({
|
|
432
|
+
...assignment,
|
|
433
|
+
roleName: actors?.roleName?.trim() || assignment.roleName,
|
|
434
|
+
roleArabicName: actors?.roleArabicName ?? null,
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
|
|
390
438
|
/** Bilingual workflow content for approved assignment steps (HR, IT, Tender, etc.). */
|
|
391
439
|
export function buildRequestApprovedAssignedWorkflowFields(
|
|
392
440
|
params: RequestApprovedAssignedWorkflowParams,
|
|
@@ -427,7 +475,10 @@ export function buildWorkflowLogUpdateFields(params: {
|
|
|
427
475
|
roleArabicName?: string | null;
|
|
428
476
|
comment?: string | null;
|
|
429
477
|
}): { content: string; content_ar: string; status: string; status_ar: string | null } {
|
|
430
|
-
|
|
478
|
+
const isApprovedLike =
|
|
479
|
+
params.approvalStatus === 'Approved' || params.approvalStatus === 'Assigned';
|
|
480
|
+
|
|
481
|
+
if (isApprovedLike) {
|
|
431
482
|
const assignment = tryParseRequestAssignedComment(params.comment);
|
|
432
483
|
if (assignment) {
|
|
433
484
|
const bilingual = buildRequestApprovedAssignedWorkflowFields({
|
|
@@ -445,7 +496,7 @@ export function buildWorkflowLogUpdateFields(params: {
|
|
|
445
496
|
}
|
|
446
497
|
|
|
447
498
|
let action: WorkflowMessageAction;
|
|
448
|
-
if (params.approvalStatus === 'Approved') action = 'approved';
|
|
499
|
+
if (params.approvalStatus === 'Approved' || params.approvalStatus === 'Assigned') action = 'approved';
|
|
449
500
|
else if (params.approvalStatus === 'Rejected') action = 'rejected';
|
|
450
501
|
else if (params.approvalStatus === 'Returned for Modification') action = 'returned_for_modification';
|
|
451
502
|
else action = 'approval_pending_update';
|
|
@@ -1368,6 +1419,11 @@ export function resolveWorkflowContentAr(
|
|
|
1368
1419
|
if (content == null || content.trim() === '') return null;
|
|
1369
1420
|
const normalized = content.trim();
|
|
1370
1421
|
|
|
1422
|
+
const embeddedAssignment = tryParseRequestAssignedComment(normalized);
|
|
1423
|
+
if (embeddedAssignment) {
|
|
1424
|
+
return buildAssignmentWorkflowFieldsFromActors(embeddedAssignment, actors).ar;
|
|
1425
|
+
}
|
|
1426
|
+
|
|
1371
1427
|
for (const tpl of Object.values(WORKFLOW_TEMPLATES)) {
|
|
1372
1428
|
if (tpl.en === normalized || tpl.en.toLowerCase() === normalized.toLowerCase()) return tpl.ar;
|
|
1373
1429
|
}
|
|
@@ -1383,6 +1439,10 @@ export function resolveWorkflowContentAr(
|
|
|
1383
1439
|
if (commentIdx > 0) {
|
|
1384
1440
|
const baseEn = normalized.slice(0, commentIdx).trim();
|
|
1385
1441
|
const commentText = normalized.slice(commentIdx + 2).trim();
|
|
1442
|
+
const assignment = tryParseRequestAssignedComment(commentText);
|
|
1443
|
+
if (assignment) {
|
|
1444
|
+
return buildAssignmentWorkflowFieldsFromActors(assignment, actors).ar;
|
|
1445
|
+
}
|
|
1386
1446
|
const commentSuffix = formatWorkflowCommentSuffix(commentText);
|
|
1387
1447
|
|
|
1388
1448
|
for (const tpl of Object.values(WORKFLOW_TEMPLATES)) {
|
|
@@ -1502,7 +1562,7 @@ export function enrichWorkflowLog(log: Record<string, unknown>): Record<string,
|
|
|
1502
1562
|
existingAr &&
|
|
1503
1563
|
resolvedAr &&
|
|
1504
1564
|
existingAr !== resolvedAr &&
|
|
1505
|
-
/
|
|
1565
|
+
(/request assigned to/i.test(content) || /request assigned to/i.test(existingAr))
|
|
1506
1566
|
) {
|
|
1507
1567
|
content_ar = resolvedAr;
|
|
1508
1568
|
}
|