/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 * @generated-id: 262fdf294dc4
 */

import * as z from "zod/v4";
import { remap as remap$ } from "../../lib/primitives.js";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
import {
  ConnectionConfigType,
  ConnectionConfigType$inboundSchema,
} from "./connectionconfigtype.js";

export type PublicConnectionConfig = {
  type?: ConnectionConfigType | undefined;
  baseUrl?: string | null | undefined;
  headers?: { [k: string]: string } | null | undefined;
  signed?: boolean | null | undefined;
};

/** @internal */
export const PublicConnectionConfig$inboundSchema: z.ZodType<
  PublicConnectionConfig,
  unknown
> = z.object({
  type: ConnectionConfigType$inboundSchema.optional(),
  base_url: z.nullable(z.string()).optional(),
  headers: z.nullable(z.record(z.string(), z.string())).optional(),
  signed: z.nullable(z.boolean()).optional(),
}).transform((v) => {
  return remap$(v, {
    "base_url": "baseUrl",
  });
});

export function publicConnectionConfigFromJSON(
  jsonString: string,
): SafeParseResult<PublicConnectionConfig, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => PublicConnectionConfig$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'PublicConnectionConfig' from JSON`,
  );
}
