finamaze_schema 1.32.0 → 1.34.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "finamaze_schema",
3
- "version": "1.32.0",
3
+ "version": "1.34.0",
4
4
  "description": "A package to connect two APIs with a single SQL database using TypeORM",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -8,14 +8,18 @@
8
8
  "build": "tsc",
9
9
  "migration:create": "ts-node node_modules/typeorm/cli.js migration:create ./src/migrations/$npm_config_name",
10
10
  "migrate": "ts-node node_modules/typeorm/cli.js migration:run -d ./src/data-source.ts",
11
- "migration:genearate": "ts-node node_modules/typeorm/cli.js migration:generate -d ./src/data-source.ts ./src/migrations/$npm_config_name",
12
- "migration:revert": "ts-node node_modules/typeorm/cli.js migration:revert -d ./src/data-source.ts"
11
+ "migration:genearate": "ts-node node_modules/typeorm/cli.js migration:generate -d ./src/data-source.ts ./src/migrations/$npm_config_name"
13
12
  },
14
13
  "keywords": [],
15
14
  "author": "",
16
15
  "license": "ISC",
17
16
  "dependencies": {
17
+ "@nestjs/common": "^10.4.1",
18
+ "@nestjs/config": "^3.2.3",
19
+ "@nestjs/core": "^10.4.1",
20
+ "@nestjs/typeorm": "^10.0.2",
18
21
  "dotenv": "^16.4.5",
22
+ "pg": "^8.12.0",
19
23
  "reflect-metadata": "^0.2.2",
20
24
  "typeorm": "^0.3.20"
21
25
  },
@@ -0,0 +1,14 @@
1
+ import { Entity, PrimaryGeneratedColumn, Column, ManyToOne } from 'typeorm';
2
+ import { User } from './user.entity';
3
+
4
+ @Entity()
5
+ export class Email {
6
+ @PrimaryGeneratedColumn()
7
+ id: number;
8
+
9
+ @Column( { nullable: false })
10
+ address: string;
11
+
12
+ @ManyToOne(() => User, (user) => user.emails, { nullable: false })
13
+ user: User;
14
+ }
@@ -0,0 +1,38 @@
1
+ import { Entity, PrimaryGeneratedColumn, Column,ManyToOne } from 'typeorm';
2
+ import { User } from './user.entity';
3
+
4
+ @Entity()
5
+ export class GoalPlan {
6
+ @PrimaryGeneratedColumn()
7
+ id: number;
8
+
9
+ @Column()
10
+ objective: string;
11
+
12
+ @Column({
13
+ type: 'varchar',
14
+ length: 3,
15
+ })
16
+ currency: 'USD' | 'SAR';
17
+
18
+ @Column({nullable: true})
19
+ initial_amount: number;
20
+
21
+ @Column({nullable: true})
22
+ target_amount: number;
23
+
24
+ @Column({nullable: true})
25
+ contribution_amount: number;
26
+
27
+ @Column()
28
+ contribution_frequency: string;
29
+
30
+ @Column()
31
+ start_date: string;
32
+
33
+ @Column({nullable: true})
34
+ investment_duration: number;
35
+
36
+ @ManyToOne(() => User, (user) => user.goal_plans, { nullable: false })
37
+ user: User;
38
+ }
@@ -1,56 +1,51 @@
1
- import {
2
- Entity,
3
- Column,
4
- PrimaryGeneratedColumn,
5
- CreateDateColumn,
6
- Unique,
7
- } from "typeorm";
1
+ import { Entity, Column, PrimaryGeneratedColumn, CreateDateColumn, Unique } from 'typeorm';
8
2
 
9
3
  @Entity()
10
- @Unique(["email"])
4
+ @Unique(['email'])
11
5
  export class Manager {
12
- @PrimaryGeneratedColumn()
13
- id: number;
14
-
15
- @Column({ nullable: true })
16
- username: string;
17
-
18
- @Column()
19
- email: string;
20
-
21
- @Column()
22
- password: string;
23
-
24
- @Column({ nullable: true })
25
- first_name: string;
26
-
27
- @Column({ nullable: true })
28
- last_name: string;
29
-
30
- @Column({ nullable: true })
31
- phone_number: string;
32
-
33
- @Column({ nullable: true })
34
- mobile_number: string;
35
-
36
- @Column({ nullable: true })
37
- department: string;
38
-
39
- @Column({ nullable: true })
40
- sub_department: string;
41
-
42
- @Column({ nullable: true })
43
- title: string;
44
-
45
- @Column()
46
- role: string;
47
-
48
- @Column({ nullable: true })
49
- is_deleted: boolean;
50
-
51
- @CreateDateColumn()
52
- created_at: Date;
53
-
54
- @CreateDateColumn()
55
- updated_at: Date;
56
- }
6
+ @PrimaryGeneratedColumn()
7
+ id: number;
8
+
9
+ @Column({ nullable: true })
10
+ username: string;
11
+
12
+ @Column()
13
+ email: string;
14
+
15
+ @Column()
16
+ password: string;
17
+
18
+ @Column({ nullable: true })
19
+ first_name: string;
20
+
21
+ @Column({ nullable: true })
22
+ last_name: string;
23
+
24
+ @Column({ nullable: true })
25
+ phone_number: string;
26
+
27
+ @Column({ nullable: true })
28
+ mobile_number: string;
29
+
30
+
31
+ @Column({ nullable: true })
32
+ department: string;
33
+
34
+ @Column({ nullable: true })
35
+ sub_department: string;
36
+
37
+ @Column({ nullable: true })
38
+ title: string;
39
+
40
+ @Column()
41
+ role: string;
42
+
43
+ @Column({ nullable: true })
44
+ is_deleted: boolean;
45
+
46
+ @CreateDateColumn()
47
+ created_at: Date;
48
+
49
+ @CreateDateColumn()
50
+ updated_at: Date;
51
+ }
@@ -0,0 +1,14 @@
1
+ import { User } from './user.entity';
2
+ import { Column, Entity, ManyToOne, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
3
+
4
+ @Entity()
5
+ export class PhoneNumber {
6
+ @PrimaryGeneratedColumn()
7
+ id: number;
8
+
9
+ @Column({ nullable: false })
10
+ number: string;
11
+
12
+ @ManyToOne(() => User, (user) => user.phone_numbers,{ nullable: false })
13
+ user: User;
14
+ }
@@ -1,65 +1,74 @@
1
- import {
2
- Entity,
3
- Column,
4
- PrimaryGeneratedColumn,
5
- CreateDateColumn,
6
- UpdateDateColumn,
7
- Unique,
8
- OneToMany,
9
- Index,
10
- DeleteDateColumn,
11
- } from "typeorm";
12
-
13
- export enum RegistrationStep {
14
- INITIATED = "INITIATED",
15
- COMPLETED = "COMPLETED",
16
- }
1
+ import { Entity, Column, PrimaryGeneratedColumn, CreateDateColumn, UpdateDateColumn, Unique, OneToMany, Index } from 'typeorm';
2
+ import { PhoneNumber } from './phone-number.entity';
3
+ import { Email } from './email.entity';
4
+ import { GoalPlan } from './goalPlan.entity';
17
5
 
18
6
  @Entity()
19
- @Unique(["username"])
7
+ @Unique(['username'])
20
8
  export class User {
21
- @PrimaryGeneratedColumn()
22
- id: number;
9
+ @PrimaryGeneratedColumn()
10
+ id: number;
11
+
12
+ @Column({ nullable: false })
13
+ username: string;
14
+
15
+ @Column({ nullable: true })
16
+ email: string;
17
+
18
+ @OneToMany(() => Email, (email) => email.user, { cascade: true })
19
+ emails: Email[];
20
+
21
+ @Column({ nullable: true })
22
+ password: string;
23
+
24
+ @Column({ nullable: true })
25
+ phone_number: string;
26
+
27
+ @OneToMany(() => PhoneNumber, (phoneNumber) => phoneNumber.user, { cascade: true })
28
+ phone_numbers: PhoneNumber[];
29
+
30
+ @Column({ nullable: true })
31
+ iqama_number: string;
23
32
 
24
- @Column({ nullable: true })
25
- username: string;
33
+ @Column({ nullable: true })
34
+ is_profile_complete: boolean;
26
35
 
27
- @Column({ nullable: true })
28
- email: string;
36
+ @Column({ nullable: true })
37
+ registration_step: string;
29
38
 
30
- @Column({ nullable: true, select: false })
31
- password: string;
39
+ @Column({ nullable: true })
40
+ smartcore_reference_id: number;
32
41
 
33
- @Column({ nullable: true })
34
- phone_number: string;
42
+ @Column({ nullable: true })
43
+ tcs_reference_id: string;
35
44
 
36
- @Column({ nullable: true })
37
- national_id: string;
45
+ @Column({ nullable: true })
46
+ name: string;
38
47
 
39
- @Column({ default: false })
40
- smartcore_sync_status: boolean;
48
+ @Column({ nullable: true })
49
+ type: string;
41
50
 
42
- @Column({ type: "varchar2", default: RegistrationStep.INITIATED })
43
- registration_step: RegistrationStep;
51
+ @Column({ nullable: true })
52
+ status: string;
44
53
 
45
- @Column({ nullable: true })
46
- smartcore_reference_id: number;
54
+ @Column({nullable: true })
55
+ risk_profile: string;
47
56
 
48
- @Column({ nullable: true })
49
- cif: string;
57
+ @Column({default: false})
58
+ is_username_set: boolean;
50
59
 
51
- @Column({ nullable: true })
52
- full_name: string;
53
60
 
54
- @Column({ type: "clob", nullable: true })
55
- metadata: string;
61
+ @Column({nullable: true })
62
+ external_status: string;
56
63
 
57
- @CreateDateColumn()
58
- created_at: Date;
64
+ // Automatically set on entity creation
65
+ @CreateDateColumn()
66
+ created_at: Date;
59
67
 
60
- @UpdateDateColumn()
61
- updated_at: Date;
68
+ // Automatically updated when entity is updated
69
+ @UpdateDateColumn()
70
+ updated_at: Date;
62
71
 
63
- @DeleteDateColumn()
64
- deleted_at: Date | null;
72
+ @OneToMany(() => GoalPlan, (goalPlan) => goalPlan.user, { cascade: true })
73
+ goal_plans: GoalPlan[];
65
74
  }
package/src/index.ts CHANGED
@@ -8,3 +8,6 @@
8
8
 
9
9
  export * from './entity/user.entity';
10
10
  export * from './entity/manager.entity';
11
+ export * from './entity/phone-number.entity';
12
+ export * from './entity/email.entity';
13
+ export * from './entity/goalPlan.entity';
@@ -1,37 +0,0 @@
1
- import { MigrationInterface, QueryRunner } from "typeorm";
2
-
3
- export class V11733323133759 implements MigrationInterface {
4
- name = 'V11733323133759'
5
-
6
- public async up(queryRunner: QueryRunner): Promise<void> {
7
- await queryRunner.query(`ALTER TABLE "user" RENAME COLUMN "iqama_number" TO "national_id"`);
8
- await queryRunner.query(`ALTER TABLE "user" RENAME COLUMN "is_profile_complete" TO "smartcore_sync_status"`);
9
- await queryRunner.query(`UPDATE "user" SET "smartcore_sync_status" = 0 WHERE "smartcore_sync_status" IS NULL`);
10
- await queryRunner.query(`ALTER TABLE "user" MODIFY "smartcore_sync_status" DEFAULT 0`);
11
- await queryRunner.query(`ALTER TABLE "user" MODIFY "smartcore_sync_status" NOT NULL`);
12
- await queryRunner.query(`ALTER TABLE "user" DROP COLUMN "status"`);
13
- await queryRunner.query(`ALTER TABLE "user" DROP COLUMN "risk_profile"`);
14
- await queryRunner.query(`ALTER TABLE "user" DROP COLUMN "is_username_set"`);
15
- await queryRunner.query(`ALTER TABLE "user" DROP COLUMN "external_status"`);
16
- await queryRunner.query(`ALTER TABLE "user" ADD "meta_data" clob`);
17
- await queryRunner.query(`ALTER TABLE "user" ADD "deleted_at" timestamp`);
18
- await queryRunner.query(`ALTER TABLE "user" MODIFY "username" varchar2(255) NULL`);
19
- await queryRunner.query(`ALTER TABLE "user" MODIFY "registration_step" varchar2(255) DEFAULT 'INITIATED' NOT NULL`);
20
- }
21
-
22
- public async down(queryRunner: QueryRunner): Promise<void> {
23
- await queryRunner.query(`ALTER TABLE "user" MODIFY "registration_step" varchar2(255) NULL`);
24
- await queryRunner.query(`ALTER TABLE "user" MODIFY "username" varchar2(255) NOT NULL`);
25
- await queryRunner.query(`ALTER TABLE "user" DROP COLUMN "deleted_at"`);
26
- await queryRunner.query(`ALTER TABLE "user" DROP COLUMN "meta_data"`);
27
- await queryRunner.query(`ALTER TABLE "user" ADD "external_status" varchar2(255) NULL`);
28
- await queryRunner.query(`ALTER TABLE "user" ADD "is_username_set" number DEFAULT 0 NOT NULL`);
29
- await queryRunner.query(`ALTER TABLE "user" ADD "risk_profile" varchar2(255) NULL`);
30
- await queryRunner.query(`ALTER TABLE "user" ADD "status" varchar2(255) NULL`);
31
- await queryRunner.query(`ALTER TABLE "user" RENAME COLUMN "smartcore_sync_status" To "is_profile_complete"`);
32
- await queryRunner.query(`ALTER TABLE "user" MODIFY "is_profile_complete" NULL`);
33
- await queryRunner.query(`ALTER TABLE "user" RENAME COLUMN "national_id" TO "iqama_number"`);
34
-
35
- }
36
-
37
- }
@@ -1,24 +0,0 @@
1
- import { MigrationInterface, QueryRunner } from "typeorm";
2
-
3
- export class V21734104865215 implements MigrationInterface {
4
- name = 'V21734104865215'
5
-
6
- public async up(queryRunner: QueryRunner): Promise<void> {
7
- await queryRunner.query(`ALTER TABLE "user" RENAME COLUMN "name" TO "full_name"`);
8
- await queryRunner.query(`ALTER TABLE "user" DROP COLUMN "type"`);
9
- await queryRunner.query(`ALTER TABLE "user" RENAME COLUMN "meta_data" TO "metadata"`);
10
- await queryRunner.query(`ALTER TABLE "user" RENAME COLUMN "tcs_reference_id" TO "cif"`);
11
- await queryRunner.query(`ALTER TABLE "user" ADD CONSTRAINT "UQ_78a916df40e02a9deb1c4b75edb" UNIQUE ("username")`);
12
- await queryRunner.query(`DROP TABLE "goal_plan"`);
13
- await queryRunner.query(`DROP TABLE "phone_number"`);
14
- await queryRunner.query(`Drop TABLE "email"`);
15
- }
16
-
17
- public async down(queryRunner: QueryRunner): Promise<void> {
18
- await queryRunner.query(`ALTER TABLE "user" RENAME COLUMN "cif" TO "tcs_reference_id"`);
19
- await queryRunner.query(`ALTER TABLE "user" RENAME COLUMN "metadata" TO "meta_data"`);
20
- await queryRunner.query(`ALTER TABLE "user" ADD "type" varchar2(255)`);
21
- await queryRunner.query(`ALTER TABLE "user" RENAME COLUMN "full_name" TO "name"`);
22
- }
23
-
24
- }