/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. * @generated-id: e11875c6e8fb */ 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"; export type TimeRange = { /** * start time of the time range, applicable for the CUSTOM type. */ startTime?: Date | undefined; /** * end time of the time range, applicable for the CUSTOM type. */ endTime?: Date | undefined; /** * The number of days to look back from the current time, applicable for the LAST_N_DAYS type. */ lastNDaysValue?: number | undefined; }; /** @internal */ export const TimeRange$inboundSchema: z.ZodType< TimeRange, z.ZodTypeDef, unknown > = z.object({ startTime: z.string().datetime({ offset: true }).transform(v => new Date(v)) .optional(), endTime: z.string().datetime({ offset: true }).transform(v => new Date(v)) .optional(), lastNDaysValue: z.number().int().optional(), }); /** @internal */ export type TimeRange$Outbound = { startTime?: string | undefined; endTime?: string | undefined; lastNDaysValue?: number | undefined; }; /** @internal */ export const TimeRange$outboundSchema: z.ZodType< TimeRange$Outbound, z.ZodTypeDef, TimeRange > = z.object({ startTime: z.date().transform(v => v.toISOString()).optional(), endTime: z.date().transform(v => v.toISOString()).optional(), lastNDaysValue: z.number().int().optional(), }); export function timeRangeToJSON(timeRange: TimeRange): string { return JSON.stringify(TimeRange$outboundSchema.parse(timeRange)); } export function timeRangeFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => TimeRange$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TimeRange' from JSON`, ); }