@hed-hog/core 0.0.349 → 0.0.351
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/dist/access-log/access-log.controller.d.ts +16 -0
- package/dist/access-log/access-log.controller.d.ts.map +1 -0
- package/dist/access-log/access-log.controller.js +44 -0
- package/dist/access-log/access-log.controller.js.map +1 -0
- package/dist/access-log/access-log.interceptor.d.ts +9 -0
- package/dist/access-log/access-log.interceptor.d.ts.map +1 -0
- package/dist/access-log/access-log.interceptor.js +46 -0
- package/dist/access-log/access-log.interceptor.js.map +1 -0
- package/dist/access-log/access-log.module.d.ts +3 -0
- package/dist/access-log/access-log.module.d.ts.map +1 -0
- package/dist/access-log/access-log.module.js +29 -0
- package/dist/access-log/access-log.module.js.map +1 -0
- package/dist/access-log/access-log.service.d.ts +47 -0
- package/dist/access-log/access-log.service.d.ts.map +1 -0
- package/dist/access-log/access-log.service.js +113 -0
- package/dist/access-log/access-log.service.js.map +1 -0
- package/dist/access-log/dto/query-access-log.dto.d.ts +8 -0
- package/dist/access-log/dto/query-access-log.dto.d.ts.map +1 -0
- package/dist/access-log/dto/query-access-log.dto.js +42 -0
- package/dist/access-log/dto/query-access-log.dto.js.map +1 -0
- package/dist/auth/auth.controller.d.ts +12 -12
- package/dist/auth/auth.service.d.ts +27 -27
- package/dist/auth/auth.service.d.ts.map +1 -1
- package/dist/auth/auth.service.js +0 -4
- package/dist/auth/auth.service.js.map +1 -1
- package/dist/challenge/challenge.service.d.ts +2 -2
- package/dist/challenge/challenge.service.d.ts.map +1 -1
- package/dist/challenge/challenge.service.js +0 -1
- package/dist/challenge/challenge.service.js.map +1 -1
- package/dist/core/system.module.d.ts.map +1 -1
- package/dist/core/system.module.js +1 -0
- package/dist/core/system.module.js.map +1 -1
- package/dist/core.module.d.ts.map +1 -1
- package/dist/core.module.js +15 -0
- package/dist/core.module.js.map +1 -1
- package/dist/dashboard/dashboard-user/dashboard-user.controller.d.ts +3 -3
- package/dist/dashboard/dashboard-user/dashboard-user.service.d.ts +3 -3
- package/dist/dashboard/dashboard.module.d.ts.map +1 -1
- package/dist/dashboard/dashboard.module.js +4 -1
- package/dist/dashboard/dashboard.module.js.map +1 -1
- package/dist/file/file.controller.js +0 -1
- package/dist/file/file.controller.js.map +1 -1
- package/dist/file/file.service.d.ts +65 -0
- package/dist/file/file.service.d.ts.map +1 -1
- package/dist/file/file.service.js +151 -3
- package/dist/file/file.service.js.map +1 -1
- package/dist/file/provider/abstract.provider.d.ts +8 -0
- package/dist/file/provider/abstract.provider.d.ts.map +1 -1
- package/dist/file/provider/abstract.provider.js.map +1 -1
- package/dist/file/provider/azure.provider.d.ts +4 -0
- package/dist/file/provider/azure.provider.d.ts.map +1 -1
- package/dist/file/provider/azure.provider.js +14 -0
- package/dist/file/provider/azure.provider.js.map +1 -1
- package/dist/file/provider/gcs.provider.d.ts +4 -0
- package/dist/file/provider/gcs.provider.d.ts.map +1 -1
- package/dist/file/provider/gcs.provider.js +14 -0
- package/dist/file/provider/gcs.provider.js.map +1 -1
- package/dist/file/provider/local.provider.d.ts +4 -0
- package/dist/file/provider/local.provider.d.ts.map +1 -1
- package/dist/file/provider/local.provider.js +19 -0
- package/dist/file/provider/local.provider.js.map +1 -1
- package/dist/file/provider/provider.factory.d.ts.map +1 -1
- package/dist/file/provider/provider.factory.js +3 -0
- package/dist/file/provider/provider.factory.js.map +1 -1
- package/dist/file/provider/s3.provider.d.ts +4 -0
- package/dist/file/provider/s3.provider.d.ts.map +1 -1
- package/dist/file/provider/s3.provider.js +17 -0
- package/dist/file/provider/s3.provider.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/mcp/guards/mcp-auth.guard.d.ts +6 -1
- package/dist/mcp/guards/mcp-auth.guard.d.ts.map +1 -1
- package/dist/mcp/guards/mcp-auth.guard.js +29 -2
- package/dist/mcp/guards/mcp-auth.guard.js.map +1 -1
- package/dist/mcp/mcp-api-key.controller.d.ts +32 -0
- package/dist/mcp/mcp-api-key.controller.d.ts.map +1 -0
- package/dist/mcp/mcp-api-key.controller.js +64 -0
- package/dist/mcp/mcp-api-key.controller.js.map +1 -0
- package/dist/mcp/mcp-api-key.service.d.ts +27 -0
- package/dist/mcp/mcp-api-key.service.d.ts.map +1 -0
- package/dist/mcp/mcp-api-key.service.js +74 -0
- package/dist/mcp/mcp-api-key.service.js.map +1 -0
- package/dist/mcp/mcp-audit.service.d.ts +3 -1
- package/dist/mcp/mcp-audit.service.d.ts.map +1 -1
- package/dist/mcp/mcp-audit.service.js +14 -2
- package/dist/mcp/mcp-audit.service.js.map +1 -1
- package/dist/mcp/mcp-registry.service.d.ts +1 -2
- package/dist/mcp/mcp-registry.service.d.ts.map +1 -1
- package/dist/mcp/mcp-registry.service.js +6 -2
- package/dist/mcp/mcp-registry.service.js.map +1 -1
- package/dist/mcp/mcp.controller.d.ts +3 -1
- package/dist/mcp/mcp.controller.d.ts.map +1 -1
- package/dist/mcp/mcp.controller.js +10 -2
- package/dist/mcp/mcp.controller.js.map +1 -1
- package/dist/mcp/mcp.module.d.ts.map +1 -1
- package/dist/mcp/mcp.module.js +80 -1
- package/dist/mcp/mcp.module.js.map +1 -1
- package/dist/mcp/tools/core-ai.mcp-tools.d.ts +45 -0
- package/dist/mcp/tools/core-ai.mcp-tools.d.ts.map +1 -0
- package/dist/mcp/tools/core-ai.mcp-tools.js +214 -0
- package/dist/mcp/tools/core-ai.mcp-tools.js.map +1 -0
- package/dist/mcp/tools/core-dashboard-items.mcp-tools.d.ts +21 -0
- package/dist/mcp/tools/core-dashboard-items.mcp-tools.d.ts.map +1 -0
- package/dist/mcp/tools/core-dashboard-items.mcp-tools.js +89 -0
- package/dist/mcp/tools/core-dashboard-items.mcp-tools.js.map +1 -0
- package/dist/mcp/tools/core-dashboard.mcp-tools.d.ts +29 -0
- package/dist/mcp/tools/core-dashboard.mcp-tools.d.ts.map +1 -0
- package/dist/mcp/tools/core-dashboard.mcp-tools.js +149 -0
- package/dist/mcp/tools/core-dashboard.mcp-tools.js.map +1 -0
- package/dist/mcp/tools/core-event-webhooks.mcp-tools.d.ts +30 -0
- package/dist/mcp/tools/core-event-webhooks.mcp-tools.d.ts.map +1 -0
- package/dist/mcp/tools/core-event-webhooks.mcp-tools.js +185 -0
- package/dist/mcp/tools/core-event-webhooks.mcp-tools.js.map +1 -0
- package/dist/mcp/tools/core-files.mcp-tools.d.ts +26 -0
- package/dist/mcp/tools/core-files.mcp-tools.d.ts.map +1 -0
- package/dist/mcp/tools/core-files.mcp-tools.js +140 -0
- package/dist/mcp/tools/core-files.mcp-tools.js.map +1 -0
- package/dist/mcp/tools/core-integration-events.mcp-tools.d.ts +26 -0
- package/dist/mcp/tools/core-integration-events.mcp-tools.d.ts.map +1 -0
- package/dist/mcp/tools/core-integration-events.mcp-tools.js +168 -0
- package/dist/mcp/tools/core-integration-events.mcp-tools.js.map +1 -0
- package/dist/mcp/tools/core-mail-profile.mcp-tools.d.ts +32 -0
- package/dist/mcp/tools/core-mail-profile.mcp-tools.d.ts.map +1 -0
- package/dist/mcp/tools/core-mail-profile.mcp-tools.js +178 -0
- package/dist/mcp/tools/core-mail-profile.mcp-tools.js.map +1 -0
- package/dist/mcp/tools/core-mail-sent.mcp-tools.d.ts +14 -0
- package/dist/mcp/tools/core-mail-sent.mcp-tools.d.ts.map +1 -0
- package/dist/mcp/tools/core-mail-sent.mcp-tools.js +106 -0
- package/dist/mcp/tools/core-mail-sent.mcp-tools.js.map +1 -0
- package/dist/mcp/tools/core-mail.mcp-tools.d.ts +36 -0
- package/dist/mcp/tools/core-mail.mcp-tools.d.ts.map +1 -0
- package/dist/mcp/tools/core-mail.mcp-tools.js +184 -0
- package/dist/mcp/tools/core-mail.mcp-tools.js.map +1 -0
- package/dist/mcp/tools/core-mcp-chat.mcp-tools.d.ts +21 -0
- package/dist/mcp/tools/core-mcp-chat.mcp-tools.d.ts.map +1 -0
- package/dist/mcp/tools/core-mcp-chat.mcp-tools.js +118 -0
- package/dist/mcp/tools/core-mcp-chat.mcp-tools.js.map +1 -0
- package/dist/mcp/tools/core-menus.mcp-tools.d.ts +40 -0
- package/dist/mcp/tools/core-menus.mcp-tools.d.ts.map +1 -0
- package/dist/mcp/tools/core-menus.mcp-tools.js +268 -0
- package/dist/mcp/tools/core-menus.mcp-tools.js.map +1 -0
- package/dist/mcp/tools/core-notifications.mcp-tools.d.ts +31 -0
- package/dist/mcp/tools/core-notifications.mcp-tools.d.ts.map +1 -0
- package/dist/mcp/tools/core-notifications.mcp-tools.js +178 -0
- package/dist/mcp/tools/core-notifications.mcp-tools.js.map +1 -0
- package/dist/mcp/tools/core-profile.mcp-tools.d.ts +20 -0
- package/dist/mcp/tools/core-profile.mcp-tools.d.ts.map +1 -0
- package/dist/mcp/tools/core-profile.mcp-tools.js +111 -0
- package/dist/mcp/tools/core-profile.mcp-tools.js.map +1 -0
- package/dist/mcp/tools/core-roles.mcp-tools.d.ts +70 -0
- package/dist/mcp/tools/core-roles.mcp-tools.d.ts.map +1 -0
- package/dist/mcp/tools/core-roles.mcp-tools.js +355 -0
- package/dist/mcp/tools/core-roles.mcp-tools.js.map +1 -0
- package/dist/mcp/tools/core-routes.mcp-tools.d.ts +52 -0
- package/dist/mcp/tools/core-routes.mcp-tools.d.ts.map +1 -0
- package/dist/mcp/tools/core-routes.mcp-tools.js +254 -0
- package/dist/mcp/tools/core-routes.mcp-tools.js.map +1 -0
- package/dist/mcp/tools/core-screens.mcp-tools.d.ts +47 -0
- package/dist/mcp/tools/core-screens.mcp-tools.d.ts.map +1 -0
- package/dist/mcp/tools/core-screens.mcp-tools.js +250 -0
- package/dist/mcp/tools/core-screens.mcp-tools.js.map +1 -0
- package/dist/mcp/tools/core-sessions.mcp-tools.d.ts +20 -0
- package/dist/mcp/tools/core-sessions.mcp-tools.d.ts.map +1 -0
- package/dist/mcp/tools/core-sessions.mcp-tools.js +128 -0
- package/dist/mcp/tools/core-sessions.mcp-tools.js.map +1 -0
- package/dist/mcp/tools/core-settings.mcp-tools.d.ts +25 -0
- package/dist/mcp/tools/core-settings.mcp-tools.d.ts.map +1 -1
- package/dist/mcp/tools/core-settings.mcp-tools.js +138 -0
- package/dist/mcp/tools/core-settings.mcp-tools.js.map +1 -1
- package/dist/mcp/tools/core-system.mcp-tools.d.ts +8 -0
- package/dist/mcp/tools/core-system.mcp-tools.d.ts.map +1 -0
- package/dist/mcp/tools/core-system.mcp-tools.js +40 -0
- package/dist/mcp/tools/core-system.mcp-tools.js.map +1 -0
- package/dist/mcp/tools/core-webhooks.mcp-tools.d.ts +46 -0
- package/dist/mcp/tools/core-webhooks.mcp-tools.d.ts.map +1 -0
- package/dist/mcp/tools/core-webhooks.mcp-tools.js +266 -0
- package/dist/mcp/tools/core-webhooks.mcp-tools.js.map +1 -0
- package/dist/mcp-chat/mcp-chat.controller.d.ts +5 -1
- package/dist/mcp-chat/mcp-chat.controller.d.ts.map +1 -1
- package/dist/mcp-chat/mcp-chat.controller.js +46 -0
- package/dist/mcp-chat/mcp-chat.controller.js.map +1 -1
- package/dist/mcp-chat/mcp-chat.service.d.ts +31 -3
- package/dist/mcp-chat/mcp-chat.service.d.ts.map +1 -1
- package/dist/mcp-chat/mcp-chat.service.js +776 -38
- package/dist/mcp-chat/mcp-chat.service.js.map +1 -1
- package/dist/notification/dto/create-notification.dto.d.ts +26 -0
- package/dist/notification/dto/create-notification.dto.d.ts.map +1 -0
- package/dist/notification/dto/create-notification.dto.js +86 -0
- package/dist/notification/dto/create-notification.dto.js.map +1 -0
- package/dist/notification/dto/update-progress.dto.d.ts +6 -0
- package/dist/notification/dto/update-progress.dto.d.ts.map +1 -0
- package/dist/notification/dto/update-progress.dto.js +33 -0
- package/dist/notification/dto/update-progress.dto.js.map +1 -0
- package/dist/notification/notification.controller.d.ts +112 -0
- package/dist/notification/notification.controller.d.ts.map +1 -0
- package/dist/notification/notification.controller.js +130 -0
- package/dist/notification/notification.controller.js.map +1 -0
- package/dist/notification/notification.module.d.ts +3 -0
- package/dist/notification/notification.module.d.ts.map +1 -0
- package/dist/notification/notification.module.js +29 -0
- package/dist/notification/notification.module.js.map +1 -0
- package/dist/notification/notification.service.d.ts +112 -0
- package/dist/notification/notification.service.d.ts.map +1 -0
- package/dist/notification/notification.service.js +269 -0
- package/dist/notification/notification.service.js.map +1 -0
- package/dist/pdf/pdf.service.js +1 -1
- package/dist/pdf/pdf.service.js.map +1 -1
- package/dist/profile/profile.controller.d.ts +4 -4
- package/dist/profile/profile.controller.js +0 -1
- package/dist/profile/profile.controller.js.map +1 -1
- package/dist/profile/profile.module.d.ts.map +1 -1
- package/dist/profile/profile.module.js +1 -0
- package/dist/profile/profile.module.js.map +1 -1
- package/dist/profile/profile.service.d.ts +4 -4
- package/dist/session/session.controller.d.ts +3 -3
- package/dist/session/session.service.d.ts +9 -9
- package/dist/setting/dto/update-setting-list.dto.d.ts +9 -0
- package/dist/setting/dto/update-setting-list.dto.d.ts.map +1 -0
- package/dist/setting/dto/update-setting-list.dto.js +44 -0
- package/dist/setting/dto/update-setting-list.dto.js.map +1 -0
- package/dist/setting/setting.controller.d.ts +20 -1
- package/dist/setting/setting.controller.d.ts.map +1 -1
- package/dist/setting/setting.controller.js +12 -0
- package/dist/setting/setting.controller.js.map +1 -1
- package/dist/setting/setting.service.d.ts +20 -1
- package/dist/setting/setting.service.d.ts.map +1 -1
- package/dist/setting/setting.service.js +80 -4
- package/dist/setting/setting.service.js.map +1 -1
- package/dist/task/task.service.d.ts +13 -0
- package/dist/task/task.service.d.ts.map +1 -1
- package/dist/task/task.service.js +85 -0
- package/dist/task/task.service.js.map +1 -1
- package/dist/token/token.service.d.ts.map +1 -1
- package/dist/token/token.service.js +0 -1
- package/dist/token/token.service.js.map +1 -1
- package/dist/user/user.controller.d.ts +11 -11
- package/dist/user/user.service.d.ts +27 -27
- package/dist/webhook-integration/dto/webhook-action.dto.d.ts +22 -0
- package/dist/webhook-integration/dto/webhook-action.dto.d.ts.map +1 -0
- package/dist/webhook-integration/dto/webhook-action.dto.js +120 -0
- package/dist/webhook-integration/dto/webhook-action.dto.js.map +1 -0
- package/dist/webhook-integration/webhook-integration.controller.d.ts +7 -5
- package/dist/webhook-integration/webhook-integration.controller.d.ts.map +1 -1
- package/dist/webhook-integration/webhook-integration.controller.js +18 -5
- package/dist/webhook-integration/webhook-integration.controller.js.map +1 -1
- package/dist/webhook-integration/webhook-integration.service.d.ts +18 -5
- package/dist/webhook-integration/webhook-integration.service.d.ts.map +1 -1
- package/dist/webhook-integration/webhook-integration.service.js +342 -59
- package/dist/webhook-integration/webhook-integration.service.js.map +1 -1
- package/dist/webhook-integration/webhook-utils.d.ts +1 -0
- package/dist/webhook-integration/webhook-utils.d.ts.map +1 -1
- package/dist/webhook-integration/webhook-utils.js +38 -0
- package/dist/webhook-integration/webhook-utils.js.map +1 -1
- package/hedhog/data/menu.yaml +63 -4
- package/hedhog/data/route.yaml +1437 -0
- package/hedhog/data/setting_group.yaml +112 -0
- package/hedhog/data/setting_subgroup.yaml +32 -0
- package/hedhog/frontend/app/access-log/page.tsx.ejs +772 -0
- package/hedhog/frontend/app/account/components/mcp-tokens.tsx.ejs +285 -0
- package/hedhog/frontend/app/account/layout.tsx.ejs +32 -55
- package/hedhog/frontend/app/account/mcp-tokens/page.tsx.ejs +5 -0
- package/hedhog/frontend/app/ai_agent/page.tsx.ejs +10 -3
- package/hedhog/frontend/app/dashboard/dashboard-home-tabs.tsx.ejs +33 -13
- package/hedhog/frontend/app/dashboard/management/tabs/components-tab.tsx.ejs +12 -5
- package/hedhog/frontend/app/dashboard/management/tabs/dashboards-tab.tsx.ejs +12 -5
- package/hedhog/frontend/app/integrations-webhooks/page.tsx.ejs +3559 -1835
- package/hedhog/frontend/app/mcp_chat/chat-components.tsx.ejs +633 -0
- package/hedhog/frontend/app/mcp_chat/chat-types.ts.ejs +16 -0
- package/hedhog/frontend/app/mcp_chat/page.tsx.ejs +583 -384
- package/hedhog/frontend/app/menu/page.tsx.ejs +9 -3
- package/hedhog/frontend/app/roles/page.tsx.ejs +18 -6
- package/hedhog/frontend/app/routes/page.tsx.ejs +9 -3
- package/hedhog/frontend/app/setting-list/page.tsx.ejs +822 -0
- package/hedhog/frontend/app/users/page.tsx.ejs +445 -203
- package/hedhog/frontend/app/users/user-access-sheet.tsx.ejs +310 -304
- package/hedhog/frontend/app/users/user-sheet.tsx.ejs +41 -44
- package/hedhog/frontend/messages/en.json +343 -3
- package/hedhog/frontend/messages/pt.json +343 -3
- package/hedhog/table/access_log.yaml +31 -0
- package/hedhog/table/mcp_api_key.yaml +30 -0
- package/hedhog/table/notification.yaml +72 -0
- package/hedhog/table/webhook_action_log.yaml +49 -0
- package/package.json +5 -4
- package/src/access-log/access-log.controller.ts +29 -0
- package/src/access-log/access-log.interceptor.ts +38 -0
- package/src/access-log/access-log.module.ts +16 -0
- package/src/access-log/access-log.service.ts +129 -0
- package/src/access-log/dto/query-access-log.dto.ts +23 -0
- package/src/auth/auth.service.ts +0 -7
- package/src/challenge/challenge.service.ts +0 -2
- package/src/core/system.module.ts +1 -0
- package/src/core.module.ts +15 -0
- package/src/dashboard/dashboard.module.ts +4 -1
- package/src/file/file.controller.ts +14 -14
- package/src/file/file.service.ts +198 -4
- package/src/file/provider/abstract.provider.ts +10 -0
- package/src/file/provider/azure.provider.ts +24 -0
- package/src/file/provider/gcs.provider.ts +20 -0
- package/src/file/provider/local.provider.ts +30 -2
- package/src/file/provider/provider.factory.ts +3 -0
- package/src/file/provider/s3.provider.ts +22 -0
- package/src/index.ts +5 -0
- package/src/mcp/guards/mcp-auth.guard.ts +64 -32
- package/src/mcp/mcp-api-key.controller.ts +42 -0
- package/src/mcp/mcp-api-key.service.ts +66 -0
- package/src/mcp/mcp-audit.service.ts +47 -36
- package/src/mcp/mcp-registry.service.ts +75 -69
- package/src/mcp/mcp.controller.ts +40 -30
- package/src/mcp/mcp.module.ts +115 -36
- package/src/mcp/tools/core-ai.mcp-tools.ts +156 -0
- package/src/mcp/tools/core-dashboard-items.mcp-tools.ts +63 -0
- package/src/mcp/tools/core-dashboard.mcp-tools.ts +103 -0
- package/src/mcp/tools/core-event-webhooks.mcp-tools.ts +134 -0
- package/src/mcp/tools/core-files.mcp-tools.ts +105 -0
- package/src/mcp/tools/core-integration-events.mcp-tools.ts +118 -0
- package/src/mcp/tools/core-mail-profile.mcp-tools.ts +128 -0
- package/src/mcp/tools/core-mail-sent.mcp-tools.ts +76 -0
- package/src/mcp/tools/core-mail.mcp-tools.ts +130 -0
- package/src/mcp/tools/core-mcp-chat.mcp-tools.ts +81 -0
- package/src/mcp/tools/core-menus.mcp-tools.ts +197 -0
- package/src/mcp/tools/core-notifications.mcp-tools.ts +128 -0
- package/src/mcp/tools/core-profile.mcp-tools.ts +74 -0
- package/src/mcp/tools/core-roles.mcp-tools.ts +288 -0
- package/src/mcp/tools/core-routes.mcp-tools.ts +196 -0
- package/src/mcp/tools/core-screens.mcp-tools.ts +186 -0
- package/src/mcp/tools/core-sessions.mcp-tools.ts +97 -0
- package/src/mcp/tools/core-settings.mcp-tools.ts +171 -53
- package/src/mcp/tools/core-system.mcp-tools.ts +19 -0
- package/src/mcp/tools/core-webhooks.mcp-tools.ts +199 -0
- package/src/mcp-chat/mcp-chat.controller.ts +113 -60
- package/src/mcp-chat/mcp-chat.service.ts +1343 -332
- package/src/notification/dto/create-notification.dto.ts +71 -0
- package/src/notification/dto/update-progress.dto.ts +16 -0
- package/src/notification/notification.controller.ts +83 -0
- package/src/notification/notification.module.ts +16 -0
- package/src/notification/notification.service.ts +324 -0
- package/src/pdf/pdf.service.ts +1 -1
- package/src/profile/profile.controller.ts +1 -1
- package/src/profile/profile.module.ts +1 -0
- package/src/setting/dto/update-setting-list.dto.ts +32 -0
- package/src/setting/setting.controller.ts +9 -0
- package/src/setting/setting.service.ts +99 -11
- package/src/task/task.service.ts +103 -0
- package/src/token/token.service.ts +0 -2
- package/src/webhook-integration/dto/webhook-action.dto.ts +96 -0
- package/src/webhook-integration/webhook-integration.controller.ts +124 -103
- package/src/webhook-integration/webhook-integration.service.ts +1137 -735
- package/src/webhook-integration/webhook-utils.ts +136 -79
|
@@ -15,6 +15,7 @@ const api_pagination_1 = require("@hed-hog/api-pagination");
|
|
|
15
15
|
const api_prisma_1 = require("@hed-hog/api-prisma");
|
|
16
16
|
const axios_1 = require("@nestjs/axios");
|
|
17
17
|
const common_1 = require("@nestjs/common");
|
|
18
|
+
const events_1 = require("events");
|
|
18
19
|
const rxjs_1 = require("rxjs");
|
|
19
20
|
const mail_service_1 = require("../mail/mail.service");
|
|
20
21
|
const setting_service_1 = require("../setting/setting.service");
|
|
@@ -27,6 +28,7 @@ let WebhookIntegrationService = class WebhookIntegrationService {
|
|
|
27
28
|
this.mailMainService = mailMainService;
|
|
28
29
|
this.coreMailService = coreMailService;
|
|
29
30
|
this.settingService = settingService;
|
|
31
|
+
this.logEmitter = new events_1.EventEmitter();
|
|
30
32
|
}
|
|
31
33
|
get integrations() {
|
|
32
34
|
return this.prisma.webhook_integration;
|
|
@@ -37,6 +39,9 @@ let WebhookIntegrationService = class WebhookIntegrationService {
|
|
|
37
39
|
get logs() {
|
|
38
40
|
return this.prisma.webhook_call_log;
|
|
39
41
|
}
|
|
42
|
+
get actionLogs() {
|
|
43
|
+
return this.prisma.webhook_action_log;
|
|
44
|
+
}
|
|
40
45
|
async list(paginationParams) {
|
|
41
46
|
const fields = ['slug', 'name', 'description', 'public_uuid', 'status'];
|
|
42
47
|
const OR = this.prisma.createInsensitiveSearch(fields, paginationParams);
|
|
@@ -126,8 +131,11 @@ let WebhookIntegrationService = class WebhookIntegrationService {
|
|
|
126
131
|
return Object.assign(Object.assign({}, (await this.withPublicUrl(record))), { plainToken });
|
|
127
132
|
}
|
|
128
133
|
async getApplicationBaseUrl() {
|
|
129
|
-
const settings = await this.settingService.getSettingValues(
|
|
130
|
-
|
|
134
|
+
const settings = await this.settingService.getSettingValues([
|
|
135
|
+
'api-url',
|
|
136
|
+
'url',
|
|
137
|
+
]);
|
|
138
|
+
const value = (settings === null || settings === void 0 ? void 0 : settings['api-url']) || (settings === null || settings === void 0 ? void 0 : settings.url);
|
|
131
139
|
return typeof value === 'string' ? value.replace(/\/+$/, '') : '';
|
|
132
140
|
}
|
|
133
141
|
async withPublicUrl(record) {
|
|
@@ -151,15 +159,19 @@ let WebhookIntegrationService = class WebhookIntegrationService {
|
|
|
151
159
|
}
|
|
152
160
|
async createAction(integrationId, data) {
|
|
153
161
|
await this.get(integrationId);
|
|
162
|
+
const normalized = this.normalizeAction(data);
|
|
163
|
+
this.validateActionConfiguration(normalized);
|
|
154
164
|
return this.actions.create({
|
|
155
|
-
data: Object.assign(Object.assign({},
|
|
165
|
+
data: Object.assign(Object.assign({}, normalized), { webhook_integration_id: integrationId }),
|
|
156
166
|
});
|
|
157
167
|
}
|
|
158
168
|
async updateAction(integrationId, actionId, data) {
|
|
159
|
-
await this.ensureAction(integrationId, actionId);
|
|
169
|
+
const existing = await this.ensureAction(integrationId, actionId);
|
|
170
|
+
const normalized = this.normalizeAction(data, true);
|
|
171
|
+
this.validateActionConfiguration(Object.assign(Object.assign({}, existing), normalized));
|
|
160
172
|
return this.actions.update({
|
|
161
173
|
where: { id: actionId },
|
|
162
|
-
data:
|
|
174
|
+
data: normalized,
|
|
163
175
|
});
|
|
164
176
|
}
|
|
165
177
|
async deleteActions(integrationId, data) {
|
|
@@ -175,16 +187,72 @@ let WebhookIntegrationService = class WebhookIntegrationService {
|
|
|
175
187
|
},
|
|
176
188
|
});
|
|
177
189
|
}
|
|
178
|
-
async listLogs(integrationId, paginationParams) {
|
|
190
|
+
async listLogs(integrationId, paginationParams, sort = 'desc') {
|
|
179
191
|
await this.get(integrationId);
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
192
|
+
const page = Math.max(Number(paginationParams.page || 1), 1);
|
|
193
|
+
const pageSize = Math.max(Number(paginationParams.pageSize || 10), 1);
|
|
194
|
+
const skip = (page - 1) * pageSize;
|
|
195
|
+
const normalizedSort = sort === 'asc' ? 'asc' : 'desc';
|
|
196
|
+
const where = { webhook_integration_id: integrationId };
|
|
197
|
+
const [data, total] = await Promise.all([
|
|
198
|
+
this.logs.findMany({
|
|
199
|
+
where,
|
|
200
|
+
orderBy: [{ created_at: normalizedSort }, { id: normalizedSort }],
|
|
201
|
+
skip,
|
|
202
|
+
take: pageSize,
|
|
203
|
+
}),
|
|
204
|
+
this.logs.count({ where }),
|
|
205
|
+
]);
|
|
206
|
+
const lastPage = Math.max(1, Math.ceil(total / pageSize));
|
|
207
|
+
const result = {
|
|
208
|
+
total,
|
|
209
|
+
lastPage,
|
|
210
|
+
page,
|
|
211
|
+
pageSize,
|
|
212
|
+
prev: page > 1 ? page - 1 : null,
|
|
213
|
+
next: page < lastPage ? page + 1 : null,
|
|
214
|
+
data,
|
|
215
|
+
};
|
|
216
|
+
const logIds = (result.data || [])
|
|
217
|
+
.map((item) => item.id)
|
|
218
|
+
.filter((id) => typeof id === 'number');
|
|
219
|
+
if (!logIds.length || !this.actionLogs) {
|
|
220
|
+
return result;
|
|
221
|
+
}
|
|
222
|
+
const actionLogs = await this.actionLogs.findMany({
|
|
223
|
+
where: {
|
|
224
|
+
webhook_call_log_id: { in: logIds },
|
|
225
|
+
},
|
|
226
|
+
orderBy: [{ created_at: 'asc' }, { id: 'asc' }],
|
|
227
|
+
});
|
|
228
|
+
const actionLogsByCallId = new Map();
|
|
229
|
+
for (const actionLog of actionLogs || []) {
|
|
230
|
+
const list = actionLogsByCallId.get(actionLog.webhook_call_log_id) || [];
|
|
231
|
+
list.push(actionLog);
|
|
232
|
+
actionLogsByCallId.set(actionLog.webhook_call_log_id, list);
|
|
233
|
+
}
|
|
234
|
+
return Object.assign(Object.assign({}, result), { data: (result.data || []).map((item) => (Object.assign(Object.assign({}, item), { webhook_action_log: actionLogsByCallId.get(item.id) || [] }))) });
|
|
235
|
+
}
|
|
236
|
+
streamLogs(integrationId, res) {
|
|
237
|
+
res.setHeader('Content-Type', 'text/event-stream; charset=utf-8');
|
|
238
|
+
res.setHeader('Cache-Control', 'no-cache, no-transform');
|
|
239
|
+
res.setHeader('Connection', 'keep-alive');
|
|
240
|
+
res.setHeader('X-Accel-Buffering', 'no');
|
|
241
|
+
res.flushHeaders();
|
|
242
|
+
res.write(`data: ${JSON.stringify({ type: 'connected' })}\n\n`);
|
|
243
|
+
const handler = (payload) => {
|
|
244
|
+
res.write(`data: ${JSON.stringify({ type: 'log', payload })}\n\n`);
|
|
245
|
+
};
|
|
246
|
+
const eventKey = `log:${integrationId}`;
|
|
247
|
+
this.logEmitter.on(eventKey, handler);
|
|
248
|
+
res.on('close', () => {
|
|
249
|
+
this.logEmitter.off(eventKey, handler);
|
|
183
250
|
});
|
|
184
251
|
}
|
|
185
252
|
async executePublic(uuid, body, headers, req) {
|
|
186
253
|
const startedAt = Date.now();
|
|
187
254
|
const remoteIp = this.getRemoteIp(req);
|
|
255
|
+
const actionLogs = [];
|
|
188
256
|
let integration = null;
|
|
189
257
|
try {
|
|
190
258
|
integration = await this.integrations.findUnique({
|
|
@@ -204,13 +272,56 @@ let WebhookIntegrationService = class WebhookIntegrationService {
|
|
|
204
272
|
this.validateBodySchema(integration, body);
|
|
205
273
|
const actionResults = [];
|
|
206
274
|
for (const action of integration.webhook_action || []) {
|
|
207
|
-
|
|
275
|
+
const actionStartedAt = Date.now();
|
|
276
|
+
try {
|
|
277
|
+
const result = await this.executeAction(action, body);
|
|
278
|
+
const durationMs = Date.now() - actionStartedAt;
|
|
279
|
+
actionResults.push({
|
|
280
|
+
id: action.id,
|
|
281
|
+
type: action.type,
|
|
282
|
+
success: true,
|
|
283
|
+
duration_ms: durationMs,
|
|
284
|
+
response: (0, webhook_utils_1.summarizePayload)(result.responsePayload),
|
|
285
|
+
});
|
|
286
|
+
actionLogs.push({
|
|
287
|
+
webhookActionId: action.id,
|
|
288
|
+
actionName: action.name,
|
|
289
|
+
actionType: action.type,
|
|
290
|
+
status: 'success',
|
|
291
|
+
durationMs,
|
|
292
|
+
requestPayload: result.requestPayload,
|
|
293
|
+
responsePayload: result.responsePayload,
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
catch (error) {
|
|
297
|
+
const durationMs = Date.now() - actionStartedAt;
|
|
298
|
+
const errorMessage = this.extractErrorMessage(error);
|
|
299
|
+
actionResults.push({
|
|
300
|
+
id: action.id,
|
|
301
|
+
type: action.type,
|
|
302
|
+
success: false,
|
|
303
|
+
duration_ms: durationMs,
|
|
304
|
+
error: errorMessage,
|
|
305
|
+
response: (0, webhook_utils_1.summarizePayload)(this.extractErrorResponse(error)),
|
|
306
|
+
});
|
|
307
|
+
actionLogs.push({
|
|
308
|
+
webhookActionId: action.id,
|
|
309
|
+
actionName: action.name,
|
|
310
|
+
actionType: action.type,
|
|
311
|
+
status: 'failed',
|
|
312
|
+
durationMs,
|
|
313
|
+
requestPayload: this.extractErrorRequestPayload(error),
|
|
314
|
+
errorMessage,
|
|
315
|
+
responsePayload: this.extractErrorResponse(error),
|
|
316
|
+
});
|
|
317
|
+
throw error;
|
|
318
|
+
}
|
|
208
319
|
}
|
|
209
320
|
const response = {
|
|
210
321
|
success: true,
|
|
211
322
|
actions: actionResults,
|
|
212
323
|
};
|
|
213
|
-
await this.createCallLog({
|
|
324
|
+
const callLog = await this.createCallLog({
|
|
214
325
|
integration,
|
|
215
326
|
uuid,
|
|
216
327
|
status: 'success',
|
|
@@ -219,37 +330,63 @@ let WebhookIntegrationService = class WebhookIntegrationService {
|
|
|
219
330
|
payload: body,
|
|
220
331
|
response,
|
|
221
332
|
});
|
|
333
|
+
await this.createActionLogs(callLog === null || callLog === void 0 ? void 0 : callLog.id, actionLogs);
|
|
334
|
+
if ((integration === null || integration === void 0 ? void 0 : integration.id) && (callLog === null || callLog === void 0 ? void 0 : callLog.id)) {
|
|
335
|
+
this.logEmitter.emit(`log:${integration.id}`, { id: callLog.id });
|
|
336
|
+
}
|
|
222
337
|
return response;
|
|
223
338
|
}
|
|
224
339
|
catch (error) {
|
|
225
|
-
await this.createCallLog({
|
|
340
|
+
const callLog = await this.createCallLog({
|
|
226
341
|
integration,
|
|
227
342
|
uuid,
|
|
228
343
|
status: 'failed',
|
|
229
344
|
remoteIp,
|
|
230
345
|
durationMs: Date.now() - startedAt,
|
|
231
346
|
payload: body,
|
|
347
|
+
response: {
|
|
348
|
+
success: false,
|
|
349
|
+
actions: actionLogs.map((item) => ({
|
|
350
|
+
id: item.webhookActionId,
|
|
351
|
+
type: item.actionType,
|
|
352
|
+
success: item.status === 'success',
|
|
353
|
+
duration_ms: item.durationMs,
|
|
354
|
+
error: item.errorMessage || null,
|
|
355
|
+
})),
|
|
356
|
+
},
|
|
232
357
|
error,
|
|
233
|
-
});
|
|
234
|
-
|
|
358
|
+
}).catch(() => null);
|
|
359
|
+
await this.createActionLogs(callLog === null || callLog === void 0 ? void 0 : callLog.id, actionLogs).catch(() => undefined);
|
|
360
|
+
if ((integration === null || integration === void 0 ? void 0 : integration.id) && (callLog === null || callLog === void 0 ? void 0 : callLog.id)) {
|
|
361
|
+
this.logEmitter.emit(`log:${integration.id}`, { id: callLog.id });
|
|
362
|
+
}
|
|
363
|
+
if (error instanceof common_1.HttpException) {
|
|
364
|
+
throw error;
|
|
365
|
+
}
|
|
366
|
+
return {
|
|
367
|
+
success: false,
|
|
368
|
+
actions: actionLogs.map((item) => ({
|
|
369
|
+
id: item.webhookActionId,
|
|
370
|
+
type: item.actionType,
|
|
371
|
+
success: item.status === 'success',
|
|
372
|
+
duration_ms: item.durationMs,
|
|
373
|
+
error: item.errorMessage || null,
|
|
374
|
+
})),
|
|
375
|
+
};
|
|
235
376
|
}
|
|
236
377
|
}
|
|
237
378
|
async executeAction(action, body) {
|
|
238
379
|
if (action.type === 'email') {
|
|
239
|
-
|
|
240
|
-
return { id: action.id, type: action.type, success: true };
|
|
380
|
+
return this.executeEmailAction(action, body);
|
|
241
381
|
}
|
|
242
382
|
if (action.type === 'whatsapp_evolution') {
|
|
243
|
-
|
|
244
|
-
return { id: action.id, type: action.type, success: true };
|
|
383
|
+
return this.executeWhatsappAction(action, body);
|
|
245
384
|
}
|
|
246
385
|
throw new common_1.BadRequestException(`Unsupported action type: ${action.type}`);
|
|
247
386
|
}
|
|
248
387
|
async executeEmailAction(action, body) {
|
|
249
|
-
var _a;
|
|
250
|
-
|
|
251
|
-
throw new common_1.BadRequestException('Email action is missing required configuration.');
|
|
252
|
-
}
|
|
388
|
+
var _a, _b, _c, _d;
|
|
389
|
+
this.validateActionConfiguration(action);
|
|
253
390
|
const profile = await this.prisma.mail_profile.findUnique({
|
|
254
391
|
where: { id: Number(action.mail_profile_id) },
|
|
255
392
|
});
|
|
@@ -274,28 +411,43 @@ let WebhookIntegrationService = class WebhookIntegrationService {
|
|
|
274
411
|
? `${profile.reply_to_name} <${profile.reply_to_email}>`
|
|
275
412
|
: profile.reply_to_email
|
|
276
413
|
: undefined;
|
|
414
|
+
const renderedTo = String((_b = (0, webhook_utils_1.renderTemplate)(action.email_to, body)) !== null && _b !== void 0 ? _b : '').trim();
|
|
415
|
+
const renderedCc = action.email_cc
|
|
416
|
+
? String((_c = (0, webhook_utils_1.renderTemplate)(action.email_cc, body)) !== null && _c !== void 0 ? _c : '').trim()
|
|
417
|
+
: '';
|
|
418
|
+
const renderedBcc = action.email_bcc
|
|
419
|
+
? String((_d = (0, webhook_utils_1.renderTemplate)(action.email_bcc, body)) !== null && _d !== void 0 ? _d : '').trim()
|
|
420
|
+
: '';
|
|
421
|
+
if (!renderedTo) {
|
|
422
|
+
throw new common_1.BadRequestException('Email action rendered an empty recipient for email_to.');
|
|
423
|
+
}
|
|
424
|
+
const requestPayload = {
|
|
425
|
+
to: renderedTo,
|
|
426
|
+
cc: renderedCc || undefined,
|
|
427
|
+
bcc: renderedBcc || undefined,
|
|
428
|
+
from: sender,
|
|
429
|
+
replyTo,
|
|
430
|
+
subject: (0, webhook_utils_1.renderTemplate)(template.subject, body),
|
|
431
|
+
body: (0, webhook_utils_1.renderTemplate)(template.body, body),
|
|
432
|
+
mail_id: mail.id,
|
|
433
|
+
};
|
|
277
434
|
try {
|
|
278
435
|
this.mailMainService.setConfig(config);
|
|
279
|
-
await this.mailMainService.send(
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
:
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
from: sender,
|
|
288
|
-
replyTo,
|
|
289
|
-
subject: (0, webhook_utils_1.renderTemplate)(template.subject, body),
|
|
290
|
-
body: (0, webhook_utils_1.renderTemplate)(template.body, body),
|
|
291
|
-
mail_id: mail.id,
|
|
292
|
-
});
|
|
436
|
+
const providerResponse = await this.mailMainService.send(requestPayload);
|
|
437
|
+
return {
|
|
438
|
+
requestPayload,
|
|
439
|
+
responsePayload: {
|
|
440
|
+
provider: 'email',
|
|
441
|
+
response: providerResponse || null,
|
|
442
|
+
},
|
|
443
|
+
};
|
|
293
444
|
}
|
|
294
445
|
finally {
|
|
295
446
|
await this.coreMailService.reloadConfig().catch(() => undefined);
|
|
296
447
|
}
|
|
297
448
|
}
|
|
298
449
|
async executeWhatsappAction(action, body) {
|
|
450
|
+
var _a, _b;
|
|
299
451
|
const required = [
|
|
300
452
|
action.whatsapp_target,
|
|
301
453
|
action.whatsapp_template,
|
|
@@ -309,18 +461,45 @@ let WebhookIntegrationService = class WebhookIntegrationService {
|
|
|
309
461
|
const baseUrl = String(action.whatsapp_base_url).replace(/\/+$/, '');
|
|
310
462
|
const instance = encodeURIComponent(action.whatsapp_instance);
|
|
311
463
|
const url = `${baseUrl}/message/sendText/${instance}`;
|
|
312
|
-
const
|
|
313
|
-
const
|
|
314
|
-
|
|
464
|
+
const targetType = action.whatsapp_target_type === 'group' ? 'group' : 'phone';
|
|
465
|
+
const renderedMessage = String((_a = (0, webhook_utils_1.renderTemplate)(action.whatsapp_template, body)) !== null && _a !== void 0 ? _a : '').trim();
|
|
466
|
+
const renderedTarget = String((_b = (0, webhook_utils_1.renderTemplate)(action.whatsapp_target, body)) !== null && _b !== void 0 ? _b : '').trim();
|
|
467
|
+
if (!renderedMessage) {
|
|
468
|
+
throw new common_1.BadRequestException('WhatsApp action template rendered an empty message.');
|
|
469
|
+
}
|
|
470
|
+
const target = this.normalizeWhatsappTarget(renderedTarget, targetType);
|
|
471
|
+
const requestPayload = {
|
|
472
|
+
provider: 'evolution',
|
|
473
|
+
url,
|
|
474
|
+
instance: action.whatsapp_instance,
|
|
475
|
+
targetType,
|
|
315
476
|
number: target,
|
|
316
|
-
text:
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
477
|
+
text: renderedMessage,
|
|
478
|
+
};
|
|
479
|
+
let response;
|
|
480
|
+
try {
|
|
481
|
+
response = await (0, rxjs_1.firstValueFrom)(this.http.post(url, {
|
|
482
|
+
number: target,
|
|
483
|
+
text: renderedMessage,
|
|
484
|
+
}, {
|
|
485
|
+
headers: {
|
|
486
|
+
apikey: action.whatsapp_token,
|
|
487
|
+
},
|
|
488
|
+
timeout: 15000,
|
|
489
|
+
}));
|
|
490
|
+
}
|
|
491
|
+
catch (error) {
|
|
492
|
+
this.attachErrorRequestPayload(error, requestPayload);
|
|
493
|
+
throw error;
|
|
494
|
+
}
|
|
495
|
+
return {
|
|
496
|
+
requestPayload,
|
|
497
|
+
responsePayload: {
|
|
498
|
+
status: (response === null || response === void 0 ? void 0 : response.status) || null,
|
|
499
|
+
statusText: (response === null || response === void 0 ? void 0 : response.statusText) || null,
|
|
500
|
+
data: (response === null || response === void 0 ? void 0 : response.data) || null,
|
|
321
501
|
},
|
|
322
|
-
|
|
323
|
-
}));
|
|
502
|
+
};
|
|
324
503
|
}
|
|
325
504
|
validateToken(integration, headers) {
|
|
326
505
|
var _a;
|
|
@@ -345,6 +524,37 @@ let WebhookIntegrationService = class WebhookIntegrationService {
|
|
|
345
524
|
throw new common_1.BadRequestException('Remote IP is not allowed.');
|
|
346
525
|
}
|
|
347
526
|
}
|
|
527
|
+
validateActionConfiguration(action) {
|
|
528
|
+
if ((action === null || action === void 0 ? void 0 : action.type) === 'email') {
|
|
529
|
+
const missing = [];
|
|
530
|
+
if (!this.nullableNumber(action.mail_profile_id)) {
|
|
531
|
+
missing.push('mail_profile_id');
|
|
532
|
+
}
|
|
533
|
+
if (!this.nullableNumber(action.mail_id)) {
|
|
534
|
+
missing.push('mail_id');
|
|
535
|
+
}
|
|
536
|
+
if (!this.nullableString(action.email_to, true)) {
|
|
537
|
+
missing.push('email_to');
|
|
538
|
+
}
|
|
539
|
+
if (missing.length) {
|
|
540
|
+
throw new common_1.BadRequestException(`Email action is missing required configuration: ${missing.join(', ')}.`);
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
if ((action === null || action === void 0 ? void 0 : action.type) === 'whatsapp_evolution') {
|
|
544
|
+
const missing = [
|
|
545
|
+
['whatsapp_target', action.whatsapp_target],
|
|
546
|
+
['whatsapp_template', action.whatsapp_template],
|
|
547
|
+
['whatsapp_instance', action.whatsapp_instance],
|
|
548
|
+
['whatsapp_base_url', action.whatsapp_base_url],
|
|
549
|
+
['whatsapp_token', action.whatsapp_token],
|
|
550
|
+
]
|
|
551
|
+
.filter(([, value]) => !String(value || '').trim())
|
|
552
|
+
.map(([key]) => key);
|
|
553
|
+
if (missing.length) {
|
|
554
|
+
throw new common_1.BadRequestException(`WhatsApp action is missing required configuration: ${missing.join(', ')}.`);
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
}
|
|
348
558
|
validateBodySchema(integration, body) {
|
|
349
559
|
if (!integration.body_schema) {
|
|
350
560
|
return;
|
|
@@ -416,25 +626,95 @@ let WebhookIntegrationService = class WebhookIntegrationService {
|
|
|
416
626
|
async createCallLog(input) {
|
|
417
627
|
var _a, _b;
|
|
418
628
|
if (!this.logs) {
|
|
419
|
-
return;
|
|
629
|
+
return null;
|
|
420
630
|
}
|
|
421
|
-
|
|
631
|
+
return this.logs.create({
|
|
422
632
|
data: {
|
|
423
633
|
webhook_integration_id: (_b = (_a = input.integration) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : null,
|
|
424
634
|
public_uuid: input.uuid,
|
|
425
635
|
status: input.status,
|
|
426
636
|
remote_ip: input.remoteIp,
|
|
427
637
|
duration_ms: input.durationMs,
|
|
428
|
-
error_message: input.error
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
response_summary: (0, webhook_utils_1.summarizePayload)(input.response),
|
|
638
|
+
error_message: input.error ? this.extractErrorMessage(input.error) : null,
|
|
639
|
+
payload_summary: (0, webhook_utils_1.summarizePayload)((0, webhook_utils_1.sanitizeSensitiveData)(input.payload)),
|
|
640
|
+
response_summary: (0, webhook_utils_1.summarizePayload)((0, webhook_utils_1.sanitizeSensitiveData)(input.response)),
|
|
641
|
+
},
|
|
642
|
+
select: {
|
|
643
|
+
id: true,
|
|
435
644
|
},
|
|
436
645
|
});
|
|
437
646
|
}
|
|
647
|
+
async createActionLogs(callLogId, logs) {
|
|
648
|
+
if (!callLogId || !logs.length || !this.actionLogs) {
|
|
649
|
+
return;
|
|
650
|
+
}
|
|
651
|
+
await this.actionLogs.createMany({
|
|
652
|
+
data: logs.map((item) => ({
|
|
653
|
+
webhook_call_log_id: callLogId,
|
|
654
|
+
webhook_action_id: item.webhookActionId,
|
|
655
|
+
action_name: item.actionName,
|
|
656
|
+
action_type: item.actionType,
|
|
657
|
+
status: item.status,
|
|
658
|
+
duration_ms: item.durationMs,
|
|
659
|
+
request_payload: (0, webhook_utils_1.summarizePayload)((0, webhook_utils_1.sanitizeSensitiveData)(item.requestPayload)),
|
|
660
|
+
response_payload: (0, webhook_utils_1.summarizePayload)((0, webhook_utils_1.sanitizeSensitiveData)(item.responsePayload)),
|
|
661
|
+
error_message: item.errorMessage || null,
|
|
662
|
+
})),
|
|
663
|
+
});
|
|
664
|
+
}
|
|
665
|
+
extractErrorMessage(error) {
|
|
666
|
+
if (!error) {
|
|
667
|
+
return 'Unknown error';
|
|
668
|
+
}
|
|
669
|
+
if (error instanceof Error && error.message) {
|
|
670
|
+
return error.message;
|
|
671
|
+
}
|
|
672
|
+
if (typeof error === 'object' && error.message) {
|
|
673
|
+
return String(error.message);
|
|
674
|
+
}
|
|
675
|
+
return String(error);
|
|
676
|
+
}
|
|
677
|
+
extractErrorResponse(error) {
|
|
678
|
+
if (!error || typeof error !== 'object') {
|
|
679
|
+
return null;
|
|
680
|
+
}
|
|
681
|
+
const maybeResponse = error.response;
|
|
682
|
+
if (!maybeResponse) {
|
|
683
|
+
return null;
|
|
684
|
+
}
|
|
685
|
+
return {
|
|
686
|
+
status: maybeResponse.status || null,
|
|
687
|
+
statusText: maybeResponse.statusText || null,
|
|
688
|
+
data: maybeResponse.data || null,
|
|
689
|
+
};
|
|
690
|
+
}
|
|
691
|
+
extractErrorRequestPayload(error) {
|
|
692
|
+
if (!error || typeof error !== 'object') {
|
|
693
|
+
return null;
|
|
694
|
+
}
|
|
695
|
+
const maybePayload = error.__webhookRequestPayload;
|
|
696
|
+
return maybePayload || null;
|
|
697
|
+
}
|
|
698
|
+
attachErrorRequestPayload(error, requestPayload) {
|
|
699
|
+
if (!error || typeof error !== 'object') {
|
|
700
|
+
return;
|
|
701
|
+
}
|
|
702
|
+
error.__webhookRequestPayload = requestPayload;
|
|
703
|
+
}
|
|
704
|
+
normalizeWhatsappTarget(renderedTarget, targetType) {
|
|
705
|
+
const rawTarget = String(renderedTarget || '').trim();
|
|
706
|
+
if (!rawTarget) {
|
|
707
|
+
throw new common_1.BadRequestException('WhatsApp action target template rendered an empty value.');
|
|
708
|
+
}
|
|
709
|
+
if (targetType === 'group') {
|
|
710
|
+
return rawTarget;
|
|
711
|
+
}
|
|
712
|
+
const normalized = rawTarget.replace(/\D+/g, '');
|
|
713
|
+
if (!normalized) {
|
|
714
|
+
throw new common_1.BadRequestException('WhatsApp action target must contain at least one digit for phone targets.');
|
|
715
|
+
}
|
|
716
|
+
return normalized;
|
|
717
|
+
}
|
|
438
718
|
getRemoteIp(req) {
|
|
439
719
|
const forwardedFor = req.headers['x-forwarded-for'];
|
|
440
720
|
const forwardedIp = Array.isArray(forwardedFor)
|
|
@@ -492,8 +772,8 @@ let WebhookIntegrationService = class WebhookIntegrationService {
|
|
|
492
772
|
assign('name', String((_a = data.name) !== null && _a !== void 0 ? _a : '').trim());
|
|
493
773
|
assign('order', Number((_b = data.order) !== null && _b !== void 0 ? _b : 0));
|
|
494
774
|
assign('status', data.status === 'inactive' ? 'inactive' : 'active');
|
|
495
|
-
assign('mail_profile_id', this.nullableNumber(data.mail_profile_id));
|
|
496
|
-
assign('mail_id', this.nullableNumber(data.mail_id));
|
|
775
|
+
assign('mail_profile_id', this.nullableNumber(data.mail_profile_id, partial));
|
|
776
|
+
assign('mail_id', this.nullableNumber(data.mail_id, partial));
|
|
497
777
|
assign('email_to', this.nullableString(data.email_to, partial));
|
|
498
778
|
assign('email_cc', this.nullableString(data.email_cc, partial));
|
|
499
779
|
assign('email_bcc', this.nullableString(data.email_bcc, partial));
|
|
@@ -515,8 +795,11 @@ let WebhookIntegrationService = class WebhookIntegrationService {
|
|
|
515
795
|
const normalized = String(value).trim();
|
|
516
796
|
return normalized || null;
|
|
517
797
|
}
|
|
518
|
-
nullableNumber(value) {
|
|
519
|
-
if (value === undefined
|
|
798
|
+
nullableNumber(value, partial = false) {
|
|
799
|
+
if (value === undefined) {
|
|
800
|
+
return partial ? undefined : null;
|
|
801
|
+
}
|
|
802
|
+
if (value === null || value === '') {
|
|
520
803
|
return null;
|
|
521
804
|
}
|
|
522
805
|
return Number(value);
|