@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.cjs.js
CHANGED
|
@@ -57,6 +57,15 @@ exports.Shops = void 0;
|
|
|
57
57
|
Shops["ALL"] = "ALL";
|
|
58
58
|
})(exports.Shops || (exports.Shops = {}));
|
|
59
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
|
+
|
|
60
69
|
class Filter extends BaseModel {
|
|
61
70
|
static get identifiersFields() {
|
|
62
71
|
return ['id'];
|
|
@@ -1843,55 +1852,6 @@ const parseDateTime = (value) => {
|
|
|
1843
1852
|
return date;
|
|
1844
1853
|
};
|
|
1845
1854
|
|
|
1846
|
-
exports.CheckoutTypes = void 0;
|
|
1847
|
-
(function (CheckoutTypes) {
|
|
1848
|
-
CheckoutTypes[CheckoutTypes["ECOMMERCE"] = 1] = "ECOMMERCE";
|
|
1849
|
-
CheckoutTypes[CheckoutTypes["SUBSCRIPTION"] = 2] = "SUBSCRIPTION";
|
|
1850
|
-
CheckoutTypes[CheckoutTypes["ALL"] = 3] = "ALL";
|
|
1851
|
-
})(exports.CheckoutTypes || (exports.CheckoutTypes = {}));
|
|
1852
|
-
|
|
1853
|
-
exports.CouponCategory = void 0;
|
|
1854
|
-
(function (CouponCategory) {
|
|
1855
|
-
CouponCategory["Reembolso"] = "Reembolso";
|
|
1856
|
-
CouponCategory["Desculpas"] = "Desculpas";
|
|
1857
|
-
CouponCategory["BFlu"] = "BFlu";
|
|
1858
|
-
CouponCategory["ROYAL"] = "Royal";
|
|
1859
|
-
CouponCategory["Glamqueens"] = "Glamqueens";
|
|
1860
|
-
CouponCategory["Glamgirls"] = "Glamgirls";
|
|
1861
|
-
CouponCategory["Glamdiva"] = "Glamdiva";
|
|
1862
|
-
CouponCategory["Impulsionamento"] = "Impulsionamento";
|
|
1863
|
-
CouponCategory["PaidMedia"] = "Paid Media";
|
|
1864
|
-
CouponCategory["Organic"] = "Organic";
|
|
1865
|
-
CouponCategory["Direct"] = "Direct";
|
|
1866
|
-
CouponCategory["CRM"] = "CRM";
|
|
1867
|
-
CouponCategory["LOJAUNICO"] = "Loja \u00FAnico";
|
|
1868
|
-
CouponCategory["Outros"] = "Outros";
|
|
1869
|
-
})(exports.CouponCategory || (exports.CouponCategory = {}));
|
|
1870
|
-
|
|
1871
|
-
exports.CouponSubtypes = void 0;
|
|
1872
|
-
(function (CouponSubtypes) {
|
|
1873
|
-
CouponSubtypes[CouponSubtypes["ABSOLUTE"] = 1] = "ABSOLUTE";
|
|
1874
|
-
CouponSubtypes[CouponSubtypes["PERCENTAGE"] = 2] = "PERCENTAGE";
|
|
1875
|
-
})(exports.CouponSubtypes || (exports.CouponSubtypes = {}));
|
|
1876
|
-
|
|
1877
|
-
exports.CouponTypes = void 0;
|
|
1878
|
-
(function (CouponTypes) {
|
|
1879
|
-
CouponTypes[CouponTypes["ABSOLUTE"] = 1] = "ABSOLUTE";
|
|
1880
|
-
CouponTypes[CouponTypes["PERCENTAGE"] = 2] = "PERCENTAGE";
|
|
1881
|
-
CouponTypes[CouponTypes["SHIPPING"] = 3] = "SHIPPING";
|
|
1882
|
-
})(exports.CouponTypes || (exports.CouponTypes = {}));
|
|
1883
|
-
|
|
1884
|
-
exports.Exclusivities = void 0;
|
|
1885
|
-
(function (Exclusivities) {
|
|
1886
|
-
Exclusivities[Exclusivities["ALL_USERS"] = 1] = "ALL_USERS";
|
|
1887
|
-
Exclusivities[Exclusivities["SPECIFIC_USER"] = 2] = "SPECIFIC_USER";
|
|
1888
|
-
Exclusivities[Exclusivities["COLLABORATORS"] = 3] = "COLLABORATORS";
|
|
1889
|
-
Exclusivities[Exclusivities["ACTIVE_SUBSCRIBER"] = 4] = "ACTIVE_SUBSCRIBER";
|
|
1890
|
-
Exclusivities[Exclusivities["INACTIVE_SUBSCRIBER"] = 5] = "INACTIVE_SUBSCRIBER";
|
|
1891
|
-
Exclusivities[Exclusivities["NON_SUBSCRIBER"] = 6] = "NON_SUBSCRIBER";
|
|
1892
|
-
})(exports.Exclusivities || (exports.Exclusivities = {}));
|
|
1893
|
-
|
|
1894
|
-
const COUPON_EXPIRATION = +1000 * 60 * 60 * 24 * 30;
|
|
1895
1855
|
class Coupon extends BaseModel {
|
|
1896
1856
|
get isInfluencer() {
|
|
1897
1857
|
return !lodash.isNil(this.influencerEmail);
|
|
@@ -1899,30 +1859,6 @@ class Coupon extends BaseModel {
|
|
|
1899
1859
|
static get identifiersFields() {
|
|
1900
1860
|
return ['id'];
|
|
1901
1861
|
}
|
|
1902
|
-
static createCoupon(userId) {
|
|
1903
|
-
return this.toInstance({
|
|
1904
|
-
nickname: `${Date.now()}`,
|
|
1905
|
-
checkoutType: exports.CheckoutTypes.ECOMMERCE,
|
|
1906
|
-
discount: {
|
|
1907
|
-
subscriber: {
|
|
1908
|
-
type: exports.CouponTypes.ABSOLUTE,
|
|
1909
|
-
value: 10,
|
|
1910
|
-
},
|
|
1911
|
-
non_subscriber: {
|
|
1912
|
-
type: exports.CouponTypes.ABSOLUTE,
|
|
1913
|
-
value: 10,
|
|
1914
|
-
},
|
|
1915
|
-
subscription: {
|
|
1916
|
-
type: exports.CouponTypes.ABSOLUTE,
|
|
1917
|
-
value: 10,
|
|
1918
|
-
},
|
|
1919
|
-
},
|
|
1920
|
-
user: userId,
|
|
1921
|
-
createdAt: new Date(Date.now()),
|
|
1922
|
-
beginAt: new Date(Date.now()),
|
|
1923
|
-
expiresIn: new Date(Date.now() + COUPON_EXPIRATION),
|
|
1924
|
-
});
|
|
1925
|
-
}
|
|
1926
1862
|
}
|
|
1927
1863
|
|
|
1928
1864
|
class SubscriptionPlan extends BaseModel {
|
|
@@ -2197,6 +2133,55 @@ tslib.__decorate([
|
|
|
2197
2133
|
tslib.__metadata("design:type", Coupon)
|
|
2198
2134
|
], Checkout.prototype, "coupon", void 0);
|
|
2199
2135
|
|
|
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["Glamqueen"] = "Glamqueen";
|
|
2143
|
+
CouponCategory["Glampartner"] = "Glampartner";
|
|
2144
|
+
CouponCategory["Glamgirl"] = "Glamgirl";
|
|
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
|
+
|
|
2155
|
+
exports.CouponSubtypes = void 0;
|
|
2156
|
+
(function (CouponSubtypes) {
|
|
2157
|
+
CouponSubtypes[CouponSubtypes["ABSOLUTE"] = 1] = "ABSOLUTE";
|
|
2158
|
+
CouponSubtypes[CouponSubtypes["PERCENTAGE"] = 2] = "PERCENTAGE";
|
|
2159
|
+
})(exports.CouponSubtypes || (exports.CouponSubtypes = {}));
|
|
2160
|
+
|
|
2161
|
+
exports.CouponTypes = void 0;
|
|
2162
|
+
(function (CouponTypes) {
|
|
2163
|
+
CouponTypes[CouponTypes["ABSOLUTE"] = 1] = "ABSOLUTE";
|
|
2164
|
+
CouponTypes[CouponTypes["PERCENTAGE"] = 2] = "PERCENTAGE";
|
|
2165
|
+
CouponTypes[CouponTypes["SHIPPING"] = 3] = "SHIPPING";
|
|
2166
|
+
})(exports.CouponTypes || (exports.CouponTypes = {}));
|
|
2167
|
+
|
|
2168
|
+
exports.Exclusivities = void 0;
|
|
2169
|
+
(function (Exclusivities) {
|
|
2170
|
+
Exclusivities[Exclusivities["ALL_USERS"] = 1] = "ALL_USERS";
|
|
2171
|
+
Exclusivities[Exclusivities["SPECIFIC_USER"] = 2] = "SPECIFIC_USER";
|
|
2172
|
+
Exclusivities[Exclusivities["COLLABORATORS"] = 3] = "COLLABORATORS";
|
|
2173
|
+
Exclusivities[Exclusivities["ACTIVE_SUBSCRIBER"] = 4] = "ACTIVE_SUBSCRIBER";
|
|
2174
|
+
Exclusivities[Exclusivities["INACTIVE_SUBSCRIBER"] = 5] = "INACTIVE_SUBSCRIBER";
|
|
2175
|
+
Exclusivities[Exclusivities["NON_SUBSCRIBER"] = 6] = "NON_SUBSCRIBER";
|
|
2176
|
+
})(exports.Exclusivities || (exports.Exclusivities = {}));
|
|
2177
|
+
|
|
2178
|
+
exports.CheckoutTypes = void 0;
|
|
2179
|
+
(function (CheckoutTypes) {
|
|
2180
|
+
CheckoutTypes[CheckoutTypes["ECOMMERCE"] = 1] = "ECOMMERCE";
|
|
2181
|
+
CheckoutTypes[CheckoutTypes["SUBSCRIPTION"] = 2] = "SUBSCRIPTION";
|
|
2182
|
+
CheckoutTypes[CheckoutTypes["ALL"] = 3] = "ALL";
|
|
2183
|
+
})(exports.CheckoutTypes || (exports.CheckoutTypes = {}));
|
|
2184
|
+
|
|
2200
2185
|
exports.OrderStatus = void 0;
|
|
2201
2186
|
(function (OrderStatus) {
|
|
2202
2187
|
OrderStatus["AGUARDANDO_PAGAMENTO"] = "Aguardando pagamento";
|
|
@@ -2258,6 +2243,12 @@ class RoundProductPricesHelper {
|
|
|
2258
2243
|
}
|
|
2259
2244
|
}
|
|
2260
2245
|
|
|
2246
|
+
class LogDocument extends BaseModel {
|
|
2247
|
+
static get identifiersFields() {
|
|
2248
|
+
return ['id'];
|
|
2249
|
+
}
|
|
2250
|
+
}
|
|
2251
|
+
|
|
2261
2252
|
exports.FilterType = void 0;
|
|
2262
2253
|
(function (FilterType) {
|
|
2263
2254
|
FilterType["ACCESSORY_IMPORTANCE"] = "accessoryImportance";
|
|
@@ -3125,278 +3116,104 @@ const withCrudFirestore = (MixinBase) => {
|
|
|
3125
3116
|
};
|
|
3126
3117
|
};
|
|
3127
3118
|
|
|
3128
|
-
class
|
|
3119
|
+
class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3129
3120
|
constructor({ firestore, interceptors }) {
|
|
3130
3121
|
super({
|
|
3131
3122
|
firestore,
|
|
3132
|
-
collectionName: '
|
|
3133
|
-
model:
|
|
3123
|
+
collectionName: 'categories',
|
|
3124
|
+
model: Category,
|
|
3134
3125
|
interceptors,
|
|
3135
3126
|
});
|
|
3136
3127
|
}
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
this.parentRepository = parentRepository;
|
|
3128
|
+
async getCategoryBySlug(slug, shop) {
|
|
3129
|
+
const categoryDocs = await this.collection(this.collectionName)
|
|
3130
|
+
.where('slug', '==', slug)
|
|
3131
|
+
.where('shop', '==', shop)
|
|
3132
|
+
.where('published', '==', true)
|
|
3133
|
+
.getDocs();
|
|
3134
|
+
if (categoryDocs.size > 1)
|
|
3135
|
+
throw new DuplicatedResultsError('Query returned duplicated values');
|
|
3136
|
+
if (categoryDocs.empty)
|
|
3137
|
+
throw new NotFoundError(`Document with slug ${slug} not found`);
|
|
3138
|
+
return categoryDocs.docs[0].data();
|
|
3149
3139
|
}
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3140
|
+
async getCategoriesForHome(categoryIds, shop, limit = 4) {
|
|
3141
|
+
const categorySnap = await this.collection(this.collectionName)
|
|
3142
|
+
.where('id', 'in', categoryIds.filter(Boolean))
|
|
3143
|
+
.where('published', '==', true)
|
|
3144
|
+
.getDocs();
|
|
3145
|
+
if (categorySnap.empty)
|
|
3146
|
+
throw new NotFoundError('Categories not found');
|
|
3147
|
+
const categories = categorySnap.docs.map((doc) => doc.data());
|
|
3148
|
+
const homeSections = await Promise.all(categories.map(async (category) => ({
|
|
3149
|
+
category,
|
|
3150
|
+
products: await this.mountCategory(category, shop, { limit, hasStock: true }),
|
|
3151
|
+
})));
|
|
3152
|
+
return homeSections;
|
|
3160
3153
|
}
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3154
|
+
async mountCategory(category, shop, options) {
|
|
3155
|
+
if (!category.products)
|
|
3156
|
+
throw new RequiredArgumentError(['Category products is empty']);
|
|
3157
|
+
const chunks = lodash.chunk(category.products, 10);
|
|
3158
|
+
const products = [];
|
|
3159
|
+
const wheres = [];
|
|
3160
|
+
for (const productIds of chunks) {
|
|
3161
|
+
if ((options === null || options === void 0 ? void 0 : options.limit) && products.length >= (options === null || options === void 0 ? void 0 : options.limit))
|
|
3162
|
+
break;
|
|
3163
|
+
wheres.push(['published', '==', true], ['id', 'in', productIds]);
|
|
3164
|
+
if (options === null || options === void 0 ? void 0 : options.hasStock)
|
|
3165
|
+
wheres.push(['stock.quantity', '>', 0]);
|
|
3166
|
+
if (options === null || options === void 0 ? void 0 : options.gender)
|
|
3167
|
+
wheres.push(['tags', 'array-contains', options === null || options === void 0 ? void 0 : options.gender]);
|
|
3168
|
+
const productSnap = await wheres
|
|
3169
|
+
.reduce((collection, where) => collection.where(...where), (options === null || options === void 0 ? void 0 : options.limit)
|
|
3170
|
+
? this.collection('productsErpVitrine').limit(options.limit)
|
|
3171
|
+
: this.collection('productsErpVitrine'))
|
|
3172
|
+
.getDocs();
|
|
3173
|
+
if (productSnap.empty)
|
|
3174
|
+
continue;
|
|
3175
|
+
products.push(...productSnap.docs);
|
|
3176
|
+
}
|
|
3177
|
+
return is(products);
|
|
3171
3178
|
}
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3175
|
-
constructor({ firestore, interceptors }, parentRepository) {
|
|
3176
|
-
super({
|
|
3177
|
-
firestore,
|
|
3178
|
-
collectionName: 'payments',
|
|
3179
|
-
parentIdField: 'subscriptionId',
|
|
3180
|
-
model: SubscriptionPayment,
|
|
3181
|
-
interceptors,
|
|
3182
|
-
});
|
|
3183
|
-
this.parentRepository = parentRepository;
|
|
3179
|
+
getCategoryByShop(shop) {
|
|
3180
|
+
return;
|
|
3184
3181
|
}
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
class SubscriptionSummaryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3188
|
-
constructor({ firestore, interceptors, }) {
|
|
3189
|
-
super({
|
|
3190
|
-
firestore,
|
|
3191
|
-
collectionName: 'subscriptionSummary',
|
|
3192
|
-
model: SubscriptionSummary,
|
|
3193
|
-
interceptors,
|
|
3194
|
-
});
|
|
3182
|
+
getChildren(parentId) {
|
|
3183
|
+
return;
|
|
3195
3184
|
}
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3199
|
-
constructor({ firestore, interceptors }, parentRepository) {
|
|
3200
|
-
super({
|
|
3201
|
-
firestore,
|
|
3202
|
-
collectionName: 'address',
|
|
3203
|
-
parentIdField: 'userId',
|
|
3204
|
-
model: UserAddress,
|
|
3205
|
-
interceptors,
|
|
3206
|
-
});
|
|
3207
|
-
this.parentRepository = parentRepository;
|
|
3185
|
+
isChild(id, parentId) {
|
|
3186
|
+
return;
|
|
3208
3187
|
}
|
|
3209
3188
|
}
|
|
3189
|
+
tslib.__decorate([
|
|
3190
|
+
Log(),
|
|
3191
|
+
tslib.__metadata("design:type", Function),
|
|
3192
|
+
tslib.__metadata("design:paramtypes", [String, String]),
|
|
3193
|
+
tslib.__metadata("design:returntype", Promise)
|
|
3194
|
+
], CategoryFirestoreRepository.prototype, "getCategoryBySlug", null);
|
|
3195
|
+
tslib.__decorate([
|
|
3196
|
+
Log(),
|
|
3197
|
+
tslib.__metadata("design:type", Function),
|
|
3198
|
+
tslib.__metadata("design:paramtypes", [Array, String, Object]),
|
|
3199
|
+
tslib.__metadata("design:returntype", Promise)
|
|
3200
|
+
], CategoryFirestoreRepository.prototype, "getCategoriesForHome", null);
|
|
3201
|
+
tslib.__decorate([
|
|
3202
|
+
Log(),
|
|
3203
|
+
tslib.__metadata("design:type", Function),
|
|
3204
|
+
tslib.__metadata("design:paramtypes", [Category, String, Object]),
|
|
3205
|
+
tslib.__metadata("design:returntype", Promise)
|
|
3206
|
+
], CategoryFirestoreRepository.prototype, "mountCategory", null);
|
|
3210
3207
|
|
|
3211
|
-
class
|
|
3212
|
-
constructor({ firestore, interceptors }
|
|
3208
|
+
class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3209
|
+
constructor({ firestore, interceptors }) {
|
|
3213
3210
|
super({
|
|
3214
3211
|
firestore,
|
|
3215
|
-
collectionName: '
|
|
3216
|
-
|
|
3217
|
-
model: BeautyProfile,
|
|
3212
|
+
collectionName: 'productsErpVitrine',
|
|
3213
|
+
model: Product,
|
|
3218
3214
|
interceptors,
|
|
3219
3215
|
});
|
|
3220
|
-
this.
|
|
3221
|
-
}
|
|
3222
|
-
}
|
|
3223
|
-
|
|
3224
|
-
class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3225
|
-
constructor({ firestore, interceptors }) {
|
|
3226
|
-
super({
|
|
3227
|
-
firestore,
|
|
3228
|
-
collectionName: 'users',
|
|
3229
|
-
model: User,
|
|
3230
|
-
interceptors,
|
|
3231
|
-
});
|
|
3232
|
-
}
|
|
3233
|
-
async get(identifiers) {
|
|
3234
|
-
const user = await super.get({ id: identifiers.id });
|
|
3235
|
-
user.beautyProfile = await this.getBeautyProfile(user.id);
|
|
3236
|
-
user.isSubscriber = await this.checkIfIsSubscriber(user.id);
|
|
3237
|
-
return user;
|
|
3238
|
-
}
|
|
3239
|
-
async checkIfExistsByField(field, value) {
|
|
3240
|
-
const result = await this.find({ filters: { [field]: value } });
|
|
3241
|
-
return result.count > 0;
|
|
3242
|
-
}
|
|
3243
|
-
buildModelInstance() {
|
|
3244
|
-
const { fromFirestore, toFirestore } = super.buildModelInstance();
|
|
3245
|
-
return {
|
|
3246
|
-
toFirestore: (data) => {
|
|
3247
|
-
const plain = toFirestore(data);
|
|
3248
|
-
delete plain.isSubscriber;
|
|
3249
|
-
return plain;
|
|
3250
|
-
},
|
|
3251
|
-
fromFirestore,
|
|
3252
|
-
};
|
|
3253
|
-
}
|
|
3254
|
-
async getBeautyProfile(userId) {
|
|
3255
|
-
const beautyProfile = await this.firestore
|
|
3256
|
-
.getCollection(`${this.collectionName}/${userId}/CX`)
|
|
3257
|
-
.withConverter(this.buildBeautyProfileModelInstance())
|
|
3258
|
-
.getDoc('beautyProfile')
|
|
3259
|
-
.get();
|
|
3260
|
-
return beautyProfile.data();
|
|
3261
|
-
}
|
|
3262
|
-
async checkIfIsSubscriber(userId) {
|
|
3263
|
-
const docs = await this.collection('subscription')
|
|
3264
|
-
.where('user.id', '==', userId)
|
|
3265
|
-
.where('status', '==', 'active')
|
|
3266
|
-
.getDocs();
|
|
3267
|
-
return !!docs && !!docs.size;
|
|
3268
|
-
}
|
|
3269
|
-
buildBeautyProfileModelInstance() {
|
|
3270
|
-
return {
|
|
3271
|
-
toFirestore: (data) => data.toPlain(),
|
|
3272
|
-
fromFirestore: (snap) => BeautyProfile.toInstance(snap.data()),
|
|
3273
|
-
};
|
|
3274
|
-
}
|
|
3275
|
-
}
|
|
3276
|
-
tslib.__decorate([
|
|
3277
|
-
Log(),
|
|
3278
|
-
tslib.__metadata("design:type", Function),
|
|
3279
|
-
tslib.__metadata("design:paramtypes", [Object]),
|
|
3280
|
-
tslib.__metadata("design:returntype", Promise)
|
|
3281
|
-
], UserFirestoreRepository.prototype, "get", null);
|
|
3282
|
-
tslib.__decorate([
|
|
3283
|
-
Log(),
|
|
3284
|
-
tslib.__metadata("design:type", Function),
|
|
3285
|
-
tslib.__metadata("design:paramtypes", [String, String]),
|
|
3286
|
-
tslib.__metadata("design:returntype", Promise)
|
|
3287
|
-
], UserFirestoreRepository.prototype, "checkIfExistsByField", null);
|
|
3288
|
-
|
|
3289
|
-
class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3290
|
-
constructor({ firestore, interceptors }, parentRepository) {
|
|
3291
|
-
super({
|
|
3292
|
-
firestore,
|
|
3293
|
-
collectionName: 'payment_method',
|
|
3294
|
-
parentIdField: 'userId',
|
|
3295
|
-
model: UserPaymentMethod,
|
|
3296
|
-
interceptors,
|
|
3297
|
-
});
|
|
3298
|
-
this.parentRepository = parentRepository;
|
|
3299
|
-
}
|
|
3300
|
-
}
|
|
3301
|
-
|
|
3302
|
-
class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3303
|
-
constructor({ firestore, interceptors }) {
|
|
3304
|
-
super({
|
|
3305
|
-
firestore,
|
|
3306
|
-
collectionName: 'categories',
|
|
3307
|
-
model: Category,
|
|
3308
|
-
interceptors,
|
|
3309
|
-
});
|
|
3310
|
-
}
|
|
3311
|
-
async getCategoryBySlug(slug, shop) {
|
|
3312
|
-
const categoryDocs = await this.collection(this.collectionName)
|
|
3313
|
-
.where('slug', '==', slug)
|
|
3314
|
-
.where('shop', '==', shop)
|
|
3315
|
-
.where('published', '==', true)
|
|
3316
|
-
.getDocs();
|
|
3317
|
-
if (categoryDocs.size > 1)
|
|
3318
|
-
throw new DuplicatedResultsError('Query returned duplicated values');
|
|
3319
|
-
if (categoryDocs.empty)
|
|
3320
|
-
throw new NotFoundError(`Document with slug ${slug} not found`);
|
|
3321
|
-
return categoryDocs.docs[0].data();
|
|
3322
|
-
}
|
|
3323
|
-
async getCategoriesForHome(categoryIds, limit = 4, gender) {
|
|
3324
|
-
const categorySnap = await this.collection(this.collectionName)
|
|
3325
|
-
.where('id', 'in', categoryIds.filter(Boolean))
|
|
3326
|
-
.where('published', '==', true)
|
|
3327
|
-
.getDocs();
|
|
3328
|
-
if (categorySnap.empty)
|
|
3329
|
-
throw new NotFoundError('Categories not found');
|
|
3330
|
-
const categories = categorySnap.docs.map((doc) => doc.data());
|
|
3331
|
-
const homeSections = await Promise.all(categories.map(async (category) => ({
|
|
3332
|
-
category,
|
|
3333
|
-
products: await this.mountCategory(category, { limit, hasStock: true, gender }),
|
|
3334
|
-
})));
|
|
3335
|
-
return homeSections;
|
|
3336
|
-
}
|
|
3337
|
-
async mountCategory(category, options) {
|
|
3338
|
-
if (!category.products)
|
|
3339
|
-
throw new RequiredArgumentError(['Category products is empty']);
|
|
3340
|
-
const chunks = lodash.chunk(category.products, 10);
|
|
3341
|
-
const products = [];
|
|
3342
|
-
const wheres = [];
|
|
3343
|
-
for (const productIds of chunks) {
|
|
3344
|
-
if ((options === null || options === void 0 ? void 0 : options.limit) && products.length >= (options === null || options === void 0 ? void 0 : options.limit))
|
|
3345
|
-
break;
|
|
3346
|
-
wheres.push(['published', '==', true], ['id', 'in', productIds]);
|
|
3347
|
-
if (options === null || options === void 0 ? void 0 : options.hasStock)
|
|
3348
|
-
wheres.push(['stock.quantity', '>', 0]);
|
|
3349
|
-
if (options === null || options === void 0 ? void 0 : options.gender)
|
|
3350
|
-
wheres.push(['tags', 'array-contains', options === null || options === void 0 ? void 0 : options.gender]);
|
|
3351
|
-
const productSnap = await wheres
|
|
3352
|
-
.reduce((collection, where) => collection.where(...where), (options === null || options === void 0 ? void 0 : options.limit)
|
|
3353
|
-
? this.collection('productsErpVitrine').limit(options.limit)
|
|
3354
|
-
: this.collection('productsErpVitrine'))
|
|
3355
|
-
.getDocs();
|
|
3356
|
-
if (productSnap.empty)
|
|
3357
|
-
continue;
|
|
3358
|
-
products.push(...productSnap.docs);
|
|
3359
|
-
}
|
|
3360
|
-
return is(products);
|
|
3361
|
-
}
|
|
3362
|
-
getCategoryByShop(shop) {
|
|
3363
|
-
return;
|
|
3364
|
-
}
|
|
3365
|
-
getChildren(parentId) {
|
|
3366
|
-
return;
|
|
3367
|
-
}
|
|
3368
|
-
isChild(id, parentId) {
|
|
3369
|
-
return;
|
|
3370
|
-
}
|
|
3371
|
-
}
|
|
3372
|
-
tslib.__decorate([
|
|
3373
|
-
Log(),
|
|
3374
|
-
tslib.__metadata("design:type", Function),
|
|
3375
|
-
tslib.__metadata("design:paramtypes", [String, String]),
|
|
3376
|
-
tslib.__metadata("design:returntype", Promise)
|
|
3377
|
-
], CategoryFirestoreRepository.prototype, "getCategoryBySlug", null);
|
|
3378
|
-
tslib.__decorate([
|
|
3379
|
-
Log(),
|
|
3380
|
-
tslib.__metadata("design:type", Function),
|
|
3381
|
-
tslib.__metadata("design:paramtypes", [Array, Object, String]),
|
|
3382
|
-
tslib.__metadata("design:returntype", Promise)
|
|
3383
|
-
], CategoryFirestoreRepository.prototype, "getCategoriesForHome", null);
|
|
3384
|
-
tslib.__decorate([
|
|
3385
|
-
Log(),
|
|
3386
|
-
tslib.__metadata("design:type", Function),
|
|
3387
|
-
tslib.__metadata("design:paramtypes", [Category, Object]),
|
|
3388
|
-
tslib.__metadata("design:returntype", Promise)
|
|
3389
|
-
], CategoryFirestoreRepository.prototype, "mountCategory", null);
|
|
3390
|
-
|
|
3391
|
-
class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3392
|
-
constructor({ firestore, interceptors }) {
|
|
3393
|
-
super({
|
|
3394
|
-
firestore,
|
|
3395
|
-
collectionName: 'productsErpVitrine',
|
|
3396
|
-
model: Product,
|
|
3397
|
-
interceptors,
|
|
3398
|
-
});
|
|
3399
|
-
this.reviews = {};
|
|
3216
|
+
this.reviews = {};
|
|
3400
3217
|
}
|
|
3401
3218
|
fetchProductReviews(filters) {
|
|
3402
3219
|
throw new Error('Method not implemented.');
|
|
@@ -3483,6 +3300,101 @@ class SubscriptionProductFirestoreRepository extends withCrudFirestore(withHelpe
|
|
|
3483
3300
|
}
|
|
3484
3301
|
}
|
|
3485
3302
|
|
|
3303
|
+
class LogFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3304
|
+
constructor({ firestore, interceptors, }) {
|
|
3305
|
+
super({
|
|
3306
|
+
firestore,
|
|
3307
|
+
collectionName: 'logs',
|
|
3308
|
+
model: LogDocument,
|
|
3309
|
+
interceptors,
|
|
3310
|
+
});
|
|
3311
|
+
}
|
|
3312
|
+
}
|
|
3313
|
+
|
|
3314
|
+
class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3315
|
+
constructor({ firestore, interceptors }) {
|
|
3316
|
+
super({
|
|
3317
|
+
firestore,
|
|
3318
|
+
collectionName: 'dms',
|
|
3319
|
+
model: Home,
|
|
3320
|
+
interceptors,
|
|
3321
|
+
});
|
|
3322
|
+
this.homeCategoryGroupToPlain = (homeCategoryGroup) => {
|
|
3323
|
+
var _a, _b, _c;
|
|
3324
|
+
return ({
|
|
3325
|
+
category: ((_a = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _a === void 0 ? void 0 : _a.toPlain)
|
|
3326
|
+
? (_b = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _b === void 0 ? void 0 : _b.toPlain()
|
|
3327
|
+
: homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category,
|
|
3328
|
+
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)) || [],
|
|
3329
|
+
});
|
|
3330
|
+
};
|
|
3331
|
+
this.plainToHomeCategoryGroup = (homeCategoryGroup) => {
|
|
3332
|
+
var _a;
|
|
3333
|
+
return ({
|
|
3334
|
+
category: Category.toInstance(homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category),
|
|
3335
|
+
products: (_a = homeCategoryGroup.products) === null || _a === void 0 ? void 0 : _a.map((product) => Product.toInstance(product)),
|
|
3336
|
+
});
|
|
3337
|
+
};
|
|
3338
|
+
}
|
|
3339
|
+
buildModelInstance() {
|
|
3340
|
+
const { fromFirestore, toFirestore } = super.buildModelInstance();
|
|
3341
|
+
return {
|
|
3342
|
+
toFirestore: (data) => {
|
|
3343
|
+
const modifiedData = this.homeToFirestore(data);
|
|
3344
|
+
return toFirestore(modifiedData);
|
|
3345
|
+
},
|
|
3346
|
+
fromFirestore: (snap) => {
|
|
3347
|
+
const instance = fromFirestore(snap);
|
|
3348
|
+
return this.homeFromFirestore(instance);
|
|
3349
|
+
},
|
|
3350
|
+
};
|
|
3351
|
+
}
|
|
3352
|
+
homeToFirestore(home) {
|
|
3353
|
+
var _a, _b, _c, _d;
|
|
3354
|
+
if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
|
|
3355
|
+
home.data.data.discoverProducts = ((_b = home.data.data.discoverProducts) === null || _b === void 0 ? void 0 : _b.map(this.homeCategoryGroupToPlain)) || [];
|
|
3356
|
+
home.data.data.featuredProducts = ((_c = home.data.data.featuredProducts) === null || _c === void 0 ? void 0 : _c.map(this.homeCategoryGroupToPlain)) || [];
|
|
3357
|
+
home.data.data.verticalProducts = ((_d = home.data.data.verticalProducts) === null || _d === void 0 ? void 0 : _d.map(this.homeCategoryGroupToPlain)) || [];
|
|
3358
|
+
}
|
|
3359
|
+
return home;
|
|
3360
|
+
}
|
|
3361
|
+
homeFromFirestore(home) {
|
|
3362
|
+
var _a;
|
|
3363
|
+
if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
|
|
3364
|
+
home.data.data.discoverProducts = home.data.data.discoverProducts.map(this.plainToHomeCategoryGroup);
|
|
3365
|
+
home.data.data.featuredProducts = home.data.data.featuredProducts.map(this.plainToHomeCategoryGroup);
|
|
3366
|
+
home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.plainToHomeCategoryGroup);
|
|
3367
|
+
home.data.createdAt =
|
|
3368
|
+
home.data.createdAt instanceof firestore.Timestamp ? home.data.createdAt.toDate() : home.data.createdAt;
|
|
3369
|
+
home.data.expiresAt =
|
|
3370
|
+
home.data.expiresAt instanceof firestore.Timestamp ? home.data.expiresAt.toDate() : home.data.expiresAt;
|
|
3371
|
+
}
|
|
3372
|
+
return home;
|
|
3373
|
+
}
|
|
3374
|
+
}
|
|
3375
|
+
|
|
3376
|
+
class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3377
|
+
constructor({ firestore, interceptors }) {
|
|
3378
|
+
super({
|
|
3379
|
+
firestore,
|
|
3380
|
+
collectionName: 'shopMenus',
|
|
3381
|
+
model: ShopMenu,
|
|
3382
|
+
interceptors,
|
|
3383
|
+
});
|
|
3384
|
+
}
|
|
3385
|
+
}
|
|
3386
|
+
|
|
3387
|
+
class ShopSettingsFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3388
|
+
constructor({ firestore, interceptors, }) {
|
|
3389
|
+
super({
|
|
3390
|
+
firestore,
|
|
3391
|
+
collectionName: 'shopSettings',
|
|
3392
|
+
model: ShopSettings,
|
|
3393
|
+
interceptors,
|
|
3394
|
+
});
|
|
3395
|
+
}
|
|
3396
|
+
}
|
|
3397
|
+
|
|
3486
3398
|
class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3487
3399
|
constructor({ firestore, interceptors }) {
|
|
3488
3400
|
super({
|
|
@@ -3676,87 +3588,177 @@ class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(
|
|
|
3676
3588
|
}
|
|
3677
3589
|
}
|
|
3678
3590
|
|
|
3679
|
-
class
|
|
3591
|
+
class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3680
3592
|
constructor({ firestore, interceptors }) {
|
|
3681
3593
|
super({
|
|
3682
3594
|
firestore,
|
|
3683
|
-
collectionName: '
|
|
3684
|
-
model:
|
|
3595
|
+
collectionName: 'leads',
|
|
3596
|
+
model: Lead,
|
|
3685
3597
|
interceptors,
|
|
3686
3598
|
});
|
|
3687
|
-
this.homeCategoryGroupToPlain = (homeCategoryGroup) => {
|
|
3688
|
-
var _a, _b, _c;
|
|
3689
|
-
return ({
|
|
3690
|
-
category: ((_a = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _a === void 0 ? void 0 : _a.toPlain)
|
|
3691
|
-
? (_b = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _b === void 0 ? void 0 : _b.toPlain()
|
|
3692
|
-
: homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category,
|
|
3693
|
-
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)) || [],
|
|
3694
|
-
});
|
|
3695
|
-
};
|
|
3696
|
-
this.plainToHomeCategoryGroup = (homeCategoryGroup) => {
|
|
3697
|
-
var _a;
|
|
3698
|
-
return ({
|
|
3699
|
-
category: Category.toInstance(homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category),
|
|
3700
|
-
products: (_a = homeCategoryGroup.products) === null || _a === void 0 ? void 0 : _a.map((product) => Product.toInstance(product)),
|
|
3701
|
-
});
|
|
3702
|
-
};
|
|
3703
3599
|
}
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
}
|
|
3717
|
-
homeToFirestore(home) {
|
|
3718
|
-
var _a, _b, _c, _d;
|
|
3719
|
-
if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
|
|
3720
|
-
home.data.data.discoverProducts = ((_b = home.data.data.discoverProducts) === null || _b === void 0 ? void 0 : _b.map(this.homeCategoryGroupToPlain)) || [];
|
|
3721
|
-
home.data.data.featuredProducts = ((_c = home.data.data.featuredProducts) === null || _c === void 0 ? void 0 : _c.map(this.homeCategoryGroupToPlain)) || [];
|
|
3722
|
-
home.data.data.verticalProducts = ((_d = home.data.data.verticalProducts) === null || _d === void 0 ? void 0 : _d.map(this.homeCategoryGroupToPlain)) || [];
|
|
3723
|
-
}
|
|
3724
|
-
return home;
|
|
3600
|
+
}
|
|
3601
|
+
|
|
3602
|
+
class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3603
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
3604
|
+
super({
|
|
3605
|
+
firestore,
|
|
3606
|
+
collectionName: 'editions',
|
|
3607
|
+
parentIdField: 'subscriptionId',
|
|
3608
|
+
model: Edition,
|
|
3609
|
+
interceptors,
|
|
3610
|
+
});
|
|
3611
|
+
this.parentRepository = parentRepository;
|
|
3725
3612
|
}
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
}
|
|
3737
|
-
return home;
|
|
3613
|
+
}
|
|
3614
|
+
|
|
3615
|
+
class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3616
|
+
constructor({ firestore, interceptors, }) {
|
|
3617
|
+
super({
|
|
3618
|
+
firestore,
|
|
3619
|
+
collectionName: 'subscription',
|
|
3620
|
+
model: Subscription,
|
|
3621
|
+
interceptors,
|
|
3622
|
+
});
|
|
3738
3623
|
}
|
|
3739
3624
|
}
|
|
3740
3625
|
|
|
3741
|
-
class
|
|
3626
|
+
class SubscriptionMaterializationFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3742
3627
|
constructor({ firestore, interceptors }) {
|
|
3743
3628
|
super({
|
|
3744
3629
|
firestore,
|
|
3745
|
-
collectionName: '
|
|
3746
|
-
model:
|
|
3630
|
+
collectionName: 'subscriptionMaterialization',
|
|
3631
|
+
model: SubscriptionMaterialization,
|
|
3747
3632
|
interceptors,
|
|
3748
3633
|
});
|
|
3749
3634
|
}
|
|
3750
3635
|
}
|
|
3751
3636
|
|
|
3752
|
-
class
|
|
3637
|
+
class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3638
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
3639
|
+
super({
|
|
3640
|
+
firestore,
|
|
3641
|
+
collectionName: 'payments',
|
|
3642
|
+
parentIdField: 'subscriptionId',
|
|
3643
|
+
model: SubscriptionPayment,
|
|
3644
|
+
interceptors,
|
|
3645
|
+
});
|
|
3646
|
+
this.parentRepository = parentRepository;
|
|
3647
|
+
}
|
|
3648
|
+
}
|
|
3649
|
+
|
|
3650
|
+
class SubscriptionSummaryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3753
3651
|
constructor({ firestore, interceptors, }) {
|
|
3754
3652
|
super({
|
|
3755
3653
|
firestore,
|
|
3756
|
-
collectionName: '
|
|
3757
|
-
model:
|
|
3654
|
+
collectionName: 'subscriptionSummary',
|
|
3655
|
+
model: SubscriptionSummary,
|
|
3656
|
+
interceptors,
|
|
3657
|
+
});
|
|
3658
|
+
}
|
|
3659
|
+
}
|
|
3660
|
+
|
|
3661
|
+
class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3662
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
3663
|
+
super({
|
|
3664
|
+
firestore,
|
|
3665
|
+
collectionName: 'address',
|
|
3666
|
+
parentIdField: 'userId',
|
|
3667
|
+
model: UserAddress,
|
|
3668
|
+
interceptors,
|
|
3669
|
+
});
|
|
3670
|
+
this.parentRepository = parentRepository;
|
|
3671
|
+
}
|
|
3672
|
+
}
|
|
3673
|
+
|
|
3674
|
+
class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3675
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
3676
|
+
super({
|
|
3677
|
+
firestore,
|
|
3678
|
+
collectionName: 'CX',
|
|
3679
|
+
parentIdField: 'userId',
|
|
3680
|
+
model: BeautyProfile,
|
|
3681
|
+
interceptors,
|
|
3682
|
+
});
|
|
3683
|
+
this.parentRepository = parentRepository;
|
|
3684
|
+
}
|
|
3685
|
+
}
|
|
3686
|
+
|
|
3687
|
+
class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3688
|
+
constructor({ firestore, interceptors }) {
|
|
3689
|
+
super({
|
|
3690
|
+
firestore,
|
|
3691
|
+
collectionName: 'users',
|
|
3692
|
+
model: User,
|
|
3693
|
+
interceptors,
|
|
3694
|
+
});
|
|
3695
|
+
}
|
|
3696
|
+
async get(identifiers) {
|
|
3697
|
+
const user = await super.get({ id: identifiers.id });
|
|
3698
|
+
user.beautyProfile = await this.getBeautyProfile(user.id);
|
|
3699
|
+
user.isSubscriber = await this.checkIfIsSubscriber(user.id);
|
|
3700
|
+
return user;
|
|
3701
|
+
}
|
|
3702
|
+
async checkIfExistsByField(field, value) {
|
|
3703
|
+
const result = await this.find({ filters: { [field]: value } });
|
|
3704
|
+
return result.count > 0;
|
|
3705
|
+
}
|
|
3706
|
+
buildModelInstance() {
|
|
3707
|
+
const { fromFirestore, toFirestore } = super.buildModelInstance();
|
|
3708
|
+
return {
|
|
3709
|
+
toFirestore: (data) => {
|
|
3710
|
+
const plain = toFirestore(data);
|
|
3711
|
+
delete plain.isSubscriber;
|
|
3712
|
+
return plain;
|
|
3713
|
+
},
|
|
3714
|
+
fromFirestore,
|
|
3715
|
+
};
|
|
3716
|
+
}
|
|
3717
|
+
async getBeautyProfile(userId) {
|
|
3718
|
+
const beautyProfile = await this.firestore
|
|
3719
|
+
.getCollection(`${this.collectionName}/${userId}/CX`)
|
|
3720
|
+
.withConverter(this.buildBeautyProfileModelInstance())
|
|
3721
|
+
.getDoc('beautyProfile')
|
|
3722
|
+
.get();
|
|
3723
|
+
return beautyProfile.data();
|
|
3724
|
+
}
|
|
3725
|
+
async checkIfIsSubscriber(userId) {
|
|
3726
|
+
const docs = await this.collection('subscription')
|
|
3727
|
+
.where('user.id', '==', userId)
|
|
3728
|
+
.where('status', '==', 'active')
|
|
3729
|
+
.getDocs();
|
|
3730
|
+
return !!docs && !!docs.size;
|
|
3731
|
+
}
|
|
3732
|
+
buildBeautyProfileModelInstance() {
|
|
3733
|
+
return {
|
|
3734
|
+
toFirestore: (data) => data.toPlain(),
|
|
3735
|
+
fromFirestore: (snap) => BeautyProfile.toInstance(snap.data()),
|
|
3736
|
+
};
|
|
3737
|
+
}
|
|
3738
|
+
}
|
|
3739
|
+
tslib.__decorate([
|
|
3740
|
+
Log(),
|
|
3741
|
+
tslib.__metadata("design:type", Function),
|
|
3742
|
+
tslib.__metadata("design:paramtypes", [Object]),
|
|
3743
|
+
tslib.__metadata("design:returntype", Promise)
|
|
3744
|
+
], UserFirestoreRepository.prototype, "get", null);
|
|
3745
|
+
tslib.__decorate([
|
|
3746
|
+
Log(),
|
|
3747
|
+
tslib.__metadata("design:type", Function),
|
|
3748
|
+
tslib.__metadata("design:paramtypes", [String, String]),
|
|
3749
|
+
tslib.__metadata("design:returntype", Promise)
|
|
3750
|
+
], UserFirestoreRepository.prototype, "checkIfExistsByField", null);
|
|
3751
|
+
|
|
3752
|
+
class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3753
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
3754
|
+
super({
|
|
3755
|
+
firestore,
|
|
3756
|
+
collectionName: 'payment_method',
|
|
3757
|
+
parentIdField: 'userId',
|
|
3758
|
+
model: UserPaymentMethod,
|
|
3758
3759
|
interceptors,
|
|
3759
3760
|
});
|
|
3761
|
+
this.parentRepository = parentRepository;
|
|
3760
3762
|
}
|
|
3761
3763
|
}
|
|
3762
3764
|
|
|
@@ -4947,7 +4949,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4947
4949
|
});
|
|
4948
4950
|
return data;
|
|
4949
4951
|
}
|
|
4950
|
-
async getCategoriesForHome(categoryIds, limit = 4
|
|
4952
|
+
async getCategoriesForHome(categoryIds, shop, limit = 4) {
|
|
4951
4953
|
if (!(categoryIds === null || categoryIds === void 0 ? void 0 : categoryIds.length))
|
|
4952
4954
|
return [];
|
|
4953
4955
|
const categoriesFirestore = categoryIds.filter((categoryId) => Number.isNaN(+categoryId));
|
|
@@ -4959,22 +4961,32 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4959
4961
|
}).then(({ data }) => data)));
|
|
4960
4962
|
if (categoriesHasura.length)
|
|
4961
4963
|
categories.push(...(await this.find({
|
|
4962
|
-
filters: {
|
|
4964
|
+
filters: {
|
|
4965
|
+
id: { operator: exports.Where.IN, value: categoriesHasura.filter(Boolean) },
|
|
4966
|
+
published: true,
|
|
4967
|
+
},
|
|
4963
4968
|
}).then(({ data }) => data)));
|
|
4964
4969
|
if (!categories.length)
|
|
4965
4970
|
return [];
|
|
4966
4971
|
const homeSections = await Promise.all(categories.map(async (category) => ({
|
|
4967
4972
|
category,
|
|
4968
|
-
products: await this.mountCategory(category, { limit, hasStock: true
|
|
4973
|
+
products: await this.mountCategory(category, shop, { limit, hasStock: true }),
|
|
4969
4974
|
})));
|
|
4970
4975
|
return homeSections;
|
|
4971
4976
|
}
|
|
4972
|
-
async mountCategory(category, options) {
|
|
4977
|
+
async mountCategory(category, shop, options) {
|
|
4973
4978
|
var _a;
|
|
4974
4979
|
if (!((_a = category === null || category === void 0 ? void 0 : category.products) === null || _a === void 0 ? void 0 : _a.length))
|
|
4975
4980
|
return [];
|
|
4981
|
+
const mostRelevants = category.getMostRelevantByShop(shop);
|
|
4982
|
+
const mostRelevantProductsIds = [...new Set(mostRelevants.concat(category.products))];
|
|
4976
4983
|
const products = [];
|
|
4977
|
-
const { data: productsData } = await this.productRepository.find(
|
|
4984
|
+
const { data: productsData } = await this.productRepository.find({
|
|
4985
|
+
filters: {
|
|
4986
|
+
id: { operator: exports.Where.IN, value: mostRelevantProductsIds },
|
|
4987
|
+
published: true,
|
|
4988
|
+
},
|
|
4989
|
+
fields: [
|
|
4978
4990
|
'id',
|
|
4979
4991
|
'name',
|
|
4980
4992
|
'slug',
|
|
@@ -5000,8 +5012,25 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
5000
5012
|
'shoppingCount',
|
|
5001
5013
|
'gender',
|
|
5002
5014
|
'createdAt',
|
|
5003
|
-
]
|
|
5004
|
-
|
|
5015
|
+
],
|
|
5016
|
+
options: { enableCount: false },
|
|
5017
|
+
orderBy: {
|
|
5018
|
+
shoppingCount: 'desc',
|
|
5019
|
+
rate: 'desc',
|
|
5020
|
+
stock: 'desc',
|
|
5021
|
+
name: 'asc',
|
|
5022
|
+
},
|
|
5023
|
+
});
|
|
5024
|
+
const mostRelevantWithouyStock = productsData.filter((product) => mostRelevants.includes(product.id) && product.stock.quantity <= 0);
|
|
5025
|
+
const firstProducts = productsData
|
|
5026
|
+
.filter((product) => mostRelevants.includes(product.id) && product.stock.quantity > 0)
|
|
5027
|
+
.sort((a, b) => mostRelevants.indexOf(a.id) - mostRelevants.indexOf(b.id));
|
|
5028
|
+
const lastProducts = productsData
|
|
5029
|
+
.filter((product) => !mostRelevants.includes(product.id))
|
|
5030
|
+
.concat(mostRelevantWithouyStock);
|
|
5031
|
+
const categoryMostRelevants = firstProducts.concat(lastProducts);
|
|
5032
|
+
const resultFinal = categoryMostRelevants.slice(0, options.limit);
|
|
5033
|
+
products.push(...resultFinal);
|
|
5005
5034
|
return products;
|
|
5006
5035
|
}
|
|
5007
5036
|
async getChildren(parentId) {
|
|
@@ -5176,13 +5205,13 @@ tslib.__decorate([
|
|
|
5176
5205
|
tslib.__decorate([
|
|
5177
5206
|
Log(),
|
|
5178
5207
|
tslib.__metadata("design:type", Function),
|
|
5179
|
-
tslib.__metadata("design:paramtypes", [Array,
|
|
5208
|
+
tslib.__metadata("design:paramtypes", [Array, String, Object]),
|
|
5180
5209
|
tslib.__metadata("design:returntype", Promise)
|
|
5181
5210
|
], CategoryHasuraGraphQLRepository.prototype, "getCategoriesForHome", null);
|
|
5182
5211
|
tslib.__decorate([
|
|
5183
5212
|
Log(),
|
|
5184
5213
|
tslib.__metadata("design:type", Function),
|
|
5185
|
-
tslib.__metadata("design:paramtypes", [Category, Object]),
|
|
5214
|
+
tslib.__metadata("design:paramtypes", [Category, String, Object]),
|
|
5186
5215
|
tslib.__metadata("design:returntype", Promise)
|
|
5187
5216
|
], CategoryHasuraGraphQLRepository.prototype, "mountCategory", null);
|
|
5188
5217
|
tslib.__decorate([
|
|
@@ -6313,10 +6342,10 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
6313
6342
|
value: [exports.PersonTypes.BFLU, exports.PersonTypes.GLAMGIRL],
|
|
6314
6343
|
} }), orderBy: Object.assign({ personHasPhoto: 'desc' }, lodash.omit(params.orderBy, ['personHasPhoto'])) }));
|
|
6315
6344
|
}
|
|
6316
|
-
getCategoriesForHome(categoryIds,
|
|
6345
|
+
getCategoriesForHome(categoryIds, gender, limit) {
|
|
6317
6346
|
return;
|
|
6318
6347
|
}
|
|
6319
|
-
mountCategory(category, options) {
|
|
6348
|
+
mountCategory(category, shop, options) {
|
|
6320
6349
|
return;
|
|
6321
6350
|
}
|
|
6322
6351
|
getChildren(parentId) {
|
|
@@ -6527,6 +6556,9 @@ class VertexAxiosAdapter {
|
|
|
6527
6556
|
throw error;
|
|
6528
6557
|
}
|
|
6529
6558
|
}
|
|
6559
|
+
bulkProducts(products) {
|
|
6560
|
+
return;
|
|
6561
|
+
}
|
|
6530
6562
|
}
|
|
6531
6563
|
|
|
6532
6564
|
class ProductsVertexSearch {
|
|
@@ -6745,6 +6777,8 @@ exports.LeadFirestoreRepository = LeadFirestoreRepository;
|
|
|
6745
6777
|
exports.LegacyOrderFirestoreRepository = LegacyOrderFirestoreRepository;
|
|
6746
6778
|
exports.LineItem = LineItem;
|
|
6747
6779
|
exports.Log = Log;
|
|
6780
|
+
exports.LogDocument = LogDocument;
|
|
6781
|
+
exports.LogFirestoreRepository = LogFirestoreRepository;
|
|
6748
6782
|
exports.Logger = Logger;
|
|
6749
6783
|
exports.NotFoundError = NotFoundError;
|
|
6750
6784
|
exports.Order = Order;
|