@unkey/api
Version:
Developer-friendly & type-safe Typescript SDK specifically catered to leverage *@unkey/api* API.
77 lines (65 loc) • 2.28 kB
text/typescript
/*
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
*/
import * as z from "zod";
import * as components from "../components/index.js";
export type UnauthorizedErrorResponseData = {
meta: components.Meta;
error: components.BaseError;
};
export class UnauthorizedErrorResponse extends Error {
meta: components.Meta;
error: components.BaseError;
/** The original data that was passed to this error instance. */
data$: UnauthorizedErrorResponseData;
constructor(err: UnauthorizedErrorResponseData) {
const message = "message" in err && typeof err.message === "string"
? err.message
: `API error occurred: ${JSON.stringify(err)}`;
super(message);
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,
})
.transform((v) => {
return new UnauthorizedErrorResponse(v);
});
/** @internal */
export type UnauthorizedErrorResponse$Outbound = {
meta: components.Meta$Outbound;
error: components.BaseError$Outbound;
};
/** @internal */
export const UnauthorizedErrorResponse$outboundSchema: z.ZodType<
UnauthorizedErrorResponse$Outbound,
z.ZodTypeDef,
UnauthorizedErrorResponse
> = z.instanceof(UnauthorizedErrorResponse)
.transform(v => v.data$)
.pipe(z.object({
meta: components.Meta$outboundSchema,
error: components.BaseError$outboundSchema,
}));
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace UnauthorizedErrorResponse$ {
/** @deprecated use `UnauthorizedErrorResponse$inboundSchema` instead. */
export const inboundSchema = UnauthorizedErrorResponse$inboundSchema;
/** @deprecated use `UnauthorizedErrorResponse$outboundSchema` instead. */
export const outboundSchema = UnauthorizedErrorResponse$outboundSchema;
/** @deprecated use `UnauthorizedErrorResponse$Outbound` instead. */
export type Outbound = UnauthorizedErrorResponse$Outbound;
}