/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: 269e79d01823 */ import * as z from "zod/v4"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import * as discriminatedUnionTypes from "../../types/discriminatedUnion.js"; import { discriminatedUnion } from "../../types/discriminatedUnion.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { APIKeyAuth, APIKeyAuth$inboundSchema, APIKeyAuth$Outbound, APIKeyAuth$outboundSchema, } from "./apikeyauth.js"; import { OAuth2TokenAuth, OAuth2TokenAuth$inboundSchema, OAuth2TokenAuth$Outbound, OAuth2TokenAuth$outboundSchema, } from "./oauth2tokenauth.js"; import { ToolConfiguration, ToolConfiguration$inboundSchema, ToolConfiguration$Outbound, ToolConfiguration$outboundSchema, } from "./toolconfiguration.js"; export type Authorization = | APIKeyAuth | OAuth2TokenAuth | discriminatedUnionTypes.Unknown<"type">; export type CustomConnector = { type: "connector"; connectorId: string; authorization?: | APIKeyAuth | OAuth2TokenAuth | discriminatedUnionTypes.Unknown<"type"> | null | undefined; toolConfiguration?: ToolConfiguration | null | undefined; }; /** @internal */ export const Authorization$inboundSchema: z.ZodType = discriminatedUnion("type", { ["api-key"]: APIKeyAuth$inboundSchema, ["oauth2-token"]: OAuth2TokenAuth$inboundSchema, }); /** @internal */ export type Authorization$Outbound = | APIKeyAuth$Outbound | OAuth2TokenAuth$Outbound; /** @internal */ export const Authorization$outboundSchema: z.ZodType< Authorization$Outbound, Authorization > = z.union([APIKeyAuth$outboundSchema, OAuth2TokenAuth$outboundSchema]); export function authorizationToJSON(authorization: Authorization): string { return JSON.stringify(Authorization$outboundSchema.parse(authorization)); } export function authorizationFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Authorization$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Authorization' from JSON`, ); } /** @internal */ export const CustomConnector$inboundSchema: z.ZodType< CustomConnector, unknown > = z.object({ type: z.literal("connector"), connector_id: z.string(), authorization: z.nullable( discriminatedUnion("type", { ["api-key"]: APIKeyAuth$inboundSchema, ["oauth2-token"]: OAuth2TokenAuth$inboundSchema, }), ).optional(), tool_configuration: z.nullable(ToolConfiguration$inboundSchema).optional(), }).transform((v) => { return remap$(v, { "connector_id": "connectorId", "tool_configuration": "toolConfiguration", }); }); /** @internal */ export type CustomConnector$Outbound = { type: "connector"; connector_id: string; authorization?: | APIKeyAuth$Outbound | OAuth2TokenAuth$Outbound | null | undefined; tool_configuration?: ToolConfiguration$Outbound | null | undefined; }; /** @internal */ export const CustomConnector$outboundSchema: z.ZodType< CustomConnector$Outbound, CustomConnector > = z.object({ type: z.literal("connector"), connectorId: z.string(), authorization: z.nullable( z.union([APIKeyAuth$outboundSchema, OAuth2TokenAuth$outboundSchema]), ).optional(), toolConfiguration: z.nullable(ToolConfiguration$outboundSchema).optional(), }).transform((v) => { return remap$(v, { connectorId: "connector_id", toolConfiguration: "tool_configuration", }); }); export function customConnectorToJSON( customConnector: CustomConnector, ): string { return JSON.stringify(CustomConnector$outboundSchema.parse(customConnector)); } export function customConnectorFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CustomConnector$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CustomConnector' from JSON`, ); }