@infrab4a/connect 0.17.0-beta.2 → 0.17.0-beta.4
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/bundles/infrab4a-connect.umd.js +267 -198
- package/bundles/infrab4a-connect.umd.js.map +1 -1
- package/domain/catalog/models/enums/shops.enum.d.ts +2 -1
- package/domain/shopping/models/coupons/coupon.d.ts +6 -4
- package/domain/shopping/models/coupons/enums/coupon-types.enum.d.ts +2 -4
- package/domain/shopping/models/coupons/index.d.ts +0 -1
- package/domain/shopping/models/enums/checkout-types.enum.d.ts +2 -1
- package/domain/users/models/subscription/edition.d.ts +2 -0
- package/domain/users/models/user-payment-method.d.ts +1 -0
- package/domain/users/models/user.d.ts +1 -0
- package/esm2015/domain/catalog/models/enums/shops.enum.js +2 -1
- package/esm2015/domain/shopping/models/coupons/coupon.js +17 -2
- package/esm2015/domain/shopping/models/coupons/enums/coupon-subtypes.enum.js +1 -1
- package/esm2015/domain/shopping/models/coupons/enums/coupon-types.enum.js +7 -5
- package/esm2015/domain/shopping/models/coupons/index.js +1 -2
- package/esm2015/domain/shopping/models/enums/checkout-types.enum.js +2 -1
- package/esm2015/domain/users/models/subscription/edition.js +1 -1
- package/esm2015/domain/users/models/user-payment-method.js +1 -1
- package/esm2015/domain/users/models/user.js +1 -1
- package/esm2015/infra/firebase/auth/authentication-firebase-auth.service.js +6 -6
- package/esm2015/infra/firebase/auth/register-firebase-auth.service.js +4 -5
- package/esm2015/infra/firebase/auth/types/firebase-user-with-id.type.js +1 -1
- package/esm2015/infra/firebase/firestore/mixins/with-create-firestore.mixin.js +5 -7
- package/esm2015/infra/firebase/firestore/mixins/with-delete-firestore.mixin.js +4 -3
- package/esm2015/infra/firebase/firestore/mixins/with-find-firestore.mixin.js +25 -31
- package/esm2015/infra/firebase/firestore/mixins/with-firestore.mixin.js +4 -4
- package/esm2015/infra/firebase/firestore/mixins/with-get-firestore.mixin.js +5 -4
- package/esm2015/infra/firebase/firestore/mixins/with-helpers.mixin.js +1 -1
- package/esm2015/infra/firebase/firestore/mixins/with-sub-collection.mixin.js +1 -1
- package/esm2015/infra/firebase/firestore/mixins/with-update-firestore.mixin.js +10 -9
- package/esm2015/infra/firebase/firestore/repositories/catalog/category-firestore.repository.js +37 -19
- package/esm2015/infra/firebase/firestore/repositories/catalog/product-firestore.repository.js +1 -1
- package/esm2015/infra/firebase/firestore/repositories/catalog/product-variant-firestore.repository.js +1 -1
- package/esm2015/infra/firebase/firestore/repositories/catalog/subscription-product-firestore.repository.js +1 -1
- package/esm2015/infra/firebase/firestore/repositories/shop-settings/home-firestore.repository.js +4 -4
- package/esm2015/infra/firebase/firestore/repositories/shop-settings/shop-menu-firestore.repository.js +1 -1
- package/esm2015/infra/firebase/firestore/repositories/shopping/buy-2-win-firestore.repository.js +1 -1
- package/esm2015/infra/firebase/firestore/repositories/shopping/checkout-firestore.repository.js +1 -1
- package/esm2015/infra/firebase/firestore/repositories/shopping/checkout-subscription-firestore.repository.js +1 -1
- package/esm2015/infra/firebase/firestore/repositories/shopping/coupon-firestore.repository.js +1 -1
- package/esm2015/infra/firebase/firestore/repositories/shopping/legacy-order-firestore.repository.js +1 -1
- package/esm2015/infra/firebase/firestore/repositories/shopping/order-firestore.repository.js +1 -1
- package/esm2015/infra/firebase/firestore/repositories/shopping/payment-firestore.repository.js +1 -1
- package/esm2015/infra/firebase/firestore/repositories/shopping/subscription-plan-firestore.repository.js +1 -1
- package/esm2015/infra/firebase/firestore/repositories/users/lead-firestore.repository.js +1 -1
- package/esm2015/infra/firebase/firestore/repositories/users/subscription-edition-firestore.repository.js +1 -1
- package/esm2015/infra/firebase/firestore/repositories/users/subscription-firestore.repository.js +1 -1
- package/esm2015/infra/firebase/firestore/repositories/users/subscription-payment-firestore.repository.js +1 -1
- package/esm2015/infra/firebase/firestore/repositories/users/user-address-firestore.repository.js +1 -1
- package/esm2015/infra/firebase/firestore/repositories/users/user-beauty-profile-firestore.repository.js +1 -1
- package/esm2015/infra/firebase/firestore/repositories/users/user-firestore.repository.js +12 -4
- package/esm2015/infra/firebase/firestore/repositories/users/user-payment-method-firestore.repository.js +1 -1
- package/esm2015/infra/firebase/firestore/repositories/users/user-search-firestore.repository.js +1 -1
- package/esm2015/infra/firebase/firestore/types/firestore.helpers.type.js +1 -1
- package/esm2015/infra/firebase/firestore/types/firestore.repository.type.js +1 -1
- package/esm2015/utils/index.js +2 -3
- package/fesm2015/infrab4a-connect.js +125 -105
- package/fesm2015/infrab4a-connect.js.map +1 -1
- package/index.d.ts.map +1 -0
- package/infra/firebase/auth/authentication-firebase-auth.service.d.ts +2 -2
- package/infra/firebase/auth/authentication-firebase-auth.service.d.ts.map +1 -0
- package/infra/firebase/auth/index.d.ts.map +1 -0
- package/infra/firebase/auth/register-firebase-auth.service.d.ts +5 -4
- package/infra/firebase/auth/register-firebase-auth.service.d.ts.map +1 -0
- package/infra/firebase/auth/types/firebase-user-with-id.type.d.ts +1 -2
- package/infra/firebase/auth/types/firebase-user-with-id.type.d.ts.map +1 -0
- package/infra/firebase/firestore/index.d.ts.map +1 -0
- package/infra/firebase/firestore/mixins/with-create-firestore.mixin.d.ts +4 -4
- package/infra/firebase/firestore/mixins/with-crud-firestore.mixin.d.ts +8 -8
- package/infra/firebase/firestore/mixins/with-delete-firestore.mixin.d.ts +3 -3
- package/infra/firebase/firestore/mixins/with-find-firestore.mixin.d.ts +7 -7
- package/infra/firebase/firestore/mixins/with-firestore.mixin.d.ts +2 -2
- package/infra/firebase/firestore/mixins/with-get-firestore.mixin.d.ts +3 -3
- package/infra/firebase/firestore/mixins/with-helpers.mixin.d.ts +1 -1
- package/infra/firebase/firestore/mixins/with-sub-collection.mixin.d.ts +2 -2
- package/infra/firebase/firestore/mixins/with-update-firestore.mixin.d.ts +3 -3
- package/infra/firebase/firestore/repositories/catalog/category-firestore.repository.d.ts +16 -18
- package/infra/firebase/firestore/repositories/catalog/category-firestore.repository.d.ts.map +1 -0
- package/infra/firebase/firestore/repositories/catalog/index.d.ts.map +1 -0
- package/infra/firebase/firestore/repositories/catalog/product-firestore.repository.d.ts +16 -16
- package/infra/firebase/firestore/repositories/catalog/product-firestore.repository.d.ts.map +1 -0
- package/infra/firebase/firestore/repositories/catalog/product-variant-firestore.repository.d.ts +18 -18
- package/infra/firebase/firestore/repositories/catalog/product-variant-firestore.repository.d.ts.map +1 -0
- package/infra/firebase/firestore/repositories/catalog/subscription-product-firestore.repository.d.ts +16 -16
- package/infra/firebase/firestore/repositories/catalog/subscription-product-firestore.repository.d.ts.map +1 -0
- package/infra/firebase/firestore/repositories/index.d.ts.map +1 -0
- package/infra/firebase/firestore/repositories/shop-settings/home-firestore.repository.d.ts +14 -14
- package/infra/firebase/firestore/repositories/shop-settings/home-firestore.repository.d.ts.map +1 -0
- package/infra/firebase/firestore/repositories/shop-settings/index.d.ts.map +1 -0
- package/infra/firebase/firestore/repositories/shop-settings/shop-menu-firestore.repository.d.ts +16 -16
- package/infra/firebase/firestore/repositories/shop-settings/shop-menu-firestore.repository.d.ts.map +1 -0
- package/infra/firebase/firestore/repositories/shopping/buy-2-win-firestore.repository.d.ts +16 -16
- package/infra/firebase/firestore/repositories/shopping/buy-2-win-firestore.repository.d.ts.map +1 -0
- package/infra/firebase/firestore/repositories/shopping/checkout-firestore.repository.d.ts +16 -16
- package/infra/firebase/firestore/repositories/shopping/checkout-firestore.repository.d.ts.map +1 -0
- package/infra/firebase/firestore/repositories/shopping/checkout-subscription-firestore.repository.d.ts +16 -16
- package/infra/firebase/firestore/repositories/shopping/checkout-subscription-firestore.repository.d.ts.map +1 -0
- package/infra/firebase/firestore/repositories/shopping/coupon-firestore.repository.d.ts +14 -14
- package/infra/firebase/firestore/repositories/shopping/coupon-firestore.repository.d.ts.map +1 -0
- package/infra/firebase/firestore/repositories/shopping/index.d.ts.map +1 -0
- package/infra/firebase/firestore/repositories/shopping/legacy-order-firestore.repository.d.ts +3 -3
- package/infra/firebase/firestore/repositories/shopping/legacy-order-firestore.repository.d.ts.map +1 -0
- package/infra/firebase/firestore/repositories/shopping/order-firestore.repository.d.ts +16 -16
- package/infra/firebase/firestore/repositories/shopping/order-firestore.repository.d.ts.map +1 -0
- package/infra/firebase/firestore/repositories/shopping/payment-firestore.repository.d.ts +16 -16
- package/infra/firebase/firestore/repositories/shopping/payment-firestore.repository.d.ts.map +1 -0
- package/infra/firebase/firestore/repositories/shopping/subscription-plan-firestore.repository.d.ts +16 -16
- package/infra/firebase/firestore/repositories/shopping/subscription-plan-firestore.repository.d.ts.map +1 -0
- package/infra/firebase/firestore/repositories/users/index.d.ts.map +1 -0
- package/infra/firebase/firestore/repositories/users/lead-firestore.repository.d.ts +16 -16
- package/infra/firebase/firestore/repositories/users/lead-firestore.repository.d.ts.map +1 -0
- package/infra/firebase/firestore/repositories/users/subscription-edition-firestore.repository.d.ts +18 -18
- package/infra/firebase/firestore/repositories/users/subscription-edition-firestore.repository.d.ts.map +1 -0
- package/infra/firebase/firestore/repositories/users/subscription-firestore.repository.d.ts +16 -16
- package/infra/firebase/firestore/repositories/users/subscription-payment-firestore.repository.d.ts +18 -18
- package/infra/firebase/firestore/repositories/users/subscription-payment-firestore.repository.d.ts.map +1 -0
- package/infra/firebase/firestore/repositories/users/user-address-firestore.repository.d.ts +18 -18
- package/infra/firebase/firestore/repositories/users/user-address-firestore.repository.d.ts.map +1 -0
- package/infra/firebase/firestore/repositories/users/user-beauty-profile-firestore.repository.d.ts +18 -18
- package/infra/firebase/firestore/repositories/users/user-beauty-profile-firestore.repository.d.ts.map +1 -0
- package/infra/firebase/firestore/repositories/users/user-firestore.repository.d.ts +14 -14
- package/infra/firebase/firestore/repositories/users/user-firestore.repository.d.ts.map +1 -0
- package/infra/firebase/firestore/repositories/users/user-payment-method-firestore.repository.d.ts +18 -18
- package/infra/firebase/firestore/repositories/users/user-payment-method-firestore.repository.d.ts.map +1 -0
- package/infra/firebase/firestore/repositories/users/user-search-firestore.repository.d.ts +16 -16
- package/infra/firebase/firestore/repositories/users/user-search-firestore.repository.d.ts.map +1 -0
- package/infra/firebase/firestore/types/firestore.helpers.type.d.ts +1 -1
- package/infra/firebase/firestore/types/firestore.repository.type.d.ts +2 -2
- package/infra/firebase/index.d.ts.map +1 -0
- package/infra/index.d.ts.map +1 -0
- package/infrab4a-connect.d.ts.map +1 -0
- package/package.json +2 -2
- package/utils/index.d.ts +1 -1
- package/domain/shopping/models/coupons/financial-coupon.d.ts +0 -9
- package/esm2015/domain/shopping/models/coupons/financial-coupon.js +0 -28
|
@@ -2,11 +2,11 @@ import 'reflect-metadata';
|
|
|
2
2
|
import { plainToClass, classToPlain, Expose, Type } from 'class-transformer';
|
|
3
3
|
import { __decorate, __metadata, __awaiter } from 'tslib';
|
|
4
4
|
export { add, sub } from 'date-fns';
|
|
5
|
-
import
|
|
6
|
-
|
|
5
|
+
import { isNil, isNumber, isString, isDate, set, isObject, isEmpty, chunk } from 'lodash';
|
|
6
|
+
export { chunk, get, isDate, isEmpty, isNil, isNumber, isObject, isString, pick, set } from 'lodash';
|
|
7
7
|
import axios from 'axios';
|
|
8
|
-
import
|
|
9
|
-
import
|
|
8
|
+
import firebase from 'firebase';
|
|
9
|
+
import firebase$1 from 'firebase/app';
|
|
10
10
|
|
|
11
11
|
class BaseModel {
|
|
12
12
|
constructor(args) {
|
|
@@ -450,6 +450,7 @@ var CheckoutTypes;
|
|
|
450
450
|
(function (CheckoutTypes) {
|
|
451
451
|
CheckoutTypes[CheckoutTypes["ECOMMERCE"] = 1] = "ECOMMERCE";
|
|
452
452
|
CheckoutTypes[CheckoutTypes["SUBSCRIPTION"] = 2] = "SUBSCRIPTION";
|
|
453
|
+
CheckoutTypes[CheckoutTypes["ALL"] = 3] = "ALL";
|
|
453
454
|
})(CheckoutTypes || (CheckoutTypes = {}));
|
|
454
455
|
|
|
455
456
|
class Base {
|
|
@@ -458,14 +459,14 @@ class Base {
|
|
|
458
459
|
}
|
|
459
460
|
}
|
|
460
461
|
|
|
461
|
-
const { chunk, get, isDate, isEmpty, isNil, isNumber, isObject, isString, pick, set } = lodash;
|
|
462
|
-
|
|
463
462
|
var CouponTypes;
|
|
464
463
|
(function (CouponTypes) {
|
|
465
|
-
CouponTypes[CouponTypes["
|
|
466
|
-
CouponTypes[CouponTypes["
|
|
467
|
-
|
|
468
|
-
|
|
464
|
+
CouponTypes[CouponTypes["ABSOLUTE"] = 1] = "ABSOLUTE";
|
|
465
|
+
CouponTypes[CouponTypes["PERCENTAGE"] = 2] = "PERCENTAGE";
|
|
466
|
+
// FINANCIAL = 1,
|
|
467
|
+
// PRODUCT,
|
|
468
|
+
// GIFTCARD,
|
|
469
|
+
// VOUCHER,
|
|
469
470
|
})(CouponTypes || (CouponTypes = {}));
|
|
470
471
|
|
|
471
472
|
var CouponSubtypes;
|
|
@@ -481,6 +482,7 @@ var Exclusivities;
|
|
|
481
482
|
Exclusivities[Exclusivities["COLLABORATORS"] = 3] = "COLLABORATORS";
|
|
482
483
|
})(Exclusivities || (Exclusivities = {}));
|
|
483
484
|
|
|
485
|
+
const COUPON_EXPIRATION = 60 * 60 * 24 * 30;
|
|
484
486
|
class Coupon extends BaseModel {
|
|
485
487
|
get isInfluencer() {
|
|
486
488
|
return !isNil(this.influencerEmail);
|
|
@@ -488,6 +490,20 @@ class Coupon extends BaseModel {
|
|
|
488
490
|
identifierFields() {
|
|
489
491
|
return ['id'];
|
|
490
492
|
}
|
|
493
|
+
static createCoupon(userId) {
|
|
494
|
+
return this.toInstance({
|
|
495
|
+
nickname: `${Date.now()}`,
|
|
496
|
+
type: CouponTypes.ABSOLUTE,
|
|
497
|
+
checkoutType: CheckoutTypes.ECOMMERCE,
|
|
498
|
+
discount: 30,
|
|
499
|
+
user: userId,
|
|
500
|
+
useLimit: 1,
|
|
501
|
+
useLimitPerUser: 1,
|
|
502
|
+
createdAt: new Date(Date.now()),
|
|
503
|
+
beginAt: new Date(Date.now()),
|
|
504
|
+
expiresIn: new Date(Date.now() + COUPON_EXPIRATION),
|
|
505
|
+
});
|
|
506
|
+
}
|
|
491
507
|
}
|
|
492
508
|
__decorate([
|
|
493
509
|
Expose({ name: 'checkout_type' }),
|
|
@@ -703,6 +719,7 @@ var Shops;
|
|
|
703
719
|
Shops["MENSMARKET"] = "mensmarket";
|
|
704
720
|
Shops["GLAMSHOP"] = "Glamshop";
|
|
705
721
|
Shops["GLAMPOINTS"] = "Glampoints";
|
|
722
|
+
Shops["ALL"] = "ALL";
|
|
706
723
|
})(Shops || (Shops = {}));
|
|
707
724
|
|
|
708
725
|
class Category extends BaseModel {
|
|
@@ -727,30 +744,6 @@ class Variant extends BaseModel {
|
|
|
727
744
|
}
|
|
728
745
|
}
|
|
729
746
|
|
|
730
|
-
const COUPON_EXPIRATION = 60 * 60 * 24 * 30;
|
|
731
|
-
class FinancialCoupon extends Coupon {
|
|
732
|
-
constructor() {
|
|
733
|
-
super(...arguments);
|
|
734
|
-
this.type = CouponTypes.FINANCIAL;
|
|
735
|
-
}
|
|
736
|
-
static isFinancialCoupon(coupon) {
|
|
737
|
-
return coupon.type === CouponTypes.FINANCIAL && !!coupon.subtype;
|
|
738
|
-
}
|
|
739
|
-
static createCoupon(userId) {
|
|
740
|
-
return this.toInstance({
|
|
741
|
-
name: Md5.hashStr(`${userId}_${Date.now}`).toString(),
|
|
742
|
-
nickname: `${Date.now()}`,
|
|
743
|
-
type: CouponTypes.FINANCIAL,
|
|
744
|
-
subtype: CouponSubtypes.PERCENTAGE,
|
|
745
|
-
checkoutType: CheckoutTypes.ECOMMERCE,
|
|
746
|
-
discount: 30,
|
|
747
|
-
user: userId,
|
|
748
|
-
createdAt: new Date(Date.now()),
|
|
749
|
-
expiresIn: new Date(Date.now() + COUPON_EXPIRATION),
|
|
750
|
-
});
|
|
751
|
-
}
|
|
752
|
-
}
|
|
753
|
-
|
|
754
747
|
var OrderStatus;
|
|
755
748
|
(function (OrderStatus) {
|
|
756
749
|
OrderStatus["AGUARDANDO_PAGAMENTO"] = "Aguardando pagamento";
|
|
@@ -1051,7 +1044,7 @@ const withFirestore = (MixinBase) => {
|
|
|
1051
1044
|
super(args);
|
|
1052
1045
|
}
|
|
1053
1046
|
collection(path) {
|
|
1054
|
-
return
|
|
1047
|
+
return this.firestore.collection(path || this.collectionName).withConverter(this.buildModelInstance());
|
|
1055
1048
|
}
|
|
1056
1049
|
buildModelInstance() {
|
|
1057
1050
|
return {
|
|
@@ -1059,7 +1052,7 @@ const withFirestore = (MixinBase) => {
|
|
|
1059
1052
|
fromFirestore: (snap) => {
|
|
1060
1053
|
const data = snap.data();
|
|
1061
1054
|
Object.keys(data).forEach((key) => {
|
|
1062
|
-
if (data[key] instanceof Timestamp) {
|
|
1055
|
+
if (data[key] instanceof firebase.firestore.Timestamp) {
|
|
1063
1056
|
data[key] = data[key].toDate();
|
|
1064
1057
|
}
|
|
1065
1058
|
});
|
|
@@ -1090,8 +1083,10 @@ const withGetFirestore = (MixinBase) => {
|
|
|
1090
1083
|
return class GetFirestore extends MixinBase {
|
|
1091
1084
|
get(identifiers) {
|
|
1092
1085
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1093
|
-
const
|
|
1094
|
-
|
|
1086
|
+
const doc = yield this.collection(this.buildCollectionPathForGet(identifiers))
|
|
1087
|
+
.doc(Object.values(identifiers).shift().toString())
|
|
1088
|
+
.get();
|
|
1089
|
+
const data = doc.data();
|
|
1095
1090
|
if (isNil(data))
|
|
1096
1091
|
throw new NotFoundError(`Document ${JSON.stringify(identifiers)} not found`);
|
|
1097
1092
|
return data;
|
|
@@ -1116,13 +1111,10 @@ const withFindFirestore = (MixinBase) => {
|
|
|
1116
1111
|
return class FindFirestore extends MixinBase {
|
|
1117
1112
|
constructor() {
|
|
1118
1113
|
super(...arguments);
|
|
1119
|
-
this.makeFirestoreWhere = (filter) => Object.keys(filter).reduce((
|
|
1120
|
-
|
|
1121
|
-
...this.buildWhereSentence(fieldName, filter[fieldName]),
|
|
1122
|
-
], []);
|
|
1123
|
-
this.buildWhereSentence = (fieldName, options) => {
|
|
1114
|
+
this.makeFirestoreWhere = (queryReference, filter) => Object.keys(filter).reduce((query, fieldName) => this.buildWhereSentence(query, fieldName, filter[fieldName]), queryReference);
|
|
1115
|
+
this.buildWhereSentence = (queryReference, fieldName, options) => {
|
|
1124
1116
|
if (this.isSubCollection(this) && fieldName === this.parentIdField)
|
|
1125
|
-
|
|
1117
|
+
return queryReference;
|
|
1126
1118
|
const value = (options === null || options === void 0 ? void 0 : options.value) || options;
|
|
1127
1119
|
const object = {};
|
|
1128
1120
|
set(object, fieldName, value);
|
|
@@ -1132,33 +1124,30 @@ const withFindFirestore = (MixinBase) => {
|
|
|
1132
1124
|
: Object.keys(plainInstance).find((key) => plainInstance[key]);
|
|
1133
1125
|
if ((options === null || options === void 0 ? void 0 : options.operator) === Where.LIKE) {
|
|
1134
1126
|
if (Array.isArray(options === null || options === void 0 ? void 0 : options.value))
|
|
1135
|
-
return
|
|
1136
|
-
|
|
1127
|
+
return queryReference.where(firestoreFieldName, 'array-contains-any', options.value);
|
|
1128
|
+
queryReference = queryReference.where(firestoreFieldName, '>=', options.value);
|
|
1129
|
+
queryReference = queryReference.where(firestoreFieldName, '<=', `${options.value}~`);
|
|
1130
|
+
return queryReference;
|
|
1137
1131
|
}
|
|
1138
1132
|
if ((options === null || options === void 0 ? void 0 : options.operator) === Where.IN && Array.isArray(options === null || options === void 0 ? void 0 : options.value))
|
|
1139
|
-
return
|
|
1133
|
+
return queryReference.where(firestoreFieldName, 'array-contains', options.value);
|
|
1140
1134
|
if (isObject(options) && isNil(options === null || options === void 0 ? void 0 : options.operator) && isNil(options === null || options === void 0 ? void 0 : options.value)) {
|
|
1141
|
-
return Object.keys(options).reduce((
|
|
1135
|
+
return Object.keys(options).reduce((queryReferenceWithWhere, key) => this.buildWhereSentence(queryReferenceWithWhere, `${fieldName}.${key}`, options[key]), queryReference);
|
|
1142
1136
|
}
|
|
1143
|
-
return
|
|
1137
|
+
return queryReference.where(firestoreFieldName, (options === null || options === void 0 ? void 0 : options.operator) || '==', (options === null || options === void 0 ? void 0 : options.value) || options);
|
|
1144
1138
|
};
|
|
1145
1139
|
}
|
|
1146
|
-
find(filters,
|
|
1140
|
+
find(filters, limits, orderBy) {
|
|
1147
1141
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
...Object.keys(sort).map((fieldName) => orderBy(fieldName, sort[fieldName])),
|
|
1154
|
-
], [])) || [];
|
|
1155
|
-
const limits = yield this.defineLimits(filters, limitList);
|
|
1156
|
-
const queryArgumments = [...queries, ...ordination, ...limits];
|
|
1157
|
-
const docs = yield getDocs(query(collection, ...queryArgumments));
|
|
1142
|
+
let query = this.collection(this.buildCollectionPathForFind(filters));
|
|
1143
|
+
filters === null || filters === void 0 ? void 0 : filters.forEach((filterer) => (query = this.makeFirestoreWhere(query, filterer)));
|
|
1144
|
+
orderBy === null || orderBy === void 0 ? void 0 : orderBy.forEach((orderer) => Object.keys(orderer).forEach((fieldName) => (query = query.orderBy(fieldName, orderer[fieldName]))));
|
|
1145
|
+
query = yield this.defineLimits(query, filters, limits);
|
|
1146
|
+
const docs = yield query.get();
|
|
1158
1147
|
const data = docs.docs.map((doc) => doc.data());
|
|
1159
1148
|
return {
|
|
1160
1149
|
data,
|
|
1161
|
-
count: this.calculateCount(data,
|
|
1150
|
+
count: this.calculateCount(data, limits),
|
|
1162
1151
|
};
|
|
1163
1152
|
});
|
|
1164
1153
|
}
|
|
@@ -1170,18 +1159,19 @@ const withFindFirestore = (MixinBase) => {
|
|
|
1170
1159
|
const parentId = getValueFromFilter((_a = filters.find((groupFilter) => Boolean(getValueFromFilter(groupFilter[parentIdField])))) === null || _a === void 0 ? void 0 : _a[parentIdField]);
|
|
1171
1160
|
return `${this.parentRepository.collectionName}/${parentId}/${this.collectionName}`;
|
|
1172
1161
|
}
|
|
1173
|
-
defineLimits(filters, limits) {
|
|
1162
|
+
defineLimits(query, filters, limits) {
|
|
1174
1163
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1175
|
-
const queries = [];
|
|
1176
1164
|
if (limits === null || limits === void 0 ? void 0 : limits.offset) {
|
|
1177
1165
|
if (limits.offset instanceof this.model)
|
|
1178
|
-
|
|
1166
|
+
query = query.startAfter(yield this.collection(this.buildCollectionPathForFind(filters))
|
|
1167
|
+
.doc(limits.offset[limits.offset.identifierFields().shift()])
|
|
1168
|
+
.get());
|
|
1179
1169
|
else if (isNumber(limits.offset) || isString(limits.offset))
|
|
1180
|
-
|
|
1170
|
+
query = query.startAt(limits.offset);
|
|
1181
1171
|
}
|
|
1182
1172
|
if (limits === null || limits === void 0 ? void 0 : limits.limit)
|
|
1183
|
-
|
|
1184
|
-
return
|
|
1173
|
+
query = query.limit(limits.limit);
|
|
1174
|
+
return query;
|
|
1185
1175
|
});
|
|
1186
1176
|
}
|
|
1187
1177
|
calculateCount(data, limits) {
|
|
@@ -1199,7 +1189,7 @@ const withCreateFirestore = (MixinBase) => {
|
|
|
1199
1189
|
create(data) {
|
|
1200
1190
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1201
1191
|
const docRef = yield this.save(this.model.toInstance(data));
|
|
1202
|
-
const doc = yield
|
|
1192
|
+
const doc = yield docRef.get();
|
|
1203
1193
|
return doc.data();
|
|
1204
1194
|
});
|
|
1205
1195
|
}
|
|
@@ -1208,11 +1198,10 @@ const withCreateFirestore = (MixinBase) => {
|
|
|
1208
1198
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1209
1199
|
const id = (_a = data[data.identifierFields().shift()]) === null || _a === void 0 ? void 0 : _a.toString();
|
|
1210
1200
|
const collectionPath = this.buildCollectionPathForAdd(data);
|
|
1211
|
-
const collection = this.collection(collectionPath);
|
|
1212
1201
|
if (isEmpty(id))
|
|
1213
|
-
return
|
|
1214
|
-
const docRef = doc(
|
|
1215
|
-
yield
|
|
1202
|
+
return this.collection(collectionPath).add(data);
|
|
1203
|
+
const docRef = this.collection(collectionPath).doc(id);
|
|
1204
|
+
yield docRef.set(data);
|
|
1216
1205
|
return docRef;
|
|
1217
1206
|
});
|
|
1218
1207
|
}
|
|
@@ -1227,15 +1216,16 @@ const withCreateFirestore = (MixinBase) => {
|
|
|
1227
1216
|
const withUpdateFirestore = (MixinBase) => {
|
|
1228
1217
|
const getValueFromParams = (params, field) => { var _a; return (isNil((_a = params[field]) === null || _a === void 0 ? void 0 : _a.value) ? params[field] : params[field].value) || null; };
|
|
1229
1218
|
const getValueByAction = (options) => {
|
|
1219
|
+
const fieldValues = firebase.firestore.FieldValue;
|
|
1230
1220
|
if (isNil(options.action))
|
|
1231
1221
|
return options;
|
|
1232
1222
|
if (options.action === UpdateOptionActions.REMOVE_FIELD)
|
|
1233
|
-
return
|
|
1223
|
+
return fieldValues.delete();
|
|
1234
1224
|
if (Array.isArray(options.value)) {
|
|
1235
1225
|
if (options.action === UpdateOptionActions.MERGE)
|
|
1236
|
-
return arrayUnion(...options.value);
|
|
1226
|
+
return fieldValues.arrayUnion(...options.value);
|
|
1237
1227
|
if (options.action === UpdateOptionActions.REMOVE)
|
|
1238
|
-
return arrayRemove(...options.value);
|
|
1228
|
+
return fieldValues.arrayRemove(...options.value);
|
|
1239
1229
|
}
|
|
1240
1230
|
return options.value;
|
|
1241
1231
|
};
|
|
@@ -1244,10 +1234,10 @@ const withUpdateFirestore = (MixinBase) => {
|
|
|
1244
1234
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1245
1235
|
const model = new this.model();
|
|
1246
1236
|
const keyField = model.identifierFields().shift();
|
|
1247
|
-
const docRef =
|
|
1248
|
-
yield
|
|
1249
|
-
const
|
|
1250
|
-
return
|
|
1237
|
+
const docRef = this.collection(this.buildCollectionPathForUpdate(data)).doc(getValueFromParams(data, keyField).toString());
|
|
1238
|
+
yield docRef.set(this.paramsToPlain(data), { merge: true });
|
|
1239
|
+
const doc = yield docRef.get();
|
|
1240
|
+
return doc.data();
|
|
1251
1241
|
});
|
|
1252
1242
|
}
|
|
1253
1243
|
buildCollectionPathForUpdate(identifiers) {
|
|
@@ -1268,7 +1258,9 @@ const withDeleteFirestore = (MixinBase) => {
|
|
|
1268
1258
|
return class DeleteFirestore extends MixinBase {
|
|
1269
1259
|
delete(identifiers) {
|
|
1270
1260
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1271
|
-
yield
|
|
1261
|
+
yield this.collection(this.buildCollectionPathForRemove(identifiers))
|
|
1262
|
+
.doc(Object.values(identifiers).shift().toString())
|
|
1263
|
+
.delete();
|
|
1272
1264
|
});
|
|
1273
1265
|
}
|
|
1274
1266
|
buildCollectionPathForRemove(identifiers) {
|
|
@@ -1357,13 +1349,22 @@ class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestor
|
|
|
1357
1349
|
}
|
|
1358
1350
|
getBeautyProfile(userId) {
|
|
1359
1351
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1360
|
-
const beautyProfile = yield
|
|
1352
|
+
const beautyProfile = yield this.collection()
|
|
1353
|
+
.doc(userId)
|
|
1354
|
+
.collection('CX')
|
|
1355
|
+
.withConverter(this.buildBeautyProfileModelInstance())
|
|
1356
|
+
.doc('beautyProfile')
|
|
1357
|
+
.get();
|
|
1361
1358
|
return beautyProfile.data();
|
|
1362
1359
|
});
|
|
1363
1360
|
}
|
|
1364
1361
|
checkIfIsSubscriber(userId) {
|
|
1365
1362
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1366
|
-
const docs = yield
|
|
1363
|
+
const docs = yield this.firestore
|
|
1364
|
+
.collection('subscription')
|
|
1365
|
+
.where('user.id', '==', userId)
|
|
1366
|
+
.where('status', '==', 'active')
|
|
1367
|
+
.get();
|
|
1367
1368
|
return !!docs && !!docs.size;
|
|
1368
1369
|
});
|
|
1369
1370
|
}
|
|
@@ -1440,26 +1441,33 @@ class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestor
|
|
|
1440
1441
|
}
|
|
1441
1442
|
|
|
1442
1443
|
class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1443
|
-
constructor(firestore
|
|
1444
|
+
constructor(firestore) {
|
|
1444
1445
|
super();
|
|
1445
1446
|
this.firestore = firestore;
|
|
1446
|
-
this.productsIndex = productsIndex;
|
|
1447
1447
|
this.collectionName = 'categories';
|
|
1448
1448
|
this.model = Category;
|
|
1449
1449
|
}
|
|
1450
1450
|
getCategoryBySlug(slug, shop) {
|
|
1451
|
-
return
|
|
1452
|
-
|
|
1453
|
-
|
|
1451
|
+
return this.collection(this.collectionName)
|
|
1452
|
+
.where('slug', '==', slug)
|
|
1453
|
+
.where('shop', '==', shop)
|
|
1454
|
+
.where('published', '==', true)
|
|
1455
|
+
.get()
|
|
1456
|
+
.then((snap) => {
|
|
1457
|
+
if (snap.size > 1)
|
|
1454
1458
|
throw new DuplicatedResultsError('Query returned duplicated values');
|
|
1455
|
-
if (
|
|
1459
|
+
if (snap.empty)
|
|
1456
1460
|
throw new NotFoundError(`Document with slug ${slug} not found`);
|
|
1457
|
-
return
|
|
1458
|
-
})
|
|
1461
|
+
return snap.docs[0].data();
|
|
1462
|
+
})
|
|
1463
|
+
.catch((error) => error);
|
|
1459
1464
|
}
|
|
1460
1465
|
getCategoriesForHome(categoryIds, limit = 4) {
|
|
1461
1466
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1462
|
-
const categorySnap = yield
|
|
1467
|
+
const categorySnap = yield this.collection(this.collectionName)
|
|
1468
|
+
.where('id', 'in', categoryIds.filter(Boolean))
|
|
1469
|
+
.where('published', '==', true)
|
|
1470
|
+
.get();
|
|
1463
1471
|
if (categorySnap.empty)
|
|
1464
1472
|
throw new NotFoundError('Categories not found');
|
|
1465
1473
|
const categories = categorySnap.docs.map((doc) => doc.data());
|
|
@@ -1476,11 +1484,23 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
1476
1484
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1477
1485
|
if (!category.products)
|
|
1478
1486
|
throw new RequiredArgumentError(['Category products is empty']);
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1487
|
+
const chunks = chunk(category.products, 10);
|
|
1488
|
+
const products = [];
|
|
1489
|
+
const publishedField = category.shop === Shops.GLAMSHOP ? 'publishedGlam' : 'published';
|
|
1490
|
+
for (const productIds of chunks) {
|
|
1491
|
+
if ((options === null || options === void 0 ? void 0 : options.limit) && products.length >= (options === null || options === void 0 ? void 0 : options.limit))
|
|
1492
|
+
break;
|
|
1493
|
+
let query = yield this.collection('products').where(publishedField, '==', true).where('id', 'in', productIds);
|
|
1494
|
+
if (options === null || options === void 0 ? void 0 : options.hasStock)
|
|
1495
|
+
query = query.where('stock.quantity', '>', 0);
|
|
1496
|
+
if (options === null || options === void 0 ? void 0 : options.limit)
|
|
1497
|
+
query = query.limit(options === null || options === void 0 ? void 0 : options.limit);
|
|
1498
|
+
const productSnap = yield query.get();
|
|
1499
|
+
if (productSnap.empty)
|
|
1500
|
+
continue;
|
|
1501
|
+
products.push(...productSnap.docs.map((doc) => doc.data()));
|
|
1502
|
+
}
|
|
1503
|
+
return products;
|
|
1484
1504
|
});
|
|
1485
1505
|
}
|
|
1486
1506
|
}
|
|
@@ -1636,9 +1656,9 @@ class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestor
|
|
|
1636
1656
|
home.data.data.featuredProducts = home.data.data.featuredProducts.map(this.plainToHomeCategoryGroup);
|
|
1637
1657
|
home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.plainToHomeCategoryGroup);
|
|
1638
1658
|
home.data.createdAt =
|
|
1639
|
-
home.data.createdAt instanceof Timestamp ? home.data.createdAt.toDate() : home.data.createdAt;
|
|
1659
|
+
home.data.createdAt instanceof firebase.firestore.Timestamp ? home.data.createdAt.toDate() : home.data.createdAt;
|
|
1640
1660
|
home.data.expiresAt =
|
|
1641
|
-
home.data.expiresAt instanceof Timestamp ? home.data.expiresAt.toDate() : home.data.expiresAt;
|
|
1661
|
+
home.data.expiresAt instanceof firebase.firestore.Timestamp ? home.data.expiresAt.toDate() : home.data.expiresAt;
|
|
1642
1662
|
}
|
|
1643
1663
|
return home;
|
|
1644
1664
|
};
|
|
@@ -1679,7 +1699,7 @@ class AuthenticationFirebaseAuthService {
|
|
|
1679
1699
|
}
|
|
1680
1700
|
signInWithEmailAndPassword(data) {
|
|
1681
1701
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1682
|
-
const credentials = yield
|
|
1702
|
+
const credentials = yield this.firebaseAuth.signInWithEmailAndPassword(data.email, data.password);
|
|
1683
1703
|
const user = credentials.user;
|
|
1684
1704
|
return {
|
|
1685
1705
|
id: user.uid,
|
|
@@ -1692,7 +1712,7 @@ class AuthenticationFirebaseAuthService {
|
|
|
1692
1712
|
}
|
|
1693
1713
|
signInWithGoogle() {
|
|
1694
1714
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1695
|
-
const credentials = yield
|
|
1715
|
+
const credentials = yield this.firebaseAuth.signInWithPopup(new firebase$1.auth.GoogleAuthProvider());
|
|
1696
1716
|
const user = credentials.user;
|
|
1697
1717
|
return {
|
|
1698
1718
|
id: user.uid,
|
|
@@ -1710,7 +1730,7 @@ class AuthenticationFirebaseAuthService {
|
|
|
1710
1730
|
}
|
|
1711
1731
|
signInAnonymously() {
|
|
1712
1732
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1713
|
-
const auth = yield
|
|
1733
|
+
const auth = yield this.firebaseAuth.signInAnonymously();
|
|
1714
1734
|
const user = auth.user;
|
|
1715
1735
|
user.id = auth.user.uid;
|
|
1716
1736
|
return user;
|
|
@@ -1718,7 +1738,7 @@ class AuthenticationFirebaseAuthService {
|
|
|
1718
1738
|
}
|
|
1719
1739
|
sendPasswordResetEmail(email) {
|
|
1720
1740
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1721
|
-
return
|
|
1741
|
+
return this.firebaseAuth.sendPasswordResetEmail(email);
|
|
1722
1742
|
});
|
|
1723
1743
|
}
|
|
1724
1744
|
}
|
|
@@ -1730,9 +1750,9 @@ class RegisterFirebaseAuthService {
|
|
|
1730
1750
|
register(params) {
|
|
1731
1751
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1732
1752
|
try {
|
|
1733
|
-
const auth = yield
|
|
1753
|
+
const auth = yield this.firebaseAuth.createUserWithEmailAndPassword(params.email, params.password);
|
|
1734
1754
|
const user = auth.user;
|
|
1735
|
-
|
|
1755
|
+
user.sendEmailVerification();
|
|
1736
1756
|
user.id = auth.user.uid;
|
|
1737
1757
|
return user;
|
|
1738
1758
|
}
|
|
@@ -1751,5 +1771,5 @@ class RegisterFirebaseAuthService {
|
|
|
1751
1771
|
* Generated bundle index. Do not edit.
|
|
1752
1772
|
*/
|
|
1753
1773
|
|
|
1754
|
-
export { AccessoryImportances, Address, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository, Category, CategoryFirestoreRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, Coupon, CouponFirestoreRepository, CouponSubtypes, CouponTypes, DuplicatedResultsError, Edition, EditionStatus, Exclusivities, FaceSkinOilinesses, FaceSkinProblems, FaceSkinTones, FamilyIncomes, FilterType,
|
|
1774
|
+
export { AccessoryImportances, Address, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository, Category, CategoryFirestoreRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, Coupon, CouponFirestoreRepository, CouponSubtypes, CouponTypes, DuplicatedResultsError, Edition, EditionStatus, Exclusivities, FaceSkinOilinesses, FaceSkinProblems, FaceSkinTones, FamilyIncomes, FilterType, FragranceImportances, HairColors, HairProblems, HairStrands, HairTypes, Home, HomeFirestoreRepository, InvalidArgumentError, Lead, LeadFirestoreRepository, LegacyOrderFirestoreRepository, LineItem, NotFoundError, OfficePosition, Order, OrderFirestoreRepository, OrderStatus, Payment, PaymentFirestoreRepository, PaymentType, Product, ProductFirestoreRepository, ProductSpents, ProductVariantFirestoreRepository, ProductsIndex, QuestionsFilters, RecoveryPassword, Register, RegisterFirebaseAuthService, RequiredArgumentError, ShippingMethod, ShopMenu, ShopMenuFirestoreRepository, Shops, SignInMethods, SignOut, Status, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, UnauthorizedError, UpdateOptionActions, User, UserAddress, UserAddressFirestoreRepository, UserAlreadyRegisteredError, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserPaymentMethod, UserPaymentMethodFirestoreRepository, UserSearchFirestoreRepository, UserType, Variant, WeakPasswordError, Where, withCreateFirestore, withCrudFirestore, withDeleteFirestore, withFindFirestore, withFirestore, withGetFirestore, withHelpers, withSubCollection, withUpdateFirestore };
|
|
1755
1775
|
//# sourceMappingURL=infrab4a-connect.js.map
|