From 4ab0da6b033717583dce8faab5093ebe15e9708f Mon Sep 17 00:00:00 2001 From: x032205 Date: Fri, 18 Jul 2025 16:22:51 -0400 Subject: [PATCH] Fix type stuff --- .../app-connection/app-connection-schemas.ts | 32 +++++++++++-------- .../GenericAppConnectionFields.tsx | 5 ++- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/backend/src/services/app-connection/app-connection-schemas.ts b/backend/src/services/app-connection/app-connection-schemas.ts index de9b4f546..92fc83123 100644 --- a/backend/src/services/app-connection/app-connection-schemas.ts +++ b/backend/src/services/app-connection/app-connection-schemas.ts @@ -30,14 +30,16 @@ export const GenericCreateAppConnectionFieldsSchema = ( .describe(AppConnections.CREATE(app).description), isPlatformManagedCredentials: supportsPlatformManagedCredentials ? z.boolean().optional().default(false).describe(AppConnections.CREATE(app).isPlatformManagedCredentials) - : z.literal(false).optional().describe(`Not supported for ${APP_CONNECTION_NAME_MAP[app]} Connections.`), - gatewayId: supportsGateways - ? z - .preprocess((val) => (val === "" ? null : val), z.string().uuid().nullish()) - .describe("The Gateway ID to use for this connection.") : z - .union([z.literal(undefined), z.literal("")]) - .transform((v) => (v === "" ? undefined : v)) + .literal(false, { + errorMap: () => ({ message: `Not supported for ${APP_CONNECTION_NAME_MAP[app]} Connections` }) + }) + .optional() + .describe(`Not supported for ${APP_CONNECTION_NAME_MAP[app]} Connections.`), + gatewayId: supportsGateways + ? z.string().uuid().nullish().describe("The Gateway ID to use for this connection.") + : z + .undefined({ message: `Not supported for ${APP_CONNECTION_NAME_MAP[app]} Connections` }) .describe(`Not supported for ${APP_CONNECTION_NAME_MAP[app]} Connections.`) }); @@ -55,13 +57,15 @@ export const GenericUpdateAppConnectionFieldsSchema = ( .describe(AppConnections.UPDATE(app).description), isPlatformManagedCredentials: supportsPlatformManagedCredentials ? z.boolean().optional().describe(AppConnections.UPDATE(app).isPlatformManagedCredentials) - : z.literal(false).optional().describe(`Not supported for ${APP_CONNECTION_NAME_MAP[app]} Connections.`), - gatewayId: supportsGateways - ? z - .preprocess((val) => (val === "" ? null : val), z.string().uuid().nullish()) - .describe("The Gateway ID to use for this connection.") : z - .union([z.literal(undefined), z.literal("")]) - .transform((v) => (v === "" ? undefined : v)) + .literal(false, { + errorMap: () => ({ message: `Not supported for ${APP_CONNECTION_NAME_MAP[app]} Connections` }) + }) + .optional() + .describe(`Not supported for ${APP_CONNECTION_NAME_MAP[app]} Connections.`), + gatewayId: supportsGateways + ? z.string().uuid().nullish().describe("The Gateway ID to use for this connection.") + : z + .undefined({ message: `Not supported for ${APP_CONNECTION_NAME_MAP[app]} Connections` }) .describe(`Not supported for ${APP_CONNECTION_NAME_MAP[app]} Connections.`) }); diff --git a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/GenericAppConnectionFields.tsx b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/GenericAppConnectionFields.tsx index 6508b28d0..e7d9cf80c 100644 --- a/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/GenericAppConnectionFields.tsx +++ b/frontend/src/pages/organization/AppConnections/AppConnectionsPage/components/AppConnectionForm/GenericAppConnectionFields.tsx @@ -7,7 +7,10 @@ import { slugSchema } from "@app/lib/schemas"; export const genericAppConnectionFieldsSchema = z.object({ name: slugSchema({ min: 1, max: 64, field: "Name" }), description: z.string().trim().max(256, "Description cannot exceed 256 characters").nullish(), - gatewayId: z.string().nullish() + gatewayId: z + .string() + .nullish() + .transform((v) => (v === "" ? null : v)) }); export const GenericAppConnectionsFields = () => {