///
import { AbstractSkeletosAction, AbstractSkeletosState, ErrorState, LoadingState } from "skeletos";
import { AbstractRouteState, IRouteBuilderInstance } from "../../";
import { AbstractRootRouteState } from "../state/AbstractRootRouteState";
import { Request, Response } from "../../../shared-interfaces/ExpressInterfaces";
/**
* The route action deals with the lifecycle of routes.
*
* Use the following table to decide what is happening to a route:
*
* oldRoute | newRoute | action
* =======================================
* x | y | Route updating, perhaps the route's currentRoute changed or some query parameter changed.
* null | y | Route is going to be used the first time (route is being mounted)
* x | null | Route is no longer used, perhaps the parent container route's currentRoute != route
*
*
* Note that newRootRoute (and newRoute) represents the current state of the route. Modifying this route will modify
* the URL in your address bar. The oldRootRoute (and oldRoute) is a read-only state for comparison purposes.
*
* Additionally, if this action does not complete successfully (i.e. completes with an error), then newRootRoute
* will be rolled back to oldRootRoute (and hence newRoute will become oldRoute).
*
* If you want this action to complete with an error, so that the newRootRoute is rolled back, but you still want to
* store some state (e.g. an error message) in the db, consider using #getStickyMutableNewRootRouteState()
*/
export declare abstract class AbstractRouteAction extends AbstractSkeletosAction {
/**
* Represents the old route that will be changed to the newRoute. This is a read-only state.
*
* This can be null if the oldRoute did not exist before.
*/
protected oldRoute: RouteStateType;
/**
* Represents the current root route. This is a read-only state.
*/
protected oldRootRoute: RootRouteStateType;
/**
* Represents the new route. This can be null if the newRoute is no longer used.
*/
protected newRoute: RouteStateType;
/**
* Represents the new root route that we are transitioning to. It is also the current state of the route in the db.
*
* If you throw an error in completing this action, the newRootRoute will be rolled back to its previous state,
* the oldRootRoute.
*
* Also, you can use this newRootRoute to make further modifications to the current route.
*
* If you want to make modifications to the new root route but also want to throw an error in the action (for
* example, user is unauthorized and you want to make modifications to the route as a result), you can use
* the attribute #stickyMutableNewRootRouteState.
*/
protected newRootRoute: RootRouteStateType;
/**
* If this action is being executed on the server, then this attribute will hold the Express Request.
*/
protected serverRequest: Request;
/**
* If this action is being executed on the server, then this attribute will hold the Express Response.
*/
protected serverResponse: Response;
/**
* Whether we should redirect to the given URL.
*/
private redirectToUrl;
constructor(oldRoute: RouteStateType, oldRootRoute: RootRouteStateType, newRoute: RouteStateType, newRootRoute: RootRouteStateType, originalServerRequest: Request, originalServerResponse: Response, loadingState?: LoadingState, errorState?: ErrorState);
/**
* Returns the route builder for this.oldRoute. Will return null if this.oldRoute is null.
*
* @returns {IRouteBuilderInstance}
*/
protected readonly routeBuilderUsingOldRoute: IRouteBuilderInstance;
/**
* Returns the route builder for the new route. Will return null if this.newRoute is null.
*
* @returns {IRouteBuilderInstance}
*/
protected readonly routeBuilderUsingNewRoute: IRouteBuilderInstance;
/**
* Returns the route builder for the old root route.
*
* @returns {IRouteBuilderInstance}
*/
protected readonly rootRouteBuilderUsingOldRoute: IRouteBuilderInstance;
/**
* Returns the route builder using the new root route.
*
* @returns {IRouteBuilderInstance}
*/
protected readonly rootRouteBuilderUsingNewRoute: IRouteBuilderInstance;
/**
* Gets the URL from the new route.
*
* @returns {string}
*/
protected readonly newUrl: string;
/**
* Gets the URL from the old route.
*
* @returns {string}
*/
protected readonly oldUrl: string;
/**
* Returns a mutable root route state that can stay mutated even after there is an error in this action that incurs
* a rollback for the transaction. Hence why the mutation is "sticky".
*
* Use this mutable root route state only when you want to modify the root route state before you throw an error,
* and if you want this mutation to not be part of the rollback of this action's transaction.
*
* @returns {RootRouteStateType}
*/
protected getStickyMutableNewRootRouteState(): RootRouteStateType;
protected doAfterExecute(err?: Error): void;
protected doBeforeExecute(): void;
/**
* Redirect to another route. You can use this in cases where you have hit an error (e.g. unauthorized, 404, etc.).
*
* @param {string | IRouteBuilderInstance} redirectUrl
*/
protected redirect(redirectUrl: string | IRouteBuilderInstance): void;
/**
* Logs the start of this action. Called from doBeforeExecute(). Only does it on the client side.
*/
protected logStart(): void;
/**
* Logs the completion of this action. Called from doAfterExecute().
*/
protected logFinish(): void;
private _doRedirect(currentRootRoute);
}