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

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 {
  BaseFieldDefinition,
  BaseFieldDefinition$inboundSchema,
} from "./basefielddefinition.js";
import { FieldGroup, FieldGroup$inboundSchema } from "./fieldgroup.js";

export type ListChatCompletionFieldsResponse = {
  fieldDefinitions: Array<BaseFieldDefinition>;
  fieldGroups: Array<FieldGroup>;
};

/** @internal */
export const ListChatCompletionFieldsResponse$inboundSchema: z.ZodType<
  ListChatCompletionFieldsResponse,
  unknown
> = z.object({
  field_definitions: z.array(BaseFieldDefinition$inboundSchema),
  field_groups: z.array(FieldGroup$inboundSchema),
}).transform((v) => {
  return remap$(v, {
    "field_definitions": "fieldDefinitions",
    "field_groups": "fieldGroups",
  });
});

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