@platform-modules/civil-aviation-authority 2.3.331 → 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.
@@ -43,5 +43,6 @@ export declare class AnnualTrainingPlanRequest extends BaseModel {
43
43
  total_participants: number;
44
44
  import_status: AnnualTrainingPlanImportStatus | null;
45
45
  submission_source: AnnualTrainingPlanSubmissionSource | null;
46
+ reference_number: string | null;
46
47
  constructor(user_id: number, status?: AnnualTrainingPlanRequestStatus, service_id?: number | null, sub_service_id?: number | null, req_user_department_id?: number | null, req_user_section_id?: number | null, req_user_position_id?: number | null, reviewer_user_id?: number | null, assigned_to_user_id?: number | null, assigned_at?: Date | null, workflow_execution_id?: string | null, directarate?: string | null);
47
48
  }
@@ -62,6 +62,7 @@ let AnnualTrainingPlanRequest = class AnnualTrainingPlanRequest extends BaseMode
62
62
  this.total_participants = 0;
63
63
  this.import_status = null;
64
64
  this.submission_source = null;
65
+ this.reference_number = null;
65
66
  }
66
67
  };
67
68
  exports.AnnualTrainingPlanRequest = AnnualTrainingPlanRequest;
@@ -170,6 +171,10 @@ __decorate([
170
171
  }),
171
172
  __metadata("design:type", Object)
172
173
  ], AnnualTrainingPlanRequest.prototype, "submission_source", void 0);
174
+ __decorate([
175
+ (0, typeorm_1.Column)({ type: "varchar", length: 20, nullable: true, unique: true }),
176
+ __metadata("design:type", Object)
177
+ ], AnnualTrainingPlanRequest.prototype, "reference_number", void 0);
173
178
  exports.AnnualTrainingPlanRequest = AnnualTrainingPlanRequest = __decorate([
174
179
  (0, typeorm_1.Entity)({ name: "annual_training_plan_requests" }),
175
180
  __metadata("design:paramtypes", [Number, String, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object])
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platform-modules/civil-aviation-authority",
3
- "version": "2.3.331",
3
+ "version": "2.3.333",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {
@@ -0,0 +1,6 @@
1
+ ALTER TABLE annual_training_plan_requests
2
+ ADD COLUMN IF NOT EXISTS reference_number VARCHAR(20);
3
+
4
+ CREATE UNIQUE INDEX IF NOT EXISTS uq_annual_training_plan_requests_reference_number
5
+ ON annual_training_plan_requests(reference_number)
6
+ WHERE reference_number IS NOT NULL;
@@ -1,80 +1,80 @@
1
- -- One plan per course inside an annual training plan request.
2
- -- Run once per environment before using per-plan approval.
3
-
4
- DO $$ BEGIN
5
- CREATE TYPE annual_training_plan_department_plans_status_enum
6
- AS ENUM ('Pending', 'Approved', 'Rejected');
7
- EXCEPTION
8
- WHEN duplicate_object THEN NULL;
9
- END $$;
10
-
11
- DO $$ BEGIN
12
- CREATE TYPE annual_training_plan_requests_submission_source_enum
13
- AS ENUM ('Excel', 'Direct');
14
- EXCEPTION
15
- WHEN duplicate_object THEN NULL;
16
- END $$;
17
-
18
- CREATE TABLE IF NOT EXISTS annual_training_plan_department_plans (
19
- id SERIAL PRIMARY KEY,
20
- request_id INTEGER NOT NULL REFERENCES annual_training_plan_requests(id) ON DELETE CASCADE,
21
- department_id INTEGER NOT NULL,
22
- status annual_training_plan_department_plans_status_enum NOT NULL DEFAULT 'Pending',
23
- created_by INTEGER,
24
- updated_by INTEGER,
25
- created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
26
- updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
27
- is_deleted BOOLEAN DEFAULT FALSE
28
- );
29
-
30
- CREATE INDEX IF NOT EXISTS ix_annual_training_plan_department_plans_request
31
- ON annual_training_plan_department_plans(request_id);
32
-
33
- CREATE TABLE IF NOT EXISTS annual_training_plan_department_plan_decisions (
34
- id SERIAL PRIMARY KEY,
35
- department_plan_id INTEGER NOT NULL REFERENCES annual_training_plan_department_plans(id) ON DELETE CASCADE,
36
- approval_level INTEGER NOT NULL,
37
- status annual_training_plan_department_plans_status_enum NOT NULL,
38
- comment TEXT,
39
- decided_by INTEGER,
40
- created_by INTEGER,
41
- updated_by INTEGER,
42
- created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
43
- updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
44
- is_deleted BOOLEAN DEFAULT FALSE
45
- );
46
-
47
- CREATE INDEX IF NOT EXISTS ix_atp_department_plan_decisions_plan_level
48
- ON annual_training_plan_department_plan_decisions(department_plan_id, approval_level);
49
-
50
- ALTER TABLE annual_training_plan_items
51
- ADD COLUMN IF NOT EXISTS department_plan_id INTEGER
52
- REFERENCES annual_training_plan_department_plans(id) ON DELETE SET NULL;
53
-
54
- ALTER TABLE annual_training_plan_requests
55
- ADD COLUMN IF NOT EXISTS submission_source annual_training_plan_requests_submission_source_enum;
56
-
57
- DO $$
58
- DECLARE
59
- rec RECORD;
60
- new_id INTEGER;
61
- BEGIN
62
- FOR rec IN
63
- SELECT id, request_id, department_id, created_by, updated_by, created_at, updated_at
64
- FROM annual_training_plan_items
65
- WHERE is_deleted = false
66
- AND department_plan_id IS NULL
67
- LOOP
68
- INSERT INTO annual_training_plan_department_plans (
69
- request_id, department_id, status, created_by, updated_by, created_at, updated_at, is_deleted
70
- ) VALUES (
71
- rec.request_id, rec.department_id, 'Pending', rec.created_by, rec.updated_by,
72
- rec.created_at, rec.updated_at, false
73
- )
74
- RETURNING id INTO new_id;
75
-
76
- UPDATE annual_training_plan_items
77
- SET department_plan_id = new_id
78
- WHERE id = rec.id;
79
- END LOOP;
80
- END $$;
1
+ -- One plan per course inside an annual training plan request.
2
+ -- Run once per environment before using per-plan approval.
3
+
4
+ DO $$ BEGIN
5
+ CREATE TYPE annual_training_plan_department_plans_status_enum
6
+ AS ENUM ('Pending', 'Approved', 'Rejected');
7
+ EXCEPTION
8
+ WHEN duplicate_object THEN NULL;
9
+ END $$;
10
+
11
+ DO $$ BEGIN
12
+ CREATE TYPE annual_training_plan_requests_submission_source_enum
13
+ AS ENUM ('Excel', 'Direct');
14
+ EXCEPTION
15
+ WHEN duplicate_object THEN NULL;
16
+ END $$;
17
+
18
+ CREATE TABLE IF NOT EXISTS annual_training_plan_department_plans (
19
+ id SERIAL PRIMARY KEY,
20
+ request_id INTEGER NOT NULL REFERENCES annual_training_plan_requests(id) ON DELETE CASCADE,
21
+ department_id INTEGER NOT NULL,
22
+ status annual_training_plan_department_plans_status_enum NOT NULL DEFAULT 'Pending',
23
+ created_by INTEGER,
24
+ updated_by INTEGER,
25
+ created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
26
+ updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
27
+ is_deleted BOOLEAN DEFAULT FALSE
28
+ );
29
+
30
+ CREATE INDEX IF NOT EXISTS ix_annual_training_plan_department_plans_request
31
+ ON annual_training_plan_department_plans(request_id);
32
+
33
+ CREATE TABLE IF NOT EXISTS annual_training_plan_department_plan_decisions (
34
+ id SERIAL PRIMARY KEY,
35
+ department_plan_id INTEGER NOT NULL REFERENCES annual_training_plan_department_plans(id) ON DELETE CASCADE,
36
+ approval_level INTEGER NOT NULL,
37
+ status annual_training_plan_department_plans_status_enum NOT NULL,
38
+ comment TEXT,
39
+ decided_by INTEGER,
40
+ created_by INTEGER,
41
+ updated_by INTEGER,
42
+ created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
43
+ updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
44
+ is_deleted BOOLEAN DEFAULT FALSE
45
+ );
46
+
47
+ CREATE INDEX IF NOT EXISTS ix_atp_department_plan_decisions_plan_level
48
+ ON annual_training_plan_department_plan_decisions(department_plan_id, approval_level);
49
+
50
+ ALTER TABLE annual_training_plan_items
51
+ ADD COLUMN IF NOT EXISTS department_plan_id INTEGER
52
+ REFERENCES annual_training_plan_department_plans(id) ON DELETE SET NULL;
53
+
54
+ ALTER TABLE annual_training_plan_requests
55
+ ADD COLUMN IF NOT EXISTS submission_source annual_training_plan_requests_submission_source_enum;
56
+
57
+ DO $$
58
+ DECLARE
59
+ rec RECORD;
60
+ new_id INTEGER;
61
+ BEGIN
62
+ FOR rec IN
63
+ SELECT id, request_id, department_id, created_by, updated_by, created_at, updated_at
64
+ FROM annual_training_plan_items
65
+ WHERE is_deleted = false
66
+ AND department_plan_id IS NULL
67
+ LOOP
68
+ INSERT INTO annual_training_plan_department_plans (
69
+ request_id, department_id, status, created_by, updated_by, created_at, updated_at, is_deleted
70
+ ) VALUES (
71
+ rec.request_id, rec.department_id, 'Pending', rec.created_by, rec.updated_by,
72
+ rec.created_at, rec.updated_at, false
73
+ )
74
+ RETURNING id INTO new_id;
75
+
76
+ UPDATE annual_training_plan_items
77
+ SET department_plan_id = new_id
78
+ WHERE id = rec.id;
79
+ END LOOP;
80
+ END $$;
@@ -1,33 +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
- }
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
+ }
@@ -1,31 +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
- }
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
+ }
@@ -109,6 +109,9 @@ export class AnnualTrainingPlanRequest extends BaseModel {
109
109
  })
110
110
  submission_source: AnnualTrainingPlanSubmissionSource | null;
111
111
 
112
+ @Column({ type: "varchar", length: 20, nullable: true, unique: true })
113
+ reference_number: string | null;
114
+
112
115
  constructor(
113
116
  user_id: number,
114
117
  status: AnnualTrainingPlanRequestStatus = AnnualTrainingPlanRequestStatus.PENDING,
@@ -147,6 +150,7 @@ export class AnnualTrainingPlanRequest extends BaseModel {
147
150
  this.total_participants = 0;
148
151
  this.import_status = null;
149
152
  this.submission_source = null;
153
+ this.reference_number = null;
150
154
  }
151
155
  }
152
156