/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ 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"; /** * Metadata about an uploaded image. */ export type ImageMetadata = { imageID: string; /** * The ID used to get an image with the public endpoint. */ publicID: string; /** * Alternative text for the image. */ altText?: string | undefined; /** * A public URL to access the image. An optional `size={width}x{height}` * * @remarks * query parameter can be provided to resize the image. */ link: string; createdOn: Date; updatedOn: Date; disabledOn?: Date | undefined; }; /** @internal */ export const ImageMetadata$inboundSchema: z.ZodType< ImageMetadata, z.ZodTypeDef, unknown > = z.object({ imageID: z.string(), publicID: z.string(), altText: z.string().optional(), link: z.string(), createdOn: z.string().datetime({ offset: true }).transform(v => new Date(v)), updatedOn: z.string().datetime({ offset: true }).transform(v => new Date(v)), disabledOn: z.string().datetime({ offset: true }).transform(v => new Date(v)) .optional(), }); /** @internal */ export type ImageMetadata$Outbound = { imageID: string; publicID: string; altText?: string | undefined; link: string; createdOn: string; updatedOn: string; disabledOn?: string | undefined; }; /** @internal */ export const ImageMetadata$outboundSchema: z.ZodType< ImageMetadata$Outbound, z.ZodTypeDef, ImageMetadata > = z.object({ imageID: z.string(), publicID: z.string(), altText: z.string().optional(), link: z.string(), createdOn: z.date().transform(v => v.toISOString()), updatedOn: z.date().transform(v => v.toISOString()), disabledOn: z.date().transform(v => v.toISOString()).optional(), }); export function imageMetadataToJSON(imageMetadata: ImageMetadata): string { return JSON.stringify(ImageMetadata$outboundSchema.parse(imageMetadata)); } export function imageMetadataFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ImageMetadata$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ImageMetadata' from JSON`, ); }