/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { ClosedEnum } from "../types/enums.js"; import * as types from "../types/primitives.js"; import { VercelError } from "./vercelerror.js"; export const Code = { Unauthorized: "unauthorized", } as const; export type Code = ClosedEnum; export type UnauthorizedData = { status: number; code: Code; message: string; }; export class Unauthorized extends VercelError { status: number; code: Code; /** The original data that was passed to this error instance. */ data$: UnauthorizedData; constructor( err: UnauthorizedData, httpMeta: { response: Response; request: Request; body: string }, ) { const message = err.message || `API error occurred: ${JSON.stringify(err)}`; super(message, httpMeta); this.data$ = err; this.status = err.status; this.code = err.code; this.name = "Unauthorized"; } } /** @internal */ export const Code$inboundSchema: z.ZodNativeEnum = z.nativeEnum( Code, ); /** @internal */ export const Code$outboundSchema: z.ZodNativeEnum = Code$inboundSchema; /** @internal */ export const Unauthorized$inboundSchema: z.ZodType< Unauthorized, z.ZodTypeDef, unknown > = z.object({ status: types.number(), code: Code$inboundSchema, message: types.string(), request$: z.instanceof(Request), response$: z.instanceof(Response), body$: z.string(), }) .transform((v) => { return new Unauthorized(v, { request: v.request$, response: v.response$, body: v.body$, }); }); /** @internal */ export type Unauthorized$Outbound = { status: number; code: string; message: string; }; /** @internal */ export const Unauthorized$outboundSchema: z.ZodType< Unauthorized$Outbound, z.ZodTypeDef, Unauthorized > = z.instanceof(Unauthorized) .transform(v => v.data$) .pipe(z.object({ status: z.number(), code: Code$outboundSchema, message: z.string(), }));