/*
 * 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 { discriminatedUnion } from "../../types/discriminatedUnion.js";
import { APIKeyAuth$inboundSchema, APIKeyAuth$outboundSchema, } from "./apikeyauth.js";
import { OAuth2TokenAuth$inboundSchema, OAuth2TokenAuth$outboundSchema, } from "./oauth2tokenauth.js";
import { ToolConfiguration$inboundSchema, ToolConfiguration$outboundSchema, } from "./toolconfiguration.js";
/** @internal */
export const Authorization$inboundSchema = discriminatedUnion("type", {
    ["api-key"]: APIKeyAuth$inboundSchema,
    ["oauth2-token"]: OAuth2TokenAuth$inboundSchema,
});
/** @internal */
export const Authorization$outboundSchema = z.union([APIKeyAuth$outboundSchema, OAuth2TokenAuth$outboundSchema]);
export function authorizationToJSON(authorization) {
    return JSON.stringify(Authorization$outboundSchema.parse(authorization));
}
export function authorizationFromJSON(jsonString) {
    return safeParse(jsonString, (x) => Authorization$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Authorization' from JSON`);
}
/** @internal */
export const CustomConnector$inboundSchema = 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 const CustomConnector$outboundSchema = 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) {
    return JSON.stringify(CustomConnector$outboundSchema.parse(customConnector));
}
export function customConnectorFromJSON(jsonString) {
    return safeParse(jsonString, (x) => CustomConnector$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CustomConnector' from JSON`);
}
//# sourceMappingURL=customconnector.js.map