import { Metadata, StatusObject } from '@grpc/grpc-js';
import { Message } from 'google-protobuf';
import { RequestLog } from './cache-request-logging';
export declare class MiddlewareMetadata {
    readonly _grpcMetadata: Metadata;
    constructor(metadata: Metadata);
    toJsonObject(): {
        [key: string]: import("@grpc/grpc-js").MetadataValue[];
    };
    toJsonString(): string;
}
export declare class MiddlewareStatus {
    readonly _grpcStatus: StatusObject;
    constructor(status: StatusObject);
    code(): import("@grpc/grpc-js").status;
}
export declare class MiddlewareMessage {
    readonly _grpcMessage: Message;
    constructor(message: Message);
    messageLength(): number;
    constructorName(): string;
    toLogFormat(): RequestLog;
}
export interface MiddlewareRequestHandler {
    onRequestMetadata(metadata: MiddlewareMetadata): Promise<MiddlewareMetadata>;
    onRequestBody(request: MiddlewareMessage): Promise<MiddlewareMessage>;
    onResponseMetadata(metadata: MiddlewareMetadata): Promise<MiddlewareMetadata>;
    onResponseBody(response: MiddlewareMessage | null): Promise<MiddlewareMessage | null>;
    onResponseStatus(status: MiddlewareStatus): Promise<MiddlewareStatus>;
}
export interface MiddlewareRequestHandlerContext {
    [key: symbol]: string;
}
/**
 * The Middleware interface allows the Configuration to provide a higher-order function that wraps all requests.
 * This allows future support for things like client-side metrics or other diagnostics helpers.
 *
 * An optional context can be provided that is essentially a <key, value> map {@link MiddlewareRequestHandlerContext}.
 * The context object is available to each individual invocation of the request handler for the middleware.
 */
export interface Middleware {
    onNewRequest(context?: MiddlewareRequestHandlerContext): MiddlewareRequestHandler;
    init?(): void;
    close?(): void;
    shouldLoadLate?: boolean;
}
