UNPKG

@vercel/sdk

Version:

<p align="center"> <a href="https://vercel.com"> <img src="https://assets.vercel.com/image/upload/v1588805858/repositories/vercel/logo.png" height="96"> <h3 align="center">Vercel</h3> </a> <p align="center">Develop. Preview. Ship.</p> </p>

67 lines 2.18 kB
/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { safeParse } from "../lib/schemas.js"; import * as types from "../types/primitives.js"; import { VercelError } from "./vercelerror.js"; export const TooManyRequestsCode = { TooManyRequests: "too_many_requests", }; export class TooManyRequests extends VercelError { status; code; retryAfter; limit; /** The original data that was passed to this error instance. */ data$; constructor(err, httpMeta) { 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.retryAfter = err.retryAfter; this.limit = err.limit; this.name = "TooManyRequests"; } } /** @internal */ export const TooManyRequestsCode$inboundSchema = z.nativeEnum(TooManyRequestsCode); /** @internal */ export const RetryAfter$inboundSchema = z.object({ value: types.number(), str: types.string(), }); export function retryAfterFromJSON(jsonString) { return safeParse(jsonString, (x) => RetryAfter$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'RetryAfter' from JSON`); } /** @internal */ export const Limit$inboundSchema = z .object({ total: types.number(), remaining: types.number(), reset: types.number(), }); export function limitFromJSON(jsonString) { return safeParse(jsonString, (x) => Limit$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Limit' from JSON`); } /** @internal */ export const TooManyRequests$inboundSchema = z.object({ status: types.number(), code: TooManyRequestsCode$inboundSchema, message: types.string(), retryAfter: z.lazy(() => RetryAfter$inboundSchema), limit: z.lazy(() => Limit$inboundSchema), request$: z.instanceof(Request), response$: z.instanceof(Response), body$: z.string(), }) .transform((v) => { return new TooManyRequests(v, { request: v.request$, response: v.response$, body: v.body$, }); }); //# sourceMappingURL=toomanyrequests.js.map