buena-typescript-sdk
Version:
Official TypeScript SDK for Buena.ai API - LinkedIn automation and lead management
103 lines (92 loc) • 2.5 kB
text/typescript
/*
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
*/
import * as z from "zod";
import * as models from "../index.js";
import { SDKError } from "./sdkerror.js";
export type ErrorTData = {
/**
* Error code
*/
error: string;
/**
* Human-readable error message
*/
message: string;
/**
* Additional error details
*/
details?: models.Details | undefined;
};
export class ErrorT extends SDKError {
/**
* Error code
*/
error: string;
/**
* Additional error details
*/
details?: models.Details | undefined;
/** The original data that was passed to this error instance. */
data$: ErrorTData;
constructor(
err: ErrorTData,
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.error = err.error;
if (err.details != null) this.details = err.details;
this.name = "ErrorT";
}
}
/** @internal */
export const ErrorT$inboundSchema: z.ZodType<ErrorT, z.ZodTypeDef, unknown> = z
.object({
error: z.string(),
message: z.string(),
details: z.lazy(() => models.Details$inboundSchema).optional(),
request$: z.instanceof(Request),
response$: z.instanceof(Response),
body$: z.string(),
})
.transform((v) => {
return new ErrorT(v, {
request: v.request$,
response: v.response$,
body: v.body$,
});
});
/** @internal */
export type ErrorT$Outbound = {
error: string;
message: string;
details?: models.Details$Outbound | undefined;
};
/** @internal */
export const ErrorT$outboundSchema: z.ZodType<
ErrorT$Outbound,
z.ZodTypeDef,
ErrorT
> = z.instanceof(ErrorT)
.transform(v => v.data$)
.pipe(z.object({
error: z.string(),
message: z.string(),
details: z.lazy(() => models.Details$outboundSchema).optional(),
}));
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace ErrorT$ {
/** @deprecated use `ErrorT$inboundSchema` instead. */
export const inboundSchema = ErrorT$inboundSchema;
/** @deprecated use `ErrorT$outboundSchema` instead. */
export const outboundSchema = ErrorT$outboundSchema;
/** @deprecated use `ErrorT$Outbound` instead. */
export type Outbound = ErrorT$Outbound;
}