@lightweightform/theme-common
Version:
Common utilities for Lightweightform themes
83 lines (82 loc) • 2.73 kB
TypeScript
import { Path } from '@angular-devkit/core';
import { Tree } from '@angular-devkit/schematics';
/**
* Interface used to create a new LF route.
*/
export interface NewLfRoute {
/**
* Route's path.
*/
routePath: string;
/**
* Route's associated LF path.
*/
storagePath: string;
/**
* Name of the component to route to.
*/
componentTsName?: string;
/**
* File path of the component to route to.
*/
componentFilePath?: Path;
/**
* When redirecting, route path to which to redirect to.
*/
redirectTo?: string;
/**
* Used to set the `pathMatch` route attribute.
*/
pathMatch?: string;
}
/**
* Information about an LF route.
*/
export interface LfRouteInfo {
/**
* Route.
*/
route?: string;
/**
* Route parameters.
*/
params: string[];
}
/**
* Changes the usage of `Routes` in a given routing module to `LfRoutes`.
* @param host Source tree.
* @param modulePath Path for the routing module on which to make the change.
*/
export declare function changeRoutesToLfRoutes(host: Tree, modulePath: Path): void;
/**
* Adds a new LF route to the router module.
* @param host Source tree.
* @param modulePath Path for the routing module on which to add the route.
* @param route Route to create.
*/
export declare function addLfRoute(host: Tree, modulePath: Path, { routePath, storagePath, componentTsName, componentFilePath, redirectTo, pathMatch, }: NewLfRoute): void;
/**
* Returns whether the routing module at the given path has routes.
* @param host Source tree.
* @param modulePath Path for the routing module.
* @returns Whether the module has any routes.
*/
export declare function hasRoutes(host: Tree, modulePath: Path): boolean;
/**
* Gets the route information of the route associated with the given storage
* path.
* @param host Source tree.
* @param modulePath Path for the routing module.
* @param storagePath Storage path for which to fetch matching route.
* @returns Information about the route matching the provided storage path or
* `undefined` when no match was found.
*/
export declare function getLfRouteInfo(host: Tree, modulePath: Path, storagePath: string): LfRouteInfo | undefined;
/**
* Whether a given route matches with a given storage path.
* @param routePrefix Part of the route before the provided route.
* @param routePath Route.
* @param storagePath Storage path.
* @returns Whether the route matches with a given storage path.
*/
export declare function routeMatchesStoragePath(routePrefix: string, routePath: string, storagePath: string): boolean;