/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; 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"; export type ModelOutput = { commodity: string; date: Date; runDate: Date; horizon: number; contract: string; runDatePrice: number; realizedPrice: number; forecast: number; forecastError: number; forecastErrorPercent: number; }; /** @internal */ export const ModelOutput$inboundSchema: z.ZodType< ModelOutput, z.ZodTypeDef, unknown > = z.object({ commodity: z.string(), date: z.string().datetime({ offset: true }).transform(v => new Date(v)), run_date: z.string().datetime({ offset: true }).transform(v => new Date(v)), horizon: z.number().int(), contract: z.string(), run_date_price: z.number(), realized_price: z.number(), forecast: z.number(), forecast_error: z.number(), forecast_error_percent: z.number(), }).transform((v) => { return remap$(v, { "run_date": "runDate", "run_date_price": "runDatePrice", "realized_price": "realizedPrice", "forecast_error": "forecastError", "forecast_error_percent": "forecastErrorPercent", }); }); /** @internal */ export type ModelOutput$Outbound = { commodity: string; date: string; run_date: string; horizon: number; contract: string; run_date_price: number; realized_price: number; forecast: number; forecast_error: number; forecast_error_percent: number; }; /** @internal */ export const ModelOutput$outboundSchema: z.ZodType< ModelOutput$Outbound, z.ZodTypeDef, ModelOutput > = z.object({ commodity: z.string(), date: z.date().transform(v => v.toISOString()), runDate: z.date().transform(v => v.toISOString()), horizon: z.number().int(), contract: z.string(), runDatePrice: z.number(), realizedPrice: z.number(), forecast: z.number(), forecastError: z.number(), forecastErrorPercent: z.number(), }).transform((v) => { return remap$(v, { runDate: "run_date", runDatePrice: "run_date_price", realizedPrice: "realized_price", forecastError: "forecast_error", forecastErrorPercent: "forecast_error_percent", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace ModelOutput$ { /** @deprecated use `ModelOutput$inboundSchema` instead. */ export const inboundSchema = ModelOutput$inboundSchema; /** @deprecated use `ModelOutput$outboundSchema` instead. */ export const outboundSchema = ModelOutput$outboundSchema; /** @deprecated use `ModelOutput$Outbound` instead. */ export type Outbound = ModelOutput$Outbound; } export function modelOutputToJSON(modelOutput: ModelOutput): string { return JSON.stringify(ModelOutput$outboundSchema.parse(modelOutput)); } export function modelOutputFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ModelOutput$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ModelOutput' from JSON`, ); }