@bytebrand/export-cars 1.3.1 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +1 -6
- package/dist/config/config.js +0 -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/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/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/ooyyo.transformer.js +1 -1
- package/dist/transformers/ooyyo.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 +1 -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/ooyyo.exporter.ts +5 -4
- package/src/exporters/rubrikk.exporter.ts +12 -8
- 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/ooyyo.transformer.ts +1 -1
- 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
|
@@ -1,11 +1,9 @@
|
|
|
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 { writeFile } from 'fs/promises';
|
|
5
4
|
import { MobileTransformer } from '../transformers/mobile.transformer';
|
|
6
5
|
import { convertToCSV } from '../utils/converter.utils';
|
|
7
6
|
import { Exporter } from '../interfaces/exporter.interface';
|
|
8
|
-
import { LoaderService } from '../services/loader.service';
|
|
9
7
|
import { CronicleUtils } from '@bytebrand/cronicle-helper';
|
|
10
8
|
import { Zipper } from '@bytebrand/zipper';
|
|
11
9
|
import { normalize, join, extname } from 'path';
|
|
@@ -14,7 +12,7 @@ import { ModuleRef } from '@nestjs/core';
|
|
|
14
12
|
import { HttpService } from '@nestjs/axios';
|
|
15
13
|
import { lastValueFrom } from 'rxjs';
|
|
16
14
|
import { get } from 'lodash';
|
|
17
|
-
import {
|
|
15
|
+
import { FileTypes } from '../enums';
|
|
18
16
|
|
|
19
17
|
@Injectable()
|
|
20
18
|
export class MobileExporter implements Exporter {
|
|
@@ -28,6 +26,8 @@ export class MobileExporter implements Exporter {
|
|
|
28
26
|
) {}
|
|
29
27
|
|
|
30
28
|
async export(): Promise<void> {
|
|
29
|
+
const fileName = '416';
|
|
30
|
+
|
|
31
31
|
await CronicleUtils.ensureDir(this.configService.config.pathesConfig.localConvertedDirectory);
|
|
32
32
|
await CronicleUtils.emptyDir(this.configService.config.pathesConfig.localConvertedDirectory);
|
|
33
33
|
if (this.configService.config.downloadImages) {
|
|
@@ -56,7 +56,7 @@ export class MobileExporter implements Exporter {
|
|
|
56
56
|
const transformedDataCSV = `${convertToCSV(transformedData)}\n`;
|
|
57
57
|
|
|
58
58
|
await writeFile(
|
|
59
|
-
`${this.configService.config.pathesConfig.localConvertedDirectory}/${
|
|
59
|
+
`${this.configService.config.pathesConfig.localConvertedDirectory}/${fileName}.${FileTypes.csv}`,
|
|
60
60
|
Buffer.from(transformedDataCSV),
|
|
61
61
|
{ flag: 'a' },
|
|
62
62
|
);
|
|
@@ -67,10 +67,10 @@ export class MobileExporter implements Exporter {
|
|
|
67
67
|
});
|
|
68
68
|
|
|
69
69
|
const fileZIP = normalize(
|
|
70
|
-
`${this.configService.config.pathesConfig.localConvertedDirectory}/${
|
|
70
|
+
`${this.configService.config.pathesConfig.localConvertedDirectory}/${fileName}.${FileTypes.zip}`,
|
|
71
71
|
);
|
|
72
72
|
const fileCSV = normalize(
|
|
73
|
-
`${this.configService.config.pathesConfig.localConvertedDirectory}/${
|
|
73
|
+
`${this.configService.config.pathesConfig.localConvertedDirectory}/${fileName}.${FileTypes.csv}`,
|
|
74
74
|
);
|
|
75
75
|
const fileList = [fileCSV];
|
|
76
76
|
if (this.configService.config.downloadImages) {
|
|
@@ -94,7 +94,7 @@ export class MobileExporter implements Exporter {
|
|
|
94
94
|
const imageFile = join(
|
|
95
95
|
this.configService.config.pathesConfig.localConvertedDirectory,
|
|
96
96
|
'images',
|
|
97
|
-
`${vehicleId}_${index + 1}${extname(imageUrl) ||
|
|
97
|
+
`${vehicleId}_${index + 1}${extname(imageUrl) || FileTypes.jpg}`,
|
|
98
98
|
);
|
|
99
99
|
|
|
100
100
|
return writeFile(imageFile, response.data, { flag: 'w' });
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { CarService } from '../services
|
|
3
|
-
import { ConfigService } from '../services/config.service';
|
|
2
|
+
import { CarService, LoaderService, ConfigService, RulesService } 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 { Zipper } from '@bytebrand/zipper';
|
|
@@ -17,6 +15,7 @@ export class OoyyoExporter implements Exporter {
|
|
|
17
15
|
private configService: ConfigService,
|
|
18
16
|
private loaderService: LoaderService,
|
|
19
17
|
private moduleRef: ModuleRef,
|
|
18
|
+
private rulesService: RulesService,
|
|
20
19
|
) {}
|
|
21
20
|
|
|
22
21
|
async export(): Promise<void> {
|
|
@@ -32,7 +31,9 @@ export class OoyyoExporter implements Exporter {
|
|
|
32
31
|
await ooyyoXmlBuilder.buildStart();
|
|
33
32
|
|
|
34
33
|
await this.loaderService.process(async (chunk: FsChunkInterface) => {
|
|
35
|
-
|
|
34
|
+
const chunkData = chunk.data.filter(car => this.carService.filterCar(car, this.rulesService.rules));
|
|
35
|
+
|
|
36
|
+
if (chunk && chunkData) {
|
|
36
37
|
for (let i = 0; i < chunk.data.length; i += 1) {
|
|
37
38
|
const data = chunk.data[i];
|
|
38
39
|
const { car, images } = data;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { Exporter } from '../interfaces/exporter.interface';
|
|
3
|
-
import { CarService } from '../services/car.service';
|
|
4
|
-
import { ConfigService } from '../services/config.service';
|
|
5
|
-
import { LoaderService } from '../services/loader.service';
|
|
6
2
|
import { ModuleRef } from '@nestjs/core';
|
|
7
|
-
|
|
3
|
+
|
|
4
|
+
import { FsChunkInterface } from '@bytebrand/chunkable';
|
|
8
5
|
import { Zipper } from '@bytebrand/zipper';
|
|
9
|
-
|
|
6
|
+
|
|
7
|
+
import { CarService, ConfigService, LoaderService, RulesService } from '../services';
|
|
8
|
+
import { Exporter } from '../interfaces/exporter.interface';
|
|
9
|
+
import { CronicleUtils } from '@bytebrand/cronicle-helper';
|
|
10
10
|
import { RubrikkTransformer } from '../transformers';
|
|
11
|
-
import {
|
|
11
|
+
import { RubrikkXmlBuilder } from '../formats';
|
|
12
12
|
|
|
13
13
|
@Injectable()
|
|
14
14
|
export class RubrikkExporter implements Exporter {
|
|
@@ -17,7 +17,9 @@ export class RubrikkExporter implements Exporter {
|
|
|
17
17
|
private configService: ConfigService,
|
|
18
18
|
private loaderService: LoaderService,
|
|
19
19
|
private moduleRef: ModuleRef,
|
|
20
|
+
private rulesService: RulesService,
|
|
20
21
|
) {}
|
|
22
|
+
|
|
21
23
|
async export(): Promise<void> {
|
|
22
24
|
for (const file of this.configService.config.outputFiles) {
|
|
23
25
|
const exists = await CronicleUtils.exists(file);
|
|
@@ -31,7 +33,9 @@ export class RubrikkExporter implements Exporter {
|
|
|
31
33
|
|
|
32
34
|
await rubrikkXmlBuilder.buildStart();
|
|
33
35
|
await this.loaderService.process(async (chunk: FsChunkInterface) => {
|
|
34
|
-
|
|
36
|
+
const chunkData = chunk.data.filter(car => this.carService.filterCar(car, this.rulesService.rules));
|
|
37
|
+
|
|
38
|
+
if (chunk && chunkData) {
|
|
35
39
|
for (let i = 0; i < chunk.data.length; i += 1) {
|
|
36
40
|
const data = chunk.data[i];
|
|
37
41
|
const { car, images } = data;
|
|
@@ -13,7 +13,7 @@ export class MappingService {
|
|
|
13
13
|
async getRules(): Promise<MappingRules[]> {
|
|
14
14
|
if (!this.rules) {
|
|
15
15
|
const spreadsheet = new GoogleSpreadsheet(this.configService.config.mappingSpreadsheetId);
|
|
16
|
-
spreadsheet.useApiKey(this.configService.config.
|
|
16
|
+
spreadsheet.useApiKey(this.configService.config.apikey);
|
|
17
17
|
await spreadsheet.loadInfo();
|
|
18
18
|
const rows = await spreadsheet.sheetsByTitle[this.configService.config.mappingSpreadsheetTitle].getRows();
|
|
19
19
|
const mappingRules = this.rowsToRules(rows) as MappingRules[];
|
|
@@ -33,7 +33,7 @@ export class MappingService {
|
|
|
33
33
|
async getDealersMapping(): Promise<DealersMapping[]> {
|
|
34
34
|
if (!this.dealers) {
|
|
35
35
|
const spreadsheet = new GoogleSpreadsheet(this.configService.config.dealersSpreadsheetId);
|
|
36
|
-
spreadsheet.useApiKey(this.configService.config.
|
|
36
|
+
spreadsheet.useApiKey(this.configService.config.apikey);
|
|
37
37
|
await spreadsheet.loadInfo();
|
|
38
38
|
const rows = await spreadsheet.sheetsByTitle[this.configService.config.dealersSpreadsheetTitle].getRows();
|
|
39
39
|
this.dealers = this.rowsToRules(rows) as DealersMapping[];
|
|
@@ -3,6 +3,7 @@ import { RequestService } from './request.service';
|
|
|
3
3
|
import { Cache } from 'cache-manager';
|
|
4
4
|
import { get } from 'lodash';
|
|
5
5
|
import { MarketingImageConfigInterface, MarketingImageConfigsInterface } from '@bytebrand/autode-request';
|
|
6
|
+
import { ExportType, FileTypes } from '../enums';
|
|
6
7
|
|
|
7
8
|
@Injectable()
|
|
8
9
|
export class UserService {
|
|
@@ -49,4 +50,8 @@ export class UserService {
|
|
|
49
50
|
|
|
50
51
|
return result;
|
|
51
52
|
}
|
|
53
|
+
|
|
54
|
+
getFileName(exportType: ExportType, fileType: FileTypes): string {
|
|
55
|
+
return `api_export_cars_${exportType}.${fileType}`;
|
|
56
|
+
}
|
|
52
57
|
}
|
|
@@ -5,13 +5,14 @@ import { MappingService } from '../services/mapping.service';
|
|
|
5
5
|
import { MappingRules } from '../interfaces/mapping-rules.interface';
|
|
6
6
|
import { Injectable } from '@nestjs/common';
|
|
7
7
|
import { LoggerService } from '@bytebrand/cronicle-helper';
|
|
8
|
+
import { UserService } from '../services';
|
|
8
9
|
|
|
9
10
|
@Injectable()
|
|
10
11
|
export class As24Transformer {
|
|
11
12
|
private currentCar: DataSchemes.Car;
|
|
12
13
|
private descriptionSchemas: unknown;
|
|
13
14
|
|
|
14
|
-
constructor(private mappingService: MappingService) {}
|
|
15
|
+
constructor(private mappingService: MappingService, private readonly userService: UserService) {}
|
|
15
16
|
|
|
16
17
|
async transform(carData: DataSchemes.Car, descriptionSchemas: unknown): Promise<unknown> {
|
|
17
18
|
this.currentCar = carData;
|
|
@@ -141,7 +142,8 @@ export class As24Transformer {
|
|
|
141
142
|
|
|
142
143
|
private async offerStringToString(): Promise<string> {
|
|
143
144
|
const dealerID = get(this.currentCar, 'metaData.ownerId');
|
|
144
|
-
|
|
145
|
+
|
|
146
|
+
const descriptionSchema = await this.userService.getDefaultSummaryByDealerId(dealerID);
|
|
145
147
|
const descriptionBuilder = CarDescriptionFactory.create(DescriptionTypeEnum.Mobile, this.currentCar);
|
|
146
148
|
return descriptionBuilder.transform(descriptionSchema);
|
|
147
149
|
}
|
|
@@ -344,7 +344,7 @@ export class MobileTransformer {
|
|
|
344
344
|
}
|
|
345
345
|
|
|
346
346
|
private getAutodeUrl(car: DataSchemes.Car): string {
|
|
347
|
-
return `${this.configService.config.
|
|
347
|
+
return `${this.configService.config.url}${car._id}?source=classifieds&medium=listing&campaign=${this.configService.config.campaign}`;
|
|
348
348
|
}
|
|
349
349
|
|
|
350
350
|
private getImages(car: DataSchemes.Car, images: unknown[]): string | null {
|
|
@@ -483,10 +483,9 @@ export class MobileTransformer {
|
|
|
483
483
|
{ url: 'https://images.auto.de/carimage/noimage/pFyfBsqBHEso/large-cached.jpeg' },
|
|
484
484
|
];
|
|
485
485
|
if (isNotEmptyArray(images)) {
|
|
486
|
-
|
|
486
|
+
return images.sort(this.setMainImageFirst(mainImageId)).map((image: any) => {
|
|
487
487
|
return { url: this.buildLargeImageUrl(carId, image.imageIdentifier) };
|
|
488
488
|
});
|
|
489
|
-
return imageList;
|
|
490
489
|
}
|
|
491
490
|
return defImages;
|
|
492
491
|
}
|
|
@@ -30,7 +30,7 @@ export class OoyyoTransformer {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
return {
|
|
33
|
-
url: `https://www.${this.configService.config.url}/search/vehicle/${autodeid}`,
|
|
33
|
+
url: `https://www.${this.configService.config.url}/search/vehicle/${autodeid}?source=classifieds&medium=listing&campaign=ooyyo`,
|
|
34
34
|
title: this.getTitle(car),
|
|
35
35
|
content: trim(toString(get(car, 'offer.offerDescription', ''))),
|
|
36
36
|
price: toString(get(car, 'price.currentSalesPrice', '')),
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseDealersList = exports.parseFields = void 0;
|
|
4
|
-
const lodash_1 = require("lodash");
|
|
5
|
-
function parseFields(values, fc) {
|
|
6
|
-
const fieldsArr = values.split(',');
|
|
7
|
-
return fieldsArr.map((e) => fc(e));
|
|
8
|
-
}
|
|
9
|
-
exports.parseFields = parseFields;
|
|
10
|
-
function parseDealersList(dealers) {
|
|
11
|
-
if (dealers) {
|
|
12
|
-
if ((0, lodash_1.indexOf)(dealers, ',') !== -1) {
|
|
13
|
-
return dealers.split(',').map((dealerId) => dealerId.trim());
|
|
14
|
-
}
|
|
15
|
-
return [dealers];
|
|
16
|
-
}
|
|
17
|
-
return [];
|
|
18
|
-
}
|
|
19
|
-
exports.parseDealersList = parseDealersList;
|
|
20
|
-
//# sourceMappingURL=parser.utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parser.utils.js","sourceRoot":"","sources":["../../src/utils/parser.utils.ts"],"names":[],"mappings":";;;AAAA,mCAAiC;AAGjC,SAAgB,WAAW,CAAI,MAAc,EAAE,EAAiB;IAC9D,MAAM,SAAS,GAAa,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC9C,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,CAAS,EAAK,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AAChD,CAAC;AAHD,kCAGC;AAED,SAAgB,gBAAgB,CAAC,OAAe;IAC9C,IAAI,OAAO,EAAE;QACX,IAAI,IAAA,gBAAO,EAAC,OAAO,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE;YAChC,OAAO,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,QAAgB,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;SACtE;QACD,OAAO,CAAC,OAAO,CAAC,CAAC;KAClB;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AARD,4CAQC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { indexOf } from 'lodash';
|
|
2
|
-
import { RuleParser } from '../interfaces/rule-parser.interface';
|
|
3
|
-
|
|
4
|
-
export function parseFields<T>(values: string, fc: RuleParser<T>): T[] {
|
|
5
|
-
const fieldsArr: string[] = values.split(',');
|
|
6
|
-
return fieldsArr.map((e: string): T => fc(e));
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function parseDealersList(dealers: string): string[] {
|
|
10
|
-
if (dealers) {
|
|
11
|
-
if (indexOf(dealers, ',') !== -1) {
|
|
12
|
-
return dealers.split(',').map((dealerId: string) => dealerId.trim());
|
|
13
|
-
}
|
|
14
|
-
return [dealers];
|
|
15
|
-
}
|
|
16
|
-
return [];
|
|
17
|
-
}
|