TypeScript 61.9%
HTML 37.2%
SQL 0.7%
1import { createRouter, createCrawlContext, getConnectorMeta } from '@rareindex/connectors';2import { saveFixture } from '@rareindex/connectors/testing';3import createConnector from './index.js';45const save = process.argv.includes('--save');6const meta = getConnectorMeta('brickset');7const connector = createConnector(meta);8const ctx = createCrawlContext({ router: createRouter({}), meta, options: { mode: 'probe', limit: 3, seeds: ['theme-Icons'] } });9for await (const raw of connector.crawl(ctx)) {10 const out = await connector.normalize({ ...raw, externalId: raw.externalId ?? null, fetchedAt: raw.fetchedAt ?? new Date() });11 console.log(`raw ${raw.externalId} → ${out.length}`);12 for (const r of out) console.log(' ', JSON.stringify(r).slice(0, 320));13}14const lk = await connector.lookup('https://brickset.com/sets/10179-1/Ultimate-Collectors-Millennium-Falcon', ctx);15if (lk[0]) {16 const out = await connector.normalize({ ...lk[0], externalId: lk[0].externalId ?? null, fetchedAt: lk[0].fetchedAt ?? new Date() });17 console.log('lookup 10179 →', out.length, JSON.stringify(out[0]).slice(0, 400));18 if (save) saveFixture('brickset', '10179-1-millennium-falcon', { raw: { url: lk[0].url, externalId: lk[0].externalId ?? null, kind: lk[0].kind, engine: lk[0].engine, fetchedAt: lk[0].fetchedAt ?? new Date(), payload: lk[0].payload }, expect: { count: 3, kinds: ['catalog_item', 'price_observation'], first: { 'attributes.number': '10179', 'attributes.year': 2007 } }, note: 'Captured live from brickset.com' });19}20const lk2 = await connector.lookup('https://brickset.com/sets/75192-1', ctx);21if (lk2[0] && save) saveFixture('brickset', '75192-1-millennium-falcon', { raw: { url: lk2[0].url, externalId: lk2[0].externalId ?? null, kind: lk2[0].kind, engine: lk2[0].engine, fetchedAt: lk2[0].fetchedAt ?? new Date(), payload: lk2[0].payload }, expect: { minCount: 1, kinds: ['catalog_item', 'price_observation'] }, note: 'Captured live from brickset.com' });22console.log('engineStats', ctx.engineStats, 'anomalies', ctx.anomalies);23