@bytebrand/export-cars 1.3.2 → 1.4.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/config/alleskralle.config.js +2 -3
- package/dist/config/alleskralle.config.js.map +1 -1
- package/dist/config/as24.config.js +0 -1
- package/dist/config/as24.config.js.map +1 -1
- package/dist/config/auto24.config.js +2 -3
- package/dist/config/auto24.config.js.map +1 -1
- package/dist/config/autouncle.config.js +0 -1
- package/dist/config/autouncle.config.js.map +1 -1
- package/dist/config/by-owner.config.js +0 -1
- package/dist/config/by-owner.config.js.map +1 -1
- package/dist/config/config.d.ts +5 -6
- package/dist/config/config.js +5 -9
- package/dist/config/config.js.map +1 -1
- package/dist/config/criteo.config.d.ts +5 -0
- package/dist/config/criteo.config.js +14 -0
- package/dist/config/criteo.config.js.map +1 -0
- package/dist/config/dasparking.config.js +2 -3
- package/dist/config/dasparking.config.js.map +1 -1
- package/dist/config/eauto.config.js +0 -1
- package/dist/config/eauto.config.js.map +1 -1
- package/dist/config/kleinanzeigeFocus.config.js +2 -1
- package/dist/config/kleinanzeigeFocus.config.js.map +1 -1
- package/dist/config/meinstadt.config.js +5 -1
- package/dist/config/meinstadt.config.js.map +1 -1
- package/dist/config/ooyyo.config.js +5 -1
- package/dist/config/ooyyo.config.js.map +1 -1
- package/dist/enums/export-type.enum.d.ts +2 -1
- package/dist/enums/export-type.enum.js +1 -0
- package/dist/enums/export-type.enum.js.map +1 -1
- package/dist/enums/file-types.enum.d.ts +8 -0
- package/dist/enums/file-types.enum.js +13 -0
- package/dist/enums/file-types.enum.js.map +1 -0
- package/dist/enums/index.d.ts +2 -0
- package/dist/enums/index.js +19 -0
- package/dist/enums/index.js.map +1 -0
- package/dist/export.schema.d.ts +5 -0
- package/dist/export.schema.js +22 -17
- package/dist/export.schema.js.map +1 -1
- package/dist/exporters/as24.exporter.d.ts +5 -4
- package/dist/exporters/as24.exporter.js +22 -22
- package/dist/exporters/as24.exporter.js.map +1 -1
- package/dist/exporters/auto24.exporter.d.ts +3 -4
- package/dist/exporters/auto24.exporter.js +13 -14
- package/dist/exporters/auto24.exporter.js.map +1 -1
- package/dist/exporters/autouncle.exporter.d.ts +4 -5
- package/dist/exporters/autouncle.exporter.js +16 -13
- package/dist/exporters/autouncle.exporter.js.map +1 -1
- package/dist/exporters/by-owner.exporter.d.ts +5 -3
- package/dist/exporters/by-owner.exporter.js +20 -17
- package/dist/exporters/by-owner.exporter.js.map +1 -1
- package/dist/exporters/fb.exporter.d.ts +3 -5
- package/dist/exporters/fb.exporter.js +15 -13
- package/dist/exporters/fb.exporter.js.map +1 -1
- package/dist/exporters/google.exporter.d.ts +3 -5
- package/dist/exporters/google.exporter.js +19 -21
- package/dist/exporters/google.exporter.js.map +1 -1
- package/dist/exporters/meinstadt.exporter.d.ts +1 -4
- package/dist/exporters/meinstadt.exporter.js +5 -8
- package/dist/exporters/meinstadt.exporter.js.map +1 -1
- package/dist/exporters/mobile.exporter.d.ts +1 -4
- package/dist/exporters/mobile.exporter.js +11 -12
- package/dist/exporters/mobile.exporter.js.map +1 -1
- package/dist/exporters/modix.exporter.d.ts +1 -3
- package/dist/exporters/modix.exporter.js +4 -6
- package/dist/exporters/modix.exporter.js.map +1 -1
- package/dist/exporters/ooyyo.exporter.d.ts +3 -4
- package/dist/exporters/ooyyo.exporter.js +11 -9
- package/dist/exporters/ooyyo.exporter.js.map +1 -1
- package/dist/exporters/rubrikk.exporter.d.ts +4 -5
- package/dist/exporters/rubrikk.exporter.js +13 -11
- package/dist/exporters/rubrikk.exporter.js.map +1 -1
- package/dist/formats/google-xml.builder.js +1 -1
- package/dist/services/index.d.ts +5 -0
- package/dist/services/index.js +22 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/mapping.service.js +2 -2
- package/dist/services/mapping.service.js.map +1 -1
- package/dist/services/user.service.d.ts +2 -0
- package/dist/services/user.service.js +3 -0
- package/dist/services/user.service.js.map +1 -1
- package/dist/transformers/as24.transformer.d.ts +3 -1
- package/dist/transformers/as24.transformer.js +6 -3
- package/dist/transformers/as24.transformer.js.map +1 -1
- package/dist/transformers/mobile.transformer.js +2 -3
- package/dist/transformers/mobile.transformer.js.map +1 -1
- package/dist/transformers/rubrikk.transformer.d.ts +1 -1
- package/dist/transformers/rubrikk.transformer.js +4 -4
- package/dist/transformers/rubrikk.transformer.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/config/alleskralle.config.ts +2 -3
- package/src/config/as24.config.ts +0 -1
- package/src/config/auto24.config.ts +2 -3
- package/src/config/autouncle.config.ts +0 -1
- package/src/config/by-owner.config.ts +0 -1
- package/src/config/config.ts +6 -10
- package/src/config/criteo.config.ts +11 -0
- package/src/config/dasparking.config.ts +2 -3
- package/src/config/eauto.config.ts +0 -1
- package/src/config/kleinanzeigeFocus.config.ts +2 -1
- package/src/config/meinstadt.config.ts +5 -1
- package/src/config/ooyyo.config.ts +5 -1
- package/src/enums/export-type.enum.ts +1 -0
- package/src/enums/file-types.enum.ts +8 -0
- package/src/enums/index.ts +2 -0
- package/src/export.schema.ts +6 -1
- package/src/exporters/as24.exporter.ts +23 -24
- package/src/exporters/auto24.exporter.ts +8 -10
- package/src/exporters/autouncle.exporter.ts +9 -7
- package/src/exporters/by-owner.exporter.ts +12 -15
- package/src/exporters/fb.exporter.ts +8 -7
- package/src/exporters/google.exporter.ts +12 -15
- package/src/exporters/meinstadt.exporter.ts +2 -5
- package/src/exporters/mobile.exporter.ts +8 -8
- package/src/exporters/modix.exporter.ts +1 -3
- package/src/exporters/ooyyo.exporter.ts +5 -4
- package/src/exporters/rubrikk.exporter.ts +12 -8
- package/src/formats/google-xml.builder.ts +1 -1
- package/src/services/index.ts +5 -0
- package/src/services/mapping.service.ts +2 -2
- package/src/services/user.service.ts +5 -0
- package/src/transformers/as24.transformer.ts +4 -2
- package/src/transformers/mobile.transformer.ts +2 -3
- package/src/transformers/rubrikk.transformer.ts +3 -4
- package/dist/utils/parser.utils.d.ts +0 -3
- package/dist/utils/parser.utils.js +0 -20
- package/dist/utils/parser.utils.js.map +0 -1
- package/src/utils/parser.utils.ts +0 -17
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bytebrand/export-cars",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "bytebrand",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"engines": {
|
|
66
66
|
"node": ">=14.0.0"
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "94e66fef8bd92335708c9c00a08956c13e2ec237"
|
|
69
69
|
}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { Params } from '../interfaces/params.interface';
|
|
2
|
-
import { parseDealersList } from '../utils/parser.utils';
|
|
3
2
|
import { Config } from './config';
|
|
3
|
+
import { ExportType, FileTypes } from '../enums';
|
|
4
4
|
|
|
5
5
|
export class AlleskralleConfig extends Config {
|
|
6
6
|
constructor(params: Params) {
|
|
7
7
|
super(params);
|
|
8
8
|
this.pathesConfig.localConvertedDirectory = this.environmentConfig[params.environment].localConvertedDirectory;
|
|
9
9
|
this.pathesConfig.remoteDirectory = this.environmentConfig[params.environment].remoteDirectory;
|
|
10
|
-
this.dealersList = params.dealers ? parseDealersList(params.dealers) : null;
|
|
11
10
|
this.campaign = 'alleskralle';
|
|
12
11
|
this.location = 'Deutschland';
|
|
13
|
-
this.outputFiles = [
|
|
12
|
+
this.outputFiles = [`api_export_cars_${ExportType.ALLESKRALLE}.${FileTypes.xml}`];
|
|
14
13
|
}
|
|
15
14
|
}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { Params } from '../interfaces/params.interface';
|
|
2
|
-
import { parseDealersList } from '../utils/parser.utils';
|
|
3
2
|
import { Config } from './config';
|
|
3
|
+
import { ExportType, FileTypes } from '../enums';
|
|
4
4
|
|
|
5
5
|
export class Auto24Config extends Config {
|
|
6
6
|
constructor(params: Params) {
|
|
7
7
|
super(params);
|
|
8
8
|
this.pathesConfig.localConvertedDirectory = this.environmentConfig[params.environment].localConvertedDirectory;
|
|
9
9
|
this.pathesConfig.remoteDirectory = this.environmentConfig[params.environment].remoteDirectory;
|
|
10
|
-
this.
|
|
11
|
-
this.outputFiles = ['api_export_cars_GERMAN.xml', 'autode.tar.gz'];
|
|
10
|
+
this.outputFiles = [`api_export_cars_${ExportType.AUTO24}.${FileTypes.xml}`, `autode.${FileTypes.targz}`];
|
|
12
11
|
}
|
|
13
12
|
}
|
|
@@ -6,6 +6,5 @@ export class AutouncleConfig extends Config {
|
|
|
6
6
|
super(params);
|
|
7
7
|
this.pathesConfig.localConvertedDirectory = this.environmentConfig[params.environment].localConvertedDirectory;
|
|
8
8
|
this.pathesConfig.remoteDirectory = this.environmentConfig[params.environment].remoteDirectory;
|
|
9
|
-
this.fileName = 'export_cars_autouncle.json';
|
|
10
9
|
}
|
|
11
10
|
}
|
|
@@ -6,6 +6,5 @@ export class ByOwnerConfig extends Config {
|
|
|
6
6
|
super(params);
|
|
7
7
|
this.pathesConfig.localConvertedDirectory = this.environmentConfig[params.environment].localConvertedDirectory;
|
|
8
8
|
this.pathesConfig.remoteDirectory = this.environmentConfig[params.environment].remoteDirectory;
|
|
9
|
-
this.fileName = `owner_${this.ownerId}_cars.csv`;
|
|
10
9
|
}
|
|
11
10
|
}
|
package/src/config/config.ts
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { Environment } from '../enums/environment.enum';
|
|
2
|
-
import { ExportType } from '../enums
|
|
2
|
+
import { ExportType } from '../enums';
|
|
3
3
|
import { Params } from '../interfaces/params.interface';
|
|
4
4
|
|
|
5
5
|
export class Config {
|
|
6
|
-
carDetailsUrl: string;
|
|
7
6
|
apikey: string;
|
|
8
7
|
campaign: string;
|
|
9
|
-
fileName: string;
|
|
10
8
|
userActionsUrl: string;
|
|
11
9
|
upaUrl: string;
|
|
12
10
|
imboUrl: string;
|
|
13
11
|
imageUrl: string;
|
|
12
|
+
baseImageUrl: string;
|
|
14
13
|
isNewCar: boolean;
|
|
15
14
|
isCriteo: boolean;
|
|
16
15
|
criteoId: number;
|
|
@@ -28,12 +27,9 @@ export class Config {
|
|
|
28
27
|
remoteDirectory: string;
|
|
29
28
|
baseFileName: string;
|
|
30
29
|
};
|
|
31
|
-
dealersList: string[];
|
|
32
30
|
outputFiles: string[];
|
|
33
31
|
cpc: string;
|
|
34
|
-
ownerId: string;
|
|
35
32
|
downloadImages: boolean;
|
|
36
|
-
googleSheetsApiKey: string;
|
|
37
33
|
mappingSpreadsheetId: string;
|
|
38
34
|
mappingSpreadsheetTitle: string;
|
|
39
35
|
dealersSpreadsheetId: string;
|
|
@@ -46,6 +42,7 @@ export class Config {
|
|
|
46
42
|
localConvertedDirectory: 'resources/csv_dev',
|
|
47
43
|
remoteDirectory: 'import_dev',
|
|
48
44
|
imageUrl: 'https://images.autode-dev.de/cache_test',
|
|
45
|
+
baseImageUrl: 'https://images.autode-dev.de',
|
|
49
46
|
},
|
|
50
47
|
[Environment.DEVELOP]: {
|
|
51
48
|
url: 'autode-dev.de',
|
|
@@ -53,6 +50,7 @@ export class Config {
|
|
|
53
50
|
localConvertedDirectory: 'resources/csv_dev',
|
|
54
51
|
remoteDirectory: 'import_dev',
|
|
55
52
|
imageUrl: 'https://images.autode-dev.de/cache_test',
|
|
53
|
+
baseImageUrl: 'https://images.autode-dev.de',
|
|
56
54
|
},
|
|
57
55
|
[Environment.PRODUCTION]: {
|
|
58
56
|
url: 'auto.de',
|
|
@@ -60,21 +58,19 @@ export class Config {
|
|
|
60
58
|
localConvertedDirectory: 'resources/csv_prod',
|
|
61
59
|
remoteDirectory: 'import',
|
|
62
60
|
imageUrl: 'https://images.auto.de/generated_images',
|
|
61
|
+
baseImageUrl: 'https://images.auto.de',
|
|
63
62
|
},
|
|
64
63
|
};
|
|
65
64
|
|
|
66
65
|
constructor(params: Params) {
|
|
67
|
-
this.carDetailsUrl = params.carDetailsUrl;
|
|
68
66
|
this.apikey = params.apikey;
|
|
69
67
|
this.isNewCar = params.isNewCar;
|
|
70
68
|
this.isCriteo = params.isCriteo;
|
|
71
69
|
this.exportType = params.exportType;
|
|
72
70
|
this.cpc = params.cpc;
|
|
73
|
-
this.ownerId = params.ownerId;
|
|
74
|
-
this.fileName = params.fileName || `${params.environment}_${params.exportType}`;
|
|
75
71
|
this.criteoId = this.environmentConfig[params.environment].criteoId;
|
|
76
72
|
this.url = this.environmentConfig[params.environment].url;
|
|
77
|
-
this.
|
|
73
|
+
this.baseImageUrl = this.environmentConfig[params.environment].baseImageUrl;
|
|
78
74
|
this.mappingSpreadsheetId = '147qz9sTgs1wi13ua8YKa0IgfxAn1X_qH6LkGnAnzeyY';
|
|
79
75
|
this.dealersSpreadsheetId = '1gWrcA-uRTpna1h66Mbe2Y7NA0tIhlUaQXBcS4a_UzOw';
|
|
80
76
|
this.dealersSpreadsheetTitle = 'dealers_mapping';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Params } from '../interfaces/params.interface';
|
|
2
|
+
import { Config } from './config';
|
|
3
|
+
|
|
4
|
+
export class CriteoConfig extends Config {
|
|
5
|
+
constructor(params: Params) {
|
|
6
|
+
super(params);
|
|
7
|
+
this.pathesConfig.localConvertedDirectory = this.environmentConfig[params.environment].localConvertedDirectory;
|
|
8
|
+
this.pathesConfig.remoteDirectory = this.environmentConfig[params.environment].remoteDirectory;
|
|
9
|
+
this.isCriteo = true;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { Params } from '../interfaces/params.interface';
|
|
2
|
-
import { parseDealersList } from '../utils/parser.utils';
|
|
3
2
|
import { Config } from './config';
|
|
3
|
+
import { ExportType, FileTypes } from '../enums';
|
|
4
4
|
|
|
5
5
|
export class DasparkingConfig extends Config {
|
|
6
6
|
constructor(params: Params) {
|
|
7
7
|
super(params);
|
|
8
8
|
this.pathesConfig.localConvertedDirectory = this.environmentConfig[params.environment].localConvertedDirectory;
|
|
9
9
|
this.pathesConfig.remoteDirectory = this.environmentConfig[params.environment].remoteDirectory;
|
|
10
|
-
this.dealersList = params.dealers ? parseDealersList(params.dealers) : null;
|
|
11
10
|
this.campaign = 'dasparking';
|
|
12
11
|
this.location = 'Deutschland';
|
|
13
|
-
this.outputFiles = [
|
|
12
|
+
this.outputFiles = [`api_export_cars_${ExportType.DASPARKING}.${FileTypes.xml}`];
|
|
14
13
|
}
|
|
15
14
|
}
|
|
@@ -6,7 +6,6 @@ export class EautoConfig extends Config {
|
|
|
6
6
|
super(params);
|
|
7
7
|
this.campaign = 'eauto';
|
|
8
8
|
this.pathesConfig.localConvertedDirectory = 'resources/eauto-export';
|
|
9
|
-
this.fileName = '416';
|
|
10
9
|
this.imageUrl = `https://images.${this.url}/carimage`;
|
|
11
10
|
this.mappingSpreadsheetTitle = 'mobile_yescar';
|
|
12
11
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Params } from '../interfaces/params.interface';
|
|
2
2
|
import { Config } from './config';
|
|
3
|
+
import { ExportType, FileTypes } from '../enums';
|
|
3
4
|
|
|
4
5
|
export class KleinanzeigeFocusConfig extends Config {
|
|
5
6
|
constructor(params: Params) {
|
|
@@ -7,6 +8,6 @@ export class KleinanzeigeFocusConfig extends Config {
|
|
|
7
8
|
this.pathesConfig.localConvertedDirectory = this.environmentConfig[params.environment].localConvertedDirectory;
|
|
8
9
|
this.pathesConfig.remoteDirectory = this.environmentConfig[params.environment].remoteDirectory;
|
|
9
10
|
this.imageUrl = this.environmentConfig[params.environment].imageUrl;
|
|
10
|
-
this.outputFiles = [
|
|
11
|
+
this.outputFiles = [`api_export_cars_${ExportType.KLEINANZEIGE_FOCUS}.${FileTypes.xml}`];
|
|
11
12
|
}
|
|
12
13
|
}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { Params } from '../interfaces/params.interface';
|
|
2
2
|
import { Config } from './config';
|
|
3
|
+
import { ExportType, FileTypes } from '../enums';
|
|
3
4
|
|
|
4
5
|
export class MeinstadtConfig extends Config {
|
|
5
6
|
constructor(params: Params) {
|
|
6
7
|
super(params);
|
|
7
8
|
this.pathesConfig.localConvertedDirectory = this.environmentConfig[params.environment].localConvertedDirectory;
|
|
8
9
|
this.pathesConfig.remoteDirectory = this.environmentConfig[params.environment].remoteDirectory;
|
|
9
|
-
this.outputFiles = [
|
|
10
|
+
this.outputFiles = [
|
|
11
|
+
`api_export_cars_${ExportType.MEINSTADT}.${FileTypes.json}`,
|
|
12
|
+
`api_export_cars_${ExportType.MEINSTADT}.${FileTypes.zip}`,
|
|
13
|
+
];
|
|
10
14
|
}
|
|
11
15
|
}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { Params } from '../interfaces/params.interface';
|
|
2
2
|
import { Config } from './config';
|
|
3
|
+
import { ExportType, FileTypes } from '../enums';
|
|
3
4
|
|
|
4
5
|
export class OoyyoConfig extends Config {
|
|
5
6
|
constructor(params: Params) {
|
|
6
7
|
super(params);
|
|
7
8
|
this.pathesConfig.localConvertedDirectory = this.environmentConfig[params.environment].localConvertedDirectory;
|
|
8
9
|
this.pathesConfig.remoteDirectory = this.environmentConfig[params.environment].remoteDirectory;
|
|
9
|
-
this.outputFiles = [
|
|
10
|
+
this.outputFiles = [
|
|
11
|
+
`api_export_cars_${ExportType.OOYYO}.${FileTypes.xml}`,
|
|
12
|
+
`autode-${ExportType.OOYYO}.${FileTypes.targz}`,
|
|
13
|
+
];
|
|
10
14
|
}
|
|
11
15
|
}
|
package/src/export.schema.ts
CHANGED
|
@@ -13,7 +13,7 @@ import { MeinstadtConfig } from './config/meinstadt.config';
|
|
|
13
13
|
import { OoyyoConfig } from './config/ooyyo.config';
|
|
14
14
|
import { YescarConfig } from './config/yescar.config';
|
|
15
15
|
import { KleinanzeigeFocusConfig } from './config/kleinanzeigeFocus.config';
|
|
16
|
-
import { ExportType } from './enums
|
|
16
|
+
import { ExportType } from './enums';
|
|
17
17
|
import { As24Exporter } from './exporters/as24.exporter';
|
|
18
18
|
import { Auto24Exporter } from './exporters/auto24.exporter';
|
|
19
19
|
import { AutouncleExporter } from './exporters/autouncle.exporter';
|
|
@@ -23,6 +23,7 @@ import { GoogleExporter } from './exporters/google.exporter';
|
|
|
23
23
|
import { MeinstadtExporter } from './exporters/meinstadt.exporter';
|
|
24
24
|
import { MobileExporter } from './exporters/mobile.exporter';
|
|
25
25
|
import { OoyyoExporter } from './exporters/ooyyo.exporter';
|
|
26
|
+
import { CriteoConfig } from './config/criteo.config';
|
|
26
27
|
import { ModixExporter, RubrikkExporter } from './exporters';
|
|
27
28
|
import { AutoborseConfig } from './config';
|
|
28
29
|
|
|
@@ -91,4 +92,8 @@ export const exportSchema = {
|
|
|
91
92
|
config: AutoborseConfig,
|
|
92
93
|
exporter: ModixExporter,
|
|
93
94
|
},
|
|
95
|
+
[ExportType.CRITEO]: {
|
|
96
|
+
config: CriteoConfig,
|
|
97
|
+
exporter: GoogleExporter,
|
|
98
|
+
},
|
|
94
99
|
};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { ConfigService } from '../services
|
|
1
|
+
import { ConfigService, LoaderService, UserService } from '../services';
|
|
2
2
|
import { FsChunkInterface } from '@bytebrand/chunkable';
|
|
3
3
|
import { Exporter } from '../interfaces/exporter.interface';
|
|
4
|
-
import { LoaderService } from '../services/loader.service';
|
|
5
4
|
import { CronicleUtils } from '@bytebrand/cronicle-helper';
|
|
6
5
|
import { Injectable } from '@nestjs/common';
|
|
7
6
|
import { ModuleRef } from '@nestjs/core';
|
|
8
7
|
import { As24Transformer } from '../transformers/as24.transformer';
|
|
9
|
-
import { UserService } from '../services/user.service';
|
|
10
8
|
import { get, union } from 'lodash';
|
|
11
9
|
import { convertToCSV } from '../utils/converter.utils';
|
|
12
10
|
import { writeFile } from 'fs/promises';
|
|
13
11
|
import { normalize } from 'path';
|
|
14
12
|
import { Zipper } from '@bytebrand/zipper';
|
|
13
|
+
import { FileTypes } from '../enums';
|
|
14
|
+
import { RulesService, CarService } from '../services';
|
|
15
15
|
|
|
16
16
|
@Injectable()
|
|
17
17
|
export class As24Exporter implements Exporter {
|
|
@@ -20,6 +20,8 @@ export class As24Exporter implements Exporter {
|
|
|
20
20
|
private loaderService: LoaderService,
|
|
21
21
|
private userService: UserService,
|
|
22
22
|
private moduleRef: ModuleRef,
|
|
23
|
+
private carService: CarService,
|
|
24
|
+
private readonly rulesService: RulesService,
|
|
23
25
|
) {}
|
|
24
26
|
|
|
25
27
|
async export(): Promise<any> {
|
|
@@ -29,33 +31,26 @@ export class As24Exporter implements Exporter {
|
|
|
29
31
|
const as24Transformer = await this.moduleRef.create(As24Transformer);
|
|
30
32
|
const descriptionSchemas: any = {};
|
|
31
33
|
|
|
32
|
-
for (const dealerId of this.configService.config.dealersList) {
|
|
33
|
-
descriptionSchemas[dealerId] = await this.userService.getDefaultSummaryByDealerId(dealerId);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
34
|
const processedDealers = [];
|
|
37
35
|
|
|
38
36
|
await this.loaderService.process(async (chunk: FsChunkInterface) => {
|
|
39
|
-
|
|
37
|
+
const chunkData = chunk.data.filter(car => this.carService.filterCar(car, this.rulesService.rules));
|
|
38
|
+
|
|
39
|
+
if (chunk && chunkData) {
|
|
40
40
|
for (let i = 0; i < chunk.data.length; i += 1) {
|
|
41
41
|
const data = chunk.data[i];
|
|
42
42
|
const ownerId = get(data.car, 'metaData.ownerId', null);
|
|
43
|
-
if (
|
|
44
|
-
ownerId &&
|
|
45
|
-
this.configService.config.dealersList &&
|
|
46
|
-
this.configService.config.dealersList.includes(ownerId)
|
|
47
|
-
) {
|
|
48
|
-
const transformedData = await as24Transformer.transform(data.car, descriptionSchemas);
|
|
49
|
-
const transformedDataCSV = `${convertToCSV(transformedData)}\n`;
|
|
50
43
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
44
|
+
const transformedData = await as24Transformer.transform(data.car, descriptionSchemas);
|
|
45
|
+
const transformedDataCSV = `${convertToCSV(transformedData)}\n`;
|
|
46
|
+
|
|
47
|
+
await writeFile(
|
|
48
|
+
`${this.configService.config.pathesConfig.localConvertedDirectory}/${ownerId}.${FileTypes.csv}`,
|
|
49
|
+
Buffer.from(transformedDataCSV),
|
|
50
|
+
{ flag: 'a' },
|
|
51
|
+
);
|
|
56
52
|
|
|
57
|
-
|
|
58
|
-
}
|
|
53
|
+
union([ownerId], processedDealers);
|
|
59
54
|
}
|
|
60
55
|
chunk.data = null;
|
|
61
56
|
}
|
|
@@ -64,8 +59,12 @@ export class As24Exporter implements Exporter {
|
|
|
64
59
|
for (const dealer of processedDealers) {
|
|
65
60
|
const now = new Date();
|
|
66
61
|
const d = `${now.getFullYear()}${now.getMonth() + 1}${now.getDate()}`;
|
|
67
|
-
const fileCSV = normalize(
|
|
68
|
-
|
|
62
|
+
const fileCSV = normalize(
|
|
63
|
+
`${this.configService.config.pathesConfig.localConvertedDirectory}/${dealer}.${FileTypes.csv}`,
|
|
64
|
+
);
|
|
65
|
+
const fileZIP = normalize(
|
|
66
|
+
`${this.configService.config.pathesConfig.localConvertedDirectory}/${d}_${dealer}.${FileTypes.zip}`,
|
|
67
|
+
);
|
|
69
68
|
if (await CronicleUtils.exists(fileCSV)) {
|
|
70
69
|
await Zipper.zip({ fileList: [fileCSV], dest: fileZIP });
|
|
71
70
|
}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { CarService } from '../services
|
|
3
|
-
import { ConfigService } from '../services/config.service';
|
|
2
|
+
import { CarService, RulesService, ConfigService, LoaderService } from '../services';
|
|
4
3
|
import { FsChunkInterface } from '@bytebrand/chunkable';
|
|
5
4
|
import { Exporter } from '../interfaces/exporter.interface';
|
|
6
|
-
import { LoaderService } from '../services/loader.service';
|
|
7
5
|
import { CronicleUtils } from '@bytebrand/cronicle-helper';
|
|
8
|
-
import {
|
|
6
|
+
import { toNumber } from 'lodash';
|
|
9
7
|
import { ModuleRef } from '@nestjs/core';
|
|
10
8
|
import { Auto24XmlBuilder } from '../formats/auto24-xml.builder';
|
|
11
9
|
import { Auto24Transformer } from '../transformers/auto24.transfomer';
|
|
@@ -18,6 +16,7 @@ export class Auto24Exporter implements Exporter {
|
|
|
18
16
|
private configService: ConfigService,
|
|
19
17
|
private loaderService: LoaderService,
|
|
20
18
|
private moduleRef: ModuleRef,
|
|
19
|
+
private rulesService: RulesService,
|
|
21
20
|
) {}
|
|
22
21
|
|
|
23
22
|
async export(): Promise<void> {
|
|
@@ -33,7 +32,9 @@ export class Auto24Exporter implements Exporter {
|
|
|
33
32
|
const auto24Transformer = await this.moduleRef.create(Auto24Transformer);
|
|
34
33
|
|
|
35
34
|
await this.loaderService.process(async (chunk: FsChunkInterface) => {
|
|
36
|
-
|
|
35
|
+
const chunkData = chunk.data.filter(car => this.carService.filterCar(car, this.rulesService.rules));
|
|
36
|
+
|
|
37
|
+
if (chunk && chunkData) {
|
|
37
38
|
if (toNumber(chunk.id) === 0) {
|
|
38
39
|
await xmlBuilder.buildStart(chunk.total);
|
|
39
40
|
}
|
|
@@ -41,11 +42,8 @@ export class Auto24Exporter implements Exporter {
|
|
|
41
42
|
for (let i = 0; i < chunk.data.length; i += 1) {
|
|
42
43
|
const data = chunk.data[i];
|
|
43
44
|
const { car, images } = data;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
await xmlBuilder.addItem(auto24Transformer.transform(car, images), this.configService.config.location);
|
|
47
|
-
this.carService.counter.countCar(images);
|
|
48
|
-
}
|
|
45
|
+
await xmlBuilder.addItem(auto24Transformer.transform(car, images), this.configService.config.location);
|
|
46
|
+
this.carService.counter.countCar(images);
|
|
49
47
|
}
|
|
50
48
|
chunk.data = null;
|
|
51
49
|
}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { CarService } from '../services
|
|
3
|
-
import { ConfigService } from '../services/config.service';
|
|
2
|
+
import { CarService, RulesService, ConfigService, LoaderService } from '../services';
|
|
4
3
|
import { FsChunkInterface } from '@bytebrand/chunkable';
|
|
5
4
|
import { Exporter } from '../interfaces/exporter.interface';
|
|
6
|
-
import { LoaderService } from '../services/loader.service';
|
|
7
5
|
import { CronicleUtils } from '@bytebrand/cronicle-helper';
|
|
8
6
|
import { ModuleRef } from '@nestjs/core';
|
|
9
7
|
import { AutouncleJsonBuilder } from '../formats/autouncle-json.builder';
|
|
10
8
|
import { AutouncleTransformer } from '../transformers/autouncle.transformer';
|
|
11
9
|
import { get, isNil } from 'lodash';
|
|
12
|
-
import {
|
|
10
|
+
import { ExportType, FileTypes } from '../enums';
|
|
11
|
+
import { UserService } from '../services';
|
|
13
12
|
|
|
14
13
|
@Injectable()
|
|
15
14
|
export class AutouncleExporter implements Exporter {
|
|
@@ -19,13 +18,16 @@ export class AutouncleExporter implements Exporter {
|
|
|
19
18
|
private loaderService: LoaderService,
|
|
20
19
|
private rulesService: RulesService,
|
|
21
20
|
private moduleRef: ModuleRef,
|
|
21
|
+
private readonly userService: UserService,
|
|
22
22
|
) {}
|
|
23
23
|
|
|
24
24
|
async export(): Promise<void> {
|
|
25
|
-
const
|
|
26
|
-
exists && (await CronicleUtils.unlink(this.configService.config.fileName));
|
|
25
|
+
const fileName = this.userService.getFileName(ExportType.AUTOUNCLE, FileTypes.json);
|
|
27
26
|
|
|
28
|
-
const
|
|
27
|
+
const exists = await CronicleUtils.exists(fileName);
|
|
28
|
+
exists && (await CronicleUtils.unlink(fileName));
|
|
29
|
+
|
|
30
|
+
const autouncleJsonBuilder = new AutouncleJsonBuilder(fileName);
|
|
29
31
|
const autouncleTransformer = await this.moduleRef.create(AutouncleTransformer);
|
|
30
32
|
|
|
31
33
|
await autouncleJsonBuilder.buildStart();
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { ConfigService } from '../services
|
|
1
|
+
import { ConfigService, LoaderService, CarService, RulesService, UserService } from '../services';
|
|
2
2
|
import { FsChunkInterface } from '@bytebrand/chunkable';
|
|
3
3
|
import { Exporter } from '../interfaces/exporter.interface';
|
|
4
|
-
import { LoaderService } from '../services/loader.service';
|
|
5
4
|
import { CronicleUtils } from '@bytebrand/cronicle-helper';
|
|
6
5
|
import { Injectable } from '@nestjs/common';
|
|
7
6
|
import { ModuleRef } from '@nestjs/core';
|
|
8
7
|
import { ByOwnerTransformer } from '../transformers/by-owner.transformer';
|
|
9
8
|
import { createWriteStream } from 'fs';
|
|
10
|
-
import {
|
|
11
|
-
|
|
9
|
+
import { ExportType, FileTypes } from '../enums';
|
|
10
|
+
|
|
12
11
|
const createCsvWriter = require('csv-write-stream');
|
|
13
12
|
|
|
14
13
|
@Injectable()
|
|
@@ -17,26 +16,24 @@ export class ByOwnerExporter implements Exporter {
|
|
|
17
16
|
private configService: ConfigService,
|
|
18
17
|
private loaderService: LoaderService,
|
|
19
18
|
private moduleRef: ModuleRef,
|
|
19
|
+
private userService: UserService,
|
|
20
|
+
private carService: CarService,
|
|
21
|
+
private rulesService: RulesService,
|
|
20
22
|
) {}
|
|
21
23
|
|
|
22
24
|
async export(): Promise<void> {
|
|
23
|
-
|
|
25
|
+
const fileName = this.userService.getFileName(ExportType.BY_OWNER, FileTypes.csv);
|
|
26
|
+
|
|
27
|
+
await CronicleUtils.unlinkIfExists(fileName);
|
|
24
28
|
|
|
25
29
|
const byOwnerTransformer = await this.moduleRef.create(ByOwnerTransformer);
|
|
26
30
|
const csvWriter = createCsvWriter();
|
|
27
|
-
csvWriter.pipe(createWriteStream(
|
|
31
|
+
csvWriter.pipe(createWriteStream(fileName));
|
|
28
32
|
|
|
29
33
|
let index = 0;
|
|
30
34
|
await this.loaderService.process(async (chunk: FsChunkInterface) => {
|
|
31
|
-
chunk.data
|
|
32
|
-
|
|
33
|
-
.filter((car: DataSchemes.Car) => {
|
|
34
|
-
const ownerId = get(car, 'metaData.ownerId');
|
|
35
|
-
return ownerId === this.configService.config.ownerId;
|
|
36
|
-
})
|
|
37
|
-
.map(car => byOwnerTransformer.transform(car, (index += 1)))
|
|
38
|
-
.forEach(car => csvWriter.write(car));
|
|
39
|
-
|
|
35
|
+
const chunkData = chunk.data.filter(car => this.carService.filterCar(car, this.rulesService.rules));
|
|
36
|
+
chunkData.map(({ car }) => byOwnerTransformer.transform(car, (index += 1))).forEach(car => csvWriter.write(car));
|
|
40
37
|
chunk.data = null;
|
|
41
38
|
});
|
|
42
39
|
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { CarService } from '../services
|
|
3
|
-
import { ConfigService } from '../services/config.service';
|
|
2
|
+
import { CarService, RulesService, LoaderService, ConfigService, UserService } from '../services';
|
|
4
3
|
import { FsChunkInterface } from '@bytebrand/chunkable';
|
|
5
4
|
import { Exporter } from '../interfaces/exporter.interface';
|
|
6
|
-
import { LoaderService } from '../services/loader.service';
|
|
7
5
|
import { CronicleUtils } from '@bytebrand/cronicle-helper';
|
|
8
6
|
import { get } from 'lodash';
|
|
9
7
|
import { FbXmlBuilder } from '../formats/fb-xml.builder';
|
|
10
8
|
import { ModuleRef } from '@nestjs/core';
|
|
11
9
|
import { FbTransformer } from '../transformers/fb.transformer';
|
|
12
|
-
import {
|
|
10
|
+
import { ExportType, FileTypes } from '../enums';
|
|
13
11
|
import { FbXmlItem } from '../interfaces';
|
|
14
12
|
|
|
15
13
|
@Injectable()
|
|
@@ -20,14 +18,17 @@ export class FbExporter implements Exporter {
|
|
|
20
18
|
private rulesService: RulesService,
|
|
21
19
|
private loaderService: LoaderService,
|
|
22
20
|
private moduleRef: ModuleRef,
|
|
21
|
+
private userService: UserService,
|
|
23
22
|
) {}
|
|
24
23
|
|
|
25
24
|
async export(): Promise<void> {
|
|
26
|
-
const
|
|
27
|
-
|
|
25
|
+
const fileName = this.userService.getFileName(ExportType.FB, FileTypes.xml);
|
|
26
|
+
|
|
27
|
+
const exists = await CronicleUtils.exists(fileName);
|
|
28
|
+
exists && (await CronicleUtils.unlink(fileName));
|
|
28
29
|
|
|
29
30
|
const fbTransformer = await this.moduleRef.create(FbTransformer);
|
|
30
|
-
const fbXmlBuilder = new FbXmlBuilder(
|
|
31
|
+
const fbXmlBuilder = new FbXmlBuilder(fileName);
|
|
31
32
|
await fbXmlBuilder.buildStart(this.configService.config.url);
|
|
32
33
|
|
|
33
34
|
await this.loaderService.process(async (chunk: FsChunkInterface) => {
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { CarService } from '../services
|
|
3
|
-
import { ConfigService } from '../services/config.service';
|
|
2
|
+
import { CarService, ConfigService, LoaderService, RulesService, UserService } from '../services';
|
|
4
3
|
import { FsChunkInterface } from '@bytebrand/chunkable';
|
|
5
4
|
import { Exporter } from '../interfaces/exporter.interface';
|
|
6
|
-
import { LoaderService } from '../services/loader.service';
|
|
7
5
|
import { CronicleUtils } from '@bytebrand/cronicle-helper';
|
|
8
|
-
import { get } from 'lodash';
|
|
9
6
|
import { GoogleXmlBuilder } from '../formats/google-xml.builder';
|
|
10
7
|
import { GoogleTransformer } from '../transformers/google.transformer';
|
|
11
8
|
import { ModuleRef } from '@nestjs/core';
|
|
12
|
-
import {
|
|
9
|
+
import { ExportType, FileTypes } from '../enums';
|
|
13
10
|
|
|
14
11
|
@Injectable()
|
|
15
12
|
export class GoogleExporter implements Exporter {
|
|
@@ -19,27 +16,27 @@ export class GoogleExporter implements Exporter {
|
|
|
19
16
|
private rulesService: RulesService,
|
|
20
17
|
private loaderService: LoaderService,
|
|
21
18
|
private moduleRef: ModuleRef,
|
|
19
|
+
private userService: UserService,
|
|
22
20
|
) {}
|
|
23
21
|
|
|
24
22
|
async export(): Promise<void> {
|
|
25
|
-
const
|
|
26
|
-
|
|
23
|
+
const exportType = this.configService.config.isCriteo ? ExportType.CRITEO : ExportType.GOOGLE;
|
|
24
|
+
const fileName = this.userService.getFileName(exportType, FileTypes.xml);
|
|
25
|
+
|
|
26
|
+
const exists = await CronicleUtils.exists(fileName);
|
|
27
|
+
exists && (await CronicleUtils.unlink(fileName));
|
|
27
28
|
|
|
28
29
|
const googleTransformer = await this.moduleRef.create(GoogleTransformer);
|
|
29
|
-
const googleXmlBuilder = new GoogleXmlBuilder(
|
|
30
|
+
const googleXmlBuilder = new GoogleXmlBuilder(fileName);
|
|
30
31
|
await googleXmlBuilder.buildStart(this.configService.config.url);
|
|
31
32
|
|
|
32
33
|
await this.loaderService.process(async (chunk: FsChunkInterface) => {
|
|
33
34
|
const chunkData = chunk.data.filter(car => this.carService.filterCar(car, this.rulesService.rules));
|
|
34
35
|
chunk.data = null;
|
|
35
36
|
for (const data of chunkData) {
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const car = await googleTransformer.transform({ ...data });
|
|
40
|
-
await googleXmlBuilder.addItem(car);
|
|
41
|
-
this.carService.counter.countCar(data.images);
|
|
42
|
-
}
|
|
37
|
+
const car = await googleTransformer.transform({ ...data });
|
|
38
|
+
await googleXmlBuilder.addItem(car);
|
|
39
|
+
this.carService.counter.countCar(data.images);
|
|
43
40
|
}
|
|
44
41
|
});
|
|
45
42
|
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { CarService } from '../services
|
|
2
|
-
import { ConfigService } from '../services/config.service';
|
|
1
|
+
import { CarService, RulesService, LoaderService, ConfigService } from '../services';
|
|
3
2
|
import { FsChunkInterface } from '@bytebrand/chunkable';
|
|
4
3
|
import { Exporter } from '../interfaces/exporter.interface';
|
|
5
|
-
import { LoaderService } from '../services/loader.service';
|
|
6
4
|
import { CronicleUtils } from '@bytebrand/cronicle-helper';
|
|
7
5
|
import { Zipper } from '@bytebrand/zipper';
|
|
8
6
|
import { Injectable } from '@nestjs/common';
|
|
@@ -10,8 +8,7 @@ import { ModuleRef } from '@nestjs/core';
|
|
|
10
8
|
import { MeinstadtJsonBuilder } from '../formats/meinstadt-json.builder';
|
|
11
9
|
import { get, isNil } from 'lodash';
|
|
12
10
|
import { MeinstadtTransformer } from '../transformers/meinstadt.transformer';
|
|
13
|
-
import {
|
|
14
|
-
import { MeinstadtJsonItem } from '../interfaces';
|
|
11
|
+
import { MeinstadtJsonItem } from '../interfaces/export-item.interface';
|
|
15
12
|
|
|
16
13
|
@Injectable()
|
|
17
14
|
export class MeinstadtExporter implements Exporter {
|