rez_core 6.5.32 → 6.5.33
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/.claude/settings.local.json +26 -0
- package/.idea/250218_nodejs_core.iml +9 -0
- package/.idea/codeStyles/Project.xml +59 -0
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/copilot.data.migration.agent.xml +6 -0
- package/.idea/copilot.data.migration.ask.xml +6 -0
- package/.idea/copilot.data.migration.ask2agent.xml +6 -0
- package/.idea/copilot.data.migration.edit.xml +6 -0
- package/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/.idea/misc.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/prettier.xml +6 -0
- package/.idea/vcs.xml +6 -0
- package/dist/app.module.js +3 -3
- package/dist/app.module.js.map +1 -1
- package/dist/constant/status.constant.d.ts +4 -0
- package/dist/constant/status.constant.js +9 -0
- package/dist/constant/status.constant.js.map +1 -0
- package/dist/core.module.js +60 -38
- package/dist/core.module.js.map +1 -1
- package/dist/module/auth/strategies/jwt.strategy.d.ts +2 -1
- package/dist/module/auth/strategies/jwt.strategy.js +3 -2
- package/dist/module/auth/strategies/jwt.strategy.js.map +1 -1
- package/dist/module/dashboard/dashboard.module.js +1 -1
- package/dist/module/dashboard/dashboard.module.js.map +1 -1
- package/dist/module/dashboard/service/dashboard.service.js +2 -3
- package/dist/module/dashboard/service/dashboard.service.js.map +1 -1
- package/dist/module/enterprise/controller/enterprise.controller.d.ts +12 -0
- package/dist/module/enterprise/controller/enterprise.controller.js +57 -0
- package/dist/module/enterprise/controller/enterprise.controller.js.map +1 -0
- package/dist/module/enterprise/controller/meta.controller.d.ts +9 -0
- package/dist/module/enterprise/controller/meta.controller.js +43 -0
- package/dist/module/enterprise/controller/meta.controller.js.map +1 -0
- package/dist/module/enterprise/controller/organization.controller.d.ts +12 -4
- package/dist/module/enterprise/controller/organization.controller.js +64 -8
- package/dist/module/enterprise/controller/organization.controller.js.map +1 -1
- package/dist/module/enterprise/enterprise.module.js +10 -15
- package/dist/module/enterprise/enterprise.module.js.map +1 -1
- package/dist/module/enterprise/entity/enterprise.entity.d.ts +1 -3
- package/dist/module/enterprise/entity/enterprise.entity.js +4 -12
- package/dist/module/enterprise/entity/enterprise.entity.js.map +1 -1
- package/dist/module/enterprise/entity/organization-app-mapping.entity.d.ts +6 -1
- package/dist/module/enterprise/entity/organization-app-mapping.entity.js +21 -4
- package/dist/module/enterprise/entity/organization-app-mapping.entity.js.map +1 -1
- package/dist/module/enterprise/entity/organization.entity.d.ts +3 -18
- package/dist/module/enterprise/entity/organization.entity.js +8 -74
- package/dist/module/enterprise/entity/organization.entity.js.map +1 -1
- package/dist/module/enterprise/repository/enterprise.repository.d.ts +4 -2
- package/dist/module/enterprise/repository/enterprise.repository.js +19 -4
- package/dist/module/enterprise/repository/enterprise.repository.js.map +1 -1
- package/dist/module/enterprise/service/brand-profile.service.d.ts +0 -0
- package/dist/module/enterprise/service/brand-profile.service.js +1 -0
- package/dist/module/enterprise/service/brand-profile.service.js.map +1 -0
- package/dist/module/enterprise/service/brand.service.d.ts +0 -3
- package/dist/module/enterprise/service/brand.service.js +0 -17
- package/dist/module/enterprise/service/brand.service.js.map +1 -1
- package/dist/module/enterprise/service/enterprise.service.d.ts +2 -2
- package/dist/module/enterprise/service/enterprise.service.js +4 -4
- package/dist/module/enterprise/service/enterprise.service.js.map +1 -1
- package/dist/module/enterprise/service/organization.service.d.ts +4 -4
- package/dist/module/enterprise/service/organization.service.js +101 -24
- package/dist/module/enterprise/service/organization.service.js.map +1 -1
- package/dist/module/enterprise/service/populate-meta.service.d.ts +9 -0
- package/dist/module/{meta → enterprise}/service/populate-meta.service.js +2 -8
- package/dist/module/enterprise/service/populate-meta.service.js.map +1 -0
- package/dist/module/enterprise/service/school.service.d.ts +0 -0
- package/dist/module/enterprise/service/school.service.js +1 -0
- package/dist/module/enterprise/service/school.service.js.map +1 -0
- package/dist/module/entity_json/controller/entity_json.controller.d.ts +9 -2
- package/dist/module/entity_json/controller/entity_json.controller.js.map +1 -1
- package/dist/module/entity_json/entity/entityJson.entity.d.ts +1 -2
- package/dist/module/entity_json/entity/entityJson.entity.js +1 -5
- package/dist/module/entity_json/entity/entityJson.entity.js.map +1 -1
- package/dist/module/entity_json/entity_json.module.js +2 -7
- package/dist/module/entity_json/entity_json.module.js.map +1 -1
- package/dist/module/entity_json/service/entity_json.service.d.ts +10 -2
- package/dist/module/entity_json/service/entity_json.service.js +23 -98
- package/dist/module/entity_json/service/entity_json.service.js.map +1 -1
- package/dist/module/filter/controller/filter.controller.d.ts +0 -12
- package/dist/module/filter/controller/filter.controller.js +1 -1
- package/dist/module/filter/controller/filter.controller.js.map +1 -1
- package/dist/module/filter/filter.module.js +2 -11
- package/dist/module/filter/filter.module.js.map +1 -1
- package/dist/module/filter/service/filter.service.d.ts +2 -38
- package/dist/module/filter/service/filter.service.js +50 -43
- package/dist/module/filter/service/filter.service.js.map +1 -1
- package/dist/module/filter/service/saved-filter.service.d.ts +2 -3
- package/dist/module/filter/service/saved-filter.service.js +18 -14
- package/dist/module/filter/service/saved-filter.service.js.map +1 -1
- package/dist/module/integration/service/integration.service.d.ts +0 -1
- package/dist/module/integration/service/integration.service.js +1 -2
- package/dist/module/integration/service/integration.service.js.map +1 -1
- package/dist/module/integration/service/wrapper.service.js +0 -1
- package/dist/module/integration/service/wrapper.service.js.map +1 -1
- package/dist/module/layout/controller/layout.controller.d.ts +1 -3
- package/dist/module/layout/controller/layout.controller.js +3 -7
- package/dist/module/layout/controller/layout.controller.js.map +1 -1
- package/dist/module/layout/entity/header-section.entity.d.ts +0 -2
- package/dist/module/layout/entity/header-section.entity.js +0 -8
- package/dist/module/layout/entity/header-section.entity.js.map +1 -1
- package/dist/module/layout/layout.module.js +1 -2
- package/dist/module/layout/layout.module.js.map +1 -1
- package/dist/module/layout/repository/header-section.repository.d.ts +0 -1
- package/dist/module/layout/repository/header-section.repository.js +0 -5
- package/dist/module/layout/repository/header-section.repository.js.map +1 -1
- package/dist/module/layout/service/header-section.service.d.ts +1 -1
- package/dist/module/layout/service/header-section.service.js +1 -1
- package/dist/module/layout/service/header-section.service.js.map +1 -1
- package/dist/module/linked_attributes/controller/linked_attributes.controller.d.ts +0 -41
- package/dist/module/linked_attributes/controller/linked_attributes.controller.js +0 -90
- package/dist/module/linked_attributes/controller/linked_attributes.controller.js.map +1 -1
- package/dist/module/linked_attributes/linked_attributes.module.js +1 -8
- package/dist/module/linked_attributes/linked_attributes.module.js.map +1 -1
- package/dist/module/linked_attributes/service/linked_attributes.service.d.ts +1 -65
- package/dist/module/linked_attributes/service/linked_attributes.service.js +2 -287
- package/dist/module/linked_attributes/service/linked_attributes.service.js.map +1 -1
- package/dist/module/listmaster/service/list-master.service.js +1 -8
- package/dist/module/listmaster/service/list-master.service.js.map +1 -1
- package/dist/module/meta/controller/meta.controller.d.ts +1 -6
- package/dist/module/meta/controller/meta.controller.js +1 -19
- package/dist/module/meta/controller/meta.controller.js.map +1 -1
- package/dist/module/meta/entity/app-master.entity.d.ts +8 -4
- package/dist/module/meta/entity/app-master.entity.js +30 -12
- package/dist/module/meta/entity/app-master.entity.js.map +1 -1
- package/dist/module/meta/entity/entity-master.entity.d.ts +0 -1
- package/dist/module/meta/entity/entity-master.entity.js +1 -8
- package/dist/module/meta/entity/entity-master.entity.js.map +1 -1
- package/dist/module/meta/entity.module.js +2 -5
- package/dist/module/meta/entity.module.js.map +1 -1
- package/dist/module/meta/repository/app-master.repository.js +1 -1
- package/dist/module/meta/repository/app-master.repository.js.map +1 -1
- package/dist/module/meta/service/attribute-master.service.d.ts +1 -6
- package/dist/module/meta/service/attribute-master.service.js +2 -22
- package/dist/module/meta/service/attribute-master.service.js.map +1 -1
- package/dist/module/meta/service/entity-master.service.js +0 -1
- package/dist/module/meta/service/entity-master.service.js.map +1 -1
- package/dist/module/meta/service/entity-relation.service.d.ts +3 -4
- package/dist/module/meta/service/entity-relation.service.js +4 -10
- package/dist/module/meta/service/entity-relation.service.js.map +1 -1
- package/dist/module/meta/service/entity-service-impl.service.d.ts +1 -1
- package/dist/module/meta/service/entity-service-impl.service.js +10 -14
- package/dist/module/meta/service/entity-service-impl.service.js.map +1 -1
- package/dist/module/meta/service/entity-table.service.d.ts +4 -5
- package/dist/module/meta/service/entity-table.service.js +25 -25
- package/dist/module/meta/service/entity-table.service.js.map +1 -1
- package/dist/module/meta/service/resolver.service.d.ts +1 -1
- package/dist/module/meta/service/resolver.service.js +3 -6
- package/dist/module/meta/service/resolver.service.js.map +1 -1
- package/dist/module/module/controller/menu.controller.js +2 -2
- package/dist/module/module/controller/menu.controller.js.map +1 -1
- package/dist/module/module/controller/module-access.controller.d.ts +3 -4
- package/dist/module/module/controller/module-access.controller.js +15 -10
- package/dist/module/module/controller/module-access.controller.js.map +1 -1
- package/dist/module/module/entity/menu.entity.d.ts +6 -4
- package/dist/module/module/entity/menu.entity.js +16 -12
- package/dist/module/module/entity/menu.entity.js.map +1 -1
- package/dist/module/module/entity/module-access.entity.d.ts +15 -0
- package/dist/module/module/entity/module-access.entity.js +50 -0
- package/dist/module/module/entity/module-access.entity.js.map +1 -1
- package/dist/module/module/entity/module-action.entity.d.ts +4 -2
- package/dist/module/module/entity/module-action.entity.js +11 -6
- package/dist/module/module/entity/module-action.entity.js.map +1 -1
- package/dist/module/module/entity/module.entity.d.ts +3 -5
- package/dist/module/module/entity/module.entity.js +8 -18
- package/dist/module/module/entity/module.entity.js.map +1 -1
- package/dist/module/module/module.module.d.ts +1 -1
- package/dist/module/module/module.module.js +5 -7
- package/dist/module/module/module.module.js.map +1 -1
- package/dist/module/module/repository/menu.repository.d.ts +4 -4
- package/dist/module/module/repository/menu.repository.js +17 -27
- package/dist/module/module/repository/menu.repository.js.map +1 -1
- package/dist/module/module/repository/module-access.repository.d.ts +7 -7
- package/dist/module/module/repository/module-access.repository.js +86 -48
- package/dist/module/module/repository/module-access.repository.js.map +1 -1
- package/dist/module/module/service/menu.service.d.ts +3 -5
- package/dist/module/module/service/menu.service.js +9 -12
- package/dist/module/module/service/menu.service.js.map +1 -1
- package/dist/module/module/service/module-access.service.d.ts +8 -11
- package/dist/module/module/service/module-access.service.js +24 -26
- package/dist/module/module/service/module-access.service.js.map +1 -1
- package/dist/module/notification/entity/notification.entity.d.ts +17 -2
- package/dist/module/notification/entity/notification.entity.js +68 -2
- package/dist/module/notification/entity/notification.entity.js.map +1 -1
- package/dist/module/notification/notification.module.js +0 -2
- package/dist/module/notification/notification.module.js.map +1 -1
- package/dist/module/notification/service/notification.service.d.ts +1 -3
- package/dist/module/notification/service/notification.service.js +2 -5
- package/dist/module/notification/service/notification.service.js.map +1 -1
- package/dist/module/notification/service/otp.service.js +0 -1
- package/dist/module/notification/service/otp.service.js.map +1 -1
- package/dist/module/user/controller/login.controller.d.ts +1 -3
- package/dist/module/user/controller/login.controller.js +2 -6
- package/dist/module/user/controller/login.controller.js.map +1 -1
- package/dist/module/user/controller/user.controller.d.ts +0 -2
- package/dist/module/user/controller/user.controller.js +0 -13
- package/dist/module/user/controller/user.controller.js.map +1 -1
- package/dist/module/user/dto/create-user.dto.d.ts +6 -3
- package/dist/module/user/dto/create-user.dto.js +17 -11
- package/dist/module/user/dto/create-user.dto.js.map +1 -1
- package/dist/module/user/entity/role.entity.d.ts +18 -6
- package/dist/module/user/entity/role.entity.js +64 -19
- package/dist/module/user/entity/role.entity.js.map +1 -1
- package/dist/module/user/entity/user-role-mapping.entity.d.ts +10 -0
- package/dist/module/user/entity/user-role-mapping.entity.js +33 -1
- package/dist/module/user/entity/user-role-mapping.entity.js.map +1 -1
- package/dist/module/user/entity/user-session.entity.d.ts +0 -2
- package/dist/module/user/entity/user-session.entity.js +2 -20
- package/dist/module/user/entity/user-session.entity.js.map +1 -1
- package/dist/module/user/entity/user.entity.d.ts +17 -5
- package/dist/module/user/entity/user.entity.js +61 -15
- package/dist/module/user/entity/user.entity.js.map +1 -1
- package/dist/module/user/repository/role.repository.d.ts +6 -2
- package/dist/module/user/repository/role.repository.js +16 -8
- package/dist/module/user/repository/role.repository.js.map +1 -1
- package/dist/module/user/repository/user-role-mapping.repository.d.ts +1 -0
- package/dist/module/user/repository/user-role-mapping.repository.js +3 -0
- package/dist/module/user/repository/user-role-mapping.repository.js.map +1 -1
- package/dist/module/user/repository/user.repository.d.ts +4 -2
- package/dist/module/user/repository/user.repository.js +19 -7
- package/dist/module/user/repository/user.repository.js.map +1 -1
- package/dist/module/user/repository/userSession.repository.d.ts +1 -0
- package/dist/module/user/repository/userSession.repository.js +3 -0
- package/dist/module/user/repository/userSession.repository.js.map +1 -1
- package/dist/module/user/service/login.service.d.ts +3 -5
- package/dist/module/user/service/login.service.js +43 -42
- package/dist/module/user/service/login.service.js.map +1 -1
- package/dist/module/user/service/role.service.d.ts +24 -11
- package/dist/module/user/service/role.service.js +42 -38
- package/dist/module/user/service/role.service.js.map +1 -1
- package/dist/module/user/service/user-role-mapping.service.d.ts +2 -0
- package/dist/module/user/service/user-role-mapping.service.js +6 -0
- package/dist/module/user/service/user-role-mapping.service.js.map +1 -1
- package/dist/module/user/service/user-session.service.d.ts +3 -4
- package/dist/module/user/service/user-session.service.js +10 -11
- package/dist/module/user/service/user-session.service.js.map +1 -1
- package/dist/module/user/service/user.service.d.ts +29 -22
- package/dist/module/user/service/user.service.js +44 -59
- package/dist/module/user/service/user.service.js.map +1 -1
- package/dist/module/user/user.module.js +1 -7
- package/dist/module/user/user.module.js.map +1 -1
- package/dist/module/workflow/repository/action-data.repository.d.ts +1 -1
- package/dist/module/workflow/repository/action-data.repository.js +6 -8
- package/dist/module/workflow/repository/action-data.repository.js.map +1 -1
- package/dist/module/workflow/repository/action.repository.d.ts +1 -1
- package/dist/module/workflow/repository/action.repository.js +10 -10
- package/dist/module/workflow/repository/action.repository.js.map +1 -1
- package/dist/module/workflow/repository/form-master.repository.d.ts +1 -1
- package/dist/module/workflow/repository/form-master.repository.js +2 -2
- package/dist/module/workflow/repository/form-master.repository.js.map +1 -1
- package/dist/module/workflow/service/action-data.service.js +1 -2
- package/dist/module/workflow/service/action-data.service.js.map +1 -1
- package/dist/module/workflow/service/action.service.js +2 -2
- package/dist/module/workflow/service/action.service.js.map +1 -1
- package/dist/module/workflow/service/comm-template.service.js +0 -2
- package/dist/module/workflow/service/comm-template.service.js.map +1 -1
- package/dist/module/workflow/service/entity-modification.service.js +0 -1
- package/dist/module/workflow/service/entity-modification.service.js.map +1 -1
- package/dist/module/workflow/service/form-master.service.js +2 -2
- package/dist/module/workflow/service/form-master.service.js.map +1 -1
- package/dist/module/workflow/service/populate-workflow.service.d.ts +1 -1
- package/dist/module/workflow/service/populate-workflow.service.js +1 -1
- package/dist/module/workflow/service/populate-workflow.service.js.map +1 -1
- package/dist/module/workflow/service/task.service.js +0 -3
- package/dist/module/workflow/service/task.service.js.map +1 -1
- package/dist/module/workflow/service/workflow-meta.service.js +2 -7
- package/dist/module/workflow/service/workflow-meta.service.js.map +1 -1
- package/dist/module/workflow/service/workflow.service.js +2 -2
- package/dist/module/workflow/service/workflow.service.js.map +1 -1
- package/dist/module/workflow/workflow.module.js +2 -0
- package/dist/module/workflow/workflow.module.js.map +1 -1
- package/dist/module/workflow-automation/service/workflow-automation.service.js +11 -6
- package/dist/module/workflow-automation/service/workflow-automation.service.js.map +1 -1
- package/dist/module/workflow-automation/workflow-automation.module.js +3 -1
- package/dist/module/workflow-automation/workflow-automation.module.js.map +1 -1
- package/dist/module/workflow-schedule/service/workflow-schedule.service.js +0 -2
- package/dist/module/workflow-schedule/service/workflow-schedule.service.js.map +1 -1
- package/dist/table.config.d.ts +2 -4
- package/dist/table.config.js +0 -2
- package/dist/table.config.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/server.log +850 -0
- package/src/app.module.ts +5 -5
- package/src/constant/status.constant.ts +4 -0
- package/src/core.module.ts +55 -44
- package/src/module/auth/strategies/jwt.strategy.ts +4 -2
- package/src/module/dashboard/dashboard.module.ts +3 -3
- package/src/module/dashboard/service/dashboard.service.ts +2 -3
- package/src/module/enterprise/controller/enterprise.controller.ts +40 -0
- package/src/module/enterprise/controller/meta.controller.ts +23 -0
- package/src/module/enterprise/controller/organization.controller.ts +60 -4
- package/src/module/enterprise/enterprise.module.ts +16 -18
- package/src/module/enterprise/entity/enterprise.entity.ts +5 -11
- package/src/module/enterprise/entity/organization-app-mapping.entity.ts +18 -4
- package/src/module/enterprise/entity/organization.entity.ts +9 -59
- package/src/module/enterprise/repository/enterprise.repository.ts +26 -4
- package/src/module/enterprise/service/brand-profile.service.ts +10 -0
- package/src/module/enterprise/service/brand.service.ts +75 -5
- package/src/module/enterprise/service/enterprise.service.ts +10 -4
- package/src/module/enterprise/service/organization.service.ts +140 -23
- package/src/module/{meta → enterprise}/service/populate-meta.service.ts +2 -5
- package/src/module/enterprise/service/school.service.ts +5 -0
- package/src/module/entity_json/controller/entity_json.controller.ts +0 -13
- package/src/module/entity_json/entity/entityJson.entity.ts +1 -4
- package/src/module/entity_json/entity_json.module.ts +5 -9
- package/src/module/entity_json/service/entity_json.service.ts +49 -233
- package/src/module/filter/controller/filter.controller.ts +3 -1
- package/src/module/filter/filter.module.ts +3 -12
- package/src/module/filter/service/filter.service.ts +73 -130
- package/src/module/filter/service/saved-filter.service.ts +26 -16
- package/src/module/integration/service/integration.service.ts +2 -6
- package/src/module/integration/service/wrapper.service.ts +0 -1
- package/src/module/layout/controller/layout.controller.ts +1 -8
- package/src/module/layout/entity/header-section.entity.ts +0 -6
- package/src/module/layout/layout.module.ts +1 -1
- package/src/module/layout/repository/header-section.repository.ts +0 -6
- package/src/module/layout/service/header-section.service.ts +1 -1
- package/src/module/linked_attributes/controller/linked_attributes.controller.ts +0 -100
- package/src/module/linked_attributes/linked_attributes.module.ts +2 -9
- package/src/module/linked_attributes/service/linked_attributes.service.ts +3 -578
- package/src/module/listmaster/service/list-master.service.ts +1 -9
- package/src/module/meta/controller/meta.controller.ts +3 -25
- package/src/module/meta/entity/app-master.entity.ts +22 -9
- package/src/module/meta/entity/entity-master.entity.ts +3 -9
- package/src/module/meta/entity.module.ts +5 -6
- package/src/module/meta/repository/app-master.repository.ts +1 -1
- package/src/module/meta/service/attribute-master.service.ts +1 -31
- package/src/module/meta/service/entity-master.service.ts +0 -1
- package/src/module/meta/service/entity-relation.service.ts +6 -10
- package/src/module/meta/service/entity-service-impl.service.ts +19 -14
- package/src/module/meta/service/entity-table.service.ts +20 -15
- package/src/module/meta/service/entity.service.ts +1 -0
- package/src/module/meta/service/resolver.service.ts +0 -4
- package/src/module/module/controller/menu.controller.ts +2 -2
- package/src/module/module/controller/module-access.controller.ts +16 -11
- package/src/module/module/entity/menu.entity.ts +14 -10
- package/src/module/module/entity/module-access.entity.ts +41 -1
- package/src/module/module/entity/module-action.entity.ts +10 -6
- package/src/module/module/entity/module.entity.ts +7 -14
- package/src/module/module/module.module.ts +2 -3
- package/src/module/module/repository/menu.repository.ts +19 -31
- package/src/module/module/repository/module-access.repository.ts +100 -63
- package/src/module/module/service/menu.service.ts +11 -13
- package/src/module/module/service/module-access.service.ts +26 -38
- package/src/module/notification/entity/notification.entity.ts +53 -3
- package/src/module/notification/notification.module.ts +0 -2
- package/src/module/notification/service/notification.service.ts +0 -1
- package/src/module/notification/service/otp.service.ts +4 -3
- package/src/module/user/controller/login.controller.ts +7 -8
- package/src/module/user/controller/user.controller.ts +0 -9
- package/src/module/user/dto/create-user.dto.ts +19 -6
- package/src/module/user/entity/role.entity.ts +59 -16
- package/src/module/user/entity/user-role-mapping.entity.ts +29 -3
- package/src/module/user/entity/user-session.entity.ts +3 -19
- package/src/module/user/entity/user.entity.ts +48 -13
- package/src/module/user/repository/role.repository.ts +24 -12
- package/src/module/user/repository/user-role-mapping.repository.ts +5 -1
- package/src/module/user/repository/user.repository.ts +28 -8
- package/src/module/user/repository/userSession.repository.ts +5 -1
- package/src/module/user/service/login.service.ts +47 -51
- package/src/module/user/service/role.service.ts +53 -60
- package/src/module/user/service/user-role-mapping.service.ts +23 -1
- package/src/module/user/service/user-session.service.ts +14 -11
- package/src/module/user/service/user.service.ts +63 -95
- package/src/module/user/user.module.ts +3 -5
- package/src/module/workflow/repository/action-data.repository.ts +6 -8
- package/src/module/workflow/repository/action.repository.ts +11 -11
- package/src/module/workflow/repository/form-master.repository.ts +2 -2
- package/src/module/workflow/service/action-data.service.ts +3 -2
- package/src/module/workflow/service/action.service.ts +2 -2
- package/src/module/workflow/service/comm-template.service.ts +0 -2
- package/src/module/workflow/service/entity-modification.service.ts +0 -1
- package/src/module/workflow/service/form-master.service.ts +2 -2
- package/src/module/workflow/service/populate-workflow.service.ts +1 -1
- package/src/module/workflow/service/task.service.ts +0 -3
- package/src/module/workflow/service/workflow-meta.service.ts +2 -7
- package/src/module/workflow/service/workflow.service.ts +2 -2
- package/src/module/workflow/workflow.module.ts +2 -0
- package/src/module/workflow-automation/service/workflow-automation.service.ts +19 -7
- package/src/module/workflow-automation/workflow-automation.module.ts +4 -3
- package/src/module/workflow-schedule/service/workflow-schedule.service.ts +0 -2
- package/src/resources/dev.properties.yaml +2 -2
- package/src/table.config.ts +0 -2
- package/dist/migrations/1732612800000-AddEntityJsonGinIndex.d.ts +0 -6
- package/dist/migrations/1732612800000-AddEntityJsonGinIndex.js +0 -32
- package/dist/migrations/1732612800000-AddEntityJsonGinIndex.js.map +0 -1
- package/dist/module/filter/service/flatjson-filter.service.d.ts +0 -32
- package/dist/module/filter/service/flatjson-filter.service.js +0 -632
- package/dist/module/filter/service/flatjson-filter.service.js.map +0 -1
- package/dist/module/linked_attributes/dto/create-linked-attribute-smart.dto.d.ts +0 -13
- package/dist/module/linked_attributes/dto/create-linked-attribute-smart.dto.js +0 -64
- package/dist/module/linked_attributes/dto/create-linked-attribute-smart.dto.js.map +0 -1
- package/dist/module/meta/service/populate-meta.service.d.ts +0 -13
- package/dist/module/meta/service/populate-meta.service.js.map +0 -1
- package/src/migrations/1732612800000-AddEntityJsonGinIndex.ts +0 -41
- package/src/module/entity_json/docs/FlatJson_Filterin_System.md +0 -2804
- package/src/module/filter/service/flatjson-filter.service.ts +0 -903
- package/src/module/filter/test/flatjson-filter.service.spec.ts +0 -415
- package/src/module/linked_attributes/dto/create-linked-attribute-smart.dto.ts +0 -54
- package/src/module/linked_attributes/test/linked-attributes.service.spec.ts +0 -244
|
@@ -1,903 +0,0 @@
|
|
|
1
|
-
import { Injectable, BadRequestException, Inject, forwardRef } from '@nestjs/common';
|
|
2
|
-
import { EntityManager, SelectQueryBuilder } from 'typeorm';
|
|
3
|
-
import { EntityMasterService } from 'src/module/meta/service/entity-master.service';
|
|
4
|
-
import { AttributeMasterService } from 'src/module/meta/service/attribute-master.service';
|
|
5
|
-
import { ResolverService } from 'src/module/meta/service/resolver.service';
|
|
6
|
-
import { LoggingService } from 'src/utils/service/loggingUtil.service';
|
|
7
|
-
import { ConfigService } from '@nestjs/config';
|
|
8
|
-
import {
|
|
9
|
-
FilterRequestDto,
|
|
10
|
-
FilterCondition,
|
|
11
|
-
SortConfig,
|
|
12
|
-
} from '../dto/filter-request.dto';
|
|
13
|
-
import { EntityJson } from 'src/module/entity_json/entity/entityJson.entity';
|
|
14
|
-
import { SavedFilterRepositoryService } from '../repository/saved-filter.repository';
|
|
15
|
-
import { EntityJSONService } from 'src/module/entity_json/service/entity_json.service';
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* JSONB query condition structure
|
|
19
|
-
*/
|
|
20
|
-
interface JsonbCondition {
|
|
21
|
-
query: string;
|
|
22
|
-
params: Record<string, any>;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
@Injectable()
|
|
26
|
-
export class FlatjsonFilterService {
|
|
27
|
-
constructor(
|
|
28
|
-
private readonly entityManager: EntityManager,
|
|
29
|
-
@Inject(forwardRef(() => EntityMasterService))
|
|
30
|
-
private readonly entityMasterService: EntityMasterService,
|
|
31
|
-
@Inject(forwardRef(() => AttributeMasterService))
|
|
32
|
-
private readonly attributeMasterService: AttributeMasterService,
|
|
33
|
-
@Inject(forwardRef(() => ResolverService))
|
|
34
|
-
private readonly resolverService: ResolverService,
|
|
35
|
-
@Inject(forwardRef(() => LoggingService))
|
|
36
|
-
private readonly loggingService: LoggingService,
|
|
37
|
-
private readonly configService: ConfigService,
|
|
38
|
-
@Inject(forwardRef(() => SavedFilterRepositoryService))
|
|
39
|
-
private readonly savedFilterRepositoryService: SavedFilterRepositoryService,
|
|
40
|
-
@Inject(forwardRef(() => EntityJSONService))
|
|
41
|
-
private readonly entityJsonService: EntityJSONService,
|
|
42
|
-
) {}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Main filtering method - queries frm_entity_json table
|
|
46
|
-
*/
|
|
47
|
-
async applyFlatjsonFilter(dto: FilterRequestDto): Promise<any> {
|
|
48
|
-
const {
|
|
49
|
-
entity_type,
|
|
50
|
-
quickFilter = [],
|
|
51
|
-
savedFilterCode,
|
|
52
|
-
attributeFilter = [],
|
|
53
|
-
sortby = [],
|
|
54
|
-
tabs,
|
|
55
|
-
page = 1,
|
|
56
|
-
size = 20,
|
|
57
|
-
loggedInUser,
|
|
58
|
-
} = dto;
|
|
59
|
-
|
|
60
|
-
await this.loggingService.log(
|
|
61
|
-
'info',
|
|
62
|
-
'FlatjsonFilterService',
|
|
63
|
-
'applyFlatjsonFilter',
|
|
64
|
-
`Filtering entity: ${entity_type}`,
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
// Step 1: Load attribute metadata for this entity
|
|
68
|
-
let attributes =
|
|
69
|
-
await this.entityJsonService.getAttributeForFlatJSON(
|
|
70
|
-
entity_type,
|
|
71
|
-
loggedInUser,
|
|
72
|
-
'filter_attribute',
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
if (!attributes?.length) {
|
|
76
|
-
attributes =
|
|
77
|
-
await this.attributeMasterService.findAttributesByMappedEntityType(
|
|
78
|
-
entity_type,
|
|
79
|
-
loggedInUser,
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
attributes = attributes ?? [];
|
|
84
|
-
|
|
85
|
-
const attributeMetaMap: Record<string, any> = {};
|
|
86
|
-
attributes.forEach((attr) => {
|
|
87
|
-
attributeMetaMap[attr.flat_json_key] = attr;
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
await this.loggingService.log(
|
|
91
|
-
'debug',
|
|
92
|
-
'FlatjsonFilterService',
|
|
93
|
-
'applyFlatjsonFilter',
|
|
94
|
-
`Loaded ${attributes.length} attributes`,
|
|
95
|
-
);
|
|
96
|
-
|
|
97
|
-
// Step 2: Merge filters (quickFilter + savedFilter + attributeFilter)
|
|
98
|
-
let allFilters: FilterCondition[] = [...quickFilter, ...attributeFilter];
|
|
99
|
-
|
|
100
|
-
if (savedFilterCode) {
|
|
101
|
-
const savedFilterDetails =
|
|
102
|
-
await this.savedFilterRepositoryService.getDetailsByCode(
|
|
103
|
-
savedFilterCode,
|
|
104
|
-
);
|
|
105
|
-
allFilters = [...allFilters, ...savedFilterDetails];
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
await this.loggingService.log(
|
|
109
|
-
'debug',
|
|
110
|
-
'FlatjsonFilterService',
|
|
111
|
-
'applyFlatjsonFilter',
|
|
112
|
-
`Total filters: ${allFilters.length}`,
|
|
113
|
-
);
|
|
114
|
-
|
|
115
|
-
// Step 3: Build JSONB conditions
|
|
116
|
-
const jsonbConditions = this.buildJsonbConditions(
|
|
117
|
-
allFilters,
|
|
118
|
-
attributeMetaMap,
|
|
119
|
-
);
|
|
120
|
-
|
|
121
|
-
// Step 4: Build base query
|
|
122
|
-
const qb = this.entityManager
|
|
123
|
-
.getRepository(EntityJson)
|
|
124
|
-
.createQueryBuilder('ej')
|
|
125
|
-
.where('ej.entity_type = :entity_type', { entity_type })
|
|
126
|
-
.andWhere('ej.organization_id = :orgId', {
|
|
127
|
-
orgId: loggedInUser.organization_id,
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
// Step 5: Apply JSONB conditions
|
|
131
|
-
jsonbConditions.forEach((condition, index) => {
|
|
132
|
-
qb.andWhere(condition.query, condition.params);
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
// Step 6: Apply tab filter if provided
|
|
136
|
-
if (tabs?.columnName && tabs?.value) {
|
|
137
|
-
const tabMeta = attributeMetaMap[tabs.columnName];
|
|
138
|
-
if (tabMeta) {
|
|
139
|
-
const flatJsonKey =
|
|
140
|
-
tabMeta.flat_json_key ||
|
|
141
|
-
`${entity_type}__${tabs.columnName}`;
|
|
142
|
-
qb.andWhere(`json_data->>'${flatJsonKey}' = :tabValue`, {
|
|
143
|
-
tabValue: tabs.value,
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
// Step 7: Get tab counts if needed (before pagination)
|
|
149
|
-
let tabCounts: any[] = [];
|
|
150
|
-
if (tabs?.columnName && !tabs?.value) {
|
|
151
|
-
const tabMeta = attributeMetaMap[tabs.columnName];
|
|
152
|
-
if (tabMeta) {
|
|
153
|
-
const flatJsonKey =
|
|
154
|
-
tabMeta.flat_json_key ||
|
|
155
|
-
`${entity_type}__${tabs.columnName}`;
|
|
156
|
-
tabCounts = await this.getJsonbTabCounts(
|
|
157
|
-
entity_type,
|
|
158
|
-
flatJsonKey,
|
|
159
|
-
jsonbConditions,
|
|
160
|
-
);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
// Step 8: Apply sorting
|
|
165
|
-
if (sortby && sortby.length > 0) {
|
|
166
|
-
this.applyJsonbSorting(qb, sortby, attributeMetaMap);
|
|
167
|
-
} else {
|
|
168
|
-
// Default sort by created_date DESC
|
|
169
|
-
qb.orderBy('ej.created_at', 'DESC');
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
// Step 9: Get total count (before pagination)
|
|
173
|
-
const totalCount = await qb.getCount();
|
|
174
|
-
|
|
175
|
-
// Step 10: Apply pagination
|
|
176
|
-
if (page && size) {
|
|
177
|
-
const skip = (page - 1) * size;
|
|
178
|
-
qb.skip(skip).take(size);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
const results = await qb.getMany();
|
|
182
|
-
|
|
183
|
-
await this.loggingService.log(
|
|
184
|
-
'info',
|
|
185
|
-
'FlatjsonFilterService',
|
|
186
|
-
'applyFlatjsonFilter',
|
|
187
|
-
`Found ${totalCount} total, returning ${results.length} records`,
|
|
188
|
-
);
|
|
189
|
-
|
|
190
|
-
// Map only json_data
|
|
191
|
-
const jsonDataResults = results.map((r) => r.json_data);
|
|
192
|
-
|
|
193
|
-
return {
|
|
194
|
-
data: jsonDataResults,
|
|
195
|
-
total: totalCount,
|
|
196
|
-
page: page || 1,
|
|
197
|
-
size: size || 20,
|
|
198
|
-
totalPages: size ? Math.ceil(totalCount / size) : 1,
|
|
199
|
-
tabCounts: tabCounts.length > 0 ? tabCounts : undefined,
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* Build JSONB where clauses from filter conditions
|
|
206
|
-
*/
|
|
207
|
-
private buildJsonbConditions(
|
|
208
|
-
filters: FilterCondition[],
|
|
209
|
-
attributeMetaMap: Record<string, any>,
|
|
210
|
-
): JsonbCondition[] {
|
|
211
|
-
const conditions: JsonbCondition[] = [];
|
|
212
|
-
|
|
213
|
-
for (const filter of filters) {
|
|
214
|
-
const meta = attributeMetaMap[filter.filter_attribute];
|
|
215
|
-
const condition = this.buildJsonbCondition(filter, meta);
|
|
216
|
-
|
|
217
|
-
if (condition) {
|
|
218
|
-
conditions.push(condition);
|
|
219
|
-
} else {
|
|
220
|
-
console.warn(
|
|
221
|
-
`Could not build condition for filter: ${filter.filter_attribute}`,
|
|
222
|
-
);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
return conditions;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
/**
|
|
230
|
-
* Resolve entity IDs to full entity data
|
|
231
|
-
*/
|
|
232
|
-
private async resolveEntityData(
|
|
233
|
-
entityJsonRecords: EntityJson[],
|
|
234
|
-
entity_type: string,
|
|
235
|
-
loggedInUser: any,
|
|
236
|
-
): Promise<any[]> {
|
|
237
|
-
if (entityJsonRecords.length === 0) return [];
|
|
238
|
-
|
|
239
|
-
const entityIds = entityJsonRecords.map((ej) => ej.entity_id);
|
|
240
|
-
|
|
241
|
-
try {
|
|
242
|
-
// Use resolver service to get full entity data
|
|
243
|
-
const fullEntities = await this.resolverService.getResolvedData(
|
|
244
|
-
entity_type,
|
|
245
|
-
entityIds,
|
|
246
|
-
loggedInUser,
|
|
247
|
-
);
|
|
248
|
-
|
|
249
|
-
// Return with json_data merged
|
|
250
|
-
return entityJsonRecords.map((ej) => {
|
|
251
|
-
const fullEntity = fullEntities.find((e) => e.id === ej.entity_id);
|
|
252
|
-
return {
|
|
253
|
-
...fullEntity,
|
|
254
|
-
_flatjson: ej.json_data, // Include flatjson for debugging
|
|
255
|
-
};
|
|
256
|
-
});
|
|
257
|
-
} catch (error) {
|
|
258
|
-
console.error('Error resolving entity data:', error);
|
|
259
|
-
// Fallback: return just the entity IDs with json_data
|
|
260
|
-
return entityJsonRecords.map((ej) => ({
|
|
261
|
-
id: ej.entity_id,
|
|
262
|
-
entity_type: ej.entity_type,
|
|
263
|
-
...ej.json_data,
|
|
264
|
-
}));
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
/**
|
|
269
|
-
* Build a single JSONB condition based on data type
|
|
270
|
-
*/
|
|
271
|
-
private buildJsonbCondition(
|
|
272
|
-
filter: FilterCondition,
|
|
273
|
-
meta: any,
|
|
274
|
-
): JsonbCondition | null {
|
|
275
|
-
if (!meta) return null;
|
|
276
|
-
|
|
277
|
-
const flatJsonKey =
|
|
278
|
-
meta.flat_json_key ||
|
|
279
|
-
`${meta.mapped_entity_type}__${filter.filter_attribute}`;
|
|
280
|
-
const op = filter.filter_operator;
|
|
281
|
-
const val = filter.filter_value;
|
|
282
|
-
const key = `param_${filter.filter_attribute}_${Math.random().toString(36).substring(2, 8)}`;
|
|
283
|
-
|
|
284
|
-
switch (meta.data_type) {
|
|
285
|
-
case 'text':
|
|
286
|
-
return this.buildTextCondition(flatJsonKey, op, val, key);
|
|
287
|
-
case 'number':
|
|
288
|
-
return this.buildNumberCondition(flatJsonKey, op, val, key);
|
|
289
|
-
case 'date':
|
|
290
|
-
return this.buildDateCondition(flatJsonKey, op, val, key);
|
|
291
|
-
case 'select':
|
|
292
|
-
case 'radio':
|
|
293
|
-
return this.buildSelectCondition(flatJsonKey, op, val, key);
|
|
294
|
-
case 'multiselect':
|
|
295
|
-
case 'checkbox':
|
|
296
|
-
return this.buildMultiSelectCondition(flatJsonKey, op, val, key);
|
|
297
|
-
case 'year':
|
|
298
|
-
return this.buildYearCondition(flatJsonKey, op, val, key);
|
|
299
|
-
default:
|
|
300
|
-
return null;
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
/**
|
|
305
|
-
* Build text condition (JSONB ->> operator)
|
|
306
|
-
*/
|
|
307
|
-
private buildTextCondition(
|
|
308
|
-
flatJsonKey: string,
|
|
309
|
-
operator: string,
|
|
310
|
-
value: any,
|
|
311
|
-
paramKey: string,
|
|
312
|
-
): JsonbCondition | null {
|
|
313
|
-
// Text is already stored lowercase in flatjson
|
|
314
|
-
const lowerValue = value ? String(value).toLowerCase() : '';
|
|
315
|
-
|
|
316
|
-
switch (operator) {
|
|
317
|
-
case 'equal':
|
|
318
|
-
return {
|
|
319
|
-
query: `json_data->>'${flatJsonKey}' = :${paramKey}`,
|
|
320
|
-
params: { [paramKey]: lowerValue },
|
|
321
|
-
};
|
|
322
|
-
|
|
323
|
-
case 'not_equal':
|
|
324
|
-
return {
|
|
325
|
-
query: `json_data->>'${flatJsonKey}' != :${paramKey}`,
|
|
326
|
-
params: { [paramKey]: lowerValue },
|
|
327
|
-
};
|
|
328
|
-
|
|
329
|
-
case 'contains':
|
|
330
|
-
return {
|
|
331
|
-
query: `json_data->>'${flatJsonKey}' LIKE :${paramKey}`,
|
|
332
|
-
params: { [paramKey]: `%${lowerValue}%` },
|
|
333
|
-
};
|
|
334
|
-
|
|
335
|
-
case 'not_contains':
|
|
336
|
-
return {
|
|
337
|
-
query: `json_data->>'${flatJsonKey}' NOT LIKE :${paramKey}`,
|
|
338
|
-
params: { [paramKey]: `%${lowerValue}%` },
|
|
339
|
-
};
|
|
340
|
-
|
|
341
|
-
case 'starts_with':
|
|
342
|
-
return {
|
|
343
|
-
query: `json_data->>'${flatJsonKey}' LIKE :${paramKey}`,
|
|
344
|
-
params: { [paramKey]: `${lowerValue}%` },
|
|
345
|
-
};
|
|
346
|
-
|
|
347
|
-
case 'ends_with':
|
|
348
|
-
return {
|
|
349
|
-
query: `json_data->>'${flatJsonKey}' LIKE :${paramKey}`,
|
|
350
|
-
params: { [paramKey]: `%${lowerValue}` },
|
|
351
|
-
};
|
|
352
|
-
|
|
353
|
-
case 'empty':
|
|
354
|
-
return {
|
|
355
|
-
query: `(json_data->>'${flatJsonKey}' IS NULL OR json_data->>'${flatJsonKey}' = '')`,
|
|
356
|
-
params: {},
|
|
357
|
-
};
|
|
358
|
-
|
|
359
|
-
case 'not_empty':
|
|
360
|
-
return {
|
|
361
|
-
query: `(json_data->>'${flatJsonKey}' IS NOT NULL AND json_data->>'${flatJsonKey}' != '')`,
|
|
362
|
-
params: {},
|
|
363
|
-
};
|
|
364
|
-
|
|
365
|
-
default:
|
|
366
|
-
console.warn(`Unsupported text operator: ${operator}`);
|
|
367
|
-
return null;
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
/**
|
|
372
|
-
* Build number condition (JSONB ->> with ::numeric cast)
|
|
373
|
-
*/
|
|
374
|
-
private buildNumberCondition(
|
|
375
|
-
flatJsonKey: string,
|
|
376
|
-
operator: string,
|
|
377
|
-
value: any,
|
|
378
|
-
paramKey: string,
|
|
379
|
-
): JsonbCondition | null {
|
|
380
|
-
// Cast JSONB text to numeric for comparison
|
|
381
|
-
const jsonbField = `(json_data->>'${flatJsonKey}')::numeric`;
|
|
382
|
-
|
|
383
|
-
switch (operator) {
|
|
384
|
-
case 'equal':
|
|
385
|
-
return {
|
|
386
|
-
query: `${jsonbField} = :${paramKey}`,
|
|
387
|
-
params: { [paramKey]: Number(value) },
|
|
388
|
-
};
|
|
389
|
-
|
|
390
|
-
case 'not_equal':
|
|
391
|
-
return {
|
|
392
|
-
query: `${jsonbField} != :${paramKey}`,
|
|
393
|
-
params: { [paramKey]: Number(value) },
|
|
394
|
-
};
|
|
395
|
-
|
|
396
|
-
case 'greater_than':
|
|
397
|
-
return {
|
|
398
|
-
query: `${jsonbField} > :${paramKey}`,
|
|
399
|
-
params: { [paramKey]: Number(value) },
|
|
400
|
-
};
|
|
401
|
-
|
|
402
|
-
case 'less_than':
|
|
403
|
-
return {
|
|
404
|
-
query: `${jsonbField} < :${paramKey}`,
|
|
405
|
-
params: { [paramKey]: Number(value) },
|
|
406
|
-
};
|
|
407
|
-
|
|
408
|
-
case 'greater_than_equal_to':
|
|
409
|
-
return {
|
|
410
|
-
query: `${jsonbField} >= :${paramKey}`,
|
|
411
|
-
params: { [paramKey]: Number(value) },
|
|
412
|
-
};
|
|
413
|
-
|
|
414
|
-
case 'less_than_equal_to':
|
|
415
|
-
return {
|
|
416
|
-
query: `${jsonbField} <= :${paramKey}`,
|
|
417
|
-
params: { [paramKey]: Number(value) },
|
|
418
|
-
};
|
|
419
|
-
|
|
420
|
-
case 'between': {
|
|
421
|
-
// Value should be array [min, max] or string "min,max"
|
|
422
|
-
let range: number[];
|
|
423
|
-
if (typeof value === 'string') {
|
|
424
|
-
range = value.split(',').map((v) => Number(v.trim()));
|
|
425
|
-
} else if (Array.isArray(value)) {
|
|
426
|
-
range = value.map((v) => Number(v));
|
|
427
|
-
} else {
|
|
428
|
-
return null;
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
if (range.length !== 2) return null;
|
|
432
|
-
|
|
433
|
-
return {
|
|
434
|
-
query: `${jsonbField} BETWEEN :${paramKey}_min AND :${paramKey}_max`,
|
|
435
|
-
params: {
|
|
436
|
-
[`${paramKey}_min`]: range[0],
|
|
437
|
-
[`${paramKey}_max`]: range[1],
|
|
438
|
-
},
|
|
439
|
-
};
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
case 'empty':
|
|
443
|
-
return {
|
|
444
|
-
query: `json_data->>'${flatJsonKey}' IS NULL`,
|
|
445
|
-
params: {},
|
|
446
|
-
};
|
|
447
|
-
|
|
448
|
-
case 'not_empty':
|
|
449
|
-
return {
|
|
450
|
-
query: `json_data->>'${flatJsonKey}' IS NOT NULL`,
|
|
451
|
-
params: {},
|
|
452
|
-
};
|
|
453
|
-
|
|
454
|
-
default:
|
|
455
|
-
console.warn(`Unsupported number operator: ${operator}`);
|
|
456
|
-
return null;
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
/**
|
|
461
|
-
* Build date condition (JSONB ->> with ::bigint cast for epoch ms)
|
|
462
|
-
*/
|
|
463
|
-
private buildDateCondition(
|
|
464
|
-
flatJsonKey: string,
|
|
465
|
-
operator: string,
|
|
466
|
-
value: any,
|
|
467
|
-
paramKey: string,
|
|
468
|
-
): JsonbCondition | null {
|
|
469
|
-
// Dates stored as epoch milliseconds (bigint)
|
|
470
|
-
const jsonbField = `(json_data->>'${flatJsonKey}')::bigint`;
|
|
471
|
-
|
|
472
|
-
// Helper: Convert date string to epoch ms
|
|
473
|
-
const toEpochMs = (dateStr: string): number => {
|
|
474
|
-
return new Date(dateStr).getTime();
|
|
475
|
-
};
|
|
476
|
-
|
|
477
|
-
// Helper: Get date N days ago
|
|
478
|
-
const daysAgo = (days: number): number => {
|
|
479
|
-
const d = new Date();
|
|
480
|
-
d.setDate(d.getDate() - days);
|
|
481
|
-
return d.getTime();
|
|
482
|
-
};
|
|
483
|
-
|
|
484
|
-
// Helper: Get date N days from now
|
|
485
|
-
const daysFromNow = (days: number): number => {
|
|
486
|
-
const d = new Date();
|
|
487
|
-
d.setDate(d.getDate() + days);
|
|
488
|
-
return d.getTime();
|
|
489
|
-
};
|
|
490
|
-
|
|
491
|
-
// Helper: Subtract business days (skip weekends)
|
|
492
|
-
const subtractBusinessDays = (days: number): number => {
|
|
493
|
-
let d = new Date();
|
|
494
|
-
let count = 0;
|
|
495
|
-
|
|
496
|
-
while (count < days) {
|
|
497
|
-
d.setDate(d.getDate() - 1);
|
|
498
|
-
const day = d.getDay(); // 0=Sun, 6=Sat
|
|
499
|
-
if (day !== 0 && day !== 6) {
|
|
500
|
-
count++;
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
return d.getTime();
|
|
505
|
-
};
|
|
506
|
-
|
|
507
|
-
const numVal = Number(value);
|
|
508
|
-
|
|
509
|
-
switch (operator) {
|
|
510
|
-
// Basic comparisons
|
|
511
|
-
case 'equal':
|
|
512
|
-
case 'is':
|
|
513
|
-
return {
|
|
514
|
-
query: `${jsonbField} = :${paramKey}`,
|
|
515
|
-
params: { [paramKey]: toEpochMs(value) },
|
|
516
|
-
};
|
|
517
|
-
|
|
518
|
-
case 'before':
|
|
519
|
-
case 'is_before':
|
|
520
|
-
return {
|
|
521
|
-
query: `${jsonbField} < :${paramKey}`,
|
|
522
|
-
params: { [paramKey]: toEpochMs(value) },
|
|
523
|
-
};
|
|
524
|
-
|
|
525
|
-
case 'after':
|
|
526
|
-
case 'is_after':
|
|
527
|
-
return {
|
|
528
|
-
query: `${jsonbField} > :${paramKey}`,
|
|
529
|
-
params: { [paramKey]: toEpochMs(value) },
|
|
530
|
-
};
|
|
531
|
-
|
|
532
|
-
case 'is_on_or_before':
|
|
533
|
-
return {
|
|
534
|
-
query: `${jsonbField} <= :${paramKey}`,
|
|
535
|
-
params: { [paramKey]: toEpochMs(value) },
|
|
536
|
-
};
|
|
537
|
-
|
|
538
|
-
case 'is_on_or_after':
|
|
539
|
-
return {
|
|
540
|
-
query: `${jsonbField} >= :${paramKey}`,
|
|
541
|
-
params: { [paramKey]: toEpochMs(value) },
|
|
542
|
-
};
|
|
543
|
-
|
|
544
|
-
// Day offset logic
|
|
545
|
-
case 'is_day_before':
|
|
546
|
-
if (isNaN(numVal)) return null;
|
|
547
|
-
return {
|
|
548
|
-
query: `${jsonbField} <= :${paramKey}`,
|
|
549
|
-
params: { [paramKey]: daysAgo(numVal) },
|
|
550
|
-
};
|
|
551
|
-
|
|
552
|
-
case 'is_day_after':
|
|
553
|
-
if (isNaN(numVal)) return null;
|
|
554
|
-
return {
|
|
555
|
-
query: `${jsonbField} >= :${paramKey}`,
|
|
556
|
-
params: { [paramKey]: daysFromNow(numVal) },
|
|
557
|
-
};
|
|
558
|
-
|
|
559
|
-
// Business days (skip weekends)
|
|
560
|
-
case 'is_before_business_days':
|
|
561
|
-
if (isNaN(numVal)) return null;
|
|
562
|
-
return {
|
|
563
|
-
query: `${jsonbField} <= :${paramKey}`,
|
|
564
|
-
params: { [paramKey]: subtractBusinessDays(numVal) },
|
|
565
|
-
};
|
|
566
|
-
|
|
567
|
-
// Range operators
|
|
568
|
-
case 'between': {
|
|
569
|
-
let range: string[];
|
|
570
|
-
if (typeof value === 'string') {
|
|
571
|
-
range = value.split(',').map((v) => v.trim());
|
|
572
|
-
} else if (Array.isArray(value)) {
|
|
573
|
-
range = value;
|
|
574
|
-
} else {
|
|
575
|
-
return null;
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
if (range.length !== 2) return null;
|
|
579
|
-
|
|
580
|
-
return {
|
|
581
|
-
query: `${jsonbField} BETWEEN :${paramKey}_start AND :${paramKey}_end`,
|
|
582
|
-
params: {
|
|
583
|
-
[`${paramKey}_start`]: toEpochMs(range[0]),
|
|
584
|
-
[`${paramKey}_end`]: toEpochMs(range[1]),
|
|
585
|
-
},
|
|
586
|
-
};
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
case 'in_last_day':
|
|
590
|
-
if (isNaN(numVal)) return null;
|
|
591
|
-
return {
|
|
592
|
-
query: `${jsonbField} BETWEEN :${paramKey}_start AND :${paramKey}_end`,
|
|
593
|
-
params: {
|
|
594
|
-
[`${paramKey}_start`]: daysAgo(numVal),
|
|
595
|
-
[`${paramKey}_end`]: Date.now(),
|
|
596
|
-
},
|
|
597
|
-
};
|
|
598
|
-
|
|
599
|
-
case 'in_next_day':
|
|
600
|
-
if (isNaN(numVal)) return null;
|
|
601
|
-
return {
|
|
602
|
-
query: `${jsonbField} BETWEEN :${paramKey}_start AND :${paramKey}_end`,
|
|
603
|
-
params: {
|
|
604
|
-
[`${paramKey}_start`]: Date.now(),
|
|
605
|
-
[`${paramKey}_end`]: daysFromNow(numVal),
|
|
606
|
-
},
|
|
607
|
-
};
|
|
608
|
-
|
|
609
|
-
// Special cases
|
|
610
|
-
case 'today': {
|
|
611
|
-
const todayStart = new Date().setHours(0, 0, 0, 0);
|
|
612
|
-
const todayEnd = new Date().setHours(23, 59, 59, 999);
|
|
613
|
-
return {
|
|
614
|
-
query: `${jsonbField} BETWEEN :${paramKey}_start AND :${paramKey}_end`,
|
|
615
|
-
params: {
|
|
616
|
-
[`${paramKey}_start`]: todayStart,
|
|
617
|
-
[`${paramKey}_end`]: todayEnd,
|
|
618
|
-
},
|
|
619
|
-
};
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
case 'empty':
|
|
623
|
-
return {
|
|
624
|
-
query: `json_data->>'${flatJsonKey}' IS NULL`,
|
|
625
|
-
params: {},
|
|
626
|
-
};
|
|
627
|
-
|
|
628
|
-
case 'not_empty':
|
|
629
|
-
return {
|
|
630
|
-
query: `json_data->>'${flatJsonKey}' IS NOT NULL`,
|
|
631
|
-
params: {},
|
|
632
|
-
};
|
|
633
|
-
|
|
634
|
-
default:
|
|
635
|
-
console.warn(`Unsupported date operator: ${operator}`);
|
|
636
|
-
return null;
|
|
637
|
-
}
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
/**
|
|
641
|
-
* Build select condition (single value)
|
|
642
|
-
*/
|
|
643
|
-
private buildSelectCondition(
|
|
644
|
-
flatJsonKey: string,
|
|
645
|
-
operator: string,
|
|
646
|
-
value: any,
|
|
647
|
-
paramKey: string,
|
|
648
|
-
): JsonbCondition | null {
|
|
649
|
-
switch (operator) {
|
|
650
|
-
case 'equal':
|
|
651
|
-
if (Array.isArray(value)) {
|
|
652
|
-
// IN operator for multiple values
|
|
653
|
-
return {
|
|
654
|
-
query: `json_data->>'${flatJsonKey}' = ANY(:${paramKey})`,
|
|
655
|
-
params: { [paramKey]: value.map(String) },
|
|
656
|
-
};
|
|
657
|
-
}
|
|
658
|
-
return {
|
|
659
|
-
query: `json_data->>'${flatJsonKey}' = :${paramKey}`,
|
|
660
|
-
params: { [paramKey]: String(value) },
|
|
661
|
-
};
|
|
662
|
-
|
|
663
|
-
case 'not_equal':
|
|
664
|
-
if (Array.isArray(value)) {
|
|
665
|
-
// NOT IN operator
|
|
666
|
-
return {
|
|
667
|
-
query: `json_data->>'${flatJsonKey}' != ALL(:${paramKey})`,
|
|
668
|
-
params: { [paramKey]: value.map(String) },
|
|
669
|
-
};
|
|
670
|
-
}
|
|
671
|
-
return {
|
|
672
|
-
query: `json_data->>'${flatJsonKey}' != :${paramKey}`,
|
|
673
|
-
params: { [paramKey]: String(value) },
|
|
674
|
-
};
|
|
675
|
-
|
|
676
|
-
case 'in': {
|
|
677
|
-
const inValues = Array.isArray(value) ? value : [value];
|
|
678
|
-
return {
|
|
679
|
-
query: `json_data->>'${flatJsonKey}' = ANY(:${paramKey})`,
|
|
680
|
-
params: { [paramKey]: inValues.map(String) },
|
|
681
|
-
};
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
case 'not_in': {
|
|
685
|
-
const notInValues = Array.isArray(value) ? value : [value];
|
|
686
|
-
return {
|
|
687
|
-
query: `json_data->>'${flatJsonKey}' != ALL(:${paramKey})`,
|
|
688
|
-
params: { [paramKey]: notInValues.map(String) },
|
|
689
|
-
};
|
|
690
|
-
}
|
|
691
|
-
|
|
692
|
-
case 'empty':
|
|
693
|
-
return {
|
|
694
|
-
query: `json_data->>'${flatJsonKey}' IS NULL`,
|
|
695
|
-
params: {},
|
|
696
|
-
};
|
|
697
|
-
|
|
698
|
-
case 'not_empty':
|
|
699
|
-
return {
|
|
700
|
-
query: `json_data->>'${flatJsonKey}' IS NOT NULL`,
|
|
701
|
-
params: {},
|
|
702
|
-
};
|
|
703
|
-
|
|
704
|
-
default:
|
|
705
|
-
console.warn(`Unsupported select operator: ${operator}`);
|
|
706
|
-
return null;
|
|
707
|
-
}
|
|
708
|
-
}
|
|
709
|
-
|
|
710
|
-
/**
|
|
711
|
-
* Build multiselect condition (JSONB -> with ? operators for arrays)
|
|
712
|
-
*/
|
|
713
|
-
private buildMultiSelectCondition(
|
|
714
|
-
flatJsonKey: string,
|
|
715
|
-
operator: string,
|
|
716
|
-
value: any,
|
|
717
|
-
paramKey: string,
|
|
718
|
-
): JsonbCondition | null {
|
|
719
|
-
// Convert value to array if not already
|
|
720
|
-
let arr: string[];
|
|
721
|
-
if (Array.isArray(value)) {
|
|
722
|
-
arr = value.map(String);
|
|
723
|
-
} else if (typeof value === 'string') {
|
|
724
|
-
arr = value.split(',').map((v) => v.trim());
|
|
725
|
-
} else {
|
|
726
|
-
arr = [String(value)];
|
|
727
|
-
}
|
|
728
|
-
|
|
729
|
-
if (arr.length === 0) {
|
|
730
|
-
return { query: '1=1', params: {} }; // Always true for empty array
|
|
731
|
-
}
|
|
732
|
-
|
|
733
|
-
switch (operator) {
|
|
734
|
-
case 'contains':
|
|
735
|
-
case 'has':
|
|
736
|
-
// Check if JSON array contains this element
|
|
737
|
-
// json_data->'LEAD__languages' ? 'hindi'
|
|
738
|
-
if (arr.length === 1) {
|
|
739
|
-
return {
|
|
740
|
-
query: `json_data->'${flatJsonKey}' ? :${paramKey}`,
|
|
741
|
-
params: { [paramKey]: arr[0] },
|
|
742
|
-
};
|
|
743
|
-
}
|
|
744
|
-
// For multiple values, check if contains ANY
|
|
745
|
-
return {
|
|
746
|
-
query: `json_data->'${flatJsonKey}' ?| ARRAY[:...${paramKey}]::text[]`,
|
|
747
|
-
params: { [paramKey]: arr },
|
|
748
|
-
};
|
|
749
|
-
|
|
750
|
-
case 'contains_all':
|
|
751
|
-
// Check if JSON array contains ALL elements
|
|
752
|
-
// json_data->'LEAD__languages' ?& ARRAY['hindi', 'english']
|
|
753
|
-
return {
|
|
754
|
-
query: `json_data->'${flatJsonKey}' ?& ARRAY[:...${paramKey}]::text[]`,
|
|
755
|
-
params: { [paramKey]: arr },
|
|
756
|
-
};
|
|
757
|
-
|
|
758
|
-
case 'contains_any':
|
|
759
|
-
// Check if JSON array contains ANY element
|
|
760
|
-
// json_data->'LEAD__languages' ?| ARRAY['hindi', 'english']
|
|
761
|
-
return {
|
|
762
|
-
query: `json_data->'${flatJsonKey}' ?| ARRAY[:...${paramKey}]::text[]`,
|
|
763
|
-
params: { [paramKey]: arr },
|
|
764
|
-
};
|
|
765
|
-
|
|
766
|
-
case 'not_contains':
|
|
767
|
-
// Check if JSON array does NOT contain element
|
|
768
|
-
if (arr.length === 1) {
|
|
769
|
-
return {
|
|
770
|
-
query: `NOT (json_data->'${flatJsonKey}' ? :${paramKey})`,
|
|
771
|
-
params: { [paramKey]: arr[0] },
|
|
772
|
-
};
|
|
773
|
-
}
|
|
774
|
-
return {
|
|
775
|
-
query: `NOT (json_data->'${flatJsonKey}' ?| ARRAY[:...${paramKey}]::text[])`,
|
|
776
|
-
params: { [paramKey]: arr },
|
|
777
|
-
};
|
|
778
|
-
|
|
779
|
-
case 'equal':
|
|
780
|
-
// Exact array match (order matters in PostgreSQL)
|
|
781
|
-
return {
|
|
782
|
-
query: `json_data->'${flatJsonKey}'::jsonb = :${paramKey}::jsonb`,
|
|
783
|
-
params: { [paramKey]: JSON.stringify(arr) },
|
|
784
|
-
};
|
|
785
|
-
|
|
786
|
-
case 'empty':
|
|
787
|
-
return {
|
|
788
|
-
query: `(json_data->>'${flatJsonKey}' IS NULL OR json_data->'${flatJsonKey}' = '[]'::jsonb)`,
|
|
789
|
-
params: {},
|
|
790
|
-
};
|
|
791
|
-
|
|
792
|
-
case 'not_empty':
|
|
793
|
-
return {
|
|
794
|
-
query: `(json_data->>'${flatJsonKey}' IS NOT NULL AND json_data->'${flatJsonKey}' != '[]'::jsonb)`,
|
|
795
|
-
params: {},
|
|
796
|
-
};
|
|
797
|
-
|
|
798
|
-
default:
|
|
799
|
-
console.warn(`Unsupported multiselect operator: ${operator}`);
|
|
800
|
-
return null;
|
|
801
|
-
}
|
|
802
|
-
}
|
|
803
|
-
|
|
804
|
-
/**
|
|
805
|
-
* Build year condition
|
|
806
|
-
*/
|
|
807
|
-
private buildYearCondition(
|
|
808
|
-
flatJsonKey: string,
|
|
809
|
-
operator: string,
|
|
810
|
-
value: any,
|
|
811
|
-
paramKey: string,
|
|
812
|
-
): JsonbCondition | null {
|
|
813
|
-
// Similar to number condition
|
|
814
|
-
return this.buildNumberCondition(flatJsonKey, operator, value, paramKey);
|
|
815
|
-
}
|
|
816
|
-
|
|
817
|
-
/**
|
|
818
|
-
* Get tab aggregation counts from JSONB
|
|
819
|
-
*/
|
|
820
|
-
private async getJsonbTabCounts(
|
|
821
|
-
entity_type: string,
|
|
822
|
-
flatJsonKey: string,
|
|
823
|
-
whereClauses: JsonbCondition[],
|
|
824
|
-
): Promise<Array<{ tab_value: string; tab_value_count: number }>> {
|
|
825
|
-
// Build a query that groups by the tab field
|
|
826
|
-
const qb = this.entityManager
|
|
827
|
-
.getRepository(EntityJson)
|
|
828
|
-
.createQueryBuilder('ej')
|
|
829
|
-
.select(`json_data->>'${flatJsonKey}'`, 'tab_value')
|
|
830
|
-
.addSelect('COUNT(*)', 'tab_value_count')
|
|
831
|
-
.where('ej.entity_type = :entity_type', { entity_type })
|
|
832
|
-
.groupBy(`json_data->>'${flatJsonKey}'`);
|
|
833
|
-
|
|
834
|
-
// Apply the same filter conditions (but not the tab filter itself)
|
|
835
|
-
whereClauses.forEach((condition) => {
|
|
836
|
-
qb.andWhere(condition.query, condition.params);
|
|
837
|
-
});
|
|
838
|
-
|
|
839
|
-
const results = await qb.getRawMany();
|
|
840
|
-
|
|
841
|
-
// Filter out NULL/undefined tab values and convert count to number
|
|
842
|
-
return results
|
|
843
|
-
.filter((r) => r.tab_value != null && r.tab_value !== '')
|
|
844
|
-
.map((r) => ({
|
|
845
|
-
tab_value: r.tab_value,
|
|
846
|
-
tab_value_count: parseInt(r.tab_value_count, 10),
|
|
847
|
-
}))
|
|
848
|
-
.sort((a, b) => b.tab_value_count - a.tab_value_count); // Sort by count DESC
|
|
849
|
-
}
|
|
850
|
-
|
|
851
|
-
/**
|
|
852
|
-
* Apply sorting on JSONB fields
|
|
853
|
-
*/
|
|
854
|
-
private applyJsonbSorting(
|
|
855
|
-
qb: SelectQueryBuilder<EntityJson>,
|
|
856
|
-
sortby: SortConfig[],
|
|
857
|
-
attributeMetaMap: Record<string, any>,
|
|
858
|
-
): void {
|
|
859
|
-
sortby.forEach((sort, index) => {
|
|
860
|
-
const meta = attributeMetaMap[sort.sortColum];
|
|
861
|
-
|
|
862
|
-
if (!meta) {
|
|
863
|
-
console.warn(`No metadata found for sort column: ${sort.sortColum}`);
|
|
864
|
-
return;
|
|
865
|
-
}
|
|
866
|
-
|
|
867
|
-
const flatJsonKey =
|
|
868
|
-
meta.flat_json_key || `${meta.mapped_entity_type}__${sort.sortColum}`;
|
|
869
|
-
const direction = sort.sortType === 'ASC' ? 'ASC' : 'DESC';
|
|
870
|
-
|
|
871
|
-
// Apply type-specific casting for proper sorting
|
|
872
|
-
let sortExpression: string;
|
|
873
|
-
|
|
874
|
-
switch (meta.data_type) {
|
|
875
|
-
case 'number':
|
|
876
|
-
case 'year':
|
|
877
|
-
// Cast to numeric for number sorting
|
|
878
|
-
sortExpression = `(json_data->>'${flatJsonKey}')::numeric`;
|
|
879
|
-
break;
|
|
880
|
-
|
|
881
|
-
case 'date':
|
|
882
|
-
// Cast to bigint for date sorting (epoch ms)
|
|
883
|
-
sortExpression = `(json_data->>'${flatJsonKey}')::bigint`;
|
|
884
|
-
break;
|
|
885
|
-
|
|
886
|
-
case 'text':
|
|
887
|
-
case 'select':
|
|
888
|
-
case 'radio':
|
|
889
|
-
default:
|
|
890
|
-
// Text sorting (already lowercase)
|
|
891
|
-
sortExpression = `json_data->>'${flatJsonKey}'`;
|
|
892
|
-
break;
|
|
893
|
-
}
|
|
894
|
-
|
|
895
|
-
// Add to ORDER BY clause
|
|
896
|
-
if (index === 0) {
|
|
897
|
-
qb.orderBy(sortExpression, direction);
|
|
898
|
-
} else {
|
|
899
|
-
qb.addOrderBy(sortExpression, direction);
|
|
900
|
-
}
|
|
901
|
-
});
|
|
902
|
-
}
|
|
903
|
-
}
|