@platform-modules/foreign-ministry 1.3.337 → 1.3.338
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/helpers/sla-request-status.helper.d.ts +3 -0
- package/dist/helpers/sla-request-status.helper.js +36 -0
- package/dist/models/EmbassyEvaluationDepartmentSettingModel.d.ts +14 -0
- package/dist/models/EmbassyEvaluationDepartmentSettingModel.js +56 -0
- package/dist/models/EvaluationMastersModel.d.ts +16 -0
- package/dist/models/EvaluationMastersModel.js +67 -0
- package/dist/models/EvaluationQuestionMasterModel.d.ts +10 -0
- package/dist/models/EvaluationQuestionMasterModel.js +42 -0
- package/dist/models/EvaluationSectionMasterModel.d.ts +7 -0
- package/dist/models/EvaluationSectionMasterModel.js +36 -0
- package/dist/models/EvaluationWorkflowModel.d.ts +60 -0
- package/dist/models/EvaluationWorkflowModel.js +215 -0
- package/dist/models/IneligibleForEvaluationModel.d.ts +8 -0
- package/dist/models/IneligibleForEvaluationModel.js +44 -0
- package/dist/models/LMSExternalEntityTrainedPersonModel.d.ts +2 -0
- package/dist/models/LMSExternalEntityTrainedPersonModel.js +8 -0
- package/dist/models/MissionTravelClassConfigModel.d.ts +10 -0
- package/dist/models/MissionTravelClassConfigModel.js +50 -0
- package/dist/models/MissionTravelPerdiemModel.d.ts +10 -0
- package/dist/models/MissionTravelPerdiemModel.js +54 -0
- package/dist/models/SlaApprovalsViewModel.js +47 -47
- package/dist/models/SlaMyRequestsViewModel.js +52 -52
- package/dist/models/UuidAuditModel.d.ts +9 -0
- package/dist/models/UuidAuditModel.js +41 -0
- package/package.json +1 -1
- package/scripts/check-column-types.js +38 -38
- package/scripts/check-service-tables.js +42 -42
- package/scripts/sync-sla-reports-sql.js +92 -95
- package/sql/add_lms_external_entity_trained_people_dates.sql +4 -0
- package/sql/sla-reports-sync.manifest.json +9 -9
- package/sql/sla_reports_admin_procedures.sql +304 -283
- package/sql/sla_reports_approvals_workbook.sql +383 -383
- package/sql/sla_reports_procedures.sql +886 -874
- package/sql/sla_requests_status_to_varchar.sql +28 -28
- package/sql/vw_sla_approvals.sql +108 -108
- package/sql/vw_sla_my_requests.sql +55 -55
- package/src/data-source.ts +686 -686
- package/src/helpers/employee-evaluation-request.utils.ts +178 -178
- package/src/helpers/evaluation-eligibility.utils.ts +126 -126
- package/src/index.ts +617 -617
- package/src/models/DiplomaticAcademyRequestModel.ts +80 -80
- package/src/models/DocumentationFileModel.ts +40 -40
- package/src/models/EmbassyEvaluationCycleModel.ts +45 -45
- package/src/models/EmbassyEvaluationRequestModel.ts +59 -59
- package/src/models/EmployeeEvaluationAnswerModel.ts +26 -26
- package/src/models/EvaluationEligibilitySettingModel.ts +51 -51
- package/src/models/EvaluationFormModel.ts +44 -44
- package/src/models/LMSExternalEntityTrainedPersonModel.ts +51 -45
- package/src/models/LanguageCourseRequestModel.ts +67 -67
- package/src/models/LeaveApprovalsModel.ts +66 -66
- package/src/models/LeaveConfigModel.ts +71 -71
- package/src/models/MissionTravelApprovalModel.ts +101 -101
- package/src/models/MissionTravelAttachmentModel.ts +56 -56
- package/src/models/MissionTravelChatModel.ts +52 -52
- package/src/models/MissionTravelPersonModel.ts +105 -105
- package/src/models/MissionTravelWorkflowModel.ts +54 -54
- package/src/models/ProjectContactsModel.ts +51 -51
- package/src/models/ProjectFaqModel.ts +36 -36
- package/src/models/ProjectInvoicesModel.ts +41 -41
- package/src/models/ProjectModel.ts +75 -75
- package/src/models/ProjectTasksModel.ts +75 -75
- package/src/models/ServiceSlaApprovalModel.ts +63 -63
- package/src/models/ServicesNotificationConfigsModel.ts +55 -55
- package/src/models/SlaApprovalsViewModel.ts +135 -135
- package/src/models/SlaMyRequestsViewModel.ts +172 -172
- package/src/models/SlaRequestModel.ts +57 -57
- package/src/sla-report-views.ts +3 -3
- package/dist/auth/authenticate-jwt-session.d.ts +0 -19
- package/dist/auth/authenticate-jwt-session.js +0 -35
- package/dist/auth/jwt-token.helper.d.ts +0 -18
- package/dist/auth/jwt-token.helper.js +0 -58
- package/dist/auth/user-session-validation.d.ts +0 -42
- package/dist/auth/user-session-validation.js +0 -95
- package/dist/i18n/workflow-chat-i18n.d.ts +0 -5
- package/dist/i18n/workflow-chat-i18n.js +0 -21
- package/dist/i18n/workflow-chat-i18n.json +0 -320
- package/dist/i18n/workflow-chat-message.builder.d.ts +0 -325
- package/dist/i18n/workflow-chat-message.builder.js +0 -924
|
@@ -1,172 +1,172 @@
|
|
|
1
|
-
import { ViewColumn, ViewEntity } from "typeorm";
|
|
2
|
-
import { SlaRequestStatus } from "./SlaRequestModel";
|
|
3
|
-
|
|
4
|
-
/** Top-level `request_obj` keys omitted from `request_fields` (see sql/vw_sla_my_requests.sql). */
|
|
5
|
-
export const SLA_MY_REQUESTS_REQUEST_OBJ_EXCLUDED_KEYS = [
|
|
6
|
-
"id",
|
|
7
|
-
"status",
|
|
8
|
-
"role_id",
|
|
9
|
-
"user_id",
|
|
10
|
-
"createdBy",
|
|
11
|
-
"created_at",
|
|
12
|
-
"updated_by",
|
|
13
|
-
"updated_at",
|
|
14
|
-
"req_user_department_id",
|
|
15
|
-
"workflow_execution_id",
|
|
16
|
-
"department_id",
|
|
17
|
-
"req_user_section_id",
|
|
18
|
-
"service_type_id",
|
|
19
|
-
"service_type",
|
|
20
|
-
"created_by",
|
|
21
|
-
"service_id",
|
|
22
|
-
"sub_service_id",
|
|
23
|
-
"attachments",
|
|
24
|
-
"is_deleted",
|
|
25
|
-
"sla_request",
|
|
26
|
-
"sla_request_id",
|
|
27
|
-
] as const;
|
|
28
|
-
|
|
29
|
-
const VW_SLA_MY_REQUESTS_SQL = `
|
|
30
|
-
SELECT
|
|
31
|
-
sr.id AS sla_request_id,
|
|
32
|
-
sr.user_id,
|
|
33
|
-
sr.service_id AS service_id,
|
|
34
|
-
sr.sub_service_id AS sub_service_id,
|
|
35
|
-
TRIM(COALESCE(creator.employee_name, ''))::TEXT AS created_by,
|
|
36
|
-
sr.created_at,
|
|
37
|
-
TRIM(COALESCE(dept.department_name, ''))::TEXT AS req_user_department_id,
|
|
38
|
-
TRIM(COALESCE(sec.section_name, ''))::TEXT AS req_user_section_id,
|
|
39
|
-
TRIM(COALESCE(svc.name, ''))::TEXT AS service_name,
|
|
40
|
-
TRIM(COALESCE(subsvc.sub_service_name, ''))::TEXT AS sub_service_name,
|
|
41
|
-
sr.status::TEXT AS status,
|
|
42
|
-
sr.request_id,
|
|
43
|
-
(
|
|
44
|
-
COALESCE(sr.request_obj, '{}'::jsonb)
|
|
45
|
-
- 'id'
|
|
46
|
-
- 'status'
|
|
47
|
-
- 'role_id'
|
|
48
|
-
- 'user_id'
|
|
49
|
-
- 'createdBy'
|
|
50
|
-
- 'created_at'
|
|
51
|
-
- 'updated_by'
|
|
52
|
-
- 'updated_at'
|
|
53
|
-
- 'req_user_department_id'
|
|
54
|
-
- 'workflow_execution_id'
|
|
55
|
-
- 'department_id'
|
|
56
|
-
- 'req_user_section_id'
|
|
57
|
-
- 'service_type_id'
|
|
58
|
-
- 'service_type'
|
|
59
|
-
- 'created_by'
|
|
60
|
-
- 'service_id'
|
|
61
|
-
- 'sub_service_id'
|
|
62
|
-
- 'attachments'
|
|
63
|
-
- 'is_deleted'
|
|
64
|
-
- 'sla_request'
|
|
65
|
-
- 'sla_request_id'
|
|
66
|
-
) AS request_fields
|
|
67
|
-
FROM sla_requests sr
|
|
68
|
-
LEFT JOIN users creator
|
|
69
|
-
ON sr.created_by ~ '^[0-9]+$'
|
|
70
|
-
AND creator.id = sr.created_by::integer
|
|
71
|
-
AND COALESCE(creator.is_deleted, false) = false
|
|
72
|
-
LEFT JOIN departments dept
|
|
73
|
-
ON dept.id = sr.req_user_department_id AND COALESCE(dept.is_deleted, false) = false
|
|
74
|
-
LEFT JOIN sections sec
|
|
75
|
-
ON sec.id = sr.req_user_section_id AND COALESCE(sec.is_deleted, false) = false
|
|
76
|
-
LEFT JOIN fm_services svc
|
|
77
|
-
ON svc.id = sr.service_id AND COALESCE(svc.is_deleted, false) = false
|
|
78
|
-
LEFT JOIN fm_sub_services subsvc
|
|
79
|
-
ON subsvc.id = sr.sub_service_id AND COALESCE(subsvc.is_deleted, false) = false
|
|
80
|
-
WHERE COALESCE(sr.is_deleted, false) = false
|
|
81
|
-
`;
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Read-only view for SLA "my requests" listings.
|
|
85
|
-
* Display-name columns reuse sla_requests field names; values come from joined lookup tables.
|
|
86
|
-
* Service-specific payload keys live in `request_fields` (filtered `request_obj`).
|
|
87
|
-
*/
|
|
88
|
-
@ViewEntity({
|
|
89
|
-
name: "vw_sla_my_requests",
|
|
90
|
-
expression: VW_SLA_MY_REQUESTS_SQL,
|
|
91
|
-
})
|
|
92
|
-
export class SlaMyRequestsView {
|
|
93
|
-
@ViewColumn()
|
|
94
|
-
sla_request_id: number;
|
|
95
|
-
|
|
96
|
-
/** Request owner (`sla_requests.user_id`) — filter with WHERE user_id = :userId for "my requests". */
|
|
97
|
-
@ViewColumn()
|
|
98
|
-
user_id: number;
|
|
99
|
-
|
|
100
|
-
/** Numeric fm_services.id used for filtering. */
|
|
101
|
-
@ViewColumn()
|
|
102
|
-
service_id: number;
|
|
103
|
-
|
|
104
|
-
/** Numeric fm_sub_services.id used for filtering. */
|
|
105
|
-
@ViewColumn()
|
|
106
|
-
sub_service_id: number;
|
|
107
|
-
|
|
108
|
-
@ViewColumn()
|
|
109
|
-
created_by: string;
|
|
110
|
-
|
|
111
|
-
@ViewColumn()
|
|
112
|
-
created_at: Date;
|
|
113
|
-
|
|
114
|
-
@ViewColumn()
|
|
115
|
-
req_user_department_id: string;
|
|
116
|
-
|
|
117
|
-
@ViewColumn()
|
|
118
|
-
req_user_section_id: string;
|
|
119
|
-
|
|
120
|
-
@ViewColumn()
|
|
121
|
-
service_name: string;
|
|
122
|
-
|
|
123
|
-
@ViewColumn()
|
|
124
|
-
sub_service_name: string;
|
|
125
|
-
|
|
126
|
-
@ViewColumn()
|
|
127
|
-
status: SlaRequestStatus | string;
|
|
128
|
-
|
|
129
|
-
@ViewColumn()
|
|
130
|
-
request_id: number;
|
|
131
|
-
|
|
132
|
-
/** Remaining `request_obj` keys after excluding workflow/common duplicates. */
|
|
133
|
-
@ViewColumn()
|
|
134
|
-
request_fields: Record<string, unknown>;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/** Flatten view row: fixed columns plus each entry in `request_fields`. */
|
|
138
|
-
export function flattenSlaMyRequestsViewRow(
|
|
139
|
-
row: SlaMyRequestsView
|
|
140
|
-
): Record<string, unknown> {
|
|
141
|
-
const {
|
|
142
|
-
sla_request_id,
|
|
143
|
-
user_id,
|
|
144
|
-
service_id,
|
|
145
|
-
sub_service_id,
|
|
146
|
-
created_by,
|
|
147
|
-
created_at,
|
|
148
|
-
req_user_department_id,
|
|
149
|
-
req_user_section_id,
|
|
150
|
-
service_name,
|
|
151
|
-
sub_service_name,
|
|
152
|
-
status,
|
|
153
|
-
request_id,
|
|
154
|
-
request_fields,
|
|
155
|
-
} = row;
|
|
156
|
-
|
|
157
|
-
return {
|
|
158
|
-
sla_request_id,
|
|
159
|
-
user_id,
|
|
160
|
-
service_id,
|
|
161
|
-
sub_service_id,
|
|
162
|
-
created_by,
|
|
163
|
-
created_at,
|
|
164
|
-
req_user_department_id,
|
|
165
|
-
req_user_section_id,
|
|
166
|
-
service_name,
|
|
167
|
-
sub_service_name,
|
|
168
|
-
status,
|
|
169
|
-
request_id,
|
|
170
|
-
...(request_fields ?? {}),
|
|
171
|
-
};
|
|
172
|
-
}
|
|
1
|
+
import { ViewColumn, ViewEntity } from "typeorm";
|
|
2
|
+
import { SlaRequestStatus } from "./SlaRequestModel";
|
|
3
|
+
|
|
4
|
+
/** Top-level `request_obj` keys omitted from `request_fields` (see sql/vw_sla_my_requests.sql). */
|
|
5
|
+
export const SLA_MY_REQUESTS_REQUEST_OBJ_EXCLUDED_KEYS = [
|
|
6
|
+
"id",
|
|
7
|
+
"status",
|
|
8
|
+
"role_id",
|
|
9
|
+
"user_id",
|
|
10
|
+
"createdBy",
|
|
11
|
+
"created_at",
|
|
12
|
+
"updated_by",
|
|
13
|
+
"updated_at",
|
|
14
|
+
"req_user_department_id",
|
|
15
|
+
"workflow_execution_id",
|
|
16
|
+
"department_id",
|
|
17
|
+
"req_user_section_id",
|
|
18
|
+
"service_type_id",
|
|
19
|
+
"service_type",
|
|
20
|
+
"created_by",
|
|
21
|
+
"service_id",
|
|
22
|
+
"sub_service_id",
|
|
23
|
+
"attachments",
|
|
24
|
+
"is_deleted",
|
|
25
|
+
"sla_request",
|
|
26
|
+
"sla_request_id",
|
|
27
|
+
] as const;
|
|
28
|
+
|
|
29
|
+
const VW_SLA_MY_REQUESTS_SQL = `
|
|
30
|
+
SELECT
|
|
31
|
+
sr.id AS sla_request_id,
|
|
32
|
+
sr.user_id,
|
|
33
|
+
sr.service_id AS service_id,
|
|
34
|
+
sr.sub_service_id AS sub_service_id,
|
|
35
|
+
TRIM(COALESCE(creator.employee_name, ''))::TEXT AS created_by,
|
|
36
|
+
sr.created_at,
|
|
37
|
+
TRIM(COALESCE(dept.department_name, ''))::TEXT AS req_user_department_id,
|
|
38
|
+
TRIM(COALESCE(sec.section_name, ''))::TEXT AS req_user_section_id,
|
|
39
|
+
TRIM(COALESCE(svc.name, ''))::TEXT AS service_name,
|
|
40
|
+
TRIM(COALESCE(subsvc.sub_service_name, ''))::TEXT AS sub_service_name,
|
|
41
|
+
sr.status::TEXT AS status,
|
|
42
|
+
sr.request_id,
|
|
43
|
+
(
|
|
44
|
+
COALESCE(sr.request_obj, '{}'::jsonb)
|
|
45
|
+
- 'id'
|
|
46
|
+
- 'status'
|
|
47
|
+
- 'role_id'
|
|
48
|
+
- 'user_id'
|
|
49
|
+
- 'createdBy'
|
|
50
|
+
- 'created_at'
|
|
51
|
+
- 'updated_by'
|
|
52
|
+
- 'updated_at'
|
|
53
|
+
- 'req_user_department_id'
|
|
54
|
+
- 'workflow_execution_id'
|
|
55
|
+
- 'department_id'
|
|
56
|
+
- 'req_user_section_id'
|
|
57
|
+
- 'service_type_id'
|
|
58
|
+
- 'service_type'
|
|
59
|
+
- 'created_by'
|
|
60
|
+
- 'service_id'
|
|
61
|
+
- 'sub_service_id'
|
|
62
|
+
- 'attachments'
|
|
63
|
+
- 'is_deleted'
|
|
64
|
+
- 'sla_request'
|
|
65
|
+
- 'sla_request_id'
|
|
66
|
+
) AS request_fields
|
|
67
|
+
FROM sla_requests sr
|
|
68
|
+
LEFT JOIN users creator
|
|
69
|
+
ON sr.created_by ~ '^[0-9]+$'
|
|
70
|
+
AND creator.id = sr.created_by::integer
|
|
71
|
+
AND COALESCE(creator.is_deleted, false) = false
|
|
72
|
+
LEFT JOIN departments dept
|
|
73
|
+
ON dept.id = sr.req_user_department_id AND COALESCE(dept.is_deleted, false) = false
|
|
74
|
+
LEFT JOIN sections sec
|
|
75
|
+
ON sec.id = sr.req_user_section_id AND COALESCE(sec.is_deleted, false) = false
|
|
76
|
+
LEFT JOIN fm_services svc
|
|
77
|
+
ON svc.id = sr.service_id AND COALESCE(svc.is_deleted, false) = false
|
|
78
|
+
LEFT JOIN fm_sub_services subsvc
|
|
79
|
+
ON subsvc.id = sr.sub_service_id AND COALESCE(subsvc.is_deleted, false) = false
|
|
80
|
+
WHERE COALESCE(sr.is_deleted, false) = false
|
|
81
|
+
`;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Read-only view for SLA "my requests" listings.
|
|
85
|
+
* Display-name columns reuse sla_requests field names; values come from joined lookup tables.
|
|
86
|
+
* Service-specific payload keys live in `request_fields` (filtered `request_obj`).
|
|
87
|
+
*/
|
|
88
|
+
@ViewEntity({
|
|
89
|
+
name: "vw_sla_my_requests",
|
|
90
|
+
expression: VW_SLA_MY_REQUESTS_SQL,
|
|
91
|
+
})
|
|
92
|
+
export class SlaMyRequestsView {
|
|
93
|
+
@ViewColumn()
|
|
94
|
+
sla_request_id: number;
|
|
95
|
+
|
|
96
|
+
/** Request owner (`sla_requests.user_id`) — filter with WHERE user_id = :userId for "my requests". */
|
|
97
|
+
@ViewColumn()
|
|
98
|
+
user_id: number;
|
|
99
|
+
|
|
100
|
+
/** Numeric fm_services.id used for filtering. */
|
|
101
|
+
@ViewColumn()
|
|
102
|
+
service_id: number;
|
|
103
|
+
|
|
104
|
+
/** Numeric fm_sub_services.id used for filtering. */
|
|
105
|
+
@ViewColumn()
|
|
106
|
+
sub_service_id: number;
|
|
107
|
+
|
|
108
|
+
@ViewColumn()
|
|
109
|
+
created_by: string;
|
|
110
|
+
|
|
111
|
+
@ViewColumn()
|
|
112
|
+
created_at: Date;
|
|
113
|
+
|
|
114
|
+
@ViewColumn()
|
|
115
|
+
req_user_department_id: string;
|
|
116
|
+
|
|
117
|
+
@ViewColumn()
|
|
118
|
+
req_user_section_id: string;
|
|
119
|
+
|
|
120
|
+
@ViewColumn()
|
|
121
|
+
service_name: string;
|
|
122
|
+
|
|
123
|
+
@ViewColumn()
|
|
124
|
+
sub_service_name: string;
|
|
125
|
+
|
|
126
|
+
@ViewColumn()
|
|
127
|
+
status: SlaRequestStatus | string;
|
|
128
|
+
|
|
129
|
+
@ViewColumn()
|
|
130
|
+
request_id: number;
|
|
131
|
+
|
|
132
|
+
/** Remaining `request_obj` keys after excluding workflow/common duplicates. */
|
|
133
|
+
@ViewColumn()
|
|
134
|
+
request_fields: Record<string, unknown>;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** Flatten view row: fixed columns plus each entry in `request_fields`. */
|
|
138
|
+
export function flattenSlaMyRequestsViewRow(
|
|
139
|
+
row: SlaMyRequestsView
|
|
140
|
+
): Record<string, unknown> {
|
|
141
|
+
const {
|
|
142
|
+
sla_request_id,
|
|
143
|
+
user_id,
|
|
144
|
+
service_id,
|
|
145
|
+
sub_service_id,
|
|
146
|
+
created_by,
|
|
147
|
+
created_at,
|
|
148
|
+
req_user_department_id,
|
|
149
|
+
req_user_section_id,
|
|
150
|
+
service_name,
|
|
151
|
+
sub_service_name,
|
|
152
|
+
status,
|
|
153
|
+
request_id,
|
|
154
|
+
request_fields,
|
|
155
|
+
} = row;
|
|
156
|
+
|
|
157
|
+
return {
|
|
158
|
+
sla_request_id,
|
|
159
|
+
user_id,
|
|
160
|
+
service_id,
|
|
161
|
+
sub_service_id,
|
|
162
|
+
created_by,
|
|
163
|
+
created_at,
|
|
164
|
+
req_user_department_id,
|
|
165
|
+
req_user_section_id,
|
|
166
|
+
service_name,
|
|
167
|
+
sub_service_name,
|
|
168
|
+
status,
|
|
169
|
+
request_id,
|
|
170
|
+
...(request_fields ?? {}),
|
|
171
|
+
};
|
|
172
|
+
}
|
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
import { Column, Entity, Index } from "typeorm";
|
|
2
|
-
import { BaseModel } from "./BaseModel";
|
|
3
|
-
|
|
4
|
-
export enum SlaRequestStatus {
|
|
5
|
-
PENDING = "Pending",
|
|
6
|
-
IN_PROGRESS = "In Progress",
|
|
7
|
-
APPROVED = "Approved",
|
|
8
|
-
REJECTED = "Rejected",
|
|
9
|
-
ASSIGNED = "Assigned",
|
|
10
|
-
COMPLETED = "Completed"
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
@Entity({ name: "sla_requests" })
|
|
14
|
-
// @Index("uq_sla_requests_request_id", ["request_id"])
|
|
15
|
-
@Index("idx_sla_requests_user_id", ["user_id"])
|
|
16
|
-
@Index("idx_sla_requests_service_subservice", ["service_id", "sub_service_id"])
|
|
17
|
-
@Index("idx_sla_requests_workflow_execution_id", ["workflow_execution_id"])
|
|
18
|
-
@Index("idx_sla_requests_status", ["status"])
|
|
19
|
-
export class SlaRequest extends BaseModel {
|
|
20
|
-
@Column({ type: "int", nullable: true })
|
|
21
|
-
req_user_department_id: number | null;
|
|
22
|
-
|
|
23
|
-
@Column({ type: "int", nullable: true })
|
|
24
|
-
req_user_section_id: number | null;
|
|
25
|
-
|
|
26
|
-
@Column({ type: "int", nullable: true })
|
|
27
|
-
service_id: number | null;
|
|
28
|
-
|
|
29
|
-
@Column({ type: "int", nullable: true })
|
|
30
|
-
sub_service_id: number | null;
|
|
31
|
-
|
|
32
|
-
@Column({ type: "int", nullable: false })
|
|
33
|
-
user_id: number;
|
|
34
|
-
|
|
35
|
-
@Column({
|
|
36
|
-
type: "varchar",
|
|
37
|
-
length: 64,
|
|
38
|
-
default: SlaRequestStatus.PENDING,
|
|
39
|
-
nullable: false
|
|
40
|
-
})
|
|
41
|
-
status: string;
|
|
42
|
-
|
|
43
|
-
@Column({ type: "varchar", length: 255, nullable: true })
|
|
44
|
-
workflow_execution_id: string | null;
|
|
45
|
-
|
|
46
|
-
@Column({ type: "int", nullable: false })
|
|
47
|
-
request_id: number;
|
|
48
|
-
|
|
49
|
-
@Column({ type: "jsonb", nullable: false, default: () => "'{}'::jsonb" })
|
|
50
|
-
request_obj: Record<string, unknown>;
|
|
51
|
-
|
|
52
|
-
constructor() {
|
|
53
|
-
super();
|
|
54
|
-
this.request_id = 0;
|
|
55
|
-
this.request_obj = {};
|
|
56
|
-
}
|
|
57
|
-
}
|
|
1
|
+
import { Column, Entity, Index } from "typeorm";
|
|
2
|
+
import { BaseModel } from "./BaseModel";
|
|
3
|
+
|
|
4
|
+
export enum SlaRequestStatus {
|
|
5
|
+
PENDING = "Pending",
|
|
6
|
+
IN_PROGRESS = "In Progress",
|
|
7
|
+
APPROVED = "Approved",
|
|
8
|
+
REJECTED = "Rejected",
|
|
9
|
+
ASSIGNED = "Assigned",
|
|
10
|
+
COMPLETED = "Completed"
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@Entity({ name: "sla_requests" })
|
|
14
|
+
// @Index("uq_sla_requests_request_id", ["request_id"])
|
|
15
|
+
@Index("idx_sla_requests_user_id", ["user_id"])
|
|
16
|
+
@Index("idx_sla_requests_service_subservice", ["service_id", "sub_service_id"])
|
|
17
|
+
@Index("idx_sla_requests_workflow_execution_id", ["workflow_execution_id"])
|
|
18
|
+
@Index("idx_sla_requests_status", ["status"])
|
|
19
|
+
export class SlaRequest extends BaseModel {
|
|
20
|
+
@Column({ type: "int", nullable: true })
|
|
21
|
+
req_user_department_id: number | null;
|
|
22
|
+
|
|
23
|
+
@Column({ type: "int", nullable: true })
|
|
24
|
+
req_user_section_id: number | null;
|
|
25
|
+
|
|
26
|
+
@Column({ type: "int", nullable: true })
|
|
27
|
+
service_id: number | null;
|
|
28
|
+
|
|
29
|
+
@Column({ type: "int", nullable: true })
|
|
30
|
+
sub_service_id: number | null;
|
|
31
|
+
|
|
32
|
+
@Column({ type: "int", nullable: false })
|
|
33
|
+
user_id: number;
|
|
34
|
+
|
|
35
|
+
@Column({
|
|
36
|
+
type: "varchar",
|
|
37
|
+
length: 64,
|
|
38
|
+
default: SlaRequestStatus.PENDING,
|
|
39
|
+
nullable: false
|
|
40
|
+
})
|
|
41
|
+
status: string;
|
|
42
|
+
|
|
43
|
+
@Column({ type: "varchar", length: 255, nullable: true })
|
|
44
|
+
workflow_execution_id: string | null;
|
|
45
|
+
|
|
46
|
+
@Column({ type: "int", nullable: false })
|
|
47
|
+
request_id: number;
|
|
48
|
+
|
|
49
|
+
@Column({ type: "jsonb", nullable: false, default: () => "'{}'::jsonb" })
|
|
50
|
+
request_obj: Record<string, unknown>;
|
|
51
|
+
|
|
52
|
+
constructor() {
|
|
53
|
+
super();
|
|
54
|
+
this.request_id = 0;
|
|
55
|
+
this.request_obj = {};
|
|
56
|
+
}
|
|
57
|
+
}
|
package/src/sla-report-views.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/** SLA report views — import from `@platform-modules/foreign-ministry/sla-report-views` (Reports_Service only). Not in main index to avoid TypeORM synchronize conflicts. */
|
|
2
|
-
export * from './models/SlaMyRequestsViewModel';
|
|
3
|
-
export * from './models/SlaApprovalsViewModel';
|
|
1
|
+
/** SLA report views — import from `@platform-modules/foreign-ministry/sla-report-views` (Reports_Service only). Not in main index to avoid TypeORM synchronize conflicts. */
|
|
2
|
+
export * from './models/SlaMyRequestsViewModel';
|
|
3
|
+
export * from './models/SlaApprovalsViewModel';
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { UserSessionReader } from './user-session-validation';
|
|
2
|
-
export type JwtAuthFailure = {
|
|
3
|
-
ok: false;
|
|
4
|
-
statusCode: 401;
|
|
5
|
-
message: string;
|
|
6
|
-
};
|
|
7
|
-
export type JwtAuthSuccess = {
|
|
8
|
-
ok: true;
|
|
9
|
-
claims: Record<string, unknown>;
|
|
10
|
-
userId: number;
|
|
11
|
-
sessionId: number | null;
|
|
12
|
-
};
|
|
13
|
-
export type JwtAuthResult = JwtAuthSuccess | JwtAuthFailure;
|
|
14
|
-
/**
|
|
15
|
-
* After jwt.verify(), enforce server-side session binding (logout revocation).
|
|
16
|
-
*/
|
|
17
|
-
export declare function authorizeVerifiedJwtSession(verified: Record<string, unknown>, sessionReader: UserSessionReader, options?: {
|
|
18
|
-
requireActiveSession?: boolean;
|
|
19
|
-
}): Promise<JwtAuthResult>;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.authorizeVerifiedJwtSession = authorizeVerifiedJwtSession;
|
|
4
|
-
const jwt_token_helper_1 = require("./jwt-token.helper");
|
|
5
|
-
const user_session_validation_1 = require("./user-session-validation");
|
|
6
|
-
/**
|
|
7
|
-
* After jwt.verify(), enforce server-side session binding (logout revocation).
|
|
8
|
-
*/
|
|
9
|
-
async function authorizeVerifiedJwtSession(verified, sessionReader, options) {
|
|
10
|
-
const parsed = (0, jwt_token_helper_1.parseVerifiedJwtClaims)(verified);
|
|
11
|
-
if (!parsed) {
|
|
12
|
-
return { ok: false, statusCode: 401, message: 'Invalid Token' };
|
|
13
|
-
}
|
|
14
|
-
const requireActiveSession = options?.requireActiveSession !== false;
|
|
15
|
-
if (requireActiveSession) {
|
|
16
|
-
const sessionValid = await (0, user_session_validation_1.validateUserSessionBinding)(parsed.userId, parsed.sessionId, sessionReader);
|
|
17
|
-
if (!sessionValid) {
|
|
18
|
-
return { ok: false, statusCode: 401, message: 'Session Expired please login again' };
|
|
19
|
-
}
|
|
20
|
-
if (parsed.sessionId != null) {
|
|
21
|
-
const isCurrent = await (0, user_session_validation_1.validateJwtSessionIsCurrent)(parsed.userId, parsed.sessionId, sessionReader);
|
|
22
|
-
if (!isCurrent) {
|
|
23
|
-
return { ok: false, statusCode: 401, message: 'Session Expired please login again' };
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
const sessionId = await (0, user_session_validation_1.resolveAuthorizedSessionId)(parsed.userId, parsed.sessionId, sessionReader);
|
|
28
|
-
const { sessionId: _jwtSessionId, ...claimsWithoutSession } = parsed.raw;
|
|
29
|
-
return {
|
|
30
|
-
ok: true,
|
|
31
|
-
claims: claimsWithoutSession,
|
|
32
|
-
userId: parsed.userId,
|
|
33
|
-
sessionId,
|
|
34
|
-
};
|
|
35
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Extract portal API JWT from standard request headers.
|
|
3
|
-
* Supports `jwt` header (legacy) and `Authorization: Bearer <token>`.
|
|
4
|
-
*/
|
|
5
|
-
export declare function extractJwtToken(headers: Record<string, string | string[] | undefined> | undefined): string | null;
|
|
6
|
-
export type JwtTokenRequest = {
|
|
7
|
-
headers: Record<string, string | string[] | undefined>;
|
|
8
|
-
body?: unknown;
|
|
9
|
-
};
|
|
10
|
-
/** JWT from headers (`jwt`, `Authorization: Bearer`) or JSON body (`token`, `jwt`, `access_token`). */
|
|
11
|
-
export declare function extractJwtTokenFromRequest(request: JwtTokenRequest): string | null;
|
|
12
|
-
export type VerifiedJwtClaims = {
|
|
13
|
-
userId: number;
|
|
14
|
-
sessionId: number | null;
|
|
15
|
-
raw: Record<string, unknown>;
|
|
16
|
-
};
|
|
17
|
-
/** Parse verified JWT payload into userId + sessionId. */
|
|
18
|
-
export declare function parseVerifiedJwtClaims(verified: Record<string, unknown>): VerifiedJwtClaims | null;
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.extractJwtToken = extractJwtToken;
|
|
4
|
-
exports.extractJwtTokenFromRequest = extractJwtTokenFromRequest;
|
|
5
|
-
exports.parseVerifiedJwtClaims = parseVerifiedJwtClaims;
|
|
6
|
-
/**
|
|
7
|
-
* Extract portal API JWT from standard request headers.
|
|
8
|
-
* Supports `jwt` header (legacy) and `Authorization: Bearer <token>`.
|
|
9
|
-
*/
|
|
10
|
-
function extractJwtToken(headers) {
|
|
11
|
-
if (!headers)
|
|
12
|
-
return null;
|
|
13
|
-
const pick = (value) => {
|
|
14
|
-
const raw = Array.isArray(value) ? value[0] : value;
|
|
15
|
-
const trimmed = raw?.trim();
|
|
16
|
-
return trimmed ? trimmed : null;
|
|
17
|
-
};
|
|
18
|
-
const fromJwtHeader = pick(headers.jwt ?? headers.JWT);
|
|
19
|
-
if (fromJwtHeader)
|
|
20
|
-
return fromJwtHeader;
|
|
21
|
-
const authorization = pick(headers.authorization ?? headers.Authorization);
|
|
22
|
-
if (!authorization)
|
|
23
|
-
return null;
|
|
24
|
-
const bearerMatch = /^Bearer\s+(.+)$/i.exec(authorization);
|
|
25
|
-
if (bearerMatch?.[1]?.trim())
|
|
26
|
-
return bearerMatch[1].trim();
|
|
27
|
-
return authorization;
|
|
28
|
-
}
|
|
29
|
-
/** JWT from headers (`jwt`, `Authorization: Bearer`) or JSON body (`token`, `jwt`, `access_token`). */
|
|
30
|
-
function extractJwtTokenFromRequest(request) {
|
|
31
|
-
const fromHeaders = extractJwtToken(request.headers);
|
|
32
|
-
if (fromHeaders)
|
|
33
|
-
return fromHeaders;
|
|
34
|
-
const body = request.body;
|
|
35
|
-
if (!body || typeof body !== 'object')
|
|
36
|
-
return null;
|
|
37
|
-
for (const key of ['token', 'jwt', 'access_token']) {
|
|
38
|
-
const value = body[key];
|
|
39
|
-
if (typeof value === 'string' && value.trim())
|
|
40
|
-
return value.trim();
|
|
41
|
-
}
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
/** Parse verified JWT payload into userId + sessionId. */
|
|
45
|
-
function parseVerifiedJwtClaims(verified) {
|
|
46
|
-
const userId = Number(verified.userId);
|
|
47
|
-
if (!Number.isFinite(userId) || userId <= 0)
|
|
48
|
-
return null;
|
|
49
|
-
const sessionIdRaw = verified.sessionId;
|
|
50
|
-
const parsedSessionId = sessionIdRaw == null || sessionIdRaw === '' ? null : Number(sessionIdRaw);
|
|
51
|
-
return {
|
|
52
|
-
userId,
|
|
53
|
-
sessionId: parsedSessionId != null && Number.isFinite(parsedSessionId) && parsedSessionId > 0
|
|
54
|
-
? parsedSessionId
|
|
55
|
-
: null,
|
|
56
|
-
raw: verified,
|
|
57
|
-
};
|
|
58
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Server-side JWT session binding (VAPT M003/M004).
|
|
3
|
-
* JWT remains valid cryptographically until exp; access is allowed only while
|
|
4
|
-
* the bound user_sessions row is active and not expired.
|
|
5
|
-
*/
|
|
6
|
-
export type UserSessionRow = {
|
|
7
|
-
id?: number;
|
|
8
|
-
};
|
|
9
|
-
export type UserSessionReader = {
|
|
10
|
-
isSessionActiveById(sessionId: number, userId: number): Promise<boolean>;
|
|
11
|
-
/** Legacy fallback when REQUIRE_JWT_SESSION_ID=false and token has no sessionId. */
|
|
12
|
-
isSessionActive?(userId: number): Promise<UserSessionRow | null | undefined>;
|
|
13
|
-
/** Latest active session row id for user (highest id). */
|
|
14
|
-
getLatestActiveSessionId?(userId: number): Promise<number | null>;
|
|
15
|
-
};
|
|
16
|
-
/** Default true — only the newest active session may use the API when JWT carries sessionId. */
|
|
17
|
-
export declare function isSingleSessionOnLogin(): boolean;
|
|
18
|
-
/** When true (default), JWT must include sessionId and that session must be active. */
|
|
19
|
-
export declare function isRequireJwtSessionId(): boolean;
|
|
20
|
-
export declare function resolveJwtSessionId(sessionId: unknown): number | null;
|
|
21
|
-
/**
|
|
22
|
-
* Validate that a verified JWT is still authorized (not logged out / expired server-side).
|
|
23
|
-
*/
|
|
24
|
-
export declare function validateUserSessionBinding(userId: number, sessionId: number | null | undefined, reader: UserSessionReader): Promise<boolean>;
|
|
25
|
-
/** After row-level active check, enforce single-session policy (reject superseded JWTs). */
|
|
26
|
-
export declare function validateJwtSessionIsCurrent(userId: number, sessionId: number, reader: UserSessionReader): Promise<boolean>;
|
|
27
|
-
/** Resolve session id for request meta: JWT claim first, else latest active DB row. */
|
|
28
|
-
export declare function resolveAuthorizedSessionId(userId: number, jwtSessionId: number | null, reader: UserSessionReader): Promise<number | null>;
|
|
29
|
-
/** Shared TypeORM filters: active, not deleted, not past expires_at. */
|
|
30
|
-
export declare function applyActiveUserSessionFilters(qb: {
|
|
31
|
-
andWhere: (clause: string, params?: Record<string, unknown>) => unknown;
|
|
32
|
-
orderBy?: (sort: string, order?: 'ASC' | 'DESC') => unknown;
|
|
33
|
-
}, alias?: string): void;
|
|
34
|
-
/** Prefer newest active session when multiple rows match (legacy path). */
|
|
35
|
-
export declare function applyLatestActiveUserSessionOrdering(qb: {
|
|
36
|
-
orderBy: (sort: string, order?: 'ASC' | 'DESC') => unknown;
|
|
37
|
-
}, alias?: string): void;
|
|
38
|
-
/** @deprecated Use applyActiveUserSessionFilters — kept for backward compatibility. */
|
|
39
|
-
export declare function activeUserSessionSql(alias?: string): {
|
|
40
|
-
clause: string;
|
|
41
|
-
params: Record<string, unknown>;
|
|
42
|
-
};
|