import { Pathfinder, RouteParams } from '@sigiljs/pathfinder'; import { default as Sigil } from '../sigil/sigil'; import { Internal } from '../types'; import { ILogOptions } from '../utils/make-log'; import { ModifierConstructor } from './modifier'; import { default as Route, RouteOptions } from './route'; type X = Middleware extends readonly ModifierConstructor[] ? InstanceType : never; /** * Core router class that serves as a higher-level abstraction over the * underlying HTTP router (pathfinder). Provides foundational logic for: * - Mounting child routers * - Storing request metadata and validation schemas * - Managing middleware modifiers and debug logging * * @template Middleware A tuple of modifier constructors applied to this route. */ export default class RouteCore[]) | undefined> { protected readonly $pathfinder: Pathfinder; /** * Bound logger function configured with route-level debug options. */ readonly logger: (options: ILogOptions) => void; /** * Router-level configuration options (e.g., debug settings). */ protected __$options?: RouteOptions; protected __$sigil?: Sigil; /** * Reference to the root Route when chaining definitions. * Used to aggregate child request metadata. * @protected */ protected __initialParent?: Route; /** * Map of registered request descriptors for this router. * Keyed by a unique identifier. * @protected */ protected $registeredRequests: Map; /** * Instantiated middleware modifiers for this router. * @protected */ protected $modifierInstances: X[]; /** * @protected */ protected $modifierConstructors: readonly ModifierConstructor[]; /** * Callback invoked whenever the router's structure is updated. * @protected */ protected $updateCallback?: () => any; /** * Map of mounted child routers by mount path. * @private */ private $mounted; /** * Initializes the RouteCore. * * @param modifiers array of modifier constructors to apply, or undefined. * @param $pathfinder underlying pathfinder router instance. * @param $options optional router settings (excluding modifiers). * @protected */ protected constructor(modifiers: (readonly ModifierConstructor[]) | undefined, $pathfinder: Pathfinder, $options?: RouteOptions); /** * Retrieve route options */ get routeOptions(): RouteOptions | undefined; /** * Accessor for all registered request descriptors, * including those from mounted child routers with full paths. */ get exportRequests(): Internal.Route.RequestDescriptor[]; /** * Mounts a child router at the specified sub-path. * Propagates update callbacks to maintain global request metadata. * * @param path sub-path at which to mount the child router. * @param route child Route instance. */ mount(path: string, route: Route): void; /** * Applies all middleware modifiers to the incoming client request. * Merges each modifier's output into the request object. * * @param req - The parsed client request to modify. * @returns The modified request with merged modifier payloads. * @protected */ protected $injectModifier(req: Internal.Requests.ClientRequest>): Promise, unknown, unknown, unknown>>; /** * Initialize or re-initialize modifier instances * @private */ private initializeModifiers; } export {};