store-scrapper-js-common 1.0.72 → 1.0.76
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/entities/category-entity.d.ts +12 -0
- package/dist/entities/category-entity.js +45 -0
- package/dist/entities/category-entity.js.map +1 -0
- package/dist/entities/category.d.ts +2 -0
- package/dist/entities/category.js +1 -1
- package/dist/entities/category.js.map +1 -1
- package/dist/entities/index.d.ts +4 -2
- package/dist/entities/index.js +6 -1
- package/dist/entities/index.js.map +1 -1
- package/dist/entities/keyword.d.ts +38 -1
- package/dist/entities/keyword.js +37 -0
- package/dist/entities/keyword.js.map +1 -1
- package/dist/entities/price.d.ts +9 -0
- package/dist/entities/price.js +19 -1
- package/dist/entities/price.js.map +1 -1
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/index.js +3 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/price-utils.d.ts +2 -0
- package/dist/utils/price-utils.js +29 -1
- package/dist/utils/price-utils.js.map +1 -1
- package/package.json +1 -1
- package/src/entities/category-entity.ts +25 -0
- package/src/entities/category.ts +5 -1
- package/src/entities/index.ts +5 -3
- package/src/entities/keyword.ts +59 -1
- package/src/entities/price.ts +16 -0
- package/src/utils/index.ts +2 -1
- package/src/utils/price-utils.ts +34 -1
- package/tests/utils/price-utils.test.ts +78 -3
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AbstractBase } from './abstract-base';
|
|
2
|
+
import { CATEGORY_ENUM } from './keyword';
|
|
3
|
+
export declare class CategoryEntity extends AbstractBase {
|
|
4
|
+
category: CATEGORY_ENUM;
|
|
5
|
+
displayName?: {
|
|
6
|
+
es?: string;
|
|
7
|
+
en?: string;
|
|
8
|
+
br?: string;
|
|
9
|
+
};
|
|
10
|
+
subCategories?: CategoryEntity[];
|
|
11
|
+
enabled: boolean;
|
|
12
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
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.CategoryEntity = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
const class_validator_1 = require("class-validator");
|
|
15
|
+
const abstract_base_1 = require("./abstract-base");
|
|
16
|
+
const keyword_1 = require("./keyword");
|
|
17
|
+
let CategoryEntity = class CategoryEntity extends abstract_base_1.AbstractBase {
|
|
18
|
+
constructor() {
|
|
19
|
+
super(...arguments);
|
|
20
|
+
this.enabled = true;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
__decorate([
|
|
24
|
+
typeorm_1.Index(),
|
|
25
|
+
typeorm_1.Column(),
|
|
26
|
+
class_validator_1.IsEnum(keyword_1.CATEGORY_ENUM),
|
|
27
|
+
__metadata("design:type", String)
|
|
28
|
+
], CategoryEntity.prototype, "category", void 0);
|
|
29
|
+
__decorate([
|
|
30
|
+
typeorm_1.Column(),
|
|
31
|
+
__metadata("design:type", Object)
|
|
32
|
+
], CategoryEntity.prototype, "displayName", void 0);
|
|
33
|
+
__decorate([
|
|
34
|
+
typeorm_1.Column(),
|
|
35
|
+
__metadata("design:type", Array)
|
|
36
|
+
], CategoryEntity.prototype, "subCategories", void 0);
|
|
37
|
+
__decorate([
|
|
38
|
+
typeorm_1.Column({ default: true, type: 'boolean' }),
|
|
39
|
+
__metadata("design:type", Object)
|
|
40
|
+
], CategoryEntity.prototype, "enabled", void 0);
|
|
41
|
+
CategoryEntity = __decorate([
|
|
42
|
+
typeorm_1.Entity({ name: 'categories' })
|
|
43
|
+
], CategoryEntity);
|
|
44
|
+
exports.CategoryEntity = CategoryEntity;
|
|
45
|
+
//# sourceMappingURL=category-entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"category-entity.js","sourceRoot":"/","sources":["entities/category-entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAgD;AAChD,qDAAyC;AACzC,mDAA+C;AAC/C,uCAA0C;AAG1C,IAAa,cAAc,GAA3B,MAAa,cAAe,SAAQ,4BAAY;IAAhD;;QAiBE,YAAO,GAAG,IAAI,CAAC;IACjB,CAAC;CAAA,CAAA;AAdC;IAHC,eAAK,EAAE;IACP,gBAAM,EAAE;IACR,wBAAM,CAAC,uBAAa,CAAC;;gDACE;AAGxB;IADC,gBAAM,EAAE;;mDAKR;AAGD;IADC,gBAAM,EAAE;;qDACuB;AAGhC;IADC,gBAAM,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;;+CAC5B;AAjBJ,cAAc;IAD1B,gBAAM,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;GAClB,cAAc,CAkB1B;AAlBY,wCAAc","sourcesContent":["import { Column, Entity, Index } from 'typeorm';\nimport { IsEnum } from 'class-validator';\nimport { AbstractBase } from './abstract-base';\nimport { CATEGORY_ENUM } from './keyword';\n\n@Entity({ name: 'categories' })\nexport class CategoryEntity extends AbstractBase {\n @Index()\n @Column()\n @IsEnum(CATEGORY_ENUM)\n category: CATEGORY_ENUM;\n\n @Column()\n displayName?: {\n es?: string;\n en?: string;\n br?: string;\n }\n\n @Column()\n subCategories?: CategoryEntity[]\n\n @Column({ default: true, type: 'boolean' })\n enabled = true;\n}\n"]}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { AbstractBase } from './abstract-base';
|
|
2
2
|
import { ObjectLiteral } from '../classes';
|
|
3
3
|
import { Product } from './product';
|
|
4
|
+
import { CATEGORY_ENUM } from './keyword';
|
|
4
5
|
export declare class Category extends AbstractBase {
|
|
6
|
+
category?: CATEGORY_ENUM;
|
|
5
7
|
name?: string;
|
|
6
8
|
path?: string;
|
|
7
9
|
url: string;
|
|
@@ -12,7 +12,7 @@ const abstract_base_1 = require("./abstract-base");
|
|
|
12
12
|
let Category = class Category extends abstract_base_1.AbstractBase {
|
|
13
13
|
};
|
|
14
14
|
Category = __decorate([
|
|
15
|
-
typeorm_1.Entity({ name: '
|
|
15
|
+
typeorm_1.Entity({ name: 'categoryMenus' })
|
|
16
16
|
], Category);
|
|
17
17
|
exports.Category = Category;
|
|
18
18
|
//# sourceMappingURL=category.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"category.js","sourceRoot":"/","sources":["entities/category.ts"],"names":[],"mappings":";;;;;;;;;AAAA,qCAAiC;AACjC,mDAA+C;
|
|
1
|
+
{"version":3,"file":"category.js","sourceRoot":"/","sources":["entities/category.ts"],"names":[],"mappings":";;;;;;;;;AAAA,qCAAiC;AACjC,mDAA+C;AAO/C,IAAa,QAAQ,GAArB,MAAa,QAAS,SAAQ,4BAAY;CAczC,CAAA;AAdY,QAAQ;IADpB,gBAAM,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC;GACrB,QAAQ,CAcpB;AAdY,4BAAQ","sourcesContent":["import { Entity } from 'typeorm';\nimport { AbstractBase } from './abstract-base';\nimport { ObjectLiteral } from '../classes';\nimport { Product } from './product';\nimport { CATEGORY_ENUM } from './keyword';\n\n// Mucho webeo cambiarle el nombre a todas las clases..\n@Entity({ name: 'categoryMenus' })\nexport class Category extends AbstractBase {\n category?: CATEGORY_ENUM;\n\n name?: string;\n\n path?: string;\n\n url: string;\n\n sourceUrl?: string;\n\n metadata?: ObjectLiteral;\n\n products?: Product[];\n}\n"]}
|
package/dist/entities/index.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { StoreQueueConfig, Store, CountryEnum, PriorityEnum } from './store';
|
|
2
2
|
import { Product, UpdateReasonEnum, CurrencyEnum, ProductAttributes, ConditionalPrice } from './product';
|
|
3
|
-
import { Price } from './price';
|
|
3
|
+
import { Price, MeasurementUnitEnum } from './price';
|
|
4
4
|
import { Category } from './category';
|
|
5
5
|
import { AbstractBase } from './abstract-base';
|
|
6
6
|
import { Keyword, CATEGORY_ENUM, CONDITION_ENUM, CONDITION_FIELD_ENUM } from './keyword';
|
|
7
7
|
import { User } from './user';
|
|
8
8
|
import { AlertConditions } from './alert-conditions';
|
|
9
|
+
import { PricesStats } from './prices-stats';
|
|
10
|
+
import { CategoryEntity } from './category-entity';
|
|
9
11
|
export declare const Entities: (typeof Price | typeof Keyword | typeof Product | typeof Store | typeof User)[];
|
|
10
|
-
export { Store, Product, Price, Category, AbstractBase, Keyword, CONDITION_FIELD_ENUM, CONDITION_ENUM, CATEGORY_ENUM, User, AlertConditions, StoreQueueConfig, CountryEnum, PriorityEnum, CurrencyEnum, UpdateReasonEnum, ConditionalPrice, ProductAttributes, };
|
|
12
|
+
export { Store, Product, Price, Category, CategoryEntity, AbstractBase, Keyword, CONDITION_FIELD_ENUM, CONDITION_ENUM, CATEGORY_ENUM, User, AlertConditions, StoreQueueConfig, CountryEnum, PriorityEnum, CurrencyEnum, UpdateReasonEnum, ConditionalPrice, ProductAttributes, MeasurementUnitEnum, PricesStats, };
|
package/dist/entities/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UpdateReasonEnum = exports.CurrencyEnum = exports.PriorityEnum = exports.CountryEnum = exports.AlertConditions = exports.User = exports.CATEGORY_ENUM = exports.CONDITION_ENUM = exports.CONDITION_FIELD_ENUM = exports.Keyword = exports.AbstractBase = exports.Category = exports.Price = exports.Product = exports.Store = exports.Entities = void 0;
|
|
3
|
+
exports.PricesStats = exports.MeasurementUnitEnum = exports.UpdateReasonEnum = exports.CurrencyEnum = exports.PriorityEnum = exports.CountryEnum = exports.AlertConditions = exports.User = exports.CATEGORY_ENUM = exports.CONDITION_ENUM = exports.CONDITION_FIELD_ENUM = exports.Keyword = exports.AbstractBase = exports.CategoryEntity = exports.Category = exports.Price = exports.Product = exports.Store = exports.Entities = void 0;
|
|
4
4
|
const store_1 = require("./store");
|
|
5
5
|
Object.defineProperty(exports, "Store", { enumerable: true, get: function () { return store_1.Store; } });
|
|
6
6
|
Object.defineProperty(exports, "CountryEnum", { enumerable: true, get: function () { return store_1.CountryEnum; } });
|
|
@@ -11,6 +11,7 @@ Object.defineProperty(exports, "UpdateReasonEnum", { enumerable: true, get: func
|
|
|
11
11
|
Object.defineProperty(exports, "CurrencyEnum", { enumerable: true, get: function () { return product_1.CurrencyEnum; } });
|
|
12
12
|
const price_1 = require("./price");
|
|
13
13
|
Object.defineProperty(exports, "Price", { enumerable: true, get: function () { return price_1.Price; } });
|
|
14
|
+
Object.defineProperty(exports, "MeasurementUnitEnum", { enumerable: true, get: function () { return price_1.MeasurementUnitEnum; } });
|
|
14
15
|
const category_1 = require("./category");
|
|
15
16
|
Object.defineProperty(exports, "Category", { enumerable: true, get: function () { return category_1.Category; } });
|
|
16
17
|
const abstract_base_1 = require("./abstract-base");
|
|
@@ -24,6 +25,10 @@ const user_1 = require("./user");
|
|
|
24
25
|
Object.defineProperty(exports, "User", { enumerable: true, get: function () { return user_1.User; } });
|
|
25
26
|
const alert_conditions_1 = require("./alert-conditions");
|
|
26
27
|
Object.defineProperty(exports, "AlertConditions", { enumerable: true, get: function () { return alert_conditions_1.AlertConditions; } });
|
|
28
|
+
const prices_stats_1 = require("./prices-stats");
|
|
29
|
+
Object.defineProperty(exports, "PricesStats", { enumerable: true, get: function () { return prices_stats_1.PricesStats; } });
|
|
30
|
+
const category_entity_1 = require("./category-entity");
|
|
31
|
+
Object.defineProperty(exports, "CategoryEntity", { enumerable: true, get: function () { return category_entity_1.CategoryEntity; } });
|
|
27
32
|
exports.Entities = [
|
|
28
33
|
store_1.Store, product_1.Product, price_1.Price, keyword_1.Keyword, user_1.User,
|
|
29
34
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["entities/index.ts"],"names":[],"mappings":";;;AAAA,mCAEiB;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["entities/index.ts"],"names":[],"mappings":";;;AAAA,mCAEiB;AAoBf,sFArBkB,aAAK,OAqBlB;AACmE,4FAtB/C,mBAAW,OAsB+C;AAAE,6FAtB/C,oBAAY,OAsB+C;AApBnG,uCAEmB;AAiBV,wFAlBP,iBAAO,OAkBO;AAEA,iGApBL,0BAAgB,OAoBK;AAA9B,6FApB2B,sBAAY,OAoB3B;AAlBd,mCAAqD;AAgBnC,sFAhBT,aAAK,OAgBS;AAEgD,oGAlBvD,2BAAmB,OAkBuD;AAjB1F,yCAAsC;AAeb,yFAfhB,mBAAQ,OAegB;AAdjC,mDAA+C;AAcI,6FAd1C,4BAAY,OAc0C;AAb/D,uCAEmB;AAW8C,wFAZ/D,iBAAO,OAY+D;AACtD,8FAbP,uBAAa,OAaO;AAA7B,+FAbwB,wBAAc,OAaxB;AAD0D,qGAZhC,8BAAoB,OAYgC;AAV9F,iCAA8B;AAWG,qFAXxB,WAAI,OAWwB;AAVrC,yDAAqD;AAUd,gGAV9B,kCAAe,OAU8B;AATtD,iDAA6C;AAU+C,4FAVnF,0BAAW,OAUmF;AATvG,uDAAmD;AAOhB,+FAP1B,gCAAc,OAO0B;AALpC,QAAA,QAAQ,GAAG;IACtB,aAAK,EAAE,iBAAO,EAAE,aAAK,EAAE,iBAAO,EAAE,WAAI;CACrC,CAAC","sourcesContent":["import {\n StoreQueueConfig, Store, CountryEnum, PriorityEnum,\n} from './store';\nimport {\n Product, UpdateReasonEnum, CurrencyEnum, ProductAttributes, ConditionalPrice,\n} from './product';\nimport { Price, MeasurementUnitEnum } from './price';\nimport { Category } from './category';\nimport { AbstractBase } from './abstract-base';\nimport {\n Keyword, CATEGORY_ENUM, CONDITION_ENUM, CONDITION_FIELD_ENUM,\n} from './keyword';\nimport { User } from './user';\nimport { AlertConditions } from './alert-conditions';\nimport { PricesStats } from './prices-stats';\nimport { CategoryEntity } from './category-entity';\n\nexport const Entities = [\n Store, Product, Price, Keyword, User,\n];\n\nexport {\n Store, Product, Price, Category, CategoryEntity, AbstractBase, Keyword, CONDITION_FIELD_ENUM,\n CONDITION_ENUM, CATEGORY_ENUM, User, AlertConditions, StoreQueueConfig, CountryEnum, PriorityEnum,\n CurrencyEnum, UpdateReasonEnum, ConditionalPrice, ProductAttributes, MeasurementUnitEnum, PricesStats,\n};\n"]}
|
|
@@ -8,13 +8,28 @@ export declare enum CONDITION_ENUM {
|
|
|
8
8
|
export declare enum CONDITION_FIELD_ENUM {
|
|
9
9
|
CATEGORY_PATH = "categoryPath",
|
|
10
10
|
CATEGORY = "category",
|
|
11
|
-
PRODUCT_NAME = "name"
|
|
11
|
+
PRODUCT_NAME = "name",
|
|
12
|
+
STORE_REF = "storeRef",
|
|
13
|
+
STORE_NAME = "storeName"
|
|
12
14
|
}
|
|
13
15
|
export declare enum CATEGORY_ENUM {
|
|
14
16
|
NOTEBOOKS = "NOTEBOOKS",
|
|
15
17
|
NOTEBOOKS_MACBOOK = "NOTEBOOKS_MACBOOK",
|
|
18
|
+
NOTEBOOKS_M1 = "NOTEBOOKS_M1",
|
|
19
|
+
NOTEBOOKS_RYZEN = "NOTEBOOKS_RYZEN",
|
|
20
|
+
NOTEBOOKS_INTEL = "NOTEBOOKS_INTEL",
|
|
21
|
+
NOTEBOOKS_GAMER = "NOTEBOOKS_GAMER",
|
|
22
|
+
NOTEBOOKS_ACCESSORIES = "NOTEBOOKS_ACCESSORIES",
|
|
23
|
+
COMPUTERS = "COMPUTERS",
|
|
24
|
+
COMPUTERS_MONITOR = "COMPUTERS_MONITOR",
|
|
16
25
|
SMARTPHONES = "SMARTPHONES",
|
|
17
26
|
SMARTPHONES_IPHONE = "SMARTPHONES_IPHONE",
|
|
27
|
+
SMARTPHONES_SAMSUNG = "SMARTPHONES_SAMSUNG",
|
|
28
|
+
SMARTPHONES_HUAWEI = "SMARTPHONES_HUAWEI",
|
|
29
|
+
SMARTPHONES_XIOAMI = "SMARTPHONES_XIAOMI",
|
|
30
|
+
SMARTPHONES_OPPO = "SMARTPHONES_OPPO",
|
|
31
|
+
SMARTPHONES_VIVO = "SMARTPHONES_VIVO",
|
|
32
|
+
SMARTPHONES_ACCESSORIES = "SMARTPHONES_ACCESSORIES",
|
|
18
33
|
SMARTWATCHES = "SMARTWATCHES",
|
|
19
34
|
TABLETS = "TABLETS",
|
|
20
35
|
TV = "TV",
|
|
@@ -27,6 +42,7 @@ export declare enum CATEGORY_ENUM {
|
|
|
27
42
|
HEATING = "HEATING",
|
|
28
43
|
KITCHEN = "KITCHEN",
|
|
29
44
|
GAMES = "GAMES",
|
|
45
|
+
TOYS = "TOYS",
|
|
30
46
|
DRINKABLE = "DRINKABLE",
|
|
31
47
|
DRINKABLE_WHISKY = "DRINKABLE_WHISKY",
|
|
32
48
|
DRINKABLE_BEER = "DRINKABLE_BEER",
|
|
@@ -39,7 +55,28 @@ export declare enum CATEGORY_ENUM {
|
|
|
39
55
|
DRINKABLE_PISCO = "DRINKABLE_PISCO",
|
|
40
56
|
DORMITORY = "DORMITORY",
|
|
41
57
|
PHOTOGRAPHY = "PHOTOGRAPHY",
|
|
58
|
+
PHOTOGRAPHY_CAMERAS = "PHOTOGRAPHY_CAMERAS",
|
|
59
|
+
PHOTOGRAPHY_ACCESORIES = "PHOTOGRAPHY_ACCESORIES",
|
|
42
60
|
HEADPHONES = "HEADPHONES",
|
|
61
|
+
HEADPHONES_ACCESORIES = "HEADPHONES_ACCESORIES",
|
|
62
|
+
TOOLS = "TOOLS",
|
|
63
|
+
SPORTS = "SPORTS",
|
|
64
|
+
BIKES = "BIKES",
|
|
65
|
+
SNEAKERS = "SNEAKERS",
|
|
66
|
+
SHOES = "SHOES",
|
|
67
|
+
CLOTHING = "CLOTHING",
|
|
68
|
+
BABY = "BABY",
|
|
69
|
+
MUSICAL_INSTRUMENTS = "MUSICAL_INSTRUMENTS",
|
|
70
|
+
MUSICAL_INSTRUMENTS_GUITAR = "MUSICAL_INSTRUMENTS_GUITAR",
|
|
71
|
+
MUSICAL_INSTRUMENTS_BASS = "MUSICAL_INSTRUMENTS_BASS",
|
|
72
|
+
MUSICAL_INSTRUMENTS_STRINGS = "MUSICAL_INSTRUMENTS_STRINGS",
|
|
73
|
+
MUSICAL_INSTRUMENTS_PERCUSION = "MUSICAL_INSTRUMENTS_PERCUSION",
|
|
74
|
+
PATIO_AND_GARDEN = "PATIO_AND_GARDEN",
|
|
75
|
+
GROCERY = "GROCERY",
|
|
76
|
+
PHARMACY = "PHARMACY",
|
|
77
|
+
BEAUTY = "BEAUTY",
|
|
78
|
+
PERSONAL_CARE = "PERSONAL_CARE",
|
|
79
|
+
BOOKS = "BOOKS",
|
|
43
80
|
CATEGORY_NOT_FOUND = "CATEGORY_NOT_FOUND"
|
|
44
81
|
}
|
|
45
82
|
export declare class Keyword extends AbstractBase {
|
package/dist/entities/keyword.js
CHANGED
|
@@ -24,13 +24,28 @@ var CONDITION_FIELD_ENUM;
|
|
|
24
24
|
CONDITION_FIELD_ENUM["CATEGORY_PATH"] = "categoryPath";
|
|
25
25
|
CONDITION_FIELD_ENUM["CATEGORY"] = "category";
|
|
26
26
|
CONDITION_FIELD_ENUM["PRODUCT_NAME"] = "name";
|
|
27
|
+
CONDITION_FIELD_ENUM["STORE_REF"] = "storeRef";
|
|
28
|
+
CONDITION_FIELD_ENUM["STORE_NAME"] = "storeName";
|
|
27
29
|
})(CONDITION_FIELD_ENUM = exports.CONDITION_FIELD_ENUM || (exports.CONDITION_FIELD_ENUM = {}));
|
|
28
30
|
var CATEGORY_ENUM;
|
|
29
31
|
(function (CATEGORY_ENUM) {
|
|
30
32
|
CATEGORY_ENUM["NOTEBOOKS"] = "NOTEBOOKS";
|
|
31
33
|
CATEGORY_ENUM["NOTEBOOKS_MACBOOK"] = "NOTEBOOKS_MACBOOK";
|
|
34
|
+
CATEGORY_ENUM["NOTEBOOKS_M1"] = "NOTEBOOKS_M1";
|
|
35
|
+
CATEGORY_ENUM["NOTEBOOKS_RYZEN"] = "NOTEBOOKS_RYZEN";
|
|
36
|
+
CATEGORY_ENUM["NOTEBOOKS_INTEL"] = "NOTEBOOKS_INTEL";
|
|
37
|
+
CATEGORY_ENUM["NOTEBOOKS_GAMER"] = "NOTEBOOKS_GAMER";
|
|
38
|
+
CATEGORY_ENUM["NOTEBOOKS_ACCESSORIES"] = "NOTEBOOKS_ACCESSORIES";
|
|
39
|
+
CATEGORY_ENUM["COMPUTERS"] = "COMPUTERS";
|
|
40
|
+
CATEGORY_ENUM["COMPUTERS_MONITOR"] = "COMPUTERS_MONITOR";
|
|
32
41
|
CATEGORY_ENUM["SMARTPHONES"] = "SMARTPHONES";
|
|
33
42
|
CATEGORY_ENUM["SMARTPHONES_IPHONE"] = "SMARTPHONES_IPHONE";
|
|
43
|
+
CATEGORY_ENUM["SMARTPHONES_SAMSUNG"] = "SMARTPHONES_SAMSUNG";
|
|
44
|
+
CATEGORY_ENUM["SMARTPHONES_HUAWEI"] = "SMARTPHONES_HUAWEI";
|
|
45
|
+
CATEGORY_ENUM["SMARTPHONES_XIOAMI"] = "SMARTPHONES_XIAOMI";
|
|
46
|
+
CATEGORY_ENUM["SMARTPHONES_OPPO"] = "SMARTPHONES_OPPO";
|
|
47
|
+
CATEGORY_ENUM["SMARTPHONES_VIVO"] = "SMARTPHONES_VIVO";
|
|
48
|
+
CATEGORY_ENUM["SMARTPHONES_ACCESSORIES"] = "SMARTPHONES_ACCESSORIES";
|
|
34
49
|
CATEGORY_ENUM["SMARTWATCHES"] = "SMARTWATCHES";
|
|
35
50
|
CATEGORY_ENUM["TABLETS"] = "TABLETS";
|
|
36
51
|
CATEGORY_ENUM["TV"] = "TV";
|
|
@@ -43,6 +58,7 @@ var CATEGORY_ENUM;
|
|
|
43
58
|
CATEGORY_ENUM["HEATING"] = "HEATING";
|
|
44
59
|
CATEGORY_ENUM["KITCHEN"] = "KITCHEN";
|
|
45
60
|
CATEGORY_ENUM["GAMES"] = "GAMES";
|
|
61
|
+
CATEGORY_ENUM["TOYS"] = "TOYS";
|
|
46
62
|
CATEGORY_ENUM["DRINKABLE"] = "DRINKABLE";
|
|
47
63
|
CATEGORY_ENUM["DRINKABLE_WHISKY"] = "DRINKABLE_WHISKY";
|
|
48
64
|
CATEGORY_ENUM["DRINKABLE_BEER"] = "DRINKABLE_BEER";
|
|
@@ -55,7 +71,28 @@ var CATEGORY_ENUM;
|
|
|
55
71
|
CATEGORY_ENUM["DRINKABLE_PISCO"] = "DRINKABLE_PISCO";
|
|
56
72
|
CATEGORY_ENUM["DORMITORY"] = "DORMITORY";
|
|
57
73
|
CATEGORY_ENUM["PHOTOGRAPHY"] = "PHOTOGRAPHY";
|
|
74
|
+
CATEGORY_ENUM["PHOTOGRAPHY_CAMERAS"] = "PHOTOGRAPHY_CAMERAS";
|
|
75
|
+
CATEGORY_ENUM["PHOTOGRAPHY_ACCESORIES"] = "PHOTOGRAPHY_ACCESORIES";
|
|
58
76
|
CATEGORY_ENUM["HEADPHONES"] = "HEADPHONES";
|
|
77
|
+
CATEGORY_ENUM["HEADPHONES_ACCESORIES"] = "HEADPHONES_ACCESORIES";
|
|
78
|
+
CATEGORY_ENUM["TOOLS"] = "TOOLS";
|
|
79
|
+
CATEGORY_ENUM["SPORTS"] = "SPORTS";
|
|
80
|
+
CATEGORY_ENUM["BIKES"] = "BIKES";
|
|
81
|
+
CATEGORY_ENUM["SNEAKERS"] = "SNEAKERS";
|
|
82
|
+
CATEGORY_ENUM["SHOES"] = "SHOES";
|
|
83
|
+
CATEGORY_ENUM["CLOTHING"] = "CLOTHING";
|
|
84
|
+
CATEGORY_ENUM["BABY"] = "BABY";
|
|
85
|
+
CATEGORY_ENUM["MUSICAL_INSTRUMENTS"] = "MUSICAL_INSTRUMENTS";
|
|
86
|
+
CATEGORY_ENUM["MUSICAL_INSTRUMENTS_GUITAR"] = "MUSICAL_INSTRUMENTS_GUITAR";
|
|
87
|
+
CATEGORY_ENUM["MUSICAL_INSTRUMENTS_BASS"] = "MUSICAL_INSTRUMENTS_BASS";
|
|
88
|
+
CATEGORY_ENUM["MUSICAL_INSTRUMENTS_STRINGS"] = "MUSICAL_INSTRUMENTS_STRINGS";
|
|
89
|
+
CATEGORY_ENUM["MUSICAL_INSTRUMENTS_PERCUSION"] = "MUSICAL_INSTRUMENTS_PERCUSION";
|
|
90
|
+
CATEGORY_ENUM["PATIO_AND_GARDEN"] = "PATIO_AND_GARDEN";
|
|
91
|
+
CATEGORY_ENUM["GROCERY"] = "GROCERY";
|
|
92
|
+
CATEGORY_ENUM["PHARMACY"] = "PHARMACY";
|
|
93
|
+
CATEGORY_ENUM["BEAUTY"] = "BEAUTY";
|
|
94
|
+
CATEGORY_ENUM["PERSONAL_CARE"] = "PERSONAL_CARE";
|
|
95
|
+
CATEGORY_ENUM["BOOKS"] = "BOOKS";
|
|
59
96
|
CATEGORY_ENUM["CATEGORY_NOT_FOUND"] = "CATEGORY_NOT_FOUND";
|
|
60
97
|
})(CATEGORY_ENUM = exports.CATEGORY_ENUM || (exports.CATEGORY_ENUM = {}));
|
|
61
98
|
let Keyword = class Keyword extends abstract_base_1.AbstractBase {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyword.js","sourceRoot":"/","sources":["entities/keyword.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAyC;AACzC,mDAA+C;AAE/C,IAAY,cAKX;AALD,WAAY,cAAc;IACtB,4CAA0B,CAAA;IAC1B,wCAAsB,CAAA;IACtB,uCAAqB,CAAA;IACrB,mCAAiB,CAAA;AACrB,CAAC,EALW,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAKzB;AAED,IAAY,
|
|
1
|
+
{"version":3,"file":"keyword.js","sourceRoot":"/","sources":["entities/keyword.ts"],"names":[],"mappings":"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","sourcesContent":["import { Column, Entity } from 'typeorm';\nimport { AbstractBase } from './abstract-base';\n\nexport enum CONDITION_ENUM {\n STARTS_WITH = 'startsWith',\n ENDS_WITH = 'endsWith',\n INCLUDES = 'includes',\n EQUALS = 'equals'\n}\n\nexport enum CONDITION_FIELD_ENUM {\n CATEGORY_PATH = 'categoryPath',\n CATEGORY = 'category',\n PRODUCT_NAME = 'name',\n STORE_REF = 'storeRef',\n STORE_NAME = 'storeName',\n}\n\nexport enum CATEGORY_ENUM {\n NOTEBOOKS = 'NOTEBOOKS',\n NOTEBOOKS_MACBOOK = 'NOTEBOOKS_MACBOOK',\n NOTEBOOKS_M1 = 'NOTEBOOKS_M1',\n NOTEBOOKS_RYZEN = 'NOTEBOOKS_RYZEN',\n NOTEBOOKS_INTEL = 'NOTEBOOKS_INTEL',\n NOTEBOOKS_GAMER = 'NOTEBOOKS_GAMER',\n\n NOTEBOOKS_ACCESSORIES = 'NOTEBOOKS_ACCESSORIES',\n\n COMPUTERS = 'COMPUTERS',\n COMPUTERS_MONITOR = 'COMPUTERS_MONITOR',\n\n SMARTPHONES = 'SMARTPHONES',\n SMARTPHONES_IPHONE = 'SMARTPHONES_IPHONE',\n SMARTPHONES_SAMSUNG = 'SMARTPHONES_SAMSUNG',\n SMARTPHONES_HUAWEI = 'SMARTPHONES_HUAWEI',\n SMARTPHONES_XIOAMI = 'SMARTPHONES_XIAOMI',\n SMARTPHONES_OPPO = 'SMARTPHONES_OPPO',\n SMARTPHONES_VIVO = 'SMARTPHONES_VIVO',\n\n SMARTPHONES_ACCESSORIES = 'SMARTPHONES_ACCESSORIES',\n\n SMARTWATCHES = 'SMARTWATCHES',\n TABLETS = 'TABLETS',\n\n TV = 'TV',\n AUDIO = 'AUDIO',\n\n FRIDGES = 'FRIDGES',\n WASHERS = 'WASHERS',\n DRYERS = 'DRYERS',\n WASHERS_DRYERS = 'WASHERS_DRYERS',\n AIR_CONDITIONING = 'AIR_CONDITIONING',\n HEATING = 'HEATING',\n KITCHEN = 'KITCHEN',\n\n GAMES = 'GAMES',\n TOYS = 'TOYS',\n\n DRINKABLE = 'DRINKABLE',\n DRINKABLE_WHISKY = 'DRINKABLE_WHISKY',\n DRINKABLE_BEER = 'DRINKABLE_BEER',\n DRINKABLE_WINE = 'DRINKABLE_WINE',\n DRINKABLE_VODKA = 'DRINKABLE_VODKA',\n DRINKABLE_COGNAC = 'DRINKABLE_COGNAC',\n DRINKABLE_GIN = 'DRINKABLE_GIN',\n DRINKABLE_TEQUILA = 'DRINKABLE_TEQUILA',\n DRINKABLE_RUM = 'DRINKABLE_RUM',\n DRINKABLE_PISCO = 'DRINKABLE_PISCO',\n\n DORMITORY = 'DORMITORY',\n\n PHOTOGRAPHY = 'PHOTOGRAPHY',\n PHOTOGRAPHY_CAMERAS = 'PHOTOGRAPHY_CAMERAS',\n PHOTOGRAPHY_ACCESORIES = 'PHOTOGRAPHY_ACCESORIES',\n\n HEADPHONES = 'HEADPHONES',\n HEADPHONES_ACCESORIES = 'HEADPHONES_ACCESORIES',\n\n TOOLS = 'TOOLS',\n\n SPORTS = 'SPORTS',\n\n BIKES = 'BIKES',\n\n SNEAKERS = 'SNEAKERS',\n SHOES = 'SHOES',\n\n CLOTHING = 'CLOTHING',\n\n BABY = 'BABY',\n\n MUSICAL_INSTRUMENTS = 'MUSICAL_INSTRUMENTS',\n MUSICAL_INSTRUMENTS_GUITAR = 'MUSICAL_INSTRUMENTS_GUITAR',\n MUSICAL_INSTRUMENTS_BASS = 'MUSICAL_INSTRUMENTS_BASS',\n MUSICAL_INSTRUMENTS_STRINGS = 'MUSICAL_INSTRUMENTS_STRINGS',\n MUSICAL_INSTRUMENTS_PERCUSION = 'MUSICAL_INSTRUMENTS_PERCUSION',\n\n PATIO_AND_GARDEN = 'PATIO_AND_GARDEN',\n\n GROCERY = 'GROCERY',\n\n PHARMACY = 'PHARMACY',\n\n BEAUTY = 'BEAUTY',\n PERSONAL_CARE = 'PERSONAL_CARE',\n\n BOOKS = 'BOOKS',\n\n CATEGORY_NOT_FOUND = 'CATEGORY_NOT_FOUND'\n}\n\n@Entity({ name: 'keywords' })\nexport class Keyword extends AbstractBase {\n @Column()\n category: CATEGORY_ENUM;\n\n @Column()\n keyword?: string;\n\n @Column()\n condition?: CONDITION_ENUM;\n\n @Column()\n field?: CONDITION_FIELD_ENUM;\n\n @Column()\n splitBy?: string;\n\n @Column()\n evalLastItem?: boolean;\n\n @Column()\n trim?: boolean;\n\n @Column()\n parentRef?: string;\n\n @Column()\n excludeWords: string[];\n}\n"]}
|
package/dist/entities/price.d.ts
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
import { AbstractBase } from './abstract-base';
|
|
2
|
+
export declare enum MeasurementUnitEnum {
|
|
3
|
+
KG = "kg",
|
|
4
|
+
G = "g",
|
|
5
|
+
L = "l",
|
|
6
|
+
ML = "ml",
|
|
7
|
+
UNIT = "unit"
|
|
8
|
+
}
|
|
2
9
|
export declare class Price extends AbstractBase {
|
|
3
10
|
productRef: string;
|
|
4
11
|
normalPrice?: number;
|
|
5
12
|
offerPrice?: number;
|
|
6
13
|
cardPrice?: number;
|
|
7
14
|
sourceUrl?: string;
|
|
15
|
+
unitMultiplier?: number;
|
|
16
|
+
measurementUnit?: MeasurementUnitEnum;
|
|
8
17
|
createdAt?: Date;
|
|
9
18
|
}
|
package/dist/entities/price.js
CHANGED
|
@@ -9,10 +9,18 @@ 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
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.Price = void 0;
|
|
12
|
+
exports.Price = exports.MeasurementUnitEnum = void 0;
|
|
13
13
|
const typeorm_1 = require("typeorm");
|
|
14
14
|
const class_validator_1 = require("class-validator");
|
|
15
15
|
const abstract_base_1 = require("./abstract-base");
|
|
16
|
+
var MeasurementUnitEnum;
|
|
17
|
+
(function (MeasurementUnitEnum) {
|
|
18
|
+
MeasurementUnitEnum["KG"] = "kg";
|
|
19
|
+
MeasurementUnitEnum["G"] = "g";
|
|
20
|
+
MeasurementUnitEnum["L"] = "l";
|
|
21
|
+
MeasurementUnitEnum["ML"] = "ml";
|
|
22
|
+
MeasurementUnitEnum["UNIT"] = "unit";
|
|
23
|
+
})(MeasurementUnitEnum = exports.MeasurementUnitEnum || (exports.MeasurementUnitEnum = {}));
|
|
16
24
|
let Price = class Price extends abstract_base_1.AbstractBase {
|
|
17
25
|
};
|
|
18
26
|
__decorate([
|
|
@@ -44,6 +52,16 @@ __decorate([
|
|
|
44
52
|
class_validator_1.IsOptional(),
|
|
45
53
|
__metadata("design:type", String)
|
|
46
54
|
], Price.prototype, "sourceUrl", void 0);
|
|
55
|
+
__decorate([
|
|
56
|
+
typeorm_1.Column(),
|
|
57
|
+
class_validator_1.IsOptional(),
|
|
58
|
+
__metadata("design:type", Number)
|
|
59
|
+
], Price.prototype, "unitMultiplier", void 0);
|
|
60
|
+
__decorate([
|
|
61
|
+
typeorm_1.Column(),
|
|
62
|
+
class_validator_1.IsOptional(),
|
|
63
|
+
__metadata("design:type", String)
|
|
64
|
+
], Price.prototype, "measurementUnit", void 0);
|
|
47
65
|
__decorate([
|
|
48
66
|
typeorm_1.CreateDateColumn(),
|
|
49
67
|
typeorm_1.Index(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"price.js","sourceRoot":"/","sources":["entities/price.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAEiB;AACjB,qDAAmE;AACnE,mDAA+C;
|
|
1
|
+
{"version":3,"file":"price.js","sourceRoot":"/","sources":["entities/price.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAEiB;AACjB,qDAAmE;AACnE,mDAA+C;AAE/C,IAAY,mBAMX;AAND,WAAY,mBAAmB;IAC3B,gCAAS,CAAA;IACT,8BAAO,CAAA;IACP,8BAAO,CAAA;IACP,gCAAS,CAAA;IACT,oCAAa,CAAA;AACjB,CAAC,EANW,mBAAmB,GAAnB,2BAAmB,KAAnB,2BAAmB,QAM9B;AAGD,IAAa,KAAK,GAAlB,MAAa,KAAM,SAAQ,4BAAY;CAoCtC,CAAA;AAhCG;IAHC,gBAAM,EAAE;IACR,4BAAU,EAAE;IACZ,eAAK,EAAE;;yCACW;AAKnB;IAHC,gBAAM,EAAE;IACR,0BAAQ,EAAE;IACV,4BAAU,EAAE;;0CACQ;AAKrB;IAHC,gBAAM,EAAE;IACR,0BAAQ,EAAE;IACV,4BAAU,EAAE;;yCACO;AAKpB;IAHC,gBAAM,EAAE;IACR,0BAAQ,EAAE;IACV,4BAAU,EAAE;;wCACM;AAInB;IAFC,gBAAM,EAAE;IACR,4BAAU,EAAE;;wCACM;AAInB;IAFC,gBAAM,EAAE;IACR,4BAAU,EAAE;;6CACW;AAIxB;IAFC,gBAAM,EAAE;IACR,4BAAU,EAAE;;8CACyB;AAItC;IAFC,0BAAgB,EAAE;IAClB,eAAK,EAAE;8BACI,IAAI;wCAAC;AAnCR,KAAK;IADjB,gBAAM,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;GACd,KAAK,CAoCjB;AApCY,sBAAK","sourcesContent":["import {\n Column, CreateDateColumn, Entity, Index,\n} from 'typeorm';\nimport { IsNotEmpty, IsNumber, IsOptional } from 'class-validator';\nimport { AbstractBase } from './abstract-base';\n\nexport enum MeasurementUnitEnum {\n KG = 'kg',\n G = 'g',\n L = 'l',\n ML = 'ml',\n UNIT = 'unit'\n}\n\n@Entity({ name: 'prices' })\nexport class Price extends AbstractBase {\n @Column()\n @IsNotEmpty()\n @Index()\n productRef: string;\n\n @Column()\n @IsNumber()\n @IsOptional()\n normalPrice?: number;\n\n @Column()\n @IsNumber()\n @IsOptional()\n offerPrice?: number;\n\n @Column()\n @IsNumber()\n @IsOptional()\n cardPrice?: number;\n\n @Column()\n @IsOptional()\n sourceUrl?: string;\n\n @Column()\n @IsOptional()\n unitMultiplier?: number;\n\n @Column()\n @IsOptional()\n measurementUnit?: MeasurementUnitEnum;\n\n @CreateDateColumn()\n @Index()\n createdAt?: Date;\n}\n"]}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { checkIfSamePrices, isCheaper, getMinPrice, isValidPrice, getAvgPrice, getMaxPrice, getPriceOperation, removeZeroPrices } from './price-utils';
|
|
1
|
+
import { checkIfSamePrices, isCheaper, getMinPrice, isValidPrice, getAvgPrice, getMaxPrice, getPriceOperation, removeZeroPrices, hasMeasurementUnitMultiplier, getPriceByMeasurementUnitMultiplier } from './price-utils';
|
|
2
2
|
import { findLastQuery } from './entity-queries-utils';
|
|
3
3
|
import { reverseString, removeNewLines, includesStringArray, getLastAfter, replaceMultipleSpacesByOne, removeIfEndsWith } from './string-utils';
|
|
4
4
|
import { isUrl, getHostname, getParam, getPathname } from './url-utils';
|
|
5
5
|
import { calculateAverage, roundNumber } from './number-utils';
|
|
6
|
-
export { checkIfSamePrices, findLastQuery, replaceMultipleSpacesByOne, removeIfEndsWith, getLastAfter, includesStringArray, removeNewLines, reverseString, getParam, getPathname, getHostname, isUrl, isValidPrice, getMinPrice, isCheaper, getMaxPrice, getPriceOperation, getAvgPrice, calculateAverage, roundNumber, removeZeroPrices, };
|
|
6
|
+
export { checkIfSamePrices, findLastQuery, replaceMultipleSpacesByOne, hasMeasurementUnitMultiplier, getPriceByMeasurementUnitMultiplier, removeIfEndsWith, getLastAfter, includesStringArray, removeNewLines, reverseString, getParam, getPathname, getHostname, isUrl, isValidPrice, getMinPrice, isCheaper, getMaxPrice, getPriceOperation, getAvgPrice, calculateAverage, roundNumber, removeZeroPrices, };
|
package/dist/utils/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.removeZeroPrices = exports.roundNumber = exports.calculateAverage = exports.getAvgPrice = exports.getPriceOperation = exports.getMaxPrice = exports.isCheaper = exports.getMinPrice = exports.isValidPrice = exports.isUrl = exports.getHostname = exports.getPathname = exports.getParam = exports.reverseString = exports.removeNewLines = exports.includesStringArray = exports.getLastAfter = exports.removeIfEndsWith = exports.replaceMultipleSpacesByOne = exports.findLastQuery = exports.checkIfSamePrices = void 0;
|
|
3
|
+
exports.removeZeroPrices = exports.roundNumber = exports.calculateAverage = exports.getAvgPrice = exports.getPriceOperation = exports.getMaxPrice = exports.isCheaper = exports.getMinPrice = exports.isValidPrice = exports.isUrl = exports.getHostname = exports.getPathname = exports.getParam = exports.reverseString = exports.removeNewLines = exports.includesStringArray = exports.getLastAfter = exports.removeIfEndsWith = exports.getPriceByMeasurementUnitMultiplier = exports.hasMeasurementUnitMultiplier = exports.replaceMultipleSpacesByOne = exports.findLastQuery = exports.checkIfSamePrices = void 0;
|
|
4
4
|
const price_utils_1 = require("./price-utils");
|
|
5
5
|
Object.defineProperty(exports, "checkIfSamePrices", { enumerable: true, get: function () { return price_utils_1.checkIfSamePrices; } });
|
|
6
6
|
Object.defineProperty(exports, "isCheaper", { enumerable: true, get: function () { return price_utils_1.isCheaper; } });
|
|
@@ -10,6 +10,8 @@ Object.defineProperty(exports, "getAvgPrice", { enumerable: true, get: function
|
|
|
10
10
|
Object.defineProperty(exports, "getMaxPrice", { enumerable: true, get: function () { return price_utils_1.getMaxPrice; } });
|
|
11
11
|
Object.defineProperty(exports, "getPriceOperation", { enumerable: true, get: function () { return price_utils_1.getPriceOperation; } });
|
|
12
12
|
Object.defineProperty(exports, "removeZeroPrices", { enumerable: true, get: function () { return price_utils_1.removeZeroPrices; } });
|
|
13
|
+
Object.defineProperty(exports, "hasMeasurementUnitMultiplier", { enumerable: true, get: function () { return price_utils_1.hasMeasurementUnitMultiplier; } });
|
|
14
|
+
Object.defineProperty(exports, "getPriceByMeasurementUnitMultiplier", { enumerable: true, get: function () { return price_utils_1.getPriceByMeasurementUnitMultiplier; } });
|
|
13
15
|
const entity_queries_utils_1 = require("./entity-queries-utils");
|
|
14
16
|
Object.defineProperty(exports, "findLastQuery", { enumerable: true, get: function () { return entity_queries_utils_1.findLastQuery; } });
|
|
15
17
|
const string_utils_1 = require("./string-utils");
|
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["utils/index.ts"],"names":[],"mappings":";;;AAAA,+
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["utils/index.ts"],"names":[],"mappings":";;;AAAA,+CAGuB;AAcrB,kGAhBA,+BAAiB,OAgBA;AAE8B,0FAlB5B,uBAAS,OAkB4B;AAAtB,4FAlBJ,yBAAW,OAkBI;AAAzB,6FAlBuB,0BAAY,OAkBvB;AAA0D,4FAlBjC,yBAAW,OAkBiC;AAA3C,4FAlBY,yBAAW,OAkBZ;AAAE,kGAlBY,+BAAiB,OAkBZ;AAC3E,iGAnByF,8BAAgB,OAmBzF;AAHiC,6GAf9D,0CAA4B,OAe8D;AAAE,oHAf9D,iDAAmC,OAe8D;AAbjI,iEAAuD;AAalC,8FAbZ,oCAAa,OAaY;AAZlC,iDAGwB;AAU+C,8FAZrE,4BAAa,OAYqE;AAA7B,+FAZtC,6BAAc,OAYsC;AAAnC,oGAZD,kCAAmB,OAYC;AAAjC,6FAZkC,2BAAY,OAYlC;AADI,2GAXgC,yCAA0B,OAWhC;AAC5D,iGAZ8F,+BAAgB,OAY9F;AATlB,2CAEqB;AAQN,sFATb,iBAAK,OASa;AAAlB,4FATO,uBAAW,OASP;AADyE,yFARhE,oBAAQ,OAQgE;AAAE,4FARhE,uBAAW,OAQgE;AAN3G,iDAEwB;AAKiF,iGANvG,+BAAgB,OAMuG;AACvH,4FAPkB,0BAAW,OAOlB","sourcesContent":["import {\n checkIfSamePrices, isCheaper, getMinPrice, isValidPrice, getAvgPrice, getMaxPrice, getPriceOperation, removeZeroPrices,\n hasMeasurementUnitMultiplier, getPriceByMeasurementUnitMultiplier,\n} from './price-utils';\nimport { findLastQuery } from './entity-queries-utils';\nimport {\n reverseString, removeNewLines, includesStringArray, getLastAfter, replaceMultipleSpacesByOne, removeIfEndsWith,\n}\n from './string-utils';\nimport {\n isUrl, getHostname, getParam, getPathname,\n} from './url-utils';\nimport {\n calculateAverage, roundNumber,\n} from './number-utils';\n\nexport {\n checkIfSamePrices, findLastQuery, replaceMultipleSpacesByOne, hasMeasurementUnitMultiplier, getPriceByMeasurementUnitMultiplier,\n removeIfEndsWith, getLastAfter, includesStringArray, removeNewLines, reverseString, getParam, getPathname,\n getHostname, isUrl, isValidPrice, getMinPrice, isCheaper, getMaxPrice, getPriceOperation, getAvgPrice, calculateAverage,\n roundNumber, removeZeroPrices,\n};\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Price } from '../entities';
|
|
2
|
+
export declare const hasMeasurementUnitMultiplier: (price: Price) => boolean;
|
|
2
3
|
export declare const checkIfSamePrices: (_price: Price, _price2: Price) => boolean;
|
|
3
4
|
export declare const isValidPrice: (price: Price) => boolean;
|
|
4
5
|
export declare const removeZeroPrices: (price: Price) => Price;
|
|
@@ -6,4 +7,5 @@ export declare const getPriceOperation: (price: Price, fn: (...p: any[]) => numb
|
|
|
6
7
|
export declare const getMinPrice: (price: Price) => number;
|
|
7
8
|
export declare const getMaxPrice: (price: Price) => number;
|
|
8
9
|
export declare const getAvgPrice: (price: Price) => number;
|
|
10
|
+
export declare const getPriceByMeasurementUnitMultiplier: (price: Price, minUnit?: number) => number;
|
|
9
11
|
export declare const isCheaper: (price: Price, comparePrice: Price) => boolean | null;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isCheaper = exports.getAvgPrice = exports.getMaxPrice = exports.getMinPrice = exports.getPriceOperation = exports.removeZeroPrices = exports.isValidPrice = exports.checkIfSamePrices = void 0;
|
|
3
|
+
exports.isCheaper = exports.getPriceByMeasurementUnitMultiplier = exports.getAvgPrice = exports.getMaxPrice = exports.getMinPrice = exports.getPriceOperation = exports.removeZeroPrices = exports.isValidPrice = exports.checkIfSamePrices = exports.hasMeasurementUnitMultiplier = void 0;
|
|
4
4
|
const lodash_1 = require("lodash");
|
|
5
|
+
const entities_1 = require("../entities");
|
|
6
|
+
exports.hasMeasurementUnitMultiplier = (price) => !!price && !!price.unitMultiplier && !!price.measurementUnit;
|
|
5
7
|
exports.checkIfSamePrices = (_price, _price2) => _price && _price2 && lodash_1.isEqual(lodash_1.pickBy({ normalPrice: _price.normalPrice, offerPrice: _price.offerPrice, cardPrice: _price.cardPrice }, lodash_1.identity), lodash_1.pickBy({ normalPrice: _price2.normalPrice, offerPrice: _price2.offerPrice, cardPrice: _price2.cardPrice }, lodash_1.identity));
|
|
6
8
|
exports.isValidPrice = (price) => !(!price || (!price.normalPrice && !price.cardPrice && !price.offerPrice));
|
|
7
9
|
exports.removeZeroPrices = (price) => {
|
|
@@ -36,12 +38,38 @@ exports.getAvgPrice = (price) => {
|
|
|
36
38
|
};
|
|
37
39
|
return exports.getPriceOperation(price, fn);
|
|
38
40
|
};
|
|
41
|
+
exports.getPriceByMeasurementUnitMultiplier = (price, minUnit = 100) => {
|
|
42
|
+
if (!exports.hasMeasurementUnitMultiplier(price)) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
const { measurementUnit, unitMultiplier } = price;
|
|
46
|
+
const minPrice = exports.getMinPrice(price);
|
|
47
|
+
let value;
|
|
48
|
+
if ([entities_1.MeasurementUnitEnum.KG, entities_1.MeasurementUnitEnum.L].includes(measurementUnit)) {
|
|
49
|
+
const grams = unitMultiplier * 1000;
|
|
50
|
+
value = (minPrice / grams) * minUnit;
|
|
51
|
+
}
|
|
52
|
+
else if ([entities_1.MeasurementUnitEnum.G, entities_1.MeasurementUnitEnum.ML].includes(measurementUnit)) {
|
|
53
|
+
value = (minPrice / unitMultiplier) * minUnit;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
value = minPrice * unitMultiplier;
|
|
57
|
+
}
|
|
58
|
+
return value ? Math.round(value) : null;
|
|
59
|
+
};
|
|
39
60
|
exports.isCheaper = (price, comparePrice) => {
|
|
40
61
|
if (!exports.isValidPrice(price) || !exports.isValidPrice(comparePrice)) {
|
|
41
62
|
return null;
|
|
42
63
|
}
|
|
43
64
|
const minPrice = exports.getMinPrice(price);
|
|
44
65
|
const minComparePrice = exports.getMinPrice(comparePrice);
|
|
66
|
+
if (exports.hasMeasurementUnitMultiplier(price) && exports.hasMeasurementUnitMultiplier(comparePrice)) {
|
|
67
|
+
const minPriceWithMeasurementUnit = exports.getPriceByMeasurementUnitMultiplier(price);
|
|
68
|
+
const comparePriceWithMeasurementUnit = exports.getPriceByMeasurementUnitMultiplier(comparePrice);
|
|
69
|
+
if (minPriceWithMeasurementUnit && comparePriceWithMeasurementUnit) {
|
|
70
|
+
return minPriceWithMeasurementUnit < comparePriceWithMeasurementUnit;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
45
73
|
return minPrice < minComparePrice;
|
|
46
74
|
};
|
|
47
75
|
//# sourceMappingURL=price-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"price-utils.js","sourceRoot":"/","sources":["utils/price-utils.ts"],"names":[],"mappings":";;;AAAA,mCAAmD;
|
|
1
|
+
{"version":3,"file":"price-utils.js","sourceRoot":"/","sources":["utils/price-utils.ts"],"names":[],"mappings":"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","sourcesContent":["import { identity, isEqual, pickBy } from 'lodash';\nimport { MeasurementUnitEnum, Price } from '../entities';\n\nexport const hasMeasurementUnitMultiplier = (price: Price): boolean => !!price && !!price.unitMultiplier && !!price.measurementUnit;\n\nexport const checkIfSamePrices = (_price: Price, _price2: Price): boolean => _price && _price2 && isEqual(\n pickBy({ normalPrice: _price.normalPrice, offerPrice: _price.offerPrice, cardPrice: _price.cardPrice }, identity),\n pickBy({ normalPrice: _price2.normalPrice, offerPrice: _price2.offerPrice, cardPrice: _price2.cardPrice }, identity),\n);\n\nexport const isValidPrice = (price: Price): boolean => !(!price || (!price.normalPrice && !price.cardPrice && !price.offerPrice));\n\nexport const removeZeroPrices = (price:Price): Price => {\n const removedZeroesPrice = price;\n\n if (!price.cardPrice) {\n delete removedZeroesPrice.cardPrice;\n }\n\n if (!price.normalPrice) {\n delete removedZeroesPrice.normalPrice;\n }\n\n if (!price.offerPrice) {\n delete removedZeroesPrice.offerPrice;\n }\n\n return removedZeroesPrice;\n};\n\nexport const getPriceOperation = (price: Price, fn: (...p) => number): number => {\n if (!price) {\n return null;\n }\n\n const arr = [price.normalPrice, price.offerPrice, price.cardPrice].filter((v) => v);\n if (arr.length === 0) {\n return null;\n }\n\n return fn(...arr);\n};\n\nexport const getMinPrice = (price: Price): number => getPriceOperation(price, Math.min);\n\nexport const getMaxPrice = (price: Price): number => getPriceOperation(price, Math.max);\n\nexport const getAvgPrice = (price: Price): number => {\n const fn = (...arr) => {\n const sum = arr.reduce(((previousValue, currentValue) => previousValue + currentValue));\n\n return (sum / arr.length);\n };\n\n return getPriceOperation(price, fn);\n};\n\nexport const getPriceByMeasurementUnitMultiplier = (price: Price, minUnit = 100): number => {\n if (!hasMeasurementUnitMultiplier(price)) {\n return null;\n }\n\n const { measurementUnit, unitMultiplier } = price;\n\n const minPrice = getMinPrice(price);\n\n let value;\n if ([MeasurementUnitEnum.KG, MeasurementUnitEnum.L].includes(measurementUnit)) {\n const grams = unitMultiplier * 1000;\n value = (minPrice / grams) * minUnit;\n } else if ([MeasurementUnitEnum.G, MeasurementUnitEnum.ML].includes(measurementUnit)) {\n value = (minPrice / unitMultiplier) * minUnit;\n } else {\n value = minPrice * unitMultiplier;\n }\n\n return value ? Math.round(value) : null;\n};\n\nexport const isCheaper = (price: Price, comparePrice: Price): boolean | null => {\n if (!isValidPrice(price) || !isValidPrice(comparePrice)) {\n return null;\n }\n\n const minPrice = getMinPrice(price);\n const minComparePrice = getMinPrice(comparePrice);\n\n if (hasMeasurementUnitMultiplier(price) && hasMeasurementUnitMultiplier(comparePrice)) {\n const minPriceWithMeasurementUnit = getPriceByMeasurementUnitMultiplier(price);\n const comparePriceWithMeasurementUnit = getPriceByMeasurementUnitMultiplier(comparePrice);\n\n if (minPriceWithMeasurementUnit && comparePriceWithMeasurementUnit) {\n return minPriceWithMeasurementUnit < comparePriceWithMeasurementUnit;\n }\n }\n\n return minPrice < minComparePrice;\n};\n"]}
|
package/package.json
CHANGED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Column, Entity, Index } from 'typeorm';
|
|
2
|
+
import { IsEnum } from 'class-validator';
|
|
3
|
+
import { AbstractBase } from './abstract-base';
|
|
4
|
+
import { CATEGORY_ENUM } from './keyword';
|
|
5
|
+
|
|
6
|
+
@Entity({ name: 'categories' })
|
|
7
|
+
export class CategoryEntity extends AbstractBase {
|
|
8
|
+
@Index()
|
|
9
|
+
@Column()
|
|
10
|
+
@IsEnum(CATEGORY_ENUM)
|
|
11
|
+
category: CATEGORY_ENUM;
|
|
12
|
+
|
|
13
|
+
@Column()
|
|
14
|
+
displayName?: {
|
|
15
|
+
es?: string;
|
|
16
|
+
en?: string;
|
|
17
|
+
br?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@Column()
|
|
21
|
+
subCategories?: CategoryEntity[]
|
|
22
|
+
|
|
23
|
+
@Column({ default: true, type: 'boolean' })
|
|
24
|
+
enabled = true;
|
|
25
|
+
}
|
package/src/entities/category.ts
CHANGED
|
@@ -2,9 +2,13 @@ import { Entity } from 'typeorm';
|
|
|
2
2
|
import { AbstractBase } from './abstract-base';
|
|
3
3
|
import { ObjectLiteral } from '../classes';
|
|
4
4
|
import { Product } from './product';
|
|
5
|
+
import { CATEGORY_ENUM } from './keyword';
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
// Mucho webeo cambiarle el nombre a todas las clases..
|
|
8
|
+
@Entity({ name: 'categoryMenus' })
|
|
7
9
|
export class Category extends AbstractBase {
|
|
10
|
+
category?: CATEGORY_ENUM;
|
|
11
|
+
|
|
8
12
|
name?: string;
|
|
9
13
|
|
|
10
14
|
path?: string;
|
package/src/entities/index.ts
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
Product, UpdateReasonEnum, CurrencyEnum, ProductAttributes, ConditionalPrice,
|
|
6
6
|
} from './product';
|
|
7
|
-
import { Price } from './price';
|
|
7
|
+
import { Price, MeasurementUnitEnum } from './price';
|
|
8
8
|
import { Category } from './category';
|
|
9
9
|
import { AbstractBase } from './abstract-base';
|
|
10
10
|
import {
|
|
@@ -12,13 +12,15 @@ import {
|
|
|
12
12
|
} from './keyword';
|
|
13
13
|
import { User } from './user';
|
|
14
14
|
import { AlertConditions } from './alert-conditions';
|
|
15
|
+
import { PricesStats } from './prices-stats';
|
|
16
|
+
import { CategoryEntity } from './category-entity';
|
|
15
17
|
|
|
16
18
|
export const Entities = [
|
|
17
19
|
Store, Product, Price, Keyword, User,
|
|
18
20
|
];
|
|
19
21
|
|
|
20
22
|
export {
|
|
21
|
-
Store, Product, Price, Category, AbstractBase, Keyword, CONDITION_FIELD_ENUM,
|
|
23
|
+
Store, Product, Price, Category, CategoryEntity, AbstractBase, Keyword, CONDITION_FIELD_ENUM,
|
|
22
24
|
CONDITION_ENUM, CATEGORY_ENUM, User, AlertConditions, StoreQueueConfig, CountryEnum, PriorityEnum,
|
|
23
|
-
CurrencyEnum, UpdateReasonEnum, ConditionalPrice, ProductAttributes,
|
|
25
|
+
CurrencyEnum, UpdateReasonEnum, ConditionalPrice, ProductAttributes, MeasurementUnitEnum, PricesStats,
|
|
24
26
|
};
|
package/src/entities/keyword.ts
CHANGED
|
@@ -11,20 +11,40 @@ export enum CONDITION_ENUM {
|
|
|
11
11
|
export enum CONDITION_FIELD_ENUM {
|
|
12
12
|
CATEGORY_PATH = 'categoryPath',
|
|
13
13
|
CATEGORY = 'category',
|
|
14
|
-
PRODUCT_NAME = 'name'
|
|
14
|
+
PRODUCT_NAME = 'name',
|
|
15
|
+
STORE_REF = 'storeRef',
|
|
16
|
+
STORE_NAME = 'storeName',
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
export enum CATEGORY_ENUM {
|
|
18
20
|
NOTEBOOKS = 'NOTEBOOKS',
|
|
19
21
|
NOTEBOOKS_MACBOOK = 'NOTEBOOKS_MACBOOK',
|
|
22
|
+
NOTEBOOKS_M1 = 'NOTEBOOKS_M1',
|
|
23
|
+
NOTEBOOKS_RYZEN = 'NOTEBOOKS_RYZEN',
|
|
24
|
+
NOTEBOOKS_INTEL = 'NOTEBOOKS_INTEL',
|
|
25
|
+
NOTEBOOKS_GAMER = 'NOTEBOOKS_GAMER',
|
|
26
|
+
|
|
27
|
+
NOTEBOOKS_ACCESSORIES = 'NOTEBOOKS_ACCESSORIES',
|
|
28
|
+
|
|
29
|
+
COMPUTERS = 'COMPUTERS',
|
|
30
|
+
COMPUTERS_MONITOR = 'COMPUTERS_MONITOR',
|
|
20
31
|
|
|
21
32
|
SMARTPHONES = 'SMARTPHONES',
|
|
22
33
|
SMARTPHONES_IPHONE = 'SMARTPHONES_IPHONE',
|
|
34
|
+
SMARTPHONES_SAMSUNG = 'SMARTPHONES_SAMSUNG',
|
|
35
|
+
SMARTPHONES_HUAWEI = 'SMARTPHONES_HUAWEI',
|
|
36
|
+
SMARTPHONES_XIOAMI = 'SMARTPHONES_XIAOMI',
|
|
37
|
+
SMARTPHONES_OPPO = 'SMARTPHONES_OPPO',
|
|
38
|
+
SMARTPHONES_VIVO = 'SMARTPHONES_VIVO',
|
|
39
|
+
|
|
40
|
+
SMARTPHONES_ACCESSORIES = 'SMARTPHONES_ACCESSORIES',
|
|
23
41
|
|
|
24
42
|
SMARTWATCHES = 'SMARTWATCHES',
|
|
25
43
|
TABLETS = 'TABLETS',
|
|
44
|
+
|
|
26
45
|
TV = 'TV',
|
|
27
46
|
AUDIO = 'AUDIO',
|
|
47
|
+
|
|
28
48
|
FRIDGES = 'FRIDGES',
|
|
29
49
|
WASHERS = 'WASHERS',
|
|
30
50
|
DRYERS = 'DRYERS',
|
|
@@ -32,7 +52,9 @@ export enum CATEGORY_ENUM {
|
|
|
32
52
|
AIR_CONDITIONING = 'AIR_CONDITIONING',
|
|
33
53
|
HEATING = 'HEATING',
|
|
34
54
|
KITCHEN = 'KITCHEN',
|
|
55
|
+
|
|
35
56
|
GAMES = 'GAMES',
|
|
57
|
+
TOYS = 'TOYS',
|
|
36
58
|
|
|
37
59
|
DRINKABLE = 'DRINKABLE',
|
|
38
60
|
DRINKABLE_WHISKY = 'DRINKABLE_WHISKY',
|
|
@@ -46,8 +68,44 @@ export enum CATEGORY_ENUM {
|
|
|
46
68
|
DRINKABLE_PISCO = 'DRINKABLE_PISCO',
|
|
47
69
|
|
|
48
70
|
DORMITORY = 'DORMITORY',
|
|
71
|
+
|
|
49
72
|
PHOTOGRAPHY = 'PHOTOGRAPHY',
|
|
73
|
+
PHOTOGRAPHY_CAMERAS = 'PHOTOGRAPHY_CAMERAS',
|
|
74
|
+
PHOTOGRAPHY_ACCESORIES = 'PHOTOGRAPHY_ACCESORIES',
|
|
75
|
+
|
|
50
76
|
HEADPHONES = 'HEADPHONES',
|
|
77
|
+
HEADPHONES_ACCESORIES = 'HEADPHONES_ACCESORIES',
|
|
78
|
+
|
|
79
|
+
TOOLS = 'TOOLS',
|
|
80
|
+
|
|
81
|
+
SPORTS = 'SPORTS',
|
|
82
|
+
|
|
83
|
+
BIKES = 'BIKES',
|
|
84
|
+
|
|
85
|
+
SNEAKERS = 'SNEAKERS',
|
|
86
|
+
SHOES = 'SHOES',
|
|
87
|
+
|
|
88
|
+
CLOTHING = 'CLOTHING',
|
|
89
|
+
|
|
90
|
+
BABY = 'BABY',
|
|
91
|
+
|
|
92
|
+
MUSICAL_INSTRUMENTS = 'MUSICAL_INSTRUMENTS',
|
|
93
|
+
MUSICAL_INSTRUMENTS_GUITAR = 'MUSICAL_INSTRUMENTS_GUITAR',
|
|
94
|
+
MUSICAL_INSTRUMENTS_BASS = 'MUSICAL_INSTRUMENTS_BASS',
|
|
95
|
+
MUSICAL_INSTRUMENTS_STRINGS = 'MUSICAL_INSTRUMENTS_STRINGS',
|
|
96
|
+
MUSICAL_INSTRUMENTS_PERCUSION = 'MUSICAL_INSTRUMENTS_PERCUSION',
|
|
97
|
+
|
|
98
|
+
PATIO_AND_GARDEN = 'PATIO_AND_GARDEN',
|
|
99
|
+
|
|
100
|
+
GROCERY = 'GROCERY',
|
|
101
|
+
|
|
102
|
+
PHARMACY = 'PHARMACY',
|
|
103
|
+
|
|
104
|
+
BEAUTY = 'BEAUTY',
|
|
105
|
+
PERSONAL_CARE = 'PERSONAL_CARE',
|
|
106
|
+
|
|
107
|
+
BOOKS = 'BOOKS',
|
|
108
|
+
|
|
51
109
|
CATEGORY_NOT_FOUND = 'CATEGORY_NOT_FOUND'
|
|
52
110
|
}
|
|
53
111
|
|
package/src/entities/price.ts
CHANGED
|
@@ -4,6 +4,14 @@ import {
|
|
|
4
4
|
import { IsNotEmpty, IsNumber, IsOptional } from 'class-validator';
|
|
5
5
|
import { AbstractBase } from './abstract-base';
|
|
6
6
|
|
|
7
|
+
export enum MeasurementUnitEnum {
|
|
8
|
+
KG = 'kg',
|
|
9
|
+
G = 'g',
|
|
10
|
+
L = 'l',
|
|
11
|
+
ML = 'ml',
|
|
12
|
+
UNIT = 'unit'
|
|
13
|
+
}
|
|
14
|
+
|
|
7
15
|
@Entity({ name: 'prices' })
|
|
8
16
|
export class Price extends AbstractBase {
|
|
9
17
|
@Column()
|
|
@@ -30,6 +38,14 @@ export class Price extends AbstractBase {
|
|
|
30
38
|
@IsOptional()
|
|
31
39
|
sourceUrl?: string;
|
|
32
40
|
|
|
41
|
+
@Column()
|
|
42
|
+
@IsOptional()
|
|
43
|
+
unitMultiplier?: number;
|
|
44
|
+
|
|
45
|
+
@Column()
|
|
46
|
+
@IsOptional()
|
|
47
|
+
measurementUnit?: MeasurementUnitEnum;
|
|
48
|
+
|
|
33
49
|
@CreateDateColumn()
|
|
34
50
|
@Index()
|
|
35
51
|
createdAt?: Date;
|
package/src/utils/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
checkIfSamePrices, isCheaper, getMinPrice, isValidPrice, getAvgPrice, getMaxPrice, getPriceOperation, removeZeroPrices,
|
|
3
|
+
hasMeasurementUnitMultiplier, getPriceByMeasurementUnitMultiplier,
|
|
3
4
|
} from './price-utils';
|
|
4
5
|
import { findLastQuery } from './entity-queries-utils';
|
|
5
6
|
import {
|
|
@@ -14,7 +15,7 @@ import {
|
|
|
14
15
|
} from './number-utils';
|
|
15
16
|
|
|
16
17
|
export {
|
|
17
|
-
checkIfSamePrices, findLastQuery, replaceMultipleSpacesByOne,
|
|
18
|
+
checkIfSamePrices, findLastQuery, replaceMultipleSpacesByOne, hasMeasurementUnitMultiplier, getPriceByMeasurementUnitMultiplier,
|
|
18
19
|
removeIfEndsWith, getLastAfter, includesStringArray, removeNewLines, reverseString, getParam, getPathname,
|
|
19
20
|
getHostname, isUrl, isValidPrice, getMinPrice, isCheaper, getMaxPrice, getPriceOperation, getAvgPrice, calculateAverage,
|
|
20
21
|
roundNumber, removeZeroPrices,
|
package/src/utils/price-utils.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { identity, isEqual, pickBy } from 'lodash';
|
|
2
|
-
import { Price } from '../entities';
|
|
2
|
+
import { MeasurementUnitEnum, Price } from '../entities';
|
|
3
|
+
|
|
4
|
+
export const hasMeasurementUnitMultiplier = (price: Price): boolean => !!price && !!price.unitMultiplier && !!price.measurementUnit;
|
|
3
5
|
|
|
4
6
|
export const checkIfSamePrices = (_price: Price, _price2: Price): boolean => _price && _price2 && isEqual(
|
|
5
7
|
pickBy({ normalPrice: _price.normalPrice, offerPrice: _price.offerPrice, cardPrice: _price.cardPrice }, identity),
|
|
@@ -53,6 +55,28 @@ export const getAvgPrice = (price: Price): number => {
|
|
|
53
55
|
return getPriceOperation(price, fn);
|
|
54
56
|
};
|
|
55
57
|
|
|
58
|
+
export const getPriceByMeasurementUnitMultiplier = (price: Price, minUnit = 100): number => {
|
|
59
|
+
if (!hasMeasurementUnitMultiplier(price)) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const { measurementUnit, unitMultiplier } = price;
|
|
64
|
+
|
|
65
|
+
const minPrice = getMinPrice(price);
|
|
66
|
+
|
|
67
|
+
let value;
|
|
68
|
+
if ([MeasurementUnitEnum.KG, MeasurementUnitEnum.L].includes(measurementUnit)) {
|
|
69
|
+
const grams = unitMultiplier * 1000;
|
|
70
|
+
value = (minPrice / grams) * minUnit;
|
|
71
|
+
} else if ([MeasurementUnitEnum.G, MeasurementUnitEnum.ML].includes(measurementUnit)) {
|
|
72
|
+
value = (minPrice / unitMultiplier) * minUnit;
|
|
73
|
+
} else {
|
|
74
|
+
value = minPrice * unitMultiplier;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return value ? Math.round(value) : null;
|
|
78
|
+
};
|
|
79
|
+
|
|
56
80
|
export const isCheaper = (price: Price, comparePrice: Price): boolean | null => {
|
|
57
81
|
if (!isValidPrice(price) || !isValidPrice(comparePrice)) {
|
|
58
82
|
return null;
|
|
@@ -61,5 +85,14 @@ export const isCheaper = (price: Price, comparePrice: Price): boolean | null =>
|
|
|
61
85
|
const minPrice = getMinPrice(price);
|
|
62
86
|
const minComparePrice = getMinPrice(comparePrice);
|
|
63
87
|
|
|
88
|
+
if (hasMeasurementUnitMultiplier(price) && hasMeasurementUnitMultiplier(comparePrice)) {
|
|
89
|
+
const minPriceWithMeasurementUnit = getPriceByMeasurementUnitMultiplier(price);
|
|
90
|
+
const comparePriceWithMeasurementUnit = getPriceByMeasurementUnitMultiplier(comparePrice);
|
|
91
|
+
|
|
92
|
+
if (minPriceWithMeasurementUnit && comparePriceWithMeasurementUnit) {
|
|
93
|
+
return minPriceWithMeasurementUnit < comparePriceWithMeasurementUnit;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
64
97
|
return minPrice < minComparePrice;
|
|
65
98
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
|
-
checkIfSamePrices, Price, getMinPrice, isCheaper, removeZeroPrices,
|
|
2
|
+
checkIfSamePrices, Price, getMinPrice, isCheaper, removeZeroPrices, hasMeasurementUnitMultiplier,
|
|
3
|
+
getAvgPrice, getMaxPrice, getPriceByMeasurementUnitMultiplier,
|
|
4
|
+
isValidPrice,
|
|
3
5
|
} from '../../src';
|
|
4
|
-
import { getAvgPrice, getMaxPrice } from '../../src/utils/price-utils';
|
|
5
|
-
import { isValidPrice } from '../../dist';
|
|
6
6
|
|
|
7
7
|
describe('price utils tests', () => {
|
|
8
8
|
it('should check if both Prices objects are equal', () => {
|
|
@@ -56,6 +56,81 @@ describe('price utils tests', () => {
|
|
|
56
56
|
expect(isCheaper(<Price>{ offerPrice: 2, cardPrice: 1 }, <Price>{ normalPrice: 2 })).toStrictEqual(true);
|
|
57
57
|
});
|
|
58
58
|
|
|
59
|
+
it('should return true if price is cheaper than comparing price using measurement unit', () => {
|
|
60
|
+
expect.hasAssertions();
|
|
61
|
+
|
|
62
|
+
// Real example from Santa Isabel
|
|
63
|
+
expect(isCheaper(
|
|
64
|
+
<Price>{ measurementUnit: 'kg', unitMultiplier: 0.1, normalPrice: 720 },
|
|
65
|
+
<Price>{ measurementUnit: 'kg', unitMultiplier: 1.0, normalPrice: 7196 },
|
|
66
|
+
)).toStrictEqual(false);
|
|
67
|
+
|
|
68
|
+
expect(isCheaper(
|
|
69
|
+
<Price>{ normalPrice: 100, unitMultiplier: 0.1, measurementUnit: 'kg' },
|
|
70
|
+
<Price>{ offerPrice: 1000, unitMultiplier: 1, measurementUnit: 'kg' },
|
|
71
|
+
)).toStrictEqual(false);
|
|
72
|
+
|
|
73
|
+
expect(isCheaper(
|
|
74
|
+
<Price>{
|
|
75
|
+
normalPrice: 100, offerPrice: 2, unitMultiplier: 0.1, measurementUnit: 'kg',
|
|
76
|
+
},
|
|
77
|
+
<Price>{
|
|
78
|
+
cardPrice: 1, offerPrice: 1000, unitMultiplier: 1, measurementUnit: 'kg',
|
|
79
|
+
},
|
|
80
|
+
)).toStrictEqual(false);
|
|
81
|
+
|
|
82
|
+
expect(isCheaper(
|
|
83
|
+
<Price>{ normalPrice: 100, unitMultiplier: 1, measurementUnit: 'kg' },
|
|
84
|
+
<Price>{ cardPrice: 900, unitMultiplier: 1, measurementUnit: 'kg' },
|
|
85
|
+
)).toStrictEqual(true);
|
|
86
|
+
|
|
87
|
+
expect(isCheaper(<Price>{ normalPrice: 100, unitMultiplier: 0.1, measurementUnit: 'kg' },
|
|
88
|
+
<Price>{
|
|
89
|
+
cardPrice: 150, offerPrice: 300, unitMultiplier: 0.1, measurementUnit: 'kg',
|
|
90
|
+
})).toStrictEqual(true);
|
|
91
|
+
|
|
92
|
+
expect(isCheaper(
|
|
93
|
+
<Price>{ normalPrice: 90, unitMultiplier: 0.1, measurementUnit: 'kg' },
|
|
94
|
+
<Price>{ cardPrice: 1000, unitMultiplier: 1, measurementUnit: 'kg' },
|
|
95
|
+
)).toStrictEqual(true);
|
|
96
|
+
|
|
97
|
+
// Second item without measurementUnit nor unitMultiplier
|
|
98
|
+
expect(isCheaper(
|
|
99
|
+
<Price>{ normalPrice: 100, unitMultiplier: 0.1, measurementUnit: 'kg' },
|
|
100
|
+
<Price>{ offerPrice: 1000 },
|
|
101
|
+
)).toStrictEqual(true);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it('should return true if price have measurement unit and multiplier', () => {
|
|
105
|
+
expect.hasAssertions();
|
|
106
|
+
|
|
107
|
+
expect(hasMeasurementUnitMultiplier(null)).toStrictEqual(false);
|
|
108
|
+
expect(hasMeasurementUnitMultiplier(<Price>{ })).toStrictEqual(false);
|
|
109
|
+
expect(hasMeasurementUnitMultiplier(<Price>{ unitMultiplier: 1 })).toStrictEqual(false);
|
|
110
|
+
expect(hasMeasurementUnitMultiplier(<Price>{ measurementUnit: 'kg' })).toStrictEqual(false);
|
|
111
|
+
|
|
112
|
+
expect(hasMeasurementUnitMultiplier(<Price>{ unitMultiplier: 1, measurementUnit: 'kg' })).toStrictEqual(true);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it('should return minimum price unit using measurement unit and unit multiplier', () => {
|
|
116
|
+
expect.hasAssertions();
|
|
117
|
+
|
|
118
|
+
expect(getPriceByMeasurementUnitMultiplier(<Price>{})).toBeNull();
|
|
119
|
+
|
|
120
|
+
expect(getPriceByMeasurementUnitMultiplier(<Price>{ normalPrice: 1000, unitMultiplier: 1, measurementUnit: 'unit' })).toStrictEqual(1000);
|
|
121
|
+
|
|
122
|
+
expect(getPriceByMeasurementUnitMultiplier(<Price>{ normalPrice: 120000, unitMultiplier: 1.2, measurementUnit: 'kg' })).toStrictEqual(10000);
|
|
123
|
+
expect(getPriceByMeasurementUnitMultiplier(<Price>{ normalPrice: 100000, unitMultiplier: 1.0, measurementUnit: 'kg' })).toStrictEqual(10000);
|
|
124
|
+
expect(getPriceByMeasurementUnitMultiplier(<Price>{ normalPrice: 10000, unitMultiplier: 0.1, measurementUnit: 'kg' })).toStrictEqual(10000);
|
|
125
|
+
expect(getPriceByMeasurementUnitMultiplier(<Price>{ normalPrice: 20000, unitMultiplier: 0.2, measurementUnit: 'kg' })).toStrictEqual(10000);
|
|
126
|
+
expect(getPriceByMeasurementUnitMultiplier(<Price>{ normalPrice: 1000, unitMultiplier: 100, measurementUnit: 'g' })).toStrictEqual(1000);
|
|
127
|
+
expect(getPriceByMeasurementUnitMultiplier(<Price>{ normalPrice: 100, unitMultiplier: 10, measurementUnit: 'g' })).toStrictEqual(1000);
|
|
128
|
+
expect(getPriceByMeasurementUnitMultiplier(<Price>{ normalPrice: 10, unitMultiplier: 1, measurementUnit: 'g' })).toStrictEqual(1000);
|
|
129
|
+
|
|
130
|
+
expect(getPriceByMeasurementUnitMultiplier(<Price>{ normalPrice: 10000, unitMultiplier: 0.1, measurementUnit: 'l' })).toStrictEqual(10000);
|
|
131
|
+
expect(getPriceByMeasurementUnitMultiplier(<Price>{ normalPrice: 1000, unitMultiplier: 100, measurementUnit: 'ml' })).toStrictEqual(1000);
|
|
132
|
+
});
|
|
133
|
+
|
|
59
134
|
it('should remove prices with value of 0', () => {
|
|
60
135
|
expect.hasAssertions();
|
|
61
136
|
|