"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "FileReader", {
    enumerable: true,
    get: function() {
        return FileReader;
    }
});
const _env = require("@llamaindex/env");
class FileReader {
    async loadData(filePath) {
        const fileContent = await _env.fs.readFile(filePath);
        const docs = await this.loadDataAsContent(fileContent);
        docs.forEach(FileReader.addMetaData(filePath));
        return docs;
    }
    static addMetaData(filePath) {
        return (doc, index)=>{
            // generate id as loadDataAsContent is only responsible for the content
            doc.id_ = `${filePath}_${index + 1}`;
            doc.metadata["file_path"] = _env.path.resolve(filePath);
            doc.metadata["file_name"] = _env.path.basename(filePath);
        };
    }
}
