import { Middleware as Middleware$1, IError, Response as Response$1, Request as Request$1, Polka } from 'polka';
import { File } from 'formidable';
import * as express_session from 'express-session';
import { Session, Store } from 'express-session';
import { Validator as Validator$1 } from '@kodepandai/node-input-validator';
import { StorageManager } from '@kodepandai/flydrive';
import { AsyncLocalStorage } from 'async_hooks';
import { Command as Command$1 } from 'commander';

declare class Repository {
    static symbol: symbol;
    /** All configuration items */
    protected items: ObjectOf<any>;
    constructor(items: ObjectOf<any>);
    /**
     * Determine if the given configuration value exists.
     */
    has(key: string): boolean;
    /**
     * Get the specified configuration value.
     */
    get<T = any>(key?: string, defaultValue?: T): T;
    /**
     * Get all of the configuration items for the application.
     */
    all(): ObjectOf<any>;
    /**
     * Set a given configuration value.
     */
    set(key: string, value: any | null): void;
}

interface Binding {
    concrete: Concrete;
    shared: boolean;
}
declare class Container {
    /** The container's shared instances. */
    instances: Record<string | symbol, any>;
    /** The container's bindings. */
    protected bindings: Record<string | symbol, Binding>;
    /** Register a binding with the container. */
    bind(abstract: string | symbol, concrete: Concrete, shared?: boolean): void;
    /** Register shared binding in container. */
    singleton(abstract: string | symbol, concrete: Concrete): void;
    /** Instantiate a concrete instance of the given type. */
    build<T>(abstract: string | symbol, params?: Record<string, any>): T;
    /** Resolve the given type from the container. */
    make<T = any>(abstract: string | symbol, params?: {}): T;
    /** Register an existing instance as shared in the container. */
    instance(abstract: string | symbol, instance: any): any;
}

interface Bootstrapper {
    bootstrap: (app: Application) => Promise<void>;
}

declare class Command {
    protected lunox: Application;
    SUCCESS: 0;
    FAILURE: 1;
    INVALID: 2;
    protected signature: string;
    protected description: string;
    protected args: ObjectOf<string>;
    protected opts: ObjectOf<any>;
    handle(): Promise<0 | 1 | 2>;
    getSignature(): string;
    getDescription(): string;
    setArguments(args: ObjectOf<string>): void;
    setOptions(opts: ObjectOf<any>): void;
    setLunox(lunox: Application): void;
    arguments(): ObjectOf<string>;
    argument(key: string): string;
    options(): ObjectOf<any>;
    option(key: string): any;
    protected info(message: string): void;
    protected line(message: string): void;
    protected error(message: string): void;
    protected newLine(line?: number): void;
    protected comment(message: string): void;
    tryCommand(name: string, run: () => Promise<void>, onError: (error: string) => void): Promise<void>;
    shellExec(command: string, watch?: boolean): Promise<void>;
}

declare class Kernel$1 {
    protected app: Application;
    protected program: Command$1;
    protected bootstrappers: Class<Bootstrapper>[];
    constructor(app: Application);
    handle(): Promise<void>;
    /**
     * Register built in commans for the application
     */
    protected builtinCommands(): Promise<void>;
    /**
     * Register the Closure based commands for the application.
     */
    protected commands(): Promise<void>;
    protected load(paths: string): Promise<void>;
    protected registerCommand(commandInstance: Command): void;
}

declare abstract class ServiceProvider {
    protected app: Application;
    constructor(app: Application);
    register(): Promise<void>;
    boot(): Promise<void>;
    commands(commands: (typeof Command)[]): void;
}

declare class Cookie {
    protected name: string;
    protected value: any;
    protected expires: number;
    protected path: string;
    protected domain: string | undefined | null;
    protected secure: boolean;
    protected httpOnly: boolean;
    protected raw: boolean;
    protected sameSite: "lax" | "strict" | "none" | undefined | null;
    constructor(name: string, value: any, expires?: number, path?: string, domain?: string | undefined | null, secure?: boolean, httpOnly?: boolean, raw?: boolean, sameSite?: "lax" | "strict" | "none" | undefined | null);
    static fromString(_cookie: string): Cookie | null;
    static getExpiresTimeFromLifeTime(lifetime: number | string): number;
    getName(): string;
    getExpiresTime(): number;
    getPath(): string;
    getDomain(): string | null | undefined;
    isSecure(): boolean;
    isHttpOnly(): boolean;
    isRaw(): boolean;
    getSameSite(): "lax" | "strict" | "none" | null | undefined;
    getValue(): any;
    toString(): string;
}

declare class Validator extends Validator$1 {
    protected _inputs: ObjectOf<any>;
    constructor(data: ObjectOf<any>, rules: ObjectOf<any>, messages: ObjectOf<any>, customAttributes?: ObjectOf<any>);
    fails(): Promise<boolean>;
    validate(inputs?: ObjectOf<any>): Promise<any>;
}

interface Rule {
    name: string;
    passes: (args: string[] | undefined, value: any) => Promise<boolean>;
    message?: string;
}

declare class Factory {
    static symbol: symbol;
    protected app: Application;
    constructor(app: Application);
    make(data: ObjectOf<any>, rules: ObjectOf<string>, messages?: ObjectOf<string>, customAttributes?: ObjectOf<string>): Validator;
    extend(rule: Rule): void;
}

declare class FormRequest extends _default$a {
    /**
     * validator instance.
     */
    protected validator: Validator | null;
    /**
     * Get rules for validator.
     */
    rules(): Record<string, any>;
    /**
     * Get custom messages for validator errors.
     */
    messages(): Record<string, any>;
    /**
     * Set validator instance.
     */
    setValidator(validator: Validator): this;
    /**
     * Get custom attributes for validator errors.
     */
    attributes(): Record<string, any>;
    /**
     * Validate this form request.
     */
    validateForm(): Promise<any>;
    /**
     * Create default validator instance
     */
    protected createDefaultValidator(factory: Factory): Validator;
    /**
     * Get validator instance for the request.
     */
    protected getValidatorInstance(): Validator;
}

type NativeMiddleware = Middleware$1;
type NextFunction = (req: Request) => Response;
type MiddlewareStack = null | Middleware | string | (Middleware | string)[];
interface Middleware {
    handle?: (req: Request, next: NextFunction, ...args: any[]) => Promise<Response>;
    handleAfter?: (res: Response, req: Request) => Promise<Response>;
    handleNative?: NativeMiddleware;
}

declare class Kernel {
    protected app: Application;
    protected middleware: (Middleware | Class<Middleware>)[];
    protected middlewareGroups: Record<string, (Middleware | Class<Middleware>)[]>;
    protected routeMiddleware: Record<string, Middleware | Class<Middleware>>;
    protected bootstrappers: Class<Bootstrapper>[];
    constructor(app: Application);
    start(): Promise<Application>;
    private handleMiddleware;
    private send;
    protected reportException(e: string | IError): void;
    protected renderException(req: Request, e: string | IError): Promise<Response>;
}

type CipherTypes = "aes-128-cbc" | "aes-256-cbc" | "aes-128-gcm" | "aes-256-gcm";
interface JsonPayload {
    iv: string;
    mac: string;
    value: string;
}

declare class Encrypter {
    static symbol: symbol;
    protected key: Buffer;
    protected cipher: CipherTypes;
    private static supportedCiphers;
    constructor(key: Buffer, cipher?: CipherTypes);
    getKey(): Buffer;
    static supported(key: Buffer, cipher: CipherTypes): boolean;
    static generateKey(cipher: CipherTypes): Buffer;
    encrypt(value: any, needSerialize?: boolean): string;
    encryptString(value: string): string;
    decrypt(payloadString: string, needUnserialize?: boolean): any;
    decryptString(payloadString: string): any;
    hash(iv: string, value: string): string;
    hashHmac(algoritm: "sha1" | "sha256", data: string, key: Buffer): string;
    protected getJsonPayload(payload: string): JsonPayload;
    protected isValidPayload(payload: ObjectOf<any>): boolean;
    protected isValidMac(payload: JsonPayload): boolean;
    static hashEquals(answer: string, guess: string): boolean;
    static base64Encode(value: string | Buffer): string;
    static base64Decode(value: string): Buffer;
}

interface AppConfig {
    name: string;
    env: string;
    key: string;
    cipher: CipherTypes;
    providers: (typeof ServiceProvider)[];
}
interface SessionConfig {
    driver: "file" | "cookie" | "database";
    lifetime: number;
    files: string;
    table: string;
    cookie: string;
    path: string;
    domain?: string;
    http_only: boolean;
    same_site: "lax" | "strict" | "none" | null;
    secure: boolean;
}

declare class VerifyCsrfToken implements Middleware {
    protected app: Application;
    protected encrypter: Encrypter;
    protected except: string[];
    protected addHttpCookie: boolean;
    constructor();
    handle(req: Request, next: NextFunction): Promise<Response>;
    protected isReading(req: Request): boolean;
    protected runningUnitTests(): boolean | null;
    protected inExceptArray(req: Request): boolean;
    protected tokensMatch(req: Request): boolean;
    protected getTokenFromRequest(req: Request): any;
    shouldAddXsrfTokenCookie(): boolean;
    protected addCookieToResponse(req: Request, res: Response): void;
    protected newCookie(req: Request, config: SessionConfig): Cookie;
}

interface ResponseHeaders {
    [key: string]: any;
    getCookies: () => Cookie[];
    setCookie: (cookie: Cookie) => void;
}
declare class Response {
    protected original: any;
    protected status: number;
    protected _headers: Record<string, any>;
    protected res?: Response$1;
    protected cookies: Cookie[];
    constructor(content: any, status?: number, headers?: Record<string, any>);
    getCookies(): Cookie[];
    setCookie(cookie: Cookie): void;
    getOriginal(): any;
    getStatus(): number;
    get headers(): ResponseHeaders;
    setCookiesToHeaders(): void;
    setOriginal(data: any): this;
    setServerResponse(res: Response$1): this;
    mergeResponse(res: Response): void;
    getServerResponse(): Response$1 | undefined;
    setHeader(key: string, value: string | string[]): this;
}

interface ResponseRenderer {
    render(request: Request): Promise<Response>;
}

declare class Application extends Container {
    protected _basePath: string;
    protected isBooted: boolean;
    config: Repository;
    responseRenderers: Class<ResponseRenderer>[];
    protected isRunningInConsole: boolean | null;
    constructor(basePath?: string | null);
    setBasePath(basePath: string | null): string;
    basePath(_path?: string): string;
    configPath(_path?: string): string;
    storagePath(_path?: string): string;
    bindPaths(): void;
    bootstrapWith(bootstrappers: Class<Bootstrapper>[]): Promise<void>;
    register(provider: ServiceProvider): Promise<void>;
    registerConfiguredProviders(): Promise<void>;
    boot(): Promise<void>;
    protected registerBaseServiceProviders(): Promise<void>;
    abort(code: number, message?: string, headers?: ObjectOf<string>): void;
    runningInConsole(): boolean | null;
    runingUnitTests(): boolean;
}

declare class UploadedFile {
    protected file: File | File[];
    constructor(file: File | File[]);
    path(): string;
    getClientOriginalExtension(): string;
    getClientOriginalName(): string | null;
    getClientMimeType(): string | null;
    move(directory: string, name?: string | null): void;
    private failIfArray;
    private moveFile;
}

interface ExtendedRequest extends Request$1 {
    session?: Session;
}

interface ExtendedSession extends Partial<Session> {
    __old?: any;
    __lastAccess?: any;
    sessionStore?: Store;
    [key: string]: any;
}
declare class SessionManager {
    static symbol: symbol;
    protected app: Application;
    protected session: ExtendedSession;
    protected request: Request;
    protected started: boolean;
    constructor(app: Application);
    setRequest(request: Request): this;
    get(key: string): any;
    /**
     * get flashed session.
     */
    getFlashed(): any;
    old(key?: string): any;
    all(withFlashed?: boolean, withAuth?: boolean, withToken?: boolean): {
        [x: string]: any;
        __old?: any;
        __lastAccess?: any;
        sessionStore?: Store | undefined;
        id?: string | undefined;
        cookie?: express_session.Cookie | undefined;
        regenerate?: ((callback: (err: any) => void) => Session) | undefined;
        destroy?: ((callback: (err: any) => void) => Session) | undefined;
        reload?: ((callback: (err: any) => void) => Session) | undefined;
        resetMaxAge?: (() => Session) | undefined;
        save?: ((callback?: ((err: any) => void) | undefined) => Session) | undefined;
        touch?: (() => Session) | undefined;
    };
    put(key: string, value: any): void;
    /**
     * flash session to view. Will be removed on next request.
     */
    flash(key: string, value: any): void;
    has(key: string): boolean;
    exists(key: string): boolean;
    save(): Promise<unknown>;
    flush(): Promise<unknown>;
    remove(key: string): void;
    forget(keys: string[]): void;
    static getDefaultDriver(): string;
    static getStore(session: any): Promise<Store>;
    private static getStoreConfig;
    static getConfig(): SessionConfig;
    migrate(destroy?: boolean): Promise<boolean>;
    start(): Promise<void>;
    regenerateToken(): void;
    token(): any;
    isStarted(): boolean;
}

interface Authenticatable {
    getAuthIdentifierName(): string;
    getAuthPassword(): string;
    getAuthIdentifier(): string;
    /**
     * Get the token value for the "remember me" session.
     */
    getRememberToken(): string;
    /**
     * Get the column name for the "remember me" token.
     */
    getRememberTokenName(): string;
    /**
     * Set the token value for the "remember me" session.
     */
    setRememberToken(token: string): void;
}
interface Credentials {
    password?: string;
    [key: string]: any;
}

interface Guard {
    check(): Promise<boolean>;
    guest(): Promise<boolean>;
    user<T = Authenticatable>(): Promise<T | undefined>;
    id(): Promise<string | undefined>;
    validate(credentials: Credentials): Promise<boolean>;
    setUser(user: Authenticatable): void;
}

interface StatefulGuard extends Guard {
    attempt: (credentials: Credentials, remember?: boolean) => Promise<boolean>;
    login(user: Authenticatable, remember?: boolean): Promise<void>;
    logout(): Promise<void>;
}

interface UserProvider {
    validateCredentials(user: Authenticatable, credentials: Credentials): boolean;
    retrieveByCredentials(credentials: Credentials): Promise<Authenticatable | undefined>;
    retrieveById(id: string): Promise<Authenticatable | undefined>;
    /**
     * Update the "remember me" token for the given user in storage.
     */
    updateRememberToken(user: Authenticatable, token: string): Promise<void>;
    /**
     * Retrieve a user by their unique identifier and "remember me" token.
     */
    retrieveByToken(identifier: any, token: string): Promise<Authenticatable | undefined>;
}

interface ExceptionHandler {
    render(req: Request, e: Error): Promise<Response>;
    report(e: Error): void;
}

interface HttpExceptionInterface {
    getStatusCode(): number;
    getHeaders(): ObjectOf<string>;
    getPrevious(): Error | null;
}

type Method = "post" | "delete" | "get" | "put" | "patch" | "all";
interface Routes {
    prefix: string;
    uri: string;
    method: Method;
    action: RouteCallback;
    middleware: (string | Middleware)[];
    controllerMiddleware: (string | Middleware)[];
    [key: string]: any;
}
type RouteCallback = (req: Request, ...params: any) => any;

interface HttpController {
    [key: string]: RouteCallback;
}

interface Configuration {
    driver: string;
    url?: string;
    host: string;
    port: string;
    database: string;
    username: string;
    password: string;
    useNullAsDefault?: boolean;
    pool?: {
        min?: number;
        max?: number;
        idleTimeoutMillis?: number;
    };
}

declare abstract class GuardHelper {
    protected _user?: Authenticatable;
    protected provider: UserProvider;
    user<T = Authenticatable>(): Promise<T | undefined>;
    protected authenticate(): Authenticatable;
    check(): Promise<boolean>;
    guest(): Promise<boolean>;
    id(): Promise<string | undefined>;
    getProvider(): UserProvider;
    setProvider(provider: UserProvider): void;
}

declare class Recaller {
    protected recaller: string;
    constructor(recaller: string);
    /**
     * Determine if the recaller is valid.
     */
    valid(): boolean;
    /**
     * Determine if the recaller is an valid string.
     */
    protected properString(): boolean;
    /**
     * Determine if the recaller has all segments.
     */
    protected hasAllSegments(): boolean;
    /**
     * Get the user ID from the recaller
     */
    id(): string;
    /**
     * Get the "remember token" from the recaller
     */
    token(): string;
}

declare class SessionGuard extends GuardHelper implements StatefulGuard {
    name: string;
    session: SessionManager;
    request: Request;
    lastAttempted: Authenticatable | undefined;
    /**
     * The number of minutes that the "remember me" cookie should be valid for.
     */
    protected rememberDuration: number;
    protected loggedOut: boolean;
    /**
     * Indicates if a token user retrieval has been attempted.
     */
    protected recallAttempted: boolean;
    /**
     * Indicates if the user was authenticated via a recaller cookie.
     */
    protected viaRemember: boolean;
    constructor(name: string, provider: UserProvider, session: SessionManager, request: Request);
    validate(credentials: Credentials): Promise<boolean>;
    once(credentials: Credentials): Promise<boolean>;
    attempt(credentials?: Credentials, remember?: boolean): Promise<boolean>;
    protected hasValidCredentials(user: Authenticatable | undefined, credentials: Credentials): boolean;
    login(user: Authenticatable, remember?: boolean): Promise<void>;
    /**
     * Queue the recaller cookie into the cookie jar.
     */
    protected queueRecallerCookie(user: Authenticatable): void;
    /**
     * Create a "remember me" cookie for a given ID.
     */
    protected createRecaller(value: string): Cookie;
    /**
     * Get the number of minutes the remember me cookie should be valid for.
     */
    protected getRememberDuration(): number;
    /**
     * Set the number of minutes the remember me cookie should be valid for.
     */
    setRememberDuration(minutes: number): this;
    /**
     * Create a new "remember me" token for the user if one doesn't already exist.
     */
    protected ensureRememberTokenIsSet(user: Authenticatable): Promise<void>;
    /**
     * Refresh the "remember me" token for the user.
     */
    protected cycleRememberToken(user: Authenticatable): Promise<void>;
    logout(): Promise<void>;
    setUser(user: Authenticatable): this;
    getName(): string;
    protected updateSession(id: string): Promise<void>;
    user<T = Authenticatable>(): Promise<T | undefined>;
    /**
     * Pull a user from the repository by its "remember me" cookie token.
     */
    protected userFromRecaller(recaller: Recaller): Promise<Authenticatable | undefined>;
    /**
     * Get the decrypted recaller cookie for the request.
     */
    protected recaller(): Recaller | undefined;
    /**
     * Get the name of the cookie used to store the "recaller".
     */
    protected getRecallerName(): string;
    /**
     * Remove the user data from the session and cookies.
     */
    protected clearUserDataFromStorage(): void;
}

type UserProviderCreator = (config: Record<string, any>) => UserProvider;
declare class AuthManager {
    static symbol: symbol;
    protected app: Application;
    protected guards: Record<string, StatefulGuard>;
    protected request: Request;
    protected static userProviders: Record<string, UserProviderCreator>;
    constructor(app: Application);
    setRequest(request: Request): this;
    guard(name?: string): StatefulGuard;
    getDefaultDriver(): string;
    static registerUserProvider(name: string, providerCreator: UserProviderCreator): void;
    protected resolve(name: string): StatefulGuard;
    protected getConfig(name: string): Record<string, any>;
    protected createSessionDriver(name: string, config: Record<string, any>): SessionGuard;
    createUserProvider(provider: string): UserProvider;
    protected getProviderConfiguration(provider?: string): Record<string, any> | undefined;
    protected config<T>(key: string): T;
    getDefaultUserProvider(): string;
    __get(method: keyof StatefulGuard): any;
}
declare const _default$c: typeof AuthManager & Class<StatefulGuard, any[]>;

type Macro = (...arg: any[]) => any;
declare class Macroable {
    protected static macros: ObjectOf<Macro>;
    /**
     * Register a custom macro
     */
    static macro(name: string, macro: Macro): void;
    /**
     * Check if macro is registered
     */
    static hasMacro(name: string): boolean;
    /**
     * Flush the existing macros
     */
    static flushMacros(): void;
    /**
     * Dynamically handle call to the class
     */
    protected static __getStatic(method: string): any;
    /**
     * Dynamically handle call to the class
     */
    protected __get(method: string): any;
}
declare const _default$b: typeof Macroable;

declare class CookieJar {
    protected _queued: ObjectOf<Record<string, Cookie>>;
    /**
     * Create new Cookie instance
     */
    make(name: string, value: any, minutes?: number, path?: string, domain?: string | undefined | null, secure?: boolean, httpOnly?: boolean, raw?: boolean, sameSite?: "lax" | "strict" | "none" | undefined | null): Cookie;
    /**
     * Queue a cookie to send with the next response.
     */
    queue(...params: any[]): void;
    /**
     * Get the cookies which have been queued for the next request.
     */
    getQueuedCookies(): Cookie[];
    /**
     * Flush the cookies which have been queued for the next request.
     */
    flushQueuedCookies(): this;
    /**
     * Expire the given cookie.
     */
    forget(name: string, path?: string, domain?: string | undefined | null): Cookie;
}

interface RequestCookies {
    [key: string]: any;
    set: (key: string, value: any) => void;
    get: (key: string) => any;
}
declare class Request extends _default$b {
    protected static macros: Record<string, Macro>;
    static symbol: symbol;
    protected app: Application;
    files: Record<string, UploadedFile>;
    protected req: ExtendedRequest;
    protected data: Record<string, any>;
    protected sessionManager: SessionManager | null;
    protected authManager: (AuthManager & StatefulGuard) | null;
    protected _cookies: Record<string, any> | null;
    protected _cookieJar: CookieJar | null;
    protected router: Partial<Routes>;
    protected formRequest: FormRequest | null;
    constructor(app: Application, req: ExtendedRequest);
    get<T = any>(key: string, defaultValue?: any): T;
    input(key: string, defaultValue?: any): any;
    header(key: string): string | string[] | undefined;
    only(keys: string[]): Record<string, any>;
    all(): any;
    allFiles(): Record<string, UploadedFile>;
    file(key: string): UploadedFile;
    method(): string;
    merge(newData: Record<string, any>): this;
    getOriginalRequest(): ExtendedRequest;
    instance(): this;
    session(): SessionManager;
    get cookies(): RequestCookies;
    get cookieJar(): CookieJar;
    protected setCookie(key: string, value: any): void;
    protected getCookie(key: string): any;
    auth(): AuthManager & StatefulGuard;
    wantsJson(): boolean;
    /**
     * Validate request inputs.
     */
    validate(rules: Record<string, string>, messages?: Record<string, string>, customAttributes?: Record<string, string>): Promise<any>;
    /**
     * set Form Request for validation.
     */
    setFormRequest(formRequest: typeof FormRequest): FormRequest;
    /**
     * Get Form Request instance
     */
    getFormRequest(): FormRequest | null;
    is(...patterns: any[]): boolean;
    /**
     * Set router data to request instance
     */
    setRouter(router: Routes): void;
    /**
     * Get router data from current route
     */
    getRouter(): Partial<Routes>;
}
interface Request {
    macro: (name: string, macro: Macro) => any;
    [key: string]: any;
}
declare const _default$a: typeof Request;

type Concrete = NewableFunction | (() => any);
type CallBack = (...params: any[]) => any;
interface ObjectOf<T> {
    [key: string]: T;
}
type Class<I, Args extends any[] = any[]> = new (...args: Args) => I;
type Server = Polka;
type OnServer = (req: Request, ctx: any) => Promise<ObjectOf<any>>;

type Trait<Base = any, T = any> = (s: Base) => T;
declare const Traitable: <T>(superclass: T) => TraitBuilder<T>;
declare class TraitBuilder<T> {
    superclass: T;
    constructor(superclass: T);
    use(...traits: Trait[]): T;
}

declare const AuthenticatableTrait: Trait<any>;

declare class AuthServiceProvider extends ServiceProvider {
    register(): Promise<void>;
}

declare class FilesystemServiceProvider extends ServiceProvider {
    register(): Promise<void>;
    boot(): Promise<void>;
}

declare class HttpException extends Error implements HttpExceptionInterface {
    private statusCode;
    private headers;
    private previous;
    constructor(statusCode: number, message?: string, previous?: Error | null, headers?: ObjectOf<string>);
    getStatusCode(): number;
    getHeaders(): ObjectOf<string>;
    getPrevious(): Error | null;
}

declare class NotFoundHttpException extends HttpException {
    constructor(message?: string, previous?: Error | null, headers?: ObjectOf<string>);
}

declare class RedirectResponse extends Response {
    protected request: Request;
    protected isWithInput: boolean;
    protected inputExcept: string[];
    protected session: ObjectOf<any>;
    protected url: string;
    constructor(url: string);
    setRequest(req: Request): Request;
    withInput(options?: {
        except: string | string[];
    }): this;
    with(session: ObjectOf<any>): this;
}

declare abstract class ViewFactory implements ResponseRenderer {
    protected app: Application;
    protected path: string;
    protected data: Record<string, any>;
    protected ctx: Record<string, any>;
    constructor(app: Application);
    make(_path: string, data?: Record<string, any>): this;
    withContext(ctx: Record<string, any>): this;
    render(req: Request): Promise<Response>;
}

type renderUsing<E> = (e: E, req: Request) => Response | ViewFactory;
type reportUsing<E> = (e: E) => void;
interface renderCallback<E> {
    exception: Class<E>;
    renderUsing: renderUsing<E>;
}
interface reportCallback<E> {
    exception: Class<E>;
    reportUsing: reportUsing<E>;
}
declare class Handler implements ExceptionHandler {
    static symbol: symbol;
    protected container: Container;
    protected reportCallbacks: reportCallback<any>[];
    protected renderCallbacks: renderCallback<any>[];
    protected dontReport: Class<Error>[];
    protected internalDontReport: Class<Error>[];
    constructor(container: Container);
    render(req: Request, e: any): Promise<Response>;
    protected prepareException(e: any): any;
    report(e: any): void;
    reportable<E = Error>(exception: Class<E>, reportUsing: reportUsing<E>): void;
    renderable<E = Error>(exception: Class<E>, renderUsing: renderUsing<E>): void;
    protected register(): void;
    protected shouldntReport(e: Class<Error>): boolean;
}

declare class BadMethodCallException extends Error {
}

declare class RuntimeException extends Error {
}

interface IOptions {
    only: string | string[];
    except: string | string[];
}
declare class ControllerMiddlewareOptions {
    protected options: IOptions;
    constructor(options: IOptions);
    only(methods: string | string[]): this;
    except(methods: string | string[]): this;
}

declare abstract class Controller {
    protected middlewares: {
        middleware: string | Middleware;
        options: IOptions;
    }[];
    /**
     * Execute an action on the controller.
     */
    callAction(this: any, method: string, parameters: any[]): any;
    /**
     * Register middleware on the controller
     */
    middleware(middleware: MiddlewareStack): ControllerMiddlewareOptions;
    /**
     * Get the middleware assigned to the controller.
     */
    getMiddleware(): {
        middleware: string | Middleware;
        options: IOptions;
    }[];
}

type RouteAction<T> = RouteCallback | [Class<T>, Exclude<keyof T, keyof Controller>];
declare class Router extends _default$b {
    protected routes: Routes[];
    protected prefixStack: string[];
    protected middlewareStack: MiddlewareStack[];
    protected deep: number;
    protected calledAction: string;
    protected static macros: ObjectOf<Macro>;
    constructor();
    private addRoutes;
    get: <T>(uri: string, action: RouteAction<T>, ctx?: ObjectOf<any>) => this;
    post: <T>(uri: string, action: RouteAction<T>, ctx?: ObjectOf<any>) => this;
    delete: <T>(uri: string, action: RouteAction<T>, ctx?: ObjectOf<any>) => this;
    patch: <T>(uri: string, action: RouteAction<T>, ctx?: ObjectOf<any>) => this;
    put: <T>(uri: string, action: RouteAction<T>, ctx?: ObjectOf<any>) => this;
    all: <T>(uri: string, action: RouteAction<T>, ctx?: ObjectOf<any>) => this;
    getRoutes(): Routes[];
    prefix(prefix: string): this;
    middleware(middleware: MiddlewareStack): this;
    group(callback: string | CallBack): Promise<void>;
    private flattenMiddleware;
    /**
     * This method just to reset calledAction when Route facade called
     * See implementation in Support/Facade class
     */
    protected facadeCalled(): void;
    /**
     * determine if the given options should included in particular method
     */
    private methodIncludedByOptions;
}
interface Router {
    macro: (name: string, macro: Macro) => any;
    [key: string]: any;
}
declare const _default$9: typeof Router;

declare class RoutingServiceProvider extends ServiceProvider {
    register(): Promise<void>;
}

declare const useMagic: <T>(clazz: any, ...params: any[]) => T;

declare class Str {
    protected static studlyCache: ObjectOf<string>;
    static plural(value: string, count?: number): string;
    static ucfirst(value: string): string;
    static snake(value: string, glue?: string): string;
    static contains(haystack: string, needles: string | string[]): boolean;
    static is(pattern: string | string[], value: string): boolean;
    static random(length?: number): string;
    /**
     * Convert a value to studly caps case.
     */
    static studly(value: string): string;
}

declare class Arr {
    static wrap<T = string>(value: T[] | T | null): T[];
}

declare abstract class Facade {
    protected static facadeId: string | null;
    protected static app: Application;
    protected static resolvedInstance: Record<string | symbol, any>;
    static setApplicationFacade(app: Application): void;
    static getFacadeAccessor(): Class<any> | string | symbol;
    static __getStatic(name: string, abstract: string | symbol): (...args: any) => any;
    protected static resolveFacadeInstance(abstract: string | symbol): any;
}
declare class ExtendedFacade extends Facade {
}
declare const _default$8: typeof Facade;

declare class Env {
    static symbol: symbol;
    constructor();
    get(key: string, defaultValue?: string | boolean | null | number): any;
}

declare const _default$7: Env & typeof ExtendedFacade;

declare const _default$6: Encrypter & typeof ExtendedFacade;

declare class ResponseFactory {
    static symbol: symbol;
    constructor();
    make(content?: any, status?: number, headers?: ObjectOf<string>): Response;
}

declare const _default$5: ResponseFactory & typeof ExtendedFacade;

declare const _default$4: Router & typeof ExtendedFacade;

declare class FilesystemManager extends StorageManager {
    static symbol: symbol;
    protected app: Application;
    constructor(app: Application);
    isUsingS3(): boolean;
    registerS3Driver(): Promise<void>;
}

declare const _default$3: FilesystemManager & typeof ExtendedFacade;

declare function useFacade<T>(clazz: any): T & typeof ExtendedFacade;

declare const _default$2: Factory & typeof ExtendedFacade;

declare const _default$1: Repository & typeof ExtendedFacade;

declare const _default: AsyncLocalStorage<Map<string | symbol, any>> & typeof ExtendedFacade;

declare class ValidationException extends Error {
    status: number;
    protected validator: Validator;
    constructor(validator: Validator);
    errors(): any;
}

declare class ValidationServiceProvider extends ServiceProvider {
    register(): Promise<void>;
    boot(): Promise<void>;
}

declare const StartSession: Middleware;

declare class SessionServiceProvider extends ServiceProvider {
    register(): Promise<void>;
    boot(): Promise<void>;
}

declare class TokenMismatchException extends Error {
}

declare class CookieValuePrefix {
    /**
     *  Create a new cookie value prefix for the given cookie name.
     */
    static create(cookieName: string, key: Buffer): string;
    /**
     * Validate a cookie value contains a valid prefix. If it does, return the cookie value with the prefix removed. Otherwise, return null.
     */
    static validate(cookieName: string, cookieValue: string, key: Buffer): string | null;
    /**
     * Remove the cookie value prefix.
     */
    static remove(cookieValue: string): string;
}

declare class AddQueuedCookiesToResponse implements Middleware {
    handleAfter(res: Response, req: Request): Promise<Response>;
}

declare class EncryptCookie implements Middleware {
    protected encrypter: Encrypter;
    protected except: string[];
    constructor(encrypter?: Encrypter);
    handle(req: Request, next: NextFunction): Promise<Response>;
    handleAfter(res: Response): Promise<Response>;
    protected decrypt(req: Request): Request;
    protected encrypt(res: Response): Response;
    isDisabled(key: string): boolean;
    protected decryptCookie(cookie: string): string;
    /**
     * validate and remove the cookie value prefix from the value
     */
    protected validateValue(key: string, value: string): string | null;
    /**
     * Duplicate a cookie with a new value.
     */
    protected duplicate(cookie: Cookie, value: any): Cookie;
}

declare class DecryptException extends RuntimeException {
}

declare class EncryptionServiceProvider extends ServiceProvider {
    register(): Promise<void>;
    protected parseKey(config: AppConfig): Buffer;
    protected key(config: AppConfig): string;
}

declare class MissingAppKeyException extends Error {
    constructor(message?: string);
}

declare abstract class TestCase {
    protected app: Application;
    static make<T extends TestCase>(this: new () => T): T;
    /**
     * Setup the test environment
     */
    protected setUp(): Promise<void>;
    /**
     * Refresh the application instance
     */
    protected refreshApplication(): Promise<void>;
    abstract createApplication(): Promise<Application>;
    /**
     * Clean up the test environtment before next test.
     */
    protected tearDown(): void;
}

export { AddQueuedCookiesToResponse, _default as Als, AppConfig, Application, Arr, _default$c as AuthManager, AuthServiceProvider, Authenticatable, AuthenticatableTrait, BadMethodCallException, Bootstrapper, CallBack, CipherTypes, Class, Command, Concrete, _default$1 as Config, Configuration, Kernel$1 as ConsoleKernel, Controller, Cookie, CookieValuePrefix, Credentials, _default$6 as Crypt, DecryptException, EncryptCookie, Encrypter, EncryptionServiceProvider, _default$7 as Env, ExceptionHandler, ExtendedFacade, ExtendedRequest, _default$8 as Facade, FilesystemServiceProvider, FormRequest, Guard, Handler, HttpController, HttpException, HttpExceptionInterface, Request as HttpRequest, Response as HttpResponse, JsonPayload, Kernel, Method, Middleware, MiddlewareStack, MissingAppKeyException, NativeMiddleware, NextFunction, NotFoundHttpException, ObjectOf, OnServer, RedirectResponse, _default$a as Request, _default$5 as Response, ResponseRenderer, _default$4 as Route, RouteCallback, _default$9 as Router, Routes, RoutingServiceProvider, Rule, RuntimeException, Server, ServiceProvider, SessionConfig, SessionManager, SessionServiceProvider, StartSession, StatefulGuard, _default$3 as Storage, Str, TestCase, TokenMismatchException, Trait, Traitable, UserProvider, ValidationException, ValidationServiceProvider, _default$2 as Validator, VerifyCsrfToken, ViewFactory, useFacade, useMagic };
