UNPKG

@unkey/api

Version:

Developer-friendly & type-safe Typescript SDK specifically catered to leverage *@unkey/api* API.

94 lines (85 loc) 2.43 kB
/* * 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"; export type BaseError = { /** * A human-readable explanation specific to this occurrence of the problem. */ detail: string; /** * A URI reference that identifies the specific occurrence of the problem. */ instance?: string | undefined; /** * HTTP status code */ status: number; /** * A short, human-readable summary of the problem type. This value should not change between occurrences of the error. */ title: string; /** * A URI reference to human-readable documentation for the error. */ type: string; }; /** @internal */ export const BaseError$inboundSchema: z.ZodType< BaseError, z.ZodTypeDef, unknown > = z.object({ detail: z.string(), instance: z.string().optional(), status: z.number().int(), title: z.string(), type: z.string(), }); /** @internal */ export type BaseError$Outbound = { detail: string; instance?: string | undefined; status: number; title: string; type: string; }; /** @internal */ export const BaseError$outboundSchema: z.ZodType< BaseError$Outbound, z.ZodTypeDef, BaseError > = z.object({ detail: z.string(), instance: z.string().optional(), status: z.number().int(), title: z.string(), type: z.string(), }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace BaseError$ { /** @deprecated use `BaseError$inboundSchema` instead. */ export const inboundSchema = BaseError$inboundSchema; /** @deprecated use `BaseError$outboundSchema` instead. */ export const outboundSchema = BaseError$outboundSchema; /** @deprecated use `BaseError$Outbound` instead. */ export type Outbound = BaseError$Outbound; } export function baseErrorToJSON(baseError: BaseError): string { return JSON.stringify(BaseError$outboundSchema.parse(baseError)); } export function baseErrorFromJSON( jsonString: string, ): SafeParseResult<BaseError, SDKValidationError> { return safeParse( jsonString, (x) => BaseError$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BaseError' from JSON`, ); }