feat: EMEX VIN decode → catalog DB matching via pathData/SSD
Some checks failed
CI / Lint, Typecheck, Test & Build (push) Has been cancelled

Parse path_data from Vehicle.aspx URLs (Base64-decoded vehicle name),
persist vehicleLabel/vid/pathData in rawData, and add 4-step matching
cascade for category resolution:
1. pathData name → matchByName (DB-only, ~50ms)
2. emexVehicleName → matchByName (DB-only, ~50ms)
3. ssd + catalogCode → matchBySsd (wizard HTTP + DB, ~2-3s)
4. Fallback → on-demand EMEX scrape (unchanged, ~6-13s)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-06 14:46:00 +00:00
parent adfba6c543
commit 53a6296a91
5 changed files with 207 additions and 30 deletions

View File

@@ -432,6 +432,10 @@ function buildRawResponse(
message: response.message,
parsedOptions: response.parsedOptions,
rawResponse: response.rawResponse,
emexVehicleName: response.vehicle?.model || null,
emexLabel: response.vehicleLabel || null,
emexVid: response.vid || null,
emexPathData: response.pathData || null,
// Store category tree for hierarchical insertion (QuickGroups.aspx)
emexCategoryTree: response.categoryTree || [],
// Store flat category URLs for on-demand parts fetching (fallback)

View File

@@ -42,6 +42,7 @@ interface EmexHttpVehicle {
vid: string | null;
ssd: string | null;
quickGroupsUrl: string | null;
pathData: string | null;
}
interface EmexHttpCategory {
@@ -278,6 +279,15 @@ export class EmexService {
const c = params.get('c');
const vid = params.get('vid');
const ssd = params.get('ssd');
const rawPathData = params.get('path_data');
let pathData: string | null = null;
if (rawPathData) {
try {
pathData = Buffer.from(rawPathData, 'base64').toString('utf-8');
} catch {
pathData = rawPathData;
}
}
const modelMatch = label.match(/^([^\[]+)/);
const yearMatch = label.match(/\((\d{4})/);
vehicles.push({
@@ -290,6 +300,7 @@ export class EmexService {
quickGroupsUrl: c && vid != null && ssd
? `${EMEX_BASE_URL}/QuickGroups.aspx?c=${c}&vid=${vid}&ssd=${encodeURIComponent(ssd)}`
: null,
pathData,
});
}
return vehicles;
@@ -379,6 +390,9 @@ export class EmexService {
vin,
catalogCode: v.catalogCode || '',
ssd: v.ssd || undefined,
vehicleLabel: v.label,
vid: v.vid || undefined,
pathData: v.pathData || undefined,
vehicle: {
brand,
model: v.model,
@@ -462,6 +476,9 @@ export class EmexService {
vin,
catalogCode: v.catalogCode || '',
ssd: v.ssd || undefined,
vehicleLabel: v.label,
vid: v.vid || undefined,
pathData: v.pathData || undefined,
vehicle: {
brand,
model: v.model,
@@ -525,6 +542,9 @@ export class EmexService {
vin,
catalogCode: v.catalogCode || '',
ssd: v.ssd || undefined,
vehicleLabel: v.label,
vid: v.vid || undefined,
pathData: v.pathData || undefined,
vehicle: {
brand,
model: v.model,

View File

@@ -131,6 +131,9 @@ export interface EmexScraperResponse {
catalogCode: string;
ssd?: string;
vehicle: EmexVehicleData;
vehicleLabel?: string;
vid?: string;
pathData?: string;
message?: string;
error?: string;
rawResponse?: Record<string, unknown>;