@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.cjs.js +276 -275
- package/index.esm.js +275 -276
- package/package.json +1 -1
- package/src/domain/catalog/models/enums/index.d.ts +1 -0
- package/src/domain/catalog/models/enums/wishlist-log.enum.d.ts +7 -0
- package/src/domain/catalog/repositories/category.repository.d.ts +2 -2
- package/src/domain/general/index.d.ts +2 -0
- package/src/domain/general/models/index.d.ts +1 -0
- package/src/domain/general/models/log-document.d.ts +15 -0
- package/src/domain/general/repositories/index.d.ts +1 -0
- package/src/domain/general/repositories/log.repository.d.ts +4 -0
- package/src/infra/firebase/firestore/repositories/catalog/category-firestore.repository.d.ts +2 -2
- package/src/infra/firebase/firestore/repositories/general/index.d.ts +1 -0
- package/src/infra/firebase/firestore/repositories/general/log-firestore.repository.d.ts +7 -0
- package/src/infra/firebase/firestore/repositories/index.d.ts +3 -2
- package/src/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.d.ts +2 -2
- package/src/infra/hasura-graphql/repositories/catalog/wishlist-hasura-graphql.repository.d.ts +2 -2
package/index.cjs.js
CHANGED
|
@@ -57,6 +57,15 @@ exports.Shops = void 0;
|
|
|
57
57
|
Shops["ALL"] = "ALL";
|
|
58
58
|
})(exports.Shops || (exports.Shops = {}));
|
|
59
59
|
|
|
60
|
+
exports.WishlistLogType = void 0;
|
|
61
|
+
(function (WishlistLogType) {
|
|
62
|
+
WishlistLogType["CREATE"] = "create";
|
|
63
|
+
WishlistLogType["UPDATE"] = "update";
|
|
64
|
+
WishlistLogType["DELETE"] = "delete";
|
|
65
|
+
WishlistLogType["ADD_PRODUCT"] = "add_product";
|
|
66
|
+
WishlistLogType["REMOVE_PRODUCT"] = "remove_product";
|
|
67
|
+
})(exports.WishlistLogType || (exports.WishlistLogType = {}));
|
|
68
|
+
|
|
60
69
|
class Filter extends BaseModel {
|
|
61
70
|
static get identifiersFields() {
|
|
62
71
|
return ['id'];
|
|
@@ -2231,6 +2240,12 @@ class RoundProductPricesHelper {
|
|
|
2231
2240
|
}
|
|
2232
2241
|
}
|
|
2233
2242
|
|
|
2243
|
+
class LogDocument extends BaseModel {
|
|
2244
|
+
static get identifiersFields() {
|
|
2245
|
+
return ['id'];
|
|
2246
|
+
}
|
|
2247
|
+
}
|
|
2248
|
+
|
|
2234
2249
|
exports.FilterType = void 0;
|
|
2235
2250
|
(function (FilterType) {
|
|
2236
2251
|
FilterType["ACCESSORY_IMPORTANCE"] = "accessoryImportance";
|
|
@@ -3098,180 +3113,6 @@ const withCrudFirestore = (MixinBase) => {
|
|
|
3098
3113
|
};
|
|
3099
3114
|
};
|
|
3100
3115
|
|
|
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
3116
|
class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3276
3117
|
constructor({ firestore, interceptors }) {
|
|
3277
3118
|
super({
|
|
@@ -3293,7 +3134,7 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
3293
3134
|
throw new NotFoundError(`Document with slug ${slug} not found`);
|
|
3294
3135
|
return categoryDocs.docs[0].data();
|
|
3295
3136
|
}
|
|
3296
|
-
async getCategoriesForHome(categoryIds,
|
|
3137
|
+
async getCategoriesForHome(categoryIds, limit = 4, gender) {
|
|
3297
3138
|
const categorySnap = await this.collection(this.collectionName)
|
|
3298
3139
|
.where('id', 'in', categoryIds.filter(Boolean))
|
|
3299
3140
|
.where('published', '==', true)
|
|
@@ -3303,11 +3144,11 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
3303
3144
|
const categories = categorySnap.docs.map((doc) => doc.data());
|
|
3304
3145
|
const homeSections = await Promise.all(categories.map(async (category) => ({
|
|
3305
3146
|
category,
|
|
3306
|
-
products: await this.mountCategory(category,
|
|
3147
|
+
products: await this.mountCategory(category, { limit, hasStock: true, gender }),
|
|
3307
3148
|
})));
|
|
3308
3149
|
return homeSections;
|
|
3309
3150
|
}
|
|
3310
|
-
async mountCategory(category,
|
|
3151
|
+
async mountCategory(category, options) {
|
|
3311
3152
|
if (!category.products)
|
|
3312
3153
|
throw new RequiredArgumentError(['Category products is empty']);
|
|
3313
3154
|
const chunks = lodash.chunk(category.products, 10);
|
|
@@ -3351,13 +3192,13 @@ tslib.__decorate([
|
|
|
3351
3192
|
tslib.__decorate([
|
|
3352
3193
|
Log(),
|
|
3353
3194
|
tslib.__metadata("design:type", Function),
|
|
3354
|
-
tslib.__metadata("design:paramtypes", [Array,
|
|
3195
|
+
tslib.__metadata("design:paramtypes", [Array, Object, String]),
|
|
3355
3196
|
tslib.__metadata("design:returntype", Promise)
|
|
3356
3197
|
], CategoryFirestoreRepository.prototype, "getCategoriesForHome", null);
|
|
3357
3198
|
tslib.__decorate([
|
|
3358
3199
|
Log(),
|
|
3359
3200
|
tslib.__metadata("design:type", Function),
|
|
3360
|
-
tslib.__metadata("design:paramtypes", [Category,
|
|
3201
|
+
tslib.__metadata("design:paramtypes", [Category, Object]),
|
|
3361
3202
|
tslib.__metadata("design:returntype", Promise)
|
|
3362
3203
|
], CategoryFirestoreRepository.prototype, "mountCategory", null);
|
|
3363
3204
|
|
|
@@ -3456,6 +3297,101 @@ class SubscriptionProductFirestoreRepository extends withCrudFirestore(withHelpe
|
|
|
3456
3297
|
}
|
|
3457
3298
|
}
|
|
3458
3299
|
|
|
3300
|
+
class LogFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3301
|
+
constructor({ firestore, interceptors, }) {
|
|
3302
|
+
super({
|
|
3303
|
+
firestore,
|
|
3304
|
+
collectionName: 'logs',
|
|
3305
|
+
model: LogDocument,
|
|
3306
|
+
interceptors,
|
|
3307
|
+
});
|
|
3308
|
+
}
|
|
3309
|
+
}
|
|
3310
|
+
|
|
3311
|
+
class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3312
|
+
constructor({ firestore, interceptors }) {
|
|
3313
|
+
super({
|
|
3314
|
+
firestore,
|
|
3315
|
+
collectionName: 'dms',
|
|
3316
|
+
model: Home,
|
|
3317
|
+
interceptors,
|
|
3318
|
+
});
|
|
3319
|
+
this.homeCategoryGroupToPlain = (homeCategoryGroup) => {
|
|
3320
|
+
var _a, _b, _c;
|
|
3321
|
+
return ({
|
|
3322
|
+
category: ((_a = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _a === void 0 ? void 0 : _a.toPlain)
|
|
3323
|
+
? (_b = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _b === void 0 ? void 0 : _b.toPlain()
|
|
3324
|
+
: homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category,
|
|
3325
|
+
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)) || [],
|
|
3326
|
+
});
|
|
3327
|
+
};
|
|
3328
|
+
this.plainToHomeCategoryGroup = (homeCategoryGroup) => {
|
|
3329
|
+
var _a;
|
|
3330
|
+
return ({
|
|
3331
|
+
category: Category.toInstance(homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category),
|
|
3332
|
+
products: (_a = homeCategoryGroup.products) === null || _a === void 0 ? void 0 : _a.map((product) => Product.toInstance(product)),
|
|
3333
|
+
});
|
|
3334
|
+
};
|
|
3335
|
+
}
|
|
3336
|
+
buildModelInstance() {
|
|
3337
|
+
const { fromFirestore, toFirestore } = super.buildModelInstance();
|
|
3338
|
+
return {
|
|
3339
|
+
toFirestore: (data) => {
|
|
3340
|
+
const modifiedData = this.homeToFirestore(data);
|
|
3341
|
+
return toFirestore(modifiedData);
|
|
3342
|
+
},
|
|
3343
|
+
fromFirestore: (snap) => {
|
|
3344
|
+
const instance = fromFirestore(snap);
|
|
3345
|
+
return this.homeFromFirestore(instance);
|
|
3346
|
+
},
|
|
3347
|
+
};
|
|
3348
|
+
}
|
|
3349
|
+
homeToFirestore(home) {
|
|
3350
|
+
var _a, _b, _c, _d;
|
|
3351
|
+
if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
|
|
3352
|
+
home.data.data.discoverProducts = ((_b = home.data.data.discoverProducts) === null || _b === void 0 ? void 0 : _b.map(this.homeCategoryGroupToPlain)) || [];
|
|
3353
|
+
home.data.data.featuredProducts = ((_c = home.data.data.featuredProducts) === null || _c === void 0 ? void 0 : _c.map(this.homeCategoryGroupToPlain)) || [];
|
|
3354
|
+
home.data.data.verticalProducts = ((_d = home.data.data.verticalProducts) === null || _d === void 0 ? void 0 : _d.map(this.homeCategoryGroupToPlain)) || [];
|
|
3355
|
+
}
|
|
3356
|
+
return home;
|
|
3357
|
+
}
|
|
3358
|
+
homeFromFirestore(home) {
|
|
3359
|
+
var _a;
|
|
3360
|
+
if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
|
|
3361
|
+
home.data.data.discoverProducts = home.data.data.discoverProducts.map(this.plainToHomeCategoryGroup);
|
|
3362
|
+
home.data.data.featuredProducts = home.data.data.featuredProducts.map(this.plainToHomeCategoryGroup);
|
|
3363
|
+
home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.plainToHomeCategoryGroup);
|
|
3364
|
+
home.data.createdAt =
|
|
3365
|
+
home.data.createdAt instanceof firestore.Timestamp ? home.data.createdAt.toDate() : home.data.createdAt;
|
|
3366
|
+
home.data.expiresAt =
|
|
3367
|
+
home.data.expiresAt instanceof firestore.Timestamp ? home.data.expiresAt.toDate() : home.data.expiresAt;
|
|
3368
|
+
}
|
|
3369
|
+
return home;
|
|
3370
|
+
}
|
|
3371
|
+
}
|
|
3372
|
+
|
|
3373
|
+
class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3374
|
+
constructor({ firestore, interceptors }) {
|
|
3375
|
+
super({
|
|
3376
|
+
firestore,
|
|
3377
|
+
collectionName: 'shopMenus',
|
|
3378
|
+
model: ShopMenu,
|
|
3379
|
+
interceptors,
|
|
3380
|
+
});
|
|
3381
|
+
}
|
|
3382
|
+
}
|
|
3383
|
+
|
|
3384
|
+
class ShopSettingsFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3385
|
+
constructor({ firestore, interceptors, }) {
|
|
3386
|
+
super({
|
|
3387
|
+
firestore,
|
|
3388
|
+
collectionName: 'shopSettings',
|
|
3389
|
+
model: ShopSettings,
|
|
3390
|
+
interceptors,
|
|
3391
|
+
});
|
|
3392
|
+
}
|
|
3393
|
+
}
|
|
3394
|
+
|
|
3459
3395
|
class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3460
3396
|
constructor({ firestore, interceptors }) {
|
|
3461
3397
|
super({
|
|
@@ -3649,90 +3585,180 @@ class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(
|
|
|
3649
3585
|
}
|
|
3650
3586
|
}
|
|
3651
3587
|
|
|
3652
|
-
class
|
|
3588
|
+
class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3653
3589
|
constructor({ firestore, interceptors }) {
|
|
3654
3590
|
super({
|
|
3655
3591
|
firestore,
|
|
3656
|
-
collectionName: '
|
|
3657
|
-
model:
|
|
3592
|
+
collectionName: 'leads',
|
|
3593
|
+
model: Lead,
|
|
3658
3594
|
interceptors,
|
|
3659
3595
|
});
|
|
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
3596
|
}
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3597
|
+
}
|
|
3598
|
+
|
|
3599
|
+
class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3600
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
3601
|
+
super({
|
|
3602
|
+
firestore,
|
|
3603
|
+
collectionName: 'editions',
|
|
3604
|
+
parentIdField: 'subscriptionId',
|
|
3605
|
+
model: Edition,
|
|
3606
|
+
interceptors,
|
|
3607
|
+
});
|
|
3608
|
+
this.parentRepository = parentRepository;
|
|
3698
3609
|
}
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
}
|
|
3710
|
-
return home;
|
|
3610
|
+
}
|
|
3611
|
+
|
|
3612
|
+
class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3613
|
+
constructor({ firestore, interceptors, }) {
|
|
3614
|
+
super({
|
|
3615
|
+
firestore,
|
|
3616
|
+
collectionName: 'subscription',
|
|
3617
|
+
model: Subscription,
|
|
3618
|
+
interceptors,
|
|
3619
|
+
});
|
|
3711
3620
|
}
|
|
3712
3621
|
}
|
|
3713
3622
|
|
|
3714
|
-
class
|
|
3623
|
+
class SubscriptionMaterializationFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3715
3624
|
constructor({ firestore, interceptors }) {
|
|
3716
3625
|
super({
|
|
3717
3626
|
firestore,
|
|
3718
|
-
collectionName: '
|
|
3719
|
-
model:
|
|
3627
|
+
collectionName: 'subscriptionMaterialization',
|
|
3628
|
+
model: SubscriptionMaterialization,
|
|
3720
3629
|
interceptors,
|
|
3721
3630
|
});
|
|
3722
3631
|
}
|
|
3723
3632
|
}
|
|
3724
3633
|
|
|
3725
|
-
class
|
|
3634
|
+
class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3635
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
3636
|
+
super({
|
|
3637
|
+
firestore,
|
|
3638
|
+
collectionName: 'payments',
|
|
3639
|
+
parentIdField: 'subscriptionId',
|
|
3640
|
+
model: SubscriptionPayment,
|
|
3641
|
+
interceptors,
|
|
3642
|
+
});
|
|
3643
|
+
this.parentRepository = parentRepository;
|
|
3644
|
+
}
|
|
3645
|
+
}
|
|
3646
|
+
|
|
3647
|
+
class SubscriptionSummaryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3726
3648
|
constructor({ firestore, interceptors, }) {
|
|
3727
3649
|
super({
|
|
3728
3650
|
firestore,
|
|
3729
|
-
collectionName: '
|
|
3730
|
-
model:
|
|
3651
|
+
collectionName: 'subscriptionSummary',
|
|
3652
|
+
model: SubscriptionSummary,
|
|
3731
3653
|
interceptors,
|
|
3732
3654
|
});
|
|
3733
3655
|
}
|
|
3734
3656
|
}
|
|
3735
3657
|
|
|
3658
|
+
class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3659
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
3660
|
+
super({
|
|
3661
|
+
firestore,
|
|
3662
|
+
collectionName: 'address',
|
|
3663
|
+
parentIdField: 'userId',
|
|
3664
|
+
model: UserAddress,
|
|
3665
|
+
interceptors,
|
|
3666
|
+
});
|
|
3667
|
+
this.parentRepository = parentRepository;
|
|
3668
|
+
}
|
|
3669
|
+
}
|
|
3670
|
+
|
|
3671
|
+
class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3672
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
3673
|
+
super({
|
|
3674
|
+
firestore,
|
|
3675
|
+
collectionName: 'CX',
|
|
3676
|
+
parentIdField: 'userId',
|
|
3677
|
+
model: BeautyProfile,
|
|
3678
|
+
interceptors,
|
|
3679
|
+
});
|
|
3680
|
+
this.parentRepository = parentRepository;
|
|
3681
|
+
}
|
|
3682
|
+
}
|
|
3683
|
+
|
|
3684
|
+
class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
3685
|
+
constructor({ firestore, interceptors }) {
|
|
3686
|
+
super({
|
|
3687
|
+
firestore,
|
|
3688
|
+
collectionName: 'users',
|
|
3689
|
+
model: User,
|
|
3690
|
+
interceptors,
|
|
3691
|
+
});
|
|
3692
|
+
}
|
|
3693
|
+
async get(identifiers) {
|
|
3694
|
+
const user = await super.get({ id: identifiers.id });
|
|
3695
|
+
user.beautyProfile = await this.getBeautyProfile(user.id);
|
|
3696
|
+
user.isSubscriber = await this.checkIfIsSubscriber(user.id);
|
|
3697
|
+
return user;
|
|
3698
|
+
}
|
|
3699
|
+
async checkIfExistsByField(field, value) {
|
|
3700
|
+
const result = await this.find({ filters: { [field]: value } });
|
|
3701
|
+
return result.count > 0;
|
|
3702
|
+
}
|
|
3703
|
+
buildModelInstance() {
|
|
3704
|
+
const { fromFirestore, toFirestore } = super.buildModelInstance();
|
|
3705
|
+
return {
|
|
3706
|
+
toFirestore: (data) => {
|
|
3707
|
+
const plain = toFirestore(data);
|
|
3708
|
+
delete plain.isSubscriber;
|
|
3709
|
+
return plain;
|
|
3710
|
+
},
|
|
3711
|
+
fromFirestore,
|
|
3712
|
+
};
|
|
3713
|
+
}
|
|
3714
|
+
async getBeautyProfile(userId) {
|
|
3715
|
+
const beautyProfile = await this.firestore
|
|
3716
|
+
.getCollection(`${this.collectionName}/${userId}/CX`)
|
|
3717
|
+
.withConverter(this.buildBeautyProfileModelInstance())
|
|
3718
|
+
.getDoc('beautyProfile')
|
|
3719
|
+
.get();
|
|
3720
|
+
return beautyProfile.data();
|
|
3721
|
+
}
|
|
3722
|
+
async checkIfIsSubscriber(userId) {
|
|
3723
|
+
const docs = await this.collection('subscription')
|
|
3724
|
+
.where('user.id', '==', userId)
|
|
3725
|
+
.where('status', '==', 'active')
|
|
3726
|
+
.getDocs();
|
|
3727
|
+
return !!docs && !!docs.size;
|
|
3728
|
+
}
|
|
3729
|
+
buildBeautyProfileModelInstance() {
|
|
3730
|
+
return {
|
|
3731
|
+
toFirestore: (data) => data.toPlain(),
|
|
3732
|
+
fromFirestore: (snap) => BeautyProfile.toInstance(snap.data()),
|
|
3733
|
+
};
|
|
3734
|
+
}
|
|
3735
|
+
}
|
|
3736
|
+
tslib.__decorate([
|
|
3737
|
+
Log(),
|
|
3738
|
+
tslib.__metadata("design:type", Function),
|
|
3739
|
+
tslib.__metadata("design:paramtypes", [Object]),
|
|
3740
|
+
tslib.__metadata("design:returntype", Promise)
|
|
3741
|
+
], UserFirestoreRepository.prototype, "get", null);
|
|
3742
|
+
tslib.__decorate([
|
|
3743
|
+
Log(),
|
|
3744
|
+
tslib.__metadata("design:type", Function),
|
|
3745
|
+
tslib.__metadata("design:paramtypes", [String, String]),
|
|
3746
|
+
tslib.__metadata("design:returntype", Promise)
|
|
3747
|
+
], UserFirestoreRepository.prototype, "checkIfExistsByField", null);
|
|
3748
|
+
|
|
3749
|
+
class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
|
|
3750
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
3751
|
+
super({
|
|
3752
|
+
firestore,
|
|
3753
|
+
collectionName: 'payment_method',
|
|
3754
|
+
parentIdField: 'userId',
|
|
3755
|
+
model: UserPaymentMethod,
|
|
3756
|
+
interceptors,
|
|
3757
|
+
});
|
|
3758
|
+
this.parentRepository = parentRepository;
|
|
3759
|
+
}
|
|
3760
|
+
}
|
|
3761
|
+
|
|
3736
3762
|
class ConnectBaseDocumentSnapshot {
|
|
3737
3763
|
constructor(connectDocumentSnapshot) {
|
|
3738
3764
|
this.connectDocumentSnapshot = connectDocumentSnapshot;
|
|
@@ -4920,7 +4946,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4920
4946
|
});
|
|
4921
4947
|
return data;
|
|
4922
4948
|
}
|
|
4923
|
-
async getCategoriesForHome(categoryIds,
|
|
4949
|
+
async getCategoriesForHome(categoryIds, limit = 4, gender) {
|
|
4924
4950
|
if (!(categoryIds === null || categoryIds === void 0 ? void 0 : categoryIds.length))
|
|
4925
4951
|
return [];
|
|
4926
4952
|
const categoriesFirestore = categoryIds.filter((categoryId) => Number.isNaN(+categoryId));
|
|
@@ -4932,32 +4958,22 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4932
4958
|
}).then(({ data }) => data)));
|
|
4933
4959
|
if (categoriesHasura.length)
|
|
4934
4960
|
categories.push(...(await this.find({
|
|
4935
|
-
filters: {
|
|
4936
|
-
id: { operator: exports.Where.IN, value: categoriesHasura.filter(Boolean) },
|
|
4937
|
-
published: true,
|
|
4938
|
-
},
|
|
4961
|
+
filters: { id: { operator: exports.Where.IN, value: categoriesHasura.filter(Boolean) }, published: true },
|
|
4939
4962
|
}).then(({ data }) => data)));
|
|
4940
4963
|
if (!categories.length)
|
|
4941
4964
|
return [];
|
|
4942
4965
|
const homeSections = await Promise.all(categories.map(async (category) => ({
|
|
4943
4966
|
category,
|
|
4944
|
-
products: await this.mountCategory(category,
|
|
4967
|
+
products: await this.mountCategory(category, { limit, hasStock: true, gender }),
|
|
4945
4968
|
})));
|
|
4946
4969
|
return homeSections;
|
|
4947
4970
|
}
|
|
4948
|
-
async mountCategory(category,
|
|
4971
|
+
async mountCategory(category, options) {
|
|
4949
4972
|
var _a;
|
|
4950
4973
|
if (!((_a = category === null || category === void 0 ? void 0 : category.products) === null || _a === void 0 ? void 0 : _a.length))
|
|
4951
4974
|
return [];
|
|
4952
|
-
const mostRelevants = category.getMostRelevantByShop(shop);
|
|
4953
|
-
const mostRelevantProductsIds = [...new Set(mostRelevants.concat(category.products))];
|
|
4954
4975
|
const products = [];
|
|
4955
|
-
const { data: productsData } = await this.productRepository.find({
|
|
4956
|
-
filters: {
|
|
4957
|
-
id: { operator: exports.Where.IN, value: mostRelevantProductsIds },
|
|
4958
|
-
published: true,
|
|
4959
|
-
},
|
|
4960
|
-
fields: [
|
|
4976
|
+
const { data: productsData } = await this.productRepository.find(Object.assign(Object.assign({ filters: Object.assign(Object.assign({ id: { operator: exports.Where.IN, value: category.products }, published: true }, ((options === null || options === void 0 ? void 0 : options.hasStock) ? { stock: { quantity: { operator: exports.Where.GT, value: 0 } } } : {})), ((options === null || options === void 0 ? void 0 : options.gender) ? { tags: { operator: exports.Where.IN, value: [options === null || options === void 0 ? void 0 : options.gender] } } : {})), fields: [
|
|
4961
4977
|
'id',
|
|
4962
4978
|
'name',
|
|
4963
4979
|
'slug',
|
|
@@ -4983,25 +4999,8 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4983
4999
|
'shoppingCount',
|
|
4984
5000
|
'gender',
|
|
4985
5001
|
'createdAt',
|
|
4986
|
-
],
|
|
4987
|
-
|
|
4988
|
-
orderBy: {
|
|
4989
|
-
shoppingCount: 'desc',
|
|
4990
|
-
rate: 'desc',
|
|
4991
|
-
stock: 'desc',
|
|
4992
|
-
name: 'asc',
|
|
4993
|
-
},
|
|
4994
|
-
});
|
|
4995
|
-
const mostRelevantWithouyStock = productsData.filter((product) => mostRelevants.includes(product.id) && product.stock.quantity <= 0);
|
|
4996
|
-
const firstProducts = productsData
|
|
4997
|
-
.filter((product) => mostRelevants.includes(product.id) && product.stock.quantity > 0)
|
|
4998
|
-
.sort((a, b) => mostRelevants.indexOf(a.id) - mostRelevants.indexOf(b.id));
|
|
4999
|
-
const lastProducts = productsData
|
|
5000
|
-
.filter((product) => !mostRelevants.includes(product.id) && product.stock.quantity > 0)
|
|
5001
|
-
.concat(mostRelevantWithouyStock);
|
|
5002
|
-
const categoryMostRelevants = firstProducts.concat(lastProducts);
|
|
5003
|
-
const resultFinal = categoryMostRelevants.slice(0, options.limit);
|
|
5004
|
-
products.push(...resultFinal);
|
|
5002
|
+
] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})), { options: { enableCount: false } }));
|
|
5003
|
+
products.push(...productsData);
|
|
5005
5004
|
return products;
|
|
5006
5005
|
}
|
|
5007
5006
|
async getChildren(parentId) {
|
|
@@ -5176,13 +5175,13 @@ tslib.__decorate([
|
|
|
5176
5175
|
tslib.__decorate([
|
|
5177
5176
|
Log(),
|
|
5178
5177
|
tslib.__metadata("design:type", Function),
|
|
5179
|
-
tslib.__metadata("design:paramtypes", [Array,
|
|
5178
|
+
tslib.__metadata("design:paramtypes", [Array, Object, String]),
|
|
5180
5179
|
tslib.__metadata("design:returntype", Promise)
|
|
5181
5180
|
], CategoryHasuraGraphQLRepository.prototype, "getCategoriesForHome", null);
|
|
5182
5181
|
tslib.__decorate([
|
|
5183
5182
|
Log(),
|
|
5184
5183
|
tslib.__metadata("design:type", Function),
|
|
5185
|
-
tslib.__metadata("design:paramtypes", [Category,
|
|
5184
|
+
tslib.__metadata("design:paramtypes", [Category, Object]),
|
|
5186
5185
|
tslib.__metadata("design:returntype", Promise)
|
|
5187
5186
|
], CategoryHasuraGraphQLRepository.prototype, "mountCategory", null);
|
|
5188
5187
|
tslib.__decorate([
|
|
@@ -6313,10 +6312,10 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
6313
6312
|
value: [exports.PersonTypes.BFLU, exports.PersonTypes.GLAMGIRL],
|
|
6314
6313
|
} }), orderBy: Object.assign({ personHasPhoto: 'desc' }, lodash.omit(params.orderBy, ['personHasPhoto'])) }));
|
|
6315
6314
|
}
|
|
6316
|
-
getCategoriesForHome(categoryIds,
|
|
6315
|
+
getCategoriesForHome(categoryIds, limit, gender) {
|
|
6317
6316
|
return;
|
|
6318
6317
|
}
|
|
6319
|
-
mountCategory(category,
|
|
6318
|
+
mountCategory(category, options) {
|
|
6320
6319
|
return;
|
|
6321
6320
|
}
|
|
6322
6321
|
getChildren(parentId) {
|
|
@@ -6748,6 +6747,8 @@ exports.LeadFirestoreRepository = LeadFirestoreRepository;
|
|
|
6748
6747
|
exports.LegacyOrderFirestoreRepository = LegacyOrderFirestoreRepository;
|
|
6749
6748
|
exports.LineItem = LineItem;
|
|
6750
6749
|
exports.Log = Log;
|
|
6750
|
+
exports.LogDocument = LogDocument;
|
|
6751
|
+
exports.LogFirestoreRepository = LogFirestoreRepository;
|
|
6751
6752
|
exports.Logger = Logger;
|
|
6752
6753
|
exports.NotFoundError = NotFoundError;
|
|
6753
6754
|
exports.Order = Order;
|