@infrab4a/connect 4.1.2-beta.15 → 4.1.2-beta.2

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.
Files changed (52) hide show
  1. package/index.cjs.js +491 -1071
  2. package/index.esm.js +492 -1056
  3. package/package.json +2 -3
  4. package/src/domain/index.d.ts +3 -4
  5. package/src/domain/shopping/index.d.ts +0 -4
  6. package/src/domain/shopping/models/index.d.ts +0 -3
  7. package/src/domain/shopping/models/order.d.ts +2 -2
  8. package/src/domain/shopping/models/payment.d.ts +61 -7
  9. package/src/domain/shopping/models/types/index.d.ts +4 -4
  10. package/src/domain/shopping/repositories/index.d.ts +0 -1
  11. package/src/infra/firebase/firestore/repositories/index.d.ts +2 -3
  12. package/src/infra/firebase/firestore/repositories/shopping/index.d.ts +0 -1
  13. package/teste2.d.ts +1 -0
  14. package/src/domain/general/index.d.ts +0 -2
  15. package/src/domain/general/models/index.d.ts +0 -1
  16. package/src/domain/general/models/sequences.d.ts +0 -9
  17. package/src/domain/general/repositories/index.d.ts +0 -1
  18. package/src/domain/general/repositories/sequences.repository.d.ts +0 -4
  19. package/src/domain/shopping/enums/index.d.ts +0 -2
  20. package/src/domain/shopping/enums/payment-methods.enum.d.ts +0 -6
  21. package/src/domain/shopping/enums/payment-providers.enum.d.ts +0 -5
  22. package/src/domain/shopping/factories/adyen-payment-method.factory.d.ts +0 -8
  23. package/src/domain/shopping/factories/base-payment-method.factory.d.ts +0 -7
  24. package/src/domain/shopping/factories/glampoints-payment-method.factory.d.ts +0 -8
  25. package/src/domain/shopping/factories/index.d.ts +0 -4
  26. package/src/domain/shopping/factories/pagarme-payment-method.factory.d.ts +0 -10
  27. package/src/domain/shopping/factories/payment-provider.factory.d.ts +0 -15
  28. package/src/domain/shopping/interfaces/index.d.ts +0 -5
  29. package/src/domain/shopping/interfaces/payment-method-factory.interface.d.ts +0 -14
  30. package/src/domain/shopping/interfaces/payment-provider-bank-slip.interface.d.ts +0 -5
  31. package/src/domain/shopping/interfaces/payment-provider-card.interface.d.ts +0 -7
  32. package/src/domain/shopping/interfaces/payment-provider-glampoints.interface.d.ts +0 -5
  33. package/src/domain/shopping/interfaces/payment-provider-pix.interface.d.ts +0 -5
  34. package/src/domain/shopping/models/order-blocked.d.ts +0 -26
  35. package/src/domain/shopping/models/payment.transaction.d.ts +0 -66
  36. package/src/domain/shopping/repositories/order-blocked.repository.d.ts +0 -4
  37. package/src/domain/shopping/services/adyen-card-payment.service.d.ts +0 -28
  38. package/src/domain/shopping/services/antifraude.service.d.ts +0 -19
  39. package/src/domain/shopping/services/glampoints-payment.service.d.ts +0 -4
  40. package/src/domain/shopping/services/index.d.ts +0 -6
  41. package/src/domain/shopping/services/pagarme-bank-slip-payment.service.d.ts +0 -8
  42. package/src/domain/shopping/services/pagarme-card-payment.service.d.ts +0 -10
  43. package/src/domain/shopping/services/pagarme-pix-payment.service.d.ts +0 -8
  44. package/src/domain/shopping/types/adyen-credentials.type.d.ts +0 -6
  45. package/src/domain/shopping/types/index.d.ts +0 -5
  46. package/src/domain/shopping/types/pagarme-credentials.type.d.ts +0 -5
  47. package/src/domain/shopping/types/payment-card-info.type.d.ts +0 -4
  48. package/src/domain/shopping/types/payment-method.type.d.ts +0 -2
  49. package/src/domain/shopping/types/payment-provider.type.d.ts +0 -2
  50. package/src/infra/firebase/firestore/repositories/general/index.d.ts +0 -1
  51. package/src/infra/firebase/firestore/repositories/general/sequences-firestore.repository.d.ts +0 -7
  52. package/src/infra/firebase/firestore/repositories/shopping/order-blocked-firestore.repository.d.ts +0 -7
package/index.cjs.js CHANGED
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  require('reflect-metadata');
6
- var tslib_1 = require('tslib');
7
6
  var classTransformer = require('class-transformer');
7
+ var tslib_1 = require('tslib');
8
8
  var dateFns = require('date-fns');
9
9
  var lodash = require('lodash');
10
10
  var debug = require('debug');
@@ -13,7 +13,6 @@ var axios = require('axios');
13
13
  var firestore = require('firebase/firestore');
14
14
  var auth = require('firebase/auth');
15
15
  var gqlQueryBuilder = require('gql-query-builder');
16
- var moment = require('moment');
17
16
 
18
17
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
19
18
 
@@ -37,49 +36,6 @@ function _interopNamespace(e) {
37
36
 
38
37
  var tslib_1__namespace = /*#__PURE__*/_interopNamespace(tslib_1);
39
38
  var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
40
- var moment__namespace = /*#__PURE__*/_interopNamespace(moment);
41
-
42
- exports.PaymentMethods = void 0;
43
- (function (PaymentMethods) {
44
- PaymentMethods["CARD"] = "card";
45
- PaymentMethods["BANKSLIP"] = "bankSlip";
46
- PaymentMethods["PIX"] = "pix";
47
- PaymentMethods["POINTS"] = "glampoints";
48
- })(exports.PaymentMethods || (exports.PaymentMethods = {}));
49
-
50
- exports.PaymentProviders = void 0;
51
- (function (PaymentProviders) {
52
- PaymentProviders["PAGARME"] = "pagarMe";
53
- PaymentProviders["ADYEN"] = "adyen";
54
- PaymentProviders["GLAMPOINTS"] = "glampoints";
55
- })(exports.PaymentProviders || (exports.PaymentProviders = {}));
56
-
57
- class BasePaymentMethodFactory {
58
- constructor(methods) {
59
- this.methods = methods;
60
- }
61
- build(method) {
62
- return this.methods[method];
63
- }
64
- }
65
-
66
- class AdyenPaymentMethodFactory extends BasePaymentMethodFactory {
67
- }
68
-
69
- class GlampointsPaymentMethodFactory extends BasePaymentMethodFactory {
70
- }
71
-
72
- class PagarmePaymentMethodFactory extends BasePaymentMethodFactory {
73
- }
74
-
75
- class PaymentProviderFactory {
76
- constructor(paymentProviders) {
77
- this.paymentProviders = paymentProviders;
78
- }
79
- build(provider) {
80
- return this.paymentProviders[provider];
81
- }
82
- }
83
39
 
84
40
  class BaseModel {
85
41
  get identifier() {
@@ -104,181 +60,6 @@ class BaseModel {
104
60
  }
105
61
  }
106
62
 
107
- class Filter extends BaseModel {
108
- static get identifiersFields() {
109
- return ['id'];
110
- }
111
- }
112
-
113
- class CategoryBase extends BaseModel {
114
- static get identifiersFields() {
115
- return ['id'];
116
- }
117
- }
118
- tslib_1.__decorate([
119
- classTransformer.Type(() => CategoryBase),
120
- tslib_1.__metadata("design:type", CategoryBase)
121
- ], CategoryBase.prototype, "parent", void 0);
122
- tslib_1.__decorate([
123
- classTransformer.Type(() => Filter),
124
- tslib_1.__metadata("design:type", Array)
125
- ], CategoryBase.prototype, "filters", void 0);
126
-
127
- class CategoryForProduct extends CategoryBase {
128
- static get identifiersFields() {
129
- return ['id'];
130
- }
131
- }
132
-
133
- class ProductBase extends BaseModel {
134
- get evaluation() {
135
- return {
136
- reviews: this.reviews,
137
- count: this.reviewsTotal,
138
- rating: this.rate,
139
- };
140
- }
141
- set evaluation(evaluation) {
142
- if (!evaluation) {
143
- this.reviews = null;
144
- this.reviewsTotal = null;
145
- this.rate = null;
146
- return;
147
- }
148
- this.reviews = evaluation.reviews || this.reviews;
149
- this.reviewsTotal = evaluation.count || this.reviewsTotal;
150
- this.rate = evaluation.rating || this.rate;
151
- }
152
- static get identifiersFields() {
153
- return ['id'];
154
- }
155
- }
156
-
157
- class ProductForKit extends ProductBase {
158
- static get identifiersFields() {
159
- return ['id'];
160
- }
161
- }
162
- tslib_1.__decorate([
163
- classTransformer.Type(() => CategoryForProduct),
164
- tslib_1.__metadata("design:type", CategoryForProduct)
165
- ], ProductForKit.prototype, "category", void 0);
166
-
167
- class KitProduct extends BaseModel {
168
- static get identifiersFields() {
169
- return ['productId', 'kitProductId'];
170
- }
171
- }
172
- tslib_1.__decorate([
173
- classTransformer.Type(() => ProductForKit),
174
- tslib_1.__metadata("design:type", ProductForKit)
175
- ], KitProduct.prototype, "kit", void 0);
176
- tslib_1.__decorate([
177
- classTransformer.Type(() => ProductForKit),
178
- tslib_1.__metadata("design:type", ProductForKit)
179
- ], KitProduct.prototype, "product", void 0);
180
-
181
- class ProductForCategory extends ProductBase {
182
- static get identifiersFields() {
183
- return ['id'];
184
- }
185
- }
186
- tslib_1.__decorate([
187
- classTransformer.Type(() => KitProduct),
188
- tslib_1.__metadata("design:type", Array)
189
- ], ProductForCategory.prototype, "kitProducts", void 0);
190
-
191
- class Category extends CategoryBase {
192
- static get identifiersFields() {
193
- return ['id'];
194
- }
195
- }
196
- tslib_1.__decorate([
197
- classTransformer.Type(() => ProductForCategory),
198
- tslib_1.__metadata("design:type", Array)
199
- ], Category.prototype, "childrenProducts", void 0);
200
-
201
- class CategoryCollectionChildren extends BaseModel {
202
- static get identifiersFields() {
203
- return ['collectionId', 'categoryId'];
204
- }
205
- }
206
- tslib_1.__decorate([
207
- classTransformer.Type(() => CategoryCollectionChildren),
208
- tslib_1.__metadata("design:type", CategoryCollectionChildren)
209
- ], CategoryCollectionChildren.prototype, "parent", void 0);
210
-
211
- class CategoryFilter extends BaseModel {
212
- static get identifiersFields() {
213
- return ['id'];
214
- }
215
- }
216
- tslib_1.__decorate([
217
- classTransformer.Type(() => Filter),
218
- tslib_1.__metadata("design:type", Filter)
219
- ], CategoryFilter.prototype, "filter", void 0);
220
- tslib_1.__decorate([
221
- classTransformer.Type(() => Category),
222
- tslib_1.__metadata("design:type", Category)
223
- ], CategoryFilter.prototype, "category", void 0);
224
-
225
- exports.GenderDestination = void 0;
226
- (function (GenderDestination) {
227
- GenderDestination["FEMALE"] = "female";
228
- GenderDestination["MALE"] = "male";
229
- GenderDestination["UNISEX"] = "unisex";
230
- })(exports.GenderDestination || (exports.GenderDestination = {}));
231
-
232
- exports.Shops = void 0;
233
- (function (Shops) {
234
- Shops["MENSMARKET"] = "mensmarket";
235
- Shops["GLAMSHOP"] = "Glamshop";
236
- Shops["GLAMPOINTS"] = "Glampoints";
237
- Shops["ALL"] = "ALL";
238
- })(exports.Shops || (exports.Shops = {}));
239
-
240
- class FilterOption extends BaseModel {
241
- static get identifiersFields() {
242
- return ['id'];
243
- }
244
- }
245
-
246
- class Product extends ProductBase {
247
- static get identifiersFields() {
248
- return ['id'];
249
- }
250
- }
251
- tslib_1.__decorate([
252
- classTransformer.Type(() => CategoryForProduct),
253
- tslib_1.__metadata("design:type", CategoryForProduct)
254
- ], Product.prototype, "category", void 0);
255
- tslib_1.__decorate([
256
- classTransformer.Type(() => KitProduct),
257
- tslib_1.__metadata("design:type", Array)
258
- ], Product.prototype, "kitProducts", void 0);
259
-
260
- class Variant extends BaseModel {
261
- static get identifiersFields() {
262
- return ['id', 'productId'];
263
- }
264
- }
265
-
266
- class Wishlist extends Category {
267
- static get identifiersFields() {
268
- return ['id'];
269
- }
270
- }
271
-
272
- class Buy2Win extends BaseModel {
273
- static get identifiersFields() {
274
- return ['id'];
275
- }
276
- }
277
- tslib_1.__decorate([
278
- classTransformer.Type(() => Category),
279
- tslib_1.__metadata("design:type", Array)
280
- ], Buy2Win.prototype, "categories", void 0);
281
-
282
63
  exports.Where = void 0;
283
64
  (function (Where) {
284
65
  Where["EQUALS"] = "==";
@@ -304,18 +85,6 @@ exports.UpdateOptionActions = void 0;
304
85
  UpdateOptionActions["NULL"] = "null";
305
86
  })(exports.UpdateOptionActions || (exports.UpdateOptionActions = {}));
306
87
 
307
- class CampaignDashboard extends BaseModel {
308
- static get identifiersFields() {
309
- return ['id'];
310
- }
311
- }
312
-
313
- class CampaignHashtag extends BaseModel {
314
- static get identifiersFields() {
315
- return ['id'];
316
- }
317
- }
318
-
319
88
  exports.AccessoryImportances = void 0;
320
89
  (function (AccessoryImportances) {
321
90
  AccessoryImportances["NOT_INTERESTED"] = "N\u00E3o tenho interesse";
@@ -542,178 +311,171 @@ class Edition extends BaseModel {
542
311
  }
543
312
  }
544
313
 
545
- class PaymentTransaction extends BaseModel {
314
+ class Payment extends BaseModel {
315
+ static get identifiersFields() {
316
+ return ['id'];
317
+ }
546
318
  }
547
319
  tslib_1.__decorate([
548
320
  classTransformer.Expose({ name: 'refuse_reason' }),
549
321
  tslib_1.__metadata("design:type", String)
550
- ], PaymentTransaction.prototype, "refuseReason", void 0);
322
+ ], Payment.prototype, "refuseReason", void 0);
551
323
  tslib_1.__decorate([
552
324
  classTransformer.Expose({ name: 'status_reason' }),
553
325
  tslib_1.__metadata("design:type", String)
554
- ], PaymentTransaction.prototype, "statusReason", void 0);
326
+ ], Payment.prototype, "statusReason", void 0);
555
327
  tslib_1.__decorate([
556
328
  classTransformer.Expose({ name: 'acquirer_response_code' }),
557
329
  tslib_1.__metadata("design:type", String)
558
- ], PaymentTransaction.prototype, "acquirerResponseCode", void 0);
330
+ ], Payment.prototype, "acquirerResponseCode", void 0);
559
331
  tslib_1.__decorate([
560
332
  classTransformer.Expose({ name: 'acquirer_name' }),
561
333
  tslib_1.__metadata("design:type", String)
562
- ], PaymentTransaction.prototype, "acquirerName", void 0);
334
+ ], Payment.prototype, "acquirerName", void 0);
563
335
  tslib_1.__decorate([
564
336
  classTransformer.Expose({ name: 'acquirer_id' }),
565
337
  tslib_1.__metadata("design:type", String)
566
- ], PaymentTransaction.prototype, "acquirerId", void 0);
338
+ ], Payment.prototype, "acquirerId", void 0);
567
339
  tslib_1.__decorate([
568
340
  classTransformer.Expose({ name: 'authorization_code' }),
569
341
  tslib_1.__metadata("design:type", String)
570
- ], PaymentTransaction.prototype, "authorizationCode", void 0);
342
+ ], Payment.prototype, "authorizationCode", void 0);
571
343
  tslib_1.__decorate([
572
344
  classTransformer.Expose({ name: 'soft_descriptor' }),
573
345
  tslib_1.__metadata("design:type", String)
574
- ], PaymentTransaction.prototype, "softDescriptor", void 0);
346
+ ], Payment.prototype, "softDescriptor", void 0);
575
347
  tslib_1.__decorate([
576
348
  classTransformer.Expose({ name: 'date_created' }),
577
349
  tslib_1.__metadata("design:type", String)
578
- ], PaymentTransaction.prototype, "dateCreated", void 0);
350
+ ], Payment.prototype, "dateCreated", void 0);
579
351
  tslib_1.__decorate([
580
352
  classTransformer.Expose({ name: 'date_updated' }),
581
353
  tslib_1.__metadata("design:type", String)
582
- ], PaymentTransaction.prototype, "dateUpdated", void 0);
354
+ ], Payment.prototype, "dateUpdated", void 0);
583
355
  tslib_1.__decorate([
584
356
  classTransformer.Expose({ name: 'authorized_amount' }),
585
357
  tslib_1.__metadata("design:type", Number)
586
- ], PaymentTransaction.prototype, "authorizedAmount", void 0);
358
+ ], Payment.prototype, "authorizedAmount", void 0);
587
359
  tslib_1.__decorate([
588
360
  classTransformer.Expose({ name: 'paid_amount' }),
589
361
  tslib_1.__metadata("design:type", Number)
590
- ], PaymentTransaction.prototype, "paidAmount", void 0);
362
+ ], Payment.prototype, "paidAmount", void 0);
591
363
  tslib_1.__decorate([
592
364
  classTransformer.Expose({ name: 'refunded_amount' }),
593
365
  tslib_1.__metadata("design:type", Number)
594
- ], PaymentTransaction.prototype, "refundedAmount", void 0);
366
+ ], Payment.prototype, "refundedAmount", void 0);
595
367
  tslib_1.__decorate([
596
368
  classTransformer.Expose({ name: 'card_holder_name' }),
597
369
  tslib_1.__metadata("design:type", String)
598
- ], PaymentTransaction.prototype, "cardHolderName", void 0);
370
+ ], Payment.prototype, "cardHolderName", void 0);
599
371
  tslib_1.__decorate([
600
372
  classTransformer.Expose({ name: 'card_last_digits' }),
601
373
  tslib_1.__metadata("design:type", String)
602
- ], PaymentTransaction.prototype, "cardLastDigits", void 0);
374
+ ], Payment.prototype, "cardLastDigits", void 0);
603
375
  tslib_1.__decorate([
604
376
  classTransformer.Expose({ name: 'card_first_digits' }),
605
377
  tslib_1.__metadata("design:type", String)
606
- ], PaymentTransaction.prototype, "cardFirstDigits", void 0);
378
+ ], Payment.prototype, "cardFirstDigits", void 0);
607
379
  tslib_1.__decorate([
608
380
  classTransformer.Expose({ name: 'card_brand' }),
609
381
  tslib_1.__metadata("design:type", String)
610
- ], PaymentTransaction.prototype, "cardBrand", void 0);
382
+ ], Payment.prototype, "cardBrand", void 0);
611
383
  tslib_1.__decorate([
612
384
  classTransformer.Expose({ name: 'card_pin_mode' }),
613
385
  tslib_1.__metadata("design:type", String)
614
- ], PaymentTransaction.prototype, "cardPinMode", void 0);
386
+ ], Payment.prototype, "cardPinMode", void 0);
615
387
  tslib_1.__decorate([
616
388
  classTransformer.Expose({ name: 'card_magstripe_fallback' }),
617
389
  tslib_1.__metadata("design:type", Boolean)
618
- ], PaymentTransaction.prototype, "cardMagstripeFallback", void 0);
390
+ ], Payment.prototype, "cardMagstripeFallback", void 0);
619
391
  tslib_1.__decorate([
620
392
  classTransformer.Expose({ name: 'cvm_pin' }),
621
393
  tslib_1.__metadata("design:type", Boolean)
622
- ], PaymentTransaction.prototype, "cvmPin", void 0);
394
+ ], Payment.prototype, "cvmPin", void 0);
623
395
  tslib_1.__decorate([
624
396
  classTransformer.Expose({ name: 'postback_url' }),
625
397
  tslib_1.__metadata("design:type", String)
626
- ], PaymentTransaction.prototype, "postbackUrl", void 0);
398
+ ], Payment.prototype, "postbackUrl", void 0);
627
399
  tslib_1.__decorate([
628
400
  classTransformer.Expose({ name: 'payment_method' }),
629
401
  tslib_1.__metadata("design:type", String)
630
- ], PaymentTransaction.prototype, "paymentMethod", void 0);
402
+ ], Payment.prototype, "paymentMethod", void 0);
631
403
  tslib_1.__decorate([
632
404
  classTransformer.Expose({ name: 'capture_method' }),
633
405
  tslib_1.__metadata("design:type", String)
634
- ], PaymentTransaction.prototype, "captureMethod", void 0);
406
+ ], Payment.prototype, "captureMethod", void 0);
635
407
  tslib_1.__decorate([
636
408
  classTransformer.Expose({ name: 'antifraud_score' }),
637
409
  tslib_1.__metadata("design:type", String)
638
- ], PaymentTransaction.prototype, "antifraudScore", void 0);
410
+ ], Payment.prototype, "antifraudScore", void 0);
639
411
  tslib_1.__decorate([
640
412
  classTransformer.Expose({ name: 'boleto_url' }),
641
413
  tslib_1.__metadata("design:type", String)
642
- ], PaymentTransaction.prototype, "boletoUrl", void 0);
414
+ ], Payment.prototype, "boletoUrl", void 0);
643
415
  tslib_1.__decorate([
644
416
  classTransformer.Expose({ name: 'boleto_barcode' }),
645
417
  tslib_1.__metadata("design:type", String)
646
- ], PaymentTransaction.prototype, "boletoBarcode", void 0);
418
+ ], Payment.prototype, "boletoBarcode", void 0);
647
419
  tslib_1.__decorate([
648
420
  classTransformer.Expose({ name: 'boleto_expiration_date' }),
649
421
  tslib_1.__metadata("design:type", String)
650
- ], PaymentTransaction.prototype, "boletoExpirationDate", void 0);
422
+ ], Payment.prototype, "boletoExpirationDate", void 0);
651
423
  tslib_1.__decorate([
652
424
  classTransformer.Expose({ name: 'subscription_id' }),
653
425
  tslib_1.__metadata("design:type", String)
654
- ], PaymentTransaction.prototype, "subscriptionId", void 0);
426
+ ], Payment.prototype, "subscriptionId", void 0);
655
427
  tslib_1.__decorate([
656
428
  classTransformer.Expose({ name: 'split_rules' }),
657
429
  tslib_1.__metadata("design:type", String)
658
- ], PaymentTransaction.prototype, "splitRules", void 0);
430
+ ], Payment.prototype, "splitRules", void 0);
659
431
  tslib_1.__decorate([
660
432
  classTransformer.Expose({ name: 'antifraud_metadata' }),
661
433
  tslib_1.__metadata("design:type", Object)
662
- ], PaymentTransaction.prototype, "antifraudMetadata", void 0);
434
+ ], Payment.prototype, "antifraudMetadata", void 0);
663
435
  tslib_1.__decorate([
664
436
  classTransformer.Expose({ name: 'reference_key' }),
665
437
  tslib_1.__metadata("design:type", String)
666
- ], PaymentTransaction.prototype, "referenceKey", void 0);
438
+ ], Payment.prototype, "referenceKey", void 0);
667
439
  tslib_1.__decorate([
668
440
  classTransformer.Expose({ name: 'local_transaction_id' }),
669
441
  tslib_1.__metadata("design:type", String)
670
- ], PaymentTransaction.prototype, "localTransactionId", void 0);
442
+ ], Payment.prototype, "localTransactionId", void 0);
671
443
  tslib_1.__decorate([
672
444
  classTransformer.Expose({ name: 'local_time' }),
673
445
  tslib_1.__metadata("design:type", String)
674
- ], PaymentTransaction.prototype, "localTime", void 0);
446
+ ], Payment.prototype, "localTime", void 0);
675
447
  tslib_1.__decorate([
676
448
  classTransformer.Expose({ name: 'fraud_covered' }),
677
449
  tslib_1.__metadata("design:type", Boolean)
678
- ], PaymentTransaction.prototype, "fraudCovered", void 0);
450
+ ], Payment.prototype, "fraudCovered", void 0);
679
451
  tslib_1.__decorate([
680
452
  classTransformer.Expose({ name: 'fraud_reimbursed' }),
681
453
  tslib_1.__metadata("design:type", String)
682
- ], PaymentTransaction.prototype, "fraudReimbursed", void 0);
454
+ ], Payment.prototype, "fraudReimbursed", void 0);
683
455
  tslib_1.__decorate([
684
456
  classTransformer.Expose({ name: 'order_id' }),
685
457
  tslib_1.__metadata("design:type", String)
686
- ], PaymentTransaction.prototype, "orderId", void 0);
458
+ ], Payment.prototype, "orderId", void 0);
687
459
  tslib_1.__decorate([
688
460
  classTransformer.Expose({ name: 'risk_level' }),
689
461
  tslib_1.__metadata("design:type", String)
690
- ], PaymentTransaction.prototype, "riskLevel", void 0);
462
+ ], Payment.prototype, "riskLevel", void 0);
691
463
  tslib_1.__decorate([
692
464
  classTransformer.Expose({ name: 'receipt_url' }),
693
465
  tslib_1.__metadata("design:type", String)
694
- ], PaymentTransaction.prototype, "receiptUrl", void 0);
466
+ ], Payment.prototype, "receiptUrl", void 0);
695
467
  tslib_1.__decorate([
696
468
  classTransformer.Expose({ name: 'private_label' }),
697
469
  tslib_1.__metadata("design:type", String)
698
- ], PaymentTransaction.prototype, "privateLabel", void 0);
470
+ ], Payment.prototype, "privateLabel", void 0);
699
471
  tslib_1.__decorate([
700
472
  classTransformer.Expose({ name: 'pix_qr_code' }),
701
473
  tslib_1.__metadata("design:type", String)
702
- ], PaymentTransaction.prototype, "pixQrCode", void 0);
474
+ ], Payment.prototype, "pixQrCode", void 0);
703
475
  tslib_1.__decorate([
704
476
  classTransformer.Expose({ name: 'pix_expiration_date' }),
705
477
  tslib_1.__metadata("design:type", String)
706
- ], PaymentTransaction.prototype, "pixExpirationDate", void 0);
707
-
708
- class Payment extends BaseModel {
709
- static get identifiersFields() {
710
- return ['id'];
711
- }
712
- }
713
- tslib_1.__decorate([
714
- classTransformer.Type(() => PaymentTransaction),
715
- tslib_1.__metadata("design:type", PaymentTransaction)
716
- ], Payment.prototype, "transaction", void 0);
478
+ ], Payment.prototype, "pixExpirationDate", void 0);
717
479
 
718
480
  class SubscriptionPayment extends BaseModel {
719
481
  static get identifiersFields() {
@@ -2225,571 +1987,272 @@ class RecoveryPassword {
2225
1987
  }
2226
1988
  }
2227
1989
 
2228
- class LineItem extends Product {
2229
- }
2230
-
2231
- class ShippingMethod extends BaseModel {
1990
+ class Filter extends BaseModel {
2232
1991
  static get identifiersFields() {
2233
1992
  return ['id'];
2234
1993
  }
2235
1994
  }
2236
1995
 
2237
- class Checkout extends BaseModel {
1996
+ class CategoryBase extends BaseModel {
2238
1997
  static get identifiersFields() {
2239
1998
  return ['id'];
2240
1999
  }
2241
2000
  }
2242
2001
  tslib_1.__decorate([
2243
- classTransformer.Type(() => LineItem),
2244
- tslib_1.__metadata("design:type", Array)
2245
- ], Checkout.prototype, "lineItems", void 0);
2246
- tslib_1.__decorate([
2247
- classTransformer.Type(() => User),
2248
- tslib_1.__metadata("design:type", User)
2249
- ], Checkout.prototype, "user", void 0);
2250
- tslib_1.__decorate([
2251
- classTransformer.Type(() => UserAddress),
2252
- tslib_1.__metadata("design:type", UserAddress)
2253
- ], Checkout.prototype, "shippingAddress", void 0);
2254
- tslib_1.__decorate([
2255
- classTransformer.Type(() => UserAddress),
2256
- tslib_1.__metadata("design:type", UserAddress)
2257
- ], Checkout.prototype, "billingAddress", void 0);
2258
- tslib_1.__decorate([
2259
- classTransformer.Type(() => ShippingMethod),
2260
- tslib_1.__metadata("design:type", ShippingMethod)
2261
- ], Checkout.prototype, "shipping", void 0);
2002
+ classTransformer.Type(() => CategoryBase),
2003
+ tslib_1.__metadata("design:type", CategoryBase)
2004
+ ], CategoryBase.prototype, "parent", void 0);
2262
2005
  tslib_1.__decorate([
2263
- classTransformer.Type(() => Coupon),
2264
- tslib_1.__metadata("design:type", Coupon)
2265
- ], Checkout.prototype, "coupon", void 0);
2006
+ classTransformer.Type(() => Filter),
2007
+ tslib_1.__metadata("design:type", Array)
2008
+ ], CategoryBase.prototype, "filters", void 0);
2266
2009
 
2267
- exports.OrderStatus = void 0;
2268
- (function (OrderStatus) {
2269
- OrderStatus["AGUARDANDO_PAGAMENTO"] = "Aguardando pagamento";
2270
- OrderStatus["EM_PREPARO"] = "Preparando pedido";
2271
- OrderStatus["NF_EMITIDA"] = "Nota Fiscal Emitida";
2272
- OrderStatus["AGUARDANDO_ENVIO"] = "Aguardando Transaportadora";
2273
- OrderStatus["ENVIADO"] = "Enviado";
2274
- OrderStatus["ENTREGUE"] = "Entregue";
2275
- OrderStatus["CANCELADO"] = "Cancelado";
2276
- OrderStatus["CREDIT_CARD"] = "credit_card";
2277
- })(exports.OrderStatus || (exports.OrderStatus = {}));
2278
-
2279
- class Order extends Checkout {
2280
- }
2281
- tslib_1.__decorate([
2282
- classTransformer.Type(() => PaymentTransaction),
2283
- tslib_1.__metadata("design:type", PaymentTransaction)
2284
- ], Order.prototype, "payment", void 0);
2010
+ class CategoryForProduct extends CategoryBase {
2011
+ static get identifiersFields() {
2012
+ return ['id'];
2013
+ }
2014
+ }
2285
2015
 
2286
- class OrderBlocked extends BaseModel {
2016
+ class ProductBase extends BaseModel {
2017
+ get evaluation() {
2018
+ return {
2019
+ reviews: this.reviews,
2020
+ count: this.reviewsTotal,
2021
+ rating: this.rate,
2022
+ };
2023
+ }
2024
+ set evaluation(evaluation) {
2025
+ if (!evaluation) {
2026
+ this.reviews = null;
2027
+ this.reviewsTotal = null;
2028
+ this.rate = null;
2029
+ return;
2030
+ }
2031
+ this.reviews = evaluation.reviews || this.reviews;
2032
+ this.reviewsTotal = evaluation.count || this.reviewsTotal;
2033
+ this.rate = evaluation.rating || this.rate;
2034
+ }
2287
2035
  static get identifiersFields() {
2288
2036
  return ['id'];
2289
2037
  }
2290
2038
  }
2291
2039
 
2292
- class CheckoutSubscription extends BaseModel {
2040
+ class ProductForKit extends ProductBase {
2293
2041
  static get identifiersFields() {
2294
2042
  return ['id'];
2295
2043
  }
2296
2044
  }
2297
2045
  tslib_1.__decorate([
2298
- classTransformer.Type(() => UserAddress),
2299
- tslib_1.__metadata("design:type", UserAddress)
2300
- ], CheckoutSubscription.prototype, "shippingAddress", void 0);
2046
+ classTransformer.Type(() => CategoryForProduct),
2047
+ tslib_1.__metadata("design:type", CategoryForProduct)
2048
+ ], ProductForKit.prototype, "category", void 0);
2049
+
2050
+ class KitProduct extends BaseModel {
2051
+ static get identifiersFields() {
2052
+ return ['productId', 'kitProductId'];
2053
+ }
2054
+ }
2301
2055
  tslib_1.__decorate([
2302
- classTransformer.Type(() => UserAddress),
2303
- tslib_1.__metadata("design:type", UserAddress)
2304
- ], CheckoutSubscription.prototype, "billingAddress", void 0);
2056
+ classTransformer.Type(() => ProductForKit),
2057
+ tslib_1.__metadata("design:type", ProductForKit)
2058
+ ], KitProduct.prototype, "kit", void 0);
2305
2059
  tslib_1.__decorate([
2306
- classTransformer.Type(() => SubscriptionPlan),
2307
- tslib_1.__metadata("design:type", SubscriptionPlan)
2308
- ], CheckoutSubscription.prototype, "subscriptionPlan", void 0);
2060
+ classTransformer.Type(() => ProductForKit),
2061
+ tslib_1.__metadata("design:type", ProductForKit)
2062
+ ], KitProduct.prototype, "product", void 0);
2063
+
2064
+ class ProductForCategory extends ProductBase {
2065
+ static get identifiersFields() {
2066
+ return ['id'];
2067
+ }
2068
+ }
2309
2069
  tslib_1.__decorate([
2310
- classTransformer.Type(() => Coupon),
2311
- tslib_1.__metadata("design:type", Coupon)
2312
- ], CheckoutSubscription.prototype, "coupon", void 0);
2070
+ classTransformer.Type(() => KitProduct),
2071
+ tslib_1.__metadata("design:type", Array)
2072
+ ], ProductForCategory.prototype, "kitProducts", void 0);
2313
2073
 
2314
- class AdyenCardService {
2315
- constructor(credentials) {
2316
- this.credentials = credentials;
2074
+ class Category extends CategoryBase {
2075
+ static get identifiersFields() {
2076
+ return ['id'];
2317
2077
  }
2318
- async pay(checkout, card) {
2319
- try {
2320
- const result = await axios__default["default"]({
2321
- method: 'POST',
2322
- url: this.credentials.URL_TRANSACTION,
2323
- headers: {
2324
- 'x-api-key': this.credentials.API_KEY,
2325
- 'content-type': 'application/json',
2326
- },
2327
- data: this.createCardPayment(checkout, card),
2328
- });
2329
- if (result.data.resultCode !== 'Authorised') {
2330
- this.checkoutAntiFraudService.createBlockedOrderOrPayment(checkout, 'Card not authorized', 'Card', 'day', card);
2331
- return Promise.reject(new Error(`Seu pagamento com cartão não foi autorizado. Para não perder seus produtos, pague com PIX ou outro cartão de crédito`));
2332
- }
2333
- const payment = {
2334
- createdAt: new Date(),
2335
- updatedAt: new Date(),
2336
- userId: checkout.user.id,
2337
- checkoutId: checkout.id,
2338
- totalPrice: checkout.totalPrice,
2339
- transaction: Object.assign(Object.assign({}, result.data), { status: 'paid' }),
2340
- };
2341
- return payment;
2342
- }
2343
- catch (error) { }
2078
+ }
2079
+ tslib_1.__decorate([
2080
+ classTransformer.Type(() => ProductForCategory),
2081
+ tslib_1.__metadata("design:type", Array)
2082
+ ], Category.prototype, "childrenProducts", void 0);
2083
+
2084
+ class CategoryCollectionChildren extends BaseModel {
2085
+ static get identifiersFields() {
2086
+ return ['collectionId', 'categoryId'];
2344
2087
  }
2345
- createCardPayment(checkout, card) {
2346
- return {
2347
- amount: {
2348
- currency: 'BRL',
2349
- value: ((checkout === null || checkout === void 0 ? void 0 : checkout.totalPrice) || 0) * 100,
2350
- },
2351
- paymentMethod: {
2352
- type: 'scheme',
2353
- storedPaymentMethodId: card.cardId,
2354
- },
2355
- reference: checkout.id,
2356
- shopperInteraction: 'Ecommerce',
2357
- merchantAccount: this.credentials.MERCHANT_ACCOUNT,
2358
- shopperReference: checkout.user.id,
2359
- recurringProcessingModel: 'CardOnFile',
2360
- returnUrl: this.credentials.URL_POSTBACK,
2361
- installments: {
2362
- value: card.installments,
2363
- },
2364
- };
2088
+ }
2089
+ tslib_1.__decorate([
2090
+ classTransformer.Type(() => CategoryCollectionChildren),
2091
+ tslib_1.__metadata("design:type", CategoryCollectionChildren)
2092
+ ], CategoryCollectionChildren.prototype, "parent", void 0);
2093
+
2094
+ class CategoryFilter extends BaseModel {
2095
+ static get identifiersFields() {
2096
+ return ['id'];
2365
2097
  }
2366
- addCard() {
2367
- throw new Error('Method not implemented.');
2098
+ }
2099
+ tslib_1.__decorate([
2100
+ classTransformer.Type(() => Filter),
2101
+ tslib_1.__metadata("design:type", Filter)
2102
+ ], CategoryFilter.prototype, "filter", void 0);
2103
+ tslib_1.__decorate([
2104
+ classTransformer.Type(() => Category),
2105
+ tslib_1.__metadata("design:type", Category)
2106
+ ], CategoryFilter.prototype, "category", void 0);
2107
+
2108
+ exports.GenderDestination = void 0;
2109
+ (function (GenderDestination) {
2110
+ GenderDestination["FEMALE"] = "female";
2111
+ GenderDestination["MALE"] = "male";
2112
+ GenderDestination["UNISEX"] = "unisex";
2113
+ })(exports.GenderDestination || (exports.GenderDestination = {}));
2114
+
2115
+ exports.Shops = void 0;
2116
+ (function (Shops) {
2117
+ Shops["MENSMARKET"] = "mensmarket";
2118
+ Shops["GLAMSHOP"] = "Glamshop";
2119
+ Shops["GLAMPOINTS"] = "Glampoints";
2120
+ Shops["ALL"] = "ALL";
2121
+ })(exports.Shops || (exports.Shops = {}));
2122
+
2123
+ class FilterOption extends BaseModel {
2124
+ static get identifiersFields() {
2125
+ return ['id'];
2368
2126
  }
2369
2127
  }
2370
2128
 
2371
- class CheckoutAntiFraudService {
2372
- constructor(orderRepository, orderBlockedRepository) {
2373
- this.orderRepository = orderRepository;
2374
- this.orderBlockedRepository = orderBlockedRepository;
2375
- this.LIMIT_ORDERS_DAY = 2;
2376
- this.LIMIT_ORDERS_WEEK = 7;
2377
- this.LIMIT_BLOCKED_ORDERS_DAY = 5;
2378
- }
2379
- async validAntiFraud(checkout, boleto, pix, card) {
2380
- if (this.couponValidation(checkout))
2381
- return false;
2382
- if (pix)
2383
- return true;
2384
- if (boleto && !this.verifyBoletoOrder(checkout))
2385
- return false;
2386
- if (card && !(await this.verifyBlockedOrderAttempts(checkout, card)))
2387
- return false;
2388
- if (card && !(await this.verifyDayAndWeekOrders(checkout, card)))
2389
- return false;
2390
- return true;
2391
- }
2392
- couponValidation(checkout) {
2393
- var _a, _b;
2394
- if (((_a = checkout.coupon) === null || _a === void 0 ? void 0 : _a.nickname) === 'FALHADEPAGAMENTO') {
2395
- console.error(`Falha de pagamento com cupom. CheckoutId: ${JSON.stringify({
2396
- checkoutId: checkout.id,
2397
- user: checkout.user.id,
2398
- coupon: (_b = checkout.coupon) === null || _b === void 0 ? void 0 : _b.nickname,
2399
- })}`);
2400
- return false;
2401
- }
2402
- return true;
2403
- }
2404
- async verifyDayAndWeekOrders(checkout, card) {
2405
- var _a, _b, _c, _d, _e, _f, _g, _h;
2406
- const ordersPerDay = await this.validateOrdersByRange((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.cpf, (_b = checkout.user) === null || _b === void 0 ? void 0 : _b.email, (_c = checkout.user) === null || _c === void 0 ? void 0 : _c.phone, (_d = checkout.shippingAddress) === null || _d === void 0 ? void 0 : _d.zip, card, this.getDateRange('day'));
2407
- for (const key in ordersPerDay) {
2408
- if (ordersPerDay[key] > this.LIMIT_ORDERS_DAY) {
2409
- await this.createBlockedOrderOrPayment(checkout, 'Order limit', key, 'day');
2410
- return false;
2411
- }
2412
- }
2413
- const ordersPerWeek = await this.validateOrdersByRange((_e = checkout.user) === null || _e === void 0 ? void 0 : _e.cpf, (_f = checkout.user) === null || _f === void 0 ? void 0 : _f.email, (_g = checkout.user) === null || _g === void 0 ? void 0 : _g.phone, (_h = checkout.shippingAddress) === null || _h === void 0 ? void 0 : _h.zip, card, this.getDateRange('week'));
2414
- for (const key in ordersPerWeek) {
2415
- if (ordersPerDay[key] > this.LIMIT_ORDERS_WEEK) {
2416
- await this.createBlockedOrderOrPayment(checkout, 'Order limit', key, 'week');
2417
- return false;
2418
- }
2419
- }
2420
- return true;
2421
- }
2422
- async validateOrdersByRange(cpf, email, phone, zip, card, range) {
2423
- const ordersCpf = await this.countOrdersByField('user', 'cpf', cpf, range);
2424
- const ordersByEmail = await this.countOrdersByField('user', 'email', email, range);
2425
- const ordersByPhone = await this.countOrdersByField('user', 'phone', phone, range);
2426
- const ordersByZip = await this.countOrdersByField('shippingAddress', 'zip', zip, range);
2427
- return {
2428
- cpf: ordersCpf,
2429
- email: ordersByEmail,
2430
- phone: ordersByPhone,
2431
- zip: ordersByZip,
2432
- };
2433
- }
2434
- async countOrdersByField(property, field, value, range) {
2435
- const filters = {
2436
- [property]: {
2437
- [field]: value,
2438
- },
2439
- ['createdAt']: [
2440
- { operator: exports.Where.GTE, value: range.firstDate },
2441
- { operator: exports.Where.LTE, value: range.lastDate },
2442
- ],
2443
- };
2444
- const docs = await (await this.orderRepository.find({ filters })).count;
2445
- return docs;
2446
- }
2447
- async verifyBoletoOrder(checkout) {
2448
- var _a;
2449
- const maxOrderValue = 5000;
2450
- if (checkout.totalPrice && checkout.totalPrice > maxOrderValue && !((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.isSubscriber)) {
2451
- await this.createBlockedOrderOrPayment(checkout, 'Boleto not authorized', 'Boleto', 'day');
2452
- return false;
2453
- }
2454
- return true;
2455
- }
2456
- async verifyBlockedOrderAttempts(checkout, card) {
2457
- var _a, _b, _c, _d;
2458
- const day = `${moment__namespace().format('YYYY-MM-DD')}T00:00:00`;
2459
- const endOfDay = `${moment__namespace().format('YYYY-MM-DD')}T23:59:59`;
2460
- const ordersBlockedWithCpf = await this.orderBlockedRepository
2461
- .find({
2462
- filters: {
2463
- customer: { cpf: { operator: exports.Where.EQUALS, value: (_a = checkout.user) === null || _a === void 0 ? void 0 : _a.cpf } },
2464
- date: [
2465
- { operator: exports.Where.GTE, value: new Date(day) },
2466
- { operator: exports.Where.LTE, value: new Date(endOfDay) },
2467
- ],
2468
- },
2469
- })
2470
- .then((data) => data.data);
2471
- const ordersBlockedWithEmail = await this.orderBlockedRepository
2472
- .find({
2473
- filters: {
2474
- customer: { email: { operator: exports.Where.EQUALS, value: (_b = checkout.user) === null || _b === void 0 ? void 0 : _b.email } },
2475
- date: [
2476
- { operator: exports.Where.GTE, value: new Date(day) },
2477
- { operator: exports.Where.LTE, value: new Date(endOfDay) },
2478
- ],
2479
- },
2480
- })
2481
- .then((data) => data.data);
2482
- const ordersBlockedWithCep = await this.orderBlockedRepository
2483
- .find({
2484
- filters: {
2485
- customer: { shippingAddress: { zip: { operator: exports.Where.EQUALS, value: (_c = checkout.shippingAddress) === null || _c === void 0 ? void 0 : _c.zip } } },
2486
- date: [
2487
- { operator: exports.Where.GTE, value: new Date(day) },
2488
- { operator: exports.Where.LTE, value: new Date(endOfDay) },
2489
- ],
2490
- },
2491
- })
2492
- .then((data) => data.data);
2493
- const ordersBlockedWithPhone = await this.orderBlockedRepository
2494
- .find({
2495
- filters: {
2496
- customer: { phoneNumber: { operator: exports.Where.EQUALS, value: (_d = checkout.user) === null || _d === void 0 ? void 0 : _d.phone } },
2497
- date: [
2498
- { operator: exports.Where.GTE, value: new Date(day) },
2499
- { operator: exports.Where.LTE, value: new Date(endOfDay) },
2500
- ],
2501
- },
2502
- })
2503
- .then((data) => data.data);
2504
- const blockedUniqueEmails = ordersBlockedWithEmail.filter((e) => {
2505
- var _a;
2506
- return e.customer.cpf !== ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.cpf);
2507
- });
2508
- const blockedUniqueCeps = ordersBlockedWithCep.filter((e) => {
2509
- var _a, _b;
2510
- return e.customer.cpf !== ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.cpf) && e.customer.email !== ((_b = checkout.user) === null || _b === void 0 ? void 0 : _b.email);
2511
- });
2512
- const blockedUniquePhone = ordersBlockedWithPhone.filter((e) => {
2513
- var _a, _b, _c, _d, _e, _f;
2514
- return (e.customer.cpf !== ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.cpf) &&
2515
- e.customer.email !== ((_b = checkout.user) === null || _b === void 0 ? void 0 : _b.email) &&
2516
- ((_d = (_c = e.customer.shippingAddress) === null || _c === void 0 ? void 0 : _c.zip) === null || _d === void 0 ? void 0 : _d.toString()) !== ((_f = (_e = checkout.shippingAddress) === null || _e === void 0 ? void 0 : _e.zip) === null || _f === void 0 ? void 0 : _f.toString()));
2517
- });
2518
- const blockedAttempts = ordersBlockedWithCpf
2519
- .concat(blockedUniqueEmails)
2520
- .concat(blockedUniqueCeps)
2521
- .concat(blockedUniquePhone);
2522
- if (blockedAttempts.length >= this.LIMIT_BLOCKED_ORDERS_DAY) {
2523
- await this.createBlockedOrderOrPayment(checkout, 'More than 5 attempts have failed', 'Failed attempts', 'day', card || null);
2524
- return false;
2525
- }
2526
- return true;
2527
- }
2528
- async createBlockedOrderOrPayment(checkout, blockType, type, limiteRange, card = null) {
2529
- var _a, _b, _c, _d, _e, _f, _g, _h;
2530
- const paymentBlocked = {
2531
- customer: {
2532
- name: ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.displayName) || '',
2533
- cpf: ((_b = checkout.user) === null || _b === void 0 ? void 0 : _b.cpf) || '',
2534
- id: (_c = checkout.user) === null || _c === void 0 ? void 0 : _c.id,
2535
- email: ((_d = checkout.user) === null || _d === void 0 ? void 0 : _d.email) || '',
2536
- phoneNumber: '+55' + ((_e = checkout.user) === null || _e === void 0 ? void 0 : _e.phone),
2537
- isSubscriber: (_f = checkout.user) === null || _f === void 0 ? void 0 : _f.isSubscriber,
2538
- subscriptionPlan: ((_g = checkout.user) === null || _g === void 0 ? void 0 : _g.subscriptionPlan) || '',
2539
- shippingAddress: Object.assign(Object.assign({}, checkout.shippingAddress), { zip: this.formatZip((_h = checkout.shippingAddress) === null || _h === void 0 ? void 0 : _h.zip) }),
2540
- },
2541
- blockType,
2542
- limiteRange,
2543
- type,
2544
- card,
2545
- checkout: {
2546
- id: checkout.id,
2547
- shop: checkout.shop,
2548
- total: checkout.totalPrice,
2549
- },
2550
- date: new Date(),
2551
- };
2552
- await this.orderBlockedRepository.create(paymentBlocked);
2553
- }
2554
- getDateRange(range = 'day') {
2555
- switch (range) {
2556
- case 'day':
2557
- return {
2558
- firstDate: moment__namespace().startOf('D').valueOf(),
2559
- lastDate: moment__namespace().endOf('D').valueOf(),
2560
- };
2561
- case 'week':
2562
- return {
2563
- firstDate: moment__namespace().subtract(7, 'd').startOf('D').valueOf(),
2564
- lastDate: moment__namespace().endOf('D').valueOf(),
2565
- };
2566
- default:
2567
- return {
2568
- firstDate: moment__namespace().startOf('D').valueOf(),
2569
- lastDate: moment__namespace().endOf('D').valueOf(),
2570
- };
2571
- }
2129
+ class Product extends ProductBase {
2130
+ static get identifiersFields() {
2131
+ return ['id'];
2572
2132
  }
2573
- formatZip(zip) {
2574
- if (zip.length === 8)
2575
- return zip.substring(0, 5) + '-' + zip.substring(5, 8);
2576
- return zip;
2133
+ }
2134
+ tslib_1.__decorate([
2135
+ classTransformer.Type(() => CategoryForProduct),
2136
+ tslib_1.__metadata("design:type", CategoryForProduct)
2137
+ ], Product.prototype, "category", void 0);
2138
+ tslib_1.__decorate([
2139
+ classTransformer.Type(() => KitProduct),
2140
+ tslib_1.__metadata("design:type", Array)
2141
+ ], Product.prototype, "kitProducts", void 0);
2142
+
2143
+ class Variant extends BaseModel {
2144
+ static get identifiersFields() {
2145
+ return ['id', 'productId'];
2577
2146
  }
2578
2147
  }
2579
2148
 
2580
- class GlampointsPaymentService {
2581
- pay(checkout) {
2582
- const payment = {
2583
- createdAt: new Date(),
2584
- updatedAt: new Date(),
2585
- userId: checkout.user.id,
2586
- checkoutId: checkout.id,
2587
- totalPrice: checkout.totalPrice,
2588
- transaction: {
2589
- amount: 0,
2590
- acquirerResponseCode: '0000',
2591
- acquirerName: 'glampoints',
2592
- authorizedAmount: 0,
2593
- captureMethod: 'ecommerce',
2594
- installments: 1,
2595
- cost: 0,
2596
- paidAmount: 0,
2597
- paymentMethod: 'glampoints',
2598
- referer: 'api_key',
2599
- refundedAmount: 0,
2600
- status: 'paid',
2601
- statusReason: 'acquirer',
2602
- },
2603
- };
2604
- return Promise.resolve(payment);
2149
+ class Wishlist extends Category {
2150
+ static get identifiersFields() {
2151
+ return ['id'];
2605
2152
  }
2606
2153
  }
2607
2154
 
2608
- class PagarmeBankSlipService {
2609
- constructor(credentials) {
2610
- this.credentials = credentials;
2611
- }
2612
- async pay(checkout) {
2613
- try {
2614
- const result = await axios__default["default"]({
2615
- method: 'POST',
2616
- url: this.credentials.URL_TRANSACTION,
2617
- data: this.createBoletoPayment(checkout),
2618
- });
2619
- if (result.data.status !== 'processing') {
2620
- console.log('Erro ao gerar o boleto para o checkout: ');
2621
- return Promise.reject(new Error(`Erro ao gerar o boleto para o checkout: ${checkout.id}`));
2622
- }
2623
- const payment = {
2624
- createdAt: new Date(),
2625
- updatedAt: new Date(),
2626
- userId: checkout.user.id,
2627
- checkoutId: checkout.id,
2628
- totalPrice: checkout.totalPrice,
2629
- transaction: result.data,
2630
- };
2631
- return payment;
2632
- }
2633
- catch (error) {
2634
- console.log(error);
2635
- }
2155
+ class Buy2Win extends BaseModel {
2156
+ static get identifiersFields() {
2157
+ return ['id'];
2636
2158
  }
2637
- createBoletoPayment(checkout) {
2638
- return {
2639
- api_key: this.credentials.API_KEY,
2640
- amount: Math.floor(checkout.totalPrice * 100),
2641
- boleto_rules: ['strict_expiration_date'],
2642
- boleto_instructions: 'Sr. Caixa, NÃO aceitar o pagamento após o vencimento.',
2643
- boleto_expiration_date: moment__namespace().add(3, 'day').format('YYYY-MM-DD'),
2644
- payment_method: 'boleto',
2645
- postback_url: this.credentials.URL_POSTBACK,
2646
- customer: {
2647
- external_id: checkout.user.id,
2648
- type: 'individual',
2649
- country: 'br',
2650
- name: checkout.user.displayName,
2651
- documents: [
2652
- {
2653
- type: 'cpf',
2654
- number: checkout.user.cpf,
2655
- },
2656
- ],
2657
- },
2658
- };
2159
+ }
2160
+ tslib_1.__decorate([
2161
+ classTransformer.Type(() => Category),
2162
+ tslib_1.__metadata("design:type", Array)
2163
+ ], Buy2Win.prototype, "categories", void 0);
2164
+
2165
+ class CampaignDashboard extends BaseModel {
2166
+ static get identifiersFields() {
2167
+ return ['id'];
2659
2168
  }
2660
2169
  }
2661
2170
 
2662
- class PagarmeCardService {
2663
- constructor(credentials) {
2664
- this.credentials = credentials;
2665
- }
2666
- async pay(checkout, card) {
2667
- try {
2668
- const result = await axios__default["default"]({
2669
- method: 'POST',
2670
- url: this.credentials.URL_TRANSACTION,
2671
- data: this.createCardPayment(checkout, card),
2672
- });
2673
- if (result.data.status !== 'paid') {
2674
- this.checkoutAntiFraudService.createBlockedOrderOrPayment(checkout, 'Card not authorized', 'Card', 'day', card);
2675
- return Promise.reject(new Error(`Seu pagamento com cartão não foi autorizado. Para não perder seus produtos, pague com PIX ou outro cartão de crédito`));
2676
- }
2677
- const payment = {
2678
- createdAt: new Date(),
2679
- updatedAt: new Date(),
2680
- userId: checkout.user.id,
2681
- checkoutId: checkout.id,
2682
- totalPrice: checkout.totalPrice,
2683
- transaction: result.data,
2684
- };
2685
- return payment;
2686
- }
2687
- catch (error) {
2688
- console.log(error);
2689
- }
2690
- }
2691
- addCard() {
2692
- throw new Error('Method not implemented.');
2693
- }
2694
- createCardPayment(checkout, card) {
2695
- var _a, _b, _c, _d, _e, _f;
2696
- return {
2697
- api_key: this.credentials.API_KEY,
2698
- amount: Math.floor(checkout.totalPrice * 100),
2699
- card_id: card.cardId,
2700
- payment_method: 'credit_card',
2701
- installments: card.installments,
2702
- soft_descriptor: checkout.shop,
2703
- customer: {
2704
- external_id: checkout.user.id,
2705
- name: checkout.user.displayName,
2706
- type: 'individual',
2707
- country: 'br',
2708
- email: checkout.user.email,
2709
- phone_numbers: checkout.user.phone ? ['+55' + checkout.user.phone] : '',
2710
- documents: [
2711
- {
2712
- type: 'cpf',
2713
- number: checkout.user.cpf,
2714
- },
2715
- ],
2716
- },
2717
- billing: {
2718
- name: checkout.user.displayName,
2719
- address: {
2720
- country: 'br',
2721
- state: checkout.billingAddress ? checkout.billingAddress.state : (_a = checkout.shippingAddress) === null || _a === void 0 ? void 0 : _a.state,
2722
- city: checkout.billingAddress ? checkout.billingAddress.city : (_b = checkout.shippingAddress) === null || _b === void 0 ? void 0 : _b.city,
2723
- neighborhood: checkout.billingAddress ? checkout.billingAddress.district : (_c = checkout.shippingAddress) === null || _c === void 0 ? void 0 : _c.district,
2724
- street: checkout.billingAddress ? checkout.billingAddress.street : (_d = checkout.shippingAddress) === null || _d === void 0 ? void 0 : _d.street,
2725
- street_number: checkout.billingAddress ? checkout.billingAddress.number : (_e = checkout.shippingAddress) === null || _e === void 0 ? void 0 : _e.number,
2726
- zipcode: checkout.billingAddress
2727
- ? checkout.billingAddress.zip.replace('-', '')
2728
- : (_f = checkout.shippingAddress) === null || _f === void 0 ? void 0 : _f.zip.replace('-', ''),
2729
- },
2730
- },
2731
- items: checkout.lineItems.map((item) => {
2732
- return {
2733
- id: item.id,
2734
- title: checkout.user.isSubscriber ? `${item.name} - ASSINANTE` : item.name,
2735
- unit_price: Math.floor(item.pricePaid * 100),
2736
- quantity: item.quantity,
2737
- tangible: true,
2738
- };
2739
- }),
2740
- };
2171
+ class CampaignHashtag extends BaseModel {
2172
+ static get identifiersFields() {
2173
+ return ['id'];
2741
2174
  }
2742
2175
  }
2743
2176
 
2744
- class PagarmePixService {
2745
- constructor(credentials) {
2746
- this.credentials = credentials;
2177
+ class LineItem extends Product {
2178
+ }
2179
+
2180
+ class ShippingMethod extends BaseModel {
2181
+ static get identifiersFields() {
2182
+ return ['id'];
2747
2183
  }
2748
- async pay(checkout) {
2749
- try {
2750
- const result = await axios__default["default"]({
2751
- method: 'POST',
2752
- url: this.credentials.URL_TRANSACTION,
2753
- data: this.createPixPayment(checkout),
2754
- });
2755
- const payment = {
2756
- createdAt: new Date(),
2757
- updatedAt: new Date(),
2758
- userId: checkout.user.id,
2759
- checkoutId: checkout.id,
2760
- totalPrice: checkout.totalPrice,
2761
- transaction: result.data,
2762
- };
2763
- return payment;
2764
- }
2765
- catch (error) {
2766
- console.log(error);
2767
- }
2184
+ }
2185
+
2186
+ class Checkout extends BaseModel {
2187
+ static get identifiersFields() {
2188
+ return ['id'];
2768
2189
  }
2769
- createPixPayment(checkout) {
2770
- return {
2771
- payment_method: 'pix',
2772
- amount: Math.floor(checkout.totalPrice * 100),
2773
- api_key: this.credentials.API_KEY,
2774
- postback_url: this.credentials.URL_POSTBACK,
2775
- pix_expiration_date: moment__namespace().add(1, 'day').format('YYYY-MM-DD'),
2776
- customer: {
2777
- external_id: checkout.user.id,
2778
- type: 'individual',
2779
- country: 'br',
2780
- name: checkout.user.displayName,
2781
- email: checkout.user.email.trim(),
2782
- phone_numbers: checkout.user.phone ? ['+55' + checkout.user.phone] : '',
2783
- documents: [
2784
- {
2785
- type: 'cpf',
2786
- number: checkout.user.cpf,
2787
- },
2788
- ],
2789
- },
2790
- };
2190
+ }
2191
+ tslib_1.__decorate([
2192
+ classTransformer.Type(() => LineItem),
2193
+ tslib_1.__metadata("design:type", Array)
2194
+ ], Checkout.prototype, "lineItems", void 0);
2195
+ tslib_1.__decorate([
2196
+ classTransformer.Type(() => User),
2197
+ tslib_1.__metadata("design:type", User)
2198
+ ], Checkout.prototype, "user", void 0);
2199
+ tslib_1.__decorate([
2200
+ classTransformer.Type(() => UserAddress),
2201
+ tslib_1.__metadata("design:type", UserAddress)
2202
+ ], Checkout.prototype, "shippingAddress", void 0);
2203
+ tslib_1.__decorate([
2204
+ classTransformer.Type(() => UserAddress),
2205
+ tslib_1.__metadata("design:type", UserAddress)
2206
+ ], Checkout.prototype, "billingAddress", void 0);
2207
+ tslib_1.__decorate([
2208
+ classTransformer.Type(() => ShippingMethod),
2209
+ tslib_1.__metadata("design:type", ShippingMethod)
2210
+ ], Checkout.prototype, "shipping", void 0);
2211
+ tslib_1.__decorate([
2212
+ classTransformer.Type(() => Coupon),
2213
+ tslib_1.__metadata("design:type", Coupon)
2214
+ ], Checkout.prototype, "coupon", void 0);
2215
+
2216
+ exports.OrderStatus = void 0;
2217
+ (function (OrderStatus) {
2218
+ OrderStatus["AGUARDANDO_PAGAMENTO"] = "Aguardando pagamento";
2219
+ OrderStatus["EM_PREPARO"] = "Preparando pedido";
2220
+ OrderStatus["NF_EMITIDA"] = "Nota Fiscal Emitida";
2221
+ OrderStatus["AGUARDANDO_ENVIO"] = "Aguardando Transaportadora";
2222
+ OrderStatus["ENVIADO"] = "Enviado";
2223
+ OrderStatus["ENTREGUE"] = "Entregue";
2224
+ OrderStatus["CANCELADO"] = "Cancelado";
2225
+ OrderStatus["CREDIT_CARD"] = "credit_card";
2226
+ })(exports.OrderStatus || (exports.OrderStatus = {}));
2227
+
2228
+ class Order extends Checkout {
2229
+ }
2230
+ tslib_1.__decorate([
2231
+ classTransformer.Type(() => Payment),
2232
+ tslib_1.__metadata("design:type", Payment)
2233
+ ], Order.prototype, "payment", void 0);
2234
+
2235
+ class CheckoutSubscription extends BaseModel {
2236
+ static get identifiersFields() {
2237
+ return ['id'];
2791
2238
  }
2792
- }
2239
+ }
2240
+ tslib_1.__decorate([
2241
+ classTransformer.Type(() => UserAddress),
2242
+ tslib_1.__metadata("design:type", UserAddress)
2243
+ ], CheckoutSubscription.prototype, "shippingAddress", void 0);
2244
+ tslib_1.__decorate([
2245
+ classTransformer.Type(() => UserAddress),
2246
+ tslib_1.__metadata("design:type", UserAddress)
2247
+ ], CheckoutSubscription.prototype, "billingAddress", void 0);
2248
+ tslib_1.__decorate([
2249
+ classTransformer.Type(() => SubscriptionPlan),
2250
+ tslib_1.__metadata("design:type", SubscriptionPlan)
2251
+ ], CheckoutSubscription.prototype, "subscriptionPlan", void 0);
2252
+ tslib_1.__decorate([
2253
+ classTransformer.Type(() => Coupon),
2254
+ tslib_1.__metadata("design:type", Coupon)
2255
+ ], CheckoutSubscription.prototype, "coupon", void 0);
2793
2256
 
2794
2257
  class RoundProductPricesHelper {
2795
2258
  static roundProductPrices(product) {
@@ -2805,12 +2268,6 @@ class RoundProductPricesHelper {
2805
2268
  }
2806
2269
  }
2807
2270
 
2808
- class Sequence extends BaseModel {
2809
- static get identifiersFields() {
2810
- return ['id'];
2811
- }
2812
- }
2813
-
2814
2271
  exports.FilterType = void 0;
2815
2272
  (function (FilterType) {
2816
2273
  FilterType["ACCESSORY_IMPORTANCE"] = "accessoryImportance";
@@ -3325,7 +2782,7 @@ const withFindFirestore = (MixinBase) => {
3325
2782
  const collection = this.collection(this.buildCollectionPathForFind(find.filters));
3326
2783
  const enableCount = (_b = (_a = find === null || find === void 0 ? void 0 : find.options) === null || _a === void 0 ? void 0 : _a.enableCount) !== null && _b !== void 0 ? _b : true;
3327
2784
  const intercepted = await ((_d = (_c = this.interceptors) === null || _c === void 0 ? void 0 : _c.request) === null || _d === void 0 ? void 0 : _d.call(_c, { find }));
3328
- const { filters, limits, orderBy } = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.find) || find;
2785
+ const { filters, limits, orderBy } = intercepted.find || find;
3329
2786
  const queries = this.makeFirestoreWhere(filters || {});
3330
2787
  const ordination = this.makeFirestoreOrderBy(filters, orderBy);
3331
2788
  const offsets = await this.defineLimits(filters, limits);
@@ -3483,6 +2940,139 @@ const withCrudFirestore = (MixinBase) => {
3483
2940
  };
3484
2941
  };
3485
2942
 
2943
+ class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2944
+ constructor({ firestore, interceptors }) {
2945
+ super({
2946
+ firestore,
2947
+ collectionName: 'leads',
2948
+ model: Lead,
2949
+ interceptors,
2950
+ });
2951
+ }
2952
+ }
2953
+
2954
+ class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
2955
+ constructor({ firestore, interceptors }, parentRepository) {
2956
+ super({
2957
+ firestore,
2958
+ collectionName: 'editions',
2959
+ parentIdField: 'subscriptionId',
2960
+ model: Edition,
2961
+ interceptors,
2962
+ });
2963
+ this.parentRepository = parentRepository;
2964
+ }
2965
+ }
2966
+
2967
+ class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2968
+ constructor({ firestore, interceptors, }) {
2969
+ super({
2970
+ firestore,
2971
+ collectionName: 'subscription',
2972
+ model: Subscription,
2973
+ interceptors,
2974
+ });
2975
+ }
2976
+ }
2977
+
2978
+ class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
2979
+ constructor({ firestore, interceptors }, parentRepository) {
2980
+ super({
2981
+ firestore,
2982
+ collectionName: 'payments',
2983
+ parentIdField: 'subscriptionId',
2984
+ model: SubscriptionPayment,
2985
+ interceptors,
2986
+ });
2987
+ this.parentRepository = parentRepository;
2988
+ }
2989
+ }
2990
+
2991
+ class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
2992
+ constructor({ firestore, interceptors }, parentRepository) {
2993
+ super({
2994
+ firestore,
2995
+ collectionName: 'address',
2996
+ parentIdField: 'userId',
2997
+ model: UserAddress,
2998
+ interceptors,
2999
+ });
3000
+ this.parentRepository = parentRepository;
3001
+ }
3002
+ }
3003
+
3004
+ class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3005
+ constructor({ firestore, interceptors }, parentRepository) {
3006
+ super({
3007
+ firestore,
3008
+ collectionName: 'CX',
3009
+ parentIdField: 'userId',
3010
+ model: BeautyProfile,
3011
+ interceptors,
3012
+ });
3013
+ this.parentRepository = parentRepository;
3014
+ }
3015
+ }
3016
+
3017
+ class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3018
+ constructor({ firestore, interceptors }) {
3019
+ super({
3020
+ firestore,
3021
+ collectionName: 'users',
3022
+ model: User,
3023
+ interceptors,
3024
+ });
3025
+ }
3026
+ async get(identifiers) {
3027
+ const user = await super.get({ id: identifiers.id });
3028
+ user.beautyProfile = await this.getBeautyProfile(user.id);
3029
+ user.isSubscriber = await this.checkIfIsSubscriber(user.id);
3030
+ return user;
3031
+ }
3032
+ async checkIfExistsByField(field, value) {
3033
+ const result = await this.find({ filters: { [field]: value } });
3034
+ return result.count > 0;
3035
+ }
3036
+ buildModelInstance() {
3037
+ const { fromFirestore, toFirestore } = super.buildModelInstance();
3038
+ return {
3039
+ toFirestore: (data) => {
3040
+ const plain = toFirestore(data);
3041
+ delete plain.isSubscriber;
3042
+ return plain;
3043
+ },
3044
+ fromFirestore,
3045
+ };
3046
+ }
3047
+ async getBeautyProfile(userId) {
3048
+ const beautyProfile = await firestore.getDoc(firestore.doc(this.collection(`${this.collectionName}/${userId}/CX`).withConverter(this.buildBeautyProfileModelInstance()), 'beautyProfile'));
3049
+ return beautyProfile.data();
3050
+ }
3051
+ async checkIfIsSubscriber(userId) {
3052
+ const docs = await firestore.getDocs(firestore.query(this.collection('subscription'), firestore.where('user.id', '==', userId), firestore.where('status', '==', 'active')));
3053
+ return !!docs && !!docs.size;
3054
+ }
3055
+ buildBeautyProfileModelInstance() {
3056
+ return {
3057
+ toFirestore: (data) => data.toPlain(),
3058
+ fromFirestore: (snap) => BeautyProfile.toInstance(snap.data()),
3059
+ };
3060
+ }
3061
+ }
3062
+
3063
+ class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3064
+ constructor({ firestore, interceptors }, parentRepository) {
3065
+ super({
3066
+ firestore,
3067
+ collectionName: 'payment_method',
3068
+ parentIdField: 'userId',
3069
+ model: UserPaymentMethod,
3070
+ interceptors,
3071
+ });
3072
+ this.parentRepository = parentRepository;
3073
+ }
3074
+ }
3075
+
3486
3076
  class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3487
3077
  constructor({ firestore, interceptors }) {
3488
3078
  super({
@@ -3563,155 +3153,60 @@ class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFires
3563
3153
  },
3564
3154
  });
3565
3155
  return (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
3566
- }
3567
- async fetchReviews(status) {
3568
- const { data: products } = await this.find();
3569
- products.forEach((product) => {
3570
- var _a;
3571
- if ([undefined, 0].includes((_a = product.reviews) === null || _a === void 0 ? void 0 : _a.length))
3572
- return;
3573
- const productInfo = {
3574
- productId: product.id,
3575
- productName: product.name,
3576
- productSku: product.sku,
3577
- };
3578
- this.reviews.pending = [];
3579
- this.reviews.approved = [];
3580
- this.reviews.rejected = [];
3581
- product.reviews.forEach((review) => {
3582
- if ([null, undefined].includes(review.status))
3583
- return this.reviews.pending.push(Object.assign(Object.assign({}, review), productInfo));
3584
- if (review.status === false)
3585
- return this.reviews.rejected.push(Object.assign(Object.assign({}, review), productInfo));
3586
- if (!!review.status)
3587
- return this.reviews.approved.push(Object.assign(Object.assign({}, review), productInfo));
3588
- return review;
3589
- });
3590
- });
3591
- return this.reviews[status];
3592
- }
3593
- cleanShoppingCountFromIds() {
3594
- return;
3595
- }
3596
- findCatalog(params) {
3597
- return this.find(params);
3598
- }
3599
- }
3600
-
3601
- class ProductVariantFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3602
- constructor({ firestore, interceptors }, parentRepository) {
3603
- super({
3604
- firestore,
3605
- collectionName: 'variants',
3606
- parentIdField: 'productId',
3607
- model: Variant,
3608
- interceptors,
3609
- });
3610
- this.parentRepository = parentRepository;
3611
- }
3612
- }
3613
-
3614
- class SubscriptionProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3615
- constructor({ firestore, interceptors }) {
3616
- super({
3617
- firestore,
3618
- collectionName: 'subscriptionProducts',
3619
- model: Product,
3620
- interceptors,
3621
- });
3622
- }
3623
- }
3624
-
3625
- class SequenceFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3626
- constructor({ firestore, interceptors }) {
3627
- super({
3628
- firestore,
3629
- collectionName: 'sequences',
3630
- model: Sequence,
3631
- interceptors,
3632
- });
3633
- }
3634
- }
3635
-
3636
- class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3637
- constructor({ firestore, interceptors }) {
3638
- super({
3639
- firestore,
3640
- collectionName: 'dms',
3641
- model: Home,
3642
- interceptors,
3643
- });
3644
- this.homeCategoryGroupToPlain = (homeCategoryGroup) => {
3645
- var _a, _b, _c;
3646
- return ({
3647
- category: ((_a = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _a === void 0 ? void 0 : _a.toPlain)
3648
- ? (_b = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _b === void 0 ? void 0 : _b.toPlain()
3649
- : homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category,
3650
- products: ((_c = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.products) === null || _c === void 0 ? void 0 : _c.map((product) => ((product === null || product === void 0 ? void 0 : product.toPlain) ? product === null || product === void 0 ? void 0 : product.toPlain() : product)).filter(Boolean)) || [],
3651
- });
3652
- };
3653
- this.plainToHomeCategoryGroup = (homeCategoryGroup) => {
3156
+ }
3157
+ async fetchReviews(status) {
3158
+ const { data: products } = await this.find();
3159
+ products.forEach((product) => {
3654
3160
  var _a;
3655
- return ({
3656
- category: Category.toInstance(homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category),
3657
- products: (_a = homeCategoryGroup.products) === null || _a === void 0 ? void 0 : _a.map((product) => Product.toInstance(product)),
3161
+ if ([undefined, 0].includes((_a = product.reviews) === null || _a === void 0 ? void 0 : _a.length))
3162
+ return;
3163
+ const productInfo = {
3164
+ productId: product.id,
3165
+ productName: product.name,
3166
+ productSku: product.sku,
3167
+ };
3168
+ this.reviews.pending = [];
3169
+ this.reviews.approved = [];
3170
+ this.reviews.rejected = [];
3171
+ product.reviews.forEach((review) => {
3172
+ if ([null, undefined].includes(review.status))
3173
+ return this.reviews.pending.push(Object.assign(Object.assign({}, review), productInfo));
3174
+ if (review.status === false)
3175
+ return this.reviews.rejected.push(Object.assign(Object.assign({}, review), productInfo));
3176
+ if (!!review.status)
3177
+ return this.reviews.approved.push(Object.assign(Object.assign({}, review), productInfo));
3178
+ return review;
3658
3179
  });
3659
- };
3660
- }
3661
- buildModelInstance() {
3662
- const { fromFirestore, toFirestore } = super.buildModelInstance();
3663
- return {
3664
- toFirestore: (data) => {
3665
- const modifiedData = this.homeToFirestore(data);
3666
- return toFirestore(modifiedData);
3667
- },
3668
- fromFirestore: (snap) => {
3669
- const instance = fromFirestore(snap);
3670
- return this.homeFromFirestore(instance);
3671
- },
3672
- };
3180
+ });
3181
+ return this.reviews[status];
3673
3182
  }
3674
- homeToFirestore(home) {
3675
- var _a, _b, _c, _d;
3676
- if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
3677
- home.data.data.discoverProducts = ((_b = home.data.data.discoverProducts) === null || _b === void 0 ? void 0 : _b.map(this.homeCategoryGroupToPlain)) || [];
3678
- home.data.data.featuredProducts = ((_c = home.data.data.featuredProducts) === null || _c === void 0 ? void 0 : _c.map(this.homeCategoryGroupToPlain)) || [];
3679
- home.data.data.verticalProducts = ((_d = home.data.data.verticalProducts) === null || _d === void 0 ? void 0 : _d.map(this.homeCategoryGroupToPlain)) || [];
3680
- }
3681
- return home;
3183
+ cleanShoppingCountFromIds() {
3184
+ return;
3682
3185
  }
3683
- homeFromFirestore(home) {
3684
- var _a;
3685
- if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
3686
- home.data.data.discoverProducts = home.data.data.discoverProducts.map(this.plainToHomeCategoryGroup);
3687
- home.data.data.featuredProducts = home.data.data.featuredProducts.map(this.plainToHomeCategoryGroup);
3688
- home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.plainToHomeCategoryGroup);
3689
- home.data.createdAt =
3690
- home.data.createdAt instanceof firestore.Timestamp ? home.data.createdAt.toDate() : home.data.createdAt;
3691
- home.data.expiresAt =
3692
- home.data.expiresAt instanceof firestore.Timestamp ? home.data.expiresAt.toDate() : home.data.expiresAt;
3693
- }
3694
- return home;
3186
+ findCatalog(params) {
3187
+ return this.find(params);
3695
3188
  }
3696
3189
  }
3697
3190
 
3698
- class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3699
- constructor({ firestore, interceptors }) {
3191
+ class ProductVariantFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3192
+ constructor({ firestore, interceptors }, parentRepository) {
3700
3193
  super({
3701
3194
  firestore,
3702
- collectionName: 'shopMenus',
3703
- model: ShopMenu,
3195
+ collectionName: 'variants',
3196
+ parentIdField: 'productId',
3197
+ model: Variant,
3704
3198
  interceptors,
3705
3199
  });
3200
+ this.parentRepository = parentRepository;
3706
3201
  }
3707
3202
  }
3708
3203
 
3709
- class ShopSettingsFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3710
- constructor({ firestore, interceptors, }) {
3204
+ class SubscriptionProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3205
+ constructor({ firestore, interceptors }) {
3711
3206
  super({
3712
3207
  firestore,
3713
- collectionName: 'shopSettings',
3714
- model: ShopSettings,
3208
+ collectionName: 'subscriptionProducts',
3209
+ model: Product,
3715
3210
  interceptors,
3716
3211
  });
3717
3212
  }
@@ -3847,17 +3342,6 @@ class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
3847
3342
  }
3848
3343
  }
3849
3344
 
3850
- class OrderBlockedFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3851
- constructor({ firestore, interceptors, }) {
3852
- super({
3853
- firestore,
3854
- collectionName: 'paymentBlockedAttempts',
3855
- model: OrderBlocked,
3856
- interceptors,
3857
- });
3858
- }
3859
- }
3860
-
3861
3345
  class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3862
3346
  constructor({ firestore, interceptors }) {
3863
3347
  super({
@@ -3880,136 +3364,87 @@ class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(
3880
3364
  }
3881
3365
  }
3882
3366
 
3883
- class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3367
+ class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3884
3368
  constructor({ firestore, interceptors }) {
3885
3369
  super({
3886
3370
  firestore,
3887
- collectionName: 'leads',
3888
- model: Lead,
3889
- interceptors,
3890
- });
3891
- }
3892
- }
3893
-
3894
- class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3895
- constructor({ firestore, interceptors }, parentRepository) {
3896
- super({
3897
- firestore,
3898
- collectionName: 'editions',
3899
- parentIdField: 'subscriptionId',
3900
- model: Edition,
3901
- interceptors,
3902
- });
3903
- this.parentRepository = parentRepository;
3904
- }
3905
- }
3906
-
3907
- class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3908
- constructor({ firestore, interceptors, }) {
3909
- super({
3910
- firestore,
3911
- collectionName: 'subscription',
3912
- model: Subscription,
3371
+ collectionName: 'dms',
3372
+ model: Home,
3913
3373
  interceptors,
3914
3374
  });
3375
+ this.homeCategoryGroupToPlain = (homeCategoryGroup) => {
3376
+ var _a, _b, _c;
3377
+ return ({
3378
+ category: ((_a = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _a === void 0 ? void 0 : _a.toPlain)
3379
+ ? (_b = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _b === void 0 ? void 0 : _b.toPlain()
3380
+ : homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category,
3381
+ products: ((_c = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.products) === null || _c === void 0 ? void 0 : _c.map((product) => ((product === null || product === void 0 ? void 0 : product.toPlain) ? product === null || product === void 0 ? void 0 : product.toPlain() : product)).filter(Boolean)) || [],
3382
+ });
3383
+ };
3384
+ this.plainToHomeCategoryGroup = (homeCategoryGroup) => {
3385
+ var _a;
3386
+ return ({
3387
+ category: Category.toInstance(homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category),
3388
+ products: (_a = homeCategoryGroup.products) === null || _a === void 0 ? void 0 : _a.map((product) => Product.toInstance(product)),
3389
+ });
3390
+ };
3915
3391
  }
3916
- }
3917
-
3918
- class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3919
- constructor({ firestore, interceptors }, parentRepository) {
3920
- super({
3921
- firestore,
3922
- collectionName: 'payments',
3923
- parentIdField: 'subscriptionId',
3924
- model: SubscriptionPayment,
3925
- interceptors,
3926
- });
3927
- this.parentRepository = parentRepository;
3392
+ buildModelInstance() {
3393
+ const { fromFirestore, toFirestore } = super.buildModelInstance();
3394
+ return {
3395
+ toFirestore: (data) => {
3396
+ const modifiedData = this.homeToFirestore(data);
3397
+ return toFirestore(modifiedData);
3398
+ },
3399
+ fromFirestore: (snap) => {
3400
+ const instance = fromFirestore(snap);
3401
+ return this.homeFromFirestore(instance);
3402
+ },
3403
+ };
3928
3404
  }
3929
- }
3930
-
3931
- class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3932
- constructor({ firestore, interceptors }, parentRepository) {
3933
- super({
3934
- firestore,
3935
- collectionName: 'address',
3936
- parentIdField: 'userId',
3937
- model: UserAddress,
3938
- interceptors,
3939
- });
3940
- this.parentRepository = parentRepository;
3405
+ homeToFirestore(home) {
3406
+ var _a, _b, _c, _d;
3407
+ if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
3408
+ home.data.data.discoverProducts = ((_b = home.data.data.discoverProducts) === null || _b === void 0 ? void 0 : _b.map(this.homeCategoryGroupToPlain)) || [];
3409
+ home.data.data.featuredProducts = ((_c = home.data.data.featuredProducts) === null || _c === void 0 ? void 0 : _c.map(this.homeCategoryGroupToPlain)) || [];
3410
+ home.data.data.verticalProducts = ((_d = home.data.data.verticalProducts) === null || _d === void 0 ? void 0 : _d.map(this.homeCategoryGroupToPlain)) || [];
3411
+ }
3412
+ return home;
3941
3413
  }
3942
- }
3943
-
3944
- class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3945
- constructor({ firestore, interceptors }, parentRepository) {
3946
- super({
3947
- firestore,
3948
- collectionName: 'CX',
3949
- parentIdField: 'userId',
3950
- model: BeautyProfile,
3951
- interceptors,
3952
- });
3953
- this.parentRepository = parentRepository;
3414
+ homeFromFirestore(home) {
3415
+ var _a;
3416
+ if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
3417
+ home.data.data.discoverProducts = home.data.data.discoverProducts.map(this.plainToHomeCategoryGroup);
3418
+ home.data.data.featuredProducts = home.data.data.featuredProducts.map(this.plainToHomeCategoryGroup);
3419
+ home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.plainToHomeCategoryGroup);
3420
+ home.data.createdAt =
3421
+ home.data.createdAt instanceof firestore.Timestamp ? home.data.createdAt.toDate() : home.data.createdAt;
3422
+ home.data.expiresAt =
3423
+ home.data.expiresAt instanceof firestore.Timestamp ? home.data.expiresAt.toDate() : home.data.expiresAt;
3424
+ }
3425
+ return home;
3954
3426
  }
3955
3427
  }
3956
3428
 
3957
- class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3429
+ class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3958
3430
  constructor({ firestore, interceptors }) {
3959
3431
  super({
3960
3432
  firestore,
3961
- collectionName: 'users',
3962
- model: User,
3433
+ collectionName: 'shopMenus',
3434
+ model: ShopMenu,
3963
3435
  interceptors,
3964
3436
  });
3965
3437
  }
3966
- async get(identifiers) {
3967
- const user = await super.get({ id: identifiers.id });
3968
- user.beautyProfile = await this.getBeautyProfile(user.id);
3969
- user.isSubscriber = await this.checkIfIsSubscriber(user.id);
3970
- return user;
3971
- }
3972
- async checkIfExistsByField(field, value) {
3973
- const result = await this.find({ filters: { [field]: value } });
3974
- return result.count > 0;
3975
- }
3976
- buildModelInstance() {
3977
- const { fromFirestore, toFirestore } = super.buildModelInstance();
3978
- return {
3979
- toFirestore: (data) => {
3980
- const plain = toFirestore(data);
3981
- delete plain.isSubscriber;
3982
- return plain;
3983
- },
3984
- fromFirestore,
3985
- };
3986
- }
3987
- async getBeautyProfile(userId) {
3988
- const beautyProfile = await firestore.getDoc(firestore.doc(this.collection(`${this.collectionName}/${userId}/CX`).withConverter(this.buildBeautyProfileModelInstance()), 'beautyProfile'));
3989
- return beautyProfile.data();
3990
- }
3991
- async checkIfIsSubscriber(userId) {
3992
- const docs = await firestore.getDocs(firestore.query(this.collection('subscription'), firestore.where('user.id', '==', userId), firestore.where('status', '==', 'active')));
3993
- return !!docs && !!docs.size;
3994
- }
3995
- buildBeautyProfileModelInstance() {
3996
- return {
3997
- toFirestore: (data) => data.toPlain(),
3998
- fromFirestore: (snap) => BeautyProfile.toInstance(snap.data()),
3999
- };
4000
- }
4001
3438
  }
4002
3439
 
4003
- class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
4004
- constructor({ firestore, interceptors }, parentRepository) {
3440
+ class ShopSettingsFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3441
+ constructor({ firestore, interceptors, }) {
4005
3442
  super({
4006
3443
  firestore,
4007
- collectionName: 'payment_method',
4008
- parentIdField: 'userId',
4009
- model: UserPaymentMethod,
3444
+ collectionName: 'shopSettings',
3445
+ model: ShopSettings,
4010
3446
  interceptors,
4011
3447
  });
4012
- this.parentRepository = parentRepository;
4013
3448
  }
4014
3449
  }
4015
3450
 
@@ -6212,8 +5647,6 @@ Object.defineProperty(exports, 'unset', {
6212
5647
  get: function () { return lodash.unset; }
6213
5648
  });
6214
5649
  exports.Address = Address;
6215
- exports.AdyenCardService = AdyenCardService;
6216
- exports.AdyenPaymentMethodFactory = AdyenPaymentMethodFactory;
6217
5650
  exports.Authentication = Authentication;
6218
5651
  exports.AuthenticationFirebaseAuthService = AuthenticationFirebaseAuthService;
6219
5652
  exports.AxiosAdapter = AxiosAdapter;
@@ -6238,7 +5671,6 @@ exports.CategoryFirestoreRepository = CategoryFirestoreRepository;
6238
5671
  exports.CategoryHasuraGraphQL = CategoryHasuraGraphQL;
6239
5672
  exports.CategoryHasuraGraphQLRepository = CategoryHasuraGraphQLRepository;
6240
5673
  exports.Checkout = Checkout;
6241
- exports.CheckoutAntiFraudService = CheckoutAntiFraudService;
6242
5674
  exports.CheckoutFirestoreRepository = CheckoutFirestoreRepository;
6243
5675
  exports.CheckoutSubscription = CheckoutSubscription;
6244
5676
  exports.CheckoutSubscriptionFirestoreRepository = CheckoutSubscriptionFirestoreRepository;
@@ -6254,8 +5686,6 @@ exports.Filter = Filter;
6254
5686
  exports.FilterHasuraGraphQLRepository = FilterHasuraGraphQLRepository;
6255
5687
  exports.FilterOption = FilterOption;
6256
5688
  exports.FilterOptionHasuraGraphQLRepository = FilterOptionHasuraGraphQLRepository;
6257
- exports.GlampointsPaymentMethodFactory = GlampointsPaymentMethodFactory;
6258
- exports.GlampointsPaymentService = GlampointsPaymentService;
6259
5689
  exports.Home = Home;
6260
5690
  exports.HomeFirestoreRepository = HomeFirestoreRepository;
6261
5691
  exports.InvalidArgumentError = InvalidArgumentError;
@@ -6269,17 +5699,9 @@ exports.Log = Log;
6269
5699
  exports.Logger = Logger;
6270
5700
  exports.NotFoundError = NotFoundError;
6271
5701
  exports.Order = Order;
6272
- exports.OrderBlocked = OrderBlocked;
6273
- exports.OrderBlockedFirestoreRepository = OrderBlockedFirestoreRepository;
6274
5702
  exports.OrderFirestoreRepository = OrderFirestoreRepository;
6275
- exports.PagarmeBankSlipService = PagarmeBankSlipService;
6276
- exports.PagarmeCardService = PagarmeCardService;
6277
- exports.PagarmePaymentMethodFactory = PagarmePaymentMethodFactory;
6278
- exports.PagarmePixService = PagarmePixService;
6279
5703
  exports.Payment = Payment;
6280
5704
  exports.PaymentFirestoreRepository = PaymentFirestoreRepository;
6281
- exports.PaymentProviderFactory = PaymentProviderFactory;
6282
- exports.PaymentTransaction = PaymentTransaction;
6283
5705
  exports.Product = Product;
6284
5706
  exports.ProductFirestoreRepository = ProductFirestoreRepository;
6285
5707
  exports.ProductHasuraGraphQL = ProductHasuraGraphQL;
@@ -6292,8 +5714,6 @@ exports.Register = Register;
6292
5714
  exports.RegisterFirebaseAuthService = RegisterFirebaseAuthService;
6293
5715
  exports.RequiredArgumentError = RequiredArgumentError;
6294
5716
  exports.RoundProductPricesHelper = RoundProductPricesHelper;
6295
- exports.Sequence = Sequence;
6296
- exports.SequenceFirestoreRepository = SequenceFirestoreRepository;
6297
5717
  exports.ShippingMethod = ShippingMethod;
6298
5718
  exports.ShopMenu = ShopMenu;
6299
5719
  exports.ShopMenuFirestoreRepository = ShopMenuFirestoreRepository;