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

import * as z from "zod/v3";
import { remap as remap$ } from "../../lib/primitives.js";
import { safeParse } from "../../lib/schemas.js";
import { ClosedEnum } from "../../types/enums.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
import {
  FTModelCapabilitiesOut,
  FTModelCapabilitiesOut$inboundSchema,
} from "./ftmodelcapabilitiesout.js";

export const CompletionFTModelOutObject = {
  Model: "model",
} as const;
export type CompletionFTModelOutObject = ClosedEnum<
  typeof CompletionFTModelOutObject
>;

export const ModelType = {
  Completion: "completion",
} as const;
export type ModelType = ClosedEnum<typeof ModelType>;

export type CompletionFTModelOut = {
  id: string;
  object: CompletionFTModelOutObject | undefined;
  created: number;
  ownedBy: string;
  workspaceId: string;
  root: string;
  rootVersion: string;
  archived: boolean;
  name?: string | null | undefined;
  description?: string | null | undefined;
  capabilities: FTModelCapabilitiesOut;
  maxContextLength: number | undefined;
  aliases?: Array<string> | undefined;
  job: string;
  modelType: ModelType | undefined;
};

/** @internal */
export const CompletionFTModelOutObject$inboundSchema: z.ZodNativeEnum<
  typeof CompletionFTModelOutObject
> = z.nativeEnum(CompletionFTModelOutObject);

/** @internal */
export const ModelType$inboundSchema: z.ZodNativeEnum<typeof ModelType> = z
  .nativeEnum(ModelType);

/** @internal */
export const CompletionFTModelOut$inboundSchema: z.ZodType<
  CompletionFTModelOut,
  z.ZodTypeDef,
  unknown
> = z.object({
  id: z.string(),
  object: CompletionFTModelOutObject$inboundSchema.default("model"),
  created: z.number().int(),
  owned_by: z.string(),
  workspace_id: z.string(),
  root: z.string(),
  root_version: z.string(),
  archived: z.boolean(),
  name: z.nullable(z.string()).optional(),
  description: z.nullable(z.string()).optional(),
  capabilities: FTModelCapabilitiesOut$inboundSchema,
  max_context_length: z.number().int().default(32768),
  aliases: z.array(z.string()).optional(),
  job: z.string(),
  model_type: ModelType$inboundSchema.default("completion"),
}).transform((v) => {
  return remap$(v, {
    "owned_by": "ownedBy",
    "workspace_id": "workspaceId",
    "root_version": "rootVersion",
    "max_context_length": "maxContextLength",
    "model_type": "modelType",
  });
});

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