@tomei/sso 0.8.2 → 0.8.5

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.
Files changed (30) hide show
  1. package/Jenkinsfile +6 -1
  2. package/dist/src/components/login-history/login-history.repository.js.map +1 -1
  3. package/dist/src/components/login-user/login-user.js +6 -6
  4. package/dist/src/components/login-user/login-user.js.map +1 -1
  5. package/dist/src/components/login-user/user.repository.js.map +1 -1
  6. package/dist/src/components/system/system.repository.d.ts +1 -1
  7. package/dist/src/components/system/system.repository.js +1 -1
  8. package/dist/src/components/system/system.repository.js.map +1 -1
  9. package/dist/src/components/system-access/system-access.repository.js.map +1 -1
  10. package/dist/src/components/user-group/user-group.repository.js.map +1 -1
  11. package/dist/src/components/user-user-group/user-user-group.repository.d.ts +1 -1
  12. package/dist/src/components/user-user-group/user-user-group.repository.js +1 -1
  13. package/dist/src/components/user-user-group/user-user-group.repository.js.map +1 -1
  14. package/dist/src/models/building.entity.d.ts +11 -0
  15. package/dist/src/models/building.entity.js +33 -0
  16. package/dist/src/models/building.entity.js.map +1 -1
  17. package/dist/src/models/user-role.entity.d.ts +3 -0
  18. package/dist/src/models/user-role.entity.js +11 -0
  19. package/dist/src/models/user-role.entity.js.map +1 -1
  20. package/dist/tsconfig.tsbuildinfo +1 -1
  21. package/package.json +1 -1
  22. package/src/components/login-history/login-history.repository.ts +0 -34
  23. package/src/components/login-user/login-user.ts +7 -7
  24. package/src/components/login-user/user.repository.ts +0 -34
  25. package/src/components/system/system.repository.ts +1 -34
  26. package/src/components/system-access/system-access.repository.ts +0 -34
  27. package/src/components/user-group/user-group.repository.ts +0 -34
  28. package/src/components/user-user-group/user-user-group.repository.ts +1 -35
  29. package/src/models/building.entity.ts +30 -0
  30. package/src/models/user-role.entity.ts +9 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tomei/sso",
3
- "version": "0.8.2",
3
+ "version": "0.8.5",
4
4
  "description": "Tomei SSO Package",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -1,38 +1,4 @@
1
1
  import LoginHistory from '../../models/login-history.entity';
2
- import prisma from '../../prisma-client/client';
3
-
4
- // export class LoginHistoryRepository {
5
- // private _prisma: any;
6
-
7
- // constructor(client?: any) {
8
- // if (client) {
9
- // this._prisma = client;
10
- // } else {
11
- // this._prisma = prisma;
12
- // }
13
- // }
14
-
15
- // public async create(data: any): Promise<any> {
16
- // return await this._prisma.loginHistory.create(data);
17
- // }
18
-
19
- // public async findAll(options: any): Promise<any[]> {
20
- // return await this._prisma.loginHistory.findMany(options);
21
- // }
22
-
23
- // public async findOne(options: any): Promise<any> {
24
- // return await this._prisma.loginHistory.findFirst(options);
25
- // }
26
-
27
- // public async update(where: any, data: any): Promise<any> {
28
- // return await this._prisma.loginHistory.update(where, data);
29
- // }
30
-
31
- // public async delete(where: any): Promise<any> {
32
- // return await this._prisma.loginHistory.delete(where);
33
- // }
34
- // }
35
-
36
2
  import { RepositoryBase, IRepositoryBase } from '@tomei/general';
37
3
 
38
4
  export class LoginHistoryRepository
@@ -13,13 +13,13 @@ import { UserGroupRepository } from '../user-group/user-group.repository';
13
13
  import * as nodemailer from 'nodemailer';
14
14
  import { Mailer } from '@tomei/mailer';
15
15
  import { ISystemLogin } from '../../../src/interfaces/system-login.interface';
16
- import Staff from 'models/staff.entity';
17
- import SystemPrivilege from 'models/system-privilege.entity';
18
- import LoginHistory from 'models/login-history.entity';
19
- import GroupSystemPrivilege from 'models/group-system-privilege.entity';
20
- import GroupRolePrivilege from 'models/group-role-privilege.entity';
21
- import UserGroup from 'models/user-group.entity';
22
- import UserSystemPrivileges from 'models/user-system-privileges.entity';
16
+ import Staff from '../../models/staff.entity';
17
+ import SystemPrivilege from '../../models/system-privilege.entity';
18
+ import LoginHistory from '../../models/login-history.entity';
19
+ import GroupSystemPrivilege from '../../models/group-system-privilege.entity';
20
+ import GroupRolePrivilege from '../../models/group-role-privilege.entity';
21
+ import UserGroup from '../../models/user-group.entity';
22
+ import UserSystemPrivileges from '../../models/user-system-privileges.entity';
23
23
  export class LoginUser extends ObjectBase implements IPerson {
24
24
  FullName: string;
25
25
  IDNo: string;
@@ -1,38 +1,4 @@
1
1
  import User from '../../models/user.entity';
2
- import prisma from '../../prisma-client/client';
3
-
4
- // export class UserRepository {
5
- // private _prisma: any;
6
-
7
- // constructor(client?: any) {
8
- // if (client) {
9
- // this._prisma = client;
10
- // } else {
11
- // this._prisma = prisma;
12
- // }
13
- // }
14
-
15
- // public async create(data: any): Promise<any> {
16
- // return await this._prisma.user.create(data);
17
- // }
18
-
19
- // public async findAll(options: any): Promise<any[]> {
20
- // return await this._prisma.user.findMany(options);
21
- // }
22
-
23
- // public async findOne(options: any): Promise<any> {
24
- // return await this._prisma.user.findFirst(options);
25
- // }
26
-
27
- // public async update(where: any, data: any): Promise<any> {
28
- // return await this._prisma.user.update(where, data);
29
- // }
30
-
31
- // public async delete(where: any): Promise<any> {
32
- // return await this._prisma.user.delete(where);
33
- // }
34
- // }
35
-
36
2
  import { RepositoryBase, IRepositoryBase } from '@tomei/general';
37
3
 
38
4
  export class UserRepository
@@ -1,39 +1,6 @@
1
- import System from 'models/system.entity';
2
- import prisma from '../../prisma-client/client';
1
+ import System from '../../models/system.entity';
3
2
  import { RepositoryBase, IRepositoryBase } from '@tomei/general';
4
3
 
5
- // export class SystemRepository {
6
- // private _prisma: any;
7
-
8
- // constructor(client?: any) {
9
- // if (client) {
10
- // this._prisma = client;
11
- // } else {
12
- // this._prisma = prisma;
13
- // }
14
- // }
15
-
16
- // public async create(data: any): Promise<any> {
17
- // return await this._prisma.system.create(data);
18
- // }
19
-
20
- // public async findAll(options: any): Promise<any[]> {
21
- // return await this._prisma.system.findMany(options);
22
- // }
23
-
24
- // public async findOne(options: any): Promise<any> {
25
- // return await this._prisma.system.findFirst(options);
26
- // }
27
-
28
- // public async update(where: any, data: any): Promise<any> {
29
- // return await this._prisma.system.update(where, data);
30
- // }
31
-
32
- // public async delete(where: any): Promise<any> {
33
- // return await this._prisma.system.delete(where);
34
- // }
35
- // }
36
-
37
4
  export class SystemRepository
38
5
  extends RepositoryBase<System>
39
6
  implements IRepositoryBase<System>
@@ -1,38 +1,4 @@
1
1
  import SystemAccess from '../../models/system-accesss.entity';
2
- import prisma from '../../prisma-client/client';
3
-
4
- // export class SystemAccessRepository {
5
- // private _prisma: any;
6
-
7
- // constructor(client?: any) {
8
- // if (client) {
9
- // this._prisma = client;
10
- // } else {
11
- // this._prisma = prisma;
12
- // }
13
- // }
14
-
15
- // public async create(data: any): Promise<any> {
16
- // return await this._prisma.systemAccess.create(data);
17
- // }
18
-
19
- // public async findAll(options: any): Promise<any[]> {
20
- // return await this._prisma.systemAccess.findMany(options);
21
- // }
22
-
23
- // public async findOne(options: any): Promise<any> {
24
- // return await this._prisma.systemAccess.findFirst(options);
25
- // }
26
-
27
- // public async update(where: any, data: any): Promise<any> {
28
- // return await this._prisma.systemAccess.update(where, data);
29
- // }
30
-
31
- // public async delete(where: any): Promise<any> {
32
- // return await this._prisma.systemAccess.delete(where);
33
- // }
34
- // }
35
-
36
2
  import { RepositoryBase, IRepositoryBase } from '@tomei/general';
37
3
 
38
4
  export class SystemAccessRepository
@@ -1,38 +1,4 @@
1
1
  import UserGroup from '../../models/user-group.entity';
2
- import prisma from '../../prisma-client/client';
3
-
4
- // export class UserGroupRepository {
5
- // private _prisma: any;
6
-
7
- // constructor(client?: any) {
8
- // if (client) {
9
- // this._prisma = client;
10
- // } else {
11
- // this._prisma = prisma;
12
- // }
13
- // }
14
-
15
- // public async create(data: any): Promise<any> {
16
- // return await this._prisma.userGroup.create(data);
17
- // }
18
-
19
- // public async findAll(options: any): Promise<any[]> {
20
- // return await this._prisma.userGroup.findMany(options);
21
- // }
22
-
23
- // public async findOne(options: any): Promise<any> {
24
- // return await this._prisma.userGroup.findFirst(options);
25
- // }
26
-
27
- // public async update(where: any, data: any): Promise<any> {
28
- // return await this._prisma.userGroup.update(where, data);
29
- // }
30
-
31
- // public async delete(where: any): Promise<any> {
32
- // return await this._prisma.userGroups.delete(where);
33
- // }
34
- // }
35
-
36
2
  import { RepositoryBase, IRepositoryBase } from '@tomei/general';
37
3
 
38
4
  export class UserGroupRepository
@@ -1,38 +1,4 @@
1
- import UserUserGroup from 'models/user-user-group.entity';
2
- import prisma from '../../prisma-client/client';
3
-
4
- // export class UserUserGroupRepository {
5
- // private _prisma: any;
6
-
7
- // constructor(client?: any) {
8
- // if (client) {
9
- // this._prisma = client;
10
- // } else {
11
- // this._prisma = prisma;
12
- // }
13
- // }
14
-
15
- // public async create(data: any): Promise<any> {
16
- // return await this._prisma.userUserGroup.create(data);
17
- // }
18
-
19
- // public async findAll(options: any): Promise<any[]> {
20
- // return await this._prisma.userUserGroup.findMany(options);
21
- // }
22
-
23
- // public async findOne(options: any): Promise<any> {
24
- // return await this._prisma.userUserGroup.findFirst(options);
25
- // }
26
-
27
- // public async update(where: any, data: any): Promise<any> {
28
- // return await this._prisma.userUserGroup.update(where, data);
29
- // }
30
-
31
- // public async delete(where: any): Promise<any> {
32
- // return await this._prisma.userUserGroup.delete(where);
33
- // }
34
- // }
35
-
1
+ import UserUserGroup from '../../models/user-user-group.entity';
36
2
  import { RepositoryBase, IRepositoryBase } from '@tomei/general';
37
3
 
38
4
  export class UserUserGroupRepository
@@ -1,11 +1,19 @@
1
1
  import {
2
+ BelongsTo,
2
3
  Column,
3
4
  CreatedAt,
4
5
  DataType,
6
+ ForeignKey,
7
+ HasMany,
5
8
  Model,
6
9
  Table,
7
10
  UpdatedAt,
8
11
  } from 'sequelize-typescript';
12
+ import BuildingType from './building-type.entity';
13
+ import Country from './country.entity';
14
+ import User from './user.entity';
15
+ import Department from './department.entity';
16
+ import Staff from './staff.entity';
9
17
 
10
18
  @Table({
11
19
  tableName: 'sso_buildings',
@@ -37,6 +45,7 @@ export default class Building extends Model {
37
45
  })
38
46
  Code: string;
39
47
 
48
+ @ForeignKey(() => BuildingType)
40
49
  @Column({
41
50
  allowNull: false,
42
51
  type: DataType.INTEGER,
@@ -100,6 +109,7 @@ export default class Building extends Model {
100
109
  })
101
110
  PostCode: string;
102
111
 
112
+ @ForeignKey(() => Country)
103
113
  @Column({
104
114
  allowNull: false,
105
115
  type: DataType.INTEGER,
@@ -121,6 +131,7 @@ export default class Building extends Model {
121
131
  })
122
132
  City: string;
123
133
 
134
+ @ForeignKey(() => User)
124
135
  @Column({
125
136
  allowNull: true,
126
137
  type: DataType.INTEGER,
@@ -128,6 +139,7 @@ export default class Building extends Model {
128
139
  })
129
140
  CreatedById: number;
130
141
 
142
+ @ForeignKey(() => User)
131
143
  @Column({
132
144
  allowNull: true,
133
145
  type: DataType.INTEGER,
@@ -182,4 +194,22 @@ export default class Building extends Model {
182
194
 
183
195
  @UpdatedAt
184
196
  UpdatedAt: Date;
197
+
198
+ @BelongsTo(() => BuildingType)
199
+ BuildingType: BuildingType;
200
+
201
+ @BelongsTo(() => Country)
202
+ Country: Country;
203
+
204
+ @BelongsTo(() => User, 'created_by_id')
205
+ CreatedBy: User;
206
+
207
+ @BelongsTo(() => User, 'updated_by_id')
208
+ UpdatedBy: User;
209
+
210
+ @HasMany(() => Department)
211
+ Departments: Department[];
212
+
213
+ @HasMany(() => Staff)
214
+ Staffs: Staff[];
185
215
  }
@@ -8,6 +8,7 @@ import {
8
8
  UpdatedAt,
9
9
  } from 'sequelize-typescript';
10
10
  import User from './user.entity';
11
+ import Role from './role.entity';
11
12
 
12
13
  @Table({
13
14
  tableName: 'sso_user_roles',
@@ -17,6 +18,7 @@ import User from './user.entity';
17
18
  underscored: true,
18
19
  })
19
20
  export default class UserRole extends Model {
21
+ @ForeignKey(() => User)
20
22
  @Column({
21
23
  primaryKey: true,
22
24
  type: DataType.INTEGER,
@@ -25,6 +27,7 @@ export default class UserRole extends Model {
25
27
  })
26
28
  UserId: number;
27
29
 
30
+ @ForeignKey(() => Role)
28
31
  @Column({
29
32
  primaryKey: true,
30
33
  type: DataType.INTEGER,
@@ -47,4 +50,10 @@ export default class UserRole extends Model {
47
50
 
48
51
  @BelongsTo(() => User)
49
52
  User: User;
53
+
54
+ @BelongsTo(() => Role)
55
+ Role: Role;
56
+
57
+ @BelongsTo(() => User, 'updated_by_id')
58
+ UpdatedBy: User;
50
59
  }