commit eb37c4967f29415923c363ae7a1edcb7c83b63e6 Author: Abdul Rahman Reza Date: Sat Nov 30 11:32:24 2024 +0700 initial diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..66368b4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +.vscode/ +.DS_Store + +node_modules/ +build/ +dist/ +temp/ +package-lock.json diff --git a/package.json b/package.json new file mode 100644 index 0000000..0c26703 --- /dev/null +++ b/package.json @@ -0,0 +1,25 @@ +{ + "name": "Entity", + "version": "1.0.0", + "description": "This kind of project was built to present entity table type ORM", + "main": "dist/src/index.d.ts", + "types": "dist/src/index.d.ts", + "scripts": { + "dev": "nodemon", + "build": "tsc" + }, + "keywords": [ + "BRI" + ], + "author": "STS", + "license": "ISC", + "dependencies": { + "bcryptjs": "^2.4.3", + "typeorm": "^0.3.20" + }, + "devDependencies": { + "@types/bcryptjs": "^2.4.6", + "@types/node": "^22.10.1", + "typescript": "^5.7.2" + } +} diff --git a/src/entity/cif_account.ts b/src/entity/cif_account.ts new file mode 100644 index 0000000..aa2bc91 --- /dev/null +++ b/src/entity/cif_account.ts @@ -0,0 +1,149 @@ +import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, DeleteDateColumn } from 'typeorm'; + +@Entity('cif_account') +export class CifAccount { + @PrimaryGeneratedColumn('uuid') + id: string; + + @Column({ + nullable: false, + length: 12 + }) + cif_number: string; + + @Column({ + nullable: false, + length: 128 + }) + name: string; + + @Column({ + nullable: false, + length: 20 + }) + account_number: string; + + @Column({ + nullable: false, + length: 4 + }) + branch_code: string; + + @Column({ + nullable: false, + }) + open_date: Date; + + @Column({ + type: 'int2', + nullable: false, + }) + product_type: number; + + @Column({ + nullable: false, + length: 256 + }) + product_description: string; + + @Column({ + type: 'float8', + nullable: false, + }) + current_balance: number; + + @Column({ + nullable: false, + length: 2 + }) + country_code: string; + + @Column({ + nullable: false, + length: 128 + }) + country_name: string; + + @Column({ + nullable: false, + length: 1 + }) + exposed_person_flag: string; + + @Column({ + nullable: false, + length: 1 + }) + income_tiering: string; + + @Column({ + nullable: false, + length: 1 + }) + cif_type: string; + + @Column({ + type: 'int2', + nullable: false, + }) + status: number; + + @Column({ + nullable: false, + length: 1 + }) + gender: string; + + @Column({ + nullable: false, + }) + birth_date: Date; + + @Column({ + type: 'uuid', + nullable: false, + }) + economic_sub_clasification: string; + + @Column({ + type: 'uuid', + nullable: true, + }) + district: string; + + @Column({ + type: 'uuid', + nullable: true, + }) + munisipiu: string; + + @Column({ + type: 'uuid', + nullable: true, + }) + administrativu: string; + + @Column({ + type: 'uuid', + nullable: true, + }) + suco: string; + + @Column({ + type: 'uuid', + nullable: true, + }) + aldeia: string; + + @Column() + @CreateDateColumn() + created_at: Date; + + @Column() + @UpdateDateColumn() + updated_at: Date; + + @Column({ nullable: true }) + @DeleteDateColumn() + deleted_at: Date; +} \ No newline at end of file diff --git a/src/entity/lnkolek.ts b/src/entity/lnkolek.ts new file mode 100644 index 0000000..e224f8f --- /dev/null +++ b/src/entity/lnkolek.ts @@ -0,0 +1,113 @@ +import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, DeleteDateColumn } from 'typeorm'; + +@Entity('lnkolek') +export class LNKOLEK { + @PrimaryGeneratedColumn('uuid') + id: string; + + @Column({ + type: 'float', + nullable: false + }) + rate: string; + + @Column({ + nullable: false, + length: 32 + }) + cif: string; + + @Column({ + nullable: false, + length: 128 + }) + loan_holder_name: string; + + @Column({ + nullable: false, + length: 32 + }) + loan_number: string; + + @Column({ + nullable: false, + length: 4 + }) + branch_code: string; + + @Column({ + nullable: false, + }) + start_date: Date; + + @Column({ + nullable: false, + }) + due_date: Date; + + @Column({ + type: 'float8', + nullable: false, + }) + plafon: number; + + @Column({ + type: 'float8', + nullable: false, + }) + balance: number; + + @Column({ + type: 'int2', + nullable: false, + }) + collect: number; + + @Column({ + nullable: false, + }) + collect_date: Date; + + @Column({ + type: 'int2', + nullable: false, + }) + number_of_days_due: number; + + @Column({ + type: 'int2', + nullable: false, + }) + credit_segmentation: number; + + @Column({ + type: 'int2', + nullable: false, + }) + status: number; + + @Column({ + type: 'float', + nullable: false, + }) + ppap_percent: number; + + + @Column({ + type: 'float8', + nullable: false, + }) + ppap: number; + + @Column() + @CreateDateColumn() + created_at: Date; + + @Column() + @UpdateDateColumn() + updated_at: Date; + + @Column({ nullable: true }) + @DeleteDateColumn() + deleted_at: Date; +} \ No newline at end of file diff --git a/src/entity/trial_balance.ts b/src/entity/trial_balance.ts new file mode 100644 index 0000000..305b284 --- /dev/null +++ b/src/entity/trial_balance.ts @@ -0,0 +1,85 @@ +import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, DeleteDateColumn } from 'typeorm'; + +@Entity('trial_balance') +export class TrialBalance { + @PrimaryGeneratedColumn('uuid') + id: string; + + @Column({ + unique: true, + nullable: false, + length: 64 + }) + ledger: string; + + @Column({ + nullable: false, + length: 256 + }) + description: string; + + @Column({ + nullable: false, + length: 32 + }) + type: string; + + @Column({ + nullable: false, + length: 1 + }) + dc: string; + + @Column({ + type: 'float8', + nullable: false, + }) + initial_balance: number; + + @Column({ + type: 'float8', + nullable: false, + }) + debet_transaction: number; + + @Column({ + type: 'float8', + nullable: false, + }) + credit_transaction: number; + + @Column({ + type: 'float8', + nullable: false, + }) + closing_balance: number; + + @Column({ + type: 'float8', + nullable: false, + }) + closing_balance_eq: number; + + @Column({ + nullable: false, + length: 3 + }) + currency: string; + + @Column({ + nullable: false, + }) + position_date: Date; + + @Column() + @CreateDateColumn() + created_at: Date; + + @Column() + @UpdateDateColumn() + updated_at: Date; + + @Column({ nullable: true }) + @DeleteDateColumn() + deleted_at: Date; +} \ No newline at end of file diff --git a/src/entity/user_activity.ts b/src/entity/user_activity.ts new file mode 100644 index 0000000..31fd37d --- /dev/null +++ b/src/entity/user_activity.ts @@ -0,0 +1,64 @@ +import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, DeleteDateColumn, Index } from 'typeorm'; + +import { ActivityType } from '../types/action'; + +@Entity('user_activities') +export class UserActivity { + @PrimaryGeneratedColumn('uuid') + id: string; + + @Index() + @Column({ + type: 'uuid' + }) + id_user: string; + + @Index() + @Column({ + type: 'uuid' + }) + refresh_token: string; + + @Index() + @Column({ + nullable: false, + length: 512 + }) + module: string; + + @Column({ + nullable: false, + length: 2048 + }) + description: string; + + @Column({ + nullable: true, + length: 1 + }) + action: ActivityType; + + @Column({ + nullable: false, + length: 2048, + }) + url: String; + + @Column({ + type: 'text', + nullable: true, + }) + data_body: String; + + @Column() + @CreateDateColumn() + created_at: Date; + + @Column({ nullable: true }) + @UpdateDateColumn() + updated_at: Date; + + @Column({ nullable: true }) + @DeleteDateColumn() + deleted_at: Date; +} \ No newline at end of file diff --git a/src/entity/user_refresh_token.ts b/src/entity/user_refresh_token.ts new file mode 100644 index 0000000..cc3181e --- /dev/null +++ b/src/entity/user_refresh_token.ts @@ -0,0 +1,64 @@ +import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, DeleteDateColumn, Index } from 'typeorm'; + +@Entity('user_refresh_tokens') +export class UserRefreshToken { + @PrimaryGeneratedColumn('uuid') + refresh_token: string; + + @Index() + @Column({ + type: 'uuid' + }) + id_user: string; + + @Column({ + nullable: false, + length: 4096, + }) + user_agent: string; + + @Column({ + nullable: true, + length: 128 + }) + os: string; + + @Column({ + nullable: true, + length: 256 + }) + device: string; + + @Column({ + nullable: true, + length: 64 + }) + platform: string; + + @Column({ + nullable: true, + length: 64 + }) + browser: string; + + @Column({ + nullable: true, + length: 32 + }) + remote_addr: string; + + @Column('timestamp') + expired_at: Date; + + @Column() + @CreateDateColumn() + created_at: Date; + + @Column({ nullable: true }) + @UpdateDateColumn() + updated_at: Date; + + @Column({ nullable: true }) + @DeleteDateColumn() + deleted_at: Date; +} \ No newline at end of file diff --git a/src/entity/users.ts b/src/entity/users.ts new file mode 100644 index 0000000..295e9b2 --- /dev/null +++ b/src/entity/users.ts @@ -0,0 +1,76 @@ +import bcrypt from 'bcryptjs'; +import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, DeleteDateColumn, Index } from 'typeorm'; + +import { Status } from '../types/status'; + +@Entity('users') +export class User { + @PrimaryGeneratedColumn('uuid') + id: string; + + @Column({ + nullable: false, + unique: true, + length: 64 + }) + email: string; + + @Column({ + nullable: false, + length: 64, + select: false + }) + password: string; + + @Column({ + nullable: false, + unique: true, + length: 64 + }) + username: string; + + @Column({ + nullable: true, + length: 64 + }) + name: string; + + @Column({ + nullable: true, + type: 'uuid' + }) + id_role: string; + + @Index() + @Column({ + nullable: true, + type: 'uuid' + }) + reset_token: string; + + @Column({ + nullable: false, + length: 64 + }) + status: Status; + + @Column() + @CreateDateColumn() + created_at: Date; + + @Column({ nullable: true }) + @UpdateDateColumn() + updated_at: Date; + + @Column({ nullable: true }) + @DeleteDateColumn() + deleted_at: Date; + + hashPassword() { + this.password = bcrypt.hashSync(this.password, 8); + } + + checkIfPasswordMatch(unencryptedPassword: string) { + return bcrypt.compareSync(unencryptedPassword, this.password); + } +} \ No newline at end of file diff --git a/src/entity/users_roles.ts b/src/entity/users_roles.ts new file mode 100644 index 0000000..19dc98d --- /dev/null +++ b/src/entity/users_roles.ts @@ -0,0 +1,41 @@ +import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, DeleteDateColumn } from 'typeorm'; + +import { Status } from '../types/status'; +import { RoleList } from '../types/role'; + +@Entity('user_roles') +export class UserRole { + @PrimaryGeneratedColumn('uuid') + id: string; + + @Column({ + nullable: false, + unique: true, + length: 128 + }) + name: string; + + @Column({ + nullable: false, + type: 'jsonb' + }) + roles: RoleList[]; + + @Column({ + nullable: false, + length: 64 + }) + status: Status; + + @Column() + @CreateDateColumn() + created_at: Date; + + @Column({ nullable: true }) + @UpdateDateColumn() + updated_at: Date; + + @Column({ nullable: true }) + @DeleteDateColumn() + deleted_at: Date; +} \ No newline at end of file diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..94438a9 --- /dev/null +++ b/src/index.ts @@ -0,0 +1,9 @@ +import { CifAccount } from "./entity/cif_account"; +import { LNKOLEK } from "./entity/lnkolek"; +import { TrialBalance } from "./entity/trial_balance"; +import { UserActivity } from "./entity/user_activity"; +import { UserRefreshToken } from "./entity/user_refresh_token"; +import { User } from "./entity/users"; +import { UserRole } from "./entity/users_roles"; + +export { User, UserRole, UserActivity, UserRefreshToken, TrialBalance, LNKOLEK, CifAccount }; \ No newline at end of file diff --git a/src/types/action.ts b/src/types/action.ts new file mode 100644 index 0000000..314bcad --- /dev/null +++ b/src/types/action.ts @@ -0,0 +1,7 @@ +export enum ActivityType { + "Create" = "C", + "View" = "V", + "Update" = "U", + "Delete" = "D", + "Restore" = "T", +}; \ No newline at end of file diff --git a/src/types/error.ts b/src/types/error.ts new file mode 100644 index 0000000..1415969 --- /dev/null +++ b/src/types/error.ts @@ -0,0 +1,3 @@ +export type ErrorType = 'General' | 'Raw' | 'Validation' | 'Unauthorized'; + +export type ErrorValidation = { [key: string]: string }; \ No newline at end of file diff --git a/src/types/paging.ts b/src/types/paging.ts new file mode 100644 index 0000000..ee83de9 --- /dev/null +++ b/src/types/paging.ts @@ -0,0 +1,8 @@ +export interface Paging { + page: number, + limit: number, + filter: any, + with_deleted: boolean, + order_field: string, + order_direction: 'ASC' | 'DESC' +} \ No newline at end of file diff --git a/src/types/role.ts b/src/types/role.ts new file mode 100644 index 0000000..18edd28 --- /dev/null +++ b/src/types/role.ts @@ -0,0 +1,23 @@ +export enum RoleList { + "Dashboard" = "dashboard", + "Kinerja UKLN" = "ukln", + "Dana Pihak Ketiga" = "dpk", + "Posisi Outstanding Pinjaman" = "outstanding_loan", + "Presentasi NPL" = "npl", + "PPAP Amount NPL" = "ppap_amount", + "Report Regulator Bulanan" = "regulator_bulanan", + "Report Regulator Triwulan" = "regulator_triwulan", + "Report Regulator Publikasi" = "regulator_publikasi", + "Perhitungan Simulasi Perpajakan Per Bulan" = "pajak_per_bulan", + "Perhitungan Simulasi Perpajakan Per Tahun" = "pajak_per_tahun", + "Data Nasabah Potensial" = "nasabah_potensial", + "Master Data User" = "master_user", + "Master Data Product" = "master_product", + "Master Data Tier" = "master_tier", + "Master Klasifikasi Ekonomi" = "master_klasifikasi_ekonomi", + "Master District" = "master_district", + "Master Munisipu" = "master_munisipu", + "Master Administrativu" = "master_administrativu", + "Master Suco" = "master_suco", + "Master Aldeia" = "master_aldeia", +} \ No newline at end of file diff --git a/src/types/status.ts b/src/types/status.ts new file mode 100644 index 0000000..7408c75 --- /dev/null +++ b/src/types/status.ts @@ -0,0 +1,4 @@ +export enum Status { + "Active" = "Y", + "Not Active" = "N" +}; \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..6f17fc4 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,27 @@ +{ + "compilerOptions": { + "target": "es6", + "module": "commonjs", + "lib": ["dom", "es6", "es2017", "esnext.asynciterable"], + "sourceMap": true, + "outDir": "./dist", + "rootDir": "./", + "moduleResolution": "node", + "removeComments": true, + "allowSyntheticDefaultImports": true, + "esModuleInterop": true, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "resolveJsonModule": true, + "typeRoots": ["./src/types", "./node_modules/@types"], + // "baseUrl": "src/", + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "allowJs": true, + "declaration": true, + "emitDeclarationOnly": true, + "declarationMap": true + }, + "include": ["src/swagger-output.json", "src/langs/json/*.json", "./src/**/*.tsx", "./src/**/*.ts"], + "exclude": ["node_modules", "test/**/*.ts"] +}