@tomei/sso 0.60.4 → 0.61.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 (677) hide show
  1. package/.commitlintrc.json +22 -22
  2. package/.gitlab-ci.yml +16 -16
  3. package/.husky/commit-msg +15 -15
  4. package/.husky/pre-commit +7 -7
  5. package/.prettierrc +4 -4
  6. package/Jenkinsfile +57 -57
  7. package/README.md +23 -23
  8. package/__tests__/unit/components/group/group.spec.ts +79 -79
  9. package/__tests__/unit/components/group-object-privilege/group-object-privilege.spec.ts +88 -88
  10. package/__tests__/unit/components/group-privilege/group-privilege.spec.ts +68 -68
  11. package/__tests__/unit/components/group-reporting-user/group-reporting-user.spec.ts +66 -66
  12. package/__tests__/unit/components/group-system-access/group-system-access.spec.ts +83 -83
  13. package/__tests__/unit/components/login-user/l.spec.ts +746 -746
  14. package/__tests__/unit/components/login-user/login.spec.ts +1164 -1164
  15. package/__tests__/unit/components/password-hash/password-hash.service.spec.ts +31 -31
  16. package/__tests__/unit/components/system/system.spec.ts +254 -254
  17. package/__tests__/unit/components/system-privilege/system-privilege.spec.ts +83 -83
  18. package/__tests__/unit/components/user-group/user-group.spec.ts +86 -86
  19. package/__tests__/unit/components/user-object-privilege/user-object-privilege.spec.ts +78 -78
  20. package/__tests__/unit/components/user-privilege/user-privilege.spec.ts +72 -72
  21. package/__tests__/unit/components/user-system-access/user-system-access.spec.ts +89 -89
  22. package/__tests__/unit/redis-client/redis.service.spec.ts +23 -23
  23. package/__tests__/unit/session/session.service.spec.ts +47 -47
  24. package/__tests__/unit/system-privilege/system-privilage.spec.ts +91 -91
  25. package/coverage/clover.xml +1452 -1452
  26. package/coverage/coverage-final.json +47 -47
  27. package/coverage/lcov-report/base.css +224 -224
  28. package/coverage/lcov-report/block-navigation.js +87 -87
  29. package/coverage/lcov-report/components/group/group.repository.ts.html +117 -117
  30. package/coverage/lcov-report/components/group/group.ts.html +327 -327
  31. package/coverage/lcov-report/components/group/index.html +130 -130
  32. package/coverage/lcov-report/components/group-object-privilege/group-object-privilege.repository.ts.html +117 -117
  33. package/coverage/lcov-report/components/group-object-privilege/group-object-privilege.ts.html +321 -321
  34. package/coverage/lcov-report/components/group-object-privilege/index.html +130 -130
  35. package/coverage/lcov-report/components/group-privilege/group-privilege.repository.ts.html +117 -117
  36. package/coverage/lcov-report/components/group-privilege/group-privilege.ts.html +303 -303
  37. package/coverage/lcov-report/components/group-privilege/index.html +130 -130
  38. package/coverage/lcov-report/components/group-reporting-user/group-reporting-user.repository.ts.html +117 -117
  39. package/coverage/lcov-report/components/group-reporting-user/group-reporting-user.ts.html +327 -327
  40. package/coverage/lcov-report/components/group-reporting-user/index.html +130 -130
  41. package/coverage/lcov-report/components/group-system-access/group-system-access.repository.ts.html +117 -117
  42. package/coverage/lcov-report/components/group-system-access/group-system-access.ts.html +309 -309
  43. package/coverage/lcov-report/components/group-system-access/index.html +130 -130
  44. package/coverage/lcov-report/components/login-history/index.html +115 -115
  45. package/coverage/lcov-report/components/login-history/login-history.repository.ts.html +117 -117
  46. package/coverage/lcov-report/components/login-user/index.html +130 -130
  47. package/coverage/lcov-report/components/login-user/login-user.ts.html +5007 -5007
  48. package/coverage/lcov-report/components/login-user/user.repository.ts.html +117 -117
  49. package/coverage/lcov-report/components/password-hash/index.html +115 -115
  50. package/coverage/lcov-report/components/password-hash/password-hash.service.ts.html +126 -126
  51. package/coverage/lcov-report/components/system/index.html +130 -130
  52. package/coverage/lcov-report/components/system/system.repository.ts.html +117 -117
  53. package/coverage/lcov-report/components/system/system.ts.html +909 -909
  54. package/coverage/lcov-report/components/system-privilege/index.html +130 -130
  55. package/coverage/lcov-report/components/system-privilege/system-privilege.repository.ts.html +120 -120
  56. package/coverage/lcov-report/components/system-privilege/system-privilege.ts.html +390 -390
  57. package/coverage/lcov-report/components/user-group/index.html +130 -130
  58. package/coverage/lcov-report/components/user-group/user-group.repository.ts.html +117 -117
  59. package/coverage/lcov-report/components/user-group/user-group.ts.html +354 -354
  60. package/coverage/lcov-report/components/user-object-privilege/index.html +130 -130
  61. package/coverage/lcov-report/components/user-object-privilege/user-object-privilege.repository.ts.html +117 -117
  62. package/coverage/lcov-report/components/user-object-privilege/user-object-privilege.ts.html +312 -312
  63. package/coverage/lcov-report/components/user-privilege/index.html +130 -130
  64. package/coverage/lcov-report/components/user-privilege/user-privilege.repository.ts.html +117 -117
  65. package/coverage/lcov-report/components/user-privilege/user-privilege.ts.html +306 -306
  66. package/coverage/lcov-report/components/user-system-access/index.html +130 -130
  67. package/coverage/lcov-report/components/user-system-access/user-system-access.repository.ts.html +117 -117
  68. package/coverage/lcov-report/components/user-system-access/user-system-access.ts.html +312 -312
  69. package/coverage/lcov-report/enum/group-type.enum.ts.html +108 -108
  70. package/coverage/lcov-report/enum/index.html +160 -160
  71. package/coverage/lcov-report/enum/index.ts.html +93 -93
  72. package/coverage/lcov-report/enum/user-status.enum.ts.html +105 -105
  73. package/coverage/lcov-report/enum/yn.enum.ts.html +96 -96
  74. package/coverage/lcov-report/index.html +370 -370
  75. package/coverage/lcov-report/models/group-object-privilege.entity.ts.html +333 -333
  76. package/coverage/lcov-report/models/group-privilege.entity.ts.html +315 -315
  77. package/coverage/lcov-report/models/group-reporting-user.entity.ts.html +339 -339
  78. package/coverage/lcov-report/models/group-system-access.entity.ts.html +324 -324
  79. package/coverage/lcov-report/models/group.entity.ts.html +435 -435
  80. package/coverage/lcov-report/models/index.html +310 -310
  81. package/coverage/lcov-report/models/login-history.entity.ts.html +252 -252
  82. package/coverage/lcov-report/models/staff.entity.ts.html +411 -411
  83. package/coverage/lcov-report/models/system-privilege.entity.ts.html +354 -354
  84. package/coverage/lcov-report/models/system.entity.ts.html +423 -423
  85. package/coverage/lcov-report/models/user-group.entity.ts.html +354 -354
  86. package/coverage/lcov-report/models/user-object-privilege.entity.ts.html +330 -330
  87. package/coverage/lcov-report/models/user-privilege.entity.ts.html +315 -315
  88. package/coverage/lcov-report/models/user-system-access.entity.ts.html +315 -315
  89. package/coverage/lcov-report/models/user.entity.ts.html +522 -522
  90. package/coverage/lcov-report/prettify.css +1 -1
  91. package/coverage/lcov-report/prettify.js +2 -2
  92. package/coverage/lcov-report/redis-client/index.html +115 -115
  93. package/coverage/lcov-report/redis-client/redis.service.ts.html +240 -240
  94. package/coverage/lcov-report/session/index.html +115 -115
  95. package/coverage/lcov-report/session/session.service.ts.html +246 -246
  96. package/coverage/lcov-report/sorter.js +196 -196
  97. package/coverage/lcov.info +2490 -2490
  98. package/coverage/test-report.xml +128 -128
  99. package/create-sso-user.sql +39 -39
  100. package/dist/src/components/login-user/user.js +8 -0
  101. package/dist/src/components/login-user/user.js.map +1 -1
  102. package/dist/tsconfig.tsbuildinfo +1 -1
  103. package/eslint.config.mjs +58 -58
  104. package/jest.config.js +14 -14
  105. package/migrations/20240314080602-create-user-table.js +124 -124
  106. package/migrations/20240314080603-create-user-group-table.js +85 -85
  107. package/migrations/20240314080604-create-user-user-group-table.js +55 -55
  108. package/migrations/20240314080605-create-login-history-table.js +53 -53
  109. package/migrations/20240527064925-create-system-table.js +78 -78
  110. package/migrations/20240527064926-create-system-privilege-table.js +71 -71
  111. package/migrations/20240527065342-create-group-table.js +93 -93
  112. package/migrations/20240527065633-create-group-reporting-user-table.js +76 -76
  113. package/migrations/20240528011551-create-group-system-access-table.js +72 -72
  114. package/migrations/20240528023018-user-system-access-table.js +75 -75
  115. package/migrations/20240528032229-user-privilege-table.js +76 -76
  116. package/migrations/20240528063003-create-group-privilege-table.js +76 -76
  117. package/migrations/20240528063051-create-group-object-privilege-table.js +84 -84
  118. package/migrations/20240528063107-create-user-object-privilege-table.js +84 -84
  119. package/migrations/20240528063108-create-api-key-table.js +85 -85
  120. package/migrations/20241104104802-create-building-table.js +95 -95
  121. package/migrations/20250108091132-add-area-manager-user-id-to-building-table.js +14 -14
  122. package/migrations/20250108091133-add-passcode-to-user-table.js +36 -36
  123. package/migrations/20250210115636-create-user-reporting-hierarchy.js +76 -76
  124. package/migrations/20250326043818-crate-user-password-history.js +42 -42
  125. package/package.json +90 -90
  126. package/sampledotenv +7 -7
  127. package/sonar-project.properties +22 -22
  128. package/src/components/api-key/api-key.repository.ts +15 -15
  129. package/src/components/api-key/api-key.ts +448 -448
  130. package/src/components/api-key/index.ts +4 -4
  131. package/src/components/building/building.repository.ts +27 -27
  132. package/src/components/building/index.ts +2 -2
  133. package/src/components/group/group.repository.ts +26 -26
  134. package/src/components/group/group.ts +2284 -2284
  135. package/src/components/group/index.ts +3 -3
  136. package/src/components/group-object-privilege/group-object-privilege.repository.ts +25 -25
  137. package/src/components/group-object-privilege/group-object-privilege.ts +278 -278
  138. package/src/components/group-object-privilege/index.ts +2 -2
  139. package/src/components/group-privilege/group-privilege.repository.ts +29 -29
  140. package/src/components/group-privilege/group-privilege.ts +84 -84
  141. package/src/components/group-privilege/index.ts +2 -2
  142. package/src/components/group-reporting-user/group-reporting-user.repository.ts +23 -23
  143. package/src/components/group-reporting-user/group-reporting-user.ts +506 -506
  144. package/src/components/group-reporting-user/index.ts +3 -3
  145. package/src/components/group-system-access/group-system-access.repository.ts +43 -43
  146. package/src/components/group-system-access/group-system-access.ts +90 -90
  147. package/src/components/group-system-access/index.ts +2 -2
  148. package/src/components/index.ts +20 -20
  149. package/src/components/login-history/index.ts +1 -1
  150. package/src/components/login-history/login-history.repository.ts +11 -11
  151. package/src/components/login-user/index.ts +5 -5
  152. package/src/components/login-user/interfaces/check-user-info-duplicated.interface.ts +7 -7
  153. package/src/components/login-user/interfaces/index.ts +1 -1
  154. package/src/components/login-user/interfaces/system-access.interface.ts +13 -13
  155. package/src/components/login-user/interfaces/user-info.interface.ts +34 -34
  156. package/src/components/login-user/login-user.ts +362 -362
  157. package/src/components/login-user/user.repository.ts +11 -11
  158. package/src/components/login-user/user.ts +3142 -3134
  159. package/src/components/password-hash/index.ts +2 -2
  160. package/src/components/password-hash/interfaces/index.ts +1 -1
  161. package/src/components/password-hash/interfaces/password-hash-service.interface.ts +4 -4
  162. package/src/components/password-hash/password-hash.service.ts +14 -14
  163. package/src/components/staff/index.ts +2 -2
  164. package/src/components/staff/staff.repository.ts +27 -27
  165. package/src/components/system/index.ts +3 -3
  166. package/src/components/system/system.repository.ts +11 -11
  167. package/src/components/system/system.ts +456 -456
  168. package/src/components/system-privilege/index.ts +4 -4
  169. package/src/components/system-privilege/system-privilege.repository.ts +18 -18
  170. package/src/components/system-privilege/system-privilege.ts +541 -541
  171. package/src/components/user-group/index.ts +2 -2
  172. package/src/components/user-group/user-group.repository.ts +19 -19
  173. package/src/components/user-group/user-group.ts +764 -764
  174. package/src/components/user-object-privilege/index.ts +2 -2
  175. package/src/components/user-object-privilege/user-object-privilege.repository.ts +11 -11
  176. package/src/components/user-object-privilege/user-object-privilege.ts +79 -79
  177. package/src/components/user-password-history/index.ts +2 -2
  178. package/src/components/user-password-history/user-password-history.repository.ts +39 -39
  179. package/src/components/user-password-history/user-password-history.ts +187 -187
  180. package/src/components/user-privilege/index.ts +2 -2
  181. package/src/components/user-privilege/user-privilege.repository.ts +25 -25
  182. package/src/components/user-privilege/user-privilege.ts +662 -662
  183. package/src/components/user-reporting-hierarchy/index.ts +2 -2
  184. package/src/components/user-reporting-hierarchy/user-reporting-hierarchy.repository.ts +30 -30
  185. package/src/components/user-reporting-hierarchy/user-reporting-hierarchy.ts +505 -505
  186. package/src/components/user-system-access/index.ts +2 -2
  187. package/src/components/user-system-access/user-system-access.repository.ts +41 -41
  188. package/src/components/user-system-access/user-system-access.ts +717 -717
  189. package/src/database.ts +15 -15
  190. package/src/enum/api-key.enum.ts +5 -5
  191. package/src/enum/building-type.enum.ts +6 -6
  192. package/src/enum/group-type.enum.ts +8 -8
  193. package/src/enum/index.ts +6 -6
  194. package/src/enum/login-status.enum.ts +4 -4
  195. package/src/enum/object-status.enum.ts +4 -4
  196. package/src/enum/user-status.enum.ts +7 -7
  197. package/src/enum/yn.enum.ts +4 -4
  198. package/src/index.ts +8 -8
  199. package/src/interfaces/api-key-attr.interface.ts +16 -16
  200. package/src/interfaces/group-object-privilege.interface.ts +14 -14
  201. package/src/interfaces/group-privilege.interface.ts +10 -10
  202. package/src/interfaces/group-reporting-user.interface.ts +11 -11
  203. package/src/interfaces/group-search-attr.interface.ts +9 -9
  204. package/src/interfaces/group-system-access.interface.ts +10 -10
  205. package/src/interfaces/group.interface.ts +17 -17
  206. package/src/interfaces/index.ts +13 -13
  207. package/src/interfaces/system-login.interface.ts +6 -6
  208. package/src/interfaces/system-privilege-search.interface.ts +5 -5
  209. package/src/interfaces/system-privilege.interface.ts +11 -11
  210. package/src/interfaces/system-search-attr.interface.ts +5 -5
  211. package/src/interfaces/system.interface.ts +15 -15
  212. package/src/interfaces/user-group.interface.ts +12 -12
  213. package/src/interfaces/user-object-privilege.interface.ts +14 -14
  214. package/src/interfaces/user-password-history.interface.ts +6 -6
  215. package/src/interfaces/user-privilege.interface.ts +10 -10
  216. package/src/interfaces/user-reporting-hierarchy.interface.ts +11 -11
  217. package/src/interfaces/user-session.interface.ts +5 -5
  218. package/src/interfaces/user-system-access.interface.ts +10 -10
  219. package/src/models/api-key-entity.ts +101 -101
  220. package/src/models/building.entity.ts +103 -103
  221. package/src/models/group-object-privilege.entity.ts +91 -91
  222. package/src/models/group-privilege.entity.ts +78 -78
  223. package/src/models/group-reporting-user.entity.ts +95 -95
  224. package/src/models/group-system-access.entity.ts +81 -81
  225. package/src/models/group.entity.ts +127 -127
  226. package/src/models/login-history.entity.ts +63 -63
  227. package/src/models/staff.entity.ts +91 -91
  228. package/src/models/system-privilege.entity.ts +90 -90
  229. package/src/models/system.entity.ts +113 -113
  230. package/src/models/user-group.entity.ts +91 -91
  231. package/src/models/user-object-privilege.entity.ts +90 -90
  232. package/src/models/user-password-history.ts +51 -51
  233. package/src/models/user-privilege.entity.ts +78 -78
  234. package/src/models/user-reporting-hierarchy.entity.ts +102 -102
  235. package/src/models/user-system-access.entity.ts +87 -87
  236. package/src/models/user.entity.ts +193 -193
  237. package/src/redis-client/__mocks__/jest-initial-setup.ts +2 -2
  238. package/src/redis-client/__mocks__/redis-mock.ts +28 -28
  239. package/src/redis-client/index.ts +1 -1
  240. package/src/redis-client/redis.service.ts +75 -75
  241. package/src/session/index.ts +2 -2
  242. package/src/session/interfaces/index.ts +1 -1
  243. package/src/session/interfaces/session-service.interface.ts +26 -26
  244. package/src/session/session.service.ts +96 -96
  245. package/src/types/auth-context.ts +10 -10
  246. package/src/types/index.ts +1 -1
  247. package/tsconfig.build.json +5 -5
  248. package/tsconfig.json +23 -23
  249. package/dist/components/api-key/api-key.d.ts +0 -85
  250. package/dist/components/api-key/api-key.d.ts.map +0 -1
  251. package/dist/components/api-key/api-key.js +0 -245
  252. package/dist/components/api-key/api-key.js.map +0 -1
  253. package/dist/components/api-key/api-key.repository.d.ts +0 -7
  254. package/dist/components/api-key/api-key.repository.d.ts.map +0 -1
  255. package/dist/components/api-key/api-key.repository.js +0 -18
  256. package/dist/components/api-key/api-key.repository.js.map +0 -1
  257. package/dist/components/api-key/index.d.ts +0 -4
  258. package/dist/components/api-key/index.d.ts.map +0 -1
  259. package/dist/components/api-key/index.js +0 -8
  260. package/dist/components/api-key/index.js.map +0 -1
  261. package/dist/components/building/building.repository.d.ts +0 -7
  262. package/dist/components/building/building.repository.d.ts.map +0 -1
  263. package/dist/components/building/building.repository.js +0 -30
  264. package/dist/components/building/building.repository.js.map +0 -1
  265. package/dist/components/building/index.d.ts +0 -2
  266. package/dist/components/building/index.d.ts.map +0 -1
  267. package/dist/components/building/index.js +0 -18
  268. package/dist/components/building/index.js.map +0 -1
  269. package/dist/components/group/group.d.ts +0 -129
  270. package/dist/components/group/group.d.ts.map +0 -1
  271. package/dist/components/group/group.js +0 -1337
  272. package/dist/components/group/group.js.map +0 -1
  273. package/dist/components/group/group.repository.d.ts +0 -8
  274. package/dist/components/group/group.repository.d.ts.map +0 -1
  275. package/dist/components/group/group.repository.js +0 -29
  276. package/dist/components/group/group.repository.js.map +0 -1
  277. package/dist/components/group/index.d.ts +0 -3
  278. package/dist/components/group/index.d.ts.map +0 -1
  279. package/dist/components/group/index.js +0 -19
  280. package/dist/components/group/index.js.map +0 -1
  281. package/dist/components/group-object-privilege/group-object-privilege.d.ts +0 -28
  282. package/dist/components/group-object-privilege/group-object-privilege.d.ts.map +0 -1
  283. package/dist/components/group-object-privilege/group-object-privilege.js +0 -163
  284. package/dist/components/group-object-privilege/group-object-privilege.js.map +0 -1
  285. package/dist/components/group-object-privilege/group-object-privilege.repository.d.ts +0 -7
  286. package/dist/components/group-object-privilege/group-object-privilege.repository.d.ts.map +0 -1
  287. package/dist/components/group-object-privilege/group-object-privilege.repository.js +0 -26
  288. package/dist/components/group-object-privilege/group-object-privilege.repository.js.map +0 -1
  289. package/dist/components/group-object-privilege/index.d.ts +0 -3
  290. package/dist/components/group-object-privilege/index.d.ts.map +0 -1
  291. package/dist/components/group-object-privilege/index.js +0 -19
  292. package/dist/components/group-object-privilege/index.js.map +0 -1
  293. package/dist/components/group-privilege/group-privilege.d.ts +0 -25
  294. package/dist/components/group-privilege/group-privilege.d.ts.map +0 -1
  295. package/dist/components/group-privilege/group-privilege.js +0 -67
  296. package/dist/components/group-privilege/group-privilege.js.map +0 -1
  297. package/dist/components/group-privilege/group-privilege.repository.d.ts +0 -7
  298. package/dist/components/group-privilege/group-privilege.repository.d.ts.map +0 -1
  299. package/dist/components/group-privilege/group-privilege.repository.js +0 -28
  300. package/dist/components/group-privilege/group-privilege.repository.js.map +0 -1
  301. package/dist/components/group-privilege/index.d.ts +0 -3
  302. package/dist/components/group-privilege/index.d.ts.map +0 -1
  303. package/dist/components/group-privilege/index.js +0 -19
  304. package/dist/components/group-privilege/index.js.map +0 -1
  305. package/dist/components/group-reporting-user/group-reporting-user.d.ts +0 -30
  306. package/dist/components/group-reporting-user/group-reporting-user.d.ts.map +0 -1
  307. package/dist/components/group-reporting-user/group-reporting-user.js +0 -277
  308. package/dist/components/group-reporting-user/group-reporting-user.js.map +0 -1
  309. package/dist/components/group-reporting-user/group-reporting-user.repository.d.ts +0 -7
  310. package/dist/components/group-reporting-user/group-reporting-user.repository.d.ts.map +0 -1
  311. package/dist/components/group-reporting-user/group-reporting-user.repository.js +0 -23
  312. package/dist/components/group-reporting-user/group-reporting-user.repository.js.map +0 -1
  313. package/dist/components/group-reporting-user/index.d.ts +0 -3
  314. package/dist/components/group-reporting-user/index.d.ts.map +0 -1
  315. package/dist/components/group-reporting-user/index.js +0 -19
  316. package/dist/components/group-reporting-user/index.js.map +0 -1
  317. package/dist/components/group-system-access/group-system-access.d.ts +0 -28
  318. package/dist/components/group-system-access/group-system-access.d.ts.map +0 -1
  319. package/dist/components/group-system-access/group-system-access.js +0 -70
  320. package/dist/components/group-system-access/group-system-access.js.map +0 -1
  321. package/dist/components/group-system-access/group-system-access.repository.d.ts +0 -8
  322. package/dist/components/group-system-access/group-system-access.repository.d.ts.map +0 -1
  323. package/dist/components/group-system-access/group-system-access.repository.js +0 -46
  324. package/dist/components/group-system-access/group-system-access.repository.js.map +0 -1
  325. package/dist/components/group-system-access/index.d.ts +0 -3
  326. package/dist/components/group-system-access/index.d.ts.map +0 -1
  327. package/dist/components/group-system-access/index.js +0 -19
  328. package/dist/components/group-system-access/index.js.map +0 -1
  329. package/dist/components/index.d.ts +0 -18
  330. package/dist/components/index.d.ts.map +0 -1
  331. package/dist/components/index.js +0 -34
  332. package/dist/components/index.js.map +0 -1
  333. package/dist/components/login-history/index.d.ts +0 -2
  334. package/dist/components/login-history/index.d.ts.map +0 -1
  335. package/dist/components/login-history/index.js +0 -18
  336. package/dist/components/login-history/index.js.map +0 -1
  337. package/dist/components/login-history/login-history.repository.d.ts +0 -6
  338. package/dist/components/login-history/login-history.repository.d.ts.map +0 -1
  339. package/dist/components/login-history/login-history.repository.js +0 -15
  340. package/dist/components/login-history/login-history.repository.js.map +0 -1
  341. package/dist/components/login-user/index.d.ts +0 -5
  342. package/dist/components/login-user/index.d.ts.map +0 -1
  343. package/dist/components/login-user/index.js +0 -21
  344. package/dist/components/login-user/index.js.map +0 -1
  345. package/dist/components/login-user/interfaces/check-user-info-duplicated.interface.d.ts +0 -8
  346. package/dist/components/login-user/interfaces/check-user-info-duplicated.interface.d.ts.map +0 -1
  347. package/dist/components/login-user/interfaces/check-user-info-duplicated.interface.js +0 -3
  348. package/dist/components/login-user/interfaces/check-user-info-duplicated.interface.js.map +0 -1
  349. package/dist/components/login-user/interfaces/index.d.ts +0 -2
  350. package/dist/components/login-user/interfaces/index.d.ts.map +0 -1
  351. package/dist/components/login-user/interfaces/index.js +0 -18
  352. package/dist/components/login-user/interfaces/index.js.map +0 -1
  353. package/dist/components/login-user/interfaces/system-access.interface.d.ts +0 -14
  354. package/dist/components/login-user/interfaces/system-access.interface.d.ts.map +0 -1
  355. package/dist/components/login-user/interfaces/system-access.interface.js +0 -3
  356. package/dist/components/login-user/interfaces/system-access.interface.js.map +0 -1
  357. package/dist/components/login-user/interfaces/user-info.interface.d.ts +0 -31
  358. package/dist/components/login-user/interfaces/user-info.interface.d.ts.map +0 -1
  359. package/dist/components/login-user/interfaces/user-info.interface.js +0 -3
  360. package/dist/components/login-user/interfaces/user-info.interface.js.map +0 -1
  361. package/dist/components/login-user/login-user.d.ts +0 -14
  362. package/dist/components/login-user/login-user.d.ts.map +0 -1
  363. package/dist/components/login-user/login-user.js +0 -127
  364. package/dist/components/login-user/login-user.js.map +0 -1
  365. package/dist/components/login-user/user.d.ts +0 -155
  366. package/dist/components/login-user/user.d.ts.map +0 -1
  367. package/dist/components/login-user/user.js +0 -1753
  368. package/dist/components/login-user/user.js.map +0 -1
  369. package/dist/components/login-user/user.repository.d.ts +0 -6
  370. package/dist/components/login-user/user.repository.d.ts.map +0 -1
  371. package/dist/components/login-user/user.repository.js +0 -15
  372. package/dist/components/login-user/user.repository.js.map +0 -1
  373. package/dist/components/password-hash/index.d.ts +0 -3
  374. package/dist/components/password-hash/index.d.ts.map +0 -1
  375. package/dist/components/password-hash/index.js +0 -19
  376. package/dist/components/password-hash/index.js.map +0 -1
  377. package/dist/components/password-hash/interfaces/index.d.ts +0 -2
  378. package/dist/components/password-hash/interfaces/index.d.ts.map +0 -1
  379. package/dist/components/password-hash/interfaces/index.js +0 -18
  380. package/dist/components/password-hash/interfaces/index.js.map +0 -1
  381. package/dist/components/password-hash/interfaces/password-hash-service.interface.d.ts +0 -5
  382. package/dist/components/password-hash/interfaces/password-hash-service.interface.d.ts.map +0 -1
  383. package/dist/components/password-hash/interfaces/password-hash-service.interface.js +0 -3
  384. package/dist/components/password-hash/interfaces/password-hash-service.interface.js.map +0 -1
  385. package/dist/components/password-hash/password-hash.service.d.ts +0 -7
  386. package/dist/components/password-hash/password-hash.service.d.ts.map +0 -1
  387. package/dist/components/password-hash/password-hash.service.js +0 -48
  388. package/dist/components/password-hash/password-hash.service.js.map +0 -1
  389. package/dist/components/staff/index.d.ts +0 -2
  390. package/dist/components/staff/index.d.ts.map +0 -1
  391. package/dist/components/staff/index.js +0 -18
  392. package/dist/components/staff/index.js.map +0 -1
  393. package/dist/components/staff/staff.repository.d.ts +0 -7
  394. package/dist/components/staff/staff.repository.d.ts.map +0 -1
  395. package/dist/components/staff/staff.repository.js +0 -30
  396. package/dist/components/staff/staff.repository.js.map +0 -1
  397. package/dist/components/system/index.d.ts +0 -3
  398. package/dist/components/system/index.d.ts.map +0 -1
  399. package/dist/components/system/index.js +0 -19
  400. package/dist/components/system/index.js.map +0 -1
  401. package/dist/components/system/system.d.ts +0 -40
  402. package/dist/components/system/system.d.ts.map +0 -1
  403. package/dist/components/system/system.js +0 -283
  404. package/dist/components/system/system.js.map +0 -1
  405. package/dist/components/system/system.repository.d.ts +0 -6
  406. package/dist/components/system/system.repository.d.ts.map +0 -1
  407. package/dist/components/system/system.repository.js +0 -15
  408. package/dist/components/system/system.repository.js.map +0 -1
  409. package/dist/components/system-privilege/index.d.ts +0 -4
  410. package/dist/components/system-privilege/index.d.ts.map +0 -1
  411. package/dist/components/system-privilege/index.js +0 -8
  412. package/dist/components/system-privilege/index.js.map +0 -1
  413. package/dist/components/system-privilege/system-privilege.d.ts +0 -53
  414. package/dist/components/system-privilege/system-privilege.d.ts.map +0 -1
  415. package/dist/components/system-privilege/system-privilege.js +0 -315
  416. package/dist/components/system-privilege/system-privilege.js.map +0 -1
  417. package/dist/components/system-privilege/system-privilege.repository.d.ts +0 -7
  418. package/dist/components/system-privilege/system-privilege.repository.d.ts.map +0 -1
  419. package/dist/components/system-privilege/system-privilege.repository.js +0 -21
  420. package/dist/components/system-privilege/system-privilege.repository.js.map +0 -1
  421. package/dist/components/user-group/index.d.ts +0 -3
  422. package/dist/components/user-group/index.d.ts.map +0 -1
  423. package/dist/components/user-group/index.js +0 -19
  424. package/dist/components/user-group/index.js.map +0 -1
  425. package/dist/components/user-group/user-group.d.ts +0 -51
  426. package/dist/components/user-group/user-group.d.ts.map +0 -1
  427. package/dist/components/user-group/user-group.js +0 -335
  428. package/dist/components/user-group/user-group.js.map +0 -1
  429. package/dist/components/user-group/user-group.repository.d.ts +0 -6
  430. package/dist/components/user-group/user-group.repository.d.ts.map +0 -1
  431. package/dist/components/user-group/user-group.repository.js +0 -15
  432. package/dist/components/user-group/user-group.repository.js.map +0 -1
  433. package/dist/components/user-object-privilege/index.d.ts +0 -3
  434. package/dist/components/user-object-privilege/index.d.ts.map +0 -1
  435. package/dist/components/user-object-privilege/index.js +0 -19
  436. package/dist/components/user-object-privilege/index.js.map +0 -1
  437. package/dist/components/user-object-privilege/user-object-privilege.d.ts +0 -24
  438. package/dist/components/user-object-privilege/user-object-privilege.d.ts.map +0 -1
  439. package/dist/components/user-object-privilege/user-object-privilege.js +0 -59
  440. package/dist/components/user-object-privilege/user-object-privilege.js.map +0 -1
  441. package/dist/components/user-object-privilege/user-object-privilege.repository.d.ts +0 -6
  442. package/dist/components/user-object-privilege/user-object-privilege.repository.d.ts.map +0 -1
  443. package/dist/components/user-object-privilege/user-object-privilege.repository.js +0 -15
  444. package/dist/components/user-object-privilege/user-object-privilege.repository.js.map +0 -1
  445. package/dist/components/user-privilege/index.d.ts +0 -3
  446. package/dist/components/user-privilege/index.d.ts.map +0 -1
  447. package/dist/components/user-privilege/index.js +0 -19
  448. package/dist/components/user-privilege/index.js.map +0 -1
  449. package/dist/components/user-privilege/user-privilege.d.ts +0 -71
  450. package/dist/components/user-privilege/user-privilege.d.ts.map +0 -1
  451. package/dist/components/user-privilege/user-privilege.js +0 -388
  452. package/dist/components/user-privilege/user-privilege.js.map +0 -1
  453. package/dist/components/user-privilege/user-privilege.repository.d.ts +0 -7
  454. package/dist/components/user-privilege/user-privilege.repository.d.ts.map +0 -1
  455. package/dist/components/user-privilege/user-privilege.repository.js +0 -29
  456. package/dist/components/user-privilege/user-privilege.repository.js.map +0 -1
  457. package/dist/components/user-system-access/index.d.ts +0 -3
  458. package/dist/components/user-system-access/index.d.ts.map +0 -1
  459. package/dist/components/user-system-access/index.js +0 -19
  460. package/dist/components/user-system-access/index.js.map +0 -1
  461. package/dist/components/user-system-access/user-system-access.d.ts +0 -69
  462. package/dist/components/user-system-access/user-system-access.d.ts.map +0 -1
  463. package/dist/components/user-system-access/user-system-access.js +0 -413
  464. package/dist/components/user-system-access/user-system-access.js.map +0 -1
  465. package/dist/components/user-system-access/user-system-access.repository.d.ts +0 -8
  466. package/dist/components/user-system-access/user-system-access.repository.d.ts.map +0 -1
  467. package/dist/components/user-system-access/user-system-access.repository.js +0 -44
  468. package/dist/components/user-system-access/user-system-access.repository.js.map +0 -1
  469. package/dist/database.d.ts +0 -5
  470. package/dist/database.d.ts.map +0 -1
  471. package/dist/database.js +0 -14
  472. package/dist/database.js.map +0 -1
  473. package/dist/enum/api-key.enum.d.ts +0 -6
  474. package/dist/enum/api-key.enum.d.ts.map +0 -1
  475. package/dist/enum/api-key.enum.js +0 -10
  476. package/dist/enum/api-key.enum.js.map +0 -1
  477. package/dist/enum/group-type.enum.d.ts +0 -9
  478. package/dist/enum/group-type.enum.d.ts.map +0 -1
  479. package/dist/enum/group-type.enum.js +0 -13
  480. package/dist/enum/group-type.enum.js.map +0 -1
  481. package/dist/enum/index.d.ts +0 -7
  482. package/dist/enum/index.d.ts.map +0 -1
  483. package/dist/enum/index.js +0 -23
  484. package/dist/enum/index.js.map +0 -1
  485. package/dist/enum/login-status.enum.d.ts +0 -5
  486. package/dist/enum/login-status.enum.d.ts.map +0 -1
  487. package/dist/enum/login-status.enum.js +0 -9
  488. package/dist/enum/login-status.enum.js.map +0 -1
  489. package/dist/enum/object-status.enum.d.ts +0 -5
  490. package/dist/enum/object-status.enum.d.ts.map +0 -1
  491. package/dist/enum/object-status.enum.js +0 -9
  492. package/dist/enum/object-status.enum.js.map +0 -1
  493. package/dist/enum/user-status.enum.d.ts +0 -8
  494. package/dist/enum/user-status.enum.d.ts.map +0 -1
  495. package/dist/enum/user-status.enum.js +0 -12
  496. package/dist/enum/user-status.enum.js.map +0 -1
  497. package/dist/enum/yn.enum.d.ts +0 -5
  498. package/dist/enum/yn.enum.d.ts.map +0 -1
  499. package/dist/enum/yn.enum.js +0 -9
  500. package/dist/enum/yn.enum.js.map +0 -1
  501. package/dist/index.d.ts.map +0 -1
  502. package/dist/interfaces/api-key-attr.interface.d.ts +0 -16
  503. package/dist/interfaces/api-key-attr.interface.d.ts.map +0 -1
  504. package/dist/interfaces/api-key-attr.interface.js +0 -3
  505. package/dist/interfaces/api-key-attr.interface.js.map +0 -1
  506. package/dist/interfaces/group-object-privilege.interface.d.ts +0 -14
  507. package/dist/interfaces/group-object-privilege.interface.d.ts.map +0 -1
  508. package/dist/interfaces/group-object-privilege.interface.js +0 -3
  509. package/dist/interfaces/group-object-privilege.interface.js.map +0 -1
  510. package/dist/interfaces/group-privilege.interface.d.ts +0 -11
  511. package/dist/interfaces/group-privilege.interface.d.ts.map +0 -1
  512. package/dist/interfaces/group-privilege.interface.js +0 -3
  513. package/dist/interfaces/group-privilege.interface.js.map +0 -1
  514. package/dist/interfaces/group-reporting-user.interface.d.ts +0 -12
  515. package/dist/interfaces/group-reporting-user.interface.d.ts.map +0 -1
  516. package/dist/interfaces/group-reporting-user.interface.js +0 -3
  517. package/dist/interfaces/group-reporting-user.interface.js.map +0 -1
  518. package/dist/interfaces/group-search-attr.interface.d.ts +0 -9
  519. package/dist/interfaces/group-search-attr.interface.d.ts.map +0 -1
  520. package/dist/interfaces/group-search-attr.interface.js +0 -3
  521. package/dist/interfaces/group-search-attr.interface.js.map +0 -1
  522. package/dist/interfaces/group-system-access.interface.d.ts +0 -11
  523. package/dist/interfaces/group-system-access.interface.d.ts.map +0 -1
  524. package/dist/interfaces/group-system-access.interface.js +0 -3
  525. package/dist/interfaces/group-system-access.interface.js.map +0 -1
  526. package/dist/interfaces/group.interface.d.ts +0 -17
  527. package/dist/interfaces/group.interface.d.ts.map +0 -1
  528. package/dist/interfaces/group.interface.js +0 -3
  529. package/dist/interfaces/group.interface.js.map +0 -1
  530. package/dist/interfaces/index.d.ts +0 -14
  531. package/dist/interfaces/index.d.ts.map +0 -1
  532. package/dist/interfaces/index.js +0 -30
  533. package/dist/interfaces/index.js.map +0 -1
  534. package/dist/interfaces/system-login.interface.d.ts +0 -7
  535. package/dist/interfaces/system-login.interface.d.ts.map +0 -1
  536. package/dist/interfaces/system-login.interface.js +0 -3
  537. package/dist/interfaces/system-login.interface.js.map +0 -1
  538. package/dist/interfaces/system-privilege-search.interface.d.ts +0 -6
  539. package/dist/interfaces/system-privilege-search.interface.d.ts.map +0 -1
  540. package/dist/interfaces/system-privilege-search.interface.js +0 -3
  541. package/dist/interfaces/system-privilege-search.interface.js.map +0 -1
  542. package/dist/interfaces/system-privilege.interface.d.ts +0 -12
  543. package/dist/interfaces/system-privilege.interface.d.ts.map +0 -1
  544. package/dist/interfaces/system-privilege.interface.js +0 -3
  545. package/dist/interfaces/system-privilege.interface.js.map +0 -1
  546. package/dist/interfaces/system-search-attr.interface.d.ts +0 -6
  547. package/dist/interfaces/system-search-attr.interface.d.ts.map +0 -1
  548. package/dist/interfaces/system-search-attr.interface.js +0 -3
  549. package/dist/interfaces/system-search-attr.interface.js.map +0 -1
  550. package/dist/interfaces/system.interface.d.ts +0 -16
  551. package/dist/interfaces/system.interface.d.ts.map +0 -1
  552. package/dist/interfaces/system.interface.js +0 -3
  553. package/dist/interfaces/system.interface.js.map +0 -1
  554. package/dist/interfaces/user-group.interface.d.ts +0 -13
  555. package/dist/interfaces/user-group.interface.d.ts.map +0 -1
  556. package/dist/interfaces/user-group.interface.js +0 -3
  557. package/dist/interfaces/user-group.interface.js.map +0 -1
  558. package/dist/interfaces/user-object-privilege.interface.d.ts +0 -14
  559. package/dist/interfaces/user-object-privilege.interface.d.ts.map +0 -1
  560. package/dist/interfaces/user-object-privilege.interface.js +0 -3
  561. package/dist/interfaces/user-object-privilege.interface.js.map +0 -1
  562. package/dist/interfaces/user-privilege.interface.d.ts +0 -11
  563. package/dist/interfaces/user-privilege.interface.d.ts.map +0 -1
  564. package/dist/interfaces/user-privilege.interface.js +0 -3
  565. package/dist/interfaces/user-privilege.interface.js.map +0 -1
  566. package/dist/interfaces/user-session.interface.d.ts +0 -5
  567. package/dist/interfaces/user-session.interface.d.ts.map +0 -1
  568. package/dist/interfaces/user-session.interface.js +0 -3
  569. package/dist/interfaces/user-session.interface.js.map +0 -1
  570. package/dist/interfaces/user-system-access.interface.d.ts +0 -11
  571. package/dist/interfaces/user-system-access.interface.d.ts.map +0 -1
  572. package/dist/interfaces/user-system-access.interface.js +0 -3
  573. package/dist/interfaces/user-system-access.interface.js.map +0 -1
  574. package/dist/models/api-key-entity.d.ts +0 -22
  575. package/dist/models/api-key-entity.d.ts.map +0 -1
  576. package/dist/models/api-key-entity.js +0 -125
  577. package/dist/models/api-key-entity.js.map +0 -1
  578. package/dist/models/building.entity.d.ts +0 -30
  579. package/dist/models/building.entity.d.ts.map +0 -1
  580. package/dist/models/building.entity.js +0 -216
  581. package/dist/models/building.entity.js.map +0 -1
  582. package/dist/models/group-object-privilege.entity.d.ts +0 -22
  583. package/dist/models/group-object-privilege.entity.d.ts.map +0 -1
  584. package/dist/models/group-object-privilege.entity.js +0 -114
  585. package/dist/models/group-object-privilege.entity.js.map +0 -1
  586. package/dist/models/group-privilege.entity.d.ts +0 -19
  587. package/dist/models/group-privilege.entity.d.ts.map +0 -1
  588. package/dist/models/group-privilege.entity.js +0 -99
  589. package/dist/models/group-privilege.entity.js.map +0 -1
  590. package/dist/models/group-reporting-user.entity.d.ts +0 -18
  591. package/dist/models/group-reporting-user.entity.d.ts.map +0 -1
  592. package/dist/models/group-reporting-user.entity.js +0 -117
  593. package/dist/models/group-reporting-user.entity.js.map +0 -1
  594. package/dist/models/group-system-access.entity.d.ts +0 -19
  595. package/dist/models/group-system-access.entity.d.ts.map +0 -1
  596. package/dist/models/group-system-access.entity.js +0 -102
  597. package/dist/models/group-system-access.entity.js.map +0 -1
  598. package/dist/models/group.entity.d.ts +0 -33
  599. package/dist/models/group.entity.d.ts.map +0 -1
  600. package/dist/models/group.entity.js +0 -157
  601. package/dist/models/group.entity.js.map +0 -1
  602. package/dist/models/login-history.entity.d.ts +0 -15
  603. package/dist/models/login-history.entity.d.ts.map +0 -1
  604. package/dist/models/login-history.entity.js +0 -81
  605. package/dist/models/login-history.entity.js.map +0 -1
  606. package/dist/models/staff.entity.d.ts +0 -19
  607. package/dist/models/staff.entity.d.ts.map +0 -1
  608. package/dist/models/staff.entity.js +0 -113
  609. package/dist/models/staff.entity.js.map +0 -1
  610. package/dist/models/system-privilege.entity.d.ts +0 -19
  611. package/dist/models/system-privilege.entity.d.ts.map +0 -1
  612. package/dist/models/system-privilege.entity.js +0 -111
  613. package/dist/models/system-privilege.entity.js.map +0 -1
  614. package/dist/models/system.entity.d.ts +0 -26
  615. package/dist/models/system.entity.d.ts.map +0 -1
  616. package/dist/models/system.entity.js +0 -139
  617. package/dist/models/system.entity.js.map +0 -1
  618. package/dist/models/user-group.entity.d.ts +0 -20
  619. package/dist/models/user-group.entity.d.ts.map +0 -1
  620. package/dist/models/user-group.entity.js +0 -114
  621. package/dist/models/user-group.entity.js.map +0 -1
  622. package/dist/models/user-object-privilege.entity.d.ts +0 -21
  623. package/dist/models/user-object-privilege.entity.d.ts.map +0 -1
  624. package/dist/models/user-object-privilege.entity.js +0 -113
  625. package/dist/models/user-object-privilege.entity.js.map +0 -1
  626. package/dist/models/user-privilege.entity.d.ts +0 -18
  627. package/dist/models/user-privilege.entity.d.ts.map +0 -1
  628. package/dist/models/user-privilege.entity.js +0 -99
  629. package/dist/models/user-privilege.entity.js.map +0 -1
  630. package/dist/models/user-system-access.entity.d.ts +0 -18
  631. package/dist/models/user-system-access.entity.d.ts.map +0 -1
  632. package/dist/models/user-system-access.entity.js +0 -108
  633. package/dist/models/user-system-access.entity.js.map +0 -1
  634. package/dist/models/user.entity.d.ts +0 -41
  635. package/dist/models/user.entity.d.ts.map +0 -1
  636. package/dist/models/user.entity.js +0 -218
  637. package/dist/models/user.entity.js.map +0 -1
  638. package/dist/redis-client/__mocks__/jest-initial-setup.d.ts +0 -2
  639. package/dist/redis-client/__mocks__/jest-initial-setup.d.ts.map +0 -1
  640. package/dist/redis-client/__mocks__/jest-initial-setup.js +0 -8
  641. package/dist/redis-client/__mocks__/jest-initial-setup.js.map +0 -1
  642. package/dist/redis-client/__mocks__/redis-mock.d.ts +0 -3
  643. package/dist/redis-client/__mocks__/redis-mock.d.ts.map +0 -1
  644. package/dist/redis-client/__mocks__/redis-mock.js +0 -56
  645. package/dist/redis-client/__mocks__/redis-mock.js.map +0 -1
  646. package/dist/redis-client/index.d.ts +0 -2
  647. package/dist/redis-client/index.d.ts.map +0 -1
  648. package/dist/redis-client/index.js +0 -18
  649. package/dist/redis-client/index.js.map +0 -1
  650. package/dist/redis-client/redis.service.d.ts +0 -10
  651. package/dist/redis-client/redis.service.d.ts.map +0 -1
  652. package/dist/redis-client/redis.service.js +0 -69
  653. package/dist/redis-client/redis.service.js.map +0 -1
  654. package/dist/session/index.d.ts +0 -3
  655. package/dist/session/index.d.ts.map +0 -1
  656. package/dist/session/index.js +0 -19
  657. package/dist/session/index.js.map +0 -1
  658. package/dist/session/interfaces/index.d.ts +0 -2
  659. package/dist/session/interfaces/index.d.ts.map +0 -1
  660. package/dist/session/interfaces/index.js +0 -18
  661. package/dist/session/interfaces/index.js.map +0 -1
  662. package/dist/session/interfaces/session-service.interface.d.ts +0 -10
  663. package/dist/session/interfaces/session-service.interface.d.ts.map +0 -1
  664. package/dist/session/interfaces/session-service.interface.js +0 -3
  665. package/dist/session/interfaces/session-service.interface.js.map +0 -1
  666. package/dist/session/session.service.d.ts +0 -14
  667. package/dist/session/session.service.d.ts.map +0 -1
  668. package/dist/session/session.service.js +0 -73
  669. package/dist/session/session.service.js.map +0 -1
  670. package/dist/types/auth-context.d.ts +0 -7
  671. package/dist/types/auth-context.d.ts.map +0 -1
  672. package/dist/types/auth-context.js +0 -3
  673. package/dist/types/auth-context.js.map +0 -1
  674. package/dist/types/index.d.ts +0 -2
  675. package/dist/types/index.d.ts.map +0 -1
  676. package/dist/types/index.js +0 -18
  677. package/dist/types/index.js.map +0 -1
@@ -1,1337 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Group = void 0;
7
- const general_1 = require("@tomei/general");
8
- const group_repository_1 = require("./group.repository");
9
- const config_1 = require("@tomei/config");
10
- const sequelize_1 = require("sequelize");
11
- const activity_history_1 = require("@tomei/activity-history");
12
- const group_system_access_repository_1 = require("../group-system-access/group-system-access.repository");
13
- const system_entity_1 = __importDefault(require("../../models/system.entity"));
14
- const group_system_access_1 = require("../group-system-access");
15
- const redis_service_1 = require("../../redis-client/redis.service");
16
- const system_privilege_entity_1 = __importDefault(require("../../models/system-privilege.entity"));
17
- const group_privilege_repository_1 = require("../group-privilege/group-privilege.repository");
18
- const system_privilege_1 = require("../system-privilege/system-privilege");
19
- const group_privilege_entity_1 = __importDefault(require("../../models/group-privilege.entity"));
20
- const group_object_privilege_repository_1 = require("../group-object-privilege/group-object-privilege.repository");
21
- const group_object_privilege_1 = require("../group-object-privilege/group-object-privilege");
22
- const group_privilege_1 = require("../group-privilege/group-privilege");
23
- const group_reporting_user_entity_1 = __importDefault(require("../../models/group-reporting-user.entity"));
24
- const group_entity_1 = __importDefault(require("../../models/group.entity"));
25
- const user_entity_1 = __importDefault(require("../../models/user.entity"));
26
- class Group extends general_1.TreeNodeBase {
27
- get GroupCode() {
28
- return this.ObjectId;
29
- }
30
- set GroupCode(value) {
31
- this.ObjectId = value;
32
- }
33
- get CreatedById() {
34
- return this._CreatedById;
35
- }
36
- get CreatedAt() {
37
- return this._CreatedAt;
38
- }
39
- get UpdatedById() {
40
- return this._UpdatedById;
41
- }
42
- get UpdatedAt() {
43
- return this._UpdatedAt;
44
- }
45
- get Path() {
46
- return this._Path;
47
- }
48
- set Path(value) {
49
- this._Path = value;
50
- }
51
- constructor(groupAttr) {
52
- super();
53
- this.ObjectType = 'Group';
54
- this._Path = '';
55
- this.isChildrenLoaded = false;
56
- this.isParentLoaded = false;
57
- if (groupAttr) {
58
- this.GroupCode = groupAttr.GroupCode;
59
- this.Name = groupAttr.Name;
60
- this.Description = groupAttr?.Description;
61
- this.Type = groupAttr?.Type;
62
- this.ParentGroupCode = groupAttr?.ParentGroupCode;
63
- this.InheritParentPrivilegeYN = groupAttr?.InheritParentPrivilegeYN;
64
- this.InheritParentSystemAccessYN = groupAttr?.InheritParentSystemAccessYN;
65
- this.Status = groupAttr?.Status;
66
- this._Path = groupAttr?.Path;
67
- this._CreatedById = groupAttr.CreatedById;
68
- this._CreatedAt = groupAttr.CreatedAt;
69
- this._UpdatedById = groupAttr.UpdatedById;
70
- this._UpdatedAt = groupAttr.UpdatedAt;
71
- }
72
- }
73
- static async init(dbTransaction, GroupCode) {
74
- try {
75
- Group._RedisService = await redis_service_1.RedisService.init();
76
- if (GroupCode) {
77
- const group = await Group._Repo.findByPk(GroupCode, {
78
- transaction: dbTransaction,
79
- });
80
- if (group) {
81
- return new Group(group);
82
- }
83
- else {
84
- throw Error('Group not found');
85
- }
86
- }
87
- return new Group();
88
- }
89
- catch (error) {
90
- throw new general_1.ClassError('Group', 'GroupErrMsg01', 'Failed To Initialize Group');
91
- }
92
- }
93
- async loadChildren(dbTransaction) {
94
- if (!this.GroupCode) {
95
- throw Error('GroupCode is missing.');
96
- }
97
- const children = await Group._Repo.findAll({
98
- where: { ParentGroupCode: this.GroupCode },
99
- order: [['CreatedAt', 'ASC']],
100
- transaction: dbTransaction,
101
- });
102
- this.children = children.map((child) => {
103
- return new Group(child.get({ plain: true }));
104
- });
105
- this.isChildrenLoaded = true;
106
- }
107
- async loadParent(dbTransaction) {
108
- if (!this.GroupCode) {
109
- throw Error('GroupCode are missing.');
110
- }
111
- if (this.ParentGroupCode) {
112
- if (this.ParentGroupCode !== this.GroupCode) {
113
- const parent = await Group._Repo.findByPk(this.ParentGroupCode, {
114
- transaction: dbTransaction,
115
- });
116
- this.parent = new Group(parent.get({ plain: true }));
117
- }
118
- }
119
- this.isParentLoaded = true;
120
- }
121
- async isLeaf(dbTransaction) {
122
- if (!this.isChildrenLoaded) {
123
- await this.loadChildren(dbTransaction);
124
- }
125
- return this.children.length === 0;
126
- }
127
- async getPath(dbTransaction) {
128
- if (!this.isParentLoaded) {
129
- await this.loadParent(dbTransaction);
130
- }
131
- if (this.parent) {
132
- this._Path =
133
- (await this.parent.getPath(dbTransaction)) + '/' + this.GroupCode;
134
- return this._Path;
135
- }
136
- this._Path = this.GroupCode;
137
- return this._Path;
138
- }
139
- async updatePath(dbTransaction) {
140
- const path = await this.getPath(dbTransaction);
141
- this._Path = path;
142
- }
143
- async setParent(parent, dbTransaction) {
144
- this.parent = parent;
145
- await this.updatePath(dbTransaction);
146
- }
147
- async getPathDetail(dbTransaction) {
148
- const path = this._Path.split('/');
149
- const groups = [];
150
- for (let i = 0; i < path.length; i++) {
151
- const group = await Group.init(dbTransaction, path[i]);
152
- groups.push(group);
153
- }
154
- return groups;
155
- }
156
- static async findAll(page, row, dbTransaction, loginUser, search) {
157
- const systemCode = config_1.ApplicationConfig.getComponentConfigValue('system-code');
158
- const isPrivileged = await loginUser.checkPrivileges(systemCode, 'GROUP_LIST');
159
- if (!isPrivileged) {
160
- throw new general_1.ClassError('Group', 'GroupErrMsg04', 'User is not privileged to list group');
161
- }
162
- const queryObj = {};
163
- let options = {
164
- transaction: dbTransaction,
165
- };
166
- if (page && row) {
167
- options = {
168
- ...options,
169
- limit: row,
170
- offset: row * (page - 1),
171
- order: [['CreatedAt', 'DESC']],
172
- };
173
- }
174
- if (search) {
175
- Object.entries(search).forEach(([key, value]) => {
176
- queryObj[key] = {
177
- [sequelize_1.Op.substring]: value,
178
- };
179
- });
180
- options = {
181
- ...options,
182
- where: queryObj,
183
- };
184
- const result = await Group._Repo.findAllWithPagination(options);
185
- return {
186
- Count: result.count,
187
- Groups: result.rows.map((group) => new Group(group.get({ plain: true }))),
188
- };
189
- }
190
- }
191
- static async create(loginUser, dbTransaction, group) {
192
- try {
193
- const systemCode = config_1.ApplicationConfig.getComponentConfigValue('system-code');
194
- const isPrivileged = await loginUser.checkPrivileges(systemCode, 'GROUP_CREATE');
195
- if (!isPrivileged) {
196
- throw new Error('You do not have permission to create group');
197
- }
198
- if (!group.GroupCode) {
199
- throw new general_1.ClassError('Group', 'GroupErrMsg02', 'Group Code is required');
200
- }
201
- if (!group.Name) {
202
- throw new general_1.ClassError('Group', 'GroupErrMsg02', 'Group Name is required');
203
- }
204
- if (!group.Type) {
205
- throw new general_1.ClassError('Group', 'GroupErrMsg02', 'Group Type is required');
206
- }
207
- const existingGroupCode = await Group._Repo.findByPk(group.GroupCode, {
208
- transaction: dbTransaction,
209
- });
210
- if (existingGroupCode) {
211
- throw new general_1.ClassError('Group', 'GroupErrMsg03', 'Duplicate GroupCode found.');
212
- }
213
- if (group.ParentGroupCode) {
214
- const parentGroup = await Group._Repo.findByPk(group.ParentGroupCode, {
215
- transaction: dbTransaction,
216
- });
217
- if (!parentGroup) {
218
- throw new general_1.ClassError('Group', 'GroupErrMsg04', 'ParentGroupCode is not found.');
219
- }
220
- if (group.GroupCode === group.ParentGroupCode) {
221
- throw new general_1.ClassError('Group', 'GroupErrMsg05', 'GroupCode and ParentGroupCode cannot be the same.');
222
- }
223
- }
224
- const newGroup = new Group(group);
225
- newGroup.ObjectId = group.GroupCode;
226
- newGroup.Name = group.Name;
227
- newGroup.Type = group.Type;
228
- newGroup.Description = group.Description;
229
- newGroup.ParentGroupCode = group.ParentGroupCode;
230
- newGroup.InheritParentPrivilegeYN = group.InheritParentPrivilegeYN;
231
- newGroup.InheritParentSystemAccessYN = group.InheritParentSystemAccessYN;
232
- newGroup.Status = 'Active';
233
- newGroup._CreatedById = loginUser.UserId;
234
- newGroup._UpdatedById = loginUser.UserId;
235
- newGroup._Path = await newGroup.getPath(dbTransaction);
236
- const entityGroupAfter = {
237
- GroupCode: newGroup.ObjectId,
238
- Name: newGroup.Name,
239
- Type: newGroup.Type,
240
- Description: newGroup.Description,
241
- ParentGroupCode: newGroup.ParentGroupCode,
242
- InheritParentPrivilegeYN: newGroup.InheritParentPrivilegeYN,
243
- InheritParentSystemAccessYN: newGroup.InheritParentSystemAccessYN,
244
- Path: newGroup._Path,
245
- Status: newGroup.Status,
246
- CreatedById: newGroup._CreatedById,
247
- UpdatedById: newGroup._UpdatedById,
248
- CreatedAt: newGroup._CreatedAt,
249
- UpdatedAt: newGroup._UpdatedAt,
250
- };
251
- await Group._Repo.create(entityGroupAfter, {
252
- transaction: dbTransaction,
253
- });
254
- const entityValueBefore = {};
255
- const activity = new activity_history_1.Activity();
256
- activity.ActivityId = activity.createId();
257
- activity.Action = activity_history_1.ActionEnum.CREATE;
258
- activity.Description = 'Create Group';
259
- activity.EntityType = 'Group';
260
- activity.EntityId = newGroup.ObjectId;
261
- activity.EntityValueBefore = JSON.stringify(entityValueBefore);
262
- activity.EntityValueAfter = JSON.stringify(entityGroupAfter);
263
- await activity.create(loginUser.ObjectId, dbTransaction);
264
- return newGroup;
265
- }
266
- catch (error) {
267
- throw error;
268
- }
269
- }
270
- static async checkDuplicateGroupCode(dbTransaction, GroupCode) {
271
- const isGroupCodeExist = await Group._Repo.findOne({
272
- where: { GroupCode },
273
- transaction: dbTransaction,
274
- });
275
- if (isGroupCodeExist) {
276
- throw new general_1.ClassError('Group', 'GroupErrMsg07', 'GroupCode already exists.');
277
- }
278
- }
279
- async updateChildrenPath(oldGroupCode, dbTransaction) {
280
- try {
281
- const isLeaf = await this.isLeaf(dbTransaction);
282
- if (isLeaf) {
283
- return;
284
- }
285
- const childrens = await Group._Repo.findAll({
286
- where: {
287
- Path: {
288
- [sequelize_1.Op.like]: `${oldGroupCode}/%`,
289
- },
290
- },
291
- transaction: dbTransaction,
292
- });
293
- childrens.forEach(async (children) => {
294
- const path = children.Path.split(`${oldGroupCode}/`);
295
- const childPath = path[1];
296
- await children.update({ Path: `${this._Path}/${childPath}` }, { transaction: dbTransaction });
297
- });
298
- }
299
- catch (error) {
300
- throw error;
301
- }
302
- }
303
- async update(loginUser, dbTransaction, group) {
304
- const systemCode = config_1.ApplicationConfig.getComponentConfigValue('system-code');
305
- const isPrivileged = await loginUser.checkPrivileges(systemCode, 'GROUP_UPDATE');
306
- if (!isPrivileged) {
307
- throw new general_1.ClassError('Group', 'GroupErrMsg06', 'You do not have the privilege to update Group');
308
- }
309
- try {
310
- if (group.NewGroupCode) {
311
- await Group.checkDuplicateGroupCode(dbTransaction, group.NewGroupCode);
312
- }
313
- const entityValueBefore = {
314
- GroupCode: this.GroupCode,
315
- Name: this.Name,
316
- Type: this.Type,
317
- Description: this.Description,
318
- ParentGroupCode: this.ParentGroupCode,
319
- InheritParentPrivilegeYN: this.InheritParentPrivilegeYN,
320
- InheritParentSystemAccessYN: this.InheritParentSystemAccessYN,
321
- Path: this.Path,
322
- Status: this.Status,
323
- CreatedById: this._CreatedById,
324
- UpdatedById: this._UpdatedById,
325
- CreatedAt: this._CreatedAt,
326
- UpdatedAt: this._UpdatedAt,
327
- };
328
- let isPathChanged = false;
329
- const oldGroupCode = this.GroupCode;
330
- if (group.NewGroupCode) {
331
- this.GroupCode = group.NewGroupCode;
332
- isPathChanged = true;
333
- }
334
- if ((group.ParentGroupCode &&
335
- this.ParentGroupCode !== group.ParentGroupCode) ||
336
- (group.ParentGroupCode && !this.ParentGroupCode)) {
337
- const parentGroup = await Group.init(dbTransaction, group.ParentGroupCode);
338
- if (!parentGroup) {
339
- throw new general_1.ClassError('Group', 'GroupErrMsg08', 'Parent Group Code not found');
340
- }
341
- await this.setParent(parentGroup);
342
- isPathChanged = true;
343
- }
344
- else if (!group.ParentGroupCode && this.ParentGroupCode) {
345
- await this.setParent(null);
346
- isPathChanged = true;
347
- }
348
- if (isPathChanged) {
349
- await this.updateChildrenPath(oldGroupCode, dbTransaction);
350
- }
351
- this.Name = group?.Name || this.Name;
352
- this.Type = group?.Type || this.Type;
353
- this.Description = group?.Description || this.Description;
354
- this.ParentGroupCode = group?.ParentGroupCode || this.ParentGroupCode;
355
- this.InheritParentPrivilegeYN =
356
- group?.InheritParentPrivilegeYN || this.InheritParentPrivilegeYN;
357
- this.InheritParentSystemAccessYN =
358
- group?.InheritParentSystemAccessYN || this.InheritParentSystemAccessYN;
359
- this.Status = group?.Status || this.Status;
360
- this._UpdatedById = loginUser.UserId;
361
- this._UpdatedAt = new Date();
362
- await Group._Repo.update({
363
- GroupCode: this.GroupCode,
364
- Name: this.Name,
365
- Type: this.Type,
366
- Description: this.Description,
367
- ParentGroupCode: this.ParentGroupCode,
368
- InheritParentPrivilegeYN: this.InheritParentPrivilegeYN,
369
- InheritParentSystemAccessYN: this.InheritParentSystemAccessYN,
370
- Status: this.Status,
371
- Path: this._Path,
372
- UpdatedById: this._UpdatedById,
373
- UpdatedAt: this._UpdatedAt,
374
- }, {
375
- where: {
376
- GroupCode: group.GroupCode,
377
- },
378
- transaction: dbTransaction,
379
- });
380
- const entityValueAfter = {
381
- GroupCode: this.GroupCode,
382
- Name: this.Name,
383
- Type: this.Type,
384
- Description: this.Description,
385
- ParentGroupCode: this.ParentGroupCode,
386
- InheritParentPrivilegeYN: this.InheritParentPrivilegeYN,
387
- InheritParentSystemAccessYN: this.InheritParentSystemAccessYN,
388
- Status: this.Status,
389
- Path: this._Path,
390
- CreatedById: this._CreatedById,
391
- UpdatedById: this._UpdatedById,
392
- CreatedAt: this._CreatedAt,
393
- UpdatedAt: this._UpdatedAt,
394
- };
395
- const activity = new activity_history_1.Activity();
396
- activity.ActivityId = activity.createId();
397
- activity.Action = activity_history_1.ActionEnum.UPDATE;
398
- activity.Description = `Update Group ${group.Type}`;
399
- activity.EntityType = 'Group';
400
- activity.EntityId = group.GroupCode;
401
- activity.EntityValueBefore = JSON.stringify(entityValueBefore);
402
- activity.EntityValueAfter = JSON.stringify(entityValueAfter);
403
- await activity.create(loginUser.ObjectId, dbTransaction);
404
- return this;
405
- }
406
- catch (error) {
407
- throw error;
408
- }
409
- }
410
- static async delete(loginUser, dbTransaction, GroupCode) {
411
- const systemCode = config_1.ApplicationConfig.getComponentConfigValue('system-code');
412
- const isPrivileged = await loginUser.checkPrivileges(systemCode, 'GROUP_DELETE');
413
- if (!isPrivileged) {
414
- throw new general_1.ClassError('Group', 'GroupErrMsg03', 'You do not have the privilege to delete groups records.');
415
- }
416
- try {
417
- const group = await Group.init(dbTransaction, GroupCode);
418
- if (group.Status === 'Active') {
419
- throw new general_1.ClassError('Group', 'GroupErrMsg03', 'Active Group cant be deleted');
420
- }
421
- const relatedGroup = await Group.findAll(1, Number.MAX_SAFE_INTEGER, dbTransaction, loginUser, {
422
- ParentGroupCode: GroupCode,
423
- });
424
- if (relatedGroup.Count > 0) {
425
- const listOfRelatedGroup = relatedGroup.Groups.map((group) => {
426
- return group.GroupCode;
427
- });
428
- throw new general_1.ClassError('Group', 'GroupErrMsg03', `Group still has associated user group ${listOfRelatedGroup}`);
429
- }
430
- await Group._Repo.delete(GroupCode, dbTransaction);
431
- const EntityValueBefore = {
432
- GroupCode: group.GroupCode,
433
- Name: group.Name,
434
- Type: group.Type,
435
- Description: group.Description,
436
- ParentGroupCode: group.ParentGroupCode,
437
- InheritParentPrivilegeYN: group.InheritParentPrivilegeYN,
438
- InheritParentSystemAccessYN: group.InheritParentSystemAccessYN,
439
- Status: group.Status,
440
- CreatedById: group._CreatedById,
441
- UpdatedById: group._UpdatedById,
442
- CreatedAt: group._CreatedAt,
443
- UpdatedAt: group._UpdatedAt,
444
- };
445
- const activity = new activity_history_1.Activity();
446
- activity.ActivityId = activity.createId();
447
- activity.Action = activity_history_1.ActionEnum.DELETE;
448
- activity.Description = 'Delete Group';
449
- activity.EntityType = 'Group';
450
- activity.EntityId = group.ObjectId;
451
- activity.EntityValueBefore = JSON.stringify(EntityValueBefore);
452
- activity.EntityValueAfter = JSON.stringify({});
453
- await activity.create(loginUser.ObjectId, dbTransaction);
454
- return { Message: 'Group removed.' };
455
- }
456
- catch (error) {
457
- throw error;
458
- }
459
- }
460
- static async getSystemAccesses(loginUser, dbTransaction, GroupCode, Page, Rows, Search) {
461
- const systemCode = config_1.ApplicationConfig.getComponentConfigValue('system-code');
462
- const isPrivileged = await loginUser.checkPrivileges(systemCode, 'SYSTEM_ACCESS_VIEW');
463
- if (!isPrivileged) {
464
- throw new general_1.ClassError('Group', 'GroupErrMsg06', 'You do not have the privilege to view system access');
465
- }
466
- try {
467
- await Group.init(dbTransaction, GroupCode);
468
- const queryObj = { GroupCode: GroupCode };
469
- if (Search) {
470
- Object.entries(Search).forEach(([key, value]) => {
471
- queryObj[key] = value;
472
- });
473
- }
474
- let options = {
475
- where: queryObj,
476
- distinct: true,
477
- transaction: dbTransaction,
478
- };
479
- if (Page && Rows) {
480
- options = {
481
- ...options,
482
- limit: Rows,
483
- offset: Rows * (Page - 1),
484
- order: [['CreatedAt', 'DESC']],
485
- };
486
- }
487
- const systemAccess = await Group._GroupSystemAccessRepo.findAndCountAll(options);
488
- return systemAccess;
489
- }
490
- catch (error) {
491
- return error;
492
- }
493
- }
494
- static async getSystemAccessRoles(loginUser, dbTransaction, SystemCode, Page, Rows, Search) {
495
- const systemCode = config_1.ApplicationConfig.getComponentConfigValue('system-code');
496
- const isPrivileged = await loginUser.checkPrivileges(systemCode, 'SYSTEM_ACCESS_VIEW');
497
- if (!isPrivileged) {
498
- throw new general_1.ClassError('Group', 'GroupErrMsg06', 'You do not have the privilege to view system access');
499
- }
500
- try {
501
- const queryObj = { SystemCode: SystemCode };
502
- if (Search) {
503
- Object.entries(Search).forEach(([key, value]) => {
504
- queryObj[key] = value;
505
- });
506
- }
507
- let options = {
508
- where: queryObj,
509
- distinct: true,
510
- transaction: dbTransaction,
511
- };
512
- if (Page && Rows) {
513
- options = {
514
- ...options,
515
- limit: Rows,
516
- offset: Rows * (Page - 1),
517
- order: [['CreatedAt', 'DESC']],
518
- include: {
519
- model: group_entity_1.default,
520
- where: {
521
- Type: 'Role',
522
- },
523
- },
524
- };
525
- }
526
- const systemAccess = await Group._GroupSystemAccessRepo.findAndCountAll(options);
527
- return systemAccess;
528
- }
529
- catch (error) {
530
- return error;
531
- }
532
- }
533
- static async getInheritedSystemAccess(dbTransaction, group) {
534
- const options = {
535
- where: {
536
- GroupCode: group.GroupCode,
537
- Status: 'Active',
538
- },
539
- include: [
540
- {
541
- model: system_entity_1.default,
542
- },
543
- ],
544
- transaction: dbTransaction,
545
- };
546
- let systemAccess = await Group._GroupSystemAccessRepo.findAll(options);
547
- if (group.InheritParentSystemAccessYN === 'Y' && group.ParentGroupCode) {
548
- const parentGroup = await Group.init(dbTransaction, group.ParentGroupCode);
549
- const parentSystemAccesses = await this.getInheritedSystemAccess(dbTransaction, parentGroup);
550
- systemAccess = systemAccess.concat(parentSystemAccesses);
551
- }
552
- return systemAccess;
553
- }
554
- static async isGroupCodeInHierarchy(dbTransaction, GroupCode, ListGroupCode = []) {
555
- ListGroupCode.push(GroupCode);
556
- const group = await Group._Repo.findOne({
557
- where: { GroupCode },
558
- transaction: dbTransaction,
559
- });
560
- if (group?.ParentGroupCode) {
561
- const isGroupCodeExist = ListGroupCode.includes(group.ParentGroupCode);
562
- if (!isGroupCodeExist) {
563
- await this.isGroupCodeInHierarchy(dbTransaction, group.ParentGroupCode, ListGroupCode);
564
- }
565
- {
566
- return false;
567
- }
568
- }
569
- else {
570
- return true;
571
- }
572
- }
573
- static async getParentSystemAccesses(loginUser, dbTransaction, GroupCode) {
574
- const systemCode = config_1.ApplicationConfig.getComponentConfigValue('system-code');
575
- const isPrivileged = await loginUser.checkPrivileges(systemCode, 'SYSTEM_ACCESS_VIEW');
576
- if (!isPrivileged) {
577
- throw new general_1.ClassError('Group', 'GroupErrMsg06', 'You do not have the privilege to view system access');
578
- }
579
- try {
580
- const group = await Group.init(dbTransaction, GroupCode);
581
- if (group.InheritParentSystemAccessYN !== 'Y' || !group.ParentGroupCode) {
582
- return [];
583
- }
584
- else {
585
- const parentGroup = await Group.init(dbTransaction, group.ParentGroupCode);
586
- const inheritSystemAccess = await Group.getInheritedSystemAccess(dbTransaction, parentGroup);
587
- return inheritSystemAccess;
588
- }
589
- }
590
- catch (error) {
591
- throw error;
592
- }
593
- }
594
- static async addSystemAccesses(loginUser, dbTransaction, GroupCode, SystemCodes) {
595
- const systemCode = config_1.ApplicationConfig.getComponentConfigValue('system-code');
596
- const isPrivileged = await loginUser.checkPrivileges(systemCode, 'SYSTEM_ACCESS_CREATE');
597
- if (!isPrivileged) {
598
- throw new general_1.ClassError('Group', 'GroupErrMsg07', 'You do not have the privilege to create system access');
599
- }
600
- try {
601
- if (SystemCodes.length > 0) {
602
- for (const element of SystemCodes) {
603
- const CurrentGroupSystemAccess = await Group.getSystemAccesses(loginUser, dbTransaction, GroupCode, 1, Number.MAX_SAFE_INTEGER, { SystemCode: element });
604
- if (CurrentGroupSystemAccess?.count > 0) {
605
- throw new general_1.ClassError('Group', 'GroupErrMsg08', 'System access already exists');
606
- }
607
- const groupSystemAccess = await group_system_access_1.GroupSystemAccess.init(dbTransaction);
608
- groupSystemAccess.createId();
609
- groupSystemAccess.GroupCode = GroupCode;
610
- groupSystemAccess.SystemCode = element;
611
- groupSystemAccess.Status = 'Active';
612
- groupSystemAccess.CreatedById = +loginUser.ObjectId;
613
- groupSystemAccess.CreatedAt = new Date();
614
- groupSystemAccess.UpdatedById = +loginUser.ObjectId;
615
- groupSystemAccess.UpdatedAt = new Date();
616
- const EntityValueAfter = {
617
- GroupCode: groupSystemAccess.GroupCode,
618
- SystemCode: groupSystemAccess.SystemCode,
619
- Status: groupSystemAccess.Status,
620
- CreatedById: groupSystemAccess.CreatedById,
621
- CreatedAt: groupSystemAccess.CreatedAt,
622
- UpdatedById: groupSystemAccess.UpdatedById,
623
- UpdatedAt: groupSystemAccess.UpdatedAt,
624
- };
625
- const systemAccess = await Group._GroupSystemAccessRepo.create(EntityValueAfter, {
626
- transaction: dbTransaction,
627
- });
628
- const activity = new activity_history_1.Activity();
629
- activity.ActivityId = activity.createId();
630
- activity.Action = activity_history_1.ActionEnum.CREATE;
631
- activity.Description = 'Create Group System Access';
632
- activity.EntityType = 'GroupSystemAccess';
633
- activity.EntityId = systemAccess.GroupSystemAccessId?.toString();
634
- activity.EntityValueBefore = JSON.stringify({});
635
- activity.EntityValueAfter = JSON.stringify(EntityValueAfter);
636
- await activity.create(loginUser.ObjectId, dbTransaction);
637
- }
638
- return { Message: 'Successfully added.' };
639
- }
640
- }
641
- catch (error) {
642
- throw error;
643
- }
644
- }
645
- static async deleteSystemAccess(loginUser, dbTransaction, GroupCode, SystemCode) {
646
- const systemCode = config_1.ApplicationConfig.getComponentConfigValue('system-code');
647
- const isPrivileged = await loginUser.checkPrivileges(systemCode, 'SYSTEM_ACCESS_DELETE');
648
- if (!isPrivileged) {
649
- throw new general_1.ClassError('Group', 'GroupErrMsg08', 'You do not have the privilege to delete system access');
650
- }
651
- try {
652
- const currentGroupSystemAccess = await Group.getSystemAccesses(loginUser, dbTransaction, GroupCode, 1, Number.MAX_SAFE_INTEGER, { SystemCode: SystemCode });
653
- if (currentGroupSystemAccess.count < 1) {
654
- throw new general_1.ClassError('Group', 'GroupErrMsg10', 'No associated system access found.');
655
- }
656
- await Group._GroupSystemAccessRepo.delete(GroupCode, SystemCode, dbTransaction);
657
- const EntityValueBefore = {
658
- GroupCode: currentGroupSystemAccess?.rows[0]?.GroupCode,
659
- SystemCode: currentGroupSystemAccess?.rows[0]?.SystemCode,
660
- Status: currentGroupSystemAccess?.rows[0]?.Status,
661
- CreatedById: currentGroupSystemAccess?.rows[0]?.CreatedById,
662
- CreatedAt: currentGroupSystemAccess?.rows[0]?.CreatedAt,
663
- UpdatedById: currentGroupSystemAccess?.rows[0]?.UpdatedById,
664
- UpdatedAt: currentGroupSystemAccess?.rows[0]?.UpdatedAt,
665
- };
666
- const activity = new activity_history_1.Activity();
667
- activity.ActivityId = activity.createId();
668
- activity.Action = activity_history_1.ActionEnum.DELETE;
669
- activity.Description = 'Delete Group System Access';
670
- activity.EntityType = 'GroupSystemAccess';
671
- activity.EntityId =
672
- currentGroupSystemAccess?.rows[0]?.GroupSystemAccessId?.toString();
673
- activity.EntityValueBefore = JSON.stringify(EntityValueBefore);
674
- activity.EntityValueAfter = JSON.stringify({});
675
- await activity.create(loginUser.ObjectId, dbTransaction);
676
- return { Message: 'System access removed.', SystemCode: SystemCode };
677
- }
678
- catch (error) {
679
- throw error;
680
- }
681
- }
682
- static async getSystemPrivileges(loginUser, dbTransaction, GroupCode, search) {
683
- try {
684
- const systemCode = config_1.ApplicationConfig.getComponentConfigValue('system-code');
685
- const isPrivileged = await loginUser.checkPrivileges(systemCode, 'GROUP_PRIVILEGE_VIEW');
686
- if (!isPrivileged) {
687
- throw new general_1.ClassError('Group', 'GroupErrMsg11', 'You do not have the privilege to view group privileges');
688
- }
689
- await Group.init(dbTransaction, GroupCode);
690
- let where = {
691
- GroupCode,
692
- };
693
- let systemWhere = {};
694
- if (search) {
695
- if (search.Status) {
696
- where = {
697
- ...where,
698
- Status: search.Status,
699
- };
700
- }
701
- if (search.SystemCode) {
702
- systemWhere = {
703
- SystemCode: {
704
- [sequelize_1.Op.substring]: search.SystemCode,
705
- },
706
- };
707
- }
708
- }
709
- const groupOwnPrivileges = await Group._GroupPrivilegeRepo.findAll({
710
- where,
711
- include: [
712
- {
713
- model: system_privilege_entity_1.default,
714
- where: systemWhere,
715
- },
716
- ],
717
- transaction: dbTransaction,
718
- });
719
- const privileges = [];
720
- for (const groupPrivilege of groupOwnPrivileges) {
721
- const systemPrivilege = await system_privilege_1.SystemPrivilege.init(dbTransaction);
722
- systemPrivilege.setAttributes(groupPrivilege.Privilege.get({ plain: true }));
723
- privileges.push(systemPrivilege);
724
- }
725
- return privileges;
726
- }
727
- catch (error) {
728
- throw error;
729
- }
730
- }
731
- static async getSystemPrivilegeRoles(loginUser, dbTransaction, SystemCode, search) {
732
- try {
733
- const systemCode = config_1.ApplicationConfig.getComponentConfigValue('system-code');
734
- const isPrivileged = await loginUser.checkPrivileges(systemCode, 'GROUP_PRIVILEGE_VIEW');
735
- if (!isPrivileged) {
736
- throw new general_1.ClassError('Group', 'GroupErrMsg11', 'You do not have the privilege to view group privileges');
737
- }
738
- let systemWhere = {};
739
- if (SystemCode) {
740
- systemWhere = {
741
- SystemCode: {
742
- [sequelize_1.Op.substring]: SystemCode,
743
- },
744
- };
745
- }
746
- const groupCodesPrivileges = [];
747
- const allGroupCodePrivileges = await Group._GroupPrivilegeRepo.findAll({
748
- include: [
749
- {
750
- model: system_privilege_entity_1.default,
751
- where: systemWhere,
752
- },
753
- {
754
- model: group_entity_1.default,
755
- where: {
756
- Type: 'Role',
757
- },
758
- },
759
- ],
760
- transaction: dbTransaction,
761
- });
762
- const privilegesMap = new Map();
763
- for (const groupCodePrivilege of allGroupCodePrivileges) {
764
- const { SystemPrivilegeId, GroupCode, Group } = groupCodePrivilege;
765
- if (!privilegesMap.has(SystemPrivilegeId)) {
766
- privilegesMap.set(SystemPrivilegeId, []);
767
- }
768
- if (GroupCode && Group?.Name) {
769
- const groupCodes = privilegesMap.get(SystemPrivilegeId);
770
- const newGroupEntry = { Code: GroupCode, Name: Group.Name };
771
- if (groupCodes &&
772
- !groupCodes.some((g) => g.Code === GroupCode && g.Name === Group.Name)) {
773
- groupCodes.push(newGroupEntry);
774
- }
775
- }
776
- }
777
- privilegesMap.forEach((groupCodes, SystemPrivilegeId) => {
778
- groupCodesPrivileges.push({
779
- SystemPrivilegeId,
780
- GroupCodes: groupCodes,
781
- });
782
- });
783
- const allPrivileges = await system_privilege_entity_1.default.findAll({
784
- where: systemWhere,
785
- transaction: dbTransaction,
786
- });
787
- const groupPrivilegeRoles = [];
788
- for (const privilege of allPrivileges) {
789
- const matchingGroupPrivilege = groupCodesPrivileges.find((groupPrivilege) => groupPrivilege.SystemPrivilegeId === privilege.SystemPrivilegeId);
790
- if (matchingGroupPrivilege) {
791
- groupPrivilegeRoles.push({
792
- SystemPrivilegeId: privilege.SystemPrivilegeId,
793
- PrivilegeCode: privilege.PrivilegeCode,
794
- Description: privilege.Description,
795
- GroupCodes: matchingGroupPrivilege.GroupCodes,
796
- });
797
- }
798
- else {
799
- groupPrivilegeRoles.push({
800
- SystemPrivilegeId: privilege.SystemPrivilegeId,
801
- PrivilegeCode: privilege.PrivilegeCode,
802
- Description: privilege.Description,
803
- GroupCodes: [],
804
- });
805
- }
806
- }
807
- const filteredGroupPrivilegeRoles = groupPrivilegeRoles
808
- .map((role) => {
809
- if (search.GroupCode?.length) {
810
- const matchingGroupCodes = role.GroupCodes.filter((groupCode) => search.GroupCode.includes(groupCode.Code));
811
- if (matchingGroupCodes.length === 0) {
812
- return null;
813
- }
814
- return {
815
- ...role,
816
- GroupCodes: matchingGroupCodes,
817
- };
818
- }
819
- return role;
820
- })
821
- .filter(Boolean);
822
- return filteredGroupPrivilegeRoles;
823
- }
824
- catch (error) {
825
- throw error;
826
- }
827
- }
828
- static async getInheritedSystemPrivileges(dbTransaction, GroupCode, search) {
829
- try {
830
- const where = {
831
- GroupCode,
832
- };
833
- let groupPrivilegeWhere = {};
834
- let systemPrivilegeWhere = {};
835
- if (search) {
836
- if (search.Status) {
837
- groupPrivilegeWhere = {
838
- Status: search.Status,
839
- };
840
- }
841
- if (search.SystemCode) {
842
- systemPrivilegeWhere = {
843
- SystemCode: {
844
- [sequelize_1.Op.substring]: search.SystemCode,
845
- },
846
- };
847
- }
848
- if (search.PrivilegeCode) {
849
- systemPrivilegeWhere = {
850
- ...systemPrivilegeWhere,
851
- PrivilegeCode: {
852
- [sequelize_1.Op.substring]: search.PrivilegeCode,
853
- },
854
- };
855
- }
856
- }
857
- const group = await Group._Repo.findOne({
858
- where: where,
859
- include: [
860
- {
861
- model: group_privilege_entity_1.default,
862
- where: groupPrivilegeWhere,
863
- separate: true,
864
- include: [
865
- {
866
- model: system_privilege_entity_1.default,
867
- where: systemPrivilegeWhere,
868
- },
869
- ],
870
- },
871
- ],
872
- transaction: dbTransaction,
873
- });
874
- const objectWhere = {
875
- GroupCode,
876
- };
877
- const systemWhere = {};
878
- if (search) {
879
- Object.entries(search).forEach(([key, value]) => {
880
- if (key === 'Status') {
881
- objectWhere[key] = {
882
- [sequelize_1.Op.substring]: value,
883
- };
884
- }
885
- else {
886
- systemWhere[key] = {
887
- [sequelize_1.Op.substring]: value,
888
- };
889
- }
890
- });
891
- }
892
- const groupObjectPrivileges = await Group._GroupObjectPrivilegeRepo.findAll({
893
- where: objectWhere,
894
- include: [
895
- {
896
- model: system_privilege_entity_1.default,
897
- where: systemWhere,
898
- },
899
- ],
900
- transaction: dbTransaction,
901
- });
902
- let privileges = [];
903
- for (const groupPrivilege of group.GroupPrivileges) {
904
- const systemPrivilege = await system_privilege_1.SystemPrivilege.init(dbTransaction);
905
- systemPrivilege.setAttributes(groupPrivilege.Privilege.get({ plain: true }));
906
- privileges.push(systemPrivilege);
907
- }
908
- for (const groupObjectPrivilege of groupObjectPrivileges) {
909
- const systemPrivilege = await system_privilege_1.SystemPrivilege.init(dbTransaction);
910
- systemPrivilege.setAttributes(groupObjectPrivilege.Privilege.get({ plain: true }));
911
- privileges.push(systemPrivilege);
912
- }
913
- if (group.InheritParentPrivilegeYN === 'Y' && group.ParentGroupCode) {
914
- const inheritedPrivileges = await Group.getInheritedSystemPrivileges(dbTransaction, group.ParentGroupCode, search);
915
- privileges = privileges.concat(inheritedPrivileges);
916
- }
917
- const uniquePrivileges = Array.from(new Set(privileges.map((a) => a.SystemPrivilegeId))).map((SystemPrivilegeId) => {
918
- return privileges.find((a) => a.SystemPrivilegeId === SystemPrivilegeId);
919
- });
920
- return uniquePrivileges;
921
- }
922
- catch (error) {
923
- throw error;
924
- }
925
- }
926
- static async getParentSystemPrivileges(loginUser, dbTransaction, GroupCode, search) {
927
- try {
928
- const systemCode = config_1.ApplicationConfig.getComponentConfigValue('system-code');
929
- const isPrivileged = await loginUser.checkPrivileges(systemCode, 'GROUP_PRIVILEGE_VIEW');
930
- if (!isPrivileged) {
931
- throw new general_1.ClassError('Group', 'GroupErrMsg11', 'You do not have the privilege to view group privileges');
932
- }
933
- const group = await Group.init(dbTransaction, GroupCode);
934
- if (group.InheritParentPrivilegeYN !== 'Y' || !group.ParentGroupCode) {
935
- return [];
936
- }
937
- const privileges = await Group.getInheritedSystemPrivileges(dbTransaction, group.ParentGroupCode, search);
938
- return privileges;
939
- }
940
- catch (error) {
941
- throw error;
942
- }
943
- }
944
- static async assignGroupObjectPrivilege(loginUser, dbTransaction, GroupCode, GroupObjectPrivileges, SystemCode) {
945
- try {
946
- const systemCode = config_1.ApplicationConfig.getComponentConfigValue('system-code');
947
- const isPrivileged = await loginUser.checkPrivileges(systemCode, 'GROUP_OBJECT_PRIVILEGE_ASSIGN');
948
- if (!isPrivileged) {
949
- throw new general_1.ClassError('Group', 'GroupErrMsg12', 'You do not have the privilege to assign group object privilege');
950
- }
951
- const group = await Group.init(dbTransaction, GroupCode);
952
- const groupSystemAccesses = await Group.getSystemAccesses(loginUser, dbTransaction, GroupCode, 1, Number.MAX_SAFE_INTEGER, {});
953
- let parentGroupSystemAccesses = {
954
- rows: [],
955
- count: 0,
956
- };
957
- if (group.InheritParentSystemAccessYN === 'Y' && group.ParentGroupCode) {
958
- parentGroupSystemAccesses = await Group.getSystemAccesses(loginUser, dbTransaction, group.ParentGroupCode, 1, Number.MAX_SAFE_INTEGER, undefined);
959
- }
960
- for (const groupObjectPrivilege of GroupObjectPrivileges) {
961
- const systemPrivilege = await system_privilege_1.SystemPrivilege.init(dbTransaction, groupObjectPrivilege.SystemPrivilegeId);
962
- const combinedSystemAccesses = {
963
- ...groupSystemAccesses.rows,
964
- ...parentGroupSystemAccesses.rows,
965
- };
966
- const systemAccess = combinedSystemAccesses.find((systemAccess) => systemAccess.SystemCode === systemPrivilege.SystemCode);
967
- if (!systemAccess) {
968
- throw new general_1.ClassError('Group', 'GroupErrMsg13', 'Failed to assign privilege ' +
969
- groupObjectPrivilege.SystemPrivilegeId +
970
- ' due to non-existent system access.');
971
- }
972
- const groupObjectPrivilegeData = await Group._GroupObjectPrivilegeRepo.findOne({
973
- where: {
974
- GroupCode,
975
- SystemPrivilegeId: groupObjectPrivilege.SystemPrivilegeId,
976
- ObjectId: groupObjectPrivilege.ObjectId,
977
- ObjectType: groupObjectPrivilege.ObjectType,
978
- },
979
- transaction: dbTransaction,
980
- });
981
- if (groupObjectPrivilegeData) {
982
- continue;
983
- }
984
- else {
985
- await group_object_privilege_1.GroupObjectPrivilege.create(loginUser, dbTransaction, groupObjectPrivilege);
986
- }
987
- }
988
- return 'Successfully added.';
989
- }
990
- catch (error) {
991
- throw error;
992
- }
993
- }
994
- static async getGroubObjectPrivileges(loginUser, dbTransaction, GroupCode, search) {
995
- try {
996
- const systemCode = config_1.ApplicationConfig.getComponentConfigValue('system-code');
997
- const isPrivileged = await loginUser.checkPrivileges(systemCode, 'GROUP_PRIVILEGE_VIEW');
998
- if (!isPrivileged) {
999
- throw new general_1.ClassError('Group', 'GroupErrMsg11', 'You do not have the privilege to view group privileges');
1000
- }
1001
- await Group.init(dbTransaction, GroupCode);
1002
- const where = {
1003
- GroupCode,
1004
- };
1005
- const systemWhere = {};
1006
- if (search) {
1007
- Object.entries(search).forEach(([key, value]) => {
1008
- if (key === 'SystemCode' || key === 'PrivilegeCode') {
1009
- systemWhere[key] = {
1010
- [sequelize_1.Op.substring]: value,
1011
- };
1012
- }
1013
- else {
1014
- where[key] = {
1015
- [sequelize_1.Op.substring]: value,
1016
- };
1017
- }
1018
- });
1019
- }
1020
- const groupObjectPrivileges = await Group._GroupObjectPrivilegeRepo.findAll({
1021
- where,
1022
- include: [
1023
- {
1024
- model: system_privilege_entity_1.default,
1025
- where: systemWhere,
1026
- },
1027
- ],
1028
- transaction: dbTransaction,
1029
- });
1030
- const privileges = [];
1031
- for (const groupObjectPrivilege of groupObjectPrivileges) {
1032
- const systemPrivilege = await system_privilege_1.SystemPrivilege.init(dbTransaction);
1033
- systemPrivilege.setAttributes(groupObjectPrivilege.Privilege.get({ plain: true }));
1034
- privileges.push(systemPrivilege);
1035
- }
1036
- const uniquePrivileges = Array.from(new Set(privileges.map((a) => a.SystemPrivilegeId))).map((SystemPrivilegeId) => {
1037
- return privileges.find((a) => a.SystemPrivilegeId === SystemPrivilegeId);
1038
- });
1039
- return uniquePrivileges;
1040
- }
1041
- catch (error) {
1042
- throw error;
1043
- }
1044
- }
1045
- static async assignGroupPrivileges(loginUser, dbTransaction, GroupCode, SystemPrivilegeIds) {
1046
- try {
1047
- const systemCode = config_1.ApplicationConfig.getComponentConfigValue('system-code');
1048
- const isPrivileged = await loginUser.checkPrivileges(systemCode, 'GROUP_PRIVILEGE_ASSIGN');
1049
- if (!isPrivileged) {
1050
- throw new general_1.ClassError('Group', 'GroupErrMsg06', 'You do not have the privilege to assign group privileges');
1051
- }
1052
- const group = await Group.init(dbTransaction, GroupCode);
1053
- const groupSystemAccesses = await Group.getSystemAccesses(loginUser, dbTransaction, GroupCode, 1, Number.MAX_SAFE_INTEGER, {});
1054
- let parentGroupSystemAccesses = {
1055
- rows: [],
1056
- count: 0,
1057
- };
1058
- if (group.InheritParentSystemAccessYN === 'Y' && group.ParentGroupCode) {
1059
- parentGroupSystemAccesses = await Group.getSystemAccesses(loginUser, dbTransaction, group.ParentGroupCode, 1, Number.MAX_SAFE_INTEGER, {});
1060
- }
1061
- for (const SystemPrivilegeId of SystemPrivilegeIds) {
1062
- const systemPrivilege = await system_privilege_1.SystemPrivilege.init(dbTransaction, SystemPrivilegeId);
1063
- const combinedSystemAccesses = [
1064
- ...groupSystemAccesses.rows,
1065
- ...parentGroupSystemAccesses.rows,
1066
- ];
1067
- const systemAccess = combinedSystemAccesses.find((systemAccess) => systemAccess.SystemCode === systemPrivilege.SystemCode);
1068
- if (!systemAccess) {
1069
- throw new general_1.ClassError('Group', 'GroupErrMsg13', 'Failed to assign privilege ' +
1070
- SystemPrivilegeId +
1071
- ' due to non-existent system access.');
1072
- }
1073
- const groupPrivilege = await Group._GroupPrivilegeRepo.findOne({
1074
- where: {
1075
- GroupCode,
1076
- SystemPrivilegeId,
1077
- },
1078
- include: [
1079
- {
1080
- model: system_privilege_entity_1.default,
1081
- },
1082
- ],
1083
- transaction: dbTransaction,
1084
- });
1085
- if (groupPrivilege && groupPrivilege.Status === 'Active') {
1086
- continue;
1087
- }
1088
- let entityValueBefore = {};
1089
- let entityValueAfter = {};
1090
- let action = activity_history_1.ActionEnum.CREATE;
1091
- let description = 'Create Group Privilege';
1092
- let entityId = null;
1093
- if (groupPrivilege && groupPrivilege.Status !== 'Active') {
1094
- entityValueBefore = {
1095
- GroupCode: groupPrivilege.GroupCode,
1096
- SystemPrivilegeId: groupPrivilege.SystemPrivilegeId,
1097
- Status: groupPrivilege.Status,
1098
- CreatedById: groupPrivilege.CreatedById,
1099
- CreatedAt: groupPrivilege.CreatedAt,
1100
- UpdatedById: groupPrivilege.UpdatedById,
1101
- UpdatedAt: groupPrivilege.UpdatedAt,
1102
- };
1103
- const updatedPayload = {
1104
- Status: 'Active',
1105
- UpdatedById: loginUser.UserId,
1106
- UpdatedAt: new Date(),
1107
- };
1108
- const data = await Group._GroupPrivilegeRepo.findOne({
1109
- where: {
1110
- GroupCode,
1111
- SystemPrivilegeId,
1112
- },
1113
- include: [
1114
- {
1115
- model: system_privilege_entity_1.default,
1116
- },
1117
- ],
1118
- transaction: dbTransaction,
1119
- });
1120
- data.Status = 'Active';
1121
- data.UpdatedById = updatedPayload.UpdatedById;
1122
- data.UpdatedAt = updatedPayload.UpdatedAt;
1123
- await data.save({ transaction: dbTransaction });
1124
- entityValueAfter = {
1125
- GroupCode: groupPrivilege.GroupCode,
1126
- SystemPrivilegeId: groupPrivilege.SystemPrivilegeId,
1127
- Status: updatedPayload.Status,
1128
- CreatedById: groupPrivilege.CreatedById,
1129
- CreatedAt: groupPrivilege.CreatedAt,
1130
- UpdatedById: updatedPayload.UpdatedById,
1131
- UpdatedAt: updatedPayload.UpdatedAt,
1132
- };
1133
- action = activity_history_1.ActionEnum.UPDATE;
1134
- description = 'Update Group Privilege';
1135
- entityId = groupPrivilege.GroupPrivilegeId;
1136
- }
1137
- else {
1138
- const newGroupPrivilege = await group_privilege_1.GroupPrivilege.init(dbTransaction);
1139
- newGroupPrivilege.setAttributes({
1140
- GroupCode,
1141
- SystemPrivilegeId,
1142
- Status: 'Active',
1143
- CreatedById: loginUser.UserId,
1144
- CreatedAt: new Date(),
1145
- UpdatedById: loginUser.UserId,
1146
- UpdatedAt: new Date(),
1147
- });
1148
- entityValueAfter = {
1149
- GroupCode: newGroupPrivilege.GroupCode,
1150
- SystemPrivilegeId: newGroupPrivilege.SystemPrivilegeId,
1151
- Status: newGroupPrivilege.Status,
1152
- CreatedById: newGroupPrivilege.CreatedById,
1153
- CreatedAt: newGroupPrivilege.CreatedAt,
1154
- UpdatedById: newGroupPrivilege.UpdatedById,
1155
- UpdatedAt: newGroupPrivilege.UpdatedAt,
1156
- };
1157
- const groupPrivilege = await Group._GroupPrivilegeRepo.create(entityValueAfter, {
1158
- transaction: dbTransaction,
1159
- });
1160
- action = activity_history_1.ActionEnum.CREATE;
1161
- description = 'Create Group Privilege';
1162
- entityId = groupPrivilege.GroupPrivilegeId;
1163
- }
1164
- const activity = new activity_history_1.Activity();
1165
- activity.ActivityId = activity.createId();
1166
- activity.Action = action;
1167
- activity.Description = description;
1168
- activity.EntityType = 'GroupPrivilege';
1169
- activity.EntityId = entityId;
1170
- activity.EntityValueBefore = JSON.stringify(entityValueBefore);
1171
- activity.EntityValueAfter = JSON.stringify(entityValueAfter);
1172
- await activity.create(loginUser.ObjectId, dbTransaction);
1173
- }
1174
- return 'Successfully added.';
1175
- }
1176
- catch (error) {
1177
- throw error;
1178
- }
1179
- }
1180
- static async deleteGroupPrivilege(loginUser, dbTransaction, GroupCode, SystemPrivilegeIds) {
1181
- try {
1182
- const systemCode = config_1.ApplicationConfig.getComponentConfigValue('system-code');
1183
- const isPrivileged = await loginUser.checkPrivileges(systemCode, 'GROUP_PRIVILEGE_DELETE');
1184
- if (!isPrivileged) {
1185
- throw new general_1.ClassError('Group', 'GroupErrMsg06', 'You do not have the privilege to delete group privileges');
1186
- }
1187
- for (const SystemPrivilegeId of SystemPrivilegeIds) {
1188
- const groupPrivilege = await Group._GroupPrivilegeRepo.findOne({
1189
- where: {
1190
- GroupCode,
1191
- SystemPrivilegeId,
1192
- },
1193
- include: [
1194
- {
1195
- model: system_privilege_entity_1.default,
1196
- },
1197
- ],
1198
- transaction: dbTransaction,
1199
- });
1200
- if (!groupPrivilege) {
1201
- throw new general_1.ClassError('Group', 'GroupErrMsg14', 'GroupPrivilege not found.');
1202
- }
1203
- const entityValueBefore = {
1204
- GroupCode: groupPrivilege.GroupCode,
1205
- SystemPrivilegeId: groupPrivilege.SystemPrivilegeId,
1206
- Status: groupPrivilege.Status,
1207
- CreatedById: groupPrivilege.CreatedById,
1208
- CreatedAt: groupPrivilege.CreatedAt,
1209
- UpdatedById: groupPrivilege.UpdatedById,
1210
- UpdatedAt: groupPrivilege.UpdatedAt,
1211
- };
1212
- await Group._GroupPrivilegeRepo.delete(GroupCode, SystemPrivilegeId, dbTransaction);
1213
- const activity = new activity_history_1.Activity();
1214
- activity.ActivityId = activity.createId();
1215
- activity.Action = activity_history_1.ActionEnum.DELETE;
1216
- activity.Description = 'DELETE Group Privilege';
1217
- activity.EntityType = 'GroupPrivilege';
1218
- activity.EntityId = groupPrivilege.GroupPrivilegeId.toString();
1219
- activity.EntityValueBefore = JSON.stringify(entityValueBefore);
1220
- activity.EntityValueAfter = JSON.stringify({});
1221
- await activity.create(loginUser.ObjectId, dbTransaction);
1222
- }
1223
- return 'Successfully deleted.';
1224
- }
1225
- catch (error) {
1226
- throw error;
1227
- }
1228
- }
1229
- static async getHierarchy(loginUser, dbTransaction, Status, Type, ParentGroupCode) {
1230
- const systemCode = config_1.ApplicationConfig.getComponentConfigValue('system-code');
1231
- const isPrivileged = await loginUser.checkPrivileges(systemCode, 'GROUP_VIEW');
1232
- if (!isPrivileged) {
1233
- throw new general_1.ClassError('Group', 'GroupErrMsg04', 'User is not privileged to view group');
1234
- }
1235
- const queryObj = {};
1236
- let options = {
1237
- transaction: dbTransaction,
1238
- };
1239
- const search = {
1240
- Status: Status ? Status : 'Active',
1241
- Type: Type,
1242
- ParentGroupCode: ParentGroupCode,
1243
- };
1244
- if (search) {
1245
- Object.entries(search).forEach(([key, value]) => {
1246
- if (value) {
1247
- queryObj[key] = {
1248
- [sequelize_1.Op.substring]: value,
1249
- };
1250
- }
1251
- });
1252
- options = {
1253
- ...options,
1254
- where: queryObj,
1255
- };
1256
- const result = await Group._Repo.findAll(options);
1257
- const data = result.map((group) => new Group(group.get({ plain: true })));
1258
- const generateTree = async (groups) => {
1259
- const data = groups.map((group) => {
1260
- return {
1261
- GroupCode: group.ObjectId,
1262
- Name: group.Name,
1263
- Description: group.Description,
1264
- Type: group.Type,
1265
- ParentGroupCode: group.ParentGroupCode,
1266
- InheritParentPrivilegeYN: group.InheritParentPrivilegeYN,
1267
- InheritParentSystemAccessYN: group.InheritParentSystemAccessYN,
1268
- Path: group._Path,
1269
- Status: group.Status,
1270
- CreatedById: group._CreatedById,
1271
- CreatedAt: group._CreatedAt,
1272
- UpdatedById: group._UpdatedById,
1273
- UpdatedAt: group._UpdatedAt,
1274
- childrens: [],
1275
- };
1276
- });
1277
- const groupMap = {};
1278
- data.forEach((group) => {
1279
- group.childrens = [];
1280
- groupMap[group.GroupCode] = group;
1281
- });
1282
- const tree = [];
1283
- data.forEach((group) => {
1284
- if (group.ParentGroupCode) {
1285
- const parent = groupMap[group.ParentGroupCode];
1286
- if (parent) {
1287
- parent.childrens.push(group);
1288
- }
1289
- }
1290
- else {
1291
- tree.push(group);
1292
- }
1293
- });
1294
- return tree;
1295
- };
1296
- const tree = await generateTree(data);
1297
- return tree;
1298
- }
1299
- }
1300
- static async getGroupsWithReportingUser(loginUser, dbTransaction, whereOptions) {
1301
- try {
1302
- const systemCode = config_1.ApplicationConfig.getComponentConfigValue('system-code');
1303
- const isPrivileged = await loginUser.checkPrivileges(systemCode, 'GROUP_VIEW');
1304
- if (!isPrivileged) {
1305
- throw new general_1.ClassError('Group', 'GroupErrMsg04', 'User is not privileged to view group');
1306
- }
1307
- const options = {
1308
- where: whereOptions,
1309
- include: [
1310
- {
1311
- model: group_reporting_user_entity_1.default,
1312
- where: { Status: 'Active' },
1313
- include: [
1314
- {
1315
- model: user_entity_1.default,
1316
- as: 'User',
1317
- attributes: ['UserId', 'FullName'],
1318
- },
1319
- ],
1320
- },
1321
- ],
1322
- transaction: dbTransaction,
1323
- };
1324
- const groups = await Group._Repo.findAll(options);
1325
- return groups;
1326
- }
1327
- catch (error) {
1328
- throw error;
1329
- }
1330
- }
1331
- }
1332
- exports.Group = Group;
1333
- Group._Repo = new group_repository_1.GroupRepository();
1334
- Group._GroupSystemAccessRepo = new group_system_access_repository_1.GroupSystemAccessRepository();
1335
- Group._GroupPrivilegeRepo = new group_privilege_repository_1.GroupPrivilegeRepository();
1336
- Group._GroupObjectPrivilegeRepo = new group_object_privilege_repository_1.GroupObjectPrivilegeRepository();
1337
- //# sourceMappingURL=group.js.map