@infrab4a/connect 4.16.2-beta.1 → 4.17.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.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({
@@ -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,87 +3588,177 @@ class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(
3649
3588
  }
3650
3589
  }
3651
3590
 
3652
- class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3591
+ class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3653
3592
  constructor({ firestore, interceptors }) {
3654
3593
  super({
3655
3594
  firestore,
3656
- collectionName: 'dms',
3657
- model: Home,
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
- homeToFirestore(home) {
3691
- var _a, _b, _c, _d;
3692
- if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
3693
- home.data.data.discoverProducts = ((_b = home.data.data.discoverProducts) === null || _b === void 0 ? void 0 : _b.map(this.homeCategoryGroupToPlain)) || [];
3694
- home.data.data.featuredProducts = ((_c = home.data.data.featuredProducts) === null || _c === void 0 ? void 0 : _c.map(this.homeCategoryGroupToPlain)) || [];
3695
- home.data.data.verticalProducts = ((_d = home.data.data.verticalProducts) === null || _d === void 0 ? void 0 : _d.map(this.homeCategoryGroupToPlain)) || [];
3696
- }
3697
- 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;
3698
3612
  }
3699
- homeFromFirestore(home) {
3700
- var _a;
3701
- if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
3702
- home.data.data.discoverProducts = home.data.data.discoverProducts.map(this.plainToHomeCategoryGroup);
3703
- home.data.data.featuredProducts = home.data.data.featuredProducts.map(this.plainToHomeCategoryGroup);
3704
- home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.plainToHomeCategoryGroup);
3705
- home.data.createdAt =
3706
- home.data.createdAt instanceof firestore.Timestamp ? home.data.createdAt.toDate() : home.data.createdAt;
3707
- home.data.expiresAt =
3708
- home.data.expiresAt instanceof firestore.Timestamp ? home.data.expiresAt.toDate() : home.data.expiresAt;
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 ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3626
+ class SubscriptionMaterializationFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3715
3627
  constructor({ firestore, interceptors }) {
3716
3628
  super({
3717
3629
  firestore,
3718
- collectionName: 'shopMenus',
3719
- model: ShopMenu,
3630
+ collectionName: 'subscriptionMaterialization',
3631
+ model: SubscriptionMaterialization,
3720
3632
  interceptors,
3721
3633
  });
3722
3634
  }
3723
3635
  }
3724
3636
 
3725
- class ShopSettingsFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
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: 'shopSettings',
3730
- model: ShopSettings,
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,
3731
3681
  interceptors,
3732
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;
3733
3762
  }
3734
3763
  }
3735
3764
 
@@ -4952,7 +4981,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4952
4981
  const mostRelevants = category.getMostRelevantByShop(shop);
4953
4982
  const mostRelevantProductsIds = [...new Set(mostRelevants.concat(category.products))];
4954
4983
  const products = [];
4955
- const { data: productsData } = await this.productRepository.findCatalog({
4984
+ const { data: productsData } = await this.productRepository.find({
4956
4985
  filters: {
4957
4986
  id: { operator: exports.Where.IN, value: mostRelevantProductsIds },
4958
4987
  published: true,
@@ -4991,13 +5020,13 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4991
5020
  stock: 'desc',
4992
5021
  name: 'asc',
4993
5022
  },
4994
- }, shop === exports.Shops.MENSMARKET ? 'male' : 'female');
5023
+ });
4995
5024
  const mostRelevantWithouyStock = productsData.filter((product) => mostRelevants.includes(product.id) && product.stock.quantity <= 0);
4996
5025
  const firstProducts = productsData
4997
5026
  .filter((product) => mostRelevants.includes(product.id) && product.stock.quantity > 0)
4998
5027
  .sort((a, b) => mostRelevants.indexOf(a.id) - mostRelevants.indexOf(b.id));
4999
5028
  const lastProducts = productsData
5000
- .filter((product) => !mostRelevants.includes(product.id) && product.stock.quantity > 0)
5029
+ .filter((product) => !mostRelevants.includes(product.id))
5001
5030
  .concat(mostRelevantWithouyStock);
5002
5031
  const categoryMostRelevants = firstProducts.concat(lastProducts);
5003
5032
  const resultFinal = categoryMostRelevants.slice(0, options.limit);
@@ -6748,6 +6777,8 @@ exports.LeadFirestoreRepository = LeadFirestoreRepository;
6748
6777
  exports.LegacyOrderFirestoreRepository = LegacyOrderFirestoreRepository;
6749
6778
  exports.LineItem = LineItem;
6750
6779
  exports.Log = Log;
6780
+ exports.LogDocument = LogDocument;
6781
+ exports.LogFirestoreRepository = LogFirestoreRepository;
6751
6782
  exports.Logger = Logger;
6752
6783
  exports.NotFoundError = NotFoundError;
6753
6784
  exports.Order = Order;
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'];
@@ -2124,6 +2133,9 @@ var CouponCategory;
2124
2133
  CouponCategory["Desculpas"] = "Desculpas";
2125
2134
  CouponCategory["BFlu"] = "BFlu";
2126
2135
  CouponCategory["ROYAL"] = "Royal";
2136
+ CouponCategory["Glamqueen"] = "Glamqueen";
2137
+ CouponCategory["Glampartner"] = "Glampartner";
2138
+ CouponCategory["Glamgirl"] = "Glamgirl";
2127
2139
  CouponCategory["Glamdiva"] = "Glamdiva";
2128
2140
  CouponCategory["Impulsionamento"] = "Impulsionamento";
2129
2141
  CouponCategory["PaidMedia"] = "Paid Media";
@@ -2225,6 +2237,12 @@ class RoundProductPricesHelper {
2225
2237
  }
2226
2238
  }
2227
2239
 
2240
+ class LogDocument extends BaseModel {
2241
+ static get identifiersFields() {
2242
+ return ['id'];
2243
+ }
2244
+ }
2245
+
2228
2246
  var FilterType;
2229
2247
  (function (FilterType) {
2230
2248
  FilterType["ACCESSORY_IMPORTANCE"] = "accessoryImportance";
@@ -3092,180 +3110,6 @@ const withCrudFirestore = (MixinBase) => {
3092
3110
  };
3093
3111
  };
3094
3112
 
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
3113
  class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3270
3114
  constructor({ firestore, interceptors }) {
3271
3115
  super({
@@ -3450,6 +3294,101 @@ class SubscriptionProductFirestoreRepository extends withCrudFirestore(withHelpe
3450
3294
  }
3451
3295
  }
3452
3296
 
3297
+ class LogFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3298
+ constructor({ firestore, interceptors, }) {
3299
+ super({
3300
+ firestore,
3301
+ collectionName: 'logs',
3302
+ model: LogDocument,
3303
+ interceptors,
3304
+ });
3305
+ }
3306
+ }
3307
+
3308
+ class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3309
+ constructor({ firestore, interceptors }) {
3310
+ super({
3311
+ firestore,
3312
+ collectionName: 'dms',
3313
+ model: Home,
3314
+ interceptors,
3315
+ });
3316
+ this.homeCategoryGroupToPlain = (homeCategoryGroup) => {
3317
+ var _a, _b, _c;
3318
+ return ({
3319
+ category: ((_a = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _a === void 0 ? void 0 : _a.toPlain)
3320
+ ? (_b = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _b === void 0 ? void 0 : _b.toPlain()
3321
+ : homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category,
3322
+ products: ((_c = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.products) === null || _c === void 0 ? void 0 : _c.map((product) => ((product === null || product === void 0 ? void 0 : product.toPlain) ? product === null || product === void 0 ? void 0 : product.toPlain() : product)).filter(Boolean)) || [],
3323
+ });
3324
+ };
3325
+ this.plainToHomeCategoryGroup = (homeCategoryGroup) => {
3326
+ var _a;
3327
+ return ({
3328
+ category: Category.toInstance(homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category),
3329
+ products: (_a = homeCategoryGroup.products) === null || _a === void 0 ? void 0 : _a.map((product) => Product.toInstance(product)),
3330
+ });
3331
+ };
3332
+ }
3333
+ buildModelInstance() {
3334
+ const { fromFirestore, toFirestore } = super.buildModelInstance();
3335
+ return {
3336
+ toFirestore: (data) => {
3337
+ const modifiedData = this.homeToFirestore(data);
3338
+ return toFirestore(modifiedData);
3339
+ },
3340
+ fromFirestore: (snap) => {
3341
+ const instance = fromFirestore(snap);
3342
+ return this.homeFromFirestore(instance);
3343
+ },
3344
+ };
3345
+ }
3346
+ homeToFirestore(home) {
3347
+ var _a, _b, _c, _d;
3348
+ if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
3349
+ home.data.data.discoverProducts = ((_b = home.data.data.discoverProducts) === null || _b === void 0 ? void 0 : _b.map(this.homeCategoryGroupToPlain)) || [];
3350
+ home.data.data.featuredProducts = ((_c = home.data.data.featuredProducts) === null || _c === void 0 ? void 0 : _c.map(this.homeCategoryGroupToPlain)) || [];
3351
+ home.data.data.verticalProducts = ((_d = home.data.data.verticalProducts) === null || _d === void 0 ? void 0 : _d.map(this.homeCategoryGroupToPlain)) || [];
3352
+ }
3353
+ return home;
3354
+ }
3355
+ homeFromFirestore(home) {
3356
+ var _a;
3357
+ if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
3358
+ home.data.data.discoverProducts = home.data.data.discoverProducts.map(this.plainToHomeCategoryGroup);
3359
+ home.data.data.featuredProducts = home.data.data.featuredProducts.map(this.plainToHomeCategoryGroup);
3360
+ home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.plainToHomeCategoryGroup);
3361
+ home.data.createdAt =
3362
+ home.data.createdAt instanceof Timestamp ? home.data.createdAt.toDate() : home.data.createdAt;
3363
+ home.data.expiresAt =
3364
+ home.data.expiresAt instanceof Timestamp ? home.data.expiresAt.toDate() : home.data.expiresAt;
3365
+ }
3366
+ return home;
3367
+ }
3368
+ }
3369
+
3370
+ class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3371
+ constructor({ firestore, interceptors }) {
3372
+ super({
3373
+ firestore,
3374
+ collectionName: 'shopMenus',
3375
+ model: ShopMenu,
3376
+ interceptors,
3377
+ });
3378
+ }
3379
+ }
3380
+
3381
+ class ShopSettingsFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3382
+ constructor({ firestore, interceptors, }) {
3383
+ super({
3384
+ firestore,
3385
+ collectionName: 'shopSettings',
3386
+ model: ShopSettings,
3387
+ interceptors,
3388
+ });
3389
+ }
3390
+ }
3391
+
3453
3392
  class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3454
3393
  constructor({ firestore, interceptors }) {
3455
3394
  super({
@@ -3643,87 +3582,177 @@ class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(
3643
3582
  }
3644
3583
  }
3645
3584
 
3646
- class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3585
+ class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3647
3586
  constructor({ firestore, interceptors }) {
3648
3587
  super({
3649
3588
  firestore,
3650
- collectionName: 'dms',
3651
- model: Home,
3589
+ collectionName: 'leads',
3590
+ model: Lead,
3652
3591
  interceptors,
3653
3592
  });
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
3593
  }
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;
3594
+ }
3595
+
3596
+ class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3597
+ constructor({ firestore, interceptors }, parentRepository) {
3598
+ super({
3599
+ firestore,
3600
+ collectionName: 'editions',
3601
+ parentIdField: 'subscriptionId',
3602
+ model: Edition,
3603
+ interceptors,
3604
+ });
3605
+ this.parentRepository = parentRepository;
3692
3606
  }
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;
3607
+ }
3608
+
3609
+ class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3610
+ constructor({ firestore, interceptors, }) {
3611
+ super({
3612
+ firestore,
3613
+ collectionName: 'subscription',
3614
+ model: Subscription,
3615
+ interceptors,
3616
+ });
3705
3617
  }
3706
3618
  }
3707
3619
 
3708
- class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3620
+ class SubscriptionMaterializationFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3709
3621
  constructor({ firestore, interceptors }) {
3710
3622
  super({
3711
3623
  firestore,
3712
- collectionName: 'shopMenus',
3713
- model: ShopMenu,
3624
+ collectionName: 'subscriptionMaterialization',
3625
+ model: SubscriptionMaterialization,
3714
3626
  interceptors,
3715
3627
  });
3716
3628
  }
3717
3629
  }
3718
3630
 
3719
- class ShopSettingsFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3631
+ class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3632
+ constructor({ firestore, interceptors }, parentRepository) {
3633
+ super({
3634
+ firestore,
3635
+ collectionName: 'payments',
3636
+ parentIdField: 'subscriptionId',
3637
+ model: SubscriptionPayment,
3638
+ interceptors,
3639
+ });
3640
+ this.parentRepository = parentRepository;
3641
+ }
3642
+ }
3643
+
3644
+ class SubscriptionSummaryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3720
3645
  constructor({ firestore, interceptors, }) {
3721
3646
  super({
3722
3647
  firestore,
3723
- collectionName: 'shopSettings',
3724
- model: ShopSettings,
3648
+ collectionName: 'subscriptionSummary',
3649
+ model: SubscriptionSummary,
3650
+ interceptors,
3651
+ });
3652
+ }
3653
+ }
3654
+
3655
+ class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3656
+ constructor({ firestore, interceptors }, parentRepository) {
3657
+ super({
3658
+ firestore,
3659
+ collectionName: 'address',
3660
+ parentIdField: 'userId',
3661
+ model: UserAddress,
3662
+ interceptors,
3663
+ });
3664
+ this.parentRepository = parentRepository;
3665
+ }
3666
+ }
3667
+
3668
+ class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3669
+ constructor({ firestore, interceptors }, parentRepository) {
3670
+ super({
3671
+ firestore,
3672
+ collectionName: 'CX',
3673
+ parentIdField: 'userId',
3674
+ model: BeautyProfile,
3725
3675
  interceptors,
3726
3676
  });
3677
+ this.parentRepository = parentRepository;
3678
+ }
3679
+ }
3680
+
3681
+ class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3682
+ constructor({ firestore, interceptors }) {
3683
+ super({
3684
+ firestore,
3685
+ collectionName: 'users',
3686
+ model: User,
3687
+ interceptors,
3688
+ });
3689
+ }
3690
+ async get(identifiers) {
3691
+ const user = await super.get({ id: identifiers.id });
3692
+ user.beautyProfile = await this.getBeautyProfile(user.id);
3693
+ user.isSubscriber = await this.checkIfIsSubscriber(user.id);
3694
+ return user;
3695
+ }
3696
+ async checkIfExistsByField(field, value) {
3697
+ const result = await this.find({ filters: { [field]: value } });
3698
+ return result.count > 0;
3699
+ }
3700
+ buildModelInstance() {
3701
+ const { fromFirestore, toFirestore } = super.buildModelInstance();
3702
+ return {
3703
+ toFirestore: (data) => {
3704
+ const plain = toFirestore(data);
3705
+ delete plain.isSubscriber;
3706
+ return plain;
3707
+ },
3708
+ fromFirestore,
3709
+ };
3710
+ }
3711
+ async getBeautyProfile(userId) {
3712
+ const beautyProfile = await this.firestore
3713
+ .getCollection(`${this.collectionName}/${userId}/CX`)
3714
+ .withConverter(this.buildBeautyProfileModelInstance())
3715
+ .getDoc('beautyProfile')
3716
+ .get();
3717
+ return beautyProfile.data();
3718
+ }
3719
+ async checkIfIsSubscriber(userId) {
3720
+ const docs = await this.collection('subscription')
3721
+ .where('user.id', '==', userId)
3722
+ .where('status', '==', 'active')
3723
+ .getDocs();
3724
+ return !!docs && !!docs.size;
3725
+ }
3726
+ buildBeautyProfileModelInstance() {
3727
+ return {
3728
+ toFirestore: (data) => data.toPlain(),
3729
+ fromFirestore: (snap) => BeautyProfile.toInstance(snap.data()),
3730
+ };
3731
+ }
3732
+ }
3733
+ __decorate([
3734
+ Log(),
3735
+ __metadata("design:type", Function),
3736
+ __metadata("design:paramtypes", [Object]),
3737
+ __metadata("design:returntype", Promise)
3738
+ ], UserFirestoreRepository.prototype, "get", null);
3739
+ __decorate([
3740
+ Log(),
3741
+ __metadata("design:type", Function),
3742
+ __metadata("design:paramtypes", [String, String]),
3743
+ __metadata("design:returntype", Promise)
3744
+ ], UserFirestoreRepository.prototype, "checkIfExistsByField", null);
3745
+
3746
+ class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3747
+ constructor({ firestore, interceptors }, parentRepository) {
3748
+ super({
3749
+ firestore,
3750
+ collectionName: 'payment_method',
3751
+ parentIdField: 'userId',
3752
+ model: UserPaymentMethod,
3753
+ interceptors,
3754
+ });
3755
+ this.parentRepository = parentRepository;
3727
3756
  }
3728
3757
  }
3729
3758
 
@@ -4946,7 +4975,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4946
4975
  const mostRelevants = category.getMostRelevantByShop(shop);
4947
4976
  const mostRelevantProductsIds = [...new Set(mostRelevants.concat(category.products))];
4948
4977
  const products = [];
4949
- const { data: productsData } = await this.productRepository.findCatalog({
4978
+ const { data: productsData } = await this.productRepository.find({
4950
4979
  filters: {
4951
4980
  id: { operator: Where.IN, value: mostRelevantProductsIds },
4952
4981
  published: true,
@@ -4985,13 +5014,13 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4985
5014
  stock: 'desc',
4986
5015
  name: 'asc',
4987
5016
  },
4988
- }, shop === Shops.MENSMARKET ? 'male' : 'female');
5017
+ });
4989
5018
  const mostRelevantWithouyStock = productsData.filter((product) => mostRelevants.includes(product.id) && product.stock.quantity <= 0);
4990
5019
  const firstProducts = productsData
4991
5020
  .filter((product) => mostRelevants.includes(product.id) && product.stock.quantity > 0)
4992
5021
  .sort((a, b) => mostRelevants.indexOf(a.id) - mostRelevants.indexOf(b.id));
4993
5022
  const lastProducts = productsData
4994
- .filter((product) => !mostRelevants.includes(product.id) && product.stock.quantity > 0)
5023
+ .filter((product) => !mostRelevants.includes(product.id))
4995
5024
  .concat(mostRelevantWithouyStock);
4996
5025
  const categoryMostRelevants = firstProducts.concat(lastProducts);
4997
5026
  const resultFinal = categoryMostRelevants.slice(0, options.limit);
@@ -6571,4 +6600,4 @@ class ProductsVertexSearch {
6571
6600
  }
6572
6601
  }
6573
6602
 
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 };
6603
+ export { AccessoryImportances, Address, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository, Campaign, CampaignBanner, CampaignDashboard, CampaignDashboardFirestoreRepository, CampaignHashtag, CampaignHashtagFirestoreRepository, Category, CategoryCollectionChildren, CategoryCollectionChildrenHasuraGraphQLRepository, CategoryFilter, CategoryFilterHasuraGraphQLRepository, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, ClassNameHelper, ConnectBaseDocumentSnapshot, ConnectCollectionService, ConnectDocumentService, ConnectFirestoreService, Coupon, CouponCategory, CouponFirestoreRepository, CouponSubtypes, CouponTypes, Debug, DebugDecoratorHelper, DebugHelper, DebugNamespaces, DuplicatedResultsError, Edition, EditionStatus, Exclusivities, FaceSkinOilinesses, FaceSkinProblems, FaceSkinTones, FamilyIncomes, Filter, FilterHasuraGraphQLRepository, FilterOption, FilterOptionHasuraGraphQLRepository, FilterType, FirebaseFileUploaderService, FragranceImportances, GenderDestination, HairColors, HairProblems, HairStrands, HairTypes, Home, HomeFirestoreRepository, InvalidArgumentError, KitProduct, KitProductHasuraGraphQL, Lead, LeadFirestoreRepository, LegacyOrderFirestoreRepository, LineItem, Log, LogDocument, LogFirestoreRepository, Logger, NotFoundError, OfficePosition, Order, OrderBlocked, OrderBlockedFirestoreRepository, OrderFirestoreRepository, OrderStatus, Payment, PaymentFirestoreRepository, PaymentType, PersonTypes, Plans, Product, ProductFirestoreRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductReviews, ProductReviewsHasuraGraphQLRepository, ProductSpents, ProductStockNotification, ProductStockNotificationHasuraGraphQLRepository, ProductVariantFirestoreRepository, ProductsIndex, ProductsVertexSearch, QuestionsFilters, RecoveryPassword, ReflectHelper, Register, RegisterFirebaseAuthService, RequiredArgumentError, RoundProductPricesHelper, ShippingMethod, ShopMenu, ShopMenuFirestoreRepository, ShopPageName, ShopSettings, ShopSettingsFirestoreRepository, Shops, SignInMethods, SignOut, Status, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionMaterialization, SubscriptionMaterializationFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionSummary, SubscriptionSummaryFirestoreRepository, Trace, UnauthorizedError, UpdateOptionActions, UpdateUserImage, User, UserAddress, UserAddressFirestoreRepository, UserAlreadyRegisteredError, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserPaymentMethod, UserPaymentMethodFirestoreRepository, UserType, Variant, VariantHasuraGraphQL, VariantHasuraGraphQLRepository, VertexAxiosAdapter, WeakPasswordError, Where, Wishlist, WishlistHasuraGraphQLRepository, WishlistLogType, is, isDebuggable, isUUID, parseDateTime, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infrab4a/connect",
3
- "version": "4.16.2-beta.1",
3
+ "version": "4.17.0",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org"
6
6
  },
@@ -1,2 +1,3 @@
1
1
  export * from './product-genders.enum';
2
2
  export * from './shops.enum';
3
+ export * from './wishlist-log.enum';
@@ -0,0 +1,7 @@
1
+ export declare enum WishlistLogType {
2
+ CREATE = "create",
3
+ UPDATE = "update",
4
+ DELETE = "delete",
5
+ ADD_PRODUCT = "add_product",
6
+ REMOVE_PRODUCT = "remove_product"
7
+ }
@@ -1,2 +1,4 @@
1
+ export * from './models';
2
+ export * from './repositories';
1
3
  export * from './search';
2
4
  export * from './storage';
@@ -0,0 +1 @@
1
+ export * from './log-document';
@@ -0,0 +1,15 @@
1
+ import { BaseModel, GenericIdentifier } from '../../generic';
2
+ export declare class LogDocument extends BaseModel<LogDocument> {
3
+ id?: string;
4
+ collection: string;
5
+ documentId: string;
6
+ user?: {
7
+ id?: string;
8
+ name?: string;
9
+ email?: string;
10
+ };
11
+ document: any;
12
+ date: Date;
13
+ operation: 'CREATE' | 'UPDATE' | 'DELETE';
14
+ static get identifiersFields(): GenericIdentifier[];
15
+ }
@@ -0,0 +1 @@
1
+ export * from './log.repository';
@@ -0,0 +1,4 @@
1
+ import { CrudRepository } from '../../generic/repository/crud.repository';
2
+ import { LogDocument } from '../models';
3
+ export interface LogRepository extends CrudRepository<LogDocument> {
4
+ }
@@ -3,6 +3,9 @@ export declare enum CouponCategory {
3
3
  Desculpas = "Desculpas",
4
4
  BFlu = "BFlu",
5
5
  ROYAL = "Royal",
6
+ Glamqueen = "Glamqueen",
7
+ Glampartner = "Glampartner",
8
+ Glamgirl = "Glamgirl",
6
9
  Glamdiva = "Glamdiva",
7
10
  Impulsionamento = "Impulsionamento",
8
11
  PaidMedia = "Paid Media",
@@ -0,0 +1 @@
1
+ export * from './log-firestore.repository';
@@ -0,0 +1,7 @@
1
+ import { LogDocument, LogRepository } from '../../../../../domain';
2
+ import { FirestoreConstructorParams } from '../../mixins';
3
+ declare const LogFirestoreRepository_base: import("../../../../../utils").MixinCtor<import("../..").FirestoreRepository<LogDocument> & import("../../../../../domain").CrudRepository<LogDocument, import("../../../../../domain").CrudParams<LogDocument>> & import("../..").FirestoreHelpers, [FirestoreConstructorParams<LogDocument>, ...any[]]>;
4
+ export declare class LogFirestoreRepository extends LogFirestoreRepository_base implements LogRepository {
5
+ constructor({ firestore, interceptors, }: Pick<FirestoreConstructorParams<LogDocument>, 'firestore' | 'interceptors'>);
6
+ }
7
+ export {};
@@ -1,4 +1,5 @@
1
- export * from './users';
2
1
  export * from './catalog';
3
- export * from './shopping';
2
+ export * from './general';
4
3
  export * from './shop-settings';
4
+ export * from './shopping';
5
+ export * from './users';