@bytebrand/export-cars 1.6.6 → 1.7.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/d.json +1 -0
- package/dist/app.module.js +14 -20
- package/dist/app.module.js.map +1 -1
- package/dist/exporters/modix.exporter.js +5 -2
- package/dist/exporters/modix.exporter.js.map +1 -1
- package/dist/formats/modix-xml.builder.d.ts +1 -0
- package/dist/formats/modix-xml.builder.js +14 -0
- package/dist/formats/modix-xml.builder.js.map +1 -1
- package/dist/interfaces/export-item.interface.d.ts +2 -0
- package/dist/services/index.d.ts +3 -0
- package/dist/services/index.js +3 -0
- package/dist/services/index.js.map +1 -1
- package/dist/transformers/modix.transformer.d.ts +4 -2
- package/dist/transformers/modix.transformer.js +10 -2
- package/dist/transformers/modix.transformer.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/app.module.ts +18 -13
- package/src/export.command.ts +1 -1
- package/src/exporters/modix.exporter.ts +10 -4
- package/src/formats/modix-xml.builder.ts +19 -0
- package/src/interfaces/export-item.interface.ts +3 -0
- package/src/services/index.ts +4 -0
- package/src/transformers/modix.transformer.ts +22 -13
- package/api_export_cars_dasparking.xml +0 -603
- package/api_export_cars_fb.xml +0 -1108
- package/api_export_cars_kleinanzeigefocus.xml +0 -1035
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bytebrand/export-cars",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "bytebrand",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"@bytebrand/cronicle-helper": "^1.15.1",
|
|
24
24
|
"@bytebrand/fe-financing": "^5.4.3",
|
|
25
25
|
"@bytebrand/i18n-dictionaries": "^1.4.2",
|
|
26
|
-
"@bytebrand/import-helper": "^0.
|
|
26
|
+
"@bytebrand/import-helper": "^0.35.1",
|
|
27
27
|
"@bytebrand/schema-tools": "^3.13.24",
|
|
28
28
|
"@bytebrand/zipper": "^2.1.1",
|
|
29
29
|
"@nestjs/axios": "^0.1.0",
|
|
@@ -66,5 +66,5 @@
|
|
|
66
66
|
"engines": {
|
|
67
67
|
"node": ">=14.0.0"
|
|
68
68
|
},
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "0a32c8e63b3fa1e50969fd1067762548862b3435"
|
|
70
70
|
}
|
package/src/app.module.ts
CHANGED
|
@@ -1,19 +1,23 @@
|
|
|
1
|
-
import Bottleneck from 'bottleneck';
|
|
2
1
|
import { CacheModule, Module } from '@nestjs/common';
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
import { CarService } from './services/car.service';
|
|
6
|
-
import { RequestService } from './services/request.service';
|
|
7
|
-
import { MappingService } from './services/mapping.service';
|
|
8
|
-
import { UserService } from './services/user.service';
|
|
2
|
+
import Bottleneck from 'bottleneck';
|
|
3
|
+
|
|
9
4
|
import { InputQuestions } from './input.questions';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
import { ExportRunner } from './export.command';
|
|
6
|
+
import {
|
|
7
|
+
ConfigService,
|
|
8
|
+
RequestService,
|
|
9
|
+
MappingService,
|
|
10
|
+
CarService,
|
|
11
|
+
UserService,
|
|
12
|
+
LoaderService,
|
|
13
|
+
RulesService,
|
|
14
|
+
MarketingImagesService
|
|
15
|
+
} from './services';
|
|
14
16
|
|
|
15
17
|
@Module({
|
|
16
|
-
imports: [
|
|
18
|
+
imports: [
|
|
19
|
+
CacheModule.register(),
|
|
20
|
+
],
|
|
17
21
|
providers: [
|
|
18
22
|
InputQuestions,
|
|
19
23
|
ExportRunner,
|
|
@@ -31,4 +35,5 @@ import { MarketingImagesService } from './services/marketing-images.service';
|
|
|
31
35
|
},
|
|
32
36
|
],
|
|
33
37
|
})
|
|
34
|
-
|
|
38
|
+
|
|
39
|
+
export class AppModule { }
|
package/src/export.command.ts
CHANGED
|
@@ -26,7 +26,7 @@ export class ExportRunner extends CommandRunner {
|
|
|
26
26
|
rl.on('line', async (data: string) => {
|
|
27
27
|
const input = JSON.parse(data) as Input;
|
|
28
28
|
LoggerService.log(`Running job: ${input.id} - ${JSON.stringify(input)}\n`);
|
|
29
|
-
|
|
29
|
+
|
|
30
30
|
this.configService.config = new exportSchema[input.params.exportType].config(input.params);
|
|
31
31
|
const exporter = await this.moduleRef.create<Exporter>(exportSchema[input.params.exportType].exporter);
|
|
32
32
|
await exporter.export().catch(reject);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
1
|
+
import { Inject, Injectable } from '@nestjs/common';
|
|
2
2
|
import { ModuleRef } from '@nestjs/core';
|
|
3
3
|
|
|
4
|
-
import { CronicleUtils } from '@bytebrand/cronicle-helper';
|
|
4
|
+
import { CronicleUtils, ImportOrigins } from '@bytebrand/cronicle-helper';
|
|
5
|
+
import { MappingBuilder } from '@bytebrand/import-helper';
|
|
5
6
|
import { FsChunkInterface } from '@bytebrand/chunkable';
|
|
6
7
|
|
|
7
8
|
import { CarService, ConfigService, LoaderService } from '../services';
|
|
@@ -9,6 +10,7 @@ import { Exporter } from '../interfaces/exporter.interface';
|
|
|
9
10
|
import { ModixTransformer } from '../transformers';
|
|
10
11
|
import { ModixXmlBuilder } from '../formats';
|
|
11
12
|
|
|
13
|
+
|
|
12
14
|
@Injectable()
|
|
13
15
|
export class ModixExporter implements Exporter {
|
|
14
16
|
constructor(
|
|
@@ -19,9 +21,13 @@ export class ModixExporter implements Exporter {
|
|
|
19
21
|
) {}
|
|
20
22
|
async export(): Promise<void> {
|
|
21
23
|
const [fileXml] = this.configService.config.outputFiles;
|
|
24
|
+
|
|
22
25
|
await CronicleUtils.ensureDir(this.configService.config.pathesConfig.localConvertedDirectory);
|
|
23
26
|
await CronicleUtils.emptyDir(this.configService.config.pathesConfig.localConvertedDirectory);
|
|
24
27
|
|
|
28
|
+
const mappingBuilder = new MappingBuilder(this.configService.config.apikey);
|
|
29
|
+
await mappingBuilder.loadMappingRules(ImportOrigins.MODIX);
|
|
30
|
+
|
|
25
31
|
const modixXmlBuilder = new ModixXmlBuilder(fileXml);
|
|
26
32
|
await modixXmlBuilder.buildStart();
|
|
27
33
|
|
|
@@ -32,8 +38,8 @@ export class ModixExporter implements Exporter {
|
|
|
32
38
|
for (let i = 0; i < chunk.data.length; i += 1) {
|
|
33
39
|
const data = chunk.data[i];
|
|
34
40
|
|
|
35
|
-
const
|
|
36
|
-
await modixXmlBuilder.addItem(
|
|
41
|
+
const transformedCar = await modixTransformer.transform(data, mappingBuilder.getMappingRules({ reversTransforming: true }));
|
|
42
|
+
await modixXmlBuilder.addItem(transformedCar);
|
|
37
43
|
|
|
38
44
|
this.carService.counter.countCar(data.images);
|
|
39
45
|
}
|
|
@@ -52,6 +52,10 @@ export class ModixXmlBuilder extends XMLBuilderBase {
|
|
|
52
52
|
item += this.mapDealer(car.dealer.address, car.dealer.imprint);
|
|
53
53
|
break;
|
|
54
54
|
}
|
|
55
|
+
case 'options': {
|
|
56
|
+
item += this.mapOptions(car);
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
55
59
|
default: {
|
|
56
60
|
item += this.getElement(tag, value, false);
|
|
57
61
|
}
|
|
@@ -164,4 +168,19 @@ export class ModixXmlBuilder extends XMLBuilderBase {
|
|
|
164
168
|
await this.write('\n</vehicles>\n</vehiclePool>\n</automotive>');
|
|
165
169
|
await this.end();
|
|
166
170
|
}
|
|
171
|
+
// { [id: string]: string }
|
|
172
|
+
mapOptions(car: ModixXmlItem) {
|
|
173
|
+
const result = [];
|
|
174
|
+
|
|
175
|
+
for (const id in car.options) {
|
|
176
|
+
const value = car.options[id];
|
|
177
|
+
result.push(
|
|
178
|
+
`<option id="${id}">
|
|
179
|
+
<value>${value}</value>
|
|
180
|
+
</option>`
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
return `<options>${result.join('')}</options>`
|
|
185
|
+
}
|
|
167
186
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { DataSchemes } from '@bytebrand/car-schema';
|
|
2
|
+
|
|
1
3
|
import { IModixWrapItem } from './autoborse.intreface';
|
|
2
4
|
|
|
3
5
|
export interface FbXmlItem {
|
|
@@ -217,6 +219,7 @@ export interface ModixXmlItem {
|
|
|
217
219
|
prices: priceItem;
|
|
218
220
|
images: imageItem;
|
|
219
221
|
dealer: dealerItem;
|
|
222
|
+
options: Omit<DataSchemes.Car, 'state'>;
|
|
220
223
|
}
|
|
221
224
|
|
|
222
225
|
export interface mapSameTagsItem {
|
package/src/services/index.ts
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
import { findLast, get, toNumber, toSafeInteger, toString } from 'lodash';
|
|
1
|
+
import { findLast, get, omit, toNumber, toSafeInteger, toString } from 'lodash';
|
|
2
2
|
import * as moment from 'moment/moment';
|
|
3
3
|
|
|
4
4
|
import { Injectable } from '@nestjs/common';
|
|
5
5
|
|
|
6
|
+
import { MappingRulesInterface, TransformerFactory } from '@bytebrand/import-helper';
|
|
6
7
|
import { toLowercase } from '@bytebrand/schema-tools/dist/transform/utils';
|
|
7
8
|
import { ImboImageResponseInterface } from '@bytebrand/chunkable';
|
|
9
|
+
import { ImportOrigins } from '@bytebrand/cronicle-helper';
|
|
8
10
|
import { DataSchemes } from '@bytebrand/car-schema';
|
|
9
11
|
|
|
10
|
-
|
|
12
|
+
import { imageItem, IModixWrapItem, ModixXmlItem } from '../interfaces';
|
|
13
|
+
import { isNotEmptyArray, isValidVin } from '../utils/validator.utils';
|
|
14
|
+
import { CategoryList } from '../constants/modix/category.constant';
|
|
15
|
+
import { ConfigService } from '../services/config.service';
|
|
11
16
|
import {
|
|
12
17
|
BodyColorList,
|
|
13
18
|
VehicleClassList,
|
|
@@ -17,23 +22,19 @@ import {
|
|
|
17
22
|
UsageConditionList,
|
|
18
23
|
UsageTypeList,
|
|
19
24
|
} from '../constants';
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
import { CategoryList } from '../constants/modix/category.constant';
|
|
23
|
-
import { ConfigService } from '../services/config.service';
|
|
25
|
+
|
|
26
|
+
|
|
24
27
|
|
|
25
28
|
@Injectable()
|
|
26
29
|
export class ModixTransformer {
|
|
27
30
|
constructor(private readonly configService: ConfigService) { }
|
|
28
31
|
|
|
29
|
-
transform({
|
|
30
|
-
|
|
31
|
-
images
|
|
32
|
-
|
|
33
|
-
car: DataSchemes.Car;
|
|
34
|
-
images: ImboImageResponseInterface[];
|
|
35
|
-
}): ModixXmlItem {
|
|
32
|
+
async transform(chunkData: { car: DataSchemes.Car; images: ImboImageResponseInterface[]; }, mappingRules: MappingRulesInterface[]): Promise<ModixXmlItem> {
|
|
33
|
+
|
|
34
|
+
const { car, images } = chunkData;
|
|
35
|
+
// await this.buildOptions(car, mappingRules);
|
|
36
36
|
return {
|
|
37
|
+
|
|
37
38
|
//Main data
|
|
38
39
|
maindata: {
|
|
39
40
|
category: this.getCategoryData(car),
|
|
@@ -108,6 +109,7 @@ export class ModixTransformer {
|
|
|
108
109
|
vatid: { value: 'DE311875741' },
|
|
109
110
|
},
|
|
110
111
|
},
|
|
112
|
+
options: await this.buildOptions(car, mappingRules),
|
|
111
113
|
};
|
|
112
114
|
}
|
|
113
115
|
|
|
@@ -206,4 +208,11 @@ export class ModixTransformer {
|
|
|
206
208
|
}
|
|
207
209
|
return { url, imageList };
|
|
208
210
|
}
|
|
211
|
+
|
|
212
|
+
private async buildOptions(car: DataSchemes.Car, mappingRules: MappingRulesInterface[]): Promise<Omit<DataSchemes.Car, 'state'>> {
|
|
213
|
+
const transformer = TransformerFactory.createTransformer(ImportOrigins.MODIX, car, { importSelectorMappingLog: () => { } } as any, [{ make: 'make', model: 'model' }], ['alt_model']);
|
|
214
|
+
const { car: transformedCar } = await transformer.transform(mappingRules);
|
|
215
|
+
|
|
216
|
+
return omit(transformedCar, ['state']);
|
|
217
|
+
}
|
|
209
218
|
}
|