/* * 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 SupplyData = { symbol: string; commodity: string; countryCode: string; country: string; date: Date; model: string; forecastedSupply: number; reportedSupply: number; reportingAgency: string; unit: string; featureContributions: Array | null; }; /** @internal */ export const SupplyData$inboundSchema: z.ZodType< SupplyData, z.ZodTypeDef, unknown > = z.object({ symbol: z.string(), commodity: z.string(), country_code: z.string(), country: z.string(), date: z.string().datetime({ offset: true }).transform(v => new Date(v)), model: z.string(), forecasted_supply: z.number(), reported_supply: z.number(), reporting_agency: z.string(), unit: z.string(), feature_contributions: z.nullable(z.array(FeatureCategory$inboundSchema)), }).transform((v) => { return remap$(v, { "country_code": "countryCode", "forecasted_supply": "forecastedSupply", "reported_supply": "reportedSupply", "reporting_agency": "reportingAgency", "feature_contributions": "featureContributions", }); }); /** @internal */ export type SupplyData$Outbound = { symbol: string; commodity: string; country_code: string; country: string; date: string; model: string; forecasted_supply: number; reported_supply: number; reporting_agency: string; unit: string; feature_contributions: Array | null; }; /** @internal */ export const SupplyData$outboundSchema: z.ZodType< SupplyData$Outbound, z.ZodTypeDef, SupplyData > = z.object({ symbol: z.string(), commodity: z.string(), countryCode: z.string(), country: z.string(), date: z.date().transform(v => v.toISOString()), model: z.string(), forecastedSupply: z.number(), reportedSupply: z.number(), reportingAgency: z.string(), unit: z.string(), featureContributions: z.nullable(z.array(FeatureCategory$outboundSchema)), }).transform((v) => { return remap$(v, { countryCode: "country_code", forecastedSupply: "forecasted_supply", reportedSupply: "reported_supply", reportingAgency: "reporting_agency", featureContributions: "feature_contributions", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace SupplyData$ { /** @deprecated use `SupplyData$inboundSchema` instead. */ export const inboundSchema = SupplyData$inboundSchema; /** @deprecated use `SupplyData$outboundSchema` instead. */ export const outboundSchema = SupplyData$outboundSchema; /** @deprecated use `SupplyData$Outbound` instead. */ export type Outbound = SupplyData$Outbound; } export function supplyDataToJSON(supplyData: SupplyData): string { return JSON.stringify(SupplyData$outboundSchema.parse(supplyData)); } export function supplyDataFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => SupplyData$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SupplyData' from JSON`, ); }