@platform-modules/civil-aviation-authority 2.3.299 → 2.3.301

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
@@ -2,17 +2,11 @@ DB_HOST=164.52.222.169
2
2
  DB_PORT=5432
3
3
  DB_USER=postgres_admin_user
4
4
  DB_PASS=pg_admin_user_pwd_caa_fa_$%^&OIukhjgcvbn
5
- DB_NAME=CAA_DEV
5
+ DB_NAME=CAA
6
6
 
7
7
 
8
8
  # DB_HOST=localhost
9
9
  # DB_PORT=5432
10
10
  # DB_USER=postgres
11
11
  # DB_PASS=stevejobs
12
- # DB_NAME=CAA
13
-
14
- # DB_HOST=10.44.3.201
15
- # DB_PORT=5432
16
- # DB_USER=appuser
17
- # DB_PASS=HamaCaa7489
18
- # DB_NAME=caa_prd_db
12
+ # DB_NAME=CAA
@@ -80,7 +80,12 @@ __decorate([
80
80
  __metadata("design:type", String)
81
81
  ], FollowUpReportRequests.prototype, "subject", void 0);
82
82
  __decorate([
83
- (0, typeorm_1.Column)({ type: 'varchar', length: 100, nullable: false }),
83
+ (0, typeorm_1.Column)({
84
+ type: 'varchar',
85
+ length: 100,
86
+ nullable: false,
87
+ default: FollowUpReportSubjectClassification.NORMAL,
88
+ }),
84
89
  __metadata("design:type", String)
85
90
  ], FollowUpReportRequests.prototype, "subject_classification", void 0);
86
91
  __decorate([
@@ -15,7 +15,9 @@ export declare class StudyLeaveWorkFlow extends BaseModel {
15
15
  approver_role_id: number | null;
16
16
  approver_user_id: number | null;
17
17
  approved_by: number | null;
18
+ department_id: number | null;
19
+ section_id: number | null;
18
20
  status: StudyLeaveWorkFlowStatus;
19
21
  status_ar: string | null;
20
- constructor(request_id: number, content: string, status: StudyLeaveWorkFlowStatus, service_id?: number | null, sub_service_id?: number | null, order?: number, approver_role_id?: number | null, approver_user_id?: number | null, approved_by?: number | null);
22
+ constructor(request_id: number, content: string, status: StudyLeaveWorkFlowStatus, service_id?: number | null, sub_service_id?: number | null, order?: number, approver_role_id?: number | null, approver_user_id?: number | null, approved_by?: number | null, department_id?: number | null, section_id?: number | null);
21
23
  }
@@ -20,7 +20,7 @@ var StudyLeaveWorkFlowStatus;
20
20
  StudyLeaveWorkFlowStatus["REJECTED"] = "Rejected";
21
21
  })(StudyLeaveWorkFlowStatus || (exports.StudyLeaveWorkFlowStatus = StudyLeaveWorkFlowStatus = {}));
22
22
  let StudyLeaveWorkFlow = class StudyLeaveWorkFlow extends BaseModel_1.BaseModel {
23
- constructor(request_id, content, status, service_id, sub_service_id, order, approver_role_id, approver_user_id, approved_by) {
23
+ constructor(request_id, content, status, service_id, sub_service_id, order, approver_role_id, approver_user_id, approved_by, department_id, section_id) {
24
24
  super();
25
25
  this.request_id = request_id;
26
26
  this.service_id = service_id || null;
@@ -31,6 +31,8 @@ let StudyLeaveWorkFlow = class StudyLeaveWorkFlow extends BaseModel_1.BaseModel
31
31
  this.approver_role_id = approver_role_id || null;
32
32
  this.approver_user_id = approver_user_id || null;
33
33
  this.approved_by = approved_by || null;
34
+ this.department_id = department_id || null;
35
+ this.section_id = section_id || null;
34
36
  }
35
37
  };
36
38
  exports.StudyLeaveWorkFlow = StudyLeaveWorkFlow;
@@ -70,6 +72,14 @@ __decorate([
70
72
  (0, typeorm_1.Column)({ type: "integer", nullable: true }),
71
73
  __metadata("design:type", Object)
72
74
  ], StudyLeaveWorkFlow.prototype, "approved_by", void 0);
75
+ __decorate([
76
+ (0, typeorm_1.Column)({ type: "integer", nullable: true }),
77
+ __metadata("design:type", Object)
78
+ ], StudyLeaveWorkFlow.prototype, "department_id", void 0);
79
+ __decorate([
80
+ (0, typeorm_1.Column)({ type: "integer", nullable: true }),
81
+ __metadata("design:type", Object)
82
+ ], StudyLeaveWorkFlow.prototype, "section_id", void 0);
73
83
  __decorate([
74
84
  (0, typeorm_1.Column)({
75
85
  type: "enum",
@@ -85,5 +95,5 @@ __decorate([
85
95
  ], StudyLeaveWorkFlow.prototype, "status_ar", void 0);
86
96
  exports.StudyLeaveWorkFlow = StudyLeaveWorkFlow = __decorate([
87
97
  (0, typeorm_1.Entity)({ name: "study_leave_workflows" }),
88
- __metadata("design:paramtypes", [Number, String, String, Object, Object, Number, Object, Object, Object])
98
+ __metadata("design:paramtypes", [Number, String, String, Object, Object, Number, Object, Object, Object, Object, Object])
89
99
  ], StudyLeaveWorkFlow);
@@ -15,7 +15,9 @@ export declare class TrainingWorkFlow extends BaseModel {
15
15
  approver_role_id: number | null;
16
16
  approver_user_id: number | null;
17
17
  approved_by: number | null;
18
+ department_id: number | null;
19
+ section_id: number | null;
18
20
  status: TrainingWorkFlowStatus;
19
21
  status_ar: string | null;
20
- constructor(request_id: number, content: string, status: TrainingWorkFlowStatus, service_id?: number | null, sub_service_id?: number | null, order?: number, approver_role_id?: number | null, approver_user_id?: number | null, approved_by?: number | null);
22
+ constructor(request_id: number, content: string, status: TrainingWorkFlowStatus, service_id?: number | null, sub_service_id?: number | null, order?: number, approver_role_id?: number | null, approver_user_id?: number | null, approved_by?: number | null, department_id?: number | null, section_id?: number | null);
21
23
  }
@@ -20,7 +20,7 @@ var TrainingWorkFlowStatus;
20
20
  TrainingWorkFlowStatus["REJECTED"] = "Rejected";
21
21
  })(TrainingWorkFlowStatus || (exports.TrainingWorkFlowStatus = TrainingWorkFlowStatus = {}));
22
22
  let TrainingWorkFlow = class TrainingWorkFlow extends BaseModel_1.BaseModel {
23
- constructor(request_id, content, status, service_id, sub_service_id, order, approver_role_id, approver_user_id, approved_by) {
23
+ constructor(request_id, content, status, service_id, sub_service_id, order, approver_role_id, approver_user_id, approved_by, department_id, section_id) {
24
24
  super();
25
25
  this.request_id = request_id;
26
26
  this.service_id = service_id || null;
@@ -31,6 +31,8 @@ let TrainingWorkFlow = class TrainingWorkFlow extends BaseModel_1.BaseModel {
31
31
  this.approver_role_id = approver_role_id || null;
32
32
  this.approver_user_id = approver_user_id || null;
33
33
  this.approved_by = approved_by || null;
34
+ this.department_id = department_id || null;
35
+ this.section_id = section_id || null;
34
36
  }
35
37
  };
36
38
  exports.TrainingWorkFlow = TrainingWorkFlow;
@@ -70,6 +72,14 @@ __decorate([
70
72
  (0, typeorm_1.Column)({ type: "integer", nullable: true }),
71
73
  __metadata("design:type", Object)
72
74
  ], TrainingWorkFlow.prototype, "approved_by", void 0);
75
+ __decorate([
76
+ (0, typeorm_1.Column)({ type: "integer", nullable: true }),
77
+ __metadata("design:type", Object)
78
+ ], TrainingWorkFlow.prototype, "department_id", void 0);
79
+ __decorate([
80
+ (0, typeorm_1.Column)({ type: "integer", nullable: true }),
81
+ __metadata("design:type", Object)
82
+ ], TrainingWorkFlow.prototype, "section_id", void 0);
73
83
  __decorate([
74
84
  (0, typeorm_1.Column)({
75
85
  type: "enum",
@@ -85,5 +95,5 @@ __decorate([
85
95
  ], TrainingWorkFlow.prototype, "status_ar", void 0);
86
96
  exports.TrainingWorkFlow = TrainingWorkFlow = __decorate([
87
97
  (0, typeorm_1.Entity)({ name: "training_workflows" }),
88
- __metadata("design:paramtypes", [Number, String, String, Object, Object, Number, Object, Object, Object])
98
+ __metadata("design:paramtypes", [Number, String, String, Object, Object, Number, Object, Object, Object, Object, Object])
89
99
  ], TrainingWorkFlow);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platform-modules/civil-aviation-authority",
3
- "version": "2.3.299",
3
+ "version": "2.3.301",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {
@@ -1,30 +1,51 @@
1
- require('dotenv').config();
2
1
  const fs = require('fs');
3
2
  const path = require('path');
4
3
  const { Client } = require('pg');
5
4
 
6
- async function main() {
7
- const sqlPath = path.join(__dirname, '..', 'sql', 'fix_maintenance_subject_classification_enum_2026_07.sql');
8
- const sql = fs.readFileSync(sqlPath, 'utf8');
5
+ function loadEnv() {
6
+ try {
7
+ require('dotenv').config({ path: path.join(__dirname, '..', '.env') });
8
+ } catch {
9
+ // dotenv is optional at runtime if env vars are already set
10
+ }
11
+ }
9
12
 
10
- const client = new Client({
13
+ function getDbConfig() {
14
+ const config = {
11
15
  host: process.env.DB_HOST,
12
16
  port: Number(process.env.DB_PORT || 5432),
13
17
  user: process.env.DB_USER,
14
18
  password: process.env.DB_PASS,
15
19
  database: process.env.DB_NAME,
16
- });
20
+ };
21
+
22
+ const missing = ['DB_HOST', 'DB_USER', 'DB_PASS', 'DB_NAME'].filter((key) => !process.env[key]);
23
+ if (missing.length > 0) {
24
+ throw new Error(
25
+ `Missing database env vars in shared_models/.env: ${missing.join(', ')}`,
26
+ );
27
+ }
28
+
29
+ return config;
30
+ }
31
+
32
+ async function main() {
33
+ loadEnv();
34
+
35
+ const sqlPath = path.join(__dirname, '..', 'sql', 'fix_maintenance_subject_classification_enum_2026_07.sql');
36
+ const sql = fs.readFileSync(sqlPath, 'utf8');
37
+ const client = new Client(getDbConfig());
17
38
 
18
39
  await client.connect();
19
40
  try {
20
41
  await client.query(sql);
21
- console.log('Enum repair SQL applied successfully.');
42
+ console.log('Enum repair SQL applied successfully.');
22
43
  } finally {
23
44
  await client.end();
24
45
  }
25
46
  }
26
47
 
27
48
  main().catch((error) => {
28
- console.error('Enum repair failed:', error.message);
49
+ console.error('Enum repair failed:', error.message);
29
50
  process.exit(1);
30
51
  });
@@ -32,13 +32,62 @@ ALTER TABLE cyber_security_risk_management_risks
32
32
  ADD COLUMN IF NOT EXISTS action TEXT;
33
33
 
34
34
  -- 7. Follow-up report: subject_classification as varchar (avoids TypeORM PG enum sync failures)
35
- ALTER TABLE followup_report_items
36
- ALTER COLUMN subject_classification TYPE VARCHAR(100)
37
- USING subject_classification::text;
35
+ DO $$
36
+ BEGIN
37
+ IF EXISTS (
38
+ SELECT 1 FROM information_schema.tables
39
+ WHERE table_schema = 'public' AND table_name = 'followup_report_requests'
40
+ ) THEN
41
+ IF NOT EXISTS (
42
+ SELECT 1 FROM information_schema.columns
43
+ WHERE table_schema = 'public'
44
+ AND table_name = 'followup_report_requests'
45
+ AND column_name = 'subject_classification'
46
+ ) THEN
47
+ ALTER TABLE followup_report_requests
48
+ ADD COLUMN subject_classification VARCHAR(100);
49
+ END IF;
50
+
51
+ BEGIN
52
+ ALTER TABLE followup_report_requests
53
+ ALTER COLUMN subject_classification TYPE VARCHAR(100)
54
+ USING COALESCE(subject_classification::text, 'Normal');
55
+ EXCEPTION WHEN OTHERS THEN NULL;
56
+ END;
57
+
58
+ UPDATE followup_report_requests
59
+ SET subject_classification = 'Normal'
60
+ WHERE subject_classification IS NULL OR TRIM(subject_classification) = '';
61
+
62
+ ALTER TABLE followup_report_requests
63
+ ALTER COLUMN subject_classification SET DEFAULT 'Normal';
38
64
 
39
- ALTER TABLE followup_report_requests
40
- ALTER COLUMN subject_classification TYPE VARCHAR(100)
41
- USING subject_classification::text;
65
+ ALTER TABLE followup_report_requests
66
+ ALTER COLUMN subject_classification SET NOT NULL;
67
+ END IF;
68
+
69
+ IF EXISTS (
70
+ SELECT 1 FROM information_schema.tables
71
+ WHERE table_schema = 'public' AND table_name = 'followup_report_items'
72
+ ) THEN
73
+ IF NOT EXISTS (
74
+ SELECT 1 FROM information_schema.columns
75
+ WHERE table_schema = 'public'
76
+ AND table_name = 'followup_report_items'
77
+ AND column_name = 'subject_classification'
78
+ ) THEN
79
+ ALTER TABLE followup_report_items
80
+ ADD COLUMN subject_classification VARCHAR(100);
81
+ END IF;
82
+
83
+ BEGIN
84
+ ALTER TABLE followup_report_items
85
+ ALTER COLUMN subject_classification TYPE VARCHAR(100)
86
+ USING subject_classification::text;
87
+ EXCEPTION WHEN OTHERS THEN NULL;
88
+ END;
89
+ END IF;
90
+ END $$;
42
91
 
43
92
  DROP TYPE IF EXISTS maintenance_subject_classification_en_old;
44
93
 
@@ -1,20 +1,76 @@
1
- -- Repair stuck TypeORM enum swap for follow-up report subject_classification.
2
- -- Safe to re-run.
1
+ -- Repair follow-up report subject_classification for TypeORM schema sync.
2
+ -- Safe to re-run. Skips tables/columns that do not exist yet.
3
3
 
4
- -- 1) Move report items off PG enum (_old or live) -> varchar
5
- ALTER TABLE followup_report_items
6
- ALTER COLUMN subject_classification TYPE VARCHAR(100)
7
- USING subject_classification::text;
4
+ DO $$
5
+ BEGIN
6
+ IF EXISTS (
7
+ SELECT 1
8
+ FROM information_schema.tables
9
+ WHERE table_schema = 'public'
10
+ AND table_name = 'followup_report_requests'
11
+ ) THEN
12
+ IF NOT EXISTS (
13
+ SELECT 1
14
+ FROM information_schema.columns
15
+ WHERE table_schema = 'public'
16
+ AND table_name = 'followup_report_requests'
17
+ AND column_name = 'subject_classification'
18
+ ) THEN
19
+ ALTER TABLE followup_report_requests
20
+ ADD COLUMN subject_classification VARCHAR(100);
21
+ END IF;
22
+
23
+ BEGIN
24
+ ALTER TABLE followup_report_requests
25
+ ALTER COLUMN subject_classification TYPE VARCHAR(100)
26
+ USING COALESCE(subject_classification::text, 'Normal');
27
+ EXCEPTION
28
+ WHEN OTHERS THEN
29
+ NULL;
30
+ END;
31
+
32
+ UPDATE followup_report_requests
33
+ SET subject_classification = 'Normal'
34
+ WHERE subject_classification IS NULL
35
+ OR TRIM(subject_classification) = '';
36
+
37
+ ALTER TABLE followup_report_requests
38
+ ALTER COLUMN subject_classification SET DEFAULT 'Normal';
8
39
 
9
- -- 2) Move requests off PG enum (_old or live) -> varchar
10
- ALTER TABLE followup_report_requests
11
- ALTER COLUMN subject_classification TYPE VARCHAR(100)
12
- USING subject_classification::text;
40
+ ALTER TABLE followup_report_requests
41
+ ALTER COLUMN subject_classification SET NOT NULL;
42
+ END IF;
43
+
44
+ IF EXISTS (
45
+ SELECT 1
46
+ FROM information_schema.tables
47
+ WHERE table_schema = 'public'
48
+ AND table_name = 'followup_report_items'
49
+ ) THEN
50
+ IF NOT EXISTS (
51
+ SELECT 1
52
+ FROM information_schema.columns
53
+ WHERE table_schema = 'public'
54
+ AND table_name = 'followup_report_items'
55
+ AND column_name = 'subject_classification'
56
+ ) THEN
57
+ ALTER TABLE followup_report_items
58
+ ADD COLUMN subject_classification VARCHAR(100);
59
+ END IF;
60
+
61
+ BEGIN
62
+ ALTER TABLE followup_report_items
63
+ ALTER COLUMN subject_classification TYPE VARCHAR(100)
64
+ USING subject_classification::text;
65
+ EXCEPTION
66
+ WHEN OTHERS THEN
67
+ NULL;
68
+ END;
69
+ END IF;
70
+ END $$;
13
71
 
14
- -- 3) Drop leftover TypeORM enum type if nothing depends on it
15
72
  DROP TYPE IF EXISTS maintenance_subject_classification_en_old;
16
73
 
17
- -- 4) Drop orphaned live enum only when no column uses it anymore
18
74
  DO $$
19
75
  BEGIN
20
76
  IF NOT EXISTS (
@@ -62,7 +62,12 @@ export class FollowUpReportRequests extends BaseModel {
62
62
  @Column({ type: 'varchar', length: 500, nullable: false })
63
63
  subject: string;
64
64
 
65
- @Column({ type: 'varchar', length: 100, nullable: false })
65
+ @Column({
66
+ type: 'varchar',
67
+ length: 100,
68
+ nullable: false,
69
+ default: FollowUpReportSubjectClassification.NORMAL,
70
+ })
66
71
  subject_classification: FollowUpReportSubjectClassification;
67
72
 
68
73
  @Column({ type: 'text', nullable: false })
@@ -37,6 +37,12 @@ export class StudyLeaveWorkFlow extends BaseModel {
37
37
  @Column({ type: "integer", nullable: true })
38
38
  approved_by: number | null;
39
39
 
40
+ @Column({ type: "integer", nullable: true })
41
+ department_id: number | null;
42
+
43
+ @Column({ type: "integer", nullable: true })
44
+ section_id: number | null;
45
+
40
46
  @Column({
41
47
  type: "enum",
42
48
  enum: StudyLeaveWorkFlowStatus,
@@ -57,7 +63,9 @@ export class StudyLeaveWorkFlow extends BaseModel {
57
63
  order?: number,
58
64
  approver_role_id?: number | null,
59
65
  approver_user_id?: number | null,
60
- approved_by?: number | null
66
+ approved_by?: number | null,
67
+ department_id?: number | null,
68
+ section_id?: number | null
61
69
  ) {
62
70
  super();
63
71
  this.request_id = request_id;
@@ -69,6 +77,8 @@ export class StudyLeaveWorkFlow extends BaseModel {
69
77
  this.approver_role_id = approver_role_id || null;
70
78
  this.approver_user_id = approver_user_id || null;
71
79
  this.approved_by = approved_by || null;
80
+ this.department_id = department_id || null;
81
+ this.section_id = section_id || null;
72
82
  }
73
83
  }
74
84
 
@@ -37,6 +37,12 @@ export class TrainingWorkFlow extends BaseModel {
37
37
  @Column({ type: "integer", nullable: true })
38
38
  approved_by: number | null;
39
39
 
40
+ @Column({ type: "integer", nullable: true })
41
+ department_id: number | null;
42
+
43
+ @Column({ type: "integer", nullable: true })
44
+ section_id: number | null;
45
+
40
46
  @Column({
41
47
  type: "enum",
42
48
  enum: TrainingWorkFlowStatus,
@@ -57,7 +63,9 @@ export class TrainingWorkFlow extends BaseModel {
57
63
  order?: number,
58
64
  approver_role_id?: number | null,
59
65
  approver_user_id?: number | null,
60
- approved_by?: number | null
66
+ approved_by?: number | null,
67
+ department_id?: number | null,
68
+ section_id?: number | null
61
69
  ) {
62
70
  super();
63
71
  this.request_id = request_id;
@@ -69,6 +77,8 @@ export class TrainingWorkFlow extends BaseModel {
69
77
  this.approver_role_id = approver_role_id || null;
70
78
  this.approver_user_id = approver_user_id || null;
71
79
  this.approved_by = approved_by || null;
80
+ this.department_id = department_id || null;
81
+ this.section_id = section_id || null;
72
82
  }
73
83
  }
74
84