// Proxy de servicio de nombres (caché + normalización) export class NamesServiceProxy { constructor(fetchNamesForDocs){ this._fetch = typeof fetchNamesForDocs === 'function' ? fetchNamesForDocs : async () => ({}); this._cache = new Map(); } async get(docs){ const ask = []; for (const d of docs) if (!this._cache.has(d)) ask.push(d); if (ask.length){ const map = await this._fetch(ask); for (const [k,v] of Object.entries(map || {})) this._cache.set(String(k), v || {}); } const out = {}; for (const d of docs) out[d] = this._cache.get(d) || {}; return out; } }