@tomei/sso 0.16.3 → 0.16.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 (105) hide show
  1. package/.commitlintrc.json +22 -22
  2. package/.eslintrc +16 -16
  3. package/.eslintrc.js +35 -35
  4. package/.husky/commit-msg +15 -15
  5. package/.husky/pre-commit +7 -7
  6. package/.prettierrc +4 -4
  7. package/Jenkinsfile +57 -57
  8. package/README.md +23 -23
  9. package/__tests__/unit/components/login-user/login-user.spec.ts +742 -742
  10. package/__tests__/unit/components/password-hash/password-hash.service.spec.ts +31 -31
  11. package/__tests__/unit/redis-client/redis.service.spec.ts +23 -23
  12. package/__tests__/unit/session/session.service.spec.ts +47 -47
  13. package/__tests__/unit/system-privilege/system-privilage.spec.ts +91 -91
  14. package/create-sso-user.sql +39 -39
  15. package/dist/src/components/index.d.ts +3 -0
  16. package/dist/src/components/index.js +3 -0
  17. package/dist/src/components/index.js.map +1 -1
  18. package/dist/src/components/sso-group/group.d.ts +26 -0
  19. package/dist/src/components/sso-group/group.js +66 -0
  20. package/dist/src/components/sso-group/group.js.map +1 -0
  21. package/dist/src/components/sso-group/group.repository.d.ts +5 -0
  22. package/dist/src/components/sso-group/group.repository.js +12 -0
  23. package/dist/src/components/sso-group/group.repository.js.map +1 -0
  24. package/dist/src/components/sso-group/index.d.ts +2 -0
  25. package/dist/src/components/sso-group/index.js +19 -0
  26. package/dist/src/components/sso-group/index.js.map +1 -0
  27. package/dist/src/components/sso-group-reporting-user/group-reporting-user.d.ts +23 -0
  28. package/dist/src/components/sso-group-reporting-user/group-reporting-user.js +64 -0
  29. package/dist/src/components/sso-group-reporting-user/group-reporting-user.js.map +1 -0
  30. package/dist/src/components/sso-group-reporting-user/group-reporting-user.repository.d.ts +5 -0
  31. package/dist/src/components/sso-group-reporting-user/group-reporting-user.repository.js +12 -0
  32. package/dist/src/components/sso-group-reporting-user/group-reporting-user.repository.js.map +1 -0
  33. package/dist/src/components/sso-group-reporting-user/index.d.ts +2 -0
  34. package/dist/src/components/sso-group-reporting-user/index.js +19 -0
  35. package/dist/src/components/sso-group-reporting-user/index.js.map +1 -0
  36. package/dist/src/components/sso-system/index.d.ts +2 -0
  37. package/dist/src/components/sso-system/index.js +19 -0
  38. package/dist/src/components/sso-system/index.js.map +1 -0
  39. package/dist/src/components/sso-system/system.d.ts +28 -0
  40. package/dist/src/components/sso-system/system.js +68 -0
  41. package/dist/src/components/sso-system/system.js.map +1 -0
  42. package/dist/src/components/sso-system/system.repository.d.ts +5 -0
  43. package/dist/src/components/sso-system/system.repository.js +12 -0
  44. package/dist/src/components/sso-system/system.repository.js.map +1 -0
  45. package/dist/src/components/staff/staff.js +1 -1
  46. package/dist/src/components/staff/staff.js.map +1 -1
  47. package/dist/src/enum/group-type.enum.d.ts +8 -0
  48. package/dist/src/enum/group-type.enum.js +13 -0
  49. package/dist/src/enum/group-type.enum.js.map +1 -0
  50. package/dist/src/enum/index.d.ts +1 -0
  51. package/dist/src/enum/index.js +1 -0
  52. package/dist/src/enum/index.js.map +1 -1
  53. package/dist/src/interfaces/group-reporting-user.interface.d.ts +11 -0
  54. package/dist/src/interfaces/group-reporting-user.interface.js +3 -0
  55. package/dist/src/interfaces/group-reporting-user.interface.js.map +1 -0
  56. package/dist/src/interfaces/group.interface.d.ts +14 -0
  57. package/dist/src/interfaces/group.interface.js +3 -0
  58. package/dist/src/interfaces/group.interface.js.map +1 -0
  59. package/dist/src/interfaces/index.d.ts +3 -0
  60. package/dist/src/interfaces/index.js +3 -0
  61. package/dist/src/interfaces/index.js.map +1 -1
  62. package/dist/src/interfaces/system.interface.d.ts +15 -0
  63. package/dist/src/interfaces/system.interface.js +3 -0
  64. package/dist/src/interfaces/system.interface.js.map +1 -0
  65. package/dist/src/models/sso-group-reporting-user.entity.d.ts +17 -0
  66. package/dist/src/models/sso-group-reporting-user.entity.js +105 -0
  67. package/dist/src/models/sso-group-reporting-user.entity.js.map +1 -0
  68. package/dist/src/models/sso-group.entity.d.ts +18 -0
  69. package/dist/src/models/sso-group.entity.js +111 -0
  70. package/dist/src/models/sso-group.entity.js.map +1 -0
  71. package/dist/src/models/sso-system.entity.d.ts +19 -0
  72. package/dist/src/models/sso-system.entity.js +122 -0
  73. package/dist/src/models/sso-system.entity.js.map +1 -0
  74. package/dist/tsconfig.tsbuildinfo +1 -1
  75. package/jest.config.js +13 -13
  76. package/migrations/20240314080603-create-user-table.js +108 -108
  77. package/migrations/20240314080604-create-user-user-group-table.js +55 -55
  78. package/migrations/20240314080605-create-login-history-table.js +49 -49
  79. package/migrations/20240527064925-create-system-table.js +78 -0
  80. package/migrations/20240527065342-create-group-table.js +84 -0
  81. package/migrations/20240527065633-create-group-reporting-user-table.js +72 -0
  82. package/package.json +80 -80
  83. package/sampledotenv +7 -7
  84. package/src/components/index.ts +5 -0
  85. package/src/components/sso-group/group.repository.ts +11 -0
  86. package/src/components/sso-group/group.ts +77 -0
  87. package/src/components/sso-group/index.ts +3 -0
  88. package/src/components/sso-group-reporting-user/group-reporting-user.repository.ts +11 -0
  89. package/src/components/sso-group-reporting-user/group-reporting-user.ts +79 -0
  90. package/src/components/sso-group-reporting-user/index.ts +3 -0
  91. package/src/components/sso-system/index.ts +3 -0
  92. package/src/components/sso-system/system.repository.ts +11 -0
  93. package/src/components/sso-system/system.ts +81 -0
  94. package/src/components/staff/staff.ts +3 -1
  95. package/src/enum/group-type.enum.ts +8 -0
  96. package/src/enum/index.ts +1 -0
  97. package/src/interfaces/group-reporting-user.interface.ts +13 -0
  98. package/src/interfaces/group.interface.ts +15 -0
  99. package/src/interfaces/index.ts +3 -0
  100. package/src/interfaces/system.interface.ts +15 -0
  101. package/src/models/sso-group-reporting-user.entity.ts +86 -0
  102. package/src/models/sso-group.entity.ts +91 -0
  103. package/src/models/sso-system.entity.ts +101 -0
  104. package/tsconfig.build.json +5 -5
  105. package/tsconfig.json +23 -23
package/package.json CHANGED
@@ -1,80 +1,80 @@
1
- {
2
- "name": "@tomei/sso",
3
- "version": "0.16.3",
4
- "description": "Tomei SSO Package",
5
- "main": "dist/index.js",
6
- "scripts": {
7
- "start:dev": "tsc -w",
8
- "build": "tsc",
9
- "prepare": "husky install",
10
- "format": "prettier --write \"src/**/*.ts\"",
11
- "lint": "npx eslint . --fix",
12
- "test": "jest --forceExit --detectOpenHandles"
13
- },
14
- "repository": {
15
- "type": "git",
16
- "url": "git+ssh://git@gitlab.com/tomei-package/sso.git"
17
- },
18
- "keywords": [
19
- "tomei",
20
- "sso"
21
- ],
22
- "author": "Tomei",
23
- "license": "ISC",
24
- "bugs": {
25
- "url": "https://gitlab.com/tomei-package/sso/issues"
26
- },
27
- "homepage": "https://gitlab.com/tomei-package/sso#readme",
28
- "devDependencies": {
29
- "@commitlint/cli": "^17.6.3",
30
- "@commitlint/config-conventional": "^17.6.3",
31
- "@tsconfig/node18": "^2.0.1",
32
- "@types/bcrypt": "^5.0.0",
33
- "@types/jest": "^29.5.2",
34
- "@types/node": "^18.17.5",
35
- "@types/redis": "^4.0.11",
36
- "@types/validator": "^13.11.1",
37
- "@typescript-eslint/eslint-plugin": "^5.33.0",
38
- "dotenv": "^16.1.4",
39
- "eslint": "^8.40.0",
40
- "eslint-config-prettier": "^8.5.0",
41
- "eslint-plugin-prettier": "^4.2.1",
42
- "husky": "^8.0.3",
43
- "jest": "^29.5.0",
44
- "jest-mock-extended": "^3.0.4",
45
- "lint-staged": "^13.2.2",
46
- "prettier": "^2.7.1",
47
- "prisma": "^4.14.0",
48
- "redis-mock": "^0.56.3",
49
- "sequelize-cli": "^6.6.2",
50
- "ts-jest": "^29.1.0",
51
- "ts-node": "^10.9.1",
52
- "tsc-watch": "^5.0.3",
53
- "tsconfig-paths": "^4.0.0",
54
- "tslint": "^6.1.3",
55
- "typescript": "^4.7.4"
56
- },
57
- "publishConfig": {
58
- "access": "public"
59
- },
60
- "peerDependencies": {
61
- "@tomei/config": "^0.3.9",
62
- "@tomei/general": "^0.10.6",
63
- "@tomei/mailer": "^0.5.11",
64
- "@types/jest": "^29.5.2",
65
- "argon2": "^0.30.3",
66
- "cls-hooked": "^4.2.2",
67
- "cuid": "^3.0.0",
68
- "nodemailer": "^6.9.3",
69
- "redis": "^4.6.7",
70
- "reflect-metadata": "^0.1.13",
71
- "sequelize": "^6.32.1",
72
- "sequelize-typescript": "^2.1.5"
73
- },
74
- "lint-staged": {
75
- "*/**/*.{js,ts,tsx}": [
76
- "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
77
- "eslint \"{src,apps,libs,test}/**/*.ts\" --fix"
78
- ]
79
- }
80
- }
1
+ {
2
+ "name": "@tomei/sso",
3
+ "version": "0.16.5",
4
+ "description": "Tomei SSO Package",
5
+ "main": "dist/index.js",
6
+ "scripts": {
7
+ "start:dev": "tsc -w",
8
+ "build": "tsc",
9
+ "prepare": "husky install",
10
+ "format": "prettier --write \"src/**/*.ts\"",
11
+ "lint": "npx eslint . --fix",
12
+ "test": "jest --forceExit --detectOpenHandles"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+ssh://git@gitlab.com/tomei-package/sso.git"
17
+ },
18
+ "keywords": [
19
+ "tomei",
20
+ "sso"
21
+ ],
22
+ "author": "Tomei",
23
+ "license": "ISC",
24
+ "bugs": {
25
+ "url": "https://gitlab.com/tomei-package/sso/issues"
26
+ },
27
+ "homepage": "https://gitlab.com/tomei-package/sso#readme",
28
+ "devDependencies": {
29
+ "@commitlint/cli": "^17.6.3",
30
+ "@commitlint/config-conventional": "^17.6.3",
31
+ "@tsconfig/node18": "^2.0.1",
32
+ "@types/bcrypt": "^5.0.0",
33
+ "@types/jest": "^29.5.2",
34
+ "@types/node": "^18.17.5",
35
+ "@types/redis": "^4.0.11",
36
+ "@types/validator": "^13.11.1",
37
+ "@typescript-eslint/eslint-plugin": "^5.33.0",
38
+ "dotenv": "^16.1.4",
39
+ "eslint": "^8.40.0",
40
+ "eslint-config-prettier": "^8.5.0",
41
+ "eslint-plugin-prettier": "^4.2.1",
42
+ "husky": "^8.0.3",
43
+ "jest": "^29.5.0",
44
+ "jest-mock-extended": "^3.0.4",
45
+ "lint-staged": "^13.2.2",
46
+ "prettier": "^2.7.1",
47
+ "prisma": "^4.14.0",
48
+ "redis-mock": "^0.56.3",
49
+ "sequelize-cli": "^6.6.2",
50
+ "ts-jest": "^29.1.0",
51
+ "ts-node": "^10.9.1",
52
+ "tsc-watch": "^5.0.3",
53
+ "tsconfig-paths": "^4.0.0",
54
+ "tslint": "^6.1.3",
55
+ "typescript": "^4.7.4"
56
+ },
57
+ "publishConfig": {
58
+ "access": "public"
59
+ },
60
+ "peerDependencies": {
61
+ "@tomei/config": "^0.3.9",
62
+ "@tomei/general": "^0.10.6",
63
+ "@tomei/mailer": "^0.5.11",
64
+ "@types/jest": "^29.5.2",
65
+ "argon2": "^0.30.3",
66
+ "cls-hooked": "^4.2.2",
67
+ "cuid": "^3.0.0",
68
+ "nodemailer": "^6.9.3",
69
+ "redis": "^4.6.7",
70
+ "reflect-metadata": "^0.1.13",
71
+ "sequelize": "^6.32.1",
72
+ "sequelize-typescript": "^2.1.5"
73
+ },
74
+ "lint-staged": {
75
+ "*/**/*.{js,ts,tsx}": [
76
+ "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
77
+ "eslint \"{src,apps,libs,test}/**/*.ts\" --fix"
78
+ ]
79
+ }
80
+ }
package/sampledotenv CHANGED
@@ -1,8 +1,8 @@
1
- DATABASE_URL=
2
- SHADOW_DATABASE_URL=
3
- REDIS_URL=
4
- REDIS_PASSWORD=
5
- SMTP_HOST=
6
- SMTP_PORT=
7
- EMAIL_SENDER=
1
+ DATABASE_URL=
2
+ SHADOW_DATABASE_URL=
3
+ REDIS_URL=
4
+ REDIS_PASSWORD=
5
+ SMTP_HOST=
6
+ SMTP_PORT=
7
+ EMAIL_SENDER=
8
8
  EMAIL_PASSWORD=
@@ -8,4 +8,9 @@ export * from './user-user-group';
8
8
  export * from './building';
9
9
  export * from './building-type';
10
10
  export * from './staff';
11
+
12
+ export * from './sso-group';
13
+ export * from './sso-group-reporting-user';
14
+ export * from './sso-system';
15
+
11
16
  //test ci
@@ -0,0 +1,11 @@
1
+ import GroupModel from '../../models/sso-group.entity';
2
+ import { RepositoryBase, IRepositoryBase } from '@tomei/general';
3
+
4
+ export class GroupRepository
5
+ extends RepositoryBase<GroupModel>
6
+ implements IRepositoryBase<GroupModel>
7
+ {
8
+ constructor() {
9
+ super(GroupModel);
10
+ }
11
+ }
@@ -0,0 +1,77 @@
1
+ import { ClassError, HashTable, ObjectBase } from '@tomei/general';
2
+ import { GroupRepository } from './group.repository';
3
+ import { IGroupAttr } from '../../interfaces/group.interface';
4
+ import { GroupTypeEnum } from 'enum';
5
+
6
+ export class Group extends ObjectBase {
7
+ ObjectId: string;
8
+ ObjectName: string;
9
+ TableName: 'sso_group';
10
+ ObjectType: 'sso_group';
11
+
12
+ GroupCode: string;
13
+ Name: string;
14
+ Description: string;
15
+ Type: GroupTypeEnum;
16
+ ParentGroupCode: string;
17
+ InheritParentPrivilegeYN: string;
18
+ Status: string;
19
+ private _CreatedById: number;
20
+ private _CreatedAt: Date;
21
+ private _UpdatedById: number;
22
+ private _UpdatedAt: Date;
23
+ private static _Repo = new GroupRepository();
24
+
25
+ get CreatedById(): number {
26
+ return this._CreatedById;
27
+ }
28
+
29
+ get CreatedAt(): Date {
30
+ return this._CreatedAt;
31
+ }
32
+
33
+ get UpdatedById(): number {
34
+ return this._UpdatedById;
35
+ }
36
+
37
+ get UpdatedAt(): Date {
38
+ return this._UpdatedAt;
39
+ }
40
+
41
+ private constructor(groupAttr?: IGroupAttr) {
42
+ super();
43
+ if (groupAttr) {
44
+ this.GroupCode = groupAttr.GroupCode;
45
+ this.Name = groupAttr.Name;
46
+ this.Description = groupAttr?.Description;
47
+ this.Type = groupAttr?.Type;
48
+ this.ParentGroupCode = groupAttr?.ParentGroupCode;
49
+ this.InheritParentPrivilegeYN = groupAttr?.InheritParentPrivilegeYN;
50
+ this.Status = groupAttr?.Status;
51
+ this._CreatedById = groupAttr.CreatedById;
52
+ this._CreatedAt = groupAttr.CreatedAt;
53
+ this._UpdatedById = groupAttr.UpdatedById;
54
+ this._UpdatedAt = groupAttr.UpdatedAt;
55
+ }
56
+ }
57
+
58
+ public static async init(dbTransaction: any, GroupCode?: string) {
59
+ try {
60
+ if (GroupCode) {
61
+ const group = await Group._Repo.findByPk(GroupCode, dbTransaction);
62
+ if (group) {
63
+ return new Group(group);
64
+ } else {
65
+ throw new ClassError('Group', 'GroupErrMsg00', 'Group Not Found');
66
+ }
67
+ }
68
+ return new Group();
69
+ } catch (error) {
70
+ throw new ClassError(
71
+ 'Group',
72
+ 'GroupErrMsg01',
73
+ 'Failed To Initialize Group',
74
+ );
75
+ }
76
+ }
77
+ }
@@ -0,0 +1,3 @@
1
+ //export all files inside this folder
2
+ export * from './group';
3
+ export * from './group.repository';
@@ -0,0 +1,11 @@
1
+ import GroupReportingUserModel from '../../models/sso-group-reporting-user.entity';
2
+ import { RepositoryBase, IRepositoryBase } from '@tomei/general';
3
+
4
+ export class GroupReportingUserRepository
5
+ extends RepositoryBase<GroupReportingUserModel>
6
+ implements IRepositoryBase<GroupReportingUserModel>
7
+ {
8
+ constructor() {
9
+ super(GroupReportingUserModel);
10
+ }
11
+ }
@@ -0,0 +1,79 @@
1
+ import { ClassError, HashTable, ObjectBase } from '@tomei/general';
2
+ import { GroupReportingUserRepository } from './group-reporting-user.repository';
3
+ import { IGroupReportingUserAttr } from '../../interfaces/group-reporting-user.interface';
4
+
5
+ export class GroupReportingUser extends ObjectBase {
6
+ ObjectId: string;
7
+ ObjectName: string;
8
+ TableName: 'sso_GroupReportingUser';
9
+ ObjectType: 'sso_GroupReportingUser';
10
+
11
+ GroupReportingUserId: string;
12
+ GroupCode: string;
13
+ UserId: number;
14
+ Rank: number;
15
+ Status: string;
16
+ private _CreatedById: number;
17
+ private _CreatedAt: Date;
18
+ private _UpdatedById: number;
19
+ private _UpdatedAt: Date;
20
+ private static _Repo = new GroupReportingUserRepository();
21
+
22
+ get CreatedById(): number {
23
+ return this._CreatedById;
24
+ }
25
+
26
+ get CreatedAt(): Date {
27
+ return this._CreatedAt;
28
+ }
29
+
30
+ get UpdatedById(): number {
31
+ return this._UpdatedById;
32
+ }
33
+
34
+ get UpdatedAt(): Date {
35
+ return this._UpdatedAt;
36
+ }
37
+
38
+ private constructor(groupReportingUserAttr?: IGroupReportingUserAttr) {
39
+ super();
40
+ if (groupReportingUserAttr) {
41
+ this.GroupReportingUserId = groupReportingUserAttr.GroupReportingUserId;
42
+ this.GroupCode = groupReportingUserAttr.GroupCode;
43
+ this.UserId = groupReportingUserAttr?.UserId;
44
+ this.Rank = groupReportingUserAttr?.Rank;
45
+ this.Status = groupReportingUserAttr?.Status;
46
+ this._CreatedById = groupReportingUserAttr.CreatedById;
47
+ this._CreatedAt = groupReportingUserAttr.CreatedAt;
48
+ this._UpdatedById = groupReportingUserAttr.UpdatedById;
49
+ this._UpdatedAt = groupReportingUserAttr.UpdatedAt;
50
+ }
51
+ }
52
+
53
+ public static async init(dbTransaction: any, GroupReportingUserId?: string) {
54
+ try {
55
+ if (GroupReportingUserId) {
56
+ const groupReportingUser = await GroupReportingUser._Repo.findByPk(
57
+ GroupReportingUserId,
58
+ dbTransaction,
59
+ );
60
+ if (groupReportingUser) {
61
+ return new GroupReportingUser(groupReportingUser);
62
+ } else {
63
+ throw new ClassError(
64
+ 'GroupReportingUser',
65
+ 'GroupReportingUserErrMsg00',
66
+ 'GroupReportingUser Not Found',
67
+ );
68
+ }
69
+ }
70
+ return new GroupReportingUser();
71
+ } catch (error) {
72
+ throw new ClassError(
73
+ 'GroupReportingUser',
74
+ 'GroupReportingUserErrMsg01',
75
+ 'Failed To Initialize GroupReportingUser',
76
+ );
77
+ }
78
+ }
79
+ }
@@ -0,0 +1,3 @@
1
+ //export all files inside this folder
2
+ export * from './group-reporting-user';
3
+ export * from './group-reporting-user.repository';
@@ -0,0 +1,3 @@
1
+ //export all files inside this folder
2
+ export * from './system';
3
+ export * from './system.repository';
@@ -0,0 +1,11 @@
1
+ import SystemModel from '../../models/sso-system.entity';
2
+ import { RepositoryBase, IRepositoryBase } from '@tomei/general';
3
+
4
+ export class SSOSystemRepository
5
+ extends RepositoryBase<SystemModel>
6
+ implements IRepositoryBase<SystemModel>
7
+ {
8
+ constructor() {
9
+ super(SystemModel);
10
+ }
11
+ }
@@ -0,0 +1,81 @@
1
+ import { ClassError, HashTable, ObjectBase } from '@tomei/general';
2
+ import { SSOSystemRepository } from './system.repository';
3
+ import { ISystemAttr } from '../../interfaces/system.interface';
4
+
5
+ export class System extends ObjectBase {
6
+ ObjectId: string;
7
+ ObjectName: string;
8
+ TableName: 'sso_system';
9
+ ObjectType: 'sso_system';
10
+ private static _htSystem: HashTable;
11
+
12
+ SystemCode: string;
13
+ Name: string;
14
+ Description: string;
15
+ AccessURL: string;
16
+ GooglePlayURL: string;
17
+ AppleStoreURL: string;
18
+ APIKey: string;
19
+ APISecret: string;
20
+ Status: string;
21
+ private _CreatedById: number;
22
+ private _CreatedAt: Date;
23
+ private _UpdatedById: number;
24
+ private _UpdatedAt: Date;
25
+ private static _Repo = new SSOSystemRepository();
26
+
27
+ get CreatedById(): number {
28
+ return this._CreatedById;
29
+ }
30
+
31
+ get CreatedAt(): Date {
32
+ return this._CreatedAt;
33
+ }
34
+
35
+ get UpdatedById(): number {
36
+ return this._UpdatedById;
37
+ }
38
+
39
+ get UpdatedAt(): Date {
40
+ return this._UpdatedAt;
41
+ }
42
+
43
+ private constructor(systemAttr?: ISystemAttr) {
44
+ super();
45
+ if (systemAttr) {
46
+ this.SystemCode = systemAttr.SystemCode;
47
+ this.Name = systemAttr.Name;
48
+ this.Description = systemAttr?.Description;
49
+ this.AccessURL = systemAttr?.AccessURL;
50
+ this.GooglePlayURL = systemAttr?.GooglePlayURL;
51
+ this.AppleStoreURL = systemAttr?.AppleStoreURL;
52
+ this.APIKey = systemAttr?.APIKey;
53
+ this.APISecret = systemAttr?.APISecret;
54
+ this.Status = systemAttr?.Status;
55
+ this._CreatedById = systemAttr.CreatedById;
56
+ this._CreatedAt = systemAttr.CreatedAt;
57
+ this._UpdatedById = systemAttr.UpdatedById;
58
+ this._UpdatedAt = systemAttr.UpdatedAt;
59
+ }
60
+ }
61
+
62
+ public static async init(dbTransaction: any, SystemCode?: string) {
63
+ try {
64
+ if (SystemCode) {
65
+ const system = await System._Repo.findByPk(SystemCode, dbTransaction);
66
+ if (system) {
67
+ return new System(system);
68
+ } else {
69
+ throw new ClassError('System', 'SystemErrMsg00', 'System Not Found');
70
+ }
71
+ }
72
+ return new System();
73
+ } catch (error) {
74
+ throw new ClassError(
75
+ 'System',
76
+ 'SystemErrMsg01',
77
+ 'Failed To Initialize System',
78
+ );
79
+ }
80
+ }
81
+ }
@@ -64,7 +64,9 @@ export class Staff extends ObjectBase implements IPerson {
64
64
  private constructor(staffInfo) {
65
65
  super();
66
66
  if (staffInfo) {
67
- this.ObjectId = staffInfo.id;
67
+ // needed to implement objectBase
68
+ this.ObjectId = staffInfo.staff_id;
69
+
68
70
  this.UserId = staffInfo.user_id;
69
71
  this.StaffId = staffInfo.staff_id;
70
72
  this.FullName = staffInfo.full_name;
@@ -0,0 +1,8 @@
1
+ export enum GroupTypeEnum {
2
+ COMPANY = 'Company',
3
+ DEPARTMENT = 'Department',
4
+ TEAM = 'Team',
5
+ PROJECT = 'Project',
6
+ BUILDING = 'Building',
7
+ ROLE = 'Role',
8
+ }
package/src/enum/index.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './yn.enum';
2
2
  export * from './user-status.enum';
3
+ export * from './group-type.enum';
@@ -0,0 +1,13 @@
1
+ import { GroupTypeEnum } from 'enum';
2
+
3
+ export interface IGroupReportingUserAttr {
4
+ GroupReportingUserId: string;
5
+ GroupCode: string;
6
+ UserId: number;
7
+ Rank: number;
8
+ Status: string;
9
+ CreatedById: number;
10
+ UpdatedById: number;
11
+ CreatedAt: Date;
12
+ UpdatedAt: Date;
13
+ }
@@ -0,0 +1,15 @@
1
+ import { GroupTypeEnum } from 'enum';
2
+
3
+ export interface IGroupAttr {
4
+ GroupCode: string;
5
+ Name: string;
6
+ Description: string;
7
+ Type: GroupTypeEnum;
8
+ ParentGroupCode: string;
9
+ InheritParentPrivilegeYN: string;
10
+ Status: string;
11
+ CreatedById: number;
12
+ UpdatedById: number;
13
+ CreatedAt: Date;
14
+ UpdatedAt: Date;
15
+ }
@@ -1,2 +1,5 @@
1
1
  export * from './system-login.interface';
2
2
  export * from './user-session.interface';
3
+ export * from './system.interface';
4
+ export * from './group.interface';
5
+ export * from './group-reporting-user.interface';
@@ -0,0 +1,15 @@
1
+ export interface ISystemAttr {
2
+ SystemCode: string;
3
+ Name: string;
4
+ Description: string;
5
+ AccessURL: string;
6
+ GooglePlayURL: string;
7
+ AppleStoreURL: string;
8
+ APIKey: string;
9
+ APISecret: string;
10
+ Status: string;
11
+ CreatedById: number;
12
+ UpdatedById: number;
13
+ CreatedAt: Date;
14
+ UpdatedAt: Date;
15
+ }
@@ -0,0 +1,86 @@
1
+ import {
2
+ BelongsTo,
3
+ Column,
4
+ CreatedAt,
5
+ DataType,
6
+ ForeignKey,
7
+ Model,
8
+ Table,
9
+ UpdatedAt,
10
+ } from 'sequelize-typescript';
11
+ import User from './user.entity';
12
+ import GroupModel from './sso-group.entity';
13
+
14
+ @Table({
15
+ tableName: 'sso_GroupReportingUser',
16
+ timestamps: true,
17
+ createdAt: 'created_at',
18
+ updatedAt: 'updated_at',
19
+ underscored: true,
20
+ })
21
+ export default class GroupReportingUserModel extends Model {
22
+ @Column({
23
+ primaryKey: true,
24
+ allowNull: false,
25
+ type: DataType.STRING(10),
26
+ })
27
+ GroupReportingUserId: string;
28
+
29
+ @ForeignKey(() => GroupModel)
30
+ @Column({
31
+ allowNull: false,
32
+ type: DataType.STRING(10),
33
+ })
34
+ GroupCode: string;
35
+
36
+ @ForeignKey(() => User)
37
+ @Column({
38
+ allowNull: false,
39
+ type: DataType.INTEGER,
40
+ })
41
+ UserId: number;
42
+
43
+ @Column({
44
+ allowNull: false,
45
+ type: DataType.TINYINT,
46
+ })
47
+ Rank: number;
48
+
49
+ @Column({
50
+ allowNull: false,
51
+ type: DataType.CHAR(10),
52
+ })
53
+ Status: string;
54
+
55
+ @ForeignKey(() => User)
56
+ @Column({
57
+ allowNull: false,
58
+ type: DataType.INTEGER,
59
+ })
60
+ CreatedById: number;
61
+
62
+ @ForeignKey(() => User)
63
+ @Column({
64
+ allowNull: false,
65
+ type: DataType.INTEGER,
66
+ })
67
+ UpdatedById: number;
68
+
69
+ @CreatedAt
70
+ CreatedAt: Date;
71
+
72
+ @UpdatedAt
73
+ UpdatedAt: Date;
74
+
75
+ @BelongsTo(() => User, 'CreatedById')
76
+ CreatedByUser: User;
77
+
78
+ @BelongsTo(() => User, 'UpdatedById')
79
+ UpdatedByUser: User;
80
+
81
+ @BelongsTo(() => User, 'UserId')
82
+ User: User;
83
+
84
+ @BelongsTo(() => GroupModel, 'GroupCode')
85
+ Group: User;
86
+ }