UNPKG

polen

Version:

A framework for delightful GraphQL developer portals

60 lines (59 loc) 1.89 kB
import { type Path } from '@wollybeard/kit'; export type Path = PathSegment[]; export type PathRoot = []; export type PathTop = [PathSegment]; export type PathSub = [PathSegment, PathSegment, ...PathSegment[]]; export type PathSegment = string; export declare const sep = "/"; export declare const pathToExpression: (path: Path) => string; export interface Route { logical: RouteLogical; file: RouteFile; id: string; parentId: string | null; } export interface RouteLogical { path: Path; order?: number; } export interface RouteFile { path: { relative: Path.Parsed; absolute: Path.Parsed; }; } export interface TopLevelRoute extends Route { logical: TopLevelRouteLogical; } export interface TopLevelRouteLogical { path: PathTop; } /** * Route is top level meaning exists directly under the root. * * It excludes the root level route. */ export declare const routeIsTopLevel: (route: Route) => route is TopLevelRoute; export interface RouteSubLevel extends Route { logical: RoutePathSubLevel; } export interface RoutePathSubLevel { path: PathSub; } /** * Route is not top or root level */ export declare const routeIsSubLevel: (route: Route) => route is RouteSubLevel; /** * Route is the singular root route. * This is the case of index under root. */ export declare const routeIsRootLevel: (route: Route) => route is TopLevelRoute; export declare const routeIsFromIndexFile: (route: Route) => boolean; export declare const routeIsSubOf: (route: Route, potentialAncestorPath: PathSegment[]) => boolean; /** * You are responsible for ensuring given ancestor path is really an ancestor of given route's path. */ export declare const makeRelativeUnsafe: (route: Route, assumedAncestorPath: PathSegment[]) => Route; export declare const routeToPathExpression: (route: Route) => string; //# sourceMappingURL=route.d.ts.map