/* * 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 { RFCDate } from "../../types/rfcdate.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { ForecastTrajectoryElement, ForecastTrajectoryElement$inboundSchema, ForecastTrajectoryElement$Outbound, ForecastTrajectoryElement$outboundSchema, } from "./forecasttrajectoryelement.js"; export type ForecastTrajectory = { trajectory: Array; startDate: RFCDate; endDate?: RFCDate | null | undefined; }; /** @internal */ export const ForecastTrajectory$inboundSchema: z.ZodType< ForecastTrajectory, z.ZodTypeDef, unknown > = z.object({ trajectory: z.array(ForecastTrajectoryElement$inboundSchema), start_date: z.string().transform(v => new RFCDate(v)), end_date: z.nullable(z.string().transform(v => new RFCDate(v))).optional(), }).transform((v) => { return remap$(v, { "start_date": "startDate", "end_date": "endDate", }); }); /** @internal */ export type ForecastTrajectory$Outbound = { trajectory: Array; start_date: string; end_date?: string | null | undefined; }; /** @internal */ export const ForecastTrajectory$outboundSchema: z.ZodType< ForecastTrajectory$Outbound, z.ZodTypeDef, ForecastTrajectory > = z.object({ trajectory: z.array(ForecastTrajectoryElement$outboundSchema), startDate: z.instanceof(RFCDate).transform(v => v.toString()), endDate: z.nullable(z.instanceof(RFCDate).transform(v => v.toString())) .optional(), }).transform((v) => { return remap$(v, { startDate: "start_date", endDate: "end_date", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace ForecastTrajectory$ { /** @deprecated use `ForecastTrajectory$inboundSchema` instead. */ export const inboundSchema = ForecastTrajectory$inboundSchema; /** @deprecated use `ForecastTrajectory$outboundSchema` instead. */ export const outboundSchema = ForecastTrajectory$outboundSchema; /** @deprecated use `ForecastTrajectory$Outbound` instead. */ export type Outbound = ForecastTrajectory$Outbound; } export function forecastTrajectoryToJSON( forecastTrajectory: ForecastTrajectory, ): string { return JSON.stringify( ForecastTrajectory$outboundSchema.parse(forecastTrajectory), ); } export function forecastTrajectoryFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ForecastTrajectory$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ForecastTrajectory' from JSON`, ); }