import UrlPattern from "url-pattern"; import { RemoteIconData } from "../icons/icons"; interface IRouteDisplay { title: string; description: string; route: string; icon: RemoteIconData; } /** * a route display data for sending built route data to client. if your client uses remote-ui, it will draw a interactive button, listTile, etc, . automatically targets the route provided. */ export declare class RouteDisplay implements IRouteDisplay { description: string; icon: RemoteIconData; route: string; title: string; constructor(props: any); static fromSpec(spec: any, params: any): RouteDisplay; } export declare enum RouteType { LIST = 0, DETAIL = 1, HOME = 2, MIXED = 3 } /** * @type:P the interface structure type of parameter. e.g. "/users/:id" will take param type { id: string } * @type:T the data type used for building route contents like, title, description, icon * @field:pattern a unique url pattern for this route. e.g. "/users/:id" * @field:key use for loading template, or localized string (template formatted) automatically builds child's key. e.g. if key "menu/user" is provided, it will make title field's key as "menu/user/title" if no override key is provided * @field:params a parsed params value for built route input. e.g. if "/user/123" is provided, params will be { id : "123"} * @field:type a type of this route. * @function:dataFetcher a function for loading data T via provided params P. */ export interface IRouteSpec { pattern: string; key: string; params?: P; type?: RouteType; dataFetcher?: (params: P) => Promise; title: IDisplayFieldBuilder; description?: IDisplayFieldBuilder; icon?: IDisplayFieldBuilder; } /** * a data container interface for building route's specific field. for example, title. (used along with function buildField) * @type:I input data type * @type:O output value type * @field:default a fallback string or default value if no template, key, builder is provided * @field:key use for loading template, or localized string (template formatted) * @field:template a mustache based template, data I from RouteSpec is filled automatically. use valid template. if template is not valid, fallback default value will be returned * @field:builder a builder function which takes I as input and returns O as output */ interface IDisplayFieldBuilder { default: O; key?: string; template?: string; builder?: (data: IDisplayFieldBuilderInput) => O; } interface IDisplayFieldBuilderInput { data: T; params: P; key: string; } export declare class RouteSpec implements IRouteSpec { pattern: string; key: string; params: P; data: T; type: RouteType; dataFetcher: (params: P) => Promise; title: IDisplayFieldBuilder; description?: IDisplayFieldBuilder; icon?: IDisplayFieldBuilder; _compiledPattern: UrlPattern; constructor(props: IRouteSpec); fetchData(): Promise; } export declare class RouteInstance extends RouteSpec { data: T; constructor(props: IRouteSpec); toDisplay(): Promise; buildRoute(): string; buildTitle(): Promise; buildDescription(): Promise; buildIcon(): Promise; } export {};