From 44bbf7b410d4374632f21bc32be3f72b790802a0 Mon Sep 17 00:00:00 2001 From: "alexei.dolgolyov" Date: Wed, 25 Mar 2026 22:19:56 +0300 Subject: [PATCH] fix(service-integrations): resolve type errors and test failures - Fix CreateAppInput nullable types for integration fields - Add type casts in IntegrationWidget renderer dispatching - Guard decryptAppIntegration against missing fields in test mocks --- .../integration/IntegrationWidget.svelte | 22 +++++++++++++------ src/lib/server/services/appService.ts | 5 +++-- src/lib/types/app.ts | 4 ++-- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/lib/components/widget/integration/IntegrationWidget.svelte b/src/lib/components/widget/integration/IntegrationWidget.svelte index d9f2400..ac95074 100644 --- a/src/lib/components/widget/integration/IntegrationWidget.svelte +++ b/src/lib/components/widget/integration/IntegrationWidget.svelte @@ -5,7 +5,15 @@ import ProgressRenderer from './ProgressRenderer.svelte'; import AlertBannerRenderer from './AlertBannerRenderer.svelte'; import ChartRenderer from './ChartRenderer.svelte'; - import type { IntegrationData } from '$lib/server/integrations/types.js'; + import type { + IntegrationData, + StatCardData, + GaugeData, + ListData, + ProgressData, + AlertBannerData, + ChartData + } from '$lib/server/integrations/types.js'; interface Props { config: { @@ -61,17 +69,17 @@ {:else if integrationData} {#if integrationData.renderer === 'stat-card'} - + {:else if integrationData.renderer === 'gauge'} - + {:else if integrationData.renderer === 'list'} - + {:else if integrationData.renderer === 'progress'} - + {:else if integrationData.renderer === 'alert-banner'} - + {:else if integrationData.renderer === 'chart'} - + {:else}
Unknown renderer: {integrationData.renderer}
{/if} diff --git a/src/lib/server/services/appService.ts b/src/lib/server/services/appService.ts index 6defeeb..2269de5 100644 --- a/src/lib/server/services/appService.ts +++ b/src/lib/server/services/appService.ts @@ -2,10 +2,11 @@ import { prisma } from '../prisma.js'; import type { CreateAppInput, UpdateAppInput } from '$lib/types/app.js'; import { encrypt, tryDecrypt } from '../integrations/encryption.js'; -function decryptAppIntegration(app: T): T { +function decryptAppIntegration>(app: T): T { + if (!('integrationConfig' in app) || !app.integrationConfig) return app; return { ...app, - integrationConfig: tryDecrypt(app.integrationConfig) + integrationConfig: tryDecrypt(app.integrationConfig as string) }; } diff --git a/src/lib/types/app.ts b/src/lib/types/app.ts index b66c85e..b598e5f 100644 --- a/src/lib/types/app.ts +++ b/src/lib/types/app.ts @@ -35,8 +35,8 @@ export interface CreateAppInput { readonly healthcheckMethod?: HealthcheckMethod; readonly healthcheckExpectedStatus?: number; readonly healthcheckTimeout?: number; - readonly integrationType?: string; - readonly integrationConfig?: string; + readonly integrationType?: string | null; + readonly integrationConfig?: string | null; readonly integrationEnabled?: boolean; readonly createdById?: string; }