/* * 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 { BatchErrors, BatchErrors$inboundSchema, BatchErrors$Outbound, BatchErrors$outboundSchema, } from "./batcherrors.js"; import { RequestCounts, RequestCounts$inboundSchema, RequestCounts$Outbound, RequestCounts$outboundSchema, } from "./requestcounts.js"; export const BatchObjectStatus = { Validating: "validating", Failed: "failed", InProgress: "in_progress", Finalizing: "finalizing", Completed: "completed", Expired: "expired", Cancelling: "cancelling", Cancelled: "cancelled", } as const; export type BatchObjectStatus = ClosedEnum; export type BatchObject = { id: string; object: "batch"; endpoint: string; errors?: BatchErrors | null | undefined; inputFileId: string; completionWindow: string; status: BatchObjectStatus; outputFileId?: string | null | undefined; errorFileId?: string | null | undefined; createdAt: number; inProgressAt?: number | null | undefined; expiresAt?: number | null | undefined; finalizingAt?: number | null | undefined; completedAt?: number | null | undefined; failedAt?: number | null | undefined; expiredAt?: number | null | undefined; cancellingAt?: number | null | undefined; cancelledAt?: number | null | undefined; requestCounts: RequestCounts; metadata?: { [k: string]: string } | null | undefined; }; /** @internal */ export const BatchObjectStatus$inboundSchema: z.ZodNativeEnum< typeof BatchObjectStatus > = z.nativeEnum(BatchObjectStatus); /** @internal */ export const BatchObjectStatus$outboundSchema: z.ZodNativeEnum< typeof BatchObjectStatus > = BatchObjectStatus$inboundSchema; /** @internal */ export const BatchObject$inboundSchema: z.ZodType< BatchObject, z.ZodTypeDef, unknown > = z.object({ id: z.string(), object: z.literal("batch"), endpoint: z.string(), errors: z.nullable(BatchErrors$inboundSchema).optional(), input_file_id: z.string(), completion_window: z.string(), status: BatchObjectStatus$inboundSchema, output_file_id: z.nullable(z.string()).optional(), error_file_id: z.nullable(z.string()).optional(), created_at: z.number().int(), in_progress_at: z.nullable(z.number().int()).optional(), expires_at: z.nullable(z.number().int()).optional(), finalizing_at: z.nullable(z.number().int()).optional(), completed_at: z.nullable(z.number().int()).optional(), failed_at: z.nullable(z.number().int()).optional(), expired_at: z.nullable(z.number().int()).optional(), cancelling_at: z.nullable(z.number().int()).optional(), cancelled_at: z.nullable(z.number().int()).optional(), request_counts: RequestCounts$inboundSchema, metadata: z.nullable(z.record(z.string())).optional(), }).transform((v) => { return remap$(v, { "input_file_id": "inputFileId", "completion_window": "completionWindow", "output_file_id": "outputFileId", "error_file_id": "errorFileId", "created_at": "createdAt", "in_progress_at": "inProgressAt", "expires_at": "expiresAt", "finalizing_at": "finalizingAt", "completed_at": "completedAt", "failed_at": "failedAt", "expired_at": "expiredAt", "cancelling_at": "cancellingAt", "cancelled_at": "cancelledAt", "request_counts": "requestCounts", }); }); /** @internal */ export type BatchObject$Outbound = { id: string; object: "batch"; endpoint: string; errors?: BatchErrors$Outbound | null | undefined; input_file_id: string; completion_window: string; status: string; output_file_id?: string | null | undefined; error_file_id?: string | null | undefined; created_at: number; in_progress_at?: number | null | undefined; expires_at?: number | null | undefined; finalizing_at?: number | null | undefined; completed_at?: number | null | undefined; failed_at?: number | null | undefined; expired_at?: number | null | undefined; cancelling_at?: number | null | undefined; cancelled_at?: number | null | undefined; request_counts: RequestCounts$Outbound; metadata?: { [k: string]: string } | null | undefined; }; /** @internal */ export const BatchObject$outboundSchema: z.ZodType< BatchObject$Outbound, z.ZodTypeDef, BatchObject > = z.object({ id: z.string(), object: z.literal("batch"), endpoint: z.string(), errors: z.nullable(BatchErrors$outboundSchema).optional(), inputFileId: z.string(), completionWindow: z.string(), status: BatchObjectStatus$outboundSchema, outputFileId: z.nullable(z.string()).optional(), errorFileId: z.nullable(z.string()).optional(), createdAt: z.number().int(), inProgressAt: z.nullable(z.number().int()).optional(), expiresAt: z.nullable(z.number().int()).optional(), finalizingAt: z.nullable(z.number().int()).optional(), completedAt: z.nullable(z.number().int()).optional(), failedAt: z.nullable(z.number().int()).optional(), expiredAt: z.nullable(z.number().int()).optional(), cancellingAt: z.nullable(z.number().int()).optional(), cancelledAt: z.nullable(z.number().int()).optional(), requestCounts: RequestCounts$outboundSchema, metadata: z.nullable(z.record(z.string())).optional(), }).transform((v) => { return remap$(v, { inputFileId: "input_file_id", completionWindow: "completion_window", outputFileId: "output_file_id", errorFileId: "error_file_id", createdAt: "created_at", inProgressAt: "in_progress_at", expiresAt: "expires_at", finalizingAt: "finalizing_at", completedAt: "completed_at", failedAt: "failed_at", expiredAt: "expired_at", cancellingAt: "cancelling_at", cancelledAt: "cancelled_at", requestCounts: "request_counts", }); }); export function batchObjectToJSON(batchObject: BatchObject): string { return JSON.stringify(BatchObject$outboundSchema.parse(batchObject)); } export function batchObjectFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => BatchObject$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BatchObject' from JSON`, ); }