@platform-modules/civil-aviation-authority 2.3.293 → 2.3.295

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.
@@ -1,5 +1,4 @@
1
1
  import { BaseModel } from './BaseModel';
2
- import { FollowUpReportSubjectClassification } from './FollowUpReportRequestModel';
3
2
  export declare class FollowUpReportItem extends BaseModel {
4
3
  request_id: number;
5
4
  service_id: number | null;
@@ -7,7 +6,7 @@ export declare class FollowUpReportItem extends BaseModel {
7
6
  reference_type: string | null;
8
7
  letter_date: Date | null;
9
8
  subject: string | null;
10
- subject_classification: FollowUpReportSubjectClassification | null;
9
+ subject_classification: string | null;
11
10
  general_manager_comment: string | null;
12
11
  response_date_target: string | null;
13
12
  action_status: string | null;
@@ -12,7 +12,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.FollowUpReportItem = void 0;
13
13
  const typeorm_1 = require("typeorm");
14
14
  const BaseModel_1 = require("./BaseModel");
15
- const FollowUpReportRequestModel_1 = require("./FollowUpReportRequestModel");
16
15
  let FollowUpReportItem = class FollowUpReportItem extends BaseModel_1.BaseModel {
17
16
  };
18
17
  exports.FollowUpReportItem = FollowUpReportItem;
@@ -41,12 +40,7 @@ __decorate([
41
40
  __metadata("design:type", Object)
42
41
  ], FollowUpReportItem.prototype, "subject", void 0);
43
42
  __decorate([
44
- (0, typeorm_1.Column)({
45
- type: 'enum',
46
- enum: FollowUpReportRequestModel_1.FollowUpReportSubjectClassification,
47
- enumName: 'maintenance_subject_classification_en',
48
- nullable: true,
49
- }),
43
+ (0, typeorm_1.Column)({ type: 'varchar', length: 100, nullable: true }),
50
44
  __metadata("design:type", Object)
51
45
  ], FollowUpReportItem.prototype, "subject_classification", void 0);
52
46
  __decorate([
@@ -80,12 +80,7 @@ __decorate([
80
80
  __metadata("design:type", String)
81
81
  ], FollowUpReportRequests.prototype, "subject", void 0);
82
82
  __decorate([
83
- (0, typeorm_1.Column)({
84
- type: 'enum',
85
- enum: FollowUpReportSubjectClassification,
86
- enumName: 'maintenance_subject_classification_en',
87
- nullable: false,
88
- }),
83
+ (0, typeorm_1.Column)({ type: 'varchar', length: 100, nullable: false }),
89
84
  __metadata("design:type", String)
90
85
  ], FollowUpReportRequests.prototype, "subject_classification", void 0);
91
86
  __decorate([
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@platform-modules/civil-aviation-authority",
3
- "version": "2.3.293",
3
+ "version": "2.3.295",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {
7
7
  "build": "tsc && node -e \"require('fs').mkdirSync('dist/i18n',{recursive:true}); require('fs').copyFileSync('src/i18n/workflow-chat-i18n.json','dist/i18n/workflow-chat-i18n.json')\"",
8
8
  "dev": "ts-node src/scripts.ts",
9
+ "fix:enum": "node scripts/run-enum-fix.js",
9
10
  "sync:sla-sql": "node scripts/sync-sla-reports-sql.js"
10
11
  },
11
12
  "publishConfig": {
@@ -0,0 +1,30 @@
1
+ require('dotenv').config();
2
+ const fs = require('fs');
3
+ const path = require('path');
4
+ const { Client } = require('pg');
5
+
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');
9
+
10
+ const client = new Client({
11
+ host: process.env.DB_HOST,
12
+ port: Number(process.env.DB_PORT || 5432),
13
+ user: process.env.DB_USER,
14
+ password: process.env.DB_PASS,
15
+ database: process.env.DB_NAME,
16
+ });
17
+
18
+ await client.connect();
19
+ try {
20
+ await client.query(sql);
21
+ console.log('✅ Enum repair SQL applied successfully.');
22
+ } finally {
23
+ await client.end();
24
+ }
25
+ }
26
+
27
+ main().catch((error) => {
28
+ console.error('❌ Enum repair failed:', error.message);
29
+ process.exit(1);
30
+ });
@@ -31,11 +31,28 @@ ALTER TABLE cyber_security_risk_management_risks
31
31
  ADD COLUMN IF NOT EXISTS treatment TEXT,
32
32
  ADD COLUMN IF NOT EXISTS action TEXT;
33
33
 
34
- -- 7. Follow-up report: subject_classification enum values
35
- ALTER TYPE maintenance_subject_classification_en ADD VALUE IF NOT EXISTS 'Important';
36
- ALTER TYPE maintenance_subject_classification_en ADD VALUE IF NOT EXISTS 'Highly Confidential';
37
- ALTER TYPE maintenance_subject_classification_en ADD VALUE IF NOT EXISTS 'Restricted';
38
- ALTER TYPE maintenance_subject_classification_en ADD VALUE IF NOT EXISTS 'Limited';
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;
38
+
39
+ ALTER TABLE followup_report_requests
40
+ ALTER COLUMN subject_classification TYPE VARCHAR(100)
41
+ USING subject_classification::text;
42
+
43
+ DROP TYPE IF EXISTS maintenance_subject_classification_en_old;
44
+
45
+ DO $$
46
+ BEGIN
47
+ IF NOT EXISTS (
48
+ SELECT 1
49
+ FROM information_schema.columns
50
+ WHERE table_schema = 'public'
51
+ AND udt_name = 'maintenance_subject_classification_en'
52
+ ) THEN
53
+ DROP TYPE IF EXISTS maintenance_subject_classification_en;
54
+ END IF;
55
+ END $$;
39
56
 
40
57
  -- 8. Contract service request: notes, company phone, contract documents table
41
58
  ALTER TABLE contract_service_requests
@@ -0,0 +1,28 @@
1
+ -- Repair stuck TypeORM enum swap for follow-up report subject_classification.
2
+ -- Safe to re-run.
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;
8
+
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;
13
+
14
+ -- 3) Drop leftover TypeORM enum type if nothing depends on it
15
+ DROP TYPE IF EXISTS maintenance_subject_classification_en_old;
16
+
17
+ -- 4) Drop orphaned live enum only when no column uses it anymore
18
+ DO $$
19
+ BEGIN
20
+ IF NOT EXISTS (
21
+ SELECT 1
22
+ FROM information_schema.columns
23
+ WHERE table_schema = 'public'
24
+ AND udt_name = 'maintenance_subject_classification_en'
25
+ ) THEN
26
+ DROP TYPE IF EXISTS maintenance_subject_classification_en;
27
+ END IF;
28
+ END $$;
@@ -1,6 +1,5 @@
1
1
  import { Column, Entity } from 'typeorm';
2
2
  import { BaseModel } from './BaseModel';
3
- import { FollowUpReportSubjectClassification } from './FollowUpReportRequestModel';
4
3
 
5
4
  @Entity({ name: 'followup_report_items' })
6
5
  export class FollowUpReportItem extends BaseModel {
@@ -22,13 +21,8 @@ export class FollowUpReportItem extends BaseModel {
22
21
  @Column({ type: 'varchar', length: 500, nullable: true })
23
22
  subject: string | null;
24
23
 
25
- @Column({
26
- type: 'enum',
27
- enum: FollowUpReportSubjectClassification,
28
- enumName: 'maintenance_subject_classification_en',
29
- nullable: true,
30
- })
31
- subject_classification: FollowUpReportSubjectClassification | null;
24
+ @Column({ type: 'varchar', length: 100, nullable: true })
25
+ subject_classification: string | null;
32
26
 
33
27
  @Column({ type: 'varchar', length: 500, nullable: true })
34
28
  general_manager_comment: string | null;
@@ -62,12 +62,7 @@ export class FollowUpReportRequests extends BaseModel {
62
62
  @Column({ type: 'varchar', length: 500, nullable: false })
63
63
  subject: string;
64
64
 
65
- @Column({
66
- type: 'enum',
67
- enum: FollowUpReportSubjectClassification,
68
- enumName: 'maintenance_subject_classification_en',
69
- nullable: false,
70
- })
65
+ @Column({ type: 'varchar', length: 100, nullable: false })
71
66
  subject_classification: FollowUpReportSubjectClassification;
72
67
 
73
68
  @Column({ type: 'text', nullable: false })