@infrab4a/connect 0.17.0-beta.2 → 0.17.0-beta.3
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 +5 -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/infra/firebase/auth/authentication-firebase-auth.service.d.ts +2 -2
- package/infra/firebase/auth/register-firebase-auth.service.d.ts +5 -4
- package/infra/firebase/auth/types/firebase-user-with-id.type.d.ts +1 -2
- 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/product-firestore.repository.d.ts +16 -16
- package/infra/firebase/firestore/repositories/catalog/product-variant-firestore.repository.d.ts +18 -18
- package/infra/firebase/firestore/repositories/catalog/subscription-product-firestore.repository.d.ts +16 -16
- package/infra/firebase/firestore/repositories/shop-settings/home-firestore.repository.d.ts +14 -14
- package/infra/firebase/firestore/repositories/shop-settings/shop-menu-firestore.repository.d.ts +16 -16
- package/infra/firebase/firestore/repositories/shopping/buy-2-win-firestore.repository.d.ts +16 -16
- package/infra/firebase/firestore/repositories/shopping/checkout-firestore.repository.d.ts +16 -16
- package/infra/firebase/firestore/repositories/shopping/checkout-subscription-firestore.repository.d.ts +16 -16
- package/infra/firebase/firestore/repositories/shopping/coupon-firestore.repository.d.ts +14 -14
- package/infra/firebase/firestore/repositories/shopping/legacy-order-firestore.repository.d.ts +3 -3
- package/infra/firebase/firestore/repositories/shopping/order-firestore.repository.d.ts +16 -16
- package/infra/firebase/firestore/repositories/shopping/payment-firestore.repository.d.ts +16 -16
- package/infra/firebase/firestore/repositories/shopping/subscription-plan-firestore.repository.d.ts +16 -16
- package/infra/firebase/firestore/repositories/users/lead-firestore.repository.d.ts +16 -16
- package/infra/firebase/firestore/repositories/users/subscription-edition-firestore.repository.d.ts +18 -18
- 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/user-address-firestore.repository.d.ts +18 -18
- package/infra/firebase/firestore/repositories/users/user-beauty-profile-firestore.repository.d.ts +18 -18
- package/infra/firebase/firestore/repositories/users/user-firestore.repository.d.ts +14 -14
- package/infra/firebase/firestore/repositories/users/user-payment-method-firestore.repository.d.ts +18 -18
- package/infra/firebase/firestore/repositories/users/user-search-firestore.repository.d.ts +16 -16
- 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/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
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('reflect-metadata'), require('class-transformer'), require('date-fns'), require('lodash'), require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define('@infrab4a/connect', ['exports', 'reflect-metadata', 'class-transformer', 'date-fns', 'lodash', '
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.infrab4a = global.infrab4a || {}, global.infrab4a.connect = {}), null, global["class-transformer"], global["date-fns"], global.lodash, global.
|
|
5
|
-
})(this, (function (exports, reflectMetadata, classTransformer, dateFns, lodash,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('reflect-metadata'), require('class-transformer'), require('date-fns'), require('lodash'), require('axios'), require('firebase'), require('firebase/app')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define('@infrab4a/connect', ['exports', 'reflect-metadata', 'class-transformer', 'date-fns', 'lodash', 'axios', 'firebase', 'firebase/app'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.infrab4a = global.infrab4a || {}, global.infrab4a.connect = {}), null, global["class-transformer"], global["date-fns"], global.lodash, global.axios, global.firebase, global.firebase$1));
|
|
5
|
+
})(this, (function (exports, reflectMetadata, classTransformer, dateFns, lodash, axios, firebase, firebase$1) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
9
|
-
var lodash__default = /*#__PURE__*/_interopDefaultLegacy(lodash);
|
|
10
9
|
var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
|
|
10
|
+
var firebase__default = /*#__PURE__*/_interopDefaultLegacy(firebase);
|
|
11
|
+
var firebase__default$1 = /*#__PURE__*/_interopDefaultLegacy(firebase$1);
|
|
11
12
|
|
|
12
13
|
var BaseModel = /** @class */ (function () {
|
|
13
14
|
function BaseModel(args) {
|
|
@@ -786,6 +787,13 @@
|
|
|
786
787
|
return Address;
|
|
787
788
|
}(BaseModel));
|
|
788
789
|
|
|
790
|
+
exports.CheckoutTypes = void 0;
|
|
791
|
+
(function (CheckoutTypes) {
|
|
792
|
+
CheckoutTypes[CheckoutTypes["ECOMMERCE"] = 1] = "ECOMMERCE";
|
|
793
|
+
CheckoutTypes[CheckoutTypes["SUBSCRIPTION"] = 2] = "SUBSCRIPTION";
|
|
794
|
+
CheckoutTypes[CheckoutTypes["ALL"] = 3] = "ALL";
|
|
795
|
+
})(exports.CheckoutTypes || (exports.CheckoutTypes = {}));
|
|
796
|
+
|
|
789
797
|
var Base = /** @class */ (function () {
|
|
790
798
|
function Base() {
|
|
791
799
|
var args = [];
|
|
@@ -797,8 +805,30 @@
|
|
|
797
805
|
return Base;
|
|
798
806
|
}());
|
|
799
807
|
|
|
800
|
-
|
|
808
|
+
exports.CouponTypes = void 0;
|
|
809
|
+
(function (CouponTypes) {
|
|
810
|
+
CouponTypes[CouponTypes["ABSOLUTE"] = 1] = "ABSOLUTE";
|
|
811
|
+
CouponTypes[CouponTypes["PERCENTAGE"] = 2] = "PERCENTAGE";
|
|
812
|
+
// FINANCIAL = 1,
|
|
813
|
+
// PRODUCT,
|
|
814
|
+
// GIFTCARD,
|
|
815
|
+
// VOUCHER,
|
|
816
|
+
})(exports.CouponTypes || (exports.CouponTypes = {}));
|
|
817
|
+
|
|
818
|
+
exports.CouponSubtypes = void 0;
|
|
819
|
+
(function (CouponSubtypes) {
|
|
820
|
+
CouponSubtypes[CouponSubtypes["ABSOLUTE"] = 1] = "ABSOLUTE";
|
|
821
|
+
CouponSubtypes[CouponSubtypes["PERCENTAGE"] = 2] = "PERCENTAGE";
|
|
822
|
+
})(exports.CouponSubtypes || (exports.CouponSubtypes = {}));
|
|
801
823
|
|
|
824
|
+
exports.Exclusivities = void 0;
|
|
825
|
+
(function (Exclusivities) {
|
|
826
|
+
Exclusivities[Exclusivities["ALL_USERS"] = 1] = "ALL_USERS";
|
|
827
|
+
Exclusivities[Exclusivities["SPECIFIC_USER"] = 2] = "SPECIFIC_USER";
|
|
828
|
+
Exclusivities[Exclusivities["COLLABORATORS"] = 3] = "COLLABORATORS";
|
|
829
|
+
})(exports.Exclusivities || (exports.Exclusivities = {}));
|
|
830
|
+
|
|
831
|
+
var COUPON_EXPIRATION = 60 * 60 * 24 * 30;
|
|
802
832
|
var Coupon = /** @class */ (function (_super) {
|
|
803
833
|
__extends(Coupon, _super);
|
|
804
834
|
function Coupon() {
|
|
@@ -806,7 +836,7 @@
|
|
|
806
836
|
}
|
|
807
837
|
Object.defineProperty(Coupon.prototype, "isInfluencer", {
|
|
808
838
|
get: function () {
|
|
809
|
-
return !isNil(this.influencerEmail);
|
|
839
|
+
return !lodash.isNil(this.influencerEmail);
|
|
810
840
|
},
|
|
811
841
|
enumerable: false,
|
|
812
842
|
configurable: true
|
|
@@ -814,6 +844,20 @@
|
|
|
814
844
|
Coupon.prototype.identifierFields = function () {
|
|
815
845
|
return ['id'];
|
|
816
846
|
};
|
|
847
|
+
Coupon.createCoupon = function (userId) {
|
|
848
|
+
return this.toInstance({
|
|
849
|
+
nickname: "" + Date.now(),
|
|
850
|
+
type: exports.CouponTypes.ABSOLUTE,
|
|
851
|
+
checkoutType: exports.CheckoutTypes.ECOMMERCE,
|
|
852
|
+
discount: 30,
|
|
853
|
+
user: userId,
|
|
854
|
+
useLimit: 1,
|
|
855
|
+
useLimitPerUser: 1,
|
|
856
|
+
createdAt: new Date(Date.now()),
|
|
857
|
+
beginAt: new Date(Date.now()),
|
|
858
|
+
expiresIn: new Date(Date.now() + COUPON_EXPIRATION),
|
|
859
|
+
});
|
|
860
|
+
};
|
|
817
861
|
return Coupon;
|
|
818
862
|
}(BaseModel));
|
|
819
863
|
__decorate([
|
|
@@ -859,8 +903,8 @@
|
|
|
859
903
|
}
|
|
860
904
|
User.toInstance = function (data) {
|
|
861
905
|
var instance = _super.toInstance.call(this, data);
|
|
862
|
-
if (!isNil(data.firstName))
|
|
863
|
-
instance.displayName = "" + data.firstName + (!isNil(data.lastName) ? " " + data.lastName : '');
|
|
906
|
+
if (!lodash.isNil(data.firstName))
|
|
907
|
+
instance.displayName = "" + data.firstName + (!lodash.isNil(data.lastName) ? " " + data.lastName : '');
|
|
864
908
|
return instance;
|
|
865
909
|
};
|
|
866
910
|
User.prototype.identifierFields = function () {
|
|
@@ -982,7 +1026,7 @@
|
|
|
982
1026
|
case 1:
|
|
983
1027
|
userAuth = _b.sent();
|
|
984
1028
|
user = this.userRepository.get(userAuth);
|
|
985
|
-
if (!isNil(user))
|
|
1029
|
+
if (!lodash.isNil(user))
|
|
986
1030
|
return [2 /*return*/, user];
|
|
987
1031
|
if (/^.+@b4a.com.br$/.test(userAuth.email))
|
|
988
1032
|
return [2 /*return*/, this.createsUserByCredential(userAuth)];
|
|
@@ -1119,6 +1163,7 @@
|
|
|
1119
1163
|
Shops["MENSMARKET"] = "mensmarket";
|
|
1120
1164
|
Shops["GLAMSHOP"] = "Glamshop";
|
|
1121
1165
|
Shops["GLAMPOINTS"] = "Glampoints";
|
|
1166
|
+
Shops["ALL"] = "ALL";
|
|
1122
1167
|
})(exports.Shops || (exports.Shops = {}));
|
|
1123
1168
|
|
|
1124
1169
|
var Category = /** @class */ (function (_super) {
|
|
@@ -1158,60 +1203,6 @@
|
|
|
1158
1203
|
return Variant;
|
|
1159
1204
|
}(BaseModel));
|
|
1160
1205
|
|
|
1161
|
-
exports.CouponTypes = void 0;
|
|
1162
|
-
(function (CouponTypes) {
|
|
1163
|
-
CouponTypes[CouponTypes["FINANCIAL"] = 1] = "FINANCIAL";
|
|
1164
|
-
CouponTypes[CouponTypes["PRODUCT"] = 2] = "PRODUCT";
|
|
1165
|
-
CouponTypes[CouponTypes["GIFTCARD"] = 3] = "GIFTCARD";
|
|
1166
|
-
CouponTypes[CouponTypes["VOUCHER"] = 4] = "VOUCHER";
|
|
1167
|
-
})(exports.CouponTypes || (exports.CouponTypes = {}));
|
|
1168
|
-
|
|
1169
|
-
exports.CouponSubtypes = void 0;
|
|
1170
|
-
(function (CouponSubtypes) {
|
|
1171
|
-
CouponSubtypes[CouponSubtypes["ABSOLUTE"] = 1] = "ABSOLUTE";
|
|
1172
|
-
CouponSubtypes[CouponSubtypes["PERCENTAGE"] = 2] = "PERCENTAGE";
|
|
1173
|
-
})(exports.CouponSubtypes || (exports.CouponSubtypes = {}));
|
|
1174
|
-
|
|
1175
|
-
exports.Exclusivities = void 0;
|
|
1176
|
-
(function (Exclusivities) {
|
|
1177
|
-
Exclusivities[Exclusivities["ALL_USERS"] = 1] = "ALL_USERS";
|
|
1178
|
-
Exclusivities[Exclusivities["SPECIFIC_USER"] = 2] = "SPECIFIC_USER";
|
|
1179
|
-
Exclusivities[Exclusivities["COLLABORATORS"] = 3] = "COLLABORATORS";
|
|
1180
|
-
})(exports.Exclusivities || (exports.Exclusivities = {}));
|
|
1181
|
-
|
|
1182
|
-
exports.CheckoutTypes = void 0;
|
|
1183
|
-
(function (CheckoutTypes) {
|
|
1184
|
-
CheckoutTypes[CheckoutTypes["ECOMMERCE"] = 1] = "ECOMMERCE";
|
|
1185
|
-
CheckoutTypes[CheckoutTypes["SUBSCRIPTION"] = 2] = "SUBSCRIPTION";
|
|
1186
|
-
})(exports.CheckoutTypes || (exports.CheckoutTypes = {}));
|
|
1187
|
-
|
|
1188
|
-
var COUPON_EXPIRATION = 60 * 60 * 24 * 30;
|
|
1189
|
-
var FinancialCoupon = /** @class */ (function (_super) {
|
|
1190
|
-
__extends(FinancialCoupon, _super);
|
|
1191
|
-
function FinancialCoupon() {
|
|
1192
|
-
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
1193
|
-
_this.type = exports.CouponTypes.FINANCIAL;
|
|
1194
|
-
return _this;
|
|
1195
|
-
}
|
|
1196
|
-
FinancialCoupon.isFinancialCoupon = function (coupon) {
|
|
1197
|
-
return coupon.type === exports.CouponTypes.FINANCIAL && !!coupon.subtype;
|
|
1198
|
-
};
|
|
1199
|
-
FinancialCoupon.createCoupon = function (userId) {
|
|
1200
|
-
return this.toInstance({
|
|
1201
|
-
name: tsMd5.Md5.hashStr(userId + "_" + Date.now).toString(),
|
|
1202
|
-
nickname: "" + Date.now(),
|
|
1203
|
-
type: exports.CouponTypes.FINANCIAL,
|
|
1204
|
-
subtype: exports.CouponSubtypes.PERCENTAGE,
|
|
1205
|
-
checkoutType: exports.CheckoutTypes.ECOMMERCE,
|
|
1206
|
-
discount: 30,
|
|
1207
|
-
user: userId,
|
|
1208
|
-
createdAt: new Date(Date.now()),
|
|
1209
|
-
expiresIn: new Date(Date.now() + COUPON_EXPIRATION),
|
|
1210
|
-
});
|
|
1211
|
-
};
|
|
1212
|
-
return FinancialCoupon;
|
|
1213
|
-
}(Coupon));
|
|
1214
|
-
|
|
1215
1206
|
exports.OrderStatus = void 0;
|
|
1216
1207
|
(function (OrderStatus) {
|
|
1217
1208
|
OrderStatus["AGUARDANDO_PAGAMENTO"] = "Aguardando pagamento";
|
|
@@ -1589,7 +1580,7 @@
|
|
|
1589
1580
|
return _super.call(this, args) || this;
|
|
1590
1581
|
}
|
|
1591
1582
|
class_1.prototype.collection = function (path) {
|
|
1592
|
-
return firestore.collection(
|
|
1583
|
+
return this.firestore.collection(path || this.collectionName).withConverter(this.buildModelInstance());
|
|
1593
1584
|
};
|
|
1594
1585
|
class_1.prototype.buildModelInstance = function () {
|
|
1595
1586
|
var _this = this;
|
|
@@ -1598,7 +1589,7 @@
|
|
|
1598
1589
|
fromFirestore: function (snap) {
|
|
1599
1590
|
var data = snap.data();
|
|
1600
1591
|
Object.keys(data).forEach(function (key) {
|
|
1601
|
-
if (data[key] instanceof firestore.Timestamp) {
|
|
1592
|
+
if (data[key] instanceof firebase__default["default"].firestore.Timestamp) {
|
|
1602
1593
|
data[key] = data[key].toDate();
|
|
1603
1594
|
}
|
|
1604
1595
|
});
|
|
@@ -1625,7 +1616,7 @@
|
|
|
1625
1616
|
}
|
|
1626
1617
|
};
|
|
1627
1618
|
class_1.prototype.isSubCollection = function (repository) {
|
|
1628
|
-
return !isNil(Object.keys(this).find(function (key) { return key === 'parentRepository'; }));
|
|
1619
|
+
return !lodash.isNil(Object.keys(this).find(function (key) { return key === 'parentRepository'; }));
|
|
1629
1620
|
};
|
|
1630
1621
|
return class_1;
|
|
1631
1622
|
}(MixinBase));
|
|
@@ -1639,18 +1630,16 @@
|
|
|
1639
1630
|
}
|
|
1640
1631
|
GetFirestore.prototype.get = function (identifiers) {
|
|
1641
1632
|
return __awaiter(this, void 0, void 0, function () {
|
|
1642
|
-
var
|
|
1643
|
-
return __generator(this, function (
|
|
1644
|
-
switch (
|
|
1645
|
-
case 0:
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
data = docRef.data();
|
|
1653
|
-
if (isNil(data))
|
|
1633
|
+
var doc, data;
|
|
1634
|
+
return __generator(this, function (_a) {
|
|
1635
|
+
switch (_a.label) {
|
|
1636
|
+
case 0: return [4 /*yield*/, this.collection(this.buildCollectionPathForGet(identifiers))
|
|
1637
|
+
.doc(Object.values(identifiers).shift().toString())
|
|
1638
|
+
.get()];
|
|
1639
|
+
case 1:
|
|
1640
|
+
doc = _a.sent();
|
|
1641
|
+
data = doc.data();
|
|
1642
|
+
if (lodash.isNil(data))
|
|
1654
1643
|
throw new NotFoundError("Document " + JSON.stringify(identifiers) + " not found");
|
|
1655
1644
|
return [2 /*return*/, data];
|
|
1656
1645
|
}
|
|
@@ -1667,64 +1656,64 @@
|
|
|
1667
1656
|
};
|
|
1668
1657
|
|
|
1669
1658
|
var withFindFirestore = function (MixinBase) {
|
|
1670
|
-
var checkIfIsFilterOption = function (filter) { return !isNil(filter === null || filter === void 0 ? void 0 : filter.operator); };
|
|
1659
|
+
var checkIfIsFilterOption = function (filter) { return !lodash.isNil(filter === null || filter === void 0 ? void 0 : filter.operator); };
|
|
1671
1660
|
var getValueFromFilter = function (filter) {
|
|
1672
1661
|
return checkIfIsFilterOption(filter) ? filter.value : filter;
|
|
1673
1662
|
};
|
|
1674
|
-
var getFinalValueFrom = function (value) { return isNumber(value) || isString(value) || isDate(value) || Array.isArray(value)
|
|
1663
|
+
var getFinalValueFrom = function (value) { return lodash.isNumber(value) || lodash.isString(value) || lodash.isDate(value) || Array.isArray(value)
|
|
1675
1664
|
? value
|
|
1676
1665
|
: Object.values(getFinalValueFrom); };
|
|
1677
1666
|
return /** @class */ (function (_super) {
|
|
1678
1667
|
__extends(FindFirestore, _super);
|
|
1679
1668
|
function FindFirestore() {
|
|
1680
1669
|
var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
|
|
1681
|
-
_this.makeFirestoreWhere = function (filter) { return Object.keys(filter).reduce(function (
|
|
1682
|
-
_this.buildWhereSentence = function (fieldName, options) {
|
|
1670
|
+
_this.makeFirestoreWhere = function (queryReference, filter) { return Object.keys(filter).reduce(function (query, fieldName) { return _this.buildWhereSentence(query, fieldName, filter[fieldName]); }, queryReference); };
|
|
1671
|
+
_this.buildWhereSentence = function (queryReference, fieldName, options) {
|
|
1683
1672
|
if (_this.isSubCollection(_this) && fieldName === _this.parentIdField)
|
|
1684
|
-
|
|
1673
|
+
return queryReference;
|
|
1685
1674
|
var value = (options === null || options === void 0 ? void 0 : options.value) || options;
|
|
1686
1675
|
var object = {};
|
|
1687
|
-
set(object, fieldName, value);
|
|
1676
|
+
lodash.set(object, fieldName, value);
|
|
1688
1677
|
var plainInstance = new _this.model(object).toPlain();
|
|
1689
1678
|
var firestoreFieldName = fieldName.toString().indexOf('.') > -1
|
|
1690
1679
|
? fieldName.toString()
|
|
1691
1680
|
: Object.keys(plainInstance).find(function (key) { return plainInstance[key]; });
|
|
1692
1681
|
if ((options === null || options === void 0 ? void 0 : options.operator) === exports.Where.LIKE) {
|
|
1693
1682
|
if (Array.isArray(options === null || options === void 0 ? void 0 : options.value))
|
|
1694
|
-
return
|
|
1695
|
-
|
|
1683
|
+
return queryReference.where(firestoreFieldName, 'array-contains-any', options.value);
|
|
1684
|
+
queryReference = queryReference.where(firestoreFieldName, '>=', options.value);
|
|
1685
|
+
queryReference = queryReference.where(firestoreFieldName, '<=', options.value + "~");
|
|
1686
|
+
return queryReference;
|
|
1696
1687
|
}
|
|
1697
1688
|
if ((options === null || options === void 0 ? void 0 : options.operator) === exports.Where.IN && Array.isArray(options === null || options === void 0 ? void 0 : options.value))
|
|
1698
|
-
return
|
|
1699
|
-
if (isObject(options) && isNil(options === null || options === void 0 ? void 0 : options.operator) && isNil(options === null || options === void 0 ? void 0 : options.value)) {
|
|
1700
|
-
return Object.keys(options).reduce(function (
|
|
1689
|
+
return queryReference.where(firestoreFieldName, 'array-contains', options.value);
|
|
1690
|
+
if (lodash.isObject(options) && lodash.isNil(options === null || options === void 0 ? void 0 : options.operator) && lodash.isNil(options === null || options === void 0 ? void 0 : options.value)) {
|
|
1691
|
+
return Object.keys(options).reduce(function (queryReferenceWithWhere, key) { return _this.buildWhereSentence(queryReferenceWithWhere, fieldName + "." + key, options[key]); }, queryReference);
|
|
1701
1692
|
}
|
|
1702
|
-
return
|
|
1693
|
+
return queryReference.where(firestoreFieldName, (options === null || options === void 0 ? void 0 : options.operator) || '==', (options === null || options === void 0 ? void 0 : options.value) || options);
|
|
1703
1694
|
};
|
|
1704
1695
|
return _this;
|
|
1705
1696
|
}
|
|
1706
|
-
FindFirestore.prototype.find = function (filters,
|
|
1697
|
+
FindFirestore.prototype.find = function (filters, limits, orderBy) {
|
|
1707
1698
|
return __awaiter(this, void 0, void 0, function () {
|
|
1708
|
-
var
|
|
1699
|
+
var query, docs, data;
|
|
1709
1700
|
var _this = this;
|
|
1710
1701
|
return __generator(this, function (_b) {
|
|
1711
1702
|
switch (_b.label) {
|
|
1712
1703
|
case 0:
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
return [4 /*yield*/, this.defineLimits(filters, limitList)];
|
|
1704
|
+
query = this.collection(this.buildCollectionPathForFind(filters));
|
|
1705
|
+
filters === null || filters === void 0 ? void 0 : filters.forEach(function (filterer) { return (query = _this.makeFirestoreWhere(query, filterer)); });
|
|
1706
|
+
orderBy === null || orderBy === void 0 ? void 0 : orderBy.forEach(function (orderer) { return Object.keys(orderer).forEach(function (fieldName) { return (query = query.orderBy(fieldName, orderer[fieldName])); }); });
|
|
1707
|
+
return [4 /*yield*/, this.defineLimits(query, filters, limits)];
|
|
1718
1708
|
case 1:
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
return [4 /*yield*/, firestore.getDocs(firestore.query.apply(void 0, __spreadArray([collection], __read(queryArgumments))))];
|
|
1709
|
+
query = _b.sent();
|
|
1710
|
+
return [4 /*yield*/, query.get()];
|
|
1722
1711
|
case 2:
|
|
1723
1712
|
docs = _b.sent();
|
|
1724
1713
|
data = docs.docs.map(function (doc) { return doc.data(); });
|
|
1725
1714
|
return [2 /*return*/, {
|
|
1726
1715
|
data: data,
|
|
1727
|
-
count: this.calculateCount(data,
|
|
1716
|
+
count: this.calculateCount(data, limits),
|
|
1728
1717
|
}];
|
|
1729
1718
|
}
|
|
1730
1719
|
});
|
|
@@ -1738,29 +1727,29 @@
|
|
|
1738
1727
|
var parentId = getValueFromFilter((_a = filters.find(function (groupFilter) { return Boolean(getValueFromFilter(groupFilter[parentIdField])); })) === null || _a === void 0 ? void 0 : _a[parentIdField]);
|
|
1739
1728
|
return this.parentRepository.collectionName + "/" + parentId + "/" + this.collectionName;
|
|
1740
1729
|
};
|
|
1741
|
-
FindFirestore.prototype.defineLimits = function (filters, limits) {
|
|
1730
|
+
FindFirestore.prototype.defineLimits = function (query, filters, limits) {
|
|
1742
1731
|
return __awaiter(this, void 0, void 0, function () {
|
|
1743
|
-
var
|
|
1744
|
-
return __generator(this, function (
|
|
1745
|
-
switch (
|
|
1732
|
+
var _b, _c;
|
|
1733
|
+
return __generator(this, function (_d) {
|
|
1734
|
+
switch (_d.label) {
|
|
1746
1735
|
case 0:
|
|
1747
|
-
queries = [];
|
|
1748
1736
|
if (!(limits === null || limits === void 0 ? void 0 : limits.offset)) return [3 /*break*/, 3];
|
|
1749
1737
|
if (!(limits.offset instanceof this.model)) return [3 /*break*/, 2];
|
|
1750
|
-
_c = (_b =
|
|
1751
|
-
|
|
1752
|
-
|
|
1738
|
+
_c = (_b = query).startAfter;
|
|
1739
|
+
return [4 /*yield*/, this.collection(this.buildCollectionPathForFind(filters))
|
|
1740
|
+
.doc(limits.offset[limits.offset.identifierFields().shift()])
|
|
1741
|
+
.get()];
|
|
1753
1742
|
case 1:
|
|
1754
|
-
_c.apply(_b, [_d.
|
|
1743
|
+
query = _c.apply(_b, [_d.sent()]);
|
|
1755
1744
|
return [3 /*break*/, 3];
|
|
1756
1745
|
case 2:
|
|
1757
|
-
if (isNumber(limits.offset) || isString(limits.offset))
|
|
1758
|
-
|
|
1759
|
-
|
|
1746
|
+
if (lodash.isNumber(limits.offset) || lodash.isString(limits.offset))
|
|
1747
|
+
query = query.startAt(limits.offset);
|
|
1748
|
+
_d.label = 3;
|
|
1760
1749
|
case 3:
|
|
1761
1750
|
if (limits === null || limits === void 0 ? void 0 : limits.limit)
|
|
1762
|
-
|
|
1763
|
-
return [2 /*return*/,
|
|
1751
|
+
query = query.limit(limits.limit);
|
|
1752
|
+
return [2 /*return*/, query];
|
|
1764
1753
|
}
|
|
1765
1754
|
});
|
|
1766
1755
|
});
|
|
@@ -1790,7 +1779,7 @@
|
|
|
1790
1779
|
case 0: return [4 /*yield*/, this.save(this.model.toInstance(data))];
|
|
1791
1780
|
case 1:
|
|
1792
1781
|
docRef = _b.sent();
|
|
1793
|
-
return [4 /*yield*/,
|
|
1782
|
+
return [4 /*yield*/, docRef.get()];
|
|
1794
1783
|
case 2:
|
|
1795
1784
|
doc = _b.sent();
|
|
1796
1785
|
return [2 /*return*/, doc.data()];
|
|
@@ -1801,17 +1790,16 @@
|
|
|
1801
1790
|
CreateFirestore.prototype.save = function (data) {
|
|
1802
1791
|
var _a;
|
|
1803
1792
|
return __awaiter(this, void 0, void 0, function () {
|
|
1804
|
-
var id, collectionPath,
|
|
1793
|
+
var id, collectionPath, docRef;
|
|
1805
1794
|
return __generator(this, function (_b) {
|
|
1806
1795
|
switch (_b.label) {
|
|
1807
1796
|
case 0:
|
|
1808
1797
|
id = (_a = data[data.identifierFields().shift()]) === null || _a === void 0 ? void 0 : _a.toString();
|
|
1809
1798
|
collectionPath = this.buildCollectionPathForAdd(data);
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
return [4 /*yield*/, firestore.setDoc(docRef, data)];
|
|
1799
|
+
if (lodash.isEmpty(id))
|
|
1800
|
+
return [2 /*return*/, this.collection(collectionPath).add(data)];
|
|
1801
|
+
docRef = this.collection(collectionPath).doc(id);
|
|
1802
|
+
return [4 /*yield*/, docRef.set(data)];
|
|
1815
1803
|
case 1:
|
|
1816
1804
|
_b.sent();
|
|
1817
1805
|
return [2 /*return*/, docRef];
|
|
@@ -1829,17 +1817,18 @@
|
|
|
1829
1817
|
};
|
|
1830
1818
|
|
|
1831
1819
|
var withUpdateFirestore = function (MixinBase) {
|
|
1832
|
-
var getValueFromParams = function (params, field) { var _a; return (isNil((_a = params[field]) === null || _a === void 0 ? void 0 : _a.value) ? params[field] : params[field].value) || null; };
|
|
1820
|
+
var getValueFromParams = function (params, field) { var _a; return (lodash.isNil((_a = params[field]) === null || _a === void 0 ? void 0 : _a.value) ? params[field] : params[field].value) || null; };
|
|
1833
1821
|
var getValueByAction = function (options) {
|
|
1834
|
-
|
|
1822
|
+
var fieldValues = firebase__default["default"].firestore.FieldValue;
|
|
1823
|
+
if (lodash.isNil(options.action))
|
|
1835
1824
|
return options;
|
|
1836
1825
|
if (options.action === exports.UpdateOptionActions.REMOVE_FIELD)
|
|
1837
|
-
return
|
|
1826
|
+
return fieldValues.delete();
|
|
1838
1827
|
if (Array.isArray(options.value)) {
|
|
1839
1828
|
if (options.action === exports.UpdateOptionActions.MERGE)
|
|
1840
|
-
return
|
|
1829
|
+
return fieldValues.arrayUnion.apply(fieldValues, __spreadArray([], __read(options.value)));
|
|
1841
1830
|
if (options.action === exports.UpdateOptionActions.REMOVE)
|
|
1842
|
-
return
|
|
1831
|
+
return fieldValues.arrayRemove.apply(fieldValues, __spreadArray([], __read(options.value)));
|
|
1843
1832
|
}
|
|
1844
1833
|
return options.value;
|
|
1845
1834
|
};
|
|
@@ -1850,20 +1839,20 @@
|
|
|
1850
1839
|
}
|
|
1851
1840
|
UpdateFirestore.prototype.update = function (data) {
|
|
1852
1841
|
return __awaiter(this, void 0, void 0, function () {
|
|
1853
|
-
var model, keyField, docRef,
|
|
1842
|
+
var model, keyField, docRef, doc;
|
|
1854
1843
|
return __generator(this, function (_b) {
|
|
1855
1844
|
switch (_b.label) {
|
|
1856
1845
|
case 0:
|
|
1857
1846
|
model = new this.model();
|
|
1858
1847
|
keyField = model.identifierFields().shift();
|
|
1859
|
-
docRef =
|
|
1860
|
-
return [4 /*yield*/,
|
|
1848
|
+
docRef = this.collection(this.buildCollectionPathForUpdate(data)).doc(getValueFromParams(data, keyField).toString());
|
|
1849
|
+
return [4 /*yield*/, docRef.set(this.paramsToPlain(data), { merge: true })];
|
|
1861
1850
|
case 1:
|
|
1862
1851
|
_b.sent();
|
|
1863
|
-
return [4 /*yield*/,
|
|
1852
|
+
return [4 /*yield*/, docRef.get()];
|
|
1864
1853
|
case 2:
|
|
1865
|
-
|
|
1866
|
-
return [2 /*return*/,
|
|
1854
|
+
doc = _b.sent();
|
|
1855
|
+
return [2 /*return*/, doc.data()];
|
|
1867
1856
|
}
|
|
1868
1857
|
});
|
|
1869
1858
|
});
|
|
@@ -1896,7 +1885,9 @@
|
|
|
1896
1885
|
return __awaiter(this, void 0, void 0, function () {
|
|
1897
1886
|
return __generator(this, function (_a) {
|
|
1898
1887
|
switch (_a.label) {
|
|
1899
|
-
case 0: return [4 /*yield*/,
|
|
1888
|
+
case 0: return [4 /*yield*/, this.collection(this.buildCollectionPathForRemove(identifiers))
|
|
1889
|
+
.doc(Object.values(identifiers).shift().toString())
|
|
1890
|
+
.delete()];
|
|
1900
1891
|
case 1:
|
|
1901
1892
|
_a.sent();
|
|
1902
1893
|
return [2 /*return*/];
|
|
@@ -2040,7 +2031,12 @@
|
|
|
2040
2031
|
var beautyProfile;
|
|
2041
2032
|
return __generator(this, function (_a) {
|
|
2042
2033
|
switch (_a.label) {
|
|
2043
|
-
case 0: return [4 /*yield*/,
|
|
2034
|
+
case 0: return [4 /*yield*/, this.collection()
|
|
2035
|
+
.doc(userId)
|
|
2036
|
+
.collection('CX')
|
|
2037
|
+
.withConverter(this.buildBeautyProfileModelInstance())
|
|
2038
|
+
.doc('beautyProfile')
|
|
2039
|
+
.get()];
|
|
2044
2040
|
case 1:
|
|
2045
2041
|
beautyProfile = _a.sent();
|
|
2046
2042
|
return [2 /*return*/, beautyProfile.data()];
|
|
@@ -2053,7 +2049,11 @@
|
|
|
2053
2049
|
var docs;
|
|
2054
2050
|
return __generator(this, function (_a) {
|
|
2055
2051
|
switch (_a.label) {
|
|
2056
|
-
case 0: return [4 /*yield*/,
|
|
2052
|
+
case 0: return [4 /*yield*/, this.firestore
|
|
2053
|
+
.collection('subscription')
|
|
2054
|
+
.where('user.id', '==', userId)
|
|
2055
|
+
.where('status', '==', 'active')
|
|
2056
|
+
.get()];
|
|
2057
2057
|
case 1:
|
|
2058
2058
|
docs = _a.sent();
|
|
2059
2059
|
return [2 /*return*/, !!docs && !!docs.size];
|
|
@@ -2154,30 +2154,27 @@
|
|
|
2154
2154
|
|
|
2155
2155
|
var CategoryFirestoreRepository = /** @class */ (function (_super) {
|
|
2156
2156
|
__extends(CategoryFirestoreRepository, _super);
|
|
2157
|
-
function CategoryFirestoreRepository(firestore
|
|
2157
|
+
function CategoryFirestoreRepository(firestore) {
|
|
2158
2158
|
var _this = _super.call(this) || this;
|
|
2159
2159
|
_this.firestore = firestore;
|
|
2160
|
-
_this.productsIndex = productsIndex;
|
|
2161
2160
|
_this.collectionName = 'categories';
|
|
2162
2161
|
_this.model = Category;
|
|
2163
2162
|
return _this;
|
|
2164
2163
|
}
|
|
2165
2164
|
CategoryFirestoreRepository.prototype.getCategoryBySlug = function (slug, shop) {
|
|
2166
|
-
return
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
});
|
|
2180
|
-
});
|
|
2165
|
+
return this.collection(this.collectionName)
|
|
2166
|
+
.where('slug', '==', slug)
|
|
2167
|
+
.where('shop', '==', shop)
|
|
2168
|
+
.where('published', '==', true)
|
|
2169
|
+
.get()
|
|
2170
|
+
.then(function (snap) {
|
|
2171
|
+
if (snap.size > 1)
|
|
2172
|
+
throw new DuplicatedResultsError('Query returned duplicated values');
|
|
2173
|
+
if (snap.empty)
|
|
2174
|
+
throw new NotFoundError("Document with slug " + slug + " not found");
|
|
2175
|
+
return snap.docs[0].data();
|
|
2176
|
+
})
|
|
2177
|
+
.catch(function (error) { return error; });
|
|
2181
2178
|
};
|
|
2182
2179
|
CategoryFirestoreRepository.prototype.getCategoriesForHome = function (categoryIds, limit) {
|
|
2183
2180
|
if (limit === void 0) { limit = 4; }
|
|
@@ -2186,7 +2183,10 @@
|
|
|
2186
2183
|
var _this = this;
|
|
2187
2184
|
return __generator(this, function (_a) {
|
|
2188
2185
|
switch (_a.label) {
|
|
2189
|
-
case 0: return [4 /*yield*/,
|
|
2186
|
+
case 0: return [4 /*yield*/, this.collection(this.collectionName)
|
|
2187
|
+
.where('id', 'in', categoryIds.filter(Boolean))
|
|
2188
|
+
.where('published', '==', true)
|
|
2189
|
+
.get()];
|
|
2190
2190
|
case 1:
|
|
2191
2191
|
categorySnap = _a.sent();
|
|
2192
2192
|
if (categorySnap.empty)
|
|
@@ -2215,14 +2215,56 @@
|
|
|
2215
2215
|
};
|
|
2216
2216
|
CategoryFirestoreRepository.prototype.mountCategory = function (category, options) {
|
|
2217
2217
|
return __awaiter(this, void 0, void 0, function () {
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2218
|
+
var chunks, products, publishedField, chunks_1, chunks_1_1, productIds, query, productSnap, e_1_1;
|
|
2219
|
+
var e_1, _a;
|
|
2220
|
+
return __generator(this, function (_b) {
|
|
2221
|
+
switch (_b.label) {
|
|
2222
|
+
case 0:
|
|
2223
|
+
if (!category.products)
|
|
2224
|
+
throw new RequiredArgumentError(['Category products is empty']);
|
|
2225
|
+
chunks = lodash.chunk(category.products, 10);
|
|
2226
|
+
products = [];
|
|
2227
|
+
publishedField = category.shop === exports.Shops.GLAMSHOP ? 'publishedGlam' : 'published';
|
|
2228
|
+
_b.label = 1;
|
|
2229
|
+
case 1:
|
|
2230
|
+
_b.trys.push([1, 7, 8, 9]);
|
|
2231
|
+
chunks_1 = __values(chunks), chunks_1_1 = chunks_1.next();
|
|
2232
|
+
_b.label = 2;
|
|
2233
|
+
case 2:
|
|
2234
|
+
if (!!chunks_1_1.done) return [3 /*break*/, 6];
|
|
2235
|
+
productIds = chunks_1_1.value;
|
|
2236
|
+
if ((options === null || options === void 0 ? void 0 : options.limit) && products.length >= (options === null || options === void 0 ? void 0 : options.limit))
|
|
2237
|
+
return [3 /*break*/, 6];
|
|
2238
|
+
return [4 /*yield*/, this.collection('products').where(publishedField, '==', true).where('id', 'in', productIds)];
|
|
2239
|
+
case 3:
|
|
2240
|
+
query = _b.sent();
|
|
2241
|
+
if (options === null || options === void 0 ? void 0 : options.hasStock)
|
|
2242
|
+
query = query.where('stock.quantity', '>', 0);
|
|
2243
|
+
if (options === null || options === void 0 ? void 0 : options.limit)
|
|
2244
|
+
query = query.limit(options === null || options === void 0 ? void 0 : options.limit);
|
|
2245
|
+
return [4 /*yield*/, query.get()];
|
|
2246
|
+
case 4:
|
|
2247
|
+
productSnap = _b.sent();
|
|
2248
|
+
if (productSnap.empty)
|
|
2249
|
+
return [3 /*break*/, 5];
|
|
2250
|
+
products.push.apply(products, __spreadArray([], __read(productSnap.docs.map(function (doc) { return doc.data(); }))));
|
|
2251
|
+
_b.label = 5;
|
|
2252
|
+
case 5:
|
|
2253
|
+
chunks_1_1 = chunks_1.next();
|
|
2254
|
+
return [3 /*break*/, 2];
|
|
2255
|
+
case 6: return [3 /*break*/, 9];
|
|
2256
|
+
case 7:
|
|
2257
|
+
e_1_1 = _b.sent();
|
|
2258
|
+
e_1 = { error: e_1_1 };
|
|
2259
|
+
return [3 /*break*/, 9];
|
|
2260
|
+
case 8:
|
|
2261
|
+
try {
|
|
2262
|
+
if (chunks_1_1 && !chunks_1_1.done && (_a = chunks_1.return)) _a.call(chunks_1);
|
|
2263
|
+
}
|
|
2264
|
+
finally { if (e_1) throw e_1.error; }
|
|
2265
|
+
return [7 /*endfinally*/];
|
|
2266
|
+
case 9: return [2 /*return*/, products];
|
|
2267
|
+
}
|
|
2226
2268
|
});
|
|
2227
2269
|
});
|
|
2228
2270
|
};
|
|
@@ -2316,7 +2358,7 @@
|
|
|
2316
2358
|
},
|
|
2317
2359
|
fromFirestore: function (snap) {
|
|
2318
2360
|
var instance = fromFirestore(snap);
|
|
2319
|
-
if (!isNil(instance.expiresIn))
|
|
2361
|
+
if (!lodash.isNil(instance.expiresIn))
|
|
2320
2362
|
instance.expiresIn = new Date(snap.data().expiresIn);
|
|
2321
2363
|
return instance;
|
|
2322
2364
|
},
|
|
@@ -2398,9 +2440,9 @@
|
|
|
2398
2440
|
|
|
2399
2441
|
var HomeFirestoreRepository = /** @class */ (function (_super) {
|
|
2400
2442
|
__extends(HomeFirestoreRepository, _super);
|
|
2401
|
-
function HomeFirestoreRepository(firestore
|
|
2443
|
+
function HomeFirestoreRepository(firestore) {
|
|
2402
2444
|
var _this = _super.call(this) || this;
|
|
2403
|
-
_this.firestore = firestore
|
|
2445
|
+
_this.firestore = firestore;
|
|
2404
2446
|
_this.homeToFirestore = function (home) {
|
|
2405
2447
|
var _a;
|
|
2406
2448
|
if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
|
|
@@ -2421,9 +2463,9 @@
|
|
|
2421
2463
|
home.data.data.featuredProducts = home.data.data.featuredProducts.map(_this.plainToHomeCategoryGroup);
|
|
2422
2464
|
home.data.data.verticalProducts = home.data.data.verticalProducts.map(_this.plainToHomeCategoryGroup);
|
|
2423
2465
|
home.data.createdAt =
|
|
2424
|
-
home.data.createdAt instanceof firestore.Timestamp ? home.data.createdAt.toDate() : home.data.createdAt;
|
|
2466
|
+
home.data.createdAt instanceof firebase__default["default"].firestore.Timestamp ? home.data.createdAt.toDate() : home.data.createdAt;
|
|
2425
2467
|
home.data.expiresAt =
|
|
2426
|
-
home.data.expiresAt instanceof firestore.Timestamp ? home.data.expiresAt.toDate() : home.data.expiresAt;
|
|
2468
|
+
home.data.expiresAt instanceof firebase__default["default"].firestore.Timestamp ? home.data.expiresAt.toDate() : home.data.expiresAt;
|
|
2427
2469
|
}
|
|
2428
2470
|
return home;
|
|
2429
2471
|
};
|
|
@@ -2473,7 +2515,7 @@
|
|
|
2473
2515
|
var credentials, user;
|
|
2474
2516
|
return __generator(this, function (_a) {
|
|
2475
2517
|
switch (_a.label) {
|
|
2476
|
-
case 0: return [4 /*yield*/,
|
|
2518
|
+
case 0: return [4 /*yield*/, this.firebaseAuth.signInWithEmailAndPassword(data.email, data.password)];
|
|
2477
2519
|
case 1:
|
|
2478
2520
|
credentials = _a.sent();
|
|
2479
2521
|
user = credentials.user;
|
|
@@ -2493,7 +2535,7 @@
|
|
|
2493
2535
|
var credentials, user;
|
|
2494
2536
|
return __generator(this, function (_a) {
|
|
2495
2537
|
switch (_a.label) {
|
|
2496
|
-
case 0: return [4 /*yield*/,
|
|
2538
|
+
case 0: return [4 /*yield*/, this.firebaseAuth.signInWithPopup(new firebase__default$1["default"].auth.GoogleAuthProvider())];
|
|
2497
2539
|
case 1:
|
|
2498
2540
|
credentials = _a.sent();
|
|
2499
2541
|
user = credentials.user;
|
|
@@ -2518,14 +2560,14 @@
|
|
|
2518
2560
|
};
|
|
2519
2561
|
AuthenticationFirebaseAuthService.prototype.signInAnonymously = function () {
|
|
2520
2562
|
return __awaiter(this, void 0, void 0, function () {
|
|
2521
|
-
var auth
|
|
2563
|
+
var auth, user;
|
|
2522
2564
|
return __generator(this, function (_a) {
|
|
2523
2565
|
switch (_a.label) {
|
|
2524
|
-
case 0: return [4 /*yield*/,
|
|
2566
|
+
case 0: return [4 /*yield*/, this.firebaseAuth.signInAnonymously()];
|
|
2525
2567
|
case 1:
|
|
2526
|
-
auth
|
|
2527
|
-
user = auth
|
|
2528
|
-
user.id = auth
|
|
2568
|
+
auth = _a.sent();
|
|
2569
|
+
user = auth.user;
|
|
2570
|
+
user.id = auth.user.uid;
|
|
2529
2571
|
return [2 /*return*/, user];
|
|
2530
2572
|
}
|
|
2531
2573
|
});
|
|
@@ -2534,7 +2576,7 @@
|
|
|
2534
2576
|
AuthenticationFirebaseAuthService.prototype.sendPasswordResetEmail = function (email) {
|
|
2535
2577
|
return __awaiter(this, void 0, void 0, function () {
|
|
2536
2578
|
return __generator(this, function (_a) {
|
|
2537
|
-
return [2 /*return*/,
|
|
2579
|
+
return [2 /*return*/, this.firebaseAuth.sendPasswordResetEmail(email)];
|
|
2538
2580
|
});
|
|
2539
2581
|
});
|
|
2540
2582
|
};
|
|
@@ -2547,28 +2589,26 @@
|
|
|
2547
2589
|
}
|
|
2548
2590
|
RegisterFirebaseAuthService.prototype.register = function (params) {
|
|
2549
2591
|
return __awaiter(this, void 0, void 0, function () {
|
|
2550
|
-
var auth
|
|
2592
|
+
var auth, user, error_1;
|
|
2551
2593
|
return __generator(this, function (_a) {
|
|
2552
2594
|
switch (_a.label) {
|
|
2553
2595
|
case 0:
|
|
2554
|
-
_a.trys.push([0,
|
|
2555
|
-
return [4 /*yield*/,
|
|
2596
|
+
_a.trys.push([0, 2, , 3]);
|
|
2597
|
+
return [4 /*yield*/, this.firebaseAuth.createUserWithEmailAndPassword(params.email, params.password)];
|
|
2556
2598
|
case 1:
|
|
2557
|
-
auth
|
|
2558
|
-
user = auth
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
_a.sent();
|
|
2562
|
-
user.id = auth$1.user.uid;
|
|
2599
|
+
auth = _a.sent();
|
|
2600
|
+
user = auth.user;
|
|
2601
|
+
user.sendEmailVerification();
|
|
2602
|
+
user.id = auth.user.uid;
|
|
2563
2603
|
return [2 /*return*/, user];
|
|
2564
|
-
case
|
|
2604
|
+
case 2:
|
|
2565
2605
|
error_1 = _a.sent();
|
|
2566
2606
|
if (error_1.code === 'auth/email-already-in-use')
|
|
2567
2607
|
throw new UserAlreadyRegisteredError('Email already registered');
|
|
2568
2608
|
if (error_1.code === 'auth/weak-password')
|
|
2569
2609
|
throw new WeakPasswordError();
|
|
2570
2610
|
throw error_1;
|
|
2571
|
-
case
|
|
2611
|
+
case 3: return [2 /*return*/];
|
|
2572
2612
|
}
|
|
2573
2613
|
});
|
|
2574
2614
|
});
|
|
@@ -2588,6 +2628,46 @@
|
|
|
2588
2628
|
enumerable: true,
|
|
2589
2629
|
get: function () { return dateFns.sub; }
|
|
2590
2630
|
});
|
|
2631
|
+
Object.defineProperty(exports, 'chunk', {
|
|
2632
|
+
enumerable: true,
|
|
2633
|
+
get: function () { return lodash.chunk; }
|
|
2634
|
+
});
|
|
2635
|
+
Object.defineProperty(exports, 'get', {
|
|
2636
|
+
enumerable: true,
|
|
2637
|
+
get: function () { return lodash.get; }
|
|
2638
|
+
});
|
|
2639
|
+
Object.defineProperty(exports, 'isDate', {
|
|
2640
|
+
enumerable: true,
|
|
2641
|
+
get: function () { return lodash.isDate; }
|
|
2642
|
+
});
|
|
2643
|
+
Object.defineProperty(exports, 'isEmpty', {
|
|
2644
|
+
enumerable: true,
|
|
2645
|
+
get: function () { return lodash.isEmpty; }
|
|
2646
|
+
});
|
|
2647
|
+
Object.defineProperty(exports, 'isNil', {
|
|
2648
|
+
enumerable: true,
|
|
2649
|
+
get: function () { return lodash.isNil; }
|
|
2650
|
+
});
|
|
2651
|
+
Object.defineProperty(exports, 'isNumber', {
|
|
2652
|
+
enumerable: true,
|
|
2653
|
+
get: function () { return lodash.isNumber; }
|
|
2654
|
+
});
|
|
2655
|
+
Object.defineProperty(exports, 'isObject', {
|
|
2656
|
+
enumerable: true,
|
|
2657
|
+
get: function () { return lodash.isObject; }
|
|
2658
|
+
});
|
|
2659
|
+
Object.defineProperty(exports, 'isString', {
|
|
2660
|
+
enumerable: true,
|
|
2661
|
+
get: function () { return lodash.isString; }
|
|
2662
|
+
});
|
|
2663
|
+
Object.defineProperty(exports, 'pick', {
|
|
2664
|
+
enumerable: true,
|
|
2665
|
+
get: function () { return lodash.pick; }
|
|
2666
|
+
});
|
|
2667
|
+
Object.defineProperty(exports, 'set', {
|
|
2668
|
+
enumerable: true,
|
|
2669
|
+
get: function () { return lodash.set; }
|
|
2670
|
+
});
|
|
2591
2671
|
exports.Address = Address;
|
|
2592
2672
|
exports.Authentication = Authentication;
|
|
2593
2673
|
exports.AuthenticationFirebaseAuthService = AuthenticationFirebaseAuthService;
|
|
@@ -2608,7 +2688,6 @@
|
|
|
2608
2688
|
exports.CouponFirestoreRepository = CouponFirestoreRepository;
|
|
2609
2689
|
exports.DuplicatedResultsError = DuplicatedResultsError;
|
|
2610
2690
|
exports.Edition = Edition;
|
|
2611
|
-
exports.FinancialCoupon = FinancialCoupon;
|
|
2612
2691
|
exports.Home = Home;
|
|
2613
2692
|
exports.HomeFirestoreRepository = HomeFirestoreRepository;
|
|
2614
2693
|
exports.InvalidArgumentError = InvalidArgumentError;
|
|
@@ -2653,16 +2732,6 @@
|
|
|
2653
2732
|
exports.UserSearchFirestoreRepository = UserSearchFirestoreRepository;
|
|
2654
2733
|
exports.Variant = Variant;
|
|
2655
2734
|
exports.WeakPasswordError = WeakPasswordError;
|
|
2656
|
-
exports.chunk = chunk;
|
|
2657
|
-
exports.get = get;
|
|
2658
|
-
exports.isDate = isDate;
|
|
2659
|
-
exports.isEmpty = isEmpty;
|
|
2660
|
-
exports.isNil = isNil;
|
|
2661
|
-
exports.isNumber = isNumber;
|
|
2662
|
-
exports.isObject = isObject;
|
|
2663
|
-
exports.isString = isString;
|
|
2664
|
-
exports.pick = pick;
|
|
2665
|
-
exports.set = set;
|
|
2666
2735
|
exports.withCreateFirestore = withCreateFirestore;
|
|
2667
2736
|
exports.withCrudFirestore = withCrudFirestore;
|
|
2668
2737
|
exports.withDeleteFirestore = withDeleteFirestore;
|