UNPKG

@unkey/api

Version:

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

88 lines (80 loc) 3.17 kB
/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import * as components from "../components/index.js"; import { UnkeyError } from "./unkeyerror.js"; /** * Error response when authentication has failed or credentials are missing. This occurs when: * * @remarks * - No authentication token is provided in the request * - The provided token is invalid, expired, or malformed * - The token format doesn't match expected patterns * * To resolve this error, ensure you're including a valid root key in the Authorization header. */ export type UnauthorizedErrorResponseData = { /** * Metadata object included in every API response. This provides context about the request and is essential for debugging, audit trails, and support inquiries. The `requestId` is particularly important when troubleshooting issues with the Unkey support team. */ meta: components.Meta; /** * Base error structure following Problem Details for HTTP APIs (RFC 7807). This provides a standardized way to carry machine-readable details of errors in HTTP response content. */ error: components.BaseError; }; /** * Error response when authentication has failed or credentials are missing. This occurs when: * * @remarks * - No authentication token is provided in the request * - The provided token is invalid, expired, or malformed * - The token format doesn't match expected patterns * * To resolve this error, ensure you're including a valid root key in the Authorization header. */ export class UnauthorizedErrorResponse extends UnkeyError { /** * Metadata object included in every API response. This provides context about the request and is essential for debugging, audit trails, and support inquiries. The `requestId` is particularly important when troubleshooting issues with the Unkey support team. */ meta: components.Meta; /** * Base error structure following Problem Details for HTTP APIs (RFC 7807). This provides a standardized way to carry machine-readable details of errors in HTTP response content. */ error: components.BaseError; /** The original data that was passed to this error instance. */ data$: UnauthorizedErrorResponseData; constructor( err: UnauthorizedErrorResponseData, httpMeta: { response: Response; request: Request; body: string }, ) { const message = "message" in err && typeof err.message === "string" ? err.message : `API error occurred: ${JSON.stringify(err)}`; super(message, httpMeta); this.data$ = err; this.meta = err.meta; this.error = err.error; this.name = "UnauthorizedErrorResponse"; } } /** @internal */ export const UnauthorizedErrorResponse$inboundSchema: z.ZodType< UnauthorizedErrorResponse, z.ZodTypeDef, unknown > = z.object({ meta: components.Meta$inboundSchema, error: components.BaseError$inboundSchema, request$: z.instanceof(Request), response$: z.instanceof(Response), body$: z.string(), }) .transform((v) => { return new UnauthorizedErrorResponse(v, { request: v.request$, response: v.response$, body: v.body$, }); });