TypeScript 61.9%
HTML 37.2%
SQL 0.7%
1import { readFileSync } from 'node:fs';2import { ConnectorMetaSchema, createCrawlContext, createRouter } from '@rareindex/connectors';3import { saveFixture } from '@rareindex/connectors/testing';4import { childLogger } from '@rareindex/shared';5import create from '../noble-knight/index.js';6const meta = ConnectorMetaSchema.parse(JSON.parse(readFileSync('connectors/api/noble-knight/meta.json', 'utf8')));7const c = create(meta);8const ctx = createCrawlContext({ router: createRouter({}), meta, options: { mode: 'probe' }, log: childLogger({}) });9for (const [name, url] of [['board-game', 'https://www.nobleknight.com/P/2147993326/007---Spectre-Board-Game'], ['gunpla', 'https://www.nobleknight.com/P/2148351787/002-Ex-S-GUNDAM']] as const) {10 const raws = await c.lookup!(url, ctx);11 const raw = raws[0]!;12 const fetchedAt = raw.fetchedAt ?? new Date();13 const records = await c.normalize({ ...raw, externalId: raw.externalId ?? null, fetchedAt });14 saveFixture(meta.id, name, { raw: { url: raw.url, externalId: raw.externalId ?? null, kind: raw.kind, engine: raw.engine, fetchedAt, payload: raw.payload }, expect: { count: records.length, kinds: [...new Set(records.map((r) => r.kind))] }, note: `Captured live via lookup(${url}).` });15 console.log(name, records.length, records.map((r) => r.kind));16}17