/**
 * Copyright 2020 Baidu Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/// <reference types="node" />
declare type Query = Record<string, string | number> | null;
interface WriteOptions {
    type?: 'json' | 'buffer';
}
interface MetaData {
    uri: string;
    query?: Record<string, string | string[]>;
    filename: string;
    headers: Record<string, string>;
}
interface ResponseData<T = any> {
    status: number;
    msg?: string;
    data: T;
}
export default class IO {
    static readonly metaFileName = "meta.json";
    static readonly dataPath = "data";
    static readonly hashFunction = "md4";
    protected readonly url: string;
    protected readonly dataDir: string;
    protected metadata: MetaData[];
    constructor(url: string, dataDir: string);
    static isSameUri(url1: Pick<MetaData, 'uri' | 'query'>, url2: Pick<MetaData, 'uri' | 'query'>): boolean;
    private generateFilename;
    private addMeta;
    protected write(filePath: string, content: Record<string, any> | Buffer, contentType: string, options?: WriteOptions | WriteOptions['type']): Promise<string>;
    fetch(uri: string, query?: Query): Promise<import("node-fetch").Response>;
    protected fetchAndWrite<T>(uri: string, query?: Query, options?: WriteOptions | WriteOptions['type']): Promise<ArrayBuffer | ResponseData<T>>;
    save<T>(uri: string, query?: Query): Promise<T>;
    saveBinary(uri: string, query?: Query): Promise<Buffer>;
    getData<T>(uri: string, query?: Query): Promise<T>;
    generateMeta(): Promise<void>;
    sleep(time: number): Promise<unknown>;
}
export {};
