TypeScript 61.9%
HTML 37.2%
SQL 0.7%
1import { slugFromTitle, watchBrand } from '../_auction-lib/categories.js';2import { popCultureCategory, sportsCategory } from '../_memorabilia-lib/index.js';34/** Firearms / ammunition are never emitted (compliance). */5export function isFirearm(text: string): boolean {6 return /\b(firearms?|rifles?|pistols?|shotguns?|revolvers?|handguns?|carbines?|ammunition|ammo|cartridges|\d+\s?(?:ga|gauge)\b|\.\d{2,3}\s?cal(?:iber)?|9\s?mm|air ?gun|bb gun)\b/i.test(text);7}89function tcg(title: string): string {10 if (/pok[eé]mon|charizard|pikachu/i.test(title)) return 'pokemon';11 if (/magic:? the gathering|\bmtg\b/i.test(title)) return 'magic_the_gathering';12 if (/yu-?gi-?oh/i.test(title)) return 'yugioh';13 if (/\bone piece\b/i.test(title)) return 'one_piece_card_game';14 if (/lorcana/i.test(title)) return 'disney_lorcana';15 if (/\b(topps|panini|bowman|upper deck|fleer|donruss|rookie|psa|sgc|bgs)\b/i.test(title)) return sportsCategory(title);16 return 'other_tcg';17}1819/**20 * HiBid CategoryTree.fullCategory ("Coins & Currency - Currency - Canada") + lot title → taxonomy slug,21 * or null when the lot is outside the collectibles universe (real estate, vehicles, equipment, household…).22 * Only slugs present in data/taxonomy/categories.json are returned.23 */24/** New merchandise / liquidation lots that surface under collectible categories (wholesale, bulk packs, notices). */25const LIQUIDATION_TITLE = /\b(\d+\s?pcs?|\d+\s?pack|wholesale|liquidation|pallet|case of \d+|information only|do not bid|shelf pull|overstock|brand new in box|nib\b.*\bnew)\b/i;26/** Sub-categories of "Antiques & Collectibles - Collectibles" that are household goods, not collectibles. */27const HOUSEHOLD_SUB = /bakeware|candle|ornaments?|kitchen|home d[eé]cor|linens?|bedding|lighting|office|garden|tools?|electronics|holiday|seasonal|party|crafts?|\bpet\b|baby|health|beauty|cleaning|storage|furniture|appliances?|cookware|tableware|dinnerware|drinkware|mugs?|frames?|wall art|rugs?|pillows?|blankets?|misc/;2829export function hibidCategory(fullCategory: string | null | undefined, title: string): string | null {30 const c = (fullCategory ?? '').toLowerCase();31 if (!c) return null;32 if (isFirearm(c) || LIQUIDATION_TITLE.test(title)) return null;33 if (/^coins & currency/.test(c)) {34 const sub = c.replace(/^coins & currency/, '');35 if (/currency|paper money|bank ?notes?/.test(sub) || /\b(bill|note|banknote|dollar bill)\b/i.test(title)) return 'banknotes';36 if (/stamps?/.test(c)) return 'stamps';37 return 'coins';38 }39 if (/sports? (memorabilia|cards?)|sports? collectibles|^sports\b/.test(c)) return sportsCategory(title);40 if (/trading cards?|collectible card|card games?|tcg|non-?sport cards?/.test(c)) return /non-?sport/.test(c) ? 'non_sport_cards' : tcg(title);41 if (/comics?|comic books?/.test(c)) return popCultureCategory(title);42 if (/video ?games?|gaming consoles?/.test(c)) return 'video_games';43 if (/toys? & hobbies|\btoys?\b|action figures?|dolls?|die-?cast|model (trains?|kits?|cars?)/.test(c)) {44 if (/model trains?|railroad/.test(c)) return 'model_trains';45 if (/die-?cast|model cars?/.test(c)) return 'model_cars';46 if (/dolls?/.test(c)) return 'dolls';47 if (/action figures?/.test(c)) return 'action_figures';48 return slugFromTitle(title, 'toys') ?? popCultureCategory(title);49 }50 if (/watches?/.test(c)) return watchBrand(title).slug;51 if (/jewelry|jewellery|gemstones?|diamonds?/.test(c)) return /\b(watch|wristwatch)\b/i.test(title) ? watchBrand(title).slug : /loose|unmounted|gia/i.test(title) ? 'gemstones' : 'jewelry';52 if (/advertising|signs?|petroliana|breweriana|soda/.test(c)) return 'advertising';53 if (/stamps?|philatel/.test(c)) return 'stamps';54 if (/militaria|military collectibles|medals?/.test(c)) return /\bmedal/i.test(title) ? 'medals' : 'militaria';55 if (/musical instruments?|music - instruments|guitars?/.test(c)) return 'musical_instruments';56 if (/records?|vinyl|\blps?\b/.test(c)) return 'music';57 if (/music memorabilia|entertainment memorabilia|movie memorabilia|movie posters?/.test(c)) return popCultureCategory(title);58 if (/cameras?|photography equipment/.test(c)) return 'cameras';59 if (/clocks?/.test(c)) return 'clocks';60 if (/books?|manuscripts?|ephemera/.test(c)) return /\bmap\b|atlas/i.test(title) ? 'maps' : /postcard/i.test(title) ? 'postcards' : 'books';61 if (/maps?|atlases/.test(c)) return 'maps';62 if (/postcards?/.test(c)) return 'postcards';63 if (/glass(ware)?|crystal/.test(c)) return 'glass_crystal';64 if (/porcelain|china|pottery|ceramics?|stoneware/.test(c)) return 'porcelain';65 if (/silver|sterling/.test(c)) return 'silver';66 if (/fine art|paintings?|prints?|sculptures?|^art\b|art - |artwork/.test(c)) return slugFromTitle(title, 'art') ?? 'art';67 if (/fossils?|minerals?|meteorites?|natural history|rocks?/.test(c)) return /meteorite/i.test(title) ? 'meteorites' : /\b(fossil|ammonite|trilobite|tooth|skull|dinosaur)\b/i.test(title) ? 'fossils' : 'minerals';68 if (/pens?|writing instruments?/.test(c)) return 'pens';69 if (/lighters?/.test(c)) return 'lighters';70 if (/perfume|fragrance/.test(c)) return 'perfume';71 if (/pinball|arcade|slot machines?|coin-?op/.test(c)) return /slot machine/i.test(title) ? 'casino_memorabilia' : 'arcade_pinball';72 if (/casino|gaming chips?/.test(c)) return 'casino_memorabilia';73 if (/political/.test(c)) return 'political_memorabilia';74 if (/disney/.test(c)) return 'disney_collectibles';75 if (/star wars/.test(c)) return 'star_wars';76 if (/board games?|puzzles?/.test(c)) return 'board_games';77 if (/license plates?/.test(c)) return 'license_plates';78 if (/pins?|badges?|buttons?/.test(c)) return 'pins';79 if (/vintage computers?|apple/.test(c)) return /\bapple\b|macintosh/i.test(title) ? 'apple_collectibles' : 'vintage_computers';80 if (/typewriters?/.test(c)) return 'typewriters';81 if (/scientific instruments?/.test(c)) return 'scientific_instruments';82 if (/antiques?|collectibles|decorative arts?|primitives|folk art|americana|asian antiques|oriental/.test(c)) {83 const sub = c.replace(/^antiques & collectibles(?: - collectibles)?/, '');84 const vintageSignal = /\b(antique|vintage|victorian|edwardian|georgian|art deco|art nouveau|mid-?century|19th|18th|17th|c\.?\s?1[89]\d\d|1[89]\d\ds|primitive|folk art|cast iron)\b/i.test(title) || /antique|primitive|folk art|americana/.test(sub);85 if (HOUSEHOLD_SUB.test(sub) && !vintageSignal) return null;86 if (/\b(lighter|zippo)\b/i.test(title)) return 'lighters';87 if (/\b(fountain pen|montblanc|parker 51)\b/i.test(title)) return 'pens';88 if (/\b(mechanical bank|still bank|tin toy|wind-?up|pedal car|cap gun)\b/i.test(title)) return 'vintage_toys';89 const bySignal = slugFromTitle(title, 'decorative');90 if (bySignal && bySignal !== 'antiques') return bySignal;91 return vintageSignal || (bySignal === 'antiques' && !HOUSEHOLD_SUB.test(sub)) ? 'antiques' : null;92 }93 if (/automobilia|automotive memorabilia|petroliana|gas & oil/.test(c)) return 'automotive_memorabilia';94 if (/wine|whisk(e)?y|spirits/.test(c)) return slugFromTitle(title, 'wine');95 if (/sneakers?|streetwear|handbags?|luxury|designer/.test(c)) return slugFromTitle(title, 'fashion');96 return null;97}98