import { ComponentType, ReactNode } from 'react'; /** * Route group configuration */ export interface RouteGroupConfig { /** Unique group name (used in file system as (name)) */ readonly name: string; /** Display name for UI/debugging */ readonly displayName?: string; /** Group description */ readonly description?: string; /** Layout component for all routes in group */ readonly layout?: ComponentType<{ children: ReactNode; }>; /** Guards applied to all routes in group */ readonly guards?: readonly RouteGroupGuard[]; /** Middleware applied to all routes in group */ readonly middleware?: readonly RouteGroupMiddleware[]; /** Metadata inherited by all routes in group */ readonly meta?: RouteGroupMeta; /** Parent group (for nested groups) */ readonly parent?: string; /** Child groups */ readonly children?: readonly string[]; /** Feature flag for this group */ readonly featureFlag?: string; /** Whether group is enabled */ readonly enabled?: boolean; } /** * Route group guard function */ export type RouteGroupGuard = (context: RouteGroupContext) => boolean | Promise; /** * Route group middleware function */ export type RouteGroupMiddleware = (context: RouteGroupContext, next: () => void | Promise) => void | Promise; /** * Context passed to group guards and middleware */ export interface RouteGroupContext { /** Current group */ readonly group: RouteGroup; /** Current route path */ readonly path: string; /** Route parameters */ readonly params: Record; /** Query parameters */ readonly query: Record; /** User context (if available) */ readonly user?: RouteGroupUser; /** Feature flags */ readonly features?: Record; } /** * User context for group access control */ export interface RouteGroupUser { /** User ID */ readonly id: string; /** User roles */ readonly roles: readonly string[]; /** User permissions */ readonly permissions: readonly string[]; /** Additional user data */ readonly data?: Record; } /** * Route group metadata */ export interface RouteGroupMeta { /** Whether routes require authentication */ readonly requiresAuth?: boolean; /** Required roles for access */ readonly roles?: readonly string[]; /** Required permissions for access */ readonly permissions?: readonly string[]; /** Analytics category */ readonly analyticsCategory?: string; /** SEO configuration */ readonly seo?: RouteGroupSEO; /** Custom metadata */ readonly custom?: Record; } /** * SEO configuration for route group */ export interface RouteGroupSEO { /** Title template (can include {route} placeholder) */ readonly titleTemplate?: string; /** Default description */ readonly description?: string; /** robots directive */ readonly robots?: string; } /** * Registered route group */ export interface RouteGroup extends RouteGroupConfig { /** Full path to this group (including parents) */ readonly fullPath: string; /** Computed guards (including inherited) */ readonly computedGuards: readonly RouteGroupGuard[]; /** Computed middleware (including inherited) */ readonly computedMiddleware: readonly RouteGroupMiddleware[]; /** Computed metadata (including inherited) */ readonly computedMeta: RouteGroupMeta; /** Registration timestamp */ readonly registeredAt: number; } /** * Route assignment to group */ export interface GroupedRoute { /** Route path */ readonly path: string; /** Group this route belongs to */ readonly group: string; /** Route-specific metadata (merged with group meta) */ readonly meta?: RouteGroupMeta; /** Route-specific guards (added to group guards) */ readonly guards?: readonly RouteGroupGuard[]; } /** * Group resolution result */ export interface GroupResolution { /** Resolved group chain (from root to leaf) */ readonly groups: readonly RouteGroup[]; /** Combined guards */ readonly guards: readonly RouteGroupGuard[]; /** Combined middleware */ readonly middleware: readonly RouteGroupMiddleware[]; /** Combined metadata */ readonly meta: RouteGroupMeta; /** Layout components (outer to inner) */ readonly layouts: readonly ComponentType<{ children: ReactNode; }>[]; } /** * Manages route group registration and resolution * * @example * ```typescript * const manager = new RouteGroupManager(); * * // Register groups * manager.registerGroup(createRouteGroup({ name: 'marketing' })); * manager.registerGroup(createRouteGroup({ name: 'dashboard', parent: 'auth' })); * * // Resolve groups for a route * const resolution = manager.resolveGroups('/dashboard/settings'); * ``` */ export declare class RouteGroupManager { private groups; private routeAssignments; /** * Register a route group * * @param config - Group configuration * @returns Registered group */ registerGroup(config: RouteGroupConfig): RouteGroup; /** * Unregister a route group * * @param name - Group name * @returns True if group was found and removed */ unregisterGroup(name: string): boolean; /** * Assign a route to a group * * @param route - Grouped route configuration */ assignRoute(route: GroupedRoute): void; /** * Remove route assignment * * @param path - Route path * @returns True if assignment was found and removed */ unassignRoute(path: string): boolean; /** * Get group for a route * * @param path - Route path * @returns Group name or null */ getRouteGroup(path: string): string | null; /** * Get a registered group * * @param name - Group name * @returns Group or undefined */ getGroup(name: string): RouteGroup | undefined; /** * Get all registered groups */ getAllGroups(): readonly RouteGroup[]; /** * Resolve groups for a route path * * @param path - Route path * @returns Group resolution result */ resolveGroups(path: string): GroupResolution; /** * Check if a user can access routes in a group * * @param groupName - Group name * @param user - User context * @returns True if user can access */ canAccess(groupName: string, user: RouteGroupUser | undefined): boolean; /** * Run guards for a group * * @param groupName - Group name * @param context - Guard context * @returns True if all guards pass */ runGuards(groupName: string, context: Omit): Promise; /** * Run middleware chain for a group * * @param groupName - Group name * @param context - Middleware context * @returns Promise that resolves when chain completes */ runMiddleware(groupName: string, context: Omit): Promise; /** * Get all routes in a group * * @param groupName - Group name * @param includeChildren - Include routes in child groups * @returns Array of route paths */ getRoutesInGroup(groupName: string, includeChildren?: boolean): string[]; /** * Clear all groups and assignments */ clearAll(): void; /** * Compute inherited properties from parent groups */ private computeInheritedProperties; /** * Get parent group chain (from root to immediate parent) */ private getParentChain; /** * Merge metadata objects */ private mergeMeta; /** * Get group and all its descendants */ private getGroupWithDescendants; } /** * Create a route group configuration * * @param config - Group configuration * @returns Validated configuration */ export declare function createRouteGroup(config: RouteGroupConfig): RouteGroupConfig; /** * Create a grouped route assignment * * @param path - Route path * @param group - Group name * @param options - Additional options * @returns Grouped route configuration */ export declare function createGroupedRoute(path: string, group: string, options?: Partial>): GroupedRoute; /** * Get the default route group manager */ export declare function getRouteGroupManager(): RouteGroupManager; /** * Reset the default route group manager */ export declare function resetRouteGroupManager(): void; /** * Check if a path segment is a group marker * * @param segment - Path segment * @returns True if segment is a group marker */ export declare function isGroupSegment(segment: string): boolean; /** * Extract group name from segment * * @param segment - Group segment (e.g., '(auth)') * @returns Group name (e.g., 'auth') */ export declare function extractGroupName(segment: string): string | null; /** * Create a group segment from name * * @param name - Group name * @returns Group segment (e.g., '(auth)') */ export declare function createGroupSegment(name: string): string; /** * Extract all groups from a path * * @param path - File path with group markers * @returns Array of group names */ export declare function extractGroupsFromPath(path: string): string[]; /** * Remove group segments from a path * * @param path - Path with group markers * @returns Clean URL path */ export declare function stripGroupsFromPath(path: string): string; /** * Type guard for RouteGroup */ export declare function isRouteGroup(value: unknown): value is RouteGroup; /** * Type guard for GroupedRoute */ export declare function isGroupedRoute(value: unknown): value is GroupedRoute;