/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; import { safeParse } from "../lib/schemas.js"; import { Result as SafeParseResult } from "../types/fp.js"; import { SDKValidationError } from "./errors/sdkvalidationerror.js"; import { UpdateChanges, UpdateChanges$inboundSchema, UpdateChanges$Outbound, UpdateChanges$outboundSchema, } from "./updatechanges.js"; export type UpdateResource = { id?: number | undefined; version?: string | null | undefined; branch?: string | null | undefined; releaseDate?: Date | undefined; fileName?: string | null | undefined; url?: string | null | undefined; installed?: boolean | undefined; installedOn?: Date | null | undefined; installable?: boolean | undefined; latest?: boolean | undefined; changes?: UpdateChanges | undefined; hash?: string | null | undefined; }; /** @internal */ export const UpdateResource$inboundSchema: z.ZodType< UpdateResource, z.ZodTypeDef, unknown > = z.object({ id: z.number().int().optional(), version: z.nullable(z.string()).optional(), branch: z.nullable(z.string()).optional(), releaseDate: z.string().datetime({ offset: true }).transform(v => new Date(v)) .optional(), fileName: z.nullable(z.string()).optional(), url: z.nullable(z.string()).optional(), installed: z.boolean().optional(), installedOn: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), installable: z.boolean().optional(), latest: z.boolean().optional(), changes: UpdateChanges$inboundSchema.optional(), hash: z.nullable(z.string()).optional(), }); /** @internal */ export type UpdateResource$Outbound = { id?: number | undefined; version?: string | null | undefined; branch?: string | null | undefined; releaseDate?: string | undefined; fileName?: string | null | undefined; url?: string | null | undefined; installed?: boolean | undefined; installedOn?: string | null | undefined; installable?: boolean | undefined; latest?: boolean | undefined; changes?: UpdateChanges$Outbound | undefined; hash?: string | null | undefined; }; /** @internal */ export const UpdateResource$outboundSchema: z.ZodType< UpdateResource$Outbound, z.ZodTypeDef, UpdateResource > = z.object({ id: z.number().int().optional(), version: z.nullable(z.string()).optional(), branch: z.nullable(z.string()).optional(), releaseDate: z.date().transform(v => v.toISOString()).optional(), fileName: z.nullable(z.string()).optional(), url: z.nullable(z.string()).optional(), installed: z.boolean().optional(), installedOn: z.nullable(z.date().transform(v => v.toISOString())).optional(), installable: z.boolean().optional(), latest: z.boolean().optional(), changes: UpdateChanges$outboundSchema.optional(), hash: z.nullable(z.string()).optional(), }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace UpdateResource$ { /** @deprecated use `UpdateResource$inboundSchema` instead. */ export const inboundSchema = UpdateResource$inboundSchema; /** @deprecated use `UpdateResource$outboundSchema` instead. */ export const outboundSchema = UpdateResource$outboundSchema; /** @deprecated use `UpdateResource$Outbound` instead. */ export type Outbound = UpdateResource$Outbound; } export function updateResourceToJSON(updateResource: UpdateResource): string { return JSON.stringify(UpdateResource$outboundSchema.parse(updateResource)); } export function updateResourceFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => UpdateResource$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'UpdateResource' from JSON`, ); }