@platform-modules/foreign-ministry 1.3.324 → 1.3.326

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/.env CHANGED
@@ -1,10 +1,10 @@
1
- # DB_HOST=localhost
2
- # DB_PORT=5432
3
- # DB_USER=postgres
4
- # DB_PASS=stevejobs
5
- # DB_NAME=FM
6
-
7
- DB_HOST = 164.52.222.169
8
- DB_USER = postgres_admin_user
9
- DB_PASS = pg_admin_user_pwd_caa_fa_$%^&OIukhjgcvbn
10
- DB_NAME=FM
1
+ # DB_HOST=localhost
2
+ # DB_PORT=5432
3
+ # DB_USER=postgres
4
+ # DB_PASS=stevejobs
5
+ # DB_NAME=FM
6
+
7
+ DB_HOST = 164.52.222.169
8
+ DB_USER = postgres_admin_user
9
+ DB_PASS = pg_admin_user_pwd_caa_fa_$%^&OIukhjgcvbn
10
+ DB_NAME=FM
@@ -0,0 +1,18 @@
1
+ import type { DataSource } from 'typeorm';
2
+ /** Parse authenticated user id from Fastify `request.meta`. */
3
+ export declare function parsePortalUserIdFromRequest(request: {
4
+ meta?: {
5
+ userId?: string | number;
6
+ };
7
+ }): number | null;
8
+ /**
9
+ * True when the user has an active Admin role in `user_role` (role.name = admin, case-insensitive).
10
+ * Same check as Reports_Service `isReportsAdmin`.
11
+ */
12
+ export declare function userHasPortalAdminRole(dataSource: DataSource, userId: number): Promise<boolean>;
13
+ /** Convenience: resolve user id from request and check admin role. */
14
+ export declare function isPortalAdminFromRequest(dataSource: DataSource, request: {
15
+ meta?: {
16
+ userId?: string | number;
17
+ };
18
+ }): Promise<boolean>;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parsePortalUserIdFromRequest = parsePortalUserIdFromRequest;
4
+ exports.userHasPortalAdminRole = userHasPortalAdminRole;
5
+ exports.isPortalAdminFromRequest = isPortalAdminFromRequest;
6
+ const role_1 = require("../models/role");
7
+ const userRolesModel_1 = require("../models/userRolesModel");
8
+ /** Parse authenticated user id from Fastify `request.meta`. */
9
+ function parsePortalUserIdFromRequest(request) {
10
+ const raw = request.meta?.userId;
11
+ if (raw == null || raw === '')
12
+ return null;
13
+ const n = Number(raw);
14
+ return Number.isFinite(n) && n > 0 ? n : null;
15
+ }
16
+ /**
17
+ * True when the user has an active Admin role in `user_role` (role.name = admin, case-insensitive).
18
+ * Same check as Reports_Service `isReportsAdmin`.
19
+ */
20
+ async function userHasPortalAdminRole(dataSource, userId) {
21
+ if (!dataSource?.isInitialized || !Number.isFinite(userId) || userId <= 0) {
22
+ return false;
23
+ }
24
+ return dataSource
25
+ .getRepository(userRolesModel_1.UserRole)
26
+ .createQueryBuilder('ur')
27
+ .innerJoin(role_1.Role, 'role', 'role.id = ur.role_id AND COALESCE(role.is_deleted, false) = false')
28
+ .where('ur.user_id = :userId', { userId })
29
+ .andWhere('ur.is_deleted = false')
30
+ .andWhere('ur.is_active = true')
31
+ .andWhere('LOWER(role.name) = :adminRole', { adminRole: 'admin' })
32
+ .getExists();
33
+ }
34
+ /** Convenience: resolve user id from request and check admin role. */
35
+ async function isPortalAdminFromRequest(dataSource, request) {
36
+ const userId = parsePortalUserIdFromRequest(request);
37
+ if (!userId)
38
+ return false;
39
+ return userHasPortalAdminRole(dataSource, userId);
40
+ }
@@ -0,0 +1,38 @@
1
+ import type { EntityManager } from 'typeorm';
2
+ export type FmServicesNotificationConfigRecipient = {
3
+ user_id: number;
4
+ department_id: number | null;
5
+ section_id: number | null;
6
+ role_id: number | null;
7
+ };
8
+ export type CollectFmServicesNotificationConfigRecipientsParams = {
9
+ serviceId: number | null | undefined;
10
+ subServiceId: number | null | undefined;
11
+ /** When 0, FINAL_APPROVAL configs apply; EVERY_APPROVAL always applies on approval. */
12
+ pendingCount: number;
13
+ logPrefix?: string;
14
+ };
15
+ export type SendFmServicesNotificationConfigNotificationsParams = {
16
+ serviceId: number | null | undefined;
17
+ subServiceId: number | null | undefined;
18
+ pendingCount: number;
19
+ requestId: number;
20
+ status: string;
21
+ approvalLevel: number;
22
+ shortProductName: string;
23
+ requestTypeKey: string;
24
+ routePath: string;
25
+ createdBy: string | number;
26
+ logPrefix?: string;
27
+ };
28
+ /**
29
+ * Resolves users from active `services_notification_configs` for service/sub-service.
30
+ * FINAL_APPROVAL only when pendingCount === 0; EVERY_APPROVAL on each approval step.
31
+ */
32
+ export declare function collectFmServicesNotificationConfigRecipients(manager: EntityManager, params: CollectFmServicesNotificationConfigRecipientsParams): Promise<FmServicesNotificationConfigRecipient[]>;
33
+ /**
34
+ * Inserts portal notifications for users resolved from `services_notification_configs`.
35
+ */
36
+ export declare function sendFmServicesNotificationConfigNotifications(manager: EntityManager, params: SendFmServicesNotificationConfigNotificationsParams): Promise<{
37
+ sentCount: number;
38
+ }>;
@@ -0,0 +1,181 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.collectFmServicesNotificationConfigRecipients = collectFmServicesNotificationConfigRecipients;
4
+ exports.sendFmServicesNotificationConfigNotifications = sendFmServicesNotificationConfigNotifications;
5
+ const NotificationModel_1 = require("../models/NotificationModel");
6
+ const ServicesNotificationConfigsModel_1 = require("../models/ServicesNotificationConfigsModel");
7
+ const userRolesModel_1 = require("../models/userRolesModel");
8
+ /**
9
+ * Resolves users from active `services_notification_configs` for service/sub-service.
10
+ * FINAL_APPROVAL only when pendingCount === 0; EVERY_APPROVAL on each approval step.
11
+ */
12
+ async function collectFmServicesNotificationConfigRecipients(manager, params) {
13
+ const { serviceId, subServiceId, pendingCount, logPrefix = '[FM notification config]' } = params;
14
+ if (!serviceId || !subServiceId)
15
+ return [];
16
+ const notificationConfigs = await manager
17
+ .getRepository(ServicesNotificationConfigsModel_1.ServicesNotificationConfigs)
18
+ .createQueryBuilder('SNC')
19
+ .where('SNC.service_id = :service_id', { service_id: serviceId })
20
+ .andWhere('SNC.sub_service_id = :sub_service_id', { sub_service_id: subServiceId })
21
+ .andWhere('SNC.is_deleted = :is_deleted', { is_deleted: false })
22
+ .andWhere('SNC.is_active = :is_active', { is_active: true })
23
+ .getMany();
24
+ if (!notificationConfigs?.length) {
25
+ console.warn(`${logPrefix} No notification configurations found for service ${serviceId} and sub_service ${subServiceId}`);
26
+ return [];
27
+ }
28
+ const seen = new Map();
29
+ for (const notificationConfig of notificationConfigs) {
30
+ if (notificationConfig.trigger === ServicesNotificationConfigsModel_1.ServicesNotificationTriggerType.FINAL_APPROVAL) {
31
+ if (pendingCount !== 0)
32
+ continue;
33
+ }
34
+ else if (notificationConfig.trigger === ServicesNotificationConfigsModel_1.ServicesNotificationTriggerType.EVERY_APPROVAL) {
35
+ // include on every approval step
36
+ }
37
+ else {
38
+ continue;
39
+ }
40
+ let usersQuery = manager
41
+ .getRepository(userRolesModel_1.UserRole)
42
+ .createQueryBuilder('user_role')
43
+ .where('user_role.department_id = :department_id', {
44
+ department_id: notificationConfig.department_id,
45
+ })
46
+ .andWhere('user_role.section_id = :section_id', { section_id: notificationConfig.section_id })
47
+ .andWhere('user_role.is_deleted = :is_deleted', { is_deleted: false });
48
+ if (notificationConfig.role_id != null && notificationConfig.role_id !== undefined) {
49
+ usersQuery = usersQuery.andWhere('user_role.role_id = :role_id', {
50
+ role_id: notificationConfig.role_id,
51
+ });
52
+ }
53
+ const userRoles = await usersQuery.getMany();
54
+ if (!userRoles?.length) {
55
+ console.warn(`${logPrefix} No users found for config (dept ${notificationConfig.department_id}${notificationConfig.section_id != null ? `, section ${notificationConfig.section_id}` : ''})`);
56
+ continue;
57
+ }
58
+ for (const ur of userRoles) {
59
+ const uid = ur.user_id;
60
+ if (seen.has(uid))
61
+ continue;
62
+ const userRole = await manager
63
+ .getRepository(userRolesModel_1.UserRole)
64
+ .createQueryBuilder('user_role')
65
+ .where('user_role.user_id = :userId', { userId: uid })
66
+ .andWhere('user_role.is_deleted = :is_deleted', { is_deleted: false })
67
+ .orderBy('user_role.created_at', 'ASC')
68
+ .getOne();
69
+ seen.set(uid, {
70
+ user_id: uid,
71
+ department_id: notificationConfig.department_id ?? null,
72
+ section_id: notificationConfig.section_id ?? null,
73
+ role_id: userRole?.role_id ?? null,
74
+ });
75
+ }
76
+ }
77
+ return Array.from(seen.values());
78
+ }
79
+ /**
80
+ * Inserts portal notifications for users resolved from `services_notification_configs`.
81
+ */
82
+ async function sendFmServicesNotificationConfigNotifications(manager, params) {
83
+ const { serviceId, subServiceId, pendingCount, requestId, status, approvalLevel, shortProductName, requestTypeKey, routePath, createdBy, logPrefix = '[FM notification config]', } = params;
84
+ if (!serviceId || !subServiceId)
85
+ return { sentCount: 0 };
86
+ const notificationConfigs = await manager
87
+ .getRepository(ServicesNotificationConfigsModel_1.ServicesNotificationConfigs)
88
+ .createQueryBuilder('SNC')
89
+ .where('SNC.service_id = :service_id', { service_id: serviceId })
90
+ .andWhere('SNC.sub_service_id = :sub_service_id', { sub_service_id: subServiceId })
91
+ .andWhere('SNC.is_deleted = :is_deleted', { is_deleted: false })
92
+ .andWhere('SNC.is_active = :is_active', { is_active: true })
93
+ .getMany();
94
+ if (!notificationConfigs?.length) {
95
+ console.warn(`${logPrefix} No notification configurations found for service ${serviceId} and sub_service ${subServiceId}`);
96
+ return { sentCount: 0 };
97
+ }
98
+ let sentCount = 0;
99
+ const createdByStr = String(createdBy ?? 'system');
100
+ for (const notificationConfig of notificationConfigs) {
101
+ if (notificationConfig.trigger === ServicesNotificationConfigsModel_1.ServicesNotificationTriggerType.FINAL_APPROVAL) {
102
+ if (pendingCount !== 0)
103
+ continue;
104
+ }
105
+ else if (notificationConfig.trigger === ServicesNotificationConfigsModel_1.ServicesNotificationTriggerType.EVERY_APPROVAL) {
106
+ // include on every approval step
107
+ }
108
+ else {
109
+ continue;
110
+ }
111
+ let usersQuery = manager
112
+ .getRepository(userRolesModel_1.UserRole)
113
+ .createQueryBuilder('user_role')
114
+ .where('user_role.department_id = :department_id', {
115
+ department_id: notificationConfig.department_id,
116
+ })
117
+ .andWhere('user_role.section_id = :section_id', { section_id: notificationConfig.section_id })
118
+ .andWhere('user_role.is_deleted = :is_deleted', { is_deleted: false });
119
+ if (notificationConfig.role_id != null && notificationConfig.role_id !== undefined) {
120
+ usersQuery = usersQuery.andWhere('user_role.role_id = :role_id', {
121
+ role_id: notificationConfig.role_id,
122
+ });
123
+ }
124
+ const userRoles = await usersQuery.getMany();
125
+ if (!userRoles?.length) {
126
+ console.warn(`${logPrefix} No users found for ${notificationConfig.trigger} config (dept ${notificationConfig.department_id}${notificationConfig.section_id != null ? `, section ${notificationConfig.section_id}` : ''})`);
127
+ continue;
128
+ }
129
+ const isEveryApproval = notificationConfig.trigger === ServicesNotificationConfigsModel_1.ServicesNotificationTriggerType.EVERY_APPROVAL;
130
+ const notificationTitle = isEveryApproval
131
+ ? `${shortProductName} Request ${status} at Level ${approvalLevel}`
132
+ : `${shortProductName} Request ${status}`;
133
+ const notificationData = `${shortProductName} request #${requestId} has been ${status}.`;
134
+ for (const ur of userRoles) {
135
+ const targetUserId = ur.user_id;
136
+ try {
137
+ const primaryUserRole = await manager
138
+ .getRepository(userRolesModel_1.UserRole)
139
+ .createQueryBuilder('user_role')
140
+ .where('user_role.user_id = :userId', { userId: targetUserId })
141
+ .andWhere('user_role.is_deleted = :is_deleted', { is_deleted: false })
142
+ .orderBy('user_role.created_at', 'ASC')
143
+ .getOne();
144
+ await manager
145
+ .createQueryBuilder()
146
+ .insert()
147
+ .into(NotificationModel_1.Notification)
148
+ .values({
149
+ type: NotificationModel_1.NotificationType.REQUEST_RAISED,
150
+ user_id: targetUserId,
151
+ role_id: primaryUserRole?.role_id ?? null,
152
+ department_id: notificationConfig.department_id ?? null,
153
+ section_id: notificationConfig.section_id ?? null,
154
+ request_id: requestId,
155
+ service_id: serviceId ?? null,
156
+ sub_service_id: subServiceId ?? null,
157
+ content: {
158
+ title: notificationTitle,
159
+ data: notificationData,
160
+ requestId,
161
+ requestType: requestTypeKey,
162
+ status,
163
+ level: approvalLevel,
164
+ timestamp: new Date().toISOString(),
165
+ },
166
+ is_read: false,
167
+ route_path: routePath,
168
+ created_by: createdByStr,
169
+ })
170
+ .execute();
171
+ sentCount += 1;
172
+ }
173
+ catch (userNotificationError) {
174
+ const message = userNotificationError instanceof Error ? userNotificationError.message : String(userNotificationError);
175
+ console.warn(`${logPrefix} Failed to send config notification to user ${targetUserId}:`, message);
176
+ }
177
+ }
178
+ console.info(`${logPrefix} Sent ${notificationConfig.trigger} config notifications to ${userRoles.length} user(s) in department ${notificationConfig.department_id}${notificationConfig.section_id != null ? `, section ${notificationConfig.section_id}` : ''}`);
179
+ }
180
+ return { sentCount };
181
+ }
package/dist/index.d.ts CHANGED
@@ -404,6 +404,9 @@ export * from './models/EmployeeMilestoneDetailsModel';
404
404
  export * from './models/MissionTravelPassportExpiryNotificationConfigModel';
405
405
  export * from './models/ServicesNotificationConfigsModel';
406
406
  export { ServicesNotificationTriggerType } from './models/ServicesNotificationConfigsModel';
407
+ export { collectFmServicesNotificationConfigRecipients, sendFmServicesNotificationConfigNotifications, } from './helpers/services-notification-config.helper';
408
+ export { parsePortalUserIdFromRequest, userHasPortalAdminRole, isPortalAdminFromRequest, } from './helpers/admin-auth.helper';
409
+ export type { FmServicesNotificationConfigRecipient, CollectFmServicesNotificationConfigRecipientsParams, SendFmServicesNotificationConfigNotificationsParams, } from './helpers/services-notification-config.helper';
407
410
  export * from './models/MoodleUsersModel';
408
411
  export { EvaluationEligibilitySetting, EvaluationEligibilitySettingEmployee, } from './models/EvaluationEligibilitySettingModel';
409
412
  export { isEvaluationEligibilityWindowOpen, parseEvaluationEndDay, parseMonthRange, } from './helpers/evaluation-eligibility.utils';
package/dist/index.js CHANGED
@@ -14,9 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.EvaluationEligibilitySetting = exports.ServicesNotificationTriggerType = exports.AppointmentWorkFlowStatus = exports.AppointmentMessageType = exports.AppointmentAttendeeStatus = exports.AppointmentApprovalStatus = exports.AppointmentAttendees = exports.AppointmentWorkFlow = exports.AppointmentRequestChat = exports.AppointmentRequestAttachment = exports.AppointmentApprovalDetails = exports.AppointmentRequestStatus = exports.AppointmentRequests = exports.TravelClass = exports.MissionTravelWorkFlowStatus = exports.MissionTravelApprovalStatus = exports.AllowanceRatio = exports.DecisionType = exports.MissionType = exports.MissionTravelStatus = exports.GatePassMessageType = exports.GatePassWorkFlowStatus = exports.GatePassApprovalStatus = exports.GatePassType = exports.GatePassRequestStatus = exports.SecurityDeptMessageType = exports.SecurityDeptAccessType = exports.SecurityDeptRequestStatus = exports.RetiredCardMessageType = exports.RetiredCardWorkFlowStatus = exports.RetiredCardApprovalStatus = exports.RetiredCardAccessType = exports.RetiredCardRequestStatus = exports.TitleCategory = exports.ProfileUpdateRequestStatus = exports.StayAfterHoursTransactionStatus = exports.StayAfterHoursTransaction = exports.StayAfterHoursBalance = exports.EarlyCheckoutTransactionStatus = exports.EarlyCheckoutTransaction = exports.EarlyCheckoutFrequency = exports.EarlyCheckoutConfiguration = exports.EarlyCheckoutBalance = exports.LeaveTransactionStatus = exports.LeaveTransaction = exports.LeaveConfigurationGrades = exports.enumFrequency = exports.LeaveConfiguration = exports.ParcelDepartmentCategory = exports.RegisterCandidateExperienceActivity = void 0;
18
- exports.InnovativeEmployeeNominationWorkFlow = exports.InnovativeEmployeeNominationApprovalStatus = exports.InnovativeEmployeeNominationApprovalDetails = exports.InnovativeEmployeeNominationRequestStatus = exports.InnovativeEmployeeNominationRequests = exports.InitiatorEmployeeNominationRequestAttachment = exports.InitiatorEmployeeNominationMessageType = exports.InitiatorEmployeeNominationRequestChat = exports.InitiatorEmployeeNominationWorkFlowStatus = exports.InitiatorEmployeeNominationWorkFlow = exports.InitiatorEmployeeNominationApprovalStatus = exports.InitiatorEmployeeNominationApprovalDetails = exports.InitiatorInitiativeType = exports.InitiatorEmployeeNominationRequestStatus = exports.InitiatorEmployeeNominationRequests = exports.IpeGrievanceRequestAttachment = exports.IpeGrievanceMessageType = exports.IpeGrievanceRequestChat = exports.IpeGrievanceWorkFlowStatus = exports.IpeGrievanceWorkFlow = exports.IpeGrievanceApprovalStatus = exports.IpeGrievanceApprovalDetails = exports.IpeGrievancePeriodRating = exports.IpeGrievanceExemptionReason = exports.IpeGrievancePeriodType = exports.IpeGrievanceFinalEvaluationResult = exports.IpeGrievanceRequestStatus = exports.IpeGrievanceRequests = exports.EmployeeEvaluationRequestAttachment = exports.EmployeeEvaluationMessageType = exports.EmployeeEvaluationRequestChat = exports.EmployeeEvaluationWorkFlowStatus = exports.EmployeeEvaluationWorkFlow = exports.EmployeeEvaluationApprovalStatus = exports.EmployeeEvaluationApprovalDetails = exports.EmployeeEvaluationPersonScore = exports.EmployeeEvaluationAnswers = exports.EmployeeEvaluationUsFeedback = exports.EmployeeEvaluation = exports.EmployeeEvaluationRoutingBucket = exports.EmployeeEvaluationRequestStatus = exports.EmployeeEvaluationRequests = exports.persistEmployeeEvaluationScores = exports.resolveMaxEmployeesPerRequest = exports.normalizeEmployeeSubmissions = exports.DEFAULT_MAX_EMPLOYEES_PER_REQUEST = exports.parseMonthRange = exports.parseEvaluationEndDay = exports.isEvaluationEligibilityWindowOpen = exports.EvaluationEligibilitySettingEmployee = void 0;
19
- exports.EvaluationFormQuestionType = exports.EvaluationFormQuestion = exports.EvaluationFormSection = exports.EvaluationFormType = exports.EvaluationForm = exports.EmbassyEvaluationRequestAttachment = exports.EmbassyEvaluationMessageType = exports.EmbassyEvaluationRequestChat = exports.EmbassyEvaluationWorkFlowStatus = exports.EmbassyEvaluationWorkFlow = exports.EmbassyEvaluationApprovalStatus = exports.EmbassyEvaluationApprovalDetails = exports.EmbassyEvaluationRequestStatus = exports.EmbassyEvaluationRequests = exports.EmbassyEvaluationResponse = exports.EmbassyEvaluationAssignmentStatus = exports.EmbassyEvaluationAssignment = exports.EmbassyEvaluationCycleStatus = exports.EmbassyEvaluationCycle = exports.EmployeeOfMonthSupportNominationRequestAttachment = exports.EmployeeOfMonthSupportNominationMessageType = exports.EmployeeOfMonthSupportNominationRequestChat = exports.EmployeeOfMonthSupportNominationWorkFlowStatus = exports.EmployeeOfMonthSupportNominationWorkFlow = exports.EmployeeOfMonthSupportNominationApprovalStatus = exports.EmployeeOfMonthSupportNominationApprovalDetails = exports.EmployeeOfMonthSupportNominationRequestStatus = exports.EmployeeOfMonthSupportNominationRequests = exports.EmployeeOfMonthNominationRequestAttachment = exports.EmployeeOfMonthNominationMessageType = exports.EmployeeOfMonthNominationRequestChat = exports.EmployeeOfMonthNominationWorkFlowStatus = exports.EmployeeOfMonthNominationWorkFlow = exports.EmployeeOfMonthNominationApprovalStatus = exports.EmployeeOfMonthNominationApprovalDetails = exports.EmployeeOfMonthNominationRequestStatus = exports.EmployeeOfMonthNominationRequests = exports.InnovativeEmployeeNominationRequestAttachment = exports.InnovativeEmployeeNominationMessageType = exports.InnovativeEmployeeNominationRequestChat = exports.InnovativeEmployeeNominationWorkFlowStatus = void 0;
17
+ exports.collectFmServicesNotificationConfigRecipients = exports.ServicesNotificationTriggerType = exports.AppointmentWorkFlowStatus = exports.AppointmentMessageType = exports.AppointmentAttendeeStatus = exports.AppointmentApprovalStatus = exports.AppointmentAttendees = exports.AppointmentWorkFlow = exports.AppointmentRequestChat = exports.AppointmentRequestAttachment = exports.AppointmentApprovalDetails = exports.AppointmentRequestStatus = exports.AppointmentRequests = exports.TravelClass = exports.MissionTravelWorkFlowStatus = exports.MissionTravelApprovalStatus = exports.AllowanceRatio = exports.DecisionType = exports.MissionType = exports.MissionTravelStatus = exports.GatePassMessageType = exports.GatePassWorkFlowStatus = exports.GatePassApprovalStatus = exports.GatePassType = exports.GatePassRequestStatus = exports.SecurityDeptMessageType = exports.SecurityDeptAccessType = exports.SecurityDeptRequestStatus = exports.RetiredCardMessageType = exports.RetiredCardWorkFlowStatus = exports.RetiredCardApprovalStatus = exports.RetiredCardAccessType = exports.RetiredCardRequestStatus = exports.TitleCategory = exports.ProfileUpdateRequestStatus = exports.StayAfterHoursTransactionStatus = exports.StayAfterHoursTransaction = exports.StayAfterHoursBalance = exports.EarlyCheckoutTransactionStatus = exports.EarlyCheckoutTransaction = exports.EarlyCheckoutFrequency = exports.EarlyCheckoutConfiguration = exports.EarlyCheckoutBalance = exports.LeaveTransactionStatus = exports.LeaveTransaction = exports.LeaveConfigurationGrades = exports.enumFrequency = exports.LeaveConfiguration = exports.ParcelDepartmentCategory = exports.RegisterCandidateExperienceActivity = void 0;
18
+ exports.InitiatorEmployeeNominationRequestAttachment = exports.InitiatorEmployeeNominationMessageType = exports.InitiatorEmployeeNominationRequestChat = exports.InitiatorEmployeeNominationWorkFlowStatus = exports.InitiatorEmployeeNominationWorkFlow = exports.InitiatorEmployeeNominationApprovalStatus = exports.InitiatorEmployeeNominationApprovalDetails = exports.InitiatorInitiativeType = exports.InitiatorEmployeeNominationRequestStatus = exports.InitiatorEmployeeNominationRequests = exports.IpeGrievanceRequestAttachment = exports.IpeGrievanceMessageType = exports.IpeGrievanceRequestChat = exports.IpeGrievanceWorkFlowStatus = exports.IpeGrievanceWorkFlow = exports.IpeGrievanceApprovalStatus = exports.IpeGrievanceApprovalDetails = exports.IpeGrievancePeriodRating = exports.IpeGrievanceExemptionReason = exports.IpeGrievancePeriodType = exports.IpeGrievanceFinalEvaluationResult = exports.IpeGrievanceRequestStatus = exports.IpeGrievanceRequests = exports.EmployeeEvaluationRequestAttachment = exports.EmployeeEvaluationMessageType = exports.EmployeeEvaluationRequestChat = exports.EmployeeEvaluationWorkFlowStatus = exports.EmployeeEvaluationWorkFlow = exports.EmployeeEvaluationApprovalStatus = exports.EmployeeEvaluationApprovalDetails = exports.EmployeeEvaluationPersonScore = exports.EmployeeEvaluationAnswers = exports.EmployeeEvaluationUsFeedback = exports.EmployeeEvaluation = exports.EmployeeEvaluationRoutingBucket = exports.EmployeeEvaluationRequestStatus = exports.EmployeeEvaluationRequests = exports.persistEmployeeEvaluationScores = exports.resolveMaxEmployeesPerRequest = exports.normalizeEmployeeSubmissions = exports.DEFAULT_MAX_EMPLOYEES_PER_REQUEST = exports.parseMonthRange = exports.parseEvaluationEndDay = exports.isEvaluationEligibilityWindowOpen = exports.EvaluationEligibilitySettingEmployee = exports.EvaluationEligibilitySetting = exports.isPortalAdminFromRequest = exports.userHasPortalAdminRole = exports.parsePortalUserIdFromRequest = exports.sendFmServicesNotificationConfigNotifications = void 0;
19
+ exports.EvaluationFormQuestionType = exports.EvaluationFormQuestion = exports.EvaluationFormSection = exports.EvaluationFormType = exports.EvaluationForm = exports.EmbassyEvaluationRequestAttachment = exports.EmbassyEvaluationMessageType = exports.EmbassyEvaluationRequestChat = exports.EmbassyEvaluationWorkFlowStatus = exports.EmbassyEvaluationWorkFlow = exports.EmbassyEvaluationApprovalStatus = exports.EmbassyEvaluationApprovalDetails = exports.EmbassyEvaluationRequestStatus = exports.EmbassyEvaluationRequests = exports.EmbassyEvaluationResponse = exports.EmbassyEvaluationAssignmentStatus = exports.EmbassyEvaluationAssignment = exports.EmbassyEvaluationCycleStatus = exports.EmbassyEvaluationCycle = exports.EmployeeOfMonthSupportNominationRequestAttachment = exports.EmployeeOfMonthSupportNominationMessageType = exports.EmployeeOfMonthSupportNominationRequestChat = exports.EmployeeOfMonthSupportNominationWorkFlowStatus = exports.EmployeeOfMonthSupportNominationWorkFlow = exports.EmployeeOfMonthSupportNominationApprovalStatus = exports.EmployeeOfMonthSupportNominationApprovalDetails = exports.EmployeeOfMonthSupportNominationRequestStatus = exports.EmployeeOfMonthSupportNominationRequests = exports.EmployeeOfMonthNominationRequestAttachment = exports.EmployeeOfMonthNominationMessageType = exports.EmployeeOfMonthNominationRequestChat = exports.EmployeeOfMonthNominationWorkFlowStatus = exports.EmployeeOfMonthNominationWorkFlow = exports.EmployeeOfMonthNominationApprovalStatus = exports.EmployeeOfMonthNominationApprovalDetails = exports.EmployeeOfMonthNominationRequestStatus = exports.EmployeeOfMonthNominationRequests = exports.InnovativeEmployeeNominationRequestAttachment = exports.InnovativeEmployeeNominationMessageType = exports.InnovativeEmployeeNominationRequestChat = exports.InnovativeEmployeeNominationWorkFlowStatus = exports.InnovativeEmployeeNominationWorkFlow = exports.InnovativeEmployeeNominationApprovalStatus = exports.InnovativeEmployeeNominationApprovalDetails = exports.InnovativeEmployeeNominationRequestStatus = exports.InnovativeEmployeeNominationRequests = void 0;
20
20
  __exportStar(require("./models/user"), exports);
21
21
  __exportStar(require("./models/role"), exports);
22
22
  __exportStar(require("./models/user-sessions"), exports);
@@ -490,6 +490,13 @@ __exportStar(require("./models/MissionTravelPassportExpiryNotificationConfigMode
490
490
  __exportStar(require("./models/ServicesNotificationConfigsModel"), exports);
491
491
  var ServicesNotificationConfigsModel_1 = require("./models/ServicesNotificationConfigsModel");
492
492
  Object.defineProperty(exports, "ServicesNotificationTriggerType", { enumerable: true, get: function () { return ServicesNotificationConfigsModel_1.ServicesNotificationTriggerType; } });
493
+ var services_notification_config_helper_1 = require("./helpers/services-notification-config.helper");
494
+ Object.defineProperty(exports, "collectFmServicesNotificationConfigRecipients", { enumerable: true, get: function () { return services_notification_config_helper_1.collectFmServicesNotificationConfigRecipients; } });
495
+ Object.defineProperty(exports, "sendFmServicesNotificationConfigNotifications", { enumerable: true, get: function () { return services_notification_config_helper_1.sendFmServicesNotificationConfigNotifications; } });
496
+ var admin_auth_helper_1 = require("./helpers/admin-auth.helper");
497
+ Object.defineProperty(exports, "parsePortalUserIdFromRequest", { enumerable: true, get: function () { return admin_auth_helper_1.parsePortalUserIdFromRequest; } });
498
+ Object.defineProperty(exports, "userHasPortalAdminRole", { enumerable: true, get: function () { return admin_auth_helper_1.userHasPortalAdminRole; } });
499
+ Object.defineProperty(exports, "isPortalAdminFromRequest", { enumerable: true, get: function () { return admin_auth_helper_1.isPortalAdminFromRequest; } });
493
500
  // Moodle Users Model
494
501
  __exportStar(require("./models/MoodleUsersModel"), exports);
495
502
  // Evaluation
@@ -11,53 +11,53 @@ var __metadata = (this && this.__metadata) || function (k, v) {
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.SlaApprovalsView = void 0;
13
13
  const typeorm_1 = require("typeorm");
14
- const VW_SLA_APPROVALS_SQL = `
15
- SELECT
16
- sa.id AS sla_approval_id,
17
- sa.source_approval_id,
18
- sa.request_id,
19
- sa.service_id AS service_id,
20
- sa.sub_service_id AS sub_service_id,
21
- TRIM(COALESCE(svc.name, ''))::TEXT AS service_name,
22
- TRIM(COALESCE(subsvc.sub_service_name, ''))::TEXT AS sub_service_name,
23
- sa.approver_role_id AS approval_role_id,
24
- TRIM(COALESCE(ar.name, ''))::TEXT AS approval_role_name,
25
- sa.department_id AS approval_department_id,
26
- TRIM(COALESCE(adpt.department_name, ''))::TEXT AS approval_department_name,
27
- sa.section_id AS approval_section_id,
28
- TRIM(COALESCE(asec.section_name, ''))::TEXT AS approval_section_name,
29
- sa.approval_status::TEXT AS approval_status,
30
- sr.status::TEXT AS request_status,
31
- sa.level AS level,
32
- sa.approver_user_id AS approver_user_id,
33
- TRIM(COALESCE(au.employee_name, ''))::TEXT AS approver_user_name,
34
- sa.delegate_user_id AS delegate_user_id,
35
- TRIM(COALESCE(du.employee_name, ''))::TEXT AS delegate_user_name,
36
- sa.approved_by AS approved_by,
37
- TRIM(COALESCE(ab.employee_name, ''))::TEXT AS approved_by_name,
38
- sa.comment::TEXT AS comment,
39
- sa.created_at AS created_at,
40
- sa.updated_at AS updated_at
41
- FROM sla_approval sa
42
- INNER JOIN sla_requests sr
43
- ON sr.request_id = sa.request_id AND COALESCE(sr.is_deleted, false) = false
44
- LEFT JOIN fm_services svc
45
- ON svc.id = sa.service_id AND COALESCE(svc.is_deleted, false) = false
46
- LEFT JOIN fm_sub_services subsvc
47
- ON subsvc.id = sa.sub_service_id AND COALESCE(subsvc.is_deleted, false) = false
48
- LEFT JOIN departments adpt
49
- ON adpt.id = sa.department_id AND COALESCE(adpt.is_deleted, false) = false
50
- LEFT JOIN sections asec
51
- ON asec.id = sa.section_id AND COALESCE(asec.is_deleted, false) = false
52
- LEFT JOIN role ar
53
- ON ar.id = sa.approver_role_id AND COALESCE(ar.is_deleted, false) = false
54
- LEFT JOIN users au
55
- ON au.id = sa.approver_user_id AND COALESCE(au.is_deleted, false) = false
56
- LEFT JOIN users du
57
- ON du.id = sa.delegate_user_id AND COALESCE(du.is_deleted, false) = false
58
- LEFT JOIN users ab
59
- ON ab.id = sa.approved_by AND COALESCE(ab.is_deleted, false) = false
60
- WHERE COALESCE(sa.is_deleted, false) = false
14
+ const VW_SLA_APPROVALS_SQL = `
15
+ SELECT
16
+ sa.id AS sla_approval_id,
17
+ sa.source_approval_id,
18
+ sa.request_id,
19
+ sa.service_id AS service_id,
20
+ sa.sub_service_id AS sub_service_id,
21
+ TRIM(COALESCE(svc.name, ''))::TEXT AS service_name,
22
+ TRIM(COALESCE(subsvc.sub_service_name, ''))::TEXT AS sub_service_name,
23
+ sa.approver_role_id AS approval_role_id,
24
+ TRIM(COALESCE(ar.name, ''))::TEXT AS approval_role_name,
25
+ sa.department_id AS approval_department_id,
26
+ TRIM(COALESCE(adpt.department_name, ''))::TEXT AS approval_department_name,
27
+ sa.section_id AS approval_section_id,
28
+ TRIM(COALESCE(asec.section_name, ''))::TEXT AS approval_section_name,
29
+ sa.approval_status::TEXT AS approval_status,
30
+ sr.status::TEXT AS request_status,
31
+ sa.level AS level,
32
+ sa.approver_user_id AS approver_user_id,
33
+ TRIM(COALESCE(au.employee_name, ''))::TEXT AS approver_user_name,
34
+ sa.delegate_user_id AS delegate_user_id,
35
+ TRIM(COALESCE(du.employee_name, ''))::TEXT AS delegate_user_name,
36
+ sa.approved_by AS approved_by,
37
+ TRIM(COALESCE(ab.employee_name, ''))::TEXT AS approved_by_name,
38
+ sa.comment::TEXT AS comment,
39
+ sa.created_at AS created_at,
40
+ sa.updated_at AS updated_at
41
+ FROM sla_approval sa
42
+ INNER JOIN sla_requests sr
43
+ ON sr.request_id = sa.request_id AND COALESCE(sr.is_deleted, false) = false
44
+ LEFT JOIN fm_services svc
45
+ ON svc.id = sa.service_id AND COALESCE(svc.is_deleted, false) = false
46
+ LEFT JOIN fm_sub_services subsvc
47
+ ON subsvc.id = sa.sub_service_id AND COALESCE(subsvc.is_deleted, false) = false
48
+ LEFT JOIN departments adpt
49
+ ON adpt.id = sa.department_id AND COALESCE(adpt.is_deleted, false) = false
50
+ LEFT JOIN sections asec
51
+ ON asec.id = sa.section_id AND COALESCE(asec.is_deleted, false) = false
52
+ LEFT JOIN role ar
53
+ ON ar.id = sa.approver_role_id AND COALESCE(ar.is_deleted, false) = false
54
+ LEFT JOIN users au
55
+ ON au.id = sa.approver_user_id AND COALESCE(au.is_deleted, false) = false
56
+ LEFT JOIN users du
57
+ ON du.id = sa.delegate_user_id AND COALESCE(du.is_deleted, false) = false
58
+ LEFT JOIN users ab
59
+ ON ab.id = sa.approved_by AND COALESCE(ab.is_deleted, false) = false
60
+ WHERE COALESCE(sa.is_deleted, false) = false
61
61
  `;
62
62
  /**
63
63
  * Read-only view for SLA approvals listings (TypeORM).
@@ -36,58 +36,58 @@ exports.SLA_MY_REQUESTS_REQUEST_OBJ_EXCLUDED_KEYS = [
36
36
  "sla_request",
37
37
  "sla_request_id",
38
38
  ];
39
- const VW_SLA_MY_REQUESTS_SQL = `
40
- SELECT
41
- sr.id AS sla_request_id,
42
- sr.user_id,
43
- sr.service_id AS service_id,
44
- sr.sub_service_id AS sub_service_id,
45
- TRIM(COALESCE(creator.employee_name, ''))::TEXT AS created_by,
46
- sr.created_at,
47
- TRIM(COALESCE(dept.department_name, ''))::TEXT AS req_user_department_id,
48
- TRIM(COALESCE(sec.section_name, ''))::TEXT AS req_user_section_id,
49
- TRIM(COALESCE(svc.name, ''))::TEXT AS service_name,
50
- TRIM(COALESCE(subsvc.sub_service_name, ''))::TEXT AS sub_service_name,
51
- sr.status::TEXT AS status,
52
- sr.request_id,
53
- (
54
- COALESCE(sr.request_obj, '{}'::jsonb)
55
- - 'id'
56
- - 'status'
57
- - 'role_id'
58
- - 'user_id'
59
- - 'createdBy'
60
- - 'created_at'
61
- - 'updated_by'
62
- - 'updated_at'
63
- - 'req_user_department_id'
64
- - 'workflow_execution_id'
65
- - 'department_id'
66
- - 'req_user_section_id'
67
- - 'service_type_id'
68
- - 'service_type'
69
- - 'created_by'
70
- - 'service_id'
71
- - 'sub_service_id'
72
- - 'attachments'
73
- - 'is_deleted'
74
- - 'sla_request'
75
- - 'sla_request_id'
76
- ) AS request_fields
77
- FROM sla_requests sr
78
- LEFT JOIN users creator
79
- ON sr.created_by ~ '^[0-9]+$'
80
- AND creator.id = sr.created_by::integer
81
- AND COALESCE(creator.is_deleted, false) = false
82
- LEFT JOIN departments dept
83
- ON dept.id = sr.req_user_department_id AND COALESCE(dept.is_deleted, false) = false
84
- LEFT JOIN sections sec
85
- ON sec.id = sr.req_user_section_id AND COALESCE(sec.is_deleted, false) = false
86
- LEFT JOIN fm_services svc
87
- ON svc.id = sr.service_id AND COALESCE(svc.is_deleted, false) = false
88
- LEFT JOIN fm_sub_services subsvc
89
- ON subsvc.id = sr.sub_service_id AND COALESCE(subsvc.is_deleted, false) = false
90
- WHERE COALESCE(sr.is_deleted, false) = false
39
+ const VW_SLA_MY_REQUESTS_SQL = `
40
+ SELECT
41
+ sr.id AS sla_request_id,
42
+ sr.user_id,
43
+ sr.service_id AS service_id,
44
+ sr.sub_service_id AS sub_service_id,
45
+ TRIM(COALESCE(creator.employee_name, ''))::TEXT AS created_by,
46
+ sr.created_at,
47
+ TRIM(COALESCE(dept.department_name, ''))::TEXT AS req_user_department_id,
48
+ TRIM(COALESCE(sec.section_name, ''))::TEXT AS req_user_section_id,
49
+ TRIM(COALESCE(svc.name, ''))::TEXT AS service_name,
50
+ TRIM(COALESCE(subsvc.sub_service_name, ''))::TEXT AS sub_service_name,
51
+ sr.status::TEXT AS status,
52
+ sr.request_id,
53
+ (
54
+ COALESCE(sr.request_obj, '{}'::jsonb)
55
+ - 'id'
56
+ - 'status'
57
+ - 'role_id'
58
+ - 'user_id'
59
+ - 'createdBy'
60
+ - 'created_at'
61
+ - 'updated_by'
62
+ - 'updated_at'
63
+ - 'req_user_department_id'
64
+ - 'workflow_execution_id'
65
+ - 'department_id'
66
+ - 'req_user_section_id'
67
+ - 'service_type_id'
68
+ - 'service_type'
69
+ - 'created_by'
70
+ - 'service_id'
71
+ - 'sub_service_id'
72
+ - 'attachments'
73
+ - 'is_deleted'
74
+ - 'sla_request'
75
+ - 'sla_request_id'
76
+ ) AS request_fields
77
+ FROM sla_requests sr
78
+ LEFT JOIN users creator
79
+ ON sr.created_by ~ '^[0-9]+$'
80
+ AND creator.id = sr.created_by::integer
81
+ AND COALESCE(creator.is_deleted, false) = false
82
+ LEFT JOIN departments dept
83
+ ON dept.id = sr.req_user_department_id AND COALESCE(dept.is_deleted, false) = false
84
+ LEFT JOIN sections sec
85
+ ON sec.id = sr.req_user_section_id AND COALESCE(sec.is_deleted, false) = false
86
+ LEFT JOIN fm_services svc
87
+ ON svc.id = sr.service_id AND COALESCE(svc.is_deleted, false) = false
88
+ LEFT JOIN fm_sub_services subsvc
89
+ ON subsvc.id = sr.sub_service_id AND COALESCE(subsvc.is_deleted, false) = false
90
+ WHERE COALESCE(sr.is_deleted, false) = false
91
91
  `;
92
92
  /**
93
93
  * Read-only view for SLA "my requests" listings.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platform-modules/foreign-ministry",
3
- "version": "1.3.324",
3
+ "version": "1.3.326",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "exports": {