import type { EndpointDefaults } from "./EndpointDefaults.js"; import type { RequestOptions } from "./RequestOptions.js"; import type { RequestParameters } from "./RequestParameters.js"; import type { Route } from "./Route.js"; import type { Endpoints } from "./generated/Endpoints.js"; export interface EndpointInterface { /** * Transforms a GitHub REST API endpoint into generic request options * * @param {object} endpoint Must set `url` unless it's set defaults. Plus URL, query or body parameters, as well as `headers`, `mediaType.{format|previews}`, `request`, or `baseUrl`. */ (options: O & { method?: string; } & ("url" extends keyof D ? { url?: string; } : { url: string; })): RequestOptions & Pick; /** * Transforms a GitHub REST API endpoint into generic request options * * @param {string} route Request method + URL. Example: `'GET /orgs/{org}'` * @param {object} [parameters] URL, query or body parameters, as well as `headers`, `mediaType.{format|previews}`, `request`, or `baseUrl`. */ (route: keyof Endpoints | R, parameters?: P): (R extends keyof Endpoints ? Endpoints[R]["request"] : RequestOptions) & Pick; /** * Object with current default route and parameters */ DEFAULTS: D & EndpointDefaults; /** * Returns a new `endpoint` interface with new defaults */ defaults: (newDefaults: O) => EndpointInterface; merge: { /** * Merges current endpoint defaults with passed route and parameters, * without transforming them into request options. * * @param {string} route Request method + URL. Example: `'GET /orgs/{org}'` * @param {object} [parameters] URL, query or body parameters, as well as `headers`, `mediaType.{format|previews}`, `request`, or `baseUrl`. * */ (route: keyof Endpoints | R, parameters?: P): D & (R extends keyof Endpoints ? Endpoints[R]["request"] & Endpoints[R]["parameters"] : EndpointDefaults) & P; /** * Merges current endpoint defaults with passed route and parameters, * without transforming them into request options. * * @param {object} endpoint Must set `method` and `url`. Plus URL, query or body parameters, as well as `headers`, `mediaType.{format|previews}`, `request`, or `baseUrl`. */

(options: P): EndpointDefaults & D & P; /** * Returns current default options. * * @deprecated use endpoint.DEFAULTS instead */ (): D & EndpointDefaults; }; /** * Stateless method to turn endpoint options into request options. * Calling `endpoint(options)` is the same as calling `endpoint.parse(endpoint.merge(options))`. * * @param {object} options `method`, `url`. Plus URL, query or body parameters, as well as `headers`, `mediaType.{format|previews}`, `request`, or `baseUrl`. */ parse: (options: O) => RequestOptions & Pick; }