@bytebrand/export-cars 1.21.89 → 1.21.91

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytebrand/export-cars",
3
- "version": "1.21.89",
3
+ "version": "1.21.91",
4
4
  "description": "",
5
5
  "author": "bytebrand",
6
6
  "license": "UNLICENSED",
@@ -170,15 +170,7 @@ export class ImagesService {
170
170
  }
171
171
 
172
172
  generateImageLinks(images: ImboImageResponseInterface[], carId: string, size: ImageSize = ImageSize.large) {
173
- if (carId === 'b75573af-57a0-4c30-9128-dac832fc09b9') {
174
- console.log('generateImageLinks', size);
175
- }
176
-
177
173
  return images.map((image: ImboImageResponseInterface) => {
178
- if (carId === 'b75573af-57a0-4c30-9128-dac832fc09b9') {
179
- console.log('generateImageLinks', `${this.configService.config.baseImageUrl}/carimage/${carId}/${image.imageIdentifier}/${size}`);
180
- }
181
-
182
174
  return `${this.configService.config.baseImageUrl}/carimage/${carId}/${image.imageIdentifier}/${size}`;
183
175
  });
184
176
  }
@@ -50,11 +50,6 @@ export class GoogleTransformer {
50
50
  ...transformedImages.feat
51
51
  ]
52
52
 
53
- if (carId === 'b75573af-57a0-4c30-9128-dac832fc09b9') {
54
- console.log('b75573af-57a0-4c30-9128-dac832fc09b9');
55
- console.log('images', allImages);
56
- }
57
-
58
53
  return {
59
54
  google_product_category: '916',
60
55
  vehicle_fulfillment: {
@@ -91,7 +86,7 @@ export class GoogleTransformer {
91
86
  fuel_consumption: `${this.transformService.fuelConsumption(car)}l/100km`,
92
87
  energy_consumption: this.getWLTP(car),
93
88
  co2_emissions: `${this.transformService.cO2Emission(car)}g/km`,
94
- description: (await this.getDescription(car)).substring(0, 4800),
89
+ description: this.processText((await this.getDescription(car))),
95
90
  identifier_exists: 'no',
96
91
  availability: 'in_stock',
97
92
  // custom_label_0: '',
@@ -124,18 +119,33 @@ export class GoogleTransformer {
124
119
  return trim(escape(join([this.getBrand(car), model], ' ')));
125
120
  }
126
121
 
122
+ private processText(input: string) {
123
+ return input
124
+ .replace(/\*\*\\/g, '</strong></p>|||')
125
+ .replace(/\*\*/g, '<p><strong>')
126
+ .split('|||')
127
+ .map(item => item.trim())
128
+ .flatMap(str =>
129
+ str.split('\\')
130
+ .map(item => item.trim())
131
+ .filter(Boolean)
132
+ )
133
+ .map(item =>
134
+ item.startsWith('* ') ? item.slice(2) : item
135
+ )
136
+ .map(item =>
137
+ item.includes('<p>') ? item : `<p>${item}</p>`
138
+ )
139
+ .join('');
140
+ }
141
+
127
142
  private async getDescription(car: DataSchemes.Car): Promise<string> {
128
- const carId = get(car, '_id');
129
143
  const dealerId = get(car, 'metaData.ownerId');
130
144
  const descriptionSchema = await this.userService.getDefaultSummaryByDealerId(dealerId);
131
145
  const descriptionBuilder = CarDescriptionFactory.create(DescriptionTypeEnum.Mobile, car);
132
146
 
133
147
  const transformedBody = descriptionBuilder.transformSeparately(descriptionSchema)
134
148
 
135
- if (carId === 'b75573af-57a0-4c30-9128-dac832fc09b9') {
136
- console.log('transformedBody', JSON.stringify(transformedBody));
137
- }
138
-
139
149
  return transformedBody.body;
140
150
  }
141
151