@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.
Files changed (160) hide show
  1. package/.editorconfig +8 -8
  2. package/.eslintignore +1 -1
  3. package/.eslintrc.js +24 -24
  4. package/.prettierrc.js +7 -7
  5. package/README.md +65 -65
  6. package/dist/configs/index.d.ts +1 -0
  7. package/dist/configs/index.js +1 -0
  8. package/dist/configs/index.js.map +1 -1
  9. package/dist/configs/santander.config.d.ts +5 -0
  10. package/dist/configs/santander.config.js +18 -0
  11. package/dist/configs/santander.config.js.map +1 -0
  12. package/dist/enums/export-type.enum.d.ts +1 -0
  13. package/dist/enums/export-type.enum.js +1 -0
  14. package/dist/enums/export-type.enum.js.map +1 -1
  15. package/dist/export.command.js +1 -1
  16. package/dist/export.command.js.map +1 -1
  17. package/dist/export.schema.d.ts +6 -2
  18. package/dist/export.schema.js +4 -0
  19. package/dist/export.schema.js.map +1 -1
  20. package/dist/exporters/autouncle.exporter.js +5 -1
  21. package/dist/exporters/autouncle.exporter.js.map +1 -1
  22. package/dist/exporters/fb.exporter.js +7 -1
  23. package/dist/exporters/fb.exporter.js.map +1 -1
  24. package/dist/exporters/index.d.ts +1 -0
  25. package/dist/exporters/index.js +1 -0
  26. package/dist/exporters/index.js.map +1 -1
  27. package/dist/exporters/santander.exporter.d.ts +12 -0
  28. package/dist/exporters/santander.exporter.js +63 -0
  29. package/dist/exporters/santander.exporter.js.map +1 -0
  30. package/dist/formats/auto24-xml.builder.js +2 -2
  31. package/dist/formats/google-xml.builder.js +3 -3
  32. package/dist/formats/modix-xml.builder.js +2 -2
  33. package/dist/formats/ooyyo-xml.builder.js +1 -1
  34. package/dist/formats/santander-csv.builder.d.ts +6 -0
  35. package/dist/formats/santander-csv.builder.js +17 -0
  36. package/dist/formats/santander-csv.builder.js.map +1 -0
  37. package/dist/tsconfig.build.tsbuildinfo +1 -1
  38. package/nest-cli.json +5 -5
  39. package/package.json +61 -61
  40. package/src/app.module.ts +38 -38
  41. package/src/configs/alleskralle.config.ts +15 -15
  42. package/src/configs/as24.config.ts +13 -13
  43. package/src/configs/auto24.config.ts +15 -15
  44. package/src/configs/autoboerse.config.ts +16 -16
  45. package/src/configs/autouncle.config.ts +14 -14
  46. package/src/configs/awin.config.ts +15 -15
  47. package/src/configs/by-owner.config.ts +14 -14
  48. package/src/configs/config.ts +83 -83
  49. package/src/configs/criteo.config.ts +17 -17
  50. package/src/configs/dasparking.config.ts +15 -15
  51. package/src/configs/eauto.config.ts +15 -15
  52. package/src/configs/evium.config.ts +18 -18
  53. package/src/configs/facebook-shop.config.ts +16 -16
  54. package/src/configs/fb.config.ts +16 -16
  55. package/src/configs/google.config.ts +14 -14
  56. package/src/configs/index.ts +22 -21
  57. package/src/configs/kleinanzeigeFocus.config.ts +14 -14
  58. package/src/configs/marktde.config.ts +18 -18
  59. package/src/configs/meinstadt.config.ts +15 -15
  60. package/src/configs/mitula.config.ts +14 -14
  61. package/src/configs/ooyyo.config.ts +15 -15
  62. package/src/configs/santander.config.ts +15 -0
  63. package/src/configs/trovit.config.ts +14 -14
  64. package/src/configs/yescar.config.ts +17 -17
  65. package/src/constants/autouncle.contants.ts +4 -4
  66. package/src/constants/fb.constants.ts +7 -7
  67. package/src/constants/index.ts +1 -1
  68. package/src/constants/modix/body-color-name.constant.ts +20 -20
  69. package/src/constants/modix/category.constant.ts +14 -14
  70. package/src/constants/modix/fuel.constant.ts +14 -14
  71. package/src/constants/modix/index.ts +7 -7
  72. package/src/constants/modix/manufacturers.constant.ts +7498 -7498
  73. package/src/constants/modix/transmission.constant.ts +8 -8
  74. package/src/constants/modix/usage-type.constant.ts +13 -13
  75. package/src/constants/modix/vehicle-class.constant.ts +17 -17
  76. package/src/enums/environment.enum.ts +5 -5
  77. package/src/enums/export-type.enum.ts +33 -32
  78. package/src/enums/file-types.enum.ts +8 -8
  79. package/src/enums/image-type.enum.ts +4 -4
  80. package/src/enums/index.ts +4 -4
  81. package/src/export.command.ts +37 -37
  82. package/src/export.schema.ts +134 -128
  83. package/src/exporters/as24.exporter.ts +69 -69
  84. package/src/exporters/auto24.exporter.ts +48 -48
  85. package/src/exporters/autouncle.exporter.ts +60 -58
  86. package/src/exporters/awin.exporter.ts +47 -47
  87. package/src/exporters/by-owner.exporter.ts +44 -44
  88. package/src/exporters/facebook-shop.exporter.ts +51 -51
  89. package/src/exporters/fb.exporter.ts +52 -50
  90. package/src/exporters/google.exporter.ts +45 -45
  91. package/src/exporters/index.ts +15 -14
  92. package/src/exporters/meinstadt.exporter.ts +55 -55
  93. package/src/exporters/mobile.exporter.ts +64 -64
  94. package/src/exporters/modix.exporter.ts +56 -56
  95. package/src/exporters/ooyyo.exporter.ts +48 -48
  96. package/src/exporters/rubrikk.exporter.ts +53 -53
  97. package/src/exporters/santander.exporter.ts +50 -0
  98. package/src/exporters/trovit.exporter.ts +51 -51
  99. package/src/formats/auto24-xml.builder.ts +54 -54
  100. package/src/formats/autouncle-json.builder.ts +20 -20
  101. package/src/formats/awin-csv.builder.ts +16 -16
  102. package/src/formats/facebook-shop.builder.ts +69 -69
  103. package/src/formats/fb-xml.builder.ts +71 -71
  104. package/src/formats/google-xml.builder.ts +35 -35
  105. package/src/formats/index.ts +5 -5
  106. package/src/formats/meinstadt-json.builder.ts +19 -19
  107. package/src/formats/modix-xml.builder.ts +180 -180
  108. package/src/formats/ooyyo-xml.builder.ts +48 -48
  109. package/src/formats/rubrikk-xml.builder.ts +27 -27
  110. package/src/formats/santander-csv.builder.ts +15 -0
  111. package/src/formats/trovit-xml.builder.ts +44 -44
  112. package/src/interfaces/atributes-wrap-item.intreface.ts +6 -6
  113. package/src/interfaces/dealers-mapping.interface.ts +7 -7
  114. package/src/interfaces/description.interface.ts +24 -24
  115. package/src/interfaces/export-item.interface.ts +366 -366
  116. package/src/interfaces/exporter.interface.ts +3 -3
  117. package/src/interfaces/index.ts +3 -3
  118. package/src/interfaces/input.interface.ts +6 -6
  119. package/src/interfaces/mapping-rules.interface.ts +11 -11
  120. package/src/interfaces/modix/index.ts +1 -1
  121. package/src/interfaces/modix/modix-item-list.interface.ts +5 -5
  122. package/src/interfaces/params.interface.ts +13 -13
  123. package/src/interfaces/rule-parser.interface.ts +3 -3
  124. package/src/main.ts +14 -14
  125. package/src/rules/abstract.rule.ts +37 -37
  126. package/src/rules/date.rule.ts +19 -19
  127. package/src/rules/number.rule.ts +15 -15
  128. package/src/rules/string.rule.ts +8 -8
  129. package/src/services/car.service.ts +49 -49
  130. package/src/services/config.service.ts +15 -15
  131. package/src/services/images.service.ts +207 -207
  132. package/src/services/index.ts +9 -9
  133. package/src/services/loader.service.ts +29 -29
  134. package/src/services/mapping.service.ts +91 -91
  135. package/src/services/request.service.ts +44 -44
  136. package/src/services/rules.service.ts +61 -61
  137. package/src/services/transformer.service.ts +129 -129
  138. package/src/services/user.service.ts +57 -57
  139. package/src/transformers/as24.transformer.ts +253 -253
  140. package/src/transformers/auto24.transfomer.ts +155 -155
  141. package/src/transformers/autouncle.transformer.ts +236 -236
  142. package/src/transformers/awin.transformer.ts +193 -193
  143. package/src/transformers/by-owner.transformer.ts +354 -354
  144. package/src/transformers/facebook-shop.transformer.ts +93 -93
  145. package/src/transformers/fb-description.transformer.ts +316 -316
  146. package/src/transformers/fb-equipment.transformer.ts +161 -161
  147. package/src/transformers/fb.transformer.ts +655 -655
  148. package/src/transformers/google.transformer.ts +169 -169
  149. package/src/transformers/index.ts +5 -5
  150. package/src/transformers/meinstadt.transformer.ts +92 -92
  151. package/src/transformers/mobile.transformer.ts +482 -482
  152. package/src/transformers/modix.transformer.ts +227 -227
  153. package/src/transformers/ooyyo.transformer.ts +109 -109
  154. package/src/transformers/rubrikk.transformer.ts +200 -200
  155. package/src/transformers/trovit.transformer.ts +63 -63
  156. package/src/utils/converter.utils.ts +15 -15
  157. package/src/utils/index.ts +2 -2
  158. package/src/utils/validator.utils.ts +7 -7
  159. package/tsconfig.build.json +4 -4
  160. 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
- const ownerId = get(data.car, 'metaData.ownerId', null);
37
- const owner = await this.carService.getOwner(ownerId);
38
- // console.time(`Transform ${data.car._id}`);
39
- const car = await fbTransformer.transform({ owner, ...data });
40
- // console.timeEnd(`Transform ${data.car._id}`);
41
-
42
- await fbXmlBuilder.addItem(car as FbXmlItem);
43
- this.carService.counter.countCar(data.images);
44
- }
45
- });
46
-
47
- await fbXmlBuilder.buildEnd();
48
- console.log(this.carService.counter.getCountedCars());
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
+ }
@@ -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
+ }