@infrab4a/connect 4.9.7-beta.3 → 4.9.7-beta.31
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 +1059 -617
- package/index.esm.js +1052 -618
- 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 +2 -0
- package/src/domain/catalog/models/enums/product-label.enum.d.ts +6 -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 +2 -0
- package/src/domain/catalog/models/types/report-stock-notification.type.d.ts +21 -0
- package/src/domain/catalog/models/variant.d.ts +4 -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,38 @@ 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 ProductLabelEnum;
|
|
47
|
+
(function (ProductLabelEnum) {
|
|
48
|
+
ProductLabelEnum["ON_SALE"] = "on-sale";
|
|
49
|
+
ProductLabelEnum["OUTLET"] = "outlet";
|
|
50
|
+
ProductLabelEnum["LAST_UNITS"] = "last-units";
|
|
51
|
+
ProductLabelEnum["GLAMSTAR"] = "glamstar";
|
|
52
|
+
})(ProductLabelEnum || (ProductLabelEnum = {}));
|
|
53
|
+
|
|
54
|
+
var Shops;
|
|
55
|
+
(function (Shops) {
|
|
56
|
+
Shops["MENSMARKET"] = "mensmarket";
|
|
57
|
+
Shops["GLAMSHOP"] = "Glamshop";
|
|
58
|
+
Shops["GLAMPOINTS"] = "Glampoints";
|
|
59
|
+
Shops["ALL"] = "ALL";
|
|
60
|
+
})(Shops || (Shops = {}));
|
|
61
|
+
|
|
62
|
+
var WishlistLogType;
|
|
63
|
+
(function (WishlistLogType) {
|
|
64
|
+
WishlistLogType["CREATE"] = "create";
|
|
65
|
+
WishlistLogType["UPDATE"] = "update";
|
|
66
|
+
WishlistLogType["DELETE"] = "delete";
|
|
67
|
+
WishlistLogType["ADD_PRODUCT"] = "add_product";
|
|
68
|
+
WishlistLogType["REMOVE_PRODUCT"] = "remove_product";
|
|
69
|
+
})(WishlistLogType || (WishlistLogType = {}));
|
|
70
|
+
|
|
39
71
|
class Filter extends BaseModel {
|
|
40
72
|
static get identifiersFields() {
|
|
41
73
|
return ['id'];
|
|
@@ -50,6 +82,33 @@ class CategoryBase extends BaseModel {
|
|
|
50
82
|
static get identifiersFields() {
|
|
51
83
|
return ['id'];
|
|
52
84
|
}
|
|
85
|
+
get glamImages() {
|
|
86
|
+
return this.images && this.images[Shops.GLAMSHOP]
|
|
87
|
+
? this.images[Shops.GLAMSHOP]
|
|
88
|
+
: {
|
|
89
|
+
brandBanner: null,
|
|
90
|
+
brandBannerMobile: null,
|
|
91
|
+
image: null,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
get mensImages() {
|
|
95
|
+
return this.images && this.images[Shops.MENSMARKET]
|
|
96
|
+
? this.images[Shops.MENSMARKET]
|
|
97
|
+
: {
|
|
98
|
+
brandBanner: null,
|
|
99
|
+
brandBannerMobile: null,
|
|
100
|
+
image: null,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
get glamMetadata() {
|
|
104
|
+
return this.metadatas.find((metadata) => metadata.shop === Shops.GLAMSHOP);
|
|
105
|
+
}
|
|
106
|
+
get mensMetadata() {
|
|
107
|
+
return this.metadatas.find((metadata) => metadata.shop === Shops.MENSMARKET);
|
|
108
|
+
}
|
|
109
|
+
getMostRelevantByShop(shop) {
|
|
110
|
+
return this.mostRelevants && this.mostRelevants[shop] ? this.mostRelevants[shop] : [];
|
|
111
|
+
}
|
|
53
112
|
}
|
|
54
113
|
__decorate([
|
|
55
114
|
Type(() => CategoryBase),
|
|
@@ -158,20 +217,11 @@ __decorate([
|
|
|
158
217
|
__metadata("design:type", Category)
|
|
159
218
|
], CategoryFilter.prototype, "category", void 0);
|
|
160
219
|
|
|
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 = {}));
|
|
220
|
+
class CategoryProduct extends BaseModel {
|
|
221
|
+
static get identifiersFields() {
|
|
222
|
+
return ['categoryId', 'productId'];
|
|
223
|
+
}
|
|
224
|
+
}
|
|
175
225
|
|
|
176
226
|
class FilterOption extends BaseModel {
|
|
177
227
|
static get identifiersFields() {
|
|
@@ -265,6 +315,17 @@ class CampaignHashtag extends BaseModel {
|
|
|
265
315
|
}
|
|
266
316
|
}
|
|
267
317
|
|
|
318
|
+
class BeautyProfile extends BaseModel {
|
|
319
|
+
toPlain() {
|
|
320
|
+
const plain = super.toPlain();
|
|
321
|
+
delete plain.id;
|
|
322
|
+
return plain;
|
|
323
|
+
}
|
|
324
|
+
static get identifiersFields() {
|
|
325
|
+
return ['id', 'userId'];
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
268
329
|
var AccessoryImportances;
|
|
269
330
|
(function (AccessoryImportances) {
|
|
270
331
|
AccessoryImportances["NOT_INTERESTED"] = "N\u00E3o tenho interesse";
|
|
@@ -441,6 +502,13 @@ var OfficePosition;
|
|
|
441
502
|
OfficePosition["Director"] = "Diretor";
|
|
442
503
|
})(OfficePosition || (OfficePosition = {}));
|
|
443
504
|
|
|
505
|
+
var PersonTypes;
|
|
506
|
+
(function (PersonTypes) {
|
|
507
|
+
PersonTypes["GLAMGIRL"] = "glamgirl";
|
|
508
|
+
PersonTypes["BFLU"] = "bflu";
|
|
509
|
+
PersonTypes["NONE"] = "none";
|
|
510
|
+
})(PersonTypes || (PersonTypes = {}));
|
|
511
|
+
|
|
444
512
|
var ProductSpents;
|
|
445
513
|
(function (ProductSpents) {
|
|
446
514
|
ProductSpents["UNTIL_50"] = "At\u00E9 R$50";
|
|
@@ -461,6 +529,12 @@ var UserType;
|
|
|
461
529
|
UserType["Influencer"] = "Influencer";
|
|
462
530
|
})(UserType || (UserType = {}));
|
|
463
531
|
|
|
532
|
+
class Lead extends BaseModel {
|
|
533
|
+
static get identifiersFields() {
|
|
534
|
+
return ['id'];
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
|
|
464
538
|
class Edition extends BaseModel {
|
|
465
539
|
static get identifiersFields() {
|
|
466
540
|
return ['id', 'subscriptionId'];
|
|
@@ -1786,40 +1860,6 @@ const parseDateTime = (value) => {
|
|
|
1786
1860
|
return date;
|
|
1787
1861
|
};
|
|
1788
1862
|
|
|
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
1863
|
class Coupon extends BaseModel {
|
|
1824
1864
|
get isInfluencer() {
|
|
1825
1865
|
return !isNil(this.influencerEmail);
|
|
@@ -1827,30 +1867,6 @@ class Coupon extends BaseModel {
|
|
|
1827
1867
|
static get identifiersFields() {
|
|
1828
1868
|
return ['id'];
|
|
1829
1869
|
}
|
|
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
1870
|
}
|
|
1855
1871
|
|
|
1856
1872
|
class SubscriptionPlan extends BaseModel {
|
|
@@ -1859,17 +1875,6 @@ class SubscriptionPlan extends BaseModel {
|
|
|
1859
1875
|
}
|
|
1860
1876
|
}
|
|
1861
1877
|
|
|
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
1878
|
class User extends BaseModel {
|
|
1874
1879
|
static toInstance(data) {
|
|
1875
1880
|
const instance = super.toInstance(data);
|
|
@@ -1983,12 +1988,6 @@ class UserPaymentMethod extends BaseModel {
|
|
|
1983
1988
|
}
|
|
1984
1989
|
}
|
|
1985
1990
|
|
|
1986
|
-
class Lead extends BaseModel {
|
|
1987
|
-
static get identifiersFields() {
|
|
1988
|
-
return ['id'];
|
|
1989
|
-
}
|
|
1990
|
-
}
|
|
1991
|
-
|
|
1992
1991
|
class UnauthorizedError extends CustomError {
|
|
1993
1992
|
constructor(message) {
|
|
1994
1993
|
super(message);
|
|
@@ -2142,6 +2141,93 @@ __decorate([
|
|
|
2142
2141
|
__metadata("design:type", Coupon)
|
|
2143
2142
|
], Checkout.prototype, "coupon", void 0);
|
|
2144
2143
|
|
|
2144
|
+
var CouponCategory;
|
|
2145
|
+
(function (CouponCategory) {
|
|
2146
|
+
CouponCategory["Reembolso"] = "Reembolso";
|
|
2147
|
+
CouponCategory["Desculpas"] = "Desculpas";
|
|
2148
|
+
CouponCategory["BFlu"] = "BFlu";
|
|
2149
|
+
CouponCategory["ROYAL"] = "Royal";
|
|
2150
|
+
CouponCategory["Glamqueens"] = "Glamqueens";
|
|
2151
|
+
CouponCategory["Glampartner"] = "Glampartner";
|
|
2152
|
+
CouponCategory["Glamgirls"] = "Glamgirls";
|
|
2153
|
+
CouponCategory["Glamdiva"] = "Glamdiva";
|
|
2154
|
+
CouponCategory["Impulsionamento"] = "Impulsionamento";
|
|
2155
|
+
CouponCategory["PaidMedia"] = "Paid Media";
|
|
2156
|
+
CouponCategory["Organic"] = "Organic";
|
|
2157
|
+
CouponCategory["Direct"] = "Direct";
|
|
2158
|
+
CouponCategory["CRM"] = "CRM";
|
|
2159
|
+
CouponCategory["LOJAUNICO"] = "Loja \u00FAnico";
|
|
2160
|
+
CouponCategory["Outros"] = "Outros";
|
|
2161
|
+
})(CouponCategory || (CouponCategory = {}));
|
|
2162
|
+
var CouponOldCategories;
|
|
2163
|
+
(function (CouponOldCategories) {
|
|
2164
|
+
CouponOldCategories["Reembolso"] = "Reembolso";
|
|
2165
|
+
CouponOldCategories["Desculpas"] = "Desculpas";
|
|
2166
|
+
CouponOldCategories["BFlu"] = "BFlu";
|
|
2167
|
+
CouponOldCategories["ROYAL"] = "Royal";
|
|
2168
|
+
CouponOldCategories["Glamqueens"] = "Glamqueens";
|
|
2169
|
+
CouponOldCategories["Glampartner"] = "Glampartner";
|
|
2170
|
+
CouponOldCategories["Glamgirls"] = "Glamgirls";
|
|
2171
|
+
CouponOldCategories["Glamdiva"] = "Glamdiva";
|
|
2172
|
+
CouponOldCategories["Impulsionamento"] = "Impulsionamento";
|
|
2173
|
+
CouponOldCategories["PaidMedia"] = "Paid Media";
|
|
2174
|
+
CouponOldCategories["Organic"] = "Organic";
|
|
2175
|
+
CouponOldCategories["Direct"] = "Direct";
|
|
2176
|
+
CouponOldCategories["CRM"] = "CRM";
|
|
2177
|
+
CouponOldCategories["LOJAUNICO"] = "Loja \u00FAnico";
|
|
2178
|
+
CouponOldCategories["Outros"] = "Outros";
|
|
2179
|
+
})(CouponOldCategories || (CouponOldCategories = {}));
|
|
2180
|
+
var CouponCategories;
|
|
2181
|
+
(function (CouponCategories) {
|
|
2182
|
+
CouponCategories["API_001"] = "API-001";
|
|
2183
|
+
CouponCategories["COMPRE_E_GANHE"] = "COMPRE E GANHE";
|
|
2184
|
+
CouponCategories["DESCONTO"] = "DESCONTO";
|
|
2185
|
+
CouponCategories["REEMBOLSO"] = "REEMBOLSO";
|
|
2186
|
+
CouponCategories["DESCULPAS"] = "DESCULPAS";
|
|
2187
|
+
})(CouponCategories || (CouponCategories = {}));
|
|
2188
|
+
|
|
2189
|
+
var CouponChannels;
|
|
2190
|
+
(function (CouponChannels) {
|
|
2191
|
+
CouponChannels["BANNER"] = "7";
|
|
2192
|
+
CouponChannels["BFLUENCE"] = "3";
|
|
2193
|
+
CouponChannels["CRM"] = "2";
|
|
2194
|
+
CouponChannels["GLAMGIRL"] = "0";
|
|
2195
|
+
CouponChannels["PAID"] = "4";
|
|
2196
|
+
CouponChannels["ROYAL"] = "1";
|
|
2197
|
+
CouponChannels["SAC"] = "8";
|
|
2198
|
+
CouponChannels["SOCIAL"] = "5";
|
|
2199
|
+
})(CouponChannels || (CouponChannels = {}));
|
|
2200
|
+
|
|
2201
|
+
var CouponSubtypes;
|
|
2202
|
+
(function (CouponSubtypes) {
|
|
2203
|
+
CouponSubtypes[CouponSubtypes["ABSOLUTE"] = 1] = "ABSOLUTE";
|
|
2204
|
+
CouponSubtypes[CouponSubtypes["PERCENTAGE"] = 2] = "PERCENTAGE";
|
|
2205
|
+
})(CouponSubtypes || (CouponSubtypes = {}));
|
|
2206
|
+
|
|
2207
|
+
var CouponTypes;
|
|
2208
|
+
(function (CouponTypes) {
|
|
2209
|
+
CouponTypes[CouponTypes["ABSOLUTE"] = 1] = "ABSOLUTE";
|
|
2210
|
+
CouponTypes[CouponTypes["PERCENTAGE"] = 2] = "PERCENTAGE";
|
|
2211
|
+
CouponTypes[CouponTypes["SHIPPING"] = 3] = "SHIPPING";
|
|
2212
|
+
})(CouponTypes || (CouponTypes = {}));
|
|
2213
|
+
|
|
2214
|
+
var Exclusivities;
|
|
2215
|
+
(function (Exclusivities) {
|
|
2216
|
+
Exclusivities[Exclusivities["ALL_USERS"] = 1] = "ALL_USERS";
|
|
2217
|
+
Exclusivities[Exclusivities["SPECIFIC_USER"] = 2] = "SPECIFIC_USER";
|
|
2218
|
+
Exclusivities[Exclusivities["COLLABORATORS"] = 3] = "COLLABORATORS";
|
|
2219
|
+
Exclusivities[Exclusivities["ACTIVE_SUBSCRIBER"] = 4] = "ACTIVE_SUBSCRIBER";
|
|
2220
|
+
Exclusivities[Exclusivities["INACTIVE_SUBSCRIBER"] = 5] = "INACTIVE_SUBSCRIBER";
|
|
2221
|
+
Exclusivities[Exclusivities["NON_SUBSCRIBER"] = 6] = "NON_SUBSCRIBER";
|
|
2222
|
+
})(Exclusivities || (Exclusivities = {}));
|
|
2223
|
+
|
|
2224
|
+
var CheckoutTypes;
|
|
2225
|
+
(function (CheckoutTypes) {
|
|
2226
|
+
CheckoutTypes[CheckoutTypes["ECOMMERCE"] = 1] = "ECOMMERCE";
|
|
2227
|
+
CheckoutTypes[CheckoutTypes["SUBSCRIPTION"] = 2] = "SUBSCRIPTION";
|
|
2228
|
+
CheckoutTypes[CheckoutTypes["ALL"] = 3] = "ALL";
|
|
2229
|
+
})(CheckoutTypes || (CheckoutTypes = {}));
|
|
2230
|
+
|
|
2145
2231
|
var OrderStatus;
|
|
2146
2232
|
(function (OrderStatus) {
|
|
2147
2233
|
OrderStatus["AGUARDANDO_PAGAMENTO"] = "Aguardando pagamento";
|
|
@@ -2161,6 +2247,12 @@ __decorate([
|
|
|
2161
2247
|
__metadata("design:type", Payment)
|
|
2162
2248
|
], Order.prototype, "payment", void 0);
|
|
2163
2249
|
|
|
2250
|
+
class OrderBlocked extends BaseModel {
|
|
2251
|
+
static get identifiersFields() {
|
|
2252
|
+
return ['id'];
|
|
2253
|
+
}
|
|
2254
|
+
}
|
|
2255
|
+
|
|
2164
2256
|
class CheckoutSubscription extends BaseModel {
|
|
2165
2257
|
static get identifiersFields() {
|
|
2166
2258
|
return ['id'];
|
|
@@ -2197,6 +2289,12 @@ class RoundProductPricesHelper {
|
|
|
2197
2289
|
}
|
|
2198
2290
|
}
|
|
2199
2291
|
|
|
2292
|
+
class LogDocument extends BaseModel {
|
|
2293
|
+
static get identifiersFields() {
|
|
2294
|
+
return ['id'];
|
|
2295
|
+
}
|
|
2296
|
+
}
|
|
2297
|
+
|
|
2200
2298
|
var FilterType;
|
|
2201
2299
|
(function (FilterType) {
|
|
2202
2300
|
FilterType["ACCESSORY_IMPORTANCE"] = "accessoryImportance";
|
|
@@ -2495,8 +2593,6 @@ class ProductsIndex {
|
|
|
2495
2593
|
'rate',
|
|
2496
2594
|
];
|
|
2497
2595
|
const filter = [{ term: { published: true } }];
|
|
2498
|
-
if (shop && shop !== Shops.ALL)
|
|
2499
|
-
filter.push({ term: { tags: shop == Shops.GLAMSHOP ? 'feminino' : 'masculino' } });
|
|
2500
2596
|
if (size > 9)
|
|
2501
2597
|
fields.push(...['pricePaid', 'isGift', 'stock', 'weight', 'tags']);
|
|
2502
2598
|
const query = {
|
|
@@ -2552,7 +2648,9 @@ class ProductsIndex {
|
|
|
2552
2648
|
RoundProductPricesHelper.roundProductPrices(hit._source);
|
|
2553
2649
|
return hit;
|
|
2554
2650
|
});
|
|
2555
|
-
return search
|
|
2651
|
+
return search.hits.map((hit) => {
|
|
2652
|
+
return Object.assign(Object.assign({}, hit._source), { stock: hit._source.stock.quantity });
|
|
2653
|
+
});
|
|
2556
2654
|
}
|
|
2557
2655
|
async save(product) {
|
|
2558
2656
|
try {
|
|
@@ -2986,6 +3084,8 @@ const withUpdateFirestore = (MixinBase) => {
|
|
|
2986
3084
|
try {
|
|
2987
3085
|
const identifiers = getValueFromParams(data, keyField);
|
|
2988
3086
|
const docRef = this.collection(collectionName).getDoc(identifiers.toString());
|
|
3087
|
+
if (!(await docRef.get()).data())
|
|
3088
|
+
throw new NotFoundError(`Document '${collectionName}/${Object.values(identifiers.toString())}' not found`);
|
|
2989
3089
|
const plainFromData = this.model.toInstance(this.paramsToPlain(data));
|
|
2990
3090
|
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
3091
|
const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || plainFromData;
|
|
@@ -3062,278 +3162,104 @@ const withCrudFirestore = (MixinBase) => {
|
|
|
3062
3162
|
};
|
|
3063
3163
|
};
|
|
3064
3164
|
|
|
3065
|
-
class
|
|
3165
|
+
class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3066
3166
|
constructor({ firestore, interceptors }) {
|
|
3067
3167
|
super({
|
|
3068
3168
|
firestore,
|
|
3069
|
-
collectionName: '
|
|
3070
|
-
model:
|
|
3169
|
+
collectionName: 'categories',
|
|
3170
|
+
model: Category,
|
|
3071
3171
|
interceptors,
|
|
3072
3172
|
});
|
|
3073
3173
|
}
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3174
|
+
async getCategoryBySlug(slug, shop) {
|
|
3175
|
+
const categoryDocs = await this.collection(this.collectionName)
|
|
3176
|
+
.where('slug', '==', slug)
|
|
3177
|
+
.where('shop', '==', shop)
|
|
3178
|
+
.where('published', '==', true)
|
|
3179
|
+
.getDocs();
|
|
3180
|
+
if (categoryDocs.size > 1)
|
|
3181
|
+
throw new DuplicatedResultsError('Query returned duplicated values');
|
|
3182
|
+
if (categoryDocs.empty)
|
|
3183
|
+
throw new NotFoundError(`Document with slug ${slug} not found`);
|
|
3184
|
+
return categoryDocs.docs[0].data();
|
|
3185
|
+
}
|
|
3186
|
+
async getCategoriesForHome(categoryIds, shop, limit = 4) {
|
|
3187
|
+
const categorySnap = await this.collection(this.collectionName)
|
|
3188
|
+
.where('id', 'in', categoryIds.filter(Boolean))
|
|
3189
|
+
.where('published', '==', true)
|
|
3190
|
+
.getDocs();
|
|
3191
|
+
if (categorySnap.empty)
|
|
3192
|
+
throw new NotFoundError('Categories not found');
|
|
3193
|
+
const categories = categorySnap.docs.map((doc) => doc.data());
|
|
3194
|
+
const homeSections = await Promise.all(categories.map(async (category) => ({
|
|
3195
|
+
category,
|
|
3196
|
+
products: await this.mountCategory(category, shop, { limit, hasStock: true }),
|
|
3197
|
+
})));
|
|
3198
|
+
return homeSections;
|
|
3199
|
+
}
|
|
3200
|
+
async mountCategory(category, shop, options) {
|
|
3201
|
+
if (!category.products)
|
|
3202
|
+
throw new RequiredArgumentError(['Category products is empty']);
|
|
3203
|
+
const chunks = chunk(category.products, 10);
|
|
3204
|
+
const products = [];
|
|
3205
|
+
const wheres = [];
|
|
3206
|
+
for (const productIds of chunks) {
|
|
3207
|
+
if ((options === null || options === void 0 ? void 0 : options.limit) && products.length >= (options === null || options === void 0 ? void 0 : options.limit))
|
|
3208
|
+
break;
|
|
3209
|
+
wheres.push(['published', '==', true], ['id', 'in', productIds]);
|
|
3210
|
+
if (options === null || options === void 0 ? void 0 : options.hasStock)
|
|
3211
|
+
wheres.push(['stock.quantity', '>', 0]);
|
|
3212
|
+
if (options === null || options === void 0 ? void 0 : options.gender)
|
|
3213
|
+
wheres.push(['tags', 'array-contains', options === null || options === void 0 ? void 0 : options.gender]);
|
|
3214
|
+
const productSnap = await wheres
|
|
3215
|
+
.reduce((collection, where) => collection.where(...where), (options === null || options === void 0 ? void 0 : options.limit)
|
|
3216
|
+
? this.collection('productsErpVitrine').limit(options.limit)
|
|
3217
|
+
: this.collection('productsErpVitrine'))
|
|
3218
|
+
.getDocs();
|
|
3219
|
+
if (productSnap.empty)
|
|
3220
|
+
continue;
|
|
3221
|
+
products.push(...productSnap.docs);
|
|
3222
|
+
}
|
|
3223
|
+
return is(products);
|
|
3224
|
+
}
|
|
3225
|
+
getCategoryByShop(shop) {
|
|
3226
|
+
return;
|
|
3227
|
+
}
|
|
3228
|
+
getChildren(parentId) {
|
|
3229
|
+
return;
|
|
3230
|
+
}
|
|
3231
|
+
isChild(id, parentId) {
|
|
3232
|
+
return;
|
|
3086
3233
|
}
|
|
3087
3234
|
}
|
|
3235
|
+
__decorate([
|
|
3236
|
+
Log(),
|
|
3237
|
+
__metadata("design:type", Function),
|
|
3238
|
+
__metadata("design:paramtypes", [String, String]),
|
|
3239
|
+
__metadata("design:returntype", Promise)
|
|
3240
|
+
], CategoryFirestoreRepository.prototype, "getCategoryBySlug", null);
|
|
3241
|
+
__decorate([
|
|
3242
|
+
Log(),
|
|
3243
|
+
__metadata("design:type", Function),
|
|
3244
|
+
__metadata("design:paramtypes", [Array, String, Object]),
|
|
3245
|
+
__metadata("design:returntype", Promise)
|
|
3246
|
+
], CategoryFirestoreRepository.prototype, "getCategoriesForHome", null);
|
|
3247
|
+
__decorate([
|
|
3248
|
+
Log(),
|
|
3249
|
+
__metadata("design:type", Function),
|
|
3250
|
+
__metadata("design:paramtypes", [Category, String, Object]),
|
|
3251
|
+
__metadata("design:returntype", Promise)
|
|
3252
|
+
], CategoryFirestoreRepository.prototype, "mountCategory", null);
|
|
3088
3253
|
|
|
3089
|
-
class
|
|
3090
|
-
constructor({ firestore, interceptors
|
|
3254
|
+
class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3255
|
+
constructor({ firestore, interceptors }) {
|
|
3091
3256
|
super({
|
|
3092
3257
|
firestore,
|
|
3093
|
-
collectionName: '
|
|
3094
|
-
model:
|
|
3258
|
+
collectionName: 'productsErpVitrine',
|
|
3259
|
+
model: Product,
|
|
3095
3260
|
interceptors,
|
|
3096
3261
|
});
|
|
3097
|
-
|
|
3098
|
-
}
|
|
3099
|
-
|
|
3100
|
-
class SubscriptionMaterializationFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3101
|
-
constructor({ firestore, interceptors }) {
|
|
3102
|
-
super({
|
|
3103
|
-
firestore,
|
|
3104
|
-
collectionName: 'subscriptionMaterialization',
|
|
3105
|
-
model: SubscriptionMaterialization,
|
|
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,
|
|
3334
|
-
interceptors,
|
|
3335
|
-
});
|
|
3336
|
-
this.reviews = {};
|
|
3262
|
+
this.reviews = {};
|
|
3337
3263
|
}
|
|
3338
3264
|
fetchProductReviews(filters) {
|
|
3339
3265
|
throw new Error('Method not implemented.');
|
|
@@ -3420,6 +3346,101 @@ class SubscriptionProductFirestoreRepository extends withCrudFirestore(withHelpe
|
|
|
3420
3346
|
}
|
|
3421
3347
|
}
|
|
3422
3348
|
|
|
3349
|
+
class LogFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3350
|
+
constructor({ firestore, interceptors, }) {
|
|
3351
|
+
super({
|
|
3352
|
+
firestore,
|
|
3353
|
+
collectionName: 'logs',
|
|
3354
|
+
model: LogDocument,
|
|
3355
|
+
interceptors,
|
|
3356
|
+
});
|
|
3357
|
+
}
|
|
3358
|
+
}
|
|
3359
|
+
|
|
3360
|
+
class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3361
|
+
constructor({ firestore, interceptors }) {
|
|
3362
|
+
super({
|
|
3363
|
+
firestore,
|
|
3364
|
+
collectionName: 'dms',
|
|
3365
|
+
model: Home,
|
|
3366
|
+
interceptors,
|
|
3367
|
+
});
|
|
3368
|
+
this.homeCategoryGroupToPlain = (homeCategoryGroup) => {
|
|
3369
|
+
var _a, _b, _c;
|
|
3370
|
+
return ({
|
|
3371
|
+
category: ((_a = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _a === void 0 ? void 0 : _a.toPlain)
|
|
3372
|
+
? (_b = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _b === void 0 ? void 0 : _b.toPlain()
|
|
3373
|
+
: homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category,
|
|
3374
|
+
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)) || [],
|
|
3375
|
+
});
|
|
3376
|
+
};
|
|
3377
|
+
this.plainToHomeCategoryGroup = (homeCategoryGroup) => {
|
|
3378
|
+
var _a;
|
|
3379
|
+
return ({
|
|
3380
|
+
category: Category.toInstance(homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category),
|
|
3381
|
+
products: (_a = homeCategoryGroup.products) === null || _a === void 0 ? void 0 : _a.map((product) => Product.toInstance(product)),
|
|
3382
|
+
});
|
|
3383
|
+
};
|
|
3384
|
+
}
|
|
3385
|
+
buildModelInstance() {
|
|
3386
|
+
const { fromFirestore, toFirestore } = super.buildModelInstance();
|
|
3387
|
+
return {
|
|
3388
|
+
toFirestore: (data) => {
|
|
3389
|
+
const modifiedData = this.homeToFirestore(data);
|
|
3390
|
+
return toFirestore(modifiedData);
|
|
3391
|
+
},
|
|
3392
|
+
fromFirestore: (snap) => {
|
|
3393
|
+
const instance = fromFirestore(snap);
|
|
3394
|
+
return this.homeFromFirestore(instance);
|
|
3395
|
+
},
|
|
3396
|
+
};
|
|
3397
|
+
}
|
|
3398
|
+
homeToFirestore(home) {
|
|
3399
|
+
var _a, _b, _c, _d;
|
|
3400
|
+
if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
|
|
3401
|
+
home.data.data.discoverProducts = ((_b = home.data.data.discoverProducts) === null || _b === void 0 ? void 0 : _b.map(this.homeCategoryGroupToPlain)) || [];
|
|
3402
|
+
home.data.data.featuredProducts = ((_c = home.data.data.featuredProducts) === null || _c === void 0 ? void 0 : _c.map(this.homeCategoryGroupToPlain)) || [];
|
|
3403
|
+
home.data.data.verticalProducts = ((_d = home.data.data.verticalProducts) === null || _d === void 0 ? void 0 : _d.map(this.homeCategoryGroupToPlain)) || [];
|
|
3404
|
+
}
|
|
3405
|
+
return home;
|
|
3406
|
+
}
|
|
3407
|
+
homeFromFirestore(home) {
|
|
3408
|
+
var _a;
|
|
3409
|
+
if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
|
|
3410
|
+
home.data.data.discoverProducts = home.data.data.discoverProducts.map(this.plainToHomeCategoryGroup);
|
|
3411
|
+
home.data.data.featuredProducts = home.data.data.featuredProducts.map(this.plainToHomeCategoryGroup);
|
|
3412
|
+
home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.plainToHomeCategoryGroup);
|
|
3413
|
+
home.data.createdAt =
|
|
3414
|
+
home.data.createdAt instanceof Timestamp ? home.data.createdAt.toDate() : home.data.createdAt;
|
|
3415
|
+
home.data.expiresAt =
|
|
3416
|
+
home.data.expiresAt instanceof Timestamp ? home.data.expiresAt.toDate() : home.data.expiresAt;
|
|
3417
|
+
}
|
|
3418
|
+
return home;
|
|
3419
|
+
}
|
|
3420
|
+
}
|
|
3421
|
+
|
|
3422
|
+
class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3423
|
+
constructor({ firestore, interceptors }) {
|
|
3424
|
+
super({
|
|
3425
|
+
firestore,
|
|
3426
|
+
collectionName: 'shopMenus',
|
|
3427
|
+
model: ShopMenu,
|
|
3428
|
+
interceptors,
|
|
3429
|
+
});
|
|
3430
|
+
}
|
|
3431
|
+
}
|
|
3432
|
+
|
|
3433
|
+
class ShopSettingsFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3434
|
+
constructor({ firestore, interceptors, }) {
|
|
3435
|
+
super({
|
|
3436
|
+
firestore,
|
|
3437
|
+
collectionName: 'shopSettings',
|
|
3438
|
+
model: ShopSettings,
|
|
3439
|
+
interceptors,
|
|
3440
|
+
});
|
|
3441
|
+
}
|
|
3442
|
+
}
|
|
3443
|
+
|
|
3423
3444
|
class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3424
3445
|
constructor({ firestore, interceptors }) {
|
|
3425
3446
|
super({
|
|
@@ -3507,152 +3528,283 @@ class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFiresto
|
|
|
3507
3528
|
constructor({ firestore, interceptors }) {
|
|
3508
3529
|
super({
|
|
3509
3530
|
firestore,
|
|
3510
|
-
collectionName: 'orders',
|
|
3511
|
-
model: Order,
|
|
3531
|
+
collectionName: 'orders',
|
|
3532
|
+
model: Order,
|
|
3533
|
+
interceptors,
|
|
3534
|
+
fields: {
|
|
3535
|
+
status: FirestoreFieldType.String,
|
|
3536
|
+
},
|
|
3537
|
+
});
|
|
3538
|
+
this.orderFromFirestore = (order) => {
|
|
3539
|
+
var _a;
|
|
3540
|
+
if (!!((_a = order === null || order === void 0 ? void 0 : order.lineItems) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
3541
|
+
order.lineItems = order.lineItems.map((lineItem) => {
|
|
3542
|
+
const prices = !!lineItem.price;
|
|
3543
|
+
const shopPrice = prices[order.shop];
|
|
3544
|
+
if (!!shopPrice)
|
|
3545
|
+
lineItem.price = shopPrice;
|
|
3546
|
+
return lineItem;
|
|
3547
|
+
});
|
|
3548
|
+
}
|
|
3549
|
+
return order;
|
|
3550
|
+
};
|
|
3551
|
+
}
|
|
3552
|
+
buildModelInstance() {
|
|
3553
|
+
const { fromFirestore, toFirestore } = super.buildModelInstance();
|
|
3554
|
+
return {
|
|
3555
|
+
toFirestore: (data) => toFirestore((data === null || data === void 0 ? void 0 : data.toPlain) ? data.toPlain() : data),
|
|
3556
|
+
fromFirestore: (snap) => {
|
|
3557
|
+
const instance = fromFirestore(snap);
|
|
3558
|
+
return this.orderFromFirestore(instance);
|
|
3559
|
+
},
|
|
3560
|
+
};
|
|
3561
|
+
}
|
|
3562
|
+
}
|
|
3563
|
+
|
|
3564
|
+
class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
|
|
3565
|
+
constructor({ firestore, interceptors }) {
|
|
3566
|
+
super({
|
|
3567
|
+
firestore,
|
|
3568
|
+
interceptors,
|
|
3569
|
+
});
|
|
3570
|
+
this.collectionName = 'legacyOrders';
|
|
3571
|
+
}
|
|
3572
|
+
}
|
|
3573
|
+
|
|
3574
|
+
class OrderBlockedFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3575
|
+
constructor({ firestore, interceptors, }) {
|
|
3576
|
+
super({
|
|
3577
|
+
firestore,
|
|
3578
|
+
collectionName: 'paymentBlockedAttempts',
|
|
3579
|
+
model: OrderBlocked,
|
|
3580
|
+
interceptors,
|
|
3581
|
+
});
|
|
3582
|
+
}
|
|
3583
|
+
async createBlockedOrderOrPayment(checkout, blockType, type, limiteRange, card = null) {
|
|
3584
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
3585
|
+
return this.create(OrderBlocked.toInstance({
|
|
3586
|
+
customer: {
|
|
3587
|
+
name: ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.displayName) || '',
|
|
3588
|
+
cpf: ((_b = checkout.user) === null || _b === void 0 ? void 0 : _b.cpf) || '',
|
|
3589
|
+
id: (_c = checkout.user) === null || _c === void 0 ? void 0 : _c.id,
|
|
3590
|
+
email: ((_d = checkout.user) === null || _d === void 0 ? void 0 : _d.email) || '',
|
|
3591
|
+
phoneNumber: '+55' + ((_e = checkout.user) === null || _e === void 0 ? void 0 : _e.phone),
|
|
3592
|
+
isSubscriber: (_f = checkout.user) === null || _f === void 0 ? void 0 : _f.isSubscriber,
|
|
3593
|
+
subscriptionPlan: ((_g = checkout.user) === null || _g === void 0 ? void 0 : _g.subscriptionPlan) || '',
|
|
3594
|
+
shippingAddress: Object.assign(Object.assign({}, checkout.shippingAddress), { zip: this.formatZip((_h = checkout.shippingAddress) === null || _h === void 0 ? void 0 : _h.zip) }),
|
|
3595
|
+
},
|
|
3596
|
+
blockType,
|
|
3597
|
+
limiteRange,
|
|
3598
|
+
type,
|
|
3599
|
+
card,
|
|
3600
|
+
checkout: {
|
|
3601
|
+
id: checkout.id,
|
|
3602
|
+
shop: checkout.shop,
|
|
3603
|
+
total: checkout.totalPrice,
|
|
3604
|
+
},
|
|
3605
|
+
date: new Date(),
|
|
3606
|
+
}));
|
|
3607
|
+
}
|
|
3608
|
+
formatZip(zip) {
|
|
3609
|
+
if (zip.length === 8)
|
|
3610
|
+
return zip.substring(0, 5) + '-' + zip.substring(5, 8);
|
|
3611
|
+
return zip;
|
|
3612
|
+
}
|
|
3613
|
+
}
|
|
3614
|
+
|
|
3615
|
+
class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3616
|
+
constructor({ firestore, interceptors }) {
|
|
3617
|
+
super({
|
|
3618
|
+
firestore,
|
|
3619
|
+
collectionName: 'payments',
|
|
3620
|
+
model: Payment,
|
|
3621
|
+
interceptors,
|
|
3622
|
+
});
|
|
3623
|
+
}
|
|
3624
|
+
}
|
|
3625
|
+
|
|
3626
|
+
class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3627
|
+
constructor({ firestore, interceptors, }) {
|
|
3628
|
+
super({
|
|
3629
|
+
firestore,
|
|
3630
|
+
collectionName: 'subscriptionPlans',
|
|
3631
|
+
model: SubscriptionPlan,
|
|
3632
|
+
interceptors,
|
|
3633
|
+
});
|
|
3634
|
+
}
|
|
3635
|
+
}
|
|
3636
|
+
|
|
3637
|
+
class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3638
|
+
constructor({ firestore, interceptors }) {
|
|
3639
|
+
super({
|
|
3640
|
+
firestore,
|
|
3641
|
+
collectionName: 'leads',
|
|
3642
|
+
model: Lead,
|
|
3643
|
+
interceptors,
|
|
3644
|
+
});
|
|
3645
|
+
}
|
|
3646
|
+
}
|
|
3647
|
+
|
|
3648
|
+
class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3649
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
3650
|
+
super({
|
|
3651
|
+
firestore,
|
|
3652
|
+
collectionName: 'editions',
|
|
3653
|
+
parentIdField: 'subscriptionId',
|
|
3654
|
+
model: Edition,
|
|
3655
|
+
interceptors,
|
|
3656
|
+
});
|
|
3657
|
+
this.parentRepository = parentRepository;
|
|
3658
|
+
}
|
|
3659
|
+
}
|
|
3660
|
+
|
|
3661
|
+
class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3662
|
+
constructor({ firestore, interceptors, }) {
|
|
3663
|
+
super({
|
|
3664
|
+
firestore,
|
|
3665
|
+
collectionName: 'subscription',
|
|
3666
|
+
model: Subscription,
|
|
3667
|
+
interceptors,
|
|
3668
|
+
});
|
|
3669
|
+
}
|
|
3670
|
+
}
|
|
3671
|
+
|
|
3672
|
+
class SubscriptionMaterializationFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3673
|
+
constructor({ firestore, interceptors }) {
|
|
3674
|
+
super({
|
|
3675
|
+
firestore,
|
|
3676
|
+
collectionName: 'subscriptionMaterialization',
|
|
3677
|
+
model: SubscriptionMaterialization,
|
|
3678
|
+
interceptors,
|
|
3679
|
+
});
|
|
3680
|
+
}
|
|
3681
|
+
}
|
|
3682
|
+
|
|
3683
|
+
class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3684
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
3685
|
+
super({
|
|
3686
|
+
firestore,
|
|
3687
|
+
collectionName: 'payments',
|
|
3688
|
+
parentIdField: 'subscriptionId',
|
|
3689
|
+
model: SubscriptionPayment,
|
|
3512
3690
|
interceptors,
|
|
3513
|
-
fields: {
|
|
3514
|
-
status: FirestoreFieldType.String,
|
|
3515
|
-
},
|
|
3516
3691
|
});
|
|
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
|
-
};
|
|
3692
|
+
this.parentRepository = parentRepository;
|
|
3540
3693
|
}
|
|
3541
3694
|
}
|
|
3542
3695
|
|
|
3543
|
-
class
|
|
3544
|
-
constructor({ firestore, interceptors }) {
|
|
3696
|
+
class SubscriptionSummaryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3697
|
+
constructor({ firestore, interceptors, }) {
|
|
3545
3698
|
super({
|
|
3546
3699
|
firestore,
|
|
3700
|
+
collectionName: 'subscriptionSummary',
|
|
3701
|
+
model: SubscriptionSummary,
|
|
3547
3702
|
interceptors,
|
|
3548
3703
|
});
|
|
3549
|
-
this.collectionName = 'legacyOrders';
|
|
3550
3704
|
}
|
|
3551
3705
|
}
|
|
3552
3706
|
|
|
3553
|
-
class
|
|
3554
|
-
constructor({ firestore, interceptors }) {
|
|
3707
|
+
class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3708
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
3555
3709
|
super({
|
|
3556
3710
|
firestore,
|
|
3557
|
-
collectionName: '
|
|
3558
|
-
|
|
3711
|
+
collectionName: 'address',
|
|
3712
|
+
parentIdField: 'userId',
|
|
3713
|
+
model: UserAddress,
|
|
3559
3714
|
interceptors,
|
|
3560
3715
|
});
|
|
3716
|
+
this.parentRepository = parentRepository;
|
|
3561
3717
|
}
|
|
3562
3718
|
}
|
|
3563
3719
|
|
|
3564
|
-
class
|
|
3565
|
-
constructor({ firestore, interceptors,
|
|
3720
|
+
class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3721
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
3566
3722
|
super({
|
|
3567
3723
|
firestore,
|
|
3568
|
-
collectionName: '
|
|
3569
|
-
|
|
3724
|
+
collectionName: 'CX',
|
|
3725
|
+
parentIdField: 'userId',
|
|
3726
|
+
model: BeautyProfile,
|
|
3570
3727
|
interceptors,
|
|
3571
3728
|
});
|
|
3729
|
+
this.parentRepository = parentRepository;
|
|
3572
3730
|
}
|
|
3573
3731
|
}
|
|
3574
3732
|
|
|
3575
|
-
class
|
|
3733
|
+
class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3576
3734
|
constructor({ firestore, interceptors }) {
|
|
3577
3735
|
super({
|
|
3578
3736
|
firestore,
|
|
3579
|
-
collectionName: '
|
|
3580
|
-
model:
|
|
3737
|
+
collectionName: 'users',
|
|
3738
|
+
model: User,
|
|
3581
3739
|
interceptors,
|
|
3582
3740
|
});
|
|
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
|
-
};
|
|
3741
|
+
}
|
|
3742
|
+
async get(identifiers) {
|
|
3743
|
+
const user = await super.get({ id: identifiers.id });
|
|
3744
|
+
user.beautyProfile = await this.getBeautyProfile(user.id);
|
|
3745
|
+
user.isSubscriber = await this.checkIfIsSubscriber(user.id);
|
|
3746
|
+
return user;
|
|
3747
|
+
}
|
|
3748
|
+
async checkIfExistsByField(field, value) {
|
|
3749
|
+
const result = await this.find({ filters: { [field]: value } });
|
|
3750
|
+
return result.count > 0;
|
|
3599
3751
|
}
|
|
3600
3752
|
buildModelInstance() {
|
|
3601
3753
|
const { fromFirestore, toFirestore } = super.buildModelInstance();
|
|
3602
3754
|
return {
|
|
3603
3755
|
toFirestore: (data) => {
|
|
3604
|
-
const
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
fromFirestore: (snap) => {
|
|
3608
|
-
const instance = fromFirestore(snap);
|
|
3609
|
-
return this.homeFromFirestore(instance);
|
|
3756
|
+
const plain = toFirestore(data);
|
|
3757
|
+
delete plain.isSubscriber;
|
|
3758
|
+
return plain;
|
|
3610
3759
|
},
|
|
3760
|
+
fromFirestore,
|
|
3611
3761
|
};
|
|
3612
3762
|
}
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
return home;
|
|
3763
|
+
async getBeautyProfile(userId) {
|
|
3764
|
+
const beautyProfile = await this.firestore
|
|
3765
|
+
.getCollection(`${this.collectionName}/${userId}/CX`)
|
|
3766
|
+
.withConverter(this.buildBeautyProfileModelInstance())
|
|
3767
|
+
.getDoc('beautyProfile')
|
|
3768
|
+
.get();
|
|
3769
|
+
return beautyProfile.data();
|
|
3621
3770
|
}
|
|
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;
|
|
3771
|
+
async checkIfIsSubscriber(userId) {
|
|
3772
|
+
const docs = await this.collection('subscription')
|
|
3773
|
+
.where('user.id', '==', userId)
|
|
3774
|
+
.where('status', '==', 'active')
|
|
3775
|
+
.getDocs();
|
|
3776
|
+
return !!docs && !!docs.size;
|
|
3634
3777
|
}
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
firestore,
|
|
3641
|
-
collectionName: 'shopMenus',
|
|
3642
|
-
model: ShopMenu,
|
|
3643
|
-
interceptors,
|
|
3644
|
-
});
|
|
3778
|
+
buildBeautyProfileModelInstance() {
|
|
3779
|
+
return {
|
|
3780
|
+
toFirestore: (data) => data.toPlain(),
|
|
3781
|
+
fromFirestore: (snap) => BeautyProfile.toInstance(snap.data()),
|
|
3782
|
+
};
|
|
3645
3783
|
}
|
|
3646
3784
|
}
|
|
3785
|
+
__decorate([
|
|
3786
|
+
Log(),
|
|
3787
|
+
__metadata("design:type", Function),
|
|
3788
|
+
__metadata("design:paramtypes", [Object]),
|
|
3789
|
+
__metadata("design:returntype", Promise)
|
|
3790
|
+
], UserFirestoreRepository.prototype, "get", null);
|
|
3791
|
+
__decorate([
|
|
3792
|
+
Log(),
|
|
3793
|
+
__metadata("design:type", Function),
|
|
3794
|
+
__metadata("design:paramtypes", [String, String]),
|
|
3795
|
+
__metadata("design:returntype", Promise)
|
|
3796
|
+
], UserFirestoreRepository.prototype, "checkIfExistsByField", null);
|
|
3647
3797
|
|
|
3648
|
-
class
|
|
3649
|
-
constructor({ firestore, interceptors,
|
|
3798
|
+
class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3799
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
3650
3800
|
super({
|
|
3651
3801
|
firestore,
|
|
3652
|
-
collectionName: '
|
|
3653
|
-
|
|
3802
|
+
collectionName: 'payment_method',
|
|
3803
|
+
parentIdField: 'userId',
|
|
3804
|
+
model: UserPaymentMethod,
|
|
3654
3805
|
interceptors,
|
|
3655
3806
|
});
|
|
3807
|
+
this.parentRepository = parentRepository;
|
|
3656
3808
|
}
|
|
3657
3809
|
}
|
|
3658
3810
|
|
|
@@ -4205,7 +4357,7 @@ const withHasuraGraphQL = (MixinBase) => {
|
|
|
4205
4357
|
const response = await axios(request);
|
|
4206
4358
|
if (!isNil(response.data.errors)) {
|
|
4207
4359
|
this.logger.error({ req: request, res: response.data.errors });
|
|
4208
|
-
throw new Error(response.data.errors);
|
|
4360
|
+
throw new Error(JSON.stringify(response.data.errors));
|
|
4209
4361
|
}
|
|
4210
4362
|
this.logger.log({ req: request, res: response.data });
|
|
4211
4363
|
return response.data.data;
|
|
@@ -4346,6 +4498,7 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
4346
4498
|
return class FindHasuraGraphQLMixin extends MixinBase {
|
|
4347
4499
|
constructor() {
|
|
4348
4500
|
super(...arguments);
|
|
4501
|
+
this.lastDistinct = {};
|
|
4349
4502
|
this.bindOrderByAttributes = (orderBy, fields) => Object.keys(orderBy).reduce((acc, current) => [
|
|
4350
4503
|
...acc,
|
|
4351
4504
|
{
|
|
@@ -4381,9 +4534,10 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
4381
4534
|
});
|
|
4382
4535
|
}
|
|
4383
4536
|
async find(params) {
|
|
4384
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
4537
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
4385
4538
|
this.logger = DebugHelper.from(this, 'find');
|
|
4386
4539
|
const { filters, limits, orderBy, options } = params || {};
|
|
4540
|
+
const tableFiltersNamed = `${this.tableName}:${JSON.stringify(filters)}`;
|
|
4387
4541
|
const enableCount = (_a = options === null || options === void 0 ? void 0 : options.enableCount) !== null && _a !== void 0 ? _a : true;
|
|
4388
4542
|
const variablesFilters = isNil(filters)
|
|
4389
4543
|
? {}
|
|
@@ -4434,8 +4588,8 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
4434
4588
|
},
|
|
4435
4589
|
]
|
|
4436
4590
|
: []),
|
|
4437
|
-
...((!
|
|
4438
|
-
((
|
|
4591
|
+
...((!this.lastDistinct[tableFiltersNamed] &&
|
|
4592
|
+
((_c = (_b = params.options) === null || _b === void 0 ? void 0 : _b.distinct) === null || _c === void 0 ? void 0 : _c.map((distinct) => {
|
|
4439
4593
|
var _a, _b;
|
|
4440
4594
|
const distinctOption = (_a = this.fields.find((fieldOption) => fieldOption === distinct)) !== null && _a !== void 0 ? _a : this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === distinct);
|
|
4441
4595
|
const fieldName = ((_b = Object.values(distinctOption).shift()) === null || _b === void 0 ? void 0 : _b.columnName) || distinct;
|
|
@@ -4456,28 +4610,27 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
4456
4610
|
[]),
|
|
4457
4611
|
]);
|
|
4458
4612
|
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 }, (((
|
|
4613
|
+
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
4614
|
? {
|
|
4461
4615
|
minimal: options.minimal.reduce((minimals, current) => {
|
|
4462
4616
|
var _a;
|
|
4463
4617
|
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
4618
|
}, {}),
|
|
4465
4619
|
}
|
|
4466
|
-
: {})), (((
|
|
4620
|
+
: {})), (((_e = options === null || options === void 0 ? void 0 : options.maximum) === null || _e === void 0 ? void 0 : _e.length)
|
|
4467
4621
|
? {
|
|
4468
4622
|
maximum: options.maximum.reduce((maximums, current) => {
|
|
4469
4623
|
var _a;
|
|
4470
4624
|
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
4625
|
}, {}),
|
|
4472
4626
|
}
|
|
4473
|
-
: {})), (
|
|
4474
|
-
(
|
|
4475
|
-
distinct: options === null || options === void 0 ? void 0 : options.distinct.reduce((distinct, current) => {
|
|
4627
|
+
: {})), (((_f = options === null || options === void 0 ? void 0 : options.distinct) === null || _f === void 0 ? void 0 : _f.length) && {
|
|
4628
|
+
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
4629
|
var _a, _b;
|
|
4477
4630
|
const distinctOption = (_a = this.fields.find((fieldOption) => fieldOption === current)) !== null && _a !== void 0 ? _a : this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === current);
|
|
4478
4631
|
const fieldName = ((_b = Object.values(distinctOption).shift()) === null || _b === void 0 ? void 0 : _b.columnName) || current;
|
|
4479
4632
|
return Object.assign(Object.assign({}, distinct), { [current.toString()]: result[`${this.tableName}_${current.toString()}_distinct`].map((obj) => obj[fieldName]) });
|
|
4480
|
-
}, {}),
|
|
4633
|
+
}, {})),
|
|
4481
4634
|
}));
|
|
4482
4635
|
}
|
|
4483
4636
|
};
|
|
@@ -4572,6 +4725,7 @@ class CategoryFilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHa
|
|
|
4572
4725
|
fields: [
|
|
4573
4726
|
'id',
|
|
4574
4727
|
'description',
|
|
4728
|
+
'title',
|
|
4575
4729
|
'slug',
|
|
4576
4730
|
'enabled',
|
|
4577
4731
|
{ createdAt: { columnName: 'created_at' } },
|
|
@@ -4683,6 +4837,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4683
4837
|
'name',
|
|
4684
4838
|
'description',
|
|
4685
4839
|
'image',
|
|
4840
|
+
{ images: { columnName: 'images', type: HasuraGraphQLColumnType.Jsonb } },
|
|
4686
4841
|
'published',
|
|
4687
4842
|
'shop',
|
|
4688
4843
|
{ shops: { columnName: 'shops', type: HasuraGraphQLColumnType.Jsonb } },
|
|
@@ -4715,11 +4870,11 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4715
4870
|
filters: {
|
|
4716
4871
|
columnName: 'filters',
|
|
4717
4872
|
foreignKeyColumn: { filter_id: 'id' },
|
|
4718
|
-
fields: [{ filter: ['id', 'description', 'slug', 'enabled'] }],
|
|
4873
|
+
fields: [{ filter: ['id', 'title', 'description', 'slug', 'enabled'] }],
|
|
4719
4874
|
bindPersistData: (value) => ({
|
|
4720
4875
|
filters: { data: value.map((filter) => ({ filter_id: filter.id })) },
|
|
4721
4876
|
}),
|
|
4722
|
-
from: (filters) => (filters === null || filters === void 0 ? void 0 : filters.map((filter) => filter === null || filter === void 0 ? void 0 : filter.filter)) || [],
|
|
4877
|
+
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
4878
|
},
|
|
4724
4879
|
},
|
|
4725
4880
|
{ createdAt: { columnName: 'created_at' } },
|
|
@@ -4738,12 +4893,21 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4738
4893
|
{
|
|
4739
4894
|
metadata: {
|
|
4740
4895
|
columnName: 'metadata',
|
|
4741
|
-
fields: ['title', 'description'],
|
|
4896
|
+
fields: ['shop', 'title', 'description'],
|
|
4742
4897
|
bindPersistData: (value) => ({
|
|
4743
4898
|
metadata: { data: value },
|
|
4744
4899
|
}),
|
|
4745
4900
|
},
|
|
4746
4901
|
},
|
|
4902
|
+
{
|
|
4903
|
+
metadatas: {
|
|
4904
|
+
columnName: 'metadatas',
|
|
4905
|
+
fields: ['shop', 'title', 'description'],
|
|
4906
|
+
bindPersistData: (value) => ({
|
|
4907
|
+
metadatas: { data: value },
|
|
4908
|
+
}),
|
|
4909
|
+
},
|
|
4910
|
+
},
|
|
4747
4911
|
{ isCollection: { columnName: 'is_collection' } },
|
|
4748
4912
|
{ isWishlist: { columnName: 'is_wishlist' } },
|
|
4749
4913
|
'reference',
|
|
@@ -4758,14 +4922,29 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4758
4922
|
'theme',
|
|
4759
4923
|
{ bannerUrl: { columnName: 'banner_url' } },
|
|
4760
4924
|
{ mostRelevant: { columnName: 'most_relevant', type: HasuraGraphQLColumnType.Jsonb } },
|
|
4925
|
+
{ mostRelevants: { columnName: 'most_relevants', type: HasuraGraphQLColumnType.Jsonb } },
|
|
4761
4926
|
],
|
|
4762
4927
|
});
|
|
4763
4928
|
this.productRepository = productRepository;
|
|
4764
4929
|
this.categoryFilterRepository = categoryFilterRepository;
|
|
4765
4930
|
}
|
|
4766
4931
|
async create(params) {
|
|
4767
|
-
const {
|
|
4768
|
-
return super.create(Object.assign(Object.assign({}, data), { isWishlist: false,
|
|
4932
|
+
const { images, mostRelevants, metadatas } = params, data = __rest(params, ["images", "mostRelevants", "metadatas"]);
|
|
4933
|
+
return super.create(Object.assign(Object.assign({}, data), { isWishlist: false, metadatas: metadatas || [{ shop: null, description: null, title: null }], mostRelevants: mostRelevants || {
|
|
4934
|
+
[Shops.GLAMSHOP]: null,
|
|
4935
|
+
[Shops.MENSMARKET]: null,
|
|
4936
|
+
}, images: images || {
|
|
4937
|
+
[Shops.GLAMSHOP]: {
|
|
4938
|
+
brandBanner: null,
|
|
4939
|
+
brandBannerMobile: null,
|
|
4940
|
+
image: null,
|
|
4941
|
+
},
|
|
4942
|
+
[Shops.MENSMARKET]: {
|
|
4943
|
+
brandBanner: null,
|
|
4944
|
+
brandBannerMobile: null,
|
|
4945
|
+
image: null,
|
|
4946
|
+
},
|
|
4947
|
+
} }));
|
|
4769
4948
|
}
|
|
4770
4949
|
async get(identifiers) {
|
|
4771
4950
|
var _a;
|
|
@@ -4774,12 +4953,12 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4774
4953
|
: super.get(identifiers);
|
|
4775
4954
|
}
|
|
4776
4955
|
async update(params) {
|
|
4777
|
-
const { products, id: checkId,
|
|
4956
|
+
const { products, id: checkId, metadatas, filters } = params, data = __rest(params, ["products", "id", "metadatas", "filters"]);
|
|
4778
4957
|
const plainData = this.paramsToPlain({ id: checkId });
|
|
4779
4958
|
const id = await this.getId(plainData.id);
|
|
4780
4959
|
const category = await super.update(Object.assign(Object.assign({ id }, data), { isWishlist: false }));
|
|
4781
4960
|
category.products = products && (await this.updateProducts(+id, { products }));
|
|
4782
|
-
category.
|
|
4961
|
+
category.metadatas = metadatas && (await this.updateMetadata(+id, { metadatas }));
|
|
4783
4962
|
category.filters = filters && (await this.updateFilters(+id, { filters }));
|
|
4784
4963
|
return category;
|
|
4785
4964
|
}
|
|
@@ -4817,7 +4996,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4817
4996
|
});
|
|
4818
4997
|
return data;
|
|
4819
4998
|
}
|
|
4820
|
-
async getCategoriesForHome(categoryIds, limit = 4
|
|
4999
|
+
async getCategoriesForHome(categoryIds, shop, limit = 4) {
|
|
4821
5000
|
if (!(categoryIds === null || categoryIds === void 0 ? void 0 : categoryIds.length))
|
|
4822
5001
|
return [];
|
|
4823
5002
|
const categoriesFirestore = categoryIds.filter((categoryId) => Number.isNaN(+categoryId));
|
|
@@ -4829,22 +5008,32 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4829
5008
|
}).then(({ data }) => data)));
|
|
4830
5009
|
if (categoriesHasura.length)
|
|
4831
5010
|
categories.push(...(await this.find({
|
|
4832
|
-
filters: {
|
|
5011
|
+
filters: {
|
|
5012
|
+
id: { operator: Where.IN, value: categoriesHasura.filter(Boolean) },
|
|
5013
|
+
published: true,
|
|
5014
|
+
},
|
|
4833
5015
|
}).then(({ data }) => data)));
|
|
4834
5016
|
if (!categories.length)
|
|
4835
5017
|
return [];
|
|
4836
5018
|
const homeSections = await Promise.all(categories.map(async (category) => ({
|
|
4837
5019
|
category,
|
|
4838
|
-
products: await this.mountCategory(category, { limit, hasStock: true
|
|
5020
|
+
products: await this.mountCategory(category, shop, { limit, hasStock: true }),
|
|
4839
5021
|
})));
|
|
4840
5022
|
return homeSections;
|
|
4841
5023
|
}
|
|
4842
|
-
async mountCategory(category, options) {
|
|
5024
|
+
async mountCategory(category, shop, options) {
|
|
4843
5025
|
var _a;
|
|
4844
5026
|
if (!((_a = category === null || category === void 0 ? void 0 : category.products) === null || _a === void 0 ? void 0 : _a.length))
|
|
4845
5027
|
return [];
|
|
5028
|
+
const mostRelevants = category.getMostRelevantByShop(shop);
|
|
5029
|
+
const mostRelevantProductsIds = [...new Set(mostRelevants.concat(category.products))];
|
|
4846
5030
|
const products = [];
|
|
4847
|
-
const { data: productsData } = await this.productRepository.
|
|
5031
|
+
const { data: productsData } = await this.productRepository.findCatalog({
|
|
5032
|
+
filters: {
|
|
5033
|
+
id: { operator: Where.IN, value: mostRelevantProductsIds },
|
|
5034
|
+
published: true,
|
|
5035
|
+
},
|
|
5036
|
+
fields: [
|
|
4848
5037
|
'id',
|
|
4849
5038
|
'name',
|
|
4850
5039
|
'slug',
|
|
@@ -4870,12 +5059,29 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4870
5059
|
'shoppingCount',
|
|
4871
5060
|
'gender',
|
|
4872
5061
|
'createdAt',
|
|
4873
|
-
]
|
|
4874
|
-
|
|
5062
|
+
],
|
|
5063
|
+
options: { enableCount: false },
|
|
5064
|
+
orderBy: {
|
|
5065
|
+
shoppingCount: 'desc',
|
|
5066
|
+
rate: 'desc',
|
|
5067
|
+
stock: 'desc',
|
|
5068
|
+
name: 'asc',
|
|
5069
|
+
},
|
|
5070
|
+
}, shop === Shops.MENSMARKET ? 'male' : 'female');
|
|
5071
|
+
const mostRelevantWithouyStock = productsData.filter((product) => mostRelevants.includes(product.id) && product.stock.quantity <= 0);
|
|
5072
|
+
const firstProducts = productsData
|
|
5073
|
+
.filter((product) => mostRelevants.includes(product.id) && product.stock.quantity > 0)
|
|
5074
|
+
.sort((a, b) => mostRelevants.indexOf(a.id) - mostRelevants.indexOf(b.id));
|
|
5075
|
+
const lastProducts = productsData
|
|
5076
|
+
.filter((product) => !mostRelevants.includes(product.id) && product.stock.quantity > 0)
|
|
5077
|
+
.concat(mostRelevantWithouyStock);
|
|
5078
|
+
const categoryMostRelevants = firstProducts.concat(lastProducts);
|
|
5079
|
+
const resultFinal = categoryMostRelevants.slice(0, options.limit);
|
|
5080
|
+
products.push(...resultFinal);
|
|
4875
5081
|
return products;
|
|
4876
5082
|
}
|
|
4877
5083
|
async getChildren(parentId) {
|
|
4878
|
-
const { category_tree } = await this.query('category_tree', ['id', 'name', 'parent_id', 'slug', 'reference'], {
|
|
5084
|
+
const { category_tree } = await this.query('category_tree', ['id', 'name', 'parent_id', 'slug', 'reference', 'published', 'shops'], {
|
|
4879
5085
|
args: {
|
|
4880
5086
|
type: 'category_tree_args',
|
|
4881
5087
|
value: { parentid: parentId },
|
|
@@ -4908,29 +5114,6 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4908
5114
|
});
|
|
4909
5115
|
return [];
|
|
4910
5116
|
}
|
|
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
5117
|
const productsOrder = products.map((product, index) => {
|
|
4935
5118
|
return {
|
|
4936
5119
|
id: product,
|
|
@@ -4939,7 +5122,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4939
5122
|
});
|
|
4940
5123
|
const updateQueries = productsOrder.map((product) => ({
|
|
4941
5124
|
where: {
|
|
4942
|
-
category_id: { _eq:
|
|
5125
|
+
category_id: { _eq: categoryId },
|
|
4943
5126
|
product_id: { _eq: product.id },
|
|
4944
5127
|
},
|
|
4945
5128
|
_set: {
|
|
@@ -4953,25 +5136,39 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4953
5136
|
required: true,
|
|
4954
5137
|
},
|
|
4955
5138
|
});
|
|
5139
|
+
const plainData = this.paramsToPlain({ products });
|
|
4956
5140
|
return plainData.products;
|
|
4957
5141
|
}
|
|
4958
|
-
async updateMetadata(categoryId, {
|
|
4959
|
-
|
|
4960
|
-
|
|
4961
|
-
|
|
4962
|
-
|
|
4963
|
-
|
|
4964
|
-
|
|
4965
|
-
|
|
4966
|
-
|
|
4967
|
-
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
|
|
4972
|
-
|
|
4973
|
-
|
|
4974
|
-
|
|
5142
|
+
async updateMetadata(categoryId, { metadatas }) {
|
|
5143
|
+
if (Array.isArray(metadatas) && !metadatas.length)
|
|
5144
|
+
return [];
|
|
5145
|
+
if (Array.isArray(metadatas) && metadatas.length) {
|
|
5146
|
+
await this.mutation('delete_category_metadata', ['affected_rows'], {
|
|
5147
|
+
where: {
|
|
5148
|
+
type: 'category_metadata_bool_exp',
|
|
5149
|
+
required: true,
|
|
5150
|
+
value: { category_id: { _eq: categoryId } },
|
|
5151
|
+
},
|
|
5152
|
+
});
|
|
5153
|
+
await this.mutation('insert_category_metadata', ['affected_rows'], {
|
|
5154
|
+
objects: {
|
|
5155
|
+
type: '[category_metadata_insert_input!]',
|
|
5156
|
+
required: true,
|
|
5157
|
+
value: metadatas.map((m) => (Object.assign({ category_id: categoryId }, m))),
|
|
5158
|
+
},
|
|
5159
|
+
});
|
|
5160
|
+
return metadatas;
|
|
5161
|
+
}
|
|
5162
|
+
if ('action' in metadatas && metadatas.action === 'remove' && metadatas.value.length) {
|
|
5163
|
+
await this.mutation('delete_category_metadata', ['affected_rows'], {
|
|
5164
|
+
where: {
|
|
5165
|
+
type: 'category_metadata_bool_exp',
|
|
5166
|
+
required: true,
|
|
5167
|
+
value: { category_id: { _eq: categoryId } },
|
|
5168
|
+
},
|
|
5169
|
+
});
|
|
5170
|
+
return [];
|
|
5171
|
+
}
|
|
4975
5172
|
}
|
|
4976
5173
|
async updateFilters(categoryId, { filters }) {
|
|
4977
5174
|
if ('action' in filters && filters.action === 'remove' && filters.value.length) {
|
|
@@ -5033,13 +5230,13 @@ __decorate([
|
|
|
5033
5230
|
__decorate([
|
|
5034
5231
|
Log(),
|
|
5035
5232
|
__metadata("design:type", Function),
|
|
5036
|
-
__metadata("design:paramtypes", [Array,
|
|
5233
|
+
__metadata("design:paramtypes", [Array, String, Object]),
|
|
5037
5234
|
__metadata("design:returntype", Promise)
|
|
5038
5235
|
], CategoryHasuraGraphQLRepository.prototype, "getCategoriesForHome", null);
|
|
5039
5236
|
__decorate([
|
|
5040
5237
|
Log(),
|
|
5041
5238
|
__metadata("design:type", Function),
|
|
5042
|
-
__metadata("design:paramtypes", [Category, Object]),
|
|
5239
|
+
__metadata("design:paramtypes", [Category, String, Object]),
|
|
5043
5240
|
__metadata("design:returntype", Promise)
|
|
5044
5241
|
], CategoryHasuraGraphQLRepository.prototype, "mountCategory", null);
|
|
5045
5242
|
__decorate([
|
|
@@ -5055,6 +5252,40 @@ __decorate([
|
|
|
5055
5252
|
__metadata("design:returntype", Promise)
|
|
5056
5253
|
], CategoryHasuraGraphQLRepository.prototype, "isChild", null);
|
|
5057
5254
|
|
|
5255
|
+
class CategoryProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
5256
|
+
constructor({ endpoint, authOptions, interceptors, }) {
|
|
5257
|
+
super({
|
|
5258
|
+
tableName: 'category_product',
|
|
5259
|
+
model: CategoryProduct,
|
|
5260
|
+
endpoint,
|
|
5261
|
+
authOptions,
|
|
5262
|
+
interceptors,
|
|
5263
|
+
fields: [{ productId: { columnName: 'product_id' } }, { categoryId: { columnName: 'category_id' } }, 'order'],
|
|
5264
|
+
});
|
|
5265
|
+
}
|
|
5266
|
+
async removeProductFromCategory(categoryId, productId) {
|
|
5267
|
+
await this.mutation('delete_category_product', ['affected_rows'], {
|
|
5268
|
+
where: {
|
|
5269
|
+
type: 'category_product_bool_exp',
|
|
5270
|
+
required: true,
|
|
5271
|
+
value: {
|
|
5272
|
+
product_id: { _eq: productId },
|
|
5273
|
+
category_id: { _eq: categoryId },
|
|
5274
|
+
},
|
|
5275
|
+
},
|
|
5276
|
+
});
|
|
5277
|
+
}
|
|
5278
|
+
async addProductToCategory(categoryId, productId) {
|
|
5279
|
+
await this.mutation('insert_category_product', ['affected_rows'], {
|
|
5280
|
+
objects: {
|
|
5281
|
+
type: '[category_product_insert_input!]',
|
|
5282
|
+
required: true,
|
|
5283
|
+
value: [{ category_id: categoryId, product_id: productId }],
|
|
5284
|
+
},
|
|
5285
|
+
});
|
|
5286
|
+
}
|
|
5287
|
+
}
|
|
5288
|
+
|
|
5058
5289
|
class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
5059
5290
|
constructor({ endpoint, authOptions, interceptors, }, filterOptionRepository, categoryFilterRepository) {
|
|
5060
5291
|
super({
|
|
@@ -5065,6 +5296,7 @@ class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGrap
|
|
|
5065
5296
|
interceptors,
|
|
5066
5297
|
fields: [
|
|
5067
5298
|
'id',
|
|
5299
|
+
'title',
|
|
5068
5300
|
'description',
|
|
5069
5301
|
'slug',
|
|
5070
5302
|
'enabled',
|
|
@@ -5320,6 +5552,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
5320
5552
|
{ subscriberPrice: { columnName: 'subscriber_price' } },
|
|
5321
5553
|
'published',
|
|
5322
5554
|
'outlet',
|
|
5555
|
+
'label',
|
|
5323
5556
|
'sku',
|
|
5324
5557
|
{
|
|
5325
5558
|
stock: {
|
|
@@ -5351,6 +5584,8 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
5351
5584
|
fields: ['id', 'name', 'reference', 'slug'],
|
|
5352
5585
|
},
|
|
5353
5586
|
},
|
|
5587
|
+
'group',
|
|
5588
|
+
'validity',
|
|
5354
5589
|
];
|
|
5355
5590
|
this.fields = [
|
|
5356
5591
|
...commonFields,
|
|
@@ -5452,6 +5687,8 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
5452
5687
|
enableCount: false,
|
|
5453
5688
|
},
|
|
5454
5689
|
});
|
|
5690
|
+
if (!result.data.length)
|
|
5691
|
+
return null;
|
|
5455
5692
|
const product = (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
|
|
5456
5693
|
RoundProductPricesHelper.roundProductPrices(product);
|
|
5457
5694
|
return product;
|
|
@@ -5461,7 +5698,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
5461
5698
|
const plainData = this.paramsToPlain({ id: checkId });
|
|
5462
5699
|
const id = await this.getId(plainData.id);
|
|
5463
5700
|
const product = await super.update(Object.assign({ id }, data));
|
|
5464
|
-
product.categories = categories && (await this.updateCategories(+id, { categories }));
|
|
5465
5701
|
product.kitProducts = kitProducts && (await this.updateKitProducts(+id, { kitProducts }));
|
|
5466
5702
|
product.reviews = reviews && (await this.updateReviews(+id, { reviews }));
|
|
5467
5703
|
product.metadata = metadata && (await this.updateMetadata(+id, { metadata }));
|
|
@@ -5525,42 +5761,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
5525
5761
|
getReviewStatus(review) {
|
|
5526
5762
|
return review.status === true ? 'approved' : review.status === false ? 'rejected' : 'pending';
|
|
5527
5763
|
}
|
|
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
5764
|
async updateKitProducts(productId, { kitProducts }) {
|
|
5565
5765
|
const plainData = this.paramsToPlain({ kitProducts });
|
|
5566
5766
|
await this.mutation('delete_product_kit', ['affected_rows'], {
|
|
@@ -5751,6 +5951,24 @@ class ProductReviewsHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHa
|
|
|
5751
5951
|
],
|
|
5752
5952
|
});
|
|
5753
5953
|
}
|
|
5954
|
+
async updateManyStatus(reviews) {
|
|
5955
|
+
return await this.mutation('update_product_review_many', ['affected_rows'], {
|
|
5956
|
+
updates: {
|
|
5957
|
+
type: '[product_review_updates!]',
|
|
5958
|
+
required: true,
|
|
5959
|
+
value: [
|
|
5960
|
+
{
|
|
5961
|
+
_set: { status: true },
|
|
5962
|
+
where: { id: { _in: reviews.filter((review) => review.status).map((review) => review.id) } },
|
|
5963
|
+
},
|
|
5964
|
+
{
|
|
5965
|
+
_set: { status: false },
|
|
5966
|
+
where: { id: { _in: reviews.filter((review) => !review.status).map((review) => review.id) } },
|
|
5967
|
+
},
|
|
5968
|
+
],
|
|
5969
|
+
},
|
|
5970
|
+
});
|
|
5971
|
+
}
|
|
5754
5972
|
aproveReview(id) {
|
|
5755
5973
|
return this.update({ id, status: true });
|
|
5756
5974
|
}
|
|
@@ -5805,6 +6023,31 @@ class ProductStockNotificationHasuraGraphQLRepository extends withCrudHasuraGrap
|
|
|
5805
6023
|
email,
|
|
5806
6024
|
});
|
|
5807
6025
|
}
|
|
6026
|
+
async getNotificationsReport(params, orderBy, pagination) {
|
|
6027
|
+
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 } }));
|
|
6028
|
+
const orderByField = {
|
|
6029
|
+
[orderBy.field]: orderBy.direction,
|
|
6030
|
+
};
|
|
6031
|
+
const { report_stock_notification } = await this.query('report_stock_notification', ['product_id', 'ean', 'sku', 'name', 'stock', 'category_id', 'category', 'reference', 'emails_registered'], {
|
|
6032
|
+
where: {
|
|
6033
|
+
type: 'report_stock_notification_bool_exp',
|
|
6034
|
+
value: query,
|
|
6035
|
+
required: true,
|
|
6036
|
+
},
|
|
6037
|
+
order_by: {
|
|
6038
|
+
type: '[report_stock_notification_order_by]',
|
|
6039
|
+
value: orderByField,
|
|
6040
|
+
required: true,
|
|
6041
|
+
},
|
|
6042
|
+
});
|
|
6043
|
+
const data = (pagination === null || pagination === void 0 ? void 0 : pagination.limit)
|
|
6044
|
+
? 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))
|
|
6045
|
+
: report_stock_notification;
|
|
6046
|
+
return {
|
|
6047
|
+
data,
|
|
6048
|
+
count: report_stock_notification.length,
|
|
6049
|
+
};
|
|
6050
|
+
}
|
|
5808
6051
|
}
|
|
5809
6052
|
|
|
5810
6053
|
class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
@@ -5878,6 +6121,10 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
5878
6121
|
type: HasuraGraphQLColumnType.Jsonb,
|
|
5879
6122
|
},
|
|
5880
6123
|
},
|
|
6124
|
+
'group',
|
|
6125
|
+
'validity',
|
|
6126
|
+
{ tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
|
|
6127
|
+
'published',
|
|
5881
6128
|
],
|
|
5882
6129
|
});
|
|
5883
6130
|
}
|
|
@@ -5913,11 +6160,14 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
5913
6160
|
}
|
|
5914
6161
|
}
|
|
5915
6162
|
|
|
6163
|
+
class WishlistHasuraGraphQL extends Wishlist {
|
|
6164
|
+
}
|
|
6165
|
+
|
|
5916
6166
|
class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
5917
|
-
constructor({ endpoint, authOptions, interceptors, },
|
|
6167
|
+
constructor({ endpoint, authOptions, interceptors, }, categoryProductRepository) {
|
|
5918
6168
|
super({
|
|
5919
6169
|
tableName: 'category',
|
|
5920
|
-
model:
|
|
6170
|
+
model: WishlistHasuraGraphQL,
|
|
5921
6171
|
endpoint,
|
|
5922
6172
|
authOptions,
|
|
5923
6173
|
interceptors,
|
|
@@ -5978,12 +6228,21 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
5978
6228
|
{
|
|
5979
6229
|
metadata: {
|
|
5980
6230
|
columnName: 'metadata',
|
|
5981
|
-
fields: ['title', 'description'],
|
|
6231
|
+
fields: ['shop', 'title', 'description'],
|
|
5982
6232
|
bindPersistData: (value) => ({
|
|
5983
6233
|
metadata: { data: value },
|
|
5984
6234
|
}),
|
|
5985
6235
|
},
|
|
5986
6236
|
},
|
|
6237
|
+
{
|
|
6238
|
+
metadatas: {
|
|
6239
|
+
columnName: 'metadatas',
|
|
6240
|
+
fields: ['shop', 'title', 'description'],
|
|
6241
|
+
bindPersistData: (value) => ({
|
|
6242
|
+
metadatas: { data: value },
|
|
6243
|
+
}),
|
|
6244
|
+
},
|
|
6245
|
+
},
|
|
5987
6246
|
{ isCollection: { columnName: 'is_collection' } },
|
|
5988
6247
|
{ isWishlist: { columnName: 'is_wishlist' } },
|
|
5989
6248
|
'reference',
|
|
@@ -5998,15 +6257,34 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
5998
6257
|
{ personId: { columnName: 'person_id' } },
|
|
5999
6258
|
{ personName: { columnName: 'person_name' } },
|
|
6000
6259
|
{ personPhoto: { columnName: 'person_photo' } },
|
|
6260
|
+
{ personType: { columnName: 'person_type' } },
|
|
6261
|
+
{ personIsSubscriber: { columnName: 'person_is_subscriber' } },
|
|
6001
6262
|
'theme',
|
|
6002
6263
|
{ bannerUrl: { columnName: 'banner_url' } },
|
|
6264
|
+
{ personHasPhoto: { columnName: 'person_has_photo' } },
|
|
6265
|
+
{ mostRelevants: { columnName: 'most_relevants', type: HasuraGraphQLColumnType.Jsonb } },
|
|
6003
6266
|
],
|
|
6004
6267
|
});
|
|
6005
|
-
this.
|
|
6268
|
+
this.categoryProductRepository = categoryProductRepository;
|
|
6006
6269
|
}
|
|
6007
6270
|
async create(params) {
|
|
6008
|
-
|
|
6009
|
-
|
|
6271
|
+
var _a;
|
|
6272
|
+
const { images, mostRelevants, metadatas } = params, data = __rest(params, ["images", "mostRelevants", "metadatas"]);
|
|
6273
|
+
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 || {
|
|
6274
|
+
[Shops.GLAMSHOP]: null,
|
|
6275
|
+
[Shops.MENSMARKET]: null,
|
|
6276
|
+
}, images: images || {
|
|
6277
|
+
[Shops.GLAMSHOP]: {
|
|
6278
|
+
brandBanner: null,
|
|
6279
|
+
brandBannerMobile: null,
|
|
6280
|
+
image: null,
|
|
6281
|
+
},
|
|
6282
|
+
[Shops.MENSMARKET]: {
|
|
6283
|
+
brandBanner: null,
|
|
6284
|
+
brandBannerMobile: null,
|
|
6285
|
+
image: null,
|
|
6286
|
+
},
|
|
6287
|
+
} }));
|
|
6010
6288
|
}
|
|
6011
6289
|
async get(identifiers) {
|
|
6012
6290
|
const data = await super.get(identifiers);
|
|
@@ -6019,12 +6297,11 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
6019
6297
|
return await super.find(Object.assign(Object.assign({}, rest), { filters: Object.assign(Object.assign({}, filters), { isWishlist: { operator: Where.EQUALS, value: true } }) }));
|
|
6020
6298
|
}
|
|
6021
6299
|
async update(params) {
|
|
6022
|
-
const { products, id: checkId,
|
|
6300
|
+
const { products, id: checkId, metadatas, filters } = params, data = __rest(params, ["products", "id", "metadatas", "filters"]);
|
|
6023
6301
|
const plainData = this.paramsToPlain({ id: checkId });
|
|
6024
6302
|
const id = plainData.id;
|
|
6025
6303
|
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 }));
|
|
6304
|
+
category.metadatas = metadatas && (await this.updateMetadata(+id, { metadatas }));
|
|
6028
6305
|
return category;
|
|
6029
6306
|
}
|
|
6030
6307
|
async getWishlistBySlug(slug) {
|
|
@@ -6056,12 +6333,18 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
6056
6333
|
options: {
|
|
6057
6334
|
enableCount: false,
|
|
6058
6335
|
},
|
|
6336
|
+
orderBy: {
|
|
6337
|
+
id: 'asc',
|
|
6338
|
+
},
|
|
6339
|
+
limits: {
|
|
6340
|
+
limit: 1,
|
|
6341
|
+
},
|
|
6059
6342
|
});
|
|
6060
6343
|
if (!data.length)
|
|
6061
6344
|
throw new NotFoundError(`Wishlists from person ${personId} not found`);
|
|
6062
6345
|
return data;
|
|
6063
6346
|
}
|
|
6064
|
-
getCategoryBySlug(slug, _shop) {
|
|
6347
|
+
async getCategoryBySlug(slug, _shop) {
|
|
6065
6348
|
return this.getWishlistBySlug(slug);
|
|
6066
6349
|
}
|
|
6067
6350
|
async getCategoryByShop(shop) {
|
|
@@ -6079,10 +6362,17 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
6079
6362
|
});
|
|
6080
6363
|
return data;
|
|
6081
6364
|
}
|
|
6082
|
-
|
|
6365
|
+
async findBfluOrGlamgirlWishlists(params, shops) {
|
|
6366
|
+
var _a, _b;
|
|
6367
|
+
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 : {
|
|
6368
|
+
operator: Where.IN,
|
|
6369
|
+
value: [PersonTypes.BFLU, PersonTypes.GLAMGIRL],
|
|
6370
|
+
} }), orderBy: Object.assign({ personHasPhoto: 'desc' }, omit(params.orderBy, ['personHasPhoto'])) }));
|
|
6371
|
+
}
|
|
6372
|
+
getCategoriesForHome(categoryIds, gender, limit) {
|
|
6083
6373
|
return;
|
|
6084
6374
|
}
|
|
6085
|
-
mountCategory(category, options) {
|
|
6375
|
+
mountCategory(category, shop, options) {
|
|
6086
6376
|
return;
|
|
6087
6377
|
}
|
|
6088
6378
|
getChildren(parentId) {
|
|
@@ -6091,61 +6381,46 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
6091
6381
|
isChild(id, parentId) {
|
|
6092
6382
|
return;
|
|
6093
6383
|
}
|
|
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);
|
|
6384
|
+
async updateMetadata(categoryId, { metadatas }) {
|
|
6385
|
+
if (Array.isArray(metadatas) && !metadatas.length)
|
|
6104
6386
|
return [];
|
|
6387
|
+
if (Array.isArray(metadatas) && metadatas.length) {
|
|
6388
|
+
const metadataUpdated = [];
|
|
6389
|
+
for (const data of metadatas) {
|
|
6390
|
+
const update = await this.mutation('update_category_metadata_by_pk', ['category_id', 'shop'], {
|
|
6391
|
+
pk_columns: {
|
|
6392
|
+
value: { category_id: categoryId, shop: data.shop },
|
|
6393
|
+
type: 'category_metadata_pk_columns_input',
|
|
6394
|
+
required: true,
|
|
6395
|
+
},
|
|
6396
|
+
_set: {
|
|
6397
|
+
value: omit(data, ['category_id', 'shop']),
|
|
6398
|
+
type: 'category_metadata_set_input',
|
|
6399
|
+
required: true,
|
|
6400
|
+
},
|
|
6401
|
+
});
|
|
6402
|
+
metadataUpdated.push(update);
|
|
6403
|
+
}
|
|
6404
|
+
return metadataUpdated;
|
|
6105
6405
|
}
|
|
6106
|
-
|
|
6107
|
-
|
|
6406
|
+
if ('action' in metadatas && metadatas.action === 'remove' && metadatas.value.length) {
|
|
6407
|
+
for (let i = 0; i < metadatas.value.length; i++) {
|
|
6408
|
+
await this.mutation('delete_category_metadata', ['affected_rows'], {
|
|
6409
|
+
where: {
|
|
6410
|
+
type: 'category_metadata_bool_exp',
|
|
6411
|
+
required: true,
|
|
6412
|
+
value: { category_id: { _eq: categoryId }, shop: metadatas.value[i].shop },
|
|
6413
|
+
},
|
|
6414
|
+
});
|
|
6415
|
+
}
|
|
6108
6416
|
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;
|
|
6417
|
+
}
|
|
6131
6418
|
}
|
|
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;
|
|
6419
|
+
async addProduct(wishlistId, productId) {
|
|
6420
|
+
return this.categoryProductRepository.addProductToCategory(wishlistId, productId);
|
|
6421
|
+
}
|
|
6422
|
+
async removeProduct(wishlistId, productId) {
|
|
6423
|
+
return this.categoryProductRepository.removeProductFromCategory(wishlistId, productId);
|
|
6149
6424
|
}
|
|
6150
6425
|
}
|
|
6151
6426
|
__decorate([
|
|
@@ -6166,5 +6441,164 @@ __decorate([
|
|
|
6166
6441
|
__metadata("design:paramtypes", [String]),
|
|
6167
6442
|
__metadata("design:returntype", Promise)
|
|
6168
6443
|
], WishlistHasuraGraphQLRepository.prototype, "getCategoryByShop", null);
|
|
6444
|
+
__decorate([
|
|
6445
|
+
Log(),
|
|
6446
|
+
__metadata("design:type", Function),
|
|
6447
|
+
__metadata("design:paramtypes", [Object, Array]),
|
|
6448
|
+
__metadata("design:returntype", Promise)
|
|
6449
|
+
], WishlistHasuraGraphQLRepository.prototype, "findBfluOrGlamgirlWishlists", null);
|
|
6450
|
+
|
|
6451
|
+
class VertexAxiosAdapter {
|
|
6452
|
+
constructor(config) {
|
|
6453
|
+
this.config = config;
|
|
6454
|
+
this.logger = DebugHelper.from(this);
|
|
6455
|
+
}
|
|
6456
|
+
async query(term, total, gender) {
|
|
6457
|
+
const logger = this.logger.with('query');
|
|
6458
|
+
const req = {
|
|
6459
|
+
url: `${this.config.url}/search`,
|
|
6460
|
+
method: 'POST',
|
|
6461
|
+
responseType: 'json',
|
|
6462
|
+
headers: {
|
|
6463
|
+
Accept: 'application/json',
|
|
6464
|
+
},
|
|
6465
|
+
data: { term, total, gender },
|
|
6466
|
+
};
|
|
6467
|
+
try {
|
|
6468
|
+
const { data } = await axios(req);
|
|
6469
|
+
return data;
|
|
6470
|
+
}
|
|
6471
|
+
catch (error) {
|
|
6472
|
+
logger.error({ req, res: error });
|
|
6473
|
+
throw error;
|
|
6474
|
+
}
|
|
6475
|
+
}
|
|
6476
|
+
async get(id) {
|
|
6477
|
+
const logger = this.logger.with('update');
|
|
6478
|
+
const req = {
|
|
6479
|
+
url: `${this.config.url}/${id}`,
|
|
6480
|
+
method: 'GET',
|
|
6481
|
+
responseType: 'json',
|
|
6482
|
+
headers: {
|
|
6483
|
+
Accept: 'application/json',
|
|
6484
|
+
},
|
|
6485
|
+
};
|
|
6486
|
+
try {
|
|
6487
|
+
const { data } = await axios(req);
|
|
6488
|
+
return data;
|
|
6489
|
+
}
|
|
6490
|
+
catch (error) {
|
|
6491
|
+
logger.error({ req, res: error });
|
|
6492
|
+
throw error;
|
|
6493
|
+
}
|
|
6494
|
+
}
|
|
6495
|
+
async save(data) {
|
|
6496
|
+
const logger = this.logger.with('save');
|
|
6497
|
+
const req = {
|
|
6498
|
+
url: `${this.config.url}/sync`,
|
|
6499
|
+
method: 'POST',
|
|
6500
|
+
responseType: 'json',
|
|
6501
|
+
headers: {
|
|
6502
|
+
Accept: 'application/json',
|
|
6503
|
+
},
|
|
6504
|
+
data,
|
|
6505
|
+
};
|
|
6506
|
+
try {
|
|
6507
|
+
const { data } = await axios(req);
|
|
6508
|
+
return data;
|
|
6509
|
+
}
|
|
6510
|
+
catch (error) {
|
|
6511
|
+
logger.error({ req, res: error });
|
|
6512
|
+
throw error;
|
|
6513
|
+
}
|
|
6514
|
+
}
|
|
6515
|
+
async update(id, data) {
|
|
6516
|
+
const logger = this.logger.with('update');
|
|
6517
|
+
const req = {
|
|
6518
|
+
url: `${this.config.url}/${id}`,
|
|
6519
|
+
method: 'PUT',
|
|
6520
|
+
responseType: 'json',
|
|
6521
|
+
headers: {
|
|
6522
|
+
Accept: 'application/json',
|
|
6523
|
+
},
|
|
6524
|
+
data,
|
|
6525
|
+
};
|
|
6526
|
+
try {
|
|
6527
|
+
const { data } = await axios(req);
|
|
6528
|
+
return data;
|
|
6529
|
+
}
|
|
6530
|
+
catch (error) {
|
|
6531
|
+
logger.error({ req, res: error });
|
|
6532
|
+
throw error;
|
|
6533
|
+
}
|
|
6534
|
+
}
|
|
6535
|
+
async delete(id) {
|
|
6536
|
+
const logger = this.logger.with('delete');
|
|
6537
|
+
const req = {
|
|
6538
|
+
url: `${this.config.url}/${id}`,
|
|
6539
|
+
method: 'DELETE',
|
|
6540
|
+
responseType: 'json',
|
|
6541
|
+
headers: {
|
|
6542
|
+
Accept: 'application/json',
|
|
6543
|
+
},
|
|
6544
|
+
};
|
|
6545
|
+
try {
|
|
6546
|
+
const { data } = await axios(req);
|
|
6547
|
+
return data;
|
|
6548
|
+
}
|
|
6549
|
+
catch (error) {
|
|
6550
|
+
logger.error({ req, res: error });
|
|
6551
|
+
throw error;
|
|
6552
|
+
}
|
|
6553
|
+
}
|
|
6554
|
+
bulkProducts(products) {
|
|
6555
|
+
return;
|
|
6556
|
+
}
|
|
6557
|
+
}
|
|
6558
|
+
|
|
6559
|
+
class ProductsVertexSearch {
|
|
6560
|
+
constructor(adapter) {
|
|
6561
|
+
this.adapter = adapter;
|
|
6562
|
+
}
|
|
6563
|
+
async getById(id) {
|
|
6564
|
+
const data = await this.adapter.get(id);
|
|
6565
|
+
return data;
|
|
6566
|
+
}
|
|
6567
|
+
async search(searchTerm, total, gender) {
|
|
6568
|
+
try {
|
|
6569
|
+
const result = await this.adapter.query(searchTerm, total, gender);
|
|
6570
|
+
return result;
|
|
6571
|
+
}
|
|
6572
|
+
catch (error) {
|
|
6573
|
+
console.error(error);
|
|
6574
|
+
}
|
|
6575
|
+
}
|
|
6576
|
+
async save(product) {
|
|
6577
|
+
try {
|
|
6578
|
+
const _a = product.toPlain(), { createdAt, updatedAt, kitProducts } = _a, data = __rest(_a, ["createdAt", "updatedAt", "kitProducts"]);
|
|
6579
|
+
const newProduct = Product.toInstance(data);
|
|
6580
|
+
await this.adapter.save(newProduct);
|
|
6581
|
+
}
|
|
6582
|
+
catch (error) {
|
|
6583
|
+
console.error(error);
|
|
6584
|
+
}
|
|
6585
|
+
}
|
|
6586
|
+
async update(product) {
|
|
6587
|
+
try {
|
|
6588
|
+
await this.adapter.update(product.id, product);
|
|
6589
|
+
}
|
|
6590
|
+
catch (error) {
|
|
6591
|
+
console.error(error);
|
|
6592
|
+
}
|
|
6593
|
+
}
|
|
6594
|
+
async delete(id) {
|
|
6595
|
+
try {
|
|
6596
|
+
await this.adapter.delete(id);
|
|
6597
|
+
}
|
|
6598
|
+
catch (error) {
|
|
6599
|
+
console.error(error);
|
|
6600
|
+
}
|
|
6601
|
+
}
|
|
6602
|
+
}
|
|
6169
6603
|
|
|
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 };
|
|
6604
|
+
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, ProductLabelEnum, 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 };
|