@infrab4a/connect 4.16.2-beta.0 → 4.17.0-beta.0

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.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'];
@@ -2225,6 +2234,12 @@ class RoundProductPricesHelper {
2225
2234
  }
2226
2235
  }
2227
2236
 
2237
+ class LogDocument extends BaseModel {
2238
+ static get identifiersFields() {
2239
+ return ['id'];
2240
+ }
2241
+ }
2242
+
2228
2243
  var FilterType;
2229
2244
  (function (FilterType) {
2230
2245
  FilterType["ACCESSORY_IMPORTANCE"] = "accessoryImportance";
@@ -3092,180 +3107,6 @@ const withCrudFirestore = (MixinBase) => {
3092
3107
  };
3093
3108
  };
3094
3109
 
3095
- class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3096
- constructor({ firestore, interceptors }) {
3097
- super({
3098
- firestore,
3099
- collectionName: 'leads',
3100
- model: Lead,
3101
- interceptors,
3102
- });
3103
- }
3104
- }
3105
-
3106
- class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3107
- constructor({ firestore, interceptors }, parentRepository) {
3108
- super({
3109
- firestore,
3110
- collectionName: 'editions',
3111
- parentIdField: 'subscriptionId',
3112
- model: Edition,
3113
- interceptors,
3114
- });
3115
- this.parentRepository = parentRepository;
3116
- }
3117
- }
3118
-
3119
- class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3120
- constructor({ firestore, interceptors, }) {
3121
- super({
3122
- firestore,
3123
- collectionName: 'subscription',
3124
- model: Subscription,
3125
- interceptors,
3126
- });
3127
- }
3128
- }
3129
-
3130
- class SubscriptionMaterializationFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3131
- constructor({ firestore, interceptors }) {
3132
- super({
3133
- firestore,
3134
- collectionName: 'subscriptionMaterialization',
3135
- model: SubscriptionMaterialization,
3136
- interceptors,
3137
- });
3138
- }
3139
- }
3140
-
3141
- class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3142
- constructor({ firestore, interceptors }, parentRepository) {
3143
- super({
3144
- firestore,
3145
- collectionName: 'payments',
3146
- parentIdField: 'subscriptionId',
3147
- model: SubscriptionPayment,
3148
- interceptors,
3149
- });
3150
- this.parentRepository = parentRepository;
3151
- }
3152
- }
3153
-
3154
- class SubscriptionSummaryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3155
- constructor({ firestore, interceptors, }) {
3156
- super({
3157
- firestore,
3158
- collectionName: 'subscriptionSummary',
3159
- model: SubscriptionSummary,
3160
- interceptors,
3161
- });
3162
- }
3163
- }
3164
-
3165
- class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3166
- constructor({ firestore, interceptors }, parentRepository) {
3167
- super({
3168
- firestore,
3169
- collectionName: 'address',
3170
- parentIdField: 'userId',
3171
- model: UserAddress,
3172
- interceptors,
3173
- });
3174
- this.parentRepository = parentRepository;
3175
- }
3176
- }
3177
-
3178
- class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3179
- constructor({ firestore, interceptors }, parentRepository) {
3180
- super({
3181
- firestore,
3182
- collectionName: 'CX',
3183
- parentIdField: 'userId',
3184
- model: BeautyProfile,
3185
- interceptors,
3186
- });
3187
- this.parentRepository = parentRepository;
3188
- }
3189
- }
3190
-
3191
- class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3192
- constructor({ firestore, interceptors }) {
3193
- super({
3194
- firestore,
3195
- collectionName: 'users',
3196
- model: User,
3197
- interceptors,
3198
- });
3199
- }
3200
- async get(identifiers) {
3201
- const user = await super.get({ id: identifiers.id });
3202
- user.beautyProfile = await this.getBeautyProfile(user.id);
3203
- user.isSubscriber = await this.checkIfIsSubscriber(user.id);
3204
- return user;
3205
- }
3206
- async checkIfExistsByField(field, value) {
3207
- const result = await this.find({ filters: { [field]: value } });
3208
- return result.count > 0;
3209
- }
3210
- buildModelInstance() {
3211
- const { fromFirestore, toFirestore } = super.buildModelInstance();
3212
- return {
3213
- toFirestore: (data) => {
3214
- const plain = toFirestore(data);
3215
- delete plain.isSubscriber;
3216
- return plain;
3217
- },
3218
- fromFirestore,
3219
- };
3220
- }
3221
- async getBeautyProfile(userId) {
3222
- const beautyProfile = await this.firestore
3223
- .getCollection(`${this.collectionName}/${userId}/CX`)
3224
- .withConverter(this.buildBeautyProfileModelInstance())
3225
- .getDoc('beautyProfile')
3226
- .get();
3227
- return beautyProfile.data();
3228
- }
3229
- async checkIfIsSubscriber(userId) {
3230
- const docs = await this.collection('subscription')
3231
- .where('user.id', '==', userId)
3232
- .where('status', '==', 'active')
3233
- .getDocs();
3234
- return !!docs && !!docs.size;
3235
- }
3236
- buildBeautyProfileModelInstance() {
3237
- return {
3238
- toFirestore: (data) => data.toPlain(),
3239
- fromFirestore: (snap) => BeautyProfile.toInstance(snap.data()),
3240
- };
3241
- }
3242
- }
3243
- __decorate([
3244
- Log(),
3245
- __metadata("design:type", Function),
3246
- __metadata("design:paramtypes", [Object]),
3247
- __metadata("design:returntype", Promise)
3248
- ], UserFirestoreRepository.prototype, "get", null);
3249
- __decorate([
3250
- Log(),
3251
- __metadata("design:type", Function),
3252
- __metadata("design:paramtypes", [String, String]),
3253
- __metadata("design:returntype", Promise)
3254
- ], UserFirestoreRepository.prototype, "checkIfExistsByField", null);
3255
-
3256
- class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3257
- constructor({ firestore, interceptors }, parentRepository) {
3258
- super({
3259
- firestore,
3260
- collectionName: 'payment_method',
3261
- parentIdField: 'userId',
3262
- model: UserPaymentMethod,
3263
- interceptors,
3264
- });
3265
- this.parentRepository = parentRepository;
3266
- }
3267
- }
3268
-
3269
3110
  class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3270
3111
  constructor({ firestore, interceptors }) {
3271
3112
  super({
@@ -3287,7 +3128,7 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
3287
3128
  throw new NotFoundError(`Document with slug ${slug} not found`);
3288
3129
  return categoryDocs.docs[0].data();
3289
3130
  }
3290
- async getCategoriesForHome(categoryIds, shop, limit = 4) {
3131
+ async getCategoriesForHome(categoryIds, limit = 4, gender) {
3291
3132
  const categorySnap = await this.collection(this.collectionName)
3292
3133
  .where('id', 'in', categoryIds.filter(Boolean))
3293
3134
  .where('published', '==', true)
@@ -3297,11 +3138,11 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
3297
3138
  const categories = categorySnap.docs.map((doc) => doc.data());
3298
3139
  const homeSections = await Promise.all(categories.map(async (category) => ({
3299
3140
  category,
3300
- products: await this.mountCategory(category, shop, { limit, hasStock: true }),
3141
+ products: await this.mountCategory(category, { limit, hasStock: true, gender }),
3301
3142
  })));
3302
3143
  return homeSections;
3303
3144
  }
3304
- async mountCategory(category, shop, options) {
3145
+ async mountCategory(category, options) {
3305
3146
  if (!category.products)
3306
3147
  throw new RequiredArgumentError(['Category products is empty']);
3307
3148
  const chunks = chunk(category.products, 10);
@@ -3345,13 +3186,13 @@ __decorate([
3345
3186
  __decorate([
3346
3187
  Log(),
3347
3188
  __metadata("design:type", Function),
3348
- __metadata("design:paramtypes", [Array, String, Object]),
3189
+ __metadata("design:paramtypes", [Array, Object, String]),
3349
3190
  __metadata("design:returntype", Promise)
3350
3191
  ], CategoryFirestoreRepository.prototype, "getCategoriesForHome", null);
3351
3192
  __decorate([
3352
3193
  Log(),
3353
3194
  __metadata("design:type", Function),
3354
- __metadata("design:paramtypes", [Category, String, Object]),
3195
+ __metadata("design:paramtypes", [Category, Object]),
3355
3196
  __metadata("design:returntype", Promise)
3356
3197
  ], CategoryFirestoreRepository.prototype, "mountCategory", null);
3357
3198
 
@@ -3450,6 +3291,101 @@ class SubscriptionProductFirestoreRepository extends withCrudFirestore(withHelpe
3450
3291
  }
3451
3292
  }
3452
3293
 
3294
+ class LogFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3295
+ constructor({ firestore, interceptors, }) {
3296
+ super({
3297
+ firestore,
3298
+ collectionName: 'logs',
3299
+ model: LogDocument,
3300
+ interceptors,
3301
+ });
3302
+ }
3303
+ }
3304
+
3305
+ class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3306
+ constructor({ firestore, interceptors }) {
3307
+ super({
3308
+ firestore,
3309
+ collectionName: 'dms',
3310
+ model: Home,
3311
+ interceptors,
3312
+ });
3313
+ this.homeCategoryGroupToPlain = (homeCategoryGroup) => {
3314
+ var _a, _b, _c;
3315
+ return ({
3316
+ category: ((_a = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _a === void 0 ? void 0 : _a.toPlain)
3317
+ ? (_b = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _b === void 0 ? void 0 : _b.toPlain()
3318
+ : homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category,
3319
+ 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)) || [],
3320
+ });
3321
+ };
3322
+ this.plainToHomeCategoryGroup = (homeCategoryGroup) => {
3323
+ var _a;
3324
+ return ({
3325
+ category: Category.toInstance(homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category),
3326
+ products: (_a = homeCategoryGroup.products) === null || _a === void 0 ? void 0 : _a.map((product) => Product.toInstance(product)),
3327
+ });
3328
+ };
3329
+ }
3330
+ buildModelInstance() {
3331
+ const { fromFirestore, toFirestore } = super.buildModelInstance();
3332
+ return {
3333
+ toFirestore: (data) => {
3334
+ const modifiedData = this.homeToFirestore(data);
3335
+ return toFirestore(modifiedData);
3336
+ },
3337
+ fromFirestore: (snap) => {
3338
+ const instance = fromFirestore(snap);
3339
+ return this.homeFromFirestore(instance);
3340
+ },
3341
+ };
3342
+ }
3343
+ homeToFirestore(home) {
3344
+ var _a, _b, _c, _d;
3345
+ if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
3346
+ home.data.data.discoverProducts = ((_b = home.data.data.discoverProducts) === null || _b === void 0 ? void 0 : _b.map(this.homeCategoryGroupToPlain)) || [];
3347
+ home.data.data.featuredProducts = ((_c = home.data.data.featuredProducts) === null || _c === void 0 ? void 0 : _c.map(this.homeCategoryGroupToPlain)) || [];
3348
+ home.data.data.verticalProducts = ((_d = home.data.data.verticalProducts) === null || _d === void 0 ? void 0 : _d.map(this.homeCategoryGroupToPlain)) || [];
3349
+ }
3350
+ return home;
3351
+ }
3352
+ homeFromFirestore(home) {
3353
+ var _a;
3354
+ if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
3355
+ home.data.data.discoverProducts = home.data.data.discoverProducts.map(this.plainToHomeCategoryGroup);
3356
+ home.data.data.featuredProducts = home.data.data.featuredProducts.map(this.plainToHomeCategoryGroup);
3357
+ home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.plainToHomeCategoryGroup);
3358
+ home.data.createdAt =
3359
+ home.data.createdAt instanceof Timestamp ? home.data.createdAt.toDate() : home.data.createdAt;
3360
+ home.data.expiresAt =
3361
+ home.data.expiresAt instanceof Timestamp ? home.data.expiresAt.toDate() : home.data.expiresAt;
3362
+ }
3363
+ return home;
3364
+ }
3365
+ }
3366
+
3367
+ class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3368
+ constructor({ firestore, interceptors }) {
3369
+ super({
3370
+ firestore,
3371
+ collectionName: 'shopMenus',
3372
+ model: ShopMenu,
3373
+ interceptors,
3374
+ });
3375
+ }
3376
+ }
3377
+
3378
+ class ShopSettingsFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3379
+ constructor({ firestore, interceptors, }) {
3380
+ super({
3381
+ firestore,
3382
+ collectionName: 'shopSettings',
3383
+ model: ShopSettings,
3384
+ interceptors,
3385
+ });
3386
+ }
3387
+ }
3388
+
3453
3389
  class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3454
3390
  constructor({ firestore, interceptors }) {
3455
3391
  super({
@@ -3643,90 +3579,180 @@ class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(
3643
3579
  }
3644
3580
  }
3645
3581
 
3646
- class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3582
+ class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3647
3583
  constructor({ firestore, interceptors }) {
3648
3584
  super({
3649
3585
  firestore,
3650
- collectionName: 'dms',
3651
- model: Home,
3586
+ collectionName: 'leads',
3587
+ model: Lead,
3652
3588
  interceptors,
3653
3589
  });
3654
- this.homeCategoryGroupToPlain = (homeCategoryGroup) => {
3655
- var _a, _b, _c;
3656
- return ({
3657
- category: ((_a = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _a === void 0 ? void 0 : _a.toPlain)
3658
- ? (_b = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _b === void 0 ? void 0 : _b.toPlain()
3659
- : homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category,
3660
- 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)) || [],
3661
- });
3662
- };
3663
- this.plainToHomeCategoryGroup = (homeCategoryGroup) => {
3664
- var _a;
3665
- return ({
3666
- category: Category.toInstance(homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category),
3667
- products: (_a = homeCategoryGroup.products) === null || _a === void 0 ? void 0 : _a.map((product) => Product.toInstance(product)),
3668
- });
3669
- };
3670
- }
3671
- buildModelInstance() {
3672
- const { fromFirestore, toFirestore } = super.buildModelInstance();
3673
- return {
3674
- toFirestore: (data) => {
3675
- const modifiedData = this.homeToFirestore(data);
3676
- return toFirestore(modifiedData);
3677
- },
3678
- fromFirestore: (snap) => {
3679
- const instance = fromFirestore(snap);
3680
- return this.homeFromFirestore(instance);
3681
- },
3682
- };
3683
3590
  }
3684
- homeToFirestore(home) {
3685
- var _a, _b, _c, _d;
3686
- if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
3687
- home.data.data.discoverProducts = ((_b = home.data.data.discoverProducts) === null || _b === void 0 ? void 0 : _b.map(this.homeCategoryGroupToPlain)) || [];
3688
- home.data.data.featuredProducts = ((_c = home.data.data.featuredProducts) === null || _c === void 0 ? void 0 : _c.map(this.homeCategoryGroupToPlain)) || [];
3689
- home.data.data.verticalProducts = ((_d = home.data.data.verticalProducts) === null || _d === void 0 ? void 0 : _d.map(this.homeCategoryGroupToPlain)) || [];
3690
- }
3691
- return home;
3591
+ }
3592
+
3593
+ class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3594
+ constructor({ firestore, interceptors }, parentRepository) {
3595
+ super({
3596
+ firestore,
3597
+ collectionName: 'editions',
3598
+ parentIdField: 'subscriptionId',
3599
+ model: Edition,
3600
+ interceptors,
3601
+ });
3602
+ this.parentRepository = parentRepository;
3692
3603
  }
3693
- homeFromFirestore(home) {
3694
- var _a;
3695
- if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
3696
- home.data.data.discoverProducts = home.data.data.discoverProducts.map(this.plainToHomeCategoryGroup);
3697
- home.data.data.featuredProducts = home.data.data.featuredProducts.map(this.plainToHomeCategoryGroup);
3698
- home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.plainToHomeCategoryGroup);
3699
- home.data.createdAt =
3700
- home.data.createdAt instanceof Timestamp ? home.data.createdAt.toDate() : home.data.createdAt;
3701
- home.data.expiresAt =
3702
- home.data.expiresAt instanceof Timestamp ? home.data.expiresAt.toDate() : home.data.expiresAt;
3703
- }
3704
- return home;
3604
+ }
3605
+
3606
+ class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3607
+ constructor({ firestore, interceptors, }) {
3608
+ super({
3609
+ firestore,
3610
+ collectionName: 'subscription',
3611
+ model: Subscription,
3612
+ interceptors,
3613
+ });
3705
3614
  }
3706
3615
  }
3707
3616
 
3708
- class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3617
+ class SubscriptionMaterializationFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3709
3618
  constructor({ firestore, interceptors }) {
3710
3619
  super({
3711
3620
  firestore,
3712
- collectionName: 'shopMenus',
3713
- model: ShopMenu,
3621
+ collectionName: 'subscriptionMaterialization',
3622
+ model: SubscriptionMaterialization,
3714
3623
  interceptors,
3715
3624
  });
3716
3625
  }
3717
3626
  }
3718
3627
 
3719
- class ShopSettingsFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3628
+ class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3629
+ constructor({ firestore, interceptors }, parentRepository) {
3630
+ super({
3631
+ firestore,
3632
+ collectionName: 'payments',
3633
+ parentIdField: 'subscriptionId',
3634
+ model: SubscriptionPayment,
3635
+ interceptors,
3636
+ });
3637
+ this.parentRepository = parentRepository;
3638
+ }
3639
+ }
3640
+
3641
+ class SubscriptionSummaryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3720
3642
  constructor({ firestore, interceptors, }) {
3721
3643
  super({
3722
3644
  firestore,
3723
- collectionName: 'shopSettings',
3724
- model: ShopSettings,
3645
+ collectionName: 'subscriptionSummary',
3646
+ model: SubscriptionSummary,
3725
3647
  interceptors,
3726
3648
  });
3727
3649
  }
3728
3650
  }
3729
3651
 
3652
+ class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3653
+ constructor({ firestore, interceptors }, parentRepository) {
3654
+ super({
3655
+ firestore,
3656
+ collectionName: 'address',
3657
+ parentIdField: 'userId',
3658
+ model: UserAddress,
3659
+ interceptors,
3660
+ });
3661
+ this.parentRepository = parentRepository;
3662
+ }
3663
+ }
3664
+
3665
+ class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3666
+ constructor({ firestore, interceptors }, parentRepository) {
3667
+ super({
3668
+ firestore,
3669
+ collectionName: 'CX',
3670
+ parentIdField: 'userId',
3671
+ model: BeautyProfile,
3672
+ interceptors,
3673
+ });
3674
+ this.parentRepository = parentRepository;
3675
+ }
3676
+ }
3677
+
3678
+ class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3679
+ constructor({ firestore, interceptors }) {
3680
+ super({
3681
+ firestore,
3682
+ collectionName: 'users',
3683
+ model: User,
3684
+ interceptors,
3685
+ });
3686
+ }
3687
+ async get(identifiers) {
3688
+ const user = await super.get({ id: identifiers.id });
3689
+ user.beautyProfile = await this.getBeautyProfile(user.id);
3690
+ user.isSubscriber = await this.checkIfIsSubscriber(user.id);
3691
+ return user;
3692
+ }
3693
+ async checkIfExistsByField(field, value) {
3694
+ const result = await this.find({ filters: { [field]: value } });
3695
+ return result.count > 0;
3696
+ }
3697
+ buildModelInstance() {
3698
+ const { fromFirestore, toFirestore } = super.buildModelInstance();
3699
+ return {
3700
+ toFirestore: (data) => {
3701
+ const plain = toFirestore(data);
3702
+ delete plain.isSubscriber;
3703
+ return plain;
3704
+ },
3705
+ fromFirestore,
3706
+ };
3707
+ }
3708
+ async getBeautyProfile(userId) {
3709
+ const beautyProfile = await this.firestore
3710
+ .getCollection(`${this.collectionName}/${userId}/CX`)
3711
+ .withConverter(this.buildBeautyProfileModelInstance())
3712
+ .getDoc('beautyProfile')
3713
+ .get();
3714
+ return beautyProfile.data();
3715
+ }
3716
+ async checkIfIsSubscriber(userId) {
3717
+ const docs = await this.collection('subscription')
3718
+ .where('user.id', '==', userId)
3719
+ .where('status', '==', 'active')
3720
+ .getDocs();
3721
+ return !!docs && !!docs.size;
3722
+ }
3723
+ buildBeautyProfileModelInstance() {
3724
+ return {
3725
+ toFirestore: (data) => data.toPlain(),
3726
+ fromFirestore: (snap) => BeautyProfile.toInstance(snap.data()),
3727
+ };
3728
+ }
3729
+ }
3730
+ __decorate([
3731
+ Log(),
3732
+ __metadata("design:type", Function),
3733
+ __metadata("design:paramtypes", [Object]),
3734
+ __metadata("design:returntype", Promise)
3735
+ ], UserFirestoreRepository.prototype, "get", null);
3736
+ __decorate([
3737
+ Log(),
3738
+ __metadata("design:type", Function),
3739
+ __metadata("design:paramtypes", [String, String]),
3740
+ __metadata("design:returntype", Promise)
3741
+ ], UserFirestoreRepository.prototype, "checkIfExistsByField", null);
3742
+
3743
+ class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3744
+ constructor({ firestore, interceptors }, parentRepository) {
3745
+ super({
3746
+ firestore,
3747
+ collectionName: 'payment_method',
3748
+ parentIdField: 'userId',
3749
+ model: UserPaymentMethod,
3750
+ interceptors,
3751
+ });
3752
+ this.parentRepository = parentRepository;
3753
+ }
3754
+ }
3755
+
3730
3756
  class ConnectBaseDocumentSnapshot {
3731
3757
  constructor(connectDocumentSnapshot) {
3732
3758
  this.connectDocumentSnapshot = connectDocumentSnapshot;
@@ -4914,7 +4940,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4914
4940
  });
4915
4941
  return data;
4916
4942
  }
4917
- async getCategoriesForHome(categoryIds, shop, limit = 4) {
4943
+ async getCategoriesForHome(categoryIds, limit = 4, gender) {
4918
4944
  if (!(categoryIds === null || categoryIds === void 0 ? void 0 : categoryIds.length))
4919
4945
  return [];
4920
4946
  const categoriesFirestore = categoryIds.filter((categoryId) => Number.isNaN(+categoryId));
@@ -4926,32 +4952,22 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4926
4952
  }).then(({ data }) => data)));
4927
4953
  if (categoriesHasura.length)
4928
4954
  categories.push(...(await this.find({
4929
- filters: {
4930
- id: { operator: Where.IN, value: categoriesHasura.filter(Boolean) },
4931
- published: true,
4932
- },
4955
+ filters: { id: { operator: Where.IN, value: categoriesHasura.filter(Boolean) }, published: true },
4933
4956
  }).then(({ data }) => data)));
4934
4957
  if (!categories.length)
4935
4958
  return [];
4936
4959
  const homeSections = await Promise.all(categories.map(async (category) => ({
4937
4960
  category,
4938
- products: await this.mountCategory(category, shop, { limit, hasStock: true }),
4961
+ products: await this.mountCategory(category, { limit, hasStock: true, gender }),
4939
4962
  })));
4940
4963
  return homeSections;
4941
4964
  }
4942
- async mountCategory(category, shop, options) {
4965
+ async mountCategory(category, options) {
4943
4966
  var _a;
4944
4967
  if (!((_a = category === null || category === void 0 ? void 0 : category.products) === null || _a === void 0 ? void 0 : _a.length))
4945
4968
  return [];
4946
- const mostRelevants = category.getMostRelevantByShop(shop);
4947
- const mostRelevantProductsIds = [...new Set(mostRelevants.concat(category.products))];
4948
4969
  const products = [];
4949
- const { data: productsData } = await this.productRepository.find({
4950
- filters: {
4951
- id: { operator: Where.IN, value: mostRelevantProductsIds },
4952
- published: true,
4953
- },
4954
- fields: [
4970
+ const { data: productsData } = await this.productRepository.find(Object.assign(Object.assign({ filters: Object.assign(Object.assign({ id: { operator: Where.IN, value: category.products }, published: true }, ((options === null || options === void 0 ? void 0 : options.hasStock) ? { stock: { quantity: { operator: Where.GT, value: 0 } } } : {})), ((options === null || options === void 0 ? void 0 : options.gender) ? { tags: { operator: Where.IN, value: [options === null || options === void 0 ? void 0 : options.gender] } } : {})), fields: [
4955
4971
  'id',
4956
4972
  'name',
4957
4973
  'slug',
@@ -4977,25 +4993,8 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4977
4993
  'shoppingCount',
4978
4994
  'gender',
4979
4995
  'createdAt',
4980
- ],
4981
- options: { enableCount: false },
4982
- orderBy: {
4983
- shoppingCount: 'desc',
4984
- rate: 'desc',
4985
- stock: 'desc',
4986
- name: 'asc',
4987
- },
4988
- });
4989
- const mostRelevantWithouyStock = productsData.filter((product) => mostRelevants.includes(product.id) && product.stock.quantity <= 0);
4990
- const firstProducts = productsData
4991
- .filter((product) => mostRelevants.includes(product.id) && product.stock.quantity > 0)
4992
- .sort((a, b) => mostRelevants.indexOf(a.id) - mostRelevants.indexOf(b.id));
4993
- const lastProducts = productsData
4994
- .filter((product) => !mostRelevants.includes(product.id) && product.stock.quantity > 0)
4995
- .concat(mostRelevantWithouyStock);
4996
- const categoryMostRelevants = firstProducts.concat(lastProducts);
4997
- const resultFinal = categoryMostRelevants.slice(0, options.limit);
4998
- products.push(...resultFinal);
4996
+ ] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})), { options: { enableCount: false } }));
4997
+ products.push(...productsData);
4999
4998
  return products;
5000
4999
  }
5001
5000
  async getChildren(parentId) {
@@ -5170,13 +5169,13 @@ __decorate([
5170
5169
  __decorate([
5171
5170
  Log(),
5172
5171
  __metadata("design:type", Function),
5173
- __metadata("design:paramtypes", [Array, String, Object]),
5172
+ __metadata("design:paramtypes", [Array, Object, String]),
5174
5173
  __metadata("design:returntype", Promise)
5175
5174
  ], CategoryHasuraGraphQLRepository.prototype, "getCategoriesForHome", null);
5176
5175
  __decorate([
5177
5176
  Log(),
5178
5177
  __metadata("design:type", Function),
5179
- __metadata("design:paramtypes", [Category, String, Object]),
5178
+ __metadata("design:paramtypes", [Category, Object]),
5180
5179
  __metadata("design:returntype", Promise)
5181
5180
  ], CategoryHasuraGraphQLRepository.prototype, "mountCategory", null);
5182
5181
  __decorate([
@@ -6307,10 +6306,10 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6307
6306
  value: [PersonTypes.BFLU, PersonTypes.GLAMGIRL],
6308
6307
  } }), orderBy: Object.assign({ personHasPhoto: 'desc' }, omit(params.orderBy, ['personHasPhoto'])) }));
6309
6308
  }
6310
- getCategoriesForHome(categoryIds, gender, limit) {
6309
+ getCategoriesForHome(categoryIds, limit, gender) {
6311
6310
  return;
6312
6311
  }
6313
- mountCategory(category, shop, options) {
6312
+ mountCategory(category, options) {
6314
6313
  return;
6315
6314
  }
6316
6315
  getChildren(parentId) {
@@ -6571,4 +6570,4 @@ class ProductsVertexSearch {
6571
6570
  }
6572
6571
  }
6573
6572
 
6574
- 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 };
6573
+ 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 };