import{FileHashStatus as r}from"../../../persistence/file-hashes/types.js";import{sha1 as i}from"../../../utils/crypto/sha1.js";class o{#t;constructor(t){this.#t=t}async markAllAsOutdated(t){return await this.#t.updateFileHashes(r.OUTDATED,{field:"file_type",operator:"equal",value:t})}async getByPath(t){return await this.#t.getByPath(t)}async upsert(t,s,e,a){return await this.#t.upsertFileHash({fileType:t,filePath:s,hash:e,status:a})}async getAllOutdated(t){return await this.#t.getAllOutdated(t)}async getStatusSnapshot(t){const s=await this.#t.getAllByFileType(t),e=new Map;for(const a of s)e.set(a.filePath,a.status);return e}async computeFileHash(t){try{return i(JSON.stringify(t))}catch{throw new Error(`Error computing hash for file content: ${JSON.stringify(t)}`)}}async deleteFileHashes(t){return await this.#t.deleteFileHashes(t)}}export{o as HashManager};
