@hed-hog/core 0.0.355 → 0.0.358

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 (287) hide show
  1. package/dist/ai/ai.service.d.ts +3 -12
  2. package/dist/ai/ai.service.d.ts.map +1 -1
  3. package/dist/ai/ai.service.js +34 -125
  4. package/dist/ai/ai.service.js.map +1 -1
  5. package/dist/auth/guards/auth.guard.d.ts +6 -1
  6. package/dist/auth/guards/auth.guard.d.ts.map +1 -1
  7. package/dist/auth/guards/auth.guard.js +33 -2
  8. package/dist/auth/guards/auth.guard.js.map +1 -1
  9. package/dist/core.module.d.ts.map +1 -1
  10. package/dist/core.module.js +3 -3
  11. package/dist/core.module.js.map +1 -1
  12. package/dist/file/file.controller.d.ts +4 -2
  13. package/dist/file/file.controller.d.ts.map +1 -1
  14. package/dist/file/file.controller.js +44 -38
  15. package/dist/file/file.controller.js.map +1 -1
  16. package/dist/file/file.service.d.ts +2 -2
  17. package/dist/file/file.service.d.ts.map +1 -1
  18. package/dist/file/file.service.js +58 -89
  19. package/dist/file/file.service.js.map +1 -1
  20. package/dist/file/provider/azure.provider.d.ts.map +1 -1
  21. package/dist/file/provider/azure.provider.js +10 -15
  22. package/dist/file/provider/azure.provider.js.map +1 -1
  23. package/dist/file/provider/gcs.provider.d.ts.map +1 -1
  24. package/dist/file/provider/gcs.provider.js +8 -9
  25. package/dist/file/provider/gcs.provider.js.map +1 -1
  26. package/dist/file/provider/local.provider.d.ts.map +1 -1
  27. package/dist/file/provider/local.provider.js +11 -10
  28. package/dist/file/provider/local.provider.js.map +1 -1
  29. package/dist/file/provider/provider.enum.d.ts +2 -1
  30. package/dist/file/provider/provider.enum.d.ts.map +1 -1
  31. package/dist/file/provider/provider.enum.js +1 -0
  32. package/dist/file/provider/provider.enum.js.map +1 -1
  33. package/dist/file/provider/provider.factory.d.ts +1 -1
  34. package/dist/file/provider/provider.factory.d.ts.map +1 -1
  35. package/dist/file/provider/provider.factory.js +18 -5
  36. package/dist/file/provider/provider.factory.js.map +1 -1
  37. package/dist/file/provider/s3.provider.d.ts.map +1 -1
  38. package/dist/file/provider/s3.provider.js +4 -20
  39. package/dist/file/provider/s3.provider.js.map +1 -1
  40. package/dist/file/provider/spaces.provider.d.ts +27 -0
  41. package/dist/file/provider/spaces.provider.d.ts.map +1 -0
  42. package/dist/file/provider/spaces.provider.js +203 -0
  43. package/dist/file/provider/spaces.provider.js.map +1 -0
  44. package/dist/index.d.ts +4 -3
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js +4 -3
  47. package/dist/index.js.map +1 -1
  48. package/dist/integration-profile/dto/create.dto.d.ts +9 -0
  49. package/dist/integration-profile/dto/create.dto.d.ts.map +1 -0
  50. package/dist/integration-profile/dto/create.dto.js +54 -0
  51. package/dist/integration-profile/dto/create.dto.js.map +1 -0
  52. package/dist/integration-profile/dto/export.dto.d.ts +5 -0
  53. package/dist/integration-profile/dto/export.dto.d.ts.map +1 -0
  54. package/dist/integration-profile/dto/export.dto.js +29 -0
  55. package/dist/integration-profile/dto/export.dto.js.map +1 -0
  56. package/dist/integration-profile/dto/import-confirm.dto.d.ts +17 -0
  57. package/dist/integration-profile/dto/import-confirm.dto.d.ts.map +1 -0
  58. package/dist/integration-profile/dto/import-confirm.dto.js +77 -0
  59. package/dist/integration-profile/dto/import-confirm.dto.js.map +1 -0
  60. package/dist/integration-profile/dto/update.dto.d.ts.map +1 -0
  61. package/dist/integration-profile/dto/update.dto.js.map +1 -0
  62. package/dist/integration-profile/integration-profile.controller.d.ts +142 -0
  63. package/dist/integration-profile/integration-profile.controller.d.ts.map +1 -0
  64. package/dist/integration-profile/integration-profile.controller.js +166 -0
  65. package/dist/integration-profile/integration-profile.controller.js.map +1 -0
  66. package/dist/integration-profile/integration-profile.module.d.ts +3 -0
  67. package/dist/integration-profile/integration-profile.module.d.ts.map +1 -0
  68. package/dist/{mail-profile/mail-profile.module.js → integration-profile/integration-profile.module.js} +11 -13
  69. package/dist/integration-profile/integration-profile.module.js.map +1 -0
  70. package/dist/integration-profile/integration-profile.service.d.ts +160 -0
  71. package/dist/integration-profile/integration-profile.service.d.ts.map +1 -0
  72. package/dist/integration-profile/integration-profile.service.js +609 -0
  73. package/dist/integration-profile/integration-profile.service.js.map +1 -0
  74. package/dist/integration-profile/integration-profile.utils.d.ts +30 -0
  75. package/dist/integration-profile/integration-profile.utils.d.ts.map +1 -0
  76. package/dist/integration-profile/integration-profile.utils.js +156 -0
  77. package/dist/integration-profile/integration-profile.utils.js.map +1 -0
  78. package/dist/mail/mail.module.d.ts.map +1 -1
  79. package/dist/mail/mail.module.js +36 -23
  80. package/dist/mail/mail.module.js.map +1 -1
  81. package/dist/mail/mail.service.d.ts +4 -2
  82. package/dist/mail/mail.service.d.ts.map +1 -1
  83. package/dist/mail/mail.service.js +33 -51
  84. package/dist/mail/mail.service.js.map +1 -1
  85. package/dist/mcp/guards/mcp-auth.guard.js +1 -1
  86. package/dist/mcp/guards/mcp-auth.guard.js.map +1 -1
  87. package/dist/mcp/mcp-api-key.controller.d.ts +2 -0
  88. package/dist/mcp/mcp-api-key.controller.d.ts.map +1 -1
  89. package/dist/mcp/mcp-api-key.controller.js +1 -1
  90. package/dist/mcp/mcp-api-key.controller.js.map +1 -1
  91. package/dist/mcp/mcp-api-key.service.d.ts +2 -1
  92. package/dist/mcp/mcp-api-key.service.d.ts.map +1 -1
  93. package/dist/mcp/mcp-api-key.service.js +6 -2
  94. package/dist/mcp/mcp-api-key.service.js.map +1 -1
  95. package/dist/mcp/mcp.module.d.ts.map +1 -1
  96. package/dist/mcp/mcp.module.js +3 -5
  97. package/dist/mcp/mcp.module.js.map +1 -1
  98. package/dist/mcp-chat/mcp-chat.service.d.ts.map +1 -1
  99. package/dist/mcp-chat/mcp-chat.service.js +17 -16
  100. package/dist/mcp-chat/mcp-chat.service.js.map +1 -1
  101. package/dist/oauth/interfaces/OAuthProvider.d.ts +1 -1
  102. package/dist/oauth/interfaces/OAuthProvider.d.ts.map +1 -1
  103. package/dist/oauth/oauth.controller.d.ts +4 -1
  104. package/dist/oauth/oauth.controller.d.ts.map +1 -1
  105. package/dist/oauth/oauth.controller.js +31 -5
  106. package/dist/oauth/oauth.controller.js.map +1 -1
  107. package/dist/oauth/oauth.service.d.ts +12 -1
  108. package/dist/oauth/oauth.service.d.ts.map +1 -1
  109. package/dist/oauth/oauth.service.js +125 -23
  110. package/dist/oauth/oauth.service.js.map +1 -1
  111. package/dist/oauth/providers/abstract.provider.d.ts +1 -1
  112. package/dist/oauth/providers/abstract.provider.d.ts.map +1 -1
  113. package/dist/oauth/providers/facebook.provider.d.ts +5 -2
  114. package/dist/oauth/providers/facebook.provider.d.ts.map +1 -1
  115. package/dist/oauth/providers/facebook.provider.js +34 -19
  116. package/dist/oauth/providers/facebook.provider.js.map +1 -1
  117. package/dist/oauth/providers/github.provider.d.ts +6 -2
  118. package/dist/oauth/providers/github.provider.d.ts.map +1 -1
  119. package/dist/oauth/providers/github.provider.js +43 -20
  120. package/dist/oauth/providers/github.provider.js.map +1 -1
  121. package/dist/oauth/providers/google.provider.d.ts +5 -2
  122. package/dist/oauth/providers/google.provider.d.ts.map +1 -1
  123. package/dist/oauth/providers/google.provider.js +34 -19
  124. package/dist/oauth/providers/google.provider.js.map +1 -1
  125. package/dist/oauth/providers/microsoft-entra-id.provider.d.ts +5 -2
  126. package/dist/oauth/providers/microsoft-entra-id.provider.d.ts.map +1 -1
  127. package/dist/oauth/providers/microsoft-entra-id.provider.js +43 -40
  128. package/dist/oauth/providers/microsoft-entra-id.provider.js.map +1 -1
  129. package/dist/oauth/providers/microsoft.provider.d.ts +5 -2
  130. package/dist/oauth/providers/microsoft.provider.d.ts.map +1 -1
  131. package/dist/oauth/providers/microsoft.provider.js +34 -19
  132. package/dist/oauth/providers/microsoft.provider.js.map +1 -1
  133. package/dist/profile/profile.controller.js +1 -1
  134. package/dist/profile/profile.controller.js.map +1 -1
  135. package/dist/security/security.service.d.ts +2 -0
  136. package/dist/security/security.service.d.ts.map +1 -1
  137. package/dist/security/security.service.js +21 -0
  138. package/dist/security/security.service.js.map +1 -1
  139. package/dist/setting/setting.service.d.ts +26 -1
  140. package/dist/setting/setting.service.d.ts.map +1 -1
  141. package/dist/setting/setting.service.js +240 -7
  142. package/dist/setting/setting.service.js.map +1 -1
  143. package/dist/user/user.controller.d.ts +2 -1
  144. package/dist/user/user.controller.d.ts.map +1 -1
  145. package/dist/user/user.controller.js +5 -4
  146. package/dist/user/user.controller.js.map +1 -1
  147. package/dist/user/user.service.d.ts +4 -2
  148. package/dist/user/user.service.d.ts.map +1 -1
  149. package/dist/user/user.service.js +19 -4
  150. package/dist/user/user.service.js.map +1 -1
  151. package/dist/webhook-integration/dto/webhook-action.dto.d.ts +17 -2
  152. package/dist/webhook-integration/dto/webhook-action.dto.d.ts.map +1 -1
  153. package/dist/webhook-integration/dto/webhook-action.dto.js +93 -2
  154. package/dist/webhook-integration/dto/webhook-action.dto.js.map +1 -1
  155. package/dist/webhook-integration/event-webhook.controller.d.ts +1 -0
  156. package/dist/webhook-integration/event-webhook.controller.d.ts.map +1 -1
  157. package/dist/webhook-integration/event-webhook.controller.js +10 -0
  158. package/dist/webhook-integration/event-webhook.controller.js.map +1 -1
  159. package/dist/webhook-integration/event-webhook.service.d.ts +2 -0
  160. package/dist/webhook-integration/event-webhook.service.d.ts.map +1 -1
  161. package/dist/webhook-integration/event-webhook.service.js +30 -0
  162. package/dist/webhook-integration/event-webhook.service.js.map +1 -1
  163. package/dist/webhook-integration/webhook-command.registry.d.ts +15 -0
  164. package/dist/webhook-integration/webhook-command.registry.d.ts.map +1 -0
  165. package/dist/webhook-integration/webhook-command.registry.js +36 -0
  166. package/dist/webhook-integration/webhook-command.registry.js.map +1 -0
  167. package/dist/webhook-integration/webhook-integration.controller.d.ts +20 -0
  168. package/dist/webhook-integration/webhook-integration.controller.d.ts.map +1 -1
  169. package/dist/webhook-integration/webhook-integration.controller.js +48 -0
  170. package/dist/webhook-integration/webhook-integration.controller.js.map +1 -1
  171. package/dist/webhook-integration/webhook-integration.module.d.ts.map +1 -1
  172. package/dist/webhook-integration/webhook-integration.module.js +5 -0
  173. package/dist/webhook-integration/webhook-integration.module.js.map +1 -1
  174. package/dist/webhook-integration/webhook-integration.service.d.ts +27 -2
  175. package/dist/webhook-integration/webhook-integration.service.d.ts.map +1 -1
  176. package/dist/webhook-integration/webhook-integration.service.js +377 -50
  177. package/dist/webhook-integration/webhook-integration.service.js.map +1 -1
  178. package/hedhog/data/file_provider.yaml +9 -1
  179. package/hedhog/data/integration_provider.yaml +148 -0
  180. package/hedhog/data/integration_type.yaml +29 -0
  181. package/hedhog/data/menu.yaml +6 -21
  182. package/hedhog/data/role.yaml +8 -0
  183. package/hedhog/data/route.yaml +73 -373
  184. package/hedhog/data/setting_group.yaml +209 -365
  185. package/hedhog/data/setting_subgroup.yaml +21 -13
  186. package/hedhog/frontend/app/account/components/connected-accounts.tsx.ejs +25 -20
  187. package/hedhog/frontend/app/account/components/tokens.tsx.ejs +421 -0
  188. package/hedhog/frontend/app/account/layout.tsx.ejs +6 -3
  189. package/hedhog/frontend/app/account/mcp-tokens/page.tsx.ejs +2 -2
  190. package/hedhog/frontend/app/account/tokens/page.tsx.ejs +5 -0
  191. package/hedhog/frontend/app/configurations/[slug]/components/setting-field.tsx.ejs +938 -225
  192. package/hedhog/frontend/app/configurations/layout.tsx.ejs +1 -1
  193. package/hedhog/frontend/app/dashboard/dashboard-home-tabs.tsx.ejs +3 -1
  194. package/hedhog/frontend/app/integration/profiles/page.tsx.ejs +1830 -0
  195. package/hedhog/frontend/app/integrations-webhooks/page.tsx.ejs +829 -128
  196. package/hedhog/frontend/app/mail/profiles/page.tsx.ejs +1 -820
  197. package/hedhog/frontend/app/setting-list/page.tsx.ejs +229 -395
  198. package/hedhog/frontend/app/users/permissions.tsx.ejs +79 -2
  199. package/hedhog/frontend/app/users/user-sheet.tsx.ejs +7 -2
  200. package/hedhog/frontend/messages/en.json +239 -3
  201. package/hedhog/frontend/messages/pt.json +239 -3
  202. package/hedhog/table/file.yaml +1 -1
  203. package/hedhog/table/integration_profile.yaml +34 -0
  204. package/hedhog/table/integration_provider.yaml +23 -0
  205. package/hedhog/table/integration_type.yaml +19 -0
  206. package/hedhog/table/mcp_api_key.yaml +4 -0
  207. package/hedhog/table/webhook_action.yaml +141 -85
  208. package/package.json +4 -3
  209. package/src/ai/ai.service.ts +35 -153
  210. package/src/auth/guards/auth.guard.ts +32 -0
  211. package/src/core.module.ts +3 -3
  212. package/src/file/file.controller.ts +51 -42
  213. package/src/file/file.service.ts +67 -104
  214. package/src/file/provider/azure.provider.ts +14 -28
  215. package/src/file/provider/gcs.provider.ts +9 -9
  216. package/src/file/provider/local.provider.ts +10 -13
  217. package/src/file/provider/provider.enum.ts +1 -0
  218. package/src/file/provider/provider.factory.ts +21 -6
  219. package/src/file/provider/s3.provider.ts +4 -20
  220. package/src/file/provider/spaces.provider.ts +246 -0
  221. package/src/index.ts +6 -3
  222. package/src/integration-profile/dto/create.dto.ts +44 -0
  223. package/src/integration-profile/dto/export.dto.ts +15 -0
  224. package/src/integration-profile/dto/import-confirm.dto.ts +61 -0
  225. package/src/integration-profile/integration-profile.controller.ts +131 -0
  226. package/src/integration-profile/integration-profile.module.ts +16 -0
  227. package/src/integration-profile/integration-profile.service.ts +793 -0
  228. package/src/integration-profile/integration-profile.utils.ts +173 -0
  229. package/src/mail/mail.module.ts +41 -22
  230. package/src/mail/mail.service.ts +40 -64
  231. package/src/mcp/guards/mcp-auth.guard.ts +1 -1
  232. package/src/mcp/mcp-api-key.controller.ts +2 -2
  233. package/src/mcp/mcp-api-key.service.ts +6 -2
  234. package/src/mcp/mcp.module.ts +3 -5
  235. package/src/mcp-chat/mcp-chat.service.ts +23 -20
  236. package/src/oauth/interfaces/OAuthProvider.ts +1 -1
  237. package/src/oauth/oauth.controller.ts +30 -2
  238. package/src/oauth/oauth.service.ts +194 -35
  239. package/src/oauth/providers/abstract.provider.ts +1 -1
  240. package/src/oauth/providers/facebook.provider.ts +36 -20
  241. package/src/oauth/providers/github.provider.ts +46 -23
  242. package/src/oauth/providers/google.provider.ts +36 -20
  243. package/src/oauth/providers/microsoft-entra-id.provider.ts +42 -46
  244. package/src/oauth/providers/microsoft.provider.ts +36 -21
  245. package/src/profile/profile.controller.ts +2 -2
  246. package/src/security/security.service.ts +34 -1
  247. package/src/setting/setting.service.ts +307 -9
  248. package/src/user/user.controller.ts +4 -1
  249. package/src/user/user.service.ts +20 -2
  250. package/src/webhook-integration/dto/webhook-action.dto.ts +85 -4
  251. package/src/webhook-integration/event-webhook.controller.ts +55 -50
  252. package/src/webhook-integration/event-webhook.service.ts +422 -384
  253. package/src/webhook-integration/webhook-command.registry.ts +42 -0
  254. package/src/webhook-integration/webhook-integration.controller.ts +25 -0
  255. package/src/webhook-integration/webhook-integration.module.ts +50 -45
  256. package/src/webhook-integration/webhook-integration.service.ts +444 -53
  257. package/dist/mail-profile/dto/create.dto.d.ts +0 -23
  258. package/dist/mail-profile/dto/create.dto.d.ts.map +0 -1
  259. package/dist/mail-profile/dto/create.dto.js +0 -139
  260. package/dist/mail-profile/dto/create.dto.js.map +0 -1
  261. package/dist/mail-profile/dto/update.dto.d.ts.map +0 -1
  262. package/dist/mail-profile/dto/update.dto.js.map +0 -1
  263. package/dist/mail-profile/mail-profile.controller.d.ts +0 -94
  264. package/dist/mail-profile/mail-profile.controller.d.ts.map +0 -1
  265. package/dist/mail-profile/mail-profile.controller.js +0 -95
  266. package/dist/mail-profile/mail-profile.controller.js.map +0 -1
  267. package/dist/mail-profile/mail-profile.module.d.ts +0 -3
  268. package/dist/mail-profile/mail-profile.module.d.ts.map +0 -1
  269. package/dist/mail-profile/mail-profile.module.js.map +0 -1
  270. package/dist/mail-profile/mail-profile.service.d.ts +0 -109
  271. package/dist/mail-profile/mail-profile.service.d.ts.map +0 -1
  272. package/dist/mail-profile/mail-profile.service.js +0 -278
  273. package/dist/mail-profile/mail-profile.service.js.map +0 -1
  274. package/dist/mcp/tools/core-mail-profile.mcp-tools.d.ts +0 -32
  275. package/dist/mcp/tools/core-mail-profile.mcp-tools.d.ts.map +0 -1
  276. package/dist/mcp/tools/core-mail-profile.mcp-tools.js +0 -178
  277. package/dist/mcp/tools/core-mail-profile.mcp-tools.js.map +0 -1
  278. package/hedhog/data/mail_profile.yaml +0 -18
  279. package/hedhog/table/mail_profile.yaml +0 -75
  280. package/src/mail-profile/dto/create.dto.ts +0 -145
  281. package/src/mail-profile/mail-profile.controller.ts +0 -56
  282. package/src/mail-profile/mail-profile.module.ts +0 -18
  283. package/src/mail-profile/mail-profile.service.ts +0 -308
  284. package/src/mcp/tools/core-mail-profile.mcp-tools.ts +0 -128
  285. /package/dist/{mail-profile → integration-profile}/dto/update.dto.d.ts +0 -0
  286. /package/dist/{mail-profile → integration-profile}/dto/update.dto.js +0 -0
  287. /package/src/{mail-profile → integration-profile}/dto/update.dto.ts +0 -0
@@ -1,145 +0,0 @@
1
- import { getLocaleText } from '@hed-hog/api-locale';
2
- import { Transform } from 'class-transformer';
3
- import {
4
- IsBoolean,
5
- IsEmail,
6
- IsIn,
7
- IsInt,
8
- IsOptional,
9
- IsString,
10
- MaxLength,
11
- Min,
12
- } from 'class-validator';
13
-
14
- const providerOptions = ['SMTP', 'GMAIL', 'SES'] as const;
15
-
16
- export class CreateDTO {
17
- @IsString({ message: (args) => getLocaleText('validation.stringRequired', args.value) })
18
- @MaxLength(127)
19
- @Transform(({ value }) => String(value ?? '').trim())
20
- slug: string;
21
-
22
- @IsString({ message: (args) => getLocaleText('validation.stringRequired', args.value) })
23
- @MaxLength(127)
24
- @Transform(({ value }) => String(value ?? '').trim())
25
- name: string;
26
-
27
- @IsIn(providerOptions)
28
- @Transform(({ value }) => String(value ?? '').trim().toUpperCase())
29
- provider: (typeof providerOptions)[number];
30
-
31
- @IsOptional()
32
- @IsString()
33
- @MaxLength(127)
34
- @Transform(({ value }) =>
35
- value === undefined || value === null || value === '' ? undefined : String(value).trim(),
36
- )
37
- from_name?: string;
38
-
39
- @IsEmail({}, { message: 'Invalid email address.' })
40
- @MaxLength(255)
41
- @Transform(({ value }) => String(value ?? '').trim())
42
- from_email: string;
43
-
44
- @IsOptional()
45
- @IsString()
46
- @MaxLength(127)
47
- @Transform(({ value }) =>
48
- value === undefined || value === null || value === '' ? undefined : String(value).trim(),
49
- )
50
- reply_to_name?: string;
51
-
52
- @IsOptional()
53
- @IsEmail({}, { message: 'Invalid email address.' })
54
- @MaxLength(255)
55
- @Transform(({ value }) =>
56
- value === undefined || value === null || value === '' ? undefined : String(value).trim(),
57
- )
58
- reply_to_email?: string;
59
-
60
- @IsOptional()
61
- @IsString()
62
- @MaxLength(255)
63
- @Transform(({ value }) =>
64
- value === undefined || value === null || value === '' ? undefined : String(value).trim(),
65
- )
66
- smtp_host?: string;
67
-
68
- @IsOptional()
69
- @Transform(({ value }) =>
70
- value === undefined || value === null || value === '' ? undefined : Number(value),
71
- )
72
- @IsInt()
73
- @Min(1)
74
- smtp_port?: number;
75
-
76
- @IsOptional()
77
- @Transform(({ value }) =>
78
- value === true || value === 'true' || value === 1 || value === '1',
79
- )
80
- @IsBoolean()
81
- smtp_secure?: boolean;
82
-
83
- @IsOptional()
84
- @IsString()
85
- @MaxLength(255)
86
- @Transform(({ value }) =>
87
- value === undefined || value === null || value === '' ? undefined : String(value).trim(),
88
- )
89
- smtp_username?: string;
90
-
91
- @IsOptional()
92
- @IsString()
93
- @MaxLength(255)
94
- @Transform(({ value }) =>
95
- value === undefined || value === null || value === '' ? undefined : String(value),
96
- )
97
- smtp_password?: string;
98
-
99
- @IsOptional()
100
- @IsString()
101
- @MaxLength(255)
102
- @Transform(({ value }) =>
103
- value === undefined || value === null || value === '' ? undefined : String(value).trim(),
104
- )
105
- gmail_client_id?: string;
106
-
107
- @IsOptional()
108
- @IsString()
109
- @MaxLength(255)
110
- @Transform(({ value }) =>
111
- value === undefined || value === null || value === '' ? undefined : String(value),
112
- )
113
- gmail_client_secret?: string;
114
-
115
- @IsOptional()
116
- @IsString()
117
- @Transform(({ value }) =>
118
- value === undefined || value === null || value === '' ? undefined : String(value),
119
- )
120
- gmail_refresh_token?: string;
121
-
122
- @IsOptional()
123
- @IsString()
124
- @MaxLength(255)
125
- @Transform(({ value }) =>
126
- value === undefined || value === null || value === '' ? undefined : String(value).trim(),
127
- )
128
- ses_access_key_id?: string;
129
-
130
- @IsOptional()
131
- @IsString()
132
- @MaxLength(255)
133
- @Transform(({ value }) =>
134
- value === undefined || value === null || value === '' ? undefined : String(value),
135
- )
136
- ses_secret_access_key?: string;
137
-
138
- @IsOptional()
139
- @IsString()
140
- @MaxLength(127)
141
- @Transform(({ value }) =>
142
- value === undefined || value === null || value === '' ? undefined : String(value).trim(),
143
- )
144
- ses_region?: string;
145
- }
@@ -1,56 +0,0 @@
1
- import { DeleteDTO, Role } from '@hed-hog/api';
2
- import { Pagination } from '@hed-hog/api-pagination';
3
- import {
4
- Body,
5
- Controller,
6
- Delete,
7
- Get,
8
- Inject,
9
- Param,
10
- ParseIntPipe,
11
- Patch,
12
- Post,
13
- forwardRef,
14
- } from '@nestjs/common';
15
- import { CreateDTO } from './dto/create.dto';
16
- import { UpdateDTO } from './dto/update.dto';
17
- import { MailProfileService } from './mail-profile.service';
18
-
19
- @Role()
20
- @Controller('mail-profile')
21
- export class MailProfileController {
22
- constructor(
23
- @Inject(forwardRef(() => MailProfileService))
24
- private readonly mailProfileService: MailProfileService,
25
- ) {}
26
-
27
- @Get()
28
- async list(@Pagination() paginationParams) {
29
- return this.mailProfileService.list(paginationParams);
30
- }
31
-
32
- @Get(':id')
33
- async get(@Param('id', ParseIntPipe) id: number) {
34
- return this.mailProfileService.get(id);
35
- }
36
-
37
- @Post()
38
- async create(@Body() data: CreateDTO) {
39
- return this.mailProfileService.create(data);
40
- }
41
-
42
- @Post('test')
43
- async test(@Body() data: CreateDTO) {
44
- return this.mailProfileService.test(data);
45
- }
46
-
47
- @Patch(':id')
48
- async update(@Param('id', ParseIntPipe) id: number, @Body() data: UpdateDTO) {
49
- return this.mailProfileService.update({ id, data });
50
- }
51
-
52
- @Delete()
53
- async delete(@Body() data: DeleteDTO) {
54
- return this.mailProfileService.delete(data);
55
- }
56
- }
@@ -1,18 +0,0 @@
1
- import { PaginationModule } from '@hed-hog/api-pagination';
2
- import { PrismaModule } from '@hed-hog/api-prisma';
3
- import { forwardRef, Module } from '@nestjs/common';
4
- import { MailModule } from '../mail/mail.module';
5
- import { MailProfileController } from './mail-profile.controller';
6
- import { MailProfileService } from './mail-profile.service';
7
-
8
- @Module({
9
- imports: [
10
- forwardRef(() => PrismaModule),
11
- forwardRef(() => PaginationModule),
12
- forwardRef(() => MailModule),
13
- ],
14
- controllers: [MailProfileController],
15
- providers: [MailProfileService],
16
- exports: [MailProfileService],
17
- })
18
- export class MailProfileModule {}
@@ -1,308 +0,0 @@
1
- import { DeleteDTO } from '@hed-hog/api';
2
- import { MailService as MailMainService } from '@hed-hog/api-mail';
3
- import { PaginationDTO, PaginationService } from '@hed-hog/api-pagination';
4
- import { PrismaService } from '@hed-hog/api-prisma';
5
- import {
6
- BadRequestException,
7
- Inject,
8
- Injectable,
9
- NotFoundException,
10
- forwardRef,
11
- } from '@nestjs/common';
12
- import { MailService } from '../mail/mail.service';
13
- import { CreateDTO } from './dto/create.dto';
14
- import { UpdateDTO } from './dto/update.dto';
15
-
16
- @Injectable()
17
- export class MailProfileService {
18
- constructor(
19
- @Inject(forwardRef(() => PrismaService))
20
- private readonly prismaService: PrismaService,
21
- @Inject(forwardRef(() => PaginationService))
22
- private readonly paginationService: PaginationService,
23
- @Inject(forwardRef(() => MailMainService))
24
- private readonly mailMainService: MailMainService,
25
- @Inject(forwardRef(() => MailService))
26
- private readonly mailService: MailService,
27
- ) {}
28
-
29
- async list(paginationParams: PaginationDTO) {
30
- const fields = ['slug', 'name', 'from_email', 'reply_to_email'];
31
- const OR = this.prismaService.createInsensitiveSearch(fields, paginationParams);
32
-
33
- return this.paginationService.paginate(
34
- this.prismaService.mail_profile,
35
- paginationParams,
36
- {
37
- where: OR.length > 0 ? { OR } : {},
38
- select: {
39
- id: true,
40
- slug: true,
41
- name: true,
42
- provider: true,
43
- from_name: true,
44
- from_email: true,
45
- reply_to_name: true,
46
- reply_to_email: true,
47
- created_at: true,
48
- updated_at: true,
49
- },
50
- orderBy: [{ updated_at: 'desc' }, { id: 'desc' }],
51
- },
52
- );
53
- }
54
-
55
- async get(id: number) {
56
- const profile = await this.prismaService.mail_profile.findUnique({
57
- where: { id },
58
- });
59
-
60
- if (!profile) {
61
- throw new NotFoundException(`Mail profile with id ${id} not found.`);
62
- }
63
-
64
- return profile;
65
- }
66
-
67
- async create(data: CreateDTO) {
68
- await this.ensureSlugIsAvailable(data.slug);
69
- this.validateProviderFields(data as unknown as Record<string, unknown>);
70
-
71
- return this.prismaService.mail_profile.create({
72
- data: this.normalizeData(data as unknown as Record<string, unknown>) as any,
73
- });
74
- }
75
-
76
- async update({ id, data }: { id: number; data: UpdateDTO }) {
77
- const existing = await this.prismaService.mail_profile.findUnique({
78
- where: { id },
79
- });
80
-
81
- if (!existing) {
82
- throw new NotFoundException(`Mail profile with id ${id} not found.`);
83
- }
84
-
85
- if (data.slug && data.slug !== existing.slug) {
86
- await this.ensureSlugIsAvailable(data.slug);
87
- }
88
-
89
- const merged = {
90
- ...existing,
91
- ...data,
92
- } satisfies Record<string, unknown>;
93
-
94
- this.validateProviderFields(merged);
95
-
96
- return this.prismaService.mail_profile.update({
97
- where: { id },
98
- data: this.normalizeData(merged) as any,
99
- });
100
- }
101
-
102
- async delete({ ids }: DeleteDTO): Promise<{ count: number }> {
103
- if (!ids?.length) {
104
- throw new BadRequestException('You must select at least one item to delete.');
105
- }
106
-
107
- return this.prismaService.mail_profile.deleteMany({
108
- where: {
109
- id: {
110
- in: ids,
111
- },
112
- },
113
- });
114
- }
115
-
116
- async test(data: CreateDTO) {
117
- this.validateProviderFields(data as unknown as Record<string, unknown>);
118
-
119
- const normalized = this.normalizeData(data as unknown as Record<string, unknown>);
120
- const config = this.buildMailConfig(normalized);
121
- const destinationEmail = normalized.from_email;
122
- const sender = normalized.from_name
123
- ? `${normalized.from_name} <${normalized.from_email}>`
124
- : normalized.from_email;
125
- const replyTo = normalized.reply_to_email
126
- ? normalized.reply_to_name
127
- ? `${normalized.reply_to_name} <${normalized.reply_to_email}>`
128
- : normalized.reply_to_email
129
- : undefined;
130
-
131
- try {
132
- this.mailMainService.setConfig(config);
133
-
134
- await this.mailMainService.send({
135
- to: destinationEmail,
136
- from: sender,
137
- replyTo,
138
- subject: `[HedHog] Teste do perfil ${normalized.name}`,
139
- body: `
140
- <p>Este e-mail confirma que o perfil <strong>${normalized.name}</strong> foi validado com sucesso.</p>
141
- <p><strong>Slug:</strong> ${normalized.slug}</p>
142
- <p><strong>Provedor:</strong> ${normalized.provider}</p>
143
- <p><strong>Remetente:</strong> ${sender}</p>
144
- `,
145
- });
146
-
147
- return {
148
- success: true,
149
- destination: destinationEmail,
150
- };
151
- } finally {
152
- await this.mailService.reloadConfig().catch(() => undefined);
153
- }
154
- }
155
-
156
- private async ensureSlugIsAvailable(slug: string) {
157
- const existing = await this.prismaService.mail_profile.findUnique({
158
- where: { slug },
159
- select: { id: true },
160
- });
161
-
162
- if (existing) {
163
- throw new BadRequestException(`Mail profile with slug "${slug}" already exists.`);
164
- }
165
- }
166
-
167
- private validateProviderFields(input: Record<string, unknown>) {
168
- const provider = String(input.provider ?? '').toUpperCase();
169
-
170
- if (!provider) {
171
- throw new BadRequestException('Provider is required.');
172
- }
173
-
174
- if (!String(input.from_email ?? '').trim()) {
175
- throw new BadRequestException('Sender email is required.');
176
- }
177
-
178
- switch (provider) {
179
- case 'SMTP':
180
- if (!String(input.smtp_host ?? '').trim()) {
181
- throw new BadRequestException('SMTP host is required.');
182
- }
183
- if (!input.smtp_port) {
184
- throw new BadRequestException('SMTP port is required.');
185
- }
186
- if (!String(input.smtp_username ?? '').trim()) {
187
- throw new BadRequestException('SMTP username is required.');
188
- }
189
- if (!String(input.smtp_password ?? '').trim()) {
190
- throw new BadRequestException('SMTP password is required.');
191
- }
192
- break;
193
- case 'GMAIL':
194
- if (!String(input.gmail_client_id ?? '').trim()) {
195
- throw new BadRequestException('Gmail client ID is required.');
196
- }
197
- if (!String(input.gmail_client_secret ?? '').trim()) {
198
- throw new BadRequestException('Gmail client secret is required.');
199
- }
200
- if (!String(input.gmail_refresh_token ?? '').trim()) {
201
- throw new BadRequestException('Gmail refresh token is required.');
202
- }
203
- break;
204
- case 'SES':
205
- if (!String(input.ses_access_key_id ?? '').trim()) {
206
- throw new BadRequestException('SES access key ID is required.');
207
- }
208
- if (!String(input.ses_secret_access_key ?? '').trim()) {
209
- throw new BadRequestException('SES secret access key is required.');
210
- }
211
- if (!String(input.ses_region ?? '').trim()) {
212
- throw new BadRequestException('SES region is required.');
213
- }
214
- break;
215
- default:
216
- throw new BadRequestException(`Invalid provider: ${provider}`);
217
- }
218
- }
219
-
220
- private normalizeData(input: Record<string, unknown>) {
221
- const provider = String(input.provider ?? '').toUpperCase();
222
-
223
- return {
224
- slug: this.normalizeString(input.slug),
225
- name: this.normalizeString(input.name),
226
- provider,
227
- from_name: this.normalizeNullableString(input.from_name),
228
- from_email: this.normalizeString(input.from_email),
229
- reply_to_name: this.normalizeNullableString(input.reply_to_name),
230
- reply_to_email: this.normalizeNullableString(input.reply_to_email),
231
- smtp_host: provider === 'SMTP' ? this.normalizeNullableString(input.smtp_host) : null,
232
- smtp_port:
233
- provider === 'SMTP' && input.smtp_port !== undefined && input.smtp_port !== null
234
- ? Number(input.smtp_port)
235
- : null,
236
- smtp_secure: provider === 'SMTP' ? Boolean(input.smtp_secure) : false,
237
- smtp_username:
238
- provider === 'SMTP' ? this.normalizeNullableString(input.smtp_username) : null,
239
- smtp_password:
240
- provider === 'SMTP' ? this.normalizeNullableString(input.smtp_password) : null,
241
- gmail_client_id:
242
- provider === 'GMAIL' ? this.normalizeNullableString(input.gmail_client_id) : null,
243
- gmail_client_secret:
244
- provider === 'GMAIL'
245
- ? this.normalizeNullableString(input.gmail_client_secret)
246
- : null,
247
- gmail_refresh_token:
248
- provider === 'GMAIL'
249
- ? this.normalizeNullableString(input.gmail_refresh_token)
250
- : null,
251
- ses_access_key_id:
252
- provider === 'SES' ? this.normalizeNullableString(input.ses_access_key_id) : null,
253
- ses_secret_access_key:
254
- provider === 'SES'
255
- ? this.normalizeNullableString(input.ses_secret_access_key)
256
- : null,
257
- ses_region: provider === 'SES' ? this.normalizeNullableString(input.ses_region) : null,
258
- };
259
- }
260
-
261
- private buildMailConfig(input: ReturnType<MailProfileService['normalizeData']>) {
262
- switch (input.provider) {
263
- case 'SMTP':
264
- return {
265
- global: true,
266
- type: 'SMTP' as const,
267
- host: input.smtp_host ?? '',
268
- port: input.smtp_port ?? 587,
269
- secure: input.smtp_secure,
270
- username: input.smtp_username ?? '',
271
- password: input.smtp_password ?? '',
272
- };
273
- case 'GMAIL':
274
- return {
275
- global: true,
276
- type: 'GMAIL' as const,
277
- clientId: input.gmail_client_id ?? '',
278
- clientSecret: input.gmail_client_secret ?? '',
279
- refreshToken: input.gmail_refresh_token ?? '',
280
- from: input.from_email,
281
- };
282
- case 'SES':
283
- return {
284
- global: true,
285
- type: 'SES' as const,
286
- region: input.ses_region ?? '',
287
- accessKeyId: input.ses_access_key_id ?? '',
288
- secretAccessKey: input.ses_secret_access_key ?? '',
289
- from: input.from_email,
290
- };
291
- default:
292
- throw new BadRequestException(`Invalid provider: ${input.provider}`);
293
- }
294
- }
295
-
296
- private normalizeString(value: unknown) {
297
- return String(value ?? '').trim();
298
- }
299
-
300
- private normalizeNullableString(value: unknown) {
301
- if (value === undefined || value === null) {
302
- return null;
303
- }
304
-
305
- const normalized = String(value).trim();
306
- return normalized.length > 0 ? normalized : null;
307
- }
308
- }
@@ -1,128 +0,0 @@
1
- import { Injectable } from '@nestjs/common';
2
- import { MailProfileService } from '../../mail-profile/mail-profile.service';
3
- import { McpTool } from '../decorators/mcp-tool.decorator';
4
- import { McpContext } from '../types/mcp-context.type';
5
-
6
- @Injectable()
7
- export class CoreMailProfileMcpTools {
8
- constructor(private readonly mailProfileService: MailProfileService) {}
9
-
10
- @McpTool({
11
- name: 'core.mail-profile.list',
12
- description: 'Lists mail profiles with optional pagination. Admin only.',
13
- inputSchema: {
14
- type: 'object',
15
- properties: {
16
- page: { type: 'number', description: 'Page number (default: 1)' },
17
- pageSize: { type: 'number', description: 'Items per page (default: 20)' },
18
- search: { type: 'string', description: 'Search term' },
19
- sortField: { type: 'string', description: 'Field to sort by' },
20
- sortOrder: { type: 'string', enum: ['asc', 'desc'], description: 'Sort direction' },
21
- },
22
- },
23
- readOnly: true,
24
- })
25
- async listMailProfiles(
26
- args: { page?: number; pageSize?: number; search?: string; sortField?: string; sortOrder?: string },
27
- _context: McpContext,
28
- ): Promise<any> {
29
- return this.mailProfileService.list({
30
- page: args.page ?? 1,
31
- pageSize: args.pageSize ?? 20,
32
- search: args.search ?? '',
33
- sortField: args.sortField ?? 'id',
34
- sortOrder: (args.sortOrder as any) ?? 'asc',
35
- fields: '',
36
- });
37
- }
38
-
39
- @McpTool({
40
- name: 'core.mail-profile.get',
41
- description: 'Returns a single mail profile by ID. Admin only.',
42
- inputSchema: {
43
- type: 'object',
44
- properties: {
45
- id: { type: 'number', description: 'Mail profile ID' },
46
- },
47
- required: ['id'],
48
- },
49
- readOnly: true,
50
- })
51
- async getMailProfile(args: { id: number }, _context: McpContext): Promise<any> {
52
- return this.mailProfileService.get(args.id);
53
- }
54
-
55
- @McpTool({
56
- name: 'core.mail-profile.create',
57
- description: 'Creates a new mail profile (SMTP configuration). Admin only.',
58
- inputSchema: {
59
- type: 'object',
60
- properties: {
61
- name: { type: 'string', description: 'Profile name' },
62
- host: { type: 'string', description: 'SMTP host' },
63
- port: { type: 'number', description: 'SMTP port' },
64
- username: { type: 'string', description: 'SMTP username' },
65
- password: { type: 'string', description: 'SMTP password' },
66
- },
67
- required: ['name', 'host', 'port', 'username'],
68
- },
69
- })
70
- async createMailProfile(args: { name: string; host: string; port: number; username: string; password?: string }, _context: McpContext): Promise<any> {
71
- return this.mailProfileService.create(args as any);
72
- }
73
-
74
- @McpTool({
75
- name: 'core.mail-profile.update',
76
- description: 'Updates an existing mail profile by ID. Admin only.',
77
- inputSchema: {
78
- type: 'object',
79
- properties: {
80
- id: { type: 'number', description: 'Mail profile ID' },
81
- name: { type: 'string', description: 'New profile name' },
82
- host: { type: 'string', description: 'New SMTP host' },
83
- port: { type: 'number', description: 'New SMTP port' },
84
- username: { type: 'string', description: 'New SMTP username' },
85
- password: { type: 'string', description: 'New SMTP password' },
86
- },
87
- required: ['id'],
88
- },
89
- })
90
- async updateMailProfile(args: { id: number; [key: string]: any }, _context: McpContext): Promise<any> {
91
- const { id, ...data } = args;
92
- return this.mailProfileService.update({ id, data: data as any });
93
- }
94
-
95
- @McpTool({
96
- name: 'core.mail-profile.delete',
97
- description: 'Deletes one or more mail profiles by their IDs. Admin only.',
98
- inputSchema: {
99
- type: 'object',
100
- properties: {
101
- ids: { type: 'array', items: { type: 'number' }, description: 'Mail profile IDs to delete' },
102
- },
103
- required: ['ids'],
104
- },
105
- })
106
- async deleteMailProfiles(args: { ids: number[] }, _context: McpContext): Promise<any> {
107
- return this.mailProfileService.delete({ ids: args.ids });
108
- }
109
-
110
- @McpTool({
111
- name: 'core.mail-profile.test',
112
- description: 'Tests a mail profile by sending a test message. Admin only.',
113
- inputSchema: {
114
- type: 'object',
115
- properties: {
116
- name: { type: 'string', description: 'Profile name' },
117
- host: { type: 'string', description: 'SMTP host' },
118
- port: { type: 'number', description: 'SMTP port' },
119
- username: { type: 'string', description: 'SMTP username' },
120
- password: { type: 'string', description: 'SMTP password' },
121
- },
122
- required: ['host', 'port', 'username'],
123
- },
124
- })
125
- async testMailProfile(args: Record<string, any>, _context: McpContext): Promise<any> {
126
- return this.mailProfileService.test(args as any);
127
- }
128
- }