@platform-modules/civil-aviation-authority 2.3.330 → 2.3.333

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.
@@ -0,0 +1,33 @@
1
+ import { Column, Entity, Index, JoinColumn, ManyToOne } from "typeorm";
2
+ import { BaseModel } from "./BaseModel";
3
+ import {
4
+ AnnualTrainingPlanDepartmentPlan,
5
+ AnnualTrainingPlanDepartmentPlanStatus
6
+ } from "./AnnualTrainingPlanDepartmentPlanModel";
7
+
8
+ @Entity({ name: "annual_training_plan_department_plan_decisions" })
9
+ @Index(["department_plan_id", "approval_level"])
10
+ export class AnnualTrainingPlanDepartmentPlanDecision extends BaseModel {
11
+ @Column({ type: "integer", nullable: false })
12
+ department_plan_id: number;
13
+
14
+ @Column({ type: "integer", nullable: false })
15
+ approval_level: number;
16
+
17
+ @Column({
18
+ type: "enum",
19
+ enum: AnnualTrainingPlanDepartmentPlanStatus,
20
+ nullable: false
21
+ })
22
+ status: AnnualTrainingPlanDepartmentPlanStatus;
23
+
24
+ @Column({ type: "text", nullable: true })
25
+ comment: string | null;
26
+
27
+ @Column({ type: "integer", nullable: true })
28
+ decided_by: number | null;
29
+
30
+ @ManyToOne(() => AnnualTrainingPlanDepartmentPlan, { onDelete: "CASCADE" })
31
+ @JoinColumn({ name: "department_plan_id" })
32
+ department_plan: AnnualTrainingPlanDepartmentPlan;
33
+ }
@@ -0,0 +1,31 @@
1
+ import { Column, Entity, Index, JoinColumn, ManyToOne } from "typeorm";
2
+ import { BaseModel } from "./BaseModel";
3
+ import { AnnualTrainingPlanRequest } from "./AnnualTrainingPlanRequestModel";
4
+
5
+ export enum AnnualTrainingPlanDepartmentPlanStatus {
6
+ PENDING = "Pending",
7
+ APPROVED = "Approved",
8
+ REJECTED = "Rejected"
9
+ }
10
+
11
+ @Entity({ name: "annual_training_plan_department_plans" })
12
+ @Index(["request_id"])
13
+ export class AnnualTrainingPlanDepartmentPlan extends BaseModel {
14
+ @Column({ type: "integer", nullable: false })
15
+ request_id: number;
16
+
17
+ @Column({ type: "integer", nullable: false })
18
+ department_id: number;
19
+
20
+ @Column({
21
+ type: "enum",
22
+ enum: AnnualTrainingPlanDepartmentPlanStatus,
23
+ default: AnnualTrainingPlanDepartmentPlanStatus.PENDING,
24
+ nullable: false
25
+ })
26
+ status: AnnualTrainingPlanDepartmentPlanStatus;
27
+
28
+ @ManyToOne(() => AnnualTrainingPlanRequest, { onDelete: "CASCADE" })
29
+ @JoinColumn({ name: "request_id" })
30
+ request: AnnualTrainingPlanRequest;
31
+ }
@@ -0,0 +1,71 @@
1
+ import { Column, Entity, Index, JoinColumn, ManyToOne, Unique } from "typeorm";
2
+ import { BaseModel } from "./BaseModel";
3
+ import {
4
+ AnnualTrainingPlanPlace,
5
+ AnnualTrainingPlanRequest
6
+ } from "./AnnualTrainingPlanRequestModel";
7
+
8
+ @Entity({ name: "annual_training_plan_items" })
9
+ @Unique(["request_id", "row_number"])
10
+ @Index(["request_id"])
11
+ @Index(["department_id"])
12
+ export class AnnualTrainingPlanItem extends BaseModel {
13
+ @Column({ type: "integer", nullable: false })
14
+ request_id: number;
15
+
16
+ @Column({ type: "integer", nullable: true })
17
+ department_plan_id: number | null;
18
+
19
+ @Column({ type: "integer", nullable: false })
20
+ row_number: number;
21
+
22
+ @Column({ type: "integer", nullable: false })
23
+ department_id: number;
24
+
25
+ @Column({ type: "integer", nullable: true })
26
+ section_id: number | null;
27
+
28
+ @Column({ type: "varchar", length: 255, nullable: false })
29
+ course_name: string;
30
+
31
+ @Column({ type: "integer", nullable: false })
32
+ no_of_participants: number;
33
+
34
+ @Column({ type: "decimal", precision: 10, scale: 2, nullable: false })
35
+ course_cost: number;
36
+
37
+ @Column({ type: "decimal", precision: 14, scale: 2, nullable: false })
38
+ total_cost: number;
39
+
40
+ @Column({ type: "varchar", length: 500, nullable: false })
41
+ proposed_implementation_date: string;
42
+
43
+ @Column({ type: "text", nullable: false })
44
+ description: string;
45
+
46
+ @Column({ type: "text", nullable: false })
47
+ reason: string;
48
+
49
+ @Column({ type: "varchar", length: 255, nullable: true })
50
+ job_competency: string | null;
51
+
52
+ @Column({
53
+ type: "enum",
54
+ enum: AnnualTrainingPlanPlace,
55
+ nullable: true
56
+ })
57
+ place: AnnualTrainingPlanPlace | null;
58
+
59
+ @Column({ type: "varchar", length: 255, nullable: true })
60
+ location: string | null;
61
+
62
+ @Column({ type: "jsonb", nullable: true })
63
+ name_of_participants: string[] | null;
64
+
65
+ @Column({ type: "jsonb", nullable: true })
66
+ employee_list: any[] | null;
67
+
68
+ @ManyToOne(() => AnnualTrainingPlanRequest, { onDelete: "CASCADE" })
69
+ @JoinColumn({ name: "request_id" })
70
+ request: AnnualTrainingPlanRequest;
71
+ }
@@ -14,6 +14,17 @@ export enum AnnualTrainingPlanPlace {
14
14
  OUTSIDE = "Outside"
15
15
  }
16
16
 
17
+ export enum AnnualTrainingPlanImportStatus {
18
+ VALIDATED = "Validated",
19
+ IMPORTED = "Imported",
20
+ FAILED = "Failed"
21
+ }
22
+
23
+ export enum AnnualTrainingPlanSubmissionSource {
24
+ EXCEL = "Excel",
25
+ DIRECT = "Direct"
26
+ }
27
+
17
28
  @Entity({ name: "annual_training_plan_requests" })
18
29
  export class AnnualTrainingPlanRequest extends BaseModel {
19
30
  @Column({ type: "integer", nullable: true })
@@ -34,40 +45,9 @@ export class AnnualTrainingPlanRequest extends BaseModel {
34
45
  @Column({ type: "integer", nullable: false })
35
46
  user_id: number;
36
47
 
37
- @Column({ type: "varchar", length: 255, nullable: false })
38
- course_name: string;
39
-
40
- @Column({ type: "integer", nullable: false })
41
- no_of_participants: number;
42
-
43
- @Column({ type: "decimal", precision: 10, scale: 2, nullable: false })
44
- course_cost: number;
45
-
46
- @Column({ type: "decimal", precision: 10, scale: 2, nullable: false })
48
+ @Column({ type: "decimal", precision: 14, scale: 2, nullable: false, default: 0 })
47
49
  total_cost: number;
48
50
 
49
- @Column({ type: "varchar", length: 500, nullable: false, default: "" })
50
- proposed_implementation_date: string;
51
-
52
- @Column({ type: "text", nullable: false })
53
- description: string;
54
-
55
- @Column({
56
- type: "enum",
57
- enum: AnnualTrainingPlanPlace,
58
- nullable: true
59
- })
60
- place: AnnualTrainingPlanPlace | null;
61
-
62
- @Column({ type: "varchar", length: 255, nullable: true })
63
- location: string | null;
64
-
65
- @Column({ type: "text", nullable: false })
66
- reason: string;
67
-
68
- @Column({ type: "jsonb", nullable: true })
69
- employee_list: any[] | null; // List of employees for training attendance
70
-
71
51
  @Column({
72
52
  type: "enum",
73
53
  enum: AnnualTrainingPlanRequestStatus,
@@ -89,65 +69,88 @@ export class AnnualTrainingPlanRequest extends BaseModel {
89
69
  workflow_execution_id: string | null;
90
70
 
91
71
  @Column({ type: "varchar", length: 255, nullable: true })
92
- job_competency: string | null;
72
+ directarate: string | null;
73
+
74
+ @Column({ type: "varchar", length: 255, nullable: true })
75
+ plan_name: string | null;
76
+
77
+ @Column({ type: "varchar", length: 30, nullable: true, unique: true })
78
+ plan_number: string | null;
79
+
80
+ @Column({ type: "integer", nullable: true })
81
+ plan_year: number | null;
93
82
 
94
- @Column({ type: "jsonb", nullable: true })
95
- name_of_participants: string[] | null;
83
+ @Column({ type: "varchar", length: 1000, nullable: true })
84
+ source_file_url: string | null;
96
85
 
97
86
  @Column({ type: "varchar", length: 255, nullable: true })
98
- directarate: string | null;
87
+ source_file_name: string | null;
88
+
89
+ @Column({ type: "integer", nullable: false, default: 0 })
90
+ total_departments: number;
91
+
92
+ @Column({ type: "integer", nullable: false, default: 0 })
93
+ total_courses: number;
94
+
95
+ @Column({ type: "integer", nullable: false, default: 0 })
96
+ total_participants: number;
97
+
98
+ @Column({
99
+ type: "enum",
100
+ enum: AnnualTrainingPlanImportStatus,
101
+ nullable: true
102
+ })
103
+ import_status: AnnualTrainingPlanImportStatus | null;
104
+
105
+ @Column({
106
+ type: "enum",
107
+ enum: AnnualTrainingPlanSubmissionSource,
108
+ nullable: true
109
+ })
110
+ submission_source: AnnualTrainingPlanSubmissionSource | null;
111
+
112
+ @Column({ type: "varchar", length: 20, nullable: true, unique: true })
113
+ reference_number: string | null;
99
114
 
100
115
  constructor(
101
116
  user_id: number,
102
- course_name: string,
103
- no_of_participants: number,
104
- course_cost: number,
105
- total_cost: number,
106
- proposed_implementation_date: string,
107
- description: string,
108
- place: AnnualTrainingPlanPlace | null,
109
- reason: string,
110
117
  status: AnnualTrainingPlanRequestStatus = AnnualTrainingPlanRequestStatus.PENDING,
111
118
  service_id?: number | null,
112
119
  sub_service_id?: number | null,
113
120
  req_user_department_id?: number | null,
114
121
  req_user_section_id?: number | null,
115
122
  req_user_position_id?: number | null,
116
- location?: string | null,
117
- employee_list?: any[] | null,
118
123
  reviewer_user_id?: number | null,
119
124
  assigned_to_user_id?: number | null,
120
125
  assigned_at?: Date | null,
121
126
  workflow_execution_id?: string | null,
122
- job_competency?: string | null,
123
- name_of_participants?: string[] | null,
124
127
  directarate?: string | null
125
128
  ) {
126
129
  super();
127
130
  this.user_id = user_id;
128
- this.course_name = course_name;
129
- this.no_of_participants = no_of_participants;
130
- this.course_cost = course_cost;
131
- this.total_cost = total_cost;
132
- this.proposed_implementation_date = proposed_implementation_date;
133
- this.description = description;
134
- this.place = place;
135
- this.reason = reason;
131
+ this.total_cost = 0;
136
132
  this.status = status;
137
133
  this.service_id = service_id || null;
138
134
  this.sub_service_id = sub_service_id || null;
139
135
  this.req_user_department_id = req_user_department_id || null;
140
136
  this.req_user_section_id = req_user_section_id || null;
141
137
  this.req_user_position_id = req_user_position_id || null;
142
- this.location = location || null;
143
- this.employee_list = employee_list || null;
144
138
  this.reviewer_user_id = reviewer_user_id || null;
145
139
  this.assigned_to_user_id = assigned_to_user_id || null;
146
140
  this.assigned_at = assigned_at || null;
147
141
  this.workflow_execution_id = workflow_execution_id || null;
148
- this.job_competency = job_competency ?? null;
149
- this.name_of_participants = name_of_participants ?? null;
150
142
  this.directarate = directarate ?? null;
143
+ this.plan_name = null;
144
+ this.plan_number = null;
145
+ this.plan_year = null;
146
+ this.source_file_url = null;
147
+ this.source_file_name = null;
148
+ this.total_departments = 0;
149
+ this.total_courses = 0;
150
+ this.total_participants = 0;
151
+ this.import_status = null;
152
+ this.submission_source = null;
153
+ this.reference_number = null;
151
154
  }
152
155
  }
153
156
 
@@ -1,81 +1,81 @@
1
- import { Column, Entity } from "typeorm";
2
- import { BaseModel } from "./BaseModel";
3
-
4
- export enum TrainingRoomBookingWorkFlowStatus {
5
- COMPLETED = "Completed",
6
- NOT_YET_STARTED = "Not Yet Started",
7
- PENDING = "Pending",
8
- IN_PROGRESS = "In Progress",
9
- REJECTED = "Rejected"
10
- }
11
-
12
- @Entity({ name: "training_room_booking_workflows" })
13
- export class TrainingRoomBookingWorkFlow extends BaseModel {
14
- @Column({ type: "int", nullable: false })
15
- request_id: number;
16
-
17
- @Column({ type: "integer", nullable: true })
18
- service_id: number | null;
19
-
20
- @Column({ type: "integer", nullable: true })
21
- sub_service_id: number | null;
22
-
23
- @Column({ type: "int", nullable: true })
24
- order: number | null;
25
-
26
- @Column({ type: "varchar", length: 255, nullable: false })
27
- content: string;
28
- @Column({ type: "varchar", length: 500, nullable: true })
29
- content_ar: string | null;
30
-
31
-
32
- @Column({ type: "integer", nullable: true })
33
- approver_role_id: number | null;
34
-
35
- @Column({ type: "integer", nullable: true })
36
- approver_user_id: number | null;
37
-
38
- @Column({ type: "integer", nullable: true })
39
- approved_by: number | null;
40
-
41
- @Column({ type: "integer", nullable: true })
42
- department_id: number | null;
43
-
44
- @Column({ type: "integer", nullable: true })
45
- section_id: number | null;
46
-
47
- @Column({
48
- type: "enum",
49
- enum: TrainingRoomBookingWorkFlowStatus,
50
- default: TrainingRoomBookingWorkFlowStatus.PENDING,
51
- nullable: false
52
- })
53
- status: TrainingRoomBookingWorkFlowStatus;
54
- @Column({ type: "varchar", length: 100, nullable: true })
55
- status_ar: string | null;
56
-
57
-
58
- constructor(
59
- request_id: number,
60
- content: string,
61
- status: TrainingRoomBookingWorkFlowStatus,
62
- service_id?: number | null,
63
- sub_service_id?: number | null,
64
- order?: number,
65
- approver_role_id?: number | null,
66
- approver_user_id?: number | null,
67
- approved_by?: number | null
68
- ) {
69
- super();
70
- this.request_id = request_id;
71
- this.service_id = service_id || null;
72
- this.sub_service_id = sub_service_id || null;
73
- this.content = content;
74
- this.status = status;
75
- this.order = order || null;
76
- this.approver_role_id = approver_role_id || null;
77
- this.approver_user_id = approver_user_id || null;
78
- this.approved_by = approved_by || null;
79
- }
80
- }
81
-
1
+ import { Column, Entity } from "typeorm";
2
+ import { BaseModel } from "./BaseModel";
3
+
4
+ export enum TrainingRoomBookingWorkFlowStatus {
5
+ COMPLETED = "Completed",
6
+ NOT_YET_STARTED = "Not Yet Started",
7
+ PENDING = "Pending",
8
+ IN_PROGRESS = "In Progress",
9
+ REJECTED = "Rejected"
10
+ }
11
+
12
+ @Entity({ name: "training_room_booking_workflows" })
13
+ export class TrainingRoomBookingWorkFlow extends BaseModel {
14
+ @Column({ type: "int", nullable: false })
15
+ request_id: number;
16
+
17
+ @Column({ type: "integer", nullable: true })
18
+ service_id: number | null;
19
+
20
+ @Column({ type: "integer", nullable: true })
21
+ sub_service_id: number | null;
22
+
23
+ @Column({ type: "int", nullable: true })
24
+ order: number | null;
25
+
26
+ @Column({ type: "varchar", length: 255, nullable: false })
27
+ content: string;
28
+ @Column({ type: "varchar", length: 500, nullable: true })
29
+ content_ar: string | null;
30
+
31
+
32
+ @Column({ type: "integer", nullable: true })
33
+ approver_role_id: number | null;
34
+
35
+ @Column({ type: "integer", nullable: true })
36
+ approver_user_id: number | null;
37
+
38
+ @Column({ type: "integer", nullable: true })
39
+ approved_by: number | null;
40
+
41
+ @Column({ type: "integer", nullable: true })
42
+ department_id: number | null;
43
+
44
+ @Column({ type: "integer", nullable: true })
45
+ section_id: number | null;
46
+
47
+ @Column({
48
+ type: "enum",
49
+ enum: TrainingRoomBookingWorkFlowStatus,
50
+ default: TrainingRoomBookingWorkFlowStatus.PENDING,
51
+ nullable: false
52
+ })
53
+ status: TrainingRoomBookingWorkFlowStatus;
54
+ @Column({ type: "varchar", length: 100, nullable: true })
55
+ status_ar: string | null;
56
+
57
+
58
+ constructor(
59
+ request_id: number,
60
+ content: string,
61
+ status: TrainingRoomBookingWorkFlowStatus,
62
+ service_id?: number | null,
63
+ sub_service_id?: number | null,
64
+ order?: number,
65
+ approver_role_id?: number | null,
66
+ approver_user_id?: number | null,
67
+ approved_by?: number | null
68
+ ) {
69
+ super();
70
+ this.request_id = request_id;
71
+ this.service_id = service_id || null;
72
+ this.sub_service_id = sub_service_id || null;
73
+ this.content = content;
74
+ this.status = status;
75
+ this.order = order || null;
76
+ this.approver_role_id = approver_role_id || null;
77
+ this.approver_user_id = approver_user_id || null;
78
+ this.approved_by = approved_by || null;
79
+ }
80
+ }
81
+
package/src/scripts.ts CHANGED
@@ -1,10 +1,20 @@
1
- import { AppDataSource } from './data-source';
2
-
3
- AppDataSource.initialize()
4
- .then(() => {
5
- console.log('✅ Database schema synchronized successfully.');
6
- })
7
- .catch((error: any) => {
8
- console.error('❌ Error during schema synchronization:', error);
9
- process.exit(1);
10
- });
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
+