/* * 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"; import { FeatureCategory, FeatureCategory$inboundSchema, FeatureCategory$Outbound, FeatureCategory$outboundSchema, } from "./featurecategory.js"; export type MarketDriver = { model: string; forecastDate: Date; targetDateContract: string; horizon: number; categories: Array; }; /** @internal */ export const MarketDriver$inboundSchema: z.ZodType< MarketDriver, z.ZodTypeDef, unknown > = z.object({ model: z.string(), forecast_date: z.string().datetime({ offset: true }).transform(v => new Date(v) ), target_date_contract: z.string(), horizon: z.number().int(), categories: z.array(FeatureCategory$inboundSchema), }).transform((v) => { return remap$(v, { "forecast_date": "forecastDate", "target_date_contract": "targetDateContract", }); }); /** @internal */ export type MarketDriver$Outbound = { model: string; forecast_date: string; target_date_contract: string; horizon: number; categories: Array; }; /** @internal */ export const MarketDriver$outboundSchema: z.ZodType< MarketDriver$Outbound, z.ZodTypeDef, MarketDriver > = z.object({ model: z.string(), forecastDate: z.date().transform(v => v.toISOString()), targetDateContract: z.string(), horizon: z.number().int(), categories: z.array(FeatureCategory$outboundSchema), }).transform((v) => { return remap$(v, { forecastDate: "forecast_date", targetDateContract: "target_date_contract", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace MarketDriver$ { /** @deprecated use `MarketDriver$inboundSchema` instead. */ export const inboundSchema = MarketDriver$inboundSchema; /** @deprecated use `MarketDriver$outboundSchema` instead. */ export const outboundSchema = MarketDriver$outboundSchema; /** @deprecated use `MarketDriver$Outbound` instead. */ export type Outbound = MarketDriver$Outbound; } export function marketDriverToJSON(marketDriver: MarketDriver): string { return JSON.stringify(MarketDriver$outboundSchema.parse(marketDriver)); } export function marketDriverFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => MarketDriver$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'MarketDriver' from JSON`, ); }