interface IDestructable {
    /**
     * Clean all timeouts, intervals and links to other objects in this method
     */
    destroy(): void;
}

interface IService extends IDestructable {
    /**
     * Implement direct communication with API or SDK
     */
    sendAllLogs<T>(logs: T[]): Promise<any>;
    /**
     * Implement the final processing of logs before sending it directly to the endpoint
     */
    preparePayload<T>(logs: T[]): Promise<any>;
    serializer<T>(log: T): any;
}

type Listener = (...args: any[]) => void;
declare class EventEmitter {
    private listeners;
    on(event: string, fn: Listener): this;
    once(event: string, fn: Listener): this;
    off(event: string, fn: Listener): this;
    removeListener(event: string, fn: Listener): this;
    emit(event: string, ...args: any[]): boolean;
    removeAllListeners(event?: string): this;
    private set;
}

interface IAddEventConfig {
    logCount: number;
}

interface IStrategy extends IDestructable {
    eventEmitter: EventEmitter;
    onAdd(info?: IAddEventConfig): void;
    onClear(): void;
    sendAll(): void;
}

declare enum TransformationEnum {
    RAPID_FIRE_GROUPING = 0
}

interface IGroupTransformation {
    groupIdentityFields: string[];
    groupFieldName: string;
    interval: number;
}

interface ITransformation {
    type: TransformationEnum;
    configuration: IGroupTransformation;
}

interface ILoggerConfig {
    service: IService;
    strategy: IStrategy;
    transformations?: ITransformation[];
}

interface IDefaultLogConfig {
    [key: string]: any;
}

/**
 * Uses different strategies to submit logs to log server via Service facade.
 */
declare class AdvancedLogger<T extends IDefaultLogConfig> {
    private configuration;
    private strategy;
    private service;
    private logStore;
    constructor(configuration: ILoggerConfig);
    log(log: T): void;
    /**
     * Forces strategy to initiate logs sending
     */
    sendAllLogs(): void;
    destroy(): void;
    private onStoreError;
    private onAdd;
    private onClear;
    private onStrategyError;
    private onSend;
}

type Method = "GET" | "DELETE" | "HEAD" | "OPTIONS" | "POST" | "PUT" | "PATCH" | "get" | "delete" | "head" | "options" | "post" | "put" | "patch";
interface IRequestConfig {
    url: string;
    method: Method;
    retryInterval?: number;
    retryAttempts?: number;
    logMetaIndexField?: string;
    [propName: string]: any;
}

interface IServiceConfig {
    serviceConfig: IRequestConfig;
    defaultLogConfig?: IDefaultLogConfig;
    serializer?<T extends IDefaultLogConfig>(log: T): string;
}

declare class BaseRemoteService implements IService, IDestructable {
    protected serviceConfig: IRequestConfig;
    protected defaultLogConfig: IDefaultLogConfig;
    constructor(config: IServiceConfig);
    serializer<T>(log: T): string;
    sendAllLogs<T>(logs: T[]): Promise<Response>;
    preparePayload<T>(logs: T[]): Promise<string>;
    destroy(): void;
    /**
     * Returns object for headers config
     * @example
     * {"Content-Type": "text/plain"}
     */
    protected getHeaders(): {
        [propName: string]: string;
    };
}

/**
 * Console reporting service for debugging purposes
 */
declare class ConsoleService implements IService {
    preparePayload<T>(logs: T[]): Promise<T[]>;
    sendAllLogs<T>(logs: T[]): Promise<void>;
    destroy(): void;
    serializer<T>(log: T): T;
}

declare class ElasticsearchService extends BaseRemoteService {
    preparePayload<T>(logs: T[]): Promise<string>;
    protected getHeaders(): {
        [propName: string]: string;
    };
    private getLogMetaConfig;
}

declare class LogglyService extends BaseRemoteService {
    protected getHeaders(): {
        [propName: string]: string;
    };
}

declare class SumologicService extends BaseRemoteService {
    protected getHeaders(): {
        [propName: string]: string;
    };
}

declare class InstantStrategy implements IStrategy {
    eventEmitter: EventEmitter;
    constructor();
    onAdd(info?: IAddEventConfig): void;
    onClear(): void;
    sendAll(): void;
    destroy(): void;
}

declare class OnBundleSizeStrategy implements IStrategy {
    eventEmitter: EventEmitter;
    /**
     * @type {number}
     */
    MAX_BUNDLE_SIZE: number;
    constructor(config: {
        maxBundle?: number;
    });
    onAdd(info: IAddEventConfig): void;
    onClear(): void;
    sendAll(): void;
    destroy(): void;
}

declare class OnIntervalStrategy implements IStrategy {
    eventEmitter: EventEmitter;
    SEND_INTERVAL: number;
    private readonly intervalSend;
    constructor(config: {
        interval?: number;
    });
    onAdd(info?: IAddEventConfig): void;
    onClear(): void;
    sendAll(): void;
    destroy(): void;
    private send;
}

declare class OnRequestStrategy implements IStrategy {
    eventEmitter: EventEmitter;
    constructor();
    onAdd(info?: IAddEventConfig): void;
    onClear(): void;
    sendAll(): void;
    destroy(): void;
}

declare class HybridStrategy implements IStrategy {
    eventEmitter: EventEmitter;
    MAX_BUNDLE_SIZE: number;
    SEND_INTERVAL: number;
    private readonly intervalSend;
    constructor(config?: {
        maxBundle?: number;
        interval?: number;
    });
    onAdd(info?: IAddEventConfig): void;
    onClear(): void;
    sendAll(): void;
    destroy(): void;
    private send;
}

declare const strategy: {
    InstantStrategy: typeof InstantStrategy;
    OnBundleSizeStrategy: typeof OnBundleSizeStrategy;
    OnRequestStrategy: typeof OnRequestStrategy;
    OnIntervalStrategy: typeof OnIntervalStrategy;
    HybridStrategy: typeof HybridStrategy;
};
declare const service: {
    BaseRemoteService: typeof BaseRemoteService;
    SumologicService: typeof SumologicService;
    LogglyService: typeof LogglyService;
    ConsoleService: typeof ConsoleService;
    ElasticsearchService: typeof ElasticsearchService;
};

export { AdvancedLogger, TransformationEnum, service, strategy };
