@infrab4a/connect 4.9.7-beta.25 → 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 +306 -248
- package/index.esm.js +305 -249
- 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/enums/coupon-category.enum.d.ts +3 -0
- 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/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'];
|
|
@@ -2130,6 +2139,9 @@ exports.CouponCategory = void 0;
|
|
|
2130
2139
|
CouponCategory["Desculpas"] = "Desculpas";
|
|
2131
2140
|
CouponCategory["BFlu"] = "BFlu";
|
|
2132
2141
|
CouponCategory["ROYAL"] = "Royal";
|
|
2142
|
+
CouponCategory["Glamqueen"] = "Glamqueen";
|
|
2143
|
+
CouponCategory["Glampartner"] = "Glampartner";
|
|
2144
|
+
CouponCategory["Glamgirl"] = "Glamgirl";
|
|
2133
2145
|
CouponCategory["Glamdiva"] = "Glamdiva";
|
|
2134
2146
|
CouponCategory["Impulsionamento"] = "Impulsionamento";
|
|
2135
2147
|
CouponCategory["PaidMedia"] = "Paid Media";
|
|
@@ -2231,6 +2243,12 @@ class RoundProductPricesHelper {
|
|
|
2231
2243
|
}
|
|
2232
2244
|
}
|
|
2233
2245
|
|
|
2246
|
+
class LogDocument extends BaseModel {
|
|
2247
|
+
static get identifiersFields() {
|
|
2248
|
+
return ['id'];
|
|
2249
|
+
}
|
|
2250
|
+
}
|
|
2251
|
+
|
|
2234
2252
|
exports.FilterType = void 0;
|
|
2235
2253
|
(function (FilterType) {
|
|
2236
2254
|
FilterType["ACCESSORY_IMPORTANCE"] = "accessoryImportance";
|
|
@@ -3098,180 +3116,6 @@ const withCrudFirestore = (MixinBase) => {
|
|
|
3098
3116
|
};
|
|
3099
3117
|
};
|
|
3100
3118
|
|
|
3101
|
-
class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3102
|
-
constructor({ firestore, interceptors }) {
|
|
3103
|
-
super({
|
|
3104
|
-
firestore,
|
|
3105
|
-
collectionName: 'leads',
|
|
3106
|
-
model: Lead,
|
|
3107
|
-
interceptors,
|
|
3108
|
-
});
|
|
3109
|
-
}
|
|
3110
|
-
}
|
|
3111
|
-
|
|
3112
|
-
class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3113
|
-
constructor({ firestore, interceptors }, parentRepository) {
|
|
3114
|
-
super({
|
|
3115
|
-
firestore,
|
|
3116
|
-
collectionName: 'editions',
|
|
3117
|
-
parentIdField: 'subscriptionId',
|
|
3118
|
-
model: Edition,
|
|
3119
|
-
interceptors,
|
|
3120
|
-
});
|
|
3121
|
-
this.parentRepository = parentRepository;
|
|
3122
|
-
}
|
|
3123
|
-
}
|
|
3124
|
-
|
|
3125
|
-
class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3126
|
-
constructor({ firestore, interceptors, }) {
|
|
3127
|
-
super({
|
|
3128
|
-
firestore,
|
|
3129
|
-
collectionName: 'subscription',
|
|
3130
|
-
model: Subscription,
|
|
3131
|
-
interceptors,
|
|
3132
|
-
});
|
|
3133
|
-
}
|
|
3134
|
-
}
|
|
3135
|
-
|
|
3136
|
-
class SubscriptionMaterializationFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3137
|
-
constructor({ firestore, interceptors }) {
|
|
3138
|
-
super({
|
|
3139
|
-
firestore,
|
|
3140
|
-
collectionName: 'subscriptionMaterialization',
|
|
3141
|
-
model: SubscriptionMaterialization,
|
|
3142
|
-
interceptors,
|
|
3143
|
-
});
|
|
3144
|
-
}
|
|
3145
|
-
}
|
|
3146
|
-
|
|
3147
|
-
class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3148
|
-
constructor({ firestore, interceptors }, parentRepository) {
|
|
3149
|
-
super({
|
|
3150
|
-
firestore,
|
|
3151
|
-
collectionName: 'payments',
|
|
3152
|
-
parentIdField: 'subscriptionId',
|
|
3153
|
-
model: SubscriptionPayment,
|
|
3154
|
-
interceptors,
|
|
3155
|
-
});
|
|
3156
|
-
this.parentRepository = parentRepository;
|
|
3157
|
-
}
|
|
3158
|
-
}
|
|
3159
|
-
|
|
3160
|
-
class SubscriptionSummaryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3161
|
-
constructor({ firestore, interceptors, }) {
|
|
3162
|
-
super({
|
|
3163
|
-
firestore,
|
|
3164
|
-
collectionName: 'subscriptionSummary',
|
|
3165
|
-
model: SubscriptionSummary,
|
|
3166
|
-
interceptors,
|
|
3167
|
-
});
|
|
3168
|
-
}
|
|
3169
|
-
}
|
|
3170
|
-
|
|
3171
|
-
class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3172
|
-
constructor({ firestore, interceptors }, parentRepository) {
|
|
3173
|
-
super({
|
|
3174
|
-
firestore,
|
|
3175
|
-
collectionName: 'address',
|
|
3176
|
-
parentIdField: 'userId',
|
|
3177
|
-
model: UserAddress,
|
|
3178
|
-
interceptors,
|
|
3179
|
-
});
|
|
3180
|
-
this.parentRepository = parentRepository;
|
|
3181
|
-
}
|
|
3182
|
-
}
|
|
3183
|
-
|
|
3184
|
-
class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3185
|
-
constructor({ firestore, interceptors }, parentRepository) {
|
|
3186
|
-
super({
|
|
3187
|
-
firestore,
|
|
3188
|
-
collectionName: 'CX',
|
|
3189
|
-
parentIdField: 'userId',
|
|
3190
|
-
model: BeautyProfile,
|
|
3191
|
-
interceptors,
|
|
3192
|
-
});
|
|
3193
|
-
this.parentRepository = parentRepository;
|
|
3194
|
-
}
|
|
3195
|
-
}
|
|
3196
|
-
|
|
3197
|
-
class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3198
|
-
constructor({ firestore, interceptors }) {
|
|
3199
|
-
super({
|
|
3200
|
-
firestore,
|
|
3201
|
-
collectionName: 'users',
|
|
3202
|
-
model: User,
|
|
3203
|
-
interceptors,
|
|
3204
|
-
});
|
|
3205
|
-
}
|
|
3206
|
-
async get(identifiers) {
|
|
3207
|
-
const user = await super.get({ id: identifiers.id });
|
|
3208
|
-
user.beautyProfile = await this.getBeautyProfile(user.id);
|
|
3209
|
-
user.isSubscriber = await this.checkIfIsSubscriber(user.id);
|
|
3210
|
-
return user;
|
|
3211
|
-
}
|
|
3212
|
-
async checkIfExistsByField(field, value) {
|
|
3213
|
-
const result = await this.find({ filters: { [field]: value } });
|
|
3214
|
-
return result.count > 0;
|
|
3215
|
-
}
|
|
3216
|
-
buildModelInstance() {
|
|
3217
|
-
const { fromFirestore, toFirestore } = super.buildModelInstance();
|
|
3218
|
-
return {
|
|
3219
|
-
toFirestore: (data) => {
|
|
3220
|
-
const plain = toFirestore(data);
|
|
3221
|
-
delete plain.isSubscriber;
|
|
3222
|
-
return plain;
|
|
3223
|
-
},
|
|
3224
|
-
fromFirestore,
|
|
3225
|
-
};
|
|
3226
|
-
}
|
|
3227
|
-
async getBeautyProfile(userId) {
|
|
3228
|
-
const beautyProfile = await this.firestore
|
|
3229
|
-
.getCollection(`${this.collectionName}/${userId}/CX`)
|
|
3230
|
-
.withConverter(this.buildBeautyProfileModelInstance())
|
|
3231
|
-
.getDoc('beautyProfile')
|
|
3232
|
-
.get();
|
|
3233
|
-
return beautyProfile.data();
|
|
3234
|
-
}
|
|
3235
|
-
async checkIfIsSubscriber(userId) {
|
|
3236
|
-
const docs = await this.collection('subscription')
|
|
3237
|
-
.where('user.id', '==', userId)
|
|
3238
|
-
.where('status', '==', 'active')
|
|
3239
|
-
.getDocs();
|
|
3240
|
-
return !!docs && !!docs.size;
|
|
3241
|
-
}
|
|
3242
|
-
buildBeautyProfileModelInstance() {
|
|
3243
|
-
return {
|
|
3244
|
-
toFirestore: (data) => data.toPlain(),
|
|
3245
|
-
fromFirestore: (snap) => BeautyProfile.toInstance(snap.data()),
|
|
3246
|
-
};
|
|
3247
|
-
}
|
|
3248
|
-
}
|
|
3249
|
-
tslib.__decorate([
|
|
3250
|
-
Log(),
|
|
3251
|
-
tslib.__metadata("design:type", Function),
|
|
3252
|
-
tslib.__metadata("design:paramtypes", [Object]),
|
|
3253
|
-
tslib.__metadata("design:returntype", Promise)
|
|
3254
|
-
], UserFirestoreRepository.prototype, "get", null);
|
|
3255
|
-
tslib.__decorate([
|
|
3256
|
-
Log(),
|
|
3257
|
-
tslib.__metadata("design:type", Function),
|
|
3258
|
-
tslib.__metadata("design:paramtypes", [String, String]),
|
|
3259
|
-
tslib.__metadata("design:returntype", Promise)
|
|
3260
|
-
], UserFirestoreRepository.prototype, "checkIfExistsByField", null);
|
|
3261
|
-
|
|
3262
|
-
class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3263
|
-
constructor({ firestore, interceptors }, parentRepository) {
|
|
3264
|
-
super({
|
|
3265
|
-
firestore,
|
|
3266
|
-
collectionName: 'payment_method',
|
|
3267
|
-
parentIdField: 'userId',
|
|
3268
|
-
model: UserPaymentMethod,
|
|
3269
|
-
interceptors,
|
|
3270
|
-
});
|
|
3271
|
-
this.parentRepository = parentRepository;
|
|
3272
|
-
}
|
|
3273
|
-
}
|
|
3274
|
-
|
|
3275
3119
|
class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3276
3120
|
constructor({ firestore, interceptors }) {
|
|
3277
3121
|
super({
|
|
@@ -3293,7 +3137,7 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
3293
3137
|
throw new NotFoundError(`Document with slug ${slug} not found`);
|
|
3294
3138
|
return categoryDocs.docs[0].data();
|
|
3295
3139
|
}
|
|
3296
|
-
async getCategoriesForHome(categoryIds, limit = 4
|
|
3140
|
+
async getCategoriesForHome(categoryIds, shop, limit = 4) {
|
|
3297
3141
|
const categorySnap = await this.collection(this.collectionName)
|
|
3298
3142
|
.where('id', 'in', categoryIds.filter(Boolean))
|
|
3299
3143
|
.where('published', '==', true)
|
|
@@ -3303,11 +3147,11 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
3303
3147
|
const categories = categorySnap.docs.map((doc) => doc.data());
|
|
3304
3148
|
const homeSections = await Promise.all(categories.map(async (category) => ({
|
|
3305
3149
|
category,
|
|
3306
|
-
products: await this.mountCategory(category, { limit, hasStock: true
|
|
3150
|
+
products: await this.mountCategory(category, shop, { limit, hasStock: true }),
|
|
3307
3151
|
})));
|
|
3308
3152
|
return homeSections;
|
|
3309
3153
|
}
|
|
3310
|
-
async mountCategory(category, options) {
|
|
3154
|
+
async mountCategory(category, shop, options) {
|
|
3311
3155
|
if (!category.products)
|
|
3312
3156
|
throw new RequiredArgumentError(['Category products is empty']);
|
|
3313
3157
|
const chunks = lodash.chunk(category.products, 10);
|
|
@@ -3351,13 +3195,13 @@ tslib.__decorate([
|
|
|
3351
3195
|
tslib.__decorate([
|
|
3352
3196
|
Log(),
|
|
3353
3197
|
tslib.__metadata("design:type", Function),
|
|
3354
|
-
tslib.__metadata("design:paramtypes", [Array,
|
|
3198
|
+
tslib.__metadata("design:paramtypes", [Array, String, Object]),
|
|
3355
3199
|
tslib.__metadata("design:returntype", Promise)
|
|
3356
3200
|
], CategoryFirestoreRepository.prototype, "getCategoriesForHome", null);
|
|
3357
3201
|
tslib.__decorate([
|
|
3358
3202
|
Log(),
|
|
3359
3203
|
tslib.__metadata("design:type", Function),
|
|
3360
|
-
tslib.__metadata("design:paramtypes", [Category, Object]),
|
|
3204
|
+
tslib.__metadata("design:paramtypes", [Category, String, Object]),
|
|
3361
3205
|
tslib.__metadata("design:returntype", Promise)
|
|
3362
3206
|
], CategoryFirestoreRepository.prototype, "mountCategory", null);
|
|
3363
3207
|
|
|
@@ -3456,6 +3300,101 @@ class SubscriptionProductFirestoreRepository extends withCrudFirestore(withHelpe
|
|
|
3456
3300
|
}
|
|
3457
3301
|
}
|
|
3458
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
|
+
|
|
3459
3398
|
class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3460
3399
|
constructor({ firestore, interceptors }) {
|
|
3461
3400
|
super({
|
|
@@ -3649,90 +3588,180 @@ class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(
|
|
|
3649
3588
|
}
|
|
3650
3589
|
}
|
|
3651
3590
|
|
|
3652
|
-
class
|
|
3591
|
+
class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3653
3592
|
constructor({ firestore, interceptors }) {
|
|
3654
3593
|
super({
|
|
3655
3594
|
firestore,
|
|
3656
|
-
collectionName: '
|
|
3657
|
-
model:
|
|
3595
|
+
collectionName: 'leads',
|
|
3596
|
+
model: Lead,
|
|
3658
3597
|
interceptors,
|
|
3659
3598
|
});
|
|
3660
|
-
this.homeCategoryGroupToPlain = (homeCategoryGroup) => {
|
|
3661
|
-
var _a, _b, _c;
|
|
3662
|
-
return ({
|
|
3663
|
-
category: ((_a = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _a === void 0 ? void 0 : _a.toPlain)
|
|
3664
|
-
? (_b = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _b === void 0 ? void 0 : _b.toPlain()
|
|
3665
|
-
: homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category,
|
|
3666
|
-
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)) || [],
|
|
3667
|
-
});
|
|
3668
|
-
};
|
|
3669
|
-
this.plainToHomeCategoryGroup = (homeCategoryGroup) => {
|
|
3670
|
-
var _a;
|
|
3671
|
-
return ({
|
|
3672
|
-
category: Category.toInstance(homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category),
|
|
3673
|
-
products: (_a = homeCategoryGroup.products) === null || _a === void 0 ? void 0 : _a.map((product) => Product.toInstance(product)),
|
|
3674
|
-
});
|
|
3675
|
-
};
|
|
3676
|
-
}
|
|
3677
|
-
buildModelInstance() {
|
|
3678
|
-
const { fromFirestore, toFirestore } = super.buildModelInstance();
|
|
3679
|
-
return {
|
|
3680
|
-
toFirestore: (data) => {
|
|
3681
|
-
const modifiedData = this.homeToFirestore(data);
|
|
3682
|
-
return toFirestore(modifiedData);
|
|
3683
|
-
},
|
|
3684
|
-
fromFirestore: (snap) => {
|
|
3685
|
-
const instance = fromFirestore(snap);
|
|
3686
|
-
return this.homeFromFirestore(instance);
|
|
3687
|
-
},
|
|
3688
|
-
};
|
|
3689
3599
|
}
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
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;
|
|
3698
3612
|
}
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
}
|
|
3710
|
-
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
|
+
});
|
|
3711
3623
|
}
|
|
3712
3624
|
}
|
|
3713
3625
|
|
|
3714
|
-
class
|
|
3626
|
+
class SubscriptionMaterializationFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3715
3627
|
constructor({ firestore, interceptors }) {
|
|
3716
3628
|
super({
|
|
3717
3629
|
firestore,
|
|
3718
|
-
collectionName: '
|
|
3719
|
-
model:
|
|
3630
|
+
collectionName: 'subscriptionMaterialization',
|
|
3631
|
+
model: SubscriptionMaterialization,
|
|
3720
3632
|
interceptors,
|
|
3721
3633
|
});
|
|
3722
3634
|
}
|
|
3723
3635
|
}
|
|
3724
3636
|
|
|
3725
|
-
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))) {
|
|
3726
3651
|
constructor({ firestore, interceptors, }) {
|
|
3727
3652
|
super({
|
|
3728
3653
|
firestore,
|
|
3729
|
-
collectionName: '
|
|
3730
|
-
model:
|
|
3654
|
+
collectionName: 'subscriptionSummary',
|
|
3655
|
+
model: SubscriptionSummary,
|
|
3731
3656
|
interceptors,
|
|
3732
3657
|
});
|
|
3733
3658
|
}
|
|
3734
3659
|
}
|
|
3735
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,
|
|
3759
|
+
interceptors,
|
|
3760
|
+
});
|
|
3761
|
+
this.parentRepository = parentRepository;
|
|
3762
|
+
}
|
|
3763
|
+
}
|
|
3764
|
+
|
|
3736
3765
|
class ConnectBaseDocumentSnapshot {
|
|
3737
3766
|
constructor(connectDocumentSnapshot) {
|
|
3738
3767
|
this.connectDocumentSnapshot = connectDocumentSnapshot;
|
|
@@ -4920,7 +4949,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4920
4949
|
});
|
|
4921
4950
|
return data;
|
|
4922
4951
|
}
|
|
4923
|
-
async getCategoriesForHome(categoryIds, limit = 4
|
|
4952
|
+
async getCategoriesForHome(categoryIds, shop, limit = 4) {
|
|
4924
4953
|
if (!(categoryIds === null || categoryIds === void 0 ? void 0 : categoryIds.length))
|
|
4925
4954
|
return [];
|
|
4926
4955
|
const categoriesFirestore = categoryIds.filter((categoryId) => Number.isNaN(+categoryId));
|
|
@@ -4932,22 +4961,32 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4932
4961
|
}).then(({ data }) => data)));
|
|
4933
4962
|
if (categoriesHasura.length)
|
|
4934
4963
|
categories.push(...(await this.find({
|
|
4935
|
-
filters: {
|
|
4964
|
+
filters: {
|
|
4965
|
+
id: { operator: exports.Where.IN, value: categoriesHasura.filter(Boolean) },
|
|
4966
|
+
published: true,
|
|
4967
|
+
},
|
|
4936
4968
|
}).then(({ data }) => data)));
|
|
4937
4969
|
if (!categories.length)
|
|
4938
4970
|
return [];
|
|
4939
4971
|
const homeSections = await Promise.all(categories.map(async (category) => ({
|
|
4940
4972
|
category,
|
|
4941
|
-
products: await this.mountCategory(category, { limit, hasStock: true
|
|
4973
|
+
products: await this.mountCategory(category, shop, { limit, hasStock: true }),
|
|
4942
4974
|
})));
|
|
4943
4975
|
return homeSections;
|
|
4944
4976
|
}
|
|
4945
|
-
async mountCategory(category, options) {
|
|
4977
|
+
async mountCategory(category, shop, options) {
|
|
4946
4978
|
var _a;
|
|
4947
4979
|
if (!((_a = category === null || category === void 0 ? void 0 : category.products) === null || _a === void 0 ? void 0 : _a.length))
|
|
4948
4980
|
return [];
|
|
4981
|
+
const mostRelevants = category.getMostRelevantByShop(shop);
|
|
4982
|
+
const mostRelevantProductsIds = [...new Set(mostRelevants.concat(category.products))];
|
|
4949
4983
|
const products = [];
|
|
4950
|
-
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: [
|
|
4951
4990
|
'id',
|
|
4952
4991
|
'name',
|
|
4953
4992
|
'slug',
|
|
@@ -4973,8 +5012,25 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4973
5012
|
'shoppingCount',
|
|
4974
5013
|
'gender',
|
|
4975
5014
|
'createdAt',
|
|
4976
|
-
]
|
|
4977
|
-
|
|
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);
|
|
4978
5034
|
return products;
|
|
4979
5035
|
}
|
|
4980
5036
|
async getChildren(parentId) {
|
|
@@ -5149,13 +5205,13 @@ tslib.__decorate([
|
|
|
5149
5205
|
tslib.__decorate([
|
|
5150
5206
|
Log(),
|
|
5151
5207
|
tslib.__metadata("design:type", Function),
|
|
5152
|
-
tslib.__metadata("design:paramtypes", [Array,
|
|
5208
|
+
tslib.__metadata("design:paramtypes", [Array, String, Object]),
|
|
5153
5209
|
tslib.__metadata("design:returntype", Promise)
|
|
5154
5210
|
], CategoryHasuraGraphQLRepository.prototype, "getCategoriesForHome", null);
|
|
5155
5211
|
tslib.__decorate([
|
|
5156
5212
|
Log(),
|
|
5157
5213
|
tslib.__metadata("design:type", Function),
|
|
5158
|
-
tslib.__metadata("design:paramtypes", [Category, Object]),
|
|
5214
|
+
tslib.__metadata("design:paramtypes", [Category, String, Object]),
|
|
5159
5215
|
tslib.__metadata("design:returntype", Promise)
|
|
5160
5216
|
], CategoryHasuraGraphQLRepository.prototype, "mountCategory", null);
|
|
5161
5217
|
tslib.__decorate([
|
|
@@ -6286,10 +6342,10 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
6286
6342
|
value: [exports.PersonTypes.BFLU, exports.PersonTypes.GLAMGIRL],
|
|
6287
6343
|
} }), orderBy: Object.assign({ personHasPhoto: 'desc' }, lodash.omit(params.orderBy, ['personHasPhoto'])) }));
|
|
6288
6344
|
}
|
|
6289
|
-
getCategoriesForHome(categoryIds,
|
|
6345
|
+
getCategoriesForHome(categoryIds, gender, limit) {
|
|
6290
6346
|
return;
|
|
6291
6347
|
}
|
|
6292
|
-
mountCategory(category, options) {
|
|
6348
|
+
mountCategory(category, shop, options) {
|
|
6293
6349
|
return;
|
|
6294
6350
|
}
|
|
6295
6351
|
getChildren(parentId) {
|
|
@@ -6721,6 +6777,8 @@ exports.LeadFirestoreRepository = LeadFirestoreRepository;
|
|
|
6721
6777
|
exports.LegacyOrderFirestoreRepository = LegacyOrderFirestoreRepository;
|
|
6722
6778
|
exports.LineItem = LineItem;
|
|
6723
6779
|
exports.Log = Log;
|
|
6780
|
+
exports.LogDocument = LogDocument;
|
|
6781
|
+
exports.LogFirestoreRepository = LogFirestoreRepository;
|
|
6724
6782
|
exports.Logger = Logger;
|
|
6725
6783
|
exports.NotFoundError = NotFoundError;
|
|
6726
6784
|
exports.Order = Order;
|