rez_core 5.0.157 → 5.0.158
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 +8 -11
- package/.idea/codeStyles/Project.xml +58 -58
- package/.idea/codeStyles/codeStyleConfig.xml +4 -4
- 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 +1 -1
- package/.idea/misc.xml +6 -0
- package/.idea/modules.xml +7 -7
- package/.idea/prettier.xml +5 -5
- package/.idea/vcs.xml +5 -5
- package/.prettierrc +3 -3
- package/README.md +99 -99
- package/dist/config/bull.config.js +4 -4
- package/dist/config/bull.config.js.map +1 -1
- package/dist/config/database.config.js +1 -1
- package/dist/config/database.config.js.map +1 -1
- package/dist/core.module.js +2 -5
- package/dist/core.module.js.map +1 -1
- package/dist/module/auth/guards/role.guard.js +3 -3
- package/dist/module/entity_json/controller/entity_json.controller.d.ts +9 -2
- 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 +4 -54
- 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/entity/saved-filter-master.entity.d.ts +2 -1
- package/dist/module/filter/entity/saved-filter-master.entity.js +6 -2
- package/dist/module/filter/entity/saved-filter-master.entity.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/repository/saved-filter.repository.d.ts +1 -5
- package/dist/module/filter/repository/saved-filter.repository.js +1 -5
- package/dist/module/filter/repository/saved-filter.repository.js.map +1 -1
- package/dist/module/filter/service/filter.service.d.ts +1 -37
- package/dist/module/filter/service/filter.service.js +63 -51
- package/dist/module/filter/service/filter.service.js.map +1 -1
- package/dist/module/integration/examples/usage.example.js +9 -9
- package/dist/module/integration/service/wrapper.service.d.ts +3 -1
- package/dist/module/integration/service/wrapper.service.js +24 -2
- package/dist/module/integration/service/wrapper.service.js.map +1 -1
- package/dist/module/linked_attributes/controller/linked_attributes.controller.d.ts +0 -19
- package/dist/module/linked_attributes/controller/linked_attributes.controller.js +0 -77
- 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 -41
- package/dist/module/linked_attributes/service/linked_attributes.service.js +2 -266
- package/dist/module/linked_attributes/service/linked_attributes.service.js.map +1 -1
- package/dist/module/meta/dto/entity-table.dto.d.ts +1 -4
- package/dist/module/meta/dto/entity-table.dto.js.map +1 -1
- package/dist/module/meta/entity.module.js +2 -0
- package/dist/module/meta/entity.module.js.map +1 -1
- package/dist/module/meta/repository/attribute-master.repository.js +8 -8
- package/dist/module/meta/repository/entity-relation.repository.d.ts +7 -0
- package/dist/module/meta/repository/entity-relation.repository.js +39 -0
- package/dist/module/meta/repository/entity-relation.repository.js.map +1 -0
- package/dist/module/meta/service/entity-dynamic.service.d.ts +4 -1
- package/dist/module/meta/service/entity-dynamic.service.js +23 -22
- package/dist/module/meta/service/entity-dynamic.service.js.map +1 -1
- package/dist/module/meta/service/entity-list.service.js +2 -2
- package/dist/module/meta/service/entity-relation.service.d.ts +4 -1
- package/dist/module/meta/service/entity-relation.service.js +20 -14
- package/dist/module/meta/service/entity-relation.service.js.map +1 -1
- package/dist/module/meta/service/media-data.service.js +24 -11
- package/dist/module/meta/service/media-data.service.js.map +1 -1
- package/dist/module/meta/service/resolver.service.js +15 -15
- package/dist/module/module/repository/menu.repository.js +4 -4
- package/dist/module/notification/service/notification.service.js +6 -6
- package/dist/module/user/controller/login.controller.js +18 -18
- package/dist/module/workflow/repository/action.repository.js +2 -2
- package/dist/module/workflow/repository/stage.repository.js +8 -8
- package/dist/module/workflow/service/action-template-mapping.service.js +2 -2
- package/dist/module/workflow/service/action.service.js +7 -15
- package/dist/module/workflow/service/action.service.js.map +1 -1
- package/dist/module/workflow/service/entity-modification.service.js +2 -2
- package/dist/module/workflow/service/task.service.js +12 -13
- package/dist/module/workflow/service/task.service.js.map +1 -1
- package/dist/module/workflow-automation/service/schedule-handler.service.js +9 -9
- package/dist/table.config.d.ts +1 -3
- package/dist/table.config.js +0 -2
- package/dist/table.config.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utils/service/reflection-helper.service.js +2 -2
- package/docs/modules/event-driven-integration-design.md +91 -91
- package/docs/modules/integration.md +250 -250
- package/eslint.config.mjs +34 -34
- package/nest-cli.json +14 -14
- package/package.json +125 -125
- package/server.log +850 -0
- package/src/app.controller.ts +12 -12
- package/src/app.module.ts +68 -68
- package/src/app.service.ts +8 -8
- package/src/config/bull.config.ts +69 -69
- package/src/config/config.module.ts +17 -17
- package/src/config/database.config.ts +48 -48
- package/src/constant/global.constant.ts +67 -67
- package/src/core.module.ts +94 -97
- package/src/decorators/roles.decorator.ts +7 -7
- package/src/dtos/response.dto.ts +6 -6
- package/src/dtos/response.ts +5 -5
- package/src/index.ts +1 -1
- package/src/module/auth/auth.module.ts +49 -49
- package/src/module/auth/controller/auth.controller.ts +28 -28
- package/src/module/auth/guards/google-auth.guard.ts +9 -9
- package/src/module/auth/guards/jwt.guard.ts +22 -22
- package/src/module/auth/guards/role.guard.ts +68 -68
- package/src/module/auth/services/auth.service.ts +56 -56
- package/src/module/auth/services/jwt.service.ts +11 -11
- package/src/module/auth/strategies/google.strategy.ts +54 -54
- package/src/module/auth/strategies/jwt.strategy.ts +58 -58
- package/src/module/auth/strategies/local.strategy.ts +13 -13
- package/src/module/dashboard/controller/dashboard.controller.ts +36 -36
- package/src/module/dashboard/dashboard.module.ts +21 -21
- package/src/module/dashboard/entity/dashboard_page_data.entity.ts +27 -27
- package/src/module/dashboard/entity/widget_master.entity.ts +18 -18
- package/src/module/dashboard/repository/dashboard.repository.ts +51 -51
- package/src/module/dashboard/service/dashboard.service.ts +73 -73
- package/src/module/enterprise/controller/organization.controller.ts +36 -36
- package/src/module/enterprise/enterprise.module.ts +30 -30
- package/src/module/enterprise/entity/enterprise.entity.ts +37 -37
- package/src/module/enterprise/entity/organization-app-mapping.entity.ts +13 -13
- package/src/module/enterprise/entity/organization.entity.ts +92 -92
- package/src/module/enterprise/repository/enterprise.repository.ts +31 -31
- package/src/module/enterprise/repository/organization.repository.ts +26 -26
- package/src/module/enterprise/repository/school.repository.ts +272 -272
- package/src/module/enterprise/service/brand.service.ts +5 -5
- package/src/module/enterprise/service/enterprise.service.ts +16 -16
- package/src/module/enterprise/service/organization-app-mapping.service.ts +4 -4
- package/src/module/enterprise/service/organization.service.ts +145 -145
- package/src/module/entity_json/controller/entity_json.controller.ts +47 -47
- package/src/module/entity_json/entity/entityJson.entity.ts +39 -42
- package/src/module/entity_json/entity_json.module.ts +18 -23
- package/src/module/entity_json/service/entityJson.repository.ts +37 -37
- package/src/module/entity_json/service/entity_json.service.ts +242 -349
- package/src/module/export/controller/export.controller.ts +83 -83
- package/src/module/export/export.module.ts +14 -14
- package/src/module/export/service/export.service.ts +105 -105
- package/src/module/filter/controller/filter.controller.ts +84 -82
- package/src/module/filter/dto/filter-request.dto.ts +39 -39
- package/src/module/filter/entity/saved-filter-detail.entity.ts +41 -41
- package/src/module/filter/entity/saved-filter-master.entity.ts +32 -29
- package/src/module/filter/filter.module.ts +33 -42
- package/src/module/filter/repository/saved-filter.repository.ts +200 -196
- package/src/module/filter/repository/saved.filter-detail.repository.ts +19 -19
- package/src/module/filter/service/filter-evaluator.service.ts +82 -82
- package/src/module/filter/service/filter.service.ts +1317 -1365
- package/src/module/filter/service/saved-filter.service.ts +164 -164
- package/src/module/ics/controller/ics.controller.ts +21 -21
- package/src/module/ics/dto/ics.dto.ts +55 -55
- package/src/module/ics/ics.module.ts +13 -13
- package/src/module/ics/service/ics.service.ts +57 -57
- package/src/module/integration/controller/calender-event.controller.ts +31 -31
- package/src/module/integration/controller/integration.controller.ts +662 -662
- package/src/module/integration/controller/wrapper.controller.ts +37 -37
- package/src/module/integration/dto/create-config.dto.ts +526 -526
- package/src/module/integration/entity/integration-config.entity.ts +112 -112
- package/src/module/integration/entity/integration-entity-mapper.entity.ts +14 -14
- package/src/module/integration/entity/integration-source.entity.ts +17 -17
- package/src/module/integration/entity/user-integration.entity.ts +71 -71
- package/src/module/integration/examples/usage.example.ts +338 -338
- package/src/module/integration/factories/base.factory.ts +7 -7
- package/src/module/integration/factories/email.factory.ts +49 -49
- package/src/module/integration/factories/integration.factory.ts +121 -121
- package/src/module/integration/factories/sms.factory.ts +51 -51
- package/src/module/integration/factories/telephone.factory.ts +41 -41
- package/src/module/integration/factories/whatsapp.factory.ts +56 -56
- package/src/module/integration/integration.module.ts +110 -110
- package/src/module/integration/service/calendar-event.service.ts +118 -118
- package/src/module/integration/service/integration-entity-mapper.service.ts +17 -17
- package/src/module/integration/service/integration-queue.service.ts +229 -229
- package/src/module/integration/service/integration.service.ts +2634 -2634
- package/src/module/integration/service/oauth.service.ts +224 -224
- package/src/module/integration/service/wrapper.service.ts +753 -716
- package/src/module/integration/strategies/email/gmail-api.strategy.ts +280 -280
- package/src/module/integration/strategies/email/outlook-api.strategy.ts +44 -44
- package/src/module/integration/strategies/email/outlook.strategy.ts +64 -64
- package/src/module/integration/strategies/email/sendgrid-api.strategy.ts +260 -260
- package/src/module/integration/strategies/integration.strategy.ts +97 -97
- package/src/module/integration/strategies/sms/gupshup-sms.strategy.ts +146 -146
- package/src/module/integration/strategies/sms/msg91-sms.strategy.ts +164 -164
- package/src/module/integration/strategies/sms/tubelight-sms.strategy.ts +163 -163
- package/src/module/integration/strategies/telephone/ozonetel-voice.strategy.ts +238 -238
- package/src/module/integration/strategies/telephone/tubelight-voice.strategy.ts +210 -210
- package/src/module/integration/strategies/whatsapp/gupshup-whatsapp.strategy.ts +359 -359
- package/src/module/integration/strategies/whatsapp/tubelight-whatsapp.strategy.ts +372 -372
- package/src/module/integration/strategies/whatsapp/whatsapp-cloud.strategy.ts +403 -403
- package/src/module/integration/strategies/whatsapp/whatsapp.strategy.ts +57 -57
- package/src/module/layout/controller/layout.controller.ts +47 -47
- package/src/module/layout/entity/header-items.entity.ts +28 -28
- package/src/module/layout/entity/header-section.entity.ts +19 -19
- package/src/module/layout/layout.module.ts +21 -21
- package/src/module/layout/repository/header-items.repository.ts +18 -18
- package/src/module/layout/repository/header-section.repository.ts +22 -22
- package/src/module/layout/service/header-section.service.ts +25 -25
- package/src/module/layout_preference/controller/layout_preference.controller.ts +73 -73
- package/src/module/layout_preference/entity/layout_preference.entity.ts +28 -28
- package/src/module/layout_preference/layout_preference.module.ts +22 -22
- package/src/module/layout_preference/repository/layout_preference.repository.ts +65 -65
- package/src/module/layout_preference/service/layout_preference.service.ts +191 -191
- package/src/module/lead/controller/lead.controller.ts +30 -30
- package/src/module/lead/lead.module.ts +14 -14
- package/src/module/lead/repository/lead.repository.ts +41 -41
- package/src/module/lead/service/lead.service.ts +54 -54
- package/src/module/linked_attributes/controller/linked_attributes.controller.ts +37 -123
- package/src/module/linked_attributes/entity/linked_attribute.entity.ts +51 -51
- package/src/module/linked_attributes/linked_attributes.module.ts +16 -23
- package/src/module/linked_attributes/repository/linked_attribute.repository.ts +12 -12
- package/src/module/linked_attributes/service/linked_attributes.service.ts +75 -620
- package/src/module/listmaster/controller/list-master.controller.ts +230 -230
- package/src/module/listmaster/entity/list-master-items.entity.ts +43 -43
- package/src/module/listmaster/entity/list-master.entity.ts +33 -33
- package/src/module/listmaster/listmaster.module.ts +46 -46
- package/src/module/listmaster/repository/list-master-items.repository.ts +173 -173
- package/src/module/listmaster/repository/list-master.repository.ts +56 -56
- package/src/module/listmaster/service/list-master-engine.ts +19 -19
- package/src/module/listmaster/service/list-master-extension.interface.ts +4 -4
- package/src/module/listmaster/service/list-master-item.service.ts +281 -281
- package/src/module/listmaster/service/list-master-registry.ts +15 -15
- package/src/module/listmaster/service/list-master.service.ts +535 -535
- package/src/module/mapper/controller/field-mapper.controller.ts +76 -76
- package/src/module/mapper/controller/mapper.controller.ts +20 -20
- package/src/module/mapper/dto/field-mapper.dto.ts +14 -14
- package/src/module/mapper/entity/field-lovs.entity.ts +19 -19
- package/src/module/mapper/entity/field-mapper.entity.ts +53 -53
- package/src/module/mapper/entity/mapper.entity.ts +16 -16
- package/src/module/mapper/mapper.module.ts +35 -35
- package/src/module/mapper/repository/field-lovs.repository.ts +35 -35
- package/src/module/mapper/repository/field-mapper.repository.ts +42 -42
- package/src/module/mapper/repository/mapper.repository.ts +32 -32
- package/src/module/mapper/service/field-mapper.service.ts +269 -269
- package/src/module/mapper/service/mapper.service.ts +81 -81
- package/src/module/master/controller/master.controller.ts +74 -74
- package/src/module/master/service/master.service.ts +483 -483
- package/src/module/meta/controller/app-master.controller.ts +38 -38
- package/src/module/meta/controller/attribute-master.controller.ts +84 -84
- package/src/module/meta/controller/entity-dynamic.controller.ts +125 -125
- package/src/module/meta/controller/entity-master.controller.ts +41 -41
- package/src/module/meta/controller/entity-relation.controller.ts +36 -36
- package/src/module/meta/controller/entity.controller.ts +342 -342
- package/src/module/meta/controller/entity.public.controller.ts +75 -75
- package/src/module/meta/controller/media.controller.ts +135 -135
- package/src/module/meta/controller/meta.controller.ts +96 -96
- package/src/module/meta/controller/view-master.controller.ts +86 -86
- package/src/module/meta/dto/entity-list-data.dto.ts +6 -6
- package/src/module/meta/dto/entity-tab.dto.ts +4 -4
- package/src/module/meta/dto/entity-table.dto.ts +12 -10
- package/src/module/meta/entity/app-master.entity.ts +37 -37
- package/src/module/meta/entity/attribute-master.entity.ts +92 -92
- package/src/module/meta/entity/base-entity.entity.ts +75 -75
- package/src/module/meta/entity/entity-master.entity.ts +85 -85
- package/src/module/meta/entity/entity-relation-data.entity.ts +29 -29
- package/src/module/meta/entity/entity-relation.entity.ts +23 -23
- package/src/module/meta/entity/entity-table-column.entity.ts +61 -61
- package/src/module/meta/entity/entity-table.entity.ts +50 -50
- package/src/module/meta/entity/media-data.entity.ts +32 -32
- package/src/module/meta/entity/preference.entity.ts +62 -62
- package/src/module/meta/entity/view-master.entity.ts +41 -41
- package/src/module/meta/entity.module.ts +168 -166
- package/src/module/meta/repository/app-master.repository.ts +20 -20
- package/src/module/meta/repository/attribute-master.repository.ts +156 -156
- package/src/module/meta/repository/entity-attribute-update.repository.ts +48 -48
- package/src/module/meta/repository/entity-master.repository.ts +110 -110
- package/src/module/meta/repository/entity-relation.repository.ts +23 -0
- package/src/module/meta/repository/entity-table-column.repository.ts +39 -39
- package/src/module/meta/repository/entity-table.repository.ts +53 -53
- package/src/module/meta/repository/media-data.repository.ts +50 -50
- package/src/module/meta/repository/preference.repository.ts +20 -20
- package/src/module/meta/repository/user-app-mapping.repository.ts +28 -28
- package/src/module/meta/repository/view-master.repository.ts +42 -42
- package/src/module/meta/service/app-master.service.ts +37 -37
- package/src/module/meta/service/attribute-master.service.ts +130 -130
- package/src/module/meta/service/common.service.ts +9 -9
- package/src/module/meta/service/entity-attribute-update.service.ts +26 -26
- package/src/module/meta/service/entity-dynamic.service.ts +822 -818
- package/src/module/meta/service/entity-list.service.ts +201 -201
- package/src/module/meta/service/entity-master.service.ts +171 -171
- package/src/module/meta/service/entity-realation-data.service.ts +9 -9
- package/src/module/meta/service/entity-relation.service.ts +74 -69
- package/src/module/meta/service/entity-service-impl.service.ts +439 -439
- package/src/module/meta/service/entity-table-column.service.ts +39 -39
- package/src/module/meta/service/entity-table.service.ts +157 -157
- package/src/module/meta/service/entity-validation.service.ts +187 -187
- package/src/module/meta/service/entity.service.ts +59 -59
- package/src/module/meta/service/field-group.service.ts +103 -103
- package/src/module/meta/service/media-data.service.ts +591 -573
- package/src/module/meta/service/populate-meta.service.ts +222 -222
- package/src/module/meta/service/preference.service.ts +16 -16
- package/src/module/meta/service/resolver.service.ts +291 -291
- package/src/module/meta/service/section-master.service.ts +104 -104
- package/src/module/meta/service/update-form-json.service.ts +22 -22
- package/src/module/meta/service/user-app-mapping.service.ts +17 -17
- package/src/module/meta/service/view-master.service.ts +127 -127
- package/src/module/microservice-client/microservice-clients.module.ts +13 -13
- package/src/module/microservice-client/service/microservice-client-factory.ts +37 -37
- package/src/module/microservice-client/service/microservice-clients.ts +4 -4
- package/src/module/module/controller/menu.controller.ts +15 -15
- package/src/module/module/controller/module-access.controller.ts +134 -134
- package/src/module/module/entity/menu.entity.ts +43 -43
- package/src/module/module/entity/module-access.entity.ts +25 -25
- package/src/module/module/entity/module-action.entity.ts +17 -17
- package/src/module/module/entity/module.entity.ts +52 -52
- package/src/module/module/module.module.ts +42 -42
- package/src/module/module/repository/menu.repository.ts +186 -186
- package/src/module/module/repository/module-access.repository.ts +344 -344
- package/src/module/module/service/menu.service.ts +82 -82
- package/src/module/module/service/module-access.service.ts +199 -199
- package/src/module/notification/controller/notification.controller.ts +58 -58
- package/src/module/notification/controller/otp.controller.ts +117 -117
- package/src/module/notification/entity/notification.entity.ts +26 -26
- package/src/module/notification/entity/otp.entity.ts +28 -28
- package/src/module/notification/firebase-admin.config.ts +22 -22
- package/src/module/notification/notification.module.ts +69 -69
- package/src/module/notification/repository/otp.repository.ts +27 -27
- package/src/module/notification/service/email.service.ts +127 -127
- package/src/module/notification/service/notification.service.ts +164 -164
- package/src/module/notification/service/otp.service.ts +133 -133
- package/src/module/third-party-module/entity/third-party-api-registry.entity.ts +52 -52
- package/src/module/third-party-module/repository/third-party-api-registry.repository.ts +20 -20
- package/src/module/third-party-module/service/api-registry.service.ts +13 -13
- package/src/module/third-party-module/third-party.module.ts +12 -12
- package/src/module/user/controller/login.controller.ts +198 -198
- package/src/module/user/controller/user.controller.ts +40 -40
- package/src/module/user/dto/create-user.dto.ts +62 -62
- package/src/module/user/dto/update-user.dto.ts +4 -4
- package/src/module/user/entity/role.entity.ts +33 -33
- package/src/module/user/entity/user-role-mapping.entity.ts +38 -38
- package/src/module/user/entity/user-session.entity.ts +73 -73
- package/src/module/user/entity/user.entity.ts +59 -59
- package/src/module/user/repository/role.repository.ts +96 -96
- package/src/module/user/repository/user-role-mapping.repository.ts +126 -126
- package/src/module/user/repository/user.repository.ts +50 -50
- package/src/module/user/repository/userSession.repository.ts +33 -33
- package/src/module/user/service/login.service.ts +326 -326
- package/src/module/user/service/role.service.ts +197 -197
- package/src/module/user/service/user-role-mapping.service.ts +98 -98
- package/src/module/user/service/user-session.service.ts +200 -200
- package/src/module/user/service/user.service.ts +368 -368
- package/src/module/user/user.module.ts +65 -65
- package/src/module/workflow/controller/action-category.controller.ts +54 -54
- package/src/module/workflow/controller/action-resource-mapping.controller.ts +23 -23
- package/src/module/workflow/controller/action-template-mapping.controller.ts +35 -35
- package/src/module/workflow/controller/action.controller.ts +111 -111
- package/src/module/workflow/controller/activity-log.controller.ts +55 -55
- package/src/module/workflow/controller/comm-template.controller.ts +43 -43
- package/src/module/workflow/controller/entity-modification.controller.ts +35 -35
- package/src/module/workflow/controller/form-master.controller.ts +43 -43
- package/src/module/workflow/controller/stage-group.controller.ts +48 -48
- package/src/module/workflow/controller/stage.controller.ts +50 -50
- package/src/module/workflow/controller/task.controller.ts +77 -77
- package/src/module/workflow/controller/workflow-list-master.controller.ts +44 -44
- package/src/module/workflow/controller/workflow-meta.controller.ts +80 -80
- package/src/module/workflow/controller/workflow.controller.ts +67 -67
- package/src/module/workflow/entity/action-category.entity.ts +38 -38
- package/src/module/workflow/entity/action-data.entity.ts +55 -55
- package/src/module/workflow/entity/action-resources-mapping.entity.ts +29 -29
- package/src/module/workflow/entity/action-template-mapping.entity.ts +17 -17
- package/src/module/workflow/entity/action.entity.ts +53 -53
- package/src/module/workflow/entity/activity-log.entity.ts +43 -43
- package/src/module/workflow/entity/comm-template.entity.ts +43 -43
- package/src/module/workflow/entity/entity-modification.entity.ts +38 -38
- package/src/module/workflow/entity/form.entity.ts +25 -25
- package/src/module/workflow/entity/stage-action-mapping.entity.ts +17 -17
- package/src/module/workflow/entity/stage-group.entity.ts +23 -23
- package/src/module/workflow/entity/stage-movement-data.entity.ts +38 -38
- package/src/module/workflow/entity/stage.entity.ts +20 -20
- package/src/module/workflow/entity/task-data.entity.ts +88 -88
- package/src/module/workflow/entity/template-attach-mapper.entity.ts +30 -30
- package/src/module/workflow/entity/workflow-data.entity.ts +11 -11
- package/src/module/workflow/entity/workflow-level-mapping.entity.ts +18 -18
- package/src/module/workflow/entity/workflow.entity.ts +20 -20
- package/src/module/workflow/repository/action-category.repository.ts +79 -79
- package/src/module/workflow/repository/action-data.repository.ts +346 -346
- package/src/module/workflow/repository/action.repository.ts +339 -339
- package/src/module/workflow/repository/activity-log.repository.ts +148 -148
- package/src/module/workflow/repository/comm-template.repository.ts +157 -157
- package/src/module/workflow/repository/form-master.repository.ts +50 -50
- package/src/module/workflow/repository/stage-group.repository.ts +186 -186
- package/src/module/workflow/repository/stage-movement.repository.ts +257 -257
- package/src/module/workflow/repository/stage.repository.ts +160 -160
- package/src/module/workflow/repository/task.repository.ts +151 -151
- package/src/module/workflow/repository/workflow.repository.ts +42 -42
- package/src/module/workflow/service/action-category.service.ts +33 -33
- package/src/module/workflow/service/action-data.service.ts +62 -62
- package/src/module/workflow/service/action-resources-mapping.service.ts +10 -10
- package/src/module/workflow/service/action-template-mapping.service.ts +140 -140
- package/src/module/workflow/service/action.service.ts +302 -306
- package/src/module/workflow/service/activity-log.service.ts +107 -107
- package/src/module/workflow/service/comm-template.service.ts +180 -180
- package/src/module/workflow/service/entity-modification.service.ts +61 -61
- package/src/module/workflow/service/form-master.service.ts +35 -35
- package/src/module/workflow/service/populate-workflow.service.ts +320 -320
- package/src/module/workflow/service/stage-action-mapping.service.ts +5 -5
- package/src/module/workflow/service/stage-group.service.ts +344 -344
- package/src/module/workflow/service/stage.service.ts +207 -207
- package/src/module/workflow/service/task.service.ts +550 -549
- package/src/module/workflow/service/workflow-list-master.service.ts +68 -68
- package/src/module/workflow/service/workflow-meta.service.ts +639 -639
- package/src/module/workflow/service/workflow.service.ts +213 -213
- package/src/module/workflow/workflow.module.ts +180 -180
- package/src/module/workflow-automation/SCHEDULING_GUIDE.md +145 -145
- package/src/module/workflow-automation/controller/workflow-automation.controller.ts +43 -43
- package/src/module/workflow-automation/entity/workflow-automation-action.entity.ts +26 -26
- package/src/module/workflow-automation/entity/workflow-automation.entity.ts +40 -40
- package/src/module/workflow-automation/interface/action.decorator.ts +7 -7
- package/src/module/workflow-automation/interface/action.interface.ts +5 -5
- package/src/module/workflow-automation/service/action-registery.service.ts +35 -35
- package/src/module/workflow-automation/service/schedule-handler.service.ts +168 -168
- package/src/module/workflow-automation/service/workflow-automation-engine.service.ts +219 -219
- package/src/module/workflow-automation/service/workflow-automation.service.ts +515 -515
- package/src/module/workflow-automation/workflow-automation.module.ts +54 -54
- package/src/module/workflow-schedule/INSTALLATION.md +244 -244
- package/src/module/workflow-schedule/MULTI_PROJECT_GUIDE.md +196 -196
- package/src/module/workflow-schedule/README.md +422 -422
- package/src/module/workflow-schedule/constants/schedule.constants.ts +48 -48
- package/src/module/workflow-schedule/controller/workflow-schedule.controller.ts +255 -255
- package/src/module/workflow-schedule/docs/CLAUDE_CODE_GUIDE.md +510 -510
- package/src/module/workflow-schedule/docs/CLAUDE_CODE_PROMPT.md +362 -362
- package/src/module/workflow-schedule/docs/RUN_CLAUDE_CODE.sh +68 -68
- package/src/module/workflow-schedule/dto/create-schedule.dto.ts +147 -147
- package/src/module/workflow-schedule/dto/get-execution-logs.dto.ts +119 -119
- package/src/module/workflow-schedule/dto/update-schedule.dto.ts +96 -96
- package/src/module/workflow-schedule/entities/scheduled-workflow.entity.ts +148 -148
- package/src/module/workflow-schedule/entities/workflow-execution-log.entity.ts +154 -154
- package/src/module/workflow-schedule/interfaces/schedule-job-data.interface.ts +53 -53
- package/src/module/workflow-schedule/interfaces/workflow-schedule-options.interface.ts +12 -12
- package/src/module/workflow-schedule/processors/schedule.processor.ts +620 -620
- package/src/module/workflow-schedule/service/workflow-schedule.service.ts +598 -598
- package/src/module/workflow-schedule/workflow-schedule.module.ts +67 -67
- package/src/resources/dev.properties.yaml +31 -31
- package/src/resources/local.properties.yaml +27 -27
- package/src/resources/properties.module.ts +12 -12
- package/src/resources/properties.yaml.ts +11 -11
- package/src/resources/uat.properties.yaml +31 -31
- package/src/table.config.ts +133 -135
- package/src/utils/dto/excel-data.dto.ts +14 -14
- package/src/utils/dto/excelsheet-data.dto.ts +5 -5
- package/src/utils/service/base64util.service.ts +18 -18
- package/src/utils/service/clockIDGenUtil.service.ts +21 -21
- package/src/utils/service/codeGenerator.service.ts +22 -22
- package/src/utils/service/dateUtil.service.ts +17 -17
- package/src/utils/service/encryptUtil.service.ts +97 -97
- package/src/utils/service/excel-helper.service.ts +72 -72
- package/src/utils/service/excelUtil.service.ts +15 -15
- package/src/utils/service/file-util.service.ts +11 -11
- package/src/utils/service/json-util.service.ts +23 -23
- package/src/utils/service/loggingUtil.service.ts +88 -88
- package/src/utils/service/reflection-helper.service.ts +62 -62
- package/src/utils/service/wbsCodeGen.service.ts +8 -8
- package/src/utils/utils.module.ts +27 -27
- package/tsconfig.build.json +4 -4
- package/tsconfig.json +24 -24
- 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 -626
- 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/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 -902
- 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,620 +1,75 @@
|
|
|
1
|
-
import { Injectable
|
|
2
|
-
import { EntityServiceImpl } from 'src/module/meta/service/entity-service-impl.service';
|
|
3
|
-
import {
|
|
4
|
-
import { LinkedAttributes } from '../entity/linked_attribute.entity';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
.
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
.
|
|
59
|
-
.
|
|
60
|
-
.
|
|
61
|
-
.
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
.insert()
|
|
77
|
-
.into(LinkedAttributes)
|
|
78
|
-
.values(newPayloads)
|
|
79
|
-
.execute();
|
|
80
|
-
|
|
81
|
-
// Step 4: Return inserted list
|
|
82
|
-
const ids = insertResult.identifiers.map((i) => i.id);
|
|
83
|
-
|
|
84
|
-
const newlyCreated = await this.dataSource
|
|
85
|
-
.getRepository(LinkedAttributes)
|
|
86
|
-
.createQueryBuilder('la')
|
|
87
|
-
.where('la.id IN (:...ids)', { ids })
|
|
88
|
-
.andWhere('la.organization_id = :orgId', { orgId })
|
|
89
|
-
.getMany();
|
|
90
|
-
|
|
91
|
-
return newlyCreated;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Generate the next sequence number for a linked attribute
|
|
96
|
-
* @param mapped_entity_type - Main entity type (e.g., "LEAD")
|
|
97
|
-
* @param applicable_entity_type - Source 1:M entity (e.g., "LFMG")
|
|
98
|
-
* @param applicable_attribute_key - Source attribute (e.g., "name")
|
|
99
|
-
* @param organization_id - Organization ID
|
|
100
|
-
* @returns Next available sequence number
|
|
101
|
-
*/
|
|
102
|
-
private async generateNextSequence(
|
|
103
|
-
mapped_entity_type: string,
|
|
104
|
-
applicable_entity_type: string,
|
|
105
|
-
applicable_attribute_key: string,
|
|
106
|
-
organization_id: number,
|
|
107
|
-
): Promise<number> {
|
|
108
|
-
const result = await this.dataSource
|
|
109
|
-
.getRepository(LinkedAttributes)
|
|
110
|
-
.createQueryBuilder('fla')
|
|
111
|
-
.select('MAX(fla.sequence)', 'max_sequence')
|
|
112
|
-
.where('fla.mapped_entity_type = :mapped_entity_type', {
|
|
113
|
-
mapped_entity_type,
|
|
114
|
-
})
|
|
115
|
-
.andWhere('fla.applicable_entity_type = :applicable_entity_type', {
|
|
116
|
-
applicable_entity_type,
|
|
117
|
-
})
|
|
118
|
-
.andWhere('fla.applicable_attribute_key = :applicable_attribute_key', {
|
|
119
|
-
applicable_attribute_key,
|
|
120
|
-
})
|
|
121
|
-
.andWhere('fla.organization_id = :organization_id', { organization_id })
|
|
122
|
-
.getRawOne();
|
|
123
|
-
|
|
124
|
-
const maxSequence = result?.max_sequence;
|
|
125
|
-
|
|
126
|
-
// If no records exist or max is null, return 1; otherwise return max + 1
|
|
127
|
-
return maxSequence ? maxSequence + 1 : 1;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Generate a flatjson attribute key in format: ENTITY__attribute__N
|
|
132
|
-
* @param applicable_entity_type - Entity code (e.g., "LFMG")
|
|
133
|
-
* @param applicable_attribute_key - Attribute key (e.g., "name")
|
|
134
|
-
* @param sequence - Sequence number (e.g., 1)
|
|
135
|
-
* @returns Generated key (e.g., "LFMG__name__1")
|
|
136
|
-
* @example generateAttributeKey('LFMG', 'name', 1) => 'LFMG__name__1'
|
|
137
|
-
*/
|
|
138
|
-
public generateAttributeKey(
|
|
139
|
-
applicable_entity_type: string,
|
|
140
|
-
applicable_attribute_key: string,
|
|
141
|
-
sequence: number,
|
|
142
|
-
): string {
|
|
143
|
-
// Validate inputs
|
|
144
|
-
if (!applicable_entity_type || applicable_entity_type.trim() === '') {
|
|
145
|
-
throw new Error('applicable_entity_type is required and cannot be empty');
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
if (!applicable_attribute_key || applicable_attribute_key.trim() === '') {
|
|
149
|
-
throw new Error(
|
|
150
|
-
'applicable_attribute_key is required and cannot be empty',
|
|
151
|
-
);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
if (!sequence || sequence < 1 || !Number.isInteger(sequence)) {
|
|
155
|
-
throw new Error('sequence must be a positive integer greater than 0');
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
// Generate and return formatted key
|
|
159
|
-
return `${applicable_entity_type}__${applicable_attribute_key}__${sequence}`;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Create a SavedFilter for a linked attribute
|
|
164
|
-
* @param entity_type - Entity type to filter (e.g., "LFMG")
|
|
165
|
-
* @param conditions - Array of filter conditions
|
|
166
|
-
* @param attribute_key - Linked attribute key (for naming)
|
|
167
|
-
* @param loggedInUser - Current user context
|
|
168
|
-
* @returns Generated filter code
|
|
169
|
-
*/
|
|
170
|
-
private async createFilterForLinkedAttribute(
|
|
171
|
-
entity_type: string,
|
|
172
|
-
conditions: Array<{
|
|
173
|
-
filter_attribute: string;
|
|
174
|
-
filter_operator: string;
|
|
175
|
-
filter_value: any;
|
|
176
|
-
}>,
|
|
177
|
-
attribute_key: string,
|
|
178
|
-
loggedInUser: any,
|
|
179
|
-
): Promise<string> {
|
|
180
|
-
return await this.dataSource.transaction(async (transactionManager) => {
|
|
181
|
-
// Step 1: Generate unique filter code
|
|
182
|
-
const timestamp = Date.now();
|
|
183
|
-
const filterCode = `LA_${entity_type}_${attribute_key}_${timestamp}`;
|
|
184
|
-
|
|
185
|
-
// Step 2: Create SavedFilterMaster
|
|
186
|
-
const filterMasterData = {
|
|
187
|
-
name: `Auto Filter - ${attribute_key}`,
|
|
188
|
-
code: filterCode,
|
|
189
|
-
mapped_entity_type: entity_type,
|
|
190
|
-
filter_scope: 'FILTER' as const,
|
|
191
|
-
organization_id: loggedInUser.organization_id,
|
|
192
|
-
level_type: loggedInUser.level_type,
|
|
193
|
-
level_id: loggedInUser.level_id,
|
|
194
|
-
user_id: loggedInUser.id,
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
const filterMaster = await this.savedFilterService.createEntity(
|
|
198
|
-
filterMasterData,
|
|
199
|
-
loggedInUser,
|
|
200
|
-
);
|
|
201
|
-
|
|
202
|
-
// Step 3: Create SavedFilterDetail records
|
|
203
|
-
const detailPromises = conditions.map((condition) => {
|
|
204
|
-
const detailData = {
|
|
205
|
-
mapped_filter_code: filterMaster.code,
|
|
206
|
-
filter_entity_type: entity_type,
|
|
207
|
-
filter_attribute: condition.filter_attribute,
|
|
208
|
-
filter_operator: condition.filter_operator,
|
|
209
|
-
filter_value: String(condition.filter_value),
|
|
210
|
-
organization_id: loggedInUser.organization_id,
|
|
211
|
-
level_type: loggedInUser.level_type,
|
|
212
|
-
level_id: loggedInUser.level_id,
|
|
213
|
-
};
|
|
214
|
-
|
|
215
|
-
return transactionManager.save('SavedFilterDetail', detailData);
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
await Promise.all(detailPromises);
|
|
219
|
-
|
|
220
|
-
// Step 4: Return the generated filter code
|
|
221
|
-
return filterMaster.code;
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* Smart creation of linked attribute with auto-generation
|
|
227
|
-
* @param payload - Linked attribute data
|
|
228
|
-
* @param loggedInUser - Current user context
|
|
229
|
-
* @returns Created LinkedAttribute entity
|
|
230
|
-
*/
|
|
231
|
-
async createLinkedAttributeSmart(
|
|
232
|
-
payload: CreateLinkedAttributeSmartDto,
|
|
233
|
-
loggedInUser: any,
|
|
234
|
-
): Promise<LinkedAttributes> {
|
|
235
|
-
// Step 1: Validate input
|
|
236
|
-
const validation = await this.validateLinkedAttribute(
|
|
237
|
-
{
|
|
238
|
-
field_name: payload.field_name,
|
|
239
|
-
mapped_entity_type: payload.mapped_entity_type,
|
|
240
|
-
applicable_entity_type: payload.applicable_entity_type,
|
|
241
|
-
applicable_attribute_key: payload.applicable_attribute_key,
|
|
242
|
-
organization_id: loggedInUser.organization_id,
|
|
243
|
-
},
|
|
244
|
-
loggedInUser,
|
|
245
|
-
);
|
|
246
|
-
|
|
247
|
-
if (!validation.valid) {
|
|
248
|
-
throw new BadRequestException(validation.errors.join(', '));
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
// Step 2: Generate sequence number
|
|
252
|
-
const sequence = await this.generateNextSequence(
|
|
253
|
-
payload.mapped_entity_type,
|
|
254
|
-
payload.applicable_entity_type,
|
|
255
|
-
payload.applicable_attribute_key,
|
|
256
|
-
loggedInUser.organization_id,
|
|
257
|
-
);
|
|
258
|
-
|
|
259
|
-
// Step 3: Generate attribute_key
|
|
260
|
-
const attribute_key = this.generateAttributeKey(
|
|
261
|
-
payload.applicable_entity_type,
|
|
262
|
-
payload.applicable_attribute_key,
|
|
263
|
-
sequence,
|
|
264
|
-
);
|
|
265
|
-
|
|
266
|
-
// Step 4: Create saved filter if conditions provided
|
|
267
|
-
let saved_filter_code: string | null = payload.saved_filter_code || null;
|
|
268
|
-
// if (payload.filter_conditions && payload.filter_conditions.length > 0) {
|
|
269
|
-
// saved_filter_code = await this.createFilterForLinkedAttribute(
|
|
270
|
-
// payload.applicable_entity_type,
|
|
271
|
-
// payload.filter_conditions,
|
|
272
|
-
// attribute_key,
|
|
273
|
-
// loggedInUser,
|
|
274
|
-
// );
|
|
275
|
-
// }
|
|
276
|
-
|
|
277
|
-
// Step 5: Create LinkedAttribute entity
|
|
278
|
-
let linkedAttrData:any = {
|
|
279
|
-
field_name: payload.field_name,
|
|
280
|
-
attribute_key,
|
|
281
|
-
applicable_entity_type: payload.applicable_entity_type,
|
|
282
|
-
applicable_attribute_key: payload.applicable_attribute_key,
|
|
283
|
-
mapped_entity_type: payload.mapped_entity_type,
|
|
284
|
-
saved_filter_code,
|
|
285
|
-
sequence,
|
|
286
|
-
organization_id: loggedInUser.organization_id,
|
|
287
|
-
level_type: loggedInUser.level_type,
|
|
288
|
-
level_id: loggedInUser.level_id,
|
|
289
|
-
entity_type:'LNATR'
|
|
290
|
-
};
|
|
291
|
-
|
|
292
|
-
const linkedAttribute = (await super.createEntity(
|
|
293
|
-
linkedAttrData,
|
|
294
|
-
loggedInUser,
|
|
295
|
-
)) as LinkedAttributes;
|
|
296
|
-
|
|
297
|
-
// Step 6: Trigger backfill if requested (async, don't await)
|
|
298
|
-
if (payload.backfill) {
|
|
299
|
-
this.backfillLinkedAttribute(linkedAttribute.id, loggedInUser).catch(
|
|
300
|
-
(err) =>
|
|
301
|
-
console.error(
|
|
302
|
-
`Backfill failed for linked attribute ${linkedAttribute.id}:`,
|
|
303
|
-
err,
|
|
304
|
-
),
|
|
305
|
-
);
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
return linkedAttribute;
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
/**
|
|
312
|
-
* Validate linked attribute payload before creation
|
|
313
|
-
* @param payload - Linked attribute data to validate
|
|
314
|
-
* @param loggedInUser - Current user context
|
|
315
|
-
* @returns Validation result with errors array
|
|
316
|
-
*/
|
|
317
|
-
async validateLinkedAttribute(
|
|
318
|
-
payload: {
|
|
319
|
-
field_name: string;
|
|
320
|
-
mapped_entity_type: string;
|
|
321
|
-
applicable_entity_type: string;
|
|
322
|
-
applicable_attribute_key: string;
|
|
323
|
-
attribute_key?: string;
|
|
324
|
-
organization_id: number;
|
|
325
|
-
},
|
|
326
|
-
loggedInUser: any,
|
|
327
|
-
): Promise<{ valid: boolean; errors: string[] }> {
|
|
328
|
-
const errors: string[] = [];
|
|
329
|
-
|
|
330
|
-
// Run all validations in parallel
|
|
331
|
-
const [
|
|
332
|
-
duplicateError,
|
|
333
|
-
mappedEntityError,
|
|
334
|
-
applicableEntityError,
|
|
335
|
-
attributeError,
|
|
336
|
-
] = await Promise.all([
|
|
337
|
-
this.checkDuplicateAttributeKey(
|
|
338
|
-
payload.attribute_key,
|
|
339
|
-
payload.organization_id,
|
|
340
|
-
),
|
|
341
|
-
this.validateEntityTypeExists(
|
|
342
|
-
payload.mapped_entity_type,
|
|
343
|
-
loggedInUser,
|
|
344
|
-
),
|
|
345
|
-
this.validateEntityTypeExists(
|
|
346
|
-
payload.applicable_entity_type,
|
|
347
|
-
loggedInUser,
|
|
348
|
-
),
|
|
349
|
-
this.validateAttributeKeyExists(
|
|
350
|
-
payload.applicable_entity_type,
|
|
351
|
-
payload.applicable_attribute_key,
|
|
352
|
-
loggedInUser,
|
|
353
|
-
),
|
|
354
|
-
]);
|
|
355
|
-
|
|
356
|
-
// Collect errors
|
|
357
|
-
if (duplicateError) errors.push(duplicateError);
|
|
358
|
-
if (mappedEntityError) errors.push(mappedEntityError);
|
|
359
|
-
if (applicableEntityError) errors.push(applicableEntityError);
|
|
360
|
-
if (attributeError) errors.push(attributeError);
|
|
361
|
-
|
|
362
|
-
// Validate required fields
|
|
363
|
-
this.validateRequiredFields(payload, errors);
|
|
364
|
-
|
|
365
|
-
return { valid: errors.length === 0, errors };
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
/**
|
|
369
|
-
* Validate that all required fields are present and not empty
|
|
370
|
-
* @param payload - Payload to validate
|
|
371
|
-
* @param errors - Array to collect error messages
|
|
372
|
-
*/
|
|
373
|
-
private validateRequiredFields(
|
|
374
|
-
payload: {
|
|
375
|
-
field_name: string;
|
|
376
|
-
mapped_entity_type: string;
|
|
377
|
-
applicable_entity_type: string;
|
|
378
|
-
applicable_attribute_key: string;
|
|
379
|
-
},
|
|
380
|
-
errors: string[],
|
|
381
|
-
): void {
|
|
382
|
-
const requiredFields = [
|
|
383
|
-
{ field: 'field_name', value: payload.field_name },
|
|
384
|
-
{ field: 'mapped_entity_type', value: payload.mapped_entity_type },
|
|
385
|
-
{ field: 'applicable_entity_type', value: payload.applicable_entity_type },
|
|
386
|
-
{ field: 'applicable_attribute_key', value: payload.applicable_attribute_key },
|
|
387
|
-
];
|
|
388
|
-
|
|
389
|
-
for (const { field, value } of requiredFields) {
|
|
390
|
-
if (!value || (typeof value === 'string' && value.trim() === '')) {
|
|
391
|
-
errors.push(`Required field '${field}' is missing or empty`);
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
/**
|
|
397
|
-
* Check if attribute_key already exists for the organization
|
|
398
|
-
* @param attribute_key - Attribute key to check
|
|
399
|
-
* @param organization_id - Organization ID
|
|
400
|
-
* @returns Error message if duplicate exists, null otherwise
|
|
401
|
-
*/
|
|
402
|
-
private async checkDuplicateAttributeKey(
|
|
403
|
-
attribute_key: string | undefined,
|
|
404
|
-
organization_id: number,
|
|
405
|
-
): Promise<string | null> {
|
|
406
|
-
// Skip check if attribute_key is not provided (will be auto-generated)
|
|
407
|
-
if (!attribute_key || attribute_key.trim() === '') {
|
|
408
|
-
return null;
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
const existing = await this.dataSource
|
|
412
|
-
.getRepository(LinkedAttributes)
|
|
413
|
-
.createQueryBuilder('fla')
|
|
414
|
-
.where('fla.attribute_key = :attribute_key', { attribute_key })
|
|
415
|
-
.andWhere('fla.organization_id = :organization_id', { organization_id })
|
|
416
|
-
.getOne();
|
|
417
|
-
|
|
418
|
-
if (existing) {
|
|
419
|
-
return `Attribute key '${attribute_key}' already exists for this organization`;
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
return null;
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
/**
|
|
426
|
-
* Validate that entity type exists in frm_entity_master
|
|
427
|
-
* @param entity_type - Entity type to validate
|
|
428
|
-
* @param loggedInUser - Current user context
|
|
429
|
-
* @returns Error message if entity doesn't exist, null otherwise
|
|
430
|
-
*/
|
|
431
|
-
private async validateEntityTypeExists(
|
|
432
|
-
entity_type: string,
|
|
433
|
-
loggedInUser: any,
|
|
434
|
-
): Promise<string | null> {
|
|
435
|
-
if (!entity_type || entity_type.trim() === '') {
|
|
436
|
-
return null; // Will be caught by required field validation
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
try {
|
|
440
|
-
await this.entityMasterService.getEntityData(entity_type, loggedInUser);
|
|
441
|
-
return null; // Entity exists
|
|
442
|
-
} catch (error) {
|
|
443
|
-
return `Entity type '${entity_type}' does not exist`;
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
/**
|
|
448
|
-
* Validate that attribute exists in frm_attribute_master for the given entity
|
|
449
|
-
* @param entity_type - Entity type
|
|
450
|
-
* @param attribute_key - Attribute key to validate
|
|
451
|
-
* @param loggedInUser - Current user context
|
|
452
|
-
* @returns Error message if attribute doesn't exist, null otherwise
|
|
453
|
-
*/
|
|
454
|
-
private async validateAttributeKeyExists(
|
|
455
|
-
entity_type: string,
|
|
456
|
-
attribute_key: string,
|
|
457
|
-
loggedInUser: any,
|
|
458
|
-
): Promise<string | null> {
|
|
459
|
-
if (!entity_type || !attribute_key) {
|
|
460
|
-
return null; // Will be caught by required field validation
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
try {
|
|
464
|
-
const attributes =
|
|
465
|
-
await this.attributeMasterService.findAttributesByMappedEntityType(
|
|
466
|
-
entity_type,
|
|
467
|
-
loggedInUser,
|
|
468
|
-
);
|
|
469
|
-
|
|
470
|
-
const attributeExists = attributes.some(
|
|
471
|
-
(attr) => attr.attribute_key === attribute_key,
|
|
472
|
-
);
|
|
473
|
-
|
|
474
|
-
if (!attributeExists) {
|
|
475
|
-
return `Attribute '${attribute_key}' does not exist in entity '${entity_type}'`;
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
return null;
|
|
479
|
-
} catch (error) {
|
|
480
|
-
return `Error validating attribute '${attribute_key}' in entity '${entity_type}': ${error.message}`;
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
/**
|
|
485
|
-
* Backfill existing entities with a new linked attribute
|
|
486
|
-
* @param linked_attribute_id - ID of the linked attribute to backfill
|
|
487
|
-
* @param loggedInUser - Current user context
|
|
488
|
-
* @returns Summary of backfill operation
|
|
489
|
-
*/
|
|
490
|
-
async backfillLinkedAttribute(
|
|
491
|
-
linked_attribute_id: number,
|
|
492
|
-
loggedInUser: any,
|
|
493
|
-
): Promise<{
|
|
494
|
-
total: number;
|
|
495
|
-
updated: number;
|
|
496
|
-
failed: number;
|
|
497
|
-
errors: Array<{ entity_id: number; error: string }>;
|
|
498
|
-
}> {
|
|
499
|
-
// Step 1: Load linked attribute
|
|
500
|
-
const linkedAttr = await this.dataSource
|
|
501
|
-
.getRepository(LinkedAttributes)
|
|
502
|
-
.findOne({ where: { id: linked_attribute_id } });
|
|
503
|
-
|
|
504
|
-
if (!linkedAttr) {
|
|
505
|
-
throw new NotFoundException(
|
|
506
|
-
`LinkedAttribute with ID ${linked_attribute_id} not found`,
|
|
507
|
-
);
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
// Step 2: Get all entities of this type
|
|
511
|
-
const entityJsonRecords = await this.dataSource
|
|
512
|
-
.getRepository(EntityJson)
|
|
513
|
-
.createQueryBuilder('ej')
|
|
514
|
-
.select(['ej.entity_id'])
|
|
515
|
-
.where('ej.entity_type = :entityType', {
|
|
516
|
-
entityType: linkedAttr.mapped_entity_type,
|
|
517
|
-
})
|
|
518
|
-
.andWhere('ej.organization_id = :orgId', {
|
|
519
|
-
orgId: loggedInUser.organization_id,
|
|
520
|
-
})
|
|
521
|
-
.getMany();
|
|
522
|
-
|
|
523
|
-
// Step 3: Process in batches
|
|
524
|
-
const batchSize = 100;
|
|
525
|
-
const results = {
|
|
526
|
-
total: entityJsonRecords.length,
|
|
527
|
-
updated: 0,
|
|
528
|
-
failed: 0,
|
|
529
|
-
errors: [] as Array<{ entity_id: number; error: string }>,
|
|
530
|
-
};
|
|
531
|
-
|
|
532
|
-
for (let i = 0; i < entityJsonRecords.length; i += batchSize) {
|
|
533
|
-
const batch = entityJsonRecords.slice(i, i + batchSize);
|
|
534
|
-
|
|
535
|
-
for (const record of batch) {
|
|
536
|
-
try {
|
|
537
|
-
await this.entityJsonService.updateEntityJSON(
|
|
538
|
-
linkedAttr.mapped_entity_type,
|
|
539
|
-
record.entity_id,
|
|
540
|
-
loggedInUser,
|
|
541
|
-
);
|
|
542
|
-
results.updated++;
|
|
543
|
-
} catch (error) {
|
|
544
|
-
results.failed++;
|
|
545
|
-
results.errors.push({
|
|
546
|
-
entity_id: record.entity_id,
|
|
547
|
-
error: error.message,
|
|
548
|
-
});
|
|
549
|
-
console.error(
|
|
550
|
-
`Failed to update entity ${record.entity_id}:`,
|
|
551
|
-
error,
|
|
552
|
-
);
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
// Log progress
|
|
557
|
-
console.log(
|
|
558
|
-
`Backfill progress: ${Math.min(i + batchSize, results.total)}/${results.total}`,
|
|
559
|
-
);
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
return results;
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
/**
|
|
566
|
-
* Backfill all linked attributes for an entity type
|
|
567
|
-
* @param mapped_entity_type - Entity type to backfill
|
|
568
|
-
* @param loggedInUser - Current user context
|
|
569
|
-
* @returns Summary of backfill operation
|
|
570
|
-
*/
|
|
571
|
-
async backfillAllForEntity(
|
|
572
|
-
mapped_entity_type: string,
|
|
573
|
-
loggedInUser: any,
|
|
574
|
-
): Promise<{ updated: number; failed: number }> {
|
|
575
|
-
// Get all entities of this type
|
|
576
|
-
const entityJsonRecords = await this.dataSource
|
|
577
|
-
.getRepository(EntityJson)
|
|
578
|
-
.createQueryBuilder('ej')
|
|
579
|
-
.select(['ej.entity_id'])
|
|
580
|
-
.where('ej.entity_type = :entityType', { entityType: mapped_entity_type })
|
|
581
|
-
.andWhere('ej.organization_id = :orgId', {
|
|
582
|
-
orgId: loggedInUser.organization_id,
|
|
583
|
-
})
|
|
584
|
-
.getMany();
|
|
585
|
-
|
|
586
|
-
const batchSize = 100;
|
|
587
|
-
const results = {
|
|
588
|
-
updated: 0,
|
|
589
|
-
failed: 0,
|
|
590
|
-
};
|
|
591
|
-
|
|
592
|
-
for (let i = 0; i < entityJsonRecords.length; i += batchSize) {
|
|
593
|
-
const batch = entityJsonRecords.slice(i, i + batchSize);
|
|
594
|
-
|
|
595
|
-
for (const record of batch) {
|
|
596
|
-
try {
|
|
597
|
-
await this.entityJsonService.updateEntityJSON(
|
|
598
|
-
mapped_entity_type,
|
|
599
|
-
record.entity_id,
|
|
600
|
-
loggedInUser,
|
|
601
|
-
);
|
|
602
|
-
results.updated++;
|
|
603
|
-
} catch (error) {
|
|
604
|
-
results.failed++;
|
|
605
|
-
console.error(
|
|
606
|
-
`Failed to update entity ${record.entity_id}:`,
|
|
607
|
-
error,
|
|
608
|
-
);
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
// Log progress
|
|
613
|
-
console.log(
|
|
614
|
-
`Backfill all progress: ${Math.min(i + batchSize, entityJsonRecords.length)}/${entityJsonRecords.length}`,
|
|
615
|
-
);
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
return results;
|
|
619
|
-
}
|
|
620
|
-
}
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { EntityServiceImpl } from 'src/module/meta/service/entity-service-impl.service';
|
|
3
|
+
import { DataSource } from 'typeorm';
|
|
4
|
+
import { LinkedAttributes } from '../entity/linked_attribute.entity';
|
|
5
|
+
|
|
6
|
+
@Injectable()
|
|
7
|
+
export class LinkedAttributesService extends EntityServiceImpl {
|
|
8
|
+
constructor(private readonly dataSource: DataSource) {
|
|
9
|
+
super();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async createEntity(payload: any, loggedInUser: any): Promise<any> {
|
|
13
|
+
// Auto-generate attribute_key if missing OR empty
|
|
14
|
+
if (!payload.attribute_key || payload.attribute_key.trim() === '') {
|
|
15
|
+
payload.attribute_key = payload.field_name
|
|
16
|
+
.trim()
|
|
17
|
+
.toLowerCase()
|
|
18
|
+
.replace(/\s+/g, '_');
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Pass to base class create method
|
|
22
|
+
return super.createEntity(payload, loggedInUser);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async getAllLinkedAttributes(loggedInUser: any) {
|
|
26
|
+
const orgId = loggedInUser.organization_id;
|
|
27
|
+
|
|
28
|
+
return this.dataSource
|
|
29
|
+
.getRepository(LinkedAttributes)
|
|
30
|
+
.createQueryBuilder('fla')
|
|
31
|
+
.where('fla.organization_id = :orgId', { orgId })
|
|
32
|
+
.getMany();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async upsertLinkedAttributes(payloadList: any[], loggedInUser: any) {
|
|
36
|
+
const orgId = loggedInUser.organization_id;
|
|
37
|
+
|
|
38
|
+
// Step 1: Delete all existing rows for this organization
|
|
39
|
+
await this.dataSource
|
|
40
|
+
.createQueryBuilder()
|
|
41
|
+
.delete()
|
|
42
|
+
.from(LinkedAttributes)
|
|
43
|
+
.where('organization_id = :orgId', { orgId })
|
|
44
|
+
.execute();
|
|
45
|
+
|
|
46
|
+
// Step 2: Normalize & prepare payloads
|
|
47
|
+
const newPayloads = payloadList.map((item) => ({
|
|
48
|
+
...item,
|
|
49
|
+
organization_id: orgId,
|
|
50
|
+
attribute_key: item.attribute_key
|
|
51
|
+
? item.attribute_key.trim().toLowerCase().replace(/\s+/g, '_')
|
|
52
|
+
: item.field_name.trim().toLowerCase().replace(/\s+/g, '_'),
|
|
53
|
+
}));
|
|
54
|
+
|
|
55
|
+
// Step 3: Bulk Insert
|
|
56
|
+
const insertResult = await this.dataSource
|
|
57
|
+
.createQueryBuilder()
|
|
58
|
+
.insert()
|
|
59
|
+
.into(LinkedAttributes)
|
|
60
|
+
.values(newPayloads)
|
|
61
|
+
.execute();
|
|
62
|
+
|
|
63
|
+
// Step 4: Return inserted list
|
|
64
|
+
const ids = insertResult.identifiers.map((i) => i.id);
|
|
65
|
+
|
|
66
|
+
const newlyCreated = await this.dataSource
|
|
67
|
+
.getRepository(LinkedAttributes)
|
|
68
|
+
.createQueryBuilder('la')
|
|
69
|
+
.where('la.id IN (:...ids)', { ids })
|
|
70
|
+
.andWhere('la.organization_id = :orgId', { orgId })
|
|
71
|
+
.getMany();
|
|
72
|
+
|
|
73
|
+
return newlyCreated;
|
|
74
|
+
}
|
|
75
|
+
}
|