@platform-modules/civil-aviation-authority 1.0.0

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,4 @@
1
+ import 'reflect-metadata';
2
+ import { DataSource } from 'typeorm';
3
+ import 'dotenv/config';
4
+ export declare const AppDataSource: DataSource;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AppDataSource = void 0;
4
+ // src/data-source.ts
5
+ require("reflect-metadata");
6
+ const typeorm_1 = require("typeorm");
7
+ require("dotenv/config");
8
+ const user_1 = require("./models/user"); // import all entities here
9
+ const user_sessions_1 = require("./models/user-sessions");
10
+ const role_1 = require("./models/role");
11
+ exports.AppDataSource = new typeorm_1.DataSource({
12
+ type: 'postgres',
13
+ host: process.env.DB_HOST || 'localhost',
14
+ port: +(process.env.DB_PORT || 5432),
15
+ username: process.env.DB_USER || 'postgres',
16
+ password: process.env.DB_PASS || 'postgres',
17
+ database: process.env.DB_NAME || 'common_models',
18
+ synchronize: true, // auto-create tables (disable in prod)
19
+ logging: false,
20
+ entities: [user_1.User, user_sessions_1.userSessions, role_1.Role],
21
+ });
@@ -0,0 +1,75 @@
1
+ export declare enum ImportStatusType {
2
+ NotStarted = 1,
3
+ InProgress = 2,
4
+ Completed = 3,
5
+ Error = 4
6
+ }
7
+ export declare const enum EmployeeType {
8
+ Permanent = "Permanent",
9
+ Contract = "Contract"
10
+ }
11
+ export declare const enum MaritalType {
12
+ Single = "Single",
13
+ Married = "Married"
14
+ }
15
+ export declare const enum genderType {
16
+ Male = "Male",
17
+ Female = "Female",
18
+ Others = "Others"
19
+ }
20
+ export declare const enum ActionItemStatusType {
21
+ Not_Yet_Started = "Not Yet Started",
22
+ InProgress = "InProgress",
23
+ Completed = "Completed",
24
+ Cancelled = "Cancelled"
25
+ }
26
+ export declare const enum CampaignStatusType {
27
+ Not_Yet_Started = "Not Yet Started",
28
+ InProgress = "InProgress",
29
+ Completed = "Completed"
30
+ }
31
+ export declare const enum platformType {
32
+ web = "Web",
33
+ mobile = "Mobile"
34
+ }
35
+ export declare const enum contextType {
36
+ ADMIN = "Admin",
37
+ BUSINESS_PARTNER = "Business Partner",
38
+ CLIENT = "Client"
39
+ }
40
+ export declare enum ImportType {
41
+ admin = 1,
42
+ business_partner = 2,
43
+ client = 3
44
+ }
45
+ export declare enum userType {
46
+ admin = 1,
47
+ business_partner = 2,
48
+ client = 3
49
+ }
50
+ export declare enum ReportColumnDataType {
51
+ Int = 1,
52
+ String = 2,
53
+ Date = 3,
54
+ Time = 4,
55
+ DateTime = 5,
56
+ Money = 6
57
+ }
58
+ export declare enum CONSTANTS {
59
+ READ = "READ",
60
+ DELETE = "DELETE",
61
+ SEND = "SEND"
62
+ }
63
+ export declare enum NotificationRequestType {
64
+ request_raised = "request raised",
65
+ request_approve = "request approve",
66
+ request_reject = "request reject",
67
+ request_withdraw = "request withdraw",
68
+ reminder = "reminder",
69
+ import = "import"
70
+ }
71
+ export declare enum RequestGroup {
72
+ ADMIN = "Admin",
73
+ BUSINESS_PARTNER = "Business Partner",
74
+ CLIENT = "Client"
75
+ }
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ //import enums
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.RequestGroup = exports.NotificationRequestType = exports.CONSTANTS = exports.ReportColumnDataType = exports.userType = exports.ImportType = exports.ImportStatusType = void 0;
5
+ var ImportStatusType;
6
+ (function (ImportStatusType) {
7
+ ImportStatusType[ImportStatusType["NotStarted"] = 1] = "NotStarted";
8
+ ImportStatusType[ImportStatusType["InProgress"] = 2] = "InProgress";
9
+ ImportStatusType[ImportStatusType["Completed"] = 3] = "Completed";
10
+ ImportStatusType[ImportStatusType["Error"] = 4] = "Error";
11
+ })(ImportStatusType || (exports.ImportStatusType = ImportStatusType = {}));
12
+ var ImportType;
13
+ (function (ImportType) {
14
+ ImportType[ImportType["admin"] = 1] = "admin";
15
+ ImportType[ImportType["business_partner"] = 2] = "business_partner";
16
+ ImportType[ImportType["client"] = 3] = "client";
17
+ })(ImportType || (exports.ImportType = ImportType = {}));
18
+ var userType;
19
+ (function (userType) {
20
+ userType[userType["admin"] = 1] = "admin";
21
+ userType[userType["business_partner"] = 2] = "business_partner";
22
+ userType[userType["client"] = 3] = "client";
23
+ })(userType || (exports.userType = userType = {}));
24
+ var ReportColumnDataType;
25
+ (function (ReportColumnDataType) {
26
+ ReportColumnDataType[ReportColumnDataType["Int"] = 1] = "Int";
27
+ ReportColumnDataType[ReportColumnDataType["String"] = 2] = "String";
28
+ ReportColumnDataType[ReportColumnDataType["Date"] = 3] = "Date";
29
+ ReportColumnDataType[ReportColumnDataType["Time"] = 4] = "Time";
30
+ ReportColumnDataType[ReportColumnDataType["DateTime"] = 5] = "DateTime";
31
+ ReportColumnDataType[ReportColumnDataType["Money"] = 6] = "Money";
32
+ })(ReportColumnDataType || (exports.ReportColumnDataType = ReportColumnDataType = {}));
33
+ var CONSTANTS;
34
+ (function (CONSTANTS) {
35
+ CONSTANTS["READ"] = "READ";
36
+ CONSTANTS["DELETE"] = "DELETE";
37
+ CONSTANTS["SEND"] = "SEND";
38
+ })(CONSTANTS || (exports.CONSTANTS = CONSTANTS = {}));
39
+ var NotificationRequestType;
40
+ (function (NotificationRequestType) {
41
+ NotificationRequestType["request_raised"] = "request raised";
42
+ NotificationRequestType["request_approve"] = "request approve";
43
+ NotificationRequestType["request_reject"] = "request reject";
44
+ NotificationRequestType["request_withdraw"] = "request withdraw";
45
+ NotificationRequestType["reminder"] = "reminder";
46
+ NotificationRequestType["import"] = "import";
47
+ })(NotificationRequestType || (exports.NotificationRequestType = NotificationRequestType = {}));
48
+ var RequestGroup;
49
+ (function (RequestGroup) {
50
+ RequestGroup["ADMIN"] = "Admin";
51
+ RequestGroup["BUSINESS_PARTNER"] = "Business Partner";
52
+ RequestGroup["CLIENT"] = "Client";
53
+ })(RequestGroup || (exports.RequestGroup = RequestGroup = {}));
@@ -0,0 +1,3 @@
1
+ export * from './models/user';
2
+ export * from './models/role';
3
+ export * from './models/user-sessions';
package/dist/index.js ADDED
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ // src/index.ts
18
+ __exportStar(require("./models/user"), exports);
19
+ //export * from './models/AMC';
20
+ //export * from './models/categories';
21
+ //export * from './models/import';
22
+ //export * from './models/notifications';
23
+ //export * from './models/otps';
24
+ __exportStar(require("./models/role"), exports);
25
+ //export * from './models/subcategories';
26
+ __exportStar(require("./models/user-sessions"), exports);
27
+ //export * from './models/workflow';
28
+ // export * from './models/request';
@@ -0,0 +1,16 @@
1
+ export declare abstract class Model0 {
2
+ jsonIgnore: string[];
3
+ created_by?: string;
4
+ created_at?: Date;
5
+ updated_by?: string;
6
+ updated_at?: Date;
7
+ insertCreated(): void;
8
+ is_deleted?: boolean;
9
+ logicalDelete: boolean;
10
+ constructor();
11
+ toJSON(): Record<string, any>;
12
+ }
13
+ export declare abstract class BaseModel extends Model0 {
14
+ id: number;
15
+ constructor();
16
+ }
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.BaseModel = exports.Model0 = void 0;
16
+ const moment_timezone_1 = __importDefault(require("moment-timezone"));
17
+ const typeorm_1 = require("typeorm");
18
+ class Model0 {
19
+ insertCreated() {
20
+ const currentTime = (0, moment_timezone_1.default)().utc().tz('Asia/Kolkata').toDate();
21
+ this.created_at = currentTime;
22
+ this.updated_at = currentTime;
23
+ }
24
+ constructor() {
25
+ this.jsonIgnore = ['logicalDelete', 'is_deleted', 'jsonIgnore'];
26
+ this.created_by = '';
27
+ this.updated_by = '';
28
+ this.is_deleted = false;
29
+ this.logicalDelete = true;
30
+ }
31
+ // Don't serialize some fields
32
+ toJSON() {
33
+ const result = {};
34
+ for (const x in this) {
35
+ if (!this.jsonIgnore.includes(x)) {
36
+ // @ts-ignore
37
+ result[x] = this[x];
38
+ }
39
+ }
40
+ return result;
41
+ }
42
+ }
43
+ exports.Model0 = Model0;
44
+ __decorate([
45
+ (0, typeorm_1.Column)({ nullable: false }),
46
+ __metadata("design:type", String)
47
+ ], Model0.prototype, "created_by", void 0);
48
+ __decorate([
49
+ (0, typeorm_1.CreateDateColumn)({ type: "timestamptz", default: () => "CURRENT_TIMESTAMP" }),
50
+ __metadata("design:type", Date)
51
+ ], Model0.prototype, "created_at", void 0);
52
+ __decorate([
53
+ (0, typeorm_1.Column)({ nullable: true }),
54
+ __metadata("design:type", String)
55
+ ], Model0.prototype, "updated_by", void 0);
56
+ __decorate([
57
+ (0, typeorm_1.UpdateDateColumn)({ type: "timestamptz", default: () => "CURRENT_TIMESTAMP" }),
58
+ __metadata("design:type", Date)
59
+ ], Model0.prototype, "updated_at", void 0);
60
+ __decorate([
61
+ (0, typeorm_1.BeforeInsert)(),
62
+ __metadata("design:type", Function),
63
+ __metadata("design:paramtypes", []),
64
+ __metadata("design:returntype", void 0)
65
+ ], Model0.prototype, "insertCreated", null);
66
+ __decorate([
67
+ (0, typeorm_1.Column)({ nullable: true, default: false }),
68
+ __metadata("design:type", Boolean)
69
+ ], Model0.prototype, "is_deleted", void 0);
70
+ class BaseModel extends Model0 {
71
+ constructor() {
72
+ super();
73
+ this.id = 0; // This will be set by the database when the entity is saved
74
+ }
75
+ }
76
+ exports.BaseModel = BaseModel;
77
+ __decorate([
78
+ (0, typeorm_1.PrimaryGeneratedColumn)(),
79
+ __metadata("design:type", Number)
80
+ ], BaseModel.prototype, "id", void 0);
@@ -0,0 +1,2 @@
1
+ declare let AppDataSource: any;
2
+ export default AppDataSource;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const typeorm_1 = require("typeorm");
7
+ const dotenv_1 = __importDefault(require("dotenv"));
8
+ const user_1 = require("../models/user");
9
+ const user_sessions_1 = require("../models/user-sessions");
10
+ dotenv_1.default.config();
11
+ let AppDataSource;
12
+ let retries = 5;
13
+ while (retries) {
14
+ try {
15
+ AppDataSource = new typeorm_1.DataSource({
16
+ type: "postgres",
17
+ host: process.env.TYPEORM_HOST,
18
+ port: parseInt(process.env.TYPEORM_PORT),
19
+ username: process.env.TYPEORM_USERNAME,
20
+ password: process.env.TYPEORM_PASSWORD,
21
+ database: process.env.TYPEORM_DATABASE,
22
+ synchronize: true,
23
+ logging: false,
24
+ entities: [user_1.User, user_sessions_1.userSessions]
25
+ });
26
+ AppDataSource.initialize()
27
+ .then(() => {
28
+ console.log("Database Connection Established");
29
+ })
30
+ .catch((error) => console.log(error));
31
+ retries = 0;
32
+ }
33
+ catch (error) {
34
+ console.log('Postgres trying to reconnect : ', retries, 'Error :', error);
35
+ retries -= 1;
36
+ AppDataSource = undefined;
37
+ new Promise(res => setTimeout(res, 500));
38
+ }
39
+ }
40
+ exports.default = AppDataSource;
@@ -0,0 +1,22 @@
1
+ /** *
2
+ @author
3
+ Amnet Digital
4
+ @date
5
+ 2024-05-20
6
+ @Model
7
+ Role
8
+ @usage
9
+ Userrole Information will store
10
+ */
11
+ import { BaseModel } from './BaseModel';
12
+ export interface Irole {
13
+ name: string;
14
+ id?: number;
15
+ is_deleted?: boolean;
16
+ created_by?: number;
17
+ }
18
+ export declare class Role extends BaseModel {
19
+ name: string;
20
+ is_deleted?: boolean;
21
+ constructor(name: string, is_deleted: boolean, userId: number);
22
+ }
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ /** *
3
+ @author
4
+ Amnet Digital
5
+ @date
6
+ 2024-05-20
7
+ @Model
8
+ Role
9
+ @usage
10
+ Userrole Information will store
11
+ */
12
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
13
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
14
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
15
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
16
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
17
+ };
18
+ var __metadata = (this && this.__metadata) || function (k, v) {
19
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.Role = void 0;
23
+ const typeorm_1 = require("typeorm");
24
+ const BaseModel_1 = require("./BaseModel");
25
+ let Role = class Role extends BaseModel_1.BaseModel {
26
+ constructor(name, is_deleted, userId) {
27
+ super();
28
+ this.name = name;
29
+ this.is_deleted = is_deleted;
30
+ }
31
+ };
32
+ exports.Role = Role;
33
+ __decorate([
34
+ (0, typeorm_1.Column)({ nullable: true }),
35
+ __metadata("design:type", String)
36
+ ], Role.prototype, "name", void 0);
37
+ __decorate([
38
+ (0, typeorm_1.Column)({ nullable: true }),
39
+ __metadata("design:type", Boolean)
40
+ ], Role.prototype, "is_deleted", void 0);
41
+ exports.Role = Role = __decorate([
42
+ (0, typeorm_1.Entity)({ name: 'role' }),
43
+ __metadata("design:paramtypes", [String, Boolean, Number])
44
+ ], Role);
@@ -0,0 +1,18 @@
1
+ /** *
2
+ @author
3
+ Amnet Digital
4
+ @date
5
+ 2024-05-20
6
+ @Model
7
+ Role
8
+ @usage
9
+ Roles Information will store
10
+ */
11
+ import { BaseModel } from './BaseModel';
12
+ export declare class userSessions extends BaseModel {
13
+ last_active_at: Date;
14
+ is_active: boolean;
15
+ expires_at: Date;
16
+ user_id: number;
17
+ constructor(last_active_at: Date, expires_at: Date, user_id: number, is_active: boolean);
18
+ }
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ /** *
3
+ @author
4
+ Amnet Digital
5
+ @date
6
+ 2024-05-20
7
+ @Model
8
+ Role
9
+ @usage
10
+ Roles Information will store
11
+ */
12
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
13
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
14
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
15
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
16
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
17
+ };
18
+ var __metadata = (this && this.__metadata) || function (k, v) {
19
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.userSessions = void 0;
23
+ const typeorm_1 = require("typeorm");
24
+ const BaseModel_1 = require("./BaseModel");
25
+ let userSessions = class userSessions extends BaseModel_1.BaseModel {
26
+ constructor(last_active_at, expires_at, user_id, is_active) {
27
+ super();
28
+ this.last_active_at = last_active_at,
29
+ this.expires_at = expires_at,
30
+ this.user_id = user_id,
31
+ this.is_active = is_active;
32
+ }
33
+ };
34
+ exports.userSessions = userSessions;
35
+ __decorate([
36
+ (0, typeorm_1.Column)({ nullable: true }),
37
+ __metadata("design:type", Date)
38
+ ], userSessions.prototype, "last_active_at", void 0);
39
+ __decorate([
40
+ (0, typeorm_1.Column)({ nullable: true, default: true }),
41
+ __metadata("design:type", Boolean)
42
+ ], userSessions.prototype, "is_active", void 0);
43
+ __decorate([
44
+ (0, typeorm_1.Column)({ nullable: true }),
45
+ __metadata("design:type", Date)
46
+ ], userSessions.prototype, "expires_at", void 0);
47
+ __decorate([
48
+ (0, typeorm_1.Column)({ nullable: true }),
49
+ __metadata("design:type", Number)
50
+ ], userSessions.prototype, "user_id", void 0);
51
+ exports.userSessions = userSessions = __decorate([
52
+ (0, typeorm_1.Entity)({ name: 'user_sessions' }),
53
+ __metadata("design:paramtypes", [Date, Date, Number, Boolean])
54
+ ], userSessions);
@@ -0,0 +1,19 @@
1
+ import { BaseModel } from './BaseModel';
2
+ export declare class User extends BaseModel {
3
+ first_name: string;
4
+ last_name: string;
5
+ full_name: string;
6
+ password: string;
7
+ mobile: string;
8
+ email: string;
9
+ address: string;
10
+ city: string;
11
+ state: string;
12
+ country: string;
13
+ pincode: string;
14
+ is_active: boolean;
15
+ EncryptPassword: string;
16
+ roleId: number;
17
+ company: string;
18
+ constructor(first_name: string, last_name: string, full_name: string, password: string, mobile: string, email: string, address: string, city: string, state: string, country: string, pincode: string, is_active: boolean, EncryptPassword: string, roleId: number, company: string);
19
+ }
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.User = void 0;
13
+ const typeorm_1 = require("typeorm");
14
+ const BaseModel_1 = require("./BaseModel");
15
+ let User = class User extends BaseModel_1.BaseModel {
16
+ constructor(first_name, last_name, full_name, password, mobile, email, address, city, state, country, pincode, is_active, EncryptPassword, roleId,
17
+ // contract_start_date: string,
18
+ // contract_end_date: string,
19
+ company) {
20
+ super();
21
+ this.first_name = first_name,
22
+ this.last_name = last_name,
23
+ this.full_name = full_name,
24
+ this.password = password,
25
+ this.EncryptPassword = EncryptPassword,
26
+ this.mobile = mobile,
27
+ this.email = email,
28
+ this.is_active = is_active,
29
+ this.address = address,
30
+ this.city = city,
31
+ this.state = state,
32
+ this.country = country,
33
+ this.pincode = pincode,
34
+ this.roleId = roleId,
35
+ // this.contract_start_date = contract_start_date,
36
+ // this.contract_end_date = contract_end_date,
37
+ this.company = company;
38
+ }
39
+ };
40
+ exports.User = User;
41
+ __decorate([
42
+ (0, typeorm_1.Column)({ nullable: true }),
43
+ __metadata("design:type", String)
44
+ ], User.prototype, "first_name", void 0);
45
+ __decorate([
46
+ (0, typeorm_1.Column)({ nullable: true }),
47
+ __metadata("design:type", String)
48
+ ], User.prototype, "last_name", void 0);
49
+ __decorate([
50
+ (0, typeorm_1.Column)({ nullable: true }),
51
+ __metadata("design:type", String)
52
+ ], User.prototype, "full_name", void 0);
53
+ __decorate([
54
+ (0, typeorm_1.Column)({ nullable: true }),
55
+ __metadata("design:type", String)
56
+ ], User.prototype, "password", void 0);
57
+ __decorate([
58
+ (0, typeorm_1.Column)({ nullable: true }),
59
+ __metadata("design:type", String)
60
+ ], User.prototype, "mobile", void 0);
61
+ __decorate([
62
+ (0, typeorm_1.Column)({ nullable: true }),
63
+ __metadata("design:type", String)
64
+ ], User.prototype, "email", void 0);
65
+ __decorate([
66
+ (0, typeorm_1.Column)({ nullable: true }),
67
+ __metadata("design:type", String)
68
+ ], User.prototype, "address", void 0);
69
+ __decorate([
70
+ (0, typeorm_1.Column)({ nullable: true }),
71
+ __metadata("design:type", String)
72
+ ], User.prototype, "city", void 0);
73
+ __decorate([
74
+ (0, typeorm_1.Column)({ nullable: true }),
75
+ __metadata("design:type", String)
76
+ ], User.prototype, "state", void 0);
77
+ __decorate([
78
+ (0, typeorm_1.Column)({ nullable: true }),
79
+ __metadata("design:type", String)
80
+ ], User.prototype, "country", void 0);
81
+ __decorate([
82
+ (0, typeorm_1.Column)({ nullable: true }),
83
+ __metadata("design:type", String)
84
+ ], User.prototype, "pincode", void 0);
85
+ __decorate([
86
+ (0, typeorm_1.Column)({ nullable: true, default: true }),
87
+ __metadata("design:type", Boolean)
88
+ ], User.prototype, "is_active", void 0);
89
+ __decorate([
90
+ (0, typeorm_1.Column)({ nullable: true }),
91
+ __metadata("design:type", String)
92
+ ], User.prototype, "EncryptPassword", void 0);
93
+ __decorate([
94
+ (0, typeorm_1.Column)({ nullable: true }),
95
+ __metadata("design:type", Number)
96
+ ], User.prototype, "roleId", void 0);
97
+ __decorate([
98
+ (0, typeorm_1.Column)({ nullable: true }),
99
+ __metadata("design:type", String)
100
+ ], User.prototype, "company", void 0);
101
+ exports.User = User = __decorate([
102
+ (0, typeorm_1.Entity)({ name: 'users' }),
103
+ __metadata("design:paramtypes", [String, String, String, String, String, String, String, String, String, String, String, Boolean, String, Number, String])
104
+ ], User);
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const data_source_1 = require("./data-source");
4
+ data_source_1.AppDataSource.initialize()
5
+ .then(() => {
6
+ console.log('✅ Database schema synchronized successfully.');
7
+ })
8
+ .catch((error) => {
9
+ console.error('❌ Error during schema synchronization:', error);
10
+ process.exit(1);
11
+ });
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@platform-modules/civil-aviation-authority",
3
+ "version": "1.0.0",
4
+ "main": "dist/index.js",
5
+ "types": "dist/index.d.ts",
6
+ "scripts": {
7
+ "build": "tsc",
8
+ "sync-db": "ts-node src/scripts.ts"
9
+ },
10
+ "publishConfig": {
11
+ "access": "public"
12
+ },
13
+ "dependencies": {
14
+ "moment-timezone": "^0.6.0",
15
+ "pg": "^8.16.0",
16
+ "typeorm": "^0.3.17"
17
+ },
18
+ "devDependencies": {
19
+ "@types/moment-timezone": "^0.5.30",
20
+ "dotenv": "^16.5.0",
21
+ "ts-node": "^10.9.2",
22
+ "typescript": "^5.2.0"
23
+ }
24
+ }
@@ -0,0 +1,19 @@
1
+ // src/data-source.ts
2
+ import 'reflect-metadata';
3
+ import { DataSource } from 'typeorm';
4
+ import 'dotenv/config';
5
+ import { User } from './models/user'; // import all entities here
6
+ import { userSessions } from './models/user-sessions';
7
+ import { Role } from './models/role';
8
+
9
+ export const AppDataSource = new DataSource({
10
+ type: 'postgres',
11
+ host: process.env.DB_HOST || 'localhost',
12
+ port: +(process.env.DB_PORT || 5432),
13
+ username: process.env.DB_USER || 'postgres',
14
+ password: process.env.DB_PASS || 'postgres',
15
+ database: process.env.DB_NAME || 'common_models',
16
+ synchronize: true, // auto-create tables (disable in prod)
17
+ logging: false,
18
+ entities: [User,userSessions,Role],
19
+ });
@@ -0,0 +1,94 @@
1
+ //import enums
2
+
3
+ export enum ImportStatusType {
4
+ NotStarted = 1,
5
+ InProgress = 2,
6
+ Completed = 3,
7
+ Error = 4,
8
+ }
9
+
10
+ export const enum EmployeeType {
11
+ Permanent = 'Permanent',
12
+ Contract = 'Contract',
13
+ }
14
+
15
+ export const enum MaritalType {
16
+ Single = 'Single',
17
+ Married = 'Married',
18
+ }
19
+
20
+ export const enum genderType {
21
+ Male = 'Male',
22
+ Female = 'Female',
23
+ Others = 'Others',
24
+
25
+ }
26
+
27
+ export const enum ActionItemStatusType {
28
+ Not_Yet_Started = 'Not Yet Started',
29
+ InProgress = 'InProgress',
30
+ Completed = 'Completed',
31
+ Cancelled = 'Cancelled',
32
+ }
33
+
34
+ export const enum CampaignStatusType {
35
+ Not_Yet_Started = 'Not Yet Started',
36
+ InProgress = 'InProgress',
37
+ Completed = 'Completed',
38
+ }
39
+
40
+ export const enum platformType {
41
+ web = 'Web',
42
+ mobile = 'Mobile'
43
+ }
44
+
45
+ export const enum contextType {
46
+ ADMIN = 'Admin',
47
+ BUSINESS_PARTNER = 'Business Partner',
48
+ CLIENT = 'Client'
49
+ }
50
+
51
+ export enum ImportType {
52
+ admin = 1,
53
+ business_partner = 2,
54
+ client = 3
55
+ }
56
+
57
+ export enum userType {
58
+ admin = 1,
59
+ business_partner = 2,
60
+ client = 3
61
+ }
62
+
63
+ export enum ReportColumnDataType {
64
+ Int = 1,
65
+ String = 2,
66
+ Date = 3,
67
+ Time = 4,
68
+ DateTime = 5,
69
+ Money = 6,
70
+ }
71
+
72
+ export enum CONSTANTS {
73
+ READ = 'READ',
74
+ DELETE = 'DELETE',
75
+ SEND = 'SEND',
76
+ }
77
+
78
+ export enum NotificationRequestType {
79
+ request_raised = 'request raised',
80
+ request_approve = 'request approve',
81
+ request_reject = 'request reject',
82
+ request_withdraw = 'request withdraw',
83
+ reminder = 'reminder',
84
+ import = 'import',
85
+ }
86
+
87
+ export enum RequestGroup {
88
+ ADMIN = 'Admin',
89
+ BUSINESS_PARTNER = 'Business Partner',
90
+ CLIENT = 'Client'
91
+
92
+ }
93
+
94
+
package/src/index.ts ADDED
@@ -0,0 +1,13 @@
1
+ // src/index.ts
2
+ export * from './models/user';
3
+ //export * from './models/AMC';
4
+ //export * from './models/categories';
5
+ //export * from './models/import';
6
+ //export * from './models/notifications';
7
+ //export * from './models/otps';
8
+ export * from './models/role';
9
+ //export * from './models/subcategories';
10
+ export * from './models/user-sessions';
11
+ //export * from './models/workflow';
12
+ // export * from './models/request';
13
+
@@ -0,0 +1,62 @@
1
+ import moment from "moment-timezone";
2
+ import {
3
+ Column,
4
+ CreateDateColumn,
5
+ UpdateDateColumn,
6
+ BeforeInsert,
7
+ PrimaryGeneratedColumn
8
+ } from 'typeorm';
9
+
10
+ export abstract class Model0 {
11
+ jsonIgnore: string[] = ['logicalDelete', 'is_deleted', 'jsonIgnore'];
12
+
13
+ @Column({ nullable: false })
14
+ created_by?: string = '';
15
+
16
+ @CreateDateColumn({ type: "timestamptz", default: () => "CURRENT_TIMESTAMP" })
17
+ created_at?: Date;
18
+
19
+ @Column({ nullable: true })
20
+ updated_by?: string = '';
21
+
22
+ @UpdateDateColumn({ type: "timestamptz", default: () => "CURRENT_TIMESTAMP" })
23
+ updated_at?: Date;
24
+
25
+ @BeforeInsert()
26
+ insertCreated() {
27
+ const currentTime = moment().utc().tz('Asia/Kolkata').toDate();
28
+ this.created_at = currentTime;
29
+ this.updated_at = currentTime;
30
+ }
31
+
32
+ @Column({ nullable: true, default: false })
33
+ is_deleted?: boolean = false;
34
+
35
+ logicalDelete: boolean;
36
+
37
+ constructor() {
38
+ this.logicalDelete = true;
39
+ }
40
+
41
+ // Don't serialize some fields
42
+ toJSON() {
43
+ const result: Record<string, any> = {};
44
+ for (const x in this) {
45
+ if (!this.jsonIgnore.includes(x)) {
46
+ // @ts-ignore
47
+ result[x] = this[x];
48
+ }
49
+ }
50
+ return result;
51
+ }
52
+ }
53
+
54
+ export abstract class BaseModel extends Model0 {
55
+ @PrimaryGeneratedColumn()
56
+ id: number;
57
+
58
+ constructor() {
59
+ super();
60
+ this.id = 0; // This will be set by the database when the entity is saved
61
+ }
62
+ }
@@ -0,0 +1,37 @@
1
+ import { DataSource } from "typeorm";
2
+ import dotenv from 'dotenv';
3
+ import { User } from "../models/user";
4
+ import { userSessions } from '../models/user-sessions';
5
+
6
+ dotenv.config();
7
+ let AppDataSource: any;
8
+ let retries: number = 5;
9
+ while (retries) {
10
+ try {
11
+ AppDataSource = new DataSource({
12
+ type: "postgres",
13
+ host: process.env.TYPEORM_HOST,
14
+ port: parseInt(process.env.TYPEORM_PORT!),
15
+ username: process.env.TYPEORM_USERNAME,
16
+ password: process.env.TYPEORM_PASSWORD,
17
+ database: process.env.TYPEORM_DATABASE,
18
+ synchronize: true,
19
+ logging: false,
20
+ entities: [ User,userSessions]
21
+ });
22
+ AppDataSource.initialize()
23
+ .then(() => {
24
+ console.log("Database Connection Established");
25
+ })
26
+ .catch((error: any) => console.log(error));
27
+ retries = 0;
28
+ } catch (error) {
29
+ console.log('Postgres trying to reconnect : ', retries, 'Error :', error);
30
+ retries -= 1;
31
+ AppDataSource = undefined;
32
+ new Promise(res => setTimeout(res, 500));
33
+ }
34
+ }
35
+
36
+
37
+ export default AppDataSource;
@@ -0,0 +1,36 @@
1
+ /** *
2
+ @author
3
+ Amnet Digital
4
+ @date
5
+ 2024-05-20
6
+ @Model
7
+ Role
8
+ @usage
9
+ Userrole Information will store
10
+ */
11
+
12
+ import { Column, Entity } from "typeorm";
13
+ import { BaseModel } from './BaseModel';
14
+
15
+ export interface Irole {
16
+ name: string;
17
+ id?: number;
18
+ is_deleted?: boolean;
19
+ created_by?: number;
20
+ }
21
+ @Entity({ name: 'role' })
22
+ export class Role extends BaseModel {
23
+
24
+ @Column({ nullable: true })
25
+ name: string;
26
+
27
+ @Column({ nullable: true })
28
+ is_deleted?: boolean;
29
+
30
+
31
+ constructor(name: string,is_deleted:boolean,userId: number) {
32
+ super();
33
+ this.name = name
34
+ this.is_deleted = is_deleted
35
+ }
36
+ }
@@ -0,0 +1,38 @@
1
+
2
+ /** *
3
+ @author
4
+ Amnet Digital
5
+ @date
6
+ 2024-05-20
7
+ @Model
8
+ Role
9
+ @usage
10
+ Roles Information will store
11
+ */
12
+
13
+ import { Column, Entity, PrimaryGeneratedColumn } from "typeorm";
14
+ import { BaseModel} from './BaseModel';
15
+
16
+ @Entity({ name: 'user_sessions' })
17
+ export class userSessions extends BaseModel {
18
+ @Column({ nullable: true })
19
+ last_active_at: Date;
20
+
21
+ @Column({ nullable: true, default: true })
22
+ is_active: boolean;
23
+
24
+ @Column({ nullable: true })
25
+ expires_at: Date;
26
+
27
+ @Column({ nullable: true })
28
+ user_id: number;
29
+
30
+ constructor(last_active_at: Date, expires_at: Date, user_id: number, is_active: boolean) {
31
+ super();
32
+ this.last_active_at = last_active_at,
33
+ this.expires_at = expires_at,
34
+ this.user_id = user_id,
35
+ this.is_active = is_active
36
+ }
37
+ }
38
+
@@ -0,0 +1,100 @@
1
+
2
+ import { Column, Entity ,BeforeInsert,BeforeUpdate } from "typeorm";
3
+ import { BaseModel } from './BaseModel';
4
+
5
+ @Entity({ name: 'users' })
6
+ export class User extends BaseModel {
7
+
8
+ @Column({ nullable: true })
9
+ first_name: string;
10
+
11
+ @Column({ nullable: true })
12
+ last_name: string;
13
+
14
+ @Column({ nullable: true })
15
+ full_name: string;
16
+
17
+ @Column({ nullable: true })
18
+ password: string;
19
+
20
+ @Column({ nullable: true })
21
+ mobile: string;
22
+
23
+ @Column({ nullable: true })
24
+ email: string;
25
+
26
+ @Column({ nullable: true })
27
+ address: string;
28
+
29
+ @Column({ nullable: true })
30
+ city: string;
31
+
32
+ @Column({ nullable: true })
33
+ state: string;
34
+
35
+ @Column({ nullable: true })
36
+ country: string;
37
+
38
+ @Column({ nullable: true })
39
+ pincode: string;
40
+
41
+ @Column({ nullable: true, default: true })
42
+ is_active: boolean;
43
+
44
+ @Column({ nullable: true })
45
+ EncryptPassword: string;
46
+
47
+ @Column({ nullable: true })
48
+ roleId: number;
49
+
50
+ // @Column({ nullable: true })
51
+ // contract_start_date: string;
52
+
53
+ // @Column({ nullable: true })
54
+ // contract_end_date: string;
55
+
56
+ @Column({ nullable: true })
57
+ company: string;
58
+
59
+ constructor(
60
+ first_name: string,
61
+ last_name: string,
62
+ full_name: string,
63
+ password: string,
64
+ mobile: string,
65
+ email: string,
66
+ address: string,
67
+ city: string,
68
+ state: string,
69
+ country: string,
70
+ pincode: string,
71
+ is_active: boolean,
72
+ EncryptPassword: string,
73
+ roleId: number,
74
+ // contract_start_date: string,
75
+ // contract_end_date: string,
76
+ company: string
77
+
78
+ ) {
79
+ super();
80
+ this.first_name = first_name,
81
+ this.last_name = last_name,
82
+ this.full_name = full_name ,
83
+ this.password = password,
84
+ this.EncryptPassword = EncryptPassword,
85
+ this.mobile = mobile,
86
+ this.email = email,
87
+ this.is_active = is_active,
88
+ this.address = address,
89
+ this.city = city,
90
+ this.state = state,
91
+ this.country = country,
92
+ this.pincode = pincode,
93
+ this.roleId = roleId,
94
+ // this.contract_start_date = contract_start_date,
95
+ // this.contract_end_date = contract_end_date,
96
+ this.company = company
97
+ }
98
+ }
99
+
100
+
package/src/scripts.ts ADDED
@@ -0,0 +1,10 @@
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
+ });
package/tsconfig.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "CommonJS",
5
+ "declaration": true,
6
+ "outDir": "./dist",
7
+ "strict": true,
8
+ "esModuleInterop": true,
9
+ "skipLibCheck": true,
10
+ "strictPropertyInitialization": false,
11
+ "experimentalDecorators": true,
12
+ "emitDecoratorMetadata": true
13
+ },
14
+ "include": ["src"],
15
+ "exclude": ["node_modules", "dist"]
16
+ }