@infrab4a/connect 4.9.7-beta.29 → 4.9.7-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs.js +503 -985
- package/index.esm.js +504 -980
- package/package.json +1 -1
- package/src/domain/catalog/models/category-base.d.ts +1 -17
- package/src/domain/catalog/models/enums/index.d.ts +0 -1
- package/src/domain/catalog/models/filter.d.ts +0 -1
- package/src/domain/catalog/models/product-base.d.ts +1 -4
- package/src/domain/catalog/models/types/category-metadata.type.d.ts +0 -2
- package/src/domain/catalog/models/types/index.d.ts +0 -4
- package/src/domain/catalog/models/variant.d.ts +0 -2
- package/src/domain/catalog/models/wishlist.d.ts +0 -3
- package/src/domain/catalog/repositories/category.repository.d.ts +3 -3
- package/src/domain/catalog/repositories/product-reviews.repository.d.ts +0 -1
- package/src/domain/catalog/repositories/product-stock-notification.repository.d.ts +1 -9
- package/src/domain/catalog/repositories/wishlist.repository.d.ts +1 -4
- package/src/domain/general/index.d.ts +0 -3
- package/src/domain/shopping/index.d.ts +0 -1
- package/src/domain/shopping/models/buy-2-win.d.ts +0 -2
- package/src/domain/shopping/models/coupons/coupon.d.ts +4 -8
- package/src/domain/shopping/models/coupons/enums/coupon-types.enum.d.ts +1 -2
- package/src/domain/shopping/models/coupons/enums/index.d.ts +1 -3
- package/src/domain/shopping/models/index.d.ts +0 -1
- package/src/domain/shopping/models/order.d.ts +0 -4
- package/src/domain/shopping/repositories/index.d.ts +0 -1
- package/src/domain/users/models/enums/index.d.ts +0 -1
- package/src/domain/users/models/index.d.ts +2 -3
- package/src/infra/elasticsearch/indexes/products-index.d.ts +1 -39
- package/src/infra/firebase/firestore/mixins/with-helpers.mixin.d.ts +1 -1
- package/src/infra/firebase/firestore/repositories/catalog/category-firestore.repository.d.ts +2 -2
- package/src/infra/firebase/firestore/repositories/index.d.ts +2 -3
- package/src/infra/firebase/firestore/repositories/shopping/index.d.ts +0 -1
- package/src/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.d.ts +0 -1
- package/src/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.d.ts +2 -2
- package/src/infra/hasura-graphql/repositories/catalog/product-review-hasura-graphql.repository.d.ts +0 -1
- package/src/infra/hasura-graphql/repositories/catalog/product-stock-notification-hasura-graphql.repository.d.ts +1 -8
- package/src/infra/hasura-graphql/repositories/catalog/wishlist-hasura-graphql.repository.d.ts +11 -13
- package/src/infra/index.d.ts +0 -1
- package/src/domain/catalog/models/enums/wishlist-log.enum.d.ts +0 -7
- package/src/domain/catalog/models/types/category-images.type.d.ts +0 -8
- package/src/domain/catalog/models/types/category-most-relevant.type.d.ts +0 -4
- package/src/domain/catalog/models/types/product-label.type.d.ts +0 -1
- package/src/domain/catalog/models/types/report-stock-notification.type.d.ts +0 -21
- package/src/domain/general/models/index.d.ts +0 -1
- package/src/domain/general/models/log-document.d.ts +0 -15
- package/src/domain/general/repositories/index.d.ts +0 -1
- package/src/domain/general/repositories/log.repository.d.ts +0 -4
- package/src/domain/general/search/index.d.ts +0 -1
- package/src/domain/general/search/product-search-index.d.ts +0 -3
- package/src/domain/shopping/models/coupons/enums/coupon-category.enum.d.ts +0 -41
- package/src/domain/shopping/models/coupons/enums/coupon-channels.enum.d.ts +0 -10
- package/src/domain/shopping/models/coupons/types/coupon-category.type.d.ts +0 -2
- package/src/domain/shopping/models/coupons/types/coupon-channel.type.d.ts +0 -2
- package/src/domain/shopping/models/coupons/types/index.d.ts +0 -2
- package/src/domain/shopping/models/order-blocked.d.ts +0 -26
- package/src/domain/shopping/repositories/order-blocked.repository.d.ts +0 -6
- package/src/domain/shopping/types/index.d.ts +0 -2
- package/src/domain/shopping/types/order-tracking-events.type.d.ts +0 -14
- package/src/domain/shopping/types/payment-card-info.type.d.ts +0 -4
- package/src/domain/users/models/enums/person-types.enum.d.ts +0 -5
- package/src/domain/users/models/types/index.d.ts +0 -1
- package/src/domain/users/models/types/person.type.d.ts +0 -2
- package/src/infra/firebase/firestore/repositories/general/index.d.ts +0 -1
- package/src/infra/firebase/firestore/repositories/general/log-firestore.repository.d.ts +0 -7
- package/src/infra/firebase/firestore/repositories/shopping/order-blocked-firestore.repository.ts.d.ts +0 -9
- package/src/infra/hasura-graphql/models/wishlist-hasura-graphql.d.ts +0 -4
- package/src/infra/vertex-ai/adapters/index.d.ts +0 -2
- package/src/infra/vertex-ai/adapters/vertex-ai-search.adapter.d.ts +0 -10
- package/src/infra/vertex-ai/adapters/vertex-axios.adapter.d.ts +0 -15
- package/src/infra/vertex-ai/index.d.ts +0 -3
- package/src/infra/vertex-ai/indexes/index.d.ts +0 -1
- package/src/infra/vertex-ai/indexes/products-vertex-search.d.ts +0 -13
- package/src/infra/vertex-ai/types/axios-vertex-search-config.d.ts +0 -4
- package/src/infra/vertex-ai/types/index.d.ts +0 -3
- package/src/infra/vertex-ai/types/product-bulk.d.ts +0 -4
- package/src/infra/vertex-ai/types/product-search.d.ts +0 -21
package/index.cjs.js
CHANGED
|
@@ -42,30 +42,6 @@ class BaseModel {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
exports.GenderDestination = void 0;
|
|
46
|
-
(function (GenderDestination) {
|
|
47
|
-
GenderDestination["FEMALE"] = "female";
|
|
48
|
-
GenderDestination["MALE"] = "male";
|
|
49
|
-
GenderDestination["UNISEX"] = "unisex";
|
|
50
|
-
})(exports.GenderDestination || (exports.GenderDestination = {}));
|
|
51
|
-
|
|
52
|
-
exports.Shops = void 0;
|
|
53
|
-
(function (Shops) {
|
|
54
|
-
Shops["MENSMARKET"] = "mensmarket";
|
|
55
|
-
Shops["GLAMSHOP"] = "Glamshop";
|
|
56
|
-
Shops["GLAMPOINTS"] = "Glampoints";
|
|
57
|
-
Shops["ALL"] = "ALL";
|
|
58
|
-
})(exports.Shops || (exports.Shops = {}));
|
|
59
|
-
|
|
60
|
-
exports.WishlistLogType = void 0;
|
|
61
|
-
(function (WishlistLogType) {
|
|
62
|
-
WishlistLogType["CREATE"] = "create";
|
|
63
|
-
WishlistLogType["UPDATE"] = "update";
|
|
64
|
-
WishlistLogType["DELETE"] = "delete";
|
|
65
|
-
WishlistLogType["ADD_PRODUCT"] = "add_product";
|
|
66
|
-
WishlistLogType["REMOVE_PRODUCT"] = "remove_product";
|
|
67
|
-
})(exports.WishlistLogType || (exports.WishlistLogType = {}));
|
|
68
|
-
|
|
69
45
|
class Filter extends BaseModel {
|
|
70
46
|
static get identifiersFields() {
|
|
71
47
|
return ['id'];
|
|
@@ -80,33 +56,6 @@ class CategoryBase extends BaseModel {
|
|
|
80
56
|
static get identifiersFields() {
|
|
81
57
|
return ['id'];
|
|
82
58
|
}
|
|
83
|
-
get glamImages() {
|
|
84
|
-
return this.images && this.images[exports.Shops.GLAMSHOP]
|
|
85
|
-
? this.images[exports.Shops.GLAMSHOP]
|
|
86
|
-
: {
|
|
87
|
-
brandBanner: null,
|
|
88
|
-
brandBannerMobile: null,
|
|
89
|
-
image: null,
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
get mensImages() {
|
|
93
|
-
return this.images && this.images[exports.Shops.MENSMARKET]
|
|
94
|
-
? this.images[exports.Shops.MENSMARKET]
|
|
95
|
-
: {
|
|
96
|
-
brandBanner: null,
|
|
97
|
-
brandBannerMobile: null,
|
|
98
|
-
image: null,
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
get glamMetadata() {
|
|
102
|
-
return this.metadatas.find((metadata) => metadata.shop === exports.Shops.GLAMSHOP);
|
|
103
|
-
}
|
|
104
|
-
get mensMetadata() {
|
|
105
|
-
return this.metadatas.find((metadata) => metadata.shop === exports.Shops.MENSMARKET);
|
|
106
|
-
}
|
|
107
|
-
getMostRelevantByShop(shop) {
|
|
108
|
-
return this.mostRelevants && this.mostRelevants[shop] ? this.mostRelevants[shop] : [];
|
|
109
|
-
}
|
|
110
59
|
}
|
|
111
60
|
tslib.__decorate([
|
|
112
61
|
classTransformer.Type(() => CategoryBase),
|
|
@@ -215,6 +164,21 @@ tslib.__decorate([
|
|
|
215
164
|
tslib.__metadata("design:type", Category)
|
|
216
165
|
], CategoryFilter.prototype, "category", void 0);
|
|
217
166
|
|
|
167
|
+
exports.GenderDestination = void 0;
|
|
168
|
+
(function (GenderDestination) {
|
|
169
|
+
GenderDestination["FEMALE"] = "female";
|
|
170
|
+
GenderDestination["MALE"] = "male";
|
|
171
|
+
GenderDestination["UNISEX"] = "unisex";
|
|
172
|
+
})(exports.GenderDestination || (exports.GenderDestination = {}));
|
|
173
|
+
|
|
174
|
+
exports.Shops = void 0;
|
|
175
|
+
(function (Shops) {
|
|
176
|
+
Shops["MENSMARKET"] = "mensmarket";
|
|
177
|
+
Shops["GLAMSHOP"] = "Glamshop";
|
|
178
|
+
Shops["GLAMPOINTS"] = "Glampoints";
|
|
179
|
+
Shops["ALL"] = "ALL";
|
|
180
|
+
})(exports.Shops || (exports.Shops = {}));
|
|
181
|
+
|
|
218
182
|
class FilterOption extends BaseModel {
|
|
219
183
|
static get identifiersFields() {
|
|
220
184
|
return ['id'];
|
|
@@ -307,17 +271,6 @@ class CampaignHashtag extends BaseModel {
|
|
|
307
271
|
}
|
|
308
272
|
}
|
|
309
273
|
|
|
310
|
-
class BeautyProfile extends BaseModel {
|
|
311
|
-
toPlain() {
|
|
312
|
-
const plain = super.toPlain();
|
|
313
|
-
delete plain.id;
|
|
314
|
-
return plain;
|
|
315
|
-
}
|
|
316
|
-
static get identifiersFields() {
|
|
317
|
-
return ['id', 'userId'];
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
|
|
321
274
|
exports.AccessoryImportances = void 0;
|
|
322
275
|
(function (AccessoryImportances) {
|
|
323
276
|
AccessoryImportances["NOT_INTERESTED"] = "N\u00E3o tenho interesse";
|
|
@@ -494,13 +447,6 @@ exports.OfficePosition = void 0;
|
|
|
494
447
|
OfficePosition["Director"] = "Diretor";
|
|
495
448
|
})(exports.OfficePosition || (exports.OfficePosition = {}));
|
|
496
449
|
|
|
497
|
-
exports.PersonTypes = void 0;
|
|
498
|
-
(function (PersonTypes) {
|
|
499
|
-
PersonTypes["GLAMGIRL"] = "glamgirl";
|
|
500
|
-
PersonTypes["BFLU"] = "bflu";
|
|
501
|
-
PersonTypes["NONE"] = "none";
|
|
502
|
-
})(exports.PersonTypes || (exports.PersonTypes = {}));
|
|
503
|
-
|
|
504
450
|
exports.ProductSpents = void 0;
|
|
505
451
|
(function (ProductSpents) {
|
|
506
452
|
ProductSpents["UNTIL_50"] = "At\u00E9 R$50";
|
|
@@ -521,12 +467,6 @@ exports.UserType = void 0;
|
|
|
521
467
|
UserType["Influencer"] = "Influencer";
|
|
522
468
|
})(exports.UserType || (exports.UserType = {}));
|
|
523
469
|
|
|
524
|
-
class Lead extends BaseModel {
|
|
525
|
-
static get identifiersFields() {
|
|
526
|
-
return ['id'];
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
|
|
530
470
|
class Edition extends BaseModel {
|
|
531
471
|
static get identifiersFields() {
|
|
532
472
|
return ['id', 'subscriptionId'];
|
|
@@ -1852,6 +1792,40 @@ const parseDateTime = (value) => {
|
|
|
1852
1792
|
return date;
|
|
1853
1793
|
};
|
|
1854
1794
|
|
|
1795
|
+
exports.CheckoutTypes = void 0;
|
|
1796
|
+
(function (CheckoutTypes) {
|
|
1797
|
+
CheckoutTypes[CheckoutTypes["ECOMMERCE"] = 1] = "ECOMMERCE";
|
|
1798
|
+
CheckoutTypes[CheckoutTypes["SUBSCRIPTION"] = 2] = "SUBSCRIPTION";
|
|
1799
|
+
CheckoutTypes[CheckoutTypes["ALL"] = 3] = "ALL";
|
|
1800
|
+
})(exports.CheckoutTypes || (exports.CheckoutTypes = {}));
|
|
1801
|
+
|
|
1802
|
+
exports.CouponTypes = void 0;
|
|
1803
|
+
(function (CouponTypes) {
|
|
1804
|
+
CouponTypes[CouponTypes["ABSOLUTE"] = 1] = "ABSOLUTE";
|
|
1805
|
+
CouponTypes[CouponTypes["PERCENTAGE"] = 2] = "PERCENTAGE";
|
|
1806
|
+
// FINANCIAL = 1,
|
|
1807
|
+
// PRODUCT,
|
|
1808
|
+
// GIFTCARD,
|
|
1809
|
+
// VOUCHER,
|
|
1810
|
+
})(exports.CouponTypes || (exports.CouponTypes = {}));
|
|
1811
|
+
|
|
1812
|
+
exports.CouponSubtypes = void 0;
|
|
1813
|
+
(function (CouponSubtypes) {
|
|
1814
|
+
CouponSubtypes[CouponSubtypes["ABSOLUTE"] = 1] = "ABSOLUTE";
|
|
1815
|
+
CouponSubtypes[CouponSubtypes["PERCENTAGE"] = 2] = "PERCENTAGE";
|
|
1816
|
+
})(exports.CouponSubtypes || (exports.CouponSubtypes = {}));
|
|
1817
|
+
|
|
1818
|
+
exports.Exclusivities = void 0;
|
|
1819
|
+
(function (Exclusivities) {
|
|
1820
|
+
Exclusivities[Exclusivities["ALL_USERS"] = 1] = "ALL_USERS";
|
|
1821
|
+
Exclusivities[Exclusivities["SPECIFIC_USER"] = 2] = "SPECIFIC_USER";
|
|
1822
|
+
Exclusivities[Exclusivities["COLLABORATORS"] = 3] = "COLLABORATORS";
|
|
1823
|
+
Exclusivities[Exclusivities["ACTIVE_SUBSCRIBER"] = 4] = "ACTIVE_SUBSCRIBER";
|
|
1824
|
+
Exclusivities[Exclusivities["INACTIVE_SUBSCRIBER"] = 5] = "INACTIVE_SUBSCRIBER";
|
|
1825
|
+
Exclusivities[Exclusivities["NON_SUBSCRIBER"] = 6] = "NON_SUBSCRIBER";
|
|
1826
|
+
})(exports.Exclusivities || (exports.Exclusivities = {}));
|
|
1827
|
+
|
|
1828
|
+
const COUPON_EXPIRATION = +1000 * 60 * 60 * 24 * 30;
|
|
1855
1829
|
class Coupon extends BaseModel {
|
|
1856
1830
|
get isInfluencer() {
|
|
1857
1831
|
return !lodash.isNil(this.influencerEmail);
|
|
@@ -1859,6 +1833,30 @@ class Coupon extends BaseModel {
|
|
|
1859
1833
|
static get identifiersFields() {
|
|
1860
1834
|
return ['id'];
|
|
1861
1835
|
}
|
|
1836
|
+
static createCoupon(userId) {
|
|
1837
|
+
return this.toInstance({
|
|
1838
|
+
nickname: `${Date.now()}`,
|
|
1839
|
+
checkoutType: exports.CheckoutTypes.ECOMMERCE,
|
|
1840
|
+
discount: {
|
|
1841
|
+
subscriber: {
|
|
1842
|
+
type: exports.CouponTypes.ABSOLUTE,
|
|
1843
|
+
value: 10,
|
|
1844
|
+
},
|
|
1845
|
+
non_subscriber: {
|
|
1846
|
+
type: exports.CouponTypes.ABSOLUTE,
|
|
1847
|
+
value: 10,
|
|
1848
|
+
},
|
|
1849
|
+
subscription: {
|
|
1850
|
+
type: exports.CouponTypes.ABSOLUTE,
|
|
1851
|
+
value: 10,
|
|
1852
|
+
},
|
|
1853
|
+
},
|
|
1854
|
+
user: userId,
|
|
1855
|
+
createdAt: new Date(Date.now()),
|
|
1856
|
+
beginAt: new Date(Date.now()),
|
|
1857
|
+
expiresIn: new Date(Date.now() + COUPON_EXPIRATION),
|
|
1858
|
+
});
|
|
1859
|
+
}
|
|
1862
1860
|
}
|
|
1863
1861
|
|
|
1864
1862
|
class SubscriptionPlan extends BaseModel {
|
|
@@ -1867,6 +1865,17 @@ class SubscriptionPlan extends BaseModel {
|
|
|
1867
1865
|
}
|
|
1868
1866
|
}
|
|
1869
1867
|
|
|
1868
|
+
class BeautyProfile extends BaseModel {
|
|
1869
|
+
toPlain() {
|
|
1870
|
+
const plain = super.toPlain();
|
|
1871
|
+
delete plain.id;
|
|
1872
|
+
return plain;
|
|
1873
|
+
}
|
|
1874
|
+
static get identifiersFields() {
|
|
1875
|
+
return ['id', 'userId'];
|
|
1876
|
+
}
|
|
1877
|
+
}
|
|
1878
|
+
|
|
1870
1879
|
class User extends BaseModel {
|
|
1871
1880
|
static toInstance(data) {
|
|
1872
1881
|
const instance = super.toInstance(data);
|
|
@@ -1980,6 +1989,12 @@ class UserPaymentMethod extends BaseModel {
|
|
|
1980
1989
|
}
|
|
1981
1990
|
}
|
|
1982
1991
|
|
|
1992
|
+
class Lead extends BaseModel {
|
|
1993
|
+
static get identifiersFields() {
|
|
1994
|
+
return ['id'];
|
|
1995
|
+
}
|
|
1996
|
+
}
|
|
1997
|
+
|
|
1983
1998
|
class UnauthorizedError extends tsCustomError.CustomError {
|
|
1984
1999
|
constructor(message) {
|
|
1985
2000
|
super(message);
|
|
@@ -2133,93 +2148,6 @@ tslib.__decorate([
|
|
|
2133
2148
|
tslib.__metadata("design:type", Coupon)
|
|
2134
2149
|
], Checkout.prototype, "coupon", void 0);
|
|
2135
2150
|
|
|
2136
|
-
exports.CouponCategory = void 0;
|
|
2137
|
-
(function (CouponCategory) {
|
|
2138
|
-
CouponCategory["Reembolso"] = "Reembolso";
|
|
2139
|
-
CouponCategory["Desculpas"] = "Desculpas";
|
|
2140
|
-
CouponCategory["BFlu"] = "BFlu";
|
|
2141
|
-
CouponCategory["ROYAL"] = "Royal";
|
|
2142
|
-
CouponCategory["Glamqueens"] = "Glamqueens";
|
|
2143
|
-
CouponCategory["Glampartner"] = "Glampartner";
|
|
2144
|
-
CouponCategory["Glamgirls"] = "Glamgirls";
|
|
2145
|
-
CouponCategory["Glamdiva"] = "Glamdiva";
|
|
2146
|
-
CouponCategory["Impulsionamento"] = "Impulsionamento";
|
|
2147
|
-
CouponCategory["PaidMedia"] = "Paid Media";
|
|
2148
|
-
CouponCategory["Organic"] = "Organic";
|
|
2149
|
-
CouponCategory["Direct"] = "Direct";
|
|
2150
|
-
CouponCategory["CRM"] = "CRM";
|
|
2151
|
-
CouponCategory["LOJAUNICO"] = "Loja \u00FAnico";
|
|
2152
|
-
CouponCategory["Outros"] = "Outros";
|
|
2153
|
-
})(exports.CouponCategory || (exports.CouponCategory = {}));
|
|
2154
|
-
exports.CouponOldCategories = void 0;
|
|
2155
|
-
(function (CouponOldCategories) {
|
|
2156
|
-
CouponOldCategories["Reembolso"] = "Reembolso";
|
|
2157
|
-
CouponOldCategories["Desculpas"] = "Desculpas";
|
|
2158
|
-
CouponOldCategories["BFlu"] = "BFlu";
|
|
2159
|
-
CouponOldCategories["ROYAL"] = "Royal";
|
|
2160
|
-
CouponOldCategories["Glamqueens"] = "Glamqueens";
|
|
2161
|
-
CouponOldCategories["Glampartner"] = "Glampartner";
|
|
2162
|
-
CouponOldCategories["Glamgirls"] = "Glamgirls";
|
|
2163
|
-
CouponOldCategories["Glamdiva"] = "Glamdiva";
|
|
2164
|
-
CouponOldCategories["Impulsionamento"] = "Impulsionamento";
|
|
2165
|
-
CouponOldCategories["PaidMedia"] = "Paid Media";
|
|
2166
|
-
CouponOldCategories["Organic"] = "Organic";
|
|
2167
|
-
CouponOldCategories["Direct"] = "Direct";
|
|
2168
|
-
CouponOldCategories["CRM"] = "CRM";
|
|
2169
|
-
CouponOldCategories["LOJAUNICO"] = "Loja \u00FAnico";
|
|
2170
|
-
CouponOldCategories["Outros"] = "Outros";
|
|
2171
|
-
})(exports.CouponOldCategories || (exports.CouponOldCategories = {}));
|
|
2172
|
-
exports.CouponCategories = void 0;
|
|
2173
|
-
(function (CouponCategories) {
|
|
2174
|
-
CouponCategories["API_001"] = "API-001";
|
|
2175
|
-
CouponCategories["COMPRE_E_GANHE"] = "COMPRE E GANHE";
|
|
2176
|
-
CouponCategories["DESCONTO"] = "DESCONTO";
|
|
2177
|
-
CouponCategories["REEMBOLSO"] = "REEMBOLSO";
|
|
2178
|
-
CouponCategories["DESCULPAS"] = "DESCULPAS";
|
|
2179
|
-
})(exports.CouponCategories || (exports.CouponCategories = {}));
|
|
2180
|
-
|
|
2181
|
-
exports.CouponChannels = void 0;
|
|
2182
|
-
(function (CouponChannels) {
|
|
2183
|
-
CouponChannels["BANNER"] = "7";
|
|
2184
|
-
CouponChannels["BFLUENCE"] = "3";
|
|
2185
|
-
CouponChannels["CRM"] = "2";
|
|
2186
|
-
CouponChannels["GLAMGIRL"] = "0";
|
|
2187
|
-
CouponChannels["PAID"] = "4";
|
|
2188
|
-
CouponChannels["ROYAL"] = "1";
|
|
2189
|
-
CouponChannels["SAC"] = "8";
|
|
2190
|
-
CouponChannels["SOCIAL"] = "5";
|
|
2191
|
-
})(exports.CouponChannels || (exports.CouponChannels = {}));
|
|
2192
|
-
|
|
2193
|
-
exports.CouponSubtypes = void 0;
|
|
2194
|
-
(function (CouponSubtypes) {
|
|
2195
|
-
CouponSubtypes[CouponSubtypes["ABSOLUTE"] = 1] = "ABSOLUTE";
|
|
2196
|
-
CouponSubtypes[CouponSubtypes["PERCENTAGE"] = 2] = "PERCENTAGE";
|
|
2197
|
-
})(exports.CouponSubtypes || (exports.CouponSubtypes = {}));
|
|
2198
|
-
|
|
2199
|
-
exports.CouponTypes = void 0;
|
|
2200
|
-
(function (CouponTypes) {
|
|
2201
|
-
CouponTypes[CouponTypes["ABSOLUTE"] = 1] = "ABSOLUTE";
|
|
2202
|
-
CouponTypes[CouponTypes["PERCENTAGE"] = 2] = "PERCENTAGE";
|
|
2203
|
-
CouponTypes[CouponTypes["SHIPPING"] = 3] = "SHIPPING";
|
|
2204
|
-
})(exports.CouponTypes || (exports.CouponTypes = {}));
|
|
2205
|
-
|
|
2206
|
-
exports.Exclusivities = void 0;
|
|
2207
|
-
(function (Exclusivities) {
|
|
2208
|
-
Exclusivities[Exclusivities["ALL_USERS"] = 1] = "ALL_USERS";
|
|
2209
|
-
Exclusivities[Exclusivities["SPECIFIC_USER"] = 2] = "SPECIFIC_USER";
|
|
2210
|
-
Exclusivities[Exclusivities["COLLABORATORS"] = 3] = "COLLABORATORS";
|
|
2211
|
-
Exclusivities[Exclusivities["ACTIVE_SUBSCRIBER"] = 4] = "ACTIVE_SUBSCRIBER";
|
|
2212
|
-
Exclusivities[Exclusivities["INACTIVE_SUBSCRIBER"] = 5] = "INACTIVE_SUBSCRIBER";
|
|
2213
|
-
Exclusivities[Exclusivities["NON_SUBSCRIBER"] = 6] = "NON_SUBSCRIBER";
|
|
2214
|
-
})(exports.Exclusivities || (exports.Exclusivities = {}));
|
|
2215
|
-
|
|
2216
|
-
exports.CheckoutTypes = void 0;
|
|
2217
|
-
(function (CheckoutTypes) {
|
|
2218
|
-
CheckoutTypes[CheckoutTypes["ECOMMERCE"] = 1] = "ECOMMERCE";
|
|
2219
|
-
CheckoutTypes[CheckoutTypes["SUBSCRIPTION"] = 2] = "SUBSCRIPTION";
|
|
2220
|
-
CheckoutTypes[CheckoutTypes["ALL"] = 3] = "ALL";
|
|
2221
|
-
})(exports.CheckoutTypes || (exports.CheckoutTypes = {}));
|
|
2222
|
-
|
|
2223
2151
|
exports.OrderStatus = void 0;
|
|
2224
2152
|
(function (OrderStatus) {
|
|
2225
2153
|
OrderStatus["AGUARDANDO_PAGAMENTO"] = "Aguardando pagamento";
|
|
@@ -2239,12 +2167,6 @@ tslib.__decorate([
|
|
|
2239
2167
|
tslib.__metadata("design:type", Payment)
|
|
2240
2168
|
], Order.prototype, "payment", void 0);
|
|
2241
2169
|
|
|
2242
|
-
class OrderBlocked extends BaseModel {
|
|
2243
|
-
static get identifiersFields() {
|
|
2244
|
-
return ['id'];
|
|
2245
|
-
}
|
|
2246
|
-
}
|
|
2247
|
-
|
|
2248
2170
|
class CheckoutSubscription extends BaseModel {
|
|
2249
2171
|
static get identifiersFields() {
|
|
2250
2172
|
return ['id'];
|
|
@@ -2281,12 +2203,6 @@ class RoundProductPricesHelper {
|
|
|
2281
2203
|
}
|
|
2282
2204
|
}
|
|
2283
2205
|
|
|
2284
|
-
class LogDocument extends BaseModel {
|
|
2285
|
-
static get identifiersFields() {
|
|
2286
|
-
return ['id'];
|
|
2287
|
-
}
|
|
2288
|
-
}
|
|
2289
|
-
|
|
2290
2206
|
exports.FilterType = void 0;
|
|
2291
2207
|
(function (FilterType) {
|
|
2292
2208
|
FilterType["ACCESSORY_IMPORTANCE"] = "accessoryImportance";
|
|
@@ -2585,6 +2501,8 @@ class ProductsIndex {
|
|
|
2585
2501
|
'rate',
|
|
2586
2502
|
];
|
|
2587
2503
|
const filter = [{ term: { published: true } }];
|
|
2504
|
+
if (shop && shop !== exports.Shops.ALL)
|
|
2505
|
+
filter.push({ term: { tags: shop == exports.Shops.GLAMSHOP ? 'feminino' : 'masculino' } });
|
|
2588
2506
|
if (size > 9)
|
|
2589
2507
|
fields.push(...['pricePaid', 'isGift', 'stock', 'weight', 'tags']);
|
|
2590
2508
|
const query = {
|
|
@@ -2640,9 +2558,7 @@ class ProductsIndex {
|
|
|
2640
2558
|
RoundProductPricesHelper.roundProductPrices(hit._source);
|
|
2641
2559
|
return hit;
|
|
2642
2560
|
});
|
|
2643
|
-
return search
|
|
2644
|
-
return Object.assign(Object.assign({}, hit._source), { stock: hit._source.stock.quantity });
|
|
2645
|
-
});
|
|
2561
|
+
return search;
|
|
2646
2562
|
}
|
|
2647
2563
|
async save(product) {
|
|
2648
2564
|
try {
|
|
@@ -3076,8 +2992,6 @@ const withUpdateFirestore = (MixinBase) => {
|
|
|
3076
2992
|
try {
|
|
3077
2993
|
const identifiers = getValueFromParams(data, keyField);
|
|
3078
2994
|
const docRef = this.collection(collectionName).getDoc(identifiers.toString());
|
|
3079
|
-
if (!(await docRef.get()).data())
|
|
3080
|
-
throw new NotFoundError(`Document '${collectionName}/${Object.values(identifiers.toString())}' not found`);
|
|
3081
2995
|
const plainFromData = this.model.toInstance(this.paramsToPlain(data));
|
|
3082
2996
|
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 }));
|
|
3083
2997
|
const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || plainFromData;
|
|
@@ -3154,280 +3068,359 @@ const withCrudFirestore = (MixinBase) => {
|
|
|
3154
3068
|
};
|
|
3155
3069
|
};
|
|
3156
3070
|
|
|
3157
|
-
class
|
|
3071
|
+
class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3158
3072
|
constructor({ firestore, interceptors }) {
|
|
3159
3073
|
super({
|
|
3160
3074
|
firestore,
|
|
3161
|
-
collectionName: '
|
|
3162
|
-
model:
|
|
3075
|
+
collectionName: 'leads',
|
|
3076
|
+
model: Lead,
|
|
3163
3077
|
interceptors,
|
|
3164
3078
|
});
|
|
3165
3079
|
}
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
async getCategoriesForHome(categoryIds, shop, limit = 4) {
|
|
3179
|
-
const categorySnap = await this.collection(this.collectionName)
|
|
3180
|
-
.where('id', 'in', categoryIds.filter(Boolean))
|
|
3181
|
-
.where('published', '==', true)
|
|
3182
|
-
.getDocs();
|
|
3183
|
-
if (categorySnap.empty)
|
|
3184
|
-
throw new NotFoundError('Categories not found');
|
|
3185
|
-
const categories = categorySnap.docs.map((doc) => doc.data());
|
|
3186
|
-
const homeSections = await Promise.all(categories.map(async (category) => ({
|
|
3187
|
-
category,
|
|
3188
|
-
products: await this.mountCategory(category, shop, { limit, hasStock: true }),
|
|
3189
|
-
})));
|
|
3190
|
-
return homeSections;
|
|
3191
|
-
}
|
|
3192
|
-
async mountCategory(category, shop, options) {
|
|
3193
|
-
if (!category.products)
|
|
3194
|
-
throw new RequiredArgumentError(['Category products is empty']);
|
|
3195
|
-
const chunks = lodash.chunk(category.products, 10);
|
|
3196
|
-
const products = [];
|
|
3197
|
-
const wheres = [];
|
|
3198
|
-
for (const productIds of chunks) {
|
|
3199
|
-
if ((options === null || options === void 0 ? void 0 : options.limit) && products.length >= (options === null || options === void 0 ? void 0 : options.limit))
|
|
3200
|
-
break;
|
|
3201
|
-
wheres.push(['published', '==', true], ['id', 'in', productIds]);
|
|
3202
|
-
if (options === null || options === void 0 ? void 0 : options.hasStock)
|
|
3203
|
-
wheres.push(['stock.quantity', '>', 0]);
|
|
3204
|
-
if (options === null || options === void 0 ? void 0 : options.gender)
|
|
3205
|
-
wheres.push(['tags', 'array-contains', options === null || options === void 0 ? void 0 : options.gender]);
|
|
3206
|
-
const productSnap = await wheres
|
|
3207
|
-
.reduce((collection, where) => collection.where(...where), (options === null || options === void 0 ? void 0 : options.limit)
|
|
3208
|
-
? this.collection('productsErpVitrine').limit(options.limit)
|
|
3209
|
-
: this.collection('productsErpVitrine'))
|
|
3210
|
-
.getDocs();
|
|
3211
|
-
if (productSnap.empty)
|
|
3212
|
-
continue;
|
|
3213
|
-
products.push(...productSnap.docs);
|
|
3214
|
-
}
|
|
3215
|
-
return is(products);
|
|
3216
|
-
}
|
|
3217
|
-
getCategoryByShop(shop) {
|
|
3218
|
-
return;
|
|
3219
|
-
}
|
|
3220
|
-
getChildren(parentId) {
|
|
3221
|
-
return;
|
|
3080
|
+
}
|
|
3081
|
+
|
|
3082
|
+
class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3083
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
3084
|
+
super({
|
|
3085
|
+
firestore,
|
|
3086
|
+
collectionName: 'editions',
|
|
3087
|
+
parentIdField: 'subscriptionId',
|
|
3088
|
+
model: Edition,
|
|
3089
|
+
interceptors,
|
|
3090
|
+
});
|
|
3091
|
+
this.parentRepository = parentRepository;
|
|
3222
3092
|
}
|
|
3223
|
-
|
|
3224
|
-
|
|
3093
|
+
}
|
|
3094
|
+
|
|
3095
|
+
class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3096
|
+
constructor({ firestore, interceptors, }) {
|
|
3097
|
+
super({
|
|
3098
|
+
firestore,
|
|
3099
|
+
collectionName: 'subscription',
|
|
3100
|
+
model: Subscription,
|
|
3101
|
+
interceptors,
|
|
3102
|
+
});
|
|
3225
3103
|
}
|
|
3226
3104
|
}
|
|
3227
|
-
tslib.__decorate([
|
|
3228
|
-
Log(),
|
|
3229
|
-
tslib.__metadata("design:type", Function),
|
|
3230
|
-
tslib.__metadata("design:paramtypes", [String, String]),
|
|
3231
|
-
tslib.__metadata("design:returntype", Promise)
|
|
3232
|
-
], CategoryFirestoreRepository.prototype, "getCategoryBySlug", null);
|
|
3233
|
-
tslib.__decorate([
|
|
3234
|
-
Log(),
|
|
3235
|
-
tslib.__metadata("design:type", Function),
|
|
3236
|
-
tslib.__metadata("design:paramtypes", [Array, String, Object]),
|
|
3237
|
-
tslib.__metadata("design:returntype", Promise)
|
|
3238
|
-
], CategoryFirestoreRepository.prototype, "getCategoriesForHome", null);
|
|
3239
|
-
tslib.__decorate([
|
|
3240
|
-
Log(),
|
|
3241
|
-
tslib.__metadata("design:type", Function),
|
|
3242
|
-
tslib.__metadata("design:paramtypes", [Category, String, Object]),
|
|
3243
|
-
tslib.__metadata("design:returntype", Promise)
|
|
3244
|
-
], CategoryFirestoreRepository.prototype, "mountCategory", null);
|
|
3245
3105
|
|
|
3246
|
-
class
|
|
3106
|
+
class SubscriptionMaterializationFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3247
3107
|
constructor({ firestore, interceptors }) {
|
|
3248
3108
|
super({
|
|
3249
3109
|
firestore,
|
|
3250
|
-
collectionName: '
|
|
3251
|
-
model:
|
|
3110
|
+
collectionName: 'subscriptionMaterialization',
|
|
3111
|
+
model: SubscriptionMaterialization,
|
|
3252
3112
|
interceptors,
|
|
3253
3113
|
});
|
|
3254
|
-
this.reviews = {};
|
|
3255
3114
|
}
|
|
3256
|
-
|
|
3257
|
-
|
|
3115
|
+
}
|
|
3116
|
+
|
|
3117
|
+
class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3118
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
3119
|
+
super({
|
|
3120
|
+
firestore,
|
|
3121
|
+
collectionName: 'payments',
|
|
3122
|
+
parentIdField: 'subscriptionId',
|
|
3123
|
+
model: SubscriptionPayment,
|
|
3124
|
+
interceptors,
|
|
3125
|
+
});
|
|
3126
|
+
this.parentRepository = parentRepository;
|
|
3258
3127
|
}
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3128
|
+
}
|
|
3129
|
+
|
|
3130
|
+
class SubscriptionSummaryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3131
|
+
constructor({ firestore, interceptors, }) {
|
|
3132
|
+
super({
|
|
3133
|
+
firestore,
|
|
3134
|
+
collectionName: 'subscriptionSummary',
|
|
3135
|
+
model: SubscriptionSummary,
|
|
3136
|
+
interceptors,
|
|
3265
3137
|
});
|
|
3266
|
-
return (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
|
|
3267
3138
|
}
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
};
|
|
3279
|
-
this.reviews.pending = [];
|
|
3280
|
-
this.reviews.approved = [];
|
|
3281
|
-
this.reviews.rejected = [];
|
|
3282
|
-
product.reviews.forEach((review) => {
|
|
3283
|
-
if ([null, undefined].includes(review.status))
|
|
3284
|
-
return this.reviews.pending.push(Object.assign(Object.assign({}, review), productInfo));
|
|
3285
|
-
if (review.status === false)
|
|
3286
|
-
return this.reviews.rejected.push(Object.assign(Object.assign({}, review), productInfo));
|
|
3287
|
-
if (!!review.status)
|
|
3288
|
-
return this.reviews.approved.push(Object.assign(Object.assign({}, review), productInfo));
|
|
3289
|
-
return review;
|
|
3290
|
-
});
|
|
3139
|
+
}
|
|
3140
|
+
|
|
3141
|
+
class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3142
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
3143
|
+
super({
|
|
3144
|
+
firestore,
|
|
3145
|
+
collectionName: 'address',
|
|
3146
|
+
parentIdField: 'userId',
|
|
3147
|
+
model: UserAddress,
|
|
3148
|
+
interceptors,
|
|
3291
3149
|
});
|
|
3292
|
-
|
|
3150
|
+
this.parentRepository = parentRepository;
|
|
3293
3151
|
}
|
|
3294
|
-
|
|
3295
|
-
|
|
3152
|
+
}
|
|
3153
|
+
|
|
3154
|
+
class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3155
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
3156
|
+
super({
|
|
3157
|
+
firestore,
|
|
3158
|
+
collectionName: 'CX',
|
|
3159
|
+
parentIdField: 'userId',
|
|
3160
|
+
model: BeautyProfile,
|
|
3161
|
+
interceptors,
|
|
3162
|
+
});
|
|
3163
|
+
this.parentRepository = parentRepository;
|
|
3296
3164
|
}
|
|
3297
|
-
|
|
3298
|
-
|
|
3165
|
+
}
|
|
3166
|
+
|
|
3167
|
+
class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3168
|
+
constructor({ firestore, interceptors }) {
|
|
3169
|
+
super({
|
|
3170
|
+
firestore,
|
|
3171
|
+
collectionName: 'users',
|
|
3172
|
+
model: User,
|
|
3173
|
+
interceptors,
|
|
3174
|
+
});
|
|
3299
3175
|
}
|
|
3300
|
-
async
|
|
3301
|
-
|
|
3176
|
+
async get(identifiers) {
|
|
3177
|
+
const user = await super.get({ id: identifiers.id });
|
|
3178
|
+
user.beautyProfile = await this.getBeautyProfile(user.id);
|
|
3179
|
+
user.isSubscriber = await this.checkIfIsSubscriber(user.id);
|
|
3180
|
+
return user;
|
|
3181
|
+
}
|
|
3182
|
+
async checkIfExistsByField(field, value) {
|
|
3183
|
+
const result = await this.find({ filters: { [field]: value } });
|
|
3184
|
+
return result.count > 0;
|
|
3185
|
+
}
|
|
3186
|
+
buildModelInstance() {
|
|
3187
|
+
const { fromFirestore, toFirestore } = super.buildModelInstance();
|
|
3188
|
+
return {
|
|
3189
|
+
toFirestore: (data) => {
|
|
3190
|
+
const plain = toFirestore(data);
|
|
3191
|
+
delete plain.isSubscriber;
|
|
3192
|
+
return plain;
|
|
3193
|
+
},
|
|
3194
|
+
fromFirestore,
|
|
3195
|
+
};
|
|
3196
|
+
}
|
|
3197
|
+
async getBeautyProfile(userId) {
|
|
3198
|
+
const beautyProfile = await this.firestore
|
|
3199
|
+
.getCollection(`${this.collectionName}/${userId}/CX`)
|
|
3200
|
+
.withConverter(this.buildBeautyProfileModelInstance())
|
|
3201
|
+
.getDoc('beautyProfile')
|
|
3202
|
+
.get();
|
|
3203
|
+
return beautyProfile.data();
|
|
3204
|
+
}
|
|
3205
|
+
async checkIfIsSubscriber(userId) {
|
|
3206
|
+
const docs = await this.collection('subscription')
|
|
3207
|
+
.where('user.id', '==', userId)
|
|
3208
|
+
.where('status', '==', 'active')
|
|
3209
|
+
.getDocs();
|
|
3210
|
+
return !!docs && !!docs.size;
|
|
3211
|
+
}
|
|
3212
|
+
buildBeautyProfileModelInstance() {
|
|
3213
|
+
return {
|
|
3214
|
+
toFirestore: (data) => data.toPlain(),
|
|
3215
|
+
fromFirestore: (snap) => BeautyProfile.toInstance(snap.data()),
|
|
3216
|
+
};
|
|
3302
3217
|
}
|
|
3303
3218
|
}
|
|
3304
3219
|
tslib.__decorate([
|
|
3305
3220
|
Log(),
|
|
3306
3221
|
tslib.__metadata("design:type", Function),
|
|
3307
|
-
tslib.__metadata("design:paramtypes", [
|
|
3222
|
+
tslib.__metadata("design:paramtypes", [Object]),
|
|
3308
3223
|
tslib.__metadata("design:returntype", Promise)
|
|
3309
|
-
],
|
|
3224
|
+
], UserFirestoreRepository.prototype, "get", null);
|
|
3310
3225
|
tslib.__decorate([
|
|
3311
3226
|
Log(),
|
|
3312
3227
|
tslib.__metadata("design:type", Function),
|
|
3313
|
-
tslib.__metadata("design:paramtypes", [String]),
|
|
3228
|
+
tslib.__metadata("design:paramtypes", [String, String]),
|
|
3314
3229
|
tslib.__metadata("design:returntype", Promise)
|
|
3315
|
-
],
|
|
3230
|
+
], UserFirestoreRepository.prototype, "checkIfExistsByField", null);
|
|
3316
3231
|
|
|
3317
|
-
class
|
|
3232
|
+
class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3318
3233
|
constructor({ firestore, interceptors }, parentRepository) {
|
|
3319
3234
|
super({
|
|
3320
3235
|
firestore,
|
|
3321
|
-
collectionName: '
|
|
3322
|
-
parentIdField: '
|
|
3323
|
-
model:
|
|
3236
|
+
collectionName: 'payment_method',
|
|
3237
|
+
parentIdField: 'userId',
|
|
3238
|
+
model: UserPaymentMethod,
|
|
3324
3239
|
interceptors,
|
|
3325
3240
|
});
|
|
3326
3241
|
this.parentRepository = parentRepository;
|
|
3327
3242
|
}
|
|
3328
3243
|
}
|
|
3329
3244
|
|
|
3330
|
-
class
|
|
3245
|
+
class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3331
3246
|
constructor({ firestore, interceptors }) {
|
|
3332
3247
|
super({
|
|
3333
3248
|
firestore,
|
|
3334
|
-
collectionName: '
|
|
3335
|
-
model:
|
|
3249
|
+
collectionName: 'categories',
|
|
3250
|
+
model: Category,
|
|
3336
3251
|
interceptors,
|
|
3337
3252
|
});
|
|
3338
3253
|
}
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3254
|
+
async getCategoryBySlug(slug, shop) {
|
|
3255
|
+
const categoryDocs = await this.collection(this.collectionName)
|
|
3256
|
+
.where('slug', '==', slug)
|
|
3257
|
+
.where('shop', '==', shop)
|
|
3258
|
+
.where('published', '==', true)
|
|
3259
|
+
.getDocs();
|
|
3260
|
+
if (categoryDocs.size > 1)
|
|
3261
|
+
throw new DuplicatedResultsError('Query returned duplicated values');
|
|
3262
|
+
if (categoryDocs.empty)
|
|
3263
|
+
throw new NotFoundError(`Document with slug ${slug} not found`);
|
|
3264
|
+
return categoryDocs.docs[0].data();
|
|
3265
|
+
}
|
|
3266
|
+
async getCategoriesForHome(categoryIds, limit = 4, gender) {
|
|
3267
|
+
const categorySnap = await this.collection(this.collectionName)
|
|
3268
|
+
.where('id', 'in', categoryIds.filter(Boolean))
|
|
3269
|
+
.where('published', '==', true)
|
|
3270
|
+
.getDocs();
|
|
3271
|
+
if (categorySnap.empty)
|
|
3272
|
+
throw new NotFoundError('Categories not found');
|
|
3273
|
+
const categories = categorySnap.docs.map((doc) => doc.data());
|
|
3274
|
+
const homeSections = await Promise.all(categories.map(async (category) => ({
|
|
3275
|
+
category,
|
|
3276
|
+
products: await this.mountCategory(category, { limit, hasStock: true, gender }),
|
|
3277
|
+
})));
|
|
3278
|
+
return homeSections;
|
|
3279
|
+
}
|
|
3280
|
+
async mountCategory(category, options) {
|
|
3281
|
+
if (!category.products)
|
|
3282
|
+
throw new RequiredArgumentError(['Category products is empty']);
|
|
3283
|
+
const chunks = lodash.chunk(category.products, 10);
|
|
3284
|
+
const products = [];
|
|
3285
|
+
const wheres = [];
|
|
3286
|
+
for (const productIds of chunks) {
|
|
3287
|
+
if ((options === null || options === void 0 ? void 0 : options.limit) && products.length >= (options === null || options === void 0 ? void 0 : options.limit))
|
|
3288
|
+
break;
|
|
3289
|
+
wheres.push(['published', '==', true], ['id', 'in', productIds]);
|
|
3290
|
+
if (options === null || options === void 0 ? void 0 : options.hasStock)
|
|
3291
|
+
wheres.push(['stock.quantity', '>', 0]);
|
|
3292
|
+
if (options === null || options === void 0 ? void 0 : options.gender)
|
|
3293
|
+
wheres.push(['tags', 'array-contains', options === null || options === void 0 ? void 0 : options.gender]);
|
|
3294
|
+
const productSnap = await wheres
|
|
3295
|
+
.reduce((collection, where) => collection.where(...where), (options === null || options === void 0 ? void 0 : options.limit)
|
|
3296
|
+
? this.collection('productsErpVitrine').limit(options.limit)
|
|
3297
|
+
: this.collection('productsErpVitrine'))
|
|
3298
|
+
.getDocs();
|
|
3299
|
+
if (productSnap.empty)
|
|
3300
|
+
continue;
|
|
3301
|
+
products.push(...productSnap.docs);
|
|
3302
|
+
}
|
|
3303
|
+
return is(products);
|
|
3304
|
+
}
|
|
3305
|
+
getCategoryByShop(shop) {
|
|
3306
|
+
return;
|
|
3307
|
+
}
|
|
3308
|
+
getChildren(parentId) {
|
|
3309
|
+
return;
|
|
3310
|
+
}
|
|
3311
|
+
isChild(id, parentId) {
|
|
3312
|
+
return;
|
|
3349
3313
|
}
|
|
3350
3314
|
}
|
|
3315
|
+
tslib.__decorate([
|
|
3316
|
+
Log(),
|
|
3317
|
+
tslib.__metadata("design:type", Function),
|
|
3318
|
+
tslib.__metadata("design:paramtypes", [String, String]),
|
|
3319
|
+
tslib.__metadata("design:returntype", Promise)
|
|
3320
|
+
], CategoryFirestoreRepository.prototype, "getCategoryBySlug", null);
|
|
3321
|
+
tslib.__decorate([
|
|
3322
|
+
Log(),
|
|
3323
|
+
tslib.__metadata("design:type", Function),
|
|
3324
|
+
tslib.__metadata("design:paramtypes", [Array, Object, String]),
|
|
3325
|
+
tslib.__metadata("design:returntype", Promise)
|
|
3326
|
+
], CategoryFirestoreRepository.prototype, "getCategoriesForHome", null);
|
|
3327
|
+
tslib.__decorate([
|
|
3328
|
+
Log(),
|
|
3329
|
+
tslib.__metadata("design:type", Function),
|
|
3330
|
+
tslib.__metadata("design:paramtypes", [Category, Object]),
|
|
3331
|
+
tslib.__metadata("design:returntype", Promise)
|
|
3332
|
+
], CategoryFirestoreRepository.prototype, "mountCategory", null);
|
|
3351
3333
|
|
|
3352
|
-
class
|
|
3334
|
+
class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3353
3335
|
constructor({ firestore, interceptors }) {
|
|
3354
3336
|
super({
|
|
3355
3337
|
firestore,
|
|
3356
|
-
collectionName: '
|
|
3357
|
-
model:
|
|
3338
|
+
collectionName: 'productsErpVitrine',
|
|
3339
|
+
model: Product,
|
|
3358
3340
|
interceptors,
|
|
3359
3341
|
});
|
|
3360
|
-
this.
|
|
3361
|
-
var _a, _b, _c;
|
|
3362
|
-
return ({
|
|
3363
|
-
category: ((_a = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _a === void 0 ? void 0 : _a.toPlain)
|
|
3364
|
-
? (_b = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _b === void 0 ? void 0 : _b.toPlain()
|
|
3365
|
-
: homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category,
|
|
3366
|
-
products: ((_c = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.products) === null || _c === void 0 ? void 0 : _c.map((product) => ((product === null || product === void 0 ? void 0 : product.toPlain) ? product === null || product === void 0 ? void 0 : product.toPlain() : product)).filter(Boolean)) || [],
|
|
3367
|
-
});
|
|
3368
|
-
};
|
|
3369
|
-
this.plainToHomeCategoryGroup = (homeCategoryGroup) => {
|
|
3370
|
-
var _a;
|
|
3371
|
-
return ({
|
|
3372
|
-
category: Category.toInstance(homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category),
|
|
3373
|
-
products: (_a = homeCategoryGroup.products) === null || _a === void 0 ? void 0 : _a.map((product) => Product.toInstance(product)),
|
|
3374
|
-
});
|
|
3375
|
-
};
|
|
3342
|
+
this.reviews = {};
|
|
3376
3343
|
}
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
const instance = fromFirestore(snap);
|
|
3386
|
-
return this.homeFromFirestore(instance);
|
|
3344
|
+
fetchProductReviews(filters) {
|
|
3345
|
+
throw new Error('Method not implemented.');
|
|
3346
|
+
}
|
|
3347
|
+
async getBySlug(slug) {
|
|
3348
|
+
var _a;
|
|
3349
|
+
const result = await this.find({
|
|
3350
|
+
filters: {
|
|
3351
|
+
slug: { operator: exports.Where.EQUALS, value: slug },
|
|
3387
3352
|
},
|
|
3388
|
-
};
|
|
3353
|
+
});
|
|
3354
|
+
return (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
|
|
3389
3355
|
}
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3356
|
+
async fetchReviews(status) {
|
|
3357
|
+
const { data: products } = await this.find();
|
|
3358
|
+
products.forEach((product) => {
|
|
3359
|
+
var _a;
|
|
3360
|
+
if ([undefined, 0].includes((_a = product.reviews) === null || _a === void 0 ? void 0 : _a.length))
|
|
3361
|
+
return;
|
|
3362
|
+
const productInfo = {
|
|
3363
|
+
productId: product.id,
|
|
3364
|
+
productName: product.name,
|
|
3365
|
+
productSku: product.sku,
|
|
3366
|
+
};
|
|
3367
|
+
this.reviews.pending = [];
|
|
3368
|
+
this.reviews.approved = [];
|
|
3369
|
+
this.reviews.rejected = [];
|
|
3370
|
+
product.reviews.forEach((review) => {
|
|
3371
|
+
if ([null, undefined].includes(review.status))
|
|
3372
|
+
return this.reviews.pending.push(Object.assign(Object.assign({}, review), productInfo));
|
|
3373
|
+
if (review.status === false)
|
|
3374
|
+
return this.reviews.rejected.push(Object.assign(Object.assign({}, review), productInfo));
|
|
3375
|
+
if (!!review.status)
|
|
3376
|
+
return this.reviews.approved.push(Object.assign(Object.assign({}, review), productInfo));
|
|
3377
|
+
return review;
|
|
3378
|
+
});
|
|
3379
|
+
});
|
|
3380
|
+
return this.reviews[status];
|
|
3381
|
+
}
|
|
3382
|
+
cleanShoppingCountFromIds() {
|
|
3383
|
+
return;
|
|
3398
3384
|
}
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.plainToHomeCategoryGroup);
|
|
3405
|
-
home.data.createdAt =
|
|
3406
|
-
home.data.createdAt instanceof firestore.Timestamp ? home.data.createdAt.toDate() : home.data.createdAt;
|
|
3407
|
-
home.data.expiresAt =
|
|
3408
|
-
home.data.expiresAt instanceof firestore.Timestamp ? home.data.expiresAt.toDate() : home.data.expiresAt;
|
|
3409
|
-
}
|
|
3410
|
-
return home;
|
|
3385
|
+
findCatalog(params) {
|
|
3386
|
+
return this.find(params);
|
|
3387
|
+
}
|
|
3388
|
+
async fetchPaginatedReviews() {
|
|
3389
|
+
return Promise.resolve([]);
|
|
3411
3390
|
}
|
|
3412
3391
|
}
|
|
3392
|
+
tslib.__decorate([
|
|
3393
|
+
Log(),
|
|
3394
|
+
tslib.__metadata("design:type", Function),
|
|
3395
|
+
tslib.__metadata("design:paramtypes", [String]),
|
|
3396
|
+
tslib.__metadata("design:returntype", Promise)
|
|
3397
|
+
], ProductFirestoreRepository.prototype, "getBySlug", null);
|
|
3398
|
+
tslib.__decorate([
|
|
3399
|
+
Log(),
|
|
3400
|
+
tslib.__metadata("design:type", Function),
|
|
3401
|
+
tslib.__metadata("design:paramtypes", [String]),
|
|
3402
|
+
tslib.__metadata("design:returntype", Promise)
|
|
3403
|
+
], ProductFirestoreRepository.prototype, "fetchReviews", null);
|
|
3413
3404
|
|
|
3414
|
-
class
|
|
3415
|
-
constructor({ firestore, interceptors }) {
|
|
3405
|
+
class ProductVariantFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3406
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
3416
3407
|
super({
|
|
3417
3408
|
firestore,
|
|
3418
|
-
collectionName: '
|
|
3419
|
-
|
|
3409
|
+
collectionName: 'variants',
|
|
3410
|
+
parentIdField: 'productId',
|
|
3411
|
+
model: Variant,
|
|
3420
3412
|
interceptors,
|
|
3421
3413
|
});
|
|
3414
|
+
this.parentRepository = parentRepository;
|
|
3422
3415
|
}
|
|
3423
3416
|
}
|
|
3424
3417
|
|
|
3425
|
-
class
|
|
3426
|
-
constructor({ firestore, interceptors
|
|
3418
|
+
class SubscriptionProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3419
|
+
constructor({ firestore, interceptors }) {
|
|
3427
3420
|
super({
|
|
3428
3421
|
firestore,
|
|
3429
|
-
collectionName: '
|
|
3430
|
-
model:
|
|
3422
|
+
collectionName: 'subscriptionProducts',
|
|
3423
|
+
model: Product,
|
|
3431
3424
|
interceptors,
|
|
3432
3425
|
});
|
|
3433
3426
|
}
|
|
@@ -3563,47 +3556,6 @@ class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
|
|
|
3563
3556
|
}
|
|
3564
3557
|
}
|
|
3565
3558
|
|
|
3566
|
-
class OrderBlockedFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3567
|
-
constructor({ firestore, interceptors, }) {
|
|
3568
|
-
super({
|
|
3569
|
-
firestore,
|
|
3570
|
-
collectionName: 'paymentBlockedAttempts',
|
|
3571
|
-
model: OrderBlocked,
|
|
3572
|
-
interceptors,
|
|
3573
|
-
});
|
|
3574
|
-
}
|
|
3575
|
-
async createBlockedOrderOrPayment(checkout, blockType, type, limiteRange, card = null) {
|
|
3576
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
3577
|
-
return this.create(OrderBlocked.toInstance({
|
|
3578
|
-
customer: {
|
|
3579
|
-
name: ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.displayName) || '',
|
|
3580
|
-
cpf: ((_b = checkout.user) === null || _b === void 0 ? void 0 : _b.cpf) || '',
|
|
3581
|
-
id: (_c = checkout.user) === null || _c === void 0 ? void 0 : _c.id,
|
|
3582
|
-
email: ((_d = checkout.user) === null || _d === void 0 ? void 0 : _d.email) || '',
|
|
3583
|
-
phoneNumber: '+55' + ((_e = checkout.user) === null || _e === void 0 ? void 0 : _e.phone),
|
|
3584
|
-
isSubscriber: (_f = checkout.user) === null || _f === void 0 ? void 0 : _f.isSubscriber,
|
|
3585
|
-
subscriptionPlan: ((_g = checkout.user) === null || _g === void 0 ? void 0 : _g.subscriptionPlan) || '',
|
|
3586
|
-
shippingAddress: Object.assign(Object.assign({}, checkout.shippingAddress), { zip: this.formatZip((_h = checkout.shippingAddress) === null || _h === void 0 ? void 0 : _h.zip) }),
|
|
3587
|
-
},
|
|
3588
|
-
blockType,
|
|
3589
|
-
limiteRange,
|
|
3590
|
-
type,
|
|
3591
|
-
card,
|
|
3592
|
-
checkout: {
|
|
3593
|
-
id: checkout.id,
|
|
3594
|
-
shop: checkout.shop,
|
|
3595
|
-
total: checkout.totalPrice,
|
|
3596
|
-
},
|
|
3597
|
-
date: new Date(),
|
|
3598
|
-
}));
|
|
3599
|
-
}
|
|
3600
|
-
formatZip(zip) {
|
|
3601
|
-
if (zip.length === 8)
|
|
3602
|
-
return zip.substring(0, 5) + '-' + zip.substring(5, 8);
|
|
3603
|
-
return zip;
|
|
3604
|
-
}
|
|
3605
|
-
}
|
|
3606
|
-
|
|
3607
3559
|
class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3608
3560
|
constructor({ firestore, interceptors }) {
|
|
3609
3561
|
super({
|
|
@@ -3626,177 +3578,87 @@ class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(
|
|
|
3626
3578
|
}
|
|
3627
3579
|
}
|
|
3628
3580
|
|
|
3629
|
-
class
|
|
3630
|
-
constructor({ firestore, interceptors }) {
|
|
3631
|
-
super({
|
|
3632
|
-
firestore,
|
|
3633
|
-
collectionName: 'leads',
|
|
3634
|
-
model: Lead,
|
|
3635
|
-
interceptors,
|
|
3636
|
-
});
|
|
3637
|
-
}
|
|
3638
|
-
}
|
|
3639
|
-
|
|
3640
|
-
class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3641
|
-
constructor({ firestore, interceptors }, parentRepository) {
|
|
3642
|
-
super({
|
|
3643
|
-
firestore,
|
|
3644
|
-
collectionName: 'editions',
|
|
3645
|
-
parentIdField: 'subscriptionId',
|
|
3646
|
-
model: Edition,
|
|
3647
|
-
interceptors,
|
|
3648
|
-
});
|
|
3649
|
-
this.parentRepository = parentRepository;
|
|
3650
|
-
}
|
|
3651
|
-
}
|
|
3652
|
-
|
|
3653
|
-
class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3654
|
-
constructor({ firestore, interceptors, }) {
|
|
3655
|
-
super({
|
|
3656
|
-
firestore,
|
|
3657
|
-
collectionName: 'subscription',
|
|
3658
|
-
model: Subscription,
|
|
3659
|
-
interceptors,
|
|
3660
|
-
});
|
|
3661
|
-
}
|
|
3662
|
-
}
|
|
3663
|
-
|
|
3664
|
-
class SubscriptionMaterializationFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3665
|
-
constructor({ firestore, interceptors }) {
|
|
3666
|
-
super({
|
|
3667
|
-
firestore,
|
|
3668
|
-
collectionName: 'subscriptionMaterialization',
|
|
3669
|
-
model: SubscriptionMaterialization,
|
|
3670
|
-
interceptors,
|
|
3671
|
-
});
|
|
3672
|
-
}
|
|
3673
|
-
}
|
|
3674
|
-
|
|
3675
|
-
class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3676
|
-
constructor({ firestore, interceptors }, parentRepository) {
|
|
3677
|
-
super({
|
|
3678
|
-
firestore,
|
|
3679
|
-
collectionName: 'payments',
|
|
3680
|
-
parentIdField: 'subscriptionId',
|
|
3681
|
-
model: SubscriptionPayment,
|
|
3682
|
-
interceptors,
|
|
3683
|
-
});
|
|
3684
|
-
this.parentRepository = parentRepository;
|
|
3685
|
-
}
|
|
3686
|
-
}
|
|
3687
|
-
|
|
3688
|
-
class SubscriptionSummaryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3689
|
-
constructor({ firestore, interceptors, }) {
|
|
3690
|
-
super({
|
|
3691
|
-
firestore,
|
|
3692
|
-
collectionName: 'subscriptionSummary',
|
|
3693
|
-
model: SubscriptionSummary,
|
|
3694
|
-
interceptors,
|
|
3695
|
-
});
|
|
3696
|
-
}
|
|
3697
|
-
}
|
|
3698
|
-
|
|
3699
|
-
class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3700
|
-
constructor({ firestore, interceptors }, parentRepository) {
|
|
3701
|
-
super({
|
|
3702
|
-
firestore,
|
|
3703
|
-
collectionName: 'address',
|
|
3704
|
-
parentIdField: 'userId',
|
|
3705
|
-
model: UserAddress,
|
|
3706
|
-
interceptors,
|
|
3707
|
-
});
|
|
3708
|
-
this.parentRepository = parentRepository;
|
|
3709
|
-
}
|
|
3710
|
-
}
|
|
3711
|
-
|
|
3712
|
-
class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3713
|
-
constructor({ firestore, interceptors }, parentRepository) {
|
|
3714
|
-
super({
|
|
3715
|
-
firestore,
|
|
3716
|
-
collectionName: 'CX',
|
|
3717
|
-
parentIdField: 'userId',
|
|
3718
|
-
model: BeautyProfile,
|
|
3719
|
-
interceptors,
|
|
3720
|
-
});
|
|
3721
|
-
this.parentRepository = parentRepository;
|
|
3722
|
-
}
|
|
3723
|
-
}
|
|
3724
|
-
|
|
3725
|
-
class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3581
|
+
class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3726
3582
|
constructor({ firestore, interceptors }) {
|
|
3727
3583
|
super({
|
|
3728
3584
|
firestore,
|
|
3729
|
-
collectionName: '
|
|
3730
|
-
model:
|
|
3585
|
+
collectionName: 'dms',
|
|
3586
|
+
model: Home,
|
|
3731
3587
|
interceptors,
|
|
3732
3588
|
});
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3589
|
+
this.homeCategoryGroupToPlain = (homeCategoryGroup) => {
|
|
3590
|
+
var _a, _b, _c;
|
|
3591
|
+
return ({
|
|
3592
|
+
category: ((_a = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _a === void 0 ? void 0 : _a.toPlain)
|
|
3593
|
+
? (_b = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _b === void 0 ? void 0 : _b.toPlain()
|
|
3594
|
+
: homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category,
|
|
3595
|
+
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)) || [],
|
|
3596
|
+
});
|
|
3597
|
+
};
|
|
3598
|
+
this.plainToHomeCategoryGroup = (homeCategoryGroup) => {
|
|
3599
|
+
var _a;
|
|
3600
|
+
return ({
|
|
3601
|
+
category: Category.toInstance(homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category),
|
|
3602
|
+
products: (_a = homeCategoryGroup.products) === null || _a === void 0 ? void 0 : _a.map((product) => Product.toInstance(product)),
|
|
3603
|
+
});
|
|
3604
|
+
};
|
|
3743
3605
|
}
|
|
3744
3606
|
buildModelInstance() {
|
|
3745
3607
|
const { fromFirestore, toFirestore } = super.buildModelInstance();
|
|
3746
3608
|
return {
|
|
3747
3609
|
toFirestore: (data) => {
|
|
3748
|
-
const
|
|
3749
|
-
|
|
3750
|
-
|
|
3610
|
+
const modifiedData = this.homeToFirestore(data);
|
|
3611
|
+
return toFirestore(modifiedData);
|
|
3612
|
+
},
|
|
3613
|
+
fromFirestore: (snap) => {
|
|
3614
|
+
const instance = fromFirestore(snap);
|
|
3615
|
+
return this.homeFromFirestore(instance);
|
|
3751
3616
|
},
|
|
3752
|
-
fromFirestore,
|
|
3753
3617
|
};
|
|
3754
3618
|
}
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
.
|
|
3759
|
-
.
|
|
3760
|
-
.
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
async checkIfIsSubscriber(userId) {
|
|
3764
|
-
const docs = await this.collection('subscription')
|
|
3765
|
-
.where('user.id', '==', userId)
|
|
3766
|
-
.where('status', '==', 'active')
|
|
3767
|
-
.getDocs();
|
|
3768
|
-
return !!docs && !!docs.size;
|
|
3619
|
+
homeToFirestore(home) {
|
|
3620
|
+
var _a, _b, _c, _d;
|
|
3621
|
+
if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
|
|
3622
|
+
home.data.data.discoverProducts = ((_b = home.data.data.discoverProducts) === null || _b === void 0 ? void 0 : _b.map(this.homeCategoryGroupToPlain)) || [];
|
|
3623
|
+
home.data.data.featuredProducts = ((_c = home.data.data.featuredProducts) === null || _c === void 0 ? void 0 : _c.map(this.homeCategoryGroupToPlain)) || [];
|
|
3624
|
+
home.data.data.verticalProducts = ((_d = home.data.data.verticalProducts) === null || _d === void 0 ? void 0 : _d.map(this.homeCategoryGroupToPlain)) || [];
|
|
3625
|
+
}
|
|
3626
|
+
return home;
|
|
3769
3627
|
}
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
3628
|
+
homeFromFirestore(home) {
|
|
3629
|
+
var _a;
|
|
3630
|
+
if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
|
|
3631
|
+
home.data.data.discoverProducts = home.data.data.discoverProducts.map(this.plainToHomeCategoryGroup);
|
|
3632
|
+
home.data.data.featuredProducts = home.data.data.featuredProducts.map(this.plainToHomeCategoryGroup);
|
|
3633
|
+
home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.plainToHomeCategoryGroup);
|
|
3634
|
+
home.data.createdAt =
|
|
3635
|
+
home.data.createdAt instanceof firestore.Timestamp ? home.data.createdAt.toDate() : home.data.createdAt;
|
|
3636
|
+
home.data.expiresAt =
|
|
3637
|
+
home.data.expiresAt instanceof firestore.Timestamp ? home.data.expiresAt.toDate() : home.data.expiresAt;
|
|
3638
|
+
}
|
|
3639
|
+
return home;
|
|
3640
|
+
}
|
|
3641
|
+
}
|
|
3642
|
+
|
|
3643
|
+
class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3644
|
+
constructor({ firestore, interceptors }) {
|
|
3645
|
+
super({
|
|
3646
|
+
firestore,
|
|
3647
|
+
collectionName: 'shopMenus',
|
|
3648
|
+
model: ShopMenu,
|
|
3649
|
+
interceptors,
|
|
3650
|
+
});
|
|
3775
3651
|
}
|
|
3776
3652
|
}
|
|
3777
|
-
tslib.__decorate([
|
|
3778
|
-
Log(),
|
|
3779
|
-
tslib.__metadata("design:type", Function),
|
|
3780
|
-
tslib.__metadata("design:paramtypes", [Object]),
|
|
3781
|
-
tslib.__metadata("design:returntype", Promise)
|
|
3782
|
-
], UserFirestoreRepository.prototype, "get", null);
|
|
3783
|
-
tslib.__decorate([
|
|
3784
|
-
Log(),
|
|
3785
|
-
tslib.__metadata("design:type", Function),
|
|
3786
|
-
tslib.__metadata("design:paramtypes", [String, String]),
|
|
3787
|
-
tslib.__metadata("design:returntype", Promise)
|
|
3788
|
-
], UserFirestoreRepository.prototype, "checkIfExistsByField", null);
|
|
3789
3653
|
|
|
3790
|
-
class
|
|
3791
|
-
constructor({ firestore, interceptors }
|
|
3654
|
+
class ShopSettingsFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3655
|
+
constructor({ firestore, interceptors, }) {
|
|
3792
3656
|
super({
|
|
3793
3657
|
firestore,
|
|
3794
|
-
collectionName: '
|
|
3795
|
-
|
|
3796
|
-
model: UserPaymentMethod,
|
|
3658
|
+
collectionName: 'shopSettings',
|
|
3659
|
+
model: ShopSettings,
|
|
3797
3660
|
interceptors,
|
|
3798
3661
|
});
|
|
3799
|
-
this.parentRepository = parentRepository;
|
|
3800
3662
|
}
|
|
3801
3663
|
}
|
|
3802
3664
|
|
|
@@ -4349,7 +4211,7 @@ const withHasuraGraphQL = (MixinBase) => {
|
|
|
4349
4211
|
const response = await axios__default["default"](request);
|
|
4350
4212
|
if (!lodash.isNil(response.data.errors)) {
|
|
4351
4213
|
this.logger.error({ req: request, res: response.data.errors });
|
|
4352
|
-
throw new Error(
|
|
4214
|
+
throw new Error(response.data.errors);
|
|
4353
4215
|
}
|
|
4354
4216
|
this.logger.log({ req: request, res: response.data });
|
|
4355
4217
|
return response.data.data;
|
|
@@ -4490,7 +4352,6 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
4490
4352
|
return class FindHasuraGraphQLMixin extends MixinBase {
|
|
4491
4353
|
constructor() {
|
|
4492
4354
|
super(...arguments);
|
|
4493
|
-
this.lastDistinct = {};
|
|
4494
4355
|
this.bindOrderByAttributes = (orderBy, fields) => Object.keys(orderBy).reduce((acc, current) => [
|
|
4495
4356
|
...acc,
|
|
4496
4357
|
{
|
|
@@ -4526,10 +4387,9 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
4526
4387
|
});
|
|
4527
4388
|
}
|
|
4528
4389
|
async find(params) {
|
|
4529
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
4390
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
4530
4391
|
this.logger = DebugHelper.from(this, 'find');
|
|
4531
4392
|
const { filters, limits, orderBy, options } = params || {};
|
|
4532
|
-
const tableFiltersNamed = `${this.tableName}:${JSON.stringify(filters)}`;
|
|
4533
4393
|
const enableCount = (_a = options === null || options === void 0 ? void 0 : options.enableCount) !== null && _a !== void 0 ? _a : true;
|
|
4534
4394
|
const variablesFilters = lodash.isNil(filters)
|
|
4535
4395
|
? {}
|
|
@@ -4580,8 +4440,8 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
4580
4440
|
},
|
|
4581
4441
|
]
|
|
4582
4442
|
: []),
|
|
4583
|
-
...((!
|
|
4584
|
-
((
|
|
4443
|
+
...((!((_b = params.limits) === null || _b === void 0 ? void 0 : _b.offset) &&
|
|
4444
|
+
((_d = (_c = params.options) === null || _c === void 0 ? void 0 : _c.distinct) === null || _d === void 0 ? void 0 : _d.map((distinct) => {
|
|
4585
4445
|
var _a, _b;
|
|
4586
4446
|
const distinctOption = (_a = this.fields.find((fieldOption) => fieldOption === distinct)) !== null && _a !== void 0 ? _a : this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === distinct);
|
|
4587
4447
|
const fieldName = ((_b = Object.values(distinctOption).shift()) === null || _b === void 0 ? void 0 : _b.columnName) || distinct;
|
|
@@ -4602,27 +4462,28 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
4602
4462
|
[]),
|
|
4603
4463
|
]);
|
|
4604
4464
|
const data = result[this.tableName].map((row) => this.convertDataFromHasura(row));
|
|
4605
|
-
return Object.assign(Object.assign(Object.assign({ data, count: enableCount ? result[`${this.tableName}_aggregate`].aggregate.count : Infinity }, (((
|
|
4465
|
+
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)
|
|
4606
4466
|
? {
|
|
4607
4467
|
minimal: options.minimal.reduce((minimals, current) => {
|
|
4608
4468
|
var _a;
|
|
4609
4469
|
return (Object.assign(Object.assign({}, minimals), lodash.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])));
|
|
4610
4470
|
}, {}),
|
|
4611
4471
|
}
|
|
4612
|
-
: {})), (((
|
|
4472
|
+
: {})), (((_f = options === null || options === void 0 ? void 0 : options.maximum) === null || _f === void 0 ? void 0 : _f.length)
|
|
4613
4473
|
? {
|
|
4614
4474
|
maximum: options.maximum.reduce((maximums, current) => {
|
|
4615
4475
|
var _a;
|
|
4616
4476
|
return (Object.assign(Object.assign({}, maximums), lodash.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])));
|
|
4617
4477
|
}, {}),
|
|
4618
4478
|
}
|
|
4619
|
-
: {})), (((
|
|
4620
|
-
|
|
4479
|
+
: {})), (!((_g = params.limits) === null || _g === void 0 ? void 0 : _g.offset) &&
|
|
4480
|
+
((_h = options === null || options === void 0 ? void 0 : options.distinct) === null || _h === void 0 ? void 0 : _h.length) && {
|
|
4481
|
+
distinct: options === null || options === void 0 ? void 0 : options.distinct.reduce((distinct, current) => {
|
|
4621
4482
|
var _a, _b;
|
|
4622
4483
|
const distinctOption = (_a = this.fields.find((fieldOption) => fieldOption === current)) !== null && _a !== void 0 ? _a : this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === current);
|
|
4623
4484
|
const fieldName = ((_b = Object.values(distinctOption).shift()) === null || _b === void 0 ? void 0 : _b.columnName) || current;
|
|
4624
4485
|
return Object.assign(Object.assign({}, distinct), { [current.toString()]: result[`${this.tableName}_${current.toString()}_distinct`].map((obj) => obj[fieldName]) });
|
|
4625
|
-
}, {})
|
|
4486
|
+
}, {}),
|
|
4626
4487
|
}));
|
|
4627
4488
|
}
|
|
4628
4489
|
};
|
|
@@ -4717,7 +4578,6 @@ class CategoryFilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHa
|
|
|
4717
4578
|
fields: [
|
|
4718
4579
|
'id',
|
|
4719
4580
|
'description',
|
|
4720
|
-
'title',
|
|
4721
4581
|
'slug',
|
|
4722
4582
|
'enabled',
|
|
4723
4583
|
{ createdAt: { columnName: 'created_at' } },
|
|
@@ -4829,7 +4689,6 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4829
4689
|
'name',
|
|
4830
4690
|
'description',
|
|
4831
4691
|
'image',
|
|
4832
|
-
{ images: { columnName: 'images', type: HasuraGraphQLColumnType.Jsonb } },
|
|
4833
4692
|
'published',
|
|
4834
4693
|
'shop',
|
|
4835
4694
|
{ shops: { columnName: 'shops', type: HasuraGraphQLColumnType.Jsonb } },
|
|
@@ -4862,11 +4721,11 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4862
4721
|
filters: {
|
|
4863
4722
|
columnName: 'filters',
|
|
4864
4723
|
foreignKeyColumn: { filter_id: 'id' },
|
|
4865
|
-
fields: [{ filter: ['id', '
|
|
4724
|
+
fields: [{ filter: ['id', 'description', 'slug', 'enabled'] }],
|
|
4866
4725
|
bindPersistData: (value) => ({
|
|
4867
4726
|
filters: { data: value.map((filter) => ({ filter_id: filter.id })) },
|
|
4868
4727
|
}),
|
|
4869
|
-
from: (filters) => (filters === null || filters === void 0 ? void 0 : filters.map((filter) => filter === null || filter === void 0 ? void 0 : filter.filter)
|
|
4728
|
+
from: (filters) => (filters === null || filters === void 0 ? void 0 : filters.map((filter) => filter === null || filter === void 0 ? void 0 : filter.filter)) || [],
|
|
4870
4729
|
},
|
|
4871
4730
|
},
|
|
4872
4731
|
{ createdAt: { columnName: 'created_at' } },
|
|
@@ -4885,21 +4744,12 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4885
4744
|
{
|
|
4886
4745
|
metadata: {
|
|
4887
4746
|
columnName: 'metadata',
|
|
4888
|
-
fields: ['
|
|
4747
|
+
fields: ['title', 'description'],
|
|
4889
4748
|
bindPersistData: (value) => ({
|
|
4890
4749
|
metadata: { data: value },
|
|
4891
4750
|
}),
|
|
4892
4751
|
},
|
|
4893
4752
|
},
|
|
4894
|
-
{
|
|
4895
|
-
metadatas: {
|
|
4896
|
-
columnName: 'metadatas',
|
|
4897
|
-
fields: ['shop', 'title', 'description'],
|
|
4898
|
-
bindPersistData: (value) => ({
|
|
4899
|
-
metadatas: { data: value },
|
|
4900
|
-
}),
|
|
4901
|
-
},
|
|
4902
|
-
},
|
|
4903
4753
|
{ isCollection: { columnName: 'is_collection' } },
|
|
4904
4754
|
{ isWishlist: { columnName: 'is_wishlist' } },
|
|
4905
4755
|
'reference',
|
|
@@ -4914,29 +4764,14 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4914
4764
|
'theme',
|
|
4915
4765
|
{ bannerUrl: { columnName: 'banner_url' } },
|
|
4916
4766
|
{ mostRelevant: { columnName: 'most_relevant', type: HasuraGraphQLColumnType.Jsonb } },
|
|
4917
|
-
{ mostRelevants: { columnName: 'most_relevants', type: HasuraGraphQLColumnType.Jsonb } },
|
|
4918
4767
|
],
|
|
4919
4768
|
});
|
|
4920
4769
|
this.productRepository = productRepository;
|
|
4921
4770
|
this.categoryFilterRepository = categoryFilterRepository;
|
|
4922
4771
|
}
|
|
4923
4772
|
async create(params) {
|
|
4924
|
-
const {
|
|
4925
|
-
return super.create(Object.assign(Object.assign({}, data), { isWishlist: false,
|
|
4926
|
-
[exports.Shops.GLAMSHOP]: null,
|
|
4927
|
-
[exports.Shops.MENSMARKET]: null,
|
|
4928
|
-
}, images: images || {
|
|
4929
|
-
[exports.Shops.GLAMSHOP]: {
|
|
4930
|
-
brandBanner: null,
|
|
4931
|
-
brandBannerMobile: null,
|
|
4932
|
-
image: null,
|
|
4933
|
-
},
|
|
4934
|
-
[exports.Shops.MENSMARKET]: {
|
|
4935
|
-
brandBanner: null,
|
|
4936
|
-
brandBannerMobile: null,
|
|
4937
|
-
image: null,
|
|
4938
|
-
},
|
|
4939
|
-
} }));
|
|
4773
|
+
const { metadata } = params, data = tslib.__rest(params, ["metadata"]);
|
|
4774
|
+
return super.create(Object.assign(Object.assign({}, data), { isWishlist: false, metadata: metadata || { description: null, title: null } }));
|
|
4940
4775
|
}
|
|
4941
4776
|
async get(identifiers) {
|
|
4942
4777
|
var _a;
|
|
@@ -4945,12 +4780,12 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4945
4780
|
: super.get(identifiers);
|
|
4946
4781
|
}
|
|
4947
4782
|
async update(params) {
|
|
4948
|
-
const { products, id: checkId,
|
|
4783
|
+
const { products, id: checkId, metadata, filters } = params, data = tslib.__rest(params, ["products", "id", "metadata", "filters"]);
|
|
4949
4784
|
const plainData = this.paramsToPlain({ id: checkId });
|
|
4950
4785
|
const id = await this.getId(plainData.id);
|
|
4951
4786
|
const category = await super.update(Object.assign(Object.assign({ id }, data), { isWishlist: false }));
|
|
4952
4787
|
category.products = products && (await this.updateProducts(+id, { products }));
|
|
4953
|
-
category.
|
|
4788
|
+
category.metadata = metadata && (await this.updateMetadata(+id, { metadata }));
|
|
4954
4789
|
category.filters = filters && (await this.updateFilters(+id, { filters }));
|
|
4955
4790
|
return category;
|
|
4956
4791
|
}
|
|
@@ -4988,7 +4823,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4988
4823
|
});
|
|
4989
4824
|
return data;
|
|
4990
4825
|
}
|
|
4991
|
-
async getCategoriesForHome(categoryIds,
|
|
4826
|
+
async getCategoriesForHome(categoryIds, limit = 4, gender) {
|
|
4992
4827
|
if (!(categoryIds === null || categoryIds === void 0 ? void 0 : categoryIds.length))
|
|
4993
4828
|
return [];
|
|
4994
4829
|
const categoriesFirestore = categoryIds.filter((categoryId) => Number.isNaN(+categoryId));
|
|
@@ -5000,32 +4835,22 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
5000
4835
|
}).then(({ data }) => data)));
|
|
5001
4836
|
if (categoriesHasura.length)
|
|
5002
4837
|
categories.push(...(await this.find({
|
|
5003
|
-
filters: {
|
|
5004
|
-
id: { operator: exports.Where.IN, value: categoriesHasura.filter(Boolean) },
|
|
5005
|
-
published: true,
|
|
5006
|
-
},
|
|
4838
|
+
filters: { id: { operator: exports.Where.IN, value: categoriesHasura.filter(Boolean) }, published: true },
|
|
5007
4839
|
}).then(({ data }) => data)));
|
|
5008
4840
|
if (!categories.length)
|
|
5009
4841
|
return [];
|
|
5010
4842
|
const homeSections = await Promise.all(categories.map(async (category) => ({
|
|
5011
4843
|
category,
|
|
5012
|
-
products: await this.mountCategory(category,
|
|
4844
|
+
products: await this.mountCategory(category, { limit, hasStock: true, gender }),
|
|
5013
4845
|
})));
|
|
5014
4846
|
return homeSections;
|
|
5015
4847
|
}
|
|
5016
|
-
async mountCategory(category,
|
|
4848
|
+
async mountCategory(category, options) {
|
|
5017
4849
|
var _a;
|
|
5018
4850
|
if (!((_a = category === null || category === void 0 ? void 0 : category.products) === null || _a === void 0 ? void 0 : _a.length))
|
|
5019
4851
|
return [];
|
|
5020
|
-
const mostRelevants = category.getMostRelevantByShop(shop);
|
|
5021
|
-
const mostRelevantProductsIds = [...new Set(mostRelevants.concat(category.products))];
|
|
5022
4852
|
const products = [];
|
|
5023
|
-
const { data: productsData } = await this.productRepository.
|
|
5024
|
-
filters: {
|
|
5025
|
-
id: { operator: exports.Where.IN, value: mostRelevantProductsIds },
|
|
5026
|
-
published: true,
|
|
5027
|
-
},
|
|
5028
|
-
fields: [
|
|
4853
|
+
const { data: productsData } = await this.productRepository.find(Object.assign(Object.assign({ filters: Object.assign(Object.assign({ id: { operator: exports.Where.IN, value: category.products }, published: true }, ((options === null || options === void 0 ? void 0 : options.hasStock) ? { stock: { quantity: { operator: exports.Where.GT, value: 0 } } } : {})), ((options === null || options === void 0 ? void 0 : options.gender) ? { tags: { operator: exports.Where.IN, value: [options === null || options === void 0 ? void 0 : options.gender] } } : {})), fields: [
|
|
5029
4854
|
'id',
|
|
5030
4855
|
'name',
|
|
5031
4856
|
'slug',
|
|
@@ -5051,29 +4876,12 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
5051
4876
|
'shoppingCount',
|
|
5052
4877
|
'gender',
|
|
5053
4878
|
'createdAt',
|
|
5054
|
-
],
|
|
5055
|
-
|
|
5056
|
-
orderBy: {
|
|
5057
|
-
shoppingCount: 'desc',
|
|
5058
|
-
rate: 'desc',
|
|
5059
|
-
stock: 'desc',
|
|
5060
|
-
name: 'asc',
|
|
5061
|
-
},
|
|
5062
|
-
}, shop === exports.Shops.MENSMARKET ? 'male' : 'female');
|
|
5063
|
-
const mostRelevantWithouyStock = productsData.filter((product) => mostRelevants.includes(product.id) && product.stock.quantity <= 0);
|
|
5064
|
-
const firstProducts = productsData
|
|
5065
|
-
.filter((product) => mostRelevants.includes(product.id) && product.stock.quantity > 0)
|
|
5066
|
-
.sort((a, b) => mostRelevants.indexOf(a.id) - mostRelevants.indexOf(b.id));
|
|
5067
|
-
const lastProducts = productsData
|
|
5068
|
-
.filter((product) => !mostRelevants.includes(product.id) && product.stock.quantity > 0)
|
|
5069
|
-
.concat(mostRelevantWithouyStock);
|
|
5070
|
-
const categoryMostRelevants = firstProducts.concat(lastProducts);
|
|
5071
|
-
const resultFinal = categoryMostRelevants.slice(0, options.limit);
|
|
5072
|
-
products.push(...resultFinal);
|
|
4879
|
+
] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})), { options: { enableCount: false } }));
|
|
4880
|
+
products.push(...productsData);
|
|
5073
4881
|
return products;
|
|
5074
4882
|
}
|
|
5075
4883
|
async getChildren(parentId) {
|
|
5076
|
-
const { category_tree } = await this.query('category_tree', ['id', 'name', 'parent_id', 'slug', 'reference'
|
|
4884
|
+
const { category_tree } = await this.query('category_tree', ['id', 'name', 'parent_id', 'slug', 'reference'], {
|
|
5077
4885
|
args: {
|
|
5078
4886
|
type: 'category_tree_args',
|
|
5079
4887
|
value: { parentid: parentId },
|
|
@@ -5153,36 +4961,23 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
5153
4961
|
});
|
|
5154
4962
|
return plainData.products;
|
|
5155
4963
|
}
|
|
5156
|
-
async updateMetadata(categoryId, {
|
|
5157
|
-
|
|
5158
|
-
|
|
5159
|
-
|
|
5160
|
-
|
|
5161
|
-
|
|
5162
|
-
|
|
5163
|
-
|
|
5164
|
-
|
|
5165
|
-
|
|
5166
|
-
|
|
5167
|
-
|
|
5168
|
-
|
|
5169
|
-
|
|
5170
|
-
|
|
5171
|
-
|
|
5172
|
-
|
|
5173
|
-
});
|
|
5174
|
-
return metadatas;
|
|
5175
|
-
}
|
|
5176
|
-
if ('action' in metadatas && metadatas.action === 'remove' && metadatas.value.length) {
|
|
5177
|
-
await this.mutation('delete_category_metadata', ['affected_rows'], {
|
|
5178
|
-
where: {
|
|
5179
|
-
type: 'category_metadata_bool_exp',
|
|
5180
|
-
required: true,
|
|
5181
|
-
value: { category_id: { _eq: categoryId } },
|
|
5182
|
-
},
|
|
5183
|
-
});
|
|
5184
|
-
return [];
|
|
5185
|
-
}
|
|
4964
|
+
async updateMetadata(categoryId, { metadata }) {
|
|
4965
|
+
const plainData = this.paramsToPlain({ metadata });
|
|
4966
|
+
if (!plainData.metadata)
|
|
4967
|
+
return null;
|
|
4968
|
+
await this.mutation('update_category_metadata_by_pk', ['category_id'], {
|
|
4969
|
+
pk_columns: {
|
|
4970
|
+
value: { category_id: categoryId },
|
|
4971
|
+
type: 'category_metadata_pk_columns_input',
|
|
4972
|
+
required: true,
|
|
4973
|
+
},
|
|
4974
|
+
_set: {
|
|
4975
|
+
value: lodash.omit(metadata, ['category_id']),
|
|
4976
|
+
type: 'category_metadata_set_input',
|
|
4977
|
+
required: true,
|
|
4978
|
+
},
|
|
4979
|
+
});
|
|
4980
|
+
return plainData.metadata;
|
|
5186
4981
|
}
|
|
5187
4982
|
async updateFilters(categoryId, { filters }) {
|
|
5188
4983
|
if ('action' in filters && filters.action === 'remove' && filters.value.length) {
|
|
@@ -5244,13 +5039,13 @@ tslib.__decorate([
|
|
|
5244
5039
|
tslib.__decorate([
|
|
5245
5040
|
Log(),
|
|
5246
5041
|
tslib.__metadata("design:type", Function),
|
|
5247
|
-
tslib.__metadata("design:paramtypes", [Array,
|
|
5042
|
+
tslib.__metadata("design:paramtypes", [Array, Object, String]),
|
|
5248
5043
|
tslib.__metadata("design:returntype", Promise)
|
|
5249
5044
|
], CategoryHasuraGraphQLRepository.prototype, "getCategoriesForHome", null);
|
|
5250
5045
|
tslib.__decorate([
|
|
5251
5046
|
Log(),
|
|
5252
5047
|
tslib.__metadata("design:type", Function),
|
|
5253
|
-
tslib.__metadata("design:paramtypes", [Category,
|
|
5048
|
+
tslib.__metadata("design:paramtypes", [Category, Object]),
|
|
5254
5049
|
tslib.__metadata("design:returntype", Promise)
|
|
5255
5050
|
], CategoryHasuraGraphQLRepository.prototype, "mountCategory", null);
|
|
5256
5051
|
tslib.__decorate([
|
|
@@ -5276,7 +5071,6 @@ class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGrap
|
|
|
5276
5071
|
interceptors,
|
|
5277
5072
|
fields: [
|
|
5278
5073
|
'id',
|
|
5279
|
-
'title',
|
|
5280
5074
|
'description',
|
|
5281
5075
|
'slug',
|
|
5282
5076
|
'enabled',
|
|
@@ -5532,7 +5326,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
5532
5326
|
{ subscriberPrice: { columnName: 'subscriber_price' } },
|
|
5533
5327
|
'published',
|
|
5534
5328
|
'outlet',
|
|
5535
|
-
'label',
|
|
5536
5329
|
'sku',
|
|
5537
5330
|
{
|
|
5538
5331
|
stock: {
|
|
@@ -5564,8 +5357,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
5564
5357
|
fields: ['id', 'name', 'reference', 'slug'],
|
|
5565
5358
|
},
|
|
5566
5359
|
},
|
|
5567
|
-
'group',
|
|
5568
|
-
'validity',
|
|
5569
5360
|
];
|
|
5570
5361
|
this.fields = [
|
|
5571
5362
|
...commonFields,
|
|
@@ -5667,8 +5458,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
5667
5458
|
enableCount: false,
|
|
5668
5459
|
},
|
|
5669
5460
|
});
|
|
5670
|
-
if (!result.data.length)
|
|
5671
|
-
return null;
|
|
5672
5461
|
const product = (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
|
|
5673
5462
|
RoundProductPricesHelper.roundProductPrices(product);
|
|
5674
5463
|
return product;
|
|
@@ -5968,24 +5757,6 @@ class ProductReviewsHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHa
|
|
|
5968
5757
|
],
|
|
5969
5758
|
});
|
|
5970
5759
|
}
|
|
5971
|
-
async updateManyStatus(reviews) {
|
|
5972
|
-
return await this.mutation('update_product_review_many', ['affected_rows'], {
|
|
5973
|
-
updates: {
|
|
5974
|
-
type: '[product_review_updates!]',
|
|
5975
|
-
required: true,
|
|
5976
|
-
value: [
|
|
5977
|
-
{
|
|
5978
|
-
_set: { status: true },
|
|
5979
|
-
where: { id: { _in: reviews.filter((review) => review.status).map((review) => review.id) } },
|
|
5980
|
-
},
|
|
5981
|
-
{
|
|
5982
|
-
_set: { status: false },
|
|
5983
|
-
where: { id: { _in: reviews.filter((review) => !review.status).map((review) => review.id) } },
|
|
5984
|
-
},
|
|
5985
|
-
],
|
|
5986
|
-
},
|
|
5987
|
-
});
|
|
5988
|
-
}
|
|
5989
5760
|
aproveReview(id) {
|
|
5990
5761
|
return this.update({ id, status: true });
|
|
5991
5762
|
}
|
|
@@ -6040,31 +5811,6 @@ class ProductStockNotificationHasuraGraphQLRepository extends withCrudHasuraGrap
|
|
|
6040
5811
|
email,
|
|
6041
5812
|
});
|
|
6042
5813
|
}
|
|
6043
|
-
async getNotificationsReport(params, orderBy, pagination) {
|
|
6044
|
-
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 } }));
|
|
6045
|
-
const orderByField = {
|
|
6046
|
-
[orderBy.field]: orderBy.direction,
|
|
6047
|
-
};
|
|
6048
|
-
const { report_stock_notification } = await this.query('report_stock_notification', ['product_id', 'ean', 'sku', 'name', 'stock', 'category_id', 'category', 'reference', 'emails_registered'], {
|
|
6049
|
-
where: {
|
|
6050
|
-
type: 'report_stock_notification_bool_exp',
|
|
6051
|
-
value: query,
|
|
6052
|
-
required: true,
|
|
6053
|
-
},
|
|
6054
|
-
order_by: {
|
|
6055
|
-
type: '[report_stock_notification_order_by]',
|
|
6056
|
-
value: orderByField,
|
|
6057
|
-
required: true,
|
|
6058
|
-
},
|
|
6059
|
-
});
|
|
6060
|
-
const data = (pagination === null || pagination === void 0 ? void 0 : pagination.limit)
|
|
6061
|
-
? 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))
|
|
6062
|
-
: report_stock_notification;
|
|
6063
|
-
return {
|
|
6064
|
-
data,
|
|
6065
|
-
count: report_stock_notification.length,
|
|
6066
|
-
};
|
|
6067
|
-
}
|
|
6068
5814
|
}
|
|
6069
5815
|
|
|
6070
5816
|
class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
@@ -6138,8 +5884,6 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
6138
5884
|
type: HasuraGraphQLColumnType.Jsonb,
|
|
6139
5885
|
},
|
|
6140
5886
|
},
|
|
6141
|
-
'group',
|
|
6142
|
-
'validity',
|
|
6143
5887
|
],
|
|
6144
5888
|
});
|
|
6145
5889
|
}
|
|
@@ -6175,14 +5919,11 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
6175
5919
|
}
|
|
6176
5920
|
}
|
|
6177
5921
|
|
|
6178
|
-
class WishlistHasuraGraphQL extends Wishlist {
|
|
6179
|
-
}
|
|
6180
|
-
|
|
6181
5922
|
class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
6182
5923
|
constructor({ endpoint, authOptions, interceptors, }, categoryFilterRepository) {
|
|
6183
5924
|
super({
|
|
6184
5925
|
tableName: 'category',
|
|
6185
|
-
model:
|
|
5926
|
+
model: Wishlist,
|
|
6186
5927
|
endpoint,
|
|
6187
5928
|
authOptions,
|
|
6188
5929
|
interceptors,
|
|
@@ -6243,21 +5984,12 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
6243
5984
|
{
|
|
6244
5985
|
metadata: {
|
|
6245
5986
|
columnName: 'metadata',
|
|
6246
|
-
fields: ['
|
|
5987
|
+
fields: ['title', 'description'],
|
|
6247
5988
|
bindPersistData: (value) => ({
|
|
6248
5989
|
metadata: { data: value },
|
|
6249
5990
|
}),
|
|
6250
5991
|
},
|
|
6251
5992
|
},
|
|
6252
|
-
{
|
|
6253
|
-
metadatas: {
|
|
6254
|
-
columnName: 'metadatas',
|
|
6255
|
-
fields: ['shop', 'title', 'description'],
|
|
6256
|
-
bindPersistData: (value) => ({
|
|
6257
|
-
metadatas: { data: value },
|
|
6258
|
-
}),
|
|
6259
|
-
},
|
|
6260
|
-
},
|
|
6261
5993
|
{ isCollection: { columnName: 'is_collection' } },
|
|
6262
5994
|
{ isWishlist: { columnName: 'is_wishlist' } },
|
|
6263
5995
|
'reference',
|
|
@@ -6272,34 +6004,15 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
6272
6004
|
{ personId: { columnName: 'person_id' } },
|
|
6273
6005
|
{ personName: { columnName: 'person_name' } },
|
|
6274
6006
|
{ personPhoto: { columnName: 'person_photo' } },
|
|
6275
|
-
{ personType: { columnName: 'person_type' } },
|
|
6276
|
-
{ personIsSubscriber: { columnName: 'person_is_subscriber' } },
|
|
6277
6007
|
'theme',
|
|
6278
6008
|
{ bannerUrl: { columnName: 'banner_url' } },
|
|
6279
|
-
{ personHasPhoto: { columnName: 'person_has_photo' } },
|
|
6280
|
-
{ mostRelevants: { columnName: 'most_relevants', type: HasuraGraphQLColumnType.Jsonb } },
|
|
6281
6009
|
],
|
|
6282
6010
|
});
|
|
6283
6011
|
this.categoryFilterRepository = categoryFilterRepository;
|
|
6284
6012
|
}
|
|
6285
6013
|
async create(params) {
|
|
6286
|
-
|
|
6287
|
-
|
|
6288
|
-
return super.create(Object.assign(Object.assign({}, data), { isWishlist: true, isCollection: true, brandCategory: false, metadatas: metadatas || [{ shop: (_a = data.shop) !== null && _a !== void 0 ? _a : null, description: data.description, title: data.name }], mostRelevants: mostRelevants || {
|
|
6289
|
-
[exports.Shops.GLAMSHOP]: null,
|
|
6290
|
-
[exports.Shops.MENSMARKET]: null,
|
|
6291
|
-
}, images: images || {
|
|
6292
|
-
[exports.Shops.GLAMSHOP]: {
|
|
6293
|
-
brandBanner: null,
|
|
6294
|
-
brandBannerMobile: null,
|
|
6295
|
-
image: null,
|
|
6296
|
-
},
|
|
6297
|
-
[exports.Shops.MENSMARKET]: {
|
|
6298
|
-
brandBanner: null,
|
|
6299
|
-
brandBannerMobile: null,
|
|
6300
|
-
image: null,
|
|
6301
|
-
},
|
|
6302
|
-
} }));
|
|
6014
|
+
const { metadata } = params, data = tslib.__rest(params, ["metadata"]);
|
|
6015
|
+
return super.create(Object.assign(Object.assign({}, data), { isWishlist: true, isCollection: true, brandCategory: false, metadata: metadata || { description: data.description, title: data.name } }));
|
|
6303
6016
|
}
|
|
6304
6017
|
async get(identifiers) {
|
|
6305
6018
|
const data = await super.get(identifiers);
|
|
@@ -6312,12 +6025,12 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
6312
6025
|
return await super.find(Object.assign(Object.assign({}, rest), { filters: Object.assign(Object.assign({}, filters), { isWishlist: { operator: exports.Where.EQUALS, value: true } }) }));
|
|
6313
6026
|
}
|
|
6314
6027
|
async update(params) {
|
|
6315
|
-
const { products, id: checkId,
|
|
6028
|
+
const { products, id: checkId, metadata, filters } = params, data = tslib.__rest(params, ["products", "id", "metadata", "filters"]);
|
|
6316
6029
|
const plainData = this.paramsToPlain({ id: checkId });
|
|
6317
6030
|
const id = plainData.id;
|
|
6318
6031
|
const category = await super.update(Object.assign(Object.assign({ id }, data), { isWishlist: true, isCollection: true, brandCategory: false }));
|
|
6319
6032
|
category.products = products && (await this.updateProducts(+id, { products }));
|
|
6320
|
-
category.
|
|
6033
|
+
category.metadata = metadata && (await this.updateMetadata(+id, { metadata }));
|
|
6321
6034
|
return category;
|
|
6322
6035
|
}
|
|
6323
6036
|
async getWishlistBySlug(slug) {
|
|
@@ -6349,18 +6062,12 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
6349
6062
|
options: {
|
|
6350
6063
|
enableCount: false,
|
|
6351
6064
|
},
|
|
6352
|
-
orderBy: {
|
|
6353
|
-
id: 'asc',
|
|
6354
|
-
},
|
|
6355
|
-
limits: {
|
|
6356
|
-
limit: 1,
|
|
6357
|
-
},
|
|
6358
6065
|
});
|
|
6359
6066
|
if (!data.length)
|
|
6360
6067
|
throw new NotFoundError(`Wishlists from person ${personId} not found`);
|
|
6361
6068
|
return data;
|
|
6362
6069
|
}
|
|
6363
|
-
|
|
6070
|
+
getCategoryBySlug(slug, _shop) {
|
|
6364
6071
|
return this.getWishlistBySlug(slug);
|
|
6365
6072
|
}
|
|
6366
6073
|
async getCategoryByShop(shop) {
|
|
@@ -6378,17 +6085,10 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
6378
6085
|
});
|
|
6379
6086
|
return data;
|
|
6380
6087
|
}
|
|
6381
|
-
|
|
6382
|
-
var _a, _b;
|
|
6383
|
-
return this.find(Object.assign(Object.assign({}, params), { filters: Object.assign(Object.assign({}, params.filters), { published: true, shops: { operator: exports.Where.LIKE, value: shops }, personType: (_b = (_a = params.filters) === null || _a === void 0 ? void 0 : _a.personType) !== null && _b !== void 0 ? _b : {
|
|
6384
|
-
operator: exports.Where.IN,
|
|
6385
|
-
value: [exports.PersonTypes.BFLU, exports.PersonTypes.GLAMGIRL],
|
|
6386
|
-
} }), orderBy: Object.assign({ personHasPhoto: 'desc' }, lodash.omit(params.orderBy, ['personHasPhoto'])) }));
|
|
6387
|
-
}
|
|
6388
|
-
getCategoriesForHome(categoryIds, gender, limit) {
|
|
6088
|
+
getCategoriesForHome(categoryIds, limit, gender) {
|
|
6389
6089
|
return;
|
|
6390
6090
|
}
|
|
6391
|
-
mountCategory(category,
|
|
6091
|
+
mountCategory(category, options) {
|
|
6392
6092
|
return;
|
|
6393
6093
|
}
|
|
6394
6094
|
getChildren(parentId) {
|
|
@@ -6435,40 +6135,23 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
6435
6135
|
});
|
|
6436
6136
|
return plainData.products;
|
|
6437
6137
|
}
|
|
6438
|
-
async updateMetadata(categoryId, {
|
|
6439
|
-
|
|
6440
|
-
|
|
6441
|
-
|
|
6442
|
-
|
|
6443
|
-
|
|
6444
|
-
|
|
6445
|
-
|
|
6446
|
-
|
|
6447
|
-
|
|
6448
|
-
|
|
6449
|
-
|
|
6450
|
-
|
|
6451
|
-
|
|
6452
|
-
|
|
6453
|
-
|
|
6454
|
-
|
|
6455
|
-
});
|
|
6456
|
-
metadataUpdated.push(update);
|
|
6457
|
-
}
|
|
6458
|
-
return metadataUpdated;
|
|
6459
|
-
}
|
|
6460
|
-
if ('action' in metadatas && metadatas.action === 'remove' && metadatas.value.length) {
|
|
6461
|
-
for (let i = 0; i < metadatas.value.length; i++) {
|
|
6462
|
-
await this.mutation('delete_category_metadata', ['affected_rows'], {
|
|
6463
|
-
where: {
|
|
6464
|
-
type: 'category_metadata_bool_exp',
|
|
6465
|
-
required: true,
|
|
6466
|
-
value: { category_id: { _eq: categoryId }, shop: metadatas.value[i].shop },
|
|
6467
|
-
},
|
|
6468
|
-
});
|
|
6469
|
-
}
|
|
6470
|
-
return [];
|
|
6471
|
-
}
|
|
6138
|
+
async updateMetadata(categoryId, { metadata }) {
|
|
6139
|
+
const plainData = this.paramsToPlain({ metadata });
|
|
6140
|
+
if (!plainData.metadata)
|
|
6141
|
+
return;
|
|
6142
|
+
await this.mutation('update_category_metadata_by_pk', ['category_id'], {
|
|
6143
|
+
pk_columns: {
|
|
6144
|
+
value: { category_id: categoryId },
|
|
6145
|
+
type: 'category_metadata_pk_columns_input',
|
|
6146
|
+
required: true,
|
|
6147
|
+
},
|
|
6148
|
+
_set: {
|
|
6149
|
+
value: lodash.omit(metadata, ['category_id']),
|
|
6150
|
+
type: 'category_metadata_set_input',
|
|
6151
|
+
required: true,
|
|
6152
|
+
},
|
|
6153
|
+
});
|
|
6154
|
+
return plainData.metadata;
|
|
6472
6155
|
}
|
|
6473
6156
|
}
|
|
6474
6157
|
tslib.__decorate([
|
|
@@ -6489,165 +6172,6 @@ tslib.__decorate([
|
|
|
6489
6172
|
tslib.__metadata("design:paramtypes", [String]),
|
|
6490
6173
|
tslib.__metadata("design:returntype", Promise)
|
|
6491
6174
|
], WishlistHasuraGraphQLRepository.prototype, "getCategoryByShop", null);
|
|
6492
|
-
tslib.__decorate([
|
|
6493
|
-
Log(),
|
|
6494
|
-
tslib.__metadata("design:type", Function),
|
|
6495
|
-
tslib.__metadata("design:paramtypes", [Object, Array]),
|
|
6496
|
-
tslib.__metadata("design:returntype", Promise)
|
|
6497
|
-
], WishlistHasuraGraphQLRepository.prototype, "findBfluOrGlamgirlWishlists", null);
|
|
6498
|
-
|
|
6499
|
-
class VertexAxiosAdapter {
|
|
6500
|
-
constructor(config) {
|
|
6501
|
-
this.config = config;
|
|
6502
|
-
this.logger = DebugHelper.from(this);
|
|
6503
|
-
}
|
|
6504
|
-
async query(term, total, gender) {
|
|
6505
|
-
const logger = this.logger.with('query');
|
|
6506
|
-
const req = {
|
|
6507
|
-
url: `${this.config.url}/search`,
|
|
6508
|
-
method: 'POST',
|
|
6509
|
-
responseType: 'json',
|
|
6510
|
-
headers: {
|
|
6511
|
-
Accept: 'application/json',
|
|
6512
|
-
},
|
|
6513
|
-
data: { term, total, gender },
|
|
6514
|
-
};
|
|
6515
|
-
try {
|
|
6516
|
-
const { data } = await axios__default["default"](req);
|
|
6517
|
-
return data;
|
|
6518
|
-
}
|
|
6519
|
-
catch (error) {
|
|
6520
|
-
logger.error({ req, res: error });
|
|
6521
|
-
throw error;
|
|
6522
|
-
}
|
|
6523
|
-
}
|
|
6524
|
-
async get(id) {
|
|
6525
|
-
const logger = this.logger.with('update');
|
|
6526
|
-
const req = {
|
|
6527
|
-
url: `${this.config.url}/${id}`,
|
|
6528
|
-
method: 'GET',
|
|
6529
|
-
responseType: 'json',
|
|
6530
|
-
headers: {
|
|
6531
|
-
Accept: 'application/json',
|
|
6532
|
-
},
|
|
6533
|
-
};
|
|
6534
|
-
try {
|
|
6535
|
-
const { data } = await axios__default["default"](req);
|
|
6536
|
-
return data;
|
|
6537
|
-
}
|
|
6538
|
-
catch (error) {
|
|
6539
|
-
logger.error({ req, res: error });
|
|
6540
|
-
throw error;
|
|
6541
|
-
}
|
|
6542
|
-
}
|
|
6543
|
-
async save(data) {
|
|
6544
|
-
const logger = this.logger.with('save');
|
|
6545
|
-
const req = {
|
|
6546
|
-
url: `${this.config.url}/sync`,
|
|
6547
|
-
method: 'POST',
|
|
6548
|
-
responseType: 'json',
|
|
6549
|
-
headers: {
|
|
6550
|
-
Accept: 'application/json',
|
|
6551
|
-
},
|
|
6552
|
-
data,
|
|
6553
|
-
};
|
|
6554
|
-
try {
|
|
6555
|
-
const { data } = await axios__default["default"](req);
|
|
6556
|
-
return data;
|
|
6557
|
-
}
|
|
6558
|
-
catch (error) {
|
|
6559
|
-
logger.error({ req, res: error });
|
|
6560
|
-
throw error;
|
|
6561
|
-
}
|
|
6562
|
-
}
|
|
6563
|
-
async update(id, data) {
|
|
6564
|
-
const logger = this.logger.with('update');
|
|
6565
|
-
const req = {
|
|
6566
|
-
url: `${this.config.url}/${id}`,
|
|
6567
|
-
method: 'PUT',
|
|
6568
|
-
responseType: 'json',
|
|
6569
|
-
headers: {
|
|
6570
|
-
Accept: 'application/json',
|
|
6571
|
-
},
|
|
6572
|
-
data,
|
|
6573
|
-
};
|
|
6574
|
-
try {
|
|
6575
|
-
const { data } = await axios__default["default"](req);
|
|
6576
|
-
return data;
|
|
6577
|
-
}
|
|
6578
|
-
catch (error) {
|
|
6579
|
-
logger.error({ req, res: error });
|
|
6580
|
-
throw error;
|
|
6581
|
-
}
|
|
6582
|
-
}
|
|
6583
|
-
async delete(id) {
|
|
6584
|
-
const logger = this.logger.with('delete');
|
|
6585
|
-
const req = {
|
|
6586
|
-
url: `${this.config.url}/${id}`,
|
|
6587
|
-
method: 'DELETE',
|
|
6588
|
-
responseType: 'json',
|
|
6589
|
-
headers: {
|
|
6590
|
-
Accept: 'application/json',
|
|
6591
|
-
},
|
|
6592
|
-
};
|
|
6593
|
-
try {
|
|
6594
|
-
const { data } = await axios__default["default"](req);
|
|
6595
|
-
return data;
|
|
6596
|
-
}
|
|
6597
|
-
catch (error) {
|
|
6598
|
-
logger.error({ req, res: error });
|
|
6599
|
-
throw error;
|
|
6600
|
-
}
|
|
6601
|
-
}
|
|
6602
|
-
bulkProducts(products) {
|
|
6603
|
-
return;
|
|
6604
|
-
}
|
|
6605
|
-
}
|
|
6606
|
-
|
|
6607
|
-
class ProductsVertexSearch {
|
|
6608
|
-
constructor(adapter) {
|
|
6609
|
-
this.adapter = adapter;
|
|
6610
|
-
}
|
|
6611
|
-
async getById(id) {
|
|
6612
|
-
const data = await this.adapter.get(id);
|
|
6613
|
-
return data;
|
|
6614
|
-
}
|
|
6615
|
-
async search(searchTerm, total, gender) {
|
|
6616
|
-
try {
|
|
6617
|
-
const result = await this.adapter.query(searchTerm, total, gender);
|
|
6618
|
-
return result;
|
|
6619
|
-
}
|
|
6620
|
-
catch (error) {
|
|
6621
|
-
console.error(error);
|
|
6622
|
-
}
|
|
6623
|
-
}
|
|
6624
|
-
async save(product) {
|
|
6625
|
-
try {
|
|
6626
|
-
const _a = product.toPlain(), { createdAt, updatedAt, kitProducts } = _a, data = tslib.__rest(_a, ["createdAt", "updatedAt", "kitProducts"]);
|
|
6627
|
-
const newProduct = Product.toInstance(data);
|
|
6628
|
-
await this.adapter.save(newProduct);
|
|
6629
|
-
}
|
|
6630
|
-
catch (error) {
|
|
6631
|
-
console.error(error);
|
|
6632
|
-
}
|
|
6633
|
-
}
|
|
6634
|
-
async update(product) {
|
|
6635
|
-
try {
|
|
6636
|
-
await this.adapter.update(product.id, product);
|
|
6637
|
-
}
|
|
6638
|
-
catch (error) {
|
|
6639
|
-
console.error(error);
|
|
6640
|
-
}
|
|
6641
|
-
}
|
|
6642
|
-
async delete(id) {
|
|
6643
|
-
try {
|
|
6644
|
-
await this.adapter.delete(id);
|
|
6645
|
-
}
|
|
6646
|
-
catch (error) {
|
|
6647
|
-
console.error(error);
|
|
6648
|
-
}
|
|
6649
|
-
}
|
|
6650
|
-
}
|
|
6651
6175
|
|
|
6652
6176
|
Object.defineProperty(exports, 'add', {
|
|
6653
6177
|
enumerable: true,
|
|
@@ -6820,13 +6344,9 @@ exports.LeadFirestoreRepository = LeadFirestoreRepository;
|
|
|
6820
6344
|
exports.LegacyOrderFirestoreRepository = LegacyOrderFirestoreRepository;
|
|
6821
6345
|
exports.LineItem = LineItem;
|
|
6822
6346
|
exports.Log = Log;
|
|
6823
|
-
exports.LogDocument = LogDocument;
|
|
6824
|
-
exports.LogFirestoreRepository = LogFirestoreRepository;
|
|
6825
6347
|
exports.Logger = Logger;
|
|
6826
6348
|
exports.NotFoundError = NotFoundError;
|
|
6827
6349
|
exports.Order = Order;
|
|
6828
|
-
exports.OrderBlocked = OrderBlocked;
|
|
6829
|
-
exports.OrderBlockedFirestoreRepository = OrderBlockedFirestoreRepository;
|
|
6830
6350
|
exports.OrderFirestoreRepository = OrderFirestoreRepository;
|
|
6831
6351
|
exports.Payment = Payment;
|
|
6832
6352
|
exports.PaymentFirestoreRepository = PaymentFirestoreRepository;
|
|
@@ -6840,7 +6360,6 @@ exports.ProductStockNotification = ProductStockNotification;
|
|
|
6840
6360
|
exports.ProductStockNotificationHasuraGraphQLRepository = ProductStockNotificationHasuraGraphQLRepository;
|
|
6841
6361
|
exports.ProductVariantFirestoreRepository = ProductVariantFirestoreRepository;
|
|
6842
6362
|
exports.ProductsIndex = ProductsIndex;
|
|
6843
|
-
exports.ProductsVertexSearch = ProductsVertexSearch;
|
|
6844
6363
|
exports.RecoveryPassword = RecoveryPassword;
|
|
6845
6364
|
exports.ReflectHelper = ReflectHelper;
|
|
6846
6365
|
exports.Register = Register;
|
|
@@ -6879,7 +6398,6 @@ exports.UserPaymentMethodFirestoreRepository = UserPaymentMethodFirestoreReposit
|
|
|
6879
6398
|
exports.Variant = Variant;
|
|
6880
6399
|
exports.VariantHasuraGraphQL = VariantHasuraGraphQL;
|
|
6881
6400
|
exports.VariantHasuraGraphQLRepository = VariantHasuraGraphQLRepository;
|
|
6882
|
-
exports.VertexAxiosAdapter = VertexAxiosAdapter;
|
|
6883
6401
|
exports.WeakPasswordError = WeakPasswordError;
|
|
6884
6402
|
exports.Wishlist = Wishlist;
|
|
6885
6403
|
exports.WishlistHasuraGraphQLRepository = WishlistHasuraGraphQLRepository;
|