@infrab4a/connect 4.9.7-beta.24 → 4.9.7-beta.26
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 +430 -396
- package/index.esm.js +429 -397
- package/package.json +1 -1
- package/src/domain/catalog/models/enums/index.d.ts +1 -0
- package/src/domain/catalog/models/enums/wishlist-log.enum.d.ts +7 -0
- package/src/domain/catalog/repositories/category.repository.d.ts +2 -2
- package/src/domain/general/index.d.ts +2 -0
- package/src/domain/general/models/index.d.ts +1 -0
- package/src/domain/general/models/log-document.d.ts +15 -0
- package/src/domain/general/repositories/index.d.ts +1 -0
- package/src/domain/general/repositories/log.repository.d.ts +4 -0
- package/src/domain/shopping/models/coupons/coupon.d.ts +1 -1
- package/src/domain/shopping/models/coupons/enums/coupon-category.enum.d.ts +3 -2
- package/src/infra/firebase/firestore/repositories/catalog/category-firestore.repository.d.ts +2 -2
- package/src/infra/firebase/firestore/repositories/general/index.d.ts +1 -0
- package/src/infra/firebase/firestore/repositories/general/log-firestore.repository.d.ts +7 -0
- package/src/infra/firebase/firestore/repositories/index.d.ts +3 -2
- package/src/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.d.ts +2 -2
- package/src/infra/hasura-graphql/repositories/catalog/wishlist-hasura-graphql.repository.d.ts +2 -2
- package/src/infra/vertex-ai/adapters/vertex-ai-search.adapter.d.ts +3 -2
- package/src/infra/vertex-ai/adapters/vertex-axios.adapter.d.ts +2 -1
- package/src/infra/vertex-ai/types/index.d.ts +1 -0
- package/src/infra/vertex-ai/types/product-bulk.d.ts +4 -0
package/index.esm.js
CHANGED
|
@@ -51,6 +51,15 @@ var Shops;
|
|
|
51
51
|
Shops["ALL"] = "ALL";
|
|
52
52
|
})(Shops || (Shops = {}));
|
|
53
53
|
|
|
54
|
+
var WishlistLogType;
|
|
55
|
+
(function (WishlistLogType) {
|
|
56
|
+
WishlistLogType["CREATE"] = "create";
|
|
57
|
+
WishlistLogType["UPDATE"] = "update";
|
|
58
|
+
WishlistLogType["DELETE"] = "delete";
|
|
59
|
+
WishlistLogType["ADD_PRODUCT"] = "add_product";
|
|
60
|
+
WishlistLogType["REMOVE_PRODUCT"] = "remove_product";
|
|
61
|
+
})(WishlistLogType || (WishlistLogType = {}));
|
|
62
|
+
|
|
54
63
|
class Filter extends BaseModel {
|
|
55
64
|
static get identifiersFields() {
|
|
56
65
|
return ['id'];
|
|
@@ -1837,55 +1846,6 @@ const parseDateTime = (value) => {
|
|
|
1837
1846
|
return date;
|
|
1838
1847
|
};
|
|
1839
1848
|
|
|
1840
|
-
var CheckoutTypes;
|
|
1841
|
-
(function (CheckoutTypes) {
|
|
1842
|
-
CheckoutTypes[CheckoutTypes["ECOMMERCE"] = 1] = "ECOMMERCE";
|
|
1843
|
-
CheckoutTypes[CheckoutTypes["SUBSCRIPTION"] = 2] = "SUBSCRIPTION";
|
|
1844
|
-
CheckoutTypes[CheckoutTypes["ALL"] = 3] = "ALL";
|
|
1845
|
-
})(CheckoutTypes || (CheckoutTypes = {}));
|
|
1846
|
-
|
|
1847
|
-
var CouponCategory;
|
|
1848
|
-
(function (CouponCategory) {
|
|
1849
|
-
CouponCategory["Reembolso"] = "Reembolso";
|
|
1850
|
-
CouponCategory["Desculpas"] = "Desculpas";
|
|
1851
|
-
CouponCategory["BFlu"] = "BFlu";
|
|
1852
|
-
CouponCategory["ROYAL"] = "Royal";
|
|
1853
|
-
CouponCategory["Glamqueens"] = "Glamqueens";
|
|
1854
|
-
CouponCategory["Glamgirls"] = "Glamgirls";
|
|
1855
|
-
CouponCategory["Glamdiva"] = "Glamdiva";
|
|
1856
|
-
CouponCategory["Impulsionamento"] = "Impulsionamento";
|
|
1857
|
-
CouponCategory["PaidMedia"] = "Paid Media";
|
|
1858
|
-
CouponCategory["Organic"] = "Organic";
|
|
1859
|
-
CouponCategory["Direct"] = "Direct";
|
|
1860
|
-
CouponCategory["CRM"] = "CRM";
|
|
1861
|
-
CouponCategory["LOJAUNICO"] = "Loja \u00FAnico";
|
|
1862
|
-
CouponCategory["Outros"] = "Outros";
|
|
1863
|
-
})(CouponCategory || (CouponCategory = {}));
|
|
1864
|
-
|
|
1865
|
-
var CouponSubtypes;
|
|
1866
|
-
(function (CouponSubtypes) {
|
|
1867
|
-
CouponSubtypes[CouponSubtypes["ABSOLUTE"] = 1] = "ABSOLUTE";
|
|
1868
|
-
CouponSubtypes[CouponSubtypes["PERCENTAGE"] = 2] = "PERCENTAGE";
|
|
1869
|
-
})(CouponSubtypes || (CouponSubtypes = {}));
|
|
1870
|
-
|
|
1871
|
-
var CouponTypes;
|
|
1872
|
-
(function (CouponTypes) {
|
|
1873
|
-
CouponTypes[CouponTypes["ABSOLUTE"] = 1] = "ABSOLUTE";
|
|
1874
|
-
CouponTypes[CouponTypes["PERCENTAGE"] = 2] = "PERCENTAGE";
|
|
1875
|
-
CouponTypes[CouponTypes["SHIPPING"] = 3] = "SHIPPING";
|
|
1876
|
-
})(CouponTypes || (CouponTypes = {}));
|
|
1877
|
-
|
|
1878
|
-
var Exclusivities;
|
|
1879
|
-
(function (Exclusivities) {
|
|
1880
|
-
Exclusivities[Exclusivities["ALL_USERS"] = 1] = "ALL_USERS";
|
|
1881
|
-
Exclusivities[Exclusivities["SPECIFIC_USER"] = 2] = "SPECIFIC_USER";
|
|
1882
|
-
Exclusivities[Exclusivities["COLLABORATORS"] = 3] = "COLLABORATORS";
|
|
1883
|
-
Exclusivities[Exclusivities["ACTIVE_SUBSCRIBER"] = 4] = "ACTIVE_SUBSCRIBER";
|
|
1884
|
-
Exclusivities[Exclusivities["INACTIVE_SUBSCRIBER"] = 5] = "INACTIVE_SUBSCRIBER";
|
|
1885
|
-
Exclusivities[Exclusivities["NON_SUBSCRIBER"] = 6] = "NON_SUBSCRIBER";
|
|
1886
|
-
})(Exclusivities || (Exclusivities = {}));
|
|
1887
|
-
|
|
1888
|
-
const COUPON_EXPIRATION = +1000 * 60 * 60 * 24 * 30;
|
|
1889
1849
|
class Coupon extends BaseModel {
|
|
1890
1850
|
get isInfluencer() {
|
|
1891
1851
|
return !isNil(this.influencerEmail);
|
|
@@ -1893,30 +1853,6 @@ class Coupon extends BaseModel {
|
|
|
1893
1853
|
static get identifiersFields() {
|
|
1894
1854
|
return ['id'];
|
|
1895
1855
|
}
|
|
1896
|
-
static createCoupon(userId) {
|
|
1897
|
-
return this.toInstance({
|
|
1898
|
-
nickname: `${Date.now()}`,
|
|
1899
|
-
checkoutType: CheckoutTypes.ECOMMERCE,
|
|
1900
|
-
discount: {
|
|
1901
|
-
subscriber: {
|
|
1902
|
-
type: CouponTypes.ABSOLUTE,
|
|
1903
|
-
value: 10,
|
|
1904
|
-
},
|
|
1905
|
-
non_subscriber: {
|
|
1906
|
-
type: CouponTypes.ABSOLUTE,
|
|
1907
|
-
value: 10,
|
|
1908
|
-
},
|
|
1909
|
-
subscription: {
|
|
1910
|
-
type: CouponTypes.ABSOLUTE,
|
|
1911
|
-
value: 10,
|
|
1912
|
-
},
|
|
1913
|
-
},
|
|
1914
|
-
user: userId,
|
|
1915
|
-
createdAt: new Date(Date.now()),
|
|
1916
|
-
beginAt: new Date(Date.now()),
|
|
1917
|
-
expiresIn: new Date(Date.now() + COUPON_EXPIRATION),
|
|
1918
|
-
});
|
|
1919
|
-
}
|
|
1920
1856
|
}
|
|
1921
1857
|
|
|
1922
1858
|
class SubscriptionPlan extends BaseModel {
|
|
@@ -2191,6 +2127,55 @@ __decorate([
|
|
|
2191
2127
|
__metadata("design:type", Coupon)
|
|
2192
2128
|
], Checkout.prototype, "coupon", void 0);
|
|
2193
2129
|
|
|
2130
|
+
var CouponCategory;
|
|
2131
|
+
(function (CouponCategory) {
|
|
2132
|
+
CouponCategory["Reembolso"] = "Reembolso";
|
|
2133
|
+
CouponCategory["Desculpas"] = "Desculpas";
|
|
2134
|
+
CouponCategory["BFlu"] = "BFlu";
|
|
2135
|
+
CouponCategory["ROYAL"] = "Royal";
|
|
2136
|
+
CouponCategory["Glamqueen"] = "Glamqueen";
|
|
2137
|
+
CouponCategory["Glampartner"] = "Glampartner";
|
|
2138
|
+
CouponCategory["Glamgirl"] = "Glamgirl";
|
|
2139
|
+
CouponCategory["Glamdiva"] = "Glamdiva";
|
|
2140
|
+
CouponCategory["Impulsionamento"] = "Impulsionamento";
|
|
2141
|
+
CouponCategory["PaidMedia"] = "Paid Media";
|
|
2142
|
+
CouponCategory["Organic"] = "Organic";
|
|
2143
|
+
CouponCategory["Direct"] = "Direct";
|
|
2144
|
+
CouponCategory["CRM"] = "CRM";
|
|
2145
|
+
CouponCategory["LOJAUNICO"] = "Loja \u00FAnico";
|
|
2146
|
+
CouponCategory["Outros"] = "Outros";
|
|
2147
|
+
})(CouponCategory || (CouponCategory = {}));
|
|
2148
|
+
|
|
2149
|
+
var CouponSubtypes;
|
|
2150
|
+
(function (CouponSubtypes) {
|
|
2151
|
+
CouponSubtypes[CouponSubtypes["ABSOLUTE"] = 1] = "ABSOLUTE";
|
|
2152
|
+
CouponSubtypes[CouponSubtypes["PERCENTAGE"] = 2] = "PERCENTAGE";
|
|
2153
|
+
})(CouponSubtypes || (CouponSubtypes = {}));
|
|
2154
|
+
|
|
2155
|
+
var CouponTypes;
|
|
2156
|
+
(function (CouponTypes) {
|
|
2157
|
+
CouponTypes[CouponTypes["ABSOLUTE"] = 1] = "ABSOLUTE";
|
|
2158
|
+
CouponTypes[CouponTypes["PERCENTAGE"] = 2] = "PERCENTAGE";
|
|
2159
|
+
CouponTypes[CouponTypes["SHIPPING"] = 3] = "SHIPPING";
|
|
2160
|
+
})(CouponTypes || (CouponTypes = {}));
|
|
2161
|
+
|
|
2162
|
+
var Exclusivities;
|
|
2163
|
+
(function (Exclusivities) {
|
|
2164
|
+
Exclusivities[Exclusivities["ALL_USERS"] = 1] = "ALL_USERS";
|
|
2165
|
+
Exclusivities[Exclusivities["SPECIFIC_USER"] = 2] = "SPECIFIC_USER";
|
|
2166
|
+
Exclusivities[Exclusivities["COLLABORATORS"] = 3] = "COLLABORATORS";
|
|
2167
|
+
Exclusivities[Exclusivities["ACTIVE_SUBSCRIBER"] = 4] = "ACTIVE_SUBSCRIBER";
|
|
2168
|
+
Exclusivities[Exclusivities["INACTIVE_SUBSCRIBER"] = 5] = "INACTIVE_SUBSCRIBER";
|
|
2169
|
+
Exclusivities[Exclusivities["NON_SUBSCRIBER"] = 6] = "NON_SUBSCRIBER";
|
|
2170
|
+
})(Exclusivities || (Exclusivities = {}));
|
|
2171
|
+
|
|
2172
|
+
var CheckoutTypes;
|
|
2173
|
+
(function (CheckoutTypes) {
|
|
2174
|
+
CheckoutTypes[CheckoutTypes["ECOMMERCE"] = 1] = "ECOMMERCE";
|
|
2175
|
+
CheckoutTypes[CheckoutTypes["SUBSCRIPTION"] = 2] = "SUBSCRIPTION";
|
|
2176
|
+
CheckoutTypes[CheckoutTypes["ALL"] = 3] = "ALL";
|
|
2177
|
+
})(CheckoutTypes || (CheckoutTypes = {}));
|
|
2178
|
+
|
|
2194
2179
|
var OrderStatus;
|
|
2195
2180
|
(function (OrderStatus) {
|
|
2196
2181
|
OrderStatus["AGUARDANDO_PAGAMENTO"] = "Aguardando pagamento";
|
|
@@ -2252,6 +2237,12 @@ class RoundProductPricesHelper {
|
|
|
2252
2237
|
}
|
|
2253
2238
|
}
|
|
2254
2239
|
|
|
2240
|
+
class LogDocument extends BaseModel {
|
|
2241
|
+
static get identifiersFields() {
|
|
2242
|
+
return ['id'];
|
|
2243
|
+
}
|
|
2244
|
+
}
|
|
2245
|
+
|
|
2255
2246
|
var FilterType;
|
|
2256
2247
|
(function (FilterType) {
|
|
2257
2248
|
FilterType["ACCESSORY_IMPORTANCE"] = "accessoryImportance";
|
|
@@ -3119,278 +3110,104 @@ const withCrudFirestore = (MixinBase) => {
|
|
|
3119
3110
|
};
|
|
3120
3111
|
};
|
|
3121
3112
|
|
|
3122
|
-
class
|
|
3113
|
+
class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3123
3114
|
constructor({ firestore, interceptors }) {
|
|
3124
3115
|
super({
|
|
3125
3116
|
firestore,
|
|
3126
|
-
collectionName: '
|
|
3127
|
-
model:
|
|
3117
|
+
collectionName: 'categories',
|
|
3118
|
+
model: Category,
|
|
3128
3119
|
interceptors,
|
|
3129
3120
|
});
|
|
3130
3121
|
}
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
this.parentRepository = parentRepository;
|
|
3122
|
+
async getCategoryBySlug(slug, shop) {
|
|
3123
|
+
const categoryDocs = await this.collection(this.collectionName)
|
|
3124
|
+
.where('slug', '==', slug)
|
|
3125
|
+
.where('shop', '==', shop)
|
|
3126
|
+
.where('published', '==', true)
|
|
3127
|
+
.getDocs();
|
|
3128
|
+
if (categoryDocs.size > 1)
|
|
3129
|
+
throw new DuplicatedResultsError('Query returned duplicated values');
|
|
3130
|
+
if (categoryDocs.empty)
|
|
3131
|
+
throw new NotFoundError(`Document with slug ${slug} not found`);
|
|
3132
|
+
return categoryDocs.docs[0].data();
|
|
3143
3133
|
}
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3134
|
+
async getCategoriesForHome(categoryIds, shop, limit = 4) {
|
|
3135
|
+
const categorySnap = await this.collection(this.collectionName)
|
|
3136
|
+
.where('id', 'in', categoryIds.filter(Boolean))
|
|
3137
|
+
.where('published', '==', true)
|
|
3138
|
+
.getDocs();
|
|
3139
|
+
if (categorySnap.empty)
|
|
3140
|
+
throw new NotFoundError('Categories not found');
|
|
3141
|
+
const categories = categorySnap.docs.map((doc) => doc.data());
|
|
3142
|
+
const homeSections = await Promise.all(categories.map(async (category) => ({
|
|
3143
|
+
category,
|
|
3144
|
+
products: await this.mountCategory(category, shop, { limit, hasStock: true }),
|
|
3145
|
+
})));
|
|
3146
|
+
return homeSections;
|
|
3154
3147
|
}
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3148
|
+
async mountCategory(category, shop, options) {
|
|
3149
|
+
if (!category.products)
|
|
3150
|
+
throw new RequiredArgumentError(['Category products is empty']);
|
|
3151
|
+
const chunks = chunk(category.products, 10);
|
|
3152
|
+
const products = [];
|
|
3153
|
+
const wheres = [];
|
|
3154
|
+
for (const productIds of chunks) {
|
|
3155
|
+
if ((options === null || options === void 0 ? void 0 : options.limit) && products.length >= (options === null || options === void 0 ? void 0 : options.limit))
|
|
3156
|
+
break;
|
|
3157
|
+
wheres.push(['published', '==', true], ['id', 'in', productIds]);
|
|
3158
|
+
if (options === null || options === void 0 ? void 0 : options.hasStock)
|
|
3159
|
+
wheres.push(['stock.quantity', '>', 0]);
|
|
3160
|
+
if (options === null || options === void 0 ? void 0 : options.gender)
|
|
3161
|
+
wheres.push(['tags', 'array-contains', options === null || options === void 0 ? void 0 : options.gender]);
|
|
3162
|
+
const productSnap = await wheres
|
|
3163
|
+
.reduce((collection, where) => collection.where(...where), (options === null || options === void 0 ? void 0 : options.limit)
|
|
3164
|
+
? this.collection('productsErpVitrine').limit(options.limit)
|
|
3165
|
+
: this.collection('productsErpVitrine'))
|
|
3166
|
+
.getDocs();
|
|
3167
|
+
if (productSnap.empty)
|
|
3168
|
+
continue;
|
|
3169
|
+
products.push(...productSnap.docs);
|
|
3170
|
+
}
|
|
3171
|
+
return is(products);
|
|
3165
3172
|
}
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3169
|
-
constructor({ firestore, interceptors }, parentRepository) {
|
|
3170
|
-
super({
|
|
3171
|
-
firestore,
|
|
3172
|
-
collectionName: 'payments',
|
|
3173
|
-
parentIdField: 'subscriptionId',
|
|
3174
|
-
model: SubscriptionPayment,
|
|
3175
|
-
interceptors,
|
|
3176
|
-
});
|
|
3177
|
-
this.parentRepository = parentRepository;
|
|
3173
|
+
getCategoryByShop(shop) {
|
|
3174
|
+
return;
|
|
3178
3175
|
}
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
class SubscriptionSummaryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3182
|
-
constructor({ firestore, interceptors, }) {
|
|
3183
|
-
super({
|
|
3184
|
-
firestore,
|
|
3185
|
-
collectionName: 'subscriptionSummary',
|
|
3186
|
-
model: SubscriptionSummary,
|
|
3187
|
-
interceptors,
|
|
3188
|
-
});
|
|
3176
|
+
getChildren(parentId) {
|
|
3177
|
+
return;
|
|
3189
3178
|
}
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3193
|
-
constructor({ firestore, interceptors }, parentRepository) {
|
|
3194
|
-
super({
|
|
3195
|
-
firestore,
|
|
3196
|
-
collectionName: 'address',
|
|
3197
|
-
parentIdField: 'userId',
|
|
3198
|
-
model: UserAddress,
|
|
3199
|
-
interceptors,
|
|
3200
|
-
});
|
|
3201
|
-
this.parentRepository = parentRepository;
|
|
3179
|
+
isChild(id, parentId) {
|
|
3180
|
+
return;
|
|
3202
3181
|
}
|
|
3203
3182
|
}
|
|
3183
|
+
__decorate([
|
|
3184
|
+
Log(),
|
|
3185
|
+
__metadata("design:type", Function),
|
|
3186
|
+
__metadata("design:paramtypes", [String, String]),
|
|
3187
|
+
__metadata("design:returntype", Promise)
|
|
3188
|
+
], CategoryFirestoreRepository.prototype, "getCategoryBySlug", null);
|
|
3189
|
+
__decorate([
|
|
3190
|
+
Log(),
|
|
3191
|
+
__metadata("design:type", Function),
|
|
3192
|
+
__metadata("design:paramtypes", [Array, String, Object]),
|
|
3193
|
+
__metadata("design:returntype", Promise)
|
|
3194
|
+
], CategoryFirestoreRepository.prototype, "getCategoriesForHome", null);
|
|
3195
|
+
__decorate([
|
|
3196
|
+
Log(),
|
|
3197
|
+
__metadata("design:type", Function),
|
|
3198
|
+
__metadata("design:paramtypes", [Category, String, Object]),
|
|
3199
|
+
__metadata("design:returntype", Promise)
|
|
3200
|
+
], CategoryFirestoreRepository.prototype, "mountCategory", null);
|
|
3204
3201
|
|
|
3205
|
-
class
|
|
3206
|
-
constructor({ firestore, interceptors }
|
|
3202
|
+
class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3203
|
+
constructor({ firestore, interceptors }) {
|
|
3207
3204
|
super({
|
|
3208
3205
|
firestore,
|
|
3209
|
-
collectionName: '
|
|
3210
|
-
|
|
3211
|
-
model: BeautyProfile,
|
|
3206
|
+
collectionName: 'productsErpVitrine',
|
|
3207
|
+
model: Product,
|
|
3212
3208
|
interceptors,
|
|
3213
3209
|
});
|
|
3214
|
-
this.
|
|
3215
|
-
}
|
|
3216
|
-
}
|
|
3217
|
-
|
|
3218
|
-
class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3219
|
-
constructor({ firestore, interceptors }) {
|
|
3220
|
-
super({
|
|
3221
|
-
firestore,
|
|
3222
|
-
collectionName: 'users',
|
|
3223
|
-
model: User,
|
|
3224
|
-
interceptors,
|
|
3225
|
-
});
|
|
3226
|
-
}
|
|
3227
|
-
async get(identifiers) {
|
|
3228
|
-
const user = await super.get({ id: identifiers.id });
|
|
3229
|
-
user.beautyProfile = await this.getBeautyProfile(user.id);
|
|
3230
|
-
user.isSubscriber = await this.checkIfIsSubscriber(user.id);
|
|
3231
|
-
return user;
|
|
3232
|
-
}
|
|
3233
|
-
async checkIfExistsByField(field, value) {
|
|
3234
|
-
const result = await this.find({ filters: { [field]: value } });
|
|
3235
|
-
return result.count > 0;
|
|
3236
|
-
}
|
|
3237
|
-
buildModelInstance() {
|
|
3238
|
-
const { fromFirestore, toFirestore } = super.buildModelInstance();
|
|
3239
|
-
return {
|
|
3240
|
-
toFirestore: (data) => {
|
|
3241
|
-
const plain = toFirestore(data);
|
|
3242
|
-
delete plain.isSubscriber;
|
|
3243
|
-
return plain;
|
|
3244
|
-
},
|
|
3245
|
-
fromFirestore,
|
|
3246
|
-
};
|
|
3247
|
-
}
|
|
3248
|
-
async getBeautyProfile(userId) {
|
|
3249
|
-
const beautyProfile = await this.firestore
|
|
3250
|
-
.getCollection(`${this.collectionName}/${userId}/CX`)
|
|
3251
|
-
.withConverter(this.buildBeautyProfileModelInstance())
|
|
3252
|
-
.getDoc('beautyProfile')
|
|
3253
|
-
.get();
|
|
3254
|
-
return beautyProfile.data();
|
|
3255
|
-
}
|
|
3256
|
-
async checkIfIsSubscriber(userId) {
|
|
3257
|
-
const docs = await this.collection('subscription')
|
|
3258
|
-
.where('user.id', '==', userId)
|
|
3259
|
-
.where('status', '==', 'active')
|
|
3260
|
-
.getDocs();
|
|
3261
|
-
return !!docs && !!docs.size;
|
|
3262
|
-
}
|
|
3263
|
-
buildBeautyProfileModelInstance() {
|
|
3264
|
-
return {
|
|
3265
|
-
toFirestore: (data) => data.toPlain(),
|
|
3266
|
-
fromFirestore: (snap) => BeautyProfile.toInstance(snap.data()),
|
|
3267
|
-
};
|
|
3268
|
-
}
|
|
3269
|
-
}
|
|
3270
|
-
__decorate([
|
|
3271
|
-
Log(),
|
|
3272
|
-
__metadata("design:type", Function),
|
|
3273
|
-
__metadata("design:paramtypes", [Object]),
|
|
3274
|
-
__metadata("design:returntype", Promise)
|
|
3275
|
-
], UserFirestoreRepository.prototype, "get", null);
|
|
3276
|
-
__decorate([
|
|
3277
|
-
Log(),
|
|
3278
|
-
__metadata("design:type", Function),
|
|
3279
|
-
__metadata("design:paramtypes", [String, String]),
|
|
3280
|
-
__metadata("design:returntype", Promise)
|
|
3281
|
-
], UserFirestoreRepository.prototype, "checkIfExistsByField", null);
|
|
3282
|
-
|
|
3283
|
-
class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3284
|
-
constructor({ firestore, interceptors }, parentRepository) {
|
|
3285
|
-
super({
|
|
3286
|
-
firestore,
|
|
3287
|
-
collectionName: 'payment_method',
|
|
3288
|
-
parentIdField: 'userId',
|
|
3289
|
-
model: UserPaymentMethod,
|
|
3290
|
-
interceptors,
|
|
3291
|
-
});
|
|
3292
|
-
this.parentRepository = parentRepository;
|
|
3293
|
-
}
|
|
3294
|
-
}
|
|
3295
|
-
|
|
3296
|
-
class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3297
|
-
constructor({ firestore, interceptors }) {
|
|
3298
|
-
super({
|
|
3299
|
-
firestore,
|
|
3300
|
-
collectionName: 'categories',
|
|
3301
|
-
model: Category,
|
|
3302
|
-
interceptors,
|
|
3303
|
-
});
|
|
3304
|
-
}
|
|
3305
|
-
async getCategoryBySlug(slug, shop) {
|
|
3306
|
-
const categoryDocs = await this.collection(this.collectionName)
|
|
3307
|
-
.where('slug', '==', slug)
|
|
3308
|
-
.where('shop', '==', shop)
|
|
3309
|
-
.where('published', '==', true)
|
|
3310
|
-
.getDocs();
|
|
3311
|
-
if (categoryDocs.size > 1)
|
|
3312
|
-
throw new DuplicatedResultsError('Query returned duplicated values');
|
|
3313
|
-
if (categoryDocs.empty)
|
|
3314
|
-
throw new NotFoundError(`Document with slug ${slug} not found`);
|
|
3315
|
-
return categoryDocs.docs[0].data();
|
|
3316
|
-
}
|
|
3317
|
-
async getCategoriesForHome(categoryIds, limit = 4, gender) {
|
|
3318
|
-
const categorySnap = await this.collection(this.collectionName)
|
|
3319
|
-
.where('id', 'in', categoryIds.filter(Boolean))
|
|
3320
|
-
.where('published', '==', true)
|
|
3321
|
-
.getDocs();
|
|
3322
|
-
if (categorySnap.empty)
|
|
3323
|
-
throw new NotFoundError('Categories not found');
|
|
3324
|
-
const categories = categorySnap.docs.map((doc) => doc.data());
|
|
3325
|
-
const homeSections = await Promise.all(categories.map(async (category) => ({
|
|
3326
|
-
category,
|
|
3327
|
-
products: await this.mountCategory(category, { limit, hasStock: true, gender }),
|
|
3328
|
-
})));
|
|
3329
|
-
return homeSections;
|
|
3330
|
-
}
|
|
3331
|
-
async mountCategory(category, options) {
|
|
3332
|
-
if (!category.products)
|
|
3333
|
-
throw new RequiredArgumentError(['Category products is empty']);
|
|
3334
|
-
const chunks = chunk(category.products, 10);
|
|
3335
|
-
const products = [];
|
|
3336
|
-
const wheres = [];
|
|
3337
|
-
for (const productIds of chunks) {
|
|
3338
|
-
if ((options === null || options === void 0 ? void 0 : options.limit) && products.length >= (options === null || options === void 0 ? void 0 : options.limit))
|
|
3339
|
-
break;
|
|
3340
|
-
wheres.push(['published', '==', true], ['id', 'in', productIds]);
|
|
3341
|
-
if (options === null || options === void 0 ? void 0 : options.hasStock)
|
|
3342
|
-
wheres.push(['stock.quantity', '>', 0]);
|
|
3343
|
-
if (options === null || options === void 0 ? void 0 : options.gender)
|
|
3344
|
-
wheres.push(['tags', 'array-contains', options === null || options === void 0 ? void 0 : options.gender]);
|
|
3345
|
-
const productSnap = await wheres
|
|
3346
|
-
.reduce((collection, where) => collection.where(...where), (options === null || options === void 0 ? void 0 : options.limit)
|
|
3347
|
-
? this.collection('productsErpVitrine').limit(options.limit)
|
|
3348
|
-
: this.collection('productsErpVitrine'))
|
|
3349
|
-
.getDocs();
|
|
3350
|
-
if (productSnap.empty)
|
|
3351
|
-
continue;
|
|
3352
|
-
products.push(...productSnap.docs);
|
|
3353
|
-
}
|
|
3354
|
-
return is(products);
|
|
3355
|
-
}
|
|
3356
|
-
getCategoryByShop(shop) {
|
|
3357
|
-
return;
|
|
3358
|
-
}
|
|
3359
|
-
getChildren(parentId) {
|
|
3360
|
-
return;
|
|
3361
|
-
}
|
|
3362
|
-
isChild(id, parentId) {
|
|
3363
|
-
return;
|
|
3364
|
-
}
|
|
3365
|
-
}
|
|
3366
|
-
__decorate([
|
|
3367
|
-
Log(),
|
|
3368
|
-
__metadata("design:type", Function),
|
|
3369
|
-
__metadata("design:paramtypes", [String, String]),
|
|
3370
|
-
__metadata("design:returntype", Promise)
|
|
3371
|
-
], CategoryFirestoreRepository.prototype, "getCategoryBySlug", null);
|
|
3372
|
-
__decorate([
|
|
3373
|
-
Log(),
|
|
3374
|
-
__metadata("design:type", Function),
|
|
3375
|
-
__metadata("design:paramtypes", [Array, Object, String]),
|
|
3376
|
-
__metadata("design:returntype", Promise)
|
|
3377
|
-
], CategoryFirestoreRepository.prototype, "getCategoriesForHome", null);
|
|
3378
|
-
__decorate([
|
|
3379
|
-
Log(),
|
|
3380
|
-
__metadata("design:type", Function),
|
|
3381
|
-
__metadata("design:paramtypes", [Category, Object]),
|
|
3382
|
-
__metadata("design:returntype", Promise)
|
|
3383
|
-
], CategoryFirestoreRepository.prototype, "mountCategory", null);
|
|
3384
|
-
|
|
3385
|
-
class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3386
|
-
constructor({ firestore, interceptors }) {
|
|
3387
|
-
super({
|
|
3388
|
-
firestore,
|
|
3389
|
-
collectionName: 'productsErpVitrine',
|
|
3390
|
-
model: Product,
|
|
3391
|
-
interceptors,
|
|
3392
|
-
});
|
|
3393
|
-
this.reviews = {};
|
|
3210
|
+
this.reviews = {};
|
|
3394
3211
|
}
|
|
3395
3212
|
fetchProductReviews(filters) {
|
|
3396
3213
|
throw new Error('Method not implemented.');
|
|
@@ -3477,6 +3294,101 @@ class SubscriptionProductFirestoreRepository extends withCrudFirestore(withHelpe
|
|
|
3477
3294
|
}
|
|
3478
3295
|
}
|
|
3479
3296
|
|
|
3297
|
+
class LogFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3298
|
+
constructor({ firestore, interceptors, }) {
|
|
3299
|
+
super({
|
|
3300
|
+
firestore,
|
|
3301
|
+
collectionName: 'logs',
|
|
3302
|
+
model: LogDocument,
|
|
3303
|
+
interceptors,
|
|
3304
|
+
});
|
|
3305
|
+
}
|
|
3306
|
+
}
|
|
3307
|
+
|
|
3308
|
+
class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3309
|
+
constructor({ firestore, interceptors }) {
|
|
3310
|
+
super({
|
|
3311
|
+
firestore,
|
|
3312
|
+
collectionName: 'dms',
|
|
3313
|
+
model: Home,
|
|
3314
|
+
interceptors,
|
|
3315
|
+
});
|
|
3316
|
+
this.homeCategoryGroupToPlain = (homeCategoryGroup) => {
|
|
3317
|
+
var _a, _b, _c;
|
|
3318
|
+
return ({
|
|
3319
|
+
category: ((_a = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _a === void 0 ? void 0 : _a.toPlain)
|
|
3320
|
+
? (_b = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _b === void 0 ? void 0 : _b.toPlain()
|
|
3321
|
+
: homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category,
|
|
3322
|
+
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)) || [],
|
|
3323
|
+
});
|
|
3324
|
+
};
|
|
3325
|
+
this.plainToHomeCategoryGroup = (homeCategoryGroup) => {
|
|
3326
|
+
var _a;
|
|
3327
|
+
return ({
|
|
3328
|
+
category: Category.toInstance(homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category),
|
|
3329
|
+
products: (_a = homeCategoryGroup.products) === null || _a === void 0 ? void 0 : _a.map((product) => Product.toInstance(product)),
|
|
3330
|
+
});
|
|
3331
|
+
};
|
|
3332
|
+
}
|
|
3333
|
+
buildModelInstance() {
|
|
3334
|
+
const { fromFirestore, toFirestore } = super.buildModelInstance();
|
|
3335
|
+
return {
|
|
3336
|
+
toFirestore: (data) => {
|
|
3337
|
+
const modifiedData = this.homeToFirestore(data);
|
|
3338
|
+
return toFirestore(modifiedData);
|
|
3339
|
+
},
|
|
3340
|
+
fromFirestore: (snap) => {
|
|
3341
|
+
const instance = fromFirestore(snap);
|
|
3342
|
+
return this.homeFromFirestore(instance);
|
|
3343
|
+
},
|
|
3344
|
+
};
|
|
3345
|
+
}
|
|
3346
|
+
homeToFirestore(home) {
|
|
3347
|
+
var _a, _b, _c, _d;
|
|
3348
|
+
if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
|
|
3349
|
+
home.data.data.discoverProducts = ((_b = home.data.data.discoverProducts) === null || _b === void 0 ? void 0 : _b.map(this.homeCategoryGroupToPlain)) || [];
|
|
3350
|
+
home.data.data.featuredProducts = ((_c = home.data.data.featuredProducts) === null || _c === void 0 ? void 0 : _c.map(this.homeCategoryGroupToPlain)) || [];
|
|
3351
|
+
home.data.data.verticalProducts = ((_d = home.data.data.verticalProducts) === null || _d === void 0 ? void 0 : _d.map(this.homeCategoryGroupToPlain)) || [];
|
|
3352
|
+
}
|
|
3353
|
+
return home;
|
|
3354
|
+
}
|
|
3355
|
+
homeFromFirestore(home) {
|
|
3356
|
+
var _a;
|
|
3357
|
+
if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
|
|
3358
|
+
home.data.data.discoverProducts = home.data.data.discoverProducts.map(this.plainToHomeCategoryGroup);
|
|
3359
|
+
home.data.data.featuredProducts = home.data.data.featuredProducts.map(this.plainToHomeCategoryGroup);
|
|
3360
|
+
home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.plainToHomeCategoryGroup);
|
|
3361
|
+
home.data.createdAt =
|
|
3362
|
+
home.data.createdAt instanceof Timestamp ? home.data.createdAt.toDate() : home.data.createdAt;
|
|
3363
|
+
home.data.expiresAt =
|
|
3364
|
+
home.data.expiresAt instanceof Timestamp ? home.data.expiresAt.toDate() : home.data.expiresAt;
|
|
3365
|
+
}
|
|
3366
|
+
return home;
|
|
3367
|
+
}
|
|
3368
|
+
}
|
|
3369
|
+
|
|
3370
|
+
class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3371
|
+
constructor({ firestore, interceptors }) {
|
|
3372
|
+
super({
|
|
3373
|
+
firestore,
|
|
3374
|
+
collectionName: 'shopMenus',
|
|
3375
|
+
model: ShopMenu,
|
|
3376
|
+
interceptors,
|
|
3377
|
+
});
|
|
3378
|
+
}
|
|
3379
|
+
}
|
|
3380
|
+
|
|
3381
|
+
class ShopSettingsFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3382
|
+
constructor({ firestore, interceptors, }) {
|
|
3383
|
+
super({
|
|
3384
|
+
firestore,
|
|
3385
|
+
collectionName: 'shopSettings',
|
|
3386
|
+
model: ShopSettings,
|
|
3387
|
+
interceptors,
|
|
3388
|
+
});
|
|
3389
|
+
}
|
|
3390
|
+
}
|
|
3391
|
+
|
|
3480
3392
|
class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3481
3393
|
constructor({ firestore, interceptors }) {
|
|
3482
3394
|
super({
|
|
@@ -3670,87 +3582,177 @@ class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(
|
|
|
3670
3582
|
}
|
|
3671
3583
|
}
|
|
3672
3584
|
|
|
3673
|
-
class
|
|
3585
|
+
class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3674
3586
|
constructor({ firestore, interceptors }) {
|
|
3675
3587
|
super({
|
|
3676
3588
|
firestore,
|
|
3677
|
-
collectionName: '
|
|
3678
|
-
model:
|
|
3589
|
+
collectionName: 'leads',
|
|
3590
|
+
model: Lead,
|
|
3679
3591
|
interceptors,
|
|
3680
3592
|
});
|
|
3681
|
-
this.homeCategoryGroupToPlain = (homeCategoryGroup) => {
|
|
3682
|
-
var _a, _b, _c;
|
|
3683
|
-
return ({
|
|
3684
|
-
category: ((_a = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _a === void 0 ? void 0 : _a.toPlain)
|
|
3685
|
-
? (_b = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _b === void 0 ? void 0 : _b.toPlain()
|
|
3686
|
-
: homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category,
|
|
3687
|
-
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)) || [],
|
|
3688
|
-
});
|
|
3689
|
-
};
|
|
3690
|
-
this.plainToHomeCategoryGroup = (homeCategoryGroup) => {
|
|
3691
|
-
var _a;
|
|
3692
|
-
return ({
|
|
3693
|
-
category: Category.toInstance(homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category),
|
|
3694
|
-
products: (_a = homeCategoryGroup.products) === null || _a === void 0 ? void 0 : _a.map((product) => Product.toInstance(product)),
|
|
3695
|
-
});
|
|
3696
|
-
};
|
|
3697
3593
|
}
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
}
|
|
3711
|
-
homeToFirestore(home) {
|
|
3712
|
-
var _a, _b, _c, _d;
|
|
3713
|
-
if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
|
|
3714
|
-
home.data.data.discoverProducts = ((_b = home.data.data.discoverProducts) === null || _b === void 0 ? void 0 : _b.map(this.homeCategoryGroupToPlain)) || [];
|
|
3715
|
-
home.data.data.featuredProducts = ((_c = home.data.data.featuredProducts) === null || _c === void 0 ? void 0 : _c.map(this.homeCategoryGroupToPlain)) || [];
|
|
3716
|
-
home.data.data.verticalProducts = ((_d = home.data.data.verticalProducts) === null || _d === void 0 ? void 0 : _d.map(this.homeCategoryGroupToPlain)) || [];
|
|
3717
|
-
}
|
|
3718
|
-
return home;
|
|
3594
|
+
}
|
|
3595
|
+
|
|
3596
|
+
class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3597
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
3598
|
+
super({
|
|
3599
|
+
firestore,
|
|
3600
|
+
collectionName: 'editions',
|
|
3601
|
+
parentIdField: 'subscriptionId',
|
|
3602
|
+
model: Edition,
|
|
3603
|
+
interceptors,
|
|
3604
|
+
});
|
|
3605
|
+
this.parentRepository = parentRepository;
|
|
3719
3606
|
}
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
}
|
|
3731
|
-
return home;
|
|
3607
|
+
}
|
|
3608
|
+
|
|
3609
|
+
class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3610
|
+
constructor({ firestore, interceptors, }) {
|
|
3611
|
+
super({
|
|
3612
|
+
firestore,
|
|
3613
|
+
collectionName: 'subscription',
|
|
3614
|
+
model: Subscription,
|
|
3615
|
+
interceptors,
|
|
3616
|
+
});
|
|
3732
3617
|
}
|
|
3733
3618
|
}
|
|
3734
3619
|
|
|
3735
|
-
class
|
|
3620
|
+
class SubscriptionMaterializationFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3736
3621
|
constructor({ firestore, interceptors }) {
|
|
3737
3622
|
super({
|
|
3738
3623
|
firestore,
|
|
3739
|
-
collectionName: '
|
|
3740
|
-
model:
|
|
3624
|
+
collectionName: 'subscriptionMaterialization',
|
|
3625
|
+
model: SubscriptionMaterialization,
|
|
3741
3626
|
interceptors,
|
|
3742
3627
|
});
|
|
3743
3628
|
}
|
|
3744
3629
|
}
|
|
3745
3630
|
|
|
3746
|
-
class
|
|
3631
|
+
class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3632
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
3633
|
+
super({
|
|
3634
|
+
firestore,
|
|
3635
|
+
collectionName: 'payments',
|
|
3636
|
+
parentIdField: 'subscriptionId',
|
|
3637
|
+
model: SubscriptionPayment,
|
|
3638
|
+
interceptors,
|
|
3639
|
+
});
|
|
3640
|
+
this.parentRepository = parentRepository;
|
|
3641
|
+
}
|
|
3642
|
+
}
|
|
3643
|
+
|
|
3644
|
+
class SubscriptionSummaryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3747
3645
|
constructor({ firestore, interceptors, }) {
|
|
3748
3646
|
super({
|
|
3749
3647
|
firestore,
|
|
3750
|
-
collectionName: '
|
|
3751
|
-
model:
|
|
3648
|
+
collectionName: 'subscriptionSummary',
|
|
3649
|
+
model: SubscriptionSummary,
|
|
3650
|
+
interceptors,
|
|
3651
|
+
});
|
|
3652
|
+
}
|
|
3653
|
+
}
|
|
3654
|
+
|
|
3655
|
+
class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3656
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
3657
|
+
super({
|
|
3658
|
+
firestore,
|
|
3659
|
+
collectionName: 'address',
|
|
3660
|
+
parentIdField: 'userId',
|
|
3661
|
+
model: UserAddress,
|
|
3662
|
+
interceptors,
|
|
3663
|
+
});
|
|
3664
|
+
this.parentRepository = parentRepository;
|
|
3665
|
+
}
|
|
3666
|
+
}
|
|
3667
|
+
|
|
3668
|
+
class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3669
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
3670
|
+
super({
|
|
3671
|
+
firestore,
|
|
3672
|
+
collectionName: 'CX',
|
|
3673
|
+
parentIdField: 'userId',
|
|
3674
|
+
model: BeautyProfile,
|
|
3675
|
+
interceptors,
|
|
3676
|
+
});
|
|
3677
|
+
this.parentRepository = parentRepository;
|
|
3678
|
+
}
|
|
3679
|
+
}
|
|
3680
|
+
|
|
3681
|
+
class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3682
|
+
constructor({ firestore, interceptors }) {
|
|
3683
|
+
super({
|
|
3684
|
+
firestore,
|
|
3685
|
+
collectionName: 'users',
|
|
3686
|
+
model: User,
|
|
3687
|
+
interceptors,
|
|
3688
|
+
});
|
|
3689
|
+
}
|
|
3690
|
+
async get(identifiers) {
|
|
3691
|
+
const user = await super.get({ id: identifiers.id });
|
|
3692
|
+
user.beautyProfile = await this.getBeautyProfile(user.id);
|
|
3693
|
+
user.isSubscriber = await this.checkIfIsSubscriber(user.id);
|
|
3694
|
+
return user;
|
|
3695
|
+
}
|
|
3696
|
+
async checkIfExistsByField(field, value) {
|
|
3697
|
+
const result = await this.find({ filters: { [field]: value } });
|
|
3698
|
+
return result.count > 0;
|
|
3699
|
+
}
|
|
3700
|
+
buildModelInstance() {
|
|
3701
|
+
const { fromFirestore, toFirestore } = super.buildModelInstance();
|
|
3702
|
+
return {
|
|
3703
|
+
toFirestore: (data) => {
|
|
3704
|
+
const plain = toFirestore(data);
|
|
3705
|
+
delete plain.isSubscriber;
|
|
3706
|
+
return plain;
|
|
3707
|
+
},
|
|
3708
|
+
fromFirestore,
|
|
3709
|
+
};
|
|
3710
|
+
}
|
|
3711
|
+
async getBeautyProfile(userId) {
|
|
3712
|
+
const beautyProfile = await this.firestore
|
|
3713
|
+
.getCollection(`${this.collectionName}/${userId}/CX`)
|
|
3714
|
+
.withConverter(this.buildBeautyProfileModelInstance())
|
|
3715
|
+
.getDoc('beautyProfile')
|
|
3716
|
+
.get();
|
|
3717
|
+
return beautyProfile.data();
|
|
3718
|
+
}
|
|
3719
|
+
async checkIfIsSubscriber(userId) {
|
|
3720
|
+
const docs = await this.collection('subscription')
|
|
3721
|
+
.where('user.id', '==', userId)
|
|
3722
|
+
.where('status', '==', 'active')
|
|
3723
|
+
.getDocs();
|
|
3724
|
+
return !!docs && !!docs.size;
|
|
3725
|
+
}
|
|
3726
|
+
buildBeautyProfileModelInstance() {
|
|
3727
|
+
return {
|
|
3728
|
+
toFirestore: (data) => data.toPlain(),
|
|
3729
|
+
fromFirestore: (snap) => BeautyProfile.toInstance(snap.data()),
|
|
3730
|
+
};
|
|
3731
|
+
}
|
|
3732
|
+
}
|
|
3733
|
+
__decorate([
|
|
3734
|
+
Log(),
|
|
3735
|
+
__metadata("design:type", Function),
|
|
3736
|
+
__metadata("design:paramtypes", [Object]),
|
|
3737
|
+
__metadata("design:returntype", Promise)
|
|
3738
|
+
], UserFirestoreRepository.prototype, "get", null);
|
|
3739
|
+
__decorate([
|
|
3740
|
+
Log(),
|
|
3741
|
+
__metadata("design:type", Function),
|
|
3742
|
+
__metadata("design:paramtypes", [String, String]),
|
|
3743
|
+
__metadata("design:returntype", Promise)
|
|
3744
|
+
], UserFirestoreRepository.prototype, "checkIfExistsByField", null);
|
|
3745
|
+
|
|
3746
|
+
class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3747
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
3748
|
+
super({
|
|
3749
|
+
firestore,
|
|
3750
|
+
collectionName: 'payment_method',
|
|
3751
|
+
parentIdField: 'userId',
|
|
3752
|
+
model: UserPaymentMethod,
|
|
3752
3753
|
interceptors,
|
|
3753
3754
|
});
|
|
3755
|
+
this.parentRepository = parentRepository;
|
|
3754
3756
|
}
|
|
3755
3757
|
}
|
|
3756
3758
|
|
|
@@ -4941,7 +4943,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4941
4943
|
});
|
|
4942
4944
|
return data;
|
|
4943
4945
|
}
|
|
4944
|
-
async getCategoriesForHome(categoryIds, limit = 4
|
|
4946
|
+
async getCategoriesForHome(categoryIds, shop, limit = 4) {
|
|
4945
4947
|
if (!(categoryIds === null || categoryIds === void 0 ? void 0 : categoryIds.length))
|
|
4946
4948
|
return [];
|
|
4947
4949
|
const categoriesFirestore = categoryIds.filter((categoryId) => Number.isNaN(+categoryId));
|
|
@@ -4953,22 +4955,32 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4953
4955
|
}).then(({ data }) => data)));
|
|
4954
4956
|
if (categoriesHasura.length)
|
|
4955
4957
|
categories.push(...(await this.find({
|
|
4956
|
-
filters: {
|
|
4958
|
+
filters: {
|
|
4959
|
+
id: { operator: Where.IN, value: categoriesHasura.filter(Boolean) },
|
|
4960
|
+
published: true,
|
|
4961
|
+
},
|
|
4957
4962
|
}).then(({ data }) => data)));
|
|
4958
4963
|
if (!categories.length)
|
|
4959
4964
|
return [];
|
|
4960
4965
|
const homeSections = await Promise.all(categories.map(async (category) => ({
|
|
4961
4966
|
category,
|
|
4962
|
-
products: await this.mountCategory(category, { limit, hasStock: true
|
|
4967
|
+
products: await this.mountCategory(category, shop, { limit, hasStock: true }),
|
|
4963
4968
|
})));
|
|
4964
4969
|
return homeSections;
|
|
4965
4970
|
}
|
|
4966
|
-
async mountCategory(category, options) {
|
|
4971
|
+
async mountCategory(category, shop, options) {
|
|
4967
4972
|
var _a;
|
|
4968
4973
|
if (!((_a = category === null || category === void 0 ? void 0 : category.products) === null || _a === void 0 ? void 0 : _a.length))
|
|
4969
4974
|
return [];
|
|
4975
|
+
const mostRelevants = category.getMostRelevantByShop(shop);
|
|
4976
|
+
const mostRelevantProductsIds = [...new Set(mostRelevants.concat(category.products))];
|
|
4970
4977
|
const products = [];
|
|
4971
|
-
const { data: productsData } = await this.productRepository.find(
|
|
4978
|
+
const { data: productsData } = await this.productRepository.find({
|
|
4979
|
+
filters: {
|
|
4980
|
+
id: { operator: Where.IN, value: mostRelevantProductsIds },
|
|
4981
|
+
published: true,
|
|
4982
|
+
},
|
|
4983
|
+
fields: [
|
|
4972
4984
|
'id',
|
|
4973
4985
|
'name',
|
|
4974
4986
|
'slug',
|
|
@@ -4994,8 +5006,25 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4994
5006
|
'shoppingCount',
|
|
4995
5007
|
'gender',
|
|
4996
5008
|
'createdAt',
|
|
4997
|
-
]
|
|
4998
|
-
|
|
5009
|
+
],
|
|
5010
|
+
options: { enableCount: false },
|
|
5011
|
+
orderBy: {
|
|
5012
|
+
shoppingCount: 'desc',
|
|
5013
|
+
rate: 'desc',
|
|
5014
|
+
stock: 'desc',
|
|
5015
|
+
name: 'asc',
|
|
5016
|
+
},
|
|
5017
|
+
});
|
|
5018
|
+
const mostRelevantWithouyStock = productsData.filter((product) => mostRelevants.includes(product.id) && product.stock.quantity <= 0);
|
|
5019
|
+
const firstProducts = productsData
|
|
5020
|
+
.filter((product) => mostRelevants.includes(product.id) && product.stock.quantity > 0)
|
|
5021
|
+
.sort((a, b) => mostRelevants.indexOf(a.id) - mostRelevants.indexOf(b.id));
|
|
5022
|
+
const lastProducts = productsData
|
|
5023
|
+
.filter((product) => !mostRelevants.includes(product.id))
|
|
5024
|
+
.concat(mostRelevantWithouyStock);
|
|
5025
|
+
const categoryMostRelevants = firstProducts.concat(lastProducts);
|
|
5026
|
+
const resultFinal = categoryMostRelevants.slice(0, options.limit);
|
|
5027
|
+
products.push(...resultFinal);
|
|
4999
5028
|
return products;
|
|
5000
5029
|
}
|
|
5001
5030
|
async getChildren(parentId) {
|
|
@@ -5170,13 +5199,13 @@ __decorate([
|
|
|
5170
5199
|
__decorate([
|
|
5171
5200
|
Log(),
|
|
5172
5201
|
__metadata("design:type", Function),
|
|
5173
|
-
__metadata("design:paramtypes", [Array,
|
|
5202
|
+
__metadata("design:paramtypes", [Array, String, Object]),
|
|
5174
5203
|
__metadata("design:returntype", Promise)
|
|
5175
5204
|
], CategoryHasuraGraphQLRepository.prototype, "getCategoriesForHome", null);
|
|
5176
5205
|
__decorate([
|
|
5177
5206
|
Log(),
|
|
5178
5207
|
__metadata("design:type", Function),
|
|
5179
|
-
__metadata("design:paramtypes", [Category, Object]),
|
|
5208
|
+
__metadata("design:paramtypes", [Category, String, Object]),
|
|
5180
5209
|
__metadata("design:returntype", Promise)
|
|
5181
5210
|
], CategoryHasuraGraphQLRepository.prototype, "mountCategory", null);
|
|
5182
5211
|
__decorate([
|
|
@@ -6307,10 +6336,10 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
6307
6336
|
value: [PersonTypes.BFLU, PersonTypes.GLAMGIRL],
|
|
6308
6337
|
} }), orderBy: Object.assign({ personHasPhoto: 'desc' }, omit(params.orderBy, ['personHasPhoto'])) }));
|
|
6309
6338
|
}
|
|
6310
|
-
getCategoriesForHome(categoryIds,
|
|
6339
|
+
getCategoriesForHome(categoryIds, gender, limit) {
|
|
6311
6340
|
return;
|
|
6312
6341
|
}
|
|
6313
|
-
mountCategory(category, options) {
|
|
6342
|
+
mountCategory(category, shop, options) {
|
|
6314
6343
|
return;
|
|
6315
6344
|
}
|
|
6316
6345
|
getChildren(parentId) {
|
|
@@ -6521,6 +6550,9 @@ class VertexAxiosAdapter {
|
|
|
6521
6550
|
throw error;
|
|
6522
6551
|
}
|
|
6523
6552
|
}
|
|
6553
|
+
bulkProducts(products) {
|
|
6554
|
+
return;
|
|
6555
|
+
}
|
|
6524
6556
|
}
|
|
6525
6557
|
|
|
6526
6558
|
class ProductsVertexSearch {
|
|
@@ -6568,4 +6600,4 @@ class ProductsVertexSearch {
|
|
|
6568
6600
|
}
|
|
6569
6601
|
}
|
|
6570
6602
|
|
|
6571
|
-
export { AccessoryImportances, Address, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository, Campaign, CampaignBanner, CampaignDashboard, CampaignDashboardFirestoreRepository, CampaignHashtag, CampaignHashtagFirestoreRepository, Category, CategoryCollectionChildren, CategoryCollectionChildrenHasuraGraphQLRepository, CategoryFilter, CategoryFilterHasuraGraphQLRepository, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, ClassNameHelper, ConnectBaseDocumentSnapshot, ConnectCollectionService, ConnectDocumentService, ConnectFirestoreService, Coupon, CouponCategory, CouponFirestoreRepository, CouponSubtypes, CouponTypes, Debug, DebugDecoratorHelper, DebugHelper, DebugNamespaces, DuplicatedResultsError, Edition, EditionStatus, Exclusivities, FaceSkinOilinesses, FaceSkinProblems, FaceSkinTones, FamilyIncomes, Filter, FilterHasuraGraphQLRepository, FilterOption, FilterOptionHasuraGraphQLRepository, FilterType, FirebaseFileUploaderService, FragranceImportances, GenderDestination, HairColors, HairProblems, HairStrands, HairTypes, Home, HomeFirestoreRepository, InvalidArgumentError, KitProduct, KitProductHasuraGraphQL, Lead, LeadFirestoreRepository, LegacyOrderFirestoreRepository, LineItem, Log, Logger, NotFoundError, OfficePosition, Order, OrderBlocked, OrderBlockedFirestoreRepository, OrderFirestoreRepository, OrderStatus, Payment, PaymentFirestoreRepository, PaymentType, PersonTypes, Plans, Product, ProductFirestoreRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductReviews, ProductReviewsHasuraGraphQLRepository, ProductSpents, ProductStockNotification, ProductStockNotificationHasuraGraphQLRepository, ProductVariantFirestoreRepository, ProductsIndex, ProductsVertexSearch, QuestionsFilters, RecoveryPassword, ReflectHelper, Register, RegisterFirebaseAuthService, RequiredArgumentError, RoundProductPricesHelper, ShippingMethod, ShopMenu, ShopMenuFirestoreRepository, ShopPageName, ShopSettings, ShopSettingsFirestoreRepository, Shops, SignInMethods, SignOut, Status, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionMaterialization, SubscriptionMaterializationFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionSummary, SubscriptionSummaryFirestoreRepository, Trace, UnauthorizedError, UpdateOptionActions, UpdateUserImage, User, UserAddress, UserAddressFirestoreRepository, UserAlreadyRegisteredError, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserPaymentMethod, UserPaymentMethodFirestoreRepository, UserType, Variant, VariantHasuraGraphQL, VariantHasuraGraphQLRepository, VertexAxiosAdapter, WeakPasswordError, Where, Wishlist, WishlistHasuraGraphQLRepository, is, isDebuggable, isUUID, parseDateTime, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
|
|
6603
|
+
export { AccessoryImportances, Address, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository, Campaign, CampaignBanner, CampaignDashboard, CampaignDashboardFirestoreRepository, CampaignHashtag, CampaignHashtagFirestoreRepository, Category, CategoryCollectionChildren, CategoryCollectionChildrenHasuraGraphQLRepository, CategoryFilter, CategoryFilterHasuraGraphQLRepository, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, ClassNameHelper, ConnectBaseDocumentSnapshot, ConnectCollectionService, ConnectDocumentService, ConnectFirestoreService, Coupon, CouponCategory, CouponFirestoreRepository, CouponSubtypes, CouponTypes, Debug, DebugDecoratorHelper, DebugHelper, DebugNamespaces, DuplicatedResultsError, Edition, EditionStatus, Exclusivities, FaceSkinOilinesses, FaceSkinProblems, FaceSkinTones, FamilyIncomes, Filter, FilterHasuraGraphQLRepository, FilterOption, FilterOptionHasuraGraphQLRepository, FilterType, FirebaseFileUploaderService, FragranceImportances, GenderDestination, HairColors, HairProblems, HairStrands, HairTypes, Home, HomeFirestoreRepository, InvalidArgumentError, KitProduct, KitProductHasuraGraphQL, Lead, LeadFirestoreRepository, LegacyOrderFirestoreRepository, LineItem, Log, LogDocument, LogFirestoreRepository, Logger, NotFoundError, OfficePosition, Order, OrderBlocked, OrderBlockedFirestoreRepository, OrderFirestoreRepository, OrderStatus, Payment, PaymentFirestoreRepository, PaymentType, PersonTypes, Plans, Product, ProductFirestoreRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductReviews, ProductReviewsHasuraGraphQLRepository, ProductSpents, ProductStockNotification, ProductStockNotificationHasuraGraphQLRepository, ProductVariantFirestoreRepository, ProductsIndex, ProductsVertexSearch, QuestionsFilters, RecoveryPassword, ReflectHelper, Register, RegisterFirebaseAuthService, RequiredArgumentError, RoundProductPricesHelper, ShippingMethod, ShopMenu, ShopMenuFirestoreRepository, ShopPageName, ShopSettings, ShopSettingsFirestoreRepository, Shops, SignInMethods, SignOut, Status, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionMaterialization, SubscriptionMaterializationFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionSummary, SubscriptionSummaryFirestoreRepository, Trace, UnauthorizedError, UpdateOptionActions, UpdateUserImage, User, UserAddress, UserAddressFirestoreRepository, UserAlreadyRegisteredError, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserPaymentMethod, UserPaymentMethodFirestoreRepository, UserType, Variant, VariantHasuraGraphQL, VariantHasuraGraphQLRepository, VertexAxiosAdapter, WeakPasswordError, Where, Wishlist, WishlistHasuraGraphQLRepository, WishlistLogType, is, isDebuggable, isUUID, parseDateTime, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
|