@hed-hog/core 0.0.356 → 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.
- package/dist/auth/guards/auth.guard.d.ts +6 -1
- package/dist/auth/guards/auth.guard.d.ts.map +1 -1
- package/dist/auth/guards/auth.guard.js +33 -2
- package/dist/auth/guards/auth.guard.js.map +1 -1
- package/dist/file/file.controller.d.ts +4 -2
- package/dist/file/file.controller.d.ts.map +1 -1
- package/dist/file/file.controller.js +44 -38
- package/dist/file/file.controller.js.map +1 -1
- package/dist/file/file.service.d.ts +2 -2
- package/dist/file/file.service.d.ts.map +1 -1
- package/dist/file/file.service.js +25 -42
- package/dist/file/file.service.js.map +1 -1
- package/dist/file/provider/azure.provider.d.ts.map +1 -1
- package/dist/file/provider/azure.provider.js +10 -15
- package/dist/file/provider/azure.provider.js.map +1 -1
- package/dist/file/provider/gcs.provider.d.ts.map +1 -1
- package/dist/file/provider/gcs.provider.js +8 -9
- package/dist/file/provider/gcs.provider.js.map +1 -1
- package/dist/file/provider/local.provider.d.ts.map +1 -1
- package/dist/file/provider/local.provider.js +11 -10
- package/dist/file/provider/local.provider.js.map +1 -1
- package/dist/file/provider/provider.factory.d.ts +1 -1
- package/dist/file/provider/provider.factory.d.ts.map +1 -1
- package/dist/file/provider/provider.factory.js +16 -6
- package/dist/file/provider/provider.factory.js.map +1 -1
- package/dist/file/provider/s3.provider.d.ts.map +1 -1
- package/dist/file/provider/s3.provider.js +4 -20
- package/dist/file/provider/s3.provider.js.map +1 -1
- package/dist/file/provider/spaces.provider.d.ts.map +1 -1
- package/dist/file/provider/spaces.provider.js +4 -19
- package/dist/file/provider/spaces.provider.js.map +1 -1
- package/dist/integration-profile/integration-profile.controller.d.ts +1 -1
- package/dist/integration-profile/integration-profile.controller.d.ts.map +1 -1
- package/dist/integration-profile/integration-profile.controller.js +4 -3
- package/dist/integration-profile/integration-profile.controller.js.map +1 -1
- package/dist/integration-profile/integration-profile.service.d.ts +1 -1
- package/dist/integration-profile/integration-profile.service.d.ts.map +1 -1
- package/dist/integration-profile/integration-profile.service.js +7 -4
- package/dist/integration-profile/integration-profile.service.js.map +1 -1
- package/dist/integration-profile/integration-profile.utils.d.ts +6 -0
- package/dist/integration-profile/integration-profile.utils.d.ts.map +1 -1
- package/dist/integration-profile/integration-profile.utils.js +9 -0
- package/dist/integration-profile/integration-profile.utils.js.map +1 -1
- package/dist/mail/mail.module.d.ts.map +1 -1
- package/dist/mail/mail.module.js +9 -4
- package/dist/mail/mail.module.js.map +1 -1
- package/dist/mail/mail.service.d.ts +2 -1
- package/dist/mail/mail.service.d.ts.map +1 -1
- package/dist/mail/mail.service.js +11 -7
- package/dist/mail/mail.service.js.map +1 -1
- package/dist/mcp/guards/mcp-auth.guard.js +1 -1
- package/dist/mcp/guards/mcp-auth.guard.js.map +1 -1
- package/dist/mcp/mcp-api-key.controller.d.ts +2 -0
- package/dist/mcp/mcp-api-key.controller.d.ts.map +1 -1
- package/dist/mcp/mcp-api-key.controller.js +1 -1
- package/dist/mcp/mcp-api-key.controller.js.map +1 -1
- package/dist/mcp/mcp-api-key.service.d.ts +2 -1
- package/dist/mcp/mcp-api-key.service.d.ts.map +1 -1
- package/dist/mcp/mcp-api-key.service.js +6 -2
- package/dist/mcp/mcp-api-key.service.js.map +1 -1
- package/dist/mcp/mcp.module.d.ts.map +1 -1
- package/dist/mcp/mcp.module.js +1 -3
- package/dist/mcp/mcp.module.js.map +1 -1
- package/dist/oauth/interfaces/OAuthProvider.d.ts +1 -1
- package/dist/oauth/interfaces/OAuthProvider.d.ts.map +1 -1
- package/dist/oauth/oauth.controller.d.ts +4 -1
- package/dist/oauth/oauth.controller.d.ts.map +1 -1
- package/dist/oauth/oauth.controller.js +31 -5
- package/dist/oauth/oauth.controller.js.map +1 -1
- package/dist/oauth/oauth.service.d.ts +12 -1
- package/dist/oauth/oauth.service.d.ts.map +1 -1
- package/dist/oauth/oauth.service.js +125 -23
- package/dist/oauth/oauth.service.js.map +1 -1
- package/dist/oauth/providers/abstract.provider.d.ts +1 -1
- package/dist/oauth/providers/abstract.provider.d.ts.map +1 -1
- package/dist/oauth/providers/facebook.provider.d.ts +5 -2
- package/dist/oauth/providers/facebook.provider.d.ts.map +1 -1
- package/dist/oauth/providers/facebook.provider.js +34 -19
- package/dist/oauth/providers/facebook.provider.js.map +1 -1
- package/dist/oauth/providers/github.provider.d.ts +6 -2
- package/dist/oauth/providers/github.provider.d.ts.map +1 -1
- package/dist/oauth/providers/github.provider.js +43 -20
- package/dist/oauth/providers/github.provider.js.map +1 -1
- package/dist/oauth/providers/google.provider.d.ts +5 -2
- package/dist/oauth/providers/google.provider.d.ts.map +1 -1
- package/dist/oauth/providers/google.provider.js +34 -19
- package/dist/oauth/providers/google.provider.js.map +1 -1
- package/dist/oauth/providers/microsoft-entra-id.provider.d.ts +5 -2
- package/dist/oauth/providers/microsoft-entra-id.provider.d.ts.map +1 -1
- package/dist/oauth/providers/microsoft-entra-id.provider.js +43 -40
- package/dist/oauth/providers/microsoft-entra-id.provider.js.map +1 -1
- package/dist/oauth/providers/microsoft.provider.d.ts +5 -2
- package/dist/oauth/providers/microsoft.provider.d.ts.map +1 -1
- package/dist/oauth/providers/microsoft.provider.js +34 -19
- package/dist/oauth/providers/microsoft.provider.js.map +1 -1
- package/dist/profile/profile.controller.js +1 -1
- package/dist/profile/profile.controller.js.map +1 -1
- package/dist/security/security.service.d.ts +2 -0
- package/dist/security/security.service.d.ts.map +1 -1
- package/dist/security/security.service.js +21 -0
- package/dist/security/security.service.js.map +1 -1
- package/dist/setting/setting.service.d.ts +26 -1
- package/dist/setting/setting.service.d.ts.map +1 -1
- package/dist/setting/setting.service.js +240 -5
- package/dist/setting/setting.service.js.map +1 -1
- package/dist/user/user.controller.d.ts +2 -1
- package/dist/user/user.controller.d.ts.map +1 -1
- package/dist/user/user.controller.js +5 -4
- package/dist/user/user.controller.js.map +1 -1
- package/dist/user/user.service.d.ts +4 -2
- package/dist/user/user.service.d.ts.map +1 -1
- package/dist/user/user.service.js +19 -4
- package/dist/user/user.service.js.map +1 -1
- package/dist/webhook-integration/dto/webhook-action.dto.d.ts +17 -2
- package/dist/webhook-integration/dto/webhook-action.dto.d.ts.map +1 -1
- package/dist/webhook-integration/dto/webhook-action.dto.js +93 -2
- package/dist/webhook-integration/dto/webhook-action.dto.js.map +1 -1
- package/dist/webhook-integration/webhook-command.registry.d.ts +15 -0
- package/dist/webhook-integration/webhook-command.registry.d.ts.map +1 -0
- package/dist/webhook-integration/webhook-command.registry.js +36 -0
- package/dist/webhook-integration/webhook-command.registry.js.map +1 -0
- package/dist/webhook-integration/webhook-integration.controller.d.ts +19 -0
- package/dist/webhook-integration/webhook-integration.controller.d.ts.map +1 -1
- package/dist/webhook-integration/webhook-integration.controller.js +38 -0
- package/dist/webhook-integration/webhook-integration.controller.js.map +1 -1
- package/dist/webhook-integration/webhook-integration.module.d.ts.map +1 -1
- package/dist/webhook-integration/webhook-integration.module.js +5 -0
- package/dist/webhook-integration/webhook-integration.module.js.map +1 -1
- package/dist/webhook-integration/webhook-integration.service.d.ts +25 -1
- package/dist/webhook-integration/webhook-integration.service.d.ts.map +1 -1
- package/dist/webhook-integration/webhook-integration.service.js +332 -23
- package/dist/webhook-integration/webhook-integration.service.js.map +1 -1
- package/hedhog/data/integration_provider.yaml +16 -0
- package/hedhog/data/menu.yaml +0 -16
- package/hedhog/data/route.yaml +32 -383
- package/hedhog/data/setting_group.yaml +179 -174
- package/hedhog/data/setting_subgroup.yaml +16 -0
- package/hedhog/frontend/app/account/components/tokens.tsx.ejs +421 -0
- package/hedhog/frontend/app/account/layout.tsx.ejs +6 -3
- package/hedhog/frontend/app/account/mcp-tokens/page.tsx.ejs +2 -2
- package/hedhog/frontend/app/account/tokens/page.tsx.ejs +5 -0
- package/hedhog/frontend/app/configurations/[slug]/components/setting-field.tsx.ejs +414 -76
- package/hedhog/frontend/app/configurations/layout.tsx.ejs +1 -1
- package/hedhog/frontend/app/dashboard/dashboard-home-tabs.tsx.ejs +3 -1
- package/hedhog/frontend/app/integration/profiles/page.tsx.ejs +186 -18
- package/hedhog/frontend/app/integrations-webhooks/page.tsx.ejs +597 -21
- package/hedhog/frontend/app/mail/profiles/page.tsx.ejs +2 -2
- package/hedhog/frontend/app/setting-list/page.tsx.ejs +229 -395
- package/hedhog/frontend/messages/en.json +67 -3
- package/hedhog/frontend/messages/pt.json +67 -3
- package/hedhog/table/file.yaml +1 -1
- package/hedhog/table/mcp_api_key.yaml +4 -0
- package/hedhog/table/webhook_action.yaml +57 -1
- package/package.json +5 -4
- package/src/auth/guards/auth.guard.ts +32 -0
- package/src/file/file.controller.ts +51 -42
- package/src/file/file.service.ts +31 -52
- package/src/file/provider/azure.provider.ts +14 -28
- package/src/file/provider/gcs.provider.ts +9 -9
- package/src/file/provider/local.provider.ts +10 -13
- package/src/file/provider/provider.factory.ts +19 -7
- package/src/file/provider/s3.provider.ts +4 -20
- package/src/file/provider/spaces.provider.ts +4 -19
- package/src/integration-profile/integration-profile.controller.ts +2 -0
- package/src/integration-profile/integration-profile.service.ts +7 -2
- package/src/integration-profile/integration-profile.utils.ts +17 -0
- package/src/mail/mail.module.ts +14 -4
- package/src/mail/mail.service.ts +12 -7
- package/src/mcp/guards/mcp-auth.guard.ts +1 -1
- package/src/mcp/mcp-api-key.controller.ts +2 -2
- package/src/mcp/mcp-api-key.service.ts +6 -2
- package/src/mcp/mcp.module.ts +1 -3
- package/src/oauth/interfaces/OAuthProvider.ts +1 -1
- package/src/oauth/oauth.controller.ts +30 -2
- package/src/oauth/oauth.service.ts +194 -35
- package/src/oauth/providers/abstract.provider.ts +1 -1
- package/src/oauth/providers/facebook.provider.ts +36 -20
- package/src/oauth/providers/github.provider.ts +46 -23
- package/src/oauth/providers/google.provider.ts +36 -20
- package/src/oauth/providers/microsoft-entra-id.provider.ts +42 -46
- package/src/oauth/providers/microsoft.provider.ts +36 -21
- package/src/profile/profile.controller.ts +2 -2
- package/src/security/security.service.ts +34 -1
- package/src/setting/setting.service.ts +307 -7
- package/src/user/user.controller.ts +4 -1
- package/src/user/user.service.ts +20 -2
- package/src/webhook-integration/dto/webhook-action.dto.ts +85 -4
- package/src/webhook-integration/webhook-command.registry.ts +42 -0
- package/src/webhook-integration/webhook-integration.controller.ts +20 -0
- package/src/webhook-integration/webhook-integration.module.ts +50 -45
- package/src/webhook-integration/webhook-integration.service.ts +374 -11
- package/dist/mail-profile/dto/create.dto.d.ts +0 -23
- package/dist/mail-profile/dto/create.dto.d.ts.map +0 -1
- package/dist/mail-profile/dto/create.dto.js +0 -139
- package/dist/mail-profile/dto/create.dto.js.map +0 -1
- package/dist/mail-profile/dto/update.dto.d.ts +0 -6
- package/dist/mail-profile/dto/update.dto.d.ts.map +0 -1
- package/dist/mail-profile/dto/update.dto.js +0 -9
- package/dist/mail-profile/dto/update.dto.js.map +0 -1
- package/dist/mail-profile/mail-profile.controller.d.ts +0 -94
- package/dist/mail-profile/mail-profile.controller.d.ts.map +0 -1
- package/dist/mail-profile/mail-profile.controller.js +0 -95
- package/dist/mail-profile/mail-profile.controller.js.map +0 -1
- package/dist/mail-profile/mail-profile.module.d.ts +0 -3
- package/dist/mail-profile/mail-profile.module.d.ts.map +0 -1
- package/dist/mail-profile/mail-profile.module.js +0 -31
- package/dist/mail-profile/mail-profile.module.js.map +0 -1
- package/dist/mail-profile/mail-profile.service.d.ts +0 -109
- package/dist/mail-profile/mail-profile.service.d.ts.map +0 -1
- package/dist/mail-profile/mail-profile.service.js +0 -278
- package/dist/mail-profile/mail-profile.service.js.map +0 -1
- package/dist/mcp/tools/core-mail-profile.mcp-tools.d.ts +0 -20
- package/dist/mcp/tools/core-mail-profile.mcp-tools.d.ts.map +0 -1
- package/dist/mcp/tools/core-mail-profile.mcp-tools.js +0 -96
- package/dist/mcp/tools/core-mail-profile.mcp-tools.js.map +0 -1
- package/dist/whatsapp-profile/dto/create.dto.d.ts +0 -11
- package/dist/whatsapp-profile/dto/create.dto.d.ts.map +0 -1
- package/dist/whatsapp-profile/dto/create.dto.js +0 -55
- package/dist/whatsapp-profile/dto/create.dto.js.map +0 -1
- package/dist/whatsapp-profile/dto/update.dto.d.ts +0 -6
- package/dist/whatsapp-profile/dto/update.dto.d.ts.map +0 -1
- package/dist/whatsapp-profile/dto/update.dto.js +0 -9
- package/dist/whatsapp-profile/dto/update.dto.js.map +0 -1
- package/dist/whatsapp-profile/whatsapp-profile.controller.d.ts +0 -54
- package/dist/whatsapp-profile/whatsapp-profile.controller.d.ts.map +0 -1
- package/dist/whatsapp-profile/whatsapp-profile.controller.js +0 -85
- package/dist/whatsapp-profile/whatsapp-profile.controller.js.map +0 -1
- package/dist/whatsapp-profile/whatsapp-profile.module.d.ts +0 -3
- package/dist/whatsapp-profile/whatsapp-profile.module.d.ts.map +0 -1
- package/dist/whatsapp-profile/whatsapp-profile.module.js +0 -26
- package/dist/whatsapp-profile/whatsapp-profile.module.js.map +0 -1
- package/dist/whatsapp-profile/whatsapp-profile.service.d.ts +0 -63
- package/dist/whatsapp-profile/whatsapp-profile.service.d.ts.map +0 -1
- package/dist/whatsapp-profile/whatsapp-profile.service.js +0 -138
- package/dist/whatsapp-profile/whatsapp-profile.service.js.map +0 -1
- package/hedhog/data/mail_profile.yaml +0 -18
- package/hedhog/data/whatsapp_profile.yaml +0 -6
- package/hedhog/table/mail_profile.yaml +0 -75
- package/hedhog/table/whatsapp_profile.yaml +0 -26
- package/src/mail-profile/dto/create.dto.ts +0 -145
- package/src/mail-profile/dto/update.dto.ts +0 -4
- package/src/mail-profile/mail-profile.controller.ts +0 -56
- package/src/mail-profile/mail-profile.module.ts +0 -18
- package/src/mail-profile/mail-profile.service.ts +0 -308
- package/src/mcp/tools/core-mail-profile.mcp-tools.ts +0 -69
- package/src/whatsapp-profile/dto/create.dto.ts +0 -36
- package/src/whatsapp-profile/dto/update.dto.ts +0 -4
- package/src/whatsapp-profile/whatsapp-profile.controller.ts +0 -51
- package/src/whatsapp-profile/whatsapp-profile.module.ts +0 -13
- package/src/whatsapp-profile/whatsapp-profile.service.ts +0 -160
|
@@ -115,11 +115,16 @@ type EventCatalog = {
|
|
|
115
115
|
|
|
116
116
|
type IncomingAction = {
|
|
117
117
|
id: number;
|
|
118
|
-
type:
|
|
118
|
+
type:
|
|
119
|
+
| 'email'
|
|
120
|
+
| 'whatsapp_evolution'
|
|
121
|
+
| 'http_request'
|
|
122
|
+
| 'internal_api'
|
|
123
|
+
| 'app_command';
|
|
119
124
|
name: string;
|
|
120
125
|
order: number;
|
|
121
126
|
status: Status;
|
|
122
|
-
|
|
127
|
+
integration_profile_id?: number | null;
|
|
123
128
|
mail_id?: number | null;
|
|
124
129
|
email_to?: string | null;
|
|
125
130
|
email_cc?: string | null;
|
|
@@ -130,6 +135,21 @@ type IncomingAction = {
|
|
|
130
135
|
whatsapp_instance?: string | null;
|
|
131
136
|
whatsapp_base_url?: string | null;
|
|
132
137
|
whatsapp_token?: string | null;
|
|
138
|
+
http_url?: string | null;
|
|
139
|
+
http_method?: string | null;
|
|
140
|
+
http_headers?: string | null;
|
|
141
|
+
http_query?: string | null;
|
|
142
|
+
http_body?: string | null;
|
|
143
|
+
http_timeout_ms?: number | null;
|
|
144
|
+
http_retry_count?: number | null;
|
|
145
|
+
internal_api_path?: string | null;
|
|
146
|
+
internal_api_method?: string | null;
|
|
147
|
+
internal_api_query?: string | null;
|
|
148
|
+
internal_api_body?: string | null;
|
|
149
|
+
internal_api_token?: string | null;
|
|
150
|
+
internal_api_user_id?: number | null;
|
|
151
|
+
app_command_slug?: string | null;
|
|
152
|
+
app_command_params?: string | null;
|
|
133
153
|
};
|
|
134
154
|
|
|
135
155
|
type IncomingActionForm = {
|
|
@@ -137,7 +157,7 @@ type IncomingActionForm = {
|
|
|
137
157
|
name: string;
|
|
138
158
|
order: number;
|
|
139
159
|
status: Status;
|
|
140
|
-
|
|
160
|
+
integration_profile_id: number | null;
|
|
141
161
|
mail_id: number | null;
|
|
142
162
|
email_to: string;
|
|
143
163
|
email_cc: string;
|
|
@@ -148,6 +168,21 @@ type IncomingActionForm = {
|
|
|
148
168
|
whatsapp_instance: string;
|
|
149
169
|
whatsapp_base_url: string;
|
|
150
170
|
whatsapp_token: string;
|
|
171
|
+
http_url: string;
|
|
172
|
+
http_method: string;
|
|
173
|
+
http_headers: string;
|
|
174
|
+
http_query: string;
|
|
175
|
+
http_body: string;
|
|
176
|
+
http_timeout_ms: number;
|
|
177
|
+
http_retry_count: number;
|
|
178
|
+
internal_api_path: string;
|
|
179
|
+
internal_api_method: string;
|
|
180
|
+
internal_api_query: string;
|
|
181
|
+
internal_api_body: string;
|
|
182
|
+
internal_api_token: string;
|
|
183
|
+
internal_api_user_id: number | null;
|
|
184
|
+
app_command_slug: string;
|
|
185
|
+
app_command_params: string;
|
|
151
186
|
};
|
|
152
187
|
|
|
153
188
|
type IncomingIntegration = {
|
|
@@ -373,7 +408,7 @@ const defaultActionForm: IncomingActionForm = {
|
|
|
373
408
|
name: '',
|
|
374
409
|
order: 0,
|
|
375
410
|
status: 'active' as Status,
|
|
376
|
-
|
|
411
|
+
integration_profile_id: null,
|
|
377
412
|
mail_id: null,
|
|
378
413
|
email_to: '',
|
|
379
414
|
email_cc: '',
|
|
@@ -384,6 +419,21 @@ const defaultActionForm: IncomingActionForm = {
|
|
|
384
419
|
whatsapp_instance: '',
|
|
385
420
|
whatsapp_base_url: '',
|
|
386
421
|
whatsapp_token: '',
|
|
422
|
+
http_url: '',
|
|
423
|
+
http_method: 'POST',
|
|
424
|
+
http_headers: '',
|
|
425
|
+
http_query: '',
|
|
426
|
+
http_body: '',
|
|
427
|
+
http_timeout_ms: 30000,
|
|
428
|
+
http_retry_count: 0,
|
|
429
|
+
internal_api_path: '',
|
|
430
|
+
internal_api_method: 'POST',
|
|
431
|
+
internal_api_query: '',
|
|
432
|
+
internal_api_body: '',
|
|
433
|
+
internal_api_token: '',
|
|
434
|
+
internal_api_user_id: null,
|
|
435
|
+
app_command_slug: '',
|
|
436
|
+
app_command_params: '',
|
|
387
437
|
};
|
|
388
438
|
|
|
389
439
|
const defaultEventWebhookForm = {
|
|
@@ -487,6 +537,7 @@ export default function IntegrationsWebhooksPage() {
|
|
|
487
537
|
const [incomingForm, setIncomingForm] = useState(defaultIncomingForm);
|
|
488
538
|
const [incomingSheetTab, setIncomingSheetTab] = useState('settings');
|
|
489
539
|
const [oneTimeToken, setOneTimeToken] = useState<string | null>(null);
|
|
540
|
+
const [generatedToken, setGeneratedToken] = useState<string | null>(null);
|
|
490
541
|
const [allowedIpDraft, setAllowedIpDraft] = useState('');
|
|
491
542
|
const [incomingActions, setIncomingActions] = useState<IncomingAction[]>([]);
|
|
492
543
|
const [actionSheetOpen, setActionSheetOpen] = useState(false);
|
|
@@ -549,7 +600,7 @@ export default function IntegrationsWebhooksPage() {
|
|
|
549
600
|
const { data: mailProfiles = [], refetch: refetchMailProfiles } = useQuery<
|
|
550
601
|
SelectOption[]
|
|
551
602
|
>({
|
|
552
|
-
queryKey: ['webhook-
|
|
603
|
+
queryKey: ['webhook-integration-profiles', currentLocaleCode],
|
|
553
604
|
queryFn: async () => {
|
|
554
605
|
const response = await request<{
|
|
555
606
|
data: Array<{
|
|
@@ -603,6 +654,56 @@ export default function IntegrationsWebhooksPage() {
|
|
|
603
654
|
placeholderData: (previous) => previous ?? [],
|
|
604
655
|
});
|
|
605
656
|
|
|
657
|
+
const { data: appCommands = [] } = useQuery<
|
|
658
|
+
Array<{
|
|
659
|
+
slug: string;
|
|
660
|
+
name: string;
|
|
661
|
+
description: string;
|
|
662
|
+
inputSchema: Record<string, unknown>;
|
|
663
|
+
}>
|
|
664
|
+
>({
|
|
665
|
+
queryKey: ['webhook-app-commands'],
|
|
666
|
+
queryFn: async () => {
|
|
667
|
+
const response = await request<
|
|
668
|
+
Array<{
|
|
669
|
+
slug: string;
|
|
670
|
+
name: string;
|
|
671
|
+
description: string;
|
|
672
|
+
inputSchema: Record<string, unknown>;
|
|
673
|
+
}>
|
|
674
|
+
>({
|
|
675
|
+
url: '/webhook-integration/app-commands',
|
|
676
|
+
method: 'GET',
|
|
677
|
+
});
|
|
678
|
+
return response.data || [];
|
|
679
|
+
},
|
|
680
|
+
placeholderData: (previous) => previous ?? [],
|
|
681
|
+
});
|
|
682
|
+
|
|
683
|
+
const { data: internalRoutes = [] } = useQuery<
|
|
684
|
+
Array<{
|
|
685
|
+
id: number;
|
|
686
|
+
url: string;
|
|
687
|
+
method: string;
|
|
688
|
+
}>
|
|
689
|
+
>({
|
|
690
|
+
queryKey: ['webhook-internal-routes'],
|
|
691
|
+
queryFn: async () => {
|
|
692
|
+
const response = await request<
|
|
693
|
+
Array<{
|
|
694
|
+
id: number;
|
|
695
|
+
url: string;
|
|
696
|
+
method: string;
|
|
697
|
+
}>
|
|
698
|
+
>({
|
|
699
|
+
url: '/webhook-integration/internal-routes',
|
|
700
|
+
method: 'GET',
|
|
701
|
+
});
|
|
702
|
+
return response.data || [];
|
|
703
|
+
},
|
|
704
|
+
placeholderData: (previous) => previous ?? [],
|
|
705
|
+
});
|
|
706
|
+
|
|
606
707
|
const { data: incomingLogsResult, isFetching: isFetchingIncomingLogs } =
|
|
607
708
|
useQuery<PaginatedResponse<IncomingCallLog>>({
|
|
608
709
|
queryKey: [
|
|
@@ -850,6 +951,7 @@ export default function IntegrationsWebhooksPage() {
|
|
|
850
951
|
|
|
851
952
|
const openActionCreate = () => {
|
|
852
953
|
setActionEdit(null);
|
|
954
|
+
setGeneratedToken(null);
|
|
853
955
|
setActionForm({
|
|
854
956
|
...defaultActionForm,
|
|
855
957
|
order: incomingActions.length,
|
|
@@ -859,12 +961,13 @@ export default function IntegrationsWebhooksPage() {
|
|
|
859
961
|
|
|
860
962
|
const openActionEdit = (action: IncomingAction) => {
|
|
861
963
|
setActionEdit(action);
|
|
964
|
+
setGeneratedToken(null);
|
|
862
965
|
setActionForm({
|
|
863
966
|
type: action.type,
|
|
864
967
|
name: action.name,
|
|
865
968
|
order: Number(action.order || 0),
|
|
866
969
|
status: action.status,
|
|
867
|
-
|
|
970
|
+
integration_profile_id: action.integration_profile_id ?? null,
|
|
868
971
|
mail_id: action.mail_id ?? null,
|
|
869
972
|
email_to: action.email_to || '',
|
|
870
973
|
email_cc: action.email_cc || '',
|
|
@@ -875,6 +978,31 @@ export default function IntegrationsWebhooksPage() {
|
|
|
875
978
|
whatsapp_instance: action.whatsapp_instance || '',
|
|
876
979
|
whatsapp_base_url: action.whatsapp_base_url || '',
|
|
877
980
|
whatsapp_token: action.whatsapp_token || '',
|
|
981
|
+
http_url: action.http_url || '',
|
|
982
|
+
http_method: action.http_method || 'POST',
|
|
983
|
+
http_headers: action.http_headers
|
|
984
|
+
? JSON.stringify(action.http_headers, null, 2)
|
|
985
|
+
: '',
|
|
986
|
+
http_query: action.http_query
|
|
987
|
+
? JSON.stringify(action.http_query, null, 2)
|
|
988
|
+
: '',
|
|
989
|
+
http_body: action.http_body || '',
|
|
990
|
+
http_timeout_ms: action.http_timeout_ms ?? 30000,
|
|
991
|
+
http_retry_count: action.http_retry_count ?? 0,
|
|
992
|
+
internal_api_path: action.internal_api_path || '',
|
|
993
|
+
internal_api_method: action.internal_api_method || 'POST',
|
|
994
|
+
internal_api_query: action.internal_api_query
|
|
995
|
+
? JSON.stringify(action.internal_api_query, null, 2)
|
|
996
|
+
: '',
|
|
997
|
+
internal_api_body: action.internal_api_body
|
|
998
|
+
? JSON.stringify(action.internal_api_body, null, 2)
|
|
999
|
+
: '',
|
|
1000
|
+
internal_api_token: action.internal_api_token || '',
|
|
1001
|
+
internal_api_user_id: action.internal_api_user_id ?? null,
|
|
1002
|
+
app_command_slug: action.app_command_slug || '',
|
|
1003
|
+
app_command_params: action.app_command_params
|
|
1004
|
+
? JSON.stringify(action.app_command_params, null, 2)
|
|
1005
|
+
: '',
|
|
878
1006
|
});
|
|
879
1007
|
setActionSheetOpen(true);
|
|
880
1008
|
};
|
|
@@ -949,14 +1077,19 @@ export default function IntegrationsWebhooksPage() {
|
|
|
949
1077
|
}
|
|
950
1078
|
);
|
|
951
1079
|
|
|
1080
|
+
const fallbackFromEmail =
|
|
1081
|
+
payload.config && typeof payload.config === 'object'
|
|
1082
|
+
? String((payload.config as Record<string, unknown>).from_email ?? '')
|
|
1083
|
+
: '';
|
|
1084
|
+
|
|
952
1085
|
setMailProfileTestedSignature(currentMailProfileSignature);
|
|
953
1086
|
toast.success(
|
|
954
|
-
data.destination ||
|
|
955
|
-
? `Perfil testado com sucesso para ${data.destination ||
|
|
1087
|
+
data.destination || fallbackFromEmail
|
|
1088
|
+
? `Perfil testado com sucesso para ${data.destination || fallbackFromEmail}`
|
|
956
1089
|
: 'Perfil testado com sucesso.'
|
|
957
1090
|
);
|
|
958
1091
|
} catch (error) {
|
|
959
|
-
console.error('Error testing
|
|
1092
|
+
console.error('Error testing integration profile:', error);
|
|
960
1093
|
setMailProfileTestedSignature(null);
|
|
961
1094
|
toast.error('Erro ao testar o perfil de e-mail.');
|
|
962
1095
|
} finally {
|
|
@@ -1129,8 +1262,8 @@ export default function IntegrationsWebhooksPage() {
|
|
|
1129
1262
|
const missingFields: string[] = [];
|
|
1130
1263
|
|
|
1131
1264
|
if (actionForm.type === 'email') {
|
|
1132
|
-
if (actionForm.
|
|
1133
|
-
missingFields.push('
|
|
1265
|
+
if (actionForm.integration_profile_id == null)
|
|
1266
|
+
missingFields.push('integration_profile_id');
|
|
1134
1267
|
if (actionForm.mail_id == null) missingFields.push('mail_id');
|
|
1135
1268
|
if (!actionForm.email_to.trim()) missingFields.push('email_to');
|
|
1136
1269
|
}
|
|
@@ -1153,6 +1286,24 @@ export default function IntegrationsWebhooksPage() {
|
|
|
1153
1286
|
}
|
|
1154
1287
|
}
|
|
1155
1288
|
|
|
1289
|
+
if (actionForm.type === 'http_request') {
|
|
1290
|
+
if (!actionForm.http_url.trim()) missingFields.push('http_url');
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
if (actionForm.type === 'internal_api') {
|
|
1294
|
+
if (!actionForm.internal_api_path.trim())
|
|
1295
|
+
missingFields.push('internal_api_path');
|
|
1296
|
+
if (actionForm.internal_api_user_id == null)
|
|
1297
|
+
missingFields.push('internal_api_user_id');
|
|
1298
|
+
if (!actionForm.internal_api_token.trim())
|
|
1299
|
+
missingFields.push('internal_api_token');
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
if (actionForm.type === 'app_command') {
|
|
1303
|
+
if (!actionForm.app_command_slug.trim())
|
|
1304
|
+
missingFields.push('app_command_slug');
|
|
1305
|
+
}
|
|
1306
|
+
|
|
1156
1307
|
if (missingFields.length) {
|
|
1157
1308
|
toast.error(
|
|
1158
1309
|
`Preencha os campos obrigatorios da acao: ${missingFields.join(', ')}`
|
|
@@ -1164,7 +1315,7 @@ export default function IntegrationsWebhooksPage() {
|
|
|
1164
1315
|
const payload = {
|
|
1165
1316
|
...actionForm,
|
|
1166
1317
|
order: Number(actionForm.order || 0),
|
|
1167
|
-
|
|
1318
|
+
integration_profile_id: actionForm.integration_profile_id,
|
|
1168
1319
|
mail_id: actionForm.mail_id,
|
|
1169
1320
|
email_to: actionForm.email_to.trim(),
|
|
1170
1321
|
email_cc: actionForm.email_cc.trim(),
|
|
@@ -1174,6 +1325,61 @@ export default function IntegrationsWebhooksPage() {
|
|
|
1174
1325
|
whatsapp_instance: actionForm.whatsapp_instance.trim(),
|
|
1175
1326
|
whatsapp_base_url: actionForm.whatsapp_base_url.trim(),
|
|
1176
1327
|
whatsapp_token: actionForm.whatsapp_token.trim(),
|
|
1328
|
+
http_url: actionForm.http_url.trim() || undefined,
|
|
1329
|
+
http_method: actionForm.http_method || 'POST',
|
|
1330
|
+
http_headers: actionForm.http_headers.trim()
|
|
1331
|
+
? (() => {
|
|
1332
|
+
try {
|
|
1333
|
+
return JSON.parse(actionForm.http_headers);
|
|
1334
|
+
} catch {
|
|
1335
|
+
return undefined;
|
|
1336
|
+
}
|
|
1337
|
+
})()
|
|
1338
|
+
: undefined,
|
|
1339
|
+
http_query: actionForm.http_query.trim()
|
|
1340
|
+
? (() => {
|
|
1341
|
+
try {
|
|
1342
|
+
return JSON.parse(actionForm.http_query);
|
|
1343
|
+
} catch {
|
|
1344
|
+
return undefined;
|
|
1345
|
+
}
|
|
1346
|
+
})()
|
|
1347
|
+
: undefined,
|
|
1348
|
+
http_body: actionForm.http_body.trim() || undefined,
|
|
1349
|
+
http_timeout_ms: actionForm.http_timeout_ms || undefined,
|
|
1350
|
+
http_retry_count: actionForm.http_retry_count ?? 0,
|
|
1351
|
+
internal_api_path: actionForm.internal_api_path.trim() || undefined,
|
|
1352
|
+
internal_api_method: actionForm.internal_api_method || 'POST',
|
|
1353
|
+
internal_api_query: actionForm.internal_api_query.trim()
|
|
1354
|
+
? (() => {
|
|
1355
|
+
try {
|
|
1356
|
+
return JSON.parse(actionForm.internal_api_query);
|
|
1357
|
+
} catch {
|
|
1358
|
+
return undefined;
|
|
1359
|
+
}
|
|
1360
|
+
})()
|
|
1361
|
+
: undefined,
|
|
1362
|
+
internal_api_body: actionForm.internal_api_body.trim()
|
|
1363
|
+
? (() => {
|
|
1364
|
+
try {
|
|
1365
|
+
return JSON.parse(actionForm.internal_api_body);
|
|
1366
|
+
} catch {
|
|
1367
|
+
return undefined;
|
|
1368
|
+
}
|
|
1369
|
+
})()
|
|
1370
|
+
: undefined,
|
|
1371
|
+
internal_api_token: actionForm.internal_api_token.trim() || undefined,
|
|
1372
|
+
internal_api_user_id: actionForm.internal_api_user_id ?? undefined,
|
|
1373
|
+
app_command_slug: actionForm.app_command_slug.trim() || undefined,
|
|
1374
|
+
app_command_params: actionForm.app_command_params.trim()
|
|
1375
|
+
? (() => {
|
|
1376
|
+
try {
|
|
1377
|
+
return JSON.parse(actionForm.app_command_params);
|
|
1378
|
+
} catch {
|
|
1379
|
+
return undefined;
|
|
1380
|
+
}
|
|
1381
|
+
})()
|
|
1382
|
+
: undefined,
|
|
1177
1383
|
};
|
|
1178
1384
|
|
|
1179
1385
|
if (actionEdit) {
|
|
@@ -1194,6 +1400,7 @@ export default function IntegrationsWebhooksPage() {
|
|
|
1194
1400
|
|
|
1195
1401
|
setActionEdit(null);
|
|
1196
1402
|
setActionSheetOpen(false);
|
|
1403
|
+
setGeneratedToken(null);
|
|
1197
1404
|
setActionForm(defaultActionForm);
|
|
1198
1405
|
await openIncomingEdit(incomingEdit);
|
|
1199
1406
|
await incoming.refetch();
|
|
@@ -2361,6 +2568,7 @@ export default function IntegrationsWebhooksPage() {
|
|
|
2361
2568
|
setActionSheetOpen(open);
|
|
2362
2569
|
if (!open) {
|
|
2363
2570
|
setActionEdit(null);
|
|
2571
|
+
setGeneratedToken(null);
|
|
2364
2572
|
setActionForm(defaultActionForm);
|
|
2365
2573
|
}
|
|
2366
2574
|
}}
|
|
@@ -2392,6 +2600,13 @@ export default function IntegrationsWebhooksPage() {
|
|
|
2392
2600
|
<SelectItem value="whatsapp_evolution">
|
|
2393
2601
|
{t('whatsapp')}
|
|
2394
2602
|
</SelectItem>
|
|
2603
|
+
<SelectItem value="http_request">
|
|
2604
|
+
HTTP Request
|
|
2605
|
+
</SelectItem>
|
|
2606
|
+
<SelectItem value="internal_api">
|
|
2607
|
+
Internal API
|
|
2608
|
+
</SelectItem>
|
|
2609
|
+
<SelectItem value="app_command">App Command</SelectItem>
|
|
2395
2610
|
</SelectContent>
|
|
2396
2611
|
</Select>
|
|
2397
2612
|
</Field>
|
|
@@ -2420,12 +2635,12 @@ export default function IntegrationsWebhooksPage() {
|
|
|
2420
2635
|
</Field>
|
|
2421
2636
|
</div>
|
|
2422
2637
|
|
|
2423
|
-
{actionForm.type === 'email'
|
|
2638
|
+
{actionForm.type === 'email' && (
|
|
2424
2639
|
<div className="grid gap-3 md:grid-cols-2">
|
|
2425
2640
|
<Field label={t('mailProfile')}>
|
|
2426
2641
|
<div className="flex items-start gap-2">
|
|
2427
2642
|
<EntityPicker<SelectOption>
|
|
2428
|
-
value={actionForm.
|
|
2643
|
+
value={actionForm.integration_profile_id}
|
|
2429
2644
|
className="w-full"
|
|
2430
2645
|
valueType="number"
|
|
2431
2646
|
placeholder={t('select')}
|
|
@@ -2543,7 +2758,7 @@ export default function IntegrationsWebhooksPage() {
|
|
|
2543
2758
|
onChange={(value) =>
|
|
2544
2759
|
setActionForm((current) => ({
|
|
2545
2760
|
...current,
|
|
2546
|
-
|
|
2761
|
+
integration_profile_id:
|
|
2547
2762
|
typeof value === 'number'
|
|
2548
2763
|
? value
|
|
2549
2764
|
: value != null && value !== ''
|
|
@@ -2558,13 +2773,13 @@ export default function IntegrationsWebhooksPage() {
|
|
|
2558
2773
|
variant="outline"
|
|
2559
2774
|
size="icon"
|
|
2560
2775
|
className="h-10 w-10 shrink-0"
|
|
2561
|
-
disabled={!actionForm.
|
|
2776
|
+
disabled={!actionForm.integration_profile_id}
|
|
2562
2777
|
aria-label="Editar perfil de e-mail selecionado"
|
|
2563
2778
|
title="Editar perfil de e-mail selecionado"
|
|
2564
2779
|
onClick={() => {
|
|
2565
|
-
if (actionForm.
|
|
2780
|
+
if (actionForm.integration_profile_id) {
|
|
2566
2781
|
void openMailProfileEditor(
|
|
2567
|
-
actionForm.
|
|
2782
|
+
actionForm.integration_profile_id
|
|
2568
2783
|
);
|
|
2569
2784
|
}
|
|
2570
2785
|
}}
|
|
@@ -2684,7 +2899,9 @@ export default function IntegrationsWebhooksPage() {
|
|
|
2684
2899
|
/>
|
|
2685
2900
|
</Field>
|
|
2686
2901
|
</div>
|
|
2687
|
-
)
|
|
2902
|
+
)}
|
|
2903
|
+
|
|
2904
|
+
{actionForm.type === 'whatsapp_evolution' && (
|
|
2688
2905
|
<div className="grid gap-3 md:grid-cols-2">
|
|
2689
2906
|
<Field label={t('whatsappTargetType')}>
|
|
2690
2907
|
<Select
|
|
@@ -2766,6 +2983,357 @@ export default function IntegrationsWebhooksPage() {
|
|
|
2766
2983
|
</div>
|
|
2767
2984
|
)}
|
|
2768
2985
|
|
|
2986
|
+
{actionForm.type === 'http_request' && (
|
|
2987
|
+
<div className="grid gap-3 md:grid-cols-2">
|
|
2988
|
+
<Field label="Método HTTP">
|
|
2989
|
+
<Select
|
|
2990
|
+
value={actionForm.http_method}
|
|
2991
|
+
onValueChange={(value) =>
|
|
2992
|
+
setActionForm({ ...actionForm, http_method: value })
|
|
2993
|
+
}
|
|
2994
|
+
>
|
|
2995
|
+
<SelectTrigger className="w-full">
|
|
2996
|
+
<SelectValue />
|
|
2997
|
+
</SelectTrigger>
|
|
2998
|
+
<SelectContent>
|
|
2999
|
+
{['GET', 'POST', 'PUT', 'PATCH', 'DELETE'].map(
|
|
3000
|
+
(m) => (
|
|
3001
|
+
<SelectItem key={m} value={m}>
|
|
3002
|
+
{m}
|
|
3003
|
+
</SelectItem>
|
|
3004
|
+
)
|
|
3005
|
+
)}
|
|
3006
|
+
</SelectContent>
|
|
3007
|
+
</Select>
|
|
3008
|
+
</Field>
|
|
3009
|
+
<Field label="URL *">
|
|
3010
|
+
<Input
|
|
3011
|
+
value={actionForm.http_url}
|
|
3012
|
+
onChange={(event) =>
|
|
3013
|
+
setActionForm({
|
|
3014
|
+
...actionForm,
|
|
3015
|
+
http_url: event.target.value,
|
|
3016
|
+
})
|
|
3017
|
+
}
|
|
3018
|
+
placeholder="https://example.com/api/{{endpoint}}"
|
|
3019
|
+
/>
|
|
3020
|
+
</Field>
|
|
3021
|
+
<Field label="Timeout (ms)">
|
|
3022
|
+
<Input
|
|
3023
|
+
type="number"
|
|
3024
|
+
value={actionForm.http_timeout_ms}
|
|
3025
|
+
onChange={(event) =>
|
|
3026
|
+
setActionForm({
|
|
3027
|
+
...actionForm,
|
|
3028
|
+
http_timeout_ms: Number(event.target.value),
|
|
3029
|
+
})
|
|
3030
|
+
}
|
|
3031
|
+
placeholder="30000"
|
|
3032
|
+
/>
|
|
3033
|
+
</Field>
|
|
3034
|
+
<Field label="Tentativas extras (retry)">
|
|
3035
|
+
<Input
|
|
3036
|
+
type="number"
|
|
3037
|
+
value={actionForm.http_retry_count}
|
|
3038
|
+
onChange={(event) =>
|
|
3039
|
+
setActionForm({
|
|
3040
|
+
...actionForm,
|
|
3041
|
+
http_retry_count: Number(event.target.value),
|
|
3042
|
+
})
|
|
3043
|
+
}
|
|
3044
|
+
placeholder="0"
|
|
3045
|
+
/>
|
|
3046
|
+
</Field>
|
|
3047
|
+
<Field label="Headers (JSON)">
|
|
3048
|
+
<Textarea
|
|
3049
|
+
value={actionForm.http_headers}
|
|
3050
|
+
onChange={(event) =>
|
|
3051
|
+
setActionForm({
|
|
3052
|
+
...actionForm,
|
|
3053
|
+
http_headers: event.target.value,
|
|
3054
|
+
})
|
|
3055
|
+
}
|
|
3056
|
+
className="font-mono text-xs"
|
|
3057
|
+
rows={3}
|
|
3058
|
+
placeholder='{"Authorization": "Bearer {{token}}"}'
|
|
3059
|
+
/>
|
|
3060
|
+
</Field>
|
|
3061
|
+
<Field label="Query Params (JSON)">
|
|
3062
|
+
<Textarea
|
|
3063
|
+
value={actionForm.http_query}
|
|
3064
|
+
onChange={(event) =>
|
|
3065
|
+
setActionForm({
|
|
3066
|
+
...actionForm,
|
|
3067
|
+
http_query: event.target.value,
|
|
3068
|
+
})
|
|
3069
|
+
}
|
|
3070
|
+
className="font-mono text-xs"
|
|
3071
|
+
rows={3}
|
|
3072
|
+
placeholder='{"search": "{{query}}"}'
|
|
3073
|
+
/>
|
|
3074
|
+
</Field>
|
|
3075
|
+
<div className="md:col-span-2">
|
|
3076
|
+
<Field label="Body">
|
|
3077
|
+
<Textarea
|
|
3078
|
+
value={actionForm.http_body}
|
|
3079
|
+
onChange={(event) =>
|
|
3080
|
+
setActionForm({
|
|
3081
|
+
...actionForm,
|
|
3082
|
+
http_body: event.target.value,
|
|
3083
|
+
})
|
|
3084
|
+
}
|
|
3085
|
+
className="font-mono text-xs"
|
|
3086
|
+
rows={5}
|
|
3087
|
+
placeholder='{"userId": "{{userId}}", "event": "{{type}}"}'
|
|
3088
|
+
/>
|
|
3089
|
+
</Field>
|
|
3090
|
+
</div>
|
|
3091
|
+
</div>
|
|
3092
|
+
)}
|
|
3093
|
+
|
|
3094
|
+
{actionForm.type === 'internal_api' && (
|
|
3095
|
+
<div className="grid gap-3 md:grid-cols-2">
|
|
3096
|
+
<Field label="Usuário (ID) *">
|
|
3097
|
+
<Input
|
|
3098
|
+
type="number"
|
|
3099
|
+
value={actionForm.internal_api_user_id ?? ''}
|
|
3100
|
+
onChange={(event) =>
|
|
3101
|
+
setActionForm({
|
|
3102
|
+
...actionForm,
|
|
3103
|
+
internal_api_user_id: event.target.value
|
|
3104
|
+
? Number(event.target.value)
|
|
3105
|
+
: null,
|
|
3106
|
+
})
|
|
3107
|
+
}
|
|
3108
|
+
placeholder="ID do usuário dono do token"
|
|
3109
|
+
/>
|
|
3110
|
+
</Field>
|
|
3111
|
+
<Field label="Token de autenticação *">
|
|
3112
|
+
<div className="flex items-start gap-2">
|
|
3113
|
+
<Input
|
|
3114
|
+
type="password"
|
|
3115
|
+
value={actionForm.internal_api_token}
|
|
3116
|
+
onChange={(event) =>
|
|
3117
|
+
setActionForm({
|
|
3118
|
+
...actionForm,
|
|
3119
|
+
internal_api_token: event.target.value,
|
|
3120
|
+
})
|
|
3121
|
+
}
|
|
3122
|
+
placeholder="hedhog_api_..."
|
|
3123
|
+
className="flex-1"
|
|
3124
|
+
/>
|
|
3125
|
+
<Button
|
|
3126
|
+
type="button"
|
|
3127
|
+
variant="outline"
|
|
3128
|
+
size="sm"
|
|
3129
|
+
disabled={!actionForm.internal_api_user_id}
|
|
3130
|
+
onClick={async () => {
|
|
3131
|
+
if (!actionForm.internal_api_user_id) return;
|
|
3132
|
+
try {
|
|
3133
|
+
const response = await request<{
|
|
3134
|
+
rawToken: string;
|
|
3135
|
+
}>({
|
|
3136
|
+
url: '/webhook-integration/user-tokens',
|
|
3137
|
+
method: 'POST',
|
|
3138
|
+
data: {
|
|
3139
|
+
userId: actionForm.internal_api_user_id,
|
|
3140
|
+
name: `webhook-action-${Date.now()}`,
|
|
3141
|
+
},
|
|
3142
|
+
});
|
|
3143
|
+
const raw = response.data?.rawToken;
|
|
3144
|
+
if (raw) {
|
|
3145
|
+
setActionForm({
|
|
3146
|
+
...actionForm,
|
|
3147
|
+
internal_api_token: raw,
|
|
3148
|
+
});
|
|
3149
|
+
setGeneratedToken(raw);
|
|
3150
|
+
toast.success(
|
|
3151
|
+
'Token gerado! Copie-o antes de salvar.'
|
|
3152
|
+
);
|
|
3153
|
+
}
|
|
3154
|
+
} catch {
|
|
3155
|
+
toast.error('Erro ao gerar token');
|
|
3156
|
+
}
|
|
3157
|
+
}}
|
|
3158
|
+
>
|
|
3159
|
+
Gerar
|
|
3160
|
+
</Button>
|
|
3161
|
+
</div>
|
|
3162
|
+
</Field>
|
|
3163
|
+
{generatedToken && (
|
|
3164
|
+
<div className="md:col-span-2 rounded border border-yellow-300 bg-yellow-50 p-3 text-xs text-yellow-800">
|
|
3165
|
+
<strong>Token gerado (exibido apenas uma vez):</strong>
|
|
3166
|
+
<div className="mt-1 flex items-center gap-2 font-mono break-all">
|
|
3167
|
+
<span className="flex-1">{generatedToken}</span>
|
|
3168
|
+
<Button
|
|
3169
|
+
type="button"
|
|
3170
|
+
variant="ghost"
|
|
3171
|
+
size="sm"
|
|
3172
|
+
onClick={() => {
|
|
3173
|
+
void navigator.clipboard.writeText(
|
|
3174
|
+
generatedToken
|
|
3175
|
+
);
|
|
3176
|
+
toast.success('Token copiado!');
|
|
3177
|
+
}}
|
|
3178
|
+
>
|
|
3179
|
+
Copiar
|
|
3180
|
+
</Button>
|
|
3181
|
+
</div>
|
|
3182
|
+
</div>
|
|
3183
|
+
)}
|
|
3184
|
+
<Field label="Método HTTP">
|
|
3185
|
+
<Select
|
|
3186
|
+
value={actionForm.internal_api_method}
|
|
3187
|
+
onValueChange={(value) =>
|
|
3188
|
+
setActionForm({
|
|
3189
|
+
...actionForm,
|
|
3190
|
+
internal_api_method: value,
|
|
3191
|
+
})
|
|
3192
|
+
}
|
|
3193
|
+
>
|
|
3194
|
+
<SelectTrigger className="w-full">
|
|
3195
|
+
<SelectValue />
|
|
3196
|
+
</SelectTrigger>
|
|
3197
|
+
<SelectContent>
|
|
3198
|
+
{['GET', 'POST', 'PUT', 'PATCH', 'DELETE'].map(
|
|
3199
|
+
(m) => (
|
|
3200
|
+
<SelectItem key={m} value={m}>
|
|
3201
|
+
{m}
|
|
3202
|
+
</SelectItem>
|
|
3203
|
+
)
|
|
3204
|
+
)}
|
|
3205
|
+
</SelectContent>
|
|
3206
|
+
</Select>
|
|
3207
|
+
</Field>
|
|
3208
|
+
<Field label="Path / Endpoint *">
|
|
3209
|
+
<Select
|
|
3210
|
+
value={actionForm.internal_api_path}
|
|
3211
|
+
onValueChange={(value) => {
|
|
3212
|
+
const route = internalRoutes.find(
|
|
3213
|
+
(r) => r.url === value
|
|
3214
|
+
);
|
|
3215
|
+
setActionForm({
|
|
3216
|
+
...actionForm,
|
|
3217
|
+
internal_api_path: value,
|
|
3218
|
+
internal_api_method:
|
|
3219
|
+
route?.method || actionForm.internal_api_method,
|
|
3220
|
+
});
|
|
3221
|
+
}}
|
|
3222
|
+
>
|
|
3223
|
+
<SelectTrigger className="w-full">
|
|
3224
|
+
<SelectValue placeholder="Selecione um endpoint" />
|
|
3225
|
+
</SelectTrigger>
|
|
3226
|
+
<SelectContent>
|
|
3227
|
+
{internalRoutes.map((route) => (
|
|
3228
|
+
<SelectItem key={route.id} value={route.url}>
|
|
3229
|
+
<span className="mr-2 font-mono text-xs text-muted-foreground">
|
|
3230
|
+
{route.method}
|
|
3231
|
+
</span>
|
|
3232
|
+
{route.url}
|
|
3233
|
+
</SelectItem>
|
|
3234
|
+
))}
|
|
3235
|
+
</SelectContent>
|
|
3236
|
+
</Select>
|
|
3237
|
+
</Field>
|
|
3238
|
+
<Field label="Query Params (JSON)">
|
|
3239
|
+
<Textarea
|
|
3240
|
+
value={actionForm.internal_api_query}
|
|
3241
|
+
onChange={(event) =>
|
|
3242
|
+
setActionForm({
|
|
3243
|
+
...actionForm,
|
|
3244
|
+
internal_api_query: event.target.value,
|
|
3245
|
+
})
|
|
3246
|
+
}
|
|
3247
|
+
className="font-mono text-xs"
|
|
3248
|
+
rows={3}
|
|
3249
|
+
placeholder='{"page": "1"}'
|
|
3250
|
+
/>
|
|
3251
|
+
</Field>
|
|
3252
|
+
<Field label="Body (JSON)">
|
|
3253
|
+
<Textarea
|
|
3254
|
+
value={actionForm.internal_api_body}
|
|
3255
|
+
onChange={(event) =>
|
|
3256
|
+
setActionForm({
|
|
3257
|
+
...actionForm,
|
|
3258
|
+
internal_api_body: event.target.value,
|
|
3259
|
+
})
|
|
3260
|
+
}
|
|
3261
|
+
className="font-mono text-xs"
|
|
3262
|
+
rows={3}
|
|
3263
|
+
placeholder='{"userId": "{{userId}}"}'
|
|
3264
|
+
/>
|
|
3265
|
+
</Field>
|
|
3266
|
+
</div>
|
|
3267
|
+
)}
|
|
3268
|
+
|
|
3269
|
+
{actionForm.type === 'app_command' && (
|
|
3270
|
+
<div className="grid gap-3">
|
|
3271
|
+
<Field label="Comando *">
|
|
3272
|
+
<Select
|
|
3273
|
+
value={actionForm.app_command_slug}
|
|
3274
|
+
onValueChange={(value) =>
|
|
3275
|
+
setActionForm({
|
|
3276
|
+
...actionForm,
|
|
3277
|
+
app_command_slug: value,
|
|
3278
|
+
})
|
|
3279
|
+
}
|
|
3280
|
+
>
|
|
3281
|
+
<SelectTrigger className="w-full">
|
|
3282
|
+
<SelectValue placeholder="Selecione um comando" />
|
|
3283
|
+
</SelectTrigger>
|
|
3284
|
+
<SelectContent>
|
|
3285
|
+
{appCommands.map((cmd) => (
|
|
3286
|
+
<SelectItem key={cmd.slug} value={cmd.slug}>
|
|
3287
|
+
{cmd.name}
|
|
3288
|
+
</SelectItem>
|
|
3289
|
+
))}
|
|
3290
|
+
</SelectContent>
|
|
3291
|
+
</Select>
|
|
3292
|
+
</Field>
|
|
3293
|
+
{actionForm.app_command_slug &&
|
|
3294
|
+
(() => {
|
|
3295
|
+
const cmd = appCommands.find(
|
|
3296
|
+
(c) => c.slug === actionForm.app_command_slug
|
|
3297
|
+
);
|
|
3298
|
+
return cmd ? (
|
|
3299
|
+
<p className="text-sm text-muted-foreground">
|
|
3300
|
+
{cmd.description}
|
|
3301
|
+
</p>
|
|
3302
|
+
) : null;
|
|
3303
|
+
})()}
|
|
3304
|
+
<Field label="Parâmetros (JSON)">
|
|
3305
|
+
<Textarea
|
|
3306
|
+
value={actionForm.app_command_params}
|
|
3307
|
+
onChange={(event) =>
|
|
3308
|
+
setActionForm({
|
|
3309
|
+
...actionForm,
|
|
3310
|
+
app_command_params: event.target.value,
|
|
3311
|
+
})
|
|
3312
|
+
}
|
|
3313
|
+
className="font-mono text-xs"
|
|
3314
|
+
rows={5}
|
|
3315
|
+
placeholder="{}"
|
|
3316
|
+
/>
|
|
3317
|
+
</Field>
|
|
3318
|
+
{actionForm.app_command_slug &&
|
|
3319
|
+
(() => {
|
|
3320
|
+
const cmd = appCommands.find(
|
|
3321
|
+
(c) => c.slug === actionForm.app_command_slug
|
|
3322
|
+
);
|
|
3323
|
+
return cmd?.inputSchema ? (
|
|
3324
|
+
<div className="rounded border bg-muted/40 p-2">
|
|
3325
|
+
<p className="mb-1 text-xs font-medium text-muted-foreground">
|
|
3326
|
+
Schema esperado:
|
|
3327
|
+
</p>
|
|
3328
|
+
<pre className="whitespace-pre-wrap break-all font-mono text-xs">
|
|
3329
|
+
{JSON.stringify(cmd.inputSchema, null, 2)}
|
|
3330
|
+
</pre>
|
|
3331
|
+
</div>
|
|
3332
|
+
) : null;
|
|
3333
|
+
})()}
|
|
3334
|
+
</div>
|
|
3335
|
+
)}
|
|
3336
|
+
|
|
2769
3337
|
<SheetActions
|
|
2770
3338
|
onSave={saveAction}
|
|
2771
3339
|
onCancel={() => setActionSheetOpen(false)}
|
|
@@ -2976,7 +3544,7 @@ export default function IntegrationsWebhooksPage() {
|
|
|
2976
3544
|
}}
|
|
2977
3545
|
>
|
|
2978
3546
|
<ResizableSheetContent
|
|
2979
|
-
sheetId="webhooks-
|
|
3547
|
+
sheetId="webhooks-integration-profile-editor"
|
|
2980
3548
|
defaultWidth={896}
|
|
2981
3549
|
>
|
|
2982
3550
|
<SheetHeader>
|
|
@@ -3618,7 +4186,15 @@ function SortableIncomingActionRow({
|
|
|
3618
4186
|
<TableCell>{action.name}</TableCell>
|
|
3619
4187
|
<TableCell>
|
|
3620
4188
|
<Badge variant="secondary">
|
|
3621
|
-
{action.type === 'email'
|
|
4189
|
+
{action.type === 'email'
|
|
4190
|
+
? t('email')
|
|
4191
|
+
: action.type === 'whatsapp_evolution'
|
|
4192
|
+
? t('whatsapp')
|
|
4193
|
+
: action.type === 'http_request'
|
|
4194
|
+
? 'HTTP Request'
|
|
4195
|
+
: action.type === 'internal_api'
|
|
4196
|
+
? 'Internal API'
|
|
4197
|
+
: 'App Command'}
|
|
3622
4198
|
</Badge>
|
|
3623
4199
|
</TableCell>
|
|
3624
4200
|
<TableCell>{action.order}</TableCell>
|