@rafikidota/cuba-ofertas-scraping 0.34.0 → 0.35.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/modules/index.d.ts +7 -0
- package/dist/modules/index.js +7 -0
- package/dist/modules/index.js.map +1 -1
- package/dist/modules/processor/processor.module.js +5 -3
- package/dist/modules/processor/processor.module.js.map +1 -1
- package/dist/modules/rabbitmq/rabbitmq.module.d.ts +3 -1
- package/dist/modules/rabbitmq/rabbitmq.module.js +21 -20
- package/dist/modules/rabbitmq/rabbitmq.module.js.map +1 -1
- package/dist/modules/rabbitmq/types/queue.config.d.ts +4 -0
- package/dist/modules/rabbitmq/types/queue.config.js +3 -0
- package/dist/modules/rabbitmq/types/queue.config.js.map +1 -0
- package/dist/modules/repository/config/database.config.d.ts +4 -0
- package/dist/modules/repository/config/database.config.js +13 -0
- package/dist/modules/repository/config/database.config.js.map +1 -0
- package/dist/modules/repository/entities/product.entity.d.ts +27 -0
- package/dist/modules/repository/entities/product.entity.js +120 -0
- package/dist/modules/repository/entities/product.entity.js.map +1 -0
- package/dist/modules/repository/repository.module.d.ts +3 -0
- package/dist/modules/repository/repository.module.js +34 -13
- package/dist/modules/repository/repository.module.js.map +1 -1
- package/dist/modules/repository/repository.service.d.ts +3 -3
- package/dist/modules/repository/repository.service.js +11 -14
- package/dist/modules/repository/repository.service.js.map +1 -1
- package/dist/modules/repository/services/product.repository.service.d.ts +8 -5
- package/dist/modules/repository/services/product.repository.service.js +37 -17
- package/dist/modules/repository/services/product.repository.service.js.map +1 -1
- package/package.json +5 -1
package/dist/modules/index.d.ts
CHANGED
|
@@ -24,10 +24,17 @@ export * from './publisher/publisher.module';
|
|
|
24
24
|
export * from './publisher/publisher.service';
|
|
25
25
|
export * from './rabbitmq/env/rabbitmq.env.config';
|
|
26
26
|
export * from './rabbitmq/env/rabbitmq.env.validation';
|
|
27
|
+
export * from './rabbitmq/types/queue.config';
|
|
27
28
|
export * from './rabbitmq/rabbitmq.module';
|
|
28
29
|
export * from './rabbitmq/rabbitmq.service';
|
|
29
30
|
export * from './repository/repository.module';
|
|
30
31
|
export * from './repository/repository.service';
|
|
32
|
+
export * from './repository/services/category.repository.service';
|
|
33
|
+
export * from './repository/services/image.repository.service';
|
|
34
|
+
export * from './repository/services/product.repository.service';
|
|
35
|
+
export * from './repository/services/provider.repository.service';
|
|
36
|
+
export * from './repository/services/province.repository.service';
|
|
37
|
+
export * from './repository/config/database.config';
|
|
31
38
|
export * from './storage/storage.module';
|
|
32
39
|
export * from './storage/storage.service';
|
|
33
40
|
export * from './telegram/env/telegram.env.config';
|
package/dist/modules/index.js
CHANGED
|
@@ -40,10 +40,17 @@ __exportStar(require("./publisher/publisher.module"), exports);
|
|
|
40
40
|
__exportStar(require("./publisher/publisher.service"), exports);
|
|
41
41
|
__exportStar(require("./rabbitmq/env/rabbitmq.env.config"), exports);
|
|
42
42
|
__exportStar(require("./rabbitmq/env/rabbitmq.env.validation"), exports);
|
|
43
|
+
__exportStar(require("./rabbitmq/types/queue.config"), exports);
|
|
43
44
|
__exportStar(require("./rabbitmq/rabbitmq.module"), exports);
|
|
44
45
|
__exportStar(require("./rabbitmq/rabbitmq.service"), exports);
|
|
45
46
|
__exportStar(require("./repository/repository.module"), exports);
|
|
46
47
|
__exportStar(require("./repository/repository.service"), exports);
|
|
48
|
+
__exportStar(require("./repository/services/category.repository.service"), exports);
|
|
49
|
+
__exportStar(require("./repository/services/image.repository.service"), exports);
|
|
50
|
+
__exportStar(require("./repository/services/product.repository.service"), exports);
|
|
51
|
+
__exportStar(require("./repository/services/provider.repository.service"), exports);
|
|
52
|
+
__exportStar(require("./repository/services/province.repository.service"), exports);
|
|
53
|
+
__exportStar(require("./repository/config/database.config"), exports);
|
|
47
54
|
__exportStar(require("./storage/storage.module"), exports);
|
|
48
55
|
__exportStar(require("./storage/storage.service"), exports);
|
|
49
56
|
__exportStar(require("./telegram/env/telegram.env.config"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/modules/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2DAAyC;AACzC,4DAA0C;AAC1C,8EAA4D;AAC5D,sFAAoE;AACpE,oFAAkE;AAClE,8EAA4D;AAE5D,iEAA+C;AAC/C,kEAAgD;AAEhD,iEAA+C;AAC/C,qEAAmD;AACnD,2DAAyC;AACzC,4DAA0C;AAC1C,6EAA2D;AAC3D,6EAA2D;AAC3D,8EAA4D;AAE5D,yDAAuC;AAEvC,uDAAqC;AACrC,wDAAsC;AACtC,+DAA6C;AAC7C,mEAAiD;AAEjD,+DAA6C;AAC7C,gEAA8C;AAE9C,+DAA6C;AAC7C,gEAA8C;AAE9C,qEAAmD;AACnD,yEAAuD;AACvD,6DAA2C;AAC3C,8DAA4C;AAE5C,iEAA+C;AAC/C,kEAAgD;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/modules/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2DAAyC;AACzC,4DAA0C;AAC1C,8EAA4D;AAC5D,sFAAoE;AACpE,oFAAkE;AAClE,8EAA4D;AAE5D,iEAA+C;AAC/C,kEAAgD;AAEhD,iEAA+C;AAC/C,qEAAmD;AACnD,2DAAyC;AACzC,4DAA0C;AAC1C,6EAA2D;AAC3D,6EAA2D;AAC3D,8EAA4D;AAE5D,yDAAuC;AAEvC,uDAAqC;AACrC,wDAAsC;AACtC,+DAA6C;AAC7C,mEAAiD;AAEjD,+DAA6C;AAC7C,gEAA8C;AAE9C,+DAA6C;AAC7C,gEAA8C;AAE9C,qEAAmD;AACnD,yEAAuD;AACvD,gEAA8C;AAC9C,6DAA2C;AAC3C,8DAA4C;AAE5C,iEAA+C;AAC/C,kEAAgD;AAChD,oFAAkE;AAClE,iFAA+D;AAC/D,mFAAiE;AACjE,oFAAkE;AAClE,oFAAkE;AAClE,sEAAoD;AAEpD,2DAAyC;AACzC,4DAA0C;AAE1C,qEAAmD;AACnD,yEAAuD;AACvD,6DAA2C;AAC3C,8DAA4C;AAE5C,6DAA2C;AAC3C,8DAA4C;AAE5C,uEAAqD;AACrD,2EAAyD;AACzD,+DAA6C;AAC7C,gEAA8C"}
|
|
@@ -18,9 +18,11 @@ exports.ProcessorModule = ProcessorModule;
|
|
|
18
18
|
exports.ProcessorModule = ProcessorModule = __decorate([
|
|
19
19
|
(0, common_1.Module)({
|
|
20
20
|
imports: [
|
|
21
|
-
rabbitmq_module_1.RabbitMQModule.
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
rabbitmq_module_1.RabbitMQModule.forQueues([
|
|
22
|
+
{ queue: queue_name_1.QueueName.DEV, token: queue_token_1.QueueToken.DEV },
|
|
23
|
+
{ queue: queue_name_1.QueueName.QA, token: queue_token_1.QueueToken.QA },
|
|
24
|
+
{ queue: queue_name_1.QueueName.PROD, token: queue_token_1.QueueToken.PROD },
|
|
25
|
+
]),
|
|
24
26
|
],
|
|
25
27
|
providers: [processor_service_1.ProcessorService],
|
|
26
28
|
exports: [processor_service_1.ProcessorService],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processor.module.js","sourceRoot":"","sources":["../../../src/modules/processor/processor.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AAExC,iEAA6D;AAC7D,2DAAuD;AACvD,kDAA8C;AAC9C,oDAAgD;
|
|
1
|
+
{"version":3,"file":"processor.module.js","sourceRoot":"","sources":["../../../src/modules/processor/processor.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AAExC,iEAA6D;AAC7D,2DAAuD;AACvD,kDAA8C;AAC9C,oDAAgD;AAazC,IAAM,eAAe,GAArB,MAAM,eAAe;CAAG,CAAA;AAAlB,0CAAe;0BAAf,eAAe;IAX3B,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,gCAAc,CAAC,SAAS,CAAC;gBACvB,EAAE,KAAK,EAAE,sBAAS,CAAC,GAAG,EAAE,KAAK,EAAE,wBAAU,CAAC,GAAG,EAAE;gBAC/C,EAAE,KAAK,EAAE,sBAAS,CAAC,EAAE,EAAE,KAAK,EAAE,wBAAU,CAAC,EAAE,EAAE;gBAC7C,EAAE,KAAK,EAAE,sBAAS,CAAC,IAAI,EAAE,KAAK,EAAE,wBAAU,CAAC,IAAI,EAAE;aAClD,CAAC;SACH;QACD,SAAS,EAAE,CAAC,oCAAgB,CAAC;QAC7B,OAAO,EAAE,CAAC,oCAAgB,CAAC;KAC5B,CAAC;GACW,eAAe,CAAG"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { DynamicModule } from '@nestjs/common';
|
|
2
|
+
import { QueueConfig } from './types/queue.config';
|
|
2
3
|
export declare class RabbitMQModule {
|
|
3
|
-
static
|
|
4
|
+
static forQueues(queues: QueueConfig[]): DynamicModule;
|
|
5
|
+
static forRoot(queue: string, token?: string): DynamicModule;
|
|
4
6
|
}
|
|
@@ -16,35 +16,36 @@ const config_2 = require("@nestjs/config");
|
|
|
16
16
|
const rabbitmq_env_config_1 = require("./env/rabbitmq.env.config");
|
|
17
17
|
const rabbitmq_1 = require("../../common/constant/rabbitmq");
|
|
18
18
|
let RabbitMQModule = RabbitMQModule_1 = class RabbitMQModule {
|
|
19
|
-
static
|
|
20
|
-
const
|
|
19
|
+
static forQueues(queues) {
|
|
20
|
+
const clients = queues.map((config) => ({
|
|
21
|
+
name: config.token,
|
|
22
|
+
imports: [config_1.ConfigModule],
|
|
23
|
+
inject: [config_2.ConfigService],
|
|
24
|
+
useFactory: (service) => {
|
|
25
|
+
const server = service.get(rabbitmq_1.RABBITMQ_SERVER_URL);
|
|
26
|
+
return {
|
|
27
|
+
transport: microservices_2.Transport.RMQ,
|
|
28
|
+
options: {
|
|
29
|
+
urls: [server],
|
|
30
|
+
queue: config.queue,
|
|
31
|
+
queueOptions: { durable: true },
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
}));
|
|
21
36
|
return {
|
|
22
37
|
module: RabbitMQModule_1,
|
|
23
38
|
imports: [
|
|
24
39
|
config_1.ConfigModule.forFeature(rabbitmq_env_config_1.RabbitmqEnvConfig),
|
|
25
|
-
microservices_1.ClientsModule.registerAsync(
|
|
26
|
-
{
|
|
27
|
-
name: ServiceToken,
|
|
28
|
-
imports: [config_1.ConfigModule],
|
|
29
|
-
inject: [config_2.ConfigService],
|
|
30
|
-
useFactory: (service) => {
|
|
31
|
-
const server = service.get(rabbitmq_1.RABBITMQ_SERVER_URL);
|
|
32
|
-
return {
|
|
33
|
-
transport: microservices_2.Transport.RMQ,
|
|
34
|
-
options: {
|
|
35
|
-
urls: [server],
|
|
36
|
-
queue,
|
|
37
|
-
queueOptions: { durable: true },
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
]),
|
|
40
|
+
microservices_1.ClientsModule.registerAsync(clients),
|
|
43
41
|
],
|
|
44
42
|
exports: [microservices_1.ClientsModule],
|
|
45
43
|
providers: [],
|
|
46
44
|
};
|
|
47
45
|
}
|
|
46
|
+
static forRoot(queue, token = 'RABBITMQ_SERVICE') {
|
|
47
|
+
return this.forQueues([{ queue, token }]);
|
|
48
|
+
}
|
|
48
49
|
};
|
|
49
50
|
exports.RabbitMQModule = RabbitMQModule;
|
|
50
51
|
exports.RabbitMQModule = RabbitMQModule = RabbitMQModule_1 = __decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rabbitmq.module.js","sourceRoot":"","sources":["../../../src/modules/rabbitmq/rabbitmq.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAwC;AAExC,yDAAsD;AACtD,yDAAkD;AAClD,2CAA8C;AAC9C,2CAA+C;AAE/C,mEAA8D;AAC9D,6DAAqE;
|
|
1
|
+
{"version":3,"file":"rabbitmq.module.js","sourceRoot":"","sources":["../../../src/modules/rabbitmq/rabbitmq.module.ts"],"names":[],"mappings":";;;;;;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B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue.config.js","sourceRoot":"","sources":["../../../../src/modules/rabbitmq/types/queue.config.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DefaultDatabaseConfig = exports.ENTITIES = void 0;
|
|
4
|
+
const product_entity_1 = require("../entities/product.entity");
|
|
5
|
+
exports.ENTITIES = [product_entity_1.ProductEntity];
|
|
6
|
+
exports.DefaultDatabaseConfig = {
|
|
7
|
+
type: 'better-sqlite3',
|
|
8
|
+
database: './data/scraping.db',
|
|
9
|
+
synchronize: true,
|
|
10
|
+
logging: false,
|
|
11
|
+
entities: exports.ENTITIES,
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=database.config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"database.config.js","sourceRoot":"","sources":["../../../../src/modules/repository/config/database.config.ts"],"names":[],"mappings":";;;AACA,+DAA2D;AAE9C,QAAA,QAAQ,GAAG,CAAC,8BAAa,CAAC,CAAC;AAE3B,QAAA,qBAAqB,GAAyB;IACzD,IAAI,EAAE,gBAAgB;IACtB,QAAQ,EAAE,oBAAoB;IAC9B,WAAW,EAAE,IAAI;IACjB,OAAO,EAAE,KAAK;IACd,QAAQ,EAAE,gBAAQ;CACnB,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export declare class ProductEntity {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
url: string;
|
|
5
|
+
description: string;
|
|
6
|
+
currentPrice: number;
|
|
7
|
+
oldPrice: number;
|
|
8
|
+
currency: string;
|
|
9
|
+
categories: string[];
|
|
10
|
+
mainCategory: string;
|
|
11
|
+
image: string;
|
|
12
|
+
extraImages: string[];
|
|
13
|
+
manufacturer: string;
|
|
14
|
+
provider: string;
|
|
15
|
+
provinces: string[];
|
|
16
|
+
freeShipping: boolean;
|
|
17
|
+
orders: number;
|
|
18
|
+
rating: number;
|
|
19
|
+
reviewsCount: number;
|
|
20
|
+
stockQuantity: number;
|
|
21
|
+
priceByWeight: number;
|
|
22
|
+
currencyByWeight: string;
|
|
23
|
+
weightUnit: number;
|
|
24
|
+
buyPrice: number;
|
|
25
|
+
classification: string;
|
|
26
|
+
slug: string;
|
|
27
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ProductEntity = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
let ProductEntity = class ProductEntity {
|
|
15
|
+
};
|
|
16
|
+
exports.ProductEntity = ProductEntity;
|
|
17
|
+
__decorate([
|
|
18
|
+
(0, typeorm_1.PrimaryColumn)(),
|
|
19
|
+
__metadata("design:type", String)
|
|
20
|
+
], ProductEntity.prototype, "id", void 0);
|
|
21
|
+
__decorate([
|
|
22
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
23
|
+
__metadata("design:type", String)
|
|
24
|
+
], ProductEntity.prototype, "name", void 0);
|
|
25
|
+
__decorate([
|
|
26
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
27
|
+
__metadata("design:type", String)
|
|
28
|
+
], ProductEntity.prototype, "url", void 0);
|
|
29
|
+
__decorate([
|
|
30
|
+
(0, typeorm_1.Column)({ type: 'text', nullable: true }),
|
|
31
|
+
__metadata("design:type", String)
|
|
32
|
+
], ProductEntity.prototype, "description", void 0);
|
|
33
|
+
__decorate([
|
|
34
|
+
(0, typeorm_1.Column)({ type: 'float', nullable: true }),
|
|
35
|
+
__metadata("design:type", Number)
|
|
36
|
+
], ProductEntity.prototype, "currentPrice", void 0);
|
|
37
|
+
__decorate([
|
|
38
|
+
(0, typeorm_1.Column)({ type: 'float', nullable: true, default: 0 }),
|
|
39
|
+
__metadata("design:type", Number)
|
|
40
|
+
], ProductEntity.prototype, "oldPrice", void 0);
|
|
41
|
+
__decorate([
|
|
42
|
+
(0, typeorm_1.Column)({ nullable: true, default: 'USD' }),
|
|
43
|
+
__metadata("design:type", String)
|
|
44
|
+
], ProductEntity.prototype, "currency", void 0);
|
|
45
|
+
__decorate([
|
|
46
|
+
(0, typeorm_1.Column)({ type: 'jsonb', nullable: true }),
|
|
47
|
+
__metadata("design:type", Array)
|
|
48
|
+
], ProductEntity.prototype, "categories", void 0);
|
|
49
|
+
__decorate([
|
|
50
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
51
|
+
__metadata("design:type", String)
|
|
52
|
+
], ProductEntity.prototype, "mainCategory", void 0);
|
|
53
|
+
__decorate([
|
|
54
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
55
|
+
__metadata("design:type", String)
|
|
56
|
+
], ProductEntity.prototype, "image", void 0);
|
|
57
|
+
__decorate([
|
|
58
|
+
(0, typeorm_1.Column)({ type: 'jsonb', nullable: true }),
|
|
59
|
+
__metadata("design:type", Array)
|
|
60
|
+
], ProductEntity.prototype, "extraImages", void 0);
|
|
61
|
+
__decorate([
|
|
62
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
63
|
+
__metadata("design:type", String)
|
|
64
|
+
], ProductEntity.prototype, "manufacturer", void 0);
|
|
65
|
+
__decorate([
|
|
66
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
67
|
+
__metadata("design:type", String)
|
|
68
|
+
], ProductEntity.prototype, "provider", void 0);
|
|
69
|
+
__decorate([
|
|
70
|
+
(0, typeorm_1.Column)({ type: 'jsonb', nullable: true }),
|
|
71
|
+
__metadata("design:type", Array)
|
|
72
|
+
], ProductEntity.prototype, "provinces", void 0);
|
|
73
|
+
__decorate([
|
|
74
|
+
(0, typeorm_1.Column)({ type: 'boolean', nullable: true, default: false }),
|
|
75
|
+
__metadata("design:type", Boolean)
|
|
76
|
+
], ProductEntity.prototype, "freeShipping", void 0);
|
|
77
|
+
__decorate([
|
|
78
|
+
(0, typeorm_1.Column)({ type: 'integer', nullable: true, default: 0 }),
|
|
79
|
+
__metadata("design:type", Number)
|
|
80
|
+
], ProductEntity.prototype, "orders", void 0);
|
|
81
|
+
__decorate([
|
|
82
|
+
(0, typeorm_1.Column)({ type: 'float', nullable: true, default: 0 }),
|
|
83
|
+
__metadata("design:type", Number)
|
|
84
|
+
], ProductEntity.prototype, "rating", void 0);
|
|
85
|
+
__decorate([
|
|
86
|
+
(0, typeorm_1.Column)({ type: 'integer', nullable: true, default: 0 }),
|
|
87
|
+
__metadata("design:type", Number)
|
|
88
|
+
], ProductEntity.prototype, "reviewsCount", void 0);
|
|
89
|
+
__decorate([
|
|
90
|
+
(0, typeorm_1.Column)({ type: 'integer', nullable: true, default: 0 }),
|
|
91
|
+
__metadata("design:type", Number)
|
|
92
|
+
], ProductEntity.prototype, "stockQuantity", void 0);
|
|
93
|
+
__decorate([
|
|
94
|
+
(0, typeorm_1.Column)({ type: 'float', nullable: true, default: 0 }),
|
|
95
|
+
__metadata("design:type", Number)
|
|
96
|
+
], ProductEntity.prototype, "priceByWeight", void 0);
|
|
97
|
+
__decorate([
|
|
98
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
99
|
+
__metadata("design:type", String)
|
|
100
|
+
], ProductEntity.prototype, "currencyByWeight", void 0);
|
|
101
|
+
__decorate([
|
|
102
|
+
(0, typeorm_1.Column)({ type: 'float', nullable: true, default: 0 }),
|
|
103
|
+
__metadata("design:type", Number)
|
|
104
|
+
], ProductEntity.prototype, "weightUnit", void 0);
|
|
105
|
+
__decorate([
|
|
106
|
+
(0, typeorm_1.Column)({ type: 'float', nullable: true, default: 0 }),
|
|
107
|
+
__metadata("design:type", Number)
|
|
108
|
+
], ProductEntity.prototype, "buyPrice", void 0);
|
|
109
|
+
__decorate([
|
|
110
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
111
|
+
__metadata("design:type", String)
|
|
112
|
+
], ProductEntity.prototype, "classification", void 0);
|
|
113
|
+
__decorate([
|
|
114
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
115
|
+
__metadata("design:type", String)
|
|
116
|
+
], ProductEntity.prototype, "slug", void 0);
|
|
117
|
+
exports.ProductEntity = ProductEntity = __decorate([
|
|
118
|
+
(0, typeorm_1.Entity)('products')
|
|
119
|
+
], ProductEntity);
|
|
120
|
+
//# sourceMappingURL=product.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product.entity.js","sourceRoot":"","sources":["../../../../src/modules/repository/entities/product.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAwD;AAGjD,IAAM,aAAa,GAAnB,MAAM,aAAa;CA2EzB,CAAA;AA3EY,sCAAa;AAExB;IADC,IAAA,uBAAa,GAAE;;yCACL;AAGX;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;2CACd;AAGb;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;0CACf;AAGZ;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;k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EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;6CACvC;AAGf;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;mDACnC;AAGrB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;oDAClC;AAGtB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;oDAChC;AAGtB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;uDACF;AAGzB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;iDACnC;AAGnB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;+CACrC;AAGjB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;qDACJ;AAGvB;IADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;2CACd;wBA1EF,aAAa;IADzB,IAAA,gBAAM,EAAC,UAAU,CAAC;GACN,aAAa,CA2EzB"}
|
|
@@ -5,29 +5,50 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
|
+
var RepositoryModule_1;
|
|
8
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
10
|
exports.RepositoryModule = void 0;
|
|
10
11
|
const common_1 = require("@nestjs/common");
|
|
12
|
+
const typeorm_1 = require("@nestjs/typeorm");
|
|
11
13
|
const repository_service_1 = require("./repository.service");
|
|
12
14
|
const category_repository_service_1 = require("./services/category.repository.service");
|
|
13
15
|
const product_repository_service_1 = require("./services/product.repository.service");
|
|
14
16
|
const provider_repository_service_1 = require("./services/provider.repository.service");
|
|
15
17
|
const province_repository_service_1 = require("./services/province.repository.service");
|
|
16
18
|
const image_repository_service_1 = require("./services/image.repository.service");
|
|
17
|
-
|
|
19
|
+
const database_config_1 = require("./config/database.config");
|
|
20
|
+
let RepositoryModule = RepositoryModule_1 = class RepositoryModule {
|
|
21
|
+
static forRoot(config) {
|
|
22
|
+
const db = { ...database_config_1.DefaultDatabaseConfig, ...config };
|
|
23
|
+
return {
|
|
24
|
+
global: true,
|
|
25
|
+
module: RepositoryModule_1,
|
|
26
|
+
imports: [
|
|
27
|
+
typeorm_1.TypeOrmModule.forRoot({ ...db }),
|
|
28
|
+
typeorm_1.TypeOrmModule.forFeature(database_config_1.ENTITIES),
|
|
29
|
+
],
|
|
30
|
+
providers: [
|
|
31
|
+
repository_service_1.RepositoryService,
|
|
32
|
+
category_repository_service_1.CategoryRepositoryService,
|
|
33
|
+
image_repository_service_1.ImageRepositoryService,
|
|
34
|
+
product_repository_service_1.ProductRepositoryService,
|
|
35
|
+
provider_repository_service_1.ProviderRepositoryService,
|
|
36
|
+
province_repository_service_1.ProvinceRepositoryService,
|
|
37
|
+
],
|
|
38
|
+
exports: [
|
|
39
|
+
typeorm_1.TypeOrmModule,
|
|
40
|
+
repository_service_1.RepositoryService,
|
|
41
|
+
category_repository_service_1.CategoryRepositoryService,
|
|
42
|
+
image_repository_service_1.ImageRepositoryService,
|
|
43
|
+
product_repository_service_1.ProductRepositoryService,
|
|
44
|
+
provider_repository_service_1.ProviderRepositoryService,
|
|
45
|
+
province_repository_service_1.ProvinceRepositoryService,
|
|
46
|
+
],
|
|
47
|
+
};
|
|
48
|
+
}
|
|
18
49
|
};
|
|
19
50
|
exports.RepositoryModule = RepositoryModule;
|
|
20
|
-
exports.RepositoryModule = RepositoryModule = __decorate([
|
|
21
|
-
(0, common_1.Module)({
|
|
22
|
-
providers: [
|
|
23
|
-
repository_service_1.RepositoryService,
|
|
24
|
-
category_repository_service_1.CategoryRepositoryService,
|
|
25
|
-
image_repository_service_1.ImageRepositoryService,
|
|
26
|
-
product_repository_service_1.ProductRepositoryService,
|
|
27
|
-
provider_repository_service_1.ProviderRepositoryService,
|
|
28
|
-
province_repository_service_1.ProvinceRepositoryService,
|
|
29
|
-
],
|
|
30
|
-
exports: [repository_service_1.RepositoryService],
|
|
31
|
-
})
|
|
51
|
+
exports.RepositoryModule = RepositoryModule = RepositoryModule_1 = __decorate([
|
|
52
|
+
(0, common_1.Module)({})
|
|
32
53
|
], RepositoryModule);
|
|
33
54
|
//# sourceMappingURL=repository.module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repository.module.js","sourceRoot":"","sources":["../../../src/modules/repository/repository.module.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"repository.module.js","sourceRoot":"","sources":["../../../src/modules/repository/repository.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAuD;AACvD,6CAAsE;AAEtE,6DAAyD;AACzD,wFAAmF;AACnF,sFAAiF;AACjF,wFAAmF;AACnF,wFAAmF;AACnF,kFAA6E;AAC7E,8DAA2E;AAGpE,IAAM,gBAAgB,wBAAtB,MAAM,gBAAgB;IAC3B,MAAM,CAAC,OAAO,CAAC,MAAsC;QACnD,MAAM,EAAE,GAAG,EAAE,GAAG,uCAAqB,EAAE,GAAG,MAAM,EAA0B,CAAC;QAE3E,OAAO;YACL,MAAM,EAAE,IAAI;YACZ,MAAM,EAAE,kBAAgB;YACxB,OAAO,EAAE;gBACP,uBAAa,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,EAAE,CAAC;gBAChC,uBAAa,CAAC,UAAU,CAAC,0BAAQ,CAAC;aACnC;YACD,SAAS,EAAE;gBACT,sCAAiB;gBACjB,uDAAyB;gBACzB,iDAAsB;gBACtB,qDAAwB;gBACxB,uDAAyB;gBACzB,uDAAyB;aAC1B;YACD,OAAO,EAAE;gBACP,uBAAa;gBACb,sCAAiB;gBACjB,uDAAyB;gBACzB,iDAAsB;gBACtB,qDAAwB;gBACxB,uDAAyB;gBACzB,uDAAyB;aAC1B;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AA9BY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,gBAAgB,CA8B5B"}
|
|
@@ -18,13 +18,13 @@ export declare class RepositoryService {
|
|
|
18
18
|
constructor(_province: ProvinceRepositoryService, _image: ImageRepositoryService, _category: CategoryRepositoryService, _provider: ProviderRepositoryService, _product: ProductRepositoryService);
|
|
19
19
|
get categories(): Category[];
|
|
20
20
|
get images(): Image[];
|
|
21
|
-
get products(): Product[]
|
|
21
|
+
get products(): Promise<Product[]>;
|
|
22
22
|
get providers(): Provider[];
|
|
23
23
|
get provinces(): Province[];
|
|
24
24
|
saveCategories(categories: Category[]): void;
|
|
25
25
|
saveImages(images: Image[]): void;
|
|
26
|
-
saveProducts(products: Product[]): void
|
|
26
|
+
saveProducts(products: Product[]): Promise<void>;
|
|
27
27
|
saveProviders(providers: Provider[]): void;
|
|
28
28
|
saveProvinces(provinces: Province[]): void;
|
|
29
|
-
reset(): void
|
|
29
|
+
reset(): Promise<void>;
|
|
30
30
|
}
|
|
@@ -36,7 +36,7 @@ let RepositoryService = RepositoryService_1 = class RepositoryService {
|
|
|
36
36
|
return this._image.images;
|
|
37
37
|
}
|
|
38
38
|
get products() {
|
|
39
|
-
return this._product.
|
|
39
|
+
return this._product.find();
|
|
40
40
|
}
|
|
41
41
|
get providers() {
|
|
42
42
|
return this._provider.providers;
|
|
@@ -50,8 +50,8 @@ let RepositoryService = RepositoryService_1 = class RepositoryService {
|
|
|
50
50
|
saveImages(images) {
|
|
51
51
|
this._image.save(images);
|
|
52
52
|
}
|
|
53
|
-
saveProducts(products) {
|
|
54
|
-
this._product.save(products);
|
|
53
|
+
async saveProducts(products) {
|
|
54
|
+
await this._product.save(products);
|
|
55
55
|
}
|
|
56
56
|
saveProviders(providers) {
|
|
57
57
|
this._provider.save(providers);
|
|
@@ -59,15 +59,12 @@ let RepositoryService = RepositoryService_1 = class RepositoryService {
|
|
|
59
59
|
saveProvinces(provinces) {
|
|
60
60
|
this._province.save(provinces);
|
|
61
61
|
}
|
|
62
|
-
reset() {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
this._product,
|
|
69
|
-
];
|
|
70
|
-
services.forEach((x) => x.reset());
|
|
62
|
+
async reset() {
|
|
63
|
+
this._province.reset();
|
|
64
|
+
this._category.reset();
|
|
65
|
+
this._image.reset();
|
|
66
|
+
this._provider.reset();
|
|
67
|
+
await this._product.reset();
|
|
71
68
|
this.logger.log('✅ Repository reset successfully');
|
|
72
69
|
}
|
|
73
70
|
};
|
|
@@ -88,7 +85,7 @@ __decorate([
|
|
|
88
85
|
(0, event_emitter_1.OnEvent)(event_enum_1.ScrapingEvent.SAVE_PRODUCTS),
|
|
89
86
|
__metadata("design:type", Function),
|
|
90
87
|
__metadata("design:paramtypes", [Array]),
|
|
91
|
-
__metadata("design:returntype",
|
|
88
|
+
__metadata("design:returntype", Promise)
|
|
92
89
|
], RepositoryService.prototype, "saveProducts", null);
|
|
93
90
|
__decorate([
|
|
94
91
|
(0, event_emitter_1.OnEvent)(event_enum_1.ScrapingEvent.SAVE_PROVIDERS),
|
|
@@ -106,7 +103,7 @@ __decorate([
|
|
|
106
103
|
(0, event_emitter_1.OnEvent)(event_enum_1.ScrapingEvent.RESET),
|
|
107
104
|
__metadata("design:type", Function),
|
|
108
105
|
__metadata("design:paramtypes", []),
|
|
109
|
-
__metadata("design:returntype",
|
|
106
|
+
__metadata("design:returntype", Promise)
|
|
110
107
|
], RepositoryService.prototype, "reset", null);
|
|
111
108
|
exports.RepositoryService = RepositoryService = RepositoryService_1 = __decorate([
|
|
112
109
|
(0, common_1.Injectable)(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repository.service.js","sourceRoot":"","sources":["../../../src/modules/repository/repository.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,yDAAgD;AAEhD,wFAAmF;AACnF,wFAAmF;AACnF,kFAA6E;AAC7E,wFAAmF;AACnF,sFAAiF;AAEjF,uDAAoD;AACpD,6DAA6D;AAQtD,IAAM,iBAAiB,yBAAvB,MAAM,iBAAiB;IAG5B,YACmB,SAAoC,EACpC,MAA8B,EAC9B,SAAoC,EACpC,SAAoC,EACpC,QAAkC;QAJlC,cAAS,GAAT,SAAS,CAA2B;QACpC,WAAM,GAAN,MAAM,CAAwB;QAC9B,cAAS,GAAT,SAAS,CAA2B;QACpC,cAAS,GAAT,SAAS,CAA2B;QACpC,aAAQ,GAAR,QAAQ,CAA0B;QAP7C,WAAM,GAAG,IAAI,eAAM,CAAC,mBAAiB,CAAC,IAAI,CAAC,CAAC;IAQjD,CAAC;IAEJ,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC;IACnC,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;IAC5B,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"repository.service.js","sourceRoot":"","sources":["../../../src/modules/repository/repository.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,yDAAgD;AAEhD,wFAAmF;AACnF,wFAAmF;AACnF,kFAA6E;AAC7E,wFAAmF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AAC,SAAqB;QACjC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACjC,CAAC;IAGK,AAAN,KAAK,CAAC,KAAK;QACT,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QACvB,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QACvB,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QACpB,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QACvB,MAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QAC5B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAC;IACrD,CAAC;CACF,CAAA;AAjEY,8CAAiB;AAgC5B;IADC,IAAA,uBAAO,EAAC,0BAAa,CAAC,eAAe,CAAC;;;;uDAGtC;AAGD;IADC,IAAA,uBAAO,EAAC,0BAAa,CAAC,WAAW,CAAC;;;;mDAGlC;AAGK;IADL,IAAA,uBAAO,EAAC,0BAAa,CAAC,aAAa,CAAC;;;;qDAGpC;AAGD;IADC,IAAA,uBAAO,EAAC,0BAAa,CAAC,cAAc,CAAC;;;;sDAGrC;AAGD;IADC,IAAA,uBAAO,EAAC,0BAAa,CAAC,cAAc,CAAC;;;;sDAGrC;AAGK;IADL,IAAA,uBAAO,EAAC,0BAAa,CAAC,KAAK,CAAC;;;;8CAQ5B;4BAhEU,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;qCAKmB,uDAAyB;QAC5B,iDAAsB;QACnB,uDAAyB;QACzB,uDAAyB;QAC1B,qDAAwB;GAR1C,iBAAiB,CAiE7B"}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import { Repository } from 'typeorm';
|
|
1
2
|
import { Product } from '../../../common/class/product';
|
|
3
|
+
import { ProductEntity } from '../entities/product.entity';
|
|
2
4
|
export declare class ProductRepositoryService {
|
|
5
|
+
private readonly repository;
|
|
3
6
|
private logger;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
save(products: Product[]): void
|
|
8
|
-
reset(): void
|
|
7
|
+
constructor(repository: Repository<ProductEntity>);
|
|
8
|
+
find(): Promise<Product[]>;
|
|
9
|
+
count(): Promise<number>;
|
|
10
|
+
save(products: Product[]): Promise<void>;
|
|
11
|
+
reset(): Promise<void>;
|
|
9
12
|
}
|
|
@@ -8,32 +8,51 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
15
|
exports.ProductRepositoryService = void 0;
|
|
13
16
|
const common_1 = require("@nestjs/common");
|
|
17
|
+
const typeorm_1 = require("@nestjs/typeorm");
|
|
18
|
+
const typeorm_2 = require("typeorm");
|
|
14
19
|
const repository_service_1 = require("../repository.service");
|
|
15
20
|
const logger_1 = require("../../../common/logger/logger");
|
|
21
|
+
const product_1 = require("../../../common/class/product");
|
|
22
|
+
const product_entity_1 = require("../entities/product.entity");
|
|
16
23
|
let ProductRepositoryService = class ProductRepositoryService {
|
|
17
|
-
constructor() {
|
|
24
|
+
constructor(repository) {
|
|
25
|
+
this.repository = repository;
|
|
18
26
|
this.logger = new logger_1.Logger(repository_service_1.RepositoryService.name);
|
|
19
|
-
this._products = new Map();
|
|
20
27
|
}
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
return
|
|
28
|
+
async find() {
|
|
29
|
+
const entities = await this.repository.find();
|
|
30
|
+
return entities.map((entity) => new product_1.Product(entity));
|
|
31
|
+
}
|
|
32
|
+
async count() {
|
|
33
|
+
return this.repository.count();
|
|
24
34
|
}
|
|
25
|
-
save(products) {
|
|
35
|
+
async save(products) {
|
|
26
36
|
const sizes = { previous: 0, current: 0 };
|
|
27
37
|
const multiples = { previous: 0, current: 0 };
|
|
28
|
-
sizes.previous = this.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
38
|
+
sizes.previous = await this.count();
|
|
39
|
+
const entities = [];
|
|
40
|
+
for (const product of products) {
|
|
41
|
+
const data = product.getData();
|
|
42
|
+
const { id, url } = data;
|
|
43
|
+
if (id) {
|
|
44
|
+
const exists = await this.repository.existsBy({ id });
|
|
45
|
+
if (!exists) {
|
|
46
|
+
const entity = this.repository.create(data);
|
|
47
|
+
entities.push(entity);
|
|
48
|
+
this.logger.debug(`✅ ${url}`);
|
|
49
|
+
}
|
|
34
50
|
}
|
|
35
|
-
}
|
|
36
|
-
|
|
51
|
+
}
|
|
52
|
+
if (entities.length > 0) {
|
|
53
|
+
await this.repository.save(entities);
|
|
54
|
+
}
|
|
55
|
+
sizes.current = await this.repository.count();
|
|
37
56
|
multiples.previous = Math.floor(sizes.previous / 10);
|
|
38
57
|
multiples.current = Math.floor(sizes.current / 10);
|
|
39
58
|
if (multiples.current > multiples.previous) {
|
|
@@ -41,13 +60,14 @@ let ProductRepositoryService = class ProductRepositoryService {
|
|
|
41
60
|
this.logger.verbose(message);
|
|
42
61
|
}
|
|
43
62
|
}
|
|
44
|
-
reset() {
|
|
45
|
-
this.
|
|
63
|
+
async reset() {
|
|
64
|
+
await this.repository.deleteAll();
|
|
46
65
|
}
|
|
47
66
|
};
|
|
48
67
|
exports.ProductRepositoryService = ProductRepositoryService;
|
|
49
68
|
exports.ProductRepositoryService = ProductRepositoryService = __decorate([
|
|
50
69
|
(0, common_1.Injectable)(),
|
|
51
|
-
|
|
70
|
+
__param(0, (0, typeorm_1.InjectRepository)(product_entity_1.ProductEntity)),
|
|
71
|
+
__metadata("design:paramtypes", [typeorm_2.Repository])
|
|
52
72
|
], ProductRepositoryService);
|
|
53
73
|
//# sourceMappingURL=product.repository.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"product.repository.service.js","sourceRoot":"","sources":["../../../../src/modules/repository/services/product.repository.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"product.repository.service.js","sourceRoot":"","sources":["../../../../src/modules/repository/services/product.repository.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,6CAAmD;AACnD,qCAAqC;AAErC,8DAA0D;AAC1D,0DAAuD;AACvD,2DAAwD;AACxD,+DAA2D;AAGpD,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IAGnC,YAEE,UAAsD;QAArC,eAAU,GAAV,UAAU,CAA2B;QAJhD,WAAM,GAAG,IAAI,eAAM,CAAC,sCAAiB,CAAC,IAAI,CAAC,CAAC;IAKjD,CAAC;IAEJ,KAAK,CAAC,IAAI;QACR,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;QAC9C,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,iBAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IACvD,CAAC;IAED,KAAK,CAAC,KAAK;QACT,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;IACjC,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,QAAmB;QAC5B,MAAM,KAAK,GAAG,EAAE,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;QAC1C,MAAM,SAAS,GAAG,EAAE,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;QAC9C,KAAK,CAAC,QAAQ,GAAG,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;QAEpC,MAAM,QAAQ,GAAoB,EAAE,CAAC;QAErC,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;YAC/B,MAAM,IAAI,GAAG,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wB;mCAAxB,wBAAwB;IADpC,IAAA,mBAAU,GAAE;IAKR,WAAA,IAAA,0BAAgB,EAAC,8BAAa,CAAC,CAAA;qCACH,oBAAU;GAL9B,wBAAwB,CAuDpC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rafikidota/cuba-ofertas-scraping",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.35.0",
|
|
4
4
|
"description": "Sometimes, the best way to solve your own problems is to help someone else.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -29,12 +29,15 @@
|
|
|
29
29
|
"@nestjs/microservices": "11.1.17",
|
|
30
30
|
"@nestjs/schedule": "6.1.1",
|
|
31
31
|
"@nestjs/terminus": "11.1.1",
|
|
32
|
+
"@nestjs/typeorm": "11.0.0",
|
|
32
33
|
"@types/archiver": "7.0.0",
|
|
34
|
+
"@types/better-sqlite3": "7.6.13",
|
|
33
35
|
"@types/node": "25.5.0",
|
|
34
36
|
"@typescript-eslint/eslint-plugin": "8.57.2",
|
|
35
37
|
"@typescript-eslint/parser": "8.57.2",
|
|
36
38
|
"archiver": "7.0.1",
|
|
37
39
|
"axios": "1.13.6",
|
|
40
|
+
"better-sqlite3": "12.8.0",
|
|
38
41
|
"cheerio": "1.2.0",
|
|
39
42
|
"class-transformer": "0.5.1",
|
|
40
43
|
"class-validator": "0.15.1",
|
|
@@ -54,6 +57,7 @@
|
|
|
54
57
|
"rimraf": "6.1.3",
|
|
55
58
|
"rxjs": "7.8.2",
|
|
56
59
|
"telegraf": "4.16.3",
|
|
60
|
+
"typeorm": "0.3.28",
|
|
57
61
|
"typescript": "5.9.3",
|
|
58
62
|
"typescript-eslint": "8.57.2"
|
|
59
63
|
},
|