TypeScript 61.9%
HTML 37.2%
SQL 0.7%
1import { ShopifyStoreConnector, type ConnectorMeta, type RawRecordLike } from '@rareindex/connectors';2import type { NormalizedRecord } from '@rareindex/shared';34/**5 * Mattel Creations (creations.mattel.com) — Mattel's official collector shop (Hot Wheels Collectors / Red Line6 * Club, Matchbox Collectors, Barbie Signature, Masters of the Universe, WWE) on Shopify. Read through the shared7 * Shopify adapter; this subclass copies the store's "Brand: X" / "Category: Y" tags into brand/metadata and flags8 * membership-exclusive (RLC) items. Prices are Mattel's own MSRP → every listing also carries originalMsrp.9 */10export class MattelCreationsConnector extends ShopifyStoreConnector {11 override async normalize(raw: RawRecordLike): Promise<NormalizedRecord[]> {12 const out = await super.normalize(raw);13 for (const r of out) {14 if (r.kind !== 'listing') continue;15 const tags = Array.isArray(r.attributes.metadata.tags) ? (r.attributes.metadata.tags as string[]) : [];16 const tag = (prefix: string) => tags.find((t) => new RegExp(`^${prefix}\\s*:`, 'i').test(t))?.split(':').slice(1).join(':').trim() ?? null;17 const brand = tag('Brand');18 if (brand) r.attributes.brand = brand;19 r.attributes.metadata.mattel_category = tag('Category');20 r.attributes.metadata.age_grade = tag('Filter-AgeGrade');21 r.attributes.metadata.members_only = tags.some((t) => /^(RLC|BSM|brand_RLC|brand_BSM|MC_Exclusive)$/i.test(t));22 const yearTag = tags.find((t) => /^(19|20)\d{2}$/.test(t));23 if (yearTag && r.attributes.year === null) r.attributes.year = Number(yearTag);24 if (r.price !== null && r.attributes.originalMsrp === null) {25 r.attributes.originalMsrp = r.price;26 r.attributes.originalMsrpCurrency = 'USD';27 }28 r.condition = { condition: null, conditionRaw: 'new', completeness: 'sealed' };29 }30 return out;31 }32}3334export default (meta: ConnectorMeta) => new MattelCreationsConnector(meta);35