/* * 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 Feature = { featureCode: string; type: string; longName: string; variableType: string; mainCommodity?: string | null | undefined; symbols?: Array | null | undefined; country?: string | null | undefined; location?: string | null | undefined; statisticType?: string | null | undefined; unit?: string | null | undefined; source?: string | null | undefined; recentInfluence?: number | null | undefined; frequency?: string | null | undefined; phenologyStage?: Array | null | undefined; horizons?: Array | null | undefined; datasets?: Array | null | undefined; }; /** @internal */ export const Feature$inboundSchema: z.ZodType = z.object({ feature_code: z.string(), type: z.string(), long_name: z.string(), variable_type: z.string(), main_commodity: z.nullable(z.string()).optional(), symbols: z.nullable(z.array(z.string())).optional(), country: z.nullable(z.string()).optional(), location: z.nullable(z.string()).optional(), statistic_type: z.nullable(z.string()).optional(), unit: z.nullable(z.string()).optional(), source: z.nullable(z.string()).optional(), recent_influence: z.nullable(z.number()).optional(), frequency: z.nullable(z.string()).optional(), phenology_stage: z.nullable(z.array(z.string())).optional(), horizons: z.nullable(z.array(z.string())).optional(), datasets: z.nullable(z.array(z.string())).optional(), }).transform((v) => { return remap$(v, { "feature_code": "featureCode", "long_name": "longName", "variable_type": "variableType", "main_commodity": "mainCommodity", "statistic_type": "statisticType", "recent_influence": "recentInfluence", "phenology_stage": "phenologyStage", }); }); /** @internal */ export type Feature$Outbound = { feature_code: string; type: string; long_name: string; variable_type: string; main_commodity?: string | null | undefined; symbols?: Array | null | undefined; country?: string | null | undefined; location?: string | null | undefined; statistic_type?: string | null | undefined; unit?: string | null | undefined; source?: string | null | undefined; recent_influence?: number | null | undefined; frequency?: string | null | undefined; phenology_stage?: Array | null | undefined; horizons?: Array | null | undefined; datasets?: Array | null | undefined; }; /** @internal */ export const Feature$outboundSchema: z.ZodType< Feature$Outbound, z.ZodTypeDef, Feature > = z.object({ featureCode: z.string(), type: z.string(), longName: z.string(), variableType: z.string(), mainCommodity: z.nullable(z.string()).optional(), symbols: z.nullable(z.array(z.string())).optional(), country: z.nullable(z.string()).optional(), location: z.nullable(z.string()).optional(), statisticType: z.nullable(z.string()).optional(), unit: z.nullable(z.string()).optional(), source: z.nullable(z.string()).optional(), recentInfluence: z.nullable(z.number()).optional(), frequency: z.nullable(z.string()).optional(), phenologyStage: z.nullable(z.array(z.string())).optional(), horizons: z.nullable(z.array(z.string())).optional(), datasets: z.nullable(z.array(z.string())).optional(), }).transform((v) => { return remap$(v, { featureCode: "feature_code", longName: "long_name", variableType: "variable_type", mainCommodity: "main_commodity", statisticType: "statistic_type", recentInfluence: "recent_influence", phenologyStage: "phenology_stage", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Feature$ { /** @deprecated use `Feature$inboundSchema` instead. */ export const inboundSchema = Feature$inboundSchema; /** @deprecated use `Feature$outboundSchema` instead. */ export const outboundSchema = Feature$outboundSchema; /** @deprecated use `Feature$Outbound` instead. */ export type Outbound = Feature$Outbound; } export function featureToJSON(feature: Feature): string { return JSON.stringify(Feature$outboundSchema.parse(feature)); } export function featureFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Feature$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Feature' from JSON`, ); }