/* * 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"; /** * The details of file containing the snapshot data. This contains the download uri and uri expiry time. */ export type FileT = { /** * The signed download uri for the file. This allows the client to download the file. */ downloadUri?: string | undefined; /** * The timestamp at which the download uri expires in UTC. This is set to 1 hour after the request time. */ uriExpiryTime?: Date | null | undefined; }; /** * The process date of the snapshot. This date corresponds to the underlying data within the snapshot. */ export type SnapshotProcessDate = { /** * Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant. */ day?: number | undefined; /** * Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day. */ month?: number | undefined; /** * Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year. */ year?: number | undefined; }; /** * A snapshot of the data at a specific point in time. This contains the snapshot details and the download_uri of the file containing the snapshot data. */ export type Snapshot = { /** * The timestamp at which the snapshot was created at in UTC. */ createTime?: Date | null | undefined; /** * The details of file containing the snapshot data. This contains the download uri and uri expiry time. */ file?: FileT | null | undefined; /** * The name of the resource. */ name?: string | undefined; /** * The process date of the snapshot. This date corresponds to the underlying data within the snapshot. */ processDate?: SnapshotProcessDate | null | undefined; /** * The unique identifier of the snapshot file. */ snapshotId?: string | undefined; /** * The type of the snapshot. */ snapshotType?: string | undefined; /** * The version of the snapshot. */ version?: string | undefined; }; /** @internal */ export const FileT$inboundSchema: z.ZodType = z .object({ download_uri: z.string().optional(), uri_expiry_time: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), }).transform((v) => { return remap$(v, { "download_uri": "downloadUri", "uri_expiry_time": "uriExpiryTime", }); }); /** @internal */ export type FileT$Outbound = { download_uri?: string | undefined; uri_expiry_time?: string | null | undefined; }; /** @internal */ export const FileT$outboundSchema: z.ZodType< FileT$Outbound, z.ZodTypeDef, FileT > = z.object({ downloadUri: z.string().optional(), uriExpiryTime: z.nullable(z.date().transform(v => v.toISOString())) .optional(), }).transform((v) => { return remap$(v, { downloadUri: "download_uri", uriExpiryTime: "uri_expiry_time", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace FileT$ { /** @deprecated use `FileT$inboundSchema` instead. */ export const inboundSchema = FileT$inboundSchema; /** @deprecated use `FileT$outboundSchema` instead. */ export const outboundSchema = FileT$outboundSchema; /** @deprecated use `FileT$Outbound` instead. */ export type Outbound = FileT$Outbound; } export function fileToJSON(fileT: FileT): string { return JSON.stringify(FileT$outboundSchema.parse(fileT)); } export function fileFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => FileT$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'FileT' from JSON`, ); } /** @internal */ export const SnapshotProcessDate$inboundSchema: z.ZodType< SnapshotProcessDate, z.ZodTypeDef, unknown > = z.object({ day: z.number().int().optional(), month: z.number().int().optional(), year: z.number().int().optional(), }); /** @internal */ export type SnapshotProcessDate$Outbound = { day?: number | undefined; month?: number | undefined; year?: number | undefined; }; /** @internal */ export const SnapshotProcessDate$outboundSchema: z.ZodType< SnapshotProcessDate$Outbound, z.ZodTypeDef, SnapshotProcessDate > = z.object({ day: z.number().int().optional(), month: z.number().int().optional(), year: z.number().int().optional(), }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace SnapshotProcessDate$ { /** @deprecated use `SnapshotProcessDate$inboundSchema` instead. */ export const inboundSchema = SnapshotProcessDate$inboundSchema; /** @deprecated use `SnapshotProcessDate$outboundSchema` instead. */ export const outboundSchema = SnapshotProcessDate$outboundSchema; /** @deprecated use `SnapshotProcessDate$Outbound` instead. */ export type Outbound = SnapshotProcessDate$Outbound; } export function snapshotProcessDateToJSON( snapshotProcessDate: SnapshotProcessDate, ): string { return JSON.stringify( SnapshotProcessDate$outboundSchema.parse(snapshotProcessDate), ); } export function snapshotProcessDateFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => SnapshotProcessDate$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SnapshotProcessDate' from JSON`, ); } /** @internal */ export const Snapshot$inboundSchema: z.ZodType< Snapshot, z.ZodTypeDef, unknown > = z.object({ create_time: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), file: z.nullable(z.lazy(() => FileT$inboundSchema)).optional(), name: z.string().optional(), process_date: z.nullable(z.lazy(() => SnapshotProcessDate$inboundSchema)) .optional(), snapshot_id: z.string().optional(), snapshot_type: z.string().optional(), version: z.string().optional(), }).transform((v) => { return remap$(v, { "create_time": "createTime", "process_date": "processDate", "snapshot_id": "snapshotId", "snapshot_type": "snapshotType", }); }); /** @internal */ export type Snapshot$Outbound = { create_time?: string | null | undefined; file?: FileT$Outbound | null | undefined; name?: string | undefined; process_date?: SnapshotProcessDate$Outbound | null | undefined; snapshot_id?: string | undefined; snapshot_type?: string | undefined; version?: string | undefined; }; /** @internal */ export const Snapshot$outboundSchema: z.ZodType< Snapshot$Outbound, z.ZodTypeDef, Snapshot > = z.object({ createTime: z.nullable(z.date().transform(v => v.toISOString())).optional(), file: z.nullable(z.lazy(() => FileT$outboundSchema)).optional(), name: z.string().optional(), processDate: z.nullable(z.lazy(() => SnapshotProcessDate$outboundSchema)) .optional(), snapshotId: z.string().optional(), snapshotType: z.string().optional(), version: z.string().optional(), }).transform((v) => { return remap$(v, { createTime: "create_time", processDate: "process_date", snapshotId: "snapshot_id", snapshotType: "snapshot_type", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Snapshot$ { /** @deprecated use `Snapshot$inboundSchema` instead. */ export const inboundSchema = Snapshot$inboundSchema; /** @deprecated use `Snapshot$outboundSchema` instead. */ export const outboundSchema = Snapshot$outboundSchema; /** @deprecated use `Snapshot$Outbound` instead. */ export type Outbound = Snapshot$Outbound; } export function snapshotToJSON(snapshot: Snapshot): string { return JSON.stringify(Snapshot$outboundSchema.parse(snapshot)); } export function snapshotFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Snapshot$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Snapshot' from JSON`, ); }