@bytebrand/export-cars 1.23.2 → 1.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/services/images.service.js +1 -1
- package/dist/services/images.service.js.map +1 -1
- package/dist/transformers/facebook-shop.transformer.js +10 -10
- package/dist/transformers/facebook-shop.transformer.js.map +1 -1
- package/dist/transformers/fb.transformer.d.ts +1 -0
- package/dist/transformers/fb.transformer.js +15 -24
- package/dist/transformers/fb.transformer.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/services/images.service.ts +1 -1
- package/src/transformers/facebook-shop.transformer.ts +16 -10
- package/src/transformers/fb.transformer.ts +23 -24
package/package.json
CHANGED
|
@@ -202,7 +202,7 @@ export class ImagesService {
|
|
|
202
202
|
|
|
203
203
|
|
|
204
204
|
if (!ignoreDefImages && imageWithUrls.length < FB_MAX_IMAGE_COUNT_FOR_DEAFULT) {
|
|
205
|
-
|
|
205
|
+
this.DEFAULT_IMAGES.forEach(url => imageWithUrls.push({ url }));
|
|
206
206
|
}
|
|
207
207
|
|
|
208
208
|
return imageWithUrls.map(i => i.url);
|
|
@@ -122,15 +122,21 @@ export class FacebookShopTransformer {
|
|
|
122
122
|
downPayment: this.getNum(car, 'rate.firstInstallment'),
|
|
123
123
|
termLength: this.getNum(car, 'rate.paybackPeriod'),
|
|
124
124
|
};
|
|
125
|
-
const rawLeasing = {
|
|
126
|
-
monthlyPayment: this.getNum(car, 'leasing.monthlyInstallment'),
|
|
127
|
-
downPayment: this.getNum(car, 'leasing.firstInstallment'),
|
|
128
|
-
termLength: this.getNum(car, 'leasing.paybackPeriod'),
|
|
129
|
-
};
|
|
130
125
|
const leasingIsEligible = this.isLeasingEligible(car);
|
|
131
126
|
|
|
132
127
|
const { financing: computedFinancing, leasing: computedLeasing } = this.computeFinancials(car);
|
|
133
128
|
|
|
129
|
+
// Unlike financing, the CDP never reads a pre-stored leasing.monthlyInstallment — it
|
|
130
|
+
// always computes it live from RWG + price (see fe-main SearchResultsStore/NewMainPage,
|
|
131
|
+
// same isLeasingEligible formula). The raw car.leasing.monthlyInstallment field can be
|
|
132
|
+
// stale/unset even when the CDP shows an active leasing tab, so the computed value is the
|
|
133
|
+
// one that actually matches what the customer sees.
|
|
134
|
+
const computedLeasingValues = {
|
|
135
|
+
monthlyPayment: this.getNum(computedLeasing, 'monthlyInstallment'),
|
|
136
|
+
downPayment: this.getNum(computedLeasing, 'firstInstallment'),
|
|
137
|
+
termLength: this.getNum(computedLeasing, 'paybackPeriod'),
|
|
138
|
+
};
|
|
139
|
+
|
|
134
140
|
if (offersFinancing && rawFinancing.monthlyPayment && computedFinancing) {
|
|
135
141
|
offers.push({
|
|
136
142
|
offerType: OfferType.financing,
|
|
@@ -148,15 +154,15 @@ export class FacebookShopTransformer {
|
|
|
148
154
|
});
|
|
149
155
|
}
|
|
150
156
|
|
|
151
|
-
if (leasingIsEligible &&
|
|
157
|
+
if (leasingIsEligible && computedLeasingValues.monthlyPayment && computedLeasing) {
|
|
152
158
|
offers.push({
|
|
153
159
|
offerType: OfferType.leasing,
|
|
154
|
-
title: `${make} ${model} leasen – z. B. ab ${this.formatEUR(
|
|
155
|
-
description: `${make} ${model} leasen – ${
|
|
156
|
-
`${this.formatEUR(
|
|
160
|
+
title: `${make} ${model} leasen – z. B. ab ${this.formatEUR(computedLeasingValues.monthlyPayment)} €/Monat`,
|
|
161
|
+
description: `${make} ${model} leasen – ${computedLeasingValues.termLength} Monate Laufzeit, ` +
|
|
162
|
+
`${this.formatEUR(computedLeasingValues.downPayment)} € Anzahlung`,
|
|
157
163
|
disclaimer: OFFER_DISCLAIMER,
|
|
158
164
|
financials: {
|
|
159
|
-
...
|
|
165
|
+
...computedLeasingValues,
|
|
160
166
|
apr: this.getNum(computedLeasing, 'annualPercentageRate'),
|
|
161
167
|
finalPayment: this.getNum(computedLeasing, 'finalInstallment'),
|
|
162
168
|
totalAmount: this.getNum(computedLeasing, 'grossLoanAmount'),
|
|
@@ -116,31 +116,24 @@ export class FbTransformer {
|
|
|
116
116
|
interior_color: this.getInteriorColor(car),
|
|
117
117
|
condition: this.mapCondition(car),
|
|
118
118
|
energy_efficiency_class_eu: this.getEnergyEfficiencyClass(car),
|
|
119
|
-
vehicle_specifications:
|
|
120
|
-
{
|
|
121
|
-
type: 'gas_mileage_combined',
|
|
122
|
-
units: 'l/100km',
|
|
123
|
-
value: get(car, 'consumption.wltpCombined', ''),
|
|
124
|
-
},
|
|
125
|
-
{
|
|
126
|
-
type: 'gas_mileage_city',
|
|
127
|
-
units: 'l/100km',
|
|
128
|
-
value: get(car, 'consumption.wltpSlow', ''),
|
|
129
|
-
},
|
|
130
|
-
{
|
|
131
|
-
type: 'gas_mileage_highway',
|
|
132
|
-
units: 'l/100km',
|
|
133
|
-
value: get(car, 'consumption.wltpVeryFast', ''),
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
type: 'CO2_emissions',
|
|
137
|
-
units: 'g/km',
|
|
138
|
-
value: get(car, 'environmentEmissions.wltpCo2', ''),
|
|
139
|
-
},
|
|
140
|
-
],
|
|
119
|
+
vehicle_specifications: this.getVehicleSpecifications(car),
|
|
141
120
|
};
|
|
142
121
|
}
|
|
143
122
|
|
|
123
|
+
// wltp* fields are @IsOptional on the schema — genuinely absent for a meaningful share of
|
|
124
|
+
// cars (older listings, incomplete imports). Omit the whole entry rather than emit a spec
|
|
125
|
+
// with an empty <value>, but keep legitimate 0 (e.g. CO2 for an EV) — isPresent, not truthy.
|
|
126
|
+
private getVehicleSpecifications(car: DataSchemes.Car): { type: string; units: string; value: number }[] {
|
|
127
|
+
const isPresent = (value: unknown): value is number => value !== null && value !== undefined && value !== '';
|
|
128
|
+
|
|
129
|
+
return [
|
|
130
|
+
{ type: 'gas_mileage_combined', units: 'l/100km', value: get(car, 'consumption.wltpCombined') },
|
|
131
|
+
{ type: 'gas_mileage_city', units: 'l/100km', value: get(car, 'consumption.wltpSlow') },
|
|
132
|
+
{ type: 'gas_mileage_highway', units: 'l/100km', value: get(car, 'consumption.wltpVeryFast') },
|
|
133
|
+
{ type: 'CO2_emissions', units: 'g/km', value: get(car, 'environmentEmissions.wltpCo2') },
|
|
134
|
+
].filter(spec => isPresent(spec.value));
|
|
135
|
+
}
|
|
136
|
+
|
|
144
137
|
private getYear(car: DataSchemes.Car): number {
|
|
145
138
|
const firstModelsProductionDate = get(car, 'mainData.firstModelsProductionDate', 0) as number;
|
|
146
139
|
const firstModelsProductionYear = moment(firstModelsProductionDate * 1000).format('YYYY');
|
|
@@ -444,7 +437,7 @@ export class FbTransformer {
|
|
|
444
437
|
{ key: 'assistants.laneAssistant', type: 'lane_keep_assist', value: 'Spurhalte-Assistent' },
|
|
445
438
|
{ key: 'lights.ledHeadlights', type: 'led_headlights', value: 'LED Scheinwerfer' },
|
|
446
439
|
{ key: 'window.sunroof', type: 'moon_roof', value: 'Schiebedach' },
|
|
447
|
-
{ key: 'multimedia.mp3Interface', type: 'mp3
|
|
440
|
+
{ key: 'multimedia.mp3Interface', type: 'mp3', value: 'Schnittstelle' },
|
|
448
441
|
{ key: 'multimedia.navigationSystem', type: 'navigation', value: 'Navigationssystem' },
|
|
449
442
|
{ key: 'assistants.nightVisionAssistant', type: 'night_view', value: 'Nachsicht Assistent' },
|
|
450
443
|
{ key: 'window.panoramicGlassRoof', type: 'panorama_roof', value: 'Panoramaschiebedach' },
|
|
@@ -670,6 +663,12 @@ export class FbTransformer {
|
|
|
670
663
|
}
|
|
671
664
|
}
|
|
672
665
|
|
|
666
|
+
// Upper-bounded so a raw unix timestamp leaking through a non-date field (e.g.
|
|
667
|
+
// mainData.constructionYear stored as an epoch instead of a 4-digit year, seen in prod) can't
|
|
668
|
+
// be mistaken for a valid year — a timestamp is astronomically larger than any real car year.
|
|
673
669
|
function getFirstValidYear(...years: string[]): number {
|
|
674
|
-
|
|
670
|
+
const currentYear = toSafeInteger(moment().format('YYYY'));
|
|
671
|
+
return years
|
|
672
|
+
.map((year: string) => toSafeInteger(year))
|
|
673
|
+
.filter((year: number) => year > TIMESTAMP_FIRST_YEAR && year <= currentYear + 1)[0];
|
|
675
674
|
}
|