feat(pl24): enrich P5 decode for non-VAG OEMs (SEV-2)
Some checks failed
QA Gate (P0/P1) / Test affected app (pull_request) Has been cancelled
Some checks failed
QA Gate (P0/P1) / Test affected app (pull_request) Has been cancelled
parseVehicleResponse only read VAG/BMW vinfoBasic labels, so Jaguar/Land Rover/Toyota/MAN/Suzuki dropped engine+transmission and Mitsubishi's model showed an internal chassis code. - engine/transmission: read brand labels (JLR Motor Tipi/Vites Kutusu, Toyota ENGINE 1/ATM,MTM + parens engine code, MAN Yedek motor/Şanzıman, Suzuki Motor No./Şanzıman numarası). - Mitsubishi model: prefer Araç/description (L200), not the internal Model code (KB4T 2500DIESEL...). - value normalize: unescape literal \- + collapse whitespace (was prNr-only) → fixes 'XJ 2010 \- 2019', '2005\-07', 'COROLLA (TUP)'. VAG/BMW/Mercedes/Fiat unchanged. 40/40 pl24 specs. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1014,7 +1014,17 @@ export class PL24Service {
|
||||
const value = (v.key !== undefined ? v.description : v.value) || "";
|
||||
if (!label) continue;
|
||||
const key = label.toLowerCase().replace(/[\s\/]+/g, "_");
|
||||
if (!(key in vehicleData)) vehicleData[key] = value.replace(/\r?\n/g, " ").trim();
|
||||
if (!(key in vehicleData)) {
|
||||
// Normalize like prNr col3: newlines→space, unescape the literal "\-" some P5
|
||||
// backends emit (JLR "XJ 2010 \- 2019", Toyota/Suzuki dates "2023\-11\-29"/"2005\-07"),
|
||||
// and collapse runs of whitespace (Toyota "COROLLA (TUP)"). Otherwise the raw
|
||||
// escape/padding leaks straight to the UI.
|
||||
vehicleData[key] = value
|
||||
.replace(/\r?\n/g, " ")
|
||||
.replace(/\\-/g, "-")
|
||||
.replace(/\s+/g, " ")
|
||||
.trim();
|
||||
}
|
||||
}
|
||||
|
||||
// Helper: look up by multiple possible keys (EN + TR)
|
||||
@@ -1046,11 +1056,24 @@ export class PL24Service {
|
||||
.replace("?", "?scope=F&subAggregate=n-r&");
|
||||
}
|
||||
|
||||
// Engine code: vinfoBasic "Motor kodu" / "Engine code"
|
||||
// Engine code: VAG/BMW "Motor kodu" / "Engine code".
|
||||
const engineCode = lookup("motor_kodu", "engine_code");
|
||||
// Non-VAG P5 OEMs label the engine differently and give a description (sometimes with a
|
||||
// code in parens): JLR "Motor Tipi", Toyota "ENGINE 1", MAN "Yedek motor", Suzuki "Motor No.".
|
||||
const engineLabel = lookup("motor_tipi", "engine_1", "yedek_motor", "motor_no.");
|
||||
|
||||
// Transmission code: vinfoBasic "Şanzıman kodu" / "Transmission code"
|
||||
const transmissionCode = lookup("şanzıman_kodu", "sanzıman_kodu", "transmission_code");
|
||||
// Transmission: VAG "Şanzıman kodu"; other OEMs use their own labels — JLR "Vites Kutusu",
|
||||
// Toyota "ATM,MTM" (key "atm,mtm" — only spaces/slashes are underscored), MAN "Şanzıman",
|
||||
// Suzuki "Şanzıman numarası".
|
||||
const transmissionCode = lookup(
|
||||
"şanzıman_kodu",
|
||||
"sanzıman_kodu",
|
||||
"transmission_code",
|
||||
"vites_kutusu",
|
||||
"atm,mtm",
|
||||
"şanzıman",
|
||||
"şanzıman_numarası",
|
||||
);
|
||||
|
||||
// Build body type from prNr K8* (Kaporta formları); brands without a prNr segment
|
||||
// (e.g. BMW) carry it in vinfoBasic "Karoseri" ("Limousine").
|
||||
@@ -1075,10 +1098,16 @@ export class PL24Service {
|
||||
// Friendly model. p5fiat uses "Model bilgisi" ("Panda POP 1.2 …"); most P5 backends use
|
||||
// "Model". BMW's "Model" is only the trim ("520i") with the chassis/generation in "Seri"
|
||||
// ("5 G30") — fold the generation in so parts aren't ambiguous across chassis (E60/F10/G30).
|
||||
const baseModel =
|
||||
lookup("model_bilgisi", "model")?.trim() ||
|
||||
(data.description as string)?.split(" - ")[0]?.trim() ||
|
||||
"";
|
||||
// Mitsubishi's "Model" is an internal chassis/engine code ("KB4T 2500DIESEL/4WD(TRUCK)");
|
||||
// the friendly name is in "Araç" / description ("L200(EUR/MMTH)") — strip the region suffix.
|
||||
const isMitsubishi = getServiceApiPath(serviceName) === "/p5mitsubishi";
|
||||
const baseModel = isMitsubishi
|
||||
? (lookup("araç") || (data.description as string) || lookup("model") || "")
|
||||
.replace(/\s*\([^)]*\)\s*$/, "")
|
||||
.trim()
|
||||
: lookup("model_bilgisi", "model")?.trim() ||
|
||||
(data.description as string)?.split(" - ")[0]?.trim() ||
|
||||
"";
|
||||
// "Seri" is "{line} {chassis} [{variant}]" ("5 G30", "X3 G01", "5 E60 MUE"). The trim already
|
||||
// implies the line ("520i"→5, "X3 sDrive20i"→X3), so drop the leading line token and append
|
||||
// only the chassis(+variant) → "520i G30", "X3 sDrive20i G01" (avoids a redundant "X3 X3").
|
||||
@@ -1108,8 +1137,12 @@ export class PL24Service {
|
||||
0,
|
||||
series: lookup("seri", "satis_tipi", "sales_type"),
|
||||
bodyType,
|
||||
engineCode: engineCode || (engineDesc ? engineDesc.split("/")[0]?.trim() : null),
|
||||
engineType: engineDesc,
|
||||
engineCode:
|
||||
engineCode ||
|
||||
engineLabel?.match(/\(([A-Za-z0-9]{3,})\)/)?.[1] || // Toyota "1800CC … (2ZRFXE)"
|
||||
(engineDesc ? engineDesc.split("/")[0]?.trim() : null) ||
|
||||
null,
|
||||
engineType: engineDesc || engineLabel,
|
||||
engineVolume: null,
|
||||
transmission: transmissionCode || transmissionDesc,
|
||||
driveType,
|
||||
|
||||
Reference in New Issue
Block a user