@tomei/sso 0.2.2 → 0.2.3

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 (152) hide show
  1. package/.commitlintrc.json +22 -22
  2. package/.prettierrc +4 -4
  3. package/Jenkinsfile +42 -0
  4. package/README.md +23 -23
  5. package/__tests__/unit/components/login-history/login-history.repository.spec.ts +95 -95
  6. package/__tests__/unit/components/login-user/login-user.spec.ts +223 -223
  7. package/__tests__/unit/components/login-user/user.repository.spec.ts +81 -81
  8. package/__tests__/unit/components/password-hash/password-hash.service.spec.ts +31 -32
  9. package/__tests__/unit/components/system-access/system-access.repository.spec.ts +78 -78
  10. package/__tests__/unit/redis-client/redis.service.spec.ts +23 -23
  11. package/__tests__/unit/session/session.service.spec.ts +27 -27
  12. package/create-sso-user.sql +39 -39
  13. package/dist/__tests__/unit/components/login-history/login-history.repository.spec.d.ts +1 -1
  14. package/dist/__tests__/unit/components/login-history/login-history.repository.spec.js +98 -98
  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 +207 -207
  17. package/dist/__tests__/unit/components/login-user/login-user.spec.js.map +1 -1
  18. package/dist/__tests__/unit/components/login-user/user.repository.spec.d.ts +1 -1
  19. package/dist/__tests__/unit/components/login-user/user.repository.spec.js +77 -77
  20. package/dist/__tests__/unit/components/password-hash/password-hash.service.spec.d.ts +1 -1
  21. package/dist/__tests__/unit/components/password-hash/password-hash.service.spec.js +37 -37
  22. package/dist/__tests__/unit/components/password-hash/password-hash.service.spec.js.map +1 -1
  23. package/dist/__tests__/unit/components/system/system.repository.spec.d.ts +1 -1
  24. package/dist/__tests__/unit/components/system/system.repository.spec.js +84 -84
  25. package/dist/__tests__/unit/components/system-access/system-access.repository.spec.d.ts +1 -1
  26. package/dist/__tests__/unit/components/system-access/system-access.repository.spec.js +74 -74
  27. package/dist/__tests__/unit/redis-client/redis.service.spec.d.ts +1 -1
  28. package/dist/__tests__/unit/redis-client/redis.service.spec.js +31 -31
  29. package/dist/__tests__/unit/session/session.service.spec.d.ts +1 -1
  30. package/dist/__tests__/unit/session/session.service.spec.js +35 -35
  31. package/dist/index.d.ts +1 -1
  32. package/dist/index.js +17 -17
  33. package/dist/src/components/index.d.ts +7 -7
  34. package/dist/src/components/index.js +23 -23
  35. package/dist/src/components/login-history/index.d.ts +1 -1
  36. package/dist/src/components/login-history/index.js +17 -17
  37. package/dist/src/components/login-history/login-history.repository.d.ts +9 -9
  38. package/dist/src/components/login-history/login-history.repository.js +49 -49
  39. package/dist/src/components/login-user/index.d.ts +3 -3
  40. package/dist/src/components/login-user/index.js +19 -19
  41. package/dist/src/components/login-user/interfaces/index.d.ts +1 -1
  42. package/dist/src/components/login-user/interfaces/index.js +17 -17
  43. package/dist/src/components/login-user/interfaces/user-info.interface.d.ts +9 -9
  44. package/dist/src/components/login-user/interfaces/user-info.interface.js +2 -2
  45. package/dist/src/components/login-user/login-user.d.ts +41 -41
  46. package/dist/src/components/login-user/login-user.js +332 -332
  47. package/dist/src/components/login-user/user.repository.d.ts +9 -9
  48. package/dist/src/components/login-user/user.repository.js +49 -49
  49. package/dist/src/components/password-hash/index.d.ts +2 -2
  50. package/dist/src/components/password-hash/index.js +18 -18
  51. package/dist/src/components/password-hash/interfaces/index.d.ts +1 -1
  52. package/dist/src/components/password-hash/interfaces/index.js +17 -17
  53. package/dist/src/components/password-hash/interfaces/password-hash-service.interface.d.ts +4 -4
  54. package/dist/src/components/password-hash/interfaces/password-hash-service.interface.js +2 -2
  55. package/dist/src/components/password-hash/password-hash.service.d.ts +6 -6
  56. package/dist/src/components/password-hash/password-hash.service.js +27 -27
  57. package/dist/src/components/system/index.d.ts +1 -1
  58. package/dist/src/components/system/index.js +17 -17
  59. package/dist/src/components/system/system.repository.d.ts +9 -9
  60. package/dist/src/components/system/system.repository.js +49 -49
  61. package/dist/src/components/system-access/index.d.ts +1 -1
  62. package/dist/src/components/system-access/index.js +17 -17
  63. package/dist/src/components/system-access/system-access.repository.d.ts +9 -9
  64. package/dist/src/components/system-access/system-access.repository.js +49 -49
  65. package/dist/src/components/user-group/index.d.ts +1 -1
  66. package/dist/src/components/user-group/index.js +17 -17
  67. package/dist/src/components/user-group/user-group.repository.d.ts +9 -9
  68. package/dist/src/components/user-group/user-group.repository.js +49 -49
  69. package/dist/src/components/user-user-group/index.d.ts +1 -1
  70. package/dist/src/components/user-user-group/index.js +17 -17
  71. package/dist/src/components/user-user-group/user-user-group.repository.d.ts +9 -9
  72. package/dist/src/components/user-user-group/user-user-group.repository.js +49 -49
  73. package/dist/src/index.d.ts +6 -6
  74. package/dist/src/index.js +23 -23
  75. package/dist/src/interfaces/index.d.ts +2 -2
  76. package/dist/src/interfaces/index.js +18 -18
  77. package/dist/src/interfaces/system-login.interface.d.ts +6 -6
  78. package/dist/src/interfaces/system-login.interface.js +2 -2
  79. package/dist/src/interfaces/user-session.interface.d.ts +4 -4
  80. package/dist/src/interfaces/user-session.interface.js +2 -2
  81. package/dist/src/mail/index.d.ts +2 -2
  82. package/dist/src/mail/index.js +18 -18
  83. package/dist/src/mail/interfaces/index.d.ts +2 -2
  84. package/dist/src/mail/interfaces/index.js +18 -18
  85. package/dist/src/mail/interfaces/send-mail.interface.d.ts +8 -8
  86. package/dist/src/mail/interfaces/send-mail.interface.js +2 -2
  87. package/dist/src/mail/interfaces/send-new-login-alert.interface.d.ts +6 -6
  88. package/dist/src/mail/interfaces/send-new-login-alert.interface.js +2 -2
  89. package/dist/src/mail/mail.d.ts +7 -7
  90. package/dist/src/mail/mail.js +48 -48
  91. package/dist/src/mail/mail.service.d.ts +7 -7
  92. package/dist/src/mail/mail.service.js +41 -41
  93. package/dist/src/prisma-client/__mocks__/prisma.d.ts +3 -3
  94. package/dist/src/prisma-client/__mocks__/prisma.js +13 -13
  95. package/dist/src/prisma-client/client.d.ts +3 -3
  96. package/dist/src/prisma-client/client.js +5 -5
  97. package/dist/src/prisma-client/index.d.ts +1 -1
  98. package/dist/src/prisma-client/index.js +17 -17
  99. package/dist/src/redis-client/__mocks__/jest-initial-setup.d.ts +1 -1
  100. package/dist/src/redis-client/__mocks__/jest-initial-setup.js +4 -4
  101. package/dist/src/redis-client/__mocks__/redis-mock.d.ts +2 -2
  102. package/dist/src/redis-client/__mocks__/redis-mock.js +22 -22
  103. package/dist/src/redis-client/index.d.ts +1 -1
  104. package/dist/src/redis-client/index.js +17 -17
  105. package/dist/src/redis-client/redis.service.d.ts +7 -7
  106. package/dist/src/redis-client/redis.service.js +55 -55
  107. package/dist/src/session/index.d.ts +2 -2
  108. package/dist/src/session/index.js +18 -18
  109. package/dist/src/session/interfaces/index.d.ts +1 -1
  110. package/dist/src/session/interfaces/index.js +17 -17
  111. package/dist/src/session/interfaces/session-service.interface.d.ts +5 -5
  112. package/dist/src/session/interfaces/session-service.interface.js +2 -2
  113. package/dist/src/session/session.service.d.ts +9 -9
  114. package/dist/src/session/session.service.js +51 -51
  115. package/dist/tsconfig.tsbuildinfo +1 -1
  116. package/package.json +69 -69
  117. package/sampledotenv +7 -7
  118. package/src/components/index.ts +7 -7
  119. package/src/components/login-history/index.ts +1 -1
  120. package/src/components/login-history/login-history.repository.ts +33 -33
  121. package/src/components/login-user/index.ts +4 -4
  122. package/src/components/login-user/interfaces/user-info.interface.ts +9 -9
  123. package/src/components/login-user/login-user.ts +1 -1
  124. package/src/components/login-user/user.repository.ts +33 -33
  125. package/src/components/password-hash/index.ts +2 -2
  126. package/src/components/password-hash/interfaces/password-hash-service.interface.ts +4 -4
  127. package/src/components/password-hash/password-hash.service.ts +14 -14
  128. package/src/components/system/index.ts +1 -1
  129. package/src/components/system/system.repository.ts +33 -33
  130. package/src/components/system-access/index.ts +1 -1
  131. package/src/components/system-access/system-access.repository.ts +33 -33
  132. package/src/components/user-group/user-group.repository.ts +33 -33
  133. package/src/components/user-user-group/user-user-group.repository.ts +33 -33
  134. package/src/index.ts +7 -7
  135. package/src/interfaces/index.ts +2 -2
  136. package/src/interfaces/system-login.interface.ts +6 -6
  137. package/src/interfaces/user-session.interface.ts +5 -5
  138. package/src/mail/index.ts +2 -2
  139. package/src/mail/interfaces/index.ts +2 -2
  140. package/src/mail/interfaces/send-mail.interface.ts +8 -8
  141. package/src/mail/interfaces/send-new-login-alert.interface.ts +6 -6
  142. package/src/mail/mail.service.ts +33 -33
  143. package/src/mail/mail.ts +40 -40
  144. package/src/prisma-client/__mocks__/prisma.ts +15 -15
  145. package/src/prisma-client/client.ts +3 -3
  146. package/src/redis-client/__mocks__/jest-initial-setup.ts +2 -2
  147. package/src/redis-client/__mocks__/redis-mock.ts +28 -28
  148. package/src/session/index.ts +2 -2
  149. package/src/session/interfaces/index.ts +1 -1
  150. package/src/session/interfaces/session-service.interface.ts +6 -6
  151. package/src/session/session.service.ts +45 -45
  152. package/tsconfig.build.json +5 -5
@@ -1,38 +1,38 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const password_hash_service_1 = require("../../../../src/components/password-hash/password-hash.service");
13
- jest.mock('argon2', () => {
14
- return {
15
- hash: jest.fn((passowrd) => {
16
- return `hash${passowrd}`;
17
- }),
18
- verify: jest.fn().mockResolvedValue(true)
19
- };
20
- });
21
- describe('password-hash.service', () => {
22
- const passwordHashService = new password_hash_service_1.PasswordHashService();
23
- afterEach(() => {
24
- jest.clearAllMocks();
25
- });
26
- it('should return hash password', () => __awaiter(void 0, void 0, void 0, function* () {
27
- const password = 'password';
28
- const hash = yield passwordHashService.hashPassword(password);
29
- expect(hash).toEqual('hashpassword');
30
- }));
31
- it('should return true when verify password', () => __awaiter(void 0, void 0, void 0, function* () {
32
- const password = 'password';
33
- const hash = 'hashpassword10';
34
- const result = yield passwordHashService.verify(password, hash);
35
- expect(result).toEqual(true);
36
- }));
37
- });
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const password_hash_service_1 = require("../../../../src/components/password-hash/password-hash.service");
13
+ jest.mock('argon2', () => {
14
+ return {
15
+ hash: jest.fn((passowrd) => {
16
+ return `hash${passowrd}`;
17
+ }),
18
+ verify: jest.fn().mockResolvedValue(true)
19
+ };
20
+ });
21
+ describe('password-hash.service', () => {
22
+ const passwordHashService = new password_hash_service_1.PasswordHashService();
23
+ afterEach(() => {
24
+ jest.clearAllMocks();
25
+ });
26
+ it('should return hash password', () => __awaiter(void 0, void 0, void 0, function* () {
27
+ const password = 'password';
28
+ const hash = yield passwordHashService.hashPassword(password);
29
+ expect(hash).toEqual('hashpassword');
30
+ }));
31
+ it('should return true when verify password', () => __awaiter(void 0, void 0, void 0, function* () {
32
+ const password = 'password';
33
+ const hash = 'hashpassword10';
34
+ const result = yield passwordHashService.verify(password, hash);
35
+ expect(result).toEqual(true);
36
+ }));
37
+ });
38
38
  //# sourceMappingURL=password-hash.service.spec.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"password-hash.service.spec.js","sourceRoot":"","sources":["../../../../../__tests__/unit/components/password-hash/password-hash.service.spec.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,0GAAqG;AAGrG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,EAAE;IACrB,OAAO;QACH,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE,EAAE;YACvB,OAAO,OAAO,QAAQ,EAAE,CAAC;QAC7B,CAAC,CAAC;QACF,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC;KAC5C,CAAA;AACL,CAAC,CAAC,CAAA;AAEF,QAAQ,CAAC,uBAAuB,EAAE,GAAG,EAAE;IACnC,MAAM,mBAAmB,GAAG,IAAI,2CAAmB,EAAE,CAAC;IACtD,SAAS,CAAC,GAAG,EAAE;QACX,IAAI,CAAC,aAAa,EAAE,CAAC;IACzB,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,6BAA6B,EAAE,GAAS,EAAE;QACzC,MAAM,QAAQ,GAAG,UAAU,CAAC;QAC5B,MAAM,IAAI,GAAG,MAAO,mBAAmB,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QAC/D,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;IACzC,CAAC,CAAA,CAAC,CAAA;IAEF,EAAE,CAAC,yCAAyC,EAAE,GAAS,EAAE;QACrD,MAAM,QAAQ,GAAG,UAAU,CAAC;QAC5B,MAAM,IAAI,GAAG,gBAAgB,CAAC;QAC9B,MAAM,MAAM,GAAG,MAAM,mBAAmB,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QAChE,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC,CAAA,CAAC,CAAC;AAGP,CAAC,CAAC,CAAA"}
1
+ {"version":3,"file":"password-hash.service.spec.js","sourceRoot":"","sources":["../../../../../__tests__/unit/components/password-hash/password-hash.service.spec.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,0GAAqG;AAErG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,EAAE;IACrB,OAAO;QACH,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE,EAAE;YACvB,OAAO,OAAO,QAAQ,EAAE,CAAC;QAC7B,CAAC,CAAC;QACF,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC;KAC5C,CAAA;AACL,CAAC,CAAC,CAAA;AAEF,QAAQ,CAAC,uBAAuB,EAAE,GAAG,EAAE;IACnC,MAAM,mBAAmB,GAAG,IAAI,2CAAmB,EAAE,CAAC;IACtD,SAAS,CAAC,GAAG,EAAE;QACX,IAAI,CAAC,aAAa,EAAE,CAAC;IACzB,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,6BAA6B,EAAE,GAAS,EAAE;QACzC,MAAM,QAAQ,GAAG,UAAU,CAAC;QAC5B,MAAM,IAAI,GAAG,MAAO,mBAAmB,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QAC/D,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;IACzC,CAAC,CAAA,CAAC,CAAA;IAEF,EAAE,CAAC,yCAAyC,EAAE,GAAS,EAAE;QACrD,MAAM,QAAQ,GAAG,UAAU,CAAC;QAC5B,MAAM,IAAI,GAAG,gBAAgB,CAAC;QAC9B,MAAM,MAAM,GAAG,MAAM,mBAAmB,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QAChE,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC,CAAA,CAAC,CAAC;AAGP,CAAC,CAAC,CAAA"}
@@ -1 +1 @@
1
- export {};
1
+ export {};
@@ -1,85 +1,85 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const system_repository_1 = require("../../../../src/components/system/system.repository");
13
- const prisma_1 = require("../../../../src/prisma-client/__mocks__/prisma");
14
- describe('system.repository', () => {
15
- const data = {
16
- id: 175,
17
- code: 'EZC',
18
- name: 'EzCash',
19
- description: 'Tomei Money Lending System',
20
- accessUrl: 'https://app.ezcash.com.my:22443/staff/login',
21
- googlePlayUrl: '',
22
- appleStoreUrl: '',
23
- apiKey: 'f3fef257jt',
24
- logo: 'https://sso-api.tomei.com.my/upload/2023/01/10/FJ3DoHdRZKjf2bGkgA4E-BrowserIcon.png',
25
- status: 'active',
26
- visible: true,
27
- createdAt: new Date(),
28
- updatedAt: new Date(),
29
- apiSecret: '12345',
30
- updatedById: 61,
31
- createdById: 100,
32
- };
33
- afterEach(() => {
34
- jest.restoreAllMocks();
35
- });
36
- describe('findAll', () => {
37
- it('should return list of system', () => __awaiter(void 0, void 0, void 0, function* () {
38
- prisma_1.prismaMock.system.findMany.mockResolvedValueOnce([data]);
39
- const systemRepository = new system_repository_1.SystemRepository();
40
- expect(yield systemRepository.findAll({})).toEqual([data]);
41
- }));
42
- });
43
- describe('findOne', () => {
44
- it('should return system', () => __awaiter(void 0, void 0, void 0, function* () {
45
- prisma_1.prismaMock.system.findFirst.mockResolvedValueOnce(data);
46
- const systemRepository = new system_repository_1.SystemRepository();
47
- expect(yield systemRepository.findOne({
48
- where: {
49
- id: data.id,
50
- },
51
- })).toEqual(data);
52
- }));
53
- });
54
- describe('create', () => {
55
- it('should create system', () => __awaiter(void 0, void 0, void 0, function* () {
56
- prisma_1.prismaMock.system.create.mockResolvedValueOnce(data);
57
- const systemRepository = new system_repository_1.SystemRepository();
58
- expect(yield systemRepository.create(data)).toEqual(data);
59
- }));
60
- });
61
- describe('update', () => {
62
- it('should update system', () => __awaiter(void 0, void 0, void 0, function* () {
63
- prisma_1.prismaMock.system.update.mockResolvedValueOnce(data);
64
- const systemRepository = new system_repository_1.SystemRepository();
65
- expect(yield systemRepository.update({
66
- where: {
67
- id: data.id,
68
- },
69
- data: data,
70
- }, data)).toEqual(data);
71
- }));
72
- });
73
- describe('delete', () => {
74
- it('should delete system', () => __awaiter(void 0, void 0, void 0, function* () {
75
- prisma_1.prismaMock.system.delete.mockResolvedValueOnce(data);
76
- const systemRepository = new system_repository_1.SystemRepository();
77
- expect(yield systemRepository.delete({
78
- where: {
79
- id: data.id,
80
- },
81
- })).toEqual(data);
82
- }));
83
- });
84
- });
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const system_repository_1 = require("../../../../src/components/system/system.repository");
13
+ const prisma_1 = require("../../../../src/prisma-client/__mocks__/prisma");
14
+ describe('system.repository', () => {
15
+ const data = {
16
+ id: 175,
17
+ code: 'EZC',
18
+ name: 'EzCash',
19
+ description: 'Tomei Money Lending System',
20
+ accessUrl: 'https://app.ezcash.com.my:22443/staff/login',
21
+ googlePlayUrl: '',
22
+ appleStoreUrl: '',
23
+ apiKey: 'f3fef257jt',
24
+ logo: 'https://sso-api.tomei.com.my/upload/2023/01/10/FJ3DoHdRZKjf2bGkgA4E-BrowserIcon.png',
25
+ status: 'active',
26
+ visible: true,
27
+ createdAt: new Date(),
28
+ updatedAt: new Date(),
29
+ apiSecret: '12345',
30
+ updatedById: 61,
31
+ createdById: 100,
32
+ };
33
+ afterEach(() => {
34
+ jest.restoreAllMocks();
35
+ });
36
+ describe('findAll', () => {
37
+ it('should return list of system', () => __awaiter(void 0, void 0, void 0, function* () {
38
+ prisma_1.prismaMock.system.findMany.mockResolvedValueOnce([data]);
39
+ const systemRepository = new system_repository_1.SystemRepository();
40
+ expect(yield systemRepository.findAll({})).toEqual([data]);
41
+ }));
42
+ });
43
+ describe('findOne', () => {
44
+ it('should return system', () => __awaiter(void 0, void 0, void 0, function* () {
45
+ prisma_1.prismaMock.system.findFirst.mockResolvedValueOnce(data);
46
+ const systemRepository = new system_repository_1.SystemRepository();
47
+ expect(yield systemRepository.findOne({
48
+ where: {
49
+ id: data.id,
50
+ },
51
+ })).toEqual(data);
52
+ }));
53
+ });
54
+ describe('create', () => {
55
+ it('should create system', () => __awaiter(void 0, void 0, void 0, function* () {
56
+ prisma_1.prismaMock.system.create.mockResolvedValueOnce(data);
57
+ const systemRepository = new system_repository_1.SystemRepository();
58
+ expect(yield systemRepository.create(data)).toEqual(data);
59
+ }));
60
+ });
61
+ describe('update', () => {
62
+ it('should update system', () => __awaiter(void 0, void 0, void 0, function* () {
63
+ prisma_1.prismaMock.system.update.mockResolvedValueOnce(data);
64
+ const systemRepository = new system_repository_1.SystemRepository();
65
+ expect(yield systemRepository.update({
66
+ where: {
67
+ id: data.id,
68
+ },
69
+ data: data,
70
+ }, data)).toEqual(data);
71
+ }));
72
+ });
73
+ describe('delete', () => {
74
+ it('should delete system', () => __awaiter(void 0, void 0, void 0, function* () {
75
+ prisma_1.prismaMock.system.delete.mockResolvedValueOnce(data);
76
+ const systemRepository = new system_repository_1.SystemRepository();
77
+ expect(yield systemRepository.delete({
78
+ where: {
79
+ id: data.id,
80
+ },
81
+ })).toEqual(data);
82
+ }));
83
+ });
84
+ });
85
85
  //# sourceMappingURL=system.repository.spec.js.map
@@ -1 +1 @@
1
- export {};
1
+ export {};
@@ -1,75 +1,75 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const system_access_repository_1 = require("../../../../src/components/system-access/system-access.repository");
13
- const prisma_1 = require("../../../../src/prisma-client/__mocks__/prisma");
14
- describe('system-access.repository', () => {
15
- const data = {
16
- userId: 1,
17
- systemId: 175,
18
- updatedAt: new Date(),
19
- };
20
- afterEach(() => {
21
- jest.restoreAllMocks();
22
- });
23
- describe('findAll', () => {
24
- it('should return list of system access', () => __awaiter(void 0, void 0, void 0, function* () {
25
- prisma_1.prismaMock.systemAccess.findMany.mockResolvedValueOnce([data]);
26
- const systemAccessRepository = new system_access_repository_1.SystemAccessRepository();
27
- expect(yield systemAccessRepository.findAll({})).toEqual([data]);
28
- }));
29
- });
30
- describe('findOne', () => {
31
- it('should return system access', () => __awaiter(void 0, void 0, void 0, function* () {
32
- prisma_1.prismaMock.systemAccess.findFirst.mockResolvedValueOnce(data);
33
- const systemAccessRepository = new system_access_repository_1.SystemAccessRepository();
34
- expect(yield systemAccessRepository.findOne({
35
- where: {
36
- userId: data.userId,
37
- systemId: data.systemId,
38
- },
39
- })).toEqual(data);
40
- }));
41
- });
42
- describe('create', () => {
43
- it('should create system access', () => __awaiter(void 0, void 0, void 0, function* () {
44
- prisma_1.prismaMock.systemAccess.create.mockResolvedValueOnce(data);
45
- const systemAccessRepository = new system_access_repository_1.SystemAccessRepository();
46
- expect(yield systemAccessRepository.create(data)).toEqual(data);
47
- }));
48
- });
49
- describe('update', () => {
50
- it('should update system access', () => __awaiter(void 0, void 0, void 0, function* () {
51
- prisma_1.prismaMock.systemAccess.update.mockResolvedValueOnce(data);
52
- const systemAccessRepository = new system_access_repository_1.SystemAccessRepository();
53
- expect(yield systemAccessRepository.update({
54
- where: {
55
- userId: data.userId,
56
- systemId: data.systemId,
57
- },
58
- data: data,
59
- }, data)).toEqual(data);
60
- }));
61
- });
62
- describe('delete', () => {
63
- it('should delete system access', () => __awaiter(void 0, void 0, void 0, function* () {
64
- prisma_1.prismaMock.systemAccess.delete.mockResolvedValueOnce(data);
65
- const systemAccessRepository = new system_access_repository_1.SystemAccessRepository();
66
- expect(yield systemAccessRepository.delete({
67
- where: {
68
- userId: data.userId,
69
- systemId: data.systemId,
70
- },
71
- })).toEqual(data);
72
- }));
73
- });
74
- });
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const system_access_repository_1 = require("../../../../src/components/system-access/system-access.repository");
13
+ const prisma_1 = require("../../../../src/prisma-client/__mocks__/prisma");
14
+ describe('system-access.repository', () => {
15
+ const data = {
16
+ userId: 1,
17
+ systemId: 175,
18
+ updatedAt: new Date(),
19
+ };
20
+ afterEach(() => {
21
+ jest.restoreAllMocks();
22
+ });
23
+ describe('findAll', () => {
24
+ it('should return list of system access', () => __awaiter(void 0, void 0, void 0, function* () {
25
+ prisma_1.prismaMock.systemAccess.findMany.mockResolvedValueOnce([data]);
26
+ const systemAccessRepository = new system_access_repository_1.SystemAccessRepository();
27
+ expect(yield systemAccessRepository.findAll({})).toEqual([data]);
28
+ }));
29
+ });
30
+ describe('findOne', () => {
31
+ it('should return system access', () => __awaiter(void 0, void 0, void 0, function* () {
32
+ prisma_1.prismaMock.systemAccess.findFirst.mockResolvedValueOnce(data);
33
+ const systemAccessRepository = new system_access_repository_1.SystemAccessRepository();
34
+ expect(yield systemAccessRepository.findOne({
35
+ where: {
36
+ userId: data.userId,
37
+ systemId: data.systemId,
38
+ },
39
+ })).toEqual(data);
40
+ }));
41
+ });
42
+ describe('create', () => {
43
+ it('should create system access', () => __awaiter(void 0, void 0, void 0, function* () {
44
+ prisma_1.prismaMock.systemAccess.create.mockResolvedValueOnce(data);
45
+ const systemAccessRepository = new system_access_repository_1.SystemAccessRepository();
46
+ expect(yield systemAccessRepository.create(data)).toEqual(data);
47
+ }));
48
+ });
49
+ describe('update', () => {
50
+ it('should update system access', () => __awaiter(void 0, void 0, void 0, function* () {
51
+ prisma_1.prismaMock.systemAccess.update.mockResolvedValueOnce(data);
52
+ const systemAccessRepository = new system_access_repository_1.SystemAccessRepository();
53
+ expect(yield systemAccessRepository.update({
54
+ where: {
55
+ userId: data.userId,
56
+ systemId: data.systemId,
57
+ },
58
+ data: data,
59
+ }, data)).toEqual(data);
60
+ }));
61
+ });
62
+ describe('delete', () => {
63
+ it('should delete system access', () => __awaiter(void 0, void 0, void 0, function* () {
64
+ prisma_1.prismaMock.systemAccess.delete.mockResolvedValueOnce(data);
65
+ const systemAccessRepository = new system_access_repository_1.SystemAccessRepository();
66
+ expect(yield systemAccessRepository.delete({
67
+ where: {
68
+ userId: data.userId,
69
+ systemId: data.systemId,
70
+ },
71
+ })).toEqual(data);
72
+ }));
73
+ });
74
+ });
75
75
  //# sourceMappingURL=system-access.repository.spec.js.map
@@ -1 +1 @@
1
- export {};
1
+ export {};
@@ -1,32 +1,32 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const redis_service_1 = require("../../../src/redis-client/redis.service");
13
- require('dotenv').config();
14
- describe('redis.service', () => {
15
- afterEach(() => {
16
- jest.restoreAllMocks();
17
- });
18
- it('should return redis service when instansiated', () => __awaiter(void 0, void 0, void 0, function* () {
19
- const redisService = yield redis_service_1.RedisService.init();
20
- expect(redisService).toBeDefined();
21
- }));
22
- it('should able to write and read redis', () => __awaiter(void 0, void 0, void 0, function* () {
23
- const data = {
24
- test: 'test'
25
- };
26
- const redisService = yield redis_service_1.RedisService.init();
27
- yield redisService.set("test", data, 60 * 60 * 24 * 1);
28
- const result = yield redisService.get("test");
29
- expect(result).toEqual(JSON.stringify(data));
30
- }));
31
- });
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const redis_service_1 = require("../../../src/redis-client/redis.service");
13
+ require('dotenv').config();
14
+ describe('redis.service', () => {
15
+ afterEach(() => {
16
+ jest.restoreAllMocks();
17
+ });
18
+ it('should return redis service when instansiated', () => __awaiter(void 0, void 0, void 0, function* () {
19
+ const redisService = yield redis_service_1.RedisService.init();
20
+ expect(redisService).toBeDefined();
21
+ }));
22
+ it('should able to write and read redis', () => __awaiter(void 0, void 0, void 0, function* () {
23
+ const data = {
24
+ test: 'test'
25
+ };
26
+ const redisService = yield redis_service_1.RedisService.init();
27
+ yield redisService.set("test", data, 60 * 60 * 24 * 1);
28
+ const result = yield redisService.get("test");
29
+ expect(result).toEqual(JSON.stringify(data));
30
+ }));
31
+ });
32
32
  //# sourceMappingURL=redis.service.spec.js.map
@@ -1 +1 @@
1
- export {};
1
+ export {};
@@ -1,36 +1,36 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const session_service_1 = require("../../../src/session/session.service");
13
- require('dotenv').config();
14
- describe('session.service', () => {
15
- it('should return session service when instansiated', () => __awaiter(void 0, void 0, void 0, function* () {
16
- const sessionService = yield session_service_1.SessionService.init();
17
- expect(sessionService).toBeDefined();
18
- }));
19
- it('should able to write session data', () => __awaiter(void 0, void 0, void 0, function* () {
20
- const data = {
21
- systemLogins: [
22
- {
23
- id: '1',
24
- code: 'EZC',
25
- sessionId: 'test1',
26
- privileges: ['PRIVILEGE1', 'PRIVILEGE2'],
27
- },
28
- ],
29
- };
30
- const sessionService = yield session_service_1.SessionService.init();
31
- yield sessionService.setUserSession("1", data);
32
- const result = yield sessionService.retrieveUserSession("1");
33
- expect(result).toEqual(data);
34
- }));
35
- });
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const session_service_1 = require("../../../src/session/session.service");
13
+ require('dotenv').config();
14
+ describe('session.service', () => {
15
+ it('should return session service when instansiated', () => __awaiter(void 0, void 0, void 0, function* () {
16
+ const sessionService = yield session_service_1.SessionService.init();
17
+ expect(sessionService).toBeDefined();
18
+ }));
19
+ it('should able to write session data', () => __awaiter(void 0, void 0, void 0, function* () {
20
+ const data = {
21
+ systemLogins: [
22
+ {
23
+ id: '1',
24
+ code: 'EZC',
25
+ sessionId: 'test1',
26
+ privileges: ['PRIVILEGE1', 'PRIVILEGE2'],
27
+ },
28
+ ],
29
+ };
30
+ const sessionService = yield session_service_1.SessionService.init();
31
+ yield sessionService.setUserSession("1", data);
32
+ const result = yield sessionService.retrieveUserSession("1");
33
+ expect(result).toEqual(data);
34
+ }));
35
+ });
36
36
  //# sourceMappingURL=session.service.spec.js.map
package/dist/index.d.ts CHANGED
@@ -1 +1 @@
1
- export * from "./src";
1
+ export * from "./src";
package/dist/index.js CHANGED
@@ -1,18 +1,18 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./src"), exports);
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./src"), exports);
18
18
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
- export * from './login-history';
2
- export * from './login-user';
3
- export * from './password-hash';
4
- export * from './system';
5
- export * from './system-access';
6
- export * from './user-group';
7
- export * from './user-user-group';
1
+ export * from './login-history';
2
+ export * from './login-user';
3
+ export * from './password-hash';
4
+ export * from './system';
5
+ export * from './system-access';
6
+ export * from './user-group';
7
+ export * from './user-user-group';