import { cached, coingeckoGet, TTL } from './client.js';
export const coingeckoTrendingFetcher = {
    providerName: 'coingecko',
    transformQuery(_input) {
        return {};
    },
    async fetchData(_query) {
        return cached('trending', TTL.trending, async () => coingeckoGet('/search/trending'));
    },
    transformData(raw, _query) {
        const payload = raw;
        if (!payload || !Array.isArray(payload.coins)) {
            return { kind: 'upstream-error', message: 'CoinGecko /search/trending returned unexpected shape' };
        }
        return payload.coins.map(c => ({
            providerId: c.item.id,
            name: c.item.name,
            symbol: c.item.symbol,
            marketCapRank: c.item.market_cap_rank,
        }));
    },
};
