import { status as StatusCode, ServiceError } from "@grpc/grpc-js";
import type { WrongExpectedVersion } from "../../generated/shared_pb";
import type { CurrentStreamState, EndPoint, AppendStreamState } from "../types";
export declare enum ErrorType {
    TIMEOUT = "timeout",
    DEADLINE_EXCEEDED = "deadline-exceeded",
    UNAVAILABLE = "unavailable",
    CANCELLED = "cancelled",
    UNKNOWN = "unknown",
    NOT_LEADER = "not-leader",
    STREAM_NOT_FOUND = "stream-not-found",
    NO_STREAM = "no-stream",
    NOT_FOUND = "not-found",
    ACCESS_DENIED = "access-denied",
    INVALID_ARGUMENT = "invalid-argument",
    INVALID_TRANSACTION = "invalid-transaction",
    STREAM_DELETED = "stream-deleted",
    SCAVENGE_NOT_FOUND = "scavenge-not-found",
    WRONG_EXPECTED_VERSION = "wrong-expected-version",
    MAXIMUM_APPEND_SIZE_EXCEEDED = "maximum-append-size-exceeded",
    MISSING_REQUIRED_METADATA_PROPERTY = "missing-required-metadata-property",
    PERSISTENT_SUBSCRIPTION_FAILED = "persistent-subscription-failed",
    PERSISTENT_SUBSCRIPTION_DOES_NOT_EXIST = "persistent-subscription-does-not-exist",
    PERSISTENT_SUBSCRIPTION_EXISTS = "persistent-subscription-exists",
    PERSISTENT_SUBSCRIPTION_DROPPED = "persistent-subscription-dropped",
    MAXIMUM_SUBSCRIBERS_REACHED = "maximum-subscribers-reached",
    USER_NOT_FOUND = "user-not-found",
    USER_CONFLICT = "user-conflict",
    UNSUPPORTED = "unsupported"
}
declare abstract class CommandErrorBase extends Error {
    abstract readonly type: ErrorType;
    code?: StatusCode;
    message: string;
    _raw?: ServiceError;
    constructor(error?: ServiceError, message?: string);
}
export declare class TimeoutError extends CommandErrorBase {
    type: ErrorType.TIMEOUT;
}
export declare class DeadlineExceededError extends CommandErrorBase {
    type: ErrorType.DEADLINE_EXCEEDED;
}
export declare class UnavailableError extends CommandErrorBase {
    type: ErrorType.UNAVAILABLE;
}
export declare class CancelledError extends CommandErrorBase {
    type: ErrorType.CANCELLED;
}
export declare class NotFoundError extends CommandErrorBase {
    type: ErrorType.NOT_FOUND;
}
export declare class UnknownError extends CommandErrorBase {
    type: ErrorType.UNKNOWN;
}
export declare class NotLeaderError extends CommandErrorBase {
    type: ErrorType.NOT_LEADER;
    leader: EndPoint;
    constructor(error: ServiceError);
}
export declare class StreamNotFoundError extends CommandErrorBase {
    type: ErrorType.STREAM_NOT_FOUND;
    streamName: string;
    static nameToString: (error?: ServiceError, streamName?: string | Uint8Array) => string;
    constructor(error?: ServiceError, streamName?: string | Uint8Array);
}
export declare class NoStreamError extends CommandErrorBase {
    type: ErrorType.NO_STREAM;
}
export declare class AccessDeniedError extends CommandErrorBase {
    type: ErrorType.ACCESS_DENIED;
}
export declare class InvalidTransactionError extends CommandErrorBase {
    type: ErrorType.INVALID_TRANSACTION;
}
export declare class StreamDeletedError extends CommandErrorBase {
    type: ErrorType.STREAM_DELETED;
    streamName: string;
    static fromStreamName: (streamName: string) => StreamDeletedError;
    constructor(error: ServiceError);
    constructor(error: undefined, streamName: string);
}
export declare class ScavengeNotFoundError extends CommandErrorBase {
    type: ErrorType.SCAVENGE_NOT_FOUND;
    scavengeId: string;
    constructor(error: ServiceError);
}
interface WrongExpectedVersionDetails {
    streamName: string;
    expected: AppendStreamState;
    current: CurrentStreamState;
}
export declare class WrongExpectedVersionError extends CommandErrorBase {
    type: ErrorType.WRONG_EXPECTED_VERSION;
    streamName: string;
    expectedState: AppendStreamState;
    actualState: CurrentStreamState;
    static fromWrongExpectedVersion: (details: WrongExpectedVersion, streamName: string) => WrongExpectedVersionError;
    constructor(error: ServiceError);
    constructor(error: undefined, versions: WrongExpectedVersionDetails);
}
export declare class MaxAppendSizeExceededError extends CommandErrorBase {
    type: ErrorType.MAXIMUM_APPEND_SIZE_EXCEEDED;
    maxAppendSize: number;
    static fromMaxAppendSize: (maxAppendSize: number) => MaxAppendSizeExceededError;
    constructor(error: ServiceError);
    constructor(error: undefined, maxAppendSize: number);
}
export declare class RequiredMetadataPropertyMissingError extends CommandErrorBase {
    type: ErrorType.MISSING_REQUIRED_METADATA_PROPERTY;
    requiredMetadataProperties: string[];
    constructor(error: ServiceError);
}
export declare class PersistentSubscriptionFailedError extends CommandErrorBase {
    type: ErrorType.PERSISTENT_SUBSCRIPTION_FAILED;
    streamName: string;
    groupName: string;
    reason: string;
    constructor(error: ServiceError);
}
interface PersistentSubscriptionDoesNotExistMeta {
    streamName: string;
    groupName?: string;
}
export declare class PersistentSubscriptionDoesNotExistError extends CommandErrorBase {
    type: ErrorType.PERSISTENT_SUBSCRIPTION_DOES_NOT_EXIST;
    streamName: string;
    groupName: string;
    constructor(error: ServiceError);
    constructor(error: undefined, metadata: PersistentSubscriptionDoesNotExistMeta);
}
export declare class PersistentSubscriptionExistsError extends CommandErrorBase {
    type: ErrorType.PERSISTENT_SUBSCRIPTION_EXISTS;
    streamName: string;
    groupName: string;
    constructor(error: ServiceError);
}
export declare class PersistentSubscriptionMaximumSubscribersReachedError extends CommandErrorBase {
    type: ErrorType.MAXIMUM_SUBSCRIBERS_REACHED;
    streamName: string;
    groupName: string;
    constructor(error: ServiceError);
}
export declare class PersistentSubscriptionDroppedError extends CommandErrorBase {
    type: ErrorType.PERSISTENT_SUBSCRIPTION_DROPPED;
    streamName: string;
    groupName: string;
    constructor(error: ServiceError);
}
export declare class LoginNotFoundError extends CommandErrorBase {
    type: ErrorType.USER_NOT_FOUND;
    LoginName: string;
    constructor(error: ServiceError);
}
export declare class LoginConflictError extends CommandErrorBase {
    type: ErrorType.USER_CONFLICT;
    LoginName: string;
    constructor(error: ServiceError);
}
export declare class UnsupportedError extends CommandErrorBase {
    type: ErrorType.UNSUPPORTED;
    feature: string;
    minimumVersion: string;
    constructor(feature: string, minimumVersion: string);
}
export declare class InvalidArgumentError extends CommandErrorBase {
    type: ErrorType.INVALID_ARGUMENT;
    errorMessage: string;
    constructor(error: string);
}
export type CommandError = NotLeaderError | StreamNotFoundError | NoStreamError | AccessDeniedError | InvalidArgumentError | InvalidTransactionError | StreamDeletedError | ScavengeNotFoundError | WrongExpectedVersionError | MaxAppendSizeExceededError | RequiredMetadataPropertyMissingError | PersistentSubscriptionFailedError | PersistentSubscriptionDoesNotExistError | PersistentSubscriptionExistsError | PersistentSubscriptionDroppedError | PersistentSubscriptionMaximumSubscribersReachedError | LoginNotFoundError | LoginConflictError | TimeoutError | DeadlineExceededError | UnavailableError | CancelledError | UnknownError | UnsupportedError;
export declare const convertToCommandError: (error: Error) => CommandError | Error;
export declare const isCommandError: (error: Error) => error is CommandError;
export {};
