Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> git-subtree-dir: gti-maquina-comercial git-subtree-mainline:93ca82979egit-subtree-split:b77484946f
90 lines
2.7 KiB
JavaScript
90 lines
2.7 KiB
JavaScript
import * as cnpjBase from './cnpj-base.mjs';
|
|
import * as overpass from './overpass.mjs';
|
|
import * as nominatim from './nominatim.mjs';
|
|
import * as wikidata from './wikidata.mjs';
|
|
import * as googlePlaces from './google-places.mjs';
|
|
import * as mock from './mock.mjs';
|
|
|
|
// Registro central de fontes de captura. `describe()` alimenta a tela de
|
|
// captura (o front nunca conhece detalhes das fontes, so este catalogo).
|
|
export const SOURCES = [
|
|
{
|
|
id: 'cnpj-base',
|
|
label: 'Base CNPJ (Receita Federal)',
|
|
descricao: 'Base oficial local: todas as empresas ativas da UF com telefone. Fonte principal.',
|
|
gratuita: true,
|
|
recomendada: true,
|
|
collect: cnpjBase.collect
|
|
},
|
|
{
|
|
id: 'brasilapi',
|
|
label: 'Base CNPJ + BrasilAPI',
|
|
descricao: 'Mesma base CNPJ, enriquecida online pela BrasilAPI (mais lenta).',
|
|
gratuita: true,
|
|
recomendada: false,
|
|
collect: (params, ctx) => cnpjBase.collect({ ...params, enrichBrasilApi: true }, ctx)
|
|
},
|
|
{
|
|
id: 'overpass',
|
|
label: 'OpenStreetMap (Overpass)',
|
|
descricao: 'Estabelecimentos mapeados no OpenStreetMap, com telefone/site quando cadastrados.',
|
|
gratuita: true,
|
|
recomendada: true,
|
|
collect: overpass.collect
|
|
},
|
|
{
|
|
id: 'nominatim',
|
|
label: 'OpenStreetMap (Nominatim)',
|
|
descricao: 'Busca textual no OpenStreetMap por termo de nicho.',
|
|
gratuita: true,
|
|
recomendada: false,
|
|
collect: nominatim.collect
|
|
},
|
|
{
|
|
id: 'wikidata',
|
|
label: 'Wikidata',
|
|
descricao: 'Empresas registradas no Wikidata (volume baixo, util para sites).',
|
|
gratuita: true,
|
|
recomendada: false,
|
|
collect: wikidata.collect
|
|
},
|
|
{
|
|
id: 'google-places',
|
|
label: 'Google Places',
|
|
descricao: 'Google Maps (paga, exige GOOGLE_MAPS_API_KEY no .env).',
|
|
gratuita: false,
|
|
recomendada: false,
|
|
needsKey: 'GOOGLE_MAPS_API_KEY',
|
|
collect: googlePlaces.collect
|
|
},
|
|
{
|
|
id: 'mock',
|
|
label: 'Teste (mock)',
|
|
descricao: '3 leads ficticios para testar o fluxo sem tocar em APIs.',
|
|
gratuita: true,
|
|
recomendada: false,
|
|
oculta: true,
|
|
collect: mock.collect
|
|
}
|
|
];
|
|
|
|
export function getSource(id) {
|
|
return SOURCES.find((source) => source.id === id) || null;
|
|
}
|
|
|
|
export function describeSources() {
|
|
return SOURCES.filter((s) => !s.oculta).map((source) => {
|
|
const keyMissing = source.needsKey
|
|
&& (!process.env[source.needsKey] || process.env[source.needsKey].startsWith('preencher'));
|
|
return {
|
|
id: source.id,
|
|
label: source.label,
|
|
descricao: source.descricao,
|
|
gratuita: source.gratuita,
|
|
recomendada: source.recomendada,
|
|
disponivel: !keyMissing,
|
|
motivo: keyMissing ? `configure ${source.needsKey} no arquivo .env` : ''
|
|
};
|
|
});
|
|
}
|