@infrab4a/connect 0.12.0 → 0.13.0-beta.1
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 +72 -24
- package/bundles/infrab4a-connect.umd.js.map +1 -1
- package/esm2015/lib/domain/users/repositories/user.repository.js +1 -1
- package/esm2015/lib/domain/users/use-cases/register.js +6 -1
- package/esm2015/lib/infra/firebase/firestore/models/user-search.js +7 -0
- package/esm2015/lib/infra/firebase/firestore/repositories/users/index.js +2 -1
- package/esm2015/lib/infra/firebase/firestore/repositories/users/user-firestore.repository.js +11 -3
- package/esm2015/lib/infra/firebase/firestore/repositories/users/user-search-firestore.repository.js +12 -0
- package/fesm2015/infrab4a-connect.js +42 -16
- package/fesm2015/infrab4a-connect.js.map +1 -1
- package/lib/domain/users/repositories/user.repository.d.ts +2 -0
- package/lib/infra/firebase/firestore/models/user-search.d.ts +9 -0
- package/lib/infra/firebase/firestore/repositories/users/index.d.ts +1 -0
- package/lib/infra/firebase/firestore/repositories/users/user-firestore.repository.d.ts +4 -1
- package/lib/infra/firebase/firestore/repositories/users/user-search-firestore.repository.d.ts +50 -0
- package/package.json +1 -1
|
@@ -1006,6 +1006,27 @@
|
|
|
1006
1006
|
return Authentication;
|
|
1007
1007
|
}());
|
|
1008
1008
|
|
|
1009
|
+
var UserAlreadyRegisteredError = /** @class */ (function (_super) {
|
|
1010
|
+
__extends(UserAlreadyRegisteredError, _super);
|
|
1011
|
+
function UserAlreadyRegisteredError(message) {
|
|
1012
|
+
var _this = _super.call(this, message) || this;
|
|
1013
|
+
_this.message = message;
|
|
1014
|
+
return _this;
|
|
1015
|
+
}
|
|
1016
|
+
return UserAlreadyRegisteredError;
|
|
1017
|
+
}(Error));
|
|
1018
|
+
|
|
1019
|
+
var WeakPasswordError = /** @class */ (function (_super) {
|
|
1020
|
+
__extends(WeakPasswordError, _super);
|
|
1021
|
+
function WeakPasswordError(message) {
|
|
1022
|
+
if (message === void 0) { message = 'Weak password'; }
|
|
1023
|
+
var _this = _super.call(this, message) || this;
|
|
1024
|
+
_this.message = message;
|
|
1025
|
+
return _this;
|
|
1026
|
+
}
|
|
1027
|
+
return WeakPasswordError;
|
|
1028
|
+
}(Error));
|
|
1029
|
+
|
|
1009
1030
|
var Register = /** @class */ (function () {
|
|
1010
1031
|
function Register(registerService, userRepository) {
|
|
1011
1032
|
this.registerService = registerService;
|
|
@@ -1019,6 +1040,14 @@
|
|
|
1019
1040
|
case 0:
|
|
1020
1041
|
email = params.email.toLocaleLowerCase();
|
|
1021
1042
|
displayName = params.firstName + " " + params.lastName;
|
|
1043
|
+
return [4 /*yield*/, this.userRepository.checkIfExistsByField('cpf', params.cpf)];
|
|
1044
|
+
case 1:
|
|
1045
|
+
if (_a.sent())
|
|
1046
|
+
throw new UserAlreadyRegisteredError("User with CPF " + params.cpf + " already registered");
|
|
1047
|
+
return [4 /*yield*/, this.userRepository.checkIfExistsByField('email', params.email)];
|
|
1048
|
+
case 2:
|
|
1049
|
+
if (_a.sent())
|
|
1050
|
+
throw new UserAlreadyRegisteredError("User with E-mail " + params.email + " already registered");
|
|
1022
1051
|
return [4 /*yield*/, this.registerService.register({
|
|
1023
1052
|
birthday: params.birthday,
|
|
1024
1053
|
email: email,
|
|
@@ -1029,12 +1058,12 @@
|
|
|
1029
1058
|
phone: params.phone,
|
|
1030
1059
|
password: params.password,
|
|
1031
1060
|
})];
|
|
1032
|
-
case
|
|
1061
|
+
case 3:
|
|
1033
1062
|
auth = _a.sent();
|
|
1034
1063
|
delete params.password;
|
|
1035
1064
|
return [4 /*yield*/, this.userRepository.create(Object.assign(Object.assign({}, params), { id: auth.id, email: email,
|
|
1036
1065
|
displayName: displayName, type: exports.UserType.B2C, dateCreated: new Date(), dateModified: new Date() }))];
|
|
1037
|
-
case
|
|
1066
|
+
case 4:
|
|
1038
1067
|
user = _a.sent();
|
|
1039
1068
|
return [2 /*return*/, user];
|
|
1040
1069
|
}
|
|
@@ -1063,27 +1092,6 @@
|
|
|
1063
1092
|
return SignOut;
|
|
1064
1093
|
}());
|
|
1065
1094
|
|
|
1066
|
-
var UserAlreadyRegisteredError = /** @class */ (function (_super) {
|
|
1067
|
-
__extends(UserAlreadyRegisteredError, _super);
|
|
1068
|
-
function UserAlreadyRegisteredError(message) {
|
|
1069
|
-
var _this = _super.call(this, message) || this;
|
|
1070
|
-
_this.message = message;
|
|
1071
|
-
return _this;
|
|
1072
|
-
}
|
|
1073
|
-
return UserAlreadyRegisteredError;
|
|
1074
|
-
}(Error));
|
|
1075
|
-
|
|
1076
|
-
var WeakPasswordError = /** @class */ (function (_super) {
|
|
1077
|
-
__extends(WeakPasswordError, _super);
|
|
1078
|
-
function WeakPasswordError(message) {
|
|
1079
|
-
if (message === void 0) { message = 'Weak password'; }
|
|
1080
|
-
var _this = _super.call(this, message) || this;
|
|
1081
|
-
_this.message = message;
|
|
1082
|
-
return _this;
|
|
1083
|
-
}
|
|
1084
|
-
return WeakPasswordError;
|
|
1085
|
-
}(Error));
|
|
1086
|
-
|
|
1087
1095
|
exports.Shops = void 0;
|
|
1088
1096
|
(function (Shops) {
|
|
1089
1097
|
Shops["MENSMARKET"] = "mensmarket";
|
|
@@ -1816,11 +1824,36 @@
|
|
|
1816
1824
|
return SubscriptionFirestoreRepository;
|
|
1817
1825
|
}(withCrudFirestore(withHelpers(withFirestore(Base)))));
|
|
1818
1826
|
|
|
1827
|
+
var UserSearch = /** @class */ (function (_super) {
|
|
1828
|
+
__extends(UserSearch, _super);
|
|
1829
|
+
function UserSearch() {
|
|
1830
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
1831
|
+
}
|
|
1832
|
+
UserSearch.prototype.identifierFields = function () {
|
|
1833
|
+
return ['id'];
|
|
1834
|
+
};
|
|
1835
|
+
return UserSearch;
|
|
1836
|
+
}(BaseModel));
|
|
1837
|
+
|
|
1838
|
+
var UserSearchFirestoreRepository = /** @class */ (function (_super) {
|
|
1839
|
+
__extends(UserSearchFirestoreRepository, _super);
|
|
1840
|
+
function UserSearchFirestoreRepository(firestore) {
|
|
1841
|
+
var _this = _super.call(this) || this;
|
|
1842
|
+
_this.firestore = firestore;
|
|
1843
|
+
_this.collectionName = 'userSearch';
|
|
1844
|
+
_this.model = UserSearch;
|
|
1845
|
+
return _this;
|
|
1846
|
+
}
|
|
1847
|
+
return UserSearchFirestoreRepository;
|
|
1848
|
+
}(withCrudFirestore(withHelpers(withFirestore(Base)))));
|
|
1849
|
+
|
|
1819
1850
|
var UserFirestoreRepository = /** @class */ (function (_super_1) {
|
|
1820
1851
|
__extends(UserFirestoreRepository, _super_1);
|
|
1821
|
-
function UserFirestoreRepository(firestore) {
|
|
1852
|
+
function UserFirestoreRepository(firestore, userSearchFirestoreRepository) {
|
|
1853
|
+
if (userSearchFirestoreRepository === void 0) { userSearchFirestoreRepository = new UserSearchFirestoreRepository(firestore); }
|
|
1822
1854
|
var _this = _super_1.call(this) || this;
|
|
1823
1855
|
_this.firestore = firestore;
|
|
1856
|
+
_this.userSearchFirestoreRepository = userSearchFirestoreRepository;
|
|
1824
1857
|
_this.collectionName = 'users';
|
|
1825
1858
|
_this.model = User;
|
|
1826
1859
|
return _this;
|
|
@@ -1849,6 +1882,20 @@
|
|
|
1849
1882
|
});
|
|
1850
1883
|
});
|
|
1851
1884
|
};
|
|
1885
|
+
UserFirestoreRepository.prototype.checkIfExistsByField = function (field, value) {
|
|
1886
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1887
|
+
var result;
|
|
1888
|
+
var _a;
|
|
1889
|
+
return __generator(this, function (_b) {
|
|
1890
|
+
switch (_b.label) {
|
|
1891
|
+
case 0: return [4 /*yield*/, this.userSearchFirestoreRepository.find([(_a = {}, _a[field] = { operator: exports.Where.EQUALS, value: value }, _a)])];
|
|
1892
|
+
case 1:
|
|
1893
|
+
result = _b.sent();
|
|
1894
|
+
return [2 /*return*/, result.count > 0];
|
|
1895
|
+
}
|
|
1896
|
+
});
|
|
1897
|
+
});
|
|
1898
|
+
};
|
|
1852
1899
|
UserFirestoreRepository.prototype.buildModelInstance = function () {
|
|
1853
1900
|
var _a = _super_1.prototype.buildModelInstance.call(this), fromFirestore = _a.fromFirestore, toFirestore = _a.toFirestore;
|
|
1854
1901
|
return {
|
|
@@ -2496,6 +2543,7 @@
|
|
|
2496
2543
|
exports.UserFirestoreRepository = UserFirestoreRepository;
|
|
2497
2544
|
exports.UserPaymentMethod = UserPaymentMethod;
|
|
2498
2545
|
exports.UserPaymentMethodFirestoreRepository = UserPaymentMethodFirestoreRepository;
|
|
2546
|
+
exports.UserSearchFirestoreRepository = UserSearchFirestoreRepository;
|
|
2499
2547
|
exports.Variant = Variant;
|
|
2500
2548
|
exports.WeakPasswordError = WeakPasswordError;
|
|
2501
2549
|
exports.withCreateFirestore = withCreateFirestore;
|