CommandsRouter
CommandsRouter
Handles discovery and parsing of command and middleware files in the filesystem.
class CommandsRouter {
constructor(options: CommandsRouterOptions)
populate(data: ParsedCommandData) => void;
isValidPath() => boolean;
clear() => void;
scan() => Promise<ParsedCommandData>;
scanIncremental(changedPath: string, _changeType: RouterFileChangeType = 'change') => Promise<ParsedCommandData>;
getData() => {
commands: Collection<string, Command>;
middlewares: Collection<string, Middleware>;
treeNodes: Collection<string, CommandTreeNode>;
compiledRoutes: Collection<string, CompiledCommandRoute>;
diagnostics: CommandRouteDiagnostic[];
};
getTreeData() => {
treeNodes: Collection<string, CommandTreeNode>;
compiledRoutes: Collection<string, CompiledCommandRoute>;
diagnostics: CommandRouteDiagnostic[];
};
toJSON() => ParsedCommandData;
}
constructor
(options: CommandsRouterOptions) => CommandsRouterCreates a new CommandsRouter instance.
populate
(data: ParsedCommandData) => voidPopulates the router with existing command, middleware, and tree data.
isValidPath
() => booleanChecks if the configured entrypoint path exists.
clear
() => voidClears all loaded commands, middleware, and compiled tree data.
scan
() => Promise<ParsedCommandData>Scans the filesystem for commands and middleware files.
scanIncremental
(changedPath: string, _changeType: RouterFileChangeType = 'change') => Promise<ParsedCommandData>Incrementally updates only the top-level command subtree affected by a file change. Falls back to a full scan when the changed path cannot be safely scoped.
getData
() => { commands: Collection<string, Command>; middlewares: Collection<string, Middleware>; treeNodes: Collection<string, CommandTreeNode>; compiledRoutes: Collection<string, CompiledCommandRoute>; diagnostics: CommandRouteDiagnostic[]; }Gets the raw command, middleware, and compiled tree collections.
getTreeData
() => { treeNodes: Collection<string, CommandTreeNode>; compiledRoutes: Collection<string, CompiledCommandRoute>; diagnostics: CommandRouteDiagnostic[]; }Gets only the internal command tree and compiled route data.
toJSON
() => ParsedCommandDataConverts the loaded data to a JSON-serializable format.