@infrab4a/connect 4.3.0-beta.3 → 4.3.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs.js +391 -363
- package/index.esm.js +389 -363
- package/package.json +1 -1
- package/src/domain/general/index.d.ts +1 -0
- package/src/domain/general/storage/file-uploader.service.d.ts +3 -0
- package/src/domain/general/storage/index.d.ts +1 -0
- package/src/domain/index.d.ts +4 -3
- package/src/domain/users/use-cases/index.d.ts +2 -1
- package/src/domain/users/use-cases/update-user-image.d.ts +9 -0
- package/src/infra/firebase/index.d.ts +2 -1
- package/src/infra/firebase/storage/firebase-file-uploader.service.d.ts +8 -0
- package/src/infra/firebase/storage/index.d.ts +1 -0
package/index.cjs.js
CHANGED
|
@@ -3,15 +3,16 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
require('reflect-metadata');
|
|
6
|
-
var classTransformer = require('class-transformer');
|
|
7
6
|
var tslib_1 = require('tslib');
|
|
7
|
+
var classTransformer = require('class-transformer');
|
|
8
8
|
var dateFns = require('date-fns');
|
|
9
9
|
var lodash = require('lodash');
|
|
10
10
|
var debug = require('debug');
|
|
11
11
|
var tsCustomError = require('ts-custom-error');
|
|
12
12
|
var axios = require('axios');
|
|
13
|
-
var firestore = require('firebase/firestore');
|
|
14
13
|
var auth = require('firebase/auth');
|
|
14
|
+
var firestore = require('firebase/firestore');
|
|
15
|
+
var storage = require('firebase/storage');
|
|
15
16
|
var gqlQueryBuilder = require('gql-query-builder');
|
|
16
17
|
|
|
17
18
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -60,6 +61,187 @@ class BaseModel {
|
|
|
60
61
|
}
|
|
61
62
|
}
|
|
62
63
|
|
|
64
|
+
class Filter extends BaseModel {
|
|
65
|
+
static get identifiersFields() {
|
|
66
|
+
return ['id'];
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
class CategoryBase extends BaseModel {
|
|
71
|
+
static get identifiersFields() {
|
|
72
|
+
return ['id'];
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
tslib_1.__decorate([
|
|
76
|
+
classTransformer.Type(() => CategoryBase),
|
|
77
|
+
tslib_1.__metadata("design:type", CategoryBase)
|
|
78
|
+
], CategoryBase.prototype, "parent", void 0);
|
|
79
|
+
tslib_1.__decorate([
|
|
80
|
+
classTransformer.Type(() => Filter),
|
|
81
|
+
tslib_1.__metadata("design:type", Array)
|
|
82
|
+
], CategoryBase.prototype, "filters", void 0);
|
|
83
|
+
|
|
84
|
+
class CategoryForProduct extends CategoryBase {
|
|
85
|
+
static get identifiersFields() {
|
|
86
|
+
return ['id'];
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
class ProductBase extends BaseModel {
|
|
91
|
+
get evaluation() {
|
|
92
|
+
return {
|
|
93
|
+
reviews: this.reviews,
|
|
94
|
+
count: this.reviewsTotal,
|
|
95
|
+
rating: this.rate,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
set evaluation(evaluation) {
|
|
99
|
+
if (!evaluation) {
|
|
100
|
+
this.reviews = null;
|
|
101
|
+
this.reviewsTotal = null;
|
|
102
|
+
this.rate = null;
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
this.reviews = evaluation.reviews || this.reviews;
|
|
106
|
+
this.reviewsTotal = evaluation.count || this.reviewsTotal;
|
|
107
|
+
this.rate = evaluation.rating || this.rate;
|
|
108
|
+
}
|
|
109
|
+
static get identifiersFields() {
|
|
110
|
+
return ['id'];
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
class ProductForKit extends ProductBase {
|
|
115
|
+
static get identifiersFields() {
|
|
116
|
+
return ['id'];
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
tslib_1.__decorate([
|
|
120
|
+
classTransformer.Type(() => CategoryForProduct),
|
|
121
|
+
tslib_1.__metadata("design:type", CategoryForProduct)
|
|
122
|
+
], ProductForKit.prototype, "category", void 0);
|
|
123
|
+
|
|
124
|
+
class KitProduct extends BaseModel {
|
|
125
|
+
static get identifiersFields() {
|
|
126
|
+
return ['productId', 'kitProductId'];
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
tslib_1.__decorate([
|
|
130
|
+
classTransformer.Type(() => ProductForKit),
|
|
131
|
+
tslib_1.__metadata("design:type", ProductForKit)
|
|
132
|
+
], KitProduct.prototype, "kit", void 0);
|
|
133
|
+
tslib_1.__decorate([
|
|
134
|
+
classTransformer.Type(() => ProductForKit),
|
|
135
|
+
tslib_1.__metadata("design:type", ProductForKit)
|
|
136
|
+
], KitProduct.prototype, "product", void 0);
|
|
137
|
+
|
|
138
|
+
class ProductForCategory extends ProductBase {
|
|
139
|
+
static get identifiersFields() {
|
|
140
|
+
return ['id'];
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
tslib_1.__decorate([
|
|
144
|
+
classTransformer.Type(() => KitProduct),
|
|
145
|
+
tslib_1.__metadata("design:type", Array)
|
|
146
|
+
], ProductForCategory.prototype, "kitProducts", void 0);
|
|
147
|
+
|
|
148
|
+
class Category extends CategoryBase {
|
|
149
|
+
static get identifiersFields() {
|
|
150
|
+
return ['id'];
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
tslib_1.__decorate([
|
|
154
|
+
classTransformer.Type(() => ProductForCategory),
|
|
155
|
+
tslib_1.__metadata("design:type", Array)
|
|
156
|
+
], Category.prototype, "childrenProducts", void 0);
|
|
157
|
+
|
|
158
|
+
class CategoryCollectionChildren extends BaseModel {
|
|
159
|
+
static get identifiersFields() {
|
|
160
|
+
return ['collectionId', 'categoryId'];
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
tslib_1.__decorate([
|
|
164
|
+
classTransformer.Type(() => CategoryCollectionChildren),
|
|
165
|
+
tslib_1.__metadata("design:type", CategoryCollectionChildren)
|
|
166
|
+
], CategoryCollectionChildren.prototype, "parent", void 0);
|
|
167
|
+
|
|
168
|
+
class CategoryFilter extends BaseModel {
|
|
169
|
+
static get identifiersFields() {
|
|
170
|
+
return ['id'];
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
tslib_1.__decorate([
|
|
174
|
+
classTransformer.Type(() => Filter),
|
|
175
|
+
tslib_1.__metadata("design:type", Filter)
|
|
176
|
+
], CategoryFilter.prototype, "filter", void 0);
|
|
177
|
+
tslib_1.__decorate([
|
|
178
|
+
classTransformer.Type(() => Category),
|
|
179
|
+
tslib_1.__metadata("design:type", Category)
|
|
180
|
+
], CategoryFilter.prototype, "category", void 0);
|
|
181
|
+
|
|
182
|
+
exports.GenderDestination = void 0;
|
|
183
|
+
(function (GenderDestination) {
|
|
184
|
+
GenderDestination["FEMALE"] = "female";
|
|
185
|
+
GenderDestination["MALE"] = "male";
|
|
186
|
+
GenderDestination["UNISEX"] = "unisex";
|
|
187
|
+
})(exports.GenderDestination || (exports.GenderDestination = {}));
|
|
188
|
+
|
|
189
|
+
exports.Shops = void 0;
|
|
190
|
+
(function (Shops) {
|
|
191
|
+
Shops["MENSMARKET"] = "mensmarket";
|
|
192
|
+
Shops["GLAMSHOP"] = "Glamshop";
|
|
193
|
+
Shops["GLAMPOINTS"] = "Glampoints";
|
|
194
|
+
Shops["ALL"] = "ALL";
|
|
195
|
+
})(exports.Shops || (exports.Shops = {}));
|
|
196
|
+
|
|
197
|
+
class FilterOption extends BaseModel {
|
|
198
|
+
static get identifiersFields() {
|
|
199
|
+
return ['id'];
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
class Product extends ProductBase {
|
|
204
|
+
static get identifiersFields() {
|
|
205
|
+
return ['id'];
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
tslib_1.__decorate([
|
|
209
|
+
classTransformer.Type(() => CategoryForProduct),
|
|
210
|
+
tslib_1.__metadata("design:type", CategoryForProduct)
|
|
211
|
+
], Product.prototype, "category", void 0);
|
|
212
|
+
tslib_1.__decorate([
|
|
213
|
+
classTransformer.Type(() => KitProduct),
|
|
214
|
+
tslib_1.__metadata("design:type", Array)
|
|
215
|
+
], Product.prototype, "kitProducts", void 0);
|
|
216
|
+
|
|
217
|
+
class ProductReviews extends BaseModel {
|
|
218
|
+
static get identifiersFields() {
|
|
219
|
+
return ['id'];
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
class Variant extends BaseModel {
|
|
224
|
+
static get identifiersFields() {
|
|
225
|
+
return ['id', 'productId'];
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
class Wishlist extends Category {
|
|
230
|
+
static get identifiersFields() {
|
|
231
|
+
return ['id'];
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
class Buy2Win extends BaseModel {
|
|
236
|
+
static get identifiersFields() {
|
|
237
|
+
return ['id'];
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
tslib_1.__decorate([
|
|
241
|
+
classTransformer.Type(() => Category),
|
|
242
|
+
tslib_1.__metadata("design:type", Array)
|
|
243
|
+
], Buy2Win.prototype, "categories", void 0);
|
|
244
|
+
|
|
63
245
|
exports.Where = void 0;
|
|
64
246
|
(function (Where) {
|
|
65
247
|
Where["EQUALS"] = "==";
|
|
@@ -85,6 +267,18 @@ exports.UpdateOptionActions = void 0;
|
|
|
85
267
|
UpdateOptionActions["NULL"] = "null";
|
|
86
268
|
})(exports.UpdateOptionActions || (exports.UpdateOptionActions = {}));
|
|
87
269
|
|
|
270
|
+
class CampaignDashboard extends BaseModel {
|
|
271
|
+
static get identifiersFields() {
|
|
272
|
+
return ['id'];
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
class CampaignHashtag extends BaseModel {
|
|
277
|
+
static get identifiersFields() {
|
|
278
|
+
return ['id'];
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
88
282
|
exports.AccessoryImportances = void 0;
|
|
89
283
|
(function (AccessoryImportances) {
|
|
90
284
|
AccessoryImportances["NOT_INTERESTED"] = "N\u00E3o tenho interesse";
|
|
@@ -1878,196 +2072,166 @@ tslib_1.__decorate([
|
|
|
1878
2072
|
tslib_1.__metadata("design:type", Array)
|
|
1879
2073
|
], Subscription.prototype, "payment", void 0);
|
|
1880
2074
|
|
|
1881
|
-
class
|
|
1882
|
-
static get identifiersFields() {
|
|
1883
|
-
return ['id'];
|
|
1884
|
-
}
|
|
1885
|
-
}
|
|
1886
|
-
|
|
1887
|
-
class CategoryBase extends BaseModel {
|
|
2075
|
+
class SubscriptionMaterialization extends BaseModel {
|
|
1888
2076
|
static get identifiersFields() {
|
|
1889
2077
|
return ['id'];
|
|
1890
2078
|
}
|
|
1891
2079
|
}
|
|
1892
2080
|
tslib_1.__decorate([
|
|
1893
|
-
classTransformer.Type(() =>
|
|
1894
|
-
tslib_1.__metadata("design:type",
|
|
1895
|
-
],
|
|
2081
|
+
classTransformer.Type(() => User),
|
|
2082
|
+
tslib_1.__metadata("design:type", User)
|
|
2083
|
+
], SubscriptionMaterialization.prototype, "user", void 0);
|
|
1896
2084
|
tslib_1.__decorate([
|
|
1897
|
-
classTransformer.Type(() =>
|
|
2085
|
+
classTransformer.Type(() => SubscriptionPlan),
|
|
2086
|
+
tslib_1.__metadata("design:type", SubscriptionPlan)
|
|
2087
|
+
], SubscriptionMaterialization.prototype, "subscriptionPlan", void 0);
|
|
2088
|
+
tslib_1.__decorate([
|
|
2089
|
+
classTransformer.Type(() => UserAddress),
|
|
2090
|
+
tslib_1.__metadata("design:type", UserAddress)
|
|
2091
|
+
], SubscriptionMaterialization.prototype, "shippingAddress", void 0);
|
|
2092
|
+
tslib_1.__decorate([
|
|
2093
|
+
classTransformer.Type(() => UserAddress),
|
|
2094
|
+
tslib_1.__metadata("design:type", UserAddress)
|
|
2095
|
+
], SubscriptionMaterialization.prototype, "billingAddress", void 0);
|
|
2096
|
+
tslib_1.__decorate([
|
|
2097
|
+
classTransformer.Type(() => Coupon),
|
|
2098
|
+
tslib_1.__metadata("design:type", Coupon)
|
|
2099
|
+
], SubscriptionMaterialization.prototype, "coupon", void 0);
|
|
2100
|
+
tslib_1.__decorate([
|
|
2101
|
+
classTransformer.Type(() => Edition),
|
|
1898
2102
|
tslib_1.__metadata("design:type", Array)
|
|
1899
|
-
],
|
|
2103
|
+
], SubscriptionMaterialization.prototype, "editions", void 0);
|
|
2104
|
+
tslib_1.__decorate([
|
|
2105
|
+
classTransformer.Type(() => SubscriptionPayment),
|
|
2106
|
+
tslib_1.__metadata("design:type", SubscriptionPayment)
|
|
2107
|
+
], SubscriptionMaterialization.prototype, "payment", void 0);
|
|
1900
2108
|
|
|
1901
|
-
class
|
|
2109
|
+
class SubscriptionSummary extends BaseModel {
|
|
1902
2110
|
static get identifiersFields() {
|
|
1903
2111
|
return ['id'];
|
|
1904
2112
|
}
|
|
1905
2113
|
}
|
|
1906
2114
|
|
|
1907
|
-
class
|
|
1908
|
-
get
|
|
1909
|
-
return
|
|
1910
|
-
reviews: this.reviews,
|
|
1911
|
-
count: this.reviewsTotal,
|
|
1912
|
-
rating: this.rate,
|
|
1913
|
-
};
|
|
1914
|
-
}
|
|
1915
|
-
set evaluation(evaluation) {
|
|
1916
|
-
if (!evaluation) {
|
|
1917
|
-
this.reviews = null;
|
|
1918
|
-
this.reviewsTotal = null;
|
|
1919
|
-
this.rate = null;
|
|
1920
|
-
return;
|
|
1921
|
-
}
|
|
1922
|
-
this.reviews = evaluation.reviews || this.reviews;
|
|
1923
|
-
this.reviewsTotal = evaluation.count || this.reviewsTotal;
|
|
1924
|
-
this.rate = evaluation.rating || this.rate;
|
|
1925
|
-
}
|
|
1926
|
-
static get identifiersFields() {
|
|
1927
|
-
return ['id'];
|
|
2115
|
+
class UserPaymentMethod extends BaseModel {
|
|
2116
|
+
static get identifiersFields() {
|
|
2117
|
+
return ['id', 'userId'];
|
|
1928
2118
|
}
|
|
1929
2119
|
}
|
|
1930
2120
|
|
|
1931
|
-
class
|
|
2121
|
+
class Lead extends BaseModel {
|
|
1932
2122
|
static get identifiersFields() {
|
|
1933
2123
|
return ['id'];
|
|
1934
2124
|
}
|
|
1935
|
-
}
|
|
1936
|
-
tslib_1.__decorate([
|
|
1937
|
-
classTransformer.Type(() => CategoryForProduct),
|
|
1938
|
-
tslib_1.__metadata("design:type", CategoryForProduct)
|
|
1939
|
-
], ProductForKit.prototype, "category", void 0);
|
|
1940
|
-
|
|
1941
|
-
class KitProduct extends BaseModel {
|
|
1942
|
-
static get identifiersFields() {
|
|
1943
|
-
return ['productId', 'kitProductId'];
|
|
1944
|
-
}
|
|
1945
|
-
}
|
|
1946
|
-
tslib_1.__decorate([
|
|
1947
|
-
classTransformer.Type(() => ProductForKit),
|
|
1948
|
-
tslib_1.__metadata("design:type", ProductForKit)
|
|
1949
|
-
], KitProduct.prototype, "kit", void 0);
|
|
1950
|
-
tslib_1.__decorate([
|
|
1951
|
-
classTransformer.Type(() => ProductForKit),
|
|
1952
|
-
tslib_1.__metadata("design:type", ProductForKit)
|
|
1953
|
-
], KitProduct.prototype, "product", void 0);
|
|
2125
|
+
}
|
|
1954
2126
|
|
|
1955
|
-
class
|
|
1956
|
-
|
|
1957
|
-
|
|
2127
|
+
class UnauthorizedError extends tsCustomError.CustomError {
|
|
2128
|
+
constructor(message) {
|
|
2129
|
+
super(message);
|
|
1958
2130
|
}
|
|
1959
|
-
}
|
|
1960
|
-
tslib_1.__decorate([
|
|
1961
|
-
classTransformer.Type(() => KitProduct),
|
|
1962
|
-
tslib_1.__metadata("design:type", Array)
|
|
1963
|
-
], ProductForCategory.prototype, "kitProducts", void 0);
|
|
2131
|
+
}
|
|
1964
2132
|
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
2133
|
+
exports.SignInMethods = void 0;
|
|
2134
|
+
(function (SignInMethods) {
|
|
2135
|
+
SignInMethods["EMAIL_PASSWORD"] = "email_password";
|
|
2136
|
+
SignInMethods["GOOGLE"] = "google";
|
|
2137
|
+
})(exports.SignInMethods || (exports.SignInMethods = {}));
|
|
2138
|
+
class Authentication {
|
|
2139
|
+
constructor(authService, userRepository) {
|
|
2140
|
+
this.authService = authService;
|
|
2141
|
+
this.userRepository = userRepository;
|
|
1968
2142
|
}
|
|
1969
|
-
}
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
2143
|
+
async signIn({ email, password }, signInMethod) {
|
|
2144
|
+
const method = this.getServiceByMethod(signInMethod);
|
|
2145
|
+
const userAuth = await this.authService[method]({ email, password });
|
|
2146
|
+
const user = this.userRepository.get({ id: userAuth.id });
|
|
2147
|
+
if (!lodash.isNil(user))
|
|
2148
|
+
return user;
|
|
2149
|
+
if (/^.+@b4a.com.br$/.test(userAuth.email))
|
|
2150
|
+
return this.createsUserByCredential(userAuth);
|
|
2151
|
+
throw new UnauthorizedError('Invalid credentials');
|
|
1978
2152
|
}
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
classTransformer.Type(() => CategoryCollectionChildren),
|
|
1982
|
-
tslib_1.__metadata("design:type", CategoryCollectionChildren)
|
|
1983
|
-
], CategoryCollectionChildren.prototype, "parent", void 0);
|
|
1984
|
-
|
|
1985
|
-
class CategoryFilter extends BaseModel {
|
|
1986
|
-
static get identifiersFields() {
|
|
1987
|
-
return ['id'];
|
|
2153
|
+
getServiceByMethod(signInMethod) {
|
|
2154
|
+
return signInMethod === exports.SignInMethods.EMAIL_PASSWORD ? 'signInWithEmailAndPassword' : 'signInWithGoogle';
|
|
1988
2155
|
}
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
classTransformer.Type(() => Category),
|
|
1996
|
-
tslib_1.__metadata("design:type", Category)
|
|
1997
|
-
], CategoryFilter.prototype, "category", void 0);
|
|
1998
|
-
|
|
1999
|
-
exports.GenderDestination = void 0;
|
|
2000
|
-
(function (GenderDestination) {
|
|
2001
|
-
GenderDestination["FEMALE"] = "female";
|
|
2002
|
-
GenderDestination["MALE"] = "male";
|
|
2003
|
-
GenderDestination["UNISEX"] = "unisex";
|
|
2004
|
-
})(exports.GenderDestination || (exports.GenderDestination = {}));
|
|
2005
|
-
|
|
2006
|
-
exports.Shops = void 0;
|
|
2007
|
-
(function (Shops) {
|
|
2008
|
-
Shops["MENSMARKET"] = "mensmarket";
|
|
2009
|
-
Shops["GLAMSHOP"] = "Glamshop";
|
|
2010
|
-
Shops["GLAMPOINTS"] = "Glampoints";
|
|
2011
|
-
Shops["ALL"] = "ALL";
|
|
2012
|
-
})(exports.Shops || (exports.Shops = {}));
|
|
2013
|
-
|
|
2014
|
-
class FilterOption extends BaseModel {
|
|
2015
|
-
static get identifiersFields() {
|
|
2016
|
-
return ['id'];
|
|
2156
|
+
async createsUserByCredential(user) {
|
|
2157
|
+
var _a;
|
|
2158
|
+
const [firstName, lastName] = (_a = user.displayName) === null || _a === void 0 ? void 0 : _a.split(/\s/);
|
|
2159
|
+
const person = User.toInstance(Object.assign(Object.assign({}, user), { cpf: '', birthday: new Date(), firstName,
|
|
2160
|
+
lastName, acceptsNewsletter: false, area: exports.Area.Transactional, officePosition: exports.OfficePosition.Intern, type: exports.UserType.Collaborator }));
|
|
2161
|
+
return this.userRepository.create(person);
|
|
2017
2162
|
}
|
|
2018
2163
|
}
|
|
2019
2164
|
|
|
2020
|
-
class
|
|
2021
|
-
|
|
2022
|
-
|
|
2165
|
+
class RecoveryPassword {
|
|
2166
|
+
constructor(authService) {
|
|
2167
|
+
this.authService = authService;
|
|
2023
2168
|
}
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
classTransformer.Type(() => CategoryForProduct),
|
|
2027
|
-
tslib_1.__metadata("design:type", CategoryForProduct)
|
|
2028
|
-
], Product.prototype, "category", void 0);
|
|
2029
|
-
tslib_1.__decorate([
|
|
2030
|
-
classTransformer.Type(() => KitProduct),
|
|
2031
|
-
tslib_1.__metadata("design:type", Array)
|
|
2032
|
-
], Product.prototype, "kitProducts", void 0);
|
|
2033
|
-
|
|
2034
|
-
class ProductReviews extends BaseModel {
|
|
2035
|
-
static get identifiersFields() {
|
|
2036
|
-
return ['id'];
|
|
2169
|
+
async sendEmail(email) {
|
|
2170
|
+
await this.authService.sendPasswordResetEmail(email);
|
|
2037
2171
|
}
|
|
2038
2172
|
}
|
|
2039
2173
|
|
|
2040
|
-
class
|
|
2041
|
-
|
|
2042
|
-
|
|
2174
|
+
class UserAlreadyRegisteredError extends tsCustomError.CustomError {
|
|
2175
|
+
constructor(message) {
|
|
2176
|
+
super(message);
|
|
2043
2177
|
}
|
|
2044
2178
|
}
|
|
2045
2179
|
|
|
2046
|
-
class
|
|
2047
|
-
|
|
2048
|
-
|
|
2180
|
+
class WeakPasswordError extends tsCustomError.CustomError {
|
|
2181
|
+
constructor(message = 'Weak password') {
|
|
2182
|
+
super(message);
|
|
2049
2183
|
}
|
|
2050
2184
|
}
|
|
2051
2185
|
|
|
2052
|
-
class
|
|
2053
|
-
|
|
2054
|
-
|
|
2186
|
+
class Register {
|
|
2187
|
+
constructor(registerService, userRepository) {
|
|
2188
|
+
this.registerService = registerService;
|
|
2189
|
+
this.userRepository = userRepository;
|
|
2055
2190
|
}
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2191
|
+
async register(params) {
|
|
2192
|
+
const email = params.email.toLocaleLowerCase();
|
|
2193
|
+
const displayName = `${params.firstName} ${params.lastName}`;
|
|
2194
|
+
if (await this.userRepository.checkIfExistsByField('cpf', params.cpf))
|
|
2195
|
+
throw new UserAlreadyRegisteredError(`Usuário com CPF ${params.cpf} já registrado.`);
|
|
2196
|
+
if (await this.userRepository.checkIfExistsByField('email', params.email))
|
|
2197
|
+
throw new UserAlreadyRegisteredError(`Usuário com e-mail ${params.email} já registrado.`);
|
|
2198
|
+
const auth = await this.registerService.register({
|
|
2199
|
+
birthday: params.birthday,
|
|
2200
|
+
email,
|
|
2201
|
+
firstName: params.firstName,
|
|
2202
|
+
lastName: params.lastName,
|
|
2203
|
+
cpf: params.cpf,
|
|
2204
|
+
displayName,
|
|
2205
|
+
phone: params.phone,
|
|
2206
|
+
password: params.password,
|
|
2207
|
+
});
|
|
2208
|
+
delete params.password;
|
|
2209
|
+
const user = await this.userRepository.create(Object.assign(Object.assign({}, params), { id: auth.id, email,
|
|
2210
|
+
displayName, type: exports.UserType.B2C, dateCreated: new Date(), dateModified: new Date() }));
|
|
2211
|
+
return user;
|
|
2212
|
+
}
|
|
2213
|
+
}
|
|
2061
2214
|
|
|
2062
|
-
class
|
|
2063
|
-
|
|
2064
|
-
|
|
2215
|
+
class SignOut {
|
|
2216
|
+
constructor(authService) {
|
|
2217
|
+
this.authService = authService;
|
|
2218
|
+
}
|
|
2219
|
+
async signOut() {
|
|
2220
|
+
await this.authService.signOut();
|
|
2065
2221
|
}
|
|
2066
2222
|
}
|
|
2067
2223
|
|
|
2068
|
-
class
|
|
2069
|
-
|
|
2070
|
-
|
|
2224
|
+
class UpdateUserImage {
|
|
2225
|
+
constructor(userRepository, fileUploader) {
|
|
2226
|
+
this.userRepository = userRepository;
|
|
2227
|
+
this.fileUploader = fileUploader;
|
|
2228
|
+
}
|
|
2229
|
+
async execute(file, user) {
|
|
2230
|
+
const extension = file.type.split('/').pop();
|
|
2231
|
+
const path = `users/${user.id}/profile.${extension}`;
|
|
2232
|
+
const url = await this.fileUploader.upload(path, file);
|
|
2233
|
+
user.urlImageProfile = url;
|
|
2234
|
+
return this.userRepository.update(user);
|
|
2071
2235
|
}
|
|
2072
2236
|
}
|
|
2073
2237
|
|
|
@@ -2151,155 +2315,6 @@ tslib_1.__decorate([
|
|
|
2151
2315
|
tslib_1.__metadata("design:type", Coupon)
|
|
2152
2316
|
], CheckoutSubscription.prototype, "coupon", void 0);
|
|
2153
2317
|
|
|
2154
|
-
class SubscriptionMaterialization extends BaseModel {
|
|
2155
|
-
static get identifiersFields() {
|
|
2156
|
-
return ['id'];
|
|
2157
|
-
}
|
|
2158
|
-
}
|
|
2159
|
-
tslib_1.__decorate([
|
|
2160
|
-
classTransformer.Type(() => User),
|
|
2161
|
-
tslib_1.__metadata("design:type", User)
|
|
2162
|
-
], SubscriptionMaterialization.prototype, "user", void 0);
|
|
2163
|
-
tslib_1.__decorate([
|
|
2164
|
-
classTransformer.Type(() => SubscriptionPlan),
|
|
2165
|
-
tslib_1.__metadata("design:type", SubscriptionPlan)
|
|
2166
|
-
], SubscriptionMaterialization.prototype, "subscriptionPlan", void 0);
|
|
2167
|
-
tslib_1.__decorate([
|
|
2168
|
-
classTransformer.Type(() => UserAddress),
|
|
2169
|
-
tslib_1.__metadata("design:type", UserAddress)
|
|
2170
|
-
], SubscriptionMaterialization.prototype, "shippingAddress", void 0);
|
|
2171
|
-
tslib_1.__decorate([
|
|
2172
|
-
classTransformer.Type(() => UserAddress),
|
|
2173
|
-
tslib_1.__metadata("design:type", UserAddress)
|
|
2174
|
-
], SubscriptionMaterialization.prototype, "billingAddress", void 0);
|
|
2175
|
-
tslib_1.__decorate([
|
|
2176
|
-
classTransformer.Type(() => Coupon),
|
|
2177
|
-
tslib_1.__metadata("design:type", Coupon)
|
|
2178
|
-
], SubscriptionMaterialization.prototype, "coupon", void 0);
|
|
2179
|
-
tslib_1.__decorate([
|
|
2180
|
-
classTransformer.Type(() => Edition),
|
|
2181
|
-
tslib_1.__metadata("design:type", Array)
|
|
2182
|
-
], SubscriptionMaterialization.prototype, "editions", void 0);
|
|
2183
|
-
tslib_1.__decorate([
|
|
2184
|
-
classTransformer.Type(() => SubscriptionPayment),
|
|
2185
|
-
tslib_1.__metadata("design:type", SubscriptionPayment)
|
|
2186
|
-
], SubscriptionMaterialization.prototype, "payment", void 0);
|
|
2187
|
-
|
|
2188
|
-
class SubscriptionSummary extends BaseModel {
|
|
2189
|
-
static get identifiersFields() {
|
|
2190
|
-
return ['id'];
|
|
2191
|
-
}
|
|
2192
|
-
}
|
|
2193
|
-
|
|
2194
|
-
class UserPaymentMethod extends BaseModel {
|
|
2195
|
-
static get identifiersFields() {
|
|
2196
|
-
return ['id', 'userId'];
|
|
2197
|
-
}
|
|
2198
|
-
}
|
|
2199
|
-
|
|
2200
|
-
class Lead extends BaseModel {
|
|
2201
|
-
static get identifiersFields() {
|
|
2202
|
-
return ['id'];
|
|
2203
|
-
}
|
|
2204
|
-
}
|
|
2205
|
-
|
|
2206
|
-
class UnauthorizedError extends tsCustomError.CustomError {
|
|
2207
|
-
constructor(message) {
|
|
2208
|
-
super(message);
|
|
2209
|
-
}
|
|
2210
|
-
}
|
|
2211
|
-
|
|
2212
|
-
exports.SignInMethods = void 0;
|
|
2213
|
-
(function (SignInMethods) {
|
|
2214
|
-
SignInMethods["EMAIL_PASSWORD"] = "email_password";
|
|
2215
|
-
SignInMethods["GOOGLE"] = "google";
|
|
2216
|
-
})(exports.SignInMethods || (exports.SignInMethods = {}));
|
|
2217
|
-
class Authentication {
|
|
2218
|
-
constructor(authService, userRepository) {
|
|
2219
|
-
this.authService = authService;
|
|
2220
|
-
this.userRepository = userRepository;
|
|
2221
|
-
}
|
|
2222
|
-
async signIn({ email, password }, signInMethod) {
|
|
2223
|
-
const method = this.getServiceByMethod(signInMethod);
|
|
2224
|
-
const userAuth = await this.authService[method]({ email, password });
|
|
2225
|
-
const user = this.userRepository.get({ id: userAuth.id });
|
|
2226
|
-
if (!lodash.isNil(user))
|
|
2227
|
-
return user;
|
|
2228
|
-
if (/^.+@b4a.com.br$/.test(userAuth.email))
|
|
2229
|
-
return this.createsUserByCredential(userAuth);
|
|
2230
|
-
throw new UnauthorizedError('Invalid credentials');
|
|
2231
|
-
}
|
|
2232
|
-
getServiceByMethod(signInMethod) {
|
|
2233
|
-
return signInMethod === exports.SignInMethods.EMAIL_PASSWORD ? 'signInWithEmailAndPassword' : 'signInWithGoogle';
|
|
2234
|
-
}
|
|
2235
|
-
async createsUserByCredential(user) {
|
|
2236
|
-
var _a;
|
|
2237
|
-
const [firstName, lastName] = (_a = user.displayName) === null || _a === void 0 ? void 0 : _a.split(/\s/);
|
|
2238
|
-
const person = User.toInstance(Object.assign(Object.assign({}, user), { cpf: '', birthday: new Date(), firstName,
|
|
2239
|
-
lastName, acceptsNewsletter: false, area: exports.Area.Transactional, officePosition: exports.OfficePosition.Intern, type: exports.UserType.Collaborator }));
|
|
2240
|
-
return this.userRepository.create(person);
|
|
2241
|
-
}
|
|
2242
|
-
}
|
|
2243
|
-
|
|
2244
|
-
class UserAlreadyRegisteredError extends tsCustomError.CustomError {
|
|
2245
|
-
constructor(message) {
|
|
2246
|
-
super(message);
|
|
2247
|
-
}
|
|
2248
|
-
}
|
|
2249
|
-
|
|
2250
|
-
class WeakPasswordError extends tsCustomError.CustomError {
|
|
2251
|
-
constructor(message = 'Weak password') {
|
|
2252
|
-
super(message);
|
|
2253
|
-
}
|
|
2254
|
-
}
|
|
2255
|
-
|
|
2256
|
-
class Register {
|
|
2257
|
-
constructor(registerService, userRepository) {
|
|
2258
|
-
this.registerService = registerService;
|
|
2259
|
-
this.userRepository = userRepository;
|
|
2260
|
-
}
|
|
2261
|
-
async register(params) {
|
|
2262
|
-
const email = params.email.toLocaleLowerCase();
|
|
2263
|
-
const displayName = `${params.firstName} ${params.lastName}`;
|
|
2264
|
-
if (await this.userRepository.checkIfExistsByField('cpf', params.cpf))
|
|
2265
|
-
throw new UserAlreadyRegisteredError(`Usuário com CPF ${params.cpf} já registrado.`);
|
|
2266
|
-
if (await this.userRepository.checkIfExistsByField('email', params.email))
|
|
2267
|
-
throw new UserAlreadyRegisteredError(`Usuário com e-mail ${params.email} já registrado.`);
|
|
2268
|
-
const auth = await this.registerService.register({
|
|
2269
|
-
birthday: params.birthday,
|
|
2270
|
-
email,
|
|
2271
|
-
firstName: params.firstName,
|
|
2272
|
-
lastName: params.lastName,
|
|
2273
|
-
cpf: params.cpf,
|
|
2274
|
-
displayName,
|
|
2275
|
-
phone: params.phone,
|
|
2276
|
-
password: params.password,
|
|
2277
|
-
});
|
|
2278
|
-
delete params.password;
|
|
2279
|
-
const user = await this.userRepository.create(Object.assign(Object.assign({}, params), { id: auth.id, email,
|
|
2280
|
-
displayName, type: exports.UserType.B2C, dateCreated: new Date(), dateModified: new Date() }));
|
|
2281
|
-
return user;
|
|
2282
|
-
}
|
|
2283
|
-
}
|
|
2284
|
-
|
|
2285
|
-
class SignOut {
|
|
2286
|
-
constructor(authService) {
|
|
2287
|
-
this.authService = authService;
|
|
2288
|
-
}
|
|
2289
|
-
async signOut() {
|
|
2290
|
-
await this.authService.signOut();
|
|
2291
|
-
}
|
|
2292
|
-
}
|
|
2293
|
-
|
|
2294
|
-
class RecoveryPassword {
|
|
2295
|
-
constructor(authService) {
|
|
2296
|
-
this.authService = authService;
|
|
2297
|
-
}
|
|
2298
|
-
async sendEmail(email) {
|
|
2299
|
-
await this.authService.sendPasswordResetEmail(email);
|
|
2300
|
-
}
|
|
2301
|
-
}
|
|
2302
|
-
|
|
2303
2318
|
class RoundProductPricesHelper {
|
|
2304
2319
|
static roundProductPrices(product) {
|
|
2305
2320
|
product.price.price = Number(product.price.price.toFixed(2));
|
|
@@ -2633,6 +2648,75 @@ class ProductsIndex {
|
|
|
2633
2648
|
}
|
|
2634
2649
|
}
|
|
2635
2650
|
|
|
2651
|
+
class AuthenticationFirebaseAuthService {
|
|
2652
|
+
constructor(firebaseAuth) {
|
|
2653
|
+
this.firebaseAuth = firebaseAuth;
|
|
2654
|
+
}
|
|
2655
|
+
async signInWithEmailAndPassword(data) {
|
|
2656
|
+
const credentials = await auth.signInWithEmailAndPassword(this.firebaseAuth, data.email, data.password);
|
|
2657
|
+
const user = credentials.user;
|
|
2658
|
+
return {
|
|
2659
|
+
id: user.uid,
|
|
2660
|
+
displayName: user.displayName,
|
|
2661
|
+
email: user.email,
|
|
2662
|
+
phone: user.phoneNumber,
|
|
2663
|
+
isAnonymous: false,
|
|
2664
|
+
};
|
|
2665
|
+
}
|
|
2666
|
+
async signInWithGoogle() {
|
|
2667
|
+
const credentials = await auth.signInWithPopup(this.firebaseAuth, new auth.GoogleAuthProvider());
|
|
2668
|
+
const user = credentials.user;
|
|
2669
|
+
return {
|
|
2670
|
+
id: user.uid,
|
|
2671
|
+
displayName: user.displayName,
|
|
2672
|
+
email: user.email,
|
|
2673
|
+
phone: user.phoneNumber,
|
|
2674
|
+
isAnonymous: false,
|
|
2675
|
+
};
|
|
2676
|
+
}
|
|
2677
|
+
async signOut() {
|
|
2678
|
+
this.firebaseAuth.signOut();
|
|
2679
|
+
}
|
|
2680
|
+
async signInAnonymously() {
|
|
2681
|
+
const auth$1 = await auth.signInAnonymously(this.firebaseAuth);
|
|
2682
|
+
const user = auth$1.user;
|
|
2683
|
+
user.id = auth$1.user.uid;
|
|
2684
|
+
return user;
|
|
2685
|
+
}
|
|
2686
|
+
async sendPasswordResetEmail(email) {
|
|
2687
|
+
return auth.sendPasswordResetEmail(this.firebaseAuth, email);
|
|
2688
|
+
}
|
|
2689
|
+
}
|
|
2690
|
+
|
|
2691
|
+
class RegisterFirebaseAuthService {
|
|
2692
|
+
constructor(firebaseAuth) {
|
|
2693
|
+
this.firebaseAuth = firebaseAuth;
|
|
2694
|
+
}
|
|
2695
|
+
async register(params) {
|
|
2696
|
+
if (!params.email)
|
|
2697
|
+
throw new RequiredArgumentError(['email']);
|
|
2698
|
+
try {
|
|
2699
|
+
const auth$1 = await auth.createUserWithEmailAndPassword(this.firebaseAuth, params.email, params.password);
|
|
2700
|
+
const user = is(auth$1.user);
|
|
2701
|
+
if (!user)
|
|
2702
|
+
throw new Error('User not created');
|
|
2703
|
+
await auth.sendEmailVerification(user);
|
|
2704
|
+
user.id = user.uid;
|
|
2705
|
+
return user;
|
|
2706
|
+
}
|
|
2707
|
+
catch (error) {
|
|
2708
|
+
if (!(error instanceof Error))
|
|
2709
|
+
throw error;
|
|
2710
|
+
const firebaseError = error;
|
|
2711
|
+
if (firebaseError.code === 'auth/email-already-in-use')
|
|
2712
|
+
throw new UserAlreadyRegisteredError('Email already registered');
|
|
2713
|
+
if (firebaseError.code === 'auth/weak-password')
|
|
2714
|
+
throw new WeakPasswordError();
|
|
2715
|
+
throw error;
|
|
2716
|
+
}
|
|
2717
|
+
}
|
|
2718
|
+
}
|
|
2719
|
+
|
|
2636
2720
|
const withFirestore = (MixinBase) => {
|
|
2637
2721
|
const isObjectsAndNoDate = (data) => data &&
|
|
2638
2722
|
!Array.isArray(data) &&
|
|
@@ -3503,72 +3587,14 @@ class ShopSettingsFirestoreRepository extends withCrudFirestore(withHelpers(with
|
|
|
3503
3587
|
}
|
|
3504
3588
|
}
|
|
3505
3589
|
|
|
3506
|
-
class
|
|
3507
|
-
constructor(
|
|
3508
|
-
this.
|
|
3590
|
+
class FirebaseFileUploaderService {
|
|
3591
|
+
constructor(storage, baseUrl) {
|
|
3592
|
+
this.storage = storage;
|
|
3593
|
+
this.baseUrl = baseUrl;
|
|
3509
3594
|
}
|
|
3510
|
-
async
|
|
3511
|
-
const
|
|
3512
|
-
|
|
3513
|
-
return {
|
|
3514
|
-
id: user.uid,
|
|
3515
|
-
displayName: user.displayName,
|
|
3516
|
-
email: user.email,
|
|
3517
|
-
phone: user.phoneNumber,
|
|
3518
|
-
isAnonymous: false,
|
|
3519
|
-
};
|
|
3520
|
-
}
|
|
3521
|
-
async signInWithGoogle() {
|
|
3522
|
-
const credentials = await auth.signInWithPopup(this.firebaseAuth, new auth.GoogleAuthProvider());
|
|
3523
|
-
const user = credentials.user;
|
|
3524
|
-
return {
|
|
3525
|
-
id: user.uid,
|
|
3526
|
-
displayName: user.displayName,
|
|
3527
|
-
email: user.email,
|
|
3528
|
-
phone: user.phoneNumber,
|
|
3529
|
-
isAnonymous: false,
|
|
3530
|
-
};
|
|
3531
|
-
}
|
|
3532
|
-
async signOut() {
|
|
3533
|
-
this.firebaseAuth.signOut();
|
|
3534
|
-
}
|
|
3535
|
-
async signInAnonymously() {
|
|
3536
|
-
const auth$1 = await auth.signInAnonymously(this.firebaseAuth);
|
|
3537
|
-
const user = auth$1.user;
|
|
3538
|
-
user.id = auth$1.user.uid;
|
|
3539
|
-
return user;
|
|
3540
|
-
}
|
|
3541
|
-
async sendPasswordResetEmail(email) {
|
|
3542
|
-
return auth.sendPasswordResetEmail(this.firebaseAuth, email);
|
|
3543
|
-
}
|
|
3544
|
-
}
|
|
3545
|
-
|
|
3546
|
-
class RegisterFirebaseAuthService {
|
|
3547
|
-
constructor(firebaseAuth) {
|
|
3548
|
-
this.firebaseAuth = firebaseAuth;
|
|
3549
|
-
}
|
|
3550
|
-
async register(params) {
|
|
3551
|
-
if (!params.email)
|
|
3552
|
-
throw new RequiredArgumentError(['email']);
|
|
3553
|
-
try {
|
|
3554
|
-
const auth$1 = await auth.createUserWithEmailAndPassword(this.firebaseAuth, params.email, params.password);
|
|
3555
|
-
const user = is(auth$1.user);
|
|
3556
|
-
if (!user)
|
|
3557
|
-
throw new Error('User not created');
|
|
3558
|
-
await auth.sendEmailVerification(user);
|
|
3559
|
-
user.id = user.uid;
|
|
3560
|
-
return user;
|
|
3561
|
-
}
|
|
3562
|
-
catch (error) {
|
|
3563
|
-
if (!(error instanceof Error))
|
|
3564
|
-
throw error;
|
|
3565
|
-
const firebaseError = error;
|
|
3566
|
-
if (firebaseError.code === 'auth/email-already-in-use')
|
|
3567
|
-
throw new UserAlreadyRegisteredError('Email already registered');
|
|
3568
|
-
if (firebaseError.code === 'auth/weak-password')
|
|
3569
|
-
throw new WeakPasswordError();
|
|
3570
|
-
throw error;
|
|
3571
|
-
}
|
|
3595
|
+
async upload(path, file) {
|
|
3596
|
+
const storageRef = storage.ref(this.storage, path);
|
|
3597
|
+
return storage.uploadBytes(storageRef, file).then((reference) => `${this.baseUrl}/${reference.ref.bucket}/${reference.ref.fullPath}`);
|
|
3572
3598
|
}
|
|
3573
3599
|
}
|
|
3574
3600
|
|
|
@@ -5795,6 +5821,7 @@ exports.Filter = Filter;
|
|
|
5795
5821
|
exports.FilterHasuraGraphQLRepository = FilterHasuraGraphQLRepository;
|
|
5796
5822
|
exports.FilterOption = FilterOption;
|
|
5797
5823
|
exports.FilterOptionHasuraGraphQLRepository = FilterOptionHasuraGraphQLRepository;
|
|
5824
|
+
exports.FirebaseFileUploaderService = FirebaseFileUploaderService;
|
|
5798
5825
|
exports.Home = Home;
|
|
5799
5826
|
exports.HomeFirestoreRepository = HomeFirestoreRepository;
|
|
5800
5827
|
exports.InvalidArgumentError = InvalidArgumentError;
|
|
@@ -5845,6 +5872,7 @@ exports.SubscriptionSummary = SubscriptionSummary;
|
|
|
5845
5872
|
exports.SubscriptionSummaryFirestoreRepository = SubscriptionSummaryFirestoreRepository;
|
|
5846
5873
|
exports.Trace = Trace;
|
|
5847
5874
|
exports.UnauthorizedError = UnauthorizedError;
|
|
5875
|
+
exports.UpdateUserImage = UpdateUserImage;
|
|
5848
5876
|
exports.User = User;
|
|
5849
5877
|
exports.UserAddress = UserAddress;
|
|
5850
5878
|
exports.UserAddressFirestoreRepository = UserAddressFirestoreRepository;
|