@bytebrand/export-cars 1.10.0 → 1.10.1
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/configs/config.d.ts +3 -13
- package/dist/configs/config.js +3 -15
- package/dist/configs/config.js.map +1 -1
- package/dist/configs/criteo.config.js +1 -0
- package/dist/configs/criteo.config.js.map +1 -1
- package/dist/configs/facebook-shop.config.js +1 -0
- package/dist/configs/facebook-shop.config.js.map +1 -1
- package/dist/configs/fb.config.js +1 -0
- package/dist/configs/fb.config.js.map +1 -1
- package/dist/export.command.d.ts +2 -3
- package/dist/export.command.js +2 -5
- package/dist/export.command.js.map +1 -1
- package/dist/services/images.service.d.ts +3 -5
- package/dist/services/images.service.js +7 -23
- package/dist/services/images.service.js.map +1 -1
- package/dist/transformers/by-owner.transformer.js +3 -14
- package/dist/transformers/by-owner.transformer.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +3 -9
- package/src/configs/config.ts +3 -15
- package/src/configs/criteo.config.ts +1 -0
- package/src/configs/facebook-shop.config.ts +1 -0
- package/src/configs/fb.config.ts +1 -0
- package/src/export.command.ts +1 -2
- package/src/services/images.service.ts +14 -28
- package/src/transformers/by-owner.transformer.ts +3 -16
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bytebrand/export-cars",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "bytebrand",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -21,12 +21,10 @@
|
|
|
21
21
|
"@bytebrand/car-schema": "^3.12.24",
|
|
22
22
|
"@bytebrand/chunkable": "^5.13.2",
|
|
23
23
|
"@bytebrand/cronicle-helper": "^1.15.1",
|
|
24
|
-
"@bytebrand/fe-financing": "^5.4.3",
|
|
25
24
|
"@bytebrand/i18n-dictionaries": "^1.4.2",
|
|
26
25
|
"@bytebrand/import-helper": "^0.35.1",
|
|
27
26
|
"@bytebrand/schema-tools": "^3.13.24",
|
|
28
27
|
"@bytebrand/zipper": "^2.1.1",
|
|
29
|
-
"@nestjs/axios": "^0.1.0",
|
|
30
28
|
"@nestjs/common": "^9.0.0",
|
|
31
29
|
"@nestjs/core": "^9.0.0",
|
|
32
30
|
"bottleneck": "^2.19.5",
|
|
@@ -36,12 +34,8 @@
|
|
|
36
34
|
"lodash": "^4.17.21",
|
|
37
35
|
"moment": "^2.29.4",
|
|
38
36
|
"nest-commander": "^3.1.0",
|
|
39
|
-
"nest-winston": "^1.8.0",
|
|
40
37
|
"reflect-metadata": "^0.1.13",
|
|
41
|
-
"
|
|
42
|
-
"rxjs": "^7.2.0",
|
|
43
|
-
"vin-generator": "^1.0.1",
|
|
44
|
-
"winston": "^3.8.2"
|
|
38
|
+
"vin-generator": "^1.0.1"
|
|
45
39
|
},
|
|
46
40
|
"devDependencies": {
|
|
47
41
|
"@nestjs/cli": "^9.0.0",
|
|
@@ -66,5 +60,5 @@
|
|
|
66
60
|
"engines": {
|
|
67
61
|
"node": ">=14.0.0"
|
|
68
62
|
},
|
|
69
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "b3581108ff2e4747c41c6c69facbd8a599051940"
|
|
70
64
|
}
|
package/src/configs/config.ts
CHANGED
|
@@ -5,7 +5,7 @@ export class Config {
|
|
|
5
5
|
apikey: string;
|
|
6
6
|
campaign: string;
|
|
7
7
|
userActionsUrl: string;
|
|
8
|
-
|
|
8
|
+
marketingImageConfigId: number;
|
|
9
9
|
upaUrl: string;
|
|
10
10
|
imboUrl: string;
|
|
11
11
|
imageUrl: string;
|
|
@@ -13,7 +13,6 @@ export class Config {
|
|
|
13
13
|
imageType: ImageType;
|
|
14
14
|
isNewCar: boolean;
|
|
15
15
|
isCriteo: boolean;
|
|
16
|
-
criteoMarketingImagesConfigId: number;
|
|
17
16
|
exportType: ExportType;
|
|
18
17
|
domain: string;
|
|
19
18
|
input: {
|
|
@@ -34,32 +33,23 @@ export class Config {
|
|
|
34
33
|
dealersSpreadsheetTitle: string;
|
|
35
34
|
|
|
36
35
|
protected environmentConfig = {
|
|
37
|
-
[Environment.LOCAL]: {
|
|
38
|
-
domain: 'autode-dev.de',
|
|
39
|
-
criteoMarketingImagesConfigId: 12,
|
|
40
|
-
localConvertedDirectory: 'resources/csv_dev',
|
|
41
|
-
remoteDirectory: 'import_dev',
|
|
42
|
-
imageUrl: 'https://images.autode-dev.de/cache_test',
|
|
43
|
-
baseImageUrl: 'https://images.autode-dev.de',
|
|
44
|
-
marketingImageId: 8,
|
|
45
|
-
},
|
|
46
36
|
[Environment.DEVELOP]: {
|
|
47
37
|
domain: 'autode-dev.de',
|
|
38
|
+
fbMarketingImageId: 8,
|
|
48
39
|
criteoMarketingImagesConfigId: 12,
|
|
49
40
|
localConvertedDirectory: 'resources/csv_dev',
|
|
50
41
|
remoteDirectory: 'import_dev',
|
|
51
42
|
imageUrl: 'https://images.autode-dev.de/cache_test',
|
|
52
43
|
baseImageUrl: 'https://images.autode-dev.de',
|
|
53
|
-
marketingImageId: 8,
|
|
54
44
|
},
|
|
55
45
|
[Environment.PRODUCTION]: {
|
|
56
46
|
domain: 'auto.de',
|
|
47
|
+
fbMarketingImageId: 1,
|
|
57
48
|
criteoMarketingImagesConfigId: 3,
|
|
58
49
|
localConvertedDirectory: 'resources/csv_prod',
|
|
59
50
|
remoteDirectory: 'import',
|
|
60
51
|
imageUrl: 'https://images.auto.de/generated_images',
|
|
61
52
|
baseImageUrl: 'https://images.auto.de',
|
|
62
|
-
marketingImageId: 1,
|
|
63
53
|
},
|
|
64
54
|
};
|
|
65
55
|
|
|
@@ -67,9 +57,7 @@ export class Config {
|
|
|
67
57
|
this.apikey = params.apikey;
|
|
68
58
|
this.exportType = params.exportType;
|
|
69
59
|
this.cpc = params.cpc;
|
|
70
|
-
this.criteoMarketingImagesConfigId = this.environmentConfig[params.environment].criteoMarketingImagesConfigId;
|
|
71
60
|
this.domain = this.environmentConfig[params.environment].domain;
|
|
72
|
-
this.marketingImageId = this.environmentConfig[params.environment].marketingImageId;
|
|
73
61
|
this.baseImageUrl = this.environmentConfig[params.environment].baseImageUrl;
|
|
74
62
|
this.mappingSpreadsheetId = '147qz9sTgs1wi13ua8YKa0IgfxAn1X_qH6LkGnAnzeyY';
|
|
75
63
|
this.dealersSpreadsheetId = '1gWrcA-uRTpna1h66Mbe2Y7NA0tIhlUaQXBcS4a_UzOw';
|
|
@@ -8,6 +8,7 @@ export class CriteoConfig extends Config {
|
|
|
8
8
|
this.campaign = ExportType.CRITEO;
|
|
9
9
|
this.pathesConfig.localConvertedDirectory = `resources/${ExportType.CRITEO}-export`;
|
|
10
10
|
this.imageType = ImageType.marketing;
|
|
11
|
+
this.marketingImageConfigId = this.environmentConfig[params.environment].criteoMarketingImagesConfigId;
|
|
11
12
|
this.outputFiles = [
|
|
12
13
|
`${this.pathesConfig.localConvertedDirectory}/api_export_cars_${ExportType.CRITEO}.${FileType.XML}`,
|
|
13
14
|
];
|
|
@@ -8,6 +8,7 @@ export class FacebookShopConfig extends Config {
|
|
|
8
8
|
this.pathesConfig.localConvertedDirectory = `resources/${ExportType.FACEBOOK_SHOP}-export`;
|
|
9
9
|
this.imageUrl = this.environmentConfig[params.environment].baseImageUrl;
|
|
10
10
|
this.imageType = ImageType.marketing;
|
|
11
|
+
this.marketingImageConfigId = this.environmentConfig[params.environment].fbMarketingImageId;
|
|
11
12
|
this.outputFiles = [
|
|
12
13
|
`${this.pathesConfig.localConvertedDirectory}/api_export_cars_${ExportType.FACEBOOK_SHOP}.${FileType.XML}`,
|
|
13
14
|
];
|
package/src/configs/fb.config.ts
CHANGED
|
@@ -8,6 +8,7 @@ export class FbConfig extends Config {
|
|
|
8
8
|
this.pathesConfig.localConvertedDirectory = `resources/${ExportType.FB}-export`;
|
|
9
9
|
this.imageUrl = this.environmentConfig[params.environment].imageUrl;
|
|
10
10
|
this.imageType = ImageType.marketing;
|
|
11
|
+
this.marketingImageConfigId = this.environmentConfig[params.environment].fbMarketingImageId;
|
|
11
12
|
this.outputFiles = [
|
|
12
13
|
`${this.pathesConfig.localConvertedDirectory}/api_export_cars_${ExportType.FB}.${FileType.XML}`,
|
|
13
14
|
];
|
package/src/export.command.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createInterface } from 'readline';
|
|
2
|
-
import { Command, CommandRunner
|
|
2
|
+
import { Command, CommandRunner } from 'nest-commander';
|
|
3
3
|
import { ConfigService } from './services';
|
|
4
4
|
import { Input } from './interfaces/input.interface';
|
|
5
5
|
import { exportSchema } from './export.schema';
|
|
@@ -13,7 +13,6 @@ import { LoggerService } from '@bytebrand/cronicle-helper';
|
|
|
13
13
|
})
|
|
14
14
|
export class ExportRunner extends CommandRunner {
|
|
15
15
|
constructor(
|
|
16
|
-
private readonly inquirer: InquirerService,
|
|
17
16
|
private configService: ConfigService,
|
|
18
17
|
private moduleRef: ModuleRef,
|
|
19
18
|
) {
|
|
@@ -1,17 +1,20 @@
|
|
|
1
|
+
import { get, toString } from 'lodash';
|
|
2
|
+
|
|
1
3
|
import { Injectable } from '@nestjs/common';
|
|
2
|
-
|
|
4
|
+
|
|
5
|
+
import { MarketingImageConfigsInterface } from '@bytebrand/autode-request';
|
|
3
6
|
import { ImboImageResponseInterface } from '@bytebrand/chunkable';
|
|
4
|
-
import {
|
|
7
|
+
import { DataSchemes } from '@bytebrand/car-schema';
|
|
8
|
+
|
|
9
|
+
import { FB_MAX_IMAGE_COUNT_FOR_DEAFULT } from '../constants/fb.constants';
|
|
5
10
|
import { isNotEmptyArray } from '../utils/validator.utils';
|
|
6
11
|
import { ConfigService } from './config.service';
|
|
7
|
-
import { ImageType } from '../enums';
|
|
8
|
-
import { MarketingImageConfigInterface, MarketingImageConfigsInterface } from '@bytebrand/autode-request';
|
|
9
12
|
import { UserService } from './user.service';
|
|
10
|
-
import {
|
|
13
|
+
import { ImageType } from '../enums';
|
|
11
14
|
|
|
12
15
|
@Injectable()
|
|
13
16
|
export class ImagesService {
|
|
14
|
-
constructor(private readonly configService: ConfigService, private readonly userService: UserService) {}
|
|
17
|
+
constructor(private readonly configService: ConfigService, private readonly userService: UserService) { }
|
|
15
18
|
|
|
16
19
|
async getImages(
|
|
17
20
|
car: DataSchemes.Car,
|
|
@@ -74,7 +77,7 @@ export class ImagesService {
|
|
|
74
77
|
|
|
75
78
|
const carId = toString(get(car, '_id', ''));
|
|
76
79
|
|
|
77
|
-
const transformedImages = this.generateImageLinks(images, carId);
|
|
80
|
+
const transformedImages = this.generateImageLinks(images.filter(i => i), carId);
|
|
78
81
|
if (transformedImages.length < 17) {
|
|
79
82
|
transformedImages.push(...defaultImages);
|
|
80
83
|
}
|
|
@@ -90,10 +93,9 @@ export class ImagesService {
|
|
|
90
93
|
async getMarketingImages(images: any, carId: string): Promise<string[]> {
|
|
91
94
|
const imageUrl = this.configService.config.imageUrl;
|
|
92
95
|
const transformedImages = this.transformImagesArrayIntoObject(images);
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const marketingImageConfigs = this.transform(configs);
|
|
96
|
+
|
|
97
|
+
const config = await this.userService.getMarketingImageConfig(this.configService.config.marketingImageConfigId);
|
|
98
|
+
const marketingImageConfigs = config.marketingImages.map(i => ({ marketingImageCodes: i.imageCodes }));
|
|
97
99
|
|
|
98
100
|
const defImages = [
|
|
99
101
|
'https://images.auto.de/carimage/noimage/7pNvWELuWhZX/large-cached.jpeg',
|
|
@@ -110,7 +112,7 @@ export class ImagesService {
|
|
|
110
112
|
const imageCode = marketingImage.marketingImageCodes[i];
|
|
111
113
|
const imageId = transformedImages[imageCode];
|
|
112
114
|
if (imageId) {
|
|
113
|
-
imageUrls.push(this.getImagePathWithExtenstion(imageUrl, carId, imageId,
|
|
115
|
+
imageUrls.push(this.getImagePathWithExtenstion(imageUrl, carId, imageId, config));
|
|
114
116
|
break;
|
|
115
117
|
}
|
|
116
118
|
}
|
|
@@ -121,14 +123,6 @@ export class ImagesService {
|
|
|
121
123
|
return imageUrls;
|
|
122
124
|
}
|
|
123
125
|
|
|
124
|
-
async getMarketingImageConfigs(): Promise<MarketingImageConfigsInterface> {
|
|
125
|
-
const configs = await this.userService.getMarketingImageConfigs();
|
|
126
|
-
const responseData = configs.find(config => config.channelCode.includes(this.configService.config.exportType));
|
|
127
|
-
let id;
|
|
128
|
-
!responseData?.id ? (id = this.configService.config.marketingImageId) : (id = responseData.id);
|
|
129
|
-
return this.userService.getMarketingImageConfig(id);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
126
|
private transformImagesArrayIntoObject(images: { [imageCode: string]: string }[]) {
|
|
133
127
|
const result: { [imageCode: string]: string } = {};
|
|
134
128
|
images.forEach(image => {
|
|
@@ -138,14 +132,6 @@ export class ImagesService {
|
|
|
138
132
|
return result;
|
|
139
133
|
}
|
|
140
134
|
|
|
141
|
-
private transform(config: MarketingImageConfigInterface): { marketingImageCodes: string[] }[] {
|
|
142
|
-
return config.marketingImages.map(marketingImage => {
|
|
143
|
-
return {
|
|
144
|
-
marketingImageCodes: marketingImage.imageCodes,
|
|
145
|
-
};
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
|
|
149
135
|
protected getChannelPath(imageUrl: string, carId: string): string {
|
|
150
136
|
return `${imageUrl}/${[carId[0], carId[1], carId[2], carId].join('/')}`;
|
|
151
137
|
}
|
|
@@ -3,7 +3,6 @@ import { Translator, TranslatorExtended } from '@bytebrand/schema-tools';
|
|
|
3
3
|
import { de, deVehicleDetailsPage, deVehicleProps } from '@bytebrand/i18n-dictionaries';
|
|
4
4
|
import { DataSchemes } from '@bytebrand/car-schema';
|
|
5
5
|
import { Injectable } from '@nestjs/common';
|
|
6
|
-
import { normalizeRateObject, getMonthlyInstallment, getComputedFinancing } from '@bytebrand/fe-financing';
|
|
7
6
|
import * as moment from 'moment';
|
|
8
7
|
|
|
9
8
|
type transformFn = (car: DataSchemes.Car, translator: TranslatorExtended) => string;
|
|
@@ -24,23 +23,11 @@ export class ByOwnerTransformer {
|
|
|
24
23
|
|
|
25
24
|
price: 'price.currentSalesPrice',
|
|
26
25
|
'(old price) strike price': 'price.wasPrice',
|
|
27
|
-
rate: (car: DataSchemes.Car) =>
|
|
28
|
-
const { rate } = normalizeRateObject({ ...car });
|
|
29
|
-
return getMonthlyInstallment(rate);
|
|
30
|
-
},
|
|
26
|
+
rate: (car: DataSchemes.Car) => car.rate.monthlyInstallment,
|
|
31
27
|
'discount in %': this.mapToNumber('price.historyPriceDifferencePerCent', 1, 0),
|
|
32
28
|
'discount in €': this.mapToNumber('price.historyPriceDifference', 1, 0),
|
|
33
|
-
'first_installment in €': (car: DataSchemes.Car) =>
|
|
34
|
-
|
|
35
|
-
const price = getComputedFinancing(rate) as ReturnType<typeof getComputedFinancing> & {
|
|
36
|
-
firstInstallment: number;
|
|
37
|
-
};
|
|
38
|
-
return price.firstInstallment;
|
|
39
|
-
},
|
|
40
|
-
'amount of month': (car: DataSchemes.Car) => {
|
|
41
|
-
const { rate } = normalizeRateObject({ ...car });
|
|
42
|
-
return rate.paybackPeriod;
|
|
43
|
-
},
|
|
29
|
+
'first_installment in €': (car: DataSchemes.Car) => car.rate.firstInstallment,
|
|
30
|
+
'amount of month': (car: DataSchemes.Car) => car.rate.paybackPeriod,
|
|
44
31
|
|
|
45
32
|
Name: (car: DataSchemes.Car): string => {
|
|
46
33
|
const make = toString(get(car, 'mainData.make', ''));
|