@platform-modules/civil-aviation-authority 2.3.337 → 2.3.339

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.
Files changed (75) hide show
  1. package/.env +19 -10
  2. package/dist/models/DocumentMetadataModel.d.ts +45 -0
  3. package/dist/models/DocumentMetadataModel.js +171 -0
  4. package/dist/models/DocumentationDepartmentsModel.d.ts +13 -0
  5. package/dist/models/DocumentationDepartmentsModel.js +53 -0
  6. package/dist/models/FolderModel.d.ts +16 -0
  7. package/dist/models/FolderModel.js +85 -0
  8. package/dist/models/ImportExportMaterialModels.d.ts +92 -0
  9. package/dist/models/ImportExportMaterialModels.js +307 -0
  10. package/dist/models/PermissionModel.d.ts +18 -0
  11. package/dist/models/PermissionModel.js +68 -0
  12. package/dist/models/ScholarshipChatModel.d.ts +3 -0
  13. package/dist/models/ScholarshipChatModel.js +12 -0
  14. package/dist/models/ScholarshipRequestModel.d.ts +10 -0
  15. package/dist/models/ScholarshipRequestModel.js +30 -1
  16. package/dist/models/SecurityAccessApprovalModel.d.ts +23 -0
  17. package/dist/models/SecurityAccessApprovalModel.js +82 -0
  18. package/dist/models/SecurityAccessAttachmentModel.d.ts +12 -0
  19. package/dist/models/SecurityAccessAttachmentModel.js +56 -0
  20. package/dist/models/SecurityAccessChatModel.d.ts +12 -0
  21. package/dist/models/SecurityAccessChatModel.js +56 -0
  22. package/dist/models/SecurityAccessRequestModel.d.ts +25 -0
  23. package/dist/models/SecurityAccessRequestModel.js +80 -0
  24. package/dist/models/SecurityAccessWorkflowModel.d.ts +24 -0
  25. package/dist/models/SecurityAccessWorkflowModel.js +84 -0
  26. package/dist/models/ServiceExtensionAfterAge60Models.d.ts +93 -0
  27. package/dist/models/ServiceExtensionAfterAge60Models.js +312 -0
  28. package/dist/models/SlaApprovalsViewModel.js +54 -54
  29. package/dist/models/UUIDBaseModel.d.ts +14 -0
  30. package/dist/models/UUIDBaseModel.js +66 -0
  31. package/dist/models/WorkingHoursExtensionModels.d.ts +88 -0
  32. package/dist/models/WorkingHoursExtensionModels.js +295 -0
  33. package/package.json +1 -1
  34. package/scripts/sync-sla-reports-sql.js +92 -92
  35. package/sql/README.md +21 -21
  36. package/sql/add_annual_training_plan_reference_number.sql +6 -6
  37. package/sql/add_scholarship_request_extra_fields.sql +45 -0
  38. package/sql/add_training_request_reference_number.sql +9 -9
  39. package/sql/add_training_room_booking_records_reference.sql +19 -19
  40. package/sql/sla_reports_admin_procedures.sql +322 -322
  41. package/sql/sla_reports_approvals_workbook.sql +427 -427
  42. package/sql/sla_reports_procedures.sql +883 -883
  43. package/sql/update_scholarship_workflow_version_2.sql +11 -0
  44. package/sql/vw_sla_approvals.sql +115 -115
  45. package/sql/vw_sla_my_requests.sql +58 -58
  46. package/src/models/AccessCardRequestModel.ts +135 -135
  47. package/src/models/AirportEntryPermitModel.ts +276 -276
  48. package/src/models/AnnualTrainingPlanRequestModel.ts +156 -156
  49. package/src/models/DocumentDriveModel.ts +28 -28
  50. package/src/models/DocumentFolderModel.ts +45 -45
  51. package/src/models/HotelApprovalModel.ts +83 -83
  52. package/src/models/HousingContractCancelApprovalModel.ts +64 -64
  53. package/src/models/HousingContractRenewalApprovalModel.ts +64 -64
  54. package/src/models/ITRequestAttachmentModel.ts +73 -73
  55. package/src/models/ItApprovalsModel.ts +84 -84
  56. package/src/models/LegalConsultationApprovalModel.ts +65 -65
  57. package/src/models/MissionTravelPassportExpiryNotificationConfigModel.ts +36 -36
  58. package/src/models/NotificationModel.ts +89 -89
  59. package/src/models/ResidentialUnitRentalApprovalModel.ts +143 -143
  60. package/src/models/ScholarshipChatModel.ts +9 -0
  61. package/src/models/ScholarshipRequestModel.ts +23 -0
  62. package/src/models/ServiceExtensionAfter60ApprovalModel.ts +87 -87
  63. package/src/models/ServiceSlaApprovalModel.ts +64 -64
  64. package/src/models/ServicesNotificationConfigModel.ts +55 -55
  65. package/src/models/SlaApprovalsViewModel.ts +142 -142
  66. package/src/models/StudyLeaveRequestModel.ts +173 -173
  67. package/src/models/TrainingRequestModel.ts +169 -169
  68. package/src/models/TrainingRoomBookingRequestModel.ts +178 -178
  69. package/src/models/TrainingRoomBookingWorkflowModel.ts +81 -81
  70. package/src/models/TrainingRoomNotificationConfigModel.ts +30 -30
  71. package/src/models/role.ts +34 -34
  72. package/src/scripts.ts +20 -20
  73. package/src/sla/sla-table-sync.service.ts +90 -90
  74. package/dist/helpers/cancellation-bilingual-persist.helper.d.ts +0 -37
  75. package/dist/helpers/cancellation-bilingual-persist.helper.js +0 -77
package/src/scripts.ts CHANGED
@@ -1,20 +1,20 @@
1
- import { AppDataSource } from './data-source';
2
-
3
-
4
-
5
- AppDataSource.initialize()
6
-
7
- .then(() => {
8
-
9
- console.log('✅ Database schema synchronized successfully.');
10
-
11
- })
12
-
13
- .catch((error: any) => {
14
-
15
- console.error('❌ Error during schema synchronization:', error);
16
-
17
- process.exit(1);
18
-
19
- });
20
-
1
+ import { AppDataSource } from './data-source';
2
+
3
+
4
+
5
+ AppDataSource.initialize()
6
+
7
+ .then(() => {
8
+
9
+ console.log('✅ Database schema synchronized successfully.');
10
+
11
+ })
12
+
13
+ .catch((error: any) => {
14
+
15
+ console.error('❌ Error during schema synchronization:', error);
16
+
17
+ process.exit(1);
18
+
19
+ });
20
+
@@ -1,90 +1,90 @@
1
- import { EntityManager } from "typeorm";
2
- import { ServiceSlaApproval } from "../models/ServiceSlaApprovalModel";
3
- import { SlaRequest, SlaRequestStatus } from "../models/SlaRequestModel";
4
-
5
- export type PatchSlaApprovalTableInput = Partial<{
6
- approval_status: string;
7
- approver_user_id: number | null;
8
- approver_role_id: number | null;
9
- department_id: number | null;
10
- section_id: number | null;
11
- level: number;
12
- delegate_user_id: number | null;
13
- approved_by: number | null;
14
- comment: string | null;
15
- }>;
16
-
17
- export type PatchSlaRequestTableInput = Partial<{
18
- status: SlaRequestStatus | string;
19
- workflow_execution_id: string | null;
20
- }>;
21
-
22
- function stripUndefined<T extends Record<string, unknown>>(obj: T): Partial<T> {
23
- const out: Partial<T> = {};
24
- for (const key of Object.keys(obj)) {
25
- const v = obj[key];
26
- if (v !== undefined) {
27
- (out as Record<string, unknown>)[key] = v;
28
- }
29
- }
30
- return out;
31
- }
32
-
33
- /**
34
- * TypeORM patches for `sla_approval` and `sla_requests` by the keys used at insert time
35
- * (`source_approval_id` and native `request_id`). Safe to call from any service that shares the DB;
36
- * failures are swallowed so missing SLA rows never block business transactions.
37
- */
38
- export class SlaTableSyncService {
39
- static async patchSlaApprovalBySourceApprovalId(
40
- manager: EntityManager,
41
- sourceApprovalId: number,
42
- patch: PatchSlaApprovalTableInput,
43
- updatedBy?: number | null
44
- ): Promise<void> {
45
- if (!Number.isFinite(sourceApprovalId)) {
46
- return;
47
- }
48
- try {
49
- const setPayload: Record<string, unknown> = {
50
- ...stripUndefined(patch as Record<string, unknown>),
51
- updated_at: new Date()
52
- };
53
- if (updatedBy != null) {
54
- setPayload.updated_by = updatedBy;
55
- }
56
- await manager.getRepository(ServiceSlaApproval).update(
57
- { source_approval_id: sourceApprovalId, is_deleted: false },
58
- setPayload as any
59
- );
60
- } catch {
61
- // non-fatal
62
- }
63
- }
64
-
65
- static async patchSlaRequestByNativeRequestId(
66
- manager: EntityManager,
67
- nativeRequestId: number,
68
- patch: PatchSlaRequestTableInput,
69
- updatedBy?: number | null
70
- ): Promise<void> {
71
- if (!Number.isFinite(nativeRequestId) || nativeRequestId < 1) {
72
- return;
73
- }
74
- try {
75
- const setPayload: Record<string, unknown> = {
76
- ...stripUndefined(patch as Record<string, unknown>),
77
- updated_at: new Date()
78
- };
79
- if (updatedBy != null) {
80
- setPayload.updated_by = updatedBy;
81
- }
82
- await manager.getRepository(SlaRequest).update(
83
- { request_id: nativeRequestId, is_deleted: false },
84
- setPayload as any
85
- );
86
- } catch {
87
- // non-fatal
88
- }
89
- }
90
- }
1
+ import { EntityManager } from "typeorm";
2
+ import { ServiceSlaApproval } from "../models/ServiceSlaApprovalModel";
3
+ import { SlaRequest, SlaRequestStatus } from "../models/SlaRequestModel";
4
+
5
+ export type PatchSlaApprovalTableInput = Partial<{
6
+ approval_status: string;
7
+ approver_user_id: number | null;
8
+ approver_role_id: number | null;
9
+ department_id: number | null;
10
+ section_id: number | null;
11
+ level: number;
12
+ delegate_user_id: number | null;
13
+ approved_by: number | null;
14
+ comment: string | null;
15
+ }>;
16
+
17
+ export type PatchSlaRequestTableInput = Partial<{
18
+ status: SlaRequestStatus | string;
19
+ workflow_execution_id: string | null;
20
+ }>;
21
+
22
+ function stripUndefined<T extends Record<string, unknown>>(obj: T): Partial<T> {
23
+ const out: Partial<T> = {};
24
+ for (const key of Object.keys(obj)) {
25
+ const v = obj[key];
26
+ if (v !== undefined) {
27
+ (out as Record<string, unknown>)[key] = v;
28
+ }
29
+ }
30
+ return out;
31
+ }
32
+
33
+ /**
34
+ * TypeORM patches for `sla_approval` and `sla_requests` by the keys used at insert time
35
+ * (`source_approval_id` and native `request_id`). Safe to call from any service that shares the DB;
36
+ * failures are swallowed so missing SLA rows never block business transactions.
37
+ */
38
+ export class SlaTableSyncService {
39
+ static async patchSlaApprovalBySourceApprovalId(
40
+ manager: EntityManager,
41
+ sourceApprovalId: number,
42
+ patch: PatchSlaApprovalTableInput,
43
+ updatedBy?: number | null
44
+ ): Promise<void> {
45
+ if (!Number.isFinite(sourceApprovalId)) {
46
+ return;
47
+ }
48
+ try {
49
+ const setPayload: Record<string, unknown> = {
50
+ ...stripUndefined(patch as Record<string, unknown>),
51
+ updated_at: new Date()
52
+ };
53
+ if (updatedBy != null) {
54
+ setPayload.updated_by = updatedBy;
55
+ }
56
+ await manager.getRepository(ServiceSlaApproval).update(
57
+ { source_approval_id: sourceApprovalId, is_deleted: false },
58
+ setPayload as any
59
+ );
60
+ } catch {
61
+ // non-fatal
62
+ }
63
+ }
64
+
65
+ static async patchSlaRequestByNativeRequestId(
66
+ manager: EntityManager,
67
+ nativeRequestId: number,
68
+ patch: PatchSlaRequestTableInput,
69
+ updatedBy?: number | null
70
+ ): Promise<void> {
71
+ if (!Number.isFinite(nativeRequestId) || nativeRequestId < 1) {
72
+ return;
73
+ }
74
+ try {
75
+ const setPayload: Record<string, unknown> = {
76
+ ...stripUndefined(patch as Record<string, unknown>),
77
+ updated_at: new Date()
78
+ };
79
+ if (updatedBy != null) {
80
+ setPayload.updated_by = updatedBy;
81
+ }
82
+ await manager.getRepository(SlaRequest).update(
83
+ { request_id: nativeRequestId, is_deleted: false },
84
+ setPayload as any
85
+ );
86
+ } catch {
87
+ // non-fatal
88
+ }
89
+ }
90
+ }
@@ -1,37 +0,0 @@
1
- import type { EntityManager } from 'typeorm';
2
- import { CancellationMessageType } from '../models/CancellationChatModel';
3
- import { CancellationWorkFlowStatus } from '../models/CancellationWorkflowModel';
4
- export type CancellationWorkflowRowInput = {
5
- request_id: number;
6
- service_id?: number | null;
7
- sub_service_id?: number | null;
8
- content: string;
9
- content_ar?: string | null;
10
- status: CancellationWorkFlowStatus;
11
- status_ar?: string | null;
12
- user_id?: number | null;
13
- role_id?: number | null;
14
- department_id?: number | null;
15
- section_id?: number | null;
16
- step_order?: number | null;
17
- created_by?: number | null;
18
- };
19
- export type CancellationChatRowInput = {
20
- request_id: number;
21
- service_id?: number | null;
22
- sub_service_id?: number | null;
23
- user_id: number;
24
- role_id?: number | null;
25
- message: string;
26
- message_ar?: string | null;
27
- messageType?: CancellationMessageType;
28
- status?: string | null;
29
- status_ar?: string | null;
30
- created_by?: number | string | null;
31
- };
32
- /** Force-persist Arabic workflow columns (guards against stale TypeORM entity metadata). */
33
- export declare function patchCancellationWorkflowArabic(manager: EntityManager, workflowId: number, contentAr: string | null, statusAr: string | null): Promise<void>;
34
- /** Force-persist Arabic chat columns (guards against stale TypeORM entity metadata). */
35
- export declare function patchCancellationChatArabic(manager: EntityManager, chatId: number, messageAr: string | null, statusAr: string | null): Promise<void>;
36
- export declare function insertCancellationWorkflowRow(manager: EntityManager, input: CancellationWorkflowRowInput): Promise<number>;
37
- export declare function insertCancellationChatRow(manager: EntityManager, input: CancellationChatRowInput): Promise<number>;
@@ -1,77 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.patchCancellationWorkflowArabic = patchCancellationWorkflowArabic;
4
- exports.patchCancellationChatArabic = patchCancellationChatArabic;
5
- exports.insertCancellationWorkflowRow = insertCancellationWorkflowRow;
6
- exports.insertCancellationChatRow = insertCancellationChatRow;
7
- const CancellationChatModel_1 = require("../models/CancellationChatModel");
8
- const CancellationWorkflowModel_1 = require("../models/CancellationWorkflowModel");
9
- const workflow_chat_i18n_1 = require("../i18n/workflow-chat-i18n");
10
- function resolveWorkflowRowId(insertResult) {
11
- const id = insertResult.raw?.[0]?.id ?? insertResult.identifiers?.[0]?.id;
12
- if (!id) {
13
- throw new Error('Failed to insert cancellation workflow row');
14
- }
15
- return id;
16
- }
17
- function resolveChatRowId(insertResult) {
18
- const id = insertResult.raw?.[0]?.id ?? insertResult.identifiers?.[0]?.id;
19
- if (!id) {
20
- throw new Error('Failed to insert cancellation chat row');
21
- }
22
- return id;
23
- }
24
- /** Force-persist Arabic workflow columns (guards against stale TypeORM entity metadata). */
25
- async function patchCancellationWorkflowArabic(manager, workflowId, contentAr, statusAr) {
26
- await manager.query(`UPDATE cancellation_workflows
27
- SET content_ar = $1,
28
- status_ar = $2,
29
- updated_at = CURRENT_TIMESTAMP
30
- WHERE id = $3`, [contentAr, statusAr, workflowId]);
31
- }
32
- /** Force-persist Arabic chat columns (guards against stale TypeORM entity metadata). */
33
- async function patchCancellationChatArabic(manager, chatId, messageAr, statusAr) {
34
- await manager.query(`UPDATE cancellation_chats
35
- SET message_ar = $1,
36
- status_ar = $2,
37
- updated_at = CURRENT_TIMESTAMP
38
- WHERE id = $3`, [messageAr, statusAr, chatId]);
39
- }
40
- async function insertCancellationWorkflowRow(manager, input) {
41
- const contentAr = input.content_ar ?? null;
42
- const statusAr = input.status_ar ?? (0, workflow_chat_i18n_1.resolveWorkflowStatusAr)(input.status);
43
- const insertResult = await manager
44
- .createQueryBuilder()
45
- .insert()
46
- .into(CancellationWorkflowModel_1.CancellationWorkFlow)
47
- .values({
48
- ...input,
49
- content_ar: contentAr,
50
- status_ar: statusAr,
51
- })
52
- .returning('id')
53
- .execute();
54
- const id = resolveWorkflowRowId(insertResult);
55
- await patchCancellationWorkflowArabic(manager, id, contentAr, statusAr);
56
- return id;
57
- }
58
- async function insertCancellationChatRow(manager, input) {
59
- const messageAr = input.message_ar ?? null;
60
- const statusAr = input.status_ar ?? (0, workflow_chat_i18n_1.resolveChatStatusAr)(input.status ?? null);
61
- const messageType = input.messageType ?? CancellationChatModel_1.CancellationMessageType.TEXT;
62
- const insertResult = await manager
63
- .createQueryBuilder()
64
- .insert()
65
- .into(CancellationChatModel_1.CancellationRequestChat)
66
- .values({
67
- ...input,
68
- message_ar: messageAr,
69
- status_ar: statusAr,
70
- messageType,
71
- })
72
- .returning('id')
73
- .execute();
74
- const id = resolveChatRowId(insertResult);
75
- await patchCancellationChatArabic(manager, id, messageAr, statusAr);
76
- return id;
77
- }