import type { Path } from '../structures/path/index.js'; import { type RemoveFunctionFields } from '../types/functions.js'; import type { AnyObject, Coalesce, EmptyObjectNullable, Expand } from '../types/misc.js'; import type { EndpointMethods } from './methods.js'; /** * Definition of an abstract REST API endpoint. */ export interface IEndpointInfo extends IEndpointInfo.Base, IEndpointInfo.IPathAbstract, IEndpointInfo.IErrors, IEndpointInfo.IQuery { } export declare namespace IEndpointInfo { export type Base = { /** HTTP method of the endpoint, defaults to `GET`. See {@link EndpointMethods} */ readonly method: EndpointMethods; /** Optional display name, for logging purposes. */ readonly displayName?: string; }; export interface IIn { /** Marker for defining input type. */ readonly in?: TIn; } export interface IOut { /** Marker for defining output type. */ readonly out?: TOut; } /** * Helper interface for defining abstract path builder. * * `IPath` should be assignable to `IPathAbstract` */ export interface IPathAbstract { /** Path builder with unknown args */ readonly path?: Path.IBuilder; } export interface IPath { /** * Endpoint path, which can be static (just a string) or parametrized. * * See {@link Path} */ readonly path: TPath; } export type QueryKeysType = boolean | string | string[] | number | number[]; export type QueryArgs = Record; export interface IQuery { /** actual query keys to be used in argument object parsing */ readonly queryKeys?: (string & keyof TQuery)[]; /** Marker type for defining query shape. */ readonly queryTemplate?: TQuery; } export interface IErrors { readonly errorProcessor?: (err: TErrors) => void; } export interface IHeaders { /** Marker type for defining endpoint extra headers. */ readonly headers?: THeaders; } type Any = AnyObject; type Empty = EmptyObjectNullable; export type ExtractIn = T extends IIn ? Coalesce : F; export type ExtractPath = T extends IPath ? Path.ExtractObjectArgs : F; export type ExtractQuery = T extends IQuery ? TQuery : F; export type ExtractOut = T extends IOut ? TOut : never; export type ExtractErrors = T extends IErrors ? TErrors : Any; export type ExtractHeaders = T extends IHeaders ? THeaders : Any; type MergeOmit = Omit & K; export type Finalized = Expand>> & MergeOmit>> & MergeOmit ? TPath : Path.IBuilder>> & MergeOmit>> & MergeOmit>> & MergeOmit>>>>>; export {}; }