Skip to content

Commit

Permalink
fix: using parseOrElse instead of regular JSON.parse
Browse files Browse the repository at this point in the history
  • Loading branch information
alashchev17 committed Dec 9, 2024
1 parent c3a8e4a commit 642c51e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
12 changes: 7 additions & 5 deletions src/components/IntegrationsView/IntegrationsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import { useSaveIntegrationData } from "../../hooks/useSaveIntegrationData";
import {
dockerApi,
Integration,
IntegrationPrimitive,
integrationsApi,
IntegrationWithIconRecord,
IntegrationWithIconResponse,
Expand All @@ -43,6 +42,7 @@ import styles from "./IntegrationsView.module.css";
import { iconMap } from "./icons/iconMap";
import { LeftRightPadding } from "../../features/Integrations/Integrations";
import { IntermediateIntegration } from "./IntermediateIntegration";
import { parseOrElse } from "../../utils";

type IntegrationViewProps = {
integrationsMap?: IntegrationWithIconResponse;
Expand Down Expand Up @@ -288,15 +288,17 @@ export const IntegrationsView: FC<IntegrationViewProps> = ({
break;
case "tool":
// TODO: adjust types for data, it's not IntegrationPrimitive
acc[key] = JSON.parse(
acc[key] = parseOrElse<Integration["integr_values"][number]>(
rawFormValues[key] as string,
) as IntegrationPrimitive;
{},
);
break;
case "output":
// TODO: adjust types for data, it's not IntegrationPrimitive
acc[key] = JSON.parse(
acc[key] = parseOrElse<Integration["integr_values"][number]>(
rawFormValues[key] as string,
) as IntegrationPrimitive;
{},
);
break;
default:
acc[key] = rawFormValues[key] as string;
Expand Down
5 changes: 4 additions & 1 deletion src/services/refact/integrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,10 @@ export type Integration = {
integr_name: string;
integr_config_path: string;
integr_schema: IntegrationSchema;
integr_values: Record<string, IntegrationPrimitive | Record<string, boolean>>;
integr_values: Record<
string,
IntegrationPrimitive | Record<string, boolean> | Record<string, unknown>
>;
error_log: null | YamlError[];
};

Expand Down

0 comments on commit 642c51e

Please sign in to comment.