import { Route } from './route'; import { AnyPathParams, AnyRouteConfig, AnyRouteConfigWithChildren, AnySearchSchema, RootRouteId, RouteConfig, RouteOptions } from './routeConfig'; import { IsAny, UnionToIntersection, Values } from './utils'; export interface AnyAllRouteInfo { routeConfig: AnyRouteConfig; routeInfo: AnyRouteInfo; routeInfoById: Record; routeInfoByFullPath: Record; routeIds: any; routePaths: any; fullSearchSchema: Record; allParams: Record; } export interface DefaultAllRouteInfo { routeConfig: RouteConfig; routeInfo: RouteInfo; routeInfoById: Record; routeInfoByFullPath: Record; routeIds: string; routePaths: string; fullSearchSchema: AnySearchSchema; allParams: AnyPathParams; } export interface AllRouteInfo extends RoutesInfoInner> { } export type ParseRouteConfig = TRouteConfig extends AnyRouteConfig ? RouteConfigRoute | ParseRouteChildren : never; type ParseRouteChildren = TRouteConfig extends AnyRouteConfigWithChildren ? unknown extends TChildren ? never : TChildren extends AnyRouteConfig[] ? Values<{ [TId in TChildren[number]['id']]: ParseRouteChild; }> : never : never; type ParseRouteChild = TRouteConfig & { id: TId; } extends AnyRouteConfig ? ParseRouteConfig : never; export type RouteConfigRoute = TRouteConfig extends RouteConfig ? string extends TCustomId ? never : RouteInfo : never; export interface RoutesInfoInner = RouteInfo, TRouteInfoById = { '/': TRouteInfo; } & { [TInfo in TRouteInfo as TInfo['id']]: TInfo; }, TRouteInfoByFullPath = { '/': TRouteInfo; } & { [TInfo in TRouteInfo as TInfo['fullPath'] extends RootRouteId ? never : string extends TInfo['fullPath'] ? never : TInfo['fullPath']]: TInfo; }> { routeConfig: TRouteConfig; routeInfo: TRouteInfo; routeInfoById: TRouteInfoById; routeInfoByFullPath: TRouteInfoByFullPath; routeIds: keyof TRouteInfoById; routePaths: keyof TRouteInfoByFullPath; fullSearchSchema: Partial>; allParams: Partial>; } export interface AnyRouteInfo extends RouteInfo { } export interface RouteInfo { id: TId; customId: TCustomId; path: TPath; fullPath: TFullPath; searchSchema: TSearchSchema; fullSearchSchema: TFullSearchSchema; parentParams: TParentParams; params: TParams; allParams: TAllParams; options: RouteOptions; } export type RoutesById = { [K in keyof TAllRouteInfo['routeInfoById']]: Route; }; export type RouteInfoById = TId extends keyof TAllRouteInfo['routeInfoById'] ? IsAny : never; export type RouteInfoByPath = TPath extends keyof TAllRouteInfo['routeInfoByFullPath'] ? IsAny : never; export {};