@bytebrand/export-cars 1.21.6 → 1.21.8
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/.editorconfig +8 -8
- package/.eslintignore +1 -1
- package/.eslintrc.js +24 -24
- package/.prettierrc.js +7 -7
- package/README.md +65 -65
- package/dist/configs/index.d.ts +1 -0
- package/dist/configs/index.js +1 -0
- package/dist/configs/index.js.map +1 -1
- package/dist/configs/santander.config.d.ts +5 -0
- package/dist/configs/santander.config.js +18 -0
- package/dist/configs/santander.config.js.map +1 -0
- package/dist/enums/export-type.enum.d.ts +1 -0
- package/dist/enums/export-type.enum.js +1 -0
- package/dist/enums/export-type.enum.js.map +1 -1
- package/dist/export.command.js +1 -1
- package/dist/export.command.js.map +1 -1
- package/dist/export.schema.d.ts +6 -2
- package/dist/export.schema.js +4 -0
- package/dist/export.schema.js.map +1 -1
- package/dist/exporters/autouncle.exporter.js +5 -1
- package/dist/exporters/autouncle.exporter.js.map +1 -1
- package/dist/exporters/fb.exporter.js +7 -1
- package/dist/exporters/fb.exporter.js.map +1 -1
- package/dist/exporters/index.d.ts +1 -0
- package/dist/exporters/index.js +1 -0
- package/dist/exporters/index.js.map +1 -1
- package/dist/exporters/santander.exporter.d.ts +12 -0
- package/dist/exporters/santander.exporter.js +63 -0
- package/dist/exporters/santander.exporter.js.map +1 -0
- package/dist/formats/auto24-xml.builder.js +2 -2
- package/dist/formats/google-xml.builder.js +3 -3
- package/dist/formats/modix-xml.builder.js +2 -2
- package/dist/formats/ooyyo-xml.builder.js +1 -1
- package/dist/formats/santander-csv.builder.d.ts +6 -0
- package/dist/formats/santander-csv.builder.js +17 -0
- package/dist/formats/santander-csv.builder.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/nest-cli.json +5 -5
- package/package.json +61 -61
- package/src/app.module.ts +38 -38
- package/src/configs/alleskralle.config.ts +15 -15
- package/src/configs/as24.config.ts +13 -13
- package/src/configs/auto24.config.ts +15 -15
- package/src/configs/autoboerse.config.ts +16 -16
- package/src/configs/autouncle.config.ts +14 -14
- package/src/configs/awin.config.ts +15 -15
- package/src/configs/by-owner.config.ts +14 -14
- package/src/configs/config.ts +83 -83
- package/src/configs/criteo.config.ts +17 -17
- package/src/configs/dasparking.config.ts +15 -15
- package/src/configs/eauto.config.ts +15 -15
- package/src/configs/evium.config.ts +18 -18
- package/src/configs/facebook-shop.config.ts +16 -16
- package/src/configs/fb.config.ts +16 -16
- package/src/configs/google.config.ts +14 -14
- package/src/configs/index.ts +22 -21
- package/src/configs/kleinanzeigeFocus.config.ts +14 -14
- package/src/configs/marktde.config.ts +18 -18
- package/src/configs/meinstadt.config.ts +15 -15
- package/src/configs/mitula.config.ts +14 -14
- package/src/configs/ooyyo.config.ts +15 -15
- package/src/configs/santander.config.ts +15 -0
- package/src/configs/trovit.config.ts +14 -14
- package/src/configs/yescar.config.ts +17 -17
- package/src/constants/autouncle.contants.ts +4 -4
- package/src/constants/fb.constants.ts +7 -7
- package/src/constants/index.ts +1 -1
- package/src/constants/modix/body-color-name.constant.ts +20 -20
- package/src/constants/modix/category.constant.ts +14 -14
- package/src/constants/modix/fuel.constant.ts +14 -14
- package/src/constants/modix/index.ts +7 -7
- package/src/constants/modix/manufacturers.constant.ts +7498 -7498
- package/src/constants/modix/transmission.constant.ts +8 -8
- package/src/constants/modix/usage-type.constant.ts +13 -13
- package/src/constants/modix/vehicle-class.constant.ts +17 -17
- package/src/enums/environment.enum.ts +5 -5
- package/src/enums/export-type.enum.ts +33 -32
- package/src/enums/file-types.enum.ts +8 -8
- package/src/enums/image-type.enum.ts +4 -4
- package/src/enums/index.ts +4 -4
- package/src/export.command.ts +37 -37
- package/src/export.schema.ts +134 -128
- package/src/exporters/as24.exporter.ts +69 -69
- package/src/exporters/auto24.exporter.ts +48 -48
- package/src/exporters/autouncle.exporter.ts +60 -58
- package/src/exporters/awin.exporter.ts +47 -47
- package/src/exporters/by-owner.exporter.ts +44 -44
- package/src/exporters/facebook-shop.exporter.ts +51 -51
- package/src/exporters/fb.exporter.ts +52 -50
- package/src/exporters/google.exporter.ts +45 -45
- package/src/exporters/index.ts +15 -14
- package/src/exporters/meinstadt.exporter.ts +55 -55
- package/src/exporters/mobile.exporter.ts +64 -64
- package/src/exporters/modix.exporter.ts +56 -56
- package/src/exporters/ooyyo.exporter.ts +48 -48
- package/src/exporters/rubrikk.exporter.ts +53 -53
- package/src/exporters/santander.exporter.ts +50 -0
- package/src/exporters/trovit.exporter.ts +51 -51
- package/src/formats/auto24-xml.builder.ts +54 -54
- package/src/formats/autouncle-json.builder.ts +20 -20
- package/src/formats/awin-csv.builder.ts +16 -16
- package/src/formats/facebook-shop.builder.ts +69 -69
- package/src/formats/fb-xml.builder.ts +71 -71
- package/src/formats/google-xml.builder.ts +35 -35
- package/src/formats/index.ts +5 -5
- package/src/formats/meinstadt-json.builder.ts +19 -19
- package/src/formats/modix-xml.builder.ts +180 -180
- package/src/formats/ooyyo-xml.builder.ts +48 -48
- package/src/formats/rubrikk-xml.builder.ts +27 -27
- package/src/formats/santander-csv.builder.ts +15 -0
- package/src/formats/trovit-xml.builder.ts +44 -44
- package/src/interfaces/atributes-wrap-item.intreface.ts +6 -6
- package/src/interfaces/dealers-mapping.interface.ts +7 -7
- package/src/interfaces/description.interface.ts +24 -24
- package/src/interfaces/export-item.interface.ts +366 -366
- package/src/interfaces/exporter.interface.ts +3 -3
- package/src/interfaces/index.ts +3 -3
- package/src/interfaces/input.interface.ts +6 -6
- package/src/interfaces/mapping-rules.interface.ts +11 -11
- package/src/interfaces/modix/index.ts +1 -1
- package/src/interfaces/modix/modix-item-list.interface.ts +5 -5
- package/src/interfaces/params.interface.ts +13 -13
- package/src/interfaces/rule-parser.interface.ts +3 -3
- package/src/main.ts +14 -14
- package/src/rules/abstract.rule.ts +37 -37
- package/src/rules/date.rule.ts +19 -19
- package/src/rules/number.rule.ts +15 -15
- package/src/rules/string.rule.ts +8 -8
- package/src/services/car.service.ts +49 -49
- package/src/services/config.service.ts +15 -15
- package/src/services/images.service.ts +207 -207
- package/src/services/index.ts +9 -9
- package/src/services/loader.service.ts +29 -29
- package/src/services/mapping.service.ts +91 -91
- package/src/services/request.service.ts +44 -44
- package/src/services/rules.service.ts +61 -61
- package/src/services/transformer.service.ts +129 -129
- package/src/services/user.service.ts +57 -57
- package/src/transformers/as24.transformer.ts +253 -253
- package/src/transformers/auto24.transfomer.ts +155 -155
- package/src/transformers/autouncle.transformer.ts +236 -236
- package/src/transformers/awin.transformer.ts +193 -193
- package/src/transformers/by-owner.transformer.ts +354 -354
- package/src/transformers/facebook-shop.transformer.ts +93 -93
- package/src/transformers/fb-description.transformer.ts +316 -316
- package/src/transformers/fb-equipment.transformer.ts +161 -161
- package/src/transformers/fb.transformer.ts +655 -655
- package/src/transformers/google.transformer.ts +169 -169
- package/src/transformers/index.ts +5 -5
- package/src/transformers/meinstadt.transformer.ts +92 -92
- package/src/transformers/mobile.transformer.ts +482 -482
- package/src/transformers/modix.transformer.ts +227 -227
- package/src/transformers/ooyyo.transformer.ts +109 -109
- package/src/transformers/rubrikk.transformer.ts +200 -200
- package/src/transformers/trovit.transformer.ts +63 -63
- package/src/utils/converter.utils.ts +15 -15
- package/src/utils/index.ts +2 -2
- package/src/utils/validator.utils.ts +7 -7
- package/tsconfig.build.json +4 -4
- package/tsconfig.json +29 -29
|
@@ -1,50 +1,52 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { CarService, RulesService, LoaderService, ConfigService } from '../services';
|
|
3
|
-
import { FsChunkInterface } from '@bytebrand/chunkable';
|
|
4
|
-
import { Exporter } from '../interfaces/exporter.interface';
|
|
5
|
-
import { CronicleUtils } from '@bytebrand/cronicle-helper';
|
|
6
|
-
import { get } from 'lodash';
|
|
7
|
-
import { FbXmlBuilder } from '../formats/fb-xml.builder';
|
|
8
|
-
import { ModuleRef } from '@nestjs/core';
|
|
9
|
-
import { FbTransformer } from '../transformers/fb.transformer';
|
|
10
|
-
import { FbXmlItem } from '../interfaces';
|
|
11
|
-
|
|
12
|
-
@Injectable()
|
|
13
|
-
export class FbExporter implements Exporter {
|
|
14
|
-
constructor(
|
|
15
|
-
private carService: CarService,
|
|
16
|
-
private configService: ConfigService,
|
|
17
|
-
private rulesService: RulesService,
|
|
18
|
-
private loaderService: LoaderService,
|
|
19
|
-
private moduleRef: ModuleRef,
|
|
20
|
-
) {}
|
|
21
|
-
|
|
22
|
-
async export(): Promise<void> {
|
|
23
|
-
const [fileName] = this.configService.config.outputFiles;
|
|
24
|
-
await CronicleUtils.ensureDir(this.configService.config.pathesConfig.localConvertedDirectory);
|
|
25
|
-
await CronicleUtils.emptyDir(this.configService.config.pathesConfig.localConvertedDirectory);
|
|
26
|
-
|
|
27
|
-
const fbXmlBuilder = new FbXmlBuilder(fileName);
|
|
28
|
-
await fbXmlBuilder.buildStart(this.configService.config.domain);
|
|
29
|
-
|
|
30
|
-
const fbTransformer = await this.moduleRef.create(FbTransformer);
|
|
31
|
-
|
|
32
|
-
await this.loaderService.process(async (chunk: FsChunkInterface) => {
|
|
33
|
-
const chunkData = chunk.data.filter(car => this.carService.filterCar(car, this.rulesService.rules));
|
|
34
|
-
chunk.data = null;
|
|
35
|
-
for (const data of chunkData) {
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
//
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { CarService, RulesService, LoaderService, ConfigService } from '../services';
|
|
3
|
+
import { FsChunkInterface } from '@bytebrand/chunkable';
|
|
4
|
+
import { Exporter } from '../interfaces/exporter.interface';
|
|
5
|
+
import { CronicleUtils } from '@bytebrand/cronicle-helper';
|
|
6
|
+
import { get } from 'lodash';
|
|
7
|
+
import { FbXmlBuilder } from '../formats/fb-xml.builder';
|
|
8
|
+
import { ModuleRef } from '@nestjs/core';
|
|
9
|
+
import { FbTransformer } from '../transformers/fb.transformer';
|
|
10
|
+
import { FbXmlItem } from '../interfaces';
|
|
11
|
+
|
|
12
|
+
@Injectable()
|
|
13
|
+
export class FbExporter implements Exporter {
|
|
14
|
+
constructor(
|
|
15
|
+
private carService: CarService,
|
|
16
|
+
private configService: ConfigService,
|
|
17
|
+
private rulesService: RulesService,
|
|
18
|
+
private loaderService: LoaderService,
|
|
19
|
+
private moduleRef: ModuleRef,
|
|
20
|
+
) {}
|
|
21
|
+
|
|
22
|
+
async export(): Promise<void> {
|
|
23
|
+
const [fileName] = this.configService.config.outputFiles;
|
|
24
|
+
await CronicleUtils.ensureDir(this.configService.config.pathesConfig.localConvertedDirectory);
|
|
25
|
+
await CronicleUtils.emptyDir(this.configService.config.pathesConfig.localConvertedDirectory);
|
|
26
|
+
|
|
27
|
+
const fbXmlBuilder = new FbXmlBuilder(fileName);
|
|
28
|
+
await fbXmlBuilder.buildStart(this.configService.config.domain);
|
|
29
|
+
|
|
30
|
+
const fbTransformer = await this.moduleRef.create(FbTransformer);
|
|
31
|
+
|
|
32
|
+
await this.loaderService.process(async (chunk: FsChunkInterface) => {
|
|
33
|
+
const chunkData = chunk.data.filter(car => this.carService.filterCar(car, this.rulesService.rules));
|
|
34
|
+
chunk.data = null;
|
|
35
|
+
for (const data of chunkData) {
|
|
36
|
+
console.time(`Transform ${data.car._id}`);
|
|
37
|
+
const ownerId = get(data.car, 'metaData.ownerId', null);
|
|
38
|
+
// NOTES:: it must be temporary solution
|
|
39
|
+
const owner = await this.carService.getOwner(ownerId).catch((error: any) => { console.error(error); return null; });
|
|
40
|
+
if (!owner) { console.log(`Skip car because owner ${ownerId} is not a dealer`); continue; }
|
|
41
|
+
const car = await fbTransformer.transform({ owner, ...data });
|
|
42
|
+
console.timeEnd(`Transform ${data.car._id}`);
|
|
43
|
+
|
|
44
|
+
await fbXmlBuilder.addItem(car as FbXmlItem);
|
|
45
|
+
this.carService.counter.countCar(data.images);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
await fbXmlBuilder.buildEnd();
|
|
50
|
+
console.log(this.carService.counter.getCountedCars());
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { ModuleRef } from '@nestjs/core';
|
|
3
|
-
|
|
4
|
-
import { CronicleUtils } from '@bytebrand/cronicle-helper';
|
|
5
|
-
import { FsChunkInterface } from '@bytebrand/chunkable';
|
|
6
|
-
|
|
7
|
-
import { CarService, ConfigService, LoaderService, RulesService } from '../services';
|
|
8
|
-
import { GoogleTransformer } from '../transformers/google.transformer';
|
|
9
|
-
import { GoogleXmlBuilder } from '../formats/google-xml.builder';
|
|
10
|
-
import { Exporter } from '../interfaces/exporter.interface';
|
|
11
|
-
|
|
12
|
-
@Injectable()
|
|
13
|
-
export class GoogleExporter implements Exporter {
|
|
14
|
-
constructor(
|
|
15
|
-
private carService: CarService,
|
|
16
|
-
private configService: ConfigService,
|
|
17
|
-
private rulesService: RulesService,
|
|
18
|
-
private loaderService: LoaderService,
|
|
19
|
-
private moduleRef: ModuleRef,
|
|
20
|
-
) {}
|
|
21
|
-
|
|
22
|
-
async export(): Promise<void> {
|
|
23
|
-
const [fileName] = this.configService.config.outputFiles;
|
|
24
|
-
await CronicleUtils.ensureDir(this.configService.config.pathesConfig.localConvertedDirectory);
|
|
25
|
-
await CronicleUtils.emptyDir(this.configService.config.pathesConfig.localConvertedDirectory);
|
|
26
|
-
|
|
27
|
-
const googleXmlBuilder = new GoogleXmlBuilder(fileName);
|
|
28
|
-
await googleXmlBuilder.buildStart(this.configService.config.domain);
|
|
29
|
-
|
|
30
|
-
const googleTransformer = await this.moduleRef.create(GoogleTransformer);
|
|
31
|
-
|
|
32
|
-
await this.loaderService.process(async (chunk: FsChunkInterface) => {
|
|
33
|
-
chunk.data = chunk.data.filter(car => this.carService.filterCar(car, this.rulesService.rules));
|
|
34
|
-
|
|
35
|
-
for (const data of chunk.data) {
|
|
36
|
-
const car = await googleTransformer.transform(data);
|
|
37
|
-
await googleXmlBuilder.addItem(car);
|
|
38
|
-
this.carService.counter.countCar(data.images);
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
await googleXmlBuilder.buildEnd();
|
|
43
|
-
console.log(this.carService.counter.getCountedCars());
|
|
44
|
-
}
|
|
45
|
-
}
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { ModuleRef } from '@nestjs/core';
|
|
3
|
+
|
|
4
|
+
import { CronicleUtils } from '@bytebrand/cronicle-helper';
|
|
5
|
+
import { FsChunkInterface } from '@bytebrand/chunkable';
|
|
6
|
+
|
|
7
|
+
import { CarService, ConfigService, LoaderService, RulesService } from '../services';
|
|
8
|
+
import { GoogleTransformer } from '../transformers/google.transformer';
|
|
9
|
+
import { GoogleXmlBuilder } from '../formats/google-xml.builder';
|
|
10
|
+
import { Exporter } from '../interfaces/exporter.interface';
|
|
11
|
+
|
|
12
|
+
@Injectable()
|
|
13
|
+
export class GoogleExporter implements Exporter {
|
|
14
|
+
constructor(
|
|
15
|
+
private carService: CarService,
|
|
16
|
+
private configService: ConfigService,
|
|
17
|
+
private rulesService: RulesService,
|
|
18
|
+
private loaderService: LoaderService,
|
|
19
|
+
private moduleRef: ModuleRef,
|
|
20
|
+
) {}
|
|
21
|
+
|
|
22
|
+
async export(): Promise<void> {
|
|
23
|
+
const [fileName] = this.configService.config.outputFiles;
|
|
24
|
+
await CronicleUtils.ensureDir(this.configService.config.pathesConfig.localConvertedDirectory);
|
|
25
|
+
await CronicleUtils.emptyDir(this.configService.config.pathesConfig.localConvertedDirectory);
|
|
26
|
+
|
|
27
|
+
const googleXmlBuilder = new GoogleXmlBuilder(fileName);
|
|
28
|
+
await googleXmlBuilder.buildStart(this.configService.config.domain);
|
|
29
|
+
|
|
30
|
+
const googleTransformer = await this.moduleRef.create(GoogleTransformer);
|
|
31
|
+
|
|
32
|
+
await this.loaderService.process(async (chunk: FsChunkInterface) => {
|
|
33
|
+
chunk.data = chunk.data.filter(car => this.carService.filterCar(car, this.rulesService.rules));
|
|
34
|
+
|
|
35
|
+
for (const data of chunk.data) {
|
|
36
|
+
const car = await googleTransformer.transform(data);
|
|
37
|
+
await googleXmlBuilder.addItem(car);
|
|
38
|
+
this.carService.counter.countCar(data.images);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
await googleXmlBuilder.buildEnd();
|
|
43
|
+
console.log(this.carService.counter.getCountedCars());
|
|
44
|
+
}
|
|
45
|
+
}
|
package/src/exporters/index.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
export * from './as24.exporter';
|
|
2
|
-
export * from './auto24.exporter';
|
|
3
|
-
export * from './autouncle.exporter';
|
|
4
|
-
export * from './by-owner.exporter';
|
|
5
|
-
export * from './fb.exporter';
|
|
6
|
-
export * from './google.exporter';
|
|
7
|
-
export * from './meinstadt.exporter';
|
|
8
|
-
export * from './mobile.exporter';
|
|
9
|
-
export * from './modix.exporter';
|
|
10
|
-
export * from './ooyyo.exporter';
|
|
11
|
-
export * from './rubrikk.exporter';
|
|
12
|
-
export * from './facebook-shop.exporter';
|
|
13
|
-
export * from './trovit.exporter';
|
|
14
|
-
export * from './awin.exporter';
|
|
1
|
+
export * from './as24.exporter';
|
|
2
|
+
export * from './auto24.exporter';
|
|
3
|
+
export * from './autouncle.exporter';
|
|
4
|
+
export * from './by-owner.exporter';
|
|
5
|
+
export * from './fb.exporter';
|
|
6
|
+
export * from './google.exporter';
|
|
7
|
+
export * from './meinstadt.exporter';
|
|
8
|
+
export * from './mobile.exporter';
|
|
9
|
+
export * from './modix.exporter';
|
|
10
|
+
export * from './ooyyo.exporter';
|
|
11
|
+
export * from './rubrikk.exporter';
|
|
12
|
+
export * from './facebook-shop.exporter';
|
|
13
|
+
export * from './trovit.exporter';
|
|
14
|
+
export * from './awin.exporter';
|
|
15
|
+
export * from './santander.exporter';
|
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { ModuleRef } from '@nestjs/core';
|
|
3
|
-
|
|
4
|
-
import { CronicleUtils } from '@bytebrand/cronicle-helper';
|
|
5
|
-
import { FsChunkInterface } from '@bytebrand/chunkable';
|
|
6
|
-
import { Zipper } from '@bytebrand/zipper';
|
|
7
|
-
|
|
8
|
-
import { CarService, RulesService, LoaderService, ConfigService } from '../services';
|
|
9
|
-
import { MeinstadtTransformer } from '../transformers/meinstadt.transformer';
|
|
10
|
-
import { MeinstadtJsonBuilder } from '../formats/meinstadt-json.builder';
|
|
11
|
-
import { MeinstadtJsonItem } from '../interfaces';
|
|
12
|
-
import { Exporter } from '../interfaces/exporter.interface';
|
|
13
|
-
|
|
14
|
-
@Injectable()
|
|
15
|
-
export class MeinstadtExporter implements Exporter {
|
|
16
|
-
constructor(
|
|
17
|
-
private carService: CarService,
|
|
18
|
-
private configService: ConfigService,
|
|
19
|
-
private rulesService: RulesService,
|
|
20
|
-
private loaderService: LoaderService,
|
|
21
|
-
private moduleRef: ModuleRef,
|
|
22
|
-
) {}
|
|
23
|
-
|
|
24
|
-
async export(): Promise<void> {
|
|
25
|
-
const [fileJson, fileGZ] = this.configService.config.outputFiles;
|
|
26
|
-
await CronicleUtils.ensureDir(this.configService.config.pathesConfig.localConvertedDirectory);
|
|
27
|
-
await CronicleUtils.emptyDir(this.configService.config.pathesConfig.localConvertedDirectory);
|
|
28
|
-
|
|
29
|
-
const meinstadtJsonBuilder = new MeinstadtJsonBuilder(fileJson);
|
|
30
|
-
await meinstadtJsonBuilder.buildStart();
|
|
31
|
-
|
|
32
|
-
const meinstadtTransformer = await this.moduleRef.create(MeinstadtTransformer);
|
|
33
|
-
|
|
34
|
-
let firstCar = true;
|
|
35
|
-
await this.loaderService.process(async (chunk: FsChunkInterface) => {
|
|
36
|
-
chunk.data = chunk.data.filter(e => this.carService.filterCar(e, this.rulesService.rules));
|
|
37
|
-
|
|
38
|
-
for (const data of chunk.data) {
|
|
39
|
-
// console.time(`Transform ${data.car._id}`);
|
|
40
|
-
const car = await meinstadtTransformer.transform(data);
|
|
41
|
-
// console.timeEnd(`Transform ${data.car._id}`);
|
|
42
|
-
await meinstadtJsonBuilder.addItem(car as MeinstadtJsonItem, firstCar);
|
|
43
|
-
this.carService.counter.countCar(data.images);
|
|
44
|
-
|
|
45
|
-
if (firstCar) {
|
|
46
|
-
firstCar = false;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
await meinstadtJsonBuilder.buildEnd();
|
|
52
|
-
await Zipper.zip({ dest: fileGZ, fileList: [fileJson] });
|
|
53
|
-
console.log(this.carService.counter.getCountedCars());
|
|
54
|
-
}
|
|
55
|
-
}
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { ModuleRef } from '@nestjs/core';
|
|
3
|
+
|
|
4
|
+
import { CronicleUtils } from '@bytebrand/cronicle-helper';
|
|
5
|
+
import { FsChunkInterface } from '@bytebrand/chunkable';
|
|
6
|
+
import { Zipper } from '@bytebrand/zipper';
|
|
7
|
+
|
|
8
|
+
import { CarService, RulesService, LoaderService, ConfigService } from '../services';
|
|
9
|
+
import { MeinstadtTransformer } from '../transformers/meinstadt.transformer';
|
|
10
|
+
import { MeinstadtJsonBuilder } from '../formats/meinstadt-json.builder';
|
|
11
|
+
import { MeinstadtJsonItem } from '../interfaces';
|
|
12
|
+
import { Exporter } from '../interfaces/exporter.interface';
|
|
13
|
+
|
|
14
|
+
@Injectable()
|
|
15
|
+
export class MeinstadtExporter implements Exporter {
|
|
16
|
+
constructor(
|
|
17
|
+
private carService: CarService,
|
|
18
|
+
private configService: ConfigService,
|
|
19
|
+
private rulesService: RulesService,
|
|
20
|
+
private loaderService: LoaderService,
|
|
21
|
+
private moduleRef: ModuleRef,
|
|
22
|
+
) {}
|
|
23
|
+
|
|
24
|
+
async export(): Promise<void> {
|
|
25
|
+
const [fileJson, fileGZ] = this.configService.config.outputFiles;
|
|
26
|
+
await CronicleUtils.ensureDir(this.configService.config.pathesConfig.localConvertedDirectory);
|
|
27
|
+
await CronicleUtils.emptyDir(this.configService.config.pathesConfig.localConvertedDirectory);
|
|
28
|
+
|
|
29
|
+
const meinstadtJsonBuilder = new MeinstadtJsonBuilder(fileJson);
|
|
30
|
+
await meinstadtJsonBuilder.buildStart();
|
|
31
|
+
|
|
32
|
+
const meinstadtTransformer = await this.moduleRef.create(MeinstadtTransformer);
|
|
33
|
+
|
|
34
|
+
let firstCar = true;
|
|
35
|
+
await this.loaderService.process(async (chunk: FsChunkInterface) => {
|
|
36
|
+
chunk.data = chunk.data.filter(e => this.carService.filterCar(e, this.rulesService.rules));
|
|
37
|
+
|
|
38
|
+
for (const data of chunk.data) {
|
|
39
|
+
// console.time(`Transform ${data.car._id}`);
|
|
40
|
+
const car = await meinstadtTransformer.transform(data);
|
|
41
|
+
// console.timeEnd(`Transform ${data.car._id}`);
|
|
42
|
+
await meinstadtJsonBuilder.addItem(car as MeinstadtJsonItem, firstCar);
|
|
43
|
+
this.carService.counter.countCar(data.images);
|
|
44
|
+
|
|
45
|
+
if (firstCar) {
|
|
46
|
+
firstCar = false;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
await meinstadtJsonBuilder.buildEnd();
|
|
52
|
+
await Zipper.zip({ dest: fileGZ, fileList: [fileJson] });
|
|
53
|
+
console.log(this.carService.counter.getCountedCars());
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
import { writeFile } from 'fs/promises';
|
|
2
|
-
import { normalize, parse } from 'path';
|
|
3
|
-
|
|
4
|
-
import { Injectable } from '@nestjs/common';
|
|
5
|
-
import { ModuleRef } from '@nestjs/core';
|
|
6
|
-
|
|
7
|
-
import { CronicleUtils } from '@bytebrand/cronicle-helper';
|
|
8
|
-
import { FsChunkInterface } from '@bytebrand/chunkable';
|
|
9
|
-
import { Zipper } from '@bytebrand/zipper';
|
|
10
|
-
|
|
11
|
-
import { CarService, RulesService, LoaderService, ConfigService, ImagesService } from '../services';
|
|
12
|
-
import { MobileTransformer } from '../transformers/mobile.transformer';
|
|
13
|
-
import { Exporter } from '../interfaces/exporter.interface';
|
|
14
|
-
import { convertToCSV } from '../utils/converter.utils';
|
|
15
|
-
import { FileType } from '../enums';
|
|
16
|
-
|
|
17
|
-
@Injectable()
|
|
18
|
-
export class MobileExporter implements Exporter {
|
|
19
|
-
constructor(
|
|
20
|
-
private carService: CarService,
|
|
21
|
-
private configService: ConfigService,
|
|
22
|
-
private rulesService: RulesService,
|
|
23
|
-
private loaderService: LoaderService,
|
|
24
|
-
private imageService: ImagesService,
|
|
25
|
-
private moduleRef: ModuleRef,
|
|
26
|
-
) { }
|
|
27
|
-
|
|
28
|
-
async export(): Promise<void> {
|
|
29
|
-
const [fileName] = this.configService.config.outputFiles;
|
|
30
|
-
await CronicleUtils.ensureDir(this.configService.config.pathesConfig.localConvertedDirectory);
|
|
31
|
-
await CronicleUtils.emptyDir(this.configService.config.pathesConfig.localConvertedDirectory);
|
|
32
|
-
|
|
33
|
-
const mobileTransformer = await this.moduleRef.create(MobileTransformer);
|
|
34
|
-
const imagesPath = [];
|
|
35
|
-
|
|
36
|
-
await this.loaderService.process(async (chunk: FsChunkInterface) => {
|
|
37
|
-
chunk.data = chunk.data.filter(e => this.carService.filterCar(e, this.rulesService.rules));
|
|
38
|
-
|
|
39
|
-
if (chunk && chunk.data) {
|
|
40
|
-
for (let i = 0; i < chunk.data.length; i += 1) {
|
|
41
|
-
const data = chunk.data[i];
|
|
42
|
-
const { car, images } = data;
|
|
43
|
-
const transformedData = await mobileTransformer.transform(car, images);
|
|
44
|
-
|
|
45
|
-
if (this.configService.config.downloadImage) {
|
|
46
|
-
const urls = await this.imageService.getImages(car, images, this.configService.config.imageType, true);
|
|
47
|
-
imagesPath.push(...await this.imageService.downloadInParallel(car.metaData.vehicleId, urls, this.configService.config));
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
await writeFile(fileName, Buffer.from(`${convertToCSV(transformedData)}\n`), { flag: 'a' });
|
|
51
|
-
|
|
52
|
-
this.carService.counter.countCar(data.images);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
const fileZIP = normalize(`${parse(fileName).dir}/${parse(fileName).name}.${FileType.ZIP}`);
|
|
58
|
-
|
|
59
|
-
if (await CronicleUtils.exists(fileName)) {
|
|
60
|
-
await Zipper.zip({ fileList: [fileName, ...imagesPath], dest: fileZIP });
|
|
61
|
-
}
|
|
62
|
-
console.log(this.carService.counter.getCountedCars());
|
|
63
|
-
}
|
|
64
|
-
}
|
|
1
|
+
import { writeFile } from 'fs/promises';
|
|
2
|
+
import { normalize, parse } from 'path';
|
|
3
|
+
|
|
4
|
+
import { Injectable } from '@nestjs/common';
|
|
5
|
+
import { ModuleRef } from '@nestjs/core';
|
|
6
|
+
|
|
7
|
+
import { CronicleUtils } from '@bytebrand/cronicle-helper';
|
|
8
|
+
import { FsChunkInterface } from '@bytebrand/chunkable';
|
|
9
|
+
import { Zipper } from '@bytebrand/zipper';
|
|
10
|
+
|
|
11
|
+
import { CarService, RulesService, LoaderService, ConfigService, ImagesService } from '../services';
|
|
12
|
+
import { MobileTransformer } from '../transformers/mobile.transformer';
|
|
13
|
+
import { Exporter } from '../interfaces/exporter.interface';
|
|
14
|
+
import { convertToCSV } from '../utils/converter.utils';
|
|
15
|
+
import { FileType } from '../enums';
|
|
16
|
+
|
|
17
|
+
@Injectable()
|
|
18
|
+
export class MobileExporter implements Exporter {
|
|
19
|
+
constructor(
|
|
20
|
+
private carService: CarService,
|
|
21
|
+
private configService: ConfigService,
|
|
22
|
+
private rulesService: RulesService,
|
|
23
|
+
private loaderService: LoaderService,
|
|
24
|
+
private imageService: ImagesService,
|
|
25
|
+
private moduleRef: ModuleRef,
|
|
26
|
+
) { }
|
|
27
|
+
|
|
28
|
+
async export(): Promise<void> {
|
|
29
|
+
const [fileName] = this.configService.config.outputFiles;
|
|
30
|
+
await CronicleUtils.ensureDir(this.configService.config.pathesConfig.localConvertedDirectory);
|
|
31
|
+
await CronicleUtils.emptyDir(this.configService.config.pathesConfig.localConvertedDirectory);
|
|
32
|
+
|
|
33
|
+
const mobileTransformer = await this.moduleRef.create(MobileTransformer);
|
|
34
|
+
const imagesPath = [];
|
|
35
|
+
|
|
36
|
+
await this.loaderService.process(async (chunk: FsChunkInterface) => {
|
|
37
|
+
chunk.data = chunk.data.filter(e => this.carService.filterCar(e, this.rulesService.rules));
|
|
38
|
+
|
|
39
|
+
if (chunk && chunk.data) {
|
|
40
|
+
for (let i = 0; i < chunk.data.length; i += 1) {
|
|
41
|
+
const data = chunk.data[i];
|
|
42
|
+
const { car, images } = data;
|
|
43
|
+
const transformedData = await mobileTransformer.transform(car, images);
|
|
44
|
+
|
|
45
|
+
if (this.configService.config.downloadImage) {
|
|
46
|
+
const urls = await this.imageService.getImages(car, images, this.configService.config.imageType, true);
|
|
47
|
+
imagesPath.push(...await this.imageService.downloadInParallel(car.metaData.vehicleId, urls, this.configService.config));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
await writeFile(fileName, Buffer.from(`${convertToCSV(transformedData)}\n`), { flag: 'a' });
|
|
51
|
+
|
|
52
|
+
this.carService.counter.countCar(data.images);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const fileZIP = normalize(`${parse(fileName).dir}/${parse(fileName).name}.${FileType.ZIP}`);
|
|
58
|
+
|
|
59
|
+
if (await CronicleUtils.exists(fileName)) {
|
|
60
|
+
await Zipper.zip({ fileList: [fileName, ...imagesPath], dest: fileZIP });
|
|
61
|
+
}
|
|
62
|
+
console.log(this.carService.counter.getCountedCars());
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { ModuleRef } from '@nestjs/core';
|
|
3
|
-
|
|
4
|
-
import { CronicleUtils, ImportOrigins } from '@bytebrand/cronicle-helper';
|
|
5
|
-
import { MappingBuilder } from '@bytebrand/import-helper';
|
|
6
|
-
import { FsChunkInterface } from '@bytebrand/chunkable';
|
|
7
|
-
|
|
8
|
-
import { CarService, ConfigService, LoaderService, RulesService } from '../services';
|
|
9
|
-
import { Exporter } from '../interfaces/exporter.interface';
|
|
10
|
-
import { ModixTransformer } from '../transformers';
|
|
11
|
-
import { ModixXmlBuilder } from '../formats';
|
|
12
|
-
|
|
13
|
-
@Injectable()
|
|
14
|
-
export class ModixExporter implements Exporter {
|
|
15
|
-
constructor(
|
|
16
|
-
private carService: CarService,
|
|
17
|
-
private configService: ConfigService,
|
|
18
|
-
private rulesService: RulesService,
|
|
19
|
-
private loaderService: LoaderService,
|
|
20
|
-
private moduleRef: ModuleRef,
|
|
21
|
-
) { }
|
|
22
|
-
async export(): Promise<void> {
|
|
23
|
-
const [fileXml] = this.configService.config.outputFiles;
|
|
24
|
-
|
|
25
|
-
await CronicleUtils.ensureDir(this.configService.config.pathesConfig.localConvertedDirectory);
|
|
26
|
-
await CronicleUtils.emptyDir(this.configService.config.pathesConfig.localConvertedDirectory);
|
|
27
|
-
|
|
28
|
-
const mappingBuilder = new MappingBuilder(this.configService.config.apikey);
|
|
29
|
-
await mappingBuilder.loadMappingRules(ImportOrigins.MODIX);
|
|
30
|
-
|
|
31
|
-
const modixXmlBuilder = new ModixXmlBuilder(fileXml);
|
|
32
|
-
await modixXmlBuilder.buildStart();
|
|
33
|
-
|
|
34
|
-
const modixTransformer = await this.moduleRef.create(ModixTransformer);
|
|
35
|
-
|
|
36
|
-
await this.loaderService.process(async (chunk: FsChunkInterface) => {
|
|
37
|
-
chunk.data = chunk.data.filter(e => this.carService.filterCar(e, this.rulesService.rules));
|
|
38
|
-
|
|
39
|
-
if (chunk && chunk.data) {
|
|
40
|
-
for (let i = 0; i < chunk.data.length; i += 1) {
|
|
41
|
-
const data = chunk.data[i];
|
|
42
|
-
|
|
43
|
-
// console.time(`Transform ${data.car._id}`);
|
|
44
|
-
const transformedCar = await modixTransformer.transform(data, mappingBuilder.getMappingRules({ reversTransforming: true }));
|
|
45
|
-
// console.timeEnd(`Transform ${data.car._id}`);
|
|
46
|
-
await modixXmlBuilder.addItem(transformedCar);
|
|
47
|
-
|
|
48
|
-
this.carService.counter.countCar(data.images);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
await modixXmlBuilder.buildEnd();
|
|
54
|
-
console.log(this.carService.counter.getCountedCars());
|
|
55
|
-
}
|
|
56
|
-
}
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { ModuleRef } from '@nestjs/core';
|
|
3
|
+
|
|
4
|
+
import { CronicleUtils, ImportOrigins } from '@bytebrand/cronicle-helper';
|
|
5
|
+
import { MappingBuilder } from '@bytebrand/import-helper';
|
|
6
|
+
import { FsChunkInterface } from '@bytebrand/chunkable';
|
|
7
|
+
|
|
8
|
+
import { CarService, ConfigService, LoaderService, RulesService } from '../services';
|
|
9
|
+
import { Exporter } from '../interfaces/exporter.interface';
|
|
10
|
+
import { ModixTransformer } from '../transformers';
|
|
11
|
+
import { ModixXmlBuilder } from '../formats';
|
|
12
|
+
|
|
13
|
+
@Injectable()
|
|
14
|
+
export class ModixExporter implements Exporter {
|
|
15
|
+
constructor(
|
|
16
|
+
private carService: CarService,
|
|
17
|
+
private configService: ConfigService,
|
|
18
|
+
private rulesService: RulesService,
|
|
19
|
+
private loaderService: LoaderService,
|
|
20
|
+
private moduleRef: ModuleRef,
|
|
21
|
+
) { }
|
|
22
|
+
async export(): Promise<void> {
|
|
23
|
+
const [fileXml] = this.configService.config.outputFiles;
|
|
24
|
+
|
|
25
|
+
await CronicleUtils.ensureDir(this.configService.config.pathesConfig.localConvertedDirectory);
|
|
26
|
+
await CronicleUtils.emptyDir(this.configService.config.pathesConfig.localConvertedDirectory);
|
|
27
|
+
|
|
28
|
+
const mappingBuilder = new MappingBuilder(this.configService.config.apikey);
|
|
29
|
+
await mappingBuilder.loadMappingRules(ImportOrigins.MODIX);
|
|
30
|
+
|
|
31
|
+
const modixXmlBuilder = new ModixXmlBuilder(fileXml);
|
|
32
|
+
await modixXmlBuilder.buildStart();
|
|
33
|
+
|
|
34
|
+
const modixTransformer = await this.moduleRef.create(ModixTransformer);
|
|
35
|
+
|
|
36
|
+
await this.loaderService.process(async (chunk: FsChunkInterface) => {
|
|
37
|
+
chunk.data = chunk.data.filter(e => this.carService.filterCar(e, this.rulesService.rules));
|
|
38
|
+
|
|
39
|
+
if (chunk && chunk.data) {
|
|
40
|
+
for (let i = 0; i < chunk.data.length; i += 1) {
|
|
41
|
+
const data = chunk.data[i];
|
|
42
|
+
|
|
43
|
+
// console.time(`Transform ${data.car._id}`);
|
|
44
|
+
const transformedCar = await modixTransformer.transform(data, mappingBuilder.getMappingRules({ reversTransforming: true }));
|
|
45
|
+
// console.timeEnd(`Transform ${data.car._id}`);
|
|
46
|
+
await modixXmlBuilder.addItem(transformedCar);
|
|
47
|
+
|
|
48
|
+
this.carService.counter.countCar(data.images);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
await modixXmlBuilder.buildEnd();
|
|
54
|
+
console.log(this.carService.counter.getCountedCars());
|
|
55
|
+
}
|
|
56
|
+
}
|