/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: 901098307cd7 */ import * as z from "zod/v3"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { TimePoint, TimePoint$inboundSchema, TimePoint$Outbound, TimePoint$outboundSchema, } from "./timepoint.js"; export type Period = { /** * DEPRECATED - The number of days from now in the past to define upper boundary of time period. * * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. */ minDaysFromNow?: number | undefined; /** * DEPRECATED - The number of days from now in the past to define lower boundary of time period. * * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. */ maxDaysFromNow?: number | undefined; start?: TimePoint | undefined; end?: TimePoint | undefined; }; /** @internal */ export const Period$inboundSchema: z.ZodType = z .object({ minDaysFromNow: z.number().int().optional(), maxDaysFromNow: z.number().int().optional(), start: TimePoint$inboundSchema.optional(), end: TimePoint$inboundSchema.optional(), }); /** @internal */ export type Period$Outbound = { minDaysFromNow?: number | undefined; maxDaysFromNow?: number | undefined; start?: TimePoint$Outbound | undefined; end?: TimePoint$Outbound | undefined; }; /** @internal */ export const Period$outboundSchema: z.ZodType< Period$Outbound, z.ZodTypeDef, Period > = z.object({ minDaysFromNow: z.number().int().optional(), maxDaysFromNow: z.number().int().optional(), start: TimePoint$outboundSchema.optional(), end: TimePoint$outboundSchema.optional(), }); export function periodToJSON(period: Period): string { return JSON.stringify(Period$outboundSchema.parse(period)); } export function periodFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Period$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Period' from JSON`, ); }