@infrab4a/connect 4.9.7-beta.34 → 4.9.7-beta.4
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 +597 -1035
- package/index.esm.js +598 -1028
- package/package.json +1 -1
- package/src/domain/catalog/models/category-base.d.ts +3 -5
- package/src/domain/catalog/models/enums/index.d.ts +0 -2
- package/src/domain/catalog/models/filter.d.ts +0 -1
- package/src/domain/catalog/models/index.d.ts +0 -1
- package/src/domain/catalog/models/product-base.d.ts +1 -4
- package/src/domain/catalog/models/types/index.d.ts +1 -3
- package/src/domain/catalog/models/variant.d.ts +0 -4
- package/src/domain/catalog/models/wishlist.d.ts +0 -3
- package/src/domain/catalog/repositories/category.repository.d.ts +3 -3
- package/src/domain/catalog/repositories/index.d.ts +0 -1
- package/src/domain/catalog/repositories/product-reviews.repository.d.ts +0 -1
- package/src/domain/catalog/repositories/product-stock-notification.repository.d.ts +1 -9
- package/src/domain/catalog/repositories/product.repository.d.ts +1 -2
- package/src/domain/catalog/repositories/wishlist.repository.d.ts +1 -6
- package/src/domain/general/index.d.ts +0 -3
- package/src/domain/shopping/index.d.ts +0 -1
- package/src/domain/shopping/models/buy-2-win.d.ts +0 -2
- package/src/domain/shopping/models/coupons/coupon.d.ts +4 -8
- package/src/domain/shopping/models/coupons/enums/coupon-types.enum.d.ts +1 -2
- package/src/domain/shopping/models/coupons/enums/index.d.ts +1 -3
- package/src/domain/shopping/models/index.d.ts +0 -1
- package/src/domain/shopping/models/order.d.ts +0 -4
- package/src/domain/shopping/repositories/index.d.ts +0 -1
- package/src/domain/users/models/enums/index.d.ts +0 -1
- package/src/domain/users/models/index.d.ts +2 -3
- package/src/infra/elasticsearch/indexes/products-index.d.ts +1 -39
- package/src/infra/firebase/firestore/mixins/with-helpers.mixin.d.ts +1 -1
- package/src/infra/firebase/firestore/repositories/catalog/category-firestore.repository.d.ts +2 -2
- package/src/infra/firebase/firestore/repositories/catalog/product-firestore.repository.d.ts +1 -2
- package/src/infra/firebase/firestore/repositories/index.d.ts +2 -3
- package/src/infra/firebase/firestore/repositories/shopping/index.d.ts +0 -1
- package/src/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.d.ts +0 -1
- package/src/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.d.ts +2 -2
- package/src/infra/hasura-graphql/repositories/catalog/index.d.ts +0 -1
- package/src/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.d.ts +2 -2
- package/src/infra/hasura-graphql/repositories/catalog/product-review-hasura-graphql.repository.d.ts +0 -1
- package/src/infra/hasura-graphql/repositories/catalog/product-stock-notification-hasura-graphql.repository.d.ts +1 -8
- package/src/infra/hasura-graphql/repositories/catalog/wishlist-hasura-graphql.repository.d.ts +15 -18
- package/src/infra/index.d.ts +0 -1
- package/src/domain/catalog/models/category-product.d.ts +0 -8
- package/src/domain/catalog/models/enums/product-label.enum.d.ts +0 -6
- package/src/domain/catalog/models/enums/wishlist-log.enum.d.ts +0 -7
- package/src/domain/catalog/models/types/product-label.type.d.ts +0 -2
- package/src/domain/catalog/models/types/product-variant-report.type.d.ts +0 -46
- package/src/domain/catalog/models/types/report-stock-notification.type.d.ts +0 -21
- package/src/domain/catalog/repositories/category-product.repository.d.ts +0 -6
- package/src/domain/general/models/index.d.ts +0 -1
- package/src/domain/general/models/log-document.d.ts +0 -15
- package/src/domain/general/repositories/index.d.ts +0 -1
- package/src/domain/general/repositories/log.repository.d.ts +0 -4
- package/src/domain/general/search/index.d.ts +0 -1
- package/src/domain/general/search/product-search-index.d.ts +0 -3
- package/src/domain/shopping/models/coupons/enums/coupon-category.enum.d.ts +0 -41
- package/src/domain/shopping/models/coupons/enums/coupon-channels.enum.d.ts +0 -10
- package/src/domain/shopping/models/coupons/types/coupon-category.type.d.ts +0 -2
- package/src/domain/shopping/models/coupons/types/coupon-channel.type.d.ts +0 -2
- package/src/domain/shopping/models/coupons/types/index.d.ts +0 -2
- package/src/domain/shopping/models/order-blocked.d.ts +0 -26
- package/src/domain/shopping/repositories/order-blocked.repository.d.ts +0 -6
- package/src/domain/shopping/types/index.d.ts +0 -2
- package/src/domain/shopping/types/order-tracking-events.type.d.ts +0 -14
- package/src/domain/shopping/types/payment-card-info.type.d.ts +0 -4
- package/src/domain/users/models/enums/person-types.enum.d.ts +0 -5
- package/src/domain/users/models/types/index.d.ts +0 -1
- package/src/domain/users/models/types/person.type.d.ts +0 -2
- package/src/infra/firebase/firestore/repositories/general/index.d.ts +0 -1
- package/src/infra/firebase/firestore/repositories/general/log-firestore.repository.d.ts +0 -7
- package/src/infra/firebase/firestore/repositories/shopping/order-blocked-firestore.repository.ts.d.ts +0 -9
- package/src/infra/hasura-graphql/models/wishlist-hasura-graphql.d.ts +0 -4
- package/src/infra/hasura-graphql/repositories/catalog/category-product-hasura-graphql.repository.d.ts +0 -11
- package/src/infra/vertex-ai/adapters/index.d.ts +0 -2
- package/src/infra/vertex-ai/adapters/vertex-ai-search.adapter.d.ts +0 -10
- package/src/infra/vertex-ai/adapters/vertex-axios.adapter.d.ts +0 -15
- package/src/infra/vertex-ai/index.d.ts +0 -3
- package/src/infra/vertex-ai/indexes/index.d.ts +0 -1
- package/src/infra/vertex-ai/indexes/products-vertex-search.d.ts +0 -13
- package/src/infra/vertex-ai/types/axios-vertex-search-config.d.ts +0 -4
- package/src/infra/vertex-ai/types/index.d.ts +0 -3
- package/src/infra/vertex-ai/types/product-bulk.d.ts +0 -4
- package/src/infra/vertex-ai/types/product-search.d.ts +0 -21
package/index.esm.js
CHANGED
|
@@ -43,14 +43,6 @@ var GenderDestination;
|
|
|
43
43
|
GenderDestination["UNISEX"] = "unisex";
|
|
44
44
|
})(GenderDestination || (GenderDestination = {}));
|
|
45
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
46
|
var Shops;
|
|
55
47
|
(function (Shops) {
|
|
56
48
|
Shops["MENSMARKET"] = "mensmarket";
|
|
@@ -59,15 +51,6 @@ var Shops;
|
|
|
59
51
|
Shops["ALL"] = "ALL";
|
|
60
52
|
})(Shops || (Shops = {}));
|
|
61
53
|
|
|
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
|
-
|
|
71
54
|
class Filter extends BaseModel {
|
|
72
55
|
static get identifiersFields() {
|
|
73
56
|
return ['id'];
|
|
@@ -83,31 +66,19 @@ class CategoryBase extends BaseModel {
|
|
|
83
66
|
return ['id'];
|
|
84
67
|
}
|
|
85
68
|
get glamImages() {
|
|
86
|
-
return this.images
|
|
87
|
-
? this.images[Shops.GLAMSHOP]
|
|
88
|
-
: {
|
|
89
|
-
brandBanner: null,
|
|
90
|
-
brandBannerMobile: null,
|
|
91
|
-
image: null,
|
|
92
|
-
};
|
|
69
|
+
return this.images[Shops.GLAMSHOP];
|
|
93
70
|
}
|
|
94
71
|
get mensImages() {
|
|
95
|
-
return this.images
|
|
96
|
-
? this.images[Shops.MENSMARKET]
|
|
97
|
-
: {
|
|
98
|
-
brandBanner: null,
|
|
99
|
-
brandBannerMobile: null,
|
|
100
|
-
image: null,
|
|
101
|
-
};
|
|
72
|
+
return this.images[Shops.MENSMARKET];
|
|
102
73
|
}
|
|
103
74
|
get glamMetadata() {
|
|
104
|
-
return this.
|
|
75
|
+
return this.metadata.find((metadata) => metadata.shop === Shops.GLAMSHOP);
|
|
105
76
|
}
|
|
106
77
|
get mensMetadata() {
|
|
107
|
-
return this.
|
|
78
|
+
return this.metadata.find((metadata) => metadata.shop === Shops.MENSMARKET);
|
|
108
79
|
}
|
|
109
|
-
|
|
110
|
-
return this.
|
|
80
|
+
glamMostRelevantByShop(shop) {
|
|
81
|
+
return this.mostRelevant[shop];
|
|
111
82
|
}
|
|
112
83
|
}
|
|
113
84
|
__decorate([
|
|
@@ -217,12 +188,6 @@ __decorate([
|
|
|
217
188
|
__metadata("design:type", Category)
|
|
218
189
|
], CategoryFilter.prototype, "category", void 0);
|
|
219
190
|
|
|
220
|
-
class CategoryProduct extends BaseModel {
|
|
221
|
-
static get identifiersFields() {
|
|
222
|
-
return ['categoryId', 'productId'];
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
|
|
226
191
|
class FilterOption extends BaseModel {
|
|
227
192
|
static get identifiersFields() {
|
|
228
193
|
return ['id'];
|
|
@@ -315,17 +280,6 @@ class CampaignHashtag extends BaseModel {
|
|
|
315
280
|
}
|
|
316
281
|
}
|
|
317
282
|
|
|
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
|
-
|
|
329
283
|
var AccessoryImportances;
|
|
330
284
|
(function (AccessoryImportances) {
|
|
331
285
|
AccessoryImportances["NOT_INTERESTED"] = "N\u00E3o tenho interesse";
|
|
@@ -502,13 +456,6 @@ var OfficePosition;
|
|
|
502
456
|
OfficePosition["Director"] = "Diretor";
|
|
503
457
|
})(OfficePosition || (OfficePosition = {}));
|
|
504
458
|
|
|
505
|
-
var PersonTypes;
|
|
506
|
-
(function (PersonTypes) {
|
|
507
|
-
PersonTypes["GLAMGIRL"] = "glamgirl";
|
|
508
|
-
PersonTypes["BFLU"] = "bflu";
|
|
509
|
-
PersonTypes["NONE"] = "none";
|
|
510
|
-
})(PersonTypes || (PersonTypes = {}));
|
|
511
|
-
|
|
512
459
|
var ProductSpents;
|
|
513
460
|
(function (ProductSpents) {
|
|
514
461
|
ProductSpents["UNTIL_50"] = "At\u00E9 R$50";
|
|
@@ -529,12 +476,6 @@ var UserType;
|
|
|
529
476
|
UserType["Influencer"] = "Influencer";
|
|
530
477
|
})(UserType || (UserType = {}));
|
|
531
478
|
|
|
532
|
-
class Lead extends BaseModel {
|
|
533
|
-
static get identifiersFields() {
|
|
534
|
-
return ['id'];
|
|
535
|
-
}
|
|
536
|
-
}
|
|
537
|
-
|
|
538
479
|
class Edition extends BaseModel {
|
|
539
480
|
static get identifiersFields() {
|
|
540
481
|
return ['id', 'subscriptionId'];
|
|
@@ -1860,6 +1801,40 @@ const parseDateTime = (value) => {
|
|
|
1860
1801
|
return date;
|
|
1861
1802
|
};
|
|
1862
1803
|
|
|
1804
|
+
var CheckoutTypes;
|
|
1805
|
+
(function (CheckoutTypes) {
|
|
1806
|
+
CheckoutTypes[CheckoutTypes["ECOMMERCE"] = 1] = "ECOMMERCE";
|
|
1807
|
+
CheckoutTypes[CheckoutTypes["SUBSCRIPTION"] = 2] = "SUBSCRIPTION";
|
|
1808
|
+
CheckoutTypes[CheckoutTypes["ALL"] = 3] = "ALL";
|
|
1809
|
+
})(CheckoutTypes || (CheckoutTypes = {}));
|
|
1810
|
+
|
|
1811
|
+
var CouponTypes;
|
|
1812
|
+
(function (CouponTypes) {
|
|
1813
|
+
CouponTypes[CouponTypes["ABSOLUTE"] = 1] = "ABSOLUTE";
|
|
1814
|
+
CouponTypes[CouponTypes["PERCENTAGE"] = 2] = "PERCENTAGE";
|
|
1815
|
+
// FINANCIAL = 1,
|
|
1816
|
+
// PRODUCT,
|
|
1817
|
+
// GIFTCARD,
|
|
1818
|
+
// VOUCHER,
|
|
1819
|
+
})(CouponTypes || (CouponTypes = {}));
|
|
1820
|
+
|
|
1821
|
+
var CouponSubtypes;
|
|
1822
|
+
(function (CouponSubtypes) {
|
|
1823
|
+
CouponSubtypes[CouponSubtypes["ABSOLUTE"] = 1] = "ABSOLUTE";
|
|
1824
|
+
CouponSubtypes[CouponSubtypes["PERCENTAGE"] = 2] = "PERCENTAGE";
|
|
1825
|
+
})(CouponSubtypes || (CouponSubtypes = {}));
|
|
1826
|
+
|
|
1827
|
+
var Exclusivities;
|
|
1828
|
+
(function (Exclusivities) {
|
|
1829
|
+
Exclusivities[Exclusivities["ALL_USERS"] = 1] = "ALL_USERS";
|
|
1830
|
+
Exclusivities[Exclusivities["SPECIFIC_USER"] = 2] = "SPECIFIC_USER";
|
|
1831
|
+
Exclusivities[Exclusivities["COLLABORATORS"] = 3] = "COLLABORATORS";
|
|
1832
|
+
Exclusivities[Exclusivities["ACTIVE_SUBSCRIBER"] = 4] = "ACTIVE_SUBSCRIBER";
|
|
1833
|
+
Exclusivities[Exclusivities["INACTIVE_SUBSCRIBER"] = 5] = "INACTIVE_SUBSCRIBER";
|
|
1834
|
+
Exclusivities[Exclusivities["NON_SUBSCRIBER"] = 6] = "NON_SUBSCRIBER";
|
|
1835
|
+
})(Exclusivities || (Exclusivities = {}));
|
|
1836
|
+
|
|
1837
|
+
const COUPON_EXPIRATION = +1000 * 60 * 60 * 24 * 30;
|
|
1863
1838
|
class Coupon extends BaseModel {
|
|
1864
1839
|
get isInfluencer() {
|
|
1865
1840
|
return !isNil(this.influencerEmail);
|
|
@@ -1867,6 +1842,30 @@ class Coupon extends BaseModel {
|
|
|
1867
1842
|
static get identifiersFields() {
|
|
1868
1843
|
return ['id'];
|
|
1869
1844
|
}
|
|
1845
|
+
static createCoupon(userId) {
|
|
1846
|
+
return this.toInstance({
|
|
1847
|
+
nickname: `${Date.now()}`,
|
|
1848
|
+
checkoutType: CheckoutTypes.ECOMMERCE,
|
|
1849
|
+
discount: {
|
|
1850
|
+
subscriber: {
|
|
1851
|
+
type: CouponTypes.ABSOLUTE,
|
|
1852
|
+
value: 10,
|
|
1853
|
+
},
|
|
1854
|
+
non_subscriber: {
|
|
1855
|
+
type: CouponTypes.ABSOLUTE,
|
|
1856
|
+
value: 10,
|
|
1857
|
+
},
|
|
1858
|
+
subscription: {
|
|
1859
|
+
type: CouponTypes.ABSOLUTE,
|
|
1860
|
+
value: 10,
|
|
1861
|
+
},
|
|
1862
|
+
},
|
|
1863
|
+
user: userId,
|
|
1864
|
+
createdAt: new Date(Date.now()),
|
|
1865
|
+
beginAt: new Date(Date.now()),
|
|
1866
|
+
expiresIn: new Date(Date.now() + COUPON_EXPIRATION),
|
|
1867
|
+
});
|
|
1868
|
+
}
|
|
1870
1869
|
}
|
|
1871
1870
|
|
|
1872
1871
|
class SubscriptionPlan extends BaseModel {
|
|
@@ -1875,6 +1874,17 @@ class SubscriptionPlan extends BaseModel {
|
|
|
1875
1874
|
}
|
|
1876
1875
|
}
|
|
1877
1876
|
|
|
1877
|
+
class BeautyProfile extends BaseModel {
|
|
1878
|
+
toPlain() {
|
|
1879
|
+
const plain = super.toPlain();
|
|
1880
|
+
delete plain.id;
|
|
1881
|
+
return plain;
|
|
1882
|
+
}
|
|
1883
|
+
static get identifiersFields() {
|
|
1884
|
+
return ['id', 'userId'];
|
|
1885
|
+
}
|
|
1886
|
+
}
|
|
1887
|
+
|
|
1878
1888
|
class User extends BaseModel {
|
|
1879
1889
|
static toInstance(data) {
|
|
1880
1890
|
const instance = super.toInstance(data);
|
|
@@ -1988,6 +1998,12 @@ class UserPaymentMethod extends BaseModel {
|
|
|
1988
1998
|
}
|
|
1989
1999
|
}
|
|
1990
2000
|
|
|
2001
|
+
class Lead extends BaseModel {
|
|
2002
|
+
static get identifiersFields() {
|
|
2003
|
+
return ['id'];
|
|
2004
|
+
}
|
|
2005
|
+
}
|
|
2006
|
+
|
|
1991
2007
|
class UnauthorizedError extends CustomError {
|
|
1992
2008
|
constructor(message) {
|
|
1993
2009
|
super(message);
|
|
@@ -2141,93 +2157,6 @@ __decorate([
|
|
|
2141
2157
|
__metadata("design:type", Coupon)
|
|
2142
2158
|
], Checkout.prototype, "coupon", void 0);
|
|
2143
2159
|
|
|
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
|
-
|
|
2231
2160
|
var OrderStatus;
|
|
2232
2161
|
(function (OrderStatus) {
|
|
2233
2162
|
OrderStatus["AGUARDANDO_PAGAMENTO"] = "Aguardando pagamento";
|
|
@@ -2247,12 +2176,6 @@ __decorate([
|
|
|
2247
2176
|
__metadata("design:type", Payment)
|
|
2248
2177
|
], Order.prototype, "payment", void 0);
|
|
2249
2178
|
|
|
2250
|
-
class OrderBlocked extends BaseModel {
|
|
2251
|
-
static get identifiersFields() {
|
|
2252
|
-
return ['id'];
|
|
2253
|
-
}
|
|
2254
|
-
}
|
|
2255
|
-
|
|
2256
2179
|
class CheckoutSubscription extends BaseModel {
|
|
2257
2180
|
static get identifiersFields() {
|
|
2258
2181
|
return ['id'];
|
|
@@ -2289,12 +2212,6 @@ class RoundProductPricesHelper {
|
|
|
2289
2212
|
}
|
|
2290
2213
|
}
|
|
2291
2214
|
|
|
2292
|
-
class LogDocument extends BaseModel {
|
|
2293
|
-
static get identifiersFields() {
|
|
2294
|
-
return ['id'];
|
|
2295
|
-
}
|
|
2296
|
-
}
|
|
2297
|
-
|
|
2298
2215
|
var FilterType;
|
|
2299
2216
|
(function (FilterType) {
|
|
2300
2217
|
FilterType["ACCESSORY_IMPORTANCE"] = "accessoryImportance";
|
|
@@ -2593,6 +2510,8 @@ class ProductsIndex {
|
|
|
2593
2510
|
'rate',
|
|
2594
2511
|
];
|
|
2595
2512
|
const filter = [{ term: { published: true } }];
|
|
2513
|
+
if (shop && shop !== Shops.ALL)
|
|
2514
|
+
filter.push({ term: { tags: shop == Shops.GLAMSHOP ? 'feminino' : 'masculino' } });
|
|
2596
2515
|
if (size > 9)
|
|
2597
2516
|
fields.push(...['pricePaid', 'isGift', 'stock', 'weight', 'tags']);
|
|
2598
2517
|
const query = {
|
|
@@ -2648,9 +2567,7 @@ class ProductsIndex {
|
|
|
2648
2567
|
RoundProductPricesHelper.roundProductPrices(hit._source);
|
|
2649
2568
|
return hit;
|
|
2650
2569
|
});
|
|
2651
|
-
return search
|
|
2652
|
-
return Object.assign(Object.assign({}, hit._source), { stock: hit._source.stock.quantity });
|
|
2653
|
-
});
|
|
2570
|
+
return search;
|
|
2654
2571
|
}
|
|
2655
2572
|
async save(product) {
|
|
2656
2573
|
try {
|
|
@@ -3084,8 +3001,6 @@ const withUpdateFirestore = (MixinBase) => {
|
|
|
3084
3001
|
try {
|
|
3085
3002
|
const identifiers = getValueFromParams(data, keyField);
|
|
3086
3003
|
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`);
|
|
3089
3004
|
const plainFromData = this.model.toInstance(this.paramsToPlain(data));
|
|
3090
3005
|
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 }));
|
|
3091
3006
|
const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || plainFromData;
|
|
@@ -3162,118 +3077,292 @@ const withCrudFirestore = (MixinBase) => {
|
|
|
3162
3077
|
};
|
|
3163
3078
|
};
|
|
3164
3079
|
|
|
3165
|
-
class
|
|
3080
|
+
class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3166
3081
|
constructor({ firestore, interceptors }) {
|
|
3167
3082
|
super({
|
|
3168
3083
|
firestore,
|
|
3169
|
-
collectionName: '
|
|
3170
|
-
model:
|
|
3084
|
+
collectionName: 'leads',
|
|
3085
|
+
model: Lead,
|
|
3171
3086
|
interceptors,
|
|
3172
3087
|
});
|
|
3173
3088
|
}
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
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;
|
|
3089
|
+
}
|
|
3090
|
+
|
|
3091
|
+
class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3092
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
3093
|
+
super({
|
|
3094
|
+
firestore,
|
|
3095
|
+
collectionName: 'editions',
|
|
3096
|
+
parentIdField: 'subscriptionId',
|
|
3097
|
+
model: Edition,
|
|
3098
|
+
interceptors,
|
|
3099
|
+
});
|
|
3100
|
+
this.parentRepository = parentRepository;
|
|
3230
3101
|
}
|
|
3231
|
-
|
|
3232
|
-
|
|
3102
|
+
}
|
|
3103
|
+
|
|
3104
|
+
class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3105
|
+
constructor({ firestore, interceptors, }) {
|
|
3106
|
+
super({
|
|
3107
|
+
firestore,
|
|
3108
|
+
collectionName: 'subscription',
|
|
3109
|
+
model: Subscription,
|
|
3110
|
+
interceptors,
|
|
3111
|
+
});
|
|
3233
3112
|
}
|
|
3234
3113
|
}
|
|
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);
|
|
3253
3114
|
|
|
3254
|
-
class
|
|
3115
|
+
class SubscriptionMaterializationFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3255
3116
|
constructor({ firestore, interceptors }) {
|
|
3256
3117
|
super({
|
|
3257
3118
|
firestore,
|
|
3258
|
-
collectionName: '
|
|
3259
|
-
model:
|
|
3119
|
+
collectionName: 'subscriptionMaterialization',
|
|
3120
|
+
model: SubscriptionMaterialization,
|
|
3260
3121
|
interceptors,
|
|
3261
3122
|
});
|
|
3262
|
-
this.reviews = {};
|
|
3263
3123
|
}
|
|
3264
|
-
|
|
3265
|
-
|
|
3124
|
+
}
|
|
3125
|
+
|
|
3126
|
+
class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3127
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
3128
|
+
super({
|
|
3129
|
+
firestore,
|
|
3130
|
+
collectionName: 'payments',
|
|
3131
|
+
parentIdField: 'subscriptionId',
|
|
3132
|
+
model: SubscriptionPayment,
|
|
3133
|
+
interceptors,
|
|
3134
|
+
});
|
|
3135
|
+
this.parentRepository = parentRepository;
|
|
3266
3136
|
}
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3137
|
+
}
|
|
3138
|
+
|
|
3139
|
+
class SubscriptionSummaryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3140
|
+
constructor({ firestore, interceptors, }) {
|
|
3141
|
+
super({
|
|
3142
|
+
firestore,
|
|
3143
|
+
collectionName: 'subscriptionSummary',
|
|
3144
|
+
model: SubscriptionSummary,
|
|
3145
|
+
interceptors,
|
|
3273
3146
|
});
|
|
3274
|
-
return (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
|
|
3275
3147
|
}
|
|
3276
|
-
|
|
3148
|
+
}
|
|
3149
|
+
|
|
3150
|
+
class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3151
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
3152
|
+
super({
|
|
3153
|
+
firestore,
|
|
3154
|
+
collectionName: 'address',
|
|
3155
|
+
parentIdField: 'userId',
|
|
3156
|
+
model: UserAddress,
|
|
3157
|
+
interceptors,
|
|
3158
|
+
});
|
|
3159
|
+
this.parentRepository = parentRepository;
|
|
3160
|
+
}
|
|
3161
|
+
}
|
|
3162
|
+
|
|
3163
|
+
class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3164
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
3165
|
+
super({
|
|
3166
|
+
firestore,
|
|
3167
|
+
collectionName: 'CX',
|
|
3168
|
+
parentIdField: 'userId',
|
|
3169
|
+
model: BeautyProfile,
|
|
3170
|
+
interceptors,
|
|
3171
|
+
});
|
|
3172
|
+
this.parentRepository = parentRepository;
|
|
3173
|
+
}
|
|
3174
|
+
}
|
|
3175
|
+
|
|
3176
|
+
class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3177
|
+
constructor({ firestore, interceptors }) {
|
|
3178
|
+
super({
|
|
3179
|
+
firestore,
|
|
3180
|
+
collectionName: 'users',
|
|
3181
|
+
model: User,
|
|
3182
|
+
interceptors,
|
|
3183
|
+
});
|
|
3184
|
+
}
|
|
3185
|
+
async get(identifiers) {
|
|
3186
|
+
const user = await super.get({ id: identifiers.id });
|
|
3187
|
+
user.beautyProfile = await this.getBeautyProfile(user.id);
|
|
3188
|
+
user.isSubscriber = await this.checkIfIsSubscriber(user.id);
|
|
3189
|
+
return user;
|
|
3190
|
+
}
|
|
3191
|
+
async checkIfExistsByField(field, value) {
|
|
3192
|
+
const result = await this.find({ filters: { [field]: value } });
|
|
3193
|
+
return result.count > 0;
|
|
3194
|
+
}
|
|
3195
|
+
buildModelInstance() {
|
|
3196
|
+
const { fromFirestore, toFirestore } = super.buildModelInstance();
|
|
3197
|
+
return {
|
|
3198
|
+
toFirestore: (data) => {
|
|
3199
|
+
const plain = toFirestore(data);
|
|
3200
|
+
delete plain.isSubscriber;
|
|
3201
|
+
return plain;
|
|
3202
|
+
},
|
|
3203
|
+
fromFirestore,
|
|
3204
|
+
};
|
|
3205
|
+
}
|
|
3206
|
+
async getBeautyProfile(userId) {
|
|
3207
|
+
const beautyProfile = await this.firestore
|
|
3208
|
+
.getCollection(`${this.collectionName}/${userId}/CX`)
|
|
3209
|
+
.withConverter(this.buildBeautyProfileModelInstance())
|
|
3210
|
+
.getDoc('beautyProfile')
|
|
3211
|
+
.get();
|
|
3212
|
+
return beautyProfile.data();
|
|
3213
|
+
}
|
|
3214
|
+
async checkIfIsSubscriber(userId) {
|
|
3215
|
+
const docs = await this.collection('subscription')
|
|
3216
|
+
.where('user.id', '==', userId)
|
|
3217
|
+
.where('status', '==', 'active')
|
|
3218
|
+
.getDocs();
|
|
3219
|
+
return !!docs && !!docs.size;
|
|
3220
|
+
}
|
|
3221
|
+
buildBeautyProfileModelInstance() {
|
|
3222
|
+
return {
|
|
3223
|
+
toFirestore: (data) => data.toPlain(),
|
|
3224
|
+
fromFirestore: (snap) => BeautyProfile.toInstance(snap.data()),
|
|
3225
|
+
};
|
|
3226
|
+
}
|
|
3227
|
+
}
|
|
3228
|
+
__decorate([
|
|
3229
|
+
Log(),
|
|
3230
|
+
__metadata("design:type", Function),
|
|
3231
|
+
__metadata("design:paramtypes", [Object]),
|
|
3232
|
+
__metadata("design:returntype", Promise)
|
|
3233
|
+
], UserFirestoreRepository.prototype, "get", null);
|
|
3234
|
+
__decorate([
|
|
3235
|
+
Log(),
|
|
3236
|
+
__metadata("design:type", Function),
|
|
3237
|
+
__metadata("design:paramtypes", [String, String]),
|
|
3238
|
+
__metadata("design:returntype", Promise)
|
|
3239
|
+
], UserFirestoreRepository.prototype, "checkIfExistsByField", null);
|
|
3240
|
+
|
|
3241
|
+
class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3242
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
3243
|
+
super({
|
|
3244
|
+
firestore,
|
|
3245
|
+
collectionName: 'payment_method',
|
|
3246
|
+
parentIdField: 'userId',
|
|
3247
|
+
model: UserPaymentMethod,
|
|
3248
|
+
interceptors,
|
|
3249
|
+
});
|
|
3250
|
+
this.parentRepository = parentRepository;
|
|
3251
|
+
}
|
|
3252
|
+
}
|
|
3253
|
+
|
|
3254
|
+
class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3255
|
+
constructor({ firestore, interceptors }) {
|
|
3256
|
+
super({
|
|
3257
|
+
firestore,
|
|
3258
|
+
collectionName: 'categories',
|
|
3259
|
+
model: Category,
|
|
3260
|
+
interceptors,
|
|
3261
|
+
});
|
|
3262
|
+
}
|
|
3263
|
+
async getCategoryBySlug(slug, shop) {
|
|
3264
|
+
const categoryDocs = await this.collection(this.collectionName)
|
|
3265
|
+
.where('slug', '==', slug)
|
|
3266
|
+
.where('shop', '==', shop)
|
|
3267
|
+
.where('published', '==', true)
|
|
3268
|
+
.getDocs();
|
|
3269
|
+
if (categoryDocs.size > 1)
|
|
3270
|
+
throw new DuplicatedResultsError('Query returned duplicated values');
|
|
3271
|
+
if (categoryDocs.empty)
|
|
3272
|
+
throw new NotFoundError(`Document with slug ${slug} not found`);
|
|
3273
|
+
return categoryDocs.docs[0].data();
|
|
3274
|
+
}
|
|
3275
|
+
async getCategoriesForHome(categoryIds, limit = 4, gender) {
|
|
3276
|
+
const categorySnap = await this.collection(this.collectionName)
|
|
3277
|
+
.where('id', 'in', categoryIds.filter(Boolean))
|
|
3278
|
+
.where('published', '==', true)
|
|
3279
|
+
.getDocs();
|
|
3280
|
+
if (categorySnap.empty)
|
|
3281
|
+
throw new NotFoundError('Categories not found');
|
|
3282
|
+
const categories = categorySnap.docs.map((doc) => doc.data());
|
|
3283
|
+
const homeSections = await Promise.all(categories.map(async (category) => ({
|
|
3284
|
+
category,
|
|
3285
|
+
products: await this.mountCategory(category, { limit, hasStock: true, gender }),
|
|
3286
|
+
})));
|
|
3287
|
+
return homeSections;
|
|
3288
|
+
}
|
|
3289
|
+
async mountCategory(category, options) {
|
|
3290
|
+
if (!category.products)
|
|
3291
|
+
throw new RequiredArgumentError(['Category products is empty']);
|
|
3292
|
+
const chunks = chunk(category.products, 10);
|
|
3293
|
+
const products = [];
|
|
3294
|
+
const wheres = [];
|
|
3295
|
+
for (const productIds of chunks) {
|
|
3296
|
+
if ((options === null || options === void 0 ? void 0 : options.limit) && products.length >= (options === null || options === void 0 ? void 0 : options.limit))
|
|
3297
|
+
break;
|
|
3298
|
+
wheres.push(['published', '==', true], ['id', 'in', productIds]);
|
|
3299
|
+
if (options === null || options === void 0 ? void 0 : options.hasStock)
|
|
3300
|
+
wheres.push(['stock.quantity', '>', 0]);
|
|
3301
|
+
if (options === null || options === void 0 ? void 0 : options.gender)
|
|
3302
|
+
wheres.push(['tags', 'array-contains', options === null || options === void 0 ? void 0 : options.gender]);
|
|
3303
|
+
const productSnap = await wheres
|
|
3304
|
+
.reduce((collection, where) => collection.where(...where), (options === null || options === void 0 ? void 0 : options.limit)
|
|
3305
|
+
? this.collection('productsErpVitrine').limit(options.limit)
|
|
3306
|
+
: this.collection('productsErpVitrine'))
|
|
3307
|
+
.getDocs();
|
|
3308
|
+
if (productSnap.empty)
|
|
3309
|
+
continue;
|
|
3310
|
+
products.push(...productSnap.docs);
|
|
3311
|
+
}
|
|
3312
|
+
return is(products);
|
|
3313
|
+
}
|
|
3314
|
+
getCategoryByShop(shop) {
|
|
3315
|
+
return;
|
|
3316
|
+
}
|
|
3317
|
+
getChildren(parentId) {
|
|
3318
|
+
return;
|
|
3319
|
+
}
|
|
3320
|
+
isChild(id, parentId) {
|
|
3321
|
+
return;
|
|
3322
|
+
}
|
|
3323
|
+
}
|
|
3324
|
+
__decorate([
|
|
3325
|
+
Log(),
|
|
3326
|
+
__metadata("design:type", Function),
|
|
3327
|
+
__metadata("design:paramtypes", [String, String]),
|
|
3328
|
+
__metadata("design:returntype", Promise)
|
|
3329
|
+
], CategoryFirestoreRepository.prototype, "getCategoryBySlug", null);
|
|
3330
|
+
__decorate([
|
|
3331
|
+
Log(),
|
|
3332
|
+
__metadata("design:type", Function),
|
|
3333
|
+
__metadata("design:paramtypes", [Array, Object, String]),
|
|
3334
|
+
__metadata("design:returntype", Promise)
|
|
3335
|
+
], CategoryFirestoreRepository.prototype, "getCategoriesForHome", null);
|
|
3336
|
+
__decorate([
|
|
3337
|
+
Log(),
|
|
3338
|
+
__metadata("design:type", Function),
|
|
3339
|
+
__metadata("design:paramtypes", [Category, Object]),
|
|
3340
|
+
__metadata("design:returntype", Promise)
|
|
3341
|
+
], CategoryFirestoreRepository.prototype, "mountCategory", null);
|
|
3342
|
+
|
|
3343
|
+
class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3344
|
+
constructor({ firestore, interceptors }) {
|
|
3345
|
+
super({
|
|
3346
|
+
firestore,
|
|
3347
|
+
collectionName: 'productsErpVitrine',
|
|
3348
|
+
model: Product,
|
|
3349
|
+
interceptors,
|
|
3350
|
+
});
|
|
3351
|
+
this.reviews = {};
|
|
3352
|
+
}
|
|
3353
|
+
fetchProductReviews(filters) {
|
|
3354
|
+
throw new Error('Method not implemented.');
|
|
3355
|
+
}
|
|
3356
|
+
async getBySlug(slug) {
|
|
3357
|
+
var _a;
|
|
3358
|
+
const result = await this.find({
|
|
3359
|
+
filters: {
|
|
3360
|
+
slug: { operator: Where.EQUALS, value: slug },
|
|
3361
|
+
},
|
|
3362
|
+
});
|
|
3363
|
+
return (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
|
|
3364
|
+
}
|
|
3365
|
+
async fetchReviews(status) {
|
|
3277
3366
|
const { data: products } = await this.find();
|
|
3278
3367
|
products.forEach((product) => {
|
|
3279
3368
|
var _a;
|
|
@@ -3308,9 +3397,6 @@ class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFires
|
|
|
3308
3397
|
async fetchPaginatedReviews() {
|
|
3309
3398
|
return Promise.resolve([]);
|
|
3310
3399
|
}
|
|
3311
|
-
productVariantFullReport() {
|
|
3312
|
-
return;
|
|
3313
|
-
}
|
|
3314
3400
|
}
|
|
3315
3401
|
__decorate([
|
|
3316
3402
|
Log(),
|
|
@@ -3349,101 +3435,6 @@ class SubscriptionProductFirestoreRepository extends withCrudFirestore(withHelpe
|
|
|
3349
3435
|
}
|
|
3350
3436
|
}
|
|
3351
3437
|
|
|
3352
|
-
class LogFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3353
|
-
constructor({ firestore, interceptors, }) {
|
|
3354
|
-
super({
|
|
3355
|
-
firestore,
|
|
3356
|
-
collectionName: 'logs',
|
|
3357
|
-
model: LogDocument,
|
|
3358
|
-
interceptors,
|
|
3359
|
-
});
|
|
3360
|
-
}
|
|
3361
|
-
}
|
|
3362
|
-
|
|
3363
|
-
class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3364
|
-
constructor({ firestore, interceptors }) {
|
|
3365
|
-
super({
|
|
3366
|
-
firestore,
|
|
3367
|
-
collectionName: 'dms',
|
|
3368
|
-
model: Home,
|
|
3369
|
-
interceptors,
|
|
3370
|
-
});
|
|
3371
|
-
this.homeCategoryGroupToPlain = (homeCategoryGroup) => {
|
|
3372
|
-
var _a, _b, _c;
|
|
3373
|
-
return ({
|
|
3374
|
-
category: ((_a = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _a === void 0 ? void 0 : _a.toPlain)
|
|
3375
|
-
? (_b = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _b === void 0 ? void 0 : _b.toPlain()
|
|
3376
|
-
: homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category,
|
|
3377
|
-
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)) || [],
|
|
3378
|
-
});
|
|
3379
|
-
};
|
|
3380
|
-
this.plainToHomeCategoryGroup = (homeCategoryGroup) => {
|
|
3381
|
-
var _a;
|
|
3382
|
-
return ({
|
|
3383
|
-
category: Category.toInstance(homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category),
|
|
3384
|
-
products: (_a = homeCategoryGroup.products) === null || _a === void 0 ? void 0 : _a.map((product) => Product.toInstance(product)),
|
|
3385
|
-
});
|
|
3386
|
-
};
|
|
3387
|
-
}
|
|
3388
|
-
buildModelInstance() {
|
|
3389
|
-
const { fromFirestore, toFirestore } = super.buildModelInstance();
|
|
3390
|
-
return {
|
|
3391
|
-
toFirestore: (data) => {
|
|
3392
|
-
const modifiedData = this.homeToFirestore(data);
|
|
3393
|
-
return toFirestore(modifiedData);
|
|
3394
|
-
},
|
|
3395
|
-
fromFirestore: (snap) => {
|
|
3396
|
-
const instance = fromFirestore(snap);
|
|
3397
|
-
return this.homeFromFirestore(instance);
|
|
3398
|
-
},
|
|
3399
|
-
};
|
|
3400
|
-
}
|
|
3401
|
-
homeToFirestore(home) {
|
|
3402
|
-
var _a, _b, _c, _d;
|
|
3403
|
-
if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
|
|
3404
|
-
home.data.data.discoverProducts = ((_b = home.data.data.discoverProducts) === null || _b === void 0 ? void 0 : _b.map(this.homeCategoryGroupToPlain)) || [];
|
|
3405
|
-
home.data.data.featuredProducts = ((_c = home.data.data.featuredProducts) === null || _c === void 0 ? void 0 : _c.map(this.homeCategoryGroupToPlain)) || [];
|
|
3406
|
-
home.data.data.verticalProducts = ((_d = home.data.data.verticalProducts) === null || _d === void 0 ? void 0 : _d.map(this.homeCategoryGroupToPlain)) || [];
|
|
3407
|
-
}
|
|
3408
|
-
return home;
|
|
3409
|
-
}
|
|
3410
|
-
homeFromFirestore(home) {
|
|
3411
|
-
var _a;
|
|
3412
|
-
if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
|
|
3413
|
-
home.data.data.discoverProducts = home.data.data.discoverProducts.map(this.plainToHomeCategoryGroup);
|
|
3414
|
-
home.data.data.featuredProducts = home.data.data.featuredProducts.map(this.plainToHomeCategoryGroup);
|
|
3415
|
-
home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.plainToHomeCategoryGroup);
|
|
3416
|
-
home.data.createdAt =
|
|
3417
|
-
home.data.createdAt instanceof Timestamp ? home.data.createdAt.toDate() : home.data.createdAt;
|
|
3418
|
-
home.data.expiresAt =
|
|
3419
|
-
home.data.expiresAt instanceof Timestamp ? home.data.expiresAt.toDate() : home.data.expiresAt;
|
|
3420
|
-
}
|
|
3421
|
-
return home;
|
|
3422
|
-
}
|
|
3423
|
-
}
|
|
3424
|
-
|
|
3425
|
-
class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3426
|
-
constructor({ firestore, interceptors }) {
|
|
3427
|
-
super({
|
|
3428
|
-
firestore,
|
|
3429
|
-
collectionName: 'shopMenus',
|
|
3430
|
-
model: ShopMenu,
|
|
3431
|
-
interceptors,
|
|
3432
|
-
});
|
|
3433
|
-
}
|
|
3434
|
-
}
|
|
3435
|
-
|
|
3436
|
-
class ShopSettingsFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3437
|
-
constructor({ firestore, interceptors, }) {
|
|
3438
|
-
super({
|
|
3439
|
-
firestore,
|
|
3440
|
-
collectionName: 'shopSettings',
|
|
3441
|
-
model: ShopSettings,
|
|
3442
|
-
interceptors,
|
|
3443
|
-
});
|
|
3444
|
-
}
|
|
3445
|
-
}
|
|
3446
|
-
|
|
3447
3438
|
class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3448
3439
|
constructor({ firestore, interceptors }) {
|
|
3449
3440
|
super({
|
|
@@ -3556,258 +3547,127 @@ class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFiresto
|
|
|
3556
3547
|
const { fromFirestore, toFirestore } = super.buildModelInstance();
|
|
3557
3548
|
return {
|
|
3558
3549
|
toFirestore: (data) => toFirestore((data === null || data === void 0 ? void 0 : data.toPlain) ? data.toPlain() : data),
|
|
3559
|
-
fromFirestore: (snap) => {
|
|
3560
|
-
const instance = fromFirestore(snap);
|
|
3561
|
-
return this.orderFromFirestore(instance);
|
|
3562
|
-
},
|
|
3563
|
-
};
|
|
3564
|
-
}
|
|
3565
|
-
}
|
|
3566
|
-
|
|
3567
|
-
class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
|
|
3568
|
-
constructor({ firestore, interceptors }) {
|
|
3569
|
-
super({
|
|
3570
|
-
firestore,
|
|
3571
|
-
interceptors,
|
|
3572
|
-
});
|
|
3573
|
-
this.collectionName = 'legacyOrders';
|
|
3574
|
-
}
|
|
3575
|
-
}
|
|
3576
|
-
|
|
3577
|
-
class OrderBlockedFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3578
|
-
constructor({ firestore, interceptors, }) {
|
|
3579
|
-
super({
|
|
3580
|
-
firestore,
|
|
3581
|
-
collectionName: 'paymentBlockedAttempts',
|
|
3582
|
-
model: OrderBlocked,
|
|
3583
|
-
interceptors,
|
|
3584
|
-
});
|
|
3585
|
-
}
|
|
3586
|
-
async createBlockedOrderOrPayment(checkout, blockType, type, limiteRange, card = null) {
|
|
3587
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
3588
|
-
return this.create(OrderBlocked.toInstance({
|
|
3589
|
-
customer: {
|
|
3590
|
-
name: ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.displayName) || '',
|
|
3591
|
-
cpf: ((_b = checkout.user) === null || _b === void 0 ? void 0 : _b.cpf) || '',
|
|
3592
|
-
id: (_c = checkout.user) === null || _c === void 0 ? void 0 : _c.id,
|
|
3593
|
-
email: ((_d = checkout.user) === null || _d === void 0 ? void 0 : _d.email) || '',
|
|
3594
|
-
phoneNumber: '+55' + ((_e = checkout.user) === null || _e === void 0 ? void 0 : _e.phone),
|
|
3595
|
-
isSubscriber: (_f = checkout.user) === null || _f === void 0 ? void 0 : _f.isSubscriber,
|
|
3596
|
-
subscriptionPlan: ((_g = checkout.user) === null || _g === void 0 ? void 0 : _g.subscriptionPlan) || '',
|
|
3597
|
-
shippingAddress: Object.assign(Object.assign({}, checkout.shippingAddress), { zip: this.formatZip((_h = checkout.shippingAddress) === null || _h === void 0 ? void 0 : _h.zip) }),
|
|
3598
|
-
},
|
|
3599
|
-
blockType,
|
|
3600
|
-
limiteRange,
|
|
3601
|
-
type,
|
|
3602
|
-
card,
|
|
3603
|
-
checkout: {
|
|
3604
|
-
id: checkout.id,
|
|
3605
|
-
shop: checkout.shop,
|
|
3606
|
-
total: checkout.totalPrice,
|
|
3607
|
-
},
|
|
3608
|
-
date: new Date(),
|
|
3609
|
-
}));
|
|
3610
|
-
}
|
|
3611
|
-
formatZip(zip) {
|
|
3612
|
-
if (zip.length === 8)
|
|
3613
|
-
return zip.substring(0, 5) + '-' + zip.substring(5, 8);
|
|
3614
|
-
return zip;
|
|
3615
|
-
}
|
|
3616
|
-
}
|
|
3617
|
-
|
|
3618
|
-
class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3619
|
-
constructor({ firestore, interceptors }) {
|
|
3620
|
-
super({
|
|
3621
|
-
firestore,
|
|
3622
|
-
collectionName: 'payments',
|
|
3623
|
-
model: Payment,
|
|
3624
|
-
interceptors,
|
|
3625
|
-
});
|
|
3626
|
-
}
|
|
3627
|
-
}
|
|
3628
|
-
|
|
3629
|
-
class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3630
|
-
constructor({ firestore, interceptors, }) {
|
|
3631
|
-
super({
|
|
3632
|
-
firestore,
|
|
3633
|
-
collectionName: 'subscriptionPlans',
|
|
3634
|
-
model: SubscriptionPlan,
|
|
3635
|
-
interceptors,
|
|
3636
|
-
});
|
|
3637
|
-
}
|
|
3638
|
-
}
|
|
3639
|
-
|
|
3640
|
-
class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3641
|
-
constructor({ firestore, interceptors }) {
|
|
3642
|
-
super({
|
|
3643
|
-
firestore,
|
|
3644
|
-
collectionName: 'leads',
|
|
3645
|
-
model: Lead,
|
|
3646
|
-
interceptors,
|
|
3647
|
-
});
|
|
3648
|
-
}
|
|
3649
|
-
}
|
|
3650
|
-
|
|
3651
|
-
class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3652
|
-
constructor({ firestore, interceptors }, parentRepository) {
|
|
3653
|
-
super({
|
|
3654
|
-
firestore,
|
|
3655
|
-
collectionName: 'editions',
|
|
3656
|
-
parentIdField: 'subscriptionId',
|
|
3657
|
-
model: Edition,
|
|
3658
|
-
interceptors,
|
|
3659
|
-
});
|
|
3660
|
-
this.parentRepository = parentRepository;
|
|
3661
|
-
}
|
|
3662
|
-
}
|
|
3663
|
-
|
|
3664
|
-
class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3665
|
-
constructor({ firestore, interceptors, }) {
|
|
3666
|
-
super({
|
|
3667
|
-
firestore,
|
|
3668
|
-
collectionName: 'subscription',
|
|
3669
|
-
model: Subscription,
|
|
3670
|
-
interceptors,
|
|
3671
|
-
});
|
|
3550
|
+
fromFirestore: (snap) => {
|
|
3551
|
+
const instance = fromFirestore(snap);
|
|
3552
|
+
return this.orderFromFirestore(instance);
|
|
3553
|
+
},
|
|
3554
|
+
};
|
|
3672
3555
|
}
|
|
3673
3556
|
}
|
|
3674
3557
|
|
|
3675
|
-
class
|
|
3558
|
+
class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
|
|
3676
3559
|
constructor({ firestore, interceptors }) {
|
|
3677
3560
|
super({
|
|
3678
3561
|
firestore,
|
|
3679
|
-
collectionName: 'subscriptionMaterialization',
|
|
3680
|
-
model: SubscriptionMaterialization,
|
|
3681
3562
|
interceptors,
|
|
3682
3563
|
});
|
|
3564
|
+
this.collectionName = 'legacyOrders';
|
|
3683
3565
|
}
|
|
3684
3566
|
}
|
|
3685
3567
|
|
|
3686
|
-
class
|
|
3687
|
-
constructor({ firestore, interceptors }
|
|
3568
|
+
class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3569
|
+
constructor({ firestore, interceptors }) {
|
|
3688
3570
|
super({
|
|
3689
3571
|
firestore,
|
|
3690
3572
|
collectionName: 'payments',
|
|
3691
|
-
|
|
3692
|
-
model: SubscriptionPayment,
|
|
3573
|
+
model: Payment,
|
|
3693
3574
|
interceptors,
|
|
3694
3575
|
});
|
|
3695
|
-
this.parentRepository = parentRepository;
|
|
3696
3576
|
}
|
|
3697
3577
|
}
|
|
3698
3578
|
|
|
3699
|
-
class
|
|
3579
|
+
class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3700
3580
|
constructor({ firestore, interceptors, }) {
|
|
3701
3581
|
super({
|
|
3702
3582
|
firestore,
|
|
3703
|
-
collectionName: '
|
|
3704
|
-
model:
|
|
3705
|
-
interceptors,
|
|
3706
|
-
});
|
|
3707
|
-
}
|
|
3708
|
-
}
|
|
3709
|
-
|
|
3710
|
-
class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3711
|
-
constructor({ firestore, interceptors }, parentRepository) {
|
|
3712
|
-
super({
|
|
3713
|
-
firestore,
|
|
3714
|
-
collectionName: 'address',
|
|
3715
|
-
parentIdField: 'userId',
|
|
3716
|
-
model: UserAddress,
|
|
3717
|
-
interceptors,
|
|
3718
|
-
});
|
|
3719
|
-
this.parentRepository = parentRepository;
|
|
3720
|
-
}
|
|
3721
|
-
}
|
|
3722
|
-
|
|
3723
|
-
class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3724
|
-
constructor({ firestore, interceptors }, parentRepository) {
|
|
3725
|
-
super({
|
|
3726
|
-
firestore,
|
|
3727
|
-
collectionName: 'CX',
|
|
3728
|
-
parentIdField: 'userId',
|
|
3729
|
-
model: BeautyProfile,
|
|
3583
|
+
collectionName: 'subscriptionPlans',
|
|
3584
|
+
model: SubscriptionPlan,
|
|
3730
3585
|
interceptors,
|
|
3731
3586
|
});
|
|
3732
|
-
this.parentRepository = parentRepository;
|
|
3733
3587
|
}
|
|
3734
3588
|
}
|
|
3735
3589
|
|
|
3736
|
-
class
|
|
3590
|
+
class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3737
3591
|
constructor({ firestore, interceptors }) {
|
|
3738
3592
|
super({
|
|
3739
3593
|
firestore,
|
|
3740
|
-
collectionName: '
|
|
3741
|
-
model:
|
|
3594
|
+
collectionName: 'dms',
|
|
3595
|
+
model: Home,
|
|
3742
3596
|
interceptors,
|
|
3743
3597
|
});
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3598
|
+
this.homeCategoryGroupToPlain = (homeCategoryGroup) => {
|
|
3599
|
+
var _a, _b, _c;
|
|
3600
|
+
return ({
|
|
3601
|
+
category: ((_a = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _a === void 0 ? void 0 : _a.toPlain)
|
|
3602
|
+
? (_b = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _b === void 0 ? void 0 : _b.toPlain()
|
|
3603
|
+
: homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category,
|
|
3604
|
+
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)) || [],
|
|
3605
|
+
});
|
|
3606
|
+
};
|
|
3607
|
+
this.plainToHomeCategoryGroup = (homeCategoryGroup) => {
|
|
3608
|
+
var _a;
|
|
3609
|
+
return ({
|
|
3610
|
+
category: Category.toInstance(homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category),
|
|
3611
|
+
products: (_a = homeCategoryGroup.products) === null || _a === void 0 ? void 0 : _a.map((product) => Product.toInstance(product)),
|
|
3612
|
+
});
|
|
3613
|
+
};
|
|
3754
3614
|
}
|
|
3755
3615
|
buildModelInstance() {
|
|
3756
3616
|
const { fromFirestore, toFirestore } = super.buildModelInstance();
|
|
3757
3617
|
return {
|
|
3758
3618
|
toFirestore: (data) => {
|
|
3759
|
-
const
|
|
3760
|
-
|
|
3761
|
-
|
|
3619
|
+
const modifiedData = this.homeToFirestore(data);
|
|
3620
|
+
return toFirestore(modifiedData);
|
|
3621
|
+
},
|
|
3622
|
+
fromFirestore: (snap) => {
|
|
3623
|
+
const instance = fromFirestore(snap);
|
|
3624
|
+
return this.homeFromFirestore(instance);
|
|
3762
3625
|
},
|
|
3763
|
-
fromFirestore,
|
|
3764
3626
|
};
|
|
3765
3627
|
}
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
.
|
|
3770
|
-
.
|
|
3771
|
-
.
|
|
3772
|
-
|
|
3628
|
+
homeToFirestore(home) {
|
|
3629
|
+
var _a, _b, _c, _d;
|
|
3630
|
+
if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
|
|
3631
|
+
home.data.data.discoverProducts = ((_b = home.data.data.discoverProducts) === null || _b === void 0 ? void 0 : _b.map(this.homeCategoryGroupToPlain)) || [];
|
|
3632
|
+
home.data.data.featuredProducts = ((_c = home.data.data.featuredProducts) === null || _c === void 0 ? void 0 : _c.map(this.homeCategoryGroupToPlain)) || [];
|
|
3633
|
+
home.data.data.verticalProducts = ((_d = home.data.data.verticalProducts) === null || _d === void 0 ? void 0 : _d.map(this.homeCategoryGroupToPlain)) || [];
|
|
3634
|
+
}
|
|
3635
|
+
return home;
|
|
3773
3636
|
}
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
.
|
|
3778
|
-
.
|
|
3779
|
-
|
|
3637
|
+
homeFromFirestore(home) {
|
|
3638
|
+
var _a;
|
|
3639
|
+
if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
|
|
3640
|
+
home.data.data.discoverProducts = home.data.data.discoverProducts.map(this.plainToHomeCategoryGroup);
|
|
3641
|
+
home.data.data.featuredProducts = home.data.data.featuredProducts.map(this.plainToHomeCategoryGroup);
|
|
3642
|
+
home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.plainToHomeCategoryGroup);
|
|
3643
|
+
home.data.createdAt =
|
|
3644
|
+
home.data.createdAt instanceof Timestamp ? home.data.createdAt.toDate() : home.data.createdAt;
|
|
3645
|
+
home.data.expiresAt =
|
|
3646
|
+
home.data.expiresAt instanceof Timestamp ? home.data.expiresAt.toDate() : home.data.expiresAt;
|
|
3647
|
+
}
|
|
3648
|
+
return home;
|
|
3780
3649
|
}
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3650
|
+
}
|
|
3651
|
+
|
|
3652
|
+
class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3653
|
+
constructor({ firestore, interceptors }) {
|
|
3654
|
+
super({
|
|
3655
|
+
firestore,
|
|
3656
|
+
collectionName: 'shopMenus',
|
|
3657
|
+
model: ShopMenu,
|
|
3658
|
+
interceptors,
|
|
3659
|
+
});
|
|
3786
3660
|
}
|
|
3787
3661
|
}
|
|
3788
|
-
__decorate([
|
|
3789
|
-
Log(),
|
|
3790
|
-
__metadata("design:type", Function),
|
|
3791
|
-
__metadata("design:paramtypes", [Object]),
|
|
3792
|
-
__metadata("design:returntype", Promise)
|
|
3793
|
-
], UserFirestoreRepository.prototype, "get", null);
|
|
3794
|
-
__decorate([
|
|
3795
|
-
Log(),
|
|
3796
|
-
__metadata("design:type", Function),
|
|
3797
|
-
__metadata("design:paramtypes", [String, String]),
|
|
3798
|
-
__metadata("design:returntype", Promise)
|
|
3799
|
-
], UserFirestoreRepository.prototype, "checkIfExistsByField", null);
|
|
3800
3662
|
|
|
3801
|
-
class
|
|
3802
|
-
constructor({ firestore, interceptors }
|
|
3663
|
+
class ShopSettingsFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3664
|
+
constructor({ firestore, interceptors, }) {
|
|
3803
3665
|
super({
|
|
3804
3666
|
firestore,
|
|
3805
|
-
collectionName: '
|
|
3806
|
-
|
|
3807
|
-
model: UserPaymentMethod,
|
|
3667
|
+
collectionName: 'shopSettings',
|
|
3668
|
+
model: ShopSettings,
|
|
3808
3669
|
interceptors,
|
|
3809
3670
|
});
|
|
3810
|
-
this.parentRepository = parentRepository;
|
|
3811
3671
|
}
|
|
3812
3672
|
}
|
|
3813
3673
|
|
|
@@ -4360,7 +4220,7 @@ const withHasuraGraphQL = (MixinBase) => {
|
|
|
4360
4220
|
const response = await axios(request);
|
|
4361
4221
|
if (!isNil(response.data.errors)) {
|
|
4362
4222
|
this.logger.error({ req: request, res: response.data.errors });
|
|
4363
|
-
throw new Error(
|
|
4223
|
+
throw new Error(response.data.errors);
|
|
4364
4224
|
}
|
|
4365
4225
|
this.logger.log({ req: request, res: response.data });
|
|
4366
4226
|
return response.data.data;
|
|
@@ -4501,7 +4361,6 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
4501
4361
|
return class FindHasuraGraphQLMixin extends MixinBase {
|
|
4502
4362
|
constructor() {
|
|
4503
4363
|
super(...arguments);
|
|
4504
|
-
this.lastDistinct = {};
|
|
4505
4364
|
this.bindOrderByAttributes = (orderBy, fields) => Object.keys(orderBy).reduce((acc, current) => [
|
|
4506
4365
|
...acc,
|
|
4507
4366
|
{
|
|
@@ -4537,10 +4396,9 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
4537
4396
|
});
|
|
4538
4397
|
}
|
|
4539
4398
|
async find(params) {
|
|
4540
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
4399
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
4541
4400
|
this.logger = DebugHelper.from(this, 'find');
|
|
4542
4401
|
const { filters, limits, orderBy, options } = params || {};
|
|
4543
|
-
const tableFiltersNamed = `${this.tableName}:${JSON.stringify(filters)}`;
|
|
4544
4402
|
const enableCount = (_a = options === null || options === void 0 ? void 0 : options.enableCount) !== null && _a !== void 0 ? _a : true;
|
|
4545
4403
|
const variablesFilters = isNil(filters)
|
|
4546
4404
|
? {}
|
|
@@ -4591,8 +4449,8 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
4591
4449
|
},
|
|
4592
4450
|
]
|
|
4593
4451
|
: []),
|
|
4594
|
-
...((!
|
|
4595
|
-
((
|
|
4452
|
+
...((!((_b = params.limits) === null || _b === void 0 ? void 0 : _b.offset) &&
|
|
4453
|
+
((_d = (_c = params.options) === null || _c === void 0 ? void 0 : _c.distinct) === null || _d === void 0 ? void 0 : _d.map((distinct) => {
|
|
4596
4454
|
var _a, _b;
|
|
4597
4455
|
const distinctOption = (_a = this.fields.find((fieldOption) => fieldOption === distinct)) !== null && _a !== void 0 ? _a : this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === distinct);
|
|
4598
4456
|
const fieldName = ((_b = Object.values(distinctOption).shift()) === null || _b === void 0 ? void 0 : _b.columnName) || distinct;
|
|
@@ -4613,27 +4471,28 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
4613
4471
|
[]),
|
|
4614
4472
|
]);
|
|
4615
4473
|
const data = result[this.tableName].map((row) => this.convertDataFromHasura(row));
|
|
4616
|
-
return Object.assign(Object.assign(Object.assign({ data, count: enableCount ? result[`${this.tableName}_aggregate`].aggregate.count : Infinity }, (((
|
|
4474
|
+
return Object.assign(Object.assign(Object.assign({ data, count: enableCount ? result[`${this.tableName}_aggregate`].aggregate.count : Infinity }, (((_e = options === null || options === void 0 ? void 0 : options.minimal) === null || _e === void 0 ? void 0 : _e.length)
|
|
4617
4475
|
? {
|
|
4618
4476
|
minimal: options.minimal.reduce((minimals, current) => {
|
|
4619
4477
|
var _a;
|
|
4620
4478
|
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])));
|
|
4621
4479
|
}, {}),
|
|
4622
4480
|
}
|
|
4623
|
-
: {})), (((
|
|
4481
|
+
: {})), (((_f = options === null || options === void 0 ? void 0 : options.maximum) === null || _f === void 0 ? void 0 : _f.length)
|
|
4624
4482
|
? {
|
|
4625
4483
|
maximum: options.maximum.reduce((maximums, current) => {
|
|
4626
4484
|
var _a;
|
|
4627
4485
|
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])));
|
|
4628
4486
|
}, {}),
|
|
4629
4487
|
}
|
|
4630
|
-
: {})), (((
|
|
4631
|
-
|
|
4488
|
+
: {})), (!((_g = params.limits) === null || _g === void 0 ? void 0 : _g.offset) &&
|
|
4489
|
+
((_h = options === null || options === void 0 ? void 0 : options.distinct) === null || _h === void 0 ? void 0 : _h.length) && {
|
|
4490
|
+
distinct: options === null || options === void 0 ? void 0 : options.distinct.reduce((distinct, current) => {
|
|
4632
4491
|
var _a, _b;
|
|
4633
4492
|
const distinctOption = (_a = this.fields.find((fieldOption) => fieldOption === current)) !== null && _a !== void 0 ? _a : this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === current);
|
|
4634
4493
|
const fieldName = ((_b = Object.values(distinctOption).shift()) === null || _b === void 0 ? void 0 : _b.columnName) || current;
|
|
4635
4494
|
return Object.assign(Object.assign({}, distinct), { [current.toString()]: result[`${this.tableName}_${current.toString()}_distinct`].map((obj) => obj[fieldName]) });
|
|
4636
|
-
}, {})
|
|
4495
|
+
}, {}),
|
|
4637
4496
|
}));
|
|
4638
4497
|
}
|
|
4639
4498
|
};
|
|
@@ -4728,7 +4587,6 @@ class CategoryFilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHa
|
|
|
4728
4587
|
fields: [
|
|
4729
4588
|
'id',
|
|
4730
4589
|
'description',
|
|
4731
|
-
'title',
|
|
4732
4590
|
'slug',
|
|
4733
4591
|
'enabled',
|
|
4734
4592
|
{ createdAt: { columnName: 'created_at' } },
|
|
@@ -4873,11 +4731,11 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4873
4731
|
filters: {
|
|
4874
4732
|
columnName: 'filters',
|
|
4875
4733
|
foreignKeyColumn: { filter_id: 'id' },
|
|
4876
|
-
fields: [{ filter: ['id', '
|
|
4734
|
+
fields: [{ filter: ['id', 'description', 'slug', 'enabled'] }],
|
|
4877
4735
|
bindPersistData: (value) => ({
|
|
4878
4736
|
filters: { data: value.map((filter) => ({ filter_id: filter.id })) },
|
|
4879
4737
|
}),
|
|
4880
|
-
from: (filters) => (filters === null || filters === void 0 ? void 0 : filters.map((filter) => filter === null || filter === void 0 ? void 0 : filter.filter)
|
|
4738
|
+
from: (filters) => (filters === null || filters === void 0 ? void 0 : filters.map((filter) => filter === null || filter === void 0 ? void 0 : filter.filter)) || [],
|
|
4881
4739
|
},
|
|
4882
4740
|
},
|
|
4883
4741
|
{ createdAt: { columnName: 'created_at' } },
|
|
@@ -4902,15 +4760,6 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4902
4760
|
}),
|
|
4903
4761
|
},
|
|
4904
4762
|
},
|
|
4905
|
-
{
|
|
4906
|
-
metadatas: {
|
|
4907
|
-
columnName: 'metadatas',
|
|
4908
|
-
fields: ['shop', 'title', 'description'],
|
|
4909
|
-
bindPersistData: (value) => ({
|
|
4910
|
-
metadatas: { data: value },
|
|
4911
|
-
}),
|
|
4912
|
-
},
|
|
4913
|
-
},
|
|
4914
4763
|
{ isCollection: { columnName: 'is_collection' } },
|
|
4915
4764
|
{ isWishlist: { columnName: 'is_wishlist' } },
|
|
4916
4765
|
'reference',
|
|
@@ -4925,29 +4774,14 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4925
4774
|
'theme',
|
|
4926
4775
|
{ bannerUrl: { columnName: 'banner_url' } },
|
|
4927
4776
|
{ mostRelevant: { columnName: 'most_relevant', type: HasuraGraphQLColumnType.Jsonb } },
|
|
4928
|
-
{ mostRelevants: { columnName: 'most_relevants', type: HasuraGraphQLColumnType.Jsonb } },
|
|
4929
4777
|
],
|
|
4930
4778
|
});
|
|
4931
4779
|
this.productRepository = productRepository;
|
|
4932
4780
|
this.categoryFilterRepository = categoryFilterRepository;
|
|
4933
4781
|
}
|
|
4934
4782
|
async create(params) {
|
|
4935
|
-
const {
|
|
4936
|
-
return super.create(Object.assign(Object.assign({}, data), { isWishlist: false,
|
|
4937
|
-
[Shops.GLAMSHOP]: null,
|
|
4938
|
-
[Shops.MENSMARKET]: null,
|
|
4939
|
-
}, images: images || {
|
|
4940
|
-
[Shops.GLAMSHOP]: {
|
|
4941
|
-
brandBanner: null,
|
|
4942
|
-
brandBannerMobile: null,
|
|
4943
|
-
image: null,
|
|
4944
|
-
},
|
|
4945
|
-
[Shops.MENSMARKET]: {
|
|
4946
|
-
brandBanner: null,
|
|
4947
|
-
brandBannerMobile: null,
|
|
4948
|
-
image: null,
|
|
4949
|
-
},
|
|
4950
|
-
} }));
|
|
4783
|
+
const { metadata } = params, data = __rest(params, ["metadata"]);
|
|
4784
|
+
return super.create(Object.assign(Object.assign({}, data), { isWishlist: false, metadata: metadata || [{ shop: null, description: null, title: null }] }));
|
|
4951
4785
|
}
|
|
4952
4786
|
async get(identifiers) {
|
|
4953
4787
|
var _a;
|
|
@@ -4956,12 +4790,12 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4956
4790
|
: super.get(identifiers);
|
|
4957
4791
|
}
|
|
4958
4792
|
async update(params) {
|
|
4959
|
-
const { products, id: checkId,
|
|
4793
|
+
const { products, id: checkId, metadata, filters } = params, data = __rest(params, ["products", "id", "metadata", "filters"]);
|
|
4960
4794
|
const plainData = this.paramsToPlain({ id: checkId });
|
|
4961
4795
|
const id = await this.getId(plainData.id);
|
|
4962
4796
|
const category = await super.update(Object.assign(Object.assign({ id }, data), { isWishlist: false }));
|
|
4963
4797
|
category.products = products && (await this.updateProducts(+id, { products }));
|
|
4964
|
-
category.
|
|
4798
|
+
category.metadata = metadata && (await this.updateMetadata(+id, { metadata }));
|
|
4965
4799
|
category.filters = filters && (await this.updateFilters(+id, { filters }));
|
|
4966
4800
|
return category;
|
|
4967
4801
|
}
|
|
@@ -4999,7 +4833,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4999
4833
|
});
|
|
5000
4834
|
return data;
|
|
5001
4835
|
}
|
|
5002
|
-
async getCategoriesForHome(categoryIds,
|
|
4836
|
+
async getCategoriesForHome(categoryIds, limit = 4, gender) {
|
|
5003
4837
|
if (!(categoryIds === null || categoryIds === void 0 ? void 0 : categoryIds.length))
|
|
5004
4838
|
return [];
|
|
5005
4839
|
const categoriesFirestore = categoryIds.filter((categoryId) => Number.isNaN(+categoryId));
|
|
@@ -5011,32 +4845,22 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
5011
4845
|
}).then(({ data }) => data)));
|
|
5012
4846
|
if (categoriesHasura.length)
|
|
5013
4847
|
categories.push(...(await this.find({
|
|
5014
|
-
filters: {
|
|
5015
|
-
id: { operator: Where.IN, value: categoriesHasura.filter(Boolean) },
|
|
5016
|
-
published: true,
|
|
5017
|
-
},
|
|
4848
|
+
filters: { id: { operator: Where.IN, value: categoriesHasura.filter(Boolean) }, published: true },
|
|
5018
4849
|
}).then(({ data }) => data)));
|
|
5019
4850
|
if (!categories.length)
|
|
5020
4851
|
return [];
|
|
5021
4852
|
const homeSections = await Promise.all(categories.map(async (category) => ({
|
|
5022
4853
|
category,
|
|
5023
|
-
products: await this.mountCategory(category,
|
|
4854
|
+
products: await this.mountCategory(category, { limit, hasStock: true, gender }),
|
|
5024
4855
|
})));
|
|
5025
4856
|
return homeSections;
|
|
5026
4857
|
}
|
|
5027
|
-
async mountCategory(category,
|
|
4858
|
+
async mountCategory(category, options) {
|
|
5028
4859
|
var _a;
|
|
5029
4860
|
if (!((_a = category === null || category === void 0 ? void 0 : category.products) === null || _a === void 0 ? void 0 : _a.length))
|
|
5030
4861
|
return [];
|
|
5031
|
-
const mostRelevants = category.getMostRelevantByShop(shop);
|
|
5032
|
-
const mostRelevantProductsIds = [...new Set(mostRelevants.concat(category.products))];
|
|
5033
4862
|
const products = [];
|
|
5034
|
-
const { data: productsData } = await this.productRepository.
|
|
5035
|
-
filters: {
|
|
5036
|
-
id: { operator: Where.IN, value: mostRelevantProductsIds },
|
|
5037
|
-
published: true,
|
|
5038
|
-
},
|
|
5039
|
-
fields: [
|
|
4863
|
+
const { data: productsData } = await this.productRepository.find(Object.assign(Object.assign({ filters: Object.assign(Object.assign({ id: { operator: Where.IN, value: category.products }, published: true }, ((options === null || options === void 0 ? void 0 : options.hasStock) ? { stock: { quantity: { operator: Where.GT, value: 0 } } } : {})), ((options === null || options === void 0 ? void 0 : options.gender) ? { tags: { operator: Where.IN, value: [options === null || options === void 0 ? void 0 : options.gender] } } : {})), fields: [
|
|
5040
4864
|
'id',
|
|
5041
4865
|
'name',
|
|
5042
4866
|
'slug',
|
|
@@ -5062,25 +4886,8 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
5062
4886
|
'shoppingCount',
|
|
5063
4887
|
'gender',
|
|
5064
4888
|
'createdAt',
|
|
5065
|
-
],
|
|
5066
|
-
|
|
5067
|
-
orderBy: {
|
|
5068
|
-
shoppingCount: 'desc',
|
|
5069
|
-
rate: 'desc',
|
|
5070
|
-
stock: 'desc',
|
|
5071
|
-
name: 'asc',
|
|
5072
|
-
},
|
|
5073
|
-
}, shop === Shops.MENSMARKET ? 'male' : 'female');
|
|
5074
|
-
const mostRelevantWithouyStock = productsData.filter((product) => mostRelevants.includes(product.id) && product.stock.quantity <= 0);
|
|
5075
|
-
const firstProducts = productsData
|
|
5076
|
-
.filter((product) => mostRelevants.includes(product.id) && product.stock.quantity > 0)
|
|
5077
|
-
.sort((a, b) => mostRelevants.indexOf(a.id) - mostRelevants.indexOf(b.id));
|
|
5078
|
-
const lastProducts = productsData
|
|
5079
|
-
.filter((product) => !mostRelevants.includes(product.id) && product.stock.quantity > 0)
|
|
5080
|
-
.concat(mostRelevantWithouyStock);
|
|
5081
|
-
const categoryMostRelevants = firstProducts.concat(lastProducts);
|
|
5082
|
-
const resultFinal = categoryMostRelevants.slice(0, options.limit);
|
|
5083
|
-
products.push(...resultFinal);
|
|
4889
|
+
] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})), { options: { enableCount: false } }));
|
|
4890
|
+
products.push(...productsData);
|
|
5084
4891
|
return products;
|
|
5085
4892
|
}
|
|
5086
4893
|
async getChildren(parentId) {
|
|
@@ -5117,6 +4924,29 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
5117
4924
|
});
|
|
5118
4925
|
return [];
|
|
5119
4926
|
}
|
|
4927
|
+
const plainData = this.paramsToPlain({ products });
|
|
4928
|
+
if (!plainData.products || plainData.products.length <= 0)
|
|
4929
|
+
return [];
|
|
4930
|
+
const category = await this.get({ id: categoryId.toString() });
|
|
4931
|
+
await this.mutation('delete_category_product', ['affected_rows'], {
|
|
4932
|
+
where: {
|
|
4933
|
+
type: 'category_product_bool_exp',
|
|
4934
|
+
required: true,
|
|
4935
|
+
value: {
|
|
4936
|
+
category_id: { _eq: categoryId },
|
|
4937
|
+
product_id: { _in: category.products.filter((productId) => !plainData.products.includes(productId)) },
|
|
4938
|
+
},
|
|
4939
|
+
},
|
|
4940
|
+
});
|
|
4941
|
+
await this.mutation('insert_category_product', ['affected_rows'], {
|
|
4942
|
+
objects: {
|
|
4943
|
+
type: '[category_product_insert_input!]',
|
|
4944
|
+
required: true,
|
|
4945
|
+
value: plainData.products
|
|
4946
|
+
.filter((productId) => !category.products.includes(productId))
|
|
4947
|
+
.map((productId) => ({ category_id: categoryId, product_id: productId })),
|
|
4948
|
+
},
|
|
4949
|
+
});
|
|
5120
4950
|
const productsOrder = products.map((product, index) => {
|
|
5121
4951
|
return {
|
|
5122
4952
|
id: product,
|
|
@@ -5125,7 +4955,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
5125
4955
|
});
|
|
5126
4956
|
const updateQueries = productsOrder.map((product) => ({
|
|
5127
4957
|
where: {
|
|
5128
|
-
category_id: { _eq:
|
|
4958
|
+
category_id: { _eq: category.id },
|
|
5129
4959
|
product_id: { _eq: product.id },
|
|
5130
4960
|
},
|
|
5131
4961
|
_set: {
|
|
@@ -5139,13 +4969,13 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
5139
4969
|
required: true,
|
|
5140
4970
|
},
|
|
5141
4971
|
});
|
|
5142
|
-
const plainData = this.paramsToPlain({ products });
|
|
5143
4972
|
return plainData.products;
|
|
5144
4973
|
}
|
|
5145
|
-
async updateMetadata(categoryId, {
|
|
5146
|
-
if (Array.isArray(
|
|
4974
|
+
async updateMetadata(categoryId, { metadata }) {
|
|
4975
|
+
if (Array.isArray(metadata) && !metadata.length)
|
|
5147
4976
|
return [];
|
|
5148
|
-
if (Array.isArray(
|
|
4977
|
+
if (Array.isArray(metadata) && metadata.length) {
|
|
4978
|
+
const metadataUpdated = [];
|
|
5149
4979
|
await this.mutation('delete_category_metadata', ['affected_rows'], {
|
|
5150
4980
|
where: {
|
|
5151
4981
|
type: 'category_metadata_bool_exp',
|
|
@@ -5153,16 +4983,24 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
5153
4983
|
value: { category_id: { _eq: categoryId } },
|
|
5154
4984
|
},
|
|
5155
4985
|
});
|
|
5156
|
-
|
|
5157
|
-
|
|
5158
|
-
|
|
5159
|
-
|
|
5160
|
-
|
|
5161
|
-
|
|
5162
|
-
|
|
5163
|
-
|
|
4986
|
+
for (const data of metadata) {
|
|
4987
|
+
const update = await this.mutation('update_category_metadata_by_pk', ['category_id', 'shop'], {
|
|
4988
|
+
pk_columns: {
|
|
4989
|
+
value: { category_id: categoryId, shop: data.shop },
|
|
4990
|
+
type: 'category_metadata_pk_columns_input',
|
|
4991
|
+
required: true,
|
|
4992
|
+
},
|
|
4993
|
+
_set: {
|
|
4994
|
+
value: omit(data, ['category_id', 'shop']),
|
|
4995
|
+
type: 'category_metadata_set_input',
|
|
4996
|
+
required: true,
|
|
4997
|
+
},
|
|
4998
|
+
});
|
|
4999
|
+
metadataUpdated.push(update);
|
|
5000
|
+
}
|
|
5001
|
+
return metadataUpdated;
|
|
5164
5002
|
}
|
|
5165
|
-
if ('action' in
|
|
5003
|
+
if ('action' in metadata && metadata.action === 'remove' && metadata.value.length) {
|
|
5166
5004
|
await this.mutation('delete_category_metadata', ['affected_rows'], {
|
|
5167
5005
|
where: {
|
|
5168
5006
|
type: 'category_metadata_bool_exp',
|
|
@@ -5233,61 +5071,27 @@ __decorate([
|
|
|
5233
5071
|
__decorate([
|
|
5234
5072
|
Log(),
|
|
5235
5073
|
__metadata("design:type", Function),
|
|
5236
|
-
__metadata("design:paramtypes", [Array,
|
|
5074
|
+
__metadata("design:paramtypes", [Array, Object, String]),
|
|
5237
5075
|
__metadata("design:returntype", Promise)
|
|
5238
5076
|
], CategoryHasuraGraphQLRepository.prototype, "getCategoriesForHome", null);
|
|
5239
5077
|
__decorate([
|
|
5240
5078
|
Log(),
|
|
5241
5079
|
__metadata("design:type", Function),
|
|
5242
|
-
__metadata("design:paramtypes", [Category,
|
|
5080
|
+
__metadata("design:paramtypes", [Category, Object]),
|
|
5243
5081
|
__metadata("design:returntype", Promise)
|
|
5244
5082
|
], CategoryHasuraGraphQLRepository.prototype, "mountCategory", null);
|
|
5245
5083
|
__decorate([
|
|
5246
|
-
Log(),
|
|
5247
|
-
__metadata("design:type", Function),
|
|
5248
|
-
__metadata("design:paramtypes", [Number]),
|
|
5249
|
-
__metadata("design:returntype", Promise)
|
|
5250
|
-
], CategoryHasuraGraphQLRepository.prototype, "getChildren", null);
|
|
5251
|
-
__decorate([
|
|
5252
|
-
Log(),
|
|
5253
|
-
__metadata("design:type", Function),
|
|
5254
|
-
__metadata("design:paramtypes", [Number, Number]),
|
|
5255
|
-
__metadata("design:returntype", Promise)
|
|
5256
|
-
], CategoryHasuraGraphQLRepository.prototype, "isChild", null);
|
|
5257
|
-
|
|
5258
|
-
class CategoryProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
5259
|
-
constructor({ endpoint, authOptions, interceptors, }) {
|
|
5260
|
-
super({
|
|
5261
|
-
tableName: 'category_product',
|
|
5262
|
-
model: CategoryProduct,
|
|
5263
|
-
endpoint,
|
|
5264
|
-
authOptions,
|
|
5265
|
-
interceptors,
|
|
5266
|
-
fields: [{ productId: { columnName: 'product_id' } }, { categoryId: { columnName: 'category_id' } }, 'order'],
|
|
5267
|
-
});
|
|
5268
|
-
}
|
|
5269
|
-
async removeProductFromCategory(categoryId, productId) {
|
|
5270
|
-
await this.mutation('delete_category_product', ['affected_rows'], {
|
|
5271
|
-
where: {
|
|
5272
|
-
type: 'category_product_bool_exp',
|
|
5273
|
-
required: true,
|
|
5274
|
-
value: {
|
|
5275
|
-
product_id: { _eq: productId },
|
|
5276
|
-
category_id: { _eq: categoryId },
|
|
5277
|
-
},
|
|
5278
|
-
},
|
|
5279
|
-
});
|
|
5280
|
-
}
|
|
5281
|
-
async addProductToCategory(categoryId, productId) {
|
|
5282
|
-
await this.mutation('insert_category_product', ['affected_rows'], {
|
|
5283
|
-
objects: {
|
|
5284
|
-
type: '[category_product_insert_input!]',
|
|
5285
|
-
required: true,
|
|
5286
|
-
value: [{ category_id: categoryId, product_id: productId }],
|
|
5287
|
-
},
|
|
5288
|
-
});
|
|
5289
|
-
}
|
|
5290
|
-
}
|
|
5084
|
+
Log(),
|
|
5085
|
+
__metadata("design:type", Function),
|
|
5086
|
+
__metadata("design:paramtypes", [Number]),
|
|
5087
|
+
__metadata("design:returntype", Promise)
|
|
5088
|
+
], CategoryHasuraGraphQLRepository.prototype, "getChildren", null);
|
|
5089
|
+
__decorate([
|
|
5090
|
+
Log(),
|
|
5091
|
+
__metadata("design:type", Function),
|
|
5092
|
+
__metadata("design:paramtypes", [Number, Number]),
|
|
5093
|
+
__metadata("design:returntype", Promise)
|
|
5094
|
+
], CategoryHasuraGraphQLRepository.prototype, "isChild", null);
|
|
5291
5095
|
|
|
5292
5096
|
class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
5293
5097
|
constructor({ endpoint, authOptions, interceptors, }, filterOptionRepository, categoryFilterRepository) {
|
|
@@ -5299,7 +5103,6 @@ class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGrap
|
|
|
5299
5103
|
interceptors,
|
|
5300
5104
|
fields: [
|
|
5301
5105
|
'id',
|
|
5302
|
-
'title',
|
|
5303
5106
|
'description',
|
|
5304
5107
|
'slug',
|
|
5305
5108
|
'enabled',
|
|
@@ -5555,7 +5358,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
5555
5358
|
{ subscriberPrice: { columnName: 'subscriber_price' } },
|
|
5556
5359
|
'published',
|
|
5557
5360
|
'outlet',
|
|
5558
|
-
'label',
|
|
5559
5361
|
'sku',
|
|
5560
5362
|
{
|
|
5561
5363
|
stock: {
|
|
@@ -5587,8 +5389,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
5587
5389
|
fields: ['id', 'name', 'reference', 'slug'],
|
|
5588
5390
|
},
|
|
5589
5391
|
},
|
|
5590
|
-
'group',
|
|
5591
|
-
'validity',
|
|
5592
5392
|
];
|
|
5593
5393
|
this.fields = [
|
|
5594
5394
|
...commonFields,
|
|
@@ -5690,8 +5490,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
5690
5490
|
enableCount: false,
|
|
5691
5491
|
},
|
|
5692
5492
|
});
|
|
5693
|
-
if (!result.data.length)
|
|
5694
|
-
return null;
|
|
5695
5493
|
const product = (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
|
|
5696
5494
|
RoundProductPricesHelper.roundProductPrices(product);
|
|
5697
5495
|
return product;
|
|
@@ -5701,6 +5499,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
5701
5499
|
const plainData = this.paramsToPlain({ id: checkId });
|
|
5702
5500
|
const id = await this.getId(plainData.id);
|
|
5703
5501
|
const product = await super.update(Object.assign({ id }, data));
|
|
5502
|
+
product.categories = categories && (await this.updateCategories(+id, { categories }));
|
|
5704
5503
|
product.kitProducts = kitProducts && (await this.updateKitProducts(+id, { kitProducts }));
|
|
5705
5504
|
product.reviews = reviews && (await this.updateReviews(+id, { reviews }));
|
|
5706
5505
|
product.metadata = metadata && (await this.updateMetadata(+id, { metadata }));
|
|
@@ -5764,6 +5563,42 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
5764
5563
|
getReviewStatus(review) {
|
|
5765
5564
|
return review.status === true ? 'approved' : review.status === false ? 'rejected' : 'pending';
|
|
5766
5565
|
}
|
|
5566
|
+
async updateCategories(productId, { categories }) {
|
|
5567
|
+
if ('action' in categories && categories.action === 'remove') {
|
|
5568
|
+
await this.mutation('delete_category_product', ['affected_rows'], {
|
|
5569
|
+
where: {
|
|
5570
|
+
type: 'category_product_bool_exp',
|
|
5571
|
+
required: true,
|
|
5572
|
+
value: { product_id: { _eq: productId } },
|
|
5573
|
+
},
|
|
5574
|
+
});
|
|
5575
|
+
return [];
|
|
5576
|
+
}
|
|
5577
|
+
const plainData = this.paramsToPlain({ categories });
|
|
5578
|
+
if (!plainData.categories || plainData.categories.length <= 0)
|
|
5579
|
+
return [];
|
|
5580
|
+
const product = await this.get({ id: productId.toString() });
|
|
5581
|
+
await this.mutation('delete_category_product', ['affected_rows'], {
|
|
5582
|
+
where: {
|
|
5583
|
+
type: 'category_product_bool_exp',
|
|
5584
|
+
required: true,
|
|
5585
|
+
value: {
|
|
5586
|
+
product_id: { _eq: productId },
|
|
5587
|
+
category_id: { _in: product.categories.filter((categoryId) => !plainData.categories.includes(categoryId)) },
|
|
5588
|
+
},
|
|
5589
|
+
},
|
|
5590
|
+
});
|
|
5591
|
+
await this.mutation('insert_category_product', ['affected_rows'], {
|
|
5592
|
+
objects: {
|
|
5593
|
+
type: '[category_product_insert_input!]',
|
|
5594
|
+
required: true,
|
|
5595
|
+
value: plainData.categories
|
|
5596
|
+
.filter((categoryId) => !product.categories.includes(categoryId))
|
|
5597
|
+
.map((categoryId) => ({ category_id: categoryId, product_id: productId })),
|
|
5598
|
+
},
|
|
5599
|
+
});
|
|
5600
|
+
return plainData.categories;
|
|
5601
|
+
}
|
|
5767
5602
|
async updateKitProducts(productId, { kitProducts }) {
|
|
5768
5603
|
const plainData = this.paramsToPlain({ kitProducts });
|
|
5769
5604
|
await this.mutation('delete_product_kit', ['affected_rows'], {
|
|
@@ -5895,55 +5730,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
5895
5730
|
});
|
|
5896
5731
|
return data && data[0] && this.bindReviewToModel(data[0]);
|
|
5897
5732
|
}
|
|
5898
|
-
async productVariantFullReport() {
|
|
5899
|
-
const fields = [
|
|
5900
|
-
'id',
|
|
5901
|
-
'name',
|
|
5902
|
-
'description',
|
|
5903
|
-
'slug',
|
|
5904
|
-
'sku',
|
|
5905
|
-
'ean',
|
|
5906
|
-
'cest',
|
|
5907
|
-
'ncm',
|
|
5908
|
-
'has_variants',
|
|
5909
|
-
'is_variant',
|
|
5910
|
-
'grade',
|
|
5911
|
-
'type',
|
|
5912
|
-
'is_kit',
|
|
5913
|
-
'tags',
|
|
5914
|
-
'published',
|
|
5915
|
-
'stock',
|
|
5916
|
-
'brand',
|
|
5917
|
-
'brand_description',
|
|
5918
|
-
'images',
|
|
5919
|
-
'miniatures',
|
|
5920
|
-
'video',
|
|
5921
|
-
'weight',
|
|
5922
|
-
'cost_price',
|
|
5923
|
-
'full_price',
|
|
5924
|
-
'price',
|
|
5925
|
-
'subscriber_discount_percentage',
|
|
5926
|
-
'subscriber_price',
|
|
5927
|
-
'how_to_use',
|
|
5928
|
-
'who_must_use',
|
|
5929
|
-
'differentials',
|
|
5930
|
-
'ingredients',
|
|
5931
|
-
'purpose',
|
|
5932
|
-
'filters',
|
|
5933
|
-
'category_id',
|
|
5934
|
-
'outlet',
|
|
5935
|
-
'label',
|
|
5936
|
-
'group',
|
|
5937
|
-
'validity',
|
|
5938
|
-
'gender',
|
|
5939
|
-
'shopping_count',
|
|
5940
|
-
'rating',
|
|
5941
|
-
'reviews_total',
|
|
5942
|
-
'created_at',
|
|
5943
|
-
'updated_at',
|
|
5944
|
-
];
|
|
5945
|
-
return this.query('product_variant_report_query', fields);
|
|
5946
|
-
}
|
|
5947
5733
|
}
|
|
5948
5734
|
__decorate([
|
|
5949
5735
|
Log(),
|
|
@@ -6003,24 +5789,6 @@ class ProductReviewsHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHa
|
|
|
6003
5789
|
],
|
|
6004
5790
|
});
|
|
6005
5791
|
}
|
|
6006
|
-
async updateManyStatus(reviews) {
|
|
6007
|
-
return await this.mutation('update_product_review_many', ['affected_rows'], {
|
|
6008
|
-
updates: {
|
|
6009
|
-
type: '[product_review_updates!]',
|
|
6010
|
-
required: true,
|
|
6011
|
-
value: [
|
|
6012
|
-
{
|
|
6013
|
-
_set: { status: true },
|
|
6014
|
-
where: { id: { _in: reviews.filter((review) => review.status).map((review) => review.id) } },
|
|
6015
|
-
},
|
|
6016
|
-
{
|
|
6017
|
-
_set: { status: false },
|
|
6018
|
-
where: { id: { _in: reviews.filter((review) => !review.status).map((review) => review.id) } },
|
|
6019
|
-
},
|
|
6020
|
-
],
|
|
6021
|
-
},
|
|
6022
|
-
});
|
|
6023
|
-
}
|
|
6024
5792
|
aproveReview(id) {
|
|
6025
5793
|
return this.update({ id, status: true });
|
|
6026
5794
|
}
|
|
@@ -6075,31 +5843,6 @@ class ProductStockNotificationHasuraGraphQLRepository extends withCrudHasuraGrap
|
|
|
6075
5843
|
email,
|
|
6076
5844
|
});
|
|
6077
5845
|
}
|
|
6078
|
-
async getNotificationsReport(params, orderBy, pagination) {
|
|
6079
|
-
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 } }));
|
|
6080
|
-
const orderByField = {
|
|
6081
|
-
[orderBy.field]: orderBy.direction,
|
|
6082
|
-
};
|
|
6083
|
-
const { report_stock_notification } = await this.query('report_stock_notification', ['product_id', 'ean', 'sku', 'name', 'stock', 'category_id', 'category', 'reference', 'emails_registered'], {
|
|
6084
|
-
where: {
|
|
6085
|
-
type: 'report_stock_notification_bool_exp',
|
|
6086
|
-
value: query,
|
|
6087
|
-
required: true,
|
|
6088
|
-
},
|
|
6089
|
-
order_by: {
|
|
6090
|
-
type: '[report_stock_notification_order_by]',
|
|
6091
|
-
value: orderByField,
|
|
6092
|
-
required: true,
|
|
6093
|
-
},
|
|
6094
|
-
});
|
|
6095
|
-
const data = (pagination === null || pagination === void 0 ? void 0 : pagination.limit)
|
|
6096
|
-
? 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))
|
|
6097
|
-
: report_stock_notification;
|
|
6098
|
-
return {
|
|
6099
|
-
data,
|
|
6100
|
-
count: report_stock_notification.length,
|
|
6101
|
-
};
|
|
6102
|
-
}
|
|
6103
5846
|
}
|
|
6104
5847
|
|
|
6105
5848
|
class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
@@ -6173,10 +5916,6 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
6173
5916
|
type: HasuraGraphQLColumnType.Jsonb,
|
|
6174
5917
|
},
|
|
6175
5918
|
},
|
|
6176
|
-
'group',
|
|
6177
|
-
'validity',
|
|
6178
|
-
{ tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
|
|
6179
|
-
'published',
|
|
6180
5919
|
],
|
|
6181
5920
|
});
|
|
6182
5921
|
}
|
|
@@ -6212,14 +5951,11 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
6212
5951
|
}
|
|
6213
5952
|
}
|
|
6214
5953
|
|
|
6215
|
-
class WishlistHasuraGraphQL extends Wishlist {
|
|
6216
|
-
}
|
|
6217
|
-
|
|
6218
5954
|
class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
6219
|
-
constructor({ endpoint, authOptions, interceptors, },
|
|
5955
|
+
constructor({ endpoint, authOptions, interceptors, }, categoryFilterRepository) {
|
|
6220
5956
|
super({
|
|
6221
5957
|
tableName: 'category',
|
|
6222
|
-
model:
|
|
5958
|
+
model: Wishlist,
|
|
6223
5959
|
endpoint,
|
|
6224
5960
|
authOptions,
|
|
6225
5961
|
interceptors,
|
|
@@ -6286,15 +6022,6 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
6286
6022
|
}),
|
|
6287
6023
|
},
|
|
6288
6024
|
},
|
|
6289
|
-
{
|
|
6290
|
-
metadatas: {
|
|
6291
|
-
columnName: 'metadatas',
|
|
6292
|
-
fields: ['shop', 'title', 'description'],
|
|
6293
|
-
bindPersistData: (value) => ({
|
|
6294
|
-
metadatas: { data: value },
|
|
6295
|
-
}),
|
|
6296
|
-
},
|
|
6297
|
-
},
|
|
6298
6025
|
{ isCollection: { columnName: 'is_collection' } },
|
|
6299
6026
|
{ isWishlist: { columnName: 'is_wishlist' } },
|
|
6300
6027
|
'reference',
|
|
@@ -6309,34 +6036,16 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
6309
6036
|
{ personId: { columnName: 'person_id' } },
|
|
6310
6037
|
{ personName: { columnName: 'person_name' } },
|
|
6311
6038
|
{ personPhoto: { columnName: 'person_photo' } },
|
|
6312
|
-
{ personType: { columnName: 'person_type' } },
|
|
6313
|
-
{ personIsSubscriber: { columnName: 'person_is_subscriber' } },
|
|
6314
6039
|
'theme',
|
|
6315
6040
|
{ bannerUrl: { columnName: 'banner_url' } },
|
|
6316
|
-
{ personHasPhoto: { columnName: 'person_has_photo' } },
|
|
6317
|
-
{ mostRelevants: { columnName: 'most_relevants', type: HasuraGraphQLColumnType.Jsonb } },
|
|
6318
6041
|
],
|
|
6319
6042
|
});
|
|
6320
|
-
this.
|
|
6043
|
+
this.categoryFilterRepository = categoryFilterRepository;
|
|
6321
6044
|
}
|
|
6322
6045
|
async create(params) {
|
|
6323
6046
|
var _a;
|
|
6324
|
-
const {
|
|
6325
|
-
return super.create(Object.assign(Object.assign({}, data), { isWishlist: true, isCollection: true, brandCategory: false,
|
|
6326
|
-
[Shops.GLAMSHOP]: null,
|
|
6327
|
-
[Shops.MENSMARKET]: null,
|
|
6328
|
-
}, images: images || {
|
|
6329
|
-
[Shops.GLAMSHOP]: {
|
|
6330
|
-
brandBanner: null,
|
|
6331
|
-
brandBannerMobile: null,
|
|
6332
|
-
image: null,
|
|
6333
|
-
},
|
|
6334
|
-
[Shops.MENSMARKET]: {
|
|
6335
|
-
brandBanner: null,
|
|
6336
|
-
brandBannerMobile: null,
|
|
6337
|
-
image: null,
|
|
6338
|
-
},
|
|
6339
|
-
} }));
|
|
6047
|
+
const { metadata } = params, data = __rest(params, ["metadata"]);
|
|
6048
|
+
return super.create(Object.assign(Object.assign({}, data), { isWishlist: true, isCollection: true, brandCategory: false, metadata: metadata || [{ shop: (_a = data.shop) !== null && _a !== void 0 ? _a : null, description: data.description, title: data.name }] }));
|
|
6340
6049
|
}
|
|
6341
6050
|
async get(identifiers) {
|
|
6342
6051
|
const data = await super.get(identifiers);
|
|
@@ -6349,11 +6058,12 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
6349
6058
|
return await super.find(Object.assign(Object.assign({}, rest), { filters: Object.assign(Object.assign({}, filters), { isWishlist: { operator: Where.EQUALS, value: true } }) }));
|
|
6350
6059
|
}
|
|
6351
6060
|
async update(params) {
|
|
6352
|
-
const { products, id: checkId,
|
|
6061
|
+
const { products, id: checkId, metadata, filters } = params, data = __rest(params, ["products", "id", "metadata", "filters"]);
|
|
6353
6062
|
const plainData = this.paramsToPlain({ id: checkId });
|
|
6354
6063
|
const id = plainData.id;
|
|
6355
6064
|
const category = await super.update(Object.assign(Object.assign({ id }, data), { isWishlist: true, isCollection: true, brandCategory: false }));
|
|
6356
|
-
category.
|
|
6065
|
+
category.products = products && (await this.updateProducts(+id, { products }));
|
|
6066
|
+
category.metadata = metadata && (await this.updateMetadata(+id, { metadata }));
|
|
6357
6067
|
return category;
|
|
6358
6068
|
}
|
|
6359
6069
|
async getWishlistBySlug(slug) {
|
|
@@ -6385,18 +6095,12 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
6385
6095
|
options: {
|
|
6386
6096
|
enableCount: false,
|
|
6387
6097
|
},
|
|
6388
|
-
orderBy: {
|
|
6389
|
-
id: 'asc',
|
|
6390
|
-
},
|
|
6391
|
-
limits: {
|
|
6392
|
-
limit: 1,
|
|
6393
|
-
},
|
|
6394
6098
|
});
|
|
6395
6099
|
if (!data.length)
|
|
6396
6100
|
throw new NotFoundError(`Wishlists from person ${personId} not found`);
|
|
6397
6101
|
return data;
|
|
6398
6102
|
}
|
|
6399
|
-
|
|
6103
|
+
getCategoryBySlug(slug, _shop) {
|
|
6400
6104
|
return this.getWishlistBySlug(slug);
|
|
6401
6105
|
}
|
|
6402
6106
|
async getCategoryByShop(shop) {
|
|
@@ -6414,17 +6118,10 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
6414
6118
|
});
|
|
6415
6119
|
return data;
|
|
6416
6120
|
}
|
|
6417
|
-
|
|
6418
|
-
var _a, _b;
|
|
6419
|
-
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 : {
|
|
6420
|
-
operator: Where.IN,
|
|
6421
|
-
value: [PersonTypes.BFLU, PersonTypes.GLAMGIRL],
|
|
6422
|
-
} }), orderBy: Object.assign({ personHasPhoto: 'desc' }, omit(params.orderBy, ['personHasPhoto'])) }));
|
|
6423
|
-
}
|
|
6424
|
-
getCategoriesForHome(categoryIds, gender, limit) {
|
|
6121
|
+
getCategoriesForHome(categoryIds, limit, gender) {
|
|
6425
6122
|
return;
|
|
6426
6123
|
}
|
|
6427
|
-
mountCategory(category,
|
|
6124
|
+
mountCategory(category, options) {
|
|
6428
6125
|
return;
|
|
6429
6126
|
}
|
|
6430
6127
|
getChildren(parentId) {
|
|
@@ -6433,12 +6130,50 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
6433
6130
|
isChild(id, parentId) {
|
|
6434
6131
|
return;
|
|
6435
6132
|
}
|
|
6436
|
-
async
|
|
6437
|
-
if (
|
|
6133
|
+
async updateProducts(categoryId, { products }) {
|
|
6134
|
+
if ('action' in products && products.action === 'remove') {
|
|
6135
|
+
await this.mutation('delete_category_product', ['affected_rows'], {
|
|
6136
|
+
where: {
|
|
6137
|
+
type: 'category_product_bool_exp',
|
|
6138
|
+
required: true,
|
|
6139
|
+
value: { category_id: { _eq: categoryId } },
|
|
6140
|
+
},
|
|
6141
|
+
});
|
|
6142
|
+
await this.categoryFilterRepository.deleteByCategory(categoryId);
|
|
6143
|
+
return [];
|
|
6144
|
+
}
|
|
6145
|
+
const plainData = this.paramsToPlain({ products });
|
|
6146
|
+
if (!plainData.products || plainData.products.length <= 0)
|
|
6147
|
+
return [];
|
|
6148
|
+
const category = await this.get({ id: categoryId.toString() });
|
|
6149
|
+
await this.categoryFilterRepository.deleteByCategory(categoryId);
|
|
6150
|
+
await this.mutation('delete_category_product', ['affected_rows'], {
|
|
6151
|
+
where: {
|
|
6152
|
+
type: 'category_product_bool_exp',
|
|
6153
|
+
required: true,
|
|
6154
|
+
value: {
|
|
6155
|
+
category_id: { _eq: categoryId },
|
|
6156
|
+
product_id: { _in: category.products.filter((productId) => !plainData.products.includes(productId)) },
|
|
6157
|
+
},
|
|
6158
|
+
},
|
|
6159
|
+
});
|
|
6160
|
+
await this.mutation('insert_category_product', ['affected_rows'], {
|
|
6161
|
+
objects: {
|
|
6162
|
+
type: '[category_product_insert_input!]',
|
|
6163
|
+
required: true,
|
|
6164
|
+
value: plainData.products
|
|
6165
|
+
.filter((productId) => !category.products.includes(productId))
|
|
6166
|
+
.map((productId) => ({ category_id: categoryId, product_id: productId })),
|
|
6167
|
+
},
|
|
6168
|
+
});
|
|
6169
|
+
return plainData.products;
|
|
6170
|
+
}
|
|
6171
|
+
async updateMetadata(categoryId, { metadata }) {
|
|
6172
|
+
if (Array.isArray(metadata) && !metadata.length)
|
|
6438
6173
|
return [];
|
|
6439
|
-
if (Array.isArray(
|
|
6174
|
+
if (Array.isArray(metadata) && metadata.length) {
|
|
6440
6175
|
const metadataUpdated = [];
|
|
6441
|
-
for (const data of
|
|
6176
|
+
for (const data of metadata) {
|
|
6442
6177
|
const update = await this.mutation('update_category_metadata_by_pk', ['category_id', 'shop'], {
|
|
6443
6178
|
pk_columns: {
|
|
6444
6179
|
value: { category_id: categoryId, shop: data.shop },
|
|
@@ -6455,25 +6190,19 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
6455
6190
|
}
|
|
6456
6191
|
return metadataUpdated;
|
|
6457
6192
|
}
|
|
6458
|
-
if ('action' in
|
|
6459
|
-
for (let i = 0; i <
|
|
6193
|
+
if ('action' in metadata && metadata.action === 'remove' && metadata.value.length) {
|
|
6194
|
+
for (let i = 0; i < metadata.value.length; i++) {
|
|
6460
6195
|
await this.mutation('delete_category_metadata', ['affected_rows'], {
|
|
6461
6196
|
where: {
|
|
6462
6197
|
type: 'category_metadata_bool_exp',
|
|
6463
6198
|
required: true,
|
|
6464
|
-
value: { category_id: { _eq: categoryId }, shop:
|
|
6199
|
+
value: { category_id: { _eq: categoryId }, shop: metadata.value[i].shop },
|
|
6465
6200
|
},
|
|
6466
6201
|
});
|
|
6467
6202
|
}
|
|
6468
6203
|
return [];
|
|
6469
6204
|
}
|
|
6470
6205
|
}
|
|
6471
|
-
async addProduct(wishlistId, productId) {
|
|
6472
|
-
return this.categoryProductRepository.addProductToCategory(wishlistId, productId);
|
|
6473
|
-
}
|
|
6474
|
-
async removeProduct(wishlistId, productId) {
|
|
6475
|
-
return this.categoryProductRepository.removeProductFromCategory(wishlistId, productId);
|
|
6476
|
-
}
|
|
6477
6206
|
}
|
|
6478
6207
|
__decorate([
|
|
6479
6208
|
Log(),
|
|
@@ -6493,164 +6222,5 @@ __decorate([
|
|
|
6493
6222
|
__metadata("design:paramtypes", [String]),
|
|
6494
6223
|
__metadata("design:returntype", Promise)
|
|
6495
6224
|
], WishlistHasuraGraphQLRepository.prototype, "getCategoryByShop", null);
|
|
6496
|
-
__decorate([
|
|
6497
|
-
Log(),
|
|
6498
|
-
__metadata("design:type", Function),
|
|
6499
|
-
__metadata("design:paramtypes", [Object, Array]),
|
|
6500
|
-
__metadata("design:returntype", Promise)
|
|
6501
|
-
], WishlistHasuraGraphQLRepository.prototype, "findBfluOrGlamgirlWishlists", null);
|
|
6502
|
-
|
|
6503
|
-
class VertexAxiosAdapter {
|
|
6504
|
-
constructor(config) {
|
|
6505
|
-
this.config = config;
|
|
6506
|
-
this.logger = DebugHelper.from(this);
|
|
6507
|
-
}
|
|
6508
|
-
async query(term, total, gender) {
|
|
6509
|
-
const logger = this.logger.with('query');
|
|
6510
|
-
const req = {
|
|
6511
|
-
url: `${this.config.url}/search`,
|
|
6512
|
-
method: 'POST',
|
|
6513
|
-
responseType: 'json',
|
|
6514
|
-
headers: {
|
|
6515
|
-
Accept: 'application/json',
|
|
6516
|
-
},
|
|
6517
|
-
data: { term, total, gender },
|
|
6518
|
-
};
|
|
6519
|
-
try {
|
|
6520
|
-
const { data } = await axios(req);
|
|
6521
|
-
return data;
|
|
6522
|
-
}
|
|
6523
|
-
catch (error) {
|
|
6524
|
-
logger.error({ req, res: error });
|
|
6525
|
-
throw error;
|
|
6526
|
-
}
|
|
6527
|
-
}
|
|
6528
|
-
async get(id) {
|
|
6529
|
-
const logger = this.logger.with('update');
|
|
6530
|
-
const req = {
|
|
6531
|
-
url: `${this.config.url}/${id}`,
|
|
6532
|
-
method: 'GET',
|
|
6533
|
-
responseType: 'json',
|
|
6534
|
-
headers: {
|
|
6535
|
-
Accept: 'application/json',
|
|
6536
|
-
},
|
|
6537
|
-
};
|
|
6538
|
-
try {
|
|
6539
|
-
const { data } = await axios(req);
|
|
6540
|
-
return data;
|
|
6541
|
-
}
|
|
6542
|
-
catch (error) {
|
|
6543
|
-
logger.error({ req, res: error });
|
|
6544
|
-
throw error;
|
|
6545
|
-
}
|
|
6546
|
-
}
|
|
6547
|
-
async save(data) {
|
|
6548
|
-
const logger = this.logger.with('save');
|
|
6549
|
-
const req = {
|
|
6550
|
-
url: `${this.config.url}/sync`,
|
|
6551
|
-
method: 'POST',
|
|
6552
|
-
responseType: 'json',
|
|
6553
|
-
headers: {
|
|
6554
|
-
Accept: 'application/json',
|
|
6555
|
-
},
|
|
6556
|
-
data,
|
|
6557
|
-
};
|
|
6558
|
-
try {
|
|
6559
|
-
const { data } = await axios(req);
|
|
6560
|
-
return data;
|
|
6561
|
-
}
|
|
6562
|
-
catch (error) {
|
|
6563
|
-
logger.error({ req, res: error });
|
|
6564
|
-
throw error;
|
|
6565
|
-
}
|
|
6566
|
-
}
|
|
6567
|
-
async update(id, data) {
|
|
6568
|
-
const logger = this.logger.with('update');
|
|
6569
|
-
const req = {
|
|
6570
|
-
url: `${this.config.url}/${id}`,
|
|
6571
|
-
method: 'PUT',
|
|
6572
|
-
responseType: 'json',
|
|
6573
|
-
headers: {
|
|
6574
|
-
Accept: 'application/json',
|
|
6575
|
-
},
|
|
6576
|
-
data,
|
|
6577
|
-
};
|
|
6578
|
-
try {
|
|
6579
|
-
const { data } = await axios(req);
|
|
6580
|
-
return data;
|
|
6581
|
-
}
|
|
6582
|
-
catch (error) {
|
|
6583
|
-
logger.error({ req, res: error });
|
|
6584
|
-
throw error;
|
|
6585
|
-
}
|
|
6586
|
-
}
|
|
6587
|
-
async delete(id) {
|
|
6588
|
-
const logger = this.logger.with('delete');
|
|
6589
|
-
const req = {
|
|
6590
|
-
url: `${this.config.url}/${id}`,
|
|
6591
|
-
method: 'DELETE',
|
|
6592
|
-
responseType: 'json',
|
|
6593
|
-
headers: {
|
|
6594
|
-
Accept: 'application/json',
|
|
6595
|
-
},
|
|
6596
|
-
};
|
|
6597
|
-
try {
|
|
6598
|
-
const { data } = await axios(req);
|
|
6599
|
-
return data;
|
|
6600
|
-
}
|
|
6601
|
-
catch (error) {
|
|
6602
|
-
logger.error({ req, res: error });
|
|
6603
|
-
throw error;
|
|
6604
|
-
}
|
|
6605
|
-
}
|
|
6606
|
-
bulkProducts(products) {
|
|
6607
|
-
return;
|
|
6608
|
-
}
|
|
6609
|
-
}
|
|
6610
|
-
|
|
6611
|
-
class ProductsVertexSearch {
|
|
6612
|
-
constructor(adapter) {
|
|
6613
|
-
this.adapter = adapter;
|
|
6614
|
-
}
|
|
6615
|
-
async getById(id) {
|
|
6616
|
-
const data = await this.adapter.get(id);
|
|
6617
|
-
return data;
|
|
6618
|
-
}
|
|
6619
|
-
async search(searchTerm, total, gender) {
|
|
6620
|
-
try {
|
|
6621
|
-
const result = await this.adapter.query(searchTerm, total, gender);
|
|
6622
|
-
return result;
|
|
6623
|
-
}
|
|
6624
|
-
catch (error) {
|
|
6625
|
-
console.error(error);
|
|
6626
|
-
}
|
|
6627
|
-
}
|
|
6628
|
-
async save(product) {
|
|
6629
|
-
try {
|
|
6630
|
-
const _a = product.toPlain(), { createdAt, updatedAt, kitProducts } = _a, data = __rest(_a, ["createdAt", "updatedAt", "kitProducts"]);
|
|
6631
|
-
const newProduct = Product.toInstance(data);
|
|
6632
|
-
await this.adapter.save(newProduct);
|
|
6633
|
-
}
|
|
6634
|
-
catch (error) {
|
|
6635
|
-
console.error(error);
|
|
6636
|
-
}
|
|
6637
|
-
}
|
|
6638
|
-
async update(product) {
|
|
6639
|
-
try {
|
|
6640
|
-
await this.adapter.update(product.id, product);
|
|
6641
|
-
}
|
|
6642
|
-
catch (error) {
|
|
6643
|
-
console.error(error);
|
|
6644
|
-
}
|
|
6645
|
-
}
|
|
6646
|
-
async delete(id) {
|
|
6647
|
-
try {
|
|
6648
|
-
await this.adapter.delete(id);
|
|
6649
|
-
}
|
|
6650
|
-
catch (error) {
|
|
6651
|
-
console.error(error);
|
|
6652
|
-
}
|
|
6653
|
-
}
|
|
6654
|
-
}
|
|
6655
6225
|
|
|
6656
|
-
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,
|
|
6226
|
+
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 };
|