@hed-hog/core 0.0.356 → 0.0.359

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (250) hide show
  1. package/dist/auth/guards/auth.guard.d.ts +6 -1
  2. package/dist/auth/guards/auth.guard.d.ts.map +1 -1
  3. package/dist/auth/guards/auth.guard.js +33 -2
  4. package/dist/auth/guards/auth.guard.js.map +1 -1
  5. package/dist/file/file.controller.d.ts +4 -2
  6. package/dist/file/file.controller.d.ts.map +1 -1
  7. package/dist/file/file.controller.js +44 -38
  8. package/dist/file/file.controller.js.map +1 -1
  9. package/dist/file/file.service.d.ts +2 -2
  10. package/dist/file/file.service.d.ts.map +1 -1
  11. package/dist/file/file.service.js +25 -42
  12. package/dist/file/file.service.js.map +1 -1
  13. package/dist/file/provider/azure.provider.d.ts.map +1 -1
  14. package/dist/file/provider/azure.provider.js +10 -15
  15. package/dist/file/provider/azure.provider.js.map +1 -1
  16. package/dist/file/provider/gcs.provider.d.ts.map +1 -1
  17. package/dist/file/provider/gcs.provider.js +8 -9
  18. package/dist/file/provider/gcs.provider.js.map +1 -1
  19. package/dist/file/provider/local.provider.d.ts.map +1 -1
  20. package/dist/file/provider/local.provider.js +11 -10
  21. package/dist/file/provider/local.provider.js.map +1 -1
  22. package/dist/file/provider/provider.factory.d.ts +1 -1
  23. package/dist/file/provider/provider.factory.d.ts.map +1 -1
  24. package/dist/file/provider/provider.factory.js +16 -6
  25. package/dist/file/provider/provider.factory.js.map +1 -1
  26. package/dist/file/provider/s3.provider.d.ts.map +1 -1
  27. package/dist/file/provider/s3.provider.js +4 -20
  28. package/dist/file/provider/s3.provider.js.map +1 -1
  29. package/dist/file/provider/spaces.provider.d.ts.map +1 -1
  30. package/dist/file/provider/spaces.provider.js +4 -19
  31. package/dist/file/provider/spaces.provider.js.map +1 -1
  32. package/dist/integration-profile/integration-profile.controller.d.ts +1 -1
  33. package/dist/integration-profile/integration-profile.controller.d.ts.map +1 -1
  34. package/dist/integration-profile/integration-profile.controller.js +4 -3
  35. package/dist/integration-profile/integration-profile.controller.js.map +1 -1
  36. package/dist/integration-profile/integration-profile.service.d.ts +1 -1
  37. package/dist/integration-profile/integration-profile.service.d.ts.map +1 -1
  38. package/dist/integration-profile/integration-profile.service.js +7 -4
  39. package/dist/integration-profile/integration-profile.service.js.map +1 -1
  40. package/dist/integration-profile/integration-profile.utils.d.ts +6 -0
  41. package/dist/integration-profile/integration-profile.utils.d.ts.map +1 -1
  42. package/dist/integration-profile/integration-profile.utils.js +9 -0
  43. package/dist/integration-profile/integration-profile.utils.js.map +1 -1
  44. package/dist/mail/mail.module.d.ts.map +1 -1
  45. package/dist/mail/mail.module.js +9 -4
  46. package/dist/mail/mail.module.js.map +1 -1
  47. package/dist/mail/mail.service.d.ts +2 -1
  48. package/dist/mail/mail.service.d.ts.map +1 -1
  49. package/dist/mail/mail.service.js +11 -7
  50. package/dist/mail/mail.service.js.map +1 -1
  51. package/dist/mcp/guards/mcp-auth.guard.js +1 -1
  52. package/dist/mcp/guards/mcp-auth.guard.js.map +1 -1
  53. package/dist/mcp/mcp-api-key.controller.d.ts +2 -0
  54. package/dist/mcp/mcp-api-key.controller.d.ts.map +1 -1
  55. package/dist/mcp/mcp-api-key.controller.js +1 -1
  56. package/dist/mcp/mcp-api-key.controller.js.map +1 -1
  57. package/dist/mcp/mcp-api-key.service.d.ts +2 -1
  58. package/dist/mcp/mcp-api-key.service.d.ts.map +1 -1
  59. package/dist/mcp/mcp-api-key.service.js +6 -2
  60. package/dist/mcp/mcp-api-key.service.js.map +1 -1
  61. package/dist/mcp/mcp.module.d.ts.map +1 -1
  62. package/dist/mcp/mcp.module.js +1 -3
  63. package/dist/mcp/mcp.module.js.map +1 -1
  64. package/dist/oauth/interfaces/OAuthProvider.d.ts +1 -1
  65. package/dist/oauth/interfaces/OAuthProvider.d.ts.map +1 -1
  66. package/dist/oauth/oauth.controller.d.ts +4 -1
  67. package/dist/oauth/oauth.controller.d.ts.map +1 -1
  68. package/dist/oauth/oauth.controller.js +31 -5
  69. package/dist/oauth/oauth.controller.js.map +1 -1
  70. package/dist/oauth/oauth.service.d.ts +12 -1
  71. package/dist/oauth/oauth.service.d.ts.map +1 -1
  72. package/dist/oauth/oauth.service.js +125 -23
  73. package/dist/oauth/oauth.service.js.map +1 -1
  74. package/dist/oauth/providers/abstract.provider.d.ts +1 -1
  75. package/dist/oauth/providers/abstract.provider.d.ts.map +1 -1
  76. package/dist/oauth/providers/facebook.provider.d.ts +5 -2
  77. package/dist/oauth/providers/facebook.provider.d.ts.map +1 -1
  78. package/dist/oauth/providers/facebook.provider.js +34 -19
  79. package/dist/oauth/providers/facebook.provider.js.map +1 -1
  80. package/dist/oauth/providers/github.provider.d.ts +6 -2
  81. package/dist/oauth/providers/github.provider.d.ts.map +1 -1
  82. package/dist/oauth/providers/github.provider.js +43 -20
  83. package/dist/oauth/providers/github.provider.js.map +1 -1
  84. package/dist/oauth/providers/google.provider.d.ts +5 -2
  85. package/dist/oauth/providers/google.provider.d.ts.map +1 -1
  86. package/dist/oauth/providers/google.provider.js +34 -19
  87. package/dist/oauth/providers/google.provider.js.map +1 -1
  88. package/dist/oauth/providers/microsoft-entra-id.provider.d.ts +5 -2
  89. package/dist/oauth/providers/microsoft-entra-id.provider.d.ts.map +1 -1
  90. package/dist/oauth/providers/microsoft-entra-id.provider.js +43 -40
  91. package/dist/oauth/providers/microsoft-entra-id.provider.js.map +1 -1
  92. package/dist/oauth/providers/microsoft.provider.d.ts +5 -2
  93. package/dist/oauth/providers/microsoft.provider.d.ts.map +1 -1
  94. package/dist/oauth/providers/microsoft.provider.js +34 -19
  95. package/dist/oauth/providers/microsoft.provider.js.map +1 -1
  96. package/dist/profile/profile.controller.js +1 -1
  97. package/dist/profile/profile.controller.js.map +1 -1
  98. package/dist/security/security.service.d.ts +2 -0
  99. package/dist/security/security.service.d.ts.map +1 -1
  100. package/dist/security/security.service.js +21 -0
  101. package/dist/security/security.service.js.map +1 -1
  102. package/dist/setting/setting.service.d.ts +26 -1
  103. package/dist/setting/setting.service.d.ts.map +1 -1
  104. package/dist/setting/setting.service.js +240 -5
  105. package/dist/setting/setting.service.js.map +1 -1
  106. package/dist/user/user.controller.d.ts +2 -1
  107. package/dist/user/user.controller.d.ts.map +1 -1
  108. package/dist/user/user.controller.js +5 -4
  109. package/dist/user/user.controller.js.map +1 -1
  110. package/dist/user/user.service.d.ts +4 -2
  111. package/dist/user/user.service.d.ts.map +1 -1
  112. package/dist/user/user.service.js +19 -4
  113. package/dist/user/user.service.js.map +1 -1
  114. package/dist/webhook-integration/dto/webhook-action.dto.d.ts +17 -2
  115. package/dist/webhook-integration/dto/webhook-action.dto.d.ts.map +1 -1
  116. package/dist/webhook-integration/dto/webhook-action.dto.js +93 -2
  117. package/dist/webhook-integration/dto/webhook-action.dto.js.map +1 -1
  118. package/dist/webhook-integration/webhook-command.registry.d.ts +15 -0
  119. package/dist/webhook-integration/webhook-command.registry.d.ts.map +1 -0
  120. package/dist/webhook-integration/webhook-command.registry.js +36 -0
  121. package/dist/webhook-integration/webhook-command.registry.js.map +1 -0
  122. package/dist/webhook-integration/webhook-integration.controller.d.ts +19 -0
  123. package/dist/webhook-integration/webhook-integration.controller.d.ts.map +1 -1
  124. package/dist/webhook-integration/webhook-integration.controller.js +38 -0
  125. package/dist/webhook-integration/webhook-integration.controller.js.map +1 -1
  126. package/dist/webhook-integration/webhook-integration.module.d.ts.map +1 -1
  127. package/dist/webhook-integration/webhook-integration.module.js +5 -0
  128. package/dist/webhook-integration/webhook-integration.module.js.map +1 -1
  129. package/dist/webhook-integration/webhook-integration.service.d.ts +25 -1
  130. package/dist/webhook-integration/webhook-integration.service.d.ts.map +1 -1
  131. package/dist/webhook-integration/webhook-integration.service.js +332 -23
  132. package/dist/webhook-integration/webhook-integration.service.js.map +1 -1
  133. package/hedhog/data/integration_provider.yaml +16 -0
  134. package/hedhog/data/menu.yaml +0 -16
  135. package/hedhog/data/route.yaml +32 -383
  136. package/hedhog/data/setting_group.yaml +179 -174
  137. package/hedhog/data/setting_subgroup.yaml +16 -0
  138. package/hedhog/frontend/app/account/components/tokens.tsx.ejs +421 -0
  139. package/hedhog/frontend/app/account/layout.tsx.ejs +6 -3
  140. package/hedhog/frontend/app/account/mcp-tokens/page.tsx.ejs +2 -2
  141. package/hedhog/frontend/app/account/tokens/page.tsx.ejs +5 -0
  142. package/hedhog/frontend/app/configurations/[slug]/components/setting-field.tsx.ejs +414 -76
  143. package/hedhog/frontend/app/configurations/layout.tsx.ejs +1 -1
  144. package/hedhog/frontend/app/dashboard/dashboard-home-tabs.tsx.ejs +3 -1
  145. package/hedhog/frontend/app/integration/profiles/page.tsx.ejs +186 -18
  146. package/hedhog/frontend/app/integrations-webhooks/page.tsx.ejs +597 -21
  147. package/hedhog/frontend/app/mail/profiles/page.tsx.ejs +2 -2
  148. package/hedhog/frontend/app/setting-list/page.tsx.ejs +229 -395
  149. package/hedhog/frontend/messages/en.json +67 -3
  150. package/hedhog/frontend/messages/pt.json +67 -3
  151. package/hedhog/table/file.yaml +1 -1
  152. package/hedhog/table/mcp_api_key.yaml +4 -0
  153. package/hedhog/table/webhook_action.yaml +57 -1
  154. package/package.json +5 -4
  155. package/src/auth/guards/auth.guard.ts +32 -0
  156. package/src/file/file.controller.ts +51 -42
  157. package/src/file/file.service.ts +31 -52
  158. package/src/file/provider/azure.provider.ts +14 -28
  159. package/src/file/provider/gcs.provider.ts +9 -9
  160. package/src/file/provider/local.provider.ts +10 -13
  161. package/src/file/provider/provider.factory.ts +19 -7
  162. package/src/file/provider/s3.provider.ts +4 -20
  163. package/src/file/provider/spaces.provider.ts +4 -19
  164. package/src/integration-profile/integration-profile.controller.ts +2 -0
  165. package/src/integration-profile/integration-profile.service.ts +7 -2
  166. package/src/integration-profile/integration-profile.utils.ts +17 -0
  167. package/src/mail/mail.module.ts +14 -4
  168. package/src/mail/mail.service.ts +12 -7
  169. package/src/mcp/guards/mcp-auth.guard.ts +1 -1
  170. package/src/mcp/mcp-api-key.controller.ts +2 -2
  171. package/src/mcp/mcp-api-key.service.ts +6 -2
  172. package/src/mcp/mcp.module.ts +1 -3
  173. package/src/oauth/interfaces/OAuthProvider.ts +1 -1
  174. package/src/oauth/oauth.controller.ts +30 -2
  175. package/src/oauth/oauth.service.ts +194 -35
  176. package/src/oauth/providers/abstract.provider.ts +1 -1
  177. package/src/oauth/providers/facebook.provider.ts +36 -20
  178. package/src/oauth/providers/github.provider.ts +46 -23
  179. package/src/oauth/providers/google.provider.ts +36 -20
  180. package/src/oauth/providers/microsoft-entra-id.provider.ts +42 -46
  181. package/src/oauth/providers/microsoft.provider.ts +36 -21
  182. package/src/profile/profile.controller.ts +2 -2
  183. package/src/security/security.service.ts +34 -1
  184. package/src/setting/setting.service.ts +307 -7
  185. package/src/user/user.controller.ts +4 -1
  186. package/src/user/user.service.ts +20 -2
  187. package/src/webhook-integration/dto/webhook-action.dto.ts +85 -4
  188. package/src/webhook-integration/webhook-command.registry.ts +42 -0
  189. package/src/webhook-integration/webhook-integration.controller.ts +20 -0
  190. package/src/webhook-integration/webhook-integration.module.ts +50 -45
  191. package/src/webhook-integration/webhook-integration.service.ts +374 -11
  192. package/dist/mail-profile/dto/create.dto.d.ts +0 -23
  193. package/dist/mail-profile/dto/create.dto.d.ts.map +0 -1
  194. package/dist/mail-profile/dto/create.dto.js +0 -139
  195. package/dist/mail-profile/dto/create.dto.js.map +0 -1
  196. package/dist/mail-profile/dto/update.dto.d.ts +0 -6
  197. package/dist/mail-profile/dto/update.dto.d.ts.map +0 -1
  198. package/dist/mail-profile/dto/update.dto.js +0 -9
  199. package/dist/mail-profile/dto/update.dto.js.map +0 -1
  200. package/dist/mail-profile/mail-profile.controller.d.ts +0 -94
  201. package/dist/mail-profile/mail-profile.controller.d.ts.map +0 -1
  202. package/dist/mail-profile/mail-profile.controller.js +0 -95
  203. package/dist/mail-profile/mail-profile.controller.js.map +0 -1
  204. package/dist/mail-profile/mail-profile.module.d.ts +0 -3
  205. package/dist/mail-profile/mail-profile.module.d.ts.map +0 -1
  206. package/dist/mail-profile/mail-profile.module.js +0 -31
  207. package/dist/mail-profile/mail-profile.module.js.map +0 -1
  208. package/dist/mail-profile/mail-profile.service.d.ts +0 -109
  209. package/dist/mail-profile/mail-profile.service.d.ts.map +0 -1
  210. package/dist/mail-profile/mail-profile.service.js +0 -278
  211. package/dist/mail-profile/mail-profile.service.js.map +0 -1
  212. package/dist/mcp/tools/core-mail-profile.mcp-tools.d.ts +0 -20
  213. package/dist/mcp/tools/core-mail-profile.mcp-tools.d.ts.map +0 -1
  214. package/dist/mcp/tools/core-mail-profile.mcp-tools.js +0 -96
  215. package/dist/mcp/tools/core-mail-profile.mcp-tools.js.map +0 -1
  216. package/dist/whatsapp-profile/dto/create.dto.d.ts +0 -11
  217. package/dist/whatsapp-profile/dto/create.dto.d.ts.map +0 -1
  218. package/dist/whatsapp-profile/dto/create.dto.js +0 -55
  219. package/dist/whatsapp-profile/dto/create.dto.js.map +0 -1
  220. package/dist/whatsapp-profile/dto/update.dto.d.ts +0 -6
  221. package/dist/whatsapp-profile/dto/update.dto.d.ts.map +0 -1
  222. package/dist/whatsapp-profile/dto/update.dto.js +0 -9
  223. package/dist/whatsapp-profile/dto/update.dto.js.map +0 -1
  224. package/dist/whatsapp-profile/whatsapp-profile.controller.d.ts +0 -54
  225. package/dist/whatsapp-profile/whatsapp-profile.controller.d.ts.map +0 -1
  226. package/dist/whatsapp-profile/whatsapp-profile.controller.js +0 -85
  227. package/dist/whatsapp-profile/whatsapp-profile.controller.js.map +0 -1
  228. package/dist/whatsapp-profile/whatsapp-profile.module.d.ts +0 -3
  229. package/dist/whatsapp-profile/whatsapp-profile.module.d.ts.map +0 -1
  230. package/dist/whatsapp-profile/whatsapp-profile.module.js +0 -26
  231. package/dist/whatsapp-profile/whatsapp-profile.module.js.map +0 -1
  232. package/dist/whatsapp-profile/whatsapp-profile.service.d.ts +0 -63
  233. package/dist/whatsapp-profile/whatsapp-profile.service.d.ts.map +0 -1
  234. package/dist/whatsapp-profile/whatsapp-profile.service.js +0 -138
  235. package/dist/whatsapp-profile/whatsapp-profile.service.js.map +0 -1
  236. package/hedhog/data/mail_profile.yaml +0 -18
  237. package/hedhog/data/whatsapp_profile.yaml +0 -6
  238. package/hedhog/table/mail_profile.yaml +0 -75
  239. package/hedhog/table/whatsapp_profile.yaml +0 -26
  240. package/src/mail-profile/dto/create.dto.ts +0 -145
  241. package/src/mail-profile/dto/update.dto.ts +0 -4
  242. package/src/mail-profile/mail-profile.controller.ts +0 -56
  243. package/src/mail-profile/mail-profile.module.ts +0 -18
  244. package/src/mail-profile/mail-profile.service.ts +0 -308
  245. package/src/mcp/tools/core-mail-profile.mcp-tools.ts +0 -69
  246. package/src/whatsapp-profile/dto/create.dto.ts +0 -36
  247. package/src/whatsapp-profile/dto/update.dto.ts +0 -4
  248. package/src/whatsapp-profile/whatsapp-profile.controller.ts +0 -51
  249. package/src/whatsapp-profile/whatsapp-profile.module.ts +0 -13
  250. package/src/whatsapp-profile/whatsapp-profile.service.ts +0 -160
@@ -1,45 +1,50 @@
1
- import { MailModule as MailMainModule } from '@hed-hog/api-mail';
2
- import { PaginationModule } from '@hed-hog/api-pagination';
3
- import { PrismaModule } from '@hed-hog/api-prisma';
4
- import { HttpModule } from '@nestjs/axios';
5
- import { Module, forwardRef } from '@nestjs/common';
6
- import { IntegrationModule } from '../integration/integration.module';
7
- import { MailModule } from '../mail/mail.module';
8
- import { EventWebhookController } from './event-webhook.controller';
9
- import { EventWebhookService } from './event-webhook.service';
10
- import { IntegrationEventCatalogController } from './integration-event-catalog.controller';
11
- import { IntegrationEventCatalogService } from './integration-event-catalog.service';
12
- import {
13
- PublicWebhookController,
14
- WebhookIntegrationController,
15
- } from './webhook-integration.controller';
16
- import { WebhookIntegrationService } from './webhook-integration.service';
17
-
18
- @Module({
19
- imports: [
20
- HttpModule,
21
- forwardRef(() => PrismaModule),
22
- forwardRef(() => PaginationModule),
23
- forwardRef(() => IntegrationModule),
24
- forwardRef(() => MailModule),
25
- forwardRef(() => MailMainModule),
26
- ],
27
- controllers: [
28
- IntegrationEventCatalogController,
29
- WebhookIntegrationController,
30
- PublicWebhookController,
31
- EventWebhookController,
32
- ],
33
- providers: [
34
- IntegrationEventCatalogService,
35
- WebhookIntegrationService,
36
- EventWebhookService,
37
- ],
38
- exports: [
39
- IntegrationEventCatalogService,
40
- WebhookIntegrationService,
41
- EventWebhookService,
42
- ],
43
- })
44
- export class WebhookIntegrationModule {}
45
-
1
+ import { MailModule as MailMainModule } from '@hed-hog/api-mail';
2
+ import { PaginationModule } from '@hed-hog/api-pagination';
3
+ import { PrismaModule } from '@hed-hog/api-prisma';
4
+ import { HttpModule } from '@nestjs/axios';
5
+ import { Module, forwardRef } from '@nestjs/common';
6
+ import { IntegrationModule } from '../integration/integration.module';
7
+ import { MailModule } from '../mail/mail.module';
8
+ import { McpModule } from '../mcp/mcp.module';
9
+ import { EventWebhookController } from './event-webhook.controller';
10
+ import { EventWebhookService } from './event-webhook.service';
11
+ import { IntegrationEventCatalogController } from './integration-event-catalog.controller';
12
+ import { IntegrationEventCatalogService } from './integration-event-catalog.service';
13
+ import { WebhookCommandRegistry } from './webhook-command.registry';
14
+ import {
15
+ PublicWebhookController,
16
+ WebhookIntegrationController,
17
+ } from './webhook-integration.controller';
18
+ import { WebhookIntegrationService } from './webhook-integration.service';
19
+
20
+ @Module({
21
+ imports: [
22
+ HttpModule,
23
+ forwardRef(() => PrismaModule),
24
+ forwardRef(() => PaginationModule),
25
+ forwardRef(() => IntegrationModule),
26
+ forwardRef(() => MailModule),
27
+ forwardRef(() => MailMainModule),
28
+ forwardRef(() => McpModule),
29
+ ],
30
+ controllers: [
31
+ IntegrationEventCatalogController,
32
+ WebhookIntegrationController,
33
+ PublicWebhookController,
34
+ EventWebhookController,
35
+ ],
36
+ providers: [
37
+ IntegrationEventCatalogService,
38
+ WebhookCommandRegistry,
39
+ WebhookIntegrationService,
40
+ EventWebhookService,
41
+ ],
42
+ exports: [
43
+ IntegrationEventCatalogService,
44
+ WebhookCommandRegistry,
45
+ WebhookIntegrationService,
46
+ EventWebhookService,
47
+ ],
48
+ })
49
+ export class WebhookIntegrationModule {}
50
+
@@ -13,16 +13,18 @@ import { EventEmitter } from 'events';
13
13
  import { Request, Response } from 'express';
14
14
  import { firstValueFrom } from 'rxjs';
15
15
  import {
16
- buildMailConfigFromIntegration,
17
- getFromAddress,
18
- getReplyToAddress,
16
+ buildMailConfigFromIntegration,
17
+ getFromAddress,
18
+ getReplyToAddress,
19
19
  } from '../integration-profile/integration-profile.utils';
20
20
  import { MailService } from '../mail/mail.service';
21
+ import { McpApiKeyService } from '../mcp/mcp-api-key.service';
21
22
  import { SettingService } from '../setting/setting.service';
22
23
  import {
23
- CreateWebhookActionDTO,
24
- UpdateWebhookActionDTO,
24
+ CreateWebhookActionDTO,
25
+ UpdateWebhookActionDTO,
25
26
  } from './dto/webhook-action.dto';
27
+ import { WebhookCommandRegistry } from './webhook-command.registry';
26
28
  import {
27
29
  createPlainToken,
28
30
  createPublicUuid,
@@ -36,7 +38,12 @@ import {
36
38
  type ActionExecutionLog = {
37
39
  webhookActionId: number;
38
40
  actionName: string;
39
- actionType: 'email' | 'whatsapp_evolution';
41
+ actionType:
42
+ | 'email'
43
+ | 'whatsapp_evolution'
44
+ | 'http_request'
45
+ | 'internal_api'
46
+ | 'app_command';
40
47
  status: 'success' | 'failed';
41
48
  durationMs: number;
42
49
  requestPayload?: unknown;
@@ -52,6 +59,42 @@ type WebhookActionPayload =
52
59
  @Injectable()
53
60
  export class WebhookIntegrationService {
54
61
  private readonly logEmitter = new EventEmitter();
62
+ private readonly webhookActionSelect = {
63
+ id: true,
64
+ webhook_integration_id: true,
65
+ type: true,
66
+ name: true,
67
+ order: true,
68
+ status: true,
69
+ integration_profile_id: true,
70
+ mail_id: true,
71
+ email_to: true,
72
+ email_cc: true,
73
+ email_bcc: true,
74
+ whatsapp_target_type: true,
75
+ whatsapp_target: true,
76
+ whatsapp_template: true,
77
+ whatsapp_instance: true,
78
+ whatsapp_base_url: true,
79
+ whatsapp_token: true,
80
+ http_url: true,
81
+ http_method: true,
82
+ http_headers: true,
83
+ http_query: true,
84
+ http_body: true,
85
+ http_timeout_ms: true,
86
+ http_retry_count: true,
87
+ internal_api_path: true,
88
+ internal_api_method: true,
89
+ internal_api_query: true,
90
+ internal_api_body: true,
91
+ internal_api_token: true,
92
+ internal_api_user_id: true,
93
+ app_command_slug: true,
94
+ app_command_params: true,
95
+ created_at: true,
96
+ updated_at: true,
97
+ } as const;
55
98
 
56
99
  constructor(
57
100
  private readonly prisma: PrismaService,
@@ -60,6 +103,8 @@ export class WebhookIntegrationService {
60
103
  private readonly mailMainService: MailMainService,
61
104
  private readonly coreMailService: MailService,
62
105
  private readonly settingService: SettingService,
106
+ private readonly commandRegistry: WebhookCommandRegistry,
107
+ private readonly mcpApiKeyService: McpApiKeyService,
63
108
  ) {}
64
109
 
65
110
  private get integrations() {
@@ -89,6 +134,7 @@ export class WebhookIntegrationService {
89
134
  where: OR.length > 0 ? { OR } : {},
90
135
  include: {
91
136
  webhook_action: {
137
+ select: this.webhookActionSelect,
92
138
  orderBy: [{ order: 'asc' }, { id: 'asc' }],
93
139
  },
94
140
  },
@@ -107,6 +153,7 @@ export class WebhookIntegrationService {
107
153
  where: { id },
108
154
  include: {
109
155
  webhook_action: {
156
+ select: this.webhookActionSelect,
110
157
  orderBy: [{ order: 'asc' }, { id: 'asc' }],
111
158
  },
112
159
  },
@@ -237,7 +284,8 @@ export class WebhookIntegrationService {
237
284
  name: a.name,
238
285
  order: a.order,
239
286
  status: a.status,
240
- mail_profile_id: a.mail_profile_id,
287
+ integration_profile_id:
288
+ a.integration_profile_id ?? null,
241
289
  mail_id: a.mail_id,
242
290
  email_to: a.email_to,
243
291
  email_cc: a.email_cc,
@@ -248,6 +296,21 @@ export class WebhookIntegrationService {
248
296
  whatsapp_instance: a.whatsapp_instance,
249
297
  whatsapp_base_url: a.whatsapp_base_url,
250
298
  whatsapp_token: a.whatsapp_token,
299
+ http_url: a.http_url,
300
+ http_method: a.http_method,
301
+ http_headers: a.http_headers,
302
+ http_query: a.http_query,
303
+ http_body: a.http_body,
304
+ http_timeout_ms: a.http_timeout_ms,
305
+ http_retry_count: a.http_retry_count,
306
+ internal_api_path: a.internal_api_path,
307
+ internal_api_method: a.internal_api_method,
308
+ internal_api_query: a.internal_api_query,
309
+ internal_api_body: a.internal_api_body,
310
+ internal_api_token: a.internal_api_token,
311
+ internal_api_user_id: a.internal_api_user_id,
312
+ app_command_slug: a.app_command_slug,
313
+ app_command_params: a.app_command_params,
251
314
  })),
252
315
  },
253
316
  },
@@ -358,6 +421,48 @@ export class WebhookIntegrationService {
358
421
  });
359
422
  }
360
423
 
424
+ async listUserApiTokens(userId: number) {
425
+ return (this.prisma as any).mcp_api_key.findMany({
426
+ where: { user_id: userId, type: 'api', revoked_at: null },
427
+ select: {
428
+ id: true,
429
+ name: true,
430
+ token_prefix: true,
431
+ last_used_at: true,
432
+ created_at: true,
433
+ },
434
+ orderBy: { created_at: 'desc' },
435
+ });
436
+ }
437
+
438
+ async createUserApiToken(userId: number, name: string) {
439
+ return this.mcpApiKeyService.create(userId, name, 'api');
440
+ }
441
+
442
+ async listInternalRoutes() {
443
+ return (this.prisma as any).route.findMany({
444
+ select: {
445
+ id: true,
446
+ url: true,
447
+ method: true,
448
+ },
449
+ where: {
450
+ url: { not: null },
451
+ method: { not: null },
452
+ },
453
+ orderBy: [{ url: 'asc' }, { method: 'asc' }],
454
+ });
455
+ }
456
+
457
+ async listAppCommands() {
458
+ return this.commandRegistry.list().map((cmd) => ({
459
+ slug: cmd.slug,
460
+ name: cmd.name,
461
+ description: cmd.description,
462
+ inputSchema: cmd.inputSchema,
463
+ }));
464
+ }
465
+
361
466
  async listLogs(
362
467
  integrationId: number,
363
468
  paginationParams: PaginationDTO,
@@ -456,6 +561,7 @@ export class WebhookIntegrationService {
456
561
  where: { public_uuid: uuid },
457
562
  include: {
458
563
  webhook_action: {
564
+ select: this.webhookActionSelect,
459
565
  where: { status: 'active' },
460
566
  orderBy: [{ order: 'asc' }, { id: 'asc' }],
461
567
  },
@@ -598,6 +704,18 @@ export class WebhookIntegrationService {
598
704
  return this.executeWhatsappAction(action, body);
599
705
  }
600
706
 
707
+ if (action.type === 'http_request') {
708
+ return this.executeHttpRequestAction(action, body);
709
+ }
710
+
711
+ if (action.type === 'internal_api') {
712
+ return this.executeInternalApiAction(action, body);
713
+ }
714
+
715
+ if (action.type === 'app_command') {
716
+ return this.executeAppCommandAction(action, body);
717
+ }
718
+
601
719
  throw new BadRequestException(`Unsupported action type: ${action.type}`);
602
720
  }
603
721
 
@@ -605,7 +723,7 @@ export class WebhookIntegrationService {
605
723
  this.validateActionConfiguration(action);
606
724
 
607
725
  const profile = await (this.prisma as any).integration_profile.findUnique({
608
- where: { id: Number(action.mail_profile_id) },
726
+ where: { id: Number(action.integration_profile_id) },
609
727
  include: { integration_provider: { select: { slug: true } } },
610
728
  });
611
729
  const mail = await (this.prisma as any).mail.findUnique({
@@ -749,6 +867,193 @@ export class WebhookIntegrationService {
749
867
  };
750
868
  }
751
869
 
870
+ private async executeHttpRequestAction(action: any, body: any) {
871
+ this.validateActionConfiguration(action);
872
+
873
+ const method = String(action.http_method || 'POST').toUpperCase();
874
+ const rawUrl = String(action.http_url || '').trim();
875
+ const timeoutMs = Number(action.http_timeout_ms || 30000);
876
+ const maxAttempts = Math.max(1, Number(action.http_retry_count || 0) + 1);
877
+
878
+ const renderedUrl = String(renderTemplate(rawUrl, body) ?? rawUrl).trim();
879
+
880
+ const rawHeaders = normalizeJsonObject(action.http_headers) || {};
881
+ const renderedHeaders: Record<string, string> = {};
882
+ for (const [k, v] of Object.entries(rawHeaders)) {
883
+ renderedHeaders[k] = String(renderTemplate(String(v), body) ?? v);
884
+ }
885
+
886
+ const rawQuery = normalizeJsonObject(action.http_query) || {};
887
+ const renderedQuery: Record<string, string> = {};
888
+ for (const [k, v] of Object.entries(rawQuery)) {
889
+ renderedQuery[k] = String(renderTemplate(String(v), body) ?? v);
890
+ }
891
+
892
+ const rawBody = String(action.http_body || '').trim();
893
+ const renderedBody = rawBody
894
+ ? (renderTemplate(rawBody, body) as string)
895
+ : undefined;
896
+
897
+ let parsedBody: unknown = renderedBody;
898
+ if (renderedBody) {
899
+ try {
900
+ parsedBody = JSON.parse(renderedBody);
901
+ } catch {
902
+ parsedBody = renderedBody;
903
+ }
904
+ }
905
+
906
+ const requestPayload = {
907
+ method,
908
+ url: renderedUrl,
909
+ headers: renderedHeaders,
910
+ query: renderedQuery,
911
+ body: parsedBody,
912
+ };
913
+
914
+ let lastError: unknown;
915
+ for (let attempt = 0; attempt < maxAttempts; attempt++) {
916
+ try {
917
+ const response = await firstValueFrom(
918
+ this.http.request({
919
+ method,
920
+ url: renderedUrl,
921
+ headers: renderedHeaders,
922
+ params: Object.keys(renderedQuery).length ? renderedQuery : undefined,
923
+ data: parsedBody,
924
+ timeout: timeoutMs,
925
+ }),
926
+ );
927
+
928
+ return {
929
+ requestPayload,
930
+ responsePayload: {
931
+ status: response?.status || null,
932
+ statusText: response?.statusText || null,
933
+ data: response?.data || null,
934
+ },
935
+ };
936
+ } catch (error) {
937
+ lastError = error;
938
+ if (attempt === maxAttempts - 1) {
939
+ this.attachErrorRequestPayload(error, requestPayload);
940
+ throw error;
941
+ }
942
+ }
943
+ }
944
+
945
+ this.attachErrorRequestPayload(lastError, requestPayload);
946
+ throw lastError;
947
+ }
948
+
949
+ private async executeInternalApiAction(action: any, body: any) {
950
+ this.validateActionConfiguration(action);
951
+
952
+ const baseUrl = await this.getApplicationBaseUrl();
953
+ if (!baseUrl) {
954
+ throw new BadRequestException(
955
+ 'Internal API action requires the api-url setting to be configured.',
956
+ );
957
+ }
958
+
959
+ const method = String(action.internal_api_method || 'POST').toUpperCase();
960
+ const rawPath = String(action.internal_api_path || '').trim();
961
+ const token = String(action.internal_api_token || '').trim();
962
+
963
+ const renderedPath = String(renderTemplate(rawPath, body) ?? rawPath).trim();
964
+
965
+ const rawQuery = normalizeJsonObject(action.internal_api_query) || {};
966
+ const renderedQuery: Record<string, string> = {};
967
+ for (const [k, v] of Object.entries(rawQuery)) {
968
+ renderedQuery[k] = String(renderTemplate(String(v), body) ?? v);
969
+ }
970
+
971
+ const rawBody = normalizeJsonObject(action.internal_api_body) || {};
972
+ const renderedBodyObj: Record<string, unknown> = {};
973
+ for (const [k, v] of Object.entries(rawBody)) {
974
+ renderedBodyObj[k] = typeof v === 'string' ? renderTemplate(v, body) : v;
975
+ }
976
+
977
+ const url = `${baseUrl}${renderedPath.startsWith('/') ? '' : '/'}${renderedPath}`;
978
+
979
+ const requestPayload = {
980
+ method,
981
+ url,
982
+ query: renderedQuery,
983
+ body: renderedBodyObj,
984
+ };
985
+
986
+ let response: any;
987
+ try {
988
+ response = await firstValueFrom(
989
+ this.http.request({
990
+ method,
991
+ url,
992
+ headers: {
993
+ Authorization: `Bearer ${token}`,
994
+ 'Content-Type': 'application/json',
995
+ },
996
+ params: Object.keys(renderedQuery).length ? renderedQuery : undefined,
997
+ data: Object.keys(renderedBodyObj).length ? renderedBodyObj : undefined,
998
+ timeout: 30000,
999
+ }),
1000
+ );
1001
+ } catch (error) {
1002
+ this.attachErrorRequestPayload(error, requestPayload);
1003
+ throw error;
1004
+ }
1005
+
1006
+ return {
1007
+ requestPayload,
1008
+ responsePayload: {
1009
+ status: response?.status || null,
1010
+ statusText: response?.statusText || null,
1011
+ data: response?.data || null,
1012
+ },
1013
+ };
1014
+ }
1015
+
1016
+ private async executeAppCommandAction(action: any, body: any) {
1017
+ this.validateActionConfiguration(action);
1018
+
1019
+ const slug = String(action.app_command_slug || '').trim();
1020
+ const command = this.commandRegistry.find(slug);
1021
+ if (!command) {
1022
+ throw new BadRequestException(`app_command: unknown command slug "${slug}".`);
1023
+ }
1024
+
1025
+ const rawParams = normalizeJsonObject(action.app_command_params) || {};
1026
+ const renderedParams: Record<string, unknown> = {};
1027
+ for (const [k, v] of Object.entries(rawParams)) {
1028
+ renderedParams[k] = typeof v === 'string' ? renderTemplate(v, body) : v;
1029
+ }
1030
+
1031
+ const schemaErrors = this.validateJsonSchema(command.inputSchema, renderedParams);
1032
+ if (schemaErrors.length) {
1033
+ throw new BadRequestException({
1034
+ message: `app_command "${slug}" params do not match expected schema.`,
1035
+ errors: schemaErrors,
1036
+ });
1037
+ }
1038
+
1039
+ const requestPayload = { slug, params: renderedParams };
1040
+
1041
+ let result: unknown;
1042
+ try {
1043
+ result = await this.commandRegistry.dispatch(slug, renderedParams, {
1044
+ webhookBody: body,
1045
+ });
1046
+ } catch (error) {
1047
+ this.attachErrorRequestPayload(error, requestPayload);
1048
+ throw error;
1049
+ }
1050
+
1051
+ return {
1052
+ requestPayload,
1053
+ responsePayload: result,
1054
+ };
1055
+ }
1056
+
752
1057
  private validateToken(integration: any, headers: any) {
753
1058
  if (!integration.require_token) {
754
1059
  return;
@@ -782,8 +1087,8 @@ export class WebhookIntegrationService {
782
1087
  if (action?.type === 'email') {
783
1088
  const missing: string[] = [];
784
1089
 
785
- if (!this.nullableNumber(action.mail_profile_id)) {
786
- missing.push('mail_profile_id');
1090
+ if (!this.nullableNumber(action.integration_profile_id)) {
1091
+ missing.push('integration_profile_id');
787
1092
  }
788
1093
 
789
1094
  if (!this.nullableNumber(action.mail_id)) {
@@ -818,6 +1123,40 @@ export class WebhookIntegrationService {
818
1123
  );
819
1124
  }
820
1125
  }
1126
+
1127
+ if (action?.type === 'http_request') {
1128
+ if (!this.nullableString(action.http_url)) {
1129
+ throw new BadRequestException(
1130
+ 'HTTP request action is missing required configuration: http_url.',
1131
+ );
1132
+ }
1133
+ }
1134
+
1135
+ if (action?.type === 'internal_api') {
1136
+ const missing: string[] = [];
1137
+ if (!this.nullableString(action.internal_api_path)) {
1138
+ missing.push('internal_api_path');
1139
+ }
1140
+ if (!this.nullableNumber(action.internal_api_user_id)) {
1141
+ missing.push('internal_api_user_id');
1142
+ }
1143
+ if (!this.nullableString(action.internal_api_token)) {
1144
+ missing.push('internal_api_token');
1145
+ }
1146
+ if (missing.length) {
1147
+ throw new BadRequestException(
1148
+ `Internal API action is missing required configuration: ${missing.join(', ')}.`,
1149
+ );
1150
+ }
1151
+ }
1152
+
1153
+ if (action?.type === 'app_command') {
1154
+ if (!this.nullableString(action.app_command_slug)) {
1155
+ throw new BadRequestException(
1156
+ 'App command action is missing required configuration: app_command_slug.',
1157
+ );
1158
+ }
1159
+ }
821
1160
  }
822
1161
 
823
1162
  private validateBodySchema(integration: any, body: any) {
@@ -1109,7 +1448,10 @@ export class WebhookIntegrationService {
1109
1448
  assign('name', String(data.name ?? '').trim());
1110
1449
  assign('order', Number(data.order ?? 0));
1111
1450
  assign('status', data.status === 'inactive' ? 'inactive' : 'active');
1112
- assign('mail_profile_id', this.nullableNumber(data.mail_profile_id, partial));
1451
+ assign(
1452
+ 'integration_profile_id',
1453
+ this.nullableNumber((data as any).integration_profile_id, partial),
1454
+ );
1113
1455
  assign('mail_id', this.nullableNumber(data.mail_id, partial));
1114
1456
  assign('email_to', this.nullableString(data.email_to, partial));
1115
1457
  assign('email_cc', this.nullableString(data.email_cc, partial));
@@ -1132,6 +1474,27 @@ export class WebhookIntegrationService {
1132
1474
  this.nullableString(data.whatsapp_base_url, partial),
1133
1475
  );
1134
1476
  assign('whatsapp_token', this.nullableString(data.whatsapp_token, partial));
1477
+ assign('http_url', this.nullableString(data.http_url, partial));
1478
+ assign('http_method', this.nullableString(data.http_method, partial));
1479
+ assign('http_headers', normalizeJsonObject(data.http_headers));
1480
+ assign('http_query', normalizeJsonObject(data.http_query));
1481
+ assign('http_body', this.nullableString(data.http_body, partial));
1482
+ assign('http_timeout_ms', this.nullableNumber(data.http_timeout_ms, partial));
1483
+ assign('http_retry_count', this.nullableNumber(data.http_retry_count, partial));
1484
+ assign('internal_api_path', this.nullableString(data.internal_api_path, partial));
1485
+ assign(
1486
+ 'internal_api_method',
1487
+ this.nullableString(data.internal_api_method, partial),
1488
+ );
1489
+ assign('internal_api_query', normalizeJsonObject(data.internal_api_query));
1490
+ assign('internal_api_body', normalizeJsonObject(data.internal_api_body));
1491
+ assign('internal_api_token', this.nullableString(data.internal_api_token, partial));
1492
+ assign(
1493
+ 'internal_api_user_id',
1494
+ this.nullableNumber(data.internal_api_user_id, partial),
1495
+ );
1496
+ assign('app_command_slug', this.nullableString(data.app_command_slug, partial));
1497
+ assign('app_command_params', normalizeJsonObject(data.app_command_params));
1135
1498
 
1136
1499
  return normalized;
1137
1500
  }
@@ -1,23 +0,0 @@
1
- declare const providerOptions: readonly ["SMTP", "GMAIL", "SES"];
2
- export declare class CreateDTO {
3
- slug: string;
4
- name: string;
5
- provider: (typeof providerOptions)[number];
6
- from_name?: string;
7
- from_email: string;
8
- reply_to_name?: string;
9
- reply_to_email?: string;
10
- smtp_host?: string;
11
- smtp_port?: number;
12
- smtp_secure?: boolean;
13
- smtp_username?: string;
14
- smtp_password?: string;
15
- gmail_client_id?: string;
16
- gmail_client_secret?: string;
17
- gmail_refresh_token?: string;
18
- ses_access_key_id?: string;
19
- ses_secret_access_key?: string;
20
- ses_region?: string;
21
- }
22
- export {};
23
- //# sourceMappingURL=create.dto.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"create.dto.d.ts","sourceRoot":"","sources":["../../../src/mail-profile/dto/create.dto.ts"],"names":[],"mappings":"AAaA,QAAA,MAAM,eAAe,mCAAoC,CAAC;AAE1D,qBAAa,SAAS;IAIpB,IAAI,EAAE,MAAM,CAAC;IAKb,IAAI,EAAE,MAAM,CAAC;IAIb,QAAQ,EAAE,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;IAQ3C,SAAS,CAAC,EAAE,MAAM,CAAC;IAKnB,UAAU,EAAE,MAAM,CAAC;IAQnB,aAAa,CAAC,EAAE,MAAM,CAAC;IAQvB,cAAc,CAAC,EAAE,MAAM,CAAC;IAQxB,SAAS,CAAC,EAAE,MAAM,CAAC;IAQnB,SAAS,CAAC,EAAE,MAAM,CAAC;IAOnB,WAAW,CAAC,EAAE,OAAO,CAAC;IAQtB,aAAa,CAAC,EAAE,MAAM,CAAC;IAQvB,aAAa,CAAC,EAAE,MAAM,CAAC;IAQvB,eAAe,CAAC,EAAE,MAAM,CAAC;IAQzB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAO7B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAQ7B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAQ3B,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAQ/B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB"}