@platform-modules/civil-aviation-authority 2.3.258 → 2.3.259
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/models/SlaApprovalsViewModel.d.ts +26 -0
- package/dist/models/SlaApprovalsViewModel.js +170 -0
- package/dist/models/SlaMyRequestsViewModel.d.ts +7 -3
- package/dist/models/SlaMyRequestsViewModel.js +68 -50
- package/package.json +1 -1
- package/sql/vw_sla_my_requests.sql +54 -49
- package/src/data-source.ts +515 -515
- package/src/index.ts +494 -494
- package/src/models/SlaMyRequestsViewModel.ts +170 -150
|
@@ -1,150 +1,170 @@
|
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
sr.
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
TRIM(COALESCE(
|
|
36
|
-
sr.
|
|
37
|
-
|
|
38
|
-
(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
- '
|
|
46
|
-
- '
|
|
47
|
-
- '
|
|
48
|
-
- '
|
|
49
|
-
- '
|
|
50
|
-
- '
|
|
51
|
-
- '
|
|
52
|
-
- '
|
|
53
|
-
- '
|
|
54
|
-
- '
|
|
55
|
-
- '
|
|
56
|
-
- '
|
|
57
|
-
- '
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
LEFT JOIN
|
|
69
|
-
ON
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
@ViewColumn()
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
@ViewColumn()
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
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 creator.id = sr.created_by AND COALESCE(creator.is_deleted, false) = false
|
|
70
|
+
LEFT JOIN departments dept
|
|
71
|
+
ON dept.id = sr.req_user_department_id AND COALESCE(dept.is_deleted, false) = false
|
|
72
|
+
LEFT JOIN sections sec
|
|
73
|
+
ON sec.id = sr.req_user_section_id AND COALESCE(sec.is_deleted, false) = false
|
|
74
|
+
LEFT JOIN caa_services svc
|
|
75
|
+
ON svc.id = sr.service_id AND COALESCE(svc.is_deleted, false) = false
|
|
76
|
+
LEFT JOIN caa_sub_services subsvc
|
|
77
|
+
ON subsvc.id = sr.sub_service_id AND COALESCE(subsvc.is_deleted, false) = false
|
|
78
|
+
WHERE COALESCE(sr.is_deleted, false) = false
|
|
79
|
+
`;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Read-only view for SLA "my requests" listings.
|
|
83
|
+
* Display-name columns reuse sla_requests field names; values come from joined lookup tables.
|
|
84
|
+
* Service-specific payload keys live in `request_fields` (filtered `request_obj`).
|
|
85
|
+
*/
|
|
86
|
+
@ViewEntity({
|
|
87
|
+
name: "vw_sla_my_requests",
|
|
88
|
+
expression: VW_SLA_MY_REQUESTS_SQL,
|
|
89
|
+
})
|
|
90
|
+
export class SlaMyRequestsView {
|
|
91
|
+
@ViewColumn()
|
|
92
|
+
sla_request_id: number;
|
|
93
|
+
|
|
94
|
+
/** Request owner (`sla_requests.user_id`) — filter with WHERE user_id = :userId for "my requests". */
|
|
95
|
+
@ViewColumn()
|
|
96
|
+
user_id: number;
|
|
97
|
+
|
|
98
|
+
/** Numeric caa_services.id used for filtering. */
|
|
99
|
+
@ViewColumn()
|
|
100
|
+
service_id: number;
|
|
101
|
+
|
|
102
|
+
/** Numeric caa_sub_services.id used for filtering. */
|
|
103
|
+
@ViewColumn()
|
|
104
|
+
sub_service_id: number;
|
|
105
|
+
|
|
106
|
+
@ViewColumn()
|
|
107
|
+
created_by: string;
|
|
108
|
+
|
|
109
|
+
@ViewColumn()
|
|
110
|
+
created_at: Date;
|
|
111
|
+
|
|
112
|
+
@ViewColumn()
|
|
113
|
+
req_user_department_id: string;
|
|
114
|
+
|
|
115
|
+
@ViewColumn()
|
|
116
|
+
req_user_section_id: string;
|
|
117
|
+
|
|
118
|
+
@ViewColumn()
|
|
119
|
+
service_name: string;
|
|
120
|
+
|
|
121
|
+
@ViewColumn()
|
|
122
|
+
sub_service_name: string;
|
|
123
|
+
|
|
124
|
+
@ViewColumn()
|
|
125
|
+
status: SlaRequestStatus | string;
|
|
126
|
+
|
|
127
|
+
@ViewColumn()
|
|
128
|
+
request_id: number;
|
|
129
|
+
|
|
130
|
+
/** Remaining `request_obj` keys after excluding workflow/common duplicates. */
|
|
131
|
+
@ViewColumn()
|
|
132
|
+
request_fields: Record<string, unknown>;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** Flatten view row: fixed columns plus each entry in `request_fields`. */
|
|
136
|
+
export function flattenSlaMyRequestsViewRow(
|
|
137
|
+
row: SlaMyRequestsView
|
|
138
|
+
): Record<string, unknown> {
|
|
139
|
+
const {
|
|
140
|
+
sla_request_id,
|
|
141
|
+
user_id,
|
|
142
|
+
service_id,
|
|
143
|
+
sub_service_id,
|
|
144
|
+
created_by,
|
|
145
|
+
created_at,
|
|
146
|
+
req_user_department_id,
|
|
147
|
+
req_user_section_id,
|
|
148
|
+
service_name,
|
|
149
|
+
sub_service_name,
|
|
150
|
+
status,
|
|
151
|
+
request_id,
|
|
152
|
+
request_fields,
|
|
153
|
+
} = row;
|
|
154
|
+
|
|
155
|
+
return {
|
|
156
|
+
sla_request_id,
|
|
157
|
+
user_id,
|
|
158
|
+
service_id,
|
|
159
|
+
sub_service_id,
|
|
160
|
+
created_by,
|
|
161
|
+
created_at,
|
|
162
|
+
req_user_department_id,
|
|
163
|
+
req_user_section_id,
|
|
164
|
+
service_name,
|
|
165
|
+
sub_service_name,
|
|
166
|
+
status,
|
|
167
|
+
request_id,
|
|
168
|
+
...(request_fields ?? {}),
|
|
169
|
+
};
|
|
170
|
+
}
|