/* * 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 { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { ComputePriceRange, ComputePriceRange$inboundSchema, ComputePriceRange$Outbound, ComputePriceRange$outboundSchema, } from "./computepricerange.js"; import { ComputeProviderQuote, ComputeProviderQuote$inboundSchema, ComputeProviderQuote$Outbound, ComputeProviderQuote$outboundSchema, } from "./computeproviderquote.js"; export type PriceBreakdownUsdHr = { compute: ComputePriceRange; volume: ComputePriceRange; }; export type ComputeQuote = { available: boolean; expiresAt: Date | null; observedAt: Date; priceBreakdownUsdHr?: PriceBreakdownUsdHr | undefined; priceUsdHr: ComputePriceRange | null; providers?: Array | undefined; }; /** @internal */ export const PriceBreakdownUsdHr$inboundSchema: z.ZodType< PriceBreakdownUsdHr, z.ZodTypeDef, unknown > = z.object({ compute: ComputePriceRange$inboundSchema, volume: ComputePriceRange$inboundSchema, }); /** @internal */ export type PriceBreakdownUsdHr$Outbound = { compute: ComputePriceRange$Outbound; volume: ComputePriceRange$Outbound; }; /** @internal */ export const PriceBreakdownUsdHr$outboundSchema: z.ZodType< PriceBreakdownUsdHr$Outbound, z.ZodTypeDef, PriceBreakdownUsdHr > = z.object({ compute: ComputePriceRange$outboundSchema, volume: ComputePriceRange$outboundSchema, }); export function priceBreakdownUsdHrToJSON( priceBreakdownUsdHr: PriceBreakdownUsdHr, ): string { return JSON.stringify( PriceBreakdownUsdHr$outboundSchema.parse(priceBreakdownUsdHr), ); } export function priceBreakdownUsdHrFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => PriceBreakdownUsdHr$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'PriceBreakdownUsdHr' from JSON`, ); } /** @internal */ export const ComputeQuote$inboundSchema: z.ZodType< ComputeQuote, z.ZodTypeDef, unknown > = z.object({ available: z.boolean(), expires_at: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ), observed_at: z.string().datetime({ offset: true }).transform(v => new Date(v) ), price_breakdown_usd_hr: z.lazy(() => PriceBreakdownUsdHr$inboundSchema) .optional(), price_usd_hr: z.nullable(ComputePriceRange$inboundSchema), providers: z.array(ComputeProviderQuote$inboundSchema).optional(), }).transform((v) => { return remap$(v, { "expires_at": "expiresAt", "observed_at": "observedAt", "price_breakdown_usd_hr": "priceBreakdownUsdHr", "price_usd_hr": "priceUsdHr", }); }); /** @internal */ export type ComputeQuote$Outbound = { available: boolean; expires_at: string | null; observed_at: string; price_breakdown_usd_hr?: PriceBreakdownUsdHr$Outbound | undefined; price_usd_hr: ComputePriceRange$Outbound | null; providers?: Array | undefined; }; /** @internal */ export const ComputeQuote$outboundSchema: z.ZodType< ComputeQuote$Outbound, z.ZodTypeDef, ComputeQuote > = z.object({ available: z.boolean(), expiresAt: z.nullable(z.date().transform(v => v.toISOString())), observedAt: z.date().transform(v => v.toISOString()), priceBreakdownUsdHr: z.lazy(() => PriceBreakdownUsdHr$outboundSchema) .optional(), priceUsdHr: z.nullable(ComputePriceRange$outboundSchema), providers: z.array(ComputeProviderQuote$outboundSchema).optional(), }).transform((v) => { return remap$(v, { expiresAt: "expires_at", observedAt: "observed_at", priceBreakdownUsdHr: "price_breakdown_usd_hr", priceUsdHr: "price_usd_hr", }); }); export function computeQuoteToJSON(computeQuote: ComputeQuote): string { return JSON.stringify(ComputeQuote$outboundSchema.parse(computeQuote)); } export function computeQuoteFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ComputeQuote$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ComputeQuote' from JSON`, ); }