@hed-hog/core 0.0.354 → 0.0.356

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 (167) 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/core.module.d.ts.map +1 -1
  6. package/dist/core.module.js +3 -3
  7. package/dist/core.module.js.map +1 -1
  8. package/dist/file/file.service.d.ts +1 -1
  9. package/dist/file/file.service.d.ts.map +1 -1
  10. package/dist/file/file.service.js +50 -64
  11. package/dist/file/file.service.js.map +1 -1
  12. package/dist/file/provider/provider.enum.d.ts +2 -1
  13. package/dist/file/provider/provider.enum.d.ts.map +1 -1
  14. package/dist/file/provider/provider.enum.js +1 -0
  15. package/dist/file/provider/provider.enum.js.map +1 -1
  16. package/dist/file/provider/provider.factory.d.ts.map +1 -1
  17. package/dist/file/provider/provider.factory.js +3 -0
  18. package/dist/file/provider/provider.factory.js.map +1 -1
  19. package/dist/file/provider/spaces.provider.d.ts +27 -0
  20. package/dist/file/provider/spaces.provider.d.ts.map +1 -0
  21. package/dist/file/provider/spaces.provider.js +218 -0
  22. package/dist/file/provider/spaces.provider.js.map +1 -0
  23. package/dist/index.d.ts +4 -3
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +4 -3
  26. package/dist/index.js.map +1 -1
  27. package/dist/integration-profile/dto/create.dto.d.ts +9 -0
  28. package/dist/integration-profile/dto/create.dto.d.ts.map +1 -0
  29. package/dist/integration-profile/dto/create.dto.js +54 -0
  30. package/dist/integration-profile/dto/create.dto.js.map +1 -0
  31. package/dist/integration-profile/dto/export.dto.d.ts +5 -0
  32. package/dist/integration-profile/dto/export.dto.d.ts.map +1 -0
  33. package/dist/integration-profile/dto/export.dto.js +29 -0
  34. package/dist/integration-profile/dto/export.dto.js.map +1 -0
  35. package/dist/integration-profile/dto/import-confirm.dto.d.ts +17 -0
  36. package/dist/integration-profile/dto/import-confirm.dto.d.ts.map +1 -0
  37. package/dist/integration-profile/dto/import-confirm.dto.js +77 -0
  38. package/dist/integration-profile/dto/import-confirm.dto.js.map +1 -0
  39. package/dist/integration-profile/dto/update.dto.d.ts +6 -0
  40. package/dist/integration-profile/dto/update.dto.d.ts.map +1 -0
  41. package/dist/integration-profile/dto/update.dto.js +9 -0
  42. package/dist/integration-profile/dto/update.dto.js.map +1 -0
  43. package/dist/integration-profile/integration-profile.controller.d.ts +142 -0
  44. package/dist/integration-profile/integration-profile.controller.d.ts.map +1 -0
  45. package/dist/integration-profile/integration-profile.controller.js +165 -0
  46. package/dist/integration-profile/integration-profile.controller.js.map +1 -0
  47. package/dist/integration-profile/integration-profile.module.d.ts +3 -0
  48. package/dist/integration-profile/integration-profile.module.d.ts.map +1 -0
  49. package/dist/integration-profile/integration-profile.module.js +29 -0
  50. package/dist/integration-profile/integration-profile.module.js.map +1 -0
  51. package/dist/integration-profile/integration-profile.service.d.ts +160 -0
  52. package/dist/integration-profile/integration-profile.service.d.ts.map +1 -0
  53. package/dist/integration-profile/integration-profile.service.js +606 -0
  54. package/dist/integration-profile/integration-profile.service.js.map +1 -0
  55. package/dist/integration-profile/integration-profile.utils.d.ts +24 -0
  56. package/dist/integration-profile/integration-profile.utils.d.ts.map +1 -0
  57. package/dist/integration-profile/integration-profile.utils.js +147 -0
  58. package/dist/integration-profile/integration-profile.utils.js.map +1 -0
  59. package/dist/mail/mail.module.d.ts.map +1 -1
  60. package/dist/mail/mail.module.js +27 -19
  61. package/dist/mail/mail.module.js.map +1 -1
  62. package/dist/mail/mail.service.d.ts +3 -2
  63. package/dist/mail/mail.service.d.ts.map +1 -1
  64. package/dist/mail/mail.service.js +25 -47
  65. package/dist/mail/mail.service.js.map +1 -1
  66. package/dist/mcp/mcp.module.js +2 -2
  67. package/dist/mcp/mcp.module.js.map +1 -1
  68. package/dist/mcp/tools/core-mail-profile.mcp-tools.d.ts +3 -15
  69. package/dist/mcp/tools/core-mail-profile.mcp-tools.d.ts.map +1 -1
  70. package/dist/mcp/tools/core-mail-profile.mcp-tools.js +12 -94
  71. package/dist/mcp/tools/core-mail-profile.mcp-tools.js.map +1 -1
  72. package/dist/mcp-chat/mcp-chat.service.d.ts.map +1 -1
  73. package/dist/mcp-chat/mcp-chat.service.js +17 -16
  74. package/dist/mcp-chat/mcp-chat.service.js.map +1 -1
  75. package/dist/setting/setting.service.d.ts.map +1 -1
  76. package/dist/setting/setting.service.js +0 -2
  77. package/dist/setting/setting.service.js.map +1 -1
  78. package/dist/webhook-integration/event-webhook.controller.d.ts +1 -0
  79. package/dist/webhook-integration/event-webhook.controller.d.ts.map +1 -1
  80. package/dist/webhook-integration/event-webhook.controller.js +10 -0
  81. package/dist/webhook-integration/event-webhook.controller.js.map +1 -1
  82. package/dist/webhook-integration/event-webhook.service.d.ts +2 -0
  83. package/dist/webhook-integration/event-webhook.service.d.ts.map +1 -1
  84. package/dist/webhook-integration/event-webhook.service.js +30 -0
  85. package/dist/webhook-integration/event-webhook.service.js.map +1 -1
  86. package/dist/webhook-integration/webhook-integration.controller.d.ts +1 -0
  87. package/dist/webhook-integration/webhook-integration.controller.d.ts.map +1 -1
  88. package/dist/webhook-integration/webhook-integration.controller.js +10 -0
  89. package/dist/webhook-integration/webhook-integration.controller.js.map +1 -1
  90. package/dist/webhook-integration/webhook-integration.service.d.ts +2 -1
  91. package/dist/webhook-integration/webhook-integration.service.d.ts.map +1 -1
  92. package/dist/webhook-integration/webhook-integration.service.js +62 -44
  93. package/dist/webhook-integration/webhook-integration.service.js.map +1 -1
  94. package/dist/whatsapp-profile/dto/create.dto.d.ts +11 -0
  95. package/dist/whatsapp-profile/dto/create.dto.d.ts.map +1 -0
  96. package/dist/whatsapp-profile/dto/create.dto.js +55 -0
  97. package/dist/whatsapp-profile/dto/create.dto.js.map +1 -0
  98. package/dist/whatsapp-profile/dto/update.dto.d.ts +6 -0
  99. package/dist/whatsapp-profile/dto/update.dto.d.ts.map +1 -0
  100. package/dist/whatsapp-profile/dto/update.dto.js +9 -0
  101. package/dist/whatsapp-profile/dto/update.dto.js.map +1 -0
  102. package/dist/whatsapp-profile/whatsapp-profile.controller.d.ts +54 -0
  103. package/dist/whatsapp-profile/whatsapp-profile.controller.d.ts.map +1 -0
  104. package/dist/whatsapp-profile/whatsapp-profile.controller.js +85 -0
  105. package/dist/whatsapp-profile/whatsapp-profile.controller.js.map +1 -0
  106. package/dist/whatsapp-profile/whatsapp-profile.module.d.ts +3 -0
  107. package/dist/whatsapp-profile/whatsapp-profile.module.d.ts.map +1 -0
  108. package/dist/whatsapp-profile/whatsapp-profile.module.js +26 -0
  109. package/dist/whatsapp-profile/whatsapp-profile.module.js.map +1 -0
  110. package/dist/whatsapp-profile/whatsapp-profile.service.d.ts +63 -0
  111. package/dist/whatsapp-profile/whatsapp-profile.service.d.ts.map +1 -0
  112. package/dist/whatsapp-profile/whatsapp-profile.service.js +138 -0
  113. package/dist/whatsapp-profile/whatsapp-profile.service.js.map +1 -0
  114. package/hedhog/data/file_provider.yaml +9 -1
  115. package/hedhog/data/integration_provider.yaml +132 -0
  116. package/hedhog/data/integration_type.yaml +29 -0
  117. package/hedhog/data/menu.yaml +15 -14
  118. package/hedhog/data/role.yaml +8 -0
  119. package/hedhog/data/route.yaml +66 -15
  120. package/hedhog/data/setting_group.yaml +30 -191
  121. package/hedhog/data/setting_subgroup.yaml +5 -13
  122. package/hedhog/data/whatsapp_profile.yaml +6 -0
  123. package/hedhog/frontend/app/account/components/connected-accounts.tsx.ejs +25 -20
  124. package/hedhog/frontend/app/configurations/[slug]/components/setting-field.tsx.ejs +579 -204
  125. package/hedhog/frontend/app/integration/profiles/page.tsx.ejs +1662 -0
  126. package/hedhog/frontend/app/integrations-webhooks/page.tsx.ejs +233 -108
  127. package/hedhog/frontend/app/mail/profiles/page.tsx.ejs +3 -822
  128. package/hedhog/frontend/app/users/permissions.tsx.ejs +79 -2
  129. package/hedhog/frontend/app/users/user-sheet.tsx.ejs +7 -2
  130. package/hedhog/frontend/messages/en.json +172 -0
  131. package/hedhog/frontend/messages/pt.json +172 -0
  132. package/hedhog/table/integration_profile.yaml +34 -0
  133. package/hedhog/table/integration_provider.yaml +23 -0
  134. package/hedhog/table/integration_type.yaml +19 -0
  135. package/hedhog/table/webhook_action.yaml +85 -85
  136. package/hedhog/table/whatsapp_profile.yaml +26 -0
  137. package/package.json +2 -2
  138. package/src/ai/ai.service.ts +35 -153
  139. package/src/core.module.ts +3 -3
  140. package/src/file/file.service.ts +60 -76
  141. package/src/file/provider/provider.enum.ts +1 -0
  142. package/src/file/provider/provider.factory.ts +3 -0
  143. package/src/file/provider/spaces.provider.ts +261 -0
  144. package/src/index.ts +6 -3
  145. package/src/integration-profile/dto/create.dto.ts +44 -0
  146. package/src/integration-profile/dto/export.dto.ts +15 -0
  147. package/src/integration-profile/dto/import-confirm.dto.ts +61 -0
  148. package/src/integration-profile/dto/update.dto.ts +4 -0
  149. package/src/integration-profile/integration-profile.controller.ts +129 -0
  150. package/src/integration-profile/integration-profile.module.ts +16 -0
  151. package/src/integration-profile/integration-profile.service.ts +788 -0
  152. package/src/integration-profile/integration-profile.utils.ts +156 -0
  153. package/src/mail/mail.module.ts +27 -18
  154. package/src/mail/mail.service.ts +31 -60
  155. package/src/mcp/mcp.module.ts +2 -2
  156. package/src/mcp/tools/core-mail-profile.mcp-tools.ts +10 -69
  157. package/src/mcp-chat/mcp-chat.service.ts +23 -20
  158. package/src/setting/setting.service.ts +0 -2
  159. package/src/webhook-integration/event-webhook.controller.ts +55 -50
  160. package/src/webhook-integration/event-webhook.service.ts +422 -384
  161. package/src/webhook-integration/webhook-integration.controller.ts +5 -0
  162. package/src/webhook-integration/webhook-integration.service.ts +74 -46
  163. package/src/whatsapp-profile/dto/create.dto.ts +36 -0
  164. package/src/whatsapp-profile/dto/update.dto.ts +4 -0
  165. package/src/whatsapp-profile/whatsapp-profile.controller.ts +51 -0
  166. package/src/whatsapp-profile/whatsapp-profile.module.ts +13 -0
  167. package/src/whatsapp-profile/whatsapp-profile.service.ts +160 -0
@@ -74,6 +74,7 @@ import {
74
74
  BookOpenText,
75
75
  ChevronRight,
76
76
  Clock3,
77
+ Copy,
77
78
  GripVertical,
78
79
  Pencil,
79
80
  Plus,
@@ -225,22 +226,32 @@ type MailProfileDetail = {
225
226
  id: number;
226
227
  slug: string;
227
228
  name: string;
228
- provider: MailProfileProvider;
229
- from_name?: string | null;
230
- from_email: string;
231
- reply_to_name?: string | null;
232
- reply_to_email?: string | null;
233
- smtp_host?: string | null;
234
- smtp_port?: number | null;
235
- smtp_secure?: boolean;
236
- smtp_username?: string | null;
237
- smtp_password?: string | null;
238
- gmail_client_id?: string | null;
239
- gmail_client_secret?: string | null;
240
- gmail_refresh_token?: string | null;
241
- ses_access_key_id?: string | null;
242
- ses_secret_access_key?: string | null;
243
- ses_region?: string | null;
229
+ type_id: number;
230
+ provider_id: number;
231
+ config?: Record<string, unknown> | null;
232
+ integration_provider?: {
233
+ slug?: string | null;
234
+ };
235
+ };
236
+
237
+ type IntegrationProvider = {
238
+ id: number;
239
+ slug: string;
240
+ type_id: number;
241
+ };
242
+
243
+ const EMAIL_TYPE_SLUG = 'email';
244
+
245
+ const MAIL_PROVIDER_SLUG_BY_LABEL: Record<MailProfileProvider, string> = {
246
+ SMTP: 'smtp',
247
+ GMAIL: 'gmail',
248
+ SES: 'ses',
249
+ };
250
+
251
+ const MAIL_PROVIDER_LABEL_BY_SLUG: Record<string, MailProfileProvider> = {
252
+ smtp: 'SMTP',
253
+ gmail: 'GMAIL',
254
+ ses: 'SES',
244
255
  };
245
256
 
246
257
  type MailTemplateDetail = {
@@ -274,6 +285,51 @@ const defaultMailProfileEditForm = {
274
285
  ses_region: '',
275
286
  };
276
287
 
288
+ function trimString(value: unknown) {
289
+ return String(value ?? '').trim();
290
+ }
291
+
292
+ function buildMailConfigFromForm(
293
+ providerSlug: string,
294
+ form: typeof defaultMailProfileEditForm
295
+ ) {
296
+ if (providerSlug === 'smtp') {
297
+ return {
298
+ host: trimString(form.smtp_host),
299
+ port: Number(trimString(form.smtp_port) || 587),
300
+ username: trimString(form.smtp_username),
301
+ password: trimString(form.smtp_password),
302
+ secure: Boolean(form.smtp_secure),
303
+ from_email: trimString(form.from_email),
304
+ from_name: trimString(form.from_name),
305
+ reply_to_email: trimString(form.reply_to_email),
306
+ reply_to_name: trimString(form.reply_to_name),
307
+ };
308
+ }
309
+
310
+ if (providerSlug === 'gmail') {
311
+ return {
312
+ client_id: trimString(form.gmail_client_id),
313
+ client_secret: trimString(form.gmail_client_secret),
314
+ refresh_token: trimString(form.gmail_refresh_token),
315
+ from_email: trimString(form.from_email),
316
+ from_name: trimString(form.from_name),
317
+ reply_to_email: trimString(form.reply_to_email),
318
+ reply_to_name: trimString(form.reply_to_name),
319
+ };
320
+ }
321
+
322
+ return {
323
+ access_key_id: trimString(form.ses_access_key_id),
324
+ secret_access_key: trimString(form.ses_secret_access_key),
325
+ region: trimString(form.ses_region),
326
+ from_email: trimString(form.from_email),
327
+ from_name: trimString(form.from_name),
328
+ reply_to_email: trimString(form.reply_to_email),
329
+ reply_to_name: trimString(form.reply_to_name),
330
+ };
331
+ }
332
+
277
333
  const defaultMailTemplateEditForm = {
278
334
  slug: '',
279
335
  locale_code: 'en',
@@ -495,15 +551,44 @@ export default function IntegrationsWebhooksPage() {
495
551
  >({
496
552
  queryKey: ['webhook-mail-profiles', currentLocaleCode],
497
553
  queryFn: async () => {
498
- const response = await request<{ data: SelectOption[] }>({
499
- url: '/mail-profile?pageSize=100',
554
+ const response = await request<{
555
+ data: Array<{
556
+ id: number;
557
+ slug: string;
558
+ name: string;
559
+ integration_provider?: { slug?: string | null };
560
+ }>;
561
+ }>({
562
+ url: '/integration-profile?pageSize=100&typeSlug=email',
500
563
  method: 'GET',
501
564
  });
502
- return response.data.data || [];
565
+ return (response.data.data || []).map((item) => ({
566
+ id: item.id,
567
+ slug: item.slug,
568
+ name: item.name,
569
+ provider: String(item.integration_provider?.slug ?? ''),
570
+ }));
503
571
  },
504
572
  placeholderData: (previous) => previous ?? [],
505
573
  });
506
574
 
575
+ const resolveEmailProviderMeta = async (providerSlug: string) => {
576
+ const response = await request<IntegrationProvider[]>({
577
+ url: `/integration-profile/providers?typeSlug=${EMAIL_TYPE_SLUG}`,
578
+ method: 'GET',
579
+ });
580
+
581
+ const provider = (response.data ?? []).find(
582
+ (item) => item.slug === providerSlug
583
+ );
584
+
585
+ if (!provider) {
586
+ throw new Error(`Integration provider "${providerSlug}" not found.`);
587
+ }
588
+
589
+ return provider;
590
+ };
591
+
507
592
  const { data: mailTemplates = [], refetch: refetchMailTemplates } = useQuery<
508
593
  SelectOption[]
509
594
  >({
@@ -797,31 +882,33 @@ export default function IntegrationsWebhooksPage() {
797
882
  const openMailProfileEditor = async (id: number) => {
798
883
  try {
799
884
  const response = await request<MailProfileDetail>({
800
- url: `/mail-profile/${id}`,
885
+ url: `/integration-profile/${id}`,
801
886
  method: 'GET',
802
887
  });
803
888
 
804
889
  const data = response.data;
890
+ const config = (data.config as Record<string, unknown> | null) ?? {};
891
+ const providerSlug = String(data.integration_provider?.slug ?? 'smtp');
805
892
  setMailProfileEditId(data.id);
806
893
  setMailProfileEditForm({
807
894
  slug: data.slug || '',
808
895
  name: data.name || '',
809
- provider: data.provider || 'SMTP',
810
- from_name: data.from_name || '',
811
- from_email: data.from_email || '',
812
- reply_to_name: data.reply_to_name || '',
813
- reply_to_email: data.reply_to_email || '',
814
- smtp_host: data.smtp_host || '',
815
- smtp_port: data.smtp_port ? String(data.smtp_port) : '587',
816
- smtp_secure: Boolean(data.smtp_secure),
817
- smtp_username: data.smtp_username || '',
818
- smtp_password: data.smtp_password || '',
819
- gmail_client_id: data.gmail_client_id || '',
820
- gmail_client_secret: data.gmail_client_secret || '',
821
- gmail_refresh_token: data.gmail_refresh_token || '',
822
- ses_access_key_id: data.ses_access_key_id || '',
823
- ses_secret_access_key: data.ses_secret_access_key || '',
824
- ses_region: data.ses_region || '',
896
+ provider: MAIL_PROVIDER_LABEL_BY_SLUG[providerSlug] || 'SMTP',
897
+ from_name: String(config.from_name ?? ''),
898
+ from_email: String(config.from_email ?? ''),
899
+ reply_to_name: String(config.reply_to_name ?? ''),
900
+ reply_to_email: String(config.reply_to_email ?? ''),
901
+ smtp_host: String(config.host ?? ''),
902
+ smtp_port: String(config.port ?? '587'),
903
+ smtp_secure: Boolean(config.secure),
904
+ smtp_username: String(config.username ?? ''),
905
+ smtp_password: String(config.password ?? ''),
906
+ gmail_client_id: String(config.client_id ?? ''),
907
+ gmail_client_secret: String(config.client_secret ?? ''),
908
+ gmail_refresh_token: String(config.refresh_token ?? ''),
909
+ ses_access_key_id: String(config.access_key_id ?? ''),
910
+ ses_secret_access_key: String(config.secret_access_key ?? ''),
911
+ ses_region: String(config.region ?? ''),
825
912
  });
826
913
  setMailProfileTestedSignature(null);
827
914
  setMailProfileEditorOpen(true);
@@ -830,50 +917,39 @@ export default function IntegrationsWebhooksPage() {
830
917
  }
831
918
  };
832
919
 
833
- const createMailProfilePayload = () => ({
834
- slug: mailProfileEditForm.slug,
835
- name: mailProfileEditForm.name,
836
- provider: mailProfileEditForm.provider,
837
- from_name: mailProfileEditForm.from_name || undefined,
838
- from_email: mailProfileEditForm.from_email,
839
- reply_to_name: mailProfileEditForm.reply_to_name || undefined,
840
- reply_to_email: mailProfileEditForm.reply_to_email || undefined,
841
- smtp_host: mailProfileEditForm.smtp_host || undefined,
842
- smtp_port: mailProfileEditForm.smtp_port
843
- ? Number(mailProfileEditForm.smtp_port)
844
- : undefined,
845
- smtp_secure: mailProfileEditForm.smtp_secure,
846
- smtp_username: mailProfileEditForm.smtp_username || undefined,
847
- smtp_password: mailProfileEditForm.smtp_password || undefined,
848
- gmail_client_id: mailProfileEditForm.gmail_client_id || undefined,
849
- gmail_client_secret: mailProfileEditForm.gmail_client_secret || undefined,
850
- gmail_refresh_token: mailProfileEditForm.gmail_refresh_token || undefined,
851
- ses_access_key_id: mailProfileEditForm.ses_access_key_id || undefined,
852
- ses_secret_access_key:
853
- mailProfileEditForm.ses_secret_access_key || undefined,
854
- ses_region: mailProfileEditForm.ses_region || undefined,
855
- });
920
+ const createMailProfilePayload = async () => {
921
+ const providerSlug =
922
+ MAIL_PROVIDER_SLUG_BY_LABEL[mailProfileEditForm.provider] ?? 'smtp';
923
+ const provider = await resolveEmailProviderMeta(providerSlug);
924
+
925
+ return {
926
+ slug: trimString(mailProfileEditForm.slug),
927
+ name: trimString(mailProfileEditForm.name),
928
+ type_id: provider.type_id,
929
+ provider_id: provider.id,
930
+ config: buildMailConfigFromForm(providerSlug, mailProfileEditForm),
931
+ is_active: true,
932
+ };
933
+ };
856
934
 
857
- const currentMailProfileSignature = JSON.stringify(
858
- createMailProfilePayload()
859
- );
935
+ const currentMailProfileSignature = JSON.stringify(mailProfileEditForm);
860
936
  const canSubmitMailProfile =
861
937
  mailProfileTestedSignature === currentMailProfileSignature;
862
938
 
863
939
  const handleTestMailProfile = async () => {
864
- const payload = createMailProfilePayload();
940
+ const payload = await createMailProfilePayload();
865
941
 
866
942
  try {
867
943
  setMailProfileIsTesting(true);
868
944
  const { data } = await request<{ success: boolean; destination: string }>(
869
945
  {
870
- url: '/mail-profile/test',
946
+ url: '/integration-profile/test',
871
947
  method: 'POST',
872
948
  data: payload,
873
949
  }
874
950
  );
875
951
 
876
- setMailProfileTestedSignature(JSON.stringify(payload));
952
+ setMailProfileTestedSignature(currentMailProfileSignature);
877
953
  toast.success(
878
954
  data.destination || payload.from_email
879
955
  ? `Perfil testado com sucesso para ${data.destination || payload.from_email}`
@@ -890,36 +966,13 @@ export default function IntegrationsWebhooksPage() {
890
966
 
891
967
  const saveMailProfileEditor = async () => {
892
968
  if (!mailProfileEditId) return;
969
+ const payload = await createMailProfilePayload();
893
970
 
894
971
  try {
895
972
  await request({
896
- url: `/mail-profile/${mailProfileEditId}`,
973
+ url: `/integration-profile/${mailProfileEditId}`,
897
974
  method: 'PATCH',
898
- data: {
899
- slug: mailProfileEditForm.slug,
900
- name: mailProfileEditForm.name,
901
- provider: mailProfileEditForm.provider,
902
- from_name: mailProfileEditForm.from_name || undefined,
903
- from_email: mailProfileEditForm.from_email,
904
- reply_to_name: mailProfileEditForm.reply_to_name || undefined,
905
- reply_to_email: mailProfileEditForm.reply_to_email || undefined,
906
- smtp_host: mailProfileEditForm.smtp_host || undefined,
907
- smtp_port: mailProfileEditForm.smtp_port
908
- ? Number(mailProfileEditForm.smtp_port)
909
- : undefined,
910
- smtp_secure: mailProfileEditForm.smtp_secure,
911
- smtp_username: mailProfileEditForm.smtp_username || undefined,
912
- smtp_password: mailProfileEditForm.smtp_password || undefined,
913
- gmail_client_id: mailProfileEditForm.gmail_client_id || undefined,
914
- gmail_client_secret:
915
- mailProfileEditForm.gmail_client_secret || undefined,
916
- gmail_refresh_token:
917
- mailProfileEditForm.gmail_refresh_token || undefined,
918
- ses_access_key_id: mailProfileEditForm.ses_access_key_id || undefined,
919
- ses_secret_access_key:
920
- mailProfileEditForm.ses_secret_access_key || undefined,
921
- ses_region: mailProfileEditForm.ses_region || undefined,
922
- },
975
+ data: payload,
923
976
  });
924
977
 
925
978
  await refetchMailProfiles();
@@ -1221,6 +1274,16 @@ export default function IntegrationsWebhooksPage() {
1221
1274
  await incoming.refetch();
1222
1275
  };
1223
1276
 
1277
+ const duplicateIncoming = async (item: IncomingIntegration) => {
1278
+ const response = await request<IncomingIntegration>({
1279
+ url: `/webhook-integration/${item.id}/duplicate`,
1280
+ method: 'POST',
1281
+ });
1282
+ toast.success(t('duplicated'));
1283
+ await incoming.refetch();
1284
+ await openIncomingEdit(response.data);
1285
+ };
1286
+
1224
1287
  const openEventWebhookCreate = () => {
1225
1288
  setEventWebhookEdit(null);
1226
1289
  setEventWebhookForm(defaultEventWebhookForm);
@@ -1255,6 +1318,16 @@ export default function IntegrationsWebhooksPage() {
1255
1318
  setEventWebhookOpen(true);
1256
1319
  };
1257
1320
 
1321
+ const duplicateEventWebhook = async (item: EventWebhook) => {
1322
+ const response = await request<EventWebhook>({
1323
+ url: `/event-webhook/${item.id}/duplicate`,
1324
+ method: 'POST',
1325
+ });
1326
+ toast.success(t('duplicated'));
1327
+ await eventWebhooks.refetch();
1328
+ await openEventWebhookEdit(response.data);
1329
+ };
1330
+
1258
1331
  const saveEventWebhook = async () => {
1259
1332
  try {
1260
1333
  const payload = {
@@ -1563,6 +1636,13 @@ export default function IntegrationsWebhooksPage() {
1563
1636
  >
1564
1637
  <Pencil className="h-4 w-4" />
1565
1638
  </Button>
1639
+ <Button
1640
+ variant="ghost"
1641
+ size="icon"
1642
+ onClick={() => duplicateIncoming(item)}
1643
+ >
1644
+ <Copy className="h-4 w-4" />
1645
+ </Button>
1566
1646
  <Button
1567
1647
  variant="ghost"
1568
1648
  size="icon"
@@ -1672,6 +1752,13 @@ export default function IntegrationsWebhooksPage() {
1672
1752
  >
1673
1753
  <Pencil className="h-4 w-4" />
1674
1754
  </Button>
1755
+ <Button
1756
+ variant="ghost"
1757
+ size="icon"
1758
+ onClick={() => duplicateEventWebhook(item)}
1759
+ >
1760
+ <Copy className="h-4 w-4" />
1761
+ </Button>
1675
1762
  <Button
1676
1763
  variant="ghost"
1677
1764
  size="icon"
@@ -1707,7 +1794,10 @@ export default function IntegrationsWebhooksPage() {
1707
1794
  </Tabs>
1708
1795
 
1709
1796
  <Sheet open={catalogOpen} onOpenChange={setCatalogOpen}>
1710
- <ResizableSheetContent sheetId="webhooks-catalog-form" defaultWidth={672}>
1797
+ <ResizableSheetContent
1798
+ sheetId="webhooks-catalog-form"
1799
+ defaultWidth={672}
1800
+ >
1711
1801
  <SheetHeader>
1712
1802
  <SheetTitle>
1713
1803
  {catalogEdit ? t('editEvent') : t('newEvent')}
@@ -1782,7 +1872,10 @@ export default function IntegrationsWebhooksPage() {
1782
1872
  }
1783
1873
  }}
1784
1874
  >
1785
- <ResizableSheetContent sheetId="webhooks-incoming-form" defaultWidth={1024}>
1875
+ <ResizableSheetContent
1876
+ sheetId="webhooks-incoming-form"
1877
+ defaultWidth={1024}
1878
+ >
1786
1879
  <SheetHeader>
1787
1880
  <SheetTitle>
1788
1881
  {incomingEdit ? t('editIncoming') : t('newIncoming')}
@@ -2272,7 +2365,10 @@ export default function IntegrationsWebhooksPage() {
2272
2365
  }
2273
2366
  }}
2274
2367
  >
2275
- <ResizableSheetContent sheetId="webhooks-action-form" defaultWidth={768}>
2368
+ <ResizableSheetContent
2369
+ sheetId="webhooks-action-form"
2370
+ defaultWidth={768}
2371
+ >
2276
2372
  <SheetHeader>
2277
2373
  <SheetTitle>
2278
2374
  {actionEdit ? t('updated') : t('addAction')}
@@ -2337,14 +2433,28 @@ export default function IntegrationsWebhooksPage() {
2337
2433
  options={mailProfiles}
2338
2434
  loadOptions={async ({ page, pageSize, search }) => {
2339
2435
  const response = await request<{
2340
- data: SelectOption[];
2436
+ data: Array<{
2437
+ id: number;
2438
+ slug: string;
2439
+ name: string;
2440
+ integration_provider?: { slug?: string | null };
2441
+ }>;
2341
2442
  }>({
2342
- url: `/mail-profile?page=${page}&pageSize=${pageSize}&search=${encodeURIComponent(search)}`,
2443
+ url: `/integration-profile?page=${page}&pageSize=${pageSize}&typeSlug=email&search=${encodeURIComponent(search)}`,
2343
2444
  method: 'GET',
2344
2445
  });
2345
2446
 
2346
2447
  return {
2347
- items: response.data?.data || [],
2448
+ items: (response.data?.data || []).map(
2449
+ (item) => ({
2450
+ id: item.id,
2451
+ slug: item.slug,
2452
+ name: item.name,
2453
+ provider: String(
2454
+ item.integration_provider?.slug ?? ''
2455
+ ),
2456
+ })
2457
+ ),
2348
2458
  hasMore: false,
2349
2459
  };
2350
2460
  }}
@@ -2399,19 +2509,25 @@ export default function IntegrationsWebhooksPage() {
2399
2509
  createTitle="Criar perfil de e-mail"
2400
2510
  createDescription="Crie rapidamente um perfil SMTP para usar nesta ação."
2401
2511
  onCreate={async (values) => {
2512
+ const provider =
2513
+ await resolveEmailProviderMeta('smtp');
2402
2514
  const response = await request<SelectOption>({
2403
- url: '/mail-profile',
2515
+ url: '/integration-profile',
2404
2516
  method: 'POST',
2405
2517
  data: {
2406
2518
  slug: values.slug,
2407
2519
  name: values.name,
2408
- provider: 'SMTP',
2409
- from_email: values.from_email,
2410
- smtp_host: values.smtp_host,
2411
- smtp_port: Number(values.smtp_port || 587),
2412
- smtp_secure: false,
2413
- smtp_username: values.smtp_username,
2414
- smtp_password: values.smtp_password,
2520
+ type_id: provider.type_id,
2521
+ provider_id: provider.id,
2522
+ config: {
2523
+ from_email: values.from_email,
2524
+ host: values.smtp_host,
2525
+ port: Number(values.smtp_port || 587),
2526
+ secure: false,
2527
+ username: values.smtp_username,
2528
+ password: values.smtp_password,
2529
+ },
2530
+ is_active: true,
2415
2531
  },
2416
2532
  });
2417
2533
 
@@ -2662,7 +2778,10 @@ export default function IntegrationsWebhooksPage() {
2662
2778
  </Sheet>
2663
2779
 
2664
2780
  <Sheet open={eventWebhookOpen} onOpenChange={setEventWebhookOpen}>
2665
- <ResizableSheetContent sheetId="webhooks-event-webhook-form" defaultWidth={1024}>
2781
+ <ResizableSheetContent
2782
+ sheetId="webhooks-event-webhook-form"
2783
+ defaultWidth={1024}
2784
+ >
2666
2785
  <SheetHeader>
2667
2786
  <SheetTitle>
2668
2787
  {eventWebhookEdit ? t('editEventWebhook') : t('newEventWebhook')}
@@ -2856,7 +2975,10 @@ export default function IntegrationsWebhooksPage() {
2856
2975
  }
2857
2976
  }}
2858
2977
  >
2859
- <ResizableSheetContent sheetId="webhooks-mail-profile-editor" defaultWidth={896}>
2978
+ <ResizableSheetContent
2979
+ sheetId="webhooks-mail-profile-editor"
2980
+ defaultWidth={896}
2981
+ >
2860
2982
  <SheetHeader>
2861
2983
  <SheetTitle>Editar perfil de e-mail</SheetTitle>
2862
2984
  <SheetDescription>
@@ -3140,7 +3262,10 @@ export default function IntegrationsWebhooksPage() {
3140
3262
  }
3141
3263
  }}
3142
3264
  >
3143
- <ResizableSheetContent sheetId="webhooks-mail-template-editor" defaultWidth={896}>
3265
+ <ResizableSheetContent
3266
+ sheetId="webhooks-mail-template-editor"
3267
+ defaultWidth={896}
3268
+ >
3144
3269
  <SheetHeader>
3145
3270
  <SheetTitle>Editar template de e-mail</SheetTitle>
3146
3271
  <SheetDescription>