@infrab4a/connect 4.9.7-beta.3 → 4.9.7-beta.30
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 +1048 -616
- package/index.esm.js +1041 -617
- package/package.json +1 -1
- package/src/domain/catalog/models/category-base.d.ts +17 -1
- package/src/domain/catalog/models/category-product.d.ts +8 -0
- package/src/domain/catalog/models/enums/index.d.ts +1 -0
- package/src/domain/catalog/models/enums/wishlist-log.enum.d.ts +7 -0
- package/src/domain/catalog/models/filter.d.ts +1 -0
- package/src/domain/catalog/models/index.d.ts +1 -0
- package/src/domain/catalog/models/product-base.d.ts +4 -1
- package/src/domain/catalog/models/types/category-images.type.d.ts +8 -0
- package/src/domain/catalog/models/types/category-metadata.type.d.ts +2 -0
- package/src/domain/catalog/models/types/category-most-relevant.type.d.ts +4 -0
- package/src/domain/catalog/models/types/index.d.ts +4 -1
- package/src/domain/catalog/models/types/product-label.type.d.ts +1 -0
- package/src/domain/catalog/models/types/report-stock-notification.type.d.ts +21 -0
- package/src/domain/catalog/models/variant.d.ts +2 -0
- package/src/domain/catalog/models/wishlist.d.ts +3 -0
- package/src/domain/catalog/repositories/category-product.repository.d.ts +6 -0
- package/src/domain/catalog/repositories/category.repository.d.ts +3 -3
- package/src/domain/catalog/repositories/index.d.ts +1 -0
- package/src/domain/catalog/repositories/product-reviews.repository.d.ts +1 -0
- package/src/domain/catalog/repositories/product-stock-notification.repository.d.ts +9 -1
- package/src/domain/catalog/repositories/wishlist.repository.d.ts +6 -1
- package/src/domain/general/index.d.ts +3 -0
- package/src/domain/general/models/index.d.ts +1 -0
- package/src/domain/general/models/log-document.d.ts +15 -0
- package/src/domain/general/repositories/index.d.ts +1 -0
- package/src/domain/general/repositories/log.repository.d.ts +4 -0
- package/src/domain/general/search/index.d.ts +1 -0
- package/src/domain/general/search/product-search-index.d.ts +3 -0
- package/src/domain/shopping/index.d.ts +1 -0
- package/src/domain/shopping/models/buy-2-win.d.ts +2 -0
- package/src/domain/shopping/models/coupons/coupon.d.ts +8 -4
- package/src/domain/shopping/models/coupons/enums/coupon-category.enum.d.ts +41 -0
- package/src/domain/shopping/models/coupons/enums/coupon-channels.enum.d.ts +10 -0
- package/src/domain/shopping/models/coupons/enums/coupon-types.enum.d.ts +2 -1
- package/src/domain/shopping/models/coupons/enums/index.d.ts +3 -1
- package/src/domain/shopping/models/coupons/types/coupon-category.type.d.ts +2 -0
- package/src/domain/shopping/models/coupons/types/coupon-channel.type.d.ts +2 -0
- package/src/domain/shopping/models/coupons/types/index.d.ts +2 -0
- package/src/domain/shopping/models/index.d.ts +1 -0
- package/src/domain/shopping/models/order-blocked.d.ts +26 -0
- package/src/domain/shopping/models/order.d.ts +4 -0
- package/src/domain/shopping/repositories/index.d.ts +1 -0
- package/src/domain/shopping/repositories/order-blocked.repository.d.ts +6 -0
- package/src/domain/shopping/types/index.d.ts +2 -0
- package/src/domain/shopping/types/order-tracking-events.type.d.ts +14 -0
- package/src/domain/shopping/types/payment-card-info.type.d.ts +4 -0
- package/src/domain/users/models/enums/index.d.ts +1 -0
- package/src/domain/users/models/enums/person-types.enum.d.ts +5 -0
- package/src/domain/users/models/index.d.ts +3 -2
- package/src/domain/users/models/types/index.d.ts +1 -0
- package/src/domain/users/models/types/person.type.d.ts +2 -0
- package/src/infra/elasticsearch/indexes/products-index.d.ts +39 -1
- 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/general/index.d.ts +1 -0
- package/src/infra/firebase/firestore/repositories/general/log-firestore.repository.d.ts +7 -0
- package/src/infra/firebase/firestore/repositories/index.d.ts +3 -2
- package/src/infra/firebase/firestore/repositories/shopping/index.d.ts +1 -0
- package/src/infra/firebase/firestore/repositories/shopping/order-blocked-firestore.repository.ts.d.ts +9 -0
- package/src/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.d.ts +1 -0
- package/src/infra/hasura-graphql/models/wishlist-hasura-graphql.d.ts +4 -0
- package/src/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.d.ts +2 -2
- package/src/infra/hasura-graphql/repositories/catalog/category-product-hasura-graphql.repository.d.ts +11 -0
- package/src/infra/hasura-graphql/repositories/catalog/index.d.ts +1 -0
- package/src/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.d.ts +0 -1
- package/src/infra/hasura-graphql/repositories/catalog/product-review-hasura-graphql.repository.d.ts +1 -0
- package/src/infra/hasura-graphql/repositories/catalog/product-stock-notification-hasura-graphql.repository.d.ts +8 -1
- package/src/infra/hasura-graphql/repositories/catalog/wishlist-hasura-graphql.repository.d.ts +18 -15
- package/src/infra/index.d.ts +1 -0
- package/src/infra/vertex-ai/adapters/index.d.ts +2 -0
- package/src/infra/vertex-ai/adapters/vertex-ai-search.adapter.d.ts +10 -0
- package/src/infra/vertex-ai/adapters/vertex-axios.adapter.d.ts +15 -0
- package/src/infra/vertex-ai/index.d.ts +3 -0
- package/src/infra/vertex-ai/indexes/index.d.ts +1 -0
- package/src/infra/vertex-ai/indexes/products-vertex-search.d.ts +13 -0
- package/src/infra/vertex-ai/types/axios-vertex-search-config.d.ts +4 -0
- package/src/infra/vertex-ai/types/index.d.ts +3 -0
- package/src/infra/vertex-ai/types/product-bulk.d.ts +4 -0
- package/src/infra/vertex-ai/types/product-search.d.ts +21 -0
package/index.esm.js
CHANGED
|
@@ -36,6 +36,30 @@ 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
|
+
|
|
39
63
|
class Filter extends BaseModel {
|
|
40
64
|
static get identifiersFields() {
|
|
41
65
|
return ['id'];
|
|
@@ -50,6 +74,33 @@ class CategoryBase extends BaseModel {
|
|
|
50
74
|
static get identifiersFields() {
|
|
51
75
|
return ['id'];
|
|
52
76
|
}
|
|
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
|
+
}
|
|
53
104
|
}
|
|
54
105
|
__decorate([
|
|
55
106
|
Type(() => CategoryBase),
|
|
@@ -158,20 +209,11 @@ __decorate([
|
|
|
158
209
|
__metadata("design:type", Category)
|
|
159
210
|
], CategoryFilter.prototype, "category", void 0);
|
|
160
211
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
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 = {}));
|
|
212
|
+
class CategoryProduct extends BaseModel {
|
|
213
|
+
static get identifiersFields() {
|
|
214
|
+
return ['categoryId', 'productId'];
|
|
215
|
+
}
|
|
216
|
+
}
|
|
175
217
|
|
|
176
218
|
class FilterOption extends BaseModel {
|
|
177
219
|
static get identifiersFields() {
|
|
@@ -265,6 +307,17 @@ class CampaignHashtag extends BaseModel {
|
|
|
265
307
|
}
|
|
266
308
|
}
|
|
267
309
|
|
|
310
|
+
class BeautyProfile extends BaseModel {
|
|
311
|
+
toPlain() {
|
|
312
|
+
const plain = super.toPlain();
|
|
313
|
+
delete plain.id;
|
|
314
|
+
return plain;
|
|
315
|
+
}
|
|
316
|
+
static get identifiersFields() {
|
|
317
|
+
return ['id', 'userId'];
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
268
321
|
var AccessoryImportances;
|
|
269
322
|
(function (AccessoryImportances) {
|
|
270
323
|
AccessoryImportances["NOT_INTERESTED"] = "N\u00E3o tenho interesse";
|
|
@@ -441,6 +494,13 @@ var OfficePosition;
|
|
|
441
494
|
OfficePosition["Director"] = "Diretor";
|
|
442
495
|
})(OfficePosition || (OfficePosition = {}));
|
|
443
496
|
|
|
497
|
+
var PersonTypes;
|
|
498
|
+
(function (PersonTypes) {
|
|
499
|
+
PersonTypes["GLAMGIRL"] = "glamgirl";
|
|
500
|
+
PersonTypes["BFLU"] = "bflu";
|
|
501
|
+
PersonTypes["NONE"] = "none";
|
|
502
|
+
})(PersonTypes || (PersonTypes = {}));
|
|
503
|
+
|
|
444
504
|
var ProductSpents;
|
|
445
505
|
(function (ProductSpents) {
|
|
446
506
|
ProductSpents["UNTIL_50"] = "At\u00E9 R$50";
|
|
@@ -461,6 +521,12 @@ var UserType;
|
|
|
461
521
|
UserType["Influencer"] = "Influencer";
|
|
462
522
|
})(UserType || (UserType = {}));
|
|
463
523
|
|
|
524
|
+
class Lead extends BaseModel {
|
|
525
|
+
static get identifiersFields() {
|
|
526
|
+
return ['id'];
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
|
|
464
530
|
class Edition extends BaseModel {
|
|
465
531
|
static get identifiersFields() {
|
|
466
532
|
return ['id', 'subscriptionId'];
|
|
@@ -1786,40 +1852,6 @@ const parseDateTime = (value) => {
|
|
|
1786
1852
|
return date;
|
|
1787
1853
|
};
|
|
1788
1854
|
|
|
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;
|
|
1823
1855
|
class Coupon extends BaseModel {
|
|
1824
1856
|
get isInfluencer() {
|
|
1825
1857
|
return !isNil(this.influencerEmail);
|
|
@@ -1827,30 +1859,6 @@ class Coupon extends BaseModel {
|
|
|
1827
1859
|
static get identifiersFields() {
|
|
1828
1860
|
return ['id'];
|
|
1829
1861
|
}
|
|
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
|
-
}
|
|
1854
1862
|
}
|
|
1855
1863
|
|
|
1856
1864
|
class SubscriptionPlan extends BaseModel {
|
|
@@ -1859,17 +1867,6 @@ class SubscriptionPlan extends BaseModel {
|
|
|
1859
1867
|
}
|
|
1860
1868
|
}
|
|
1861
1869
|
|
|
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
|
-
|
|
1873
1870
|
class User extends BaseModel {
|
|
1874
1871
|
static toInstance(data) {
|
|
1875
1872
|
const instance = super.toInstance(data);
|
|
@@ -1983,12 +1980,6 @@ class UserPaymentMethod extends BaseModel {
|
|
|
1983
1980
|
}
|
|
1984
1981
|
}
|
|
1985
1982
|
|
|
1986
|
-
class Lead extends BaseModel {
|
|
1987
|
-
static get identifiersFields() {
|
|
1988
|
-
return ['id'];
|
|
1989
|
-
}
|
|
1990
|
-
}
|
|
1991
|
-
|
|
1992
1983
|
class UnauthorizedError extends CustomError {
|
|
1993
1984
|
constructor(message) {
|
|
1994
1985
|
super(message);
|
|
@@ -2142,6 +2133,93 @@ __decorate([
|
|
|
2142
2133
|
__metadata("design:type", Coupon)
|
|
2143
2134
|
], Checkout.prototype, "coupon", void 0);
|
|
2144
2135
|
|
|
2136
|
+
var CouponCategory;
|
|
2137
|
+
(function (CouponCategory) {
|
|
2138
|
+
CouponCategory["Reembolso"] = "Reembolso";
|
|
2139
|
+
CouponCategory["Desculpas"] = "Desculpas";
|
|
2140
|
+
CouponCategory["BFlu"] = "BFlu";
|
|
2141
|
+
CouponCategory["ROYAL"] = "Royal";
|
|
2142
|
+
CouponCategory["Glamqueens"] = "Glamqueens";
|
|
2143
|
+
CouponCategory["Glampartner"] = "Glampartner";
|
|
2144
|
+
CouponCategory["Glamgirls"] = "Glamgirls";
|
|
2145
|
+
CouponCategory["Glamdiva"] = "Glamdiva";
|
|
2146
|
+
CouponCategory["Impulsionamento"] = "Impulsionamento";
|
|
2147
|
+
CouponCategory["PaidMedia"] = "Paid Media";
|
|
2148
|
+
CouponCategory["Organic"] = "Organic";
|
|
2149
|
+
CouponCategory["Direct"] = "Direct";
|
|
2150
|
+
CouponCategory["CRM"] = "CRM";
|
|
2151
|
+
CouponCategory["LOJAUNICO"] = "Loja \u00FAnico";
|
|
2152
|
+
CouponCategory["Outros"] = "Outros";
|
|
2153
|
+
})(CouponCategory || (CouponCategory = {}));
|
|
2154
|
+
var CouponOldCategories;
|
|
2155
|
+
(function (CouponOldCategories) {
|
|
2156
|
+
CouponOldCategories["Reembolso"] = "Reembolso";
|
|
2157
|
+
CouponOldCategories["Desculpas"] = "Desculpas";
|
|
2158
|
+
CouponOldCategories["BFlu"] = "BFlu";
|
|
2159
|
+
CouponOldCategories["ROYAL"] = "Royal";
|
|
2160
|
+
CouponOldCategories["Glamqueens"] = "Glamqueens";
|
|
2161
|
+
CouponOldCategories["Glampartner"] = "Glampartner";
|
|
2162
|
+
CouponOldCategories["Glamgirls"] = "Glamgirls";
|
|
2163
|
+
CouponOldCategories["Glamdiva"] = "Glamdiva";
|
|
2164
|
+
CouponOldCategories["Impulsionamento"] = "Impulsionamento";
|
|
2165
|
+
CouponOldCategories["PaidMedia"] = "Paid Media";
|
|
2166
|
+
CouponOldCategories["Organic"] = "Organic";
|
|
2167
|
+
CouponOldCategories["Direct"] = "Direct";
|
|
2168
|
+
CouponOldCategories["CRM"] = "CRM";
|
|
2169
|
+
CouponOldCategories["LOJAUNICO"] = "Loja \u00FAnico";
|
|
2170
|
+
CouponOldCategories["Outros"] = "Outros";
|
|
2171
|
+
})(CouponOldCategories || (CouponOldCategories = {}));
|
|
2172
|
+
var CouponCategories;
|
|
2173
|
+
(function (CouponCategories) {
|
|
2174
|
+
CouponCategories["API_001"] = "API-001";
|
|
2175
|
+
CouponCategories["COMPRE_E_GANHE"] = "COMPRE E GANHE";
|
|
2176
|
+
CouponCategories["DESCONTO"] = "DESCONTO";
|
|
2177
|
+
CouponCategories["REEMBOLSO"] = "REEMBOLSO";
|
|
2178
|
+
CouponCategories["DESCULPAS"] = "DESCULPAS";
|
|
2179
|
+
})(CouponCategories || (CouponCategories = {}));
|
|
2180
|
+
|
|
2181
|
+
var CouponChannels;
|
|
2182
|
+
(function (CouponChannels) {
|
|
2183
|
+
CouponChannels["BANNER"] = "7";
|
|
2184
|
+
CouponChannels["BFLUENCE"] = "3";
|
|
2185
|
+
CouponChannels["CRM"] = "2";
|
|
2186
|
+
CouponChannels["GLAMGIRL"] = "0";
|
|
2187
|
+
CouponChannels["PAID"] = "4";
|
|
2188
|
+
CouponChannels["ROYAL"] = "1";
|
|
2189
|
+
CouponChannels["SAC"] = "8";
|
|
2190
|
+
CouponChannels["SOCIAL"] = "5";
|
|
2191
|
+
})(CouponChannels || (CouponChannels = {}));
|
|
2192
|
+
|
|
2193
|
+
var CouponSubtypes;
|
|
2194
|
+
(function (CouponSubtypes) {
|
|
2195
|
+
CouponSubtypes[CouponSubtypes["ABSOLUTE"] = 1] = "ABSOLUTE";
|
|
2196
|
+
CouponSubtypes[CouponSubtypes["PERCENTAGE"] = 2] = "PERCENTAGE";
|
|
2197
|
+
})(CouponSubtypes || (CouponSubtypes = {}));
|
|
2198
|
+
|
|
2199
|
+
var CouponTypes;
|
|
2200
|
+
(function (CouponTypes) {
|
|
2201
|
+
CouponTypes[CouponTypes["ABSOLUTE"] = 1] = "ABSOLUTE";
|
|
2202
|
+
CouponTypes[CouponTypes["PERCENTAGE"] = 2] = "PERCENTAGE";
|
|
2203
|
+
CouponTypes[CouponTypes["SHIPPING"] = 3] = "SHIPPING";
|
|
2204
|
+
})(CouponTypes || (CouponTypes = {}));
|
|
2205
|
+
|
|
2206
|
+
var Exclusivities;
|
|
2207
|
+
(function (Exclusivities) {
|
|
2208
|
+
Exclusivities[Exclusivities["ALL_USERS"] = 1] = "ALL_USERS";
|
|
2209
|
+
Exclusivities[Exclusivities["SPECIFIC_USER"] = 2] = "SPECIFIC_USER";
|
|
2210
|
+
Exclusivities[Exclusivities["COLLABORATORS"] = 3] = "COLLABORATORS";
|
|
2211
|
+
Exclusivities[Exclusivities["ACTIVE_SUBSCRIBER"] = 4] = "ACTIVE_SUBSCRIBER";
|
|
2212
|
+
Exclusivities[Exclusivities["INACTIVE_SUBSCRIBER"] = 5] = "INACTIVE_SUBSCRIBER";
|
|
2213
|
+
Exclusivities[Exclusivities["NON_SUBSCRIBER"] = 6] = "NON_SUBSCRIBER";
|
|
2214
|
+
})(Exclusivities || (Exclusivities = {}));
|
|
2215
|
+
|
|
2216
|
+
var CheckoutTypes;
|
|
2217
|
+
(function (CheckoutTypes) {
|
|
2218
|
+
CheckoutTypes[CheckoutTypes["ECOMMERCE"] = 1] = "ECOMMERCE";
|
|
2219
|
+
CheckoutTypes[CheckoutTypes["SUBSCRIPTION"] = 2] = "SUBSCRIPTION";
|
|
2220
|
+
CheckoutTypes[CheckoutTypes["ALL"] = 3] = "ALL";
|
|
2221
|
+
})(CheckoutTypes || (CheckoutTypes = {}));
|
|
2222
|
+
|
|
2145
2223
|
var OrderStatus;
|
|
2146
2224
|
(function (OrderStatus) {
|
|
2147
2225
|
OrderStatus["AGUARDANDO_PAGAMENTO"] = "Aguardando pagamento";
|
|
@@ -2161,6 +2239,12 @@ __decorate([
|
|
|
2161
2239
|
__metadata("design:type", Payment)
|
|
2162
2240
|
], Order.prototype, "payment", void 0);
|
|
2163
2241
|
|
|
2242
|
+
class OrderBlocked extends BaseModel {
|
|
2243
|
+
static get identifiersFields() {
|
|
2244
|
+
return ['id'];
|
|
2245
|
+
}
|
|
2246
|
+
}
|
|
2247
|
+
|
|
2164
2248
|
class CheckoutSubscription extends BaseModel {
|
|
2165
2249
|
static get identifiersFields() {
|
|
2166
2250
|
return ['id'];
|
|
@@ -2197,6 +2281,12 @@ class RoundProductPricesHelper {
|
|
|
2197
2281
|
}
|
|
2198
2282
|
}
|
|
2199
2283
|
|
|
2284
|
+
class LogDocument extends BaseModel {
|
|
2285
|
+
static get identifiersFields() {
|
|
2286
|
+
return ['id'];
|
|
2287
|
+
}
|
|
2288
|
+
}
|
|
2289
|
+
|
|
2200
2290
|
var FilterType;
|
|
2201
2291
|
(function (FilterType) {
|
|
2202
2292
|
FilterType["ACCESSORY_IMPORTANCE"] = "accessoryImportance";
|
|
@@ -2495,8 +2585,6 @@ class ProductsIndex {
|
|
|
2495
2585
|
'rate',
|
|
2496
2586
|
];
|
|
2497
2587
|
const filter = [{ term: { published: true } }];
|
|
2498
|
-
if (shop && shop !== Shops.ALL)
|
|
2499
|
-
filter.push({ term: { tags: shop == Shops.GLAMSHOP ? 'feminino' : 'masculino' } });
|
|
2500
2588
|
if (size > 9)
|
|
2501
2589
|
fields.push(...['pricePaid', 'isGift', 'stock', 'weight', 'tags']);
|
|
2502
2590
|
const query = {
|
|
@@ -2552,7 +2640,9 @@ class ProductsIndex {
|
|
|
2552
2640
|
RoundProductPricesHelper.roundProductPrices(hit._source);
|
|
2553
2641
|
return hit;
|
|
2554
2642
|
});
|
|
2555
|
-
return search
|
|
2643
|
+
return search.hits.map((hit) => {
|
|
2644
|
+
return Object.assign(Object.assign({}, hit._source), { stock: hit._source.stock.quantity });
|
|
2645
|
+
});
|
|
2556
2646
|
}
|
|
2557
2647
|
async save(product) {
|
|
2558
2648
|
try {
|
|
@@ -2986,6 +3076,8 @@ const withUpdateFirestore = (MixinBase) => {
|
|
|
2986
3076
|
try {
|
|
2987
3077
|
const identifiers = getValueFromParams(data, keyField);
|
|
2988
3078
|
const docRef = this.collection(collectionName).getDoc(identifiers.toString());
|
|
3079
|
+
if (!(await docRef.get()).data())
|
|
3080
|
+
throw new NotFoundError(`Document '${collectionName}/${Object.values(identifiers.toString())}' not found`);
|
|
2989
3081
|
const plainFromData = this.model.toInstance(this.paramsToPlain(data));
|
|
2990
3082
|
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 }));
|
|
2991
3083
|
const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || plainFromData;
|
|
@@ -3062,275 +3154,101 @@ const withCrudFirestore = (MixinBase) => {
|
|
|
3062
3154
|
};
|
|
3063
3155
|
};
|
|
3064
3156
|
|
|
3065
|
-
class
|
|
3157
|
+
class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3066
3158
|
constructor({ firestore, interceptors }) {
|
|
3067
3159
|
super({
|
|
3068
3160
|
firestore,
|
|
3069
|
-
collectionName: '
|
|
3070
|
-
model:
|
|
3161
|
+
collectionName: 'categories',
|
|
3162
|
+
model: Category,
|
|
3071
3163
|
interceptors,
|
|
3072
3164
|
});
|
|
3073
3165
|
}
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
this.parentRepository = parentRepository;
|
|
3166
|
+
async getCategoryBySlug(slug, shop) {
|
|
3167
|
+
const categoryDocs = await this.collection(this.collectionName)
|
|
3168
|
+
.where('slug', '==', slug)
|
|
3169
|
+
.where('shop', '==', shop)
|
|
3170
|
+
.where('published', '==', true)
|
|
3171
|
+
.getDocs();
|
|
3172
|
+
if (categoryDocs.size > 1)
|
|
3173
|
+
throw new DuplicatedResultsError('Query returned duplicated values');
|
|
3174
|
+
if (categoryDocs.empty)
|
|
3175
|
+
throw new NotFoundError(`Document with slug ${slug} not found`);
|
|
3176
|
+
return categoryDocs.docs[0].data();
|
|
3086
3177
|
}
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3178
|
+
async getCategoriesForHome(categoryIds, shop, limit = 4) {
|
|
3179
|
+
const categorySnap = await this.collection(this.collectionName)
|
|
3180
|
+
.where('id', 'in', categoryIds.filter(Boolean))
|
|
3181
|
+
.where('published', '==', true)
|
|
3182
|
+
.getDocs();
|
|
3183
|
+
if (categorySnap.empty)
|
|
3184
|
+
throw new NotFoundError('Categories not found');
|
|
3185
|
+
const categories = categorySnap.docs.map((doc) => doc.data());
|
|
3186
|
+
const homeSections = await Promise.all(categories.map(async (category) => ({
|
|
3187
|
+
category,
|
|
3188
|
+
products: await this.mountCategory(category, shop, { limit, hasStock: true }),
|
|
3189
|
+
})));
|
|
3190
|
+
return homeSections;
|
|
3191
|
+
}
|
|
3192
|
+
async mountCategory(category, shop, options) {
|
|
3193
|
+
if (!category.products)
|
|
3194
|
+
throw new RequiredArgumentError(['Category products is empty']);
|
|
3195
|
+
const chunks = chunk(category.products, 10);
|
|
3196
|
+
const products = [];
|
|
3197
|
+
const wheres = [];
|
|
3198
|
+
for (const productIds of chunks) {
|
|
3199
|
+
if ((options === null || options === void 0 ? void 0 : options.limit) && products.length >= (options === null || options === void 0 ? void 0 : options.limit))
|
|
3200
|
+
break;
|
|
3201
|
+
wheres.push(['published', '==', true], ['id', 'in', productIds]);
|
|
3202
|
+
if (options === null || options === void 0 ? void 0 : options.hasStock)
|
|
3203
|
+
wheres.push(['stock.quantity', '>', 0]);
|
|
3204
|
+
if (options === null || options === void 0 ? void 0 : options.gender)
|
|
3205
|
+
wheres.push(['tags', 'array-contains', options === null || options === void 0 ? void 0 : options.gender]);
|
|
3206
|
+
const productSnap = await wheres
|
|
3207
|
+
.reduce((collection, where) => collection.where(...where), (options === null || options === void 0 ? void 0 : options.limit)
|
|
3208
|
+
? this.collection('productsErpVitrine').limit(options.limit)
|
|
3209
|
+
: this.collection('productsErpVitrine'))
|
|
3210
|
+
.getDocs();
|
|
3211
|
+
if (productSnap.empty)
|
|
3212
|
+
continue;
|
|
3213
|
+
products.push(...productSnap.docs);
|
|
3214
|
+
}
|
|
3215
|
+
return is(products);
|
|
3216
|
+
}
|
|
3217
|
+
getCategoryByShop(shop) {
|
|
3218
|
+
return;
|
|
3219
|
+
}
|
|
3220
|
+
getChildren(parentId) {
|
|
3221
|
+
return;
|
|
3222
|
+
}
|
|
3223
|
+
isChild(id, parentId) {
|
|
3224
|
+
return;
|
|
3097
3225
|
}
|
|
3098
3226
|
}
|
|
3227
|
+
__decorate([
|
|
3228
|
+
Log(),
|
|
3229
|
+
__metadata("design:type", Function),
|
|
3230
|
+
__metadata("design:paramtypes", [String, String]),
|
|
3231
|
+
__metadata("design:returntype", Promise)
|
|
3232
|
+
], CategoryFirestoreRepository.prototype, "getCategoryBySlug", null);
|
|
3233
|
+
__decorate([
|
|
3234
|
+
Log(),
|
|
3235
|
+
__metadata("design:type", Function),
|
|
3236
|
+
__metadata("design:paramtypes", [Array, String, Object]),
|
|
3237
|
+
__metadata("design:returntype", Promise)
|
|
3238
|
+
], CategoryFirestoreRepository.prototype, "getCategoriesForHome", null);
|
|
3239
|
+
__decorate([
|
|
3240
|
+
Log(),
|
|
3241
|
+
__metadata("design:type", Function),
|
|
3242
|
+
__metadata("design:paramtypes", [Category, String, Object]),
|
|
3243
|
+
__metadata("design:returntype", Promise)
|
|
3244
|
+
], CategoryFirestoreRepository.prototype, "mountCategory", null);
|
|
3099
3245
|
|
|
3100
|
-
class
|
|
3246
|
+
class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3101
3247
|
constructor({ firestore, interceptors }) {
|
|
3102
3248
|
super({
|
|
3103
3249
|
firestore,
|
|
3104
|
-
collectionName: '
|
|
3105
|
-
model:
|
|
3106
|
-
interceptors,
|
|
3107
|
-
});
|
|
3108
|
-
}
|
|
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;
|
|
3121
|
-
}
|
|
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,
|
|
3131
|
-
});
|
|
3132
|
-
}
|
|
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,
|
|
3143
|
-
});
|
|
3144
|
-
this.parentRepository = parentRepository;
|
|
3145
|
-
}
|
|
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;
|
|
3158
|
-
}
|
|
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
|
-
});
|
|
3169
|
-
}
|
|
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
|
-
};
|
|
3211
|
-
}
|
|
3212
|
-
}
|
|
3213
|
-
__decorate([
|
|
3214
|
-
Log(),
|
|
3215
|
-
__metadata("design:type", Function),
|
|
3216
|
-
__metadata("design:paramtypes", [Object]),
|
|
3217
|
-
__metadata("design:returntype", Promise)
|
|
3218
|
-
], UserFirestoreRepository.prototype, "get", null);
|
|
3219
|
-
__decorate([
|
|
3220
|
-
Log(),
|
|
3221
|
-
__metadata("design:type", Function),
|
|
3222
|
-
__metadata("design:paramtypes", [String, String]),
|
|
3223
|
-
__metadata("design:returntype", Promise)
|
|
3224
|
-
], UserFirestoreRepository.prototype, "checkIfExistsByField", null);
|
|
3225
|
-
|
|
3226
|
-
class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3227
|
-
constructor({ firestore, interceptors }, parentRepository) {
|
|
3228
|
-
super({
|
|
3229
|
-
firestore,
|
|
3230
|
-
collectionName: 'payment_method',
|
|
3231
|
-
parentIdField: 'userId',
|
|
3232
|
-
model: UserPaymentMethod,
|
|
3233
|
-
interceptors,
|
|
3234
|
-
});
|
|
3235
|
-
this.parentRepository = parentRepository;
|
|
3236
|
-
}
|
|
3237
|
-
}
|
|
3238
|
-
|
|
3239
|
-
class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3240
|
-
constructor({ firestore, interceptors }) {
|
|
3241
|
-
super({
|
|
3242
|
-
firestore,
|
|
3243
|
-
collectionName: 'categories',
|
|
3244
|
-
model: Category,
|
|
3245
|
-
interceptors,
|
|
3246
|
-
});
|
|
3247
|
-
}
|
|
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;
|
|
3307
|
-
}
|
|
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);
|
|
3327
|
-
|
|
3328
|
-
class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3329
|
-
constructor({ firestore, interceptors }) {
|
|
3330
|
-
super({
|
|
3331
|
-
firestore,
|
|
3332
|
-
collectionName: 'productsErpVitrine',
|
|
3333
|
-
model: Product,
|
|
3250
|
+
collectionName: 'productsErpVitrine',
|
|
3251
|
+
model: Product,
|
|
3334
3252
|
interceptors,
|
|
3335
3253
|
});
|
|
3336
3254
|
this.reviews = {};
|
|
@@ -3420,6 +3338,101 @@ class SubscriptionProductFirestoreRepository extends withCrudFirestore(withHelpe
|
|
|
3420
3338
|
}
|
|
3421
3339
|
}
|
|
3422
3340
|
|
|
3341
|
+
class LogFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3342
|
+
constructor({ firestore, interceptors, }) {
|
|
3343
|
+
super({
|
|
3344
|
+
firestore,
|
|
3345
|
+
collectionName: 'logs',
|
|
3346
|
+
model: LogDocument,
|
|
3347
|
+
interceptors,
|
|
3348
|
+
});
|
|
3349
|
+
}
|
|
3350
|
+
}
|
|
3351
|
+
|
|
3352
|
+
class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3353
|
+
constructor({ firestore, interceptors }) {
|
|
3354
|
+
super({
|
|
3355
|
+
firestore,
|
|
3356
|
+
collectionName: 'dms',
|
|
3357
|
+
model: Home,
|
|
3358
|
+
interceptors,
|
|
3359
|
+
});
|
|
3360
|
+
this.homeCategoryGroupToPlain = (homeCategoryGroup) => {
|
|
3361
|
+
var _a, _b, _c;
|
|
3362
|
+
return ({
|
|
3363
|
+
category: ((_a = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _a === void 0 ? void 0 : _a.toPlain)
|
|
3364
|
+
? (_b = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _b === void 0 ? void 0 : _b.toPlain()
|
|
3365
|
+
: homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category,
|
|
3366
|
+
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)) || [],
|
|
3367
|
+
});
|
|
3368
|
+
};
|
|
3369
|
+
this.plainToHomeCategoryGroup = (homeCategoryGroup) => {
|
|
3370
|
+
var _a;
|
|
3371
|
+
return ({
|
|
3372
|
+
category: Category.toInstance(homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category),
|
|
3373
|
+
products: (_a = homeCategoryGroup.products) === null || _a === void 0 ? void 0 : _a.map((product) => Product.toInstance(product)),
|
|
3374
|
+
});
|
|
3375
|
+
};
|
|
3376
|
+
}
|
|
3377
|
+
buildModelInstance() {
|
|
3378
|
+
const { fromFirestore, toFirestore } = super.buildModelInstance();
|
|
3379
|
+
return {
|
|
3380
|
+
toFirestore: (data) => {
|
|
3381
|
+
const modifiedData = this.homeToFirestore(data);
|
|
3382
|
+
return toFirestore(modifiedData);
|
|
3383
|
+
},
|
|
3384
|
+
fromFirestore: (snap) => {
|
|
3385
|
+
const instance = fromFirestore(snap);
|
|
3386
|
+
return this.homeFromFirestore(instance);
|
|
3387
|
+
},
|
|
3388
|
+
};
|
|
3389
|
+
}
|
|
3390
|
+
homeToFirestore(home) {
|
|
3391
|
+
var _a, _b, _c, _d;
|
|
3392
|
+
if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
|
|
3393
|
+
home.data.data.discoverProducts = ((_b = home.data.data.discoverProducts) === null || _b === void 0 ? void 0 : _b.map(this.homeCategoryGroupToPlain)) || [];
|
|
3394
|
+
home.data.data.featuredProducts = ((_c = home.data.data.featuredProducts) === null || _c === void 0 ? void 0 : _c.map(this.homeCategoryGroupToPlain)) || [];
|
|
3395
|
+
home.data.data.verticalProducts = ((_d = home.data.data.verticalProducts) === null || _d === void 0 ? void 0 : _d.map(this.homeCategoryGroupToPlain)) || [];
|
|
3396
|
+
}
|
|
3397
|
+
return home;
|
|
3398
|
+
}
|
|
3399
|
+
homeFromFirestore(home) {
|
|
3400
|
+
var _a;
|
|
3401
|
+
if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
|
|
3402
|
+
home.data.data.discoverProducts = home.data.data.discoverProducts.map(this.plainToHomeCategoryGroup);
|
|
3403
|
+
home.data.data.featuredProducts = home.data.data.featuredProducts.map(this.plainToHomeCategoryGroup);
|
|
3404
|
+
home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.plainToHomeCategoryGroup);
|
|
3405
|
+
home.data.createdAt =
|
|
3406
|
+
home.data.createdAt instanceof Timestamp ? home.data.createdAt.toDate() : home.data.createdAt;
|
|
3407
|
+
home.data.expiresAt =
|
|
3408
|
+
home.data.expiresAt instanceof Timestamp ? home.data.expiresAt.toDate() : home.data.expiresAt;
|
|
3409
|
+
}
|
|
3410
|
+
return home;
|
|
3411
|
+
}
|
|
3412
|
+
}
|
|
3413
|
+
|
|
3414
|
+
class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3415
|
+
constructor({ firestore, interceptors }) {
|
|
3416
|
+
super({
|
|
3417
|
+
firestore,
|
|
3418
|
+
collectionName: 'shopMenus',
|
|
3419
|
+
model: ShopMenu,
|
|
3420
|
+
interceptors,
|
|
3421
|
+
});
|
|
3422
|
+
}
|
|
3423
|
+
}
|
|
3424
|
+
|
|
3425
|
+
class ShopSettingsFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3426
|
+
constructor({ firestore, interceptors, }) {
|
|
3427
|
+
super({
|
|
3428
|
+
firestore,
|
|
3429
|
+
collectionName: 'shopSettings',
|
|
3430
|
+
model: ShopSettings,
|
|
3431
|
+
interceptors,
|
|
3432
|
+
});
|
|
3433
|
+
}
|
|
3434
|
+
}
|
|
3435
|
+
|
|
3423
3436
|
class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3424
3437
|
constructor({ firestore, interceptors }) {
|
|
3425
3438
|
super({
|
|
@@ -3503,156 +3516,287 @@ class CouponFirestoreRepository extends withCrudFirestore(withHelpers(withFirest
|
|
|
3503
3516
|
}
|
|
3504
3517
|
}
|
|
3505
3518
|
|
|
3506
|
-
class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3507
|
-
constructor({ firestore, interceptors }) {
|
|
3519
|
+
class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3520
|
+
constructor({ firestore, interceptors }) {
|
|
3521
|
+
super({
|
|
3522
|
+
firestore,
|
|
3523
|
+
collectionName: 'orders',
|
|
3524
|
+
model: Order,
|
|
3525
|
+
interceptors,
|
|
3526
|
+
fields: {
|
|
3527
|
+
status: FirestoreFieldType.String,
|
|
3528
|
+
},
|
|
3529
|
+
});
|
|
3530
|
+
this.orderFromFirestore = (order) => {
|
|
3531
|
+
var _a;
|
|
3532
|
+
if (!!((_a = order === null || order === void 0 ? void 0 : order.lineItems) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
3533
|
+
order.lineItems = order.lineItems.map((lineItem) => {
|
|
3534
|
+
const prices = !!lineItem.price;
|
|
3535
|
+
const shopPrice = prices[order.shop];
|
|
3536
|
+
if (!!shopPrice)
|
|
3537
|
+
lineItem.price = shopPrice;
|
|
3538
|
+
return lineItem;
|
|
3539
|
+
});
|
|
3540
|
+
}
|
|
3541
|
+
return order;
|
|
3542
|
+
};
|
|
3543
|
+
}
|
|
3544
|
+
buildModelInstance() {
|
|
3545
|
+
const { fromFirestore, toFirestore } = super.buildModelInstance();
|
|
3546
|
+
return {
|
|
3547
|
+
toFirestore: (data) => toFirestore((data === null || data === void 0 ? void 0 : data.toPlain) ? data.toPlain() : data),
|
|
3548
|
+
fromFirestore: (snap) => {
|
|
3549
|
+
const instance = fromFirestore(snap);
|
|
3550
|
+
return this.orderFromFirestore(instance);
|
|
3551
|
+
},
|
|
3552
|
+
};
|
|
3553
|
+
}
|
|
3554
|
+
}
|
|
3555
|
+
|
|
3556
|
+
class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
|
|
3557
|
+
constructor({ firestore, interceptors }) {
|
|
3558
|
+
super({
|
|
3559
|
+
firestore,
|
|
3560
|
+
interceptors,
|
|
3561
|
+
});
|
|
3562
|
+
this.collectionName = 'legacyOrders';
|
|
3563
|
+
}
|
|
3564
|
+
}
|
|
3565
|
+
|
|
3566
|
+
class OrderBlockedFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3567
|
+
constructor({ firestore, interceptors, }) {
|
|
3568
|
+
super({
|
|
3569
|
+
firestore,
|
|
3570
|
+
collectionName: 'paymentBlockedAttempts',
|
|
3571
|
+
model: OrderBlocked,
|
|
3572
|
+
interceptors,
|
|
3573
|
+
});
|
|
3574
|
+
}
|
|
3575
|
+
async createBlockedOrderOrPayment(checkout, blockType, type, limiteRange, card = null) {
|
|
3576
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
3577
|
+
return this.create(OrderBlocked.toInstance({
|
|
3578
|
+
customer: {
|
|
3579
|
+
name: ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.displayName) || '',
|
|
3580
|
+
cpf: ((_b = checkout.user) === null || _b === void 0 ? void 0 : _b.cpf) || '',
|
|
3581
|
+
id: (_c = checkout.user) === null || _c === void 0 ? void 0 : _c.id,
|
|
3582
|
+
email: ((_d = checkout.user) === null || _d === void 0 ? void 0 : _d.email) || '',
|
|
3583
|
+
phoneNumber: '+55' + ((_e = checkout.user) === null || _e === void 0 ? void 0 : _e.phone),
|
|
3584
|
+
isSubscriber: (_f = checkout.user) === null || _f === void 0 ? void 0 : _f.isSubscriber,
|
|
3585
|
+
subscriptionPlan: ((_g = checkout.user) === null || _g === void 0 ? void 0 : _g.subscriptionPlan) || '',
|
|
3586
|
+
shippingAddress: Object.assign(Object.assign({}, checkout.shippingAddress), { zip: this.formatZip((_h = checkout.shippingAddress) === null || _h === void 0 ? void 0 : _h.zip) }),
|
|
3587
|
+
},
|
|
3588
|
+
blockType,
|
|
3589
|
+
limiteRange,
|
|
3590
|
+
type,
|
|
3591
|
+
card,
|
|
3592
|
+
checkout: {
|
|
3593
|
+
id: checkout.id,
|
|
3594
|
+
shop: checkout.shop,
|
|
3595
|
+
total: checkout.totalPrice,
|
|
3596
|
+
},
|
|
3597
|
+
date: new Date(),
|
|
3598
|
+
}));
|
|
3599
|
+
}
|
|
3600
|
+
formatZip(zip) {
|
|
3601
|
+
if (zip.length === 8)
|
|
3602
|
+
return zip.substring(0, 5) + '-' + zip.substring(5, 8);
|
|
3603
|
+
return zip;
|
|
3604
|
+
}
|
|
3605
|
+
}
|
|
3606
|
+
|
|
3607
|
+
class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3608
|
+
constructor({ firestore, interceptors }) {
|
|
3609
|
+
super({
|
|
3610
|
+
firestore,
|
|
3611
|
+
collectionName: 'payments',
|
|
3612
|
+
model: Payment,
|
|
3613
|
+
interceptors,
|
|
3614
|
+
});
|
|
3615
|
+
}
|
|
3616
|
+
}
|
|
3617
|
+
|
|
3618
|
+
class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3619
|
+
constructor({ firestore, interceptors, }) {
|
|
3620
|
+
super({
|
|
3621
|
+
firestore,
|
|
3622
|
+
collectionName: 'subscriptionPlans',
|
|
3623
|
+
model: SubscriptionPlan,
|
|
3624
|
+
interceptors,
|
|
3625
|
+
});
|
|
3626
|
+
}
|
|
3627
|
+
}
|
|
3628
|
+
|
|
3629
|
+
class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3630
|
+
constructor({ firestore, interceptors }) {
|
|
3631
|
+
super({
|
|
3632
|
+
firestore,
|
|
3633
|
+
collectionName: 'leads',
|
|
3634
|
+
model: Lead,
|
|
3635
|
+
interceptors,
|
|
3636
|
+
});
|
|
3637
|
+
}
|
|
3638
|
+
}
|
|
3639
|
+
|
|
3640
|
+
class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3641
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
3642
|
+
super({
|
|
3643
|
+
firestore,
|
|
3644
|
+
collectionName: 'editions',
|
|
3645
|
+
parentIdField: 'subscriptionId',
|
|
3646
|
+
model: Edition,
|
|
3647
|
+
interceptors,
|
|
3648
|
+
});
|
|
3649
|
+
this.parentRepository = parentRepository;
|
|
3650
|
+
}
|
|
3651
|
+
}
|
|
3652
|
+
|
|
3653
|
+
class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3654
|
+
constructor({ firestore, interceptors, }) {
|
|
3655
|
+
super({
|
|
3656
|
+
firestore,
|
|
3657
|
+
collectionName: 'subscription',
|
|
3658
|
+
model: Subscription,
|
|
3659
|
+
interceptors,
|
|
3660
|
+
});
|
|
3661
|
+
}
|
|
3662
|
+
}
|
|
3663
|
+
|
|
3664
|
+
class SubscriptionMaterializationFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3665
|
+
constructor({ firestore, interceptors }) {
|
|
3666
|
+
super({
|
|
3667
|
+
firestore,
|
|
3668
|
+
collectionName: 'subscriptionMaterialization',
|
|
3669
|
+
model: SubscriptionMaterialization,
|
|
3670
|
+
interceptors,
|
|
3671
|
+
});
|
|
3672
|
+
}
|
|
3673
|
+
}
|
|
3674
|
+
|
|
3675
|
+
class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3676
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
3508
3677
|
super({
|
|
3509
3678
|
firestore,
|
|
3510
|
-
collectionName: '
|
|
3511
|
-
|
|
3679
|
+
collectionName: 'payments',
|
|
3680
|
+
parentIdField: 'subscriptionId',
|
|
3681
|
+
model: SubscriptionPayment,
|
|
3512
3682
|
interceptors,
|
|
3513
|
-
fields: {
|
|
3514
|
-
status: FirestoreFieldType.String,
|
|
3515
|
-
},
|
|
3516
3683
|
});
|
|
3517
|
-
this.
|
|
3518
|
-
var _a;
|
|
3519
|
-
if (!!((_a = order === null || order === void 0 ? void 0 : order.lineItems) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
3520
|
-
order.lineItems = order.lineItems.map((lineItem) => {
|
|
3521
|
-
const prices = !!lineItem.price;
|
|
3522
|
-
const shopPrice = prices[order.shop];
|
|
3523
|
-
if (!!shopPrice)
|
|
3524
|
-
lineItem.price = shopPrice;
|
|
3525
|
-
return lineItem;
|
|
3526
|
-
});
|
|
3527
|
-
}
|
|
3528
|
-
return order;
|
|
3529
|
-
};
|
|
3530
|
-
}
|
|
3531
|
-
buildModelInstance() {
|
|
3532
|
-
const { fromFirestore, toFirestore } = super.buildModelInstance();
|
|
3533
|
-
return {
|
|
3534
|
-
toFirestore: (data) => toFirestore((data === null || data === void 0 ? void 0 : data.toPlain) ? data.toPlain() : data),
|
|
3535
|
-
fromFirestore: (snap) => {
|
|
3536
|
-
const instance = fromFirestore(snap);
|
|
3537
|
-
return this.orderFromFirestore(instance);
|
|
3538
|
-
},
|
|
3539
|
-
};
|
|
3684
|
+
this.parentRepository = parentRepository;
|
|
3540
3685
|
}
|
|
3541
3686
|
}
|
|
3542
3687
|
|
|
3543
|
-
class
|
|
3544
|
-
constructor({ firestore, interceptors }) {
|
|
3688
|
+
class SubscriptionSummaryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3689
|
+
constructor({ firestore, interceptors, }) {
|
|
3545
3690
|
super({
|
|
3546
3691
|
firestore,
|
|
3692
|
+
collectionName: 'subscriptionSummary',
|
|
3693
|
+
model: SubscriptionSummary,
|
|
3547
3694
|
interceptors,
|
|
3548
3695
|
});
|
|
3549
|
-
this.collectionName = 'legacyOrders';
|
|
3550
3696
|
}
|
|
3551
3697
|
}
|
|
3552
3698
|
|
|
3553
|
-
class
|
|
3554
|
-
constructor({ firestore, interceptors }) {
|
|
3699
|
+
class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3700
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
3555
3701
|
super({
|
|
3556
3702
|
firestore,
|
|
3557
|
-
collectionName: '
|
|
3558
|
-
|
|
3703
|
+
collectionName: 'address',
|
|
3704
|
+
parentIdField: 'userId',
|
|
3705
|
+
model: UserAddress,
|
|
3559
3706
|
interceptors,
|
|
3560
3707
|
});
|
|
3708
|
+
this.parentRepository = parentRepository;
|
|
3561
3709
|
}
|
|
3562
3710
|
}
|
|
3563
3711
|
|
|
3564
|
-
class
|
|
3565
|
-
constructor({ firestore, interceptors,
|
|
3712
|
+
class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3713
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
3566
3714
|
super({
|
|
3567
3715
|
firestore,
|
|
3568
|
-
collectionName: '
|
|
3569
|
-
|
|
3716
|
+
collectionName: 'CX',
|
|
3717
|
+
parentIdField: 'userId',
|
|
3718
|
+
model: BeautyProfile,
|
|
3570
3719
|
interceptors,
|
|
3571
3720
|
});
|
|
3721
|
+
this.parentRepository = parentRepository;
|
|
3572
3722
|
}
|
|
3573
3723
|
}
|
|
3574
3724
|
|
|
3575
|
-
class
|
|
3725
|
+
class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3576
3726
|
constructor({ firestore, interceptors }) {
|
|
3577
3727
|
super({
|
|
3578
3728
|
firestore,
|
|
3579
|
-
collectionName: '
|
|
3580
|
-
model:
|
|
3729
|
+
collectionName: 'users',
|
|
3730
|
+
model: User,
|
|
3581
3731
|
interceptors,
|
|
3582
3732
|
});
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
};
|
|
3592
|
-
|
|
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
|
-
};
|
|
3733
|
+
}
|
|
3734
|
+
async get(identifiers) {
|
|
3735
|
+
const user = await super.get({ id: identifiers.id });
|
|
3736
|
+
user.beautyProfile = await this.getBeautyProfile(user.id);
|
|
3737
|
+
user.isSubscriber = await this.checkIfIsSubscriber(user.id);
|
|
3738
|
+
return user;
|
|
3739
|
+
}
|
|
3740
|
+
async checkIfExistsByField(field, value) {
|
|
3741
|
+
const result = await this.find({ filters: { [field]: value } });
|
|
3742
|
+
return result.count > 0;
|
|
3599
3743
|
}
|
|
3600
3744
|
buildModelInstance() {
|
|
3601
3745
|
const { fromFirestore, toFirestore } = super.buildModelInstance();
|
|
3602
3746
|
return {
|
|
3603
3747
|
toFirestore: (data) => {
|
|
3604
|
-
const
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
fromFirestore: (snap) => {
|
|
3608
|
-
const instance = fromFirestore(snap);
|
|
3609
|
-
return this.homeFromFirestore(instance);
|
|
3748
|
+
const plain = toFirestore(data);
|
|
3749
|
+
delete plain.isSubscriber;
|
|
3750
|
+
return plain;
|
|
3610
3751
|
},
|
|
3752
|
+
fromFirestore,
|
|
3611
3753
|
};
|
|
3612
3754
|
}
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
return home;
|
|
3755
|
+
async getBeautyProfile(userId) {
|
|
3756
|
+
const beautyProfile = await this.firestore
|
|
3757
|
+
.getCollection(`${this.collectionName}/${userId}/CX`)
|
|
3758
|
+
.withConverter(this.buildBeautyProfileModelInstance())
|
|
3759
|
+
.getDoc('beautyProfile')
|
|
3760
|
+
.get();
|
|
3761
|
+
return beautyProfile.data();
|
|
3621
3762
|
}
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
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;
|
|
3763
|
+
async checkIfIsSubscriber(userId) {
|
|
3764
|
+
const docs = await this.collection('subscription')
|
|
3765
|
+
.where('user.id', '==', userId)
|
|
3766
|
+
.where('status', '==', 'active')
|
|
3767
|
+
.getDocs();
|
|
3768
|
+
return !!docs && !!docs.size;
|
|
3634
3769
|
}
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
firestore,
|
|
3641
|
-
collectionName: 'shopMenus',
|
|
3642
|
-
model: ShopMenu,
|
|
3643
|
-
interceptors,
|
|
3644
|
-
});
|
|
3770
|
+
buildBeautyProfileModelInstance() {
|
|
3771
|
+
return {
|
|
3772
|
+
toFirestore: (data) => data.toPlain(),
|
|
3773
|
+
fromFirestore: (snap) => BeautyProfile.toInstance(snap.data()),
|
|
3774
|
+
};
|
|
3645
3775
|
}
|
|
3646
3776
|
}
|
|
3777
|
+
__decorate([
|
|
3778
|
+
Log(),
|
|
3779
|
+
__metadata("design:type", Function),
|
|
3780
|
+
__metadata("design:paramtypes", [Object]),
|
|
3781
|
+
__metadata("design:returntype", Promise)
|
|
3782
|
+
], UserFirestoreRepository.prototype, "get", null);
|
|
3783
|
+
__decorate([
|
|
3784
|
+
Log(),
|
|
3785
|
+
__metadata("design:type", Function),
|
|
3786
|
+
__metadata("design:paramtypes", [String, String]),
|
|
3787
|
+
__metadata("design:returntype", Promise)
|
|
3788
|
+
], UserFirestoreRepository.prototype, "checkIfExistsByField", null);
|
|
3647
3789
|
|
|
3648
|
-
class
|
|
3649
|
-
constructor({ firestore, interceptors,
|
|
3790
|
+
class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3791
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
3650
3792
|
super({
|
|
3651
3793
|
firestore,
|
|
3652
|
-
collectionName: '
|
|
3653
|
-
|
|
3794
|
+
collectionName: 'payment_method',
|
|
3795
|
+
parentIdField: 'userId',
|
|
3796
|
+
model: UserPaymentMethod,
|
|
3654
3797
|
interceptors,
|
|
3655
3798
|
});
|
|
3799
|
+
this.parentRepository = parentRepository;
|
|
3656
3800
|
}
|
|
3657
3801
|
}
|
|
3658
3802
|
|
|
@@ -4205,7 +4349,7 @@ const withHasuraGraphQL = (MixinBase) => {
|
|
|
4205
4349
|
const response = await axios(request);
|
|
4206
4350
|
if (!isNil(response.data.errors)) {
|
|
4207
4351
|
this.logger.error({ req: request, res: response.data.errors });
|
|
4208
|
-
throw new Error(response.data.errors);
|
|
4352
|
+
throw new Error(JSON.stringify(response.data.errors));
|
|
4209
4353
|
}
|
|
4210
4354
|
this.logger.log({ req: request, res: response.data });
|
|
4211
4355
|
return response.data.data;
|
|
@@ -4346,6 +4490,7 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
4346
4490
|
return class FindHasuraGraphQLMixin extends MixinBase {
|
|
4347
4491
|
constructor() {
|
|
4348
4492
|
super(...arguments);
|
|
4493
|
+
this.lastDistinct = {};
|
|
4349
4494
|
this.bindOrderByAttributes = (orderBy, fields) => Object.keys(orderBy).reduce((acc, current) => [
|
|
4350
4495
|
...acc,
|
|
4351
4496
|
{
|
|
@@ -4381,9 +4526,10 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
4381
4526
|
});
|
|
4382
4527
|
}
|
|
4383
4528
|
async find(params) {
|
|
4384
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
4529
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
4385
4530
|
this.logger = DebugHelper.from(this, 'find');
|
|
4386
4531
|
const { filters, limits, orderBy, options } = params || {};
|
|
4532
|
+
const tableFiltersNamed = `${this.tableName}:${JSON.stringify(filters)}`;
|
|
4387
4533
|
const enableCount = (_a = options === null || options === void 0 ? void 0 : options.enableCount) !== null && _a !== void 0 ? _a : true;
|
|
4388
4534
|
const variablesFilters = isNil(filters)
|
|
4389
4535
|
? {}
|
|
@@ -4434,8 +4580,8 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
4434
4580
|
},
|
|
4435
4581
|
]
|
|
4436
4582
|
: []),
|
|
4437
|
-
...((!
|
|
4438
|
-
((
|
|
4583
|
+
...((!this.lastDistinct[tableFiltersNamed] &&
|
|
4584
|
+
((_c = (_b = params.options) === null || _b === void 0 ? void 0 : _b.distinct) === null || _c === void 0 ? void 0 : _c.map((distinct) => {
|
|
4439
4585
|
var _a, _b;
|
|
4440
4586
|
const distinctOption = (_a = this.fields.find((fieldOption) => fieldOption === distinct)) !== null && _a !== void 0 ? _a : this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === distinct);
|
|
4441
4587
|
const fieldName = ((_b = Object.values(distinctOption).shift()) === null || _b === void 0 ? void 0 : _b.columnName) || distinct;
|
|
@@ -4456,28 +4602,27 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
4456
4602
|
[]),
|
|
4457
4603
|
]);
|
|
4458
4604
|
const data = result[this.tableName].map((row) => this.convertDataFromHasura(row));
|
|
4459
|
-
return Object.assign(Object.assign(Object.assign({ data, count: enableCount ? result[`${this.tableName}_aggregate`].aggregate.count : Infinity }, (((
|
|
4605
|
+
return Object.assign(Object.assign(Object.assign({ data, count: enableCount ? result[`${this.tableName}_aggregate`].aggregate.count : Infinity }, (((_d = options === null || options === void 0 ? void 0 : options.minimal) === null || _d === void 0 ? void 0 : _d.length)
|
|
4460
4606
|
? {
|
|
4461
4607
|
minimal: options.minimal.reduce((minimals, current) => {
|
|
4462
4608
|
var _a;
|
|
4463
4609
|
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])));
|
|
4464
4610
|
}, {}),
|
|
4465
4611
|
}
|
|
4466
|
-
: {})), (((
|
|
4612
|
+
: {})), (((_e = options === null || options === void 0 ? void 0 : options.maximum) === null || _e === void 0 ? void 0 : _e.length)
|
|
4467
4613
|
? {
|
|
4468
4614
|
maximum: options.maximum.reduce((maximums, current) => {
|
|
4469
4615
|
var _a;
|
|
4470
4616
|
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])));
|
|
4471
4617
|
}, {}),
|
|
4472
4618
|
}
|
|
4473
|
-
: {})), (
|
|
4474
|
-
(
|
|
4475
|
-
distinct: options === null || options === void 0 ? void 0 : options.distinct.reduce((distinct, current) => {
|
|
4619
|
+
: {})), (((_f = options === null || options === void 0 ? void 0 : options.distinct) === null || _f === void 0 ? void 0 : _f.length) && {
|
|
4620
|
+
distinct: (_g = this.lastDistinct[tableFiltersNamed]) !== null && _g !== void 0 ? _g : (this.lastDistinct[tableFiltersNamed] = options === null || options === void 0 ? void 0 : options.distinct.reduce((distinct, current) => {
|
|
4476
4621
|
var _a, _b;
|
|
4477
4622
|
const distinctOption = (_a = this.fields.find((fieldOption) => fieldOption === current)) !== null && _a !== void 0 ? _a : this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === current);
|
|
4478
4623
|
const fieldName = ((_b = Object.values(distinctOption).shift()) === null || _b === void 0 ? void 0 : _b.columnName) || current;
|
|
4479
4624
|
return Object.assign(Object.assign({}, distinct), { [current.toString()]: result[`${this.tableName}_${current.toString()}_distinct`].map((obj) => obj[fieldName]) });
|
|
4480
|
-
}, {}),
|
|
4625
|
+
}, {})),
|
|
4481
4626
|
}));
|
|
4482
4627
|
}
|
|
4483
4628
|
};
|
|
@@ -4572,6 +4717,7 @@ class CategoryFilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHa
|
|
|
4572
4717
|
fields: [
|
|
4573
4718
|
'id',
|
|
4574
4719
|
'description',
|
|
4720
|
+
'title',
|
|
4575
4721
|
'slug',
|
|
4576
4722
|
'enabled',
|
|
4577
4723
|
{ createdAt: { columnName: 'created_at' } },
|
|
@@ -4683,6 +4829,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4683
4829
|
'name',
|
|
4684
4830
|
'description',
|
|
4685
4831
|
'image',
|
|
4832
|
+
{ images: { columnName: 'images', type: HasuraGraphQLColumnType.Jsonb } },
|
|
4686
4833
|
'published',
|
|
4687
4834
|
'shop',
|
|
4688
4835
|
{ shops: { columnName: 'shops', type: HasuraGraphQLColumnType.Jsonb } },
|
|
@@ -4715,11 +4862,11 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4715
4862
|
filters: {
|
|
4716
4863
|
columnName: 'filters',
|
|
4717
4864
|
foreignKeyColumn: { filter_id: 'id' },
|
|
4718
|
-
fields: [{ filter: ['id', 'description', 'slug', 'enabled'] }],
|
|
4865
|
+
fields: [{ filter: ['id', 'title', 'description', 'slug', 'enabled'] }],
|
|
4719
4866
|
bindPersistData: (value) => ({
|
|
4720
4867
|
filters: { data: value.map((filter) => ({ filter_id: filter.id })) },
|
|
4721
4868
|
}),
|
|
4722
|
-
from: (filters) => (filters === null || filters === void 0 ? void 0 : filters.map((filter) => filter === null || filter === void 0 ? void 0 : filter.filter)) || [],
|
|
4869
|
+
from: (filters) => (filters === null || filters === void 0 ? void 0 : filters.map((filter) => filter === null || filter === void 0 ? void 0 : filter.filter).filter((filter) => filter.enabled)) || [],
|
|
4723
4870
|
},
|
|
4724
4871
|
},
|
|
4725
4872
|
{ createdAt: { columnName: 'created_at' } },
|
|
@@ -4738,12 +4885,21 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4738
4885
|
{
|
|
4739
4886
|
metadata: {
|
|
4740
4887
|
columnName: 'metadata',
|
|
4741
|
-
fields: ['title', 'description'],
|
|
4888
|
+
fields: ['shop', 'title', 'description'],
|
|
4742
4889
|
bindPersistData: (value) => ({
|
|
4743
4890
|
metadata: { data: value },
|
|
4744
4891
|
}),
|
|
4745
4892
|
},
|
|
4746
4893
|
},
|
|
4894
|
+
{
|
|
4895
|
+
metadatas: {
|
|
4896
|
+
columnName: 'metadatas',
|
|
4897
|
+
fields: ['shop', 'title', 'description'],
|
|
4898
|
+
bindPersistData: (value) => ({
|
|
4899
|
+
metadatas: { data: value },
|
|
4900
|
+
}),
|
|
4901
|
+
},
|
|
4902
|
+
},
|
|
4747
4903
|
{ isCollection: { columnName: 'is_collection' } },
|
|
4748
4904
|
{ isWishlist: { columnName: 'is_wishlist' } },
|
|
4749
4905
|
'reference',
|
|
@@ -4758,14 +4914,29 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4758
4914
|
'theme',
|
|
4759
4915
|
{ bannerUrl: { columnName: 'banner_url' } },
|
|
4760
4916
|
{ mostRelevant: { columnName: 'most_relevant', type: HasuraGraphQLColumnType.Jsonb } },
|
|
4917
|
+
{ mostRelevants: { columnName: 'most_relevants', type: HasuraGraphQLColumnType.Jsonb } },
|
|
4761
4918
|
],
|
|
4762
4919
|
});
|
|
4763
4920
|
this.productRepository = productRepository;
|
|
4764
4921
|
this.categoryFilterRepository = categoryFilterRepository;
|
|
4765
4922
|
}
|
|
4766
4923
|
async create(params) {
|
|
4767
|
-
const {
|
|
4768
|
-
return super.create(Object.assign(Object.assign({}, data), { isWishlist: false,
|
|
4924
|
+
const { images, mostRelevants, metadatas } = params, data = __rest(params, ["images", "mostRelevants", "metadatas"]);
|
|
4925
|
+
return super.create(Object.assign(Object.assign({}, data), { isWishlist: false, metadatas: metadatas || [{ shop: null, description: null, title: null }], mostRelevants: mostRelevants || {
|
|
4926
|
+
[Shops.GLAMSHOP]: null,
|
|
4927
|
+
[Shops.MENSMARKET]: null,
|
|
4928
|
+
}, images: images || {
|
|
4929
|
+
[Shops.GLAMSHOP]: {
|
|
4930
|
+
brandBanner: null,
|
|
4931
|
+
brandBannerMobile: null,
|
|
4932
|
+
image: null,
|
|
4933
|
+
},
|
|
4934
|
+
[Shops.MENSMARKET]: {
|
|
4935
|
+
brandBanner: null,
|
|
4936
|
+
brandBannerMobile: null,
|
|
4937
|
+
image: null,
|
|
4938
|
+
},
|
|
4939
|
+
} }));
|
|
4769
4940
|
}
|
|
4770
4941
|
async get(identifiers) {
|
|
4771
4942
|
var _a;
|
|
@@ -4774,12 +4945,12 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4774
4945
|
: super.get(identifiers);
|
|
4775
4946
|
}
|
|
4776
4947
|
async update(params) {
|
|
4777
|
-
const { products, id: checkId,
|
|
4948
|
+
const { products, id: checkId, metadatas, filters } = params, data = __rest(params, ["products", "id", "metadatas", "filters"]);
|
|
4778
4949
|
const plainData = this.paramsToPlain({ id: checkId });
|
|
4779
4950
|
const id = await this.getId(plainData.id);
|
|
4780
4951
|
const category = await super.update(Object.assign(Object.assign({ id }, data), { isWishlist: false }));
|
|
4781
4952
|
category.products = products && (await this.updateProducts(+id, { products }));
|
|
4782
|
-
category.
|
|
4953
|
+
category.metadatas = metadatas && (await this.updateMetadata(+id, { metadatas }));
|
|
4783
4954
|
category.filters = filters && (await this.updateFilters(+id, { filters }));
|
|
4784
4955
|
return category;
|
|
4785
4956
|
}
|
|
@@ -4817,7 +4988,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4817
4988
|
});
|
|
4818
4989
|
return data;
|
|
4819
4990
|
}
|
|
4820
|
-
async getCategoriesForHome(categoryIds, limit = 4
|
|
4991
|
+
async getCategoriesForHome(categoryIds, shop, limit = 4) {
|
|
4821
4992
|
if (!(categoryIds === null || categoryIds === void 0 ? void 0 : categoryIds.length))
|
|
4822
4993
|
return [];
|
|
4823
4994
|
const categoriesFirestore = categoryIds.filter((categoryId) => Number.isNaN(+categoryId));
|
|
@@ -4829,22 +5000,32 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4829
5000
|
}).then(({ data }) => data)));
|
|
4830
5001
|
if (categoriesHasura.length)
|
|
4831
5002
|
categories.push(...(await this.find({
|
|
4832
|
-
filters: {
|
|
5003
|
+
filters: {
|
|
5004
|
+
id: { operator: Where.IN, value: categoriesHasura.filter(Boolean) },
|
|
5005
|
+
published: true,
|
|
5006
|
+
},
|
|
4833
5007
|
}).then(({ data }) => data)));
|
|
4834
5008
|
if (!categories.length)
|
|
4835
5009
|
return [];
|
|
4836
5010
|
const homeSections = await Promise.all(categories.map(async (category) => ({
|
|
4837
5011
|
category,
|
|
4838
|
-
products: await this.mountCategory(category, { limit, hasStock: true
|
|
5012
|
+
products: await this.mountCategory(category, shop, { limit, hasStock: true }),
|
|
4839
5013
|
})));
|
|
4840
5014
|
return homeSections;
|
|
4841
5015
|
}
|
|
4842
|
-
async mountCategory(category, options) {
|
|
5016
|
+
async mountCategory(category, shop, options) {
|
|
4843
5017
|
var _a;
|
|
4844
5018
|
if (!((_a = category === null || category === void 0 ? void 0 : category.products) === null || _a === void 0 ? void 0 : _a.length))
|
|
4845
5019
|
return [];
|
|
5020
|
+
const mostRelevants = category.getMostRelevantByShop(shop);
|
|
5021
|
+
const mostRelevantProductsIds = [...new Set(mostRelevants.concat(category.products))];
|
|
4846
5022
|
const products = [];
|
|
4847
|
-
const { data: productsData } = await this.productRepository.
|
|
5023
|
+
const { data: productsData } = await this.productRepository.findCatalog({
|
|
5024
|
+
filters: {
|
|
5025
|
+
id: { operator: Where.IN, value: mostRelevantProductsIds },
|
|
5026
|
+
published: true,
|
|
5027
|
+
},
|
|
5028
|
+
fields: [
|
|
4848
5029
|
'id',
|
|
4849
5030
|
'name',
|
|
4850
5031
|
'slug',
|
|
@@ -4870,12 +5051,29 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4870
5051
|
'shoppingCount',
|
|
4871
5052
|
'gender',
|
|
4872
5053
|
'createdAt',
|
|
4873
|
-
]
|
|
4874
|
-
|
|
5054
|
+
],
|
|
5055
|
+
options: { enableCount: false },
|
|
5056
|
+
orderBy: {
|
|
5057
|
+
shoppingCount: 'desc',
|
|
5058
|
+
rate: 'desc',
|
|
5059
|
+
stock: 'desc',
|
|
5060
|
+
name: 'asc',
|
|
5061
|
+
},
|
|
5062
|
+
}, shop === Shops.MENSMARKET ? 'male' : 'female');
|
|
5063
|
+
const mostRelevantWithouyStock = productsData.filter((product) => mostRelevants.includes(product.id) && product.stock.quantity <= 0);
|
|
5064
|
+
const firstProducts = productsData
|
|
5065
|
+
.filter((product) => mostRelevants.includes(product.id) && product.stock.quantity > 0)
|
|
5066
|
+
.sort((a, b) => mostRelevants.indexOf(a.id) - mostRelevants.indexOf(b.id));
|
|
5067
|
+
const lastProducts = productsData
|
|
5068
|
+
.filter((product) => !mostRelevants.includes(product.id) && product.stock.quantity > 0)
|
|
5069
|
+
.concat(mostRelevantWithouyStock);
|
|
5070
|
+
const categoryMostRelevants = firstProducts.concat(lastProducts);
|
|
5071
|
+
const resultFinal = categoryMostRelevants.slice(0, options.limit);
|
|
5072
|
+
products.push(...resultFinal);
|
|
4875
5073
|
return products;
|
|
4876
5074
|
}
|
|
4877
5075
|
async getChildren(parentId) {
|
|
4878
|
-
const { category_tree } = await this.query('category_tree', ['id', 'name', 'parent_id', 'slug', 'reference'], {
|
|
5076
|
+
const { category_tree } = await this.query('category_tree', ['id', 'name', 'parent_id', 'slug', 'reference', 'published', 'shops'], {
|
|
4879
5077
|
args: {
|
|
4880
5078
|
type: 'category_tree_args',
|
|
4881
5079
|
value: { parentid: parentId },
|
|
@@ -4908,29 +5106,6 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4908
5106
|
});
|
|
4909
5107
|
return [];
|
|
4910
5108
|
}
|
|
4911
|
-
const plainData = this.paramsToPlain({ products });
|
|
4912
|
-
if (!plainData.products || plainData.products.length <= 0)
|
|
4913
|
-
return [];
|
|
4914
|
-
const category = await this.get({ id: categoryId.toString() });
|
|
4915
|
-
await this.mutation('delete_category_product', ['affected_rows'], {
|
|
4916
|
-
where: {
|
|
4917
|
-
type: 'category_product_bool_exp',
|
|
4918
|
-
required: true,
|
|
4919
|
-
value: {
|
|
4920
|
-
category_id: { _eq: categoryId },
|
|
4921
|
-
product_id: { _in: category.products.filter((productId) => !plainData.products.includes(productId)) },
|
|
4922
|
-
},
|
|
4923
|
-
},
|
|
4924
|
-
});
|
|
4925
|
-
await this.mutation('insert_category_product', ['affected_rows'], {
|
|
4926
|
-
objects: {
|
|
4927
|
-
type: '[category_product_insert_input!]',
|
|
4928
|
-
required: true,
|
|
4929
|
-
value: plainData.products
|
|
4930
|
-
.filter((productId) => !category.products.includes(productId))
|
|
4931
|
-
.map((productId) => ({ category_id: categoryId, product_id: productId })),
|
|
4932
|
-
},
|
|
4933
|
-
});
|
|
4934
5109
|
const productsOrder = products.map((product, index) => {
|
|
4935
5110
|
return {
|
|
4936
5111
|
id: product,
|
|
@@ -4939,7 +5114,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4939
5114
|
});
|
|
4940
5115
|
const updateQueries = productsOrder.map((product) => ({
|
|
4941
5116
|
where: {
|
|
4942
|
-
category_id: { _eq:
|
|
5117
|
+
category_id: { _eq: categoryId },
|
|
4943
5118
|
product_id: { _eq: product.id },
|
|
4944
5119
|
},
|
|
4945
5120
|
_set: {
|
|
@@ -4953,25 +5128,39 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4953
5128
|
required: true,
|
|
4954
5129
|
},
|
|
4955
5130
|
});
|
|
5131
|
+
const plainData = this.paramsToPlain({ products });
|
|
4956
5132
|
return plainData.products;
|
|
4957
5133
|
}
|
|
4958
|
-
async updateMetadata(categoryId, {
|
|
4959
|
-
|
|
4960
|
-
|
|
4961
|
-
|
|
4962
|
-
|
|
4963
|
-
|
|
4964
|
-
|
|
4965
|
-
|
|
4966
|
-
|
|
4967
|
-
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
|
|
4972
|
-
|
|
4973
|
-
|
|
4974
|
-
|
|
5134
|
+
async updateMetadata(categoryId, { metadatas }) {
|
|
5135
|
+
if (Array.isArray(metadatas) && !metadatas.length)
|
|
5136
|
+
return [];
|
|
5137
|
+
if (Array.isArray(metadatas) && metadatas.length) {
|
|
5138
|
+
await this.mutation('delete_category_metadata', ['affected_rows'], {
|
|
5139
|
+
where: {
|
|
5140
|
+
type: 'category_metadata_bool_exp',
|
|
5141
|
+
required: true,
|
|
5142
|
+
value: { category_id: { _eq: categoryId } },
|
|
5143
|
+
},
|
|
5144
|
+
});
|
|
5145
|
+
await this.mutation('insert_category_metadata', ['affected_rows'], {
|
|
5146
|
+
objects: {
|
|
5147
|
+
type: '[category_metadata_insert_input!]',
|
|
5148
|
+
required: true,
|
|
5149
|
+
value: metadatas.map((m) => (Object.assign({ category_id: categoryId }, m))),
|
|
5150
|
+
},
|
|
5151
|
+
});
|
|
5152
|
+
return metadatas;
|
|
5153
|
+
}
|
|
5154
|
+
if ('action' in metadatas && metadatas.action === 'remove' && metadatas.value.length) {
|
|
5155
|
+
await this.mutation('delete_category_metadata', ['affected_rows'], {
|
|
5156
|
+
where: {
|
|
5157
|
+
type: 'category_metadata_bool_exp',
|
|
5158
|
+
required: true,
|
|
5159
|
+
value: { category_id: { _eq: categoryId } },
|
|
5160
|
+
},
|
|
5161
|
+
});
|
|
5162
|
+
return [];
|
|
5163
|
+
}
|
|
4975
5164
|
}
|
|
4976
5165
|
async updateFilters(categoryId, { filters }) {
|
|
4977
5166
|
if ('action' in filters && filters.action === 'remove' && filters.value.length) {
|
|
@@ -5033,13 +5222,13 @@ __decorate([
|
|
|
5033
5222
|
__decorate([
|
|
5034
5223
|
Log(),
|
|
5035
5224
|
__metadata("design:type", Function),
|
|
5036
|
-
__metadata("design:paramtypes", [Array,
|
|
5225
|
+
__metadata("design:paramtypes", [Array, String, Object]),
|
|
5037
5226
|
__metadata("design:returntype", Promise)
|
|
5038
5227
|
], CategoryHasuraGraphQLRepository.prototype, "getCategoriesForHome", null);
|
|
5039
5228
|
__decorate([
|
|
5040
5229
|
Log(),
|
|
5041
5230
|
__metadata("design:type", Function),
|
|
5042
|
-
__metadata("design:paramtypes", [Category, Object]),
|
|
5231
|
+
__metadata("design:paramtypes", [Category, String, Object]),
|
|
5043
5232
|
__metadata("design:returntype", Promise)
|
|
5044
5233
|
], CategoryHasuraGraphQLRepository.prototype, "mountCategory", null);
|
|
5045
5234
|
__decorate([
|
|
@@ -5055,6 +5244,40 @@ __decorate([
|
|
|
5055
5244
|
__metadata("design:returntype", Promise)
|
|
5056
5245
|
], CategoryHasuraGraphQLRepository.prototype, "isChild", null);
|
|
5057
5246
|
|
|
5247
|
+
class CategoryProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
5248
|
+
constructor({ endpoint, authOptions, interceptors, }) {
|
|
5249
|
+
super({
|
|
5250
|
+
tableName: 'category_product',
|
|
5251
|
+
model: CategoryProduct,
|
|
5252
|
+
endpoint,
|
|
5253
|
+
authOptions,
|
|
5254
|
+
interceptors,
|
|
5255
|
+
fields: [{ productId: { columnName: 'product_id' } }, { categoryId: { columnName: 'category_id' } }, 'order'],
|
|
5256
|
+
});
|
|
5257
|
+
}
|
|
5258
|
+
async removeProductFromCategory(categoryId, productId) {
|
|
5259
|
+
await this.mutation('delete_category_product', ['affected_rows'], {
|
|
5260
|
+
where: {
|
|
5261
|
+
type: 'category_product_bool_exp',
|
|
5262
|
+
required: true,
|
|
5263
|
+
value: {
|
|
5264
|
+
product_id: { _eq: productId },
|
|
5265
|
+
category_id: { _eq: categoryId },
|
|
5266
|
+
},
|
|
5267
|
+
},
|
|
5268
|
+
});
|
|
5269
|
+
}
|
|
5270
|
+
async addProductToCategory(categoryId, productId) {
|
|
5271
|
+
await this.mutation('insert_category_product', ['affected_rows'], {
|
|
5272
|
+
objects: {
|
|
5273
|
+
type: '[category_product_insert_input!]',
|
|
5274
|
+
required: true,
|
|
5275
|
+
value: [{ category_id: categoryId, product_id: productId }],
|
|
5276
|
+
},
|
|
5277
|
+
});
|
|
5278
|
+
}
|
|
5279
|
+
}
|
|
5280
|
+
|
|
5058
5281
|
class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
5059
5282
|
constructor({ endpoint, authOptions, interceptors, }, filterOptionRepository, categoryFilterRepository) {
|
|
5060
5283
|
super({
|
|
@@ -5065,6 +5288,7 @@ class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGrap
|
|
|
5065
5288
|
interceptors,
|
|
5066
5289
|
fields: [
|
|
5067
5290
|
'id',
|
|
5291
|
+
'title',
|
|
5068
5292
|
'description',
|
|
5069
5293
|
'slug',
|
|
5070
5294
|
'enabled',
|
|
@@ -5320,6 +5544,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
5320
5544
|
{ subscriberPrice: { columnName: 'subscriber_price' } },
|
|
5321
5545
|
'published',
|
|
5322
5546
|
'outlet',
|
|
5547
|
+
'label',
|
|
5323
5548
|
'sku',
|
|
5324
5549
|
{
|
|
5325
5550
|
stock: {
|
|
@@ -5351,6 +5576,8 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
5351
5576
|
fields: ['id', 'name', 'reference', 'slug'],
|
|
5352
5577
|
},
|
|
5353
5578
|
},
|
|
5579
|
+
'group',
|
|
5580
|
+
'validity',
|
|
5354
5581
|
];
|
|
5355
5582
|
this.fields = [
|
|
5356
5583
|
...commonFields,
|
|
@@ -5452,6 +5679,8 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
5452
5679
|
enableCount: false,
|
|
5453
5680
|
},
|
|
5454
5681
|
});
|
|
5682
|
+
if (!result.data.length)
|
|
5683
|
+
return null;
|
|
5455
5684
|
const product = (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
|
|
5456
5685
|
RoundProductPricesHelper.roundProductPrices(product);
|
|
5457
5686
|
return product;
|
|
@@ -5461,7 +5690,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
5461
5690
|
const plainData = this.paramsToPlain({ id: checkId });
|
|
5462
5691
|
const id = await this.getId(plainData.id);
|
|
5463
5692
|
const product = await super.update(Object.assign({ id }, data));
|
|
5464
|
-
product.categories = categories && (await this.updateCategories(+id, { categories }));
|
|
5465
5693
|
product.kitProducts = kitProducts && (await this.updateKitProducts(+id, { kitProducts }));
|
|
5466
5694
|
product.reviews = reviews && (await this.updateReviews(+id, { reviews }));
|
|
5467
5695
|
product.metadata = metadata && (await this.updateMetadata(+id, { metadata }));
|
|
@@ -5525,42 +5753,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
5525
5753
|
getReviewStatus(review) {
|
|
5526
5754
|
return review.status === true ? 'approved' : review.status === false ? 'rejected' : 'pending';
|
|
5527
5755
|
}
|
|
5528
|
-
async updateCategories(productId, { categories }) {
|
|
5529
|
-
if ('action' in categories && categories.action === 'remove') {
|
|
5530
|
-
await this.mutation('delete_category_product', ['affected_rows'], {
|
|
5531
|
-
where: {
|
|
5532
|
-
type: 'category_product_bool_exp',
|
|
5533
|
-
required: true,
|
|
5534
|
-
value: { product_id: { _eq: productId } },
|
|
5535
|
-
},
|
|
5536
|
-
});
|
|
5537
|
-
return [];
|
|
5538
|
-
}
|
|
5539
|
-
const plainData = this.paramsToPlain({ categories });
|
|
5540
|
-
if (!plainData.categories || plainData.categories.length <= 0)
|
|
5541
|
-
return [];
|
|
5542
|
-
const product = await this.get({ id: productId.toString() });
|
|
5543
|
-
await this.mutation('delete_category_product', ['affected_rows'], {
|
|
5544
|
-
where: {
|
|
5545
|
-
type: 'category_product_bool_exp',
|
|
5546
|
-
required: true,
|
|
5547
|
-
value: {
|
|
5548
|
-
product_id: { _eq: productId },
|
|
5549
|
-
category_id: { _in: product.categories.filter((categoryId) => !plainData.categories.includes(categoryId)) },
|
|
5550
|
-
},
|
|
5551
|
-
},
|
|
5552
|
-
});
|
|
5553
|
-
await this.mutation('insert_category_product', ['affected_rows'], {
|
|
5554
|
-
objects: {
|
|
5555
|
-
type: '[category_product_insert_input!]',
|
|
5556
|
-
required: true,
|
|
5557
|
-
value: plainData.categories
|
|
5558
|
-
.filter((categoryId) => !product.categories.includes(categoryId))
|
|
5559
|
-
.map((categoryId) => ({ category_id: categoryId, product_id: productId })),
|
|
5560
|
-
},
|
|
5561
|
-
});
|
|
5562
|
-
return plainData.categories;
|
|
5563
|
-
}
|
|
5564
5756
|
async updateKitProducts(productId, { kitProducts }) {
|
|
5565
5757
|
const plainData = this.paramsToPlain({ kitProducts });
|
|
5566
5758
|
await this.mutation('delete_product_kit', ['affected_rows'], {
|
|
@@ -5751,6 +5943,24 @@ class ProductReviewsHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHa
|
|
|
5751
5943
|
],
|
|
5752
5944
|
});
|
|
5753
5945
|
}
|
|
5946
|
+
async updateManyStatus(reviews) {
|
|
5947
|
+
return await this.mutation('update_product_review_many', ['affected_rows'], {
|
|
5948
|
+
updates: {
|
|
5949
|
+
type: '[product_review_updates!]',
|
|
5950
|
+
required: true,
|
|
5951
|
+
value: [
|
|
5952
|
+
{
|
|
5953
|
+
_set: { status: true },
|
|
5954
|
+
where: { id: { _in: reviews.filter((review) => review.status).map((review) => review.id) } },
|
|
5955
|
+
},
|
|
5956
|
+
{
|
|
5957
|
+
_set: { status: false },
|
|
5958
|
+
where: { id: { _in: reviews.filter((review) => !review.status).map((review) => review.id) } },
|
|
5959
|
+
},
|
|
5960
|
+
],
|
|
5961
|
+
},
|
|
5962
|
+
});
|
|
5963
|
+
}
|
|
5754
5964
|
aproveReview(id) {
|
|
5755
5965
|
return this.update({ id, status: true });
|
|
5756
5966
|
}
|
|
@@ -5805,6 +6015,31 @@ class ProductStockNotificationHasuraGraphQLRepository extends withCrudHasuraGrap
|
|
|
5805
6015
|
email,
|
|
5806
6016
|
});
|
|
5807
6017
|
}
|
|
6018
|
+
async getNotificationsReport(params, orderBy, pagination) {
|
|
6019
|
+
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 } }));
|
|
6020
|
+
const orderByField = {
|
|
6021
|
+
[orderBy.field]: orderBy.direction,
|
|
6022
|
+
};
|
|
6023
|
+
const { report_stock_notification } = await this.query('report_stock_notification', ['product_id', 'ean', 'sku', 'name', 'stock', 'category_id', 'category', 'reference', 'emails_registered'], {
|
|
6024
|
+
where: {
|
|
6025
|
+
type: 'report_stock_notification_bool_exp',
|
|
6026
|
+
value: query,
|
|
6027
|
+
required: true,
|
|
6028
|
+
},
|
|
6029
|
+
order_by: {
|
|
6030
|
+
type: '[report_stock_notification_order_by]',
|
|
6031
|
+
value: orderByField,
|
|
6032
|
+
required: true,
|
|
6033
|
+
},
|
|
6034
|
+
});
|
|
6035
|
+
const data = (pagination === null || pagination === void 0 ? void 0 : pagination.limit)
|
|
6036
|
+
? 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))
|
|
6037
|
+
: report_stock_notification;
|
|
6038
|
+
return {
|
|
6039
|
+
data,
|
|
6040
|
+
count: report_stock_notification.length,
|
|
6041
|
+
};
|
|
6042
|
+
}
|
|
5808
6043
|
}
|
|
5809
6044
|
|
|
5810
6045
|
class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
@@ -5878,6 +6113,8 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
5878
6113
|
type: HasuraGraphQLColumnType.Jsonb,
|
|
5879
6114
|
},
|
|
5880
6115
|
},
|
|
6116
|
+
'group',
|
|
6117
|
+
'validity',
|
|
5881
6118
|
],
|
|
5882
6119
|
});
|
|
5883
6120
|
}
|
|
@@ -5913,11 +6150,14 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
5913
6150
|
}
|
|
5914
6151
|
}
|
|
5915
6152
|
|
|
6153
|
+
class WishlistHasuraGraphQL extends Wishlist {
|
|
6154
|
+
}
|
|
6155
|
+
|
|
5916
6156
|
class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
5917
|
-
constructor({ endpoint, authOptions, interceptors, },
|
|
6157
|
+
constructor({ endpoint, authOptions, interceptors, }, categoryProductRepository) {
|
|
5918
6158
|
super({
|
|
5919
6159
|
tableName: 'category',
|
|
5920
|
-
model:
|
|
6160
|
+
model: WishlistHasuraGraphQL,
|
|
5921
6161
|
endpoint,
|
|
5922
6162
|
authOptions,
|
|
5923
6163
|
interceptors,
|
|
@@ -5978,12 +6218,21 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
5978
6218
|
{
|
|
5979
6219
|
metadata: {
|
|
5980
6220
|
columnName: 'metadata',
|
|
5981
|
-
fields: ['title', 'description'],
|
|
6221
|
+
fields: ['shop', 'title', 'description'],
|
|
5982
6222
|
bindPersistData: (value) => ({
|
|
5983
6223
|
metadata: { data: value },
|
|
5984
6224
|
}),
|
|
5985
6225
|
},
|
|
5986
6226
|
},
|
|
6227
|
+
{
|
|
6228
|
+
metadatas: {
|
|
6229
|
+
columnName: 'metadatas',
|
|
6230
|
+
fields: ['shop', 'title', 'description'],
|
|
6231
|
+
bindPersistData: (value) => ({
|
|
6232
|
+
metadatas: { data: value },
|
|
6233
|
+
}),
|
|
6234
|
+
},
|
|
6235
|
+
},
|
|
5987
6236
|
{ isCollection: { columnName: 'is_collection' } },
|
|
5988
6237
|
{ isWishlist: { columnName: 'is_wishlist' } },
|
|
5989
6238
|
'reference',
|
|
@@ -5998,15 +6247,34 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
5998
6247
|
{ personId: { columnName: 'person_id' } },
|
|
5999
6248
|
{ personName: { columnName: 'person_name' } },
|
|
6000
6249
|
{ personPhoto: { columnName: 'person_photo' } },
|
|
6250
|
+
{ personType: { columnName: 'person_type' } },
|
|
6251
|
+
{ personIsSubscriber: { columnName: 'person_is_subscriber' } },
|
|
6001
6252
|
'theme',
|
|
6002
6253
|
{ bannerUrl: { columnName: 'banner_url' } },
|
|
6254
|
+
{ personHasPhoto: { columnName: 'person_has_photo' } },
|
|
6255
|
+
{ mostRelevants: { columnName: 'most_relevants', type: HasuraGraphQLColumnType.Jsonb } },
|
|
6003
6256
|
],
|
|
6004
6257
|
});
|
|
6005
|
-
this.
|
|
6258
|
+
this.categoryProductRepository = categoryProductRepository;
|
|
6006
6259
|
}
|
|
6007
6260
|
async create(params) {
|
|
6008
|
-
|
|
6009
|
-
|
|
6261
|
+
var _a;
|
|
6262
|
+
const { images, mostRelevants, metadatas } = params, data = __rest(params, ["images", "mostRelevants", "metadatas"]);
|
|
6263
|
+
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 || {
|
|
6264
|
+
[Shops.GLAMSHOP]: null,
|
|
6265
|
+
[Shops.MENSMARKET]: null,
|
|
6266
|
+
}, images: images || {
|
|
6267
|
+
[Shops.GLAMSHOP]: {
|
|
6268
|
+
brandBanner: null,
|
|
6269
|
+
brandBannerMobile: null,
|
|
6270
|
+
image: null,
|
|
6271
|
+
},
|
|
6272
|
+
[Shops.MENSMARKET]: {
|
|
6273
|
+
brandBanner: null,
|
|
6274
|
+
brandBannerMobile: null,
|
|
6275
|
+
image: null,
|
|
6276
|
+
},
|
|
6277
|
+
} }));
|
|
6010
6278
|
}
|
|
6011
6279
|
async get(identifiers) {
|
|
6012
6280
|
const data = await super.get(identifiers);
|
|
@@ -6019,12 +6287,11 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
6019
6287
|
return await super.find(Object.assign(Object.assign({}, rest), { filters: Object.assign(Object.assign({}, filters), { isWishlist: { operator: Where.EQUALS, value: true } }) }));
|
|
6020
6288
|
}
|
|
6021
6289
|
async update(params) {
|
|
6022
|
-
const { products, id: checkId,
|
|
6290
|
+
const { products, id: checkId, metadatas, filters } = params, data = __rest(params, ["products", "id", "metadatas", "filters"]);
|
|
6023
6291
|
const plainData = this.paramsToPlain({ id: checkId });
|
|
6024
6292
|
const id = plainData.id;
|
|
6025
6293
|
const category = await super.update(Object.assign(Object.assign({ id }, data), { isWishlist: true, isCollection: true, brandCategory: false }));
|
|
6026
|
-
category.
|
|
6027
|
-
category.metadata = metadata && (await this.updateMetadata(+id, { metadata }));
|
|
6294
|
+
category.metadatas = metadatas && (await this.updateMetadata(+id, { metadatas }));
|
|
6028
6295
|
return category;
|
|
6029
6296
|
}
|
|
6030
6297
|
async getWishlistBySlug(slug) {
|
|
@@ -6056,12 +6323,18 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
6056
6323
|
options: {
|
|
6057
6324
|
enableCount: false,
|
|
6058
6325
|
},
|
|
6326
|
+
orderBy: {
|
|
6327
|
+
id: 'asc',
|
|
6328
|
+
},
|
|
6329
|
+
limits: {
|
|
6330
|
+
limit: 1,
|
|
6331
|
+
},
|
|
6059
6332
|
});
|
|
6060
6333
|
if (!data.length)
|
|
6061
6334
|
throw new NotFoundError(`Wishlists from person ${personId} not found`);
|
|
6062
6335
|
return data;
|
|
6063
6336
|
}
|
|
6064
|
-
getCategoryBySlug(slug, _shop) {
|
|
6337
|
+
async getCategoryBySlug(slug, _shop) {
|
|
6065
6338
|
return this.getWishlistBySlug(slug);
|
|
6066
6339
|
}
|
|
6067
6340
|
async getCategoryByShop(shop) {
|
|
@@ -6079,10 +6352,17 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
6079
6352
|
});
|
|
6080
6353
|
return data;
|
|
6081
6354
|
}
|
|
6082
|
-
|
|
6355
|
+
async findBfluOrGlamgirlWishlists(params, shops) {
|
|
6356
|
+
var _a, _b;
|
|
6357
|
+
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 : {
|
|
6358
|
+
operator: Where.IN,
|
|
6359
|
+
value: [PersonTypes.BFLU, PersonTypes.GLAMGIRL],
|
|
6360
|
+
} }), orderBy: Object.assign({ personHasPhoto: 'desc' }, omit(params.orderBy, ['personHasPhoto'])) }));
|
|
6361
|
+
}
|
|
6362
|
+
getCategoriesForHome(categoryIds, gender, limit) {
|
|
6083
6363
|
return;
|
|
6084
6364
|
}
|
|
6085
|
-
mountCategory(category, options) {
|
|
6365
|
+
mountCategory(category, shop, options) {
|
|
6086
6366
|
return;
|
|
6087
6367
|
}
|
|
6088
6368
|
getChildren(parentId) {
|
|
@@ -6091,61 +6371,46 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
6091
6371
|
isChild(id, parentId) {
|
|
6092
6372
|
return;
|
|
6093
6373
|
}
|
|
6094
|
-
async
|
|
6095
|
-
if (
|
|
6096
|
-
await this.mutation('delete_category_product', ['affected_rows'], {
|
|
6097
|
-
where: {
|
|
6098
|
-
type: 'category_product_bool_exp',
|
|
6099
|
-
required: true,
|
|
6100
|
-
value: { category_id: { _eq: categoryId } },
|
|
6101
|
-
},
|
|
6102
|
-
});
|
|
6103
|
-
await this.categoryFilterRepository.deleteByCategory(categoryId);
|
|
6374
|
+
async updateMetadata(categoryId, { metadatas }) {
|
|
6375
|
+
if (Array.isArray(metadatas) && !metadatas.length)
|
|
6104
6376
|
return [];
|
|
6377
|
+
if (Array.isArray(metadatas) && metadatas.length) {
|
|
6378
|
+
const metadataUpdated = [];
|
|
6379
|
+
for (const data of metadatas) {
|
|
6380
|
+
const update = await this.mutation('update_category_metadata_by_pk', ['category_id', 'shop'], {
|
|
6381
|
+
pk_columns: {
|
|
6382
|
+
value: { category_id: categoryId, shop: data.shop },
|
|
6383
|
+
type: 'category_metadata_pk_columns_input',
|
|
6384
|
+
required: true,
|
|
6385
|
+
},
|
|
6386
|
+
_set: {
|
|
6387
|
+
value: omit(data, ['category_id', 'shop']),
|
|
6388
|
+
type: 'category_metadata_set_input',
|
|
6389
|
+
required: true,
|
|
6390
|
+
},
|
|
6391
|
+
});
|
|
6392
|
+
metadataUpdated.push(update);
|
|
6393
|
+
}
|
|
6394
|
+
return metadataUpdated;
|
|
6105
6395
|
}
|
|
6106
|
-
|
|
6107
|
-
|
|
6396
|
+
if ('action' in metadatas && metadatas.action === 'remove' && metadatas.value.length) {
|
|
6397
|
+
for (let i = 0; i < metadatas.value.length; i++) {
|
|
6398
|
+
await this.mutation('delete_category_metadata', ['affected_rows'], {
|
|
6399
|
+
where: {
|
|
6400
|
+
type: 'category_metadata_bool_exp',
|
|
6401
|
+
required: true,
|
|
6402
|
+
value: { category_id: { _eq: categoryId }, shop: metadatas.value[i].shop },
|
|
6403
|
+
},
|
|
6404
|
+
});
|
|
6405
|
+
}
|
|
6108
6406
|
return [];
|
|
6109
|
-
|
|
6110
|
-
await this.categoryFilterRepository.deleteByCategory(categoryId);
|
|
6111
|
-
await this.mutation('delete_category_product', ['affected_rows'], {
|
|
6112
|
-
where: {
|
|
6113
|
-
type: 'category_product_bool_exp',
|
|
6114
|
-
required: true,
|
|
6115
|
-
value: {
|
|
6116
|
-
category_id: { _eq: categoryId },
|
|
6117
|
-
product_id: { _in: category.products.filter((productId) => !plainData.products.includes(productId)) },
|
|
6118
|
-
},
|
|
6119
|
-
},
|
|
6120
|
-
});
|
|
6121
|
-
await this.mutation('insert_category_product', ['affected_rows'], {
|
|
6122
|
-
objects: {
|
|
6123
|
-
type: '[category_product_insert_input!]',
|
|
6124
|
-
required: true,
|
|
6125
|
-
value: plainData.products
|
|
6126
|
-
.filter((productId) => !category.products.includes(productId))
|
|
6127
|
-
.map((productId) => ({ category_id: categoryId, product_id: productId })),
|
|
6128
|
-
},
|
|
6129
|
-
});
|
|
6130
|
-
return plainData.products;
|
|
6407
|
+
}
|
|
6131
6408
|
}
|
|
6132
|
-
async
|
|
6133
|
-
|
|
6134
|
-
|
|
6135
|
-
|
|
6136
|
-
|
|
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;
|
|
6409
|
+
async addProduct(wishlistId, productId) {
|
|
6410
|
+
return this.categoryProductRepository.addProductToCategory(wishlistId, productId);
|
|
6411
|
+
}
|
|
6412
|
+
async removeProduct(wishlistId, productId) {
|
|
6413
|
+
return this.categoryProductRepository.removeProductFromCategory(wishlistId, productId);
|
|
6149
6414
|
}
|
|
6150
6415
|
}
|
|
6151
6416
|
__decorate([
|
|
@@ -6166,5 +6431,164 @@ __decorate([
|
|
|
6166
6431
|
__metadata("design:paramtypes", [String]),
|
|
6167
6432
|
__metadata("design:returntype", Promise)
|
|
6168
6433
|
], WishlistHasuraGraphQLRepository.prototype, "getCategoryByShop", null);
|
|
6434
|
+
__decorate([
|
|
6435
|
+
Log(),
|
|
6436
|
+
__metadata("design:type", Function),
|
|
6437
|
+
__metadata("design:paramtypes", [Object, Array]),
|
|
6438
|
+
__metadata("design:returntype", Promise)
|
|
6439
|
+
], WishlistHasuraGraphQLRepository.prototype, "findBfluOrGlamgirlWishlists", null);
|
|
6440
|
+
|
|
6441
|
+
class VertexAxiosAdapter {
|
|
6442
|
+
constructor(config) {
|
|
6443
|
+
this.config = config;
|
|
6444
|
+
this.logger = DebugHelper.from(this);
|
|
6445
|
+
}
|
|
6446
|
+
async query(term, total, gender) {
|
|
6447
|
+
const logger = this.logger.with('query');
|
|
6448
|
+
const req = {
|
|
6449
|
+
url: `${this.config.url}/search`,
|
|
6450
|
+
method: 'POST',
|
|
6451
|
+
responseType: 'json',
|
|
6452
|
+
headers: {
|
|
6453
|
+
Accept: 'application/json',
|
|
6454
|
+
},
|
|
6455
|
+
data: { term, total, gender },
|
|
6456
|
+
};
|
|
6457
|
+
try {
|
|
6458
|
+
const { data } = await axios(req);
|
|
6459
|
+
return data;
|
|
6460
|
+
}
|
|
6461
|
+
catch (error) {
|
|
6462
|
+
logger.error({ req, res: error });
|
|
6463
|
+
throw error;
|
|
6464
|
+
}
|
|
6465
|
+
}
|
|
6466
|
+
async get(id) {
|
|
6467
|
+
const logger = this.logger.with('update');
|
|
6468
|
+
const req = {
|
|
6469
|
+
url: `${this.config.url}/${id}`,
|
|
6470
|
+
method: 'GET',
|
|
6471
|
+
responseType: 'json',
|
|
6472
|
+
headers: {
|
|
6473
|
+
Accept: 'application/json',
|
|
6474
|
+
},
|
|
6475
|
+
};
|
|
6476
|
+
try {
|
|
6477
|
+
const { data } = await axios(req);
|
|
6478
|
+
return data;
|
|
6479
|
+
}
|
|
6480
|
+
catch (error) {
|
|
6481
|
+
logger.error({ req, res: error });
|
|
6482
|
+
throw error;
|
|
6483
|
+
}
|
|
6484
|
+
}
|
|
6485
|
+
async save(data) {
|
|
6486
|
+
const logger = this.logger.with('save');
|
|
6487
|
+
const req = {
|
|
6488
|
+
url: `${this.config.url}/sync`,
|
|
6489
|
+
method: 'POST',
|
|
6490
|
+
responseType: 'json',
|
|
6491
|
+
headers: {
|
|
6492
|
+
Accept: 'application/json',
|
|
6493
|
+
},
|
|
6494
|
+
data,
|
|
6495
|
+
};
|
|
6496
|
+
try {
|
|
6497
|
+
const { data } = await axios(req);
|
|
6498
|
+
return data;
|
|
6499
|
+
}
|
|
6500
|
+
catch (error) {
|
|
6501
|
+
logger.error({ req, res: error });
|
|
6502
|
+
throw error;
|
|
6503
|
+
}
|
|
6504
|
+
}
|
|
6505
|
+
async update(id, data) {
|
|
6506
|
+
const logger = this.logger.with('update');
|
|
6507
|
+
const req = {
|
|
6508
|
+
url: `${this.config.url}/${id}`,
|
|
6509
|
+
method: 'PUT',
|
|
6510
|
+
responseType: 'json',
|
|
6511
|
+
headers: {
|
|
6512
|
+
Accept: 'application/json',
|
|
6513
|
+
},
|
|
6514
|
+
data,
|
|
6515
|
+
};
|
|
6516
|
+
try {
|
|
6517
|
+
const { data } = await axios(req);
|
|
6518
|
+
return data;
|
|
6519
|
+
}
|
|
6520
|
+
catch (error) {
|
|
6521
|
+
logger.error({ req, res: error });
|
|
6522
|
+
throw error;
|
|
6523
|
+
}
|
|
6524
|
+
}
|
|
6525
|
+
async delete(id) {
|
|
6526
|
+
const logger = this.logger.with('delete');
|
|
6527
|
+
const req = {
|
|
6528
|
+
url: `${this.config.url}/${id}`,
|
|
6529
|
+
method: 'DELETE',
|
|
6530
|
+
responseType: 'json',
|
|
6531
|
+
headers: {
|
|
6532
|
+
Accept: 'application/json',
|
|
6533
|
+
},
|
|
6534
|
+
};
|
|
6535
|
+
try {
|
|
6536
|
+
const { data } = await axios(req);
|
|
6537
|
+
return data;
|
|
6538
|
+
}
|
|
6539
|
+
catch (error) {
|
|
6540
|
+
logger.error({ req, res: error });
|
|
6541
|
+
throw error;
|
|
6542
|
+
}
|
|
6543
|
+
}
|
|
6544
|
+
bulkProducts(products) {
|
|
6545
|
+
return;
|
|
6546
|
+
}
|
|
6547
|
+
}
|
|
6548
|
+
|
|
6549
|
+
class ProductsVertexSearch {
|
|
6550
|
+
constructor(adapter) {
|
|
6551
|
+
this.adapter = adapter;
|
|
6552
|
+
}
|
|
6553
|
+
async getById(id) {
|
|
6554
|
+
const data = await this.adapter.get(id);
|
|
6555
|
+
return data;
|
|
6556
|
+
}
|
|
6557
|
+
async search(searchTerm, total, gender) {
|
|
6558
|
+
try {
|
|
6559
|
+
const result = await this.adapter.query(searchTerm, total, gender);
|
|
6560
|
+
return result;
|
|
6561
|
+
}
|
|
6562
|
+
catch (error) {
|
|
6563
|
+
console.error(error);
|
|
6564
|
+
}
|
|
6565
|
+
}
|
|
6566
|
+
async save(product) {
|
|
6567
|
+
try {
|
|
6568
|
+
const _a = product.toPlain(), { createdAt, updatedAt, kitProducts } = _a, data = __rest(_a, ["createdAt", "updatedAt", "kitProducts"]);
|
|
6569
|
+
const newProduct = Product.toInstance(data);
|
|
6570
|
+
await this.adapter.save(newProduct);
|
|
6571
|
+
}
|
|
6572
|
+
catch (error) {
|
|
6573
|
+
console.error(error);
|
|
6574
|
+
}
|
|
6575
|
+
}
|
|
6576
|
+
async update(product) {
|
|
6577
|
+
try {
|
|
6578
|
+
await this.adapter.update(product.id, product);
|
|
6579
|
+
}
|
|
6580
|
+
catch (error) {
|
|
6581
|
+
console.error(error);
|
|
6582
|
+
}
|
|
6583
|
+
}
|
|
6584
|
+
async delete(id) {
|
|
6585
|
+
try {
|
|
6586
|
+
await this.adapter.delete(id);
|
|
6587
|
+
}
|
|
6588
|
+
catch (error) {
|
|
6589
|
+
console.error(error);
|
|
6590
|
+
}
|
|
6591
|
+
}
|
|
6592
|
+
}
|
|
6169
6593
|
|
|
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 };
|
|
6594
|
+
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, CategoryProduct, CategoryProductHasuraGraphQLRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, ClassNameHelper, ConnectBaseDocumentSnapshot, ConnectCollectionService, ConnectDocumentService, ConnectFirestoreService, Coupon, CouponCategories, CouponCategory, CouponChannels, CouponFirestoreRepository, CouponOldCategories, 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, LogDocument, LogFirestoreRepository, Logger, NotFoundError, OfficePosition, Order, OrderBlocked, OrderBlockedFirestoreRepository, OrderFirestoreRepository, OrderStatus, Payment, PaymentFirestoreRepository, PaymentType, PersonTypes, Plans, Product, ProductFirestoreRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductReviews, ProductReviewsHasuraGraphQLRepository, ProductSpents, ProductStockNotification, ProductStockNotificationHasuraGraphQLRepository, ProductVariantFirestoreRepository, ProductsIndex, ProductsVertexSearch, 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, VertexAxiosAdapter, WeakPasswordError, Where, Wishlist, WishlistHasuraGraphQLRepository, WishlistLogType, is, isDebuggable, isUUID, parseDateTime, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
|