TypeScript 61.9%
HTML 37.2%
SQL 0.7%
1import type { ConnectorMeta, CrawlContext } from '@rareindex/connectors';2import { parseBidsquareEvents, popCultureCategory } from '../_memorabilia-lib/index.js';3import { BidsquareHouseConnector } from '../scp-auctions/index.js';45/**6 * Hake's Auctions (Bidsquare platform, same HTML as SCP). Hake's hides its past-auction list7 * (/auctions/past returns "No Auction Available"), so this connector works in two phases:8 * upcoming catalogs are crawled for auction lots and remembered in the cursor; once an event's9 * catalog reports status 'past' the same pages yield realized "Sold for" prices.10 */11export class HakesConnector extends BidsquareHouseConnector {12 protected override async listEvents(ctx: CrawlContext): Promise<Array<{ id: string; name: string; url: string; status: string }>> {13 const known = (Array.isArray(ctx.options.cursor?.knownEvents) ? (ctx.options.cursor!.knownEvents as Array<{ id: string; name: string; url: string }>) : []).filter((e) => e && e.id && e.url);14 const up = await this.fetchHtml(ctx, `${this.opts.base}/auctions`);15 const upcoming = up.html ? parseBidsquareEvents(up.html) : [];16 const upcomingIds = new Set(upcoming.map((e) => e.id));17 // Events seen before that are no longer upcoming are revisited as past (their catalog reports the status).18 const past = known.filter((e) => !upcomingIds.has(e.id)).map((e) => ({ ...e, status: 'past' }));19 const merged = [...known.filter((e) => upcomingIds.has(e.id)), ...upcoming.filter((e) => !known.some((k) => k.id === e.id)).map((e) => ({ id: e.id, name: e.name, url: e.url }))];20 await ctx.setCursor({ ...(ctx.options.cursor ?? {}), knownEvents: merged.slice(-60) });21 return [...past, ...upcoming.map((e) => ({ id: e.id, name: e.name, url: e.url, status: 'upcoming' }))];22 }23}2425export default (meta: ConnectorMeta) =>26 new HakesConnector(meta, {27 base: 'https://www.hakes.com',28 house: "Hake's Auctions",29 category: popCultureCategory,30 buyerPremiumIncluded: null,31 idKey: 'hakes_item_id',32 location: 'US',33 });34