@infrab4a/connect 4.9.7-beta.29 → 4.9.7-beta.3
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/index.cjs.js +503 -985
- package/index.esm.js +504 -980
- package/package.json +1 -1
- package/src/domain/catalog/models/category-base.d.ts +1 -17
- package/src/domain/catalog/models/enums/index.d.ts +0 -1
- package/src/domain/catalog/models/filter.d.ts +0 -1
- package/src/domain/catalog/models/product-base.d.ts +1 -4
- package/src/domain/catalog/models/types/category-metadata.type.d.ts +0 -2
- package/src/domain/catalog/models/types/index.d.ts +0 -4
- package/src/domain/catalog/models/variant.d.ts +0 -2
- package/src/domain/catalog/models/wishlist.d.ts +0 -3
- package/src/domain/catalog/repositories/category.repository.d.ts +3 -3
- package/src/domain/catalog/repositories/product-reviews.repository.d.ts +0 -1
- package/src/domain/catalog/repositories/product-stock-notification.repository.d.ts +1 -9
- package/src/domain/catalog/repositories/wishlist.repository.d.ts +1 -4
- package/src/domain/general/index.d.ts +0 -3
- package/src/domain/shopping/index.d.ts +0 -1
- package/src/domain/shopping/models/buy-2-win.d.ts +0 -2
- package/src/domain/shopping/models/coupons/coupon.d.ts +4 -8
- package/src/domain/shopping/models/coupons/enums/coupon-types.enum.d.ts +1 -2
- package/src/domain/shopping/models/coupons/enums/index.d.ts +1 -3
- package/src/domain/shopping/models/index.d.ts +0 -1
- package/src/domain/shopping/models/order.d.ts +0 -4
- package/src/domain/shopping/repositories/index.d.ts +0 -1
- package/src/domain/users/models/enums/index.d.ts +0 -1
- package/src/domain/users/models/index.d.ts +2 -3
- package/src/infra/elasticsearch/indexes/products-index.d.ts +1 -39
- package/src/infra/firebase/firestore/mixins/with-helpers.mixin.d.ts +1 -1
- package/src/infra/firebase/firestore/repositories/catalog/category-firestore.repository.d.ts +2 -2
- package/src/infra/firebase/firestore/repositories/index.d.ts +2 -3
- package/src/infra/firebase/firestore/repositories/shopping/index.d.ts +0 -1
- package/src/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.d.ts +0 -1
- package/src/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.d.ts +2 -2
- package/src/infra/hasura-graphql/repositories/catalog/product-review-hasura-graphql.repository.d.ts +0 -1
- package/src/infra/hasura-graphql/repositories/catalog/product-stock-notification-hasura-graphql.repository.d.ts +1 -8
- package/src/infra/hasura-graphql/repositories/catalog/wishlist-hasura-graphql.repository.d.ts +11 -13
- package/src/infra/index.d.ts +0 -1
- package/src/domain/catalog/models/enums/wishlist-log.enum.d.ts +0 -7
- package/src/domain/catalog/models/types/category-images.type.d.ts +0 -8
- package/src/domain/catalog/models/types/category-most-relevant.type.d.ts +0 -4
- package/src/domain/catalog/models/types/product-label.type.d.ts +0 -1
- package/src/domain/catalog/models/types/report-stock-notification.type.d.ts +0 -21
- package/src/domain/general/models/index.d.ts +0 -1
- package/src/domain/general/models/log-document.d.ts +0 -15
- package/src/domain/general/repositories/index.d.ts +0 -1
- package/src/domain/general/repositories/log.repository.d.ts +0 -4
- package/src/domain/general/search/index.d.ts +0 -1
- package/src/domain/general/search/product-search-index.d.ts +0 -3
- package/src/domain/shopping/models/coupons/enums/coupon-category.enum.d.ts +0 -41
- package/src/domain/shopping/models/coupons/enums/coupon-channels.enum.d.ts +0 -10
- package/src/domain/shopping/models/coupons/types/coupon-category.type.d.ts +0 -2
- package/src/domain/shopping/models/coupons/types/coupon-channel.type.d.ts +0 -2
- package/src/domain/shopping/models/coupons/types/index.d.ts +0 -2
- package/src/domain/shopping/models/order-blocked.d.ts +0 -26
- package/src/domain/shopping/repositories/order-blocked.repository.d.ts +0 -6
- package/src/domain/shopping/types/index.d.ts +0 -2
- package/src/domain/shopping/types/order-tracking-events.type.d.ts +0 -14
- package/src/domain/shopping/types/payment-card-info.type.d.ts +0 -4
- package/src/domain/users/models/enums/person-types.enum.d.ts +0 -5
- package/src/domain/users/models/types/index.d.ts +0 -1
- package/src/domain/users/models/types/person.type.d.ts +0 -2
- package/src/infra/firebase/firestore/repositories/general/index.d.ts +0 -1
- package/src/infra/firebase/firestore/repositories/general/log-firestore.repository.d.ts +0 -7
- package/src/infra/firebase/firestore/repositories/shopping/order-blocked-firestore.repository.ts.d.ts +0 -9
- package/src/infra/hasura-graphql/models/wishlist-hasura-graphql.d.ts +0 -4
- package/src/infra/vertex-ai/adapters/index.d.ts +0 -2
- package/src/infra/vertex-ai/adapters/vertex-ai-search.adapter.d.ts +0 -10
- package/src/infra/vertex-ai/adapters/vertex-axios.adapter.d.ts +0 -15
- package/src/infra/vertex-ai/index.d.ts +0 -3
- package/src/infra/vertex-ai/indexes/index.d.ts +0 -1
- package/src/infra/vertex-ai/indexes/products-vertex-search.d.ts +0 -13
- package/src/infra/vertex-ai/types/axios-vertex-search-config.d.ts +0 -4
- package/src/infra/vertex-ai/types/index.d.ts +0 -3
- package/src/infra/vertex-ai/types/product-bulk.d.ts +0 -4
- package/src/infra/vertex-ai/types/product-search.d.ts +0 -21
package/index.esm.js
CHANGED
|
@@ -36,30 +36,6 @@ class BaseModel {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
var GenderDestination;
|
|
40
|
-
(function (GenderDestination) {
|
|
41
|
-
GenderDestination["FEMALE"] = "female";
|
|
42
|
-
GenderDestination["MALE"] = "male";
|
|
43
|
-
GenderDestination["UNISEX"] = "unisex";
|
|
44
|
-
})(GenderDestination || (GenderDestination = {}));
|
|
45
|
-
|
|
46
|
-
var Shops;
|
|
47
|
-
(function (Shops) {
|
|
48
|
-
Shops["MENSMARKET"] = "mensmarket";
|
|
49
|
-
Shops["GLAMSHOP"] = "Glamshop";
|
|
50
|
-
Shops["GLAMPOINTS"] = "Glampoints";
|
|
51
|
-
Shops["ALL"] = "ALL";
|
|
52
|
-
})(Shops || (Shops = {}));
|
|
53
|
-
|
|
54
|
-
var WishlistLogType;
|
|
55
|
-
(function (WishlistLogType) {
|
|
56
|
-
WishlistLogType["CREATE"] = "create";
|
|
57
|
-
WishlistLogType["UPDATE"] = "update";
|
|
58
|
-
WishlistLogType["DELETE"] = "delete";
|
|
59
|
-
WishlistLogType["ADD_PRODUCT"] = "add_product";
|
|
60
|
-
WishlistLogType["REMOVE_PRODUCT"] = "remove_product";
|
|
61
|
-
})(WishlistLogType || (WishlistLogType = {}));
|
|
62
|
-
|
|
63
39
|
class Filter extends BaseModel {
|
|
64
40
|
static get identifiersFields() {
|
|
65
41
|
return ['id'];
|
|
@@ -74,33 +50,6 @@ class CategoryBase extends BaseModel {
|
|
|
74
50
|
static get identifiersFields() {
|
|
75
51
|
return ['id'];
|
|
76
52
|
}
|
|
77
|
-
get glamImages() {
|
|
78
|
-
return this.images && this.images[Shops.GLAMSHOP]
|
|
79
|
-
? this.images[Shops.GLAMSHOP]
|
|
80
|
-
: {
|
|
81
|
-
brandBanner: null,
|
|
82
|
-
brandBannerMobile: null,
|
|
83
|
-
image: null,
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
get mensImages() {
|
|
87
|
-
return this.images && this.images[Shops.MENSMARKET]
|
|
88
|
-
? this.images[Shops.MENSMARKET]
|
|
89
|
-
: {
|
|
90
|
-
brandBanner: null,
|
|
91
|
-
brandBannerMobile: null,
|
|
92
|
-
image: null,
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
get glamMetadata() {
|
|
96
|
-
return this.metadatas.find((metadata) => metadata.shop === Shops.GLAMSHOP);
|
|
97
|
-
}
|
|
98
|
-
get mensMetadata() {
|
|
99
|
-
return this.metadatas.find((metadata) => metadata.shop === Shops.MENSMARKET);
|
|
100
|
-
}
|
|
101
|
-
getMostRelevantByShop(shop) {
|
|
102
|
-
return this.mostRelevants && this.mostRelevants[shop] ? this.mostRelevants[shop] : [];
|
|
103
|
-
}
|
|
104
53
|
}
|
|
105
54
|
__decorate([
|
|
106
55
|
Type(() => CategoryBase),
|
|
@@ -209,6 +158,21 @@ __decorate([
|
|
|
209
158
|
__metadata("design:type", Category)
|
|
210
159
|
], CategoryFilter.prototype, "category", void 0);
|
|
211
160
|
|
|
161
|
+
var GenderDestination;
|
|
162
|
+
(function (GenderDestination) {
|
|
163
|
+
GenderDestination["FEMALE"] = "female";
|
|
164
|
+
GenderDestination["MALE"] = "male";
|
|
165
|
+
GenderDestination["UNISEX"] = "unisex";
|
|
166
|
+
})(GenderDestination || (GenderDestination = {}));
|
|
167
|
+
|
|
168
|
+
var Shops;
|
|
169
|
+
(function (Shops) {
|
|
170
|
+
Shops["MENSMARKET"] = "mensmarket";
|
|
171
|
+
Shops["GLAMSHOP"] = "Glamshop";
|
|
172
|
+
Shops["GLAMPOINTS"] = "Glampoints";
|
|
173
|
+
Shops["ALL"] = "ALL";
|
|
174
|
+
})(Shops || (Shops = {}));
|
|
175
|
+
|
|
212
176
|
class FilterOption extends BaseModel {
|
|
213
177
|
static get identifiersFields() {
|
|
214
178
|
return ['id'];
|
|
@@ -301,17 +265,6 @@ class CampaignHashtag extends BaseModel {
|
|
|
301
265
|
}
|
|
302
266
|
}
|
|
303
267
|
|
|
304
|
-
class BeautyProfile extends BaseModel {
|
|
305
|
-
toPlain() {
|
|
306
|
-
const plain = super.toPlain();
|
|
307
|
-
delete plain.id;
|
|
308
|
-
return plain;
|
|
309
|
-
}
|
|
310
|
-
static get identifiersFields() {
|
|
311
|
-
return ['id', 'userId'];
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
|
|
315
268
|
var AccessoryImportances;
|
|
316
269
|
(function (AccessoryImportances) {
|
|
317
270
|
AccessoryImportances["NOT_INTERESTED"] = "N\u00E3o tenho interesse";
|
|
@@ -488,13 +441,6 @@ var OfficePosition;
|
|
|
488
441
|
OfficePosition["Director"] = "Diretor";
|
|
489
442
|
})(OfficePosition || (OfficePosition = {}));
|
|
490
443
|
|
|
491
|
-
var PersonTypes;
|
|
492
|
-
(function (PersonTypes) {
|
|
493
|
-
PersonTypes["GLAMGIRL"] = "glamgirl";
|
|
494
|
-
PersonTypes["BFLU"] = "bflu";
|
|
495
|
-
PersonTypes["NONE"] = "none";
|
|
496
|
-
})(PersonTypes || (PersonTypes = {}));
|
|
497
|
-
|
|
498
444
|
var ProductSpents;
|
|
499
445
|
(function (ProductSpents) {
|
|
500
446
|
ProductSpents["UNTIL_50"] = "At\u00E9 R$50";
|
|
@@ -515,12 +461,6 @@ var UserType;
|
|
|
515
461
|
UserType["Influencer"] = "Influencer";
|
|
516
462
|
})(UserType || (UserType = {}));
|
|
517
463
|
|
|
518
|
-
class Lead extends BaseModel {
|
|
519
|
-
static get identifiersFields() {
|
|
520
|
-
return ['id'];
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
|
|
524
464
|
class Edition extends BaseModel {
|
|
525
465
|
static get identifiersFields() {
|
|
526
466
|
return ['id', 'subscriptionId'];
|
|
@@ -1846,6 +1786,40 @@ const parseDateTime = (value) => {
|
|
|
1846
1786
|
return date;
|
|
1847
1787
|
};
|
|
1848
1788
|
|
|
1789
|
+
var CheckoutTypes;
|
|
1790
|
+
(function (CheckoutTypes) {
|
|
1791
|
+
CheckoutTypes[CheckoutTypes["ECOMMERCE"] = 1] = "ECOMMERCE";
|
|
1792
|
+
CheckoutTypes[CheckoutTypes["SUBSCRIPTION"] = 2] = "SUBSCRIPTION";
|
|
1793
|
+
CheckoutTypes[CheckoutTypes["ALL"] = 3] = "ALL";
|
|
1794
|
+
})(CheckoutTypes || (CheckoutTypes = {}));
|
|
1795
|
+
|
|
1796
|
+
var CouponTypes;
|
|
1797
|
+
(function (CouponTypes) {
|
|
1798
|
+
CouponTypes[CouponTypes["ABSOLUTE"] = 1] = "ABSOLUTE";
|
|
1799
|
+
CouponTypes[CouponTypes["PERCENTAGE"] = 2] = "PERCENTAGE";
|
|
1800
|
+
// FINANCIAL = 1,
|
|
1801
|
+
// PRODUCT,
|
|
1802
|
+
// GIFTCARD,
|
|
1803
|
+
// VOUCHER,
|
|
1804
|
+
})(CouponTypes || (CouponTypes = {}));
|
|
1805
|
+
|
|
1806
|
+
var CouponSubtypes;
|
|
1807
|
+
(function (CouponSubtypes) {
|
|
1808
|
+
CouponSubtypes[CouponSubtypes["ABSOLUTE"] = 1] = "ABSOLUTE";
|
|
1809
|
+
CouponSubtypes[CouponSubtypes["PERCENTAGE"] = 2] = "PERCENTAGE";
|
|
1810
|
+
})(CouponSubtypes || (CouponSubtypes = {}));
|
|
1811
|
+
|
|
1812
|
+
var Exclusivities;
|
|
1813
|
+
(function (Exclusivities) {
|
|
1814
|
+
Exclusivities[Exclusivities["ALL_USERS"] = 1] = "ALL_USERS";
|
|
1815
|
+
Exclusivities[Exclusivities["SPECIFIC_USER"] = 2] = "SPECIFIC_USER";
|
|
1816
|
+
Exclusivities[Exclusivities["COLLABORATORS"] = 3] = "COLLABORATORS";
|
|
1817
|
+
Exclusivities[Exclusivities["ACTIVE_SUBSCRIBER"] = 4] = "ACTIVE_SUBSCRIBER";
|
|
1818
|
+
Exclusivities[Exclusivities["INACTIVE_SUBSCRIBER"] = 5] = "INACTIVE_SUBSCRIBER";
|
|
1819
|
+
Exclusivities[Exclusivities["NON_SUBSCRIBER"] = 6] = "NON_SUBSCRIBER";
|
|
1820
|
+
})(Exclusivities || (Exclusivities = {}));
|
|
1821
|
+
|
|
1822
|
+
const COUPON_EXPIRATION = +1000 * 60 * 60 * 24 * 30;
|
|
1849
1823
|
class Coupon extends BaseModel {
|
|
1850
1824
|
get isInfluencer() {
|
|
1851
1825
|
return !isNil(this.influencerEmail);
|
|
@@ -1853,6 +1827,30 @@ class Coupon extends BaseModel {
|
|
|
1853
1827
|
static get identifiersFields() {
|
|
1854
1828
|
return ['id'];
|
|
1855
1829
|
}
|
|
1830
|
+
static createCoupon(userId) {
|
|
1831
|
+
return this.toInstance({
|
|
1832
|
+
nickname: `${Date.now()}`,
|
|
1833
|
+
checkoutType: CheckoutTypes.ECOMMERCE,
|
|
1834
|
+
discount: {
|
|
1835
|
+
subscriber: {
|
|
1836
|
+
type: CouponTypes.ABSOLUTE,
|
|
1837
|
+
value: 10,
|
|
1838
|
+
},
|
|
1839
|
+
non_subscriber: {
|
|
1840
|
+
type: CouponTypes.ABSOLUTE,
|
|
1841
|
+
value: 10,
|
|
1842
|
+
},
|
|
1843
|
+
subscription: {
|
|
1844
|
+
type: CouponTypes.ABSOLUTE,
|
|
1845
|
+
value: 10,
|
|
1846
|
+
},
|
|
1847
|
+
},
|
|
1848
|
+
user: userId,
|
|
1849
|
+
createdAt: new Date(Date.now()),
|
|
1850
|
+
beginAt: new Date(Date.now()),
|
|
1851
|
+
expiresIn: new Date(Date.now() + COUPON_EXPIRATION),
|
|
1852
|
+
});
|
|
1853
|
+
}
|
|
1856
1854
|
}
|
|
1857
1855
|
|
|
1858
1856
|
class SubscriptionPlan extends BaseModel {
|
|
@@ -1861,6 +1859,17 @@ class SubscriptionPlan extends BaseModel {
|
|
|
1861
1859
|
}
|
|
1862
1860
|
}
|
|
1863
1861
|
|
|
1862
|
+
class BeautyProfile extends BaseModel {
|
|
1863
|
+
toPlain() {
|
|
1864
|
+
const plain = super.toPlain();
|
|
1865
|
+
delete plain.id;
|
|
1866
|
+
return plain;
|
|
1867
|
+
}
|
|
1868
|
+
static get identifiersFields() {
|
|
1869
|
+
return ['id', 'userId'];
|
|
1870
|
+
}
|
|
1871
|
+
}
|
|
1872
|
+
|
|
1864
1873
|
class User extends BaseModel {
|
|
1865
1874
|
static toInstance(data) {
|
|
1866
1875
|
const instance = super.toInstance(data);
|
|
@@ -1974,6 +1983,12 @@ class UserPaymentMethod extends BaseModel {
|
|
|
1974
1983
|
}
|
|
1975
1984
|
}
|
|
1976
1985
|
|
|
1986
|
+
class Lead extends BaseModel {
|
|
1987
|
+
static get identifiersFields() {
|
|
1988
|
+
return ['id'];
|
|
1989
|
+
}
|
|
1990
|
+
}
|
|
1991
|
+
|
|
1977
1992
|
class UnauthorizedError extends CustomError {
|
|
1978
1993
|
constructor(message) {
|
|
1979
1994
|
super(message);
|
|
@@ -2127,93 +2142,6 @@ __decorate([
|
|
|
2127
2142
|
__metadata("design:type", Coupon)
|
|
2128
2143
|
], Checkout.prototype, "coupon", void 0);
|
|
2129
2144
|
|
|
2130
|
-
var CouponCategory;
|
|
2131
|
-
(function (CouponCategory) {
|
|
2132
|
-
CouponCategory["Reembolso"] = "Reembolso";
|
|
2133
|
-
CouponCategory["Desculpas"] = "Desculpas";
|
|
2134
|
-
CouponCategory["BFlu"] = "BFlu";
|
|
2135
|
-
CouponCategory["ROYAL"] = "Royal";
|
|
2136
|
-
CouponCategory["Glamqueens"] = "Glamqueens";
|
|
2137
|
-
CouponCategory["Glampartner"] = "Glampartner";
|
|
2138
|
-
CouponCategory["Glamgirls"] = "Glamgirls";
|
|
2139
|
-
CouponCategory["Glamdiva"] = "Glamdiva";
|
|
2140
|
-
CouponCategory["Impulsionamento"] = "Impulsionamento";
|
|
2141
|
-
CouponCategory["PaidMedia"] = "Paid Media";
|
|
2142
|
-
CouponCategory["Organic"] = "Organic";
|
|
2143
|
-
CouponCategory["Direct"] = "Direct";
|
|
2144
|
-
CouponCategory["CRM"] = "CRM";
|
|
2145
|
-
CouponCategory["LOJAUNICO"] = "Loja \u00FAnico";
|
|
2146
|
-
CouponCategory["Outros"] = "Outros";
|
|
2147
|
-
})(CouponCategory || (CouponCategory = {}));
|
|
2148
|
-
var CouponOldCategories;
|
|
2149
|
-
(function (CouponOldCategories) {
|
|
2150
|
-
CouponOldCategories["Reembolso"] = "Reembolso";
|
|
2151
|
-
CouponOldCategories["Desculpas"] = "Desculpas";
|
|
2152
|
-
CouponOldCategories["BFlu"] = "BFlu";
|
|
2153
|
-
CouponOldCategories["ROYAL"] = "Royal";
|
|
2154
|
-
CouponOldCategories["Glamqueens"] = "Glamqueens";
|
|
2155
|
-
CouponOldCategories["Glampartner"] = "Glampartner";
|
|
2156
|
-
CouponOldCategories["Glamgirls"] = "Glamgirls";
|
|
2157
|
-
CouponOldCategories["Glamdiva"] = "Glamdiva";
|
|
2158
|
-
CouponOldCategories["Impulsionamento"] = "Impulsionamento";
|
|
2159
|
-
CouponOldCategories["PaidMedia"] = "Paid Media";
|
|
2160
|
-
CouponOldCategories["Organic"] = "Organic";
|
|
2161
|
-
CouponOldCategories["Direct"] = "Direct";
|
|
2162
|
-
CouponOldCategories["CRM"] = "CRM";
|
|
2163
|
-
CouponOldCategories["LOJAUNICO"] = "Loja \u00FAnico";
|
|
2164
|
-
CouponOldCategories["Outros"] = "Outros";
|
|
2165
|
-
})(CouponOldCategories || (CouponOldCategories = {}));
|
|
2166
|
-
var CouponCategories;
|
|
2167
|
-
(function (CouponCategories) {
|
|
2168
|
-
CouponCategories["API_001"] = "API-001";
|
|
2169
|
-
CouponCategories["COMPRE_E_GANHE"] = "COMPRE E GANHE";
|
|
2170
|
-
CouponCategories["DESCONTO"] = "DESCONTO";
|
|
2171
|
-
CouponCategories["REEMBOLSO"] = "REEMBOLSO";
|
|
2172
|
-
CouponCategories["DESCULPAS"] = "DESCULPAS";
|
|
2173
|
-
})(CouponCategories || (CouponCategories = {}));
|
|
2174
|
-
|
|
2175
|
-
var CouponChannels;
|
|
2176
|
-
(function (CouponChannels) {
|
|
2177
|
-
CouponChannels["BANNER"] = "7";
|
|
2178
|
-
CouponChannels["BFLUENCE"] = "3";
|
|
2179
|
-
CouponChannels["CRM"] = "2";
|
|
2180
|
-
CouponChannels["GLAMGIRL"] = "0";
|
|
2181
|
-
CouponChannels["PAID"] = "4";
|
|
2182
|
-
CouponChannels["ROYAL"] = "1";
|
|
2183
|
-
CouponChannels["SAC"] = "8";
|
|
2184
|
-
CouponChannels["SOCIAL"] = "5";
|
|
2185
|
-
})(CouponChannels || (CouponChannels = {}));
|
|
2186
|
-
|
|
2187
|
-
var CouponSubtypes;
|
|
2188
|
-
(function (CouponSubtypes) {
|
|
2189
|
-
CouponSubtypes[CouponSubtypes["ABSOLUTE"] = 1] = "ABSOLUTE";
|
|
2190
|
-
CouponSubtypes[CouponSubtypes["PERCENTAGE"] = 2] = "PERCENTAGE";
|
|
2191
|
-
})(CouponSubtypes || (CouponSubtypes = {}));
|
|
2192
|
-
|
|
2193
|
-
var CouponTypes;
|
|
2194
|
-
(function (CouponTypes) {
|
|
2195
|
-
CouponTypes[CouponTypes["ABSOLUTE"] = 1] = "ABSOLUTE";
|
|
2196
|
-
CouponTypes[CouponTypes["PERCENTAGE"] = 2] = "PERCENTAGE";
|
|
2197
|
-
CouponTypes[CouponTypes["SHIPPING"] = 3] = "SHIPPING";
|
|
2198
|
-
})(CouponTypes || (CouponTypes = {}));
|
|
2199
|
-
|
|
2200
|
-
var Exclusivities;
|
|
2201
|
-
(function (Exclusivities) {
|
|
2202
|
-
Exclusivities[Exclusivities["ALL_USERS"] = 1] = "ALL_USERS";
|
|
2203
|
-
Exclusivities[Exclusivities["SPECIFIC_USER"] = 2] = "SPECIFIC_USER";
|
|
2204
|
-
Exclusivities[Exclusivities["COLLABORATORS"] = 3] = "COLLABORATORS";
|
|
2205
|
-
Exclusivities[Exclusivities["ACTIVE_SUBSCRIBER"] = 4] = "ACTIVE_SUBSCRIBER";
|
|
2206
|
-
Exclusivities[Exclusivities["INACTIVE_SUBSCRIBER"] = 5] = "INACTIVE_SUBSCRIBER";
|
|
2207
|
-
Exclusivities[Exclusivities["NON_SUBSCRIBER"] = 6] = "NON_SUBSCRIBER";
|
|
2208
|
-
})(Exclusivities || (Exclusivities = {}));
|
|
2209
|
-
|
|
2210
|
-
var CheckoutTypes;
|
|
2211
|
-
(function (CheckoutTypes) {
|
|
2212
|
-
CheckoutTypes[CheckoutTypes["ECOMMERCE"] = 1] = "ECOMMERCE";
|
|
2213
|
-
CheckoutTypes[CheckoutTypes["SUBSCRIPTION"] = 2] = "SUBSCRIPTION";
|
|
2214
|
-
CheckoutTypes[CheckoutTypes["ALL"] = 3] = "ALL";
|
|
2215
|
-
})(CheckoutTypes || (CheckoutTypes = {}));
|
|
2216
|
-
|
|
2217
2145
|
var OrderStatus;
|
|
2218
2146
|
(function (OrderStatus) {
|
|
2219
2147
|
OrderStatus["AGUARDANDO_PAGAMENTO"] = "Aguardando pagamento";
|
|
@@ -2233,12 +2161,6 @@ __decorate([
|
|
|
2233
2161
|
__metadata("design:type", Payment)
|
|
2234
2162
|
], Order.prototype, "payment", void 0);
|
|
2235
2163
|
|
|
2236
|
-
class OrderBlocked extends BaseModel {
|
|
2237
|
-
static get identifiersFields() {
|
|
2238
|
-
return ['id'];
|
|
2239
|
-
}
|
|
2240
|
-
}
|
|
2241
|
-
|
|
2242
2164
|
class CheckoutSubscription extends BaseModel {
|
|
2243
2165
|
static get identifiersFields() {
|
|
2244
2166
|
return ['id'];
|
|
@@ -2275,12 +2197,6 @@ class RoundProductPricesHelper {
|
|
|
2275
2197
|
}
|
|
2276
2198
|
}
|
|
2277
2199
|
|
|
2278
|
-
class LogDocument extends BaseModel {
|
|
2279
|
-
static get identifiersFields() {
|
|
2280
|
-
return ['id'];
|
|
2281
|
-
}
|
|
2282
|
-
}
|
|
2283
|
-
|
|
2284
2200
|
var FilterType;
|
|
2285
2201
|
(function (FilterType) {
|
|
2286
2202
|
FilterType["ACCESSORY_IMPORTANCE"] = "accessoryImportance";
|
|
@@ -2579,6 +2495,8 @@ class ProductsIndex {
|
|
|
2579
2495
|
'rate',
|
|
2580
2496
|
];
|
|
2581
2497
|
const filter = [{ term: { published: true } }];
|
|
2498
|
+
if (shop && shop !== Shops.ALL)
|
|
2499
|
+
filter.push({ term: { tags: shop == Shops.GLAMSHOP ? 'feminino' : 'masculino' } });
|
|
2582
2500
|
if (size > 9)
|
|
2583
2501
|
fields.push(...['pricePaid', 'isGift', 'stock', 'weight', 'tags']);
|
|
2584
2502
|
const query = {
|
|
@@ -2634,9 +2552,7 @@ class ProductsIndex {
|
|
|
2634
2552
|
RoundProductPricesHelper.roundProductPrices(hit._source);
|
|
2635
2553
|
return hit;
|
|
2636
2554
|
});
|
|
2637
|
-
return search
|
|
2638
|
-
return Object.assign(Object.assign({}, hit._source), { stock: hit._source.stock.quantity });
|
|
2639
|
-
});
|
|
2555
|
+
return search;
|
|
2640
2556
|
}
|
|
2641
2557
|
async save(product) {
|
|
2642
2558
|
try {
|
|
@@ -3070,8 +2986,6 @@ const withUpdateFirestore = (MixinBase) => {
|
|
|
3070
2986
|
try {
|
|
3071
2987
|
const identifiers = getValueFromParams(data, keyField);
|
|
3072
2988
|
const docRef = this.collection(collectionName).getDoc(identifiers.toString());
|
|
3073
|
-
if (!(await docRef.get()).data())
|
|
3074
|
-
throw new NotFoundError(`Document '${collectionName}/${Object.values(identifiers.toString())}' not found`);
|
|
3075
2989
|
const plainFromData = this.model.toInstance(this.paramsToPlain(data));
|
|
3076
2990
|
const intercepted = await ((_b = (_a = this.interceptors) === null || _a === void 0 ? void 0 : _a.request) === null || _b === void 0 ? void 0 : _b.call(_a, { instance: plainFromData }));
|
|
3077
2991
|
const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || plainFromData;
|
|
@@ -3148,280 +3062,359 @@ const withCrudFirestore = (MixinBase) => {
|
|
|
3148
3062
|
};
|
|
3149
3063
|
};
|
|
3150
3064
|
|
|
3151
|
-
class
|
|
3065
|
+
class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3152
3066
|
constructor({ firestore, interceptors }) {
|
|
3153
3067
|
super({
|
|
3154
3068
|
firestore,
|
|
3155
|
-
collectionName: '
|
|
3156
|
-
model:
|
|
3069
|
+
collectionName: 'leads',
|
|
3070
|
+
model: Lead,
|
|
3157
3071
|
interceptors,
|
|
3158
3072
|
});
|
|
3159
3073
|
}
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
async getCategoriesForHome(categoryIds, shop, limit = 4) {
|
|
3173
|
-
const categorySnap = await this.collection(this.collectionName)
|
|
3174
|
-
.where('id', 'in', categoryIds.filter(Boolean))
|
|
3175
|
-
.where('published', '==', true)
|
|
3176
|
-
.getDocs();
|
|
3177
|
-
if (categorySnap.empty)
|
|
3178
|
-
throw new NotFoundError('Categories not found');
|
|
3179
|
-
const categories = categorySnap.docs.map((doc) => doc.data());
|
|
3180
|
-
const homeSections = await Promise.all(categories.map(async (category) => ({
|
|
3181
|
-
category,
|
|
3182
|
-
products: await this.mountCategory(category, shop, { limit, hasStock: true }),
|
|
3183
|
-
})));
|
|
3184
|
-
return homeSections;
|
|
3185
|
-
}
|
|
3186
|
-
async mountCategory(category, shop, options) {
|
|
3187
|
-
if (!category.products)
|
|
3188
|
-
throw new RequiredArgumentError(['Category products is empty']);
|
|
3189
|
-
const chunks = chunk(category.products, 10);
|
|
3190
|
-
const products = [];
|
|
3191
|
-
const wheres = [];
|
|
3192
|
-
for (const productIds of chunks) {
|
|
3193
|
-
if ((options === null || options === void 0 ? void 0 : options.limit) && products.length >= (options === null || options === void 0 ? void 0 : options.limit))
|
|
3194
|
-
break;
|
|
3195
|
-
wheres.push(['published', '==', true], ['id', 'in', productIds]);
|
|
3196
|
-
if (options === null || options === void 0 ? void 0 : options.hasStock)
|
|
3197
|
-
wheres.push(['stock.quantity', '>', 0]);
|
|
3198
|
-
if (options === null || options === void 0 ? void 0 : options.gender)
|
|
3199
|
-
wheres.push(['tags', 'array-contains', options === null || options === void 0 ? void 0 : options.gender]);
|
|
3200
|
-
const productSnap = await wheres
|
|
3201
|
-
.reduce((collection, where) => collection.where(...where), (options === null || options === void 0 ? void 0 : options.limit)
|
|
3202
|
-
? this.collection('productsErpVitrine').limit(options.limit)
|
|
3203
|
-
: this.collection('productsErpVitrine'))
|
|
3204
|
-
.getDocs();
|
|
3205
|
-
if (productSnap.empty)
|
|
3206
|
-
continue;
|
|
3207
|
-
products.push(...productSnap.docs);
|
|
3208
|
-
}
|
|
3209
|
-
return is(products);
|
|
3210
|
-
}
|
|
3211
|
-
getCategoryByShop(shop) {
|
|
3212
|
-
return;
|
|
3213
|
-
}
|
|
3214
|
-
getChildren(parentId) {
|
|
3215
|
-
return;
|
|
3074
|
+
}
|
|
3075
|
+
|
|
3076
|
+
class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3077
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
3078
|
+
super({
|
|
3079
|
+
firestore,
|
|
3080
|
+
collectionName: 'editions',
|
|
3081
|
+
parentIdField: 'subscriptionId',
|
|
3082
|
+
model: Edition,
|
|
3083
|
+
interceptors,
|
|
3084
|
+
});
|
|
3085
|
+
this.parentRepository = parentRepository;
|
|
3216
3086
|
}
|
|
3217
|
-
|
|
3218
|
-
|
|
3087
|
+
}
|
|
3088
|
+
|
|
3089
|
+
class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3090
|
+
constructor({ firestore, interceptors, }) {
|
|
3091
|
+
super({
|
|
3092
|
+
firestore,
|
|
3093
|
+
collectionName: 'subscription',
|
|
3094
|
+
model: Subscription,
|
|
3095
|
+
interceptors,
|
|
3096
|
+
});
|
|
3219
3097
|
}
|
|
3220
3098
|
}
|
|
3221
|
-
__decorate([
|
|
3222
|
-
Log(),
|
|
3223
|
-
__metadata("design:type", Function),
|
|
3224
|
-
__metadata("design:paramtypes", [String, String]),
|
|
3225
|
-
__metadata("design:returntype", Promise)
|
|
3226
|
-
], CategoryFirestoreRepository.prototype, "getCategoryBySlug", null);
|
|
3227
|
-
__decorate([
|
|
3228
|
-
Log(),
|
|
3229
|
-
__metadata("design:type", Function),
|
|
3230
|
-
__metadata("design:paramtypes", [Array, String, Object]),
|
|
3231
|
-
__metadata("design:returntype", Promise)
|
|
3232
|
-
], CategoryFirestoreRepository.prototype, "getCategoriesForHome", null);
|
|
3233
|
-
__decorate([
|
|
3234
|
-
Log(),
|
|
3235
|
-
__metadata("design:type", Function),
|
|
3236
|
-
__metadata("design:paramtypes", [Category, String, Object]),
|
|
3237
|
-
__metadata("design:returntype", Promise)
|
|
3238
|
-
], CategoryFirestoreRepository.prototype, "mountCategory", null);
|
|
3239
3099
|
|
|
3240
|
-
class
|
|
3100
|
+
class SubscriptionMaterializationFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3241
3101
|
constructor({ firestore, interceptors }) {
|
|
3242
3102
|
super({
|
|
3243
3103
|
firestore,
|
|
3244
|
-
collectionName: '
|
|
3245
|
-
model:
|
|
3104
|
+
collectionName: 'subscriptionMaterialization',
|
|
3105
|
+
model: SubscriptionMaterialization,
|
|
3246
3106
|
interceptors,
|
|
3247
3107
|
});
|
|
3248
|
-
this.reviews = {};
|
|
3249
3108
|
}
|
|
3250
|
-
|
|
3251
|
-
|
|
3109
|
+
}
|
|
3110
|
+
|
|
3111
|
+
class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3112
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
3113
|
+
super({
|
|
3114
|
+
firestore,
|
|
3115
|
+
collectionName: 'payments',
|
|
3116
|
+
parentIdField: 'subscriptionId',
|
|
3117
|
+
model: SubscriptionPayment,
|
|
3118
|
+
interceptors,
|
|
3119
|
+
});
|
|
3120
|
+
this.parentRepository = parentRepository;
|
|
3252
3121
|
}
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3122
|
+
}
|
|
3123
|
+
|
|
3124
|
+
class SubscriptionSummaryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3125
|
+
constructor({ firestore, interceptors, }) {
|
|
3126
|
+
super({
|
|
3127
|
+
firestore,
|
|
3128
|
+
collectionName: 'subscriptionSummary',
|
|
3129
|
+
model: SubscriptionSummary,
|
|
3130
|
+
interceptors,
|
|
3259
3131
|
});
|
|
3260
|
-
return (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
|
|
3261
3132
|
}
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
};
|
|
3273
|
-
this.reviews.pending = [];
|
|
3274
|
-
this.reviews.approved = [];
|
|
3275
|
-
this.reviews.rejected = [];
|
|
3276
|
-
product.reviews.forEach((review) => {
|
|
3277
|
-
if ([null, undefined].includes(review.status))
|
|
3278
|
-
return this.reviews.pending.push(Object.assign(Object.assign({}, review), productInfo));
|
|
3279
|
-
if (review.status === false)
|
|
3280
|
-
return this.reviews.rejected.push(Object.assign(Object.assign({}, review), productInfo));
|
|
3281
|
-
if (!!review.status)
|
|
3282
|
-
return this.reviews.approved.push(Object.assign(Object.assign({}, review), productInfo));
|
|
3283
|
-
return review;
|
|
3284
|
-
});
|
|
3133
|
+
}
|
|
3134
|
+
|
|
3135
|
+
class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3136
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
3137
|
+
super({
|
|
3138
|
+
firestore,
|
|
3139
|
+
collectionName: 'address',
|
|
3140
|
+
parentIdField: 'userId',
|
|
3141
|
+
model: UserAddress,
|
|
3142
|
+
interceptors,
|
|
3285
3143
|
});
|
|
3286
|
-
|
|
3144
|
+
this.parentRepository = parentRepository;
|
|
3287
3145
|
}
|
|
3288
|
-
|
|
3289
|
-
|
|
3146
|
+
}
|
|
3147
|
+
|
|
3148
|
+
class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3149
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
3150
|
+
super({
|
|
3151
|
+
firestore,
|
|
3152
|
+
collectionName: 'CX',
|
|
3153
|
+
parentIdField: 'userId',
|
|
3154
|
+
model: BeautyProfile,
|
|
3155
|
+
interceptors,
|
|
3156
|
+
});
|
|
3157
|
+
this.parentRepository = parentRepository;
|
|
3290
3158
|
}
|
|
3291
|
-
|
|
3292
|
-
|
|
3159
|
+
}
|
|
3160
|
+
|
|
3161
|
+
class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3162
|
+
constructor({ firestore, interceptors }) {
|
|
3163
|
+
super({
|
|
3164
|
+
firestore,
|
|
3165
|
+
collectionName: 'users',
|
|
3166
|
+
model: User,
|
|
3167
|
+
interceptors,
|
|
3168
|
+
});
|
|
3293
3169
|
}
|
|
3294
|
-
async
|
|
3295
|
-
|
|
3170
|
+
async get(identifiers) {
|
|
3171
|
+
const user = await super.get({ id: identifiers.id });
|
|
3172
|
+
user.beautyProfile = await this.getBeautyProfile(user.id);
|
|
3173
|
+
user.isSubscriber = await this.checkIfIsSubscriber(user.id);
|
|
3174
|
+
return user;
|
|
3175
|
+
}
|
|
3176
|
+
async checkIfExistsByField(field, value) {
|
|
3177
|
+
const result = await this.find({ filters: { [field]: value } });
|
|
3178
|
+
return result.count > 0;
|
|
3179
|
+
}
|
|
3180
|
+
buildModelInstance() {
|
|
3181
|
+
const { fromFirestore, toFirestore } = super.buildModelInstance();
|
|
3182
|
+
return {
|
|
3183
|
+
toFirestore: (data) => {
|
|
3184
|
+
const plain = toFirestore(data);
|
|
3185
|
+
delete plain.isSubscriber;
|
|
3186
|
+
return plain;
|
|
3187
|
+
},
|
|
3188
|
+
fromFirestore,
|
|
3189
|
+
};
|
|
3190
|
+
}
|
|
3191
|
+
async getBeautyProfile(userId) {
|
|
3192
|
+
const beautyProfile = await this.firestore
|
|
3193
|
+
.getCollection(`${this.collectionName}/${userId}/CX`)
|
|
3194
|
+
.withConverter(this.buildBeautyProfileModelInstance())
|
|
3195
|
+
.getDoc('beautyProfile')
|
|
3196
|
+
.get();
|
|
3197
|
+
return beautyProfile.data();
|
|
3198
|
+
}
|
|
3199
|
+
async checkIfIsSubscriber(userId) {
|
|
3200
|
+
const docs = await this.collection('subscription')
|
|
3201
|
+
.where('user.id', '==', userId)
|
|
3202
|
+
.where('status', '==', 'active')
|
|
3203
|
+
.getDocs();
|
|
3204
|
+
return !!docs && !!docs.size;
|
|
3205
|
+
}
|
|
3206
|
+
buildBeautyProfileModelInstance() {
|
|
3207
|
+
return {
|
|
3208
|
+
toFirestore: (data) => data.toPlain(),
|
|
3209
|
+
fromFirestore: (snap) => BeautyProfile.toInstance(snap.data()),
|
|
3210
|
+
};
|
|
3296
3211
|
}
|
|
3297
3212
|
}
|
|
3298
3213
|
__decorate([
|
|
3299
3214
|
Log(),
|
|
3300
3215
|
__metadata("design:type", Function),
|
|
3301
|
-
__metadata("design:paramtypes", [
|
|
3216
|
+
__metadata("design:paramtypes", [Object]),
|
|
3302
3217
|
__metadata("design:returntype", Promise)
|
|
3303
|
-
],
|
|
3218
|
+
], UserFirestoreRepository.prototype, "get", null);
|
|
3304
3219
|
__decorate([
|
|
3305
3220
|
Log(),
|
|
3306
3221
|
__metadata("design:type", Function),
|
|
3307
|
-
__metadata("design:paramtypes", [String]),
|
|
3222
|
+
__metadata("design:paramtypes", [String, String]),
|
|
3308
3223
|
__metadata("design:returntype", Promise)
|
|
3309
|
-
],
|
|
3224
|
+
], UserFirestoreRepository.prototype, "checkIfExistsByField", null);
|
|
3310
3225
|
|
|
3311
|
-
class
|
|
3226
|
+
class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3312
3227
|
constructor({ firestore, interceptors }, parentRepository) {
|
|
3313
3228
|
super({
|
|
3314
3229
|
firestore,
|
|
3315
|
-
collectionName: '
|
|
3316
|
-
parentIdField: '
|
|
3317
|
-
model:
|
|
3230
|
+
collectionName: 'payment_method',
|
|
3231
|
+
parentIdField: 'userId',
|
|
3232
|
+
model: UserPaymentMethod,
|
|
3318
3233
|
interceptors,
|
|
3319
3234
|
});
|
|
3320
3235
|
this.parentRepository = parentRepository;
|
|
3321
3236
|
}
|
|
3322
3237
|
}
|
|
3323
3238
|
|
|
3324
|
-
class
|
|
3239
|
+
class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3325
3240
|
constructor({ firestore, interceptors }) {
|
|
3326
3241
|
super({
|
|
3327
3242
|
firestore,
|
|
3328
|
-
collectionName: '
|
|
3329
|
-
model:
|
|
3243
|
+
collectionName: 'categories',
|
|
3244
|
+
model: Category,
|
|
3330
3245
|
interceptors,
|
|
3331
3246
|
});
|
|
3332
3247
|
}
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3248
|
+
async getCategoryBySlug(slug, shop) {
|
|
3249
|
+
const categoryDocs = await this.collection(this.collectionName)
|
|
3250
|
+
.where('slug', '==', slug)
|
|
3251
|
+
.where('shop', '==', shop)
|
|
3252
|
+
.where('published', '==', true)
|
|
3253
|
+
.getDocs();
|
|
3254
|
+
if (categoryDocs.size > 1)
|
|
3255
|
+
throw new DuplicatedResultsError('Query returned duplicated values');
|
|
3256
|
+
if (categoryDocs.empty)
|
|
3257
|
+
throw new NotFoundError(`Document with slug ${slug} not found`);
|
|
3258
|
+
return categoryDocs.docs[0].data();
|
|
3259
|
+
}
|
|
3260
|
+
async getCategoriesForHome(categoryIds, limit = 4, gender) {
|
|
3261
|
+
const categorySnap = await this.collection(this.collectionName)
|
|
3262
|
+
.where('id', 'in', categoryIds.filter(Boolean))
|
|
3263
|
+
.where('published', '==', true)
|
|
3264
|
+
.getDocs();
|
|
3265
|
+
if (categorySnap.empty)
|
|
3266
|
+
throw new NotFoundError('Categories not found');
|
|
3267
|
+
const categories = categorySnap.docs.map((doc) => doc.data());
|
|
3268
|
+
const homeSections = await Promise.all(categories.map(async (category) => ({
|
|
3269
|
+
category,
|
|
3270
|
+
products: await this.mountCategory(category, { limit, hasStock: true, gender }),
|
|
3271
|
+
})));
|
|
3272
|
+
return homeSections;
|
|
3273
|
+
}
|
|
3274
|
+
async mountCategory(category, options) {
|
|
3275
|
+
if (!category.products)
|
|
3276
|
+
throw new RequiredArgumentError(['Category products is empty']);
|
|
3277
|
+
const chunks = chunk(category.products, 10);
|
|
3278
|
+
const products = [];
|
|
3279
|
+
const wheres = [];
|
|
3280
|
+
for (const productIds of chunks) {
|
|
3281
|
+
if ((options === null || options === void 0 ? void 0 : options.limit) && products.length >= (options === null || options === void 0 ? void 0 : options.limit))
|
|
3282
|
+
break;
|
|
3283
|
+
wheres.push(['published', '==', true], ['id', 'in', productIds]);
|
|
3284
|
+
if (options === null || options === void 0 ? void 0 : options.hasStock)
|
|
3285
|
+
wheres.push(['stock.quantity', '>', 0]);
|
|
3286
|
+
if (options === null || options === void 0 ? void 0 : options.gender)
|
|
3287
|
+
wheres.push(['tags', 'array-contains', options === null || options === void 0 ? void 0 : options.gender]);
|
|
3288
|
+
const productSnap = await wheres
|
|
3289
|
+
.reduce((collection, where) => collection.where(...where), (options === null || options === void 0 ? void 0 : options.limit)
|
|
3290
|
+
? this.collection('productsErpVitrine').limit(options.limit)
|
|
3291
|
+
: this.collection('productsErpVitrine'))
|
|
3292
|
+
.getDocs();
|
|
3293
|
+
if (productSnap.empty)
|
|
3294
|
+
continue;
|
|
3295
|
+
products.push(...productSnap.docs);
|
|
3296
|
+
}
|
|
3297
|
+
return is(products);
|
|
3298
|
+
}
|
|
3299
|
+
getCategoryByShop(shop) {
|
|
3300
|
+
return;
|
|
3301
|
+
}
|
|
3302
|
+
getChildren(parentId) {
|
|
3303
|
+
return;
|
|
3304
|
+
}
|
|
3305
|
+
isChild(id, parentId) {
|
|
3306
|
+
return;
|
|
3343
3307
|
}
|
|
3344
3308
|
}
|
|
3309
|
+
__decorate([
|
|
3310
|
+
Log(),
|
|
3311
|
+
__metadata("design:type", Function),
|
|
3312
|
+
__metadata("design:paramtypes", [String, String]),
|
|
3313
|
+
__metadata("design:returntype", Promise)
|
|
3314
|
+
], CategoryFirestoreRepository.prototype, "getCategoryBySlug", null);
|
|
3315
|
+
__decorate([
|
|
3316
|
+
Log(),
|
|
3317
|
+
__metadata("design:type", Function),
|
|
3318
|
+
__metadata("design:paramtypes", [Array, Object, String]),
|
|
3319
|
+
__metadata("design:returntype", Promise)
|
|
3320
|
+
], CategoryFirestoreRepository.prototype, "getCategoriesForHome", null);
|
|
3321
|
+
__decorate([
|
|
3322
|
+
Log(),
|
|
3323
|
+
__metadata("design:type", Function),
|
|
3324
|
+
__metadata("design:paramtypes", [Category, Object]),
|
|
3325
|
+
__metadata("design:returntype", Promise)
|
|
3326
|
+
], CategoryFirestoreRepository.prototype, "mountCategory", null);
|
|
3345
3327
|
|
|
3346
|
-
class
|
|
3328
|
+
class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3347
3329
|
constructor({ firestore, interceptors }) {
|
|
3348
3330
|
super({
|
|
3349
3331
|
firestore,
|
|
3350
|
-
collectionName: '
|
|
3351
|
-
model:
|
|
3332
|
+
collectionName: 'productsErpVitrine',
|
|
3333
|
+
model: Product,
|
|
3352
3334
|
interceptors,
|
|
3353
3335
|
});
|
|
3354
|
-
this.
|
|
3355
|
-
var _a, _b, _c;
|
|
3356
|
-
return ({
|
|
3357
|
-
category: ((_a = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _a === void 0 ? void 0 : _a.toPlain)
|
|
3358
|
-
? (_b = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _b === void 0 ? void 0 : _b.toPlain()
|
|
3359
|
-
: homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category,
|
|
3360
|
-
products: ((_c = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.products) === null || _c === void 0 ? void 0 : _c.map((product) => ((product === null || product === void 0 ? void 0 : product.toPlain) ? product === null || product === void 0 ? void 0 : product.toPlain() : product)).filter(Boolean)) || [],
|
|
3361
|
-
});
|
|
3362
|
-
};
|
|
3363
|
-
this.plainToHomeCategoryGroup = (homeCategoryGroup) => {
|
|
3364
|
-
var _a;
|
|
3365
|
-
return ({
|
|
3366
|
-
category: Category.toInstance(homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category),
|
|
3367
|
-
products: (_a = homeCategoryGroup.products) === null || _a === void 0 ? void 0 : _a.map((product) => Product.toInstance(product)),
|
|
3368
|
-
});
|
|
3369
|
-
};
|
|
3336
|
+
this.reviews = {};
|
|
3370
3337
|
}
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
const instance = fromFirestore(snap);
|
|
3380
|
-
return this.homeFromFirestore(instance);
|
|
3338
|
+
fetchProductReviews(filters) {
|
|
3339
|
+
throw new Error('Method not implemented.');
|
|
3340
|
+
}
|
|
3341
|
+
async getBySlug(slug) {
|
|
3342
|
+
var _a;
|
|
3343
|
+
const result = await this.find({
|
|
3344
|
+
filters: {
|
|
3345
|
+
slug: { operator: Where.EQUALS, value: slug },
|
|
3381
3346
|
},
|
|
3382
|
-
};
|
|
3347
|
+
});
|
|
3348
|
+
return (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
|
|
3383
3349
|
}
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3350
|
+
async fetchReviews(status) {
|
|
3351
|
+
const { data: products } = await this.find();
|
|
3352
|
+
products.forEach((product) => {
|
|
3353
|
+
var _a;
|
|
3354
|
+
if ([undefined, 0].includes((_a = product.reviews) === null || _a === void 0 ? void 0 : _a.length))
|
|
3355
|
+
return;
|
|
3356
|
+
const productInfo = {
|
|
3357
|
+
productId: product.id,
|
|
3358
|
+
productName: product.name,
|
|
3359
|
+
productSku: product.sku,
|
|
3360
|
+
};
|
|
3361
|
+
this.reviews.pending = [];
|
|
3362
|
+
this.reviews.approved = [];
|
|
3363
|
+
this.reviews.rejected = [];
|
|
3364
|
+
product.reviews.forEach((review) => {
|
|
3365
|
+
if ([null, undefined].includes(review.status))
|
|
3366
|
+
return this.reviews.pending.push(Object.assign(Object.assign({}, review), productInfo));
|
|
3367
|
+
if (review.status === false)
|
|
3368
|
+
return this.reviews.rejected.push(Object.assign(Object.assign({}, review), productInfo));
|
|
3369
|
+
if (!!review.status)
|
|
3370
|
+
return this.reviews.approved.push(Object.assign(Object.assign({}, review), productInfo));
|
|
3371
|
+
return review;
|
|
3372
|
+
});
|
|
3373
|
+
});
|
|
3374
|
+
return this.reviews[status];
|
|
3375
|
+
}
|
|
3376
|
+
cleanShoppingCountFromIds() {
|
|
3377
|
+
return;
|
|
3392
3378
|
}
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.plainToHomeCategoryGroup);
|
|
3399
|
-
home.data.createdAt =
|
|
3400
|
-
home.data.createdAt instanceof Timestamp ? home.data.createdAt.toDate() : home.data.createdAt;
|
|
3401
|
-
home.data.expiresAt =
|
|
3402
|
-
home.data.expiresAt instanceof Timestamp ? home.data.expiresAt.toDate() : home.data.expiresAt;
|
|
3403
|
-
}
|
|
3404
|
-
return home;
|
|
3379
|
+
findCatalog(params) {
|
|
3380
|
+
return this.find(params);
|
|
3381
|
+
}
|
|
3382
|
+
async fetchPaginatedReviews() {
|
|
3383
|
+
return Promise.resolve([]);
|
|
3405
3384
|
}
|
|
3406
3385
|
}
|
|
3386
|
+
__decorate([
|
|
3387
|
+
Log(),
|
|
3388
|
+
__metadata("design:type", Function),
|
|
3389
|
+
__metadata("design:paramtypes", [String]),
|
|
3390
|
+
__metadata("design:returntype", Promise)
|
|
3391
|
+
], ProductFirestoreRepository.prototype, "getBySlug", null);
|
|
3392
|
+
__decorate([
|
|
3393
|
+
Log(),
|
|
3394
|
+
__metadata("design:type", Function),
|
|
3395
|
+
__metadata("design:paramtypes", [String]),
|
|
3396
|
+
__metadata("design:returntype", Promise)
|
|
3397
|
+
], ProductFirestoreRepository.prototype, "fetchReviews", null);
|
|
3407
3398
|
|
|
3408
|
-
class
|
|
3409
|
-
constructor({ firestore, interceptors }) {
|
|
3399
|
+
class ProductVariantFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3400
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
3410
3401
|
super({
|
|
3411
3402
|
firestore,
|
|
3412
|
-
collectionName: '
|
|
3413
|
-
|
|
3403
|
+
collectionName: 'variants',
|
|
3404
|
+
parentIdField: 'productId',
|
|
3405
|
+
model: Variant,
|
|
3414
3406
|
interceptors,
|
|
3415
3407
|
});
|
|
3408
|
+
this.parentRepository = parentRepository;
|
|
3416
3409
|
}
|
|
3417
3410
|
}
|
|
3418
3411
|
|
|
3419
|
-
class
|
|
3420
|
-
constructor({ firestore, interceptors
|
|
3412
|
+
class SubscriptionProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3413
|
+
constructor({ firestore, interceptors }) {
|
|
3421
3414
|
super({
|
|
3422
3415
|
firestore,
|
|
3423
|
-
collectionName: '
|
|
3424
|
-
model:
|
|
3416
|
+
collectionName: 'subscriptionProducts',
|
|
3417
|
+
model: Product,
|
|
3425
3418
|
interceptors,
|
|
3426
3419
|
});
|
|
3427
3420
|
}
|
|
@@ -3557,47 +3550,6 @@ class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
|
|
|
3557
3550
|
}
|
|
3558
3551
|
}
|
|
3559
3552
|
|
|
3560
|
-
class OrderBlockedFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3561
|
-
constructor({ firestore, interceptors, }) {
|
|
3562
|
-
super({
|
|
3563
|
-
firestore,
|
|
3564
|
-
collectionName: 'paymentBlockedAttempts',
|
|
3565
|
-
model: OrderBlocked,
|
|
3566
|
-
interceptors,
|
|
3567
|
-
});
|
|
3568
|
-
}
|
|
3569
|
-
async createBlockedOrderOrPayment(checkout, blockType, type, limiteRange, card = null) {
|
|
3570
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
3571
|
-
return this.create(OrderBlocked.toInstance({
|
|
3572
|
-
customer: {
|
|
3573
|
-
name: ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.displayName) || '',
|
|
3574
|
-
cpf: ((_b = checkout.user) === null || _b === void 0 ? void 0 : _b.cpf) || '',
|
|
3575
|
-
id: (_c = checkout.user) === null || _c === void 0 ? void 0 : _c.id,
|
|
3576
|
-
email: ((_d = checkout.user) === null || _d === void 0 ? void 0 : _d.email) || '',
|
|
3577
|
-
phoneNumber: '+55' + ((_e = checkout.user) === null || _e === void 0 ? void 0 : _e.phone),
|
|
3578
|
-
isSubscriber: (_f = checkout.user) === null || _f === void 0 ? void 0 : _f.isSubscriber,
|
|
3579
|
-
subscriptionPlan: ((_g = checkout.user) === null || _g === void 0 ? void 0 : _g.subscriptionPlan) || '',
|
|
3580
|
-
shippingAddress: Object.assign(Object.assign({}, checkout.shippingAddress), { zip: this.formatZip((_h = checkout.shippingAddress) === null || _h === void 0 ? void 0 : _h.zip) }),
|
|
3581
|
-
},
|
|
3582
|
-
blockType,
|
|
3583
|
-
limiteRange,
|
|
3584
|
-
type,
|
|
3585
|
-
card,
|
|
3586
|
-
checkout: {
|
|
3587
|
-
id: checkout.id,
|
|
3588
|
-
shop: checkout.shop,
|
|
3589
|
-
total: checkout.totalPrice,
|
|
3590
|
-
},
|
|
3591
|
-
date: new Date(),
|
|
3592
|
-
}));
|
|
3593
|
-
}
|
|
3594
|
-
formatZip(zip) {
|
|
3595
|
-
if (zip.length === 8)
|
|
3596
|
-
return zip.substring(0, 5) + '-' + zip.substring(5, 8);
|
|
3597
|
-
return zip;
|
|
3598
|
-
}
|
|
3599
|
-
}
|
|
3600
|
-
|
|
3601
3553
|
class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3602
3554
|
constructor({ firestore, interceptors }) {
|
|
3603
3555
|
super({
|
|
@@ -3620,177 +3572,87 @@ class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(
|
|
|
3620
3572
|
}
|
|
3621
3573
|
}
|
|
3622
3574
|
|
|
3623
|
-
class
|
|
3624
|
-
constructor({ firestore, interceptors }) {
|
|
3625
|
-
super({
|
|
3626
|
-
firestore,
|
|
3627
|
-
collectionName: 'leads',
|
|
3628
|
-
model: Lead,
|
|
3629
|
-
interceptors,
|
|
3630
|
-
});
|
|
3631
|
-
}
|
|
3632
|
-
}
|
|
3633
|
-
|
|
3634
|
-
class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3635
|
-
constructor({ firestore, interceptors }, parentRepository) {
|
|
3636
|
-
super({
|
|
3637
|
-
firestore,
|
|
3638
|
-
collectionName: 'editions',
|
|
3639
|
-
parentIdField: 'subscriptionId',
|
|
3640
|
-
model: Edition,
|
|
3641
|
-
interceptors,
|
|
3642
|
-
});
|
|
3643
|
-
this.parentRepository = parentRepository;
|
|
3644
|
-
}
|
|
3645
|
-
}
|
|
3646
|
-
|
|
3647
|
-
class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3648
|
-
constructor({ firestore, interceptors, }) {
|
|
3649
|
-
super({
|
|
3650
|
-
firestore,
|
|
3651
|
-
collectionName: 'subscription',
|
|
3652
|
-
model: Subscription,
|
|
3653
|
-
interceptors,
|
|
3654
|
-
});
|
|
3655
|
-
}
|
|
3656
|
-
}
|
|
3657
|
-
|
|
3658
|
-
class SubscriptionMaterializationFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3659
|
-
constructor({ firestore, interceptors }) {
|
|
3660
|
-
super({
|
|
3661
|
-
firestore,
|
|
3662
|
-
collectionName: 'subscriptionMaterialization',
|
|
3663
|
-
model: SubscriptionMaterialization,
|
|
3664
|
-
interceptors,
|
|
3665
|
-
});
|
|
3666
|
-
}
|
|
3667
|
-
}
|
|
3668
|
-
|
|
3669
|
-
class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3670
|
-
constructor({ firestore, interceptors }, parentRepository) {
|
|
3671
|
-
super({
|
|
3672
|
-
firestore,
|
|
3673
|
-
collectionName: 'payments',
|
|
3674
|
-
parentIdField: 'subscriptionId',
|
|
3675
|
-
model: SubscriptionPayment,
|
|
3676
|
-
interceptors,
|
|
3677
|
-
});
|
|
3678
|
-
this.parentRepository = parentRepository;
|
|
3679
|
-
}
|
|
3680
|
-
}
|
|
3681
|
-
|
|
3682
|
-
class SubscriptionSummaryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3683
|
-
constructor({ firestore, interceptors, }) {
|
|
3684
|
-
super({
|
|
3685
|
-
firestore,
|
|
3686
|
-
collectionName: 'subscriptionSummary',
|
|
3687
|
-
model: SubscriptionSummary,
|
|
3688
|
-
interceptors,
|
|
3689
|
-
});
|
|
3690
|
-
}
|
|
3691
|
-
}
|
|
3692
|
-
|
|
3693
|
-
class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3694
|
-
constructor({ firestore, interceptors }, parentRepository) {
|
|
3695
|
-
super({
|
|
3696
|
-
firestore,
|
|
3697
|
-
collectionName: 'address',
|
|
3698
|
-
parentIdField: 'userId',
|
|
3699
|
-
model: UserAddress,
|
|
3700
|
-
interceptors,
|
|
3701
|
-
});
|
|
3702
|
-
this.parentRepository = parentRepository;
|
|
3703
|
-
}
|
|
3704
|
-
}
|
|
3705
|
-
|
|
3706
|
-
class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3707
|
-
constructor({ firestore, interceptors }, parentRepository) {
|
|
3708
|
-
super({
|
|
3709
|
-
firestore,
|
|
3710
|
-
collectionName: 'CX',
|
|
3711
|
-
parentIdField: 'userId',
|
|
3712
|
-
model: BeautyProfile,
|
|
3713
|
-
interceptors,
|
|
3714
|
-
});
|
|
3715
|
-
this.parentRepository = parentRepository;
|
|
3716
|
-
}
|
|
3717
|
-
}
|
|
3718
|
-
|
|
3719
|
-
class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3575
|
+
class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3720
3576
|
constructor({ firestore, interceptors }) {
|
|
3721
3577
|
super({
|
|
3722
3578
|
firestore,
|
|
3723
|
-
collectionName: '
|
|
3724
|
-
model:
|
|
3579
|
+
collectionName: 'dms',
|
|
3580
|
+
model: Home,
|
|
3725
3581
|
interceptors,
|
|
3726
3582
|
});
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3583
|
+
this.homeCategoryGroupToPlain = (homeCategoryGroup) => {
|
|
3584
|
+
var _a, _b, _c;
|
|
3585
|
+
return ({
|
|
3586
|
+
category: ((_a = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _a === void 0 ? void 0 : _a.toPlain)
|
|
3587
|
+
? (_b = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _b === void 0 ? void 0 : _b.toPlain()
|
|
3588
|
+
: homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category,
|
|
3589
|
+
products: ((_c = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.products) === null || _c === void 0 ? void 0 : _c.map((product) => ((product === null || product === void 0 ? void 0 : product.toPlain) ? product === null || product === void 0 ? void 0 : product.toPlain() : product)).filter(Boolean)) || [],
|
|
3590
|
+
});
|
|
3591
|
+
};
|
|
3592
|
+
this.plainToHomeCategoryGroup = (homeCategoryGroup) => {
|
|
3593
|
+
var _a;
|
|
3594
|
+
return ({
|
|
3595
|
+
category: Category.toInstance(homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category),
|
|
3596
|
+
products: (_a = homeCategoryGroup.products) === null || _a === void 0 ? void 0 : _a.map((product) => Product.toInstance(product)),
|
|
3597
|
+
});
|
|
3598
|
+
};
|
|
3737
3599
|
}
|
|
3738
3600
|
buildModelInstance() {
|
|
3739
3601
|
const { fromFirestore, toFirestore } = super.buildModelInstance();
|
|
3740
3602
|
return {
|
|
3741
3603
|
toFirestore: (data) => {
|
|
3742
|
-
const
|
|
3743
|
-
|
|
3744
|
-
|
|
3604
|
+
const modifiedData = this.homeToFirestore(data);
|
|
3605
|
+
return toFirestore(modifiedData);
|
|
3606
|
+
},
|
|
3607
|
+
fromFirestore: (snap) => {
|
|
3608
|
+
const instance = fromFirestore(snap);
|
|
3609
|
+
return this.homeFromFirestore(instance);
|
|
3745
3610
|
},
|
|
3746
|
-
fromFirestore,
|
|
3747
3611
|
};
|
|
3748
3612
|
}
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
.
|
|
3753
|
-
.
|
|
3754
|
-
.
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
async checkIfIsSubscriber(userId) {
|
|
3758
|
-
const docs = await this.collection('subscription')
|
|
3759
|
-
.where('user.id', '==', userId)
|
|
3760
|
-
.where('status', '==', 'active')
|
|
3761
|
-
.getDocs();
|
|
3762
|
-
return !!docs && !!docs.size;
|
|
3613
|
+
homeToFirestore(home) {
|
|
3614
|
+
var _a, _b, _c, _d;
|
|
3615
|
+
if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
|
|
3616
|
+
home.data.data.discoverProducts = ((_b = home.data.data.discoverProducts) === null || _b === void 0 ? void 0 : _b.map(this.homeCategoryGroupToPlain)) || [];
|
|
3617
|
+
home.data.data.featuredProducts = ((_c = home.data.data.featuredProducts) === null || _c === void 0 ? void 0 : _c.map(this.homeCategoryGroupToPlain)) || [];
|
|
3618
|
+
home.data.data.verticalProducts = ((_d = home.data.data.verticalProducts) === null || _d === void 0 ? void 0 : _d.map(this.homeCategoryGroupToPlain)) || [];
|
|
3619
|
+
}
|
|
3620
|
+
return home;
|
|
3763
3621
|
}
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3622
|
+
homeFromFirestore(home) {
|
|
3623
|
+
var _a;
|
|
3624
|
+
if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
|
|
3625
|
+
home.data.data.discoverProducts = home.data.data.discoverProducts.map(this.plainToHomeCategoryGroup);
|
|
3626
|
+
home.data.data.featuredProducts = home.data.data.featuredProducts.map(this.plainToHomeCategoryGroup);
|
|
3627
|
+
home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.plainToHomeCategoryGroup);
|
|
3628
|
+
home.data.createdAt =
|
|
3629
|
+
home.data.createdAt instanceof Timestamp ? home.data.createdAt.toDate() : home.data.createdAt;
|
|
3630
|
+
home.data.expiresAt =
|
|
3631
|
+
home.data.expiresAt instanceof Timestamp ? home.data.expiresAt.toDate() : home.data.expiresAt;
|
|
3632
|
+
}
|
|
3633
|
+
return home;
|
|
3634
|
+
}
|
|
3635
|
+
}
|
|
3636
|
+
|
|
3637
|
+
class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3638
|
+
constructor({ firestore, interceptors }) {
|
|
3639
|
+
super({
|
|
3640
|
+
firestore,
|
|
3641
|
+
collectionName: 'shopMenus',
|
|
3642
|
+
model: ShopMenu,
|
|
3643
|
+
interceptors,
|
|
3644
|
+
});
|
|
3769
3645
|
}
|
|
3770
3646
|
}
|
|
3771
|
-
__decorate([
|
|
3772
|
-
Log(),
|
|
3773
|
-
__metadata("design:type", Function),
|
|
3774
|
-
__metadata("design:paramtypes", [Object]),
|
|
3775
|
-
__metadata("design:returntype", Promise)
|
|
3776
|
-
], UserFirestoreRepository.prototype, "get", null);
|
|
3777
|
-
__decorate([
|
|
3778
|
-
Log(),
|
|
3779
|
-
__metadata("design:type", Function),
|
|
3780
|
-
__metadata("design:paramtypes", [String, String]),
|
|
3781
|
-
__metadata("design:returntype", Promise)
|
|
3782
|
-
], UserFirestoreRepository.prototype, "checkIfExistsByField", null);
|
|
3783
3647
|
|
|
3784
|
-
class
|
|
3785
|
-
constructor({ firestore, interceptors }
|
|
3648
|
+
class ShopSettingsFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3649
|
+
constructor({ firestore, interceptors, }) {
|
|
3786
3650
|
super({
|
|
3787
3651
|
firestore,
|
|
3788
|
-
collectionName: '
|
|
3789
|
-
|
|
3790
|
-
model: UserPaymentMethod,
|
|
3652
|
+
collectionName: 'shopSettings',
|
|
3653
|
+
model: ShopSettings,
|
|
3791
3654
|
interceptors,
|
|
3792
3655
|
});
|
|
3793
|
-
this.parentRepository = parentRepository;
|
|
3794
3656
|
}
|
|
3795
3657
|
}
|
|
3796
3658
|
|
|
@@ -4343,7 +4205,7 @@ const withHasuraGraphQL = (MixinBase) => {
|
|
|
4343
4205
|
const response = await axios(request);
|
|
4344
4206
|
if (!isNil(response.data.errors)) {
|
|
4345
4207
|
this.logger.error({ req: request, res: response.data.errors });
|
|
4346
|
-
throw new Error(
|
|
4208
|
+
throw new Error(response.data.errors);
|
|
4347
4209
|
}
|
|
4348
4210
|
this.logger.log({ req: request, res: response.data });
|
|
4349
4211
|
return response.data.data;
|
|
@@ -4484,7 +4346,6 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
4484
4346
|
return class FindHasuraGraphQLMixin extends MixinBase {
|
|
4485
4347
|
constructor() {
|
|
4486
4348
|
super(...arguments);
|
|
4487
|
-
this.lastDistinct = {};
|
|
4488
4349
|
this.bindOrderByAttributes = (orderBy, fields) => Object.keys(orderBy).reduce((acc, current) => [
|
|
4489
4350
|
...acc,
|
|
4490
4351
|
{
|
|
@@ -4520,10 +4381,9 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
4520
4381
|
});
|
|
4521
4382
|
}
|
|
4522
4383
|
async find(params) {
|
|
4523
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
4384
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
4524
4385
|
this.logger = DebugHelper.from(this, 'find');
|
|
4525
4386
|
const { filters, limits, orderBy, options } = params || {};
|
|
4526
|
-
const tableFiltersNamed = `${this.tableName}:${JSON.stringify(filters)}`;
|
|
4527
4387
|
const enableCount = (_a = options === null || options === void 0 ? void 0 : options.enableCount) !== null && _a !== void 0 ? _a : true;
|
|
4528
4388
|
const variablesFilters = isNil(filters)
|
|
4529
4389
|
? {}
|
|
@@ -4574,8 +4434,8 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
4574
4434
|
},
|
|
4575
4435
|
]
|
|
4576
4436
|
: []),
|
|
4577
|
-
...((!
|
|
4578
|
-
((
|
|
4437
|
+
...((!((_b = params.limits) === null || _b === void 0 ? void 0 : _b.offset) &&
|
|
4438
|
+
((_d = (_c = params.options) === null || _c === void 0 ? void 0 : _c.distinct) === null || _d === void 0 ? void 0 : _d.map((distinct) => {
|
|
4579
4439
|
var _a, _b;
|
|
4580
4440
|
const distinctOption = (_a = this.fields.find((fieldOption) => fieldOption === distinct)) !== null && _a !== void 0 ? _a : this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === distinct);
|
|
4581
4441
|
const fieldName = ((_b = Object.values(distinctOption).shift()) === null || _b === void 0 ? void 0 : _b.columnName) || distinct;
|
|
@@ -4596,27 +4456,28 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
4596
4456
|
[]),
|
|
4597
4457
|
]);
|
|
4598
4458
|
const data = result[this.tableName].map((row) => this.convertDataFromHasura(row));
|
|
4599
|
-
return Object.assign(Object.assign(Object.assign({ data, count: enableCount ? result[`${this.tableName}_aggregate`].aggregate.count : Infinity }, (((
|
|
4459
|
+
return Object.assign(Object.assign(Object.assign({ data, count: enableCount ? result[`${this.tableName}_aggregate`].aggregate.count : Infinity }, (((_e = options === null || options === void 0 ? void 0 : options.minimal) === null || _e === void 0 ? void 0 : _e.length)
|
|
4600
4460
|
? {
|
|
4601
4461
|
minimal: options.minimal.reduce((minimals, current) => {
|
|
4602
4462
|
var _a;
|
|
4603
4463
|
return (Object.assign(Object.assign({}, minimals), set(minimals, current, result[`${this.tableName}_aggregate`].aggregate.min[((_a = AttributeOptionHelper.FindByAttribute(current.toString().split('.').pop(), this.fields)) === null || _a === void 0 ? void 0 : _a.columnName) || current])));
|
|
4604
4464
|
}, {}),
|
|
4605
4465
|
}
|
|
4606
|
-
: {})), (((
|
|
4466
|
+
: {})), (((_f = options === null || options === void 0 ? void 0 : options.maximum) === null || _f === void 0 ? void 0 : _f.length)
|
|
4607
4467
|
? {
|
|
4608
4468
|
maximum: options.maximum.reduce((maximums, current) => {
|
|
4609
4469
|
var _a;
|
|
4610
4470
|
return (Object.assign(Object.assign({}, maximums), set(maximums, current, result[`${this.tableName}_aggregate`].aggregate.max[((_a = AttributeOptionHelper.FindByAttribute(current.toString().split('.').pop(), this.fields)) === null || _a === void 0 ? void 0 : _a.columnName) || current])));
|
|
4611
4471
|
}, {}),
|
|
4612
4472
|
}
|
|
4613
|
-
: {})), (((
|
|
4614
|
-
|
|
4473
|
+
: {})), (!((_g = params.limits) === null || _g === void 0 ? void 0 : _g.offset) &&
|
|
4474
|
+
((_h = options === null || options === void 0 ? void 0 : options.distinct) === null || _h === void 0 ? void 0 : _h.length) && {
|
|
4475
|
+
distinct: options === null || options === void 0 ? void 0 : options.distinct.reduce((distinct, current) => {
|
|
4615
4476
|
var _a, _b;
|
|
4616
4477
|
const distinctOption = (_a = this.fields.find((fieldOption) => fieldOption === current)) !== null && _a !== void 0 ? _a : this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === current);
|
|
4617
4478
|
const fieldName = ((_b = Object.values(distinctOption).shift()) === null || _b === void 0 ? void 0 : _b.columnName) || current;
|
|
4618
4479
|
return Object.assign(Object.assign({}, distinct), { [current.toString()]: result[`${this.tableName}_${current.toString()}_distinct`].map((obj) => obj[fieldName]) });
|
|
4619
|
-
}, {})
|
|
4480
|
+
}, {}),
|
|
4620
4481
|
}));
|
|
4621
4482
|
}
|
|
4622
4483
|
};
|
|
@@ -4711,7 +4572,6 @@ class CategoryFilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHa
|
|
|
4711
4572
|
fields: [
|
|
4712
4573
|
'id',
|
|
4713
4574
|
'description',
|
|
4714
|
-
'title',
|
|
4715
4575
|
'slug',
|
|
4716
4576
|
'enabled',
|
|
4717
4577
|
{ createdAt: { columnName: 'created_at' } },
|
|
@@ -4823,7 +4683,6 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4823
4683
|
'name',
|
|
4824
4684
|
'description',
|
|
4825
4685
|
'image',
|
|
4826
|
-
{ images: { columnName: 'images', type: HasuraGraphQLColumnType.Jsonb } },
|
|
4827
4686
|
'published',
|
|
4828
4687
|
'shop',
|
|
4829
4688
|
{ shops: { columnName: 'shops', type: HasuraGraphQLColumnType.Jsonb } },
|
|
@@ -4856,11 +4715,11 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4856
4715
|
filters: {
|
|
4857
4716
|
columnName: 'filters',
|
|
4858
4717
|
foreignKeyColumn: { filter_id: 'id' },
|
|
4859
|
-
fields: [{ filter: ['id', '
|
|
4718
|
+
fields: [{ filter: ['id', 'description', 'slug', 'enabled'] }],
|
|
4860
4719
|
bindPersistData: (value) => ({
|
|
4861
4720
|
filters: { data: value.map((filter) => ({ filter_id: filter.id })) },
|
|
4862
4721
|
}),
|
|
4863
|
-
from: (filters) => (filters === null || filters === void 0 ? void 0 : filters.map((filter) => filter === null || filter === void 0 ? void 0 : filter.filter)
|
|
4722
|
+
from: (filters) => (filters === null || filters === void 0 ? void 0 : filters.map((filter) => filter === null || filter === void 0 ? void 0 : filter.filter)) || [],
|
|
4864
4723
|
},
|
|
4865
4724
|
},
|
|
4866
4725
|
{ createdAt: { columnName: 'created_at' } },
|
|
@@ -4879,21 +4738,12 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4879
4738
|
{
|
|
4880
4739
|
metadata: {
|
|
4881
4740
|
columnName: 'metadata',
|
|
4882
|
-
fields: ['
|
|
4741
|
+
fields: ['title', 'description'],
|
|
4883
4742
|
bindPersistData: (value) => ({
|
|
4884
4743
|
metadata: { data: value },
|
|
4885
4744
|
}),
|
|
4886
4745
|
},
|
|
4887
4746
|
},
|
|
4888
|
-
{
|
|
4889
|
-
metadatas: {
|
|
4890
|
-
columnName: 'metadatas',
|
|
4891
|
-
fields: ['shop', 'title', 'description'],
|
|
4892
|
-
bindPersistData: (value) => ({
|
|
4893
|
-
metadatas: { data: value },
|
|
4894
|
-
}),
|
|
4895
|
-
},
|
|
4896
|
-
},
|
|
4897
4747
|
{ isCollection: { columnName: 'is_collection' } },
|
|
4898
4748
|
{ isWishlist: { columnName: 'is_wishlist' } },
|
|
4899
4749
|
'reference',
|
|
@@ -4908,29 +4758,14 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4908
4758
|
'theme',
|
|
4909
4759
|
{ bannerUrl: { columnName: 'banner_url' } },
|
|
4910
4760
|
{ mostRelevant: { columnName: 'most_relevant', type: HasuraGraphQLColumnType.Jsonb } },
|
|
4911
|
-
{ mostRelevants: { columnName: 'most_relevants', type: HasuraGraphQLColumnType.Jsonb } },
|
|
4912
4761
|
],
|
|
4913
4762
|
});
|
|
4914
4763
|
this.productRepository = productRepository;
|
|
4915
4764
|
this.categoryFilterRepository = categoryFilterRepository;
|
|
4916
4765
|
}
|
|
4917
4766
|
async create(params) {
|
|
4918
|
-
const {
|
|
4919
|
-
return super.create(Object.assign(Object.assign({}, data), { isWishlist: false,
|
|
4920
|
-
[Shops.GLAMSHOP]: null,
|
|
4921
|
-
[Shops.MENSMARKET]: null,
|
|
4922
|
-
}, images: images || {
|
|
4923
|
-
[Shops.GLAMSHOP]: {
|
|
4924
|
-
brandBanner: null,
|
|
4925
|
-
brandBannerMobile: null,
|
|
4926
|
-
image: null,
|
|
4927
|
-
},
|
|
4928
|
-
[Shops.MENSMARKET]: {
|
|
4929
|
-
brandBanner: null,
|
|
4930
|
-
brandBannerMobile: null,
|
|
4931
|
-
image: null,
|
|
4932
|
-
},
|
|
4933
|
-
} }));
|
|
4767
|
+
const { metadata } = params, data = __rest(params, ["metadata"]);
|
|
4768
|
+
return super.create(Object.assign(Object.assign({}, data), { isWishlist: false, metadata: metadata || { description: null, title: null } }));
|
|
4934
4769
|
}
|
|
4935
4770
|
async get(identifiers) {
|
|
4936
4771
|
var _a;
|
|
@@ -4939,12 +4774,12 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4939
4774
|
: super.get(identifiers);
|
|
4940
4775
|
}
|
|
4941
4776
|
async update(params) {
|
|
4942
|
-
const { products, id: checkId,
|
|
4777
|
+
const { products, id: checkId, metadata, filters } = params, data = __rest(params, ["products", "id", "metadata", "filters"]);
|
|
4943
4778
|
const plainData = this.paramsToPlain({ id: checkId });
|
|
4944
4779
|
const id = await this.getId(plainData.id);
|
|
4945
4780
|
const category = await super.update(Object.assign(Object.assign({ id }, data), { isWishlist: false }));
|
|
4946
4781
|
category.products = products && (await this.updateProducts(+id, { products }));
|
|
4947
|
-
category.
|
|
4782
|
+
category.metadata = metadata && (await this.updateMetadata(+id, { metadata }));
|
|
4948
4783
|
category.filters = filters && (await this.updateFilters(+id, { filters }));
|
|
4949
4784
|
return category;
|
|
4950
4785
|
}
|
|
@@ -4982,7 +4817,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4982
4817
|
});
|
|
4983
4818
|
return data;
|
|
4984
4819
|
}
|
|
4985
|
-
async getCategoriesForHome(categoryIds,
|
|
4820
|
+
async getCategoriesForHome(categoryIds, limit = 4, gender) {
|
|
4986
4821
|
if (!(categoryIds === null || categoryIds === void 0 ? void 0 : categoryIds.length))
|
|
4987
4822
|
return [];
|
|
4988
4823
|
const categoriesFirestore = categoryIds.filter((categoryId) => Number.isNaN(+categoryId));
|
|
@@ -4994,32 +4829,22 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4994
4829
|
}).then(({ data }) => data)));
|
|
4995
4830
|
if (categoriesHasura.length)
|
|
4996
4831
|
categories.push(...(await this.find({
|
|
4997
|
-
filters: {
|
|
4998
|
-
id: { operator: Where.IN, value: categoriesHasura.filter(Boolean) },
|
|
4999
|
-
published: true,
|
|
5000
|
-
},
|
|
4832
|
+
filters: { id: { operator: Where.IN, value: categoriesHasura.filter(Boolean) }, published: true },
|
|
5001
4833
|
}).then(({ data }) => data)));
|
|
5002
4834
|
if (!categories.length)
|
|
5003
4835
|
return [];
|
|
5004
4836
|
const homeSections = await Promise.all(categories.map(async (category) => ({
|
|
5005
4837
|
category,
|
|
5006
|
-
products: await this.mountCategory(category,
|
|
4838
|
+
products: await this.mountCategory(category, { limit, hasStock: true, gender }),
|
|
5007
4839
|
})));
|
|
5008
4840
|
return homeSections;
|
|
5009
4841
|
}
|
|
5010
|
-
async mountCategory(category,
|
|
4842
|
+
async mountCategory(category, options) {
|
|
5011
4843
|
var _a;
|
|
5012
4844
|
if (!((_a = category === null || category === void 0 ? void 0 : category.products) === null || _a === void 0 ? void 0 : _a.length))
|
|
5013
4845
|
return [];
|
|
5014
|
-
const mostRelevants = category.getMostRelevantByShop(shop);
|
|
5015
|
-
const mostRelevantProductsIds = [...new Set(mostRelevants.concat(category.products))];
|
|
5016
4846
|
const products = [];
|
|
5017
|
-
const { data: productsData } = await this.productRepository.
|
|
5018
|
-
filters: {
|
|
5019
|
-
id: { operator: Where.IN, value: mostRelevantProductsIds },
|
|
5020
|
-
published: true,
|
|
5021
|
-
},
|
|
5022
|
-
fields: [
|
|
4847
|
+
const { data: productsData } = await this.productRepository.find(Object.assign(Object.assign({ filters: Object.assign(Object.assign({ id: { operator: Where.IN, value: category.products }, published: true }, ((options === null || options === void 0 ? void 0 : options.hasStock) ? { stock: { quantity: { operator: Where.GT, value: 0 } } } : {})), ((options === null || options === void 0 ? void 0 : options.gender) ? { tags: { operator: Where.IN, value: [options === null || options === void 0 ? void 0 : options.gender] } } : {})), fields: [
|
|
5023
4848
|
'id',
|
|
5024
4849
|
'name',
|
|
5025
4850
|
'slug',
|
|
@@ -5045,29 +4870,12 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
5045
4870
|
'shoppingCount',
|
|
5046
4871
|
'gender',
|
|
5047
4872
|
'createdAt',
|
|
5048
|
-
],
|
|
5049
|
-
|
|
5050
|
-
orderBy: {
|
|
5051
|
-
shoppingCount: 'desc',
|
|
5052
|
-
rate: 'desc',
|
|
5053
|
-
stock: 'desc',
|
|
5054
|
-
name: 'asc',
|
|
5055
|
-
},
|
|
5056
|
-
}, shop === Shops.MENSMARKET ? 'male' : 'female');
|
|
5057
|
-
const mostRelevantWithouyStock = productsData.filter((product) => mostRelevants.includes(product.id) && product.stock.quantity <= 0);
|
|
5058
|
-
const firstProducts = productsData
|
|
5059
|
-
.filter((product) => mostRelevants.includes(product.id) && product.stock.quantity > 0)
|
|
5060
|
-
.sort((a, b) => mostRelevants.indexOf(a.id) - mostRelevants.indexOf(b.id));
|
|
5061
|
-
const lastProducts = productsData
|
|
5062
|
-
.filter((product) => !mostRelevants.includes(product.id) && product.stock.quantity > 0)
|
|
5063
|
-
.concat(mostRelevantWithouyStock);
|
|
5064
|
-
const categoryMostRelevants = firstProducts.concat(lastProducts);
|
|
5065
|
-
const resultFinal = categoryMostRelevants.slice(0, options.limit);
|
|
5066
|
-
products.push(...resultFinal);
|
|
4873
|
+
] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})), { options: { enableCount: false } }));
|
|
4874
|
+
products.push(...productsData);
|
|
5067
4875
|
return products;
|
|
5068
4876
|
}
|
|
5069
4877
|
async getChildren(parentId) {
|
|
5070
|
-
const { category_tree } = await this.query('category_tree', ['id', 'name', 'parent_id', 'slug', 'reference'
|
|
4878
|
+
const { category_tree } = await this.query('category_tree', ['id', 'name', 'parent_id', 'slug', 'reference'], {
|
|
5071
4879
|
args: {
|
|
5072
4880
|
type: 'category_tree_args',
|
|
5073
4881
|
value: { parentid: parentId },
|
|
@@ -5147,36 +4955,23 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
5147
4955
|
});
|
|
5148
4956
|
return plainData.products;
|
|
5149
4957
|
}
|
|
5150
|
-
async updateMetadata(categoryId, {
|
|
5151
|
-
|
|
5152
|
-
|
|
5153
|
-
|
|
5154
|
-
|
|
5155
|
-
|
|
5156
|
-
|
|
5157
|
-
|
|
5158
|
-
|
|
5159
|
-
|
|
5160
|
-
|
|
5161
|
-
|
|
5162
|
-
|
|
5163
|
-
|
|
5164
|
-
|
|
5165
|
-
|
|
5166
|
-
|
|
5167
|
-
});
|
|
5168
|
-
return metadatas;
|
|
5169
|
-
}
|
|
5170
|
-
if ('action' in metadatas && metadatas.action === 'remove' && metadatas.value.length) {
|
|
5171
|
-
await this.mutation('delete_category_metadata', ['affected_rows'], {
|
|
5172
|
-
where: {
|
|
5173
|
-
type: 'category_metadata_bool_exp',
|
|
5174
|
-
required: true,
|
|
5175
|
-
value: { category_id: { _eq: categoryId } },
|
|
5176
|
-
},
|
|
5177
|
-
});
|
|
5178
|
-
return [];
|
|
5179
|
-
}
|
|
4958
|
+
async updateMetadata(categoryId, { metadata }) {
|
|
4959
|
+
const plainData = this.paramsToPlain({ metadata });
|
|
4960
|
+
if (!plainData.metadata)
|
|
4961
|
+
return null;
|
|
4962
|
+
await this.mutation('update_category_metadata_by_pk', ['category_id'], {
|
|
4963
|
+
pk_columns: {
|
|
4964
|
+
value: { category_id: categoryId },
|
|
4965
|
+
type: 'category_metadata_pk_columns_input',
|
|
4966
|
+
required: true,
|
|
4967
|
+
},
|
|
4968
|
+
_set: {
|
|
4969
|
+
value: omit(metadata, ['category_id']),
|
|
4970
|
+
type: 'category_metadata_set_input',
|
|
4971
|
+
required: true,
|
|
4972
|
+
},
|
|
4973
|
+
});
|
|
4974
|
+
return plainData.metadata;
|
|
5180
4975
|
}
|
|
5181
4976
|
async updateFilters(categoryId, { filters }) {
|
|
5182
4977
|
if ('action' in filters && filters.action === 'remove' && filters.value.length) {
|
|
@@ -5238,13 +5033,13 @@ __decorate([
|
|
|
5238
5033
|
__decorate([
|
|
5239
5034
|
Log(),
|
|
5240
5035
|
__metadata("design:type", Function),
|
|
5241
|
-
__metadata("design:paramtypes", [Array,
|
|
5036
|
+
__metadata("design:paramtypes", [Array, Object, String]),
|
|
5242
5037
|
__metadata("design:returntype", Promise)
|
|
5243
5038
|
], CategoryHasuraGraphQLRepository.prototype, "getCategoriesForHome", null);
|
|
5244
5039
|
__decorate([
|
|
5245
5040
|
Log(),
|
|
5246
5041
|
__metadata("design:type", Function),
|
|
5247
|
-
__metadata("design:paramtypes", [Category,
|
|
5042
|
+
__metadata("design:paramtypes", [Category, Object]),
|
|
5248
5043
|
__metadata("design:returntype", Promise)
|
|
5249
5044
|
], CategoryHasuraGraphQLRepository.prototype, "mountCategory", null);
|
|
5250
5045
|
__decorate([
|
|
@@ -5270,7 +5065,6 @@ class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGrap
|
|
|
5270
5065
|
interceptors,
|
|
5271
5066
|
fields: [
|
|
5272
5067
|
'id',
|
|
5273
|
-
'title',
|
|
5274
5068
|
'description',
|
|
5275
5069
|
'slug',
|
|
5276
5070
|
'enabled',
|
|
@@ -5526,7 +5320,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
5526
5320
|
{ subscriberPrice: { columnName: 'subscriber_price' } },
|
|
5527
5321
|
'published',
|
|
5528
5322
|
'outlet',
|
|
5529
|
-
'label',
|
|
5530
5323
|
'sku',
|
|
5531
5324
|
{
|
|
5532
5325
|
stock: {
|
|
@@ -5558,8 +5351,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
5558
5351
|
fields: ['id', 'name', 'reference', 'slug'],
|
|
5559
5352
|
},
|
|
5560
5353
|
},
|
|
5561
|
-
'group',
|
|
5562
|
-
'validity',
|
|
5563
5354
|
];
|
|
5564
5355
|
this.fields = [
|
|
5565
5356
|
...commonFields,
|
|
@@ -5661,8 +5452,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
5661
5452
|
enableCount: false,
|
|
5662
5453
|
},
|
|
5663
5454
|
});
|
|
5664
|
-
if (!result.data.length)
|
|
5665
|
-
return null;
|
|
5666
5455
|
const product = (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
|
|
5667
5456
|
RoundProductPricesHelper.roundProductPrices(product);
|
|
5668
5457
|
return product;
|
|
@@ -5962,24 +5751,6 @@ class ProductReviewsHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHa
|
|
|
5962
5751
|
],
|
|
5963
5752
|
});
|
|
5964
5753
|
}
|
|
5965
|
-
async updateManyStatus(reviews) {
|
|
5966
|
-
return await this.mutation('update_product_review_many', ['affected_rows'], {
|
|
5967
|
-
updates: {
|
|
5968
|
-
type: '[product_review_updates!]',
|
|
5969
|
-
required: true,
|
|
5970
|
-
value: [
|
|
5971
|
-
{
|
|
5972
|
-
_set: { status: true },
|
|
5973
|
-
where: { id: { _in: reviews.filter((review) => review.status).map((review) => review.id) } },
|
|
5974
|
-
},
|
|
5975
|
-
{
|
|
5976
|
-
_set: { status: false },
|
|
5977
|
-
where: { id: { _in: reviews.filter((review) => !review.status).map((review) => review.id) } },
|
|
5978
|
-
},
|
|
5979
|
-
],
|
|
5980
|
-
},
|
|
5981
|
-
});
|
|
5982
|
-
}
|
|
5983
5754
|
aproveReview(id) {
|
|
5984
5755
|
return this.update({ id, status: true });
|
|
5985
5756
|
}
|
|
@@ -6034,31 +5805,6 @@ class ProductStockNotificationHasuraGraphQLRepository extends withCrudHasuraGrap
|
|
|
6034
5805
|
email,
|
|
6035
5806
|
});
|
|
6036
5807
|
}
|
|
6037
|
-
async getNotificationsReport(params, orderBy, pagination) {
|
|
6038
|
-
const query = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (params.productId && { product_id: { _eq: params.productId } })), (params.ean && { ean: { _eq: params.ean } })), (params.sku && { sku: { _eq: params.sku } })), (params.name && { name: { _iregex: params.name } })), (params.categoryId && { category_id: { _eq: params.categoryId } })), (params.category && { category: { _iregex: params.category } })), (params.reference && { category_reference: { _eq: params.reference } })), (params.emailsCount && { emails_registered: { _eq: params.emailsCount } }));
|
|
6039
|
-
const orderByField = {
|
|
6040
|
-
[orderBy.field]: orderBy.direction,
|
|
6041
|
-
};
|
|
6042
|
-
const { report_stock_notification } = await this.query('report_stock_notification', ['product_id', 'ean', 'sku', 'name', 'stock', 'category_id', 'category', 'reference', 'emails_registered'], {
|
|
6043
|
-
where: {
|
|
6044
|
-
type: 'report_stock_notification_bool_exp',
|
|
6045
|
-
value: query,
|
|
6046
|
-
required: true,
|
|
6047
|
-
},
|
|
6048
|
-
order_by: {
|
|
6049
|
-
type: '[report_stock_notification_order_by]',
|
|
6050
|
-
value: orderByField,
|
|
6051
|
-
required: true,
|
|
6052
|
-
},
|
|
6053
|
-
});
|
|
6054
|
-
const data = (pagination === null || pagination === void 0 ? void 0 : pagination.limit)
|
|
6055
|
-
? report_stock_notification.slice(pagination === null || pagination === void 0 ? void 0 : pagination.offset, (pagination === null || pagination === void 0 ? void 0 : pagination.offset) + (pagination === null || pagination === void 0 ? void 0 : pagination.limit))
|
|
6056
|
-
: report_stock_notification;
|
|
6057
|
-
return {
|
|
6058
|
-
data,
|
|
6059
|
-
count: report_stock_notification.length,
|
|
6060
|
-
};
|
|
6061
|
-
}
|
|
6062
5808
|
}
|
|
6063
5809
|
|
|
6064
5810
|
class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
@@ -6132,8 +5878,6 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
6132
5878
|
type: HasuraGraphQLColumnType.Jsonb,
|
|
6133
5879
|
},
|
|
6134
5880
|
},
|
|
6135
|
-
'group',
|
|
6136
|
-
'validity',
|
|
6137
5881
|
],
|
|
6138
5882
|
});
|
|
6139
5883
|
}
|
|
@@ -6169,14 +5913,11 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
6169
5913
|
}
|
|
6170
5914
|
}
|
|
6171
5915
|
|
|
6172
|
-
class WishlistHasuraGraphQL extends Wishlist {
|
|
6173
|
-
}
|
|
6174
|
-
|
|
6175
5916
|
class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
6176
5917
|
constructor({ endpoint, authOptions, interceptors, }, categoryFilterRepository) {
|
|
6177
5918
|
super({
|
|
6178
5919
|
tableName: 'category',
|
|
6179
|
-
model:
|
|
5920
|
+
model: Wishlist,
|
|
6180
5921
|
endpoint,
|
|
6181
5922
|
authOptions,
|
|
6182
5923
|
interceptors,
|
|
@@ -6237,21 +5978,12 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
6237
5978
|
{
|
|
6238
5979
|
metadata: {
|
|
6239
5980
|
columnName: 'metadata',
|
|
6240
|
-
fields: ['
|
|
5981
|
+
fields: ['title', 'description'],
|
|
6241
5982
|
bindPersistData: (value) => ({
|
|
6242
5983
|
metadata: { data: value },
|
|
6243
5984
|
}),
|
|
6244
5985
|
},
|
|
6245
5986
|
},
|
|
6246
|
-
{
|
|
6247
|
-
metadatas: {
|
|
6248
|
-
columnName: 'metadatas',
|
|
6249
|
-
fields: ['shop', 'title', 'description'],
|
|
6250
|
-
bindPersistData: (value) => ({
|
|
6251
|
-
metadatas: { data: value },
|
|
6252
|
-
}),
|
|
6253
|
-
},
|
|
6254
|
-
},
|
|
6255
5987
|
{ isCollection: { columnName: 'is_collection' } },
|
|
6256
5988
|
{ isWishlist: { columnName: 'is_wishlist' } },
|
|
6257
5989
|
'reference',
|
|
@@ -6266,34 +5998,15 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
6266
5998
|
{ personId: { columnName: 'person_id' } },
|
|
6267
5999
|
{ personName: { columnName: 'person_name' } },
|
|
6268
6000
|
{ personPhoto: { columnName: 'person_photo' } },
|
|
6269
|
-
{ personType: { columnName: 'person_type' } },
|
|
6270
|
-
{ personIsSubscriber: { columnName: 'person_is_subscriber' } },
|
|
6271
6001
|
'theme',
|
|
6272
6002
|
{ bannerUrl: { columnName: 'banner_url' } },
|
|
6273
|
-
{ personHasPhoto: { columnName: 'person_has_photo' } },
|
|
6274
|
-
{ mostRelevants: { columnName: 'most_relevants', type: HasuraGraphQLColumnType.Jsonb } },
|
|
6275
6003
|
],
|
|
6276
6004
|
});
|
|
6277
6005
|
this.categoryFilterRepository = categoryFilterRepository;
|
|
6278
6006
|
}
|
|
6279
6007
|
async create(params) {
|
|
6280
|
-
|
|
6281
|
-
|
|
6282
|
-
return super.create(Object.assign(Object.assign({}, data), { isWishlist: true, isCollection: true, brandCategory: false, metadatas: metadatas || [{ shop: (_a = data.shop) !== null && _a !== void 0 ? _a : null, description: data.description, title: data.name }], mostRelevants: mostRelevants || {
|
|
6283
|
-
[Shops.GLAMSHOP]: null,
|
|
6284
|
-
[Shops.MENSMARKET]: null,
|
|
6285
|
-
}, images: images || {
|
|
6286
|
-
[Shops.GLAMSHOP]: {
|
|
6287
|
-
brandBanner: null,
|
|
6288
|
-
brandBannerMobile: null,
|
|
6289
|
-
image: null,
|
|
6290
|
-
},
|
|
6291
|
-
[Shops.MENSMARKET]: {
|
|
6292
|
-
brandBanner: null,
|
|
6293
|
-
brandBannerMobile: null,
|
|
6294
|
-
image: null,
|
|
6295
|
-
},
|
|
6296
|
-
} }));
|
|
6008
|
+
const { metadata } = params, data = __rest(params, ["metadata"]);
|
|
6009
|
+
return super.create(Object.assign(Object.assign({}, data), { isWishlist: true, isCollection: true, brandCategory: false, metadata: metadata || { description: data.description, title: data.name } }));
|
|
6297
6010
|
}
|
|
6298
6011
|
async get(identifiers) {
|
|
6299
6012
|
const data = await super.get(identifiers);
|
|
@@ -6306,12 +6019,12 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
6306
6019
|
return await super.find(Object.assign(Object.assign({}, rest), { filters: Object.assign(Object.assign({}, filters), { isWishlist: { operator: Where.EQUALS, value: true } }) }));
|
|
6307
6020
|
}
|
|
6308
6021
|
async update(params) {
|
|
6309
|
-
const { products, id: checkId,
|
|
6022
|
+
const { products, id: checkId, metadata, filters } = params, data = __rest(params, ["products", "id", "metadata", "filters"]);
|
|
6310
6023
|
const plainData = this.paramsToPlain({ id: checkId });
|
|
6311
6024
|
const id = plainData.id;
|
|
6312
6025
|
const category = await super.update(Object.assign(Object.assign({ id }, data), { isWishlist: true, isCollection: true, brandCategory: false }));
|
|
6313
6026
|
category.products = products && (await this.updateProducts(+id, { products }));
|
|
6314
|
-
category.
|
|
6027
|
+
category.metadata = metadata && (await this.updateMetadata(+id, { metadata }));
|
|
6315
6028
|
return category;
|
|
6316
6029
|
}
|
|
6317
6030
|
async getWishlistBySlug(slug) {
|
|
@@ -6343,18 +6056,12 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
6343
6056
|
options: {
|
|
6344
6057
|
enableCount: false,
|
|
6345
6058
|
},
|
|
6346
|
-
orderBy: {
|
|
6347
|
-
id: 'asc',
|
|
6348
|
-
},
|
|
6349
|
-
limits: {
|
|
6350
|
-
limit: 1,
|
|
6351
|
-
},
|
|
6352
6059
|
});
|
|
6353
6060
|
if (!data.length)
|
|
6354
6061
|
throw new NotFoundError(`Wishlists from person ${personId} not found`);
|
|
6355
6062
|
return data;
|
|
6356
6063
|
}
|
|
6357
|
-
|
|
6064
|
+
getCategoryBySlug(slug, _shop) {
|
|
6358
6065
|
return this.getWishlistBySlug(slug);
|
|
6359
6066
|
}
|
|
6360
6067
|
async getCategoryByShop(shop) {
|
|
@@ -6372,17 +6079,10 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
6372
6079
|
});
|
|
6373
6080
|
return data;
|
|
6374
6081
|
}
|
|
6375
|
-
|
|
6376
|
-
var _a, _b;
|
|
6377
|
-
return this.find(Object.assign(Object.assign({}, params), { filters: Object.assign(Object.assign({}, params.filters), { published: true, shops: { operator: Where.LIKE, value: shops }, personType: (_b = (_a = params.filters) === null || _a === void 0 ? void 0 : _a.personType) !== null && _b !== void 0 ? _b : {
|
|
6378
|
-
operator: Where.IN,
|
|
6379
|
-
value: [PersonTypes.BFLU, PersonTypes.GLAMGIRL],
|
|
6380
|
-
} }), orderBy: Object.assign({ personHasPhoto: 'desc' }, omit(params.orderBy, ['personHasPhoto'])) }));
|
|
6381
|
-
}
|
|
6382
|
-
getCategoriesForHome(categoryIds, gender, limit) {
|
|
6082
|
+
getCategoriesForHome(categoryIds, limit, gender) {
|
|
6383
6083
|
return;
|
|
6384
6084
|
}
|
|
6385
|
-
mountCategory(category,
|
|
6085
|
+
mountCategory(category, options) {
|
|
6386
6086
|
return;
|
|
6387
6087
|
}
|
|
6388
6088
|
getChildren(parentId) {
|
|
@@ -6429,40 +6129,23 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
6429
6129
|
});
|
|
6430
6130
|
return plainData.products;
|
|
6431
6131
|
}
|
|
6432
|
-
async updateMetadata(categoryId, {
|
|
6433
|
-
|
|
6434
|
-
|
|
6435
|
-
|
|
6436
|
-
|
|
6437
|
-
|
|
6438
|
-
|
|
6439
|
-
|
|
6440
|
-
|
|
6441
|
-
|
|
6442
|
-
|
|
6443
|
-
|
|
6444
|
-
|
|
6445
|
-
|
|
6446
|
-
|
|
6447
|
-
|
|
6448
|
-
|
|
6449
|
-
});
|
|
6450
|
-
metadataUpdated.push(update);
|
|
6451
|
-
}
|
|
6452
|
-
return metadataUpdated;
|
|
6453
|
-
}
|
|
6454
|
-
if ('action' in metadatas && metadatas.action === 'remove' && metadatas.value.length) {
|
|
6455
|
-
for (let i = 0; i < metadatas.value.length; i++) {
|
|
6456
|
-
await this.mutation('delete_category_metadata', ['affected_rows'], {
|
|
6457
|
-
where: {
|
|
6458
|
-
type: 'category_metadata_bool_exp',
|
|
6459
|
-
required: true,
|
|
6460
|
-
value: { category_id: { _eq: categoryId }, shop: metadatas.value[i].shop },
|
|
6461
|
-
},
|
|
6462
|
-
});
|
|
6463
|
-
}
|
|
6464
|
-
return [];
|
|
6465
|
-
}
|
|
6132
|
+
async updateMetadata(categoryId, { metadata }) {
|
|
6133
|
+
const plainData = this.paramsToPlain({ metadata });
|
|
6134
|
+
if (!plainData.metadata)
|
|
6135
|
+
return;
|
|
6136
|
+
await this.mutation('update_category_metadata_by_pk', ['category_id'], {
|
|
6137
|
+
pk_columns: {
|
|
6138
|
+
value: { category_id: categoryId },
|
|
6139
|
+
type: 'category_metadata_pk_columns_input',
|
|
6140
|
+
required: true,
|
|
6141
|
+
},
|
|
6142
|
+
_set: {
|
|
6143
|
+
value: omit(metadata, ['category_id']),
|
|
6144
|
+
type: 'category_metadata_set_input',
|
|
6145
|
+
required: true,
|
|
6146
|
+
},
|
|
6147
|
+
});
|
|
6148
|
+
return plainData.metadata;
|
|
6466
6149
|
}
|
|
6467
6150
|
}
|
|
6468
6151
|
__decorate([
|
|
@@ -6483,164 +6166,5 @@ __decorate([
|
|
|
6483
6166
|
__metadata("design:paramtypes", [String]),
|
|
6484
6167
|
__metadata("design:returntype", Promise)
|
|
6485
6168
|
], WishlistHasuraGraphQLRepository.prototype, "getCategoryByShop", null);
|
|
6486
|
-
__decorate([
|
|
6487
|
-
Log(),
|
|
6488
|
-
__metadata("design:type", Function),
|
|
6489
|
-
__metadata("design:paramtypes", [Object, Array]),
|
|
6490
|
-
__metadata("design:returntype", Promise)
|
|
6491
|
-
], WishlistHasuraGraphQLRepository.prototype, "findBfluOrGlamgirlWishlists", null);
|
|
6492
|
-
|
|
6493
|
-
class VertexAxiosAdapter {
|
|
6494
|
-
constructor(config) {
|
|
6495
|
-
this.config = config;
|
|
6496
|
-
this.logger = DebugHelper.from(this);
|
|
6497
|
-
}
|
|
6498
|
-
async query(term, total, gender) {
|
|
6499
|
-
const logger = this.logger.with('query');
|
|
6500
|
-
const req = {
|
|
6501
|
-
url: `${this.config.url}/search`,
|
|
6502
|
-
method: 'POST',
|
|
6503
|
-
responseType: 'json',
|
|
6504
|
-
headers: {
|
|
6505
|
-
Accept: 'application/json',
|
|
6506
|
-
},
|
|
6507
|
-
data: { term, total, gender },
|
|
6508
|
-
};
|
|
6509
|
-
try {
|
|
6510
|
-
const { data } = await axios(req);
|
|
6511
|
-
return data;
|
|
6512
|
-
}
|
|
6513
|
-
catch (error) {
|
|
6514
|
-
logger.error({ req, res: error });
|
|
6515
|
-
throw error;
|
|
6516
|
-
}
|
|
6517
|
-
}
|
|
6518
|
-
async get(id) {
|
|
6519
|
-
const logger = this.logger.with('update');
|
|
6520
|
-
const req = {
|
|
6521
|
-
url: `${this.config.url}/${id}`,
|
|
6522
|
-
method: 'GET',
|
|
6523
|
-
responseType: 'json',
|
|
6524
|
-
headers: {
|
|
6525
|
-
Accept: 'application/json',
|
|
6526
|
-
},
|
|
6527
|
-
};
|
|
6528
|
-
try {
|
|
6529
|
-
const { data } = await axios(req);
|
|
6530
|
-
return data;
|
|
6531
|
-
}
|
|
6532
|
-
catch (error) {
|
|
6533
|
-
logger.error({ req, res: error });
|
|
6534
|
-
throw error;
|
|
6535
|
-
}
|
|
6536
|
-
}
|
|
6537
|
-
async save(data) {
|
|
6538
|
-
const logger = this.logger.with('save');
|
|
6539
|
-
const req = {
|
|
6540
|
-
url: `${this.config.url}/sync`,
|
|
6541
|
-
method: 'POST',
|
|
6542
|
-
responseType: 'json',
|
|
6543
|
-
headers: {
|
|
6544
|
-
Accept: 'application/json',
|
|
6545
|
-
},
|
|
6546
|
-
data,
|
|
6547
|
-
};
|
|
6548
|
-
try {
|
|
6549
|
-
const { data } = await axios(req);
|
|
6550
|
-
return data;
|
|
6551
|
-
}
|
|
6552
|
-
catch (error) {
|
|
6553
|
-
logger.error({ req, res: error });
|
|
6554
|
-
throw error;
|
|
6555
|
-
}
|
|
6556
|
-
}
|
|
6557
|
-
async update(id, data) {
|
|
6558
|
-
const logger = this.logger.with('update');
|
|
6559
|
-
const req = {
|
|
6560
|
-
url: `${this.config.url}/${id}`,
|
|
6561
|
-
method: 'PUT',
|
|
6562
|
-
responseType: 'json',
|
|
6563
|
-
headers: {
|
|
6564
|
-
Accept: 'application/json',
|
|
6565
|
-
},
|
|
6566
|
-
data,
|
|
6567
|
-
};
|
|
6568
|
-
try {
|
|
6569
|
-
const { data } = await axios(req);
|
|
6570
|
-
return data;
|
|
6571
|
-
}
|
|
6572
|
-
catch (error) {
|
|
6573
|
-
logger.error({ req, res: error });
|
|
6574
|
-
throw error;
|
|
6575
|
-
}
|
|
6576
|
-
}
|
|
6577
|
-
async delete(id) {
|
|
6578
|
-
const logger = this.logger.with('delete');
|
|
6579
|
-
const req = {
|
|
6580
|
-
url: `${this.config.url}/${id}`,
|
|
6581
|
-
method: 'DELETE',
|
|
6582
|
-
responseType: 'json',
|
|
6583
|
-
headers: {
|
|
6584
|
-
Accept: 'application/json',
|
|
6585
|
-
},
|
|
6586
|
-
};
|
|
6587
|
-
try {
|
|
6588
|
-
const { data } = await axios(req);
|
|
6589
|
-
return data;
|
|
6590
|
-
}
|
|
6591
|
-
catch (error) {
|
|
6592
|
-
logger.error({ req, res: error });
|
|
6593
|
-
throw error;
|
|
6594
|
-
}
|
|
6595
|
-
}
|
|
6596
|
-
bulkProducts(products) {
|
|
6597
|
-
return;
|
|
6598
|
-
}
|
|
6599
|
-
}
|
|
6600
|
-
|
|
6601
|
-
class ProductsVertexSearch {
|
|
6602
|
-
constructor(adapter) {
|
|
6603
|
-
this.adapter = adapter;
|
|
6604
|
-
}
|
|
6605
|
-
async getById(id) {
|
|
6606
|
-
const data = await this.adapter.get(id);
|
|
6607
|
-
return data;
|
|
6608
|
-
}
|
|
6609
|
-
async search(searchTerm, total, gender) {
|
|
6610
|
-
try {
|
|
6611
|
-
const result = await this.adapter.query(searchTerm, total, gender);
|
|
6612
|
-
return result;
|
|
6613
|
-
}
|
|
6614
|
-
catch (error) {
|
|
6615
|
-
console.error(error);
|
|
6616
|
-
}
|
|
6617
|
-
}
|
|
6618
|
-
async save(product) {
|
|
6619
|
-
try {
|
|
6620
|
-
const _a = product.toPlain(), { createdAt, updatedAt, kitProducts } = _a, data = __rest(_a, ["createdAt", "updatedAt", "kitProducts"]);
|
|
6621
|
-
const newProduct = Product.toInstance(data);
|
|
6622
|
-
await this.adapter.save(newProduct);
|
|
6623
|
-
}
|
|
6624
|
-
catch (error) {
|
|
6625
|
-
console.error(error);
|
|
6626
|
-
}
|
|
6627
|
-
}
|
|
6628
|
-
async update(product) {
|
|
6629
|
-
try {
|
|
6630
|
-
await this.adapter.update(product.id, product);
|
|
6631
|
-
}
|
|
6632
|
-
catch (error) {
|
|
6633
|
-
console.error(error);
|
|
6634
|
-
}
|
|
6635
|
-
}
|
|
6636
|
-
async delete(id) {
|
|
6637
|
-
try {
|
|
6638
|
-
await this.adapter.delete(id);
|
|
6639
|
-
}
|
|
6640
|
-
catch (error) {
|
|
6641
|
-
console.error(error);
|
|
6642
|
-
}
|
|
6643
|
-
}
|
|
6644
|
-
}
|
|
6645
6169
|
|
|
6646
|
-
export { AccessoryImportances, Address, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository, Campaign, CampaignBanner, CampaignDashboard, CampaignDashboardFirestoreRepository, CampaignHashtag, CampaignHashtagFirestoreRepository, Category, CategoryCollectionChildren, CategoryCollectionChildrenHasuraGraphQLRepository, CategoryFilter, CategoryFilterHasuraGraphQLRepository, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, ClassNameHelper, ConnectBaseDocumentSnapshot, ConnectCollectionService, ConnectDocumentService, ConnectFirestoreService, Coupon,
|
|
6170
|
+
export { AccessoryImportances, Address, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository, Campaign, CampaignBanner, CampaignDashboard, CampaignDashboardFirestoreRepository, CampaignHashtag, CampaignHashtagFirestoreRepository, Category, CategoryCollectionChildren, CategoryCollectionChildrenHasuraGraphQLRepository, CategoryFilter, CategoryFilterHasuraGraphQLRepository, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, ClassNameHelper, ConnectBaseDocumentSnapshot, ConnectCollectionService, ConnectDocumentService, ConnectFirestoreService, Coupon, CouponFirestoreRepository, CouponSubtypes, CouponTypes, Debug, DebugDecoratorHelper, DebugHelper, DebugNamespaces, DuplicatedResultsError, Edition, EditionStatus, Exclusivities, FaceSkinOilinesses, FaceSkinProblems, FaceSkinTones, FamilyIncomes, Filter, FilterHasuraGraphQLRepository, FilterOption, FilterOptionHasuraGraphQLRepository, FilterType, FirebaseFileUploaderService, FragranceImportances, GenderDestination, HairColors, HairProblems, HairStrands, HairTypes, Home, HomeFirestoreRepository, InvalidArgumentError, KitProduct, KitProductHasuraGraphQL, Lead, LeadFirestoreRepository, LegacyOrderFirestoreRepository, LineItem, Log, Logger, NotFoundError, OfficePosition, Order, OrderFirestoreRepository, OrderStatus, Payment, PaymentFirestoreRepository, PaymentType, Plans, Product, ProductFirestoreRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductReviews, ProductReviewsHasuraGraphQLRepository, ProductSpents, ProductStockNotification, ProductStockNotificationHasuraGraphQLRepository, ProductVariantFirestoreRepository, ProductsIndex, QuestionsFilters, RecoveryPassword, ReflectHelper, Register, RegisterFirebaseAuthService, RequiredArgumentError, RoundProductPricesHelper, ShippingMethod, ShopMenu, ShopMenuFirestoreRepository, ShopPageName, ShopSettings, ShopSettingsFirestoreRepository, Shops, SignInMethods, SignOut, Status, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionMaterialization, SubscriptionMaterializationFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionSummary, SubscriptionSummaryFirestoreRepository, Trace, UnauthorizedError, UpdateOptionActions, UpdateUserImage, User, UserAddress, UserAddressFirestoreRepository, UserAlreadyRegisteredError, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserPaymentMethod, UserPaymentMethodFirestoreRepository, UserType, Variant, VariantHasuraGraphQL, VariantHasuraGraphQLRepository, WeakPasswordError, Where, Wishlist, WishlistHasuraGraphQLRepository, is, isDebuggable, isUUID, parseDateTime, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
|