@bytebrand/export-cars 1.0.6 → 1.0.9
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/export.command.d.ts +0 -1
- package/dist/export.command.js +4 -7
- package/dist/export.command.js.map +1 -1
- package/dist/main.js +8 -2
- package/dist/main.js.map +1 -1
- package/dist/services/loader.service.d.ts +0 -1
- package/dist/services/loader.service.js +4 -5
- package/dist/services/loader.service.js.map +1 -1
- package/dist/services/rules.service.d.ts +0 -1
- package/dist/services/rules.service.js +4 -5
- package/dist/services/rules.service.js.map +1 -1
- package/dist/transformers/as24.transformer.d.ts +0 -1
- package/dist/transformers/as24.transformer.js +4 -5
- package/dist/transformers/as24.transformer.js.map +1 -1
- package/dist/transformers/mobile.transformer.d.ts +0 -1
- package/dist/transformers/mobile.transformer.js +6 -7
- package/dist/transformers/mobile.transformer.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +5 -3
- package/src/export.command.ts +2 -6
- package/src/main.ts +7 -2
- package/src/services/loader.service.ts +3 -4
- package/src/services/rules.service.ts +3 -3
- package/src/transformers/as24.transformer.ts +3 -3
- package/src/transformers/mobile.transformer.ts +5 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bytebrand/export-cars",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "bytebrand",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -34,10 +34,12 @@
|
|
|
34
34
|
"lodash": "^4.17.21",
|
|
35
35
|
"moment": "^2.29.4",
|
|
36
36
|
"nest-commander": "^3.1.0",
|
|
37
|
+
"nest-winston": "^1.8.0",
|
|
37
38
|
"reflect-metadata": "^0.1.13",
|
|
38
39
|
"rimraf": "^3.0.2",
|
|
39
40
|
"rxjs": "^7.2.0",
|
|
40
|
-
"vin-generator": "^1.0.1"
|
|
41
|
+
"vin-generator": "^1.0.1",
|
|
42
|
+
"winston": "^3.8.2"
|
|
41
43
|
},
|
|
42
44
|
"devDependencies": {
|
|
43
45
|
"@nestjs/cli": "^9.0.0",
|
|
@@ -62,5 +64,5 @@
|
|
|
62
64
|
"engines": {
|
|
63
65
|
"node": ">=14.0.0"
|
|
64
66
|
},
|
|
65
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "8f6de1762a4b742afd2e9020cf9a27d4fe0d57e3"
|
|
66
68
|
}
|
package/src/export.command.ts
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import { Command, CommandRunner, InquirerService } from 'nest-commander';
|
|
2
2
|
import { ConfigService } from './services/config.service';
|
|
3
3
|
import { Input } from './interfaces/input.interface';
|
|
4
|
-
import { Logger } from '@nestjs/common';
|
|
5
4
|
import { exportSchema } from './export.schema';
|
|
6
5
|
import { ModuleRef } from '@nestjs/core';
|
|
7
6
|
import { Exporter } from './interfaces/exporter.interface';
|
|
7
|
+
import { LoggerService } from '@bytebrand/cronicle-helper';
|
|
8
8
|
|
|
9
9
|
@Command({
|
|
10
10
|
name: 'export',
|
|
11
11
|
options: { isDefault: true },
|
|
12
12
|
})
|
|
13
13
|
export class ExportRunner extends CommandRunner {
|
|
14
|
-
private readonly logger = new Logger(ExportRunner.name);
|
|
15
|
-
|
|
16
14
|
constructor(
|
|
17
15
|
private readonly inquirer: InquirerService,
|
|
18
16
|
private configService: ConfigService,
|
|
@@ -24,12 +22,10 @@ export class ExportRunner extends CommandRunner {
|
|
|
24
22
|
async run(): Promise<void> {
|
|
25
23
|
const input = (await this.inquirer.ask<{ input: Input }>('input-questions', undefined)).input;
|
|
26
24
|
|
|
27
|
-
|
|
25
|
+
LoggerService.log(`Running job: ${input.id} - ${JSON.stringify(input)}\n`);
|
|
28
26
|
|
|
29
27
|
this.configService.config = new exportSchema[input.params.exportType].config(input.params);
|
|
30
28
|
const exporter = await this.moduleRef.create<Exporter>(exportSchema[input.params.exportType].exporter);
|
|
31
29
|
await exporter.export();
|
|
32
|
-
|
|
33
|
-
this.logger.log({ complete: 1, code: 0 });
|
|
34
30
|
}
|
|
35
31
|
}
|
package/src/main.ts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LoggerService } from '@bytebrand/cronicle-helper';
|
|
2
2
|
import { CommandFactory } from 'nest-commander';
|
|
3
3
|
import { AppModule } from './app.module';
|
|
4
4
|
|
|
5
5
|
async function bootstrap() {
|
|
6
|
-
|
|
6
|
+
try {
|
|
7
|
+
await CommandFactory.run(AppModule, console);
|
|
8
|
+
LoggerService.complete();
|
|
9
|
+
} catch (e) {
|
|
10
|
+
LoggerService.exitError(e.message || e);
|
|
11
|
+
}
|
|
7
12
|
}
|
|
8
13
|
|
|
9
14
|
bootstrap();
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { Injectable
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
2
|
import { AbstractChunkable, FsChunkInterface, Loaders } from '@bytebrand/chunkable';
|
|
3
3
|
import { ConfigService } from './config.service';
|
|
4
4
|
import { toNumber } from 'lodash';
|
|
5
|
+
import { LoggerService } from '@bytebrand/cronicle-helper';
|
|
5
6
|
|
|
6
7
|
@Injectable()
|
|
7
8
|
export class LoaderService {
|
|
8
|
-
private readonly logger = new Logger(LoaderService.name);
|
|
9
|
-
|
|
10
9
|
constructor(private configService: ConfigService) {}
|
|
11
10
|
|
|
12
11
|
private loader: AbstractChunkable;
|
|
@@ -20,7 +19,7 @@ export class LoaderService {
|
|
|
20
19
|
await fn(chunk);
|
|
21
20
|
|
|
22
21
|
const progress = (toNumber(chunk.id) + 1) / chunk.total;
|
|
23
|
-
|
|
22
|
+
LoggerService.progress(progress < 1 ? progress : 1);
|
|
24
23
|
});
|
|
25
24
|
|
|
26
25
|
this.loader.onError(reject);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LoggerService } from '@bytebrand/cronicle-helper';
|
|
2
|
+
import { Injectable } from '@nestjs/common';
|
|
2
3
|
import { concat, toSafeInteger, toString } from 'lodash';
|
|
3
4
|
import { DateRule } from '../rules/date.rule';
|
|
4
5
|
import { NumberRule } from '../rules/number.rule';
|
|
@@ -7,7 +8,6 @@ import { ConfigService } from './config.service';
|
|
|
7
8
|
|
|
8
9
|
@Injectable()
|
|
9
10
|
export class RulesService {
|
|
10
|
-
private readonly logger = new Logger(RulesService.name);
|
|
11
11
|
constructor(private configService: ConfigService) {}
|
|
12
12
|
|
|
13
13
|
private _rules: Array<StringRule | NumberRule | DateRule>;
|
|
@@ -42,7 +42,7 @@ export class RulesService {
|
|
|
42
42
|
});
|
|
43
43
|
return rulesArr;
|
|
44
44
|
} catch (error) {
|
|
45
|
-
|
|
45
|
+
LoggerService.error(error);
|
|
46
46
|
return rulesArr;
|
|
47
47
|
}
|
|
48
48
|
}
|
|
@@ -3,11 +3,11 @@ import { DataSchemes } from '@bytebrand/car-schema';
|
|
|
3
3
|
import { CarDescriptionFactory, DescriptionTypeEnum } from '@bytebrand/car-description';
|
|
4
4
|
import { MappingService } from '../services/mapping.service';
|
|
5
5
|
import { MappingRules } from '../interfaces/mapping-rules.interface';
|
|
6
|
-
import { Injectable
|
|
6
|
+
import { Injectable } from '@nestjs/common';
|
|
7
|
+
import { LoggerService } from '@bytebrand/cronicle-helper';
|
|
7
8
|
|
|
8
9
|
@Injectable()
|
|
9
10
|
export class As24Transformer {
|
|
10
|
-
private readonly logger = new Logger(As24Transformer.name);
|
|
11
11
|
private currentCar: DataSchemes.Car;
|
|
12
12
|
private descriptionSchemas: unknown;
|
|
13
13
|
|
|
@@ -97,7 +97,7 @@ export class As24Transformer {
|
|
|
97
97
|
return this.selectorToCategoryOrClass_selector(fieldValue, rule);
|
|
98
98
|
}
|
|
99
99
|
default:
|
|
100
|
-
|
|
100
|
+
LoggerService.log(`missing transform: ${transformProcedureName}`);
|
|
101
101
|
break;
|
|
102
102
|
}
|
|
103
103
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Injectable
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
2
|
import { DataSchemes } from '@bytebrand/car-schema';
|
|
3
3
|
import { get, isEmpty, isNil, set, toString, upperFirst } from 'lodash';
|
|
4
4
|
import { MappingService } from '../services/mapping.service';
|
|
@@ -7,12 +7,12 @@ import { UserService } from '../services/user.service';
|
|
|
7
7
|
import { CarDescriptionFactory, DescriptionTypeEnum } from '@bytebrand/car-description';
|
|
8
8
|
import { ConfigService } from '../services/config.service';
|
|
9
9
|
import { isNotEmptyArray } from '../utils/validator.utils';
|
|
10
|
+
import { LoggerService } from '@bytebrand/cronicle-helper';
|
|
10
11
|
|
|
11
12
|
const vinGenerator = require('vin-generator');
|
|
12
13
|
|
|
13
14
|
@Injectable()
|
|
14
15
|
export class MobileTransformer {
|
|
15
|
-
private readonly logger = new Logger(MobileTransformer.name);
|
|
16
16
|
private currentCar: DataSchemes.Car;
|
|
17
17
|
|
|
18
18
|
constructor(
|
|
@@ -107,7 +107,7 @@ export class MobileTransformer {
|
|
|
107
107
|
return this.selectorToCategoryOrClass_selector(fieldValue);
|
|
108
108
|
}
|
|
109
109
|
default:
|
|
110
|
-
|
|
110
|
+
LoggerService.log(`missing transform: ${transformProcedureName}`);
|
|
111
111
|
break;
|
|
112
112
|
}
|
|
113
113
|
}
|
|
@@ -341,7 +341,7 @@ export class MobileTransformer {
|
|
|
341
341
|
try {
|
|
342
342
|
res = this.getImagesField(car._id, get(car, 'metaData.mainImageId', null), images);
|
|
343
343
|
} catch (e) {
|
|
344
|
-
|
|
344
|
+
LoggerService.error(e);
|
|
345
345
|
throw e;
|
|
346
346
|
}
|
|
347
347
|
let imagesAsALine;
|
|
@@ -438,7 +438,7 @@ export class MobileTransformer {
|
|
|
438
438
|
if (found) {
|
|
439
439
|
return `Car.${found}`;
|
|
440
440
|
} else {
|
|
441
|
-
|
|
441
|
+
LoggerService.log(`Missing mapping for: ${fieldValue}`);
|
|
442
442
|
return 'Car.OtherCar';
|
|
443
443
|
}
|
|
444
444
|
}
|