@tomei/sso 0.60.4-dev.6 → 0.60.4
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.
- package/.husky/commit-msg +6 -0
- package/.husky/pre-commit +0 -0
- package/dist/components/api-key/api-key.d.ts +85 -0
- package/dist/components/api-key/api-key.d.ts.map +1 -0
- package/dist/components/api-key/api-key.js +245 -0
- package/dist/components/api-key/api-key.js.map +1 -0
- package/dist/components/api-key/api-key.repository.d.ts +7 -0
- package/dist/components/api-key/api-key.repository.d.ts.map +1 -0
- package/dist/components/api-key/api-key.repository.js +18 -0
- package/dist/components/api-key/api-key.repository.js.map +1 -0
- package/dist/components/api-key/index.d.ts +4 -0
- package/dist/components/api-key/index.d.ts.map +1 -0
- package/dist/components/api-key/index.js +8 -0
- package/dist/components/api-key/index.js.map +1 -0
- package/dist/components/building/building.repository.d.ts +7 -0
- package/dist/components/building/building.repository.d.ts.map +1 -0
- package/dist/components/building/building.repository.js +30 -0
- package/dist/components/building/building.repository.js.map +1 -0
- package/dist/components/building/index.d.ts +2 -0
- package/dist/components/building/index.d.ts.map +1 -0
- package/dist/components/building/index.js +18 -0
- package/dist/components/building/index.js.map +1 -0
- package/dist/components/group/group.d.ts +129 -0
- package/dist/components/group/group.d.ts.map +1 -0
- package/dist/components/group/group.js +1337 -0
- package/dist/components/group/group.js.map +1 -0
- package/dist/components/group/group.repository.d.ts +8 -0
- package/dist/components/group/group.repository.d.ts.map +1 -0
- package/dist/components/group/group.repository.js +29 -0
- package/dist/components/group/group.repository.js.map +1 -0
- package/dist/components/group/index.d.ts +3 -0
- package/dist/components/group/index.d.ts.map +1 -0
- package/dist/components/group/index.js +19 -0
- package/dist/components/group/index.js.map +1 -0
- package/dist/components/group-object-privilege/group-object-privilege.d.ts +28 -0
- package/dist/components/group-object-privilege/group-object-privilege.d.ts.map +1 -0
- package/dist/components/group-object-privilege/group-object-privilege.js +163 -0
- package/dist/components/group-object-privilege/group-object-privilege.js.map +1 -0
- package/dist/components/group-object-privilege/group-object-privilege.repository.d.ts +7 -0
- package/dist/components/group-object-privilege/group-object-privilege.repository.d.ts.map +1 -0
- package/dist/components/group-object-privilege/group-object-privilege.repository.js +26 -0
- package/dist/components/group-object-privilege/group-object-privilege.repository.js.map +1 -0
- package/dist/components/group-object-privilege/index.d.ts +3 -0
- package/dist/components/group-object-privilege/index.d.ts.map +1 -0
- package/dist/components/group-object-privilege/index.js +19 -0
- package/dist/components/group-object-privilege/index.js.map +1 -0
- package/dist/components/group-privilege/group-privilege.d.ts +25 -0
- package/dist/components/group-privilege/group-privilege.d.ts.map +1 -0
- package/dist/components/group-privilege/group-privilege.js +67 -0
- package/dist/components/group-privilege/group-privilege.js.map +1 -0
- package/dist/components/group-privilege/group-privilege.repository.d.ts +7 -0
- package/dist/components/group-privilege/group-privilege.repository.d.ts.map +1 -0
- package/dist/components/group-privilege/group-privilege.repository.js +28 -0
- package/dist/components/group-privilege/group-privilege.repository.js.map +1 -0
- package/dist/components/group-privilege/index.d.ts +3 -0
- package/dist/components/group-privilege/index.d.ts.map +1 -0
- package/dist/components/group-privilege/index.js +19 -0
- package/dist/components/group-privilege/index.js.map +1 -0
- package/dist/components/group-reporting-user/group-reporting-user.d.ts +30 -0
- package/dist/components/group-reporting-user/group-reporting-user.d.ts.map +1 -0
- package/dist/components/group-reporting-user/group-reporting-user.js +277 -0
- package/dist/components/group-reporting-user/group-reporting-user.js.map +1 -0
- package/dist/components/group-reporting-user/group-reporting-user.repository.d.ts +7 -0
- package/dist/components/group-reporting-user/group-reporting-user.repository.d.ts.map +1 -0
- package/dist/components/group-reporting-user/group-reporting-user.repository.js +23 -0
- package/dist/components/group-reporting-user/group-reporting-user.repository.js.map +1 -0
- package/dist/components/group-reporting-user/index.d.ts +3 -0
- package/dist/components/group-reporting-user/index.d.ts.map +1 -0
- package/dist/components/group-reporting-user/index.js +19 -0
- package/dist/components/group-reporting-user/index.js.map +1 -0
- package/dist/components/group-system-access/group-system-access.d.ts +28 -0
- package/dist/components/group-system-access/group-system-access.d.ts.map +1 -0
- package/dist/components/group-system-access/group-system-access.js +70 -0
- package/dist/components/group-system-access/group-system-access.js.map +1 -0
- package/dist/components/group-system-access/group-system-access.repository.d.ts +8 -0
- package/dist/components/group-system-access/group-system-access.repository.d.ts.map +1 -0
- package/dist/components/group-system-access/group-system-access.repository.js +46 -0
- package/dist/components/group-system-access/group-system-access.repository.js.map +1 -0
- package/dist/components/group-system-access/index.d.ts +3 -0
- package/dist/components/group-system-access/index.d.ts.map +1 -0
- package/dist/components/group-system-access/index.js +19 -0
- package/dist/components/group-system-access/index.js.map +1 -0
- package/dist/components/index.d.ts +18 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +34 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/login-history/index.d.ts +2 -0
- package/dist/components/login-history/index.d.ts.map +1 -0
- package/dist/components/login-history/index.js +18 -0
- package/dist/components/login-history/index.js.map +1 -0
- package/dist/components/login-history/login-history.repository.d.ts +6 -0
- package/dist/components/login-history/login-history.repository.d.ts.map +1 -0
- package/dist/components/login-history/login-history.repository.js +15 -0
- package/dist/components/login-history/login-history.repository.js.map +1 -0
- package/dist/components/login-user/index.d.ts +5 -0
- package/dist/components/login-user/index.d.ts.map +1 -0
- package/dist/components/login-user/index.js +21 -0
- package/dist/components/login-user/index.js.map +1 -0
- package/dist/components/login-user/interfaces/check-user-info-duplicated.interface.d.ts +8 -0
- package/dist/components/login-user/interfaces/check-user-info-duplicated.interface.d.ts.map +1 -0
- package/dist/components/login-user/interfaces/check-user-info-duplicated.interface.js +3 -0
- package/dist/components/login-user/interfaces/check-user-info-duplicated.interface.js.map +1 -0
- package/dist/components/login-user/interfaces/index.d.ts +2 -0
- package/dist/components/login-user/interfaces/index.d.ts.map +1 -0
- package/dist/components/login-user/interfaces/index.js +18 -0
- package/dist/components/login-user/interfaces/index.js.map +1 -0
- package/dist/components/login-user/interfaces/system-access.interface.d.ts +14 -0
- package/dist/components/login-user/interfaces/system-access.interface.d.ts.map +1 -0
- package/dist/{src/interfaces/login-history.interface.js → components/login-user/interfaces/system-access.interface.js} +1 -1
- package/dist/components/login-user/interfaces/system-access.interface.js.map +1 -0
- package/dist/components/login-user/interfaces/user-info.interface.d.ts +31 -0
- package/dist/components/login-user/interfaces/user-info.interface.d.ts.map +1 -0
- package/dist/{src/interfaces/login-history-search-attr.interface.js → components/login-user/interfaces/user-info.interface.js} +1 -1
- package/dist/components/login-user/interfaces/user-info.interface.js.map +1 -0
- package/dist/components/login-user/login-user.d.ts +14 -0
- package/dist/components/login-user/login-user.d.ts.map +1 -0
- package/dist/components/login-user/login-user.js +127 -0
- package/dist/components/login-user/login-user.js.map +1 -0
- package/dist/components/login-user/user.d.ts +155 -0
- package/dist/components/login-user/user.d.ts.map +1 -0
- package/dist/components/login-user/user.js +1753 -0
- package/dist/components/login-user/user.js.map +1 -0
- package/dist/components/login-user/user.repository.d.ts +6 -0
- package/dist/components/login-user/user.repository.d.ts.map +1 -0
- package/dist/components/login-user/user.repository.js +15 -0
- package/dist/components/login-user/user.repository.js.map +1 -0
- package/dist/components/password-hash/index.d.ts +3 -0
- package/dist/components/password-hash/index.d.ts.map +1 -0
- package/dist/components/password-hash/index.js +19 -0
- package/dist/components/password-hash/index.js.map +1 -0
- package/dist/components/password-hash/interfaces/index.d.ts +2 -0
- package/dist/components/password-hash/interfaces/index.d.ts.map +1 -0
- package/dist/components/password-hash/interfaces/index.js +18 -0
- package/dist/components/password-hash/interfaces/index.js.map +1 -0
- package/dist/components/password-hash/interfaces/password-hash-service.interface.d.ts +5 -0
- package/dist/components/password-hash/interfaces/password-hash-service.interface.d.ts.map +1 -0
- package/dist/components/password-hash/interfaces/password-hash-service.interface.js +3 -0
- package/dist/components/password-hash/interfaces/password-hash-service.interface.js.map +1 -0
- package/dist/components/password-hash/password-hash.service.d.ts +7 -0
- package/dist/components/password-hash/password-hash.service.d.ts.map +1 -0
- package/dist/components/password-hash/password-hash.service.js +48 -0
- package/dist/components/password-hash/password-hash.service.js.map +1 -0
- package/dist/components/staff/index.d.ts +2 -0
- package/dist/components/staff/index.d.ts.map +1 -0
- package/dist/components/staff/index.js +18 -0
- package/dist/components/staff/index.js.map +1 -0
- package/dist/components/staff/staff.repository.d.ts +7 -0
- package/dist/components/staff/staff.repository.d.ts.map +1 -0
- package/dist/components/staff/staff.repository.js +30 -0
- package/dist/components/staff/staff.repository.js.map +1 -0
- package/dist/components/system/index.d.ts +3 -0
- package/dist/components/system/index.d.ts.map +1 -0
- package/dist/components/system/index.js +19 -0
- package/dist/components/system/index.js.map +1 -0
- package/dist/components/system/system.d.ts +40 -0
- package/dist/components/system/system.d.ts.map +1 -0
- package/dist/components/system/system.js +283 -0
- package/dist/components/system/system.js.map +1 -0
- package/dist/components/system/system.repository.d.ts +6 -0
- package/dist/components/system/system.repository.d.ts.map +1 -0
- package/dist/components/system/system.repository.js +15 -0
- package/dist/components/system/system.repository.js.map +1 -0
- package/dist/components/system-privilege/index.d.ts +4 -0
- package/dist/components/system-privilege/index.d.ts.map +1 -0
- package/dist/components/system-privilege/index.js +8 -0
- package/dist/components/system-privilege/index.js.map +1 -0
- package/dist/components/system-privilege/system-privilege.d.ts +53 -0
- package/dist/components/system-privilege/system-privilege.d.ts.map +1 -0
- package/dist/components/system-privilege/system-privilege.js +315 -0
- package/dist/components/system-privilege/system-privilege.js.map +1 -0
- package/dist/components/system-privilege/system-privilege.repository.d.ts +7 -0
- package/dist/components/system-privilege/system-privilege.repository.d.ts.map +1 -0
- package/dist/components/system-privilege/system-privilege.repository.js +21 -0
- package/dist/components/system-privilege/system-privilege.repository.js.map +1 -0
- package/dist/components/user-group/index.d.ts +3 -0
- package/dist/components/user-group/index.d.ts.map +1 -0
- package/dist/components/user-group/index.js +19 -0
- package/dist/components/user-group/index.js.map +1 -0
- package/dist/components/user-group/user-group.d.ts +51 -0
- package/dist/components/user-group/user-group.d.ts.map +1 -0
- package/dist/components/user-group/user-group.js +335 -0
- package/dist/components/user-group/user-group.js.map +1 -0
- package/dist/components/user-group/user-group.repository.d.ts +6 -0
- package/dist/components/user-group/user-group.repository.d.ts.map +1 -0
- package/dist/components/user-group/user-group.repository.js +15 -0
- package/dist/components/user-group/user-group.repository.js.map +1 -0
- package/dist/components/user-object-privilege/index.d.ts +3 -0
- package/dist/components/user-object-privilege/index.d.ts.map +1 -0
- package/dist/components/user-object-privilege/index.js +19 -0
- package/dist/components/user-object-privilege/index.js.map +1 -0
- package/dist/components/user-object-privilege/user-object-privilege.d.ts +24 -0
- package/dist/components/user-object-privilege/user-object-privilege.d.ts.map +1 -0
- package/dist/components/user-object-privilege/user-object-privilege.js +59 -0
- package/dist/components/user-object-privilege/user-object-privilege.js.map +1 -0
- package/dist/components/user-object-privilege/user-object-privilege.repository.d.ts +6 -0
- package/dist/components/user-object-privilege/user-object-privilege.repository.d.ts.map +1 -0
- package/dist/components/user-object-privilege/user-object-privilege.repository.js +15 -0
- package/dist/components/user-object-privilege/user-object-privilege.repository.js.map +1 -0
- package/dist/components/user-privilege/index.d.ts +3 -0
- package/dist/components/user-privilege/index.d.ts.map +1 -0
- package/dist/components/user-privilege/index.js +19 -0
- package/dist/components/user-privilege/index.js.map +1 -0
- package/dist/components/user-privilege/user-privilege.d.ts +71 -0
- package/dist/components/user-privilege/user-privilege.d.ts.map +1 -0
- package/dist/components/user-privilege/user-privilege.js +388 -0
- package/dist/components/user-privilege/user-privilege.js.map +1 -0
- package/dist/components/user-privilege/user-privilege.repository.d.ts +7 -0
- package/dist/components/user-privilege/user-privilege.repository.d.ts.map +1 -0
- package/dist/components/user-privilege/user-privilege.repository.js +29 -0
- package/dist/components/user-privilege/user-privilege.repository.js.map +1 -0
- package/dist/components/user-system-access/index.d.ts +3 -0
- package/dist/components/user-system-access/index.d.ts.map +1 -0
- package/dist/components/user-system-access/index.js +19 -0
- package/dist/components/user-system-access/index.js.map +1 -0
- package/dist/components/user-system-access/user-system-access.d.ts +69 -0
- package/dist/components/user-system-access/user-system-access.d.ts.map +1 -0
- package/dist/components/user-system-access/user-system-access.js +413 -0
- package/dist/components/user-system-access/user-system-access.js.map +1 -0
- package/dist/components/user-system-access/user-system-access.repository.d.ts +8 -0
- package/dist/components/user-system-access/user-system-access.repository.d.ts.map +1 -0
- package/dist/components/user-system-access/user-system-access.repository.js +44 -0
- package/dist/components/user-system-access/user-system-access.repository.js.map +1 -0
- package/dist/database.d.ts +5 -0
- package/dist/database.d.ts.map +1 -0
- package/dist/database.js +14 -0
- package/dist/database.js.map +1 -0
- package/dist/enum/api-key.enum.d.ts +6 -0
- package/dist/enum/api-key.enum.d.ts.map +1 -0
- package/dist/enum/api-key.enum.js +10 -0
- package/dist/enum/api-key.enum.js.map +1 -0
- package/dist/enum/group-type.enum.d.ts +9 -0
- package/dist/enum/group-type.enum.d.ts.map +1 -0
- package/dist/enum/group-type.enum.js +13 -0
- package/dist/enum/group-type.enum.js.map +1 -0
- package/dist/enum/index.d.ts +7 -0
- package/dist/enum/index.d.ts.map +1 -0
- package/dist/enum/index.js +23 -0
- package/dist/enum/index.js.map +1 -0
- package/dist/enum/login-status.enum.d.ts +5 -0
- package/dist/enum/login-status.enum.d.ts.map +1 -0
- package/dist/enum/login-status.enum.js +9 -0
- package/dist/enum/login-status.enum.js.map +1 -0
- package/dist/enum/object-status.enum.d.ts +5 -0
- package/dist/enum/object-status.enum.d.ts.map +1 -0
- package/dist/enum/object-status.enum.js +9 -0
- package/dist/enum/object-status.enum.js.map +1 -0
- package/dist/enum/user-status.enum.d.ts +8 -0
- package/dist/enum/user-status.enum.d.ts.map +1 -0
- package/dist/enum/user-status.enum.js +12 -0
- package/dist/enum/user-status.enum.js.map +1 -0
- package/dist/enum/yn.enum.d.ts +5 -0
- package/dist/enum/yn.enum.d.ts.map +1 -0
- package/dist/enum/yn.enum.js +9 -0
- package/dist/enum/yn.enum.js.map +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/interfaces/api-key-attr.interface.d.ts +16 -0
- package/dist/interfaces/api-key-attr.interface.d.ts.map +1 -0
- package/dist/interfaces/api-key-attr.interface.js +3 -0
- package/dist/interfaces/api-key-attr.interface.js.map +1 -0
- package/dist/interfaces/group-object-privilege.interface.d.ts +14 -0
- package/dist/interfaces/group-object-privilege.interface.d.ts.map +1 -0
- package/dist/interfaces/group-object-privilege.interface.js +3 -0
- package/dist/interfaces/group-object-privilege.interface.js.map +1 -0
- package/dist/interfaces/group-privilege.interface.d.ts +11 -0
- package/dist/interfaces/group-privilege.interface.d.ts.map +1 -0
- package/dist/interfaces/group-privilege.interface.js +3 -0
- package/dist/interfaces/group-privilege.interface.js.map +1 -0
- package/dist/interfaces/group-reporting-user.interface.d.ts +12 -0
- package/dist/interfaces/group-reporting-user.interface.d.ts.map +1 -0
- package/dist/interfaces/group-reporting-user.interface.js +3 -0
- package/dist/interfaces/group-reporting-user.interface.js.map +1 -0
- package/dist/interfaces/group-search-attr.interface.d.ts +9 -0
- package/dist/interfaces/group-search-attr.interface.d.ts.map +1 -0
- package/dist/interfaces/group-search-attr.interface.js +3 -0
- package/dist/interfaces/group-search-attr.interface.js.map +1 -0
- package/dist/interfaces/group-system-access.interface.d.ts +11 -0
- package/dist/interfaces/group-system-access.interface.d.ts.map +1 -0
- package/dist/interfaces/group-system-access.interface.js +3 -0
- package/dist/interfaces/group-system-access.interface.js.map +1 -0
- package/dist/interfaces/group.interface.d.ts +17 -0
- package/dist/interfaces/group.interface.d.ts.map +1 -0
- package/dist/interfaces/group.interface.js +3 -0
- package/dist/interfaces/group.interface.js.map +1 -0
- package/dist/interfaces/index.d.ts +14 -0
- package/dist/interfaces/index.d.ts.map +1 -0
- package/dist/interfaces/index.js +30 -0
- package/dist/interfaces/index.js.map +1 -0
- package/dist/interfaces/system-login.interface.d.ts +7 -0
- package/dist/interfaces/system-login.interface.d.ts.map +1 -0
- package/dist/interfaces/system-login.interface.js +3 -0
- package/dist/interfaces/system-login.interface.js.map +1 -0
- package/dist/interfaces/system-privilege-search.interface.d.ts +6 -0
- package/dist/interfaces/system-privilege-search.interface.d.ts.map +1 -0
- package/dist/interfaces/system-privilege-search.interface.js +3 -0
- package/dist/interfaces/system-privilege-search.interface.js.map +1 -0
- package/dist/interfaces/system-privilege.interface.d.ts +12 -0
- package/dist/interfaces/system-privilege.interface.d.ts.map +1 -0
- package/dist/interfaces/system-privilege.interface.js +3 -0
- package/dist/interfaces/system-privilege.interface.js.map +1 -0
- package/dist/interfaces/system-search-attr.interface.d.ts +6 -0
- package/dist/interfaces/system-search-attr.interface.d.ts.map +1 -0
- package/dist/interfaces/system-search-attr.interface.js +3 -0
- package/dist/interfaces/system-search-attr.interface.js.map +1 -0
- package/dist/interfaces/system.interface.d.ts +16 -0
- package/dist/interfaces/system.interface.d.ts.map +1 -0
- package/dist/interfaces/system.interface.js +3 -0
- package/dist/interfaces/system.interface.js.map +1 -0
- package/dist/interfaces/user-group.interface.d.ts +13 -0
- package/dist/interfaces/user-group.interface.d.ts.map +1 -0
- package/dist/interfaces/user-group.interface.js +3 -0
- package/dist/interfaces/user-group.interface.js.map +1 -0
- package/dist/interfaces/user-object-privilege.interface.d.ts +14 -0
- package/dist/interfaces/user-object-privilege.interface.d.ts.map +1 -0
- package/dist/interfaces/user-object-privilege.interface.js +3 -0
- package/dist/interfaces/user-object-privilege.interface.js.map +1 -0
- package/dist/interfaces/user-privilege.interface.d.ts +11 -0
- package/dist/interfaces/user-privilege.interface.d.ts.map +1 -0
- package/dist/interfaces/user-privilege.interface.js +3 -0
- package/dist/interfaces/user-privilege.interface.js.map +1 -0
- package/dist/interfaces/user-session.interface.d.ts +5 -0
- package/dist/interfaces/user-session.interface.d.ts.map +1 -0
- package/dist/interfaces/user-session.interface.js +3 -0
- package/dist/interfaces/user-session.interface.js.map +1 -0
- package/dist/interfaces/user-system-access.interface.d.ts +11 -0
- package/dist/interfaces/user-system-access.interface.d.ts.map +1 -0
- package/dist/interfaces/user-system-access.interface.js +3 -0
- package/dist/interfaces/user-system-access.interface.js.map +1 -0
- package/dist/models/api-key-entity.d.ts +22 -0
- package/dist/models/api-key-entity.d.ts.map +1 -0
- package/dist/models/api-key-entity.js +125 -0
- package/dist/models/api-key-entity.js.map +1 -0
- package/dist/models/building.entity.d.ts +30 -0
- package/dist/models/building.entity.d.ts.map +1 -0
- package/dist/models/building.entity.js +216 -0
- package/dist/models/building.entity.js.map +1 -0
- package/dist/models/group-object-privilege.entity.d.ts +22 -0
- package/dist/models/group-object-privilege.entity.d.ts.map +1 -0
- package/dist/models/group-object-privilege.entity.js +114 -0
- package/dist/models/group-object-privilege.entity.js.map +1 -0
- package/dist/models/group-privilege.entity.d.ts +19 -0
- package/dist/models/group-privilege.entity.d.ts.map +1 -0
- package/dist/models/group-privilege.entity.js +99 -0
- package/dist/models/group-privilege.entity.js.map +1 -0
- package/dist/models/group-reporting-user.entity.d.ts +18 -0
- package/dist/models/group-reporting-user.entity.d.ts.map +1 -0
- package/dist/models/group-reporting-user.entity.js +117 -0
- package/dist/models/group-reporting-user.entity.js.map +1 -0
- package/dist/models/group-system-access.entity.d.ts +19 -0
- package/dist/models/group-system-access.entity.d.ts.map +1 -0
- package/dist/models/group-system-access.entity.js +102 -0
- package/dist/models/group-system-access.entity.js.map +1 -0
- package/dist/models/group.entity.d.ts +33 -0
- package/dist/models/group.entity.d.ts.map +1 -0
- package/dist/models/group.entity.js +157 -0
- package/dist/models/group.entity.js.map +1 -0
- package/dist/models/login-history.entity.d.ts +15 -0
- package/dist/models/login-history.entity.d.ts.map +1 -0
- package/dist/models/login-history.entity.js +81 -0
- package/dist/models/login-history.entity.js.map +1 -0
- package/dist/models/staff.entity.d.ts +19 -0
- package/dist/models/staff.entity.d.ts.map +1 -0
- package/dist/models/staff.entity.js +113 -0
- package/dist/models/staff.entity.js.map +1 -0
- package/dist/models/system-privilege.entity.d.ts +19 -0
- package/dist/models/system-privilege.entity.d.ts.map +1 -0
- package/dist/models/system-privilege.entity.js +111 -0
- package/dist/models/system-privilege.entity.js.map +1 -0
- package/dist/models/system.entity.d.ts +26 -0
- package/dist/models/system.entity.d.ts.map +1 -0
- package/dist/models/system.entity.js +139 -0
- package/dist/models/system.entity.js.map +1 -0
- package/dist/models/user-group.entity.d.ts +20 -0
- package/dist/models/user-group.entity.d.ts.map +1 -0
- package/dist/models/user-group.entity.js +114 -0
- package/dist/models/user-group.entity.js.map +1 -0
- package/dist/models/user-object-privilege.entity.d.ts +21 -0
- package/dist/models/user-object-privilege.entity.d.ts.map +1 -0
- package/dist/models/user-object-privilege.entity.js +113 -0
- package/dist/models/user-object-privilege.entity.js.map +1 -0
- package/dist/models/user-privilege.entity.d.ts +18 -0
- package/dist/models/user-privilege.entity.d.ts.map +1 -0
- package/dist/models/user-privilege.entity.js +99 -0
- package/dist/models/user-privilege.entity.js.map +1 -0
- package/dist/models/user-system-access.entity.d.ts +18 -0
- package/dist/models/user-system-access.entity.d.ts.map +1 -0
- package/dist/models/user-system-access.entity.js +108 -0
- package/dist/models/user-system-access.entity.js.map +1 -0
- package/dist/models/user.entity.d.ts +41 -0
- package/dist/models/user.entity.d.ts.map +1 -0
- package/dist/models/user.entity.js +218 -0
- package/dist/models/user.entity.js.map +1 -0
- package/dist/redis-client/__mocks__/jest-initial-setup.d.ts +2 -0
- package/dist/redis-client/__mocks__/jest-initial-setup.d.ts.map +1 -0
- package/dist/redis-client/__mocks__/jest-initial-setup.js +8 -0
- package/dist/redis-client/__mocks__/jest-initial-setup.js.map +1 -0
- package/dist/redis-client/__mocks__/redis-mock.d.ts +3 -0
- package/dist/redis-client/__mocks__/redis-mock.d.ts.map +1 -0
- package/dist/redis-client/__mocks__/redis-mock.js +56 -0
- package/dist/redis-client/__mocks__/redis-mock.js.map +1 -0
- package/dist/redis-client/index.d.ts +2 -0
- package/dist/redis-client/index.d.ts.map +1 -0
- package/dist/redis-client/index.js +18 -0
- package/dist/redis-client/index.js.map +1 -0
- package/dist/redis-client/redis.service.d.ts +10 -0
- package/dist/redis-client/redis.service.d.ts.map +1 -0
- package/dist/redis-client/redis.service.js +69 -0
- package/dist/redis-client/redis.service.js.map +1 -0
- package/dist/session/index.d.ts +3 -0
- package/dist/session/index.d.ts.map +1 -0
- package/dist/session/index.js +19 -0
- package/dist/session/index.js.map +1 -0
- package/dist/session/interfaces/index.d.ts +2 -0
- package/dist/session/interfaces/index.d.ts.map +1 -0
- package/dist/session/interfaces/index.js +18 -0
- package/dist/session/interfaces/index.js.map +1 -0
- package/dist/session/interfaces/session-service.interface.d.ts +10 -0
- package/dist/session/interfaces/session-service.interface.d.ts.map +1 -0
- package/dist/session/interfaces/session-service.interface.js +3 -0
- package/dist/session/interfaces/session-service.interface.js.map +1 -0
- package/dist/session/session.service.d.ts +14 -0
- package/dist/session/session.service.d.ts.map +1 -0
- package/dist/session/session.service.js +73 -0
- package/dist/session/session.service.js.map +1 -0
- package/dist/src/components/login-history/index.d.ts +0 -1
- package/dist/src/components/login-history/index.js +0 -1
- package/dist/src/components/login-history/index.js.map +1 -1
- package/dist/src/components/login-history/login-history.repository.d.ts +2 -2
- package/dist/src/components/login-history/login-history.repository.js.map +1 -1
- package/dist/src/components/login-user/user.js +1 -1
- package/dist/src/components/login-user/user.js.map +1 -1
- package/dist/src/components/user-system-access/user-system-access.js +1 -1
- package/dist/src/components/user-system-access/user-system-access.js.map +1 -1
- package/dist/src/models/login-history.entity.d.ts +2 -2
- package/dist/src/models/login-history.entity.js +13 -13
- package/dist/src/models/login-history.entity.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/auth-context.d.ts +7 -0
- package/dist/types/auth-context.d.ts.map +1 -0
- package/dist/types/auth-context.js +3 -0
- package/dist/types/auth-context.js.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +18 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +2 -2
- package/src/components/login-history/index.ts +0 -1
- package/src/components/login-history/login-history.repository.ts +4 -4
- package/src/components/login-user/user.ts +1 -1
- package/src/components/user-system-access/user-system-access.ts +1 -1
- package/src/models/login-history.entity.ts +2 -2
- package/dist/src/components/login-history/login-history.d.ts +0 -23
- package/dist/src/components/login-history/login-history.js +0 -84
- package/dist/src/components/login-history/login-history.js.map +0 -1
- package/dist/src/interfaces/login-history-search-attr.interface.d.ts +0 -8
- package/dist/src/interfaces/login-history-search-attr.interface.js.map +0 -1
- package/dist/src/interfaces/login-history.interface.d.ts +0 -11
- package/dist/src/interfaces/login-history.interface.js.map +0 -1
- package/src/components/login-history/login-history.ts +0 -119
- package/src/interfaces/login-history-search-attr.interface.ts +0 -8
- package/src/interfaces/login-history.interface.ts +0 -11
@@ -0,0 +1,1337 @@
|
|
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
|