@hed-hog/core 0.0.356 → 0.0.359
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
|
@@ -61,7 +61,7 @@ import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
|
|
61
61
|
import { usePagination } from '@/hooks/use-pagination';
|
|
62
62
|
import { formatDate } from '@/lib/format-date';
|
|
63
63
|
import { useApp } from '@hed-hog/next-app-provider';
|
|
64
|
-
import { Eye, EyeOff, Pencil, PlugZap, Trash2 } from 'lucide-react';
|
|
64
|
+
import { Check, Copy, Eye, EyeOff, Pencil, PlugZap, Plus, Trash2, X } from 'lucide-react';
|
|
65
65
|
import { useTranslations } from 'next-intl';
|
|
66
66
|
import { useEffect, useRef, useState } from 'react';
|
|
67
67
|
import { toast } from 'sonner';
|
|
@@ -104,7 +104,7 @@ type ProfileForm = {
|
|
|
104
104
|
slug: string;
|
|
105
105
|
type_id: string;
|
|
106
106
|
provider_id: string;
|
|
107
|
-
config: Record<string, string | boolean | number>;
|
|
107
|
+
config: Record<string, string | boolean | number | string[]>;
|
|
108
108
|
is_active: boolean;
|
|
109
109
|
};
|
|
110
110
|
|
|
@@ -452,13 +452,6 @@ const PROVIDER_FIELDS: Record<string, FieldDef[]> = {
|
|
|
452
452
|
type: 'password',
|
|
453
453
|
required: true,
|
|
454
454
|
},
|
|
455
|
-
{
|
|
456
|
-
key: 'redirect_uri',
|
|
457
|
-
labelKey: 'fieldRedirectUri',
|
|
458
|
-
type: 'url',
|
|
459
|
-
required: true,
|
|
460
|
-
colSpan: true,
|
|
461
|
-
},
|
|
462
455
|
],
|
|
463
456
|
'github-oauth': [
|
|
464
457
|
{
|
|
@@ -494,12 +487,39 @@ const PROVIDER_FIELDS: Record<string, FieldDef[]> = {
|
|
|
494
487
|
required: true,
|
|
495
488
|
placeholder: 'common',
|
|
496
489
|
},
|
|
490
|
+
],
|
|
491
|
+
'facebook-oauth': [
|
|
497
492
|
{
|
|
498
|
-
key: '
|
|
499
|
-
labelKey: '
|
|
500
|
-
type: '
|
|
493
|
+
key: 'client_id',
|
|
494
|
+
labelKey: 'fieldClientId',
|
|
495
|
+
type: 'text',
|
|
496
|
+
required: true,
|
|
497
|
+
},
|
|
498
|
+
{
|
|
499
|
+
key: 'client_secret',
|
|
500
|
+
labelKey: 'fieldClientSecret',
|
|
501
|
+
type: 'password',
|
|
502
|
+
required: true,
|
|
503
|
+
},
|
|
504
|
+
],
|
|
505
|
+
'microsoft-entra-id-oauth': [
|
|
506
|
+
{
|
|
507
|
+
key: 'client_id',
|
|
508
|
+
labelKey: 'fieldClientId',
|
|
509
|
+
type: 'text',
|
|
510
|
+
required: true,
|
|
511
|
+
},
|
|
512
|
+
{
|
|
513
|
+
key: 'client_secret',
|
|
514
|
+
labelKey: 'fieldClientSecret',
|
|
515
|
+
type: 'password',
|
|
516
|
+
required: true,
|
|
517
|
+
},
|
|
518
|
+
{
|
|
519
|
+
key: 'tenant_id',
|
|
520
|
+
labelKey: 'fieldTenantId',
|
|
521
|
+
type: 'text',
|
|
501
522
|
required: true,
|
|
502
|
-
colSpan: true,
|
|
503
523
|
},
|
|
504
524
|
],
|
|
505
525
|
};
|
|
@@ -797,6 +817,7 @@ export default function IntegrationProfilesPage() {
|
|
|
797
817
|
const [visibleFields, setVisibleFields] = useState<Record<string, boolean>>(
|
|
798
818
|
{}
|
|
799
819
|
);
|
|
820
|
+
const [copiedUrlIndex, setCopiedUrlIndex] = useState<number | null>(null);
|
|
800
821
|
const [selectedProfileIds, setSelectedProfileIds] = useState<Set<number>>(
|
|
801
822
|
new Set()
|
|
802
823
|
);
|
|
@@ -826,6 +847,28 @@ export default function IntegrationProfilesPage() {
|
|
|
826
847
|
? (PROVIDER_FIELDS[selectedProvider.slug] ?? [])
|
|
827
848
|
: [];
|
|
828
849
|
|
|
850
|
+
const isOAuthProvider = (selectedProvider?.slug ?? '').endsWith('-oauth');
|
|
851
|
+
const oauthProviderName = isOAuthProvider
|
|
852
|
+
? selectedProvider!.slug.replace(/-oauth$/, '')
|
|
853
|
+
: '';
|
|
854
|
+
const appUrl =
|
|
855
|
+
typeof window !== 'undefined'
|
|
856
|
+
? window.location.origin
|
|
857
|
+
: String(getSettingValue?.('url') ?? '').replace(/\/+$/, '');
|
|
858
|
+
const defaultCallbackUrls =
|
|
859
|
+
isOAuthProvider && appUrl
|
|
860
|
+
? [
|
|
861
|
+
`${appUrl}/callback/${oauthProviderName}/login`,
|
|
862
|
+
`${appUrl}/callback/${oauthProviderName}/register`,
|
|
863
|
+
`${appUrl}/callback/${oauthProviderName}/connect`,
|
|
864
|
+
]
|
|
865
|
+
: [];
|
|
866
|
+
const callbackUrls: string[] = (() => {
|
|
867
|
+
const saved = formData.config.callback_urls;
|
|
868
|
+
if (Array.isArray(saved)) return saved as string[];
|
|
869
|
+
return defaultCallbackUrls;
|
|
870
|
+
})();
|
|
871
|
+
|
|
829
872
|
useEffect(() => {
|
|
830
873
|
request<IntegrationType[]>({
|
|
831
874
|
url: '/integration-profile/types',
|
|
@@ -868,13 +911,32 @@ export default function IntegrationProfilesPage() {
|
|
|
868
911
|
url: `/integration-profile/${profile.id}`,
|
|
869
912
|
method: 'GET',
|
|
870
913
|
});
|
|
914
|
+
const loadedConfig =
|
|
915
|
+
(data.config as Record<
|
|
916
|
+
string,
|
|
917
|
+
string | boolean | number | string[]
|
|
918
|
+
>) ?? {};
|
|
919
|
+
const providerSlug =
|
|
920
|
+
providers.find((p) => p.id === data.provider_id)?.slug ?? '';
|
|
921
|
+
if (
|
|
922
|
+
providerSlug.endsWith('-oauth') &&
|
|
923
|
+
!Array.isArray(loadedConfig.callback_urls)
|
|
924
|
+
) {
|
|
925
|
+
const pName = providerSlug.replace(/-oauth$/, '');
|
|
926
|
+
if (appUrl) {
|
|
927
|
+
loadedConfig.callback_urls = [
|
|
928
|
+
`${appUrl}/callback/${pName}/login`,
|
|
929
|
+
`${appUrl}/callback/${pName}/register`,
|
|
930
|
+
`${appUrl}/callback/${pName}/connect`,
|
|
931
|
+
];
|
|
932
|
+
}
|
|
933
|
+
}
|
|
871
934
|
setFormData({
|
|
872
935
|
name: data.name,
|
|
873
936
|
slug: data.slug,
|
|
874
937
|
type_id: String(data.type_id),
|
|
875
938
|
provider_id: String(data.provider_id),
|
|
876
|
-
config:
|
|
877
|
-
(data.config as Record<string, string | boolean | number>) ?? {},
|
|
939
|
+
config: loadedConfig,
|
|
878
940
|
is_active: data.is_active,
|
|
879
941
|
});
|
|
880
942
|
} catch {
|
|
@@ -1082,14 +1144,49 @@ export default function IntegrationProfilesPage() {
|
|
|
1082
1144
|
};
|
|
1083
1145
|
|
|
1084
1146
|
const handleProviderChange = (provider_id: string) => {
|
|
1085
|
-
|
|
1147
|
+
const provider = formTypeProviders.find((p) => String(p.id) === provider_id);
|
|
1148
|
+
const initialConfig: Record<string, string | boolean | number | string[]> = {};
|
|
1149
|
+
if (provider?.slug?.endsWith('-oauth')) {
|
|
1150
|
+
const pName = provider.slug.replace(/-oauth$/, '');
|
|
1151
|
+
initialConfig.callback_urls = appUrl
|
|
1152
|
+
? [
|
|
1153
|
+
`${appUrl}/callback/${pName}/login`,
|
|
1154
|
+
`${appUrl}/callback/${pName}/register`,
|
|
1155
|
+
`${appUrl}/callback/${pName}/connect`,
|
|
1156
|
+
]
|
|
1157
|
+
: [];
|
|
1158
|
+
}
|
|
1159
|
+
setFormData((p) => ({ ...p, provider_id, config: initialConfig }));
|
|
1086
1160
|
setVisibleFields({});
|
|
1087
1161
|
};
|
|
1088
1162
|
|
|
1089
|
-
const updateConfig = (key: string, value: string | boolean | number) => {
|
|
1163
|
+
const updateConfig = (key: string, value: string | boolean | number | string[]) => {
|
|
1090
1164
|
setFormData((p) => ({ ...p, config: { ...p.config, [key]: value } }));
|
|
1091
1165
|
};
|
|
1092
1166
|
|
|
1167
|
+
const updateCallbackUrl = (index: number, value: string) => {
|
|
1168
|
+
const urls = [...callbackUrls];
|
|
1169
|
+
urls[index] = value;
|
|
1170
|
+
setFormData((p) => ({ ...p, config: { ...p.config, callback_urls: urls } }));
|
|
1171
|
+
};
|
|
1172
|
+
|
|
1173
|
+
const addCallbackUrl = () => {
|
|
1174
|
+
setFormData((p) => ({
|
|
1175
|
+
...p,
|
|
1176
|
+
config: { ...p.config, callback_urls: [...callbackUrls, ''] },
|
|
1177
|
+
}));
|
|
1178
|
+
};
|
|
1179
|
+
|
|
1180
|
+
const removeCallbackUrl = (index: number) => {
|
|
1181
|
+
setFormData((p) => ({
|
|
1182
|
+
...p,
|
|
1183
|
+
config: {
|
|
1184
|
+
...p.config,
|
|
1185
|
+
callback_urls: callbackUrls.filter((_, i) => i !== index),
|
|
1186
|
+
},
|
|
1187
|
+
}));
|
|
1188
|
+
};
|
|
1189
|
+
|
|
1093
1190
|
const handleSubmit = async (event: React.FormEvent) => {
|
|
1094
1191
|
event.preventDefault();
|
|
1095
1192
|
if (!formData.type_id || !formData.provider_id) return;
|
|
@@ -1100,7 +1197,9 @@ export default function IntegrationProfilesPage() {
|
|
|
1100
1197
|
name: formData.name,
|
|
1101
1198
|
type_id: Number(formData.type_id),
|
|
1102
1199
|
provider_id: Number(formData.provider_id),
|
|
1103
|
-
config:
|
|
1200
|
+
config: isOAuthProvider
|
|
1201
|
+
? { ...formData.config, callback_urls: callbackUrls }
|
|
1202
|
+
: formData.config,
|
|
1104
1203
|
is_active: formData.is_active,
|
|
1105
1204
|
};
|
|
1106
1205
|
|
|
@@ -1608,6 +1707,75 @@ export default function IntegrationProfilesPage() {
|
|
|
1608
1707
|
</div>
|
|
1609
1708
|
)}
|
|
1610
1709
|
|
|
1710
|
+
{/* ── Callback URLs (OAuth only) ── */}
|
|
1711
|
+
{isOAuthProvider && (
|
|
1712
|
+
<div className="rounded-lg border">
|
|
1713
|
+
<div className="flex items-center justify-between border-b px-4 py-3">
|
|
1714
|
+
<div>
|
|
1715
|
+
<p className="text-sm font-semibold">
|
|
1716
|
+
{t('callbackUrlsSectionTitle')}
|
|
1717
|
+
</p>
|
|
1718
|
+
<p className="mt-0.5 text-xs text-muted-foreground">
|
|
1719
|
+
{t('callbackUrlsDescription')}
|
|
1720
|
+
</p>
|
|
1721
|
+
</div>
|
|
1722
|
+
<Button
|
|
1723
|
+
type="button"
|
|
1724
|
+
variant="outline"
|
|
1725
|
+
size="sm"
|
|
1726
|
+
onClick={addCallbackUrl}
|
|
1727
|
+
>
|
|
1728
|
+
<Plus className="mr-1.5 h-3.5 w-3.5" />
|
|
1729
|
+
{t('addCallbackUrl')}
|
|
1730
|
+
</Button>
|
|
1731
|
+
</div>
|
|
1732
|
+
<div className="space-y-2 p-4">
|
|
1733
|
+
{callbackUrls.length === 0 && (
|
|
1734
|
+
<p className="py-1 text-center text-sm text-muted-foreground">
|
|
1735
|
+
{t('noCallbackUrls')}
|
|
1736
|
+
</p>
|
|
1737
|
+
)}
|
|
1738
|
+
{callbackUrls.map((url, index) => (
|
|
1739
|
+
<div key={index} className="flex gap-2">
|
|
1740
|
+
<Input
|
|
1741
|
+
value={url}
|
|
1742
|
+
onChange={(e) => updateCallbackUrl(index, e.target.value)}
|
|
1743
|
+
placeholder={t('callbackUrlPlaceholder')}
|
|
1744
|
+
className="font-mono text-sm"
|
|
1745
|
+
/>
|
|
1746
|
+
<Button
|
|
1747
|
+
type="button"
|
|
1748
|
+
variant="ghost"
|
|
1749
|
+
size="icon"
|
|
1750
|
+
className="shrink-0"
|
|
1751
|
+
disabled={!url}
|
|
1752
|
+
onClick={() => {
|
|
1753
|
+
navigator.clipboard.writeText(url);
|
|
1754
|
+
setCopiedUrlIndex(index);
|
|
1755
|
+
setTimeout(() => setCopiedUrlIndex(null), 1500);
|
|
1756
|
+
}}
|
|
1757
|
+
>
|
|
1758
|
+
{copiedUrlIndex === index ? (
|
|
1759
|
+
<Check className="h-4 w-4 text-green-500" />
|
|
1760
|
+
) : (
|
|
1761
|
+
<Copy className="h-4 w-4" />
|
|
1762
|
+
)}
|
|
1763
|
+
</Button>
|
|
1764
|
+
<Button
|
|
1765
|
+
type="button"
|
|
1766
|
+
variant="ghost"
|
|
1767
|
+
size="icon"
|
|
1768
|
+
onClick={() => removeCallbackUrl(index)}
|
|
1769
|
+
className="shrink-0"
|
|
1770
|
+
>
|
|
1771
|
+
<X className="h-4 w-4" />
|
|
1772
|
+
</Button>
|
|
1773
|
+
</div>
|
|
1774
|
+
))}
|
|
1775
|
+
</div>
|
|
1776
|
+
</div>
|
|
1777
|
+
)}
|
|
1778
|
+
|
|
1611
1779
|
{/* ── Active ── */}
|
|
1612
1780
|
<div className="flex items-center justify-between rounded-md border px-4 py-3">
|
|
1613
1781
|
<p className="text-sm font-medium">{t('isActiveLabel')}</p>
|