@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.
- package/dist/ai/ai.service.d.ts +3 -12
- package/dist/ai/ai.service.d.ts.map +1 -1
- package/dist/ai/ai.service.js +34 -125
- package/dist/ai/ai.service.js.map +1 -1
- package/dist/core.module.d.ts.map +1 -1
- package/dist/core.module.js +3 -3
- package/dist/core.module.js.map +1 -1
- package/dist/file/file.service.d.ts +1 -1
- package/dist/file/file.service.d.ts.map +1 -1
- package/dist/file/file.service.js +50 -64
- package/dist/file/file.service.js.map +1 -1
- package/dist/file/provider/provider.enum.d.ts +2 -1
- package/dist/file/provider/provider.enum.d.ts.map +1 -1
- package/dist/file/provider/provider.enum.js +1 -0
- package/dist/file/provider/provider.enum.js.map +1 -1
- package/dist/file/provider/provider.factory.d.ts.map +1 -1
- package/dist/file/provider/provider.factory.js +3 -0
- package/dist/file/provider/provider.factory.js.map +1 -1
- package/dist/file/provider/spaces.provider.d.ts +27 -0
- package/dist/file/provider/spaces.provider.d.ts.map +1 -0
- package/dist/file/provider/spaces.provider.js +218 -0
- package/dist/file/provider/spaces.provider.js.map +1 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/integration-profile/dto/create.dto.d.ts +9 -0
- package/dist/integration-profile/dto/create.dto.d.ts.map +1 -0
- package/dist/integration-profile/dto/create.dto.js +54 -0
- package/dist/integration-profile/dto/create.dto.js.map +1 -0
- package/dist/integration-profile/dto/export.dto.d.ts +5 -0
- package/dist/integration-profile/dto/export.dto.d.ts.map +1 -0
- package/dist/integration-profile/dto/export.dto.js +29 -0
- package/dist/integration-profile/dto/export.dto.js.map +1 -0
- package/dist/integration-profile/dto/import-confirm.dto.d.ts +17 -0
- package/dist/integration-profile/dto/import-confirm.dto.d.ts.map +1 -0
- package/dist/integration-profile/dto/import-confirm.dto.js +77 -0
- package/dist/integration-profile/dto/import-confirm.dto.js.map +1 -0
- package/dist/integration-profile/dto/update.dto.d.ts +6 -0
- package/dist/integration-profile/dto/update.dto.d.ts.map +1 -0
- package/dist/integration-profile/dto/update.dto.js +9 -0
- package/dist/integration-profile/dto/update.dto.js.map +1 -0
- package/dist/integration-profile/integration-profile.controller.d.ts +142 -0
- package/dist/integration-profile/integration-profile.controller.d.ts.map +1 -0
- package/dist/integration-profile/integration-profile.controller.js +165 -0
- package/dist/integration-profile/integration-profile.controller.js.map +1 -0
- package/dist/integration-profile/integration-profile.module.d.ts +3 -0
- package/dist/integration-profile/integration-profile.module.d.ts.map +1 -0
- package/dist/integration-profile/integration-profile.module.js +29 -0
- package/dist/integration-profile/integration-profile.module.js.map +1 -0
- package/dist/integration-profile/integration-profile.service.d.ts +160 -0
- package/dist/integration-profile/integration-profile.service.d.ts.map +1 -0
- package/dist/integration-profile/integration-profile.service.js +606 -0
- package/dist/integration-profile/integration-profile.service.js.map +1 -0
- package/dist/integration-profile/integration-profile.utils.d.ts +24 -0
- package/dist/integration-profile/integration-profile.utils.d.ts.map +1 -0
- package/dist/integration-profile/integration-profile.utils.js +147 -0
- package/dist/integration-profile/integration-profile.utils.js.map +1 -0
- package/dist/mail/mail.module.d.ts.map +1 -1
- package/dist/mail/mail.module.js +27 -19
- package/dist/mail/mail.module.js.map +1 -1
- package/dist/mail/mail.service.d.ts +3 -2
- package/dist/mail/mail.service.d.ts.map +1 -1
- package/dist/mail/mail.service.js +25 -47
- package/dist/mail/mail.service.js.map +1 -1
- package/dist/mcp/mcp.module.js +2 -2
- package/dist/mcp/mcp.module.js.map +1 -1
- package/dist/mcp/tools/core-mail-profile.mcp-tools.d.ts +3 -15
- package/dist/mcp/tools/core-mail-profile.mcp-tools.d.ts.map +1 -1
- package/dist/mcp/tools/core-mail-profile.mcp-tools.js +12 -94
- package/dist/mcp/tools/core-mail-profile.mcp-tools.js.map +1 -1
- package/dist/mcp-chat/mcp-chat.service.d.ts.map +1 -1
- package/dist/mcp-chat/mcp-chat.service.js +17 -16
- package/dist/mcp-chat/mcp-chat.service.js.map +1 -1
- package/dist/setting/setting.service.d.ts.map +1 -1
- package/dist/setting/setting.service.js +0 -2
- package/dist/setting/setting.service.js.map +1 -1
- package/dist/webhook-integration/event-webhook.controller.d.ts +1 -0
- package/dist/webhook-integration/event-webhook.controller.d.ts.map +1 -1
- package/dist/webhook-integration/event-webhook.controller.js +10 -0
- package/dist/webhook-integration/event-webhook.controller.js.map +1 -1
- package/dist/webhook-integration/event-webhook.service.d.ts +2 -0
- package/dist/webhook-integration/event-webhook.service.d.ts.map +1 -1
- package/dist/webhook-integration/event-webhook.service.js +30 -0
- package/dist/webhook-integration/event-webhook.service.js.map +1 -1
- package/dist/webhook-integration/webhook-integration.controller.d.ts +1 -0
- package/dist/webhook-integration/webhook-integration.controller.d.ts.map +1 -1
- package/dist/webhook-integration/webhook-integration.controller.js +10 -0
- package/dist/webhook-integration/webhook-integration.controller.js.map +1 -1
- package/dist/webhook-integration/webhook-integration.service.d.ts +2 -1
- package/dist/webhook-integration/webhook-integration.service.d.ts.map +1 -1
- package/dist/webhook-integration/webhook-integration.service.js +62 -44
- package/dist/webhook-integration/webhook-integration.service.js.map +1 -1
- package/dist/whatsapp-profile/dto/create.dto.d.ts +11 -0
- package/dist/whatsapp-profile/dto/create.dto.d.ts.map +1 -0
- package/dist/whatsapp-profile/dto/create.dto.js +55 -0
- package/dist/whatsapp-profile/dto/create.dto.js.map +1 -0
- package/dist/whatsapp-profile/dto/update.dto.d.ts +6 -0
- package/dist/whatsapp-profile/dto/update.dto.d.ts.map +1 -0
- package/dist/whatsapp-profile/dto/update.dto.js +9 -0
- package/dist/whatsapp-profile/dto/update.dto.js.map +1 -0
- package/dist/whatsapp-profile/whatsapp-profile.controller.d.ts +54 -0
- package/dist/whatsapp-profile/whatsapp-profile.controller.d.ts.map +1 -0
- package/dist/whatsapp-profile/whatsapp-profile.controller.js +85 -0
- package/dist/whatsapp-profile/whatsapp-profile.controller.js.map +1 -0
- package/dist/whatsapp-profile/whatsapp-profile.module.d.ts +3 -0
- package/dist/whatsapp-profile/whatsapp-profile.module.d.ts.map +1 -0
- package/dist/whatsapp-profile/whatsapp-profile.module.js +26 -0
- package/dist/whatsapp-profile/whatsapp-profile.module.js.map +1 -0
- package/dist/whatsapp-profile/whatsapp-profile.service.d.ts +63 -0
- package/dist/whatsapp-profile/whatsapp-profile.service.d.ts.map +1 -0
- package/dist/whatsapp-profile/whatsapp-profile.service.js +138 -0
- package/dist/whatsapp-profile/whatsapp-profile.service.js.map +1 -0
- package/hedhog/data/file_provider.yaml +9 -1
- package/hedhog/data/integration_provider.yaml +132 -0
- package/hedhog/data/integration_type.yaml +29 -0
- package/hedhog/data/menu.yaml +15 -14
- package/hedhog/data/role.yaml +8 -0
- package/hedhog/data/route.yaml +66 -15
- package/hedhog/data/setting_group.yaml +30 -191
- package/hedhog/data/setting_subgroup.yaml +5 -13
- package/hedhog/data/whatsapp_profile.yaml +6 -0
- package/hedhog/frontend/app/account/components/connected-accounts.tsx.ejs +25 -20
- package/hedhog/frontend/app/configurations/[slug]/components/setting-field.tsx.ejs +579 -204
- package/hedhog/frontend/app/integration/profiles/page.tsx.ejs +1662 -0
- package/hedhog/frontend/app/integrations-webhooks/page.tsx.ejs +233 -108
- package/hedhog/frontend/app/mail/profiles/page.tsx.ejs +3 -822
- package/hedhog/frontend/app/users/permissions.tsx.ejs +79 -2
- package/hedhog/frontend/app/users/user-sheet.tsx.ejs +7 -2
- package/hedhog/frontend/messages/en.json +172 -0
- package/hedhog/frontend/messages/pt.json +172 -0
- package/hedhog/table/integration_profile.yaml +34 -0
- package/hedhog/table/integration_provider.yaml +23 -0
- package/hedhog/table/integration_type.yaml +19 -0
- package/hedhog/table/webhook_action.yaml +85 -85
- package/hedhog/table/whatsapp_profile.yaml +26 -0
- package/package.json +2 -2
- package/src/ai/ai.service.ts +35 -153
- package/src/core.module.ts +3 -3
- package/src/file/file.service.ts +60 -76
- package/src/file/provider/provider.enum.ts +1 -0
- package/src/file/provider/provider.factory.ts +3 -0
- package/src/file/provider/spaces.provider.ts +261 -0
- package/src/index.ts +6 -3
- package/src/integration-profile/dto/create.dto.ts +44 -0
- package/src/integration-profile/dto/export.dto.ts +15 -0
- package/src/integration-profile/dto/import-confirm.dto.ts +61 -0
- package/src/integration-profile/dto/update.dto.ts +4 -0
- package/src/integration-profile/integration-profile.controller.ts +129 -0
- package/src/integration-profile/integration-profile.module.ts +16 -0
- package/src/integration-profile/integration-profile.service.ts +788 -0
- package/src/integration-profile/integration-profile.utils.ts +156 -0
- package/src/mail/mail.module.ts +27 -18
- package/src/mail/mail.service.ts +31 -60
- package/src/mcp/mcp.module.ts +2 -2
- package/src/mcp/tools/core-mail-profile.mcp-tools.ts +10 -69
- package/src/mcp-chat/mcp-chat.service.ts +23 -20
- package/src/setting/setting.service.ts +0 -2
- package/src/webhook-integration/event-webhook.controller.ts +55 -50
- package/src/webhook-integration/event-webhook.service.ts +422 -384
- package/src/webhook-integration/webhook-integration.controller.ts +5 -0
- package/src/webhook-integration/webhook-integration.service.ts +74 -46
- package/src/whatsapp-profile/dto/create.dto.ts +36 -0
- package/src/whatsapp-profile/dto/update.dto.ts +4 -0
- package/src/whatsapp-profile/whatsapp-profile.controller.ts +51 -0
- package/src/whatsapp-profile/whatsapp-profile.module.ts +13 -0
- 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
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
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<{
|
|
499
|
-
|
|
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: `/
|
|
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:
|
|
810
|
-
from_name:
|
|
811
|
-
from_email:
|
|
812
|
-
reply_to_name:
|
|
813
|
-
reply_to_email:
|
|
814
|
-
smtp_host:
|
|
815
|
-
smtp_port:
|
|
816
|
-
smtp_secure: Boolean(
|
|
817
|
-
smtp_username:
|
|
818
|
-
smtp_password:
|
|
819
|
-
gmail_client_id:
|
|
820
|
-
gmail_client_secret:
|
|
821
|
-
gmail_refresh_token:
|
|
822
|
-
ses_access_key_id:
|
|
823
|
-
ses_secret_access_key:
|
|
824
|
-
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
|
-
|
|
835
|
-
|
|
836
|
-
provider
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
:
|
|
845
|
-
|
|
846
|
-
|
|
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: '/
|
|
946
|
+
url: '/integration-profile/test',
|
|
871
947
|
method: 'POST',
|
|
872
948
|
data: payload,
|
|
873
949
|
}
|
|
874
950
|
);
|
|
875
951
|
|
|
876
|
-
setMailProfileTestedSignature(
|
|
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: `/
|
|
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
|
|
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
|
|
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
|
|
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:
|
|
2436
|
+
data: Array<{
|
|
2437
|
+
id: number;
|
|
2438
|
+
slug: string;
|
|
2439
|
+
name: string;
|
|
2440
|
+
integration_provider?: { slug?: string | null };
|
|
2441
|
+
}>;
|
|
2341
2442
|
}>({
|
|
2342
|
-
url: `/
|
|
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: '/
|
|
2515
|
+
url: '/integration-profile',
|
|
2404
2516
|
method: 'POST',
|
|
2405
2517
|
data: {
|
|
2406
2518
|
slug: values.slug,
|
|
2407
2519
|
name: values.name,
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
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
|
|
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
|
|
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
|
|
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>
|