@tomei/sso 0.11.7 → 0.14.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.
Files changed (209) 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/__tests__/unit/components/login-user/login-user.spec.d.ts +1 -1
  16. package/dist/__tests__/unit/components/login-user/login-user.spec.js +662 -662
  17. package/dist/__tests__/unit/components/password-hash/password-hash.service.spec.d.ts +1 -1
  18. package/dist/__tests__/unit/components/password-hash/password-hash.service.spec.js +37 -37
  19. package/dist/__tests__/unit/redis-client/redis.service.spec.d.ts +1 -1
  20. package/dist/__tests__/unit/redis-client/redis.service.spec.js +31 -31
  21. package/dist/__tests__/unit/session/session.service.spec.d.ts +1 -1
  22. package/dist/__tests__/unit/session/session.service.spec.js +54 -54
  23. package/dist/__tests__/unit/system-privilege/system-privilage.spec.js +5 -5
  24. package/dist/index.d.ts +1 -1
  25. package/dist/index.js +17 -17
  26. package/dist/src/components/building/building.d.ts +38 -0
  27. package/dist/src/components/building/building.js +92 -0
  28. package/dist/src/components/building/building.js.map +1 -0
  29. package/dist/src/components/building/building.repository.d.ts +5 -0
  30. package/dist/src/components/building/building.repository.js +12 -0
  31. package/dist/src/components/building/building.repository.js.map +1 -0
  32. package/dist/src/components/building/index.d.ts +2 -0
  33. package/dist/src/components/building/index.js +19 -0
  34. package/dist/src/components/building/index.js.map +1 -0
  35. package/dist/src/components/building-type/building-type.repository.d.ts +5 -0
  36. package/dist/src/components/building-type/building-type.repository.js +12 -0
  37. package/dist/src/components/building-type/building-type.repository.js.map +1 -0
  38. package/dist/src/components/building-type/index.d.ts +1 -0
  39. package/dist/src/{prisma-client → components/building-type}/index.js +17 -17
  40. package/dist/src/components/building-type/index.js.map +1 -0
  41. package/dist/src/components/index.d.ts +9 -7
  42. package/dist/src/components/index.js +25 -23
  43. package/dist/src/components/index.js.map +1 -1
  44. package/dist/src/components/login-history/index.d.ts +1 -1
  45. package/dist/src/components/login-history/index.js +17 -17
  46. package/dist/src/components/login-history/login-history.repository.d.ts +5 -5
  47. package/dist/src/components/login-history/login-history.repository.js +11 -11
  48. package/dist/src/components/login-user/index.d.ts +3 -3
  49. package/dist/src/components/login-user/index.js +19 -19
  50. package/dist/src/components/login-user/interfaces/index.d.ts +1 -1
  51. package/dist/src/components/login-user/interfaces/index.js +17 -17
  52. package/dist/src/components/login-user/interfaces/user-info.interface.d.ts +9 -9
  53. package/dist/src/components/login-user/interfaces/user-info.interface.js +2 -2
  54. package/dist/src/components/login-user/login-user.d.ts +46 -45
  55. package/dist/src/components/login-user/login-user.js +430 -414
  56. package/dist/src/components/login-user/login-user.js.map +1 -1
  57. package/dist/src/components/login-user/user.repository.d.ts +5 -5
  58. package/dist/src/components/login-user/user.repository.js +11 -11
  59. package/dist/src/components/password-hash/index.d.ts +2 -2
  60. package/dist/src/components/password-hash/index.js +18 -18
  61. package/dist/src/components/password-hash/interfaces/index.d.ts +1 -1
  62. package/dist/src/components/password-hash/interfaces/index.js +17 -17
  63. package/dist/src/components/password-hash/interfaces/password-hash-service.interface.d.ts +4 -4
  64. package/dist/src/components/password-hash/interfaces/password-hash-service.interface.js +2 -2
  65. package/dist/src/components/password-hash/password-hash.service.d.ts +6 -6
  66. package/dist/src/components/password-hash/password-hash.service.js +27 -27
  67. package/dist/src/components/system/index.d.ts +1 -1
  68. package/dist/src/components/system/index.js +17 -17
  69. package/dist/src/components/system/system.repository.d.ts +5 -5
  70. package/dist/src/components/system/system.repository.js +11 -11
  71. package/dist/src/components/system-access/index.d.ts +1 -1
  72. package/dist/src/components/system-access/index.js +17 -17
  73. package/dist/src/components/system-access/system-access.repository.d.ts +5 -5
  74. package/dist/src/components/system-access/system-access.repository.js +11 -11
  75. package/dist/src/components/system-privilege/privilege.d.ts +6 -6
  76. package/dist/src/components/system-privilege/privilege.js +76 -76
  77. package/dist/src/components/system-privilege/system-privilege.repository.d.ts +6 -6
  78. package/dist/src/components/system-privilege/system-privilege.repository.js +34 -34
  79. package/dist/src/components/user-group/index.d.ts +1 -1
  80. package/dist/src/components/user-group/index.js +17 -17
  81. package/dist/src/components/user-group/user-group.repository.d.ts +5 -5
  82. package/dist/src/components/user-group/user-group.repository.js +11 -11
  83. package/dist/src/components/user-user-group/index.d.ts +1 -1
  84. package/dist/src/components/user-user-group/index.js +17 -17
  85. package/dist/src/components/user-user-group/user-user-group.repository.d.ts +5 -5
  86. package/dist/src/components/user-user-group/user-user-group.repository.js +11 -11
  87. package/dist/src/database.d.ts +4 -4
  88. package/dist/src/database.js +14 -14
  89. package/dist/src/index.d.ts +5 -5
  90. package/dist/src/index.js +23 -23
  91. package/dist/src/interfaces/index.d.ts +2 -2
  92. package/dist/src/interfaces/index.js +18 -18
  93. package/dist/src/interfaces/system-login.interface.d.ts +6 -6
  94. package/dist/src/interfaces/system-login.interface.js +2 -2
  95. package/dist/src/interfaces/user-session.interface.d.ts +4 -4
  96. package/dist/src/interfaces/user-session.interface.js +2 -2
  97. package/dist/src/models/authorization-code.entity.d.ts +14 -14
  98. package/dist/src/models/authorization-code.entity.js +85 -85
  99. package/dist/src/models/bearer-token.entity.d.ts +11 -11
  100. package/dist/src/models/bearer-token.entity.js +71 -71
  101. package/dist/src/models/building-type.entity.d.ts +7 -7
  102. package/dist/src/models/building-type.entity.js +49 -49
  103. package/dist/src/models/building.entity.d.ts +39 -39
  104. package/dist/src/models/building.entity.js +250 -250
  105. package/dist/src/models/city.entity.d.ts +11 -11
  106. package/dist/src/models/city.entity.js +71 -71
  107. package/dist/src/models/company.entity.d.ts +18 -18
  108. package/dist/src/models/company.entity.js +113 -113
  109. package/dist/src/models/country.entity.d.ts +15 -15
  110. package/dist/src/models/country.entity.js +91 -91
  111. package/dist/src/models/department.entity.d.ts +19 -19
  112. package/dist/src/models/department.entity.js +111 -111
  113. package/dist/src/models/group-role-privilege.entity.d.ts +17 -17
  114. package/dist/src/models/group-role-privilege.entity.js +89 -89
  115. package/dist/src/models/group-system-access.entity.d.ts +11 -11
  116. package/dist/src/models/group-system-access.entity.js +61 -61
  117. package/dist/src/models/group-system-privilege.entity.d.ts +11 -11
  118. package/dist/src/models/group-system-privilege.entity.js +61 -61
  119. package/dist/src/models/group-system-role.entity.d.ts +11 -11
  120. package/dist/src/models/group-system-role.entity.js +61 -61
  121. package/dist/src/models/login-history.entity.d.ts +12 -12
  122. package/dist/src/models/login-history.entity.js +69 -69
  123. package/dist/src/models/oauth-token.entity.d.ts +14 -14
  124. package/dist/src/models/oauth-token.entity.js +85 -85
  125. package/dist/src/models/role.entity.d.ts +17 -17
  126. package/dist/src/models/role.entity.js +101 -101
  127. package/dist/src/models/staff-type.entity.d.ts +7 -7
  128. package/dist/src/models/staff-type.entity.js +49 -49
  129. package/dist/src/models/staff.entity.d.ts +39 -39
  130. package/dist/src/models/staff.entity.js +249 -249
  131. package/dist/src/models/state.entity.d.ts +10 -10
  132. package/dist/src/models/state.entity.js +63 -63
  133. package/dist/src/models/system-accesss.entity.d.ts +6 -6
  134. package/dist/src/models/system-accesss.entity.js +50 -50
  135. package/dist/src/models/system-privilege.entity.d.ts +16 -16
  136. package/dist/src/models/system-privilege.entity.js +89 -89
  137. package/dist/src/models/system-role-privilege.entity.d.ts +11 -11
  138. package/dist/src/models/system-role-privilege.entity.js +59 -59
  139. package/dist/src/models/system-role.entity.d.ts +11 -11
  140. package/dist/src/models/system-role.entity.js +82 -82
  141. package/dist/src/models/system.entity.d.ts +19 -19
  142. package/dist/src/models/system.entity.js +145 -145
  143. package/dist/src/models/user-group.entity.d.ts +23 -23
  144. package/dist/src/models/user-group.entity.js +139 -139
  145. package/dist/src/models/user-role.entity.d.ts +12 -12
  146. package/dist/src/models/user-role.entity.js +72 -72
  147. package/dist/src/models/user-system-privileges.entity.d.ts +13 -13
  148. package/dist/src/models/user-system-privileges.entity.js +88 -88
  149. package/dist/src/models/user-system-role.entity.d.ts +11 -11
  150. package/dist/src/models/user-system-role.entity.js +59 -59
  151. package/dist/src/models/user-user-group.entity.d.ts +14 -14
  152. package/dist/src/models/user-user-group.entity.js +72 -72
  153. package/dist/src/models/user.entity.d.ts +30 -30
  154. package/dist/src/models/user.entity.js +130 -130
  155. package/dist/src/redis-client/__mocks__/jest-initial-setup.d.ts +1 -1
  156. package/dist/src/redis-client/__mocks__/jest-initial-setup.js +4 -4
  157. package/dist/src/redis-client/__mocks__/redis-mock.d.ts +2 -2
  158. package/dist/src/redis-client/__mocks__/redis-mock.js +22 -22
  159. package/dist/src/redis-client/index.d.ts +1 -1
  160. package/dist/src/redis-client/index.js +17 -17
  161. package/dist/src/redis-client/redis.service.d.ts +7 -7
  162. package/dist/src/redis-client/redis.service.js +60 -60
  163. package/dist/src/session/index.d.ts +2 -2
  164. package/dist/src/session/index.js +18 -18
  165. package/dist/src/session/interfaces/index.d.ts +1 -1
  166. package/dist/src/session/interfaces/index.js +17 -17
  167. package/dist/src/session/interfaces/session-service.interface.d.ts +6 -6
  168. package/dist/src/session/interfaces/session-service.interface.js +2 -2
  169. package/dist/src/session/session.service.d.ts +10 -10
  170. package/dist/src/session/session.service.js +62 -62
  171. package/dist/tsconfig.tsbuildinfo +1 -1
  172. package/jest.config.js +13 -13
  173. package/migrations/01-alter-system-privilege-table.js +13 -13
  174. package/migrations/02-alter-user-group-table.js +78 -78
  175. package/migrations/03-alter-user-system-privilege-table.js +38 -38
  176. package/migrations/04-create-user-user-group-table.js +55 -55
  177. package/migrations/05-create-login-history-table.js +49 -49
  178. package/package.json +2 -2
  179. package/sampledotenv +7 -7
  180. package/src/components/building/building.repository.ts +11 -0
  181. package/src/components/building/building.ts +119 -0
  182. package/src/components/building/index.ts +3 -0
  183. package/src/components/building-type/building-type.repository.ts +11 -0
  184. package/src/components/building-type/index.ts +2 -0
  185. package/src/components/index.ts +2 -0
  186. package/src/components/login-user/login-user.ts +18 -0
  187. package/src/models/building-type.entity.ts +1 -1
  188. package/tsconfig.build.json +5 -5
  189. package/tsconfig.json +23 -23
  190. package/dist/__tests__/unit/components/login-history/login-history.repository.spec.d.ts +0 -0
  191. package/dist/__tests__/unit/components/login-history/login-history.repository.spec.js +0 -1
  192. package/dist/__tests__/unit/components/login-history/login-history.repository.spec.js.map +0 -1
  193. package/dist/__tests__/unit/components/login-user/user.repository.spec.d.ts +0 -0
  194. package/dist/__tests__/unit/components/login-user/user.repository.spec.js +0 -1
  195. package/dist/__tests__/unit/components/login-user/user.repository.spec.js.map +0 -1
  196. package/dist/__tests__/unit/components/system/system.repository.spec.d.ts +0 -0
  197. package/dist/__tests__/unit/components/system/system.repository.spec.js +0 -1
  198. package/dist/__tests__/unit/components/system/system.repository.spec.js.map +0 -1
  199. package/dist/__tests__/unit/components/system-access/system-access.repository.spec.d.ts +0 -0
  200. package/dist/__tests__/unit/components/system-access/system-access.repository.spec.js +0 -1
  201. package/dist/__tests__/unit/components/system-access/system-access.repository.spec.js.map +0 -1
  202. package/dist/src/prisma-client/__mocks__/prisma.d.ts +0 -3
  203. package/dist/src/prisma-client/__mocks__/prisma.js +0 -14
  204. package/dist/src/prisma-client/__mocks__/prisma.js.map +0 -1
  205. package/dist/src/prisma-client/client.d.ts +0 -3
  206. package/dist/src/prisma-client/client.js +0 -6
  207. package/dist/src/prisma-client/client.js.map +0 -1
  208. package/dist/src/prisma-client/index.d.ts +0 -1
  209. package/dist/src/prisma-client/index.js.map +0 -1
@@ -0,0 +1,11 @@
1
+ import BuildingType from '../../models/building-type.entity';
2
+ import { RepositoryBase, IRepositoryBase } from '@tomei/general';
3
+
4
+ export class BuildingTypeRepository
5
+ extends RepositoryBase<BuildingType>
6
+ implements IRepositoryBase<BuildingType>
7
+ {
8
+ constructor() {
9
+ super(BuildingType);
10
+ }
11
+ }
@@ -0,0 +1,2 @@
1
+ //export all files inside this folder
2
+ export * from './building-type.repository';
@@ -5,4 +5,6 @@ export * from './system';
5
5
  export * from './system-access';
6
6
  export * from './user-group';
7
7
  export * from './user-user-group';
8
+ export * from './building';
9
+ export * from './building-type';
8
10
  //test ci
@@ -535,4 +535,22 @@ export class LoginUser extends LoginUserBase {
535
535
  throw error;
536
536
  }
537
537
  }
538
+
539
+ async logout(systemCode: string) {
540
+ try {
541
+ if (!this.ObjectId) {
542
+ throw new Error('ObjectId(UserId) is not set');
543
+ }
544
+ const userSession = await this._SessionService.retrieveUserSession(
545
+ this.ObjectId,
546
+ );
547
+ const index = userSession.systemLogins.findIndex(
548
+ (system) => system.code === systemCode,
549
+ );
550
+ userSession.systemLogins.splice(index, 1);
551
+ this._SessionService.setUserSession(this.ObjectId, userSession);
552
+ } catch (error) {
553
+ throw error;
554
+ }
555
+ }
538
556
  }
@@ -28,7 +28,7 @@ export default class BuildingType extends Model {
28
28
  type: DataType.STRING,
29
29
  field: 'name',
30
30
  })
31
- Name: string;
31
+ name: string;
32
32
 
33
33
  @CreatedAt
34
34
  CreatedAt: Date;
@@ -1,6 +1,6 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "include": ["**/*.ts"],
4
- "exclude": ["node_modules", "__test__", "dist", "**/*spec.ts"]
5
- }
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "include": ["**/*.ts"],
4
+ "exclude": ["node_modules", "__test__", "dist", "**/*spec.ts"]
5
+ }
6
6
 
package/tsconfig.json CHANGED
@@ -1,23 +1,23 @@
1
- {
2
- "compilerOptions": {
3
- "module": "commonjs",
4
- "declaration": true,
5
- "removeComments": true,
6
- "emitDecoratorMetadata": true,
7
- "experimentalDecorators": true,
8
- "allowSyntheticDefaultImports": true,
9
- "moduleResolution": "node",
10
- "target": "es6",
11
- "sourceMap": true,
12
- "outDir": "./dist",
13
- "baseUrl": "./src",
14
- "rootDir": "./",
15
- "incremental": true,
16
- "skipLibCheck": true,
17
- "noImplicitAny": false,
18
- "strictBindCallApply": false,
19
- "forceConsistentCasingInFileNames": false,
20
- "noFallthroughCasesInSwitch": false,
21
- "strictNullChecks": true,
22
- },
23
- }
1
+ {
2
+ "compilerOptions": {
3
+ "module": "commonjs",
4
+ "declaration": true,
5
+ "removeComments": true,
6
+ "emitDecoratorMetadata": true,
7
+ "experimentalDecorators": true,
8
+ "allowSyntheticDefaultImports": true,
9
+ "moduleResolution": "node",
10
+ "target": "es6",
11
+ "sourceMap": true,
12
+ "outDir": "./dist",
13
+ "baseUrl": "./src",
14
+ "rootDir": "./",
15
+ "incremental": true,
16
+ "skipLibCheck": true,
17
+ "noImplicitAny": false,
18
+ "strictBindCallApply": false,
19
+ "forceConsistentCasingInFileNames": false,
20
+ "noFallthroughCasesInSwitch": false,
21
+ "strictNullChecks": true,
22
+ },
23
+ }
@@ -1 +0,0 @@
1
- //# sourceMappingURL=login-history.repository.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"login-history.repository.spec.js","sourceRoot":"","sources":["../../../../../__tests__/unit/components/login-history/login-history.repository.spec.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- //# sourceMappingURL=user.repository.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"user.repository.spec.js","sourceRoot":"","sources":["../../../../../__tests__/unit/components/login-user/user.repository.spec.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- //# sourceMappingURL=system.repository.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"system.repository.spec.js","sourceRoot":"","sources":["../../../../../__tests__/unit/components/system/system.repository.spec.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- //# sourceMappingURL=system-access.repository.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"system-access.repository.spec.js","sourceRoot":"","sources":["../../../../../__tests__/unit/components/system-access/system-access.repository.spec.ts"],"names":[],"mappings":""}
@@ -1,3 +0,0 @@
1
- import { PrismaClient } from '@prisma/client';
2
- import { DeepMockProxy } from 'jest-mock-extended';
3
- export declare const prismaMock: DeepMockProxy<PrismaClient<import(".prisma/client").Prisma.PrismaClientOptions, never, import(".prisma/client").Prisma.RejectOnNotFound | import(".prisma/client").Prisma.RejectPerOperation | undefined>>;
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.prismaMock = void 0;
4
- const jest_mock_extended_1 = require("jest-mock-extended");
5
- const client_1 = require("../client");
6
- jest.mock('../client', () => ({
7
- __esModule: true,
8
- default: (0, jest_mock_extended_1.mockDeep)(),
9
- }));
10
- beforeEach(() => {
11
- (0, jest_mock_extended_1.mockReset)(exports.prismaMock);
12
- });
13
- exports.prismaMock = client_1.default;
14
- //# sourceMappingURL=prisma.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"prisma.js","sourceRoot":"","sources":["../../../../src/prisma-client/__mocks__/prisma.ts"],"names":[],"mappings":";;;AACA,2DAAwE;AAExE,sCAA+B;AAE/B,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,EAAE,CAAC,CAAC;IAC5B,UAAU,EAAE,IAAI;IAChB,OAAO,EAAE,IAAA,6BAAQ,GAAgB;CAClC,CAAC,CAAC,CAAC;AAEJ,UAAU,CAAC,GAAG,EAAE;IACd,IAAA,8BAAS,EAAC,kBAAU,CAAC,CAAC;AACxB,CAAC,CAAC,CAAC;AAEU,QAAA,UAAU,GAAG,gBAAgD,CAAC"}
@@ -1,3 +0,0 @@
1
- import { PrismaClient } from '@prisma/client';
2
- declare const prisma: PrismaClient<import(".prisma/client").Prisma.PrismaClientOptions, never, import(".prisma/client").Prisma.RejectOnNotFound | import(".prisma/client").Prisma.RejectPerOperation | undefined>;
3
- export default prisma;
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const client_1 = require("@prisma/client");
4
- const prisma = new client_1.PrismaClient();
5
- exports.default = prisma;
6
- //# sourceMappingURL=client.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/prisma-client/client.ts"],"names":[],"mappings":";;AAAA,2CAA8C;AAC9C,MAAM,MAAM,GAAG,IAAI,qBAAY,EAAE,CAAC;AAClC,kBAAe,MAAM,CAAC"}
@@ -1 +0,0 @@
1
- export * from './client';
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/prisma-client/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB"}