web: update the type names for routes.

While writing up the commit message for the previous commit, I realized that I didn't really like
the typenames as they're outlaid in `routeUtils`.  This is much more explicit, describing the
four types of routes we have: ListRoute, ViewRoute, InternalRedirect, ExternalRedirect.
This commit is contained in:
Ken Sternberg
2024-03-14 14:40:19 -07:00
parent 70bf745c0c
commit 27e9e892e7

View File

@ -3,13 +3,17 @@ import { P, match } from "ts-pattern";
import { TemplateResult } from "lit";
type RouteInvoke =
| ((_1: RouteArgs) => Promise<TemplateResult<1>>)
| (() => Promise<TemplateResult<1>>);
type ListRoute = () => Promise<TemplateResult<1>>;
type ViewRoute = (_1: RouteArgs) => Promise<TemplateResult<1>>;
type InternalRedirect = string;
type ExternalRedirect = [string, boolean];
type _RawRedirect = [string, string | [string, boolean]];
type _RawRoute = [string, RouteInvoke];
export type RawRoute = _RawRoute | _RawRedirect;
type RouteInvoke = ViewRoute | ListRoute;
type RedirectRoute = [string, InternalRedirect | ExternalRedirect];
type PageRoute = [string, RouteInvoke];
export type RawRoute = PageRoute | RedirectRoute;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const isLoader = (v: any): v is RouteInvoke => typeof v === "function";