import {HttpStatusCode, HttpSuccessCodes} from "./utils/client/httpStatusCode.js"; import {Resolves} from "./utils/types.js"; /* eslint-disable @typescript-eslint/naming-convention, @typescript-eslint/no-explicit-any */ export type APIClientHandler = (...args: any) => PromiseLike; export type APIServerHandler = (...args: any) => PromiseLike; export type ApiClientSuccessResponse = {ok: true; status: S; response: T; error?: never}; export type ApiClientSErrorResponse> = { ok: false; status: S; response?: never; error: {code: S; operationId: string; message?: string}; }; export type ApiClientResponse< S extends Partial<{[K in HttpSuccessCodes]: unknown}> = {[K in HttpSuccessCodes]: unknown}, E extends Exclude = Exclude > = | {[K in keyof S]: ApiClientSuccessResponse}[keyof S] | {[K in E]: ApiClientSErrorResponse}[E] | ApiClientSErrorResponse; export type ApiClientResponseData = T extends {ok: true; response: infer R} ? R : never; export type GenericRequestObject = Record; export type GenericResponseObject = {code: (code: number) => void}; export type ServerApi> = { [K in keyof T]: ( ...args: [...args: Parameters, req?: GenericRequestObject, res?: GenericResponseObject] ) => Promise>>; }; export type ClientApi> = { [K in keyof T]: (...args: Parameters) => Promise}>>; };