@versatiledatakit/shared
Version:
Versatile Data Kit Shared library enables reusability of shared features like: NgRx Redux, Error Handlers, Utils, Generic Components, etc.
204 lines (203 loc) • 5.7 kB
TypeScript
import { Params } from '@angular/router';
import { BaseRouterStoreState, RouterReducerState } from '@ngrx/router-store';
import { PrimitivesNil } from '../../../utils';
import { Serializable, TaurusRouteData } from '../../../common';
/**
* ** Route Segments Class.
*/
export declare class RouteSegments {
readonly routePath: string;
readonly data: TaurusRouteData;
readonly params: Params;
readonly queryParams: Params;
readonly parent?: RouteSegments;
readonly configPath?: string;
/**
* ** Constructor.
*/
constructor(routePath: string, data: TaurusRouteData, params: Params, queryParams: Params, parent?: RouteSegments, configPath?: string);
/**
* ** Factory method.
*/
static of(routePath?: string, data?: TaurusRouteData, params?: Params, queryParams?: Params, parent?: RouteSegments, configPath?: string): RouteSegments;
/**
* ** Factory method for empty RouteSegments.
*/
static empty(): RouteSegments;
/**
* ** Get RoutePath Segments.
*/
get routePathSegments(): string[];
/**
* ** Get ConfigPath Segments.
*/
get configPathSegments(): string[];
/**
* ** Get Data from Route configuration by key.
*
* - Return first (closest) found key starting from the current one.
*/
getData<T>(key: string): T;
/**
* ** Get url param by key.
*
* - Return first (closest) found key starting from the current one.
*/
getParam(key: string): string;
/**
* ** Get query param by key.
*/
getQueryParam(key: string): string;
}
/**
* ** Route State Class.
*/
export declare class RouteState implements BaseRouterStoreState, Serializable<SerializedRouteState> {
readonly routeSegments: RouteSegments;
readonly url: string;
/**
* ** Constructor.
*/
constructor(routeSegments: RouteSegments, url: string);
/**
* ** Factory method.
*/
static of(routeSegments: RouteSegments, url: string): RouteState;
/**
* ** Factory method for empty State.
*/
static empty(): RouteState;
/**
* ** Get serialized queryString.
*/
static serializeQueryParams(queryParams: unknown): string;
/**
* ** Returns current RoutePath.
*/
get routePath(): string;
/**
* ** Returns current Absolute RoutePath.
*/
get absoluteRoutePath(): string;
/**
* ** Returns the route paths for each route segment starting from the root.
*/
get routePathSegments(): string[];
/**
* ** Returns current ConfigPath.
*/
get configPath(): string;
/**
* ** Returns current Absolute ConfigPath.
*/
get absoluteConfigPath(): string;
/**
* ** Returns the config paths for each route segment starting from the root.
*/
get configPathSegments(): string[];
/**
* ** Get all query params.
*/
get queryParams(): Params;
/**
* ** Get serialized queryString.
*/
serializeQueryParams(): string;
/**
* ** Get url including QueryParams.
*/
getUrl(): string;
/**
* ** Get Data from Route configuration by key.
*
* - Return first (closest) found key starting from first RouteSegment.
*/
getData<T>(key: string): T;
/**
* ** Get url param by key.
*
* - Return first (closest) found key starting from first RouteSegment.
*/
getParam(key: string): string;
/**
* ** Get query param by key.
*/
getQueryParam(key: string): string;
/**
* ** Get Absolute ConfigPath.
*/
getAbsoluteConfigPath(): string;
/**
* ** Get parent of current Absolute ConfigPath.
*/
getParentAbsoluteConfigPath(): string;
/**
* ** Get Absolute RoutePath.
*/
getAbsoluteRoutePath(): string;
/**
* ** Get parent of current Absolute RoutePath.
*/
getParentAbsoluteRoutePath(): string;
/**
* @inheritDoc
*/
toJSON(): SerializedRouteState;
/**
* ** Resolve Absolute RoutePath from given routePathSegments.
*/
private static _resolveAbsolutePath;
}
/**
* ** Router state.
*/
export declare class RouterState implements RouterReducerState<RouteState> {
readonly state: RouteState;
readonly navigationId: number;
readonly previousStates: RouterState[];
/**
* ** Constructor.
*/
constructor(state: RouteState, navigationId: number);
/**
* ** Factory method.
*/
static of(state: RouteState, navigationId: number): RouterState;
/**
* ** Factory method for empty State.
*/
static empty(): RouterState;
/**
* ** Returns previous RouterState if exist otherwise null.
*
* - Optional parameter could be provided to instruct which previous RouterState to return, default one is 0.
* - 0 means the first before current.
* - 1 means the second before current.
* - 2 means the third before current.
* - 3 ... etc...
*/
getPrevious(index?: number): RouterState | null;
/**
* ** Append previous RouterState[] to current One.
*
* - Internal API used in reducer, not for public use.
*/
appendPrevious(routerState: RouterState): void;
}
/**
* ** Route state serialized.
*/
interface SerializedRouteState {
url: string;
routePath: string;
absoluteRoutePath: string;
routePathSegments: string[];
configPath: string;
absoluteConfigPath: string;
configPathSegments: string[];
queryParams: {
[]: PrimitivesNil;
};
routeSegments: RouteSegments;
}
export {};