export declare type ResourceAction = Function; export interface ResourceModule { name: string; pathPrefix?: string; extraActions?: Array; index?: ResourceActionType; new?: ResourceActionType; new_?: ResourceActionType; create?: ResourceActionType; show?: ResourceActionType; edit?: ResourceActionType; update?: ResourceActionType; updateByPost?: ResourceActionType; destroy?: ResourceActionType; delete?: ResourceActionType; } export declare class ActionMethod { value: string; constructor(value: string); static ALL: ActionMethod; static GET: ActionMethod; static POST: ActionMethod; static PUT: ActionMethod; static DELETE: ActionMethod; static PATCH: ActionMethod; static OPTIONS: ActionMethod; static HEAD: ActionMethod; static fromValue(value: string): ActionMethod; } export interface ResourceEndpoint { /** * HTTP Method * @type {ActionMethod} */ method: ActionMethod; /** * The HTTP path to the endpoint * @type {string} */ path: string; /** * Name of the action * @type {string} */ name: string; } export interface Resource { handler: ResourceModule; endpoints: { [key: string]: ResourceEndpoint; }; } export interface SerializedResourceEndpoint { /** * HTTP Method * @type {string} */ method: string; /** * The HTTP path to the endpoint * @type {string} */ path: string; /** * Name of the action * @type {string} */ name: string; } export interface SerializedResource { handler: { [key: string]: string; }; endpoints: { [key: string]: SerializedResourceEndpoint; }; } export interface ResourceCollectionJson { globalPathPrefix: string; paths: { [key: string]: SerializedResource; }; } export declare class ResourceCollection { globalPathPrefix: string; resources: { [key: string]: Resource; }; constructor(globalPathPrefix?: string); getEndpoint(resource: string, action: string): ResourceEndpoint; /** * Add a resource to the ResourceCollection instance. * @param {string} name name of the resource. * @param {Resource} resourceModule the module with action. if you * just want the path helpers, * you can ignore this parameter. * handlers * @param {ResourceEndpoint[]} extra non-restful endpoints. * @return {void} */ resource(name: string, resourceModule?: ResourceModule, extra?: ResourceEndpoint[]): void; registerResourceModule(name: string, resourceModule: ResourceModule): void; hasAction(resourceName: string, actionName: string): boolean; toJson(): ResourceCollectionJson; /** * Restore the endpoints in the serialied ResourceCollection json instance. * @param {SerializedResource|string}} json The serialized * ResourceCollection instance from * toJson method. */ loadFromJson(json: ResourceCollectionJson): void; } export declare class PathHelpers { resources: ResourceCollection; urlRoot: string; constructor(resources: ResourceCollection, urlRoot?: string); regexOf(resource: string): RegExp; /** * Return the path to the specified resource action. * @param {string} resource The name of the resource. * @param {string} action The name of the action. * @param {string|string[]} args The arguments to be supplied to * the path params. Formatting is * done by utils.fillString function. * @param {dict} getParams The url's get parameters. * @return {string} The final url. */ pathTo(resource: string, action: string, args?: any | any[], getParams?: { [key: string]: any; }): string; genPathTo(resource: string, action: string): (args?: any, getParams?: { [key: string]: any; }) => string; urlTo(resource: string, action: string, args?: any | any[], getParams?: { [key: string]: any; }): string; genUrlTo(resource: string, action: string): (args?: any, getParams?: { [key: string]: any; }) => string; }